EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
File containing the implementation of the pcap service utilities. More...
#include <pcap.h>
#include "pcap_service.h"
#include "../utils/allocs.h"
#include "../utils/log.h"
#include "../utils/net.h"
#include "../utils/os.h"
Macros | |
#define | PCAP_SNAPSHOT_LENGTH 65535 |
#define | PCAP_BUFFER_SIZE 64 * 1024 |
Functions | |
int | find_device (char *ifname, bpf_u_int32 *net, bpf_u_int32 *mask) |
void | receive_pcap_packet (u_char *args, const struct pcap_pkthdr *header, const u_char *packet) |
int | capture_pcap_packet (struct pcap_context *ctx) |
Captures a pcap packet. More... | |
void | close_pcap (struct pcap_context *ctx) |
Closes the pcap service. More... | |
int | capture_pcap_start (struct pcap_context *ctx) |
Starts the blocking pcap loop. More... | |
void | capture_pcap_stop (struct pcap_context *ctx) |
Stops the blocking pcap loop. More... | |
int | get_pcap_datalink (struct pcap_context *ctx) |
Get the pcap config datalink value. More... | |
int | run_pcap (char *interface, bool immediate, bool promiscuous, int timeout, char *filter, bool nonblock, capture_callback_fn pcap_fn, void *fn_ctx, struct pcap_context **pctx) |
Executes the libpcap service. More... | |
int | dump_file_pcap (struct pcap_context *ctx, char *file_path, struct pcap_pkthdr *header, uint8_t *packet) |
Saves a packet packet into file. More... | |
int | get_pcap_stats (const struct pcap_context *ctx, struct pcap_stat *ps) |
Return pcap capture statistics. More... | |
int | inject_pcap (struct pcap_context *ctx, uint8_t *packet, size_t size) |
Injects a packets. More... | |
void | free_pcap_list (UT_array *ctx_list) |
Frees a pcap list. More... | |
UT_array * | create_pcap_list (void) |
Creates a pcap list. More... | |
File containing the implementation of the pcap service utilities.
#define PCAP_BUFFER_SIZE 64 * 1024 |
#define PCAP_SNAPSHOT_LENGTH 65535 |
int capture_pcap_packet | ( | struct pcap_context * | ctx | ) |
Captures a pcap packet.
ctx | The pcap context structure |
int capture_pcap_start | ( | struct pcap_context * | ctx | ) |
Starts the blocking pcap loop.
ctx | The pcap context |
void capture_pcap_stop | ( | struct pcap_context * | ctx | ) |
Stops the blocking pcap loop.
ctx | The pcap context |
void close_pcap | ( | struct pcap_context * | ctx | ) |
Closes the pcap service.
ctx | The pcap context |
UT_array* create_pcap_list | ( | void | ) |
Creates a pcap list.
int dump_file_pcap | ( | struct pcap_context * | ctx, |
char * | file_path, | ||
struct pcap_pkthdr * | header, | ||
uint8_t * | packet | ||
) |
Saves a packet packet into file.
ctx | The pcap context |
file_path | The file path to save the packet |
header | The packet header |
packet | The packet data |
int find_device | ( | char * | ifname, |
bpf_u_int32 * | net, | ||
bpf_u_int32 * | mask | ||
) |
void free_pcap_list | ( | UT_array * | ctx_list | ) |
Frees a pcap list.
ctx_list | The pcap list |
int get_pcap_datalink | ( | struct pcap_context * | ctx | ) |
Get the pcap config datalink value.
ctx | The pcap context |
int get_pcap_stats | ( | const struct pcap_context * | ctx, |
struct pcap_stat * | ps | ||
) |
Return pcap capture statistics.
ctx[in] | The pcap context |
ps[out] | The pcap_stat structure |
int inject_pcap | ( | struct pcap_context * | ctx, |
uint8_t * | packet, | ||
size_t | size | ||
) |
Injects a packets.
ctx | The pcap context |
packet | The packet data |
size | The packet size |
void receive_pcap_packet | ( | u_char * | args, |
const struct pcap_pkthdr * | header, | ||
const u_char * | packet | ||
) |
int run_pcap | ( | char * | interface, |
bool | immediate, | ||
bool | promiscuous, | ||
int | timeout, | ||
char * | filter, | ||
bool | nonblock, | ||
capture_callback_fn | pcap_fn, | ||
void * | fn_ctx, | ||
struct pcap_context ** | pctx | ||
) |
Executes the libpcap service.
interface | The capture interface |
immediate | The immediate mode flag |
promiscuous | The promiscuous mode flag |
timeout | The timeout (in milliseconds) |
filter | The capture filter string |
nonblock | Sets the capture to nonblocking mode |
pcap_fn | The pcap capture callback |
fn_ctx | The context for callback function |
pctx | The returned pcap context |