aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_limited_sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_limited_sockets.c')
-rw-r--r--src/transport/test_transport_api_limited_sockets.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index 1a04ad6fe..be91a5947 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -59,15 +59,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
59 59
60static struct GNUNET_SCHEDULER_Task * send_task; 60static struct GNUNET_SCHEDULER_Task * send_task;
61 61
62static struct PeerContext *p1; 62static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
63 63
64static struct PeerContext *p2; 64static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
65 65
66static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 66static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
67 67
68static struct GNUNET_TRANSPORT_TransmitHandle *th; 68static struct GNUNET_TRANSPORT_TransmitHandle *th;
69 69
70static struct GNUNET_TRANSPORT_TESTING_handle *tth; 70static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
71 71
72static char *cfg_file_p1; 72static char *cfg_file_p1;
73 73
@@ -95,8 +95,8 @@ end ()
95 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 95 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
96 th = NULL; 96 th = NULL;
97 97
98 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 98 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
99 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 99 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
100 GNUNET_TRANSPORT_TESTING_done (tth); 100 GNUNET_TRANSPORT_TESTING_done (tth);
101 101
102} 102}
@@ -112,16 +112,16 @@ end_badly (void *cls)
112 GNUNET_SCHEDULER_cancel (send_task); 112 GNUNET_SCHEDULER_cancel (send_task);
113 113
114 if (cc != NULL) 114 if (cc != NULL)
115 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 115 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
116 116
117 if (th != NULL) 117 if (th != NULL)
118 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 118 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
119 th = NULL; 119 th = NULL;
120 120
121 if (p1 != NULL) 121 if (p1 != NULL)
122 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 122 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
123 if (p2 != NULL) 123 if (p2 != NULL)
124 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 124 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
125 125
126 if (NULL != th) 126 if (NULL != th)
127 GNUNET_TRANSPORT_TESTING_done (tth); 127 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -156,7 +156,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
156static size_t 156static size_t
157notify_ready (void *cls, size_t size, void *buf) 157notify_ready (void *cls, size_t size, void *buf)
158{ 158{
159 struct PeerContext *p = cls; 159 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
160 struct GNUNET_MessageHeader *hdr; 160 struct GNUNET_MessageHeader *hdr;
161 161
162 th = NULL; 162 th = NULL;
@@ -206,7 +206,7 @@ sendtask (void *cls)
206 206
207 207
208static void 208static void
209testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 209testing_connect_cb (void *cls)
210{ 210{
211 cc = NULL; 211 cc = NULL;
212 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 212 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -221,7 +221,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
221} 221}
222 222
223static void 223static void
224start_cb (struct PeerContext *p, void *cls) 224start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
225{ 225{
226 static int started; 226 static int started;
227 227
@@ -233,7 +233,9 @@ start_cb (struct PeerContext *p, void *cls)
233 if (started != 2) 233 if (started != 2)
234 return; 234 return;
235 235
236 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb, 236 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p2,
237 p1,
238 &testing_connect_cb,
237 NULL); 239 NULL);
238 240
239} 241}
@@ -246,13 +248,21 @@ run (void *cls, char *const *args, const char *cfgfile,
246 248
247 tth = GNUNET_TRANSPORT_TESTING_init (); 249 tth = GNUNET_TRANSPORT_TESTING_init ();
248 250
249 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 251 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
250 &notify_receive, &notify_connect, 252 cfg_file_p1,
251 &notify_disconnect, &start_cb, 253 1,
254 &notify_receive,
255 &notify_connect,
256 &notify_disconnect,
257 &start_cb,
252 NULL); 258 NULL);
253 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 259 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
254 &notify_receive, &notify_connect, 260 cfg_file_p2,
255 &notify_disconnect, &start_cb, 261 2,
262 &notify_receive,
263 &notify_connect,
264 &notify_disconnect,
265 &start_cb,
256 NULL); 266 NULL);
257 if ((p1 == NULL) || (p2 == NULL)) 267 if ((p1 == NULL) || (p2 == NULL))
258 { 268 {
@@ -298,11 +308,10 @@ main (int argc, char *argv[])
298 int res; 308 int res;
299 int ret = 0; 309 int ret = 0;
300 310
301 test_plugin = NULL; 311 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
302 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 312 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
303 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 313 test_source);
304 &test_plugin); 314 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
305 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
306 GNUNET_log_setup (test_name, 315 GNUNET_log_setup (test_name,
307 "WARNING", 316 "WARNING",
308 NULL); 317 NULL);
@@ -328,8 +337,8 @@ main (int argc, char *argv[])
328 return 0; 337 return 0;
329 } 338 }
330 339
331 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 340 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
332 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 341 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
333 ret = check (); 342 ret = check ();
334 343
335 GNUNET_free (cfg_file_p1); 344 GNUNET_free (cfg_file_p1);