summaryrefslogtreecommitdiff
path: root/src/transport/transport_api2_application.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/transport/transport_api2_application.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/transport_api2_application.c')
-rw-r--r--src/transport/transport_api2_application.c184
1 files changed, 93 insertions, 91 deletions
diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c
index 8ddf48a86..4862863dd 100644
--- a/src/transport/transport_api2_application.c
+++ b/src/transport/transport_api2_application.c
@@ -30,13 +30,14 @@
#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.
*/
@@ -62,7 +63,8 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle {
/**
* Handle to the TRANSPORT subsystem for application management.
*/
-struct GNUNET_TRANSPORT_ApplicationHandle {
+struct GNUNET_TRANSPORT_ApplicationHandle
+{
/**
* Our configuration.
*/
@@ -98,7 +100,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);
/**
@@ -107,12 +109,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);
}
@@ -122,15 +124,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);
}
@@ -142,14 +144,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);
}
@@ -163,9 +165,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;
@@ -174,11 +176,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;
}
@@ -189,21 +191,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 } };
- 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);
}
@@ -214,15 +216,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;
}
@@ -237,11 +239,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;
}
@@ -252,24 +254,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);
}
@@ -284,7 +286,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,
@@ -292,22 +294,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;
}
@@ -318,30 +320,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);
}
@@ -361,7 +363,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,
@@ -372,23 +374,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);
}