aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-26 12:42:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-26 12:42:21 +0000
commitb1d6e04df1db5221c70a36d15a8011ef6b5ba38f (patch)
treeeca0fa8c823f53a4ec574ccd5bd8d1f990c0e31f /src
parente4cd44308b1130f02d6c4ed3116b2b26ffbff78a (diff)
downloadgnunet-b1d6e04df1db5221c70a36d15a8011ef6b5ba38f.tar.gz
gnunet-b1d6e04df1db5221c70a36d15a8011ef6b5ba38f.zip
- test code
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index e46eb8ea3..3d35a52d2 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -64,6 +64,8 @@
64#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 64#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
65 65
66 66
67#define TEST_NEW_CODE GNUNET_NO
68
67/** 69/**
68 * Entry in neighbours. 70 * Entry in neighbours.
69 */ 71 */
@@ -589,6 +591,39 @@ change (struct NeighbourMapEntry *n, int state, int line)
589} 591}
590 592
591static ssize_t 593static ssize_t
594send_with_session (struct NeighbourMapEntry *n,
595 struct Session *session,
596 const char *msgbuf, size_t msgbuf_size,
597 uint32_t priority,
598 struct GNUNET_TIME_Relative timeout,
599 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
600{
601 struct GNUNET_TRANSPORT_PluginFunctions *papi;
602 size_t ret = GNUNET_SYSERR;
603
604 papi = GST_plugins_find (n->address->transport_name);
605 if (papi == NULL)
606 {
607 if (cont != NULL)
608 cont (cont_cls, &n->id, GNUNET_SYSERR);
609 return GNUNET_SYSERR;
610 }
611
612 ret = papi->send_with_session (papi->cls,
613 session,
614 msgbuf, msgbuf_size,
615 0,
616 timeout,
617 cont, cont_cls);
618
619 if ((ret == -1) && (cont != NULL))
620 cont (cont_cls, &n->id, GNUNET_SYSERR);
621 return ret;
622}
623
624
625
626static ssize_t
592send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, 627send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
593 size_t msgbuf_size, uint32_t priority, 628 size_t msgbuf_size, uint32_t priority,
594 struct GNUNET_TIME_Relative timeout, struct Session *session, 629 struct GNUNET_TIME_Relative timeout, struct Session *session,
@@ -1452,11 +1487,11 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1452 1487
1453#if TEST_NEW_CODE 1488#if TEST_NEW_CODE
1454 /* Obtain an session for this address from plugin */ 1489 /* Obtain an session for this address from plugin */
1490 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1455 papi = GST_plugins_find (address->transport_name); 1491 papi = GST_plugins_find (address->transport_name);
1456 GNUNET_assert (papi != NULL); 1492 GNUNET_assert (papi != NULL);
1457 if (session == NULL) 1493 if (session == NULL)
1458 { 1494 {
1459 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1460 n->session = papi->get_session (papi->cls, address); 1495 n->session = papi->get_session (papi->cls, address);
1461 /* Session could not be initiated */ 1496 /* Session could not be initiated */
1462 if (n->session == NULL) 1497 if (n->session == NULL)
@@ -1493,6 +1528,9 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1493 } 1528 }
1494#else 1529#else
1495 n->session = session; 1530 n->session = session;
1531
1532 /* dummy */
1533 if (NULL != NULL) send_with_session(NULL, NULL, NULL, 0, 0, GNUNET_TIME_relative_get_zero(), NULL, NULL);
1496#endif 1534#endif
1497 1535
1498 switch (n->state) 1536 switch (n->state)
@@ -1527,11 +1565,19 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1527 cc = GNUNET_malloc (sizeof (struct ContinutionContext)); 1565 cc = GNUNET_malloc (sizeof (struct ContinutionContext));
1528 cc->session = session; 1566 cc->session = session;
1529 cc->address = GNUNET_HELLO_address_copy (address); 1567 cc->address = GNUNET_HELLO_address_copy (address);
1568#if TEST_NEW_CODE
1569 ret = send_with_session(n, n->session,
1570 (const void *) &connect_msg, msg_len,
1571 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
1572 &send_connect_ack_continuation,
1573 cc);
1574#else
1530 ret = 1575 ret =
1531 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, 1576 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
1532 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1577 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1533 address, GNUNET_YES, &send_connect_ack_continuation, 1578 address, GNUNET_YES, &send_connect_ack_continuation,
1534 cc); 1579 cc);
1580#endif
1535 return GNUNET_NO; 1581 return GNUNET_NO;
1536 case S_CONNECTED: 1582 case S_CONNECTED:
1537 case S_FAST_RECONNECT: 1583 case S_FAST_RECONNECT: