summaryrefslogtreecommitdiff
path: root/ACE/ace/os_include
diff options
context:
space:
mode:
authorAdam Mitz <mitza@objectcomputing.com>2019-10-21 10:31:14 -0500
committerAdam Mitz <mitza@objectcomputing.com>2019-10-21 10:31:14 -0500
commitc815b4b4820a4f79cb0d91702b29e4cb741f3f29 (patch)
treebfdc9b5b7b6fd6aec8df1a46bdb31f3fb402e546 /ACE/ace/os_include
parente12d23326b610d6aca94cab94b317575a7f9d5b4 (diff)
downloadATCD-c815b4b4820a4f79cb0d91702b29e4cb741f3f29.tar.gz
sendmsg/recvmsg with msg_control: added Windows platform support
Diffstat (limited to 'ACE/ace/os_include')
-rw-r--r--ACE/ace/os_include/sys/os_socket.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/ACE/ace/os_include/sys/os_socket.h b/ACE/ace/os_include/sys/os_socket.h
index dbdba632729..cd287246422 100644
--- a/ACE/ace/os_include/sys/os_socket.h
+++ b/ACE/ace/os_include/sys/os_socket.h
@@ -77,7 +77,7 @@ extern "C"
struct msghdr
{
/// Optional address
- sockaddr * msg_name;
+ sockaddr *msg_name;
/// Size of address
int msg_namelen;
@@ -92,9 +92,49 @@ extern "C"
caddr_t msg_accrights;
int msg_accrightslen;
+
+ /// Control messages, set msg_control to 0 if not using:
+ void *msg_control;
+ int msg_controllen;
};
+
+ typedef WSACMSGHDR cmsghdr;
#endif /* ACE_WIN32 */
+ // Using msghdr::msg_control and msghdr::msg_controllen portably:
+ // For a parameter of size n, reserve space for ACE_CMSG_SPACE(n) bytes.
+ // This can be extended to the sum of ACE_CMSG_SPACE(n_i) for multiple
+ // parameters.
+ // Pass that buffer's address and length as msg_control/msg_controllen when
+ // invoking sendmsg/recvmsg. The buffer's address must be aligned to hold an
+ // object of type cmsghdr at the beginning of the buffer.
+ // If the send or recv succeeds, examine the
+ // resulting cmsg structure using the following macros with signatures:
+ // cmsghdr *ACE_CMSG_FIRSTHDR(msghdr *m)
+ // cmsghdr *ACE_CMSG_NXTHDR(msghdr *m, cmsghdr *c)
+ // unsigned char *ACE_CMSG_DATA(cmsghdr *c)
+
+#ifdef ACE_WIN32
+# define ACE_CMSG_SPACE WSA_CMSG_SPACE
+# define ACE_CMSG_FIRSTHDR(msg) \
+ (((msg)->msg_controllen >= sizeof (WSACMSGHDR)) \
+ ? (LPWSACMSGHDR) (msg)->msg_control : (LPWSACMSGHDR) 0)
+# define ACE_CMSG_NXTHDR(msg, cmsg) \
+ (((cmsg) == 0) ? ACE_CMSG_FIRSTHDR (msg) \
+ : ((((PUCHAR) (cmsg) + WSA_CMSGHDR_ALIGN ((cmsg)->cmsg_len) \
+ + sizeof (WSACMSGHDR)) > (PUCHAR) ((msg)->msg_control) \
+ + (msg)->msg_controllen) \
+ ? (LPWSACMSGHDR) 0 \
+ : (LPWSACMSGHDR) ((PUCHAR) (cmsg) \
+ + WSA_CMSGHDR_ALIGN ((cmsg)->cmsg_len))))
+# define ACE_CMSG_DATA WSA_CMSG_DATA
+#else
+# define ACE_CMSG_SPACE CMSG_SPACE
+# define ACE_CMSG_FIRSTHDR CMSG_FIRSTHDR
+# define ACE_CMSG_NXTHDR CMSG_NXTHDR
+# define ACE_CMSG_DATA CMSG_DATA
+#endif
+
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
// Control message size to pass a file descriptor.
# define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)