summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c39
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c2
-rw-r--r--src/transport/gnunet-service-transport_clients.c43
-rw-r--r--src/transport/gnunet-service-transport_hello.c15
-rw-r--r--src/transport/gnunet-service-transport_hello.h4
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c463
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h19
-rw-r--r--src/transport/gnunet-service-transport_plugins.c17
-rw-r--r--src/transport/gnunet-service-transport_validation.c146
-rw-r--r--src/transport/gnunet-service-transport_validation.h18
-rw-r--r--src/transport/gnunet-transport-wlan-helper-dummy.c47
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c1033
-rw-r--r--src/transport/gnunet-transport.c38
-rw-r--r--src/transport/plugin_transport_http.c41
-rw-r--r--src/transport/plugin_transport_http_server.c49
-rw-r--r--src/transport/plugin_transport_udp.c301
-rw-r--r--src/transport/plugin_transport_wlan.c23
-rw-r--r--src/transport/test_quota_compliance.c3
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c10
-rw-r--r--src/transport/test_transport_api_disconnect.c2
-rw-r--r--src/transport/test_transport_api_restart_1peer.c28
-rw-r--r--src/transport/test_transport_api_restart_2peers.c30
-rw-r--r--src/transport/test_transport_api_unreliability.c7
-rw-r--r--src/transport/transport-testing.c90
-rw-r--r--src/transport/transport-testing.h8
-rw-r--r--src/transport/transport.h2
-rw-r--r--src/transport/transport_api_address_lookup.c43
-rw-r--r--src/transport/transport_api_address_to_string.c22
28 files changed, 1264 insertions, 1279 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index b148f289b..d4d8828d0 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -90,7 +90,7 @@ static void
transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address)
{
const struct GNUNET_MessageHeader *hello = cls;
@@ -136,7 +136,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
size_t msg_size = ntohs (message->size);
size_t size =
sizeof (struct InboundMessage) + msg_size +
- sizeof (struct GNUNET_ATS_Information) * (ats_count + 1);
+ sizeof (struct GNUNET_ATS_Information) * (ats_count + 1);
char buf[size];
struct GNUNET_ATS_Information *ap;
@@ -168,10 +168,11 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
ap = (struct GNUNET_ATS_Information *) &im[1];
memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- ap[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
+ ap[ats_count].value =
+ htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
memcpy (&ap[ats_count + 1], message, ntohs (message->size));
- GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count +1 );
+ GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count + 1);
GST_clients_broadcast (&im->header, GNUNET_YES);
return ret;
@@ -202,8 +203,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
* (plugins that do not support this, can ignore the return value)
*/
static struct GNUNET_TIME_Relative
-plugin_env_receive_callback (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count, struct Session *session,
@@ -237,8 +237,8 @@ plugin_env_receive_callback (void *cls,
#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 (&address)
- : "<inbound>");
+ (sender_address !=
+ NULL) ? GST_plugins_a2s (&address) : "<inbound>");
#endif
GST_validation_handle_ping (peer, message, &address, session);
break;
@@ -246,20 +246,22 @@ plugin_env_receive_callback (void *cls,
#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 (&address)
- : "<inbound>");
+ (sender_address !=
+ NULL) ? GST_plugins_a2s (&address) : "<inbound>");
#endif
GST_validation_handle_pong (peer, message);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
- GST_neighbours_handle_connect (message, peer, &address, session, ats, ats_count);
+ GST_neighbours_handle_connect (message, peer, &address, session, ats,
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
- GST_neighbours_handle_connect_ack (message, peer, &address,
- session, ats, ats_count);
+ GST_neighbours_handle_connect_ack (message, peer, &address, session, ats,
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
- GST_neighbours_handle_ack (message, peer, &address, session, ats, ats_count);
+ GST_neighbours_handle_ack (message, peer, &address, session, ats,
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
GST_neighbours_handle_disconnect_message (peer, message);
@@ -336,7 +338,7 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
const char *transport_name = cls;
struct GNUNET_HELLO_Address address;
- GNUNET_assert (strlen(transport_name) > 0);
+ GNUNET_assert (strlen (transport_name) > 0);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
session, GNUNET_i2s (peer));
@@ -369,8 +371,8 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer
*/
static void
-ats_request_address_change (void *cls,
- const struct GNUNET_HELLO_Address *address,
+ats_request_address_change (void *cls,
+ const struct GNUNET_HELLO_Address *address,
struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -392,8 +394,7 @@ ats_request_address_change (void *cls,
return;
}
/* will never return GNUNET_YES since connection is to be established */
- GST_neighbours_switch_to_address_3way (&address->peer,
- address, session, ats,
+ GST_neighbours_switch_to_address_3way (&address->peer, address, session, ats,
ats_count, bandwidth_in,
bandwidth_out);
}
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index b3edc01db..105f1fcaf 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -556,7 +556,7 @@ static void
test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address)
{
struct TestConnectionContext *tcc = cls;
struct GST_BlacklistCheck *bc;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 2aea7aa7e..da6201d97 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -331,8 +331,8 @@ static void
notify_client_about_neighbour (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ uint32_t ats_count,
+ const struct GNUNET_HELLO_Address *address)
{
struct TransportClient *tc = cls;
struct ConnectInfoMessage *cim;
@@ -633,8 +633,9 @@ transmit_address_to_client (void *cls, const char *buf)
* @param message the resolution request
*/
static void
-clients_handle_address_to_string (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+clients_handle_address_to_string (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
const struct AddressLookupMessage *alum;
struct GNUNET_TRANSPORT_PluginFunctions *papi;
@@ -699,34 +700,38 @@ clients_handle_address_to_string (void *cls, struct GNUNET_SERVER_Client *client
*/
static void
output_address (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
+ const struct GNUNET_HELLO_Address *address)
{
struct GNUNET_SERVER_TransmitContext *tc = cls;
struct AddressIterateResponseMessage *msg;
size_t size;
size_t tlen;
size_t alen;
- char * addr;
+ char *addr;
tlen = strlen (address->transport_name) + 1;
alen = address->address_length;
size = (sizeof (struct AddressIterateResponseMessage) + alen + tlen);
{
char buf[size];
-
- msg = (struct AddressIterateResponseMessage*) buf;
+
+ msg = (struct AddressIterateResponseMessage *) buf;
msg->reserved = htonl (0);
msg->peer = *peer;
msg->addrlen = htonl (alen);
msg->pluginlen = htonl (tlen);
addr = (char *) &msg[1];
- memcpy (addr,address->address, alen);
+ memcpy (addr, address->address, alen);
memcpy (&addr[alen], address->transport_name, tlen);
- GNUNET_SERVER_transmit_context_append_data (tc,
- &buf[sizeof(struct GNUNET_MessageHeader)],
- size - sizeof (struct GNUNET_MessageHeader),
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
+ GNUNET_SERVER_transmit_context_append_data (tc,
+ &buf[sizeof
+ (struct
+ GNUNET_MessageHeader)],
+ size -
+ sizeof (struct
+ GNUNET_MessageHeader),
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
}
}
@@ -746,7 +751,7 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
{
static struct GNUNET_PeerIdentity all_zeros;
struct GNUNET_SERVER_TransmitContext *tc;
- struct AddressIterateMessage * msg;
+ struct AddressIterateMessage *msg;
struct GNUNET_HELLO_Address *address;
if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE)
@@ -765,7 +770,7 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
if (GNUNET_YES != ntohl (msg->one_shot))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Address monitoring not implemented\n");
+ "Address monitoring not implemented\n");
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
@@ -779,12 +784,12 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
else
{
/* just return one neighbour */
- address = GST_neighbour_get_current_address(&msg->peer);
+ address = GST_neighbour_get_current_address (&msg->peer);
if (address != NULL)
output_address (tc, &msg->peer, NULL, 0, address);
}
GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
}
@@ -809,7 +814,7 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server)
sizeof (struct TransportRequestConnectMessage)},
{&clients_handle_address_to_string, NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0},
- {&clients_handle_address_iterate, NULL,
+ {&clients_handle_address_iterate, NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE,
sizeof (struct AddressIterateMessage)},
{&GST_blacklist_handle_init, NULL,
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index 8b38a673e..120f17668 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -138,8 +138,8 @@ address_generator (void *cls, size_t max, void *buf)
if (NULL == gc->addr_pos)
return 0;
ret =
- GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration,
- buf, max);
+ GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, buf,
+ max);
gc->addr_pos = gc->addr_pos->next;
return ret;
}
@@ -251,7 +251,7 @@ GST_hello_get ()
*/
void
GST_hello_modify_addresses (int addremove,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address)
{
struct OwnAddressList *al;
@@ -266,10 +266,8 @@ GST_hello_modify_addresses (int addremove,
if (GNUNET_NO == addremove)
{
for (al = oal_head; al != NULL; al = al->next)
- if (0 ==
- GNUNET_HELLO_address_cmp (address,
- al->address))
- {
+ if (0 == GNUNET_HELLO_address_cmp (address, al->address))
+ {
GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al);
GNUNET_HELLO_address_free (al->address);
GNUNET_free (al);
@@ -305,8 +303,7 @@ GST_hello_test_address (const struct GNUNET_HELLO_Address *address,
struct OwnAddressList *al;
for (al = oal_head; al != NULL; al = al->next)
- if (0 == GNUNET_HELLO_address_cmp (address,
- al->address))
+ if (0 == GNUNET_HELLO_address_cmp (address, al->address))
{
*sig = &al->pong_signature;
*sig_expiration = &al->pong_sig_expires;
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h
index 168dd4364..605d19861 100644
--- a/src/transport/gnunet-service-transport_hello.h
+++ b/src/transport/gnunet-service-transport_hello.h
@@ -76,8 +76,8 @@ GST_hello_get (void);
* @param address address to add or remove
*/
void
-GST_hello_modify_addresses (int addremove,
- const struct GNUNET_HELLO_Address *address);
+GST_hello_modify_addresses (int addremove,
+ const struct GNUNET_HELLO_Address *address);
/**
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 3024d8bc1..a0f6e2e42 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -190,22 +190,22 @@ struct MessageQueue
enum State
{
/**
- * fresh peer or completely disconnected
+ * fresh peer or completely disconnected
*/
S_NOT_CONNECTED,
/**
- * sent CONNECT message to other peer, waiting for CONNECT_ACK
+ * sent CONNECT message to other peer, waiting for CONNECT_ACK
*/
S_CONNECT_SENT,
/**
- * received CONNECT message to other peer, sending CONNECT_ACK
+ * received CONNECT message to other peer, sending CONNECT_ACK
*/
S_CONNECT_RECV,
/**
- * received ACK or payload
+ * received ACK or payload
*/
S_CONNECTED,
@@ -215,7 +215,7 @@ enum State
S_FAST_RECONNECT,
/**
- * Disconnect in progress
+ * Disconnect in progress
*/
S_DISCONNECT
};
@@ -452,6 +452,7 @@ static void
reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct NeighbourMapEntry *n = cls;
+
if (n == NULL)
return;
@@ -472,7 +473,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
/* destroying address */
if (n->address != NULL)
{
- GNUNET_assert (strlen(n->address->transport_name) > 0);
+ GNUNET_assert (strlen (n->address->transport_name) > 0);
GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session);
}
@@ -522,6 +523,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
{
char *old = GNUNET_strdup (print_state (n->state));
char *new = GNUNET_strdup (print_state (state));
+
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Illegal state transition from `%s' to `%s' in line %u \n", old,
new, line);
@@ -534,6 +536,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
{
char *old = GNUNET_strdup (print_state (n->state));
char *new = GNUNET_strdup (print_state (state));
+
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n",
GNUNET_i2s (&n->id), n, old, new, line);
@@ -551,8 +554,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
if (n->state_reset != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->state_reset);
n->state_reset =
- GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task,
- n);
+ GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, n);
break;
case S_CONNECTED:
case S_NOT_CONNECTED:
@@ -562,10 +564,10 @@ change (struct NeighbourMapEntry *n, int state, int line)
#if DEBUG_TRANSPORT
char *old = GNUNET_strdup (print_state (n->state));
char *new = GNUNET_strdup (print_state (state));
+
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->address),
- old, new);
+ "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), old, new);
GNUNET_free (old);
GNUNET_free (new);
#endif
@@ -578,7 +580,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
default:
GNUNET_assert (0);
}
-
+
return GNUNET_OK;
@@ -588,9 +590,8 @@ 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 struct GNUNET_HELLO_Address *address,
- int force_address, GNUNET_TRANSPORT_TransmitContinuation cont,
- void *cont_cls)
+ const struct GNUNET_HELLO_Address *address, int force_address,
+ GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
size_t ret = GNUNET_SYSERR;
@@ -620,8 +621,8 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
ret =
papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session,
- address->address,
- address->address_length, GNUNET_YES, cont, cont_cls);
+ address->address, address->address_length, GNUNET_YES, cont,
+ cont_cls);
if (ret == -1)
{
@@ -657,7 +658,7 @@ transmit_send_continuation (void *cls,
struct NeighbourMapEntry *n;
struct NeighbourMapEntry *tmp;
- tmp = lookup_neighbour(receiver);
+ tmp = lookup_neighbour (receiver);
mq = cls;
n = mq->n;
@@ -720,8 +721,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
if (n->address == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No address for peer `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
GNUNET_i2s (&n->id));
transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
@@ -740,8 +740,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
if ((n->address->address_length == 0) && (n->session == NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No address for peer `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
GNUNET_i2s (&n->id));
transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
@@ -751,9 +750,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
ret =
send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0,
- timeout, n->session, n->address,
- GNUNET_YES, &transmit_send_continuation,
- mq);
+ timeout, n->session, n->address, GNUNET_YES,
+ &transmit_send_continuation, mq);
if (ret == -1)
{
/* failure, but 'send' would not call continuation in this case,
@@ -826,7 +824,8 @@ send_disconnect (const struct GNUNET_PeerIdentity *target,
#endif
disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage));
- disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
+ disconnect_msg.header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
disconnect_msg.reserved = htonl (0);
disconnect_msg.purpose.size =
htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
@@ -846,8 +845,7 @@ send_disconnect (const struct GNUNET_PeerIdentity *target,
send_with_plugin (target, (const char *) &disconnect_msg,
sizeof (disconnect_msg), UINT32_MAX,
GNUNET_TIME_UNIT_FOREVER_REL, session, address,
- GNUNET_YES,
- &send_disconnect_cont, NULL);
+ GNUNET_YES, &send_disconnect_cont, NULL);
if (ret == GNUNET_SYSERR)
return GNUNET_SYSERR;
@@ -880,9 +878,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
/* send DISCONNECT MESSAGE */
if ((previous_state == S_CONNECTED) || is_connecting (n))
{
- if (GNUNET_OK ==
- send_disconnect (&n->id, n->address,
- n->session))
+ if (GNUNET_OK == send_disconnect (&n->id, n->address, n->session))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n",
GNUNET_i2s (&n->id));
else
@@ -898,9 +894,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
GNUNET_assert (NULL != n->address);
if (n->address_state == USED)
{
- GST_validation_set_address_use (&n->id,
- n->address,
- n->session,
+ GST_validation_set_address_use (&n->id, n->address, n->session,
GNUNET_NO);
GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
@@ -911,6 +905,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
if (n->address != NULL)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
+
papi = GST_plugins_find (n->address->transport_name);
if (papi != NULL)
papi->disconnect (papi->cls, &n->id);
@@ -928,27 +923,27 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
n->is_active = NULL;
}
- switch (previous_state) {
- case S_CONNECTED:
+ switch (previous_state)
+ {
+ case S_CONNECTED:
// GNUNET_assert (neighbours_connected > 0);
- neighbours_connected--;
- GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task);
- GNUNET_SCHEDULER_cancel (n->keepalive_task);
- n->keepalive_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
- GNUNET_NO);
- disconnect_notify_cb (callback_cls, &n->id);
- break;
- case S_FAST_RECONNECT:
- GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
- GNUNET_NO);
- GNUNET_STATISTICS_update (GST_stats,
- gettext_noop
- ("# fast reconnects failed"),
- 1, GNUNET_NO);
- disconnect_notify_cb (callback_cls, &n->id);
- default:
- break;
+ neighbours_connected--;
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task);
+ GNUNET_SCHEDULER_cancel (n->keepalive_task);
+ n->keepalive_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
+ GNUNET_NO);
+ disconnect_notify_cb (callback_cls, &n->id);
+ break;
+ case S_FAST_RECONNECT:
+ GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
+ GNUNET_NO);
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop ("# fast reconnects failed"), 1,
+ GNUNET_NO);
+ disconnect_notify_cb (callback_cls, &n->id);
+ default:
+ break;
}
GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id);
@@ -1030,17 +1025,18 @@ neighbour_keepalive_task (void *cls,
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
- ret = send_with_plugin (&n->id, (const void *) &m, sizeof (m),
- UINT32_MAX /* priority */ ,
- GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
- GNUNET_YES, NULL, NULL);
+ ret =
+ send_with_plugin (&n->id, (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
+ GNUNET_YES, NULL, NULL);
n->expect_latency_response = GNUNET_NO;
- n->keep_alive_sent = GNUNET_TIME_absolute_get_zero();
+ n->keep_alive_sent = GNUNET_TIME_absolute_get_zero ();
if (ret != GNUNET_SYSERR)
{
n->expect_latency_response = GNUNET_YES;
- n->keep_alive_sent = GNUNET_TIME_absolute_get();
+ n->keep_alive_sent = GNUNET_TIME_absolute_get ();
}
}
@@ -1115,19 +1111,22 @@ struct ContinutionContext
struct Session *session;
};
-static void send_outbound_quota (const struct GNUNET_PeerIdentity *target, struct GNUNET_BANDWIDTH_Value32NBO quota)
+static void
+send_outbound_quota (const struct GNUNET_PeerIdentity *target,
+ struct GNUNET_BANDWIDTH_Value32NBO quota)
{
- struct QuotaSetMessage q_msg;
+ struct QuotaSetMessage q_msg;
+
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
- ntohl (quota.value__), GNUNET_i2s (target));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
+ ntohl (quota.value__), GNUNET_i2s (target));
#endif
- q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
- q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
- q_msg.quota = quota;
- q_msg.peer = (*target);
- 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 = quota;
+ q_msg.peer = (*target);
+ GST_clients_broadcast (&q_msg.header, GNUNET_NO);
}
/**
@@ -1143,17 +1142,15 @@ static void
send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
int success)
{
- struct ContinutionContext * cc = cls;
+ struct ContinutionContext *cc = cls;
struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer);
-
+
if (GNUNET_YES != success)
{
- GNUNET_assert (strlen(cc->address->transport_name) > 0);
+ GNUNET_assert (strlen (cc->address->transport_name) > 0);
GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
}
- if ( (NULL == neighbours) ||
- (NULL == n) ||
- (n->state == S_DISCONNECT))
+ if ((NULL == neighbours) || (NULL == n) || (n->state == S_DISCONNECT))
{
GNUNET_HELLO_address_free (cc->address);
GNUNET_free (cc);
@@ -1161,7 +1158,7 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
}
if ((GNUNET_YES == success) &&
- ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
+ ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
{
change_state (n, S_CONNECT_SENT);
GNUNET_HELLO_address_free (cc->address);
@@ -1170,21 +1167,19 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
}
if ((GNUNET_NO == success) &&
- ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
+ ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address),
- n->session);
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
#endif
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_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel,
+ n);
GNUNET_ATS_suggest_address (GST_ats, &n->id);
}
GNUNET_HELLO_address_free (cc->address);
@@ -1205,7 +1200,7 @@ send_switch_address_continuation (void *cls,
const struct GNUNET_PeerIdentity *target,
int success)
{
- struct ContinutionContext * cc = cls;
+ struct ContinutionContext *cc = cls;
struct NeighbourMapEntry *n;
if (neighbours == NULL)
@@ -1215,7 +1210,7 @@ send_switch_address_continuation (void *cls,
return; /* neighbour is going away */
}
- n = lookup_neighbour(&cc->address->peer);
+ n = lookup_neighbour (&cc->address->peer);
if ((n == NULL) || (is_disconnecting (n)))
{
GNUNET_HELLO_address_free (cc->address);
@@ -1229,10 +1224,9 @@ send_switch_address_continuation (void *cls,
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to switch connected peer `%s' to address '%s' session %X, asking ATS for new address \n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address), n->session);
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
#endif
- GNUNET_assert (strlen(cc->address->transport_name) > 0);
+ GNUNET_assert (strlen (cc->address->transport_name) > 0);
GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -1246,49 +1240,48 @@ send_switch_address_continuation (void *cls,
return;
}
/* Tell ATS that switching addresses was successful */
- switch (n->state) {
- case S_CONNECTED:
- if (n->address_state == FRESH)
- {
- GST_validation_set_address_use (&n->id,
- cc->address,
- cc->session,
- GNUNET_YES);
- GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
- GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
- n->address_state = USED;
- }
- break;
- case S_FAST_RECONNECT:
+ switch (n->state)
+ {
+ case S_CONNECTED:
+ if (n->address_state == FRESH)
+ {
+ GST_validation_set_address_use (&n->id, cc->address, cc->session,
+ GNUNET_YES);
+ GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
+ GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
+ n->address_state = USED;
+ }
+ break;
+ case S_FAST_RECONNECT:
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Successful fast reconnect to peer `%s'\n", GNUNET_i2s (&n->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Successful fast reconnect to peer `%s'\n",
+ GNUNET_i2s (&n->id));
#endif
- change_state (n, S_CONNECTED);
- neighbours_connected++;
- GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
- GNUNET_NO);
-
- if (n->address_state == FRESH)
- {
- GST_validation_set_address_use (&n->id,
- cc->address,
- cc->session,
- GNUNET_YES);
- GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
- GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
- n->address_state = USED;
- }
-
- if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
- n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
-
- /* Updating quotas */
- GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
- send_outbound_quota(target, n->bandwidth_out);
-
- default:
- break;
+ change_state (n, S_CONNECTED);
+ neighbours_connected++;
+ GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
+ GNUNET_NO);
+
+ if (n->address_state == FRESH)
+ {
+ GST_validation_set_address_use (&n->id, cc->address, cc->session,
+ GNUNET_YES);
+ GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
+ GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
+ n->address_state = USED;
+ }
+
+ if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
+ n->keepalive_task =
+ GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
+
+ /* Updating quotas */
+ GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
+ send_outbound_quota (target, n->bandwidth_out);
+
+ default:
+ break;
}
GNUNET_HELLO_address_free (cc->address);
GNUNET_free (cc);
@@ -1309,7 +1302,7 @@ send_connect_ack_continuation (void *cls,
const struct GNUNET_PeerIdentity *target,
int success)
{
- struct ContinutionContext * cc = cls;
+ struct ContinutionContext *cc = cls;
struct NeighbourMapEntry *n;
if (neighbours == NULL)
@@ -1319,7 +1312,7 @@ send_connect_ack_continuation (void *cls,
return; /* neighbour is going away */
}
- n = lookup_neighbour(&cc->address->peer);
+ n = lookup_neighbour (&cc->address->peer);
if ((n == NULL) || (is_disconnecting (n)))
{
GNUNET_HELLO_address_free (cc->address);
@@ -1338,12 +1331,10 @@ send_connect_ack_continuation (void *cls,
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %X, asking ATS for new address \n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address),
- n->session);
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
#endif
change_state (n, S_NOT_CONNECTED);
- GNUNET_assert (strlen(cc->address->transport_name) > 0);
+ GNUNET_assert (strlen (cc->address->transport_name) > 0);
GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -1372,8 +1363,8 @@ send_connect_ack_continuation (void *cls,
*/
int
GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session,
+ const struct GNUNET_HELLO_Address
+ *address, struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count,
struct GNUNET_BANDWIDTH_Value32NBO
@@ -1383,7 +1374,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
{
struct NeighbourMapEntry *n;
struct SessionConnectMessage connect_msg;
- struct ContinutionContext * cc;
+ struct ContinutionContext *cc;
size_t msg_len;
size_t ret;
@@ -1401,11 +1392,11 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
return GNUNET_NO;
}
GNUNET_assert (address->transport_name != NULL);
- if ( (session == NULL) && (0 == address->address_length) )
+ if ((session == NULL) && (0 == address->address_length))
{
GNUNET_break_op (0);
/* FIXME: is this actually possible? When does this happen? */
- if (strlen(address->transport_name) > 0)
+ if (strlen (address->transport_name) > 0)
GNUNET_ATS_address_destroyed (GST_ats, address, session);
GNUNET_ATS_suggest_address (GST_ats, peer);
return GNUNET_NO;
@@ -1415,10 +1406,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"ATS tells us to switch to address '%s' session %p for peer `%s' in state `%s'\n",
- GST_plugins_a2s (address),
- session,
- GNUNET_i2s (peer),
- print_state(n->state));
+ GST_plugins_a2s (address), session, GNUNET_i2s (peer),
+ print_state (n->state));
#endif
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
{
@@ -1426,17 +1415,15 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
n->ats_suggest = GNUNET_SCHEDULER_NO_TASK;
}
/* do not switch addresses just update quotas */
- if ( (n->state == S_CONNECTED) &&
- (NULL != n->address) &&
- (0 == GNUNET_HELLO_address_cmp (address,
- n->address)) &&
- (n->session == session) )
+ if ((n->state == S_CONNECTED) && (NULL != n->address) &&
+ (0 == GNUNET_HELLO_address_cmp (address, n->address)) &&
+ (n->session == session))
{
n->bandwidth_in = bandwidth_in;
n->bandwidth_out = bandwidth_out;
GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
- send_outbound_quota(peer, n->bandwidth_out);
- return GNUNET_NO;
+ send_outbound_quota (peer, n->bandwidth_out);
+ return GNUNET_NO;
}
if (n->state == S_CONNECTED)
{
@@ -1444,9 +1431,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
GNUNET_assert (NULL != n->address);
if (n->address_state == USED)
{
- GST_validation_set_address_use (&n->id,
- n->address,
- n->session,
+ GST_validation_set_address_use (&n->id, n->address, n->session,
GNUNET_NO);
GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
n->address_state = UNUSED;
@@ -1468,7 +1453,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
&neighbour_timeout_task, n);
switch (n->state)
{
- case S_NOT_CONNECTED:
+ case S_NOT_CONNECTED:
case S_CONNECT_SENT:
msg_len = sizeof (struct SessionConnectMessage);
connect_msg.header.size = htons (msg_len);
@@ -1478,15 +1463,13 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
connect_msg.timestamp =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- cc = GNUNET_malloc(sizeof (struct ContinutionContext));
+ cc = GNUNET_malloc (sizeof (struct ContinutionContext));
cc->session = session;
cc->address = GNUNET_HELLO_address_copy (address);
ret =
send_with_plugin (peer, (const char *) &connect_msg, msg_len,
UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
- address, GNUNET_YES,
- &send_connect_continuation,
- cc);
+ address, GNUNET_YES, &send_connect_continuation, cc);
return GNUNET_NO;
case S_CONNECT_RECV:
/* We received a CONNECT message and asked ATS for an address */
@@ -1497,18 +1480,18 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
connect_msg.reserved = htonl (0);
connect_msg.timestamp =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- cc = GNUNET_malloc(sizeof (struct ContinutionContext));
+ cc = GNUNET_malloc (sizeof (struct ContinutionContext));
cc->session = session;
cc->address = GNUNET_HELLO_address_copy (address);
ret =
send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
- address, GNUNET_YES,
- &send_connect_ack_continuation, cc);
+ address, GNUNET_YES, &send_connect_ack_continuation,
+ cc);
return GNUNET_NO;
case S_CONNECTED:
case S_FAST_RECONNECT:
- /* connected peer is switching addresses or tries fast reconnect*/
+ /* connected peer is switching addresses or tries fast reconnect */
msg_len = sizeof (struct SessionConnectMessage);
connect_msg.header.size = htons (msg_len);
connect_msg.header.type =
@@ -1516,7 +1499,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
connect_msg.reserved = htonl (0);
connect_msg.timestamp =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- cc = GNUNET_malloc(sizeof (struct ContinutionContext));
+ cc = GNUNET_malloc (sizeof (struct ContinutionContext));
cc->session = session;
cc->address = GNUNET_HELLO_address_copy (address);
ret =
@@ -1528,13 +1511,12 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MESSAGE to `%4s' using address '%s' session %X\n",
- GNUNET_i2s (peer),
- GST_plugins_a2s (address), session);
+ GNUNET_i2s (peer), GST_plugins_a2s (address), session);
}
return GNUNET_NO;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid connection state to switch addresses %u \n", n->state);
+ "Invalid connection state to switch addresses %u \n", n->state);
GNUNET_break_op (0);
return GNUNET_NO;
}
@@ -1544,7 +1526,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
/**
* Obtain current latency information for the given neighbour.
*
- * @param peer
+ * @param peer
* @return observed latency of the address, FOREVER if the address was
* never successfully validated
*/
@@ -1554,8 +1536,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
struct NeighbourMapEntry *n;
n = lookup_neighbour (peer);
- if ( (NULL == n) ||
- ( (n->address == NULL) && (n->session == NULL) ) )
+ if ((NULL == n) || ((n->address == NULL) && (n->session == NULL)))
return GNUNET_TIME_UNIT_FOREVER_REL;
return n->latency;
@@ -1573,8 +1554,7 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer)
struct NeighbourMapEntry *n;
n = lookup_neighbour (peer);
- if ( (NULL == n) ||
- ( (n->address == NULL) && (n->session == NULL) ) )
+ if ((NULL == n) || ((n->address == NULL) && (n->session == NULL)))
return NULL;
return n->address;
@@ -1600,7 +1580,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
n->id = *peer;
n->state = S_NOT_CONNECTED;
- n->latency = GNUNET_TIME_relative_get_forever();
+ n->latency = GNUNET_TIME_relative_get_forever ();
GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
MAX_BANDWIDTH_CARRY_S);
@@ -1718,11 +1698,9 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
{
if (n->address_state == USED)
{
- GST_validation_set_address_use (&n->id,
- n->address,
- n->session,
+ GST_validation_set_address_use (&n->id, n->address, n->session,
GNUNET_NO);
- GNUNET_ATS_address_in_use (GST_ats,n->address, n->session, GNUNET_NO);
+ GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
n->address_state = UNUSED;
}
}
@@ -1733,15 +1711,15 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
n->address = NULL;
}
n->session = NULL;
-
+
/* not connected anymore anyway, shouldn't matter */
if (S_CONNECTED != n->state)
return;
/* connected, try fast reconnect */
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying fast reconnect to peer `%s'\n", GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying fast reconnect to peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
change_state (n, S_FAST_RECONNECT);
GNUNET_assert (neighbours_connected > 0);
@@ -1814,7 +1792,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
return;
}
- if ((n->session == NULL) && (n->address == NULL) )
+ if ((n->session == NULL) && (n->address == NULL))
{
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
@@ -1983,6 +1961,7 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
return;
struct GNUNET_MessageHeader m;
+
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE);
@@ -2002,11 +1981,11 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
*/
void
GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information * ats,
+ const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
{
struct NeighbourMapEntry *n;
- struct GNUNET_ATS_Information * ats_new;
+ struct GNUNET_ATS_Information *ats_new;
uint32_t latency;
if (neighbours == NULL)
@@ -2034,22 +2013,26 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
}
n->expect_latency_response = GNUNET_NO;
- GNUNET_assert (n->keep_alive_sent.abs_value != GNUNET_TIME_absolute_get_zero().abs_value);
- n->latency = GNUNET_TIME_absolute_get_difference(n->keep_alive_sent, GNUNET_TIME_absolute_get());
+ GNUNET_assert (n->keep_alive_sent.abs_value !=
+ GNUNET_TIME_absolute_get_zero ().abs_value);
+ n->latency =
+ GNUNET_TIME_absolute_get_difference (n->keep_alive_sent,
+ GNUNET_TIME_absolute_get ());
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Latency for peer `%s' is %llu ms\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Latency for peer `%s' is %llu ms\n",
GNUNET_i2s (&n->id), n->latency.rel_value);
#endif
- if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value)
+ if (n->latency.rel_value == GNUNET_TIME_relative_get_forever ().rel_value)
{
GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count);
}
else
{
- ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * (ats_count + 1));
+ ats_new =
+ GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) *
+ (ats_count + 1));
memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
/* add latency */
@@ -2060,7 +2043,8 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
latency = n->latency.rel_value;
ats_new[ats_count].value = htonl (latency);
- GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats_new, ats_count + 1);
+ GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats_new,
+ ats_count + 1);
GNUNET_free (ats_new);
}
}
@@ -2314,10 +2298,11 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
{
/* we did not send 'CONNECT' -- at least not recently */
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# unexpected CONNECT_ACK messages (no peer)"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# unexpected CONNECT_ACK messages (no peer)"),
+ 1, GNUNET_NO);
return;
- }
+ }
/* Additional check
*
@@ -2326,11 +2311,13 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
* We also received an CONNECT message, switched from SENDT to RECV and
* ATS already suggested us an address after a successful blacklist check
*/
- if ((n->state != S_CONNECT_SENT) && ((n->state != S_CONNECT_RECV) && (n->address != NULL)))
+ if ((n->state != S_CONNECT_SENT) &&
+ ((n->state != S_CONNECT_RECV) && (n->address != NULL)))
{
GNUNET_STATISTICS_update (GST_stats,
- gettext_noop ("# unexpected CONNECT_ACK messages"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# unexpected CONNECT_ACK messages"), 1,
+ GNUNET_NO);
return;
}
@@ -2347,10 +2334,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
GNUNET_assert (NULL != n->address);
if (n->address_state == FRESH)
{
- GST_validation_set_address_use (&n->id,
- n->address,
- n->session,
- GNUNET_YES);
+ GST_validation_set_address_use (&n->id, n->address, n->session, GNUNET_YES);
GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
n->address_state = USED;
}
@@ -2364,32 +2348,29 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
ret =
send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
- GNUNET_TIME_UNIT_FOREVER_REL, n->session,
- n->address, GNUNET_YES, NULL,
- NULL);
+ GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
+ GNUNET_YES, NULL, NULL);
if (ret == GNUNET_SYSERR)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send SESSION_ACK to `%4s' using address '%s' session %X\n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address), n->session);
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
-
+
neighbours_connected++;
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
- GNUNET_NO);
+ GNUNET_NO);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address), n->session,
- __LINE__);
+ "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
+ __LINE__);
#endif
- connect_notify_cb (callback_cls, &n->id, ats, ats_count);
- send_outbound_quota(peer, n->bandwidth_out);
+ connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+ send_outbound_quota (peer, n->bandwidth_out);
}
@@ -2398,15 +2379,14 @@ void
GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
- struct Session *session,
+ struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
{
struct NeighbourMapEntry *n;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received ACK message from peer `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n",
GNUNET_i2s (peer));
#endif
@@ -2418,16 +2398,16 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
n = lookup_neighbour (peer);
if (NULL == n)
{
- send_disconnect (peer, address,
- session);
+ send_disconnect (peer, address, session);
GNUNET_break (0);
return;
}
if (S_CONNECTED == n->state)
return;
- if (!is_connecting(n))
+ if (!is_connecting (n))
{
- GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# unexpected ACK messages"), 1,
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop ("# unexpected ACK messages"), 1,
GNUNET_NO);
return;
}
@@ -2441,30 +2421,26 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
GNUNET_assert (n->address != NULL);
if (n->address_state == FRESH)
{
- GST_validation_set_address_use (&n->id,
- n->address,
- n->session,
- GNUNET_YES);
+ GST_validation_set_address_use (&n->id, n->address, n->session, GNUNET_YES);
GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
n->address_state = USED;
}
neighbours_connected++;
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
- GNUNET_NO);
-
+ GNUNET_NO);
+
GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
- n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
+ n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
- GNUNET_i2s (&n->id),
- GST_plugins_a2s (n->address), n->session,
- __LINE__);
+ "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
+ GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
+ __LINE__);
#endif
- connect_notify_cb (callback_cls, &n->id, ats, ats_count);
- send_outbound_quota(peer, n->bandwidth_out);
+ connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+ send_outbound_quota (peer, n->bandwidth_out);
}
struct BlackListCheckContext
@@ -2514,15 +2490,11 @@ handle_connect_blacklist_cont (void *cls,
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
"Giving ATS session %p of address `%s' for peer %s\n",
- bcc->session,
- GST_plugins_a2s (bcc->address),
+ bcc->session, GST_plugins_a2s (bcc->address),
GNUNET_i2s (peer));
/* Tell ATS about the session, so ATS can suggest it if it likes it. */
- GNUNET_ATS_address_update (GST_ats,
- bcc->address,
- bcc->session,
- bcc->ats,
+ GNUNET_ATS_address_update (GST_ats, bcc->address, bcc->session, bcc->ats,
bcc->ats_count);
n->connect_ts = bcc->ts;
}
@@ -2584,10 +2556,10 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
n = lookup_neighbour (peer);
- if ( (n != NULL) && (S_CONNECTED == n->state) )
+ if ((n != NULL) && (S_CONNECTED == n->state))
{
- /* connected peer switches addresses */
- return;
+ /* connected peer switches addresses */
+ return;
}
@@ -2603,9 +2575,10 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1];
memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
- GST_blacklist_test_allowed (peer, address->transport_name, handle_connect_blacklist_cont,
- bcc);
+ bcc->ats[ats_count].value =
+ htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
+ GST_blacklist_test_allowed (peer, address->transport_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 e85f1a4d0..5b37ccb6a 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -134,7 +134,7 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour);
*/
void
GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information * ats,
+ const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
@@ -172,7 +172,8 @@ typedef void (*GST_NeighbourIterator) (void *cls,
neighbour,
const struct GNUNET_ATS_Information *
ats, uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address);
+ const struct GNUNET_HELLO_Address *
+ address);
/**
@@ -213,10 +214,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
*/
int
GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
+ const struct GNUNET_HELLO_Address
+ *address, struct Session *session,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count,
struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO
@@ -259,7 +260,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
void
GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+ const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
@@ -268,7 +269,7 @@ void
GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
- struct Session *session,
+ struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
@@ -276,7 +277,7 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
/**
* Obtain current latency information for the given neighbour.
*
- * @param peer
+ * @param peer
* @return observed latency of the address, FOREVER if the address was
* never successfully validated
*/
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index f14eb57d6..4b3dd455d 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -144,7 +144,8 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
if (plug->api == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to load transport plugin for `%s'\n"), plug->lib_name);
+ _("Failed to load transport plugin for `%s'\n"),
+ plug->lib_name);
GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug);
GNUNET_free (plug->short_name);
GNUNET_free (plug->lib_name);
@@ -210,16 +211,16 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
api = GST_plugins_find (address->transport_name);
if (NULL == api)
return "<plugin unknown>";
- if (0 == address->address_length)
+ if (0 == address->address_length)
{
- GNUNET_snprintf (unable_to_show,
- sizeof (unable_to_show),
- "<unable to stringify %u-byte long address of %s transport>",
- (unsigned int) address->address_length,
- address->transport_name);
+ GNUNET_snprintf (unable_to_show, sizeof (unable_to_show),
+ "<unable to stringify %u-byte long address of %s transport>",
+ (unsigned int) address->address_length,
+ address->transport_name);
return unable_to_show;
}
- return api->address_to_string (NULL, address->address, address->address_length);
+ return api->address_to_string (NULL, address->address,
+ address->address_length);
}
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 006a318f6..641214b39 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -333,9 +333,7 @@ validation_entry_match (void *cls, const GNUNET_HashCode * key, void *value)
struct ValidationEntryMatchContext *vemc = cls;
struct ValidationEntry *ve = value;
- if (0 ==
- GNUNET_HELLO_address_cmp (ve->address,
- vemc->address))
+ if (0 == GNUNET_HELLO_address_cmp (ve->address, vemc->address))
{
vemc->ve = ve;
return GNUNET_NO;
@@ -397,15 +395,13 @@ timeout_hello_validation (void *cls,
struct GNUNET_TIME_Relative left;
ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- max = GNUNET_TIME_absolute_max (ve->valid_until,
- ve->revalidation_block);
+ max = GNUNET_TIME_absolute_max (ve->valid_until, ve->revalidation_block);
left = GNUNET_TIME_absolute_get_remaining (max);
if (left.rel_value > 0)
{
/* should wait a bit longer */
- ve->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
- &timeout_hello_validation,
- ve);
+ ve->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (left, &timeout_hello_validation, ve);
return;
}
GNUNET_STATISTICS_update (GST_stats,
@@ -443,10 +439,13 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
slen = strlen (ve->address->transport_name) + 1;
hello = GST_hello_get ();
hsize = ntohs (hello->size);
- tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize;
+ tsize =
+ sizeof (struct TransportPingMessage) + ve->address->address_length +
+ slen + hsize;
ping.header.size =
- htons (sizeof (struct TransportPingMessage) + ve->address->address_length + slen);
+ htons (sizeof (struct TransportPingMessage) +
+ ve->address->address_length + slen);
ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
ping.challenge = htonl (ve->challenge);
ping.target = *pid;
@@ -459,7 +458,9 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
"HELLO", "PING", (unsigned int) tsize);
/* message too big (!?), get rid of HELLO */
hsize = 0;
- tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize;
+ tsize =
+ sizeof (struct TransportPingMessage) + ve->address->address_length +
+ slen + hsize;
}
{
char message_buf[tsize];
@@ -481,8 +482,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
ret =
papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY,
ACCEPTABLE_PING_DELAY, NULL /* no session */ ,
- ve->address->address, ve->address->address_length,
- GNUNET_YES, NULL, NULL);
+ ve->address->address, ve->address->address_length,
+ GNUNET_YES, NULL, NULL);
}
}
if (-1 != ret)
@@ -515,12 +516,11 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK;
delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block);
/* How long until we can possibly permit the next PING? */
- canonical_delay =
- (ve->in_use == GNUNET_YES)
- ? CONNECTED_PING_FREQUENCY
- : ( (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0)
- ? VALIDATED_PING_FREQUENCY
- : UNVALIDATED_PING_KEEPALIVE);
+ canonical_delay =
+ (ve->in_use ==
+ GNUNET_YES) ? CONNECTED_PING_FREQUENCY
+ : ((GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value >
+ 0) ? VALIDATED_PING_FREQUENCY : UNVALIDATED_PING_KEEPALIVE);
if (delay.rel_value > canonical_delay.rel_value * 2)
{
/* situation changed, recalculate delay */
@@ -534,28 +534,28 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
return;
}
- ve->revalidation_block =
- GNUNET_TIME_relative_to_absolute (canonical_delay);
+ ve->revalidation_block = GNUNET_TIME_relative_to_absolute (canonical_delay);
/* schedule next PINGing with some extra random delay to avoid synchronous re-validations */
- rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- canonical_delay.rel_value);
+ rdelay =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ canonical_delay.rel_value);
delay =
- GNUNET_TIME_relative_add (canonical_delay,
- GNUNET_TIME_relative_multiply
+ GNUNET_TIME_relative_add (canonical_delay,
+ GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, rdelay));
ve->revalidation_task =
- GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
+ GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
- /* start PINGing by checking blacklist */
+ /* start PINGing by checking blacklist */
GNUNET_STATISTICS_update (GST_stats,
gettext_noop ("# address revalidations started"), 1,
- GNUNET_NO);
- bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name,
- &transmit_ping_if_allowed, ve);
+ GNUNET_NO);
+ bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name,
+ &transmit_ping_if_allowed, ve);
if (NULL != bc)
- ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already
- called... */
+ ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already
+ * called... */
}
@@ -592,9 +592,11 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
ve->latency = GNUNET_TIME_UNIT_FOREVER_REL;
ve->challenge =
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
- ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE,
- &timeout_hello_validation, ve);
- GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey, ve,
+ ve->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE,
+ &timeout_hello_validation, ve);
+ GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey,
+ ve,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
ve->expecting_pong = GNUNET_NO;
return ve;
@@ -611,8 +613,7 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
* @return GNUNET_OK (keep the address)
*/
static int
-add_valid_address (void *cls,
- const struct GNUNET_HELLO_Address *address,
+add_valid_address (void *cls, const struct GNUNET_HELLO_Address *address,
struct GNUNET_TIME_Absolute expiration)
{
const struct GNUNET_HELLO_Message *hello = cls;
@@ -628,7 +629,7 @@ add_valid_address (void *cls,
GNUNET_break (0);
return GNUNET_OK; /* invalid HELLO !? */
}
- if (0 == memcmp(&GST_my_identity, &pid, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (&GST_my_identity, &pid, sizeof (struct GNUNET_PeerIdentity)))
{
/* Peerinfo returned own identity, skip validation */
return GNUNET_OK;
@@ -639,8 +640,7 @@ add_valid_address (void *cls,
if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
- GNUNET_ATS_address_update (GST_ats, address, NULL, NULL,
- 0);
+ GNUNET_ATS_address_update (GST_ats, address, NULL, NULL, 0);
return GNUNET_OK;
}
@@ -716,8 +716,7 @@ GST_validation_stop ()
static void
multicast_pong (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
- *public_key,
- struct GNUNET_TIME_Absolute valid_until,
+ *public_key, struct GNUNET_TIME_Absolute valid_until,
struct GNUNET_TIME_Absolute validation_block,
const struct GNUNET_HELLO_Address *address)
{
@@ -729,8 +728,7 @@ multicast_pong (void *cls,
return;
(void) papi->send (papi->cls, &address->peer, (const char *) pong,
ntohs (pong->header.size), PONG_PRIORITY,
- ACCEPTABLE_PING_DELAY, NULL,
- address->address,
+ ACCEPTABLE_PING_DELAY, NULL, address->address,
address->address_length, GNUNET_YES, NULL, NULL);
}
@@ -747,7 +745,7 @@ void
GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
const struct GNUNET_HELLO_Address *sender_address,
- struct Session *session)
+ struct Session *session)
{
const struct TransportPingMessage *ping;
struct TransportPongMessage *pong;
@@ -804,8 +802,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
address.transport_name = addr;
address.peer = *sender;
if (GNUNET_YES !=
- GST_hello_test_address (&address, &sig_cache,
- &sig_cache_exp))
+ GST_hello_test_address (&address, &sig_cache, &sig_cache_exp))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_
@@ -867,10 +864,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
ret =
papi->send (papi->cls, sender, (const char *) pong,
ntohs (pong->header.size), PONG_PRIORITY,
- ACCEPTABLE_PING_DELAY, session,
- sender_address->address,
- sender_address->address_length,
- GNUNET_SYSERR, NULL, NULL);
+ ACCEPTABLE_PING_DELAY, session, sender_address->address,
+ sender_address->address_length, GNUNET_SYSERR, NULL, NULL);
if (ret != -1)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -922,9 +917,9 @@ struct ValidateAddressContext
* @return GNUNET_OK (keep the address)
*/
static int
-validate_address_iterator (void *cls,
- const struct GNUNET_HELLO_Address *address,
- struct GNUNET_TIME_Absolute expiration)
+validate_address_iterator (void *cls,
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute expiration)
{
const struct ValidateAddressContext *vac = cls;
struct ValidationEntry *ve;
@@ -933,8 +928,7 @@ validate_address_iterator (void *cls,
return GNUNET_OK; /* expired */
ve = find_validation_entry (&vac->public_key, address);
if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
- ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address,
- ve);
+ ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
return GNUNET_OK;
}
@@ -956,8 +950,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
if (GNUNET_YES == ve->copied)
return 0; /* terminate */
ve->copied = GNUNET_YES;
- return GNUNET_HELLO_add_address (ve->address, ve->valid_until,
- buf, max);
+ return GNUNET_HELLO_add_address (ve->address, ve->valid_until, buf, max);
}
@@ -1056,7 +1049,7 @@ 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) ve->latency.rel_value);
+ ats.value = htonl ((uint32_t) ve->latency.rel_value);
GNUNET_ATS_address_update (GST_ats, ve->address, NULL, &ats, 1);
}
/* build HELLO to store in PEERINFO */
@@ -1102,7 +1095,8 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
GNUNET_free (h);
GNUNET_assert (NULL ==
GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
- &validate_address_iterator, &vac));
+ &validate_address_iterator,
+ &vac));
}
@@ -1138,8 +1132,8 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value)
struct IteratorContext *ic = cls;
struct ValidationEntry *ve = value;
- ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until,
- ve->revalidation_block, ve->address);
+ ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until, ve->revalidation_block,
+ ve->address);
return GNUNET_OK;
}
@@ -1178,16 +1172,15 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
*/
void
GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- int in_use)
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session, int in_use)
{
struct ValidationEntry *ve;
if (NULL != address)
ve = find_validation_entry (NULL, address);
else
- ve = NULL; /* FIXME: lookup based on session... */
+ ve = NULL; /* FIXME: lookup based on session... */
if (NULL == ve)
{
/* this can happen for inbound connections (sender_address_len == 0); */
@@ -1195,19 +1188,16 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
}
if (ve->in_use == in_use)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "GST_validation_set_address_use: %s %s: ve->in_use %i <-> in_use %i\n",
- GNUNET_i2s(sender),
- GST_plugins_a2s(address),
- ve->in_use,
- in_use);
- GNUNET_break (ve->in_use != in_use); /* should be different... */
+ "GST_validation_set_address_use: %s %s: ve->in_use %i <-> in_use %i\n",
+ GNUNET_i2s (sender), GST_plugins_a2s (address), ve->in_use,
+ in_use);
+ GNUNET_break (ve->in_use != in_use); /* should be different... */
ve->in_use = in_use;
if (in_use == GNUNET_YES)
{
/* from now on, higher frequeny, so reschedule now */
GNUNET_SCHEDULER_cancel (ve->revalidation_task);
- ve->revalidation_task =
- GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
+ ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
}
}
@@ -1218,20 +1208,20 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
*
* @param sender peer
* @param address the address
- * @param session session
+ * @param session session
* @return observed latency of the address, FOREVER if the address was
* never successfully validated
*/
struct GNUNET_TIME_Relative
GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session)
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session)
{
struct ValidationEntry *ve;
if (NULL == address)
{
- GNUNET_break (0); // FIXME: support having latency only with session...
+ GNUNET_break (0); // FIXME: support having latency only with session...
return GNUNET_TIME_UNIT_FOREVER_REL;
}
ve = find_validation_entry (NULL, address);
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index a3692e3cf..f5282d4e9 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -59,16 +59,15 @@ GST_validation_stop (void);
*/
void
GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- int in_use);
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session, int in_use);
/**
* Query validation about the latest observed latency on a given
* address.
*
- * @param sender peer
+ * @param sender peer
* @param address the address
* @param session session
* @return observed latency of the address, FOREVER if the address was
@@ -76,8 +75,8 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
*/
struct GNUNET_TIME_Relative
GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session);
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session);
/**
@@ -91,8 +90,8 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
void
GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *hdr,
- const struct GNUNET_HELLO_Address *sender_address,
- struct Session *session);
+ const struct GNUNET_HELLO_Address *sender_address,
+ struct Session *session);
/**
@@ -138,7 +137,8 @@ typedef void (*GST_ValidationAddressCallback) (void *cls,
valid_until,
struct GNUNET_TIME_Absolute
validation_block,
- const struct GNUNET_HELLO_Address *address);
+ const struct GNUNET_HELLO_Address
+ * address);
/**
diff --git a/src/transport/gnunet-transport-wlan-helper-dummy.c b/src/transport/gnunet-transport-wlan-helper-dummy.c
index b5f2f625a..32d58426c 100644
--- a/src/transport/gnunet-transport-wlan-helper-dummy.c
+++ b/src/transport/gnunet-transport-wlan-helper-dummy.c
@@ -188,19 +188,15 @@ main (int argc, char *argv[])
erg = mkfifo (FIFO_FILE1, 0666);
if (0 != erg)
{
- fprintf (stderr,
- "Error in mkfifo(%s): %s\n",
- FIFO_FILE1,
- strerror (errno));
+ fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
+ strerror (errno));
//exit(1);
}
erg = mkfifo (FIFO_FILE2, 0666);
if (0 != erg)
{
- fprintf (stderr,
- "Error in mkfifo(%s): %s\n",
- FIFO_FILE2,
- strerror (errno));
+ fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE2,
+ strerror (errno));
//exit(1);
}
@@ -256,9 +252,7 @@ main (int argc, char *argv[])
if (fdpin >= FD_SETSIZE)
{
- fprintf (stderr,
- "File fdpin number too large (%d > %u)\n",
- fdpin,
+ fprintf (stderr, "File fdpin number too large (%d > %u)\n", fdpin,
(unsigned int) FD_SETSIZE);
goto end;
}
@@ -268,9 +262,7 @@ main (int argc, char *argv[])
if (fdpout >= FD_SETSIZE)
{
- fprintf (stderr,
- "File fdpout number too large (%d > %u)\n",
- fdpout,
+ fprintf (stderr, "File fdpout number too large (%d > %u)\n", fdpout,
(unsigned int) FD_SETSIZE);
goto end;
@@ -328,13 +320,11 @@ main (int argc, char *argv[])
}
retval = select (maxfd + 1, &rfds, &wfds, NULL, &tv);
- if ( (-1 == retval) && (EINTR == errno) )
- continue;
+ if ((-1 == retval) && (EINTR == errno))
+ continue;
if (0 > retval)
{
- fprintf (stderr,
- "select failed: %s\n",
- strerror (errno));
+ fprintf (stderr, "select failed: %s\n", strerror (errno));
closeprog = 1;
break;
}
@@ -347,9 +337,8 @@ main (int argc, char *argv[])
if (0 > ret)
{
closeprog = 1;
- fprintf (stderr,
- "Write ERROR to STDOUT_FILENO: %s\n",
- strerror (errno));
+ fprintf (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
+ strerror (errno));
break;
}
else
@@ -373,9 +362,7 @@ main (int argc, char *argv[])
if (0 > ret)
{
closeprog = 1;
- fprintf (stderr,
- "Write ERROR to fdpout: %s\n",
- strerror (errno));
+ fprintf (stderr, "Write ERROR to fdpout: %s\n", strerror (errno));
}
else
{
@@ -396,9 +383,8 @@ main (int argc, char *argv[])
if (0 > readsize)
{
closeprog = 1;
- fprintf (stderr,
- "Error reading from STDIN_FILENO: %s\n",
- strerror (errno));
+ fprintf (stderr, "Error reading from STDIN_FILENO: %s\n",
+ strerror (errno));
}
else if (0 < readsize)
{
@@ -419,9 +405,7 @@ main (int argc, char *argv[])
if (0 > readsize)
{
closeprog = 1;
- fprintf (stderr,
- "Error reading from fdpin: %s\n",
- strerror (errno));
+ fprintf (stderr, "Error reading from fdpin: %s\n", strerror (errno));
break;
}
else if (0 < readsize)
@@ -453,4 +437,3 @@ end:
}
return 0;
}
-
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 53e0efedd..ca4542f1a 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -239,35 +239,35 @@ enum ieee80211_radiotap_type
};
/* For IEEE80211_RADIOTAP_FLAGS */
-#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
- * during CFP
- */
-#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
- * with short
- * preamble
- */
-#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
- * with WEP encryption
- */
-#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
- * with fragmentation
- */
-#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
-#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
- * 802.11 header and payload
- * (to 32-bit boundary)
- */
+#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
+ * during CFP
+ */
+#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
+ * with short
+ * preamble
+ */
+#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
+ * with WEP encryption
+ */
+#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
+ * with fragmentation
+ */
+#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
+#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
+ * 802.11 header and payload
+ * (to 32-bit boundary)
+ */
/* For IEEE80211_RADIOTAP_RX_FLAGS */
-#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
+#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
/* For IEEE80211_RADIOTAP_TX_FLAGS */
-#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
- * retries */
-#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
-#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
-#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */
-#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled
- * by userspace */
+#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
+ * retries */
+#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
+#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
+#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */
+#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled
+ * by userspace */
/**
@@ -478,10 +478,9 @@ struct ieee80211_radiotap_iterator
* index corresponds to the IEEE80211_RADIOTAP_... defines.
*/
static int
-ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator
- *iterator,
- struct ieee80211_radiotap_header
- *radiotap_header, int max_length)
+ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator,
+ struct ieee80211_radiotap_header
+ *radiotap_header, int max_length)
{
if (iterator == NULL)
return (-EINVAL);
@@ -503,47 +502,47 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator
iterator->arg_index = 0;
iterator->bitmap_shifter = le32toh (radiotap_header->it_present);
iterator->arg =
- ((uint8_t *) radiotap_header) + sizeof (struct ieee80211_radiotap_header);
+ ((uint8_t *) radiotap_header) + sizeof (struct ieee80211_radiotap_header);
iterator->this_arg = 0;
/* find payload start allowing for extended bitmap(s) */
if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK))
+ {
+ while (le32toh (*((uint32_t *) iterator->arg)) &
+ IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
{
- while (le32toh (*((uint32_t *) iterator->arg)) &
- IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
- {
- iterator->arg += sizeof (uint32_t);
-
- /*
- * check for insanity where the present bitmaps
- * keep claiming to extend up to or even beyond the
- * stated radiotap header length
- */
-
- if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
- iterator->max_length)
- return (-EINVAL);
-
- }
-
iterator->arg += sizeof (uint32_t);
/*
- * no need to check again for blowing past stated radiotap
- * header length, becuase ieee80211_radiotap_iterator_next
- * checks it before it is dereferenced
+ * check for insanity where the present bitmaps
+ * keep claiming to extend up to or even beyond the
+ * stated radiotap header length
*/
+ if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
+ iterator->max_length)
+ return (-EINVAL);
+
}
+ iterator->arg += sizeof (uint32_t);
+
+ /*
+ * no need to check again for blowing past stated radiotap
+ * header length, becuase ieee80211_radiotap_iterator_next
+ * checks it before it is dereferenced
+ */
+
+ }
+
/* we are all initialized happily */
return 0;
}
/**
- * @brief ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
+ * @brief ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
*
* This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...)
* and sets iterator->this_arg to point to the payload for the arg. It takes
@@ -556,8 +555,7 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator
* @return next present arg index on success or negative if no more or error
*/
static int
-ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator
- *iterator)
+ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator)
{
/*
@@ -594,10 +592,10 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator
[IEEE80211_RADIOTAP_RX_FLAGS] = 0x22,
[IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11,
[IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11
- /*
- * add more here as they are defined in
- * include/net/ieee80211_radiotap.h
- */
+ /*
+ * add more here as they are defined in
+ * include/net/ieee80211_radiotap.h
+ */
};
/*
@@ -606,92 +604,92 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator
*/
while (iterator->arg_index < (int) sizeof (rt_sizes))
+ {
+ int hit = 0;
+
+ if (!(iterator->bitmap_shifter & 1))
+ goto next_entry; /* arg not present */
+
+ /*
+ * arg is present, account for alignment padding
+ * 8-bit args can be at any alignment
+ * 16-bit args must start on 16-bit boundary
+ * 32-bit args must start on 32-bit boundary
+ * 64-bit args must start on 64-bit boundary
+ *
+ * note that total arg size can differ from alignment of
+ * elements inside arg, so we use upper nybble of length
+ * table to base alignment on
+ *
+ * also note: these alignments are ** relative to the
+ * start of the radiotap header **. There is no guarantee
+ * that the radiotap header itself is aligned on any
+ * kind of boundary.
+ */
+
+ if ((((void *) iterator->arg) -
+ ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4)
+ - 1))
+ iterator->arg_index +=
+ (rt_sizes[iterator->arg_index] >> 4) -
+ ((((void *) iterator->arg) -
+ ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >>
+ 4) - 1));
+
+ /*
+ * this is what we will return to user, but we need to
+ * move on first so next call has something fresh to test
+ */
+
+ iterator->this_arg_index = iterator->arg_index;
+ iterator->this_arg = iterator->arg;
+ hit = 1;
+
+ /* internally move on the size of this arg */
+
+ iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
+
+ /*
+ * check for insanity where we are given a bitmap that
+ * claims to have more arg content than the length of the
+ * radiotap section. We will normally end up equalling this
+ * max_length on the last arg, never exceeding it.
+ */
+
+ if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
+ iterator->max_length)
+ return (-EINVAL);
+
+next_entry:
+
+ iterator->arg_index++;
+ if (((iterator->arg_index & 31) == 0))
{
- int hit = 0;
-
- if (!(iterator->bitmap_shifter & 1))
- goto next_entry; /* arg not present */
-
- /*
- * arg is present, account for alignment padding
- * 8-bit args can be at any alignment
- * 16-bit args must start on 16-bit boundary
- * 32-bit args must start on 32-bit boundary
- * 64-bit args must start on 64-bit boundary
- *
- * note that total arg size can differ from alignment of
- * elements inside arg, so we use upper nybble of length
- * table to base alignment on
- *
- * also note: these alignments are ** relative to the
- * start of the radiotap header **. There is no guarantee
- * that the radiotap header itself is aligned on any
- * kind of boundary.
- */
-
- if ((((void *) iterator->arg) -
- ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >>
- 4) - 1))
- iterator->arg_index +=
- (rt_sizes[iterator->arg_index] >> 4) -
- ((((void *) iterator->arg) -
- ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index]
- >> 4) - 1));
-
- /*
- * this is what we will return to user, but we need to
- * move on first so next call has something fresh to test
- */
-
- iterator->this_arg_index = iterator->arg_index;
- iterator->this_arg = iterator->arg;
- hit = 1;
-
- /* internally move on the size of this arg */
-
- iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
-
- /*
- * check for insanity where we are given a bitmap that
- * claims to have more arg content than the length of the
- * radiotap section. We will normally end up equalling this
- * max_length on the last arg, never exceeding it.
- */
-
- if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
- iterator->max_length)
- return (-EINVAL);
-
- next_entry:
-
- iterator->arg_index++;
- if (((iterator->arg_index & 31) == 0))
- {
- /* completed current uint32_t bitmap */
- if (iterator->bitmap_shifter & 1)
- {
- /* b31 was set, there is more */
- /* move to next uint32_t bitmap */
- iterator->bitmap_shifter = le32toh (*iterator->next_bitmap);
- iterator->next_bitmap++;
- }
- else
- {
- /* no more bitmaps: end */
- iterator->arg_index = sizeof (rt_sizes);
- }
- }
+ /* completed current uint32_t bitmap */
+ if (iterator->bitmap_shifter & 1)
+ {
+ /* b31 was set, there is more */
+ /* move to next uint32_t bitmap */
+ iterator->bitmap_shifter = le32toh (*iterator->next_bitmap);
+ iterator->next_bitmap++;
+ }
else
- { /* just try the next bit */
- iterator->bitmap_shifter >>= 1;
- }
+ {
+ /* no more bitmaps: end */
+ iterator->arg_index = sizeof (rt_sizes);
+ }
+ }
+ else
+ { /* just try the next bit */
+ iterator->bitmap_shifter >>= 1;
+ }
- /* if we found a valid arg earlier, return it now */
+ /* if we found a valid arg earlier, return it now */
- if (hit)
- return (iterator->this_arg_index);
+ if (hit)
+ return (iterator->this_arg_index);
- }
+ }
/* we don't know how to handle any more args, we're done */
@@ -841,7 +839,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
crc = calc_crc_osdep (buf, len);
buf += len;
return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
- ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
+ ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
}
@@ -890,8 +888,8 @@ linux_get_channel (const struct Hardware_Infos *dev)
* @return size read from the buffer
*/
static ssize_t
-linux_read (struct Hardware_Infos *dev, unsigned char *buf,
- size_t buf_size, struct Radiotap_rx *ri)
+linux_read (struct Hardware_Infos *dev, unsigned char *buf, size_t buf_size,
+ struct Radiotap_rx *ri)
{
unsigned char tmpbuf[buf_size];
ssize_t caplen;
@@ -901,172 +899,170 @@ linux_read (struct Hardware_Infos *dev, unsigned char *buf,
caplen = read (dev->fd_raw, tmpbuf, buf_size);
if (0 > caplen)
- {
- if (EAGAIN == errno)
- return 0;
- fprintf (stderr, "Failed to read from RAW socket: %s\n",
- strerror (errno));
- return -1;
- }
+ {
+ if (EAGAIN == errno)
+ return 0;
+ fprintf (stderr, "Failed to read from RAW socket: %s\n", strerror (errno));
+ return -1;
+ }
memset (buf, 0, buf_size);
memset (ri, 0, sizeof (*ri));
switch (dev->arptype_in)
+ {
+ case ARPHRD_IEEE80211_PRISM:
+ {
+ /* skip the prism header */
+ if (tmpbuf[7] == 0x40)
{
- case ARPHRD_IEEE80211_PRISM:
- {
- /* skip the prism header */
- if (tmpbuf[7] == 0x40)
- {
- /* prism54 uses a different format */
- ri->ri_power = tmpbuf[0x33];
- ri->ri_noise = *(unsigned int *) (tmpbuf + 0x33 + 12);
- ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x33 + 24)) * 500000;
- got_signal = 1;
- got_noise = 1;
- n = 0x40;
- }
- else
- {
- ri->ri_mactime = *(uint64_t *) (tmpbuf + 0x5C - 48);
- ri->ri_channel = *(unsigned int *) (tmpbuf + 0x5C - 36);
- ri->ri_power = *(unsigned int *) (tmpbuf + 0x5C);
- ri->ri_noise = *(unsigned int *) (tmpbuf + 0x5C + 12);
- ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x5C + 24)) * 500000;
- got_channel = 1;
- got_signal = 1;
- got_noise = 1;
- n = *(int *) (tmpbuf + 4);
- }
-
- if (n < 8 || n >= caplen)
- return (0);
- }
- break;
+ /* prism54 uses a different format */
+ ri->ri_power = tmpbuf[0x33];
+ ri->ri_noise = *(unsigned int *) (tmpbuf + 0x33 + 12);
+ ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x33 + 24)) * 500000;
+ got_signal = 1;
+ got_noise = 1;
+ n = 0x40;
+ }
+ else
+ {
+ ri->ri_mactime = *(uint64_t *) (tmpbuf + 0x5C - 48);
+ ri->ri_channel = *(unsigned int *) (tmpbuf + 0x5C - 36);
+ ri->ri_power = *(unsigned int *) (tmpbuf + 0x5C);
+ ri->ri_noise = *(unsigned int *) (tmpbuf + 0x5C + 12);
+ ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x5C + 24)) * 500000;
+ got_channel = 1;
+ got_signal = 1;
+ got_noise = 1;
+ n = *(int *) (tmpbuf + 4);
+ }
+
+ if (n < 8 || n >= caplen)
+ return (0);
+ }
+ break;
- case ARPHRD_IEEE80211_FULL:
+ case ARPHRD_IEEE80211_FULL:
+ {
+ struct ieee80211_radiotap_iterator iterator;
+ struct ieee80211_radiotap_header *rthdr;
+
+ rthdr = (struct ieee80211_radiotap_header *) tmpbuf;
+
+ if (ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen) < 0)
+ return (0);
+
+ /* go through the radiotap arguments we have been given
+ * by the driver
+ */
+
+ while (ieee80211_radiotap_iterator_next (&iterator) >= 0)
+ {
+
+ switch (iterator.this_arg_index)
{
- struct ieee80211_radiotap_iterator iterator;
- struct ieee80211_radiotap_header *rthdr;
-
- rthdr = (struct ieee80211_radiotap_header *) tmpbuf;
-
- if (ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen) < 0)
- return (0);
-
- /* go through the radiotap arguments we have been given
- * by the driver
- */
-
- while (ieee80211_radiotap_iterator_next (&iterator) >= 0)
- {
-
- switch (iterator.this_arg_index)
- {
-
- case IEEE80211_RADIOTAP_TSFT:
- ri->ri_mactime = le64toh (*((uint64_t *) iterator.this_arg));
- break;
-
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- if (!got_signal)
- {
- if (*iterator.this_arg < 127)
- ri->ri_power = *iterator.this_arg;
- else
- ri->ri_power = *iterator.this_arg - 255;
-
- got_signal = 1;
- }
- break;
-
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- if (!got_signal)
- {
- if (*iterator.this_arg < 127)
- ri->ri_power = *iterator.this_arg;
- else
- ri->ri_power = *iterator.this_arg - 255;
-
- got_signal = 1;
- }
- break;
-
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- if (!got_noise)
- {
- if (*iterator.this_arg < 127)
- ri->ri_noise = *iterator.this_arg;
- else
- ri->ri_noise = *iterator.this_arg - 255;
-
- got_noise = 1;
- }
- break;
-
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- if (!got_noise)
- {
- if (*iterator.this_arg < 127)
- ri->ri_noise = *iterator.this_arg;
- else
- ri->ri_noise = *iterator.this_arg - 255;
-
- got_noise = 1;
- }
- break;
-
- case IEEE80211_RADIOTAP_ANTENNA:
- ri->ri_antenna = *iterator.this_arg;
- break;
-
- case IEEE80211_RADIOTAP_CHANNEL:
- ri->ri_channel = *iterator.this_arg;
- got_channel = 1;
- break;
-
- case IEEE80211_RADIOTAP_RATE:
- ri->ri_rate = (*iterator.this_arg) * 500000;
- break;
-
- case IEEE80211_RADIOTAP_FLAGS:
- /* is the CRC visible at the end?
- * remove
- */
- if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS)
- {
- fcs_removed = 1;
- caplen -= 4;
- }
-
- if (*iterator.this_arg & IEEE80211_RADIOTAP_F_RX_BADFCS)
- return (0);
-
- break;
- }
- }
- n = le16toh (rthdr->it_len);
- if (n <= 0 || n >= caplen)
- return 0;
+
+ case IEEE80211_RADIOTAP_TSFT:
+ ri->ri_mactime = le64toh (*((uint64_t *) iterator.this_arg));
+ break;
+
+ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
+ if (!got_signal)
+ {
+ if (*iterator.this_arg < 127)
+ ri->ri_power = *iterator.this_arg;
+ else
+ ri->ri_power = *iterator.this_arg - 255;
+
+ got_signal = 1;
+ }
+ break;
+
+ case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
+ if (!got_signal)
+ {
+ if (*iterator.this_arg < 127)
+ ri->ri_power = *iterator.this_arg;
+ else
+ ri->ri_power = *iterator.this_arg - 255;
+
+ got_signal = 1;
+ }
+ break;
+
+ case IEEE80211_RADIOTAP_DBM_ANTNOISE:
+ if (!got_noise)
+ {
+ if (*iterator.this_arg < 127)
+ ri->ri_noise = *iterator.this_arg;
+ else
+ ri->ri_noise = *iterator.this_arg - 255;
+
+ got_noise = 1;
+ }
+ break;
+
+ case IEEE80211_RADIOTAP_DB_ANTNOISE:
+ if (!got_noise)
+ {
+ if (*iterator.this_arg < 127)
+ ri->ri_noise = *iterator.this_arg;
+ else
+ ri->ri_noise = *iterator.this_arg - 255;
+
+ got_noise = 1;
+ }
+ break;
+
+ case IEEE80211_RADIOTAP_ANTENNA:
+ ri->ri_antenna = *iterator.this_arg;
+ break;
+
+ case IEEE80211_RADIOTAP_CHANNEL:
+ ri->ri_channel = *iterator.this_arg;
+ got_channel = 1;
+ break;
+
+ case IEEE80211_RADIOTAP_RATE:
+ ri->ri_rate = (*iterator.this_arg) * 500000;
+ break;
+
+ case IEEE80211_RADIOTAP_FLAGS:
+ /* is the CRC visible at the end?
+ * remove
+ */
+ if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS)
+ {
+ fcs_removed = 1;
+ caplen -= 4;
+ }
+
+ if (*iterator.this_arg & IEEE80211_RADIOTAP_F_RX_BADFCS)
+ return (0);
+
+ break;
}
- break;
- case ARPHRD_IEEE80211:
- /* do nothing? */
- break;
- default:
- errno = ENOTSUP;
- return -1;
}
+ n = le16toh (rthdr->it_len);
+ if (n <= 0 || n >= caplen)
+ return 0;
+ }
+ break;
+ case ARPHRD_IEEE80211:
+ /* do nothing? */
+ break;
+ default:
+ errno = ENOTSUP;
+ return -1;
+ }
caplen -= n;
//detect fcs at the end, even if the flag wasn't set and remove it
- if ((0 == fcs_removed)
- && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4)))
- {
- caplen -= 4;
- }
+ if ((0 == fcs_removed) && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4)))
+ {
+ caplen -= 4;
+ }
memcpy (buf, tmpbuf + n, caplen);
if (!got_channel)
ri->ri_channel = linux_get_channel (dev);
@@ -1092,12 +1088,11 @@ openraw (struct Hardware_Infos *dev)
memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, dev->iface, IFNAMSIZ);
if (-1 == ioctl (dev->fd_raw, SIOCGIFINDEX, &ifr))
- {
- fprintf (stderr,
- "ioctl(SIOCGIFINDEX) on interface `%.*s' failed: %s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
- return 1;
- }
+ {
+ fprintf (stderr, "ioctl(SIOCGIFINDEX) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ, dev->iface, strerror (errno));
+ return 1;
+ }
/* lookup the hardware type */
memset (&sll, 0, sizeof (sll));
@@ -1105,78 +1100,72 @@ openraw (struct Hardware_Infos *dev)
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons (ETH_P_ALL);
if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
- {
- fprintf (stderr,
- "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
- return 1;
- }
+ {
+ fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ, dev->iface, strerror (errno));
+ return 1;
+ }
/* lookup iw mode */
memset (&wrq, 0, sizeof (struct iwreq));
strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ);
if (-1 == ioctl (dev->fd_raw, SIOCGIWMODE, &wrq))
- {
- /* most probably not supported (ie for rtap ipw interface) *
- * so just assume its correctly set... */
- wrq.u.mode = IW_MODE_MONITOR;
- }
+ {
+ /* most probably not supported (ie for rtap ipw interface) *
+ * so just assume its correctly set... */
+ wrq.u.mode = IW_MODE_MONITOR;
+ }
if (((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) &&
(ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) &&
(ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) ||
(wrq.u.mode != IW_MODE_MONITOR))
- {
- fprintf (stderr,
- "Error: interface `%.*s' is not in monitor mode\n",
- IFNAMSIZ, dev->iface);
- return 1;
- }
+ {
+ fprintf (stderr, "Error: interface `%.*s' is not in monitor mode\n",
+ IFNAMSIZ, dev->iface);
+ return 1;
+ }
/* Is interface st to up, broadcast & running ? */
if ((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags)
+ {
+ /* Bring interface up */
+ ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING;
+
+ if (-1 == ioctl (dev->fd_raw, SIOCSIFFLAGS, &ifr))
{
- /* Bring interface up */
- ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING;
-
- if (-1 == ioctl (dev->fd_raw, SIOCSIFFLAGS, &ifr))
- {
- fprintf (stderr,
- "ioctl(SIOCSIFFLAGS) on interface `%.*s' failed: %s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
- return 1;
- }
+ fprintf (stderr, "ioctl(SIOCSIFFLAGS) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ, dev->iface, strerror (errno));
+ return 1;
}
+ }
/* bind the raw socket to the interface */
if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll)))
- {
- fprintf (stderr,
- "Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
- dev->iface, strerror (errno));
- return 1;
- }
+ {
+ fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
+ dev->iface, strerror (errno));
+ return 1;
+ }
/* lookup the hardware type */
if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
- {
- fprintf (stderr,
- "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
- IFNAMSIZ, dev->iface, strerror (errno));
- return 1;
- }
+ {
+ fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
+ IFNAMSIZ, dev->iface, strerror (errno));
+ return 1;
+ }
memcpy (&dev->pl_mac, ifr.ifr_hwaddr.sa_data, MAC_ADDR_SIZE);
dev->arptype_in = ifr.ifr_hwaddr.sa_family;
if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) &&
(ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) &&
(ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL))
- {
- fprintf (stderr,
- "Unsupported hardware link type %d on interface `%.*s'\n",
- ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface);
- return 1;
- }
+ {
+ fprintf (stderr, "Unsupported hardware link type %d on interface `%.*s'\n",
+ ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface);
+ return 1;
+ }
/* enable promiscuous mode */
memset (&mr, 0, sizeof (mr));
@@ -1184,13 +1173,12 @@ openraw (struct Hardware_Infos *dev)
mr.mr_type = PACKET_MR_PROMISC;
if (0 !=
setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
- sizeof (mr)))
- {
- fprintf (stderr,
- "Failed to enable promiscuous mode on interface `%.*s'\n",
- IFNAMSIZ, dev->iface);
- return 1;
- }
+ sizeof (mr)))
+ {
+ fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n",
+ IFNAMSIZ, dev->iface);
+ return 1;
+ }
return 0;
}
@@ -1211,36 +1199,34 @@ wlaninit (struct Hardware_Infos *dev, const char *iface)
dev->fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
if (0 > dev->fd_raw)
- {
- fprintf (stderr, "Failed to create raw socket: %s\n", strerror (errno));
- return 1;
- }
+ {
+ fprintf (stderr, "Failed to create raw socket: %s\n", strerror (errno));
+ return 1;
+ }
if (dev->fd_raw >= FD_SETSIZE)
- {
- fprintf (stderr,
- "File descriptor too large for select (%d > %d)\n",
- dev->fd_raw, FD_SETSIZE);
- close (dev->fd_raw);
- return 1;
- }
+ {
+ fprintf (stderr, "File descriptor too large for select (%d > %d)\n",
+ dev->fd_raw, FD_SETSIZE);
+ close (dev->fd_raw);
+ return 1;
+ }
/* mac80211 stack detection */
ret =
- snprintf (strbuf,
- sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", iface);
+ snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem",
+ iface);
if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
- {
- fprintf (stderr,
- "Did not find 802.11 interface `%s'. Exiting.\n", iface);
- close (dev->fd_raw);
- return 1;
- }
+ {
+ fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface);
+ close (dev->fd_raw);
+ return 1;
+ }
strncpy (dev->iface, iface, IFNAMSIZ);
if (0 != openraw (dev))
- {
- close (dev->fd_raw);
- return 1;
- }
+ {
+ close (dev->fd_raw);
+ return 1;
+ }
return 0;
}
@@ -1254,7 +1240,7 @@ wlaninit (struct Hardware_Infos *dev, const char *iface)
*/
static int
mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
- const struct Hardware_Infos *dev)
+ const struct Hardware_Infos *dev)
{
if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE))
return 1;
@@ -1273,7 +1259,7 @@ mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
*/
static void
mac_set (struct ieee80211_frame *uint8_taIeeeHeader,
- const struct Hardware_Infos *dev)
+ const struct Hardware_Infos *dev)
{
uint8_taIeeeHeader->i_fc[0] = 0x08;
uint8_taIeeeHeader->i_fc[1] = 0x00;
@@ -1289,8 +1275,7 @@ mac_set (struct ieee80211_frame *uint8_taIeeeHeader,
* @param hdr pointer to the start of the packet
*/
static void
-stdin_send_hw (void *cls, void *client,
- const struct GNUNET_MessageHeader *hdr)
+stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
struct Hardware_Infos *dev = cls;
struct sendbuf *write_pout = &dev->write_pout;
@@ -1305,7 +1290,7 @@ stdin_send_hw (void *cls, void *client,
rtheader.rate = 0x00;
rtheader.pad1 = 0x00;
rtheader.txflags =
- htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
+ htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
/* { 0x00, 0x00, <-- radiotap version
* 0x0c, 0x00, <- radiotap header length
@@ -1318,24 +1303,23 @@ stdin_send_hw (void *cls, void *client,
sendsize = ntohs (hdr->size);
if (sendsize <
sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader))
- {
- fprintf (stderr,
- "Function stdin_send_hw: malformed packet (too small)\n");
- exit (1);
- }
+ {
+ fprintf (stderr, "Function stdin_send_hw: malformed packet (too small)\n");
+ exit (1);
+ }
sendsize -=
- sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader);
+ sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader);
if (MAXLINE < sendsize)
- {
- fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n");
- exit (1);
- }
+ {
+ fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n");
+ exit (1);
+ }
if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type))
- {
- fprintf (stderr, "Function stdin_send: wrong packet type\n");
- exit (1);
- }
+ {
+ fprintf (stderr, "Function stdin_send: wrong packet type\n");
+ exit (1);
+ }
rtheader.header.it_len = htole16 (sizeof (rtheader));
rtheader.rate = header->rate;
@@ -1343,8 +1327,7 @@ stdin_send_hw (void *cls, void *client,
memcpy (write_pout->buf + sizeof (rtheader), &header[1], sendsize);
/* payload contains MAC address, but we don't trust it, so we'll
* overwrite it with OUR MAC address again to prevent mischief */
- wlanheader =
- (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader));
+ wlanheader = (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader));
mac_set (wlanheader, dev);
write_pout->size = sendsize + sizeof (rtheader);
}
@@ -1372,19 +1355,19 @@ main (int argc, char *argv[])
struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst;
if (2 != argc)
- {
- fprintf (stderr,
- "You must specify the name of the interface as the first and only argument to this program.\n");
- return 1;
- }
+ {
+ fprintf (stderr,
+ "You must specify the name of the interface as the first and only argument to this program.\n");
+ return 1;
+ }
if (0 != wlaninit (&dev, argv[1]))
return 1;
uid = getuid ();
if (0 != setresuid (uid, uid, uid))
- {
- fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
- /* not critical, continue anyway */
- }
+ {
+ fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
+ /* not critical, continue anyway */
+ }
dev.write_pout.size = 0;
dev.write_pout.pos = 0;
@@ -1396,135 +1379,129 @@ main (int argc, char *argv[])
stdin_open = 1;
while (1)
+ {
+ maxfd = -1;
+ FD_ZERO (&rfds);
+ if ((0 == dev.write_pout.size) && (1 == stdin_open))
+ {
+ FD_SET (STDIN_FILENO, &rfds);
+ maxfd = MAX (maxfd, STDIN_FILENO);
+ }
+ if (0 == write_std.size)
+ {
+ FD_SET (dev.fd_raw, &rfds);
+ maxfd = MAX (maxfd, dev.fd_raw);
+ }
+ FD_ZERO (&wfds);
+ if (0 < write_std.size)
+ {
+ FD_SET (STDOUT_FILENO, &wfds);
+ maxfd = MAX (maxfd, STDOUT_FILENO);
+ }
+ if (0 < dev.write_pout.size)
+ {
+ FD_SET (dev.fd_raw, &wfds);
+ maxfd = MAX (maxfd, dev.fd_raw);
+ }
+ retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
+ if ((-1 == retval) && (EINTR == errno))
+ continue;
+ if (0 > retval)
+ {
+ fprintf (stderr, "select failed: %s\n", strerror (errno));
+ break;
+ }
+ if (FD_ISSET (STDOUT_FILENO, &wfds))
+ {
+ ret =
+ write (STDOUT_FILENO, write_std.buf + write_std.pos,
+ write_std.size - write_std.pos);
+ if (0 > ret)
+ {
+ fprintf (stderr, "Failed to write to STDOUT: %s\n", strerror (errno));
+ break;
+ }
+ write_std.pos += ret;
+ if (write_std.pos == write_std.size)
+ {
+ write_std.pos = 0;
+ write_std.size = 0;
+ }
+ }
+ if (FD_ISSET (dev.fd_raw, &wfds))
+ {
+ ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size);
+ if (0 > ret)
+ {
+ fprintf (stderr, "Failed to write to WLAN device: %s\n",
+ strerror (errno));
+ break;
+ }
+ dev.write_pout.pos += ret;
+ if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
+ {
+ /* we should not get partial sends with packet-oriented devices... */
+ fprintf (stderr, "Write error, partial send: %u/%u\n",
+ dev.write_pout.pos, dev.write_pout.size);
+ break;
+ }
+ if (dev.write_pout.pos == dev.write_pout.size)
+ {
+ dev.write_pout.pos = 0;
+ dev.write_pout.size = 0;
+ }
+ }
+
+ if (FD_ISSET (STDIN_FILENO, &rfds))
{
- maxfd = -1;
- FD_ZERO (&rfds);
- if ((0 == dev.write_pout.size) && (1 == stdin_open))
- {
- FD_SET (STDIN_FILENO, &rfds);
- maxfd = MAX (maxfd, STDIN_FILENO);
- }
- if (0 == write_std.size)
- {
- FD_SET (dev.fd_raw, &rfds);
- maxfd = MAX (maxfd, dev.fd_raw);
- }
- FD_ZERO (&wfds);
- if (0 < write_std.size)
- {
- FD_SET (STDOUT_FILENO, &wfds);
- maxfd = MAX (maxfd, STDOUT_FILENO);
- }
- if (0 < dev.write_pout.size)
- {
- FD_SET (dev.fd_raw, &wfds);
- maxfd = MAX (maxfd, dev.fd_raw);
- }
- retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
- if ((-1 == retval) && (EINTR == errno))
- continue;
- if (0 > retval)
- {
- fprintf (stderr, "select failed: %s\n", strerror (errno));
- break;
- }
- if (FD_ISSET (STDOUT_FILENO, &wfds))
- {
- ret =
- write (STDOUT_FILENO,
- write_std.buf + write_std.pos,
- write_std.size - write_std.pos);
- if (0 > ret)
- {
- fprintf (stderr,
- "Failed to write to STDOUT: %s\n", strerror (errno));
- break;
- }
- write_std.pos += ret;
- if (write_std.pos == write_std.size)
- {
- write_std.pos = 0;
- write_std.size = 0;
- }
- }
- if (FD_ISSET (dev.fd_raw, &wfds))
- {
- ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size);
- if (0 > ret)
- {
- fprintf (stderr,
- "Failed to write to WLAN device: %s\n",
- strerror (errno));
- break;
- }
- dev.write_pout.pos += ret;
- if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
- {
- /* we should not get partial sends with packet-oriented devices... */
- fprintf (stderr,
- "Write error, partial send: %u/%u\n",
- dev.write_pout.pos, dev.write_pout.size);
- break;
- }
- if (dev.write_pout.pos == dev.write_pout.size)
- {
- dev.write_pout.pos = 0;
- dev.write_pout.size = 0;
- }
- }
-
- if (FD_ISSET (STDIN_FILENO, &rfds))
- {
- ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
- if (0 > ret)
- {
- fprintf (stderr,
- "Read error from STDIN: %s\n", strerror (errno));
- break;
- }
- if (0 == ret)
- {
- /* stop reading... */
- stdin_open = 0;
- }
- GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO,
- GNUNET_NO);
- }
-
- if (FD_ISSET (dev.fd_raw, &rfds))
- {
- struct GNUNET_MessageHeader *header;
- struct Radiotap_rx *rxinfo;
- struct ieee80211_frame *datastart;
-
- header = (struct GNUNET_MessageHeader *) write_std.buf;
- rxinfo = (struct Radiotap_rx *) &header[1];
- datastart = (struct ieee80211_frame *) &rxinfo[1];
- ret =
- linux_read (&dev, (unsigned char *) datastart,
- sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
- sizeof (struct GNUNET_MessageHeader), rxinfo);
- if (0 > ret)
- {
- fprintf (stderr,
- "Read error from raw socket: %s\n", strerror (errno));
- break;
- }
- if ((0 < ret) && (0 == mac_test (datastart, &dev)))
- {
- write_std.size =
- ret + sizeof (struct GNUNET_MessageHeader) +
- sizeof (struct Radiotap_rx);
- header->size = htons (write_std.size);
- header->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
- }
- }
+ ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
+ if (0 > ret)
+ {
+ fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno));
+ break;
+ }
+ if (0 == ret)
+ {
+ /* stop reading... */
+ stdin_open = 0;
+ }
+ GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO,
+ GNUNET_NO);
+ }
+ if (FD_ISSET (dev.fd_raw, &rfds))
+ {
+ struct GNUNET_MessageHeader *header;
+ struct Radiotap_rx *rxinfo;
+ struct ieee80211_frame *datastart;
+
+ header = (struct GNUNET_MessageHeader *) write_std.buf;
+ rxinfo = (struct Radiotap_rx *) &header[1];
+ datastart = (struct ieee80211_frame *) &rxinfo[1];
+ ret =
+ linux_read (&dev, (unsigned char *) datastart,
+ sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
+ sizeof (struct GNUNET_MessageHeader), rxinfo);
+ if (0 > ret)
+ {
+ fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno));
+ break;
+ }
+ if ((0 < ret) && (0 == mac_test (datastart, &dev)))
+ {
+ write_std.size =
+ ret + sizeof (struct GNUNET_MessageHeader) +
+ sizeof (struct Radiotap_rx);
+ header->size = htons (write_std.size);
+ header->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
+ }
}
+
+ }
/* Error handling, try to clean up a bit at least */
GNUNET_SERVER_mst_destroy (stdin_mst);
close (dev.fd_raw);
- return 1; /* we never exit 'normally' */
+ return 1; /* we never exit 'normally' */
}
/* end of gnunet-transport-wlan-helper.c */
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 66f02b104..c069bfb24 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -437,14 +437,14 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
traffic_received += ntohs (message->size);
}
-void process_string (void *cls,
- const char *address)
+void
+process_string (void *cls, const char *address)
{
- struct GNUNET_PeerIdentity * peer = cls;
+ struct GNUNET_PeerIdentity *peer = cls;
if ((address != NULL))
{
- fprintf (stdout, _("Peer `%s': %s\n"), GNUNET_i2s(peer), address);
+ fprintf (stdout, _("Peer `%s': %s\n"), GNUNET_i2s (peer), address);
}
else
{
@@ -463,29 +463,25 @@ void process_string (void *cls,
* @param addrlen number of bytes in addr
*/
static void
-process_address (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address)
+process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address)
{
- const struct GNUNET_CONFIGURATION_Handle * cfg = cls;
+ const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct GNUNET_PeerIdentity *peercp;
- if ( (address == NULL) || (peer == NULL) )
+ if ((address == NULL) || (peer == NULL))
{
/* done */
return;
}
- peercp = GNUNET_malloc(sizeof (struct GNUNET_PeerIdentity));
+ peercp = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
*peercp = *peer;
/* Resolve address to string */
- GNUNET_TRANSPORT_address_to_string (cfg,
- address,
- numeric,
- GNUNET_TIME_UNIT_MINUTES,
- &process_string,
- peercp);
+ GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
+ GNUNET_TIME_UNIT_MINUTES, &process_string,
+ peercp);
}
@@ -542,8 +538,8 @@ run (void *cls, char *const *args, const char *cfgfile,
if (iterate_connections)
{
GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_YES,
- GNUNET_TIME_UNIT_MINUTES,
- &process_address, (void *)cfg);
+ GNUNET_TIME_UNIT_MINUTES,
+ &process_address, (void *) cfg);
}
}
@@ -568,9 +564,9 @@ main (int argc, char *const *argv)
{'t', "test", NULL,
gettext_noop ("test transport configuration (involves external server)"),
0, &GNUNET_GETOPT_set_one, &test_configuration},
- {'n', "numeric", NULL,
- gettext_noop ("do not resolve hostnames"),
- 0, &GNUNET_GETOPT_set_one, &numeric},
+ {'n', "numeric", NULL,
+ gettext_noop ("do not resolve hostnames"),
+ 0, &GNUNET_GETOPT_set_one, &numeric},
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index a6c9190bd..502e26597 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -513,6 +513,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
struct Plugin *plugin = cls;
struct HTTP_Message *msg;
struct Session *s;
+
GNUNET_assert (plugin != NULL);
int res = GNUNET_SYSERR;
@@ -563,17 +564,20 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
GNUNET_i2s (target));
#endif
int res = GNUNET_OK;
+
if (addrlen == sizeof (struct IPv4HttpAddress))
{
- struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr;
- if ((ntohs(a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO))
- res = GNUNET_SYSERR;
+ struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr;
+
+ if ((ntohs (a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO))
+ res = GNUNET_SYSERR;
}
if (addrlen == sizeof (struct IPv6HttpAddress))
{
- struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr;
- if ((ntohs(a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO))
- res = GNUNET_SYSERR;
+ struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr;
+
+ if ((ntohs (a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO))
+ res = GNUNET_SYSERR;
}
if (res == GNUNET_OK)
{
@@ -606,8 +610,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
{
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Using outbound client session %p to send to `%s'\n",
- s,
+ "Using outbound client session %p to send to `%s'\n", s,
GNUNET_i2s (target));
#endif
@@ -618,8 +621,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
{
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Using inbound server %p session to send to `%s'\n",
- s,
+ "Using inbound server %p session to send to `%s'\n", s,
GNUNET_i2s (target));
#endif
@@ -659,16 +661,17 @@ http_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
GNUNET_assert (GNUNET_OK == server_disconnect (s));
GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
- struct HTTP_Message * msg = s->msg_head;
- struct HTTP_Message * tmp = s->msg_head;
+ struct HTTP_Message *msg = s->msg_head;
+ struct HTTP_Message *tmp = s->msg_head;
+
while (msg != NULL)
{
tmp = msg->next;
- GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
if (msg->transmit_cont != NULL)
{
- msg->transmit_cont(msg->transmit_cont_cls, target, GNUNET_SYSERR);
+ msg->transmit_cont (msg->transmit_cont_cls, target, GNUNET_SYSERR);
}
GNUNET_free (msg);
msg = tmp;
@@ -1427,18 +1430,20 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
while (s != NULL)
{
struct Session *t = s->next;
+
GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
- struct HTTP_Message * msg = s->msg_head;
- struct HTTP_Message * tmp = s->msg_head;
+ struct HTTP_Message *msg = s->msg_head;
+ struct HTTP_Message *tmp = s->msg_head;
+
while (msg != NULL)
{
tmp = msg->next;
- GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
if (msg->transmit_cont != NULL)
{
- msg->transmit_cont(msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
+ msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
}
GNUNET_free (msg);
msg = tmp;
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 159b0853f..2c180c5ff 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -312,6 +312,7 @@ static ssize_t
server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
{
struct Session *s = cls;
+
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name,
"Server: %X can sent maximum %u \n", s, max);
@@ -349,6 +350,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
#if VERBOSE_SERVER
struct Plugin *plugin = s->plugin;
+
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
"Server: %X: sent %u bytes\n", s, bytes_read);
#endif
@@ -575,7 +577,8 @@ found:
#endif
MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to);
- struct MHD_Daemon * d = NULL;
+ struct MHD_Daemon *d = NULL;
+
if (s->addrlen == sizeof (struct IPv6HttpAddress))
d = plugin->server_v6;
if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -649,10 +652,10 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL))
{
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n",
- GNUNET_i2s (&s->target),
- http_plugin_address_to_string (NULL, s->addr, s->addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n",
+ GNUNET_i2s (&s->target),
+ http_plugin_address_to_string (NULL, s->addr, s->addrlen));
#endif
return MHD_YES;
}
@@ -674,7 +677,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Server: Peer `%s' PUT on address `%s' connected\n",
GNUNET_i2s (&s->target),
- http_plugin_address_to_string (NULL, s->addr, s->addrlen));
+ http_plugin_address_to_string (NULL, s->addr,
+ s->addrlen));
#endif
return MHD_YES;
}
@@ -686,7 +690,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Server: peer `%s' PUT on address `%s' received %u bytes\n",
GNUNET_i2s (&s->target),
- http_plugin_address_to_string (NULL,s->addr, s->addrlen),
+ http_plugin_address_to_string (NULL, s->addr,
+ s->addrlen),
*upload_data_size);
#endif
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
@@ -739,6 +744,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
to);
}
struct MHD_Daemon *d = NULL;
+
if (s->addrlen == sizeof (struct IPv6HttpAddress))
d = plugin->server_v6;
if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -839,6 +845,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
plugin->cur_connections--;
struct MHD_Daemon *d = NULL;
+
if (s->addrlen == sizeof (struct IPv6HttpAddress))
d = plugin->server_v6;
if (s->addrlen == sizeof (struct IPv4HttpAddress))
@@ -894,11 +901,11 @@ server_send (struct Session *s, struct HTTP_Message *msg)
if (s->addrlen == sizeof (struct IPv4HttpAddress))
{
- server_reschedule (s->plugin, s->plugin->server_v4 , GNUNET_YES);
+ server_reschedule (s->plugin, s->plugin->server_v4, GNUNET_YES);
}
else if (s->addrlen == sizeof (struct IPv6HttpAddress))
{
- server_reschedule (s->plugin, s->plugin->server_v6 , GNUNET_YES);
+ server_reschedule (s->plugin, s->plugin->server_v6, GNUNET_YES);
}
else
return GNUNET_SYSERR;
@@ -926,7 +933,7 @@ server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Running IPv4 server\n");
+ "Running IPv4 server\n");
#endif
GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4));
if (plugin->server_v4 != NULL)
@@ -954,7 +961,7 @@ server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Running IPv6 server\n");
+ "Running IPv6 server\n");
#endif
GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6));
if (plugin->server_v6 != NULL)
@@ -1027,8 +1034,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK;
}
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Scheduling IPv4 server task in %llu ms\n", tv);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Scheduling IPv4 server task in %llu ms\n", tv);
#endif
ret =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -1043,8 +1050,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle,
plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
}
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Scheduling IPv6 server task in %llu ms\n", tv);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Scheduling IPv6 server task in %llu ms\n", tv);
#endif
ret =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -1195,8 +1202,7 @@ server_stop (struct Plugin *plugin)
struct Session *t = NULL;
#if VERBOSE_SERVER
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "server_stop\n");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "server_stop\n");
#endif
struct MHD_Daemon *server_v4_tmp = plugin->server_v4;
@@ -1236,16 +1242,17 @@ server_stop (struct Plugin *plugin)
"Deleting semi-sessions %p\n", s);
#endif
t = s->next;
- struct HTTP_Message * msg = s->msg_head;
- struct HTTP_Message * tmp = s->msg_head;
+ struct HTTP_Message *msg = s->msg_head;
+ struct HTTP_Message *tmp = s->msg_head;
+
while (msg != NULL)
{
tmp = msg->next;
- GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg);
+ GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg);
if (msg->transmit_cont != NULL)
{
- msg->transmit_cont(msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
+ msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR);
}
GNUNET_free (msg);
msg = tmp;
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index a0d5072b8..1ef0bca98 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -267,7 +267,7 @@ struct BroadcastAddress
struct BroadcastAddress *next;
struct BroadcastAddress *prev;
- void * addr;
+ void *addr;
socklen_t addrlen;
};
@@ -540,8 +540,11 @@ destroy_session (void *cls, const GNUNET_HashCode * key, void *value)
struct Session *peer_session = value;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (peer_session->plugin->sessions,
- &peer_session->target.hashPubKey, peer_session));
+ GNUNET_CONTAINER_multihashmap_remove (peer_session->
+ plugin->sessions,
+ &peer_session->
+ target.hashPubKey,
+ peer_session));
if (peer_session->frag != NULL)
GNUNET_FRAGMENT_context_destroy (peer_session->frag);
if (GNUNET_SCHEDULER_NO_TASK != peer_session->delayed_cont_task)
@@ -568,7 +571,8 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value)
GNUNET_SCHEDULER_cancel (s->invalidation_task);
if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task)
GNUNET_SCHEDULER_cancel (s->delayed_cont_task);
- GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions, &s->target.hashPubKey, s);
+ GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions,
+ &s->target.hashPubKey, s);
GNUNET_free (s);
return GNUNET_OK;
}
@@ -1300,42 +1304,46 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
switch (ntohs (msg->type))
{
case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON:
+ {
+ if (fromlen == sizeof (struct sockaddr_in))
{
- if (fromlen == sizeof (struct sockaddr_in))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n",
- ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen));
-
- struct Mstv4Context *mc;
- mc = GNUNET_malloc (sizeof (struct Mstv4Context));
- 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_ipv4_mst, mc, buf, ret, GNUNET_NO,
- GNUNET_NO))
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n",
+ ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen));
+
+ struct Mstv4Context *mc;
+
+ mc = GNUNET_malloc (sizeof (struct Mstv4Context));
+ 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_ipv4_mst, mc, buf, ret,
+ GNUNET_NO, GNUNET_NO))
GNUNET_free (mc);
- }
- else if (fromlen == sizeof (struct sockaddr_in6))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n",
- ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen));
+ }
+ else if (fromlen == sizeof (struct sockaddr_in6))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n",
+ ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen));
- struct Mstv6Context *mc;
- mc = GNUNET_malloc (sizeof (struct Mstv6Context));
- struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr;
+ struct Mstv6Context *mc;
- mc->addr.ipv6_addr = av6->sin6_addr;
- mc->addr.u6_port = av6->sin6_port;
+ mc = GNUNET_malloc (sizeof (struct Mstv6Context));
+ struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr;
- if (GNUNET_OK !=
- GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret, GNUNET_NO,
- GNUNET_NO))
- GNUNET_free (mc);
- }
- return;
+ mc->addr.ipv6_addr = av6->sin6_addr;
+ mc->addr.u6_port = av6->sin6_port;
+
+ if (GNUNET_OK !=
+ GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret,
+ GNUNET_NO, GNUNET_NO))
+ GNUNET_free (mc);
}
+ return;
+ }
case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE:
if (ntohs (msg->size) < sizeof (struct UDPMessage))
{
@@ -1489,7 +1497,7 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
void
broadcast_ipv4_mst_cb (void *cls, void *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct Plugin *plugin = cls;
struct Mstv4Context *mc = client;
@@ -1517,15 +1525,16 @@ broadcast_ipv4_mst_cb (void *cls, void *client,
(const char *) &mc->addr, sizeof (mc->addr));
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# IPv4 broadcast HELLO beacons received via udp"), 1,
- GNUNET_NO);
+ _
+ ("# IPv4 broadcast HELLO beacons received via udp"),
+ 1, GNUNET_NO);
GNUNET_free (mc);
}
void
broadcast_ipv6_mst_cb (void *cls, void *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct Plugin *plugin = cls;
@@ -1554,14 +1563,16 @@ broadcast_ipv6_mst_cb (void *cls, void *client,
(const char *) &mc->addr, sizeof (mc->addr));
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# IPv6 multicast HELLO beacons received via udp"), 1,
- GNUNET_NO);
+ _
+ ("# IPv6 multicast HELLO beacons received via udp"),
+ 1, GNUNET_NO);
GNUNET_free (mc);
}
static void
-udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+udp_ipv4_broadcast_send (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
int sent;
@@ -1571,7 +1582,7 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
const struct GNUNET_MessageHeader *hello;
struct UDP_Beacon_Message *msg;
- struct BroadcastAddress * baddr;
+ struct BroadcastAddress *baddr;
plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
@@ -1594,18 +1605,21 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
/* just IPv4 */
while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
{
- struct sockaddr_in * addr = (struct sockaddr_in * ) baddr->addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr;
+
addr->sin_port = htons (plugin->port);
- sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size,
- (const struct sockaddr *) addr,
- baddr->addrlen);
+ sent =
+ GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size,
+ (const struct sockaddr *) addr,
+ baddr->addrlen);
if (sent == GNUNET_SYSERR)
- GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes to address %s\n",
- sent, GNUNET_a2s(baddr->addr, baddr->addrlen));
- baddr = baddr->next;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sent HELLO beacon broadcast with %i bytes to address %s\n", sent,
+ GNUNET_a2s (baddr->addr, baddr->addrlen));
+ baddr = baddr->next;
}
plugin->send_ipv4_broadcast_task =
@@ -1614,7 +1628,8 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
}
static void
-udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+udp_ipv6_broadcast_send (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Plugin *plugin = cls;
int sent;
@@ -1642,14 +1657,19 @@ udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
memcpy (&msg[1], hello, hello_size);
sent = 0;
- sent = GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size,
- (const struct sockaddr *) &plugin->ipv6_multicast_address,
- sizeof(struct sockaddr_in6));
+ sent =
+ GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size,
+ (const struct sockaddr *)
+ &plugin->ipv6_multicast_address,
+ sizeof (struct sockaddr_in6));
if (sent == GNUNET_SYSERR)
- GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n",
- sent, GNUNET_a2s((const struct sockaddr *) &plugin->ipv6_multicast_address, sizeof(struct sockaddr_in6)));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n",
+ sent,
+ GNUNET_a2s ((const struct sockaddr *) &plugin->ipv6_multicast_address,
+ sizeof (struct sockaddr_in6)));
@@ -1953,33 +1973,33 @@ udp_nat_port_map_callback (void *cls, int add_remove,
static int
-iface_proc (void *cls, const char *name,
- int isDefault,
- const struct sockaddr * addr,
- const struct sockaddr * broadcast_addr,
- const struct sockaddr * netmask,
- socklen_t addrlen)
+iface_proc (void *cls, const char *name, int isDefault,
+ const struct sockaddr *addr, const struct sockaddr *broadcast_addr,
+ const struct sockaddr *netmask, socklen_t addrlen)
{
struct Plugin *plugin = cls;
if (addr != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ",
- GNUNET_a2s(addr,addrlen), name, addr);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "broadcast address %s for interface %s %p\n ",
- GNUNET_a2s(broadcast_addr,addrlen), name, broadcast_addr);
+ GNUNET_a2s (addr, addrlen), name, addr);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "broadcast address %s for interface %s %p\n ",
+ GNUNET_a2s (broadcast_addr, addrlen), name, broadcast_addr);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
- GNUNET_a2s(netmask,addrlen), name, netmask);
+ GNUNET_a2s (netmask, addrlen), name, netmask);
- /* Collecting broadcast addresses*/
+ /* Collecting broadcast addresses */
if (broadcast_addr != NULL)
{
- struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct BroadcastAddress));
- ba->addr = GNUNET_malloc(addrlen);
- memcpy(ba->addr, broadcast_addr, addrlen);
+ struct BroadcastAddress *ba =
+ GNUNET_malloc (sizeof (struct BroadcastAddress));
+ ba->addr = GNUNET_malloc (addrlen);
+ memcpy (ba->addr, broadcast_addr, addrlen);
ba->addrlen = addrlen;
- GNUNET_CONTAINER_DLL_insert(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, ba);
+ GNUNET_CONTAINER_DLL_insert (plugin->ipv4_broadcast_head,
+ plugin->ipv4_broadcast_tail, ba);
}
}
return GNUNET_OK;
@@ -2225,73 +2245,80 @@ libgnunet_plugin_transport_udp_init (void *cls)
{
/* create IPv4 broadcast socket */
plugin->broadcast_ipv4 = GNUNET_NO;
- if (plugin->sockv4 != NULL)
- {
- int yes = 1;
+ if (plugin->sockv4 != NULL)
+ {
+ int yes = 1;
- if (GNUNET_NETWORK_socket_setsockopt
- (plugin->sockv4, 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));
- }
- else
- {
- GNUNET_OS_network_interfaces_list(iface_proc, plugin);
- plugin->send_ipv4_broadcast_task =
+ if (GNUNET_NETWORK_socket_setsockopt
+ (plugin->sockv4, 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));
+ }
+ else
+ {
+ GNUNET_OS_network_interfaces_list (iface_proc, plugin);
+ plugin->send_ipv4_broadcast_task =
GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, plugin);
- plugin->broadcast_ipv4_mst =
- GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin);
+ plugin->broadcast_ipv4_mst =
+ GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n");
- plugin->broadcast_ipv4 = GNUNET_YES;
- }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n");
+ plugin->broadcast_ipv4 = GNUNET_YES;
}
+ }
- plugin->broadcast_ipv6 = GNUNET_NO;
- if (plugin->sockv6 != NULL)
+ plugin->broadcast_ipv6 = GNUNET_NO;
+ if (plugin->sockv6 != NULL)
+ {
+ memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6));
+ GNUNET_assert (1 ==
+ inet_pton (AF_INET6, "FF05::13B",
+ &plugin->ipv6_multicast_address.sin6_addr));
+
+ plugin->ipv6_multicast_address.sin6_family = AF_INET6;
+ plugin->ipv6_multicast_address.sin6_port = htons (plugin->port);
+
+ plugin->broadcast_ipv6_mst =
+ GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin);
+
+ /* Create IPv6 multicast request */
+ struct ipv6_mreq multicastRequest;
+
+ multicastRequest.ipv6mr_multiaddr =
+ plugin->ipv6_multicast_address.sin6_addr;
+ /* TODO: 0 selects the "best" interface, tweak to use all interfaces
+ *
+ * http://tools.ietf.org/html/rfc2553#section-5.2:
+ *
+ * IPV6_JOIN_GROUP
+ *
+ * Join a multicast group on a specified local interface. If the
+ * interface index is specified as 0, the kernel chooses the local
+ * interface. For example, some kernels look up the multicast
+ * group in the normal IPv6 routing table and using the resulting
+ * interface.
+ * */
+ multicastRequest.ipv6mr_interface = 0;
+
+ /* Join the multicast group */
+ if (GNUNET_NETWORK_socket_setsockopt
+ (plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ (char *) &multicastRequest, sizeof (multicastRequest)) == GNUNET_OK)
{
- memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6));
- GNUNET_assert (1 == inet_pton(AF_INET6, "FF05::13B", &plugin->ipv6_multicast_address.sin6_addr));
-
- plugin->ipv6_multicast_address.sin6_family = AF_INET6;
- plugin->ipv6_multicast_address.sin6_port = htons(plugin->port);
-
- plugin->broadcast_ipv6_mst =
- GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin);
-
- /* Create IPv6 multicast request */
- struct ipv6_mreq multicastRequest;
- multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr;
- /* TODO: 0 selects the "best" interface, tweak to use all interfaces
- *
- * http://tools.ietf.org/html/rfc2553#section-5.2:
- *
- * IPV6_JOIN_GROUP
- *
- * Join a multicast group on a specified local interface. If the
- * interface index is specified as 0, the kernel chooses the local
- * interface. For example, some kernels look up the multicast
- * group in the normal IPv6 routing table and using the resulting
- * interface.
- * */
- multicastRequest.ipv6mr_interface = 0;
-
- /* Join the multicast group */
- if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == GNUNET_OK )
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
- plugin->send_ipv6_broadcast_task =
+ plugin->send_ipv6_broadcast_task =
GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin);
- plugin->broadcast_ipv6 = GNUNET_YES;
- }
- else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n");
+ plugin->broadcast_ipv6 = GNUNET_YES;
}
+ else
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n");
+ }
}
if (sockets_created == 0)
@@ -2351,8 +2378,10 @@ libgnunet_plugin_transport_udp_done (void *cls)
while (plugin->ipv4_broadcast_head != NULL)
{
- struct BroadcastAddress * p= plugin->ipv4_broadcast_head;
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, p);
+ struct BroadcastAddress *p = plugin->ipv4_broadcast_head;
+
+ GNUNET_CONTAINER_DLL_remove (plugin->ipv4_broadcast_head,
+ plugin->ipv4_broadcast_tail, p);
GNUNET_free (p->addr);
GNUNET_free (p);
}
@@ -2362,16 +2391,20 @@ libgnunet_plugin_transport_udp_done (void *cls)
{
/* Create IPv6 multicast request */
struct ipv6_mreq multicastRequest;
- multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr;
+
+ multicastRequest.ipv6mr_multiaddr =
+ plugin->ipv6_multicast_address.sin6_addr;
multicastRequest.ipv6mr_interface = 0;
/* Join the multicast address */
- if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == 0 )
+ if (GNUNET_NETWORK_socket_setsockopt
+ (plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
+ (char *) &multicastRequest, sizeof (multicastRequest)) == 0)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n");
}
else
- GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, setsockopt);
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, setsockopt);
if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
{
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index c7029a579..bf5411d59 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -355,7 +355,7 @@ struct Sessionqueue
struct Sessionqueue *prev;
struct Session *content;
#if !HAVE_UNALIGNED_64_ACCESS
- void *dummy; /* for alignment, see #1909 */
+ void *dummy; /* for alignment, see #1909 */
#endif
};
@@ -1066,8 +1066,9 @@ set_next_send (struct Plugin *const plugin)
struct GNUNET_TIME_Relative next_send;
//abort if helper is not running
- if (plugin->helper_is_running == GNUNET_NO){
- return;
+ if (plugin->helper_is_running == GNUNET_NO)
+ {
+ return;
}
//cancel old task
@@ -1465,12 +1466,13 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
const char *filenameloopback = "gnunet-transport-wlan-helper-dummy";
char *absolute_filename = NULL;
- if (plugin->helper_is_running == GNUNET_YES){
+ if (plugin->helper_is_running == GNUNET_YES)
+ {
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_transport_start_wlan_helper not needed, helper already running!");
#endif
- return GNUNET_YES;
+ return GNUNET_YES;
}
plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
@@ -1634,12 +1636,13 @@ wlan_transport_stop_wlan_helper (struct Plugin *plugin)
"Stoping WLAN helper process\n");
#endif
- if (plugin->helper_is_running == GNUNET_NO){
+ if (plugin->helper_is_running == GNUNET_NO)
+ {
#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_transport_stop_wlan_helper not needed, helper already stopped!");
#endif
- return GNUNET_YES;
+ return GNUNET_YES;
}
if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -2604,13 +2607,15 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
crc = ntohl (wlanheader->crc);
wlanheader->crc = 0;
- if (GNUNET_CRYPTO_crc32_n ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
+ if (GNUNET_CRYPTO_crc32_n
+ ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
{
//wrong crc, dispose message
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
"Wlan message header crc was wrong: %u != %u\n",
GNUNET_CRYPTO_crc32_n ((char *) wlanheader,
- ntohs (wlanheader->header.size)), crc);
+ ntohs (wlanheader->header.size)),
+ crc);
hexdump ((void *) hdr, ntohs (hdr->size));
return;
}
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 52051954b..1742dd0d3 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -484,8 +484,7 @@ generate_config (char *cfg_file, unsigned long long quota_in,
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, "ats", "WAN_QUOTA_IN",
- quota_in);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_IN", quota_in);
GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "WAN_QUOTA_OUT",
quota_out);
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname));
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c
index aa6f98027..20005deab 100644
--- a/src/transport/test_transport_api_bidirectional_connect.c
+++ b/src/transport/test_transport_api_bidirectional_connect.c
@@ -312,10 +312,12 @@ start_cb (struct PeerContext *p, void *cls)
"Test tries to connect peer %u (`%s') <-> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
- cc1 = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
- NULL);
- cc2 = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
- NULL);
+ cc1 =
+ GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
+ NULL);
+ cc2 =
+ GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
}
static void
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 7dd9bd913..026ed085a 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -128,7 +128,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
cc = NULL;
}
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 87383bbac..61423a7ee 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -155,10 +155,12 @@ static void
reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerContext *p = cls;
+
reconnect_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_TRANSPORT_try_connect (p->th, &p2->id);
- reconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
+ reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
}
static void
@@ -166,20 +168,17 @@ restart_cb (struct PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peer %u (`%4s'), issuing reconnect\n",
- p->no,
+ "Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
GNUNET_i2s (&p->id));
- reconnect_task = GNUNET_SCHEDULER_add_now(&reconnect, p);
+ reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
}
-static
-void restart (struct PeerContext *p , char * cfg_file)
+static void
+restart (struct PeerContext *p, char *cfg_file)
{
GNUNET_assert (p != NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarting peer %u (`%4s')\n",
- p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p);
return;
@@ -200,6 +199,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_assert (t != NULL);
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
@@ -217,8 +217,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peers connected, stopping test...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarted peers connected, stopping test...\n");
ok = 0;
end ();
}
@@ -329,6 +329,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
GNUNET_i2s (peer));
@@ -368,6 +369,7 @@ start_cb (struct PeerContext *p, void *cls)
return;
char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
@@ -451,8 +453,8 @@ main (int argc, char *argv[])
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_asprintf(&cfg_file_p1,"test_transport_api_tcp_peer1.conf");
- GNUNET_asprintf(&cfg_file_p2,"test_transport_api_tcp_peer2.conf");
+ GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf");
+ GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf");
ret = check ();
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c
index 44a41614f..67cc90f0e 100644
--- a/src/transport/test_transport_api_restart_2peers.c
+++ b/src/transport/test_transport_api_restart_2peers.c
@@ -155,36 +155,36 @@ static void
reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerContext *p = cls;
+
reconnect_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_TRANSPORT_try_connect (p1->th, &p2->id);
- reconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
+ reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
}
static void
restart_cb (struct PeerContext *p, void *cls)
{
static int c;
+
c++;
if (c != 2)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peer %u (`%4s'), issuing reconnect\n",
- p->no,
+ "Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
GNUNET_i2s (&p->id));
- reconnect_task = GNUNET_SCHEDULER_add_now(&reconnect, p);
+ reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
}
-static
-void restart (struct PeerContext *p , char * cfg_file)
+static void
+restart (struct PeerContext *p, char *cfg_file)
{
GNUNET_assert (p != NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarting peer %u (`%4s')\n",
- p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p);
return;
@@ -205,6 +205,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_assert (t != NULL);
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
@@ -223,8 +224,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peers connected, stopping test...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarted peers connected, stopping test...\n");
ok = 0;
end ();
}
@@ -335,6 +336,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
GNUNET_i2s (peer));
@@ -374,6 +376,7 @@ start_cb (struct PeerContext *p, void *cls)
return;
char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
@@ -457,8 +460,8 @@ main (int argc, char *argv[])
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_asprintf(&cfg_file_p1,"test_transport_api_tcp_peer1.conf");
- GNUNET_asprintf(&cfg_file_p2,"test_transport_api_tcp_peer2.conf");
+ GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf");
+ GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf");
ret = check ();
@@ -472,4 +475,5 @@ main (int argc, char *argv[])
return ret;
}
+
/* end of test_transport_api_restart_2peers.c */
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 90defae02..e52b20f7c 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -229,10 +229,9 @@ get_size (unsigned int iter)
#ifndef LINUX
/* FreeBSD/OSX etc. Unix DGRAMs do not work
- with large messages */
- if (0 == strcmp ("unix",
- test_plugin))
- return sizeof (struct TestMessage) + (ret % 1024);
+ * with large messages */
+ if (0 == strcmp ("unix", test_plugin))
+ return sizeof (struct TestMessage) + (ret % 1024);
#endif
return sizeof (struct TestMessage) + (ret % 60000);
}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index e45953239..9f7a99a7b 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -284,22 +284,22 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
- if (GNUNET_CONFIGURATION_have_value (p->
- cfg, "PATHS", "SERVICEHOME"))
+ if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "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);
+ if (NULL != p->servicehome)
+ GNUNET_DISK_directory_remove (p->servicehome);
- hostkey = get_host_key(tth);
+ hostkey = get_host_key (tth);
if (hostkey != NULL)
{
GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome);
- GNUNET_assert(GNUNET_OK == GNUNET_DISK_directory_create_for_file (p->hostkeyfile));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_DISK_directory_create_for_file (p->hostkeyfile));
fn = GNUNET_DISK_file_open (p->hostkeyfile,
GNUNET_DISK_OPEN_READWRITE |
GNUNET_DISK_OPEN_CREATE,
@@ -355,11 +355,11 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
* @return GNUNET_OK in success otherwise GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, struct PeerContext *p,
const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
- void *cb_cls)
+ GNUNET_TRANSPORT_TESTING_start_cb
+ restart_cb, void *cb_cls)
{
struct GNUNET_DISK_FileHandle *fn;
@@ -370,9 +370,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
/* shutdown */
#if VERBOSE
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Stopping peer %u (`%s')\n", p->no,
- GNUNET_i2s (&p->id));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
#endif
if (p->ghh != NULL)
GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
@@ -400,48 +399,48 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
/* start */
#if VERBOSE
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Restarting peer %u (`%s')\n", p->no,
- GNUNET_i2s (&p->id));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
#endif
- sleep (5); // YUCK!
+ sleep (5); // YUCK!
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);
goto fail;
}
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
- if (! GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
+ if (!GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
goto fail;
fn = GNUNET_DISK_file_open (p->hostkeyfile,
- GNUNET_DISK_OPEN_READWRITE |
- GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
+ GNUNET_DISK_OPEN_READWRITE |
+ GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
if (fn == NULL)
- goto fail;
+ goto fail;
if (GNUNET_OK != GNUNET_DISK_file_close (fn))
- goto fail;
+ goto fail;
- p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm", "-c", cfgname,
- #if VERBOSE_PEERS
- "-L", "DEBUG",
- #else
- "-L", "ERROR",
- #endif
- NULL);
+ p->arm_proc =
+ GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ "gnunet-service-arm", "-c", cfgname,
+#if VERBOSE_PEERS
+ "-L", "DEBUG",
+#else
+ "-L", "ERROR",
+#endif
+ NULL);
p->th =
- GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
- &notify_connect, &notify_disconnect);
+ GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
+ &notify_connect, &notify_disconnect);
GNUNET_assert (p->th != NULL);
p->start_cb = restart_cb;
@@ -451,11 +450,11 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
GNUNET_assert (p->ghh != NULL);
return GNUNET_OK;
- fail:
+fail:
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Restarting peer %u (`%s') failed, removing peer\n", p->no,
- GNUNET_i2s (&p->id));
- GNUNET_TRANSPORT_TESTING_stop_peer (tth,p);
+ "Restarting peer %u (`%s') failed, removing peer\n", p->no,
+ GNUNET_i2s (&p->id));
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
return GNUNET_SYSERR;
}
@@ -643,11 +642,11 @@ GNUNET_TRANSPORT_TESTING_init ()
/* prepare hostkeys */
tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
tth->hostkey_data = NULL;
- const char * hostkeys_file = "../../contrib/testing_hostkeys.dat";
+ const char *hostkeys_file = "../../contrib/testing_hostkeys.dat";
+
if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Could not read hostkeys file!\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not read hostkeys file!\n"));
}
else
{
@@ -656,8 +655,7 @@ GNUNET_TRANSPORT_TESTING_init ()
GNUNET_DISK_PERM_NONE);
if (NULL == fd)
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
- hostkeys_file);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file);
GNUNET_free (tth);
return NULL;
}
@@ -668,7 +666,7 @@ GNUNET_TRANSPORT_TESTING_init ()
if (0 != (fs % HOSTKEYFILESIZE))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
- "File size %llu seems incorrect for hostkeys...\n", fs);
+ "File size %llu seems incorrect for hostkeys...\n", fs);
}
else
{
@@ -676,7 +674,7 @@ GNUNET_TRANSPORT_TESTING_init ()
tth->hostkey_data = GNUNET_malloc_large (fs);
GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
- "Read %llu hostkeys from file\n", total_hostkeys);
+ "Read %llu hostkeys from file\n", total_hostkeys);
tth->hostkeys_total = total_hostkeys;
}
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 883c68837..c77d79381 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -169,11 +169,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
* @return GNUNET_OK in success otherwise GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
+ *tth, struct PeerContext *p,
const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb start_cb,
- void *cb_cls);
+ GNUNET_TRANSPORT_TESTING_start_cb
+ start_cb, void *cb_cls);
/**
* Connect the given peers and call the callback when both peers report the
diff --git a/src/transport/transport.h b/src/transport/transport.h
index bfcf9fe6e..d2792b92d 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -401,7 +401,7 @@ struct AddressIterateResponseMessage
* length of the plugin name
*/
uint32_t pluginlen GNUNET_PACKED;
-
+
};
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index 7cd61e896..9ae9b4031 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -93,7 +93,8 @@ peer_address_response_processor (void *cls,
return;
}
size = ntohs (msg->size);
- GNUNET_break (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
+ GNUNET_break (ntohs (msg->type) ==
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
if (size == sizeof (struct GNUNET_MessageHeader))
{
/* done! */
@@ -102,8 +103,11 @@ peer_address_response_processor (void *cls,
return;
}
- if ( (size < sizeof (struct GNUNET_MessageHeader) + sizeof (struct AddressIterateResponseMessage)) ||
- (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE) )
+ if ((size <
+ sizeof (struct GNUNET_MessageHeader) +
+ sizeof (struct AddressIterateResponseMessage)) ||
+ (ntohs (msg->type) !=
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE))
{
GNUNET_break (0);
pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
@@ -112,8 +116,8 @@ peer_address_response_processor (void *cls,
}
air_msg = (struct AddressIterateResponseMessage *) msg;
- tlen = ntohl(air_msg->pluginlen);
- alen = ntohl(air_msg->addrlen);
+ tlen = ntohl (air_msg->pluginlen);
+ alen = ntohl (air_msg->addrlen);
if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen)
{
@@ -126,7 +130,7 @@ peer_address_response_processor (void *cls,
addr = (const char *) &air_msg[1];
transport_name = &addr[alen];
- if (transport_name[tlen-1] != '\0')
+ if (transport_name[tlen - 1] != '\0')
{
GNUNET_break_op (0);
pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
@@ -135,13 +139,14 @@ peer_address_response_processor (void *cls,
}
/* expect more replies */
- GNUNET_CLIENT_receive (pal_ctx->client,
- &peer_address_response_processor, pal_ctx,
+ GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor,
+ pal_ctx,
GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout));
/* notify client */
- address = GNUNET_HELLO_address_allocate (&air_msg->peer,
- transport_name, addr, alen);
+ address =
+ GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr,
+ alen);
pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address);
GNUNET_HELLO_address_free (address);
}
@@ -165,11 +170,13 @@ peer_address_response_processor (void *cls,
* @param peer_address_callback_cls closure for peer_address_callback
*/
struct GNUNET_TRANSPORT_PeerIterateContext *
-GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_PeerIdentity *peer,
- int one_shot,
+GNUNET_TRANSPORT_peer_get_active_addresses (const struct
+ GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_PeerIdentity
+ *peer, int one_shot,
struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_PeerIterateCallback peer_address_callback,
+ GNUNET_TRANSPORT_PeerIterateCallback
+ peer_address_callback,
void *peer_address_callback_cls)
{
struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx;
@@ -180,7 +187,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
if (GNUNET_YES != one_shot)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Address monitoring not implemented\n");
+ "Address monitoring not implemented\n");
return NULL;
}
client = GNUNET_CLIENT_connect ("transport", cfg);
@@ -192,7 +199,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
msg.one_shot = htonl (one_shot);
msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout);
if (peer == NULL)
- memset (&msg.peer, 0 , sizeof (struct GNUNET_PeerIdentity));
+ memset (&msg.peer, 0, sizeof (struct GNUNET_PeerIdentity));
else
msg.peer = *peer;
pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext));
@@ -216,8 +223,8 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha
*/
void
GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct
- GNUNET_TRANSPORT_PeerIterateContext
- *alc)
+ GNUNET_TRANSPORT_PeerIterateContext
+ *alc)
{
GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO);
GNUNET_free (alc);
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c
index 5c44c288b..4d809530a 100644
--- a/src/transport/transport_api_address_to_string.c
+++ b/src/transport/transport_api_address_to_string.c
@@ -76,7 +76,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
return;
}
GNUNET_break (ntohs (msg->type) ==
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
size = ntohs (msg->size);
if (size == sizeof (struct GNUNET_MessageHeader))
{
@@ -116,12 +116,13 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
* @return handle to cancel the operation, NULL on error
*/
struct GNUNET_TRANSPORT_AddressToStringContext *
-GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_HELLO_Address *address,
- int numeric,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_AddressToStringCallback aluc,
- void *aluc_cls)
+GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle
+ *cfg,
+ const struct GNUNET_HELLO_Address *address,
+ int numeric,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TRANSPORT_AddressToStringCallback
+ aluc, void *aluc_cls)
{
size_t len;
size_t alen;
@@ -145,8 +146,7 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
if (client == NULL)
return NULL;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNUNET_TRANSPORT_address_to_string\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_TRANSPORT_address_to_string\n");
#endif
msg = GNUNET_malloc (len);
msg->header.size = htons (len);
@@ -180,8 +180,8 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
*/
void
GNUNET_TRANSPORT_address_to_string_cancel (struct
- GNUNET_TRANSPORT_AddressToStringContext
- *alc)
+ GNUNET_TRANSPORT_AddressToStringContext
+ *alc)
{
GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO);
GNUNET_free (alc);