Tor
0.4.7.0-alpha-dev
|
Header file for geoip.c. More...
#include "orconfig.h"
#include "lib/net/nettypes.h"
#include "lib/testsupport/testsupport.h"
#include "lib/net/inaddr_st.h"
#include "lib/geoip/country.h"
Go to the source code of this file.
Data Structures | |
struct | geoip_country_t |
Functions | |
int | geoip_get_country_by_ipv4 (uint32_t ipaddr) |
int | geoip_get_country_by_ipv6 (const struct in6_addr *addr) |
const struct smartlist_t * | geoip_get_countries (void) |
int | geoip_load_file (sa_family_t family, const char *filename, int severity) |
int | geoip_get_country_by_addr (const struct tor_addr_t *addr) |
int | geoip_get_n_countries (void) |
const char * | geoip_get_country_name (country_t num) |
int | geoip_is_loaded (sa_family_t family) |
const char * | geoip_db_digest (sa_family_t family) |
country_t | geoip_get_country (const char *countrycode) |
void | geoip_free_all (void) |
const char* geoip_db_digest | ( | sa_family_t | family | ) |
void geoip_free_all | ( | void | ) |
const struct smartlist_t* geoip_get_countries | ( | void | ) |
Return a list of geoip_country_t for all known countries.
Definition at line 89 of file geoip.c.
Referenced by geoip_get_request_history().
country_t geoip_get_country | ( | const char * | country | ) |
int geoip_get_country_by_ipv4 | ( | uint32_t | ipaddr | ) |
Given an IP address in host order, return a number representing the country to which that address belongs, -1 for "No geoip information available", or 0 for the 'unknown country'. The return value will always be less than geoip_get_n_countries(). To decode it, call geoip_get_country_name().
Definition at line 391 of file geoip.c.
Referenced by geoip_get_country_by_addr(), and getinfo_helper_geoip().
int geoip_get_country_by_ipv6 | ( | const struct in6_addr * | addr | ) |
Given an IPv6 address, return a number representing the country to which that address belongs, -1 for "No geoip information available", or 0 for the 'unknown country'. The return value will always be less than geoip_get_n_countries(). To decode it, call geoip_get_country_name().
Definition at line 407 of file geoip.c.
Referenced by geoip_get_country_by_addr(), and getinfo_helper_geoip().
const char* geoip_get_country_name | ( | country_t | num | ) |
Return the two-letter country code associated with the number num, or "??" for an unknown value.
Definition at line 447 of file geoip.c.
Referenced by addr_is_in_cc_list().
int geoip_get_n_countries | ( | void | ) |
Return the number of countries recognized by the GeoIP country list.
Definition at line 437 of file geoip.c.
Referenced by geoip_get_client_history().
int geoip_is_loaded | ( | sa_family_t | family | ) |
Return true iff we have loaded a GeoIP database.
Definition at line 458 of file geoip.c.
Referenced by config_maybe_load_geoip_files_(), geoip_get_client_history(), and getinfo_helper_geoip().
int geoip_load_file | ( | sa_family_t | family, |
const char * | filename, | ||
int | severity | ||
) |
Clear appropriate GeoIP database, based on family, and reload it from the file filename. Return 0 on success, -1 on failure.
Recognized line formats for IPv4 are: INTIPLOW,INTIPHIGH,CC and "INTIPLOW","INTIPHIGH","CC","CC3","COUNTRY NAME" where INTIPLOW and INTIPHIGH are IPv4 addresses encoded as 4-byte unsigned integers, and CC is a country code.
Recognized line format for IPv6 is: IPV6LOW,IPV6HIGH,CC where IPV6LOW and IPV6HIGH are IPv6 addresses and CC is a country code.
It also recognizes, and skips over, blank lines and lines that start with '#' (comments).
Definition at line 324 of file geoip.c.
Referenced by config_load_geoip_file_().