#pragma once
#include "main.hpp"
#include <netinet/in.h>


typedef struct {
    struct in_addr src, dst;
    in_port_t src_port, dst_port;
    usec_t ts; ///< microsecond timestamp
} conn_t;


typedef struct packet_s {
    conn_t conn;

    bool syn, ack, fin;
    uint32_t seq;
    const unsigned char* buf;
    size_t len;

    bool parse(const struct timeval&, const unsigned char*, size_t); ///< tcp/ipv4 only atm
} packet_t;


INLINE bool operator==(const struct in_addr& a, const struct in_addr& b) {
    return a.s_addr == b.s_addr;
}
INLINE bool operator!=(const struct in_addr& a, const struct in_addr& b) {
    return a.s_addr != b.s_addr;
}