Module: sip-router
Branch: kamailio_3.0
Commit: cb1866ee7b23688d12b222d503b1709f16f75a12
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cb1866e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Dec 23 17:34:09 2009 +0100
tm: updated doc for t_drop_replies()
---
modules/tm/README | 15 ++++++++++-----
modules/tm/doc/functions.xml | 13 ++++++++++---
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/modules/tm/README b/modules/tm/README
index 64ede44..a257952 100644
--- a/modules/tm/README
+++ b/modules/tm/README
@@ -96,7 +96,7 @@ Juha Heinanen
1.5.26. t_is_expired()
1.5.27. t_relay_cancel()
1.5.28. t_lookup_cancel(), t_lookup_cancel(1)
- 1.5.29. t_drop_replies()
+ 1.5.29. t_drop_replies([mode])
1.5.30. t_save_lumps()
1.5.31. t_load_contacts()
1.5.32. t_next_contacts()
@@ -1718,12 +1718,17 @@ if (method == CANCEL) {
# do the same as for INVITEs
}
-1.5.29. t_drop_replies()
+1.5.29. t_drop_replies([mode])
Drops all the previously received replies in failure_route block to
- make sure that none of them is picked up again. Works only if a new
- branch is added to the transaction, or it is explicitly replied in the
- script!
+ make sure that none of them is picked up again.
+
+ The parameter 'mode' controls which replies are dropped: 'a' or missing
+ - all replies are dropped; 'l' - replies received for last set of
+ branches are dropped; 'n' - no reply is dropped.
+
+ Dropping replies works only if a new branch is added to the
+ transaction, or it is explicitly replied in the script!
Example 66. t_drop_replies() usage
...
diff --git a/modules/tm/doc/functions.xml b/modules/tm/doc/functions.xml
index c8f09d7..5aee3bb 100644
--- a/modules/tm/doc/functions.xml
+++ b/modules/tm/doc/functions.xml
@@ -946,13 +946,20 @@ if (method == CANCEL) {
<section id="t_drop_replies">
<title>
- <function>t_drop_replies()</function>
+ <function>t_drop_replies([mode])</function>
</title>
<para>
Drops all the previously received replies in failure_route
block to make sure that none of them is picked up again.
- Works only if a new branch is added to the transaction,
- or it is explicitly replied in the script!
+ </para>
+ <para>
+ The parameter 'mode' controls which replies are dropped: 'a'
+ or missing - all replies are dropped; 'l' - replies received for
+ last set of branches are dropped; 'n' - no reply is dropped.
+ </para>
+ <para>
+ Dropping replies works only if a new branch is added to the
+ transaction, or it is explicitly replied in the script!
</para>
<example>
<title><function>t_drop_replies()</function> usage</title>
Hi Juha!
I tried your new add_contact_alias function - some questions:
1.
+ /* Compare source ip and port against contact uri */
+ if ((ip = str2ip(&(uri.host))) == NULL) {
+ LM_ERR("contact uri host is not an ip address\n");
+ return -1;
+ }
Why do you in return -1 in case of a domain instead of adding the alias
parameter in this case too?
2. AFAIS the new functions are included in sr3.0 branch, but not in
kamailio-3.0 branch. Why?
regards
klaus
Module: sip-router
Branch: sr_3.0
Commit: 49218e800df4a349fae240733963ca4b46bdca3a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=49218e8…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Dec 23 13:16:01 2009 +0100
tm: new param: local_ack_mode
local_ack_mode controls how local 200 ACKs (ACKs to 2xx replies
for local transactions, created via t_uac*) are sent.
There are 3 possible modes:
- 0 (default) - ACK is sent according to the rfc (the next hop is
found using the contact and the route set and then dns
resolution is used on it).
- 1 - the ACK is sent to the same address as the corresponding
INVITE branch.
- 2 - the ACL is sent to the same address as the source of the 2xx
reply.
Modes 1 and 2 break the rfc, but are useful to deal with
some simple UA behind the NAT cases.
Note that mode 1 is not similar to generating ACKs for negative
replies. Even if the ACK will be sent to the same address as the
INVITE, it will contain the correct route set and uri.
---
modules/tm/config.c | 10 +++++++-
modules/tm/config.h | 1 +
modules/tm/t_msgbuilder.c | 56 +++++++++++++++++++++++++++++----------------
modules/tm/tm.c | 1 +
4 files changed, 47 insertions(+), 21 deletions(-)
diff --git a/modules/tm/config.c b/modules/tm/config.c
index 1ecb5ac..654153d 100644
--- a/modules/tm/config.c
+++ b/modules/tm/config.c
@@ -91,7 +91,8 @@ struct cfg_group_tm default_tm_cfg = {
* for every method except BYE by default */
1, /* cancel_b_method used for e2e and 6xx cancels*/
1, /* reparse_on_dns_failover */
- 0 /* disable_6xx, by default off */
+ 0, /* disable_6xx, by default off */
+ 0 /* local_ack_mode, default 0 (rfc3261 conformant) */
};
void *tm_cfg = &default_tm_cfg;
@@ -186,5 +187,12 @@ cfg_def_t tm_cfg_def[] = {
"branch instead of from the received request"},
{"disable_6xx_block", CFG_VAR_INT | CFG_ATOMIC, 0, 1, 0, 0,
"if set to 1, 6xx is treated like a normal reply (breaks rfc)"},
+ {"local_ack_mode", CFG_VAR_INT | CFG_ATOMIC, 0, 2, 0, 0,
+ "if set to 1 or 2, local 200 ACKs are sent to the same address as the"
+ " corresponding INVITE (1) or the source of the 200 reply (2) instead"
+ " of using the contact and the route set (it breaks the rfc, if "
+ " it is not set to 0 but allows dealing with NATed contacts in some "
+ "simple cases)"
+ },
{0, 0, 0, 0, 0, 0}
};
diff --git a/modules/tm/config.h b/modules/tm/config.h
index 91edf42..cfdd41f 100644
--- a/modules/tm/config.h
+++ b/modules/tm/config.h
@@ -134,6 +134,7 @@ struct cfg_group_tm {
unsigned int cancel_b_flags;
int reparse_on_dns_failover;
int disable_6xx;
+ int local_ack_mode;
};
extern struct cfg_group_tm default_tm_cfg;
diff --git a/modules/tm/t_msgbuilder.c b/modules/tm/t_msgbuilder.c
index c0160b9..b76c659 100644
--- a/modules/tm/t_msgbuilder.c
+++ b/modules/tm/t_msgbuilder.c
@@ -982,33 +982,49 @@ char *build_dlg_ack(struct sip_msg* rpl, struct cell *Trans,
*len = SIP_VERSION_LEN + ACK_LEN + 2 /* spaces */ + CRLF_LEN;
*len += ruri.len;
-
- /* via */
+ /* dst */
+ switch(cfg_get(tm, tm_cfg, local_ack_mode)){
+ case 1:
+ /* send the local 200 ack to the same dst as the corresp. invite*/
+ *dst=Trans->uac[branch].request.dst;
+ break;
+ case 2:
+ /* send the local 200 ack to the same dst as the 200 reply source*/
+ init_dst_from_rcv(dst, &rpl->rcv);
+ dst->send_flags=rpl->fwd_send_flags;
+ break;
+ case 0:
+ default:
+ /* rfc conformant behaviour: use the next_hop determined from the
+ contact and the route set */
#ifdef USE_DNS_FAILOVER
- if (cfg_get(core, core_cfg, use_dns_failover)){
- dns_srv_handle_init(&dns_h);
- if ((uri2dst(&dns_h , dst, rpl, &next_hop, PROTO_NONE)==0) ||
- (dst->send_sock==0)){
- dns_srv_handle_put(&dns_h);
- LOG(L_ERR, "build_dlg_ack: no socket found\n");
- goto error;
+ if (cfg_get(core, core_cfg, use_dns_failover)){
+ dns_srv_handle_init(&dns_h);
+ if ((uri2dst(&dns_h , dst, rpl, &next_hop, PROTO_NONE)==0) ||
+ (dst->send_sock==0)){
+ dns_srv_handle_put(&dns_h);
+ LOG(L_ERR, "build_dlg_ack: no socket found\n");
+ goto error;
+ }
+ dns_srv_handle_put(&dns_h); /* not needed any more */
+ }else{
+ if ((uri2dst(0 , dst, rpl, &next_hop, PROTO_NONE)==0) ||
+ (dst->send_sock==0)){
+ LOG(L_ERR, "build_dlg_ack: no socket found\n");
+ goto error;
+ }
}
- dns_srv_handle_put(&dns_h); /* not needed any more */
- }else{
- if ((uri2dst(0 , dst, rpl, &next_hop, PROTO_NONE)==0) ||
+#else /* USE_DNS_FAILOVER */
+ if ( (uri2dst( dst, rpl, &next_hop, PROTO_NONE)==0) ||
(dst->send_sock==0)){
- LOG(L_ERR, "build_dlg_ack: no socket found\n");
+ LOG(L_ERR, "build_dlg_ack: no socket found\n");
goto error;
}
+#endif /* USE_DNS_FAILOVER */
+ break;
}
-#else
- if ( (uri2dst( dst, rpl, &next_hop, PROTO_NONE)==0) ||
- (dst->send_sock==0)){
- LOG(L_ERR, "build_dlg_ack: no socket found\n");
- goto error;
- }
-#endif
+ /* via */
if (!t_calc_branch(Trans, branch, branch_buf, &branch_len)) goto error;
branch_str.s = branch_buf;
branch_str.len = branch_len;
diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index 09f08c6..f4fb487 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -470,6 +470,7 @@ static param_export_t params[]={
{"on_sl_reply", PARAM_STRING|PARAM_USE_FUNC, fixup_on_sl_reply },
{"contacts_avp", PARAM_STRING, &contacts_avp_param },
{"disable_6xx_block", PARAM_INT, &default_tm_cfg.disable_6xx },
+ {"local_ack_mode", PARAM_INT, &default_tm_cfg.local_ack_mode },
{0,0,0}
};
Hi!
I sr code I found several methods how RURI is set, eg:
- rewrite_uri()
- act.type = SET_URI_T;
do_action(&act, msg)
- manually by applying a lump
What is the preferred way to do this?
Thanks
klaus