Parcourir la source

examples ported from stable to devel

Jiri Kuthan il y a 22 ans
Parent
commit
fe81a67e6b
2 fichiers modifiés avec 150 ajouts et 0 suppressions
  1. 50 0
      examples/exec_dist.cfg
  2. 100 0
      examples/voicemail.cfg

+ 50 - 0
examples/exec_dist.cfg

@@ -0,0 +1,50 @@
+#
+# $Id$
+#
+# Example for distributing load accross multiple devices
+#
+fork=no
+log_stderror=yes
+listen=192.168.2.16
+# ----------- global configuration parameters ------------------------
+
+loadmodule "modules/exec/exec.so"
+loadmodule "modules/sl/sl.so"
+loadmodule "modules/tm/tm.so"
+
+# ----------------- setting module-specific parameters ---------------
+
+route{
+	# uri for my domain ?
+	if (!(uri==myself)) {
+		sl_send_reply("500", "example serves only my domain");
+		break;
+	};
+	if (method=="REGISTER") {
+		sl_send_reply("200", "silly example -- pretend registrar");
+		break;
+	};
+   	exec_dset('
+# calculate a characteristic value for this call
+CHAR=`echo $SIP_HF_CALLID | sum  | awk " { print \\\$1 } "`
+# normalize the value
+NC=`expr $CHAR % 100`
+
+# distribute now
+
+# gateway 192.168.2.35 @ 10 %
+if [ "$NC" -lt 10 ] ; then
+	printf "sip:[email protected]"
+	exit
+fi
+
+# anything else at 90 %
+printf "sip:[email protected]"  
+exit
+
+# SER adds command-line parameters -- trash them here
+echo > dev/null
+');
+
+	t_relay();
+}

+ 100 - 0
examples/voicemail.cfg

@@ -0,0 +1,100 @@
+#
+# $Id$
+#
+# this script is configured for use as voicemail UAS; it processes
+# INVITEs and BYEs and asks SEMS to record media via "vm"; in this
+# script, all record-routing and other constructs known from proxy
+# scripts are not present  -- it is a simple UAS 
+#
+
+# ----------- global configuration parameters ------------------------
+
+#debug=		        # debug level (cmd line: -dddddddddd)
+#fork=no
+#log_stderror=yes 	# (cmd line: -E)
+
+
+check_via=no		# (cmd. line: -v)
+dns=no			# (cmd. line: -r)
+rev_dns=no		# (cmd. line: -R)
+port=5090
+children=4
+fifo="/tmp/vm_ser_fifo"
+
+# ------------------ module loading ----------------------------------
+
+loadmodule "/home/srouter/sip_router/modules/sl/sl.so"
+loadmodule "/home/srouter/sip_router/modules/tm/tm.so"
+loadmodule "/home/srouter/sip_router/modules/maxfwd/maxfwd.so"
+loadmodule "/home/srouter/sip_router/modules/mysql/mysql.so"
+loadmodule "/home/srouter/sip_router/modules/vm/vm.so"
+	    
+# ----------------- setting module-specific parameters ---------------
+
+modparam("voicemail", "db_url","sql://ser:heslo@dbhost/ser")
+
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+
+
+	# initial sanity checks -- messages with
+	# max_forwars==0, or excessively long requests
+	if (!mf_process_maxfwd_header("10")) {
+		sl_send_reply("483","Too Many Hops");
+		break;
+	};
+	if (len_gt( max_len )) {
+		sl_send_reply("513", "Message too big");
+		break;
+	};
+
+	if (!uri==myself) {
+		sl_send_reply("404", "not reponsible for host in r-uri");
+		break;
+	};
+
+
+	# Voicemail specific configuration - begin
+
+	if(method=="ACK" || method=="INVITE" || method=="BYE"){
+
+		if (!t_newtran()) {
+			log("could not create new transaction\n");
+			sl_send_reply("500","could not create new transaction");
+			break;
+		};
+
+		t_reply("100","Trying -- just wait a minute !");
+		if(method=="INVITE"){
+			log("**************** vm start - begin ******************\n");
+			if (uri=~"sip:as_welcome@.*" || uri=~"sip:as_nomoney@.*") {
+	               		if (!vm("/tmp/am_fifo", "announcement")) {
+			        	log("couldn't contact announcement server\n");
+					t_reply("500", "couldn not contact announcement server");
+				};
+			} else {
+				if(!vm("/tmp/am_fifo","voicemail")){
+					log("could not contact the answer machine\n");
+					t_reply("500","could not contact the answer machine");
+				};
+			};
+			log("**************** vm start - end ******************\n");
+		} else if(method=="BYE"){
+			log("**************** vm end - begin ******************\n");
+			if(!vm("/tmp/am_fifo","bye")){
+				log("could not contact the answer machine\n");
+				t_reply("500","could not contact the answer machine");
+			};
+			log("**************** vm end - end ******************\n");
+		};
+		break;
+	};
+	if (method=="CANCEL") {
+		sl_send_reply("200", "cancels are junked here");
+		break;
+	};
+	sl_send_reply("501", "method not understood here");
+}