From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 24 05:46:36 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13D5716A4CE for ; Fri, 24 Sep 2004 05:46:36 +0000 (GMT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id E645E43D45 for ; Fri, 24 Sep 2004 05:46:35 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.13.0/8.13.0) with ESMTP id i8O5nHTg000707; Thu, 23 Sep 2004 22:49:17 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.13.0/8.13.0/Submit) id i8O5nHam000706; Thu, 23 Sep 2004 22:49:17 -0700 Date: Thu, 23 Sep 2004 22:49:17 -0700 From: Brooks Davis To: Phillip Crumpler Message-ID: <20040924054917.GA31309@odin.ac.hmc.edu> References: <4153AF49.6020603@crippy.mel.crumpler.com.au> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: <4153AF49.6020603@crippy.mel.crumpler.com.au> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new X-Spam-Status: No, hits=0.0 required=8.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on odin.ac.hmc.edu cc: freebsd-hackers@freebsd.org Subject: Re: ifunit and struct ifnet/ieee80211com X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2004 05:46:36 -0000 --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--