summaryrefslogtreecommitdiff
path: root/geoip.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-04-17 20:31:24 +0300
committerTobias Klauser <tklauser@distanz.ch>2016-04-18 16:25:10 +0200
commitf61f39d3972960d795d3d5e5fe6e16179591e2bb (patch)
tree591f25d671ee3494ef2d4cdb1c6fcbb6506456ce /geoip.c
parent74babd0fa3cb34b247222c751c928b76fc84df36 (diff)
geoip: Allow to get country 3-code
Add func to get country code-3 name by IPv4/6 address Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'geoip.c')
-rw-r--r--geoip.c14
1 files changed, 14 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