Skip to content

Commit fa93ebb

Browse files
committed
[tm] Changes on the new local_reply/request_route mod params
Improve the names of the variables. Improve docs with more details. Make `local_reply_route` a generic route, not a onreply route (as it taints the concept of onreply routes) Related to #3329 Complets 57b122f29e0872b221e40fba6f9e900362f8c2ce
1 parent 1248f80 commit fa93ebb

File tree

6 files changed

+71
-37
lines changed

6 files changed

+71
-37
lines changed

modules/tm/doc/tm_admin.xml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,29 @@ modparam("tm", "cluster_auto_cancel", no)
864864
<section id="param_local_request_route" xreflabel="local_request_route">
865865
<title><varname>local_request_route</varname> (string)</title>
866866
<para>
867-
This parameter points to a route, which is executed whenever TM creates
868-
a new request (e.g., through the B2B modules or through MI).
867+
This parameter points to a route, which is executed whenever TM is
868+
about to send out a locally generated request (e.g., through the
869+
B2B modules or through MI).
869870
</para>
870871
<para>
871-
The route is executed with the generated message by TM, incorporating all
872-
modifications.
872+
The purpose of this route is limited to exposing the content of the
873+
request as SIP message
874+
</para>
875+
<para>
876+
The route is executed with the generated message by TM, incorporating
877+
all modifications.
878+
</para>
879+
<para>
880+
IMPORTANT: this route is executed AFTER the local_route (if defined)
881+
and it expose all the changes from that route.
882+
</para>
883+
<para>
884+
IMPORTANT: this route is to be used in a read-only manner, inspection
885+
only. Any changes you do here will discarded.
886+
</para>
887+
<para>
888+
IMPORTANT: this route does not offer any message, transactional or
889+
dialog context, so do not rely on any variables with scope (like AVPs).
873890
</para>
874891
<example>
875892
<title>Set the <varname>local_request_route</varname> parameter</title>
@@ -879,7 +896,7 @@ modparam("tm", "cluster_auto_cancel", no)
879896
modparam("tm", "local_request_route", "tm_local_request")
880897

881898
route[tm_local_request] {
882-
if (is_method("INVITE") && $rb(application/sdp) && !has_totag()) {
899+
if (is_method("INVITE") &amp;&amp; $rb(application/sdp) &amp;&amp; !has_totag()) {
883900
$avp(sdp_request) := $rb(application/sdp);
884901
}
885902
}
@@ -891,18 +908,30 @@ route[tm_local_request] {
891908
<section id="param_local_reply_route" xreflabel="local_reply_route">
892909
<title><varname>local_reply_route</varname> (string)</title>
893910
<para>
894-
This parameter points to a reply-route, which is executed whenever TM creates
895-
a reply (e.g., through the B2B modules or through MI).
911+
This parameter points to a route, which is executed whenever TM is
912+
about to send out a locally generated reply (e.g., through the
913+
B2B modules or through MI).
914+
</para>
915+
<para>
916+
The purpose of this route is limited to exposing the content of the
917+
reply as SIP message
918+
</para>
919+
<para>
920+
IMPORTANT: this route is to be used in a read-only manner, inspection
921+
only. Any changes you do here will discarded.
922+
</para>
923+
<para>
924+
IMPORTANT: this route does not offer any message, transactional or
925+
dialog context, so do not rely on any variables with scope (like AVPs).
896926
</para>
897-
898927
<example>
899928
<title>Set the <varname>local_reply_route</varname> parameter</title>
900929
<programlisting format="linespecific">
901930
...
902931
# Execute the route "tm_local_reply" upon sending a request
903932
modparam("tm", "local_reply_route", "tm_local_reply")
904933

905-
onreply_route[tm_local_reply] {
934+
route[tm_local_reply] {
906935
if (is_method("BYE")) {
907936
$var(rc) = rest_get("http://localhost/qos/delete",
908937
$var(recv_body), $var(recv_ct), $var(rcode));

modules/tm/t_reply.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,17 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
441441
if(trans->uas.request && trans->uas.request->flags&tcp_no_new_conn_rplflag)
442442
tcp_no_new_conn = 1;
443443

444-
if(ref_script_route_is_valid(tm_local_reply)) {
444+
if(ref_script_route_is_valid(tm_local_reply_route)) {
445445
LM_DBG("Found Local-Reply Route...\n");
446-
LM_DBG("Message:\n-----------------\n%.*s\n--------------------\n", len, buf);
447446
memset(&dummy_msg, 0, sizeof(struct sip_msg));
448447
dummy_msg.buf = buf;
449448
dummy_msg.len = len;
450449

451450
if (parse_msg(buf, len, &dummy_msg) == 0) {
452-
LM_DBG("Parsed Message, executing Local-Reply Route with Message...\n");
453-
run_top_route(sroutes->onreply[tm_local_reply->idx], &dummy_msg);
451+
LM_DBG("Parsed Message, executing Local-Reply Route "
452+
"with Message...\n");
453+
run_top_route(sroutes->request[tm_local_reply_route->idx],
454+
&dummy_msg);
454455
}
455456
free_sip_msg(&dummy_msg);
456457
}

modules/tm/t_reply.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
extern int restart_fr_on_each_reply;
3232
extern int onreply_avp_mode;
33-
extern struct script_route_ref *tm_local_reply;
33+
extern struct script_route_ref *tm_local_reply_route;
3434

3535
/* reply processing status */
3636
enum rps {

modules/tm/tm.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ struct sip_msg* tm_pv_context_reply(struct sip_msg* msg);
141141
int fr_timeout;
142142
int fr_inv_timeout;
143143

144-
static char* tm_local_reply_route;
145-
struct script_route_ref *tm_local_reply = NULL;
144+
static char* tm_local_reply_route_s;
145+
struct script_route_ref *tm_local_reply_route = NULL;
146146

147-
static char* tm_local_request_route;
148-
struct script_route_ref *tm_local_request = NULL;
147+
static char* tm_local_request_route_s;
148+
struct script_route_ref *tm_local_request_route = NULL;
149149

150150
#define TM_CANCEL_BRANCH_ALL (1<<0)
151151
#define TM_CANCEL_BRANCH_OTHERS (1<<1)
@@ -346,10 +346,10 @@ static const param_export_t params[]={
346346
&tm_cluster_param.s },
347347
{ "cluster_auto_cancel", INT_PARAM,
348348
&tm_repl_auto_cancel },
349-
{ "local_reply_route", STR_PARAM,
350-
&tm_local_reply_route },
349+
{ "local_reply_route", STR_PARAM,
350+
&tm_local_reply_route_s },
351351
{ "local_request_route", STR_PARAM,
352-
&tm_local_request_route },
352+
&tm_local_request_route_s },
353353
{0,0,0}
354354
};
355355

@@ -957,27 +957,29 @@ static int mod_init(void)
957957
LM_WARN("running without cluster support for transactions!\n");
958958
}
959959

960-
if (tm_local_reply_route)
960+
if (tm_local_reply_route_s)
961961
{
962-
tm_local_reply = ref_script_route_by_name( tm_local_reply_route,
963-
sroutes->onreply, ONREPLY_RT_NO, ONREPLY_ROUTE, 0);
964-
if (!ref_script_route_is_valid(tm_local_reply))
962+
tm_local_reply_route = ref_script_route_by_name(
963+
tm_local_reply_route_s,
964+
sroutes->onreply, RT_NO, REQUEST_ROUTE, 0);
965+
if (!ref_script_route_is_valid(tm_local_reply_route))
965966
{
966-
LM_ERR("route <%s> does not exist\n",tm_local_reply_route);
967+
LM_ERR("route <%s> does not exist\n",tm_local_reply_route_s);
967968
return -1;
968969
}
969-
}
970+
}
970971

971-
if (tm_local_request_route)
972+
if (tm_local_request_route_s)
972973
{
973-
tm_local_request = ref_script_route_by_name( tm_local_request_route,
974+
tm_local_request_route = ref_script_route_by_name(
975+
tm_local_request_route_s,
974976
sroutes->request, RT_NO, REQUEST_ROUTE, 0);
975-
if (!ref_script_route_is_valid(tm_local_request))
977+
if (!ref_script_route_is_valid(tm_local_request_route))
976978
{
977-
LM_ERR("route <%s> does not exist\n",tm_local_request_route);
979+
LM_ERR("route <%s> does not exist\n",tm_local_request_route_s);
978980
return -1;
979981
}
980-
}
982+
}
981983

982984
return 0;
983985
}

modules/tm/uac.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,17 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
553553
request->buffer.len = buf_len;
554554
}
555555

556-
if (ref_script_route_is_valid(tm_local_request)) {
556+
if (ref_script_route_is_valid(tm_local_request_route)) {
557557
LM_DBG("Found Local-Request Route...\n");
558558
memset(&dummy_msg, 0, sizeof(struct sip_msg));
559559
dummy_msg.buf = request->buffer.s;
560560
dummy_msg.len = request->buffer.len;
561561

562-
if (parse_msg(request->buffer.s, request->buffer.len, &dummy_msg) == 0) {
563-
LM_DBG("Parsed Message, executing Local-Reply Route with Message...\n");
564-
run_top_route(sroutes->request[tm_local_request->idx], &dummy_msg);
562+
if (parse_msg(request->buffer.s, request->buffer.len, &dummy_msg)==0){
563+
LM_DBG("Parsed Message, executing Local-Request Route "
564+
"with Message...\n");
565+
run_top_route(sroutes->request[tm_local_request_route->idx],
566+
&dummy_msg);
565567
}
566568
free_sip_msg(&dummy_msg);
567569
}

modules/tm/uac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/* Pass provisional replies to fifo applications */
3636
extern int pass_provisional_replies;
37-
extern struct script_route_ref *tm_local_request;
37+
extern struct script_route_ref *tm_local_request_route;
3838

3939
/*
4040
* Function prototypes

0 commit comments

Comments
 (0)