summaryrefslogtreecommitdiff
path: root/src/transport/transport_api2_monitor.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_monitor.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/transport_api2_monitor.c')
-rw-r--r--src/transport/transport_api2_monitor.c127
1 files changed, 64 insertions, 63 deletions
diff --git a/src/transport/transport_api2_monitor.c b/src/transport/transport_api2_monitor.c
index 74624326c..f358051b6 100644
--- a/src/transport/transport_api2_monitor.c
+++ b/src/transport/transport_api2_monitor.c
@@ -33,7 +33,8 @@
/**
* Opaque handle to the transport service for monitors.
*/
-struct GNUNET_TRANSPORT_MonitorContext {
+struct GNUNET_TRANSPORT_MonitorContext
+{
/**
* Our configuration.
*/
@@ -72,7 +73,7 @@ struct GNUNET_TRANSPORT_MonitorContext {
* @param mc handle to reconnect
*/
static void
-reconnect(struct GNUNET_TRANSPORT_MonitorContext *mc);
+reconnect (struct GNUNET_TRANSPORT_MonitorContext *mc);
/**
@@ -82,17 +83,17 @@ reconnect(struct GNUNET_TRANSPORT_MonitorContext *mc);
* @param ai address to delete
*/
static void
-send_start_monitor(struct GNUNET_TRANSPORT_MonitorContext *mc)
+send_start_monitor (struct GNUNET_TRANSPORT_MonitorContext *mc)
{
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_MonitorStart *smm;
if (NULL == mc->mq)
return;
- env = GNUNET_MQ_msg(smm, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START);
- smm->one_shot = htonl((uint32_t)mc->one_shot);
+ env = GNUNET_MQ_msg (smm, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START);
+ smm->one_shot = htonl ((uint32_t) mc->one_shot);
smm->peer = mc->peer;
- GNUNET_MQ_send(mc->mq, env);
+ GNUNET_MQ_send (mc->mq, env);
}
@@ -102,11 +103,11 @@ send_start_monitor(struct GNUNET_TRANSPORT_MonitorContext *mc)
* @param mc service to disconnect from
*/
static void
-disconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
+disconnect (struct GNUNET_TRANSPORT_MonitorContext *mc)
{
if (NULL == mc->mq)
return;
- GNUNET_MQ_destroy(mc->mq);
+ GNUNET_MQ_destroy (mc->mq);
mc->mq = NULL;
}
@@ -118,16 +119,16 @@ disconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
* @param error what error happened?
*/
static void
-error_handler(void *cls, enum GNUNET_MQ_Error error)
+error_handler (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_TRANSPORT_MonitorContext *mc = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "MQ failure %d, reconnecting to transport service.\n",
- error);
- disconnect(mc);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "MQ failure %d, reconnecting to transport service.\n",
+ error);
+ disconnect (mc);
/* TODO: maybe do this with exponential backoff/delay */
- reconnect(mc);
+ reconnect (mc);
}
@@ -140,10 +141,10 @@ error_handler(void *cls, enum GNUNET_MQ_Error error)
* @return #GNUNET_OK if @a smt is well-formed
*/
static int
-check_monitor_data(void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
+check_monitor_data (void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
{
- (void)cls;
- GNUNET_MQ_check_zero_termination(md);
+ (void) cls;
+ GNUNET_MQ_check_zero_termination (md);
return GNUNET_OK;
}
@@ -155,21 +156,21 @@ check_monitor_data(void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
* @param md monitor data
*/
static void
-handle_monitor_data(void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
+handle_monitor_data (void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
{
struct GNUNET_TRANSPORT_MonitorContext *mc = cls;
struct GNUNET_TRANSPORT_MonitorInformation mi;
- mi.address = (const char *)&md[1];
- mi.nt = (enum GNUNET_NetworkType)ntohl(md->nt);
- mi.cs = (enum GNUNET_TRANSPORT_ConnectionStatus)ntohl(md->cs);
- mi.num_msg_pending = ntohl(md->num_msg_pending);
- mi.num_bytes_pending = ntohl(md->num_bytes_pending);
- mi.last_validation = GNUNET_TIME_absolute_ntoh(md->last_validation);
- mi.valid_until = GNUNET_TIME_absolute_ntoh(md->valid_until);
- mi.next_validation = GNUNET_TIME_absolute_ntoh(md->next_validation);
- mi.rtt = GNUNET_TIME_relative_ntoh(md->rtt);
- mc->cb(mc->cb_cls, &md->peer, &mi);
+ mi.address = (const char *) &md[1];
+ mi.nt = (enum GNUNET_NetworkType) ntohl (md->nt);
+ mi.cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (md->cs);
+ mi.num_msg_pending = ntohl (md->num_msg_pending);
+ mi.num_bytes_pending = ntohl (md->num_bytes_pending);
+ mi.last_validation = GNUNET_TIME_absolute_ntoh (md->last_validation);
+ mi.valid_until = GNUNET_TIME_absolute_ntoh (md->valid_until);
+ mi.next_validation = GNUNET_TIME_absolute_ntoh (md->next_validation);
+ mi.rtt = GNUNET_TIME_relative_ntoh (md->rtt);
+ mc->cb (mc->cb_cls, &md->peer, &mi);
}
@@ -180,19 +181,19 @@ handle_monitor_data(void *cls, const struct GNUNET_TRANSPORT_MonitorData *md)
* @param me end message
*/
static void
-handle_monitor_end(void *cls, const struct GNUNET_MessageHeader *me)
+handle_monitor_end (void *cls, const struct GNUNET_MessageHeader *me)
{
struct GNUNET_TRANSPORT_MonitorContext *mc = cls;
if (GNUNET_YES != mc->one_shot)
- {
- GNUNET_break(0);
- disconnect(mc);
- reconnect(mc);
- return;
- }
- mc->cb(mc->cb_cls, NULL, NULL);
- GNUNET_TRANSPORT_monitor_cancel(mc);
+ {
+ GNUNET_break (0);
+ disconnect (mc);
+ reconnect (mc);
+ return;
+ }
+ mc->cb (mc->cb_cls, NULL, NULL);
+ GNUNET_TRANSPORT_monitor_cancel (mc);
}
@@ -202,24 +203,24 @@ handle_monitor_end(void *cls, const struct GNUNET_MessageHeader *me)
* @param mc handle to reconnect
*/
static void
-reconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
+reconnect (struct GNUNET_TRANSPORT_MonitorContext *mc)
{
struct GNUNET_MQ_MessageHandler handlers[] =
- { GNUNET_MQ_hd_var_size(monitor_data,
- GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA,
- struct GNUNET_TRANSPORT_MonitorData,
- mc),
- GNUNET_MQ_hd_fixed_size(monitor_end,
- GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_END,
- struct GNUNET_MessageHeader,
- mc),
- GNUNET_MQ_handler_end() };
+ { GNUNET_MQ_hd_var_size (monitor_data,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA,
+ struct GNUNET_TRANSPORT_MonitorData,
+ mc),
+ GNUNET_MQ_hd_fixed_size (monitor_end,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_END,
+ struct GNUNET_MessageHeader,
+ mc),
+ GNUNET_MQ_handler_end () };
mc->mq =
- GNUNET_CLIENT_connect(mc->cfg, "transport", handlers, &error_handler, mc);
+ GNUNET_CLIENT_connect (mc->cfg, "transport", handlers, &error_handler, mc);
if (NULL == mc->mq)
return;
- send_start_monitor(mc);
+ send_start_monitor (mc);
}
@@ -250,27 +251,27 @@ reconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
* @param cb_cls closure for @a mc
*/
struct GNUNET_TRANSPORT_MonitorContext *
-GNUNET_TRANSPORT_monitor(const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_PeerIdentity *peer,
- int one_shot,
- GNUNET_TRANSPORT_MonitorCallback cb,
- void *cb_cls)
+GNUNET_TRANSPORT_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_PeerIdentity *peer,
+ int one_shot,
+ GNUNET_TRANSPORT_MonitorCallback cb,
+ void *cb_cls)
{
struct GNUNET_TRANSPORT_MonitorContext *mc;
- mc = GNUNET_new(struct GNUNET_TRANSPORT_MonitorContext);
+ mc = GNUNET_new (struct GNUNET_TRANSPORT_MonitorContext);
mc->cfg = cfg;
if (NULL != peer)
mc->peer = *peer;
mc->one_shot = one_shot;
mc->cb = cb;
mc->cb_cls = cb_cls;
- reconnect(mc);
+ reconnect (mc);
if (NULL == mc->mq)
- {
- GNUNET_free(mc);
- return NULL;
- }
+ {
+ GNUNET_free (mc);
+ return NULL;
+ }
return mc;
}
@@ -281,10 +282,10 @@ GNUNET_TRANSPORT_monitor(const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param pmc handle for the request to cancel
*/
void
-GNUNET_TRANSPORT_monitor_cancel(struct GNUNET_TRANSPORT_MonitorContext *mc)
+GNUNET_TRANSPORT_monitor_cancel (struct GNUNET_TRANSPORT_MonitorContext *mc)
{
- disconnect(mc);
- GNUNET_free(mc);
+ disconnect (mc);
+ GNUNET_free (mc);
}
/* end of transport_api2_monitor.c */