RECLAIM/OIDC: code cleanup
[oweals/gnunet.git] / src / include / gnunet_transport_plugin.h
index 90d6ed2c6c430b724eeca844b84e1f91a58c9d01..ed5244987cea13464e10e685a8fe727b90d7498b 100644 (file)
@@ -1,32 +1,37 @@
 /*
      This file is part of GNUnet
-     (C) 2009-2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2014 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     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
-     General Public License for more details.
+     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 <http://www.gnu.org/licenses/>.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
- * @file include/gnunet_transport_plugin.h
- * @brief API for the transport services.  This header
- *        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 transport plugins will
- *        be given the value returned by the constructor
- *        and is expected to return a NULL pointer.
  * @author Christian Grothoff
+ *
+ * @file
+ * Transport service plugin API
+ *
+ * @defgroup transport-plugin  Transport Service plugin API
+ *
+ * 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 transport plugins
+ * will be given the value returned by the constructor and is expected to return
+ * a NULL pointer.
+ *
+ * @{
  */
 #ifndef PLUGIN_TRANSPORT_H
 #define PLUGIN_TRANSPORT_H
  * connection may not have an address that can be used for meaningful
  * distinction between sessions to the same peer.
  *
- * Each 'struct Session' MUST start with the 'struct GNUNET_PeerIdentity'
+ * Each 'struct GNUNET_ATS_Session' MUST start with the 'struct GNUNET_PeerIdentity'
  * of the peer the session is for (which will be used for some error
  * checking by the ATS code).
  */
-struct Session;
+struct GNUNET_ATS_Session;
 
 
 /**
@@ -71,7 +76,7 @@ struct Session;
 typedef void
 (*GNUNET_TRANSPORT_SessionEnd) (void *cls,
                                 const struct GNUNET_HELLO_Address *address,
-                                struct Session *session);
+                                struct GNUNET_ATS_Session *session);
 
 
 /**
@@ -80,15 +85,14 @@ typedef void
  * @param cls unused
  * @param address the address
  * @param session the new session
- * @param ats ats information
- * @param ats_count number of @a ats information
+ * @param net network information
  */
 typedef void
 (*GNUNET_TRANSPORT_SessionStart) (void *cls,
-                                  struct GNUNET_HELLO_Address *address,
-                                  struct Session *session,
-                                  const struct GNUNET_ATS_Information *ats,
-                                  uint32_t ats_count);
+                                  const struct GNUNET_HELLO_Address *address,
+                                  struct GNUNET_ATS_Session *session,
+                                  enum GNUNET_NetworkType net);
+
 
 /**
  * Function called by the transport for each received message.
@@ -115,42 +119,38 @@ typedef void
 typedef struct GNUNET_TIME_Relative
 (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
                                            const struct GNUNET_HELLO_Address *address,
-                                           struct Session *session,
+                                           struct GNUNET_ATS_Session *session,
                                            const struct GNUNET_MessageHeader *message);
 
 
 /**
- * Function that will be called to figure if an address is an
- * loopback, LAN, WAN etc. address
+ * Function that can be called by plugins to figure if an address is
+ * an loopback, LAN or WAN address.   Ultimately invokes
+ * #GNUNET_ATS_address_get_type().
  *
  * @param cls closure
  * @param addr binary address
  * @param addrlen length of the @a addr
  * @return type of the network the address belongs to
  */
-typedef enum GNUNET_ATS_Network_Type
+typedef enum GNUNET_NetworkType
 (*GNUNET_TRANSPORT_AddressToType) (void *cls,
                                    const struct sockaddr *addr,
                                    size_t addrlen);
 
 
 /**
- * Function called when quality properties of an address change.
+ * Function called when distance of an address changes.
  *
  * @param cls closure
  * @param peer peer
- * @param address address
- * @param address_len length of the @a address
- * @param session session
- * @param ats ATS information
- * @param ats_count number entries in the @a ats array
+ * @param distance new distance
  */
 typedef void
-(*GNUNET_TRANSPORT_UpdateAddressMetrics) (void *cls,
-                                         const struct GNUNET_HELLO_Address *address,
-                                         struct Session *session,
-                                         const struct GNUNET_ATS_Information *ats,
-                                         uint32_t ats_count);
+(*GNUNET_TRANSPORT_UpdateAddressDistance) (void *cls,
+                                           const struct GNUNET_HELLO_Address *address,
+                                           uint32_t distance);
+
 
 /**
  * Function that will be called for each address the transport
@@ -189,38 +189,6 @@ typedef struct GNUNET_TIME_Relative
                                    size_t amount_recved);
 
 
-/**
- * Function to be called by the plugin to be notified about changes to the quota
- * for a specific peer, plugin and session
- *
- * @param cls closure
- * @param peer the peer to be notified about
- * @param plugin the plugin to be notified about
- * @param session the session for include in the notification
- *
- */
-typedef void
-(*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls,
-                                               const struct GNUNET_PeerIdentity *peer,
-                                               const char *plugin,
-                                               struct Session *session);
-
-
-/**
- * Function to be called by the plugin to stop notification about changes to the quota
- * for a specific peer, plugin and session
- *
- * @param cls closure
- * @param peer the peer to be notified about
- * @param plugin the plugin to be notified about
- * @param session the session for include in the notification
- */
-typedef void
-(*GNUNET_TRANSPORT_UnregisterQuotaNotification) (void *cls,
-                                                 const struct GNUNET_PeerIdentity *peer,
-                                                 const char *plugin,
-                                                 struct Session *session);
-
 /**
  * Function that returns a HELLO message.
  *
@@ -298,20 +266,10 @@ struct GNUNET_TRANSPORT_PluginEnvironment
   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;
-
-  /**
-   * FIXME: document!
+   * Function that will be called by DV to update distance for
+   * an address.
    */
-  GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_notification;
-
-  /**
-   * FIXME: document!
-   */
-  GNUNET_TRANSPORT_UnregisterQuotaNotification unregister_quota_notification;
+  GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance;
 
   /**
    * What is the maximum number of connections that this transport
@@ -381,7 +339,7 @@ typedef void
  */
 typedef ssize_t
 (*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
-                                      struct Session *session,
+                                      struct GNUNET_ATS_Session *session,
                                       const char *msgbuf,
                                       size_t msgbuf_size,
                                       unsigned int priority,
@@ -404,7 +362,7 @@ typedef ssize_t
  */
 typedef int
 (*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls,
-                                               struct Session *session);
+                                               struct GNUNET_ATS_Session *session);
 
 
 /**
@@ -510,7 +468,7 @@ typedef int
  * @param address the hello address
  * @return the session if the address is valid, NULL otherwise
  */
-typedef struct Session *
+typedef struct GNUNET_ATS_Session *
 (*GNUNET_TRANSPORT_CreateSession) (void *cls,
                                    const struct GNUNET_HELLO_Address *address);
 
@@ -527,8 +485,7 @@ typedef struct Session *
 typedef void
 (*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls,
                                           const struct GNUNET_PeerIdentity *peer,
-                                          struct Session *session);
-
+                                          struct GNUNET_ATS_Session *session);
 
 
 /**
@@ -544,9 +501,10 @@ typedef void
 typedef void
 (*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls,
                                         const struct GNUNET_PeerIdentity *peer,
-                                        struct Session *session,
+                                        struct GNUNET_ATS_Session *session,
                                         struct GNUNET_TIME_Relative delay);
 
+
 /**
  * Function called for a quick conversion of the binary address to
  * a numeric address.  Note that the caller must not free the
@@ -587,13 +545,25 @@ typedef int
 /**
  * Function to obtain the network type for a session
  *
- * @param cls closure ('struct Plugin*')
+ * @param cls closure (`struct Plugin *`)
  * @param session the session
  * @return the network type
  */
-typedef enum GNUNET_ATS_Network_Type
+typedef enum GNUNET_NetworkType
 (*GNUNET_TRANSPORT_GetNetworkType) (void *cls,
-                                    struct Session *session);
+                                    struct GNUNET_ATS_Session *session);
+
+
+/**
+ * Function to obtain the network type for an address.
+ *
+ * @param cls closure (`struct Plugin *`)
+ * @param address the address
+ * @return the network type
+ */
+typedef enum GNUNET_NetworkType
+(*GNUNET_TRANSPORT_GetNetworkTypeForAddress) (void *cls,
+                                              const struct GNUNET_HELLO_Address *address);
 
 
 /**
@@ -610,7 +580,7 @@ typedef enum GNUNET_ATS_Network_Type
  */
 typedef void
 (*GNUNET_TRANSPORT_SessionInfoCallback) (void *cls,
-                                         struct Session *session,
+                                         struct GNUNET_ATS_Session *session,
                                          const struct GNUNET_TRANSPORT_SessionInfo *info);
 
 
@@ -718,7 +688,7 @@ struct GNUNET_TRANSPORT_PluginFunctions
 
   /**
    * Function that will be called tell the plugin to create a session
-   * object
+   * object.
    */
   GNUNET_TRANSPORT_CreateSession get_session;
 
@@ -727,6 +697,11 @@ struct GNUNET_TRANSPORT_PluginFunctions
    */
   GNUNET_TRANSPORT_GetNetworkType get_network;
 
+  /**
+   * Function to obtain the network type for an address
+   */
+  GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address;
+
   /**
    * Function to monitor the sessions managed by the plugin.
    */
@@ -736,4 +711,7 @@ struct GNUNET_TRANSPORT_PluginFunctions
 
 /*#ifndef PLUGIN_TRANSPORT_H*/
 #endif
+
+/** @} */  /* end of group */
+
 /* end of gnunet_transport_plugin.h */