2
0
Эх сурвалжийг харах

modules_k/outbound: Updates to outbound module documentation

Peter Dunkley 12 жил өмнө
parent
commit
9f63684167

+ 68 - 4
modules_k/outbound/README

@@ -117,12 +117,70 @@ modparam("websocket", "keepalive_timeout", FLOW_TIMER+5)
 modparam("outbound", "flow_token_key", "!!!Kamailio rocks!!!")
 ...
 route {
-...
-        if (is_method("INVITE|SUBSCRIBE"))
+        route(REQINIT);
+        ...
+        t_check_trans();
+
+        if (is_method("INVITE|SUBSCRIBE")) {
                 record_route();
-        else if (is_method("REGISTER"))
+
+                if ($rU==$null) {
+                        sl_send_reply("484", "Address Incomplete");
+                        exit;
+                }
+
+                if (!loose_route()) {
+                        switch($rc) {
+                        case -2:
+                                # Flow-token has been tampered with
+                                sl_send_reply("403", "Forbidden");
+                                exit;
+                        case -1:
+                                # Handle -1 here if all dialog forming requests
+                                # must be outbound routed
+                        }
+                }
+                route(RELAY);
+        } else if (is_method("REGISTER")) {
                 add_path();
+                if (!t_relay("### Registrar ###")) {
+                        sl_reply_error();
+                }
+                exit;
+        }
+}
+
+route[RELAY] {
+        t_on_failure("FAIL_OUTBOUND");
+        if (!t_relay()) {
+                sl_send_reply("430", "Flow Failed");
+        }
+        exit;
+}
 ...
+route[WITHINDLG] {
+        if (has_totag()) {
+                if (!loose_route()) {
+                        switch($rc) {
+                        case -2:
+                                sl_send_reply("403", "Forbidden");
+                                exit;
+                        case -1:
+                                if (is_method("ACK")) {
+                                        if (t_check_trans()) {
+                                                t_relay();
+                                                exit;
+                                        } else {
+                                                exit;
+                                        }
+                                }
+                                sl_send_reply("404", "Not Found");
+                        }
+                } else {
+                        route(RELAY);
+                }
+                exit;
+        }
 }
 ...
 onreply_route {
@@ -137,11 +195,17 @@ onreply_route {
         }
 }
 
+failure_route[REPLY_OUTBOUND] {
+        if (t_branch_timeout() || !t_branch_replied()) {
+                send_reply("430", "Flow Failed");
+        }
+}
+
    Example 1.3. Registrar Configuration
 ...
 loadmodule "registrar.so"
 ...
-modparam("registrar", "outbound_mode", 2)
+TBD
 ...
 
 2. Dependencies

+ 68 - 4
modules_k/outbound/doc/outbound_admin.xml

@@ -72,12 +72,70 @@ modparam("websocket", "keepalive_timeout", FLOW_TIMER+5)
 modparam("outbound", "flow_token_key", "!!!Kamailio rocks!!!")
 ...
 route {
-...
-	if (is_method("INVITE|SUBSCRIBE"))
+	route(REQINIT);
+	...
+	t_check_trans();
+
+	if (is_method("INVITE|SUBSCRIBE")) {
 		record_route();
-	else if (is_method("REGISTER"))
+
+		if ($rU==$null) {
+			sl_send_reply("484", "Address Incomplete");
+			exit;
+		}
+
+		if (!loose_route()) {
+			switch($rc) {
+			case -2:
+				# Flow-token has been tampered with
+				sl_send_reply("403", "Forbidden");
+				exit;
+			case -1:
+				# Handle -1 here if all dialog forming requests
+				# must be outbound routed
+			}
+		}
+		route(RELAY);
+	} else if (is_method("REGISTER")) {
 		add_path();
+		if (!t_relay("### Registrar ###")) {
+			sl_reply_error();
+		}
+		exit;
+	}
+}
+
+route[RELAY] {
+	t_on_failure("FAIL_OUTBOUND");
+	if (!t_relay()) {
+		sl_send_reply("430", "Flow Failed");
+	}
+	exit;
+}
 ...
+route[WITHINDLG] {
+	if (has_totag()) {
+		if (!loose_route()) {
+			switch($rc) {
+			case -2:
+				sl_send_reply("403", "Forbidden");
+				exit;
+			case -1:
+				if (is_method("ACK")) {
+					if (t_check_trans()) {
+						t_relay();
+						exit;
+					} else {
+						exit;
+					}
+				}
+				sl_send_reply("404", "Not Found");
+			}
+		} else {
+			route(RELAY);
+		}
+		exit;
+	}
 }
 ...
 onreply_route {
@@ -91,6 +149,12 @@ onreply_route {
 			insert_hf("Flow-Timer: FLOW_TIMER\r\n", "Call-ID");
 	}
 }
+
+failure_route[REPLY_OUTBOUND] {
+	if (t_branch_timeout() || !t_branch_replied()) {
+		send_reply("430", "Flow Failed");
+	}
+}
 ]]></programlisting>
 	</example>
 	<example>
@@ -99,7 +163,7 @@ onreply_route {
 ...
 loadmodule "registrar.so"
 ...
-modparam("registrar", "outbound_mode", 2)
+TBD
 ...
 ]]></programlisting>
 	</example>