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