/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1982, 1986, 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 _NETINET_IF_ETHER_H_32#define _NETINET_IF_ETHER_H_3334#include <net/ethernet.h>35#include <net/if_arp.h>3637/*38* Macro to map an IP multicast address to an Ethernet multicast address.39* The high-order 25 bits of the Ethernet address are statically assigned,40* and the low-order 23 bits are taken from the low end of the IP address.41*/42#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \43/* struct in_addr *ipaddr; */ \44/* u_char enaddr[ETHER_ADDR_LEN]; */ \45{ \46(enaddr)[0] = 0x01; \47(enaddr)[1] = 0x00; \48(enaddr)[2] = 0x5e; \49(enaddr)[3] = ((const u_char *)ipaddr)[1] & 0x7f; \50(enaddr)[4] = ((const u_char *)ipaddr)[2]; \51(enaddr)[5] = ((const u_char *)ipaddr)[3]; \52}53/*54* Macro to map an IP6 multicast address to an Ethernet multicast address.55* The high-order 16 bits of the Ethernet address are statically assigned,56* and the low-order 32 bits are taken from the low end of the IP6 address.57*/58#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \59/* struct in6_addr *ip6addr; */ \60/* u_char enaddr[ETHER_ADDR_LEN]; */ \61{ \62(enaddr)[0] = 0x33; \63(enaddr)[1] = 0x33; \64(enaddr)[2] = ((const u_char *)ip6addr)[12]; \65(enaddr)[3] = ((const u_char *)ip6addr)[13]; \66(enaddr)[4] = ((const u_char *)ip6addr)[14]; \67(enaddr)[5] = ((const u_char *)ip6addr)[15]; \68}6970/*71* Ethernet Address Resolution Protocol.72*73* See RFC 826 for protocol description. Structure below is adapted74* to resolving internet addresses. Field names used correspond to75* RFC 826.76*/77struct ether_arp {78struct arphdr ea_hdr; /* fixed-size header */79u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */80u_char arp_spa[4]; /* sender protocol address */81u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */82u_char arp_tpa[4]; /* target protocol address */83};84#define arp_hrd ea_hdr.ar_hrd85#define arp_pro ea_hdr.ar_pro86#define arp_hln ea_hdr.ar_hln87#define arp_pln ea_hdr.ar_pln88#define arp_op ea_hdr.ar_op8990#ifndef BURN_BRIDGES /* Can be used by third party software. */91struct sockaddr_inarp {92u_char sin_len;93u_char sin_family;94u_short sin_port;95struct in_addr sin_addr;96struct in_addr sin_srcaddr;97u_short sin_tos;98u_short sin_other;99#define SIN_PROXY 1100};101#endif /* !BURN_BRIDGES */102103/*104* IP and ethernet specific routing flags105*/106#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */107#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */108109#ifdef _KERNEL110extern u_char ether_ipmulticast_min[ETHER_ADDR_LEN];111extern u_char ether_ipmulticast_max[ETHER_ADDR_LEN];112113struct ifaddr;114struct llentry;115116int arpresolve(struct ifnet *ifp, int is_gw, struct mbuf *m,117const struct sockaddr *dst, u_char *desten, uint32_t *pflags,118struct llentry **plle);119void arprequest(struct ifnet *, const struct in_addr *,120const struct in_addr *, u_char *);121void arp_ifinit(struct ifnet *, struct ifaddr *);122void arp_announce_ifaddr(struct ifnet *, struct in_addr addr, u_char *);123#endif124125#endif126127128