aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-14 14:59:21 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-14 14:59:21 +0000
commitdd0cb0a52289df80d378f2c518e5036c64aef7a0 (patch)
treea576743e30aa3a04075bacb07dd108c13c9982ea /src
parentb8fae42695546f532ed66fa75d525d1f65a90338 (diff)
downloadgnunet-dd0cb0a52289df80d378f2c518e5036c64aef7a0.tar.gz
gnunet-dd0cb0a52289df80d378f2c518e5036c64aef7a0.zip
stuff
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport-new.c20
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c3
-rw-r--r--src/transport/gnunet-service-transport_blacklist.h3
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c12
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h5
-rw-r--r--src/transport/gnunet-service-transport_validation.c11
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 */
773struct GST_BlacklistCheck * 774struct GST_BlacklistCheck *
774GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, 775GST_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 */
113struct GST_BlacklistCheck * 114struct GST_BlacklistCheck *
114GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, 115GST_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 */
761struct GNUNET_TIME_Relative 763struct GNUNET_TIME_Relative
762GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, 764GST_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 */
116struct GNUNET_TIME_Relative 118struct GNUNET_TIME_Relative
117GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, 119GST_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