diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 1 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | 33 | ||||
-rw-r--r-- | src/transport/test_transport_start_with_config.c | 1 | ||||
-rw-r--r-- | src/transport/transport-testing-cmds.h | 105 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_backchannel_check.c | 6 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 35 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_send_simple.c | 10 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer.c | 168 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_stop_peer.c | 9 |
9 files changed, 103 insertions, 265 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 423602fea..751bc40c1 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -159,6 +159,7 @@ libgnunettransporttesting_la_LDFLAGS = \ | |||
159 | $(GN_LIB_LDFLAGS) | 159 | $(GN_LIB_LDFLAGS) |
160 | 160 | ||
161 | libgnunettransporttesting2_la_SOURCES = \ | 161 | libgnunettransporttesting2_la_SOURCES = \ |
162 | transport_api_traits.c \ | ||
162 | transport_api_cmd_connecting_peers.c \ | 163 | transport_api_cmd_connecting_peers.c \ |
163 | transport_api_cmd_backchannel_check.c \ | 164 | transport_api_cmd_backchannel_check.c \ |
164 | transport_api_cmd_start_peer.c \ | 165 | transport_api_cmd_start_peer.c \ |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 526f08e6a..9d6844be1 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -96,15 +96,15 @@ static void | |||
96 | handle_test (void *cls, | 96 | handle_test (void *cls, |
97 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 97 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
98 | { | 98 | { |
99 | struct GNUNET_TESTING_AsyncContext *ac; | 99 | const struct GNUNET_TESTING_AsyncContext *ac; |
100 | 100 | ||
101 | GNUNET_TESTING_get_trait_async_context (&block_receive, | 101 | GNUNET_TESTING_get_trait_async_context (&block_receive, |
102 | &ac); | 102 | &ac); |
103 | GNUNET_assert (NULL != ac); | 103 | GNUNET_assert (NULL != ac); |
104 | if (NULL == ac->cont) | 104 | if ((GNUNET_NO == ac->finished) && (NULL == ac->cont)) |
105 | GNUNET_TESTING_async_fail (ac); | 105 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); |
106 | else | 106 | else if (GNUNET_NO == ac->finished) |
107 | GNUNET_TESTING_async_finish (ac); | 107 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
@@ -115,7 +115,7 @@ handle_test (void *cls, | |||
115 | static void | 115 | static void |
116 | all_peers_started () | 116 | all_peers_started () |
117 | { | 117 | { |
118 | struct GNUNET_TESTING_AsyncContext *ac; | 118 | const struct GNUNET_TESTING_AsyncContext *ac; |
119 | 119 | ||
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
121 | "Received message\n"); | 121 | "Received message\n"); |
@@ -123,9 +123,9 @@ all_peers_started () | |||
123 | &ac); | 123 | &ac); |
124 | GNUNET_assert (NULL != ac); | 124 | GNUNET_assert (NULL != ac); |
125 | if (NULL == ac->cont) | 125 | if (NULL == ac->cont) |
126 | GNUNET_TESTING_async_fail (ac); | 126 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); |
127 | else | 127 | else |
128 | GNUNET_TESTING_async_finish (ac); | 128 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
@@ -168,7 +168,7 @@ static void * | |||
168 | notify_connect (struct GNUNET_TESTING_Interpreter *is, | 168 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
169 | const struct GNUNET_PeerIdentity *peer) | 169 | const struct GNUNET_PeerIdentity *peer) |
170 | { | 170 | { |
171 | struct GNUNET_TESTING_AsyncContext *ac; | 171 | const struct GNUNET_TESTING_AsyncContext *ac; |
172 | void *ret = NULL; | 172 | void *ret = NULL; |
173 | const struct GNUNET_TESTING_Command *cmd; | 173 | const struct GNUNET_TESTING_Command *cmd; |
174 | struct BlockState *bs; | 174 | struct BlockState *bs; |
@@ -186,9 +186,9 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
186 | "notify_connect running\n"); | 186 | "notify_connect running\n"); |
187 | GNUNET_assert (NULL != ac); | 187 | GNUNET_assert (NULL != ac); |
188 | if (NULL == ac->cont) | 188 | if (NULL == ac->cont) |
189 | GNUNET_TESTING_async_fail (ac); | 189 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); |
190 | else | 190 | else |
191 | GNUNET_TESTING_async_finish (ac); | 191 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | { | 194 | { |
@@ -198,7 +198,9 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
198 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 198 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
199 | "block state %s\n", | 199 | "block state %s\n", |
200 | cmd->label); | 200 | cmd->label); |
201 | GNUNET_TESTING_get_trait_block_state (cmd,&bs); | 201 | GNUNET_TESTING_get_trait_block_state ( |
202 | cmd, | ||
203 | (const struct BlockState **) &bs); | ||
202 | 204 | ||
203 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 205 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
204 | "block state %u\n", | 206 | "block state %u\n", |
@@ -219,15 +221,16 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
219 | static void | 221 | static void |
220 | all_local_tests_prepared () | 222 | all_local_tests_prepared () |
221 | { | 223 | { |
222 | struct LocalPreparedState *lfs; | 224 | const struct LocalPreparedState *lfs; |
223 | 225 | ||
224 | GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, | 226 | GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, |
225 | &lfs); | 227 | &lfs); |
226 | GNUNET_assert (NULL != &lfs->ac); | 228 | GNUNET_assert (NULL != &lfs->ac); |
227 | if (NULL == lfs->ac.cont) | 229 | if (NULL == lfs->ac.cont) |
228 | GNUNET_TESTING_async_fail (&lfs->ac); | 230 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac); |
229 | else | 231 | else |
230 | GNUNET_TESTING_async_finish (&lfs->ac); | 232 | GNUNET_TESTING_async_finish ((struct |
233 | GNUNET_TESTING_AsyncContext *) &lfs->ac); | ||
231 | } | 234 | } |
232 | 235 | ||
233 | 236 | ||
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c index 7eb92d629..c3411becc 100644 --- a/src/transport/test_transport_start_with_config.c +++ b/src/transport/test_transport_start_with_config.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_testing_netjail_lib.h" | 28 | #include "gnunet_testing_netjail_lib.h" |
29 | #include "transport-testing-cmds.h" | ||
29 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
30 | 31 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index d64279aeb..af6f47962 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -49,7 +49,7 @@ struct ConnectPeersState | |||
49 | /** | 49 | /** |
50 | * The testing system of this node. | 50 | * The testing system of this node. |
51 | */ | 51 | */ |
52 | struct GNUNET_TESTING_System *tl_system; | 52 | const struct GNUNET_TESTING_System *tl_system; |
53 | 53 | ||
54 | // Label of the cmd which started the test system. | 54 | // Label of the cmd which started the test system. |
55 | const char *create_label; | 55 | const char *create_label; |
@@ -180,7 +180,7 @@ struct StartPeerState | |||
180 | 180 | ||
181 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 181 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
182 | 182 | ||
183 | struct GNUNET_TESTING_System *tl_system; | 183 | const struct GNUNET_TESTING_System *tl_system; |
184 | 184 | ||
185 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; | 185 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; |
186 | 186 | ||
@@ -192,26 +192,6 @@ struct StartPeerState | |||
192 | 192 | ||
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Function to get the trait with the struct ConnectPeersState. | ||
196 | * | ||
197 | * @param[out] sps struct ConnectPeersState. | ||
198 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
199 | * | ||
200 | */ | ||
201 | int | ||
202 | GNUNET_TRANSPORT_get_trait_connect_peer_state ( | ||
203 | const struct GNUNET_TESTING_Command *cmd, | ||
204 | struct ConnectPeersState **cps); | ||
205 | |||
206 | |||
207 | int | ||
208 | GNUNET_TRANSPORT_get_trait_state (const struct | ||
209 | GNUNET_TESTING_Command | ||
210 | *cmd, | ||
211 | struct StartPeerState **sps); | ||
212 | |||
213 | |||
214 | /** | ||
215 | * Create command. | 195 | * Create command. |
216 | * | 196 | * |
217 | * @param label name for command. | 197 | * @param label name for command. |
@@ -305,43 +285,62 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | |||
305 | topology); | 285 | topology); |
306 | 286 | ||
307 | 287 | ||
288 | /** | ||
289 | * Create headers for a trait with name @a name for | ||
290 | * statically allocated data of type @a type. | ||
291 | */ | ||
292 | #define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \ | ||
293 | enum GNUNET_GenericReturnValue \ | ||
294 | GNUNET_TRANSPORT_get_trait_ ## name ( \ | ||
295 | const struct GNUNET_TESTING_Command *cmd, \ | ||
296 | type **ret); \ | ||
297 | struct GNUNET_TESTING_Trait \ | ||
298 | GNUNET_TRANSPORT_make_trait_ ## name ( \ | ||
299 | type * value); | ||
308 | 300 | ||
309 | 301 | ||
302 | /** | ||
303 | * Create C implementation for a trait with name @a name for statically | ||
304 | * allocated data of type @a type. | ||
305 | */ | ||
306 | #define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ | ||
307 | enum GNUNET_GenericReturnValue \ | ||
308 | GNUNET_TRANSPORT_get_trait_ ## name ( \ | ||
309 | const struct GNUNET_TESTING_Command *cmd, \ | ||
310 | type **ret) \ | ||
311 | { \ | ||
312 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | ||
313 | return cmd->traits (cmd->cls, \ | ||
314 | (const void **) ret, \ | ||
315 | GNUNET_S (name), \ | ||
316 | 0); \ | ||
317 | } \ | ||
318 | struct GNUNET_TESTING_Trait \ | ||
319 | GNUNET_TRANSPORT_make_trait_ ## name ( \ | ||
320 | type * value) \ | ||
321 | { \ | ||
322 | struct GNUNET_TESTING_Trait ret = { \ | ||
323 | .trait_name = GNUNET_S (name), \ | ||
324 | .ptr = (const void *) value \ | ||
325 | }; \ | ||
326 | return ret; \ | ||
327 | } | ||
310 | 328 | ||
311 | int | ||
312 | GNUNET_TRANSPORT_get_trait_peer_id (const struct | ||
313 | GNUNET_TESTING_Command *cmd, | ||
314 | struct GNUNET_PeerIdentity **id); | ||
315 | |||
316 | |||
317 | int | ||
318 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | ||
319 | GNUNET_TESTING_Command | ||
320 | *cmd, | ||
321 | struct | ||
322 | GNUNET_CONTAINER_MultiShortmap | ||
323 | * | ||
324 | * | ||
325 | connected_peers_map); | ||
326 | int | ||
327 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | ||
328 | GNUNET_TESTING_Command | ||
329 | *cmd, | ||
330 | size_t **hello_size); | ||
331 | 329 | ||
332 | int | 330 | /** |
333 | GNUNET_TRANSPORT_get_trait_hello (const struct | 331 | * Call #op on all simple traits. |
334 | GNUNET_TESTING_Command | 332 | */ |
335 | *cmd, | 333 | #define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \ |
336 | char **hello); | 334 | op (peer_id, const struct GNUNET_PeerIdentity) \ |
335 | op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \ | ||
336 | op (hello_size, const size_t) \ | ||
337 | op (hello, const char) \ | ||
338 | op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \ | ||
339 | op (connect_peer_state, const struct ConnectPeersState) \ | ||
340 | op (state, const struct StartPeerState) | ||
337 | 341 | ||
342 | GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT) | ||
338 | 343 | ||
339 | int | ||
340 | GNUNET_TRANSPORT_get_trait_application_handle (const struct | ||
341 | GNUNET_TESTING_Command *cmd, | ||
342 | struct | ||
343 | GNUNET_TRANSPORT_ApplicationHandle | ||
344 | **ah); | ||
345 | 344 | ||
346 | #endif | 345 | #endif |
347 | /* end of transport_testing.h */ | 346 | /* end of transport_testing.h */ |
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index 529b4690b..1bec3abd3 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -69,7 +69,7 @@ struct CheckState | |||
69 | /** | 69 | /** |
70 | * The testing system of this node. | 70 | * The testing system of this node. |
71 | */ | 71 | */ |
72 | struct GNUNET_TESTING_System *tl_system; | 72 | const struct GNUNET_TESTING_System *tl_system; |
73 | 73 | ||
74 | // Label of the cmd which started the test system. | 74 | // Label of the cmd which started the test system. |
75 | const char *create_label; | 75 | const char *create_label; |
@@ -404,9 +404,9 @@ backchannel_check_run (void *cls, | |||
404 | // char *part_one = "Delivering backchannel message from "; | 404 | // char *part_one = "Delivering backchannel message from "; |
405 | // char *part_two = " of type 1460 to udp"; | 405 | // char *part_two = " of type 1460 to udp"; |
406 | const struct GNUNET_TESTING_Command *system_cmd; | 406 | const struct GNUNET_TESTING_Command *system_cmd; |
407 | struct GNUNET_TESTING_System *tl_system; | 407 | const struct GNUNET_TESTING_System *tl_system; |
408 | const struct GNUNET_TESTING_Command *peer1_cmd; | 408 | const struct GNUNET_TESTING_Command *peer1_cmd; |
409 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | 409 | const struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
410 | // struct GNUNET_PeerIdentity *peer; | 410 | // struct GNUNET_PeerIdentity *peer; |
411 | // uint32_t num; | 411 | // uint32_t num; |
412 | // struct GNUNET_TESTING_NodeConnection *pos_connection; | 412 | // struct GNUNET_TESTING_NodeConnection *pos_connection; |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index f65b6f666..fc925675d 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -47,11 +47,11 @@ connect_peers_run (void *cls, | |||
47 | { | 47 | { |
48 | struct ConnectPeersState *cps = cls; | 48 | struct ConnectPeersState *cps = cls; |
49 | const struct GNUNET_TESTING_Command *system_cmd; | 49 | const struct GNUNET_TESTING_Command *system_cmd; |
50 | struct GNUNET_TESTING_System *tl_system; | 50 | const struct GNUNET_TESTING_System *tl_system; |
51 | 51 | ||
52 | 52 | ||
53 | const struct GNUNET_TESTING_Command *peer1_cmd; | 53 | const struct GNUNET_TESTING_Command *peer1_cmd; |
54 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | 54 | const struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
55 | struct GNUNET_PeerIdentity *peer; | 55 | struct GNUNET_PeerIdentity *peer; |
56 | char *addr; | 56 | char *addr; |
57 | enum GNUNET_NetworkType nt = 0; | 57 | enum GNUNET_NetworkType nt = 0; |
@@ -98,7 +98,9 @@ connect_peers_run (void *cls, | |||
98 | "validating peer number %u with identity %s\n", | 98 | "validating peer number %u with identity %s\n", |
99 | num, | 99 | num, |
100 | GNUNET_i2s (peer)); | 100 | GNUNET_i2s (peer)); |
101 | GNUNET_TRANSPORT_application_validate (ah, | 101 | GNUNET_TRANSPORT_application_validate ((struct |
102 | GNUNET_TRANSPORT_ApplicationHandle | ||
103 | *) ah, | ||
102 | peer, | 104 | peer, |
103 | nt, | 105 | nt, |
104 | addr); | 106 | addr); |
@@ -176,13 +178,9 @@ connect_peers_traits (void *cls, | |||
176 | const char *trait, | 178 | const char *trait, |
177 | unsigned int index) | 179 | unsigned int index) |
178 | { | 180 | { |
179 | struct StartPeerState *cps = cls; | 181 | struct ConnectPeersState *cps = cls; |
180 | struct GNUNET_TESTING_Trait traits[] = { | 182 | struct GNUNET_TESTING_Trait traits[] = { |
181 | { | 183 | GNUNET_TRANSPORT_make_trait_connect_peer_state ((const void *) cps), |
182 | .index = 0, | ||
183 | .trait_name = "state", | ||
184 | .ptr = (const void *) cps, | ||
185 | }, | ||
186 | GNUNET_TESTING_trait_end () | 184 | GNUNET_TESTING_trait_end () |
187 | }; | 185 | }; |
188 | return GNUNET_TESTING_get_trait (traits, | 186 | return GNUNET_TESTING_get_trait (traits, |
@@ -193,25 +191,6 @@ connect_peers_traits (void *cls, | |||
193 | 191 | ||
194 | 192 | ||
195 | /** | 193 | /** |
196 | * Function to get the trait with the struct ConnectPeersState. | ||
197 | * | ||
198 | * @param[out] sps struct ConnectPeersState. | ||
199 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
200 | * | ||
201 | */ | ||
202 | enum GNUNET_GenericReturnValue | ||
203 | GNUNET_TRANSPORT_get_trait_connect_peer_state ( | ||
204 | const struct GNUNET_TESTING_Command *cmd, | ||
205 | struct ConnectPeersState **cps) | ||
206 | { | ||
207 | return cmd->traits (cmd->cls, | ||
208 | (const void **) cps, | ||
209 | "state", | ||
210 | (unsigned int) 0); | ||
211 | } | ||
212 | |||
213 | |||
214 | /** | ||
215 | * Create command | 194 | * Create command |
216 | * | 195 | * |
217 | * @param label name for command | 196 | * @param label name for command |
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c index 8b37dbf90..ade0cc914 100644 --- a/src/transport/transport_api_cmd_send_simple.c +++ b/src/transport/transport_api_cmd_send_simple.c | |||
@@ -114,7 +114,7 @@ send_simple_run (void *cls, | |||
114 | struct GNUNET_TESTING_Interpreter *is) | 114 | struct GNUNET_TESTING_Interpreter *is) |
115 | { | 115 | { |
116 | struct SendSimpleState *sss = cls; | 116 | struct SendSimpleState *sss = cls; |
117 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 117 | const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
118 | const struct GNUNET_TESTING_Command *peer1_cmd; | 118 | const struct GNUNET_TESTING_Command *peer1_cmd; |
119 | // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | 119 | // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); |
120 | struct GNUNET_HashCode hc; | 120 | struct GNUNET_HashCode hc; |
@@ -124,7 +124,7 @@ send_simple_run (void *cls, | |||
124 | uint32_t num; | 124 | uint32_t num; |
125 | struct GNUNET_TESTING_NodeConnection *pos_connection; | 125 | struct GNUNET_TESTING_NodeConnection *pos_connection; |
126 | const struct GNUNET_TESTING_Command *system_cmd; | 126 | const struct GNUNET_TESTING_Command *system_cmd; |
127 | struct GNUNET_TESTING_System *tl_system; | 127 | const struct GNUNET_TESTING_System *tl_system; |
128 | 128 | ||
129 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 129 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
130 | sss->start_peer_label); | 130 | sss->start_peer_label); |
@@ -139,8 +139,10 @@ send_simple_run (void *cls, | |||
139 | node_connections_head = GNUNET_TESTING_get_connections (sss->num, | 139 | node_connections_head = GNUNET_TESTING_get_connections (sss->num, |
140 | sss->topology); | 140 | sss->topology); |
141 | 141 | ||
142 | GNUNET_CONTAINER_multishortmap_iterate (connected_peers_map, send_simple_cb, | 142 | GNUNET_CONTAINER_multishortmap_iterate ( |
143 | sss); | 143 | (struct GNUNET_CONTAINER_MultiShortmap *) |
144 | connected_peers_map, send_simple_cb, | ||
145 | sss); | ||
144 | /*for (int i = 0; i < 1; i++) | 146 | /*for (int i = 0; i < 1; i++) |
145 | { | 147 | { |
146 | for (pos_connection = node_connections_head; NULL != pos_connection; | 148 | for (pos_connection = node_connections_head; NULL != pos_connection; |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index 52eacabb2..be2ea25b4 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -167,7 +167,7 @@ start_peer_run (void *cls, | |||
167 | char *emsg = NULL; | 167 | char *emsg = NULL; |
168 | struct GNUNET_PeerIdentity dummy; | 168 | struct GNUNET_PeerIdentity dummy; |
169 | const struct GNUNET_TESTING_Command *system_cmd; | 169 | const struct GNUNET_TESTING_Command *system_cmd; |
170 | struct GNUNET_TESTING_System *tl_system; | 170 | const struct GNUNET_TESTING_System *tl_system; |
171 | char *home; | 171 | char *home; |
172 | char *transport_unix_path; | 172 | char *transport_unix_path; |
173 | char *tcp_communicator_unix_path; | 173 | char *tcp_communicator_unix_path; |
@@ -251,7 +251,8 @@ start_peer_run (void *cls, | |||
251 | sps->no); | 251 | sps->no); |
252 | 252 | ||
253 | if (GNUNET_SYSERR == | 253 | if (GNUNET_SYSERR == |
254 | GNUNET_TESTING_configuration_create (tl_system, | 254 | GNUNET_TESTING_configuration_create ((struct |
255 | GNUNET_TESTING_System *) tl_system, | ||
255 | sps->cfg)) | 256 | sps->cfg)) |
256 | { | 257 | { |
257 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 258 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -262,7 +263,9 @@ start_peer_run (void *cls, | |||
262 | return; | 263 | return; |
263 | } | 264 | } |
264 | 265 | ||
265 | sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system, | 266 | sps->peer = GNUNET_TESTING_peer_configure ((struct |
267 | GNUNET_TESTING_System *) sps-> | ||
268 | tl_system, | ||
266 | sps->cfg, | 269 | sps->cfg, |
267 | sps->no, | 270 | sps->no, |
268 | NULL, | 271 | NULL, |
@@ -407,36 +410,14 @@ start_peer_traits (void *cls, | |||
407 | 410 | ||
408 | 411 | ||
409 | struct GNUNET_TESTING_Trait traits[] = { | 412 | struct GNUNET_TESTING_Trait traits[] = { |
410 | { | 413 | GNUNET_TRANSPORT_make_trait_application_handle ((const void *) ah), |
411 | .index = 0, | 414 | GNUNET_TRANSPORT_make_trait_peer_id ((const void *) id), |
412 | .trait_name = "application_handle", | 415 | GNUNET_TRANSPORT_make_trait_connected_peers_map ((const |
413 | .ptr = (const void *) ah, | 416 | void *) |
414 | }, | 417 | connected_peers_map), |
415 | { | 418 | GNUNET_TRANSPORT_make_trait_hello ((const void *) hello), |
416 | .index = 1, | 419 | GNUNET_TRANSPORT_make_trait_hello_size ((const void *) hello_size), |
417 | .trait_name = "peer_id", | 420 | GNUNET_TRANSPORT_make_trait_state ((const void *) sps), |
418 | .ptr = (const void *) id, | ||
419 | }, | ||
420 | { | ||
421 | .index = 2, | ||
422 | .trait_name = "connected_peers_map", | ||
423 | .ptr = (const void *) connected_peers_map, | ||
424 | }, | ||
425 | { | ||
426 | .index = 3, | ||
427 | .trait_name = "hello", | ||
428 | .ptr = (const void *) hello, | ||
429 | }, | ||
430 | { | ||
431 | .index = 4, | ||
432 | .trait_name = "hello_size", | ||
433 | .ptr = (const void *) hello_size, | ||
434 | }, | ||
435 | { | ||
436 | .index = 5, | ||
437 | .trait_name = "state", | ||
438 | .ptr = (const void *) sps, | ||
439 | }, | ||
440 | GNUNET_TESTING_trait_end () | 421 | GNUNET_TESTING_trait_end () |
441 | }; | 422 | }; |
442 | 423 | ||
@@ -448,127 +429,6 @@ start_peer_traits (void *cls, | |||
448 | 429 | ||
449 | 430 | ||
450 | /** | 431 | /** |
451 | * Function to get the trait with the struct StartPeerState. | ||
452 | * | ||
453 | * @param[out] sps struct StartPeerState. | ||
454 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
455 | * | ||
456 | */ | ||
457 | int | ||
458 | GNUNET_TRANSPORT_get_trait_state ( | ||
459 | const struct GNUNET_TESTING_Command *cmd, | ||
460 | struct StartPeerState **sps) | ||
461 | { | ||
462 | return cmd->traits (cmd->cls, | ||
463 | (const void **) sps, | ||
464 | "state", | ||
465 | (unsigned int) 5); | ||
466 | } | ||
467 | |||
468 | |||
469 | /** | ||
470 | * Function to get the trait with the size of the hello. | ||
471 | * | ||
472 | * @param[out] hello_size size of hello. | ||
473 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
474 | * | ||
475 | */ | ||
476 | int | ||
477 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | ||
478 | GNUNET_TESTING_Command | ||
479 | *cmd, | ||
480 | size_t **hello_size) | ||
481 | { | ||
482 | return cmd->traits (cmd->cls, | ||
483 | (const void **) hello_size, | ||
484 | "hello_size", | ||
485 | (unsigned int) 4); | ||
486 | } | ||
487 | |||
488 | |||
489 | /** | ||
490 | * Function to get the trait with the hello. | ||
491 | * | ||
492 | * @param[out] hello The hello for the peer. | ||
493 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
494 | * | ||
495 | */ | ||
496 | int | ||
497 | GNUNET_TRANSPORT_get_trait_hello (const struct | ||
498 | GNUNET_TESTING_Command | ||
499 | *cmd, | ||
500 | char **hello) | ||
501 | { | ||
502 | return cmd->traits (cmd->cls, | ||
503 | (const void **) hello, | ||
504 | "hello", | ||
505 | (unsigned int) 3); | ||
506 | } | ||
507 | |||
508 | |||
509 | /** | ||
510 | * Function to get the trait with the map of connected peers. | ||
511 | * | ||
512 | * @param[out] connected_peers_map The map with connected peers. | ||
513 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
514 | * | ||
515 | */ | ||
516 | int | ||
517 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | ||
518 | GNUNET_TESTING_Command | ||
519 | *cmd, | ||
520 | struct | ||
521 | GNUNET_CONTAINER_MultiShortmap | ||
522 | * | ||
523 | * | ||
524 | connected_peers_map) | ||
525 | { | ||
526 | return cmd->traits (cmd->cls, | ||
527 | (const void **) connected_peers_map, | ||
528 | "connected_peers_map", | ||
529 | (unsigned int) 2); | ||
530 | } | ||
531 | |||
532 | |||
533 | /** | ||
534 | * Function to get the trait with the transport application handle. | ||
535 | * | ||
536 | * @param[out] ah The application handle. | ||
537 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
538 | */ | ||
539 | int | ||
540 | GNUNET_TRANSPORT_get_trait_application_handle (const struct | ||
541 | GNUNET_TESTING_Command *cmd, | ||
542 | struct | ||
543 | GNUNET_TRANSPORT_ApplicationHandle | ||
544 | **ah) | ||
545 | { | ||
546 | return cmd->traits (cmd->cls, | ||
547 | (const void **) ah, | ||
548 | "application_handle", | ||
549 | (unsigned int) 0); | ||
550 | } | ||
551 | |||
552 | |||
553 | /** | ||
554 | * Function to get the trait with the peer id. | ||
555 | * | ||
556 | * @param[out] id The peer id. | ||
557 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
558 | */ | ||
559 | int | ||
560 | GNUNET_TRANSPORT_get_trait_peer_id (const struct | ||
561 | GNUNET_TESTING_Command *cmd, | ||
562 | struct GNUNET_PeerIdentity **id) | ||
563 | { | ||
564 | return cmd->traits (cmd->cls, | ||
565 | (const void **) id, | ||
566 | "peer_id", | ||
567 | (unsigned int) 1); | ||
568 | } | ||
569 | |||
570 | |||
571 | /** | ||
572 | * Create command. | 432 | * Create command. |
573 | * | 433 | * |
574 | * @param label name for command. | 434 | * @param label name for command. |
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c index 97408b083..4ca730add 100644 --- a/src/transport/transport_api_cmd_stop_peer.c +++ b/src/transport/transport_api_cmd_stop_peer.c | |||
@@ -58,7 +58,7 @@ stop_peer_run (void *cls, | |||
58 | struct GNUNET_TESTING_Interpreter *is) | 58 | struct GNUNET_TESTING_Interpreter *is) |
59 | { | 59 | { |
60 | struct StopPeerState *stop_ps = cls; | 60 | struct StopPeerState *stop_ps = cls; |
61 | struct StartPeerState *sps; | 61 | const struct StartPeerState *sps; |
62 | const struct GNUNET_TESTING_Command *start_cmd; | 62 | const struct GNUNET_TESTING_Command *start_cmd; |
63 | 63 | ||
64 | start_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 64 | start_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
@@ -69,24 +69,20 @@ stop_peer_run (void *cls, | |||
69 | if (NULL != sps->pic) | 69 | if (NULL != sps->pic) |
70 | { | 70 | { |
71 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | 71 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); |
72 | sps->pic = NULL; | ||
73 | } | 72 | } |
74 | if (NULL != sps->th) | 73 | if (NULL != sps->th) |
75 | { | 74 | { |
76 | GNUNET_TRANSPORT_core_disconnect (sps->th); | 75 | GNUNET_TRANSPORT_core_disconnect (sps->th); |
77 | sps->th = NULL; | ||
78 | } | 76 | } |
79 | if (NULL != sps->ah) | 77 | if (NULL != sps->ah) |
80 | { | 78 | { |
81 | GNUNET_TRANSPORT_application_done (sps->ah); | 79 | GNUNET_TRANSPORT_application_done (sps->ah); |
82 | sps->ah = NULL; | ||
83 | } | 80 | } |
84 | if (NULL != sps->ph) | 81 | if (NULL != sps->ph) |
85 | { | 82 | { |
86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
87 | "Disconnecting from PEERSTORE service\n"); | 84 | "Disconnecting from PEERSTORE service\n"); |
88 | GNUNET_PEERSTORE_disconnect (sps->ph, GNUNET_NO); | 85 | GNUNET_PEERSTORE_disconnect (sps->ph, GNUNET_NO); |
89 | sps->ph = NULL; | ||
90 | } | 86 | } |
91 | if (NULL != sps->peer) | 87 | if (NULL != sps->peer) |
92 | { | 88 | { |
@@ -99,12 +95,9 @@ stop_peer_run (void *cls, | |||
99 | GNUNET_i2s (&sps->id)); | 95 | GNUNET_i2s (&sps->id)); |
100 | } | 96 | } |
101 | GNUNET_TESTING_peer_destroy (sps->peer); | 97 | GNUNET_TESTING_peer_destroy (sps->peer); |
102 | sps->peer = NULL; | ||
103 | } | 98 | } |
104 | if (NULL != sps->rh_task) | 99 | if (NULL != sps->rh_task) |
105 | GNUNET_SCHEDULER_cancel (sps->rh_task); | 100 | GNUNET_SCHEDULER_cancel (sps->rh_task); |
106 | sps->rh_task = NULL; | ||
107 | |||
108 | } | 101 | } |
109 | 102 | ||
110 | 103 | ||