summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--geoip.c14
-rw-r--r--geoip.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/geoip.c b/geoip.c
index ee654a6..917b1a7 100644
--- a/geoip.c
+++ b/geoip.c
@@ -339,6 +339,20 @@ const char *geoip6_country_name(struct sockaddr_in6 *sa)
return GeoIP_country_name_by_ipnum_v6(gi6_country, sa->sin6_addr);
}
+const char *geoip4_country_code3_name(struct sockaddr_in *sa)
+{
+ bug_on(gi4_country == NULL);
+
+ return GeoIP_country_code3_by_ipnum(gi4_country, ntohl(sa->sin_addr.s_addr));
+}
+
+const char *geoip6_country_code3_name(struct sockaddr_in6 *sa)
+{
+ bug_on(gi6_country == NULL);
+
+ return GeoIP_country_code3_by_ipnum_v6(gi6_country, sa->sin6_addr);
+}
+
static int fdout, fderr;
/* GeoIP people were too stupid to come to the idea that you could set
diff --git a/geoip.h b/geoip.h
index 66ed20b..0cbd619 100644
--- a/geoip.h
+++ b/geoip.h
@@ -17,6 +17,8 @@ extern const char *geoip4_region_name(struct sockaddr_in *sa);
extern const char *geoip6_region_name(struct sockaddr_in6 *sa);
extern const char *geoip4_country_name(struct sockaddr_in *sa);
extern const char *geoip6_country_name(struct sockaddr_in6 *sa);
+extern const char *geoip4_country_code3_name(struct sockaddr_in *sa);
+extern const char *geoip6_country_code3_name(struct sockaddr_in6 *sa);
extern float geoip4_longitude(struct sockaddr_in *sa);
extern float geoip4_latitude(struct sockaddr_in *sa);
extern float geoip6_longitude(struct sockaddr_in6 *sa);