xref: /illumos-gate/usr/src/uts/common/net/if_dl.h (revision 1a1df1dbef1b5c57672433301a296dfe4311e6db)
1 /*
2  * Copyright 1993-2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 /*
6  * Copyright (c) 1990, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by the University of
20  *	California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  */
37 
38 #ifndef	_NET_IF_DL_H
39 #define	_NET_IF_DL_H
40 
41 /* from UCB 8.1 (Berkeley) 6/10/93 */
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * A Link-Level Sockaddr may specify the interface in one of two
49  * ways: either by means of a system-provided index number (computed
50  * anew and possibly differently on every reboot), or by a human-readable
51  * string such as "il0" (for managerial convenience).
52  *
53  * Census taking actions, such as something akin to SIOCGCONF would return
54  * both the index and the human name.
55  *
56  * High volume transactions (such as giving a link-level ``from'' address
57  * in a recvfrom or recvmsg call) may be likely only to provide the indexed
58  * form, (which requires fewer copy operations and less space).
59  *
60  * The form and interpretation  of the link-level address is purely a matter
61  * of convention between the device driver and its consumers; however, it is
62  * expected that all drivers for an interface of a given if_type will agree.
63  */
64 
65 /*
66  * Structure of a Link-Level sockaddr:
67  */
68 struct sockaddr_dl {
69 	ushort_t sdl_family;	/* AF_LINK */
70 	ushort_t sdl_index;	/* if != 0, system given index for interface */
71 	uchar_t	sdl_type;	/* interface type */
72 	uchar_t	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
73 	uchar_t	sdl_alen;	/* link level address length */
74 	uchar_t	sdl_slen;	/* link layer selector length */
75 	char	sdl_data[244];	/* contains both if name and ll address */
76 };
77 
78 #define	LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
79 
80 #ifdef	__STDC__
81 extern char *_link_ntoa(const unsigned char *, char *, int, int);
82 extern unsigned char *_link_aton(const char *, int *);
83 #else	/* __STDC__ */
84 extern char *_link_ntoa();
85 extern unsigned char *_link_aton();
86 #endif	/* __STDC__ */
87 
88 #ifdef	__cplusplus
89 }
90 #endif
91 
92 #endif	/* _NET_IF_DL_H */
93