Monday, 27 October 2014

Accessing the full P-Asserted-Identity header from FreeSWITCH

I hope this can save the reader some time.
If you need to read the entire content of the P-Asserted-Identity header of an incoming INVITE, be aware that you should change the sofia profile by adding a param like:

param name="p-asserted-id-parse" value="verbatim"

FreeSWITCH will populate the variable accordingly and make it available with commands like (e.g. with lua):

PAID = session:getVariable("sip_P-Asserted-Identity")

If you don't add this parameter, you'll get the default behaviour, which is just filling the variable with the P-Asserted-Identity URI username part.

Possible value are: "default", "user-only", "user-domain", "verbatim", which I think are self-explanatory.

A recent reference here.

4 comments:

  1. Hi,
    Is there a way to modify the value of P-Asserted-Identity before it is send to the provider? If I use {sip_cid_type=pid}sofia/gateway/MyProvider/$1, it gets the value in From header.
    The provider wants to see a specific number in PAI and I cannot figure how to do it with FS.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Hi Drago,
      yes, there is a way. With a classical XML dialplan you could try something like this:

      < action application="set" data="sip_h_P-Asserted-Identity=sip:the_user@the_domain"/ >

      Of course you can "build" the final P-Asserted-Identity SIP URI using variables, like:

      < action application="set" data="sip_h_P-Asserted-Identity=sip:${PAI_user}@${PAI_domain}"/ >

      It's easy to do the same with other approaches, like e.g. using Lua and setting that variable to the value you want, before the bridge instruction.

      I hope this helps (and works, depending on your specific set up).

      Giacomo

      Delete