net_if.h(7POSIX)

🌸 net_if.h(7POSIX) 🌸

ok bestie, so this is a page from the POSIX Programmer's Manual β€” yes, the whole net_if.h thing, 7POSIX section and all. Come sit with me, we're doing network interface lore today πŸ’…


✨ PROLOG ✨

So like, heads up: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so if you're on Linux, go read the corresponding Linux manual page for the deets on Linux behavior, fr), or honestly the interface might not even be implemented on Linux at all. Not me warning you up front 🫢


πŸ‘‘ NAME πŸ‘‘

net/if.h β€” sockets local interfaces. That's it, that's the vibe. Local interfaces for your sockets ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <net/if.h>

πŸ’– DESCRIPTION πŸ’–

okay so the <net/if.h> header shall define the if_nameindex structure, and it has to include at least these members:

unsigned  if_index  Numeric index of the interface.
char     *if_name   Null-terminated name of the interface.

if_index is the numeric index of the interface, and if_name is the null-terminated name of the interface. iconic duo, no cap.

The <net/if.h> header shall also define this symbolic constant for the length of a buffer that contains an interface name (and yes, that length includes the terminating NULL character, don't forget the terminator bestie 😭):

  • IF_NAMESIZE β€” Interface name length.

And the following shall be declared as functions, and they may also be defined as macros. Function prototypes shall be provided. Look at them, they're gorgeous:

void                  if_freenameindex(struct if_nameindex *);
char                 *if_indextoname(unsigned, char *);
struct if_nameindex  *if_nameindex(void);
unsigned              if_nametoindex(const char *);
Also, just so you know: the following sections are informative. Not normative. Informative. Big difference, iykyk πŸ’€

🌈 APPLICATION USAGE 🌈

None. Literally none. The section is giving absolutely nothing and I respect it πŸ™ˆ


πŸ¦‹ RATIONALE πŸ¦‹

None. Empty. A whole blank moment ✨


⭐ FUTURE DIRECTIONS ⭐

None. Nothing coming. The future is quiet πŸ’œ


🌸 SEE ALSO 🌸

The System Interfaces volume of POSIX.1‐2017, plus these besties: if_freenameindex(), if_indextoname(), if_nameindex(), if_nametoindex(). Go read them, they're the whole point 🫢


okay so legal moment, don't skip it:

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie πŸŽ€ this one's brought to you by IEEE/The Open Group, 2017 β€” yeah, 2017, she's vintage and she still ate πŸ’– mwah, go read a man page, ily ✨