Date: Sat, 20 Nov 1999 21:37:13 +0100 From: Jeroen Ruigrok/Asmodai <asmodai@wxs.nl> To: net@freebsd.org Cc: cvs-committers@freebsd.org Subject: Patches for socket.h Message-ID: <19991120213713.N41154@daemon.ninth-circle.org>
next in thread | raw e-mail | index | archive | help
--cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Hi, in an effort to sync us with NetBSD and be more compliant with SUSv2 I present two patches. One to socket.h, which introduces the type socklen_t which replaces the unsigned integer in some areas. One caveat for now is the sa_family_t type, which would be the type for sa_family in the sockaddr struct. Also, the msg_name and msg_control members of msghdr have now been made pointers of type void. The patch in uipc_syscalls.c is needed to cast msg_control to caddr_t. -- Jeroen Ruigrok van der Werven/Asmodai asmodai(at)wxs.nl The BSD Programmer's Documentation Project <http://home.wxs.nl/~asmodai> Network/Security Specialist BSD: Technical excellence at its best Learn e-mail netiquette: http://www.lemis.com/email.html Beauty is a short-lived reign... --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="socket.h.diff" --- sys/sys/socket.h.orig Sat Nov 20 19:27:48 1999 +++ sys/sys/socket.h Sat Nov 20 21:10:06 1999 @@ -42,6 +42,11 @@ */ /* + * Data types. + */ +typedef unsigned int socklen_t; + +/* * Types */ #define SOCK_STREAM 1 /* stream socket */ @@ -289,13 +294,13 @@ * Used value-result for recvmsg, value only for sendmsg. */ struct msghdr { - caddr_t msg_name; /* optional address */ - u_int msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - u_int msg_iovlen; /* # elements in msg_iov */ - caddr_t msg_control; /* ancillary data, see below */ - u_int msg_controllen; /* ancillary data buffer len */ - int msg_flags; /* flags on received message */ + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + u_int msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + socklen_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ }; #define MSG_OOB 0x1 /* process out-of-band data */ @@ -316,9 +321,9 @@ * of message elements headed by cmsghdr structures. */ struct cmsghdr { - u_int cmsg_len; /* data byte count, including hdr */ - int cmsg_level; /* originating protocol */ - int cmsg_type; /* protocol-specific type */ + socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ /* followed by u_char cmsg_data[]; */ }; @@ -414,22 +419,22 @@ #include <sys/cdefs.h> __BEGIN_DECLS -int accept __P((int, struct sockaddr *, int *)); -int bind __P((int, const struct sockaddr *, int)); -int connect __P((int, const struct sockaddr *, int)); -int getpeername __P((int, struct sockaddr *, int *)); -int getsockname __P((int, struct sockaddr *, int *)); -int getsockopt __P((int, int, int, void *, int *)); +int accept __P((int, struct sockaddr *, socklen_t *)); +int bind __P((int, const struct sockaddr *, socklen_t)); +int connect __P((int, const struct sockaddr *, socklen_t)); +int getpeername __P((int, struct sockaddr *, socklen_t *)); +int getsockname __P((int, struct sockaddr *, socklen_t *)); +int getsockopt __P((int, int, int, void *, socklen_t *)); int listen __P((int, int)); ssize_t recv __P((int, void *, size_t, int)); -ssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, int *)); +ssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *)); ssize_t recvmsg __P((int, struct msghdr *, int)); ssize_t send __P((int, const void *, size_t, int)); ssize_t sendto __P((int, const void *, - size_t, int, const struct sockaddr *, int)); + size_t, int, const struct sockaddr *, socklen_t)); ssize_t sendmsg __P((int, const struct msghdr *, int)); int sendfile __P((int, int, off_t, size_t, struct sf_hdtr *, off_t *, int)); -int setsockopt __P((int, int, int, const void *, int)); +int setsockopt __P((int, int, int, const void *, socklen_t)); int shutdown __P((int, int)); int socket __P((int, int, int)); int socketpair __P((int, int, int, int *)); --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="uipc_syscalls.c.diff" --- sys/kern/uipc_syscalls.c.orig Sat Nov 20 20:44:24 1999 +++ sys/kern/uipc_syscalls.c Sat Nov 20 20:34:28 1999 @@ -805,7 +805,7 @@ len -= tocopy; m = m->m_next; } - mp->msg_controllen = ctlbuf - mp->msg_control; + mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control; } out: if (fromsa) --cWoXeonUoKmBZSoM-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991120213713.N41154>