[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26740 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26740 - gnunet/src/transport |
Date: |
Wed, 3 Apr 2013 16:59:01 +0200 |
Author: wachs
Date: 2013-04-03 16:59:01 +0200 (Wed, 03 Apr 2013)
New Revision: 26740
Modified:
gnunet/src/transport/gnunet-service-transport_manipulation.c
Log:
generic ats manipulation
Modified: gnunet/src/transport/gnunet-service-transport_manipulation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-04-03 14:22:33 UTC (rev 26739)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-04-03 14:59:01 UTC (rev 26740)
@@ -48,6 +48,57 @@
struct GST_ManipulationHandle man_handle;
+/**
+ * Struct containing information about manipulations to a specific peer
+ */
+struct TM_Peer;
+
+struct PropManipulationEntry
+{
+ struct PropManipulationEntry *next;
+ struct PropManipulationEntry *prev;
+
+ uint32_t type;
+
+ uint32_t metrics[TM_BOTH];
+
+};
+
+/**
+ * Struct containing information about manipulations to a specific peer
+ */
+struct TM_Peer
+{
+ /**
+ * Peer ID
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ struct PropManipulationEntry *head;
+ struct PropManipulationEntry *tail;
+
+ /**
+ * Peer specific manipulation metrics
+ */
+ uint32_t metrics [TM_BOTH][GNUNET_ATS_QualityPropertiesCount];
+
+ /**
+ * Task to schedule delayed sendding
+ */
+ GNUNET_SCHEDULER_TaskIdentifier send_delay_task;
+
+ /**
+ * Send queue DLL head
+ */
+ struct DelayQueueEntry *send_head;
+
+ /**
+ * Send queue DLL tail
+ */
+ struct DelayQueueEntry *send_tail;
+};
+
+
struct GST_ManipulationHandle
{
/**
@@ -55,6 +106,8 @@
*/
struct GNUNET_CONTAINER_MultiHashMap *peers;
+ struct TM_Peer general;
+
/**
* General inbound delay
*/
@@ -75,13 +128,12 @@
*/
unsigned long long distance_send;
+ struct PropManipulationEntry *head;
+ struct PropManipulationEntry *tail;
};
-/**
- * Struct containing information about manipulations to a specific peer
- */
-struct TM_Peer;
+
/**
* Entry in the delay queue for an outbound delayed message
*/
@@ -133,39 +185,72 @@
void *cont_cls;
};
-/**
- * Struct containing information about manipulations to a specific peer
- */
-struct TM_Peer
+
+static void
+set_metric (struct TM_Peer *dest, int direction, uint32_t type, uint32_t value)
{
- /**
- * Peer ID
- */
- struct GNUNET_PeerIdentity peer;
+ struct PropManipulationEntry *cur;
+ for (cur = dest->head; NULL != cur; cur = cur->next)
+ {
+ if (cur->type == type)
+ break;
+ }
+ if (NULL == cur)
+ {
+ cur = GNUNET_malloc (sizeof (struct PropManipulationEntry));
+ GNUNET_CONTAINER_DLL_insert (dest->head, dest->tail, cur);
+ cur->type = type;
+ cur->metrics[TM_SEND] = UINT32_MAX;
+ cur->metrics[TM_RECEIVE] = UINT32_MAX;
+ }
- /**
- * Peer specific manipulation metrics
- */
- uint32_t metrics [TM_BOTH][GNUNET_ATS_QualityPropertiesCount];
- /**
- * Task to schedule delayed sendding
- */
- GNUNET_SCHEDULER_TaskIdentifier send_delay_task;
+ switch (direction) {
+ case TM_BOTH:
+ cur->metrics[TM_SEND] = value;
+ cur->metrics[TM_RECEIVE] = value;
+ break;
+ case TM_SEND:
+ cur->metrics[TM_SEND] = value;
+ break;
+ case TM_RECEIVE:
+ cur->metrics[TM_RECEIVE] = value;
+ break;
+ default:
+ break;
+ }
- /**
- * Send queue DLL head
- */
- struct DelayQueueEntry *send_head;
+}
- /**
- * Send queue DLL tail
- */
- struct DelayQueueEntry *send_tail;
-};
+static uint32_t
+find_metric (struct TM_Peer *dest, uint32_t type, int direction)
+{
+ struct PropManipulationEntry *cur;
+ for (cur = dest->head; NULL != cur; cur = cur->next)
+ {
+ if (cur->type == type)
+ return cur->metrics[direction];
+ }
+ return UINT32_MAX;
+}
+
static void
+free_metric (struct TM_Peer *dest)
+{
+ struct PropManipulationEntry *cur;
+ struct PropManipulationEntry *next;
+
+ for (cur = dest->head; NULL != cur; cur = next)
+ {
+ next = cur->next;
+ GNUNET_CONTAINER_DLL_remove (dest->head, dest->tail, cur);
+ GNUNET_free (cur);
+ }
+}
+
+static void
set_delay(struct TM_Peer *tmp, struct GNUNET_PeerIdentity *peer, int
direction, uint32_t value)
{
uint32_t val;
@@ -278,6 +363,8 @@
type = htonl (ats[c].type);
value = htonl (ats[c].value);
+ set_metric (&man_handle.general,
direction, type, value);
+
switch (type) {
case
GNUNET_ATS_QUALITY_NET_DELAY:
if ((TM_RECEIVE ==
direction) || (TM_BOTH == direction))
@@ -321,6 +408,10 @@
{
type = htonl (ats[c].type);
value = htonl (ats[c].value);
+
+ set_metric (tmp, direction, type, value);
+
+
switch (type) {
case GNUNET_ATS_QUALITY_NET_DELAY:
set_delay (tmp, &tm->peer, direction,
value);
@@ -570,6 +661,7 @@
{
struct TM_Peer *tmp = (struct TM_Peer *) value;
GNUNET_CONTAINER_multihashmap_remove (man_handle.peers,
key, value);
+ free_metric (tmp);
next = tmp->send_head;
while (NULL != (dqe = next))
{
@@ -597,6 +689,7 @@
GNUNET_CONTAINER_multihashmap_iterate (man_handle.peers,
&free_tmps,NULL);
GNUNET_CONTAINER_multihashmap_destroy (man_handle.peers);
+ free_metric (&man_handle.general);
man_handle.peers = NULL;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26740 - gnunet/src/transport,
gnunet <=