Browse code

- tm send w/ PROTO_NONE fixes (from stable)

Andrei Pelinescu-Onciul authored on 07/07/2003 15:06:23
Showing 4 changed files
... ...
@@ -40,7 +40,7 @@ export makefile_defs
40 40
 VERSION = 0
41 41
 PATCHLEVEL = 8
42 42
 SUBLEVEL =   12
43
-EXTRAVERSION = dev-t07
43
+EXTRAVERSION = dev-t08
44 44
 
45 45
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
46 46
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -38,6 +38,7 @@
38 38
  *  2003-04-14  use protocol from uri (jiri)
39 39
  *  2003-04-25  do it (^) really everywhere (jiri)
40 40
  *  2003-04-26  do it (^) really really really everywhere (jiri)
41
+ *  2003-07-07  added get_proto calls when proxy!=0 (andrei)
41 42
  */
42 43
 
43 44
 
... ...
@@ -237,7 +238,8 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
237 238
 					ret=E_BAD_ADDRESS;
238 239
 					goto done;
239 240
 			}
240
-			ret=forward_request( p_msg , proxy, proxy->proto) ;
241
+			proto=proxy->proto; /* uri2proxy set it correctly */
242
+			ret=forward_request( p_msg , proxy, proto) ;
241 243
 			free_proxy( proxy );	
242 244
 			pkg_free( proxy );
243 245
 #ifdef ACK_FORKING_HACK
... ...
@@ -247,20 +249,21 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
247 249
 				p_msg->new_uri=ack_uri;
248 250
 				proxy=uri2proxy(GET_NEXT_HOP(p_msg), proto);
249 251
 				if (proxy==0) continue;
250
-				forward_request(p_msg, proxy, proxy->proto);
252
+				forward_request(p_msg, proxy, proxy->proto); /* ok, uri2proxy*/
251 253
 				free_proxy( proxy );	
252 254
 				pkg_free( proxy );
253 255
 			}
254 256
 			p_msg->new_uri=backup_uri;
255 257
 #endif
256 258
 		} else {
257
-			ret=forward_request( p_msg , proxy, proxy->proto ) ;
259
+			proto=get_proto(proto, proxy->proto);
260
+			ret=forward_request( p_msg , proxy, proto ) ;
258 261
 #ifdef ACK_FORKING_HACK
259 262
 			backup_uri=p_msg->new_uri;
260 263
 			init_branch_iterator();
261 264
 			while((ack_uri.s=next_branch(&ack_uri.len))) {
262 265
 				p_msg->new_uri=ack_uri;
263
-				forward_request(p_msg, proxy, proxy->proto);
266
+				forward_request(p_msg, proxy, proto);
264 267
 			}
265 268
 			p_msg->new_uri=backup_uri;
266 269
 #endif
... ...
@@ -189,8 +189,12 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
189 189
 	}
190 190
 
191 191
 	/* check DNS resolution */
192
-	if (proxy) temp_proxy=0; else {
192
+	if (proxy){
193
+		temp_proxy=0;
194
+		proto=get_proto(proto, proxy->proto);
195
+	}else {
193 196
 		proxy=uri2proxy( next_hop ? next_hop : uri, proto );
197
+		proto=proxy->proto; /* uri2proxy will fix it for us */
194 198
 		if (proxy==0)  {
195 199
 			ret=E_BAD_ADDRESS;
196 200
 			goto error;
... ...
@@ -208,18 +212,18 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
208 212
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
209 213
 		proxy->port ? proxy->port:SIP_PORT);
210 214
 
211
-	send_sock=get_send_socket( &to , proxy->proto);
215
+	send_sock=get_send_socket( &to , proto);
212 216
 	if (send_sock==0) {
213 217
 		LOG(L_ERR, "ERROR: add_uac: can't fwd to af %d, proto %d "
214 218
 			" (no corresponding listening socket)\n",
215
-			to.s.sa_family, proxy->proto );
219
+			to.s.sa_family, proto );
216 220
 		ret=ser_error=E_NO_SOCKET;
217 221
 		goto error01;
218 222
 	}
219 223
 
220 224
 	/* now message printing starts ... */
221 225
 	shbuf=print_uac_request( t, request, branch, uri, 
222
-		&len, send_sock, proxy->proto );
226
+		&len, send_sock, proto );
223 227
 	if (!shbuf) {
224 228
 		ret=ser_error=E_OUT_OF_MEM;
225 229
 		goto error01;
... ...
@@ -228,7 +232,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
228 232
 	/* things went well, move ahead and install new buffer! */
229 233
 	t->uac[branch].request.dst.to=to;
230 234
 	t->uac[branch].request.dst.send_sock=send_sock;
231
-	t->uac[branch].request.dst.proto=proxy->proto;
235
+	t->uac[branch].request.dst.proto=proto;
232 236
 	t->uac[branch].request.dst.proto_reserved1=0;
233 237
 	t->uac[branch].request.buffer=shbuf;
234 238
 	t->uac[branch].request.buffer_len=len;
... ...
@@ -33,6 +33,7 @@
33 33
  *  2003-04-09  uri2sock moved from uac.c (janakj)
34 34
  *  2003-04-14  added get_proto to determine protocol from uri unless
35 35
  *              specified explicitely (jiri)
36
+ *  2003-07-07  get_proto takes now two protos as arguments (andrei)
36 37
  */
37 38
 
38 39
 
... ...
@@ -51,41 +52,36 @@
51 52
 #include "../../mem/mem.h"
52 53
 #include "../../parser/msg_parser.h"
53 54
 
55
+/* a forced_proto takes precedence if != PROTO_NONE */
54 56
 inline static enum sip_protos get_proto(enum sip_protos force_proto,
55
-       struct sip_uri *u)
57
+										enum sip_protos proto)
56 58
 {
57
-       /* calculate transport protocol */
58
-       switch(force_proto) {
59
-               case PROTO_NONE:        /* no protocol has been forced -- look at uri */
60
-                       switch(u->proto) {
61
-                               case PROTO_NONE: /* uri default to UDP */
62
-                                       return PROTO_UDP;
63
-                               case PROTO_UDP: /* transport specified explicitely */
59
+	/* calculate transport protocol */
60
+	switch(force_proto) {
61
+		case PROTO_NONE: /* no protocol has been forced -- look at proto */
62
+			switch(proto) {
63
+				case PROTO_NONE: /* uri default to UDP */
64
+						return PROTO_UDP;
65
+				case PROTO_UDP:/* transport specified explicitely */
64 66
 #ifdef USE_TCP
65
-                               case PROTO_TCP:
67
+				case PROTO_TCP:
66 68
 #endif
67
-#ifdef USE_TLS
68
-                               case PROTO_TLS:
69
-#endif
70
-                                       return u->proto;
71
-                               default:
72
-                                       LOG(L_ERR, "ERROR: get_proto: unsupported transport: %d\n",
73
-                                               u->proto );
74
-                                       return PROTO_NONE;
75
-                       }
76
-               case PROTO_UDP: /* some protocol has been forced -- take it */
69
+						return proto;
70
+				default:
71
+						LOG(L_ERR, "ERROR: get_proto: unsupported transport:"
72
+								" %d\n", proto );
73
+						return PROTO_NONE;
74
+			}
75
+		case PROTO_UDP: /* some protocol has been forced -- take it */
77 76
 #ifdef USE_TCP
78
-               case PROTO_TCP:
79
-#endif
80
-#ifdef USE_TLS
81
-               case PROTO_TLS:
77
+		case PROTO_TCP:
82 78
 #endif
83
-                       return force_proto;
84
-               default:
85
-                       LOG(L_ERR, "ERROR: get_proto: unsupported forced protocol: "
86
-                               "%d\n", force_proto);
87
-                       return PROTO_NONE;
88
-       }
79
+			return force_proto;
80
+		default:
81
+			LOG(L_ERR, "ERROR: get_proto: unsupported forced protocol: "
82
+					"%d\n", force_proto);
83
+			return PROTO_NONE;
84
+	}
89 85
 }
90 86
 
91 87
 
... ...
@@ -106,7 +102,7 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
106 102
 	
107 103
 	p = mk_proxy(&parsed_uri.host, 
108 104
 		      parsed_uri.port_no, 
109
-		      get_proto(proto, &parsed_uri));
105
+		      get_proto(proto, parsed_uri.proto));
110 106
 	if (p == 0) {
111 107
 		LOG(L_ERR, "ERROR: uri2proxy: bad host name in URI <%.*s>\n",
112 108
 		    uri->len, ZSW(uri->s));
... ...
@@ -134,6 +130,7 @@ static inline struct socket_info *uri2sock(str *uri, union sockaddr_union *to_su
134 130
 	
135 131
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
136 132
 		   (proxy->port) ? proxy->port : SIP_PORT);
133
+			/* we use proxy->proto since uri2proxy just set it correctly*/
137 134
 	send_sock = get_send_socket(to_su, proxy->proto);
138 135
 	if (!send_sock) {
139 136
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n",