Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
netdevice(7)
Edit
PageHistory
Diff
Info
LikePages
NETDEVICE !!!NETDEVICE NAME SYNOPSIS DESCRIPTION IOCTLS NOTES BUGS SEE ALSO ---- !!NAME netdevice - Low level access to Linux network devices. !!SYNOPSIS #include <sys/ioctl.h> #include <net/if.h> !!DESCRIPTION This man page describes the sockets interface which is used to configure network devices. Linux supports some standard ioctls to configure network devices. They can be used on any socket's file descriptor regardless of the family or type. They pass an __ifreq__ structure: struct ifreq { char ifr_name[[IFNAMSIZ];/* Interface name */ union { struct sockaddrifr_addr; struct sockaddrifr_dstaddr; struct sockaddrifr_broadaddr; struct sockaddrifr_netmask; struct sockaddrifr_hwaddr; short ifr_flags; int ifr_ifindex; int ifr_metric; int ifr_mtu; struct ifmapifr_map; char ifr_slave[[IFNAMSIZ]; char ifr_newname[[IFNAMSIZ]; char * ifr_data; }; }; struct ifconf { int ifc_len; /* size of buffer */ union { char * ifc_buf; /* buffer address */ struct ifreq *ifc_req; /* array of structures */ }; }; Normally, the user specifies which device to affect by setting __ifr_name__ to the name of the interface. All other members of the structure may share memory. !!IOCTLS If an ioctl is marked as privileged then using it requires an effective user id of 0 or the __CAP_NET_ADMIN__ capability. If this is not the case __EPERM__ will be returned. __SIOCGIFNAME__ Given the __ifr_ifindex__, return the name of the interface in __ifr_name__. This is the only ioctl which returns its result in __ifr_name__. __SIOCGIFINDEX__ Retrieve the interface index of the interface into __ifr_ifindex__. __SIOCGIFFLAGS__, __SIOCSIFFLAGS__ Get or set the active flag word of the device. __ifr_flags__ contains a bitmask of the following values: Setting the active flag word is a privileged operation, but any process may read it. __SIOCGIFMETRIC__, __SIOCSIFMETRIC__ Get or set the metric of the device using __ifr_metric__. This is currently not implemented; it sets __ifr_metric__ to 0 if you attempt to read it and returns __EOPNOTSUPP__ if you attempt to set it. __SIOCGIFMTU__, __SIOCSIFMTU__ Get or set the MTU (Maximum Transfer Unit) of a device using __ifr_mtu__. Setting the MTU is a privileged operation. Setting the MTU to too small values may cause kernel crashes. __SIOCGIFHWADDR__, __SIOCSIFHWADDR__ Get or set the hardware address of a device using __ifr_hwaddr__. The hardware address is specified in a struct ''sockaddr''. ''sa_family'' contains the ARPHRD_* device type, ''sa_data'' the L2 hardware address starting from byte 0. Setting the hardware address is a privileged operation. __SIOCSIFHWBROADCAST__ Set the hardware broadcast address of a device from __ifr_hwaddr__. This is a privileged operation. __SIOCGIFMAP__, __SIOCSIFMAP__ Get or set the interface's hardware parameters using __ifr_map__. Setting the parameters is a privileged operation. struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; }; The interpretation of the ifmap structure depends on the device driver and the architecture. __SIOCADDMULTI__, __SIOCDELMULTI__ Add an address to or delete an address from the device's link layer multicast filters using __ifr_hwaddr__. These are privileged operations. See also packet(7) for an alternative. __SIOCGIFTXQLEN__, __SIOCSIFTXQLEN__ Get or set the transmit queue length of a device using __ifr_qlen__. Setting the transmit queue length is a privileged operation. __SIOCSIFNAME__ Changes the name of the interface specified in __ifr_name__ to __ifr_newname__. This is a privileged operation. It is only allowed when the interface is not up. __SIOCGIFCONF__ Return a list of interface (transport layer) addresses. This currently means only addresses of the AF_INET (IPv4) family for compatibility. The user passes a __ifconf__ structure as argument to the ioctl. It contains a pointer to an array of ''ifreq'' structures in __ifc_req__ and its length in bytes in __ifc_len.__ The kernel fills the ifreqs with all current L3 interface addresses that are running: ''ifr_name'' contains the interface name (eth0:1 etc.), ''ifr_addr'' the address. The kernel returns with the actual length in ''ifc_len''. If ''ifc_len'' is equal to the original length the buffer probably has overflowed and you should retry with a bigger buffer to get all addresses. When no error occurs the ioctl returns 0; otherwise -1. Overflow is no error. Most protocols support their own ioctls to configure protocol specific interface options. See the protocol man pages for a description. For configuring IP addresses see ip(7). In addition some devices support private ioctls. These are not described here. !!NOTES Strictly seen, __SIOCGIFCONF__ is IP specific and belongs in ip(7). The names of interfaces with no addresses or that don't have the __IFF_RUNNING__ flag set can be found via ''/proc/net/dev''. Local IPv6 IP addresses can be found via /proc/net or via rtnetlink(7). !!BUGS glibc 2.1 is missing the ''ifr_newname'' macro in net/if.h. Add the following to your program as workaround: #ifndef ifr_newname #define ifr_newname ifr_ifru.ifru_slave #endif !!SEE ALSO ip(7), proc(7), rtnetlink(7) ----
5 pages link to
netdevice(7)
:
ioctl(2)
Man7n
ipv6(7)
packet(7)
ip(7)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.