1 Protocols if_tcp(7P)
2
3 NAME
4 if_tcp, if - general properties of Internet Protocol network
5 interfaces
6
7 DESCRIPTION
8 A network interface is a device for sending and receiving
9 packets on a network. It is usually a hardware device,
10 although it can be implemented in software. Network inter-
11 faces used by the Internet Protocol (IPv4 or IPv6) must be
12 STREAMS devices conforming to the Data Link Provider Inter-
13 face (DLPI). See dlpi(7P).
14
15 APPLICATION PROGRAMMING INTERFACE
16 An interface becomes available to IP when it is opened and
17 the IP module is pushed onto the stream with the I_PUSH
18 ioctl(2) command. (See streamio(7I)). The SIOCSLIFNAME
19 ioctl(2) is issued to specify the name of the interface and
20 to indicate whether it is IPv4 or IPv6. This may be ini-
21 tiated by the kernel at boot time or by a user program after
22 the system is running. Each interface must be assigned an IP
23 address with the SIOCSLIFADDR ioctl() before it can be used.
24 On interfaces where the network-to-link layer address map-
25 ping is static, only the network number is taken from the
26 ioctl() request; the remainder is found in a hardware
27 specific manner. On interfaces which provide dynamic
28 network-to-link layer address mapping facilities (for exam-
29 ple, 10Mb/s Ethernets using arp(7P)), the entire address
30 specified in the ioctl() is used. A routing table entry for
31 destinations on the network of the interface is installed
32 automatically when an interface's address is set.
33
34 Note IPMP IP interfaces cannot be created using the
35 procedure described above. Instead, ifconfig(1M) must be
36 used to create IPMP IP interfaces.
37
38 IOCTLS
39 The following ioctl() calls may be used to manipulate IP
40 network interfaces. Unless specified otherwise, the request
41 takes an lifreq structure as its parameter. This structure
42 has the form:
43
44 struct lifreq {
45 #define LIFNAMSIZ 32
46 char lifr_name[LIFNAMSIZ]; /* if name, e.g. "le1" */
47 union {
48 int lifru_addrlen; /* for subnet/token etc */
49 uint_t lifru_ppa; /* SIOCSLIFNAME */
50 } lifr_lifru1;
51 union {
52 struct sockaddr_storage lifru_addr;
53 struct sockaddr_storage lifru_dstaddr;
54 struct sockaddr_storage lifru_broadaddr;
55 struct sockaddr_storage lifru_token; /* With lifr_addrlen */
56 struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */
57 int lifru_index; /* interface index */
58 uint64_t lifru_flags; /* SIOC?LIFFLAGS */
59
60 SunOS 5.10 Last change: 14 Nov 2008 1
61
62 Protocols if_tcp(7P)
63
64 int lifru_metric;
65 uint_t lifru_mtu;
66 int lif_muxid[2]; /* mux id's for arp & ip */
67 struct lif_nd_req lifru_nd_req;
68 struct lif_ifinfo_req lifru_ifinfo_req;
69 zoneid_t lifru_zone; /* SIOC[GS]LIFZONE */
70 } lifr_lifru;
71
72 #define lifr_addrlen lifr_lifru1.lifru_addrlen
73 #define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */
74 #define lifr_addr lifr_lifru.lifru_addr /* address */
75 #define lifr_dstaddr lifr_lifru.lifru_dstaddr
76 #define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast addr. */
77 #define lifr_token lifr_lifru.lifru_token /* address token */
78 #define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */
79 #define lifr_index lifr_lifru.lifru_index /* interface index */
80 #define lifr_flags lifr_lifru.lifru_flags /* flags */
81 #define lifr_metric lifr_lifru.lifru_metric /* metric */
82 #define lifr_mtu lifr_lifru.lifru_mtu /* mtu */
83 #define lifr_ip_muxid lifr_lifru.lif_muxid[0]
84 #define lifr_arp_muxid lifr_lifru.lif_muxid[1]
85 #define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */
86 #define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
87 #define lifr_zone lifr_lifru.lifru_zone /* SIOC[GS]LIFZONE */
88 };
89
90 SIOCSLIFADDR Set interface address.
91
92 SIOCGLIFADDR Get interface address.
93
94 SIOCSLIFDSTADDR Set point to point address for inter-
95 face.
96
97 SIOCGLIFDSTADDR Get point to point address for inter-
98 face.
99
100 SIOCSLIFFLAGS Set interface flags field. If the inter-
101 face is marked down, any processes
102 currently routing packets through the
103 interface are notified.
104
105 SIOCGLIFFLAGS Get interface flags.
106
107 SIOCGLIFCONF Get interface configuration list. This
108 request takes a *lifconf* structure (see
109 below) as a value-result parameter. The
110 *lifc_family* field can be set to
111 *AF_UNSPEC* to retrieve both *AF_INET*
112 and *AF_INET6* interfaces. The
113 *lifc_len* field should be set to the
114 size of the buffer pointed to by
115 *lifc_buf*.
116
117 The *lifc_flags* field should usually be
118 set to zero, but callers that need low-
119 level knowledge of the underlying IP
120 interfaces that comprise an IPMP group
121 can set it to *LIFC_UNDER_IPMP* to
122 request that those interfaces be
123 included in the result.
124
125 Upon success, *lifc_len* will contain
126 the length, in bytes, of the array of
127 *lifreq* structures pointed to by
128 *lifc_req*. For each *lifreq* structure,
129 the *lifr_name* and *lifr_addr* fields
130 will be valid.
131
132
133 SIOCGLIFNUM Get number of interfaces. This request
134 returns an integer which is the number
135 of interface descriptions (struct
136 lifreq) that will be returned by the
137 SIOCGLIFCONF ioctl; that is, it gives an
138 indication of how large lifc_len has
139 to be.
140
141 This request takes a *struct lifnum*
142 (see below) as a value-result parameter.
143 The *lifn_family* field can be set to
144 *AF_UNSPEC* to count both *AF_INET* and
145 *AF_INET6* interfaces. The *lifn_flags*
146 field should usually be set to zero, but
147 callers that need low-level knowledge of
148 the underlying IP interfaces that
149 comprise an IPMP group can set it to
150 *LIFC_UNDER_IPMP* to request that those
151 interfaces be included in the count.
152
153
154 SIOCSLIFMTU Set the maximum transmission unit (MTU)
155 size for interface. Place the request in
156 the lifru_mtu field. The MTU can not
157 exceed the physical MTU limitation
158 (which is reported in the DLPI
159 DL_INFO_ACK message).
160
161 SIOCGLIFMTU Get the maximum transmission unit size
162 for interface.
163
164 SIOCSLIFMETRIC Set the metric associated with the
165 interface. The metric is used by rout-
166 ing daemons such as in.routed(1M).
167
168 SIOCGLIFMETRIC Get the metric associated with the
169 interface.
170
171 SIOCGLIFMUXID Get the ip and arp muxid associated with
172 the interface.
173
174 SunOS 5.10 Last change: 14 Nov 2008 3
175
176 Protocols if_tcp(7P)
177
178 SIOCSLIFMUXID Set the ip and arp muxid associated with
179 the interface.
180
181 SIOCGLIFINDEX Get the interface index associated with
182 the interface.
183
184 SIOCSLIFINDEX Set the interface index associated with
185 the interface.
186
187 SIOCGLIFZONE Get the zone associated with the inter-
188 face.
189
190 SIOCSLIFZONE Set the zone associated with the inter-
191 face. Only applies for zones that use
192 the shared-IP instance.
193
194 SIOCLIFADDIF Add a new logical interface on a physi-
195 cal interface using an unused logical
196 interface number.
197
198 SIOCLIFREMOVEIF Remove a logical interface by specifying
199 its IP address or logical interface
200 name.
201
202 SIOCSLIFTOKEN Set the address token used to form IPv6
203 link-local addresses and for stateless
204 address autoconfiguration.
205
206 SIOCGLIFTOKEN Get the address token used to form IPv6
207 link-local addresses and for stateless
208 address autoconfiguration.
209
210 SunOS 5.10 Last change: 14 Nov 2008 4
211
212 Protocols if_tcp(7P)
213
214 SIOCSLIFSUBNET Set the subnet prefix associated with
215 the interface.
216
217 SIOCGLIFSUBNET Get the subnet prefix associated with
218 the interface.
219
220 SIOCSLIFLNKINFO Set link specific parameters for the
221 interface.
222
223 SIOCGLIFLNKINFO Get link specific parameters for the
224 interface.
225
226 SIOCLIFDELND Delete a neighbor cache entry for IPv6.
227
228 SIOCLIFGETND Get a neighbor cache entry for IPv6.
229
230 SIOCLIFSETND Set a neighbor cache entry for IPv6.
231
232 SIOCSLIFUSESRC Set the interface from which to choose a
233 source address. The lifr_index field has
234 the interface index corresponding to the
235 interface whose address is to be used as
236 the source address for packets going out
237 on the interface whose name is provided
238 by lifr_name. If the lifr_index field is
239 set to zero, the previous setting is
240 cleared. See ifconfig(1M) for examples
241 of the usesrc option.
242
243 SIOCGLIFUSESRC Get the interface index of the interface
244 whose address is used as the source
245 address for packets going out on the
246 interface provided by lifr_name field.
247 The value is retrieved in the lifr_index
248 field. See ifconfig(1M) for examples of
249 the usesrc option.
250
251 SIOCGLIFSRCOF Get the interface configuration list for
252 interfaces that use an address hosted on
253 the interface provided by the
254 lifs_ifindex field in the lifsrcof
255 struct (see below), as a source address.
256 The application sets lifs_maxlen to the
257
258 SunOS 5.10 Last change: 14 Nov 2008 5
259
260 Protocols if_tcp(7P)
261
262 size (in bytes) of the buffer it has
263 allocated for the data. On return, the
264 kernel sets lifs_len to the actual size
265 required. Note, the application could
266 set lifs_maxlen to zero to query the
267 kernel of the required buffer size
268 instead of estimating a buffer size. The
269 application tests lifs_len <=
270 lifs_maxlen -- if that's true, the
271 buffer was big enough and the applica-
272 tion has an accurate list. If it is
273 false, it needs to allocate a bigger
274 buffer and try again, and lifs_len pro-
275 vides a hint of how big to make the next
276 trial. See ifconfig(1M) for examples of
277 the usesrc option.
278
279 SIOCTONLINK Test if the address is directly reach-
280 able, for example, that it can be
281 reached without going through a router.
282 This request takes an sioc_addrreq
283 structure (see below) as a value-result
284 parameter. The sa_addr field should be
285 set to the address to test. The sa_res
286 field will contain a non-zero value if
287 the address is onlink.
288
289 SIOCTMYADDR Test if the address is assigned to this
290 node. This request takes an sioc_addrreq
291 structure (see below) as a value-result
292 parameter. The sa_addr field should be
293 set to the address to test. The sa_res
294 field will contain a non-zero value if
295 the address is assigned to this node.
296
297 SIOCTMYSITE Test if the address is part of the same
298 site as this node. This request takes an
299 sioc_addrreq structure (see below) as a
300 value-result parameter. The sa_addr
301 field should be set to the address to
302 test. The sa_res field will contain a
303 non-zero value if the address is in the
304 same site.
305
306 The structure used by SIOCGLIFCONF has the form:
307
308 struct lifconf {
309 sa_family_t lifc_family;
310
311 SunOS 5.10 Last change: 14 Nov 2008 6
312
313 Protocols if_tcp(7P)
314
315 int lifc_flags; /* request specific
316 /* interfaces */
317 int lifc_len; /* size of assoc. buffer */
318 union {
319 caddr_t lifcu_buf;
320 struct lifreq *lifcu_req;
321 } lifc_lifcu;
322
323 #define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */
324 #define lifc_req lifc_lifcu.lifcu_req /* array of structs returned */
325 };
326
327 The structure used by SIOCGLIFNUM has the form:
328
329 struct lifnum {
330 sa_family_t lifn_family;
331 int lifn_flags; /* req. specf. interfaces */
332 int lifn_count; /* Result */
333 };
334
335 The structure used by SIOCTONLINK, SIOCTMYADDR and SIOCTMYSITE has the form:
336
337 struct sioc_addrreq {
338 struct sockaddr_storage sa_addr; /* Address to test */
339 int sa_res; /* Result - 0/1 */
340 };
341
342 The structure used by SIOCGLIFSRCOF has the form:
343
344 struct lifsrcof {
345 uint_t lifs_ifindex; /* addr on this interface */
346 /* used as the src addr */
347 size_t lifs_maxlen; /* size of buffer: input */
348 size_t lifs_len; /* size of buffer: output */
349 union {
350 caddr_t lifsu_buf;
351 struct lifreq *lifsu_req;
352 } lifs_lifsu;
353 #define lifs_buf lifs_lifsu.lifsu_buf /* buffer addr. */
354 #define lifs_req lifs_lifsu.lifsu_req /* array returned */
355 };
356
357 The following ioctl() calls are maintained for compatibility
358 but only apply to IPv4 network interfaces, since the data
359 structures are too small to hold an IPv6 address. Unless
360 specified otherwise, the request takes an ifreq structure as
361 its parameter. This structure has the form:
362
363 struct ifreq {
364
365 SunOS 5.10 Last change: 14 Nov 2008 7
366
367 Protocols if_tcp(7P)
368
369 #define IFNAMSIZ 16
370 char ifr_name[IFNAMSIZ]; /* interface name - e.g. "hme0" */
371 union {
372 struct sockaddr ifru_addr;
373 struct sockaddr ifru_dstaddr;
374 struct sockaddr ifru_broadaddr;
375 short ifru_flags;
376 int ifru_metric;
377 int if_muxid[2]; /* mux id's for arp and ip */
378 int ifru_index; /* interface index */
379 } ifr_ifru;
380
381 #define ifr_addr ifr_ifru.ifru_addr /* address */
382 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
383 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
384 #define ifr_flags ifr_ifru.ifru_flags /* flags */
385 #define ifr_index ifr_ifru.ifru_index /* interface index */
386 #define ifr_metric ifr_ifru.ifru_metric /* metric */
387 };
388
389 SIOCSIFADDR Set interface address.
390
391 SIOCGIFADDR Get interface address.
392
393 SIOCSIFDSTADDR Set point to point address for interface.
394
395 SIOCGIFDSTADDR Get point to point address for interface.
396
397 SIOCSIFFLAGS Set interface flags field. If the inter-
398 face is marked down, any processes
399 currently routing packets through the
400 interface are notified.
401
402 SIOCGIFFLAGS Get interface flags.
403
404 SIOCGIFCONF Get interface configuration list. This
405 request takes an ifconf structure (see
406 below) as a value-result parameter. The
407 ifc_len field should be set to the size
408 of the buffer pointed to by ifc_buf. Upon
409 success, ifc_len will contain the length,
410 in bytes, of the array of ifreq struc-
411 tures pointed to by ifc_req. For each
412 ifreq structure, the ifr_name and
413 *ifr_addr* fields will be valid. While
414 any IPMP IP interfaces will be included
415 in the array, the underlying IP
416 interfaces that comprise those IPMP
417 groups will not be.
418
419 SunOS 5.10 Last change: 14 Nov 2008 8
420
421 Protocols if_tcp(7P)
422
423 SIOCGIFNUM Get number of interfaces. This request
424 returns an integer which is the number of
425 interface descriptions (struct ifreq)
426 that will be returned by the SIOCGIFCONF
427 ioctl; that is, it gives an indication of
428 how large *ifc_len* has to be. While any
429 IPMP IP interfaces will be included in
430 the array, the underlying IP interfaces
431 that comprise those IPMP groups will not
432 be.
433
434 SIOCSIFMTU Set the maximum transmission unit (MTU)
435 size for interface. Place the request in
436 the ifr_metric field. The MTU has to be
437 smaller than physical MTU limitation
438 (which is reported in the DLPI
439 DL_INFO_ACK message).
440
441 SIOCGIFMTU Get the maximum transmission unit size
442 for interface. Upon success, the request
443 is placed in the ifr_metric field.
444
445 SIOCSIFMETRIC Set the metric associated with the inter-
446 face. The metric is used by routine dae-
447 mons such as in.routed(1M).
448
449 SIOCGIFMETRIC Get the metric associated with the inter-
450 face.
451
452 SIOCGIFMUXID Get the ip and arp muxid associated with
453 the interface.
454
455 SIOCSIFMUXID Set the ip and arp muxid associated with
456 the interface.
457
458 SIOCGIFINDEX Get the interface index associated with
459 the interface.
460
461 SIOCSIFINDEX Set the interface index associated with
462 the interface.
463
464 The ifconf structure has the form:
465
466 struct ifconf {
467 int ifc_len; /* size of assoc. buffer */
468 union {
469
470 SunOS 5.10 Last change: 14 Nov 2008 9
471
472 Protocols if_tcp(7P)
473
474 caddr_t ifcu_buf;
475 struct ifreq *ifcu_req;
476 } ifc_ifcu;
477
478 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
479 #define ifc_req ifc_ifcu.ifcu_req /* array of structs returned */
480 };
481
482 IFF_ Flags
483 You can use the ifconfig(1M) command to display the IFF_
484 flags listed below (with the leading IFF_ prefix removed).
485 See the ifconfig(1M) manpage for a definition of each flag.
486
487 #define IFF_UP 0x0000000001 /* Address is up */
488 #define IFF_BROADCAST 0x0000000002 /* Broadcast address valid */
489 #define IFF_DEBUG 0x0000000004 /* Turn on debugging */
490 #define IFF_LOOPBACK 0x0000000008 /* Loopback net */
491
492 #define IFF_POINTOPOINT 0x0000000010 /* Interface is p-to-p */
493 #define IFF_NOTRAILERS 0x0000000020 /* Avoid use of trailers */
494 #define IFF_RUNNING 0x0000000040 /* Resources allocated */
495 #define IFF_NOARP 0x0000000080 /* No address res. protocol */
496
497 #define IFF_PROMISC 0x0000000100 /* Receive all packets */
498 #define IFF_ALLMULTI 0x0000000200 /* Receive all multicast pkts */
499 #define IFF_INTELLIGENT 0x0000000400 /* Protocol code on board */
500 #define IFF_MULTICAST 0x0000000800 /* Supports multicast */
501
502 #define IFF_MULTI_BCAST 0x0000001000 /* Multicast using broadcst. add. */
503 #define IFF_UNNUMBERED 0x0000002000 /* Non-unique address */
504 #define IFF_DHCPRUNNING 0x0000004000 /* DHCP controls interface */
505 #define IFF_PRIVATE 0x0000008000 /* Do not advertise */
506
507 #define IFF_NOXMIT 0x0000010000 /* Do not transmit pkts */
508 #define IFF_NOLOCAL 0x0000020000 /* No address - just on-link subnet */
509 #define IFF_DEPRECATED 0x0000040000 /* Address is deprecated */
510 #define IFF_ADDRCONF 0x0000080000 /* Addr. from stateless addrconf */
511
512 #define IFF_ROUTER 0x0000100000 /* Router on interface */
513 #define IFF_NONUD 0x0000200000 /* No NUD on interface */
514 #define IFF_ANYCAST 0x0000400000 /* Anycast address */
515 #define IFF_NORTEXCH 0x0000800000 /* Don't xchange rout. info */
516
517 #define IFF_IPV4 0x0001000000 /* IPv4 interface */
518 #define IFF_IPV6 0x0002000000 /* IPv6 interface */
519 #define IFF_NOFAILOVER 0x0008000000 /* in.mpathd test address */
520 #define IFF_FAILED 0x0010000000 /* Interface has failed */
521
522 #define IFF_STANDBY 0x0020000000 /* Interface is a hot-spare */
523 #define IFF_INACTIVE 0x0040000000 /* Functioning but not used */
524 #define IFF_OFFLINE 0x0080000000 /* Interface is offline */
525 #define IFF_XRESOLV 0x0100000000 /* IPv6 external resolver */
526
527 #define IFF_COS_ENABLED 0x0200000000 /* If CoS marking is supported */
528 #define IFF_PREFERRED 0x0400000000 /* Prefer as source address */
529 #define IFF_TEMPORARY 0x0800000000 /* RFC3041 */
530 #define IFF_FIXEDMTU 0x1000000000 /* MTU set with SIOCSLIFMTU */
531
532 #define IFF_VIRTUAL 0x2000000000 /* Cannot send/receive pkts */
533 #define IFF_DUPLICATE 0x4000000000 /* Local address in use */
534 #define IFF_IPMP 0x8000000000 /* IPMP IP interface */
535
536 ERRORS
537 EPERM Calling process has insufficient privileges.
538
539 ENXIO The lifr_name member of the lifreq structure
540 contains an invalid value.
541
542 For SIOCGLIFSRCOF, the lifs_ifindex member of
543 the lifsrcof structure contains an invalid
544 value.
545
546 For SIOCSLIFUSESRC, this error is returned if
547 the lifr_index is set to an invalid value.
548
549 EBADADDR Wrong address family or malformed address.
550
551 EBUSY For SIOCSLIFFLAGS, this error is returned when
552 the order of bringing the physical interface
553 (for example, eri0) and a logical interface
554 associated with the same physical interface
555 (for example, eri0:1) up or down is violated.
556 The physical interface must be configured up
557 first and cannot be configured down until all
558 the corresponding logical interfaces have been
559 configured down.
560
561 EINVAL For SIOCSLIFMTU, this error is returned when
562 the requested MTU size is invalid. This error
563 indicates the MTU size is greater than the MTU
564 size supported by the DLPI provider or less
565 than 68 (for IPv4) or less than 1280 (for
566 IPv6).
567
568 For SIOCSLIFUSESRC, this error is returned if
569 either the lifr_index or lifr_name identify
570 interfaces that are already part of an existing
571 IPMP group.
572
573 SunOS 5.10 Last change: 14 Nov 2008 11
574
575 Protocols if_tcp(7P)
576
577 EEXIST For SIOCLIFADDIF, this error is returned if the
578 lifr_name member in the lifreq structure
579 corresponds to an interface that already has
580 the PPA specified by lifr_ppa plumbed.
581
582 SEE ALSO
583 ifconfig(1M), in.routed(1M), ioctl(2), streamio(7I),
584 arp(7P), dlpi(7P), ip(7P), ip6(7P)
585