diff options
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r-- | src/transport/plugin_transport_unix.c | 582 |
1 files changed, 283 insertions, 299 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 2a7dc9065..22dda8e8b 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -375,26 +375,27 @@ unix_transport_server_stop (void *cls) | |||
375 | 375 | ||
376 | pos = retry_list_head; | 376 | pos = retry_list_head; |
377 | 377 | ||
378 | while(NULL != (pos = retry_list_head)) | 378 | while (NULL != (pos = retry_list_head)) |
379 | { | ||
380 | GNUNET_CONTAINER_DLL_remove (retry_list_head, retry_list_tail, pos); | ||
381 | if (GNUNET_SCHEDULER_NO_TASK != pos->retry_ctx->retry_task) | ||
379 | { | 382 | { |
380 | GNUNET_CONTAINER_DLL_remove(retry_list_head, retry_list_tail, pos); | 383 | GNUNET_SCHEDULER_cancel (pos->retry_ctx->retry_task); |
381 | if (GNUNET_SCHEDULER_NO_TASK != pos->retry_ctx->retry_task) | ||
382 | { | ||
383 | GNUNET_SCHEDULER_cancel(pos->retry_ctx->retry_task); | ||
384 | } | ||
385 | GNUNET_free(pos->retry_ctx->msg); | ||
386 | GNUNET_free(pos->retry_ctx->addr); | ||
387 | GNUNET_free(pos->retry_ctx); | ||
388 | GNUNET_free(pos); | ||
389 | } | 384 | } |
385 | GNUNET_free (pos->retry_ctx->msg); | ||
386 | GNUNET_free (pos->retry_ctx->addr); | ||
387 | GNUNET_free (pos->retry_ctx); | ||
388 | GNUNET_free (pos); | ||
389 | } | ||
390 | 390 | ||
391 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) | 391 | if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) |
392 | { | 392 | { |
393 | GNUNET_SCHEDULER_cancel (plugin->select_task); | 393 | GNUNET_SCHEDULER_cancel (plugin->select_task); |
394 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; | 394 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; |
395 | } | 395 | } |
396 | 396 | ||
397 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->unix_sock.desc)); | 397 | GNUNET_break (GNUNET_OK == |
398 | GNUNET_NETWORK_socket_close (plugin->unix_sock.desc)); | ||
398 | plugin->unix_sock.desc = NULL; | 399 | plugin->unix_sock.desc = NULL; |
399 | 400 | ||
400 | return GNUNET_OK; | 401 | return GNUNET_OK; |
@@ -402,18 +403,17 @@ unix_transport_server_stop (void *cls) | |||
402 | 403 | ||
403 | 404 | ||
404 | struct PeerSession * | 405 | struct PeerSession * |
405 | find_session (struct Plugin *plugin, | 406 | find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer) |
406 | const struct GNUNET_PeerIdentity *peer) | ||
407 | { | 407 | { |
408 | struct PeerSession *pos; | 408 | struct PeerSession *pos; |
409 | 409 | ||
410 | pos = plugin->sessions; | 410 | pos = plugin->sessions; |
411 | while (pos != NULL) | 411 | while (pos != NULL) |
412 | { | 412 | { |
413 | if (memcmp(&pos->target, peer, sizeof(struct GNUNET_PeerIdentity)) == 0) | 413 | if (memcmp (&pos->target, peer, sizeof (struct GNUNET_PeerIdentity)) == 0) |
414 | return pos; | 414 | return pos; |
415 | pos = pos->next; | 415 | pos = pos->next; |
416 | } | 416 | } |
417 | 417 | ||
418 | return pos; | 418 | return pos; |
419 | } | 419 | } |
@@ -430,8 +430,7 @@ unix_real_send (void *cls, | |||
430 | struct GNUNET_TIME_Relative timeout, | 430 | struct GNUNET_TIME_Relative timeout, |
431 | const void *addr, | 431 | const void *addr, |
432 | size_t addrlen, | 432 | size_t addrlen, |
433 | GNUNET_TRANSPORT_TransmitContinuation cont, | 433 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls); |
434 | void *cont_cls); | ||
435 | 434 | ||
436 | /** | 435 | /** |
437 | * Retry sending a message. | 436 | * Retry sending a message. |
@@ -439,18 +438,18 @@ unix_real_send (void *cls, | |||
439 | * @param cls closure a struct RetrySendContext | 438 | * @param cls closure a struct RetrySendContext |
440 | * @param tc context information | 439 | * @param tc context information |
441 | */ | 440 | */ |
442 | void retry_send_message (void *cls, | 441 | void |
443 | const struct GNUNET_SCHEDULER_TaskContext * tc) | 442 | retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
444 | { | 443 | { |
445 | struct RetrySendContext *retry_ctx = cls; | 444 | struct RetrySendContext *retry_ctx = cls; |
446 | 445 | ||
447 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 446 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
448 | { | 447 | { |
449 | GNUNET_free(retry_ctx->msg); | 448 | GNUNET_free (retry_ctx->msg); |
450 | GNUNET_free(retry_ctx->addr); | 449 | GNUNET_free (retry_ctx->addr); |
451 | GNUNET_free(retry_ctx); | 450 | GNUNET_free (retry_ctx); |
452 | return; | 451 | return; |
453 | } | 452 | } |
454 | 453 | ||
455 | unix_real_send (retry_ctx->plugin, | 454 | unix_real_send (retry_ctx->plugin, |
456 | retry_ctx, | 455 | retry_ctx, |
@@ -461,9 +460,7 @@ void retry_send_message (void *cls, | |||
461 | retry_ctx->priority, | 460 | retry_ctx->priority, |
462 | GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout), | 461 | GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout), |
463 | retry_ctx->addr, | 462 | retry_ctx->addr, |
464 | retry_ctx->addrlen, | 463 | retry_ctx->addrlen, retry_ctx->cont, retry_ctx->cont_cls); |
465 | retry_ctx->cont, | ||
466 | retry_ctx->cont_cls); | ||
467 | return; | 464 | return; |
468 | } | 465 | } |
469 | 466 | ||
@@ -493,15 +490,14 @@ static ssize_t | |||
493 | unix_real_send (void *cls, | 490 | unix_real_send (void *cls, |
494 | struct RetrySendContext *incoming_retry_context, | 491 | struct RetrySendContext *incoming_retry_context, |
495 | struct GNUNET_NETWORK_Handle *send_handle, | 492 | struct GNUNET_NETWORK_Handle *send_handle, |
496 | const struct GNUNET_PeerIdentity *target, | 493 | const struct GNUNET_PeerIdentity *target, |
497 | const char *msgbuf, | 494 | const char *msgbuf, |
498 | size_t msgbuf_size, | 495 | size_t msgbuf_size, |
499 | unsigned int priority, | 496 | unsigned int priority, |
500 | struct GNUNET_TIME_Relative timeout, | 497 | struct GNUNET_TIME_Relative timeout, |
501 | const void *addr, | 498 | const void *addr, |
502 | size_t addrlen, | 499 | size_t addrlen, |
503 | GNUNET_TRANSPORT_TransmitContinuation cont, | 500 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
504 | void *cont_cls) | ||
505 | { | 501 | { |
506 | struct Plugin *plugin = cls; | 502 | struct Plugin *plugin = cls; |
507 | struct UNIXMessage *message; | 503 | struct UNIXMessage *message; |
@@ -516,26 +512,26 @@ unix_real_send (void *cls, | |||
516 | int retry; | 512 | int retry; |
517 | 513 | ||
518 | if (send_handle == NULL) | 514 | if (send_handle == NULL) |
519 | { | 515 | { |
520 | #if DEBUG_UNIX | 516 | #if DEBUG_UNIX |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
522 | "unix_real_send with send_handle NULL!\n"); | 518 | "unix_real_send with send_handle NULL!\n"); |
523 | #endif | 519 | #endif |
524 | /* failed to open send socket for AF */ | 520 | /* failed to open send socket for AF */ |
525 | if (cont != NULL) | 521 | if (cont != NULL) |
526 | cont (cont_cls, target, GNUNET_SYSERR); | 522 | cont (cont_cls, target, GNUNET_SYSERR); |
527 | return 0; | 523 | return 0; |
528 | } | 524 | } |
529 | if ((addr == NULL) || (addrlen == 0)) | 525 | if ((addr == NULL) || (addrlen == 0)) |
530 | { | 526 | { |
531 | #if DEBUG_UNIX | 527 | #if DEBUG_UNIX |
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
533 | "unix_real_send called without address, returning!\n"); | 529 | "unix_real_send called without address, returning!\n"); |
534 | #endif | 530 | #endif |
535 | if (cont != NULL) | 531 | if (cont != NULL) |
536 | cont (cont_cls, target, GNUNET_SYSERR); | 532 | cont (cont_cls, target, GNUNET_SYSERR); |
537 | return 0; /* Can never send if we don't have an address!! */ | 533 | return 0; /* Can never send if we don't have an address!! */ |
538 | } | 534 | } |
539 | 535 | ||
540 | /* Build the message to be sent */ | 536 | /* Build the message to be sent */ |
541 | message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size); | 537 | message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size); |
@@ -547,13 +543,13 @@ unix_real_send (void *cls, | |||
547 | sizeof (struct GNUNET_PeerIdentity)); | 543 | sizeof (struct GNUNET_PeerIdentity)); |
548 | memcpy (&message[1], msgbuf, msgbuf_size); | 544 | memcpy (&message[1], msgbuf, msgbuf_size); |
549 | 545 | ||
550 | memset(&un, 0, sizeof(un)); | 546 | memset (&un, 0, sizeof (un)); |
551 | un.sun_family = AF_UNIX; | 547 | un.sun_family = AF_UNIX; |
552 | slen = strlen (addr) + 1; | 548 | slen = strlen (addr) + 1; |
553 | if (slen >= sizeof (un.sun_path)) | 549 | if (slen >= sizeof (un.sun_path)) |
554 | slen = sizeof (un.sun_path) - 1; | 550 | slen = sizeof (un.sun_path) - 1; |
555 | sent = 0; | 551 | sent = 0; |
556 | GNUNET_assert(slen < sizeof(un.sun_path)); | 552 | GNUNET_assert (slen < sizeof (un.sun_path)); |
557 | memcpy (un.sun_path, addr, slen); | 553 | memcpy (un.sun_path, addr, slen); |
558 | un.sun_path[slen] = '\0'; | 554 | un.sun_path[slen] = '\0'; |
559 | slen = sizeof (struct sockaddr_un); | 555 | slen = sizeof (struct sockaddr_un); |
@@ -563,104 +559,105 @@ unix_real_send (void *cls, | |||
563 | #if HAVE_SOCKADDR_IN_SIN_LEN | 559 | #if HAVE_SOCKADDR_IN_SIN_LEN |
564 | un.sun_len = (u_char) slen; | 560 | un.sun_len = (u_char) slen; |
565 | #endif | 561 | #endif |
566 | sb = (struct sockaddr*) &un; | 562 | sb = (struct sockaddr *) &un; |
567 | sbs = slen; | 563 | sbs = slen; |
568 | retry = GNUNET_NO; | 564 | retry = GNUNET_NO; |
569 | 565 | ||
570 | sent = GNUNET_NETWORK_socket_sendto(send_handle, message, ssize, sb, sbs); | 566 | sent = GNUNET_NETWORK_socket_sendto (send_handle, message, ssize, sb, sbs); |
571 | 567 | ||
572 | if ((GNUNET_SYSERR == sent) && (errno == EAGAIN)) | 568 | if ((GNUNET_SYSERR == sent) && (errno == EAGAIN)) |
573 | retry = GNUNET_YES; | 569 | retry = GNUNET_YES; |
574 | 570 | ||
575 | if ((GNUNET_SYSERR == sent) && (errno == EMSGSIZE)) | 571 | if ((GNUNET_SYSERR == sent) && (errno == EMSGSIZE)) |
576 | { | 572 | { |
577 | socklen_t size = 0; | 573 | socklen_t size = 0; |
578 | socklen_t len = sizeof (size); | 574 | socklen_t len = sizeof (size); |
579 | GNUNET_NETWORK_socket_getsockopt ((struct GNUNET_NETWORK_Handle * ) send_handle, | 575 | |
580 | SOL_SOCKET, | 576 | GNUNET_NETWORK_socket_getsockopt ((struct GNUNET_NETWORK_Handle *) |
581 | SO_SNDBUF, | 577 | send_handle, SOL_SOCKET, SO_SNDBUF, &size, |
582 | &size, &len); | 578 | &len); |
583 | 579 | ||
584 | if (size < ssize) | 580 | if (size < ssize) |
585 | { | 581 | { |
586 | #if DEBUG_UNIX | 582 | #if DEBUG_UNIX |
587 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
588 | "Trying to increase socket buffer size from %i to %i for message size %i\n", | 584 | "Trying to increase socket buffer size from %i to %i for message size %i\n", |
589 | size, | 585 | size, ((ssize / 1000) + 2) * 1000, ssize); |
590 | ((ssize / 1000) + 2) * 1000, ssize); | ||
591 | #endif | 586 | #endif |
592 | size = ((ssize / 1000) + 2) * 1000; | 587 | size = ((ssize / 1000) + 2) * 1000; |
593 | if (GNUNET_NETWORK_socket_setsockopt ((struct GNUNET_NETWORK_Handle * ) send_handle, | 588 | if (GNUNET_NETWORK_socket_setsockopt |
594 | SOL_SOCKET, | 589 | ((struct GNUNET_NETWORK_Handle *) send_handle, SOL_SOCKET, SO_SNDBUF, |
595 | SO_SNDBUF, | 590 | &size, sizeof (size)) == GNUNET_OK) |
596 | &size, sizeof(size)) == GNUNET_OK) | 591 | retry = GNUNET_YES; |
597 | retry = GNUNET_YES; | 592 | else |
598 | else | 593 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "setsockopt"); |
599 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "setsockopt"); | 594 | } |
600 | } | ||
601 | } | 595 | } |
602 | 596 | ||
603 | if (retry == GNUNET_YES) | 597 | if (retry == GNUNET_YES) |
598 | { | ||
599 | if (incoming_retry_context == NULL) | ||
604 | { | 600 | { |
605 | if (incoming_retry_context == NULL) | 601 | retry_list_entry = GNUNET_malloc (sizeof (struct RetryList)); |
606 | { | 602 | retry_ctx = GNUNET_malloc (sizeof (struct RetrySendContext)); |
607 | retry_list_entry = GNUNET_malloc(sizeof(struct RetryList)); | 603 | retry_ctx->addr = GNUNET_malloc (addrlen); |
608 | retry_ctx = GNUNET_malloc(sizeof(struct RetrySendContext)); | 604 | retry_ctx->msg = GNUNET_malloc (msgbuf_size); |
609 | retry_ctx->addr = GNUNET_malloc(addrlen); | 605 | retry_ctx->plugin = plugin; |
610 | retry_ctx->msg = GNUNET_malloc(msgbuf_size); | 606 | memcpy (retry_ctx->addr, addr, addrlen); |
611 | retry_ctx->plugin = plugin; | 607 | memcpy (retry_ctx->msg, msgbuf, msgbuf_size); |
612 | memcpy(retry_ctx->addr, addr, addrlen); | 608 | retry_ctx->msg_size = msgbuf_size; |
613 | memcpy(retry_ctx->msg, msgbuf, msgbuf_size); | 609 | retry_ctx->addrlen = addrlen; |
614 | retry_ctx->msg_size = msgbuf_size; | 610 | retry_ctx->send_handle = send_handle; |
615 | retry_ctx->addrlen = addrlen; | 611 | retry_ctx->cont = cont; |
616 | retry_ctx->send_handle = send_handle; | 612 | retry_ctx->cont_cls = cont_cls; |
617 | retry_ctx->cont = cont; | 613 | retry_ctx->priority = priority; |
618 | retry_ctx->cont_cls = cont_cls; | 614 | retry_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
619 | retry_ctx->priority = priority; | 615 | memcpy (&retry_ctx->target, target, sizeof (struct GNUNET_PeerIdentity)); |
620 | retry_ctx->timeout = GNUNET_TIME_relative_to_absolute(timeout); | 616 | retry_ctx->delay = GNUNET_TIME_UNIT_MILLISECONDS; |
621 | memcpy(&retry_ctx->target, target, sizeof(struct GNUNET_PeerIdentity)); | 617 | retry_ctx->retry_list_entry = retry_list_entry; |
622 | retry_ctx->delay = GNUNET_TIME_UNIT_MILLISECONDS; | 618 | retry_list_entry->retry_ctx = retry_ctx; |
623 | retry_ctx->retry_list_entry = retry_list_entry; | 619 | GNUNET_CONTAINER_DLL_insert (retry_list_head, retry_list_tail, |
624 | retry_list_entry->retry_ctx = retry_ctx; | 620 | retry_list_entry); |
625 | GNUNET_CONTAINER_DLL_insert(retry_list_head, retry_list_tail, retry_list_entry); | ||
626 | } | ||
627 | else | ||
628 | { | ||
629 | retry_ctx = incoming_retry_context; | ||
630 | retry_ctx->delay = GNUNET_TIME_relative_multiply(retry_ctx->delay, 2); | ||
631 | } | ||
632 | retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(retry_ctx->delay, &retry_send_message, retry_ctx); | ||
633 | |||
634 | //GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); | ||
635 | GNUNET_free(message); | ||
636 | return ssize; | ||
637 | } | 621 | } |
622 | else | ||
623 | { | ||
624 | retry_ctx = incoming_retry_context; | ||
625 | retry_ctx->delay = GNUNET_TIME_relative_multiply (retry_ctx->delay, 2); | ||
626 | } | ||
627 | retry_ctx->retry_task = | ||
628 | GNUNET_SCHEDULER_add_delayed (retry_ctx->delay, &retry_send_message, | ||
629 | retry_ctx); | ||
630 | |||
631 | //GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); | ||
632 | GNUNET_free (message); | ||
633 | return ssize; | ||
634 | } | ||
638 | #if DEBUG_UNIX | 635 | #if DEBUG_UNIX |
639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
640 | "UNIX transmit %u-byte message to %s (%d: %s)\n", | 637 | "UNIX transmit %u-byte message to %s (%d: %s)\n", |
641 | (unsigned int) ssize, | 638 | (unsigned int) ssize, |
642 | GNUNET_a2s (sb, sbs), | 639 | GNUNET_a2s (sb, sbs), |
643 | (int) sent, | 640 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); |
644 | (sent < 0) ? STRERROR (errno) : "ok"); | ||
645 | #endif | 641 | #endif |
646 | if (cont != NULL) | 642 | if (cont != NULL) |
643 | { | ||
644 | if (sent == GNUNET_SYSERR) | ||
645 | cont (cont_cls, target, GNUNET_SYSERR); | ||
646 | else | ||
647 | { | 647 | { |
648 | if (sent == GNUNET_SYSERR) | 648 | cont (cont_cls, target, GNUNET_OK); |
649 | cont (cont_cls, target, GNUNET_SYSERR); | ||
650 | else | ||
651 | { | ||
652 | cont (cont_cls, target, GNUNET_OK); | ||
653 | } | ||
654 | } | 649 | } |
650 | } | ||
655 | 651 | ||
656 | if (incoming_retry_context != NULL) | 652 | if (incoming_retry_context != NULL) |
657 | { | 653 | { |
658 | GNUNET_CONTAINER_DLL_remove(retry_list_head, retry_list_tail, incoming_retry_context->retry_list_entry); | 654 | GNUNET_CONTAINER_DLL_remove (retry_list_head, retry_list_tail, |
659 | GNUNET_free(incoming_retry_context->retry_list_entry); | 655 | incoming_retry_context->retry_list_entry); |
660 | GNUNET_free(incoming_retry_context->msg); | 656 | GNUNET_free (incoming_retry_context->retry_list_entry); |
661 | GNUNET_free(incoming_retry_context->addr); | 657 | GNUNET_free (incoming_retry_context->msg); |
662 | GNUNET_free(incoming_retry_context); | 658 | GNUNET_free (incoming_retry_context->addr); |
663 | } | 659 | GNUNET_free (incoming_retry_context); |
660 | } | ||
664 | 661 | ||
665 | GNUNET_free (message); | 662 | GNUNET_free (message); |
666 | return sent; | 663 | return sent; |
@@ -693,16 +690,16 @@ unix_real_send (void *cls, | |||
693 | */ | 690 | */ |
694 | static ssize_t | 691 | static ssize_t |
695 | unix_plugin_send (void *cls, | 692 | unix_plugin_send (void *cls, |
696 | const struct GNUNET_PeerIdentity *target, | 693 | const struct GNUNET_PeerIdentity *target, |
697 | const char *msgbuf, | 694 | const char *msgbuf, |
698 | size_t msgbuf_size, | 695 | size_t msgbuf_size, |
699 | unsigned int priority, | 696 | unsigned int priority, |
700 | struct GNUNET_TIME_Relative timeout, | 697 | struct GNUNET_TIME_Relative timeout, |
701 | struct Session *session, | 698 | struct Session *session, |
702 | const void *addr, | 699 | const void *addr, |
703 | size_t addrlen, | 700 | size_t addrlen, |
704 | int force_address, | 701 | int force_address, |
705 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 702 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
706 | { | 703 | { |
707 | struct Plugin *plugin = cls; | 704 | struct Plugin *plugin = cls; |
708 | ssize_t sent; | 705 | ssize_t sent; |
@@ -712,17 +709,18 @@ unix_plugin_send (void *cls, | |||
712 | GNUNET_assert (NULL == session); | 709 | GNUNET_assert (NULL == session); |
713 | 710 | ||
714 | #if DEBUG_UNIX | 711 | #if DEBUG_UNIX |
715 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n", (char *)addr); | 712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n", |
713 | (char *) addr); | ||
716 | #endif | 714 | #endif |
717 | sent = unix_real_send(cls, | 715 | sent = unix_real_send (cls, |
718 | NULL, | 716 | NULL, |
719 | plugin->unix_sock.desc, | 717 | plugin->unix_sock.desc, |
720 | target, | 718 | target, |
721 | msgbuf, msgbuf_size, | 719 | msgbuf, msgbuf_size, |
722 | priority, timeout, addr, addrlen, | 720 | priority, timeout, addr, addrlen, cont, cont_cls); |
723 | cont, cont_cls); | ||
724 | #if DEBUG_UNIX | 721 | #if DEBUG_UNIX |
725 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent, (char *)addr); | 722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent, |
723 | (char *) addr); | ||
726 | #endif | 724 | #endif |
727 | if (sent == GNUNET_SYSERR) | 725 | if (sent == GNUNET_SYSERR) |
728 | return 0; | 726 | return 0; |
@@ -740,11 +738,10 @@ unix_plugin_send (void *cls, | |||
740 | * @param fromlen the length of the address | 738 | * @param fromlen the length of the address |
741 | */ | 739 | */ |
742 | static void | 740 | static void |
743 | unix_demultiplexer(struct Plugin *plugin, | 741 | unix_demultiplexer (struct Plugin *plugin, |
744 | struct GNUNET_PeerIdentity *sender, | 742 | struct GNUNET_PeerIdentity *sender, |
745 | const struct GNUNET_MessageHeader *currhdr, | 743 | const struct GNUNET_MessageHeader *currhdr, |
746 | const struct sockaddr_un *un, | 744 | const struct sockaddr_un *un, size_t fromlen) |
747 | size_t fromlen) | ||
748 | { | 745 | { |
749 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; | 746 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; |
750 | 747 | ||
@@ -753,14 +750,16 @@ unix_demultiplexer(struct Plugin *plugin, | |||
753 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | 750 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); |
754 | distance[1].value = htonl (0); | 751 | distance[1].value = htonl (0); |
755 | 752 | ||
756 | GNUNET_assert(fromlen >= sizeof(struct sockaddr_un)); | 753 | GNUNET_assert (fromlen >= sizeof (struct sockaddr_un)); |
757 | 754 | ||
758 | #if DEBUG_UNIX | 755 | #if DEBUG_UNIX |
759 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received message from %s\n", un->sun_path); | 756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message from %s\n", |
757 | un->sun_path); | ||
760 | #endif | 758 | #endif |
761 | plugin->env->receive (plugin->env->cls, sender, currhdr, | 759 | plugin->env->receive (plugin->env->cls, sender, currhdr, |
762 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, | 760 | (const struct GNUNET_TRANSPORT_ATS_Information *) |
763 | NULL, un->sun_path, strlen(un->sun_path) + 1); | 761 | &distance, 2, NULL, un->sun_path, |
762 | strlen (un->sun_path) + 1); | ||
764 | } | 763 | } |
765 | 764 | ||
766 | 765 | ||
@@ -774,8 +773,7 @@ unix_demultiplexer(struct Plugin *plugin, | |||
774 | * | 773 | * |
775 | */ | 774 | */ |
776 | static void | 775 | static void |
777 | unix_plugin_select (void *cls, | 776 | unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
778 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
779 | { | 777 | { |
780 | struct Plugin *plugin = cls; | 778 | struct Plugin *plugin = cls; |
781 | char buf[65536]; | 779 | char buf[65536]; |
@@ -791,33 +789,35 @@ unix_plugin_select (void *cls, | |||
791 | uint16_t csize; | 789 | uint16_t csize; |
792 | 790 | ||
793 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; | 791 | plugin->select_task = GNUNET_SCHEDULER_NO_TASK; |
794 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 792 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
795 | return; | 793 | return; |
796 | 794 | ||
797 | addrlen = sizeof(un); | 795 | addrlen = sizeof (un); |
798 | memset(&un, 0, sizeof(un)); | 796 | memset (&un, 0, sizeof (un)); |
799 | GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->unix_sock.desc)); | 797 | GNUNET_assert (GNUNET_NETWORK_fdset_isset |
798 | (tc->read_ready, plugin->unix_sock.desc)); | ||
800 | ret = | 799 | ret = |
801 | GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof (buf), | 800 | GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof (buf), |
802 | (struct sockaddr *)&un, &addrlen); | 801 | (struct sockaddr *) &un, &addrlen); |
803 | 802 | ||
804 | if (ret == GNUNET_SYSERR) | 803 | if (ret == GNUNET_SYSERR) |
805 | { | 804 | { |
806 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom"); | 805 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom"); |
807 | plugin->select_task = | 806 | plugin->select_task = |
808 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 807 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
809 | GNUNET_SCHEDULER_NO_TASK, | 808 | GNUNET_SCHEDULER_NO_TASK, |
810 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 809 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
811 | NULL, &unix_plugin_select, plugin); | 810 | NULL, &unix_plugin_select, plugin); |
812 | return; | 811 | return; |
813 | } | 812 | } |
814 | else | 813 | else |
815 | { | 814 | { |
816 | #if LINUX | 815 | #if LINUX |
817 | un.sun_path[0] = '/'; | 816 | un.sun_path[0] = '/'; |
818 | #endif | 817 | #endif |
819 | #if DEBUG_UNIX | 818 | #if DEBUG_UNIX |
820 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Read %d bytes from socket %s\n", ret, &un.sun_path[0]); | 819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %d bytes from socket %s\n", ret, |
820 | &un.sun_path[0]); | ||
821 | #endif | 821 | #endif |
822 | } | 822 | } |
823 | 823 | ||
@@ -825,40 +825,38 @@ unix_plugin_select (void *cls, | |||
825 | 825 | ||
826 | msg = (struct UNIXMessage *) buf; | 826 | msg = (struct UNIXMessage *) buf; |
827 | csize = ntohs (msg->header.size); | 827 | csize = ntohs (msg->header.size); |
828 | if ( (csize < sizeof (struct UNIXMessage)) || | 828 | if ((csize < sizeof (struct UNIXMessage)) || (csize > ret)) |
829 | (csize > ret) ) | 829 | { |
830 | { | 830 | GNUNET_break_op (0); |
831 | GNUNET_break_op (0); | 831 | plugin->select_task = |
832 | plugin->select_task = | 832 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
833 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 833 | GNUNET_SCHEDULER_NO_TASK, |
834 | GNUNET_SCHEDULER_NO_TASK, | 834 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
835 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 835 | NULL, &unix_plugin_select, plugin); |
836 | NULL, &unix_plugin_select, plugin); | 836 | return; |
837 | return; | 837 | } |
838 | } | 838 | msgbuf = (char *) &msg[1]; |
839 | msgbuf = (char *)&msg[1]; | ||
840 | memcpy (&sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity)); | 839 | memcpy (&sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity)); |
841 | offset = 0; | 840 | offset = 0; |
842 | tsize = csize - sizeof (struct UNIXMessage); | 841 | tsize = csize - sizeof (struct UNIXMessage); |
843 | while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize) | 842 | while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize) |
843 | { | ||
844 | currhdr = (struct GNUNET_MessageHeader *) &msgbuf[offset]; | ||
845 | csize = ntohs (currhdr->size); | ||
846 | if ((csize < sizeof (struct GNUNET_MessageHeader)) || | ||
847 | (csize > tsize - offset)) | ||
844 | { | 848 | { |
845 | currhdr = (struct GNUNET_MessageHeader *)&msgbuf[offset]; | 849 | GNUNET_break_op (0); |
846 | csize = ntohs (currhdr->size); | 850 | break; |
847 | if ( (csize < sizeof (struct GNUNET_MessageHeader)) || | ||
848 | (csize > tsize - offset) ) | ||
849 | { | ||
850 | GNUNET_break_op (0); | ||
851 | break; | ||
852 | } | ||
853 | unix_demultiplexer(plugin, &sender, currhdr, | ||
854 | &un, sizeof(un)); | ||
855 | offset += csize; | ||
856 | } | 851 | } |
852 | unix_demultiplexer (plugin, &sender, currhdr, &un, sizeof (un)); | ||
853 | offset += csize; | ||
854 | } | ||
857 | plugin->select_task = | 855 | plugin->select_task = |
858 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 856 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
859 | GNUNET_SCHEDULER_NO_TASK, | 857 | GNUNET_SCHEDULER_NO_TASK, |
860 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 858 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
861 | NULL, &unix_plugin_select, plugin); | 859 | NULL, &unix_plugin_select, plugin); |
862 | } | 860 | } |
863 | 861 | ||
864 | /** | 862 | /** |
@@ -876,7 +874,7 @@ unix_transport_server_start (void *cls) | |||
876 | struct sockaddr_un un; | 874 | struct sockaddr_un un; |
877 | size_t slen; | 875 | size_t slen; |
878 | 876 | ||
879 | memset(&un, 0, sizeof(un)); | 877 | memset (&un, 0, sizeof (un)); |
880 | un.sun_family = AF_UNIX; | 878 | un.sun_family = AF_UNIX; |
881 | slen = strlen (plugin->unix_socket_path) + 1; | 879 | slen = strlen (plugin->unix_socket_path) + 1; |
882 | if (slen >= sizeof (un.sun_path)) | 880 | if (slen >= sizeof (un.sun_path)) |
@@ -889,42 +887,40 @@ unix_transport_server_start (void *cls) | |||
889 | un.sun_len = (u_char) slen; | 887 | un.sun_len = (u_char) slen; |
890 | #endif | 888 | #endif |
891 | 889 | ||
892 | serverAddr = (struct sockaddr*) &un; | 890 | serverAddr = (struct sockaddr *) &un; |
893 | addrlen = slen; | 891 | addrlen = slen; |
894 | #if LINUX | 892 | #if LINUX |
895 | un.sun_path[0] = '\0'; | 893 | un.sun_path[0] = '\0'; |
896 | #endif | 894 | #endif |
897 | 895 | ||
898 | plugin->unix_sock.desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0); | 896 | plugin->unix_sock.desc = |
897 | GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0); | ||
899 | if (NULL == plugin->unix_sock.desc) | 898 | if (NULL == plugin->unix_sock.desc) |
900 | { | 899 | { |
901 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 900 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
902 | return GNUNET_SYSERR; | 901 | return GNUNET_SYSERR; |
903 | } | 902 | } |
904 | if (GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc, serverAddr, addrlen) != | 903 | if (GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc, serverAddr, addrlen) |
905 | GNUNET_OK) | 904 | != GNUNET_OK) |
906 | { | 905 | { |
907 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); | 906 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); |
908 | GNUNET_NETWORK_socket_close (plugin->unix_sock.desc); | 907 | GNUNET_NETWORK_socket_close (plugin->unix_sock.desc); |
909 | plugin->unix_sock.desc = NULL; | 908 | plugin->unix_sock.desc = NULL; |
910 | return GNUNET_SYSERR; | 909 | return GNUNET_SYSERR; |
911 | } | 910 | } |
912 | #if DEBUG_UNIX | 911 | #if DEBUG_UNIX |
913 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 912 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
914 | "unix", | 913 | "unix", "Bound to `%s'\n", &un.sun_path[0]); |
915 | "Bound to `%s'\n", | ||
916 | &un.sun_path[0]); | ||
917 | #endif | 914 | #endif |
918 | plugin->rs = GNUNET_NETWORK_fdset_create (); | 915 | plugin->rs = GNUNET_NETWORK_fdset_create (); |
919 | GNUNET_NETWORK_fdset_zero (plugin->rs); | 916 | GNUNET_NETWORK_fdset_zero (plugin->rs); |
920 | GNUNET_NETWORK_fdset_set (plugin->rs, | 917 | GNUNET_NETWORK_fdset_set (plugin->rs, plugin->unix_sock.desc); |
921 | plugin->unix_sock.desc); | ||
922 | 918 | ||
923 | plugin->select_task = | 919 | plugin->select_task = |
924 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 920 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
925 | GNUNET_SCHEDULER_NO_TASK, | 921 | GNUNET_SCHEDULER_NO_TASK, |
926 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, | 922 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, |
927 | NULL, &unix_plugin_select, plugin); | 923 | NULL, &unix_plugin_select, plugin); |
928 | return 1; | 924 | return 1; |
929 | } | 925 | } |
930 | 926 | ||
@@ -946,15 +942,13 @@ unix_transport_server_start (void *cls) | |||
946 | * | 942 | * |
947 | */ | 943 | */ |
948 | static int | 944 | static int |
949 | unix_check_address (void *cls, | 945 | unix_check_address (void *cls, const void *addr, size_t addrlen) |
950 | const void *addr, | ||
951 | size_t addrlen) | ||
952 | { | 946 | { |
953 | 947 | ||
954 | #if DEBUG_UNIX | 948 | #if DEBUG_UNIX |
955 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 949 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
956 | "Informing transport service about my address `%s'\n", | 950 | "Informing transport service about my address `%s'\n", |
957 | (char *)addr); | 951 | (char *) addr); |
958 | #endif | 952 | #endif |
959 | return GNUNET_OK; | 953 | return GNUNET_OK; |
960 | } | 954 | } |
@@ -970,11 +964,11 @@ append_port (void *cls, const char *hostname) | |||
970 | char *ret; | 964 | char *ret; |
971 | 965 | ||
972 | if (hostname == NULL) | 966 | if (hostname == NULL) |
973 | { | 967 | { |
974 | ppc->asc (ppc->asc_cls, NULL); | 968 | ppc->asc (ppc->asc_cls, NULL); |
975 | GNUNET_free (ppc); | 969 | GNUNET_free (ppc); |
976 | return; | 970 | return; |
977 | } | 971 | } |
978 | GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); | 972 | GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); |
979 | ppc->asc (ppc->asc_cls, ret); | 973 | ppc->asc (ppc->asc_cls, ret); |
980 | GNUNET_free (ret); | 974 | GNUNET_free (ret); |
@@ -997,13 +991,13 @@ append_port (void *cls, const char *hostname) | |||
997 | */ | 991 | */ |
998 | static void | 992 | static void |
999 | unix_plugin_address_pretty_printer (void *cls, | 993 | unix_plugin_address_pretty_printer (void *cls, |
1000 | const char *type, | 994 | const char *type, |
1001 | const void *addr, | 995 | const void *addr, |
1002 | size_t addrlen, | 996 | size_t addrlen, |
1003 | int numeric, | 997 | int numeric, |
1004 | struct GNUNET_TIME_Relative timeout, | 998 | struct GNUNET_TIME_Relative timeout, |
1005 | GNUNET_TRANSPORT_AddressStringCallback asc, | 999 | GNUNET_TRANSPORT_AddressStringCallback asc, |
1006 | void *asc_cls) | 1000 | void *asc_cls) |
1007 | { | 1001 | { |
1008 | struct PrettyPrinterContext *ppc; | 1002 | struct PrettyPrinterContext *ppc; |
1009 | const void *sb; | 1003 | const void *sb; |
@@ -1015,43 +1009,39 @@ unix_plugin_address_pretty_printer (void *cls, | |||
1015 | uint16_t port; | 1009 | uint16_t port; |
1016 | 1010 | ||
1017 | if (addrlen == sizeof (struct IPv6UdpAddress)) | 1011 | if (addrlen == sizeof (struct IPv6UdpAddress)) |
1018 | { | 1012 | { |
1019 | u6 = addr; | 1013 | u6 = addr; |
1020 | memset (&a6, 0, sizeof (a6)); | 1014 | memset (&a6, 0, sizeof (a6)); |
1021 | a6.sin6_family = AF_INET6; | 1015 | a6.sin6_family = AF_INET6; |
1022 | a6.sin6_port = u6->u6_port; | 1016 | a6.sin6_port = u6->u6_port; |
1023 | memcpy (&a6.sin6_addr, | 1017 | memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof (struct in6_addr)); |
1024 | &u6->ipv6_addr, | 1018 | port = ntohs (u6->u6_port); |
1025 | sizeof (struct in6_addr)); | 1019 | sb = &a6; |
1026 | port = ntohs (u6->u6_port); | 1020 | sbs = sizeof (a6); |
1027 | sb = &a6; | 1021 | } |
1028 | sbs = sizeof (a6); | ||
1029 | } | ||
1030 | else if (addrlen == sizeof (struct IPv4UdpAddress)) | 1022 | else if (addrlen == sizeof (struct IPv4UdpAddress)) |
1031 | { | 1023 | { |
1032 | u4 = addr; | 1024 | u4 = addr; |
1033 | memset (&a4, 0, sizeof (a4)); | 1025 | memset (&a4, 0, sizeof (a4)); |
1034 | a4.sin_family = AF_INET; | 1026 | a4.sin_family = AF_INET; |
1035 | a4.sin_port = u4->u_port; | 1027 | a4.sin_port = u4->u_port; |
1036 | a4.sin_addr.s_addr = u4->ipv4_addr; | 1028 | a4.sin_addr.s_addr = u4->ipv4_addr; |
1037 | port = ntohs (u4->u_port); | 1029 | port = ntohs (u4->u_port); |
1038 | sb = &a4; | 1030 | sb = &a4; |
1039 | sbs = sizeof (a4); | 1031 | sbs = sizeof (a4); |
1040 | } | 1032 | } |
1041 | else | 1033 | else |
1042 | { | 1034 | { |
1043 | /* invalid address */ | 1035 | /* invalid address */ |
1044 | GNUNET_break_op (0); | 1036 | GNUNET_break_op (0); |
1045 | asc (asc_cls, NULL); | 1037 | asc (asc_cls, NULL); |
1046 | return; | 1038 | return; |
1047 | } | 1039 | } |
1048 | ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext)); | 1040 | ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext)); |
1049 | ppc->asc = asc; | 1041 | ppc->asc = asc; |
1050 | ppc->asc_cls = asc_cls; | 1042 | ppc->asc_cls = asc_cls; |
1051 | ppc->port = port; | 1043 | ppc->port = port; |
1052 | GNUNET_RESOLVER_hostname_get (sb, | 1044 | GNUNET_RESOLVER_hostname_get (sb, sbs, !numeric, timeout, &append_port, ppc); |
1053 | sbs, | ||
1054 | !numeric, timeout, &append_port, ppc); | ||
1055 | } | 1045 | } |
1056 | 1046 | ||
1057 | /** | 1047 | /** |
@@ -1065,10 +1055,8 @@ unix_plugin_address_pretty_printer (void *cls, | |||
1065 | * @param addrlen length of the address | 1055 | * @param addrlen length of the address |
1066 | * @return string representing the same address | 1056 | * @return string representing the same address |
1067 | */ | 1057 | */ |
1068 | static const char* | 1058 | static const char * |
1069 | unix_address_to_string (void *cls, | 1059 | unix_address_to_string (void *cls, const void *addr, size_t addrlen) |
1070 | const void *addr, | ||
1071 | size_t addrlen) | ||
1072 | { | 1060 | { |
1073 | if ((addr != NULL) && (addrlen > 0)) | 1061 | if ((addr != NULL) && (addrlen > 0)) |
1074 | return (const char *) addr; | 1062 | return (const char *) addr; |
@@ -1083,14 +1071,14 @@ unix_address_to_string (void *cls, | |||
1083 | * @param tc unused | 1071 | * @param tc unused |
1084 | */ | 1072 | */ |
1085 | static void | 1073 | static void |
1086 | address_notification (void *cls, | 1074 | address_notification (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1087 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1088 | { | 1075 | { |
1089 | struct Plugin *plugin = cls; | 1076 | struct Plugin *plugin = cls; |
1090 | plugin->env->notify_address(plugin->env->cls, | 1077 | |
1091 | GNUNET_YES, | 1078 | plugin->env->notify_address (plugin->env->cls, |
1092 | plugin->unix_socket_path, | 1079 | GNUNET_YES, |
1093 | strlen(plugin->unix_socket_path) + 1); | 1080 | plugin->unix_socket_path, |
1081 | strlen (plugin->unix_socket_path) + 1); | ||
1094 | } | 1082 | } |
1095 | 1083 | ||
1096 | /** | 1084 | /** |
@@ -1108,17 +1096,14 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1108 | 1096 | ||
1109 | if (GNUNET_OK != | 1097 | if (GNUNET_OK != |
1110 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 1098 | GNUNET_CONFIGURATION_get_value_number (env->cfg, |
1111 | "transport-unix", | 1099 | "transport-unix", "PORT", &port)) |
1112 | "PORT", | ||
1113 | &port)) | ||
1114 | port = UNIX_NAT_DEFAULT_PORT; | 1100 | port = UNIX_NAT_DEFAULT_PORT; |
1115 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1101 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1116 | plugin->port = port; | 1102 | plugin->port = port; |
1117 | plugin->env = env; | 1103 | plugin->env = env; |
1118 | GNUNET_asprintf (&plugin->unix_socket_path, | 1104 | GNUNET_asprintf (&plugin->unix_socket_path, |
1119 | "/tmp/unix-plugin-sock.%d", | 1105 | "/tmp/unix-plugin-sock.%d", plugin->port); |
1120 | plugin->port); | 1106 | |
1121 | |||
1122 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 1107 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
1123 | api->cls = plugin; | 1108 | api->cls = plugin; |
1124 | 1109 | ||
@@ -1129,10 +1114,9 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1129 | api->check_address = &unix_check_address; | 1114 | api->check_address = &unix_check_address; |
1130 | sockets_created = unix_transport_server_start (plugin); | 1115 | sockets_created = unix_transport_server_start (plugin); |
1131 | if (sockets_created == 0) | 1116 | if (sockets_created == 0) |
1132 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1117 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UNIX sockets\n")); |
1133 | _("Failed to open UNIX sockets\n")); | ||
1134 | 1118 | ||
1135 | GNUNET_SCHEDULER_add_now(address_notification, plugin); | 1119 | GNUNET_SCHEDULER_add_now (address_notification, plugin); |
1136 | return api; | 1120 | return api; |
1137 | } | 1121 | } |
1138 | 1122 | ||