nhrp_protocol.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* nhrp_protocol.h - NHRP protocol definitions
  2. *
  3. * Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi>
  4. *
  5. * This software is licensed under the MIT License.
  6. * See MIT-LICENSE.txt for additional details.
  7. */
  8. #ifndef NHRP_PROTOCOL_H
  9. #define NHRP_PROTOCOL_H
  10. #include <stdint.h>
  11. /* NHRP Ethernet protocol number */
  12. #define ETH_P_NHRP 0x2001
  13. /* NHRP Version */
  14. #define NHRP_VERSION_RFC2332 1
  15. /* NHRP Packet Types */
  16. #define NHRP_PACKET_RESOLUTION_REQUEST 1
  17. #define NHRP_PACKET_RESOLUTION_REPLY 2
  18. #define NHRP_PACKET_REGISTRATION_REQUEST 3
  19. #define NHRP_PACKET_REGISTRATION_REPLY 4
  20. #define NHRP_PACKET_PURGE_REQUEST 5
  21. #define NHRP_PACKET_PURGE_REPLY 6
  22. #define NHRP_PACKET_ERROR_INDICATION 7
  23. #define NHRP_PACKET_TRAFFIC_INDICATION 8
  24. /* NHRP Extension Types */
  25. #define NHRP_EXTENSION_FLAG_COMPULSORY 0x8000
  26. #define NHRP_EXTENSION_END 0
  27. #define NHRP_EXTENSION_PAYLOAD 0
  28. #define NHRP_EXTENSION_RESPONDER_ADDRESS 3
  29. #define NHRP_EXTENSION_FORWARD_TRANSIT_NHS 4
  30. #define NHRP_EXTENSION_REVERSE_TRANSIT_NHS 5
  31. #define NHRP_EXTENSION_AUTHENTICATION 7
  32. #define NHRP_EXTENSION_VENDOR 8
  33. #define NHRP_EXTENSION_NAT_ADDRESS 9
  34. /* NHRP Error Indication Codes */
  35. #define NHRP_ERROR_UNRECOGNIZED_EXTENSION 1
  36. #define NHRP_ERROR_LOOP_DETECTED 2
  37. #define NHRP_ERROR_PROTOCOL_ADDRESS_UNREACHABLE 6
  38. #define NHRP_ERROR_PROTOCOL_ERROR 7
  39. #define NHRP_ERROR_SDU_SIZE_EXCEEDED 8
  40. #define NHRP_ERROR_INVALID_EXTENSION 9
  41. #define NHRP_ERROR_INVALID_RESOLUTION_REPLY 10
  42. #define NHRP_ERROR_AUTHENTICATION_FAILURE 11
  43. #define NHRP_ERROR_HOP_COUNT_EXCEEDED 15
  44. /* NHRP CIE Codes */
  45. #define NHRP_CODE_SUCCESS 0
  46. #define NHRP_CODE_ADMINISTRATIVELY_PROHIBITED 4
  47. #define NHRP_CODE_INSUFFICIENT_RESOURCES 5
  48. #define NHRP_CODE_NO_BINDING_EXISTS 11
  49. #define NHRP_CODE_BINDING_NON_UNIQUE 13
  50. #define NHRP_CODE_UNIQUE_ADDRESS_REGISTERED 14
  51. /* NHRP Flags for Resolution request/reply */
  52. #define NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER 0x8000
  53. #define NHRP_FLAG_RESOLUTION_AUTHORATIVE 0x4000
  54. #define NHRP_FLAG_RESOLUTION_DESTINATION_STABLE 0x2000
  55. #define NHRP_FLAG_RESOLUTION_UNIQUE 0x1000
  56. #define NHRP_FLAG_RESOLUTION_SOURCE_STABLE 0x0800
  57. #define NHRP_FLAG_RESOLUTION_NAT 0x0002
  58. /* NHRP Flags for Registration request/reply */
  59. #define NHRP_FLAG_REGISTRATION_UNIQUE 0x8000
  60. #define NHRP_FLAG_REGISTRATION_NAT 0x0002
  61. /* NHRP Flags for Purge request/reply */
  62. #define NHRP_FLAG_PURGE_NO_REPLY 0x8000
  63. /* NHRP Authentication extension types (ala Cisco) */
  64. #define NHRP_AUTHENTICATION_PLAINTEXT 0x00000001
  65. /* NHRP Packet Structures */
  66. struct nhrp_packet_header {
  67. /* Fixed header */
  68. uint16_t afnum;
  69. uint16_t protocol_type;
  70. uint8_t snap[5];
  71. uint8_t hop_count;
  72. uint16_t packet_size;
  73. uint16_t checksum;
  74. uint16_t extension_offset;
  75. uint8_t version;
  76. uint8_t type;
  77. uint8_t src_nbma_address_len;
  78. uint8_t src_nbma_subaddress_len;
  79. /* Mandatory header */
  80. uint8_t src_protocol_address_len;
  81. uint8_t dst_protocol_address_len;
  82. uint16_t flags;
  83. union {
  84. uint32_t request_id;
  85. struct {
  86. uint16_t code;
  87. uint16_t offset;
  88. } error;
  89. } u;
  90. } __attribute__((packed));
  91. struct nhrp_cie_header {
  92. uint8_t code;
  93. uint8_t prefix_length;
  94. uint16_t unused;
  95. uint16_t mtu;
  96. uint16_t holding_time;
  97. uint8_t nbma_address_len;
  98. uint8_t nbma_subaddress_len;
  99. uint8_t protocol_address_len;
  100. uint8_t preference;
  101. } __attribute__((packed));
  102. struct nhrp_extension_header {
  103. uint16_t type;
  104. uint16_t length;
  105. } __attribute__((packed));
  106. struct nhrp_cisco_authentication_extension {
  107. uint32_t type;
  108. uint8_t secret[8];
  109. } __attribute__((packed));
  110. #endif