diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-25 00:30:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-25 00:30:00 +0000 |
commit | d0701eb6315fc3f5aca74415bbf0ff7418409f87 (patch) | |
tree | fcacb97bbcca542ce9493001c825fd265cb8a801 /src/transport/transport-testing.h | |
parent | 9bfb8bff3fd253407530c76c7590b33bacf033f1 (diff) | |
download | gnunet-d0701eb6315fc3f5aca74415bbf0ff7418409f87.tar.gz gnunet-d0701eb6315fc3f5aca74415bbf0ff7418409f87.zip |
switching transport tests to new MQ-based transport API
Diffstat (limited to 'src/transport/transport-testing.h')
-rw-r--r-- | src/transport/transport-testing.h | 153 |
1 files changed, 45 insertions, 108 deletions
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h index 806b8c5f9..87e647c2f 100644 --- a/src/transport/transport-testing.h +++ b/src/transport/transport-testing.h | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_hello_lib.h" |
32 | #include "gnunet_transport_service.h" | 32 | #include "gnunet_transport_service.h" |
33 | #include "gnunet_transport_core_service.h" | ||
34 | #include "gnunet_transport_manipulation_service.h" | ||
33 | #include "gnunet_testing_lib.h" | 35 | #include "gnunet_testing_lib.h" |
34 | 36 | ||
35 | 37 | ||
@@ -47,19 +49,6 @@ struct GNUNET_TRANSPORT_TESTING_Handle; | |||
47 | 49 | ||
48 | 50 | ||
49 | /** | 51 | /** |
50 | * Callback when two peers are connected and both have called the connect callback | ||
51 | * to notify clients about a new peer | ||
52 | * | ||
53 | * @param p FIXME: remove ASAP. | ||
54 | * @param cls closure | ||
55 | */ | ||
56 | typedef void | ||
57 | (*GNUNET_TRANSPORT_TESTING_StartCallback) (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, | ||
58 | void *cls); | ||
59 | |||
60 | |||
61 | |||
62 | /** | ||
63 | * Context for a single peer | 52 | * Context for a single peer |
64 | */ | 53 | */ |
65 | struct GNUNET_TRANSPORT_TESTING_PeerContext | 54 | struct GNUNET_TRANSPORT_TESTING_PeerContext |
@@ -87,7 +76,12 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext | |||
87 | /** | 76 | /** |
88 | * Peer's transport service handle | 77 | * Peer's transport service handle |
89 | */ | 78 | */ |
90 | struct GNUNET_TRANSPORT_Handle *th; | 79 | struct GNUNET_TRANSPORT_CoreHandle *th; |
80 | |||
81 | /** | ||
82 | * Peer's transport service manipulation handle | ||
83 | */ | ||
84 | struct GNUNET_TRANSPORT_ManipulationHandle *tmh; | ||
91 | 85 | ||
92 | /** | 86 | /** |
93 | * Peer's ATS handle. | 87 | * Peer's ATS handle. |
@@ -117,22 +111,22 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext | |||
117 | /** | 111 | /** |
118 | * Receive callback | 112 | * Receive callback |
119 | */ | 113 | */ |
120 | GNUNET_TRANSPORT_ReceiveCallback rec; | 114 | struct GNUNET_MQ_MessageHandler *handlers; |
121 | 115 | ||
122 | /** | 116 | /** |
123 | * Notify connect callback | 117 | * Notify connect callback |
124 | */ | 118 | */ |
125 | GNUNET_TRANSPORT_NotifyConnect nc; | 119 | GNUNET_TRANSPORT_NotifyConnecT nc; |
126 | 120 | ||
127 | /** | 121 | /** |
128 | * Notify disconnect callback | 122 | * Notify disconnect callback |
129 | */ | 123 | */ |
130 | GNUNET_TRANSPORT_NotifyDisconnect nd; | 124 | GNUNET_TRANSPORT_NotifyDisconnecT nd; |
131 | 125 | ||
132 | /** | 126 | /** |
133 | * Startup completed callback | 127 | * Startup completed callback |
134 | */ | 128 | */ |
135 | GNUNET_TRANSPORT_TESTING_StartCallback start_cb; | 129 | GNUNET_SCHEDULER_TaskCallback start_cb; |
136 | 130 | ||
137 | /** | 131 | /** |
138 | * Peers HELLO Message | 132 | * Peers HELLO Message |
@@ -207,6 +201,11 @@ struct GNUNET_TRANSPORT_TESTING_ConnectRequest | |||
207 | */ | 201 | */ |
208 | void *cb_cls; | 202 | void *cb_cls; |
209 | 203 | ||
204 | /** | ||
205 | * Message queue for sending from @a p1 to @a p2. | ||
206 | */ | ||
207 | struct GNUNET_MQ_Handle *mq; | ||
208 | |||
210 | /** | 209 | /** |
211 | * Set if peer1 says the connection is up to peer2. | 210 | * Set if peer1 says the connection is up to peer2. |
212 | */ | 211 | */ |
@@ -225,65 +224,6 @@ struct GNUNET_TRANSPORT_TESTING_ConnectRequest | |||
225 | 224 | ||
226 | 225 | ||
227 | /** | 226 | /** |
228 | * Information we keep for active transmission jobs. | ||
229 | */ | ||
230 | struct TRANSPORT_TESTING_SendJob | ||
231 | { | ||
232 | |||
233 | /** | ||
234 | * Kept in a DLL. | ||
235 | */ | ||
236 | struct TRANSPORT_TESTING_SendJob *next; | ||
237 | |||
238 | /** | ||
239 | * Kept in a DLL. | ||
240 | */ | ||
241 | struct TRANSPORT_TESTING_SendJob *prev; | ||
242 | |||
243 | /** | ||
244 | * Sender of the message. | ||
245 | */ | ||
246 | struct GNUNET_TRANSPORT_TESTING_PeerContext *sender; | ||
247 | |||
248 | /** | ||
249 | * Receiver of the message. | ||
250 | */ | ||
251 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver; | ||
252 | |||
253 | /** | ||
254 | * Operation handle. | ||
255 | */ | ||
256 | struct GNUNET_TRANSPORT_TransmitHandle *th; | ||
257 | |||
258 | /** | ||
259 | * Function to call upon completion. | ||
260 | */ | ||
261 | GNUNET_SCHEDULER_TaskCallback cont; | ||
262 | |||
263 | /** | ||
264 | * Closure for @e cont. | ||
265 | */ | ||
266 | void *cont_cls; | ||
267 | |||
268 | /** | ||
269 | * Number of the message. | ||
270 | */ | ||
271 | uint32_t num; | ||
272 | |||
273 | /** | ||
274 | * Type of message to send. | ||
275 | */ | ||
276 | uint16_t mtype; | ||
277 | |||
278 | /** | ||
279 | * Length of the message. | ||
280 | */ | ||
281 | uint16_t msize; | ||
282 | |||
283 | }; | ||
284 | |||
285 | |||
286 | /** | ||
287 | * Handle for a test run. | 227 | * Handle for a test run. |
288 | */ | 228 | */ |
289 | struct GNUNET_TRANSPORT_TESTING_Handle | 229 | struct GNUNET_TRANSPORT_TESTING_Handle |
@@ -304,16 +244,6 @@ struct GNUNET_TRANSPORT_TESTING_Handle | |||
304 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail; | 244 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail; |
305 | 245 | ||
306 | /** | 246 | /** |
307 | * Kept in a DLL. | ||
308 | */ | ||
309 | struct TRANSPORT_TESTING_SendJob *sj_head; | ||
310 | |||
311 | /** | ||
312 | * Kept in a DLL. | ||
313 | */ | ||
314 | struct TRANSPORT_TESTING_SendJob *sj_tail; | ||
315 | |||
316 | /** | ||
317 | * head DLL of peers | 247 | * head DLL of peers |
318 | */ | 248 | */ |
319 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head; | 249 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head; |
@@ -349,7 +279,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth); | |||
349 | * @param tth the testing handle | 279 | * @param tth the testing handle |
350 | * @param cfgname configuration file | 280 | * @param cfgname configuration file |
351 | * @param peer_id the peer_id | 281 | * @param peer_id the peer_id |
352 | * @param rec receive callback | 282 | * @param handlers functions for receiving messages |
353 | * @param nc connect callback | 283 | * @param nc connect callback |
354 | * @param nd disconnect callback | 284 | * @param nd disconnect callback |
355 | * @param cb_cls closure for @a nc and @a nd callback | 285 | * @param cb_cls closure for @a nc and @a nd callback |
@@ -361,11 +291,11 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext * | |||
361 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth, | 291 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth, |
362 | const char *cfgname, | 292 | const char *cfgname, |
363 | int peer_id, | 293 | int peer_id, |
364 | GNUNET_TRANSPORT_ReceiveCallback rec, | 294 | const struct GNUNET_MQ_MessageHandler *handlers, |
365 | GNUNET_TRANSPORT_NotifyConnect nc, | 295 | GNUNET_TRANSPORT_NotifyConnecT nc, |
366 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 296 | GNUNET_TRANSPORT_NotifyDisconnecT nd, |
367 | void *cb_cls, | 297 | void *cb_cls, |
368 | GNUNET_TRANSPORT_TESTING_StartCallback start_cb, | 298 | GNUNET_SCHEDULER_TaskCallback start_cb, |
369 | void *start_cb_cls); | 299 | void *start_cb_cls); |
370 | 300 | ||
371 | 301 | ||
@@ -388,7 +318,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext | |||
388 | */ | 318 | */ |
389 | int | 319 | int |
390 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, | 320 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, |
391 | GNUNET_TRANSPORT_TESTING_StartCallback restart_cb, | 321 | GNUNET_SCHEDULER_TaskCallback restart_cb, |
392 | void *restart_cb_cls); | 322 | void *restart_cb_cls); |
393 | 323 | ||
394 | 324 | ||
@@ -476,6 +406,23 @@ struct GNUNET_TRANSPORT_TESTING_ConnectRequestList; | |||
476 | struct GNUNET_TRANSPORT_TESTING_InternalPeerContext; | 406 | struct GNUNET_TRANSPORT_TESTING_InternalPeerContext; |
477 | 407 | ||
478 | 408 | ||
409 | GNUNET_NETWORK_STRUCT_BEGIN | ||
410 | struct GNUNET_TRANSPORT_TESTING_TestMessage | ||
411 | { | ||
412 | /** | ||
413 | * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE. | ||
414 | */ | ||
415 | struct GNUNET_MessageHeader header; | ||
416 | |||
417 | /** | ||
418 | * Monotonically increasing counter throughout the test. | ||
419 | */ | ||
420 | uint32_t num GNUNET_PACKED; | ||
421 | }; | ||
422 | GNUNET_NETWORK_STRUCT_END | ||
423 | |||
424 | |||
425 | |||
479 | /** | 426 | /** |
480 | * Function called by the transport for each received message. | 427 | * Function called by the transport for each received message. |
481 | * | 428 | * |
@@ -488,7 +435,7 @@ typedef void | |||
488 | (*GNUNET_TRANSPORT_TESTING_ReceiveCallback) (void *cls, | 435 | (*GNUNET_TRANSPORT_TESTING_ReceiveCallback) (void *cls, |
489 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, | 436 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, |
490 | const struct GNUNET_PeerIdentity *sender, | 437 | const struct GNUNET_PeerIdentity *sender, |
491 | const struct GNUNET_MessageHeader *message); | 438 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message); |
492 | 439 | ||
493 | 440 | ||
494 | /** | 441 | /** |
@@ -800,20 +747,10 @@ GNUNET_TRANSPORT_TESTING_send (struct GNUNET_TRANSPORT_TESTING_PeerContext *send | |||
800 | */ | 747 | */ |
801 | #define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345 | 748 | #define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345 |
802 | 749 | ||
803 | GNUNET_NETWORK_STRUCT_BEGIN | 750 | /** |
804 | struct GNUNET_TRANSPORT_TESTING_TestMessage | 751 | * Alternative message type for tests. |
805 | { | 752 | */ |
806 | /** | 753 | #define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 12346 |
807 | * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE. | ||
808 | */ | ||
809 | struct GNUNET_MessageHeader header; | ||
810 | |||
811 | /** | ||
812 | * Monotonically increasing counter throughout the test. | ||
813 | */ | ||
814 | uint32_t num GNUNET_PACKED; | ||
815 | }; | ||
816 | GNUNET_NETWORK_STRUCT_END | ||
817 | 754 | ||
818 | 755 | ||
819 | /** | 756 | /** |