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 π«Ά
β¨ COPYRIGHT β¨
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
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms