User Tools

Site Tools


cookbooks:devel:transformations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cookbooks:devel:transformations [2017/11/18 17:16]
miconda
cookbooks:devel:transformations [2020/01/28 10:54]
miconda [{s.rm,match}]
Line 1: Line 1:
-====== Kamailio SIP Server v5.2.x (devel): Transformations ======+====== Kamailio SIP Server v5.4.x (devel): Transformations ======
  
 <code> <code>
Line 153: Line 153:
 Decode base64 encoded PV and return value Decode base64 encoded PV and return value
  
 +==== {s.encode.base64t} ====
  
 +Return base64 encoding of PV value without trailing padding characters('=').
  
 +
 +==== {s.decode.base64t} ====
 +
 +Decode base64 encoded PV, handling missing trailing padding characters, and return value.
 ==== {s.escape.common} ==== ==== {s.escape.common} ====
  
Line 308: Line 314:
 </code> </code>
  
 +==== {s.rmws} ====
 +
 +Remove occurrences of whitespace characters (' ', '\t, '\r', '\n').
 +
 +<code c>
 +$(var(x){s.rmws})
 +</code>
 ==== {s.corehash,n} ==== ==== {s.corehash,n} ====
  
Line 317: Line 330:
 $(var(x){s.corehash}) $(var(x){s.corehash})
 </code> </code>
 +
 +==== {s.unquote} ====
 +
 +Return the value without surrounding single (') or double quotes (").
 +
 +<code c>
 +$var(x) = "\"alice\"";
 +$var(alice) = $(var(x){s.unquote});
 +</code>
 +
 +==== {s.unbracket} ====
 +
 +Return the value without surrounding (), [], {} or <>.
 +
 +<code c>
 +$var(x) = "<sip:alice@test.sip>";
 +$var(uri) = $(var(x){s.unbracket});
 +</code>
 +
 +==== {s.count,c} ====
 +
 +Count how many times c appears in the pv value.
 +
 +<code c>
 +abababa"{s.count,a}
 +# will return 4
 +</code>
 +
 +
 ===== URI Transformations ===== ===== URI Transformations =====
  
Line 385: Line 427:
 Return the string value of URI scheme. Return the string value of URI scheme.
  
 +==== {uri.tosocket} ====
 +
 +Return the string value corresponding to socket address matching proto, address and port from the URI. In other words, converts from a format like **sip:address:port;transport=proto** to **proto:address:port**.
 +
 +Example:
 +
 +<code>
 +"sip:test@127.0.0.1:5060;transport=udp"{uri.tosocket} => "udp:127.0.0.1:5060"
 +</code>
 ===== Parameters List Transformations ===== ===== Parameters List Transformations =====
  
 The name of the transformation starts with 'param.'. The PV value 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. The name of the transformation starts with 'param.'. The PV value 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:+Available transformations in this class are presented in the next sections. 
 + 
 +**Important Note:** the delimiter cannot be comma (,), because this transformation is using SIP header/URI parameters parser and the comma is a delimiter between serialized SIP header/URI bodies. The workaround is to use the subst transformation to replace the comma with another character that is used then as separator.
  
  
Line 573: Line 626:
 ==== {re.subst,expression} ==== ==== {re.subst,expression} ====
  
-Perform Perl-like substitutions on string value pseudo-variables.+Perform POSIX regex substitutions on string value pseudo-variables.
  
 <code c> <code c>
Line 684: Line 737:
  
 $(hu{url.querystring}) => "this=is&the=querystring" $(hu{url.querystring}) => "this=is&the=querystring"
 +</code>
 +
 +===== JSON Transformations =====
 +
 +<fc #0000ff>This transformation class is exported by **json** module.</fc>
 +
 +
 +==== {json.parse} ====
 +
 +You can use the transformation to extract values from the json structured pseudo-variables
 +
 +<code>
 +
 +$var(Custom-Data) = $(rb{json.parse,Custom-Data});
 +
 </code> </code>
  
cookbooks/devel/transformations.txt · Last modified: 2022/04/08 18:08 by miconda