summaryrefslogtreecommitdiff
path: root/src/transport/transport_api2_application.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/transport/transport_api2_application.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
uncrustify as demanded.
Diffstat (limited to 'src/transport/transport_api2_application.c')
-rw-r--r--src/transport/transport_api2_application.c189
1 files changed, 93 insertions, 96 deletions
diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c
index 7d790d738..8ddf48a86 100644
--- a/src/transport/transport_api2_application.c
+++ b/src/transport/transport_api2_application.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file transport/transport_api2_application.c
* @brief enable clients to ask TRANSPORT about establishing connections to peers
@@ -30,14 +30,13 @@
#define LOG(kind, ...) \
- GNUNET_log_from (kind, "transport-application-api", __VA_ARGS__)
+ GNUNET_log_from(kind, "transport-application-api", __VA_ARGS__)
/**
* Handle for TRANSPORT address suggestion requests.
*/
-struct GNUNET_TRANSPORT_ApplicationSuggestHandle
-{
+struct GNUNET_TRANSPORT_ApplicationSuggestHandle {
/**
* ID of the peer for which address suggestion was requested.
*/
@@ -63,9 +62,7 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle
/**
* Handle to the TRANSPORT subsystem for application management.
*/
-struct GNUNET_TRANSPORT_ApplicationHandle
-{
-
+struct GNUNET_TRANSPORT_ApplicationHandle {
/**
* Our configuration.
*/
@@ -101,7 +98,7 @@ struct GNUNET_TRANSPORT_ApplicationHandle
* @param ch handle to use to re-connect.
*/
static void
-reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch);
+reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch);
/**
@@ -110,12 +107,12 @@ reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch);
* @param cls handle to use to re-connect.
*/
static void
-reconnect_task (void *cls)
+reconnect_task(void *cls)
{
struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls;
ch->task = NULL;
- reconnect (ch);
+ reconnect(ch);
}
@@ -125,15 +122,15 @@ reconnect_task (void *cls)
* @param ch our handle
*/
static void
-force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
+force_reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
{
if (NULL != ch->mq)
- {
- GNUNET_MQ_destroy (ch->mq);
- ch->mq = NULL;
- }
- ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff);
- ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, &reconnect_task, ch);
+ {
+ GNUNET_MQ_destroy(ch->mq);
+ ch->mq = NULL;
+ }
+ ch->backoff = GNUNET_TIME_STD_BACKOFF(ch->backoff);
+ ch->task = GNUNET_SCHEDULER_add_delayed(ch->backoff, &reconnect_task, ch);
}
@@ -145,14 +142,14 @@ force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
* @param error details about the error
*/
static void
-error_handler (void *cls, enum GNUNET_MQ_Error error)
+error_handler(void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "TRANSPORT connection died (code %d), reconnecting\n",
- (int) error);
- force_reconnect (ch);
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "TRANSPORT connection died (code %d), reconnecting\n",
+ (int)error);
+ force_reconnect(ch);
}
@@ -166,9 +163,9 @@ error_handler (void *cls, enum GNUNET_MQ_Error error)
* failure (message queue no longer exists)
*/
static int
-transmit_suggestion (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- void *value)
+transmit_suggestion(void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ void *value)
{
struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls;
struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh = value;
@@ -177,11 +174,11 @@ transmit_suggestion (void *cls,
if (NULL == ch->mq)
return GNUNET_SYSERR;
- ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST);
- m->pk = htonl ((uint32_t) sh->pk);
+ ev = GNUNET_MQ_msg(m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST);
+ m->pk = htonl((uint32_t)sh->pk);
m->bw = sh->bw;
m->peer = *peer;
- GNUNET_MQ_send (ch->mq, ev);
+ GNUNET_MQ_send(ch->mq, ev);
return GNUNET_OK;
}
@@ -192,21 +189,21 @@ transmit_suggestion (void *cls,
* @param ch handle to use to re-connect.
*/
static void
-reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
+reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
{
- static const struct GNUNET_MQ_MessageHandler handlers[] = {{NULL, 0, 0}};
+ static const struct GNUNET_MQ_MessageHandler handlers[] = { { NULL, 0, 0 } };
- GNUNET_assert (NULL == ch->mq);
+ GNUNET_assert(NULL == ch->mq);
ch->mq =
- GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch);
+ GNUNET_CLIENT_connect(ch->cfg, "transport", handlers, &error_handler, ch);
if (NULL == ch->mq)
- {
- force_reconnect (ch);
- return;
- }
- GNUNET_CONTAINER_multipeermap_iterate (ch->sug_requests,
- &transmit_suggestion,
- ch);
+ {
+ force_reconnect(ch);
+ return;
+ }
+ GNUNET_CONTAINER_multipeermap_iterate(ch->sug_requests,
+ &transmit_suggestion,
+ ch);
}
@@ -217,15 +214,15 @@ reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
* @return transport application handle, NULL on error
*/
struct GNUNET_TRANSPORT_ApplicationHandle *
-GNUNET_TRANSPORT_application_init (
+GNUNET_TRANSPORT_application_init(
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_TRANSPORT_ApplicationHandle *ch;
- ch = GNUNET_new (struct GNUNET_TRANSPORT_ApplicationHandle);
+ ch = GNUNET_new(struct GNUNET_TRANSPORT_ApplicationHandle);
ch->cfg = cfg;
- ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
- reconnect (ch);
+ ch->sug_requests = GNUNET_CONTAINER_multipeermap_create(32, GNUNET_YES);
+ reconnect(ch);
return ch;
}
@@ -240,11 +237,11 @@ GNUNET_TRANSPORT_application_init (
* @return #GNUNET_OK (continue to iterate)
*/
static int
-free_sug_handle (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
{
struct GNUNET_TRANSPORT_ApplicationSuggestHandle *cur = value;
- GNUNET_free (cur);
+ GNUNET_free(cur);
return GNUNET_OK;
}
@@ -255,24 +252,24 @@ free_sug_handle (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
* @param ch handle to release
*/
void
-GNUNET_TRANSPORT_application_done (
+GNUNET_TRANSPORT_application_done(
struct GNUNET_TRANSPORT_ApplicationHandle *ch)
{
if (NULL != ch->mq)
- {
- GNUNET_MQ_destroy (ch->mq);
- ch->mq = NULL;
- }
+ {
+ GNUNET_MQ_destroy(ch->mq);
+ ch->mq = NULL;
+ }
if (NULL != ch->task)
- {
- GNUNET_SCHEDULER_cancel (ch->task);
- ch->task = NULL;
- }
- GNUNET_CONTAINER_multipeermap_iterate (ch->sug_requests,
- &free_sug_handle,
- NULL);
- GNUNET_CONTAINER_multipeermap_destroy (ch->sug_requests);
- GNUNET_free (ch);
+ {
+ GNUNET_SCHEDULER_cancel(ch->task);
+ ch->task = NULL;
+ }
+ GNUNET_CONTAINER_multipeermap_iterate(ch->sug_requests,
+ &free_sug_handle,
+ NULL);
+ GNUNET_CONTAINER_multipeermap_destroy(ch->sug_requests);
+ GNUNET_free(ch);
}
@@ -287,7 +284,7 @@ GNUNET_TRANSPORT_application_done (
* @return suggest handle, NULL if a request is already pending
*/
struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
-GNUNET_TRANSPORT_application_suggest (
+GNUNET_TRANSPORT_application_suggest(
struct GNUNET_TRANSPORT_ApplicationHandle *ch,
const struct GNUNET_PeerIdentity *peer,
enum GNUNET_MQ_PriorityPreferences pk,
@@ -295,22 +292,22 @@ GNUNET_TRANSPORT_application_suggest (
{
struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s;
- s = GNUNET_new (struct GNUNET_TRANSPORT_ApplicationSuggestHandle);
+ s = GNUNET_new(struct GNUNET_TRANSPORT_ApplicationSuggestHandle);
s->ch = ch;
s->id = *peer;
s->pk = pk;
s->bw = bw;
- (void) GNUNET_CONTAINER_multipeermap_put (
+ (void)GNUNET_CONTAINER_multipeermap_put(
ch->sug_requests,
&s->id,
s,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting TRANSPORT to suggest address for `%s'\n",
- GNUNET_i2s (peer));
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting TRANSPORT to suggest address for `%s'\n",
+ GNUNET_i2s(peer));
if (NULL == ch->mq)
return s;
- GNUNET_assert (GNUNET_OK == transmit_suggestion (ch, &s->id, s));
+ GNUNET_assert(GNUNET_OK == transmit_suggestion(ch, &s->id, s));
return s;
}
@@ -321,30 +318,30 @@ GNUNET_TRANSPORT_application_suggest (
* @param sh handle to stop
*/
void
-GNUNET_TRANSPORT_application_suggest_cancel (
+GNUNET_TRANSPORT_application_suggest_cancel(
struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh)
{
struct GNUNET_TRANSPORT_ApplicationHandle *ch = sh->ch;
struct GNUNET_MQ_Envelope *ev;
struct ExpressPreferenceMessage *m;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Telling TRANSPORT we no longer care for an address for `%s'\n",
- GNUNET_i2s (&sh->id));
- GNUNET_assert (
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Telling TRANSPORT we no longer care for an address for `%s'\n",
+ GNUNET_i2s(&sh->id));
+ GNUNET_assert(
GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, &sh->id, sh));
+ GNUNET_CONTAINER_multipeermap_remove(ch->sug_requests, &sh->id, sh));
if (NULL == ch->mq)
- {
- GNUNET_free (sh);
- return;
- }
- ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL);
- m->pk = htonl ((uint32_t) sh->pk);
+ {
+ GNUNET_free(sh);
+ return;
+ }
+ ev = GNUNET_MQ_msg(m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL);
+ m->pk = htonl((uint32_t)sh->pk);
m->bw = sh->bw;
m->peer = sh->id;
- GNUNET_MQ_send (ch->mq, ev);
- GNUNET_free (sh);
+ GNUNET_MQ_send(ch->mq, ev);
+ GNUNET_free(sh);
}
@@ -364,7 +361,7 @@ GNUNET_TRANSPORT_application_suggest_cancel (
* @param addr address to validate
*/
void
-GNUNET_TRANSPORT_application_validate (
+GNUNET_TRANSPORT_application_validate(
struct GNUNET_TRANSPORT_ApplicationHandle *ch,
const struct GNUNET_PeerIdentity *peer,
enum GNUNET_NetworkType nt,
@@ -375,23 +372,23 @@ GNUNET_TRANSPORT_application_validate (
size_t alen;
if (NULL == ch->mq)
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- "Address validation for %s:%s skipped as transport is not connected\n",
- GNUNET_i2s (peer),
- addr);
- return;
- }
- alen = strlen (addr) + 1;
+ {
+ GNUNET_log(
+ GNUNET_ERROR_TYPE_WARNING,
+ "Address validation for %s:%s skipped as transport is not connected\n",
+ GNUNET_i2s(peer),
+ addr);
+ return;
+ }
+ alen = strlen(addr) + 1;
ev =
- GNUNET_MQ_msg_extra (m,
- alen,
- GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION);
+ GNUNET_MQ_msg_extra(m,
+ alen,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION);
m->peer = *peer;
- m->nt = htonl ((uint32_t) nt);
- memcpy (&m[1], addr, alen);
- GNUNET_MQ_send (ch->mq, ev);
+ m->nt = htonl((uint32_t)nt);
+ memcpy(&m[1], addr, alen);
+ GNUNET_MQ_send(ch->mq, ev);
}