Browse Source

- Support for force_send_socket in the destination set. That allows to specify
the outbound socket for every branch when doing parallel forking.
- Modules aligned to new prototypes of append_branch and next_branch functions.

Jan Janak 20 years ago
parent
commit
dc4b13e870
4 changed files with 21 additions and 8 deletions
  1. 1 1
      action.c
  2. 15 4
      dset.c
  3. 4 2
      dset.h
  4. 1 1
      modules/tm/t_fwd.c

+ 1 - 1
action.c

@@ -285,7 +285,7 @@ int do_action(struct action* a, struct sip_msg* msg)
 			}
 			ret=append_branch( msg, a->p1.string, 
 					   a->p1.string ? strlen(a->p1.string):0,
-					   0, 0, a->p2.number);
+					   0, 0, a->p2.number, 0);
 			break;
 
 		/* jku begin: is_length_greater_than */

+ 15 - 4
dset.c

@@ -37,6 +37,7 @@
 #include "error.h"
 #include "dset.h"
 #include "mem/mem.h"
+#include "ip_addr.h"
 
 #define CONTACT "Contact: "
 #define CONTACT_LEN (sizeof(CONTACT) - 1)
@@ -58,6 +59,7 @@ struct branch
 
 	int q; /* Preference of the contact among
 		* contact within the array */
+	struct socket_info* force_send_socket;
 };
 
 
@@ -93,7 +95,7 @@ void init_branch_iterator(void)
  * array, 0 is returned if there are no
  * more branches
  */
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket)
 {
 	unsigned int i;
 
@@ -106,6 +108,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
 			*dst_uri = branches[i].dst_uri;
 			*dst_len = branches[i].dst_uri_len;
 		}
+		if (force_socket) {
+			*force_socket = branches[i].force_send_socket;
+		}
 		return branches[i].uri;
 	} else {
 		*len = 0;
@@ -114,6 +119,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
 			*dst_uri = 0;
 			*dst_len = 0;
 		}
+		if (force_socket) {
+			*force_socket = 0;
+		}
 		return 0;
 	}
 }
@@ -132,7 +140,8 @@ void clear_branches(void)
 /* 
  * Add a new branch to current transaction 
  */
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q)
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
+		  qvalue_t q, struct socket_info* force_socket)
 {
 	     /* if we have already set up the maximum number
 	      * of branches, don't try new ones 
@@ -175,6 +184,8 @@ int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, in
  		branches[nr_branches].dst_uri_len = 0;
 	}
 
+	branches[nr_branches].force_send_socket = force_socket;
+	
 	nr_branches++;
 	return 1;
 }
@@ -205,7 +216,7 @@ char* print_dset(struct sip_msg* msg, int* len)
 	}
 
 	init_branch_iterator();
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
 		cnt++;
 		*len += uri.len;
 		if (q != Q_UNSPECIFIED) {
@@ -246,7 +257,7 @@ char* print_dset(struct sip_msg* msg, int* len)
 	}
 
 	init_branch_iterator();
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
 		if (i) {
 			memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
 			p += CONTACT_DELIM_LEN;

+ 4 - 2
dset.h

@@ -28,6 +28,7 @@
 #ifndef _DSET_H
 #define _DSET_H
 
+#include "ip_addr.h"
 #include "qvalue.h"
 
 struct sip_msg;
@@ -38,7 +39,8 @@ extern unsigned int nr_branches;
 /* 
  * Add a new branch to current transaction 
  */
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q);
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
+		  qvalue_t q, struct socket_info* force_socket);
 
 
 /* 
@@ -50,7 +52,7 @@ void init_branch_iterator(void);
 /*
  * Get the next branch in the current transaction
  */
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len);
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket);
 
 
 /*

+ 1 - 1
modules/tm/t_fwd.c

@@ -445,7 +445,7 @@ 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( &current_uri.len, &q, &dst_uri.s, &dst_uri.len))) {
+	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len, 0))) {
 		try_new++;
 		branch_ret=add_uac( t, p_msg, &current_uri, 
 				    (dst_uri.len) ? (&dst_uri) : &current_uri,