if(7) DEVICES AND MODULES if(7)
NAME
if - general properties of Internet Protocol network inter-
faces
DESCRIPTION
A network interface is a device for sending and receiving
packets on a network. A network interface is usually a
hardware device, although certain interfaces such as the
loopback interface, lo(7), are implemented in software.
Network interfaces used by the Internet Protocol (IP) must
be STREAMS devices conforming to the Datalink Provider
Interface (DLPI).
An interface becomes available to IP when it is linked below
the IP STREAMS device with the ILINK ioctl() call. This
may be initiated by the kernel at boot time or by a user
program some time after the system is running. Each IP
interface must have a name assigned to it with the SIOCSIF-
NAME ioctl(). This name is used as a unique handle on the
interface by all of the other network interface ioctl()
calls. Each interface must be assigned an IP address with
the SIOCSIFADDR ioctl() before it can be used. On inter-
faces where the network-to-link layer address mapping is
static, only the network number is taken from the ioctl()
request; the remainder is found in a hardware specific
manner. On interfaces which provide dynamic network-to-link
layer address mapping facilities [for example, 10Mb/s Ether-
nets using arp(7)], the entire address specified in the
ioctl() is used. A routing table entry for destinations on
the network of the interface is installed automatically when
an interface's address is set.
IOCTLS
The following ioctl() calls may be used to manipulate IP
network interfaces. Unless specified otherwise, the request
takes an ifreq structure as its parameter. This structure
has the form:
/*
* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
* definitions which begin with ifrname. The
* remainder may be interface specific.
*/
struct ifreq {
#define IFNAMSIZ 16
char ifrname[IFNAMSIZ]; /* if name, e.g. "emd1" */
union {
struct sockaddr ifruaddr;
struct sockaddr ifrudstaddr;
char ifruoname[IFNAMSIZ]; /* other if name */
struct sockaddr ifrubroadaddr;
1
if(7) DEVICES AND MODULES if(7)
short ifruflags;
int ifrumetric;
char ifrudata[1]; /* interface dependent data */
char ifruenaddr[6];
} ifrifru;
#define ifraddr ifrifru.ifruaddr /* address */
#define ifrdstaddr ifrifru.ifrudstaddr /* other end of p-to-p link */
#define ifroname ifrifru.ifruoname /* other if name */
#define ifrbroadaddr ifrifru.ifrubroadaddr /* broadcast address */
#define ifrflags ifrifru.ifruflags /* flags */
#define ifrmetric ifrifru.ifrumetric /* metric */
#define ifrdata ifrifru.ifrudata /* for use by interface */
#define ifrenaddr ifrifru.ifruenaddr /* ethernet address */
};
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 inter-
face.
SIOCGIFDSTADDR Get point to point address for inter-
face.
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.
SIOCGIFCONF Get interface configuration list. This
request takes an ifconf structure (see
below) as a value-result parameter. The
ifclen field should be initially set to
the size of the buffer pointed to by
ifcbuf. On return it will contain the
length, in bytes, of the configuration
list.
2
if(7) DEVICES AND MODULES if(7)
The ifconf structure has the form:
/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int ifclen; /* size of associated buffer */
union {
caddrt ifcubuf;
struct ifreq *ifcureq;
} ifcifcu;
#define ifcbuf ifcifcu.ifcubuf /* buffer address */
#define ifcreq ifcifcu.ifcureq /* array of structures returned */
};
SIOCSIFNAME
Set the name of the interface.
SEE ALSO
arp(7), ip(7), lo(7).
3