diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-04-06 17:27:25 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-04-06 17:27:25 +0000 |
commit | 78821fe96de53ff40851c11cf2134654a0b63640 (patch) | |
tree | 1dfecd3050c4b62488c295e3bdbb8a702cce5723 /src/mesh/gnunet-service-mesh.c | |
parent | ba830bbe8fe27e46ac748a2e02bdc7dfeb1f3b5c (diff) | |
download | gnunet-78821fe96de53ff40851c11cf2134654a0b63640.tar.gz gnunet-78821fe96de53ff40851c11cf2134654a0b63640.zip |
New mesh API
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 100 |
1 files changed, 69 insertions, 31 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index fce2d1406..6725db563 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "platform.h" | 34 | #include "platform.h" |
35 | #include "gnunet_common.h" | 35 | #include "gnunet_common.h" |
36 | #include "gnunet_util_lib.h" | 36 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_peer_lib.h" | ||
37 | #include "gnunet_core_service.h" | 38 | #include "gnunet_core_service.h" |
38 | #include "gnunet_protocols.h" | 39 | #include "gnunet_protocols.h" |
39 | #include "mesh.h" | 40 | #include "mesh.h" |
@@ -56,7 +57,7 @@ struct GNUNET_MESH_ManipulatePath | |||
56 | struct GNUNET_MessageHeader header; | 57 | struct GNUNET_MessageHeader header; |
57 | 58 | ||
58 | /** | 59 | /** |
59 | * Id of the tunnel this path belongs to, unique in conjunction with the origin. | 60 | * (global) Id of the tunnel this path belongs to, unique in conjunction with the origin. |
60 | */ | 61 | */ |
61 | uint32_t tid GNUNET_PACKED; | 62 | uint32_t tid GNUNET_PACKED; |
62 | 63 | ||
@@ -67,6 +68,11 @@ struct GNUNET_MESH_ManipulatePath | |||
67 | uint32_t speed_min GNUNET_PACKED; | 68 | uint32_t speed_min GNUNET_PACKED; |
68 | 69 | ||
69 | /** | 70 | /** |
71 | * 64-bit alignment. | ||
72 | */ | ||
73 | uint32_t reserved GNUNET_PACKED; | ||
74 | |||
75 | /** | ||
70 | * path_length structs defining the *whole* path from the origin [0] to the | 76 | * path_length structs defining the *whole* path from the origin [0] to the |
71 | * final destination [path_length-1]. | 77 | * final destination [path_length-1]. |
72 | */ | 78 | */ |
@@ -94,11 +100,6 @@ struct GNUNET_MESH_OriginMulticast | |||
94 | struct GNUNET_PeerIdentity oid; | 100 | struct GNUNET_PeerIdentity oid; |
95 | 101 | ||
96 | /** | 102 | /** |
97 | * FIXME: Some form of authentication | ||
98 | */ | ||
99 | // uint32_t token; | ||
100 | |||
101 | /** | ||
102 | * Payload follows | 103 | * Payload follows |
103 | */ | 104 | */ |
104 | }; | 105 | }; |
@@ -130,11 +131,6 @@ struct GNUNET_MESH_DataMessageFromOrigin | |||
130 | struct GNUNET_PeerIdentity destination; | 131 | struct GNUNET_PeerIdentity destination; |
131 | 132 | ||
132 | /** | 133 | /** |
133 | * FIXME: Some form of authentication | ||
134 | */ | ||
135 | // uint32_t token; | ||
136 | |||
137 | /** | ||
138 | * Payload follows | 134 | * Payload follows |
139 | */ | 135 | */ |
140 | }; | 136 | }; |
@@ -166,11 +162,6 @@ struct GNUNET_MESH_DataMessageToOrigin | |||
166 | struct GNUNET_PeerIdentity sender; | 162 | struct GNUNET_PeerIdentity sender; |
167 | 163 | ||
168 | /** | 164 | /** |
169 | * FIXME: Some form of authentication | ||
170 | */ | ||
171 | // uint32_t token; | ||
172 | |||
173 | /** | ||
174 | * Payload follows | 165 | * Payload follows |
175 | */ | 166 | */ |
176 | }; | 167 | }; |
@@ -240,7 +231,7 @@ struct PeerInfo | |||
240 | /** | 231 | /** |
241 | * ID of the peer | 232 | * ID of the peer |
242 | */ | 233 | */ |
243 | struct GNUNET_PeerIdentity id; | 234 | GNUNET_PEER_Id id; |
244 | 235 | ||
245 | /** | 236 | /** |
246 | * Is the peer reachable? Is the peer even connected? | 237 | * Is the peer reachable? Is the peer even connected? |
@@ -248,9 +239,9 @@ struct PeerInfo | |||
248 | enum PeerState state; | 239 | enum PeerState state; |
249 | 240 | ||
250 | /** | 241 | /** |
251 | * Who to send the data to | 242 | * Who to send the data to --- what about multiple (alternate) paths? |
252 | */ | 243 | */ |
253 | uint32_t first_hop; | 244 | GNUNET_PEER_Id first_hop; |
254 | 245 | ||
255 | /** | 246 | /** |
256 | * Max data rate to this peer | 247 | * Max data rate to this peer |
@@ -276,7 +267,7 @@ struct Path | |||
276 | /** | 267 | /** |
277 | * List of all the peers that form the path from origin to target | 268 | * List of all the peers that form the path from origin to target |
278 | */ | 269 | */ |
279 | struct PeerInfo *peers; | 270 | GNUNET_PEER_Id *peers; |
280 | }; | 271 | }; |
281 | 272 | ||
282 | /** | 273 | /** |
@@ -290,10 +281,15 @@ struct Path | |||
290 | */ | 281 | */ |
291 | struct MESH_tunnel | 282 | struct MESH_tunnel |
292 | { | 283 | { |
284 | |||
285 | struct MESH_tunnel *next; | ||
286 | |||
287 | struct MESH_tunnel *prev; | ||
288 | |||
293 | /** | 289 | /** |
294 | * Origin ID: Node that created the tunnel | 290 | * Origin ID: Node that created the tunnel |
295 | */ | 291 | */ |
296 | struct GNUNET_PeerIdentity oid; | 292 | GNUNET_PEER_Id oid; |
297 | 293 | ||
298 | /** | 294 | /** |
299 | * Tunnel number (unique for a given oid) | 295 | * Tunnel number (unique for a given oid) |
@@ -301,7 +297,7 @@ struct MESH_tunnel | |||
301 | uint32_t tid; | 297 | uint32_t tid; |
302 | 298 | ||
303 | /** | 299 | /** |
304 | * Whether the tunnel is in state to transmit data | 300 | * Whether the tunnel is in a state to transmit data |
305 | */ | 301 | */ |
306 | int ready; | 302 | int ready; |
307 | 303 | ||
@@ -331,33 +327,53 @@ struct MESH_tunnel | |||
331 | struct Path *paths; | 327 | struct Path *paths; |
332 | 328 | ||
333 | /** | 329 | /** |
334 | * Messages ready to transmit | 330 | * Messages ready to transmit??? -- real queues needed |
335 | */ | 331 | */ |
336 | struct GNUNET_MessageHeader *msg_out; | 332 | struct GNUNET_MessageHeader *msg_out; |
337 | 333 | ||
338 | /** | 334 | /** |
339 | * Messages received and not processed | 335 | * Messages received and not processed??? -- real queues needed |
340 | */ | 336 | */ |
341 | struct GNUNET_MessageHeader *msg_in; | 337 | struct GNUNET_MessageHeader *msg_in; |
342 | 338 | ||
343 | /** | 339 | /** |
344 | * FIXME Clients. Is anyone to be notified for traffic here? | 340 | * If this tunnel was created by a local client, what's its handle? |
345 | */ | 341 | */ |
342 | struct GNUNET_SERVER_Client *initiator; | ||
346 | }; | 343 | }; |
347 | 344 | ||
348 | /** | 345 | /** |
349 | * So, I'm an endpoint. Why am I receiveing traffic? | 346 | * So, I'm an endpoint. Why am I receiveing traffic? |
350 | * Who is interested in this? How to communicate with them? | 347 | * Who is interested in this? How to communicate with them? |
351 | */ | 348 | */ |
352 | struct Clients | 349 | struct Client |
353 | { | 350 | { |
351 | |||
352 | struct Client *next; | ||
353 | |||
354 | struct Client *prev; | ||
355 | |||
356 | struct MESH_tunnel *my_tunnels_head; | ||
357 | |||
358 | struct MESH_tunnel *my_tunnels_tail; | ||
359 | |||
354 | /** | 360 | /** |
355 | * FIXME add structures needed to handle client connections | 361 | * If this tunnel was created by a local client, what's its handle? |
356 | */ | 362 | */ |
357 | int fixme; | 363 | struct GNUNET_SERVER_Client *handle; |
364 | |||
365 | unsigned int messages_subscribed_counter; | ||
366 | |||
367 | uint16_t *messages_subscribed; | ||
368 | |||
358 | }; | 369 | }; |
359 | 370 | ||
360 | 371 | ||
372 | static struct MESH_tunnel *tunnel_participation_head; | ||
373 | |||
374 | static struct MESH_tunnel *tunnel_participation_tail; | ||
375 | |||
376 | |||
361 | 377 | ||
362 | /******************************************************************************/ | 378 | /******************************************************************************/ |
363 | /******************** MESH NETWORK HANDLERS **************************/ | 379 | /******************** MESH NETWORK HANDLERS **************************/ |
@@ -382,6 +398,28 @@ handle_mesh_path_create (void *cls, | |||
382 | const struct GNUNET_TRANSPORT_ATS_Information | 398 | const struct GNUNET_TRANSPORT_ATS_Information |
383 | *atsi) | 399 | *atsi) |
384 | { | 400 | { |
401 | /* | ||
402 | * EXAMPLE OF USING THE API | ||
403 | * NOT ACTUAL CODE!!!!! | ||
404 | */ | ||
405 | /*client *c; | ||
406 | tunnel *t; | ||
407 | |||
408 | t = new; | ||
409 | GNUNET_CONTAINER_DLL_insert (c->my_tunnels_head, | ||
410 | c->my_tunnels_tail, | ||
411 | t); | ||
412 | |||
413 | while (NULL != (t = c->my_tunnels_head)) | ||
414 | { | ||
415 | GNUNET_CONTAINER_DLL_remove (c->my_tunnels_head, | ||
416 | c->my_tunnels_tail, | ||
417 | t); | ||
418 | GNUNET_free (t); | ||
419 | } | ||
420 | */ | ||
421 | |||
422 | |||
385 | /* Extract path */ | 423 | /* Extract path */ |
386 | /* Find origin & self */ | 424 | /* Find origin & self */ |
387 | /* Search for origin in local tunnels */ | 425 | /* Search for origin in local tunnels */ |
@@ -515,8 +553,8 @@ static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { | |||
515 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, | 553 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, |
516 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, | 554 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, |
517 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, | 555 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, |
518 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, sizeof(struct GNUNET_MESH_Control)}, | 556 | {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, 0}, |
519 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY, sizeof(struct GNUNET_MESH_Control)}, | 557 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY, 0}, |
520 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, /* FIXME needed? */ | 558 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, /* FIXME needed? */ |
521 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST, 0}, /* FIXME needed? */ | 559 | {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST, 0}, /* FIXME needed? */ |
522 | {NULL, NULL, 0, 0} | 560 | {NULL, NULL, 0, 0} |
@@ -620,4 +658,4 @@ main (int argc, char *const *argv) | |||
620 | "mesh", | 658 | "mesh", |
621 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; | 659 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; |
622 | return ret; | 660 | return ret; |
623 | } \ No newline at end of file | 661 | } |