[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26461 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26461 - gnunet/src/transport |
Date: |
Fri, 15 Mar 2013 15:27:17 +0100 |
Author: wachs
Date: 2013-03-15 15:27:16 +0100 (Fri, 15 Mar 2013)
New Revision: 26461
Modified:
gnunet/src/transport/gnunet-service-transport_manipulation.c
gnunet/src/transport/gnunet-service-transport_manipulation.h
gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
gnunet/src/transport/transport_api.c
Log:
clean up
Modified: gnunet/src/transport/gnunet-service-transport_manipulation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-03-15 14:00:14 UTC (rev 26460)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-03-15 14:27:16 UTC (rev 26461)
@@ -37,6 +37,14 @@
#define DELAY 0
#define DISTANCE 1
+
+enum TRAFFIC_METRIC_DIRECTION
+{
+ TM_SEND = 0,
+ TM_RECEIVE = 1,
+ TM_BOTH = 2
+};
+
struct GST_ManipulationHandle man_handle;
@@ -175,6 +183,20 @@
if (0 == ntohs (tm->ats_count))
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ switch (ntohs(tm->direction)) {
+ case 1:
+ direction = TM_SEND;
+ break;
+ case 2:
+ direction = TM_RECEIVE;
+ break;
+ case 3:
+ direction = TM_BOTH;
+ break;
+ default:
+ break;
+ }
+
memset (&dummy, '\0', sizeof (struct GNUNET_PeerIdentity));
if (0 == memcmp (&tm->peer, &dummy, sizeof (struct
GNUNET_PeerIdentity)))
{
@@ -185,7 +207,7 @@
{
type = htonl (ats[c].type);
value = htonl (ats[c].value);
- direction = ntohs (tm->direction);
+
switch (type) {
case
GNUNET_ATS_QUALITY_NET_DELAY:
@@ -229,10 +251,10 @@
value = htonl (ats[c].value);
switch (type) {
case GNUNET_ATS_QUALITY_NET_DELAY:
- set_delay (tmp, &tm->peer, ntohs
(tm->direction), value);
+ set_delay (tmp, &tm->peer, direction,
value);
break;
case GNUNET_ATS_QUALITY_NET_DISTANCE:
- set_distance (tmp, &tm->peer, ntohs
(tm->direction), value);
+ set_distance (tmp, &tm->peer,
direction, value);
break;
default:
break;
Modified: gnunet/src/transport/gnunet-service-transport_manipulation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.h
2013-03-15 14:00:14 UTC (rev 26460)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.h
2013-03-15 14:27:16 UTC (rev 26461)
@@ -36,6 +36,7 @@
#include "gnunet-service-transport.h"
#include "transport.h"
+
void
GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message);
Modified: gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
===================================================================
--- gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
2013-03-15 14:00:14 UTC (rev 26460)
+++ gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
2013-03-15 14:27:16 UTC (rev 26461)
@@ -212,7 +212,7 @@
ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
ats[1].value = htonl (10);
- GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id, TM_RECEIVE, ats, 2);
+ GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id, GNUNET_YES,
GNUNET_NO, ats, 2);
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
if (2 == messages_recv)
Modified: gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
===================================================================
--- gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
2013-03-15 14:00:14 UTC (rev 26460)
+++ gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
2013-03-15 14:27:16 UTC (rev 26461)
@@ -306,10 +306,10 @@
{
ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
ats[0].value = htonl (1000);
- GNUNET_TRANSPORT_set_traffic_metric (p2->th, &p1->id, TM_SEND,
ats, 1);
+ GNUNET_TRANSPORT_set_traffic_metric (p2->th, &p1->id,
GNUNET_NO, GNUNET_YES, ats, 1);
ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
ats[0].value = htonl (10);
- GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id, TM_BOTH,
ats, 1);
+ GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id,
GNUNET_YES, GNUNET_YES, ats, 1);
start_delayed = GNUNET_TIME_absolute_get();
}
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2013-03-15 14:00:14 UTC (rev
26460)
+++ gnunet/src/transport/transport_api.c 2013-03-15 14:27:16 UTC (rev
26461)
@@ -1213,7 +1213,8 @@
*
* @param handle transport handle
* @param peer the peer to set the metric for
- * @param direction can be: TM_SEND, TM_RECV, TM_BOTH
+ * @param inbound set inbound direction (GNUNET_YES or GNUNET_NO)
+ * @param outbound set outbound direction (GNUNET_YES or GNUNET_NO)
* @param ats the metric as ATS information
* @param ats_count the number of metrics
*
@@ -1236,7 +1237,8 @@
void
GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
const struct
GNUNET_PeerIdentity *peer,
-
int direction,
+
int inbound,
+
int outbound,
const struct
GNUNET_ATS_Information *ats,
size_t
ats_count)
{
@@ -1244,9 +1246,11 @@
GNUNET_assert (NULL != handle);
GNUNET_assert (NULL != peer);
- GNUNET_assert (direction >= TM_SEND);
- GNUNET_assert (direction <= TM_BOTH);
+ GNUNET_assert ((outbound == GNUNET_YES) || (outbound == GNUNET_NO));
+ GNUNET_assert ((inbound == GNUNET_YES) || (inbound == GNUNET_NO));
+ if ((GNUNET_NO == inbound) && (GNUNET_NO == outbound))
+ return;
if (0 == ats_count)
return;
@@ -1256,7 +1260,7 @@
msg = GNUNET_malloc (len);
msg->header.size = htons (len);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC);
- msg->direction = htons (direction);
+ msg->direction = htons (0 + outbound + 2 * inbound);
msg->ats_count = htons (ats_count);
msg->peer = (*peer);
memcpy (&msg[1], ats, ats_count * sizeof (struct GNUNET_ATS_Information));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26461 - gnunet/src/transport,
gnunet <=