summaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats_api.c4
-rw-r--r--src/ats/ats_api_performance.c4
-rw-r--r--src/ats/ats_api_scheduling.c81
-rw-r--r--src/ats/gnunet-service-ats_addresses.c43
-rw-r--r--src/ats/gnunet-service-ats_addresses.h3
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c23
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h5
-rw-r--r--src/ats/test_ats_api_scheduling.c12
8 files changed, 83 insertions, 92 deletions
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c
index 47daad6cf..7c0fb2d32 100644
--- a/src/ats/ats_api.c
+++ b/src/ats/ats_api.c
@@ -342,9 +342,9 @@ GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
atc->peers = GNUNET_CONTAINER_multihashmap_create (256);
atc->notify_map = GNUNET_CONTAINER_multihashmap_create (256);
GNUNET_CONFIGURATION_get_value_size (cfg, "ats", "WAN_QUOTA_OUT",
- &atc->total_bps_out);
+ &atc->total_bps_out);
GNUNET_CONFIGURATION_get_value_size (cfg, "ats", "WAN_QUOTA_IN",
- &atc->total_bps_in);
+ &atc->total_bps_in);
return atc;
}
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index 9739ac1e5..c9f9a0b38 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -307,8 +307,8 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
address.address = plugin_address;
address.address_length = plugin_address_length;
address.transport_name = plugin_name;
- ph->infocb (ph->infocb_cls, &address,
- pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count);
+ ph->infocb (ph->infocb_cls, &address, pi->bandwidth_out, pi->bandwidth_in,
+ atsi, ats_count);
return GNUNET_OK;
}
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 89a3bb472..0658e362c 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -287,11 +287,8 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Find session %u from peer %s in %p\n",
- (unsigned int) session_id,
- GNUNET_i2s (peer),
- sh);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Find session %u from peer %s in %p\n",
+ (unsigned int) session_id, GNUNET_i2s (peer), sh);
#endif
if (session_id >= sh->session_array_size)
{
@@ -303,14 +300,14 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
if (sh->session_array[session_id].session == NULL)
{
GNUNET_break (0 ==
- memcmp (peer, &sh->session_array[session_id].peer,
- sizeof (struct GNUNET_PeerIdentity)));
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
return NULL;
}
if (0 !=
memcmp (peer, &sh->session_array[session_id].peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
sh->reconnect = GNUNET_YES;
@@ -338,10 +335,8 @@ get_session_id (struct GNUNET_ATS_SchedulingHandle *sh, struct Session *session,
#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get session ID for session %p from peer %s in %p\n",
- session,
- GNUNET_i2s (peer),
- sh);
+ "Get session ID for session %p from peer %s in %p\n", session,
+ GNUNET_i2s (peer), sh);
#endif
if (NULL == session)
return 0;
@@ -350,8 +345,9 @@ get_session_id (struct GNUNET_ATS_SchedulingHandle *sh, struct Session *session,
{
if (session == sh->session_array[i].session)
{
- GNUNET_assert (0 == memcmp (peer, &sh->session_array[i].peer,
- sizeof (struct GNUNET_PeerIdentity)));
+ GNUNET_assert (0 ==
+ memcmp (peer, &sh->session_array[i].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
return i;
}
if ((f == 0) && (sh->session_array[i].slot_used == GNUNET_NO))
@@ -369,11 +365,8 @@ get_session_id (struct GNUNET_ATS_SchedulingHandle *sh, struct Session *session,
sh->session_array[f].slot_used = GNUNET_YES;
#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Assigning session ID %u for session %p of peer %s in %p\n",
- f,
- session,
- GNUNET_i2s (peer),
- sh);
+ "Assigning session ID %u for session %p of peer %s in %p\n", f,
+ session, GNUNET_i2s (peer), sh);
#endif
return f;
}
@@ -393,16 +386,15 @@ remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
{
#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Remove sessionID %u from peer %s in %p\n",
- (unsigned int) session_id,
- GNUNET_i2s (peer),
- sh);
+ "Remove sessionID %u from peer %s in %p\n",
+ (unsigned int) session_id, GNUNET_i2s (peer), sh);
#endif
if (0 == session_id)
return;
GNUNET_assert (session_id < sh->session_array_size);
GNUNET_assert (GNUNET_YES == sh->session_array[session_id].slot_used);
- GNUNET_assert (0 == memcmp (peer, &sh->session_array[session_id].peer,
+ GNUNET_assert (0 ==
+ memcmp (peer, &sh->session_array[session_id].peer,
sizeof (struct GNUNET_PeerIdentity)));
sh->session_array[session_id].session = NULL;
}
@@ -422,10 +414,8 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
{
#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Release sessionID %u from peer %s in %p\n",
- (unsigned int) session_id,
- GNUNET_i2s (peer),
- sh);
+ "Release sessionID %u from peer %s in %p\n",
+ (unsigned int) session_id, GNUNET_i2s (peer), sh);
#endif
if (session_id >= sh->session_array_size)
{
@@ -437,7 +427,8 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
/* this slot should have been removed from remove_session before */
GNUNET_assert (sh->session_array[session_id].session == NULL);
- if (0 != memcmp (peer, &sh->session_array[session_id].peer,
+ if (0 !=
+ memcmp (peer, &sh->session_array[session_id].peer,
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
@@ -477,7 +468,7 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
uint16_t plugin_name_length;
uint32_t ats_count;
struct GNUNET_HELLO_Address address;
- struct Session * s;
+ struct Session *s;
if (NULL == msg)
{
@@ -519,7 +510,7 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
force_reconnect (sh);
return;
}
- uint32_t session_id = ntohl (m->session_id);
+ uint32_t session_id = ntohl (m->session_id);
if (session_id == 0)
s = NULL;
@@ -529,9 +520,9 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
if (s == NULL)
{
#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS tries to use outdated session `%s'\n",
- GNUNET_i2s(&m->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "ATS tries to use outdated session `%s'\n",
+ GNUNET_i2s (&m->peer));
#endif
GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
GNUNET_TIME_UNIT_FOREVER_REL);
@@ -545,9 +536,10 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
if ((s == NULL) && (0 == address.address_length))
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "ATS returned invalid address for peer `%s' transport `%s' address length %i, session_id %i\n",
- GNUNET_i2s(&address.peer) , address.transport_name, plugin_address_length, session_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "ATS returned invalid address for peer `%s' transport `%s' address length %i, session_id %i\n",
+ GNUNET_i2s (&address.peer), address.transport_name,
+ plugin_address_length, session_id);
GNUNET_break_op (0);
GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
GNUNET_TIME_UNIT_FOREVER_REL);
@@ -731,7 +723,9 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
size_t namelen;
size_t msize;
- namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1;
+ namelen =
+ (address->transport_name ==
+ NULL) ? 0 : strlen (address->transport_name) + 1;
msize =
sizeof (struct AddressUpdateMessage) + address->address_length +
ats_count * sizeof (struct GNUNET_ATS_Information) + namelen;
@@ -778,8 +772,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
void
GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- int in_use)
+ struct Session *session, int in_use)
{
struct PendingMessage *p;
struct AddressUseMessage *m;
@@ -788,7 +781,9 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
size_t msize;
GNUNET_assert (NULL != address);
- namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1;
+ namelen =
+ (address->transport_name ==
+ NULL) ? 0 : strlen (address->transport_name) + 1;
msize = sizeof (struct AddressUseMessage) + address->address_length + namelen;
if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
(address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
@@ -839,7 +834,9 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
GNUNET_assert (address->transport_name != NULL);
namelen = strlen (address->transport_name) + 1;
GNUNET_assert (namelen > 1);
- msize = sizeof (struct AddressDestroyedMessage) + address->address_length + namelen;
+ msize =
+ sizeof (struct AddressDestroyedMessage) + address->address_length +
+ namelen;
if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
(address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
(namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 04eacbbb1..e9f7539be 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -305,26 +305,22 @@ destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value)
const struct ATS_Address *info = cls;
struct ATS_Address *aa = value;
- GNUNET_assert (0 == memcmp (&aa->peer,
- &info->peer,
- sizeof (struct GNUNET_PeerIdentity)));
- if ( (info->session_id == 0) &&
- (0 == strcmp (info->plugin,
- aa->plugin)) &&
- (aa->addr_len == info->addr_len) &&
- (0 == memcmp (info->addr,
- aa->addr,
- aa->addr_len)) )
+ GNUNET_assert (0 ==
+ memcmp (&aa->peer, &info->peer,
+ sizeof (struct GNUNET_PeerIdentity)));
+ if ((info->session_id == 0) && (0 == strcmp (info->plugin, aa->plugin)) &&
+ (aa->addr_len == info->addr_len) &&
+ (0 == memcmp (info->addr, aa->addr, aa->addr_len)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting address for peer `%s': `%s'\n",
- GNUNET_i2s (&aa->peer), aa->plugin);
+ "Deleting address for peer `%s': `%s'\n",
+ GNUNET_i2s (&aa->peer), aa->plugin);
if (GNUNET_YES == destroy_address (aa))
recalculate_assigned_bw ();
return GNUNET_OK;
}
if (aa->session_id != info->session_id)
- return GNUNET_OK; /* irrelevant */
+ return GNUNET_OK; /* irrelevant */
if (aa->session_id != 0)
GNUNET_break (0 == strcmp (info->plugin, aa->plugin));
/* session died */
@@ -358,10 +354,8 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
aa.addr = plugin_addr;
aa.plugin = (char *) plugin_name;
aa.session_id = session_id;
- GNUNET_CONTAINER_multihashmap_get_multiple (addresses,
- &peer->hashPubKey,
- &destroy_by_session_id,
- &aa);
+ GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
+ &destroy_by_session_id, &aa);
}
@@ -414,12 +408,11 @@ find_address_it (void *cls, const GNUNET_HashCode * key, void *value)
void
GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
- size_t plugin_addr_len, uint32_t session_id,
- int in_use)
+ size_t plugin_addr_len, uint32_t session_id, int in_use)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s': %i\n",
- "ADDRESS_IN_USE",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message for peer `%s': %i\n", "ADDRESS_IN_USE",
GNUNET_i2s (peer), in_use);
}
@@ -476,12 +469,12 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "WAN_QUOTA_IN",
- &wan_quota_in));
+ "WAN_QUOTA_IN",
+ &wan_quota_in));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "WAN_QUOTA_OUT",
- &wan_quota_out));
+ "WAN_QUOTA_OUT",
+ &wan_quota_out));
addresses = GNUNET_CONTAINER_multihashmap_create (128);
}
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index 95f267bf9..75c220017 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -52,8 +52,7 @@ GAS_addresses_done (void);
void
GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
- size_t plugin_addr_len, uint32_t session_id,
- int in_use);
+ size_t plugin_addr_len, uint32_t session_id, int in_use);
void
GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 4659a2363..f5e286a64 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -142,8 +142,10 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity
memcpy (addrp, plugin_addr, plugin_addr_len);
strcpy (&addrp[plugin_addr_len], plugin_name);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS sends quota for peer `%s': (in/out) %u/%u\n",
- GNUNET_i2s (peer), ntohl (bandwidth_in.value__), ntohl(bandwidth_out.value__));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "ATS sends quota for peer `%s': (in/out) %u/%u\n",
+ GNUNET_i2s (peer), ntohl (bandwidth_in.value__),
+ ntohl (bandwidth_out.value__));
GNUNET_SERVER_notification_context_unicast (nc, my_client, &msg->header,
GNUNET_YES);
@@ -182,8 +184,9 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
* @param message the request message
*/
void
-GAS_handle_request_address_cancel (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+GAS_handle_request_address_cancel (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
const struct RequestAddressMessage *msg =
(const struct RequestAddressMessage *) message;
@@ -304,12 +307,8 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
}
in_use = ntohs (m->in_use);
- GAS_addresses_in_use (&m->peer,
- plugin_name,
- address,
- address_length,
- ntohl (m->session_id),
- in_use);
+ GAS_addresses_in_use (&m->peer, plugin_name, address, address_length,
+ ntohl (m->session_id), in_use);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -359,8 +358,8 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- if ( (plugin_name_length == 0) ||
- (plugin_name[plugin_name_length - 1] != '\0'))
+ if ((plugin_name_length == 0) ||
+ (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h
index cb4e5e08e..45fca2f3d 100644
--- a/src/ats/gnunet-service-ats_scheduling.h
+++ b/src/ats/gnunet-service-ats_scheduling.h
@@ -98,8 +98,9 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
* @param message the request message
*/
void
-GAS_handle_request_address_cancel (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+GAS_handle_request_address_cancel (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message);
/**
* Handle 'address update' messages from clients.
diff --git a/src/ats/test_ats_api_scheduling.c b/src/ats/test_ats_api_scheduling.c
index bf11aef8d..fdff3e36d 100644
--- a/src/ats/test_ats_api_scheduling.c
+++ b/src/ats/test_ats_api_scheduling.c
@@ -118,8 +118,7 @@ end ()
static void
-address_suggest_cb (void *cls,
- const struct GNUNET_HELLO_Address *address,
+address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -130,10 +129,13 @@ address_suggest_cb (void *cls,
GNUNET_i2s (&address->peer));
GNUNET_assert (0 ==
- memcmp (&address->peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity)));
+ memcmp (&address->peer, &p[0].id,
+ sizeof (struct GNUNET_PeerIdentity)));
GNUNET_assert (0 == strcmp (address->transport_name, addr[0].plugin));
GNUNET_assert (address->address_length == addr[0].addr_len);
- GNUNET_assert (0 == memcmp (address->address, addr[0].plugin, address->address_length));
+ GNUNET_assert (0 ==
+ memcmp (address->address, addr[0].plugin,
+ address->address_length));
GNUNET_assert (addr[0].session == session);
@@ -224,7 +226,7 @@ check (void *cls, char *const *args, const char *cfgfile,
GNUNET_ATS_address_update (ats, &address0, addr[0].session, atsi, 2);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n");
- address0.peer = p[1].id; // FIXME: why? typo in old code?
+ address0.peer = p[1].id; // FIXME: why? typo in old code?
GNUNET_ATS_address_update (ats, &address0, addr[0].session, NULL, 0);
GNUNET_ATS_address_destroyed (ats, &address0, addr[0].session);