Global Number Rewriting Rules Affecting ALL Headers?

Home » Asterisk Users » Global Number Rewriting Rules Affecting ALL Headers?
Asterisk Users 4 Comments

Hi List

One more Problem I stumbled upon.

Using Asterisk in a TSP environement.

Incomming IC Calls are e164 and have a NPRN (Routing Number) prefixed.

Example: +4198055615995555
+41 country prefix
98055 Routing Prefix
615995555 effective phone number Calls routed to Customers need to be put in the ‘local’ format.

0615995555

This is also the format of the From / To / Invite header recieved from customers.

Phone Numbers originating from customers have again to get manipulated:

If this is a ported number to another TSP, the destination TSP NPRN has to be inserted so it can correctly be routed in transit.

If it is a emergency phone number, a location based routing prefix has to be added.

If it is a value added number, the NPRN of the operator AND and ID
designating the originator TSP of the call has to be prefixed for billing.

In the Dialplan (also with help of some AGI Magic doing screening and routing) it is easy to correctly set the Request User, From and To Headers. Setting the PAI correctly was also doable via a pre-dial handler.

But now I am stuck with the Diversion: header.

If the call is being redirected by a SIP 301 from a customer, asterisk is setting a Diversion: Header in the 181 message alerting the caller of the Diversion and I am absolutely at a loss how I can correctly rewrite that phone number in this header.

So I start to wonder, if there is some mechanism within asterisk on which I could apply correct phone number translations for each endpoint which would apply to ALL possible headers.

Mit freundlichen Grüssen

-Benoît Panizzon-

I m p r o W a r e A G – Leiter Commerce Kunden

4 thoughts on - Global Number Rewriting Rules Affecting ALL Headers?

  • Hi Joshua

    I had a shot at your suggestion, bug still no success.

    I fear the 181 is sent before the macro is called.

    I want to change the Diversion Header in the 181 message sent back to the caller to put the number it contains in the correct e164 format
    (stripping the 0 and adding +41 for Switzerland) but just any ‘dialplan set’ value would do for an example 🙂

    Could you please make an example how to do that?

    PS: CONNECTED_LINE_CALLER_SEND_MACRO is depreciated and should be replaced by: CONNECTED_LINE_CALLER_SEND_SUB

    Do I have to call my routine [sub-routine] and end with ExitSub?

    Mit freundlichen Grüssen

    -Benoît Panizzon-

    I m p r o W a r e A G – Leiter Commerce Kunden

  • I don’t have experience with the specific thing linked, I just remembered it from seeing it in the past. Someone else may have more insight instead.

  • Quick update.

    I guessed right.

    I had put the call to the subrouting on the ‘local’ channel which is created after the call is being redirecting.

    If i put it on the calling channel and setting RDNIS to the correct value, the corrected phone nuber is transmitted to the calling party via Diversion header.

    Similar, on the Local generated call from the remote 301, I could just change CALLERID(RDNIS) to the correct value, causing this value to be sent to the destination in the Diversion header correctly indicating origin and cause of the redirection.

    Mit freundlichen Grüssen

    -Benoît Panizzon-

    I m p r o W a r e A G – Leiter Commerce Kunden