gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r26016 - in gnunet/src: include transport


From: gnunet
Subject: [GNUnet-SVN] r26016 - in gnunet/src: include transport
Date: Tue, 5 Feb 2013 13:47:04 +0100

Author: wachs
Date: 2013-02-05 13:47:04 +0100 (Tue, 05 Feb 2013)
New Revision: 26016

Modified:
   gnunet/src/include/gnunet_transport_service.h
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/transport_api.c
Log:
last commit for metric


Modified: gnunet/src/include/gnunet_transport_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_service.h       2013-02-05 12:46:15 UTC 
(rev 26015)
+++ gnunet/src/include/gnunet_transport_service.h       2013-02-05 12:47:04 UTC 
(rev 26016)
@@ -43,7 +43,14 @@
  */
 #define GNUNET_TRANSPORT_VERSION 0x00000000
 
+enum TRAFFIC_METRIC_DIRECTION
+{
+       TM_SEND = 0,
+       TM_RECEIVE = 1,
+       TM_BOTH = 2
+};
 
+
 /**
  * Function called by the transport for each received message.
  *
@@ -282,6 +289,14 @@
                                                                const struct 
GNUNET_PeerIdentity *peer);
 
 
+void
+GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
+                                                                               
                                                                const struct 
GNUNET_PeerIdentity *peer,
+                                                                               
                                                                int direction,
+                                                                               
                                                                const struct 
GNUNET_ATS_Information *ats,
+                                                                               
                                                                size_t 
ats_count);
+
+
 /**
  * Obtain updates on changes to the HELLO message for this peer. The callback
  * given in this function is never called synchronously.

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2013-02-05 12:46:15 UTC (rev 26015)
+++ gnunet/src/transport/Makefile.am    2013-02-05 12:47:04 UTC (rev 26016)
@@ -164,7 +164,8 @@
  gnunet-service-transport_hello.h gnunet-service-transport_hello.c \
  gnunet-service-transport_neighbours.h gnunet-service-transport_neighbours.c \
  gnunet-service-transport_plugins.h gnunet-service-transport_plugins.c \
- gnunet-service-transport_validation.h gnunet-service-transport_validation.c 
+ gnunet-service-transport_validation.h gnunet-service-transport_validation.c \
+ gnunet-service-transport_manipulation.h 
gnunet-service-transport_manipulation.c 
 gnunet_service_transport_LDADD = \
   $(top_builddir)/src/ats/libgnunetats.la \
   $(top_builddir)/src/hello/libgnunethello.la \
@@ -342,6 +343,7 @@
  $(HTTPS_API_TIMEOUT_TEST) \
  $(WLAN_API_TEST) \
  test_transport_api_multi \
+ test_transport_api_manipulation_tcp \
  test_transport_api_reliability_tcp \
  test_transport_api_reliability_tcp_nat \
  test_transport_api_unreliability_udp \
@@ -389,6 +391,7 @@
  $(HTTPS_API_TIMEOUT_TEST) \
  $(WLAN_API_TEST) \
  test_transport_api_multi \
+ test_transport_api_manipulation_tcp \
  test_transport_api_reliability_tcp \
  test_transport_api_reliability_tcp_nat \
  test_transport_api_unreliability_udp \
@@ -430,7 +433,6 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
 
-
 test_transport_api_blacklisting_SOURCES = \
  test_transport_api_blacklisting.c
 test_transport_api_blacklisting_LDADD = \
@@ -590,6 +592,15 @@
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
 
+test_transport_api_manipulation_tcp_SOURCES = \
+ test_transport_api_manipulation.c
+test_transport_api_manipulation_tcp_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la 
+
+
 test_transport_api_reliability_tcp_SOURCES = \
  test_transport_api_reliability.c
 test_transport_api_reliability_tcp_LDADD = \

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2013-02-05 12:46:15 UTC (rev 
26015)
+++ gnunet/src/transport/transport_api.c        2013-02-05 12:47:04 UTC (rev 
26016)
@@ -1180,6 +1180,66 @@
 
 
 /**
+ * Send traffic metric message to the service.
+ *
+ * @param cls the message to send
+ * @param size number of bytes available in buf
+ * @param buf where to copy the message
+ * @return number of bytes copied to buf
+ */
+static size_t
+send_metric (void *cls, size_t size, void *buf)
+{
+       struct TrafficMetricMessage *msg = cls;
+  uint16_t ssize;
+  if (buf == NULL)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Timeout while trying to transmit `%s' request.\n", "TRAFFIC_METRIC");
+    GNUNET_free (msg);
+    return 0;
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", 
"TRAFFIC_METRIC");
+  ssize = ntohs (msg->header.size);
+  GNUNET_assert (size >= ssize);
+  memcpy (buf, msg, ssize);
+  GNUNET_free (msg);
+  return ssize;
+}
+
+void
+GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
+                                                                               
                                                                const struct 
GNUNET_PeerIdentity *peer,
+                                                                               
                                                                int direction,
+                                                                               
                                                                const struct 
GNUNET_ATS_Information *ats,
+                                                                               
                                                                size_t 
ats_count)
+{
+  struct TrafficMetricMessage *msg;
+
+  GNUNET_assert (NULL != handle);
+  GNUNET_assert (NULL != peer);
+  GNUNET_assert (direction >= TM_SEND);
+  GNUNET_assert (direction <= TM_BOTH);
+
+  if (0 == ats_count)
+       return;
+
+  size_t len = sizeof (struct TrafficMetricMessage) +
+                                                ats_count * sizeof (struct 
GNUNET_ATS_Information);
+
+  msg = GNUNET_malloc (len);
+  msg->header.size = htons (len);
+  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC);
+  msg->direction = htons (direction);
+  msg->ats_count = htons (ats_count);
+  msg->peer = (*peer);
+  memcpy (&msg[1], ats, ats_count * sizeof (struct GNUNET_ATS_Information));
+  schedule_control_transmit (handle, len, &send_metric, msg);
+}
+
+
+
+/**
  * Offer the transport service the HELLO of another peer.  Note that
  * the transport service may just ignore this message if the HELLO is
  * malformed or useless due to our local configuration.




reply via email to

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