Browse code

- statefull replies are sent out exactly on the same interface on which the request was received; - note that the previous version was broken since get_send_socket(request) was called to determin the outgoing interface for relies; this was leading to sending back replies on the forced interfaced set for request forwarding!

Bogdan-Andrei Iancu authored on 01/03/2005 11:22:09
Showing 2 changed files
... ...
@@ -77,6 +77,8 @@
77 77
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
78 78
  * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
79 79
  * 2004-10-10: use of mhomed disabled for replies (jiri)
80
+ * 2005-02-01: use the incoming request interface for sending the replies
81
+ *             - changes in init_rb() (bogdan)
80 82
  */
81 83
 
82 84
 #include "defs.h"
... ...
@@ -907,7 +909,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
907 909
 
908 910
 int init_rb( struct retr_buf *rb, struct sip_msg *msg)
909 911
 {
910
-	struct socket_info* send_sock;
912
+	/*struct socket_info* send_sock;*/
911 913
 	struct via_body* via;
912 914
 	int proto;
913 915
 	int backup_mhomed;
... ...
@@ -933,17 +935,17 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
933 935
 	*/
934 936
 	backup_mhomed=mhomed;
935 937
 	mhomed=0;
936
-	send_sock=get_send_socket(msg, &rb->dst.to, proto);
937 938
 	mhomed=backup_mhomed;
939
+	/* use for sending replies the incoming interface of the request -bogdan */
940
+	/*send_sock=get_send_socket(msg, &rb->dst.to, proto);
938 941
 	if (send_sock==0) {
939 942
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d, proto %d "
940 943
 			"no socket\n", rb->dst.to.s.sa_family, proto);
941 944
 		ser_error=E_BAD_VIA;
942 945
 		return 0;
943
-	}
944
-	rb->dst.send_sock=send_sock;
945
-	
946
-    return 1;
946
+	}*/
947
+	rb->dst.send_sock=msg->rcv.bind_address;
948
+	return 1;
947 949
 }
948 950
 
949 951
 
... ...
@@ -62,6 +62,8 @@
62 62
  *  2004-02-18  fifo_t_reply imported from vm module (bogdan)
63 63
  *  2004-08-23  avp list is available from failure/on_reply routes (bogdan)
64 64
  *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
65
+ *  2005-03-01  force for statefull replies the incoming interface of 
66
+ *              the request (bogdan)
65 67
  */
66 68
 
67 69
 
... ...
@@ -408,13 +410,17 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
408 410
 	/* first check if we managed to resolve topmost Via -- if
409 411
 	   not yet, don't try to retransmit
410 412
 	*/
413
+	/*
414
+	   response.dst.send_sock is valid all the time now, as it's taken
415
+	   from original request -bogdan
411 416
 	if (!trans->uas.response.dst.send_sock) {
412 417
 		LOG(L_ERR, "ERROR: _reply_light: no resolved dst to send reply to\n");
413 418
 	} else {
414
-		SEND_PR_BUFFER( rb, buf, len );
415
-		DBG("DEBUG: reply sent out. buf=%p: %.9s..., shmem=%p: %.9s\n", 
416
-			buf, buf, rb->buffer, rb->buffer );
417
-	}
419
+	*/
420
+	assert(trans->uas.response.dst.send_sock);
421
+	SEND_PR_BUFFER( rb, buf, len );
422
+	DBG("DEBUG: reply sent out. buf=%p: %.9s..., shmem=%p: %.9s\n", 
423
+		buf, buf, rb->buffer, rb->buffer );
418 424
 	pkg_free( buf ) ;
419 425
 	DBG("DEBUG: _reply_light: finished\n");
420 426
 	return 1;
... ...
@@ -847,11 +853,15 @@ int t_retransmit_reply( struct cell *t )
847 853
 	/* first check if we managed to resolve topmost Via -- if
848 854
 	   not yet, don't try to retransmit
849 855
 	*/
856
+	/* response.dst.send_sock is valid all the time now, as it's taken
857
+	   from original request -bogdan
850 858
 	if (!t->uas.response.dst.send_sock) {
851 859
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
852 860
 			"no resolved dst to retransmit\n");
853 861
 		return -1;
854 862
 	}
863
+	*/
864
+	assert(t->uas.response.dst.send_sock);
855 865
 
856 866
 	/* we need to lock the transaction as messages from
857 867
 	   upstream may change it continuously