[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26479 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26479 - in gnunet/src: include transport |
Date: |
Mon, 18 Mar 2013 17:10:32 +0100 |
Author: wachs
Date: 2013-03-18 17:10:31 +0100 (Mon, 18 Mar 2013)
New Revision: 26479
Modified:
gnunet/src/include/gnunet_transport_plugin.h
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/gnunet-service-transport.h
gnunet/src/transport/gnunet-service-transport_manipulation.c
gnunet/src/transport/gnunet-service-transport_manipulation.h
gnunet/src/transport/gnunet-service-transport_plugins.c
gnunet/src/transport/gnunet-service-transport_plugins.h
gnunet/src/transport/plugin_transport_http_client.c
gnunet/src/transport/plugin_transport_http_server.c
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/plugin_transport_udp.c
gnunet/src/transport/plugin_transport_udp_broadcasting.c
gnunet/src/transport/plugin_transport_unix.c
gnunet/src/transport/plugin_transport_wlan.c
gnunet/src/transport/test_plugin_transport.c
Log:
transport plugin api change: split of address receive and ats updates
Modified: gnunet/src/include/gnunet_transport_plugin.h
===================================================================
--- gnunet/src/include/gnunet_transport_plugin.h 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/include/gnunet_transport_plugin.h 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -100,24 +100,11 @@
*/
typedef struct
GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
- const
struct
-
GNUNET_PeerIdentity
- * peer,
- const
struct
-
GNUNET_MessageHeader
- * message,
- const
struct
-
GNUNET_ATS_Information
- * ats,
- uint32_t
- ats_count,
- struct
- Session *
- session,
- const char
-
*sender_address,
- uint16_t
-
sender_address_len);
+
const struct
GNUNET_PeerIdentity *peer,
+
const struct
GNUNET_MessageHeader *message,
+
struct Session
*session,
+
const char
*sender_address,
+
uint16_t
sender_address_len);
/**
@@ -134,7 +121,28 @@
const struct sockaddr *addr,
size_t addrlen);
+
/**
+ * Function called when quality properties of an address change.
+ *
+ * @param cls closure
+ * @param peer peer
+ * @param address address
+ * @param address_len length of the address
+ * @param session session
+ * @param ats ATS information
+ * @param ats_count number of ATS information contained
+ */
+typedef void
+(*GNUNET_TRANSPORT_UpdateAddressMetrics) (void *cls,
+
const struct GNUNET_PeerIdentity *peer,
+
const
char *address,
+
uint16_t address_len,
+
struct
Session *session,
+
struct
GNUNET_ATS_Information *ats,
+
uint32_t ats_count);
+
+/**
* Function that will be called for each address the transport
* is aware that it might be reachable under.
*
@@ -246,7 +254,13 @@
*/
GNUNET_TRANSPORT_AddressToType get_address_type;
+ /**
+ * Function that will be called to figure if an address is an loopback,
+ * LAN, WAN etc. address
+ */
+ GNUNET_TRANSPORT_UpdateAddressMetrics update_address_metrics;
+
/**
* What is the maximum number of connections that this transport
* should allow? Transports that do not have sessions (such as
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/gnunet-service-transport.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -233,8 +233,7 @@
struct GNUNET_TIME_Relative
GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count, struct Session *session,
+ struct Session *session,
const char *sender_address,
uint16_t sender_address_len)
{
@@ -278,16 +277,13 @@
GST_validation_handle_pong (peer, message);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
- GST_neighbours_handle_connect (message, peer, &address, session, ats,
- ats_count);
+ GST_neighbours_handle_connect (message, peer, &address, session, NULL, 0);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
- GST_neighbours_handle_connect_ack (message, peer, &address, session, ats,
- ats_count);
+ GST_neighbours_handle_connect_ack (message, peer, &address, session, NULL,
0);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
- GST_neighbours_handle_session_ack (message, peer, &address, session, ats,
- ats_count);
+ GST_neighbours_handle_session_ack (message, peer, &address, session, NULL,
0);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
GST_neighbours_handle_disconnect_message (peer, message);
@@ -296,7 +292,7 @@
GST_neighbours_keepalive (peer);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE:
- GST_neighbours_keepalive_response (peer, ats, ats_count);
+ GST_neighbours_keepalive_response (peer, NULL, 0);
break;
default:
/* should be payload */
@@ -304,7 +300,7 @@
gettext_noop
("# bytes payload received"),
ntohs (message->size), GNUNET_NO);
- ret = process_payload (peer, &address, session, message, ats, ats_count);
+ ret = process_payload (peer, &address, session, message, NULL, 0);
break;
}
end:
@@ -416,7 +412,40 @@
return GNUNET_ATS_address_get_type(GST_ats, addr, addrlen);
}
+/**
+ * Function that will be called to figure if an address is an loopback,
+ * LAN, WAN etc. address
+ *
+ * @param cls closure
+ * @param addr binary address
+ * @param addrlen length of the address
+ * @return ATS Information containing the network type
+ */
+static void
+plugin_env_update_metrics (void *cls,
+
const 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_HELLO_Address haddress;
+ const char *plugin_name = cls;
+ if ((NULL == ats) || (0 == ats_count))
+ return;
+ GNUNET_assert (NULL != GST_ats);
+
+ haddress.peer = *peer;
+ haddress.address = address;
+ haddress.address_length = address_len;
+ haddress.transport_name = plugin_name;
+
+ GNUNET_ATS_address_update (GST_ats, &haddress, session, ats, ats_count);
+}
+
+
/**
* Function called by ATS to notify the callee that the
* assigned bandwidth or address for a given peer was changed. If the
@@ -671,7 +700,8 @@
GST_plugins_load (&GST_manipulation_recv,
&plugin_env_address_change_notification,
&plugin_env_session_end,
- &plugin_env_address_to_type);
+ &plugin_env_address_to_type,
+ &plugin_env_update_metrics);
GST_neighbours_start (NULL,
&neighbours_connect_notification,
&neighbours_disconnect_notification,
Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/gnunet-service-transport.h 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -93,8 +93,7 @@
struct GNUNET_TIME_Relative
GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count, struct Session *session,
+ struct Session *session,
const char *sender_address,
uint16_t sender_address_len);
Modified: gnunet/src/transport/gnunet-service-transport_manipulation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-03-18 14:34:48 UTC (rev 26478)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.c
2013-03-18 16:10:31 UTC (rev 26479)
@@ -342,19 +342,26 @@
}
struct GNUNET_TIME_Relative
-GST_manipulation_recv (void *cls, const struct GNUNET_PeerIdentity *peer,
+GST_manipulation_recv (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count, struct Session *session,
+ struct Session *session,
const char *sender_address,
uint16_t sender_address_len)
{
+ return GST_receive_callback (cls, peer, message,
+ session, sender_address, sender_address_len);
+
+/* FIXME */
+#if 0
struct TM_Peer *tmp;
int d;
struct GNUNET_ATS_Information ats_new[ats_count];
struct GNUNET_TIME_Relative quota_delay;
struct GNUNET_TIME_Relative m_delay;
+
+
if (man_handle.delay_in.rel_value > GNUNET_TIME_UNIT_ZERO.rel_value)
m_delay = man_handle.delay_in; /* Global delay */
else
@@ -385,12 +392,13 @@
m_delay.rel_value =
tmp->metrics[TM_RECEIVE][DELAY]; /* Peer specific delay */
}
- quota_delay = GST_receive_callback (cls, peer, message, ats_new,
ats_count,
+ quota_delay = GST_receive_callback (cls, peer, message,
session, sender_address, sender_address_len);
if (quota_delay.rel_value > m_delay.rel_value)
return quota_delay;
else
return m_delay;
+#endif
}
void
Modified: gnunet/src/transport/gnunet-service-transport_manipulation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_manipulation.h
2013-03-18 14:34:48 UTC (rev 26478)
+++ gnunet/src/transport/gnunet-service-transport_manipulation.h
2013-03-18 16:10:31 UTC (rev 26479)
@@ -47,12 +47,12 @@
GST_NeighbourSendContinuation cont, void *cont_cls);
struct GNUNET_TIME_Relative
-GST_manipulation_recv (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count, struct Session *session,
- const char *sender_address,
- uint16_t sender_address_len);
+GST_manipulation_recv (void *cls,
+
const struct GNUNET_PeerIdentity *peer,
+
const struct GNUNET_MessageHeader *message,
+
struct Session *session,
+
const char *sender_address,
+
uint16_t sender_address_len);
void
GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg);
Modified: gnunet/src/transport/gnunet-service-transport_plugins.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.c 2013-03-18
14:34:48 UTC (rev 26478)
+++ gnunet/src/transport/gnunet-service-transport_plugins.c 2013-03-18
16:10:31 UTC (rev 26479)
@@ -89,12 +89,14 @@
* @param address_cb function to call when our public addresses changed
* @param session_end_cb function to call when a session was terminated
* @param address_type_cb function to call when a address type is requested
+ * @param metric_update_cb function to call when address metrics change
*/
void
GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
GNUNET_TRANSPORT_AddressNotification address_cb,
GNUNET_TRANSPORT_SessionEnd session_end_cb,
- GNUNET_TRANSPORT_AddressToType address_type_cb)
+ GNUNET_TRANSPORT_AddressToType address_type_cb,
+ GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb)
{
struct TransportPlugin *plug;
struct TransportPlugin *next;
@@ -133,6 +135,7 @@
plug->env.notify_address = address_cb;
plug->env.session_end = session_end_cb;
plug->env.get_address_type = address_type_cb;
+ plug->env.update_address_metrics = metric_update_cb;
plug->env.max_connections = tneigh;
plug->env.stats = GST_stats;
GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug);
Modified: gnunet/src/transport/gnunet-service-transport_plugins.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.h 2013-03-18
14:34:48 UTC (rev 26478)
+++ gnunet/src/transport/gnunet-service-transport_plugins.h 2013-03-18
16:10:31 UTC (rev 26479)
@@ -43,12 +43,14 @@
* @param address_cb function to call when our public addresses changed
* @param session_end_cb function to call when a session was terminated
* @param address_type_cb function to call when a address type is requested
+ * @param metric_update_cb function to call when address metrics change
*/
void
GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
GNUNET_TRANSPORT_AddressNotification address_cb,
GNUNET_TRANSPORT_SessionEnd session_end_cb,
- GNUNET_TRANSPORT_AddressToType address_type_cb);
+ GNUNET_TRANSPORT_AddressToType address_type_cb,
+ GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb);
/**
* Unload all plugins
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/plugin_transport_http_client.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -919,9 +919,15 @@
GNUNET_break (s->ats_address_network_type != ntohl
(GNUNET_ATS_NET_UNSPECIFIED));
delay = s->plugin->env->receive (plugin->env->cls, &s->target, message,
- (const struct GNUNET_ATS_Information *)
&atsi, 2,
s, s->addr, s->addrlen);
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &s->target,
+ s->addr,
+ s->addrlen,
+ s,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
+
GNUNET_asprintf (&stat_txt, "# bytes received via %s_client",
plugin->protocol);
GNUNET_STATISTICS_update (plugin->env->stats,
stat_txt, ntohs(message->size), GNUNET_NO);
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/plugin_transport_http_server.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -1289,9 +1289,15 @@
delay = plugin->env->receive (plugin->env->cls,
&s->target,
message,
- (const struct GNUNET_ATS_Information *) &atsi,
2,
s, s->addr, s->addrlen);
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &s->target,
+ s->addr,
+ s->addrlen,
+ s,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
+
GNUNET_asprintf (&stat_txt, "# bytes received via %s_server",
plugin->protocol);
GNUNET_STATISTICS_update (plugin->env->stats,
stat_txt, ntohs (message->size), GNUNET_NO);
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2013-03-18 14:34:48 UTC (rev
26478)
+++ gnunet/src/transport/plugin_transport_tcp.c 2013-03-18 16:10:31 UTC (rev
26479)
@@ -2050,10 +2050,16 @@
delay = plugin->env->receive (plugin->env->cls,
&session->target,
message,
- (const struct GNUNET_ATS_Information *)
&distance,
- 2, session,
+ session,
(GNUNET_YES == session->inbound) ? NULL :
session->addr,
(GNUNET_YES == session->inbound) ? 0 :
session->addrlen);
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &session->target,
+ (GNUNET_YES == session->inbound) ? NULL : session->addr,
+ (GNUNET_YES == session->inbound) ? 0 : session->addrlen,
+ session,
+ (struct GNUNET_ATS_Information *) &distance,
+ 2);
reschedule_session_timeout (session);
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2013-03-18 14:34:48 UTC (rev
26478)
+++ gnunet/src/transport/plugin_transport_udp.c 2013-03-18 16:10:31 UTC (rev
26479)
@@ -1907,10 +1907,17 @@
delay = plugin->env->receive (plugin->env->cls,
&si->sender,
hdr,
- (const struct GNUNET_ATS_Information *) &ats, 2,
si->session,
si->arg,
si->args);
+
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &si->sender,
+ si->arg,
+ si->args,
+ si->session,
+ (struct GNUNET_ATS_Information *) &ats, 2);
+
si->session->flow_delay_for_other_peer = delay;
reschedule_session_timeout(si->session);
return GNUNET_OK;
Modified: gnunet/src/transport/plugin_transport_udp_broadcasting.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_broadcasting.c 2013-03-18
14:34:48 UTC (rev 26478)
+++ gnunet/src/transport/plugin_transport_udp_broadcasting.c 2013-03-18
16:10:31 UTC (rev 26479)
@@ -119,9 +119,18 @@
GNUNET_break (ntohl(mc->ats_address_network_type) !=
GNUNET_ATS_NET_UNSPECIFIED);
hello = (struct GNUNET_MessageHeader *) &msg[1];
- plugin->env->receive (plugin->env->cls, &msg->sender, hello,
- (const struct GNUNET_ATS_Information *) &atsi, 2, NULL,
- (const char *) &mc->addr, sizeof (mc->addr));
+ plugin->env->receive (plugin->env->cls,
+
&msg->sender,
+
hello,
+ NULL,
+ (const char *) &mc->addr,
+ sizeof (mc->addr));
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &msg->sender,
+ (const char *) &mc->addr,
+ sizeof (mc->addr),
+ NULL,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
GNUNET_STATISTICS_update (plugin->env->stats,
_
@@ -160,10 +169,20 @@
GNUNET_break (ntohl(mc->ats_address_network_type) !=
GNUNET_ATS_NET_UNSPECIFIED);
hello = (struct GNUNET_MessageHeader *) &msg[1];
- plugin->env->receive (plugin->env->cls, &msg->sender, hello,
- (const struct GNUNET_ATS_Information *) &atsi, 2, NULL,
- (const char *) &mc->addr, sizeof (mc->addr));
+ plugin->env->receive (plugin->env->cls,
+
&msg->sender,
+
hello,
+ NULL,
+ (const char *) &mc->addr,
+ sizeof (mc->addr));
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &msg->sender,
+ (const char *) &mc->addr,
+ sizeof (mc->addr),
+ NULL,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
+
GNUNET_STATISTICS_update (plugin->env->stats,
_
("# IPv4 broadcast HELLO beacons received via
udp"),
Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/plugin_transport_unix.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -823,8 +823,15 @@
reschedule_session_timeout (s);
plugin->env->receive (plugin->env->cls, sender, currhdr,
- (const struct GNUNET_ATS_Information *) &ats, 2,
s, un->sun_path, strlen (un->sun_path) + 1);
+
+ plugin->env->update_address_metrics (plugin->env->cls,
+ sender,
+ un->sun_path,
+ strlen (un->sun_path) + 1,
+ s,
+ (struct GNUNET_ATS_Information *) &ats, 2);
+
GNUNET_free (addr);
}
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/plugin_transport_wlan.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -1171,10 +1171,15 @@
plugin->env->receive (plugin->env->cls,
&tmpsource,
hdr,
- ats, NUM_ATS,
mas->session,
(mas->endpoint == NULL) ? NULL : (const char *)
&mas->endpoint->addr,
(mas->endpoint == NULL) ? 0 : sizeof (struct
GNUNET_TRANSPORT_WLAN_MacAddress));
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &tmpsource,
+ (mas->endpoint == NULL) ? NULL : (const char *)
&mas->endpoint->addr,
+ (mas->endpoint == NULL) ? 0 : sizeof (struct
GNUNET_TRANSPORT_WLAN_MacAddress),
+ mas->session,
+ (struct GNUNET_ATS_Information *) &ats, NUM_ATS);
break;
case GNUNET_MESSAGE_TYPE_FRAGMENT:
if (NULL == mas->endpoint)
@@ -1289,10 +1294,15 @@
plugin->env->receive (plugin->env->cls,
&mas->session->target,
hdr,
- ats, NUM_ATS,
mas->session,
(mas->endpoint == NULL) ? NULL : (const char *)
&mas->endpoint->addr,
(mas->endpoint == NULL) ? 0 : sizeof (struct
GNUNET_TRANSPORT_WLAN_MacAddress));
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &mas->session->target,
+ (mas->endpoint == NULL) ? NULL : (const char *)
&mas->endpoint->addr,
+ (mas->endpoint == NULL) ? 0 : sizeof (struct
GNUNET_TRANSPORT_WLAN_MacAddress),
+ mas->session,
+ (struct GNUNET_ATS_Information *) &ats, NUM_ATS);
break;
}
return GNUNET_OK;
Modified: gnunet/src/transport/test_plugin_transport.c
===================================================================
--- gnunet/src/transport/test_plugin_transport.c 2013-03-18 14:34:48 UTC
(rev 26478)
+++ gnunet/src/transport/test_plugin_transport.c 2013-03-18 16:10:31 UTC
(rev 26479)
@@ -292,8 +292,6 @@
env_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count,
struct Session * session,
const char *sender_address,
uint16_t sender_address_len)
@@ -485,6 +483,18 @@
static void
+env_update_metrics (void *cls,
+
const struct GNUNET_PeerIdentity *peer,
+
const char *address,
+
uint16_t address_len,
+
struct Session *session,
+
struct GNUNET_ATS_Information *ats,
+
uint32_t ats_count)
+{
+}
+
+
+static void
setup_plugin_environment ()
{
env.cfg = cfg;
@@ -496,6 +506,7 @@
env.receive = &env_receive;
env.notify_address = &env_notify_address;
env.get_address_type = &env_get_address_type;
+ env.update_address_metrics = &env_update_metrics;
env.get_our_hello = &env_get_our_hello;
env.session_end = &env_session_end;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26479 - in gnunet/src: include transport,
gnunet <=