diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-31 14:44:41 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-31 14:44:41 +0100 |
commit | 2503d0fdf24b506999ed927240c55d3863e6163c (patch) | |
tree | 25ee56b2b9abf775057b2872f9770341ea64328a /src/dht | |
parent | fbb30a3aff6bdc2b33ad8c97f0a69f9181853a39 (diff) | |
download | gnunet-2503d0fdf24b506999ed927240c55d3863e6163c.tar.gz gnunet-2503d0fdf24b506999ed927240c55d3863e6163c.zip |
add method to record and print DHT routes to DHT command-line tools
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-dht-get.c | 31 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 18 |
2 files changed, 43 insertions, 6 deletions
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index 8a1b836f6..ce479dc3e 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -148,13 +148,36 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
148 | const struct GNUNET_PeerIdentity *get_path, | 148 | const struct GNUNET_PeerIdentity *get_path, |
149 | unsigned int get_path_length, | 149 | unsigned int get_path_length, |
150 | const struct GNUNET_PeerIdentity *put_path, | 150 | const struct GNUNET_PeerIdentity *put_path, |
151 | unsigned int put_path_length, enum GNUNET_BLOCK_Type type, | 151 | unsigned int put_path_length, |
152 | size_t size, const void *data) | 152 | enum GNUNET_BLOCK_Type type, |
153 | size_t size, | ||
154 | const void *data) | ||
153 | { | 155 | { |
154 | FPRINTF (stdout, | 156 | FPRINTF (stdout, |
155 | _("Result %d, type %d:\n%.*s\n"), | 157 | _("Result %d, type %d:\n%.*s\n"), |
156 | result_count, type, | 158 | result_count, |
157 | (unsigned int) size, (char *) data); | 159 | type, |
160 | (unsigned int) size, | ||
161 | (char *) data); | ||
162 | if (verbose) | ||
163 | { | ||
164 | FPRINTF (stdout, | ||
165 | " GET path: "); | ||
166 | for (unsigned int i=0;i<get_path_length;i++) | ||
167 | FPRINTF (stdout, | ||
168 | "%s%s", | ||
169 | (0 == i) ? "" : "-", | ||
170 | GNUNET_i2s (&get_path[i])); | ||
171 | FPRINTF (stdout, | ||
172 | "\n PUT path: "); | ||
173 | for (unsigned int i=0;i<put_path_length;i++) | ||
174 | FPRINTF (stdout, | ||
175 | "%s%s", | ||
176 | (0 == i) ? "" : "-", | ||
177 | GNUNET_i2s (&put_path[i])); | ||
178 | FPRINTF (stdout, | ||
179 | "\n"); | ||
180 | } | ||
158 | result_count++; | 181 | result_count++; |
159 | } | 182 | } |
160 | 183 | ||
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 1f3df1d35..9b17da01f 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -57,11 +57,16 @@ static unsigned int replication = 5; | |||
57 | static int verbose; | 57 | static int verbose; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Use DHT demultixplex_everywhere | 60 | * Use #GNUNET_DHT_DEMULTIPLEX_EVERYWHERE. |
61 | */ | 61 | */ |
62 | static int demultixplex_everywhere; | 62 | static int demultixplex_everywhere; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Use #GNUNET_DHT_RO_RECORD_ROUTE. | ||
66 | */ | ||
67 | static int record_route; | ||
68 | |||
69 | /** | ||
65 | * Handle to the DHT | 70 | * Handle to the DHT |
66 | */ | 71 | */ |
67 | static struct GNUNET_DHT_Handle *dht_handle; | 72 | static struct GNUNET_DHT_Handle *dht_handle; |
@@ -144,6 +149,7 @@ run (void *cls, | |||
144 | const struct GNUNET_CONFIGURATION_Handle *c) | 149 | const struct GNUNET_CONFIGURATION_Handle *c) |
145 | { | 150 | { |
146 | struct GNUNET_TIME_Absolute expiration; | 151 | struct GNUNET_TIME_Absolute expiration; |
152 | enum GNUNET_DHT_RouteOption ro; | ||
147 | 153 | ||
148 | cfg = c; | 154 | cfg = c; |
149 | if ((NULL == query_key) || (NULL == data)) | 155 | if ((NULL == query_key) || (NULL == data)) |
@@ -171,10 +177,15 @@ run (void *cls, | |||
171 | if (verbose) | 177 | if (verbose) |
172 | FPRINTF (stderr, _("Issuing put request for `%s' with data `%s'!\n"), | 178 | FPRINTF (stderr, _("Issuing put request for `%s' with data `%s'!\n"), |
173 | query_key, data); | 179 | query_key, data); |
180 | ro = GNUNET_DHT_RO_NONE; | ||
181 | if (demultixplex_everywhere) | ||
182 | ro |= GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; | ||
183 | if (record_route) | ||
184 | ro |= GNUNET_DHT_RO_RECORD_ROUTE; | ||
174 | GNUNET_DHT_put (dht_handle, | 185 | GNUNET_DHT_put (dht_handle, |
175 | &key, | 186 | &key, |
176 | replication, | 187 | replication, |
177 | (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, | 188 | ro, |
178 | query_type, | 189 | query_type, |
179 | strlen (data), | 190 | strlen (data), |
180 | data, | 191 | data, |
@@ -203,6 +214,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
203 | {'r', "replication", "LEVEL", | 214 | {'r', "replication", "LEVEL", |
204 | gettext_noop ("how many replicas to create"), | 215 | gettext_noop ("how many replicas to create"), |
205 | 1, &GNUNET_GETOPT_set_uint, &replication}, | 216 | 1, &GNUNET_GETOPT_set_uint, &replication}, |
217 | {'R', "record", NULL, | ||
218 | gettext_noop ("use DHT's record route option"), | ||
219 | 0, &GNUNET_GETOPT_set_one, &record_route}, | ||
206 | {'t', "type", "TYPE", | 220 | {'t', "type", "TYPE", |
207 | gettext_noop ("the type to insert data as"), | 221 | gettext_noop ("the type to insert data as"), |
208 | 1, &GNUNET_GETOPT_set_uint, &query_type}, | 222 | 1, &GNUNET_GETOPT_set_uint, &query_type}, |