Custom functions and how to run them

Hi,

I’m trying to add custom sip headers to outgoing call. Looking at extensions_additional.conf I found some functions which are adding sip headers…

All of the existing functions within this file include “custom” functions. So my idea is to write such a custom function (like “func-apply-sipheaders-custom”).

I added this function to “extensions_custom.conf” or “extensions_override_freepbx.conf”. But this custom function is never called. Is there something what I did wrong or misunderstood?

Thanks in advance
Sascha

There is a context reserved for this purpose macro-dialout-trunk-predial-hook.

I know the context you are talking about. But adding SIP-Headers there does not work. I know that it worked in the past. But with freepbx 14 and asterisk 15 I can’t get them work in this section.

Any hints?

Which SIP Driver?

Remember that there are two “SIP Header” types now that we have two SIP drivers.

I have tested AddSipHeadet for chan_sip and the Set(… for PJSIP. I‘m using PJSIP to make calls.

In this context adding the headers didn‘t work.

I presume AddSipHeadet is a typo, but if spelled correctly it does work from the predial hook macro. If you’re using pjsip trunks, then you can’t add headers with this macro, and instead must use the method described here:

I noticed that something important has changed at this point. I don’t have a full understanding of “the new method”. Investigating and reading many docs I found a solution which seems to work for me:

There are functions which are adding these headers to the sip data stream. The function uses the SIPHEADERS variable to fetch custom/new/addtional headers. So I added the following code to the “old” [macro-dialout-trunk-predial-hook]:

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(******************** PRE DIAL HOOK ********************)

; sipgate trunk
exten => s,n,GotoIf($[ "${TRUNKOUTCID}" = "<CID OF TRUNK>" ]?sipgate_cid)
exten => s,n,MacroExit()

; Setting P-Preferred-Identity at sipgate trunk for custom caller id
exten => s,n(sipgate_cid),Set(HASH(_SIPHEADERS,P-Preferred-Identity)=<sip:${CALLERID(num)}@sipconnect.sipgate.de>)
exten => s,n,MacroExit()
2 Likes

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