ethernet.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef TINC_ETHERNET_H
  2. #define TINC_ETHERNET_H
  3. /*
  4. ethernet.h -- missing Ethernet related definitions
  5. Copyright (C) 2005 Ivo Timmermans
  6. 2006 Guus Sliepen <guus@tinc-vpn.org>
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License along
  16. with this program; if not, write to the Free Software Foundation, Inc.,
  17. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. #ifndef ETH_ALEN
  20. #define ETH_ALEN 6
  21. #endif
  22. #ifndef ARPHRD_ETHER
  23. #define ARPHRD_ETHER 1
  24. #endif
  25. #ifndef ETH_P_IP
  26. #define ETH_P_IP 0x0800
  27. #endif
  28. #ifndef ETH_P_ARP
  29. #define ETH_P_ARP 0x0806
  30. #endif
  31. #ifndef ETH_P_IPV6
  32. #define ETH_P_IPV6 0x86DD
  33. #endif
  34. #ifndef ETH_P_8021Q
  35. #define ETH_P_8021Q 0x8100
  36. #endif
  37. #ifndef HAVE_STRUCT_ETHER_HEADER
  38. struct ether_header {
  39. uint8_t ether_dhost[ETH_ALEN];
  40. uint8_t ether_shost[ETH_ALEN];
  41. uint16_t ether_type;
  42. } __attribute__((__packed__));
  43. #endif
  44. #ifndef HAVE_STRUCT_ARPHDR
  45. struct arphdr {
  46. uint16_t ar_hrd;
  47. uint16_t ar_pro;
  48. uint8_t ar_hln;
  49. uint8_t ar_pln;
  50. uint16_t ar_op;
  51. } __attribute__((__packed__));
  52. #define ARPOP_REQUEST 1
  53. #define ARPOP_REPLY 2
  54. #define ARPOP_RREQUEST 3
  55. #define ARPOP_RREPLY 4
  56. #define ARPOP_InREQUEST 8
  57. #define ARPOP_InREPLY 9
  58. #define ARPOP_NAK 10
  59. #endif
  60. #ifndef HAVE_STRUCT_ETHER_ARP
  61. struct ether_arp {
  62. struct arphdr ea_hdr;
  63. uint8_t arp_sha[ETH_ALEN];
  64. uint8_t arp_spa[4];
  65. uint8_t arp_tha[ETH_ALEN];
  66. uint8_t arp_tpa[4];
  67. } __attribute__((__packed__));
  68. #define arp_hrd ea_hdr.ar_hrd
  69. #define arp_pro ea_hdr.ar_pro
  70. #define arp_hln ea_hdr.ar_hln
  71. #define arp_pln ea_hdr.ar_pln
  72. #define arp_op ea_hdr.ar_op
  73. #endif
  74. #endif