Browse code

- 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 authored on 26/02/2005 15:29:03
Showing 4 changed files
... ...
@@ -285,7 +285,7 @@ int do_action(struct action* a, struct sip_msg* msg)
285 285
 			}
286 286
 			ret=append_branch( msg, a->p1.string, 
287 287
 					   a->p1.string ? strlen(a->p1.string):0,
288
-					   0, 0, a->p2.number);
288
+					   0, 0, a->p2.number, 0);
289 289
 			break;
290 290
 
291 291
 		/* jku begin: is_length_greater_than */
... ...
@@ -37,6 +37,7 @@
37 37
 #include "error.h"
38 38
 #include "dset.h"
39 39
 #include "mem/mem.h"
40
+#include "ip_addr.h"
40 41
 
41 42
 #define CONTACT "Contact: "
42 43
 #define CONTACT_LEN (sizeof(CONTACT) - 1)
... ...
@@ -58,6 +59,7 @@ struct branch
58 58
 
59 59
 	int q; /* Preference of the contact among
60 60
 		* contact within the array */
61
+	struct socket_info* force_send_socket;
61 62
 };
62 63
 
63 64
 
... ...
@@ -93,7 +95,7 @@ void init_branch_iterator(void)
93 93
  * array, 0 is returned if there are no
94 94
  * more branches
95 95
  */
96
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
96
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket)
97 97
 {
98 98
 	unsigned int i;
99 99
 
... ...
@@ -106,6 +108,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
106 106
 			*dst_uri = branches[i].dst_uri;
107 107
 			*dst_len = branches[i].dst_uri_len;
108 108
 		}
109
+		if (force_socket) {
110
+			*force_socket = branches[i].force_send_socket;
111
+		}
109 112
 		return branches[i].uri;
110 113
 	} else {
111 114
 		*len = 0;
... ...
@@ -114,6 +119,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
114 114
 			*dst_uri = 0;
115 115
 			*dst_len = 0;
116 116
 		}
117
+		if (force_socket) {
118
+			*force_socket = 0;
119
+		}
117 120
 		return 0;
118 121
 	}
119 122
 }
... ...
@@ -132,7 +140,8 @@ void clear_branches(void)
132 132
 /* 
133 133
  * Add a new branch to current transaction 
134 134
  */
135
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q)
135
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
136
+		  qvalue_t q, struct socket_info* force_socket)
136 137
 {
137 138
 	     /* if we have already set up the maximum number
138 139
 	      * 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
175 175
  		branches[nr_branches].dst_uri_len = 0;
176 176
 	}
177 177
 
178
+	branches[nr_branches].force_send_socket = force_socket;
179
+	
178 180
 	nr_branches++;
179 181
 	return 1;
180 182
 }
... ...
@@ -205,7 +216,7 @@ char* print_dset(struct sip_msg* msg, int* len)
205 205
 	}
206 206
 
207 207
 	init_branch_iterator();
208
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
208
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
209 209
 		cnt++;
210 210
 		*len += uri.len;
211 211
 		if (q != Q_UNSPECIFIED) {
... ...
@@ -246,7 +257,7 @@ char* print_dset(struct sip_msg* msg, int* len)
246 246
 	}
247 247
 
248 248
 	init_branch_iterator();
249
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
249
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
250 250
 		if (i) {
251 251
 			memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
252 252
 			p += CONTACT_DELIM_LEN;
... ...
@@ -28,6 +28,7 @@
28 28
 #ifndef _DSET_H
29 29
 #define _DSET_H
30 30
 
31
+#include "ip_addr.h"
31 32
 #include "qvalue.h"
32 33
 
33 34
 struct sip_msg;
... ...
@@ -38,7 +39,8 @@ extern unsigned int nr_branches;
38 38
 /* 
39 39
  * Add a new branch to current transaction 
40 40
  */
41
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q);
41
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
42
+		  qvalue_t q, struct socket_info* force_socket);
42 43
 
43 44
 
44 45
 /* 
... ...
@@ -50,7 +52,7 @@ void init_branch_iterator(void);
50 50
 /*
51 51
  * Get the next branch in the current transaction
52 52
  */
53
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len);
53
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket);
54 54
 
55 55
 
56 56
 /*
... ...
@@ -445,7 +445,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
445 445
 	} else try_new=0;
446 446
 
447 447
 	init_branch_iterator();
448
-	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len))) {
448
+	while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len, 0))) {
449 449
 		try_new++;
450 450
 		branch_ret=add_uac( t, p_msg, &current_uri, 
451 451
 				    (dst_uri.len) ? (&dst_uri) : &current_uri,