diff src/lib/network.c @ 349:fd32faeb7ba5 HEAD

keep the port unsigned.
author Timo Sirainen <tss@iki.fi>
date Sun, 06 Oct 2002 00:04:50 +0300
parents 4a7ab9e94f25
children 792fc5b3daa4
line wrap: on
line diff
--- a/src/lib/network.c	Sat Oct 05 23:39:19 2002 +0300
+++ b/src/lib/network.c	Sun Oct 06 00:04:50 2002 +0300
@@ -98,7 +98,7 @@
 		memcpy(&ip->ip, &so->sin.sin_addr, 4);
 }
 
-static inline void sin_set_port(union sockaddr_union *so, int port)
+static inline void sin_set_port(union sockaddr_union *so, unsigned int port)
 {
 #ifdef HAVE_IPV6
 	if (so->sin.sin_family == AF_INET6)
@@ -108,7 +108,7 @@
 		so->sin.sin_port = htons((unsigned short) port);
 }
 
-static inline int sin_get_port(union sockaddr_union *so)
+static inline unsigned int sin_get_port(union sockaddr_union *so)
 {
 #ifdef HAVE_IPV6
 	if (so->sin.sin_family == AF_INET6)
@@ -125,7 +125,7 @@
 }
 
 /* Connect to socket with ip address */
-int net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
+int net_connect_ip(IPADDR *ip, unsigned int port, IPADDR *my_ip)
 {
 	union sockaddr_union so;
 	int fd, ret, opt = 1;
@@ -233,7 +233,7 @@
 
 /* Listen for connections on a socket. if `my_ip' is NULL, listen in any
    address. */
-int net_listen(IPADDR *my_ip, int *port)
+int net_listen(IPADDR *my_ip, unsigned int *port)
 {
 	union sockaddr_union so;
 	int ret, fd, opt = 1;
@@ -320,7 +320,7 @@
 }
 
 /* Accept a connection on a socket */
-int net_accept(int fd, IPADDR *addr, int *port)
+int net_accept(int fd, IPADDR *addr, unsigned int *port)
 {
 	union sockaddr_union so;
 	int ret;
@@ -451,7 +451,7 @@
 }
 
 /* Get socket address/port */
-int net_getsockname(int fd, IPADDR *addr, int *port)
+int net_getsockname(int fd, IPADDR *addr, unsigned int *port)
 {
 	union sockaddr_union so;
 	socklen_t addrlen;
@@ -565,11 +565,11 @@
 }
 
 /* Get name of TCP service */
-char *net_getservbyport(int port)
+char *net_getservbyport(unsigned short port)
 {
 	struct servent *entry;
 
-	entry = getservbyport(htons((unsigned short) port), "tcp");
+	entry = getservbyport(htons(port), "tcp");
 	return entry == NULL ? NULL : entry->s_name;
 }