<div dir="ltr"><div dir="ltr">On Tue, Nov 19, 2019 at 6:11 AM Benoit Panizzon <<a href="mailto:benoit.panizzon@imp.ch">benoit.panizzon@imp.ch</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi List<br>
<br>
One more Problem I stumbled upon.<br>
<br>
Using Asterisk in a TSP environement.<br>
<br>
Incomming IC Calls are e164 and have a NPRN (Routing Number) prefixed.<br>
<br>
Example: +4198055615995555<br>
+41 country prefix<br>
98055 Routing Prefix<br>
615995555 effective phone number <br>
<br>
Calls routed to Customers need to be put in the 'local' format.<br>
<br>
0615995555<br>
<br>
This is also the format of the From / To / Invite header recieved from<br>
customers.<br>
<br>
Phone Numbers originating from customers have again to get manipulated:<br>
<br>
If this is a ported number to another TSP, the destination TSP NPRN has<br>
to be inserted so it can correctly be routed in transit.<br>
<br>
If it is a emergency phone number, a location based routing prefix has<br>
to be added.<br>
<br>
If it is a value added number, the NPRN of the operator AND and ID<br>
designating the originator TSP of the call has to be prefixed for<br>
billing.<br>
<br>
In the Dialplan (also with help of some AGI Magic doing screening and<br>
routing) it is easy to correctly set the Request User, From and To<br>
Headers.<br>
Setting the PAI correctly was also doable via a pre-dial handler.<br>
<br>
But now I am stuck with the Diversion: header.<br>
<br>
If the call is being redirected by a SIP 301 from a customer, asterisk<br>
is setting a Diversion: Header in the 181 message alerting the caller<br>
of the Diversion and I am absolutely at a loss how I can correctly<br>
rewrite that phone number in this header.<br>
<br>
So I start to wonder, if there is some mechanism within<br>
asterisk on which I could apply correct phone number translations for<br>
each endpoint which would apply to ALL possible headers.<br></blockquote><div><br></div><div>There is no hook to apply to everything, you have to write dialplan logic in various places to do so. There are some cases where there are hooks - redirecting (diversion) and connected line updates[1][2]. </div></div><div><br></div>[1] <a href="https://wiki.asterisk.org/wiki/display/AST/Party+ID+Interception+Macros+and+Routines">https://wiki.asterisk.org/wiki/display/AST/Party+ID+Interception+Macros+and+Routines</a><div>[2] <a href="https://wiki.asterisk.org/wiki/display/AST/Manipulating+Party+ID+Information">https://wiki.asterisk.org/wiki/display/AST/Manipulating+Party+ID+Information</a><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Joshua C. Colp<br>Digium - A Sangoma Company | Senior Software Developer<br>445 Jan Davis Drive NW - Huntsville, AL 35806 - US<br>Check us out at: <a href="http://www.sangoma.com/" target="_blank">www.sangoma.com</a> & <a href="http://www.asterisk.org/" target="_blank">www.asterisk.org</a><br></div></div></div></div>