Browse code

scripts moved to examples

Jiri Kuthan authored on 19/08/2002 18:33:17
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,59 @@
1
+#
2
+# $Id$
3
+#
4
+# this example shows use of ser as stateless redirect server
5
+# which rewrites URIs using an exernal utility
6
+#
7
+
8
+# ----------- global configuration parameters ------------------------
9
+
10
+debug=4
11
+fork=1
12
+log_stderror=yes	# (cmd line: -E)
13
+check_via=no # (cmd. line: -v)
14
+dns=no # (cmd. line: -r)
15
+syn_branch=1
16
+reply_to_via=0
17
+
18
+# advertise IP address in Via (as opposed to advertising DNS name
19
+# which is annoying for downstream servers and some phones can
20
+# not handle DNS at all)
21
+listen=195.37.77.100
22
+
23
+# ------------------ module loading ----------------------------------
24
+
25
+loadmodule "../sip_router/modules/sl/sl.so"
26
+loadmodule "../sip_router/modules/print/print.so"
27
+loadmodule "../sip_router/modules/exec/exec_mod.so"
28
+loadmodule "../sip_router/modules/ext/ext.so"
29
+
30
+# -------------------------  request routing logic -------------------
31
+
32
+# main routing logic
33
+
34
+route{
35
+	# for testing purposes, simply okay all REGISTERs
36
+	if (method=="REGISTER") {
37
+		log("REGISTER");
38
+		sl_send_reply("200", "ok");
39
+		break;
40
+	};
41
+
42
+	# obsoleted
43
+	#ext_rewriteuri("echo sip:jiri@iptel.org; echo >/dev/null");
44
+	#break;
45
+
46
+	# first dump the message to a file using cat command
47
+	exec_msg("printenv SRCIP > /tmp/exectest.txt; cat >> /tmp/exectest.txt");
48
+	# and then rewrite URI using external utility
49
+	# note that the last echo command trashes input parameter
50
+	if (exec_uri("echo sip:mra@iptel.org;echo sip:mrb@iptel.org;echo>/dev/null")) {
51
+
52
+	#if (exec_uri("/tmp/sh.sh")) {
53
+		sl_send_reply("300", "Redirect");
54
+	} else {
55
+		sl_reply_error();
56
+		log(1, "alas, rewriting failed\n");
57
+	};
58
+}
59
+
0 60
new file mode 100644
... ...
@@ -0,0 +1,72 @@
1
+#
2
+# $Id$
3
+#
4
+# example script showing both types of forking;
5
+# incoming message is foked in parallel to
6
+# 'nobody' and 'parallel', if no positive reply
7
+# appears with final_response timer, nonsense
8
+# is retried (serial forking); than, destination
9
+# 'foo' is given last chance
10
+
11
+# ----------- global configuration parameters ------------------------
12
+
13
+debug=3
14
+fork=no
15
+log_stderror=yes	# (cmd line: -E)
16
+check_via=no # (cmd. line: -v)
17
+dns=no # (cmd. line: -r)
18
+syn_branch=1
19
+reply_to_via=0
20
+
21
+# advertise IP address in Via (as opposed to advertising DNS name
22
+# which is annoying for downstream servers and some phones can
23
+# not handle DNS at all)
24
+listen=195.37.77.100
25
+
26
+# ------------------ module loading ----------------------------------
27
+
28
+loadmodule "../sip_router/modules/sl/sl.so"
29
+loadmodule "../sip_router/modules/print/print.so"
30
+#loadmodule "../sip_router/modules/tm/tm.so"
31
+
32
+# ----------------- setting module-specific parameters ---------------
33
+
34
+# -- tm params --
35
+modparam("tm", "fr_timer", 10 )
36
+modparam("tm", "fr_inv_timer", 5 )
37
+
38
+# -------------------------  request routing logic -------------------
39
+
40
+# main routing logic
41
+
42
+route{
43
+	# for testing purposes, simply okay all REGISTERs
44
+	if (method=="REGISTER") {
45
+		log("REGISTER");
46
+		sl_send_reply("200", "ok");
47
+		break;
48
+	};
49
+	# print a message if a call was missed
50
+	seturi("sip:nobody@iptel.org");
51
+	/* parallel branch to sink port -- that will make it
52
+	   wait until timer hits
53
+	*/
54
+	append_branch("sip:parallel@iptel.org:9");
55
+	t_on_negative("1");
56
+	# start parallel forking to nobody and wer.xmla	
57
+	log(1,"about to relay\n");
58
+	t_relay();
59
+}
60
+
61
+reply_route[1] {
62
+	rewriteuri("sip:nonsense@iptel.org");
63
+	append_branch();
64
+	log(1,"first redirection\n");
65
+	t_on_negative("2");
66
+}
67
+
68
+reply_route[2] {
69
+	rewriteuri("sip:foo@iptel.org");
70
+	log(1, "second redirection\n");
71
+	append_branch();
72
+}
0 73
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+#
2
+# $Id$
3
+#
4
+# this example shows use of ser as stateless redirect server
5
+#
6
+
7
+# ----------- global configuration parameters ------------------------
8
+
9
+debug=3
10
+fork=no
11
+log_stderror=yes	# (cmd line: -E)
12
+check_via=no # (cmd. line: -v)
13
+dns=no # (cmd. line: -r)
14
+syn_branch=1
15
+reply_to_via=0
16
+
17
+# advertise IP address in Via (as opposed to advertising DNS name
18
+# which is annoying for downstream servers and some phones can
19
+# not handle DNS at all)
20
+listen=195.37.77.100
21
+
22
+# ------------------ module loading ----------------------------------
23
+
24
+loadmodule "../sip_router/modules/sl/sl.so"
25
+loadmodule "../sip_router/modules/print/print.so"
26
+
27
+
28
+# -------------------------  request routing logic -------------------
29
+
30
+# main routing logic
31
+
32
+route{
33
+	# for testing purposes, simply okay all REGISTERs
34
+	if (method=="REGISTER") {
35
+		log("REGISTER");
36
+		sl_send_reply("200", "ok");
37
+		break;
38
+	};
39
+	append_branch("sip:parallel@iptel.org:9");
40
+	append_branch("sip:redirect@iptel.org:9");
41
+	sl_send_reply("300", "Redirect");
42
+}
43
+
0 44
new file mode 100644
... ...
@@ -0,0 +1,81 @@
1
+#
2
+# $Id$
3
+#
4
+# this example shows usage of ser as user agent
5
+# server which does some functionality (in this
6
+# example, 'log' is used to print a notification
7
+# on a new transaction) and behaves statefuly
8
+# (e.g., it retransmits replies on request
9
+# retransmissions)
10
+
11
+# ----------- global configuration parameters ------------------------
12
+
13
+debug=3
14
+fork=no
15
+#children=2
16
+log_stderror=yes	# (cmd line: -E)
17
+check_via=yes     # (cmd. line: -v)
18
+dns=0           # (cmd. line: -r)
19
+rev_dns=0      # (cmd. line: -R)
20
+port=5068
21
+reply_to_via=no
22
+
23
+# advertise IP address in Via (as opposed to advertising DNS name
24
+# which is annoying for downstream servers and some phones can
25
+# not handle DNS at all)
26
+listen=195.37.77.100
27
+
28
+# ------------------ module loading ----------------------------------
29
+
30
+loadmodule "../sip_router/modules/sl/sl.so"
31
+loadmodule "../sip_router/modules/print/print.so"
32
+#loadmodule "../sip_router/modules/tm/tm.so"
33
+loadmodule "../sip_router/modules/usrloc/usrloc.so"
34
+
35
+# ----------------- setting module-specific parameters ---------------
36
+
37
+# -- usrloc params --
38
+
39
+modparam("usrloc", "use_database",   0)
40
+modparam("usrloc", "flush_interval", 3600)
41
+
42
+# -------------------------  request routing logic -------------------
43
+
44
+# main routing logic
45
+
46
+route{
47
+	# for testing purposes, simply okay all REGISTERs
48
+	if (method=="REGISTER") {
49
+		log("REGISTER");
50
+		sl_send_reply("200", "ok");
51
+		#t_replicate("localhost", "9");
52
+		break;
53
+	};
54
+	# print a message if a call was missed
55
+
56
+	if ( t_newtran())
57
+    {
58
+		if (method=="ACK") {
59
+			log("oops--ACK to a non-existent transaction");
60
+			drop;
61
+		};
62
+		log("New Transaction Arrived\n");
63
+        # do what you want to do as a sever
64
+		if (uri=~"a@") {
65
+			if (!t_reply("409", "Bizzar Error")) {
66
+				sl_reply_error();
67
+			};
68
+		} else if (uri=~"b@") {
69
+			if (!t_reply("979", "You did not expect this did you")) {
70
+				sl_reply_error();
71
+			};
72
+		} else {
73
+			if (!t_reply("699", "I don't want to chat with you")) {
74
+				sl_reply_error();
75
+			};
76
+		} ;
77
+    } else {
78
+		sl_reply_error();
79
+	};
80
+}
81
+