st = GNUNET_TIME_UNIT_FOREVER_REL;
while (NULL != (sender = GNUNET_CONTAINER_heap_peek (senders_heap)))
{
- st = GNUNET_TIME_absolute_get_remaining (receiver->timeout);
+ st = GNUNET_TIME_absolute_get_remaining (sender->timeout);
if (0 != st.rel_value_us)
break;
sender_destroy (sender);
}
-/**
- * Setup a receiver for transmission. Setup the MQ processing and
- * inform transport that the queue is ready.
- *
- * @param target which peer are we talking to
- * @param address address of the peer
- * @param address_len number of bytes in @a address
- * @return handle for the address
- */
-static struct ReceiverAddress *
-receiver_setup (const struct GNUNET_PeerIdentity *target,
- const struct sockaddr *address,
- socklen_t address_len)
-{
- struct ReceiverAddress *receiver;
-
- receiver = GNUNET_new (struct ReceiverAddress);
- receiver->address = GNUNET_memdup (address, address_len);
- receiver->address_len = address_len;
- receiver->target = *target;
- receiver->nt = GNUNET_NT_scanner_get_type (is, address, address_len);
- (void) GNUNET_CONTAINER_multipeermap_put (
- receivers,
- &receiver->target,
- receiver,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- receiver->timeout =
- GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap,
- receiver,
- receiver->timeout.abs_value_us);
- GNUNET_STATISTICS_set (stats,
- "# receivers active",
- GNUNET_CONTAINER_multipeermap_size (receivers),
- GNUNET_NO);
- receiver->foreign_addr =
- sockaddr_to_udpaddr_string (receiver->address, receiver->address_len);
- setup_receiver_mq (receiver);
-
- if (NULL == timeout_task)
- timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL);
- return receiver;
-}
-
-
/**
* Function called by the transport service to initialize a
* message queue given address information about another peer.
}
path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
in = udp_address_to_sockaddr (path, &in_len);
- receiver = receiver_setup (peer, in, in_len);
- (void) receiver;
+
+ receiver = GNUNET_new (struct ReceiverAddress);
+ receiver->address = in;
+ receiver->address_len = in_len;
+ receiver->target = *peer;
+ receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
+ (void) GNUNET_CONTAINER_multipeermap_put (receivers,
+ &receiver->target,
+ receiver,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ receiver->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap,
+ receiver,
+ receiver->timeout.abs_value_us);
+ GNUNET_STATISTICS_set (stats,
+ "# receivers active",
+ GNUNET_CONTAINER_multipeermap_size (receivers),
+ GNUNET_NO);
+ receiver->foreign_addr =
+ sockaddr_to_udpaddr_string (receiver->address, receiver->address_len);
+ setup_receiver_mq (receiver);
+ if (NULL == timeout_task)
+ timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL);
return GNUNET_OK;
}
(void) cls;
(void) netmask;
+ if (NULL == addr)
+ return GNUNET_YES; /* need to know our address! */
network = GNUNET_NT_scanner_get_type (is, addr, addrlen);
if (GNUNET_NT_LOOPBACK == network)
{
/* Broadcasting on loopback does not make sense */
return GNUNET_YES;
}
- if (NULL == addr)
- return GNUNET_YES; /* need to know our address! */
for (bi = bi_head; NULL != bi; bi = bi->next)
{
if ((bi->salen == addrlen) && (0 == memcmp (addr, bi->sa, addrlen)))
while (NULL != (pm = vl->pending_msg_head))
free_pending_message (pm);
- GNUNET_CONTAINER_multipeermap_remove (links, &vl->target, vl);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (links, &vl->target, vl));
if (NULL != vl->visibility_task)
{
GNUNET_SCHEDULER_cancel (vl->visibility_task);
static void
free_validation_state (struct ValidationState *vs)
{
- GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs);
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs));
GNUNET_CONTAINER_heap_remove_node (vs->hn);
vs->hn = NULL;
if (NULL != vs->sc)
struct DistanceVector *dv;
vl = lookup_virtual_link (target);
+ GNUNET_assert (NULL != vl);
n = vl->n;
dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL;
if (0 == (options & RMO_UNCONFIRMED_ALLOWED))
const struct GNUNET_TRANSPORT_DelAddressMessage *dam)
{
struct TransportClient *tc = cls;
+ struct AddressListEntry *alen;
if (CT_COMMUNICATOR != tc->type)
{
}
for (struct AddressListEntry *ale = tc->details.communicator.addr_head;
NULL != ale;
- ale = ale->next)
+ ale = alen)
{
+ alen = ale->next;
if (dam->aid != ale->aid)
continue;
GNUNET_assert (ale->tc == tc);
msize = ntohs (fb->msg_size);
fc.message_uuid = fb->msg_uuid;
fc.rc = NULL;
- GNUNET_CONTAINER_multihashmap32_get_multiple (n->reassembly_map,
- fb->msg_uuid.uuid,
- &find_by_message_uuid,
- &fc);
+ (void) GNUNET_CONTAINER_multihashmap32_get_multiple (n->reassembly_map,
+ fb->msg_uuid.uuid,
+ &find_by_message_uuid,
+ &fc);
if (NULL == (rc = fc.rc))
{
rc = GNUNET_malloc (sizeof (*rc) + msize + /* reassembly payload buffer */
struct GNUNET_TIME_RelativeNBO validity_duration;
struct IncomingRequest *ir;
struct Neighbour *n;
+ struct GNUNET_PeerIdentity sender;
/* DV-routed messages are not allowed for validation challenges */
if (cmc->total_hops > 0)
route_control_message_without_fc (&cmc->im.sender,
&tvr.header,
RMO_ANYTHING_GOES | RMO_REDUNDANT);
+ sender = cmc->im.sender;
finish_cmc_handling (cmc);
-
- vl = lookup_virtual_link (&cmc->im.sender);
+ vl = lookup_virtual_link (&sender);
if (NULL != vl)
return;
CORE), so we must try to bring the link up! */
/* (1) Check existing queues, if any, we may be lucky! */
- n = lookup_neighbour (&cmc->im.sender);
+ n = lookup_neighbour (&sender);
if (NULL != n)
for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
- start_address_validation (&cmc->im.sender, q->address);
+ start_address_validation (&sender, q->address);
/* (2) Also try to see if we have addresses in PEERSTORE for this peer
we could use */
for (ir = ir_head; NULL != ir; ir = ir->next)
- if (0 == GNUNET_memcmp (&ir->pid, &cmc->im.sender))
+ if (0 == GNUNET_memcmp (&ir->pid, &sender))
return; /* we are already trying */
ir = GNUNET_new (struct IncomingRequest);
- ir->pid = cmc->im.sender;
+ ir->pid = sender;
GNUNET_CONTAINER_DLL_insert (ir_head, ir_tail, ir);
ir->wc = GNUNET_PEERSTORE_watch (peerstore,
"transport",
"Cannot connect to %s at `%s', no matching communicator present\n",
GNUNET_i2s (pid),
address);
+ GNUNET_free (prefix);
return;
}
/* forward suggestion for queue creation to communicator */
(unsigned int) idgen,
prefix,
address);
+ GNUNET_free (prefix);
alen = strlen (address) + 1;
env =
GNUNET_MQ_msg_extra (cqm, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
struct PeerStats *stat = cls;
stat->switch_attempts++;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Switch attempted (%p)",
- stat);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Switch attempted (%p)", stat);
bytes_recv_after_switch = 0;
bytes_sent_after_switch = 0;
struct PeerStats *stat = cls;
stat->switch_success++;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Switch succeeded (%p)",
- stat);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Switch succeeded (%p)", stat);
return GNUNET_OK;
}
return GNUNET_OK;
stat->switch_fail++;
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Switch failed (%p)",
- stat);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Switch failed (%p)", stat);
return GNUNET_OK;
}
/**
* List of statistics entries we care about.
*/
-static struct WatchEntry {
+static struct WatchEntry
+{
/**
* Name of the statistic we watch.
* Handler to register;
*/
GNUNET_STATISTICS_Iterator stat_handler;
-} watches[] = {
- { "# Attempts to switch addresses", &stat_start_attempt_cb },
- { "# Successful attempts to switch addresses", &stat_success_attempt_cb },
- { "# Failed attempts to switch addresses (failed to send CONNECT CONT)", &stat_fail_attempt_cb },
- { "# Failed attempts to switch addresses (failed to send CONNECT)", &stat_fail_attempt_cb },
- { "# Failed attempts to switch addresses (no response)", &stat_fail_attempt_cb },
- { "# transport addresses", &stat_addresses_available },
- { NULL, NULL }
-};
+} watches[] =
+ {{"# Attempts to switch addresses", &stat_start_attempt_cb},
+ {"# Successful attempts to switch addresses", &stat_success_attempt_cb},
+ {"# Failed attempts to switch addresses (failed to send CONNECT CONT)",
+ &stat_fail_attempt_cb},
+ {"# Failed attempts to switch addresses (failed to send CONNECT)",
+ &stat_fail_attempt_cb},
+ {"# Failed attempts to switch addresses (no response)",
+ &stat_fail_attempt_cb},
+ {"# transport addresses", &stat_addresses_available},
+ {NULL, NULL}};
static void
}
/* stop statistics */
- for (unsigned int i=0;i<2;i++)
+ for (unsigned int i = 0; i < 2; i++)
{
if (NULL != stats[i].stat)
{
- for (unsigned int j=0;NULL != watches[j].stat_name; j++)
- GNUNET_STATISTICS_watch_cancel (stats[i].stat,
- "transport",
- watches[j].stat_name,
- watches[j].stat_handler,
- &stats[i]);
-
- GNUNET_STATISTICS_destroy (stats[i].stat,
- GNUNET_NO);
+ for (unsigned int j = 0; NULL != watches[j].stat_name; j++)
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_STATISTICS_watch_cancel (stats[i].stat,
+ "transport",
+ watches[j].stat_name,
+ watches[j].stat_handler,
+ &stats[i]));
+ GNUNET_STATISTICS_destroy (stats[i].stat, GNUNET_NO);
stats[i].stat = NULL;
}
}
FPRINTF (stderr, "\n");
if (stats[0].switch_attempts > 0)
{
- FPRINTF (stderr,
- "Peer 1 tried %u times to switch and succeeded %u times, failed %u times\n",
- stats[0].switch_attempts,
- stats[0].switch_success,
- stats[0].switch_fail);
+ FPRINTF (
+ stderr,
+ "Peer 1 tried %u times to switch and succeeded %u times, failed %u times\n",
+ stats[0].switch_attempts,
+ stats[0].switch_success,
+ stats[0].switch_fail);
if (stats[0].switch_success != stats[0].switch_attempts)
{
GNUNET_break (0);
- result ++;
+ result++;
}
}
else if (stats[0].addresses_avail > 1)
}
if (stats[1].switch_attempts > 0)
{
- FPRINTF (stderr,
- "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n",
- stats[1].switch_attempts,
- stats[1].switch_success,
- stats[1].switch_fail);
+ FPRINTF (
+ stderr,
+ "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n",
+ stats[1].switch_attempts,
+ stats[1].switch_success,
+ stats[1].switch_fail);
if (stats[1].switch_success != stats[1].switch_attempts)
{
GNUNET_break (0);
stats[1].addresses_avail);
}
- if ( ((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
- (bytes_sent_after_switch == 0) )
+ if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
+ (bytes_sent_after_switch == 0))
{
- FPRINTF (stderr,
- "No data sent after switching!\n");
+ FPRINTF (stderr, "No data sent after switching!\n");
GNUNET_break (0);
result++;
}
- if ( ((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
- (bytes_recv_after_switch == 0) )
+ if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
+ (bytes_recv_after_switch == 0))
{
- FPRINTF (stderr,
- "No data received after switching!\n");
+ FPRINTF (stderr, "No data received after switching!\n");
GNUNET_break (0);
result++;
}
GNUNET_i2s (sender));
GNUNET_free (ps);
}
- if ( ((stats[0].switch_attempts >= 1) || (stats[1].switch_attempts >= 1)) &&
- (stats[0].switch_attempts == stats[0].switch_fail + stats[0].switch_success) &&
- (stats[1].switch_attempts == stats[1].switch_fail + stats[1].switch_success) )
+ if (((stats[0].switch_attempts >= 1) || (stats[1].switch_attempts >= 1)) &&
+ (stats[0].switch_attempts ==
+ stats[0].switch_fail + stats[0].switch_success) &&
+ (stats[1].switch_attempts ==
+ stats[1].switch_fail + stats[1].switch_success))
{
- bytes_recv_after_switch += ntohs(hdr->header.size);
- if ( (bytes_sent_after_switch > 0) &&
- (bytes_recv_after_switch > 0) )
+ bytes_recv_after_switch += ntohs (hdr->header.size);
+ if ((bytes_sent_after_switch > 0) && (bytes_recv_after_switch > 0))
{
/* A peer switched addresses and sent and received data after the
* switch operations */
{
static uint32_t cnt;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_TRANSPORT_TESTING_send (ccc->p[1],
- ccc->p[0],
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE,
- ++cnt,
- ¬ify_send,
- NULL));
- if ( ( (stats[0].switch_attempts >= 1) ||
- (stats[1].switch_attempts >= 1) ) &&
- (stats[0].switch_attempts == stats[0].switch_fail + stats[0].switch_success) &&
- (stats[1].switch_attempts == stats[1].switch_fail + stats[1].switch_success) )
+ GNUNET_assert (
+ GNUNET_OK ==
+ GNUNET_TRANSPORT_TESTING_send (ccc->p[1],
+ ccc->p[0],
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE,
+ ++cnt,
+ ¬ify_send,
+ NULL));
+ if (((stats[0].switch_attempts >= 1) || (stats[1].switch_attempts >= 1)) &&
+ (stats[0].switch_attempts ==
+ stats[0].switch_fail + stats[0].switch_success) &&
+ (stats[1].switch_attempts ==
+ stats[1].switch_fail + stats[1].switch_success))
{
- bytes_sent_after_switch
- += GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE;
+ bytes_sent_after_switch += GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE;
}
}
static void
connected_cb (void *cls)
{
- for (unsigned int i=0;i<2;i++)
+ for (unsigned int i = 0; i < 2; i++)
{
- stats[i].stat = GNUNET_STATISTICS_create ("transport",
- ccc->p[i]->cfg);
+ stats[i].stat = GNUNET_STATISTICS_create ("transport", ccc->p[i]->cfg);
if (NULL == stats[i].stat)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_SCHEDULER_shutdown ();
return;
}
- for (unsigned int j=0;NULL != watches[j].stat_name; j++)
+ for (unsigned int j = 0; NULL != watches[j].stat_name; j++)
{
GNUNET_STATISTICS_watch (stats[i].stat,
"transport",
&progress_indicator,
NULL);
/* Peers are connected, start transmit test messages */
- GNUNET_assert (GNUNET_OK ==
- GNUNET_TRANSPORT_TESTING_send (ccc->p[1],
- ccc->p[0],
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE,
- 0,
- ¬ify_send,
- NULL));
+ GNUNET_assert (
+ GNUNET_OK ==
+ GNUNET_TRANSPORT_TESTING_send (ccc->p[1],
+ ccc->p[0],
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE,
+ 0,
+ ¬ify_send,
+ NULL));
}
int
-main (int argc,
- char *argv[])
+main (int argc, char *argv[])
{
- struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {
- .connect_continuation = &connected_cb,
- .config_file = "test_transport_api_data.conf",
- .rec = ¬ify_receive,
- .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
- .shutdown_task = &custom_shutdown,
- .timeout = TIMEOUT
- };
+ struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc =
+ {.connect_continuation = &connected_cb,
+ .config_file = "test_transport_api_data.conf",
+ .rec = ¬ify_receive,
+ .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
+ .shutdown_task = &custom_shutdown,
+ .timeout = TIMEOUT};
ccc = &my_ccc;
int ret;