Difference between revisions of "M4 Header Transformation Rules Groups"
(Created page with "'''Header Transformation Rules''' are available in the '''Routing''' section. File:M4_routing_header_transformation_rules.png") |
|||
(23 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
=About= | |||
Header Transformation Rules are used to modify or add headers. | |||
'''Header Transformation Rules''' are available in the '''Routing''' section. | '''Header Transformation Rules''' are available in the '''Routing''' section. | ||
[[File:M4_routing_header_transformation_rules.png]] | [[File:M4_routing_header_transformation_rules.png]] | ||
<br><br> | |||
=Create= | |||
Press '''ADD NEW''' to create '''Header Transformation Rules Group'''. | |||
[[File:M4_header_transformation_rules_add_new.png]] | |||
The image below shows which headers are possible to modify. | |||
<br> | |||
[[File:M4_header_transformation_rules.png]] | |||
==Actions== | |||
Depending on the header, it is possible to perform various actions on the header. | |||
===Forward without changes=== | |||
If the header exists, it will be forwarded with no additional changes. | |||
Some headers will still be modified during call processing, for example Max-Forwards counter will be changed (decreased) even if it was set to forward without changes as this is required for SIP message processing. | |||
Both <code>EXISTING HEADER TRANSFORMATION</code> and <code>NEW HEADER CONSTRUCTION</code> options are disabled in this action since no modification is required. | |||
<br> | |||
<br> | |||
===Transform and forward=== | |||
If the header exists, it will be modified by <code>EXISTING HEADER TRANSFORMATION</code> rule. | |||
Option <code>NEW HEADER CONSTRUCTION</code> is disabled in this action since we only operate on an existing header. | |||
<br> | |||
<br> | |||
===Transform existing, generate if missing=== | |||
If the header exists, it will be modified by <code>EXISTING HEADER TRANSFORMATION</code> rule.<br> | |||
If the header does not exist, it will be generated by <code>NEW HEADER CONSTRUCTION</code> rule. | |||
<br> | |||
<br> | |||
===Overwrite=== | |||
A new header will be constructed by <code>NEW HEADER CONSTRUCTION</code> rule.<br> | |||
If the header is already present, it will be overwritten by the new header. | |||
Option <code>EXISTING HEADER TRANSFORMATION</code> is disabled in this action since we only overwrite the existing header (or if the header is missing, adding a new header). | |||
<br> | |||
<br> | |||
===Drop=== | |||
If the header exists, it will be dropped. | |||
Both <code>EXISTING HEADER TRANSFORMATION</code> and <code>NEW HEADER CONSTRUCTION</code> options are disabled in this action since no modification is required, only drop. | |||
<br> | |||
<br> | |||
==Existing Header Transformation== | |||
This option is only available in actions <code>Transform and forward</code> and <code>Transform existing, generate if missing</code>. | |||
The format is: | |||
'''/match_expression/replacement_expression/flags''' | |||
* match_expression - POSIX regular expression | |||
* replacement_expression - replacement expression with back references to matched tokes: \1, \2, …, \9 | |||
* flags (optional): | |||
** i - match ignore case | |||
** g - replace all matches | |||
More information [[M4_Kamailio_Transformations | here]]. | |||
==New Header Construction== | |||
This option is only available in actions <code>Transform existing, generate if missing</code> and <code>Overwrite</code>. | |||
The format is a plain text value that will be added to a header. | |||
==Custom headers== | |||
It is also possible to add a custom header to the empty header field. | |||
==Limitations== | |||
* Only the outgoing Invite request is available for modifications. | |||
* Some actions cannot be applied to specific headers. For example, you can't modify Call-ID, Via, Contact headers as these headers are required for internal operations and should be left as is. | |||
<br><br> | |||
=Enable= | |||
When rules are created, they should be enabled at Termination Point settings: Termination Point Signaling Settings | |||
<br> | |||
[[File:Termination point rules settings.png]] | |||
<br><br> | |||
= User-Agent header = | |||
Due to technical limitations, [[M4_User-Agent|User-Agent]] header cannot be changed using Header Transformation Rules. Please contact support to change this header for all calls. | |||
<br><br> | |||
= See also = | |||
* [[M4 Regexp Examples]] | |||
* [[M4 Kamailio Transformations]] | |||
* [[M4 Source Transformation]] | |||
* [[M4 Destination Transformation]] | |||
* Check your regexp: http://regex101.com/ |
Latest revision as of 08:34, 9 February 2024
About
Header Transformation Rules are used to modify or add headers.
Header Transformation Rules are available in the Routing section.
Create
Press ADD NEW to create Header Transformation Rules Group.
The image below shows which headers are possible to modify.
Actions
Depending on the header, it is possible to perform various actions on the header.
Forward without changes
If the header exists, it will be forwarded with no additional changes.
Some headers will still be modified during call processing, for example Max-Forwards counter will be changed (decreased) even if it was set to forward without changes as this is required for SIP message processing.
Both EXISTING HEADER TRANSFORMATION
and NEW HEADER CONSTRUCTION
options are disabled in this action since no modification is required.
Transform and forward
If the header exists, it will be modified by EXISTING HEADER TRANSFORMATION
rule.
Option NEW HEADER CONSTRUCTION
is disabled in this action since we only operate on an existing header.
Transform existing, generate if missing
If the header exists, it will be modified by EXISTING HEADER TRANSFORMATION
rule.
If the header does not exist, it will be generated by NEW HEADER CONSTRUCTION
rule.
Overwrite
A new header will be constructed by NEW HEADER CONSTRUCTION
rule.
If the header is already present, it will be overwritten by the new header.
Option EXISTING HEADER TRANSFORMATION
is disabled in this action since we only overwrite the existing header (or if the header is missing, adding a new header).
Drop
If the header exists, it will be dropped.
Both EXISTING HEADER TRANSFORMATION
and NEW HEADER CONSTRUCTION
options are disabled in this action since no modification is required, only drop.
Existing Header Transformation
This option is only available in actions Transform and forward
and Transform existing, generate if missing
.
The format is:
/match_expression/replacement_expression/flags
- match_expression - POSIX regular expression
- replacement_expression - replacement expression with back references to matched tokes: \1, \2, …, \9
- flags (optional):
- i - match ignore case
- g - replace all matches
More information here.
New Header Construction
This option is only available in actions Transform existing, generate if missing
and Overwrite
.
The format is a plain text value that will be added to a header.
Custom headers
It is also possible to add a custom header to the empty header field.
Limitations
- Only the outgoing Invite request is available for modifications.
- Some actions cannot be applied to specific headers. For example, you can't modify Call-ID, Via, Contact headers as these headers are required for internal operations and should be left as is.
Enable
When rules are created, they should be enabled at Termination Point settings: Termination Point Signaling Settings
User-Agent header
Due to technical limitations, User-Agent header cannot be changed using Header Transformation Rules. Please contact support to change this header for all calls.