Resources.DocsCoreTran HistoryShow minor edits - Show changes to markup April 24, 2013, at 02:00 PM
by
- Changed lines 1-545 from:
Resources -> Documentation -> CookBooks -> Script TransformationsThis documentation is valid for OpenSIPS v1.9.x / devel (:toc-float Table of Content:) A Transformation is basically a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the original variable is not altered. Example of using different kind of variables in OpenSIPS script: # check if username in From header is equal with username in To header if($fU==$tU) { ... } # r-uri username based processing switch($ruri.user) { case "1234": ... break; case "5678": ... break; default: ... } # assign integer value to an AVP $avp(i:11) = 1; #assing string value to an AVP $avp(i:22) = "opensips"; # write ruri in an AVP $avp(i:33) = $ruri; # concat "sip:" + From username + "@" + To domain in a script variable x $var(x) = "sip:" + $fU +"@" + $td; The transformations are intended to facilitate access to different attributes of variables (like strlen of value, parts of value, substrings) or complete different value of variables (encoded in hexa, md5 value, escape/unescape value for DB operations...). A transformation is represented in between '{' and '}' and follows the name of a variable. When using transformations, the variable name and transformations must be enclosed in between '(' and ')'. Example: # the length of From URI ($fu is pseudo-variable for From URI) $(fu{s.len}) Many transformations can be applied in the same time to a variable. # the length of escaped 'Test' header body $(hdr(Test){s.escape.common}{s.len}) The transformations can be used anywhere, being considered parts of script variables support -- in xlog, avpops or other modules' functions and parameters, in right side assignment expressions or in comparisons. IMPORTANT: To learn what variables can be used with transformations see Scripting variables list. String TransformationsThe name of these transformation starts with 's.'. They are intended to apply string operations to variables. Available transformations in this class: {s.len}Return strlen of variable value $var(x) = "abc"; if($(var(x){s.len}) == 3) { ... } {s.int}Return integer value of a string-represented number $var(x) = "1234"; if($(var(x){s.int})==1234) { ... } {s.md5}Return md5 over variable value xlog("MD4 over From username: $(fU{s.md5})"); {s.substr,offset,length}Return substring starting at offset having size of 'length'. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of positive value, 0 is first char. Length must be positive, in case of 0, substring to the end of variable value is returned. offset and length can be a varibale as well. Example: $var(x) = "abcd"; $(var(x){s.substr,1,0}) = "bcd" {s.select,index,separator}Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of value, -1 being last field. If index is positive, 0 is the first field. Example: $var(x) = "12,34,56"; $(var(x){s.select,1,,}) => "34" ; $var(x) = "12,34,56"; $(var(x){s.select,-2,,}) => "34" {s.encode.hexa}Return encoding in hexa of variable's value {s.decode.hexa}Return decoding from hexa of variable's value {s.escape.common}Return escaped string of variable's value. Characters escaped are ', ", and 0. Useful when doing DB queries (care should be taken for non Latin character set). {s.unescape.common}Return unescaped string of variable's value. Reverse of above transformation. {s.escape.user}Return escaped string of variable's value, changing to '%hexa' the characters that are not allowed in user part of SIP URI following RFC requirements. {s.unescape.user}Return unescaped string of variable's value, changing '%hexa' to character code. Reverse of above transformation. {s.escape.param}Return escaped string of variable's value, changing to '%hexa' the characters that are not allowed in the param part of SIP URI following RFC requirements. {s.unescape.param}Return unescaped string of variable's value, changing '%hexa' to character code. Reverse of above transformation. {s.tolower}Return string with lower case ASCII letters. {s.toupper}Return string with upper case ASCII letters. {s.dec2hex}Converts a decimal(base 10) number to hexadecimal (in base 16), represented as string. {s.hex2dec}Converts a hexadecimal number (base 16) represented as string to decimal (base 10). URI TransformationsThe name of transformation starts with 'uri.'. The value of the variable is considered to be a SIP URI. This transformation returns parts of SIP URI (see struct sip_uri). If that part is missing, the returned value is an empty string. Available transformations in this class: {uri.user}Returns the user part of the URI schema. {uri.host}(same as {uri.domain}) Returns the domain part of the URI schema. {uri.passwd}Returns the password part of the URI schema. {uri.port}Returns the port of the URI schema. {uri.params}Returns all the URI parameters into a single string. {uri.param,name}Returns the value of URI parameter with name "name" {uri.headers}Returns URI headers. {uri.transport}Returns the value of transport URI parameter. {uri.ttl}Returns the value of ttl URI parameter. {uri.uparam}Returns the value of user URI parameter {uri.maddr}Returns the value of maddr URI parameter. {uri.method}Returns the value of method URI parameter. {uri.lr}Returns the value of lr URI parameter. {uri.r2}Returns the value of r2 URI parameter. VIA TransformationsThese transformations parse Via headers and all starts with Examples: $var(upstreamtransport) = $(hdr(Via)[1]{via.transport}{s.tolower}); $var(upstreamip) = $(hdr(Via)[1]{via.param,received}); $var(clientport) = $(hdr(Via)[-1]{via.param,rport}); Available transformations in this class: {via.name}Returns the {via.version}Returns the {via.transport}Returns the {via.host}(same as Returns the {via.port}Returns the {via.comment}The comment associated with the via header. The {via.params}Returns all the Via headers parameters ( {via.param,name}Returns the value of Via header parameter with name {via.branch}Returns the value of the branch parameter in the VIA header. {via.received}Returns the value of the received parameter in the VIA header, if any. {via.rport}Returns the value of the rport parameter in the VIA header, if any. Parameters List TransformationsThe name of the transformation starts with "param.". The value of the variable is considered to be a string like name1=value1;name2=value2;...". The transformations returns the value for a specific parameter, or the name of a parameter at a specific index. Available transformations in this class: {param.value,name}Returns the value of parameter 'name' Example: "a=1;b=2;c=3"{param.value,c} = "3" 'name' can be a variable {param.exist,name}Returns 1 if the parameter Example: "a=0;b=2;ob;c=3"{param.exist,ob}; # returns 1 "a=0;b=2;ob;c=3"{param.exist,a}; # returns 1 "a=0;b=2;ob;c=3"{param.exist,foo}; # returns 0 {param.valueat,index}Returns the value of parameter at position give by 'index' (0-based index) Example: "a=1;b=2;c=3"{param.valueat,1} = "2" 'index' can be a variable {param.name,index}Returns the name of parameter at position 'index'. Example: "a=1;b=2;c=3"{param.name,1} = "b" {param.count}Returns the number of parameters in the list. Example: "a=1;b=2;c=3"{param.count} = 3 Name-address TransformationsThe name of the transformation starts with 'nameaddr.'. The value of the variable is considered to be a string like '[display_name] uri'. The transformations returns the value for a specific field. Available transformations in this class: {nameaddr.name}Returns the value of display name Example: '"test" <sip:test@opensips.org>' {nameaddr.name} = "test" {nameaddr.uri}Returns the value of URI Example: '"test" <sip:test@opensips.org>' {nameaddr.uri} = sip:test@opensips.org {nameaddr.len}Returns the length of the entire name-addr part from the value. {nameaddr.param,param_name}Returns the value of the parameter with name param_name. Example: '"test" <sip:test@opensips.org>;tag=dat43h' {nameaddr.param,tag} = dat43h {nameaddr.params}Returns all the parameters and their corresponding values. Example: '"test" <sip:test@opensips.org>;tag=dat43h;private=yes' {nameaddr.params} = "tag=dat43h;private=yes" IP TransformationsThe name of the transformation starts with 'ip.'. Available transformations in this class: {ip.pton}Returns a binary representation of a string represented IP. Example: "192.168.2.134" {ip.pton} returns a 4 byte binary representation of the IP provided {ip.ntop}Returns a string representation of the binary IP provided Example: "192.168.2.134"{ip.pton}{ip.ntop} = "192.168.2.134" {ip.isip}Returns 1 or 0, if the string provided is a valid IP or not. Example: "192.168.2.134" {ip.isip} = 1 "192.168.2.134.1" {ip.isip} = 0 {ip.family}Returns INET or INET6 if the binary IP representation provided is IPv4 or IPv6. Example: "192.168.2.134" {ip.pton}{ip.family} = "INET" {ip.resolve}Returns the resolved IP address coresponding to the string domain provided. Transformation has no effect if a string IP is provided. Example: "opensips.org" {ip.resolve} = "78.46.64.50" CSV TransformationsThe name of the transformation starts with "csv.". The value of the variable is considered to be a string like "field1,field2,...". The transformations return the number of entries in the provided CSV, or the field at a specified position in the CSV. Available transformations in this class: {csv.count}Returns the number of entries in the provided CSV. Example: "a,b,c" {csv.count} = 3 {csv.value}Returns the entry at the specified positions. Indexing starts from 0. Example: "a,b,c" {csv.value,2} = c SDP TransformationsThe name of the transformation starts with "sdp.". The value of the variable is considered to be a valid SDP body. The transformation returns a specific line in the SDP body. Available transformations in this class: {sdp.line}Returns the specified line in the SDP body. The transformations also accepts a second parameter, that specifies the line number of the first parameter's type to get from the SDP body. Indexing starts from 0. If the second parameter is missing, it is assumed to be 0. Example: if (is_method("INVITE")) { $var(aline) = $(rb{sdp.line,a,1}); xlog("The second a line in the SDP body is $var(aline)\n"); } if (is_method("INVITE")) { $var(mline) = $(rb{sdp.line,m}); xlog("The first m line in the SDP body is $var(mline)\n"); } Regular Expression TransformationsThe name of the transformation starts with "re.". The input can be any string. {re.subst,reg_exp}The reg_exp parameter can either be a plain string or a variable. The format of the reg_exp is : /posix_match_expression/replacement_expression/flags The flags can be i - match ignore case s - match within multi-lines strings g - replace all matches Example: $var(reg_input)="abc"; $var(reg) = "/a/A/g"; xlog("Applying reg exp $var(reg) to $var(reg_input) : $(var(reg_input){re.subst,$var(reg)})\n"); ... ... xlog("Applying reg /b/B/g to $var(reg_input) : $(var(reg_input){re.subst,/b/B/g})\n"); ExamplesWithin a variable, many transformation can be applied, being executed from left to right.
$var(x) = "a=1;b=22;c=333"; $(var(x){param.value,$(var(x){param.name,1})}{s.len}) = 2
if(is_method("REGISTER") && is_present_hf("Expires") && $(hdr(Expires){s.int})==0) xlog("This is an un-registrationn"); to:
(:redirect Documentation.Script-Tran quiet=1 :) March 15, 2013, at 01:37 PM
by
- Changed lines 178-184 from:
to:
{s.dec2hex}Converts a decimal(base 10) number to hexadecimal (in base 16), represented as string. {s.hex2dec}Converts a hexadecimal number (base 16) represented as string to decimal (base 10). October 29, 2012, at 12:42 PM
by
- Changed line 500 from:
{sdp.subst,reg_exp}to:
{re.subst,reg_exp}June 05, 2012, at 12:58 PM
by
- Added lines 495-521:
Regular Expression TransformationsThe name of the transformation starts with "re.". The input can be any string. {sdp.subst,reg_exp}The reg_exp parameter can either be a plain string or a variable. The format of the reg_exp is : /posix_match_expression/replacement_expression/flags The flags can be i - match ignore case s - match within multi-lines strings g - replace all matches Example: $var(reg_input)="abc"; $var(reg) = "/a/A/g"; xlog("Applying reg exp $var(reg) to $var(reg_input) : $(var(reg_input){re.subst,$var(reg)})\n"); ... ... xlog("Applying reg /b/B/g to $var(reg_input) : $(var(reg_input){re.subst,/b/B/g})\n"); May 29, 2012, at 05:04 PM
by
- Added lines 401-409:
{nameaddr.params}Returns all the parameters and their corresponding values. Example: '"test" <sip:test@opensips.org>;tag=dat43h;private=yes' {nameaddr.params} = "tag=dat43h;private=yes" April 23, 2012, at 07:35 PM
by
- Changed lines 249-251 from:
$var(upstreamtransport) = $(hdr(Via)[1]){via.transport}{s.tolower}); $var(upstreamip) = $(hdr(Via)[1]){via.param,received}); $var(clientport) = $(hdr(Via)[-1]){via.param,rport}); to:
$var(upstreamtransport) = $(hdr(Via)[1]{via.transport}{s.tolower}); $var(upstreamip) = $(hdr(Via)[1]{via.param,received}); $var(clientport) = $(hdr(Via)[-1]{via.param,rport}); April 23, 2012, at 12:04 PM
by
- Added lines 290-300:
{via.branch}Returns the value of the branch parameter in the VIA header. {via.received}Returns the value of the received parameter in the VIA header, if any. {via.rport}Returns the value of the rport parameter in the VIA header, if any. March 22, 2012, at 01:55 PM
by
- Changed line 4 from:
This documentation is valid for OpenSIPS v1.8.x / devel to:
This documentation is valid for OpenSIPS v1.9.x / devel July 12, 2011, at 07:55 PM
by
- Changed line 1 from:
Resources -> Documentation -> CookBooks -> Script Transformations - develto:
Resources -> Documentation -> CookBooks -> Script TransformationsChanged line 4 from:
This documentation is valid for OpenSIPS v1.7.x / devel to:
This documentation is valid for OpenSIPS v1.8.x / devel April 21, 2011, at 11:54 PM
by
- Add {param.exist,name} transformChanged lines 309-312 from:
{param.valueat,index}Returns the value of parameter at position give by 'index' (0-based index) to:
{param.exist,name}Returns 1 if the parameter Changed lines 315-317 from:
"a=1;b=2;c=3"{param.valueat,1} = "2" to:
"a=0;b=2;ob;c=3"{param.exist,ob}; # returns 1 "a=0;b=2;ob;c=3"{param.exist,a}; # returns 1 "a=0;b=2;ob;c=3"{param.exist,foo}; # returns 0 Added lines 320-328:
{param.valueat,index}Returns the value of parameter at position give by 'index' (0-based index) Example: "a=1;b=2;c=3"{param.valueat,1} = "2" Added line 339:
April 21, 2011, at 11:46 PM
by
- Finish {via.*} transform docsChanged lines 246-247 from:
These transformations parse Via headers and all starts with to:
These transformations parse Via headers and all starts with Examples: $var(upstreamtransport) = $(hdr(Via)[1]){via.transport}{s.tolower}); $var(upstreamip) = $(hdr(Via)[1]){via.param,received}); $var(clientport) = $(hdr(Via)[-1]){via.param,rport}); Changed lines 280-281 from:
TBD to:
The comment associated with the via header. The Changed line 288 from:
TBD to:
Returns the value of Via header parameter with name April 21, 2011, at 10:26 PM
by
- Initial documentation of via.* transformAdded lines 244-282:
VIA TransformationsThese transformations parse Via headers and all starts with Available transformations in this class: {via.name}Returns the {via.version}Returns the {via.transport}Returns the {via.host}(same as Returns the {via.port}Returns the {via.comment}TBD {via.params}Returns all the Via headers parameters ( {via.param,name}TBD March 02, 2011, at 02:59 PM
by
- Changed line 408 from:
$var(aline) = $(rb{sdp.lineat,a,1}); to:
$var(aline) = $(rb{sdp.line,a,1}); Changed line 414 from:
$var(mline) = $(rb{sdp.lineat,m}); to:
$var(mline) = $(rb{sdp.line,m}); August 13, 2010, at 11:35 AM
by
- Changed lines 333-340 from:
ExamplesWithin a variable, many transformation can be applied, being executed from left to right.
to:
IP TransformationsThe name of the transformation starts with 'ip.'. Available transformations in this class: {ip.pton}Returns a binary representation of a string represented IP. Example: "192.168.2.134" {ip.pton} returns a 4 byte binary representation of the IP provided {ip.ntop}Returns a string representation of the binary IP provided Example: "192.168.2.134"{ip.pton}{ip.ntop} = "192.168.2.134" {ip.isip}Returns 1 or 0, if the string provided is a valid IP or not. Example: "192.168.2.134" {ip.isip} = 1 "192.168.2.134.1" {ip.isip} = 0 {ip.family}Returns INET or INET6 if the binary IP representation provided is IPv4 or IPv6. Example: "192.168.2.134" {ip.pton}{ip.family} = "INET" {ip.resolve}Returns the resolved IP address coresponding to the string domain provided. Transformation has no effect if a string IP is provided. Example: "opensips.org" {ip.resolve} = "78.46.64.50" CSV TransformationsThe name of the transformation starts with "csv.". The value of the variable is considered to be a string like "field1,field2,...". The transformations return the number of entries in the provided CSV, or the field at a specified position in the CSV. Available transformations in this class: {csv.count}Returns the number of entries in the provided CSV. Example: "a,b,c" {csv.count} = 3 {csv.value}Returns the entry at the specified positions. Indexing starts from 0. Example: "a,b,c" {csv.value,2} = c SDP TransformationsThe name of the transformation starts with "sdp.". The value of the variable is considered to be a valid SDP body. The transformation returns a specific line in the SDP body. Available transformations in this class: {sdp.line}Returns the specified line in the SDP body. The transformations also accepts a second parameter, that specifies the line number of the first parameter's type to get from the SDP body. Indexing starts from 0. If the second parameter is missing, it is assumed to be 0. Example: if (is_method("INVITE")) { $var(aline) = $(rb{sdp.lineat,a,1}); xlog("The second a line in the SDP body is $var(aline)\n"); } if (is_method("INVITE")) { $var(mline) = $(rb{sdp.lineat,m}); xlog("The first m line in the SDP body is $var(mline)\n"); } October 14, 2009, at 12:38 AM
by
- Changed line 4 from:
This documentation is valid for OpenSIPS v1.6.x / devel to:
This documentation is valid for OpenSIPS v1.7.x / devel September 02, 2009, at 12:18 PM
by
- Added lines 329-332:
Example: '"test" <sip:test@opensips.org>;tag=dat43h' {nameaddr.param,tag} = dat43h August 20, 2009, at 12:34 PM
by
- Added lines 326-328:
{nameaddr.param,param_name}Returns the value of the parameter with name param_name. April 23, 2009, at 11:30 AM
by
- Changed lines 1-4 from:
Resources -> Documentation -> CookBooks -> Script Transformationsto:
Resources -> Documentation -> CookBooks -> Script Transformations - develThis documentation is valid for OpenSIPS v1.6.x / devel October 08, 2008, at 09:45 AM
by
- Changed lines 1-2 from:
Resources -> Documentation -> Script Transformationsto:
Resources -> Documentation -> CookBooks -> Script TransformationsOctober 03, 2008, at 01:51 PM
by
- Added lines 3-4:
(:toc-float Table of Content:) July 21, 2008, at 07:49 PM
by
- Changed lines 3-4 from:
Transformation is basically a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the orignal variable is not altered. to:
A Transformation is basically a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the original variable is not altered. Changed lines 29-30 from:
$avp(i:22) = "openser"; to:
$avp(i:22) = "opensips"; Changed lines 42-43 from:
A transformation is represented in between '{' and '}' and follows the name of a PV. When using transformations, the PV name and transformations must be enclosed in between '(' and ')'. to:
A transformation is represented in between '{' and '}' and follows the name of a variable. When using transformations, the variable name and transformations must be enclosed in between '(' and ')'. Changed lines 47-48 from:
to:
Changed lines 60-61 from:
The transformations can be used anywhere, being considered parts of PV -- in xlog, avpops or other modules' functions and parameters, in right side assignment expressions or in comparisons. to:
The transformations can be used anywhere, being considered parts of script variables support -- in xlog, avpops or other modules' functions and parameters, in right side assignment expressions or in comparisons. Changed lines 106-107 from:
Return substring starting at offset having size of 'length'. If offset is negative, then it is counted from the end of PV value, -1 being the last char. In case of positive value, 0 is first char. Length must be positive, in case of 0, substring to the end of variable value is returned. offset and length can be a varibale as well. to:
Return substring starting at offset having size of 'length'. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of positive value, 0 is first char. Length must be positive, in case of 0, substring to the end of variable value is returned. offset and length can be a varibale as well. Changed lines 116-117 from:
Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of PV value, -1 being last field. If index is positive, 0 is the first field. to:
Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of value, -1 being last field. If index is positive, 0 is the first field. July 21, 2008, at 07:46 PM
by
- Changed lines 1-339 from:
Resources -> Documentation -> Script Transformationsto:
Resources -> Documentation -> Script TransformationsTransformation is basically a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the orignal variable is not altered. Example of using different kind of variables in OpenSIPS script: # check if username in From header is equal with username in To header if($fU==$tU) { ... } # r-uri username based processing switch($ruri.user) { case "1234": ... break; case "5678": ... break; default: ... } # assign integer value to an AVP $avp(i:11) = 1; #assing string value to an AVP $avp(i:22) = "openser"; # write ruri in an AVP $avp(i:33) = $ruri; # concat "sip:" + From username + "@" + To domain in a script variable x $var(x) = "sip:" + $fU +"@" + $td; The transformations are intended to facilitate access to different attributes of variables (like strlen of value, parts of value, substrings) or complete different value of variables (encoded in hexa, md5 value, escape/unescape value for DB operations...). A transformation is represented in between '{' and '}' and follows the name of a PV. When using transformations, the PV name and transformations must be enclosed in between '(' and ')'. Example: # the length of From URI ($fu is PV for From URI) $(fu{s.len}) Many transformations can be applied in the same time to a variable. # the length of escaped 'Test' header body $(hdr(Test){s.escape.common}{s.len}) The transformations can be used anywhere, being considered parts of PV -- in xlog, avpops or other modules' functions and parameters, in right side assignment expressions or in comparisons. IMPORTANT: To learn what variables can be used with transformations see Scripting variables list. String TransformationsThe name of these transformation starts with 's.'. They are intended to apply string operations to variables. Available transformations in this class: {s.len}Return strlen of variable value $var(x) = "abc"; if($(var(x){s.len}) == 3) { ... } {s.int}Return integer value of a string-represented number $var(x) = "1234"; if($(var(x){s.int})==1234) { ... } {s.md5}Return md5 over variable value xlog("MD4 over From username: $(fU{s.md5})"); {s.substr,offset,length}Return substring starting at offset having size of 'length'. If offset is negative, then it is counted from the end of PV value, -1 being the last char. In case of positive value, 0 is first char. Length must be positive, in case of 0, substring to the end of variable value is returned. offset and length can be a varibale as well. Example: $var(x) = "abcd"; $(var(x){s.substr,1,0}) = "bcd" {s.select,index,separator}Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of PV value, -1 being last field. If index is positive, 0 is the first field. Example: $var(x) = "12,34,56"; $(var(x){s.select,1,,}) => "34" ; $var(x) = "12,34,56"; $(var(x){s.select,-2,,}) => "34" {s.encode.hexa}Return encoding in hexa of variable's value {s.decode.hexa}Return decoding from hexa of variable's value {s.escape.common}Return escaped string of variable's value. Characters escaped are ', ", and 0. Useful when doing DB queries (care should be taken for non Latin character set). {s.unescape.common}Return unescaped string of variable's value. Reverse of above transformation. {s.escape.user}Return escaped string of variable's value, changing to '%hexa' the characters that are not allowed in user part of SIP URI following RFC requirements. {s.unescape.user}Return unescaped string of variable's value, changing '%hexa' to character code. Reverse of above transformation. {s.escape.param}Return escaped string of variable's value, changing to '%hexa' the characters that are not allowed in the param part of SIP URI following RFC requirements. {s.unescape.param}Return unescaped string of variable's value, changing '%hexa' to character code. Reverse of above transformation. {s.tolower}Return string with lower case ASCII letters. {s.toupper}Return string with upper case ASCII letters. URI TransformationsThe name of transformation starts with 'uri.'. The value of the variable is considered to be a SIP URI. This transformation returns parts of SIP URI (see struct sip_uri). If that part is missing, the returned value is an empty string. Available transformations in this class: {uri.user}Returns the user part of the URI schema. {uri.host}(same as {uri.domain}) Returns the domain part of the URI schema. {uri.passwd}Returns the password part of the URI schema. {uri.port}Returns the port of the URI schema. {uri.params}Returns all the URI parameters into a single string. {uri.param,name}Returns the value of URI parameter with name "name" {uri.headers}Returns URI headers. {uri.transport}Returns the value of transport URI parameter. {uri.ttl}Returns the value of ttl URI parameter. {uri.uparam}Returns the value of user URI parameter {uri.maddr}Returns the value of maddr URI parameter. {uri.method}Returns the value of method URI parameter. {uri.lr}Returns the value of lr URI parameter. {uri.r2}Returns the value of r2 URI parameter. Parameters List TransformationsThe name of the transformation starts with "param.". The value of the variable is considered to be a string like name1=value1;name2=value2;...". The transformations returns the value for a specific parameter, or the name of a parameter at a specific index. Available transformations in this class: {param.value,name}Returns the value of parameter 'name' Example: "a=1;b=2;c=3"{param.value,c} = "3" 'name' can be a variable {param.valueat,index}Returns the value of parameter at position give by 'index' (0-based index) Example: "a=1;b=2;c=3"{param.valueat,1} = "2" 'index' can be a variable {param.name,index}Returns the name of parameter at position 'index'. Example: "a=1;b=2;c=3"{param.name,1} = "b" {param.count}Returns the number of parameters in the list. Example: "a=1;b=2;c=3"{param.count} = 3 Name-address TransformationsThe name of the transformation starts with 'nameaddr.'. The value of the variable is considered to be a string like '[display_name] uri'. The transformations returns the value for a specific field. Available transformations in this class: {nameaddr.name}Returns the value of display name Example: '"test" <sip:test@opensips.org>' {nameaddr.name} = "test" {nameaddr.uri}Returns the value of URI Example: '"test" <sip:test@opensips.org>' {nameaddr.uri} = sip:test@opensips.org {nameaddr.len}Returns the length of the entire name-addr part from the value. ExamplesWithin a variable, many transformation can be applied, being executed from left to right.
$var(x) = "a=1;b=22;c=333"; $(var(x){param.value,$(var(x){param.name,1})}{s.len}) = 2
if(is_method("REGISTER") && is_present_hf("Expires") && $(hdr(Expires){s.int})==0) xlog("This is an un-registrationn"); |