Browse code

modules_k/outbound: Updates to outbound module documentation

Peter Dunkley authored on 06/01/2013 19:32:45
Showing 2 changed files
... ...
@@ -117,12 +117,70 @@ modparam("websocket", "keepalive_timeout", FLOW_TIMER+5)
117 117
 modparam("outbound", "flow_token_key", "!!!Kamailio rocks!!!")
118 118
 ...
119 119
 route {
120
-...
121
-        if (is_method("INVITE|SUBSCRIBE"))
120
+        route(REQINIT);
121
+        ...
122
+        t_check_trans();
123
+
124
+        if (is_method("INVITE|SUBSCRIBE")) {
122 125
                 record_route();
123
-        else if (is_method("REGISTER"))
126
+
127
+                if ($rU==$null) {
128
+                        sl_send_reply("484", "Address Incomplete");
129
+                        exit;
130
+                }
131
+
132
+                if (!loose_route()) {
133
+                        switch($rc) {
134
+                        case -2:
135
+                                # Flow-token has been tampered with
136
+                                sl_send_reply("403", "Forbidden");
137
+                                exit;
138
+                        case -1:
139
+                                # Handle -1 here if all dialog forming requests
140
+                                # must be outbound routed
141
+                        }
142
+                }
143
+                route(RELAY);
144
+        } else if (is_method("REGISTER")) {
124 145
                 add_path();
146
+                if (!t_relay("### Registrar ###")) {
147
+                        sl_reply_error();
148
+                }
149
+                exit;
150
+        }
151
+}
152
+
153
+route[RELAY] {
154
+        t_on_failure("FAIL_OUTBOUND");
155
+        if (!t_relay()) {
156
+                sl_send_reply("430", "Flow Failed");
157
+        }
158
+        exit;
159
+}
125 160
 ...
161
+route[WITHINDLG] {
162
+        if (has_totag()) {
163
+                if (!loose_route()) {
164
+                        switch($rc) {
165
+                        case -2:
166
+                                sl_send_reply("403", "Forbidden");
167
+                                exit;
168
+                        case -1:
169
+                                if (is_method("ACK")) {
170
+                                        if (t_check_trans()) {
171
+                                                t_relay();
172
+                                                exit;
173
+                                        } else {
174
+                                                exit;
175
+                                        }
176
+                                }
177
+                                sl_send_reply("404", "Not Found");
178
+                        }
179
+                } else {
180
+                        route(RELAY);
181
+                }
182
+                exit;
183
+        }
126 184
 }
127 185
 ...
128 186
 onreply_route {
... ...
@@ -137,11 +195,17 @@ onreply_route {
137 195
         }
138 196
 }
139 197
 
198
+failure_route[REPLY_OUTBOUND] {
199
+        if (t_branch_timeout() || !t_branch_replied()) {
200
+                send_reply("430", "Flow Failed");
201
+        }
202
+}
203
+
140 204
    Example 1.3. Registrar Configuration
141 205
 ...
142 206
 loadmodule "registrar.so"
143 207
 ...
144
-modparam("registrar", "outbound_mode", 2)
208
+TBD
145 209
 ...
146 210
 
147 211
 2. Dependencies
... ...
@@ -72,12 +72,70 @@ modparam("websocket", "keepalive_timeout", FLOW_TIMER+5)
72 72
 modparam("outbound", "flow_token_key", "!!!Kamailio rocks!!!")
73 73
 ...
74 74
 route {
75
-...
76
-	if (is_method("INVITE|SUBSCRIBE"))
75
+	route(REQINIT);
76
+	...
77
+	t_check_trans();
78
+
79
+	if (is_method("INVITE|SUBSCRIBE")) {
77 80
 		record_route();
78
-	else if (is_method("REGISTER"))
81
+
82
+		if ($rU==$null) {
83
+			sl_send_reply("484", "Address Incomplete");
84
+			exit;
85
+		}
86
+
87
+		if (!loose_route()) {
88
+			switch($rc) {
89
+			case -2:
90
+				# Flow-token has been tampered with
91
+				sl_send_reply("403", "Forbidden");
92
+				exit;
93
+			case -1:
94
+				# Handle -1 here if all dialog forming requests
95
+				# must be outbound routed
96
+			}
97
+		}
98
+		route(RELAY);
99
+	} else if (is_method("REGISTER")) {
79 100
 		add_path();
101
+		if (!t_relay("### Registrar ###")) {
102
+			sl_reply_error();
103
+		}
104
+		exit;
105
+	}
106
+}
107
+
108
+route[RELAY] {
109
+	t_on_failure("FAIL_OUTBOUND");
110
+	if (!t_relay()) {
111
+		sl_send_reply("430", "Flow Failed");
112
+	}
113
+	exit;
114
+}
80 115
 ...
116
+route[WITHINDLG] {
117
+	if (has_totag()) {
118
+		if (!loose_route()) {
119
+			switch($rc) {
120
+			case -2:
121
+				sl_send_reply("403", "Forbidden");
122
+				exit;
123
+			case -1:
124
+				if (is_method("ACK")) {
125
+					if (t_check_trans()) {
126
+						t_relay();
127
+						exit;
128
+					} else {
129
+						exit;
130
+					}
131
+				}
132
+				sl_send_reply("404", "Not Found");
133
+			}
134
+		} else {
135
+			route(RELAY);
136
+		}
137
+		exit;
138
+	}
81 139
 }
82 140
 ...
83 141
 onreply_route {
... ...
@@ -91,6 +149,12 @@ onreply_route {
91 149
 			insert_hf("Flow-Timer: FLOW_TIMER\r\n", "Call-ID");
92 150
 	}
93 151
 }
152
+
153
+failure_route[REPLY_OUTBOUND] {
154
+	if (t_branch_timeout() || !t_branch_replied()) {
155
+		send_reply("430", "Flow Failed");
156
+	}
157
+}
94 158
 ]]></programlisting>
95 159
 	</example>
96 160
 	<example>
... ...
@@ -99,7 +163,7 @@ onreply_route {
99 163
 ...
100 164
 loadmodule "registrar.so"
101 165
 ...
102
-modparam("registrar", "outbound_mode", 2)
166
+TBD
103 167
 ...
104 168
 ]]></programlisting>
105 169
 	</example>