summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/plugin_transport_http_common.c18
-rw-r--r--src/transport/test_quota_compliance.c34
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c87
-rw-r--r--src/transport/test_transport_api_blacklisting.c43
-rw-r--r--src/transport/test_transport_api_manipulation_cfg.c85
-rw-r--r--src/transport/test_transport_api_manipulation_recv_tcp.c124
-rw-r--r--src/transport/test_transport_api_manipulation_send_tcp.c105
-rw-r--r--src/transport/test_transport_api_monitor_peers.c28
-rw-r--r--src/transport/test_transport_api_monitor_validation.c49
-rw-r--r--src/transport/test_transport_api_restart_1peer.c37
10 files changed, 379 insertions, 231 deletions
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c
index 13f01f713..9c0e93a37 100644
--- a/src/transport/plugin_transport_http_common.c
+++ b/src/transport/plugin_transport_http_common.c
@@ -567,7 +567,7 @@ http_common_plugin_address_to_url (void *cls,
GNUNET_break(0);
return NULL;
}
- if (0 >= addrlen)
+ if (0 == addrlen)
{
GNUNET_break(0);
return NULL;
@@ -611,14 +611,14 @@ http_common_plugin_address_to_string (const char *plugin,
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)
@@ -629,7 +629,7 @@ http_common_plugin_address_to_string (const char *plugin,
}
GNUNET_break(0);
GNUNET_free(res);
- return NULL ;
+ return NULL;
}
/**
@@ -772,7 +772,7 @@ http_common_socket_from_address (const void *addr,
GNUNET_break (0);
return NULL;
}
- if (0 >= addrlen)
+ if (0 == addrlen)
{
GNUNET_break (0);
return NULL;
@@ -868,14 +868,14 @@ http_common_cmp_addresses (const void *addr1,
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;
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index b53bda514..d01d335f8 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -209,23 +209,29 @@ get_size (unsigned int iter)
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);
+ }
}
@@ -315,8 +321,10 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
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));
}
@@ -325,7 +333,9 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *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);
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c
index 5c9ae36fe..f7f284a9a 100644
--- a/src/transport/test_transport_api_bidirectional_connect.c
+++ b/src/transport/test_transport_api_bidirectional_connect.c
@@ -185,20 +185,24 @@ notify_ready (void *cls, size_t size, void *buf)
}
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);
}
@@ -229,7 +233,6 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- GNUNET_assert (NULL != cls);
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
@@ -239,12 +242,17 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
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);
+ }
}
@@ -252,14 +260,17 @@ static void
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);
@@ -277,7 +288,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
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);
@@ -290,14 +302,23 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
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);
}
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c
index 9c3a0c460..f2265028f 100644
--- a/src/transport/test_transport_api_blacklisting.c
+++ b/src/transport/test_transport_api_blacklisting.c
@@ -236,24 +236,28 @@ notify_ready (void *cls, size_t size, void *buf)
}
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)
{
@@ -291,12 +295,17 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
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);
+ }
}
diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c
index 41ad7f68f..ce968a497 100644
--- a/src/transport/test_transport_api_manipulation_cfg.c
+++ b/src/transport/test_transport_api_manipulation_cfg.c
@@ -107,6 +107,7 @@ end ()
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
}
+
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -180,26 +181,31 @@ notify_request_ready (void *cls, size_t size, void *buf)
}
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;
@@ -240,42 +246,55 @@ notify_response_ready (void *cls, size_t size, void *buf)
}
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, &notify_response_ready,
+ start_response = GNUNET_TIME_absolute_get();
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ TEST_MESSAGE_SIZE,
+ TIMEOUT_TRANSMIT,
+ &notify_response_ready,
p1);
}
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c
index 8a820fa16..48e0fe418 100644
--- a/src/transport/test_transport_api_manipulation_recv_tcp.c
+++ b/src/transport/test_transport_api_manipulation_recv_tcp.c
@@ -264,27 +264,32 @@ notify_ready (void *cls, size_t size, void *buf)
}
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;
@@ -300,22 +305,26 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
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, &notify_ready,
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ TEST_MESSAGE_SIZE,
+ TIMEOUT_TRANSMIT,
+ &notify_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;
@@ -329,42 +338,63 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
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);
@@ -377,21 +407,31 @@ start_cb (struct PeerContext *p, void *cls)
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);
}
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c
index 0a52556ab..a1f9055ea 100644
--- a/src/transport/test_transport_api_manipulation_send_tcp.c
+++ b/src/transport/test_transport_api_manipulation_send_tcp.c
@@ -85,6 +85,7 @@ static struct GNUNET_TIME_Relative dur_normal;
static struct GNUNET_TIME_Absolute start_delayed;
static struct GNUNET_TIME_Relative dur_delayed;
+
static void
end ()
{
@@ -104,6 +105,7 @@ end ()
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
}
+
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -160,6 +162,7 @@ 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)
@@ -173,13 +176,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
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)))
@@ -252,21 +261,24 @@ notify_ready (void *cls, size_t size, void *buf)
}
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;
}
@@ -291,7 +303,6 @@ sendtask (void *cls,
receiver_s);
GNUNET_free (receiver_s);
-
if (0 == messages_recv)
{
start_normal = GNUNET_TIME_absolute_get ();
@@ -325,23 +336,27 @@ static void
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);
+ }
}
@@ -349,17 +364,23 @@ static void
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;
+ }
}
@@ -367,12 +388,18 @@ static void
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);
@@ -385,7 +412,9 @@ start_cb (struct PeerContext *p, void *cls)
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)
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c
index 8cd952cc5..38884f7d5 100644
--- a/src/transport/test_transport_api_monitor_peers.c
+++ b/src/transport/test_transport_api_monitor_peers.c
@@ -237,21 +237,25 @@ notify_ready (void *cls, size_t size, void *buf)
}
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;
}
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c
index 76fa66949..ac7a1805b 100644
--- a/src/transport/test_transport_api_monitor_validation.c
+++ b/src/transport/test_transport_api_monitor_validation.c
@@ -229,40 +229,45 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
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;
}
@@ -290,9 +295,13 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
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();
}
@@ -403,7 +412,7 @@ monitor1_cb (void *cls,
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,
@@ -427,7 +436,7 @@ monitor2_cb (void *cls,
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,
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 2c4382e9c..86eb299ef 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -225,7 +225,7 @@ notify_ready (void *cls, size_t size, void *buf)
th = NULL;
- if (buf == NULL)
+ if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout occurred while waiting for transmit_ready\n");
@@ -237,20 +237,23 @@ notify_ready (void *cls, size_t size, void *buf)
}
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);
}
@@ -269,14 +272,18 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
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, &notify_ready,
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+ &p1->id,
+ 256,
+ TIMEOUT_TRANSMIT,
+ &notify_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;