aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_mesh_service_new.h47
-rw-r--r--src/mesh/gnunet-service-mesh.c84
2 files changed, 74 insertions, 57 deletions
diff --git a/src/include/gnunet_mesh_service_new.h b/src/include/gnunet_mesh_service_new.h
index 4dd738327..3a0aa9507 100644
--- a/src/include/gnunet_mesh_service_new.h
+++ b/src/include/gnunet_mesh_service_new.h
@@ -73,7 +73,8 @@ typedef int
73 void **tunnel_ctx, 73 void **tunnel_ctx,
74 const struct GNUNET_PeerIdentity *sender, 74 const struct GNUNET_PeerIdentity *sender,
75 const struct GNUNET_MessageHeader *message, 75 const struct GNUNET_MessageHeader *message,
76 const struct GNUNET_TRANSPORT_ATS_Information *atsi); 76 const struct GNUNET_TRANSPORT_ATS_Information
77 *atsi);
77 78
78 79
79/** 80/**
@@ -108,10 +109,12 @@ struct GNUNET_MESH_MessageHandler
108 * 109 *
109 * @param cls closure (set from GNUNET_MESH_connect) 110 * @param cls closure (set from GNUNET_MESH_connect)
110 * @param tunnel connection to the other end (henceforth invalid) 111 * @param tunnel connection to the other end (henceforth invalid)
111 * @param tunnel_ctx place where local state associated with the tunnel is stored 112 * @param tunnel_ctx place where local state associated
113 * with the tunnel is stored
112 */ 114 */
113typedef void (GNUNET_MESH_TunnelEndHandler)(void *cls, 115typedef void (GNUNET_MESH_TunnelEndHandler)(void *cls,
114 const struct GNUNET_MESH_Tunnel *tunnel, 116 const struct GNUNET_MESH_Tunnel
117 *tunnel,
115 void **tunnel_ctx); 118 void **tunnel_ctx);
116 119
117 120
@@ -125,14 +128,15 @@ typedef uint32_t GNUNET_MESH_ApplicationType;
125 * Connect to the mesh service. 128 * Connect to the mesh service.
126 * 129 *
127 * @param cfg configuration to use 130 * @param cfg configuration to use
128 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 131 * @param cls closure for the various callbacks that follow
132 * (including handlers in the handlers array)
129 * @param cleaner function called when an *inbound* tunnel is destroyed 133 * @param cleaner function called when an *inbound* tunnel is destroyed
130 * @param handlers callbacks for messages we care about, NULL-terminated 134 * @param handlers callbacks for messages we care about, NULL-terminated
131 * note that the mesh is allowed to drop notifications about inbound 135 * note that the mesh is allowed to drop notifications about
132 * messages if the client does not process them fast enough (for this 136 * inbound messages if the client does not process them fast
133 * notification type, a bounded queue is used) 137 * enough (for this notification type, a bounded queue is used)
134 * @return handle to the mesh service 138 * @return handle to the mesh service NULL on error
135 * NULL on error (in this case, init is never called) 139 * (in this case, init is never called)
136 */ 140 */
137struct GNUNET_MESH_Handle * 141struct GNUNET_MESH_Handle *
138GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 142GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -157,7 +161,7 @@ void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle);
157 * @param peer peer identity the tunnel stopped working with 161 * @param peer peer identity the tunnel stopped working with
158 */ 162 */
159typedef void (*GNUNET_MESH_TunnelDisconnectHandler) (void *cls, 163typedef void (*GNUNET_MESH_TunnelDisconnectHandler) (void *cls,
160 const struct GNUNET_PeerIdentity *peer); 164 const struct GNUNET_PeerIdentity *peer);
161 165
162 166
163/** 167/**
@@ -168,14 +172,14 @@ typedef void (*GNUNET_MESH_TunnelDisconnectHandler) (void *cls,
168 * @param atsi performance data for the connection 172 * @param atsi performance data for the connection
169 */ 173 */
170typedef void (*GNUNET_MESH_TunnelConnectHandler) (void *cls, 174typedef void (*GNUNET_MESH_TunnelConnectHandler) (void *cls,
171 const struct GNUNET_PeerIdentity *peer, 175 const struct GNUNET_PeerIdentity *peer,
172 const struct GNUNET_TRANSPORT_ATS_Information *atsi); 176 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
173 177
174 178
175 179
176/** 180/**
177 * Create a new tunnel (we're initiator and will be allowed to add/remove peers and 181 * Create a new tunnel (we're initiator and will be allowed to add/remove peers
178 * to broadcast). 182 * and to broadcast).
179 * 183 *
180 * @param h mesh handle 184 * @param h mesh handle
181 * @param connect_handler function to call when peers are actually connected 185 * @param connect_handler function to call when peers are actually connected
@@ -184,9 +188,11 @@ typedef void (*GNUNET_MESH_TunnelConnectHandler) (void *cls,
184 */ 188 */
185struct GNUNET_MESH_Tunnel * 189struct GNUNET_MESH_Tunnel *
186GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, 190GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
187 GNUNET_MESH_TunnelConnectHandler connect_handler, 191 GNUNET_MESH_TunnelConnectHandler
188 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler, 192 connect_handler,
189 void *handler_cls); 193 GNUNET_MESH_TunnelDisconnectHandler
194 disconnect_handler,
195 void *handler_cls);
190 196
191/** 197/**
192 * Destroy an existing tunnel. 198 * Destroy an existing tunnel.
@@ -229,8 +235,8 @@ GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
229 * 235 *
230 * @param tunnel handle to existing tunnel 236 * @param tunnel handle to existing tunnel
231 * @param timeout how long to try to establish a connection 237 * @param timeout how long to try to establish a connection
232 * @param app_type application type that must be supported by the peer (MESH should 238 * @param app_type application type that must be supported by the peer
233 * discover peer in proximity handling this type) 239 * (MESH should discover peer in proximity handling this type)
234 */ 240 */
235void 241void
236GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel, 242GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
@@ -254,7 +260,8 @@ struct GNUNET_MESH_TransmitHandle;
254 * @param cork is corking allowed for this transmission? 260 * @param cork is corking allowed for this transmission?
255 * @param priority how important is the message? 261 * @param priority how important is the message?
256 * @param maxdelay how long can the message wait? 262 * @param maxdelay how long can the message wait?
257 * @param target destination for the message, NULL for multicast to all tunnel targets 263 * @param target destination for the message
264 * NULL for multicast to all tunnel targets
258 * @param notify_size how many bytes of buffer space does notify want? 265 * @param notify_size how many bytes of buffer space does notify want?
259 * @param notify function to call when buffer space is available; 266 * @param notify function to call when buffer space is available;
260 * will be called with NULL on timeout or if the overall queue 267 * will be called with NULL on timeout or if the overall queue
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 145807338..f6be64457 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -279,6 +279,7 @@ struct Path
279}; 279};
280 280
281 281
282struct Client; /* FWD declaration */
282/** 283/**
283 * Struct containing all information regarding a tunnel 284 * Struct containing all information regarding a tunnel
284 * For an intermediate node the improtant info used will be: 285 * For an intermediate node the improtant info used will be:
@@ -338,6 +339,11 @@ struct MESH_tunnel
338 struct Path *paths; 339 struct Path *paths;
339 340
340 /** 341 /**
342 * If this tunnel was created by a local client, what's its handle?
343 */
344 struct Client *client;
345
346 /**
341 * Messages ready to transmit??? -- FIXME real queues needed 347 * Messages ready to transmit??? -- FIXME real queues needed
342 */ 348 */
343 struct GNUNET_MessageHeader *msg_out; 349 struct GNUNET_MessageHeader *msg_out;
@@ -347,10 +353,6 @@ struct MESH_tunnel
347 */ 353 */
348 struct GNUNET_MessageHeader *msg_in; 354 struct GNUNET_MessageHeader *msg_in;
349 355
350 /**
351 * If this tunnel was created by a local client, what's its handle?
352 */
353 struct GNUNET_SERVER_Client *initiator;
354}; 356};
355 357
356/** 358/**
@@ -391,8 +393,8 @@ struct Client
391/** 393/**
392 * All the clients 394 * All the clients
393 */ 395 */
394// static struct Client clients_head; 396//static struct Client clients_head;
395// static struct Client clients_tail; 397//static struct Client clients_tail;
396 398
397/** 399/**
398 * All the tunnels 400 * All the tunnels
@@ -522,7 +524,20 @@ handle_local_new_client (void *cls,
522 struct GNUNET_SERVER_Client *client, 524 struct GNUNET_SERVER_Client *client,
523 const struct GNUNET_MessageHeader *message) 525 const struct GNUNET_MessageHeader *message)
524{ 526{
525 return; 527 struct Client *c;
528 c = GNUNET_malloc(sizeof(struct Client));
529 c->handle = client;
530 //c->messages_subscribed = message->;
531
532 /*client *c;
533 tunnel *t;
534
535 t = new;
536 GNUNET_CONTAINER_DLL_insert (c->my_tunnels_head,
537 c->my_tunnels_tail,
538 t);*/
539
540
526} 541}
527 542
528/** 543/**
@@ -558,29 +573,23 @@ handle_local_network_traffic (void *cls,
558/** 573/**
559 * Functions to handle messages from clients 574 * Functions to handle messages from clients
560 */ 575 */
561/* MESSAGES DEFINED:
562#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272
563#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ANY 273
564#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ALL 274
565#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD 275
566#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL 276
567#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE 277
568#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL 278
569#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY 279
570#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATED 280
571#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROYED 281
572#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 282
573#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST 283
574 */
575static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 576static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
576 {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, 577 {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0},
577 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, 578 {&handle_local_connect, NULL,
578 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, 579 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0},
579 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, 580 {&handle_local_connect, NULL,
580 {&handle_local_connect, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, 0}, 581 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0},
581 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY, 0}, 582 {&handle_local_connect, NULL,
582 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, /* FIXME needed? */ 583 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE,
583 {&handle_local_network_traffic, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST, 0}, /* FIXME needed? */ 584 sizeof(struct GNUNET_MESH_ConnectPeerByType)},
585 {&handle_local_connect, NULL,
586 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, 0},
587 {&handle_local_network_traffic, NULL,
588 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY, 0},
589 {&handle_local_network_traffic, NULL,
590 GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, /* FIXME needed? */
591 {&handle_local_network_traffic, NULL,
592 GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST, 0}, /* FIXME needed? */
584 {NULL, NULL, 0, 0} 593 {NULL, NULL, 0, 0}
585}; 594};
586 595
@@ -678,12 +687,13 @@ run (void *cls,
678int 687int
679main (int argc, char *const *argv) 688main (int argc, char *const *argv)
680{ 689{
681 int ret; 690 int ret;
682 691
683 ret = (GNUNET_OK == 692 ret = (GNUNET_OK ==
684 GNUNET_SERVICE_run (argc, 693 GNUNET_SERVICE_run (argc,
685 argv, 694 argv,
686 "mesh", 695 "mesh",
687 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; 696 GNUNET_SERVICE_OPTION_NONE,
688 return ret; 697 &run, NULL)) ? 0 : 1;
689} 698 return ret;
699 }