OpenVPN
|
Go to the source code of this file.
Data Structures | |
struct | openvpn_ethhdr |
struct | openvpn_8021qhdr |
struct | openvpn_arp |
struct | openvpn_iphdr |
struct | openvpn_ipv6hdr |
struct | openvpn_icmp6hdr |
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 | OPENVPN_ETH_P_8021Q 0x8100 /* 802.1Q protocol */ |
#define | OPENVPN_8021Q_MASK_PCP htons(0xE000) /* mask PCP out of pcp_cfi_vid */ |
#define | OPENVPN_8021Q_MASK_CFI htons(0x1000) /* mask CFI out of pcp_cfi_vid */ |
#define | OPENVPN_8021Q_MASK_VID htons(0x0FFF) /* mask VID out of pcp_cfi_vid */ |
#define | SIZE_ETH_TO_8021Q_HDR |
#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_IPPROTO_ICMPV6 58 /* ICMPV6 protocol */ |
#define | OPENVPN_ICMP6_DESTINATION_UNREACHABLE 1 |
#define | OPENVPN_ND_ROUTER_SOLICIT 133 |
#define | OPENVPN_ND_ROUTER_ADVERT 134 |
#define | OPENVPN_ND_NEIGHBOR_SOLICIT 135 |
#define | OPENVPN_ND_NEIGHBOR_ADVERT 136 |
#define | OPENVPN_ND_INVERSE_SOLICIT 141 |
#define | OPENVPN_ND_INVERSE_ADVERT 142 |
#define | OPENVPN_ICMP6_DU_NOROUTE 0 |
#define | OPENVPN_ICMP6_DU_COMMUNICATION_PROHIBTED 1 |
#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) |
#define | OPENVPN_8021Q_MIN_VID 1 |
#define | OPENVPN_8021Q_MAX_VID 4094 |
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) |
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... | |
#define ADD_CHECKSUM_32 | ( | acc, | |
u32 | |||
) |
Definition at line 240 of file proto.h.
Referenced by client_nat_transform().
#define ADJUST_CHECKSUM | ( | acc, | |
cksum | |||
) |
Definition at line 225 of file proto.h.
Referenced by client_nat_transform(), and mss_fixup_dowork().
#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().
#define DEV_TYPE_TAP 3 /* ethernet (802.3) tunnel */ |
Definition at line 38 of file proto.h.
Referenced by add_route_ipv6(), check_addr_clash(), delete_route_ipv6(), dev_type_enum(), dev_type_string(), get_tun_ip_ver(), guess_tuntap_dev(), helper_client_server(), ifconfig_options_string(), init_tun(), ipv6_send_icmp_unreachable(), is_ipv_X(), is_tun_p2p(), mroute_extract_addr_from_packet(), multi_process_incoming_link(), multi_process_incoming_tun(), multi_select_virtual_addr(), multi_set_virtual_addr_env(), open_null(), open_tun(), options_postprocess_mutate_ce(), options_postprocess_mutate_invariant(), options_postprocess_verify_ce(), and tuntap_dhcp_mask().
#define DEV_TYPE_TUN 2 /* point-to-point IP tunnel */ |
Definition at line 37 of file proto.h.
Referenced by add_route_ipv6(), check_addr_clash(), delete_route_ipv6(), dev_type_enum(), dev_type_string(), do_address_service(), do_ifconfig_ipv4(), do_ifconfig_ipv6(), do_init_route_list(), do_route_ipv6_service(), get_tun_ip_ver(), guess_tuntap_dev(), helper_client_server(), ifconfig_options_string(), init_tun(), is_ipv_X(), is_tun_p2p(), mroute_extract_addr_from_packet(), multi_add_iroutes(), multi_client_connect_late_setup(), multi_del_iroutes(), multi_init(), multi_process_incoming_link(), multi_process_incoming_tun(), multi_select_virtual_addr(), multi_set_virtual_addr_env(), netsh_delete_address_dns(), open_null(), open_tun(), options_postprocess_mutate_invariant(), options_postprocess_verify_ce(), tuntap_dhcp_mask(), tuntap_get_version_info(), and tuntap_post_open().
#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().
#define MTU_TO_MSS | ( | mtu | ) |
Definition at line 258 of file proto.h.
Referenced by process_ip_header().
#define OPENVPN_8021Q_MASK_CFI htons(0x1000) /* mask CFI out of pcp_cfi_vid */ |
#define OPENVPN_8021Q_MASK_PCP htons(0xE000) /* mask PCP out of pcp_cfi_vid */ |
#define OPENVPN_8021Q_MASK_VID htons(0x0FFF) /* mask VID out of pcp_cfi_vid */ |
Definition at line 75 of file proto.h.
Referenced by vlanhdr_get_vid(), and vlanhdr_set_vid().
#define OPENVPN_8021Q_MAX_VID 4094 |
Definition at line 337 of file proto.h.
Referenced by add_option().
#define OPENVPN_8021Q_MIN_VID 1 |
Definition at line 336 of file proto.h.
Referenced by add_option().
#define OPENVPN_ETH_ALEN 6 /* ethernet address length */ |
Definition at line 54 of file proto.h.
Referenced by ipv6_send_icmp_unreachable(), and mroute_copy_ether_to_addr().
#define OPENVPN_ETH_P_8021Q 0x8100 /* 802.1Q protocol */ |
Definition at line 63 of file proto.h.
Referenced by is_ipv_X(), vlan_decapsulate(), vlan_encapsulate(), and vlan_is_tagged().
#define OPENVPN_ETH_P_IPV4 0x0800 /* IPv4 protocol */ |
Definition at line 60 of file proto.h.
Referenced by get_tun_ip_ver(), and is_ipv_X().
#define OPENVPN_ETH_P_IPV6 0x86DD /* IPv6 protocol */ |
Definition at line 61 of file proto.h.
Referenced by get_tun_ip_ver(), ipv6_send_icmp_unreachable(), and is_ipv_X().
#define OPENVPN_ICMP6_DESTINATION_UNREACHABLE 1 |
Definition at line 150 of file proto.h.
Referenced by ipv6_send_icmp_unreachable().
#define OPENVPN_ICMP6_DU_NOROUTE 0 |
Definition at line 158 of file proto.h.
Referenced by ipv6_send_icmp_unreachable().
#define OPENVPN_IP_OFFMASK 0x1fff |
Definition at line 115 of file proto.h.
Referenced by mss_fixup_ipv4().
#define OPENVPN_IPH_GET_LEN | ( | v | ) | (((v) & 0x0F) << 2) |
Definition at line 108 of file proto.h.
Referenced by ip_checksum(), and mss_fixup_ipv4().
#define OPENVPN_IPH_GET_VER | ( | v | ) | (((v) >> 4) & 0x0F) |
Definition at line 107 of file proto.h.
Referenced by get_tun_ip_ver(), is_ip_packet_valid(), is_ipv_X(), mroute_extract_addr_ip(), and open_null().
#define OPENVPN_IPPROTO_ICMPV6 58 /* ICMPV6 protocol */ |
Definition at line 123 of file proto.h.
Referenced by ipv6_send_icmp_unreachable().
#define OPENVPN_IPPROTO_IGMP 2 /* IGMP protocol */ |
Definition at line 120 of file proto.h.
Referenced by mroute_extract_addr_ip().
#define OPENVPN_IPPROTO_TCP 6 /* TCP protocol */ |
Definition at line 121 of file proto.h.
Referenced by client_nat_transform(), mss_fixup_ipv4(), and mss_fixup_ipv6().
#define OPENVPN_IPPROTO_UDP 17 /* UDP protocol */ |
Definition at line 122 of file proto.h.
Referenced by client_nat_transform(), and dhcp_extract_router_msg().
#define OPENVPN_TCPH_GET_DOFF | ( | d | ) | (((d) & 0xF0) >> 2) |
Definition at line 184 of file proto.h.
Referenced by mss_fixup_dowork().
#define OPENVPN_TCPH_SYN_MASK (1<<1) |
Definition at line 188 of file proto.h.
Referenced by mss_fixup_ipv4(), and mss_fixup_ipv6().
#define OPENVPN_TCPOLEN_MAXSEG 4 |
Definition at line 205 of file proto.h.
Referenced by mss_fixup_dowork().
#define OPENVPN_TCPOPT_EOL 0 |
Definition at line 202 of file proto.h.
Referenced by mss_fixup_dowork().
#define OPENVPN_TCPOPT_MAXSEG 2 |
Definition at line 204 of file proto.h.
Referenced by mss_fixup_dowork().
#define OPENVPN_TCPOPT_NOP 1 |
Definition at line 203 of file proto.h.
Referenced by mss_fixup_dowork().
#define SIZE_ETH_TO_8021Q_HDR |
Definition at line 84 of file proto.h.
Referenced by vlan_decapsulate(), and vlan_encapsulate().
#define SUB_CHECKSUM_32 | ( | acc, | |
u32 | |||
) |
Definition at line 245 of file proto.h.
Referenced by client_nat_transform().
#define TOP_NET30 1 |
Definition at line 43 of file proto.h.
Referenced by do_ifconfig_ipv4(), do_init_route_list(), helper_client_server(), ifconfig_sanity_check(), init_options(), multi_init(), multi_select_virtual_addr(), parse_topology(), and print_topology().
#define TOP_P2P 2 |
Definition at line 44 of file proto.h.
Referenced by do_ifconfig_ipv4(), do_init_route_list(), helper_client_server(), ifconfig_sanity_check(), multi_select_virtual_addr(), parse_topology(), and print_topology().
#define TOP_SUBNET 3 |
Definition at line 45 of file proto.h.
Referenced by do_ifconfig_ipv4(), helper_client_server(), ifconfig_options_string(), init_tun(), is_tun_p2p(), multi_select_virtual_addr(), multi_set_virtual_addr_env(), options_postprocess_verify_ce(), parse_topology(), print_topology(), tuntap_dhcp_mask(), and tuntap_set_ptp().
#define TOP_UNDEF 0 |
Definition at line 42 of file proto.h.
Referenced by parse_topology(), and print_topology().
|
inlinestatic |
Definition at line 266 of file proto.h.
References BLEN, BPTR, DEV_TYPE_TAP, DEV_TYPE_TUN, ip_checksum(), is_ipv4(), is_ipv6(), likely, OPENVPN_ETH_P_IPV4, OPENVPN_ETH_P_IPV6, OPENVPN_IPH_GET_VER, and openvpn_ethhdr::proto.
Referenced by drop_if_recursive_routing().
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.
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 |
Definition at line 125 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().
bool is_ipv4 | ( | int | tunnel_type, |
struct buffer * | buf | ||
) |
Definition at line 113 of file proto.c.
References is_ipv_X().
Referenced by get_tun_ip_ver(), ip_checksum(), and process_ip_header().
bool is_ipv6 | ( | int | tunnel_type, |
struct buffer * | buf | ||
) |
Definition at line 118 of file proto.c.
References is_ipv_X().
Referenced by get_tun_ip_ver(), ipv6_send_icmp_unreachable(), and process_ip_header().