diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-10 16:24:53 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-10 16:24:53 +0000 |
commit | cab00729856bdbe0c60f298a79b1f12aac2aee8b (patch) | |
tree | 14ea5bf0b19dca878e5f5aafcf69599e3e4726b7 /src/dht/test_dht_api.c | |
parent | 0cd34604e5497edad8fa3a761ef626ad7168c90a (diff) | |
download | gnunet-cab00729856bdbe0c60f298a79b1f12aac2aee8b.tar.gz gnunet-cab00729856bdbe0c60f298a79b1f12aac2aee8b.zip |
api change to allow client to set DHT malicious, still need to implement it on the dht driver side
Diffstat (limited to 'src/dht/test_dht_api.c')
-rw-r--r-- | src/dht/test_dht_api.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index f7ee94fa4..29606db60 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -110,10 +110,10 @@ static void | |||
110 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 110 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
111 | { | 111 | { |
112 | /* do work here */ | 112 | /* do work here */ |
113 | sleep(2); | ||
113 | GNUNET_SCHEDULER_cancel (sched, die_task); | 114 | GNUNET_SCHEDULER_cancel (sched, die_task); |
114 | 115 | ||
115 | GNUNET_DHT_disconnect (p1.dht_handle); | 116 | GNUNET_DHT_disconnect (p1.dht_handle); |
116 | |||
117 | die_task = GNUNET_SCHEDULER_NO_TASK; | 117 | die_task = GNUNET_SCHEDULER_NO_TASK; |
118 | 118 | ||
119 | if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) | 119 | if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) |
@@ -166,6 +166,63 @@ end_badly () | |||
166 | * @param cls closure | 166 | * @param cls closure |
167 | * @param tc context information (why was this task triggered now) | 167 | * @param tc context information (why was this task triggered now) |
168 | */ | 168 | */ |
169 | void test_set_peer_malicious_drop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
170 | { | ||
171 | struct PeerContext *peer = cls; | ||
172 | |||
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_drop!\n"); | ||
174 | if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) | ||
175 | GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | ||
176 | |||
177 | GNUNET_assert (peer->dht_handle != NULL); | ||
178 | |||
179 | GNUNET_DHT_set_malicious_dropper (peer->dht_handle, &end, &p1); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * Signature of the main function of a task. | ||
184 | * | ||
185 | * @param cls closure | ||
186 | * @param tc context information (why was this task triggered now) | ||
187 | */ | ||
188 | void test_set_peer_malicious_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
189 | { | ||
190 | struct PeerContext *peer = cls; | ||
191 | |||
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_put!\n"); | ||
193 | if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) | ||
194 | GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | ||
195 | |||
196 | GNUNET_assert (peer->dht_handle != NULL); | ||
197 | |||
198 | GNUNET_DHT_set_malicious_putter (peer->dht_handle, 750, &test_set_peer_malicious_drop, &p1); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Signature of the main function of a task. | ||
203 | * | ||
204 | * @param cls closure | ||
205 | * @param tc context information (why was this task triggered now) | ||
206 | */ | ||
207 | void test_set_peer_malicious_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
208 | { | ||
209 | struct PeerContext *peer = cls; | ||
210 | |||
211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_get!\n"); | ||
212 | if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT) | ||
213 | GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | ||
214 | |||
215 | GNUNET_assert (peer->dht_handle != NULL); | ||
216 | |||
217 | GNUNET_DHT_set_malicious_getter (peer->dht_handle, 1500, &test_set_peer_malicious_put, &p1); | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * Signature of the main function of a task. | ||
222 | * | ||
223 | * @param cls closure | ||
224 | * @param tc context information (why was this task triggered now) | ||
225 | */ | ||
169 | void | 226 | void |
170 | test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 227 | test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
171 | { | 228 | { |
@@ -177,7 +234,7 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
177 | 234 | ||
178 | GNUNET_assert (peer->dht_handle != NULL); | 235 | GNUNET_assert (peer->dht_handle != NULL); |
179 | 236 | ||
180 | GNUNET_DHT_find_peer_stop (peer->find_peer_handle, &end, &p1); | 237 | GNUNET_DHT_find_peer_stop (peer->find_peer_handle, &test_set_peer_malicious_get, &p1); |
181 | 238 | ||
182 | //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1); | 239 | //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1); |
183 | 240 | ||