From e298fa7e3eeafea48a8abf6c5b8bf449b279e7a7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 6 Dec 2018 17:03:35 +0100 Subject: high-level new ATS service implementation --- src/include/gnunet_ats_plugin_new.h | 169 +++++++++++++++++++++++++++++ src/include/gnunet_ats_transport_service.h | 2 +- src/include/gnunet_container_lib.h | 10 +- 3 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 src/include/gnunet_ats_plugin_new.h (limited to 'src/include') diff --git a/src/include/gnunet_ats_plugin_new.h b/src/include/gnunet_ats_plugin_new.h new file mode 100644 index 000000000..267477871 --- /dev/null +++ b/src/include/gnunet_ats_plugin_new.h @@ -0,0 +1,169 @@ +/* + This file is part of GNUnet + Copyright (C) 2009-2015, 2018 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +/** + * @author Christian Grothoff + * + * @file + * API for the ATS solvers. + * + * @defgroup ats-plugin ATS service plugin API + * Plugin API for the ATS service. + * + * Specifies the struct that is given to the plugin's entry method and the other + * struct that must be returned. Note that the destructors of ATS plugins will + * be given the value returned by the constructor and is expected to return a + * NULL pointer. + * + * @{ + */ +#ifndef PLUGIN_ATS_H +#define PLUGIN_ATS_H + +#include "gnunet_mq_lib.h" +#include "gnunet_bandwidth_lib.h" +#include "gnunet_ats_application_service.h" +#include "gnunet_ats_transport_service.h" +#include "gnunet_statistics_service.h" + + +/** + * Preference being expressed by an application client. + */ +struct GNUNET_ATS_Preference { + + /** + * Peer to get address suggestions for. + */ + struct GNUNET_PeerIdentity peer; + + /** + * How much bandwidth in bytes/second does the application expect? + */ + struct GNUNET_BANDWIDTH_Value32NBO bw; + + /** + * What type of performance preference does the client have? + */ + enum GNUNET_MQ_PreferenceKind pk; +}; + + +/** + * Opaque representation of a session the plugin can allocate bandwidth for. + */ +struct GNUNET_ATS_Session; + +/** + * Plugin-relevant information about a session. + */ +struct GNUNET_ATS_SessionData { + + /** + * Peer the session is with. + */ + struct GNUNET_PeerIdentity peer; + + /** + * ATS performance characteristics for a session. + */ + struct GNUNET_ATS_Properties prop; + + /** + * Handle to the session that has the given properties. + */ + struct GNUNET_ATS_Session *session; + + /** + * Is the session inbound only? + */ + int inbound_only; + +}; + +/** + * Internal representation of a preference by the plugin. + * (If desired, plugin may just use NULL.) + */ +struct GNUNET_ATS_PreferenceHandle; + +/** + * Internal representation of a session by the plugin. + * (If desired, plugin may just use NULL.) + */ +struct GNUNET_ATS_SessionHandle; + + +/** + * Solver functions. + * + * Each solver is required to set up and return an instance + * of this struct during initialization. + */ +struct GNUNET_ATS_SolverFunctions +{ + + /** + * Closure to pass to all solver functions in this struct. + */ + void *cls; + + /** + * The plugin should begin to respect a new preference. + * + * @param cls the closure + * @param pref the preference to add + * @return plugin's internal representation, or NULL + */ + struct GNUNET_ATS_PreferenceHandle * + (*preference_add)(void *cls, + const struct GNUNET_ATS_Preference *pref); + + /** + * The plugin should end respecting a preference. + * + * @param cls the closure + * @param ph whatever @e preference_add returned + * @param pref the preference to delete + * @return plugin's internal representation, or NULL + */ + void + (*preference_del)(void *cls, + struct GNUNET_ATS_PreferenceHandle *ph, + const struct GNUNET_ATS_Preference *pref); + + + struct GNUNET_ATS_SessionHandle * + (*session_add)(void *cls, + const struct GNUNET_ATS_SessionData *data); + + void + (*session_update)(void *cls, + struct GNUNET_ATS_SessionHandle *sh, + const struct GNUNET_ATS_SessionData *data); + + void + (*session_del)(void *cls, + struct GNUNET_ATS_SessionHandle *sh, + const struct GNUNET_ATS_SessionData *data); + +}; + +#endif + +/** @} */ /* end of group */ diff --git a/src/include/gnunet_ats_transport_service.h b/src/include/gnunet_ats_transport_service.h index b55c6a374..0df703712 100644 --- a/src/include/gnunet_ats_transport_service.h +++ b/src/include/gnunet_ats_transport_service.h @@ -39,7 +39,7 @@ /** - * ATS performance characteristics for an address. + * ATS performance characteristics for a session. */ struct GNUNET_ATS_Properties { diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index bd9ce7bb2..a06d697f7 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h @@ -1580,9 +1580,10 @@ struct GNUNET_CONTAINER_MultiHashMap32Iterator; * iterate, * #GNUNET_NO if not. */ -typedef int (*GNUNET_CONTAINER_HashMapIterator32) (void *cls, - uint32_t key, - void *value); +typedef int +(*GNUNET_CONTAINER_HashMapIterator32) (void *cls, + uint32_t key, + void *value); /** @@ -1604,8 +1605,7 @@ GNUNET_CONTAINER_multihashmap32_create (unsigned int len); * @param map the map */ void -GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32 - *map); +GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32 *map); /** -- cgit v1.2.3