Module rustix::net::netdevice

source ·
Expand description

Low-level Linux network device access

The methods in this module take a socket’s file descriptor to communicate with the kernel in their ioctl call:

  • glibc uses an AF_UNIX, AF_INET, or AF_INET6 socket. The address family itself does not matter and glibc tries the next address family if socket creation with one fails.
  • Android (bionic) uses an AF_INET socket.
  • Both create the socket with SOCK_DGRAM|SOCK_CLOEXEC type/flag.
  • The manual pages specify that the ioctl calls “can be used on any socket’s file descriptor regardless of the family or type”.

§References

Functions§

  • ioctl(fd, SIOCGIFNAME, ifreq)—Returns the interface name for a given index.
  • ioctl(fd, SIOCGIFINDEX, ifreq)—Returns the interface index for a given name.