include: Add macros for retrieving control message headers.
This commit is contained in:
parent
4b6d5fd583
commit
cac2c176ef
|
@ -78,4 +78,21 @@ typedef enum {
|
||||||
ScopeLevelGlobal = 14
|
ScopeLevelGlobal = 14
|
||||||
} SCOPE_LEVEL;
|
} SCOPE_LEVEL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for retrieving control message data returned by WSARecvMsg()
|
||||||
|
*/
|
||||||
|
#define WSA_CMSG_DATA(cmsg) ((UCHAR*)((WSACMSGHDR*)(cmsg)+1))
|
||||||
|
#define WSA_CMSG_FIRSTHDR(mhdr) ((mhdr)->Control.len >= sizeof(WSACMSGHDR) ? (WSACMSGHDR *) (mhdr)->Control.buf : (WSACMSGHDR *) 0)
|
||||||
|
#define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
|
||||||
|
/*
|
||||||
|
* Next Header: If the response is too short (or the next message in the response
|
||||||
|
* is too short) then return NULL, otherwise return the next control message.
|
||||||
|
*/
|
||||||
|
#define WSA_CMSG_NXTHDR(mhdr,cmsg) \
|
||||||
|
(!(cmsg) ? WSA_CMSG_FIRSTHDR(mhdr) : \
|
||||||
|
((mhdr)->Control.len < sizeof(WSACMSGHDR) ? NULL : \
|
||||||
|
(((unsigned char*)(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))+1) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
|
||||||
|
(((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)+WSA_CMSG_ALIGN(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))->cmsg_len) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
|
||||||
|
(WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len))))))
|
||||||
|
|
||||||
#endif /* _WS2DEF_ */
|
#endif /* _WS2DEF_ */
|
||||||
|
|
Loading…
Reference in New Issue