On 02/11/15 18:52, Daniel Tryba wrote:
On Monday 02 November 2015 17:28:29 Daniel Bryars wrote:
So I'm investigating if it's possible to fix up the number and add the + in Kamailio. Clearly I could detect if the number starts with 44 and change this to +44, but this seems very brittle (what about other international numbers) - it there a proper way to do this, or a standard module?
I do it with a couple of regexps for $fU/$tU$rU. You just have to make some assumtions. It pretty stupid straight forward code, transforming to "e164 plus" format and than back to the endpoint specific settings:
$avp(ntU)=$tU; if($tU=~"^00[1-9][0-9]+$") { $avp(ntU)="+"+$(tU{s.substr,2,0}); } else if($tU=~"^0[1-9][0-9]+$") { $avp(ntU)="+31"+$(tU{s.substr,1,0}); } else if($tU~="^[2-8][0-9]{5,6}$") { $avp(ntU)="+31"+$avp(areacode)+$tU; } else { $avp(ntU)="+"+$tU; }
and use $avp(ntU) with uac_replace_to (after modifiying $ntU to the format desired by endpoint (yet more regexps like above)).
Repeat for $fU and $rU. You might want to to this in an external script instead of kamailio config script though.
If there is a better way, I'd like to know myself.
Dialplan module can be used to do those transformations -- if you have many countries, you can group the country rules under same dialplan id. I used to set dialplan id to to the country code then associate users with it via extra column in subscriber table (which can be loaded with load_credentials parameter in auth_db module). A second extra column might be needed for area code.
Maybe worth collecting the dialplan module rules for different country in a wiki page, so people that are familiar with various countries can contribute.
Cheers, Daniel