1 /* $NetBSD: geoip.h,v 1.1.1.3 2014/12/10 03:34:42 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef DNS_GEOIP_H 20 #define DNS_GEOIP_H 1 21 22 /***** 23 ***** Module Info 24 *****/ 25 26 /*! \file dns/acl.h 27 * \brief 28 * Address match list handling. 29 */ 30 31 /*** 32 *** Imports 33 ***/ 34 35 #include <isc/lang.h> 36 #include <isc/magic.h> 37 #include <isc/netaddr.h> 38 #include <isc/refcount.h> 39 40 #include <dns/name.h> 41 #include <dns/types.h> 42 #include <dns/iptable.h> 43 44 #ifdef HAVE_GEOIP 45 #include <GeoIP.h> 46 #else 47 typedef void GeoIP; 48 #endif 49 50 /*** 51 *** Types 52 ***/ 53 54 typedef enum { 55 dns_geoip_countrycode, 56 dns_geoip_countrycode3, 57 dns_geoip_countryname, 58 dns_geoip_region, 59 dns_geoip_regionname, 60 dns_geoip_country_code, 61 dns_geoip_country_code3, 62 dns_geoip_country_name, 63 dns_geoip_region_countrycode, 64 dns_geoip_region_code, 65 dns_geoip_region_name, 66 dns_geoip_city_countrycode, 67 dns_geoip_city_countrycode3, 68 dns_geoip_city_countryname, 69 dns_geoip_city_region, 70 dns_geoip_city_regionname, 71 dns_geoip_city_name, 72 dns_geoip_city_postalcode, 73 dns_geoip_city_metrocode, 74 dns_geoip_city_areacode, 75 dns_geoip_city_continentcode, 76 dns_geoip_city_timezonecode, 77 dns_geoip_isp_name, 78 dns_geoip_org_name, 79 dns_geoip_as_asnum, 80 dns_geoip_domain_name, 81 dns_geoip_netspeed_id 82 } dns_geoip_subtype_t; 83 84 typedef struct dns_geoip_elem { 85 dns_geoip_subtype_t subtype; 86 GeoIP *db; 87 union { 88 char as_string[256]; 89 int as_int; 90 }; 91 } dns_geoip_elem_t; 92 93 typedef struct dns_geoip_databases { 94 GeoIP *country_v4; /* DB 1 */ 95 GeoIP *city_v4; /* DB 2 or 6 */ 96 GeoIP *region; /* DB 3 or 7 */ 97 GeoIP *isp; /* DB 4 */ 98 GeoIP *org; /* DB 5 */ 99 GeoIP *as; /* DB 9 */ 100 GeoIP *netspeed; /* DB 10 */ 101 GeoIP *domain; /* DB 11 */ 102 GeoIP *country_v6; /* DB 12 */ 103 GeoIP *city_v6; /* DB 30 or 31 */ 104 } dns_geoip_databases_t; 105 106 /*** 107 *** Functions 108 ***/ 109 110 ISC_LANG_BEGINDECLS 111 112 isc_boolean_t 113 dns_geoip_match(const isc_netaddr_t *reqaddr, 114 const dns_geoip_databases_t *geoip, 115 const dns_geoip_elem_t *elt); 116 117 void 118 dns_geoip_shutdown(void); 119 120 ISC_LANG_ENDDECLS 121 #endif /* DNS_GEOIP_H */ 122