Documentation |
Documentation.Tutorials-ScriptHelper-1-11 HistoryHide minor edits - Show changes to output April 07, 2014, at 12:00 PM
by
- Changed line 8 from:
The purpose of this new module is to help you %blue%start in an easy way with the OpenSIPS script%%. %blue%The learning curve gets milder%% as the beginners can start with a simplified format of the script - the idea is to %blue%shift the main focus on routing the SIP initial requests%% (which define the service logic), while transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers both a brief overview on the features of the new module and an example script. to:
The purpose of this new module is to help you %blue%start in an easy way with the OpenSIPS script%%. %blue%The learning curve gets milder%% as the beginners can start with a simplified format of the script - the idea is to %blue%shift the main focus on routing the SIP initial requests%% (which define the service logic), while transparently handling a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers both a brief overview on the features of the new module and an example script. April 07, 2014, at 11:48 AM
by
- Changed lines 8-9 from:
The purpose of this new module is to transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers both a brief overview on the features of the new module and an example script. to:
The purpose of this new module is to help you %blue%start in an easy way with the OpenSIPS script%%. %blue%The learning curve gets milder%% as the beginners can start with a simplified format of the script - the idea is to %blue%shift the main focus on routing the SIP initial requests%% (which define the service logic), while transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers both a brief overview on the features of the new module and an example script. Changed lines 13-14 from:
* transparent handling for SIP requests ** sequential requests are silently handled and will not hit the script at all anymore - they are routed using loose_route() to:
# '''transparent handling of SIP sequential requests''' ** sequential requests are properly and silently handled - they will not hit the script at all anymore Changed lines 16-17 from:
** ''[optional]'' a special route may be run just before all sequential requests are routed out * ''[optional]'' embedded dialog support to:
** for sequential SIP requests, the module is automatically doing loose_route() for proper routing. ** optionally a special route may be run just before all sequential requests are routed out # '''automatic dialog support''' ** automatically create dialog support for the INVITE-based sessions April 04, 2014, at 01:47 PM
by
- Changed line 16 from:
* ''[optional]'' a special route may be run just before all sequential requests are routed out to:
** ''[optional]'' a special route may be run just before all sequential requests are routed out April 03, 2014, at 08:26 PM
by
- Changed lines 12-15 from:
As stated in the [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html | documentation ]], the default features are: * transparent handling for sequential requests (they will not hit the script at all anymore!) * record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Record-Route'' header), after which the main route is triggered, just as before to:
As stated in the [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html | documentation ]], the module currently features: * transparent handling for SIP requests ** sequential requests are silently handled and will not hit the script at all anymore - they are routed using loose_route() ** for initial SIP requests, the module performs record-routing (i.e. OpenSIPS adds itself in the signaling path using a ''Record-Route'' header), after which the main route is triggered, just as before * ''[optional]'' a special route may be run just before all sequential requests are routed out * ''[optional]'' embedded dialog support ** for sequential requests within a dialog, a complete dialog matching (Call-ID, From-tag, To-tag) will be attempted if the quick 'did'-based Record-Route parameter matching fails Deleted lines 21-26:
Optionally, through a series of [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html#id249114 | module parameters ]], the script writer may include some additional logic: * dialog support (for sequential requests within a dialog, a complete dialog matching (Call-ID, From-tag, To-tag) will be attempted if the quick 'did'-based Record-Route parameter matching fails) * a special route to be run before all sequential requests are routed out \\ Changed line 37 from:
||[@ to:
||%block black% [@ Changed line 102 from:
to:
@][@ Added lines 104-105:
# this route will be run right before sequential requests are routed out Changed line 115 from:
to:
@][@ Added lines 326-327:
Changed line 339 from:
to:
@][@ Changed line 396 from:
to:
@][@ March 25, 2014, at 01:41 PM
by
- Changed line 223 from:
route(1); to:
route(relay); Changed line 245 from:
t_on_failure("1"); to:
t_on_failure("failed_call"); Changed line 433 from:
route(1); to:
route(relay); Changed line 455 from:
t_on_failure("1"); to:
t_on_failure("failed_call"); March 25, 2014, at 01:34 PM
by
- Changed lines 76-79 from:
modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "disable_6xx_block", 1) modparam("tm", "onreply_avp_mode", 1) to:
Changed line 95 from:
modparam("dialog", "db_mode", 0) to:
modparam("dialog", "db_mode", 1) Deleted line 96:
modparam("dialog", "profiles_no_value", "inbound/s ; outbound/s ; shared/s") Deleted line 99:
modparam("usrloc", "nat_bflag", "NAT") Changed lines 104-105 from:
modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_FLAG") to:
Changed lines 286-289 from:
modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "disable_6xx_block", 1) modparam("tm", "onreply_avp_mode", 1) to:
Changed line 305 from:
modparam("dialog", "db_mode", 0) to:
modparam("dialog", "db_mode", 1) Deleted line 306:
modparam("dialog", "profiles_no_value", "inbound/s ; outbound/s ; shared/s") Deleted line 309:
modparam("usrloc", "nat_bflag", "NAT") Deleted line 313:
modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_FLAG") March 25, 2014, at 01:29 PM
by
- Changed line 36 from:
%color=#ff7f00% Table: %black%'''Scenario init node examples''' to:
%color=#ff7f00% Table: %green%'''Scripting examples''' March 25, 2014, at 01:27 PM
by
- Changed lines 114-115 from:
modparam("script_helper", "create_dialog_flags", "Pp") to:
modparam("script_helper", "create_dialog_flags", "PpB") Added lines 134-190:
Added lines 197-199:
Changed lines 327-339 from:
route [my_seq_route] to:
# main request routing logic route Deleted lines 340-346:
xlog("---- Sequential request handler ---- \n"); xlog("$rm | Call-ID: $ci | FT: $ft | TT: $tt\n"); } # main request routing logic route { Changed line 352 from:
if (loose_route()) to:
if (loose_route() || match_dialog()) Added lines 362-364:
xlog("---- Sequential request handler ---- \n"); xlog("$rm | Call-ID: $ci | FT: $ft | TT: $tt\n"); Changed line 371 from:
if ( is_method("ACK") ) to:
if (is_method("ACK")) Changed line 373 from:
if ( t_check_trans() ) to:
if (t_check_trans()) Changed lines 414-416 from:
{ create_dialog("Pp"); } to:
create_dialog("PpB"); March 25, 2014, at 01:11 PM
by
- Added lines 111-115:
loadmodule "script_helper.so" modparam("script_helper", "sequential_route", "my_seq_route") modparam("script_helper", "use_dialog", 1) modparam("script_helper", "create_dialog_flags", "Pp") Changed line 134 from:
if (has_totag()) to:
if (!uri == myself) Changed lines 136-170 from:
if (loose_route()) { if (is_method("INVITE")) { # even if in most of the cases is useless, do RR for # re-INVITEs alos, as some buggy clients do change route set # during the dialog. record_route(); } # route it out to whatever destination was set by loose_route() # in $du (destination URI). route(relay); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { # non loose-route, but stateful ACK; must be an ACK after # a 487 or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction -> # ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; to:
append_hf("P-hint: outbound\r\n"); route(relay); Changed lines 140-141 from:
# CANCEL processing if (is_method("CANCEL")) to:
if (is_method("PUBLISH|SUBSCRIBE")) Changed lines 142-144 from:
if (t_check_trans()) t_relay(); to:
sl_send_reply("503", "Service Unavailable"); Changed lines 146-152 from:
t_check_trans(); # record routing if (!is_method("REGISTER|MESSAGE")) record_route(); if (!uri == myself) to:
if (is_method("REGISTER")) Changed lines 148-149 from:
append_hf("P-hint: outbound\r\n"); route(relay); to:
if (!save("location")) sl_reply_error(); exit; Changed line 154 from:
if (is_method("INVITE") && !has_totag()) to:
if ($rU == NULL) Changed lines 156-158 from:
create_dialog("Pp"); to:
# request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; Changed lines 161-162 from:
if (is_method("PUBLISH|SUBSCRIBE")) to:
# do lookup with method filtering if (!lookup("location","")) Changed lines 164-165 from:
sl_send_reply("503", "Service Unavailable"); to:
t_newtran(); t_reply("404", "Not Found"); Changed lines 169-189 from:
if (is_method("REGISTER")) to:
route(1); } route [relay] { # for INVITEs enable some additional helper routes if (is_method("INVITE")) t_on_failure("failed_call"); if (!t_relay()) send_reply("500", "Internal Error"); exit; } failure_route [failed_call] { if (t_was_cancelled()) exit; if (next_branches()) Changed lines 191-194 from:
if (!save("location")) sl_reply_error(); exit; to:
t_on_failure("1"); t_relay(); Deleted lines 193-209:
if ($rU == NULL) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # do lookup with method filtering if (!lookup("location","")) { t_newtran(); t_reply("404", "Not Found"); exit; } route(1); Deleted lines 194-217:
route [relay] { # for INVITEs enable some additional helper routes if (is_method("INVITE")) t_on_failure("failed_call"); if (!t_relay()) send_reply("500", "Internal Error"); exit; } failure_route [failed_call] { if (t_was_cancelled()) exit; if (next_branches()) { t_on_failure("1"); t_relay(); } } Deleted lines 266-270:
loadmodule "script_helper.so" modparam("script_helper", "sequential_route", "my_seq_route") modparam("script_helper", "use_dialog", 1) modparam("script_helper", "create_dialog_flags", "Pp") Changed line 285 from:
if (!uri == myself) to:
if (has_totag()) Changed lines 287-288 from:
append_hf("P-hint: outbound\r\n"); route(relay); to:
if (loose_route()) { if (is_method("INVITE")) { # even if in most of the cases is useless, do RR for # re-INVITEs alos, as some buggy clients do change route set # during the dialog. record_route(); } # route it out to whatever destination was set by loose_route() # in $du (destination URI). route(relay); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { # non loose-route, but stateful ACK; must be an ACK after # a 487 or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction -> # ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # record routing if (!is_method("REGISTER|MESSAGE")) record_route(); if (!uri == myself) { append_hf("P-hint: outbound\r\n"); route(relay); } if (is_method("INVITE") && !has_totag()) { create_dialog("Pp"); March 25, 2014, at 01:08 PM
by
- Deleted lines 110-114:
loadmodule "script_helper.so" modparam("script_helper", "sequential_route", "my_seq_route") modparam("script_helper", "use_dialog", 1) modparam("script_helper", "create_dialog_flags", "Pp") Changed line 129 from:
if (!uri == myself) to:
if (has_totag()) Changed lines 131-132 from:
append_hf("P-hint: outbound\r\n"); route(relay); to:
if (loose_route()) { if (is_method("INVITE")) { # even if in most of the cases is useless, do RR for # re-INVITEs alos, as some buggy clients do change route set # during the dialog. record_route(); } # route it out to whatever destination was set by loose_route() # in $du (destination URI). route(relay); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { # non loose-route, but stateful ACK; must be an ACK after # a 487 or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction -> # ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # record routing if (!is_method("REGISTER|MESSAGE")) record_route(); if (!uri == myself) { append_hf("P-hint: outbound\r\n"); route(relay); } if (is_method("INVITE") && !has_totag()) { create_dialog("Pp"); March 25, 2014, at 01:02 PM
by
- Changed lines 35-36 from:
[@ to:
[[<<]] %color=#ff7f00% Table: %black%'''Scenario init node examples''' ||border=1 || '''With Script Helper''' || '''Classic Script''' || ||[@ Changed lines 195-196 from:
@] to:
@]||[@ ####### Global Parameters ######### debug = 3 # log to syslog by default log_stderror = no log_facility = LOG_LOCAL0 fork = yes children = 5 tcp_children = 1 # comment the next line to enable the auto discovery of local aliases # based on reverse DNS on IPs auto_aliases = no listen = udp:192.168.2.133:5060 use_children 8 disable_tcp = no disable_tls = no exec_msg_threshold = 200000 ####### Modules Section ######## mpath = "/usr/local/lib/opensips/modules/" loadmodule "signaling.so" #### Stateless module loadmodule "sl.so" #### Transaction Module loadmodule "tm.so" modparam("tm", "fr_timeout", 10) modparam("tm", "fr_inv_timeout", 40) modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "disable_6xx_block", 1) modparam("tm", "onreply_avp_mode", 1) loadmodule "rr.so" modparam("rr", "append_fromtag", 0) loadmodule "maxfwd.so" loadmodule "sipmsgops.so" #### FIFO Management Interface loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") loadmodule "db_mysql.so" modparam("db_mysql", "exec_query_threshold", 200000) loadmodule "uri.so" modparam("uri", "use_uri_table", 0) loadmodule "dialog.so" modparam("dialog", "db_url", "mysql://opensips:XXXXXXXXX@192.168.2.133/opensips") modparam("dialog", "db_mode", 0) modparam("dialog", "default_timeout", 3600) modparam("dialog", "profiles_no_value", "inbound/s ; outbound/s ; shared/s") modparam("dialog", "ping_interval", 5) loadmodule "usrloc.so" modparam("usrloc", "nat_bflag", "NAT") modparam("usrloc", "db_mode", 1) modparam("usrloc", "db_url", "mysql://opensips:XXXXXXXXX@192.168.2.133/opensips") loadmodule "registrar.so" modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_FLAG") loadmodule "script_helper.so" modparam("script_helper", "sequential_route", "my_seq_route") modparam("script_helper", "use_dialog", 1) modparam("script_helper", "create_dialog_flags", "Pp") route [my_seq_route] { xlog("---- Sequential request handler ---- \n"); xlog("$rm | Call-ID: $ci | FT: $ft | TT: $tt\n"); } # main request routing logic route { $T_fr_timeout = 8; $T_fr_inv_timeout = 30; if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; } if (!uri == myself) { append_hf("P-hint: outbound\r\n"); route(relay); } if (is_method("PUBLISH|SUBSCRIBE")) { sl_send_reply("503", "Service Unavailable"); exit; } if (is_method("REGISTER")) { if (!save("location")) sl_reply_error(); exit; } if ($rU == NULL) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # do lookup with method filtering if (!lookup("location","")) { t_newtran(); t_reply("404", "Not Found"); exit; } route(1); } route [relay] { # for INVITEs enable some additional helper routes if (is_method("INVITE")) t_on_failure("failed_call"); if (!t_relay()) send_reply("500", "Internal Error"); exit; } failure_route [failed_call] { if (t_was_cancelled()) exit; if (next_branches()) { t_on_failure("1"); t_relay(); } } @]|| March 25, 2014, at 12:51 PM
by
- Changed line 19 from:
* dialog support to:
* dialog support (for sequential requests within a dialog, a complete dialog matching (Call-ID, From-tag, To-tag) will be attempted if the quick 'did'-based Record-Route parameter matching fails) March 25, 2014, at 12:48 PM
by
- Deleted line 12:
* record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Record-Route'' header) Added line 14:
* record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Record-Route'' header), after which the main route is triggered, just as before March 25, 2014, at 09:04 AM
by
- Changed line 13 from:
* record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Route'' header) to:
* record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Record-Route'' header) March 24, 2014, at 07:47 PM
by
- Changed line 8 from:
The purpose of this new module is to transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers a brief overview on the features of the new module. to:
The purpose of this new module is to transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers both a brief overview on the features of the new module and an example script. March 24, 2014, at 07:40 PM
by
- Changed line 94 from:
modparam("dialog", "db_url", "mysql://root:XXXXXXX@192.168.2.133/opensips") to:
modparam("dialog", "db_url", "mysql://opensips:XXXXXXXXX@192.168.2.133/opensips") Changed lines 103-104 from:
modparam("usrloc", "db_url", "mysql://root:XXXXXXX@192.168.2.133/opensips") to:
modparam("usrloc", "db_url", "mysql://opensips:XXXXXXXXX@192.168.2.133/opensips") Deleted line 106:
modparam("registrar", "attr_avp", "$avp(attr_avp)") March 24, 2014, at 07:38 PM
by
- Changed lines 29-30 from:
* initial and sequential SIP request routing (with script helper) * dialog support (with script helper) to:
* initial and sequential SIP request routing (using the script helper) * dialog support (using the script helper) March 24, 2014, at 07:38 PM
by
- Added lines 32-33:
\\ March 24, 2014, at 07:38 PM
by
- Added lines 27-31:
SIP logic provided: * initial and sequential SIP request routing (with script helper) * dialog support (with script helper) * also acts as a SIP registrar March 24, 2014, at 07:25 PM
by
- Changed lines 42-43 from:
/* comment the next line to enable the auto discovery of local aliases based on revers DNS on IPs */ to:
# comment the next line to enable the auto discovery of local aliases # based on reverse DNS on IPs March 24, 2014, at 07:24 PM
by
- Added lines 28-187:
[@ ####### Global Parameters ######### debug = 3 # log to syslog by default log_stderror = no log_facility = LOG_LOCAL0 fork = yes children = 5 tcp_children = 1 /* comment the next line to enable the auto discovery of local aliases based on revers DNS on IPs */ auto_aliases = no listen = udp:192.168.2.133:5060 use_children 8 disable_tcp = no disable_tls = no exec_msg_threshold = 200000 ####### Modules Section ######## mpath = "/usr/local/lib/opensips/modules/" loadmodule "signaling.so" #### Stateless module loadmodule "sl.so" #### Transaction Module loadmodule "tm.so" modparam("tm", "fr_timeout", 10) modparam("tm", "fr_inv_timeout", 40) modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "disable_6xx_block", 1) modparam("tm", "onreply_avp_mode", 1) loadmodule "rr.so" modparam("rr", "append_fromtag", 0) loadmodule "maxfwd.so" loadmodule "sipmsgops.so" #### FIFO Management Interface loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") loadmodule "db_mysql.so" modparam("db_mysql", "exec_query_threshold", 200000) loadmodule "uri.so" modparam("uri", "use_uri_table", 0) loadmodule "dialog.so" modparam("dialog", "db_url", "mysql://root:XXXXXXX@192.168.2.133/opensips") modparam("dialog", "db_mode", 0) modparam("dialog", "default_timeout", 3600) modparam("dialog", "profiles_no_value", "inbound/s ; outbound/s ; shared/s") modparam("dialog", "ping_interval", 5) loadmodule "usrloc.so" modparam("usrloc", "nat_bflag", "NAT") modparam("usrloc", "db_mode", 1) modparam("usrloc", "db_url", "mysql://root:XXXXXXX@192.168.2.133/opensips") loadmodule "registrar.so" modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_FLAG") modparam("registrar", "attr_avp", "$avp(attr_avp)") loadmodule "script_helper.so" modparam("script_helper", "sequential_route", "my_seq_route") modparam("script_helper", "use_dialog", 1) modparam("script_helper", "create_dialog_flags", "Pp") route [my_seq_route] { xlog("---- Sequential request handler ---- \n"); xlog("$rm | Call-ID: $ci | FT: $ft | TT: $tt\n"); } # main request routing logic route { $T_fr_timeout = 8; $T_fr_inv_timeout = 30; if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; } if (!uri == myself) { append_hf("P-hint: outbound\r\n"); route(relay); } if (is_method("PUBLISH|SUBSCRIBE")) { sl_send_reply("503", "Service Unavailable"); exit; } if (is_method("REGISTER")) { if (!save("location")) sl_reply_error(); exit; } if ($rU == NULL) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # do lookup with method filtering if (!lookup("location","")) { t_newtran(); t_reply("404", "Not Found"); exit; } route(1); } route [relay] { # for INVITEs enable some additional helper routes if (is_method("INVITE")) t_on_failure("failed_call"); if (!t_relay()) send_reply("500", "Internal Error"); exit; } failure_route [failed_call] { if (t_was_cancelled()) exit; if (next_branches()) { t_on_failure("1"); t_relay(); } } @] March 24, 2014, at 06:31 PM
by
- Added lines 1-27:
!!!!! Documentation -> [[Documentation.Tutorials | Tutorials ]] -> Using the [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html | {+Script Helper+} ]] module This page has been visited {$PageCount} times. (:toc-float Table of Content:) ---- !!!! Tutorial Overview The purpose of this new module is to transparently handle a lot of "standard" SIP scripting logic, in order to both save script coding time and mitigate potential SIP scripting errors. This tutorial offers a brief overview on the features of the new module. !!!! Current features As stated in the [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html | documentation ]], the default features are: * record-routing for initial SIP requests (i.e. OpenSIPS adds itself in the signaling path using a ''Route'' header) * transparent handling for sequential requests (they will not hit the script at all anymore!) \\ Optionally, through a series of [[ http://www.opensips.org/html/docs/modules/1.12.x/script_helper.html#id249114 | module parameters ]], the script writer may include some additional logic: * dialog support * a special route to be run before all sequential requests are routed out \\ Future directions for the module include adding authentication and NAT support. !!!! Example script |