changeset 349:fd32faeb7ba5 HEAD

keep the port unsigned.
author Timo Sirainen <tss@iki.fi>
date Sun, 06 Oct 2002 00:04:50 +0300
parents f15420cb362d
children 2c6b6594a14b
files src/lib/network.c src/lib/network.h
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
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;
 }
 
--- a/src/lib/network.h	Sat Oct 05 23:39:19 2002 +0300
+++ b/src/lib/network.h	Sun Oct 06 00:04:50 2002 +0300
@@ -43,7 +43,7 @@
 int net_ip_compare(IPADDR *ip1, IPADDR *ip2);
 
 /* 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);
 /* Connect to named UNIX socket */
 int net_connect_unix(const char *path);
 /* Disconnect socket */
@@ -58,11 +58,11 @@
 void net_set_cork(int fd, int cork);
 
 /* Listen for connections on a socket */
-int net_listen(IPADDR *my_ip, int *port);
+int net_listen(IPADDR *my_ip, unsigned int *port);
 /* Listen for connections on an UNIX socket */
 int net_listen_unix(const char *path);
 /* 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);
 
 /* Read data from socket, return number of bytes read, -1 = error */
 ssize_t net_receive(int fd, void *buf, size_t len);
@@ -79,7 +79,7 @@
 int net_hosterror_notfound(int error);
 
 /* Get socket address/port */
-int net_getsockname(int fd, IPADDR *addr, int *port);
+int net_getsockname(int fd, IPADDR *addr, unsigned int *port);
 
 /* IPADDR -> char* translation. `host' must be at least MAX_IP_LEN bytes */
 int net_ip2host(IPADDR *ip, char *host);
@@ -90,7 +90,7 @@
 int net_geterror(int fd);
 
 /* Get name of TCP service */
-char *net_getservbyport(int port);
+char *net_getservbyport(unsigned short port);
 
 int is_ipv4_address(const char *host);
 int is_ipv6_address(const char *host);