diff options
Diffstat (limited to 'src/mesh/mesh_protocol.h')
-rw-r--r-- | src/mesh/mesh_protocol.h | 358 |
1 files changed, 257 insertions, 101 deletions
diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h index 2d708eb62..c36fa9f93 100644 --- a/src/mesh/mesh_protocol.h +++ b/src/mesh/mesh_protocol.h | |||
@@ -26,7 +26,13 @@ | |||
26 | #ifndef MESH_PROTOCOL_H_ | 26 | #ifndef MESH_PROTOCOL_H_ |
27 | #define MESH_PROTOCOL_H_ | 27 | #define MESH_PROTOCOL_H_ |
28 | 28 | ||
29 | #include "platform.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "mesh.h" | ||
32 | |||
29 | #ifdef __cplusplus | 33 | #ifdef __cplusplus |
34 | |||
35 | struct GNUNET_MESH_TunnelMessage; | ||
30 | extern "C" | 36 | extern "C" |
31 | { | 37 | { |
32 | #if 0 | 38 | #if 0 |
@@ -42,225 +48,375 @@ extern "C" | |||
42 | GNUNET_NETWORK_STRUCT_BEGIN | 48 | GNUNET_NETWORK_STRUCT_BEGIN |
43 | 49 | ||
44 | /** | 50 | /** |
45 | * Message for mesh path creation. | 51 | * Message for mesh connection creation. |
52 | * TODO onionify path, add random tunnel ID | ||
46 | */ | 53 | */ |
47 | struct GNUNET_MESH_CreateTunnel | 54 | struct GNUNET_MESH_ConnectionCreate |
48 | { | 55 | { |
49 | /** | 56 | /** |
50 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE | 57 | * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE |
51 | * | 58 | * |
52 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + | 59 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + |
53 | * path_length * sizeof (struct GNUNET_PeerIdentity) | 60 | * path_length * sizeof (struct GNUNET_PeerIdentity) |
54 | */ | 61 | */ |
55 | struct GNUNET_MessageHeader header; | 62 | struct GNUNET_MessageHeader header; |
56 | 63 | ||
57 | /** | 64 | /** |
58 | * Global id of the tunnel this path belongs to, | 65 | * ID of the connection |
59 | * unique in conjunction with the origin. | ||
60 | */ | ||
61 | uint32_t tid GNUNET_PACKED; | ||
62 | |||
63 | /** | ||
64 | * Tunnel options (GNUNET_MESH_OPTION_*). | ||
65 | */ | ||
66 | uint32_t opt GNUNET_PACKED; | ||
67 | |||
68 | /** | ||
69 | * Destination port. | ||
70 | */ | 66 | */ |
71 | uint32_t port GNUNET_PACKED; | 67 | struct GNUNET_HashCode cid; |
72 | 68 | ||
73 | /** | 69 | /** |
74 | * FIXME do not add the first hop | ||
75 | * path_length structs defining the *whole* path from the origin [0] to the | 70 | * path_length structs defining the *whole* path from the origin [0] to the |
76 | * final destination [path_length-1]. | 71 | * final destination [path_length-1]. |
77 | */ | 72 | */ |
78 | /* struct GNUNET_PeerIdentity peers[path_length]; */ | 73 | /* struct GNUNET_PeerIdentity peers[path_length]; */ |
79 | }; | 74 | }; |
80 | 75 | ||
81 | |||
82 | /** | 76 | /** |
83 | * Message for mesh data traffic. | 77 | * Message for ack'ing a connection |
84 | */ | 78 | */ |
85 | struct GNUNET_MESH_Data | 79 | struct GNUNET_MESH_ConnectionACK |
86 | { | 80 | { |
87 | /** | 81 | /** |
88 | * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST, | 82 | * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK |
89 | * GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN | ||
90 | */ | 83 | */ |
91 | struct GNUNET_MessageHeader header; | 84 | struct GNUNET_MessageHeader header; |
92 | 85 | ||
93 | /** | 86 | /** |
94 | * TID of the tunnel | 87 | * Always 0. |
95 | */ | 88 | */ |
96 | uint32_t tid GNUNET_PACKED; | 89 | uint32_t reserved GNUNET_PACKED; |
97 | 90 | ||
98 | /** | 91 | /** |
99 | * Number of hops to live | 92 | * ID of the connection. |
100 | */ | 93 | */ |
101 | uint32_t ttl GNUNET_PACKED; | 94 | struct GNUNET_HashCode cid; |
95 | |||
96 | /* TODO: signature */ | ||
97 | }; | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Message for encapsulation of a Key eXchange message in a connection. | ||
102 | */ | ||
103 | struct GNUNET_MESH_KX | ||
104 | { | ||
105 | /** | ||
106 | * Type: GNUNET_MESSAGE_TYPE_MESH_KX. | ||
107 | */ | ||
108 | struct GNUNET_MessageHeader header; | ||
102 | 109 | ||
103 | /** | 110 | /** |
104 | * ID of the packet | 111 | * Always 0. |
105 | */ | 112 | */ |
106 | uint32_t pid GNUNET_PACKED; | 113 | uint32_t reserved GNUNET_PACKED; |
107 | 114 | ||
108 | /** | 115 | /** |
109 | * OID of the tunnel | 116 | * ID of the connection. |
110 | */ | 117 | */ |
111 | struct GNUNET_PeerIdentity oid; | 118 | struct GNUNET_HashCode cid; |
119 | |||
120 | /* Specific KX message follows. */ | ||
121 | }; | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Message transmitted with the signed ephemeral key of a peer. The | ||
126 | * session key is then derived from the two ephemeral keys (ECDHE). | ||
127 | * | ||
128 | * As far as possible, same as CORE's EphemeralKeyMessage. | ||
129 | */ | ||
130 | struct GNUNET_MESH_KX_Ephemeral | ||
131 | { | ||
112 | 132 | ||
113 | /** | 133 | /** |
114 | * Unique ID of the payload message | 134 | * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL. |
115 | */ | 135 | */ |
116 | uint32_t mid GNUNET_PACKED; | 136 | struct GNUNET_MessageHeader header; |
117 | 137 | ||
118 | /** | 138 | /** |
119 | * Payload follows | 139 | * Status of the sender (should be in "enum PeerStateMachine"), nbo. |
120 | */ | 140 | */ |
141 | int32_t sender_status GNUNET_PACKED; | ||
142 | |||
143 | /** | ||
144 | * An ECC signature of the 'origin' asserting the validity of | ||
145 | * the given ephemeral key. | ||
146 | */ | ||
147 | struct GNUNET_CRYPTO_EddsaSignature signature; | ||
148 | |||
149 | /** | ||
150 | * Information about what is being signed. | ||
151 | */ | ||
152 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
153 | |||
154 | /** | ||
155 | * At what time was this key created (beginning of validity). | ||
156 | */ | ||
157 | struct GNUNET_TIME_AbsoluteNBO creation_time; | ||
158 | |||
159 | /** | ||
160 | * When does the given ephemeral key expire (end of validity). | ||
161 | */ | ||
162 | struct GNUNET_TIME_AbsoluteNBO expiration_time; | ||
163 | |||
164 | /** | ||
165 | * Ephemeral public ECC key (always for NIST P-521) encoded in a format suitable | ||
166 | * for network transmission as created using 'gcry_sexp_sprint'. | ||
167 | */ | ||
168 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key; | ||
169 | |||
170 | /** | ||
171 | * Public key of the signing peer (persistent version, not the ephemeral public key). | ||
172 | */ | ||
173 | struct GNUNET_PeerIdentity origin_identity; | ||
121 | }; | 174 | }; |
122 | 175 | ||
123 | 176 | ||
124 | /** | 177 | /** |
125 | * Message to acknowledge end-to-end data. | 178 | * We're sending an (encrypted) PING to the other peer to check if he |
179 | * can decrypt. The other peer should respond with a PONG with the | ||
180 | * same content, except this time encrypted with the receiver's key. | ||
126 | */ | 181 | */ |
127 | struct GNUNET_MESH_DataACK | 182 | struct GNUNET_MESH_KX_Ping |
128 | { | 183 | { |
129 | /** | 184 | /** |
130 | * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK | 185 | * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_PING. |
131 | */ | 186 | */ |
132 | struct GNUNET_MessageHeader header; | 187 | struct GNUNET_MessageHeader header; |
133 | 188 | ||
134 | /** | 189 | /** |
135 | * TID of the tunnel | 190 | * Seed for the IV |
136 | */ | 191 | */ |
137 | uint32_t tid GNUNET_PACKED; | 192 | uint32_t iv GNUNET_PACKED; |
138 | 193 | ||
139 | /** | 194 | /** |
140 | * OID of the tunnel | 195 | * Intended target of the PING, used primarily to check |
196 | * that decryption actually worked. | ||
141 | */ | 197 | */ |
142 | struct GNUNET_PeerIdentity oid; | 198 | struct GNUNET_PeerIdentity target; |
143 | 199 | ||
144 | /** | 200 | /** |
145 | * Bitfield of already-received newer messages | 201 | * Random number chosen to make reply harder. |
146 | * pid + 1 @ LSB | ||
147 | * pid + 64 @ MSB | ||
148 | */ | 202 | */ |
149 | uint64_t futures GNUNET_PACKED; | 203 | uint32_t nonce GNUNET_PACKED; |
204 | }; | ||
205 | |||
150 | 206 | ||
207 | /** | ||
208 | * Response to a PING. Includes data from the original PING. | ||
209 | */ | ||
210 | struct GNUNET_MESH_KX_Pong | ||
211 | { | ||
151 | /** | 212 | /** |
152 | * Last message ID received. | 213 | * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_PONG. |
153 | */ | 214 | */ |
154 | uint32_t mid GNUNET_PACKED; | 215 | struct GNUNET_MessageHeader header; |
216 | |||
217 | /** | ||
218 | * Seed for the IV | ||
219 | */ | ||
220 | uint32_t iv GNUNET_PACKED; | ||
221 | |||
222 | /** | ||
223 | * Same nonce as in the reve. | ||
224 | */ | ||
225 | uint32_t nonce GNUNET_PACKED; | ||
155 | }; | 226 | }; |
156 | 227 | ||
157 | 228 | ||
158 | /** | 229 | /** |
159 | * Message to acknowledge mesh data traffic. | 230 | * Tunnel(ed) message. |
160 | */ | 231 | */ |
161 | struct GNUNET_MESH_ACK | 232 | struct GNUNET_MESH_Encrypted |
233 | { | ||
234 | /** | ||
235 | * Type: GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED | ||
236 | */ | ||
237 | struct GNUNET_MessageHeader header; | ||
238 | |||
239 | /** | ||
240 | * Initialization Vector for payload encryption. | ||
241 | */ | ||
242 | uint32_t iv GNUNET_PACKED; | ||
243 | |||
244 | /** | ||
245 | * ID of the connection. | ||
246 | */ | ||
247 | struct GNUNET_HashCode cid; | ||
248 | |||
249 | /** | ||
250 | * ID of the packet (hop by hop). | ||
251 | */ | ||
252 | uint32_t pid GNUNET_PACKED; | ||
253 | |||
254 | /** | ||
255 | * Number of hops to live. | ||
256 | */ | ||
257 | uint32_t ttl GNUNET_PACKED; | ||
258 | |||
259 | /** | ||
260 | * Encrypted content follows. | ||
261 | */ | ||
262 | }; | ||
263 | |||
264 | struct GNUNET_MESH_ChannelCreate | ||
265 | { | ||
266 | /** | ||
267 | * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE | ||
268 | */ | ||
269 | struct GNUNET_MessageHeader header; | ||
270 | |||
271 | /** | ||
272 | * ID of the channel | ||
273 | */ | ||
274 | MESH_ChannelNumber chid GNUNET_PACKED; | ||
275 | |||
276 | /** | ||
277 | * Destination port. | ||
278 | */ | ||
279 | uint32_t port GNUNET_PACKED; | ||
280 | |||
281 | /** | ||
282 | * Channel options. | ||
283 | */ | ||
284 | uint32_t opt GNUNET_PACKED; | ||
285 | }; | ||
286 | |||
287 | struct GNUNET_MESH_ChannelManage | ||
288 | { | ||
289 | /** | ||
290 | * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_{ACK|NACK|DESTROY} | ||
291 | */ | ||
292 | struct GNUNET_MessageHeader header; | ||
293 | |||
294 | /** | ||
295 | * ID of the channel | ||
296 | */ | ||
297 | MESH_ChannelNumber chid GNUNET_PACKED; | ||
298 | }; | ||
299 | |||
300 | /** | ||
301 | * Message for mesh data traffic. | ||
302 | */ | ||
303 | struct GNUNET_MESH_Data | ||
162 | { | 304 | { |
163 | /** | 305 | /** |
164 | * Type: GNUNET_MESSAGE_TYPE_MESH_ACK | 306 | * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST, |
307 | * GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN | ||
165 | */ | 308 | */ |
166 | struct GNUNET_MessageHeader header; | 309 | struct GNUNET_MessageHeader header; |
167 | 310 | ||
168 | /** | 311 | /** |
169 | * TID of the tunnel | 312 | * Unique ID of the payload message |
170 | */ | 313 | */ |
171 | uint32_t tid GNUNET_PACKED; | 314 | uint32_t mid GNUNET_PACKED; |
172 | 315 | ||
173 | /** | 316 | /** |
174 | * OID of the tunnel | 317 | * ID of the channel |
175 | */ | 318 | */ |
176 | struct GNUNET_PeerIdentity oid; | 319 | MESH_ChannelNumber chid GNUNET_PACKED; |
177 | 320 | ||
178 | /** | 321 | /** |
179 | * Maximum packet ID authorized. | 322 | * Payload follows |
180 | */ | 323 | */ |
181 | uint32_t pid GNUNET_PACKED; | ||
182 | }; | 324 | }; |
183 | 325 | ||
184 | 326 | ||
185 | /** | 327 | /** |
186 | * Message to query a peer about its Flow Control status regarding a tunnel. | 328 | * Message to acknowledge end-to-end data. |
187 | */ | 329 | */ |
188 | struct GNUNET_MESH_Poll | 330 | struct GNUNET_MESH_DataACK |
189 | { | 331 | { |
190 | /** | 332 | /** |
191 | * Type: GNUNET_MESSAGE_TYPE_MESH_POLL | 333 | * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK |
192 | */ | 334 | */ |
193 | struct GNUNET_MessageHeader header; | 335 | struct GNUNET_MessageHeader header; |
194 | 336 | ||
195 | /** | 337 | /** |
196 | * TID of the tunnel | 338 | * ID of the channel |
197 | */ | 339 | */ |
198 | uint32_t tid GNUNET_PACKED; | 340 | MESH_ChannelNumber chid GNUNET_PACKED; |
199 | 341 | ||
200 | /** | 342 | /** |
201 | * OID of the tunnel | 343 | * Bitfield of already-received newer messages |
344 | * pid + 1 @ LSB | ||
345 | * pid + 64 @ MSB | ||
202 | */ | 346 | */ |
203 | struct GNUNET_PeerIdentity oid; | 347 | uint64_t futures GNUNET_PACKED; |
204 | 348 | ||
205 | /** | 349 | /** |
206 | * Last packet sent. | 350 | * Last message ID received. |
207 | */ | 351 | */ |
208 | uint32_t pid GNUNET_PACKED; | 352 | uint32_t mid GNUNET_PACKED; |
209 | }; | 353 | }; |
210 | 354 | ||
355 | |||
211 | /** | 356 | /** |
212 | * Message for ack'ing a path | 357 | * Message to acknowledge mesh encrypted traffic. |
213 | */ | 358 | */ |
214 | struct GNUNET_MESH_PathACK | 359 | struct GNUNET_MESH_ACK |
215 | { | 360 | { |
216 | /** | 361 | /** |
217 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK | 362 | * Type: GNUNET_MESSAGE_TYPE_MESH_ACK |
218 | */ | 363 | */ |
219 | struct GNUNET_MessageHeader header; | 364 | struct GNUNET_MessageHeader header; |
220 | 365 | ||
221 | /** | 366 | /** |
222 | * TID of the tunnel | 367 | * Maximum packet ID authorized. |
223 | */ | 368 | */ |
224 | uint32_t tid GNUNET_PACKED; | 369 | uint32_t ack GNUNET_PACKED; |
225 | 370 | ||
226 | /** | 371 | /** |
227 | * OID of the tunnel | 372 | * ID of the connection. |
228 | */ | 373 | */ |
229 | struct GNUNET_PeerIdentity oid; | 374 | struct GNUNET_HashCode cid; |
375 | }; | ||
230 | 376 | ||
231 | /** | 377 | |
232 | * ID of the endpoint | 378 | /** |
233 | */ | 379 | * Message to query a peer about its Flow Control status regarding a tunnel. |
234 | struct GNUNET_PeerIdentity peer_id; | 380 | */ |
381 | struct GNUNET_MESH_Poll | ||
382 | { | ||
383 | /** | ||
384 | * Type: GNUNET_MESSAGE_TYPE_MESH_POLL | ||
385 | */ | ||
386 | struct GNUNET_MessageHeader header; | ||
387 | |||
388 | /** | ||
389 | * Last packet sent. | ||
390 | */ | ||
391 | uint32_t pid GNUNET_PACKED; | ||
235 | 392 | ||
236 | /** | 393 | /** |
237 | * Initial ACK value for payload. | 394 | * ID of the connection. |
238 | */ | 395 | */ |
239 | uint32_t ack GNUNET_PACKED; | 396 | struct GNUNET_HashCode cid; |
240 | 397 | ||
241 | /* TODO: signature */ | ||
242 | }; | 398 | }; |
243 | 399 | ||
244 | 400 | ||
245 | /** | 401 | /** |
246 | * Message for notifying a disconnection in a path | 402 | * Message for notifying a disconnection in a path |
247 | */ | 403 | */ |
248 | struct GNUNET_MESH_PathBroken | 404 | struct GNUNET_MESH_ConnectionBroken |
249 | { | 405 | { |
250 | /** | 406 | /** |
251 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN | 407 | * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN |
252 | */ | 408 | */ |
253 | struct GNUNET_MessageHeader header; | 409 | struct GNUNET_MessageHeader header; |
254 | 410 | ||
255 | /** | 411 | /** |
256 | * TID of the tunnel | 412 | * Always 0. |
257 | */ | 413 | */ |
258 | uint32_t tid GNUNET_PACKED; | 414 | uint32_t reserved GNUNET_PACKED; |
259 | 415 | ||
260 | /** | 416 | /** |
261 | * OID of the tunnel | 417 | * ID of the connection. |
262 | */ | 418 | */ |
263 | struct GNUNET_PeerIdentity oid; | 419 | struct GNUNET_HashCode cid; |
264 | 420 | ||
265 | /** | 421 | /** |
266 | * ID of the endpoint | 422 | * ID of the endpoint |
@@ -277,48 +433,48 @@ struct GNUNET_MESH_PathBroken | |||
277 | 433 | ||
278 | 434 | ||
279 | /** | 435 | /** |
280 | * Message to destroy a tunnel | 436 | * Message to destroy a connection. |
281 | */ | 437 | */ |
282 | struct GNUNET_MESH_TunnelDestroy | 438 | struct GNUNET_MESH_ConnectionDestroy |
283 | { | 439 | { |
284 | /** | 440 | /** |
285 | * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY | 441 | * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY |
286 | */ | 442 | */ |
287 | struct GNUNET_MessageHeader header; | 443 | struct GNUNET_MessageHeader header; |
288 | 444 | ||
289 | /** | 445 | /** |
290 | * TID of the tunnel | 446 | * Always 0. |
291 | */ | 447 | */ |
292 | uint32_t tid GNUNET_PACKED; | 448 | uint32_t reserved GNUNET_PACKED; |
293 | 449 | ||
294 | /** | 450 | /** |
295 | * OID of the tunnel | 451 | * ID of the connection. |
296 | */ | 452 | */ |
297 | struct GNUNET_PeerIdentity oid; | 453 | struct GNUNET_HashCode cid; |
298 | 454 | ||
299 | /* TODO: signature */ | 455 | /* TODO: signature */ |
300 | }; | 456 | }; |
301 | 457 | ||
302 | 458 | ||
303 | /** | 459 | /** |
304 | * Message to destroy a tunnel | 460 | * Message to keep a connection alive. |
305 | */ | 461 | */ |
306 | struct GNUNET_MESH_TunnelKeepAlive | 462 | struct GNUNET_MESH_ConnectionKeepAlive |
307 | { | 463 | { |
308 | /** | 464 | /** |
309 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_(FWD|BCK)_KEEPALIVE | 465 | * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE |
310 | */ | 466 | */ |
311 | struct GNUNET_MessageHeader header; | 467 | struct GNUNET_MessageHeader header; |
312 | 468 | ||
313 | /** | 469 | /** |
314 | * TID of the tunnel | 470 | * Always 0. |
315 | */ | 471 | */ |
316 | uint32_t tid GNUNET_PACKED; | 472 | uint32_t reserved GNUNET_PACKED; |
317 | 473 | ||
318 | /** | 474 | /** |
319 | * OID of the tunnel | 475 | * ID of the connection. |
320 | */ | 476 | */ |
321 | struct GNUNET_PeerIdentity oid; | 477 | struct GNUNET_HashCode cid; |
322 | }; | 478 | }; |
323 | 479 | ||
324 | 480 | ||