SIP Headers

Hi FreePBX People!

Is it possible to add a custom SIP header?

I would like to add the privacy=full flag in the RPID header.

I’ve tried everything in the GUI, the only thing I can think of is to add a custom SIP header:

Remote-Party-ID: “xxxxxxx” sip:[email protected];privacy=full;screen=no

Any suggestions greatly appreciated.

Regards
Brian

Thank, I will check it out…

the original DID that was called is stored in ${FROM_DID}.

That is what we use in 2.9 to auto-generation Diversion headers.

Additional question:

I have two numbers: 800 and 801 -> 801 has CFU on my mobile (051654321), and I can lookup in the asterisk DB, what this CFU number is.

So when 800 calls 801 - the call if forwarded to my mobile number. Now, I’m trying to change the callerid for the call to my mobile number -> But here is the problem, if I lookup in the database what my mobile number is - I cannot, because the callerid is set to 800, and not 801.

This is my dialplan (extension_custom.conf):
[macro-dialout-trunk-predial-hook]

exten => s,1,SIPAddHeader(Diversion:sip:blablabla\@192.168.1.1\:5060\;user=phone;reason=unconditional;privacy=off;counter=1)
exten => s,2,Set(CALLERID(all)=“CFU” <${DB(CF/${CALLERID(num))}>)
exten => s,n,MacroExit()

The part in bold is the problem - is there any other variable, which can tell me the original number 801?

Ok, thanks for the answer, and the answer in the other thread…

Hi Peter/Peter,

Both methods worked very well.

Thank you very much for your assistance.

Regards,
Brian

Does FreePBX know that when you put into extension-custom.conf this macro ([macro-dialout-trunk-predial-hook]) - that it will call it when an outbound call will be made?

And one more thing - can I specify to which trunk this macro will go (let’s say I have multiple trunks (1x SIP, 2x ISDN…), and I only want this macro to go via SIP trunk)?

black187,

it is called on every outbound call.

It is up to you to add any logic that checks which trunk and decides what to do.

However, see my response to you other post. And in general, there is no harm that will be done if you add a Diversion Header even on a trunk where it is not necessary, though you obviously want to confirm that with some testing.

you can have RPID created by setting sendrpid=yes for the trunk configuration.

As far as the privacy=full, you would need a hook similar to Peter and then you could use the CALLERPRES() function to set it to the desired setting that achieve this.

Of course, what peter suggested works perfectly fine as well.

My config excerpt above was built from my deconstructed Diversion Header config. I’ll put my full macro below while only obscuring the NPA of each number. It handles multiple SIP trunks as well as PRI trunks in the logic – though, as Philippe noted, extra SIP headers won’t hurt a call that ends up using a DAHDI trunk.

[macro-dialout-trunk-predial-hook] ; is sip trunk? yes , goto checkcid exten => s,1,Set(CDR(accountcode)=${CALLERID(num):-4:4}) exten => s,n,Set(TRACKTR=${OUT_${DIAL_TRUNK}:4}) exten => s,n,GotoIf($["${TRACKTR}" = "6122771999"]?checkcid) ; trunk id 1 exten => s,n,GotoIf($["${TRACKTR}" = "6126380000"]?checkcid) ; trunk id 2 exten => s,n,Goto(s,done) ; is callerid local? exten => s,n(checkcid),Set(TRCID=${CALLERID(num)}) exten => s,n,GotoIf($[$[${TRCID} >= PREFIXA4301] & $[${TRCID} <= PREFIXA4387]]?done) ; block 1 exten => s,n,GotoIf($[$[${TRCID} >= PREFIXB3798] & $[${TRCID} <= PREFIXB3997]]?done) ; block 2 exten => s,n,GotoIf($[$[${TRCID} >= PREFIXC3944] & $[${TRCID} <= PREFIXC3949]]?done) ; block 3 exten => s,n,GotoIf($[$[${TRCID} >= PREFIXD0002] & $[${TRCID} <= PREFIXD0020]]?done) ; block 4 exten => s,n,GotoIf($[$[${TRCID} >= PREFIXE2058] & $[${TRCID} <= PREFIXE2097]]?done) ; block 5 exten => s,n,GotoIf($[${TRCID} = PREFIXF3300]?done) ; old company number exten => s,n,GotoIf($[${TRCID} = PREFIXF3700]?done) ; old company FAX exten => s,n,GotoIf($[${TRCID} = PREFIXG0000]?done) ; singlet phone number ; add sip header goto done exten => s,n(addheader),SIPAddHeader(Diversion: <sip:${TRACKTR}@localhost>\;reason=unconditional\;screen=no\;privacy=off) exten => s,n,NoOp(Call from ${TRCID} on trunk ${TRACKTR}) exten => s,n(done),MacroExit()

I do it for outbound calls on my SIP trunks. In my /etc/asterisk/extensions_custom.conf file I implemented a macro for dialout-trunk-predial-hook like:

[macro-dialout-trunk-predial-hook]
exten => s,1,SIPAddHeader(Remote-Party-ID: “xxxxxxx” ;privacy=full;screen=no)
exten => s,n,MacroExit()

Of course, that may not be the right insertion point for your usage. I can’t tell from how you want to use it.