Go to the documentation of this file.
113 return is_ipv_X( tunnel_type, buf, 4 );
118 return is_ipv_X( tunnel_type, buf, 6 );
124 const uint8_t *src_addr,
const uint8_t *dest_addr,
const int proto)
127 int addr_len = (af == AF_INET) ? 4 : 16;
133 for (
int i = 0; i < len_payload; i += 2)
135 sum += (uint16_t)(((payload[i] << 8) & 0xFF00)
136 +((i + 1 < len_payload) ? (payload[i + 1] & 0xFF) : 0));
144 for (
int i = 0; i < addr_len; i += 2)
146 sum += (uint16_t)((src_addr[i] << 8) & 0xFF00) + (src_addr[i + 1] & 0xFF);
149 for (
int i = 0; i < addr_len; i += 2)
151 sum += (uint16_t)((dest_addr[i] << 8) & 0xFF00) + (dest_addr[i + 1] & 0xFF);
155 sum += (uint16_t)len_payload;
158 sum += (uint16_t)proto;
166 sum = (sum & 0xFFFF) + (sum >> 16);
170 return ((uint16_t) ~sum);
173 #ifdef PACKET_TRUNCATION_CHECK
176 ipv4_packet_size_verify(
const uint8_t *data,
178 const int tunnel_type,
188 if (
is_ipv4(tunnel_type, &buf))
193 const char *msgstr =
"PACKET SIZE INFO";
207 if (
BLEN(&buf) != totlen)
209 msgstr =
"PACKET TRUNCATION ERROR";
#define D_PACKET_TRUNC_ERR
#define D_PACKET_TRUNC_DEBUG
bool is_ipv6(int tunnel_type, struct buffer *buf)
unsigned short sa_family_t
static bool buf_advance(struct buffer *buf, int size)
#define OPENVPN_ETH_P_8021Q
#define OPENVPN_ETH_P_IPV4
#define verify_align_4(ptr)
Wrapper structure for dynamically allocated memory.
static bool is_ipv_X(int tunnel_type, struct buffer *buf, int ip_ver)
#define OPENVPN_IPH_GET_VER(v)
bool is_ipv4(int tunnel_type, struct buffer *buf)
#define OPENVPN_IPH_GET_LEN(v)
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 void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
#define OPENVPN_ETH_P_IPV6
uint8_t * data
Pointer to the allocated memory.