diff options
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 491 |
1 files changed, 242 insertions, 249 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 65c232f93..5bfaf4859 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.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 gns/gnunet-service-gns.c | 21 | * @file gns/gnunet-service-gns.c |
22 | * @brief GNU Name System (main service) | 22 | * @brief GNU Name System (main service) |
@@ -46,9 +46,7 @@ struct GnsClient; | |||
46 | /** | 46 | /** |
47 | * Handle to a lookup operation from client via API. | 47 | * Handle to a lookup operation from client via API. |
48 | */ | 48 | */ |
49 | struct ClientLookupHandle | 49 | struct ClientLookupHandle { |
50 | { | ||
51 | |||
52 | /** | 50 | /** |
53 | * We keep these in a DLL. | 51 | * We keep these in a DLL. |
54 | */ | 52 | */ |
@@ -73,15 +71,13 @@ struct ClientLookupHandle | |||
73 | * request id | 71 | * request id |
74 | */ | 72 | */ |
75 | uint32_t request_id; | 73 | uint32_t request_id; |
76 | |||
77 | }; | 74 | }; |
78 | 75 | ||
79 | 76 | ||
80 | /** | 77 | /** |
81 | * Information we track per connected client. | 78 | * Information we track per connected client. |
82 | */ | 79 | */ |
83 | struct GnsClient | 80 | struct GnsClient { |
84 | { | ||
85 | /** | 81 | /** |
86 | * The client | 82 | * The client |
87 | */ | 83 | */ |
@@ -108,9 +104,7 @@ struct GnsClient | |||
108 | * Representation of a TLD, mapping the respective TLD string | 104 | * Representation of a TLD, mapping the respective TLD string |
109 | * (i.e. ".gnu") to the respective public key of the zone. | 105 | * (i.e. ".gnu") to the respective public key of the zone. |
110 | */ | 106 | */ |
111 | struct GNS_TopLevelDomain | 107 | struct GNS_TopLevelDomain { |
112 | { | ||
113 | |||
114 | /** | 108 | /** |
115 | * Kept in a DLL, as there are unlikely enough of these to | 109 | * Kept in a DLL, as there are unlikely enough of these to |
116 | * warrant a hash map. | 110 | * warrant a hash map. |
@@ -132,7 +126,6 @@ struct GNS_TopLevelDomain | |||
132 | * Top-level domain as a string, including leading ".". | 126 | * Top-level domain as a string, including leading ".". |
133 | */ | 127 | */ |
134 | char *tld; | 128 | char *tld; |
135 | |||
136 | }; | 129 | }; |
137 | 130 | ||
138 | 131 | ||
@@ -180,25 +173,25 @@ static struct GNS_TopLevelDomain *tld_tail; | |||
180 | * @return #GNUNET_YES if @a tld was found #GNUNET_NO if not | 173 | * @return #GNUNET_YES if @a tld was found #GNUNET_NO if not |
181 | */ | 174 | */ |
182 | int | 175 | int |
183 | GNS_find_tld (const char *tld_str, | 176 | GNS_find_tld(const char *tld_str, |
184 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey) | 177 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey) |
185 | { | 178 | { |
186 | if ('\0' == *tld_str) | 179 | if ('\0' == *tld_str) |
187 | return GNUNET_NO; | 180 | return GNUNET_NO; |
188 | for (struct GNS_TopLevelDomain *tld = tld_head; | 181 | for (struct GNS_TopLevelDomain *tld = tld_head; |
189 | NULL != tld; | 182 | NULL != tld; |
190 | tld = tld->next) | 183 | tld = tld->next) |
191 | { | ||
192 | if (0 == strcasecmp (tld_str, | ||
193 | tld->tld)) | ||
194 | { | 184 | { |
195 | *pkey = tld->pkey; | 185 | if (0 == strcasecmp(tld_str, |
196 | return GNUNET_YES; | 186 | tld->tld)) |
187 | { | ||
188 | *pkey = tld->pkey; | ||
189 | return GNUNET_YES; | ||
190 | } | ||
197 | } | 191 | } |
198 | } | ||
199 | if (GNUNET_OK == | 192 | if (GNUNET_OK == |
200 | GNUNET_GNSRECORD_zkey_to_pkey (tld_str + 1, | 193 | GNUNET_GNSRECORD_zkey_to_pkey(tld_str + 1, |
201 | pkey)) | 194 | pkey)) |
202 | return GNUNET_YES; /* TLD string *was* the public key */ | 195 | return GNUNET_YES; /* TLD string *was* the public key */ |
203 | return GNUNET_NO; | 196 | return GNUNET_NO; |
204 | } | 197 | } |
@@ -212,12 +205,12 @@ GNS_find_tld (const char *tld_str, | |||
212 | * or @a name if @a name does not contain a "." | 205 | * or @a name if @a name does not contain a "." |
213 | */ | 206 | */ |
214 | const char * | 207 | const char * |
215 | GNS_get_tld (const char *name) | 208 | GNS_get_tld(const char *name) |
216 | { | 209 | { |
217 | const char *tld; | 210 | const char *tld; |
218 | 211 | ||
219 | tld = strrchr (name, | 212 | tld = strrchr(name, |
220 | (unsigned char) '.'); | 213 | (unsigned char)'.'); |
221 | if (NULL == tld) | 214 | if (NULL == tld) |
222 | tld = name; | 215 | tld = name; |
223 | else | 216 | else |
@@ -232,39 +225,39 @@ GNS_get_tld (const char *name) | |||
232 | * @param cls unused, NULL | 225 | * @param cls unused, NULL |
233 | */ | 226 | */ |
234 | static void | 227 | static void |
235 | shutdown_task (void *cls) | 228 | shutdown_task(void *cls) |
236 | { | 229 | { |
237 | struct GNS_TopLevelDomain *tld; | 230 | struct GNS_TopLevelDomain *tld; |
238 | 231 | ||
239 | (void) cls; | 232 | (void)cls; |
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 233 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
241 | "Shutting down!\n"); | 234 | "Shutting down!\n"); |
242 | GNS_interceptor_done (); | 235 | GNS_interceptor_done(); |
243 | GNS_resolver_done (); | 236 | GNS_resolver_done(); |
244 | if (NULL != statistics) | 237 | if (NULL != statistics) |
245 | { | 238 | { |
246 | GNUNET_STATISTICS_destroy (statistics, | 239 | GNUNET_STATISTICS_destroy(statistics, |
247 | GNUNET_NO); | 240 | GNUNET_NO); |
248 | statistics = NULL; | 241 | statistics = NULL; |
249 | } | 242 | } |
250 | if (NULL != namecache_handle) | 243 | if (NULL != namecache_handle) |
251 | { | 244 | { |
252 | GNUNET_NAMECACHE_disconnect (namecache_handle); | 245 | GNUNET_NAMECACHE_disconnect(namecache_handle); |
253 | namecache_handle = NULL; | 246 | namecache_handle = NULL; |
254 | } | 247 | } |
255 | if (NULL != dht_handle) | 248 | if (NULL != dht_handle) |
256 | { | 249 | { |
257 | GNUNET_DHT_disconnect (dht_handle); | 250 | GNUNET_DHT_disconnect(dht_handle); |
258 | dht_handle = NULL; | 251 | dht_handle = NULL; |
259 | } | 252 | } |
260 | while (NULL != (tld = tld_head)) | 253 | while (NULL != (tld = tld_head)) |
261 | { | 254 | { |
262 | GNUNET_CONTAINER_DLL_remove (tld_head, | 255 | GNUNET_CONTAINER_DLL_remove(tld_head, |
263 | tld_tail, | 256 | tld_tail, |
264 | tld); | 257 | tld); |
265 | GNUNET_free (tld->tld); | 258 | GNUNET_free(tld->tld); |
266 | GNUNET_free (tld); | 259 | GNUNET_free(tld); |
267 | } | 260 | } |
268 | } | 261 | } |
269 | 262 | ||
270 | 263 | ||
@@ -276,27 +269,27 @@ shutdown_task (void *cls) | |||
276 | * @param app_ctx @a client | 269 | * @param app_ctx @a client |
277 | */ | 270 | */ |
278 | static void | 271 | static void |
279 | client_disconnect_cb (void *cls, | 272 | client_disconnect_cb(void *cls, |
280 | struct GNUNET_SERVICE_Client *client, | 273 | struct GNUNET_SERVICE_Client *client, |
281 | void *app_ctx) | 274 | void *app_ctx) |
282 | { | 275 | { |
283 | struct ClientLookupHandle *clh; | 276 | struct ClientLookupHandle *clh; |
284 | struct GnsClient *gc = app_ctx; | 277 | struct GnsClient *gc = app_ctx; |
285 | 278 | ||
286 | (void) cls; | 279 | (void)cls; |
287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 280 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
288 | "Client %p disconnected\n", | 281 | "Client %p disconnected\n", |
289 | client); | 282 | client); |
290 | while (NULL != (clh = gc->clh_head)) | 283 | while (NULL != (clh = gc->clh_head)) |
291 | { | 284 | { |
292 | if (NULL != clh->lookup) | 285 | if (NULL != clh->lookup) |
293 | GNS_resolver_lookup_cancel (clh->lookup); | 286 | GNS_resolver_lookup_cancel(clh->lookup); |
294 | GNUNET_CONTAINER_DLL_remove (gc->clh_head, | 287 | GNUNET_CONTAINER_DLL_remove(gc->clh_head, |
295 | gc->clh_tail, | 288 | gc->clh_tail, |
296 | clh); | 289 | clh); |
297 | GNUNET_free (clh); | 290 | GNUNET_free(clh); |
298 | } | 291 | } |
299 | GNUNET_free (gc); | 292 | GNUNET_free(gc); |
300 | } | 293 | } |
301 | 294 | ||
302 | 295 | ||
@@ -309,17 +302,17 @@ client_disconnect_cb (void *cls, | |||
309 | * @return internal namestore client structure for this client | 302 | * @return internal namestore client structure for this client |
310 | */ | 303 | */ |
311 | static void * | 304 | static void * |
312 | client_connect_cb (void *cls, | 305 | client_connect_cb(void *cls, |
313 | struct GNUNET_SERVICE_Client *client, | 306 | struct GNUNET_SERVICE_Client *client, |
314 | struct GNUNET_MQ_Handle *mq) | 307 | struct GNUNET_MQ_Handle *mq) |
315 | { | 308 | { |
316 | struct GnsClient *gc; | 309 | struct GnsClient *gc; |
317 | 310 | ||
318 | (void) cls; | 311 | (void)cls; |
319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 312 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
320 | "Client %p connected\n", | 313 | "Client %p connected\n", |
321 | client); | 314 | client); |
322 | gc = GNUNET_new (struct GnsClient); | 315 | gc = GNUNET_new(struct GnsClient); |
323 | gc->client = client; | 316 | gc->client = client; |
324 | gc->mq = mq; | 317 | gc->mq = mq; |
325 | return gc; | 318 | return gc; |
@@ -334,9 +327,9 @@ client_connect_cb (void *cls, | |||
334 | * @param rd the record data | 327 | * @param rd the record data |
335 | */ | 328 | */ |
336 | static void | 329 | static void |
337 | send_lookup_response (void *cls, | 330 | send_lookup_response(void *cls, |
338 | uint32_t rd_count, | 331 | uint32_t rd_count, |
339 | const struct GNUNET_GNSRECORD_Data *rd) | 332 | const struct GNUNET_GNSRECORD_Data *rd) |
340 | { | 333 | { |
341 | struct ClientLookupHandle *clh = cls; | 334 | struct ClientLookupHandle *clh = cls; |
342 | struct GnsClient *gc = clh->gc; | 335 | struct GnsClient *gc = clh->gc; |
@@ -344,46 +337,46 @@ send_lookup_response (void *cls, | |||
344 | struct LookupResultMessage *rmsg; | 337 | struct LookupResultMessage *rmsg; |
345 | ssize_t len; | 338 | ssize_t len; |
346 | 339 | ||
347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 340 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
348 | "Sending LOOKUP_RESULT message with %u results\n", | 341 | "Sending LOOKUP_RESULT message with %u results\n", |
349 | (unsigned int) rd_count); | 342 | (unsigned int)rd_count); |
350 | len = GNUNET_GNSRECORD_records_get_size (rd_count, | 343 | len = GNUNET_GNSRECORD_records_get_size(rd_count, |
351 | rd); | 344 | rd); |
352 | if (len < 0) | 345 | if (len < 0) |
353 | { | 346 | { |
354 | GNUNET_break (0); | 347 | GNUNET_break(0); |
355 | GNUNET_SERVICE_client_drop (gc->client); | 348 | GNUNET_SERVICE_client_drop(gc->client); |
356 | return; | 349 | return; |
357 | } | 350 | } |
358 | if (len > UINT16_MAX - sizeof (*rmsg)) | 351 | if (len > UINT16_MAX - sizeof(*rmsg)) |
359 | { | 352 | { |
360 | GNUNET_break (0); | 353 | GNUNET_break(0); |
361 | GNUNET_SERVICE_client_drop (gc->client); | 354 | GNUNET_SERVICE_client_drop(gc->client); |
362 | return; | 355 | return; |
363 | } | 356 | } |
364 | env = GNUNET_MQ_msg_extra (rmsg, | 357 | env = GNUNET_MQ_msg_extra(rmsg, |
365 | len, | 358 | len, |
366 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); | 359 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); |
367 | rmsg->id = clh->request_id; | 360 | rmsg->id = clh->request_id; |
368 | rmsg->rd_count = htonl (rd_count); | 361 | rmsg->rd_count = htonl(rd_count); |
369 | GNUNET_assert (len == | 362 | GNUNET_assert(len == |
370 | GNUNET_GNSRECORD_records_serialize (rd_count, | 363 | GNUNET_GNSRECORD_records_serialize(rd_count, |
371 | rd, | 364 | rd, |
372 | len, | 365 | len, |
373 | (char*) &rmsg[1])); | 366 | (char*)&rmsg[1])); |
374 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (gc->client), | 367 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(gc->client), |
375 | env); | 368 | env); |
376 | GNUNET_CONTAINER_DLL_remove (gc->clh_head, | 369 | GNUNET_CONTAINER_DLL_remove(gc->clh_head, |
377 | gc->clh_tail, | 370 | gc->clh_tail, |
378 | clh); | 371 | clh); |
379 | GNUNET_free (clh); | 372 | GNUNET_free(clh); |
380 | GNUNET_STATISTICS_update (statistics, | 373 | GNUNET_STATISTICS_update(statistics, |
381 | "Completed lookups", 1, | 374 | "Completed lookups", 1, |
382 | GNUNET_NO); | 375 | GNUNET_NO); |
383 | GNUNET_STATISTICS_update (statistics, | 376 | GNUNET_STATISTICS_update(statistics, |
384 | "Records resolved", | 377 | "Records resolved", |
385 | rd_count, | 378 | rd_count, |
386 | GNUNET_NO); | 379 | GNUNET_NO); |
387 | } | 380 | } |
388 | 381 | ||
389 | 382 | ||
@@ -395,19 +388,19 @@ send_lookup_response (void *cls, | |||
395 | * @return #GNUNET_OK if @a l_msg is well-formed | 388 | * @return #GNUNET_OK if @a l_msg is well-formed |
396 | */ | 389 | */ |
397 | static int | 390 | static int |
398 | check_lookup (void *cls, | 391 | check_lookup(void *cls, |
399 | const struct LookupMessage *l_msg) | 392 | const struct LookupMessage *l_msg) |
400 | { | 393 | { |
401 | size_t nlen; | 394 | size_t nlen; |
402 | 395 | ||
403 | (void) cls; | 396 | (void)cls; |
404 | GNUNET_MQ_check_zero_termination (l_msg); | 397 | GNUNET_MQ_check_zero_termination(l_msg); |
405 | nlen = ntohs (l_msg->header.size) - sizeof (struct LookupMessage); | 398 | nlen = ntohs(l_msg->header.size) - sizeof(struct LookupMessage); |
406 | if (nlen > GNUNET_DNSPARSER_MAX_NAME_LENGTH) | 399 | if (nlen > GNUNET_DNSPARSER_MAX_NAME_LENGTH) |
407 | { | 400 | { |
408 | GNUNET_break (0); | 401 | GNUNET_break(0); |
409 | return GNUNET_SYSERR; | 402 | return GNUNET_SYSERR; |
410 | } | 403 | } |
411 | return GNUNET_OK; | 404 | return GNUNET_OK; |
412 | } | 405 | } |
413 | 406 | ||
@@ -420,8 +413,8 @@ check_lookup (void *cls, | |||
420 | * @param message the message | 413 | * @param message the message |
421 | */ | 414 | */ |
422 | static void | 415 | static void |
423 | handle_lookup (void *cls, | 416 | handle_lookup(void *cls, |
424 | const struct LookupMessage *sh_msg) | 417 | const struct LookupMessage *sh_msg) |
425 | { | 418 | { |
426 | struct GnsClient *gc = cls; | 419 | struct GnsClient *gc = cls; |
427 | char name[GNUNET_DNSPARSER_MAX_NAME_LENGTH + 1]; | 420 | char name[GNUNET_DNSPARSER_MAX_NAME_LENGTH + 1]; |
@@ -429,47 +422,47 @@ handle_lookup (void *cls, | |||
429 | char *nameptr = name; | 422 | char *nameptr = name; |
430 | const char *utf_in; | 423 | const char *utf_in; |
431 | 424 | ||
432 | GNUNET_SERVICE_client_continue (gc->client); | 425 | GNUNET_SERVICE_client_continue(gc->client); |
433 | utf_in = (const char *) &sh_msg[1]; | 426 | utf_in = (const char *)&sh_msg[1]; |
434 | GNUNET_STRINGS_utf8_tolower (utf_in, | 427 | GNUNET_STRINGS_utf8_tolower(utf_in, |
435 | nameptr); | 428 | nameptr); |
436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 429 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
437 | "Received LOOKUP `%s' message\n", | 430 | "Received LOOKUP `%s' message\n", |
438 | name); | 431 | name); |
439 | clh = GNUNET_new (struct ClientLookupHandle); | 432 | clh = GNUNET_new(struct ClientLookupHandle); |
440 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, | 433 | GNUNET_CONTAINER_DLL_insert(gc->clh_head, |
441 | gc->clh_tail, | 434 | gc->clh_tail, |
442 | clh); | 435 | clh); |
443 | clh->gc = gc; | 436 | clh->gc = gc; |
444 | clh->request_id = sh_msg->id; | 437 | clh->request_id = sh_msg->id; |
445 | if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) && | 438 | if ((GNUNET_DNSPARSER_TYPE_A == ntohl(sh_msg->type)) && |
446 | (GNUNET_OK != v4_enabled) ) | 439 | (GNUNET_OK != v4_enabled)) |
447 | { | 440 | { |
448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
449 | "LOOKUP: Query for A record but AF_INET not supported!"); | 442 | "LOOKUP: Query for A record but AF_INET not supported!"); |
450 | send_lookup_response (clh, | 443 | send_lookup_response(clh, |
451 | 0, | 444 | 0, |
452 | NULL); | 445 | NULL); |
453 | return; | 446 | return; |
454 | } | 447 | } |
455 | if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && | 448 | if ((GNUNET_DNSPARSER_TYPE_AAAA == ntohl(sh_msg->type)) && |
456 | (GNUNET_OK != v6_enabled) ) | 449 | (GNUNET_OK != v6_enabled)) |
457 | { | 450 | { |
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 451 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
459 | "LOOKUP: Query for AAAA record but AF_INET6 not supported!"); | 452 | "LOOKUP: Query for AAAA record but AF_INET6 not supported!"); |
460 | send_lookup_response (clh, | 453 | send_lookup_response(clh, |
461 | 0, | 454 | 0, |
462 | NULL); | 455 | NULL); |
463 | return; | 456 | return; |
464 | } | 457 | } |
465 | clh->lookup = GNS_resolver_lookup (&sh_msg->zone, | 458 | clh->lookup = GNS_resolver_lookup(&sh_msg->zone, |
466 | ntohl (sh_msg->type), | 459 | ntohl(sh_msg->type), |
467 | name, | 460 | name, |
468 | (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), | 461 | (enum GNUNET_GNS_LocalOptions)ntohs(sh_msg->options), |
469 | &send_lookup_response, clh); | 462 | &send_lookup_response, clh); |
470 | GNUNET_STATISTICS_update (statistics, | 463 | GNUNET_STATISTICS_update(statistics, |
471 | "Lookup attempts", | 464 | "Lookup attempts", |
472 | 1, GNUNET_NO); | 465 | 1, GNUNET_NO); |
473 | } | 466 | } |
474 | 467 | ||
475 | 468 | ||
@@ -482,36 +475,36 @@ handle_lookup (void *cls, | |||
482 | * @param value value for the option, public key for TLDs | 475 | * @param value value for the option, public key for TLDs |
483 | */ | 476 | */ |
484 | static void | 477 | static void |
485 | read_service_conf (void *cls, | 478 | read_service_conf(void *cls, |
486 | const char *section, | 479 | const char *section, |
487 | const char *option, | 480 | const char *option, |
488 | const char *value) | 481 | const char *value) |
489 | { | 482 | { |
490 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 483 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
491 | struct GNS_TopLevelDomain *tld; | 484 | struct GNS_TopLevelDomain *tld; |
492 | 485 | ||
493 | (void) cls; | 486 | (void)cls; |
494 | (void) section; | 487 | (void)section; |
495 | if (option[0] != '.') | 488 | if (option[0] != '.') |
496 | return; | 489 | return; |
497 | if (GNUNET_OK != | 490 | if (GNUNET_OK != |
498 | GNUNET_STRINGS_string_to_data (value, | 491 | GNUNET_STRINGS_string_to_data(value, |
499 | strlen (value), | 492 | strlen(value), |
500 | &pk, | 493 | &pk, |
501 | sizeof (pk))) | 494 | sizeof(pk))) |
502 | { | 495 | { |
503 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 496 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, |
504 | section, | 497 | section, |
505 | option, | 498 | option, |
506 | _("Properly base32-encoded public key required")); | 499 | _("Properly base32-encoded public key required")); |
507 | return; | 500 | return; |
508 | } | 501 | } |
509 | tld = GNUNET_new (struct GNS_TopLevelDomain); | 502 | tld = GNUNET_new(struct GNS_TopLevelDomain); |
510 | tld->tld = GNUNET_strdup (&option[1]); | 503 | tld->tld = GNUNET_strdup(&option[1]); |
511 | tld->pkey = pk; | 504 | tld->pkey = pk; |
512 | GNUNET_CONTAINER_DLL_insert (tld_head, | 505 | GNUNET_CONTAINER_DLL_insert(tld_head, |
513 | tld_tail, | 506 | tld_tail, |
514 | tld); | 507 | tld); |
515 | } | 508 | } |
516 | 509 | ||
517 | 510 | ||
@@ -523,66 +516,66 @@ read_service_conf (void *cls, | |||
523 | * @param c configuration to use | 516 | * @param c configuration to use |
524 | */ | 517 | */ |
525 | static void | 518 | static void |
526 | run (void *cls, | 519 | run(void *cls, |
527 | const struct GNUNET_CONFIGURATION_Handle *c, | 520 | const struct GNUNET_CONFIGURATION_Handle *c, |
528 | struct GNUNET_SERVICE_Handle *service) | 521 | struct GNUNET_SERVICE_Handle *service) |
529 | { | 522 | { |
530 | unsigned long long max_parallel_bg_queries = 16; | 523 | unsigned long long max_parallel_bg_queries = 16; |
531 | 524 | ||
532 | GNUNET_CONFIGURATION_iterate_section_values (c, | 525 | GNUNET_CONFIGURATION_iterate_section_values(c, |
533 | "gns", | 526 | "gns", |
534 | &read_service_conf, | 527 | &read_service_conf, |
535 | NULL); | 528 | NULL); |
536 | v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); | 529 | v6_enabled = GNUNET_NETWORK_test_pf(PF_INET6); |
537 | v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); | 530 | v4_enabled = GNUNET_NETWORK_test_pf(PF_INET); |
538 | namecache_handle = GNUNET_NAMECACHE_connect (c); | 531 | namecache_handle = GNUNET_NAMECACHE_connect(c); |
539 | if (NULL == namecache_handle) | 532 | if (NULL == namecache_handle) |
540 | { | 533 | { |
541 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 534 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
542 | _("Failed to connect to the namecache!\n")); | 535 | _("Failed to connect to the namecache!\n")); |
543 | GNUNET_SCHEDULER_shutdown (); | 536 | GNUNET_SCHEDULER_shutdown(); |
544 | return; | 537 | return; |
545 | } | 538 | } |
546 | if (GNUNET_OK == | 539 | if (GNUNET_OK == |
547 | GNUNET_CONFIGURATION_get_value_number (c, | 540 | GNUNET_CONFIGURATION_get_value_number(c, |
548 | "gns", | 541 | "gns", |
549 | "MAX_PARALLEL_BACKGROUND_QUERIES", | 542 | "MAX_PARALLEL_BACKGROUND_QUERIES", |
550 | &max_parallel_bg_queries)) | 543 | &max_parallel_bg_queries)) |
551 | { | 544 | { |
552 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 545 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
553 | "Number of allowed parallel background queries: %llu\n", | 546 | "Number of allowed parallel background queries: %llu\n", |
554 | max_parallel_bg_queries); | 547 | max_parallel_bg_queries); |
555 | } | 548 | } |
556 | dht_handle = GNUNET_DHT_connect (c, | 549 | dht_handle = GNUNET_DHT_connect(c, |
557 | (unsigned int) max_parallel_bg_queries); | 550 | (unsigned int)max_parallel_bg_queries); |
558 | if (NULL == dht_handle) | 551 | if (NULL == dht_handle) |
559 | { | 552 | { |
560 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 553 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
561 | _("Could not connect to DHT!\n")); | 554 | _("Could not connect to DHT!\n")); |
562 | GNUNET_SCHEDULER_add_now (&shutdown_task, | 555 | GNUNET_SCHEDULER_add_now(&shutdown_task, |
563 | NULL); | 556 | NULL); |
564 | return; | 557 | return; |
565 | } | 558 | } |
566 | GNS_resolver_init (namecache_handle, | 559 | GNS_resolver_init(namecache_handle, |
567 | dht_handle, | 560 | dht_handle, |
568 | c, | 561 | c, |
569 | max_parallel_bg_queries); | 562 | max_parallel_bg_queries); |
570 | if ( (GNUNET_YES == | 563 | if ((GNUNET_YES == |
571 | GNUNET_CONFIGURATION_get_value_yesno (c, | 564 | GNUNET_CONFIGURATION_get_value_yesno(c, |
572 | "gns", | 565 | "gns", |
573 | "INTERCEPT_DNS")) && | 566 | "INTERCEPT_DNS")) && |
574 | (GNUNET_SYSERR == | 567 | (GNUNET_SYSERR == |
575 | GNS_interceptor_init (c)) ) | 568 | GNS_interceptor_init(c))) |
576 | { | 569 | { |
577 | GNUNET_break (0); | 570 | GNUNET_break(0); |
578 | GNUNET_SCHEDULER_add_now (&shutdown_task, | 571 | GNUNET_SCHEDULER_add_now(&shutdown_task, |
579 | NULL); | 572 | NULL); |
580 | return; | 573 | return; |
581 | } | 574 | } |
582 | statistics = GNUNET_STATISTICS_create ("gns", | 575 | statistics = GNUNET_STATISTICS_create("gns", |
583 | c); | 576 | c); |
584 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 577 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, |
585 | NULL); | 578 | NULL); |
586 | } | 579 | } |
587 | 580 | ||
588 | 581 | ||
@@ -590,17 +583,17 @@ run (void *cls, | |||
590 | * Define "main" method using service macro. | 583 | * Define "main" method using service macro. |
591 | */ | 584 | */ |
592 | GNUNET_SERVICE_MAIN | 585 | GNUNET_SERVICE_MAIN |
593 | ("gns", | 586 | ("gns", |
594 | GNUNET_SERVICE_OPTION_NONE, | 587 | GNUNET_SERVICE_OPTION_NONE, |
595 | &run, | 588 | &run, |
596 | &client_connect_cb, | 589 | &client_connect_cb, |
597 | &client_disconnect_cb, | 590 | &client_disconnect_cb, |
598 | NULL, | 591 | NULL, |
599 | GNUNET_MQ_hd_var_size (lookup, | 592 | GNUNET_MQ_hd_var_size(lookup, |
600 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP, | 593 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP, |
601 | struct LookupMessage, | 594 | struct LookupMessage, |
602 | NULL), | 595 | NULL), |
603 | GNUNET_MQ_handler_end()); | 596 | GNUNET_MQ_handler_end()); |
604 | 597 | ||
605 | 598 | ||
606 | /* end of gnunet-service-gns.c */ | 599 | /* end of gnunet-service-gns.c */ |