[asterisk-users] To: Field

Administrator TOOTAI admin at tootai.net
Mon Jun 1 09:35:13 CDT 2009


Hi

Charles Solar a écrit :
> Hi guys, I am new here but I have a quick question.
>
> I have an incoming trunk that sends me calls from various usernames I have
> with them.  Only trouble is they send invites as s at my.ip.addr, not as the
> username I have with them.  So I cannot match extensions like I would want
> to.
> Here is a sample invite
>
> INVITE sip:s at my.ip.ad.dr SIP/2.0
> Record-Route: <sip:0.0.0.0;lr=on;ftag=as29ffee59>
> Via: SIP/2.0/UDP 0.0.0.0;branch=z9hG4bK7238.25c90fc7.0
> Via: SIP/2.0/UDP 0.0.0.0:5060;branch=z9hG4bK1c709971;rport=5060
> From: "" <sip:9999999999 at host.ip.addr>;tag=as29ffee59
> To: <sip:myusername at mysipprovider.net <sip%3Amyusername at mysipprovider.net>>
> Contact: <sip:9999999999 at host.ip.addr>
> Call-ID: 6a379af207d78b3b5f2e8c6c55e64009
> CSeq: 102 INVITE
> User-Agent: Asterisk PBX
> Max-Forwards: 69
> Date: Fri, 29 May 2009 04:12:09 GMT
> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
> Supported: replaces
> Content-Type: application/sdp
> Content-Length: 377
>
> the only distinction between a call to username1 and username2 is in the To:
> field, but I cannot find something to route the call based on the To caller
> id.
>
> I think the dialednumber variable would be close to what I want, but
> apparently that is broken so I am unsure what to do.
>   
[macro-setDialednumberFromSipHeader]
;
; We extract the DIALEDNUMBER from SIP header
; which is of the form <sip:CALLEDNUMBER at OurAsteriskIPAddress>

exten => s,1,Set(__DIALEDNUMBER=${SIP_HEADER(TO):5})
exten => s,n,Set(__DIALEDNUMBER=${CUT(DIALEDNUMBER,@,1)})
exten => s,n,GotoIf($["${DIALEDNUMBER:0:1}" != "+"]?numberIsOK)
exten => s,n,Set(__DIALEDNUMBER=${CUT(DIALEDNUMBER,+,2)})

exten => s,n(numberIsOK),NoOp()
exten => s,n,Set(CDR(dest)=${DIALEDNUMBER})

done ;-)



More information about the asterisk-users mailing list