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 59
 
59 60
 	int q; /* Preference of the contact among
60 61
 		* contact within the array */
62
+	struct socket_info* force_send_socket;
61 63
 };
62 64
 
63 65
 
... ...
@@ -93,7 +95,7 @@ void init_branch_iterator(void)
93 95
  * array, 0 is returned if there are no
94 96
  * more branches
95 97
  */
96
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
98
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket)
97 99
 {
98 100
 	unsigned int i;
99 101
 
... ...
@@ -106,6 +108,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
106 108
 			*dst_uri = branches[i].dst_uri;
107 109
 			*dst_len = branches[i].dst_uri_len;
108 110
 		}
111
+		if (force_socket) {
112
+			*force_socket = branches[i].force_send_socket;
113
+		}
109 114
 		return branches[i].uri;
110 115
 	} else {
111 116
 		*len = 0;
... ...
@@ -114,6 +119,9 @@ char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len)
114 119
 			*dst_uri = 0;
115 120
 			*dst_len = 0;
116 121
 		}
122
+		if (force_socket) {
123
+			*force_socket = 0;
124
+		}
117 125
 		return 0;
118 126
 	}
119 127
 }
... ...
@@ -132,7 +140,8 @@ void clear_branches(void)
132 140
 /* 
133 141
  * Add a new branch to current transaction 
134 142
  */
135
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q)
143
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
144
+		  qvalue_t q, struct socket_info* force_socket)
136 145
 {
137 146
 	     /* if we have already set up the maximum number
138 147
 	      * 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 184
  		branches[nr_branches].dst_uri_len = 0;
176 185
 	}
177 186
 
187
+	branches[nr_branches].force_send_socket = force_socket;
188
+	
178 189
 	nr_branches++;
179 190
 	return 1;
180 191
 }
... ...
@@ -205,7 +216,7 @@ char* print_dset(struct sip_msg* msg, int* len)
205 216
 	}
206 217
 
207 218
 	init_branch_iterator();
208
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
219
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
209 220
 		cnt++;
210 221
 		*len += uri.len;
211 222
 		if (q != Q_UNSPECIFIED) {
... ...
@@ -246,7 +257,7 @@ char* print_dset(struct sip_msg* msg, int* len)
246 257
 	}
247 258
 
248 259
 	init_branch_iterator();
249
-	while ((uri.s = next_branch(&uri.len, &q, 0, 0))) {
260
+	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0))) {
250 261
 		if (i) {
251 262
 			memcpy(p, CONTACT_DELIM, CONTACT_DELIM_LEN);
252 263
 			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 39
 /* 
39 40
  * Add a new branch to current transaction 
40 41
  */
41
-int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, qvalue_t q);
42
+int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, int dst_uri_len, 
43
+		  qvalue_t q, struct socket_info* force_socket);
42 44
 
43 45
 
44 46
 /* 
... ...
@@ -50,7 +52,7 @@ void init_branch_iterator(void);
50 52
 /*
51 53
  * Get the next branch in the current transaction
52 54
  */
53
-char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len);
55
+char* next_branch(int* len, qvalue_t* q, char** dst_uri, int* dst_len, struct socket_info** force_socket);
54 56
 
55 57
 
56 58
 /*
... ...
@@ -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,