Forum Discussion
symtex_22198
Nimbostratus
Jul 23, 2009modify SIP contact header param
Hi,
we are using a location server which basically gets SIP invites from a SIP proxy then sends 302 redirect messages.
I have been trying to modify the IP address parameter in the Contact header which is in the 302 message. this IP address will vary, but I want to set it statically
the contact header will have a URI in the format of number xxxxxxxxxxxxx@172.24.103.10. since this is my first irule. I'm struggling.
here is what I've been trying with no success.
when SIP_RESPONSE {
set contact [ SIP::header Contact ]
set telephone 0
set bind 0
regexp {[0-9]{13}} $contact telephone
regexp {[0-9]{8}} $contact bind
SIP::header insert [format \"$bind\"
the header just returns a 0 or a 1... maybe I should try the -inline switch with regexp???
- hoolio
Cirrostratus
Hi, - symtex_22198
Nimbostratus
within a 302 SIP message is a "Contact" field - symtex_22198
Nimbostratus
oops, reposted the irule incorrectly again - symtex_22198
Nimbostratus
BTW I want to add this is my first irule and I'm fairly excited. I worked with other ADCs and was always curious about F5 and iRules. I could see myself really getting into this, iRules rule!! - symtex_22198
Nimbostratus
i was looking into getfield but I was unsure if it would copy everything before the "@" character. I used a regexp to just concentrate on the lengh of the number from the field. I think it would work if I could somehow get regexp to get the regexp result and put it into a variable that I can later outupt in SIP::header - symtex_22198
Nimbostratus
the amount of traffic is minimal and it doesn't seem like a very resource intensive regexp operation. is regexp known to be very resource intensive on TMOS? - hoolio
Cirrostratus
Here is what I was thinking might work. I tested the scan command, but not the iRule.when SIP_RESPONSE { Check for 302 responses if {[SIP::response code] == 302}{ Parse the Contact header value "16601003" using scan http://www.tcl.tk/man/tcl8.4/TclCmd/scan.htm start reading everything not a @ into 'a' then read everything not a : into 'b' finally read the rest into 'c' Example using tclsh: % scan {"16601003"} {%[^@]@%[^:]:%s} a b c 3 % puts "$a $b $c" "16601003" if {[scan [SIP::header value "Contact"] {%[^@]@%[^:]:%s} a b c] == 3}{ We parsed three strings into a b c log local0. "Parsed [SIP::header value "Contact"] into $a, $b, $c" Remove existing Contact header SIP::header remove "Contact" Insert new Contact header with 1.1.1.1 set as a static IP address SIP::header insert "Contact" "${a}@1.1.1.1:${c}" log local0. "Inserting new Contact header: ${a}@1.1.1.1:${c}" } } }
- symtex_22198
Nimbostratus
that worked!!!! except there is a problem, the telephony people told me this is what they needed. now they're telling me it's ok but erase the first part of the field so - symtex_22198
Nimbostratus
BTW thanks - symtex_22198
Nimbostratus
NEVERMIND I GOT IT I GOT IT!!!! i got the scan command
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects