1a50ffc2imp/*-
24736ccfpfg * SPDX-License-Identifier: BSD-3-Clause
34736ccfpfg *
48fb65cergrimes * Copyright (c) 1990, 1993
58fb65cergrimes *	The Regents of the University of California.  All rights reserved.
68fb65cergrimes *
78fb65cergrimes * Redistribution and use in source and binary forms, with or without
88fb65cergrimes * modification, are permitted provided that the following conditions
98fb65cergrimes * are met:
108fb65cergrimes * 1. Redistributions of source code must retain the above copyright
118fb65cergrimes *    notice, this list of conditions and the following disclaimer.
128fb65cergrimes * 2. Redistributions in binary form must reproduce the above copyright
138fb65cergrimes *    notice, this list of conditions and the following disclaimer in the
148fb65cergrimes *    documentation and/or other materials provided with the distribution.
157e6cabdimp * 3. Neither the name of the University nor the names of its contributors
168fb65cergrimes *    may be used to endorse or promote products derived from this software
178fb65cergrimes *    without specific prior written permission.
188fb65cergrimes *
198fb65cergrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208fb65cergrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218fb65cergrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228fb65cergrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238fb65cergrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248fb65cergrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258fb65cergrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268fb65cergrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278fb65cergrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288fb65cergrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298fb65cergrimes * SUCH DAMAGE.
308fb65cergrimes *
318fb65cergrimes *	@(#)if_dl.h	8.1 (Berkeley) 6/10/93
323b842d3peter * $FreeBSD$
338fb65cergrimes */
348fb65cergrimes
35be1bed5paul#ifndef _NET_IF_DL_H_
36be1bed5paul#define _NET_IF_DL_H_
37be1bed5paul
38c86f0c7rgrimes/*
398fb65cergrimes * A Link-Level Sockaddr may specify the interface in one of two
408fb65cergrimes * ways: either by means of a system-provided index number (computed
418fb65cergrimes * anew and possibly differently on every reboot), or by a human-readable
428fb65cergrimes * string such as "il0" (for managerial convenience).
43c86f0c7rgrimes *
448fb65cergrimes * Census taking actions, such as something akin to SIOCGCONF would return
458fb65cergrimes * both the index and the human name.
46c86f0c7rgrimes *
478fb65cergrimes * High volume transactions (such as giving a link-level ``from'' address
488fb65cergrimes * in a recvfrom or recvmsg call) may be likely only to provide the indexed
498fb65cergrimes * form, (which requires fewer copy operations and less space).
50c86f0c7rgrimes *
518fb65cergrimes * The form and interpretation  of the link-level address is purely a matter
528fb65cergrimes * of convention between the device driver and its consumers; however, it is
538fb65cergrimes * expected that all drivers for an interface of a given if_type will agree.
548fb65cergrimes */
558fb65cergrimes
568fb65cergrimes/*
578fb65cergrimes * Structure of a Link-Level sockaddr:
588fb65cergrimes */
598fb65cergrimesstruct sockaddr_dl {
608fb65cergrimes	u_char	sdl_len;	/* Total length of sockaddr */
6108f912aarchie	u_char	sdl_family;	/* AF_LINK */
628fb65cergrimes	u_short	sdl_index;	/* if != 0, system given index for interface */
638fb65cergrimes	u_char	sdl_type;	/* interface type */
648fb65cergrimes	u_char	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
658fb65cergrimes	u_char	sdl_alen;	/* link level address length */
668fb65cergrimes	u_char	sdl_slen;	/* link layer selector length */
67cc607e6kbyanc	char	sdl_data[46];	/* minimum work area, can be larger;
688fb65cergrimes				   contains both if name and ll address */
698fb65cergrimes};
708fb65cergrimes
718fb65cergrimes#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
72bbab608melifaro#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen))
73434c53cmarcel#define LLINDEX(s) ((s)->sdl_index)
748fb65cergrimes
75881c9e2melifaro
76881c9e2melifarostruct ifnet;
77881c9e2melifarostruct sockaddr_dl *link_alloc_sdl(size_t, int);
78881c9e2melifarovoid link_free_sdl(struct sockaddr *sa);
79881c9e2melifarostruct sockaddr_dl *link_init_sdl(struct ifnet *, struct sockaddr *, u_char);
80881c9e2melifaro
8115b9bcbpeter#ifndef _KERNEL
828fb65cergrimes
838fb65cergrimes#include <sys/cdefs.h>
848fb65cergrimes
858fb65cergrimes__BEGIN_DECLS
86c998551alfredvoid	link_addr(const char *, struct sockaddr_dl *);
87c998551alfredchar	*link_ntoa(const struct sockaddr_dl *);
888fb65cergrimes__END_DECLS
898fb65cergrimes
9015b9bcbpeter#endif /* !_KERNEL */
91be1bed5paul
92be1bed5paul#endif
93