IF_GET(9)

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

SYNOPSIS
#include <net/if.h>
struct ifnet *
if_get(unsigned int ifidx);
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_put() function releases a reference on the interface descriptor pointed by ifp. If ifp is a NULL pointer, no action occurs.

CONTEXT
if_get(), 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.