Subject: if_dl.h question
To: None <tech-kern@NetBSD.ORG>
From: Gordon W. Ross <gwr@mc.com>
List: tech-kern
Date: 04/07/1997 13:05:55
Normally, a variant of "struct sockaddr" is some kind of address.
Why is all this stuff crammed together in a sockaddr variant?
In <net/if_dl.h>:
/*
* Structure of a Link-Level sockaddr:
*/
struct sockaddr_dl {
u_char sdl_len; /* Total length of sockaddr */
u_char sdl_family; /* AF_DLI */
u_int16_t sdl_index; /* if != 0, system given index for interface */
u_char sdl_type; /* interface type */
u_char sdl_nlen; /* interface name length, no trailing 0 reqd */
u_char sdl_alen; /* link level address length */
u_char sdl_slen; /* link layer selector length */
char sdl_data[12]; /* minimum work area, can be larger;
contains both if name and ll address */
};
I would have expected to see some other interface structure with
all the above information, also containing a simpler sockaddr_dl
as one of the members, perhaps something like this:
struct sockaddr_dl {
u_char sdl_len; /* Total length of sockaddr */
u_char sdl_family; /* AF_DLI */
u_char sdl_type; /* interface type */
u_char sdl_alen; /* link level address length */
char sdl_data[12];
};
struct if_info {
u_int16_t ifi_index; /* if != 0, system given index for interface */
u_char ifi_hdrlen; /* media header length */
char ifi_xname[IFNAMSIZ]; /* external name (name + unit) */
struct sockaddr_dl *ifi_sdl;
}
Could someone explain the reasoning behind the current design?
Gordon