<p>Currently you have the following information available when using <code>phonenum_match(num, pvc)</code> from the <code>phonenum</code> module:</p>
<ul>
<li>number - phone number that is matched</li>
<li>valid - 1 if the matched number has a valid result; 0 otherwise</li>
<li>normalized - normalized phone number</li>
<li>cctel - country code for phone number</li>
<li>ltype - local network type</li>
<li>ndesc - phone number description</li>
<li>error - error string if phone number matching fails.</li>
</ul>
<p>It would be useful to have access also to the <code>cc</code> information.</p>
<p>Right now, <code>cctel</code> outputs the country code (digits) for the number.</p>
<p>Example:</p>
<p>+34123456789 --> cctel = 34</p>
<p>The enhancement would be to add the country code (string) for the number (maybe in the <code>cc</code> position?):</p>
<p>+34123456789 --> cc = ES</p>
<p>Having a look at the phonenum module code (<code>cphonenumber.cpp</code>), 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:</p>
<p><a href="https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L138">https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L138</a></p>
<pre><code> string regionCode;
        _phoneUtil.GetRegionCodeForNumber(parsedNumber, &regionCode);
        res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
</code></pre>
<p>Something like (pseudocode, this obviously doesn't work but gives the idea):</p>
<pre><code> string regionCode;
        _phoneUtil.GetRegionCodeForNumber(parsedNumber, &regionCode);
        res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
        res->cc = regionCode;
</code></pre>
<p>So then later in kamailio you can do for example:</p>
<p><code>xlog("L_INFO", "Call from $phn(src=>cc) to $phn(dst=>cc)\n");</code></p>
<p>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:</p>
<p><a href="https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L94">https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphonenumber.cpp#L94</a></p>
<p>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.</p>
<p>Thanks!</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1576">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36Zc2qrZjrrhNVQvqSxfDUMwZnkyOrks5uBnRDgaJpZM4U9dBn">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZTvTGN7UquCGePG-B3WLcjW2PWdRks5uBnRDgaJpZM4U9dBn.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Enhancement on phonenum module: add CountryCode (string) (#1576)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1576"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1576",
"url": "https://github.com/kamailio/kamailio/issues/1576",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Enhancement on phonenum module: add CountryCode (string) (#1576)",
"sections": [
{
"text": "",
"activityTitle": "**Joel Serrano**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@joelsdc",
"facts": [
{
"name": "Repository: ",
"value": "kamailio/kamailio"
},
{
"name": "Issue #: ",
"value": 1576
}
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1576,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1576\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1576"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 351653991\n}"
}
],
"themeColor": "26292E"
}
]</script>