The patch to return continent code in geoip2 module attached. Daniel, please
apply the diff to the master, I have bad luck fighting with github.
On Wednesday 11 March 2015 11:08:12 Daniel-Constantin Mierla wrote:
> I pushed a path to geoip module in master branch to return continent id
> via 'contid' attribute of the geoip variable. No testing here though,
> therefore I appreciate if you report back it works or not.
>
> Would be good to get it in geoip2 as well -- hopefully Sergey has the
> time for it.
>
> Cheers,
> Daniel
>
> On 11/03/15 01:08, Rene Montilva wrote:
> > I am trying to separate from continent to have rtp more dynamic to
> > simplify the assignment, the geoip i'm working on v1
> >
> > On Tue, Mar 10, 2015 at 7:22 PM, Sergey Okhapkin
> >
> > <s...@sokhapkin.dyndns.org <mailto:s...@sokhapkin.dyndns.org>> wrote:
> > Hmm, I can add continent code pvar to geoip2 module in kamailio
> > trunk. Is it
> > really useful instead of country code?
> >
> > On Tuesday 10 March 2015 19:03:35 Rene Montilva wrote:
> > > Hi list
> > >
> > > i'm trying to configure rtp engine routing by source ip, i'd
> >
> > like divide it
> >
> > > by continent code, is there any pseudo-variables or possibilites
> >
> > to handle
> >
> > > continent code.
> > >
> > > Team, any idea about it?
> >
> > _______________________________________________
> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
> > list
> > sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org>
> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
> >
> > _______________________________________________
> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> > sr-users@lists.sip-router.org
> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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)
{
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users