nmsg
0.9.0
|
Reassembled IP datagram interface to libpcap. More...
Go to the source code of this file.
Enumerations | |
enum | nmsg_pcap_type { nmsg_pcap_type_file, nmsg_pcap_type_live } |
Functions | |
nmsg_pcap_t | nmsg_pcap_input_open (pcap_t *phandle) |
Initialize a new nmsg_pcap_t input from a libpcap source. More... | |
nmsg_res | nmsg_pcap_input_close (nmsg_pcap_t *pcap) |
Close an nmsg_pcap_t object and release all associated resources. More... | |
nmsg_res | nmsg_pcap_input_read (nmsg_pcap_t pcap, struct nmsg_ipdg *dg, struct timespec *ts) |
Read an IP datagram from an nmsg_pcap_t input, performing reassembly if necessary. More... | |
nmsg_res | nmsg_pcap_input_read_raw (nmsg_pcap_t pcap, struct pcap_pkthdr **pkt_hdr, const uint8_t **pkt_data, struct timespec *ts) |
Read a raw packet from an nmsg_pcap_t input. More... | |
nmsg_res | nmsg_pcap_input_setfilter (nmsg_pcap_t pcap, const char *bpfstr) |
Set a bpf filter on an nmsg_pcap_t object. More... | |
nmsg_res | nmsg_pcap_input_setfilter_raw (nmsg_pcap_t pcap, const char *bpfstr) |
Set a bpf filter on an nmsg_pcap_t object. More... | |
void | nmsg_pcap_input_set_raw (nmsg_pcap_t pcap, bool raw) |
Set raw mode. More... | |
int | nmsg_pcap_snapshot (nmsg_pcap_t pcap) |
Get the snapshot length of the underlying pcap handle. More... | |
nmsg_pcap_type | nmsg_pcap_get_type (nmsg_pcap_t pcap) |
Get the type of the underlying pcap handle. More... | |
int | nmsg_pcap_get_datalink (nmsg_pcap_t pcap) |
Get the datalink type of the underlying pcap handle. More... | |
bool | nmsg_pcap_filter (nmsg_pcap_t pcap, const uint8_t *pkt, size_t len) |
Return the result of filtering a packet. More... | |
Reassembled IP datagram interface to libpcap.
libpcap's frame-based interface is wrapped with calls to the ipdg.h interface and provides the caller with reassembled IP datagrams.
Callers should not call pcap_setfilter() on the pcap_t handle passed to nmsg_pcap_input_open() but should instead use nmsg_pcap_input_setfilter(). Since IP datagrams are reassembled in userspace, they must undergo reevaluation of the user-provided filter. nmsg_pcap_input_setfilter() and nmsg_pcap_input_read() handle this transparently.
Definition in file pcap_input.h.
nmsg_pcap_t nmsg_pcap_input_open | ( | pcap_t * | phandle | ) |
Initialize a new nmsg_pcap_t input from a libpcap source.
[in] | phandle | pcap_t handle (e.g., acquired from pcap_open_offline() or pcap_open_live()). |
Definition at line 26 of file pcap_input.c.
nmsg_res nmsg_pcap_input_close | ( | nmsg_pcap_t * | pcap | ) |
Close an nmsg_pcap_t object and release all associated resources.
[in] | pcap | pointer to an nmsg_pcap_t object. |
Definition at line 53 of file pcap_input.c.
Read an IP datagram from an nmsg_pcap_t input, performing reassembly if necessary.
[in] | pcap | nmsg_pcap_t object. |
[out] | dg | nmsg_ipdg structure to be filled. |
[out] | ts | timespec structure indicating time of datagram reception. |
Definition at line 70 of file pcap_input.c.
nmsg_res nmsg_pcap_input_read_raw | ( | nmsg_pcap_t | pcap, |
struct pcap_pkthdr ** | pkt_hdr, | ||
const uint8_t ** | pkt_data, | ||
struct timespec * | ts | ||
) |
Read a raw packet from an nmsg_pcap_t input.
[in] | pcap | nmsg_pcap_t object. |
[out] | pkt_hdr | Location to store pcap packet header. |
[out] | pkt_data | Location to store pcap packet data. |
[out] | ts | timespec structure indicating time of packet reception. |
Definition at line 100 of file pcap_input.c.
nmsg_res nmsg_pcap_input_setfilter | ( | nmsg_pcap_t | pcap, |
const char * | bpfstr | ||
) |
Set a bpf filter on an nmsg_pcap_t object.
This function performs additional transformation on the bpf filter text before passing the filter to pcap_compile() and pcap_setfilter().
[in] | pcap | nmsg_pcap_t object. |
[in] | bpfstr | is a valid bpf filter expression that will be passed to pcap_compile(). |
Definition at line 207 of file pcap_input.c.
nmsg_res nmsg_pcap_input_setfilter_raw | ( | nmsg_pcap_t | pcap, |
const char * | bpfstr | ||
) |
Set a bpf filter on an nmsg_pcap_t object.
This function is a thin wrapper for pcap_setfilter().
[in] | pcap | nmsg_pcap_t object. |
[in] | bpfstr | is a valid bpf filter expression that will be passed to pcap_compile() and pcap_setfilter(). |
Definition at line 132 of file pcap_input.c.
void nmsg_pcap_input_set_raw | ( | nmsg_pcap_t | pcap, |
bool | raw | ||
) |
Set raw mode.
[in] | pcap | nmsg_pcap_t object. |
[in] | raw | True if raw packets should be passed, false if reassembled datagrams should be passed. |
Definition at line 127 of file pcap_input.c.
int nmsg_pcap_snapshot | ( | nmsg_pcap_t | pcap | ) |
Get the snapshot length of the underlying pcap handle.
[in] | pcap | nmsg_pcap_t object. |
Definition at line 336 of file pcap_input.c.
nmsg_pcap_type nmsg_pcap_get_type | ( | nmsg_pcap_t | pcap | ) |
Get the type of the underlying pcap handle.
[in] | pcap | nmsg_pcap_t object. |
Definition at line 341 of file pcap_input.c.
int nmsg_pcap_get_datalink | ( | nmsg_pcap_t | pcap | ) |
Get the datalink type of the underlying pcap handle.
[in] | pcap | nmsg_pcap_t object. |
Definition at line 346 of file pcap_input.c.
bool nmsg_pcap_filter | ( | nmsg_pcap_t | pcap, |
const uint8_t * | pkt, | ||
size_t | len | ||
) |
Return the result of filtering a packet.
[in] | pcap | nmsg_pcap_t object. |
[in] | pkt | Pointer to start of network packet. |
[in] | len | Length of packet. |
Definition at line 351 of file pcap_input.c.