diff options
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r-- | src/util/resolver_api.c | 236 |
1 files changed, 99 insertions, 137 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index c32fc58fa..69d143bc1 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -100,7 +100,7 @@ struct GNUNET_RESOLVER_RequestHandle | |||
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Desired address family. | 102 | * Desired address family. |
103 | */ | 103 | */ |
104 | int domain; | 104 | int domain; |
105 | 105 | ||
106 | /** | 106 | /** |
@@ -123,35 +123,30 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
123 | struct sockaddr_in v4; | 123 | struct sockaddr_in v4; |
124 | struct sockaddr_in6 v6; | 124 | struct sockaddr_in6 v6; |
125 | 125 | ||
126 | memset (&v4, 0, sizeof(v4)); | 126 | memset (&v4, 0, sizeof (v4)); |
127 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 127 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
128 | v4.sin_family = AF_INET; | 128 | v4.sin_family = AF_INET; |
129 | #if HAVE_SOCKADDR_IN_SIN_LEN | 129 | #if HAVE_SOCKADDR_IN_SIN_LEN |
130 | v4.sin_len = sizeof(v4); | 130 | v4.sin_len = sizeof (v4); |
131 | #endif | 131 | #endif |
132 | memset (&v6, 0, sizeof(v6)); | 132 | memset (&v6, 0, sizeof (v6)); |
133 | v6.sin6_family = AF_INET6; | 133 | v6.sin6_family = AF_INET6; |
134 | #if HAVE_SOCKADDR_IN_SIN_LEN | 134 | #if HAVE_SOCKADDR_IN_SIN_LEN |
135 | v6.sin6_len = sizeof(v6); | 135 | v6.sin6_len = sizeof (v6); |
136 | #endif | 136 | #endif |
137 | if (GNUNET_OK != | 137 | if (GNUNET_OK != |
138 | GNUNET_CONFIGURATION_get_value_string (cfg, | 138 | GNUNET_CONFIGURATION_get_value_string (cfg, |
139 | "resolver", | 139 | "resolver", |
140 | "HOSTNAME", | 140 | "HOSTNAME", &hostname)) |
141 | &hostname)) | ||
142 | { | 141 | { |
143 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 142 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
144 | _("Must specify `%s' for `%s' in configuration!\n"), | 143 | _("Must specify `%s' for `%s' in configuration!\n"), |
145 | "HOSTNAME", | 144 | "HOSTNAME", "resolver"); |
146 | "resolver"); | ||
147 | GNUNET_assert (0); | 145 | GNUNET_assert (0); |
148 | } | 146 | } |
149 | if ( (1 != inet_pton (AF_INET, | 147 | if ((1 != inet_pton (AF_INET, |
150 | hostname, | 148 | hostname, |
151 | &v4)) || | 149 | &v4)) || (1 != inet_pton (AF_INET6, hostname, &v6))) |
152 | (1 != inet_pton (AF_INET6, | ||
153 | hostname, | ||
154 | &v6)) ) | ||
155 | { | 150 | { |
156 | GNUNET_free (hostname); | 151 | GNUNET_free (hostname); |
157 | return; | 152 | return; |
@@ -160,16 +155,15 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
160 | while (loopback[i] != NULL) | 155 | while (loopback[i] != NULL) |
161 | if (0 == strcasecmp (loopback[i++], hostname)) | 156 | if (0 == strcasecmp (loopback[i++], hostname)) |
162 | { | 157 | { |
163 | GNUNET_free (hostname); | 158 | GNUNET_free (hostname); |
164 | return; | 159 | return; |
165 | } | 160 | } |
166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
167 | _("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), | 162 | _ |
168 | "localhost", | 163 | ("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), |
169 | "HOSTNAME", | 164 | "localhost", "HOSTNAME", "resolver"); |
170 | "resolver"); | 165 | GNUNET_free (hostname); |
171 | GNUNET_free (hostname); | 166 | GNUNET_assert (0); |
172 | GNUNET_assert (0); | ||
173 | } | 167 | } |
174 | 168 | ||
175 | 169 | ||
@@ -274,9 +268,7 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
274 | #if DEBUG_RESOLVER | 268 | #if DEBUG_RESOLVER |
275 | { | 269 | { |
276 | char *ips = no_resolve (sa, salen); | 270 | char *ips = no_resolve (sa, salen); |
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s'.\n", ips); |
278 | "Resolver returns `%s'.\n", | ||
279 | ips); | ||
280 | GNUNET_free (ips); | 272 | GNUNET_free (ips); |
281 | } | 273 | } |
282 | #endif | 274 | #endif |
@@ -297,54 +289,42 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
297 | * @param tc unused scheduler context | 289 | * @param tc unused scheduler context |
298 | */ | 290 | */ |
299 | static void | 291 | static void |
300 | numeric_resolution (void *cls, | 292 | numeric_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
301 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
302 | { | 293 | { |
303 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; | 294 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; |
304 | struct sockaddr_in v4; | 295 | struct sockaddr_in v4; |
305 | struct sockaddr_in6 v6; | 296 | struct sockaddr_in6 v6; |
306 | 297 | ||
307 | memset (&v4, 0, sizeof(v4)); | 298 | memset (&v4, 0, sizeof (v4)); |
308 | v4.sin_family = AF_INET; | 299 | v4.sin_family = AF_INET; |
309 | #if HAVE_SOCKADDR_IN_SIN_LEN | 300 | #if HAVE_SOCKADDR_IN_SIN_LEN |
310 | v4.sin_len = sizeof(v4); | 301 | v4.sin_len = sizeof (v4); |
311 | #endif | 302 | #endif |
312 | memset (&v6, 0, sizeof(v6)); | 303 | memset (&v6, 0, sizeof (v6)); |
313 | v6.sin6_family = AF_INET6; | 304 | v6.sin6_family = AF_INET6; |
314 | #if HAVE_SOCKADDR_IN_SIN_LEN | 305 | #if HAVE_SOCKADDR_IN_SIN_LEN |
315 | v6.sin6_len = sizeof(v6); | 306 | v6.sin6_len = sizeof (v6); |
316 | #endif | 307 | #endif |
317 | 308 | ||
318 | if ( ( (rh->domain == AF_UNSPEC) || (rh->domain == AF_INET) ) && | 309 | if (((rh->domain == AF_UNSPEC) || (rh->domain == AF_INET)) && |
319 | (1 == inet_pton (AF_INET, | 310 | (1 == inet_pton (AF_INET, rh->hostname, &v4.sin_addr))) |
320 | rh->hostname, | ||
321 | &v4.sin_addr)) ) | ||
322 | { | 311 | { |
323 | rh->addr_callback (rh->cls, | 312 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v4, sizeof (v4)); |
324 | (const struct sockaddr*) &v4, | 313 | if ((rh->domain == AF_UNSPEC) && |
325 | sizeof(v4)); | 314 | (1 == inet_pton (AF_INET6, rh->hostname, &v6.sin6_addr))) |
326 | if ( (rh->domain == AF_UNSPEC) && | 315 | { |
327 | (1 == inet_pton (AF_INET6, | 316 | /* this can happen on some systems IF "hostname" is "localhost" */ |
328 | rh->hostname, | 317 | rh->addr_callback (rh->cls, |
329 | &v6.sin6_addr)) ) | 318 | (const struct sockaddr *) &v6, sizeof (v6)); |
330 | { | 319 | } |
331 | /* this can happen on some systems IF "hostname" is "localhost" */ | 320 | rh->addr_callback (rh->cls, NULL, 0); |
332 | rh->addr_callback (rh->cls, | ||
333 | (const struct sockaddr*) &v6, | ||
334 | sizeof(v6)); | ||
335 | } | ||
336 | rh->addr_callback (rh->cls, NULL, 0); | ||
337 | GNUNET_free (rh); | 321 | GNUNET_free (rh); |
338 | return; | 322 | return; |
339 | } | 323 | } |
340 | if ( ( (rh->domain == AF_UNSPEC) || (rh->domain == AF_INET6) ) && | 324 | if (((rh->domain == AF_UNSPEC) || (rh->domain == AF_INET6)) && |
341 | (1 == inet_pton (AF_INET6, | 325 | (1 == inet_pton (AF_INET6, rh->hostname, &v6.sin6_addr))) |
342 | rh->hostname, | ||
343 | &v6.sin6_addr)) ) | ||
344 | { | 326 | { |
345 | rh->addr_callback (rh->cls, | 327 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v6, sizeof (v6)); |
346 | (const struct sockaddr*) &v6, | ||
347 | sizeof(v6)); | ||
348 | rh->addr_callback (rh->cls, NULL, 0); | 328 | rh->addr_callback (rh->cls, NULL, 0); |
349 | GNUNET_free (rh); | 329 | GNUNET_free (rh); |
350 | return; | 330 | return; |
@@ -365,44 +345,35 @@ numeric_resolution (void *cls, | |||
365 | * @param tc unused scheduler context | 345 | * @param tc unused scheduler context |
366 | */ | 346 | */ |
367 | static void | 347 | static void |
368 | loopback_resolution (void *cls, | 348 | loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
369 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
370 | { | 349 | { |
371 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; | 350 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; |
372 | struct sockaddr_in v4; | 351 | struct sockaddr_in v4; |
373 | struct sockaddr_in6 v6; | 352 | struct sockaddr_in6 v6; |
374 | 353 | ||
375 | memset (&v4, 0, sizeof(v4)); | 354 | memset (&v4, 0, sizeof (v4)); |
376 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 355 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
377 | v4.sin_family = AF_INET; | 356 | v4.sin_family = AF_INET; |
378 | #if HAVE_SOCKADDR_IN_SIN_LEN | 357 | #if HAVE_SOCKADDR_IN_SIN_LEN |
379 | v4.sin_len = sizeof(v4); | 358 | v4.sin_len = sizeof (v4); |
380 | #endif | 359 | #endif |
381 | memset (&v6, 0, sizeof(v6)); | 360 | memset (&v6, 0, sizeof (v6)); |
382 | v6.sin6_family = AF_INET6; | 361 | v6.sin6_family = AF_INET6; |
383 | #if HAVE_SOCKADDR_IN_SIN_LEN | 362 | #if HAVE_SOCKADDR_IN_SIN_LEN |
384 | v6.sin6_len = sizeof(v6); | 363 | v6.sin6_len = sizeof (v6); |
385 | #endif | 364 | #endif |
386 | v6.sin6_addr = in6addr_loopback; | 365 | v6.sin6_addr = in6addr_loopback; |
387 | switch (rh->domain) | 366 | switch (rh->domain) |
388 | { | 367 | { |
389 | case AF_INET: | 368 | case AF_INET: |
390 | rh->addr_callback (rh->cls, | 369 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v4, sizeof (v4)); |
391 | (const struct sockaddr*) &v4, | ||
392 | sizeof(v4)); | ||
393 | break; | 370 | break; |
394 | case AF_INET6: | 371 | case AF_INET6: |
395 | rh->addr_callback (rh->cls, | 372 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v6, sizeof (v6)); |
396 | (const struct sockaddr*) &v6, | ||
397 | sizeof(v6)); | ||
398 | break; | 373 | break; |
399 | case AF_UNSPEC: | 374 | case AF_UNSPEC: |
400 | rh->addr_callback (rh->cls, | 375 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v6, sizeof (v6)); |
401 | (const struct sockaddr*) &v6, | 376 | rh->addr_callback (rh->cls, (const struct sockaddr *) &v4, sizeof (v4)); |
402 | sizeof(v6)); | ||
403 | rh->addr_callback (rh->cls, | ||
404 | (const struct sockaddr*) &v4, | ||
405 | sizeof(v4)); | ||
406 | break; | 377 | break; |
407 | default: | 378 | default: |
408 | GNUNET_break (0); | 379 | GNUNET_break (0); |
@@ -431,8 +402,8 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
431 | const char *hostname, | 402 | const char *hostname, |
432 | int domain, | 403 | int domain, |
433 | struct GNUNET_TIME_Relative timeout, | 404 | struct GNUNET_TIME_Relative timeout, |
434 | GNUNET_RESOLVER_AddressCallback callback, | 405 | GNUNET_RESOLVER_AddressCallback callback, |
435 | void *callback_cls) | 406 | void *callback_cls) |
436 | { | 407 | { |
437 | struct GNUNET_CLIENT_Connection *client; | 408 | struct GNUNET_CLIENT_Connection *client; |
438 | struct GNUNET_RESOLVER_GetMessage *msg; | 409 | struct GNUNET_RESOLVER_GetMessage *msg; |
@@ -451,32 +422,31 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
451 | GNUNET_break (0); | 422 | GNUNET_break (0); |
452 | return NULL; | 423 | return NULL; |
453 | } | 424 | } |
454 | rh = GNUNET_malloc (sizeof(struct GNUNET_RESOLVER_RequestHandle) + slen); | 425 | rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); |
455 | rh->sched = sched; | 426 | rh->sched = sched; |
456 | rh->domain = domain; | 427 | rh->domain = domain; |
457 | rh->addr_callback = callback; | 428 | rh->addr_callback = callback; |
458 | rh->cls = callback_cls; | 429 | rh->cls = callback_cls; |
459 | memcpy (&rh[1], hostname, slen); | 430 | memcpy (&rh[1], hostname, slen); |
460 | rh->hostname = (const char*) &rh[1]; | 431 | rh->hostname = (const char *) &rh[1]; |
461 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 432 | rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
462 | 433 | ||
463 | /* first, check if this is a numeric address */ | 434 | /* first, check if this is a numeric address */ |
464 | if ( ( (1 == inet_pton (AF_INET, | 435 | if (((1 == inet_pton (AF_INET, |
465 | hostname, | 436 | hostname, |
466 | &v4)) && | 437 | &v4)) && |
467 | ( (domain == AF_INET) || (domain == AF_UNSPEC)) ) || | 438 | ((domain == AF_INET) || (domain == AF_UNSPEC))) || |
468 | ( (1 == inet_pton (AF_INET6, | 439 | ((1 == inet_pton (AF_INET6, |
469 | hostname, | 440 | hostname, |
470 | &v6)) && | 441 | &v6)) && |
471 | ( (domain == AF_INET6) || (domain == AF_UNSPEC)) ) ) | 442 | ((domain == AF_INET6) || (domain == AF_UNSPEC)))) |
472 | { | 443 | { |
473 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, | 444 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, |
474 | GNUNET_NO, | 445 | GNUNET_NO, |
475 | GNUNET_SCHEDULER_PRIORITY_KEEP, | 446 | GNUNET_SCHEDULER_PRIORITY_KEEP, |
476 | GNUNET_SCHEDULER_NO_TASK, | 447 | GNUNET_SCHEDULER_NO_TASK, |
477 | GNUNET_TIME_UNIT_ZERO, | 448 | GNUNET_TIME_UNIT_ZERO, |
478 | &numeric_resolution, | 449 | &numeric_resolution, rh); |
479 | rh); | ||
480 | return rh; | 450 | return rh; |
481 | } | 451 | } |
482 | /* then, check if this is a loopback address */ | 452 | /* then, check if this is a loopback address */ |
@@ -484,25 +454,24 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
484 | while (loopback[i] != NULL) | 454 | while (loopback[i] != NULL) |
485 | if (0 == strcasecmp (loopback[i++], hostname)) | 455 | if (0 == strcasecmp (loopback[i++], hostname)) |
486 | { | 456 | { |
487 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, | 457 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, |
488 | GNUNET_NO, | 458 | GNUNET_NO, |
489 | GNUNET_SCHEDULER_PRIORITY_KEEP, | 459 | GNUNET_SCHEDULER_PRIORITY_KEEP, |
490 | GNUNET_SCHEDULER_NO_TASK, | 460 | GNUNET_SCHEDULER_NO_TASK, |
491 | GNUNET_TIME_UNIT_ZERO, | 461 | GNUNET_TIME_UNIT_ZERO, |
492 | &loopback_resolution, | 462 | &loopback_resolution, rh); |
493 | rh); | 463 | return rh; |
494 | return rh; | ||
495 | } | 464 | } |
496 | 465 | ||
497 | client = GNUNET_CLIENT_connect (sched, "resolver", cfg); | 466 | client = GNUNET_CLIENT_connect (sched, "resolver", cfg); |
498 | if (client == NULL) | 467 | if (client == NULL) |
499 | { | 468 | { |
500 | GNUNET_free (rh); | 469 | GNUNET_free (rh); |
501 | return NULL; | 470 | return NULL; |
502 | } | 471 | } |
503 | rh->client = client; | 472 | rh->client = client; |
504 | 473 | ||
505 | msg = (struct GNUNET_RESOLVER_GetMessage*) buf; | 474 | msg = (struct GNUNET_RESOLVER_GetMessage *) buf; |
506 | msg->header.size = | 475 | msg->header.size = |
507 | htons (sizeof (struct GNUNET_RESOLVER_GetMessage) + slen); | 476 | htons (sizeof (struct GNUNET_RESOLVER_GetMessage) + slen); |
508 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST); | 477 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST); |
@@ -517,11 +486,10 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
517 | #endif | 486 | #endif |
518 | if (GNUNET_OK != | 487 | if (GNUNET_OK != |
519 | GNUNET_CLIENT_transmit_and_get_response (client, | 488 | GNUNET_CLIENT_transmit_and_get_response (client, |
520 | &msg->header, | 489 | &msg->header, |
521 | timeout, | 490 | timeout, |
522 | GNUNET_YES, | 491 | GNUNET_YES, |
523 | &handle_address_response, | 492 | &handle_address_response, rh)) |
524 | rh)) | ||
525 | { | 493 | { |
526 | GNUNET_free (rh); | 494 | GNUNET_free (rh); |
527 | GNUNET_CLIENT_disconnect (client); | 495 | GNUNET_CLIENT_disconnect (client); |
@@ -538,8 +506,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
538 | * @param msg message with the hostname, NULL on error | 506 | * @param msg message with the hostname, NULL on error |
539 | */ | 507 | */ |
540 | static void | 508 | static void |
541 | handle_hostname_response (void *cls, | 509 | handle_hostname_response (void *cls, const struct GNUNET_MessageHeader *msg) |
542 | const struct GNUNET_MessageHeader *msg) | ||
543 | { | 510 | { |
544 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; | 511 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; |
545 | uint16_t size; | 512 | uint16_t size; |
@@ -596,17 +563,14 @@ handle_hostname_response (void *cls, | |||
596 | * @param tc unused scheduler context | 563 | * @param tc unused scheduler context |
597 | */ | 564 | */ |
598 | static void | 565 | static void |
599 | numeric_reverse (void *cls, | 566 | numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
600 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
601 | { | 567 | { |
602 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; | 568 | struct GNUNET_RESOLVER_RequestHandle *rh = cls; |
603 | char *result; | 569 | char *result; |
604 | 570 | ||
605 | result = no_resolve ((const struct sockaddr*) &rh[1], | 571 | result = no_resolve ((const struct sockaddr *) &rh[1], rh->salen); |
606 | rh->salen); | ||
607 | #if DEBUG_RESOLVER | 572 | #if DEBUG_RESOLVER |
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 573 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s'.\n"), result); |
609 | _("Resolver returns `%s'.\n"), result); | ||
610 | #endif | 574 | #endif |
611 | if (result != NULL) | 575 | if (result != NULL) |
612 | { | 576 | { |
@@ -659,12 +623,11 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
659 | if (GNUNET_NO == do_resolve) | 623 | if (GNUNET_NO == do_resolve) |
660 | { | 624 | { |
661 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, | 625 | rh->task = GNUNET_SCHEDULER_add_delayed (sched, |
662 | GNUNET_NO, | 626 | GNUNET_NO, |
663 | GNUNET_SCHEDULER_PRIORITY_KEEP, | 627 | GNUNET_SCHEDULER_PRIORITY_KEEP, |
664 | GNUNET_SCHEDULER_NO_TASK, | 628 | GNUNET_SCHEDULER_NO_TASK, |
665 | GNUNET_TIME_UNIT_ZERO, | 629 | GNUNET_TIME_UNIT_ZERO, |
666 | &numeric_reverse, | 630 | &numeric_reverse, rh); |
667 | rh); | ||
668 | return rh; | 631 | return rh; |
669 | } | 632 | } |
670 | if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) > | 633 | if (salen + sizeof (struct GNUNET_RESOLVER_GetMessage) > |
@@ -682,7 +645,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
682 | } | 645 | } |
683 | rh->client = client; | 646 | rh->client = client; |
684 | 647 | ||
685 | msg = (struct GNUNET_RESOLVER_GetMessage*) buf; | 648 | msg = (struct GNUNET_RESOLVER_GetMessage *) buf; |
686 | msg->header.size = | 649 | msg->header.size = |
687 | htons (sizeof (struct GNUNET_RESOLVER_GetMessage) + salen); | 650 | htons (sizeof (struct GNUNET_RESOLVER_GetMessage) + salen); |
688 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST); | 651 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST); |
@@ -695,11 +658,10 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
695 | #endif | 658 | #endif |
696 | if (GNUNET_OK != | 659 | if (GNUNET_OK != |
697 | GNUNET_CLIENT_transmit_and_get_response (client, | 660 | GNUNET_CLIENT_transmit_and_get_response (client, |
698 | &msg->header, | 661 | &msg->header, |
699 | timeout, | 662 | timeout, |
700 | GNUNET_YES, | 663 | GNUNET_YES, |
701 | &handle_hostname_response, | 664 | &handle_hostname_response, rh)) |
702 | rh)) | ||
703 | { | 665 | { |
704 | GNUNET_CLIENT_disconnect (client); | 666 | GNUNET_CLIENT_disconnect (client); |
705 | GNUNET_free (rh); | 667 | GNUNET_free (rh); |
@@ -722,8 +684,8 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
722 | */ | 684 | */ |
723 | struct GNUNET_RESOLVER_RequestHandle * | 685 | struct GNUNET_RESOLVER_RequestHandle * |
724 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | 686 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, |
725 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 687 | const struct GNUNET_CONFIGURATION_Handle |
726 | int domain, | 688 | *cfg, int domain, |
727 | struct GNUNET_TIME_Relative timeout, | 689 | struct GNUNET_TIME_Relative timeout, |
728 | GNUNET_RESOLVER_AddressCallback callback, | 690 | GNUNET_RESOLVER_AddressCallback callback, |
729 | void *cls) | 691 | void *cls) |
@@ -742,7 +704,8 @@ GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | |||
742 | _("Resolving our hostname `%s'\n"), hostname); | 704 | _("Resolving our hostname `%s'\n"), hostname); |
743 | #endif | 705 | #endif |
744 | return GNUNET_RESOLVER_ip_get (sched, | 706 | return GNUNET_RESOLVER_ip_get (sched, |
745 | cfg, hostname, domain, timeout, callback, cls); | 707 | cfg, hostname, domain, timeout, callback, |
708 | cls); | ||
746 | } | 709 | } |
747 | 710 | ||
748 | 711 | ||
@@ -760,8 +723,7 @@ GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h) | |||
760 | if (h->client != NULL) | 723 | if (h->client != NULL) |
761 | GNUNET_CLIENT_disconnect (h->client); | 724 | GNUNET_CLIENT_disconnect (h->client); |
762 | if (h->task != GNUNET_SCHEDULER_NO_TASK) | 725 | if (h->task != GNUNET_SCHEDULER_NO_TASK) |
763 | GNUNET_SCHEDULER_cancel (h->sched, | 726 | GNUNET_SCHEDULER_cancel (h->sched, h->task); |
764 | h->task); | ||
765 | GNUNET_free (h); | 727 | GNUNET_free (h); |
766 | } | 728 | } |
767 | 729 | ||