Module: kamailio
Branch: master
Commit: 4d1e4e815d4ba7dbfe913caff42715b2adb74720
URL:
https://github.com/kamailio/kamailio/commit/4d1e4e815d4ba7dbfe913caff42715b…
Author: Sergey Okhapkin <sos(a)sokhapkin.dyndns.org>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-03-12T09:57:44+01:00
geoip2: added continet conde for new geoip api pv
---
Modified: modules/geoip2/README
Modified: modules/geoip2/doc/geoip2_admin.xml
Modified: modules/geoip2/geoip2_pv.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4d1e4e815d4ba7dbfe913caff42715b…
Patch:
https://github.com/kamailio/kamailio/commit/4d1e4e815d4ba7dbfe913caff42715b…
---
diff --git a/modules/geoip2/README b/modules/geoip2/README
index c9cb1ed..fd07cdd 100644
--- a/modules/geoip2/README
+++ b/modules/geoip2/README
@@ -141,6 +141,7 @@ if(geoip2_match("$si", "src"))
+ regc - region
+ regn - region name
+ metro - metro code
+ + contc - continent code
Exported pseudo-variables are documented at
http://www.kamailio.org/wiki/.
diff --git a/modules/geoip2/doc/geoip2_admin.xml b/modules/geoip2/doc/geoip2_admin.xml
index 244930d..b944bb3 100644
--- a/modules/geoip2/doc/geoip2_admin.xml
+++ b/modules/geoip2/doc/geoip2_admin.xml
@@ -163,6 +163,9 @@ if(geoip2_match("$si", "src"))
<listitem><para>
<emphasis>metro</emphasis> - metro code
</para></listitem>
+ <listitem><para>
+ <emphasis>contc</emphasis> - continent code
+ </para></listitem>
</itemizedlist>
</listitem>
</itemizedlist>
diff --git a/modules/geoip2/geoip2_pv.c b/modules/geoip2/geoip2_pv.c
index f9f7dbb..69bd719 100644
--- a/modules/geoip2/geoip2_pv.c
+++ b/modules/geoip2/geoip2_pv.c
@@ -41,6 +41,7 @@ typedef struct _sr_geoip2_record {
str region_code;
str region_name;
str country;
+ str cont_code;
char latitude[16];
char longitude[16];
char metro[16];
@@ -207,6 +208,8 @@ int pv_parse_geoip2_name(pv_spec_p sp, str *in)
gpv->type = 12;
else if(strncmp(pvs.s, "nmask", 5)==0)
gpv->type = 13;
+ else if(strncmp(pvs.s, "contc", 5)==0)
+ gpv->type = 6;
else goto error;
break;
default:
@@ -311,6 +314,22 @@ int pv_get_geoip2(struct sip_msg *msg, pv_param_t *param,
}
return pv_geoip2_get_strzval(msg, param, res,
gpv->item->r.longitude);
+ case 6: /* contc */
+ if(gpv->item->r.cont_code.s==NULL)
+ {
+ if(gpv->item->r.flags&16)
+ return pv_get_null(msg, param, res);
+ if(MMDB_get_value(&gpv->item->r.record.entry, &entry_data,
+ "continent","code", NULL
+ ) != MMDB_SUCCESS)
+ return pv_get_null(msg, param, res);
+ if(entry_data.has_data && entry_data.type == MMDB_DATA_TYPE_UTF8_STRING) {
+ gpv->item->r.cont_code.s = (char *)entry_data.utf8_string;
+ gpv->item->r.cont_code.len = entry_data.data_size;
+ }
+ gpv->item->r.flags |= 16;
+ }
+ return pv_get_strval(msg, param, res, &gpv->item->r.cont_code);
case 8: /* city */
if(gpv->item->r.city.s==NULL)
{