From fc553e0689a9be70b90663db1bcd020706ba9ae6 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 23 Jan 2017 14:00:05 -0800 Subject: nn_recvmsg, and enhancements to support NN_MSG allocated messages. --- src/nng_compat.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/nng_compat.h') diff --git a/src/nng_compat.h b/src/nng_compat.h index 020a342a..0a147196 100644 --- a/src/nng_compat.h +++ b/src/nng_compat.h @@ -245,19 +245,24 @@ struct nn_cmsghdr { #define NN_ALIGN(len) \ (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + +// Unlike old nanomsg, we explicitly only support the SP header as attached +// cmsg data. It turns out that old nanomsg didn't really store anything +// useful otherwise anyway. (One specific exception was that it stored the +// message type of text or binary for the websocket transport. We don't think +// anyone used that in practice though.) #define NN_CMSG_FIRSTHDR(mh) \ - nn_cmsg_nexthdr((struct nn_msghdr *) (mh), NULL) + nn_cmsg_next((struct nn_msghdr *) (mh), NULL) #define NN_CMSG_NEXTHDR(mh, ch) \ - nn_cmsg_nexthdr((struct nn_msghdr *) (mh), (struct nn_cmsghdr *) ch) + nn_cmsg_next((struct nn_msghdr *) (mh), (struct nn_cmsghdr *) ch) #define NN_CMSG_DATA(ch) \ - ((unsigned char *) (((struct cmsghdr *) (ch)) + 1)) + ((unsigned char *) (((struct nn_cmsghdr *) (ch)) + 1)) #define NN_CMSG_SPACE(len) \ (NN_ALIGN(len) + NN_ALIGN(sizeof (struct nn_cmsghdr))) #define NN_CMSG_LEN(len) \ (NN_ALIGN(sizeof (nn_cmsghdr)) + (len)) -NN_DECL struct cmsg_hdr *nn_cmsg_nexthdr(const struct nn_msghdr *, - const struct nn_cmsghdr *); +NN_DECL struct cmsg_hdr *nn_cmsg_next(struct nn_msghdr *, struct nn_cmsghdr *); NN_DECL int nn_socket(int, int); NN_DECL int nn_setsockopt(int, int, int, const void *, size_t); NN_DECL int nn_getsockopt(int, int, int, void *, size_t *); -- cgit v1.2.3-70-g09d2