[Users] Possible to use subst() to alter first line of INVITE?

Leif Madsen leif.madsen at gmail.com
Thu Apr 12 09:18:42 CEST 2007


Evening all!

I'm trying to use subst() to alter the first line of an INVITE I'm
sending to a remote Asterisk box, although I have been unable to get
this working. Perhaps I need to use a different function?

The INVITE I'm working with looks like (IPs have been changed to
protect the innocent):

INVITE sip:s at 192.168.1.250 SIP/2.0
Record-Route: <sip:192.168.1.190;lr;ftag=as62d28c09>
Via: SIP/2.0/UDP 192.168.1.190;branch=z9hG4bKcce2.b907e716.0
Via: SIP/2.0/UDP 192.168.1.147:5060;branch=z9hG4bK5a287301;rport=5060
From: "lmadsen2#lmentinc" <sip:lmadsen2#lmentinc at 192.168.1.147>;tag=as62d28c09
To: <4166289921 at switch1>
Contact: <sip:lmadsen2#lmentinc at 192.168.1.147>
Call-ID: 791d9cc101c5cbdd2896c0d357cf644c at 192.168.1.147
CSeq: 102 INVITE
User-Agent: Asterisk
Max-Forwards: 69
Remote-Party-ID: "lmadsen2#lmentinc"
<sip:lmadsen2#lmentinc at 192.168.1.147>;privacy=off;screen=no
Date: Thu, 12 Apr 2007 05:00:26 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length: 240


I have two subst() I've been playing with. This one works which alters
the To: line in the INVITE:

subst('/^To: (.*)sip:[^@]*+(.*)$/To: \1$hdr(X-DID)\2/g');

This one does not, which I would like to alter the INVITE
sip:s at 192.168.1.250 SIP/2.0 of the header. This is the very first line
in the INVITE.

subst('/^INVITE (.*)sip:[^@]*+(.*)$/INVITE sip:$hdr(X-DID)\2/ig');

I tested the regex online as well, and it seems to work.

Anything I'm missing? Is there another function I can use to alter the
line I want, or am I up poop creek?

Thanks!

-- 
Leif Madsen.
http://www.leifmadsen.com
http://www.oreilly.com/catalog/asterisk




More information about the Users mailing list