tm: t_reply can now be used from onreply_routes
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 22 Feb 2010 16:50:40 +0000 (17:50 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 22 Feb 2010 16:50:40 +0000 (17:50 +0100)
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).

modules/tm/tm.c

index 16275c8..513dc99 100644 (file)
@@ -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;