diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-02-04 18:21:37 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-02-04 18:21:37 +0000 |
commit | c2155235b8cbc9041da824677cd05e59908f5c2e (patch) | |
tree | b9445018524cb97a51db277fbda2af3873faeb64 /src/dht | |
parent | a75ae8ee1849d5a9671583ddc29a0df8164298b3 (diff) | |
download | gnunet-c2155235b8cbc9041da824677cd05e59908f5c2e.tar.gz gnunet-c2155235b8cbc9041da824677cd05e59908f5c2e.zip |
Finding successor of a peer id.
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-xdht_clients.c | 3 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 171 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_routing.c | 43 |
3 files changed, 113 insertions, 104 deletions
diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c index 72d086606..f7c4df759 100644 --- a/src/dht/gnunet-service-xdht_clients.c +++ b/src/dht/gnunet-service-xdht_clients.c | |||
@@ -21,7 +21,8 @@ | |||
21 | /** | 21 | /** |
22 | * @file dht/gnunet-service-xdht_clients.c | 22 | * @file dht/gnunet-service-xdht_clients.c |
23 | * @brief GNUnet DHT service's client management code | 23 | * @brief GNUnet DHT service's client management code |
24 | * @author Supriti Singh | 24 | * @author Christian Grothoff |
25 | * @author Nathan Evans | ||
25 | */ | 26 | */ |
26 | 27 | ||
27 | #include "platform.h" | 28 | #include "platform.h" |
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index c6de372f1..fa7aeb981 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -567,7 +567,6 @@ core_transmit_notify (void *cls, size_t size, void *buf) | |||
567 | static void | 567 | static void |
568 | process_friend_queue (struct FriendInfo *peer) | 568 | process_friend_queue (struct FriendInfo *peer) |
569 | { | 569 | { |
570 | |||
571 | struct P2PPendingMessage *pending; | 570 | struct P2PPendingMessage *pending; |
572 | 571 | ||
573 | if (NULL == (pending = peer->head)) | 572 | if (NULL == (pending = peer->head)) |
@@ -604,13 +603,12 @@ GDS_NEIGHBOURS_trail_setup(struct GNUNET_PeerIdentity *finger_id, | |||
604 | struct FriendInfo *target_friend) | 603 | struct FriendInfo *target_friend) |
605 | { | 604 | { |
606 | /* | 605 | /* |
607 | * FIXME: check if pending message actually contains the correct data. | 606 | * FIXME: check if pending message actually contains the correct data. |
608 | */ | 607 | */ |
609 | struct P2PPendingMessage *pending; | 608 | struct P2PPendingMessage *pending; |
610 | /* FIXME: why I have defined as **? verify by testing. */ | 609 | /* FIXME: why I have defined as **? verify by testing. */ |
611 | struct PeerTrailSetupMessage *tsm; | 610 | struct PeerTrailSetupMessage *tsm; |
612 | 611 | ||
613 | |||
614 | if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND) | 612 | if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND) |
615 | { | 613 | { |
616 | GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"), | 614 | GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"), |
@@ -619,7 +617,7 @@ GDS_NEIGHBOURS_trail_setup(struct GNUNET_PeerIdentity *finger_id, | |||
619 | 617 | ||
620 | /* SUPU: Verify if this copy between pending message, tsm is correct? */ | 618 | /* SUPU: Verify if this copy between pending message, tsm is correct? */ |
621 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage)); | 619 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage)); |
622 | /*SUPU: What does this code do? Does this intialize pending with | 620 | /*SUPU: What does this code do? Does this initialize pending with |
623 | values of tsm? */ | 621 | values of tsm? */ |
624 | tsm = (struct PeerTrailSetupMessage *) &pending[1]; | 622 | tsm = (struct PeerTrailSetupMessage *) &pending[1]; |
625 | pending->msg = &tsm->header; | 623 | pending->msg = &tsm->header; |
@@ -744,7 +742,7 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | |||
744 | */ | 742 | */ |
745 | static struct FriendInfo * | 743 | static struct FriendInfo * |
746 | get_random_friend() | 744 | get_random_friend() |
747 | { | 745 | { |
748 | unsigned int current_size; | 746 | unsigned int current_size; |
749 | unsigned int *index; | 747 | unsigned int *index; |
750 | unsigned int j = 0; | 748 | unsigned int j = 0; |
@@ -792,7 +790,6 @@ static | |||
792 | struct GNUNET_PeerIdentity * | 790 | struct GNUNET_PeerIdentity * |
793 | finger_id_to_search() | 791 | finger_id_to_search() |
794 | { | 792 | { |
795 | |||
796 | struct GNUNET_PeerIdentity *finger_peer_id; | 793 | struct GNUNET_PeerIdentity *finger_peer_id; |
797 | uint32_t peer_id; | 794 | uint32_t peer_id; |
798 | uint32_t finger_id; | 795 | uint32_t finger_id; |
@@ -803,30 +800,29 @@ finger_id_to_search() | |||
803 | if (0 == memcpy(&peer_id,&my_identity.public_key.q_y,sizeof(uint32_t))) | 800 | if (0 == memcpy(&peer_id,&my_identity.public_key.q_y,sizeof(uint32_t))) |
804 | return NULL; | 801 | return NULL; |
805 | 802 | ||
806 | |||
807 | /* We do all the arithmetic operation on peer_id to get finger_id*/ | 803 | /* We do all the arithmetic operation on peer_id to get finger_id*/ |
808 | finger_id = (uint32_t)(peer_id + pow(2,current_finger_id)) % MAX_FINGERS; | 804 | finger_id = (uint32_t)(peer_id + pow(2,current_finger_id)) % MAX_FINGERS; |
809 | 805 | ||
810 | |||
811 | /* Copy the finger_id to finger_peer_id. */ | 806 | /* Copy the finger_id to finger_peer_id. */ |
812 | if (0 == memcpy(&finger_peer_id->public_key.q_y,&finger_id,sizeof(uint32_t))) | 807 | if (0 == memcpy(&finger_peer_id->public_key.q_y,&finger_id,sizeof(uint32_t))) |
813 | return NULL; | 808 | return NULL; |
814 | 809 | ||
815 | /* FIXME: Here I increment the index so that next time when we enter this | 810 | |
816 | function, then we begin the search from current index. Is it possible | 811 | /* FIXME: Here I increment the index so that next time when we enter this |
817 | to set this value when we add the finger id to our finger table. No, because | 812 | function, then we begin the search from current index. Is it possible |
818 | even there is a call going on to find the finger, we can start another call | 813 | to set this value when we add the finger id to our finger table. No, because |
819 | to search another peer. */ | 814 | even there is a call going on to find the finger, we can start another call |
820 | current_finger_id = (current_finger_id+1) % MAX_FINGERS; | 815 | to search another peer. */ |
816 | current_finger_id = (current_finger_id+1) % MAX_FINGERS; | ||
821 | 817 | ||
822 | /* Check if you already have an entry in finger_peers for this finger_id. | 818 | /* Check if you already have an entry in finger_peers for this finger_id. |
823 | If yes then again look for a new finger_id. */ | 819 | If yes then again look for a new finger_id. */ |
824 | if(NULL == GNUNET_CONTAINER_multipeermap_get(finger_peers,finger_peer_id)) | 820 | /*if(NULL != GNUNET_CONTAINER_multipeermap_get(finger_peers,finger_peer_id)) |
825 | { | 821 | { |
826 | /* Is the recursion safe here? */ | 822 | |
827 | finger_peer_id = finger_id_to_search(); | 823 | finger_peer_id = finger_id_to_search(); |
828 | } | 824 | } |
829 | 825 | */ | |
830 | return finger_peer_id; | 826 | return finger_peer_id; |
831 | } | 827 | } |
832 | 828 | ||
@@ -845,11 +841,12 @@ static | |||
845 | struct GNUNET_PeerIdentity* | 841 | struct GNUNET_PeerIdentity* |
846 | find_immediate_predecessor() | 842 | find_immediate_predecessor() |
847 | { | 843 | { |
848 | /* Using your own peer identity, calculate your predecessor | 844 | /* Using your own peer identity, calculate your predecessor |
849 | in the network. Try to setup path to this predecessor using | 845 | * in the network. Try to setup path to this predecessor using |
850 | the same logic as used for other fingers. | 846 | * the same logic as used for other fingers. |
851 | If we already have a trail to our predecessor then send NULL and | 847 | * If we already have a trail to our predecessor then send NULL and |
852 | calling function should be able to handle that case. */ | 848 | * calling function should be able to handle that case. |
849 | */ | ||
853 | return NULL; | 850 | return NULL; |
854 | } | 851 | } |
855 | 852 | ||
@@ -868,7 +865,7 @@ send_find_finger_trail_message (void *cls, | |||
868 | struct GNUNET_PeerIdentity *finger_peer_id; | 865 | struct GNUNET_PeerIdentity *finger_peer_id; |
869 | struct FriendInfo *friend_peer_id; | 866 | struct FriendInfo *friend_peer_id; |
870 | struct GNUNET_TIME_Relative next_send_time; | 867 | struct GNUNET_TIME_Relative next_send_time; |
871 | 868 | ||
872 | /* We already have found trail to each of our possible fingers in the network. */ | 869 | /* We already have found trail to each of our possible fingers in the network. */ |
873 | if (GNUNET_CONTAINER_multipeermap_size(finger_peers) == MAX_FINGERS) | 870 | if (GNUNET_CONTAINER_multipeermap_size(finger_peers) == MAX_FINGERS) |
874 | { | 871 | { |
@@ -1059,23 +1056,15 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1059 | 1056 | ||
1060 | 1057 | ||
1061 | /** | 1058 | /** |
1062 | * FIXME: | 1059 | * FIXME:1. Check if current_destination field is set correctly. |
1063 | * Are we comparing the predecessor with our own identity also. | 1060 | * 2. Is it correct to use GNUNET_CMP_PEER_IDENTITY to find out the successor |
1064 | * Its important. | 1061 | * of a finger. |
1065 | * Here also we would be comparing the numeric value of | 1062 | * The code flow seems to be very large. Could do better. |
1066 | * peer identity. We read the element from our map. Extract | ||
1067 | * the peer id and compare it with destination id. But again | ||
1068 | * this comparison is on values. Same issue again. | ||
1069 | * Find the predecessor for given finger_id from the | ||
1070 | * friend and finger table. | ||
1071 | * if friend, then just return the friend | ||
1072 | * if finger, then return the next hop to forward the packet to and also | ||
1073 | * set the current_destination field to finger_id. | ||
1074 | * @param destination peer id's predecessor we are looking for. | 1063 | * @param destination peer id's predecessor we are looking for. |
1075 | * @return | 1064 | * @return |
1076 | */ | 1065 | */ |
1077 | static struct GNUNET_PeerIdentity * | 1066 | static struct GNUNET_PeerIdentity * |
1078 | find_successor(struct GNUNET_PeerIdentity *destination) | 1067 | find_successor(struct GNUNET_PeerIdentity *destination, struct GNUNET_PeerIdentity *current_destination) |
1079 | { | 1068 | { |
1080 | unsigned int friend_index; | 1069 | unsigned int friend_index; |
1081 | unsigned int finger_index; | 1070 | unsigned int finger_index; |
@@ -1084,9 +1073,21 @@ find_successor(struct GNUNET_PeerIdentity *destination) | |||
1084 | struct GNUNET_PeerIdentity key_ret; | 1073 | struct GNUNET_PeerIdentity key_ret; |
1085 | struct FriendInfo *friend; | 1074 | struct FriendInfo *friend; |
1086 | struct FingerInfo *finger; | 1075 | struct FingerInfo *finger; |
1076 | struct GNUNET_PeerIdentity *current_successor; | ||
1077 | |||
1078 | /* FIXME: Temporary field used to understand if we got a friend or finger | ||
1079 | as next successor. find something better.*/ | ||
1080 | int successor; | ||
1081 | int finger_peer = 0; | ||
1082 | int friend_peer = 1; | ||
1083 | int me = 2; | ||
1084 | |||
1085 | current_successor = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); | ||
1086 | |||
1087 | /* initialize current_successor with your own identity.*/ | ||
1088 | memcpy(current_successor,&my_identity,sizeof(struct GNUNET_PeerIdentity)); | ||
1089 | successor = me; | ||
1087 | 1090 | ||
1088 | /* Should I keep a variable to remember if GNUNET_PeerIdentity is | ||
1089 | friend or finger. */ | ||
1090 | friend_iter = GNUNET_CONTAINER_multipeermap_iterator_create (friend_peers); | 1091 | friend_iter = GNUNET_CONTAINER_multipeermap_iterator_create (friend_peers); |
1091 | 1092 | ||
1092 | /*iterate over friend map till you reach a peer id such that destination <= peer id */ | 1093 | /*iterate over friend map till you reach a peer id such that destination <= peer id */ |
@@ -1094,37 +1095,52 @@ find_successor(struct GNUNET_PeerIdentity *destination) | |||
1094 | { | 1095 | { |
1095 | if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next(friend_iter,&key_ret,(const void **)&friend)) | 1096 | if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next(friend_iter,&key_ret,(const void **)&friend)) |
1096 | { | 1097 | { |
1097 | /* | 1098 | if(0 > GNUNET_CRYPTO_cmp_peer_identity(&friend->id,destination) || |
1098 | * 1. Check if friend >= destination. | 1099 | (0 == GNUNET_CRYPTO_cmp_peer_identity(&friend->id,destination))) |
1099 | * 2. If yes then check if friend <= current_predecessor, | 1100 | { |
1100 | * if yes then curret_predecessor = friend. | 1101 | /* If yes then check if finger <= current_successor */ |
1101 | * 3 If not then do nothing. | 1102 | if(0 < GNUNET_CRYPTO_cmp_peer_identity(&friend->id,current_successor) || |
1102 | */ | 1103 | (0 == GNUNET_CRYPTO_cmp_peer_identity(&friend->id,current_successor))) |
1104 | { | ||
1105 | memcpy(current_successor,friend,sizeof(struct GNUNET_PeerIdentity)); | ||
1106 | successor = friend_peer; | ||
1107 | } | ||
1108 | } | ||
1103 | } | 1109 | } |
1104 | } | 1110 | } |
1105 | 1111 | ||
1106 | 1112 | ||
1107 | finger_iter = GNUNET_CONTAINER_multipeermap_iterator_create (finger_peers); | 1113 | finger_iter = GNUNET_CONTAINER_multipeermap_iterator_create (finger_peers); |
1108 | /*iterate over finger map till you reach a peer id such that destination <= peer id */ | 1114 | /*iterate over finger map till you reach a peer id such that destination <= peer id */ |
1109 | for (finger_index = 0; finger_index < GNUNET_CONTAINER_multipeermap_size (friend_peers); finger_index++) | 1115 | for (finger_index = 0; finger_index < GNUNET_CONTAINER_multipeermap_size (finger_peers); finger_index++) |
1110 | { | 1116 | { |
1111 | if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next(finger_iter,&key_ret,(const void **)&finger)) | 1117 | if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next(finger_iter,&key_ret,(const void **)&finger)) |
1112 | { | 1118 | { |
1113 | /* | 1119 | if(0 > GNUNET_CRYPTO_cmp_peer_identity(&finger->id,destination) || |
1114 | * 1. Check if finger >= destination. | 1120 | (0 == GNUNET_CRYPTO_cmp_peer_identity(&finger->id,destination))) |
1115 | * 2. If yes then check if finger <= current_predecessor, | 1121 | { |
1116 | * if yes then curret_predecessor = finger. | 1122 | /* If yes then check if finger <= current_friend_successor */ |
1117 | * 3 If not then do nothing. | 1123 | if(0 < GNUNET_CRYPTO_cmp_peer_identity(&finger->id,current_successor) |
1118 | */ | 1124 | || (0 == GNUNET_CRYPTO_cmp_peer_identity(&finger->id,current_successor))) |
1125 | { | ||
1126 | memcpy(current_successor,finger,sizeof(struct GNUNET_PeerIdentity)); | ||
1127 | successor = finger_peer; | ||
1128 | } | ||
1129 | } | ||
1119 | } | 1130 | } |
1120 | } | 1131 | } |
1121 | 1132 | ||
1122 | /* Check between friend and finger value to decide which is the predecessor. | 1133 | if(successor == finger_peer) |
1123 | If friend, then send the friend id. | 1134 | { |
1124 | If finger, then send the next hop. | 1135 | memcpy(current_destination,current_successor,sizeof(struct GNUNET_PeerIdentity)); |
1125 | Also set the current_destination = friend, if friend | 1136 | } |
1126 | or else current_destination = finger. */ | 1137 | else |
1127 | return NULL; | 1138 | { |
1139 | /* The successor is either my_identity or friend. */ | ||
1140 | current_destination = NULL; | ||
1141 | } | ||
1142 | |||
1143 | return current_successor; | ||
1128 | } | 1144 | } |
1129 | 1145 | ||
1130 | 1146 | ||
@@ -1136,7 +1152,7 @@ find_trail_list_prev_hop(struct PeerTrailSetupMessage *trail_result) | |||
1136 | /*FIXME: I don't see any function in existing dll implementation, to | 1152 | /*FIXME: I don't see any function in existing dll implementation, to |
1137 | just read the dll backward or forward. So, I would implement one here. | 1153 | just read the dll backward or forward. So, I would implement one here. |
1138 | * As no one else uses this functionality so I guess its okay to just | 1154 | * As no one else uses this functionality so I guess its okay to just |
1139 | * implement it here. */ | 1155 | * implement it here. */ |
1140 | return NULL; | 1156 | return NULL; |
1141 | } | 1157 | } |
1142 | 1158 | ||
@@ -1146,7 +1162,6 @@ find_trail_list_prev_hop(struct PeerTrailSetupMessage *trail_result) | |||
1146 | * 1. Check if we are maintaining the 64k size of struct PeerTrailSetupMessage. | 1162 | * 1. Check if we are maintaining the 64k size of struct PeerTrailSetupMessage. |
1147 | * when we add ourself to the trail list. | 1163 | * when we add ourself to the trail list. |
1148 | * 2. Ensure every case is handled for current_destination. | 1164 | * 2. Ensure every case is handled for current_destination. |
1149 | * 3. When should you call GDS_Routing_Add? | ||
1150 | * Core handler for P2P trail setup message. | 1165 | * Core handler for P2P trail setup message. |
1151 | * @param cls closure | 1166 | * @param cls closure |
1152 | * @param message message | 1167 | * @param message message |
@@ -1165,7 +1180,7 @@ handle_dht_p2p_trail_setup(void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1165 | struct P2PPendingMessage *pending; | 1180 | struct P2PPendingMessage *pending; |
1166 | 1181 | ||
1167 | uint16_t msize; | 1182 | uint16_t msize; |
1168 | 1183 | ||
1169 | msize = ntohs (message->size); | 1184 | msize = ntohs (message->size); |
1170 | if (msize < sizeof (struct PeerTrailSetupMessage)) | 1185 | if (msize < sizeof (struct PeerTrailSetupMessage)) |
1171 | { | 1186 | { |
@@ -1187,12 +1202,12 @@ handle_dht_p2p_trail_setup(void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1187 | if(trail_setup->current_destination == NULL) | 1202 | if(trail_setup->current_destination == NULL) |
1188 | { | 1203 | { |
1189 | /* Find the next peer to pass the trail setup message. */ | 1204 | /* Find the next peer to pass the trail setup message. */ |
1190 | next_hop = find_successor(trail_setup->destination_finger); | 1205 | next_hop = find_successor(trail_setup->destination_finger,trail_setup->current_destination); |
1191 | } | 1206 | } |
1192 | else if( 0 == (GNUNET_CRYPTO_cmp_peer_identity(trail_setup->current_destination,&my_identity))) | 1207 | else if( 0 == (GNUNET_CRYPTO_cmp_peer_identity(trail_setup->current_destination,&my_identity))) |
1193 | { | 1208 | { |
1194 | /* I am current destination, find the next peer to pass the trail setup message. */ | 1209 | /* I am current destination, find the next peer to pass the trail setup message. */ |
1195 | next_hop = find_successor(trail_setup->destination_finger); | 1210 | next_hop = find_successor(trail_setup->destination_finger,trail_setup->current_destination); |
1196 | } | 1211 | } |
1197 | else | 1212 | else |
1198 | { | 1213 | { |
@@ -1216,20 +1231,10 @@ handle_dht_p2p_trail_setup(void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1216 | * Do we really need to pass the whole trail_setup? I guess | 1231 | * Do we really need to pass the whole trail_setup? I guess |
1217 | * we can just pass the double linked list. | 1232 | * we can just pass the double linked list. |
1218 | */ | 1233 | */ |
1219 | prev_hop = find_trail_list_prev_hop(trail_setup); | 1234 | prev_hop = find_trail_list_prev_hop(trail_setup); |
1220 | 1235 | ||
1221 | /* Add an entry in the routing table. | ||
1222 | SUPU: Here we are adding an entry to our routing table because we are not final | ||
1223 | destination.So, it means we are part of a routing trail. It may happen | ||
1224 | that we found next_hop from searching the routing table. So, in GDS_ROUTING_Add, | ||
1225 | we should first check if there is already an entry for current_destination. If yes | ||
1226 | then don't add.*/ | ||
1227 | GDS_ROUTING_add(trail_setup->source_peer,trail_setup->current_destination,prev_hop,next_hop); | 1236 | GDS_ROUTING_add(trail_setup->source_peer,trail_setup->current_destination,prev_hop,next_hop); |
1228 | 1237 | ||
1229 | /* FIXME: | ||
1230 | * 1. Insert next hop into trail list. | ||
1231 | * 2. I don't see any function to just read the DLL. Need to see again if there is | ||
1232 | * one. If not then need to write something. */ | ||
1233 | peer_entry = GNUNET_malloc (sizeof (struct TrailPeerList)); | 1238 | peer_entry = GNUNET_malloc (sizeof (struct TrailPeerList)); |
1234 | peer_entry->peer = &my_identity; | 1239 | peer_entry->peer = &my_identity; |
1235 | peer_entry->next = NULL; | 1240 | peer_entry->next = NULL; |
@@ -1249,6 +1254,8 @@ handle_dht_p2p_trail_setup(void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1249 | 1254 | ||
1250 | /* Send trail setup message to next hop friend. */ | 1255 | /* Send trail setup message to next hop friend. */ |
1251 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage)); | 1256 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage)); |
1257 | |||
1258 | /* FIXME: Check if we are properly initializing pending. */ | ||
1252 | trail_setup = (struct PeerTrailSetupMessage *) &pending[1]; | 1259 | trail_setup = (struct PeerTrailSetupMessage *) &pending[1]; |
1253 | pending->msg = &trail_setup->header; | 1260 | pending->msg = &trail_setup->header; |
1254 | GNUNET_CONTAINER_DLL_insert_tail (friend->head, friend->tail, pending); | 1261 | GNUNET_CONTAINER_DLL_insert_tail (friend->head, friend->tail, pending); |
@@ -1274,8 +1281,8 @@ static | |||
1274 | struct GNUNET_PeerIdentity * | 1281 | struct GNUNET_PeerIdentity * |
1275 | find_trail_list_next_hop(struct PeerTrailSetupResultMessage *trail_result) | 1282 | find_trail_list_next_hop(struct PeerTrailSetupResultMessage *trail_result) |
1276 | { | 1283 | { |
1277 | /* Setup the current_destination value to new next hop found. */ | 1284 | /* Setup the current_destination value to new next hop found. */ |
1278 | return NULL; | 1285 | return NULL; |
1279 | } | 1286 | } |
1280 | 1287 | ||
1281 | 1288 | ||
@@ -1344,7 +1351,7 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
1344 | process_friend_queue(friend); | 1351 | process_friend_queue(friend); |
1345 | 1352 | ||
1346 | return GNUNET_YES; | 1353 | return GNUNET_YES; |
1347 | } | 1354 | } |
1348 | } | 1355 | } |
1349 | else | 1356 | else |
1350 | return GNUNET_SYSERR; | 1357 | return GNUNET_SYSERR; |
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c index 15a492dc5..d81b79f43 100644 --- a/src/dht/gnunet-service-xdht_routing.c +++ b/src/dht/gnunet-service-xdht_routing.c | |||
@@ -92,25 +92,25 @@ GDS_ROUTING_add (struct GNUNET_PeerIdentity *source, | |||
92 | struct GNUNET_PeerIdentity *prev_hop, | 92 | struct GNUNET_PeerIdentity *prev_hop, |
93 | struct GNUNET_PeerIdentity *next_hop) | 93 | struct GNUNET_PeerIdentity *next_hop) |
94 | { | 94 | { |
95 | struct RoutingTrail *new_routing_entry; | 95 | struct RoutingTrail *new_routing_entry; |
96 | 96 | ||
97 | new_routing_entry = GNUNET_malloc (sizeof (struct RoutingTrail)); | 97 | new_routing_entry = GNUNET_malloc (sizeof (struct RoutingTrail)); |
98 | new_routing_entry->source = source; | 98 | new_routing_entry->source = source; |
99 | new_routing_entry->previous_hop = prev_hop; | 99 | new_routing_entry->previous_hop = prev_hop; |
100 | new_routing_entry->next_hop = next_hop; | 100 | new_routing_entry->next_hop = next_hop; |
101 | new_routing_entry->destination = dest; | 101 | new_routing_entry->destination = dest; |
102 | 102 | ||
103 | /* If dest is already present in the routing table, then exit.*/ | 103 | /* If dest is already present in the routing table, then exit.*/ |
104 | if (GNUNET_YES == | 104 | if (GNUNET_YES == |
105 | GNUNET_CONTAINER_multipeermap_contains (routing_table, | 105 | GNUNET_CONTAINER_multipeermap_contains (routing_table, |
106 | dest)) | 106 | dest)) |
107 | { | 107 | { |
108 | GNUNET_break (0); | 108 | GNUNET_break (0); |
109 | return; | 109 | return; |
110 | } | 110 | } |
111 | 111 | ||
112 | GNUNET_assert (GNUNET_OK == | 112 | GNUNET_assert (GNUNET_OK == |
113 | GNUNET_CONTAINER_multipeermap_put (routing_table, | 113 | GNUNET_CONTAINER_multipeermap_put (routing_table, |
114 | dest, new_routing_entry, | 114 | dest, new_routing_entry, |
115 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 115 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
116 | } | 116 | } |
@@ -125,13 +125,13 @@ GDS_Routing_search(struct GNUNET_PeerIdentity *source_peer, | |||
125 | struct GNUNET_PeerIdentity *destination_peer, | 125 | struct GNUNET_PeerIdentity *destination_peer, |
126 | struct GNUNET_PeerIdentity *prev_hop) | 126 | struct GNUNET_PeerIdentity *prev_hop) |
127 | { | 127 | { |
128 | struct RoutingTrail *trail; | 128 | struct RoutingTrail *trail; |
129 | trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer)); | 129 | trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer)); |
130 | 130 | ||
131 | if(trail == NULL) | 131 | if(trail == NULL) |
132 | return NULL; | 132 | return NULL; |
133 | 133 | ||
134 | return trail->next_hop; | 134 | return trail->next_hop; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
@@ -161,6 +161,7 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type, | |||
161 | const struct GNUNET_PeerIdentity *get_path, | 161 | const struct GNUNET_PeerIdentity *get_path, |
162 | const void *data, size_t data_size) | 162 | const void *data, size_t data_size) |
163 | { | 163 | { |
164 | |||
164 | } | 165 | } |
165 | 166 | ||
166 | 167 | ||
@@ -169,7 +170,7 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type, | |||
169 | */ | 170 | */ |
170 | void | 171 | void |
171 | GDS_ROUTING_init () | 172 | GDS_ROUTING_init () |
172 | { | 173 | { |
173 | routing_table = GNUNET_CONTAINER_multipeermap_create (DHT_MAX_RECENT * 4 / 3, GNUNET_NO); | 174 | routing_table = GNUNET_CONTAINER_multipeermap_create (DHT_MAX_RECENT * 4 / 3, GNUNET_NO); |
174 | } | 175 | } |
175 | 176 | ||