Outgoing Callerid

Hi,

My SIP trunk provider requires me to send the privacy id header when making an anonymous call so I need to add some dialplan to FreePBX (which I have never done before) and I’m running into some problems.

I have multiple extensions on my server.
When an extension needs to call anonymous I fill in “hidden” in the Outbound CID field in the webinterface.
When an extension needs to have his number visible I fill in his number (like 31202011100).

Now I wrote this dialplan and added it to extensions_custom.conf:

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${CALLERID(number)}" = “”]?zondernummer:metnummer)
exten => s,n(metnummer),SipAddHeader(P-Preferred-Identity:sip:${CALLERID(number)}@provider.nl)
exten => s,n(zondernummer),SipAddHeader(P-Preferred-Identity:sip:${CALLERID(number)}@provider.nl)
exten => s,n(zondernummer),SipAddHeader(Privacy: id)

But It doesn’t seem to work, in verbose mode I see this when an extension had it’s number set:

-- Goto (macro-dialout-trunk-predial-hook,s,2)
-- Executing [[email protected]:2] SIPAddHeader("SIP/512-00015170", "P-Preferred-Identity:<sip:[email protected]>") in new stack
-- Executing [[email protected]:3] SIPAddHeader("SIP/512-00015170", "P-Preferred-Identity:<sip:[email protected]>") in new stack
-- Executing [[email protected]:4] SIPAddHeader("SIP/512-00015170", "Privacy: id") in new stack

Can someone tell me what I’m doing wrong?

I user FreePBX 2.11 and Asterisk 11.

Thanks!

It’s about how you wrote your context n is always followed unless you “escape it” with a goto before the next “named” one , Try using

exten => s,1,GotoIf($["${CALLERID(number)}" != “”]?metnummer:zondernummer)

and then tidy up the unnecessarily duplicated P-Preferred_identity

What exactly do you mean by escaping n?

When I use this I still have the same issue…
[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${CALLERID(number)}" != “”]?metnummer:zondernummer)
exten => s,n(metnummer),SipAddHeader(P-Preferred-Identity:sip:${CALLERID(number)}@provider.nl)
exten => s,n(zondernummer),SipAddHeader(P-Preferred-Identity:sip:${CALLERID(number)}@provider.nl)
exten => s,n(zondernummer),SipAddHeader(Privacy: id)

To stop processing any further priorities,

exten => s,1,GotoIf($["${CALLERID(number)}" != “”]?metnummer:zondernummer)
exten => s,n(metnummer),SipAddHeader(P-Preferred-Identity:)
exten => s,n,macroexit()
exten => s,n(zondernummer),SipAddHeader(P-Preferred-Identity:)
exten => s,n(zondernummer),SipAddHeader(Privacy: id)
exten => s,n,macroexit()

http://www.voip-info.org/wiki/view/Asterisk+cmd+MacroExit

I found out this also works:

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${CALLERID(number)}" = “”]?zondernummer)
exten => s,2,SipAddHeader(P-Preferred-Identity:sip:${CALLERID(number)}@provider.nl)
exten => s,20(zondernummer),SipAddHeader(Privacy: id)

Only thing I just noticed, the CALLERID(number) value is never empty in FreePBX, even when I don’t set anything in the webinterface.

Insert
exten => s,1,noop(“CallerID(number) is ${CALLERID(number)}”)

and test against what whatever differentiates your call.

Just did some testing and that var is allways set by some other FreePBX code.
I’m using the USEROUTCID var now and this works fine, all is working now :slight_smile:

Thanks for the help!