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/ChangeLog | 6 +++++ cpukit/librpc/include/rpc/types.h | 22 +++++++++------- cpukit/librpc/src/rpc/bindresvport.c | 49 +++++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index fef8dfe675..3dd96afdaf 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +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. + 2005-02-03 Ralf Corsepius PR 755/rtems diff --git a/cpukit/librpc/include/rpc/types.h b/cpukit/librpc/include/rpc/types.h index b962fd3e43..997a31defd 100644 --- a/cpukit/librpc/include/rpc/types.h +++ b/cpukit/librpc/include/rpc/types.h @@ -1,3 +1,5 @@ +/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej 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 @@ -28,7 +30,7 @@ * * from: @(#)types.h 1.18 87/07/24 SMI * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC - * $FreeBSD: src/include/rpc/types.h,v 1.9 1999/08/27 23:45:06 peter Exp $ + * $FreeBSD: src/include/rpc/types.h,v 1.11 2003/12/07 21:10:06 marcel Exp $ */ /* @@ -39,8 +41,16 @@ #include -#define bool_t int32_t -#define enum_t int32_t +typedef int32_t bool_t; +typedef int32_t enum_t; + +typedef uint32_t rpcprog_t; +typedef uint32_t rpcvers_t; +typedef uint32_t rpcproc_t; +typedef uint32_t rpcprot_t; +typedef uint32_t rpcport_t; +typedef int32_t rpc_inline_t; + #define __dontcare__ -1 #ifndef FALSE @@ -49,16 +59,10 @@ #ifndef TRUE # define TRUE (1) #endif -#ifndef NULL -# define NULL 0 -#endif #define mem_alloc(bsize) malloc(bsize) #define mem_free(ptr, bsize) free(ptr) -#ifndef makedev /* ie, we haven't already included it */ -#include -#endif #include #endif /* !_RPC_TYPES_H */ 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