OpenVPN
Data Structures | Macros | Functions
proto.h File Reference
#include "common.h"
#include "buffer.h"
Include dependency graph for proto.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  openvpn_ethhdr
 
struct  openvpn_arp
 
struct  openvpn_iphdr
 
struct  openvpn_ipv6hdr
 
struct  openvpn_udphdr
 
struct  openvpn_tcphdr
 
struct  ip_tcp_udp_hdr
 

Macros

#define DEV_TYPE_UNDEF   0
 
#define DEV_TYPE_NULL   1
 
#define DEV_TYPE_TUN   2 /* point-to-point IP tunnel */
 
#define DEV_TYPE_TAP   3 /* ethernet (802.3) tunnel */
 
#define TOP_UNDEF   0
 
#define TOP_NET30   1
 
#define TOP_P2P   2
 
#define TOP_SUBNET   3
 
#define OPENVPN_ETH_ALEN   6 /* ethernet address length */
 
#define OPENVPN_ETH_P_IPV4   0x0800 /* IPv4 protocol */
 
#define OPENVPN_ETH_P_IPV6   0x86DD /* IPv6 protocol */
 
#define OPENVPN_ETH_P_ARP   0x0806 /* ARP protocol */
 
#define ARP_MAC_ADDR_TYPE   0x0001
 
#define ARP_REQUEST   0x0001
 
#define ARP_REPLY   0x0002
 
#define OPENVPN_IPH_GET_VER(v)   (((v) >> 4) & 0x0F)
 
#define OPENVPN_IPH_GET_LEN(v)   (((v) & 0x0F) << 2)
 
#define OPENVPN_IP_OFFMASK   0x1fff
 
#define OPENVPN_IPPROTO_IGMP   2 /* IGMP protocol */
 
#define OPENVPN_IPPROTO_TCP   6 /* TCP protocol */
 
#define OPENVPN_IPPROTO_UDP   17 /* UDP protocol */
 
#define OPENVPN_TCPH_GET_DOFF(d)   (((d) & 0xF0) >> 2)
 
#define OPENVPN_TCPH_FIN_MASK   (1<<0)
 
#define OPENVPN_TCPH_SYN_MASK   (1<<1)
 
#define OPENVPN_TCPH_RST_MASK   (1<<2)
 
#define OPENVPN_TCPH_PSH_MASK   (1<<3)
 
#define OPENVPN_TCPH_ACK_MASK   (1<<4)
 
#define OPENVPN_TCPH_URG_MASK   (1<<5)
 
#define OPENVPN_TCPH_ECE_MASK   (1<<6)
 
#define OPENVPN_TCPH_CWR_MASK   (1<<7)
 
#define OPENVPN_TCPOPT_EOL   0
 
#define OPENVPN_TCPOPT_NOP   1
 
#define OPENVPN_TCPOPT_MAXSEG   2
 
#define OPENVPN_TCPOLEN_MAXSEG   4
 
#define ADJUST_CHECKSUM(acc, cksum)
 
#define ADD_CHECKSUM_32(acc, u32)
 
#define SUB_CHECKSUM_32(acc, u32)
 
#define MTU_TO_MSS(mtu)
 

Functions

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)
 

Macro Definition Documentation

◆ ADD_CHECKSUM_32

#define ADD_CHECKSUM_32 (   acc,
  u32 
)
Value:
{ \
acc += (u32) & 0xffff; \
acc += (u32) >> 16; \
}

Definition at line 199 of file proto.h.

Referenced by client_nat_transform().

◆ 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; \
} \
}
unsigned __int16 uint16_t
Definition: config-msvc.h:122

Definition at line 184 of file proto.h.

Referenced by client_nat_transform(), and mss_fixup_dowork().

◆ ARP_MAC_ADDR_TYPE

#define ARP_MAC_ADDR_TYPE   0x0001

Definition at line 67 of file proto.h.

◆ ARP_REPLY

#define ARP_REPLY   0x0002

Definition at line 75 of file proto.h.

◆ ARP_REQUEST

#define ARP_REQUEST   0x0001

Definition at line 74 of file proto.h.

◆ DEV_TYPE_NULL

#define DEV_TYPE_NULL   1

Definition at line 36 of file proto.h.

Referenced by dev_type_enum(), dev_type_string(), is_tun_p2p(), open_null(), and open_tun().

◆ 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

#define DEV_TYPE_UNDEF   0

Definition at line 35 of file proto.h.

Referenced by dev_type_enum(), multi_init(), and options_postprocess_verify_ce().

◆ MTU_TO_MSS

#define MTU_TO_MSS (   mtu)
Value:
(mtu - sizeof(struct openvpn_iphdr) \
- sizeof(struct openvpn_tcphdr))

Definition at line 217 of file proto.h.

Referenced by process_ip_header().

◆ OPENVPN_ETH_ALEN

#define OPENVPN_ETH_ALEN   6 /* ethernet address length */

Definition at line 54 of file proto.h.

◆ OPENVPN_ETH_P_ARP

#define OPENVPN_ETH_P_ARP   0x0806 /* ARP protocol */

Definition at line 62 of file proto.h.

Referenced by mroute_extract_addr_ether().

◆ OPENVPN_ETH_P_IPV4

#define OPENVPN_ETH_P_IPV4   0x0800 /* IPv4 protocol */

Definition at line 60 of file proto.h.

Referenced by get_tun_ip_ver(), is_ipv_X(), and mroute_extract_addr_ether().

◆ OPENVPN_ETH_P_IPV6

#define OPENVPN_ETH_P_IPV6   0x86DD /* IPv6 protocol */

Definition at line 61 of file proto.h.

Referenced by get_tun_ip_ver(), and is_ipv_X().

◆ OPENVPN_IP_OFFMASK

#define OPENVPN_IP_OFFMASK   0x1fff

Definition at line 93 of file proto.h.

Referenced by mss_fixup_ipv4().

◆ OPENVPN_IPH_GET_LEN

#define OPENVPN_IPH_GET_LEN (   v)    (((v) & 0x0F) << 2)

Definition at line 86 of file proto.h.

Referenced by is_ipv6(), and mss_fixup_ipv4().

◆ OPENVPN_IPH_GET_VER

#define OPENVPN_IPH_GET_VER (   v)    (((v) >> 4) & 0x0F)

Definition at line 85 of file proto.h.

Referenced by get_tun_ip_ver(), is_ipv_X(), mroute_extract_addr_ip(), and open_null().

◆ OPENVPN_IPPROTO_IGMP

#define OPENVPN_IPPROTO_IGMP   2 /* IGMP protocol */

Definition at line 98 of file proto.h.

Referenced by mroute_extract_addr_ip().

◆ OPENVPN_IPPROTO_TCP

#define OPENVPN_IPPROTO_TCP   6 /* TCP protocol */

Definition at line 99 of file proto.h.

Referenced by client_nat_transform(), mss_fixup_ipv4(), and mss_fixup_ipv6().

◆ OPENVPN_IPPROTO_UDP

#define OPENVPN_IPPROTO_UDP   17 /* UDP protocol */

Definition at line 100 of file proto.h.

Referenced by client_nat_transform(), dhcp_extract_router_msg(), and udp_checksum().

◆ OPENVPN_TCPH_ACK_MASK

#define OPENVPN_TCPH_ACK_MASK   (1<<4)

Definition at line 150 of file proto.h.

◆ OPENVPN_TCPH_CWR_MASK

#define OPENVPN_TCPH_CWR_MASK   (1<<7)

Definition at line 153 of file proto.h.

◆ OPENVPN_TCPH_ECE_MASK

#define OPENVPN_TCPH_ECE_MASK   (1<<6)

Definition at line 152 of file proto.h.

◆ OPENVPN_TCPH_FIN_MASK

#define OPENVPN_TCPH_FIN_MASK   (1<<0)

Definition at line 146 of file proto.h.

◆ OPENVPN_TCPH_GET_DOFF

#define OPENVPN_TCPH_GET_DOFF (   d)    (((d) & 0xF0) >> 2)

Definition at line 143 of file proto.h.

Referenced by mss_fixup_dowork().

◆ OPENVPN_TCPH_PSH_MASK

#define OPENVPN_TCPH_PSH_MASK   (1<<3)

Definition at line 149 of file proto.h.

◆ OPENVPN_TCPH_RST_MASK

#define OPENVPN_TCPH_RST_MASK   (1<<2)

Definition at line 148 of file proto.h.

◆ OPENVPN_TCPH_SYN_MASK

#define OPENVPN_TCPH_SYN_MASK   (1<<1)

Definition at line 147 of file proto.h.

Referenced by mss_fixup_ipv4(), and mss_fixup_ipv6().

◆ OPENVPN_TCPH_URG_MASK

#define OPENVPN_TCPH_URG_MASK   (1<<5)

Definition at line 151 of file proto.h.

◆ OPENVPN_TCPOLEN_MAXSEG

#define OPENVPN_TCPOLEN_MAXSEG   4

Definition at line 164 of file proto.h.

Referenced by mss_fixup_dowork().

◆ OPENVPN_TCPOPT_EOL

#define OPENVPN_TCPOPT_EOL   0

Definition at line 161 of file proto.h.

Referenced by mss_fixup_dowork().

◆ OPENVPN_TCPOPT_MAXSEG

#define OPENVPN_TCPOPT_MAXSEG   2

Definition at line 163 of file proto.h.

Referenced by mss_fixup_dowork().

◆ OPENVPN_TCPOPT_NOP

#define OPENVPN_TCPOPT_NOP   1

Definition at line 162 of file proto.h.

Referenced by mss_fixup_dowork().

◆ SUB_CHECKSUM_32

#define SUB_CHECKSUM_32 (   acc,
  u32 
)
Value:
{ \
acc -= (u32) & 0xffff; \
acc -= (u32) >> 16; \
}

Definition at line 204 of file proto.h.

Referenced by client_nat_transform().

◆ TOP_NET30

#define TOP_NET30   1

◆ TOP_P2P

#define TOP_P2P   2

◆ TOP_SUBNET

#define TOP_SUBNET   3

◆ TOP_UNDEF

#define TOP_UNDEF   0

Definition at line 42 of file proto.h.

Referenced by parse_topology(), and print_topology().

Function Documentation

◆ get_tun_ip_ver()

static int get_tun_ip_ver ( int  tunnel_type,
struct buffer buf,
int *  ip_hdr_offset 
)
inlinestatic

◆ 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(), is_ipv6(), and process_ip_header().

◆ is_ipv6()

bool is_ipv6 ( int  tunnel_type,
struct buffer buf 
)