diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-04-30 12:14:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-04-30 12:14:42 +0000 |
commit | 6aa05b3843eceb17422cf924acc35b32fd1a8659 (patch) | |
tree | 69acf6b0814e1c80354ebbfe02e331045e32ffb6 /src/dht | |
parent | 7cc8739c7f232f7225ea684074a62830857e1738 (diff) | |
download | gnunet-6aa05b3843eceb17422cf924acc35b32fd1a8659.tar.gz gnunet-6aa05b3843eceb17422cf924acc35b32fd1a8659.zip |
-towards tracking paths and trails via datacache in wdht
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-wdht_clients.c | 70 | ||||
-rw-r--r-- | src/dht/gnunet-service-wdht_datacache.c | 18 | ||||
-rw-r--r-- | src/dht/gnunet-service-wdht_datacache.h | 9 | ||||
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.c | 169 | ||||
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.h | 14 |
5 files changed, 208 insertions, 72 deletions
diff --git a/src/dht/gnunet-service-wdht_clients.c b/src/dht/gnunet-service-wdht_clients.c index 896920e98..fa43fd350 100644 --- a/src/dht/gnunet-service-wdht_clients.c +++ b/src/dht/gnunet-service-wdht_clients.c | |||
@@ -165,7 +165,7 @@ struct ClientQueryRecord | |||
165 | size_t xquery_size; | 165 | size_t xquery_size; |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Number of entries in 'seen_replies'. | 168 | * Number of entries in @e seen_replies. |
169 | */ | 169 | */ |
170 | unsigned int seen_replies_count; | 170 | unsigned int seen_replies_count; |
171 | 171 | ||
@@ -281,7 +281,7 @@ process_pending_messages (struct ClientList *client); | |||
281 | 281 | ||
282 | 282 | ||
283 | /** | 283 | /** |
284 | * Callback called as a result of issuing a GNUNET_SERVER_notify_transmit_ready | 284 | * Callback called as a result of issuing a #GNUNET_SERVER_notify_transmit_ready() |
285 | * request. A ClientList is passed as closure, take the head of the list | 285 | * request. A ClientList is passed as closure, take the head of the list |
286 | * and copy it into buf, which has the result of sending the message to the | 286 | * and copy it into buf, which has the result of sending the message to the |
287 | * client. | 287 | * client. |
@@ -375,7 +375,7 @@ add_pending_message (struct ClientList *client, | |||
375 | 375 | ||
376 | 376 | ||
377 | /** | 377 | /** |
378 | * Closure for 'forward_reply' | 378 | * Closure for #forward_reply() |
379 | */ | 379 | */ |
380 | struct ForwardReplyContext | 380 | struct ForwardReplyContext |
381 | { | 381 | { |
@@ -401,7 +401,7 @@ struct ForwardReplyContext | |||
401 | size_t data_size; | 401 | size_t data_size; |
402 | 402 | ||
403 | /** | 403 | /** |
404 | * Do we need to copy 'pm' because it was already used? | 404 | * Do we need to copy @e pm because it was already used? |
405 | */ | 405 | */ |
406 | int do_copy; | 406 | int do_copy; |
407 | 407 | ||
@@ -470,14 +470,16 @@ remove_client_records (void *cls, const struct GNUNET_HashCode * key, void *valu | |||
470 | * each of the matching clients. With some tricky recycling | 470 | * each of the matching clients. With some tricky recycling |
471 | * of the buffer. | 471 | * of the buffer. |
472 | * | 472 | * |
473 | * @param cls the 'struct ForwardReplyContext' | 473 | * @param cls the `struct ForwardReplyContext` |
474 | * @param key current key | 474 | * @param key current key |
475 | * @param value value in the hash map, a ClientQueryRecord | 475 | * @param value value in the hash map, a ClientQueryRecord |
476 | * @return #GNUNET_YES (we should continue to iterate), | 476 | * @return #GNUNET_YES (we should continue to iterate), |
477 | * if the result is mal-formed, #GNUNET_NO | 477 | * if the result is mal-formed, #GNUNET_NO |
478 | */ | 478 | */ |
479 | static int | 479 | static int |
480 | forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value) | 480 | forward_reply (void *cls, |
481 | const struct GNUNET_HashCode *key, | ||
482 | void *value) | ||
481 | { | 483 | { |
482 | struct ForwardReplyContext *frc = cls; | 484 | struct ForwardReplyContext *frc = cls; |
483 | struct ClientQueryRecord *record = value; | 485 | struct ClientQueryRecord *record = value; |
@@ -682,6 +684,7 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration, | |||
682 | } | 684 | } |
683 | } | 685 | } |
684 | 686 | ||
687 | |||
685 | /** | 688 | /** |
686 | * Check if some client is monitoring GET messages and notify | 689 | * Check if some client is monitoring GET messages and notify |
687 | * them in that case. | 690 | * them in that case. |
@@ -701,7 +704,7 @@ GDS_CLIENTS_process_get (uint32_t options, | |||
701 | uint32_t desired_replication_level, | 704 | uint32_t desired_replication_level, |
702 | unsigned int path_length, | 705 | unsigned int path_length, |
703 | const struct GNUNET_PeerIdentity *path, | 706 | const struct GNUNET_PeerIdentity *path, |
704 | const struct GNUNET_HashCode * key) | 707 | const struct GNUNET_HashCode *key) |
705 | { | 708 | { |
706 | struct ClientMonitorRecord *m; | 709 | struct ClientMonitorRecord *m; |
707 | struct ClientList **cl; | 710 | struct ClientList **cl; |
@@ -758,16 +761,16 @@ GDS_CLIENTS_process_get (uint32_t options, | |||
758 | * Check if some client is monitoring PUT messages and notify | 761 | * Check if some client is monitoring PUT messages and notify |
759 | * them in that case. | 762 | * them in that case. |
760 | * | 763 | * |
761 | * @param options Options, for instance RecordRoute, DemultiplexEverywhere. | 764 | * @param options options, for instance RecordRoute, DemultiplexEverywhere. |
762 | * @param type The type of data in the request. | 765 | * @param type type of data in the request. |
763 | * @param hop_count Hop count so far. | 766 | * @param hop_count hop count so far. |
764 | * @param path_length number of entries in path (or 0 if not recorded). | 767 | * @param path_length number of entries in @a path (or 0 if not recorded). |
765 | * @param path peers on the PUT path (or NULL if not recorded). | 768 | * @param path peers on the PUT path (or NULL if not recorded). |
766 | * @param desired_replication_level Desired replication level. | 769 | * @param desired_replication_level desired replication level. |
767 | * @param exp Expiration time of the data. | 770 | * @param exp expiration time of the data. |
768 | * @param key Key under which data is to be stored. | 771 | * @param key key under which @a data is to be stored. |
769 | * @param data Pointer to the data carried. | 772 | * @param data pointer to the data carried. |
770 | * @param size Number of bytes in data. | 773 | * @param size number of bytes in @a data. |
771 | */ | 774 | */ |
772 | void | 775 | void |
773 | GDS_CLIENTS_process_put (uint32_t options, | 776 | GDS_CLIENTS_process_put (uint32_t options, |
@@ -913,7 +916,8 @@ transmit_next_request_task (void *cls, | |||
913 | * @param message the actual message received | 916 | * @param message the actual message received |
914 | */ | 917 | */ |
915 | static void | 918 | static void |
916 | handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client, | 919 | handle_dht_local_put (void *cls, |
920 | struct GNUNET_SERVER_Client *client, | ||
917 | const struct GNUNET_MessageHeader *message) | 921 | const struct GNUNET_MessageHeader *message) |
918 | { | 922 | { |
919 | const struct GNUNET_DHT_ClientPutMessage *put_msg; | 923 | const struct GNUNET_DHT_ClientPutMessage *put_msg; |
@@ -974,7 +978,8 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client, | |||
974 | * @param message the actual message received | 978 | * @param message the actual message received |
975 | */ | 979 | */ |
976 | static void | 980 | static void |
977 | handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, | 981 | handle_dht_local_get (void *cls, |
982 | struct GNUNET_SERVER_Client *client, | ||
978 | const struct GNUNET_MessageHeader *message) | 983 | const struct GNUNET_MessageHeader *message) |
979 | { | 984 | { |
980 | const struct GNUNET_DHT_ClientGetMessage *get; | 985 | const struct GNUNET_DHT_ClientGetMessage *get; |
@@ -1041,7 +1046,7 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
1041 | 1046 | ||
1042 | 1047 | ||
1043 | /** | 1048 | /** |
1044 | * Closure for 'find_by_unique_id'. | 1049 | * Closure for #find_by_unique_id(). |
1045 | */ | 1050 | */ |
1046 | struct FindByUniqueIdContext | 1051 | struct FindByUniqueIdContext |
1047 | { | 1052 | { |
@@ -1050,6 +1055,9 @@ struct FindByUniqueIdContext | |||
1050 | */ | 1055 | */ |
1051 | struct ClientQueryRecord *cqr; | 1056 | struct ClientQueryRecord *cqr; |
1052 | 1057 | ||
1058 | /** | ||
1059 | * Which ID are we looking for? | ||
1060 | */ | ||
1053 | uint64_t unique_id; | 1061 | uint64_t unique_id; |
1054 | }; | 1062 | }; |
1055 | 1063 | ||
@@ -1061,8 +1069,8 @@ struct FindByUniqueIdContext | |||
1061 | * | 1069 | * |
1062 | * @param cls the search context | 1070 | * @param cls the search context |
1063 | * @param key query for the lookup (not used) | 1071 | * @param key query for the lookup (not used) |
1064 | * @param value the 'struct ClientQueryRecord' | 1072 | * @param value the `struct ClientQueryRecord` |
1065 | * @return GNUNET_YES to continue iteration (result not yet found) | 1073 | * @return #GNUNET_YES to continue iteration (result not yet found) |
1066 | */ | 1074 | */ |
1067 | static int | 1075 | static int |
1068 | find_by_unique_id (void *cls, | 1076 | find_by_unique_id (void *cls, |
@@ -1087,7 +1095,8 @@ find_by_unique_id (void *cls, | |||
1087 | * @param message the actual message received | 1095 | * @param message the actual message received |
1088 | */ | 1096 | */ |
1089 | static void | 1097 | static void |
1090 | handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client *client, | 1098 | handle_dht_local_get_result_seen (void *cls, |
1099 | struct GNUNET_SERVER_Client *client, | ||
1091 | const struct GNUNET_MessageHeader *message) | 1100 | const struct GNUNET_MessageHeader *message) |
1092 | { | 1101 | { |
1093 | const struct GNUNET_DHT_ClientGetResultSeenMessage *seen; | 1102 | const struct GNUNET_DHT_ClientGetResultSeenMessage *seen; |
@@ -1138,7 +1147,7 @@ handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client *client | |||
1138 | 1147 | ||
1139 | 1148 | ||
1140 | /** | 1149 | /** |
1141 | * Closure for 'remove_by_unique_id'. | 1150 | * Closure for #remove_by_unique_id(). |
1142 | */ | 1151 | */ |
1143 | struct RemoveByUniqueIdContext | 1152 | struct RemoveByUniqueIdContext |
1144 | { | 1153 | { |
@@ -1164,7 +1173,9 @@ struct RemoveByUniqueIdContext | |||
1164 | * @return #GNUNET_YES (we should continue to iterate) | 1173 | * @return #GNUNET_YES (we should continue to iterate) |
1165 | */ | 1174 | */ |
1166 | static int | 1175 | static int |
1167 | remove_by_unique_id (void *cls, const struct GNUNET_HashCode * key, void *value) | 1176 | remove_by_unique_id (void *cls, |
1177 | const struct GNUNET_HashCode *key, | ||
1178 | void *value) | ||
1168 | { | 1179 | { |
1169 | const struct RemoveByUniqueIdContext *ctx = cls; | 1180 | const struct RemoveByUniqueIdContext *ctx = cls; |
1170 | struct ClientQueryRecord *record = value; | 1181 | struct ClientQueryRecord *record = value; |
@@ -1188,7 +1199,8 @@ remove_by_unique_id (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1188 | * | 1199 | * |
1189 | */ | 1200 | */ |
1190 | static void | 1201 | static void |
1191 | handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client, | 1202 | handle_dht_local_get_stop (void *cls, |
1203 | struct GNUNET_SERVER_Client *client, | ||
1192 | const struct GNUNET_MessageHeader *message) | 1204 | const struct GNUNET_MessageHeader *message) |
1193 | { | 1205 | { |
1194 | const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg = | 1206 | const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg = |
@@ -1219,7 +1231,8 @@ handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client, | |||
1219 | * | 1231 | * |
1220 | */ | 1232 | */ |
1221 | static void | 1233 | static void |
1222 | handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, | 1234 | handle_dht_local_monitor (void *cls, |
1235 | struct GNUNET_SERVER_Client *client, | ||
1223 | const struct GNUNET_MessageHeader *message) | 1236 | const struct GNUNET_MessageHeader *message) |
1224 | { | 1237 | { |
1225 | struct ClientMonitorRecord *r; | 1238 | struct ClientMonitorRecord *r; |
@@ -1251,10 +1264,10 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, | |||
1251 | * @param cls closure for the service | 1264 | * @param cls closure for the service |
1252 | * @param client the client we received this message from | 1265 | * @param client the client we received this message from |
1253 | * @param message the actual message received | 1266 | * @param message the actual message received |
1254 | * | ||
1255 | */ | 1267 | */ |
1256 | static void | 1268 | static void |
1257 | handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client, | 1269 | handle_dht_local_monitor_stop (void *cls, |
1270 | struct GNUNET_SERVER_Client *client, | ||
1258 | const struct GNUNET_MessageHeader *message) | 1271 | const struct GNUNET_MessageHeader *message) |
1259 | { | 1272 | { |
1260 | struct ClientMonitorRecord *r; | 1273 | struct ClientMonitorRecord *r; |
@@ -1343,7 +1356,6 @@ handle_client_disconnect (void *cls, | |||
1343 | } | 1356 | } |
1344 | 1357 | ||
1345 | 1358 | ||
1346 | |||
1347 | /** | 1359 | /** |
1348 | * Initialize client subsystem. | 1360 | * Initialize client subsystem. |
1349 | * | 1361 | * |
diff --git a/src/dht/gnunet-service-wdht_datacache.c b/src/dht/gnunet-service-wdht_datacache.c index 577aa8699..63b946811 100644 --- a/src/dht/gnunet-service-wdht_datacache.c +++ b/src/dht/gnunet-service-wdht_datacache.c | |||
@@ -56,6 +56,8 @@ static struct GNUNET_DATACACHE_Handle *datacache; | |||
56 | * @param key the query this reply is for | 56 | * @param key the query this reply is for |
57 | * @param put_path_length number of peers in @a put_path | 57 | * @param put_path_length number of peers in @a put_path |
58 | * @param put_path path the reply took on put | 58 | * @param put_path path the reply took on put |
59 | * @param get_path_length number of peers in @a get_path | ||
60 | * @param get_path path the reply took on get | ||
59 | * @param type type of the reply | 61 | * @param type type of the reply |
60 | * @param data_size number of bytes in @a data | 62 | * @param data_size number of bytes in @a data |
61 | * @param data application payload data | 63 | * @param data application payload data |
@@ -65,11 +67,14 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
65 | const struct GNUNET_HashCode *key, | 67 | const struct GNUNET_HashCode *key, |
66 | unsigned int put_path_length, | 68 | unsigned int put_path_length, |
67 | const struct GNUNET_PeerIdentity *put_path, | 69 | const struct GNUNET_PeerIdentity *put_path, |
70 | unsigned int get_path_length, | ||
71 | const struct GNUNET_PeerIdentity *get_path, | ||
68 | enum GNUNET_BLOCK_Type type, | 72 | enum GNUNET_BLOCK_Type type, |
69 | size_t data_size, | 73 | size_t data_size, |
70 | const void *data) | 74 | const void *data) |
71 | { | 75 | { |
72 | int r; | 76 | int r; |
77 | struct GNUNET_PeerIdentity path[get_path_length + put_path_length]; | ||
73 | 78 | ||
74 | if (NULL == datacache) | 79 | if (NULL == datacache) |
75 | { | 80 | { |
@@ -82,7 +87,12 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
82 | GNUNET_break (0); | 87 | GNUNET_break (0); |
83 | return; | 88 | return; |
84 | } | 89 | } |
85 | 90 | memcpy (path, | |
91 | put_path, | ||
92 | put_path_length * sizeof (struct GNUNET_PeerIdentity)); | ||
93 | memcpy (&path[put_path_length], | ||
94 | get_path, | ||
95 | get_path_length * sizeof (struct GNUNET_PeerIdentity)); | ||
86 | /* Put size is actual data size plus struct overhead plus path length (if any) */ | 96 | /* Put size is actual data size plus struct overhead plus path length (if any) */ |
87 | r = GNUNET_DATACACHE_put (datacache, | 97 | r = GNUNET_DATACACHE_put (datacache, |
88 | key, | 98 | key, |
@@ -90,8 +100,8 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
90 | data, | 100 | data, |
91 | type, | 101 | type, |
92 | expiration, | 102 | expiration, |
93 | put_path_length, | 103 | get_path_length + put_path_length, |
94 | put_path); | 104 | path); |
95 | if (GNUNET_OK == r) | 105 | if (GNUNET_OK == r) |
96 | GNUNET_STATISTICS_update (GDS_stats, | 106 | GNUNET_STATISTICS_update (GDS_stats, |
97 | gettext_noop ("# ITEMS stored in datacache"), 1, | 107 | gettext_noop ("# ITEMS stored in datacache"), 1, |
@@ -101,7 +111,7 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
101 | GNUNET_h2s (key), | 111 | GNUNET_h2s (key), |
102 | data_size, | 112 | data_size, |
103 | r, | 113 | r, |
104 | put_path_length); | 114 | put_path_length + get_path_length); |
105 | } | 115 | } |
106 | 116 | ||
107 | 117 | ||
diff --git a/src/dht/gnunet-service-wdht_datacache.h b/src/dht/gnunet-service-wdht_datacache.h index 39edbbb59..f9ea8847d 100644 --- a/src/dht/gnunet-service-wdht_datacache.h +++ b/src/dht/gnunet-service-wdht_datacache.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2009, 2010, 2011, 2015 Christian Grothoff (and other contributing authors) |
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 |
@@ -38,6 +38,8 @@ | |||
38 | * @param key the query this reply is for | 38 | * @param key the query this reply is for |
39 | * @param put_path_length number of peers in @a put_path | 39 | * @param put_path_length number of peers in @a put_path |
40 | * @param put_path path the reply took on put | 40 | * @param put_path path the reply took on put |
41 | * @param get_path_length number of peers in @a get_path | ||
42 | * @param get_path path the reply took on get | ||
41 | * @param type type of the reply | 43 | * @param type type of the reply |
42 | * @param data_size number of bytes in @a data | 44 | * @param data_size number of bytes in @a data |
43 | * @param data application payload data | 45 | * @param data application payload data |
@@ -47,7 +49,10 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
47 | const struct GNUNET_HashCode *key, | 49 | const struct GNUNET_HashCode *key, |
48 | unsigned int put_path_length, | 50 | unsigned int put_path_length, |
49 | const struct GNUNET_PeerIdentity *put_path, | 51 | const struct GNUNET_PeerIdentity *put_path, |
50 | enum GNUNET_BLOCK_Type type, size_t data_size, | 52 | unsigned int get_path_length, |
53 | const struct GNUNET_PeerIdentity *get_path, | ||
54 | enum GNUNET_BLOCK_Type type, | ||
55 | size_t data_size, | ||
51 | const void *data); | 56 | const void *data); |
52 | 57 | ||
53 | 58 | ||
diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c index fd6c62540..b74f7be39 100644 --- a/src/dht/gnunet-service-wdht_neighbours.c +++ b/src/dht/gnunet-service-wdht_neighbours.c | |||
@@ -152,12 +152,24 @@ struct FriendInfo | |||
152 | */ | 152 | */ |
153 | struct GNUNET_PeerIdentity id; | 153 | struct GNUNET_PeerIdentity id; |
154 | 154 | ||
155 | /** | ||
156 | * | ||
157 | */ | ||
155 | struct Trail *pred_head; | 158 | struct Trail *pred_head; |
156 | 159 | ||
160 | /** | ||
161 | * | ||
162 | */ | ||
157 | struct Trail *pred_tail; | 163 | struct Trail *pred_tail; |
158 | 164 | ||
165 | /** | ||
166 | * | ||
167 | */ | ||
159 | struct Trail *succ_head; | 168 | struct Trail *succ_head; |
160 | 169 | ||
170 | /** | ||
171 | * | ||
172 | */ | ||
161 | struct Trail *succ_tail; | 173 | struct Trail *succ_tail; |
162 | 174 | ||
163 | /** | 175 | /** |
@@ -168,15 +180,30 @@ struct FriendInfo | |||
168 | }; | 180 | }; |
169 | 181 | ||
170 | 182 | ||
183 | /** | ||
184 | * | ||
185 | */ | ||
171 | struct FingerTable; | 186 | struct FingerTable; |
172 | 187 | ||
173 | 188 | ||
189 | /** | ||
190 | * | ||
191 | */ | ||
174 | struct Finger | 192 | struct Finger |
175 | { | 193 | { |
194 | /** | ||
195 | * | ||
196 | */ | ||
176 | struct Trail *trail; | 197 | struct Trail *trail; |
177 | 198 | ||
199 | /** | ||
200 | * | ||
201 | */ | ||
178 | struct FingerTable *ft; | 202 | struct FingerTable *ft; |
179 | 203 | ||
204 | /** | ||
205 | * | ||
206 | */ | ||
180 | struct GNUNET_HashCode destination; | 207 | struct GNUNET_HashCode destination; |
181 | 208 | ||
182 | /** | 209 | /** |
@@ -349,9 +376,14 @@ struct TrailRouteMessage | |||
349 | struct GNUNET_MessageHeader header; | 376 | struct GNUNET_MessageHeader header; |
350 | 377 | ||
351 | /** | 378 | /** |
352 | * Zero, for alignment. | 379 | * #GNUNET_YES if the path should be recorded, #GNUNET_NO if not; in NBO. |
353 | */ | 380 | */ |
354 | uint32_t reserved GNUNET_PACKED; | 381 | uint16_t record_path GNUNET_PACKED; |
382 | |||
383 | /** | ||
384 | * Length of the recorded trail, 0 if @e record_path is #GNUNET_NO; in NBO. | ||
385 | */ | ||
386 | uint16_t path_length GNUNET_PACKED; | ||
355 | 387 | ||
356 | /** | 388 | /** |
357 | * Unique (random) identifier this peer will use to | 389 | * Unique (random) identifier this peer will use to |
@@ -359,7 +391,13 @@ struct TrailRouteMessage | |||
359 | */ | 391 | */ |
360 | struct GNUNET_HashCode trail_id; | 392 | struct GNUNET_HashCode trail_id; |
361 | 393 | ||
362 | /* followed by payload to send along the trail */ | 394 | /** |
395 | * Path the message has taken so far (excluding sender). | ||
396 | */ | ||
397 | /* struct GNUNET_PeerIdentity path[path_length]; */ | ||
398 | |||
399 | /* followed by payload (another `struct GNUNET_MessageHeader`) to | ||
400 | send along the trail */ | ||
363 | }; | 401 | }; |
364 | 402 | ||
365 | 403 | ||
@@ -576,14 +614,24 @@ GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key, | |||
576 | enum GNUNET_DHT_RouteOption options, | 614 | enum GNUNET_DHT_RouteOption options, |
577 | uint32_t desired_replication_level, | 615 | uint32_t desired_replication_level, |
578 | struct GNUNET_TIME_Absolute expiration_time, | 616 | struct GNUNET_TIME_Absolute expiration_time, |
579 | const void *data, size_t data_size) | 617 | const void *data, |
618 | size_t data_size) | ||
580 | { | 619 | { |
581 | GDS_DATACACHE_handle_put (expiration_time, | 620 | GDS_DATACACHE_handle_put (expiration_time, |
582 | key, | 621 | key, |
583 | 0, NULL, | 622 | 0, NULL, |
623 | 0, NULL, | ||
584 | block_type, | 624 | block_type, |
585 | data_size, | 625 | data_size, |
586 | data); | 626 | data); |
627 | GDS_CLIENTS_process_put (options, | ||
628 | block_type, | ||
629 | 0, 0, | ||
630 | 0, NULL, | ||
631 | expiration_time, | ||
632 | key, | ||
633 | data, | ||
634 | data_size); | ||
587 | } | 635 | } |
588 | 636 | ||
589 | 637 | ||
@@ -1078,6 +1126,47 @@ handle_dht_p2p_trail_destroy (void *cls, | |||
1078 | 1126 | ||
1079 | 1127 | ||
1080 | /** | 1128 | /** |
1129 | * Handler for a message we received along some trail. | ||
1130 | * | ||
1131 | * @param cls closure | ||
1132 | * @param trail_id trail identifier | ||
1133 | * @param message the message we got | ||
1134 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1135 | */ | ||
1136 | typedef int | ||
1137 | (*TrailHandlerCallback)(void *cls, | ||
1138 | const struct GNUNET_HashCode *trail_id, | ||
1139 | const struct GNUNET_MessageHandler *message); | ||
1140 | |||
1141 | |||
1142 | /** | ||
1143 | * Definition of a handler for a message received along some trail. | ||
1144 | */ | ||
1145 | struct TrailHandler | ||
1146 | { | ||
1147 | /** | ||
1148 | * NULL for end-of-list. | ||
1149 | */ | ||
1150 | TrailHandlerCallback callback; | ||
1151 | |||
1152 | /** | ||
1153 | * Closure for @e callback. | ||
1154 | */ | ||
1155 | void *cls; | ||
1156 | |||
1157 | /** | ||
1158 | * Message type this handler addresses. | ||
1159 | */ | ||
1160 | uint16_t message_type; | ||
1161 | |||
1162 | /** | ||
1163 | * Use 0 for variable-size. | ||
1164 | */ | ||
1165 | uint16_t message_size; | ||
1166 | }; | ||
1167 | |||
1168 | |||
1169 | /** | ||
1081 | * Handle a `struct TrailRouteMessage`. | 1170 | * Handle a `struct TrailRouteMessage`. |
1082 | * | 1171 | * |
1083 | * @param cls closure (NULL) | 1172 | * @param cls closure (NULL) |
@@ -1087,8 +1176,8 @@ handle_dht_p2p_trail_destroy (void *cls, | |||
1087 | */ | 1176 | */ |
1088 | static int | 1177 | static int |
1089 | handle_dht_p2p_trail_route (void *cls, | 1178 | handle_dht_p2p_trail_route (void *cls, |
1090 | const struct GNUNET_PeerIdentity *peer, | 1179 | const struct GNUNET_PeerIdentity *peer, |
1091 | const struct GNUNET_MessageHeader *message) | 1180 | const struct GNUNET_MessageHeader *message) |
1092 | { | 1181 | { |
1093 | const struct TrailRouteMessage *trm; | 1182 | const struct TrailRouteMessage *trm; |
1094 | 1183 | ||
@@ -1100,7 +1189,6 @@ handle_dht_p2p_trail_route (void *cls, | |||
1100 | * 1.a.1 if trail not finished with us, continue to forward | 1189 | * 1.a.1 if trail not finished with us, continue to forward |
1101 | * 1.a.2 otherwise handle body message embedded in trail | 1190 | * 1.a.2 otherwise handle body message embedded in trail |
1102 | */ | 1191 | */ |
1103 | |||
1104 | return GNUNET_OK; | 1192 | return GNUNET_OK; |
1105 | } | 1193 | } |
1106 | 1194 | ||
@@ -1110,13 +1198,13 @@ handle_dht_p2p_trail_route (void *cls, | |||
1110 | * message. | 1198 | * message. |
1111 | * | 1199 | * |
1112 | * @param cls closure (NULL) | 1200 | * @param cls closure (NULL) |
1113 | * @param peer sender identity | 1201 | * @param trail_id path to the originator |
1114 | * @param message the finger setup message | 1202 | * @param message the finger setup message |
1115 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1203 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1116 | */ | 1204 | */ |
1117 | static int | 1205 | static int |
1118 | handle_dht_p2p_successor_find (void *cls, | 1206 | handle_dht_p2p_successor_find (void *cls, |
1119 | const struct GNUNET_PeerIdentity *peer, | 1207 | const struct GNUNET_HashCode *trail_id, |
1120 | const struct GNUNET_MessageHeader *message) | 1208 | const struct GNUNET_MessageHeader *message) |
1121 | { | 1209 | { |
1122 | const struct FindSuccessorMessage *fsm; | 1210 | const struct FindSuccessorMessage *fsm; |
@@ -1125,7 +1213,10 @@ handle_dht_p2p_successor_find (void *cls, | |||
1125 | // locate trail (for sending reply), if not exists, fail nicely. | 1213 | // locate trail (for sending reply), if not exists, fail nicely. |
1126 | // otherwise, go to datacache and return 'top k' elements closest to 'key' | 1214 | // otherwise, go to datacache and return 'top k' elements closest to 'key' |
1127 | // as "PUT" messages via the trail (need to extend DB API!) | 1215 | // as "PUT" messages via the trail (need to extend DB API!) |
1128 | 1216 | #if 0 | |
1217 | GDS_DATACACHE_get_successors (trail_id, | ||
1218 | key); | ||
1219 | #endif | ||
1129 | return GNUNET_OK; | 1220 | return GNUNET_OK; |
1130 | } | 1221 | } |
1131 | 1222 | ||
@@ -1134,13 +1225,13 @@ handle_dht_p2p_successor_find (void *cls, | |||
1134 | * Handle a `struct PeerGetMessage`. | 1225 | * Handle a `struct PeerGetMessage`. |
1135 | * | 1226 | * |
1136 | * @param cls closure (NULL) | 1227 | * @param cls closure (NULL) |
1137 | * @param peer sender identity | 1228 | * @param trail_id path to the originator |
1138 | * @param message the peer get message | 1229 | * @param message the peer get message |
1139 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1230 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1140 | */ | 1231 | */ |
1141 | static int | 1232 | static int |
1142 | handle_dht_p2p_peer_get (void *cls, | 1233 | handle_dht_p2p_peer_get (void *cls, |
1143 | const struct GNUNET_PeerIdentity *peer, | 1234 | const struct GNUNET_HashCode *trail_id, |
1144 | const struct GNUNET_MessageHeader *message) | 1235 | const struct GNUNET_MessageHeader *message) |
1145 | { | 1236 | { |
1146 | const struct PeerGetMessage *pgm; | 1237 | const struct PeerGetMessage *pgm; |
@@ -1165,20 +1256,34 @@ handle_dht_p2p_peer_get (void *cls, | |||
1165 | * Handle a `struct PeerGetResultMessage`. | 1256 | * Handle a `struct PeerGetResultMessage`. |
1166 | * | 1257 | * |
1167 | * @param cls closure (NULL) | 1258 | * @param cls closure (NULL) |
1168 | * @param peer sender identity | 1259 | * @param trail_id path to the originator |
1169 | * @param message the peer get result message | 1260 | * @param message the peer get result message |
1170 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1261 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1171 | */ | 1262 | */ |
1172 | static int | 1263 | static int |
1173 | handle_dht_p2p_peer_get_result (void *cls, | 1264 | handle_dht_p2p_peer_get_result (void *cls, |
1174 | const struct GNUNET_PeerIdentity *peer, | 1265 | const struct GNUNET_HashCode *trail_id, |
1175 | const struct GNUNET_MessageHeader *message) | 1266 | const struct GNUNET_MessageHeader *message) |
1176 | { | 1267 | { |
1177 | const struct PeerGetResultMessage *pgrm; | 1268 | const struct PeerGetResultMessage *pgrm; |
1178 | 1269 | ||
1179 | pgrm = (const struct PeerGetResultMessage *) message; | 1270 | pgrm = (const struct PeerGetResultMessage *) message; |
1180 | // pretty much: parse, & pass to client (there is some call for that...) | 1271 | // pretty much: parse, & pass to client (there is some call for that...) |
1181 | 1272 | ||
1273 | #if 0 | ||
1274 | GDS_CLIENTS_process_get (options, | ||
1275 | type, | ||
1276 | 0, 0, | ||
1277 | path_length, path, | ||
1278 | key); | ||
1279 | (void) GDS_DATACACHE_handle_get (trail_id, | ||
1280 | key, | ||
1281 | type, | ||
1282 | xquery, | ||
1283 | xquery_size, | ||
1284 | &reply_bf, | ||
1285 | reply_bf_mutator); | ||
1286 | #endif | ||
1182 | return GNUNET_OK; | 1287 | return GNUNET_OK; |
1183 | } | 1288 | } |
1184 | 1289 | ||
@@ -1187,14 +1292,14 @@ handle_dht_p2p_peer_get_result (void *cls, | |||
1187 | * Handle a `struct PeerPutMessage`. | 1292 | * Handle a `struct PeerPutMessage`. |
1188 | * | 1293 | * |
1189 | * @param cls closure (NULL) | 1294 | * @param cls closure (NULL) |
1190 | * @param peer sender identity | 1295 | * @param trail_id path to the originator |
1191 | * @param message the peer put message | 1296 | * @param message the peer put message |
1192 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1297 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1193 | */ | 1298 | */ |
1194 | static int | 1299 | static int |
1195 | handle_dht_p2p_peer_put (void *cls, | 1300 | handle_dht_p2p_peer_put (void *cls, |
1196 | const struct GNUNET_PeerIdentity *peer, | 1301 | const struct GNUNET_HashCode *trail_id, |
1197 | const struct GNUNET_MessageHeader *message) | 1302 | const struct GNUNET_MessageHeader *message) |
1198 | { | 1303 | { |
1199 | const struct PeerGetResultMessage *pgrm; | 1304 | const struct PeerGetResultMessage *pgrm; |
1200 | 1305 | ||
@@ -1206,6 +1311,22 @@ handle_dht_p2p_peer_put (void *cls, | |||
1206 | * 2 use the API to add the value in the "database". Check on the xdht file, how to do it. | 1311 | * 2 use the API to add the value in the "database". Check on the xdht file, how to do it. |
1207 | * 3 Did i a have to return a notification or did i have to return GNUNET_[OK|SYSERR]? | 1312 | * 3 Did i a have to return a notification or did i have to return GNUNET_[OK|SYSERR]? |
1208 | */ | 1313 | */ |
1314 | #if 0 | ||
1315 | GDS_DATACACHE_handle_put (expiration_time, | ||
1316 | key, | ||
1317 | path_length, path, | ||
1318 | block_type, | ||
1319 | data_size, | ||
1320 | data); | ||
1321 | GDS_CLIENTS_process_put (options, | ||
1322 | block_type, | ||
1323 | 0, 0, | ||
1324 | path_length, path, | ||
1325 | expiration_time, | ||
1326 | key, | ||
1327 | data, | ||
1328 | data_size); | ||
1329 | #endif | ||
1209 | return GNUNET_OK; | 1330 | return GNUNET_OK; |
1210 | } | 1331 | } |
1211 | 1332 | ||
@@ -1230,18 +1351,6 @@ GDS_NEIGHBOURS_init (void) | |||
1230 | { &handle_dht_p2p_trail_route, | 1351 | { &handle_dht_p2p_trail_route, |
1231 | GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE, | 1352 | GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE, |
1232 | 0}, | 1353 | 0}, |
1233 | { &handle_dht_p2p_successor_find, | ||
1234 | GNUNET_MESSAGE_TYPE_WDHT_SUCCESSOR_FIND, | ||
1235 | sizeof (struct FindSuccessorMessage) }, | ||
1236 | { &handle_dht_p2p_peer_get, | ||
1237 | GNUNET_MESSAGE_TYPE_WDHT_GET, | ||
1238 | sizeof (struct PeerGetMessage) }, | ||
1239 | { &handle_dht_p2p_peer_get_result, | ||
1240 | GNUNET_MESSAGE_TYPE_WDHT_GET_RESULT, | ||
1241 | 0}, | ||
1242 | { &handle_dht_p2p_peer_put, | ||
1243 | GNUNET_MESSAGE_TYPE_WDHT_PUT, | ||
1244 | 0}, | ||
1245 | {NULL, 0, 0} | 1354 | {NULL, 0, 0} |
1246 | }; | 1355 | }; |
1247 | 1356 | ||
diff --git a/src/dht/gnunet-service-wdht_neighbours.h b/src/dht/gnunet-service-wdht_neighbours.h index 4dba04da2..cc6be45a3 100644 --- a/src/dht/gnunet-service-wdht_neighbours.h +++ b/src/dht/gnunet-service-wdht_neighbours.h | |||
@@ -72,13 +72,13 @@ GDS_NEIGHBOURS_handle_get (const struct GNUNET_HashCode *key, | |||
72 | * Send the get result to requesting client. | 72 | * Send the get result to requesting client. |
73 | * | 73 | * |
74 | * @param trail_id trail identifying where to send the result to, NULL for us | 74 | * @param trail_id trail identifying where to send the result to, NULL for us |
75 | * @param key Key of the requested data. | 75 | * @param key key of the requested data. |
76 | * @param type Block type | 76 | * @param type block type |
77 | * @param put_path_length Number of peers in @a put_path | 77 | * @param put_path_length number of peers in @a put_path |
78 | * @param put_path Path taken to put the data at its stored location. | 78 | * @param put_path path taken to put the data at its stored location. |
79 | * @param expiration When will this result expire? | 79 | * @param expiration when will this result expire? |
80 | * @param data Payload to store | 80 | * @param data payload to store |
81 | * @param data_size Size of the @a data | 81 | * @param data_size size of the @a data |
82 | */ | 82 | */ |
83 | void | 83 | void |
84 | GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *trail_id, | 84 | GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *trail_id, |