aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-05-03 16:58:38 +0000
committerBart Polot <bart@net.in.tum.de>2011-05-03 16:58:38 +0000
commit4fbd46e8d0553d74ec06e9c6275d17fa73b3714c (patch)
treedb432c68552ca212c22ac76abc8507b52cfab56e /src
parent15ff6f14fedcf2e35d0970519bbb5ecbf1ad8e00 (diff)
downloadgnunet-4fbd46e8d0553d74ec06e9c6275d17fa73b3714c.tar.gz
gnunet-4fbd46e8d0553d74ec06e9c6275d17fa73b3714c.zip
WiP
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c80
-rw-r--r--src/mesh/mesh.h2
2 files changed, 69 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 3b4be4634..16f75455d 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -226,8 +226,7 @@ enum PeerState
226 /** 226 /**
227 * Peer connected previosly but not responding 227 * Peer connected previosly but not responding
228 */ 228 */
229 MESH_PEER_RECONNECTING, 229 MESH_PEER_RECONNECTING
230
231}; 230};
232 231
233/** 232/**
@@ -489,7 +488,7 @@ static GNUNET_PEER_Id myid;
489 488
490/** 489/**
491 * Function called to notify a client about the socket 490 * Function called to notify a client about the socket
492 * begin ready to queue more data. "buf" will be 491 * being ready to queue more data. "buf" will be
493 * NULL and "size" zero if the socket was closed for 492 * NULL and "size" zero if the socket was closed for
494 * writing in the meantime. 493 * writing in the meantime.
495 * 494 *
@@ -498,15 +497,38 @@ static GNUNET_PEER_Id myid;
498 * @param buf where the callee should write the message 497 * @param buf where the callee should write the message
499 * @return number of bytes written to buf 498 * @return number of bytes written to buf
500 */ 499 */
501size_t feed_data_to_core (void *cls, size_t size, void *buf) { 500size_t send_core_create_path_for_peer (void *cls, size_t size, void *buf) {
502 size_t size_used; 501 size_t size_used;
503 struct PeerInfo *peer_info; 502 struct PeerInfo *peer_info;
503 struct GNUNET_MESH_ManipulatePath *msg;
504 struct Path *p;
504 505
505 if(0 == size && NULL == buf) { 506 if((0 == size && NULL == buf) ||
506 // FIXME retry? cancel? 507 size < sizeof(struct GNUNET_MESH_ManipulatePath))
508 {
509 // TODO retry? cancel?
510 return 0;
507 } 511 }
508 size_used = 0; 512 size_used = 0;
509 peer_info = (struct PeerInfo *)cls; 513 peer_info = (struct PeerInfo *)cls;
514 peer_info->dhtget = NULL;
515 p = peer_info->t->paths_head;
516 while(NULL != p) {
517 if(p->peers[p->length-1] == peer_info->id) {
518 break;
519 }
520 if(p != peer_info->t->paths_tail) {
521 p = p->next;
522 } else {
523 // TODO ERROR Path not found
524 }
525 }
526
527 msg = (struct GNUNET_MESH_ManipulatePath *) buf;
528 msg->header.size = htons(sizeof(struct GNUNET_MESH_ManipulatePath));
529 msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE);
530
531
510 532
511 return size_used; 533 return size_used;
512} 534}
@@ -601,6 +623,22 @@ client_retrieve (struct GNUNET_SERVER_Client *client) {
601} 623}
602 624
603/** 625/**
626 * Function called to notify a client about the socket
627 * begin ready to queue more data. "buf" will be
628 * NULL and "size" zero if the socket was closed for
629 * writing in the meantime.
630 *
631 * @param cls closure
632 * @param size number of bytes available in buf
633 * @param buf where the callee should write the message
634 * @return number of bytes written to buf
635 */
636size_t notify_client_connection_failure (void *cls, size_t size, void *buf) {
637 return 0;
638}
639
640
641/**
604 * Iterator called on each result obtained for a DHT 642 * Iterator called on each result obtained for a DHT
605 * operation that expects a reply 643 * operation that expects a reply
606 * 644 *
@@ -631,6 +669,18 @@ void dht_get_response_handler(void *cls,
631 669
632 peer_info = (struct PeerInfo *)cls; 670 peer_info = (struct PeerInfo *)cls;
633 t = peer_info->t; 671 t = peer_info->t;
672
673 if(NULL == get_path || NULL == put_path) {
674 // TODO: find ourselves some alternate first path to the destination
675 GNUNET_SERVER_notify_transmit_ready(
676 t->client->handle,
677 sizeof(struct GNUNET_MESH_PeerControl),
678 GNUNET_TIME_relative_get_forever(),
679 &notify_client_connection_failure,
680 peer_info
681 );
682 }
683
634 p = GNUNET_malloc(sizeof(struct Path)); 684 p = GNUNET_malloc(sizeof(struct Path));
635 GNUNET_CONTAINER_DLL_insert(t->paths_head, t->paths_tail, p); 685 GNUNET_CONTAINER_DLL_insert(t->paths_head, t->paths_tail, p);
636 for(i = 0; get_path[i] != NULL; i++) { 686 for(i = 0; get_path[i] != NULL; i++) {
@@ -656,7 +706,7 @@ void dht_get_response_handler(void *cls,
656 sizeof(struct GNUNET_MESH_ManipulatePath) 706 sizeof(struct GNUNET_MESH_ManipulatePath)
657 + (p->length 707 + (p->length
658 * sizeof (struct GNUNET_PeerIdentity)), 708 * sizeof (struct GNUNET_PeerIdentity)),
659 feed_data_to_core, 709 &send_core_create_path_for_peer,
660 peer_info 710 peer_info
661 ); 711 );
662 return; 712 return;
@@ -1271,13 +1321,17 @@ handle_local_network_traffic_bcast (void *cls,
1271static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 1321static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
1272 {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0}, 1322 {&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0},
1273 {&handle_local_tunnel_create, NULL, 1323 {&handle_local_tunnel_create, NULL,
1274 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE, 0}, 1324 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE,
1325 sizeof(struct GNUNET_MESH_TunnelMessage)},
1275 {&handle_local_tunnel_destroy, NULL, 1326 {&handle_local_tunnel_destroy, NULL,
1276 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY, 0}, 1327 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY,
1328 sizeof(struct GNUNET_MESH_TunnelMessage)},
1277 {&handle_local_connect_add, NULL, 1329 {&handle_local_connect_add, NULL,
1278 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0}, 1330 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD,
1331 sizeof(struct GNUNET_MESH_PeerControl)},
1279 {&handle_local_connect_del, NULL, 1332 {&handle_local_connect_del, NULL,
1280 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0}, 1333 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL,
1334 sizeof(struct GNUNET_MESH_PeerControl)},
1281 {&handle_local_connect_by_type, NULL, 1335 {&handle_local_connect_by_type, NULL,
1282 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, 1336 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE,
1283 sizeof(struct GNUNET_MESH_ConnectPeerByType)}, 1337 sizeof(struct GNUNET_MESH_ConnectPeerByType)},
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index a7ce515da..c40f08325 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -77,6 +77,8 @@ typedef uint32_t MESH_TunnelID;
77struct GNUNET_MESH_TunnelMessage { 77struct GNUNET_MESH_TunnelMessage {
78 /** 78 /**
79 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY] 79 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
80 *
81 * Size: sizeof(struct GNUNET_MESH_TunnelMessage)
80 */ 82 */
81 struct GNUNET_MessageHeader header; 83 struct GNUNET_MessageHeader header;
82 84