IF_GET(9)

NAME
if_get, if_unit, if_put - get an interface pointer from an interface index

SYNOPSIS
#include <net/if.h>
struct ifnet *
if_get(unsigned int ifidx);
struct ifnet *
if_unit(const char *name);
void
if_put(struct ifnet *ifp);

DESCRIPTION
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_unit() function returns a pointer to the interface descriptor corresponding to the unique name name. This descriptor is guaranteed to be valid until if_put() is called on the returned pointer.

The if_put() function releases a reference on the interface descriptor pointed by ifp. If ifp is a NULL pointer, no action occurs.

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

RETURN VALUES
if_get() returns a pointer to an interface descriptor if the index is valid, otherwise NULL.

if_unit() returns a pointer to an interface descriptor if the interface with present name exists, otherwise NULL.