Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
core-cookbook:devel [2009/02/17 14:14] ramona |
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 Keywords ===== | ||
- | Keywords specific to SIP messages which can be used mainly in ''' | ||
- | |||
- | ==== 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(" | ||
- | } | ||
- | </ | ||
- | |||
- | ==== 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: | ||
- | |||
- | < | ||
- | | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== dst_port ==== | ||
- | |||
- | The local port where the SIP packet was received. When SIP-Router is listening on many ports, it is useful to learn which was the one that received the SIP packet. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | | ||
- | { | ||
- | | ||
- | }; | ||
- | </ | ||
- | |||
- | |||
- | ==== from_uri ==== | ||
- | |||
- | This script variable is a reference to the URI of ' | ||
- | |||
- | Example of usage: | ||
- | |||
- | < | ||
- | if(is_method(" | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== method ==== | ||
- | |||
- | The variable is a reference to the SIP method of the message. | ||
- | |||
- | Example of usage: | ||
- | |||
- | < | ||
- | if(method==" | ||
- | { | ||
- | | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== msg:len ==== | ||
- | |||
- | The variable is a reference to the size of the message. It can be used in ' | ||
- | |||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(msg: | ||
- | { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== $retcode ==== | ||
- | |||
- | It represents the value returned by last function executed (similar to $? from bash -- if you wish, you can use also $? in SIP-Router config, both names ' | ||
- | |||
- | Example of usage: | ||
- | |||
- | < | ||
- | route { | ||
- | | ||
- | | ||
- | { | ||
- | | ||
- | }; | ||
- | } | ||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | </ | ||
- | |||
- | ==== proto ==== | ||
- | |||
- | This variable can be used to test the transport protocol of the SIP message. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(proto==UDP) | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== status ==== | ||
- | |||
- | If used in onreply_route, | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(status==" | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== src_ip ==== | ||
- | |||
- | Reference to source IP address of the SIP message. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(src_ip==127.0.0.1) | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== src_port ==== | ||
- | |||
- | Reference to source port of the SIP message (from which port the message was sent by previous hop). | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(src_port==5061) | ||
- | { | ||
- | log(" | ||
- | } | ||
- | </ | ||
- | |||
- | ==== to_uri ==== | ||
- | |||
- | This variable can be used to test the value of URI from To header. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(to_uri=~" | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== uri ==== | ||
- | |||
- | |||
- | This variable can be used to test the value of the request URI. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(uri=~" | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== Core Values ===== | ||
- | |||
- | Values that can be used in ''' | ||
- | |||
- | ==== INET ==== | ||
- | |||
- | This keyword can be used to test whether the SIP packet was received over an IPv4 connection. | ||
- | |||
- | Example of usage: | ||
- | |||
- | < | ||
- | if (af==INET) { | ||
- | log(" | ||
- | } | ||
- | </ | ||
- | |||
- | ==== INET6 ==== | ||
- | |||
- | This keyword can be used to test whether the SIP packet was received over an IPv6 connection. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(af==INET6) | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== TCP ==== | ||
- | |||
- | This keyword can be used to test the value of ' | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(proto==TCP) | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== UDP ==== | ||
- | |||
- | This keyword can be used to test the value of ' | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(proto==UDP) | ||
- | { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | ==== max_len ==== | ||
- | |||
- | This keyword is set to the maximum size of an UDP packet. It can be used to test message' | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(msg: | ||
- | { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== myself ==== | ||
- | |||
- | It is a reference to the list of local IP addresses, hostnames and aliases that has been set in SIP-Router configuration file. This lists contain the domains served by SIP-Router. | ||
- | |||
- | The variable can be used to test if the host part of an URI is in the list. The usefulness of this test is to select the messages that has to be processed locally or has to be forwarded to another server. | ||
- | |||
- | See " | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | if(uri==myself) { | ||
- | log(" | ||
- | }; | ||
- | </ | ||
- | |||
- | |||
- | ==== null ==== | ||
- | |||
- | Can be used in assignment to reset the value of a per-script variable or to delete an avp. | ||
- | |||
- | Example of usage: | ||
- | < | ||
- | $avp(i:12) = null; | ||
- | $var(x) = null; | ||
- | </ | ||
- | |||
- | ===== Core parameters ===== | ||
- | |||
- | |||
- | ===== Core functions ===== | ||
- | |||
- | ===== Routing blocks ===== | ||
- | |||
- | ===== Script statements ===== | ||
- | |||
- | ===== Script operations ===== |