diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-04-22 19:52:48 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-04-22 19:52:48 +0000 |
commit | 5047e9708f1083e83b49aa806fd8e4696a5a31d9 (patch) | |
tree | 1058fcee7623970e2e346f64d8e6b92631232dcb /src/dht/gnunet-dht-monitor.c | |
parent | e2bf225a32bb93731b574ad698f20acbb92a5803 (diff) | |
download | gnunet-5047e9708f1083e83b49aa806fd8e4696a5a31d9.tar.gz gnunet-5047e9708f1083e83b49aa806fd8e4696a5a31d9.zip |
- Adapted command line client to new monitor API
Diffstat (limited to 'src/dht/gnunet-dht-monitor.c')
-rw-r--r-- | src/dht/gnunet-dht-monitor.c | 113 |
1 files changed, 89 insertions, 24 deletions
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c index fc110a8d8..6f2faa99e 100644 --- a/src/dht/gnunet-dht-monitor.c +++ b/src/dht/gnunet-dht-monitor.c | |||
@@ -112,45 +112,105 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
112 | 112 | ||
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Callback called on each request going through the DHT. | 115 | * Callback called on each GET request going through the DHT. |
116 | * | 116 | * |
117 | * @param cls Closure. | 117 | * @param cls Closure. |
118 | * @param mtype Type of the DHT message monitored. | 118 | * @param options Options, for instance RecordRoute, DemultiplexEverywhere. |
119 | * @param exp When will this value expire. | 119 | * @param type The type of data in the request. |
120 | * @param key Key of the result/request. | 120 | * @param hop_count Hop count so far. |
121 | * @param get_path Peers on reply path (or NULL if not recorded). | 121 | * @param path_length number of entries in path (or 0 if not recorded). |
122 | * @param path peers on the GET path (or NULL if not recorded). | ||
123 | * @param desired_replication_level Desired replication level. | ||
124 | * @param key Key of the requested data. | ||
125 | */ | ||
126 | void | ||
127 | get_callback (void *cls, | ||
128 | enum GNUNET_DHT_RouteOption options, | ||
129 | enum GNUNET_BLOCK_Type type, | ||
130 | uint32_t hop_count, | ||
131 | uint32_t desired_replication_level, | ||
132 | unsigned int path_length, | ||
133 | const struct GNUNET_PeerIdentity *path, | ||
134 | const GNUNET_HashCode * key) | ||
135 | { | ||
136 | FPRINTF (stdout, "Result %d, operation: %s, type %d\n", | ||
137 | result_count, | ||
138 | "GET", | ||
139 | type); | ||
140 | result_count++; | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * Callback called on each GET reply going through the DHT. | ||
145 | * | ||
146 | * @param cls Closure. | ||
147 | * @param type The type of data in the result. | ||
148 | * @param get_path Peers on GET path (or NULL if not recorded). | ||
122 | * @param get_path_length number of entries in get_path. | 149 | * @param get_path_length number of entries in get_path. |
123 | * @param put_path peers on the PUT path (or NULL if not recorded). | 150 | * @param put_path peers on the PUT path (or NULL if not recorded). |
124 | * @param put_path_length number of entries in get_path. | 151 | * @param put_path_length number of entries in get_path. |
125 | * @param desired_replication_level Desired replication level. | 152 | * @param exp Expiration time of the data. |
126 | * @param options Options of the route (record, demultiplex, etc) | 153 | * @param key Key of the data. |
127 | * @param type Type of the result/request. | ||
128 | * @param data Pointer to the result data. | 154 | * @param data Pointer to the result data. |
129 | * @param size Number of bytes in data. | 155 | * @param size Number of bytes in data. |
130 | */ | 156 | */ |
131 | void | 157 | void |
132 | monitor_callback (void *cls, | 158 | get_resp_callback (void *cls, |
133 | uint16_t mtype, | 159 | enum GNUNET_BLOCK_Type type, |
134 | struct GNUNET_TIME_Absolute exp, | 160 | const struct GNUNET_PeerIdentity *get_path, |
135 | const GNUNET_HashCode * key, | 161 | unsigned int get_path_length, |
136 | const struct GNUNET_PeerIdentity *get_path, | 162 | const struct GNUNET_PeerIdentity *put_path, |
137 | unsigned int get_path_length, | 163 | unsigned int put_path_length, |
138 | const struct GNUNET_PeerIdentity *put_path, | 164 | struct GNUNET_TIME_Absolute exp, |
139 | unsigned int put_path_length, | 165 | const GNUNET_HashCode * key, |
140 | uint32_t desired_replication_level, | 166 | const void *data, |
141 | enum GNUNET_DHT_RouteOption options, | 167 | size_t size) |
142 | enum GNUNET_BLOCK_Type type, | ||
143 | const void *data, | ||
144 | size_t size) | ||
145 | { | 168 | { |
146 | FPRINTF (stdout, "Result %d, type %d:\n%.*s\n", | 169 | FPRINTF (stdout, "Result %d, operation: %s, type %d:\n%.*s\n", |
147 | result_count, | 170 | result_count, |
171 | "GET_RESP", | ||
148 | type, | 172 | type, |
149 | (unsigned int) size, | 173 | (unsigned int) size, |
150 | (char *) data); | 174 | (char *) data); |
151 | result_count++; | 175 | result_count++; |
152 | } | 176 | } |
153 | 177 | ||
178 | /** | ||
179 | * Callback called on each PUT request going through the DHT. | ||
180 | * | ||
181 | * @param cls Closure. | ||
182 | * @param options Options, for instance RecordRoute, DemultiplexEverywhere. | ||
183 | * @param type The type of data in the request. | ||
184 | * @param hop_count Hop count so far. | ||
185 | * @param path_length number of entries in path (or 0 if not recorded). | ||
186 | * @param path peers on the PUT path (or NULL if not recorded). | ||
187 | * @param desired_replication_level Desired replication level. | ||
188 | * @param exp Expiration time of the data. | ||
189 | * @param key Key under which data is to be stored. | ||
190 | * @param data Pointer to the data carried. | ||
191 | * @param size Number of bytes in data. | ||
192 | */ | ||
193 | void | ||
194 | put_callback (void *cls, | ||
195 | enum GNUNET_DHT_RouteOption options, | ||
196 | enum GNUNET_BLOCK_Type type, | ||
197 | uint32_t hop_count, | ||
198 | uint32_t desired_replication_level, | ||
199 | unsigned int path_length, | ||
200 | const struct GNUNET_PeerIdentity *path, | ||
201 | struct GNUNET_TIME_Absolute exp, | ||
202 | const GNUNET_HashCode * key, | ||
203 | const void *data, | ||
204 | size_t size) | ||
205 | { | ||
206 | FPRINTF (stdout, "Result %d, operation: %s, type %d:\n%.*s\n", | ||
207 | result_count, | ||
208 | "PUT", | ||
209 | type, | ||
210 | (unsigned int) size, | ||
211 | (char *) data); | ||
212 | result_count++; | ||
213 | } | ||
154 | 214 | ||
155 | /** | 215 | /** |
156 | * Main function that will be run by the scheduler. | 216 | * Main function that will be run by the scheduler. |
@@ -208,8 +268,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
208 | GNUNET_SCHEDULER_add_delayed (timeout, &cleanup_task, NULL); | 268 | GNUNET_SCHEDULER_add_delayed (timeout, &cleanup_task, NULL); |
209 | if (verbose) | 269 | if (verbose) |
210 | FPRINTF (stderr, "Issuing MONITOR request for %s!\n", query_key); | 270 | FPRINTF (stderr, "Issuing MONITOR request for %s!\n", query_key); |
211 | monitor_handle = GNUNET_DHT_monitor_start (dht_handle, block_type, key, | 271 | monitor_handle = GNUNET_DHT_monitor_start (dht_handle, |
212 | &monitor_callback, NULL); | 272 | block_type, |
273 | key, | ||
274 | &get_callback, | ||
275 | &get_resp_callback, | ||
276 | &put_callback, | ||
277 | NULL); | ||
213 | if (verbose) | 278 | if (verbose) |
214 | FPRINTF (stderr, "%s", "MONITOR started!\n"); | 279 | FPRINTF (stderr, "%s", "MONITOR started!\n"); |
215 | GNUNET_free_non_null (key); | 280 | GNUNET_free_non_null (key); |