geoip.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file geoip.h
  8. * \brief Header file for geoip.c.
  9. **/
  10. #ifndef TOR_GEOIP_H
  11. #define TOR_GEOIP_H
  12. #include "lib/testsupport/testsupport.h"
  13. #ifdef GEOIP_PRIVATE
  14. STATIC int geoip_parse_entry(const char *line, sa_family_t family);
  15. STATIC void clear_geoip_db(void);
  16. #endif /* defined(GEOIP_PRIVATE) */
  17. int geoip_get_country_by_ipv4(uint32_t ipaddr);
  18. int geoip_get_country_by_ipv6(const struct in6_addr *addr);
  19. /** A per-country GeoIP record. */
  20. typedef struct geoip_country_t {
  21. char countrycode[3];
  22. } geoip_country_t;
  23. const smartlist_t *geoip_get_countries(void);
  24. int geoip_load_file(sa_family_t family, const char *filename);
  25. MOCK_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr));
  26. MOCK_DECL(int, geoip_get_n_countries, (void));
  27. const char *geoip_get_country_name(country_t num);
  28. MOCK_DECL(int, geoip_is_loaded, (sa_family_t family));
  29. const char *geoip_db_digest(sa_family_t family);
  30. MOCK_DECL(country_t, geoip_get_country, (const char *countrycode));
  31. void geoip_free_all(void);
  32. #endif /* !defined(TOR_GEOIP_H) */