aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-wdht_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-wdht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-wdht_neighbours.c267
1 files changed, 125 insertions, 142 deletions
diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c
index 6f5b93c7c..1d5fd67c0 100644
--- a/src/dht/gnunet-service-wdht_neighbours.c
+++ b/src/dht/gnunet-service-wdht_neighbours.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2015 GNUnet e.V. 3 Copyright (C) 2009-2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -164,7 +164,7 @@ struct FriendInfo
164 /** 164 /**
165 * Friend Identity 165 * Friend Identity
166 */ 166 */
167 struct GNUNET_PeerIdentity id; 167 const struct GNUNET_PeerIdentity *id;
168 168
169 /** 169 /**
170 * 170 *
@@ -840,28 +840,19 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *trail_id,
840 * 840 *
841 * @param cls closure 841 * @param cls closure
842 * @param peer peer identity this notification is about 842 * @param peer peer identity this notification is about
843 * @param internal_cls our `struct FriendInfo` for @a peer
843 */ 844 */
844static void 845static void
845handle_core_disconnect (void *cls, 846handle_core_disconnect (void *cls,
846 const struct GNUNET_PeerIdentity *peer) 847 const struct GNUNET_PeerIdentity *peer,
848 void *internal_cls)
847{ 849{
848 struct FriendInfo *remove_friend; 850 struct FriendInfo *remove_friend = internal_cls;
849 struct Trail *t; 851 struct Trail *t;
850 852
851 /* If disconnected to own identity, then return. */ 853 /* If disconnected to own identity, then return. */
852 if (0 == memcmp (&my_identity, 854 if (NULL == remove_friend)
853 peer,
854 sizeof (struct GNUNET_PeerIdentity)))
855 return; 855 return;
856
857 if (NULL == (remove_friend =
858 GNUNET_CONTAINER_multipeermap_get (friends_peermap,
859 peer)))
860 {
861 GNUNET_break (0);
862 return;
863 }
864
865 GNUNET_assert (GNUNET_YES == 856 GNUNET_assert (GNUNET_YES ==
866 GNUNET_CONTAINER_multipeermap_remove (friends_peermap, 857 GNUNET_CONTAINER_multipeermap_remove (friends_peermap,
867 peer, 858 peer,
@@ -874,10 +865,8 @@ handle_core_disconnect (void *cls,
874 delete_trail (t, 865 delete_trail (t,
875 GNUNET_NO, 866 GNUNET_NO,
876 GNUNET_YES); 867 GNUNET_YES);
877 GNUNET_MQ_destroy (remove_friend->mq);
878 GNUNET_free (remove_friend); 868 GNUNET_free (remove_friend);
879 if (0 == 869 if (0 == GNUNET_CONTAINER_multipeermap_size (friends_peermap))
880 GNUNET_CONTAINER_multipeermap_size (friends_peermap))
881 { 870 {
882 GNUNET_SCHEDULER_cancel (random_walk_task); 871 GNUNET_SCHEDULER_cancel (random_walk_task);
883 random_walk_task = NULL; 872 random_walk_task = NULL;
@@ -1056,10 +1045,13 @@ do_random_walk (void *cls)
1056 * 1045 *
1057 * @param cls closure 1046 * @param cls closure
1058 * @param peer_identity peer identity this notification is about 1047 * @param peer_identity peer identity this notification is about
1048 * @param mq message queue for transmission to @a peer_identity
1049 * @return the `struct FriendInfo` for the @a peer_identity, NULL for us
1059 */ 1050 */
1060static void 1051static void *
1061handle_core_connect (void *cls, 1052handle_core_connect (void *cls,
1062 const struct GNUNET_PeerIdentity *peer_identity) 1053 const struct GNUNET_PeerIdentity *peer_identity,
1054 struct GNUNET_MQ_Handle *mq)
1063{ 1055{
1064 struct FriendInfo *friend; 1056 struct FriendInfo *friend;
1065 1057
@@ -1067,21 +1059,11 @@ handle_core_connect (void *cls,
1067 if (0 == memcmp (&my_identity, 1059 if (0 == memcmp (&my_identity,
1068 peer_identity, 1060 peer_identity,
1069 sizeof (struct GNUNET_PeerIdentity))) 1061 sizeof (struct GNUNET_PeerIdentity)))
1070 return; 1062 return NULL;
1071
1072 /* If peer already exists in our friend_peermap, then exit. */
1073 if (GNUNET_YES ==
1074 GNUNET_CONTAINER_multipeermap_contains (friends_peermap,
1075 peer_identity))
1076 {
1077 GNUNET_break (0);
1078 return;
1079 }
1080 1063
1081 friend = GNUNET_new (struct FriendInfo); 1064 friend = GNUNET_new (struct FriendInfo);
1082 friend->id = *peer_identity; 1065 friend->id = peer_identity;
1083 friend->mq = GNUNET_CORE_mq_create (core_api, 1066 friend->mq = mq;
1084 peer_identity);
1085 GNUNET_assert (GNUNET_OK == 1067 GNUNET_assert (GNUNET_OK ==
1086 GNUNET_CONTAINER_multipeermap_put (friends_peermap, 1068 GNUNET_CONTAINER_multipeermap_put (friends_peermap,
1087 peer_identity, 1069 peer_identity,
@@ -1093,6 +1075,7 @@ handle_core_connect (void *cls,
1093 random_walk_task = GNUNET_SCHEDULER_add_now (&do_random_walk, 1075 random_walk_task = GNUNET_SCHEDULER_add_now (&do_random_walk,
1094 NULL); 1076 NULL);
1095 } 1077 }
1078 return friend;
1096} 1079}
1097 1080
1098 1081
@@ -1114,30 +1097,23 @@ core_init (void *cls,
1114 * Handle a `struct RandomWalkMessage` from a 1097 * Handle a `struct RandomWalkMessage` from a
1115 * #GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK message. 1098 * #GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK message.
1116 * 1099 *
1117 * @param cls closure (NULL) 1100 * @param cls the `struct FriendInfo` for the sender
1118 * @param peer sender identity 1101 * @param m the setup message
1119 * @param message the setup message
1120 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1121 */ 1102 */
1122static int 1103static void
1123handle_dht_p2p_random_walk (void *cls, 1104handle_dht_p2p_random_walk (void *cls,
1124 const struct GNUNET_PeerIdentity *peer, 1105 const struct RandomWalkMessage *m)
1125 const struct GNUNET_MessageHeader *message)
1126{ 1106{
1127 const struct RandomWalkMessage *m; 1107 struct FriendInfo *pred = cls;
1128 struct Trail *t; 1108 struct Trail *t;
1129 struct FriendInfo *pred;
1130 uint16_t layer; 1109 uint16_t layer;
1131 1110
1132 m = (const struct RandomWalkMessage *) message;
1133 layer = ntohs (m->layer); 1111 layer = ntohs (m->layer);
1134 if (layer > NUMBER_LAYERED_ID) 1112 if (layer > NUMBER_LAYERED_ID)
1135 { 1113 {
1136 GNUNET_break_op (0); 1114 GNUNET_break_op (0);
1137 return GNUNET_SYSERR; 1115 return;
1138 } 1116 }
1139 pred = GNUNET_CONTAINER_multipeermap_get (friends_peermap,
1140 peer);
1141 t = GNUNET_new (struct Trail); 1117 t = GNUNET_new (struct Trail);
1142 t->pred_id = m->trail_id; 1118 t->pred_id = m->trail_id;
1143 t->pred = pred; 1119 t->pred = pred;
@@ -1149,7 +1125,7 @@ handle_dht_p2p_random_walk (void *cls,
1149 { 1125 {
1150 GNUNET_break_op (0); 1126 GNUNET_break_op (0);
1151 GNUNET_free (t); 1127 GNUNET_free (t);
1152 return GNUNET_SYSERR; 1128 return;
1153 } 1129 }
1154 GNUNET_CONTAINER_MDLL_insert (pred, 1130 GNUNET_CONTAINER_MDLL_insert (pred,
1155 pred->pred_head, 1131 pred->pred_head,
@@ -1225,7 +1201,7 @@ handle_dht_p2p_random_walk (void *cls,
1225 pred->pred_tail, 1201 pred->pred_tail,
1226 t); 1202 t);
1227 GNUNET_free (t); 1203 GNUNET_free (t);
1228 return GNUNET_OK; 1204 return;
1229 } 1205 }
1230 GNUNET_CONTAINER_MDLL_insert (succ, 1206 GNUNET_CONTAINER_MDLL_insert (succ,
1231 succ->succ_head, 1207 succ->succ_head,
@@ -1239,36 +1215,30 @@ handle_dht_p2p_random_walk (void *cls,
1239 GNUNET_MQ_send (succ->mq, 1215 GNUNET_MQ_send (succ->mq,
1240 env); 1216 env);
1241 } 1217 }
1242 return GNUNET_OK;
1243} 1218}
1244 1219
1245 1220
1246/** 1221/**
1247 * Handle a `struct RandomWalkResponseMessage`. 1222 * Handle a `struct RandomWalkResponseMessage`.
1248 * 1223 *
1249 * @param cls closure (NULL) 1224 * @param cls closure
1250 * @param peer sender identity 1225 * @param rwrm the setup response message
1251 * @param message the setup response message
1252 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1253 */ 1226 */
1254static int 1227static void
1255handle_dht_p2p_random_walk_response (void *cls, 1228handle_dht_p2p_random_walk_response (void *cls,
1256 const struct GNUNET_PeerIdentity *peer, 1229 const struct RandomWalkResponseMessage *rwrm)
1257 const struct GNUNET_MessageHeader *message) 1230{
1258{
1259 const struct RandomWalkResponseMessage *rwrm;
1260 struct Trail *trail; 1231 struct Trail *trail;
1261 struct FriendInfo *pred; 1232 struct FriendInfo *pred;
1262 struct FingerTable *ft; 1233 struct FingerTable *ft;
1263 struct Finger *finger; 1234 struct Finger *finger;
1264 1235
1265 rwrm = (const struct RandomWalkResponseMessage *) message;
1266 trail = GNUNET_CONTAINER_multihashmap_get (trail_map, 1236 trail = GNUNET_CONTAINER_multihashmap_get (trail_map,
1267 &rwrm->trail_id); 1237 &rwrm->trail_id);
1268 if (NULL == trail) 1238 if (NULL == trail)
1269 { 1239 {
1270 /* TODO: log/statistics: we didn't find the trail (can happen) */ 1240 /* TODO: log/statistics: we didn't find the trail (can happen) */
1271 return GNUNET_OK; 1241 return;
1272 } 1242 }
1273 if (NULL != (pred = trail->pred)) 1243 if (NULL != (pred = trail->pred))
1274 { 1244 {
@@ -1283,7 +1253,7 @@ handle_dht_p2p_random_walk_response (void *cls,
1283 rwrm2->trail_id = trail->pred_id; 1253 rwrm2->trail_id = trail->pred_id;
1284 GNUNET_MQ_send (pred->mq, 1254 GNUNET_MQ_send (pred->mq,
1285 env); 1255 env);
1286 return GNUNET_OK; 1256 return;
1287 } 1257 }
1288 /* We are the first hop, complete finger */ 1258 /* We are the first hop, complete finger */
1289 if (NULL == (ft = trail->ft)) 1259 if (NULL == (ft = trail->ft))
@@ -1293,7 +1263,7 @@ handle_dht_p2p_random_walk_response (void *cls,
1293 delete_trail (trail, 1263 delete_trail (trail,
1294 GNUNET_NO, 1264 GNUNET_NO,
1295 GNUNET_YES); 1265 GNUNET_YES);
1296 return GNUNET_OK; 1266 return;
1297 } 1267 }
1298 if (NULL == (finger = ft->fingers[trail->finger_off])) 1268 if (NULL == (finger = ft->fingers[trail->finger_off]))
1299 { 1269 {
@@ -1302,7 +1272,7 @@ handle_dht_p2p_random_walk_response (void *cls,
1302 delete_trail (trail, 1272 delete_trail (trail,
1303 GNUNET_NO, 1273 GNUNET_NO,
1304 GNUNET_YES); 1274 GNUNET_YES);
1305 return GNUNET_OK; 1275 return;
1306 } 1276 }
1307 1277
1308 1278
@@ -1316,39 +1286,33 @@ handle_dht_p2p_random_walk_response (void *cls,
1316 */ 1286 */
1317 /* FIXME: add the value in db structure 1.a */ 1287 /* FIXME: add the value in db structure 1.a */
1318 1288
1319 return GNUNET_OK;
1320} 1289}
1321 1290
1322 1291
1323/** 1292/**
1324 * Handle a `struct TrailDestroyMessage`. 1293 * Handle a `struct TrailDestroyMessage`.
1325 * 1294 *
1326 * @param cls closure (NULL) 1295 * @param cls closure
1327 * @param peer sender identity 1296 * @param tdm the trail destroy message
1328 * @param message the finger destroy message
1329 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1330 */ 1297 */
1331static int 1298static void
1332handle_dht_p2p_trail_destroy (void *cls, 1299handle_dht_p2p_trail_destroy (void *cls,
1333 const struct GNUNET_PeerIdentity *peer, 1300 const struct TrailDestroyMessage *tdm)
1334 const struct GNUNET_MessageHeader *message) 1301{
1335{ 1302 struct FriendInfo *sender = cls;
1336 const struct TrailDestroyMessage *tdm;
1337 struct Trail *trail; 1303 struct Trail *trail;
1338 1304
1339 tdm = (const struct TrailDestroyMessage *) message;
1340 trail = GNUNET_CONTAINER_multihashmap_get (trail_map, 1305 trail = GNUNET_CONTAINER_multihashmap_get (trail_map,
1341 &tdm->trail_id); 1306 &tdm->trail_id);
1342 delete_trail (trail, 1307 delete_trail (trail,
1343 ( (NULL != trail->succ) && 1308 ( (NULL != trail->succ) &&
1344 (0 == memcmp (peer, 1309 (0 == memcmp (sender->id,
1345 &trail->succ->id, 1310 &trail->succ->id,
1346 sizeof (struct GNUNET_PeerIdentity))) ), 1311 sizeof (struct GNUNET_PeerIdentity))) ),
1347 ( (NULL != trail->pred) && 1312 ( (NULL != trail->pred) &&
1348 (0 == memcmp (peer, 1313 (0 == memcmp (sender->id,
1349 &trail->pred->id, 1314 &trail->pred->id,
1350 sizeof (struct GNUNET_PeerIdentity))) )); 1315 sizeof (struct GNUNET_PeerIdentity))) ));
1351 return GNUNET_OK;
1352} 1316}
1353 1317
1354 1318
@@ -1399,10 +1363,12 @@ handle_dht_p2p_peer_get (void *cls,
1399 unsigned int trail_path_length, 1363 unsigned int trail_path_length,
1400 const struct GNUNET_MessageHeader *message) 1364 const struct GNUNET_MessageHeader *message)
1401{ 1365{
1366#if 0
1402 const struct PeerGetMessage *pgm; 1367 const struct PeerGetMessage *pgm;
1403 1368
1404 // FIXME: note: never called like this, message embedded with trail route! 1369 // FIXME: note: never called like this, message embedded with trail route!
1405 pgm = (const struct PeerGetMessage *) message; 1370 pgm = (const struct PeerGetMessage *) message;
1371#endif
1406 // -> lookup in datacache (figure out way to remember trail!) 1372 // -> lookup in datacache (figure out way to remember trail!)
1407 /* 1373 /*
1408 * steps : 1374 * steps :
@@ -1434,9 +1400,11 @@ handle_dht_p2p_peer_get_result (void *cls,
1434 unsigned int trail_path_length, 1400 unsigned int trail_path_length,
1435 const struct GNUNET_MessageHeader *message) 1401 const struct GNUNET_MessageHeader *message)
1436{ 1402{
1403#if 0
1437 const struct PeerGetResultMessage *pgrm; 1404 const struct PeerGetResultMessage *pgrm;
1438 1405
1439 pgrm = (const struct PeerGetResultMessage *) message; 1406 pgrm = (const struct PeerGetResultMessage *) message;
1407#endif
1440 // pretty much: parse, & pass to client (there is some call for that...) 1408 // pretty much: parse, & pass to client (there is some call for that...)
1441 1409
1442#if 0 1410#if 0
@@ -1474,9 +1442,11 @@ handle_dht_p2p_peer_put (void *cls,
1474 unsigned int trail_path_length, 1442 unsigned int trail_path_length,
1475 const struct GNUNET_MessageHeader *message) 1443 const struct GNUNET_MessageHeader *message)
1476{ 1444{
1445#if 0
1477 const struct PeerGetResultMessage *pgrm; 1446 const struct PeerGetResultMessage *pgrm;
1478 1447
1479 pgrm = (const struct PeerGetResultMessage *) message; 1448 pgrm = (const struct PeerGetResultMessage *) message;
1449#endif
1480 // parse & store in datacache, this is in response to us asking for successors. 1450 // parse & store in datacache, this is in response to us asking for successors.
1481 /* 1451 /*
1482 * steps : 1452 * steps :
@@ -1550,17 +1520,53 @@ struct TrailHandler
1550 1520
1551 1521
1552/** 1522/**
1553 * Handle a `struct TrailRouteMessage`. 1523 * Check that a `struct TrailRouteMessage` is well-formed.
1554 * 1524 *
1555 * @param cls closure (NULL) 1525 * @param cls closure
1556 * @param peer sender identity 1526 * @param trm the finger destroy message
1557 * @param message the finger destroy message
1558 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 1527 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1559 */ 1528 */
1560static int 1529static int
1530check_dht_p2p_trail_route (void *cls,
1531 const struct TrailRouteMessage *trm)
1532{
1533 const struct GNUNET_PeerIdentity *path;
1534 uint16_t path_length;
1535 const struct GNUNET_MessageHeader *payload;
1536 size_t msize;
1537
1538 msize = ntohs (trm->header.size);
1539 path_length = ntohs (trm->path_length);
1540 if (msize < sizeof (struct TrailRouteMessage) +
1541 path_length * sizeof (struct GNUNET_PeerIdentity) +
1542 sizeof (struct GNUNET_MessageHeader) )
1543 {
1544 GNUNET_break_op (0);
1545 return GNUNET_SYSERR;
1546 }
1547 path = (const struct GNUNET_PeerIdentity *) &trm[1];
1548 payload = (const struct GNUNET_MessageHeader *) &path[path_length];
1549 if (msize != (ntohs (payload->size) +
1550 sizeof (struct TrailRouteMessage) +
1551 path_length * sizeof (struct GNUNET_PeerIdentity)))
1552 {
1553 GNUNET_break_op (0);
1554 return GNUNET_SYSERR;
1555 }
1556 /* FIXME: verify payload is OK!? */
1557 return GNUNET_OK;
1558}
1559
1560
1561/**
1562 * Handle a `struct TrailRouteMessage`.
1563 *
1564 * @param cls closure
1565 * @param trm the finger destroy message
1566 */
1567static void
1561handle_dht_p2p_trail_route (void *cls, 1568handle_dht_p2p_trail_route (void *cls,
1562 const struct GNUNET_PeerIdentity *peer, 1569 const struct TrailRouteMessage *trm)
1563 const struct GNUNET_MessageHeader *message)
1564{ 1570{
1565 static const struct TrailHandler handlers[] = { 1571 static const struct TrailHandler handlers[] = {
1566 { &handle_dht_p2p_successor_find, NULL, 1572 { &handle_dht_p2p_successor_find, NULL,
@@ -1577,46 +1583,22 @@ handle_dht_p2p_trail_route (void *cls,
1577 0 }, 1583 0 },
1578 { NULL, NULL, 0, 0 } 1584 { NULL, NULL, 0, 0 }
1579 }; 1585 };
1586 struct FriendInfo *sender = cls;
1580 unsigned int i; 1587 unsigned int i;
1581 const struct TrailRouteMessage *trm;
1582 const struct GNUNET_PeerIdentity *path; 1588 const struct GNUNET_PeerIdentity *path;
1583 uint16_t path_length; 1589 uint16_t path_length;
1584 const struct GNUNET_MessageHeader *payload; 1590 const struct GNUNET_MessageHeader *payload;
1585 const struct TrailHandler *th; 1591 const struct TrailHandler *th;
1586 struct Trail *trail; 1592 struct Trail *trail;
1587 size_t msize;
1588 1593
1589 /* Parse and check message is well-formed */
1590 msize = ntohs (message->size);
1591 if (msize < sizeof (struct TrailRouteMessage))
1592 {
1593 GNUNET_break_op (0);
1594 return GNUNET_YES;
1595 }
1596 trm = (const struct TrailRouteMessage *) message;
1597 path_length = ntohs (trm->path_length); 1594 path_length = ntohs (trm->path_length);
1598 if (msize < sizeof (struct TrailRouteMessage) +
1599 path_length * sizeof (struct GNUNET_PeerIdentity) +
1600 sizeof (struct GNUNET_MessageHeader) )
1601 {
1602 GNUNET_break_op (0);
1603 return GNUNET_YES;
1604 }
1605 path = (const struct GNUNET_PeerIdentity *) &trm[1]; 1595 path = (const struct GNUNET_PeerIdentity *) &trm[1];
1606 payload = (const struct GNUNET_MessageHeader *) &path[path_length]; 1596 payload = (const struct GNUNET_MessageHeader *) &path[path_length];
1607 if (msize != (ntohs (payload->size) +
1608 sizeof (struct TrailRouteMessage) +
1609 path_length * sizeof (struct GNUNET_PeerIdentity)))
1610 {
1611 GNUNET_break_op (0);
1612 return GNUNET_YES;
1613 }
1614
1615 /* Is this message for us? */ 1597 /* Is this message for us? */
1616 trail = GNUNET_CONTAINER_multihashmap_get (trail_map, 1598 trail = GNUNET_CONTAINER_multihashmap_get (trail_map,
1617 &trm->trail_id); 1599 &trm->trail_id);
1618 if ( (NULL != trail->pred) && 1600 if ( (NULL != trail->pred) &&
1619 (0 == memcmp (peer, 1601 (0 == memcmp (sender->id,
1620 &trail->pred->id, 1602 &trail->pred->id,
1621 sizeof (struct GNUNET_PeerIdentity))) ) 1603 sizeof (struct GNUNET_PeerIdentity))) )
1622 { 1604 {
@@ -1626,18 +1608,18 @@ handle_dht_p2p_trail_route (void *cls,
1626 forward_message_on_trail (trail->succ, 1608 forward_message_on_trail (trail->succ,
1627 &trail->succ_id, 1609 &trail->succ_id,
1628 ntohs (trm->record_path), 1610 ntohs (trm->record_path),
1629 peer, 1611 sender->id,
1630 path, 1612 path,
1631 path_length, 1613 path_length,
1632 payload); 1614 payload);
1633 return GNUNET_OK; 1615 return;
1634 } 1616 }
1635 } 1617 }
1636 else 1618 else
1637 { 1619 {
1638 /* forward to 'predecessor' */ 1620 /* forward to 'predecessor' */
1639 GNUNET_break_op ( (NULL != trail->succ) && 1621 GNUNET_break_op ( (NULL != trail->succ) &&
1640 (0 == memcmp (peer, 1622 (0 == memcmp (sender->id,
1641 &trail->succ->id, 1623 &trail->succ->id,
1642 sizeof (struct GNUNET_PeerIdentity))) ); 1624 sizeof (struct GNUNET_PeerIdentity))) );
1643 if (NULL != trail->pred) 1625 if (NULL != trail->pred)
@@ -1645,11 +1627,11 @@ handle_dht_p2p_trail_route (void *cls,
1645 forward_message_on_trail (trail->pred, 1627 forward_message_on_trail (trail->pred,
1646 &trail->pred_id, 1628 &trail->pred_id,
1647 ntohs (trm->record_path), 1629 ntohs (trm->record_path),
1648 peer, 1630 sender->id,
1649 path, 1631 path,
1650 path_length, 1632 path_length,
1651 payload); 1633 payload);
1652 return GNUNET_OK; 1634 return;
1653 } 1635 }
1654 } 1636 }
1655 1637
@@ -1673,7 +1655,6 @@ handle_dht_p2p_trail_route (void *cls,
1673 } 1655 }
1674 } 1656 }
1675 GNUNET_break_op (NULL != th); 1657 GNUNET_break_op (NULL != th);
1676 return GNUNET_OK;
1677} 1658}
1678 1659
1679 1660
@@ -1685,35 +1666,37 @@ handle_dht_p2p_trail_route (void *cls,
1685int 1666int
1686GDS_NEIGHBOURS_init (void) 1667GDS_NEIGHBOURS_init (void)
1687{ 1668{
1688 static const struct GNUNET_CORE_MessageHandler core_handlers[] = { 1669 GNUNET_MQ_hd_fixed_size (dht_p2p_random_walk,
1689 { &handle_dht_p2p_random_walk, 1670 GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK,
1690 GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK, 1671 struct RandomWalkMessage);
1691 sizeof (struct RandomWalkMessage) }, 1672 GNUNET_MQ_hd_fixed_size (dht_p2p_random_walk_response,
1692 { &handle_dht_p2p_random_walk_response, 1673 GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK_RESPONSE,
1693 GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK_RESPONSE, 1674 struct RandomWalkResponseMessage);
1694 sizeof (struct RandomWalkResponseMessage) }, 1675 GNUNET_MQ_hd_fixed_size (dht_p2p_trail_destroy,
1695 { &handle_dht_p2p_trail_destroy, 1676 GNUNET_MESSAGE_TYPE_WDHT_TRAIL_DESTROY,
1696 GNUNET_MESSAGE_TYPE_WDHT_TRAIL_DESTROY, 1677 struct TrailDestroyMessage);
1697 sizeof (struct TrailDestroyMessage) }, 1678 GNUNET_MQ_hd_var_size (dht_p2p_trail_route,
1698 { &handle_dht_p2p_trail_route, 1679 GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE,
1699 GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE, 1680 struct TrailRouteMessage);
1700 0}, 1681 struct GNUNET_MQ_MessageHandler core_handlers[] = {
1701 {NULL, 0, 0} 1682 make_dht_p2p_random_walk_handler (NULL),
1683 make_dht_p2p_random_walk_response_handler (NULL),
1684 make_dht_p2p_trail_destroy_handler (NULL),
1685 make_dht_p2p_trail_route_handler (NULL),
1686 GNUNET_MQ_handler_end ()
1702 }; 1687 };
1703 1688
1704 core_api = 1689 core_api = GNUNET_CORE_connecT (GDS_cfg, NULL,
1705 GNUNET_CORE_connect (GDS_cfg, NULL, 1690 &core_init,
1706 &core_init, 1691 &handle_core_connect,
1707 &handle_core_connect, 1692 &handle_core_disconnect,
1708 &handle_core_disconnect, 1693 core_handlers);
1709 NULL, GNUNET_NO,
1710 NULL, GNUNET_NO,
1711 core_handlers);
1712
1713 if (NULL == core_api) 1694 if (NULL == core_api)
1714 return GNUNET_SYSERR; 1695 return GNUNET_SYSERR;
1715 friends_peermap = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); 1696 friends_peermap = GNUNET_CONTAINER_multipeermap_create (256,
1716 trail_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); 1697 GNUNET_NO);
1698 trail_map = GNUNET_CONTAINER_multihashmap_create (1024,
1699 GNUNET_YES);
1717 trail_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1700 trail_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1718 return GNUNET_OK; 1701 return GNUNET_OK;
1719} 1702}
@@ -1727,7 +1710,7 @@ GDS_NEIGHBOURS_done (void)
1727{ 1710{
1728 if (NULL == core_api) 1711 if (NULL == core_api)
1729 return; 1712 return;
1730 GNUNET_CORE_disconnect (core_api); 1713 GNUNET_CORE_disconnecT (core_api);
1731 core_api = NULL; 1714 core_api = NULL;
1732 GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (friends_peermap)); 1715 GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (friends_peermap));
1733 GNUNET_CONTAINER_multipeermap_destroy (friends_peermap); 1716 GNUNET_CONTAINER_multipeermap_destroy (friends_peermap);