if_tcp(7P) Protocols if_tcp(7P)
NAME
if_tcp, if - general properties of Internet Protocol network interfaces
DESCRIPTION
A network interface is a device for sending and receiving packets on a network. It is usually a hardware device, although it can be imple-
mented in software. Network interfaces used by the Internet Protocol (IPv4 or IPv6) must be STREAMS devices conforming to the Data Link
Provider Interface (DLPI). See dlpi(7P).
APPLICATION PROGRAMMING INTERFACE
An interface becomes available to IP when it is opened and the IP module is pushed onto the stream with the I_PUSH ioctl(2) command. (See
streamio(7I)). The SIOCSLIFNAME ioctl(2) is issued to specify the name of the interface and to indicate whether it is IPv4 or IPv6. This
may be initiated by the kernel at boot time or by a user program after the system is running. Each interface must be assigned an IP address
with the SIOCSLIFADDR ioctl() before it can be used. On interfaces where the network-to-link layer address mapping is static, only the net-
work 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 Ethernets using arp(7P)), 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 lifreq struc-
ture as its parameter. This structure has the form:
/* Interface request structure used for socket ioctls. All */
/* interface ioctls must have parameter definitions which */
/* begin with lifr_name. The remainder may be interface specific. */
struct lifreq {
#define LIFNAMSIZ 32
char lifr_name[LIFNAMSIZ]; /* if name, for example "le1" */
union {
int lifru_addrlen; /* for subnet/token etc */
uint_t lifru_ppa; /* SIOCSLIFNAME */
} lifr_lifru1;
union {
struct sockaddr_storage lifru_addr;
struct sockaddr_storage lifru_dstaddr;
struct sockaddr_storage lifru_broadaddr;
struct sockaddr_storage lifru_token; /* With lifr_addrlen */
struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */
int lifru_index; /* interface index */
uint64_t lifru_flags; /* SIOC?LIFFLAGS */
int lifru_metric;
uint_t lifru_mtu;
char lifru_data[1]; /* intfce.dep. data/
char lifru_enaddr[6];
int lif_muxid[2]; /* mux id's for arp and ip */
struct lif_nd_req lifru_nd_req;
struct lif_ifinfo_req lifru_ifinfo_req;
zoneid_t lifru_zone; /* SIOC[GS]LIFZONE */
} lifr_lifru;
#define lifr_addrlen lifr_lifru1.lifru_addrlen
#define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */
#define lifr_addr lifr_lifru.lifru_addr /* address */
#define lifr_dstaddr lifr_lifru.lifru_dstaddr
#define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast address */
#define lifr_token lifr_lifru.lifru_token /* address token */
#define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */
#define lifr_index lifr_lifru.lifru_index /* interface index */
#define lifr_flags lifr_lifru.lifru_flags /* flags */
#define lifr_metric lifr_lifru.lifru_metric /* metric */
#define lifr_mtu lifr_lifru.lifru_mtu /* mtu */
#define lifr_data lifr_lifru.lifru_data
#define lifr_enaddr lifr_lifru.lifru_enaddr /* ethernet address */
#define lifr_index lifr_lifru.lifru_index /* interface index */
#define lifr_ip_muxid lifr_lifru.lif_muxid[0]
#define lifr_arp_muxid lifr_lifru.lif_muxid[1]
#define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */
#define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
#define lifr_zone lifr_lifru.lifru_zone /* SIOC[GS]LIFZONE */
};
SIOCSLIFADDR Set interface address. Following the address assignment, the "initialization" routine for the interface is called.
SIOCGLIFADDR Get interface address.
SIOCSLIFDSTADDR Set point to point address for interface.
SIOCGLIFDSTADDR Get point to point address for interface.
SIOCSLIFFLAGS Set interface flags field. If the interface is marked down, any processes currently routing packets through the
interface are notified.
SIOCGLIFFLAGS Get interface flags.
SIOCGLIFCONF Get interface configuration list. This request takes an lifconf structure (see below) as a value-result parameter.
The lifc_len field should be initially set to the size of the buffer pointed to by lifc_buf. On return it will con-
tain the length, in bytes, of the configuration list. The lifc_family field should be set to AF_UNSPEC to retrieve
both AF_INET and AF_INET6 interfaces. The lifc_flags field should be initially set to zero.
SIOCGLIFNUM Get number of interfaces. This request returns an integer which is the number of interface descriptions (struct
lifreq) that will be returned by the SIOCGLIFCONF ioctl; that is, it gives an indication of how large lifc_len has
to be. This request takes an lifnum structure (see below) as a value-result parameter. The lifn_family field should
be set to AF_UNSPEC to count both AF_INET and AF_INET6 interfaces. The lifn_flags field should be initially set to
zero.
SIOCSLIFMTU Set the maximum transmission unit (MTU) size for interface. Place the result of this request in lifru_mtu field.
The MTU can not exceed the physical MTU limitation (which is reported in the DLPI DL_INFO_ACK message).
SIOCGLIFMTU Get the maximum transmission unit size for interface. Place the result of this request in ifru_mtu field.
SIOCSLIFMETRIC Set the metric associated with the interface. The metric is used by routing daemons such as in.routed(1M).
SIOCGLIFMETRIC Get the metric associated with the interface.
SIOCGLIFMUXID Get the ip and arp muxid associated with the interface.
SIOCSLIFMUXID Set the ip and arp muxid associated with the interface.
SIOCGLIFINDEX Get the interface index associated with the interface.
SIOCSLIFINDEX Set the interface index associated with the interface.
SIOCGLIFZONE Get the zone associated with the interface.
SIOCSLIFZONE Set the zone associated with the interface.
SIOCLIFADDIF Add a new logical interface on a physical interface using an unused logical unit number. If the physical interface
is part of an IP multipathing group, the logical interface may be added to a different physical interface in the
same group. Upon return, the lifr_name field contains the name of the actual logical interface created.
SIOCLIFREMOVEIF Remove a logical interface by specifying its IP address or logical interface name. When the IP address is specified
and the interface is part of an IP multipathing group, the logical interface is removed from the physical interface
in the group which holds the IP address.
SIOCSLIFTOKEN Set the address token used to form IPv6 link-local addresses and for stateless address autoconfiguration.
SIOCGLIFTOKEN Get the address token used to form IPv6 link-local addresses and for stateless address autoconfiguration.
SIOCSLIFSUBNET Set the subnet prefix associated with the interface.
SIOCGLIFSUBNET Get the subnet prefix associated with the interface.
SIOCSLIFLNKINFO Set link specific parameters for the interface.
SIOCGLIFLNKINFO Get link specific parameters for the interface.
SIOCLIFDELND Delete a neighbor cache entry for IPv6.
SIOCLIFGETND Get a neighbor cache entry for IPv6.
SIOCLIFSETND Set a neighbor cache entry for IPv6.
SIOCTMYADDR Test if the address is assigned to this node. This request takes an sioc_addrreq structure (see below) as a value-
result parameter. The sa_addr field should be set to the address to test. The sa_res field will contain a non-zero
value if the address is assigned to this node.
SIOCSLIFUSESRC Set the interface from which to choose a source address. The lifr_index field has the interface index corresponding
to the interface whose address is to be used as the source address for packets going out on the interface whose
name is provided by lifr_name. If the lifr_index field is set to zero, the previous setting is cleared. See ifcon-
fig(1M) for examples of the 'usesrc' option.
SIOCGLIFUSESRC Get the interface index of the interface whose address is used as the source address for packets going out on the
interface provided by lifr_name field. The value is retrieved in the lifr_index field. See ifconfig(1M) for exam-
ples of the 'usesrc' option.
SIOCGLIFSRCOF Get the interface configuration list for interfaces that use an address hosted on the interface provided by the
lifs_ifindex field in the lifsrcof struct (see below), as a source address. The application sets lifs_maxlen to the
size (in bytes) of the buffer it has allocated for the data. On return, the kernel sets lifs_len to the actual size
required. Note, the application could set lifs_maxlen to zero to query the kernel of the required buffer size
instead of estimating a buffer size. The application tests 'lifs_len <= lifs_maxlen' -- if that's true, the buffer
was big enough and the application has an accurate list. If it is false, it needs to allocate a bigger buffer and
try again, and lifs_len provides a hint of how big to make the next trial. See ifconfig(1M) for examples of the
'usesrc' option.
The lifsrcof structure has the form:
/*
* Structure used in SIOCGLIFSRCOF to get the interface
* configuration list for those interfaces that use an address
* hosted on the interface (set in lifs_ifindex), as the source
* address.
*/
struct lifsrcof {
uint_t lifs_ifindex; /* addr on this interface used as the src addr */
size_t lifs_maxlen; /* size of buffer: input */
size_t lifs_len; /* size of buffer: output */
union {
caddr_t lifsu_buf;
struct lifreq *lifsu_req;
} lifs_lifsu;
#define lifs_buf lifs_lifsu.lifsu_buf /* buffer address */
#define lifs_req lifs_lifsu.lifsu_req /* array returned */
};
SIOCTONLINK Test if the address is directly reachable, for example, that it can be reached without going through a router. This
request takes an sioc_addrreq structure (see below) as a value-result parameter. The sa_addr field should be set to
the address to test. The sa_res field will contain a non-zero value if the address is onlink.
SIOCTMYSITE Test if the address is part of the same site as this node. This request takes an sioc_addrreq structure (see below)
as a value-result parameter. The sa_addr field should be set to the address to test. The sa_res field will contain
a non-zero value if the address is in the same site.
The lifconf structure has the form:
/*
* Structure used in SIOCGLIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct lifconf {
sa_family_t lifc_family;
int lifc_flags; /* request specific interfaces */
int lifc_len; /* size of associated buffer */
union {
caddr_t lifcu_buf;
struct ifreq *lifcu_req;
} lifc_lifcu;
#define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */
#define lifc_req lifc_lifcu.lifcu_req /* array of structures returned */
};
The sioc_addrreq structure has the form:
/* Structure used in SIOCGLIFNUM request. */
struct lifnum {
sa_family_t lifn_family;
int lifn_flags; /* request specific interfaces */
int lifn_count; /* Result */
};
/*
* Argument structure for SIOCT* address testing ioctls.
*/
struct sioc_addrreq {
struct sockaddr_storage sa_addr; /* Address to test */
int sa_res; /* Result - 0/1 */
};
The following ioctl() calls are maintained for compatibility but only apply to IPv4 network interfaces, since the data structures are too
small to hold an IPv6 address. Unless specified otherwise, the request takes an ifreq structure as its parameter. This structure has the
form:
/* Interface request structure used for socket ioctls. All */
/* interface ioctls must have parameter definitions which */
/* begin with lifr_name. The remainder may be interface specific. */
struct ifreq {
#define IFNAMSIZ 16
char lifr_name[IFNAMSIZ]; /* if name, for example */
/* "le1" */
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
char ifru_oname[IFNAMSIZ]; /* other if name */
struct sockaddr ifru_broadaddr;
short ifru_flags;
int ifru_metric;
char ifru_data[1]; /* intfce. depen. data */
char ifru_enaddr[6];
int if_muxid[2]; /* mux id's for arp and ip */
int ifru_index; /* interface index */
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_oname ifr_ifru.ifru_oname /* other if name */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_index ifr_ifru.ifru_index /* interface index */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_enaddr ifr_ifru.ifru_enaddr a/* 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 interface.
SIOCGIFDSTADDR Get point to point address for 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.
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 con-
tain the length, in bytes, of the configuration list.
SIOCGIFNUM Get number of interfaces. This request returns an integer which is the number of interface descriptions (struct
ifreq) that will be returned by the SIOCGIFCONF ioctl; that is, it gives an indication of how large ifc_len has to
be.
SIOCSIFMTU Set the maximum transmission unit (MTU) size for interface. Place the result of this request in ifru_metric field.
The MTU has to be smaller than physical MTU limitation (which is reported in the DLPI DL_INFO_ACK message).
SIOCGIFMTU Get the maximum transmission unit size for interface. Place the result of this request in ifru_metric field.
SIOCSIFMETRIC Set the metric associated with the interface. The metric is used by routine daemons such as in.routed(1M).
SIOCGIFMETRIC Get the metric associated with the interface.
SIOCGIFMUXID Get the ip and arp muxid associated with the interface.
SIOCSIFMUXID Set the ip and arp muxid associated with the interface.
SIOCGIFINDEX Get the interface index associated with the interface.
SIOCSIFINDEX Set the interface index associated with the interface.
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 ifc_len; /* size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
IFF_ Flags
To display addressing information for each interface, enter ifconfig -a. IFF_ flags are defined in /usr/include/net/if.h. The flags are:
#define IFF_UP 0x00000001 /* Interface is up */
#define IFF_BROADCAST 0x00000002 /* Broadcast address valid */
#define IFF_DEBUG 0x00000004 /* Turn on debugging */
#define IFF_LOOPBACK 0x00000008 /* Loopback net */
#define IFF_POINTOPOINT 0x00000010 /* Interface is point-to-point link */
#define IFF_NOTRAILERS 0x00000020 /* Avoid use of trailers */
#define IFF_RUNNING 0x00000040 /* Resources allocated */
#define IFF_NOARP 0x00000080 /* No address resolution protocol */
#define IFF_PROMISC 0x00000100 /* Receive all packets */
#define IFF_ALLMULTI 0x00000200 /* Receive all multicast packets */
#define IFF_INTELLIGENT 0x00000400 /* Protocol code on board */
#define IFF_MULTICAST 0x00000800 /* Supports multicast */
#define IFF_MULTI_BCAST 0x00001000 /* Multicast using broadcast address */
#define IFF_UNNUMBERED 0x00002000 /* Non-unique address */
#define IFF_DHCPRUNNING 0x00004000 /* DHCP controls this interface */
#define IFF_PRIVATE 0x00008000 /* Do not advertise */
#define IFF_NOXMIT 0x00010000 /* Do not transmit packets */
#define IFF_NOLOCAL 0x00020000 /* No address - just on-link subnet */
#define IFF_DEPRECATED 0x00040000 /* Interface address deprecated */
#define IFF_ADDRCONF 0x00080000 /* Address from stateless addrconf */
#define IFF_ROUTER 0x00100000 /* Router on this interface */
#define IFF_NONUD 0x00200000 /* No NUD on this interface */
#define IFF_ANYCAST 0x00400000 /* Anycast address */
#define IFF_NORTEXCH 0x00800000 /* Do not exchange routing info */
#define IFF_IPV4 0x01000000 /* IPv4 interface */
#define IFF_IPV6 0x02000000 /* IPv6 interface */
#define IFF_MIPRUNNING 0x04000000 /* Mobile IP controls this interface */
#define IFF_NOFAILOVER 0x008000000 /* Don't failover on NIC failure */
#define IFF_FAILED 0x010000000 /* NIC has failed */
#define IFF_STANDBY 0x020000000 /* Standby NIC-use on failures */
#define IFF_INACTIVE 0x040000000 /* Standby active or not ? */
#define IFF_OFFLINE 0x080000000 /* NIC has been offlined */
#define IFF_XRESOLV 0x100000000 /* IPv6 external resolver */
#define IFF_COS_ENABLED 0x200000000 /* If CoS marking is supported */
#define IFF_VIRTUAL 0x2000000000 /* Does not send or receive packets */
For more information on IFF_ flags, see ifconfig(1M).
ERRORS
EPERM The effective user id of the calling process in not superuser.
ENXIO The lifr_name member of the lifreq structure contains an invalid value.
For SIOCGLIFSRCOF, the lifs_ifindex member of the lifsrcof structure contains an invalid value.
For SIOCSLIFUSESRC, this error is returned if the lifr_index is set to an invalid value.
EBADADDR Wrong address family or malformed address.
EBUSY For SIOCSLIFFLAGS, this error is returned when the order of bringing the primary/physical interface (for example, eri0)
and a secondary/logical interface associated with the same physical interface (for example, eri0:1) up or down is violated.
The physical interface must be configured up first and cannot be configured down until all the corresponding logical
interfaces have been configured down.
EINVAL For SIOCSLIFMTU, this error is returned when the requested MTU size is invalid. This error indicates the MTU size is
greater than the MTU size supported by the DLPI provider or less than 68 (for IPv4 ) or less than 1200 (for IPv6 ). ]
For SIOCSLIFUSESRC, this error is returned if either the lifr_index or lifr_name identify interfaces that are already part
of an existing IPMP group.
EEXIST For SIOCLIFADDIF, this error is returned if the lifr_name member in the lifreq structure corresponds to an interface that
already has the PPA specified by lifru_ppa plumbed.
SEE ALSO
ifconfig(1M), in.routed(1M), ioctl(2), streamio(7I), arp(7P), dlpi(7P), ip(7P), ip6(7P)
SunOS 5.10 26 August 2004 if_tcp(7P)