diff options
author | kib <kib@FreeBSD.org> | 2008-11-29 17:14:06 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2008-11-29 17:14:06 +0000 |
commit | 8ffb383318e85cc991be93037b0aba04d0079d92 (patch) | |
tree | f116b5269fc019eeaca5141f67a1245ed8ac5a7c /sys/compat/linux/linux_socket.h | |
parent | 817305efd56ce8d12b11dad03e764667f4335c62 (diff) | |
download | FreeBSD-src-8ffb383318e85cc991be93037b0aba04d0079d92.zip FreeBSD-src-8ffb383318e85cc991be93037b0aba04d0079d92.tar.gz |
Make linux_sendmsg() and linux_recvmsg() work on linux32/amd64.
Change types used in the linux' struct msghdr and struct cmsghdr
definitions to the properly-sized architecture-specific types.
Move ancillary data handler from linux_sendit() to linux_sendmsg().
Submitted by: dchagin
Diffstat (limited to 'sys/compat/linux/linux_socket.h')
-rw-r--r-- | sys/compat/linux/linux_socket.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h index b6b9841..5a5d3f5 100644 --- a/sys/compat/linux/linux_socket.h +++ b/sys/compat/linux/linux_socket.h @@ -49,4 +49,35 @@ #define LINUX_MSG_ERRQUEUE 0x2000 #define LINUX_MSG_NOSIGNAL 0x4000 +/* Socket-level control message types */ + +#define LINUX_SCM_RIGHTS 0x01 + +/* Ancilliary data object information macros */ + +#define LINUX_CMSG_ALIGN(len) roundup2(len, sizeof(l_ulong)) +#define LINUX_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + \ + LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)))) +#define LINUX_CMSG_SPACE(len) (LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \ + LINUX_CMSG_ALIGN(len)) +#define LINUX_CMSG_LEN(len) (LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \ + (len)) +#define LINUX_CMSG_FIRSTHDR(msg) \ + ((msg)->msg_controllen >= \ + sizeof(struct l_cmsghdr) ? \ + (struct l_cmsghdr *)((msg)->msg_control) : \ + (struct l_cmsghdr *)(NULL)) +#define LINUX_CMSG_NXTHDR(msg, cmsg) \ + ((((char *)(cmsg) + \ + LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \ + sizeof(*(cmsg))) > \ + (((char *)(msg)->msg_control) + \ + (msg)->msg_controllen)) ? \ + (struct l_cmsghdr *) NULL : \ + (struct l_cmsghdr *)((char *)(cmsg) + \ + LINUX_CMSG_ALIGN((cmsg)->cmsg_len))) + +#define CMSG_HDRSZ CMSG_LEN(0) +#define L_CMSG_HDRSZ LINUX_CMSG_LEN(0) + #endif /* _LINUX_SOCKET_H_ */ |