38 lines
732 B
C
38 lines
732 B
C
|
#include <stdint.h>
|
||
|
|
||
|
#define REQ_MAGIC 0x179E08EF
|
||
|
|
||
|
typedef struct {
|
||
|
uint32_t magic;
|
||
|
#define REQ_VERSION 1
|
||
|
uint8_t version;
|
||
|
#define REQ_REQ 1
|
||
|
#define REQ_RESP 0
|
||
|
uint8_t req;
|
||
|
#define REQ_IPV4 32
|
||
|
#define REQ_IPV6 128
|
||
|
uint8_t err;
|
||
|
uint8_t ip_type; // 4 or 6
|
||
|
uint32_t flags;
|
||
|
union {
|
||
|
uint32_t ipv4;
|
||
|
struct {
|
||
|
uint32_t a;
|
||
|
uint32_t b;
|
||
|
uint32_t c;
|
||
|
uint32_t d;
|
||
|
}ipv6;
|
||
|
};
|
||
|
uint8_t country_code[4];
|
||
|
} request_t;
|
||
|
|
||
|
enum {
|
||
|
REQ_ERR_NO_ERR = 0,
|
||
|
REQ_ERR_BAD_MAGIC,
|
||
|
REQ_ERR_BAD_VERSION,
|
||
|
REQ_ERR_BAD_REQ_FIELD,
|
||
|
REQ_ERR_BAD_IP_VERSION,
|
||
|
REQ_ERR_UNSUPPORTED_IP_VERSION, // 5
|
||
|
REQ_IP_NOT_FOUND, // Not really an error
|
||
|
};
|