NDPHeader.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program 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
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef NDPHeader_H
  16. #define NDPHeader_H
  17. #include "util/Assert.h"
  18. #include "util/Endian.h"
  19. #include <stdint.h>
  20. struct NDPHeader_NeighborSolicitation {
  21. uint8_t oneThirtyFive;
  22. uint8_t zero;
  23. uint16_t checksum;
  24. uint32_t reserved;
  25. uint8_t targetAddr[16];
  26. };
  27. #define NDPHeader_NeighborSolicitation_SIZE 24
  28. Assert_compileTime(
  29. sizeof(struct NDPHeader_NeighborSolicitation) == NDPHeader_NeighborSolicitation_SIZE);
  30. struct NDPHeader_RouterSolicitation {
  31. uint8_t oneThirtyThree;
  32. uint8_t zero;
  33. uint16_t checksum;
  34. uint32_t reserved;
  35. };
  36. #define NDPHeader_RouterSolicitation_SIZE 8
  37. Assert_compileTime(
  38. sizeof(struct NDPHeader_RouterSolicitation) == NDPHeader_RouterSolicitation_SIZE);
  39. struct NDPHeader_NeighborAdvert {
  40. uint8_t oneThirtySix;
  41. uint8_t zero;
  42. uint16_t checksum;
  43. uint8_t bits;
  44. uint8_t reserved[3];
  45. uint8_t targetAddr[16];
  46. };
  47. #define NDPHeader_NeighborAdvert_SIZE 24
  48. Assert_compileTime(sizeof(struct NDPHeader_NeighborAdvert) == NDPHeader_NeighborAdvert_SIZE);
  49. #define NDPHeader_NeighborAdvert_bits_ROUTER (1<<7)
  50. #define NDPHeader_NeighborAdvert_bits_SOLICITED (1<<6)
  51. #define NDPHeader_NeighborAdvert_bits_OVERRIDE (1<<5)
  52. struct NDPHeader_NeighborAdvert_MacOpt {
  53. uint8_t two; // type
  54. uint8_t one; // length in 8 byte increments
  55. uint8_t mac[6];
  56. };
  57. #define NDPHeader_NeighborAdvert_MacOpt_SIZE 8
  58. Assert_compileTime(
  59. sizeof(struct NDPHeader_NeighborAdvert_MacOpt) == NDPHeader_NeighborAdvert_MacOpt_SIZE);
  60. struct NDPHeader_RouterAdvert {
  61. uint8_t oneThirtyFour;
  62. uint8_t zero;
  63. uint16_t checksum;
  64. uint8_t currentHopLimit;
  65. uint8_t bits;
  66. uint16_t routerLifetime_be;
  67. uint32_t reachableTime_be;
  68. uint32_t retransTime_be;
  69. };
  70. #define NDPHeader_RouterAdvert_SIZE 16
  71. Assert_compileTime(sizeof(struct NDPHeader_RouterAdvert) == NDPHeader_RouterAdvert_SIZE);
  72. #define NDPHeader_RouterAdvert_bits_ADDRS_AVAILABLE (1<<7)
  73. #define NDPHeader_RouterAdvert_bits_OTHER_INFO_AVAILABLE (1<<6)
  74. struct NDPHeader_RouterAdvert_PrefixOpt {
  75. uint8_t three; // type
  76. uint8_t four; // length
  77. uint8_t prefixLen;
  78. uint8_t bits;
  79. uint32_t validLifetimeSeconds_be;
  80. uint32_t preferredLifetimeSeconds_be;
  81. uint32_t reservedTwo;
  82. uint8_t prefix[16];
  83. };
  84. #define NDPHeader_RouterAdvert_PrefixOpt_bits_ONLINK (1<<7)
  85. #define NDPHeader_RouterAdvert_PrefixOpt_bits_ADDRCONF (1<<6)
  86. #define NDPHeader_RouterAdvert_PrefixOpt_SIZE 32
  87. Assert_compileTime(
  88. sizeof(struct NDPHeader_RouterAdvert_PrefixOpt) == NDPHeader_RouterAdvert_PrefixOpt_SIZE);
  89. #endif