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}"
}
}
}
Aaron