Date: Wed, 28 Apr 2004 17:09:30 -0700 From: "George V. Neville-Neil" <gnn@neville-neil.com> To: net@freebsd.org Subject: RFC 2292 CMSG_FIRSTHDR macro... Message-ID: <87r7u7wsp1.wl@jchurch.neville-neil.com.neville-neil.com>
next in thread | raw e-mail | index | archive | help
Howdy, This should be a minor nit but, is there any reason we implement this this way: #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) instead of this way: #define CMSG_FIRSTHDR(mhdr) \ ( (mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ (struct cmsghdr *)(mhdr)->msg_control : \ (struct cmsghdr *)NULL ) as suggested in RFC 2292? A coworker of mine asked about this and then I got to wondering myself. The RFC says: (Note: Most existing implementations do not test the value of msg_controllen, and just return the value of msg_control. The value of msg_controllen must be tested, because if the application asks recvmsg() to return ancillary data, by setting msg_control to point to the application's buffer and setting msg_controllen to the length of this buffer, the kernel indicates that no ancillary data is available by setting msg_controllen to 0 on return. It is also easier to put this test into this macro, than making the application perform the test.) Later, George
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87r7u7wsp1.wl>