1139823Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 2910938Swollman * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 3050477Speter * $FreeBSD$ 311541Srgrimes */ 321541Srgrimes 332169Spaul#ifndef _NETINET_IF_ETHER_H_ 342169Spaul#define _NETINET_IF_ETHER_H_ 352169Spaul 3617455Sphk#include <net/ethernet.h> 3720330Swollman#include <net/if_arp.h> 381541Srgrimes 391541Srgrimes/* 401541Srgrimes * Macro to map an IP multicast address to an Ethernet multicast address. 411541Srgrimes * The high-order 25 bits of the Ethernet address are statically assigned, 421541Srgrimes * and the low-order 23 bits are taken from the low end of the IP address. 431541Srgrimes */ 441541Srgrimes#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ 451541Srgrimes /* struct in_addr *ipaddr; */ \ 4617455Sphk /* u_char enaddr[ETHER_ADDR_LEN]; */ \ 471541Srgrimes{ \ 481541Srgrimes (enaddr)[0] = 0x01; \ 491541Srgrimes (enaddr)[1] = 0x00; \ 501541Srgrimes (enaddr)[2] = 0x5e; \ 51249925Sglebius (enaddr)[3] = ((const u_char *)ipaddr)[1] & 0x7f; \ 52249925Sglebius (enaddr)[4] = ((const u_char *)ipaddr)[2]; \ 53249925Sglebius (enaddr)[5] = ((const u_char *)ipaddr)[3]; \ 541541Srgrimes} 5552904Sshin/* 5652904Sshin * Macro to map an IP6 multicast address to an Ethernet multicast address. 5752904Sshin * The high-order 16 bits of the Ethernet address are statically assigned, 5852904Sshin * and the low-order 32 bits are taken from the low end of the IP6 address. 5952904Sshin */ 6052904Sshin#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ 6152904Sshin/* struct in6_addr *ip6addr; */ \ 6252904Sshin/* u_char enaddr[ETHER_ADDR_LEN]; */ \ 6352904Sshin{ \ 6452904Sshin (enaddr)[0] = 0x33; \ 6552904Sshin (enaddr)[1] = 0x33; \ 66249925Sglebius (enaddr)[2] = ((const u_char *)ip6addr)[12]; \ 67249925Sglebius (enaddr)[3] = ((const u_char *)ip6addr)[13]; \ 68249925Sglebius (enaddr)[4] = ((const u_char *)ip6addr)[14]; \ 69249925Sglebius (enaddr)[5] = ((const u_char *)ip6addr)[15]; \ 7052904Sshin} 711541Srgrimes 721541Srgrimes/* 731541Srgrimes * Ethernet Address Resolution Protocol. 741541Srgrimes * 751541Srgrimes * See RFC 826 for protocol description. Structure below is adapted 768876Srgrimes * to resolving internet addresses. Field names used correspond to 771541Srgrimes * RFC 826. 781541Srgrimes */ 791541Srgrimesstruct ether_arp { 801541Srgrimes struct arphdr ea_hdr; /* fixed-size header */ 8117455Sphk u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ 821541Srgrimes u_char arp_spa[4]; /* sender protocol address */ 8317455Sphk u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ 841541Srgrimes u_char arp_tpa[4]; /* target protocol address */ 851541Srgrimes}; 861541Srgrimes#define arp_hrd ea_hdr.ar_hrd 871541Srgrimes#define arp_pro ea_hdr.ar_pro 881541Srgrimes#define arp_hln ea_hdr.ar_hln 891541Srgrimes#define arp_pln ea_hdr.ar_pln 901541Srgrimes#define arp_op ea_hdr.ar_op 911541Srgrimes 92246143Sglebius#ifndef BURN_BRIDGES /* Can be used by third party software. */ 931541Srgrimesstruct sockaddr_inarp { 941541Srgrimes u_char sin_len; 951541Srgrimes u_char sin_family; 961541Srgrimes u_short sin_port; 971541Srgrimes struct in_addr sin_addr; 981541Srgrimes struct in_addr sin_srcaddr; 991541Srgrimes u_short sin_tos; 1001541Srgrimes u_short sin_other; 1011541Srgrimes#define SIN_PROXY 1 1021541Srgrimes}; 103246143Sglebius#endif /* !BURN_BRIDGES */ 104246143Sglebius 1051541Srgrimes/* 1061541Srgrimes * IP and ethernet specific routing flags 1071541Srgrimes */ 1081541Srgrimes#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */ 1091541Srgrimes#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */ 1101541Srgrimes 11155205Speter#ifdef _KERNEL 11217455Sphkextern u_char ether_ipmulticast_min[ETHER_ADDR_LEN]; 11317455Sphkextern u_char ether_ipmulticast_max[ETHER_ADDR_LEN]; 1141541Srgrimes 115186119Sqinglistruct llentry; 116188672Sluigistruct ifaddr; 117186119Sqingli 118249925Sglebiusint arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m, 119249925Sglebius const struct sockaddr *dst, u_char *desten, struct llentry **lle); 120249925Sglebiusvoid arprequest(struct ifnet *, const struct in_addr *, 121249925Sglebius const struct in_addr *, u_char *); 12292723Salfredvoid arp_ifinit(struct ifnet *, struct ifaddr *); 123142215Sglebiusvoid arp_ifinit2(struct ifnet *, struct ifaddr *, u_char *); 124228571Sglebiusvoid arp_ifscrub(struct ifnet *, uint32_t); 1251541Srgrimes#endif 1262169Spaul 1272169Spaul#endif 128