diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-14 14:59:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-14 14:59:21 +0000 |
commit | dd0cb0a52289df80d378f2c518e5036c64aef7a0 (patch) | |
tree | a576743e30aa3a04075bacb07dd108c13c9982ea /src | |
parent | b8fae42695546f532ed66fa75d525d1f65a90338 (diff) | |
download | gnunet-dd0cb0a52289df80d378f2c518e5036c64aef7a0.tar.gz gnunet-dd0cb0a52289df80d378f2c518e5036c64aef7a0.zip |
stuff
Diffstat (limited to 'src')
6 files changed, 38 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c index e8369b661..4536d2573 100644 --- a/src/transport/gnunet-service-transport-new.c +++ b/src/transport/gnunet-service-transport-new.c | |||
@@ -150,9 +150,18 @@ plugin_env_receive_callback (void *cls, | |||
150 | uint16_t sender_address_len) | 150 | uint16_t sender_address_len) |
151 | { | 151 | { |
152 | const char *plugin_name = cls; | 152 | const char *plugin_name = cls; |
153 | 153 | int do_forward; | |
154 | 154 | struct GNUNET_TIME_Relative ret; | |
155 | if (NULL != message) | 155 | |
156 | do_forward = GNUNET_SYSERR; | ||
157 | ret = GST_neighbours_calculate_receive_delay (peer, | ||
158 | (message == NULL) | ||
159 | ? 0 | ||
160 | : ntohs (message->size), | ||
161 | &do_forward); | ||
162 | /* FIXME: look at the type of the message (PING, PONG, CONNECT, payload...) */ | ||
163 | if ( (NULL != message) && | ||
164 | (do_forward == GNUNET_YES) ) | ||
156 | GST_clients_broadcast (message, GNUNET_YES); | 165 | GST_clients_broadcast (message, GNUNET_YES); |
157 | GNUNET_ATS_address_update (GST_ats, | 166 | GNUNET_ATS_address_update (GST_ats, |
158 | peer, | 167 | peer, |
@@ -162,10 +171,7 @@ plugin_env_receive_callback (void *cls, | |||
162 | sender_address, | 171 | sender_address, |
163 | sender_address_len, | 172 | sender_address_len, |
164 | ats, ats_count); | 173 | ats, ats_count); |
165 | return GST_neighbours_calculate_receive_delay (peer, | 174 | return ret; |
166 | (message == NULL) | ||
167 | ? 0 | ||
168 | : ntohs (message->size)); | ||
169 | } | 175 | } |
170 | 176 | ||
171 | 177 | ||
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 83d8e44ec..4738cdc0f 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -768,7 +768,8 @@ test_blacklisted (void *cls, | |||
768 | * @param transport_name name of the transport to test, never NULL | 768 | * @param transport_name name of the transport to test, never NULL |
769 | * @param cont function to call with result | 769 | * @param cont function to call with result |
770 | * @param cont_cls closure for 'cont' | 770 | * @param cont_cls closure for 'cont' |
771 | * @return handle to the blacklist check | 771 | * @return handle to the blacklist check, NULL if the decision |
772 | * was made instantly and 'cont' was already called | ||
772 | */ | 773 | */ |
773 | struct GST_BlacklistCheck * | 774 | struct GST_BlacklistCheck * |
774 | GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | 775 | GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, |
diff --git a/src/transport/gnunet-service-transport_blacklist.h b/src/transport/gnunet-service-transport_blacklist.h index 6721b6aa2..26309818d 100644 --- a/src/transport/gnunet-service-transport_blacklist.h +++ b/src/transport/gnunet-service-transport_blacklist.h | |||
@@ -108,7 +108,8 @@ typedef void (*GST_BlacklistTestContinuation)(void *cls, | |||
108 | * @param transport_name name of the transport to test, never NULL | 108 | * @param transport_name name of the transport to test, never NULL |
109 | * @param cont function to call with result | 109 | * @param cont function to call with result |
110 | * @param cont_cls closure for 'cont' | 110 | * @param cont_cls closure for 'cont' |
111 | * @return handle to the blacklist check | 111 | * @return handle to the blacklist check, NULL if the decision |
112 | * was made instantly and 'cont' was already called | ||
112 | */ | 113 | */ |
113 | struct GST_BlacklistCheck * | 114 | struct GST_BlacklistCheck * |
114 | GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | 115 | GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 9ae9712a9..c310afc22 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -756,18 +756,24 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, | |||
756 | * | 756 | * |
757 | * @param sender sender of the message | 757 | * @param sender sender of the message |
758 | * @param size size of the message | 758 | * @param size size of the message |
759 | * @param do_forward set to GNUNET_YES if the message should be forwarded to clients | ||
760 | * GNUNET_NO if the neighbour is not connected or violates the quota | ||
759 | * @return how long to wait before reading more from this sender | 761 | * @return how long to wait before reading more from this sender |
760 | */ | 762 | */ |
761 | struct GNUNET_TIME_Relative | 763 | struct GNUNET_TIME_Relative |
762 | GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, | 764 | GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, |
763 | ssize_t size) | 765 | ssize_t size, |
766 | int *do_forward) | ||
764 | { | 767 | { |
765 | struct NeighbourMapEntry *n; | 768 | struct NeighbourMapEntry *n; |
766 | struct GNUNET_TIME_Relative ret; | 769 | struct GNUNET_TIME_Relative ret; |
767 | 770 | ||
768 | n = lookup_neighbour (sender); | 771 | n = lookup_neighbour (sender); |
769 | if (n == NULL) | 772 | if (n == NULL) |
770 | return GNUNET_TIME_UNIT_ZERO; | 773 | { |
774 | *do_forward = GNUNET_NO; | ||
775 | return GNUNET_TIME_UNIT_ZERO; | ||
776 | } | ||
771 | if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, | 777 | if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, |
772 | size)) | 778 | size)) |
773 | { | 779 | { |
@@ -802,8 +808,10 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender | |||
802 | gettext_noop ("# bandwidth quota violations by other peers"), | 808 | gettext_noop ("# bandwidth quota violations by other peers"), |
803 | 1, | 809 | 1, |
804 | GNUNET_NO); | 810 | GNUNET_NO); |
811 | *do_forward = GNUNET_NO; | ||
805 | return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT; | 812 | return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT; |
806 | } | 813 | } |
814 | *do_forward = GNUNET_YES; | ||
807 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); | 815 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); |
808 | if (ret.rel_value > 0) | 816 | if (ret.rel_value > 0) |
809 | { | 817 | { |
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index d9b2fd6b4..14f223811 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -111,11 +111,14 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, | |||
111 | * | 111 | * |
112 | * @param sender sender of the message | 112 | * @param sender sender of the message |
113 | * @param size size of the message | 113 | * @param size size of the message |
114 | * @param do_forward set to GNUNET_YES if the message should be forwarded to clients | ||
115 | * GNUNET_NO if the neighbour is not connected or violates the quota | ||
114 | * @return how long to wait before reading more from this sender | 116 | * @return how long to wait before reading more from this sender |
115 | */ | 117 | */ |
116 | struct GNUNET_TIME_Relative | 118 | struct GNUNET_TIME_Relative |
117 | GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, | 119 | GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, |
118 | ssize_t size); | 120 | ssize_t size, |
121 | int *do_forward); | ||
119 | 122 | ||
120 | 123 | ||
121 | /** | 124 | /** |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 4f5a7fdc2..aabb28068 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -886,6 +886,7 @@ validate_address (void *cls, | |||
886 | const struct ValidateAddressContext *vac = cls; | 886 | const struct ValidateAddressContext *vac = cls; |
887 | const struct GNUNET_PeerIdentity *pid = &vac->pid; | 887 | const struct GNUNET_PeerIdentity *pid = &vac->pid; |
888 | struct ValidationEntry *ve; | 888 | struct ValidationEntry *ve; |
889 | struct GST_BlacklistCheck *bc; | ||
889 | 890 | ||
890 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) | 891 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) |
891 | return GNUNET_OK; /* expired */ | 892 | return GNUNET_OK; /* expired */ |
@@ -901,10 +902,12 @@ validate_address (void *cls, | |||
901 | ve->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_REVALIDATION_START_TIME, | 902 | ve->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_REVALIDATION_START_TIME, |
902 | &timeout_hello_validation, | 903 | &timeout_hello_validation, |
903 | ve); | 904 | ve); |
904 | ve->bc = GST_blacklist_test_allowed (pid, | 905 | bc = GST_blacklist_test_allowed (pid, |
905 | tname, | 906 | tname, |
906 | &transmit_ping_if_allowed, | 907 | &transmit_ping_if_allowed, |
907 | ve); | 908 | ve); |
909 | if (NULL != bc) | ||
910 | ve->bc = bc; | ||
908 | return GNUNET_OK; | 911 | return GNUNET_OK; |
909 | } | 912 | } |
910 | 913 | ||