IP to Geo

IP to Geo Git Source Tree

Root/src/protocol.h

1/*
2 Copyright 2016 Grégory Soutadé
3
4 This file is part of iptogeo.
5
6 iptogeo is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 iptogeo is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with iptogeo. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include <stdint.h>
21
22#define REQ_MAGIC 0x179E08EF
23
24typedef struct {
25 uint32_t magic;
26#define REQ_VERSION 1
27 uint8_t version;
28#define REQ_REQ 1
29#define REQ_RESP 0
30 uint8_t req;
31#define REQ_IPV4 4
32#define REQ_IPV6 16
33 uint8_t err;
34 uint8_t ip_type; // 4 or 6
35 uint32_t flags;
36 uint8_t ip[16]; // ipv4 or ipv6
37 uint8_t country_code[4];
38} request_t;
39
40enum {
41 REQ_ERR_NO_ERR = 0,
42 REQ_ERR_BAD_MAGIC,
43 REQ_ERR_BAD_VERSION,
44 REQ_ERR_BAD_REQ_FIELD,
45 REQ_ERR_BAD_IP_VERSION,
46 REQ_ERR_UNSUPPORTED_IP_VERSION, // 5
47 REQ_IP_NOT_FOUND, // Not really an error
48};

Archive Download this file

Branches

Tags