From-pstn-toheader context does not work

I believe this change broke from-pstn-to-header. I undid the change and it worked fine.

Debian 12
FreePBX 17.0.15.8
Asterisk 21.0.2

That change makes a big assumption that the (Asterisk) extension being matched starts with a digit. It won’t match calls that start in the s extension or where the request starts with a + for example. Definitely some room for improvement.

On a side note, I don’t understand why providers use the To header instead of sending the DID in the request URI.

1 Like

Because that would violate the SIP protocol when using registration. When you register, you are telling the registrar to use the whole Contact header URI as the request URI to correctly reach you. mot just the domain part. If you only have one DID on the account, you can set the user part of the contact header to the DID.

Noted, I’ve escalated to engineering to revert this.

Edit FREEPBX17-29- changes be reverted and ignore the warnings by prasanthcode4 · Pull Request #6 · FreePBX/ivr · GitHub

Good point. I don’t usually think about registration and multi-DID trunks in the same context.

Except for the part where the RURI can be manipulated, which is completely allowed in SIP protocols. The To header is going to contain the original digits that where being requested even if the location lookup or even routing via IP.

So I have a call come in to a DID, that DID matches to a user, I can grab that user location and then modify the Request URI to have the IP:port and change the user portion to the destination DID. The Asterisk endpoint will match based on IP and route the call to the incoming context.

In Asterisk speak, incoming call comes into DID and the context says send to extension 500 which is registered. I can just do Dial(PJSIP/${FROM_DID}@endpoint) which will use the endpoint and AOR on said endpoint and overwrites the user portion. When it grabs the AOR contact which is sip:[email protected]:50631 it will make the RURI sip:[email protected]:50631

Modifying the Request URI for this is allowed and can be done. Just not everyone chooses to do it because it’s a bit more work.