Browse code

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 authored on 15/09/2009 15:43:24
Showing 4 changed files
... ...
@@ -413,6 +413,8 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
413 413
 		t->uac[branch].request.dst.send_sock =
414 414
 		get_send_socket( request, &t->uac[branch].request.dst.to,
415 415
 								t->uac[branch].request.dst.proto);
416
+		t->uac[branch].request.dst.send_flags=request?
417
+												request->fwd_send_flags:0;
416 418
 	}else {
417 419
 #ifdef USE_DNS_FAILOVER
418 420
 		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 ,
1083 1085
 	} else try_new=0;
1084 1086
 
1085 1087
 	init_branch_iterator();
1086
-	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len, &si))) {
1088
+	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s,
1089
+										&dst_uri.len, &si))) {
1087 1090
 		try_new++;
1088 1091
 		p_msg->force_send_socket = si;
1089 1092
 		getbflagsval(get_branch_iterator(), &bflags);
1090 1093
 		setbflagsval(0, bflags);
1091 1094
 
1092 1095
 		branch_ret=add_uac( t, p_msg, &current_uri, 
1093
-				    (dst_uri.len) ? (&dst_uri) : &current_uri, 
1094
-				    proxy, proto);
1096
+							(dst_uri.len) ? (&dst_uri) : &current_uri, 
1097
+							proxy, proto);
1095 1098
 		/* pick some of the errors in case things go wrong;
1096 1099
 		   note that picking lowest error is just as good as
1097 1100
 		   any other algorithm which picks any other negative
... ...
@@ -1218,6 +1218,7 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
1218 1218
 #ifdef USE_COMP
1219 1219
 	rb->dst.comp=via->comp_no;
1220 1220
 #endif
1221
+	rb->dst.send_flags=msg->rpl_send_flags;
1221 1222
 	/* turn off mhomed for generating replies -- they are ideally sent to where
1222 1223
 	   request came from to make life with NATs and other beasts easier
1223 1224
 	*/
... ...
@@ -238,7 +238,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
238 238
 #ifdef USE_DNS_FAILOVER
239 239
 	if (cfg_get(core, core_cfg, use_dns_failover)){
240 240
 		dns_srv_handle_init(&dns_h);
241
-		if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock,
241
+		if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock, 0,
242 242
 							uac_r->dialog->hooks.next_hop, PROTO_NONE)==0)
243 243
 				|| (dst.send_sock==0)){
244 244
 			dns_srv_handle_put(&dns_h);
... ...
@@ -249,7 +249,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
249 249
 		}
250 250
 		dns_srv_handle_put(&dns_h); /* not needed anymore */
251 251
 	}else{
252
-		if ((uri2dst2(0, &dst, uac_r->dialog->send_sock,
252
+		if ((uri2dst2(0, &dst, uac_r->dialog->send_sock, 0,
253 253
 						uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
254 254
 				(dst.send_sock==0)){
255 255
 			ser_error = E_NO_SOCKET;
... ...
@@ -259,7 +259,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
259 259
 		}
260 260
 	}
261 261
 #else /* USE_DNS_FAILOVER */
262
-	if ((uri2dst2(&dst, uac_r->dialog->send_sock,
262
+	if ((uri2dst2(&dst, uac_r->dialog->send_sock, 0,
263 263
 					uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
264 264
 			(dst.send_sock==0)){
265 265
 		ser_error = E_NO_SOCKET;
... ...
@@ -221,6 +221,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
221 221
  *         dst   - will be filled
222 222
  *         force_send_sock - if 0 dst->send_sock will be set to the default 
223 223
  *                 (see get_send_socket2()) 
224
+ *         sflags - send flags
224 225
  *         uri   - uri in str form
225 226
  *         proto - if != PROTO_NONE, this protocol will be forced over the
226 227
  *                 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,
231 232
 inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
232 233
 										struct dest_info* dst,
233 234
 										struct socket_info *force_send_socket,
235
+										snd_flags_t sflags,
234 236
 										str *uri, int proto )
235 237
 #else
236 238
 inline static struct dest_info *uri2dst2(struct dest_info* dst,
237 239
 										struct socket_info *force_send_socket,
240
+										snd_flags_t sflags,
238 241
 										str *uri, int proto )
239 242
 #endif
240 243
 {
... ...
@@ -268,6 +271,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
268 271
 #ifdef USE_COMP
269 272
 	dst->comp=parsed_uri.comp;
270 273
 #endif
274
+	dst->send_flags=sflags;
271 275
 #ifdef HONOR_MADDR
272 276
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
273 277
 		host=&parsed_uri.maddr_val;
... ...
@@ -336,9 +340,10 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
336 340
  *                 null. If null or use_dns_failover==0 normal dns lookup will
337 341
  *                 be performed (no failover).
338 342
  *         dst   - will be filled
339
- *         msg   -  sip message used to set dst->send_sock, if 0 dst->send_sock
340
- *                 will be set to the default w/o using msg->force_send_socket 
341
- *                 (see get_send_socket()) 
343
+ *         msg   -  sip message used to set dst->send_sock and dst->send_flags,
344
+ *                 if 0 dst->send_sock will be set to the default w/o using 
345
+ *                  msg->force_send_socket (see get_send_socket()) and the 
346
+ *                  send_flags will be set to 0.
342 347
  *         uri   - uri in str form
343 348
  *         proto - if != PROTO_NONE, this protocol will be forced over the
344 349
  *                 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,
351 356
 										struct sip_msg *msg, str *uri, 
352 357
 											int proto )
353 358
 {
354
-	return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, uri, proto);
359
+	return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0,
360
+						msg?msg->fwd_send_flags:0, uri, proto);
355 361
 }
356 362
 #else
357 363
 inline static struct dest_info *uri2dst(struct dest_info* dst,
358 364
 										struct sip_msg *msg, str *uri, 
359 365
 											int proto )
360 366
 {
361
-	return uri2dst2(dst, msg?msg->force_send_socket:0, uri, proto);
367
+	return uri2dst2(dst, msg?msg->force_send_socket:0,
368
+						msg?msg->fwd_send_flags:0, uri, proto);
362 369
 }
363 370
 #endif /* USE_DNS_FAILOVER */
364 371