浏览代码

cfg: example configs migrated to sip-router

Ported ser example configs to sip-router:
- updated module path (now using loadpath)
- changed mysql module name to db_mysql
- replaced max_len in msg:len comparisons with 4096
- updated avp and selects non-empty checks:
  if($v)  -> if ($v!="")
  if(!$v) -> if (strempty($v)) or if ($v=="")
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
ec8e49e8b6
共有 3 个文件被更改,包括 88 次插入79 次删除
  1. 14 10
      etc/ser-basic.cfg
  2. 31 29
      etc/ser-oob.cfg
  3. 43 40
      etc/ser.cfg

+ 14 - 10
etc/ser-basic.cfg

@@ -8,7 +8,7 @@
 
 # ----------- global configuration parameters ------------------------
 
-debug=3         # debug level (cmd line: -dddddddddd)
+debug=2         # debug level (cmd line: -dddddddddd)
 #memdbg=10 # memory debug message level
 #memlog=10 # memory statistics log level
 #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
@@ -35,14 +35,18 @@ rev_dns=no      # (cmd. line: -R)
 
 # ------------------ module loading ----------------------------------
 
-loadmodule "/usr/local/lib/ser/modules/sl.so"
-loadmodule "/usr/local/lib/ser/modules/tm.so"
-loadmodule "/usr/local/lib/ser/modules/rr.so"
-loadmodule "/usr/local/lib/ser/modules/textops.so"
-loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
-loadmodule "/usr/local/lib/ser/modules/usrloc.so"
-loadmodule "/usr/local/lib/ser/modules/registrar.so"
-loadmodule "/usr/local/lib/ser/modules/ctl.so"
+#loadpath "modules:modules_s"
+loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
+
+loadmodule "sl"
+loadmodule "tm"
+loadmodule "rr"
+loadmodule "textops"
+loadmodule "maxfwd"
+loadmodule "usrloc"
+loadmodule "registrar"
+loadmodule "ctl"
+loadmodule "cfg_rpc"
 
 # ----------------- setting module-specific parameters ---------------
 
@@ -75,7 +79,7 @@ route{
 		sl_reply("483","Too Many Hops");
 		break;
 	}
-	if (msg:len >=  max_len ) {
+	if (msg:len >=  4096 ) {
 		sl_reply("513", "Message too big");
 		break;
 	}

+ 31 - 29
etc/ser-oob.cfg

@@ -254,10 +254,11 @@ rtp_proxy.enabled = "detect" desc "indicates whether the RTP Proxy is enabled or
 
 # ------------------ Module Loading -----------------------------------------
 
-loadpath "/usr/lib/ser/modules"
+#loadpath "modules:modules_s"
+loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
 
 # load a SQL database for authentication, domains, user AVPs etc.
-loadmodule "mysql"
+loadmodule "db_mysql"
 #loadmodule "postgres"
 
 loadmodule "sl"
@@ -601,7 +602,7 @@ route[FORWARD]
 	# If this is an initial INVITE (without a To-tag) we might try
 	# another target (call forwarding or voicemail) after receiving
 	# an error.
-	if (method=="INVITE" && [email protected]) {
+	if (method=="INVITE" && strempty(@to.tag)) {
 		t_on_failure("FAILURE_ROUTE");
 	}
 
@@ -652,7 +653,7 @@ route[INIT]
 	}
 
 	# Set flag for use in the onsend route
-	if (@to.tag) {
+	if (@to.tag != "") {
 		setflag(FLAG_TOTAG);
 	}
 
@@ -661,7 +662,7 @@ route[INIT]
 
 	# Activate accounting for all initial INVITEs. In-dialog requests
 	# are accounted by a RR cookie (see below).
-	if (method == "INVITE" && [email protected]) {
+	if (method == "INVITE" && strempty(@to.tag)) {
 		setflag(FLAG_ACC);
 	}
 
@@ -679,7 +680,8 @@ route[OPTIONS_REPLY]
 	# OPTIONS requests without a username in the Request-URI but one
 	# of our domains or IPs are addressed to the proxy itself and
 	# can be answered statelessly.
-	if (method == "OPTIONS" && [email protected] && (uri == myself || $t.did))
+	if (method == "OPTIONS" && strempty(@ruri.user) &&
+		(uri == myself || $t.did != ""))
 	{
 		options_reply();
 		drop;
@@ -711,7 +713,7 @@ route[NAT_DETECTION]
 	# would be to store the original information as a contact parameter
 	# and restore it on its way back.
 	if (nat_uac_test("19")
-	    || (@hf_value["contact"] && @contact.uri.params.maddr))
+	    || (@hf_value["contact"] != "" && @contact.uri.params.maddr != ""))
 	{
 		setflag(FLAG_NAT);
 		$uac_nat = 1;
@@ -756,7 +758,7 @@ route[RTPPROXY]
 	}
 
 	# Turn the RTP proxy on for INVITEs and UPDATEs.
-	if (((method=="INVITE" || method == "UPDATE") && @msg.body)
+	if (((method=="INVITE" || method == "UPDATE") && @msg.body != "")
 	    && !isflagset(FLAG_RTP_PROXY))
 	{
 		force_rtp_proxy('r');
@@ -795,7 +797,7 @@ route[LOOSE_ROUTE]
 		}
 
 		# Restore Session Timer flag and headers.
-		if ($stimer && ($stimer != "0")) {
+		if ( defined $stimer && ($stimer != "0")) {
 			route(SESSION_TIMER);
 		}
 
@@ -871,7 +873,7 @@ route[DOMAIN_POLICY]
 	# destination (a@A calls b@B who forwards to c@C. A BYE by c@C is
 	# then From b@B and To a@A. There is no mentioning of c@C despite
 	# legitimate behaviour of c@C).
-	if (!isflagset(FLAG_TOTAG) && !$t.did && !$f.did) {
+	if (!isflagset(FLAG_TOTAG) && strempty($t.did) && strempty($f.did)) {
 		sl_reply("403", "Relaying Forbidden");
 		drop;
 	}
@@ -926,7 +928,7 @@ route[REGISTRAR]
 	}
 
 	# Check if the REGISTER if for one of our local domains.
-	if (!$t.did) {
+	if (strempty($t.did)) {
 		sl_reply("403", "Register Forwarding Forbidden");
 		drop;
 	}
@@ -951,7 +953,7 @@ route[REGISTRAR]
 			sl_reply("400", "Bad Request");
 		}
 		else {
-			if ($digest_challenge) {
+			if ($digest_challenge != "") {
 				append_to_reply("%$digest_challenge");
 			}
 			sl_reply("401", "Unauthorized");
@@ -1034,7 +1036,7 @@ route[AUTHENTICATION]
 
 	# Requests from non-local to local domains should be permitted.
 	# Remove this if you want a walled garden.
-	if (!$f.did) {
+	if (strempty($f.did)) {
 		break;
 	}
 
@@ -1086,7 +1088,7 @@ route[OUTBOUND]
 	# If a local user calls to a foreign domain we play outbound
 	# proxy for them.
 	# Comment this out if you want a walled garden.
-	if ($f.did && !$t.did) {
+	if ($f.did != "" && strempty($t.did)) {
 		append_hf("P-hint: outbound\r\n");
 		route(FORWARD);
 	}
@@ -1099,7 +1101,7 @@ route[SPEEDDIAL]
 {
 	# If the caller is local and uses two digits only, we redirect the
 	# UA to the real target.
-	if ($fd.did && uri =~ "sip:[0-9][0-9]@") {
+	if ($fd.did != "" && uri =~ "sip:[0-9][0-9]@") {
 		if (sd_lookup("speed_dial")) {
 			sl_reply("302", "Speed Dial Redirect");
 		}
@@ -1133,7 +1135,7 @@ route[INBOUND]
 	# Check for call forwarding of the callee.
 	# Note: The forwarding target has to be full routable URI
 	#       in this example.
-	if ($tu.fwd_always_target) {
+	if ($tu.fwd_always_target != "") {
 		attr2uri("$tu.fwd_always_target");
 
 		# If we are forwarding to ourselves, don't remove
@@ -1143,7 +1145,7 @@ route[INBOUND]
 		# still be problematic -- credentials are already
 		# removed when we forward. Consider using a 3xx.
 		lookup_domain("$td", "@ruri.host");
-		if ($t.did) {
+		if ($t.did != "") {
 			setflag(FLAG_DONT_RM_CRED);
 		}
 		route(FORWARD);
@@ -1193,13 +1195,13 @@ route[PSTN]
 {
 	# Check some conditions first:
 	# PSTN is available for our own users only.
-	if (!$f.did) {
+	if (strempty($f.did)) {
 		break;
 	}
 
 	# If the attribute $gw_ip isn't set, there is no PSTN service
 	# active.
-	if (!$gw_ip) {
+	if (!defined $gw_ip) {
 		break;
 	}
 
@@ -1213,8 +1215,8 @@ route[PSTN]
 	# format that is accepted by your gateway here.
 
 	# Check permissions of the caller for initial INVITEs.
-	if (method == "INVITE" && [email protected]) {
-		if (!$f.gw_acl == "1") {
+	if (method == "INVITE" && strempty(@to.tag)) {
+		if ($f.gw_acl != "1") {
 			sl_reply("403", "PSTN Not Permitted");
 			drop;
 		}
@@ -1224,7 +1226,7 @@ route[PSTN]
 	# Remote-Party-ID header.
 	# Depending on your gateway, you may have to add a
 	# P-Asserted-Identity header here instead.
-	if ($asserted_id) {
+	if (defined $asserted_id) {
 		xlset_attr("$rpidheader",
 			"<sip:%$asserted_id@%@ruri.host>;screen=yes");
 		replace_attr_hf("Remote-Party-ID", "$rpidheader");
@@ -1267,7 +1269,7 @@ route[CATCH_CANCEL]
 route[SITE_SPECIFIC]
 {
 	# This is only relevant for requests for one of our domains.
-	if (!$t.did) {
+	if (strempty($t.did)) {
 		break;
 	}
 
@@ -1291,7 +1293,7 @@ route[SESSION_TIMER]
 	}
 
 	# Let's check if the Session-Expires header is already present.
-	if (@hf_value.session_expires) {
+	if (@hf_value.session_expires != "") {
 		# Compare the Session-Expires header value with the
 		# configured Min-SE.
 		eval_push("x:%@hf_value.session_expires.uri");
@@ -1377,7 +1379,7 @@ failure_route[FAILURE_ROUTE]
 		# credentials (if we consumed them, they may be missing in
 		# a loop, if we don't consume them, messages are bigger and
 		# more vulnerable)
-		if ($tu.fwd_busy_target) {
+		if ($tu.fwd_busy_target != "") {
 			#attr2uri("$tu.fwd_busy_target");
 			#route(FORWARD);
 			attr_destination("$tu.fwd_busy_target");
@@ -1390,7 +1392,7 @@ failure_route[FAILURE_ROUTE]
 		# If we received no answer and the noanswer target is set,
 		# forward it there.
 		# Note: See above.
-		if ($tu.fwd_noanswer_target) {
+		if ($tu.fwd_noanswer_target != "") {
 			#attr2uri("$tu.fwd_noanswer_target");
 			#route(FORWARD);
 			attr_destination("$tu.fwd_noanswer_target");
@@ -1409,7 +1411,7 @@ onreply_route[REPLY_ROUTE]
 	# Do the same if the contact is maddred. See the notes in route
 	# [NAT_DETECTION] for more information.
 	if (nat_uac_test("1") ||
-	    (@hf_value["contact"] && @contact.uri.params.maddr))
+	    (@hf_value["contact"] != "" && @contact.uri.params.maddr != ""))
 	{
 		fix_nated_contact();
 	}
@@ -1418,7 +1420,7 @@ onreply_route[REPLY_ROUTE]
 	# body, inform RTP proxy.
 	if (isflagset(FLAG_RTP_PROXY)
 	    && status=~"(18[03])|(2[0-9][0-9])"
-	    && @msg.body)
+	    && @msg.body != "")
 	{
 		force_rtp_proxy('r');
 	}
@@ -1426,7 +1428,7 @@ onreply_route[REPLY_ROUTE]
 	# Let's check for session timer support.
 	if (isflagset(FLAG_SESSIONTIMER) && status =~ "2[0-9][0-9]") {
 		# The UAC wanted to have a session timer.
-		if (!@hf_value.session_expires) {
+		if (strempty(@hf_value.session_expires)) {
 			# But the UAS does not support it, so we will try
 			# to convince the UAC to do it.
 			append_hf_value("Session-Expires",

+ 43 - 40
etc/ser.cfg

@@ -24,7 +24,7 @@
 
 # ----------- global configuration parameters ------------------------
 
-debug=3         # debug level (cmd line: -dddddddddd)
+debug=2         # debug level (cmd line: -dddddddddd)
 #memdbg=10 # memory debug log level
 #memlog=10 # memory statistics log level
 #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
@@ -52,29 +52,32 @@ enable_tls=yes
 
 # ------------------ module loading ----------------------------------
 
+#loadpath "modules:modules_s"
+loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
+
 # load a SQL database for authentication, domains, user AVPs etc.
-loadmodule "/usr/local/lib/ser/modules/mysql.so"
-
-loadmodule "/usr/local/lib/ser/modules/sl.so"
-loadmodule "/usr/local/lib/ser/modules/tm.so"
-loadmodule "/usr/local/lib/ser/modules/rr.so"
-loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
-loadmodule "/usr/local/lib/ser/modules/usrloc.so"
-loadmodule "/usr/local/lib/ser/modules/registrar.so"
-loadmodule "/usr/local/lib/ser/modules/xlog.so"
-loadmodule "/usr/local/lib/ser/modules/textops.so"
-loadmodule "/usr/local/lib/ser/modules/ctl.so"
-loadmodule "/usr/local/lib/ser/modules/fifo.so"
-loadmodule "/usr/local/lib/ser/modules/auth.so"
-loadmodule "/usr/local/lib/ser/modules/auth_db.so"
-loadmodule "/usr/local/lib/ser/modules/gflags.so"
-loadmodule "/usr/local/lib/ser/modules/domain.so"
-loadmodule "/usr/local/lib/ser/modules/uri_db.so"
-loadmodule "/usr/local/lib/ser/modules/avp.so"
-loadmodule "/usr/local/lib/ser/modules/avp_db.so"
-loadmodule "/usr/local/lib/ser/modules/acc_db.so"
-loadmodule "/usr/local/lib/ser/modules/xmlrpc.so"
-#loadmodule "/usr/local/lib/ser/modules/tls.so"
+loadmodule "db_mysql"
+
+loadmodule "sl"
+loadmodule "tm"
+loadmodule "rr"
+loadmodule "maxfwd"
+loadmodule "usrloc"
+loadmodule "registrar"
+loadmodule "xlog"
+loadmodule "textops"
+loadmodule "ctl"
+loadmodule "cfg_rpc"
+loadmodule "auth"
+loadmodule "auth_db"
+loadmodule "gflags"
+loadmodule "domain"
+loadmodule "uri_db"
+loadmodule "avp"
+loadmodule "avp_db"
+loadmodule "acc_db"
+loadmodule "xmlrpc"
+#loadmodule "tls"
 
 # ----------------- setting script FLAGS -----------------------------
 flags
@@ -200,7 +203,7 @@ route[FORWARD]
 
 	# if this is an initial INVITE (without a To-tag) we might try another
 	# (forwarding or voicemail) target after receiving an error
-	if (method=="INVITE" && [email protected]) {
+	if (method=="INVITE" && strempty(@to.tag)) {
 		t_on_failure("FAILURE_ROUTE");
 	}
 
@@ -221,7 +224,7 @@ route[INIT]
 		drop;
 	}
 
-	if (msg:len >=  max_len ) {
+	if (msg:len >=  4096 ) {
 		sl_reply("513", "Message too big");
 		drop;
 	}
@@ -232,7 +235,7 @@ route[INIT]
 
 	# lets account all initial INVITEs
 	# further in-dialog requests are accounted by a RR cookie (see below)
-	if (method=="INVITE" && [email protected]) {
+	if (method=="INVITE" && strempty(@to.tag)) {
 		setflag(FLAG_ACC);
 	}
 }
@@ -308,7 +311,7 @@ route[DOMAIN]
 	# we dont know the domain of the caller and also not
 	# the domain of the callee -> somone uses our proxy as
 	# a relay
-	if (!$t.did && !$f.did) {
+	if (strempty($t.did) && strempty($f.did)) {
 		sl_reply("403", "Relaying Forbidden");
 		drop;
 	}
@@ -319,7 +322,7 @@ route[REGISTRAR]
 	# if the request is a REGISTER lets take care of it
 	if (method=="REGISTER") {
 		# check if the REGISTER if for one of our local domains
-		if (!$t.did) {
+		if (strempty($t.did)) {
 			sl_reply("403", "Register forwarding forbidden");
 			drop;
 		}
@@ -331,7 +334,7 @@ route[REGISTRAR]
 			} else if ($? == -3) {
 				sl_reply("400", "Bad Request");
 			} else {
-				if ($digest_challenge) {
+				if ($digest_challenge != "") {
 					append_to_reply("%$digest_challenge");
 				}
 				sl_reply("401", "Unauthorized");
@@ -379,7 +382,7 @@ route[AUTHENTICATION]
 
 	# requests from non-local to local domains should be permitted
 	# remove this if you want a walled garden
-	if (! $f.did) {
+	if (strempty($f.did)) {
 		break;
 	}
 
@@ -397,7 +400,7 @@ route[AUTHENTICATION]
 		} else if ($? == -3) {
 			sl_reply("400", "Bad Request");
 		} else {
-			if ($digest_challenge) {
+			if ($digest_challenge != "") {
 				append_to_reply("%$digest_challenge");
 			}
 			sl_reply("407", "Proxy Authentication Required");
@@ -422,7 +425,7 @@ route[OUTBOUND]
 {
 	# if a local user calls to a foreign domain we play outbound proxy for him
 	# comment this out if you want a walled garden
-	if ($f.did && ! $t.did) {
+	if ($f.did != ""  && $t.did == "") {
 		append_hf("P-hint: outbound\r\n");
 		route(FORWARD);
 	}
@@ -438,7 +441,7 @@ route[INBOUND]
 
 		# if you want to know if the callee username was an alias
 		# check it like this
-		#if (! $tu.uri_canonical) {
+		#if (strempty($tu.uri_canonical)) {
 			# if the alias URI has different AVPs/preferences
 			# you can load them into the URI track like this
 			#load_attrs("$tr", "@ruri");
@@ -447,7 +450,7 @@ route[INBOUND]
 		# check for call forwarding of the callee
 		# Note: the forwarding target has to be full routable URI
 		#       in this example
-		if ($tu.fwd_always_target) {
+		if ($tu.fwd_always_target != "") {
 			attr2uri("$tu.fwd_always_target");
 			route(FORWARD);
 		}
@@ -461,8 +464,8 @@ route[INBOUND]
 			# Note1: timer values have to be in ms now!
 			# Note2: this makes even more sense if you switch to a voicemail
 			#        from the FAILURE_ROUTE below
-			if ($t.fr_inv_timer) {
-				if ($t.fr_timer) {
+			if ($t.fr_inv_timer != 0) {
+				if ($t.fr_timer != 0) {
 					t_set_fr("$t.fr_inv_timer", "$t.fr_timer");
 				} else {
 					t_set_fr("$t.fr_inv_timer");
@@ -484,13 +487,13 @@ route[PSTN]
 	# Only users from a local domain are permitted to make calls.
 	# Additionally you might want to check the acl AVP to verify
 	# that the user is allowed to make such expensives calls.
-	if ($f.did && $gw_ip &&
+	if ($f.did != "" && $gw_ip != "" &&
 		uri=~"sips?:\+?[0-9]{3,18}@.*") {
 		# probably you need to convert the number in the request
 		# URI according to the requirements of your gateway here
 
 		# if an AVP 'asserted_id' is set we insert an RPID header
-		if ($asserted_id) {
+		if ($asserted_id != "") {
 			xlset_attr("$rpidheader", "<sip:%$asserted_id@%@ruri.host>;screen=yes");
 			replace_attr_hf("Remote-Party-ID", "$rpidheader");
 		}
@@ -527,7 +530,7 @@ failure_route[FAILURE_ROUTE]
 	if (t_check_status("486|600")) {
 		# if we received a busy and a busy target is set, forward it there
 		# Note: again the forwarding target has to be a routeable URI
-		if ($tu.fwd_busy_target) {
+		if ($tu.fwd_busy_target != "") {
 			attr2uri("$tu.fwd_busy_target");
 			route(FORWARD);
 		}
@@ -537,7 +540,7 @@ failure_route[FAILURE_ROUTE]
 		# if we received no answer and the noanswer target is set,
 		# forward it there
 		# Note: again the target has to be a routeable URI
-		if ($tu.fwd_noanswer_target) {
+		if ($tu.fwd_noanswer_target != "") {
 			attr2uri("$tu.fwd_noanswer_target");
 			route(FORWARD);
 		}