IF_GET(9)

πŸ“¦ in nixpkgs unstable

IF_GET(9) β€” Kernel Developer's Manual πŸ’»βœ¨

okay bestie, welcome to the interface-pointer retrieval manual, no cap 🫢

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 πŸ’–

Okay so here's the vibe: these functions hand you pointers to interface descriptors, and the reference life cycle is the main character. 🫢

  • if_get() β€” 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. Slay, but respect the reference. πŸ’…
  • 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. Literally a built-in vibe check for index validity. ⭐
  • if_unit() β€” 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. Same reference rule, bestie. πŸŽ€
  • if_put() β€” releases a reference on the interface descriptor pointed to by ifp. If ifp is a NULL pointer, no action occurs. No drama, no crash, just nothing. πŸ™ˆ

CONTEXT 🌈

if_get(), if_unit() and if_put() can be called during autoconf, from process context, or from interrupt context. All three contexts, iconic flexibility. πŸ”₯

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.

That's the whole page, bestie. This one came from Debian, dated January 18, 2021, under IF_GET(9). Periodt. πŸ’œ

πŸ“¦ where this page comes from