2016-02-17 18:15:04 +01:00
|
|
|
/*
|
|
|
|
Copyright 2016 Grégory Soutadé
|
|
|
|
|
|
|
|
This file is part of iptogeo.
|
|
|
|
|
|
|
|
iptogeo is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
iptogeo is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with iptogeo. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
};
|