Subject: Re: IP_RECVIF addition
To: Bill Fenner <firstname.lastname@example.org>
From: Dennis Ferguson <email@example.com>
Date: 10/20/1996 18:39:05
> I'm happier with 8 bytes, but am not really sure how to come up with
> the number 8. Perhaps <net/if_dl.h> needs
> #define SDL_MINLEN 8 /* Minimum length sockaddr_dl */
> since I don't think I'd want to use (sdl.sdl_data - (char *)&sdl) .
I don't know, but I think I'd be tempted to use the structure offset
computation (i.e. some variant of the last thing you typed), `#define'
or not. What you're doing is trying to compute the length of a
struct sockaddr_dl with a data field which is other than 12 bytes long
(0 in your case). This is done other places in the kernel using pretty
much exactly your computation. Here's one from net/if.c, for example:
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
masklen = _offsetof(struct sockaddr_dl, sdl_data) + namelen;
Not pretty, but its prior art I guess. I don't know any other way to do it.