[asterisk-users] Trying to forward calls by using the Callee's context as the forward dial context

John French jFrench at vividvoicedata.com
Fri Dec 15 10:35:26 MST 2006


I'm simply trying to forward calls to users who have the call forwarding 
feature enabled (FWD Status and FWD Ph Number kept in the astDB).  The 
problem is that I want users to be able to forward calls to numbers that 
they would normally be allowed to dial within their own context. (I 
don't want a local call only person forwarding to a long dist number, 
for example.)  I'm able to get the channel context for SIP devices but 
not for IAX or Zap Devices.  I need some pointers on getting IAXPEER to 
work and how to handle getting the ZAP context info.  If there's an 
easier way, I'm all ears.  Thanks.

; #####################Set Some Variables####################
exten => s,1,Set(DEVICE=${ARG1}) ;i.e. SIP/johns_phone
exten => s,n,Set(Protocol=${CUT(DEVICE,/,1)}) ;Parse out SIP
exten => s,n,Set(Phone=${CUT(DEVICE,/,2)})  ;Parse out johns_phone

;Stuff omitted for some amout of brevity....

; #####################Make Forward Calls######################
; We only want people to be able to forward to numbers they could 
normally call
; We'll have to somehow get their dialing contexts from the channel conf 
files.
exten => s,n(Forward),NoOp()

exten => s,n,GotoIf($["${Protocol}" = "SIP"]?SIPDev)
exten => s,n,GotoIf($["${Protocol}" = "IAX2"]?IAXDev)
exten => s,n,Goto(ZapDev)

;ok, they are an IAX device so use IAXPEER
exten => 
s,n(IAXDev),Set(CalledUsersContext=${IAXPEER(${Phone}:context)})
exten => s,n,Goto(dial_time)

;ok, they are an SIP device so use SIPPEER
exten => 
s,n(SIPDev),Set(CalledUsersContext=${SIPPEER(${Phone}:context)})
exten => s,n,Goto(dial_time)

;ok, they are an Zap device so use... Uhhhhh.
exten => s,n(ZapDev),NoOp( I have no clue how to get the zap channel's 
context...)

exten => s,n(dial_time),NoOp(======================> Chan Type 
${Protocol})
exten => s,n,NoOp(======================> Chan Name ${Phone})
exten => s,n,NoOp(======================> Channel User's context 
${CalledUsersContext})
exten => s,n,Dial(Local/${FWDNumber}@${CalledUsersContext}/n)


Results at console on verbosity 9:
SIPPEER() Works as advertised when I dial a SIP phone which has been 
call forwarded
    -- Executing NoOp("Zap/1-1", "======================> Chan Type 
SIP") in new stack
    -- Executing NoOp("Zap/1-1", "======================> Chan Name 
jf_linksys") in new stack
    -- Executing NoOp("Zap/1-1", "======================> Channel Users 
context longdistance_users") in new stack
    -- Executing Dial("Zap/1-1", "Local/5551212 at longdistance_users/n") 
in new stack

IAXPEER() Seems to be broken or I don't know how to use it properly.
    -- Executing NoOp("SIP/jf_linksys-08f20548", 
"======================> Chan Type IAX2") in new stack
    -- Executing NoOp("SIP/jf_linksys-08f20548", 
"======================> Chan Name johns_pc") in new stack
    -- Executing NoOp("SIP/jf_linksys-08f20548", 
"======================> Channel Users context ") in new stack
    -- Executing Dial("SIP/jf_linksys-08f20548", "Local/5551212@/n") in 
new stack


More information about the asterisk-users mailing list