summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/transport
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
curly wars / auto-indentation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c146
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c4
-rw-r--r--src/transport/gnunet-service-transport_clients.c46
-rw-r--r--src/transport/gnunet-service-transport_hello.c3
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c886
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h68
-rw-r--r--src/transport/gnunet-service-transport_validation.c53
-rw-r--r--src/transport/gnunet-transport-connect-running-peers.c24
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c4
-rw-r--r--src/transport/gnunet-transport.c242
-rw-r--r--src/transport/gnunet_wlan_sender.c254
-rw-r--r--src/transport/plugin_transport_http.c263
-rw-r--r--src/transport/plugin_transport_http.h20
-rw-r--r--src/transport/plugin_transport_http_client.c181
-rw-r--r--src/transport/plugin_transport_http_server.c327
-rw-r--r--src/transport/plugin_transport_sat_constants.h20
-rw-r--r--src/transport/plugin_transport_tcp.c31
-rw-r--r--src/transport/plugin_transport_udp.c477
-rw-r--r--src/transport/plugin_transport_udp_new.c222
-rw-r--r--src/transport/plugin_transport_unix.c5
-rw-r--r--src/transport/plugin_transport_wlan.c413
-rw-r--r--src/transport/test_quota_compliance.c161
-rw-r--r--src/transport/test_transport_api.c82
-rw-r--r--src/transport/test_transport_api_disconnect.c98
-rw-r--r--src/transport/test_transport_api_limited_sockets.c28
-rw-r--r--src/transport/test_transport_api_reliability.c88
-rw-r--r--src/transport/test_transport_api_timeout.c43
-rw-r--r--src/transport/test_transport_api_unreliability.c45
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c41
-rw-r--r--src/transport/test_transport_startonly.c14
-rw-r--r--src/transport/test_transport_testing.c68
-rw-r--r--src/transport/transport-testing.c134
-rw-r--r--src/transport/transport-testing.h36
-rw-r--r--src/transport/transport_api.c4
-rw-r--r--src/transport/transport_api_address_iterate.c5
35 files changed, 2344 insertions, 2192 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 10c1c68a8..878ab2618 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -90,9 +90,7 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats;
static void
transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
- const char * transport,
- const void * addr,
+ uint32_t ats_count, const char *transport, const void *addr,
size_t addrlen)
{
const struct GNUNET_MessageHeader *hello = cls;
@@ -118,7 +116,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
/**
- * We received some payload. Prepare to pass it on to our clients.
+ * We received some payload. Prepare to pass it on to our clients.
*
* @param peer (claimed) identity of the other peer
* @param message the message, never NULL
@@ -128,48 +126,45 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
*/
static struct GNUNET_TIME_Relative
process_payload (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct GNUNET_TIME_Relative ret;
int do_forward;
struct InboundMessage *im;
size_t msg_size = ntohs (message->size);
- size_t size = sizeof (struct InboundMessage) + msg_size + sizeof (struct GNUNET_ATS_Information) * ats_count;
+ size_t size =
+ sizeof (struct InboundMessage) + msg_size +
+ sizeof (struct GNUNET_ATS_Information) * ats_count;
char buf[size];
struct GNUNET_ATS_Information *ap;
-
+
ret = GNUNET_TIME_UNIT_ZERO;
do_forward = GNUNET_SYSERR;
- ret =
- GST_neighbours_calculate_receive_delay (peer,
- msg_size,
- &do_forward);
+ ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward);
if (!GST_neighbours_test_connected (peer))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Discarded %u bytes type %u payload from peer `%s'\n",
- msg_size,
- ntohs (message->type),
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Discarded %u bytes type %u payload from peer `%s'\n", msg_size,
+ ntohs (message->type), GNUNET_i2s (peer));
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# bytes payload discarded due to not connected peer "),
- msg_size,
- GNUNET_NO);
+ gettext_noop
+ ("# bytes payload discarded due to not connected peer "),
+ msg_size, GNUNET_NO);
return ret;
}
if (do_forward != GNUNET_YES)
return ret;
- im = (struct InboundMessage*) buf;
+ im = (struct InboundMessage *) buf;
im->header.size = htons (size);
im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
im->ats_count = htonl (ats_count);
im->peer = *peer;
- ap = (struct GNUNET_ATS_Information*) &im[1];
+ ap = (struct GNUNET_ATS_Information *) &im[1];
memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
memcpy (&ap[ats_count], message, ntohs (message->size));
@@ -213,7 +208,7 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
const char *plugin_name = cls;
struct GNUNET_TIME_Relative ret;
uint16_t type;
-
+
ret = GNUNET_TIME_UNIT_ZERO;
if (NULL == message)
goto end;
@@ -231,43 +226,38 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing `%s' from `%s'\n", "PING",
- (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
- sender_address,
- sender_address_len)
- : "<inbound>");
+ "Processing `%s' from `%s'\n", "PING",
+ (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
+ sender_address,
+ sender_address_len)
+ : "<inbound>");
#endif
GST_validation_handle_ping (peer, message, plugin_name, session,
- sender_address, sender_address_len);
+ sender_address, sender_address_len);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing `%s' from `%s'\n", "PONG",
- (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
- sender_address,
- sender_address_len)
- : "<inbound>");
+ "Processing `%s' from `%s'\n", "PONG",
+ (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
+ sender_address,
+ sender_address_len)
+ : "<inbound>");
#endif
GST_validation_handle_pong (peer, message);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
- GST_neighbours_handle_connect (message,
- peer,
- plugin_name, sender_address, sender_address_len,
- session, ats, ats_count);
+ GST_neighbours_handle_connect (message, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
- GST_neighbours_handle_connect_ack (message,
- peer,
- plugin_name, sender_address, sender_address_len,
- session, ats, ats_count);
+ GST_neighbours_handle_connect_ack (message, peer, plugin_name,
+ sender_address, sender_address_len,
+ session, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
- GST_neighbours_handle_ack (message,
- peer,
- plugin_name, sender_address, sender_address_len,
- session, ats, ats_count);
+ GST_neighbours_handle_ack (message, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
GST_neighbours_handle_disconnect_message (peer, message);
@@ -277,25 +267,20 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
break;
default:
/* should be payload */
- ret = process_payload (peer,
- message,
- ats, ats_count);
+ ret = process_payload (peer, message, ats, ats_count);
break;
}
- end:
+end:
#if 1
/* FIXME: this should not be needed, and not sure it's good to have it, but without
- this connections seem to go extra-slow */
- GNUNET_ATS_address_update (GST_ats, peer,
- plugin_name, sender_address, sender_address_len,
- session,
- ats, ats_count);
+ * this connections seem to go extra-slow */
+ GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
#endif
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Allowing receive from peer %s to continue in %llu ms\n",
- GNUNET_i2s (peer),
- (unsigned long long) ret.rel_value);
+ "Allowing receive from peer %s to continue in %llu ms\n",
+ GNUNET_i2s (peer), (unsigned long long) ret.rel_value);
#endif
return ret;
}
@@ -340,16 +325,14 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
struct Session *session)
{
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Session %X to peer `%s' ended \n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
session, GNUNET_i2s (peer));
#endif
if (NULL != session)
- GNUNET_log_from (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
- "transport-ats",
- "Telling ATS to destroy session %p from peer %s\n",
- session,
- GNUNET_i2s (peer));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
+ "transport-ats",
+ "Telling ATS to destroy session %p from peer %s\n",
+ session, GNUNET_i2s (peer));
GNUNET_ATS_address_destroyed (GST_ats, peer, NULL, NULL, 0, session);
GST_neighbours_session_terminated (peer, session);
}
@@ -373,32 +356,32 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
*/
static void
ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- struct Session *session,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information * ats,
+ const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
{
uint32_t bw_in = ntohl (bandwidth_in.value__);
uint32_t bw_out = ntohl (bandwidth_out.value__);
- /* ATS tells me to disconnect from peer*/
+ /* ATS tells me to disconnect from peer */
if ((bw_in == 0) && (bw_out == 0))
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS tells me to disconnect from peer `%s'\n",
- GNUNET_i2s (peer));
+ "ATS tells me to disconnect from peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
- GST_neighbours_force_disconnect(peer);
+ GST_neighbours_force_disconnect (peer);
return;
}
/* will never return GNUNET_YES since connection is to be established */
GST_neighbours_switch_to_address_3way (peer, plugin_name, plugin_addr,
- plugin_addr_len, session, ats, ats_count,
- bandwidth_in, bandwidth_out);
+ plugin_addr_len, session, ats,
+ ats_count, bandwidth_in,
+ bandwidth_out);
}
@@ -414,10 +397,11 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
static void
neighbours_connect_notification (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information
- *ats, uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
{
- size_t len = sizeof (struct ConnectInfoMessage) +
+ size_t len =
+ sizeof (struct ConnectInfoMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information);
char buf[len];
struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
@@ -428,8 +412,7 @@ neighbours_connect_notification (void *cls,
connect_msg->ats_count = htonl (ats_count);
connect_msg->id = *peer;
ap = (struct GNUNET_ATS_Information *) &connect_msg[1];
- memcpy (ap, ats,
- ats_count * sizeof (struct GNUNET_ATS_Information));
+ memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
}
@@ -548,7 +531,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
GST_plugins_load (&plugin_env_receive_callback,
&plugin_env_address_change_notification,
&plugin_env_session_end);
- GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
+ GST_ats =
+ GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
GST_neighbours_start (NULL, &neighbours_connect_notification,
&neighbours_disconnect_notification);
GST_clients_start (server);
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index 45d01e1e2..78eea2ff9 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -557,9 +557,7 @@ struct TestConnectionContext
static void
test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
- const char * transport,
- const void * addr,
+ uint32_t ats_count, const char *transport, const void *addr,
size_t addrlen)
{
struct TestConnectionContext *tcc = cls;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 8b022ef7e..ebab72db6 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -165,8 +165,7 @@ setup_client (struct GNUNET_SERVER_Client *client)
GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %X connected\n", tc);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %X connected\n", tc);
#endif
return tc;
}
@@ -333,29 +332,26 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
static void
notify_client_about_neighbour (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information
- *ats, uint32_t ats_count,
- const char * transport,
- const void * addr,
- size_t addrlen)
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count, const char *transport,
+ const void *addr, size_t addrlen)
{
struct TransportClient *tc = cls;
struct ConnectInfoMessage *cim;
struct GNUNET_ATS_Information *ap;
size_t size =
- sizeof (struct ConnectInfoMessage) +
- ats_count * sizeof (struct GNUNET_ATS_Information);
+ sizeof (struct ConnectInfoMessage) +
+ ats_count * sizeof (struct GNUNET_ATS_Information);
char buf[size];
GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- cim = (struct ConnectInfoMessage*) buf;
+ cim = (struct ConnectInfoMessage *) buf;
cim->header.size = htons (size);
cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
cim->ats_count = htonl (ats_count);
cim->id = *peer;
ap = (struct GNUNET_ATS_Information *) &cim[1];
- memcpy (ap, ats,
- ats_count * sizeof (struct GNUNET_ATS_Information));
+ memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
unicast (tc, &cim->header, GNUNET_NO);
}
@@ -401,10 +397,10 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client,
}
start = (const struct StartMessage *) message;
options = ntohl (start->options);
- if ((0 != (1 & options) ) &&
+ if ((0 != (1 & options)) &&
(0 !=
memcmp (&start->self, &GST_my_identity,
- sizeof (struct GNUNET_PeerIdentity))))
+ sizeof (struct GNUNET_PeerIdentity))))
{
/* client thinks this is a different peer, reject */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -799,26 +795,23 @@ clients_handle_peer_address_lookup (void *cls,
*/
static void
output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
- const char * transport,
- const void * addr,
- size_t addrlen)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
+ const char *transport, const void *addr, size_t addrlen)
{
struct GNUNET_SERVER_TransmitContext *tc = cls;
- struct AddressIterateResponseMessage * msg;
+ struct AddressIterateResponseMessage *msg;
size_t size;
size =
- (sizeof (struct AddressIterateResponseMessage) + strlen(transport) + 1);
+ (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1);
msg = GNUNET_malloc (size);
memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
- memcpy (&msg[0], transport, strlen(transport)+1);
+ memcpy (&msg[0], transport, strlen (transport) + 1);
msg->addrlen = ntohs (addrlen);
- msg->pluginlen = ntohs (strlen(transport)+1);
+ msg->pluginlen = ntohs (strlen (transport) + 1);
transmit_binary_to_client (tc, msg, size);
- GNUNET_free(msg);
+ GNUNET_free (msg);
}
@@ -908,9 +901,8 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
for (tc = clients_head; tc != NULL; tc = tc->next)
{
- if ( (GNUNET_YES == may_drop) &&
- (GNUNET_YES != tc->send_payload) )
- continue; /* skip, this client does not care about payload */
+ if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload))
+ continue; /* skip, this client does not care about payload */
unicast (tc, msg, may_drop);
}
}
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index a1c721857..45fdf0a26 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -166,7 +166,8 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
hello_task = GNUNET_SCHEDULER_NO_TASK;
gc.addr_pos = oal_head;
gc.expiration =
- GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION);
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION);
GNUNET_free (our_hello);
our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc);
#if DEBUG_TRANSPORT
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index d0d5b099c..0ceba53bc 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -122,7 +122,7 @@ struct SessionDisconnectMessage
* Public key of the sender.
*/
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
-
+
/**
* Signature of the peer that sends us the disconnect. Only
* valid if the timestamp is AFTER the timestamp from the
@@ -186,18 +186,18 @@ struct MessageQueue
enum State
{
- /* fresh peer or completely disconnected */
- S_NOT_CONNECTED = 0,
- /* sent CONNECT message to other peer, waiting for CONNECT_ACK */
- S_CONNECT_SENT = 1,
- /* received CONNECT message to other peer, sending CONNECT_ACK */
- S_CONNECT_RECV = 4,
- /* sent CONNECT_ACK message to other peer, wait for ACK or payload */
- S_CONNECT_RECV_ACK_SENT = 8,
- /* received ACK or payload */
- S_CONNECTED = 16,
- /* Disconnect in progress */
- S_DISCONNECT = 32
+ /* fresh peer or completely disconnected */
+ S_NOT_CONNECTED = 0,
+ /* sent CONNECT message to other peer, waiting for CONNECT_ACK */
+ S_CONNECT_SENT = 1,
+ /* received CONNECT message to other peer, sending CONNECT_ACK */
+ S_CONNECT_RECV = 4,
+ /* sent CONNECT_ACK message to other peer, wait for ACK or payload */
+ S_CONNECT_RECV_ACK_SENT = 8,
+ /* received ACK or payload */
+ S_CONNECTED = 16,
+ /* Disconnect in progress */
+ S_DISCONNECT = 32
};
/**
@@ -359,7 +359,7 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid)
#define change_state(n, state, ...) change (n, state, __LINE__)
static int
-is_connecting (struct NeighbourMapEntry * n)
+is_connecting (struct NeighbourMapEntry *n)
{
if ((n->state > S_NOT_CONNECTED) && (n->state < S_CONNECTED))
return GNUNET_YES;
@@ -367,7 +367,7 @@ is_connecting (struct NeighbourMapEntry * n)
}
static int
-is_connected (struct NeighbourMapEntry * n)
+is_connected (struct NeighbourMapEntry *n)
{
if (n->state == S_CONNECTED)
return GNUNET_YES;
@@ -375,7 +375,7 @@ is_connected (struct NeighbourMapEntry * n)
}
static int
-is_disconnecting (struct NeighbourMapEntry * n)
+is_disconnecting (struct NeighbourMapEntry *n)
{
if (n->state == S_DISCONNECT)
return GNUNET_YES;
@@ -385,84 +385,85 @@ is_disconnecting (struct NeighbourMapEntry * n)
static const char *
print_state (int state)
{
- switch (state) {
- case S_CONNECTED:
- return "S_CONNECTED";
- break;
- case S_CONNECT_RECV:
- return "S_CONNECT_RECV";
- break;
- case S_CONNECT_RECV_ACK_SENT:
- return"S_CONNECT_RECV_ACK_SENT";
- break;
- case S_CONNECT_SENT:
- return "S_CONNECT_SENT";
- break;
- case S_DISCONNECT:
- return "S_DISCONNECT";
- break;
- case S_NOT_CONNECTED:
- return "S_NOT_CONNECTED";
- break;
- default:
- GNUNET_break (0);
- break;
+ switch (state)
+ {
+ case S_CONNECTED:
+ return "S_CONNECTED";
+ break;
+ case S_CONNECT_RECV:
+ return "S_CONNECT_RECV";
+ break;
+ case S_CONNECT_RECV_ACK_SENT:
+ return "S_CONNECT_RECV_ACK_SENT";
+ break;
+ case S_CONNECT_SENT:
+ return "S_CONNECT_SENT";
+ break;
+ case S_DISCONNECT:
+ return "S_DISCONNECT";
+ break;
+ case S_NOT_CONNECTED:
+ return "S_NOT_CONNECTED";
+ break;
+ default:
+ GNUNET_break (0);
+ break;
}
return NULL;
}
static int
-change (struct NeighbourMapEntry * n, int state, int line);
+change (struct NeighbourMapEntry *n, int state, int line);
static void
-ats_suggest_cancel (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
static void
-reset_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct NeighbourMapEntry * n = cls;
+ struct NeighbourMapEntry *n = cls;
n->state_reset = GNUNET_SCHEDULER_NO_TASK;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n",
- GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state));
+ "Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen),
+ print_state (n->state));
#endif
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# failed connection attempts due to timeout"),
- 1,
+ gettext_noop
+ ("# failed connection attempts due to timeout"), 1,
GNUNET_NO);
/* resetting state */
n->state = S_NOT_CONNECTED;
/* destroying address */
- GNUNET_ATS_address_destroyed (GST_ats,
- &n->id,
- n->plugin_name,
- n->addr,
- n->addrlen,
- NULL);
+ GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr,
+ n->addrlen, NULL);
/* request new address */
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
- GNUNET_ATS_suggest_address(GST_ats, &n->id);
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
+ GNUNET_ATS_suggest_address (GST_ats, &n->id);
}
static int
-change (struct NeighbourMapEntry * n, int state, int line)
+change (struct NeighbourMapEntry *n, int state, int line)
{
- char * old = strdup(print_state(n->state));
- char * new = strdup(print_state(state));
+ char *old = strdup (print_state (n->state));
+ char *new = strdup (print_state (state));
/* allowed transitions */
int allowed = GNUNET_NO;
- switch (n->state) {
+
+ switch (n->state)
+ {
case S_NOT_CONNECTED:
if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT) ||
(state == S_DISCONNECT))
@@ -470,10 +471,12 @@ change (struct NeighbourMapEntry * n, int state, int line)
allowed = GNUNET_YES;
/* Schedule reset task */
- if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT) )
+ if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT))
{
GNUNET_assert (n->state_reset == GNUNET_SCHEDULER_NO_TASK);
- n->state_reset = GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, n);
+ n->state_reset =
+ GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task,
+ n);
}
break;
@@ -481,14 +484,18 @@ change (struct NeighbourMapEntry * n, int state, int line)
break;
case S_CONNECT_RECV:
if ((state == S_NOT_CONNECTED) || (state == S_DISCONNECT) ||
- (state == S_CONNECTED) || /* FIXME SENT -> RECV ISSUE!*/ (state == S_CONNECT_SENT))
+ (state == S_CONNECTED) ||
+ /* FIXME SENT -> RECV ISSUE! */ (state == S_CONNECT_SENT))
{
- if ((state == S_CONNECTED) || (state == S_DISCONNECT) || (state == S_NOT_CONNECTED))
+ if ((state == S_CONNECTED) || (state == S_DISCONNECT) ||
+ (state == S_NOT_CONNECTED))
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
- GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state), print_state(state));
+ "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name,
+ n->addr, n->addrlen),
+ print_state (n->state), print_state (state));
#endif
GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK);
GNUNET_SCHEDULER_cancel (n->state_reset);
@@ -501,14 +508,18 @@ change (struct NeighbourMapEntry * n, int state, int line)
break;
case S_CONNECT_SENT:
if ((state == S_NOT_CONNECTED) || (state == S_CONNECTED) ||
- (state == S_DISCONNECT) || /* FIXME SENT -> RECV ISSUE!*/ (state == S_CONNECT_RECV))
+ (state == S_DISCONNECT) ||
+ /* FIXME SENT -> RECV ISSUE! */ (state == S_CONNECT_RECV))
{
- if ((state == S_CONNECTED) || (state == S_DISCONNECT) || (state == S_NOT_CONNECTED))
+ if ((state == S_CONNECTED) || (state == S_DISCONNECT) ||
+ (state == S_NOT_CONNECTED))
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
- GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state), print_state(state));
+ "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name,
+ n->addr, n->addrlen),
+ print_state (n->state), print_state (state));
#endif
GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK);
GNUNET_SCHEDULER_cancel (n->state_reset);
@@ -528,11 +539,11 @@ change (struct NeighbourMapEntry * n, int state, int line)
break;
case S_DISCONNECT:
/*
- if (state == S_NOT_CONNECTED)
- {
- allowed = GNUNET_YES;
- break;
- }*/
+ * if (state == S_NOT_CONNECTED)
+ * {
+ * allowed = GNUNET_YES;
+ * break;
+ * } */
break;
default:
GNUNET_break (0);
@@ -543,8 +554,8 @@ change (struct NeighbourMapEntry * n, int state, int line)
if (allowed == GNUNET_NO)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Illegal state transition from `%s' to `%s' in line %u \n",
- old, new, line);
+ "Illegal state transition from `%s' to `%s' in line %u \n", old,
+ new, line);
GNUNET_break (0);
GNUNET_free (old);
GNUNET_free (new);
@@ -553,8 +564,9 @@ change (struct NeighbourMapEntry * n, int state, int line)
n->state = state;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n",
- GNUNET_i2s (&n->id), n, old, new, line);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n",
+ GNUNET_i2s (&n->id), n, old, new, line);
#endif
GNUNET_free (old);
GNUNET_free (new);
@@ -562,19 +574,12 @@ change (struct NeighbourMapEntry * n, int state, int line)
}
static ssize_t
-send_with_plugin ( const struct GNUNET_PeerIdentity * target,
- const char *msgbuf,
- size_t msgbuf_size,
- uint32_t priority,
- struct GNUNET_TIME_Relative timeout,
- struct Session * session,
- const char * plugin_name,
- const void *addr,
- size_t addrlen,
- int force_address,
- GNUNET_TRANSPORT_TransmitContinuation cont,
- void *cont_cls)
-
+send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
+ size_t msgbuf_size, uint32_t priority,
+ struct GNUNET_TIME_Relative timeout, struct Session *session,
+ const char *plugin_name, const void *addr, size_t addrlen,
+ int force_address, GNUNET_TRANSPORT_TransmitContinuation cont,
+ void *cont_cls)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
size_t ret = GNUNET_SYSERR;
@@ -602,15 +607,9 @@ send_with_plugin ( const struct GNUNET_PeerIdentity * target,
return GNUNET_SYSERR;
}
- ret = papi->send (papi->cls,
- target,
- msgbuf, msgbuf_size,
- 0,
- timeout,
- session,
- addr, addrlen,
- GNUNET_YES,
- cont, cont_cls);
+ ret =
+ papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session,
+ addr, addrlen, GNUNET_YES, cont, cont_cls);
if (ret == -1)
{
@@ -713,7 +712,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
n->is_active = mq;
mq->n = n;
- if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0))
+ if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
GNUNET_i2s (&n->id));
@@ -723,12 +722,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
return;
}
- ret = send_with_plugin (&n->id,
- mq->message_buf, mq->message_buf_size, 0,
- timeout,
- n->session, n->plugin_name, n->addr, n->addrlen,
- GNUNET_YES,
- &transmit_send_continuation, mq);
+ ret =
+ send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0,
+ timeout, n->session, n->plugin_name, n->addr,
+ n->addrlen, GNUNET_YES, &transmit_send_continuation,
+ mq);
if (ret == -1)
{
/* failure, but 'send' would not call continuation in this case,
@@ -749,7 +747,8 @@ static void
transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct NeighbourMapEntry *n = cls;
- GNUNET_assert (NULL != lookup_neighbour(&n->id));
+
+ GNUNET_assert (NULL != lookup_neighbour (&n->id));
n->transmission_task = GNUNET_SCHEDULER_NO_TASK;
try_transmission_to_peer (n);
}
@@ -774,56 +773,61 @@ GST_neighbours_start (void *cls, GNUNET_TRANSPORT_NotifyConnect connect_cb,
static void
-send_disconnect_cont (void *cls,
- const struct GNUNET_PeerIdentity * target,
- int result)
+send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target,
+ int result)
{
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending DISCONNECT message to peer `%4s': %i\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending DISCONNECT message to peer `%4s': %i\n",
GNUNET_i2s (target), result);
#endif
}
static int
-send_disconnect (const struct GNUNET_PeerIdentity * target,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session)
+send_disconnect (const struct GNUNET_PeerIdentity *target,
+ const char *plugin_name, const char *sender_address,
+ uint16_t sender_address_len, struct Session *session)
{
size_t ret;
struct SessionDisconnectMessage disconnect_msg;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending DISCONNECT message to peer `%4s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending DISCONNECT message to peer `%4s'\n",
GNUNET_i2s (target));
#endif
disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage));
disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
disconnect_msg.reserved = htonl (0);
- disconnect_msg.purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
- sizeof (struct GNUNET_TIME_AbsoluteNBO) );
- disconnect_msg.purpose.purpose = htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
- disconnect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
+ disconnect_msg.purpose.size =
+ htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
+ sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
+ sizeof (struct GNUNET_TIME_AbsoluteNBO));
+ disconnect_msg.purpose.purpose =
+ htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
+ disconnect_msg.timestamp =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
disconnect_msg.public_key = GST_my_public_key;
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_rsa_sign (GST_my_private_key,
&disconnect_msg.purpose,
&disconnect_msg.signature));
- ret = send_with_plugin(target,
- (const char *) &disconnect_msg, sizeof (disconnect_msg),
- UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
- session, plugin_name, sender_address, sender_address_len,
- GNUNET_YES, &send_disconnect_cont, NULL);
+ ret =
+ send_with_plugin (target, (const char *) &disconnect_msg,
+ sizeof (disconnect_msg), UINT32_MAX,
+ GNUNET_TIME_UNIT_FOREVER_REL, session, plugin_name,
+ sender_address, sender_address_len, GNUNET_YES,
+ &send_disconnect_cont, NULL);
if (ret == GNUNET_SYSERR)
return GNUNET_SYSERR;
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# peers disconnected due to external request"), 1,
+ gettext_noop
+ ("# peers disconnected due to external request"), 1,
GNUNET_NO);
return GNUNET_OK;
}
@@ -837,21 +841,24 @@ static void
disconnect_neighbour (struct NeighbourMapEntry *n)
{
struct MessageQueue *mq;
- int was_connected = is_connected(n);
+ int was_connected = is_connected (n);
/* send DISCONNECT MESSAGE */
- if (is_connected(n) || is_connecting(n))
+ if (is_connected (n) || is_connecting (n))
{
- if (GNUNET_OK == send_disconnect(&n->id, n->plugin_name, n->addr, n->addrlen, n->session))
+ if (GNUNET_OK ==
+ send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen,
+ n->session))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n",
GNUNET_i2s (&n->id));
else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Could not send DISCONNECT_MSG to `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Could not send DISCONNECT_MSG to `%s'\n",
GNUNET_i2s (&n->id));
}
- if (is_disconnecting(n))
+ if (is_disconnecting (n))
return;
change_state (n, S_DISCONNECT);
@@ -871,7 +878,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
{
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task);
GNUNET_SCHEDULER_cancel (n->keepalive_task);
- n->keepalive_task = GNUNET_SCHEDULER_NO_TASK;
+ n->keepalive_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_assert (neighbours_connected > 0);
neighbours_connected--;
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
@@ -929,7 +936,8 @@ neighbour_timeout_task (void *cls,
n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# peers disconnected due to timeout"), 1,
+ gettext_noop
+ ("# peers disconnected due to timeout"), 1,
GNUNET_NO);
disconnect_neighbour (n);
}
@@ -943,27 +951,24 @@ neighbour_timeout_task (void *cls,
*/
static void
neighbour_keepalive_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct NeighbourMapEntry *n = cls;
struct GNUNET_MessageHeader m;
- n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
- &neighbour_keepalive_task,
- n);
- GNUNET_assert (is_connected(n));
- GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# keepalives sent"), 1,
- GNUNET_NO);
+ n->keepalive_task =
+ GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
+ &neighbour_keepalive_task, n);
+ GNUNET_assert (is_connected (n));
+ GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# keepalives sent"), 1,
+ GNUNET_NO);
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
- send_with_plugin(&n->id, (const void *) &m,
- sizeof (m),
- UINT32_MAX /* priority */ ,
- GNUNET_TIME_UNIT_FOREVER_REL,
- n->session, n->plugin_name, n->addr, n->addrlen,
- GNUNET_YES, NULL, NULL);
+ send_with_plugin (&n->id, (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->plugin_name,
+ n->addr, n->addrlen, GNUNET_YES, NULL, NULL);
}
@@ -983,18 +988,18 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
#endif
- if (is_connected(n))
+ if (is_connected (n))
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# peers disconnected due to global disconnect"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# peers disconnected due to global disconnect"),
+ 1, GNUNET_NO);
disconnect_neighbour (n);
return GNUNET_OK;
}
static void
-ats_suggest_cancel (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct NeighbourMapEntry *n = cls;
@@ -1004,7 +1009,7 @@ ats_suggest_cancel (void *cls,
" ATS did not suggested address to connect to peer `%s'\n",
GNUNET_i2s (&n->id));
- disconnect_neighbour(n);
+ disconnect_neighbour (n);
}
/**
@@ -1039,44 +1044,39 @@ GST_neighbours_stop ()
* @param success GNUNET_OK on success
*/
static void
-send_connect_continuation (void *cls,
- const struct GNUNET_PeerIdentity * target,
- int success)
-
+send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
+ int success)
{
struct NeighbourMapEntry *n = cls;
GNUNET_assert (n != NULL);
- GNUNET_assert (!is_connected(n));
+ GNUNET_assert (!is_connected (n));
- if (is_disconnecting(n))
- return; /* neighbour is going away */
+ if (is_disconnecting (n))
+ return; /* neighbour is going away */
if (GNUNET_YES != success)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n",
- GNUNET_i2s (&n->id), n->plugin_name,
- (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
- n->session);
+ "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n",
+ GNUNET_i2s (&n->id), n->plugin_name,
+ (n->addrlen ==
+ 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen), n->session);
#endif
- GNUNET_ATS_address_destroyed (GST_ats,
- &n->id,
- n->plugin_name,
- n->addr,
- n->addrlen,
- NULL);
+ GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr,
+ n->addrlen, NULL);
- change_state(n, S_NOT_CONNECTED);
+ change_state (n, S_NOT_CONNECTED);
- if (n->ats_suggest!= GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
- GNUNET_ATS_suggest_address(GST_ats, &n->id);
+ if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
+ GNUNET_ATS_suggest_address (GST_ats, &n->id);
return;
}
@@ -1093,40 +1093,36 @@ send_connect_continuation (void *cls,
*/
static void
send_switch_address_continuation (void *cls,
- const struct GNUNET_PeerIdentity * target,
- int success)
-
+ const struct GNUNET_PeerIdentity *target,
+ int success)
{
struct NeighbourMapEntry *n = cls;
GNUNET_assert (n != NULL);
- if (is_disconnecting(n))
- return; /* neighbour is going away */
+ if (is_disconnecting (n))
+ return; /* neighbour is going away */
GNUNET_assert (n->state == S_CONNECTED);
if (GNUNET_YES != success)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n",
- GNUNET_i2s (&n->id), n->plugin_name,
- (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
- n->session);
+ "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n",
+ GNUNET_i2s (&n->id), n->plugin_name,
+ (n->addrlen ==
+ 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen), n->session);
#endif
- GNUNET_ATS_address_destroyed (GST_ats,
- &n->id,
- n->plugin_name,
- n->addr,
- n->addrlen,
- NULL);
+ GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr,
+ n->addrlen, NULL);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
- GNUNET_ATS_suggest_address(GST_ats, &n->id);
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
+ GNUNET_ATS_suggest_address (GST_ats, &n->id);
return;
}
}
@@ -1141,40 +1137,37 @@ send_switch_address_continuation (void *cls,
*/
static void
send_connect_ack_continuation (void *cls,
- const struct GNUNET_PeerIdentity * target,
- int success)
-
+ const struct GNUNET_PeerIdentity *target,
+ int success)
{
struct NeighbourMapEntry *n = cls;
GNUNET_assert (n != NULL);
if (GNUNET_YES == success)
- return; /* sending successful */
+ return; /* sending successful */
/* sending failed, ask for next address */
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n",
GNUNET_i2s (&n->id), n->plugin_name,
(n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
+ n->addr,
+ n->addrlen),
n->session);
#endif
- change_state(n, S_NOT_CONNECTED);
+ change_state (n, S_NOT_CONNECTED);
- GNUNET_ATS_address_destroyed (GST_ats,
- &n->id,
- n->plugin_name,
- n->addr,
- n->addrlen,
- NULL);
+ GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr,
+ n->addrlen, NULL);
- if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
- GNUNET_ATS_suggest_address(GST_ats, &n->id);
+ if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
+ GNUNET_ATS_suggest_address (GST_ats, &n->id);
}
/**
@@ -1194,12 +1187,15 @@ send_connect_ack_continuation (void *cls,
*/
int
GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name, const void *address,
- size_t address_len, struct Session *session,
- const struct GNUNET_ATS_Information
- *ats, uint32_t ats_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
+ const char *plugin_name,
+ const void *address, size_t address_len,
+ struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out)
{
struct NeighbourMapEntry *n;
struct SessionConnectMessage connect_msg;
@@ -1219,14 +1215,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"ATS offered suggested us empty address: plugin NULL");
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
checks_failed = GNUNET_YES;
}
- if ((address == NULL) && (address_len == 0 ) && (session == NULL))
+ if ((address == NULL) && (address_len == 0) && (session == NULL))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"ATS offered suggested us empty address: address NULL & session NULL");
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
checks_failed = GNUNET_YES;
}
@@ -1236,12 +1232,10 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
if (checks_failed == GNUNET_YES)
{
- GNUNET_ATS_address_destroyed (GST_ats,
- peer,
- plugin_name, address,
- address_len, session);
+ GNUNET_ATS_address_destroyed (GST_ats, peer, plugin_name, address,
+ address_len, session);
if (n != NULL)
- GNUNET_ATS_suggest_address(GST_ats, peer);
+ GNUNET_ATS_suggest_address (GST_ats, peer);
return GNUNET_NO;
}
@@ -1253,18 +1247,18 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
(address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name,
address,
address_len),
- session, (is_connected(n) ? "CONNECTED" : "NOT CONNECTED"),
+ session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"),
GNUNET_i2s (peer));
#endif
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
n->ats_suggest = GNUNET_SCHEDULER_NO_TASK;
}
// do not switch addresses just update quotas
- if ((is_connected(n)) && (address_len == n->addrlen))
+ if ((is_connected (n)) && (address_len == n->addrlen))
{
if ((0 == memcmp (address, n->addr, address_len)) &&
(n->session == session))
@@ -1272,16 +1266,15 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
struct QuotaSetMessage q_msg;
#if DEBUG_TRANSPORT
-GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n",
- ntohl (n->bandwidth_out.value__),
- ntohl (n->bandwidth_in.value__),
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n",
+ ntohl (n->bandwidth_out.value__),
+ ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer));
#endif
n->bandwidth_in = bandwidth_in;
n->bandwidth_out = bandwidth_out;
- GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in);
+ GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
@@ -1324,9 +1317,11 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
change_state (n, S_CONNECT_SENT);
- ret = send_with_plugin (peer, (const char *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
- session, plugin_name, address, address_len,
- GNUNET_YES, &send_connect_continuation, n);
+ ret =
+ send_with_plugin (peer, (const char *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
+ plugin_name, address, address_len, GNUNET_YES,
+ &send_connect_continuation, n);
return GNUNET_NO;
}
@@ -1336,13 +1331,16 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
msg_len = sizeof (struct SessionConnectMessage);
connect_msg.header.size = htons (msg_len);
connect_msg.header.type =
- htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK);
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK);
connect_msg.reserved = htonl (0);
- connect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
+ connect_msg.timestamp =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- ret = send_with_plugin(&n->id, (const void *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
- session, plugin_name, address, address_len,
- GNUNET_YES, &send_connect_ack_continuation, n);
+ ret =
+ send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
+ plugin_name, address, address_len, GNUNET_YES,
+ &send_connect_ack_continuation, n);
return GNUNET_NO;
}
/* connected peer is switching addresses */
@@ -1356,26 +1354,28 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
connect_msg.timestamp =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- ret = send_with_plugin (peer, (const char *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
- session, plugin_name, address, address_len,
- GNUNET_YES, &send_switch_address_continuation, n);
+ ret =
+ send_with_plugin (peer, (const char *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
+ plugin_name, address, address_len, GNUNET_YES,
+ &send_switch_address_continuation, n);
if (ret == GNUNET_SYSERR)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n",
- GNUNET_i2s (peer), plugin_name,
- (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name,
- address,
- address_len),
- session);
+ "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n",
+ GNUNET_i2s (peer), plugin_name,
+ (address_len ==
+ 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, address,
+ address_len), session);
}
return GNUNET_NO;
}
else if (n->state == S_CONNECT_SENT)
{
- return GNUNET_NO;
+ return GNUNET_NO;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid connection state to switch addresses %u \n", n->state);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid connection state to switch addresses %u \n", n->state);
GNUNET_break_op (0);
return GNUNET_NO;
}
@@ -1383,7 +1383,7 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
/**
* Create an entry in the neighbour map for the given peer
- *
+ *
* @param peer peer to create an entry for
* @return new neighbour map entry
*/
@@ -1394,22 +1394,21 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Unknown peer `%s', creating new neighbour\n",
- GNUNET_i2s (peer));
+ "Unknown peer `%s', creating new neighbour\n", GNUNET_i2s (peer));
#endif
n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
n->id = *peer;
n->state = S_NOT_CONNECTED;
GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
- GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
- MAX_BANDWIDTH_CARRY_S);
+ GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+ MAX_BANDWIDTH_CARRY_S);
n->timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &neighbour_timeout_task, n);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &neighbour_timeout_task, n);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (neighbours,
- &n->id.hashPubKey, n,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap_put (neighbours,
+ &n->id.hashPubKey, n,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
return n;
}
@@ -1433,8 +1432,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n",
GNUNET_i2s (target));
#endif
- if (0 == memcmp (target, &GST_my_identity,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 ==
+ memcmp (target, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
/* my own hello */
return;
@@ -1443,9 +1442,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
if (NULL != n)
{
- if ((is_connected(n)) || (is_connecting(n)))
- return; /* already connecting or connected */
- if (is_disconnecting(n))
+ if ((is_connected (n)) || (is_connecting (n)))
+ return; /* already connecting or connected */
+ if (is_disconnecting (n))
change_state (n, S_NOT_CONNECTED);
}
@@ -1458,7 +1457,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
GNUNET_i2s (&n->id));
#endif
- GNUNET_ATS_suggest_address (GST_ats, &n->id);
+ GNUNET_ATS_suggest_address (GST_ats, &n->id);
}
/**
@@ -1480,7 +1479,7 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
n = lookup_neighbour (target);
- if ((NULL == n) || (!is_connected(n)))
+ if ((NULL == n) || (!is_connected (n)))
return GNUNET_NO; /* not connected */
return GNUNET_YES;
}
@@ -1505,8 +1504,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
}
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Session %X to peer `%s' ended \n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
session, GNUNET_i2s (peer));
#endif
@@ -1522,7 +1520,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
n->addrlen = 0;
/* not connected anymore anyway, shouldn't matter */
- if ((!is_connected(n)) && (!is_connecting(n)))
+ if ((!is_connected (n)) && (!is_connecting (n)))
return;
/* We are connected, so ask ATS to switch addresses */
@@ -1532,8 +1530,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
&neighbour_timeout_task, n);
/* try QUICKLY to re-establish a connection, reduce timeout! */
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
GNUNET_ATS_suggest_address (GST_ats, peer);
}
@@ -1563,7 +1563,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
}
n = lookup_neighbour (target);
- if ((n == NULL) || (!is_connected(n)))
+ if ((n == NULL) || (!is_connected (n)))
{
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
@@ -1574,7 +1574,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not send message to peer `%s': unknown neighbour",
GNUNET_i2s (target));
- else if (!is_connected(n))
+ else if (!is_connected (n))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not send message to peer `%s': not connected\n",
GNUNET_i2s (target));
@@ -1584,16 +1584,16 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
return;
}
- if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen ==0))
+ if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0))
{
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# messages not sent (no such peer or not connected)"),
1, GNUNET_NO);
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Could not send message to peer `%s': no address available\n",
- GNUNET_i2s (target));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Could not send message to peer `%s': no address available\n",
+ GNUNET_i2s (target));
#endif
if (NULL != cont)
@@ -1655,14 +1655,14 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
if (NULL == n)
{
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop
- ("# messages discarded due to lack of neighbour record"),
- 1, GNUNET_NO);
+ gettext_noop
+ ("# messages discarded due to lack of neighbour record"),
+ 1, GNUNET_NO);
*do_forward = GNUNET_NO;
return GNUNET_TIME_UNIT_ZERO;
}
}
- if (!is_connected(n))
+ if (!is_connected (n))
{
*do_forward = GNUNET_SYSERR;
return GNUNET_TIME_UNIT_ZERO;
@@ -1784,10 +1784,10 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n",
GNUNET_i2s (&n->id), "SET_QUOTA");
#endif
- if (is_connected(n))
+ if (is_connected (n))
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# disconnects due to quota of 0"), 1,
- GNUNET_NO);
+ gettext_noop ("# disconnects due to quota of 0"),
+ 1, GNUNET_NO);
disconnect_neighbour (n);
}
@@ -1823,7 +1823,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value)
struct IteratorContext *ic = cls;
struct NeighbourMapEntry *n = value;
- if (!is_connected(n))
+ if (!is_connected (n))
return GNUNET_OK;
ic->cb (ic->cb_cls, &n->id, NULL, 0, n->plugin_name, n->addr, n->addrlen);
@@ -1872,13 +1872,13 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
n = lookup_neighbour (target);
if (NULL == n)
return; /* not active */
- if (is_connected(n))
+ if (is_connected (n))
{
- send_disconnect(&n->id, n->plugin_name, n->addr, n->addrlen, n->session);
+ send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, n->session);
n = lookup_neighbour (target);
if (NULL == n)
- return; /* gone already */
+ return; /* gone already */
}
disconnect_neighbour (n);
}
@@ -1887,13 +1887,15 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
/**
* We received a disconnect message from the given peer,
* validate and process.
- *
+ *
* @param peer sender of the message
* @param msg the disconnect message
*/
void
-GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *msg)
+GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
+ *peer,
+ const struct GNUNET_MessageHeader
+ *msg)
{
struct NeighbourMapEntry *n;
const struct SessionDisconnectMessage *sdm;
@@ -1901,18 +1903,20 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received DISCONNECT message from peer `%s'\n", GNUNET_i2s (peer));
+ "Received DISCONNECT message from peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
if (ntohs (msg->size) != sizeof (struct SessionDisconnectMessage))
{
// GNUNET_break_op (0);
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# disconnect messages ignored (old format)"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# disconnect messages ignored (old format)"), 1,
+ GNUNET_NO);
return;
}
- sdm = (const struct SessionDisconnectMessage* ) msg;
+ sdm = (const struct SessionDisconnectMessage *) msg;
n = lookup_neighbour (peer);
if (NULL == n)
return; /* gone already */
@@ -1920,21 +1924,20 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
n->connect_ts.abs_value)
{
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# disconnect messages ignored (timestamp)"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# disconnect messages ignored (timestamp)"), 1,
+ GNUNET_NO);
return;
}
GNUNET_CRYPTO_hash (&sdm->public_key,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- &hc);
- if (0 != memcmp (peer,
- &hc,
- sizeof (struct GNUNET_PeerIdentity)))
+ sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &hc);
+ if (0 != memcmp (peer, &hc, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
return;
}
- if (ntohl (sdm->purpose.size) !=
+ if (ntohl (sdm->purpose.size) !=
sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
sizeof (struct GNUNET_TIME_AbsoluteNBO))
@@ -1943,10 +1946,9 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
return;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT,
- &sdm->purpose,
- &sdm->signature,
- &sdm->public_key))
+ GNUNET_CRYPTO_rsa_verify
+ (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, &sdm->purpose,
+ &sdm->signature, &sdm->public_key))
{
GNUNET_break_op (0);
return;
@@ -1970,12 +1972,13 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
*/
void
GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const char *sender_address,
+ uint16_t sender_address_len,
+ struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
{
const struct SessionConnectMessage *scm;
struct QuotaSetMessage q_msg;
@@ -1987,7 +1990,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received CONNECT_ACK message from peer `%s'\n", GNUNET_i2s (peer));
+ "Received CONNECT_ACK message from peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
@@ -2013,104 +2017,94 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
"Giving ATS session %p of plugin %s for peer %s\n",
- session,
- plugin_name,
- GNUNET_i2s (peer));
- GNUNET_ATS_address_update (GST_ats,
- peer,
- plugin_name, sender_address, sender_address_len,
- session, ats, ats_count);
-
- was_connected = is_connected(n);
- if (!is_connected(n))
+ session, plugin_name, GNUNET_i2s (peer));
+ GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
+
+ was_connected = is_connected (n);
+ if (!is_connected (n))
change_state (n, S_CONNECTED);
- GNUNET_ATS_address_in_use (GST_ats,
- peer,
- plugin_name,
- sender_address,
- sender_address_len,
- session,
- GNUNET_YES);
+ GNUNET_ATS_address_in_use (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, GNUNET_YES);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Setting inbound quota of %u for peer `%s' to \n",
ntohl (n->bandwidth_in.value__), GNUNET_i2s (&n->id));
#endif
- GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in);
+ GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
- /* send ACK (ACK)*/
- msg_len = sizeof (msg);
+ /* send ACK (ACK) */
+ msg_len = sizeof (msg);
msg.size = htons (msg_len);
msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK);
- ret = send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
- GNUNET_TIME_UNIT_FOREVER_REL,
- n->session, n->plugin_name, n->addr, n->addrlen,
- GNUNET_YES, NULL, NULL);
+ ret =
+ send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
+ GNUNET_TIME_UNIT_FOREVER_REL, n->session,
+ n->plugin_name, n->addr, n->addrlen, GNUNET_YES, NULL,
+ NULL);
if (ret == GNUNET_SYSERR)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n",
- GNUNET_i2s (&n->id), n->plugin_name,
- (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
- n->session);
+ "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n",
+ GNUNET_i2s (&n->id), n->plugin_name,
+ (n->addrlen ==
+ 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen), n->session);
if (!was_connected)
{
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
- n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
- &neighbour_keepalive_task,
- n);
+ n->keepalive_task =
+ GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
+ &neighbour_keepalive_task, n);
neighbours_connected++;
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
GNUNET_NO);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n",
- GNUNET_i2s (&n->id), n->plugin_name,
- (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
- n->session, __LINE__);
+ "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n",
+ GNUNET_i2s (&n->id), n->plugin_name,
+ (n->addrlen ==
+ 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen), n->session,
+ __LINE__);
#endif
connect_notify_cb (callback_cls, &n->id, ats, ats_count);
}
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
- ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
+ ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer));
#endif
- q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
- q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
- q_msg.quota = n->bandwidth_out;
- q_msg.peer = (*peer);
- GST_clients_broadcast (&q_msg.header, GNUNET_NO);
+ q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
+ q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
+ q_msg.quota = n->bandwidth_out;
+ q_msg.peer = (*peer);
+ GST_clients_broadcast (&q_msg.header, GNUNET_NO);
}
void
GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const char *sender_address,
+ uint16_t sender_address_len, struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
{
struct NeighbourMapEntry *n;
struct QuotaSetMessage q_msg;
int was_connected;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received ACK message from peer `%s'\n", GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
@@ -2122,60 +2116,52 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
n = lookup_neighbour (peer);
if (NULL == n)
{
- send_disconnect(peer, plugin_name, sender_address, sender_address_len, session);
+ send_disconnect (peer, plugin_name, sender_address, sender_address_len,
+ session);
GNUNET_break (0);
return;
}
- if (is_connected(n))
+ if (is_connected (n))
return;
if (NULL != session)
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
"Giving ATS session %p of plugin %s for peer %s\n",
- session,
- plugin_name,
- GNUNET_i2s (peer));
- GNUNET_ATS_address_update (GST_ats,
- peer,
- plugin_name, sender_address, sender_address_len,
- session, ats, ats_count);
-
- was_connected = is_connected(n);
+ session, plugin_name, GNUNET_i2s (peer));
+ GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
+
+ was_connected = is_connected (n);
change_state (n, S_CONNECTED);
- GNUNET_ATS_address_in_use (GST_ats,
- peer,
- plugin_name,
- sender_address,
- sender_address_len,
- session,
- GNUNET_YES);
+ GNUNET_ATS_address_in_use (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, GNUNET_YES);
- GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in);
+ GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
- n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
- &neighbour_keepalive_task,
- n);
+ n->keepalive_task =
+ GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
+ &neighbour_keepalive_task, n);
if (!was_connected)
{
- neighbours_connected++;
- GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
- GNUNET_NO);
+ neighbours_connected++;
+ GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
+ GNUNET_NO);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n",
- GNUNET_i2s (&n->id), n->plugin_name,
- (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name,
- n->addr,
- n->addrlen),
- n->session, __LINE__);
+ "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n",
+ GNUNET_i2s (&n->id), n->plugin_name,
+ (n->addrlen ==
+ 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
+ n->addrlen), n->session,
+ __LINE__);
#endif
- connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+ connect_notify_cb (callback_cls, &n->id, ats, ats_count);
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2209,15 +2195,17 @@ struct BlackListCheckContext
static void
handle_connect_blacklist_cont (void *cls,
- const struct GNUNET_PeerIdentity
- * peer, int result)
+ const struct GNUNET_PeerIdentity *peer,
+ int result)
{
struct NeighbourMapEntry *n;
- struct BlackListCheckContext * bcc = cls;
+ struct BlackListCheckContext *bcc = cls;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Blacklist check due to CONNECT message: `%s'\n", GNUNET_i2s (peer), (result == GNUNET_OK) ? "ALLOWED" : "FORBIDDEN");
+ "Blacklist check due to CONNECT message: `%s'\n",
+ GNUNET_i2s (peer),
+ (result == GNUNET_OK) ? "ALLOWED" : "FORBIDDEN");
#endif
/* not allowed */
@@ -2237,13 +2225,12 @@ handle_connect_blacklist_cont (void *cls,
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
"Giving ATS session %p of plugin %s address `%s' for peer %s\n",
- bcc->session,
- bcc->plugin_name,
- GST_plugins_a2s (bcc->plugin_name, bcc->sender_address, bcc->sender_address_len),
+ bcc->session, bcc->plugin_name,
+ GST_plugins_a2s (bcc->plugin_name, bcc->sender_address,
+ bcc->sender_address_len),
GNUNET_i2s (peer));
- GNUNET_ATS_address_update (GST_ats,
- peer,
- bcc->plugin_name, bcc->sender_address, bcc->sender_address_len,
+ GNUNET_ATS_address_update (GST_ats, peer, bcc->plugin_name,
+ bcc->sender_address, bcc->sender_address_len,
bcc->session, bcc->ats, bcc->ats_count);
n->connect_ts = bcc->ts;
}
@@ -2251,13 +2238,15 @@ handle_connect_blacklist_cont (void *cls,
GNUNET_free (bcc);
if (n->state != S_CONNECT_RECV)
- change_state (n, S_CONNECT_RECV);
+ change_state (n, S_CONNECT_RECV);
/* Ask ATS for an address to connect via that address */
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(n->ats_suggest);
- n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n);
- GNUNET_ATS_suggest_address(GST_ats, peer);
+ GNUNET_SCHEDULER_cancel (n->ats_suggest);
+ n->ats_suggest =
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ n);
+ GNUNET_ATS_suggest_address (GST_ats, peer);
}
/**
@@ -2276,20 +2265,21 @@ handle_connect_blacklist_cont (void *cls,
*/
void
GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const char *sender_address,
+ uint16_t sender_address_len,
+ struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
{
const struct SessionConnectMessage *scm;
- struct NeighbourMapEntry * n;
- struct BlackListCheckContext * bcc = NULL;
+ struct NeighbourMapEntry *n;
+ struct BlackListCheckContext *bcc = NULL;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer));
+ "Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer));
#endif
if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
@@ -2301,23 +2291,24 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
scm = (const struct SessionConnectMessage *) message;
GNUNET_break_op (ntohl (scm->reserved) == 0);
- n = lookup_neighbour(peer);
+ n = lookup_neighbour (peer);
if (n != NULL)
{
/* connected peer switches addresses */
- if (is_connected(n))
+ if (is_connected (n))
{
- GNUNET_ATS_address_update(GST_ats, peer, plugin_name, sender_address, sender_address_len, session, ats, ats_count);
+ GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address,
+ sender_address_len, session, ats, ats_count);
return;
}
}
/* we are not connected to this peer */
- /* do blacklist check*/
- bcc = GNUNET_malloc (sizeof (struct BlackListCheckContext) +
- sizeof (struct GNUNET_ATS_Information) * ats_count +
- sender_address_len +
- strlen (plugin_name)+1);
+ /* do blacklist check */
+ bcc =
+ GNUNET_malloc (sizeof (struct BlackListCheckContext) +
+ sizeof (struct GNUNET_ATS_Information) * ats_count +
+ sender_address_len + strlen (plugin_name) + 1);
bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
@@ -2326,15 +2317,16 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
bcc->session = session;
bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1];
- memcpy (bcc->ats, ats,sizeof (struct GNUNET_ATS_Information) * ats_count );
+ memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
bcc->sender_address = (char *) &bcc->ats[ats_count];
- memcpy (bcc->sender_address, sender_address , sender_address_len);
+ memcpy (bcc->sender_address, sender_address, sender_address_len);
bcc->plugin_name = &bcc->sender_address[sender_address_len];
strcpy (bcc->plugin_name, plugin_name);
- GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont, bcc);
+ GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont,
+ bcc);
}
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 3868ef2cf..3aafc3d55 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -159,11 +159,9 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
typedef void (*GST_NeighbourIterator) (void *cls,
const struct GNUNET_PeerIdentity *
neighbour,
- const struct
- GNUNET_ATS_Information * ats,
- uint32_t ats_count,
- const char * transport,
- const void * addr,
+ const struct GNUNET_ATS_Information *
+ ats, uint32_t ats_count,
+ const char *transport, const void *addr,
size_t addrlen);
@@ -209,17 +207,20 @@ int
GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *address,
size_t address_len, struct Session *session,
- const struct GNUNET_ATS_Information
- *ats, uint32_t ats_count);
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count);
int
GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name, const void *address,
- size_t address_len, struct Session *session,
- const struct GNUNET_ATS_Information
- *ats, uint32_t ats_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
+ const char *plugin_name,
+ const void *address, size_t address_len,
+ struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out);
/**
@@ -238,41 +239,44 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
*/
void
GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count);
-
-void
-GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
+ const char *sender_address,
+ uint16_t sender_address_len,
struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
void
+GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const char *sender_address,
+ uint16_t sender_address_len,
+ struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count);
+
+void
GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const char *sender_address, uint16_t sender_address_len,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count);
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const char *sender_address,
+ uint16_t sender_address_len, struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count);
/**
* We received a disconnect message from the given peer,
* validate and process.
- *
+ *
* @param peer sender of the message
* @param msg the disconnect message
*/
void
-GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *msg);
+GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
+ *peer,
+ const struct GNUNET_MessageHeader
+ *msg);
#endif
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 5758ebfbb..d7b4929b2 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -405,8 +405,8 @@ add_valid_address (void *cls, const char *tname,
}
ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration);
- GNUNET_ATS_address_update (GST_ats, &pid, tname, addr,
- addrlen, NULL, NULL, 0);
+ GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, addrlen, NULL, NULL,
+ 0);
return GNUNET_OK;
}
@@ -595,7 +595,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# PING message for different peer received"), 1,
+ gettext_noop
+ ("# PING message for different peer received"), 1,
GNUNET_NO);
return;
}
@@ -614,27 +615,28 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
{
addrend = memchr (addr, '\0', alen);
if (NULL == addrend)
- {
- GNUNET_break_op (0);
- return;
- }
+ {
+ GNUNET_break_op (0);
+ return;
+ }
addrend++;
slen = strlen (addr) + 1;
alen -= slen;
-
+
if (GNUNET_YES !=
- GST_hello_test_address (addr, addrend, alen, &sig_cache, &sig_cache_exp))
+ GST_hello_test_address (addr, addrend, alen, &sig_cache,
+ &sig_cache_exp))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _
- ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"),
- GST_plugins_a2s (addr, addrend, alen));
+ _
+ ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"),
+ GST_plugins_a2s (addr, addrend, alen));
return;
}
- }
+ }
else
{
- addrend = NULL; /* make gcc happy */
+ addrend = NULL; /* make gcc happy */
slen = 0;
static struct GNUNET_CRYPTO_RsaSignature no_address_signature;
static struct GNUNET_TIME_Absolute no_address_signature_expiration;
@@ -751,7 +753,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
ve->bc = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n",
- GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr, ve->addrlen));
+ GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr,
+ ve->addrlen));
slen = strlen (ve->transport_name) + 1;
hello = GST_hello_get ();
@@ -996,12 +999,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
struct GNUNET_ATS_Information ats;
ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- ats.value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value);
- GNUNET_ATS_address_update (GST_ats, &ve->pid,
- ve->transport_name,ve->addr, ve->addrlen, NULL,
- &ats, 1);
+ ats.value =
+ htonl ((uint32_t)
+ GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value);
+ GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->transport_name, ve->addr,
+ ve->addrlen, NULL, &ats, 1);
}
-
+
/* build HELLO to store in PEERINFO */
ve->copied = GNUNET_NO;
hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve);
@@ -1043,17 +1047,16 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
GNUNET_break (0);
return;
}
- if (0 == memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 ==
+ memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
return;
/* Add peer identity without addresses to peerinfo service */
h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL);
GNUNET_PEERINFO_add_peer (GST_peerinfo, h);
#if VERBOSE_VALIDATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _
- ("Adding `%s' without addresses for peer `%s'\n"),
- "HELLO",
- GNUNET_i2s(&vac.pid));
+ _("Adding `%s' without addresses for peer `%s'\n"), "HELLO",
+ GNUNET_i2s (&vac.pid));
#endif
GNUNET_free (h);
diff --git a/src/transport/gnunet-transport-connect-running-peers.c b/src/transport/gnunet-transport-connect-running-peers.c
index a0e3b93a2..172f34b27 100644
--- a/src/transport/gnunet-transport-connect-running-peers.c
+++ b/src/transport/gnunet-transport-connect-running-peers.c
@@ -174,24 +174,23 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
"Press <q> to quit or <1> to send from p1 to p2, <2> to send from p2 to p1, <enter> repeat\n");
read:
- t = getchar();
+ t = getchar ();
if (t == '1')
{
- th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, TIMEOUT,
- &notify_ready, p1);
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0,
+ TIMEOUT, &notify_ready, p1);
return;
}
if (t == '2')
{
- th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, TIMEOUT,
- &notify_ready, p2);
+ th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0,
+ TIMEOUT, &notify_ready, p2);
return;
}
if (t == 'q')
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Exiting %c!\n", t);
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exiting %c!\n", t);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
return;
}
goto read;
@@ -200,8 +199,7 @@ read:
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %d from peer %s!\n",
@@ -210,8 +208,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
if ((MTYPE == ntohs (message->type)) &&
(sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Successfully received message\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully received message\n");
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
@@ -219,8 +216,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
GNUNET_i2s (peer), cls);
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 016aa29dd..25e55e510 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -1016,7 +1016,9 @@ getFrequencyFromChannel (int channel)
6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100
};
- return ( (channel > 0) && (channel < sizeof(frequencies) / sizeof(int)) ) ? frequencies[channel] : -1;
+ return ((channel > 0) &&
+ (channel <
+ sizeof (frequencies) / sizeof (int))) ? frequencies[channel] : -1;
}
/**
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 686423a3d..4d2912c34 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -162,15 +162,11 @@ display_test_result (struct TestContext *tc, int result)
{
if (GNUNET_YES != result)
{
- fprintf (stderr,
- "Configuration for plugin `%s' did not work!\n",
- tc->name);
+ fprintf (stderr, "Configuration for plugin `%s' did not work!\n", tc->name);
}
else
{
- fprintf (stderr,
- "Configuration for plugin `%s' is working!\n",
- tc->name);
+ fprintf (stderr, "Configuration for plugin `%s' is working!\n", tc->name);
}
if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
{
@@ -184,8 +180,7 @@ display_test_result (struct TestContext *tc, int result)
}
GNUNET_free (tc);
resolver_users--;
- if ( (0 == resolver_users) &&
- (NULL != resolver) )
+ if ((0 == resolver_users) && (NULL != resolver))
{
GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
GNUNET_OS_process_close (resolver);
@@ -242,52 +237,46 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
struct TestContext *tc;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "transport",
- "plugins",
- &plugins))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
+ &plugins))
{
fprintf (stderr,
- _("No transport plugins configured, peer will never communicate\n"));
+ _
+ ("No transport plugins configured, peer will never communicate\n"));
ret = 4;
return;
}
for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " "))
- {
- char section[12+strlen(tok)];
-
- GNUNET_snprintf (section,
- sizeof (section),
- "transport-%s",
- tok);
+ {
+ char section[12 + strlen (tok)];
+
+ GNUNET_snprintf (section, sizeof (section), "transport-%s", tok);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT",
- &bnd_port))
- {
- fprintf (stderr,
- _("No port configured for plugin `%s', cannot test it\n"),
- tok);
- continue;
- }
+ GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", &bnd_port))
+ {
+ fprintf (stderr,
+ _("No port configured for plugin `%s', cannot test it\n"), tok);
+ continue;
+ }
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, section,
- "ADVERTISED_PORT", &adv_port))
+ GNUNET_CONFIGURATION_get_value_number (cfg, section, "ADVERTISED_PORT",
+ &adv_port))
adv_port = bnd_port;
if (NULL == resolver)
resolver =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver",
- "gnunet-service-resolver", NULL);
+ GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver",
+ "gnunet-service-resolver", NULL);
resolver_users++;
GNUNET_RESOLVER_connect (cfg);
tc = GNUNET_malloc (sizeof (struct TestContext));
tc->name = GNUNET_strdup (tok);
tc->tst =
- GNUNET_NAT_test_start (cfg,
- (0 == strcasecmp (tok, "udp"))
- ? GNUNET_NO
- : GNUNET_YES,
- (uint16_t) bnd_port,
- (uint16_t) adv_port, &result_callback, tc);
+ GNUNET_NAT_test_start (cfg,
+ (0 ==
+ strcasecmp (tok,
+ "udp")) ? GNUNET_NO : GNUNET_YES,
+ (uint16_t) bnd_port, (uint16_t) adv_port,
+ &result_callback, tc);
if (NULL == tc->tst)
{
display_test_result (tc, GNUNET_SYSERR);
@@ -303,8 +292,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
* Shutdown, print statistics.
*/
static void
-do_disconnect (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_TIME_Relative duration;
@@ -317,20 +305,16 @@ do_disconnect (void *cls,
if (benchmark_receive)
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
- fprintf (stdout,
- _("Received %llu bytes/s (%llu bytes in %llu ms)\n"),
- 1000 * traffic_received / (1+duration.rel_value),
- traffic_received,
- (unsigned long long) duration.rel_value);
+ fprintf (stdout, _("Received %llu bytes/s (%llu bytes in %llu ms)\n"),
+ 1000 * traffic_received / (1 + duration.rel_value),
+ traffic_received, (unsigned long long) duration.rel_value);
}
if (benchmark_send)
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
- fprintf (stdout,
- _("Transmitted %llu bytes/s (%llu bytes in %llu ms)\n"),
- 1000 * traffic_sent / (1+duration.rel_value),
- traffic_sent,
- (unsigned long long) duration.rel_value);
+ fprintf (stdout, _("Transmitted %llu bytes/s (%llu bytes in %llu ms)\n"),
+ 1000 * traffic_sent / (1 + duration.rel_value), traffic_sent,
+ (unsigned long long) duration.rel_value);
}
}
@@ -347,8 +331,7 @@ do_disconnect (void *cls,
* @return number of bytes written to buf
*/
static size_t
-transmit_data (void *cls, size_t size,
- void *buf)
+transmit_data (void *cls, size_t size, void *buf)
{
struct GNUNET_MessageHeader *m = buf;
@@ -358,17 +341,12 @@ transmit_data (void *cls, size_t size,
m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
memset (&m[1], 52, size - sizeof (struct GNUNET_MessageHeader));
traffic_sent += size;
- th = GNUNET_TRANSPORT_notify_transmit_ready (handle,
- &pid,
- 32 * 1024,
- 0,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_data, NULL);
+ th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, 32 * 1024, 0,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &transmit_data, NULL);
if (verbosity > 0)
- fprintf (stdout,
- _("Transmitting %u bytes to %s\n"),
- (unsigned int) size,
- GNUNET_i2s (&pid));
+ fprintf (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
+ GNUNET_i2s (&pid));
return size;
}
@@ -383,39 +361,27 @@ transmit_data (void *cls, size_t size,
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity
- * peer,
- const struct
- GNUNET_ATS_Information
- * ats, uint32_t ats_count)
+notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
if (verbosity > 0)
- fprintf (stdout,
- _("Connected to %s\n"),
- GNUNET_i2s (peer));
- if (0 != memcmp (&pid,
- peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ fprintf (stdout, _("Connected to %s\n"), GNUNET_i2s (peer));
+ if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
ret = 0;
- if (benchmark_send)
+ if (benchmark_send)
{
start_time = GNUNET_TIME_absolute_get ();
- th = GNUNET_TRANSPORT_notify_transmit_ready (handle,
- peer,
- 32 * 1024,
- 0,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_data, NULL);
+ th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer, 32 * 1024, 0,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &transmit_data, NULL);
}
else
{
/* all done, terminate instantly */
GNUNET_SCHEDULER_cancel (end);
- end = GNUNET_SCHEDULER_add_now (&do_disconnect,
- NULL);
- }
+ end = GNUNET_SCHEDULER_add_now (&do_disconnect, NULL);
+ }
}
@@ -427,24 +393,17 @@ notify_connect (void *cls,
* @param peer the peer that disconnected
*/
static void
-notify_disconnect (void *cls,
- const struct
- GNUNET_PeerIdentity * peer)
+notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
if (verbosity > 0)
- fprintf (stdout,
- _("Disconnected from %s\n"),
- GNUNET_i2s (peer));
- if ( (0 == memcmp (&pid,
- peer,
- sizeof (struct GNUNET_PeerIdentity))) &&
- (NULL != th) )
+ fprintf (stdout, _("Disconnected from %s\n"), GNUNET_i2s (peer));
+ if ((0 == memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) &&
+ (NULL != th))
{
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
GNUNET_SCHEDULER_cancel (end);
- end = GNUNET_SCHEDULER_add_now (&do_disconnect,
- NULL);
+ end = GNUNET_SCHEDULER_add_now (&do_disconnect, NULL);
}
}
@@ -456,26 +415,18 @@ notify_disconnect (void *cls,
* @param peer (claimed) identity of the other peer
* @param message the message
* @param ats performance data
- * @param ats_count number of entries in ats
+ * @param ats_count number of entries in ats
*/
static void
-notify_receive (void *cls,
- const struct
- GNUNET_PeerIdentity * peer,
- const struct
- GNUNET_MessageHeader *
- message,
- const struct
- GNUNET_ATS_Information
- * ats, uint32_t ats_count)
+notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
- if (! benchmark_receive)
+ if (!benchmark_receive)
return;
if (verbosity > 0)
- fprintf (stdout,
- _("Received %u bytes from %s\n"),
- (unsigned int) ntohs (message->size),
- GNUNET_i2s (peer));
+ fprintf (stdout, _("Received %u bytes from %s\n"),
+ (unsigned int) ntohs (message->size), GNUNET_i2s (peer));
if (traffic_received == 0)
start_time = GNUNET_TIME_absolute_get ();
traffic_received += ntohs (message->size);
@@ -494,11 +445,12 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
{
if ((peer != NULL) || (transport != NULL) ||
((addr != NULL) && (addrlen > 0)))
- fprintf (stdout,
- _("Peer `%s' plugin: `%s' address `%s'\n"),
+ fprintf (stdout, _("Peer `%s' plugin: `%s' address `%s'\n"),
(peer != NULL) ? GNUNET_i2s (peer) : "<unknown>",
- (transport != NULL) ? transport : "<unknown>",
- ((addr != NULL) && (addrlen > 0) && (transport != NULL)) ?
+ (transport != NULL) ? transport : "<unknown>", ((addr != NULL) &&
+ (addrlen > 0) &&
+ (transport !=
+ NULL)) ?
"how do i resolve the name without transport service?" :
"<unknown>");
}
@@ -523,45 +475,41 @@ run (void *cls, char *const *args, const char *cfgfile,
if (benchmark_send && (NULL == cpid))
{
fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
- "-s", "-C");
+ "-s", "-C");
return;
}
if (NULL != cpid)
{
ret = 1;
- if (GNUNET_OK !=
- GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))
+ if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))
{
- fprintf (stderr,
- _("Failed to parse peer identity `%s'\n"),
- cpid);
+ fprintf (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
return;
}
- handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
- &notify_receive,
- &notify_connect,
- &notify_disconnect);
+ handle =
+ GNUNET_TRANSPORT_connect (cfg, NULL, NULL, &notify_receive,
+ &notify_connect, &notify_disconnect);
GNUNET_TRANSPORT_try_connect (handle, &pid);
- end = GNUNET_SCHEDULER_add_delayed (benchmark_send
- ? GNUNET_TIME_UNIT_FOREVER_REL
- : GNUNET_TIME_UNIT_SECONDS,
- &do_disconnect,
- NULL);
- } else if (benchmark_receive)
+ end =
+ GNUNET_SCHEDULER_add_delayed (benchmark_send ?
+ GNUNET_TIME_UNIT_FOREVER_REL :
+ GNUNET_TIME_UNIT_SECONDS, &do_disconnect,
+ NULL);
+ }
+ else if (benchmark_receive)
{
- handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
- &notify_receive,
- &notify_connect,
- &notify_disconnect);
+ handle =
+ GNUNET_TRANSPORT_connect (cfg, NULL, NULL, &notify_receive,
+ &notify_connect, &notify_disconnect);
GNUNET_TRANSPORT_try_connect (handle, &pid);
- end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &do_disconnect,
- NULL);
+ end =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &do_disconnect, NULL);
}
if (iterate_connections)
{
GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES,
- &process_address, NULL);
+ &process_address, NULL);
}
}
@@ -578,20 +526,22 @@ main (int argc, char *const *argv)
1, &GNUNET_GETOPT_set_string, &cpid},
{'i', "information", NULL,
gettext_noop ("provide information about all current connections (once)"),
- 0, &GNUNET_GETOPT_set_one, &iterate_connections},
+ 0, &GNUNET_GETOPT_set_one, &iterate_connections},
{'s', "send", NULL,
- gettext_noop ("send data for benchmarking to the other peer (until CTRL-C)"),
- 0, &GNUNET_GETOPT_set_one, &benchmark_send},
+ gettext_noop
+ ("send data for benchmarking to the other peer (until CTRL-C)"),
+ 0, &GNUNET_GETOPT_set_one, &benchmark_send},
{'t', "test", NULL,
gettext_noop ("test transport configuration (involves external server)"),
- 0, &GNUNET_GETOPT_set_one, &test_configuration},
- GNUNET_GETOPT_OPTION_VERBOSE(&verbosity),
+ 0, &GNUNET_GETOPT_set_one, &test_configuration},
+ GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-transport",
- gettext_noop ("Direct access to transport service."),
- options, &run, NULL)) ? ret : 1;
+ gettext_noop
+ ("Direct access to transport service."), options,
+ &run, NULL)) ? ret : 1;
}
diff --git a/src/transport/gnunet_wlan_sender.c b/src/transport/gnunet_wlan_sender.c
index 3aa32fb1c..f1a90178b 100644
--- a/src/transport/gnunet_wlan_sender.c
+++ b/src/transport/gnunet_wlan_sender.c
@@ -78,13 +78,13 @@ struct ieee80211_frame
* @return GNUNET_YES at success
*/
static int
-getRadiotapHeader ( struct Radiotap_Send *header)
+getRadiotapHeader (struct Radiotap_Send *header)
{
- header->rate = 255;
- header->tx_power = 0;
- header->antenna = 0;
+ header->rate = 255;
+ header->tx_power = 0;
+ header->antenna = 0;
return GNUNET_YES;
}
@@ -98,9 +98,8 @@ getRadiotapHeader ( struct Radiotap_Send *header)
* @return GNUNET_YES if there was no error
*/
static int
-getWlanHeader (struct ieee80211_frame *Header,
- const char *to_mac_addr, const char *mac,
- unsigned int size)
+getWlanHeader (struct ieee80211_frame *Header, const char *to_mac_addr,
+ const char *mac, unsigned int size)
{
uint16_t *tmp16;
const int rate = 11000000;
@@ -108,8 +107,7 @@ getWlanHeader (struct ieee80211_frame *Header,
Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA;
Header->i_fc[1] = 0x00;
memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid));
- memcpy (&Header->i_addr2, mac,
- sizeof (mac_bssid));
+ memcpy (&Header->i_addr2, mac, sizeof (mac_bssid));
memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid));
tmp16 = (uint16_t *) Header->i_dur;
@@ -120,115 +118,133 @@ getWlanHeader (struct ieee80211_frame *Header,
return GNUNET_YES;
}
-int main(int argc, char *argv[]){
+int
+main (int argc, char *argv[])
+{
char msg_buf[WLAN_MTU];
- struct GNUNET_MessageHeader *msg;
- struct ieee80211_frame *wlan_header;
- struct Radiotap_Send *radiotap;
-
- unsigned int temp[6];
- char inmac[6];
- char outmac[6];
- int pos;
- long long count;
- double bytes_per_s;
- time_t start;
- time_t akt;
- int i;
-
- if (4 != argc) {
- fprintf(
- stderr,
- "This program must be started with the interface and the targets and source mac as argument.\nThis program was compiled at ----- %s ----\n",
- __TIMESTAMP__);
- fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
- return 1;
- }
- if (6 !=
- sscanf(argv[3], "%x-%x-%x-%x-%x-%x", &temp[0],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5]))
- {
- fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
- return 1;
- }
- if (6 !=
- sscanf(argv[2], "%x-%x-%x-%x-%x-%x", &temp[0],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5]))
- {
- fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
- return 1;
- }
- for (i = 0; i < 6; i++)
- {
- inmac[i] = temp[i];
- }
- for (i = 0; i < 6; i++)
- {
- outmac[i] = temp[i];
- }
-
-
- pid_t pid;
- int commpipe[2]; /* This holds the fd for the input & output of the pipe */
-
- /* Setup communication pipeline first */
- if(pipe(commpipe)){
- fprintf(stderr,"Pipe error!\n");
- exit(1);
- }
-
- /* Attempt to fork and check for errors */
- if( (pid=fork()) == -1){
- fprintf(stderr,"Fork error. Exiting.\n"); /* something went wrong */
- exit(1);
- }
-
- if(pid){
- /* A positive (non-negative) PID indicates the parent process */
- close(commpipe[0]); /* Close unused side of pipe (in side) */
- setvbuf(stdout,(char*)NULL,_IONBF,0); /* Set non-buffered output on stdout */
-
-
- msg = (struct GNUNET_MessageHeader*) msg_buf;
- msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
- msg->size = htons (WLAN_MTU);
- radiotap = (struct Radiotap_Send *) &msg[1];
- wlan_header = (struct ieee80211_frame *) &radiotap[1];
- pos = 0;
-
- getRadiotapHeader(radiotap);
- getWlanHeader(wlan_header, outmac, inmac, WLAN_MTU - sizeof(struct GNUNET_MessageHeader));
-
- start = time(NULL);
- count = 0;
- while (1){
- pos += write(commpipe[1], msg, WLAN_MTU - pos);
- if (pos % WLAN_MTU == 0){
- pos = 0;
- count ++;
-
- if (count % 1000 == 0){
- akt = time(NULL);
- bytes_per_s = count * WLAN_MTU / (akt - start);
- bytes_per_s /= 1024;
- printf("send %f kbytes/s\n", bytes_per_s);
- }
- }
-
- }
- }
- else{
- /* A zero PID indicates that this is the child process */
- (void) close(0);
- if (-1 == dup2(commpipe[0],0)) /* Replace stdin with the in side of the pipe */
- fprintf (stderr,
- "dup2 failed: %s\n",
- strerror (errno));
- (void) close(commpipe[1]); /* Close unused side of pipe (out side) */
- /* Replace the child fork with a new process */
- if (execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", argv[1], NULL) == -1)
- {
- fprintf(stderr,"Could not start gnunet-transport-wlan-helper!");
- _exit(1);
- }
- }
- return 0;
+ struct GNUNET_MessageHeader *msg;
+ struct ieee80211_frame *wlan_header;
+ struct Radiotap_Send *radiotap;
+
+ unsigned int temp[6];
+ char inmac[6];
+ char outmac[6];
+ int pos;
+ long long count;
+ double bytes_per_s;
+ time_t start;
+ time_t akt;
+ int i;
+
+ if (4 != argc)
+ {
+ fprintf (stderr,
+ "This program must be started with the interface and the targets and source mac as argument.\nThis program was compiled at ----- %s ----\n",
+ __TIMESTAMP__);
+ fprintf (stderr,
+ "Usage: interface-name mac-target mac-source\n"
+ "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+ return 1;
+ }
+ if (6 !=
+ sscanf (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
+ &temp[3], &temp[4], &temp[5]))
+ {
+ fprintf (stderr,
+ "Usage: interface-name mac-target mac-source\n"
+ "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+ return 1;
+ }
+ if (6 !=
+ sscanf (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
+ &temp[3], &temp[4], &temp[5]))
+ {
+ fprintf (stderr,
+ "Usage: interface-name mac-target mac-source\n"
+ "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+ return 1;
+ }
+ for (i = 0; i < 6; i++)
+ {
+ inmac[i] = temp[i];
+ }
+ for (i = 0; i < 6; i++)
+ {
+ outmac[i] = temp[i];
+ }
+
+
+ pid_t pid;
+ int commpipe[2]; /* This holds the fd for the input & output of the pipe */
+
+ /* Setup communication pipeline first */
+ if (pipe (commpipe))
+ {
+ fprintf (stderr, "Pipe error!\n");
+ exit (1);
+ }
+
+ /* Attempt to fork and check for errors */
+ if ((pid = fork ()) == -1)
+ {
+ fprintf (stderr, "Fork error. Exiting.\n"); /* something went wrong */
+ exit (1);
+ }
+
+ if (pid)
+ {
+ /* A positive (non-negative) PID indicates the parent process */
+ close (commpipe[0]); /* Close unused side of pipe (in side) */
+ setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */
+
+
+ msg = (struct GNUNET_MessageHeader *) msg_buf;
+ msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
+ msg->size = htons (WLAN_MTU);
+ radiotap = (struct Radiotap_Send *) &msg[1];
+ wlan_header = (struct ieee80211_frame *) &radiotap[1];
+ pos = 0;
+
+ getRadiotapHeader (radiotap);
+ getWlanHeader (wlan_header, outmac, inmac,
+ WLAN_MTU - sizeof (struct GNUNET_MessageHeader));
+
+ start = time (NULL);
+ count = 0;
+ while (1)
+ {
+ pos += write (commpipe[1], msg, WLAN_MTU - pos);
+ if (pos % WLAN_MTU == 0)
+ {
+ pos = 0;
+ count++;
+
+ if (count % 1000 == 0)
+ {
+ akt = time (NULL);
+ bytes_per_s = count * WLAN_MTU / (akt - start);
+ bytes_per_s /= 1024;
+ printf ("send %f kbytes/s\n", bytes_per_s);
+ }
+ }
+
+ }
+ }
+ else
+ {
+ /* A zero PID indicates that this is the child process */
+ (void) close (0);
+ if (-1 == dup2 (commpipe[0], 0)) /* Replace stdin with the in side of the pipe */
+ fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
+ (void) close (commpipe[1]); /* Close unused side of pipe (out side) */
+ /* Replace the child fork with a new process */
+ if (execl
+ ("gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper",
+ argv[1], NULL) == -1)
+ {
+ fprintf (stderr, "Could not start gnunet-transport-wlan-helper!");
+ _exit (1);
+ }
+ }
+ return 0;
}
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 784dd3002..9008b958d 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -155,18 +155,20 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
struct PrettyPrinterContext *ppc;
const void *sb;
size_t sbs;
- uint16_t port = 0 ;
+ uint16_t port = 0;
if (addrlen == sizeof (struct IPv6HttpAddress))
{
- struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr;
+ struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr;
+
sb = &a6->ipv6_addr;
sbs = sizeof (struct in6_addr);
port = ntohs (a6->u6_port);
}
else if (addrlen == sizeof (struct IPv4HttpAddress))
{
- struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr;
+ struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr;
+
sb = &a4->ipv4_addr;
sbs = sizeof (struct in_addr);
port = ntohs (a4->u4_port);
@@ -218,9 +220,12 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
if (addrlen == sizeof (struct IPv4HttpAddress))
{
struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr;
+
while (w_tv4 != NULL)
{
- if ((0 == memcmp (&w_tv4->addr.ipv4_addr, &a4->ipv4_addr, sizeof (struct in_addr))) &&
+ if ((0 ==
+ memcmp (&w_tv4->addr.ipv4_addr, &a4->ipv4_addr,
+ sizeof (struct in_addr))) &&
(w_tv4->addr.u4_port == a4->u4_port))
break;
w_tv4 = w_tv4->next;
@@ -233,9 +238,12 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
if (addrlen == sizeof (struct sockaddr_in6))
{
struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr;
+
while (w_tv6 != NULL)
{
- if ((0 == memcmp (&w_tv6->addr6.ipv6_addr, &a6->ipv6_addr, sizeof (struct in6_addr))) &&
+ if ((0 ==
+ memcmp (&w_tv6->addr6.ipv6_addr, &a6->ipv6_addr,
+ sizeof (struct in6_addr))) &&
(w_tv6->addr6.u6_port == a6->u6_port))
break;
w_tv6 = w_tv6->next;
@@ -249,11 +257,10 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
}
struct GNUNET_TIME_Relative
-http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer,
- const struct GNUNET_MessageHeader * message,
- struct Session * session,
- const char *sender_address,
- uint16_t sender_address_len)
+http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message,
+ struct Session *session, const char *sender_address,
+ uint16_t sender_address_len)
{
struct Session *s = cls;
struct Plugin *plugin = s->plugin;
@@ -263,7 +270,10 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer,
distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
distance.value = htonl (1);
- delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const struct GNUNET_ATS_Information*) &distance, 1, s, s->addr, s->addrlen);
+ delay =
+ plugin->env->receive (plugin->env->cls, &s->target, message,
+ (const struct GNUNET_ATS_Information *) &distance,
+ 1, s, s->addr, s->addrlen);
return delay;
}
@@ -293,14 +303,18 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
a6 = (struct IPv6HttpAddress *) addr;
address = GNUNET_malloc (INET6_ADDRSTRLEN);
- GNUNET_assert(NULL != inet_ntop (AF_INET6, &a6->ipv6_addr, address, INET6_ADDRSTRLEN));
+ GNUNET_assert (NULL !=
+ inet_ntop (AF_INET6, &a6->ipv6_addr, address,
+ INET6_ADDRSTRLEN));
port = ntohs (a6->u6_port);
}
else if (addrlen == sizeof (struct IPv4HttpAddress))
{
a4 = (struct IPv4HttpAddress *) addr;
address = GNUNET_malloc (INET_ADDRSTRLEN);
- GNUNET_assert(NULL != inet_ntop (AF_INET, &(a4->ipv4_addr), address, INET_ADDRSTRLEN));
+ GNUNET_assert (NULL !=
+ inet_ntop (AF_INET, &(a4->ipv4_addr), address,
+ INET_ADDRSTRLEN));
port = ntohs (a4->u4_port);
}
else
@@ -309,17 +323,21 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
GNUNET_break (0);
return NULL;
}
-#if !BUILD_HTTPS
- char * protocol = "http";
+#if !BUILD_HTTPS
+ char *protocol = "http";
#else
- char * protocol = "https";
+ char *protocol = "https";
#endif
GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13));
if (addrlen == sizeof (struct IPv6HttpAddress))
- res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port);
+ res =
+ GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol,
+ address, port);
else if (addrlen == sizeof (struct IPv4HttpAddress))
- res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port);
+ res =
+ GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address,
+ port);
GNUNET_free (address);
GNUNET_assert (res != 0);
@@ -328,8 +346,8 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
struct Session *
lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
- struct Session * session,
- const void *addr, size_t addrlen, int force_address)
+ struct Session *session, const void *addr, size_t addrlen,
+ int force_address)
{
struct Session *s = NULL;
struct Session *t = NULL;
@@ -343,9 +361,15 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
{
#if 0
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Comparing peer `%s' address `%s' len %i session %X to \n", GNUNET_i2s(target), GNUNET_a2s(addr,addrlen), addrlen, session);
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"peer `%s' address `%s' len %i session %X \n\n", GNUNET_i2s(&t->target), GNUNET_a2s(t->addr,t->addrlen), t->addrlen, t);
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"memcmp %i \n", memcmp (addr, t->addr, addrlen));
+ "Comparing peer `%s' address `%s' len %i session %X to \n",
+ GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), addrlen,
+ session);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "peer `%s' address `%s' len %i session %X \n\n",
+ GNUNET_i2s (&t->target), GNUNET_a2s (t->addr, t->addrlen),
+ t->addrlen, t);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "memcmp %i \n",
+ memcmp (addr, t->addr, addrlen));
#endif
e_peer = GNUNET_NO;
e_addr = GNUNET_NO;
@@ -362,13 +386,13 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
}
if ((t == session))
{
- if(t->addrlen == session->addrlen)
- {
- if (0 == memcmp (session->addr, t->addr, t->addrlen))
+ if (t->addrlen == session->addrlen)
{
- e_addr = GNUNET_YES;
+ if (0 == memcmp (session->addr, t->addr, t->addrlen))
+ {
+ e_addr = GNUNET_YES;
+ }
}
- }
}
}
@@ -377,7 +401,8 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
s = t;
break;
}
- if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES))
+ if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) &&
+ (e_addr == GNUNET_YES))
{
s = t;
break;
@@ -405,8 +430,8 @@ delete_session (struct Session *s)
s->msg_tk = NULL;
}
GNUNET_free (s->addr);
- GNUNET_free_non_null(s->server_recv);
- GNUNET_free_non_null(s->server_send);
+ GNUNET_free_non_null (s->server_recv);
+ GNUNET_free_non_null (s->server_send);
GNUNET_free (s);
}
@@ -416,7 +441,9 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
struct Session *s = NULL;
- GNUNET_assert ((addrlen == sizeof (struct IPv6HttpAddress)) || (addrlen == sizeof (struct IPv4HttpAddress)));
+
+ GNUNET_assert ((addrlen == sizeof (struct IPv6HttpAddress)) ||
+ (addrlen == sizeof (struct IPv4HttpAddress)));
s = GNUNET_malloc (sizeof (struct Session));
memcpy (&s->target, target, sizeof (struct GNUNET_PeerIdentity));
s->plugin = plugin;
@@ -424,14 +451,13 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
memcpy (s->addr, addr, addrlen);
s->addrlen = addrlen;
s->next = NULL;
- s->next_receive = GNUNET_TIME_absolute_get_zero();
+ s->next_receive = GNUNET_TIME_absolute_get_zero ();
return s;
}
void
-notify_session_end (void *cls,
- const struct GNUNET_PeerIdentity *
- peer, struct Session * s)
+notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
+ struct Session *s)
{
struct Plugin *plugin = cls;
@@ -486,28 +512,38 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
{
struct Plugin *plugin = cls;
struct HTTP_Message *msg;
+
GNUNET_assert (plugin != NULL);
int res = GNUNET_SYSERR;
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size,
- GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, force_address);
+ "Sending %u bytes to peer `%s' on address `%s' %X %i\n",
+ msgbuf_size, GNUNET_i2s (target), ((addr != NULL) &&
+ (addrlen !=
+ 0)) ?
+ http_plugin_address_to_string (plugin, addr,
+ addrlen) : "<inbound>",
+ session, force_address);
#endif
struct Session *s = NULL;
if (addrlen != 0)
- GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) ||
- (addrlen == sizeof (struct IPv6HttpAddress)));
+ GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) ||
+ (addrlen == sizeof (struct IPv6HttpAddress)));
/* look for existing connection */
s = lookup_session (plugin, target, session, addr, addrlen, 1);
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "%s existing session: %s\n", (s!=NULL) ? "Found" : "NOT Found", ((s != NULL) && (s->inbound == GNUNET_YES)) ? "inbound" : "outbound");
+ "%s existing session: %s\n",
+ (s != NULL) ? "Found" : "NOT Found", ((s != NULL) &&
+ (s->inbound ==
+ GNUNET_YES)) ?
+ "inbound" : "outbound");
#endif
/* create new outbound connection */
@@ -517,8 +553,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name,
"Maximum number of connections reached, "
- "cannot connect to peer `%s'\n",
- GNUNET_i2s (target));
+ "cannot connect to peer `%s'\n", GNUNET_i2s (target));
return res;
}
@@ -554,8 +589,8 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
"Using outbound client session to send to `%s'\n",
GNUNET_i2s (target));
#endif
- client_send (s, msg);
- res = msgbuf_size;
+ client_send (s, msg);
+ res = msgbuf_size;
}
if (s->inbound == GNUNET_YES)
{
@@ -621,14 +656,16 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
case AF_INET:
w_t4 = plugin->ipv4_addr_head;
struct sockaddr_in *a4 = (struct sockaddr_in *) addr;
+
while (w_t4 != NULL)
{
int res = memcmp (&w_t4->addr.ipv4_addr,
&a4->sin_addr,
sizeof (struct in_addr));
+
if (res == 0)
{
- if (a4->sin_port!= w_t4->addr.u4_port)
+ if (a4->sin_port != w_t4->addr.u4_port)
res = -1;
}
@@ -639,8 +676,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
if (w_t4 == NULL)
{
w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper));
- memcpy (&w_t4->addr.ipv4_addr, &a4->sin_addr,
- sizeof (struct in_addr));
+ memcpy (&w_t4->addr.ipv4_addr, &a4->sin_addr, sizeof (struct in_addr));
w_t4->addr.u4_port = a4->sin_port;
GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
@@ -649,18 +685,23 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Notifying transport to add IPv4 address `%s'\n",
- http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct IPv4HttpAddress)));
+ http_plugin_address_to_string (NULL, &w_t4->addr,
+ sizeof (struct
+ IPv4HttpAddress)));
#endif
- plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, sizeof (struct IPv4HttpAddress));
+ plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr,
+ sizeof (struct IPv4HttpAddress));
break;
case AF_INET6:
w_t6 = plugin->ipv6_addr_head;
struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
+
while (w_t6)
{
int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
sizeof (struct in6_addr));
+
if (res == 0)
{
if (a6->sin6_port != w_t6->addr6.u6_port)
@@ -674,8 +715,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
{
w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper));
- memcpy (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
- sizeof (struct in6_addr));
+ memcpy (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, sizeof (struct in6_addr));
w_t6->addr6.u6_port = a6->sin6_port;
GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head,
@@ -684,9 +724,12 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Notifying transport to add IPv6 address `%s'\n",
- http_plugin_address_to_string(NULL, &w_t6->addr6, sizeof (struct IPv6HttpAddress)));
+ http_plugin_address_to_string (NULL, &w_t6->addr6,
+ sizeof (struct
+ IPv6HttpAddress)));
#endif
- plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6, sizeof (struct IPv6HttpAddress));
+ plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6,
+ sizeof (struct IPv6HttpAddress));
break;
default:
return;
@@ -709,14 +752,16 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
case AF_INET:
w_t4 = plugin->ipv4_addr_head;
struct sockaddr_in *a4 = (struct sockaddr_in *) addr;
+
while (w_t4 != NULL)
{
int res = memcmp (&w_t4->addr.ipv4_addr,
&a4->sin_addr,
sizeof (struct in_addr));
+
if (res == 0)
{
- if (a4->sin_port!= w_t4->addr.u4_port)
+ if (a4->sin_port != w_t4->addr.u4_port)
res = -1;
}
@@ -730,7 +775,9 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Notifying transport to remove IPv4 address `%s'\n",
- http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct IPv4HttpAddress)));
+ http_plugin_address_to_string (NULL, &w_t4->addr,
+ sizeof (struct
+ IPv4HttpAddress)));
#endif
plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr,
sizeof (struct IPv4HttpAddress));
@@ -742,10 +789,12 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
case AF_INET6:
w_t6 = plugin->ipv6_addr_head;
struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
+
while (w_t6)
{
int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
sizeof (struct in6_addr));
+
if (res == 0)
{
if (a6->sin6_port != w_t6->addr6.u6_port)
@@ -760,7 +809,9 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Notifying transport to remove IPv6 address `%s'\n",
- http_plugin_address_to_string(NULL, &w_t6->addr6, sizeof (struct IPv6HttpAddress)));
+ http_plugin_address_to_string (NULL, &w_t6->addr6,
+ sizeof (struct
+ IPv6HttpAddress)));
#endif
plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6,
sizeof (struct IPv6HttpAddress));
@@ -801,7 +852,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr,
switch (add_remove)
{
case GNUNET_YES:
- nat_add_address (cls, add_remove, addr, addrlen);
+ nat_add_address (cls, add_remove, addr, addrlen);
break;
case GNUNET_NO:
nat_remove_address (cls, add_remove, addr, addrlen);
@@ -813,6 +864,7 @@ void
http_check_ipv6 (struct Plugin *plugin)
{
struct GNUNET_NETWORK_Handle *desc = NULL;
+
if (plugin->ipv6 == GNUNET_YES)
{
/* probe IPv6 support */
@@ -825,8 +877,8 @@ http_check_ipv6 (struct Plugin *plugin)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
}
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name,
- _
- ("Disabling IPv6 since it is not supported on this system!\n"));
+ _
+ ("Disabling IPv6 since it is not supported on this system!\n"));
plugin->ipv6 = GNUNET_NO;
}
else
@@ -835,17 +887,16 @@ http_check_ipv6 (struct Plugin *plugin)
desc = NULL;
}
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Testing IPv6 on this system: %s\n", (plugin->ipv6 == GNUNET_YES) ? "successful" : "failed");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Testing IPv6 on this system: %s\n",
+ (plugin->ipv6 == GNUNET_YES) ? "successful" : "failed");
}
}
int
-http_get_addresses (struct Plugin *plugin,
- const char *serviceName,
- const struct GNUNET_CONFIGURATION_Handle
- *cfg, struct sockaddr ***addrs,
- socklen_t ** addr_lens)
+http_get_addresses (struct Plugin *plugin, const char *serviceName,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct sockaddr ***addrs, socklen_t ** addr_lens)
{
int disablev6;
unsigned long long port;
@@ -892,8 +943,8 @@ http_get_addresses (struct Plugin *plugin,
if (hostname != NULL)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Resolving `%s' since that is where `%s' will bind to.\n",
- hostname, serviceName);
+ "Resolving `%s' since that is where `%s' will bind to.\n",
+ hostname, serviceName);
memset (&hints, 0, sizeof (struct addrinfo));
if (disablev6)
hints.ai_family = AF_INET;
@@ -938,8 +989,8 @@ http_get_addresses (struct Plugin *plugin,
if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0))
continue; /* huh? */
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Service will bind to `%s'\n",
- GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+ "Service will bind to `%s'\n", GNUNET_a2s (pos->ai_addr,
+ pos->ai_addrlen));
if (pos->ai_family == AF_INET)
{
GNUNET_assert (pos->ai_addrlen == sizeof (struct sockaddr_in));
@@ -1019,10 +1070,10 @@ start_report_addresses (struct Plugin *plugin)
socklen_t *addrlens;
res =
- http_get_addresses (plugin, plugin->name, plugin->env->cfg,
- &addrs, &addrlens);
+ http_get_addresses (plugin, plugin->name, plugin->env->cfg, &addrs,
+ &addrlens);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- _("Found %u addresses to report to NAT service\n"),res);
+ _("Found %u addresses to report to NAT service\n"), res);
if (res != GNUNET_SYSERR)
{
@@ -1030,14 +1081,12 @@ start_report_addresses (struct Plugin *plugin)
GNUNET_NAT_register (plugin->env->cfg, GNUNET_YES, plugin->port,
(unsigned int) res,
(const struct sockaddr **) addrs, addrlens,
- &nat_port_map_callback, NULL,
- plugin);
+ &nat_port_map_callback, NULL, plugin);
while (res > 0)
{
res--;
#if 0
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- _("FREEING %s\n"),
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, _("FREEING %s\n"),
GNUNET_a2s (addrs[res], addrlens[res]));
#endif
GNUNET_assert (addrs[res] != NULL);
@@ -1136,24 +1185,28 @@ configure_plugin (struct Plugin *plugin)
if (plugin->port == 0)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- _("Port 0, client only mode\n"));
+ _("Port 0, client only mode\n"));
plugin->client_only = GNUNET_YES;
}
- char * bind4_address = NULL;
- if ((plugin->ipv4 == GNUNET_YES) && (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
- "BINDTO", &bind4_address)))
+ char *bind4_address = NULL;
+
+ if ((plugin->ipv4 == GNUNET_YES) &&
+ (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
+ "BINDTO", &bind4_address)))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Binding %s plugin to specific IPv4 address: `%s'\n",
- plugin->protocol, bind4_address);
+ "Binding %s plugin to specific IPv4 address: `%s'\n",
+ plugin->protocol, bind4_address);
plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in));
- if (1 != inet_pton (AF_INET, bind4_address, &plugin->server_addr_v4->sin_addr))
+ if (1 !=
+ inet_pton (AF_INET, bind4_address, &plugin->server_addr_v4->sin_addr))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- _("Specific IPv4 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"),
- bind4_address, plugin->protocol);
+ _
+ ("Specific IPv4 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"),
+ bind4_address, plugin->protocol);
GNUNET_free (plugin->server_addr_v4);
plugin->server_addr_v4 = NULL;
}
@@ -1166,20 +1219,24 @@ configure_plugin (struct Plugin *plugin)
}
- char * bind6_address = NULL;
- if ((plugin->ipv6 == GNUNET_YES) && (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
- "BINDTO6", &bind6_address)))
+ char *bind6_address = NULL;
+
+ if ((plugin->ipv6 == GNUNET_YES) &&
+ (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
+ "BINDTO6", &bind6_address)))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Binding %s plugin to specific IPv6 address: `%s'\n",
- plugin->protocol, bind6_address);
+ "Binding %s plugin to specific IPv6 address: `%s'\n",
+ plugin->protocol, bind6_address);
plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6));
- if (1 != inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr))
+ if (1 !=
+ inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- _("Specific IPv6 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"),
- bind6_address, plugin->protocol);
+ _
+ ("Specific IPv6 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"),
+ bind6_address, plugin->protocol);
GNUNET_free (plugin->server_addr_v6);
plugin->server_addr_v6 = NULL;
}
@@ -1194,6 +1251,7 @@ configure_plugin (struct Plugin *plugin)
/* Optional parameters */
unsigned long long maxneigh;
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (plugin->env->cfg, plugin->name,
"MAX_CONNECTIONS", &maxneigh))
@@ -1303,8 +1361,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
while (s != NULL)
{
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Disconnecting `%s' \n", GNUNET_i2s (&s->target));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Disconnecting `%s' \n", GNUNET_i2s (&s->target));
#endif
if (s->inbound == GNUNET_NO)
GNUNET_assert (GNUNET_OK == client_disconnect (s));
@@ -1314,15 +1372,13 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
}
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Stopping server\n");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping server\n");
#endif
/* Stop server */
server_stop (plugin);
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Stopping client\n");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping client\n");
#endif
/* Stop client */
client_stop (plugin);
@@ -1332,6 +1388,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
while (s != NULL)
{
struct Session *t = s->next;
+
GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
delete_session (s);
s = t;
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h
index dd0bc4b9d..7ace96cb6 100644
--- a/src/transport/plugin_transport_http.h
+++ b/src/transport/plugin_transport_http.h
@@ -228,12 +228,12 @@ struct Plugin
/**
* IPv4 server socket to bind to
*/
- struct sockaddr_in * server_addr_v4;
+ struct sockaddr_in *server_addr_v4;
/**
* IPv6 server socket to bind to
*/
- struct sockaddr_in6 * server_addr_v6;
+ struct sockaddr_in6 *server_addr_v6;
/**
* Server semi connections
@@ -455,11 +455,10 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls);
struct GNUNET_TIME_Relative
-http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer,
- const struct GNUNET_MessageHeader * message,
- struct Session * session,
- const char *sender_address,
- uint16_t sender_address_len);
+http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message,
+ struct Session *session, const char *sender_address,
+ uint16_t sender_address_len);
const char *
http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen);
@@ -483,7 +482,7 @@ int
server_disconnect (struct Session *s);
int
-server_send (struct Session *s, struct HTTP_Message * msg);
+server_send (struct Session *s, struct HTTP_Message *msg);
int
server_start (struct Plugin *plugin);
@@ -492,8 +491,7 @@ void
server_stop (struct Plugin *plugin);
void
-notify_session_end (void *cls,
- const struct GNUNET_PeerIdentity *
- peer, struct Session * s);
+notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
+ struct Session *s);
/* end of plugin_transport_http.h */
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index a2024953c..62be281ab 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -52,11 +52,11 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls)
text[size + 1] = '\0';
}
#if BUILD_HTTPS
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "transport-https", "Client: %X - %s", cls, text);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https",
+ "Client: %X - %s", cls, text);
#else
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "transport-http", "Client: %X - %s", cls, text);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http",
+ "Client: %X - %s", cls, text);
#endif
}
return 0;
@@ -91,7 +91,7 @@ client_schedule (struct Plugin *plugin, int now)
struct GNUNET_TIME_Relative timeout;
/* Cancel previous scheduled task */
- if (plugin->client_perform_task!= GNUNET_SCHEDULER_NO_TASK)
+ if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (plugin->client_perform_task);
plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK;
@@ -132,12 +132,8 @@ client_schedule (struct Plugin *plugin, int now)
plugin->client_perform_task =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- timeout,
- grs,
- gws,
- &client_run,
- plugin);
+ GNUNET_SCHEDULER_NO_TASK, timeout, grs, gws,
+ &client_run, plugin);
GNUNET_NETWORK_fdset_destroy (gws);
GNUNET_NETWORK_fdset_destroy (grs);
return GNUNET_OK;
@@ -153,10 +149,10 @@ client_send (struct Session *s, struct HTTP_Message *msg)
{
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
- "Client: %X was suspended, unpausing\n", s->client_put);
+ "Client: %X was suspended, unpausing\n", s->client_put);
#endif
s->client_put_paused = GNUNET_NO;
- curl_easy_pause(s->client_put, CURLPAUSE_CONT);
+ curl_easy_pause (s->client_put, CURLPAUSE_CONT);
}
client_schedule (s->plugin, GNUNET_YES);
@@ -189,43 +185,45 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
running = 0;
mret = curl_multi_perform (plugin->client_mh, &running);
- CURLMsg * msg;
+ CURLMsg *msg;
int msgs_left;
- while ((msg = curl_multi_info_read(plugin->client_mh, &msgs_left)))
+
+ while ((msg = curl_multi_info_read (plugin->client_mh, &msgs_left)))
{
- CURL *easy_h = msg->easy_handle;
- struct Session *s = NULL;
- char * d = (char *) s;
-
-
- //GNUNET_assert (easy_h != NULL);
- if (easy_h == NULL)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: connection to ended with reason %i: `%s', %i handles running\n",
- msg->data.result,
- curl_easy_strerror(msg->data.result),
- running);
- continue;
- }
-
- GNUNET_assert (CURLE_OK == curl_easy_getinfo(easy_h, CURLINFO_PRIVATE, &d));
- s = (struct Session *) d;
- GNUNET_assert (s != NULL);
-
- if (msg->msg == CURLMSG_DONE)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X connection to '%s' %s ended with reason %i: `%s'\n",
- msg->easy_handle, GNUNET_i2s(&s->target),
- http_plugin_address_to_string (NULL, s->addr, s->addrlen),
- msg->data.result,
- curl_easy_strerror(msg->data.result));
-
- client_disconnect(s);
- //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen));
- notify_session_end (plugin, &s->target, s);
- }
+ CURL *easy_h = msg->easy_handle;
+ struct Session *s = NULL;
+ char *d = (char *) s;
+
+
+ //GNUNET_assert (easy_h != NULL);
+ if (easy_h == NULL)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Client: connection to ended with reason %i: `%s', %i handles running\n",
+ msg->data.result,
+ curl_easy_strerror (msg->data.result), running);
+ continue;
+ }
+
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d));
+ s = (struct Session *) d;
+ GNUNET_assert (s != NULL);
+
+ if (msg->msg == CURLMSG_DONE)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Client: %X connection to '%s' %s ended with reason %i: `%s'\n",
+ msg->easy_handle, GNUNET_i2s (&s->target),
+ http_plugin_address_to_string (NULL, s->addr,
+ s->addrlen),
+ msg->data.result,
+ curl_easy_strerror (msg->data.result));
+
+ client_disconnect (s);
+ //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen));
+ notify_session_end (plugin, &s->target, s);
+ }
}
}
while (mret == CURLM_CALL_MULTI_PERFORM);
@@ -238,18 +236,17 @@ client_disconnect (struct Session *s)
int res = GNUNET_OK;
CURLMcode mret;
struct Plugin *plugin = s->plugin;
- struct HTTP_Message * msg;
- struct HTTP_Message * t;
+ struct HTTP_Message *msg;
+ struct HTTP_Message *t;
if (s->client_put != NULL)
{
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X Deleting outbound PUT session to peer `%s'\n",
- s->client_put,
- GNUNET_i2s (&s->target));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Client: %X Deleting outbound PUT session to peer `%s'\n",
+ s->client_put, GNUNET_i2s (&s->target));
#endif
mret = curl_multi_remove_handle (plugin->client_mh, s->client_put);
@@ -266,17 +263,16 @@ client_disconnect (struct Session *s)
if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
- s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
+ s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
}
if (s->client_get != NULL)
{
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X Deleting outbound GET session to peer `%s'\n",
- s->client_get,
- GNUNET_i2s (&s->target));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Client: %X Deleting outbound GET session to peer `%s'\n",
+ s->client_get, GNUNET_i2s (&s->target));
#endif
mret = curl_multi_remove_handle (plugin->client_mh, s->client_get);
@@ -296,7 +292,7 @@ client_disconnect (struct Session *s)
t = msg->next;
if (NULL != msg->transmit_cont)
msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
- GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
GNUNET_free (msg);
msg = t;
}
@@ -316,24 +312,28 @@ client_disconnect (struct Session *s)
static void
client_receive_mst_cb (void *cls, void *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct Session *s = cls;
struct GNUNET_TIME_Relative delay;
delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen);
- s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
+ s->next_receive =
+ GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay);
- if (GNUNET_TIME_absolute_get().abs_value < s->next_receive.abs_value)
+ if (GNUNET_TIME_absolute_get ().abs_value < s->next_receive.abs_value)
{
#if VERBOSE_CLIENT
struct Plugin *plugin = s->plugin;
+
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: peer `%s' address `%s' next read delayed for %llu ms\n",
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), delay);
+ "Client: peer `%s' address `%s' next read delayed for %llu ms\n",
+ GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen),
+ delay);
#endif
}
}
+
static void
client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -345,11 +345,10 @@ client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
- "Client: %X Waking up receive handle\n",
- s->client_get);
+ "Client: %X Waking up receive handle\n", s->client_get);
if (s->client_get != NULL)
- curl_easy_pause(s->client_get, CURLPAUSE_CONT);
+ curl_easy_pause (s->client_get, CURLPAUSE_CONT);
}
@@ -372,37 +371,38 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls)
#if VERBOSE_CLIENT
struct Plugin *plugin = s->plugin;
+
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: Received %Zu bytes from peer `%s'\n",
- len,
+ "Client: Received %Zu bytes from peer `%s'\n", len,
GNUNET_i2s (&s->target));
#endif
- now = GNUNET_TIME_absolute_get();
+ now = GNUNET_TIME_absolute_get ();
if (now.abs_value < s->next_receive.abs_value)
{
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
- struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(now, s->next_receive);
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Relative delta =
+ GNUNET_TIME_absolute_get_difference (now, s->next_receive);
#if DEBUG_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X No inbound bandwidth available! Next read was delayed for %llu ms\n",
- s->client_get, delta.rel_value);
+ "Client: %X No inbound bandwidth available! Next read was delayed for %llu ms\n",
+ s->client_get, delta.rel_value);
#endif
if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
}
- s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed (delta, &client_wake_up, s);
+ s->recv_wakeup_task =
+ GNUNET_SCHEDULER_add_delayed (delta, &client_wake_up, s);
return CURLPAUSE_ALL;
}
if (s->msg_tk == NULL)
- s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s);
+ s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s);
- GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO,
- GNUNET_NO);
+ GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, GNUNET_NO);
return len;
}
@@ -420,6 +420,7 @@ static size_t
client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
{
struct Session *s = cls;
+
#if VERBOSE_CLIENT
struct Plugin *plugin = s->plugin;
#endif
@@ -432,7 +433,8 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
{
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X Nothing to send! Suspending PUT handle!\n", s->client_put);
+ "Client: %X Nothing to send! Suspending PUT handle!\n",
+ s->client_put);
#endif
s->client_put_paused = GNUNET_YES;
return CURL_READFUNC_PAUSE;
@@ -469,13 +471,13 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
{
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Client: %X Message with %u bytes sent, removing message from queue\n",
- s->client_put, msg->size, msg->pos);
+ "Client: %X Message with %u bytes sent, removing message from queue\n",
+ s->client_put, msg->size, msg->pos);
#endif
/* Calling transmit continuation */
if (NULL != msg->transmit_cont)
msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK);
- GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
GNUNET_free (msg);
}
return bytes_sent;
@@ -500,12 +502,11 @@ client_connect (struct Session *s)
plugin->last_tag++;
/* create url */
GNUNET_asprintf (&url, "%s%s;%u",
- http_plugin_address_to_string (plugin, s->addr, s->addrlen),
- GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),plugin->last_tag);
+ http_plugin_address_to_string (plugin, s->addr, s->addrlen),
+ GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),
+ plugin->last_tag);
#if 0
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "URL `%s'\n",
- url);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "URL `%s'\n", url);
#endif
/* create get connection */
s->client_get = curl_easy_init ();
@@ -592,7 +593,7 @@ client_connect (struct Session *s)
plugin->cur_connections += 2;
/* Re-schedule since handles have changed */
- if (plugin->client_perform_task!= GNUNET_SCHEDULER_NO_TASK)
+ if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (plugin->client_perform_task);
plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK;
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index e5b20cfb4..48c8739d5 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -39,7 +39,7 @@ struct ServerConnection
int disconnect;
struct Session *session;
- struct MHD_Connection * mhd_conn;
+ struct MHD_Connection *mhd_conn;
};
/**
@@ -50,7 +50,8 @@ struct ServerConnection
* @return gnunet task identifier
*/
static GNUNET_SCHEDULER_TaskIdentifier
-server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int now);
+server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
+ int now);
static void
server_log (void *arg, const char *fmt, va_list ap)
@@ -74,13 +75,14 @@ server_log (void *arg, const char *fmt, va_list ap)
static int
server_accept_cb (void *cls, const struct sockaddr *addr, socklen_t addr_len)
{
- struct Plugin * plugin = cls;
+ struct Plugin *plugin = cls;
if (plugin->cur_connections <= plugin->max_connections)
return MHD_YES;
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Cannot accept new connections\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Server: Cannot accept new connections\n");
return MHD_NO;
}
}
@@ -131,8 +133,11 @@ server_load_certificate (struct Plugin *plugin)
/* Get crypto init string from config
* If not present just use default values */
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
- "CRYPTO_INIT", &plugin->crypto_init));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
+ plugin->name,
+ "CRYPTO_INIT",
+ &plugin->crypto_init));
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name,
@@ -145,7 +150,7 @@ server_load_certificate (struct Plugin *plugin)
GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name,
"CERT_FILE", &cert_file))
{
- GNUNET_asprintf(&cert_file, "%s", "https_cert.crt");
+ GNUNET_asprintf (&cert_file, "%s", "https_cert.crt");
}
/* read key & certificates from file */
@@ -244,7 +249,7 @@ server_reschedule (struct Plugin *plugin, int now)
{
if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(plugin->server_v4_task);
+ GNUNET_SCHEDULER_cancel (plugin->server_v4_task);
plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK;
}
plugin->server_v4_task = server_schedule (plugin, plugin->server_v4, now);
@@ -252,12 +257,12 @@ server_reschedule (struct Plugin *plugin, int now)
if (plugin->server_v6 != NULL)
{
- if (plugin->server_v6_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(plugin->server_v6_task);
- plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
- }
- plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, now);
+ if (plugin->server_v6_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (plugin->server_v6_task);
+ plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, now);
}
}
@@ -269,9 +274,10 @@ server_reschedule (struct Plugin *plugin, int now)
*/
static void
server_receive_mst_cb (void *cls, void *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct Session *s = cls;
+
#if VERBOSE_SERVER
struct Plugin *plugin = s->plugin;
#endif
@@ -279,13 +285,16 @@ server_receive_mst_cb (void *cls, void *client,
delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen);
- s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
+ s->next_receive =
+ GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay);
if (delay.rel_value > 0)
{
#if VERBOSE_CLIENT
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Server: peer `%s' address `%s' next read delayed for %llu ms\n",
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), delay);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Server: peer `%s' address `%s' next read delayed for %llu ms\n",
+ GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen),
+ delay);
#endif
}
}
@@ -305,6 +314,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
struct HTTP_Message *msg;
int bytes_read = 0;
+
//static int c = 0;
msg = s->msg_head;
if (msg != NULL)
@@ -328,54 +338,58 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
{
if (NULL != msg->transmit_cont)
msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK);
- GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
GNUNET_free (msg);
}
}
#if VERBOSE_CLIENT
struct Plugin *plugin = s->plugin;
+
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: %X: sent %u bytes\n",
- s, bytes_read);
+ "Server: %X: sent %u bytes\n", s, bytes_read);
#endif
return bytes_read;
}
static struct ServerConnection *
server_lookup_session (struct Plugin *plugin,
- struct MHD_Connection *mhd_connection,
- const char * url,
- const char *method)
+ struct MHD_Connection *mhd_connection, const char *url,
+ const char *method)
{
struct Session *s = NULL;
- struct Session * t;
+ struct Session *t;
struct ServerConnection *sc = NULL;
const union MHD_ConnectionInfo *conn_info;
struct IPv4HttpAddress a4;
struct IPv6HttpAddress a6;
- struct sockaddr_in * s4;
- struct sockaddr_in6 * s6;
- void * a;
+ struct sockaddr_in *s4;
+ struct sockaddr_in6 *s6;
+ void *a;
size_t a_len;
struct GNUNET_PeerIdentity target;
int check = GNUNET_NO;
uint32_t tag = 0;
int direction;
- conn_info = MHD_get_connection_info (mhd_connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS);
- if ((conn_info->client_addr->sa_family != AF_INET) && (conn_info->client_addr->sa_family != AF_INET6))
+ conn_info =
+ MHD_get_connection_info (mhd_connection,
+ MHD_CONNECTION_INFO_CLIENT_ADDRESS);
+ if ((conn_info->client_addr->sa_family != AF_INET) &&
+ (conn_info->client_addr->sa_family != AF_INET6))
return MHD_NO;
- if ((strlen(&url[1]) >= 105) && (url[104] == ';'))
+ if ((strlen (&url[1]) >= 105) && (url[104] == ';'))
{
char hash[104];
- char * tagc = (char *) &url[105];
- memcpy(&hash, &url[1], 103);
- hash [103] = '\0';
- if (GNUNET_OK == GNUNET_CRYPTO_hash_from_string ((const char *) &hash,
- &(target.hashPubKey)))
+ char *tagc = (char *) &url[105];
+
+ memcpy (&hash, &url[1], 103);
+ hash[103] = '\0';
+ if (GNUNET_OK ==
+ GNUNET_CRYPTO_hash_from_string ((const char *) &hash,
+ &(target.hashPubKey)))
{
tag = strtoul (tagc, NULL, 10);
if (tagc > 0)
@@ -395,7 +409,8 @@ server_lookup_session (struct Plugin *plugin,
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag);
+ "Server: New inbound connection from %s with tag %u\n",
+ GNUNET_i2s (&target), tag);
#endif
/* find duplicate session */
@@ -403,17 +418,20 @@ server_lookup_session (struct Plugin *plugin,
while (t != NULL)
{
- if ((t->inbound) && (0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) &&
+ if ((t->inbound) &&
+ (0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity)))
+ &&
/* FIXME add source address comparison */
(t->tag == tag))
- break;
+ break;
t = t->next;
}
if (t != NULL)
{
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+ "Server: Duplicate session, dismissing new connection from peer `%s'\n",
+ GNUNET_i2s (&target));
#endif
goto error;
}
@@ -424,8 +442,8 @@ server_lookup_session (struct Plugin *plugin,
while (t != NULL)
{
/* FIXME add source address comparison */
- if ((0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) &&
- (t->tag == tag))
+ if ((0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity)))
+ && (t->tag == tag))
{
break;
}
@@ -437,25 +455,29 @@ server_lookup_session (struct Plugin *plugin,
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target));
+ "Server: Found existing semi-session for `%s'\n",
+ GNUNET_i2s (&target));
#endif
if ((direction == _SEND) && (t->server_send != NULL))
{
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+ "Server: Duplicate GET session, dismissing new connection from peer `%s'\n",
+ GNUNET_i2s (&target));
#endif
goto error;
}
else
{
s = t;
- GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s);
- GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
+ GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head,
+ plugin->server_semi_tail, s);
+ GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
+ "Server: Found matching semi-session, merging session for peer `%s'\n",
+ GNUNET_i2s (&target));
#endif
goto found;
@@ -464,18 +486,21 @@ server_lookup_session (struct Plugin *plugin,
{
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+ "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n",
+ GNUNET_i2s (&target));
#endif
goto error;
}
else
{
s = t;
- GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s);
- GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
+ GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head,
+ plugin->server_semi_tail, s);
+ GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
+ "Server: Found matching semi-session, merging session for peer `%s'\n",
+ GNUNET_i2s (&target));
#endif
goto found;
}
@@ -484,53 +509,48 @@ create:
/* create new session */
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target));
+ "Server: Creating new session for peer `%s' \n",
+ GNUNET_i2s (&target));
#endif
switch (conn_info->client_addr->sa_family)
{
case (AF_INET):
- s4 = ((struct sockaddr_in * ) conn_info->client_addr);
- a4.u4_port = s4->sin_port;
- memcpy (&a4.ipv4_addr, &s4->sin_addr,
- sizeof (struct in_addr));
- a = &a4;
- a_len = sizeof (struct IPv4HttpAddress);
- break;
+ s4 = ((struct sockaddr_in *) conn_info->client_addr);
+ a4.u4_port = s4->sin_port;
+ memcpy (&a4.ipv4_addr, &s4->sin_addr, sizeof (struct in_addr));
+ a = &a4;
+ a_len = sizeof (struct IPv4HttpAddress);
+ break;
case (AF_INET6):
- s6 = ((struct sockaddr_in6 * ) conn_info->client_addr);
- a6.u6_port = s6->sin6_port;
- memcpy (&a6.ipv6_addr, &s6->sin6_addr,
- sizeof (struct in6_addr));
- a = &a6;
- a_len = sizeof (struct IPv6HttpAddress);
- break;
+ s6 = ((struct sockaddr_in6 *) conn_info->client_addr);
+ a6.u6_port = s6->sin6_port;
+ memcpy (&a6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
+ a = &a6;
+ a_len = sizeof (struct IPv6HttpAddress);
+ break;
default:
GNUNET_break (0);
goto error;
}
- s = create_session (plugin,
- &target,
- a,
- a_len,
- NULL,
- NULL);
+ s = create_session (plugin, &target, a, a_len, NULL, NULL);
s->inbound = GNUNET_YES;
- s->next_receive = GNUNET_TIME_absolute_get_zero();
- s->tag= tag;
+ s->next_receive = GNUNET_TIME_absolute_get_zero ();
+ s->tag = tag;
if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
s->server_recv = s;
if (0 == strcmp (MHD_HTTP_METHOD_GET, method))
s->server_send = s;
- GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head, plugin->server_semi_tail, s);
+ GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head,
+ plugin->server_semi_tail, s);
goto found;
error:
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Invalid connection request\n");
+ "Server: Invalid connection request\n");
#endif
return NULL;
@@ -546,6 +566,7 @@ found:
#if MHD_VERSION >= 0x00090E00
int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000);
+
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Server: Setting timeout for %X to %u sec.\n", sc, to);
@@ -581,12 +602,14 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
/* new connection */
if (sc == NULL)
{
- sc = server_lookup_session(plugin, mhd_connection, url, method);
+ sc = server_lookup_session (plugin, mhd_connection, url, method);
if (sc != NULL)
(*httpSessionCache) = sc;
else
{
- response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
+ response =
+ MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),
+ HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response);
MHD_destroy_response (response);
return res;
@@ -597,10 +620,12 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
sc = (*httpSessionCache);
s = sc->session;
- /* connection is to be disconnected*/
+ /* connection is to be disconnected */
if (sc->disconnect == GNUNET_YES)
{
- response = MHD_create_response_from_data (strlen ("Thank you!"), "Thank you!", MHD_NO, MHD_NO);
+ response =
+ MHD_create_response_from_data (strlen ("Thank you!"), "Thank you!",
+ MHD_NO, MHD_NO);
res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
#if VERBOSE_SERVER
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -613,7 +638,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
GNUNET_assert (s != NULL);
if (sc->direction == _SEND)
{
- response = MHD_create_response_from_callback (-1, 32 * 1024, &server_send_callback,
+ response =
+ MHD_create_response_from_callback (-1, 32 * 1024, &server_send_callback,
s, NULL);
res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
@@ -624,9 +650,10 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
if (*upload_data_size == 0)
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Peer `%s' PUT on address `%s' connected\n",
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Server: Peer `%s' PUT on address `%s' connected\n",
+ GNUNET_i2s (&s->target), GNUNET_a2s (s->addr,
+ s->addrlen));
#endif
return MHD_YES;
}
@@ -635,23 +662,28 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
if ((*upload_data_size > 0))
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: peer `%s' PUT on address `%s' received %Zu bytes\n",
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), *upload_data_size);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Server: peer `%s' PUT on address `%s' received %Zu bytes\n",
+ GNUNET_i2s (&s->target), GNUNET_a2s (s->addr,
+ s->addrlen),
+ *upload_data_size);
#endif
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
- if (( s->next_receive.abs_value <= now.abs_value))
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+
+ if ((s->next_receive.abs_value <= now.abs_value))
{
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: %X: PUT with %u bytes forwarded to MST\n", s,
- *upload_data_size);
+ "Server: %X: PUT with %u bytes forwarded to MST\n", s,
+ *upload_data_size);
#endif
if (s->msg_tk == NULL)
{
s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s);
}
- res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO);
+ res =
+ GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data,
+ *upload_data_size, GNUNET_NO, GNUNET_NO);
#if MHD_VERSION >= 0x00090E00
int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000);
@@ -668,18 +700,22 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
t = s->server_recv;
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Setting timeout for %X to %u sec.\n", t, to);
+ "Server: Setting timeout for %X to %u sec.\n", t,
+ to);
#endif
- MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, to);
+ MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ to);
}
if (s->server_send != NULL)
{
t = s->server_send;
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Setting timeout for %X to %u sec.\n", t, to);
+ "Server: Setting timeout for %X to %u sec.\n", t,
+ to);
#endif
- MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, to);
+ MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ to);
}
server_reschedule (plugin, GNUNET_NO);
#endif
@@ -688,8 +724,9 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
else
{
#if DEBUG_HTTP
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n", s, now.abs_value - s->next_receive.abs_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n",
+ s, now.abs_value - s->next_receive.abs_value);
#endif
}
return MHD_YES;
@@ -706,22 +743,22 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
{
struct ServerConnection *sc = *httpSessionCache;
struct ServerConnection *tc = *httpSessionCache;
- struct Session * s = NULL;
- struct Session * t = NULL;
- struct Plugin * plugin = NULL;
+ struct Session *s = NULL;
+ struct Session *t = NULL;
+ struct Plugin *plugin = NULL;
if (sc == NULL)
return;
s = sc->session;
- plugin = s-> plugin;
+ plugin = s->plugin;
if (sc->direction == _SEND)
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Server: %X peer `%s' GET on address `%s' disconnected\n",
- s->server_send,
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Server: %X peer `%s' GET on address `%s' disconnected\n",
+ s->server_send, GNUNET_i2s (&s->target),
+ GNUNET_a2s (s->addr, s->addrlen));
#endif
s->server_send = NULL;
@@ -730,17 +767,18 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
tc = s->server_recv;
tc->disconnect = GNUNET_YES;
#if MHD_VERSION >= 0x00090E00
- MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, 1);
+ MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ 1);
#endif
}
}
if (sc->direction == _RECEIVE)
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Server: %X peer `%s' PUT on address `%s' disconnected\n",
- s->server_recv,
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Server: %X peer `%s' PUT on address `%s' disconnected\n",
+ s->server_recv, GNUNET_i2s (&s->target),
+ GNUNET_a2s (s->addr, s->addrlen));
#endif
s->server_recv = NULL;
if (s->server_send != NULL)
@@ -748,13 +786,14 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
tc = s->server_send;
tc->disconnect = GNUNET_YES;
#if MHD_VERSION >= 0x00090E00
- MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, 1);
+ MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ 1);
#endif
}
if (s->msg_tk != NULL)
{
- GNUNET_SERVER_mst_destroy(s->msg_tk);
- s->msg_tk = NULL;
+ GNUNET_SERVER_mst_destroy (s->msg_tk);
+ s->msg_tk = NULL;
}
}
GNUNET_free (sc);
@@ -764,8 +803,9 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
{
if (t == s)
{
- GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s);
- GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
+ GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head,
+ plugin->server_semi_tail, s);
+ GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
break;
}
t = t->next;
@@ -777,17 +817,17 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
if ((s->server_send == NULL) && (s->server_recv == NULL))
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: peer `%s' on address `%s' disconnected\n",
- GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Server: peer `%s' on address `%s' disconnected\n",
+ GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
#endif
if (s->msg_tk != NULL)
{
- GNUNET_SERVER_mst_destroy(s->msg_tk);
- s->msg_tk = NULL;
+ GNUNET_SERVER_mst_destroy (s->msg_tk);
+ s->msg_tk = NULL;
}
- notify_session_end(s->plugin, &s->target, s);
+ notify_session_end (s->plugin, &s->target, s);
}
}
@@ -818,7 +858,7 @@ server_disconnect (struct Session *s)
}
int
-server_send (struct Session *s, struct HTTP_Message * msg)
+server_send (struct Session *s, struct HTTP_Message *msg)
{
GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg);
server_reschedule (s->plugin, GNUNET_YES);
@@ -834,10 +874,10 @@ server_send (struct Session *s, struct HTTP_Message * msg)
* @param tc task context
*/
static void
-server_v4_run (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
+
GNUNET_assert (cls != NULL);
plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK;
@@ -847,7 +887,8 @@ server_v4_run (void *cls,
GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4));
if (plugin->server_v4 != NULL)
- plugin->server_v4_task = server_schedule (plugin, plugin->server_v4, GNUNET_NO);
+ plugin->server_v4_task =
+ server_schedule (plugin, plugin->server_v4, GNUNET_NO);
}
@@ -858,10 +899,10 @@ server_v4_run (void *cls,
* @param tc task context
*/
static void
-server_v6_run (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
+
GNUNET_assert (cls != NULL);
plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
@@ -871,7 +912,8 @@ server_v6_run (void *cls,
GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6));
if (plugin->server_v6 != NULL)
- plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, GNUNET_NO);
+ plugin->server_v6_task =
+ server_schedule (plugin, plugin->server_v6, GNUNET_NO);
}
/**
@@ -882,7 +924,8 @@ server_v6_run (void *cls,
* @return gnunet task identifier
*/
static GNUNET_SCHEDULER_TaskIdentifier
-server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int now)
+server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
+ int now)
{
GNUNET_SCHEDULER_TaskIdentifier ret;
fd_set rs;
@@ -909,7 +952,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int no
GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max));
haveto = MHD_get_timeout (daemon_handle, &timeout);
if (haveto == MHD_YES)
- {
+ {
if (timeout != last_timeout)
{
#if VERBOSE_SERVER
@@ -920,7 +963,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int no
last_timeout = timeout;
}
tv.rel_value = (uint64_t) timeout;
- }
+ }
else
tv = GNUNET_TIME_UNIT_SECONDS;
/* Force immediate run, since we have outbound data to send */
@@ -972,7 +1015,7 @@ server_start (struct Plugin *plugin)
if (res == GNUNET_SYSERR)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Could not load or create server certificate! Loading plugin failed!\n");
+ "Could not load or create server certificate! Loading plugin failed!\n");
return res;
}
#endif
@@ -981,11 +1024,13 @@ server_start (struct Plugin *plugin)
#if MHD_VERSION >= 0x00090E00
timeout = GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT.rel_value / 1000;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "MHD can set timeout per connection! Default time out %u sec.\n", timeout);
+ "MHD can set timeout per connection! Default time out %u sec.\n",
+ timeout);
#else
timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000;
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name,
- "MHD cannot set timeout per connection! Default time out %u sec.\n", timeout);
+ "MHD cannot set timeout per connection! Default time out %u sec.\n",
+ timeout);
#endif
plugin->server_v4 = NULL;
if (plugin->ipv4 == GNUNET_YES)
@@ -1015,7 +1060,7 @@ server_start (struct Plugin *plugin)
plugin->cert,
#endif
MHD_OPTION_CONNECTION_TIMEOUT,
- timeout ,
+ timeout,
MHD_OPTION_CONNECTION_MEMORY_LIMIT,
(size_t) (2 *
GNUNET_SERVER_MAX_MESSAGE_SIZE),
@@ -1066,15 +1111,15 @@ server_start (struct Plugin *plugin)
if ((plugin->ipv4 == GNUNET_YES) && (plugin->server_v4 == NULL))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Failed to start %s IPv4 server component on port %u\n", plugin->name,
- plugin->port);
+ "Failed to start %s IPv4 server component on port %u\n",
+ plugin->name, plugin->port);
return GNUNET_SYSERR;
}
if ((plugin->ipv6 == GNUNET_YES) && (plugin->server_v6 == NULL))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Failed to start %s IPv6 server component on port %u\n", plugin->name,
- plugin->port);
+ "Failed to start %s IPv6 server component on port %u\n",
+ plugin->name, plugin->port);
return GNUNET_SYSERR;
}
@@ -1095,8 +1140,10 @@ server_stop (struct Plugin *plugin)
struct Session *t = NULL;
struct MHD_Daemon *server_v4_tmp = plugin->server_v4;
+
plugin->server_v4 = NULL;
struct MHD_Daemon *server_v6_tmp = plugin->server_v6;
+
plugin->server_v6 = NULL;
if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK)
diff --git a/src/transport/plugin_transport_sat_constants.h b/src/transport/plugin_transport_sat_constants.h
index a9ee9227c..bd64c5d2b 100644
--- a/src/transport/plugin_transport_sat_constants.h
+++ b/src/transport/plugin_transport_sat_constants.h
@@ -32,22 +32,26 @@
typedef struct MacAdress
{
- uint8_t mac[6];
-}MacAdress;
+ uint8_t mac[6];
+} MacAdress;
//praeamble
-static const struct char praeambel[56] =
-{{1,0,1,0,10,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}};
+static const struct char praeambel[56] =
+ { {1, 0, 1, 0, 10, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
+ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
+ 0, 1, 0, 1, 0, 1, 0}
+};
//start of frame
-static const struct char sof[8]=
-{{1,0,1,0,1,0,1,1}}
+static const struct char sof[8] = { {1, 0, 1, 0, 1, 0, 1, 1} }
// broadcast mac
static const struct MacAddress bc_all_mac =
- { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
+ { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} };
//crc polynom
static const struct char ploynom[32] =
- {{1,1,1,0,1,1,0,1,1,0,1,1,1,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1}};
+ { {1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1,
+ 0, 0, 1, 0, 0, 0, 0, 1}
+};
#endif
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 04ba348b3..9c6535988 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -696,10 +696,9 @@ do_transmit (void *cls, size_t size, void *buf)
GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
session->pending_messages_tail, pos);
GNUNET_assert (size >= pos->message_size);
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "tcp",
- "Transmitting message of type %u\n",
- ntohs (((struct GNUNET_MessageHeader*)pos->msg)->type));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
+ "Transmitting message of type %u\n",
+ ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type));
/* FIXME: this memcpy can be up to 7% of our total runtime */
memcpy (cbuf, pos->msg, pos->message_size);
cbuf += pos->message_size;
@@ -1002,7 +1001,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
{
if (addrlen == sizeof (struct IPv6TcpAddress))
{
- GNUNET_assert (NULL != addr); /* make static analysis happy */
+ GNUNET_assert (NULL != addr); /* make static analysis happy */
t6 = addr;
af = AF_INET6;
memset (&a6, 0, sizeof (a6));
@@ -1019,7 +1018,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
}
else if (addrlen == sizeof (struct IPv4TcpAddress))
{
- GNUNET_assert (NULL != addr); /* make static analysis happy */
+ GNUNET_assert (NULL != addr); /* make static analysis happy */
t4 = addr;
af = AF_INET;
memset (&a4, 0, sizeof (a4));
@@ -1073,7 +1072,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
/* append pm to pending_messages list */
GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
- session->pending_messages_tail, pm);
+ session->pending_messages_tail, pm);
GNUNET_assert (GNUNET_CONTAINER_multihashmap_put
(plugin->nat_wait_conns, &target->hashPubKey, session,
@@ -1129,16 +1128,14 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
/* check if session is valid */
struct Session *ses = plugin->sessions;
- if (0 != memcmp (target,
- &session->target,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 !=
+ memcmp (target, &session->target, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Got session %p for `%s', but should be for peer `%s'!\n",
- session,
- GNUNET_i2s (&session->target),
- GNUNET_h2s (&target->hashPubKey));
+ "Got session %p for `%s', but should be for peer `%s'!\n",
+ session, GNUNET_i2s (&session->target),
+ GNUNET_h2s (&target->hashPubKey));
return -1;
}
@@ -1170,7 +1167,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
/* append pm to pending_messages list */
GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
- session->pending_messages_tail, pm);
+ session->pending_messages_tail, pm);
#if DEBUG_TCP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
"Asked to transmit %u bytes to `%s', added message to list.\n",
@@ -1741,8 +1738,8 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
distance.value = htonl (1);
delay =
plugin->env->receive (plugin->env->cls, &session->target, message,
- (const struct GNUNET_ATS_Information *)
- &distance, 1, session,
+ (const struct GNUNET_ATS_Information *) &distance,
+ 1, session,
(GNUNET_YES ==
session->inbound) ? NULL : session->connect_addr,
(GNUNET_YES ==
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index cf6e01306..667af25be 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -120,12 +120,12 @@ struct UDP_Beacon_Message
/**
* Message header.
*/
- struct GNUNET_MessageHeader header;
+ struct GNUNET_MessageHeader header;
/**
* What is the identity of the sender
*/
- struct GNUNET_PeerIdentity sender;
+ struct GNUNET_PeerIdentity sender;
};
@@ -396,8 +396,8 @@ struct Plugin
struct PeerSessionIteratorContext
{
- struct Session * result;
- const void * addr;
+ struct Session *result;
+ const void *addr;
size_t addrlen;
};
@@ -417,13 +417,12 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer)
}
-static int
-inbound_session_iterator (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+inbound_session_iterator (void *cls, const GNUNET_HashCode * key, void *value)
{
struct PeerSessionIteratorContext *psc = cls;
struct Session *s = value;
+
if (s->addrlen == psc->addrlen)
{
if (0 == memcmp (&s[1], psc->addr, s->addrlen))
@@ -444,26 +443,29 @@ inbound_session_iterator (void *cls,
*/
static struct Session *
find_inbound_session (struct Plugin *plugin,
- const struct GNUNET_PeerIdentity *peer,
- const void * addr, size_t addrlen)
+ const struct GNUNET_PeerIdentity *peer, const void *addr,
+ size_t addrlen)
{
struct PeerSessionIteratorContext psc;
+
psc.result = NULL;
psc.addrlen = addrlen;
psc.addr = addr;
- GNUNET_CONTAINER_multihashmap_get_multiple(plugin->inbound_sessions, &peer->hashPubKey, &inbound_session_iterator, &psc);
+ GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions,
+ &peer->hashPubKey,
+ &inbound_session_iterator, &psc);
return psc.result;
}
-static int
-inbound_session_by_addr_iterator (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+inbound_session_by_addr_iterator (void *cls, const GNUNET_HashCode * key,
+ void *value)
{
struct PeerSessionIteratorContext *psc = cls;
struct Session *s = value;
+
if (s->addrlen == psc->addrlen)
{
if (0 == memcmp (&s[1], psc->addr, s->addrlen))
@@ -484,14 +486,18 @@ inbound_session_by_addr_iterator (void *cls,
* @return NULL if we have no session
*/
static struct Session *
-find_inbound_session_by_addr (struct Plugin *plugin, const void * addr, size_t addrlen)
+find_inbound_session_by_addr (struct Plugin *plugin, const void *addr,
+ size_t addrlen)
{
struct PeerSessionIteratorContext psc;
+
psc.result = NULL;
psc.addrlen = addrlen;
psc.addr = addr;
- GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &inbound_session_by_addr_iterator, &psc);
+ GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions,
+ &inbound_session_by_addr_iterator,
+ &psc);
return psc.result;
}
@@ -531,7 +537,7 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value)
struct Session *s = value;
if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(s->invalidation_task);
+ GNUNET_SCHEDULER_cancel (s->invalidation_task);
if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task)
GNUNET_SCHEDULER_cancel (s->delayed_cont_task);
GNUNET_free (s);
@@ -560,11 +566,10 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
session));
GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions,
- &target->hashPubKey,
- &destroy_inbound_session, NULL);
+ &target->hashPubKey,
+ &destroy_inbound_session, NULL);
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "UDP DISCONNECT\n");
+ LOG (GNUNET_ERROR_TYPE_ERROR, "UDP DISCONNECT\n");
plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag);
if (GNUNET_SCHEDULER_NO_TASK != session->delayed_cont_task)
@@ -614,15 +619,15 @@ udp_send (struct Plugin *plugin, const struct sockaddr *sa,
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
LOG (GNUNET_ERROR_TYPE_ERROR,
- "UDP transmited %u-byte message to %s (%d: %s)\n",
- (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen),
- (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
+ "UDP transmited %u-byte message to %s (%d: %s)\n",
+ (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent,
+ (sent < 0) ? STRERROR (errno) : "ok");
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP transmited %u-byte message to %s (%d: %s)\n",
- (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen),
- (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
+ "UDP transmited %u-byte message to %s (%d: %s)\n",
+ (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent,
+ (sent < 0) ? STRERROR (errno) : "ok");
return sent;
}
@@ -648,10 +653,10 @@ send_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
static struct Session *
create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
- const void *addr, size_t addrlen,
- GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
+ const void *addr, size_t addrlen,
+ GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
- struct Session * peer_session;
+ struct Session *peer_session;
const struct IPv4UdpAddress *t4;
const struct IPv6UdpAddress *t6;
struct sockaddr_in *v4;
@@ -667,8 +672,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
}
t4 = addr;
peer_session =
- GNUNET_malloc (sizeof (struct Session) +
- sizeof (struct sockaddr_in));
+ GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in));
len = sizeof (struct sockaddr_in);
v4 = (struct sockaddr_in *) &peer_session[1];
v4->sin_family = AF_INET;
@@ -685,8 +689,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
}
t6 = addr;
peer_session =
- GNUNET_malloc (sizeof (struct Session) +
- sizeof (struct sockaddr_in6));
+ GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6));
len = sizeof (struct sockaddr_in6);
v6 = (struct sockaddr_in6 *) &peer_session[1];
v6->sin6_family = AF_INET6;
@@ -719,8 +722,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen);
static void
-udp_call_continuation (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+udp_call_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Session *s = cls;
GNUNET_TRANSPORT_TransmitContinuation cont = s->cont;
@@ -779,10 +781,10 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n",
- msgbuf_size, GNUNET_i2s (target),
- udp_address_to_string (NULL, addr, addrlen),
- session, force_address);
+ "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n",
+ msgbuf_size, GNUNET_i2s (target), udp_address_to_string (NULL, addr,
+ addrlen),
+ session, force_address);
if ((force_address == GNUNET_SYSERR) && (session == NULL))
return GNUNET_SYSERR;
@@ -792,10 +794,11 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
if ((session != NULL) && (addr != NULL) && (addrlen != 0))
{
s = session;
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value (
- plugin->inbound_sessions, &target->hashPubKey, s));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_contains_value
+ (plugin->inbound_sessions, &target->hashPubKey, s));
- if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity)))
return GNUNET_SYSERR;
switch (addrlen)
{
@@ -810,10 +813,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
if (s->addrlen != (sizeof (struct sockaddr_in)))
return GNUNET_SYSERR;
struct sockaddr_in *a4 = (struct sockaddr_in *) s->sock_addr;
+
GNUNET_assert (a4->sin_port == t4->u4_port);
- GNUNET_assert (0 == memcmp(&a4->sin_addr, &t4->ipv4_addr, sizeof (struct in_addr)));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session 0x%X successfully checked!\n", session);
+ GNUNET_assert (0 ==
+ memcmp (&a4->sin_addr, &t4->ipv4_addr,
+ sizeof (struct in_addr)));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n",
+ session);
break;
case sizeof (struct IPv6UdpAddress):
if (NULL == plugin->sockv6)
@@ -825,10 +831,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
t6 = addr;
GNUNET_assert (s->addrlen == sizeof (struct sockaddr_in6));
struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) s->sock_addr;
+
GNUNET_assert (a6->sin6_port == t6->u6_port);
- GNUNET_assert (0 == memcmp(&a6->sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr)));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session 0x%X successfully checked!\n", session);
+ GNUNET_assert (0 ==
+ memcmp (&a6->sin6_addr, &t6->ipv6_addr,
+ sizeof (struct in6_addr)));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n",
+ session);
break;
default:
/* Must have a valid address to send to */
@@ -854,7 +863,7 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
udp->sender = *plugin->env->my_identity;
memcpy (&udp[1], msgbuf, msgbuf_size);
- if (s != NULL)
+ if (s != NULL)
delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer);
else
delta = GNUNET_TIME_UNIT_ZERO;
@@ -863,17 +872,15 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
mlen = udp_send (plugin, peer_session->sock_addr, &udp->header);
if (cont != NULL)
{
- if ( (delta.rel_value > 0) &&
- (mlen > 0) )
+ if ((delta.rel_value > 0) && (mlen > 0))
{
- s->cont = cont;
- s->cont_cls = cont_cls;
- s->delayed_cont_task = GNUNET_SCHEDULER_add_delayed (delta,
- &udp_call_continuation,
- s);
+ s->cont = cont;
+ s->cont_cls = cont_cls;
+ s->delayed_cont_task =
+ GNUNET_SCHEDULER_add_delayed (delta, &udp_call_continuation, s);
}
else
- cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR);
+ cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR);
}
GNUNET_free_non_null (peer_session);
}
@@ -915,7 +922,7 @@ struct SourceInformation
*/
size_t args;
- struct Session * session;
+ struct Session *session;
};
@@ -940,23 +947,29 @@ process_inbound_tokenized_messages (void *cls, void *client,
distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
distance.value = htonl (1);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Giving Session %X %s to transport\n", si->session, GNUNET_i2s(&si->session->target));
- delay = plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, si->session,
- si->arg, si->args);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n",
+ si->session, GNUNET_i2s (&si->session->target));
+ delay =
+ plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1,
+ si->session, si->arg, si->args);
si->session->flow_delay_for_other_peer = delay;
}
static void
invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct Session * s = cls;
- s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Session %X (`%s') is now invalid\n", s, GNUNET_a2s (s->sock_addr,s->addrlen));
+ struct Session *s = cls;
- s->plugin->env->session_end(s->plugin->env->cls, &s->target, s);
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(s->plugin->inbound_sessions, &s->target.hashPubKey, s));
+ s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Session %X (`%s') is now invalid\n", s,
+ GNUNET_a2s (s->sock_addr, s->addrlen));
+
+ s->plugin->env->session_end (s->plugin->env->cls, &s->target, s);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (s->
+ plugin->inbound_sessions,
+ &s->target.hashPubKey,
+ s));
GNUNET_free (s);
}
@@ -1015,54 +1028,54 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg,
}
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received message with %u bytes from peer `%s' at `%s'\n",
- (unsigned int) ntohs (msg->header.size),
- GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr,
- sender_addr_len));
+ "Received message with %u bytes from peer `%s' at `%s'\n",
+ (unsigned int) ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
+ GNUNET_a2s (sender_addr, sender_addr_len));
#endif
/* create a session for inbound connections */
- const struct UDPMessage * udp_msg = (const struct UDPMessage *) msg;
+ const struct UDPMessage *udp_msg = (const struct UDPMessage *) msg;
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Lookup inbound UDP sessions for peer `%s' address `%s'\n",
- GNUNET_i2s (&udp_msg->sender),
- udp_address_to_string(NULL, arg, args));
+ "Lookup inbound UDP sessions for peer `%s' address `%s'\n",
+ GNUNET_i2s (&udp_msg->sender), udp_address_to_string (NULL, arg, args));
- struct Session * s = NULL;
- s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, sender_addr_len);
+ struct Session *s = NULL;
+
+ s = find_inbound_session (plugin, &udp_msg->sender, sender_addr,
+ sender_addr_len);
if (s != NULL)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
- s,
- GNUNET_i2s (&s->target),
- udp_address_to_string(NULL, arg, args));
+ "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
+ s, GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args));
}
else
{
s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
- s,
- GNUNET_i2s (&s->target),
- udp_address_to_string(NULL, arg, args));
-
- GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions,
- &s->target.hashPubKey,
- s,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", s,
+ GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args));
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions,
+ &s->target.hashPubKey, s,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
}
- s->valid_until = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ s->valid_until =
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(s->invalidation_task);
+ GNUNET_SCHEDULER_cancel (s->invalidation_task);
s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Rescheduling %X' `%s'\n",
- s, udp_address_to_string(NULL, arg, args));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling %X' `%s'\n", s,
+ udp_address_to_string (NULL, arg, args));
}
- s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, s);
+ s->invalidation_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &invalidation_task, s);
/* iterate over all embedded messages */
si.sender = msg->sender;
si.arg = arg;
@@ -1118,6 +1131,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
uint32_t delay = 0;
struct Session *s;
+
s = find_inbound_session_by_addr (rc->plugin, rc->src_addr, rc->addr_len);
if (s != NULL)
{
@@ -1129,12 +1143,13 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
#if DEBUG_UDP
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ACK to `%s' including delay of %u ms\n",
- GNUNET_a2s (rc->src_addr,
- (rc->src_addr->sa_family ==
- AF_INET) ? sizeof (struct sockaddr_in) :
- sizeof (struct sockaddr_in6)),
- delay);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending ACK to `%s' including delay of %u ms\n",
+ GNUNET_a2s (rc->src_addr,
+ (rc->src_addr->sa_family ==
+ AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct
+ sockaddr_in6)),
+ delay);
#endif
udp_ack = (struct UDP_ACK_Message *) buf;
udp_ack->header.size = htons ((uint16_t) msize);
@@ -1166,7 +1181,7 @@ struct FindReceiveContext
*/
socklen_t addr_len;
- struct Session * session;
+ struct Session *session;
};
@@ -1217,7 +1232,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
struct ReceiveContext *rc;
struct GNUNET_TIME_Absolute now;
struct FindReceiveContext frc;
- struct Session * s = NULL;
+ struct Session *s = NULL;
struct GNUNET_TIME_Relative flow_delay;
fromlen = sizeof (addr);
@@ -1233,8 +1248,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
msg = (const struct GNUNET_MessageHeader *) buf;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret,
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs(msg->type));
+ "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret,
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type));
if (ret != ntohs (msg->size))
{
@@ -1261,27 +1276,29 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
return;
}
udp_ack = (const struct UDP_ACK_Message *) msg;
- s = find_inbound_session(plugin, &udp_ack->sender, addr, fromlen);
+ s = find_inbound_session (plugin, &udp_ack->sender, addr, fromlen);
if (s != NULL)
{
- flow_delay.rel_value = (uint64_t) ntohl(udp_ack->delay);
+ flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "We received a sending delay of %llu\n", flow_delay.rel_value);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n",
+ flow_delay.rel_value);
- s->flow_delay_from_other_peer = GNUNET_TIME_relative_to_absolute (flow_delay);
+ s->flow_delay_from_other_peer =
+ GNUNET_TIME_relative_to_absolute (flow_delay);
}
ack = (const struct GNUNET_MessageHeader *) &udp_ack[1];
- if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message))
+ if (ntohs (ack->size) !=
+ ntohs (msg->size) - sizeof (struct UDP_ACK_Message))
{
GNUNET_break_op (0);
return;
}
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
- (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender),
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
+ "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
+ (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender),
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
#endif
peer_session = find_session (plugin, &udp_ack->sender);
@@ -1289,7 +1306,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
{
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session for ACK not found, dropping ACK!\n");
+ "Session for ACK not found, dropping ACK!\n");
#endif
return;
}
@@ -1332,10 +1349,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
now.abs_value);
}
#if DEBUG_UDP
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP processes %u-byte fragment from `%s'\n",
- (unsigned int) ntohs (msg->size),
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n",
+ (unsigned int) ntohs (msg->size),
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
#endif
if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg))
@@ -1395,40 +1411,43 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct MstContext
{
- struct Plugin * plugin;
+ struct Plugin *plugin;
struct IPv4UdpAddress addr;
};
-void udp_broadcast_mst_cb (void *cls, void *client,
- const struct
- GNUNET_MessageHeader *
- message)
+void
+udp_broadcast_mst_cb (void *cls, void *client,
+ const struct GNUNET_MessageHeader *message)
{
- struct Plugin * plugin = cls;
- struct MstContext * mc = client;
- const struct GNUNET_MessageHeader* hello;
- struct UDP_Beacon_Message * msg;
+ struct Plugin *plugin = cls;
+ struct MstContext *mc = client;
+ const struct GNUNET_MessageHeader *hello;
+ struct UDP_Beacon_Message *msg;
+
msg = (struct UDP_Beacon_Message *) message;
- if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != ntohs(msg->header.type))
+ if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON !=
+ ntohs (msg->header.type))
return;
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Received beacon with %u bytes from peer `%s' via address `%s'\n",
- ntohs(msg->header.size),
- GNUNET_i2s (&msg->sender),
- udp_address_to_string(NULL, &mc->addr, sizeof (mc->addr)));
+ "Received beacon with %u bytes from peer `%s' via address `%s'\n",
+ ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
+ udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr)));
struct GNUNET_ATS_Information ats;
+
ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
ats.value = htonl (1);
hello = (struct GNUNET_MessageHeader *) &msg[1];
- plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL, (const char *) &mc->addr, sizeof (mc->addr));
+ plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL,
+ (const char *) &mc->addr, sizeof (mc->addr));
- GNUNET_STATISTICS_update(plugin->env->stats,
- _("# HELLO beacons received via udp"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# HELLO beacons received via udp"), 1,
+ GNUNET_NO);
GNUNET_free (mc);
}
@@ -1445,54 +1464,61 @@ udp_broadcast_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
char addr[32];
char buf[65536];
ssize_t ret;
- struct MstContext * mc;
+ struct MstContext *mc;
fromlen = sizeof (addr);
memset (&addr, 0, sizeof (addr));
- ret = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), (struct sockaddr *) &addr, &fromlen);
+ ret =
+ GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf),
+ (struct sockaddr *) &addr, &fromlen);
if (ret < sizeof (struct GNUNET_MessageHeader))
{
/* malformed beacon, just throw it away */
return;
}
- mc = GNUNET_malloc(sizeof (struct MstContext));
+ mc = GNUNET_malloc (sizeof (struct MstContext));
+
+ struct sockaddr_in *av4 = (struct sockaddr_in *) &addr;
- struct sockaddr_in * av4 = (struct sockaddr_in *) &addr;
mc->addr.ipv4_addr = av4->sin_addr.s_addr;
mc->addr.u4_port = av4->sin_port;
- if (GNUNET_OK != GNUNET_SERVER_mst_receive(plugin->broadcast_mst, mc, buf, ret, GNUNET_NO, GNUNET_NO))
+ if (GNUNET_OK !=
+ GNUNET_SERVER_mst_receive (plugin->broadcast_mst, mc, buf, ret, GNUNET_NO,
+ GNUNET_NO))
GNUNET_free (mc);
}
static void
-udp_broadcast_send (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+udp_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct Plugin * plugin = cls;
+ struct Plugin *plugin = cls;
int sent;
uint16_t msg_size;
uint16_t hello_size;
char buf[65536];
+
// /ssize_t ret;
const struct GNUNET_MessageHeader *hello;
- struct UDP_Beacon_Message * msg;
+ struct UDP_Beacon_Message *msg;
plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
struct sockaddr_in baddr;
+
baddr.sin_family = AF_INET;
baddr.sin_port = htons (plugin->broadcast_port);
- baddr.sin_addr.s_addr=htonl(-1); /* send message to 255.255.255.255 */
+ baddr.sin_addr.s_addr = htonl (-1); /* send message to 255.255.255.255 */
hello = plugin->env->get_our_hello ();
hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
msg_size = hello_size + sizeof (struct UDP_Beacon_Message);
- if (hello_size < (sizeof (struct GNUNET_MessageHeader)) ||(msg_size > (UDP_MTU)))
+ if (hello_size < (sizeof (struct GNUNET_MessageHeader)) ||
+ (msg_size > (UDP_MTU)))
return;
msg = (struct UDP_Beacon_Message *) buf;
@@ -1501,13 +1527,17 @@ udp_broadcast_send (void *cls,
msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON);
memcpy (&msg[1], hello, hello_size);
- sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size,
- (const struct sockaddr *) &baddr, sizeof (struct sockaddr_in));
+ sent =
+ GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size,
+ (const struct sockaddr *) &baddr,
+ sizeof (struct sockaddr_in));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sent HELLO beacon broadcast with %i bytes\n", sent);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes\n",
+ sent);
- plugin->send_broadcast_task = GNUNET_SCHEDULER_add_delayed(plugin->broadcast_interval, &udp_broadcast_send, plugin);
+ plugin->send_broadcast_task =
+ GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval,
+ &udp_broadcast_send, plugin);
}
@@ -1520,7 +1550,8 @@ udp_broadcast_send (void *cls,
* @param tc the scheduling context (for rescheduling this function again)
*/
static void
-udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+udp_plugin_broadcast_select (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
@@ -1535,8 +1566,9 @@ udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContex
plugin->select_broadcast_task =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs,
- NULL, &udp_plugin_broadcast_select, plugin);
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ plugin->broadcast_rs, NULL,
+ &udp_plugin_broadcast_select, plugin);
}
@@ -1664,7 +1696,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen)
}
inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u",
- buf, port);
+ buf, port);
return rbuf;
}
@@ -1868,16 +1900,20 @@ libgnunet_plugin_transport_udp_init (void *cls)
&port))
port = 2086;
- broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", "BROADCAST");
- if (broadcast == GNUNET_SYSERR)
- broadcast = GNUNET_NO;
+ broadcast =
+ GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp",
+ "BROADCAST");
+ if (broadcast == GNUNET_SYSERR)
+ broadcast = GNUNET_NO;
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp", "BROADCAST_INTERVAL", &interval))
- interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10);
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp",
+ "BROADCAST_INTERVAL", &interval))
+ interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "BROADCAST_PORT",
- &bport))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp",
+ "BROADCAST_PORT", &bport))
bport = 20086;
if (GNUNET_OK !=
@@ -1891,8 +1927,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
if (port > 65535)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Given `%s' option is out of range: %llu > %u\n"), "PORT",
- port, 65535);
+ _("Given `%s' option is out of range: %llu > %u\n"), "PORT", port,
+ 65535);
return NULL;
}
memset (&serverAddrv6, 0, sizeof (serverAddrv6));
@@ -1923,8 +1959,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
"BINDTO", &plugin->bind4_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Binding udp plugin to specific address: `%s'\n",
- plugin->bind4_address);
+ "Binding udp plugin to specific address: `%s'\n",
+ plugin->bind4_address);
if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr))
{
GNUNET_free (plugin->bind4_address);
@@ -1939,13 +1975,13 @@ libgnunet_plugin_transport_udp_init (void *cls)
"BINDTO6", &plugin->bind6_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Binding udp plugin to specific address: `%s'\n",
- plugin->bind6_address);
+ "Binding udp plugin to specific address: `%s'\n",
+ plugin->bind6_address);
if (1 !=
inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr))
{
LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"),
- plugin->bind6_address);
+ plugin->bind6_address);
GNUNET_free_non_null (plugin->bind4_address);
GNUNET_free (plugin->bind6_address);
GNUNET_free (plugin);
@@ -1984,7 +2020,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddr = (struct sockaddr *) &serverAddrv6;
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n",
- ntohs (serverAddrv6.sin6_port));
+ ntohs (serverAddrv6.sin6_port));
#endif
tries = 0;
while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) !=
@@ -1993,8 +2029,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "IPv6 Binding failed, trying new port %d\n",
- ntohs (serverAddrv6.sin6_port));
+ "IPv6 Binding failed, trying new port %d\n",
+ ntohs (serverAddrv6.sin6_port));
#endif
tries++;
if (tries > 10)
@@ -2032,7 +2068,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddr = (struct sockaddr *) &serverAddrv4;
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n",
- ntohs (serverAddrv4.sin_port));
+ ntohs (serverAddrv4.sin_port));
#endif
tries = 0;
while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) !=
@@ -2040,9 +2076,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
{
serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "IPv4 Binding failed, trying new port %d\n",
- ntohs (serverAddrv4.sin_port));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Binding failed, trying new port %d\n",
+ ntohs (serverAddrv4.sin_port));
#endif
tries++;
if (tries > 10)
@@ -2077,47 +2112,56 @@ libgnunet_plugin_transport_udp_init (void *cls)
/* create broadcast socket */
if (broadcast)
{
- plugin->sockv4_broadcast = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0);
+ plugin->sockv4_broadcast =
+ GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0);
if (NULL == plugin->sockv4_broadcast)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket");
}
else
{
- #if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_IN_SIN_LEN
serverAddrv4.sin_len = sizeof (serverAddrv4);
- #endif
+#endif
serverAddrv4.sin_family = AF_INET;
serverAddrv4.sin_addr.s_addr = INADDR_ANY;
serverAddrv4.sin_port = htons (plugin->broadcast_port);
addrlen = sizeof (serverAddrv4);
serverAddr = (struct sockaddr *) &serverAddrv4;
- #if DEBUG_UDP
- #endif
+#if DEBUG_UDP
+#endif
LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding Broadcast to IPv4 port %d\n",
- ntohs (serverAddrv4.sin_port));
+ ntohs (serverAddrv4.sin_port));
- if (GNUNET_NETWORK_socket_bind (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK)
+ if (GNUNET_NETWORK_socket_bind
+ (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK)
{
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to create IPv4 broadcast socket on port %d\n"),
- ntohs (serverAddrv4.sin_port));
- GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast);
- plugin->sockv4_broadcast = NULL;
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to create IPv4 broadcast socket on port %d\n"),
+ ntohs (serverAddrv4.sin_port));
+ GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast);
+ plugin->sockv4_broadcast = NULL;
}
if (plugin->sockv4_broadcast != NULL)
{
int yes = 1;
- if (GNUNET_NETWORK_socket_setsockopt (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(int)) != GNUNET_OK)
+
+ if (GNUNET_NETWORK_socket_setsockopt
+ (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes,
+ sizeof (int)) != GNUNET_OK)
{
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"),
- ntohs (serverAddrv4.sin_port));
- GNUNET_NETWORK_socket_close(plugin->sockv4_broadcast);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _
+ ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"),
+ ntohs (serverAddrv4.sin_port));
+ GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast);
plugin->sockv4_broadcast = NULL;
}
else
{
plugin->broadcast_rs = GNUNET_NETWORK_fdset_create ();
- GNUNET_NETWORK_fdset_set (plugin->broadcast_rs, plugin->sockv4_broadcast);
+ GNUNET_NETWORK_fdset_set (plugin->broadcast_rs,
+ plugin->sockv4_broadcast);
}
}
}
@@ -2125,16 +2169,20 @@ libgnunet_plugin_transport_udp_init (void *cls)
if (plugin->sockv4_broadcast != NULL)
{
plugin->broadcast = GNUNET_YES;
- plugin->broadcast_mst = GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin);
- GNUNET_STATISTICS_update(plugin->env->stats,
- _("# HELLO beacons received via udp"), 1, GNUNET_NO);
+ plugin->broadcast_mst =
+ GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# HELLO beacons received via udp"), 1,
+ GNUNET_NO);
plugin->select_broadcast_task =
- GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs,
- NULL, &udp_plugin_broadcast_select, plugin);
-
- plugin->send_broadcast_task = GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin);
+ GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ plugin->broadcast_rs, NULL,
+ &udp_plugin_broadcast_select, plugin);
+
+ plugin->send_broadcast_task =
+ GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin);
}
else
plugin->broadcast = GNUNET_NO;
@@ -2167,8 +2215,8 @@ libgnunet_plugin_transport_udp_done (void *cls)
NULL);
GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions);
plugin->sessions = NULL;
- GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &destroy_inbound_session,
- NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions,
+ &destroy_inbound_session, NULL);
GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions);
plugin->inbound_sessions = NULL;
while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags)))
@@ -2201,16 +2249,17 @@ libgnunet_plugin_transport_udp_done (void *cls)
GNUNET_SCHEDULER_cancel (plugin->select_broadcast_task);
plugin->select_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
}
- if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
+ if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task );
- plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task);
+ plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
}
if (plugin->broadcast_mst != NULL)
- GNUNET_SERVER_mst_destroy(plugin->broadcast_mst);
+ GNUNET_SERVER_mst_destroy (plugin->broadcast_mst);
if (plugin->sockv4_broadcast != NULL)
{
- GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast));
plugin->sockv4_broadcast = NULL;
}
GNUNET_NETWORK_fdset_destroy (plugin->broadcast_rs);
diff --git a/src/transport/plugin_transport_udp_new.c b/src/transport/plugin_transport_udp_new.c
index 325c5d893..7eb4cbe87 100644
--- a/src/transport/plugin_transport_udp_new.c
+++ b/src/transport/plugin_transport_udp_new.c
@@ -299,21 +299,22 @@ struct Plugin
};
-int delete_session_iterator (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+int
+delete_session_iterator (void *cls, const GNUNET_HashCode * key, void *value)
{
struct Session *s = (struct Session *) value;
+
if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(s->invalidation_task);
+ GNUNET_SCHEDULER_cancel (s->invalidation_task);
s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_CONTAINER_multihashmap_remove(s->plugin->sessions, key, s);
+ GNUNET_CONTAINER_multihashmap_remove (s->plugin->sessions, key, s);
GNUNET_free (s);
return GNUNET_YES;
}
+
/**
* Disconnect from a remote node. Clean up session if we have one for this peer
*
@@ -326,7 +327,8 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
- GNUNET_CONTAINER_multihashmap_get_multiple(plugin, &target->hashPubKey, &delete_session_iterator, NULL);
+ GNUNET_CONTAINER_multihashmap_get_multiple (plugin, &target->hashPubKey,
+ &delete_session_iterator, NULL);
}
@@ -370,25 +372,25 @@ udp_send (struct Plugin *plugin, const struct sockaddr *sa,
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
LOG (GNUNET_ERROR_TYPE_ERROR,
- "UDP transmited %u-byte message to %s (%d: %s)\n",
- (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen),
- (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
+ "UDP transmited %u-byte message to %s (%d: %s)\n",
+ (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent,
+ (sent < 0) ? STRERROR (errno) : "ok");
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP transmited %u-byte message to %s (%d: %s)\n",
- (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen),
- (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
+ "UDP transmited %u-byte message to %s (%d: %s)\n",
+ (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent,
+ (sent < 0) ? STRERROR (errno) : "ok");
return sent;
}
static struct Session *
create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
- const void *addr, size_t addrlen,
- GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
+ const void *addr, size_t addrlen,
+ GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
- struct Session * s;
+ struct Session *s;
const struct IPv4UdpAddress *t4;
const struct IPv6UdpAddress *t6;
struct sockaddr_in *v4;
@@ -403,9 +405,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
return NULL;
}
t4 = addr;
- s =
- GNUNET_malloc (sizeof (struct Session) +
- sizeof (struct sockaddr_in));
+ s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in));
len = sizeof (struct sockaddr_in);
v4 = (struct sockaddr_in *) &s[1];
v4->sin_family = AF_INET;
@@ -421,9 +421,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
return NULL;
}
t6 = addr;
- s =
- GNUNET_malloc (sizeof (struct Session) +
- sizeof (struct sockaddr_in6));
+ s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6));
len = sizeof (struct sockaddr_in6);
v6 = (struct sockaddr_in6 *) &s[1];
v6->sin6_family = AF_INET6;
@@ -457,13 +455,17 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
static void
invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct Session * s = cls;
- s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Session %X (`%s') is now invalid\n", s, GNUNET_a2s (s->sock_addr,s->addrlen));
+ struct Session *s = cls;
- s->plugin->env->session_end(s->plugin->env->cls, &s->target, s);
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(s->plugin->sessions, &s->target.hashPubKey, s));
+ s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Session %X (`%s') is now invalid\n", s,
+ GNUNET_a2s (s->sock_addr, s->addrlen));
+
+ s->plugin->env->session_end (s->plugin->env->cls, &s->target, s);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (s->plugin->sessions,
+ &s->target.hashPubKey,
+ s));
GNUNET_free (s);
}
@@ -534,10 +536,10 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n",
- msgbuf_size, GNUNET_i2s (target),
- udp_address_to_string (NULL, addr, addrlen),
- session, force_address);
+ "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n",
+ msgbuf_size, GNUNET_i2s (target), udp_address_to_string (NULL, addr,
+ addrlen),
+ session, force_address);
/* no valid address given */
if ((addr = NULL) || (addrlen == 0))
@@ -562,10 +564,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
if (force_address == GNUNET_SYSERR)
return GNUNET_SYSERR;
/* create new session */
- s = create_session(plugin, target, addr, addrlen, cont, cont_cls);
- GNUNET_CONTAINER_multihashmap_put(plugin->sessions, &target->hashPubKey, s, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ s = create_session (plugin, target, addr, addrlen, cont, cont_cls);
+ GNUNET_CONTAINER_multihashmap_put (plugin->sessions, &target->hashPubKey, s,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* schedule invalidation task */
- s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, NULL);
+ s->invalidation_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &invalidation_task, NULL);
}
/* Message */
@@ -576,12 +581,16 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
udp->sender = *plugin->env->my_identity;
memcpy (&udp[1], msgbuf, msgbuf_size);
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+
if (s->flow_delay_from_other_peer.abs_value > now.abs_value)
{
- struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(now, s->flow_delay_from_other_peer);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "We try to send to early! Should in %llu!\n", delta.rel_value);
+ struct GNUNET_TIME_Relative delta =
+ GNUNET_TIME_absolute_get_difference (now,
+ s->flow_delay_from_other_peer);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "We try to send to early! Should in %llu!\n",
+ delta.rel_value);
}
else
LOG (GNUNET_ERROR_TYPE_DEBUG, "We can send!\n");
@@ -598,11 +607,11 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
/* send with fragmentation */
else
{
- s->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU,
+ s->frag =
+ GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU,
&plugin->tracker,
plugin->last_expected_delay,
- &udp->header, &send_fragment,
- s);
+ &udp->header, &send_fragment, s);
}
return mlen;
}
@@ -621,7 +630,7 @@ process_inbound_tokenized_messages (void *cls, void *client,
const struct GNUNET_MessageHeader *hdr)
{
struct Plugin *plugin = cls;
- struct Session * s = client;
+ struct Session *s = client;
struct GNUNET_ATS_Information distance;
struct GNUNET_TIME_Relative delay;
@@ -629,11 +638,12 @@ process_inbound_tokenized_messages (void *cls, void *client,
distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
distance.value = htonl (1);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Giving Session %X %s to transport\n", s->session, GNUNET_i2s(&s->target));
- delay = plugin->env->receive (plugin->env->cls, &s->target, hdr, &distance, 1, s,
- // FIXME: USE UDP ADDRESSES!!!!
- s->sock_addr, s->addrlen);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n",
+ s->session, GNUNET_i2s (&s->target));
+ delay =
+ plugin->env->receive (plugin->env->cls, &s->target, hdr, &distance, 1, s,
+ // FIXME: USE UDP ADDRESSES!!!!
+ s->sock_addr, s->addrlen);
s->flow_delay_for_other_peer = delay;
}
@@ -691,54 +701,54 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg,
}
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received message with %u bytes from peer `%s' at `%s'\n",
- (unsigned int) ntohs (msg->header.size),
- GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr,
- sender_addr_len));
+ "Received message with %u bytes from peer `%s' at `%s'\n",
+ (unsigned int) ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
+ GNUNET_a2s (sender_addr, sender_addr_len));
#endif
- const struct UDPMessage * udp_msg = (const struct UDPMessage *) msg;
+ const struct UDPMessage *udp_msg = (const struct UDPMessage *) msg;
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Lookup inbound UDP sessions for peer `%s' address `%s'\n",
- GNUNET_i2s (&udp_msg->sender),
- udp_address_to_string(NULL, arg, args));
+ "Lookup inbound UDP sessions for peer `%s' address `%s'\n",
+ GNUNET_i2s (&udp_msg->sender), udp_address_to_string (NULL, arg, args));
/* create a session for inbound connections */
- struct Session * s = NULL;
- s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, sender_addr_len);
+ struct Session *s = NULL;
+
+ s = find_inbound_session (plugin, &udp_msg->sender, sender_addr,
+ sender_addr_len);
if (s != NULL)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
- s,
- GNUNET_i2s (&s->target),
- udp_address_to_string(NULL, arg, args));
+ "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
+ s, GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args));
}
else
{
s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n",
- s,
- GNUNET_i2s (&s->target),
- udp_address_to_string(NULL, arg, args));
-
- GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->sessions,
- &s->target.hashPubKey,
- s,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", s,
+ GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args));
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multihashmap_put (plugin->sessions,
+ &s->target.hashPubKey, s,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
}
- s->valid_until = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ s->valid_until =
+ GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(s->invalidation_task);
+ GNUNET_SCHEDULER_cancel (s->invalidation_task);
s->invalidation_task = GNUNET_SCHEDULER_NO_TASK;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Rescheduling %X' `%s'\n",
- s, udp_address_to_string(NULL, arg, args));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling %X' `%s'\n", s,
+ udp_address_to_string (NULL, arg, args));
}
- s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, s);
+ s->invalidation_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &invalidation_task, s);
/* we received from peer, so session is bidirectional and reliable */
s->bidirectional = GNUNET_YES;
@@ -768,7 +778,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
struct ReceiveContext *rc;
struct GNUNET_TIME_Absolute now;
struct FindReceiveContext frc;
- struct Session * s = NULL;
+ struct Session *s = NULL;
struct GNUNET_TIME_Relative flow_delay;
fromlen = sizeof (addr);
@@ -784,8 +794,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
msg = (const struct GNUNET_MessageHeader *) buf;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret,
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs(msg->type));
+ "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret,
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type));
if (ret != ntohs (msg->size))
{
@@ -814,26 +824,25 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
}
udp_ack = (const struct UDP_ACK_Message *) msg;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
- (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender),
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
+ "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
+ (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender),
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
// TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right
s = guess_session (plugin->sessions, addr, addrlen);
if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (peer_session->frag, ack))
- // ... other stuff
- return;
+ // ... other stuff
+ return;
case GNUNET_MESSAGE_TYPE_FRAGMENT:
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "UDP processes %u-byte fragment from `%s'\n",
- (unsigned int) ntohs (msg->size),
- GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n",
+ (unsigned int) ntohs (msg->size),
+ GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
// TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right
s = guess_session (plugin->sessions, addr, addrlen);
if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg))
- // other stuff
- return;
+ // other stuff
+ return;
default:
GNUNET_break_op (0);
return;
@@ -995,7 +1004,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen)
}
inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u",
- buf, port);
+ buf, port);
return rbuf;
}
@@ -1206,8 +1215,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
if (port > 65535)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Given `%s' option is out of range: %llu > %u\n"), "PORT",
- port, 65535);
+ _("Given `%s' option is out of range: %llu > %u\n"), "PORT", port,
+ 65535);
return NULL;
}
memset (&serverAddrv6, 0, sizeof (serverAddrv6));
@@ -1235,8 +1244,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
"BINDTO", &plugin->bind4_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Binding udp plugin to specific address: `%s'\n",
- plugin->bind4_address);
+ "Binding udp plugin to specific address: `%s'\n",
+ plugin->bind4_address);
if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr))
{
GNUNET_free (plugin->bind4_address);
@@ -1251,13 +1260,13 @@ libgnunet_plugin_transport_udp_init (void *cls)
"BINDTO6", &plugin->bind6_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Binding udp plugin to specific address: `%s'\n",
- plugin->bind6_address);
+ "Binding udp plugin to specific address: `%s'\n",
+ plugin->bind6_address);
if (1 !=
inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr))
{
LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"),
- plugin->bind6_address);
+ plugin->bind6_address);
GNUNET_free_non_null (plugin->bind4_address);
GNUNET_free (plugin->bind6_address);
GNUNET_free (plugin);
@@ -1296,7 +1305,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddr = (struct sockaddr *) &serverAddrv6;
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n",
- ntohs (serverAddrv6.sin6_port));
+ ntohs (serverAddrv6.sin6_port));
#endif
tries = 0;
while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) !=
@@ -1305,8 +1314,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "IPv6 Binding failed, trying new port %d\n",
- ntohs (serverAddrv6.sin6_port));
+ "IPv6 Binding failed, trying new port %d\n",
+ ntohs (serverAddrv6.sin6_port));
#endif
tries++;
if (tries > 10)
@@ -1344,7 +1353,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
serverAddr = (struct sockaddr *) &serverAddrv4;
#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n",
- ntohs (serverAddrv4.sin_port));
+ ntohs (serverAddrv4.sin_port));
#endif
tries = 0;
while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) !=
@@ -1352,9 +1361,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
{
serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "IPv4 Binding failed, trying new port %d\n",
- ntohs (serverAddrv4.sin_port));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Binding failed, trying new port %d\n",
+ ntohs (serverAddrv4.sin_port));
#endif
tries++;
if (tries > 10)
@@ -1411,8 +1419,8 @@ libgnunet_plugin_transport_udp_done (void *cls)
NULL);
GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions);
plugin->sessions = NULL;
- GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &destroy_inbound_session,
- NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions,
+ &destroy_inbound_session, NULL);
GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions);
plugin->inbound_sessions = NULL;
while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags)))
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 32f047d65..270829e68 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -731,9 +731,8 @@ unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
un->sun_path);
#endif
plugin->env->receive (plugin->env->cls, sender, currhdr,
- (const struct GNUNET_ATS_Information *)
- &distance, 1, NULL, un->sun_path,
- strlen (un->sun_path) + 1);
+ (const struct GNUNET_ATS_Information *) &distance, 1,
+ NULL, un->sun_path, strlen (un->sun_path) + 1);
}
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 041e80f86..cbab8cb0f 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -862,7 +862,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct Sessionqueue *queue = cls;
GNUNET_assert (queue != NULL);
- GNUNET_assert(queue->content != NULL);
+ GNUNET_assert (queue->content != NULL);
queue->content->timeout_task = GNUNET_SCHEDULER_NO_TASK;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
{
@@ -873,9 +873,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
(queue->content->last_activity, SESSION_TIMEOUT)).rel_value == 0)
{
- GNUNET_assert(queue->content->mac != NULL);
- GNUNET_assert(queue->content->mac->plugin != NULL);
- GNUNET_STATISTICS_update (queue->content->mac->plugin->env->stats, _("# wlan session timeouts"), 1, GNUNET_NO);
+ GNUNET_assert (queue->content->mac != NULL);
+ GNUNET_assert (queue->content->mac->plugin != NULL);
+ GNUNET_STATISTICS_update (queue->content->mac->plugin->env->stats,
+ _("# wlan session timeouts"), 1, GNUNET_NO);
free_session (queue->content->mac->plugin, queue, GNUNET_YES);
}
else
@@ -900,7 +901,8 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
{
GNUNET_assert (endpoint != NULL);
GNUNET_assert (plugin != NULL);
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan session created"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan session created"), 1,
+ GNUNET_NO);
struct Sessionqueue *queue =
GNUNET_malloc (sizeof (struct Sessionqueue) + sizeof (struct Session));
@@ -983,7 +985,8 @@ queue_session (struct Plugin *plugin, struct Session *session)
GNUNET_CONTAINER_DLL_insert_tail (plugin->pending_Sessions_head,
plugin->pending_Sessions_tail, queue);
plugin->pendingsessions++;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
}
}
@@ -1132,24 +1135,25 @@ get_next_queue_session (struct Plugin *plugin)
pm = session->pending_message_head;
if (pm == NULL)
- {
+ {
#if DEBUG_wlan
- GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
- "pending message is empty, should not happen. session %p\n",
- session);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
+ "pending message is empty, should not happen. session %p\n",
+ session);
#endif
- sessionqueue_alt = sessionqueue;
- sessionqueue = sessionqueue->next;
- plugin->pendingsessions--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
- GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
- plugin->pending_Sessions_tail,
- sessionqueue_alt);
+ sessionqueue_alt = sessionqueue;
+ sessionqueue = sessionqueue->next;
+ plugin->pendingsessions--;
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
+ GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
+ plugin->pending_Sessions_tail,
+ sessionqueue_alt);
- GNUNET_free (sessionqueue_alt);
- continue;
+ GNUNET_free (sessionqueue_alt);
+ continue;
- }
+ }
//check for message timeout
if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0)
@@ -1161,7 +1165,8 @@ get_next_queue_session (struct Plugin *plugin)
FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION))
{
plugin->pendingsessions--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
plugin->pending_Sessions_tail,
sessionqueue);
@@ -1191,7 +1196,8 @@ get_next_queue_session (struct Plugin *plugin)
sessionqueue_alt = sessionqueue;
sessionqueue = sessionqueue->next;
plugin->pendingsessions--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
plugin->pending_Sessions_tail,
sessionqueue_alt);
@@ -1217,38 +1223,40 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm)
struct FragmentMessage_queue *fmq;
struct FragmentMessage_queue *fmq_next;
- fmq = plugin->sending_messages_head;
- while (fmq != NULL)
+ fmq = plugin->sending_messages_head;
+ while (fmq != NULL)
+ {
+ fmq_next = fmq->next;
+ if (fmq->content == fm)
{
- fmq_next = fmq->next;
- if (fmq->content == fm)
- {
- GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head,
- plugin->sending_messages_tail, fmq);
- GNUNET_free (fmq);
- }
- fmq = fmq_next;
+ GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head,
+ plugin->sending_messages_tail, fmq);
+ GNUNET_free (fmq);
}
+ fmq = fmq_next;
+ }
- (session->mac->fragment_messages_out_count)--;
- session->fragment_messages_out_count--;
- plugin->pending_Fragment_Messages--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending fragments"), plugin->pending_Fragment_Messages, GNUNET_NO);
- GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
- endpoint->sending_messages_tail, fm);
- GNUNET_FRAGMENT_context_destroy (fm->fragcontext);
- if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK){
- GNUNET_SCHEDULER_cancel (fm->timeout_task);
- fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ (session->mac->fragment_messages_out_count)--;
+ session->fragment_messages_out_count--;
+ plugin->pending_Fragment_Messages--;
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"),
+ plugin->pending_Fragment_Messages, GNUNET_NO);
+ GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
+ endpoint->sending_messages_tail, fm);
+ GNUNET_FRAGMENT_context_destroy (fm->fragcontext);
+ if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (fm->timeout_task);
+ fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ }
- GNUNET_free (fm);
+ GNUNET_free (fm);
- queue_session (plugin, session);
+ queue_session (plugin, session);
#if DEBUG_wlan
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Free pending fragment messages %p, session %p\n", fm,
- session);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
+ "Free pending fragment messages %p, session %p\n", fm,
+ session);
#endif
}
@@ -1499,15 +1507,17 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
else
{
char cwd[FILENAME_MAX];
- GNUNET_assert (getcwd(cwd, sizeof(cwd)) != NULL);
- GNUNET_asprintf (&absolute_filename, "%s%s%s", cwd, DIR_SEPARATOR_STR, filenameloopback);
+ GNUNET_assert (getcwd (cwd, sizeof (cwd)) != NULL);
+
+ GNUNET_asprintf (&absolute_filename, "%s%s%s", cwd, DIR_SEPARATOR_STR,
+ filenameloopback);
if (GNUNET_DISK_file_test (filenameloopback) != GNUNET_YES)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
"Helper `%s' not found! %i\n", absolute_filename);
- GNUNET_break(0);
+ GNUNET_break (0);
}
}
}
@@ -1552,14 +1562,16 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
"Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n",
absolute_filename, plugin->interface, plugin->testmode);
#endif
- plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
- absolute_filename, absolute_filename, "1",
- NULL);
+ plugin->server_proc =
+ GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ absolute_filename, absolute_filename, "1",
+ NULL);
if (plugin->server_proc == NULL)
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
- "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename);
- GNUNET_break (0);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
+ "`%s' not found, please look if it exists and is in the $PATH variable!\n",
+ absolute_filename);
+ GNUNET_break (0);
}
}
else if (plugin->testmode == 2)
@@ -1570,18 +1582,20 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
absolute_filename, plugin->interface, plugin->testmode);
#endif
- plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
- absolute_filename, absolute_filename, "2",
- NULL);
- if (plugin->server_proc == NULL)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
- "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename);
+ plugin->server_proc =
+ GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ absolute_filename, absolute_filename, "2",
+ NULL);
+ if (plugin->server_proc == NULL)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
+ "`%s' not found, please look if it exists and is in the $PATH variable!\n",
+ absolute_filename);
GNUNET_break (0);
- }
+ }
}
if (absolute_filename != NULL)
- GNUNET_free(absolute_filename);
+ GNUNET_free (absolute_filename);
if (plugin->server_proc == NULL)
{
#if DEBUG_wlan
@@ -1632,8 +1646,8 @@ static int
wlan_transport_stop_wlan_helper (struct Plugin *plugin)
{
#if DEBUG_wlan
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Stoping WLAN helper process\n");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
+ "Stoping WLAN helper process\n");
#endif
if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1657,7 +1671,7 @@ wlan_transport_stop_wlan_helper (struct Plugin *plugin)
GNUNET_DISK_pipe_close (plugin->server_stdout);
GNUNET_DISK_pipe_close (plugin->server_stdin);
GNUNET_OS_process_kill (plugin->server_proc, SIGKILL);
- GNUNET_OS_process_wait(plugin->server_proc);
+ GNUNET_OS_process_wait (plugin->server_proc);
GNUNET_OS_process_close (plugin->server_proc);
return GNUNET_YES;
@@ -1673,31 +1687,32 @@ delay_restart_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Finish_send *finish = cls;
struct Plugin *plugin;
+
plugin = finish->plugin;
plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
{
- GNUNET_free_non_null(finish->msgstart);
+ GNUNET_free_non_null (finish->msgstart);
GNUNET_free (finish);
return;
}
- wlan_transport_start_wlan_helper(plugin);
+ wlan_transport_start_wlan_helper (plugin);
if (finish->size != 0)
- {
- plugin->server_write_task =
- GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
- plugin->server_stdin_handle,
- &finish_sending, finish);
- }
+ {
+ plugin->server_write_task =
+ GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
+ plugin->server_stdin_handle,
+ &finish_sending, finish);
+ }
else
- {
- set_next_send (plugin);
- GNUNET_free_non_null(finish->msgstart);
- GNUNET_free (finish);
- }
+ {
+ set_next_send (plugin);
+ GNUNET_free_non_null (finish->msgstart);
+ GNUNET_free (finish);
+ }
}
@@ -1707,14 +1722,15 @@ delay_restart_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* @param finish pointer to the Finish_send struct to finish
*/
static void
-restart_helper(struct Plugin *plugin, struct Finish_send *finish)
+restart_helper (struct Plugin *plugin, struct Finish_send *finish)
{
- static struct GNUNET_TIME_Relative next_try = {1000};
- GNUNET_assert(finish != NULL);
+ static struct GNUNET_TIME_Relative next_try = { 1000 };
+ GNUNET_assert (finish != NULL);
- wlan_transport_stop_wlan_helper(plugin);
- plugin->server_write_task = GNUNET_SCHEDULER_add_delayed (next_try, &delay_restart_helper, finish);
- GNUNET_TIME_relative_multiply(next_try, HELPER_RESTART_SCALING_FACTOR);
+ wlan_transport_stop_wlan_helper (plugin);
+ plugin->server_write_task =
+ GNUNET_SCHEDULER_add_delayed (next_try, &delay_restart_helper, finish);
+ GNUNET_TIME_relative_multiply (next_try, HELPER_RESTART_SCALING_FACTOR);
}
@@ -1740,24 +1756,24 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
}
bytes =
- GNUNET_DISK_file_write (plugin->server_stdin_handle, finish->head_of_next_write,
- finish->size);
+ GNUNET_DISK_file_write (plugin->server_stdin_handle,
+ finish->head_of_next_write, finish->size);
if (bytes != finish->size)
{
if (bytes != GNUNET_SYSERR)
- {
+ {
finish->head_of_next_write += bytes;
finish->size -= bytes;
plugin->server_write_task =
GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdin_handle,
&finish_sending, finish);
- }
+ }
else
- {
- restart_helper(plugin, finish);
- }
+ {
+ restart_helper (plugin, finish);
+ }
}
else
{
@@ -1788,11 +1804,12 @@ send_hello_beacon (struct Plugin *plugin)
struct Radiotap_Send *radioHeader;
struct GNUNET_MessageHeader *msgheader2;
const struct GNUNET_MessageHeader *hello;
- struct Finish_send * finish;
+ struct Finish_send *finish;
GNUNET_assert (plugin != NULL);
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"),
+ 1, GNUNET_NO);
hello = plugin->env->get_our_hello ();
hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
@@ -1812,10 +1829,10 @@ send_hello_beacon (struct Plugin *plugin)
msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1];
/*msgheader2->size =
- htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) +
- sizeof (struct GNUNET_MessageHeader));
-
- msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT);*/
+ * htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) +
+ * sizeof (struct GNUNET_MessageHeader));
+ *
+ * msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT); */
memcpy (msgheader2, hello, hello_size);
bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size);
@@ -1831,17 +1848,17 @@ send_hello_beacon (struct Plugin *plugin)
finish->head_of_next_write = NULL;
finish->size = 0;
finish->msgstart = NULL;
- restart_helper(plugin, finish);
+ restart_helper (plugin, finish);
set_next_beacon_time (plugin);
}
else
- {
+ {
GNUNET_assert (bytes == size);
set_next_beacon_time (plugin);
set_next_send (plugin);
- }
+ }
GNUNET_free (msgheader);
@@ -1951,7 +1968,8 @@ check_fragment_queue (struct Plugin *plugin)
session->mac->fragment_messages_out_count++;
session->fragment_messages_out_count++;
plugin->pending_Fragment_Messages++;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending fragments"), plugin->pending_Fragment_Messages, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"),
+ plugin->pending_Fragment_Messages, GNUNET_NO);
fm = GNUNET_malloc (sizeof (struct FragmentMessage));
fm->session = session;
@@ -2012,7 +2030,7 @@ send_ack (struct Plugin *plugin)
ssize_t bytes;
struct AckSendQueue *ack;
- struct Finish_send * finish;
+ struct Finish_send *finish;
ack = plugin->ack_send_queue_head;
@@ -2025,7 +2043,8 @@ send_ack (struct Plugin *plugin)
#endif
GNUNET_assert (plugin != NULL);
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1,
+ GNUNET_NO);
getRadiotapHeader (plugin, ack->endpoint, ack->radioHeader);
getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin,
@@ -2045,7 +2064,7 @@ send_ack (struct Plugin *plugin)
finish->head_of_next_write = NULL;
finish->size = 0;
finish->msgstart = NULL;
- restart_helper(plugin, finish);
+ restart_helper (plugin, finish);
}
else
{
@@ -2067,6 +2086,7 @@ static void
do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
+
GNUNET_assert (plugin != NULL);
plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
@@ -2094,7 +2114,8 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (plugin->sending_messages_head != NULL)
{
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1,
+ GNUNET_NO);
fmq = plugin->sending_messages_head;
fm = fmq->content;
@@ -2136,16 +2157,16 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
finish->head_of_next_write = fm->frag;
finish->size = fm->size;
- restart_helper(plugin, finish);
+ restart_helper (plugin, finish);
}
else
{
finish->head_of_next_write = fm->frag + bytes;
finish->size = fm->size - bytes;
plugin->server_write_task =
- GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
- plugin->server_stdin_handle,
- &finish_sending, finish);
+ GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
+ plugin->server_stdin_handle,
+ &finish_sending, finish);
}
fm->frag = NULL;
@@ -2192,13 +2213,15 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
/* TODO check for bad addresses like multicast, broadcast, etc */
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "wlan_plugin_address_suggested got good address, size %u!\n", addrlen);
+ "wlan_plugin_address_suggested got good address, size %u!\n",
+ addrlen);
#endif
return GNUNET_OK;
}
#if DEBUG_wlan
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "wlan_plugin_address_suggested got bad address, size %u!\n", addrlen);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
+ "wlan_plugin_address_suggested got bad address, size %u!\n",
+ addrlen);
#endif
return GNUNET_SYSERR;
}
@@ -2239,6 +2262,7 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
struct Plugin *plugin = cls;
struct PendingMessage *newmsg;
struct WlanHeader *wlanheader;
+
GNUNET_assert (plugin != NULL);
//check if msglen > 0
GNUNET_assert (msgbuf_size > 0);
@@ -2258,7 +2282,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
}
}
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1,
+ GNUNET_NO);
//queue message:
@@ -2348,7 +2373,8 @@ free_macendpoint (struct Plugin *plugin, struct MacEndpoint *endpoint)
endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
plugin->mac_count--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"),
+ plugin->mac_count, GNUNET_NO);
GNUNET_free (endpoint);
}
@@ -2386,7 +2412,8 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
if (pendingsession_tmp->content == queue->content)
{
plugin->pendingsessions--;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
plugin->pending_Sessions_tail,
pendingsession_tmp);
@@ -2423,12 +2450,14 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail,
queue);
//Check that no ohter session on this endpoint for this session exits
- GNUNET_assert(search_session(plugin, endpoint, &queue->content->target) == NULL);
+ GNUNET_assert (search_session (plugin, endpoint, &queue->content->target) ==
+ NULL);
if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES)
{
free_macendpoint (plugin, endpoint);
//check if no endpoint with the same address exists
- GNUNET_assert(get_macendpoint(plugin, &endpoint->addr, GNUNET_NO) == NULL);
+ GNUNET_assert (get_macendpoint (plugin, &endpoint->addr, GNUNET_NO) ==
+ NULL);
}
if (queue->content->timeout_task != GNUNET_SCHEDULER_NO_TASK)
@@ -2507,31 +2536,31 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
const unsigned char *input;
//GNUNET_assert(cls !=NULL);
- if (addrlen != sizeof(struct MacAddress))
+ if (addrlen != sizeof (struct MacAddress))
{
/* invalid address (MAC addresses have 6 bytes) */
//GNUNET_break (0);
#if DEBUG_wlan
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n",
- addrlen);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
+ "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n",
+ addrlen);
#endif
- asc(asc_cls, NULL);
+ asc (asc_cls, NULL);
return;
}
input = (const unsigned char *) addr;
GNUNET_asprintf (&ret,
- "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",type,
- PROTOCOL_PREFIX, input[0], input[1], input[2], input[3],
- input[4], input[5]);
+ "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
+ type, PROTOCOL_PREFIX, input[0], input[1], input[2],
+ input[3], input[4], input[5]);
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n",
addrlen, numeric, type, ret);
#endif
- asc ( asc_cls, ret);
+ asc (asc_cls, ret);
//only one mac address per plugin
- asc ( asc_cls, NULL);
+ asc (asc_cls, NULL);
}
@@ -2571,7 +2600,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
return;
}
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan whole messages received"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan whole messages received"), 1,
+ GNUNET_NO);
wlanheader = (struct WlanHeader *) hdr;
session = search_session (plugin, endpoint, &wlanheader->source);
@@ -2711,9 +2742,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
#endif
plugin->env->receive (plugin->env->cls, &(session->target), hdr,
- (const struct GNUNET_ATS_Information *)
- &distance, 1, session,
- (const char *) &session->mac->addr,
+ (const struct GNUNET_ATS_Information *) &distance, 1,
+ session, (const char *) &session->mac->addr,
sizeof (session->mac->addr));
}
@@ -2735,7 +2765,7 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
struct FragmentMessage *fm2;
struct GNUNET_PeerIdentity tmpsource;
- GNUNET_assert(plugin != NULL);
+ GNUNET_assert (plugin != NULL);
//ADVERTISEMENT
if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO)
@@ -2761,18 +2791,22 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
if (GNUNET_HELLO_get_id
- ((const struct GNUNET_HELLO_Message *) hdr,
- &tmpsource) == GNUNET_OK)
+ ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource) == GNUNET_OK)
{
- session_light->session = search_session (plugin, session_light->macendpoint, &tmpsource);
+ session_light->session =
+ search_session (plugin, session_light->macendpoint, &tmpsource);
if (session_light->session == NULL)
- {
- session_light->session = create_session (plugin, session_light->macendpoint, &tmpsource);
- }
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello messages received"), 1, GNUNET_NO);
- plugin->env->receive(plugin->env->cls,&session_light->session->target,hdr, NULL, 0, session_light->session,
- (const char *) &session_light->session->mac->addr,
- sizeof (session_light->session->mac->addr));
+ {
+ session_light->session =
+ create_session (plugin, session_light->macendpoint, &tmpsource);
+ }
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan hello messages received"), 1,
+ GNUNET_NO);
+ plugin->env->receive (plugin->env->cls, &session_light->session->target,
+ hdr, NULL, 0, session_light->session,
+ (const char *) &session_light->session->mac->addr,
+ sizeof (session_light->session->mac->addr));
}
else
{
@@ -2803,7 +2837,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
6));
#endif
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments received"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan fragments received"), 1, GNUNET_NO);
int ret =
GNUNET_DEFRAGMENT_process_fragment (session_light->macendpoint->defrag,
hdr);
@@ -2855,7 +2890,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
while (fm != NULL)
{
fm2 = fm->next;
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks received"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks received"),
+ 1, GNUNET_NO);
int ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
if (ret == GNUNET_OK)
@@ -2947,8 +2983,9 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
(GNUNET_TIME_absolute_add
(endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0)
{
- GNUNET_assert(endpoint->plugin != NULL);
- GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# wlan mac endpoints timeouts"), 1, GNUNET_NO);
+ GNUNET_assert (endpoint->plugin != NULL);
+ GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
+ _("# wlan mac endpoints timeouts"), 1, GNUNET_NO);
free_macendpoint (endpoint->plugin, endpoint);
}
else
@@ -2970,8 +3007,9 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
{
struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint));
- GNUNET_assert(plugin != NULL);
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan mac endpoints created"), 1, GNUNET_NO);
+ GNUNET_assert (plugin != NULL);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan mac endpoints created"), 1, GNUNET_NO);
newend->addr = *addr;
newend->plugin = plugin;
newend->addr = *addr;
@@ -2987,7 +3025,8 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
newend);
plugin->mac_count++;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"),
+ plugin->mac_count, GNUNET_NO);
GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend);
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
@@ -3017,7 +3056,7 @@ wlan_process_helper (void *cls, void *client,
int datasize = 0;
int pos;
- GNUNET_assert(plugin != NULL);
+ GNUNET_assert (plugin != NULL);
switch (ntohs (hdr->type))
{
case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA:
@@ -3027,11 +3066,13 @@ wlan_process_helper (void *cls, void *client,
ntohs (hdr->size));
#endif
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan WLAN_HELPER_DATA received"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan WLAN_HELPER_DATA received"), 1,
+ GNUNET_NO);
//call wlan_process_helper with the message inside, later with wlan: analyze signal
if (ntohs (hdr->size) <
- sizeof (struct ieee80211_frame) + 2*sizeof (struct GNUNET_MessageHeader) +
- sizeof (struct Radiotap_rx))
+ sizeof (struct ieee80211_frame) +
+ 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx))
{
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
@@ -3057,16 +3098,19 @@ wlan_process_helper (void *cls, void *client,
{
//check for broadcast or mac
if ((memcmp
- (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
- sizeof (struct MacAddress)) == 0) ||
- (memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
- sizeof (struct MacAddress)) == 0))
+ (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
+ sizeof (struct MacAddress)) == 0) ||
+ (memcmp
+ (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
+ sizeof (struct MacAddress)) == 0))
{
- //if packet is from us return
- if ((memcmp (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address),
- sizeof (struct MacAddress)) == 0)){
- return;
- }
+ //if packet is from us return
+ if ((memcmp
+ (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address),
+ sizeof (struct MacAddress)) == 0))
+ {
+ return;
+ }
// process the inner data
@@ -3078,25 +3122,30 @@ wlan_process_helper (void *cls, void *client,
memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2),
sizeof (struct MacAddress));
//session_light->session = search_session(plugin,session_light->addr);
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages for this client received"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# wlan messages for this client received"),
+ 1, GNUNET_NO);
pos = 0;
while (pos < datasize)
{
temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos;
- if (ntohs(temp_hdr->size) <= datasize + pos)
- {
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages inside WLAN_HELPER_DATA received"), 1, GNUNET_NO);
- wlan_data_helper (plugin, session_light, temp_hdr, rxinfo);
- }
+ if (ntohs (temp_hdr->size) <= datasize + pos)
+ {
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _
+ ("# wlan messages inside WLAN_HELPER_DATA received"),
+ 1, GNUNET_NO);
+ wlan_data_helper (plugin, session_light, temp_hdr, rxinfo);
+ }
else
- {
+ {
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Size of packet is too small; size: %u > size of packet: %u\n",
- ntohs(temp_hdr->size),datasize + pos);
+ "Size of packet is too small; size: %u > size of packet: %u\n",
+ ntohs (temp_hdr->size), datasize + pos);
#endif
- }
+ }
pos += ntohs (temp_hdr->size);
}
@@ -3176,7 +3225,7 @@ libgnunet_plugin_transport_wlan_done (void *cls)
"libgnunet_plugin_transport_wlan_done started\n");
#endif
- wlan_transport_stop_wlan_helper(plugin);
+ wlan_transport_stop_wlan_helper (plugin);
GNUNET_assert (cls != NULL);
//free sessions
@@ -3220,9 +3269,11 @@ libgnunet_plugin_transport_wlan_init (void *cls)
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
plugin->pendingsessions = 0;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"),
+ plugin->pendingsessions, GNUNET_NO);
plugin->mac_count = 0;
- GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO);
+ GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"),
+ plugin->mac_count, GNUNET_NO);
plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
plugin->server_read_task = GNUNET_SCHEDULER_NO_TASK;
plugin->server_write_delay_task = GNUNET_SCHEDULER_NO_TASK;
@@ -3253,7 +3304,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
"TESTMODE", &(plugin->testmode)))
- plugin->testmode = 0; //default value
+ plugin->testmode = 0; //default value
}
if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE"))
@@ -3270,7 +3321,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
//start the plugin
wlan_transport_start_wlan_helper (plugin);
set_next_beacon_time (plugin);
- set_next_send(plugin);
+ set_next_send (plugin);
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan init finished\n");
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 1c6bba0d5..7d28820cb 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -70,9 +70,9 @@ struct PeerContext *p1;
struct PeerContext *p2;
-struct PeerContext * sender;
+struct PeerContext *sender;
-struct PeerContext * receiver;
+struct PeerContext *receiver;
struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -86,7 +86,7 @@ char *gen_cfg_p1;
unsigned long long quota_in_p2;
unsigned long long quota_out_p2;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
@@ -144,26 +144,28 @@ end ()
delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
datarate = (total_bytes_sent * 1000) / delta;
- fprintf (stderr, "Throughput was %llu b/s\n",
- datarate);
+ fprintf (stderr, "Throughput was %llu b/s\n", datarate);
test_failed = GNUNET_NO;
if (datarate > quota_in_p2)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Datarate of %llu b/s higher than allowed inbound quota of %llu b/s\n", datarate, quota_in_p2);
+ "Datarate of %llu b/s higher than allowed inbound quota of %llu b/s\n",
+ datarate, quota_in_p2);
test_failed = GNUNET_YES;
}
if (datarate > quota_out_p1)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Datarate of %llu b/s higher than allowed outbound quota of %llu b/s\n", datarate, quota_out_p1);
+ "Datarate of %llu b/s higher than allowed outbound quota of %llu b/s\n",
+ datarate, quota_out_p1);
test_failed = GNUNET_YES;
}
if (test_failed == GNUNET_NO)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n", datarate, quota_out_p1, quota_in_p2);
+ "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n",
+ datarate, quota_out_p1, quota_in_p2);
}
if (die_task != GNUNET_SCHEDULER_NO_TASK)
@@ -174,7 +176,7 @@ end ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
@@ -200,7 +202,7 @@ end_badly ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
if (p1 != NULL)
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -224,8 +226,7 @@ get_size (unsigned int iter)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int n;
unsigned int s;
@@ -269,17 +270,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
if (die_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (die_task);
test_failed = GNUNET_YES;
- die_task = GNUNET_SCHEDULER_add_now (&end_badly,
- NULL);
+ die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
#if VERBOSE
if (ntohl (hdr->num) % 5000 == 0)
{
struct PeerContext *p = cls;
- char * ps = strdup(GNUNET_i2s(&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "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));
+ char *ps = strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "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);
}
#endif
@@ -300,7 +303,8 @@ notify_ready (void *cls, size_t size, void *buf)
if (buf == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout occurred while waiting for transmit_ready for message %u of %u\n", msg_scheduled, TOTAL_MSGS);
+ "Timeout occurred while waiting for transmit_ready for message %u of %u\n",
+ msg_scheduled, TOTAL_MSGS);
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
@@ -327,12 +331,12 @@ notify_ready (void *cls, size_t size, void *buf)
if (n % 5000 == 0)
{
- char * receiver_s = strdup(GNUNET_i2s (&receiver->id));
+ char *receiver_s = strdup (GNUNET_i2s (&receiver->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n",
- n,
- sender->no,
- GNUNET_i2s (&sender->id), receiver->no, receiver_s);
+ n, sender->no, GNUNET_i2s (&sender->id), receiver->no,
+ receiver_s);
GNUNET_free (receiver_s);
}
#endif
@@ -367,11 +371,11 @@ notify_ready (void *cls, size_t size, void *buf)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct PeerContext *p = cls;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
p->no, GNUNET_i2s (peer));
}
@@ -381,8 +385,9 @@ static void
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_i2s (peer));
+
+ 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);
th = NULL;
@@ -403,10 +408,11 @@ static void
measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
static int counter;
+
measure_task = GNUNET_SCHEDULER_NO_TASK;
counter++;
- if ((DURATION.rel_value / 1000) < counter )
+ if ((DURATION.rel_value / 1000) < counter)
{
fprintf (stderr, ".\n");
GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -414,7 +420,8 @@ measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
else
{
fprintf (stderr, ".");
- measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL);
+ measure_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL);
}
}
@@ -423,28 +430,29 @@ static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
char *p1_c = 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));
+ p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
cc = NULL;
test_connected = GNUNET_YES;
- measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL);
+ measure_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL);
GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
@@ -455,61 +463,66 @@ void start_cb (struct PeerContext * p,
receiver = p1;
char *sender_c = strdup (GNUNET_i2s (&sender->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to send from %u (%s) -> peer %u (%s)\n",
- sender->no, sender_c,
- receiver->no, GNUNET_i2s (&receiver->id));
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no,
+ sender_c, receiver->no, GNUNET_i2s (&receiver->id));
+
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
}
static char *
-generate_config (char * cfg_file, unsigned long long quota_in, unsigned long long quota_out)
+generate_config (char *cfg_file, unsigned long long quota_in,
+ unsigned long long quota_out)
{
- char * fname = NULL;
- struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create();
+ char *fname = NULL;
+ struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
+
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_file));
- GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out, cfg_file);
- GNUNET_CONFIGURATION_set_value_string(cfg, "PATHS", "DEFAULTCONFIG", fname);
- GNUNET_CONFIGURATION_set_value_number(cfg, "core", "TOTAL_QUOTA_OUT", quota_out);
- GNUNET_CONFIGURATION_set_value_number(cfg, "core", "TOTAL_QUOTA_IN", quota_in);
- GNUNET_CONFIGURATION_set_value_number(cfg, "ats", "TOTAL_QUOTA_IN", quota_in);
- GNUNET_CONFIGURATION_set_value_number(cfg, "ats", "TOTAL_QUOTA_OUT", quota_out);
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write(cfg, fname));
- GNUNET_CONFIGURATION_destroy(cfg);
+ GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out,
+ cfg_file);
+ GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", fname);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "core", "TOTAL_QUOTA_OUT",
+ quota_out);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "core", "TOTAL_QUOTA_IN",
+ quota_in);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "TOTAL_QUOTA_IN",
+ quota_in);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "TOTAL_QUOTA_OUT",
+ quota_out);
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname));
+ GNUNET_CONFIGURATION_destroy (cfg);
return fname;
}
static void
-run_measurement (unsigned long long p1_quota_in, unsigned long long p1_quota_out,
- unsigned long long p2_quota_in, unsigned long long p2_quota_out)
+run_measurement (unsigned long long p1_quota_in,
+ unsigned long long p1_quota_out,
+ unsigned long long p2_quota_in,
+ unsigned long long p2_quota_out)
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
/* setting ATS quota */
quota_out_p1 = p1_quota_out;
- gen_cfg_p1 = generate_config(cfg_file_p1, p1_quota_in, p1_quota_out);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Generated config file `%s'\n",
- gen_cfg_p1);
+ gen_cfg_p1 = generate_config (cfg_file_p1, p1_quota_in, p1_quota_out);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generated config file `%s'\n",
+ gen_cfg_p1);
quota_in_p2 = p2_quota_in;
- gen_cfg_p2 = generate_config(cfg_file_p2, p2_quota_in, p2_quota_out);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Generated config file `%s'\n",
- gen_cfg_p2);
+ gen_cfg_p2 = generate_config (cfg_file_p2, p2_quota_in, p2_quota_out);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generated config file `%s'\n",
+ gen_cfg_p2);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p1, 1,
- &notify_receive,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p1, 1, &notify_receive,
&notify_connect, &notify_disconnect,
- &start_cb,
- NULL);
+ &start_cb, NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p2, 2,
- &notify_receive,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p2, 2, &notify_receive,
&notify_connect, &notify_disconnect,
- &start_cb,
- NULL);
+ &start_cb, NULL);
if ((p1 == NULL) || (p2 == NULL))
{
@@ -530,19 +543,19 @@ run (void *cls, char *const *args, const char *cfgfile,
unsigned long long p2_quota_in = 10000;
unsigned long long p2_quota_out = 10000;
- if (NULL != strstr (test_name,"asymmetric"))
+ if (NULL != strstr (test_name, "asymmetric"))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n",
- p2_quota_in, p2_quota_out);
+ "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n",
+ p2_quota_in, p2_quota_out);
p1_quota_out = 1024 * 1024 * 1024;
p1_quota_in = 1024 * 1024 * 1024;
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running symmetric test with (in/out) %llu/%llu b/s \n",
- p2_quota_in, p2_quota_out);
+ "Running symmetric test with (in/out) %llu/%llu b/s \n",
+ p2_quota_in, p2_quota_out);
}
run_measurement (p1_quota_in, p1_quota_out, p2_quota_in, p2_quota_out);
}
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 6b6cc0c0e..47686f8d9 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -74,7 +74,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
char *cfg_file_p1;
@@ -140,10 +140,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
- struct PeerContext * p = cls;
+ struct PeerContext *p = cls;
struct PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -152,11 +151,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
t = p2;
GNUNET_assert (t != NULL);
- char * ps = strdup (GNUNET_i2s(&p->id));
+ char *ps = 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));
+ p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
+ GNUNET_i2s (&t->id));
if ((MTYPE == ntohs (message->type)) &&
(sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)))
@@ -200,13 +200,12 @@ notify_ready (void *cls, size_t size, void *buf)
hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
hdr->type = htons (MTYPE);
}
- char * ps = strdup (GNUNET_i2s(&p2->id));
+ char *ps = 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));
+ p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
+ GNUNET_i2s (&p->id));
GNUNET_free (ps);
return sizeof (struct GNUNET_MessageHeader);
}
@@ -219,11 +218,11 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- char * receiver_s = strdup(GNUNET_i2s (&p1->id));
+ char *receiver_s = 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);
+ 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, 0,
@@ -234,10 +233,10 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int c;
+
c++;
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
@@ -246,11 +245,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
t = p1;
if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
t = p2;
- GNUNET_assert (t!=NULL);
+ GNUNET_assert (t != NULL);
+
+ char *ps = strdup (GNUNET_i2s (&p->id));
- char * ps = strdup (GNUNET_i2s(&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
- p->no, 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);
}
@@ -260,9 +260,11 @@ static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
- char * ps = 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 = 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));
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -276,8 +278,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
char *p1_c = 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));
+ p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
@@ -285,23 +286,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
char *sender_c = 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_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));
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
NULL);
@@ -315,17 +317,13 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
- NULL);
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 0be922e93..f97c449fc 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -71,7 +71,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
int shutdown_;
@@ -148,9 +148,11 @@ static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
- char * ps = 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 = 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));
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -158,8 +160,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
if (shutdown_ == GNUNET_YES)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n");
- GNUNET_SCHEDULER_add_now (&end, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n");
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
}
@@ -170,12 +172,12 @@ stop_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- struct PeerContext * p = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n",
- p->no,
- GNUNET_i2s (&p->id));
+ struct PeerContext *p = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no,
+ GNUNET_i2s (&p->id));
shutdown_ = GNUNET_YES;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
p2 = NULL;
GNUNET_assert (p2 == NULL);
}
@@ -183,10 +185,9 @@ stop_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
- struct PeerContext * p = cls;
+ struct PeerContext *p = cls;
struct PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -195,17 +196,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
t = p2;
GNUNET_assert (t != NULL);
- char * ps = strdup (GNUNET_i2s(&p->id));
+ char *ps = 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));
+ p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
+ GNUNET_i2s (&t->id));
if ((MTYPE == ntohs (message->type)) &&
(sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)))
{
ok = 1;
- GNUNET_SCHEDULER_add_now(stop_peer, p2);
+ GNUNET_SCHEDULER_add_now (stop_peer, p2);
return;
}
}
@@ -238,13 +240,12 @@ notify_ready (void *cls, size_t size, void *buf)
hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
hdr->type = htons (MTYPE);
}
- char * ps = strdup (GNUNET_i2s(&p2->id));
+ char *ps = 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));
+ p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
+ GNUNET_i2s (&p->id));
GNUNET_free (ps);
return sizeof (struct GNUNET_MessageHeader);
}
@@ -257,11 +258,11 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- char * receiver_s = strdup(GNUNET_i2s (&p1->id));
+ char *receiver_s = 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);
+ 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, 0,
@@ -272,10 +273,10 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int c;
+
c++;
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
@@ -284,11 +285,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
t = p1;
if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
t = p2;
- GNUNET_assert (t!=NULL);
+ GNUNET_assert (t != NULL);
+
+ char *ps = strdup (GNUNET_i2s (&p->id));
- char * ps = strdup (GNUNET_i2s(&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
- p->no, 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);
}
@@ -301,8 +303,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
char *p1_c = 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));
+ p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
@@ -310,23 +311,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
char *sender_c = 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_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));
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
NULL);
@@ -340,17 +342,13 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
- NULL);
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index 20dc3ed2e..f165a5771 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -77,7 +77,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
char *cfg_file_p1;
@@ -138,8 +138,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %d from peer %s!\n",
@@ -185,8 +184,7 @@ notify_ready (void *cls, size_t size, void *buf)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
GNUNET_i2s (peer), cls);
@@ -230,15 +228,15 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
@@ -257,14 +255,12 @@ run (void *cls, char *const *args, const char *cfgfile,
tth = GNUNET_TRANSPORT_TESTING_init ();
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index e4b635905..5bbff2550 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -69,9 +69,9 @@ struct PeerContext *p1;
struct PeerContext *p2;
-struct PeerContext * sender;
+struct PeerContext *sender;
-struct PeerContext * receiver;
+struct PeerContext *receiver;
struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -79,7 +79,7 @@ char *cfg_file_p1;
char *cfg_file_p2;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
@@ -151,7 +151,7 @@ end ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
@@ -175,7 +175,7 @@ end_badly ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
if (p1 != NULL)
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -201,8 +201,7 @@ get_size (unsigned int iter)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int n;
unsigned int s;
@@ -253,9 +252,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
if (ntohl (hdr->num) % 5000 == 0)
{
struct PeerContext *p = cls;
- char * ps = strdup(GNUNET_i2s(&p->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "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));
+ char *ps = strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "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);
}
#endif
@@ -289,7 +291,8 @@ notify_ready (void *cls, size_t size, void *buf)
if (buf == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout occurred while waiting for transmit_ready for message %u of %u\n", msg_scheduled, TOTAL_MSGS);
+ "Timeout occurred while waiting for transmit_ready for message %u of %u\n",
+ msg_scheduled, TOTAL_MSGS);
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
@@ -316,12 +319,12 @@ notify_ready (void *cls, size_t size, void *buf)
if (n % 5000 == 0)
{
- char * receiver_s = strdup(GNUNET_i2s (&receiver->id));
+ char *receiver_s = strdup (GNUNET_i2s (&receiver->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n",
- n,
- sender->no,
- GNUNET_i2s (&sender->id), receiver->no, receiver_s);
+ n, sender->no, GNUNET_i2s (&sender->id), receiver->no,
+ receiver_s);
GNUNET_free (receiver_s);
}
#endif
@@ -356,11 +359,11 @@ notify_ready (void *cls, size_t size, void *buf)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct PeerContext *p = cls;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
p->no, GNUNET_i2s (peer));
}
@@ -370,8 +373,9 @@ static void
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_i2s (peer));
+
+ 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);
th = NULL;
@@ -391,9 +395,9 @@ static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
char *p1_c = 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));
+ p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
cc = NULL;
@@ -402,37 +406,39 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
test_connected = GNUNET_NO;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n",
- p1->no,
- GNUNET_i2s (&p1->id), cfg_file_p1);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n",
- p2->no,
- GNUNET_i2s (&p2->id), cfg_file_p2);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u: `%s' using configuration file `%s'\n", p1->no,
+ GNUNET_i2s (&p1->id), cfg_file_p1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u: `%s' using configuration file `%s'\n", p2->no,
+ GNUNET_i2s (&p2->id), cfg_file_p2);
sender = p2;
receiver = p1;
char *sender_c = strdup (GNUNET_i2s (&sender->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> peer %u (%s)\n",
- sender->no, sender_c,
- receiver->no, GNUNET_i2s (&receiver->id));
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no,
+ sender_c, receiver->no, GNUNET_i2s (&receiver->id));
+
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
}
@@ -444,14 +450,12 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index aff36853a..79a90ba0e 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -65,7 +65,7 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static GNUNET_SCHEDULER_TaskIdentifier timer_task;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
struct PeerContext *p1;
@@ -161,8 +161,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %d from peer %s!\n",
@@ -171,8 +170,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
GNUNET_i2s (peer), cls);
@@ -240,23 +238,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL);
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
char *sender_c = 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_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));
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
NULL);
@@ -269,17 +268,13 @@ run (void *cls, char *const *args, const char *cfgfile,
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect,
- &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
@@ -314,8 +309,8 @@ check ()
ok = 1;
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
- "test-transport-api-timeout", "nohelp", options,
- &run, &ok);
+ "test-transport-api-timeout", "nohelp", options, &run,
+ &ok);
return ok;
}
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 90b5280ce..3077eaae6 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -78,7 +78,7 @@ char *cfg_file_p2;
uint32_t max_bps_p1;
uint32_t max_bps_p2;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
/*
* Testcase specific declarations
@@ -156,7 +156,7 @@ end ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = NULL;
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -190,13 +190,15 @@ end_badly ()
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n");
if (test_sending == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase did not send any messages timeout\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Testcase did not send any messages timeout\n");
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
msg_sent, msg_scheduled, msg_recv, msg_recv_expected);
if (test_send_timeout == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test had timeout while waiting to send data\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Test had timeout while waiting to send data\n");
if (th != NULL)
@@ -204,7 +206,7 @@ end_badly ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = NULL;
if (p1 != NULL)
@@ -273,8 +275,7 @@ get_bit (const char *map, unsigned int bit)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int n;
@@ -400,8 +401,7 @@ notify_ready (void *cls, size_t size, void *buf)
else
{
fprintf (stderr, "\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "All messages scheduled to be sent\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All messages scheduled to be sent\n");
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
@@ -418,8 +418,7 @@ notify_ready (void *cls, size_t size, void *buf)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
@@ -450,6 +449,7 @@ static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
char *p1_c = strdup (GNUNET_i2s (&p1->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
@@ -460,21 +460,22 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
test_connected = GNUNET_NO;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
}
@@ -487,14 +488,12 @@ run (void *cls, char *const *args, const char *cfgfile,
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c
index c8638cd23..3ce256017 100644
--- a/src/transport/test_transport_api_unreliability_constant.c
+++ b/src/transport/test_transport_api_unreliability_constant.c
@@ -71,7 +71,7 @@ struct PeerContext *p2;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
char *cfg_file_p1;
@@ -154,7 +154,7 @@ end ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = NULL;
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -165,7 +165,8 @@ end ()
ok = 0;
if (test_failed == GNUNET_NO)
ok = GNUNET_SYSERR;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GOT %u of %u messages\n", msg_recv, TOTAL_MSGS);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GOT %u of %u messages\n", msg_recv,
+ TOTAL_MSGS);
}
static void
@@ -186,7 +187,7 @@ end_badly ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = NULL;
if (p1 != NULL)
@@ -217,8 +218,7 @@ get_size (unsigned int iter)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
static int n;
@@ -234,8 +234,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
msg_recv = ntohl (hdr->num);
if (msg_recv_expected != msg_recv)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Expected message no %u, got %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected message no %u, got %u\n",
msg_recv_expected, msg_recv);
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
@@ -373,8 +372,7 @@ notify_ready (void *cls, size_t size, void *buf)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
@@ -415,20 +413,21 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
}
static void
@@ -438,14 +437,12 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive,
- &notify_connect, &notify_disconnect,
- &start_cb,
+ &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
diff --git a/src/transport/test_transport_startonly.c b/src/transport/test_transport_startonly.c
index 1349a0c4d..c6215c9bc 100644
--- a/src/transport/test_transport_startonly.c
+++ b/src/transport/test_transport_startonly.c
@@ -54,7 +54,7 @@ GNUNET_SCHEDULER_TaskIdentifier timeout_task;
static struct PeerContext *p1;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
static int connected = GNUNET_NO;
@@ -92,8 +92,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n",
GNUNET_i2s (peer));
@@ -110,8 +109,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n");
}
@@ -130,8 +128,10 @@ run (void *cls, char *const *args, const char *cfgfile,
while (i <= ITERATIONS)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n");
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_startonly.conf", 1,
- &notify_receive, &notify_connect,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_startonly.conf",
+ 1, &notify_receive,
+ &notify_connect,
&notify_disconnect, NULL, p1);
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c
index 266933580..996ea0543 100644
--- a/src/transport/test_transport_testing.c
+++ b/src/transport/test_transport_testing.c
@@ -55,7 +55,7 @@ static struct PeerContext *p2;
static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
-struct GNUNET_TRANSPORT_TESTING_handle * tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
static int connected = GNUNET_NO;
@@ -94,9 +94,10 @@ end_badly ()
static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
- char * ps = strdup (GNUNET_i2s(&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to peer %u (`%s')!\n",
- p1->no, ps,
+ char *ps = strdup (GNUNET_i2s (&p1->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s') connected to peer %u (`%s')!\n", p1->no, ps,
p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (ps);
GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -104,8 +105,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n",
GNUNET_i2s (peer));
@@ -122,29 +122,29 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n");
}
-void start_cb (struct PeerContext * p,
- void *cls)
+void
+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_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+ GNUNET_i2s (&p->id));
if (started != 2)
return;
char *sender_c = 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_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));
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
NULL);
@@ -161,34 +161,30 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n");
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf",
- 1,
- &notify_receive, &notify_connect,
- &notify_disconnect,
- &start_cb,
- p1);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf",
- 2,
- &notify_receive, &notify_connect,
- &notify_disconnect,
- &start_cb,
- p2);
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer1.conf",
+ 1, &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb, p1);
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer2.conf",
+ 2, &notify_receive, &notify_connect,
+ &notify_disconnect, &start_cb, p2);
if (p1 == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer1 was not started successfully\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer1 was not started successfully\n");
if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(timeout_task);
- timeout_task =
- GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ GNUNET_SCHEDULER_cancel (timeout_task);
+ timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
if (p2 == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer2 was not started successfully\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer2 was not started successfully\n");
if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel(timeout_task);
- timeout_task =
- GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ GNUNET_SCHEDULER_cancel (timeout_task);
+ timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index a4eba609d..b23879032 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -31,11 +31,11 @@
static struct PeerContext *
-find_peer_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth,
- const struct GNUNET_PeerIdentity *peer)
+find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+ const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert (tth != NULL);
- struct PeerContext * t = tth->p_head;
+ struct PeerContext *t = tth->p_head;
while (t != NULL)
{
@@ -48,17 +48,16 @@ find_peer_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth,
}
struct ConnectingContext *
-find_connecting_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext * p2)
+find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+ struct PeerContext *p1, struct PeerContext *p2)
{
GNUNET_assert (tth != NULL);
- struct ConnectingContext * cc = tth->cc_head;
+ struct ConnectingContext *cc = tth->cc_head;
while (cc != NULL)
{
if ((cc->p1 == p1) && (cc->p2 == p2))
- break;
+ break;
if ((cc->p1 == p2) && (cc->p2 == p1))
break;
cc = cc->next;
@@ -69,14 +68,14 @@ find_connecting_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth,
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct PeerContext *p = cls;
+
/* Find PeerContext */
GNUNET_assert (p != 0);
GNUNET_assert (p->tth != NULL);
- struct PeerContext * p2 = find_peer_context (p->tth, peer);
+ struct PeerContext *p2 = find_peer_context (p->tth, peer);
if (p == NULL)
return;
@@ -84,21 +83,22 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
p->nc (p->cb_cls, peer, ats, ats_count);
#if VERBOSE
- char * p2_s;
+ char *p2_s;
+
if (p2 != NULL)
- GNUNET_asprintf(&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf(&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Peers %s connected to peer %u (`%s')\n",
- p2_s,
- p->no, GNUNET_i2s (&p->id));
+ "Peers %s connected to peer %u (`%s')\n", p2_s, p->no,
+ GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
#endif
/* Find ConnectingContext */
- struct ConnectingContext * cc = find_connecting_context(p->tth, p, p2);
+ struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2);
+
if (cc == NULL)
return;
@@ -106,12 +106,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
cc->p1_c = GNUNET_YES;
if (p == cc->p2)
- cc->p2_c = GNUNET_YES;
+ cc->p2_c = GNUNET_YES;
if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
{
cc->cb (cc->p1, cc->p2, cc->cb_cls);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(p->tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc);
}
}
@@ -119,9 +119,10 @@ static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
+
/* Find PeerContext */
int no = 0;
- struct PeerContext * p2 = NULL;
+ struct PeerContext *p2 = NULL;
if (p != NULL)
{
@@ -130,15 +131,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
no = p->no;
}
- char * p2_s;
+ char *p2_s;
+
if (p2 != NULL)
- GNUNET_asprintf(&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf(&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Peers %s disconnected from peer %u (`%s')\n",
- p2_s,
- no , GNUNET_i2s (&p->id));
+ "Peers %s disconnected from peer %u (`%s')\n", p2_s, no,
+ GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
if (p == NULL)
@@ -150,8 +151,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct PeerContext *p = cls;
@@ -170,25 +170,25 @@ get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message)
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &p->id));
- size_t size = GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *) message);
+ size_t size =
+ GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) message);
GNUNET_free_non_null (p->hello);
- p->hello = (struct GNUNET_HELLO_Message*) GNUNET_copy_message (message);
+ p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message);
#if VERBOSE
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "transport-testing",
- "New HELLO for peer %u (`%s') with size %u\n",
- p->no, GNUNET_i2s (&p->id), size);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "New HELLO for peer %u (`%s') with size %u\n", p->no,
+ GNUNET_i2s (&p->id), size);
#endif
if (p->start_cb != NULL)
{
#if VERBOSE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Peer %u (`%s') successfully started\n",
- p->no, GNUNET_i2s (&p->id));
+ "Peer %u (`%s') successfully started\n", p->no,
+ GNUNET_i2s (&p->id));
#endif
- p->start_cb(p, p->cb_cls);
+ p->start_cb (p, p->cb_cls);
p->start_cb = NULL;
}
}
@@ -205,15 +205,17 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- char * p2_s = GNUNET_strdup(GNUNET_i2s (&p2->id));
+ char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
- p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s,
- GNUNET_HELLO_size (cc->p2->hello));
+ "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
+ p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s,
+ GNUNET_HELLO_size (cc->p2->hello));
GNUNET_free (p2_s);
GNUNET_TRANSPORT_offer_hello (cc->th_p1,
- (const struct GNUNET_MessageHeader *) cc->p2->hello, NULL, NULL);
+ (const struct GNUNET_MessageHeader *) cc->
+ p2->hello, NULL, NULL);
GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id);
cc->tct =
@@ -230,9 +232,8 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* @return the peer context
*/
struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth,
- const char *cfgname,
- int peer_id,
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, const char *cfgname, int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
@@ -243,7 +244,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt
if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
- "File not found: `%s' \n", cfgname);
+ "File not found: `%s' \n", cfgname);
return NULL;
}
@@ -253,8 +254,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME",
- &p->servicehome));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
+ "SERVICEHOME",
+ &p->servicehome));
if (NULL != p->servicehome)
GNUNET_DISK_directory_remove (p->servicehome);
p->arm_proc =
@@ -286,7 +289,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt
p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
GNUNET_assert (p->ghh != NULL);
- GNUNET_CONTAINER_DLL_insert(tth->p_head, tth->p_tail, p);
+ GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p);
return p;
}
@@ -296,7 +299,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt
* @param p the peer
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth,
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
struct PeerContext *p)
{
GNUNET_assert (p != NULL);
@@ -346,12 +349,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth
* @return connect context
*/
GNUNET_TRANSPORT_TESTING_ConnectRequest
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * tth,
- struct PeerContext *p1,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, struct PeerContext *p1,
struct PeerContext *p2,
GNUNET_TRANSPORT_TESTING_connect_cb cb,
void *cb_cls)
-
{
GNUNET_assert (tth != NULL);
@@ -377,7 +379,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "New connect request %X\n", cc);
+ "New connect request %X\n", cc);
return cc;
}
@@ -387,16 +389,19 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
* Tou MUST cancel the request if you stop the peers before the peers connected succesfully
* @param cc a connect request handle
*/
-void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
- (struct GNUNET_TRANSPORT_TESTING_handle * tth,
- GNUNET_TRANSPORT_TESTING_ConnectRequest ccr)
+void
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct
+ GNUNET_TRANSPORT_TESTING_handle
+ *tth,
+ GNUNET_TRANSPORT_TESTING_ConnectRequest
+ ccr)
{
struct ConnectingContext *cc = ccr;
GNUNET_assert (tth != NULL);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Canceling connect request %X!\n", cc);
+ "Canceling connect request %X!\n", cc);
if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (cc->tct);
@@ -412,7 +417,7 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
* @param tth transport testing handle
*/
void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth)
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
{
struct ConnectingContext *cc = tth->cc_head;
struct ConnectingContext *ct = NULL;
@@ -425,8 +430,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth)
{
ct = cc->next;
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
- "Developer forgot to cancel connect request %X!\n", cc);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ "Developer forgot to cancel connect request %X!\n", cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = ct;
}
@@ -434,7 +439,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth)
{
t = p->next;
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
- "Developer forgot to stop peer!\n");
+ "Developer forgot to stop peer!\n");
GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
p = t;
}
@@ -450,7 +455,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth)
struct GNUNET_TRANSPORT_TESTING_handle *
GNUNET_TRANSPORT_TESTING_init ()
{
- struct GNUNET_TRANSPORT_TESTING_handle * tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
+ struct GNUNET_TRANSPORT_TESTING_handle *tth =
+ GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
return tth;
}
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index ed9238ecb..8e5d55dcd 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -65,10 +65,10 @@ struct GNUNET_TRANSPORT_TESTING_handle;
*/
struct PeerContext
{
- struct PeerContext * next;
- struct PeerContext * prev;
+ struct PeerContext *next;
+ struct PeerContext *prev;
- struct GNUNET_TRANSPORT_TESTING_handle * tth;
+ struct GNUNET_TRANSPORT_TESTING_handle *tth;
struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -100,8 +100,8 @@ struct PeerContext
struct ConnectingContext
{
- struct ConnectingContext * next;
- struct ConnectingContext * prev;
+ struct ConnectingContext *next;
+ struct ConnectingContext *prev;
struct PeerContext *p1;
struct PeerContext *p2;
GNUNET_SCHEDULER_TaskIdentifier tct;
@@ -115,11 +115,11 @@ struct ConnectingContext
struct GNUNET_TRANSPORT_TESTING_handle
{
- struct ConnectingContext * cc_head;
- struct ConnectingContext * cc_tail;
+ struct ConnectingContext *cc_head;
+ struct ConnectingContext *cc_tail;
- struct PeerContext * p_head;
- struct PeerContext * p_tail;
+ struct PeerContext *p_head;
+ struct PeerContext *p_tail;
};
@@ -134,9 +134,8 @@ struct GNUNET_TRANSPORT_TESTING_handle
* @return the peer context
*/
struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth,
- const char *cfgname,
- int peer_id,
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, const char *cfgname, int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
@@ -150,7 +149,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth,
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
struct PeerContext *pc);
@@ -165,8 +164,8 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth
* @return a connect request handle
*/
GNUNET_TRANSPORT_TESTING_ConnectRequest
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * tth,
- struct PeerContext *p1,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, struct PeerContext *p1,
struct PeerContext *p2,
GNUNET_TRANSPORT_TESTING_connect_cb cb,
void *cls);
@@ -177,15 +176,16 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
* @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *,
- void *cc);
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct
+ GNUNET_TRANSPORT_TESTING_handle
+ *, void *cc);
/**
* Clean up the transport testing
* @param tth transport testing handle
*/
void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth);
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth);
/**
* Initialize the transport testing
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index cff967b19..b7704e512 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -473,7 +473,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
GNUNET_break (0);
break;
}
- ats = (const struct GNUNET_ATS_Information*) &cim[1];
+ ats = (const struct GNUNET_ATS_Information *) &cim[1];
#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
"CONNECT", GNUNET_i2s (&cim->id));
@@ -547,7 +547,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
}
im = (const struct InboundMessage *) msg;
ats_count = ntohl (im->ats_count);
- ats = (const struct GNUNET_ATS_Information*) &im[1];
+ ats = (const struct GNUNET_ATS_Information *) &im[1];
imm = (const struct GNUNET_MessageHeader *) &ats[ats_count];
if (ntohs (imm->size) + sizeof (struct InboundMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) != size)
diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c
index 2ffe1ada8..3c3f97c28 100644
--- a/src/transport/transport_api_address_iterate.c
+++ b/src/transport/transport_api_address_iterate.c
@@ -80,7 +80,8 @@ peer_address_response_processor (void *cls,
struct AddressLookupCtx *alucb = cls;
struct AddressIterateResponseMessage *address;
uint16_t size;
- char * transport;
+ char *transport;
+
//size_t transport_len;
//void * addr;
size_t addrlen;
@@ -120,7 +121,7 @@ peer_address_response_processor (void *cls,
transport = (char *) &address[0];
//transport_len = ntohs(address->pluginlen);
- addrlen = ntohs(address->addrlen);
+ addrlen = ntohs (address->addrlen);
/* expect more replies */
GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,