IF(4N) — UNIX Programmer’s Manual
NAME
if − general properties of network interfaces
DESCRIPTION
Each network interface in a system corresponds to a path through which messages can be sent and received. A network interface usually has a hardware device associated with it, although certain interfaces such as the loopback interface, lo(4), do not.
During the autoconfiguration process at boot time, each interface that has underlying hardware support makes itself known to the system. Once the interface has acquired its address, it is expected to install a routing table entry so that messages can be routed through it. Most interfaces require some part of their address specified with an SIOCSIFADDR ioctl before they allow traffic to flow through them. On interfaces where the network-link layer address mapping is static, only the network number is taken from the ioctl; the remainder is found in a hardware specific manner. Interfaces that provide dynamic network-link layer address mapping facilities, such as 10Mb/s Ethernets using arp(4P),), use the entire address specified in the ioctl.
The following ioctl calls can be used to manipulate network interfaces. Unless specified otherwise, the request takes an ifreq structure as its parameter. This structure has the form
structifreq {
charifr_name[16];/∗ name of interface (e.g. "ec0") ∗/
union {
struct sockaddrifru_addr;
struct sockaddrifru_dstaddr;
struct sockaddrifru_broadaddr;
shortifru_flags;
intifru_metric;
shortifru_mtu;
} ifr_ifru;
#define ifr_addrifr_ifru.ifru_addr/∗ address ∗/
#define ifr_dstaddrifr_ifru.ifru_dstaddr/∗ other end of p-to-p link ∗/
#define ifr_broadaddrifr_ifru.ifru_broadaddr/∗ broadcast address ∗/
#define ifr_flagsifr_ifru.ifru_flags/∗ flags ∗/
#define ifr_metricifr_ifru.ifru_metric/∗ routing metric ∗/
#define ifr_mtuifr_ifru.ifru_mtu/∗ mtu ∗/
};
SIOCSIFADDR
Set interface address. Following the address assignment, the “initialization” routine for the interface is called.
SIOCGIFADDR
Get interface address.
SIOCSIFDSTADDR
Set point to point address for interface.
SIOCGIFDSTADDR
Get point to point address for interface.
SIOCSIFBRDADDR
Set broadcast address for protocol family and interface.
SIOCGIFBRDADDR
Get broadcast address for protocol family and interface.
SIOCSIFFLAGS
Set interface flags field. If the interface is marked down, any processes currently routing packets through the interface are notified.
SIOCGIFFLAGS
Get interface flags.
SIOCSIFMETRIC
Set interface routing metric. The metric is used only by user-level routers.
SIOCGIFMETRIC
Get interface metric.
SIOCGIFCONF
Get interface configuration list. This request takes an ifconf structure (see below) as a value-result parameter. The ifc_len field should be initially set to the size of the buffer pointed to by ifc_buf. On return it will contain the length, in bytes, of the configuration list.
SIOCSIFMTU
set the maximum transfer unit (mtu) of an interface
SIOCGIFMTU
get the maximum transfer unit (mtu) of an interface
/∗
∗ Structure used in SIOCGIFCONF request.
∗ Used to retrieve interface configuration
∗ for machine (useful for programs which
∗ must know all networks accessible).
∗/
structifconf{
intifc_len;/∗ size of associated buffer ∗/
union{
caddr_tifcu_buf;
struct ifreq∗ifcu_req;
} ifc_ifcu;
#define ifc_bufifc_ifcu.ifcu_buf/∗ buffer address ∗/
#define ifc_reqifc_ifcu.ifcu_req/∗ array of structures returned ∗/
};
SEE ALSO
arp(4P), ec(4S), en(4S), lo(4)
4BSD