#include "gnunet_constants.h"
-/**
- * Receive and send buffer windows grow over time. For
- * how long can 'unused' bandwidth accumulate before we
- * need to cap it? (specified in seconds).
- */
-#define MAX_WINDOW_TIME_S (5 * 60)
-
-
/**
* Message ready for transmission via transport service. This struct
* is followed by the actual content of the message.
*/
GNUNET_SCHEDULER_TaskIdentifier retry_plaintext_task;
- /**
- * Tracking bandwidth for sending to this peer.
- */
- struct GNUNET_BANDWIDTH_Tracker available_recv_window;
-
};
static struct Neighbour *
find_neighbour (const struct GNUNET_PeerIdentity *peer)
{
+ if (NULL == neighbours)
+ return NULL;
return GNUNET_CONTAINER_multihashmap_get (neighbours, &peer->hashPubKey);
}
{
struct NeighbourMessageEntry *m;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Destroying neighbour entry for peer `%4s'\n",
GNUNET_i2s (&n->peer));
-#endif
while (NULL != (m = n->message_head))
{
GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th);
n->th = NULL;
}
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# sessions terminated by transport disconnect"),
+ 1, GNUNET_NO);
GSC_SESSIONS_end (&n->peer);
if (NULL != n->kxinfo)
{
}
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_remove (neighbours,
- &n->peer.hashPubKey, n));
- GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"),
+ &n->peer.hashPubKey, n));
+ GNUNET_STATISTICS_set (GSC_stats,
+ gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
GNUNET_NO);
GNUNET_free (n);
GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
if (buf == NULL)
{
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmission of message of type %u and size %u failed\n",
(unsigned int)
ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
(unsigned int) m->size);
-#endif
GNUNET_free (m);
process_queue (n);
return 0;
}
- ret = 0;
cbuf = buf;
GNUNET_assert (size >= m->size);
memcpy (cbuf, &m[1], m->size);
ret = m->size;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Copied message of type %u and size %u into transport buffer for `%4s'\n",
- (unsigned int)
- ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
- (unsigned int) ret, GNUNET_i2s (&n->peer));
-#endif
+ "Copied message of type %u and size %u into transport buffer for `%4s'\n",
+ (unsigned int)
+ ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
+ (unsigned int) ret, GNUNET_i2s (&n->peer));
GNUNET_free (m);
process_queue (n);
GNUNET_STATISTICS_update (GSC_stats,
if (m == NULL)
{
/* notify sessions that the queue is empty and more messages
- could thus be queued now */
+ * could thus be queued now */
GSC_SESSIONS_solicit (&n->peer);
return;
}
-#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n",
(unsigned int) m->size, GNUNET_i2s (&n->peer),
(unsigned long long)
GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value);
-#endif
n->th =
- GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size,
- 0,
- GNUNET_TIME_absolute_get_remaining
- (m->deadline),
- &transmit_ready,
- n);
+ GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0,
+ GNUNET_TIME_absolute_get_remaining
+ (m->deadline), &transmit_ready,
+ n);
if (n->th != NULL)
return;
/* message request too large or duplicate request */
*
* @param cls closure
* @param peer the peer that connected
- * @param ats performance data
- * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param atsi performance data
+ * @param atsi_count number of entries in ats (excluding 0-termination)
*/
static void
handle_transport_notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_TRANSPORT_ATS_Information
- *ats, uint32_t ats_count)
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct Neighbour *n;
GNUNET_break (0);
return;
}
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n",
GNUNET_i2s (peer));
-#endif
n = GNUNET_malloc (sizeof (struct Neighbour));
n->peer = *peer;
- GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window,
- GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
- MAX_WINDOW_TIME_S);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (neighbours,
&n->peer.hashPubKey, n,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"),
+ GNUNET_STATISTICS_set (GSC_stats,
+ gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
GNUNET_NO);
- GNUNET_TRANSPORT_set_quota (transport, peer,
- GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
- GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT);
n->kxinfo = GSC_KX_start (peer);
}
{
struct Neighbour *n;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%4s' disconnected from us; received notification from transport.\n",
GNUNET_i2s (peer));
-#endif
n = find_neighbour (peer);
if (n == NULL)
{
* @param cls closure
* @param peer (claimed) identity of the other peer
* @param message the message
- * @param ats performance data
- * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param atsi performance data
+ * @param atsi_count number of entries in ats (excluding 0-termination)
*/
static void
handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_TRANSPORT_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct Neighbour *n;
uint16_t type;
-#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u from `%4s', demultiplexing.\n",
(unsigned int) ntohs (message->type), GNUNET_i2s (peer));
-#endif
if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
GSC_KX_handle_pong (n->kxinfo, message);
break;
case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
- GSC_KX_handle_encrypted_message (n->kxinfo,
- message, ats,
- ats_count);
+ GSC_KX_handle_encrypted_message (n->kxinfo, message, atsi, atsi_count);
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Unsupported message of type %u received.\n"),
- (unsigned int) type);
+ _
+ ("Unsupported message of type %u (%u bytes) received from peer `%s'\n"),
+ (unsigned int) type, (unsigned int) ntohs (message->size),
+ GNUNET_i2s (peer));
return;
}
}
/**
* Transmit the given message to the given target.
- *
+ *
* @param target peer that should receive the message (must be connected)
* @param msg message to transmit
* @param timeout by when should the transmission be done?
*/
void
GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_MessageHeader *msg,
- struct GNUNET_TIME_Relative timeout)
+ const struct GNUNET_MessageHeader *msg,
+ struct GNUNET_TIME_Relative timeout)
{
struct NeighbourMessageEntry *me;
struct Neighbour *n;
me->deadline = GNUNET_TIME_relative_to_absolute (timeout);
me->size = msize;
memcpy (&me[1], msg, msize);
- GNUNET_CONTAINER_DLL_insert (n->message_head,
- n->message_tail,
- me);
+ GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me);
process_queue (n);
}
{
neighbours = GNUNET_CONTAINER_multihashmap_create (128);
transport =
- GNUNET_TRANSPORT_connect (GSC_cfg,
- &GSC_my_identity, NULL,
+ GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL,
&handle_transport_receive,
&handle_transport_notify_connect,
&handle_transport_notify_disconnect);
* @return GNUNET_OK (continue to iterate)
*/
static int
-free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value)
+free_neighbour_helper (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct Neighbour *n = value;
+ /* transport should have 'disconnected' all neighbours... */
+ GNUNET_break (0);
free_neighbour (n);
return GNUNET_OK;
}
{
if (NULL == transport)
return;
- GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper,
- NULL);
GNUNET_TRANSPORT_disconnect (transport);
transport = NULL;
+ GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper,
+ NULL);
GNUNET_CONTAINER_multihashmap_destroy (neighbours);
neighbours = NULL;
}
/* end of gnunet-service-core_neighbours.c */
-