Re: ifunit and struct ifnet/ieee80211com
From: Brooks Davis (brooks_at_one-eyed-alien.net)
Date: 09/24/04
- Previous message: Phillip Crumpler: "ifunit and struct ifnet/ieee80211com"
- In reply to: Phillip Crumpler: "ifunit and struct ifnet/ieee80211com"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Sep 2004 22:49:17 -0700 To: Phillip Crumpler <listsubs@crippy.mel.crumpler.com.au>
On Fri, Sep 24, 2004 at 03:23:21PM +1000, Phillip Crumpler wrote:
> Hi hackers,
>
> A few questions re. ifunit and struct ifnet/ieee80211com, if anyone can
> help me out:
>
> I assume that for a wireless interface ifunit will return a pointer to a
> struct ieee80211com. Is there any way to tell which of these I have, so
> I don't try to access ieee80211com members in a struct that is actually
> the smaller infet? Both ethernet and wireless ethernet seem to use
> if_type == 6 (IFT_ETHER) and if_physical == 0. Can I distinguish which
> type I have or should I just make sure I know beforehand?
You need to know that the struct ifnet is actually embeded in a struct
ieee80211com if you want to access the members. In properly designed
code this won't generally be ambiguious. If you some how manage to get
into a state where it is, if_dname is probably your best bet. That sort
of thing is discouraged though.
> Also, what is the lifetime of the (struct ifnet *) that ifunit returns?
> If an interface goes away is the ifnet freed, leaving me with a dangling
> pointer, or is it kept but marked inactive in some way?
There is currently no assurance that a pointer to a struct ifnet is
valid. If you're going to hold a pointer over anything but trivial
operations, don't. Hold the index and us ifnet_byindex instead.
Currently that also dies since it returns NULL after attach, but I plan
to look in to returning a special dead_if to avoid crashes.
-- Brooks
-- Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4
- application/pgp-signature attachment: stored
- Previous message: Phillip Crumpler: "ifunit and struct ifnet/ieee80211com"
- In reply to: Phillip Crumpler: "ifunit and struct ifnet/ieee80211com"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|