Subject: Re: adding an 802.11 data link type
To: David Young <dyoung@che.onthejob.net>
From: Andrew Brown <atatat@atatdot.net>
List: tech-net
Date: 08/06/2002 01:25:09
> #define BPF_DLTLISTSIZ 10
> struct bpf_dltlist {
> size_t bdl_len;
i'd suggest that a u_int (as below) would suffice here. what you're
storing isn't a size, per se, and i can't see any need for the count
to grow to a 64 bit on a 64 bit platform. if a 64 platform ends up
with a list of dlt types that exceeds 32 bits...well...i think you see
my point. :)
> u_int bdl_dlts[BPF_DLTLISTSIZ];
> };
>
>BIOCSDLT is self-explanatory. BIOCGDLTLIST will store up to BPF_DLTLISTSIZ
>dlts in bdl_dlts and set bdl_len to the number it stores, unless the
>number of DLTs exceed BPF_DLTLISTSIZ. In that case, it writes to bdl_len
>the total number of DLTs for the interface.
simplify the interface, perhaps? perhaps use the "trick" you have in
struct ifdltlist with the 1
> struct ifdltlist {
> u_int ifdl_count; /* length of ifdl_list */
> struct ifdltlistelt ifdl_list[1]; /* records for eligible DLTs */
> };
and *always* store the number of dlts in bdl_len. require the caller
to preset bdl_len to the maximum number for which it has allocated
storage. i could use that, for example, by passing you a pointer to a
u_int (or whatever the size of bdl_len ends up being) that's set to 0,
and get back a number that tells me how large my buffer needs to be.
then i malloc and call again. :)
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."