IO::Interface and Net::Interface both use getifaddrs, but it isn't part of the POSIX spec. From the linux manpage:
This function first appeared in BSDi and is present on the BSD
systems, but with slightly different semantics documented—
returning one entry per interface, not per address. This means
ifa_addr and other fields can actually be NULL if the interface
has no address, and no link-level address is returned if the
interface has an IP address assigned. Also, the way of choosing
either ifa_broadaddr or ifa_dstaddr differs on various systems.
getifaddrs() first appeared in glibc 2.3, but before glibc 2.3.3,
the implementation supported only IPv4 addresses; IPv6 support was
added in glibc 2.3.3. Support of address families other than IPv4
is available only on kernels that support netlink.
| [reply] |
yes, you are right, further investigation:
The getifaddrs function is not part of the POSIX standard. It is a common extension used to retrieve a linked list of network interface addresses on the local system.
POSIX Status and Portability
Non-Standard: As of the latest POSIX versions (such as POSIX.1-2001 and 2008), getifaddrs remains an extension rather than a standardized interface.
Origin: The function first appeared in BSDi and has since been adopted by most BSD-derived systems (FreeBSD, macOS, OpenBSD) and Linux (via glibc 2.3 and later).
Implementation Differences: Because it is not standardized, behavior can vary across platforms. For example:
BSD: Often returns one entry per interface.
Linux: Typically returns one entry per address assigned to an interface (e.g., separate entries for IPv4 and IPv6).
POSIX Alternative: For strictly POSIX-compliant code, developers often use the ioctl system call with the SIOCGIFCONF request to enumerate interfaces, though this method is more cumbersome and has limitations regarding IPv6 support.
| [reply] |