#ifndef H_COMMON
#define H_COMMON

#define QNAME_SIZE 128

#define REQ_QUERY   0x00
#define REQ_ANSWER  0x01

/* See section 2.3.4 RFC 1035 */
#define MAX_UDP_PAYLOAD 512
#define MAx_NAME_LEN    255 

struct dnshdr {
    uint16_t transactionID;
    uint16_t flags;
    uint16_t nbQuestions;
    uint16_t nbAnswerRRs;
    uint16_t nbAuthorityRRs;
    uint16_t nbAdditionalRRs;
};

struct event {
    uint32_t client;
    int dport;
    int sport;
    uint16_t tid;
    int req_type;
    char qname[QNAME_SIZE];
    uint16_t class;
    uint16_t type;
    uint16_t numAns;
    unsigned char buf[MAX_UDP_PAYLOAD]; // On stocke la data au format size + data
};

struct query_section{
    char qname[QNAME_SIZE];
    size_t qname_len;
    uint16_t class;
    uint16_t type;
};

struct dns_answer {
    char data[512];
    uint16_t class;
    uint16_t type;
    uint32_t ttl;
};

#endif
