net_if.h(0P)

πŸ’– net_if.h β€” the POSIX glow-up, bestie edition πŸ’–

okay so real talk, this page comes straight out of the POSIX Programmer's Manual (you know, the net_if.h(0P) one, the main character of headers). Quick heads-up before we dive in, and I need you to hear me on this one: the Linux implementation of this interface may differ β€” so if something looks sus, go check the corresponding Linux manual page for the actual Linux behavior. OR, plot twist, the interface might not even be implemented on Linux at all. πŸ™ˆ


✨ NAME ✨

net/if.h β€” sockets local interfaces πŸ¦‹


✨ SYNOPSIS ✨

#include <net/if.h>

✨ DESCRIPTION ✨

So the <net/if.h> header is gonna define the if_nameindex structure, and that structure shall include at least these members, no cap:

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

if_index is literally just the numeric index of the interface, and if_name is the name of the interface, null-terminated. slay.

The <net/if.h> header shall also define this symbolic constant, which gives you the length of a buffer that can hold an interface name (including the terminating NULL character, don't forget that part bestie):

  • IF_NAMESIZE β€” Interface name length. πŸŽ€

And then these following ones shall be declared as functions, and they may also be defined as macros (iconic of them honestly). Function prototypes shall be provided. Periodt:

void                  if_freenameindex(struct if_nameindex *);
char                 *if_indextoname(unsigned, char *);
struct if_nameindex  *if_nameindex(void);
unsigned              if_nametoindex(const char *);

The following sections are informative. πŸ’…


✨ APPLICATION USAGE ✨

None. that's it. that's the section. πŸ’€


✨ RATIONALE ✨

None. again. nothing here. moving on. πŸ™ˆ


✨ FUTURE DIRECTIONS ✨

None. truly the "no thoughts, head empty" trifecta. ✨


✨ SEE ALSO ✨

The System Interfaces volume of POSIX.1‐2017:

  • if_freenameindex()
  • if_indextoname()
  • if_nameindex()
  • if_nametoindex()

go read those, they're the besties of this page fr fr 🫢


okay legal moment, but make it cute. 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 .

Also, any typographical or formatting errors that show up 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, go to https://www.kernel.org/doc/man-pages/reporting_bugs.html . 🌸


and that's the whole page, bestie β€” brought to you by IEEE/The Open Group, 2017, filed under net_if.h(0P). mwah, go name some interfaces πŸ’–

πŸ“¦ where this page comes from