Explorar o código

- 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 %!s(int64=22) %!d(string=hai) anos
pai
achega
d531a5d5c4
Modificáronse 29 ficheiros con 336 adicións e 119 borrados
  1. 1 1
      Makefile.defs
  2. 7 0
      TODO
  3. 1 1
      action.c
  4. 2 1
      config.h
  5. 1 1
      forward.c
  6. 15 2
      ip_addr.h
  7. 2 3
      modules/tm/h_table.c
  8. 2 3
      modules/tm/h_table.h
  9. 1 2
      modules/tm/t_cancel.c
  10. 16 10
      modules/tm/t_funcs.c
  11. 5 1
      modules/tm/t_funcs.h
  12. 20 14
      modules/tm/t_fwd.c
  13. 10 3
      modules/tm/t_fwd.h
  14. 17 10
      modules/tm/t_lookup.c
  15. 5 4
      modules/tm/t_msgbuilder.c
  16. 13 9
      modules/tm/t_reply.c
  17. 105 9
      modules/tm/tm.c
  18. 1 1
      modules/tm/tm_load.c
  19. 4 0
      modules/tm/tm_load.h
  20. 28 19
      modules/tm/uac.c
  21. 4 1
      modules/tm/uac.h
  22. 7 2
      modules/tm/ut.h
  23. 1 1
      msg_translator.c
  24. 22 10
      proxy.c
  25. 10 3
      proxy.h
  26. 27 5
      resolve.c
  27. 1 1
      resolve.h
  28. 1 1
      route.c
  29. 7 1
      tags.h

+ 1 - 1
Makefile.defs

@@ -8,7 +8,7 @@
 VERSION = 0
 VERSION = 0
 PATCHLEVEL = 8
 PATCHLEVEL = 8
 SUBLEVEL =   11
 SUBLEVEL =   11
-EXTRAVERSION = pre6-tcp4
+EXTRAVERSION = pre6-tcp5-tm
 
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 7 - 0
TODO

@@ -72,3 +72,10 @@ x generic locking lib
 - force add rport (setflag(rport)???)
 - force add rport (setflag(rport)???)
 - kill all the fprintf
 - kill all the fprintf
 
 
+tm optimizations:
+
+- replace snprintfs int build_uac_request, *_dlg
+- fix the huge param no. in this functions (use structs if neccessary):
+  build_uac_request, build_uac_request_dlg, t_uac, t_uac_dlg
+  
+

+ 1 - 1
action.c

@@ -129,7 +129,7 @@ int do_action(struct action* a, struct sip_msg* msg)
 							goto error_fwd_uri;
 							goto error_fwd_uri;
 				}
 				}
 				/* create a temporary proxy*/
 				/* create a temporary proxy*/
-				p=mk_proxy(&u->host, port);
+				p=mk_proxy(&u->host, port, proto);
 				if (p==0){
 				if (p==0){
 					LOG(L_ERR, "ERROR:  bad host name in uri,"
 					LOG(L_ERR, "ERROR:  bad host name in uri,"
 							" dropping packet\n");
 							" dropping packet\n");

+ 2 - 1
config.h

@@ -91,7 +91,8 @@
 #define ID_PARAM ";i="
 #define ID_PARAM ";i="
 #define ID_PARAM_LEN 3
 #define ID_PARAM_LEN 3
 
 
-#define SRV_PREFIX "_sip._udp."
+#define SRV_UDP_PREFIX "_sip._udp."
+#define SRV_TCP_PREFIX "_sip._tcp."
 #define SRV_PREFIX_LEN 10
 #define SRV_PREFIX_LEN 10
 
 
 /*used only if PKG_MALLOC is defined*/
 /*used only if PKG_MALLOC is defined*/

+ 1 - 1
forward.c

@@ -375,7 +375,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
 	    sip_resolvehost now accepts str -janakj
 	    sip_resolvehost now accepts str -janakj
 	*/
 	*/
 	DBG("update_sock_struct_from_via: trying SRV lookup\n");
 	DBG("update_sock_struct_from_via: trying SRV lookup\n");
-	he=sip_resolvehost(name, &port);
+	he=sip_resolvehost(name, &port, via->proto);
 	
 	
 	if (he==0){
 	if (he==0){
 		LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%.*s) failure\n",
 		LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%.*s) failure\n",

+ 15 - 2
ip_addr.h

@@ -25,7 +25,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
-
+/*
+ * History:
+ * --------
+ *  2003-02-13  added struct dest_info (andrei)
+ */
 
 
 #ifndef ip_addr_h
 #ifndef ip_addr_h
 #define ip_addr_h
 #define ip_addr_h
@@ -40,7 +44,7 @@
 
 
 #include "dprint.h"
 #include "dprint.h"
 
 
-enum sip_protos { PROTO_UDP, PROTO_TCP, PROTO_TLS };
+enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS };
 
 
 
 
 struct ip_addr{
 struct ip_addr{
@@ -101,6 +105,15 @@ struct receive_info{
 };
 };
 
 
 
 
+struct dest_info{
+	int proto;
+	int proto_reserved1; /* tcp stores the connection id here */ 
+	union sockaddr_union to;
+	struct socket_info* send_sock;
+};
+
+
+
 /* len of the sockaddr */
 /* len of the sockaddr */
 #ifdef HAVE_SOCKADDR_SA_LEN
 #ifdef HAVE_SOCKADDR_SA_LEN
 #define sockaddru_len(su)	((su).s.sa_len)
 #define sockaddru_len(su)	((su).s.sa_len)

+ 2 - 3
modules/tm/h_table.c

@@ -161,7 +161,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	new_cell->uas.response.retr_timer.tg=TG_RT;
 	new_cell->uas.response.retr_timer.tg=TG_RT;
 	new_cell->uas.response.fr_timer.tg=TG_FR;
 	new_cell->uas.response.fr_timer.tg=TG_FR;
 	new_cell->uas.response.fr_timer.payload =
 	new_cell->uas.response.fr_timer.payload =
-		new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
+	new_cell->uas.response.retr_timer.payload = &(new_cell->uas.response);
 	new_cell->uas.response.my_T=new_cell;
 	new_cell->uas.response.my_T=new_cell;
 
 
 	/* bogdan - debug */
 	/* bogdan - debug */
@@ -186,8 +186,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 		uac->request.fr_timer.tg = TG_FR;
 		uac->request.fr_timer.tg = TG_FR;
 		uac->request.retr_timer.tg = TG_RT;
 		uac->request.retr_timer.tg = TG_RT;
 		uac->request.retr_timer.payload = 
 		uac->request.retr_timer.payload = 
-			uac->request.fr_timer.payload =
-			&uac->request;
+		uac->request.fr_timer.payload = &uac->request;
 		uac->local_cancel=uac->request;
 		uac->local_cancel=uac->request;
 	}
 	}
 
 

+ 2 - 3
modules/tm/h_table.h

@@ -82,9 +82,8 @@ typedef struct retr_buf
 
 
 	char *buffer;
 	char *buffer;
 	int   buffer_len;
 	int   buffer_len;
-
-	union sockaddr_union to;
-	struct socket_info* send_sock;
+	
+	struct dest_info dst;
 
 
 	/* a message can be linked just to retransmission and FR list */
 	/* a message can be linked just to retransmission and FR list */
 	struct timer_link retr_timer;
 	struct timer_link retr_timer;

+ 1 - 2
modules/tm/t_cancel.c

@@ -94,8 +94,7 @@ void cancel_branch( struct cell *t, int branch )
 	/* install cancel now */
 	/* install cancel now */
 	crb->buffer=cancel;
 	crb->buffer=cancel;
 	crb->buffer_len=len;
 	crb->buffer_len=len;
-	crb->to=irb->to;
-	crb->send_sock=irb->send_sock;
+	crb->dst=irb->dst;
 	crb->branch=branch;
 	crb->branch=branch;
 #ifdef _OBSOLETED
 #ifdef _OBSOLETED
 	crb->fr_timer.tg=TG_FR;
 	crb->fr_timer.tg=TG_FR;

+ 16 - 10
modules/tm/t_funcs.c

@@ -26,6 +26,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * -------
+ *  2003-02-13  modified send_pr_buffer to use msg_send & rb->dst (andrei)
+ */
 
 
 
 
 #include "defs.h"
 #include "defs.h"
@@ -51,7 +56,8 @@ int send_pr_buffer( struct retr_buf *rb,
 	void *buf, int len, char *function, int line )
 	void *buf, int len, char *function, int line )
 {
 {
 	if (buf && len && rb )
 	if (buf && len && rb )
-		return udp_send( rb->send_sock, buf, len, &rb->to) ;
+		return msg_send( rb->dst.send_sock, rb->dst.proto, &rb->dst.to,
+				         rb->dst.proto_reserved1, buf, len);
 	else {
 	else {
 		LOG(L_CRIT, "ERROR: sending an empty buffer from %s (%d)\n",
 		LOG(L_CRIT, "ERROR: sending an empty buffer from %s (%d)\n",
 			function, line );
 			function, line );
@@ -177,8 +183,8 @@ static int kill_transaction( struct cell *trans )
 
 
 
 
 
 
-int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
-	int replicate)
+int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
+				int replicate)
 {
 {
 	int ret;
 	int ret;
 	int new_tran;
 	int new_tran;
@@ -219,12 +225,12 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
 			uri=(p_msg->new_uri.s==0 || p_msg->new_uri.len==0) ?
 			uri=(p_msg->new_uri.s==0 || p_msg->new_uri.len==0) ?
 				&p_msg->first_line.u.request.uri :
 				&p_msg->first_line.u.request.uri :
 				&p_msg->new_uri;
 				&p_msg->new_uri;
-			proxy=uri2proxy( uri );
+			proxy=uri2proxy( uri, proto );
 			if (proxy==0) {
 			if (proxy==0) {
 					ret=E_BAD_ADDRESS;
 					ret=E_BAD_ADDRESS;
 					goto done;
 					goto done;
 			}
 			}
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto) ;
+			ret=forward_request( p_msg , proxy, proto) ;
 			free_proxy( proxy );	
 			free_proxy( proxy );	
 			free( proxy );
 			free( proxy );
 #ifdef ACK_FORKING_HACK
 #ifdef ACK_FORKING_HACK
@@ -232,22 +238,22 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
 			init_branch_iterator();
 			init_branch_iterator();
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
 				p_msg->new_uri=ack_uri;
 				p_msg->new_uri=ack_uri;
-				proxy=uri2proxy(ack_uri);
+				proxy=uri2proxy(ack_uri, proto);
 				if (proxy==0) continue;
 				if (proxy==0) continue;
-				forward_request(p_msg, proxy);
+				forward_request(p_msg, proxy, proto);
 				free_proxy( proxy );	
 				free_proxy( proxy );	
 				free( proxy );
 				free( proxy );
 			}
 			}
 			p_msg->new_uri=backup_uri;
 			p_msg->new_uri=backup_uri;
 #endif
 #endif
 		} else {
 		} else {
-			ret=forward_request( p_msg , proxy, p_msg->rcv.proto ) ;
+			ret=forward_request( p_msg , proxy, proto ) ;
 #ifdef ACK_FORKING_HACK
 #ifdef ACK_FORKING_HACK
 			backup_uri=p_msg->new_uri;
 			backup_uri=p_msg->new_uri;
 			init_branch_iterator();
 			init_branch_iterator();
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
 				p_msg->new_uri=ack_uri;
 				p_msg->new_uri=ack_uri;
-				forward_request(p_msg, proxy);
+				forward_request(p_msg, proxy, proto);
 			}
 			}
 			p_msg->new_uri=backup_uri;
 			p_msg->new_uri=backup_uri;
 #endif
 #endif
@@ -272,7 +278,7 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
 	} 
 	} 
 
 
 	/* now go ahead and forward ... */
 	/* now go ahead and forward ... */
-	ret=t_forward_nonack(t, p_msg, proxy);
+	ret=t_forward_nonack(t, p_msg, proxy, proto);
 	if (ret<=0) {
 	if (ret<=0) {
 		DBG( "SER:ERROR: t_forward \n");
 		DBG( "SER:ERROR: t_forward \n");
 		reply_ret=kill_transaction( t );
 		reply_ret=kill_transaction( t );

+ 5 - 1
modules/tm/t_funcs.h

@@ -24,6 +24,10 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+ /* History:
+  * --------
+  *  2003-02-18  updated various function prototypes (andrei)
+  */
 
 
 
 
 
 
@@ -127,7 +131,7 @@ void start_retr( struct retr_buf *rb );
 void cleanup_localcancel_timers( struct cell *t );
 void cleanup_localcancel_timers( struct cell *t );
 
 
 int t_relay_to( struct sip_msg  *p_msg ,
 int t_relay_to( struct sip_msg  *p_msg ,
-	struct proxy_l *proxy, int replicate ) ;
+	struct proxy_l *proxy, int proto, int replicate ) ;
 
 
 
 
 #endif
 #endif

+ 20 - 14
modules/tm/t_fwd.c

@@ -25,6 +25,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * -------
+ *  2003-02-13  proto support added (andrei)
+ */
 
 
 #include "defs.h"
 #include "defs.h"
 
 
@@ -127,10 +132,10 @@ error01:
 
 
 /* introduce a new uac to transaction; returns its branch id (>=0)
 /* introduce a new uac to transaction; returns its branch id (>=0)
    or error (<0); it doesn't send a message yet -- a reply to it
    or error (<0); it doesn't send a message yet -- a reply to it
-   might itnerfere with the processes of adding multiple branches
+   might interfere with the processes of adding multiple branches
 */
 */
 int add_uac( struct cell *t, struct sip_msg *request, str *uri, 
 int add_uac( struct cell *t, struct sip_msg *request, str *uri, 
-	struct proxy_l *proxy )
+	struct proxy_l *proxy, int proto )
 {
 {
 
 
 	int ret;
 	int ret;
@@ -157,7 +162,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
 
 
 	/* check DNS resolution */
 	/* check DNS resolution */
 	if (proxy) temp_proxy=0; else {
 	if (proxy) temp_proxy=0; else {
-		proxy=uri2proxy( uri );
+		proxy=uri2proxy( uri, proto );
 		if (proxy==0)  {
 		if (proxy==0)  {
 			ret=E_BAD_ADDRESS;
 			ret=E_BAD_ADDRESS;
 			goto error;
 			goto error;
@@ -175,7 +180,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
 		proxy->port ? htons(proxy->port):htons(SIP_PORT));
 		proxy->port ? htons(proxy->port):htons(SIP_PORT));
 
 
-	send_sock=get_send_socket( &to , request->rcv.proto);
+	send_sock=get_send_socket( &to , proto);
 	if (send_sock==0) {
 	if (send_sock==0) {
 		LOG(L_ERR, "ERROR: add_uac: can't fwd to af %d "
 		LOG(L_ERR, "ERROR: add_uac: can't fwd to af %d "
 			" (no corresponding listening socket)\n",
 			" (no corresponding listening socket)\n",
@@ -193,8 +198,10 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri,
 	}
 	}
 
 
 	/* things went well, move ahead and install new buffer! */
 	/* things went well, move ahead and install new buffer! */
-	t->uac[branch].request.to=to;
-	t->uac[branch].request.send_sock=send_sock;
+	t->uac[branch].request.dst.to=to;
+	t->uac[branch].request.dst.send_sock=send_sock;
+	t->uac[branch].request.dst.proto=proto;
+	t->uac[branch].request.dst.proto_reserved1=0;
 	t->uac[branch].request.buffer=shbuf;
 	t->uac[branch].request.buffer=shbuf;
 	t->uac[branch].request.buffer_len=len;
 	t->uac[branch].request.buffer_len=len;
 	t->uac[branch].uri.s=t->uac[branch].request.buffer+
 	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,
 	/* print */
 	/* print */
 	shbuf=print_uac_request( t_cancel, cancel_msg, branch, 
 	shbuf=print_uac_request( t_cancel, cancel_msg, branch, 
 		&t_invite->uac[branch].uri, &len, 
 		&t_invite->uac[branch].uri, &len, 
-		t_invite->uac[branch].request.send_sock);
+		t_invite->uac[branch].request.dst.send_sock);
 	if (!shbuf) {
 	if (!shbuf) {
 		LOG(L_ERR, "ERROR: e2e_cancel_branch: printing e2e cancel failed\n");
 		LOG(L_ERR, "ERROR: e2e_cancel_branch: printing e2e cancel failed\n");
 		ret=ser_error=E_OUT_OF_MEM;
 		ret=ser_error=E_OUT_OF_MEM;
@@ -246,8 +253,7 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
 	}
 	}
 	
 	
 	/* install buffer */
 	/* install buffer */
-	t_cancel->uac[branch].request.to=t_invite->uac[branch].request.to;
-	t_cancel->uac[branch].request.send_sock=t_invite->uac[branch].request.send_sock;
+	t_cancel->uac[branch].request.dst=t_invite->uac[branch].request.dst;
 	t_cancel->uac[branch].request.buffer=shbuf;
 	t_cancel->uac[branch].request.buffer=shbuf;
 	t_cancel->uac[branch].request.buffer_len=len;
 	t_cancel->uac[branch].request.buffer_len=len;
 	t_cancel->uac[branch].uri.s=t_cancel->uac[branch].request.buffer+
 	t_cancel->uac[branch].uri.s=t_cancel->uac[branch].request.buffer+
@@ -344,7 +350,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
  *      -1 - error during forward
  *      -1 - error during forward
  */
  */
 int t_forward_nonack( struct cell *t, struct sip_msg* p_msg , 
 int t_forward_nonack( struct cell *t, struct sip_msg* p_msg , 
-	struct proxy_l * proxy )
+	struct proxy_l * proxy, int proto)
 {
 {
 	str          backup_uri;
 	str          backup_uri;
 	int branch_ret, lowest_ret;
 	int branch_ret, lowest_ret;
@@ -384,7 +390,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 		branch_ret=add_uac( t, p_msg, 
 		branch_ret=add_uac( t, p_msg, 
 			p_msg->new_uri.s ? &p_msg->new_uri :  
 			p_msg->new_uri.s ? &p_msg->new_uri :  
 				&p_msg->first_line.u.request.uri,
 				&p_msg->first_line.u.request.uri,
-			proxy );
+				proxy, proto );
 		if (branch_ret>=0) 
 		if (branch_ret>=0) 
 			added_branches |= 1<<branch_ret;
 			added_branches |= 1<<branch_ret;
 		else
 		else
@@ -393,7 +399,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 
 
 	init_branch_iterator();
 	init_branch_iterator();
 	while((current_uri.s=next_branch( &current_uri.len))) {
 	while((current_uri.s=next_branch( &current_uri.len))) {
-		branch_ret=add_uac( t, p_msg, &current_uri, proxy );
+		branch_ret=add_uac( t, p_msg, &current_uri, proxy, proto);
 		/* pick some of the errors in case things go wrong;
 		/* pick some of the errors in case things go wrong;
 		   note that picking lowest error is just as good as
 		   note that picking lowest error is just as good as
 		   any other algorithm which picks any other negative
 		   any other algorithm which picks any other negative
@@ -431,7 +437,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 	return 1;
 	return 1;
 }	
 }	
 
 
-int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy )
+int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy, int proto )
 {
 {
 	/* this is a quite horrible hack -- we just take the message
 	/* this is a quite horrible hack -- we just take the message
 	   as is, including Route-s, Record-route-s, and Vias ,
 	   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 )
 		if we want later to make it thoroughly, we need to
 		if we want later to make it thoroughly, we need to
 		introduce delete lumps for all the header fields above
 		introduce delete lumps for all the header fields above
 	*/
 	*/
-	return t_relay_to(p_msg, proxy, 1 /* replicate */);
+	return t_relay_to(p_msg, proxy, proto, 1 /* replicate */);
 }
 }

+ 10 - 3
modules/tm/t_fwd.h

@@ -25,6 +25,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * --------
+ *  2003-02-18  added proto to various function prototypes (andrei)
+ */
 
 
 
 
 #ifndef _T_FWD_H
 #ifndef _T_FWD_H
@@ -36,13 +41,15 @@
 
 
 typedef int (*tfwd_f)(struct sip_msg* p_msg , struct proxy_l * proxy );
 typedef int (*tfwd_f)(struct sip_msg* p_msg , struct proxy_l * proxy );
 
 
-int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy );
+int t_replicate(struct sip_msg *p_msg, struct proxy_l * proxy, int proto);
 char *print_uac_request( struct cell *t, struct sip_msg *i_req,
 char *print_uac_request( struct cell *t, struct sip_msg *i_req,
     int branch, str *uri, unsigned int *len, struct socket_info *send_sock );
     int branch, str *uri, unsigned int *len, struct socket_info *send_sock );
 void e2e_cancel( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite );
 void e2e_cancel( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite );
 int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite, int branch );
 int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel, struct cell *t_invite, int branch );
-int add_uac( struct cell *t, struct sip_msg *request, str *uri, struct proxy_l *proxy );
-int t_forward_nonack( struct cell *t, struct sip_msg* p_msg, struct proxy_l * p );
+int add_uac(	struct cell *t, struct sip_msg *request, str *uri,
+				struct proxy_l *proxy, int proto );
+int t_forward_nonack( struct cell *t, struct sip_msg* p_msg,
+						struct proxy_l * p, int proto);
 int t_forward_ack( struct sip_msg* p_msg );
 int t_forward_ack( struct sip_msg* p_msg );
 
 
 
 

+ 17 - 10
modules/tm/t_lookup.c

@@ -51,9 +51,10 @@
  *
  *
  * History:
  * History:
  * ----------
  * ----------
- * 2003-01-28 scratchpad removed (jiri)
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
- * 2003-01-23 options for disabling r-uri matching introduced (jiri)
+ * 2003-01-28  scratchpad removed (jiri)
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-01-23  options for disabling r-uri matching introduced (jiri)
+ * 2003-02-13  init_rb() is proto indep. & it uses struct dest_info (andrei)
  */
  */
 
 
 
 
@@ -750,31 +751,37 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
 	return ((T)?1:0) ;
 	return ((T)?1:0) ;
 }
 }
 
 
-int init_rb( struct retr_buf *rb, struct sip_msg *msg )
+int init_rb( struct retr_buf *rb, struct sip_msg *msg)
 {
 {
 	struct socket_info* send_sock;
 	struct socket_info* send_sock;
 	struct via_body* via;
 	struct via_body* via;
+	int proto;
 
 
+	via=msg->via1;
 	if (!reply_to_via) {
 	if (!reply_to_via) {
-		update_sock_struct_from_ip( &rb->to, msg );
+		update_sock_struct_from_ip( &rb->dst.to, msg );
+		proto=msg->rcv.proto;
 	} else {
 	} else {
-		via=msg->via1;
 		/*init retrans buffer*/
 		/*init retrans buffer*/
-		if (update_sock_struct_from_via( &(rb->to),via )==-1) {
+		if (update_sock_struct_from_via( &(rb->dst.to),via )==-1) {
 			LOG(L_ERR, "ERROR: init_rb: cannot lookup reply dst: %.*s\n",
 			LOG(L_ERR, "ERROR: init_rb: cannot lookup reply dst: %.*s\n",
 				via->host.len, via->host.s );
 				via->host.len, via->host.s );
 			ser_error=E_BAD_VIA;
 			ser_error=E_BAD_VIA;
 			return 0;
 			return 0;
 		}
 		}
+		proto=via->proto;
 	}
 	}
-	send_sock=get_send_socket(&rb->to, msg->rcv.proto);
+	rb->dst.proto=proto;
+	rb->dst.proto_reserved1=msg->rcv.proto_reserved1;
+	send_sock=get_send_socket(&rb->dst.to, proto);
 	if (send_sock==0) {
 	if (send_sock==0) {
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d "
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d "
-			"no socket\n", rb->to.s.sa_family);
+			"no socket\n", rb->dst.to.s.sa_family);
 		ser_error=E_BAD_VIA;
 		ser_error=E_BAD_VIA;
 		return 0;
 		return 0;
 	}
 	}
-	rb->send_sock=send_sock;
+	rb->dst.send_sock=send_sock;
+	
     return 1;
     return 1;
 }
 }
 
 

+ 5 - 4
modules/tm/t_msgbuilder.c

@@ -29,7 +29,8 @@
  *
  *
  * History:
  * History:
  * ----------
  * ----------
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-02-13  build_uac_request uses proto (andrei)
  */
  */
 
 
 #include "defs.h"
 #include "defs.h"
@@ -91,8 +92,8 @@ char *build_local(struct cell *Trans,unsigned int branch,
 		goto error;
 		goto error;
 	branch_str.s=branch_buf;
 	branch_str.s=branch_buf;
 	branch_str.len=branch_len;
 	branch_str.len=branch_len;
-	via=via_builder(&via_len, Trans->uac[branch].request.send_sock,
-		&branch_str, 0, Trans->uac[branch].request.send_sock->proto );
+	via=via_builder(&via_len, Trans->uac[branch].request.dst.send_sock,
+		&branch_str, 0, Trans->uac[branch].request.dst.proto );
 	if (!via)
 	if (!via)
 	{
 	{
 		LOG(L_ERR, "ERROR: t_build_and_send_CANCEL: "
 		LOG(L_ERR, "ERROR: t_build_and_send_CANCEL: "
@@ -260,7 +261,7 @@ char *build_uac_request(  str msg_type, str dst, str from,
 	branch_str.len=branch_len;
 	branch_str.len=branch_len;
 	
 	
 	via=via_builder(&via_len, t->uac[branch].request.send_sock,
 	via=via_builder(&via_len, t->uac[branch].request.send_sock,
-		&branch_str, 0, t->uac[branch].request.send_sock->proto);
+		&branch_str, 0, t->uac[branch].request.dst.proto);
 	
 	
 	if (!via) {
 	if (!via) {
 		LOG(L_ERR, "ERROR: build_uac_request: via building failed\n");
 		LOG(L_ERR, "ERROR: build_uac_request: via building failed\n");

+ 13 - 9
modules/tm/t_reply.c

@@ -27,8 +27,11 @@
  *
  *
  * History:
  * History:
  * --------
  * --------
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
- * 2003-01-19 faked lump list created in on_reply handlers
+ * 2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-01-19  faked lump list created in on_reply handlers
+ * 2003-02-13  updated to use rb->dst (andrei)
+ * 2003-02-18  replaced TOTAG_LEN w/ TOTAG_VALUE_LEN (TOTAG_LEN was defined
+ *             twice with different values!)  (andrei)
  */
  */
 
 
 #include "defs.h"
 #include "defs.h"
@@ -62,7 +65,7 @@
 enum route_mode rmode=MODE_REQUEST;
 enum route_mode rmode=MODE_REQUEST;
 
 
 /* private place where we create to-tags for replies */
 /* private place where we create to-tags for replies */
-static char tm_tags[TOTAG_LEN];
+static char tm_tags[TOTAG_VALUE_LEN];
 static char *tm_tag_suffix;
 static char *tm_tag_suffix;
 
 
 /* where to go if there is no positive reply */
 /* 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,
 		init_branch_iterator();
 		init_branch_iterator();
 		if (next_branch(&dummy)) {
 		if (next_branch(&dummy)) {
 			if (t_forward_nonack(Trans, origin_rq,
 			if (t_forward_nonack(Trans, origin_rq,
-						(struct proxy_l *) 0 ) <0) {
+						(struct proxy_l *) 0,
+						Trans->uas.response.dst.proto)<0) {
 				/* error ... behave as if we did not try to
 				/* error ... behave as if we did not try to
 				   add a new branch */
 				   add a new branch */
 				*should_store=0;
 				*should_store=0;
@@ -456,7 +460,7 @@ int t_retransmit_reply( struct cell *t )
 	/* first check if we managed to resolve topmost Via -- if
 	/* first check if we managed to resolve topmost Via -- if
 	   not yet, don't try to retransmit
 	   not yet, don't try to retransmit
 	*/
 	*/
-	if (!t->uas.response.send_sock) {
+	if (!t->uas.response.dst.send_sock) {
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
 			"no resolved dst to retransmit\n");
 			"no resolved dst to retransmit\n");
 		return -1;
 		return -1;
@@ -550,12 +554,12 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg,
 			    || get_to(p_msg)->tag_value.len==0)) {
 			    || get_to(p_msg)->tag_value.len==0)) {
 		calc_crc_suffix( p_msg, tm_tag_suffix );
 		calc_crc_suffix( p_msg, tm_tag_suffix );
 		buf = build_res_buf_from_sip_req(code,text, 
 		buf = build_res_buf_from_sip_req(code,text, 
-				tm_tags, TOTAG_LEN, 
+				tm_tags, TOTAG_VALUE_LEN, 
 				p_msg,&len);
 				p_msg,&len);
 #ifdef VOICE_MAIL
 #ifdef VOICE_MAIL
 
 
 		return _reply_light(trans,buf,len,code,text,
 		return _reply_light(trans,buf,len,code,text,
-				    tm_tags, TOTAG_LEN,
+				    tm_tags, TOTAG_VALUE_LEN,
 				    lock);
 				    lock);
 #endif
 #endif
 	} else {
 	} else {
@@ -654,7 +658,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	/* first check if we managed to resolve topmost Via -- if
 	/* first check if we managed to resolve topmost Via -- if
 	   not yet, don't try to retransmit
 	   not yet, don't try to retransmit
 	*/
 	*/
-	if (!trans->uas.response.send_sock) {
+	if (!trans->uas.response.dst.send_sock) {
 		LOG(L_ERR, "ERROR: _reply: no resolved dst to send reply to\n");
 		LOG(L_ERR, "ERROR: _reply: no resolved dst to send reply to\n");
 	} else {
 	} else {
 		SEND_PR_BUFFER( rb, buf, len );
 		SEND_PR_BUFFER( rb, buf, len );
@@ -797,7 +801,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 				buf = build_res_buf_from_sip_req(
 				buf = build_res_buf_from_sip_req(
 						relayed_code,
 						relayed_code,
 						error_text(relayed_code),
 						error_text(relayed_code),
-						tm_tags, TOTAG_LEN, 
+						tm_tags, TOTAG_VALUE_LEN, 
 						t->uas.request, &res_len );
 						t->uas.request, &res_len );
 			} else {
 			} else {
 				buf = build_res_buf_from_sip_req( relayed_code,
 				buf = build_res_buf_from_sip_req( relayed_code,

+ 105 - 9
modules/tm/tm.c

@@ -51,6 +51,12 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * --------
+ *  2003-02-18  added t_forward_nonack_{udp, tcp}, t_relay_to_{udp,tcp},
+ *               t_replicate_{udp, tcp} (andrei)
+ */
 
 
 
 
 #include "defs.h"
 #include "defs.h"
@@ -94,10 +100,22 @@ inline static int w_t_newtran(struct sip_msg* p_msg, char* foo, char* bar );
 inline static int w_t_newdlg( struct sip_msg* p_msg, char* foo, char* bar );
 inline static int w_t_newdlg( struct sip_msg* p_msg, char* foo, char* bar );
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
 inline static int w_t_relay_to( struct sip_msg  *p_msg , char *proxy, char *);
 inline static int w_t_relay_to( struct sip_msg  *p_msg , char *proxy, char *);
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , char *proxy, 
+									char *);
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , char *proxy,
+									char *);
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
-	char *proxy, /* struct proxy_l *proxy expected */
-	char *_foo       /* nothing expected */ );
+							char *proxy, /* struct proxy_l *proxy expected */
+							char *_foo       /* nothing expected */ );
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
+							char *proxy, /* struct proxy_l *proxy expected */
+							char *_foo       /* nothing expected */ );
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
+							char *proxy, /* struct proxy_l *proxy expected */
+							char *_foo       /* nothing expected */ );
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
+inline static int w_t_forward_nonack_udp(struct sip_msg* msg, char* str,char*);
+inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
 inline static int fixup_hostport2proxy(void** param, int param_no);
 inline static int fixup_hostport2proxy(void** param, int param_no);
 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
 
 
@@ -124,9 +142,15 @@ struct module_exports exports= {
 				"t_retransmit_reply",
 				"t_retransmit_reply",
 				"t_release",
 				"t_release",
 				T_RELAY_TO,
 				T_RELAY_TO,
+				T_RELAY_TO_UDP,
+				T_RELAY_TO_TCP,
 				"t_replicate",
 				"t_replicate",
+				"t_replicate_udp",
+				"t_replicate_tcp",
 				T_RELAY,
 				T_RELAY,
 				T_FORWARD_NONACK,
 				T_FORWARD_NONACK,
+				T_FORWARD_NONACK_UDP,
+				T_FORWARD_NONACK_TCP,
 				"t_on_negative",
 				"t_on_negative",
 
 
 				/* not applicable from script ... */
 				/* not applicable from script ... */
@@ -155,9 +179,15 @@ struct module_exports exports= {
 					w_t_retransmit_reply,
 					w_t_retransmit_reply,
 					w_t_release,
 					w_t_release,
 					w_t_relay_to,
 					w_t_relay_to,
+					w_t_relay_to_udp,
+					w_t_relay_to_tcp,
 					w_t_replicate,
 					w_t_replicate,
+					w_t_replicate_udp,
+					w_t_replicate_tcp,
 					w_t_relay,
 					w_t_relay,
 					w_t_forward_nonack,
 					w_t_forward_nonack,
+					w_t_forward_nonack_udp,
+					w_t_forward_nonack_tcp,
 					w_t_on_negative,
 					w_t_on_negative,
 
 
 					(cmd_function) register_tmcb,
 					(cmd_function) register_tmcb,
@@ -184,9 +214,15 @@ struct module_exports exports= {
 				0, /* t_retransmit_reply */
 				0, /* t_retransmit_reply */
 				0, /* t_release */
 				0, /* t_release */
 				2, /* t_relay_to */
 				2, /* t_relay_to */
+				2, /* t_relay_to_udp */
+				2, /* t_relay_to_tcp */
 				2, /* t_replicate */
 				2, /* t_replicate */
+				2, /* t_replicate_udp */
+				2, /* t_replicate_tcp */
 				0, /* t_relay */
 				0, /* t_relay */
 				2, /* t_forward_nonack */
 				2, /* t_forward_nonack */
+				2, /* t_forward_nonack_udp */
+				2, /* t_forward_nonack_tcp */
 				1, /* t_on_negative */
 				1, /* t_on_negative */
 				NO_SCRIPT /* register_tmcb */,
 				NO_SCRIPT /* register_tmcb */,
 #ifndef DEPRECATE_OLD_STUFF
 #ifndef DEPRECATE_OLD_STUFF
@@ -212,9 +248,15 @@ struct module_exports exports= {
 				0,						/* t_retransmit_reply */
 				0,						/* t_retransmit_reply */
 				0,						/* t_release */
 				0,						/* t_release */
 				fixup_hostport2proxy,	/* t_relay_to */
 				fixup_hostport2proxy,	/* t_relay_to */
+				fixup_hostport2proxy,	/* t_relay_to_udp */
+				fixup_hostport2proxy,	/* t_relay_to_tcp */
 				fixup_hostport2proxy,	/* t_replicate */
 				fixup_hostport2proxy,	/* t_replicate */
+				fixup_hostport2proxy,	/* t_replicate_udp */
+				fixup_hostport2proxy,	/* t_replicate_tcp */
 				0,						/* t_relay */
 				0,						/* t_relay */
 				fixup_hostport2proxy,	/* t_forward_nonack */
 				fixup_hostport2proxy,	/* t_forward_nonack */
+				fixup_hostport2proxy,	/* t_forward_nonack_udp */
+				fixup_hostport2proxy,	/* t_forward_nonack_tcp */
 				fixup_str2int,			/* t_on_negative */
 				fixup_str2int,			/* t_on_negative */
 				0,						/* register_tmcb */
 				0,						/* register_tmcb */
 #ifndef DEPRECATE_OLD_STUFF
 #ifndef DEPRECATE_OLD_STUFF
@@ -240,7 +282,7 @@ struct module_exports exports= {
 #ifdef VOICE_MAIL
 #ifdef VOICE_MAIL
 	4+
 	4+
 #endif
 #endif
-	14,
+	14 + 6 /* *_(UDP|TCP) */,
 
 
 	/* ------------ exported variables ---------- */
 	/* ------------ exported variables ---------- */
 	(char *[]) { /* Module parameter names */
 	(char *[]) { /* Module parameter names */
@@ -455,7 +497,7 @@ inline static int fixup_hostport2proxy(void** param, int param_no)
 		}
 		}
 		s.s = host;
 		s.s = host;
 		s.len = strlen(host);
 		s.len = strlen(host);
-		proxy=mk_proxy(&s, port);
+		proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
 		if (proxy==0) {
 		if (proxy==0) {
 			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
 			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
 				host );
 				host );
@@ -506,7 +548,8 @@ inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
 
 
 
 
 
 
-inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _foo)
+inline static int _w_t_forward_nonack(struct sip_msg* msg, char* proxy,
+									 char* _foo, int proto)
 {
 {
 	struct cell *t;
 	struct cell *t;
 	if (t_check( msg , 0 )==-1) return -1;
 	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
 			LOG(L_WARN,"WARNING: you don't really want to fwd hbh ACK\n");
 			LOG(L_WARN,"WARNING: you don't really want to fwd hbh ACK\n");
 			return -1;
 			return -1;
 		}
 		}
-		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy );
+		return t_forward_nonack(t, msg, ( struct proxy_l *) proxy, proto );
 	} else {
 	} else {
 		DBG("DEBUG: t_forward_nonack: no transaction found\n");
 		DBG("DEBUG: t_forward_nonack: no transaction found\n");
 		return -1;
 		return -1;
@@ -524,6 +567,25 @@ inline static int w_t_forward_nonack(struct sip_msg* msg, char* proxy, char* _fo
 }
 }
 
 
 
 
+inline static int w_t_forward_nonack( struct sip_msg* msg, char* proxy,
+										char* foo)
+{
+	return _w_t_forward_nonack(msg, proxy, foo, msg->rcv.proto);
+};
+
+inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
+										char* foo)
+{
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_UDP);
+};
+
+inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
+										char* foo)
+{
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_TCP);
+};
+
+
 
 
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2)
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2)
 {
 {
@@ -632,22 +694,56 @@ inline static int w_t_relay_to( struct sip_msg  *p_msg ,
 	char *proxy, /* struct proxy_l *proxy expected */
 	char *proxy, /* struct proxy_l *proxy expected */
 	char *_foo       /* nothing expected */ )
 	char *_foo       /* nothing expected */ )
 {
 {
-	return t_relay_to( p_msg, ( struct proxy_l *) proxy,
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto,
+	0 /* no replication */ );
+}
+
+inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , 
+	char *proxy, /* struct proxy_l *proxy expected */
+	char *_foo       /* nothing expected */ )
+{
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_UDP,
 	0 /* no replication */ );
 	0 /* no replication */ );
 }
 }
 
 
+inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , 
+	char *proxy, /* struct proxy_l *proxy expected */
+	char *_foo       /* nothing expected */ )
+{
+	return t_relay_to( p_msg, ( struct proxy_l *) proxy, PROTO_TCP,
+	0 /* no replication */ );
+}
+
+
+
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
 	char *proxy, /* struct proxy_l *proxy expected */
 	char *proxy, /* struct proxy_l *proxy expected */
 	char *_foo       /* nothing expected */ )
 	char *_foo       /* nothing expected */ )
 {
 {
-	return t_replicate(p_msg, ( struct proxy_l *) proxy );
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto );
 }
 }
 
 
+inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
+	char *proxy, /* struct proxy_l *proxy expected */
+	char *_foo       /* nothing expected */ )
+{
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
+}
+
+inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
+	char *proxy, /* struct proxy_l *proxy expected */
+	char *_foo       /* nothing expected */ )
+{
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TCP );
+}
+
+
+
 inline static int w_t_relay( struct sip_msg  *p_msg , 
 inline static int w_t_relay( struct sip_msg  *p_msg , 
 						char *_foo, char *_bar)
 						char *_foo, char *_bar)
 {
 {
 	return t_relay_to( p_msg, 
 	return t_relay_to( p_msg, 
-		(struct proxy_l *) 0 /* no proxy */,
+		(struct proxy_l *) 0 /* no proxy */, p_msg->rcv.proto,
 		0 /* no replication */ );
 		0 /* no replication */ );
 }
 }
 
 

+ 1 - 1
modules/tm/tm_load.c

@@ -68,7 +68,7 @@ int load_tm( struct tm_binds *tmb)
 	        LOG( L_ERR, LOAD_ERROR "'t_reply' not found\n");
 	        LOG( L_ERR, LOAD_ERROR "'t_reply' not found\n");
 		return -1;
 		return -1;
 	}
 	}
-	if (!(tmb->t_is_local=(tget_ti_f)find_export(T_IS_LOCAL, NO_SCRIPT)) ) {
+	if (!(tmb->t_is_local=(tislocal_f)find_export(T_IS_LOCAL, NO_SCRIPT)) ) {
 	        LOG( L_ERR, LOAD_ERROR "'t_get_trans_ident' not found\n");
 	        LOG( L_ERR, LOAD_ERROR "'t_get_trans_ident' not found\n");
 		return -1;
 		return -1;
 	}
 	}

+ 4 - 0
modules/tm/tm_load.h

@@ -45,6 +45,8 @@
 #define NO_SCRIPT	-1
 #define NO_SCRIPT	-1
 
 
 #define T_RELAY_TO "t_relay_to"
 #define T_RELAY_TO "t_relay_to"
+#define T_RELAY_TO_UDP "t_relay_to_udp"
+#define T_RELAY_TO_TCP "t_relay_to_tcp"
 #define T_RELAY "t_relay"
 #define T_RELAY "t_relay"
 #ifndef DEPRECATE_OLD_STUFF
 #ifndef DEPRECATE_OLD_STUFF
 #	define T_UAC "t_uac"
 #	define T_UAC "t_uac"
@@ -56,6 +58,8 @@
 #endif
 #endif
 #define T_REPLY_UNSAFE "t_reply_unsafe"
 #define T_REPLY_UNSAFE "t_reply_unsafe"
 #define T_FORWARD_NONACK "t_forward_nonack"
 #define T_FORWARD_NONACK "t_forward_nonack"
+#define T_FORWARD_NONACK_UDP "t_forward_nonack_udp"
+#define T_FORWARD_NONACK_TCP "t_forward_nonack_tcp"
 
 
 
 
 
 

+ 28 - 19
modules/tm/uac.c

@@ -44,9 +44,11 @@
  *
  *
  * History:
  * History:
  * --------
  * --------
- * 2003-01-29 scratchpad removed (jiri)
- * 2003-01-27 fifo:t_uac_dlg completed (jiri)
- * 2003-01-23 t_uac_dlg now uses get_out_socket (jiri)
+ * 2003-01-29  scratchpad removed (jiri)
+ * 2003-01-27  fifo:t_uac_dlg completed (jiri)
+ * 2003-01-23  t_uac_dlg now uses get_out_socket (jiri)
+ * 2003-02-13  t_uac, t _uac_dlg, gethfblock, uri2proxy changed to use 
+ *              proto & rb->dst (andrei)
  */
  */
 
 
 
 
@@ -207,7 +209,7 @@ int uac_child_init( int rank )
 }
 }
 
 
 #ifndef DEPRECATE_OLD_STUFF
 #ifndef DEPRECATE_OLD_STUFF
-int t_uac( str *msg_type, str *dst, 
+int t_uac( str *msg_type, str *dst, int proto, 
 	str *headers, str *body, str *from, 
 	str *headers, str *body, str *from, 
 	transaction_cb completion_cb, void *cbp, 
 	transaction_cb completion_cb, void *cbp, 
 	dlg_t dlg)
 	dlg_t dlg)
@@ -230,7 +232,7 @@ int t_uac( str *msg_type, str *dst,
 	/* make -Wall shut up */
 	/* make -Wall shut up */
 	ret=0;
 	ret=0;
 
 
-	proxy=uri2proxy( dst );
+	proxy=uri2proxy( dst, proto );
 	if (proxy==0) {
 	if (proxy==0) {
 		ser_error=ret=E_BAD_ADDRESS;
 		ser_error=ret=E_BAD_ADDRESS;
 		LOG(L_ERR, "ERROR: t_uac: can't create a dst proxy\n");
 		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,
 	hostent2su(&to, &proxy->host, proxy->addr_idx, 
 	hostent2su(&to, &proxy->host, proxy->addr_idx, 
 		(proxy->port)?htons(proxy->port):htons(SIP_PORT));
 		(proxy->port)?htons(proxy->port):htons(SIP_PORT));
 	/* send_sock=get_send_socket( &to, PROTO_UDP ); */
 	/* send_sock=get_send_socket( &to, PROTO_UDP ); */
-	send_sock=get_out_socket( &to, PROTO_UDP );
+	send_sock=get_out_socket( &to, proto );
 	if (send_sock==0) {
 	if (send_sock==0) {
 		LOG(L_ERR, "ERROR: t_uac: no corresponding listening socket "
 		LOG(L_ERR, "ERROR: t_uac: no corresponding listening socket "
 			"for af %d\n", to.s.sa_family );
 			"for af %d\n", to.s.sa_family );
@@ -282,8 +284,10 @@ int t_uac( str *msg_type, str *dst,
 
 
 
 
 	request=&new_cell->uac[branch].request;
 	request=&new_cell->uac[branch].request;
-	request->to=to;
-	request->send_sock=send_sock;
+	request->dst.to=to;
+	request->dst.send_sock=send_sock;
+	request->dst.proto=proto;
+	request->dst.proto_reserved1=0; /* no special connection required */
 
 
 	/* need to put in table to calculate label which is needed for printing */
 	/* need to put in table to calculate label which is needed for printing */
 	LOCK_HASH(new_cell->hash_index);
 	LOCK_HASH(new_cell->hash_index);
@@ -344,12 +348,13 @@ done:
 }
 }
 #endif
 #endif
 
 
-static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
+static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su,
+									 int proto )
 {
 {
 	struct proxy_l *proxy;
 	struct proxy_l *proxy;
 	struct socket_info* send_sock;
 	struct socket_info* send_sock;
 
 
-	proxy = uri2proxy(uri);
+	proxy = uri2proxy(uri, proto);
 	if (proxy == 0) {
 	if (proxy == 0) {
 		ser_error = E_BAD_ADDRESS;
 		ser_error = E_BAD_ADDRESS;
 		LOG(L_ERR, "ERROR: uri2sock: Can't create a dst proxy\n");
 		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 )
 
 
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
 			(proxy->port) ? htons(proxy->port) : htons(SIP_PORT));
 			(proxy->port) ? htons(proxy->port) : htons(SIP_PORT));
-	send_sock=get_out_socket(to_su, PROTO_UDP);
+	send_sock=get_out_socket(to_su, proto);
 	if (send_sock == 0) {
 	if (send_sock == 0) {
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
 						to_su->s.sa_family );
 						to_su->s.sa_family );
@@ -428,6 +433,7 @@ static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su )
  */
  */
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
 	      str* dst,                     /* Real destination (can be different than R-URI) */
 	      str* dst,                     /* Real destination (can be different than R-URI) */
+		  int proto,
 	      str* ruri,                    /* Request-URI */
 	      str* ruri,                    /* Request-URI */
 	      str* to,                      /* To - w/o tag*/
 	      str* to,                      /* To - w/o tag*/
 	      str* from,                    /* From - w/o tag*/
 	      str* from,                    /* From - w/o tag*/
@@ -464,7 +470,7 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
 		goto done;
 		goto done;
 	}
 	}
 
 
-	send_sock=uri2sock( dst? dst: ruri, &to_su );
+	send_sock=uri2sock( dst? dst: ruri, &to_su, proto );
 	if (send_sock==0) {
 	if (send_sock==0) {
 		LOG(L_ERR, "ERROR: t_uac_dlg: no socket found\n");
 		LOG(L_ERR, "ERROR: t_uac_dlg: no socket found\n");
 		goto error00;
 		goto error00;
@@ -504,8 +510,10 @@ int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OP
 	new_cell->kr = REQ_FWDED;
 	new_cell->kr = REQ_FWDED;
 
 
 	request = &new_cell->uac[branch].request;
 	request = &new_cell->uac[branch].request;
-	request->to = to_su;
-	request->send_sock = send_sock;
+	request->dst.to = to_su;
+	request->dst.send_sock = send_sock;
+	request->dst.proto = proto;
+	request->dst.proto_reserved1 = 0;
 
 
 	/* need to put in table to calculate label which is needed for printing */
 	/* need to put in table to calculate label which is needed for printing */
 	LOCK_HASH(new_cell->hash_index);
 	LOCK_HASH(new_cell->hash_index);
@@ -677,7 +685,7 @@ int fifo_uac( FILE *stream, char *response_file )
 	} else {
 	} else {
 		shmem_file=0;
 		shmem_file=0;
 	}
 	}
-	ret=t_uac(&sm,&sd,&sh,&sb, 0 /* default from */,
+	ret=t_uac(&sm,&sd, PROTO_UDP,&sh,&sb, 0 /* default from */,
 		fifo_callback,shmem_file,0 /* no dialog */);
 		fifo_callback,shmem_file,0 /* no dialog */);
 	if (ret>0) {
 	if (ret>0) {
 		if (err2reason_phrase(ret, &sip_error, err_buf,
 		if (err2reason_phrase(ret, &sip_error, err_buf,
@@ -782,7 +790,7 @@ int fifo_uac_from( FILE *stream, char *response_file )
 	   will not be triggered and no feedback will be printed
 	   will not be triggered and no feedback will be printed
 	   to shmem_file
 	   to shmem_file
 	*/
 	*/
-	ret=t_uac(&sm,&sd,&sh,&sb, sf.len==0 ? 0 : &sf /* default from */,
+	ret=t_uac(&sm,&sd, PROTO_UDP, &sh,&sb, sf.len==0 ? 0: &sf/*default from*/,
 		fifo_callback,shmem_file,0 /* no dialog */);
 		fifo_callback,shmem_file,0 /* no dialog */);
 	if (ret<=0) {
 	if (ret<=0) {
 		err_ret=err2reason_phrase(ret, &sip_error, err_buf,
 		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
 }
 }
 
 
 
 
-static char *get_hfblock(str *uri, struct hdr_field *hf, int *l) 
+static char *get_hfblock(str *uri, struct hdr_field *hf, int *l, int proto) 
 {
 {
 	struct str_list sl, *last, *new, *i, *foo;
 	struct str_list sl, *last, *new, *i, *foo;
 	int hf_avail, frag_len, total_len;
 	int hf_avail, frag_len, total_len;
@@ -859,7 +867,7 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int *l)
 						if (!new) goto error;
 						if (!new) goto error;
 						/* substitute */
 						/* substitute */
 						if (!sock_name) {
 						if (!sock_name) {
-							send_sock=uri2sock( uri, &to_su );
+							send_sock=uri2sock( uri, &to_su, proto );
 							if (!send_sock) {
 							if (!send_sock) {
 								LOG(L_ERR, "ERROR: get_hf_block: send_sock failed\n");
 								LOG(L_ERR, "ERROR: get_hf_block: send_sock failed\n");
 								goto error;
 								goto error;
@@ -1117,7 +1125,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
 	}
 	}
 
 
 	hfb.s=get_hfblock(outbound.len ? &outbound : &ruri, 
 	hfb.s=get_hfblock(outbound.len ? &outbound : &ruri, 
-					faked_msg.headers, &hfb.len);
+					faked_msg.headers, &hfb.len, PROTO_UDP);
 	if (!hfb.s) {
 	if (!hfb.s) {
 		fifo_uac_error(response_file, 500, "no mem for hf block");
 		fifo_uac_error(response_file, 500, "no mem for hf block");
 		goto error;
 		goto error;
@@ -1144,6 +1152,7 @@ int fifo_uac_dlg( FILE *stream, char *response_file )
 	dummy_empty.s=0; dummy_empty.len=0;
 	dummy_empty.s=0; dummy_empty.len=0;
 	ret=t_uac_dlg( &method, 
 	ret=t_uac_dlg( &method, 
 		outbound.len ? &outbound: 0,
 		outbound.len ? &outbound: 0,
+		PROTO_UDP,
 		&ruri, 
 		&ruri, 
 		&faked_msg.to->body,	/* possibly w/to-tag in it */
 		&faked_msg.to->body,	/* possibly w/to-tag in it */
 		&faked_msg.from->body,
 		&faked_msg.from->body,

+ 4 - 1
modules/tm/uac.h

@@ -76,6 +76,7 @@ int t_uac(
 	str *msg_type,  
 	str *msg_type,  
 	/* sip:foo@bar, will be put in r-uri and To */
 	/* sip:foo@bar, will be put in r-uri and To */
 	str *dst,	
 	str *dst,	
+	int proto, 
 	/* all other header fields separated by CRLF, including 
 	/* all other header fields separated by CRLF, including 
 	   Content-type if body attached, excluding HFs
 	   Content-type if body attached, excluding HFs
 	   generated by UAC: To, Content_length, CSeq, Call-ID, Via, From
 	   generated by UAC: To, Content_length, CSeq, Call-ID, Via, From
@@ -103,7 +104,9 @@ int t_uac(
  * Send a request within a dialog
  * Send a request within a dialog
  */
  */
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
 int t_uac_dlg(str* msg,                     /* Type of the message - MESSAGE, OPTIONS etc. */
-	      str* dst,                     /* Real destination (can be different than R-URI */
+	      str* dst,                     /* Real destination (can be different 
+										   than R-URI */
+		  int proto,
 	      str* ruri,                    /* Request-URI */
 	      str* ruri,                    /* Request-URI */
 	      str* to,                      /* To - including tag */
 	      str* to,                      /* To - including tag */
 	      str* from,                    /* From - including tag */
 	      str* from,                    /* From - including tag */

+ 7 - 2
modules/tm/ut.h

@@ -27,6 +27,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * -------
+ *  2003-02-13  added proto to uri2proxy (andrei)
+*/
 
 
 
 
 #ifndef _TM_UT_H
 #ifndef _TM_UT_H
@@ -41,7 +46,7 @@
 #include "../../str.h"
 #include "../../str.h"
 #include "../../parser/msg_parser.h"
 #include "../../parser/msg_parser.h"
 
 
-inline static struct proxy_l *uri2proxy( str *uri )
+inline static struct proxy_l *uri2proxy( str *uri, int proto )
 {
 {
 	struct sip_uri parsed_uri;
 	struct sip_uri parsed_uri;
 	unsigned int  port; 
 	unsigned int  port; 
@@ -63,7 +68,7 @@ inline static struct proxy_l *uri2proxy( str *uri )
 	/* fixed use of SRV resolver
 	/* fixed use of SRV resolver
 	} else port=SIP_PORT; */
 	} else port=SIP_PORT; */
 	} else port=0;
 	} else port=0;
-	p=mk_proxy(&(parsed_uri.host), port);
+	p=mk_proxy(&(parsed_uri.host), port, proto);
 	if (p==0) {
 	if (p==0) {
 		LOG(L_ERR, "ERROR: t_relay: bad host name in URI <%.*s>\n",
 		LOG(L_ERR, "ERROR: t_relay: bad host name in URI <%.*s>\n",
 			uri->len, uri->s);
 			uri->len, uri->s);

+ 1 - 1
msg_translator.c

@@ -175,7 +175,7 @@ static int check_via_address(struct ip_addr* ip, str *name,
 	if (resolver&DO_DNS){
 	if (resolver&DO_DNS){
 		DBG("check_address: doing dns lookup\n");
 		DBG("check_address: doing dns lookup\n");
 		/* try all names ips */
 		/* try all names ips */
-		he=sip_resolvehost(name, &port);
+		he=sip_resolvehost(name, &port, 0); /* FIXME proto? */
 		if (he && ip->af==he->h_addrtype){
 		if (he && ip->af==he->h_addrtype){
 			for(i=0;he && he->h_addr_list[i];i++){
 			for(i=0;he && he->h_addr_list[i];i++){
 				if ( memcmp(&he->h_addr_list[i], ip->u.addr, ip->len)==0)
 				if ( memcmp(&he->h_addr_list[i], ip->u.addr, ip->len)==0)

+ 22 - 10
proxy.c

@@ -27,6 +27,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+ /*
+  * History:
+  * -------
+  *  2003-02-13  all *proxy fucntions are now proto aware (andrei)
+  */
 
 
 
 
 
 
@@ -55,13 +60,17 @@ struct proxy_l* proxies=0;
 
 
 
 
 
 
-/* searches for the proxy named 'name', on port 'port'
+/* searches for the proxy named 'name', on port 'port' with 
+   proto 'proto'; if proto==0 => proto wildcard (will match any proto)
    returns: pointer to proxy_l on success or 0 if not found */ 
    returns: pointer to proxy_l on success or 0 if not found */ 
-static struct proxy_l* find_proxy(str *name, unsigned short port)
+static struct proxy_l* find_proxy(str *name, unsigned short port, int proto)
 {
 {
 	struct proxy_l* t;
 	struct proxy_l* t;
 	for(t=proxies; t; t=t->next)
 	for(t=proxies; t; t=t->next)
-		if (((t->name.len == name->len) && (strncasecmp(t->name.s, name->s, name->len)==0)) && (t->port==port))
+		if (((t->name.len == name->len) &&
+			 ((proto==PROTO_NONE)||(t->proto==proto))&&
+			(strncasecmp(t->name.s, name->s, name->len)==0)) &&
+				(t->port==port))
 			break;
 			break;
 	return t;
 	return t;
 }
 }
@@ -169,12 +178,12 @@ void free_hostent(struct hostent *dst)
 
 
 
 
 
 
-struct proxy_l* add_proxy(str* name, unsigned short port)
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto)
 {
 {
 	struct proxy_l* p;
 	struct proxy_l* p;
 	
 	
-	if ((p=find_proxy(name, port))!=0) return p;
-	if ((p=mk_proxy(name, port))==0) goto error;
+	if ((p=find_proxy(name, port, proto))!=0) return p;
+	if ((p=mk_proxy(name, port, proto))==0) goto error;
 	/* add p to the proxy list */
 	/* add p to the proxy list */
 	p->next=proxies;
 	p->next=proxies;
 	proxies=p;
 	proxies=p;
@@ -188,9 +197,9 @@ error:
 
 
 
 
 /* same as add_proxy, but it doesn't add the proxy to the list
 /* same as add_proxy, but it doesn't add the proxy to the list
- * uses also SRV if possible (quick hack) */
+ * uses also SRV if possible & port==0 (quick hack) */
 
 
-struct proxy_l* mk_proxy(str* name, unsigned short port)
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto)
 {
 {
 	struct proxy_l* p;
 	struct proxy_l* p;
 	struct hostent* he;
 	struct hostent* he;
@@ -204,9 +213,10 @@ struct proxy_l* mk_proxy(str* name, unsigned short port)
 	memset(p,0,sizeof(struct proxy_l));
 	memset(p,0,sizeof(struct proxy_l));
 	p->name=*name;
 	p->name=*name;
 	p->port=port;
 	p->port=port;
+	p->proto=proto;
 
 
 	DBG("DEBUG: mk_proxy: doing DNS lookup...\n");
 	DBG("DEBUG: mk_proxy: doing DNS lookup...\n");
-	he=sip_resolvehost(name, &(p->port));
+	he=sip_resolvehost(name, &(p->port), proto);
 	if (he==0){
 	if (he==0){
 		ser_error=E_BAD_ADDRESS;
 		ser_error=E_BAD_ADDRESS;
 		LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
 		LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
@@ -227,7 +237,8 @@ error:
 
 
 
 
 /* same as mk_proxy, but get the host as an ip*/
 /* same as mk_proxy, but get the host as an ip*/
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port)
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
+									int proto)
 {
 {
 	struct proxy_l* p;
 	struct proxy_l* p;
 
 
@@ -239,6 +250,7 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port)
 	memset(p,0,sizeof(struct proxy_l));
 	memset(p,0,sizeof(struct proxy_l));
 
 
 	p->port=port;
 	p->port=port;
+	p->proto=proto;
 	p->host.h_addrtype=ip->af;
 	p->host.h_addrtype=ip->af;
 	p->host.h_length=ip->len;
 	p->host.h_length=ip->len;
 	p->host.h_addr_list=malloc(2*sizeof(char*));
 	p->host.h_addr_list=malloc(2*sizeof(char*));

+ 10 - 3
proxy.h

@@ -25,6 +25,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+ /*
+  * History:
+  * -------
+  *  2003-02-13  added proto to struct proxy_l & to *_proxy fucntions (andrei)
+  */
 
 
 
 
 #ifndef proxy_h
 #ifndef proxy_h
@@ -40,6 +45,7 @@ struct proxy_l{
 	struct hostent host; /* addresses */
 	struct hostent host; /* addresses */
 	unsigned short port;
 	unsigned short port;
 	unsigned short reserved; /*align*/
 	unsigned short reserved; /*align*/
+	int proto;
 	
 	
 	/* socket ? */
 	/* socket ? */
 
 
@@ -53,9 +59,10 @@ struct proxy_l{
 
 
 extern struct proxy_l* proxies;
 extern struct proxy_l* proxies;
 
 
-struct proxy_l* add_proxy(str* name, unsigned short port);
-struct proxy_l* mk_proxy(str* name, unsigned short port);
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port);
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto);
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto);
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
+									int proto);
 void free_proxy(struct proxy_l* p);
 void free_proxy(struct proxy_l* p);
 
 
 
 

+ 27 - 5
resolve.c

@@ -24,6 +24,11 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * -------
+ *  2003-02-13  added proto to sip_resolvehost, for SRV lookups (andrei)
+ */ 
 
 
 
 
 #include <sys/types.h>
 #include <sys/types.h>
@@ -448,10 +453,12 @@ not_found:
 
 
 /* resolves a host name trying SRV lookup if *port==0 or normal A/AAAA lookup
 /* resolves a host name trying SRV lookup if *port==0 or normal A/AAAA lookup
  * if *port!=0.
  * if *port!=0.
+ * when performing SRV lookup (*port==0) it will use proto to look for
+ * tcp or udp hosts, otherwise proto is unused; if proto==0 => no SRV lookup
  * returns: hostent struct & *port filled with the port from the SRV record;
  * returns: hostent struct & *port filled with the port from the SRV record;
  *  0 on error
  *  0 on error
  */
  */
-struct hostent* sip_resolvehost(str* name, unsigned short* port)
+struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto)
 {
 {
 	struct hostent* he;
 	struct hostent* he;
 	struct rdata* head;
 	struct rdata* head;
@@ -477,9 +484,24 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
 				return ip_addr2he(name,ip);
 				return ip_addr2he(name,ip);
 			}
 			}
 			
 			
-			memcpy(tmp, SRV_PREFIX, SRV_PREFIX_LEN);
-			memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
-			tmp[SRV_PREFIX_LEN + name->len] = '\0';
+			switch(proto){
+				case PROTO_NONE: /* no proto specified, use udp */
+					goto skip_srv;
+				case PROTO_UDP:
+					memcpy(tmp, SRV_UDP_PREFIX, SRV_PREFIX_LEN);
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
+					break;
+				case PROTO_TCP:
+					memcpy(tmp, SRV_TCP_PREFIX, SRV_PREFIX_LEN);
+					memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len);
+					tmp[SRV_PREFIX_LEN + name->len] = '\0';
+					break;
+				default:
+					LOG(L_CRIT, "BUG: sip_resolvehost: unknown proto %d\n",
+							proto);
+					return 0;
+			}
 
 
 			head=get_record(tmp, T_SRV);
 			head=get_record(tmp, T_SRV);
 			for(l=head; l; l=l->next){
 			for(l=head; l; l=l->next){
@@ -504,7 +526,7 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port)
 					" trying 'normal' lookup...\n", name->len, name->s);
 					" trying 'normal' lookup...\n", name->len, name->s);
 		}
 		}
 	}
 	}
-
+skip_srv:
 	if (name->len >= MAX_DNS_NAME) {
 	if (name->len >= MAX_DNS_NAME) {
 		LOG(L_ERR, "sip_resolvehost: domain name too long\n");
 		LOG(L_ERR, "sip_resolvehost: domain name too long\n");
 		return 0;
 		return 0;

+ 1 - 1
resolve.h

@@ -260,7 +260,7 @@ error_char:
 
 
 
 
 
 
-struct hostent* sip_resolvehost(str* name, unsigned short* port);
+struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto);
 
 
 
 
 
 

+ 1 - 1
route.c

@@ -169,7 +169,7 @@ static int fix_actions(struct action* a)
 						case STRING_ST:
 						case STRING_ST:
 							s.s = t->p1.string;
 							s.s = t->p1.string;
 							s.len = strlen(s.s);
 							s.len = strlen(s.s);
-							p=add_proxy(&s, t->p2.number);
+							p=add_proxy(&s, t->p2.number, 0); /* FIXME proto*/
 							if (p==0) return E_BAD_ADDRESS;
 							if (p==0) return E_BAD_ADDRESS;
 							t->p1.data=p;
 							t->p1.data=p;
 							t->p1_type=PROXY_ST;
 							t->p1_type=PROXY_ST;

+ 7 - 1
tags.h

@@ -33,6 +33,12 @@
  * along with this program; if not, write to the Free Software 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
+/*
+ * History:
+ * --------
+ *  2003-02-18  changed TOTAG_LEN into TOTAG_VALUE_LEN, to solve
+ *               redefinition conflict with tm/t_msgbuilder.h (andrei)
+ */
 
 
 
 
 #ifndef _TAGS_H
 #ifndef _TAGS_H
@@ -42,7 +48,7 @@
 #include "crc.h"
 #include "crc.h"
 #include "str.h"
 #include "str.h"
 
 
-#define TOTAG_LEN (MD5_LEN+CRC16_LEN+1)
+#define TOTAG_VALUE_LEN (MD5_LEN+CRC16_LEN+1)
 
 
 /* generate variable part of to-tag for a request;
 /* generate variable part of to-tag for a request;
  * it will have length of CRC16_LEN, sufficiently
  * it will have length of CRC16_LEN, sufficiently