Browse code

- fixed port byte order bugs introduced last night - updated modules to use the new byte ordering (now all the ports are kept in host byte order, previously some structures used network byte order and in other host byte order)

Andrei Pelinescu-Onciul authored on 06/04/2003 14:05:35
Showing 7 changed files
... ...
@@ -18,7 +18,7 @@
18 18
 VERSION = 0
19 19
 PATCHLEVEL = 8
20 20
 SUBLEVEL =   11
21
-EXTRAVERSION = pre11-rport+ba
21
+EXTRAVERSION = pre12
22 22
 
23 23
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
24 24
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -190,7 +190,7 @@ int do_action(struct action* a, struct sip_msg* msg)
190 190
 				p->ok=1;
191 191
 			}
192 192
 			ret=hostent2su(	to, &p->host, p->addr_idx,
193
-						(p->port)?htons(p->port):htons(SIP_PORT) );
193
+						(p->port)?p->port:SIP_PORT );
194 194
 			if (ret==0){
195 195
 				p->tx++;
196 196
 				p->tx_bytes+=msg->len;
... ...
@@ -280,7 +280,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p, int proto)
280 280
 	}
281 281
 	
282 282
 	hostent2su(to, &p->host, p->addr_idx, 
283
-				(p->port)?htons(p->port):htons(SIP_PORT));
283
+				(p->port)?p->port:SIP_PORT);
284 284
 	p->tx++;
285 285
 	p->tx_bytes+=len;
286 286
 	
... ...
@@ -410,7 +410,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
410 410
 		return -1;
411 411
 	}
412 412
 		
413
-	hostent2su(to, he, 0, htons(port));
413
+	hostent2su(to, he, 0, port);
414 414
 	return 1;
415 415
 }
416 416
 
... ...
@@ -204,7 +204,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
204 204
 	}
205 205
 
206 206
 	hostent2su( &to, &proxy->host, proxy->addr_idx, 
207
-		proxy->port ? htons(proxy->port):htons(SIP_PORT));
207
+		proxy->port ? proxy->port:SIP_PORT);
208 208
 
209 209
 	send_sock=get_send_socket( &to , proto);
210 210
 	if (send_sock==0) {
... ...
@@ -217,7 +217,7 @@ static struct socket_info *uri2sock( str *uri, union sockaddr_union *to_su,
217 217
 	}
218 218
 
219 219
 	hostent2su(to_su, &proxy->host, proxy->addr_idx, 
220
-			(proxy->port) ? htons(proxy->port) : htons(SIP_PORT));
220
+			(proxy->port) ? proxy->port : SIP_PORT);
221 221
 	send_sock=get_out_socket(to_su, proto);
222 222
 	if (send_sock == 0) {
223 223
 		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
... ...
@@ -268,7 +268,7 @@ void tcpconn_rm(struct tcp_connection* c)
268 268
 }
269 269
 
270 270
 
271
-/* finds a connection, if id=0 uses the ip addr & port
271
+/* finds a connection, if id=0 uses the ip addr & port (host byte order)
272 272
  * WARNING: unprotected (locks) use tcpconn_get unless you really
273 273
  * know what you are doing */
274 274
 struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port)
... ...
@@ -277,7 +277,7 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port)
277 277
 	struct tcp_connection *c;
278 278
 	unsigned hash;
279 279
 	
280
-	DBG("tcpconn_find: %d ",id ); print_ip(ip); DBG(" %d\n", ntohs(port));
280
+	DBG("tcpconn_find: %d ",id ); print_ip(ip); DBG(" %d\n", port);
281 281
 	if (id){
282 282
 		hash=tcp_id_hash(id);
283 283
 		for (c=tcpconn_id_hash[hash]; c; c=c->id_next){
... ...
@@ -505,7 +505,7 @@ int tcp_init(struct socket_info* sock_info)
505 505
 	
506 506
 	addr=&sock_info->su;
507 507
 	sock_info->proto=PROTO_TCP;
508
-	if (init_su(addr, &sock_info->address, htons(sock_info->port_no))<0){
508
+	if (init_su(addr, &sock_info->address, sock_info->port_no)<0){
509 509
 		LOG(L_ERR, "ERROR: tcp_init: could no init sockaddr_union\n");
510 510
 		goto error;
511 511
 	}
... ...
@@ -217,7 +217,7 @@ int udp_init(struct socket_info* sock_info)
217 217
 	}
218 218
 */
219 219
 	sock_info->proto=PROTO_UDP;
220
-	if (init_su(addr, &sock_info->address, htons(sock_info->port_no))<0){
220
+	if (init_su(addr, &sock_info->address, sock_info->port_no)<0){
221 221
 		LOG(L_ERR, "ERROR: udp_init: could not init sockaddr_union\n");
222 222
 		goto error;
223 223
 	}