Browse Source

tm: t_reply can now be used from onreply_routes

t_reply can now be used both from the main onreply_route
(onreply_route{}) or from tm onreply_routes (onreply_route[x]{},
where x!=0).
In general it should be followed by a DROP. If not you might get
some log warning messages (but besides that nothing bad will
happen).
Andrei Pelinescu-Onciul 15 years ago
parent
commit
9e2873513d
1 changed files with 16 additions and 1 deletions
  1. 16 1
      modules/tm/tm.c

+ 16 - 1
modules/tm/tm.c

@@ -315,7 +315,7 @@ static cmd_export_t cmds[]={
 	{"t_lookup_cancel",    w_t_lookup_cancel,       1, fixup_int_1,
 			REQUEST_ROUTE},
 	{T_REPLY,              w_t_reply,               2, fixup_t_reply,
-			REQUEST_ROUTE | FAILURE_ROUTE },
+			REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE },
 	{"t_retransmit_reply", w_t_retransmit_reply,    0, 0,
 			REQUEST_ROUTE},
 	{"t_release",          w_t_release,             0, 0,
@@ -1255,6 +1255,21 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
 		ret = t_reply_unsafe(t, msg, code, r);
 	} else if (is_route_type(REQUEST_ROUTE)) {
 		ret = t_reply( t, msg, code, r);
+	} else if (is_route_type(ONREPLY_ROUTE)) {
+		if (likely(t->uas.request)){
+			if (is_route_type(CORE_ONREPLY_ROUTE))
+				ret=t_reply(t, t->uas.request, code, r);
+			else
+				ret=t_reply_unsafe(t, t->uas.request, code, r);
+		}else
+			ret=-1;
+		/* t_check() above has the side effect of setting T and
+		   REFerencing T => we must unref and unset it.
+		   Note: this is needed only in the CORE_ONREPLY_ROUTE and not also in
+		   the TM_ONREPLY_ROUTE.
+		 */
+		UNREF( t );
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
 	} else {
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
 		ret = -1;