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