xref: /original-bsd/sys/net/if_dl.h (revision 3705696b)
1 /*
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)if_dl.h	8.1 (Berkeley) 06/10/93
8  */
9 
10 /*
11  * A Link-Level Sockaddr may specify the interface in one of two
12  * ways: either by means of a system-provided index number (computed
13  * anew and possibly differently on every reboot), or by a human-readable
14  * string such as "il0" (for managerial convenience).
15  *
16  * Census taking actions, such as something akin to SIOCGCONF would return
17  * both the index and the human name.
18  *
19  * High volume transactions (such as giving a link-level ``from'' address
20  * in a recvfrom or recvmsg call) may be likely only to provide the indexed
21  * form, (which requires fewer copy operations and less space).
22  *
23  * The form and interpretation  of the link-level address is purely a matter
24  * of convention between the device driver and its consumers; however, it is
25  * expected that all drivers for an interface of a given if_type will agree.
26  */
27 
28 /*
29  * Structure of a Link-Level sockaddr:
30  */
31 struct sockaddr_dl {
32 	u_char	sdl_len;	/* Total length of sockaddr */
33 	u_char	sdl_family;	/* AF_DLI */
34 	u_short	sdl_index;	/* if != 0, system given index for interface */
35 	u_char	sdl_type;	/* interface type */
36 	u_char	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
37 	u_char	sdl_alen;	/* link level address length */
38 	u_char	sdl_slen;	/* link layer selector length */
39 	char	sdl_data[12];	/* minimum work area, can be larger;
40 				   contains both if name and ll address */
41 };
42 
43 #define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
44 
45 #ifndef KERNEL
46 
47 #include <sys/cdefs.h>
48 
49 __BEGIN_DECLS
50 void	link_addr __P((const char *, struct sockaddr_dl *));
51 char	*link_ntoa __P((const struct sockaddr_dl *));
52 __END_DECLS
53 
54 #endif /* !KERNEL */
55