Kamailio – Changing the From URI for Level3

So Level3 uses the E.164 recommendation for sending caller information. The problem with this is that they send a + prefix to the phone number. The problem with sending the + in the caller number, is that a common desk phone (Polycom/Cisco/Yealink/Aastra) will try to make an IP call to the number, or just fail. It seems like only cell phones handle the + character in a number.

So to keep that plus out of the network, I added the following code to my kamailio.cfg to “filter” out the + before sending to the caller.

$avp(s:from)=$fu;
$avp(s:from) = $(fu{re.subst,/\+1//g});
  if ($(avp(s:from){s.len}) == 0) { $avp(s:from)  = $fu; }
uac_replace_from("$avp(s:from)");

Maybe there is a better way, but this is working in production. Let me know if anyone has a better method!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.