Getting the user agent of a calling PJSIP peer

While on chan_sip is extremely easy to get the useragent of a calling extension (${CHANNEL(useragent)}) on PJSIP it appears more challenging.

The user-agent is obtained by using the PJSIP_CONTACT() function, specifying the “contact” to get the user agent.

How can I get the “contact” of the current received call?

CHANNEL(contact) should tell you what contact is calling.

No, I have already checked and that function returns empty value when queried as it is also explained in the manual:

  • contact - R/O The name of the contact associated with this channel. Use the PJSIP_CONTACT function to obtain further contact related information. Note this may not be present and if so is only available on outgoing legs.

Just to be clear, I am receiving the invite from the phone and I want to check its user agent.

Can you use the PJSIP_HEADER dialplan function[1] to get the User-Agent header from the INVITE?

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Function_PJSIP_HEADER

Yes I can. It works. I wonder why I haven’t think about it before asking here.

For the records, it is ${PJSIP_HEADER(read,user-agent)}

Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.