From 0c20a46dc0a574d752f255dded721ed2f3173206 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Thu, 3 Feb 2005 15:58:18 +0000 Subject: 2005-02-03 Ralf Corsepius * librpc/include/rpc/types.h: Partial update from FreeBSD. Use stdint.h types instead of sys/types.h. * librpc/src/rpc/bindresvport.c: Partial update from FreeBSD. --- cpukit/librpc/src/rpc/bindresvport.c | 49 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'cpukit/librpc/src/rpc/bindresvport.c') diff --git a/cpukit/librpc/src/rpc/bindresvport.c b/cpukit/librpc/src/rpc/bindresvport.c index bb97570b88..50c724a32b 100644 --- a/cpukit/librpc/src/rpc/bindresvport.c +++ b/cpukit/librpc/src/rpc/bindresvport.c @@ -1,3 +1,5 @@ +/* $NetBSD: bindresvport.c,v 1.19 2000/07/06 03:03:59 christos Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -41,14 +43,29 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/2 */ #include -#include #include + #include -#include + +#include #include +#include + +#include /* - * Bind a socket to a privileged port for whatever protocol. + * Bind a socket to a privileged IP port + */ +int +bindresvport(sd, sin) + int sd; + struct sockaddr_in *sin; +{ + return bindresvport_sa(sd, (struct sockaddr *)sin); +} + +/* + * Bind a socket to a privileged IP port */ int bindresvport_sa(sd, sa) @@ -58,7 +75,7 @@ bindresvport_sa(sd, sa) int old, error, af; struct sockaddr myaddr; struct sockaddr_in *sin; -#if (defined(AF_INET6) && defined(IPPROTO_IPV6)) +#ifdef INET6 struct sockaddr_in6 *sin6; #endif int proto, portrange, portlow; @@ -77,23 +94,26 @@ bindresvport_sa(sd, sa) } else af = sa->sa_family; - if (af == AF_INET) { + switch (af) { + case AF_INET: proto = IPPROTO_IP; portrange = IP_PORTRANGE; portlow = IP_PORTRANGE_LOW; sin = (struct sockaddr_in *)sa; salen = sizeof(struct sockaddr_in); port = sin->sin_port; -#if (defined(AF_INET6) && defined(IPPROTO_IPV6)) - } else if (af == AF_INET6) { + break; +#ifdef INET6 + case AF_INET6: proto = IPPROTO_IPV6; portrange = IPV6_PORTRANGE; portlow = IPV6_PORTRANGE_LOW; sin6 = (struct sockaddr_in6 *)sa; salen = sizeof(struct sockaddr_in6); port = sin6->sin6_port; + break; #endif - } else { + default: errno = EPFNOSUPPORT; return (-1); } @@ -126,7 +146,7 @@ bindresvport_sa(sd, sa) } if (sa != (struct sockaddr *)&myaddr) { - /* Hmm, what did the kernel assign... */ + /* Hmm, what did the kernel assign? */ if (getsockname(sd, sa, &salen) < 0) errno = saved_errno; return (error); @@ -134,14 +154,3 @@ bindresvport_sa(sd, sa) } return (error); } - -/* - * Bind a socket to a privileged IP port - */ -int -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; -{ - return bindresvport_sa(sd, (struct sockaddr *)sin); -} -- cgit v1.2.3