Internal numbering, or internal extensions are common practice among SIP providers for having multiple DID numbers on a single SIP registration.
MyNetFone is a good example. You register to MyNetFone using your assigned internal extension, eg, 0946xxxx. In my case, I have two regional DID numbers assigned to my account.
Problem
Inbound calls to these regional numbers show the following in the SIP INVITE packet:
To: <sip:[email protected]>
How can I find which number was dialled and re-write the To: header? I want FreeSWITCH to route these calls through the same rules as my numbers from other providers. I want to route these numbers to different destinations if required.
Solution
After some investigation I discovered MyNetFone places the "dialled" number in the Diversion: header shown below:
Diversion: <sip:[email protected]>;reason=unconditional
As mentioned, I have multiple numbers routing through a common set of dialplan rules; requiring me to normalise (E.164) all incoming calls. This structure makes it very easy to re-write the header.
The first XML dialplan in my public SIP profile is "00_normalisation.xml". An excerpt is shown below that re-writes the Diversion header:
<include>
<extension name="mynetfone_normalisation" continue="true">
<condition field="destination_number" expression="0946xxxx" require-nested="true" break="on-false">
<condition field="${sip_h_Diversion}" expression="^(?:<sip:)?(\d+)(?:@.+)?$">
<action application="set" data="sip_h_Diversion=null"/>
<action application="transfer" data="$1 XML public"/>
</condition>
</condition>
</extension>
...
</include>
Note: Place this rule at the top of the file for normalisation to occur after the transfer.
Also for anyone interested, I have included my SIP provider configuration I use for MyNetFone; it's nice and simple:
<include>
<gateway name="MyNetFone">
<param name="username" value="0946xxxx"/>
<param name="password" value="xxxxxxxxxxxxxxxxxxx"/>
<param name="realm" value="sip01.mynetfone.com.au"/>
<param name="proxy" value="sip01.mynetfone.com.au"/>
<param name="register" value="true"/>
<param name="expire-seconds" value="120"/>
</gateway>
</include>
Jourdan