geoip.h 1.4 KB

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