/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1990, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#ifndef _NET_IF_DL_H_32#define _NET_IF_DL_H_3334#include <sys/_types.h>3536/*37* A Link-Level Sockaddr may specify the interface in one of two38* ways: either by means of a system-provided index number (computed39* anew and possibly differently on every reboot), or by a human-readable40* string such as "il0" (for managerial convenience).41*42* Census taking actions, such as something akin to SIOCGCONF would return43* both the index and the human name.44*45* High volume transactions (such as giving a link-level ``from'' address46* in a recvfrom or recvmsg call) may be likely only to provide the indexed47* form, (which requires fewer copy operations and less space).48*49* The form and interpretation of the link-level address is purely a matter50* of convention between the device driver and its consumers; however, it is51* expected that all drivers for an interface of a given if_type will agree.52*/5354/*55* Structure of a Link-Level sockaddr:56*/57struct sockaddr_dl {58u_char sdl_len; /* Total length of sockaddr */59u_char sdl_family; /* AF_LINK */60u_short sdl_index; /* if != 0, system given index for interface */61u_char sdl_type; /* interface type */62u_char sdl_nlen; /* interface name length, no trailing 0 reqd. */63u_char sdl_alen; /* link level address length */64u_char sdl_slen; /* link layer selector length */65char sdl_data[46]; /* minimum work area, can be larger;66contains both if name and ll address */67};6869#define LLADDR(s) (&(s)->sdl_data[(s)->sdl_nlen])70#define LLINDEX(s) ((s)->sdl_index)7172#ifdef _KERNEL7374struct ifnet;75struct sockaddr_dl *link_alloc_sdl(size_t size, int flags);76void link_free_sdl(struct sockaddr *sa);77struct sockaddr_dl *link_init_sdl(struct ifnet *ifp, struct sockaddr *paddr,78u_char iftypes);7980#else /* !_KERNEL */8182#include <sys/cdefs.h>8384__BEGIN_DECLS85int link_addr(const char *, struct sockaddr_dl *);86char *link_ntoa(const struct sockaddr_dl *);87int link_ntoa_r(const struct sockaddr_dl *, char *, size_t *);88__END_DECLS8990#endif /* !_KERNEL */9192#endif939495