aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-06 17:27:25 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-06 17:27:25 +0000
commit78821fe96de53ff40851c11cf2134654a0b63640 (patch)
tree1dfecd3050c4b62488c295e3bdbb8a702cce5723 /src/mesh
parentba830bbe8fe27e46ac748a2e02bdc7dfeb1f3b5c (diff)
downloadgnunet-78821fe96de53ff40851c11cf2134654a0b63640.tar.gz
gnunet-78821fe96de53ff40851c11cf2134654a0b63640.zip
New mesh API
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c100
-rw-r--r--src/mesh/mesh.h102
2 files changed, 152 insertions, 50 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 */
291struct MESH_tunnel 282struct 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 */
352struct Clients 349struct 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
372static struct MESH_tunnel *tunnel_participation_head;
373
374static 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}
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index 2c260030d..a29c63f88 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -36,19 +36,20 @@
36/* API CALL MESSAGE USED 36/* API CALL MESSAGE USED
37 * -------- ------------ 37 * -------- ------------
38 * connect GNUNET_MESH_Connect 38 * connect GNUNET_MESH_Connect
39 * disconnect Server_disconnect 39 * disconnect None (network level disconnect)
40 *
41 * tunnel_create GNUNET_MESH_TunnelMessage
42 * tunnel_destroy GNUNET_MESH_TunnelMessage
40 * 43 *
41 * peer_request_connect_any GNUNET_MESH_ConnectPeer
42 * peer_request_connect_all GNUNET_MESH_ConnectPeer
43 * peer_request_connect_add GNUNET_MESH_ConnectPeer 44 * peer_request_connect_add GNUNET_MESH_ConnectPeer
44 * peer_request_connect_del GNUNET_MESH_ConnectPeer 45 * peer_request_connect_del GNUNET_MESH_ConnectPeer
45 * peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType 46 * peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType
46 * peer_request_connect_cancel GNUNET_MESH_Control
47 * 47 *
48 * notify_transmit_ready GNUNET_MESH_Control 48 * notify_transmit_ready GNUNET_MESH_Control
49 * notify_transmit_ready_cancel None 49 * notify_transmit_ready_cancel None
50 */ 50 */
51 51
52
52struct GNUNET_MESH_Connect { 53struct GNUNET_MESH_Connect {
53 /** 54 /**
54 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 55 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
@@ -60,74 +61,137 @@ struct GNUNET_MESH_Connect {
60 /* uint16_t messages_subscribed[] */ 61 /* uint16_t messages_subscribed[] */
61}; 62};
62 63
63struct GNUNET_MESH_ConnectPeer { 64
65/**
66 *
67 */
68struct GNUNET_MESH_TunnelMessage {
64 /** 69 /**
65 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ANY|ALL|ADD|DEL] 70 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
66 *
67 * Size: sizeof(struct GNUNET_MESH_ConnectPeer) + npeers * sizeof (struct GNUNET_PeerIdentity)
68 */ 71 */
69 struct GNUNET_MessageHeader header; 72 struct GNUNET_MessageHeader header;
70 73
71 /* struct GNUNET_PeerIdentity peers[] */ 74 /**
75 * ID of a tunnel controlled by this client.
76 */
77 uint32_t tunnel_id GNUNET_PACKED;
72}; 78};
73 79
80
81struct GNUNET_MESH_PeerControl {
82
83 /**
84 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL] (client to service, client created tunnel)
85 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOTIFY[CONNECT|DISCONNECT] (service to client)
86 *
87 * Size: sizeof(struct GNUNET_MESH_PeerControl)
88 */
89 struct GNUNET_MessageHeader header;
90
91 /**
92 * ID of a tunnel controlled by this client.
93 */
94 uint32_t tunnel_id GNUNET_PACKED;
95
96 /**
97 * Peer to connect/disconnect.
98 */
99 struct GNUNET_PeerIdentity peer;
100};
101
102
103
104
74struct GNUNET_MESH_ConnectPeerByType { 105struct GNUNET_MESH_ConnectPeerByType {
75 /** 106 /**
76 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE 107 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
77 */ 108 */
78 struct GNUNET_MessageHeader header; 109 struct GNUNET_MessageHeader header;
79 110
80 /* Type specification */ 111 /**
112 * ID of a tunnel controlled by this client.
113 */
114 uint32_t tunnel_id GNUNET_PACKED;
115
116 /**
117 * Type specification
118 */
81 GNUNET_MESH_ApplicationType type; 119 GNUNET_MESH_ApplicationType type;
82}; 120};
83 121
84struct GNUNET_MESH_Control { 122
123struct GNUNET_MESH_RequestTransmitReady {
85 /** 124 /**
86 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL 125 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY
87 * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY
88 */ 126 */
89 struct GNUNET_MessageHeader header; 127 struct GNUNET_MessageHeader header;
90 128
129 /**
130 * ID of a tunnel controlled by this client.
131 */
91 uint32_t tunnel_id GNUNET_PACKED; 132 uint32_t tunnel_id GNUNET_PACKED;
92 uint32_t variable GNUNET_PACKED; /* Size of data / connection ID */ 133
134 /**
135 * Size of message we would like to transmit to this tunnel
136 */
137 uint32_t msg_size GNUNET_PACKED;
93}; 138};
94 139
95struct GNUNET_MESH_TunnelEvent { 140struct GNUNET_MESH_NotifyTransmitReady {
96 /** 141 /**
97 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATED\DESTROYED] 142 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY
98 */ 143 */
99 struct GNUNET_MessageHeader header; 144 struct GNUNET_MessageHeader header;
100 145
146 /**
147 * ID of a tunnel controlled by this client.
148 */
101 uint32_t tunnel_id GNUNET_PACKED; 149 uint32_t tunnel_id GNUNET_PACKED;
102 uint32_t reason GNUNET_PACKED; /* incoming, connect, timeout, disconnect */ 150
151 /**
152 * Size of message we can now transmit to this tunnel
153 */
154 uint32_t msg_size GNUNET_PACKED;
103}; 155};
104 156
157
105struct GNUNET_MESH_Data { 158struct GNUNET_MESH_Data {
106 /** 159 /**
107 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 160 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA (client to service, or service to client)
108 * 161 *
109 * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data) 162 * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
110 */ 163 */
111 struct GNUNET_MessageHeader header; 164 struct GNUNET_MessageHeader header;
112 165
166 /**
167 * ID of a tunnel controlled by this client.
168 */
113 uint32_t tunnel_id GNUNET_PACKED; 169 uint32_t tunnel_id GNUNET_PACKED;
114 170
171 /**
172 * Source or destination of the message (depending on direction).
173 */
115 struct GNUNET_PeerIdentity destination; 174 struct GNUNET_PeerIdentity destination;
116 175
117 /* uint8_t data[] */ 176 /* uint8_t data[] */
118}; 177};
119 178
179
120struct GNUNET_MESH_DataBroadcast { 180struct GNUNET_MESH_DataBroadcast {
121 /** 181 /**
122 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST 182 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST (client to service only, client created tunnel)
123 * 183 *
124 * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data) 184 * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data)
125 */ 185 */
126 struct GNUNET_MessageHeader header; 186 struct GNUNET_MessageHeader header;
127 187
188 /**
189 * ID of a tunnel controlled by this client.
190 */
128 uint32_t tunnel_id GNUNET_PACKED; 191 uint32_t tunnel_id GNUNET_PACKED;
129 192
130 /* uint8_t data[] */ 193 /* uint8_t data[] */
131}; 194};
132 195
196
133#endif 197#endif