Functions to parse raw packets. More...
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/net.h>
Go to the source code of this file.
Functions | |
uint16_t | fr_ip_header_checksum (uint8_t const *data, uint8_t ihl) |
Calculate IP header checksum. More... | |
ssize_t | fr_link_layer_offset (uint8_t const *data, size_t len, int link_layer) |
Returns the length of the link layer header. More... | |
bool | fr_link_layer_supported (int link_layer) |
Check whether fr_link_layer_offset can process a link_layer. More... | |
uint16_t | fr_udp_checksum (uint8_t const *data, uint16_t len, uint16_t checksum, struct in_addr const src_addr, struct in_addr const dst_addr) |
Calculate UDP checksum. More... | |
int | fr_udp_header_check (uint8_t const *data, uint16_t remaining, ip_header_t const *ip) |
Check UDP header is valid. More... | |
Variables | |
FR_NAME_NUMBER const | fr_net_af_table [] |
Strings for address families. More... | |
FR_NAME_NUMBER const | fr_net_ip_proto_table [] |
Strings for L4 protocols. More... | |
FR_NAME_NUMBER const | fr_net_sock_type_table [] |
Strings for socket types. More... | |
Functions to parse raw packets.
Definition in file net.c.
uint16_t fr_ip_header_checksum | ( | uint8_t const * | data, |
uint8_t | ihl | ||
) |
ssize_t fr_link_layer_offset | ( | uint8_t const * | data, |
size_t | len, | ||
int | link_layer | ||
) |
Returns the length of the link layer header.
Libpcap does not include a decoding function to skip the L2 header, but it does at least inform us of the type.
Unfortunately some headers are of variable length (like ethernet), so additional decoding logic is required.
data | start of packet data. |
len | caplen. |
link_layer | value returned from pcap_linktype. |
Definition at line 95 of file net.c.
bool fr_link_layer_supported | ( | int | link_layer | ) |
uint16_t fr_udp_checksum | ( | uint8_t const * | data, |
uint16_t | len, | ||
uint16_t | checksum, | ||
struct in_addr const | src_addr, | ||
struct in_addr const | dst_addr | ||
) |
Calculate UDP checksum.
Zero out UDP checksum in UDP header before calling fr_udp_checksum to get 'expected' checksum.
data | Pointer to the start of the UDP header |
len | value of udp length field in host byte order. Must be validated to make sure it won't overrun data buffer. |
checksum | current checksum, leave as 0 to just enable validation. |
src_addr | in network byte order. |
dst_addr | in network byte order. |
Definition at line 240 of file net.c.
int fr_udp_header_check | ( | uint8_t const * | data, |
uint16_t | remaining, | ||
ip_header_t const * | ip | ||
) |
Check UDP header is valid.
data | Pointer to the start of the UDP header |
remaining | bits of received packet |
ip | pointer to IP header structure |
Definition at line 186 of file net.c.
FR_NAME_NUMBER const fr_net_af_table[] |
FR_NAME_NUMBER const fr_net_ip_proto_table[] |
FR_NAME_NUMBER const fr_net_sock_type_table[] |