aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-07-13 15:28:06 +0000
committerBart Polot <bart@net.in.tum.de>2012-07-13 15:28:06 +0000
commite8bb2d25fbade797e1a2d1573c9e143b70557949 (patch)
treed1ebcdf857dbd43975a837b244105c9a81b31397 /src
parentd6f54d88f5aeddb925cf69337c83dca176e9ecee (diff)
downloadgnunet-e8bb2d25fbade797e1a2d1573c9e143b70557949.tar.gz
gnunet-e8bb2d25fbade797e1a2d1573c9e143b70557949.zip
- full version of testcase, included data traffic to trigger individual incoming tunnel detection
Diffstat (limited to 'src')
-rw-r--r--src/mesh/test_mesh_regex.c84
1 files changed, 61 insertions, 23 deletions
diff --git a/src/mesh/test_mesh_regex.c b/src/mesh/test_mesh_regex.c
index 499eac5bf..a58828dee 100644
--- a/src/mesh/test_mesh_regex.c
+++ b/src/mesh/test_mesh_regex.c
@@ -29,7 +29,7 @@
29 29
30#define VERBOSE GNUNET_YES 30#define VERBOSE GNUNET_YES
31#define REMOVE_DIR GNUNET_YES 31#define REMOVE_DIR GNUNET_YES
32#define MESH_REGEX_PEERS 2 32#define MESH_REGEX_PEERS 1
33 33
34/** 34/**
35 * How long until we give up on connecting the peers? 35 * How long until we give up on connecting the peers?
@@ -120,24 +120,23 @@ static struct GNUNET_MESH_Tunnel *incoming_t[MESH_REGEX_PEERS];
120/** 120/**
121 * Regular expressions for the announces. 121 * Regular expressions for the announces.
122 */ 122 */
123static char *regexes[MESH_REGEX_PEERS] = {"(0|1)" 123static char *regexes[MESH_REGEX_PEERS] = {/*"(0|1)"
124 "(0|1)" 124 "(0|1)"
125 "23456789A*BC", 125 "23456789ABC",
126 126
127 "0123456789ABC"/*, 127 "0123456789A*BC",*/
128 128
129 "0*123456789ABC*"*/}; 129 "0*123456789ABC*"};
130// "(0|1|2|3|4|5|6|7|8|9)"
131 130
132 131
133/** 132/**
134 * Service strings to look for. 133 * Service strings to look for.
135 */ 134 */
136static char *strings[MESH_REGEX_PEERS] = {"0123456789ABC", 135static char *strings[MESH_REGEX_PEERS] = {/*"1123456789ABC",
137 136
138 "0123456789ABC"/*, 137 "0123456789AABC",*/
139 138
140 "000123456789ABCCCC"*/}; 139 "00123456789ABCCCC"};
141 140
142/** 141/**
143 * Check whether peers successfully shut down. 142 * Check whether peers successfully shut down.
@@ -248,6 +247,28 @@ dh (void *cls, const struct GNUNET_PeerIdentity *peer)
248 return; 247 return;
249} 248}
250 249
250/**
251 * Function called to notify a client about the connection
252 * begin ready to queue more data. "buf" will be
253 * NULL and "size" zero if the connection was closed for
254 * writing in the meantime.
255 *
256 * @param cls closure
257 * @param size number of bytes available in buf
258 * @param buf where the callee should write the message
259 * @return number of bytes written to buf
260 */
261static size_t
262data_ready (void *cls, size_t size, void *buf)
263{
264 struct GNUNET_MessageHeader *m = buf;
265
266 if (NULL == buf || size < sizeof(struct GNUNET_MessageHeader))
267 return 0;
268 m->type = htons (1);
269 m->size = htons (sizeof(struct GNUNET_MessageHeader));
270 return sizeof(struct GNUNET_MessageHeader);
271}
251 272
252/** 273/**
253 * Method called whenever a peer connects to a tunnel. 274 * Method called whenever a peer connects to a tunnel.
@@ -266,14 +287,12 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer,
266 "Peer connected: %s\n", 287 "Peer connected: %s\n",
267 GNUNET_i2s (peer)); 288 GNUNET_i2s (peer));
268 connected_peers++; 289 connected_peers++;
269 GNUNET_assert (i = 1L); 290
270 291 GNUNET_MESH_notify_transmit_ready(t[i], 0, 0,
271 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 292 GNUNET_TIME_UNIT_FOREVER_REL,
272 { 293 peer,
273 GNUNET_SCHEDULER_cancel (disconnect_task); 294 sizeof(struct GNUNET_MessageHeader),
274 disconnect_task = 295 &data_ready, NULL);
275 GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
276 }
277} 296}
278 297
279/** 298/**
@@ -296,11 +315,10 @@ incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
296 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 315 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
297 "Incoming tunnel from %s to peer %d\n", 316 "Incoming tunnel from %s to peer %d\n",
298 GNUNET_i2s (initiator), (long) cls); 317 GNUNET_i2s (initiator), (long) cls);
299 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
300 if (i > 1L && i <= 1L + MESH_REGEX_PEERS) 318 if (i > 1L && i <= 1L + MESH_REGEX_PEERS)
301 { 319 {
302 incoming_t[i - 1] = tunnel; 320 incoming_t[i - 2] = tunnel;
303 ok[i - 1] = GNUNET_OK; 321 ok[i - 2] = GNUNET_OK;
304 } 322 }
305 else 323 else
306 { 324 {
@@ -334,7 +352,26 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
334 const struct GNUNET_MessageHeader *message, 352 const struct GNUNET_MessageHeader *message,
335 const struct GNUNET_ATS_Information *atsi) 353 const struct GNUNET_ATS_Information *atsi)
336{ 354{
337 return GNUNET_OK; 355 int i;
356 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
357 "test: GOT DATA!\n");
358 for (i = 0; i < MESH_REGEX_PEERS; i++)
359 {
360 if (GNUNET_OK != ok[i]) {
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
362 "test: %u DATA MISSING!\n", i);
363 return GNUNET_OK;
364 }
365 }
366 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
367 "test: EVERYONE GOT DATA, FINISHING!\n");
368 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
369 {
370 GNUNET_SCHEDULER_cancel (disconnect_task);
371 disconnect_task =
372 GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
373 }
374 return GNUNET_OK;
338} 375}
339 376
340/** 377/**
@@ -395,11 +432,12 @@ peergroup_ready (void *cls, const char *emsg)
395 NULL, 432 NULL,
396 handlers, 433 handlers,
397 &app); 434 &app);
435 connected_peers = 0;
398 for (i = 0; i < MESH_REGEX_PEERS; i++) 436 for (i = 0; i < MESH_REGEX_PEERS; i++)
399 { 437 {
400 ok[i] = GNUNET_NO; 438 ok[i] = GNUNET_NO;
401 d = GNUNET_TESTING_daemon_get (pg, 10 + i); 439 d = GNUNET_TESTING_daemon_get (pg, 10 + i);
402 h2[i] = GNUNET_MESH_connect (d->cfg, 5, (void *) (long) (i + 1), 440 h2[i] = GNUNET_MESH_connect (d->cfg, 5, (void *) (long) (i + 2),
403 &incoming_tunnel, 441 &incoming_tunnel,
404 &tunnel_cleaner, 442 &tunnel_cleaner,
405 handlers, 443 handlers,
@@ -413,7 +451,7 @@ peergroup_ready (void *cls, const char *emsg)
413 { 451 {
414 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 452 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
415 "Create tunnel\n"); 453 "Create tunnel\n");
416 t[i] = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L); 454 t[i] = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) (long) i);
417 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 455 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
418 "Connect by string %s\n", strings[i]); 456 "Connect by string %s\n", strings[i]);
419 GNUNET_MESH_peer_request_connect_by_string (t[i], strings[i]); 457 GNUNET_MESH_peer_request_connect_by_string (t[i], strings[i]);