diff options
Diffstat (limited to 'src/transport')
21 files changed, 117 insertions, 103 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 7af8e139e..b53bda514 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -73,7 +73,7 @@ unsigned long long quota_out_p2; | |||
73 | 73 | ||
74 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 74 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
75 | 75 | ||
76 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 76 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
77 | 77 | ||
78 | 78 | ||
79 | /* | 79 | /* |
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c index 52d8c441f..69e83115c 100644 --- a/src/transport/test_transport_address_switch.c +++ b/src/transport/test_transport_address_switch.c | |||
@@ -108,7 +108,7 @@ static struct GNUNET_TRANSPORT_TransmitHandle *th; | |||
108 | 108 | ||
109 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; | 109 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; |
110 | 110 | ||
111 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 111 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
112 | 112 | ||
113 | static int test_connected; | 113 | static int test_connected; |
114 | 114 | ||
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 30f4bbbab..171004204 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -66,7 +66,7 @@ static struct PeerContext *p1; | |||
66 | 66 | ||
67 | static struct PeerContext *p2; | 67 | static struct PeerContext *p2; |
68 | 68 | ||
69 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 69 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
70 | 70 | ||
71 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 71 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
72 | 72 | ||
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c index 85925b1bf..5c9ae36fe 100644 --- a/src/transport/test_transport_api_bidirectional_connect.c +++ b/src/transport/test_transport_api_bidirectional_connect.c | |||
@@ -57,8 +57,8 @@ static struct PeerContext *p1; | |||
57 | 57 | ||
58 | static struct PeerContext *p2; | 58 | static struct PeerContext *p2; |
59 | 59 | ||
60 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1; | 60 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1; |
61 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2; | 61 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2; |
62 | 62 | ||
63 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 63 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
64 | 64 | ||
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index 0ea99c3a6..9c3a0c460 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c | |||
@@ -32,7 +32,7 @@ static struct PeerContext *p1; | |||
32 | 32 | ||
33 | static struct PeerContext *p2; | 33 | static struct PeerContext *p2; |
34 | 34 | ||
35 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 35 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
36 | 36 | ||
37 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 37 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
38 | 38 | ||
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c index fe43b8e8c..7951c7678 100644 --- a/src/transport/test_transport_api_disconnect.c +++ b/src/transport/test_transport_api_disconnect.c | |||
@@ -55,7 +55,7 @@ struct PeerContext *p1; | |||
55 | 55 | ||
56 | struct PeerContext *p2; | 56 | struct PeerContext *p2; |
57 | 57 | ||
58 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 58 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
59 | 59 | ||
60 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 60 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
61 | 61 | ||
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c index 4bc0133cb..9223c3bf2 100644 --- a/src/transport/test_transport_api_limited_sockets.c +++ b/src/transport/test_transport_api_limited_sockets.c | |||
@@ -63,7 +63,7 @@ static struct PeerContext *p1; | |||
63 | 63 | ||
64 | static struct PeerContext *p2; | 64 | static struct PeerContext *p2; |
65 | 65 | ||
66 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 66 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
67 | 67 | ||
68 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 68 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
69 | 69 | ||
diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c index aa1f57a2a..41ad7f68f 100644 --- a/src/transport/test_transport_api_manipulation_cfg.c +++ b/src/transport/test_transport_api_manipulation_cfg.c | |||
@@ -75,7 +75,7 @@ static struct PeerContext *p1; | |||
75 | 75 | ||
76 | static struct PeerContext *p2; | 76 | static struct PeerContext *p2; |
77 | 77 | ||
78 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 78 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
79 | 79 | ||
80 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 80 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
81 | 81 | ||
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c index 7be1cfd3a..8a820fa16 100644 --- a/src/transport/test_transport_api_manipulation_recv_tcp.c +++ b/src/transport/test_transport_api_manipulation_recv_tcp.c | |||
@@ -67,7 +67,7 @@ static struct PeerContext *p1; | |||
67 | 67 | ||
68 | static struct PeerContext *p2; | 68 | static struct PeerContext *p2; |
69 | 69 | ||
70 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 70 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
71 | 71 | ||
72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 73 | ||
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 4dae7e6aa..0a52556ab 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -67,7 +67,7 @@ static struct PeerContext *p1; | |||
67 | 67 | ||
68 | static struct PeerContext *p2; | 68 | static struct PeerContext *p2; |
69 | 69 | ||
70 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 70 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
71 | 71 | ||
72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 73 | ||
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c index 13a7baec8..8cd952cc5 100644 --- a/src/transport/test_transport_api_monitor_peers.c +++ b/src/transport/test_transport_api_monitor_peers.c | |||
@@ -61,7 +61,7 @@ static struct PeerContext *p1; | |||
61 | 61 | ||
62 | static struct PeerContext *p2; | 62 | static struct PeerContext *p2; |
63 | 63 | ||
64 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 64 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
65 | 65 | ||
66 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 66 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
67 | 67 | ||
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c index 0b2a73059..76fa66949 100644 --- a/src/transport/test_transport_api_monitor_validation.c +++ b/src/transport/test_transport_api_monitor_validation.c | |||
@@ -64,7 +64,7 @@ static struct PeerContext *p1; | |||
64 | 64 | ||
65 | static struct PeerContext *p2; | 65 | static struct PeerContext *p2; |
66 | 66 | ||
67 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 67 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
68 | 68 | ||
69 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 69 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
70 | 70 | ||
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 0b80477bf..0561e1a10 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -161,7 +161,7 @@ static int test_send_timeout; | |||
161 | */ | 161 | */ |
162 | static char bitmap[TOTAL_MSGS / 8]; | 162 | static char bitmap[TOTAL_MSGS / 8]; |
163 | 163 | ||
164 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 164 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
165 | 165 | ||
166 | /* | 166 | /* |
167 | * END Testcase specific declarations | 167 | * END Testcase specific declarations |
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c index 5d51559b7..0e91fa68f 100644 --- a/src/transport/test_transport_api_restart_1peer.c +++ b/src/transport/test_transport_api_restart_1peer.c | |||
@@ -59,7 +59,7 @@ static struct PeerContext *p2; | |||
59 | 59 | ||
60 | static int p2_connected; | 60 | static int p2_connected; |
61 | 61 | ||
62 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 62 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
63 | 63 | ||
64 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 64 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
65 | 65 | ||
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c index db1c0920d..5b47ee1d3 100644 --- a/src/transport/test_transport_api_restart_2peers.c +++ b/src/transport/test_transport_api_restart_2peers.c | |||
@@ -54,7 +54,7 @@ static struct PeerContext *p1; | |||
54 | 54 | ||
55 | static struct PeerContext *p2; | 55 | static struct PeerContext *p2; |
56 | 56 | ||
57 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 57 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
58 | 58 | ||
59 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 59 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
60 | 60 | ||
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index 7ba74b2e9..dd0d9a344 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.c | |||
@@ -58,7 +58,7 @@ static struct PeerContext *p1; | |||
58 | 58 | ||
59 | static struct PeerContext *p2; | 59 | static struct PeerContext *p2; |
60 | 60 | ||
61 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 61 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
62 | 62 | ||
63 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 63 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
64 | 64 | ||
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c index 6f2ba91c0..a0720820d 100644 --- a/src/transport/test_transport_api_unreliability_constant.c +++ b/src/transport/test_transport_api_unreliability_constant.c | |||
@@ -66,7 +66,7 @@ char *cfg_file_p2; | |||
66 | uint32_t max_bps_p1; | 66 | uint32_t max_bps_p1; |
67 | uint32_t max_bps_p2; | 67 | uint32_t max_bps_p2; |
68 | 68 | ||
69 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 69 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * Testcase specific declarations | 72 | * Testcase specific declarations |
diff --git a/src/transport/test_transport_blacklisting.c b/src/transport/test_transport_blacklisting.c index 2972e7dae..3d3d009dc 100644 --- a/src/transport/test_transport_blacklisting.c +++ b/src/transport/test_transport_blacklisting.c | |||
@@ -58,7 +58,7 @@ struct PeerContext *p1; | |||
58 | 58 | ||
59 | struct PeerContext *p2; | 59 | struct PeerContext *p2; |
60 | 60 | ||
61 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 61 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
62 | 62 | ||
63 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 63 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
64 | 64 | ||
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c index 727d6b785..0c2043119 100644 --- a/src/transport/test_transport_testing.c +++ b/src/transport/test_transport_testing.c | |||
@@ -40,7 +40,7 @@ static struct PeerContext *p1; | |||
40 | 40 | ||
41 | static struct PeerContext *p2; | 41 | static struct PeerContext *p2; |
42 | 42 | ||
43 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 43 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
44 | 44 | ||
45 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 45 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
46 | 46 | ||
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 993103ac1..86c67a039 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2006, 2009, 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 |
@@ -48,12 +48,13 @@ find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | static struct ConnectingContext * | 51 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * |
52 | find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 52 | find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
53 | struct PeerContext *p1, struct PeerContext *p2) | 53 | struct PeerContext *p1, |
54 | struct PeerContext *p2) | ||
54 | { | 55 | { |
55 | GNUNET_assert (tth != NULL); | 56 | GNUNET_assert (tth != NULL); |
56 | struct ConnectingContext *cc = tth->cc_head; | 57 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head; |
57 | 58 | ||
58 | while (cc != NULL) | 59 | while (cc != NULL) |
59 | { | 60 | { |
@@ -69,7 +70,8 @@ find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
69 | 70 | ||
70 | 71 | ||
71 | static void | 72 | static void |
72 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 73 | notify_connect (void *cls, |
74 | const struct GNUNET_PeerIdentity *peer) | ||
73 | { | 75 | { |
74 | struct PeerContext *p = cls; | 76 | struct PeerContext *p = cls; |
75 | char *p2_s; | 77 | char *p2_s; |
@@ -93,7 +95,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
93 | GNUNET_free (p2_s); | 95 | GNUNET_free (p2_s); |
94 | 96 | ||
95 | /* Find ConnectingContext */ | 97 | /* Find ConnectingContext */ |
96 | struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2); | 98 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = find_connecting_context (p->tth, p, p2); |
97 | 99 | ||
98 | if (cc == NULL) | 100 | if (cc == NULL) |
99 | return; | 101 | return; |
@@ -113,7 +115,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
113 | 115 | ||
114 | 116 | ||
115 | static void | 117 | static void |
116 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 118 | notify_disconnect (void *cls, |
119 | const struct GNUNET_PeerIdentity *peer) | ||
117 | { | 120 | { |
118 | struct PeerContext *p = cls; | 121 | struct PeerContext *p = cls; |
119 | 122 | ||
@@ -149,7 +152,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
149 | 152 | ||
150 | 153 | ||
151 | static void | 154 | static void |
152 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 155 | notify_receive (void *cls, |
156 | const struct GNUNET_PeerIdentity *peer, | ||
153 | const struct GNUNET_MessageHeader *message) | 157 | const struct GNUNET_MessageHeader *message) |
154 | { | 158 | { |
155 | struct PeerContext *p = cls; | 159 | struct PeerContext *p = cls; |
@@ -162,7 +166,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
162 | 166 | ||
163 | 167 | ||
164 | static void | 168 | static void |
165 | get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | 169 | get_hello (void *cb_cls, |
170 | const struct GNUNET_MessageHeader *message) | ||
166 | { | 171 | { |
167 | struct PeerContext *p = cb_cls; | 172 | struct PeerContext *p = cb_cls; |
168 | struct GNUNET_PeerIdentity hello_id; | 173 | struct GNUNET_PeerIdentity hello_id; |
@@ -187,9 +192,10 @@ get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | |||
187 | 192 | ||
188 | 193 | ||
189 | static void | 194 | static void |
190 | try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 195 | try_connect (void *cls, |
196 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
191 | { | 197 | { |
192 | struct ConnectingContext *cc = cls; | 198 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; |
193 | struct PeerContext *p1 = cc->p1; | 199 | struct PeerContext *p1 = cc->p1; |
194 | struct PeerContext *p2 = cc->p2; | 200 | struct PeerContext *p2 = cc->p2; |
195 | 201 | ||
@@ -477,18 +483,16 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
477 | * @param cls callback cls | 483 | * @param cls callback cls |
478 | * @return a connect request handle | 484 | * @return a connect request handle |
479 | */ | 485 | */ |
480 | GNUNET_TRANSPORT_TESTING_ConnectRequest | 486 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest * |
481 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 487 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
482 | struct PeerContext *p1, | 488 | struct PeerContext *p1, |
483 | struct PeerContext *p2, | 489 | struct PeerContext *p2, |
484 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 490 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
485 | void *cls) | 491 | void *cls) |
486 | { | 492 | { |
487 | GNUNET_assert (tth != NULL); | 493 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); |
488 | |||
489 | struct ConnectingContext *cc = | ||
490 | GNUNET_new (struct ConnectingContext); | ||
491 | 494 | ||
495 | GNUNET_assert (tth != NULL); | ||
492 | GNUNET_assert (p1 != NULL); | 496 | GNUNET_assert (p1 != NULL); |
493 | GNUNET_assert (p2 != NULL); | 497 | GNUNET_assert (p2 != NULL); |
494 | cc->p1 = p1; | 498 | cc->p1 = p1; |
@@ -502,7 +506,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
502 | cc->th_p2 = p2->th; | 506 | cc->th_p2 = p2->th; |
503 | GNUNET_assert (cc->th_p1 != NULL); | 507 | GNUNET_assert (cc->th_p1 != NULL); |
504 | GNUNET_assert (cc->th_p2 != NULL); | 508 | GNUNET_assert (cc->th_p2 != NULL); |
505 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); | 509 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, |
510 | tth->cc_tail, | ||
511 | cc); | ||
506 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 512 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); |
507 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 513 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
508 | "New connect request %p\n", | 514 | "New connect request %p\n", |
@@ -517,17 +523,12 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
517 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully | 523 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully |
518 | * | 524 | * |
519 | * @param tth transport testing handle | 525 | * @param tth transport testing handle |
520 | * @param ccr a connect request handle | 526 | * @param cc a connect request handle |
521 | */ | 527 | */ |
522 | void | 528 | void |
523 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct | 529 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
524 | GNUNET_TRANSPORT_TESTING_handle | 530 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc) |
525 | *tth, | ||
526 | GNUNET_TRANSPORT_TESTING_ConnectRequest | ||
527 | ccr) | ||
528 | { | 531 | { |
529 | struct ConnectingContext *cc = ccr; | ||
530 | |||
531 | GNUNET_assert (tth != NULL); | 532 | GNUNET_assert (tth != NULL); |
532 | 533 | ||
533 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 534 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -550,8 +551,8 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct | |||
550 | void | 551 | void |
551 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | 552 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) |
552 | { | 553 | { |
553 | struct ConnectingContext *cc = tth->cc_head; | 554 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head; |
554 | struct ConnectingContext *ct = NULL; | 555 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct = NULL; |
555 | struct PeerContext *p = tth->p_head; | 556 | struct PeerContext *p = tth->p_head; |
556 | struct PeerContext *t = NULL; | 557 | struct PeerContext *t = NULL; |
557 | 558 | ||
@@ -596,11 +597,14 @@ GNUNET_TRANSPORT_TESTING_init () | |||
596 | tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle); | 597 | tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle); |
597 | 598 | ||
598 | /* Init testing the testing lib */ | 599 | /* Init testing the testing lib */ |
599 | tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL, | 600 | tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", |
600 | NULL, NULL); | 601 | NULL, |
602 | NULL, | ||
603 | NULL); | ||
601 | if (NULL == tth->tl_system) | 604 | if (NULL == tth->tl_system) |
602 | { | 605 | { |
603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n")); | 606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
607 | _("Failed to initialize testing library!\n")); | ||
604 | GNUNET_free (tth); | 608 | GNUNET_free (tth); |
605 | return NULL; | 609 | return NULL; |
606 | } | 610 | } |
@@ -671,7 +675,8 @@ extract_filename (const char *file) | |||
671 | * @param dest where to store result | 675 | * @param dest where to store result |
672 | */ | 676 | */ |
673 | void | 677 | void |
674 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest) | 678 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, |
679 | char **dest) | ||
675 | { | 680 | { |
676 | char *filename = extract_filename (file); | 681 | char *filename = extract_filename (file); |
677 | char *backup = filename; | 682 | char *backup = filename; |
@@ -708,7 +713,8 @@ suc: | |||
708 | * @param dest where to store result | 713 | * @param dest where to store result |
709 | */ | 714 | */ |
710 | void | 715 | void |
711 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, char **dest) | 716 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, |
717 | char **dest) | ||
712 | { | 718 | { |
713 | char *src = extract_filename (file); | 719 | char *src = extract_filename (file); |
714 | char *split; | 720 | char *split; |
@@ -732,7 +738,8 @@ GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, char **dest) | |||
732 | */ | 738 | */ |
733 | void | 739 | void |
734 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file, | 740 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file, |
735 | const char *test, char **dest) | 741 | const char *test, |
742 | char **dest) | ||
736 | { | 743 | { |
737 | char *filename; | 744 | char *filename; |
738 | char *dotexe; | 745 | char *dotexe; |
@@ -776,7 +783,8 @@ suc: | |||
776 | * @param count peer number | 783 | * @param count peer number |
777 | */ | 784 | */ |
778 | void | 785 | void |
779 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest, | 786 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, |
787 | char **dest, | ||
780 | int count) | 788 | int count) |
781 | { | 789 | { |
782 | char *filename = extract_filename (file); | 790 | char *filename = extract_filename (file); |
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h index 0e84ac236..dcac29185 100644 --- a/src/transport/transport-testing.h +++ b/src/transport/transport-testing.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2006, 2009, 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 |
@@ -31,7 +31,7 @@ | |||
31 | #include "gnunet_testing_lib.h" | 31 | #include "gnunet_testing_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define GNUNET_TRANSPORT_TESTING_ConnectRequest void * | 34 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest; |
35 | 35 | ||
36 | 36 | ||
37 | /** | 37 | /** |
@@ -43,16 +43,18 @@ struct PeerContext; | |||
43 | * Callback when two peers are connected and both have called the connect callback | 43 | * Callback when two peers are connected and both have called the connect callback |
44 | * to notify clients about a new peer | 44 | * to notify clients about a new peer |
45 | */ | 45 | */ |
46 | typedef void (*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext * p, | 46 | typedef void |
47 | void *cls); | 47 | (*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p, |
48 | void *cls); | ||
48 | 49 | ||
49 | /** | 50 | /** |
50 | * Callback when two peers are connected and both have called the connect callback | 51 | * Callback when two peers are connected and both have called the connect callback |
51 | * to notify clients about a new peer | 52 | * to notify clients about a new peer |
52 | */ | 53 | */ |
53 | typedef void (*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext * p1, | 54 | typedef void |
54 | struct PeerContext * p2, | 55 | (*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1, |
55 | void *cls); | 56 | struct PeerContext *p2, |
57 | void *cls); | ||
56 | 58 | ||
57 | 59 | ||
58 | /** | 60 | /** |
@@ -147,13 +149,13 @@ struct PeerContext | |||
147 | }; | 149 | }; |
148 | 150 | ||
149 | 151 | ||
150 | struct ConnectingContext | 152 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest |
151 | { | 153 | { |
152 | struct ConnectingContext *next; | 154 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next; |
153 | struct ConnectingContext *prev; | 155 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev; |
154 | struct PeerContext *p1; | 156 | struct PeerContext *p1; |
155 | struct PeerContext *p2; | 157 | struct PeerContext *p2; |
156 | struct GNUNET_SCHEDULER_Task * tct; | 158 | struct GNUNET_SCHEDULER_Task *tct; |
157 | GNUNET_TRANSPORT_TESTING_connect_cb cb; | 159 | GNUNET_TRANSPORT_TESTING_connect_cb cb; |
158 | void *cb_cls; | 160 | void *cb_cls; |
159 | struct GNUNET_TRANSPORT_Handle *th_p1; | 161 | struct GNUNET_TRANSPORT_Handle *th_p1; |
@@ -172,12 +174,12 @@ struct GNUNET_TRANSPORT_TESTING_handle | |||
172 | /** | 174 | /** |
173 | * head DLL of connect contexts | 175 | * head DLL of connect contexts |
174 | */ | 176 | */ |
175 | struct ConnectingContext *cc_head; | 177 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_head; |
176 | 178 | ||
177 | /** | 179 | /** |
178 | * head DLL of connect contexts | 180 | * head DLL of connect contexts |
179 | */ | 181 | */ |
180 | struct ConnectingContext *cc_tail; | 182 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail; |
181 | 183 | ||
182 | /** | 184 | /** |
183 | * head DLL of peers | 185 | * head DLL of peers |
@@ -192,20 +194,22 @@ struct GNUNET_TRANSPORT_TESTING_handle | |||
192 | 194 | ||
193 | 195 | ||
194 | /** | 196 | /** |
195 | * Start a peer with the given configuration | 197 | * Start a peer with the given configuration |
196 | * @param tth the testing handle | 198 | * |
197 | * @param cfgname configuration file | 199 | * @param tth the testing handle |
198 | * @param peer_id the peer_id | 200 | * @param cfgname configuration file |
199 | * @param rec receive callback | 201 | * @param peer_id the peer_id |
200 | * @param nc connect callback | 202 | * @param rec receive callback |
201 | * @param nd disconnect callback | 203 | * @param nc connect callback |
202 | * @param start_cb start callback | 204 | * @param nd disconnect callback |
203 | * @param cb_cls closure for callback | 205 | * @param start_cb start callback |
204 | * @return the peer context | 206 | * @param cb_cls closure for callback |
205 | */ | 207 | * @return the peer context |
208 | */ | ||
206 | struct PeerContext * | 209 | struct PeerContext * |
207 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle | 210 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
208 | *tth, const char *cfgname, int peer_id, | 211 | const char *cfgname, |
212 | int peer_id, | ||
209 | GNUNET_TRANSPORT_ReceiveCallback rec, | 213 | GNUNET_TRANSPORT_ReceiveCallback rec, |
210 | GNUNET_TRANSPORT_NotifyConnect nc, | 214 | GNUNET_TRANSPORT_NotifyConnect nc, |
211 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 215 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
@@ -215,30 +219,32 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
215 | 219 | ||
216 | /** | 220 | /** |
217 | * shutdown the given peer | 221 | * shutdown the given peer |
222 | * | ||
218 | * @param tth the testing handle | 223 | * @param tth the testing handle |
219 | * @param p the peer | 224 | * @param p the peer |
220 | */ | 225 | */ |
221 | |||
222 | void | 226 | void |
223 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 227 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
224 | struct PeerContext *pc); | 228 | struct PeerContext *pc); |
225 | 229 | ||
226 | 230 | ||
227 | /** | 231 | /** |
228 | * Restart the given peer | 232 | * Restart the given peer |
229 | * @param tth testing handle | 233 | * |
230 | * @param p the peer | 234 | * @param tth testing handle |
231 | * @param cfgname the cfg file used to restart | 235 | * @param p the peer |
232 | * @param restart_cb restart callback | 236 | * @param cfgname the cfg file used to restart |
233 | * @param cb_cls callback closure | 237 | * @param restart_cb restart callback |
234 | * @return GNUNET_OK in success otherwise GNUNET_SYSERR | 238 | * @param cb_cls callback closure |
235 | */ | 239 | * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR |
240 | */ | ||
236 | int | 241 | int |
237 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | 242 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
238 | *tth, struct PeerContext *p, | 243 | struct PeerContext *p, |
239 | const char *cfgname, | 244 | const char *cfgname, |
240 | GNUNET_TRANSPORT_TESTING_start_cb | 245 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, |
241 | restart_cb, void *cb_cls); | 246 | void *cb_cls); |
247 | |||
242 | 248 | ||
243 | /** | 249 | /** |
244 | * Connect the given peers and call the callback when both peers report the | 250 | * Connect the given peers and call the callback when both peers report the |
@@ -252,25 +258,23 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
252 | * @param cls callback cls | 258 | * @param cls callback cls |
253 | * @return a connect request handle | 259 | * @return a connect request handle |
254 | */ | 260 | */ |
255 | GNUNET_TRANSPORT_TESTING_ConnectRequest | 261 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest * |
256 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 262 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
257 | struct PeerContext *p1, | 263 | struct PeerContext *p1, |
258 | struct PeerContext *p2, | 264 | struct PeerContext *p2, |
259 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 265 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
260 | void *cls); | 266 | void *cls); |
261 | 267 | ||
268 | |||
262 | /** | 269 | /** |
263 | * Cancel the request to connect two peers | 270 | * Cancel the request to connect two peers |
264 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully | 271 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully |
265 | * @param tth testing | 272 | * @param tth testing |
266 | * @param ccr a connect request handle | 273 | * @param cc a connect request handle |
267 | */ | 274 | */ |
268 | void | 275 | void |
269 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct | 276 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
270 | GNUNET_TRANSPORT_TESTING_handle | 277 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc); |
271 | *tth, | ||
272 | GNUNET_TRANSPORT_TESTING_ConnectRequest | ||
273 | ccr); | ||
274 | 278 | ||
275 | /** | 279 | /** |
276 | * Clean up the transport testing | 280 | * Clean up the transport testing |
@@ -284,7 +288,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth); | |||
284 | * @return transport testing handle | 288 | * @return transport testing handle |
285 | */ | 289 | */ |
286 | struct GNUNET_TRANSPORT_TESTING_handle * | 290 | struct GNUNET_TRANSPORT_TESTING_handle * |
287 | GNUNET_TRANSPORT_TESTING_init (); | 291 | GNUNET_TRANSPORT_TESTING_init (void); |
288 | 292 | ||
289 | /* | 293 | /* |
290 | * Some utility functions | 294 | * Some utility functions |
@@ -296,7 +300,8 @@ GNUNET_TRANSPORT_TESTING_init (); | |||
296 | * @param dest where to store result | 300 | * @param dest where to store result |
297 | */ | 301 | */ |
298 | void | 302 | void |
299 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest); | 303 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, |
304 | char **dest); | ||
300 | 305 | ||
301 | /** | 306 | /** |
302 | * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and | 307 | * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and |
@@ -307,7 +312,8 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest); | |||
307 | * @param count peer number | 312 | * @param count peer number |
308 | */ | 313 | */ |
309 | void | 314 | void |
310 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest, | 315 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, |
316 | char **dest, | ||
311 | int count); | 317 | int count); |
312 | 318 | ||
313 | 319 | ||