Subject: mbuf context
To: None <tech-kern@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 03/06/2006 19:30:14
Hi,
in sys/mbuf.h there exists some macros to store/extract private context
information in a mbuf, so.
/*
* Allow drivers and/or protocols to use the rcvif member of
* PKTHDR mbufs to store private context information.
*/
#define M_GETCTX(m, t) ((t) (m)->m_pkthdr.rcvif + 0)
#define M_SETCTX(m, c) ((void) ((m)->m_pkthdr.rcvif = (void *) (c)))
is there a good reason for the '+ 0' in M_GETCTX? I get compiler
complaints extracting a 'void *' because of the pointer arithmetic..
The type is actually irrelevant for me since all I am doing is passing
unknown context information to a far away function which knows what the
type is. I ended up using
void *arg = M_GETCTX(m, uint8_t *);
which looks .. strange.
iain