Go to the documentation of this file.
35 #define DEV_TYPE_UNDEF 0
36 #define DEV_TYPE_TUN 2
37 #define DEV_TYPE_TAP 3
53 #define OPENVPN_ETH_ALEN 6
59 #define OPENVPN_ETH_P_IPV4 0x0800
60 #define OPENVPN_ETH_P_IPV6 0x86DD
61 #define OPENVPN_ETH_P_ARP 0x0806
62 #define OPENVPN_ETH_P_8021Q 0x8100
72 #define OPENVPN_8021Q_MASK_PCP htons(0xE000)
73 #define OPENVPN_8021Q_MASK_CFI htons(0x1000)
74 #define OPENVPN_8021Q_MASK_VID htons(0x0FFF)
83 #define SIZE_ETH_TO_8021Q_HDR (sizeof(struct openvpn_8021qhdr) \
84 - sizeof(struct openvpn_ethhdr))
89 #define OPENVPN_IN6_ARE_ADDR_EQUAL(a, b) \
90 (memcmp(a, b, sizeof(struct in6_addr)) == 0)
93 #define OPENVPN_IPH_GET_VER(v) (((v) >> 4) & 0x0F)
94 #define OPENVPN_IPH_GET_LEN(v) (((v) & 0x0F) << 2)
101 #define OPENVPN_IP_OFFMASK 0x1fff
106 #define OPENVPN_IPPROTO_IGMP 2
107 #define OPENVPN_IPPROTO_TCP 6
108 #define OPENVPN_IPPROTO_UDP 17
109 #define OPENVPN_IPPROTO_ICMPV6 58
136 #define OPENVPN_ICMP6_DESTINATION_UNREACHABLE 1
137 #define OPENVPN_ND_ROUTER_SOLICIT 133
138 #define OPENVPN_ND_ROUTER_ADVERT 134
139 #define OPENVPN_ND_NEIGHBOR_SOLICIT 135
140 #define OPENVPN_ND_NEIGHBOR_ADVERT 136
141 #define OPENVPN_ND_INVERSE_SOLICIT 141
142 #define OPENVPN_ND_INVERSE_ADVERT 142
144 #define OPENVPN_ICMP6_DU_NOROUTE 0
145 #define OPENVPN_ICMP6_DU_COMMUNICATION_PROHIBTED 1
170 #define OPENVPN_TCPH_GET_DOFF(d) (((d) & 0xF0) >> 2)
173 #define OPENVPN_TCPH_FIN_MASK (1<<0)
174 #define OPENVPN_TCPH_SYN_MASK (1<<1)
175 #define OPENVPN_TCPH_RST_MASK (1<<2)
176 #define OPENVPN_TCPH_PSH_MASK (1<<3)
177 #define OPENVPN_TCPH_ACK_MASK (1<<4)
178 #define OPENVPN_TCPH_URG_MASK (1<<5)
179 #define OPENVPN_TCPH_ECE_MASK (1<<6)
180 #define OPENVPN_TCPH_CWR_MASK (1<<7)
188 #define OPENVPN_TCPOPT_EOL 0
189 #define OPENVPN_TCPOPT_NOP 1
190 #define OPENVPN_TCPOPT_MAXSEG 2
191 #define OPENVPN_TCPOLEN_MAXSEG 4
211 #define ADJUST_CHECKSUM(acc, cksum) { \
216 _acc = (_acc >> 16) + (_acc & 0xffff); \
217 _acc += _acc >> 16; \
218 (cksum) = (uint16_t) ~_acc; \
220 _acc = (_acc >> 16) + (_acc & 0xffff); \
221 _acc += _acc >> 16; \
222 (cksum) = (uint16_t) _acc; \
226 #define ADD_CHECKSUM_32(acc, u32) { \
227 acc += (u32) & 0xffff; \
228 acc += (u32) >> 16; \
231 #define SUB_CHECKSUM_32(acc, u32) { \
232 acc -= (u32) & 0xffff; \
233 acc -= (u32) >> 16; \
299 const uint8_t *src_addr,
const uint8_t *dest_addr,
const int proto);
301 #ifdef PACKET_TRUNCATION_CHECK
302 void ipv4_packet_size_verify(
const uint8_t *data,
304 const int tunnel_type,
311 #define OPENVPN_8021Q_MIN_VID 1
312 #define OPENVPN_8021Q_MAX_VID 4094
union ip_tcp_udp_hdr::@18 u
struct openvpn_udphdr udp
unsigned short sa_family_t
#define OPENVPN_ETH_P_IPV4
Wrapper structure for dynamically allocated memory.
uint8_t source[OPENVPN_ETH_ALEN]
uint8_t dest[OPENVPN_ETH_ALEN]
uint8_t source[OPENVPN_ETH_ALEN]
struct openvpn_tcphdr tcp
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.
static int get_tun_ip_ver(int tunnel_type, struct buffer *buf, int *ip_hdr_offset)
#define OPENVPN_IPH_GET_VER(v)
bool is_ipv4(int tunnel_type, struct buffer *buf)
uint8_t dest[OPENVPN_ETH_ALEN]
bool is_ipv6(int tunnel_type, struct buffer *buf)
#define OPENVPN_ETH_P_IPV6