From cb6a3ffd26cad8cda2c2b47eea54621dfff025e2 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 9 Jul 2013 15:39:23 +0000 Subject: get function implementation in all plugins --- src/transport/plugin_transport_http_client.c | 17 ++++++++++++++++- src/transport/plugin_transport_http_server.c | 15 +++++++++++++++ src/transport/plugin_transport_tcp.c | 2 +- src/transport/plugin_transport_udp.c | 15 +++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) (limited to 'src/transport') diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index e06c41b3b..7c3cebee3 100644 --- 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 index b7967296f..dfa3a4998 100644 --- 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 index 03f6528d2..025554a26 100644 --- 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 index 5707415a8..565573081 100644 --- 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; } -- cgit v1.2.3