Browse code

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 authored on 22/02/2010 16:50:40
Showing 1 changed files
... ...
@@ -315,7 +315,7 @@ static cmd_export_t cmds[]={
315 315
 	{"t_lookup_cancel",    w_t_lookup_cancel,       1, fixup_int_1,
316 316
 			REQUEST_ROUTE},
317 317
 	{T_REPLY,              w_t_reply,               2, fixup_t_reply,
318
-			REQUEST_ROUTE | FAILURE_ROUTE },
318
+			REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE },
319 319
 	{"t_retransmit_reply", w_t_retransmit_reply,    0, 0,
320 320
 			REQUEST_ROUTE},
321 321
 	{"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)
1255 1255
 		ret = t_reply_unsafe(t, msg, code, r);
1256 1256
 	} else if (is_route_type(REQUEST_ROUTE)) {
1257 1257
 		ret = t_reply( t, msg, code, r);
1258
+	} else if (is_route_type(ONREPLY_ROUTE)) {
1259
+		if (likely(t->uas.request)){
1260
+			if (is_route_type(CORE_ONREPLY_ROUTE))
1261
+				ret=t_reply(t, t->uas.request, code, r);
1262
+			else
1263
+				ret=t_reply_unsafe(t, t->uas.request, code, r);
1264
+		}else
1265
+			ret=-1;
1266
+		/* t_check() above has the side effect of setting T and
1267
+		   REFerencing T => we must unref and unset it.
1268
+		   Note: this is needed only in the CORE_ONREPLY_ROUTE and not also in
1269
+		   the TM_ONREPLY_ROUTE.
1270
+		 */
1271
+		UNREF( t );
1272
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
1258 1273
 	} else {
1259 1274
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
1260 1275
 		ret = -1;