Actions

Sip headers manipulation: Difference between revisions

(Created page with "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 ...")
 
m (added display title)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
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).
{{DISPLAYTITLE:SIP Headers Manipulation}}


Configuration:
The behavior 'SIP headers manipulation' allows 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).
 
== 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.
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:
== 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 :
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 :
    
    
Line 29: Line 31:
     # Will add or modify "salad" and set its value to "green" header from the 18x
     # Will add or modify "salad" and set its value to "green" header from the 18x
     call[:manipulation]["18x"][:salad] = "green"
     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"]["P-Charging-Vector"] = "PCV"
     call[:manipulation]["200"][:banana] = "yellow"
     call[:manipulation]["200"][:banana] = "yellow"
     call[:manipulation]["200"][:TEST] = "STXIE"
     call[:manipulation]["200"][:TEST] = "STXIE"  
      
      
     params
     call["behaviorrbt"] = {}
    #if set call["behaviorrbt"]["18x"] as 'no', sbc will not generate ring back tone
    call["behaviorrbt"]["18x"] = "yes"
   
  params
   end  
   end  
      
      
    
    
Limitations:
== Limitations: ==
-'SIP headers manipulation' can only affect SIP headers who are not already modified/generated by the other SBC behaviors, see headers    examples below.
 
-Header values are viewed as a constant string, the routing script cannot pass variable to SBC.
# 'SIP headers manipulation' can only affect SIP headers that are not already modified/generated by the other SBC behaviors, see example below.
-If the manipulated header is already present, it will be overwritten.
# Header values are viewed as a constant string. The routing script cannot pass variables to SBC.
-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.
# If the manipulated header is already present, it will be overwritten.
-SIP header in Re-invite and 200 OK attached to Re-invite cannot be affected by this behavior.
# 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:
 
-Can be modified in 'SIP headers manipulation'.
=== Headers that cannot be used in 'SIP headers manipulation': ===
        - All X- headers
  Accept
        - Most P- headers? (except P-Asserted-Identity)
  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
 


[[category:FAQ]]
-Cannot not be used in 'SIP headers manipulation'
      - Accept
      - Accept-Encoding
      - Accept-Language
      - Alert-Info
      - Allow
      - Authorization
      - Authentication-Info
      - Also
      - Call-ID
      - Call-Info
      - Contact
      - Content-Disposition
      - Content-Encoding
      - Content-Language
      - Content-Length
      - Content-Type
      - CSeq
      - Date
      - Encryption
      - Error-Info
      - Expires
      - From
      - In-Reply-To
      - Max-Forwards
      - MIME-version
      - Min-Expires
      - Organization
      - Priority
      - Proxy-Authenticate
      - Proxy-Authorization
      - Proxy-Require
      - Record-Route
      - Reply-To
      - Require
      - Response-Key
      - Retry-After
      - Route
      - Server
      - Subject
      - Supported
      - Timestamp
      - To
      - Unsupported
      - User-Agen
      - Via
      - RAck
      - RSeq
      - Warning
      - WWW-Authenticate
      - Event
      - Allow-Events
      - Refer-To
      - Referred-By
      - Replaces
      - Session-Expires
      - Min-SE
      - Request-Disposition
      - Accept-Contact
      - Reject-Contact
      - Anonymity
      - RPID-Privacy
      - Remote-Party-ID
      - Subscription-State
      - Security-Client
      - Security-Server
      - Security-Verify
      - Reason
      - P-Media-Authorization
      - Privacy
      - P-Asserted-Identity
      - P-Preferred-Identity
      - Service-Route

Latest revision as of 13:44, 13 March 2023


The behavior 'SIP headers manipulation' allows 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).

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"] = {}
   #if set call["behaviorrbt"]["18x"] as 'no', sbc will not generate ring back tone
   call["behaviorrbt"]["18x"] = "yes"
   
 params
 end 
   
 

Limitations:

  1. 'SIP headers manipulation' can only affect SIP headers that are not already modified/generated by the other SBC behaviors, see example below.
  2. Header values are viewed as a constant string. The routing script cannot pass variables to SBC.
  3. If the manipulated header is already present, it will be overwritten.
  4. 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.
  5. 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