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
core-cookbook:devel [2009/02/17 13:51]
86.121.130.137
core-cookbook:devel [2012/03/19 09:07] (current)
85.178.69.42
Line 1: Line 1:
 ====== SIP Router: Core Cookbook ====== ====== SIP Router: Core Cookbook ======
  
-This tutorial collects the functions and parameters exported by SIP Router core to configuration file.+**This page has been moved to [[cookbooks:core-cookbook:devel|cookbooks:core-cookbook:devel]]Check there for updated version**
  
-===== Core Keywords ===== 
  
-Keywords specific to SIP messages which can be used mainly in '''if''' expressions. 
- 
-==== af ==== 
- 
-The address family of the received SIP message. It is INET if the message was received over IPv4 or INET6 if the message was received over IPv6. 
- 
-Exampe of usage: 
- 
-<code c> 
-    if (af==INET6) { 
-        log("Message received over IPv6 link\n"); 
-    } 
-</code> 
- 
-==== dst_ip ==== 
- 
-The IP of the local interface where the SIP message was received. When the proxy listens on many network interfaces, makes possible to detect which was the one that received the packet. 
- 
-Example of usage: 
- 
-<code> 
-   if(dst_ip==127.0.0.1) { 
-      log("message received on loopback interface\n"); 
-   }; 
-</code> 
- 
-==== dst_port ==== 
- 
-The local port where the SIP packet was received. When OpenSER is listening on many ports, it is useful to learn which was the one that received the SIP packet. 
- 
-Example of usage: 
-<code> 
-   if(dst_port==5061) 
-   { 
-       log("message was received on port 5061\n"); 
-   }; 
-</code> 
-// The code is original copy 
- 
-==== from_uri ==== 
- 
-This script variable is a reference to the URI of 'From' header. It can be used to test 'From'- header URI value. 
- 
-Example of usage: 
- 
-<code> 
-    if(is_method("INVITE") && from_uri=~".*@sip-router.org") 
-    { 
-        log("the caller is from sip-router.org\n"); 
-    }; 
-</code> 
- 
-==== method ==== 
- 
-The variable is a reference to the SIP method of the message. 
- 
-Example of usage: 
- 
-<code> 
-    if(method=="REGISTER") 
-    { 
-       log("this SIP request is a REGISTER message\n"); 
-    }; 
-</code> 
- 
-==== msg:len ==== 
- 
-The variable is a reference to the size of the message. It can be used in 'if' constructs to test message's size. 
- 
- 
-Example of usage: 
-<code> 
-    if(msg:len>2048) 
-    { 
-        sl_send_reply("413", "message too large"); 
-        exit; 
-    }; 
-</code> 
- 
-==== $retcode ==== 
- 
-It represents the value returned by last function executed (similar to $? from bash -- if you wish, you can use also $? in OpenSER config, both names '$retcode' and '$?' are supported). If tested after a call of a route, it is the value retuned by that route. 
- 
-Example of usage: 
- 
-<code> 
-   route { 
-       route(1); 
-       if($retcode==1) 
-       { 
-           log("The request is an INVITE\n"); 
-       }; 
-   } 
-   
-    
-   route[1] { 
-       if(is_method("INVITE")) 
-           return(1); 
-       return(2); 
-   } 
-</code> 
- 
-==== proto ==== 
- 
-This variable can be used to test the transport protocol of the SIP message. 
- 
-Example of usage: 
-<code> 
-    if(proto==UDP) 
-    { 
-        log("SIP message received over UDP\n"); 
-    }; 
-</code> 
- 
-==== status ==== 
- 
-If used in onreply_route, this variable is a referece to the status code of the reply. If it used in a standard route block, the variable is a reference to the status of the last reply sent out for the current request. 
- 
-Example of usage: 
-<code> 
-    if(status=="200") 
-    { 
-        log("this is a 200 OK reply\n"); 
-    }; 
-</code> 
- 
-==== src_ip ==== 
- 
-Reference to source IP address of the SIP message. 
- 
-Example of usage: 
-<code> 
-    if(src_ip==127.0.0.1) 
-    { 
-        log("the message was sent from localhost!\n"); 
-    }; 
-</code> 
- 
-==== src_port ==== 
- 
-Reference to source port of the SIP message (from which port the message was sent by previous hop). 
- 
-Example of usage: 
-<code> 
-    if(src_port==5061) 
-    { 
-        log("message sent from port 5061\n"); 
-    } 
-</code> 
- 
-==== to_uri ==== 
- 
-This variable can be used to test the value of URI from To header. 
- 
-Example of usage: 
-<code> 
-  if(to_uri=~"sip:.+@sip-router.org") 
-  { 
-      log("this is a request for sip-router.org users\n"); 
-  }; 
-</code> 
- 
-==== uri ==== 
- 
- 
-This variable can be used to test the value of the request URI. 
- 
-Example of usage: 
-<code> 
-    if(uri=~"sip:.+@sip-router.org") 
-    { 
-        log("this is a request for sip-router.org users\n"); 
-    }; 
-</code> 
- 
- 
- 
- 
- 
- 
-===== Core Values ===== 
- 
-Values that can be used in '''if''' expressions to check against Core Keywords 
- 
-==== INET ==== 
- 
-This keyword can be used to test whether the SIP packet was received over an IPv4 connection. 
- 
-Example of usage: 
- 
-<code c> 
-    if (af==INET) { 
-        log("the SIP message was received over IPv4\n"); 
-    } 
-</code> 
- 
-===== Core parameters ===== 
- 
-===== Core functions ===== 
- 
-===== Routing blocks ===== 
- 
-===== Script statements ===== 
- 
-===== Script operations ===== 

Navigation

Wiki

Other

QR Code
QR Code core-cookbook:devel (generated for current page)