aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api_blacklist.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_api_blacklist.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/transport_api_blacklist.c')
-rw-r--r--src/transport/transport_api_blacklist.c85
1 files changed, 43 insertions, 42 deletions
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c
index f04def49d..45d9bcf29 100644
--- a/src/transport/transport_api_blacklist.c
+++ b/src/transport/transport_api_blacklist.c
@@ -34,7 +34,8 @@
34/** 34/**
35 * Handle for blacklisting requests. 35 * Handle for blacklisting requests.
36 */ 36 */
37struct GNUNET_TRANSPORT_Blacklist { 37struct GNUNET_TRANSPORT_Blacklist
38{
38 /** 39 /**
39 * Connection to transport service. 40 * Connection to transport service.
40 */ 41 */
@@ -64,7 +65,7 @@ struct GNUNET_TRANSPORT_Blacklist {
64 * @param br overall handle 65 * @param br overall handle
65 */ 66 */
66static void 67static void
67reconnect(struct GNUNET_TRANSPORT_Blacklist *br); 68reconnect (struct GNUNET_TRANSPORT_Blacklist *br);
68 69
69 70
70/** 71/**
@@ -74,21 +75,21 @@ reconnect(struct GNUNET_TRANSPORT_Blacklist *br);
74 * @param bm query 75 * @param bm query
75 */ 76 */
76static void 77static void
77handle_query(void *cls, 78handle_query (void *cls,
78 const struct BlacklistMessage *bm) 79 const struct BlacklistMessage *bm)
79{ 80{
80 struct GNUNET_TRANSPORT_Blacklist *br = cls; 81 struct GNUNET_TRANSPORT_Blacklist *br = cls;
81 struct GNUNET_MQ_Envelope *env; 82 struct GNUNET_MQ_Envelope *env;
82 struct BlacklistMessage *res; 83 struct BlacklistMessage *res;
83 84
84 GNUNET_break(0 == ntohl(bm->is_allowed)); 85 GNUNET_break (0 == ntohl (bm->is_allowed));
85 env = GNUNET_MQ_msg(res, 86 env = GNUNET_MQ_msg (res,
86 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY); 87 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY);
87 res->is_allowed = htonl(br->cb(br->cb_cls, 88 res->is_allowed = htonl (br->cb (br->cb_cls,
88 &bm->peer)); 89 &bm->peer));
89 res->peer = bm->peer; 90 res->peer = bm->peer;
90 GNUNET_MQ_send(br->mq, 91 GNUNET_MQ_send (br->mq,
91 env); 92 env);
92} 93}
93 94
94/** 95/**
@@ -100,12 +101,12 @@ handle_query(void *cls,
100 * @param error error code 101 * @param error error code
101 */ 102 */
102static void 103static void
103mq_error_handler(void *cls, 104mq_error_handler (void *cls,
104 enum GNUNET_MQ_Error error) 105 enum GNUNET_MQ_Error error)
105{ 106{
106 struct GNUNET_TRANSPORT_Blacklist *br = cls; 107 struct GNUNET_TRANSPORT_Blacklist *br = cls;
107 108
108 reconnect(br); 109 reconnect (br);
109} 110}
110 111
111 112
@@ -115,31 +116,31 @@ mq_error_handler(void *cls,
115 * @param br overall handle 116 * @param br overall handle
116 */ 117 */
117static void 118static void
118reconnect(struct GNUNET_TRANSPORT_Blacklist *br) 119reconnect (struct GNUNET_TRANSPORT_Blacklist *br)
119{ 120{
120 struct GNUNET_MQ_MessageHandler handlers[] = { 121 struct GNUNET_MQ_MessageHandler handlers[] = {
121 GNUNET_MQ_hd_fixed_size(query, 122 GNUNET_MQ_hd_fixed_size (query,
122 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY, 123 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY,
123 struct BlacklistMessage, 124 struct BlacklistMessage,
124 br), 125 br),
125 GNUNET_MQ_handler_end() 126 GNUNET_MQ_handler_end ()
126 }; 127 };
127 struct GNUNET_MQ_Envelope *env; 128 struct GNUNET_MQ_Envelope *env;
128 struct GNUNET_MessageHeader *req; 129 struct GNUNET_MessageHeader *req;
129 130
130 if (NULL != br->mq) 131 if (NULL != br->mq)
131 GNUNET_MQ_destroy(br->mq); 132 GNUNET_MQ_destroy (br->mq);
132 br->mq = GNUNET_CLIENT_connect(br->cfg, 133 br->mq = GNUNET_CLIENT_connect (br->cfg,
133 "transport", 134 "transport",
134 handlers, 135 handlers,
135 &mq_error_handler, 136 &mq_error_handler,
136 br); 137 br);
137 if (NULL == br->mq) 138 if (NULL == br->mq)
138 return; 139 return;
139 env = GNUNET_MQ_msg(req, 140 env = GNUNET_MQ_msg (req,
140 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT); 141 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT);
141 GNUNET_MQ_send(br->mq, 142 GNUNET_MQ_send (br->mq,
142 env); 143 env);
143} 144}
144 145
145 146
@@ -158,22 +159,22 @@ reconnect(struct GNUNET_TRANSPORT_Blacklist *br)
158 * @return NULL on error, otherwise handle for cancellation 159 * @return NULL on error, otherwise handle for cancellation
159 */ 160 */
160struct GNUNET_TRANSPORT_Blacklist * 161struct GNUNET_TRANSPORT_Blacklist *
161GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, 162GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
162 GNUNET_TRANSPORT_BlacklistCallback cb, 163 GNUNET_TRANSPORT_BlacklistCallback cb,
163 void *cb_cls) 164 void *cb_cls)
164{ 165{
165 struct GNUNET_TRANSPORT_Blacklist *br; 166 struct GNUNET_TRANSPORT_Blacklist *br;
166 167
167 br = GNUNET_new(struct GNUNET_TRANSPORT_Blacklist); 168 br = GNUNET_new (struct GNUNET_TRANSPORT_Blacklist);
168 br->cfg = cfg; 169 br->cfg = cfg;
169 br->cb = cb; 170 br->cb = cb;
170 br->cb_cls = cb_cls; 171 br->cb_cls = cb_cls;
171 reconnect(br); 172 reconnect (br);
172 if (NULL == br->mq) 173 if (NULL == br->mq)
173 { 174 {
174 GNUNET_free(br); 175 GNUNET_free (br);
175 return NULL; 176 return NULL;
176 } 177 }
177 return br; 178 return br;
178} 179}
179 180
@@ -185,10 +186,10 @@ GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg,
185 * @param br handle of the request that is to be cancelled 186 * @param br handle of the request that is to be cancelled
186 */ 187 */
187void 188void
188GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br) 189GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br)
189{ 190{
190 GNUNET_MQ_destroy(br->mq); 191 GNUNET_MQ_destroy (br->mq);
191 GNUNET_free(br); 192 GNUNET_free (br);
192} 193}
193 194
194 195