Forum Discussion

Jeff_47438's avatar
Jeff_47438
Icon for Altocumulus rankAltocumulus
Mar 05, 2018

SIP "TO" header string map replacement

I am trying to manipulate a portion of a SIP INVITE with an irule. This is a version 12 F5.

The irule is this:

when SIP_REQUEST { log local0. "The TO header before changes is [SIP::header "To"]" Check if TO contains if { [SIP::header "To"] contains "TENANT_SG1_105_85TEST" }{

     Replace tenant with the ANI      
    SIP::header [string map "TENANT_SG1_105_85TEST 6144322478" [SIP::header "To"]]
log local0. "The TO header after changes is [SIP::header "To"]"
}

}

The logs that result, show no change below:

REQUEST>: The TO header before changes is ;tag=908821817 Mar 5 03:18:56 itfccs1lb02 info tmm[16925]: Rule /Common/HCR_SIP_Rewrite1 : The TO header after changes is ;tag=908821817

  • Figured it out. Here is the solution I used.

     

    when SIP_REQUEST { set TO_HEADER1 [SIP::header "To"] log local0. "Rewrite before is $TO_HEADER1" if { ($TO_HEADER1 contains "TENANT_SG1_105_85TEST") } then { set TO_HEADER2 [string map -nocase {"TENANT_SG1_105_85TEST" "3035555555"} $TO_HEADER1] log local0. "Rewrite after is $TO_HEADER2" SIP::header remove "To" SIP::header insert "To" "$TO_HEADER2" } }

     

  • Figured it out. Here is the solution I used.

     

    when SIP_REQUEST { set TO_HEADER1 [SIP::header "To"] log local0. "Rewrite before is $TO_HEADER1" if { ($TO_HEADER1 contains "TENANT_SG1_105_85TEST") } then { set TO_HEADER2 [string map -nocase {"TENANT_SG1_105_85TEST" "3035555555"} $TO_HEADER1] log local0. "Rewrite after is $TO_HEADER2" SIP::header remove "To" SIP::header insert "To" "$TO_HEADER2" } }