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 44
 
41 45
 #include "dprint.h"
42 46
 
43
-enum sip_protos { PROTO_UDP, PROTO_TCP, PROTO_TLS };
47
+enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS };
44 48
 
45 49
 
46 50
 struct ip_addr{
... ...
@@ -101,6 +105,15 @@ struct receive_info{
101 105
 };
102 106
 
103 107
 
108
+struct dest_info{
109
+	int proto;
110
+	int proto_reserved1; /* tcp stores the connection id here */ 
111
+	union sockaddr_union to;
112
+	struct socket_info* send_sock;
113
+};
114
+
115
+
116
+
104 117
 /* len of the sockaddr */
105 118
 #ifdef HAVE_SOCKADDR_SA_LEN
106 119
 #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 56
 	void *buf, int len, char *function, int line )
52 57
 {
53 58
 	if (buf && len && rb )
54
-		return udp_send( rb->send_sock, buf, len, &rb->to) ;
59
+		return msg_send( rb->dst.send_sock, rb->dst.proto, &rb->dst.to,
60
+				         rb->dst.proto_reserved1, buf, len);
55 61
 	else {
56 62
 		LOG(L_CRIT, "ERROR: sending an empty buffer from %s (%d)\n",
57 63
 			function, line );
... ...
@@ -177,8 +183,8 @@ static int kill_transaction( struct cell *trans )
177 183
 
178 184
 
179 185
 
180
-int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
181
-	int replicate)
186
+int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
187
+				int replicate)
182 188
 {
183 189
 	int ret;
184 190
 	int new_tran;
... ...
@@ -219,12 +225,12 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
219 225
 			uri=(p_msg->new_uri.s==0 || p_msg->new_uri.len==0) ?
220 226
 				&p_msg->first_line.u.request.uri :
221 227
 				&p_msg->new_uri;
222
-			proxy=uri2proxy( uri );
228
+			proxy=uri2proxy( uri, proto );
223 229
 			if (proxy==0) {
224 230
 					ret=E_BAD_ADDRESS;
225 231
 					goto done;
226 232
 			}
227
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto) ;
233
+			ret=forward_request( p_msg , proxy, proto) ;
228 234
 			free_proxy( proxy );	
229 235
 			free( proxy );
230 236
 #ifdef ACK_FORKING_HACK
... ...
@@ -232,22 +238,22 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
232 238
 			init_branch_iterator();
233 239
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
234 240
 				p_msg->new_uri=ack_uri;
235
-				proxy=uri2proxy(ack_uri);
241
+				proxy=uri2proxy(ack_uri, proto);
236 242
 				if (proxy==0) continue;
237
-				forward_request(p_msg, proxy);
243
+				forward_request(p_msg, proxy, proto);
238 244
 				free_proxy( proxy );	
239 245
 				free( proxy );
240 246
 			}
241 247
 			p_msg->new_uri=backup_uri;
242 248
 #endif
243 249
 		} else {
244
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto ) ;
250
+			ret=forward_request( p_msg , proxy, proto ) ;
245 251
 #ifdef ACK_FORKING_HACK
246 252
 			backup_uri=p_msg->new_uri;
247 253
 			init_branch_iterator();
248 254
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
249 255
 				p_msg->new_uri=ack_uri;
250
-				forward_request(p_msg, proxy);
256
+				forward_request(p_msg, proxy, proto);
251 257
 			}
252 258
 			p_msg->new_uri=backup_uri;
253 259
 #endif
... ...
@@ -272,7 +278,7 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
272 278
 	} 
273 279
 
274 280
 	/* now go ahead and forward ... */
275
-	ret=t_forward_nonack(t, p_msg, proxy);
281
+	ret=t_forward_nonack(t, p_msg, proxy, proto);
276 282
 	if (ret<=0) {
277 283
 		DBG( "SER:ERROR: t_forward \n");
278 284
 		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 131
 void cleanup_localcancel_timers( struct cell *t );
128 132
 
129 133
 int t_relay_to( struct sip_msg  *p_msg ,
130
-	struct proxy_l *proxy, int replicate ) ;
134
+	struct proxy_l *proxy, int proto, int replicate ) ;
131 135
 
132 136
 
133 137
 #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 132
 
128 133
 /* introduce a new uac to transaction; returns its branch id (>=0)
129 134
    or error (<0); it doesn't send a message yet -- a reply to it
130
-   might itnerfere with the processes of adding multiple branches
135
+   might interfere with the processes of adding multiple branches
131 136
 */
132 137
 int add_uac( struct cell *t, struct sip_msg *request, str *uri, 
133
-	struct proxy_l *proxy )
138
+	struct proxy_l *proxy, int proto )
134 139
 {
135 140
 
136 141
 	int ret;
... ...
@@ -157,7 +162,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
157 162
 
158 163
 	/* check DNS resolution */
159 164
 	if (proxy) temp_proxy=0; else {
160
-		proxy=uri2proxy( uri );
165
+		proxy=uri2proxy( uri, proto );
161 166
 		if (proxy==0)  {
162 167
 			ret=E_BAD_ADDRESS;
163 168
 			goto error;
... ...
@@ -175,7 +180,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
175 180
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
176 181
 		proxy->port ? htons(proxy->port):htons(SIP_PORT));
177 182
 
178
-	send_sock=get_send_socket( &to , request->rcv.proto);
183
+	send_sock=get_send_socket( &to , proto);
179 184
 	if (send_sock==0) {
180 185
 		LOG(L_ERR, "ERROR: add_uac: can't fwd to af %d "
181 186
 			" (no corresponding listening socket)\n",
... ...
@@ -193,8 +198,10 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
193 198
 	}
194 199
 
195 200
 	/* 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;
201
+	t->uac[branch].request.dst.to=to;
202
+	t->uac[branch].request.dst.send_sock=send_sock;
203
+	t->uac[branch].request.dst.proto=proto;
204
+	t->uac[branch].request.dst.proto_reserved1=0;
198 205
 	t->uac[branch].request.buffer=shbuf;
199 206
 	t->uac[branch].request.buffer_len=len;
200 207
 	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 245
 	/* print */
239 246
 	shbuf=print_uac_request( t_cancel, cancel_msg, branch, 
240 247
 		&t_invite->uac[branch].uri, &len, 
241
-		t_invite->uac[branch].request.send_sock);
248
+		t_invite->uac[branch].request.dst.send_sock);
242 249
 	if (!shbuf) {
243 250
 		LOG(L_ERR, "ERROR: e2e_cancel_branch: printing e2e cancel failed\n");
244 251
 		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 253
 	}
247 254
 	
248 255
 	/* 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;
256
+	t_cancel->uac[branch].request.dst=t_invite->uac[branch].request.dst;
251 257
 	t_cancel->uac[branch].request.buffer=shbuf;
252 258
 	t_cancel->uac[branch].request.buffer_len=len;
253 259
 	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 350
  *      -1 - error during forward
345 351
  */
346 352
 int t_forward_nonack( struct cell *t, struct sip_msg* p_msg , 
347
-	struct proxy_l * proxy )
353
+	struct proxy_l * proxy, int proto)
348 354
 {
349 355
 	str          backup_uri;
350 356
 	int branch_ret, lowest_ret;
... ...
@@ -384,7 +390,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
384 390
 		branch_ret=add_uac( t, p_msg, 
385 391
 			p_msg->new_uri.s ? &p_msg->new_uri :  
386 392
 				&p_msg->first_line.u.request.uri,
387
-			proxy );
393
+				proxy, proto );
388 394
 		if (branch_ret>=0) 
389 395
 			added_branches |= 1<<branch_ret;
390 396
 		else
... ...
@@ -393,7 +399,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
393 399
 
394 400
 	init_branch_iterator();
395 401
 	while((current_uri.s=next_branch( &current_uri.len))) {
396
-		branch_ret=add_uac( t, p_msg, &current_uri, proxy );
402
+		branch_ret=add_uac( t, p_msg, &current_uri, proxy, proto);
397 403
 		/* pick some of the errors in case things go wrong;
398 404
 		   note that picking lowest error is just as good as
399 405
 		   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 437
 	return 1;
432 438
 }	
433 439
 
434
-int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy )
440
+int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy, int proto )
435 441
 {
436 442
 	/* this is a quite horrible hack -- we just take the message
437 443
 	   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 450
 		if we want later to make it thoroughly, we need to
445 451
 		introduce delete lumps for all the header fields above
446 452
 	*/
447
-	return t_relay_to(p_msg, proxy, 1 /* replicate */);
453
+	return t_relay_to(p_msg, proxy, proto, 1 /* replicate */);
448 454
 }
... ...
@@ -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 41
 
37 42
 typedef int (*tfwd_f)(struct sip_msg* p_msg , struct proxy_l * proxy );
38 43
 
39
-int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy );
44
+int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy, int proto);
40 45
 char *print_uac_request( struct cell *t, struct sip_msg *i_req,
41 46
     int branch, str *uri, unsigned int *len, struct socket_info *send_sock );
42 47
 void e2e_cancel( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite );
43 48
 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 );
49
+int add_uac(	struct cell *t, struct sip_msg *request, str *uri,
50
+				struct proxy_l *proxy, int proto );
51
+int t_forward_nonack( struct cell *t, struct sip_msg* p_msg,
52
+						struct proxy_l * p, int proto);
46 53
 int t_forward_ack( struct sip_msg* p_msg );
47 54
 
48 55
 
... ...
@@ -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 751
 	return ((T)?1:0) ;
751 752
 }
752 753
 
753
-int init_rb( struct retr_buf *rb, struct sip_msg *msg )
754
+int init_rb( struct retr_buf *rb, struct sip_msg *msg)
754 755
 {
755 756
 	struct socket_info* send_sock;
756 757
 	struct via_body* via;
758
+	int proto;
757 759
 
760
+	via=msg->via1;
758 761
 	if (!reply_to_via) {
759
-		update_sock_struct_from_ip( &rb->to, msg );
762
+		update_sock_struct_from_ip( &rb->dst.to, msg );
763
+		proto=msg->rcv.proto;
760 764
 	} else {
761
-		via=msg->via1;
762 765
 		/*init retrans buffer*/
763
-		if (update_sock_struct_from_via( &(rb->to),via )==-1) {
766
+		if (update_sock_struct_from_via( &(rb->dst.to),via )==-1) {
764 767
 			LOG(L_ERR, "ERROR: init_rb: cannot lookup reply dst: %.*s\n",
765 768
 				via->host.len, via->host.s );
766 769
 			ser_error=E_BAD_VIA;
767 770
 			return 0;
768 771
 		}
772
+		proto=via->proto;
769 773
 	}
770
-	send_sock=get_send_socket(&rb->to, msg->rcv.proto);
774
+	rb->dst.proto=proto;
775
+	rb->dst.proto_reserved1=msg->rcv.proto_reserved1;
776
+	send_sock=get_send_socket(&rb->dst.to, proto);
771 777
 	if (send_sock==0) {
772 778
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d "
773
-			"no socket\n", rb->to.s.sa_family);
779
+			"no socket\n", rb->dst.to.s.sa_family);
774 780
 		ser_error=E_BAD_VIA;
775 781
 		return 0;
776 782
 	}
777
-	rb->send_sock=send_sock;
783
+	rb->dst.send_sock=send_sock;
784
+	
778 785
     return 1;
779 786
 }
780 787
 
... ...
@@ -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 92
 		goto error;
92 93
 	branch_str.s=branch_buf;
93 94
 	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 );
95
+	via=via_builder(&via_len, Trans->uac[branch].request.dst.send_sock,
96
+		&branch_str, 0, Trans->uac[branch].request.dst.proto );
96 97
 	if (!via)
97 98
 	{
98 99
 		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 261
 	branch_str.len=branch_len;
261 262
 	
262 263
 	via=via_builder(&via_len, t->uac[branch].request.send_sock,
263
-		&branch_str, 0, t->uac[branch].request.send_sock->proto);
264
+		&branch_str, 0, t->uac[branch].request.dst.proto);
264 265
 	
265 266
 	if (!via) {
266 267
 		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 65
 enum route_mode rmode=MODE_REQUEST;
63 66
 
64 67
 /* private place where we create to-tags for replies */
65
-static char tm_tags[TOTAG_LEN];
68
+static char tm_tags[TOTAG_VALUE_LEN];
66 69
 static char *tm_tag_suffix;
67 70
 
68 71
 /* 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 400
 		init_branch_iterator();
398 401
 		if (next_branch(&dummy)) {
399 402
 			if (t_forward_nonack(Trans, origin_rq,
400
-						(struct proxy_l *) 0 ) <0) {
403
+						(struct proxy_l *) 0,
404
+						Trans->uas.response.dst.proto)<0) {
401 405
 				/* error ... behave as if we did not try to
402 406
 				   add a new branch */
403 407
 				*should_store=0;
... ...
@@ -456,7 +460,7 @@ int t_retransmit_reply( struct cell *t )
456 460
 	/* first check if we managed to resolve topmost Via -- if
457 461
 	   not yet, don't try to retransmit
458 462
 	*/
459
-	if (!t->uas.response.send_sock) {
463
+	if (!t->uas.response.dst.send_sock) {
460 464
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
461 465
 			"no resolved dst to retransmit\n");
462 466
 		return -1;
... ...
@@ -550,12 +554,12 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg,
550 554
 			    || get_to(p_msg)->tag_value.len==0)) {
551 555
 		calc_crc_suffix( p_msg, tm_tag_suffix );
552 556
 		buf = build_res_buf_from_sip_req(code,text, 
553
-				tm_tags, TOTAG_LEN, 
557
+				tm_tags, TOTAG_VALUE_LEN, 
554 558
 				p_msg,&len);
555 559
 #ifdef VOICE_MAIL
556 560
 
557 561
 		return _reply_light(trans,buf,len,code,text,
558
-				    tm_tags, TOTAG_LEN,
562
+				    tm_tags, TOTAG_VALUE_LEN,
559 563
 				    lock);
560 564
 #endif
561 565
 	} else {
... ...
@@ -654,7 +658,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
654 658
 	/* first check if we managed to resolve topmost Via -- if
655 659
 	   not yet, don't try to retransmit
656 660
 	*/
657
-	if (!trans->uas.response.send_sock) {
661
+	if (!trans->uas.response.dst.send_sock) {
658 662
 		LOG(L_ERR, "ERROR: _reply: no resolved dst to send reply to\n");
659 663
 	} else {
660 664
 		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 801
 				buf = build_res_buf_from_sip_req(
798 802
 						relayed_code,
799 803
 						error_text(relayed_code),
800
-						tm_tags, TOTAG_LEN, 
804
+						tm_tags, TOTAG_VALUE_LEN, 
801 805
 						t->uas.request, &res_len );
802 806
 			} else {
803 807
 				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 100
 inline static int w_t_newdlg( struct sip_msg* p_msg, char* foo, char* bar );
95 101
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
96 102
 inline static int w_t_relay_to( struct sip_msg  *p_msg , char *proxy, char *);
103
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , char *proxy, 
104
+									char *);
105
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , char *proxy,
106
+									char *);
97 107
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
98
-	char *proxy, /* struct proxy_l *proxy expected */
99
-	char *_foo       /* nothing expected */ );
108
+							char *proxy, /* struct proxy_l *proxy expected */
109
+							char *_foo       /* nothing expected */ );
110
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
111
+							char *proxy, /* struct proxy_l *proxy expected */
112
+							char *_foo       /* nothing expected */ );
113
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
114
+							char *proxy, /* struct proxy_l *proxy expected */
115
+							char *_foo       /* nothing expected */ );
100 116
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
117
+inline static int w_t_forward_nonack_udp(struct sip_msg* msg, char* str,char*);
118
+inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
101 119
 inline static int fixup_hostport2proxy(void** param, int param_no);
102 120
 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
103 121
 
... ...
@@ -124,9 +142,15 @@ struct module_exports exports= {
124 142
 				"t_retransmit_reply",
125 143
 				"t_release",
126 144
 				T_RELAY_TO,
145
+				T_RELAY_TO_UDP,
146
+				T_RELAY_TO_TCP,
127 147
 				"t_replicate",
148
+				"t_replicate_udp",
149
+				"t_replicate_tcp",
128 150
 				T_RELAY,
129 151
 				T_FORWARD_NONACK,
152
+				T_FORWARD_NONACK_UDP,
153
+				T_FORWARD_NONACK_TCP,
130 154
 				"t_on_negative",
131 155
 
132 156
 				/* not applicable from script ... */
... ...
@@ -155,9 +179,15 @@ struct module_exports exports= {
155 179
 					w_t_retransmit_reply,
156 180
 					w_t_release,
157 181
 					w_t_relay_to,
182
+					w_t_relay_to_udp,
183
+					w_t_relay_to_tcp,
158 184
 					w_t_replicate,
185
+					w_t_replicate_udp,
186
+					w_t_replicate_tcp,
159 187
 					w_t_relay,
160 188
 					w_t_forward_nonack,
189
+					w_t_forward_nonack_udp,
190
+					w_t_forward_nonack_tcp,
161 191
 					w_t_on_negative,
162 192
 
163 193
 					(cmd_function) register_tmcb,
... ...
@@ -184,9 +214,15 @@ struct module_exports exports= {
184 214
 				0, /* t_retransmit_reply */
185 215
 				0, /* t_release */
186 216
 				2, /* t_relay_to */
217
+				2, /* t_relay_to_udp */
218
+				2, /* t_relay_to_tcp */
187 219
 				2, /* t_replicate */
220
+				2, /* t_replicate_udp */
221
+				2, /* t_replicate_tcp */
188 222
 				0, /* t_relay */
189 223
 				2, /* t_forward_nonack */
224
+				2, /* t_forward_nonack_udp */
225
+				2, /* t_forward_nonack_tcp */
190 226
 				1, /* t_on_negative */
191 227
 				NO_SCRIPT /* register_tmcb */,
192 228
 #ifndef DEPRECATE_OLD_STUFF
... ...
@@ -212,9 +248,15 @@ struct module_exports exports= {
212 248
 				0,						/* t_retransmit_reply */
213 249
 				0,						/* t_release */
214 250
 				fixup_hostport2proxy,	/* t_relay_to */
251
+				fixup_hostport2proxy,	/* t_relay_to_udp */
252
+				fixup_hostport2proxy,	/* t_relay_to_tcp */
215 253
 				fixup_hostport2proxy,	/* t_replicate */
254
+				fixup_hostport2proxy,	/* t_replicate_udp */
255
+				fixup_hostport2proxy,	/* t_replicate_tcp */
216 256
 				0,						/* t_relay */
217 257
 				fixup_hostport2proxy,	/* t_forward_nonack */
258
+				fixup_hostport2proxy,	/* t_forward_nonack_udp */
259
+				fixup_hostport2proxy,	/* t_forward_nonack_tcp */
218 260
 				fixup_str2int,			/* t_on_negative */
219 261
 				0,						/* register_tmcb */
220 262
 #ifndef DEPRECATE_OLD_STUFF
... ...
@@ -240,7 +282,7 @@ struct module_exports exports= {
240 282
 #ifdef VOICE_MAIL
241 283
 	4+
242 284
 #endif
243
-	14,
285
+	14 + 6 /* *_(UDP|TCP) */,
244 286
 
245 287
 	/* ------------ exported variables ---------- */
246 288
 	(char *[]) { /* Module parameter names */
... ...
@@ -455,7 +497,7 @@ inline static int fixup_hostport2proxy(void** param, int param_no)
455 497
 		}
456 498
 		s.s = host;
457 499
 		s.len = strlen(host);
458
-		proxy=mk_proxy(&s, port);
500
+		proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
459 501
 		if (proxy==0) {
460 502
 			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
461 503
 				host );
... ...
@@ -506,7 +548,8 @@ inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
506 548
 
507 549
 
508 550
 
509
-inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _foo)
551
+inline static int _w_t_forward_nonack(struct sip_msg* msg, char* proxy,
552
+									 char* _foo, int proto)
510 553
 {
511 554
 	struct cell *t;
512 555
 	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 559
 			LOG(L_WARN,"WARNING: you don't really want to fwd hbh ACK\n");
517 560
 			return -1;
518 561
 		}
519
-		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy );
562
+		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy, proto );
520 563
 	} else {
521 564
 		DBG("DEBUG: t_forward_nonack: no transaction found\n");
522 565
 		return -1;
... ...
@@ -524,6 +567,25 @@ inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _fo
524 567
 }
525 568
 
526 569
 
570
+inline static int w_t_forward_nonack( struct sip_msg* msg, char* proxy,
571
+										char* foo)
572
+{
573
+	return _w_t_forward_nonack(msg, proxy, foo, msg->rcv.proto);
574
+};
575
+
576
+inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
577
+										char* foo)
578
+{
579
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_UDP);
580
+};
581
+
582
+inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
583
+										char* foo)
584
+{
585
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_TCP);
586
+};
587
+
588
+
527 589
 
528 590
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2)
529 591
 {
... ...
@@ -632,22 +694,56 @@ inline static int w_t_relay_to( struct sip_msg  *p_msg ,
632 694
 	char *proxy, /* struct proxy_l *proxy expected */
633 695
 	char *_foo       /* nothing expected */ )
634 696
 {
635
-	return t_relay_to( p_msg, ( struct proxy_l *) proxy,
697
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto,
698
+	0 /* no replication */ );
699
+}
700
+
701
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , 
702
+	char *proxy, /* struct proxy_l *proxy expected */
703
+	char *_foo       /* nothing expected */ )
704
+{
705
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_UDP,
636 706
 	0 /* no replication */ );
637 707
 }
638 708
 
709
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , 
710
+	char *proxy, /* struct proxy_l *proxy expected */
711
+	char *_foo       /* nothing expected */ )
712
+{
713
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_TCP,
714
+	0 /* no replication */ );
715
+}
716
+
717
+
718
+
639 719
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
640 720
 	char *proxy, /* struct proxy_l *proxy expected */
641 721
 	char *_foo       /* nothing expected */ )
642 722
 {
643
-	return t_replicate(p_msg, ( struct proxy_l *) proxy );
723
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto );
644 724
 }
645 725
 
726
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
727
+	char *proxy, /* struct proxy_l *proxy expected */
728
+	char *_foo       /* nothing expected */ )
729
+{
730
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
731
+}
732
+
733
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
734
+	char *proxy, /* struct proxy_l *proxy expected */
735
+	char *_foo       /* nothing expected */ )
736
+{
737
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TCP );
738
+}
739
+
740
+
741
+
646 742
 inline static int w_t_relay( struct sip_msg  *p_msg , 
647 743
 						char *_foo, char *_bar)
648 744
 {
649 745
 	return t_relay_to( p_msg, 
650
-		(struct proxy_l *) 0 /* no proxy */,
746
+		(struct proxy_l *) 0 /* no proxy */, p_msg->rcv.proto,
651 747
 		0 /* no replication */ );
652 748
 }
653 749
 
... ...
@@ -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 58
 #endif
57 59
 #define T_REPLY_UNSAFE "t_reply_unsafe"
58 60
 #define T_FORWARD_NONACK "t_forward_nonack"
61
+#define T_FORWARD_NONACK_UDP "t_forward_nonack_udp"
62
+#define T_FORWARD_NONACK_TCP "t_forward_nonack_tcp"
59 63
 
60 64
 
61 65
 
... ...
@@ -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 209
 }
208 210
 
209 211
 #ifndef DEPRECATE_OLD_STUFF
210
-int t_uac( str *msg_type, str *dst, 
212
+int t_uac( str *msg_type, str *dst, int proto, 
211 213
 	str *headers, str *body, str *from, 
212 214
 	transaction_cb completion_cb, void *cbp, 
213 215
 	dlg_t dlg)
... ...
@@ -230,7 +232,7 @@ int t_uac( str *msg_type, str *dst,
230 232
 	/* make -Wall shut up */
231 233
 	ret=0;
232 234
 
233
-	proxy=uri2proxy( dst );
235
+	proxy=uri2proxy( dst, proto );
234 236
 	if (proxy==0) {
235 237
 		ser_error=ret=E_BAD_ADDRESS;
236 238
 		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 244
 	hostent2su(&to, &proxy->host, proxy->addr_idx, 
243 245
 		(proxy->port)?htons(proxy->port):htons(SIP_PORT));
244 246
 	/* send_sock=get_send_socket( &to, PROTO_UDP ); */
245
-	send_sock=get_out_socket( &to, PROTO_UDP );
247
+	send_sock=get_out_socket( &to, proto );
246 248
 	if (send_sock==0) {
247 249
 		LOG(L_ERR, "ERROR: t_uac: no corresponding listening socket "
248 250
 			"for af %d\n", to.s.sa_family );
... ...
@@ -282,8 +284,10 @@ int t_uac( str *msg_type, str *dst,
282 284
 
283 285
 
284 286
 	request=&new_cell->uac[branch].request;
285
-	request->to=to;
286
-	request->send_sock=send_sock;
287
+	request->dst.to=to;
288
+	request->dst.send_sock=send_sock;
289
+	request->dst.proto=proto;
290
+	request->dst.proto_reserved1=0; /* no special connection required */
287 291
 
288 292
 	/* need to put in table to calculate label which is needed for printing */
289 293
 	LOCK_HASH(new_cell->hash_index);
... ...
@@ -344,12 +348,13 @@ done:
344 348
 }
345 349
 #endif
346 350
 
347
-static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
351
+static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su,
352
+									 int proto )
348 353
 {
349 354
 	struct proxy_l *proxy;
350 355
 	struct socket_info* send_sock;
351 356
 
352
-	proxy = uri2proxy(uri);
357
+	proxy = uri2proxy(uri, proto);
353 358
 	if (proxy == 0) {
354 359
 		ser_error = E_BAD_ADDRESS;
355 360
 		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 363
 
359 364
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
360 365
 			(proxy->port) ? htons(proxy->port) : htons(SIP_PORT));
361
-	send_sock=get_out_socket(to_su, PROTO_UDP);
366
+	send_sock=get_out_socket(to_su, proto);
362 367
 	if (send_sock == 0) {
363 368
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
364 369
 						to_su->s.sa_family );
... ...
@@ -428,6 +433,7 @@ static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
428 433
  */
429 434
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
430 435
 	      str* dst,                     /* Real destination (can be different than R-URI) */
436
+		  int proto,
431 437
 	      str* ruri,                    /* Request-URI */
432 438
 	      str* to,                      /* To - w/o tag*/
433 439
 	      str* from,                    /* From - w/o tag*/
... ...
@@ -464,7 +470,7 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
464 470
 		goto done;
465 471
 	}
466 472
 
467
-	send_sock=uri2sock( dst? dst: ruri, &to_su );
473
+	send_sock=uri2sock( dst? dst: ruri, &to_su, proto );
468 474
 	if (send_sock==0) {
469 475
 		LOG(L_ERR, "ERROR: t_uac_dlg: no socket found\n");
470 476
 		goto error00;
... ...
@@ -504,8 +510,10 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
504 510
 	new_cell->kr = REQ_FWDED;
505 511
 
506 512
 	request = &new_cell->uac[branch].request;
507
-	request->to = to_su;
508
-	request->send_sock = send_sock;
513
+	request->dst.to = to_su;
514
+	request->dst.send_sock = send_sock;
515
+	request->dst.proto = proto;
516
+	request->dst.proto_reserved1 = 0;
509 517
 
510 518
 	/* need to put in table to calculate label which is needed for printing */
511 519
 	LOCK_HASH(new_cell->hash_index);
... ...
@@ -677,7 +685,7 @@ int fifo_uac( FILE *stream, char *response_file )
677 685
 	} else {
678 686
 		shmem_file=0;
679 687
 	}
680
-	ret=t_uac(&sm,&sd,&sh,&sb, 0 /* default from */,
688
+	ret=t_uac(&sm,&sd, PROTO_UDP,&sh,&sb, 0 /* default from */,
681 689
 		fifo_callback,shmem_file,0 /* no dialog */);
682 690
 	if (ret>0) {
683 691
 		if (err2reason_phrase(ret, &sip_error, err_buf,
... ...
@@ -782,7 +790,7 @@ int fifo_uac_from( FILE *stream, char *response_file )
782 790
 	   will not be triggered and no feedback will be printed
783 791
 	   to shmem_file
784 792
 	*/
785
-	ret=t_uac(&sm,&sd,&sh,&sb, sf.len==0 ? 0 : &sf /* default from */,
793
+	ret=t_uac(&sm,&sd, PROTO_UDP, &sh,&sb, sf.len==0 ? 0: &sf/*default from*/,
786 794
 		fifo_callback,shmem_file,0 /* no dialog */);
787 795
 	if (ret<=0) {
788 796
 		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 829
 }
822 830
 
823 831
 
824
-static char *get_hfblock(str *uri, struct hdr_field *hf, int *l) 
832
+static char *get_hfblock(str *uri, struct hdr_field *hf, int *l, int proto) 
825 833
 {
826 834
 	struct str_list sl, *last, *new, *i, *foo;
827 835
 	int hf_avail, frag_len, total_len;
... ...
@@ -859,7 +867,7 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int *l)
859 867
 						if (!new) goto error;
860 868
 						/* substitute */
861 869
 						if (!sock_name) {
862
-							send_sock=uri2sock( uri, &to_su );
870
+							send_sock=uri2sock( uri, &to_su, proto );
863 871
 							if (!send_sock) {
864 872
 								LOG(L_ERR, "ERROR: get_hf_block: send_sock failed\n");
865 873
 								goto error;
... ...
@@ -1117,7 +1125,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
1117 1125
 	}
1118 1126
 
1119 1127
 	hfb.s=get_hfblock(outbound.len ? &outbound : &ruri, 
1120
-					faked_msg.headers, &hfb.len);
1128
+					faked_msg.headers, &hfb.len, PROTO_UDP);
1121 1129
 	if (!hfb.s) {
1122 1130
 		fifo_uac_error(response_file, 500, "no mem for hf block");
1123 1131
 		goto error;
... ...
@@ -1144,6 +1152,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
1144 1152
 	dummy_empty.s=0; dummy_empty.len=0;
1145 1153
 	ret=t_uac_dlg( &method, 
1146 1154
 		outbound.len ? &outbound: 0,
1155
+		PROTO_UDP,
1147 1156
 		&ruri, 
1148 1157
 		&faked_msg.to->body,	/* possibly w/to-tag in it */
1149 1158
 		&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 104
  * Send a request within a dialog
104 105
  */
105 106
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
106
-	      str* dst,                     /* Real destination (can be different than R-URI */
107
+	      str* dst,                     /* Real destination (can be different 
108
+										   than R-URI */
109
+		  int proto,
107 110
 	      str* ruri,                    /* Request-URI */
108 111
 	      str* to,                      /* To - including tag */
109 112
 	      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 46
 #include "../../str.h"
42 47
 #include "../../parser/msg_parser.h"
43 48
 
44
-inline static struct proxy_l *uri2proxy( str *uri )
49
+inline static struct proxy_l *uri2proxy( str *uri, int proto )
45 50
 {
46 51
 	struct sip_uri parsed_uri;
47 52
 	unsigned int  port; 
... ...
@@ -63,7 +68,7 @@ inline static struct proxy_l *uri2proxy( str *uri )
63 68
 	/* fixed use of SRV resolver
64 69
 	} else port=SIP_PORT; */
65 70
 	} else port=0;
66
-	p=mk_proxy(&(parsed_uri.host), port);
71
+	p=mk_proxy(&(parsed_uri.host), port, proto);
67 72
 	if (p==0) {
68 73
 		LOG(L_ERR, "ERROR: t_relay: bad host name in URI <%.*s>\n",
69 74
 			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 60
 
56 61
 
57 62
 
58
-/* searches for the proxy named 'name', on port 'port'
63
+/* searches for the proxy named 'name', on port 'port' with 
64
+   proto 'proto'; if proto==0 => proto wildcard (will match any proto)
59 65
    returns: pointer to proxy_l on success or 0 if not found */ 
60
-static struct proxy_l* find_proxy(str *name, unsigned short port)
66
+static struct proxy_l* find_proxy(str *name, unsigned short port, int proto)
61 67
 {
62 68
 	struct proxy_l* t;
63 69
 	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))
70
+		if (((t->name.len == name->len) &&
71
+			 ((proto==PROTO_NONE)||(t->proto==proto))&&
72
+			(strncasecmp(t->name.s, name->s, name->len)==0)) &&
73
+				(t->port==port))
65 74
 			break;
66 75
 	return t;
67 76
 }
... ...
@@ -169,12 +178,12 @@ void free_hostent(struct hostent *dst)
169 178
 
170 179
 
171 180
 
172
-struct proxy_l* add_proxy(str* name, unsigned short port)
181
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto)
173 182
 {
174 183
 	struct proxy_l* p;
175 184
 	
176
-	if ((p=find_proxy(name, port))!=0) return p;
177
-	if ((p=mk_proxy(name, port))==0) goto error;
185
+	if ((p=find_proxy(name, port, proto))!=0) return p;
186
+	if ((p=mk_proxy(name, port, proto))==0) goto error;
178 187
 	/* add p to the proxy list */
179 188
 	p->next=proxies;
180 189
 	proxies=p;
... ...
@@ -188,9 +197,9 @@ error:
188 197
 
189 198
 
190 199
 /* same as add_proxy, but it doesn't add the proxy to the list
191
- * uses also SRV if possible (quick hack) */
200
+ * uses also SRV if possible & port==0 (quick hack) */
192 201
 
193
-struct proxy_l* mk_proxy(str* name, unsigned short port)
202
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto)
194 203
 {
195 204
 	struct proxy_l* p;
196 205
 	struct hostent* he;
... ...
@@ -204,9 +213,10 @@ struct proxy_l* mk_proxy(str* name, unsigned short port)
204 213
 	memset(p,0,sizeof(struct proxy_l));
205 214
 	p->name=*name;
206 215
 	p->port=port;
216
+	p->proto=proto;
207 217
 
208 218
 	DBG("DEBUG: mk_proxy: doing DNS lookup...\n");
209
-	he=sip_resolvehost(name, &(p->port));
219
+	he=sip_resolvehost(name, &(p->port), proto);
210 220
 	if (he==0){
211 221
 		ser_error=E_BAD_ADDRESS;
212 222
 		LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
... ...
@@ -227,7 +237,8 @@ error:
227 237
 
228 238
 
229 239
 /* 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)
240
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
241
+									int proto)
231 242
 {
232 243
 	struct proxy_l* p;
233 244
 
... ...
@@ -239,6 +250,7 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port)
239 250
 	memset(p,0,sizeof(struct proxy_l));
240 251
 
241 252
 	p->port=port;
253
+	p->proto=proto;
242 254
 	p->host.h_addrtype=ip->af;
243 255
 	p->host.h_length=ip->len;
244 256
 	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 45
 	struct hostent host; /* addresses */
41 46
 	unsigned short port;
42 47
 	unsigned short reserved; /*align*/
48
+	int proto;
43 49
 	
44 50
 	/* socket ? */
45 51
 
... ...
@@ -53,9 +59,10 @@ struct proxy_l{
53 59
 
54 60
 extern struct proxy_l* proxies;
55 61
 
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);
62
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto);
63
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto);
64
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
65
+									int proto);
59 66
 void free_proxy(struct proxy_l* p);
60 67
 
61 68
 
... ...
@@ -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 453
 
449 454
 /* resolves a host name trying SRV lookup if *port==0 or normal A/AAAA lookup
450 455
  * if *port!=0.
456
+ * when performing SRV lookup (*port==0) it will use proto to look for
457
+ * tcp or udp hosts, otherwise proto is unused; if proto==0 => no SRV lookup
451 458
  * returns: hostent struct & *port filled with the port from the SRV record;
452 459
  *  0 on error
453 460
  */
454
-struct hostent* sip_resolvehost(str* name, unsigned short* port)
461
+struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto)
455 462
 {
456 463
 	struct hostent* he;
457 464
 	struct rdata* head;
... ...
@@ -477,9 +484,24 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
477 484
 				return ip_addr2he(name,ip);
478 485
 			}
479 486
 			
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';
487
+			switch(proto){
488
+				case PROTO_NONE: /* no proto specified, use udp */
489
+					goto skip_srv;
490
+				case PROTO_UDP:
491
+					memcpy(tmp, SRV_UDP_PREFIX, SRV_PREFIX_LEN);
492
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
493
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
494
+					break;
495
+				case PROTO_TCP:
496
+					memcpy(tmp, SRV_TCP_PREFIX, SRV_PREFIX_LEN);
497
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
498
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
499
+					break;
500
+				default:
501
+					LOG(L_CRIT, "BUG: sip_resolvehost: unknown proto %d\n",
502
+							proto);
503
+					return 0;
504
+			}
483 505
 
484 506
 			head=get_record(tmp, T_SRV);
485 507
 			for(l=head; l; l=l->next){
... ...
@@ -504,7 +526,7 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
504 526
 					" trying 'normal' lookup...\n", name->len, name->s);
505 527
 		}
506 528
 	}
507
-
529
+skip_srv:
508 530
 	if (name->len >= MAX_DNS_NAME) {
509 531
 		LOG(L_ERR, "sip_resolvehost: domain name too long\n");
510 532
 		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 48
 #include "crc.h"
43 49
 #include "str.h"
44 50
 
45
-#define TOTAG_LEN (MD5_LEN+CRC16_LEN+1)
51
+#define TOTAG_VALUE_LEN (MD5_LEN+CRC16_LEN+1)
46 52
 
47 53
 /* generate variable part of to-tag for a request;
48 54
  * it will have length of CRC16_LEN, sufficiently