diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 12 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 6 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 16 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 39 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.h | 9 | ||||
-rw-r--r-- | src/transport/transport.h | 30 | ||||
-rw-r--r-- | src/transport/transport_api.c | 1 |
7 files changed, 98 insertions, 15 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 6bba8a12d..a0e811886 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -90,12 +90,16 @@ static int connections; | |||
90 | * @param ats performance information (unused) | 90 | * @param ats performance information (unused) |
91 | * @param ats_count number of records in ats (unused) | 91 | * @param ats_count number of records in ats (unused) |
92 | * @param address the address | 92 | * @param address the address |
93 | * @param bandwidth_in inbound quota in NBO | ||
94 | * @param bandwidth_out outbound quota in NBO | ||
93 | */ | 95 | */ |
94 | static void | 96 | static void |
95 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | 97 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, |
96 | const struct GNUNET_ATS_Information *ats, | 98 | const struct GNUNET_ATS_Information *ats, |
97 | uint32_t ats_count, | 99 | uint32_t ats_count, |
98 | const struct GNUNET_HELLO_Address *address) | 100 | const struct GNUNET_HELLO_Address *address, |
101 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
102 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
99 | { | 103 | { |
100 | const struct GNUNET_MessageHeader *hello = cls; | 104 | const struct GNUNET_MessageHeader *hello = cls; |
101 | 105 | ||
@@ -451,7 +455,9 @@ static void | |||
451 | neighbours_connect_notification (void *cls, | 455 | neighbours_connect_notification (void *cls, |
452 | const struct GNUNET_PeerIdentity *peer, | 456 | const struct GNUNET_PeerIdentity *peer, |
453 | const struct GNUNET_ATS_Information *ats, | 457 | const struct GNUNET_ATS_Information *ats, |
454 | uint32_t ats_count) | 458 | uint32_t ats_count, |
459 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
460 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
455 | { | 461 | { |
456 | size_t len = | 462 | size_t len = |
457 | sizeof (struct ConnectInfoMessage) + | 463 | sizeof (struct ConnectInfoMessage) + |
@@ -469,6 +475,8 @@ neighbours_connect_notification (void *cls, | |||
469 | connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 475 | connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
470 | connect_msg->ats_count = htonl (ats_count); | 476 | connect_msg->ats_count = htonl (ats_count); |
471 | connect_msg->id = *peer; | 477 | connect_msg->id = *peer; |
478 | connect_msg->quota_in = bandwidth_in; | ||
479 | connect_msg->quota_out = bandwidth_out; | ||
472 | ap = (struct GNUNET_ATS_Information *) &connect_msg[1]; | 480 | ap = (struct GNUNET_ATS_Information *) &connect_msg[1]; |
473 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | 481 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
474 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); | 482 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index c71ecdfd8..8b6e45612 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -543,12 +543,16 @@ struct TestConnectionContext | |||
543 | * @param ats performance data | 543 | * @param ats performance data |
544 | * @param ats_count number of entries in ats (excluding 0-termination) | 544 | * @param ats_count number of entries in ats (excluding 0-termination) |
545 | * @param address the address | 545 | * @param address the address |
546 | * @param bandwidth_in inbound quota in NBO | ||
547 | * @param bandwidth_out outbound quota in NBO | ||
546 | */ | 548 | */ |
547 | static void | 549 | static void |
548 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, | 550 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, |
549 | const struct GNUNET_ATS_Information *ats, | 551 | const struct GNUNET_ATS_Information *ats, |
550 | uint32_t ats_count, | 552 | uint32_t ats_count, |
551 | const struct GNUNET_HELLO_Address *address) | 553 | const struct GNUNET_HELLO_Address *address, |
554 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
555 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
552 | { | 556 | { |
553 | struct TestConnectionContext *tcc = cls; | 557 | struct TestConnectionContext *tcc = cls; |
554 | struct GST_BlacklistCheck *bc; | 558 | struct GST_BlacklistCheck *bc; |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index b2981951d..c530a9da4 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -437,7 +437,9 @@ notify_client_about_neighbour (void *cls, | |||
437 | const struct GNUNET_PeerIdentity *peer, | 437 | const struct GNUNET_PeerIdentity *peer, |
438 | const struct GNUNET_ATS_Information *ats, | 438 | const struct GNUNET_ATS_Information *ats, |
439 | uint32_t ats_count, | 439 | uint32_t ats_count, |
440 | const struct GNUNET_HELLO_Address *address) | 440 | const struct GNUNET_HELLO_Address *address, |
441 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
442 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
441 | { | 443 | { |
442 | struct TransportClient *tc = cls; | 444 | struct TransportClient *tc = cls; |
443 | struct ConnectInfoMessage *cim; | 445 | struct ConnectInfoMessage *cim; |
@@ -453,6 +455,8 @@ notify_client_about_neighbour (void *cls, | |||
453 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 455 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
454 | cim->ats_count = htonl (ats_count); | 456 | cim->ats_count = htonl (ats_count); |
455 | cim->id = *peer; | 457 | cim->id = *peer; |
458 | cim->quota_in = bandwidth_in; | ||
459 | cim->quota_out = bandwidth_out; | ||
456 | ap = (struct GNUNET_ATS_Information *) &cim[1]; | 460 | ap = (struct GNUNET_ATS_Information *) &cim[1]; |
457 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | 461 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
458 | unicast (tc, &cim->header, GNUNET_NO); | 462 | unicast (tc, &cim->header, GNUNET_NO); |
@@ -832,11 +836,15 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity | |||
832 | * @param ats performance data | 836 | * @param ats performance data |
833 | * @param ats_count number of entries in ats (excluding 0-termination) | 837 | * @param ats_count number of entries in ats (excluding 0-termination) |
834 | * @param address the address | 838 | * @param address the address |
839 | * @param bandwidth_in inbound quota in NBO | ||
840 | * @param bandwidth_out outbound quota in NBO | ||
835 | */ | 841 | */ |
836 | static void | 842 | static void |
837 | output_address (void *cls, const struct GNUNET_PeerIdentity *peer, | 843 | output_address (void *cls, const struct GNUNET_PeerIdentity *peer, |
838 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, | 844 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, |
839 | const struct GNUNET_HELLO_Address *address) | 845 | const struct GNUNET_HELLO_Address *address, |
846 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
847 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
840 | { | 848 | { |
841 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 849 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
842 | struct AddressIterateResponseMessage *msg; | 850 | struct AddressIterateResponseMessage *msg; |
@@ -900,7 +908,9 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, | |||
900 | /* just return one neighbour */ | 908 | /* just return one neighbour */ |
901 | address = GST_neighbour_get_current_address (&msg->peer); | 909 | address = GST_neighbour_get_current_address (&msg->peer); |
902 | if (address != NULL) | 910 | if (address != NULL) |
903 | output_address (tc, &msg->peer, NULL, 0, address); | 911 | output_address (tc, &msg->peer, NULL, 0, address, |
912 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | ||
913 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT); | ||
904 | } | 914 | } |
905 | if (GNUNET_YES != ntohl (msg->one_shot)) | 915 | if (GNUNET_YES != ntohl (msg->one_shot)) |
906 | setup_monitoring_client (client, &msg->peer); | 916 | setup_monitoring_client (client, &msg->peer); |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index cd60ad956..ce407a382 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -595,7 +595,7 @@ static void *callback_cls; | |||
595 | /** | 595 | /** |
596 | * Function to call when we connected to a neighbour. | 596 | * Function to call when we connected to a neighbour. |
597 | */ | 597 | */ |
598 | static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb; | 598 | static NotifyConnect connect_notify_cb; |
599 | 599 | ||
600 | /** | 600 | /** |
601 | * Function to call when we disconnected from a neighbour. | 601 | * Function to call when we disconnected from a neighbour. |
@@ -2170,11 +2170,14 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2173 | "ATS tells us to switch to address '%s' session %p for peer `%s' in state %s\n", | 2173 | "ATS tells us to switch to address '%s' session %p for " |
2174 | "peer `%s' in state %s (quota in/out %u %u )\n", | ||
2174 | (address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>", | 2175 | (address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>", |
2175 | session, | 2176 | session, |
2176 | GNUNET_i2s (peer), | 2177 | GNUNET_i2s (peer), |
2177 | print_state (n->state)); | 2178 | print_state (n->state), |
2179 | ntohl (bandwidth_in.value__), | ||
2180 | ntohl (bandwidth_out.value__)); | ||
2178 | 2181 | ||
2179 | if (NULL == session) | 2182 | if (NULL == session) |
2180 | { | 2183 | { |
@@ -2634,7 +2637,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2634 | gettext_noop ("# peers connected"), | 2637 | gettext_noop ("# peers connected"), |
2635 | ++neighbours_connected, | 2638 | ++neighbours_connected, |
2636 | GNUNET_NO); | 2639 | GNUNET_NO); |
2637 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2640 | connect_notify_cb (callback_cls, &n->id, ats, ats_count, |
2641 | n->primary_address.bandwidth_in, | ||
2642 | n->primary_address.bandwidth_out); | ||
2638 | /* Tell ATS that the outbound session we created to send CONNECT was successfull */ | 2643 | /* Tell ATS that the outbound session we created to send CONNECT was successfull */ |
2639 | GNUNET_ATS_address_add (GST_ats, | 2644 | GNUNET_ATS_address_add (GST_ats, |
2640 | n->primary_address.address, | 2645 | n->primary_address.address, |
@@ -2894,7 +2899,9 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
2894 | gettext_noop ("# peers connected"), | 2899 | gettext_noop ("# peers connected"), |
2895 | ++neighbours_connected, | 2900 | ++neighbours_connected, |
2896 | GNUNET_NO); | 2901 | GNUNET_NO); |
2897 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2902 | connect_notify_cb (callback_cls, &n->id, ats, ats_count, |
2903 | n->primary_address.bandwidth_in, | ||
2904 | n->primary_address.bandwidth_out); | ||
2898 | GNUNET_ATS_address_add(GST_ats, | 2905 | GNUNET_ATS_address_add(GST_ats, |
2899 | n->primary_address.address, | 2906 | n->primary_address.address, |
2900 | n->primary_address.session, | 2907 | n->primary_address.session, |
@@ -3062,7 +3069,25 @@ neighbours_iterate (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
3062 | struct NeighbourMapEntry *n = value; | 3069 | struct NeighbourMapEntry *n = value; |
3063 | 3070 | ||
3064 | if (GNUNET_YES == test_connected (n)) | 3071 | if (GNUNET_YES == test_connected (n)) |
3065 | ic->cb (ic->cb_cls, &n->id, NULL, 0, n->primary_address.address); | 3072 | { |
3073 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; | ||
3074 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; | ||
3075 | |||
3076 | if (NULL != n->primary_address.address) | ||
3077 | { | ||
3078 | bandwidth_in = n->primary_address.bandwidth_in; | ||
3079 | bandwidth_out = n->primary_address.bandwidth_out; | ||
3080 | } | ||
3081 | else | ||
3082 | { | ||
3083 | bandwidth_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; | ||
3084 | bandwidth_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; | ||
3085 | } | ||
3086 | |||
3087 | ic->cb (ic->cb_cls, &n->id, NULL, 0, | ||
3088 | n->primary_address.address, | ||
3089 | bandwidth_in, bandwidth_out); | ||
3090 | } | ||
3066 | return GNUNET_OK; | 3091 | return GNUNET_OK; |
3067 | } | 3092 | } |
3068 | 3093 | ||
@@ -3180,7 +3205,7 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer) | |||
3180 | */ | 3205 | */ |
3181 | void | 3206 | void |
3182 | GST_neighbours_start (void *cls, | 3207 | GST_neighbours_start (void *cls, |
3183 | GNUNET_TRANSPORT_NotifyConnect connect_cb, | 3208 | NotifyConnect connect_cb, |
3184 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, | 3209 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, |
3185 | GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb) | 3210 | GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb) |
3186 | { | 3211 | { |
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 18afcafc5..d137c311d 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_transport_plugin.h" | 31 | #include "gnunet_transport_plugin.h" |
32 | #include "transport.h" | ||
32 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
33 | 34 | ||
34 | // TODO: | 35 | // TODO: |
@@ -46,7 +47,7 @@ | |||
46 | */ | 47 | */ |
47 | void | 48 | void |
48 | GST_neighbours_start (void *cls, | 49 | GST_neighbours_start (void *cls, |
49 | GNUNET_TRANSPORT_NotifyConnect connect_cb, | 50 | NotifyConnect connect_cb, |
50 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, | 51 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, |
51 | GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb); | 52 | GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb); |
52 | 53 | ||
@@ -170,6 +171,8 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); | |||
170 | * @param ats performance data | 171 | * @param ats performance data |
171 | * @param ats_count number of entries in ats (including 0-termination) | 172 | * @param ats_count number of entries in ats (including 0-termination) |
172 | * @param address the address (or NULL) | 173 | * @param address the address (or NULL) |
174 | * @param bandwidth_in inbound quota in NBO | ||
175 | * @param bandwidth_out outbound quota in NBO | ||
173 | */ | 176 | */ |
174 | typedef void (*GST_NeighbourIterator) (void *cls, | 177 | typedef void (*GST_NeighbourIterator) (void *cls, |
175 | const struct GNUNET_PeerIdentity * | 178 | const struct GNUNET_PeerIdentity * |
@@ -177,7 +180,9 @@ typedef void (*GST_NeighbourIterator) (void *cls, | |||
177 | const struct GNUNET_ATS_Information * | 180 | const struct GNUNET_ATS_Information * |
178 | ats, uint32_t ats_count, | 181 | ats, uint32_t ats_count, |
179 | const struct GNUNET_HELLO_Address * | 182 | const struct GNUNET_HELLO_Address * |
180 | address); | 183 | address, |
184 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
185 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); | ||
181 | 186 | ||
182 | 187 | ||
183 | /** | 188 | /** |
diff --git a/src/transport/transport.h b/src/transport/transport.h index e0b881970..3cca8e268 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -56,6 +56,26 @@ | |||
56 | */ | 56 | */ |
57 | #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) | 57 | #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
58 | 58 | ||
59 | /** | ||
60 | * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are | ||
61 | * included here. These values are not required outside transport_api | ||
62 | * | ||
63 | * @param cls closure | ||
64 | * @param peer the peer that connected | ||
65 | * @param ats performance data | ||
66 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
67 | * @param bandwidth_in inbound bandwidth in NBO | ||
68 | * @param bandwidth_out outbound bandwidth in NBO | ||
69 | * | ||
70 | */ | ||
71 | |||
72 | typedef void (*NotifyConnect) (void *cls, | ||
73 | const struct GNUNET_PeerIdentity *peer, | ||
74 | const struct GNUNET_ATS_Information *ats, | ||
75 | uint32_t ats_count, | ||
76 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
77 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); | ||
78 | |||
59 | GNUNET_NETWORK_STRUCT_BEGIN | 79 | GNUNET_NETWORK_STRUCT_BEGIN |
60 | 80 | ||
61 | /** | 81 | /** |
@@ -109,6 +129,16 @@ struct ConnectInfoMessage | |||
109 | * Identity of the new neighbour. | 129 | * Identity of the new neighbour. |
110 | */ | 130 | */ |
111 | struct GNUNET_PeerIdentity id; | 131 | struct GNUNET_PeerIdentity id; |
132 | |||
133 | /** | ||
134 | * Current inbound quota for this peer | ||
135 | */ | ||
136 | struct GNUNET_BANDWIDTH_Value32NBO quota_in; | ||
137 | |||
138 | /** | ||
139 | * Current outbound quota for this peer | ||
140 | */ | ||
141 | struct GNUNET_BANDWIDTH_Value32NBO quota_out; | ||
112 | }; | 142 | }; |
113 | 143 | ||
114 | 144 | ||
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 3a1068cd1..ddad8f196 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -477,6 +477,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
477 | break; | 477 | break; |
478 | } | 478 | } |
479 | n = neighbour_add (h, &cim->id); | 479 | n = neighbour_add (h, &cim->id); |
480 | GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, cim->quota_out); | ||
480 | if (h->nc_cb != NULL) | 481 | if (h->nc_cb != NULL) |
481 | h->nc_cb (h->cls, &n->id, ats, ats_count); | 482 | h->nc_cb (h->cls, &n->id, ats, ats_count); |
482 | break; | 483 | break; |