SET service: accurate results for symmetric mode
[oweals/gnunet.git] / src / include / gnunet_transport_plugin.h
index 0139ca2b0142db83028474496579b1cec5335ff2..0b0be1fb978c45b858c27b0b94467c528a94b469 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2009-2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      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.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
  */
 struct Session;
 
-/**
- * Every `struct Session` must begin with this header.
- */
-struct SessionHeader
-{
-  /* empty, for now */
-};
-
 
 /**
  * Function that will be called whenever the plugin internally
@@ -81,21 +73,21 @@ typedef void
                                 const struct GNUNET_HELLO_Address *address,
                                 struct Session *session);
 
+
 /**
  * Plugin tells transport service about a new inbound session
  *
  * @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,
+                                  const struct GNUNET_HELLO_Address *address,
                                   struct Session *session,
-                                  const struct GNUNET_ATS_Information *ats,
-                                  uint32_t ats_count);
+                                  enum GNUNET_ATS_Network_Type net);
+
 
 /**
  * Function called by the transport for each received message.
@@ -127,37 +119,33 @@ typedef struct GNUNET_TIME_Relative
 
 
 /**
- * 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 ATS Information containing the network type
+ * @return type of the network the address belongs to
  */
-typedef struct GNUNET_ATS_Information
+typedef enum GNUNET_ATS_Network_Type
 (*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
@@ -196,25 +184,6 @@ typedef struct GNUNET_TIME_Relative
                                    size_t amount_recved);
 
 
-/**
- * FIXME: document!
- */
-typedef void
-(*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls,
-                                               const struct GNUNET_PeerIdentity *peer,
-                                               const char *plugin,
-                                               struct Session *session);
-
-
-/**
- * FIXME: document!
- */
-typedef void
-(*GNUNET_TRANSPORT_UnregisterQuotaNotification) (void *cls,
-                                                 const struct GNUNET_PeerIdentity *peer,
-                                                 const char *plugin,
-                                                 struct Session *session);
-
 /**
  * Function that returns a HELLO message.
  *
@@ -292,20 +261,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!
-   */
-  GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_notification;
-
-  /**
-   * FIXME: document!
+   * Function that will be called by DV to update distance for
+   * an address.
    */
-  GNUNET_TRANSPORT_UnregisterQuotaNotification unregister_quota_notification;
+  GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance;
 
   /**
    * What is the maximum number of connections that this transport
@@ -524,7 +483,6 @@ typedef void
                                           struct Session *session);
 
 
-
 /**
  * Function that will be called whenever the transport service wants to
  * notify the plugin that the inbound quota changed and that the plugin
@@ -581,7 +539,7 @@ 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
  */
@@ -590,79 +548,6 @@ typedef enum GNUNET_ATS_Network_Type
                                     struct Session *session);
 
 
-/**
- * Possible states of a session in a plugin.
- */
-enum GNUNET_TRANSPORT_SessionState
-{
-  /**
-   * Session is being torn down and about to disappear.
-   */
-  GNUNET_TRANSPORT_SS_DOWN,
-
-  /**
-   * Initial session handshake is in progress.
-   */
-  GNUNET_TRANSPORT_SS_HANDSHAKE,
-
-  /**
-   * Session is fully UP.
-   */
-  GNUNET_TRANSPORT_SS_UP
-
-};
-
-
-/**
- * Information about a plugin's session.
- */
-struct GNUNET_TRANSPORT_SessionInfo
-{
-
-  /**
-   * New state of the session.
-   */
-  enum GNUNET_TRANSPORT_SessionState state;
-
-  /**
-   * #GNUNET_YES if this is an inbound connection,
-   * #GNUNET_NO if this is an outbound connection,
-   * #GNUNET_SYSERR if connections of this plugin
-   *             are so fundamentally bidirectional
-   *             that they have no 'initiator'
-   */
-  int is_inbound;
-
-  /**
-   * Number of messages pending transmission for this session.
-   */
-  unsigned int num_msg_pending;
-
-  /**
-   * Number of bytes pending transmission for this session.
-   */
-  unsigned int num_bytes_pending;
-
-  /**
-   * Until when does this plugin refuse to receive to manage
-   * staying within the inbound quota?  ZERO if receive is
-   * active.
-   */
-  struct GNUNET_TIME_Absolute receive_delay;
-
-  /**
-   * At what time will this session timeout (unless activity
-   * happens)?
-   */
-  struct GNUNET_TIME_Absolute session_timeout;
-
-  /**
-   * Address used by the session.  Can be NULL if none is available.
-   */
-  const struct GNUNET_HELLO_Address *address;
-};
-
-
 /**
  * Function called by the plugin with information about the
  * current sessions managed by the plugin (for monitoring).
@@ -785,7 +670,7 @@ struct GNUNET_TRANSPORT_PluginFunctions
 
   /**
    * Function that will be called tell the plugin to create a session
-   * object
+   * object.
    */
   GNUNET_TRANSPORT_CreateSession get_session;