summaryrefslogtreecommitdiff
path: root/geoip.h
blob: b1e2bb50bee07c615d6b3584669e5455b50d8baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef GEOIPH_H
#define GEOIPH_H

#include <stdio.h>
#include <netinet/in.h>

#include "config.h"
#include "die.h"

#if defined(HAVE_GEOIP) && defined(HAVE_LIBZ)
extern void init_geoip(int enforce);
extern void update_geoip(void);
extern int geoip_working(void);
extern char *geoip4_city_name(struct sockaddr_in *sa);
extern char *geoip6_city_name(struct sockaddr_in6 *sa);
extern char *geoip4_region_name(struct sockaddr_in *sa);
extern char *geoip6_region_name(struct sockaddr_in6 *sa);
extern const char *geoip4_country_name(struct sockaddr_in *sa);
extern const char *geoip6_country_name(struct sockaddr_in6 *sa);
extern const char *geoip4_country_code3_name(struct sockaddr_in *sa);
extern const char *geoip6_country_code3_name(struct sockaddr_in6 *sa);
extern float geoip4_longitude(struct sockaddr_in *sa);
extern float geoip4_latitude(struct sockaddr_in *sa);
extern float geoip6_longitude(struct sockaddr_in6 *sa);
extern float geoip6_latitude(struct sockaddr_in6 *sa);
extern const char *geoip4_as_name(struct sockaddr_in *sa);
extern const char *geoip6_as_name(struct sockaddr_in6 *sa);
extern void destroy_geoip(void);
#else
static inline void init_geoip(int enforce)
{
}

static inline void destroy_geoip(void)
{
}

static inline void update_geoip(void)
{
	panic("No built-in geoip support!\n");
}

static inline int geoip_working(void)
{
	return 0;
}

static inline char *geoip4_city_name(struct sockaddr_in *sa)
{
	return NULL;
}

static inline char *geoip6_city_name(struct sockaddr_in6 *sa)
{
	return NULL;
}

static inline char *geoip4_region_name(struct sockaddr_in *sa)
{
	return NULL;
}

static inline char *geoip6_region_name(struct sockaddr_in6 *sa)
{
	return NULL;
}

static inline const char *geoip4_country_name(struct sockaddr_in *sa)
{
	return NULL;
}

static inline const char *geoip6_country_name(struct sockaddr_in6 *sa)
{
	return NULL;
}

static inline float geoip4_longitude(struct sockaddr_in *sa)
{
	return .0f;
}

static inline float geoip4_latitude(struct sockaddr_in *sa)
{
	return .0f;
}

static inline float geoip6_longitude(struct sockaddr_in6 *sa)
{
	return .0f;
}

static inline float geoip6_latitude(struct sockaddr_in6 *sa)
{
	return .0f;
}

static inline const char *geoip4_as_name(struct sockaddr_in *sa)
{
	return NULL;
}

static inline const char *geoip6_as_name(struct sockaddr_in6 *sa)
{
	return NULL;
}

static inline const char *geoip4_country_code3_name(struct sockaddr_in *sa)
{
	return NULL;
}

static inline const char *geoip6_country_code3_name(struct sockaddr_in6 *sa)
{
	return NULL;
}
#endif

#endif /* GEOIPH_H */