IF_GET(9)
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 indexifidx. This descriptor is guaranteed to be valid untilif_put()is called on the returned pointer. Slay, but respect the reference. π- The index value
0is 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 namename. This descriptor is guaranteed to be valid untilif_put()is called on the returned pointer. Same reference rule, bestie. πif_put()β releases a reference on the interface descriptor pointed to byifp. Ififpis aNULLpointer, 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, otherwiseNULL.if_unit()returns a pointer to an interface descriptor if the interface with present name exists, otherwiseNULL.
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
- nixpkgs unstable: cvs-export
- Copyright (c) 2015 Martin Pieuchot
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms