~ubuntu-branches/ubuntu/trusty/miro/trusty

« back to all changes in this revision

Viewing changes to portable/libtorrent/include/libtorrent/GeoIP.h

  • Committer: Daniel Hahler
  • Date: 2010-04-13 18:51:35 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: ubuntu-launchpad@thequod.de-20100413185135-xi24v1diqg8w406x
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2
 
/* GeoIP.h
3
 
 *
4
 
 * Copyright (C) 2006 MaxMind LLC
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU Lesser General Public
8
 
 * License as published by the Free Software Foundation; either
9
 
 * version 2.1 of the License, or (at your option) any later version.
10
 
 *
11
 
 * This library 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 GNU
14
 
 * Lesser General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Lesser General Public
17
 
 * License along with this library; if not, write to the Free Software
18
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#ifndef GEOIP_H
22
 
#define GEOIP_H
23
 
 
24
 
#ifdef __cplusplus
25
 
extern "C" {
26
 
#endif
27
 
 
28
 
#include<stdio.h>
29
 
#include<stdlib.h>
30
 
#include<string.h>
31
 
#include <sys/types.h> /* for fstat */
32
 
#include <sys/stat.h>   /* for fstat */
33
 
 
34
 
#define SEGMENT_RECORD_LENGTH 3
35
 
#define STANDARD_RECORD_LENGTH 3
36
 
#define ORG_RECORD_LENGTH 4
37
 
#define MAX_RECORD_LENGTH 4
38
 
#define NUM_DB_TYPES 20
39
 
 
40
 
typedef struct GeoIPTag {
41
 
  FILE *GeoIPDatabase;
42
 
  char *file_path;
43
 
        unsigned char *cache;
44
 
        unsigned char *index_cache;
45
 
        unsigned int *databaseSegments;
46
 
        char databaseType;
47
 
        time_t mtime;
48
 
        int flags;
49
 
        off_t   size;
50
 
        char record_length;
51
 
        int charset; /* 0 iso-8859-1 1 utf8 */
52
 
        int record_iter; /* used in GeoIP_next_record */
53
 
        int netmask; /* netmask of last lookup - set using depth in _GeoIP_seek_record */
54
 
} GeoIP;
55
 
 
56
 
 
57
 
typedef enum {
58
 
        GEOIP_CHARSET_ISO_8859_1 = 0,
59
 
        GEOIP_CHARSET_UTF8       = 1
60
 
} GeoIPCharset;
61
 
 
62
 
typedef struct GeoIPRegionTag {
63
 
        char country_code[3];
64
 
        char region[3];
65
 
} GeoIPRegion;
66
 
 
67
 
typedef enum {
68
 
        GEOIP_STANDARD = 0,
69
 
        GEOIP_MEMORY_CACHE = 1,
70
 
        GEOIP_CHECK_CACHE = 2,
71
 
        GEOIP_INDEX_CACHE = 4,
72
 
        GEOIP_MMAP_CACHE = 8
73
 
} GeoIPOptions;
74
 
 
75
 
typedef enum {
76
 
        GEOIP_COUNTRY_EDITION     = 1,
77
 
        GEOIP_REGION_EDITION_REV0 = 7,
78
 
        GEOIP_CITY_EDITION_REV0   = 6,
79
 
        GEOIP_ORG_EDITION         = 5,
80
 
        GEOIP_ISP_EDITION         = 4,
81
 
        GEOIP_CITY_EDITION_REV1   = 2,
82
 
        GEOIP_REGION_EDITION_REV1 = 3,
83
 
        GEOIP_PROXY_EDITION       = 8,
84
 
        GEOIP_ASNUM_EDITION       = 9,
85
 
        GEOIP_NETSPEED_EDITION    = 10,
86
 
        GEOIP_DOMAIN_EDITION      = 11
87
 
} GeoIPDBTypes;
88
 
 
89
 
typedef enum {
90
 
        GEOIP_ANON_PROXY = 1,
91
 
        GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
92
 
        GEOIP_HTTP_CLIENT_IP_PROXY = 3
93
 
} GeoIPProxyTypes;
94
 
 
95
 
typedef enum {
96
 
        GEOIP_UNKNOWN_SPEED = 0,
97
 
        GEOIP_DIALUP_SPEED = 1,
98
 
        GEOIP_CABLEDSL_SPEED = 2,
99
 
        GEOIP_CORPORATE_SPEED = 3
100
 
} GeoIPNetspeedValues;
101
 
 
102
 
extern char **GeoIPDBFileName;
103
 
extern const char * GeoIPDBDescription[NUM_DB_TYPES];
104
 
extern const char *GeoIPCountryDBFileName;
105
 
extern const char *GeoIPRegionDBFileName;
106
 
extern const char *GeoIPCityDBFileName;
107
 
extern const char *GeoIPOrgDBFileName;
108
 
extern const char *GeoIPISPDBFileName;
109
 
 
110
 
extern const char GeoIP_country_code[253][3];
111
 
extern const char GeoIP_country_code3[253][4];
112
 
extern const char * GeoIP_country_name[253];
113
 
extern const char GeoIP_country_continent[253][3];
114
 
 
115
 
#ifdef DLL
116
 
#define GEOIP_API __declspec(dllexport)
117
 
#else
118
 
#define GEOIP_API
119
 
#endif  /* DLL */
120
 
 
121
 
GEOIP_API void GeoIP_setup_custom_directory(char *dir);
122
 
GEOIP_API GeoIP* GeoIP_open_type (int type, int flags);
123
 
GEOIP_API GeoIP* GeoIP_new(int flags);
124
 
GEOIP_API GeoIP* GeoIP_open(const char * filename, int flags);
125
 
GEOIP_API int GeoIP_db_avail(int type);
126
 
GEOIP_API void GeoIP_delete(GeoIP* gi);
127
 
GEOIP_API const char *GeoIP_country_code_by_addr (GeoIP* gi, const char *addr);
128
 
GEOIP_API const char *GeoIP_country_code_by_name (GeoIP* gi, const char *host);
129
 
GEOIP_API const char *GeoIP_country_code3_by_addr (GeoIP* gi, const char *addr);
130
 
GEOIP_API const char *GeoIP_country_code3_by_name (GeoIP* gi, const char *host);
131
 
GEOIP_API const char *GeoIP_country_name_by_addr (GeoIP* gi, const char *addr);
132
 
GEOIP_API const char *GeoIP_country_name_by_name (GeoIP* gi, const char *host);
133
 
GEOIP_API const char *GeoIP_country_name_by_ipnum (GeoIP* gi, unsigned long ipnum);
134
 
GEOIP_API const char *GeoIP_country_code_by_ipnum (GeoIP* gi, unsigned long ipnum);
135
 
GEOIP_API const char *GeoIP_country_code3_by_ipnum (GeoIP* gi, unsigned long ipnum);
136
 
 
137
 
/* Deprecated - for backwards compatibility only */
138
 
GEOIP_API int GeoIP_country_id_by_addr (GeoIP* gi, const char *addr);
139
 
GEOIP_API int GeoIP_country_id_by_name (GeoIP* gi, const char *host);
140
 
GEOIP_API char *GeoIP_org_by_addr (GeoIP* gi, const char *addr);
141
 
GEOIP_API char *GeoIP_org_by_name (GeoIP* gi, const char *host);
142
 
/* End deprecated */
143
 
 
144
 
GEOIP_API int GeoIP_id_by_addr (GeoIP* gi, const char *addr);
145
 
GEOIP_API int GeoIP_id_by_name (GeoIP* gi, const char *host);
146
 
GEOIP_API int GeoIP_id_by_ipnum (GeoIP* gi, unsigned long ipnum);
147
 
 
148
 
GEOIP_API GeoIPRegion * GeoIP_region_by_addr (GeoIP* gi, const char *addr);
149
 
GEOIP_API GeoIPRegion * GeoIP_region_by_name (GeoIP* gi, const char *host);
150
 
GEOIP_API GeoIPRegion * GeoIP_region_by_ipnum (GeoIP *gi, unsigned long ipnum);
151
 
 
152
 
/* Warning - don't call this after GeoIP_assign_region_by_inetaddr calls */
153
 
GEOIP_API void GeoIPRegion_delete (GeoIPRegion *gir);
154
 
 
155
 
GEOIP_API void GeoIP_assign_region_by_inetaddr(GeoIP* gi, unsigned long inetaddr, GeoIPRegion *gir);
156
 
 
157
 
/* Used to query GeoIP Organization, ISP and AS Number databases */
158
 
GEOIP_API char *GeoIP_name_by_ipnum (GeoIP* gi, unsigned long ipnum);
159
 
GEOIP_API char *GeoIP_name_by_addr (GeoIP* gi, const char *addr);
160
 
GEOIP_API char *GeoIP_name_by_name (GeoIP* gi, const char *host);
161
 
 
162
 
GEOIP_API char *GeoIP_database_info (GeoIP* gi);
163
 
GEOIP_API unsigned char GeoIP_database_edition (GeoIP* gi);
164
 
 
165
 
GEOIP_API int GeoIP_charset (GeoIP* gi);
166
 
GEOIP_API int GeoIP_set_charset (GeoIP* gi, int charset);
167
 
 
168
 
GEOIP_API int GeoIP_last_netmask (GeoIP* gi);
169
 
 
170
 
/* Convert region code to region name */
171
 
GEOIP_API const char * GeoIP_region_name_by_code(const char *country_code, const char *region_code);
172
 
 
173
 
/* Get timezone from country and region code */
174
 
GEOIP_API const char * GeoIP_time_zone_by_country_and_region(const char *country_code, const char *region_code);
175
 
 
176
 
#ifdef __cplusplus
177
 
}
178
 
#endif
179
 
 
180
 
#endif /* GEOIP_H */