GNUNET_break(0);
return NULL;
}
- if (0 >= addrlen)
+ if (0 == addrlen)
{
GNUNET_break(0);
return NULL;
GNUNET_assert(NULL != plugin);
if (NULL == addr)
- return NULL ;
+ return NULL;
if (0 == addrlen)
- return NULL ;
+ return NULL;
if (addrlen != http_common_address_get_size (address))
- return NULL ;
+ return NULL;
addr_str = (char *) &address[1];
if (addr_str[ntohl (address->urlen) - 1] != '\0')
- return NULL ;
+ return NULL;
GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options),
&address[1]);
if (strlen (res) + 1 < 500)
}
GNUNET_break(0);
GNUNET_free(res);
- return NULL ;
+ return NULL;
}
/**
GNUNET_break (0);
return NULL;
}
- if (0 >= addrlen)
+ if (0 == addrlen)
{
GNUNET_break (0);
return NULL;
if (NULL == a1)
return GNUNET_SYSERR;
- if (0 >= addrlen1)
+ if (0 == addrlen1)
return GNUNET_SYSERR;
if (a1[addrlen1 - 1] != '\0')
return GNUNET_SYSERR;
if (NULL == a2)
return GNUNET_SYSERR;
- if (0 >= addrlen2)
+ if (0 == addrlen2)
return GNUNET_SYSERR;
if (a2[addrlen2 - 1] != '\0')
return GNUNET_SYSERR;
static void
-notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+notify_receive (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
const struct TestMessage *hdr;
+ struct PeerContext *p = cls;
hdr = (const struct TestMessage *) message;
if (MTYPE != ntohs (message->type))
return;
- struct PeerContext *p = cls;
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer %u (`%s') got message %u of size %u from peer (`%s')\n",
- p->no, ps, ntohl (hdr->num), ntohs (message->size),
- GNUNET_i2s (peer));
- GNUNET_free (ps);
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer %u (`%s') got message %u of size %u from peer (`%s')\n",
+ p->no,
+ ps,
+ ntohl (hdr->num),
+ ntohs (message->size),
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
}
struct PeerContext *p = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
- p->no, GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') connected to us!\n",
+ p->no,
+ GNUNET_i2s (peer));
}
{
struct PeerContext *p = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') disconnected!\n",
+ p->no,
GNUNET_i2s (peer));
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
}
GNUNET_assert (size >= 256);
+ hdr = buf;
+ hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
+ hdr->type = htons (MTYPE);
- if (buf != NULL)
{
- hdr = buf;
- hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
- hdr->type = htons (MTYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
return sizeof (struct GNUNET_MessageHeader);
}
static int c;
c++;
- GNUNET_assert (NULL != cls);
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
t = p2;
GNUNET_assert (t != NULL);
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
- t->no, GNUNET_i2s (peer));
- GNUNET_free (ps);
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+ p->no,
+ ps,
+ t->no,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
}
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
- p->no, ps,
- GNUNET_i2s (peer));
- GNUNET_free (ps);
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+ p->no,
+ ps,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
if (NULL != send_task)
{
GNUNET_SCHEDULER_cancel(send_task);
static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
- static int connected = GNUNET_NO;
+ static int connected = GNUNET_NO;
+
if ((cls == cc1) && (NULL != cc2))
{
GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
cc2 = NULL;
if (connected > 0)
- return;
- connected ++;
- char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
- p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
- GNUNET_free (p1_c);
- send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
+ return;
+ connected++;
+
+ {
+ char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peers connected: %u (%s) <-> %u (%s)\n",
+ p1->no,
+ p1_c,
+ p2->no,
+ GNUNET_i2s (&p2->id));
+ GNUNET_free (p1_c);
+ }
+ send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &sendtask,
+ NULL);
}
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_MESSAGE_TYPE);
- if (buf != NULL)
{
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
- }
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
+ }
return TEST_MESSAGE_SIZE;
}
+
static void
sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
t = p2;
GNUNET_assert (t != NULL);
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
- t->no, GNUNET_i2s (peer));
- GNUNET_free (ps);
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+ p->no,
+ ps,
+ t->no,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
}
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
}
+
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending request message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n",
+ p1->no, ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending request message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n",
- p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
return TEST_MESSAGE_SIZE;
}
static void
-sendtask_request_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+sendtask_request_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
send_task = NULL;
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending response message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n",
+ p1->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending response message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n",
- p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
-
return TEST_MESSAGE_SIZE;
}
+
static void
-sendtask_response_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+sendtask_response_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
send_task = NULL;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id));
+ {
+ char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
- p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s);
- GNUNET_free (receiver_s);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
+ p2->no,
+ GNUNET_i2s (&p2->id),
+ p1->no,
+ receiver_s);
+ GNUNET_free (receiver_s);
+ }
s_sending = GNUNET_YES;
- start_response = GNUNET_TIME_absolute_get();
- th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, TEST_MESSAGE_SIZE,
- TIMEOUT_TRANSMIT, ¬ify_response_ready,
+ start_response = GNUNET_TIME_absolute_get();
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ TEST_MESSAGE_SIZE,
+ TIMEOUT_TRANSMIT,
+ ¬ify_response_ready,
p1);
}
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
- }
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
+ }
return TEST_MESSAGE_SIZE;
}
static void
-sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+sendtask (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
send_task = NULL;
if (0 == messages_recv)
{
- start_normal = GNUNET_TIME_absolute_get();
+ start_normal = GNUNET_TIME_absolute_get();
}
if (1 == messages_recv)
{
- start_delayed = GNUNET_TIME_absolute_get();
+ start_delayed = GNUNET_TIME_absolute_get();
}
s_sending = GNUNET_YES;
- th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, TEST_MESSAGE_SIZE,
- TIMEOUT_TRANSMIT, ¬ify_ready,
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ TEST_MESSAGE_SIZE,
+ TIMEOUT_TRANSMIT,
+ ¬ify_ready,
p1);
}
static void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
static int c;
t = p2;
GNUNET_assert (t != NULL);
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
- t->no, GNUNET_i2s (peer));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+ p->no,
+ ps,
+ t->no,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
}
static void
-notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
- GNUNET_i2s (peer));
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+ p->no,
+ ps,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
if (th != NULL)
+ {
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
- th = NULL;
+ th = NULL;
+ }
}
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct PeerContext *p1,
+ struct PeerContext *p2,
+ void *cls)
{
cc = NULL;
- char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
- p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
- GNUNET_free (p1_c);
+ {
+ char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peers connected: %u (%s) <-> %u (%s)\n",
+ p1->no,
+ p1_c,
+ p2->no,
+ GNUNET_i2s (&p2->id));
+ GNUNET_free (p1_c);
+ }
s_connected = GNUNET_YES;
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
static int started;
started++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%s') started\n",
+ p->no,
GNUNET_i2s (&p->id));
if (started != 2)
return;
else
s_started = GNUNET_YES;
- char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+ {
+ char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
- p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
- GNUNET_free (sender_c);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
+ p1->no,
+ sender_c,
+ p2->no,
+ GNUNET_i2s (&p2->id));
+ GNUNET_free (sender_c);
+ }
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
+ p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
static struct GNUNET_TIME_Absolute start_delayed;
static struct GNUNET_TIME_Relative dur_delayed;
+
static void
end ()
{
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
}
+
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
static void
sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
t = p2;
GNUNET_assert (t != NULL);
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
- p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
- GNUNET_i2s (&t->id));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
+ p->no,
+ ps,
+ ntohs (message->type),
+ ntohs (message->size),
+ t->no,
+ GNUNET_i2s (&t->id));
+ GNUNET_free (ps);
+ }
if ((TEST_MESSAGE_TYPE == ntohs (message->type)) &&
(TEST_MESSAGE_SIZE == ntohs (message->size)))
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
-
return TEST_MESSAGE_SIZE;
}
receiver_s);
GNUNET_free (receiver_s);
-
if (0 == messages_recv)
{
start_normal = GNUNET_TIME_absolute_get ();
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
static int c;
-
- c++;
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
+ c++;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
t = p2;
GNUNET_assert (t != NULL);
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
- t->no, GNUNET_i2s (peer));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+ p->no,
+ ps,
+ t->no,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
}
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
- char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
- GNUNET_i2s (peer));
+ {
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
- GNUNET_free (ps);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+ p->no,
+ ps,
+ GNUNET_i2s (peer));
+ GNUNET_free (ps);
+ }
if (th != NULL)
+ {
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
- th = NULL;
+ th = NULL;
+ }
}
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
cc = NULL;
- char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers connected: %u (%s) <-> %u (%s)\n",
- p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
- GNUNET_free (p1_c);
+ {
+ char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peers connected: %u (%s) <-> %u (%s)\n",
+ p1->no,
+ p1_c,
+ p2->no,
+ GNUNET_i2s (&p2->id));
+ GNUNET_free (p1_c);
+ }
s_connected = GNUNET_YES;
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
static int started;
started++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%s') started\n",
+ p->no,
GNUNET_i2s (&p->id));
if (started != 2)
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
-
return TEST_MESSAGE_SIZE;
}
static size_t
-notify_ready (void *cls, size_t size, void *buf)
+notify_ready (void *cls,
+ size_t size,
+ void *buf)
{
struct PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
-
- if (buf == NULL)
+ if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout occurred while waiting for transmit_ready\n");
if (NULL != die_task)
GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_now (&end_badly,
+ NULL);
ok = 42;
return 0;
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
+ memset (buf, '\0', TEST_MESSAGE_SIZE);
+ hdr = buf;
+ hdr->size = htons (TEST_MESSAGE_SIZE);
+ hdr->type = htons (TEST_MESSAGE_TYPE);
+
{
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
-
return TEST_MESSAGE_SIZE;
}
static void
done ()
{
- if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c) && p1_c_notify && p2_c_notify)
+ if ( (GNUNET_YES == p1_c) &&
+ (GNUNET_YES == p2_c) &&
+ p1_c_notify &&
+ p2_c_notify)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Both peers state to be connected\n");
ok = 0;
end();
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Monitor 1: %s %s %s\n",
- GNUNET_i2s (&address->peer),
+ GNUNET_i2s (&address->peer),
GNUNET_TRANSPORT_vs2s (state),
GNUNET_STRINGS_absolute_time_to_string(valid_until));
if (0 == memcmp (&address->peer,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Monitor 2: %s %s %s\n",
GNUNET_i2s (&address->peer),
- GNUNET_TRANSPORT_vs2s(state),
+ GNUNET_TRANSPORT_vs2s(state),
GNUNET_STRINGS_absolute_time_to_string(valid_until));
if (0 == memcmp (&address->peer,
&p1->id,
th = NULL;
- if (buf == NULL)
+ if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout occurred while waiting for transmit_ready\n");
}
GNUNET_assert (size >= 256);
+ hdr = buf;
+ hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
+ hdr->type = htons (MTYPE);
- if (buf != NULL)
{
- hdr = buf;
- hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
- hdr->type = htons (MTYPE);
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
+ p2->no,
+ ps,
+ ntohs (hdr->type),
+ ntohs (hdr->size),
+ p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_free (ps);
}
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
return sizeof (struct GNUNET_MessageHeader);
}
p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s);
GNUNET_free (receiver_s);
- th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256,
- TIMEOUT_TRANSMIT, ¬ify_ready,
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ 256,
+ TIMEOUT_TRANSMIT,
+ ¬ify_ready,
p1);
}
static void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
static int c;