Functions for parsing raw network packets.  
More...
#include <freeradius-devel/util/net.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. 
 | 
|  | 
| 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. 
 | 
|  | 
| int | fr_udp_header_check (uint8_t const *data, uint16_t remaining, ip_header_t const *ip) | 
|  | Check UDP header is valid. 
 | 
|  | 
◆ 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
Initial value:= {
}
#define L(_str)
Helper for initialising arrays of string literals.
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
Initial value:= {
        { 
L(
"ICMP"),    IPPROTO_ICMP    },
        { 
L(
"ICMPv6"),  IPPROTO_ICMPV6  },
        { 
L(
"TCP"),     IPPROTO_TCP     },
        { 
L(
"UDP"),     IPPROTO_UDP     }
}
Strings for L4 protocols. 
Definition at line 28 of file net.c.
 
 
◆ fr_net_ip_proto_table_len
Definition at line 34 of file net.c.
 
 
◆ fr_net_sock_type_table
Initial value:= {
        { 
L(
"TCP"),     SOCK_STREAM     },
}
Strings for socket types. 
Definition at line 39 of file net.c.
 
 
◆ fr_net_sock_type_table_len
Definition at line 43 of file net.c.