commit cb6a3ffd26cad8cda2c2b47eea54621dfff025e2
parent c8a965baf8d65b79d03570c05bcc962fae8239c6
Author: Matthias Wachs <wachs@net.in.tum.de>
Date: Tue, 9 Jul 2013 15:39:23 +0000
get function implementation in all plugins
Diffstat:
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
@@ -1437,6 +1437,21 @@ client_connect (struct Session *s)
return res;
}
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+int http_client_get_network (void *cls,
+ void *session)
+{
+ struct Session *s = (struct Session *) session;
+ GNUNET_assert (NULL != s);
+ return ntohl(s->ats_address_network_type);
+}
+
/**
* Creates a new outbound session the transport service will use to send data to the
@@ -1786,7 +1801,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
api->address_to_string = &http_plugin_address_to_string;
api->string_to_address = &http_common_plugin_string_to_address;
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
-
+ api->get_network = &http_client_get_network;
#if BUILD_HTTPS
plugin->name = "transport-https_client";
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
@@ -3004,6 +3004,20 @@ const char *http_plugin_address_to_string (void *cls,
return http_common_plugin_address_to_string (cls, p->protocol, addr, addrlen);
}
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+int http_server_get_network (void *cls,
+ void *session)
+{
+ struct Session *s = (struct Session *) session;
+ GNUNET_assert (NULL != s);
+ return ntohl(s->ats_address_network_type);
+}
/**
* Entry point for the plugin.
@@ -3044,6 +3058,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
api->address_to_string = &http_plugin_address_to_string;
api->string_to_address = &http_common_plugin_string_to_address;
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
+ api->get_network = &http_server_get_network;
#if BUILD_HTTPS
plugin->name = "transport-https_server";
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
@@ -2391,7 +2391,7 @@ int tcp_get_network (void *cls,
{
struct Session *s = (struct Session *) session;
GNUNET_assert (NULL != session);
- return s->ats_address_network_type;
+ return ntohl(s->ats_address_network_type);
}
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
@@ -1427,6 +1427,20 @@ session_cmp_it (void *cls,
return GNUNET_YES;
}
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+int udp_get_network (void *cls,
+ void *session)
+{
+ struct Session *s = (struct Session *) session;
+
+ return ntohl(s->ats.value);
+}
/**
* Creates a new outbound session the transport service will use to send data to the
@@ -2967,6 +2981,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
api->check_address = &udp_plugin_check_address;
api->get_session = &udp_plugin_get_session;
api->send = &udp_plugin_send;
+ api->get_network = &udp_get_network;
return api;
}