Re: ifunit and struct ifnet/ieee80211com

From: Brooks Davis (brooks_at_one-eyed-alien.net)
Date: 09/24/04

  • Next message: Jeremie Le Hen: "Re: STRIP in /usr/share/mk/"
    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
    
    



  • Next message: Jeremie Le Hen: "Re: STRIP in /usr/share/mk/"

    Relevant Pages

    • Re: Another spinoza challenge
      ... You should test against the int type's limits: ... typedef struct complex ... a pointer to an integer ... A macro is preferable because it is replaced by inline code, ...
      (comp.lang.c)
    • Re: how to store list of varying types
      ... represent that with those in the struct definitions? ... pointer null, and the second one the CString object. ... then have to finish constructing the packet by copying the two data objects ... start with an upper-case letter (so, I would use DataElement ...
      (microsoft.public.vc.mfc)
    • Re: N1298 - try/finally for C
      ... Do you mean that "struct throwInfo" should be optional? ... that exception handling would be supported only on implementations ... If the standard mandates an integer as throw argument, ... should be an integer wide enough to encode a pointer if necessary. ...
      (comp.std.c)
    • Re: [RFC][PATCH 1/4] cgroup: support per cgroup subsys state ID (CSS ID)
      ... Patch for Per-CSS(Cgroup Subsys State) ID and private hierarchy code. ... This patch attaches unique ID to each css and provides following. ... returns pointer to struct cgroup_subysys_state of id. ... using a pointer introduces no such restriction. ...
      (Linux-Kernel)
    • Re: Memory Structure Pointer Problems
      ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
      (comp.lang.c)