Structures and functions for parsing raw network packets.
More...
#include <freeradius-devel/build.h>
#include <freeradius-devel/ethernet/ethernet.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/hash.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/table.h>
#include <netinet/in.h>
#include <stdint.h>
#include <sys/socket.h>
Go to the source code of this file.
|
uint16_t | fr_ip6_pesudo_header_checksum (struct in6_addr const *src, struct in6_addr const *dst, uint16_t ip_len, uint8_t ip_next) |
|
uint16_t | fr_ip_header_checksum (uint8_t const *data, uint8_t ihl) |
| Calculate IP header checksum. 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...
|
|
Structures and functions for parsing raw network packets.
- Author
- Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
- Copyright
- 2014 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
Definition in file net.h.
◆ ip_header6_t
Definition at line 118 of file net.h.
Data Fields |
struct in6_addr ip_src |
ip_dst |
Src and Dst address. |
uint8_t |
ip_hopl |
IP Hop Limit. |
uint16_t |
ip_len |
Payload length. |
uint8_t |
ip_next |
Next header (protocol) |
uint32_t |
ip_vtcfl |
Version, traffic class, flow label. |
◆ ip_header_t
Definition at line 104 of file net.h.
Data Fields |
struct in_addr ip_src |
ip_dst |
Src and Dst address. |
uint16_t |
ip_id |
identification. |
uint16_t |
ip_len |
Total length. |
uint16_t |
ip_off |
Fragment offset field. |
uint8_t |
ip_p |
Protocol. |
uint16_t |
ip_sum |
Checksum. |
uint8_t |
ip_tos |
Type of service. |
uint8_t |
ip_ttl |
Time To Live. |
uint8_t |
ip_vhl |
Header length, version. |
◆ ip_pseudo_header6_t
struct ip_pseudo_header6_t |
Definition at line 128 of file net.h.
Data Fields |
struct in6_addr ip_src |
ip_dst |
Src and Dst address. |
uint32_t |
ip_len |
length |
uint32_t |
ip_next |
upper 24 bits must be zero |
◆ udp_header_t
◆ ETHER_ADDR_LEN
Definition at line 64 of file net.h.
◆ ETHER_HDR_LEN
Definition at line 74 of file net.h.
◆ I_DF
Dont fragment flag.
Definition at line 97 of file net.h.
◆ IP_HDR_LEN
Definition at line 75 of file net.h.
◆ IP_HL
#define IP_HL |
( |
|
ip | ) |
(((ip)->ip_vhl & 0x0f) << 2) |
Definition at line 93 of file net.h.
◆ IP_MF
More fragments flag.
Definition at line 98 of file net.h.
◆ IP_OFFMASK
Mask for fragmenting bits.
Definition at line 99 of file net.h.
◆ IP_V
#define IP_V |
( |
|
ip | ) |
(((ip)->ip_vhl & 0xf0) >> 4) |
Definition at line 92 of file net.h.
◆ IP_VHL
#define IP_VHL |
( |
|
v, |
|
|
|
hl |
|
) |
| ((v & 0x0f) << 4) | (hl & 0x0f) |
Definition at line 95 of file net.h.
◆ MAX_RADIUS_LEN
Definition at line 87 of file net.h.
◆ MIN_RADIUS_LEN
Definition at line 88 of file net.h.
◆ RADIUS_AUTH_VECTOR_LENGTH
#define RADIUS_AUTH_VECTOR_LENGTH 16 |
Definition at line 89 of file net.h.
◆ RADIUS_HEADER_LENGTH
#define RADIUS_HEADER_LENGTH 20 |
Definition at line 80 of file net.h.
◆ fr_dlt
Enumerator |
---|
DLT_RAW | |
DLT_NULL | |
DLT_LOOP | |
DLT_EN10MB | |
DLT_LINUX_SLL | |
DLT_PFLOG | |
Definition at line 51 of file net.h.
◆ fr_ip6_pesudo_header_checksum()
uint16_t fr_ip6_pesudo_header_checksum |
( |
struct in6_addr const * |
src, |
|
|
struct in6_addr const * |
dst, |
|
|
uint16_t |
ip_len, |
|
|
uint8_t |
ip_next |
|
) |
| |
◆ fr_ip_header_checksum()
Calculate IP header checksum.
Zero out IP header checksum in IP header before calling fr_ip_header_checksum to get 'expected' checksum.
- Parameters
-
data | Pointer to the start of the IP header |
ihl | value of ip header length field (number of 32 bit words) |
Definition at line 154 of file net.c.
◆ fr_udp_checksum()
Calculate UDP checksum.
Zero out UDP checksum in UDP header before calling fr_udp_checksum to get 'expected' checksum.
- Parameters
-
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. |
- Returns
- 0 if the checksum is correct.
- !0 if checksum is incorrect.
Definition at line 119 of file net.c.
◆ fr_udp_header_check()
Check UDP header is valid.
- Parameters
-
data | Pointer to the start of the UDP header |
remaining | bits of received packet |
ip | pointer to IP header structure |
- Returns
- 1 if checksum is incorrect.
- 0 if UDP payload length and checksum are correct
- -1 on validation error.
Definition at line 64 of file net.c.
◆ fr_net_af_table
Strings for address families.
Definition at line 48 of file net.c.
◆ fr_net_af_table_len
Definition at line 52 of file net.c.
◆ fr_net_ip_proto_table
Strings for L4 protocols.
Definition at line 28 of file net.c.
◆ fr_net_ip_proto_table_len
size_t fr_net_ip_proto_table_len |
|
extern |
Definition at line 34 of file net.c.
◆ fr_net_sock_type_table
Strings for socket types.
Definition at line 39 of file net.c.
◆ fr_net_sock_type_table_len
size_t fr_net_sock_type_table_len |
|
extern |
Definition at line 43 of file net.c.