[sr-dev] [kamailio/kamailio] Enhancement on phonenum module: add CountryCode (string) (#1576)

Joel Serrano notifications at github.com
Fri Jun 29 20:38:59 CEST 2018


Currently you have the following information available when using `phonenum_match(num, pvc)` from the `phonenum` module:

* number - phone number that is matched
* valid - 1 if the matched number has a valid result; 0 otherwise
* normalized - normalized phone number
* cctel - country code for phone number
* ltype - local network type
* ndesc - phone number description
* error - error string if phone number matching fails.

It would be useful to have access also to the `cc` information.

Right now, `cctel` outputs the country code (digits) for the number.

Example: 

+34123456789 --> cctel = 34

The enhancement would be to add the country code (string) for the number (maybe in the `cc` position?):

+34123456789 --> cc = ES

Having a look at the phonenum module code (`cphonenumber.cpp`), I understand (with my very little idea of C) that country code (string) information is in fact used to get the country code (digits). So I think it would be only a matter of returning one more key:value:

https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L138

```
	string regionCode;
	_phoneUtil.GetRegionCodeForNumber(parsedNumber, &regionCode);
	res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
```

Something like (pseudocode, this obviously doesn't work but gives the idea):

```
	string regionCode;
	_phoneUtil.GetRegionCodeForNumber(parsedNumber, &regionCode);
	res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
	res->cc = regionCode;
```

So then later in kamailio you can do for example:

```xlog("L_INFO", "Call from $phn(src=>cc) to $phn(dst=>cc)\n");```

I have also seen that a function to provide this info exists in the module level, but I haven't seen it used anywhere else but the declaration:

https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L94

This feels like a really easy change and I tried to do it myself, but I didn't manage to get through the complete path from "getting the info" to "making it available in the pvc" so here I am asking for help.

Thanks!


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1576
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20180629/4c12288b/attachment.html>


More information about the sr-dev mailing list