IP to Geo

IP to Geo Git Source Tree

Root/src/protocol.h

1#include <stdint.h>
2
3#define REQ_MAGIC 0x179E08EF
4
5typedef struct {
6 uint32_t magic;
7#define REQ_VERSION 1
8 uint8_t version;
9#define REQ_REQ 1
10#define REQ_RESP 0
11 uint8_t req;
12#define REQ_IPV4 4
13#define REQ_IPV6 16
14 uint8_t err;
15 uint8_t ip_type; // 4 or 6
16 uint32_t flags;
17 uint8_t ip[16]; // ipv4 or ipv6
18 uint8_t country_code[4];
19} request_t;
20
21enum {
22 REQ_ERR_NO_ERR = 0,
23 REQ_ERR_BAD_MAGIC,
24 REQ_ERR_BAD_VERSION,
25 REQ_ERR_BAD_REQ_FIELD,
26 REQ_ERR_BAD_IP_VERSION,
27 REQ_ERR_UNSUPPORTED_IP_VERSION, // 5
28 REQ_IP_NOT_FOUND, // Not really an error
29};

Archive Download this file

Branches

Tags