[asterisk-users] Dial plan inquiry using GotoIf()

Steve Finkelstein sf at stevefink.net
Wed May 30 09:55:09 MST 2007


Hi all,

I'm looking for some rudimentary insight on GotoIf() which seems to be
failing on me in my dial plan. All I basically wish to do is block a
particular caller. Sounds easy enough, but my ternary operator/plan
currently is not properly being implemented. Can anyone spot where I'm
being a momo?

All extensions get forwarded to the following macro:

[macro-forward]
; arg1 = phone number
; arg2 = timeout
; arg3 = extension (voicemail)
; arg4 = mobile number
exten => s,1,Zapateller(answer|nocallerid)
exten => s,2,PrivacyManager
exten => s,3,Wait(1)
exten => s,4,GotoIf($[${CALLERID(number)} = "15552221313"]?15:5)
exten => s,5,GotoIf($[${LEN(${CALLERID(number)})} = 4]?6:8)
exten => s,6,AGI(didextlookup.agi|${CALLERID(number)})
exten => s,7,Set(CALLERID(number)=${didlookup})
exten => s,8,GotoIf($[${LEN(${CALLERID(number)})} = 10]?9:10)
exten => s,9,Set(CALLERID(number)=1${CALLERID(number)})
exten => s,10,Dial(${ARG1},${ARG2})
exten => s,11,GotoIf($[${EXISTS(${ARG4})}]?11:12)
exten => s,12,Dial(${ARG4},${ARG2})
exten => s,13,Voicemail(u${ARG3})
exten => s,14,Playback(vm-goodbye)
exten => s,15,HangUp
exten => s,105,HangUp

As you can tell, exten => s,4,GotoIf($[${CALLERID(number)} =
"15552221313"]?15:5)  is what I recently added.

Here's what I see in the CLI logs:

    -- Executing [5609 at fromlime:1] Macro("IAX2/lime-3",
"forward|SIP/5609|15|5609|IAX2/limemed at lime/15164766201") in new stack
    -- Executing [s at macro-forward:1] Zapateller("IAX2/lime-3",
"answer|nocallerid") in new stack
    -- Executing [s at macro-forward:2] PrivacyManager("IAX2/lime-3", "")
in new stack
    -- CallerID Present: Skipping
    -- Executing [s at macro-forward:3] Wait("IAX2/lime-3", "1") in new stack
    -- Executing [s at macro-forward:4] GotoIf("IAX2/lime-3", "0?15:5") in
new stack
    -- Goto (macro-forward,s,5)

It evaluates to false, hence goes to s,5. I keep dialing from that
particular number (the one in the example is clearly masked as a false
CID), and verified it's showing up as that number on callerID.

Also one last question. Say I need to add more numbers to block in the
future, is there an easier way to do this than renumbering my entire
macro? Renumbering everything is just begging for a typo which can
effectively render my dial plan broken.

Thank you kindly, everyone!

- sf


More information about the asterisk-users mailing list