if_ether.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Copyright (C) 1996, 1997 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 Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. 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. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 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. * 3. All advertising materials mentioning features or use of this software
  35. * must display the following acknowledgement:
  36. * This product includes software developed by the University of
  37. * California, Berkeley and its contributors.
  38. * 4. Neither the name of the University nor the names of its contributors
  39. * may be used to endorse or promote products derived from this software
  40. * without specific prior written permission.
  41. *
  42. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  43. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  44. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  45. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  46. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  47. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  48. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  50. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  51. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  52. * SUCH DAMAGE.
  53. *
  54. * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
  55. * $FreeBSD$
  56. */
  57. #include <net/ethernet.h>
  58. #include <net/if_arp.h>
  59. __BEGIN_DECLS
  60. /*
  61. * Ethernet Address Resolution Protocol.
  62. *
  63. * See RFC 826 for protocol description. Structure below is adapted
  64. * to resolving internet addresses. Field names used correspond to
  65. * RFC 826.
  66. */
  67. struct ether_arp {
  68. struct arphdr ea_hdr; /* fixed-size header */
  69. u_int8_t arp_sha[ETH_ALEN]; /* sender hardware address */
  70. u_int8_t arp_spa[4]; /* sender protocol address */
  71. u_int8_t arp_tha[ETH_ALEN]; /* target hardware address */
  72. u_int8_t arp_tpa[4]; /* target protocol address */
  73. };
  74. #define arp_hrd ea_hdr.ar_hrd
  75. #define arp_pro ea_hdr.ar_pro
  76. #define arp_hln ea_hdr.ar_hln
  77. #define arp_pln ea_hdr.ar_pln
  78. #define arp_op ea_hdr.ar_op
  79. /*
  80. * Macro to map an IP multicast address to an Ethernet multicast address.
  81. * The high-order 25 bits of the Ethernet address are statically assigned,
  82. * and the low-order 23 bits are taken from the low end of the IP address.
  83. */
  84. #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
  85. /* struct in_addr *ipaddr; */ \
  86. /* u_char enaddr[ETH_ALEN]; */ \
  87. { \
  88. (enaddr)[0] = 0x01; \
  89. (enaddr)[1] = 0x00; \
  90. (enaddr)[2] = 0x5e; \
  91. (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \
  92. (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \
  93. (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \
  94. }
  95. __END_DECLS
  96. #endif /* __USE_BSD */
  97. #endif /* netinet/if_ether.h */