From e88f07b434dbcfdb57435a14e1beadcdae3cef0d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 24 Jan 2017 19:26:31 -0800 Subject: Add endpoint tuning of maxrcv size. Fix cmsg API. The CMSG handling was completely borked. This is fixed now, and we stash the SP header size (ugh) in the CMSG contents to match what nanomsg does. We now pass the cmsg validation test. We also fixed handling of certain endpoint-related options, so that endpoints can get options from the socket at initialization time. This required a minor change to the transport API for endpoints. Finally, we fixed a critical fault in the REP handling of RAW sockets, which caused them to always return NNG_ESTATE in all cases. It should now honor the actual socket option. --- src/nng_compat.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/nng_compat.h') diff --git a/src/nng_compat.h b/src/nng_compat.h index 64ace069..5866fe2c 100644 --- a/src/nng_compat.h +++ b/src/nng_compat.h @@ -258,7 +258,7 @@ struct nn_cmsghdr { int cmsg_type; }; -#define NN_ALIGN(len) \ +#define NN_CMSG_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 @@ -268,16 +268,17 @@ struct nn_cmsghdr { // anyone used that in practice though.) #define NN_CMSG_FIRSTHDR(mh) \ nn_cmsg_next((struct nn_msghdr *) (mh), NULL) -#define NN_CMSG_NEXTHDR(mh, ch) \ +#define NN_CMSG_NXTHDR(mh, ch) \ nn_cmsg_next((struct nn_msghdr *) (mh), (struct nn_cmsghdr *) ch) #define NN_CMSG_DATA(ch) \ ((unsigned char *) (((struct nn_cmsghdr *) (ch)) + 1)) #define NN_CMSG_SPACE(len) \ - (NN_ALIGN(len) + NN_ALIGN(sizeof (struct nn_cmsghdr))) + (NN_CMSG_ALIGN(len) + NN_CMSG_ALIGN(sizeof (struct nn_cmsghdr))) #define NN_CMSG_LEN(len) \ - (NN_ALIGN(sizeof (nn_cmsghdr)) + (len)) + (NN_CMSG_ALIGN(sizeof (struct nn_cmsghdr)) + (len)) -NN_DECL struct cmsg_hdr *nn_cmsg_next(struct nn_msghdr *, struct nn_cmsghdr *); +NN_DECL struct nn_cmsghdr *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 *); @@ -287,7 +288,7 @@ NN_DECL int nn_shutdown(int, int); NN_DECL int nn_send(int, const void *, size_t, int); NN_DECL int nn_recv(int, void *, size_t, int); NN_DECL int nn_sendmsg(int, const struct nn_msghdr *, int); -NN_DECL int nn_recvcmsg(int, struct nn_msghdr *, int); +NN_DECL int nn_recvmsg(int, struct nn_msghdr *, int); NN_DECL int nn_close(int); NN_DECL int nn_poll(struct nn_pollfd *, int, int); NN_DECL int nn_device(int, int); -- cgit v1.2.3-70-g09d2