فهرست منبع

scripts moved to examples

Jiri Kuthan 23 سال پیش
والد
کامیت
468bf60bbe
4فایلهای تغییر یافته به همراه255 افزوده شده و 0 حذف شده
  1. 59 0
      examples/exec.cfg
  2. 72 0
      examples/onr.cfg
  3. 43 0
      examples/redirect.cfg
  4. 81 0
      examples/uas.cfg

+ 59 - 0
examples/exec.cfg

@@ -0,0 +1,59 @@
+#
+# $Id$
+#
+# this example shows use of ser as stateless redirect server
+# which rewrites URIs using an exernal utility
+#
+
+# ----------- global configuration parameters ------------------------
+
+debug=4
+fork=1
+log_stderror=yes	# (cmd line: -E)
+check_via=no # (cmd. line: -v)
+dns=no # (cmd. line: -r)
+syn_branch=1
+reply_to_via=0
+
+# advertise IP address in Via (as opposed to advertising DNS name
+# which is annoying for downstream servers and some phones can
+# not handle DNS at all)
+listen=195.37.77.100
+
+# ------------------ module loading ----------------------------------
+
+loadmodule "../sip_router/modules/sl/sl.so"
+loadmodule "../sip_router/modules/print/print.so"
+loadmodule "../sip_router/modules/exec/exec_mod.so"
+loadmodule "../sip_router/modules/ext/ext.so"
+
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+	# for testing purposes, simply okay all REGISTERs
+	if (method=="REGISTER") {
+		log("REGISTER");
+		sl_send_reply("200", "ok");
+		break;
+	};
+
+	# obsoleted
+	#ext_rewriteuri("echo sip:[email protected]; echo >/dev/null");
+	#break;
+
+	# first dump the message to a file using cat command
+	exec_msg("printenv SRCIP > /tmp/exectest.txt; cat >> /tmp/exectest.txt");
+	# and then rewrite URI using external utility
+	# note that the last echo command trashes input parameter
+	if (exec_uri("echo sip:[email protected];echo sip:[email protected];echo>/dev/null")) {
+
+	#if (exec_uri("/tmp/sh.sh")) {
+		sl_send_reply("300", "Redirect");
+	} else {
+		sl_reply_error();
+		log(1, "alas, rewriting failed\n");
+	};
+}
+

+ 72 - 0
examples/onr.cfg

@@ -0,0 +1,72 @@
+#
+# $Id$
+#
+# example script showing both types of forking;
+# incoming message is foked in parallel to
+# 'nobody' and 'parallel', if no positive reply
+# appears with final_response timer, nonsense
+# is retried (serial forking); than, destination
+# 'foo' is given last chance
+
+# ----------- global configuration parameters ------------------------
+
+debug=3
+fork=no
+log_stderror=yes	# (cmd line: -E)
+check_via=no # (cmd. line: -v)
+dns=no # (cmd. line: -r)
+syn_branch=1
+reply_to_via=0
+
+# advertise IP address in Via (as opposed to advertising DNS name
+# which is annoying for downstream servers and some phones can
+# not handle DNS at all)
+listen=195.37.77.100
+
+# ------------------ module loading ----------------------------------
+
+loadmodule "../sip_router/modules/sl/sl.so"
+loadmodule "../sip_router/modules/print/print.so"
+#loadmodule "../sip_router/modules/tm/tm.so"
+
+# ----------------- setting module-specific parameters ---------------
+
+# -- tm params --
+modparam("tm", "fr_timer", 10 )
+modparam("tm", "fr_inv_timer", 5 )
+
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+	# for testing purposes, simply okay all REGISTERs
+	if (method=="REGISTER") {
+		log("REGISTER");
+		sl_send_reply("200", "ok");
+		break;
+	};
+	# print a message if a call was missed
+	seturi("sip:[email protected]");
+	/* parallel branch to sink port -- that will make it
+	   wait until timer hits
+	*/
+	append_branch("sip:[email protected]:9");
+	t_on_negative("1");
+	# start parallel forking to nobody and wer.xmla	
+	log(1,"about to relay\n");
+	t_relay();
+}
+
+reply_route[1] {
+	rewriteuri("sip:[email protected]");
+	append_branch();
+	log(1,"first redirection\n");
+	t_on_negative("2");
+}
+
+reply_route[2] {
+	rewriteuri("sip:[email protected]");
+	log(1, "second redirection\n");
+	append_branch();
+}

+ 43 - 0
examples/redirect.cfg

@@ -0,0 +1,43 @@
+#
+# $Id$
+#
+# this example shows use of ser as stateless redirect server
+#
+
+# ----------- global configuration parameters ------------------------
+
+debug=3
+fork=no
+log_stderror=yes	# (cmd line: -E)
+check_via=no # (cmd. line: -v)
+dns=no # (cmd. line: -r)
+syn_branch=1
+reply_to_via=0
+
+# advertise IP address in Via (as opposed to advertising DNS name
+# which is annoying for downstream servers and some phones can
+# not handle DNS at all)
+listen=195.37.77.100
+
+# ------------------ module loading ----------------------------------
+
+loadmodule "../sip_router/modules/sl/sl.so"
+loadmodule "../sip_router/modules/print/print.so"
+
+
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+	# for testing purposes, simply okay all REGISTERs
+	if (method=="REGISTER") {
+		log("REGISTER");
+		sl_send_reply("200", "ok");
+		break;
+	};
+	append_branch("sip:[email protected]:9");
+	append_branch("sip:[email protected]:9");
+	sl_send_reply("300", "Redirect");
+}
+

+ 81 - 0
examples/uas.cfg

@@ -0,0 +1,81 @@
+#
+# $Id$
+#
+# this example shows usage of ser as user agent
+# server which does some functionality (in this
+# example, 'log' is used to print a notification
+# on a new transaction) and behaves statefuly
+# (e.g., it retransmits replies on request
+# retransmissions)
+
+# ----------- global configuration parameters ------------------------
+
+debug=3
+fork=no
+#children=2
+log_stderror=yes	# (cmd line: -E)
+check_via=yes     # (cmd. line: -v)
+dns=0           # (cmd. line: -r)
+rev_dns=0      # (cmd. line: -R)
+port=5068
+reply_to_via=no
+
+# advertise IP address in Via (as opposed to advertising DNS name
+# which is annoying for downstream servers and some phones can
+# not handle DNS at all)
+listen=195.37.77.100
+
+# ------------------ module loading ----------------------------------
+
+loadmodule "../sip_router/modules/sl/sl.so"
+loadmodule "../sip_router/modules/print/print.so"
+#loadmodule "../sip_router/modules/tm/tm.so"
+loadmodule "../sip_router/modules/usrloc/usrloc.so"
+
+# ----------------- setting module-specific parameters ---------------
+
+# -- usrloc params --
+
+modparam("usrloc", "use_database",   0)
+modparam("usrloc", "flush_interval", 3600)
+
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+	# for testing purposes, simply okay all REGISTERs
+	if (method=="REGISTER") {
+		log("REGISTER");
+		sl_send_reply("200", "ok");
+		#t_replicate("localhost", "9");
+		break;
+	};
+	# print a message if a call was missed
+
+	if ( t_newtran())
+    {
+		if (method=="ACK") {
+			log("oops--ACK to a non-existent transaction");
+			drop;
+		};
+		log("New Transaction Arrived\n");
+        # do what you want to do as a sever
+		if (uri=~"a@") {
+			if (!t_reply("409", "Bizzar Error")) {
+				sl_reply_error();
+			};
+		} else if (uri=~"b@") {
+			if (!t_reply("979", "You did not expect this did you")) {
+				sl_reply_error();
+			};
+		} else {
+			if (!t_reply("699", "I don't want to chat with you")) {
+				sl_reply_error();
+			};
+		} ;
+    } else {
+		sl_reply_error();
+	};
+}
+