GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Giving %u bytes to TNG\n", ntohs (hdr->size));
GNUNET_assert (GNUNET_SYSERR !=
- GNUNET_TRANSPORT_communicator_receive (ch,
- &sender->target,
- hdr,
- ADDRESS_VALIDITY_PERIOD,
- NULL /* no flow control possible */
- ,
- NULL));
+ GNUNET_TRANSPORT_communicator_receive (ch,
+ &sender->target,
+ hdr,
+ ADDRESS_VALIDITY_PERIOD,
+ NULL /* no flow control possible */
+ ,
+ NULL));
/* move on to next message, if any */
plaintext_len -= ntohs (hdr->size);
if (plaintext_len < sizeof(*hdr))
break;
pos += ntohs (hdr->size);
- hdr = (const struct GNUNET_MessageHeader *)pos;
- //TODO for now..., we do not actually sen >1msg or have a way of telling
- //if we are done
+ hdr = (const struct GNUNET_MessageHeader *) pos;
+ // TODO for now..., we do not actually sen >1msg or have a way of telling
+ // if we are done
break;
}
GNUNET_STATISTICS_update (stats,
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending KX to %s\n", GNUNET_a2s (receiver->address, receiver->address_len));
+ "Sending KX to %s\n", GNUNET_a2s (receiver->address,
+ receiver->address_len));
GNUNET_MQ_impl_send_continue (mq);
return;
} /* End of KX encryption method */
/* begin "BOX" encryption method, scan for ACKs from tail! */
for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "In non-kx mode...\n");
if (ss->sequence_used < ss->sequence_allowed)
{
char dgram[sizeof(struct UDPBox) + receiver->mtu];
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending data\n");
+ "Sending data\n");
GNUNET_MQ_impl_send_continue (mq);
receiver->acks_available--;
#define TOTAL_ITERATIONS 5
+#define PEER_A 0
+
+#define PEER_B 1
+
static unsigned int iterations_left = TOTAL_ITERATIONS;
#define SHORT_BURST_WINDOW \
aid,
nt);
// addresses[1] = GNUNET_strdup (address);
- if ((0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) &&
+ if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) &&
(GNUNET_NO == queue_est))
{
queue_est = GNUNET_YES;
- GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0],
- &peer_id[
- NUM_PEERS
- - 1],
+ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A],
+ &peer_id[PEER_B],
address);
}
}
}
+static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
+handle_backchannel_cb (void *cls,
+ struct GNUNET_MessageHeader *msg,
+ struct GNUNET_PeerIdentity *pid)
+{
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n");
+ if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid)))
+ return tc_hs[PEER_A];
+ else
+ return tc_hs[PEER_B];
+}
+
+
static char*
make_payload (size_t payload_size)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
- * num_received * 1000 * 1000)
- / duration.rel_value_us);
+ * num_received * 1000
+ * 1000)
+ / duration.rel_value_us);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
(unsigned long) num_received,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE
- * num_received * 1000 * 1000)
- / duration.rel_value_us);
+ * num_received * 1000
+ * 1000)
+ / duration.rel_value_us);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
&queue_create_reply_cb,
&add_queue_cb,
&incoming_message_cb,
+ &handle_backchannel_cb,
cfg_peers_name[i]); /* cls */
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
*/
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
+ /**
+ * @brief Backchannel callback
+ */
+ GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb;
+
/**
* Our service handle
*/
bc_msg)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *other_tc_h;
struct GNUNET_MessageHeader *msg;
msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
- struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
- struct GNUNET_MQ_Envelope *env;
uint16_t isize = ntohs (msg->size);
const char *target_communicator = ((const char *) msg) + isize;
+ struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
+ struct GNUNET_MQ_Envelope *env;
+
+
if (tc_h->bc_enabled != GNUNET_YES)
{
GNUNET_SERVICE_client_continue (tc_h->client);
"Delivering backchannel message of type %u to %s\n",
ntohs (msg->type),
target_communicator);
+ other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
+ GNUNET_PeerIdentity*) &bc_msg->pid);
env = GNUNET_MQ_msg_extra (
cbi,
isize,
GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING);
cbi->pid = bc_msg->pid;
memcpy (&cbi[1], msg, isize);
- GNUNET_MQ_send (tc_h->c_mq, env);
+
+
+ GNUNET_MQ_send (other_tc_h->c_mq, env);
GNUNET_SERVICE_client_continue (tc_h->client);
}
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
+ GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb,
void *cb_cls)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
tc_h->queue_create_reply_cb = queue_create_reply_cb;
tc_h->add_queue_cb = add_queue_cb;
tc_h->incoming_msg_cb = incoming_message_cb;
+ tc_h->bc_cb = bc_cb;
tc_h->cb_cls = cb_cls;
/* Start communicator part of service */
*/
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
+/**
+ * @brief Function signature for callbacks that are called when new
+ * backchannel message arrived
+ *
+ * @param cls Closure
+ * @param msg Backchannel message
+ * @param pid Target peer
+ */
+typedef struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
+(*GNUNET_TRANSPORT_TESTING_BackchannelCallback)(void *cls,
+ struct GNUNET_MessageHeader *msg,
+ struct GNUNET_PeerIdentity *pid);
+
/**
* @brief Function signature for callbacks that are called when new
struct
GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
*tc_h,
- const char* payload,
+ const char*payload,
size_t payload_len);
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
+ GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb,
void *cb_cls);
const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
{
struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
-
if (NULL != ch->notify_cb)
ch->notify_cb (ch->notify_cb_cls,
&bi->pid,