nmsg 1.1.2
|
IP datagram parsing functions. More...
Go to the source code of this file.
Data Structures | |
struct | nmsg_ipdg |
Parsed IP datagram. More... | |
Functions | |
nmsg_res | nmsg_ipdg_parse (struct nmsg_ipdg *dg, unsigned etype, size_t len, const u_char *pkt) |
Parse IP packets from the network layer, discarding fragments. | |
nmsg_res | nmsg_ipdg_parse_pcap (struct nmsg_ipdg *dg, nmsg_pcap_t pcap, struct pcap_pkthdr *pkt_hdr, const u_char *pkt) |
Parse IP datagrams from the data link layer, performing reassembly if necessary. | |
nmsg_res | nmsg_ipdg_parse_pcap_raw (struct nmsg_ipdg *dg, int datalink, const uint8_t *pkt, size_t len) |
Like nmsg_ipdg_parse_pcap(), but performs no fragment handling. | |
IP datagram parsing functions.
These functions parse network packets or ethernet frames and return IP datagrams, performing reassembly if requested. Non-IP packets are discarded.
Definition in file ipdg.h.
Parse IP packets from the network layer, discarding fragments.
Populate a struct nmsg_ipdg indicating where the network, transport, and payload sections of the packet are and the length of the remaining packet at each of those sections.
This function operates on datagrams from the network layer.
Broken and fragmented datagrams are discarded.
[out] | dg | caller-allocated struct nmsg_ipdg which will be populated after a successful call. |
[in] | etype | ETHERTYPE_* value. The only supported values are ETHERTYPE_IP and ETHERTYPE_IPV6. |
[in] | len | length of the packet. |
[in] | pkt | pointer to the packet. |
nmsg_res nmsg_ipdg_parse_pcap | ( | struct nmsg_ipdg * | dg, |
nmsg_pcap_t | pcap, | ||
struct pcap_pkthdr * | pkt_hdr, | ||
const u_char * | pkt | ||
) |
Parse IP datagrams from the data link layer, performing reassembly if necessary.
Populate a struct nmsg_ipdg indicating where the network, transport, and payload sections of the datagram are and the length of the remaining packet at each of those sections.
This function operates on raw frames returned by libpcap from the data link layer. The packet beginning at 'pkt' must match the datalink type associated with 'pcap' and must be pkt_hdr->caplen octets long.
libpcap data link types DLT_EN10MB, DLT_RAW, and DLT_LINUX_SLL are supported.
Broken packets are discarded. All but the final fragment of a fragmented datagram are stored internally and nmsg_res_again is returned.
[out] | dg | caller-allocated struct nmsg_ipdg which will be populated after a successful call. |
[in] | pcap | caller-initialized nmsg_pcap object from whose pcap handle the packet 'pkt' was received. |
[in] | pkt_hdr | pointer to the pcap packet header corresponding to 'pkt'. |
[in] | pkt | pointer to the packet. |
nmsg_res nmsg_ipdg_parse_pcap_raw | ( | struct nmsg_ipdg * | dg, |
int | datalink, | ||
const uint8_t * | pkt, | ||
size_t | len | ||
) |
Like nmsg_ipdg_parse_pcap(), but performs no fragment handling.
[out] | dg | caller-allocated struct nmsg_ipdg which will be populated after a successful call. |
[in] | datalink | libpcap data link type. |
[in] | pkt | pointer to the packet. |
[in] | len | length of the packet. |