OpenVPN
Functions
proto.c File Reference
#include "syshead.h"
#include "proto.h"
#include "error.h"
#include "memdbg.h"
Include dependency graph for proto.c:

Go to the source code of this file.

Functions

static bool is_ipv_X (int tunnel_type, struct buffer *buf, int ip_ver)
 
bool is_ipv4 (int tunnel_type, struct buffer *buf)
 
bool is_ipv6 (int tunnel_type, struct buffer *buf)
 
uint16_t ip_checksum (const sa_family_t af, const uint8_t *payload, const int len_payload, const uint8_t *src_addr, const uint8_t *dest_addr, const int proto)
 Calculates an IP or IPv6 checksum with a pseudo header as required by TCP, UDP and ICMPv6. More...
 

Function Documentation

◆ ip_checksum()

uint16_t ip_checksum ( const sa_family_t  af,
const uint8_t payload,
const int  len_payload,
const uint8_t src_addr,
const uint8_t dest_addr,
const int  proto 
)

Calculates an IP or IPv6 checksum with a pseudo header as required by TCP, UDP and ICMPv6.

Parameters
af- Address family for which the checksum is calculated AF_INET or AF_INET6
payload- the TCP, ICMPv6 or UDP packet
len_payload- length of payload
src_addr- Source address of the packet
dest_addr- Destination address of the packet
protonext - header or IP protocol of the packet
Returns
The calculated checksum in host order

Definition at line 103 of file proto.c.

References BLEN, BPTR, buf_set_read(), counter_format, D_PACKET_TRUNC_DEBUG, D_PACKET_TRUNC_ERR, buffer::data, is_ipv4(), msg, OPENVPN_IPH_GET_LEN, openvpn_iphdr::tot_len, verify_align_4, and openvpn_iphdr::version_len.

Referenced by dhcp_extract_router_msg(), get_tun_ip_ver(), and ipv6_send_icmp_unreachable().

◆ is_ipv4()

bool is_ipv4 ( int  tunnel_type,
struct buffer buf 
)

Definition at line 91 of file proto.c.

References is_ipv_X().

Referenced by get_tun_ip_ver(), ip_checksum(), and process_ip_header().

◆ is_ipv6()

bool is_ipv6 ( int  tunnel_type,
struct buffer buf 
)

Definition at line 96 of file proto.c.

References is_ipv_X().

Referenced by get_tun_ip_ver(), ipv6_send_icmp_unreachable(), and process_ip_header().

◆ is_ipv_X()

static bool is_ipv_X ( int  tunnel_type,
struct buffer buf,
int  ip_ver 
)
static