gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26597 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r26597 - gnunet/src/transport
Date: Mon, 25 Mar 2013 15:23:37 +0100

Author: wachs
Date: 2013-03-25 15:23:36 +0100 (Mon, 25 Mar 2013)
New Revision: 26597

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_manipulation.c
   gnunet/src/transport/gnunet-service-transport_manipulation.h
Log:
ATS manipulation


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2013-03-25 12:47:17 UTC 
(rev 26596)
+++ gnunet/src/transport/gnunet-service-transport.c     2013-03-25 14:23:36 UTC 
(rev 26597)
@@ -402,7 +402,16 @@
                        const struct GNUNET_ATS_Information *ats,
                        uint32_t ats_count)
 {
-  GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
+       struct GNUNET_ATS_Information *ats_new;
+       /* Call to manipulation to manipulate ATS information */
+       ats_new = GST_manipulation_manipulate_metrics (peer, address, session, 
ats, ats_count);
+       if (NULL == ats_new)
+       {
+                       GNUNET_break (0);
+                       return;
+       }
+  GNUNET_ATS_address_update (GST_ats, address, session, ats_new, ats_count);
+  GNUNET_free (ats_new);
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_manipulation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.c        
2013-03-25 12:47:17 UTC (rev 26596)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.c        
2013-03-25 14:23:36 UTC (rev 26597)
@@ -347,8 +347,8 @@
 
 
 /**
- * Function that will be called to figure if an address is an loopback,
- * LAN, WAN etc. address
+ * Function that will be called to manipulate ATS information according to
+ * current manipulation settings
  *
  * @param cls closure
  * @param peer the peer
@@ -358,27 +358,22 @@
  * @param ats the ats information
  * @param ats_count the number of ats information
  */
-void
-GST_manipulation_metrics_recv (void *cls,
-                                                                               
                                                 struct GNUNET_PeerIdentity 
*peer,
-                                                                               
                                                 const char *address,
-                                                                               
                                                 uint16_t address_len,
-                                                                               
                                                 struct Session *session,
-                                                                               
                                                 struct GNUNET_ATS_Information 
*ats,
-                                                                               
                                                 uint32_t ats_count)
+struct GNUNET_ATS_Information *
+GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
+               const struct GNUNET_HELLO_Address *address,
+               struct Session *session,
+               const struct GNUNET_ATS_Information *ats,
+               uint32_t ats_count)
 {
-
-       struct GNUNET_ATS_Information ats_new[ats_count];
+       struct GNUNET_ATS_Information *ats_new = GNUNET_malloc (sizeof (struct 
GNUNET_ATS_Information) *ats_count);
        struct TM_Peer *tmp;
        uint32_t m_distance;
        int d;
-
-
        m_distance = 0;
        if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, 
&peer->hashPubKey)))
        {
                        if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE])
-                               m_distance = tmp->metrics[TM_RECEIVE][DISTANCE];
+                                       m_distance = 
tmp->metrics[TM_RECEIVE][DISTANCE];
        }
 
        for (d = 0; d < ats_count; d++)
@@ -387,13 +382,17 @@
                if (ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
                {
                        if (m_distance > 0)
+                       {
                                ats_new[d].value = htonl(m_distance);
+                       }
                        else if  (man_handle.distance_recv > 0)
+                       {
                                ats_new[d].value = 
htonl(man_handle.distance_recv);
+                       }
                }
        }
 
-       man_handle.metric_update_cb (cls, peer, address, address_len, session, 
ats_new, ats_count);
+       return ats_new;
 }
 
 struct GNUNET_TIME_Relative
@@ -427,7 +426,6 @@
                return quota_delay;
        else
                return m_delay;
-
 }
 
 void

Modified: gnunet/src/transport/gnunet-service-transport_manipulation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.h        
2013-03-25 12:47:17 UTC (rev 26596)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.h        
2013-03-25 14:23:36 UTC (rev 26597)
@@ -66,14 +66,12 @@
  * @param ats the ats information
  * @param ats_count the number of ats information
  */
-void
-GST_manipulation_metrics_recv (void *cls,
-                                                                               
                                                 struct GNUNET_PeerIdentity 
*peer,
-                                                                               
                                                 const char *address,
-                                                                               
                                                 uint16_t address_len,
-                                                                               
                                                 struct Session *session,
-                                                                               
                                                 struct GNUNET_ATS_Information 
*ats,
-                                                                               
                                                 uint32_t ats_count);
+struct GNUNET_ATS_Information *
+GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
+               const struct GNUNET_HELLO_Address *address,
+               struct Session *session,
+               const struct GNUNET_ATS_Information *ats,
+               uint32_t ats_count);
 
 void
 GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]