Hello,
My provider (Vodafone UK) needs me to include two custom headers on every SIP transaction.
X-Serialnumber
User-Agent
I know that User-Agent is a global, which I can change. So I’ve concentrated on adding the X-Serialnumber header.
I’ve used these posts as reference on how to do that
I have a
extensions_override_freepbx.conf
which contains:
[func-apply-sipheaders]
include => func-apply-sipheaders-custom
exten => s,1,Noop(Applying SIP Headers to channel ${CHANNEL})
exten => s,n,Set(TECH=${CUT(CHANNEL,/,1)})
exten => s,n,Set(SIPHEADERKEYS=${HASHKEYS(SIPHEADERS)})
exten => s,n,While($["${SET(sipkey=${SHIFT(SIPHEADERKEYS)})}" != ""])
exten => s,n,Set(sipheader=${HASH(SIPHEADERS,${sipkey})})
exten => s,n,ExecIf($["${sipheader}" = "unset" & "${TECH}" = "PJSIP"]?Set(PJSIP_HEADER(remove,${sipkey})=))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1 & ${REGEX("\;info=" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>\;info=${sipheader}))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "PJSIP" & "${sipheader}" != "unset"]?Set(PJSIP_HEADER(add,${sipkey})=${sipheader}))
exten => s,n,EndWhile
exten => s,n,Noop(Applying X-Serialnumber Header to channel)
exten => s,n,Set(PJSIP_HEADER(add,X-Serialnumber)=AAAAAA))
exten => s,n,Return()
;--== end of [func-apply-sipheaders] ==--;
You’ll see I’ve added a PJSIP_HEADER(add,X-Serialnumber)=AAAAA statement to the end of the macro.
I have not altered the dial plan for the relevant trunk (it’s still Tt), as I understand that this macro is always called?
I’ve also tried following the recommendation in this post to create [macro-dialout-trunk-predial-hook] in extensions_custom.conf.
But when I turn on pjsip logger in the asterisk cli, I’m not seeing the additional X-Serialnumber being added to the REGISTER transaction.
Are there any suggestions on how I can debug this further, or amend the dialplan / configuration?
Thanks
Nick