# # OpenSIPS residential configuration script # by OpenSIPS Solutions # # This script was generated via "make menuconfig", from # the "Residential" scenario. # You can enable / disable more features / functionalities by # re-generating the scenario with different options.# # # Please refer to the Core CookBook at: # https://opensips.org/Resources/DocsCookbooks # for a explanation of possible statements, functions and parameters. # ####### Global Parameters ######### /* uncomment the following lines to enable debugging */ #debug_mode=yes log_level=1 xlog_level=1 log_stderror=yes log_facility=LOG_LOCAL0 udp_workers=8 /* uncomment the next line to enable the auto temporary blacklisting of not available destinations (default disabled) */ #disable_dns_blacklist=no /* uncomment the next line to enable IPv6 lookup after IPv4 dns lookup failures (default disabled) */ #dns_try_ipv6=yes socket=udp:10.0.0.10:5060 # CUSTOMIZE ME ####### Modules Section ######## #set module path mpath="modules/" #### SIGNALING module loadmodule "signaling.so" #### StateLess module loadmodule "sl.so" #### Transaction Module loadmodule "tm.so" modparam("tm", "fr_timeout", 5) modparam("tm", "fr_inv_timeout", 30) modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "onreply_avp_mode", 1) #### Record Route Module loadmodule "rr.so" /* do not append from tag to the RR (no need for this script) */ modparam("rr", "append_fromtag", 0) #### MAX ForWarD module loadmodule "maxfwd.so" #### SIP MSG OPerationS module loadmodule "sipmsgops.so" loadmodule "b2b_entities.so" modparam("b2b_entities", "server_hsize", 16) modparam("b2b_entities", "client_hsize", 16) ##modparam("b2b_entities", "script_req_route", "niso_request_entities") modparam("b2b_entities", "db_mode", 0) loadmodule "b2b_logic.so" #modparam("b2b_logic", "use_init_sdp", 1) modparam("b2b_logic", "hash_size", 12) #modparam("b2b_logic", "custom_headers_regexp", "/^X-/") #modparam("b2b_logic", "custom_headers", "Privacy;P-Asserted-Identity;Diversion;P-Early-Media;Reason;Date;Identity") #modparam("b2b_logic", "b2bl_from_spec_param", "$var(b2bl_from)") #modparam("b2b_logic", "init_callid_hdr", "X-uuid") modparam("b2b_logic", "server_address", "sip:uas@127.0.0.1:5060") modparam("b2b_logic", "db_mode", 0) modparam("b2b_logic", "script_req_route", "b2bl_request") #modparam("b2b_logic", "script_reply_route", "niso_reply") modparam("b2b_logic", "cleanup_period", 10) #### FIFO Management Interface loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") modparam("mi_fifo", "fifo_mode", 0666) #### USeR LOCation module loadmodule "usrloc.so" modparam("usrloc", "nat_bflag", "NAT") modparam("usrloc", "working_mode_preset", "single-instance-no-db") #### REGISTRAR module loadmodule "registrar.so" modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT") /* uncomment the next line not to allow more than 10 contacts per AOR */ #modparam("registrar", "max_contacts", 10) #### ACCounting module loadmodule "acc.so" /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_cancels", 0) /* by default we do not adjust the direct of the sequential requests. if you enable this parameter, be sure to enable "append_fromtag" in "rr" module */ modparam("acc", "detect_direction", 0) loadmodule "proto_udp.so" ####### Routing Logic ######## # main request routing logic route { if (has_totag()) $var(mid_dlg) = "mid-dialog"; else $var(mid_dlg) = "initial"; xlog("L_INFO", "[$ci] $rm ($var(mid_dlg)) in script ...\n"); if (is_method("INVITE") && !has_totag()) { # choose an initial state and save it in context $b2b_logic.ctx(state) = "1"; # save the original destination in context $b2b_logic.ctx(operator_uri) = $ru; # create the server entity b2b_server_new("customer"); # create the initial client entity, to connect the customer to the media server b2b_client_new("media", "sip:10.0.0.11:7060"); # initialize B2B session for the "marketing" scenario b2b_init_request("marketing"); exit; } xlog("L_INFO", "[$ci] $rm (script ended)\n"); } route [b2bl_request] { xlog("L_INFO", "[$ci] B2B request!! ($rm)\n"); if ($rm != "BYE" || $b2b_logic.ctx(state) == "2" || $b2b_logic.entity(id) != "media") { # for requests other than REFER, no special actions needs to be done, # just pass the request to the peer # same for BYE requests for which no special scenario action is required b2b_pass_request(); exit; } # we are in the initial state (customer connected to media server) # and the BYE is from the media server -> connect the customer with the operator # end dialog with the media server b2b_send_reply(200, "OK"); b2b_delete_entity(); # create the client entity corresponding to the operator, # take the URI of the destination from the context b2b_client_new("operator", $b2b_logic.ctx(operator_uri)); # trigger the bridging action b2b_bridge("customer", "operator"); # save the next state in context $b2b_logic.ctx(state) = "2"; }