From: Christian Grothoff Date: Sat, 13 Jul 2013 15:33:30 +0000 (+0000) Subject: -add dv_get_network to DV API, improve signature to use 'struct Session *' instead... X-Git-Tag: initial-import-from-subversion-38251~8309 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ee21a783ec2bb31b26a508d12ffad5d8b3c866e9;p=oweals%2Fgnunet.git -add dv_get_network to DV API, improve signature to use 'struct Session *' instead of 'void *' --- diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index f094075e8..8f22246eb 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -634,6 +634,26 @@ dv_plugin_string_to_address (void *cls, } + +/** + * Function to obtain the network type for a session + * FIXME: we should probably look at the network type + * used by the next hop here. Or find some other way + * to properly allow ATS-DV resource allocation. + * + * @param cls closure ('struct Plugin*') + * @param session the session + * @return the network type + */ +static enum GNUNET_ATS_Network_Type +dv_get_network (void *cls, + struct Session *session) +{ + GNUNET_assert (NULL != session); + return GNUNET_ATS_NET_UNSPECIFIED; +} + + /** * Entry point for the plugin. */ @@ -670,7 +690,8 @@ libgnunet_plugin_transport_dv_init (void *cls) api->check_address = &dv_plugin_check_address; api->address_to_string = &dv_plugin_address_to_string; api->string_to_address = &dv_plugin_string_to_address; - api->get_session = dv_get_session; + api->get_session = &dv_get_session; + api->get_network = &dv_get_network; return api; } diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 456bd1ada..1579980ea 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h @@ -497,14 +497,14 @@ typedef int (*GNUNET_TRANSPORT_StringToAddress) (void *cls, /** - * Function obtain the network type for a session + * Function to obtain the network type for a session * * @param cls closure ('struct Plugin*') * @param session the session * @return the network type */ typedef enum GNUNET_ATS_Network_Type (*GNUNET_TRANSPORT_GetNetworkType) (void *cls, - void *session); + struct Session *session); /** @@ -571,7 +571,6 @@ struct GNUNET_TRANSPORT_PluginFunctions */ GNUNET_TRANSPORT_CreateSession get_session; - /** * Function to obtain the network type for a session */ diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index 57de3022b..3f432b90e 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c @@ -1024,6 +1024,7 @@ create_macendpoint (struct Plugin *plugin, return pos; } + /** * Function obtain the network type for a session * @@ -1032,10 +1033,11 @@ create_macendpoint (struct Plugin *plugin, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -bluetooth_get_network (void *cls, void *session) +bluetooth_get_network (void *cls, + struct Session *session) { - GNUNET_assert (NULL != session); - return GNUNET_ATS_NET_BT; + GNUNET_assert (NULL != session); + return GNUNET_ATS_NET_BT; } diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 8f814b590..75daeab71 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -1438,6 +1438,7 @@ client_connect (struct Session *s) return res; } + /** * Function obtain the network type for a session * @@ -1446,11 +1447,11 @@ client_connect (struct Session *s) * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -http_client_get_network (void *cls, void *session) +http_client_get_network (void *cls, + struct Session *session) { - struct Session *s = (struct Session *) session; - GNUNET_assert (NULL != s); - return ntohl(s->ats_address_network_type); + GNUNET_assert (NULL != session); + return ntohl (session->ats_address_network_type); } diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 10ba80a19..968ee23fa 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -3021,6 +3021,7 @@ const char *http_plugin_address_to_string (void *cls, } + /** * Function obtain the network type for a session * @@ -3029,13 +3030,14 @@ const char *http_plugin_address_to_string (void *cls, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -http_server_get_network (void *cls, void *session) +http_server_get_network (void *cls, + struct Session *session) { - struct Session *s = (struct Session *) session; - GNUNET_assert (NULL != s); - return ntohl(s->ats_address_network_type); + GNUNET_assert (NULL != session); + return ntohl (session->ats_address_network_type); } + /** * Entry point for the plugin. * diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 85b91ecad..b124fc618 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2394,11 +2394,11 @@ stop_session_timeout (struct Session *s) * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -tcp_get_network (void *cls,void *session) +tcp_get_network (void *cls, + struct Session *session) { - struct Session *s = (struct Session *) session; - GNUNET_assert (NULL != session); - return ntohl(s->ats_address_network_type); + GNUNET_assert (NULL != session); + return ntohl (session->ats_address_network_type); } diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index bf405dba6..007290504 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c @@ -205,6 +205,7 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) // FIXME } + /** * Function obtain the network type for a session * @@ -213,13 +214,14 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -template_plugin_get_network (void *cls, void *session) +template_plugin_get_network (void *cls, + struct Session *session) { - struct Session *s = (struct Session *) session; - GNUNET_assert (NULL != s); - return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */ + GNUNET_assert (NULL != session); + return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */ } + /** * Convert the transports address to a nice, human-readable * format. diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 421da9812..4d74e272e 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1443,6 +1443,7 @@ session_cmp_it (void *cls, return GNUNET_YES; } + /** * Function obtain the network type for a session * @@ -1451,13 +1452,13 @@ session_cmp_it (void *cls, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -udp_get_network (void *cls, void *session) +udp_get_network (void *cls, + struct Session *session) { - struct Session *s = (struct Session *) session; - - return ntohl(s->ats.value); + return ntohl (session->ats.value); } + /** * Creates a new outbound session the transport service will use to send data to the * peer diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index afa19d0e8..88df45223 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -732,6 +732,7 @@ session_timeout (void *cls, disconnect_session (s); } + /** * Function obtain the network type for a session * @@ -740,10 +741,11 @@ session_timeout (void *cls, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -unix_get_network (void *cls, void *session) +unix_get_network (void *cls, + struct Session *session) { - GNUNET_assert (NULL != session); - return GNUNET_ATS_NET_LOOPBACK; + GNUNET_assert (NULL != session); + return GNUNET_ATS_NET_LOOPBACK; } diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 298d55653..a376a2642 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -1057,6 +1057,7 @@ create_macendpoint (struct Plugin *plugin, return pos; } + /** * Function obtain the network type for a session * @@ -1065,12 +1066,14 @@ create_macendpoint (struct Plugin *plugin, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -wlan_get_network (void *cls, void *session) +wlan_get_network (void *cls, + struct Session *session) { - GNUNET_assert (NULL != session); - return GNUNET_ATS_NET_WLAN; + GNUNET_assert (NULL != session); + return GNUNET_ATS_NET_WLAN; } + /** * Creates a new outbound session the transport service will use to send data to the * peer