geoip.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 #ifndef DNS_GEOIP_H
00018 #define DNS_GEOIP_H 1
00019 
00020 /*****
00021  ***** Module Info
00022  *****/
00023 
00024 /*! \file dns/acl.h
00025  * \brief
00026  * Address match list handling.
00027  */
00028 
00029 /***
00030  *** Imports
00031  ***/
00032 
00033 #include <isc/lang.h>
00034 #include <isc/magic.h>
00035 #include <isc/netaddr.h>
00036 #include <isc/refcount.h>
00037 
00038 #include <dns/name.h>
00039 #include <dns/types.h>
00040 #include <dns/iptable.h>
00041 
00042 #ifdef HAVE_GEOIP
00043 #include <GeoIP.h>
00044 #else
00045 typedef void GeoIP;
00046 #endif
00047 
00048 /***
00049  *** Types
00050  ***/
00051 
00052 typedef enum {
00053         dns_geoip_countrycode,
00054         dns_geoip_countrycode3,
00055         dns_geoip_countryname,
00056         dns_geoip_region,
00057         dns_geoip_regionname,
00058         dns_geoip_country_code,
00059         dns_geoip_country_code3,
00060         dns_geoip_country_name,
00061         dns_geoip_region_countrycode,
00062         dns_geoip_region_code,
00063         dns_geoip_region_name,
00064         dns_geoip_city_countrycode,
00065         dns_geoip_city_countrycode3,
00066         dns_geoip_city_countryname,
00067         dns_geoip_city_region,
00068         dns_geoip_city_regionname,
00069         dns_geoip_city_name,
00070         dns_geoip_city_postalcode,
00071         dns_geoip_city_metrocode,
00072         dns_geoip_city_areacode,
00073         dns_geoip_city_continentcode,
00074         dns_geoip_city_timezonecode,
00075         dns_geoip_isp_name,
00076         dns_geoip_org_name,
00077         dns_geoip_as_asnum,
00078         dns_geoip_domain_name,
00079         dns_geoip_netspeed_id
00080 } dns_geoip_subtype_t;
00081 
00082 typedef struct dns_geoip_elem {
00083         dns_geoip_subtype_t subtype;
00084         GeoIP *db;
00085         union {
00086                 char as_string[256];
00087                 int as_int;
00088         };
00089 } dns_geoip_elem_t;
00090 
00091 typedef struct dns_geoip_databases {
00092         GeoIP *country_v4;                      /* DB 1        */
00093         GeoIP *city_v4;                         /* DB 2 or 6   */
00094         GeoIP *region;                          /* DB 3 or 7   */
00095         GeoIP *isp;                             /* DB 4        */
00096         GeoIP *org;                             /* DB 5        */
00097         GeoIP *as;                              /* DB 9        */
00098         GeoIP *netspeed;                        /* DB 10       */
00099         GeoIP *domain;                          /* DB 11       */
00100         GeoIP *country_v6;                      /* DB 12       */
00101         GeoIP *city_v6;                         /* DB 30 or 31 */
00102 } dns_geoip_databases_t;
00103 
00104 /***
00105  *** Functions
00106  ***/
00107 
00108 ISC_LANG_BEGINDECLS
00109 
00110 isc_boolean_t
00111 dns_geoip_match(const isc_netaddr_t *reqaddr, isc_uint8_t *scope,
00112                 const dns_geoip_databases_t *geoip,
00113                 const dns_geoip_elem_t *elt);
00114 
00115 void
00116 dns_geoip_shutdown(void);
00117 
00118 ISC_LANG_ENDDECLS
00119 #endif /* DNS_GEOIP_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha