Browse code

new exmample demonstating on_reply

Jiri Kuthan authored on 07/04/2003 06:32:58
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+#
2
+# $Id$
3
+#
4
+# this example shows how to use forking on failure
5
+#
6
+
7
+log_stderror=1
8
+fork=no
9
+listen=192.168.2.16
10
+debug=3
11
+# ------------------ module loading ----------------------------------
12
+
13
+# Uncomment this if you want to use SQL database
14
+loadmodule "modules/tm/tm.so"
15
+loadmodule "modules/sl/sl.so"
16
+loadmodule "modules/maxfwd/maxfwd.so"
17
+# -------------------------  request routing logic -------------------
18
+
19
+# main routing logic
20
+
21
+route{
22
+
23
+	# initial sanity checks -- messages with
24
+	# max_forwards==0, or excessively long requests
25
+	if (!mf_process_maxfwd_header("10")) {
26
+		sl_send_reply("483","Too Many Hops");
27
+		break;
28
+	};
29
+	if (len_gt( max_len )) {
30
+		sl_send_reply("513", "Message too big");
31
+		break;
32
+	};
33
+
34
+	/* skip register for testing purposes */
35
+	if (method=="REGISTER") { sl_send_reply("200", "ok"); break; };
36
+
37
+	if (!method=="ACK")
38
+		log(1, "forwarding now to primary destination\n");
39
+	if (method=="INVITE") {
40
+		rewriteuri("sip:xxx@192.168.2.16:5064");
41
+		# if transaction broken, try other an alternative
42
+		# route
43
+		t_on_failure("1");
44
+		# if a provisional came, stop alternating
45
+		t_on_reply("1");
46
+	};
47
+	t_relay();
48
+}
49
+
50
+failure_route[1] {
51
+	log(1, "trying at alternate destination\n");
52
+	append_branch("sip:yyy@192.168.2.16:5064");
53
+	t_relay();
54
+}
55
+
56
+onreply_route[1] {
57
+	log(1, "reply came in\n");
58
+	if (status=~"18[0-9]")  {
59
+		log(1, "provisional -- resetting negative failure\n");
60
+		t_on_failure("0");
61
+	};
62
+}