geoip_test.c revision fbe600459d05e644dbda2c36ef091535ea1eacee
/*
* Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id$ */
/*! \file */
#include <config.h>
#include <atf-c.h>
#include <unistd.h>
#include "dnstest.h"
#ifdef HAVE_GEOIP
#include <GeoIP.h>
/* We use GeoIP databases from the 'geoip' system test */
/*
* Helper functions
*/
static dns_geoip_databases_t geoip = {
};
static void
{
char *info;
}
if (! GeoIP_db_avail(edition)) {
goto fail;
}
"failed to initialize GeoIP %s (type %d) DB%s\n",
? "; geoip matches using this database will fail"
: "");
goto fail;
}
return;
fail:
if (fallback != 0)
}
static void
load_geoip(const char *dir) {
#ifdef _WIN32
#else
#endif
char *p;
}
method, "Country (IPv4)");
#ifdef HAVE_GEOIP_V6
method, "Country (IPv6)");
#endif
#if defined(HAVE_GEOIP_V6) && defined(HAVE_GEOIP_CITY_V6)
#endif
method, "ISP");
method, "Org");
method, "AS");
method, "Domain");
method, "NetSpeed");
}
static isc_boolean_t
const char *string)
{
}
static isc_boolean_t
const char *string)
{
}
static isc_boolean_t
}
/*
* Individual unit tests
*/
/* GeoIP country matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_country_code3, "AUS");
dns_geoip_country_name, "Australia");
dns_test_end();
}
/* GeoIP country (ipv6) matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_country_code, "AU");
dns_geoip_country_code3, "AUS");
dns_geoip_country_name, "Australia");
dns_test_end();
}
/* GeoIP city (ipv4) matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_city_continentcode, "NA");
dns_geoip_city_countrycode, "US");
dns_geoip_city_countrycode3, "USA");
dns_geoip_city_countryname, "United States");
dns_geoip_city_region, "CA");
dns_geoip_city_regionname, "California");
dns_geoip_city_name, "Redwood City");
dns_geoip_city_postalcode, "94063");
dns_test_end();
}
/* GeoIP city (ipv6) matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_city_continentcode, "NA");
dns_geoip_city_countrycode, "US");
dns_geoip_city_countrycode3, "USA");
"United States");
dns_geoip_city_region, "CA");
dns_geoip_city_regionname, "California");
dns_geoip_city_name, "Redwood City");
dns_geoip_city_postalcode, "94063");
dns_test_end();
}
/* GeoIP region matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_region_code, "CA");
dns_geoip_region_name, "California");
dns_geoip_region_countrycode, "US");
dns_test_end();
}
/*
* GeoIP best-database matching
* (With no specified databse and a city database available, answers
* should come from city database. With city database unavailable, region
* database. Region database unavailable, country database.)
*/
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_countrycode, "US");
dns_geoip_countrycode3, "USA");
dns_geoip_countryname, "United States");
dns_geoip_regionname, "Virginia");
dns_geoip_region, "VA");
dns_geoip_countrycode, "AU");
/*
* Note, region doesn't support code3 or countryname, so
* the next two would be answered from the country database instead
*/
dns_geoip_countrycode3, "CAN");
dns_geoip_countryname, "Canada");
dns_geoip_countrycode, "CA");
dns_geoip_countrycode3, "CAN");
dns_geoip_countryname, "Canada");
dns_test_end();
}
/* GeoIP asnum matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
"AS100003 Three Network Labs");
dns_test_end();
}
/* GeoIP isp matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
"One Systems, Inc.");
dns_test_end();
}
/* GeoIP org matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
"Two Technology Ltd.");
dns_test_end();
}
/* GeoIP domain matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_geoip_domain_name, "four.com");
dns_test_end();
}
/* GeoIP netspeed matching */
}
/* Use databases from the geoip system test */
dns_test_end();
atf_tc_skip("Database not available");
}
dns_test_end();
}
#else
}
atf_tc_skip("GeoIP not available");
}
#endif
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
#ifdef HAVE_GEOIP
#else
#endif
return (atf_no_error());
}