SIP_HEADERS() equivalent for PJSIP?

Hello!

I’m very new to asterisk and doing a somewhat abnormal thing with it, so please excuse my lack of knowledge.

I essentially have an inbound route and trunk where I am just passing a call through SIP -> SIP. When doing so want to also pass the SIP X-headers through in a generic fashion

At first I guess I was using chan_sip (for inbound) as well as chan_pjsip (for my trunk). I was reading all X-* headers, storing them, and setting them with macros like this:

[bl-custom-read-headers]
exten => s,1,NoOp(Reading the custom headers)
exten => s,n,Set(inheaders=${SIP_HEADERS(X-)},${SIP_HEADERS(x-)})
exten => s,n,NoOp(Got headers: ${inheaders})
exten => s,n,While($["${SET(header=${SHIFT(inheaders)})}" != ""])
exten => s,n,Set(HASH(_blHeaders,${header})=${SIP_HEADER(${header})})
exten => s,n,EndWhile
exten => s,n,Return

[bl-custom-add-headers]
exten => s,1,NoOp(Adding the custom headers})
exten => s,n,Set(inheaders=${HASHKEYS(blHeaders)})
exten => s,n,NoOp(Setting headers: ${inheaders})
exten => s,n,While($["${SET(header=${SHIFT(inheaders)})}" != ""])
exten => s,n,Set(PJSIP_HEADER(add,${header})=${HASH(blHeaders,${header})})
exten => s,n,EndWhile
exten => s,n,Return

With dial options that would trigger these to fire
TtB(bl-custom-read-headers^s^1)b(bl-custom-add-headers^s^1)

This worked great, but then I changed to using only PJSIP. So SIP_HEADERS() stopped working. Is there any equivalent for PJSIP so I can enumerate/iterate on the headers coming in…without knowing specifically which X-* header will be passed?
PJSIP_HEADER(read,X-*) did not work for me.

Thanks!

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_PJSIP_HEADER

Thanks. I am using PJSIP_HEADER() to set and read headers successfully, but the issue is I need to be able to read the actual header keys from the inbound call. ie. the thing that is passed into PJSIP_HEADER() as the “name” param.

I don’t believe there is any functionality to do that currently. If there was, it would be documented as a dialplan application or dialplan function.

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