Explorar o código

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).
Andrei Pelinescu-Onciul %!s(int64=16) %!d(string=hai) anos
pai
achega
bf0a0d42e8
Modificáronse 4 ficheiros con 22 adicións e 11 borrados
  1. 6 3
      modules/tm/t_fwd.c
  2. 1 0
      modules/tm/t_lookup.c
  3. 3 3
      modules/tm/uac.c
  4. 12 5
      modules/tm/ut.h

+ 6 - 3
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 =
 		t->uac[branch].request.dst.send_sock =
 		get_send_socket( request, &t->uac[branch].request.dst.to,
 		get_send_socket( request, &t->uac[branch].request.dst.to,
 								t->uac[branch].request.dst.proto);
 								t->uac[branch].request.dst.proto);
+		t->uac[branch].request.dst.send_flags=request?
+												request->fwd_send_flags:0;
 	}else {
 	}else {
 #ifdef USE_DNS_FAILOVER
 #ifdef USE_DNS_FAILOVER
 		if (uri2dst(&t->uac[branch].dns_h, &t->uac[branch].request.dst,
 		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;
 	} else try_new=0;
 
 
 	init_branch_iterator();
 	init_branch_iterator();
-	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len, &si))) {
+	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s,
+										&dst_uri.len, &si))) {
 		try_new++;
 		try_new++;
 		p_msg->force_send_socket = si;
 		p_msg->force_send_socket = si;
 		getbflagsval(get_branch_iterator(), &bflags);
 		getbflagsval(get_branch_iterator(), &bflags);
 		setbflagsval(0, bflags);
 		setbflagsval(0, bflags);
 
 
 		branch_ret=add_uac( t, p_msg, &current_uri, 
 		branch_ret=add_uac( t, p_msg, &current_uri, 
-				    (dst_uri.len) ? (&dst_uri) : &current_uri, 
-				    proxy, proto);
+							(dst_uri.len) ? (&dst_uri) : &current_uri, 
+							proxy, proto);
 		/* pick some of the errors in case things go wrong;
 		/* pick some of the errors in case things go wrong;
 		   note that picking lowest error is just as good as
 		   note that picking lowest error is just as good as
 		   any other algorithm which picks any other negative
 		   any other algorithm which picks any other negative

+ 1 - 0
modules/tm/t_lookup.c

@@ -1218,6 +1218,7 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
 #ifdef USE_COMP
 #ifdef USE_COMP
 	rb->dst.comp=via->comp_no;
 	rb->dst.comp=via->comp_no;
 #endif
 #endif
+	rb->dst.send_flags=msg->rpl_send_flags;
 	/* turn off mhomed for generating replies -- they are ideally sent to where
 	/* turn off mhomed for generating replies -- they are ideally sent to where
 	   request came from to make life with NATs and other beasts easier
 	   request came from to make life with NATs and other beasts easier
 	*/
 	*/

+ 3 - 3
modules/tm/uac.c

@@ -238,7 +238,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 #ifdef USE_DNS_FAILOVER
 #ifdef USE_DNS_FAILOVER
 	if (cfg_get(core, core_cfg, use_dns_failover)){
 	if (cfg_get(core, core_cfg, use_dns_failover)){
 		dns_srv_handle_init(&dns_h);
 		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)
 							uac_r->dialog->hooks.next_hop, PROTO_NONE)==0)
 				|| (dst.send_sock==0)){
 				|| (dst.send_sock==0)){
 			dns_srv_handle_put(&dns_h);
 			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 */
 		dns_srv_handle_put(&dns_h); /* not needed anymore */
 	}else{
 	}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) ||
 						uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
 				(dst.send_sock==0)){
 				(dst.send_sock==0)){
 			ser_error = E_NO_SOCKET;
 			ser_error = E_NO_SOCKET;
@@ -259,7 +259,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 		}
 		}
 	}
 	}
 #else /* USE_DNS_FAILOVER */
 #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) ||
 					uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
 			(dst.send_sock==0)){
 			(dst.send_sock==0)){
 		ser_error = E_NO_SOCKET;
 		ser_error = E_NO_SOCKET;

+ 12 - 5
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
  *         dst   - will be filled
  *         force_send_sock - if 0 dst->send_sock will be set to the default 
  *         force_send_sock - if 0 dst->send_sock will be set to the default 
  *                 (see get_send_socket2()) 
  *                 (see get_send_socket2()) 
+ *         sflags - send flags
  *         uri   - uri in str form
  *         uri   - uri in str form
  *         proto - if != PROTO_NONE, this protocol will be forced over the
  *         proto - if != PROTO_NONE, this protocol will be forced over the
  *                 uri_proto, otherwise the uri proto will be used if set or
  *                 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,
 inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
 										struct dest_info* dst,
 										struct dest_info* dst,
 										struct socket_info *force_send_socket,
 										struct socket_info *force_send_socket,
+										snd_flags_t sflags,
 										str *uri, int proto )
 										str *uri, int proto )
 #else
 #else
 inline static struct dest_info *uri2dst2(struct dest_info* dst,
 inline static struct dest_info *uri2dst2(struct dest_info* dst,
 										struct socket_info *force_send_socket,
 										struct socket_info *force_send_socket,
+										snd_flags_t sflags,
 										str *uri, int proto )
 										str *uri, int proto )
 #endif
 #endif
 {
 {
@@ -268,6 +271,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
 #ifdef USE_COMP
 #ifdef USE_COMP
 	dst->comp=parsed_uri.comp;
 	dst->comp=parsed_uri.comp;
 #endif
 #endif
+	dst->send_flags=sflags;
 #ifdef HONOR_MADDR
 #ifdef HONOR_MADDR
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
 		host=&parsed_uri.maddr_val;
 		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
  *                 null. If null or use_dns_failover==0 normal dns lookup will
  *                 be performed (no failover).
  *                 be performed (no failover).
  *         dst   - will be filled
  *         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
  *         uri   - uri in str form
  *         proto - if != PROTO_NONE, this protocol will be forced over the
  *         proto - if != PROTO_NONE, this protocol will be forced over the
  *                 uri_proto, otherwise the uri proto will be used if set or
  *                 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, 
 										struct sip_msg *msg, str *uri, 
 											int proto )
 											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
 #else
 inline static struct dest_info *uri2dst(struct dest_info* dst,
 inline static struct dest_info *uri2dst(struct dest_info* dst,
 										struct sip_msg *msg, str *uri, 
 										struct sip_msg *msg, str *uri, 
 											int proto )
 											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 */
 #endif /* USE_DNS_FAILOVER */