Manual Page Search Parameters
IF_GET(9) Kernel Developer's Manual IF_GET(9)


if_get, if_putget an interface pointer from an interface index


#include <net/if.h>
struct ifnet *
if_get(unsigned int ifidx);
if_put(struct ifnet *ifp);


The if_get() function returns a pointer to the interface descriptor corresponding to the unique index ifidx. This descriptor is guaranteed to be valid until if_put() is called on the returned pointer.
The index value 0 is never associated with an interface descriptor and can be used to determine if an interface index is valid or not.
The if_put() function releases a reference on the interface descriptor pointed by ifp. If ifp is a NULL pointer, no action occurs.


if_get(), and if_put() can be called during autoconf, from process context, or from interrupt context.


if_get() returns a pointer to an interface descriptor if the index is valid, otherwise NULL.
December 8, 2015 OpenBSD-current