Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####### Global Parameters #########
- debug=3
- log_stderror=no
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- port=5060
- /* uncomment and configure the following line if you want opensips to
- bind on a specific interface/port/proto (default bind on all available) */
- #listen=udp:192.168.1.2:5060
- listen=udp:example.com
- ####### Modules Section ########
- #set module path
- mpath="/usr/lib/opensips/modules/"
- /* uncomment next line for MySQL DB support */
- loadmodule "db_mysql.so"
- loadmodule "signaling.so"
- loadmodule "sl.so"
- loadmodule "tm.so"
- loadmodule "rr.so"
- loadmodule "maxfwd.so"
- loadmodule "usrloc.so"
- loadmodule "dialog.so"
- loadmodule "registrar.so"
- loadmodule "textops.so"
- loadmodule "mi_fifo.so"
- loadmodule "uri.so"
- loadmodule "acc.so"
- loadmodule "aaa_radius.so"
- loadmodule "call_control.so"
- loadmodule "mi_datagram.so"
- loadmodule "auth.so"
- loadmodule "auth_db.so"
- # ----------------- setting module-specific parameters ---------------
- # ----- mi_fifo params -----
- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
- modparam("mi_datagram", "socket_name", "/tmp/opensips.sock")
- modparam("mi_datagram", "children_count", 10)
- modparam("mi_datagram", "unix_socket_mode", 0600)
- # ----- rr params -----
- # add value to ;lr param to cope with most of the UAs
- modparam("rr", "enable_full_lr", 1)
- # do not append from tag to the RR (no need for this script)
- modparam("rr", "append_fromtag", 0)
- # ----- registrar params -----
- /* uncomment the next line not to allow more than 10 contacts per AOR */
- #modparam("registrar", "max_contacts", 10)
- # ----- usrloc params -----
- #modparam("usrloc", "db_mode", 0)
- /* uncomment the following lines if you want to enable DB persistency
- for location entries */
- modparam("usrloc", "db_mode", 2)
- modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- # ----- uri params -----
- modparam("uri", "use_uri_table", 0)
- # ----- acc params -----
- #############CDRTool##############
- modparam("aaa_radius", "radius_config", "/etc/radiusclient-ng/radiusclient.conf")
- modparam("acc", "aaa_url", "radius:/etc/radiusclient-ng/radiusclient.conf")
- modparam("acc", "aaa_flag", 1)
- modparam("acc", "aaa_extra", "User-Name=$Au; \
- Calling-Station-Id=$from; \
- Called-Station-Id=$to; \
- Sip-Translated-Request-URI=$ru; \
- Canonical-URI=$avp(s:can_uri); \
- Billing-Party=$avp(s:billing_party); \
- Divert-Reason=$avp(s:divert_reason); \
- User-Agent=$hdr(user-agent); \
- Contact=$hdr(contact); \
- Event=$hdr(event); \
- ENUM-TLD=$avp(s:enum_tld); \
- From-Header=$hdr(from); \
- SIP-Application-Type=$avp(s:sip_application_type)")
- # ----- auth_db params -----
- /* uncomment the following lines if you want to enable the DB based
- authentication */
- modparam("auth_db", "calculate_ha1", yes)
- modparam("auth_db", "password_column", "password")
- modparam("auth_db", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
- modparam("auth_db", "load_credentials", "")
- ####### Routing Logic ########
- # main request routing logic
- route{
- if (!mf_process_maxfwd_header("10")) {
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- if (is_method("BYE")) {
- setflag(1); # do accounting ...
- } else 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(1);
- } else {
- /* uncomment the following lines if you want to enable presence */
- ##if (is_method("SUBSCRIBE") && $rd == "your.server.ip.address") {
- ## # in-dialog subscribe requests
- ## route(2);
- ## exit;
- ##}
- 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;
- }
- #initial requests
- if ((method=="INVITE" && !has_totag())) {
- create_dialog();
- setflag(1);
- $avp(s:can_uri) = $ru;
- $avp(s:billing_party) = $Au;
- $avp(s:sip_application_type) = "audio";
- $avp(s:enum_tld) = "E164";
- # you need to call this function at the first INVITE
- call_control();
- switch ($retcode) {
- case 2:
- # Call with no limit
- case 1:
- # Call with a limit under callcontrol management (either prepaid
- # or postpaid)
- break;
- case -1:
- # Not enough credit (prepaid call)
- xlog("L_INFO", "Call control: not enough credit for prepaid call\n");
- sl_send_reply("402", "Not enough credit");
- exit;
- break;
- case -2:
- # Locked by call in progress (prepaid call)
- xlog("L_INFO", "Call control: prepaid call locked by another call in progress\n");
- sl_send_reply("403", "Call locked by another call in progress");
- exit;
- break;
- default:
- # Internal error (message parsing, communication, ...)
- xlog("L_INFO", "Call control: internal server error\n");
- sl_send_reply("500", "Internal server error");
- exit;
- }
- }
- # CANCEL processing
- if (is_method("CANCEL"))
- {
- if (t_check_trans())
- t_relay();
- exit;
- }
- t_check_trans();
- # authenticate if from local subscriber (uncomment to enable auth)
- # authenticate all initial non-REGISTER request that pretend to be
- # generated by local subscriber (domain from FROM URI is local)
- ##if (!(method=="REGISTER") && from_uri==myself) /*no multidomain version*/
- ##if (!(method=="REGISTER") && is_from_local()) /*multidomain version*/
- ##{
- ## if (!proxy_authorize("", "subscriber")) {
- ## proxy_challenge("", "0");
- ## exit;
- ## }
- ## if (!db_check_from()) {
- ## sl_send_reply("403","Forbidden auth ID");
- ## exit;
- ## }
- ##
- ## consume_credentials();
- ## # caller authenticated
- ##}
- # preloaded route checking
- if (loose_route()) {
- xlog("L_ERR",
- "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
- if (!is_method("ACK"))
- sl_send_reply("403","Preload Route denied");
- exit;
- }
- # record routing
- if (!is_method("REGISTER|MESSAGE"))
- record_route();
- if (!uri==myself)
- {
- append_hf("P-hint: outbound\r\n");
- route(1);
- }
- # requests for my domain
- if (is_method("PUBLISH"))
- {
- sl_send_reply("503", "Service Unavailable");
- exit;
- }
- if (is_method("REGISTER"))
- {
- # authenticate the REGISTER requests (uncomment to enable auth)
- if (!www_authorize("", "subscriber"))
- {
- www_challenge("", "0");
- exit;
- }
- if (!db_check_to())
- {
- sl_send_reply("403","Forbidden auth ID");
- exit;
- }
- 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","m")) {
- switch ($retcode) {
- case -1:
- case -3:
- t_newtran();
- t_reply("404", "Not Found");
- exit;
- case -2:
- sl_send_reply("405", "Method Not Allowed");
- exit;
- }
- }
- route(1);
- }
- route[1] {
- # for INVITEs enable some additional helper routes
- if (is_method("INVITE")) {
- t_on_branch("2");
- t_on_reply("2");
- t_on_failure("1");
- }
- if (!t_relay()) {
- sl_reply_error();
- };
- exit;
- }
- branch_route[2] {
- xlog("new branch at $ru\n");
- }
- onreply_route[2] {
- xlog("incoming reply\n");
- }
- failure_route[1] {
- if (t_was_cancelled()) {
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement