#include "common.h"
#include "buffer.h"
Go to the source code of this file.
|
static int | get_tun_ip_ver (int tunnel_type, struct buffer *buf, int *ip_hdr_offset) |
|
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...
|
|
◆ ADD_CHECKSUM_32
#define ADD_CHECKSUM_32 |
( |
|
acc, |
|
|
|
u32 |
|
) |
| |
Value: { \
acc += (u32) & 0xffff; \
acc += (u32) >> 16; \
}
Definition at line 240 of file proto.h.
◆ ADJUST_CHECKSUM
#define ADJUST_CHECKSUM |
( |
|
acc, |
|
|
|
cksum |
|
) |
| |
Value: { \
int _acc = acc; \
_acc += (cksum); \
if (_acc < 0) { \
_acc = -_acc; \
_acc = (_acc >> 16) + (_acc & 0xffff); \
_acc += _acc >> 16; \
(cksum) = (uint16_t) ~_acc; \
} else { \
_acc = (_acc >> 16) + (_acc & 0xffff); \
_acc += _acc >> 16; \
(cksum) = (uint16_t) _acc; \
} \
}
Definition at line 225 of file proto.h.
◆ ARP_MAC_ADDR_TYPE
#define ARP_MAC_ADDR_TYPE 0x0001 |
◆ ARP_REPLY
◆ ARP_REQUEST
#define ARP_REQUEST 0x0001 |
◆ DEV_TYPE_NULL
◆ DEV_TYPE_TAP
#define DEV_TYPE_TAP 3 /* ethernet (802.3) tunnel */ |
◆ DEV_TYPE_TUN
#define DEV_TYPE_TUN 2 /* point-to-point IP tunnel */ |
◆ DEV_TYPE_UNDEF
◆ OPENVPN_8021Q_MASK_CFI
#define OPENVPN_8021Q_MASK_CFI htons(0x1000) /* mask CFI out of pcp_cfi_vid */ |
◆ OPENVPN_8021Q_MASK_PCP
#define OPENVPN_8021Q_MASK_PCP htons(0xE000) /* mask PCP out of pcp_cfi_vid */ |
◆ OPENVPN_8021Q_MASK_VID
#define OPENVPN_8021Q_MASK_VID htons(0x0FFF) /* mask VID out of pcp_cfi_vid */ |
◆ OPENVPN_8021Q_MAX_VID
#define OPENVPN_8021Q_MAX_VID 4094 |
◆ OPENVPN_8021Q_MIN_VID
#define OPENVPN_8021Q_MIN_VID 1 |
◆ OPENVPN_ETH_ALEN
#define OPENVPN_ETH_ALEN 6 /* ethernet address length */ |
◆ OPENVPN_ETH_P_8021Q
#define OPENVPN_ETH_P_8021Q 0x8100 /* 802.1Q protocol */ |
◆ OPENVPN_ETH_P_ARP
#define OPENVPN_ETH_P_ARP 0x0806 /* ARP protocol */ |
◆ OPENVPN_ETH_P_IPV4
#define OPENVPN_ETH_P_IPV4 0x0800 /* IPv4 protocol */ |
◆ OPENVPN_ETH_P_IPV6
#define OPENVPN_ETH_P_IPV6 0x86DD /* IPv6 protocol */ |
◆ OPENVPN_ICMP6_DESTINATION_UNREACHABLE
#define OPENVPN_ICMP6_DESTINATION_UNREACHABLE 1 |
◆ OPENVPN_ICMP6_DU_COMMUNICATION_PROHIBTED
#define OPENVPN_ICMP6_DU_COMMUNICATION_PROHIBTED 1 |
◆ OPENVPN_ICMP6_DU_NOROUTE
#define OPENVPN_ICMP6_DU_NOROUTE 0 |
◆ OPENVPN_IP_OFFMASK
#define OPENVPN_IP_OFFMASK 0x1fff |
◆ OPENVPN_IPH_GET_LEN
#define OPENVPN_IPH_GET_LEN |
( |
|
v | ) |
(((v) & 0x0F) << 2) |
◆ OPENVPN_IPH_GET_VER
#define OPENVPN_IPH_GET_VER |
( |
|
v | ) |
(((v) >> 4) & 0x0F) |
◆ OPENVPN_IPPROTO_ICMPV6
#define OPENVPN_IPPROTO_ICMPV6 58 /* ICMPV6 protocol */ |
◆ OPENVPN_IPPROTO_IGMP
#define OPENVPN_IPPROTO_IGMP 2 /* IGMP protocol */ |
◆ OPENVPN_IPPROTO_TCP
#define OPENVPN_IPPROTO_TCP 6 /* TCP protocol */ |
◆ OPENVPN_IPPROTO_UDP
#define OPENVPN_IPPROTO_UDP 17 /* UDP protocol */ |
◆ OPENVPN_ND_INVERSE_ADVERT
#define OPENVPN_ND_INVERSE_ADVERT 142 |
◆ OPENVPN_ND_INVERSE_SOLICIT
#define OPENVPN_ND_INVERSE_SOLICIT 141 |
◆ OPENVPN_ND_NEIGHBOR_ADVERT
#define OPENVPN_ND_NEIGHBOR_ADVERT 136 |
◆ OPENVPN_ND_NEIGHBOR_SOLICIT
#define OPENVPN_ND_NEIGHBOR_SOLICIT 135 |
◆ OPENVPN_ND_ROUTER_ADVERT
#define OPENVPN_ND_ROUTER_ADVERT 134 |
◆ OPENVPN_ND_ROUTER_SOLICIT
#define OPENVPN_ND_ROUTER_SOLICIT 133 |
◆ OPENVPN_TCPH_ACK_MASK
#define OPENVPN_TCPH_ACK_MASK (1<<4) |
◆ OPENVPN_TCPH_CWR_MASK
#define OPENVPN_TCPH_CWR_MASK (1<<7) |
◆ OPENVPN_TCPH_ECE_MASK
#define OPENVPN_TCPH_ECE_MASK (1<<6) |
◆ OPENVPN_TCPH_FIN_MASK
#define OPENVPN_TCPH_FIN_MASK (1<<0) |
◆ OPENVPN_TCPH_GET_DOFF
#define OPENVPN_TCPH_GET_DOFF |
( |
|
d | ) |
(((d) & 0xF0) >> 2) |
◆ OPENVPN_TCPH_PSH_MASK
#define OPENVPN_TCPH_PSH_MASK (1<<3) |
◆ OPENVPN_TCPH_RST_MASK
#define OPENVPN_TCPH_RST_MASK (1<<2) |
◆ OPENVPN_TCPH_SYN_MASK
#define OPENVPN_TCPH_SYN_MASK (1<<1) |
◆ OPENVPN_TCPH_URG_MASK
#define OPENVPN_TCPH_URG_MASK (1<<5) |
◆ OPENVPN_TCPOLEN_MAXSEG
#define OPENVPN_TCPOLEN_MAXSEG 4 |
◆ OPENVPN_TCPOPT_EOL
#define OPENVPN_TCPOPT_EOL 0 |
◆ OPENVPN_TCPOPT_MAXSEG
#define OPENVPN_TCPOPT_MAXSEG 2 |
◆ OPENVPN_TCPOPT_NOP
#define OPENVPN_TCPOPT_NOP 1 |
◆ SIZE_ETH_TO_8021Q_HDR
#define SIZE_ETH_TO_8021Q_HDR |
Value:
Definition at line 84 of file proto.h.
◆ SUB_CHECKSUM_32
#define SUB_CHECKSUM_32 |
( |
|
acc, |
|
|
|
u32 |
|
) |
| |
Value: { \
acc -= (u32) & 0xffff; \
acc -= (u32) >> 16; \
}
Definition at line 245 of file proto.h.
◆ TOP_NET30
◆ TOP_P2P
◆ TOP_SUBNET
◆ TOP_UNDEF
◆ get_tun_ip_ver()
static int get_tun_ip_ver |
( |
int |
tunnel_type, |
|
|
struct buffer * |
buf, |
|
|
int * |
ip_hdr_offset |
|
) |
| |
|
inlinestatic |
◆ 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 |
proto | next - header or IP protocol of the packet |
- Returns
- The calculated checksum in host order
Definition at line 123 of file proto.c.
Referenced by dhcp_extract_router_msg(), and ipv6_send_icmp_unreachable().
◆ is_ipv4()
bool is_ipv4 |
( |
int |
tunnel_type, |
|
|
struct buffer * |
buf |
|
) |
| |
◆ is_ipv6()
bool is_ipv6 |
( |
int |
tunnel_type, |
|
|
struct buffer * |
buf |
|
) |
| |