Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Sep 2004 22:49:17 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Phillip Crumpler <listsubs@crippy.mel.crumpler.com.au>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: ifunit and struct ifnet/ieee80211com
Message-ID:  <20040924054917.GA31309@odin.ac.hmc.edu>
In-Reply-To: <4153AF49.6020603@crippy.mel.crumpler.com.au>
References:  <4153AF49.6020603@crippy.mel.crumpler.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help

--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 24, 2004 at 03:23:21PM +1000, Phillip Crumpler wrote:
> Hi hackers,
>=20
> A few questions re. ifunit and struct ifnet/ieee80211com, if anyone can=
=20
> help me out:
>=20
> I assume that for a wireless interface ifunit will return a pointer to a=
=20
> struct ieee80211com. Is there any way to tell which of these I have, so=
=20
> I don't try to access ieee80211com members in a struct that is actually=
=20
> the smaller infet? Both ethernet and wireless ethernet seem to use=20
> if_type =3D=3D 6 (IFT_ETHER) and if_physical =3D=3D 0. Can I distinguish =
which=20
> 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?=
=20
> If an interface goes away is the ifnet freed, leaving me with a dangling=
=20
> 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

--=20
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

--yrj/dFKFPuw6o+aM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBU7VcXY6L6fI4GtQRAgokAKCsGf+fU7wta+ty6ZQpUDaLy03bmwCggrcy
Iln7mtnzCGV8s3HgZJ90194=
=SPtJ
-----END PGP SIGNATURE-----

--yrj/dFKFPuw6o+aM--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040924054917.GA31309>