2 .\" Copyright (C) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
5 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
6 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH IF_TCP 7P "Sep 02, 2015"
9 if_tcp, if \- general properties of Internet Protocol network interfaces
12 A network interface is a device for sending and receiving packets on a network.
13 It is usually a hardware device, although it can be implemented in software.
14 Network interfaces used by the Internet Protocol (IPv4 or IPv6) must be STREAMS
15 devices conforming to the Data Link Provider Interface (\fBDLPI\fR). See
17 .SH APPLICATION PROGRAMMING INTERFACE
19 An interface becomes available to \fBIP\fR when it is opened and the \fBIP\fR
20 module is pushed onto the stream with the \fBI_PUSH\fR \fBioctl\fR(2) command.
21 (See \fBstreamio\fR(7I)). The \fBSIOCSLIFNAME\fR \fBioctl\fR(2) is issued to
22 specify the name of the interface and to indicate whether it is IPv4 or IPv6.
23 This may be initiated by the kernel at boot time or by a user program after the
24 system is running. Each interface must be assigned an \fBIP\fR address with the
25 \fBSIOCSLIFADDR\fR \fBioctl()\fR before it can be used. On interfaces where the
26 network-to-link layer address mapping is static, only the network number is
27 taken from the \fBioctl()\fR request; the remainder is found in a hardware
28 specific manner. On interfaces which provide dynamic network-to-link layer
29 address mapping facilities (for example, Ethernets using \fBarp\fR(7P)), the
30 entire address specified in the \fBioctl()\fR is used. A routing table entry
31 for destinations on the network of the interface is installed automatically
32 when an interface's address is set.
35 You cannot create IPMP IP interfaces using the procedure described above.
36 Instead, use \fBifconfig\fR(8).
39 The following \fBioctl()\fR calls may be used to manipulate \fBIP\fR network
40 interfaces. Unless specified otherwise, the request takes an \fBlifreq\fR
41 structure as its parameter. This structure has the form:
47 char lifr_name[LIFNAMSIZ]; /* if name, e.g. "le1" */
49 int lifru_addrlen; /* for subnet/token etc */
50 uint_t lifru_ppa; /* SIOCSLIFNAME */
53 struct sockaddr_storage lifru_addr;
54 struct sockaddr_storage lifru_dstaddr;
55 struct sockaddr_storage lifru_broadaddr;
56 struct sockaddr_storage lifru_token; /* With lifr_addrlen */
57 struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */
58 int lifru_index; /* interface index */
59 uint64_t lifru_flags; /* SIOC?LIFFLAGS */
62 int lif_muxid[2]; /* mux id's for arp & ip */
63 struct lif_nd_req lifru_nd_req; /* SIOCLIF*ND */
64 struct lif_ifinfo_req lifru_ifinfo_req;
65 zoneid_t lifru_zone; /* SIOC[GS]LIFZONE */
68 #define lifr_addrlen lifr_lifru1.lifru_addrlen
69 #define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */
70 #define lifr_addr lifr_lifru.lifru_addr /* address */
71 #define lifr_dstaddr lifr_lifru.lifru_dstaddr
72 #define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast addr. */
73 #define lifr_token lifr_lifru.lifru_token /* address token */
74 #define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */
75 #define lifr_index lifr_lifru.lifru_index /* interface index */
76 #define lifr_flags lifr_lifru.lifru_flags /* flags */
77 #define lifr_metric lifr_lifru.lifru_metric /* metric */
78 #define lifr_mtu lifr_lifru.lifru_mtu /* mtu */
79 #define lifr_ip_muxid lifr_lifru.lif_muxid[0]
80 #define lifr_arp_muxid lifr_lifru.lif_muxid[1]
81 #define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */
82 #define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
83 #define lifr_zone lifr_lifru.lifru_zone /* SIOC[GS]LIFZONE */
91 \fB\fBSIOCSLIFADDR\fR\fR
94 Set interface address.
100 \fB\fBSIOCGLIFADDR\fR\fR
103 Get interface address.
109 \fB\fBSIOCSLIFDSTADDR\fR\fR
112 Set point to point address for interface.
118 \fB\fBSIOCGLIFDSTADDR\fR\fR
121 Get point to point address for interface.
127 \fB\fBSIOCSLIFFLAGS\fR\fR
130 Set interface flags field. If the interface is marked down, any processes
131 currently routing packets through the interface are notified.
137 \fB\fBSIOCGLIFFLAGS\fR\fR
146 \fB\fBSIOCGLIFCONF\fR\fR
149 Get interface configuration list. This request takes a \fBlifconf\fR structure
150 (see below) as a value-result parameter. The \fBlifc_family\fR field can be
151 set to \fBAF_UNSPEC\fR to retrieve both \fBAF_INET\fR and \fBAF_INET6\fR
152 interfaces. The \fBlifc_len\fR field should be set to the size of the buffer
153 pointed to by \fBlifc_buf\fR.
155 The \fBlifc_flags\fR field should usually be set to zero, but callers that need
156 low-level knowledge of the underlying IP interfaces that comprise an IPMP
157 group can set it to \fBLIFC_UNDER_IPMP\fR to request that those interfaces be
158 included in the result. Upon success, \fBlifc_len\fR contains the length, in
159 bytes, of the array of \fBlifreq\fR structures pointed to by \fBlifc_req\fR.
160 For each \fBlifreq\fR structure, the \fBlifr_name\fR and \fBlifr_addr\fR fields
167 \fB\fBSIOCGLIFNUM\fR\fR
170 Get number of interfaces. This request returns an integer which is the number
171 of interface descriptions (\fBstruct lifreq\fR) returned by the
172 \fBSIOCGLIFCONF\fR ioctl (in other words, indicates how large \fBlifc_len\fR
175 This request takes a \fBstruct lifnum\fR (see below) as a value-result
176 parameter. The \fBlifn_family\fR field can be set to \fBAF_UNSPEC\fR to count
177 both \fBAF_INET\fR and \fBAF_INET6\fR interfaces. The \fBlifn_flags\fR field
178 should usually be set to zero, but callers that need low-level knowledge of the
179 underlying IP interfaces that comprise an IPMP group can set it to
180 \fBLIFC_UNDER_IPMP\fR to request that those interfaces be included in the
187 \fB\fBSIOCSLIFMTU\fR\fR
190 Set the maximum transmission unit (MTU) size for interface. Place the request
191 in the \fBlifru_mtu\fR field. The \fBMTU\fR can not exceed the physical
192 \fBMTU\fR limitation (which is reported in the \fBDLPI\fR \fBDL_INFO_ACK\fR
199 \fB\fBSIOCGLIFMTU\fR\fR
202 Get the maximum transmission unit size for interface.
208 \fB\fBSIOCSLIFMETRIC\fR\fR
211 Set the metric associated with the interface. The metric is used by routing
212 daemons such as \fBin.routed\fR(8).
218 \fB\fBSIOCGLIFMETRIC\fR\fR
221 Get the metric associated with the interface.
227 \fB\fBSIOCGLIFMUXID\fR\fR
230 Get the \fBip\fR and \fBarp\fR \fBmuxid\fR associated with the interface.
236 \fB\fBSIOCSLIFMUXID\fR\fR
239 Set the \fBip\fR and \fBarp\fR \fBmuxid\fR associated with the interface.
245 \fB\fBSIOCGLIFINDEX\fR\fR
248 Get the interface index associated with the interface.
254 \fB\fBSIOCSLIFINDEX\fR\fR
257 Set the interface index associated with the interface.
263 \fB\fBSIOCGLIFZONE\fR\fR
266 Get the zone associated with the interface.
272 \fB\fBSIOCSLIFZONE\fR\fR
275 Set the zone associated with the interface. Only applies for zones that use the
282 \fB\fBSIOCLIFADDIF\fR\fR
285 Add a new logical interface on a physical interface using an unused logical
292 \fB\fBSIOCLIFREMOVEIF\fR\fR
295 Remove a logical interface by specifying its \fBIP\fR address or logical
302 \fB\fBSIOCSLIFTOKEN\fR\fR
305 Set the address token used to form IPv6 link-local addresses and for stateless
306 address autoconfiguration.
312 \fB\fBSIOCGLIFTOKEN\fR\fR
315 Get the address token used to form IPv6 link-local addresses and for stateless
316 address autoconfiguration.
322 \fB\fBSIOCSLIFSUBNET\fR\fR
325 Set the subnet prefix associated with the interface.
331 \fB\fBSIOCGLIFSUBNET\fR\fR
334 Get the subnet prefix associated with the interface.
340 \fB\fBSIOCSLIFLNKINFO\fR\fR
343 Set link specific parameters for the interface.
349 \fB\fBSIOCGLIFLNKINFO\fR\fR
352 Get link specific parameters for the interface.
358 \fB\fBSIOCLIFDELND\fR\fR
361 Delete a neighbor cache entry for IPv6.
367 \fB\fBSIOCLIFGETND\fR\fR
370 Get a neighbor cache entry for IPv6.
376 \fB\fBSIOCLIFSETND\fR\fR
379 Set a neighbor cache entry for IPv6.
385 \fB\fBSIOCSLIFUSESRC\fR\fR
388 Set the interface from which to choose a source address. The \fBlifr_index\fR
389 field has the interface index corresponding to the interface whose address is
390 to be used as the source address for packets going out on the interface whose
391 name is provided by \fBlifr_name\fR. If the \fBlifr_index\fR field is set to
392 zero, the previous setting is cleared. See \fBifconfig\fR(8) for examples of
393 the \fBusesrc\fR option.
399 \fB\fBSIOCGLIFUSESRC\fR\fR
402 Get the interface index of the interface whose address is used as the source
403 address for packets going out on the interface provided by \fBlifr_name\fR
404 field. The value is retrieved in the \fBlifr_index\fR field. See
405 \fBifconfig\fR(8) for examples of the \fBusesrc\fR option.
411 \fB\fBSIOCGLIFSRCOF\fR\fR
414 Get the interface configuration list for interfaces that use an address hosted
415 on the interface provided by the \fBlifs_ifindex\fR field in the \fBlifsrcof\fR
416 struct (see below), as a source address. The application sets \fBlifs_maxlen\fR
417 to the size (in bytes) of the buffer it has allocated for the data. On return,
418 the kernel sets \fBlifs_len\fR to the actual size required. Note, the
419 application could set \fBlifs_maxlen\fR to zero to query the kernel of the
420 required buffer size instead of estimating a buffer size. The application tests
421 \fBlifs_len\fR <= \fBlifs_maxlen\fR -- if that's true, the buffer was big
422 enough and the application has an accurate list. If it is false, it needs to
423 allocate a bigger buffer and try again, and \fBlifs_len\fR provides a hint of
424 how big to make the next trial. See \fBifconfig\fR(8) for examples of the
431 \fB\fBSIOCTONLINK\fR\fR
434 Test if the address is directly reachable, for example, that it can be reached
435 without going through a router. This request takes an \fBsioc_addrreq\fR
436 structure (see below) as a value-result parameter. The \fBsa_addr\fR field
437 should be set to the address to test. The \fBsa_res\fR field will contain a
438 non-zero value if the address is onlink.
444 \fB\fBSIOCTMYADDR\fR\fR
447 Test if the address is assigned to this node. This request takes an
448 \fBsioc_addrreq\fR structure (see below) as a value-result parameter. The
449 \fBsa_addr\fR field should be set to the address to test. The \fBsa_res\fR
450 field will contain a non-zero value if the address is assigned to this node.
456 \fB\fBSIOCTMYSITE\fR\fR
459 Test if the address is part of the same site as this node. This request takes
460 an \fBsioc_addrreq\fR structure (see below) as a value-result parameter. The
461 \fBsa_addr\fR field should be set to the address to test. The \fBsa_res\fR
462 field will contain a non-zero value if the address is in the same site.
467 The structure used by \fBSIOCGLIFCONF\fR has the form:
472 sa_family_t lifc_family;
473 int lifc_flags; /* request specific
475 int lifc_len; /* size of assoc. buffer */
478 struct lifreq *lifcu_req;
481 #define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */
482 #define lifc_req lifc_lifcu.lifcu_req /* array of structs returned */
489 The structure used by \fBSIOCGLIFNUM\fR has the form:
494 sa_family_t lifn_family;
495 int lifn_flags; /* req. specf. interfaces */
496 int lifn_count; /* Result */
503 The structure used by \fBSIOCTONLINK\fR, \fBSIOCTMYADDR\fR and
504 \fBSIOCTMYSITE\fR has the form:
508 struct sioc_addrreq {
509 struct sockaddr_storage sa_addr; /* Address to test */
510 int sa_res; /* Result - 0/1 */
517 The structure used by \fBSIOCGLIFSRCOF\fR has the form:
522 uint_t lifs_ifindex; /* addr on this interface */
523 /* used as the src addr */
524 size_t lifs_maxlen; /* size of buffer: input */
525 size_t lifs_len; /* size of buffer: output */
528 struct lifreq *lifsu_req;
530 #define lifs_buf lifs_lifsu.lifsu_buf /* buffer addr. */
531 #define lifs_req lifs_lifsu.lifsu_req /* array returned */
538 The following \fBioctl()\fR calls are maintained for compatibility but only
539 apply to IPv4 network interfaces, since the data structures are too small to
540 hold an IPv6 address. Unless specified otherwise, the request takes an
541 \fBifreq\fR structure as its parameter. This structure has the form:
547 char ifr_name[IFNAMSIZ]; /* interface name - e.g. "hme0" */
549 struct sockaddr ifru_addr;
550 struct sockaddr ifru_dstaddr;
551 struct sockaddr ifru_broadaddr;
554 int if_muxid[2]; /* mux id's for arp and ip */
555 int ifru_index; /* interface index */
558 #define ifr_addr ifr_ifru.ifru_addr /* address */
559 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
560 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
561 #define ifr_flags ifr_ifru.ifru_flags /* flags */
562 #define ifr_index ifr_ifru.ifru_index /* interface index */
563 #define ifr_metric ifr_ifru.ifru_metric /* metric */
571 \fB\fBSIOCSIFADDR\fR\fR
574 Set interface address.
580 \fB\fBSIOCGIFADDR\fR\fR
583 Get interface address.
589 \fB\fBSIOCSIFDSTADDR\fR\fR
592 Set point to point address for interface.
598 \fB\fBSIOCGIFDSTADDR\fR\fR
601 Get point to point address for interface.
607 \fB\fBSIOCSIFFLAGS\fR\fR
610 Set interface flags field. If the interface is marked down, any processes
611 currently routing packets through the interface are notified.
617 \fB\fBSIOCGIFFLAGS\fR\fR
626 \fB\fBSIOCGIFCONF\fR\fR
629 Get interface configuration list. This request takes an \fBifconf\fR structure
630 (see below) as a value-result parameter. The \fBifc_len\fR field should be set
631 to the size of the buffer pointed to by \fBifc_buf\fR. Upon success,
632 \fBifc_len\fR will contain the length, in bytes, of the array of \fBifreq\fR
633 structures pointed to by \fBifc_req\fR. For each \fBifreq\fR structure, the
634 \fBifr_name\fR and \fBifr_addr\fR fields are valid. Though IPMP IP interfaces
635 are included in the array, underlying IP interfaces that comprise those IPMP
642 \fB\fBSIOCGIFNUM\fR\fR
645 Get number of interfaces. This request returns an integer which is the number
646 of interface descriptions (\fBstruct ifreq\fR) returned by the
647 \fBSIOCGIFCONF\fR ioctl (in other words, indicates how large \fBifc_len\fR must
648 be). Though IPMP IP interfaces are included in the array, underlying IP
649 interfaces that comprise those IPMP groups are not.
655 \fB\fBSIOCSIFMTU\fR\fR
658 Set the maximum transmission unit (\fBMTU\fR) size for interface. Place the
659 request in the \fBifr_metric\fR field. The \fBMTU\fR has to be smaller than
660 physical \fBMTU\fR limitation (which is reported in the \fBDLPI\fR
661 \fBDL_INFO_ACK\fR message).
667 \fB\fBSIOCGIFMTU\fR\fR
670 Get the maximum transmission unit size for interface. Upon success, the request
671 is placed in the \fBifr_metric\fR field.
677 \fB\fBSIOCSIFMETRIC\fR\fR
680 Set the metric associated with the interface. The metric is used by routine
681 daemons such as \fBin.routed\fR(8).
687 \fB\fBSIOCGIFMETRIC\fR\fR
690 Get the metric associated with the interface.
696 \fB\fBSIOCGIFMUXID\fR\fR
699 Get the \fBip\fR and \fBarp\fR \fBmuxid\fR associated with the interface.
705 \fB\fBSIOCSIFMUXID\fR\fR
708 Set the \fBip\fR and \fBarp\fR \fBmuxid\fR associated with the interface.
714 \fB\fBSIOCGIFINDEX\fR\fR
717 Get the interface index associated with the interface.
723 \fB\fBSIOCSIFINDEX\fR\fR
726 Set the interface index associated with the interface.
731 The \fBifconf\fR structure has the form:
736 int ifc_len; /* size of assoc. buffer */
739 struct ifreq *ifcu_req;
742 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
743 #define ifc_req ifc_ifcu.ifcu_req /* array of structs returned */
750 You can use the \fBifconfig\fR(8) command to display the \fBIFF\fR_ flags
751 listed below (with the leading \fBIFF\fR_ prefix removed). See the
752 \fBifconfig\fR(8) manpage for a definition of each flag.
756 #define IFF_UP 0x0000000001 /* Address is up */
757 #define IFF_BROADCAST 0x0000000002 /* Broadcast address valid */
758 #define IFF_DEBUG 0x0000000004 /* Turn on debugging */
759 #define IFF_LOOPBACK 0x0000000008 /* Loopback net */
761 #define IFF_POINTOPOINT 0x0000000010 /* Interface is p-to-p */
762 #define IFF_NOTRAILERS 0x0000000020 /* Avoid use of trailers */
763 #define IFF_RUNNING 0x0000000040 /* Resources allocated */
764 #define IFF_NOARP 0x0000000080 /* No address res. protocol */
766 #define IFF_PROMISC 0x0000000100 /* Receive all packets */
767 #define IFF_ALLMULTI 0x0000000200 /* Receive all multicast pkts */
768 #define IFF_INTELLIGENT 0x0000000400 /* Protocol code on board */
769 #define IFF_MULTICAST 0x0000000800 /* Supports multicast */
771 #define IFF_MULTI_BCAST 0x0000001000 /* Multicast using broadcst. add. */
772 #define IFF_UNNUMBERED 0x0000002000 /* Non-unique address */
773 #define IFF_DHCPRUNNING 0x0000004000 /* DHCP controls interface */
774 #define IFF_PRIVATE 0x0000008000 /* Do not advertise */
776 #define IFF_NOXMIT 0x0000010000 /* Do not transmit pkts */
777 #define IFF_NOLOCAL 0x0000020000 /* No address - just on-link subnet */
778 #define IFF_DEPRECATED 0x0000040000 /* Address is deprecated */
779 #define IFF_ADDRCONF 0x0000080000 /* Addr. from stateless addrconf */
781 #define IFF_ROUTER 0x0000100000 /* Router on interface */
782 #define IFF_NONUD 0x0000200000 /* No NUD on interface */
783 #define IFF_ANYCAST 0x0000400000 /* Anycast address */
784 #define IFF_NORTEXCH 0x0000800000 /* Don't xchange rout. info */
786 #define IFF_IPV4 0x0001000000 /* IPv4 interface */
787 #define IFF_IPV6 0x0002000000 /* IPv6 interface */
788 #define IFF_NOFAILOVER 0x0008000000 /* in.mpathd test address */
789 #define IFF_FAILED 0x0010000000 /* Interface has failed */
791 #define IFF_STANDBY 0x0020000000 /* Interface is a hot-spare */
792 #define IFF_INACTIVE 0x0040000000 /* Functioning but not used */
793 #define IFF_OFFLINE 0x0080000000 /* Interface is offline */
794 #define IFF_XRESOLV 0x0100000000 /* IPv6 external resolver */
796 #define IFF_COS_ENABLED 0x0200000000 /* If CoS marking is supported */
797 #define IFF_PREFERRED 0x0400000000 /* Prefer as source address */
798 #define IFF_TEMPORARY 0x0800000000 /* RFC3041 */
799 #define IFF_FIXEDMTU 0x1000000000 /* MTU set with SIOCSLIFMTU */
801 #define IFF_VIRTUAL 0x2000000000 /* Cannot send/receive pkts */
802 #define IFF_DUPLICATE 0x4000000000 /* Local address in use */
803 #define IFF_IPMP 0x8000000000 /* IPMP IP interface */
813 Calling process has insufficient privileges.
822 The \fBlifr_name\fR member of the \fBlifreq\fR structure contains an invalid
825 For \fBSIOCGLIFSRCOF\fR, the \fBlifs_ifindex\fR member of the \fBlifsrcof\fR
826 structure contains an invalid value.
828 For \fBSIOCSLIFUSESRC\fR, this error is returned if the \fBlifr_index\fR is set
838 Wrong address family or malformed address.
847 For \fBSIOCSLIFMTU\fR, this error is returned when the requested \fBMTU\fR size
848 is invalid. This error indicates the \fBMTU\fR size is greater than the
849 \fBMTU\fR size supported by the \fBDLPI\fR provider or less than \fB68\fR (for
850 IPv4) or less than \fB1280\fR (for IPv6).
852 For \fBSIOCSLIFUSESRC\fR, this error is returned if either the \fBlifr_index\fR
853 or \fBlifr_name\fR identify interfaces that are already part of an existing
863 For \fBSIOCLIFADDIF\fR, this error is returned if the \fBlifr_name\fR member in
864 the \fBlifreq\fR structure corresponds to an interface that already has the PPA
865 specified by \fBlifr_ppa\fR plumbed.
870 \fBifconfig\fR(8), \fBin.routed\fR(8), \fBioctl\fR(2),
871 \fBsockaddr\fR(3SOCKET), \fBstreamio\fR(7I), \fBarp\fR(7P), \fBdlpi\fR(7P),
872 \fBip\fR(7P), \fBip6\fR(7P), \fBndp\fR(7P)