diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/namestore/namestore_api_monitor.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/namestore/namestore_api_monitor.c')
-rw-r--r-- | src/namestore/namestore_api_monitor.c | 189 |
1 files changed, 94 insertions, 95 deletions
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c index 2881a28ac..d87a76eed 100644 --- a/src/namestore/namestore_api_monitor.c +++ b/src/namestore/namestore_api_monitor.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/namestore_api_monitor.c | 21 | * @file namestore/namestore_api_monitor.c |
22 | * @brief API to monitor changes in the NAMESTORE | 22 | * @brief API to monitor changes in the NAMESTORE |
@@ -37,8 +37,7 @@ | |||
37 | /** | 37 | /** |
38 | * Handle for a monitoring activity. | 38 | * Handle for a monitoring activity. |
39 | */ | 39 | */ |
40 | struct GNUNET_NAMESTORE_ZoneMonitor | 40 | struct GNUNET_NAMESTORE_ZoneMonitor { |
41 | { | ||
42 | /** | 41 | /** |
43 | * Configuration (to reconnect). | 42 | * Configuration (to reconnect). |
44 | */ | 43 | */ |
@@ -97,7 +96,7 @@ struct GNUNET_NAMESTORE_ZoneMonitor | |||
97 | * @param zm monitor to reconnect | 96 | * @param zm monitor to reconnect |
98 | */ | 97 | */ |
99 | static void | 98 | static void |
100 | reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | 99 | reconnect(struct GNUNET_NAMESTORE_ZoneMonitor *zm); |
101 | 100 | ||
102 | 101 | ||
103 | /** | 102 | /** |
@@ -107,14 +106,14 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | |||
107 | * @param msg the sync message | 106 | * @param msg the sync message |
108 | */ | 107 | */ |
109 | static void | 108 | static void |
110 | handle_sync (void *cls, const struct GNUNET_MessageHeader *msg) | 109 | handle_sync(void *cls, const struct GNUNET_MessageHeader *msg) |
111 | { | 110 | { |
112 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 111 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
113 | 112 | ||
114 | (void) cls; | 113 | (void)cls; |
115 | (void) msg; | 114 | (void)msg; |
116 | if (NULL != zm->sync_cb) | 115 | if (NULL != zm->sync_cb) |
117 | zm->sync_cb (zm->sync_cb_cls); | 116 | zm->sync_cb(zm->sync_cb_cls); |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
@@ -126,7 +125,7 @@ handle_sync (void *cls, const struct GNUNET_MessageHeader *msg) | |||
126 | * @param lrm the message from the service. | 125 | * @param lrm the message from the service. |
127 | */ | 126 | */ |
128 | static int | 127 | static int |
129 | check_result (void *cls, const struct RecordResultMessage *lrm) | 128 | check_result(void *cls, const struct RecordResultMessage *lrm) |
130 | { | 129 | { |
131 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 130 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
132 | size_t lrm_len; | 131 | size_t lrm_len; |
@@ -137,49 +136,49 @@ check_result (void *cls, const struct RecordResultMessage *lrm) | |||
137 | const char *name_tmp; | 136 | const char *name_tmp; |
138 | const char *rd_ser_tmp; | 137 | const char *rd_ser_tmp; |
139 | 138 | ||
140 | (void) cls; | 139 | (void)cls; |
141 | if ((0 != GNUNET_memcmp (&lrm->private_key, &zm->zone)) && | 140 | if ((0 != GNUNET_memcmp(&lrm->private_key, &zm->zone)) && |
142 | (0 != GNUNET_is_zero (&zm->zone))) | 141 | (0 != GNUNET_is_zero(&zm->zone))) |
143 | { | 142 | { |
144 | GNUNET_break (0); | 143 | GNUNET_break(0); |
145 | return GNUNET_SYSERR; | 144 | return GNUNET_SYSERR; |
146 | } | 145 | } |
147 | lrm_len = ntohs (lrm->gns_header.header.size); | 146 | lrm_len = ntohs(lrm->gns_header.header.size); |
148 | rd_len = ntohs (lrm->rd_len); | 147 | rd_len = ntohs(lrm->rd_len); |
149 | rd_count = ntohs (lrm->rd_count); | 148 | rd_count = ntohs(lrm->rd_count); |
150 | name_len = ntohs (lrm->name_len); | 149 | name_len = ntohs(lrm->name_len); |
151 | if (name_len > MAX_NAME_LEN) | 150 | if (name_len > MAX_NAME_LEN) |
152 | { | 151 | { |
153 | GNUNET_break (0); | 152 | GNUNET_break(0); |
154 | return GNUNET_SYSERR; | 153 | return GNUNET_SYSERR; |
155 | } | 154 | } |
156 | exp_lrm_len = sizeof (struct RecordResultMessage) + name_len + rd_len; | 155 | exp_lrm_len = sizeof(struct RecordResultMessage) + name_len + rd_len; |
157 | if (lrm_len != exp_lrm_len) | 156 | if (lrm_len != exp_lrm_len) |
158 | { | 157 | { |
159 | GNUNET_break (0); | 158 | GNUNET_break(0); |
160 | return GNUNET_SYSERR; | 159 | return GNUNET_SYSERR; |
161 | } | 160 | } |
162 | if (0 == name_len) | 161 | if (0 == name_len) |
163 | { | 162 | { |
164 | GNUNET_break (0); | 163 | GNUNET_break(0); |
165 | return GNUNET_SYSERR; | 164 | return GNUNET_SYSERR; |
166 | } | 165 | } |
167 | name_tmp = (const char *) &lrm[1]; | 166 | name_tmp = (const char *)&lrm[1]; |
168 | if (name_tmp[name_len - 1] != '\0') | 167 | if (name_tmp[name_len - 1] != '\0') |
169 | { | 168 | { |
170 | GNUNET_break (0); | 169 | GNUNET_break(0); |
171 | return GNUNET_SYSERR; | 170 | return GNUNET_SYSERR; |
172 | } | 171 | } |
173 | rd_ser_tmp = (const char *) &name_tmp[name_len]; | 172 | rd_ser_tmp = (const char *)&name_tmp[name_len]; |
174 | { | 173 | { |
175 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 174 | struct GNUNET_GNSRECORD_Data rd[rd_count]; |
176 | 175 | ||
177 | if (GNUNET_OK != | 176 | if (GNUNET_OK != |
178 | GNUNET_GNSRECORD_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd)) | 177 | GNUNET_GNSRECORD_records_deserialize(rd_len, rd_ser_tmp, rd_count, rd)) |
179 | { | 178 | { |
180 | GNUNET_break (0); | 179 | GNUNET_break(0); |
181 | return GNUNET_SYSERR; | 180 | return GNUNET_SYSERR; |
182 | } | 181 | } |
183 | } | 182 | } |
184 | return GNUNET_OK; | 183 | return GNUNET_OK; |
185 | } | 184 | } |
@@ -193,7 +192,7 @@ check_result (void *cls, const struct RecordResultMessage *lrm) | |||
193 | * @param lrm the message from the service. | 192 | * @param lrm the message from the service. |
194 | */ | 193 | */ |
195 | static void | 194 | static void |
196 | handle_result (void *cls, const struct RecordResultMessage *lrm) | 195 | handle_result(void *cls, const struct RecordResultMessage *lrm) |
197 | { | 196 | { |
198 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 197 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
199 | size_t name_len; | 198 | size_t name_len; |
@@ -202,18 +201,18 @@ handle_result (void *cls, const struct RecordResultMessage *lrm) | |||
202 | const char *name_tmp; | 201 | const char *name_tmp; |
203 | const char *rd_ser_tmp; | 202 | const char *rd_ser_tmp; |
204 | 203 | ||
205 | rd_len = ntohs (lrm->rd_len); | 204 | rd_len = ntohs(lrm->rd_len); |
206 | rd_count = ntohs (lrm->rd_count); | 205 | rd_count = ntohs(lrm->rd_count); |
207 | name_len = ntohs (lrm->name_len); | 206 | name_len = ntohs(lrm->name_len); |
208 | name_tmp = (const char *) &lrm[1]; | 207 | name_tmp = (const char *)&lrm[1]; |
209 | rd_ser_tmp = (const char *) &name_tmp[name_len]; | 208 | rd_ser_tmp = (const char *)&name_tmp[name_len]; |
210 | { | 209 | { |
211 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 210 | struct GNUNET_GNSRECORD_Data rd[rd_count]; |
212 | 211 | ||
213 | GNUNET_assert ( | 212 | GNUNET_assert( |
214 | GNUNET_OK == | 213 | GNUNET_OK == |
215 | GNUNET_GNSRECORD_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd)); | 214 | GNUNET_GNSRECORD_records_deserialize(rd_len, rd_ser_tmp, rd_count, rd)); |
216 | zm->monitor (zm->monitor_cls, &lrm->private_key, name_tmp, rd_count, rd); | 215 | zm->monitor(zm->monitor_cls, &lrm->private_key, name_tmp, rd_count, rd); |
217 | } | 216 | } |
218 | } | 217 | } |
219 | 218 | ||
@@ -227,12 +226,12 @@ handle_result (void *cls, const struct RecordResultMessage *lrm) | |||
227 | * @param error error code | 226 | * @param error error code |
228 | */ | 227 | */ |
229 | static void | 228 | static void |
230 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | 229 | mq_error_handler(void *cls, enum GNUNET_MQ_Error error) |
231 | { | 230 | { |
232 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 231 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
233 | 232 | ||
234 | (void) error; | 233 | (void)error; |
235 | reconnect (zm); | 234 | reconnect(zm); |
236 | } | 235 | } |
237 | 236 | ||
238 | 237 | ||
@@ -242,37 +241,37 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | |||
242 | * @param zm monitor to reconnect | 241 | * @param zm monitor to reconnect |
243 | */ | 242 | */ |
244 | static void | 243 | static void |
245 | reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | 244 | reconnect(struct GNUNET_NAMESTORE_ZoneMonitor *zm) |
246 | { | 245 | { |
247 | struct GNUNET_MQ_MessageHandler handlers[] = | 246 | struct GNUNET_MQ_MessageHandler handlers[] = |
248 | {GNUNET_MQ_hd_fixed_size (sync, | 247 | { GNUNET_MQ_hd_fixed_size(sync, |
249 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC, | 248 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC, |
250 | struct GNUNET_MessageHeader, | 249 | struct GNUNET_MessageHeader, |
251 | zm), | ||
252 | GNUNET_MQ_hd_var_size (result, | ||
253 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, | ||
254 | struct RecordResultMessage, | ||
255 | zm), | 250 | zm), |
256 | GNUNET_MQ_handler_end ()}; | 251 | GNUNET_MQ_hd_var_size(result, |
252 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, | ||
253 | struct RecordResultMessage, | ||
254 | zm), | ||
255 | GNUNET_MQ_handler_end() }; | ||
257 | struct GNUNET_MQ_Envelope *env; | 256 | struct GNUNET_MQ_Envelope *env; |
258 | struct ZoneMonitorStartMessage *sm; | 257 | struct ZoneMonitorStartMessage *sm; |
259 | 258 | ||
260 | if (NULL != zm->mq) | 259 | if (NULL != zm->mq) |
261 | { | 260 | { |
262 | GNUNET_MQ_destroy (zm->mq); | 261 | GNUNET_MQ_destroy(zm->mq); |
263 | zm->error_cb (zm->error_cb_cls); | 262 | zm->error_cb(zm->error_cb_cls); |
264 | } | 263 | } |
265 | zm->mq = GNUNET_CLIENT_connect (zm->cfg, | 264 | zm->mq = GNUNET_CLIENT_connect(zm->cfg, |
266 | "namestore", | 265 | "namestore", |
267 | handlers, | 266 | handlers, |
268 | &mq_error_handler, | 267 | &mq_error_handler, |
269 | zm); | 268 | zm); |
270 | if (NULL == zm->mq) | 269 | if (NULL == zm->mq) |
271 | return; | 270 | return; |
272 | env = GNUNET_MQ_msg (sm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START); | 271 | env = GNUNET_MQ_msg(sm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START); |
273 | sm->iterate_first = htonl (zm->iterate_first); | 272 | sm->iterate_first = htonl(zm->iterate_first); |
274 | sm->zone = zm->zone; | 273 | sm->zone = zm->zone; |
275 | GNUNET_MQ_send (zm->mq, env); | 274 | GNUNET_MQ_send(zm->mq, env); |
276 | } | 275 | } |
277 | 276 | ||
278 | 277 | ||
@@ -300,7 +299,7 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | |||
300 | * @return handle to stop monitoring | 299 | * @return handle to stop monitoring |
301 | */ | 300 | */ |
302 | struct GNUNET_NAMESTORE_ZoneMonitor * | 301 | struct GNUNET_NAMESTORE_ZoneMonitor * |
303 | GNUNET_NAMESTORE_zone_monitor_start ( | 302 | GNUNET_NAMESTORE_zone_monitor_start( |
304 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 303 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
305 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 304 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
306 | int iterate_first, | 305 | int iterate_first, |
@@ -313,7 +312,7 @@ GNUNET_NAMESTORE_zone_monitor_start ( | |||
313 | { | 312 | { |
314 | struct GNUNET_NAMESTORE_ZoneMonitor *zm; | 313 | struct GNUNET_NAMESTORE_ZoneMonitor *zm; |
315 | 314 | ||
316 | zm = GNUNET_new (struct GNUNET_NAMESTORE_ZoneMonitor); | 315 | zm = GNUNET_new(struct GNUNET_NAMESTORE_ZoneMonitor); |
317 | if (NULL != zone) | 316 | if (NULL != zone) |
318 | zm->zone = *zone; | 317 | zm->zone = *zone; |
319 | zm->iterate_first = iterate_first; | 318 | zm->iterate_first = iterate_first; |
@@ -324,12 +323,12 @@ GNUNET_NAMESTORE_zone_monitor_start ( | |||
324 | zm->sync_cb = sync_cb; | 323 | zm->sync_cb = sync_cb; |
325 | zm->sync_cb_cls = sync_cb_cls; | 324 | zm->sync_cb_cls = sync_cb_cls; |
326 | zm->cfg = cfg; | 325 | zm->cfg = cfg; |
327 | reconnect (zm); | 326 | reconnect(zm); |
328 | if (NULL == zm->mq) | 327 | if (NULL == zm->mq) |
329 | { | 328 | { |
330 | GNUNET_free (zm); | 329 | GNUNET_free(zm); |
331 | return NULL; | 330 | return NULL; |
332 | } | 331 | } |
333 | return zm; | 332 | return zm; |
334 | } | 333 | } |
335 | 334 | ||
@@ -356,15 +355,15 @@ GNUNET_NAMESTORE_zone_monitor_start ( | |||
356 | * (before #GNUNET_NAMESTORE_zone_monitor_next is to be called again) | 355 | * (before #GNUNET_NAMESTORE_zone_monitor_next is to be called again) |
357 | */ | 356 | */ |
358 | void | 357 | void |
359 | GNUNET_NAMESTORE_zone_monitor_next (struct GNUNET_NAMESTORE_ZoneMonitor *zm, | 358 | GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, |
360 | uint64_t limit) | 359 | uint64_t limit) |
361 | { | 360 | { |
362 | struct GNUNET_MQ_Envelope *env; | 361 | struct GNUNET_MQ_Envelope *env; |
363 | struct ZoneMonitorNextMessage *nm; | 362 | struct ZoneMonitorNextMessage *nm; |
364 | 363 | ||
365 | env = GNUNET_MQ_msg (nm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT); | 364 | env = GNUNET_MQ_msg(nm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT); |
366 | nm->limit = GNUNET_htonll (limit); | 365 | nm->limit = GNUNET_htonll(limit); |
367 | GNUNET_MQ_send (zm->mq, env); | 366 | GNUNET_MQ_send(zm->mq, env); |
368 | } | 367 | } |
369 | 368 | ||
370 | 369 | ||
@@ -374,14 +373,14 @@ GNUNET_NAMESTORE_zone_monitor_next (struct GNUNET_NAMESTORE_ZoneMonitor *zm, | |||
374 | * @param zm handle to the monitor activity to stop | 373 | * @param zm handle to the monitor activity to stop |
375 | */ | 374 | */ |
376 | void | 375 | void |
377 | GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | 376 | GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm) |
378 | { | 377 | { |
379 | if (NULL != zm->mq) | 378 | if (NULL != zm->mq) |
380 | { | 379 | { |
381 | GNUNET_MQ_destroy (zm->mq); | 380 | GNUNET_MQ_destroy(zm->mq); |
382 | zm->mq = NULL; | 381 | zm->mq = NULL; |
383 | } | 382 | } |
384 | GNUNET_free (zm); | 383 | GNUNET_free(zm); |
385 | } | 384 | } |
386 | 385 | ||
387 | /* end of namestore_api_monitor.c */ | 386 | /* end of namestore_api_monitor.c */ |