[asterisk-users] Global number rewriting rules affecting ALL headers?

Benoit Panizzon benoit.panizzon at imp.ch
Tue Nov 19 04:10:40 CST 2019

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.


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

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

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
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

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch

More information about the asterisk-users mailing list