if_ether.h 4.0 KB

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