1/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef __NETINET_IF_ETHER_H
19
20#define __NETINET_IF_ETHER_H 1
21#include <features.h>
22#include <sys/types.h>
23
24/* Get definitions from kernel header file. */
25#include <linux/if_ether.h>
26
27#ifdef __USE_MISC
28/*
29 * Copyright (c) 1982, 1986, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 *
56 * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
57 * $FreeBSD$
58 */
59
60#include <net/ethernet.h>
61#include <net/if_arp.h>
62
63__BEGIN_DECLS
64/*
65 * Ethernet Address Resolution Protocol.
66 *
67 * See RFC 826 for protocol description. Structure below is adapted
68 * to resolving internet addresses. Field names used correspond to
69 * RFC 826.
70 */
71struct ether_arp {
72 struct arphdr ea_hdr; /* fixed-size header */
73 uint8_t arp_sha[ETH_ALEN]; /* sender hardware address */
74 uint8_t arp_spa[4]; /* sender protocol address */
75 uint8_t arp_tha[ETH_ALEN]; /* target hardware address */
76 uint8_t arp_tpa[4]; /* target protocol address */
77};
78#define arp_hrd ea_hdr.ar_hrd
79#define arp_pro ea_hdr.ar_pro
80#define arp_hln ea_hdr.ar_hln
81#define arp_pln ea_hdr.ar_pln
82#define arp_op ea_hdr.ar_op
83
84/*
85 * Macro to map an IP multicast address to an Ethernet multicast address.
86 * The high-order 25 bits of the Ethernet address are statically assigned,
87 * and the low-order 23 bits are taken from the low end of the IP address.
88 */
89#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
90 /* struct in_addr *ipaddr; */ \
91 /* uint8_t enaddr[ETH_ALEN]; */ \
92{ \
93 (enaddr)[0] = 0x01; \
94 (enaddr)[1] = 0x00; \
95 (enaddr)[2] = 0x5e; \
96 (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
97 (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
98 (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
99}
100
101__END_DECLS
102#endif /* __USE_MISC */
103
104#endif /* netinet/if_ether.h */
105

source code of include/netinet/if_ether.h