Go to the documentation of this file.
35 #define DEV_TYPE_UNDEF 0
36 #define DEV_TYPE_NULL 1
37 #define DEV_TYPE_TUN 2
38 #define DEV_TYPE_TAP 3
54 #define OPENVPN_ETH_ALEN 6
60 #define OPENVPN_ETH_P_IPV4 0x0800
61 #define OPENVPN_ETH_P_IPV6 0x86DD
62 #define OPENVPN_ETH_P_ARP 0x0806
63 #define OPENVPN_ETH_P_8021Q 0x8100
73 #define OPENVPN_8021Q_MASK_PCP htons(0xE000)
74 #define OPENVPN_8021Q_MASK_CFI htons(0x1000)
75 #define OPENVPN_8021Q_MASK_VID htons(0x0FFF)
84 #define SIZE_ETH_TO_8021Q_HDR (sizeof(struct openvpn_8021qhdr) \
85 - sizeof(struct openvpn_ethhdr))
89 #define ARP_MAC_ADDR_TYPE 0x0001
96 #define ARP_REQUEST 0x0001
97 #define ARP_REPLY 0x0002
107 #define OPENVPN_IPH_GET_VER(v) (((v) >> 4) & 0x0F)
108 #define OPENVPN_IPH_GET_LEN(v) (((v) & 0x0F) << 2)
115 #define OPENVPN_IP_OFFMASK 0x1fff
120 #define OPENVPN_IPPROTO_IGMP 2
121 #define OPENVPN_IPPROTO_TCP 6
122 #define OPENVPN_IPPROTO_UDP 17
123 #define OPENVPN_IPPROTO_ICMPV6 58
150 #define OPENVPN_ICMP6_DESTINATION_UNREACHABLE 1
151 #define OPENVPN_ND_ROUTER_SOLICIT 133
152 #define OPENVPN_ND_ROUTER_ADVERT 134
153 #define OPENVPN_ND_NEIGHBOR_SOLICIT 135
154 #define OPENVPN_ND_NEIGHBOR_ADVERT 136
155 #define OPENVPN_ND_INVERSE_SOLICIT 141
156 #define OPENVPN_ND_INVERSE_ADVERT 142
158 #define OPENVPN_ICMP6_DU_NOROUTE 0
159 #define OPENVPN_ICMP6_DU_COMMUNICATION_PROHIBTED 1
184 #define OPENVPN_TCPH_GET_DOFF(d) (((d) & 0xF0) >> 2)
187 #define OPENVPN_TCPH_FIN_MASK (1<<0)
188 #define OPENVPN_TCPH_SYN_MASK (1<<1)
189 #define OPENVPN_TCPH_RST_MASK (1<<2)
190 #define OPENVPN_TCPH_PSH_MASK (1<<3)
191 #define OPENVPN_TCPH_ACK_MASK (1<<4)
192 #define OPENVPN_TCPH_URG_MASK (1<<5)
193 #define OPENVPN_TCPH_ECE_MASK (1<<6)
194 #define OPENVPN_TCPH_CWR_MASK (1<<7)
202 #define OPENVPN_TCPOPT_EOL 0
203 #define OPENVPN_TCPOPT_NOP 1
204 #define OPENVPN_TCPOPT_MAXSEG 2
205 #define OPENVPN_TCPOLEN_MAXSEG 4
225 #define ADJUST_CHECKSUM(acc, cksum) { \
230 _acc = (_acc >> 16) + (_acc & 0xffff); \
231 _acc += _acc >> 16; \
232 (cksum) = (uint16_t) ~_acc; \
234 _acc = (_acc >> 16) + (_acc & 0xffff); \
235 _acc += _acc >> 16; \
236 (cksum) = (uint16_t) _acc; \
240 #define ADD_CHECKSUM_32(acc, u32) { \
241 acc += (u32) & 0xffff; \
242 acc += (u32) >> 16; \
245 #define SUB_CHECKSUM_32(acc, u32) { \
246 acc -= (u32) & 0xffff; \
247 acc -= (u32) >> 16; \
313 const uint8_t *src_addr,
const uint8_t *dest_addr,
const int proto);
315 #ifdef PACKET_TRUNCATION_CHECK
316 void ipv4_packet_size_verify(
const uint8_t *data,
318 const int tunnel_type,
325 #define OPENVPN_8021Q_MIN_VID 1
326 #define OPENVPN_8021Q_MAX_VID 4094
uint8_t mac_src[OPENVPN_ETH_ALEN]
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
union ip_tcp_udp_hdr::@12 u
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)
uint8_t mac_dest[OPENVPN_ETH_ALEN]
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