[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37552 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37552 - gnunet/src/cadet |
Date: |
Wed, 20 Jul 2016 14:07:05 +0200 |
Author: bartpolot
Date: 2016-07-20 14:07:05 +0200 (Wed, 20 Jul 2016)
New Revision: 37552
Modified:
gnunet/src/cadet/cadet_test_lib.c
gnunet/src/cadet/cadet_test_lib.h
gnunet/src/cadet/gnunet-cadet-profiler.c
gnunet/src/cadet/gnunet-service-cadet_channel.c
gnunet/src/cadet/gnunet-service-cadet_local.c
gnunet/src/cadet/gnunet-service-cadet_local.h
gnunet/src/cadet/test_cadet.c
gnunet/src/cadet/test_cadet_local.c
gnunet/src/cadet/test_cadet_single.c
Log:
- adapt test cases / framework to new port system
Modified: gnunet/src/cadet/cadet_test_lib.c
===================================================================
--- gnunet/src/cadet/cadet_test_lib.c 2016-07-20 12:07:02 UTC (rev 37551)
+++ gnunet/src/cadet/cadet_test_lib.c 2016-07-20 12:07:05 UTC (rev 37552)
@@ -80,7 +80,7 @@
/**
* Application ports.
*/
- const uint32_t *ports;
+ const struct GNUNET_HashCode **ports;
};
@@ -94,7 +94,7 @@
* Peer number for the particular peer.
*/
unsigned int peer;
-
+
/**
* General context.
*/
@@ -124,6 +124,16 @@
(void *) (long) actx->peer,
ctx->cleaner,
ctx->handlers);
+ if (NULL == ctx->ports)
+ return h;
+
+ for (int i = 0; NULL != ctx->ports[i]; i++)
+ {
+ (void ) GNUNET_CADET_open_port (h, ctx->ports[i],
+ ctx->new_channel,
+ (void *) (long) actx->peer);
+ }
+
return h;
}
@@ -269,7 +279,7 @@
GNUNET_CADET_InboundChannelNotificationHandler
new_channel,
GNUNET_CADET_ChannelEndHandler cleaner,
struct GNUNET_CADET_MessageHandler* handlers,
- const uint32_t *ports)
+ const struct GNUNET_HashCode **ports)
{
struct GNUNET_CADET_TEST_Context *ctx;
Modified: gnunet/src/cadet/cadet_test_lib.h
===================================================================
--- gnunet/src/cadet/cadet_test_lib.h 2016-07-20 12:07:02 UTC (rev 37551)
+++ gnunet/src/cadet/cadet_test_lib.h 2016-07-20 12:07:05 UTC (rev 37552)
@@ -71,7 +71,7 @@
* @param new_channel Handler for incoming tunnels.
* @param cleaner Cleaner for destroyed incoming tunnels.
* @param handlers Message handlers.
- * @param ports Ports the peers offer.
+ * @param ports Ports the peers offer, NULL-terminated.
*/
void
GNUNET_CADET_TEST_run (const char *testname,
@@ -82,7 +82,7 @@
GNUNET_CADET_InboundChannelNotificationHandler
new_channel,
GNUNET_CADET_ChannelEndHandler cleaner,
struct GNUNET_CADET_MessageHandler* handlers,
- const uint32_t* ports);
+ const struct GNUNET_HashCode **ports);
/**
Modified: gnunet/src/cadet/gnunet-cadet-profiler.c
===================================================================
--- gnunet/src/cadet/gnunet-cadet-profiler.c 2016-07-20 12:07:02 UTC (rev
37551)
+++ gnunet/src/cadet/gnunet-cadet-profiler.c 2016-07-20 12:07:05 UTC (rev
37552)
@@ -816,7 +816,8 @@
static void *
incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port, enum GNUNET_CADET_ChannelOption options)
+ const struct GNUNET_HashCode *port,
+ enum GNUNET_CADET_ChannelOption options)
{
long n = (long) cls;
struct CadetPeer *peer;
@@ -921,7 +922,7 @@
peers[i].dest = select_random_peer (&peers[i]);
peers[i].ch = GNUNET_CADET_channel_create (peers[i].cadet, NULL,
&peers[i].dest->id,
- 1, flags);
+ GC_u2h (1), flags);
if (NULL == peers[i].ch)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i);
@@ -966,7 +967,7 @@
i, get_index (peer));
peers[i].warmup_ch =
GNUNET_CADET_channel_create (peers[i].cadet, NULL, &peer->id,
- 1, GNUNET_CADET_OPTION_DEFAULT);
+ GC_u2h (1), GNUNET_CADET_OPTION_DEFAULT);
if (NULL == peers[i].warmup_ch)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Warmup %u failed\n", i);
@@ -1083,7 +1084,7 @@
int
main (int argc, char *argv[])
{
- static uint32_t ports[2];
+ static const struct GNUNET_HashCode *ports[2];
const char *config_file;
config_file = ".profiler.conf";
@@ -1135,7 +1136,7 @@
GNUNET_assert (NULL != ids);
p_ids = 0;
test_finished = GNUNET_NO;
- ports[0] = 1;
+ ports[0] = GC_u2h (1);
ports[1] = 0;
GNUNET_CADET_TEST_run ("cadet-profiler", config_file, peers_total,
&tmain, NULL, /* tmain cls */
Modified: gnunet/src/cadet/gnunet-service-cadet_channel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_channel.c 2016-07-20 12:07:02 UTC
(rev 37551)
+++ gnunet/src/cadet/gnunet-service-cadet_channel.c 2016-07-20 12:07:05 UTC
(rev 37552)
@@ -2149,7 +2149,7 @@
struct CadetChannel *ch;
struct CadetClient *c;
int new_channel;
- struct GNUNET_HashCode *port;
+ const struct GNUNET_HashCode *port;
chid = ntohl (msg->chid);
Modified: gnunet/src/cadet/gnunet-service-cadet_local.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_local.c 2016-07-20 12:07:02 UTC
(rev 37551)
+++ gnunet/src/cadet/gnunet-service-cadet_local.c 2016-07-20 12:07:05 UTC
(rev 37552)
@@ -1312,7 +1312,7 @@
* @return non-NULL if a client has the port.
*/
struct CadetClient *
-GML_client_get_by_port (struct GNUNET_HashCode *port)
+GML_client_get_by_port (const struct GNUNET_HashCode *port)
{
return GNUNET_CONTAINER_multihashmap_get (ports, port);
}
Modified: gnunet/src/cadet/gnunet-service-cadet_local.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_local.h 2016-07-20 12:07:02 UTC
(rev 37551)
+++ gnunet/src/cadet/gnunet-service-cadet_local.h 2016-07-20 12:07:05 UTC
(rev 37552)
@@ -134,7 +134,7 @@
* @return non-NULL if a client has the port.
*/
struct CadetClient *
-GML_client_get_by_port (struct GNUNET_HashCode *port);
+GML_client_get_by_port (const struct GNUNET_HashCode *port);
/**
* Deletes a tunnel from a client (either owner or destination).
Modified: gnunet/src/cadet/test_cadet.c
===================================================================
--- gnunet/src/cadet/test_cadet.c 2016-07-20 12:07:02 UTC (rev 37551)
+++ gnunet/src/cadet/test_cadet.c 2016-07-20 12:07:05 UTC (rev 37552)
@@ -97,6 +97,11 @@
struct GNUNET_PeerIdentity *p_id[2];
/**
+ * Port ID
+ */
+struct GNUNET_HashCode port;
+
+/**
* Peer ids counter.
*/
unsigned int p_ids;
@@ -761,12 +766,13 @@
static void *
incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port, enum GNUNET_CADET_ChannelOption options)
+ const struct GNUNET_HashCode *port,
+ enum GNUNET_CADET_ChannelOption options)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Incoming channel from %s to peer %d\n",
+ "Incoming channel from %s to peer %d:%s\n",
GNUNET_i2s (initiator),
- (int) (long) cls);
+ (int) (long) cls, GNUNET_h2s (port));
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
if ((long) cls == peers_requested - 1)
@@ -865,8 +871,9 @@
test = SPEED;
flags |= GNUNET_CADET_OPTION_RELIABLE;
}
- ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], 1, flags);
+ ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], &port, flags);
+
disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
&gather_stats_and_exit,
(void *) __LINE__);
@@ -965,8 +972,10 @@
main (int argc, char *argv[])
{
initialized = GNUNET_NO;
- static uint32_t ports[2];
+ static const struct GNUNET_HashCode *ports[2];
const char *config_file;
+ char port_id[] = "test port";
+ GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
GNUNET_log_setup ("test", "DEBUG", NULL);
config_file = "test_cadet.conf";
@@ -1066,8 +1075,8 @@
}
p_ids = 0;
- ports[0] = 1;
- ports[1] = 0;
+ ports[0] = &port;
+ ports[1] = NULL;
GNUNET_CADET_TEST_run ("test_cadet_small",
config_file,
peers_requested,
Modified: gnunet/src/cadet/test_cadet_local.c
===================================================================
--- gnunet/src/cadet/test_cadet_local.c 2016-07-20 12:07:02 UTC (rev 37551)
+++ gnunet/src/cadet/test_cadet_local.c 2016-07-20 12:07:05 UTC (rev 37552)
@@ -149,15 +149,15 @@
inbound_channel (void *cls,
struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port,
+ const struct GNUNET_HashCode *port,
enum GNUNET_CADET_ChannelOption options)
{
long id = (long) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "received incoming channel on peer %d, port %u\n",
+ "received incoming channel on peer %d, port %s\n",
(int) id,
- (unsigned int) port);
+ GNUNET_h2s (port));
if (id != 2L)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -259,7 +259,7 @@
connect_task = NULL;
GNUNET_TESTING_peer_get_identity (me, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n");
- ch = GNUNET_CADET_channel_create (cadet_peer_1, NULL, &id, 1,
+ ch = GNUNET_CADET_channel_create (cadet_peer_1, NULL, &id, GC_u2h (1),
GNUNET_CADET_OPTION_DEFAULT);
mth = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO,
GNUNET_TIME_UNIT_FOREVER_REL,
@@ -280,8 +280,6 @@
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
- static uint32_t ports[] = {1, 0};
-
me = peer;
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
abort_task =
@@ -291,17 +289,16 @@
NULL);
cadet_peer_1 = GNUNET_CADET_connect (cfg, /* configuration */
(void *) 1L, /* cls */
- NULL, /* inbound new hndlr */
&channel_end, /* channel end hndlr */
- handlers1, /* traffic handlers */
- NULL); /* ports offered */
+ handlers1); /* traffic handlers */
cadet_peer_2 = GNUNET_CADET_connect (cfg, /* configuration */
(void *) 2L, /* cls */
- &inbound_channel, /* inbound new hndlr
*/
&channel_end, /* channel end hndlr */
- handlers2, /* traffic handlers */
- ports); /* ports offered */
+ handlers2); /* traffic handlers */
+ GNUNET_CADET_open_port (cadet_peer_2, GC_u2h (1),
+ &inbound_channel, (void *) 2L);
+
if (NULL == cadet_peer_1 || NULL == cadet_peer_2)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
Modified: gnunet/src/cadet/test_cadet_single.c
===================================================================
--- gnunet/src/cadet/test_cadet_single.c 2016-07-20 12:07:02 UTC (rev
37551)
+++ gnunet/src/cadet/test_cadet_single.c 2016-07-20 12:07:05 UTC (rev
37552)
@@ -160,12 +160,13 @@
*/
static void *
inbound_channel (void *cls, struct GNUNET_CADET_Channel *channel,
- const struct GNUNET_PeerIdentity *initiator,
- uint32_t port, enum GNUNET_CADET_ChannelOption options)
+ const struct GNUNET_PeerIdentity *initiator,
+ const struct GNUNET_HashCode *port,
+ enum GNUNET_CADET_ChannelOption options)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "received incoming channel on port %u\n",
- port);
+ "received incoming channel on port %s\n",
+ GNUNET_h2s (port));
ch2 = channel;
return NULL;
}
@@ -249,8 +250,8 @@
connect_task = NULL;
GNUNET_TESTING_peer_get_identity (me, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n");
- ch1 = GNUNET_CADET_channel_create (cadet, NULL, &id, 1,
- GNUNET_CADET_OPTION_DEFAULT);
+ ch1 = GNUNET_CADET_channel_create (cadet, NULL, &id, GC_u2h (1),
+ GNUNET_CADET_OPTION_DEFAULT);
GNUNET_CADET_notify_transmit_ready (ch1, GNUNET_NO,
GNUNET_TIME_UNIT_FOREVER_REL,
size, &do_send, NULL);
@@ -269,8 +270,6 @@
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
- static uint32_t ports[] = {1, 0};
-
me = peer;
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
abort_task =
@@ -279,11 +278,11 @@
NULL);
cadet = GNUNET_CADET_connect (cfg, /* configuration */
(void *) 1L, /* cls */
- &inbound_channel, /* inbound new hndlr */
&channel_end, /* inbound end hndlr */
- handlers1, /* traffic handlers */
- ports); /* ports offered */
+ handlers1); /* traffic handlers */
+ GNUNET_CADET_open_port (cadet, GC_u2h (1), &inbound_channel, (void *) 1L);
+
if (NULL == cadet)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to cadet :(\n");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37552 - gnunet/src/cadet,
gnunet <=