summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-04 21:05:01 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-04 21:05:10 +0200
commit14537ef71b43ac47fe342c4e88f7bd3675ed1e39 (patch)
tree6833f549f695ba40533ba716caebc1866415e359 /src/transport
parent0e6553e41d132726eb8f7964b581bb2cac0e6b6c (diff)
misc bugfixes
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-unix.c494
-rw-r--r--src/transport/gnunet-service-tng.c7
-rw-r--r--src/transport/transport-testing2.c209
3 files changed, 316 insertions, 394 deletions
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 9bbc02c65..1772e3647 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -75,7 +75,6 @@ struct UNIXMessage
* What is the identity of the sender (GNUNET_hash of public key)
*/
struct GNUNET_PeerIdentity sender;
-
};
GNUNET_NETWORK_STRUCT_END
@@ -142,7 +141,6 @@ struct Queue
* Queue timeout task.
*/
struct GNUNET_SCHEDULER_Task *timeout_task;
-
};
@@ -215,13 +213,11 @@ queue_destroy (struct Queue *queue)
struct GNUNET_MQ_Handle *mq;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting queue for peer `%s'\n",
- GNUNET_i2s (&queue->target));
+ "Disconnecting queue for peer `%s'\n",
+ GNUNET_i2s (&queue->target));
if (0 != queue->bytes_in_queue)
{
- GNUNET_CONTAINER_DLL_remove (queue_head,
- queue_tail,
- queue);
+ GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
queue->bytes_in_queue = 0;
}
if (NULL != (mq = queue->mq))
@@ -229,14 +225,13 @@ queue_destroy (struct Queue *queue)
queue->mq = NULL;
GNUNET_MQ_destroy (mq);
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (queue_map,
- &queue->target,
- queue));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (queue_map, &queue->target, queue));
GNUNET_STATISTICS_set (stats,
- "# queues active",
- GNUNET_CONTAINER_multipeermap_size (queue_map),
- GNUNET_NO);
+ "# queues active",
+ GNUNET_CONTAINER_multipeermap_size (queue_map),
+ GNUNET_NO);
if (NULL != queue->timeout_task)
{
GNUNET_SCHEDULER_cancel (queue->timeout_task);
@@ -264,17 +259,16 @@ queue_timeout (void *cls)
{
/* not actually our turn yet, but let's at least update
the monitor, it may think we're about to die ... */
- queue->timeout_task
- = GNUNET_SCHEDULER_add_delayed (left,
- &queue_timeout,
- queue);
+ queue->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (left, &queue_timeout, queue);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queue %p was idle for %s, disconnecting\n",
- queue,
- GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- GNUNET_YES));
+ "Queue %p was idle for %s, disconnecting\n",
+ queue,
+ GNUNET_STRINGS_relative_time_to_string (
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ GNUNET_YES));
queue_destroy (queue);
}
@@ -290,8 +284,8 @@ static void
reschedule_queue_timeout (struct Queue *queue)
{
GNUNET_assert (NULL != queue->timeout_task);
- queue->timeout
- = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ queue->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
}
@@ -304,21 +298,18 @@ reschedule_queue_timeout (struct Queue *queue)
* @return converted unix path
*/
static struct sockaddr_un *
-unix_address_to_sockaddr (const char *unixpath,
- socklen_t *sock_len)
+unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len)
{
struct sockaddr_un *un;
size_t slen;
- GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
+ GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
un = GNUNET_new (struct sockaddr_un);
un->sun_family = AF_UNIX;
slen = strlen (unixpath);
if (slen >= sizeof (un->sun_path))
slen = sizeof (un->sun_path) - 1;
- GNUNET_memcpy (un->sun_path,
- unixpath,
- slen);
+ GNUNET_memcpy (un->sun_path, unixpath, slen);
un->sun_path[slen] = '\0';
slen = sizeof (struct sockaddr_un);
#if HAVE_SOCKADDR_UN_SUN_LEN
@@ -362,17 +353,13 @@ struct LookupCtx
* @return #GNUNET_YES if not found (continue looking), #GNUNET_NO on success
*/
static int
-lookup_queue_it (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value)
+lookup_queue_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
{
struct LookupCtx *lctx = cls;
struct Queue *queue = value;
- if ( (queue->address_len = lctx->un_len) &&
- (0 == memcmp (lctx->un,
- queue->address,
- queue->address_len)) )
+ if ((queue->address_len = lctx->un_len) &&
+ (0 == memcmp (lctx->un, queue->address, queue->address_len)))
{
lctx->res = queue;
return GNUNET_NO;
@@ -390,17 +377,17 @@ lookup_queue_it (void *cls,
*/
static struct Queue *
lookup_queue (const struct GNUNET_PeerIdentity *peer,
- const struct sockaddr_un *un,
- socklen_t un_len)
+ const struct sockaddr_un *un,
+ socklen_t un_len)
{
struct LookupCtx lctx;
lctx.un = un;
lctx.un_len = un_len;
GNUNET_CONTAINER_multipeermap_get_multiple (queue_map,
- peer,
- &lookup_queue_it,
- &lctx);
+ peer,
+ &lookup_queue_it,
+ &lctx);
return lctx.res;
}
@@ -417,26 +404,21 @@ select_write_cb (void *cls)
struct Queue *queue = queue_tail;
const struct GNUNET_MessageHeader *msg = queue->msg;
size_t msg_size = ntohs (msg->size);
- const void *msg;
ssize_t sent;
/* take queue of the ready list */
write_task = NULL;
- GNUNET_CONTAINER_DLL_remove (queue_head,
- queue_tail,
- queue);
+ GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
if (NULL != queue_head)
- write_task =
- GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
- unix_sock,
- &select_write_cb,
- NULL);
+ write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
+ unix_sock,
+ &select_write_cb,
+ NULL);
/* send 'msg' */
- msg = queue->msg;
queue->msg = NULL;
GNUNET_MQ_impl_send_continue (queue->mq);
- resend:
+resend:
/* Send the data */
sent = GNUNET_NETWORK_socket_sendto (unix_sock,
msg,
@@ -444,79 +426,74 @@ select_write_cb (void *cls)
(const struct sockaddr *) queue->address,
queue->address_len);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "UNIX transmitted message to %s (%d/%u: %s)\n",
- GNUNET_i2s (&queue->target),
- (int) sent,
- (unsigned int) msg_size,
- (sent < 0) ? STRERROR (errno) : "ok");
+ "UNIX transmitted message to %s (%d/%u: %s)\n",
+ GNUNET_i2s (&queue->target),
+ (int) sent,
+ (unsigned int) msg_size,
+ (sent < 0) ? STRERROR (errno) : "ok");
if (-1 != sent)
{
GNUNET_STATISTICS_update (stats,
- "# bytes sent",
- (long long) sent,
- GNUNET_NO);
+ "# bytes sent",
+ (long long) sent,
+ GNUNET_NO);
reschedule_queue_timeout (queue);
return; /* all good */
}
GNUNET_STATISTICS_update (stats,
- "# network transmission failures",
- 1,
- GNUNET_NO);
+ "# network transmission failures",
+ 1,
+ GNUNET_NO);
switch (errno)
{
case EAGAIN:
case ENOBUFS:
/* We should retry later... */
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG,
- "send");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
return;
- case EMSGSIZE:
+ case EMSGSIZE: {
+ socklen_t size = 0;
+ socklen_t len = sizeof (size);
+
+ GNUNET_NETWORK_socket_getsockopt (unix_sock,
+ SOL_SOCKET,
+ SO_SNDBUF,
+ &size,
+ &len);
+ if (size > ntohs (msg->size))
{
- socklen_t size = 0;
- socklen_t len = sizeof (size);
-
- GNUNET_NETWORK_socket_getsockopt (unix_sock,
- SOL_SOCKET,
- SO_SNDBUF,
- &size,
- &len);
- if (size > ntohs (msg->size))
- {
- /* Buffer is bigger than message: error, no retry
+ /* Buffer is bigger than message: error, no retry
* This should never happen!*/
- GNUNET_break (0);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to increase socket buffer size from %u to %u for message size %u\n",
- (unsigned int) size,
- (unsigned int) ((msg_size / 1000) + 2) * 1000,
- (unsigned int) msg_size);
- size = ((msg_size / 1000) + 2) * 1000;
- if (GNUNET_OK ==
- GNUNET_NETWORK_socket_setsockopt (unix_sock,
- SOL_SOCKET,
- SO_SNDBUF,
- &size,
- sizeof (size)))
- goto resend; /* Increased buffer size, retry sending */
- /* Ok, then just try very modest increase */
- size = msg_size;
- if (GNUNET_OK ==
- GNUNET_NETWORK_socket_setsockopt (unix_sock,
- SOL_SOCKET,
- SO_SNDBUF,
- &size,
- sizeof (size)))
- goto resend; /* Increased buffer size, retry sending */
- /* Could not increase buffer size: error, no retry */
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "setsockopt");
+ GNUNET_break (0);
return;
}
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to increase socket buffer size from %u to %u for message size %u\n",
+ (unsigned int) size,
+ (unsigned int) ((msg_size / 1000) + 2) * 1000,
+ (unsigned int) msg_size);
+ size = ((msg_size / 1000) + 2) * 1000;
+ if (GNUNET_OK == GNUNET_NETWORK_socket_setsockopt (unix_sock,
+ SOL_SOCKET,
+ SO_SNDBUF,
+ &size,
+ sizeof (size)))
+ goto resend; /* Increased buffer size, retry sending */
+ /* Ok, then just try very modest increase */
+ size = msg_size;
+ if (GNUNET_OK == GNUNET_NETWORK_socket_setsockopt (unix_sock,
+ SOL_SOCKET,
+ SO_SNDBUF,
+ &size,
+ sizeof (size)))
+ goto resend; /* Increased buffer size, retry sending */
+ /* Could not increase buffer size: error, no retry */
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "setsockopt");
+ return;
+ }
default:
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "send");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "send");
return;
}
}
@@ -532,24 +509,21 @@ select_write_cb (void *cls)
*/
static void
mq_send (struct GNUNET_MQ_Handle *mq,
- const struct GNUNET_MessageHeader *msg,
- void *impl_state)
+ const struct GNUNET_MessageHeader *msg,
+ void *impl_state)
{
struct Queue *queue = impl_state;
GNUNET_assert (mq == queue->mq);
GNUNET_assert (NULL == queue->msg);
queue->msg = msg;
- GNUNET_CONTAINER_DLL_insert (queue_head,
- queue_tail,
- queue);
+ GNUNET_CONTAINER_DLL_insert (queue_head, queue_tail, queue);
GNUNET_assert (NULL != unix_sock);
if (NULL == write_task)
- write_task =
- GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
- unix_sock,
- &select_write_cb,
- NULL);
+ write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
+ unix_sock,
+ &select_write_cb,
+ NULL);
}
@@ -562,8 +536,7 @@ mq_send (struct GNUNET_MQ_Handle *mq,
* @param impl_state our `struct Queue`
*/
static void
-mq_destroy (struct GNUNET_MQ_Handle *mq,
- void *impl_state)
+mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state)
{
struct Queue *queue = impl_state;
@@ -582,16 +555,13 @@ mq_destroy (struct GNUNET_MQ_Handle *mq,
* @param impl_state our `struct Queue`
*/
static void
-mq_cancel (struct GNUNET_MQ_Handle *mq,
- void *impl_state)
+mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state)
{
struct Queue *queue = impl_state;
GNUNET_assert (NULL != queue->msg);
queue->msg = NULL;
- GNUNET_CONTAINER_DLL_remove (queue_head,
- queue_tail,
- queue);
+ GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
GNUNET_assert (NULL != write_task);
if (NULL == queue_head)
{
@@ -611,15 +581,14 @@ mq_cancel (struct GNUNET_MQ_Handle *mq,
* @param error error code
*/
static void
-mq_error (void *cls,
- enum GNUNET_MQ_Error error)
+mq_error (void *cls, enum GNUNET_MQ_Error error)
{
struct Queue *queue = cls;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "UNIX MQ error in queue to %s: %d\n",
- GNUNET_i2s (&queue->target),
- (int) error);
+ "UNIX MQ error in queue to %s: %d\n",
+ GNUNET_i2s (&queue->target),
+ (int) error);
queue_destroy (queue);
}
@@ -644,30 +613,30 @@ setup_queue (const struct GNUNET_PeerIdentity *target,
queue = GNUNET_new (struct Queue);
queue->target = *target;
- queue->address = GNUNET_memdup (un,
- un_len);
+ queue->address = GNUNET_memdup (un, un_len);
queue->address_len = un_len;
- (void) GNUNET_CONTAINER_multipeermap_put (queue_map,
- &queue->target,
- queue,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (
+ queue_map,
+ &queue->target,
+ queue,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_STATISTICS_set (stats,
- "# queues active",
- GNUNET_CONTAINER_multipeermap_size (queue_map),
- GNUNET_NO);
- queue->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- queue->timeout_task
- = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &queue_timeout,
- queue);
- queue->mq
- = GNUNET_MQ_queue_for_callbacks (&mq_send,
- &mq_destroy,
- &mq_cancel,
- queue,
- NULL,
- &mq_error,
- queue);
+ "# queues active",
+ GNUNET_CONTAINER_multipeermap_size (queue_map),
+ GNUNET_NO);
+ queue->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ queue->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &queue_timeout,
+ queue);
+ queue->mq = GNUNET_MQ_queue_for_callbacks (&mq_send,
+ &mq_destroy,
+ &mq_cancel,
+ queue,
+ NULL,
+ &mq_error,
+ queue);
{
char *foreign_addr;
@@ -681,14 +650,13 @@ setup_queue (const struct GNUNET_PeerIdentity *target,
"%s-%s",
COMMUNICATOR_ADDRESS_PREFIX,
un->sun_path);
- queue->qh
- = GNUNET_TRANSPORT_communicator_mq_add (ch,
- &queue->target,
- foreign_addr,
- UNIX_MTU,
- GNUNET_NT_LOOPBACK,
- cs,
- queue->mq);
+ queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch,
+ &queue->target,
+ foreign_addr,
+ UNIX_MTU,
+ GNUNET_NT_LOOPBACK,
+ cs,
+ queue->mq);
GNUNET_free (foreign_addr);
}
return queue;
@@ -714,8 +682,7 @@ select_read_cb (void *cls);
* @param success #GNUNET_OK on success
*/
static void
-receive_complete_cb (void *cls,
- int success)
+receive_complete_cb (void *cls, int success)
{
delivering_messages--;
if (GNUNET_OK != success)
@@ -724,8 +691,7 @@ receive_complete_cb (void *cls,
1,
GNUNET_NO);
GNUNET_assert (NULL != unix_sock);
- if ( (NULL == read_task) &&
- (delivering_messages < max_queue_length) )
+ if ((NULL == read_task) && (delivering_messages < max_queue_length))
read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
unix_sock,
&select_read_cb,
@@ -757,22 +723,17 @@ select_read_cb (void *cls)
&select_read_cb,
NULL);
addrlen = sizeof (un);
- memset (&un,
- 0,
- sizeof (un));
+ memset (&un, 0, sizeof (un));
ret = GNUNET_NETWORK_socket_recvfrom (unix_sock,
buf,
sizeof (buf),
(struct sockaddr *) &un,
&addrlen);
- if ( (-1 == ret) &&
- ( (EAGAIN == errno) ||
- (ENOBUFS == errno) ) )
+ if ((-1 == ret) && ((EAGAIN == errno) || (ENOBUFS == errno)))
return;
if (-1 == ret)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
- "recvfrom");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -782,26 +743,23 @@ select_read_cb (void *cls)
GNUNET_assert (AF_UNIX == (un.sun_family));
msg = (struct UNIXMessage *) buf;
msize = ntohs (msg->header.size);
- if ( (msize < sizeof (struct UNIXMessage)) ||
- (msize > ret) )
+ if ((msize < sizeof (struct UNIXMessage)) || (msize > ret))
{
GNUNET_break_op (0);
return;
}
- queue = lookup_queue (&msg->sender,
- &un,
- addrlen);
+ queue = lookup_queue (&msg->sender, &un, addrlen);
if (NULL == queue)
- queue = setup_queue (&msg->sender,
- GNUNET_TRANSPORT_CS_INBOUND,
- &un,
- addrlen);
+ queue =
+ setup_queue (&msg->sender, GNUNET_TRANSPORT_CS_INBOUND, &un, addrlen);
else
reschedule_queue_timeout (queue);
if (NULL == queue)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Maximum number of UNIX connections exceeded, dropping incoming message\n"));
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_ERROR,
+ _ (
+ "Maximum number of UNIX connections exceeded, dropping incoming message\n"));
return;
}
@@ -818,12 +776,10 @@ select_read_cb (void *cls)
currhdr = (const struct GNUNET_MessageHeader *) &msgbuf[offset];
/* ensure aligned access */
- memcpy (&al_hdr,
- currhdr,
- sizeof (al_hdr));
+ memcpy (&al_hdr, currhdr, sizeof (al_hdr));
csize = ntohs (al_hdr.size);
- if ( (csize < sizeof (struct GNUNET_MessageHeader)) ||
- (csize > tsize - offset))
+ if ((csize < sizeof (struct GNUNET_MessageHeader)) ||
+ (csize > tsize - offset))
{
GNUNET_break_op (0);
break;
@@ -835,9 +791,9 @@ select_read_cb (void *cls)
&receive_complete_cb,
NULL);
if (GNUNET_SYSERR == ret)
- return; /* transport not up */
+ return; /* transport not up */
if (GNUNET_NO == ret)
- break;
+ break;
delivering_messages++;
offset += csize;
}
@@ -869,9 +825,7 @@ select_read_cb (void *cls)
* @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is invalid
*/
static int
-mq_init (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const char *address)
+mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
{
struct Queue *queue;
const char *path;
@@ -879,31 +833,25 @@ mq_init (void *cls,
socklen_t un_len;
if (0 != strncmp (address,
- COMMUNICATOR_ADDRESS_PREFIX "-",
- strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
+ COMMUNICATOR_ADDRESS_PREFIX "-",
+ strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
- un = unix_address_to_sockaddr (path,
- &un_len);
- queue = lookup_queue (peer,
- un,
- un_len);
+ un = unix_address_to_sockaddr (path, &un_len);
+ queue = lookup_queue (peer, un, un_len);
if (NULL != queue)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address `%s' for %s ignored, queue exists\n",
- path,
- GNUNET_i2s (peer));
+ "Address `%s' for %s ignored, queue exists\n",
+ path,
+ GNUNET_i2s (peer));
GNUNET_free (un);
return GNUNET_OK;
}
- queue = setup_queue (peer,
- GNUNET_TRANSPORT_CS_OUTBOUND,
- un,
- un_len);
+ queue = setup_queue (peer, GNUNET_TRANSPORT_CS_OUTBOUND, un, un_len);
GNUNET_free (un);
if (NULL == queue)
{
@@ -927,8 +875,8 @@ mq_init (void *cls,
*/
static int
get_queue_delete_it (void *cls,
- const struct GNUNET_PeerIdentity *target,
- void *value)
+ const struct GNUNET_PeerIdentity *target,
+ void *value)
{
struct Queue *queue = value;
@@ -959,13 +907,10 @@ do_shutdown (void *cls)
}
if (NULL != unix_sock)
{
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (unix_sock));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (unix_sock));
unix_sock = NULL;
}
- GNUNET_CONTAINER_multipeermap_iterate (queue_map,
- &get_queue_delete_it,
- NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL);
GNUNET_CONTAINER_multipeermap_destroy (queue_map);
if (NULL != ai)
{
@@ -979,8 +924,7 @@ do_shutdown (void *cls)
}
if (NULL != stats)
{
- GNUNET_STATISTICS_destroy (stats,
- GNUNET_NO);
+ GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
stats = NULL;
}
}
@@ -1031,9 +975,9 @@ run (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
- COMMUNICATOR_CONFIG_SECTION,
- "UNIXPATH",
- &unix_socket_path))
+ COMMUNICATOR_CONFIG_SECTION,
+ "UNIXPATH",
+ &unix_socket_path))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
COMMUNICATOR_CONFIG_SECTION,
@@ -1042,53 +986,45 @@ run (void *cls,
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
- COMMUNICATOR_CONFIG_SECTION,
- "MAX_QUEUE_LENGTH",
- &max_queue_length))
+ COMMUNICATOR_CONFIG_SECTION,
+ "MAX_QUEUE_LENGTH",
+ &max_queue_length))
max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
- un = unix_address_to_sockaddr (unix_socket_path,
- &un_len);
+ un = unix_address_to_sockaddr (unix_socket_path, &un_len);
if (NULL == un)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to setup UNIX domain socket address with path `%s'\n",
- unix_socket_path);
+ "Failed to setup UNIX domain socket address with path `%s'\n",
+ unix_socket_path);
GNUNET_free (unix_socket_path);
return;
}
- unix_sock = GNUNET_NETWORK_socket_create (AF_UNIX,
- SOCK_DGRAM,
- 0);
+ unix_sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
if (NULL == unix_sock)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "socket");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
GNUNET_free (un);
GNUNET_free (unix_socket_path);
return;
}
- if ( ('\0' != un->sun_path[0]) &&
- (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (un->sun_path)) )
+ if (('\0' != un->sun_path[0]) &&
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Cannot create path to `%s'\n"),
- un->sun_path);
+ _ ("Cannot create path to `%s'\n"),
+ un->sun_path);
GNUNET_NETWORK_socket_close (unix_sock);
unix_sock = NULL;
GNUNET_free (un);
GNUNET_free (unix_socket_path);
return;
}
- if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (unix_sock,
- (const struct sockaddr *) un,
- un_len))
+ if (GNUNET_OK != GNUNET_NETWORK_socket_bind (unix_sock,
+ (const struct sockaddr *) un,
+ un_len))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "bind",
- un->sun_path);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "bind", un->sun_path);
GNUNET_NETWORK_socket_close (unix_sock);
unix_sock = NULL;
GNUNET_free (un);
@@ -1096,25 +1032,20 @@ run (void *cls,
return;
}
GNUNET_free (un);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Bound to `%s'\n",
- unix_socket_path);
- stats = GNUNET_STATISTICS_create ("C-UNIX",
- cfg);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", unix_socket_path);
+ stats = GNUNET_STATISTICS_create ("C-UNIX", cfg);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
- unix_sock,
- &select_read_cb,
- NULL);
- queue_map = GNUNET_CONTAINER_multipeermap_create (10,
- GNUNET_NO);
+ unix_sock,
+ &select_read_cb,
+ NULL);
+ queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
ch = GNUNET_TRANSPORT_communicator_connect (cfg,
- COMMUNICATOR_CONFIG_SECTION,
- COMMUNICATOR_ADDRESS_PREFIX,
+ COMMUNICATOR_CONFIG_SECTION,
+ COMMUNICATOR_ADDRESS_PREFIX,
GNUNET_TRANSPORT_CC_RELIABLE,
- &mq_init,
- NULL,
+ &mq_init,
+ NULL,
&enc_notify_cb,
NULL);
if (NULL == ch)
@@ -1125,14 +1056,14 @@ run (void *cls,
return;
}
GNUNET_asprintf (&my_addr,
- "%s-%s",
- COMMUNICATOR_ADDRESS_PREFIX,
- unix_socket_path);
+ "%s-%s",
+ COMMUNICATOR_ADDRESS_PREFIX,
+ unix_socket_path);
GNUNET_free (unix_socket_path);
ai = GNUNET_TRANSPORT_communicator_address_add (ch,
- my_addr,
- GNUNET_NT_LOOPBACK,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ my_addr,
+ GNUNET_NT_LOOPBACK,
+ GNUNET_TIME_UNIT_FOREVER_REL);
GNUNET_free (my_addr);
}
@@ -1145,28 +1076,26 @@ run (void *cls,
* @return 0 ok, 1 on error
*/
int
-main (int argc,
- char *const *argv)
+main (int argc, char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ GNUNET_GETOPT_OPTION_END};
int ret;
- if (GNUNET_OK !=
- GNUNET_STRINGS_get_utf8_args (argc, argv,
- &argc, &argv))
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- ret =
- (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv,
- "gnunet-communicator-unix",
- _("GNUnet UNIX domain socket communicator"),
- options,
- &run,
- NULL)) ? 0 : 1;
- GNUNET_free ((void*) argv);
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-communicator-unix",
+ _ ("GNUnet UNIX domain socket communicator"),
+ options,
+ &run,
+ NULL))
+ ? 0
+ : 1;
+ GNUNET_free ((void *) argv);
return ret;
}
@@ -1177,8 +1106,7 @@ main (int argc,
/**
* MINIMIZE heap size (way below 128k) since this process doesn't need much.
*/
-void __attribute__ ((constructor))
-GNUNET_ARM_memory_init ()
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
{
mallopt (M_TRIM_THRESHOLD, 4 * 1024);
mallopt (M_TOP_PAD, 1 * 1024);
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 9262e5e97..206c59363 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5580,6 +5580,13 @@ handle_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb)
return;
}
frag_off = ntohs (fb->frag_off);
+ if (frag_off + fsize > msize)
+ {
+ /* Fragment (plus fragment size) exceeds message size! */
+ GNUNET_break_op (0);
+ finish_cmc_handling (cmc);
+ return;
+ }
memcpy (&target[frag_off], &fb[1], fsize);
/* update bitfield and msg_missing */
for (unsigned int i = frag_off; i < frag_off + fsize; i++)
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 2abe6c9ce..9bbd15983 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -35,7 +35,7 @@
#include "transport.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
@@ -110,7 +110,8 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
/**
* @brief Callback called when a new communicator connects
*/
- GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb;
+ GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
+ communicator_available_cb;
/**
* @brief Callback called when a new communicator connects
@@ -203,8 +204,9 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission
* @return GNUNET_YES in case message is correct
*/
static int
-check_communicator_available (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
+check_communicator_available (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
{
uint16_t size;
@@ -223,8 +225,9 @@ check_communicator_available (void *cls,
* @param msg Message struct
*/
static void
-handle_communicator_available (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
+handle_communicator_available (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
uint16_t size;
@@ -236,8 +239,7 @@ handle_communicator_available (void *cls,
tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
if (NULL != tc_h->communicator_available_cb)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "calling communicator_available_cb()\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
tc_h->communicator_available_cb (tc_h->cb_cls,
tc_h,
tc_h->c_characteristics,
@@ -283,8 +285,7 @@ handle_add_address (void *cls,
tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
if (NULL != tc_h->add_address_cb)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "calling communicator_available()\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available()\n");
tc_h->add_address_cb (tc_h->cb_cls,
tc_h,
tc_h->c_address,
@@ -304,25 +305,22 @@ handle_queue_create_ok (void *cls,
if (NULL != tc_h->queue_create_reply_cb)
{
- tc_h->queue_create_reply_cb (tc_h->cb_cls,
- tc_h,
- GNUNET_YES);
+ tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
}
GNUNET_SERVICE_client_continue (tc_h->client);
}
static void
-handle_queue_create_fail (void *cls,
- const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
+handle_queue_create_fail (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
if (NULL != tc_h->queue_create_reply_cb)
{
- tc_h->queue_create_reply_cb (tc_h->cb_cls,
- tc_h,
- GNUNET_NO);
+ tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
}
GNUNET_SERVICE_client_continue (tc_h->client);
}
@@ -362,16 +360,13 @@ handle_add_queue_message (void *cls,
tc_queue = tc_queue->next;
}
GNUNET_assert (tc_queue->qid == msg->qid);
- GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id,
- &msg->receiver));
+ GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
tc_queue->nt = msg->nt;
tc_queue->mtu = msg->mtu;
tc_queue->cs = msg->cs;
if (NULL != tc_h->add_queue_cb)
{
- tc_h->add_queue_cb (tc_h->cb_cls,
- tc_h,
- tc_queue);
+ tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
}
GNUNET_SERVICE_client_continue (tc_h->client);
}
@@ -408,17 +403,17 @@ connect_cb (void *cls,
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Client connected.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n");
tc_h->client = client;
tc_h->c_mq = mq;
- if (NULL == tc_h->queue_head) return tc_h;
+ if (NULL == tc_h->queue_head)
+ return tc_h;
while (NULL != (tc_queue_iter = tc_h->queue_head))
{
- if (NULL == tc_queue_iter->open_queue_env) continue;
- GNUNET_MQ_send (tc_h->c_mq,
- tc_queue_iter->open_queue_env);
+ if (NULL == tc_queue_iter->open_queue_env)
+ continue;
+ GNUNET_MQ_send (tc_h->c_mq, tc_queue_iter->open_queue_env);
tc_queue_iter->open_queue_env = NULL;
}
return tc_h;
@@ -439,8 +434,7 @@ disconnect_cb (void *cls,
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Client disconnected.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
tc_h->client = NULL;
}
@@ -453,21 +447,22 @@ disconnect_cb (void *cls,
* @param cfg Configuration
*/
static void
-transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
+transport_communicator_start (
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
{
struct GNUNET_MQ_MessageHandler mh[] = {
GNUNET_MQ_hd_var_size (communicator_available,
- GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
- struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
- &tc_h),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
+ struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
+ &tc_h),
//GNUNET_MQ_hd_var_size (communicator_backchannel,
// GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
// struct GNUNET_TRANSPORT_CommunicatorBackchannel,
// NULL),
GNUNET_MQ_hd_var_size (add_address,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
- struct GNUNET_TRANSPORT_AddAddressMessage,
- &tc_h),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
+ struct GNUNET_TRANSPORT_AddAddressMessage,
+ &tc_h),
//GNUNET_MQ_hd_fixed_size (del_address,
// GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
// struct GNUNET_TRANSPORT_DelAddressMessage,
@@ -477,17 +472,17 @@ transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunica
// struct GNUNET_TRANSPORT_IncomingMessage,
// NULL),
GNUNET_MQ_hd_fixed_size (queue_create_ok,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
- struct GNUNET_TRANSPORT_CreateQueueResponse,
- tc_h),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
+ struct GNUNET_TRANSPORT_CreateQueueResponse,
+ tc_h),
GNUNET_MQ_hd_fixed_size (queue_create_fail,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
- struct GNUNET_TRANSPORT_CreateQueueResponse,
- tc_h),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
+ struct GNUNET_TRANSPORT_CreateQueueResponse,
+ tc_h),
GNUNET_MQ_hd_var_size (add_queue_message,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
- struct GNUNET_TRANSPORT_AddQueueMessage,
- NULL),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
+ struct GNUNET_TRANSPORT_AddQueueMessage,
+ NULL),
//GNUNET_MQ_hd_fixed_size (del_queue_message,
// GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
// struct GNUNET_TRANSPORT_DelQueueMessage,
@@ -506,12 +501,10 @@ transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunica
tc_h,
mh);
if (NULL == h)
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Failed starting service!\n");
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Failed starting service!\n");
else
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Started service\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Started service\n");
/* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_service, h);
}
}
@@ -527,16 +520,14 @@ shutdown_communicator (void *cls)
{
struct GNUNET_OS_Process *proc = cls;
- if (GNUNET_OK != GNUNET_OS_process_kill (proc,
- SIGTERM))
+ if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGTERM))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- "Error shutting down communicator with SIGERM, trying SIGKILL\n");
- if (GNUNET_OK != GNUNET_OS_process_kill (proc,
- SIGKILL))
+ "Error shutting down communicator with SIGERM, trying SIGKILL\n");
+ if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGKILL))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Error shutting down communicator with SIGERM and SIGKILL\n");
+ "Error shutting down communicator with SIGERM and SIGKILL\n");
}
}
GNUNET_OS_process_destroy (proc);
@@ -549,30 +540,29 @@ shutdown_communicator (void *cls)
* @param cfgname Name of the communicator
*/
static void
-communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
+communicator_start (
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
{
char *binary;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "communicator_start\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
binary = GNUNET_OS_get_libexec_binary_path ("gnunet-communicator-unix");
- tc_h->c_proc =
- GNUNET_OS_start_process (GNUNET_YES,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, NULL,
- binary,
- "./gnunet-communicator-unix",
- "-c",
- tc_h->cfg_filename,
- NULL);
+ tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ NULL,
+ NULL,
+ binary,
+ "./gnunet-communicator-unix",
+ "-c",
+ tc_h->cfg_filename,
+ NULL);
if (NULL == tc_h->c_proc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to start communicator!");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "started communicator\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "started communicator\n");
GNUNET_free (binary);
/* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_communicator,
tc_h->c_proc);
@@ -592,27 +582,30 @@ communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
* @return Handle to the communicator duo
*/
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
-GNUNET_TRANSPORT_TESTING_transport_communicator_service_start
- (const char *service_name,
- const char *cfg_filename,
- GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb,
- GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
- GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
- GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
- void *cb_cls)
+GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
+ const char *service_name,
+ const char *cfg_filename,
+ GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
+ communicator_available_cb,
+ GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
+ GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
+ GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
+ void *cb_cls)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
- tc_h = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle);
+ tc_h =
+ GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle);
tc_h->cfg_filename = GNUNET_strdup (cfg_filename);
tc_h->cfg = GNUNET_CONFIGURATION_create ();
- if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (tc_h->cfg,
- cfg_filename)) )
+ if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_load (tc_h->cfg, cfg_filename)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Malformed configuration file `%s', exit ...\n"),
- cfg_filename);
+ _ ("Malformed configuration file `%s', exit ...\n"),
+ cfg_filename);
+ GNUNET_free (tc_h->cfg_filename);
+ GNUNET_CONFIGURATION_destroy (tc_h->cfg);
+ GNUNET_free (tc_h);
return NULL;
}
tc_h->communicator_available_cb = communicator_available_cb;
@@ -631,10 +624,10 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start
void
-GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
- (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
- const struct GNUNET_PeerIdentity *peer_id,
- const char *address)
+GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
+ const struct GNUNET_PeerIdentity *peer_id,
+ const char *address)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
static uint32_t idgen;
@@ -643,36 +636,33 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
struct GNUNET_MQ_Envelope *env;
size_t alen;
- tc_queue = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
+ tc_queue =
+ GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
prefix = GNUNET_HELLO_address_to_prefix (address);
if (NULL == prefix)
{
GNUNET_break (0); /* We got an invalid address!? */
+ GNUNET_free (tc_queue);
return;
}
+ GNUNET_free (prefix);
alen = strlen (address) + 1;
- env = GNUNET_MQ_msg_extra (msg,
- alen,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
+ env =
+ GNUNET_MQ_msg_extra (msg, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
msg->request_id = htonl (idgen++);
tc_queue->qid = msg->request_id;
msg->receiver = *peer_id;
tc_queue->peer_id = *peer_id;
- memcpy (&msg[1],
- address,
- alen);
+ memcpy (&msg[1], address, alen);
if (NULL != tc_h->c_mq)
{
- GNUNET_MQ_send (tc_h->c_mq,
- env);
+ GNUNET_MQ_send (tc_h->c_mq, env);
}
else
{
tc_queue->open_queue_env = env;
}
- GNUNET_CONTAINER_DLL_insert (tc_h->queue_head,
- tc_h->queue_tail,
- tc_queue);
+ GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
}
@@ -684,7 +674,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send
GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
void *cb_cls*/)
{
- struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
+ // struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
struct GNUNET_TRANSPORT_SendMessageTo *msg;
struct GNUNET_MQ_Envelope *env;
@@ -694,11 +684,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send
msg->qid = htonl (tc_queue->qid);
msg->mid = tc_queue->mid++;
msg->receiver = tc_queue->peer_id;
- memcpy (&msg[1],
- payload,
- payload_size);
- GNUNET_MQ_send (tc_queue->tc_h->c_mq,
- env);
- return tc_t;
+ memcpy (&msg[1], payload, payload_size);
+ GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
+ GNUNET_break (0); /* fixme: return value? */
+ return NULL; // tc_t;
}
-