diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-09-15 00:47:10 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-09-15 00:47:10 +0000 |
commit | b8005e84f7f252e93a42d945290512c185156084 (patch) | |
tree | d51500072a07f4778f4251b87b6a045c98725b87 /sys | |
parent | 96cb08314b92757feed28175fe6860f2d3854e6a (diff) |
Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.
Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in.h | 7 | ||||
-rw-r--r-- | sys/netinet6/in6.h | 8 | ||||
-rw-r--r-- | sys/sys/domain.h | 7 | ||||
-rw-r--r-- | sys/sys/socket.h | 56 | ||||
-rw-r--r-- | sys/sys/socketvar.h | 7 | ||||
-rw-r--r-- | sys/sys/types.h | 4 | ||||
-rw-r--r-- | sys/sys/un.h | 17 |
7 files changed, 86 insertions, 20 deletions
diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 56e3986185a..e503188ddaf 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.93 2012/07/16 18:05:36 markus Exp $ */ +/* $OpenBSD: in.h,v 1.94 2012/09/15 00:47:08 guenther Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -47,6 +47,11 @@ #include <machine/endian.h> #endif +#ifndef _SA_FAMILY_T_DEFINED_ +#define _SA_FAMILY_T_DEFINED_ +typedef __sa_family_t sa_family_t; /* sockaddr address family type */ +#endif + /* * Protocols */ diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 664bca96119..70a5f0858c6 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.57 2012/07/10 11:49:42 guenther Exp $ */ +/* $OpenBSD: in6.h,v 1.58 2012/09/15 00:47:08 guenther Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -769,6 +769,12 @@ int in6_mask2len(struct in6_addr *, u_char *); #endif /* _KERNEL */ #if __BSD_VISIBLE + +#ifndef _SOCKLEN_T_DEFINED_ +#define _SOCKLEN_T_DEFINED_ +typedef __socklen_t socklen_t; /* length type for network syscalls */ +#endif + __BEGIN_DECLS struct cmsghdr; diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 2e6f01e8c33..7f80bb826a2 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -1,4 +1,4 @@ -/* $OpenBSD: domain.h,v 1.9 2009/02/22 07:47:22 otto Exp $ */ +/* $OpenBSD: domain.h,v 1.10 2012/09/15 00:47:08 guenther Exp $ */ /* $NetBSD: domain.h,v 1.10 1996/02/09 18:25:07 christos Exp $ */ /* @@ -36,6 +36,11 @@ * Structure per communications domain. */ +#ifndef _SOCKLEN_T_DEFINED_ +#define _SOCKLEN_T_DEFINED_ +typedef __socklen_t socklen_t; /* length type for network syscalls */ +#endif + /* * Forward structure declarations for function prototypes [sic]. */ diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 6145db35596..3f52d86e7f0 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.81 2012/04/11 17:10:20 deraadt Exp $ */ +/* $OpenBSD: socket.h,v 1.82 2012/09/15 00:47:08 guenther Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -35,7 +35,34 @@ #ifndef _SYS_SOCKET_H_ #define _SYS_SOCKET_H_ +#include <sys/cdefs.h> + +#if __BSD_VISIBLE +#include <sys/types.h> /* for off_t, uid_t, and gid_t */ +#else #include <sys/_types.h> +#endif + +#ifndef _SOCKLEN_T_DEFINED_ +#define _SOCKLEN_T_DEFINED_ +typedef __socklen_t socklen_t; /* length type for network syscalls */ +#endif + +#ifndef _SA_FAMILY_T_DEFINED_ +#define _SA_FAMILY_T_DEFINED_ +typedef __sa_family_t sa_family_t; /* sockaddr address family type */ +#endif + +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef __size_t size_t; +#endif + +#ifndef _SSIZE_T_DEFINED_ +#define _SSIZE_T_DEFINED_ +typedef __ssize_t ssize_t; +#endif + /* * Definitions related to sockets: types, address families, options. @@ -184,6 +211,7 @@ struct sockaddr_storage { unsigned char __ss_pad3[240]; /* pad to a total of 256 bytes */ }; +#ifdef _KERNEL /* * Structure used by kernel to pass protocol * information in raw sockets. @@ -192,6 +220,7 @@ struct sockproto { unsigned short sp_family; /* address family */ unsigned short sp_protocol; /* protocol */ }; +#endif /* _KERNEL */ /* * Protocol families, same as address families for now. @@ -244,13 +273,14 @@ struct sockproto { #define SHUT_RDWR 2 #if __BSD_VISIBLE +#define SA_LEN(x) ((x)->sa_len) + /* Read using getsockopt() with SOL_SOCKET, SO_PEERCRED */ struct sockpeercred { uid_t uid; /* effective user id */ gid_t gid; /* effective group id */ pid_t pid; }; -#endif /* __BSD_VISIBLE */ /* * Definitions for network related sysctl, CTL_NET. @@ -363,6 +393,7 @@ struct sockpeercred { { 0, 0 }, \ { "stats", CTLTYPE_STRUCT }, \ } +#endif /* __BSD_VISIBLE */ /* * Maximum queue length specifiable by listen(2). @@ -414,11 +445,11 @@ struct cmsghdr { /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ #define CMSG_NXTHDR(mhdr, cmsg) \ - (((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ + (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ _ALIGN(sizeof(struct cmsghdr)) > \ - ((caddr_t)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \ + ((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \ (struct cmsghdr *)NULL : \ - (struct cmsghdr *)((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len))) + (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len))) /* * RFC 2292 requires to check msg_controllen, in case that the kernel returns @@ -444,25 +475,23 @@ struct cmsghdr { #define SCM_RIGHTS 0x01 /* access rights (array of int) */ #define SCM_TIMESTAMP 0x04 /* timestamp (struct timeval) */ +#if __BSD_VISIBLE /* * 4.3 compat sockaddr, move to compat file later + * XXX Needed by protocols/talkd.h */ struct osockaddr { unsigned short sa_family; /* address family */ char sa_data[14]; /* up to 14 bytes of direct address */ }; +#endif /* __BSD_VISIBLE */ -#define SA_LEN(x) ((x)->sa_len) - -#ifndef _KERNEL - -#include <sys/cdefs.h> +#ifndef _KERNEL __BEGIN_DECLS int accept(int, struct sockaddr *, socklen_t *); int bind(int, const struct sockaddr *, socklen_t); int connect(int, const struct sockaddr *, socklen_t); -int getpeereid(int, uid_t *, gid_t *); int getpeername(int, struct sockaddr *, socklen_t *); int getsockname(int, struct sockaddr *, socklen_t *); int getsockopt(int, int, int, void *, socklen_t *); @@ -478,8 +507,13 @@ int setsockopt(int, int, int, const void *, socklen_t); int shutdown(int, int); int socket(int, int, int); int socketpair(int, int, int, int *); + +#if __BSD_VISIBLE +int getpeereid(int, uid_t *, gid_t *); int getrtable(void); int setrtable(int); +#endif /* __BSD_VISIBLE */ + __END_DECLS #else diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index d5c34e06f59..732cead85c4 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socketvar.h,v 1.52 2012/07/13 10:51:30 claudio Exp $ */ +/* $OpenBSD: socketvar.h,v 1.53 2012/09/15 00:47:08 guenther Exp $ */ /* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */ /*- @@ -36,6 +36,11 @@ #include <sys/queue.h> #include <sys/timeout.h> +#ifndef _SOCKLEN_T_DEFINED_ +#define _SOCKLEN_T_DEFINED_ +typedef __socklen_t socklen_t; /* length type for network syscalls */ +#endif + TAILQ_HEAD(soqhead, socket); /* diff --git a/sys/sys/types.h b/sys/sys/types.h index c2ebbb10898..fc7bc5370de 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: types.h,v 1.32 2011/03/19 18:26:06 deraadt Exp $ */ +/* $OpenBSD: types.h,v 1.33 2012/09/15 00:47:09 guenther Exp $ */ /* $NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $ */ /*- @@ -159,8 +159,6 @@ typedef __fsfilcnt_t fsfilcnt_t; /* file system file count */ */ typedef __in_addr_t in_addr_t; /* base type for internet address */ typedef __in_port_t in_port_t; /* IP port type */ -typedef __sa_family_t sa_family_t; /* sockaddr address family type */ -typedef __socklen_t socklen_t; /* length type for network syscalls */ /* * The following types may be defined in multiple header files. diff --git a/sys/sys/un.h b/sys/sys/un.h index aea01eb8d64..26b726b6107 100644 --- a/sys/sys/un.h +++ b/sys/sys/un.h @@ -1,4 +1,4 @@ -/* $OpenBSD: un.h,v 1.11 2011/07/05 23:06:43 claudio Exp $ */ +/* $OpenBSD: un.h,v 1.12 2012/09/15 00:47:09 guenther Exp $ */ /* $NetBSD: un.h,v 1.11 1996/02/04 02:12:47 christos Exp $ */ /* @@ -35,12 +35,20 @@ #ifndef _SYS_UN_H_ #define _SYS_UN_H_ +#include <sys/cdefs.h> +#include <sys/_types.h> + +#ifndef _SA_FAMILY_T_DEFINED_ +#define _SA_FAMILY_T_DEFINED_ +typedef __sa_family_t sa_family_t; /* sockaddr address family type */ +#endif + /* * Definitions for UNIX IPC domain. */ struct sockaddr_un { unsigned char sun_len; /* sockaddr len excluding NUL */ - unsigned char sun_family; /* AF_UNIX */ + sa_family_t sun_family; /* AF_UNIX */ char sun_path[104]; /* path name (gag) */ }; @@ -65,8 +73,13 @@ int unp_internalize(struct mbuf *, struct proc *); void unp_dispose(struct mbuf *); #else /* !_KERNEL */ +#if __BSD_VISIBLE + /* actual length of an initialized sockaddr_un */ #define SUN_LEN(su) \ (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) + +#endif /* __BSD_VISIBLE */ + #endif /* _KERNEL */ #endif /* !_SYS_UN_H_ */ |