Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / msc_geo.h
1 /*
2  * ModSecurity for Apache 2.x, http://www.modsecurity.org/
3  * Copyright (c) 2004-2009 Breach Security, Inc. (http://www.breach.com/)
4  *
5  * This product is released under the terms of the General Public Licence,
6  * version 2 (GPLv2). Please refer to the file LICENSE (included with this
7  * distribution) which contains the complete text of the licence.
8  *
9  * There are special exceptions to the terms and conditions of the GPL
10  * as it is applied to this software. View the full text of the exception in
11  * file MODSECURITY_LICENSING_EXCEPTION in the directory of this software
12  * distribution.
13  *
14  * If any of the files related to licensing are missing or if you have any
15  * other questions related to licensing please contact Breach Security, Inc.
16  * directly using the email address support@breach.com.
17  *
18  */
19 #ifndef _MSC_GEO_H_
20 #define _MSC_GEO_H_
21
22 #define GEO_STRUCT_INFO_MAX_SIZE  20
23 #define GEO_DB_INFO_MAX_SIZE      100
24 #define GEO_COUNTRY_OFFSET        0xffff00
25 #define GEO_MAX_RECORD_LEN        4
26 #define GEO_COUNTRY_UNKNOWN       "Unknown"
27 #define GEO_CITY_UNKNOWN          "Unknown"
28 #define GEO_CITY_RECORD_LEN       50
29 #define GEO_COUNTRY_DATABASE      1
30 #define GEO_CITY_DATABASE_0       6
31 #define GEO_CITY_DATABASE_1       2
32 #define GEO_COUNTRY_LAST          250
33
34
35 typedef struct geo_rec geo_rec;
36 typedef struct geo_db geo_db;
37
38 #include <apr_file_io.h>
39 #include "modsecurity.h"
40
41 /* Structures */
42
43 struct geo_rec {
44     const char *country_code;
45     const char *country_code3;
46     const char *country_name;
47     const char *country_continent;
48     const char *region;
49     const char *city;
50     const char *postal_code;
51     float       latitude;
52     float       longitude;
53     int         dma_code;
54     int         area_code;
55 };
56
57 struct geo_db {
58     apr_file_t *db;
59     const char *dbfn;
60     int dbtype;
61     unsigned int ctry_offset;
62 };
63
64 /* Functions */
65
66 int DSOLOCAL geo_init(directory_config *dcfg, const char *dbfn, char **error_msg);
67
68 int DSOLOCAL geo_lookup(modsec_rec *msr, geo_rec *rec, const char *target, char **error_msg);
69
70 apr_status_t DSOLOCAL geo_cleanup(modsec_rec *msr);
71
72 #endif