aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-08 15:46:04 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-08 15:46:04 +0000
commit151f25fc399c71f857e1debf7d5bcd40f99ff80f (patch)
tree25ea9682fc33c263881ac33569b5191f899969e1 /src/mesh
parent618db9cb9c3751bafce28e9a56b9b0bad5e8681c (diff)
downloadgnunet-151f25fc399c71f857e1debf7d5bcd40f99ff80f.tar.gz
gnunet-151f25fc399c71f857e1debf7d5bcd40f99ff80f.zip
Finished an attempt on handle_new_client, changed message types to new API
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c31
-rw-r--r--src/mesh/mesh.h2
2 files changed, 20 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 2eccda5e0..079c5a1fa 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -542,32 +542,39 @@ handle_local_new_client (void *cls,
542{ 542{
543 struct Client *c; 543 struct Client *c;
544 unsigned int payload_size; 544 unsigned int payload_size;
545// FIXME: is this needed? should we delete the GNUNET_MESH_Connect struct?
545// struct GNUNET_MESH_Connect *connect_msg; 546// struct GNUNET_MESH_Connect *connect_msg;
546// 547//
547// connect_msg = (struct GNUNET_MESH_Connect *) message; 548// connect_msg = (struct GNUNET_MESH_Connect *) message;
549
550 /* FIXME: is this a good idea? */
551 GNUNET_assert(GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT == message->type);
548 552
549 /* FIXME: check if already exists? NO (optimization) */ 553 /* Check data sanity */
550 payload_size = message->size - sizeof(struct GNUNET_MessageHeader); 554 payload_size = message->size - sizeof(struct GNUNET_MessageHeader);
551 /* FIXME: is this way correct? NO */ 555 if (0 != payload_size % sizeof(GNUNET_MESH_ApplicationType)) {
552 GNUNET_assert(0 == payload_size % sizeof(GNUNET_MESH_ApplicationType)); 556 GNUNET_break(0);
553 /* GNUNET_break */ 557 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
554 /* notify done with syserr */ 558 return;
555 /* return */ 559 }
556 /* Create new client structure */
557 560
561 /* Create new client structure */
558 c = GNUNET_malloc(sizeof(struct Client)); 562 c = GNUNET_malloc(sizeof(struct Client));
559 c->handle = client; 563 c->handle = client;
560 c->tunnels_head = NULL; 564 c->tunnels_head = NULL;
561 c->tunnels_tail = NULL; 565 c->tunnels_tail = NULL;
562 566 if(payload_size != 0) {
563 c->messages_subscribed = GNUNET_malloc(payload_size); 567 c->messages_subscribed = GNUNET_malloc(payload_size);
564 memcpy(c->messages_subscribed, &message[1], payload_size); 568 memcpy(c->messages_subscribed, &message[1], payload_size);
565 c->subscription_counter = payload_size / sizeof(GNUNET_MESH_ApplicationType); 569 } else {
570 c->messages_subscribed = NULL;
571 }
572 c->subscription_counter = payload_size/sizeof(GNUNET_MESH_ApplicationType);
566 573
567 /* Insert new client in DLL */ 574 /* Insert new client in DLL */
568 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c); 575 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c);
569 576
570 /* FIXME: notify done */ 577 GNUNET_SERVER_receive_done(client, GNUNET_OK);
571} 578}
572 579
573/** 580/**
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index 609d35ec7..3ef0ec397 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -116,7 +116,7 @@ struct GNUNET_MESH_PeerControl {
116 /** 116 /**
117 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL] 117 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL]
118 * (client to service, client created tunnel) 118 * (client to service, client created tunnel)
119 * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOTIFY[CONNECT|DISCONNECT] 119 * GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_[CONNECTED|DISCONNECTED]
120 * (service to client) 120 * (service to client)
121 * 121 *
122 * Size: sizeof(struct GNUNET_MESH_PeerControl) 122 * Size: sizeof(struct GNUNET_MESH_PeerControl)