Sip headers manipulation
The behavior 'SIP headers manipulation' allows the SBC users to freely add ,remove and modify the sip headers when SBC forwards the received invite, 18x and 200 sip messages (there are limitations, please refer to the limitations section below).
Contents |
Configuration:
To use the behavior, you need to select the option "Enable SIP headers manipulation" under the path "Gateway -> Advanced Parameters" and use the filter script "sip_headers_manipulation.rb" in routing script setting.
Usage:
The manipulation actions are based on what are defined in "sip_headers_manipulation.rb" dynamically or statically. In sip_headers_manipulation.rb, there is filter_sip_headers_manipulation that should be applied as 'after filter' in main script and need to use call[:manipulation] to save what you want SBC to do regarding headers manipulation. An example is :
def filter_sip_headers_manipulation params # The following 4 lines are needed to initialize the hash table call = params[ :call ] call[:manipulation] = {} call[:manipulation][:invite] = {} call[:manipulation]["18x"] = {} call[:manipulation]["200"] = {} # Will remove "P-Charging-Vector" header from the the invite if exists call[:manipulation][:invite]["P-Charging-Vector"] = "todelete" # Will add or modify "banana" and set its value to "red" header from the invite call[:manipulation][:invite][:banana] = "red" # Will add or modify "salad" and set its value to "blue" header from the invite call[:manipulation][:invite][:salad] = "blue" # Will add or modify "P-Charging-Vector" and set its value to "PCV" header from the 18x call[:manipulation]["18x"]["P-Charging-Vector"] = "PCV" # Will add or modify "banana" and set its value to "yellow" header from the 18x call[:manipulation]["18x"][:banana] = "yellow" # Will add or modify "salad" and set its value to "green" header from the 18x call[:manipulation]["18x"][:salad] = "green" #if hash value begins with matchandreplace, it means the header has several possible values #we will try to compare the received value with settings and use the corresponding replacement #the following settings for P-Early-Media means if the received value includes string inactive, JF will be used as header value, #if the received value includes string sendrecv, inactive will be used as header value call[:manipulation]["18x"]["P-Early-Media"] = "matchandreplace:inactive|JF,sendrecv|inactive" #we also support regex for replacing header value, the format is "regex:pattern|stringtouse" #the setting example is like call[:manipulation]["18x"]["P-Early-Media"] = "regex:pattern|JF" #it means if the pattern exists in the received value, all the occurrences of pattern will be replaced by string JF #don't like "matchandreplace:inactive|JF,sendrecv|inactive", we don't support several possible patterns for now call[:manipulation]["200"]["P-Charging-Vector"] = "PCV" call[:manipulation]["200"][:banana] = "yellow" call[:manipulation]["200"][:TEST] = "STXIE" call["behaviorrbt"] = {} call["behaviorrbt"]["18x"] = "yes" params end
Limitations:
- 'SIP headers manipulation' can only affect SIP headers who are not already modified/generated by the other SBC behaviors, see example below.
- Header values are viewed as a constant string, the routing script cannot pass variable to SBC.
- If the manipulated header is already present, it will be overwritten.
- Manipulate headers hash can only be set once per call (on the incoming invite message). It is not possible to update the hash later during the call.
- SIP header in Re-invite and 200 OK attached to Re-invite cannot be affected by this behavior.
Headers that cannot be used in 'SIP headers manipulation':
Accept Accept-Contact Accept-Encoding Accept-Language Alert-Info Allow Allow-Events Also Anonymity Authentication-Info Authorization Call-ID Call-Info Contact Content-Disposition Content-Encoding Content-Language Content-Length Content-Type CSeq Date Encryption Error-Info Event Expires From In-Reply-To Max-Forwards MIME-version Min-Expires Min-SE Organization P-Asserted-Identity P-Media-Authorization P-Preferred-Identity Priority Privacy Proxy-Authenticate Proxy-Authorization Proxy-Require RAck Reason Record-Route Refer-To Referred-By Reject-Contact Remote-Party-ID Replaces Reply-To Request-Disposition Require Response-Key Retry-After Route RPID-Privacy RSeq Security-Client Security-Server Security-Verify Server Service-Route Session-Expires Subject Subscription-State Supported Timestamp To Unsupported User-Agen Via Warning WWW-Authenticate