/**
* Application ports.
*/
- const uint32_t *ports;
+ const struct GNUNET_HashCode **ports;
};
* Peer number for the particular peer.
*/
unsigned int peer;
-
+
/**
* General context.
*/
(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;
}
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;
* @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,
GNUNET_CADET_InboundChannelNotificationHandler new_channel,
GNUNET_CADET_ChannelEndHandler cleaner,
struct GNUNET_CADET_MessageHandler* handlers,
- const uint32_t* ports);
+ const struct GNUNET_HashCode **ports);
/**
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;
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);
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);
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";
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 */
struct CadetChannel *ch;
struct CadetClient *c;
int new_channel;
- struct GNUNET_HashCode *port;
+ const struct GNUNET_HashCode *port;
chid = ntohl (msg->chid);
* @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);
}
* @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).
*/
struct GNUNET_PeerIdentity *p_id[2];
+/**
+ * Port ID
+ */
+struct GNUNET_HashCode port;
+
/**
* Peer ids counter.
*/
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)
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,
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";
}
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,
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,
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,
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 =
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,
*/
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;
}
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);
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 =
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)
{