uint16_t sender_address_len)
{
const char *plugin_name = cls;
-
-
- if (NULL != message)
+ int do_forward;
+ struct GNUNET_TIME_Relative ret;
+
+ do_forward = GNUNET_SYSERR;
+ ret = GST_neighbours_calculate_receive_delay (peer,
+ (message == NULL)
+ ? 0
+ : ntohs (message->size),
+ &do_forward);
+ /* FIXME: look at the type of the message (PING, PONG, CONNECT, payload...) */
+ if ( (NULL != message) &&
+ (do_forward == GNUNET_YES) )
GST_clients_broadcast (message, GNUNET_YES);
GNUNET_ATS_address_update (GST_ats,
peer,
sender_address,
sender_address_len,
ats, ats_count);
- return GST_neighbours_calculate_receive_delay (peer,
- (message == NULL)
- ? 0
- : ntohs (message->size));
+ return ret;
}
* @param transport_name name of the transport to test, never NULL
* @param cont function to call with result
* @param cont_cls closure for 'cont'
- * @return handle to the blacklist check
+ * @return handle to the blacklist check, NULL if the decision
+ * was made instantly and 'cont' was already called
*/
struct GST_BlacklistCheck *
GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
* @param transport_name name of the transport to test, never NULL
* @param cont function to call with result
* @param cont_cls closure for 'cont'
- * @return handle to the blacklist check
+ * @return handle to the blacklist check, NULL if the decision
+ * was made instantly and 'cont' was already called
*/
struct GST_BlacklistCheck *
GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
*
* @param sender sender of the message
* @param size size of the message
+ * @param do_forward set to GNUNET_YES if the message should be forwarded to clients
+ * GNUNET_NO if the neighbour is not connected or violates the quota
* @return how long to wait before reading more from this sender
*/
struct GNUNET_TIME_Relative
GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender,
- ssize_t size)
+ ssize_t size,
+ int *do_forward)
{
struct NeighbourMapEntry *n;
struct GNUNET_TIME_Relative ret;
n = lookup_neighbour (sender);
if (n == NULL)
- return GNUNET_TIME_UNIT_ZERO;
+ {
+ *do_forward = GNUNET_NO;
+ return GNUNET_TIME_UNIT_ZERO;
+ }
if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
size))
{
gettext_noop ("# bandwidth quota violations by other peers"),
1,
GNUNET_NO);
+ *do_forward = GNUNET_NO;
return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT;
}
+ *do_forward = GNUNET_YES;
ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
if (ret.rel_value > 0)
{
*
* @param sender sender of the message
* @param size size of the message
+ * @param do_forward set to GNUNET_YES if the message should be forwarded to clients
+ * GNUNET_NO if the neighbour is not connected or violates the quota
* @return how long to wait before reading more from this sender
*/
struct GNUNET_TIME_Relative
GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender,
- ssize_t size);
+ ssize_t size,
+ int *do_forward);
/**
const struct ValidateAddressContext *vac = cls;
const struct GNUNET_PeerIdentity *pid = &vac->pid;
struct ValidationEntry *ve;
+ struct GST_BlacklistCheck *bc;
if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
return GNUNET_OK; /* expired */
ve->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_REVALIDATION_START_TIME,
&timeout_hello_validation,
ve);
- ve->bc = GST_blacklist_test_allowed (pid,
- tname,
- &transmit_ping_if_allowed,
- ve);
+ bc = GST_blacklist_test_allowed (pid,
+ tname,
+ &transmit_ping_if_allowed,
+ ve);
+ if (NULL != bc)
+ ve->bc = bc;
return GNUNET_OK;
}