ethernet.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2011 by Qualcomm Atheros.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software
  6. * for any purpose with or without fee is hereby granted, provided
  7. * that the above copyright notice and this permission notice appear
  8. * in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  13. * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  14. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  15. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  16. * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  17. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. *--------------------------------------------------------------------*/
  20. /*====================================================================*
  21. *
  22. * ethernet.h - substitute net/ethernet.h for systems without one;
  23. *
  24. *. Intellon INT6000 Linux Toolkit for HomePlug AV;
  25. *: Published 2006-2009 by Intellon Corp. ALL RIGHTS RESERVED;
  26. *; For demonstration; Not for production use;
  27. *
  28. *--------------------------------------------------------------------*/
  29. #ifndef ETHERNET_HEADER
  30. #define ETHERNET_HEADER
  31. /*====================================================================*
  32. * system header files;
  33. *--------------------------------------------------------------------*/
  34. #include <stdint.h>
  35. /*====================================================================*
  36. * Ethernet frame lengths;
  37. *--------------------------------------------------------------------*/
  38. #define ETHER_ADDR_LEN 6
  39. #define ETHER_TYPE_LEN 2
  40. #define ETHER_CRC_LEN 4
  41. #define ETHER_HDR_LEN (ETHER_ADDR_LEN + ETHER_ADDR_LEN + ETHER_TYPE_LEN)
  42. #define ETHER_MIN_LEN 64
  43. #define ETHER_MAX_LEN 1518
  44. #define ETHERMTU 1500
  45. #define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
  46. /*====================================================================*
  47. * Ethernet type/length field values;
  48. *--------------------------------------------------------------------*/
  49. #define ETHERTYPE_PUP 0x0200
  50. #define ETHERTYPE_IP 0x0800
  51. #define ETHERTYPE_ARP 0x0806
  52. #define ETHERTYPE_REVARP 0x8035
  53. #define ETHERTYPE_VLAN 0x8100
  54. #define ETHERTYPE_IPV6 0x86dd
  55. #define ETHERTYPE_LOOPBACK 0x9000
  56. #define ETHERTYPE_HP10 0x887B
  57. #define ETHERTYPE_HPAV 0x88E1
  58. /*====================================================================*
  59. * Ethernet frame structure;
  60. *--------------------------------------------------------------------*/
  61. #pragma pack (push, 1)
  62. struct ether_header
  63. {
  64. uint8_t ether_dhost [ETHER_ADDR_LEN];
  65. uint8_t ether_shost [ETHER_ADDR_LEN];
  66. uint16_t ether_type;
  67. };
  68. #pragma pack (pop)
  69. /*====================================================================*
  70. *
  71. *--------------------------------------------------------------------*/
  72. #endif