if_ether.h 3.9 KB

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