Computer Science
NETDEVICE(4) Linux Programmer's Manual NETDEVICE(4)
NAME
netdevice - Low level access to Linux network devices.
SYNOPSIS
#include <net/if.h>
DESCRIPTION
This man page describes the common to all protocol fami-
lies sockets interface that is used to configure network
devices. All network devices have an unique interface
index.
IOCTLS
Linux netdevices support some standard ioctls to configure
devices. They can be used on any socket's file descriptor
regardless of the family or type. They read or write an
ifreq structure. ifreq contains the char ifr_name[IFNAM-
SIZ] string member which contains the name of the inter-
face and another member depending on the ioctl type.
Valid other members:
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_ivalue;
int ifru_mtu;
struct ifmap ifru_map;
char ifru_slave[IFNAMSIZ]; /* Just fits the size */
char ifru_newname[IFNAMSIZ];
char * ifru_data;
Note that these overlap and only one of them can be
accessed at once.
Privileged means that using the ioctl requires an effec-
tive user id of 0 or the CAP_NET_ADMIN capability. If this
is not the case EPERM will be returned.
Network device ioctls
Name ifreq member Purpose
SIOCGIFNAME ifr_ifindex Return the name
of the passed
interface index.
SIOCGIFFLAGS ifr_flags Get the active
flag word of a
device. See
below for valid
flags.
SIOCSIFFLAGS ifr_flags Set the active
flag word of a
device. See
below for valid
flags. Privi-
leged.
SIOCGIFMETRIC ifr_metric Get the metric
of a device.
Currently not
implemented.
Returns always
0.
SIOCSIFMETRIC ifr_metric Set the metric
of a device.
Currently not
implemented and
returns EOPNOT-
SUPP.
SIOCSIFMTU ifr_mtu Set the MTU
(Maximum Trans-
fer Unit) of a
device. Privi-
leged.
SIOCGIFMTU ifr_mtu Get the MTU
(Maximum Trans-
fer Unit) of a
device.
SIOCGIFHWADDR ifr_hwaddr Get the hardware
address of a
device.
SIOCSIFHWADDR ifr_hwaddr Set the hardware
address of a
device. Only
implemented on a
few devices.
Privileged.
SIOCSIFHW ifr_hwaddr Set the hardware
BROADCAST broadcast
address of a
device. Privi-
leged.
SIOCADDMULTI ifr_hwaddr Add an address
to device's link
layer multicast
filters. Privi-
leged.
SIOCDELMULTI ifr_hwaddr Remove an
address from the
device's link
layer multicast
filters. Privi-
leged.
SIOCGIFINDEX ifr_ifindex Retrieve the
interface index
of an interface.
SIOCGIFTXQLEN ifr_qlen Get the transmit
queue length of
a device.
SIOCSIFTXQLEN ifr_qlen Set the transmit
queue length of
a device. Priv-
ileged.
SIOCSIFNAME ifr_newname Change the name
of a device.
Privileged.
Device flags
IFF_UP Interface is running.
IFF_BROADCAST Valid broadcast address set.
IFF_DEBUG Internal debugging flag.
IFF_LOOPBACK Interface is a loopback interface.
IFF_POINTOPOINT Interface is a point-to-point link.
IFF_RUNNING Resources allocated.
IFF_NOARP No arp protocol
IFF_PROMISC Interface is in promiscuous mode.
IFF_NOTRAILERS Avoid use of trailers.
IFF_ALLMULTI Receive all multicast packets.
IFF_MASTER Master of a load balancing bundle.
IFF_SLAVE Slave of a load balancing bundle.
IFF_MULTICAST Supports multicast
IFF_PORTSEL Is able to select media type via ifmap.
IFF_AUTOMEDIA Auto media selection active.
IFF_DYNAMIC Interface Address is not permanent.
Most protocols support their own ioctls to configure pro-
tocol specific interface options. See the protocol man
pages for a description.
In addition some devices support private ioctls. These are
not described here.
Linux Man Page 30 Oct 1998 1
Back to the index