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