2016-01-31 11:42:28 +01:00
|
|
|
#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;
|
2016-02-04 20:39:50 +01:00
|
|
|
#define REQ_IPV4 4
|
|
|
|
#define REQ_IPV6 16
|
2016-01-31 11:42:28 +01:00
|
|
|
uint8_t err;
|
|
|
|
uint8_t ip_type; // 4 or 6
|
|
|
|
uint32_t flags;
|
2016-02-04 20:39:50 +01:00
|
|
|
uint8_t ip[16]; // ipv4 or ipv6
|
2016-01-31 11:42:28 +01:00
|
|
|
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
|
|
|
|
};
|