Function: network-interface-list

network-interface-list is a function defined in process.c.

Signature

(network-interface-list &optional FULL FAMILY)

Documentation

Return an alist of all network interfaces and their network address.

Each element is cons of the form (IFNAME . IP) where IFNAME is a string containing the interface name, and IP is the network address in internal format; see the description of ADDRESS in make-network-process. The interface name is not guaranteed to be unique.

Optional parameter FULL non-nil means return all IP address info for each interface. Each element is then a list of the form
    (IFNAME IP BCAST MASK)
where IFNAME is the interface name, IP the IP address, BCAST the broadcast address, and MASK the network mask.

Optional parameter FAMILY controls the type of addresses to return. The default of nil means both IPv4 and IPv6, symbol ipv4 means IPv4 only, symbol ipv6 means IPv6 only.

See also network-interface-info, which is limited to IPv4 only.

If the information is not available, return nil.

View in manual

Probably introduced at or before Emacs version 22.1.

Source Code

// Defined in /usr/src/emacs/src/process.c
{
#if defined HAVE_GETIFADDRS || defined WINDOWSNT
  unsigned short match;
  bool full_info = false;

  if (! NILP (full))
    full_info = true;
  if (NILP (family))
    match = 0;
  else if (EQ (family, Qipv4))
    match = AF_INET;
#ifdef AF_INET6
  else if (EQ (family, Qipv6))
    match = AF_INET6;
#endif
  else
    error ("Unsupported address family");
  return network_interface_list (full_info, match);
#else
  return Qnil;
#endif
}