geoip.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/net/nettypes.h"
  13. #include "lib/testsupport/testsupport.h"
  14. #include "lib/geoip/country.h"
  15. #ifdef GEOIP_PRIVATE
  16. STATIC int geoip_parse_entry(const char *line, sa_family_t family);
  17. STATIC void clear_geoip_db(void);
  18. #endif /* defined(GEOIP_PRIVATE) */
  19. struct in6_addr;
  20. struct tor_addr_t;
  21. int geoip_get_country_by_ipv4(uint32_t ipaddr);
  22. int geoip_get_country_by_ipv6(const struct in6_addr *addr);
  23. /** A per-country GeoIP record. */
  24. typedef struct geoip_country_t {
  25. char countrycode[3];
  26. } geoip_country_t;
  27. struct smartlist_t;
  28. const struct smartlist_t *geoip_get_countries(void);
  29. int geoip_load_file(sa_family_t family, const char *filename, int severity);
  30. MOCK_DECL(int, geoip_get_country_by_addr, (const struct tor_addr_t *addr));
  31. MOCK_DECL(int, geoip_get_n_countries, (void));
  32. const char *geoip_get_country_name(country_t num);
  33. MOCK_DECL(int, geoip_is_loaded, (sa_family_t family));
  34. const char *geoip_db_digest(sa_family_t family);
  35. MOCK_DECL(country_t, geoip_get_country, (const char *countrycode));
  36. void geoip_free_all(void);
  37. #endif /* !defined(TOR_GEOIP_H) */