RFC 2292 CMSG_FIRSTHDR macro...
JINMEI Tatuya /神明達哉
jinmei at isl.rdc.toshiba.co.jp
Sun May 16 20:17:31 PDT 2004
>>>>> On Wed, 28 Apr 2004 17:09:30 -0700,
>>>>> "George V. Neville-Neil" <gnn at neville-neil.com> said:
> 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.
I see no special reason. In fact, KAME snapshots have this check as
suggested in RFC2292 (or 3542):
/*
* RFC 2292 requires to check msg_controllen, in case that the kernel returns
* an empty list for some reasons.
*/
#define CMSG_FIRSTHDR(mhdr) \
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
(struct cmsghdr *)(mhdr)->msg_control : \
(struct cmsghdr *)NULL)
JINMEI, Tatuya
Communication Platform Lab.
Corporate R&D Center, Toshiba Corp.
jinmei at isl.rdc.toshiba.co.jp
More information about the freebsd-net
mailing list