Browse code

- tm tcp support (though no timers yet) changelist (random order): - forward.c: removed calls to upd_send & tcp_send & replaced them with calls to msg_send - ip_addr.h: added struct dest_info (used in tm rbs) - proxy.c: all *proxy fucntions require also the protocol - resolve.c: added proto to sip_resolvehost, for SRV lookups - tags.h: changed TOTAG_LEN into TOTAG_VALUE_LEN, to solve redefinition conflict with tm/t_msgbuilder.h - modules/sl/sl_funcs.c: modified sl_send_reply to use the transport independend msg_send - modules/tm/t_funcs.c: modified send_pr_buffer to use msg_send & rb->dst - modules/tm/t_fwd.c: added proto to various functions - modules/tm/t_lookup.c: init_rb() is proto indep. & it uses struct dest_info - modules/tm/t_msgbuilder.c: build_uac_request uses proto - modules/tm/t_reply.c: updated to use rb->dst, fixed TOTAG_LEN bug - modules/tm/tm.c: added t_forward_nonack_{udp, tcp}, t_relay_to_{udp,tcp}, t_replicate_{udp, tcp} - modules/tm/uac.c: t_uac, t _uac_dlg, gethfblock, uri2proxy changed to use proto & rb->dst - modules/tm/ut.h: added proto to uri2proxy

old tag & version: pre6-tcp4
new tag & version (current): pre6-tcp5-tm

Andrei Pelinescu-Onciul authored on 19/02/2003 17:16:41
Showing 29 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10 10
 SUBLEVEL =   11
11
-EXTRAVERSION = pre6-tcp4
11
+EXTRAVERSION = pre6-tcp5-tm
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 14
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -72,3 +72,10 @@ x generic locking lib
72 72
 - force add rport (setflag(rport)???)
73 73
 - kill all the fprintf
74 74
 
75
+tm optimizations:
76
+
77
+- replace snprintfs int build_uac_request, *_dlg
78
+- fix the huge param no. in this functions (use structs if neccessary):
79
+  build_uac_request, build_uac_request_dlg, t_uac, t_uac_dlg
80
+  
81
+
... ...
@@ -129,7 +129,7 @@ int do_action(struct action* a, struct sip_msg* msg)
129 129
 							goto error_fwd_uri;
130 130
 				}
131 131
 				/* create a temporary proxy*/
132
-				p=mk_proxy(&u->host, port);
132
+				p=mk_proxy(&u->host, port, proto);
133 133
 				if (p==0){
134 134
 					LOG(L_ERR, "ERROR:  bad host name in uri,"
135 135
 							" dropping packet\n");
... ...
@@ -91,7 +91,8 @@
91 91
 #define ID_PARAM ";i="
92 92
 #define ID_PARAM_LEN 3
93 93
 
94
-#define SRV_PREFIX "_sip._udp."
94
+#define SRV_UDP_PREFIX "_sip._udp."
95
+#define SRV_TCP_PREFIX "_sip._tcp."
95 96
 #define SRV_PREFIX_LEN 10
96 97
 
97 98
 /*used only if PKG_MALLOC is defined*/
... ...
@@ -375,7 +375,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
375 375
 	    sip_resolvehost now accepts str -janakj
376 376
 	*/
377 377
 	DBG("update_sock_struct_from_via: trying SRV lookup\n");
378
-	he=sip_resolvehost(name, &port);
378
+	he=sip_resolvehost(name, &port, via->proto);
379 379
 	
380 380
 	if (he==0){
381 381
 		LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%.*s) failure\n",
... ...
@@ -25,7 +25,11 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
-
28
+/*
29
+ * History:
30
+ * --------
31
+ *  2003-02-13  added struct dest_info (andrei)
32
+ */
29 33
 
30 34
 #ifndef ip_addr_h
31 35
 #define ip_addr_h
... ...
@@ -40,7 +44,7 @@
40 40
 
41 41
 #include "dprint.h"
42 42
 
43
-enum sip_protos { PROTO_UDP, PROTO_TCP, PROTO_TLS };
43
+enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS };
44 44
 
45 45
 
46 46
 struct ip_addr{
... ...
@@ -101,6 +105,15 @@ struct receive_info{
101 101
 };
102 102
 
103 103
 
104
+struct dest_info{
105
+	int proto;
106
+	int proto_reserved1; /* tcp stores the connection id here */ 
107
+	union sockaddr_union to;
108
+	struct socket_info* send_sock;
109
+};
110
+
111
+
112
+
104 113
 /* len of the sockaddr */
105 114
 #ifdef HAVE_SOCKADDR_SA_LEN
106 115
 #define sockaddru_len(su)	((su).s.sa_len)
... ...
@@ -161,7 +161,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
161 161
 	new_cell->uas.response.retr_timer.tg=TG_RT;
162 162
 	new_cell->uas.response.fr_timer.tg=TG_FR;
163 163
 	new_cell->uas.response.fr_timer.payload =
164
-		new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
164
+	new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
165 165
 	new_cell->uas.response.my_T=new_cell;
166 166
 
167 167
 	/* bogdan - debug */
... ...
@@ -186,8 +186,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
186 186
 		uac->request.fr_timer.tg = TG_FR;
187 187
 		uac->request.retr_timer.tg = TG_RT;
188 188
 		uac->request.retr_timer.payload = 
189
-			uac->request.fr_timer.payload =
190
-			&uac->request;
189
+		uac->request.fr_timer.payload = &uac->request;
191 190
 		uac->local_cancel=uac->request;
192 191
 	}
193 192
 
... ...
@@ -82,9 +82,8 @@ typedef struct retr_buf
82 82
 
83 83
 	char *buffer;
84 84
 	int   buffer_len;
85
-
86
-	union sockaddr_union to;
87
-	struct socket_info* send_sock;
85
+	
86
+	struct dest_info dst;
88 87
 
89 88
 	/* a message can be linked just to retransmission and FR list */
90 89
 	struct timer_link retr_timer;
... ...
@@ -94,8 +94,7 @@ void cancel_branch( struct cell *t, int branch )
94 94
 	/* install cancel now */
95 95
 	crb->buffer=cancel;
96 96
 	crb->buffer_len=len;
97
-	crb->to=irb->to;
98
-	crb->send_sock=irb->send_sock;
97
+	crb->dst=irb->dst;
99 98
 	crb->branch=branch;
100 99
 #ifdef _OBSOLETED
101 100
 	crb->fr_timer.tg=TG_FR;
... ...
@@ -26,6 +26,11 @@
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29
+/*
30
+ * History:
31
+ * -------
32
+ *  2003-02-13  modified send_pr_buffer to use msg_send & rb->dst (andrei)
33
+ */
29 34
 
30 35
 
31 36
 #include "defs.h"
... ...
@@ -51,7 +56,8 @@ int send_pr_buffer( struct retr_buf *rb,
51 51
 	void *buf, int len, char *function, int line )
52 52
 {
53 53
 	if (buf && len && rb )
54
-		return udp_send( rb->send_sock, buf, len, &rb->to) ;
54
+		return msg_send( rb->dst.send_sock, rb->dst.proto, &rb->dst.to,
55
+				         rb->dst.proto_reserved1, buf, len);
55 56
 	else {
56 57
 		LOG(L_CRIT, "ERROR: sending an empty buffer from %s (%d)\n",
57 58
 			function, line );
... ...
@@ -177,8 +183,8 @@ static int kill_transaction( struct cell *trans )
177 177
 
178 178
 
179 179
 
180
-int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
181
-	int replicate)
180
+int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
181
+				int replicate)
182 182
 {
183 183
 	int ret;
184 184
 	int new_tran;
... ...
@@ -219,12 +225,12 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
219 219
 			uri=(p_msg->new_uri.s==0 || p_msg->new_uri.len==0) ?
220 220
 				&p_msg->first_line.u.request.uri :
221 221
 				&p_msg->new_uri;
222
-			proxy=uri2proxy( uri );
222
+			proxy=uri2proxy( uri, proto );
223 223
 			if (proxy==0) {
224 224
 					ret=E_BAD_ADDRESS;
225 225
 					goto done;
226 226
 			}
227
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto) ;
227
+			ret=forward_request( p_msg , proxy, proto) ;
228 228
 			free_proxy( proxy );	
229 229
 			free( proxy );
230 230
 #ifdef ACK_FORKING_HACK
... ...
@@ -232,22 +238,22 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
232 232
 			init_branch_iterator();
233 233
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
234 234
 				p_msg->new_uri=ack_uri;
235
-				proxy=uri2proxy(ack_uri);
235
+				proxy=uri2proxy(ack_uri, proto);
236 236
 				if (proxy==0) continue;
237
-				forward_request(p_msg, proxy);
237
+				forward_request(p_msg, proxy, proto);
238 238
 				free_proxy( proxy );	
239 239
 				free( proxy );
240 240
 			}
241 241
 			p_msg->new_uri=backup_uri;
242 242
 #endif
243 243
 		} else {
244
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto ) ;
244
+			ret=forward_request( p_msg , proxy, proto ) ;
245 245
 #ifdef ACK_FORKING_HACK
246 246
 			backup_uri=p_msg->new_uri;
247 247
 			init_branch_iterator();
248 248
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
249 249
 				p_msg->new_uri=ack_uri;
250
-				forward_request(p_msg, proxy);
250
+				forward_request(p_msg, proxy, proto);
251 251
 			}
252 252
 			p_msg->new_uri=backup_uri;
253 253
 #endif
... ...
@@ -272,7 +278,7 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
272 272
 	} 
273 273
 
274 274
 	/* now go ahead and forward ... */
275
-	ret=t_forward_nonack(t, p_msg, proxy);
275
+	ret=t_forward_nonack(t, p_msg, proxy, proto);
276 276
 	if (ret<=0) {
277 277
 		DBG( "SER:ERROR: t_forward \n");
278 278
 		reply_ret=kill_transaction( t );
... ...
@@ -24,6 +24,10 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+ /* History:
28
+  * --------
29
+  *  2003-02-18  updated various function prototypes (andrei)
30
+  */
27 31
 
28 32
 
29 33
 
... ...
@@ -127,7 +131,7 @@ void start_retr( struct retr_buf *rb );
127 127
 void cleanup_localcancel_timers( struct cell *t );
128 128
 
129 129
 int t_relay_to( struct sip_msg  *p_msg ,
130
-	struct proxy_l *proxy, int replicate ) ;
130
+	struct proxy_l *proxy, int proto, int replicate ) ;
131 131
 
132 132
 
133 133
 #endif
... ...
@@ -25,6 +25,11 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+/*
29
+ * History:
30
+ * -------
31
+ *  2003-02-13  proto support added (andrei)
32
+ */
28 33
 
29 34
 #include "defs.h"
30 35
 
... ...
@@ -127,10 +132,10 @@ error01:
127 127
 
128 128
 /* introduce a new uac to transaction; returns its branch id (>=0)
129 129
    or error (<0); it doesn't send a message yet -- a reply to it
130
-   might itnerfere with the processes of adding multiple branches
130
+   might interfere with the processes of adding multiple branches
131 131
 */
132 132
 int add_uac( struct cell *t, struct sip_msg *request, str *uri, 
133
-	struct proxy_l *proxy )
133
+	struct proxy_l *proxy, int proto )
134 134
 {
135 135
 
136 136
 	int ret;
... ...
@@ -157,7 +162,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
157 157
 
158 158
 	/* check DNS resolution */
159 159
 	if (proxy) temp_proxy=0; else {
160
-		proxy=uri2proxy( uri );
160
+		proxy=uri2proxy( uri, proto );
161 161
 		if (proxy==0)  {
162 162
 			ret=E_BAD_ADDRESS;
163 163
 			goto error;
... ...
@@ -175,7 +180,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
175 175
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
176 176
 		proxy->port ? htons(proxy->port):htons(SIP_PORT));
177 177
 
178
-	send_sock=get_send_socket( &to , request->rcv.proto);
178
+	send_sock=get_send_socket( &to , proto);
179 179
 	if (send_sock==0) {
180 180
 		LOG(L_ERR, "ERROR: add_uac: can't fwd to af %d "
181 181
 			" (no corresponding listening socket)\n",
... ...
@@ -193,8 +198,10 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
193 193
 	}
194 194
 
195 195
 	/* things went well, move ahead and install new buffer! */
196
-	t->uac[branch].request.to=to;
197
-	t->uac[branch].request.send_sock=send_sock;
196
+	t->uac[branch].request.dst.to=to;
197
+	t->uac[branch].request.dst.send_sock=send_sock;
198
+	t->uac[branch].request.dst.proto=proto;
199
+	t->uac[branch].request.dst.proto_reserved1=0;
198 200
 	t->uac[branch].request.buffer=shbuf;
199 201
 	t->uac[branch].request.buffer_len=len;
200 202
 	t->uac[branch].uri.s=t->uac[branch].request.buffer+
... ...
@@ -238,7 +245,7 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
238 238
 	/* print */
239 239
 	shbuf=print_uac_request( t_cancel, cancel_msg, branch, 
240 240
 		&t_invite->uac[branch].uri, &len, 
241
-		t_invite->uac[branch].request.send_sock);
241
+		t_invite->uac[branch].request.dst.send_sock);
242 242
 	if (!shbuf) {
243 243
 		LOG(L_ERR, "ERROR: e2e_cancel_branch: printing e2e cancel failed\n");
244 244
 		ret=ser_error=E_OUT_OF_MEM;
... ...
@@ -246,8 +253,7 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
246 246
 	}
247 247
 	
248 248
 	/* install buffer */
249
-	t_cancel->uac[branch].request.to=t_invite->uac[branch].request.to;
250
-	t_cancel->uac[branch].request.send_sock=t_invite->uac[branch].request.send_sock;
249
+	t_cancel->uac[branch].request.dst=t_invite->uac[branch].request.dst;
251 250
 	t_cancel->uac[branch].request.buffer=shbuf;
252 251
 	t_cancel->uac[branch].request.buffer_len=len;
253 252
 	t_cancel->uac[branch].uri.s=t_cancel->uac[branch].request.buffer+
... ...
@@ -344,7 +350,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
344 344
  *      -1 - error during forward
345 345
  */
346 346
 int t_forward_nonack( struct cell *t, struct sip_msg* p_msg , 
347
-	struct proxy_l * proxy )
347
+	struct proxy_l * proxy, int proto)
348 348
 {
349 349
 	str          backup_uri;
350 350
 	int branch_ret, lowest_ret;
... ...
@@ -384,7 +390,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
384 384
 		branch_ret=add_uac( t, p_msg, 
385 385
 			p_msg->new_uri.s ? &p_msg->new_uri :  
386 386
 				&p_msg->first_line.u.request.uri,
387
-			proxy );
387
+				proxy, proto );
388 388
 		if (branch_ret>=0) 
389 389
 			added_branches |= 1<<branch_ret;
390 390
 		else
... ...
@@ -393,7 +399,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
393 393
 
394 394
 	init_branch_iterator();
395 395
 	while((current_uri.s=next_branch( &current_uri.len))) {
396
-		branch_ret=add_uac( t, p_msg, &current_uri, proxy );
396
+		branch_ret=add_uac( t, p_msg, &current_uri, proxy, proto);
397 397
 		/* pick some of the errors in case things go wrong;
398 398
 		   note that picking lowest error is just as good as
399 399
 		   any other algorithm which picks any other negative
... ...
@@ -431,7 +437,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
431 431
 	return 1;
432 432
 }	
433 433
 
434
-int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy )
434
+int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy, int proto )
435 435
 {
436 436
 	/* this is a quite horrible hack -- we just take the message
437 437
 	   as is, including Route-s, Record-route-s, and Vias ,
... ...
@@ -444,5 +450,5 @@ int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy )
444 444
 		if we want later to make it thoroughly, we need to
445 445
 		introduce delete lumps for all the header fields above
446 446
 	*/
447
-	return t_relay_to(p_msg, proxy, 1 /* replicate */);
447
+	return t_relay_to(p_msg, proxy, proto, 1 /* replicate */);
448 448
 }
... ...
@@ -25,6 +25,11 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+/*
29
+ * History:
30
+ * --------
31
+ *  2003-02-18  added proto to various function prototypes (andrei)
32
+ */
28 33
 
29 34
 
30 35
 #ifndef _T_FWD_H
... ...
@@ -36,13 +41,15 @@
36 36
 
37 37
 typedef int (*tfwd_f)(struct sip_msg* p_msg , struct proxy_l * proxy );
38 38
 
39
-int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy );
39
+int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy, int proto);
40 40
 char *print_uac_request( struct cell *t, struct sip_msg *i_req,
41 41
     int branch, str *uri, unsigned int *len, struct socket_info *send_sock );
42 42
 void e2e_cancel( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite );
43 43
 int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite, int branch );
44
-int add_uac( struct cell *t, struct sip_msg *request, str *uri, struct proxy_l *proxy );
45
-int t_forward_nonack( struct cell *t, struct sip_msg* p_msg, struct proxy_l * p );
44
+int add_uac(	struct cell *t, struct sip_msg *request, str *uri,
45
+				struct proxy_l *proxy, int proto );
46
+int t_forward_nonack( struct cell *t, struct sip_msg* p_msg,
47
+						struct proxy_l * p, int proto);
46 48
 int t_forward_ack( struct sip_msg* p_msg );
47 49
 
48 50
 
... ...
@@ -51,9 +51,10 @@
51 51
  *
52 52
  * History:
53 53
  * ----------
54
- * 2003-01-28 scratchpad removed (jiri)
55
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
56
- * 2003-01-23 options for disabling r-uri matching introduced (jiri)
54
+ * 2003-01-28  scratchpad removed (jiri)
55
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
56
+ * 2003-01-23  options for disabling r-uri matching introduced (jiri)
57
+ * 2003-02-13  init_rb() is proto indep. & it uses struct dest_info (andrei)
57 58
  */
58 59
 
59 60
 
... ...
@@ -750,31 +751,37 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
750 750
 	return ((T)?1:0) ;
751 751
 }
752 752
 
753
-int init_rb( struct retr_buf *rb, struct sip_msg *msg )
753
+int init_rb( struct retr_buf *rb, struct sip_msg *msg)
754 754
 {
755 755
 	struct socket_info* send_sock;
756 756
 	struct via_body* via;
757
+	int proto;
757 758
 
759
+	via=msg->via1;
758 760
 	if (!reply_to_via) {
759
-		update_sock_struct_from_ip( &rb->to, msg );
761
+		update_sock_struct_from_ip( &rb->dst.to, msg );
762
+		proto=msg->rcv.proto;
760 763
 	} else {
761
-		via=msg->via1;
762 764
 		/*init retrans buffer*/
763
-		if (update_sock_struct_from_via( &(rb->to),via )==-1) {
765
+		if (update_sock_struct_from_via( &(rb->dst.to),via )==-1) {
764 766
 			LOG(L_ERR, "ERROR: init_rb: cannot lookup reply dst: %.*s\n",
765 767
 				via->host.len, via->host.s );
766 768
 			ser_error=E_BAD_VIA;
767 769
 			return 0;
768 770
 		}
771
+		proto=via->proto;
769 772
 	}
770
-	send_sock=get_send_socket(&rb->to, msg->rcv.proto);
773
+	rb->dst.proto=proto;
774
+	rb->dst.proto_reserved1=msg->rcv.proto_reserved1;
775
+	send_sock=get_send_socket(&rb->dst.to, proto);
771 776
 	if (send_sock==0) {
772 777
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d "
773
-			"no socket\n", rb->to.s.sa_family);
778
+			"no socket\n", rb->dst.to.s.sa_family);
774 779
 		ser_error=E_BAD_VIA;
775 780
 		return 0;
776 781
 	}
777
-	rb->send_sock=send_sock;
782
+	rb->dst.send_sock=send_sock;
783
+	
778 784
     return 1;
779 785
 }
780 786
 
... ...
@@ -29,7 +29,8 @@
29 29
  *
30 30
  * History:
31 31
  * ----------
32
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
32
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
33
+ * 2003-02-13  build_uac_request uses proto (andrei)
33 34
  */
34 35
 
35 36
 #include "defs.h"
... ...
@@ -91,8 +92,8 @@ char *build_local(struct cell *Trans,unsigned int branch,
91 91
 		goto error;
92 92
 	branch_str.s=branch_buf;
93 93
 	branch_str.len=branch_len;
94
-	via=via_builder(&via_len, Trans->uac[branch].request.send_sock,
95
-		&branch_str, 0, Trans->uac[branch].request.send_sock->proto );
94
+	via=via_builder(&via_len, Trans->uac[branch].request.dst.send_sock,
95
+		&branch_str, 0, Trans->uac[branch].request.dst.proto );
96 96
 	if (!via)
97 97
 	{
98 98
 		LOG(L_ERR, "ERROR: t_build_and_send_CANCEL: "
... ...
@@ -260,7 +261,7 @@ char *build_uac_request(  str msg_type, str dst, str from,
260 260
 	branch_str.len=branch_len;
261 261
 	
262 262
 	via=via_builder(&via_len, t->uac[branch].request.send_sock,
263
-		&branch_str, 0, t->uac[branch].request.send_sock->proto);
263
+		&branch_str, 0, t->uac[branch].request.dst.proto);
264 264
 	
265 265
 	if (!via) {
266 266
 		LOG(L_ERR, "ERROR: build_uac_request: via building failed\n");
... ...
@@ -27,8 +27,11 @@
27 27
  *
28 28
  * History:
29 29
  * --------
30
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
31
- * 2003-01-19 faked lump list created in on_reply handlers
30
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
31
+ * 2003-01-19  faked lump list created in on_reply handlers
32
+ * 2003-02-13  updated to use rb->dst (andrei)
33
+ * 2003-02-18  replaced TOTAG_LEN w/ TOTAG_VALUE_LEN (TOTAG_LEN was defined
34
+ *             twice with different values!)  (andrei)
32 35
  */
33 36
 
34 37
 #include "defs.h"
... ...
@@ -62,7 +65,7 @@
62 62
 enum route_mode rmode=MODE_REQUEST;
63 63
 
64 64
 /* private place where we create to-tags for replies */
65
-static char tm_tags[TOTAG_LEN];
65
+static char tm_tags[TOTAG_VALUE_LEN];
66 66
 static char *tm_tag_suffix;
67 67
 
68 68
 /* where to go if there is no positive reply */
... ...
@@ -397,7 +400,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
397 397
 		init_branch_iterator();
398 398
 		if (next_branch(&dummy)) {
399 399
 			if (t_forward_nonack(Trans, origin_rq,
400
-						(struct proxy_l *) 0 ) <0) {
400
+						(struct proxy_l *) 0,
401
+						Trans->uas.response.dst.proto)<0) {
401 402
 				/* error ... behave as if we did not try to
402 403
 				   add a new branch */
403 404
 				*should_store=0;
... ...
@@ -456,7 +460,7 @@ int t_retransmit_reply( struct cell *t )
456 456
 	/* first check if we managed to resolve topmost Via -- if
457 457
 	   not yet, don't try to retransmit
458 458
 	*/
459
-	if (!t->uas.response.send_sock) {
459
+	if (!t->uas.response.dst.send_sock) {
460 460
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
461 461
 			"no resolved dst to retransmit\n");
462 462
 		return -1;
... ...
@@ -550,12 +554,12 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg,
550 550
 			    || get_to(p_msg)->tag_value.len==0)) {
551 551
 		calc_crc_suffix( p_msg, tm_tag_suffix );
552 552
 		buf = build_res_buf_from_sip_req(code,text, 
553
-				tm_tags, TOTAG_LEN, 
553
+				tm_tags, TOTAG_VALUE_LEN, 
554 554
 				p_msg,&len);
555 555
 #ifdef VOICE_MAIL
556 556
 
557 557
 		return _reply_light(trans,buf,len,code,text,
558
-				    tm_tags, TOTAG_LEN,
558
+				    tm_tags, TOTAG_VALUE_LEN,
559 559
 				    lock);
560 560
 #endif
561 561
 	} else {
... ...
@@ -654,7 +658,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
654 654
 	/* first check if we managed to resolve topmost Via -- if
655 655
 	   not yet, don't try to retransmit
656 656
 	*/
657
-	if (!trans->uas.response.send_sock) {
657
+	if (!trans->uas.response.dst.send_sock) {
658 658
 		LOG(L_ERR, "ERROR: _reply: no resolved dst to send reply to\n");
659 659
 	} else {
660 660
 		SEND_PR_BUFFER( rb, buf, len );
... ...
@@ -797,7 +801,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
797 797
 				buf = build_res_buf_from_sip_req(
798 798
 						relayed_code,
799 799
 						error_text(relayed_code),
800
-						tm_tags, TOTAG_LEN, 
800
+						tm_tags, TOTAG_VALUE_LEN, 
801 801
 						t->uas.request, &res_len );
802 802
 			} else {
803 803
 				buf = build_res_buf_from_sip_req( relayed_code,
... ...
@@ -51,6 +51,12 @@
51 51
  * along with this program; if not, write to the Free Software 
52 52
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
53 53
  */
54
+/*
55
+ * History:
56
+ * --------
57
+ *  2003-02-18  added t_forward_nonack_{udp, tcp}, t_relay_to_{udp,tcp},
58
+ *               t_replicate_{udp, tcp} (andrei)
59
+ */
54 60
 
55 61
 
56 62
 #include "defs.h"
... ...
@@ -94,10 +100,22 @@ inline static int w_t_newtran(struct sip_msg* p_msg, char* foo, char* bar );
94 94
 inline static int w_t_newdlg( struct sip_msg* p_msg, char* foo, char* bar );
95 95
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
96 96
 inline static int w_t_relay_to( struct sip_msg  *p_msg , char *proxy, char *);
97
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , char *proxy, 
98
+									char *);
99
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , char *proxy,
100
+									char *);
97 101
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
98
-	char *proxy, /* struct proxy_l *proxy expected */
99
-	char *_foo       /* nothing expected */ );
102
+							char *proxy, /* struct proxy_l *proxy expected */
103
+							char *_foo       /* nothing expected */ );
104
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
105
+							char *proxy, /* struct proxy_l *proxy expected */
106
+							char *_foo       /* nothing expected */ );
107
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
108
+							char *proxy, /* struct proxy_l *proxy expected */
109
+							char *_foo       /* nothing expected */ );
100 110
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
111
+inline static int w_t_forward_nonack_udp(struct sip_msg* msg, char* str,char*);
112
+inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
101 113
 inline static int fixup_hostport2proxy(void** param, int param_no);
102 114
 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
103 115
 
... ...
@@ -124,9 +142,15 @@ struct module_exports exports= {
124 124
 				"t_retransmit_reply",
125 125
 				"t_release",
126 126
 				T_RELAY_TO,
127
+				T_RELAY_TO_UDP,
128
+				T_RELAY_TO_TCP,
127 129
 				"t_replicate",
130
+				"t_replicate_udp",
131
+				"t_replicate_tcp",
128 132
 				T_RELAY,
129 133
 				T_FORWARD_NONACK,
134
+				T_FORWARD_NONACK_UDP,
135
+				T_FORWARD_NONACK_TCP,
130 136
 				"t_on_negative",
131 137
 
132 138
 				/* not applicable from script ... */
... ...
@@ -155,9 +179,15 @@ struct module_exports exports= {
155 155
 					w_t_retransmit_reply,
156 156
 					w_t_release,
157 157
 					w_t_relay_to,
158
+					w_t_relay_to_udp,
159
+					w_t_relay_to_tcp,
158 160
 					w_t_replicate,
161
+					w_t_replicate_udp,
162
+					w_t_replicate_tcp,
159 163
 					w_t_relay,
160 164
 					w_t_forward_nonack,
165
+					w_t_forward_nonack_udp,
166
+					w_t_forward_nonack_tcp,
161 167
 					w_t_on_negative,
162 168
 
163 169
 					(cmd_function) register_tmcb,
... ...
@@ -184,9 +214,15 @@ struct module_exports exports= {
184 184
 				0, /* t_retransmit_reply */
185 185
 				0, /* t_release */
186 186
 				2, /* t_relay_to */
187
+				2, /* t_relay_to_udp */
188
+				2, /* t_relay_to_tcp */
187 189
 				2, /* t_replicate */
190
+				2, /* t_replicate_udp */
191
+				2, /* t_replicate_tcp */
188 192
 				0, /* t_relay */
189 193
 				2, /* t_forward_nonack */
194
+				2, /* t_forward_nonack_udp */
195
+				2, /* t_forward_nonack_tcp */
190 196
 				1, /* t_on_negative */
191 197
 				NO_SCRIPT /* register_tmcb */,
192 198
 #ifndef DEPRECATE_OLD_STUFF
... ...
@@ -212,9 +248,15 @@ struct module_exports exports= {
212 212
 				0,						/* t_retransmit_reply */
213 213
 				0,						/* t_release */
214 214
 				fixup_hostport2proxy,	/* t_relay_to */
215
+				fixup_hostport2proxy,	/* t_relay_to_udp */
216
+				fixup_hostport2proxy,	/* t_relay_to_tcp */
215 217
 				fixup_hostport2proxy,	/* t_replicate */
218
+				fixup_hostport2proxy,	/* t_replicate_udp */
219
+				fixup_hostport2proxy,	/* t_replicate_tcp */
216 220
 				0,						/* t_relay */
217 221
 				fixup_hostport2proxy,	/* t_forward_nonack */
222
+				fixup_hostport2proxy,	/* t_forward_nonack_udp */
223
+				fixup_hostport2proxy,	/* t_forward_nonack_tcp */
218 224
 				fixup_str2int,			/* t_on_negative */
219 225
 				0,						/* register_tmcb */
220 226
 #ifndef DEPRECATE_OLD_STUFF
... ...
@@ -240,7 +282,7 @@ struct module_exports exports= {
240 240
 #ifdef VOICE_MAIL
241 241
 	4+
242 242
 #endif
243
-	14,
243
+	14 + 6 /* *_(UDP|TCP) */,
244 244
 
245 245
 	/* ------------ exported variables ---------- */
246 246
 	(char *[]) { /* Module parameter names */
... ...
@@ -455,7 +497,7 @@ inline static int fixup_hostport2proxy(void** param, int param_no)
455 455
 		}
456 456
 		s.s = host;
457 457
 		s.len = strlen(host);
458
-		proxy=mk_proxy(&s, port);
458
+		proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
459 459
 		if (proxy==0) {
460 460
 			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
461 461
 				host );
... ...
@@ -506,7 +548,8 @@ inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
506 506
 
507 507
 
508 508
 
509
-inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _foo)
509
+inline static int _w_t_forward_nonack(struct sip_msg* msg, char* proxy,
510
+									 char* _foo, int proto)
510 511
 {
511 512
 	struct cell *t;
512 513
 	if (t_check( msg , 0 )==-1) return -1;
... ...
@@ -516,7 +559,7 @@ inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _fo
516 516
 			LOG(L_WARN,"WARNING: you don't really want to fwd hbh ACK\n");
517 517
 			return -1;
518 518
 		}
519
-		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy );
519
+		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy, proto );
520 520
 	} else {
521 521
 		DBG("DEBUG: t_forward_nonack: no transaction found\n");
522 522
 		return -1;
... ...
@@ -524,6 +567,25 @@ inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _fo
524 524
 }
525 525
 
526 526
 
527
+inline static int w_t_forward_nonack( struct sip_msg* msg, char* proxy,
528
+										char* foo)
529
+{
530
+	return _w_t_forward_nonack(msg, proxy, foo, msg->rcv.proto);
531
+};
532
+
533
+inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
534
+										char* foo)
535
+{
536
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_UDP);
537
+};
538
+
539
+inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
540
+										char* foo)
541
+{
542
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_TCP);
543
+};
544
+
545
+
527 546
 
528 547
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2)
529 548
 {
... ...
@@ -632,22 +694,56 @@ inline static int w_t_relay_to( struct sip_msg  *p_msg ,
632 632
 	char *proxy, /* struct proxy_l *proxy expected */
633 633
 	char *_foo       /* nothing expected */ )
634 634
 {
635
-	return t_relay_to( p_msg, ( struct proxy_l *) proxy,
635
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto,
636
+	0 /* no replication */ );
637
+}
638
+
639
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , 
640
+	char *proxy, /* struct proxy_l *proxy expected */
641
+	char *_foo       /* nothing expected */ )
642
+{
643
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_UDP,
636 644
 	0 /* no replication */ );
637 645
 }
638 646
 
647
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , 
648
+	char *proxy, /* struct proxy_l *proxy expected */
649
+	char *_foo       /* nothing expected */ )
650
+{
651
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_TCP,
652
+	0 /* no replication */ );
653
+}
654
+
655
+
656
+
639 657
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
640 658
 	char *proxy, /* struct proxy_l *proxy expected */
641 659
 	char *_foo       /* nothing expected */ )
642 660
 {
643
-	return t_replicate(p_msg, ( struct proxy_l *) proxy );
661
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto );
644 662
 }
645 663
 
664
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
665
+	char *proxy, /* struct proxy_l *proxy expected */
666
+	char *_foo       /* nothing expected */ )
667
+{
668
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
669
+}
670
+
671
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
672
+	char *proxy, /* struct proxy_l *proxy expected */
673
+	char *_foo       /* nothing expected */ )
674
+{
675
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TCP );
676
+}
677
+
678
+
679
+
646 680
 inline static int w_t_relay( struct sip_msg  *p_msg , 
647 681
 						char *_foo, char *_bar)
648 682
 {
649 683
 	return t_relay_to( p_msg, 
650
-		(struct proxy_l *) 0 /* no proxy */,
684
+		(struct proxy_l *) 0 /* no proxy */, p_msg->rcv.proto,
651 685
 		0 /* no replication */ );
652 686
 }
653 687
 
... ...
@@ -68,7 +68,7 @@ int load_tm( struct tm_binds *tmb)
68 68
 	        LOG( L_ERR, LOAD_ERROR "'t_reply' not found\n");
69 69
 		return -1;
70 70
 	}
71
-	if (!(tmb->t_is_local=(tget_ti_f)find_export(T_IS_LOCAL, NO_SCRIPT)) ) {
71
+	if (!(tmb->t_is_local=(tislocal_f)find_export(T_IS_LOCAL, NO_SCRIPT)) ) {
72 72
 	        LOG( L_ERR, LOAD_ERROR "'t_get_trans_ident' not found\n");
73 73
 		return -1;
74 74
 	}
... ...
@@ -45,6 +45,8 @@
45 45
 #define NO_SCRIPT	-1
46 46
 
47 47
 #define T_RELAY_TO "t_relay_to"
48
+#define T_RELAY_TO_UDP "t_relay_to_udp"
49
+#define T_RELAY_TO_TCP "t_relay_to_tcp"
48 50
 #define T_RELAY "t_relay"
49 51
 #ifndef DEPRECATE_OLD_STUFF
50 52
 #	define T_UAC "t_uac"
... ...
@@ -56,6 +58,8 @@
56 56
 #endif
57 57
 #define T_REPLY_UNSAFE "t_reply_unsafe"
58 58
 #define T_FORWARD_NONACK "t_forward_nonack"
59
+#define T_FORWARD_NONACK_UDP "t_forward_nonack_udp"
60
+#define T_FORWARD_NONACK_TCP "t_forward_nonack_tcp"
59 61
 
60 62
 
61 63
 
... ...
@@ -44,9 +44,11 @@
44 44
  *
45 45
  * History:
46 46
  * --------
47
- * 2003-01-29 scratchpad removed (jiri)
48
- * 2003-01-27 fifo:t_uac_dlg completed (jiri)
49
- * 2003-01-23 t_uac_dlg now uses get_out_socket (jiri)
47
+ * 2003-01-29  scratchpad removed (jiri)
48
+ * 2003-01-27  fifo:t_uac_dlg completed (jiri)
49
+ * 2003-01-23  t_uac_dlg now uses get_out_socket (jiri)
50
+ * 2003-02-13  t_uac, t _uac_dlg, gethfblock, uri2proxy changed to use 
51
+ *              proto & rb->dst (andrei)
50 52
  */
51 53
 
52 54
 
... ...
@@ -207,7 +209,7 @@ int uac_child_init( int rank )
207 207
 }
208 208
 
209 209
 #ifndef DEPRECATE_OLD_STUFF
210
-int t_uac( str *msg_type, str *dst, 
210
+int t_uac( str *msg_type, str *dst, int proto, 
211 211
 	str *headers, str *body, str *from, 
212 212
 	transaction_cb completion_cb, void *cbp, 
213 213
 	dlg_t dlg)
... ...
@@ -230,7 +232,7 @@ int t_uac( str *msg_type, str *dst,
230 230
 	/* make -Wall shut up */
231 231
 	ret=0;
232 232
 
233
-	proxy=uri2proxy( dst );
233
+	proxy=uri2proxy( dst, proto );
234 234
 	if (proxy==0) {
235 235
 		ser_error=ret=E_BAD_ADDRESS;
236 236
 		LOG(L_ERR, "ERROR: t_uac: can't create a dst proxy\n");
... ...
@@ -242,7 +244,7 @@ int t_uac( str *msg_type, str *dst,
242 242
 	hostent2su(&to, &proxy->host, proxy->addr_idx, 
243 243
 		(proxy->port)?htons(proxy->port):htons(SIP_PORT));
244 244
 	/* send_sock=get_send_socket( &to, PROTO_UDP ); */
245
-	send_sock=get_out_socket( &to, PROTO_UDP );
245
+	send_sock=get_out_socket( &to, proto );
246 246
 	if (send_sock==0) {
247 247
 		LOG(L_ERR, "ERROR: t_uac: no corresponding listening socket "
248 248
 			"for af %d\n", to.s.sa_family );
... ...
@@ -282,8 +284,10 @@ int t_uac( str *msg_type, str *dst,
282 282
 
283 283
 
284 284
 	request=&new_cell->uac[branch].request;
285
-	request->to=to;
286
-	request->send_sock=send_sock;
285
+	request->dst.to=to;
286
+	request->dst.send_sock=send_sock;
287
+	request->dst.proto=proto;
288
+	request->dst.proto_reserved1=0; /* no special connection required */
287 289
 
288 290
 	/* need to put in table to calculate label which is needed for printing */
289 291
 	LOCK_HASH(new_cell->hash_index);
... ...
@@ -344,12 +348,13 @@ done:
344 344
 }
345 345
 #endif
346 346
 
347
-static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
347
+static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su,
348
+									 int proto )
348 349
 {
349 350
 	struct proxy_l *proxy;
350 351
 	struct socket_info* send_sock;
351 352
 
352
-	proxy = uri2proxy(uri);
353
+	proxy = uri2proxy(uri, proto);
353 354
 	if (proxy == 0) {
354 355
 		ser_error = E_BAD_ADDRESS;
355 356
 		LOG(L_ERR, "ERROR: uri2sock: Can't create a dst proxy\n");
... ...
@@ -358,7 +363,7 @@ static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
358 358
 
359 359
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
360 360
 			(proxy->port) ? htons(proxy->port) : htons(SIP_PORT));
361
-	send_sock=get_out_socket(to_su, PROTO_UDP);
361
+	send_sock=get_out_socket(to_su, proto);
362 362
 	if (send_sock == 0) {
363 363
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
364 364
 						to_su->s.sa_family );
... ...
@@ -428,6 +433,7 @@ static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
428 428
  */
429 429
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
430 430
 	      str* dst,                     /* Real destination (can be different than R-URI) */
431
+		  int proto,
431 432
 	      str* ruri,                    /* Request-URI */
432 433
 	      str* to,                      /* To - w/o tag*/
433 434
 	      str* from,                    /* From - w/o tag*/
... ...
@@ -464,7 +470,7 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
464 464
 		goto done;
465 465
 	}
466 466
 
467
-	send_sock=uri2sock( dst? dst: ruri, &to_su );
467
+	send_sock=uri2sock( dst? dst: ruri, &to_su, proto );
468 468
 	if (send_sock==0) {
469 469
 		LOG(L_ERR, "ERROR: t_uac_dlg: no socket found\n");
470 470
 		goto error00;
... ...
@@ -504,8 +510,10 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
504 504
 	new_cell->kr = REQ_FWDED;
505 505
 
506 506
 	request = &new_cell->uac[branch].request;
507
-	request->to = to_su;
508
-	request->send_sock = send_sock;
507
+	request->dst.to = to_su;
508
+	request->dst.send_sock = send_sock;
509
+	request->dst.proto = proto;
510
+	request->dst.proto_reserved1 = 0;
509 511
 
510 512
 	/* need to put in table to calculate label which is needed for printing */
511 513
 	LOCK_HASH(new_cell->hash_index);
... ...
@@ -677,7 +685,7 @@ int fifo_uac( FILE *stream, char *response_file )
677 677
 	} else {
678 678
 		shmem_file=0;
679 679
 	}
680
-	ret=t_uac(&sm,&sd,&sh,&sb, 0 /* default from */,
680
+	ret=t_uac(&sm,&sd, PROTO_UDP,&sh,&sb, 0 /* default from */,
681 681
 		fifo_callback,shmem_file,0 /* no dialog */);
682 682
 	if (ret>0) {
683 683
 		if (err2reason_phrase(ret, &sip_error, err_buf,
... ...
@@ -782,7 +790,7 @@ int fifo_uac_from( FILE *stream, char *response_file )
782 782
 	   will not be triggered and no feedback will be printed
783 783
 	   to shmem_file
784 784
 	*/
785
-	ret=t_uac(&sm,&sd,&sh,&sb, sf.len==0 ? 0 : &sf /* default from */,
785
+	ret=t_uac(&sm,&sd, PROTO_UDP, &sh,&sb, sf.len==0 ? 0: &sf/*default from*/,
786 786
 		fifo_callback,shmem_file,0 /* no dialog */);
787 787
 	if (ret<=0) {
788 788
 		err_ret=err2reason_phrase(ret, &sip_error, err_buf,
... ...
@@ -821,7 +829,7 @@ static struct str_list *new_str(char *s, int len, struct str_list **last, int *t
821 821
 }
822 822
 
823 823
 
824
-static char *get_hfblock(str *uri, struct hdr_field *hf, int *l) 
824
+static char *get_hfblock(str *uri, struct hdr_field *hf, int *l, int proto) 
825 825
 {
826 826
 	struct str_list sl, *last, *new, *i, *foo;
827 827
 	int hf_avail, frag_len, total_len;
... ...
@@ -859,7 +867,7 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int *l)
859 859
 						if (!new) goto error;
860 860
 						/* substitute */
861 861
 						if (!sock_name) {
862
-							send_sock=uri2sock( uri, &to_su );
862
+							send_sock=uri2sock( uri, &to_su, proto );
863 863
 							if (!send_sock) {
864 864
 								LOG(L_ERR, "ERROR: get_hf_block: send_sock failed\n");
865 865
 								goto error;
... ...
@@ -1117,7 +1125,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
1117 1117
 	}
1118 1118
 
1119 1119
 	hfb.s=get_hfblock(outbound.len ? &outbound : &ruri, 
1120
-					faked_msg.headers, &hfb.len);
1120
+					faked_msg.headers, &hfb.len, PROTO_UDP);
1121 1121
 	if (!hfb.s) {
1122 1122
 		fifo_uac_error(response_file, 500, "no mem for hf block");
1123 1123
 		goto error;
... ...
@@ -1144,6 +1152,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
1144 1144
 	dummy_empty.s=0; dummy_empty.len=0;
1145 1145
 	ret=t_uac_dlg( &method, 
1146 1146
 		outbound.len ? &outbound: 0,
1147
+		PROTO_UDP,
1147 1148
 		&ruri, 
1148 1149
 		&faked_msg.to->body,	/* possibly w/to-tag in it */
1149 1150
 		&faked_msg.from->body,
... ...
@@ -76,6 +76,7 @@ int t_uac(
76 76
 	str *msg_type,  
77 77
 	/* sip:foo@bar, will be put in r-uri and To */
78 78
 	str *dst,	
79
+	int proto, 
79 80
 	/* all other header fields separated by CRLF, including 
80 81
 	   Content-type if body attached, excluding HFs
81 82
 	   generated by UAC: To, Content_length, CSeq, Call-ID, Via, From
... ...
@@ -103,7 +104,9 @@ int t_uac(
103 103
  * Send a request within a dialog
104 104
  */
105 105
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
106
-	      str* dst,                     /* Real destination (can be different than R-URI */
106
+	      str* dst,                     /* Real destination (can be different 
107
+										   than R-URI */
108
+		  int proto,
107 109
 	      str* ruri,                    /* Request-URI */
108 110
 	      str* to,                      /* To - including tag */
109 111
 	      str* from,                    /* From - including tag */
... ...
@@ -27,6 +27,11 @@
27 27
  * along with this program; if not, write to the Free Software 
28 28
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 29
  */
30
+/*
31
+ * History:
32
+ * -------
33
+ *  2003-02-13  added proto to uri2proxy (andrei)
34
+*/
30 35
 
31 36
 
32 37
 #ifndef _TM_UT_H
... ...
@@ -41,7 +46,7 @@
41 41
 #include "../../str.h"
42 42
 #include "../../parser/msg_parser.h"
43 43
 
44
-inline static struct proxy_l *uri2proxy( str *uri )
44
+inline static struct proxy_l *uri2proxy( str *uri, int proto )
45 45
 {
46 46
 	struct sip_uri parsed_uri;
47 47
 	unsigned int  port; 
... ...
@@ -63,7 +68,7 @@ inline static struct proxy_l *uri2proxy( str *uri )
63 63
 	/* fixed use of SRV resolver
64 64
 	} else port=SIP_PORT; */
65 65
 	} else port=0;
66
-	p=mk_proxy(&(parsed_uri.host), port);
66
+	p=mk_proxy(&(parsed_uri.host), port, proto);
67 67
 	if (p==0) {
68 68
 		LOG(L_ERR, "ERROR: t_relay: bad host name in URI <%.*s>\n",
69 69
 			uri->len, uri->s);
... ...
@@ -175,7 +175,7 @@ static int check_via_address(struct ip_addr* ip, str *name,
175 175
 	if (resolver&DO_DNS){
176 176
 		DBG("check_address: doing dns lookup\n");
177 177
 		/* try all names ips */
178
-		he=sip_resolvehost(name, &port);
178
+		he=sip_resolvehost(name, &port, 0); /* FIXME proto? */
179 179
 		if (he && ip->af==he->h_addrtype){
180 180
 			for(i=0;he && he->h_addr_list[i];i++){
181 181
 				if ( memcmp(&he->h_addr_list[i], ip->u.addr, ip->len)==0)
... ...
@@ -27,6 +27,11 @@
27 27
  * along with this program; if not, write to the Free Software 
28 28
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 29
  */
30
+ /*
31
+  * History:
32
+  * -------
33
+  *  2003-02-13  all *proxy fucntions are now proto aware (andrei)
34
+  */
30 35
 
31 36
 
32 37
 
... ...
@@ -55,13 +60,17 @@ struct proxy_l* proxies=0;
55 55
 
56 56
 
57 57
 
58
-/* searches for the proxy named 'name', on port 'port'
58
+/* searches for the proxy named 'name', on port 'port' with 
59
+   proto 'proto'; if proto==0 => proto wildcard (will match any proto)
59 60
    returns: pointer to proxy_l on success or 0 if not found */ 
60
-static struct proxy_l* find_proxy(str *name, unsigned short port)
61
+static struct proxy_l* find_proxy(str *name, unsigned short port, int proto)
61 62
 {
62 63
 	struct proxy_l* t;
63 64
 	for(t=proxies; t; t=t->next)
64
-		if (((t->name.len == name->len) && (strncasecmp(t->name.s, name->s, name->len)==0)) && (t->port==port))
65
+		if (((t->name.len == name->len) &&
66
+			 ((proto==PROTO_NONE)||(t->proto==proto))&&
67
+			(strncasecmp(t->name.s, name->s, name->len)==0)) &&
68
+				(t->port==port))
65 69
 			break;
66 70
 	return t;
67 71
 }
... ...
@@ -169,12 +178,12 @@ void free_hostent(struct hostent *dst)
169 169
 
170 170
 
171 171
 
172
-struct proxy_l* add_proxy(str* name, unsigned short port)
172
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto)
173 173
 {
174 174
 	struct proxy_l* p;
175 175
 	
176
-	if ((p=find_proxy(name, port))!=0) return p;
177
-	if ((p=mk_proxy(name, port))==0) goto error;
176
+	if ((p=find_proxy(name, port, proto))!=0) return p;
177
+	if ((p=mk_proxy(name, port, proto))==0) goto error;
178 178
 	/* add p to the proxy list */
179 179
 	p->next=proxies;
180 180
 	proxies=p;
... ...
@@ -188,9 +197,9 @@ error:
188 188
 
189 189
 
190 190
 /* same as add_proxy, but it doesn't add the proxy to the list
191
- * uses also SRV if possible (quick hack) */
191
+ * uses also SRV if possible & port==0 (quick hack) */
192 192
 
193
-struct proxy_l* mk_proxy(str* name, unsigned short port)
193
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto)
194 194
 {
195 195
 	struct proxy_l* p;
196 196
 	struct hostent* he;
... ...
@@ -204,9 +213,10 @@ struct proxy_l* mk_proxy(str* name, unsigned short port)
204 204
 	memset(p,0,sizeof(struct proxy_l));
205 205
 	p->name=*name;
206 206
 	p->port=port;
207
+	p->proto=proto;
207 208
 
208 209
 	DBG("DEBUG: mk_proxy: doing DNS lookup...\n");
209
-	he=sip_resolvehost(name, &(p->port));
210
+	he=sip_resolvehost(name, &(p->port), proto);
210 211
 	if (he==0){
211 212
 		ser_error=E_BAD_ADDRESS;
212 213
 		LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
... ...
@@ -227,7 +237,8 @@ error:
227 227
 
228 228
 
229 229
 /* same as mk_proxy, but get the host as an ip*/
230
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port)
230
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
231
+									int proto)
231 232
 {
232 233
 	struct proxy_l* p;
233 234
 
... ...
@@ -239,6 +250,7 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port)
239 239
 	memset(p,0,sizeof(struct proxy_l));
240 240
 
241 241
 	p->port=port;
242
+	p->proto=proto;
242 243
 	p->host.h_addrtype=ip->af;
243 244
 	p->host.h_length=ip->len;
244 245
 	p->host.h_addr_list=malloc(2*sizeof(char*));
... ...
@@ -25,6 +25,11 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+ /*
29
+  * History:
30
+  * -------
31
+  *  2003-02-13  added proto to struct proxy_l & to *_proxy fucntions (andrei)
32
+  */
28 33
 
29 34
 
30 35
 #ifndef proxy_h
... ...
@@ -40,6 +45,7 @@ struct proxy_l{
40 40
 	struct hostent host; /* addresses */
41 41
 	unsigned short port;
42 42
 	unsigned short reserved; /*align*/
43
+	int proto;
43 44
 	
44 45
 	/* socket ? */
45 46
 
... ...
@@ -53,9 +59,10 @@ struct proxy_l{
53 53
 
54 54
 extern struct proxy_l* proxies;
55 55
 
56
-struct proxy_l* add_proxy(str* name, unsigned short port);
57
-struct proxy_l* mk_proxy(str* name, unsigned short port);
58
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port);
56
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto);
57
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto);
58
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
59
+									int proto);
59 60
 void free_proxy(struct proxy_l* p);
60 61
 
61 62
 
... ...
@@ -24,6 +24,11 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/*
28
+ * History:
29
+ * -------
30
+ *  2003-02-13  added proto to sip_resolvehost, for SRV lookups (andrei)
31
+ */ 
27 32
 
28 33
 
29 34
 #include <sys/types.h>
... ...
@@ -448,10 +453,12 @@ not_found:
448 448
 
449 449
 /* resolves a host name trying SRV lookup if *port==0 or normal A/AAAA lookup
450 450
  * if *port!=0.
451
+ * when performing SRV lookup (*port==0) it will use proto to look for
452
+ * tcp or udp hosts, otherwise proto is unused; if proto==0 => no SRV lookup
451 453
  * returns: hostent struct & *port filled with the port from the SRV record;
452 454
  *  0 on error
453 455
  */
454
-struct hostent* sip_resolvehost(str* name, unsigned short* port)
456
+struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto)
455 457
 {
456 458
 	struct hostent* he;
457 459
 	struct rdata* head;
... ...
@@ -477,9 +484,24 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
477 477
 				return ip_addr2he(name,ip);
478 478
 			}
479 479
 			
480
-			memcpy(tmp, SRV_PREFIX, SRV_PREFIX_LEN);
481
-			memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
482
-			tmp[SRV_PREFIX_LEN + name->len] = '\0';
480
+			switch(proto){
481
+				case PROTO_NONE: /* no proto specified, use udp */
482
+					goto skip_srv;
483
+				case PROTO_UDP:
484
+					memcpy(tmp, SRV_UDP_PREFIX, SRV_PREFIX_LEN);
485
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
486
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
487
+					break;
488
+				case PROTO_TCP:
489
+					memcpy(tmp, SRV_TCP_PREFIX, SRV_PREFIX_LEN);
490
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
491
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
492
+					break;
493
+				default:
494
+					LOG(L_CRIT, "BUG: sip_resolvehost: unknown proto %d\n",
495
+							proto);
496
+					return 0;
497
+			}
483 498
 
484 499
 			head=get_record(tmp, T_SRV);
485 500
 			for(l=head; l; l=l->next){
... ...
@@ -504,7 +526,7 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
504 504
 					" trying 'normal' lookup...\n", name->len, name->s);
505 505
 		}
506 506
 	}
507
-
507
+skip_srv:
508 508
 	if (name->len >= MAX_DNS_NAME) {
509 509
 		LOG(L_ERR, "sip_resolvehost: domain name too long\n");
510 510
 		return 0;
... ...
@@ -260,7 +260,7 @@ error_char:
260 260
 
261 261
 
262 262
 
263
-struct hostent* sip_resolvehost(str* name, unsigned short* port);
263
+struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto);
264 264
 
265 265
 
266 266
 
... ...
@@ -169,7 +169,7 @@ static int fix_actions(struct action* a)
169 169
 						case STRING_ST:
170 170
 							s.s = t->p1.string;
171 171
 							s.len = strlen(s.s);
172
-							p=add_proxy(&s, t->p2.number);
172
+							p=add_proxy(&s, t->p2.number, 0); /* FIXME proto*/
173 173
 							if (p==0) return E_BAD_ADDRESS;
174 174
 							t->p1.data=p;
175 175
 							t->p1_type=PROXY_ST;
... ...
@@ -33,6 +33,12 @@
33 33
  * along with this program; if not, write to the Free Software 
34 34
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35 35
  */
36
+/*
37
+ * History:
38
+ * --------
39
+ *  2003-02-18  changed TOTAG_LEN into TOTAG_VALUE_LEN, to solve
40
+ *               redefinition conflict with tm/t_msgbuilder.h (andrei)
41
+ */
36 42
 
37 43
 
38 44
 #ifndef _TAGS_H
... ...
@@ -42,7 +48,7 @@
42 42
 #include "crc.h"
43 43
 #include "str.h"
44 44
 
45
-#define TOTAG_LEN (MD5_LEN+CRC16_LEN+1)
45
+#define TOTAG_VALUE_LEN (MD5_LEN+CRC16_LEN+1)
46 46
 
47 47
 /* generate variable part of to-tag for a request;
48 48
  * it will have length of CRC16_LEN, sufficiently