#include // std::swap #include #include #include #include #include // inet_ntop #include struct SocketAddr { uint32_t saddr, daddr; uint16_t sport, dport; bool operator==(const SocketAddr& rhs) const { return saddr == rhs.saddr && daddr == rhs.daddr && sport == rhs.sport && dport == rhs.dport; } bool operator<(const SocketAddr& rhs) const { BOOST_STATIC_ASSERT(sizeof(SocketAddr) == 12); return memcmp(this, &rhs, sizeof(rhs)) < 0; } }; int tun_alloc(char dev[IFNAMSIZ], bool offload = false); uint16_t in_checksum(const void* buf, int len); void icmp_input(int fd, const void* input, const void* payload, int len);