aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index aab4f71e5..2614c8551 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -516,6 +516,41 @@ print_ack_state (enum GST_ACK_State s)
516 516
517 517
518/** 518/**
519 * Send information about a new outbound quota to our clients.
520 * Note that the outbound quota is enforced client-side (i.e.
521 * in libgnunettransport).
522 *
523 * @param n affected peer
524 */
525static void
526send_outbound_quota_to_clients (struct NeighbourMapEntry *n)
527{
528 struct QuotaSetMessage q_msg;
529 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
530
531 if (! GNUNET_TRANSPORT_is_connected (n->state))
532 return;
533#if IGNORE_INBOUND_QUOTA
534 bandwidth_min = n->primary_address.bandwidth_out;
535#else
536 bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out,
537 n->neighbour_receive_quota);
538#endif
539
540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
541 "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
542 ntohl (bandwidth_min.value__),
543 GNUNET_i2s (&n->id));
544 q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
545 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
546 q_msg.quota = bandwidth_min;
547 q_msg.peer = n->id;
548 GST_clients_broadcast (&q_msg.header,
549 GNUNET_NO);
550}
551
552
553/**
519 * Notify our clients that another peer connected to us. 554 * Notify our clients that another peer connected to us.
520 * 555 *
521 * @param n the peer that connected 556 * @param n the peer that connected
@@ -628,40 +663,6 @@ test_connected (struct NeighbourMapEntry *n)
628 663
629 664
630/** 665/**
631 * Send information about a new outbound quota to our clients.
632 * Note that the outbound quota is enforced client-side (i.e.
633 * in libgnunettransport).
634 *
635 * @param n affected peer
636 */
637static void
638send_outbound_quota_to_clients (struct NeighbourMapEntry *n)
639{
640 struct QuotaSetMessage q_msg;
641 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
642
643 if (! GNUNET_TRANSPORT_is_connected (n->state))
644 return;
645#if IGNORE_INBOUND_QUOTA
646 bandwidth_min = n->primary_address.bandwidth_out;
647#else
648 bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out,
649 n->neighbour_receive_quota);
650#endif
651
652 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
653 "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
654 ntohl (bandwidth_min.value__),
655 GNUNET_i2s (&n->id));
656 q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
657 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
658 q_msg.quota = bandwidth_min;
659 q_msg.peer = n->id;
660 GST_clients_broadcast (&q_msg.header, GNUNET_NO);
661}
662
663
664/**
665 * We don't need a given neighbour address any more. 666 * We don't need a given neighbour address any more.
666 * Release its resources and give appropriate notifications 667 * Release its resources and give appropriate notifications
667 * to ATS and other subsystems. 668 * to ATS and other subsystems.