congestvpn/ip_header.hpp
Théophile Bastian 0b8cf0edc1 Tun: reject packets with bad length
Those packets are probably packets truncated because the buffer is not
large enough.
2020-06-16 20:24:59 +02:00

14 lines
348 B
C++

#pragma once
#include <netinet/in.h>
struct IPv6Header {
in6_addr source;
in6_addr dest;
uint16_t payload_length;
uint16_t packet_length() const { return payload_length + 40; }
};
/** Parse an IPv6 header, filling `header`. Returns `true` on success. */
bool parse_ipv6_header(const char* data, size_t len, IPv6Header& header);