Re: Understanding ic_node_alloc method

From: Martin Husemann <martin_at_NetBSD.org>
Date: Wed, 20 Jul 2022 16:30:32 UTC
On Wed, Jul 20, 2022 at 12:11:45PM -0400, Farhan Khan wrote:

> After looking through a few examples, I see that there is a "struct
> DRIVERNAME_node" that gets allocated. The first member of this struct
> must be a "struct ieee80211_node ni". Then the function either returns
> the allocated DRIVERNAME_node pointer or or &DRIVER_NAME_node->ni (same
> address since `ni` must be the first value in the struct). This part is
> clear.

The function allows a driver to attach additional data to each node
it talks to, e.g. the run(4) driver stores tx rate indices used to
communicate with the node there. If a driver does not need additional
data, it does not need to provide the alloc function (and uses
ieee80211_node directly).

In C++ terms the driver specific node is a subclass derived from
ieee80211_node, and the generic code only knows about the superclass.

The node alloc function is called whenever a node shows up in the
network and we need to communnicate with it (depending on operating
mode, in station mode the only node will be the access point).

Martin