new_state,
cc->mqm_ready,
new_mqm_ready);
-
+
if ((new_state == cc->state) && (new_mqm_ready == cc->mqm_ready))
return; /* no change, nothing to do */
old_ready =
GCT_2s (cc->ct->t),
old_ready,
new_ready);
-
+
if (old_ready != new_ready)
cc->ready_cb (cc->ready_cb_cls, new_ready);
}
}
-int
-set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage * msg)
+void
+set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage *msg)
{
- struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
- .purpose.size = htonl (sizeof(cp)),
- .monotonic_time = msg->monotime};
- if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (my_private_key, &cp.purpose, &msg->monotime_sig))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
+ struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
+ .purpose.size = htonl (sizeof(cp)),
+ .monotonic_time = msg->monotime};
+
+ GNUNET_CRYPTO_eddsa_sign (my_private_key, &cp,
+ &msg->monotime_sig);
+
}
/**
struct GNUNET_PeerIdentity *pids;
struct GNUNET_MQ_Envelope *env;
struct CadetTunnel *t;
-
+
cc->task = NULL;
GNUNET_assert (GNUNET_YES == cc->mqm_ready);
env =
// check for tunnel state and set signed monotime (xrs,t3ss)
t = GCP_get_tunnel (cc->destination, GNUNET_YES);
- if (NULL != t && (GCT_get_estate(t) == CADET_TUNNEL_KEY_UNINITIALIZED) &&
- (GCT_alice_or_betty (GCP_get_id(cc->destination)) == GNUNET_NO))
+ if ((NULL != t)&& (GCT_get_estate (t) == CADET_TUNNEL_KEY_UNINITIALIZED) &&
+ (GCT_alice_or_betty (GCP_get_id (cc->destination)) == GNUNET_NO))
{
create_msg->has_monotime = GNUNET_YES;
- create_msg->monotime = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic(cfg));
- GNUNET_assert (GNUNET_OK == set_monotime_sig(create_msg));
+ create_msg->monotime = GNUNET_TIME_absolute_hton (
+ GNUNET_TIME_absolute_get_monotonic (cfg));
+ set_monotime_sig (create_msg);
}
pids = (struct GNUNET_PeerIdentity *) &create_msg[1];
/*
* FIXME: comment
*/
-void
+void
GCP_update_monotime (struct CadetPeer *peer)
{
- peer->last_connection_create = GNUNET_TIME_absolute_get_monotonic(cfg);
+ peer->last_connection_create = GNUNET_TIME_absolute_get_monotonic (cfg);
}
/*
* FIXME: comment
*/
-int
-GCP_check_and_update_monotime (struct CadetPeer *peer,
+int
+GCP_check_and_update_monotime (struct CadetPeer *peer,
struct GNUNET_TIME_AbsoluteNBO monotime)
{
- struct GNUNET_TIME_Absolute mt = GNUNET_TIME_absolute_ntoh(monotime);
-
- if (mt.abs_value_us > *(&peer->last_connection_create.abs_value_us)){
+ struct GNUNET_TIME_Absolute mt = GNUNET_TIME_absolute_ntoh (monotime);
+
+ if (mt.abs_value_us > *(&peer->last_connection_create.abs_value_us))
+ {
peer->last_connection_create = mt;
return GNUNET_YES;
}
* FIXME: documentation here
*/
int
-GCP_check_monotime_sig (struct CadetPeer *peer, const struct GNUNET_CADET_ConnectionCreateMessage *msg)
+GCP_check_monotime_sig (struct CadetPeer *peer, const struct
+ GNUNET_CADET_ConnectionCreateMessage *msg)
{
- //struct CadetPeer *peer;
- //const struct GNUNET_CADET_ConnectionCreateMessage *msg;
+ // struct CadetPeer *peer;
+ // const struct GNUNET_CADET_ConnectionCreateMessage *msg;
- struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
- .purpose.size = htonl (sizeof(cp)),
- .monotonic_time = msg->monotime};
+ struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
+ .purpose.size = htonl (sizeof(cp)),
+ .monotonic_time = msg->monotime};
if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR,
- &cp.purpose,
- &msg->monotime_sig,
- &peer->pid.public_key))
+ GNUNET_CRYPTO_eddsa_verify (
+ GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR,
+ &cp,
+ &msg->monotime_sig,
+ &peer->pid.public_key))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
*/
void
GNUNET_CADET_drop_message (struct GNUNET_MQ_Handle *mq,
- struct GNUNET_CADET_ClientChannelNumber ccn,
- uint16_t type);
+ struct GNUNET_CADET_ClientChannelNumber ccn,
+ uint16_t type);
/******************************************************************************/
disconnect_handler (void *cls,
const struct GNUNET_CADET_Channel *channel);
-static struct GNUNET_PeerIdentity *
-get_from_p_ids()
+static struct GNUNET_PeerIdentity *
+get_from_p_ids ()
{
if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1]))
{
return testpeer_id[1];
- }else
+ }
+ else
{
- return testpeer_id[0];
+ return testpeer_id[0];
}
}
static struct GNUNET_CADET_Handle *
-get_from_cadets()
+get_from_cadets ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "1\n");
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "standard peer\n");
return cadets_running[0];
- }else
+ }
+ else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "the other peer\n");
return cadets_running[peers_running - 1];
- }
-
+ }
+
}
static unsigned int
-get_peer_nr(int outgoing)
+get_peer_nr (int outgoing)
{
if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1]))
{
return GNUNET_YES == outgoing ? 0 : peers_running - 1;
- }else
+ }
+ else
{
- return GNUNET_YES == outgoing ? peers_running -1 : 0;
+ return GNUNET_YES == outgoing ? peers_running - 1 : 0;
}
}
struct CadetTestChannelWrapper *ch;
static struct GNUNET_PeerIdentity *p_id;
static struct GNUNET_CADET_Handle *h1;
-
+
reconnect_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"reconnecting from line %ld\n",
}
ch = GNUNET_new (struct CadetTestChannelWrapper);
- p_id = get_from_p_ids();
- h1 = get_from_cadets();
-
+ p_id = get_from_p_ids ();
+ h1 = get_from_cadets ();
+
outgoing_ch = GNUNET_CADET_channel_create (h1,
ch,
p_id,
};
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "creating channel again\n");
- p_id = get_from_p_ids();
- h1 = get_from_cadets();
+ p_id = get_from_p_ids ();
+ h1 = get_from_cadets ();
+
ch = GNUNET_new (struct CadetTestChannelWrapper);
outgoing_ch = GNUNET_CADET_channel_create (h1,
- ch,
- p_id,
- &port,
- NULL,
- &disconnect_handler,
- handlers);
+ ch,
+ p_id,
+ &port,
+ NULL,
+ &disconnect_handler,
+ handlers);
ch->ch = outgoing_ch;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Sending second test data (after destroying the channel) on channel %p...\n",
peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple);
/**
- * We ask the monitoring api for all the peers.
+ * We ask the monitoring api for all the peers.
*/
static void
-get_peers(void *cls)
+get_peers (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "requesting peers info!\n");
- plo = GNUNET_CADET_list_peers (p_cfg[get_peer_nr(GNUNET_YES)], &peers_callback, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "requesting peers info!\n");
+ plo = GNUNET_CADET_list_peers (p_cfg[get_peer_nr (GNUNET_YES)],
+ &peers_callback, NULL);
}
*
* After last peer has been reported, an additional call with NULL is done.
*
- * We check the peer we are interested in, if we have a tunnel. If not, we
+ * We check the peer we are interested in, if we have a tunnel. If not, we
* reopen the channel
*
* @param cls Closure.
peer = &ple->peer;
-
+
if (NULL == ple)
{
plo = NULL;
return;
}
- p_id = get_from_p_ids();
+ p_id = get_from_p_ids ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"ple->peer %s\n",
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"p_id %s\n",
GNUNET_i2s_full (p_id));
-
- if (0 == GNUNET_memcmp (&ple->peer, p_id ) && ple->have_tunnel)
+
+ if ((0 == GNUNET_memcmp (&ple->peer, p_id))&& ple->have_tunnel)
{
-
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "schedule get_peers again?\n");
- get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers,
- NULL);
-
- }
+ "schedule get_peers again?\n");
+ get_peers_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
+ &get_peers,
+ NULL);
+
+ }
else if (0 == GNUNET_memcmp (&ple->peer, p_id) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "reopen channel\n");
+ "reopen channel\n");
reopen_channel ();
ok);
GNUNET_assert (ch_w->ch == channel);
- if ((NULL != disconnect_task) && (DESTROY == test) && (3 == ok))
+ if ((DESTROY == test) && (3 == ok))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Reopen channel task!\n");
if (NULL == get_peers_task)
{
get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers,
- NULL);
+ NULL);
}
return;
}
int size;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending test message on channel %p\n",
- channel);
+ "Sending test message on channel %u\n",
+ channel->ccn.channel_of_client);
size = size_payload;
if (GNUNET_NO == initialized)
{
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- " ok: (%d/%d)\n",
+ "handle_data ok: (%d/%d)\n",
ok,
ok_goal);
data = (uint32_t *) &message[1];
{
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- " ok: (%d/%d)\n",
+ "dropping message ok: (%d/%d)\n",
ok,
ok_goal);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TEST ID 0: %s\n",
- GNUNET_i2s (testpeer_id[0]));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TEST ID 1: %s\n",
- GNUNET_i2s (testpeer_id[1]));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TEST ID 0: %s\n",
+ GNUNET_i2s (testpeer_id[0]));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TEST ID 1: %s\n",
+ GNUNET_i2s (testpeer_id[1]));
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n");
GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch),
outgoing_ch->ccn,
GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
- GNUNET_CADET_channel_destroy(outgoing_ch);
+ if (NULL != outgoing_ch)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Destroying channel %p...\n",
+ outgoing_ch);
+ GNUNET_CADET_channel_destroy (outgoing_ch);
+ outgoing_ch = NULL;
+ }
}
- else if (4 == ok)
+ else if (5 == ok)
{
- ok++;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- " ok: (%d/%d)\n",
- ok,
- ok_goal);
- // End of DESTROY test.
+ ok++;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "destroy test finished ok: (%d/%d)\n",
+ ok,
+ ok_goal);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
+ (void *) __LINE__);
+ // End of DESTROY test.
}
}
channel);
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- " ok: (%d/%d)\n",
+ "connect_handler ok: (%d/%d)\n",
ok,
ok_goal);
- if (peer == get_peer_nr(GNUNET_NO))
+ if (peer == get_peer_nr (GNUNET_NO))
{
- if (DESTROY != test && NULL != incoming_ch)
+ if ((DESTROY != test)&&(NULL != incoming_ch))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Duplicate incoming channel for client %lu\n",
&reconnect_op,
(void *) __LINE__);
}
-
+
/* TODO: cannot return channel as-is, in order to unify the data handlers */
ch = GNUNET_new (struct CadetTestChannelWrapper);
test = SPEED;
}
- p_id = get_from_p_ids();
- h1 = get_from_cadets();
-
+ p_id = get_from_p_ids ();
+ h1 = get_from_cadets ();
+
ch = GNUNET_new (struct CadetTestChannelWrapper);
outgoing_ch = GNUNET_CADET_channel_create (h1,
ch,
ch->ch = outgoing_ch;
- //if (DESTROY != test)
+ if (DESTROY != test)
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
- &gather_stats_and_exit,
- (void *) __LINE__);
+ &gather_stats_and_exit,
+ (void *) __LINE__);
if (KEEPALIVE == test)
return; /* Don't send any data. */
return;
}
- if (GNUNET_TESTBED_PIT_IDENTITY == pinfo->pit)
+ if (GNUNET_TESTBED_PIT_IDENTITY == pinfo->pit)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ID callback for %ld\n",
"id: %s\n",
GNUNET_i2s (testpeer_id[i]));
}
- else if (GNUNET_TESTBED_PIT_CONFIGURATION == pinfo->pit)
+ else if (GNUNET_TESTBED_PIT_CONFIGURATION == pinfo->pit)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"CFG callback for %ld\n",
i);
p_cfg[i] = pinfo->result.cfg;
}
- else
+ else
{
GNUNET_break (0);
}
-
+
peerinfo_task_cnt++;
if (peerinfo_task_cnt < 4)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got all peer information, starting test\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TEST ID 0: %s\n",
- GNUNET_i2s (testpeer_id[0]));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TEST ID 1: %s\n",
- GNUNET_i2s (testpeer_id[1]));
+ "TEST ID 0: %s\n",
+ GNUNET_i2s (testpeer_id[0]));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TEST ID 1: %s\n",
+ GNUNET_i2s (testpeer_id[1]));
test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
}
GNUNET_assert (peers_running == peers_requested);
testbed_peers = peers;
cadets_running = cadets;
-
+
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
&disconnect_cadet_peers,
(void *) __LINE__);
{
test = DESTROY;
test_name = "destroy";
- ok_goal = 5;
+ ok_goal = 6;
short_time = GNUNET_TIME_relative_multiply (short_time, 5);
}
else