Browse code

modules_k/outbound: updated documentation

- Fixed some mistakes in the Edge Proxy example
- Filled in more detail in the Registrar example

Peter Dunkley authored on 08/01/2013 11:27:11
Showing 2 changed files
... ...
@@ -140,6 +140,8 @@ route {
140 140
                                 # must be outbound routed
141 141
                         }
142 142
                 }
143
+
144
+                t_on_failure("FAIL_OUTBOUND");
143 145
                 route(RELAY);
144 146
         } else if (is_method("REGISTER")) {
145 147
                 add_path();
... ...
@@ -151,7 +153,6 @@ route {
151 153
 }
152 154
 
153 155
 route[RELAY] {
154
-        t_on_failure("FAIL_OUTBOUND");
155 156
         if (!t_relay()) {
156 157
                 sl_send_reply("430", "Flow Failed");
157 158
         }
... ...
@@ -193,20 +194,75 @@ onreply_route {
193 194
                 if ($(hdr(Require)[*])=~"outbound")
194 195
                         insert_hf("Flow-Timer: FLOW_TIMER\r\n", "Call-ID");
195 196
         }
197
+
198
+...
196 199
 }
197 200
 
198
-failure_route[REPLY_OUTBOUND] {
201
+failure_route[FAIL_OUTBOUND] {
199 202
         if (t_branch_timeout() || !t_branch_replied()) {
200 203
                 send_reply("430", "Flow Failed");
201 204
         }
202 205
 }
206
+...
203 207
 
204 208
    Example 1.3. Registrar Configuration
205 209
 ...
210
+loadmodule "tm.so"
211
+...
206 212
 loadmodule "registrar.so"
207 213
 ...
214
+modparam("tm", "contacts_avp", "tm_contacts")
215
+modparam("tm", "contact_flows_avp", "tm_contact_flows")
216
+...
217
+modparam("registrar", "use_path", 1)
218
+modparam("registrar", "path_mode", 2)
208 219
 modparam("registrar", "outbound_mode", 2)
209
-### TBD
220
+...
221
+route[LOCATION] {
222
+...
223
+        if (!lookup("location")) {
224
+                $var(rc) = $rc;
225
+                route(TOVOICEMAIL);
226
+                t_newtran();
227
+                switch ($var(rc)) {
228
+                        case -1:
229
+                        case -3:
230
+                                send_reply("404", "Not Found");
231
+                                exit;
232
+                        case -2:
233
+                                send_reply("405", "Method Not Allowed");
234
+                                exit;
235
+                }
236
+        }
237
+
238
+        if (!t_load_contacts()) {
239
+                send_reply("500", "Server Internal Error");
240
+                exit;
241
+        }
242
+
243
+        if (!t_next_contacts()) {
244
+                send_reply("500", "Server Internal Error");
245
+                exit;
246
+        }
247
+
248
+        t_on_failure(FAIL_OUTBOUND);
249
+...
250
+}
251
+...
252
+failure_route[FAIL_OUTBOUND] {
253
+        if (t_check_status("408|430")) {
254
+                if (!t_next_contact_flows() && !t_next_contacts()) {
255
+                        send_reply("500", "Server Internal Error");
256
+                        exit;
257
+                }
258
+        } else if (!t_next_contacts()) {
259
+                send_reply("500", "Server Internal Error");
260
+                exit;
261
+        }
262
+
263
+        t_on_failure(FAIL_OUTBOUND);
264
+        route[RELAY];
265
+}
210 266
 ...
211 267
 
212 268
 2. Dependencies
... ...
@@ -95,6 +95,8 @@ route {
95 95
 				# must be outbound routed
96 96
 			}
97 97
 		}
98
+
99
+		t_on_failure("FAIL_OUTBOUND");
98 100
 		route(RELAY);
99 101
 	} else if (is_method("REGISTER")) {
100 102
 		add_path();
... ...
@@ -106,7 +108,6 @@ route {
106 108
 }
107 109
 
108 110
 route[RELAY] {
109
-	t_on_failure("FAIL_OUTBOUND");
110 111
 	if (!t_relay()) {
111 112
 		sl_send_reply("430", "Flow Failed");
112 113
 	}
... ...
@@ -148,23 +149,78 @@ onreply_route {
148 149
 		if ($(hdr(Require)[*])=~"outbound")
149 150
 			insert_hf("Flow-Timer: FLOW_TIMER\r\n", "Call-ID");
150 151
 	}
152
+
153
+...
151 154
 }
152 155
 
153
-failure_route[REPLY_OUTBOUND] {
156
+failure_route[FAIL_OUTBOUND] {
154 157
 	if (t_branch_timeout() || !t_branch_replied()) {
155 158
 		send_reply("430", "Flow Failed");
156 159
 	}
157 160
 }
161
+...
158 162
 ]]></programlisting>
159 163
 	</example>
160 164
 	<example>
161 165
 	<title>Registrar Configuration</title>
162 166
 	<programlisting><![CDATA[
163 167
 ...
168
+loadmodule "tm.so"
169
+...
164 170
 loadmodule "registrar.so"
165 171
 ...
172
+modparam("tm", "contacts_avp", "tm_contacts")
173
+modparam("tm", "contact_flows_avp", "tm_contact_flows")
174
+...
175
+modparam("registrar", "use_path", 1)
176
+modparam("registrar", "path_mode", 2)
166 177
 modparam("registrar", "outbound_mode", 2)
167
-### TBD
178
+...
179
+route[LOCATION] {
180
+...
181
+	if (!lookup("location")) {
182
+		$var(rc) = $rc;
183
+		route(TOVOICEMAIL);
184
+		t_newtran();
185
+		switch ($var(rc)) {
186
+			case -1:
187
+			case -3:
188
+				send_reply("404", "Not Found");
189
+				exit;
190
+			case -2:
191
+				send_reply("405", "Method Not Allowed");
192
+				exit;
193
+		}
194
+	}
195
+
196
+	if (!t_load_contacts()) {
197
+		send_reply("500", "Server Internal Error");
198
+		exit;
199
+	}
200
+
201
+	if (!t_next_contacts()) {
202
+		send_reply("500", "Server Internal Error");
203
+		exit;
204
+	}
205
+
206
+	t_on_failure(FAIL_OUTBOUND);
207
+...
208
+}
209
+...
210
+failure_route[FAIL_OUTBOUND] {
211
+	if (t_check_status("408|430")) {
212
+		if (!t_next_contact_flows() && !t_next_contacts()) {
213
+			send_reply("500", "Server Internal Error");
214
+			exit;
215
+		}
216
+	} else if (!t_next_contacts()) {
217
+		send_reply("500", "Server Internal Error");
218
+		exit;
219
+	}
220
+
221
+	t_on_failure(FAIL_OUTBOUND);
222
+	route[RELAY];
223
+}
168 224
 ...
169 225
 ]]></programlisting>
170 226
 	</example>