From owner-freebsd-net@FreeBSD.ORG Wed Apr 28 17:07:50 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E7B1116A4CF for ; Wed, 28 Apr 2004 17:07:50 -0700 (PDT) Received: from jchurch.neville-neil.com (jchurch.neville-neil.com [209.157.133.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id B8AF243D53 for ; Wed, 28 Apr 2004 17:07:48 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from jchurch.neville-neil.com.neville-neil.com (localhost.neville-neil.com [127.0.0.1])i3T09URb031952 for ; Wed, 28 Apr 2004 17:09:30 -0700 (PDT) (envelope-from gnn@neville-neil.com) Date: Wed, 28 Apr 2004 17:09:30 -0700 Message-ID: <87r7u7wsp1.wl@jchurch.neville-neil.com.neville-neil.com> From: "George V. Neville-Neil" To: net@freebsd.org User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3 (i386--freebsd) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Subject: RFC 2292 CMSG_FIRSTHDR macro... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2004 00:07:51 -0000 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