Module: sip-router Branch: andrei/send_flags Commit: bf0a0d42e810f6f8c3999b7f3f2b668ae0bad1d6 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bf0a0d42...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Tue Sep 15 17:43:24 2009 +0200
tm: support for send_flags
The send_flags are taken from the current message and added to the retr_bufs (for branch uacs and replies).
---
modules/tm/t_fwd.c | 9 ++++++--- modules/tm/t_lookup.c | 1 + modules/tm/uac.c | 6 +++--- modules/tm/ut.h | 17 ++++++++++++----- 4 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c index bb0cf61..5f5cb42 100644 --- a/modules/tm/t_fwd.c +++ b/modules/tm/t_fwd.c @@ -413,6 +413,8 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop, t->uac[branch].request.dst.send_sock = get_send_socket( request, &t->uac[branch].request.dst.to, t->uac[branch].request.dst.proto); + t->uac[branch].request.dst.send_flags=request? + request->fwd_send_flags:0; }else { #ifdef USE_DNS_FAILOVER if (uri2dst(&t->uac[branch].dns_h, &t->uac[branch].request.dst, @@ -1083,15 +1085,16 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg , } else try_new=0;
init_branch_iterator(); - while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri.s, &dst_uri.len, &si))) { + while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri.s, + &dst_uri.len, &si))) { try_new++; p_msg->force_send_socket = si; getbflagsval(get_branch_iterator(), &bflags); setbflagsval(0, bflags);
branch_ret=add_uac( t, p_msg, ¤t_uri, - (dst_uri.len) ? (&dst_uri) : ¤t_uri, - proxy, proto); + (dst_uri.len) ? (&dst_uri) : ¤t_uri, + proxy, proto); /* pick some of the errors in case things go wrong; note that picking lowest error is just as good as any other algorithm which picks any other negative diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c index 72c14c7..1fe5755 100644 --- a/modules/tm/t_lookup.c +++ b/modules/tm/t_lookup.c @@ -1218,6 +1218,7 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg) #ifdef USE_COMP rb->dst.comp=via->comp_no; #endif + rb->dst.send_flags=msg->rpl_send_flags; /* turn off mhomed for generating replies -- they are ideally sent to where request came from to make life with NATs and other beasts easier */ diff --git a/modules/tm/uac.c b/modules/tm/uac.c index e070cd5..cd3e1e9 100644 --- a/modules/tm/uac.c +++ b/modules/tm/uac.c @@ -238,7 +238,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r, #ifdef USE_DNS_FAILOVER if (cfg_get(core, core_cfg, use_dns_failover)){ dns_srv_handle_init(&dns_h); - if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock, + if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock, 0, uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) || (dst.send_sock==0)){ dns_srv_handle_put(&dns_h); @@ -249,7 +249,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r, } dns_srv_handle_put(&dns_h); /* not needed anymore */ }else{ - if ((uri2dst2(0, &dst, uac_r->dialog->send_sock, + if ((uri2dst2(0, &dst, uac_r->dialog->send_sock, 0, uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) || (dst.send_sock==0)){ ser_error = E_NO_SOCKET; @@ -259,7 +259,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r, } } #else /* USE_DNS_FAILOVER */ - if ((uri2dst2(&dst, uac_r->dialog->send_sock, + if ((uri2dst2(&dst, uac_r->dialog->send_sock, 0, uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) || (dst.send_sock==0)){ ser_error = E_NO_SOCKET; diff --git a/modules/tm/ut.h b/modules/tm/ut.h index 0c7afaf..e0cabcf 100644 --- a/modules/tm/ut.h +++ b/modules/tm/ut.h @@ -221,6 +221,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port, * dst - will be filled * force_send_sock - if 0 dst->send_sock will be set to the default * (see get_send_socket2()) + * sflags - send flags * uri - uri in str form * proto - if != PROTO_NONE, this protocol will be forced over the * uri_proto, otherwise the uri proto will be used if set or @@ -231,10 +232,12 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port, inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h, struct dest_info* dst, struct socket_info *force_send_socket, + snd_flags_t sflags, str *uri, int proto ) #else inline static struct dest_info *uri2dst2(struct dest_info* dst, struct socket_info *force_send_socket, + snd_flags_t sflags, str *uri, int proto ) #endif { @@ -268,6 +271,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst, #ifdef USE_COMP dst->comp=parsed_uri.comp; #endif + dst->send_flags=sflags; #ifdef HONOR_MADDR if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) { host=&parsed_uri.maddr_val; @@ -336,9 +340,10 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst, * null. If null or use_dns_failover==0 normal dns lookup will * be performed (no failover). * dst - will be filled - * msg - sip message used to set dst->send_sock, if 0 dst->send_sock - * will be set to the default w/o using msg->force_send_socket - * (see get_send_socket()) + * msg - sip message used to set dst->send_sock and dst->send_flags, + * if 0 dst->send_sock will be set to the default w/o using + * msg->force_send_socket (see get_send_socket()) and the + * send_flags will be set to 0. * uri - uri in str form * proto - if != PROTO_NONE, this protocol will be forced over the * uri_proto, otherwise the uri proto will be used if set or @@ -351,14 +356,16 @@ inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h, struct sip_msg *msg, str *uri, int proto ) { - return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, uri, proto); + return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, + msg?msg->fwd_send_flags:0, uri, proto); } #else inline static struct dest_info *uri2dst(struct dest_info* dst, struct sip_msg *msg, str *uri, int proto ) { - return uri2dst2(dst, msg?msg->force_send_socket:0, uri, proto); + return uri2dst2(dst, msg?msg->force_send_socket:0, + msg?msg->fwd_send_flags:0, uri, proto); } #endif /* USE_DNS_FAILOVER */