-preparatory steps for transport API change
[oweals/gnunet.git] / src / core / core.h
index b76528a8ec275f33d960a4cc6babfedfbcec1647..7c3a5bdd8e0648bd2dd8a09593a8028c7d9a18d8 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2010 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
@@ -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.
 */
 
 /**
  * transmitted to the client.
  */
 #define GNUNET_CORE_OPTION_NOTHING             0
+
+/**
+ * Client cares about connectivity changes.
+ */
 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE  4
+
+/**
+ * Client wants all inbound messages in full.
+ */
 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND   8
+
+/**
+ * Client just wants the 4-byte message headers of
+ * all inbound messages.
+ */
 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND   16
+
+/**
+ * Client wants all outbound messages in full.
+ */
 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
+
+/**
+ * Client just wants the 4-byte message headers of
+ * all outbound messages.
+ */
 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND  64
 
 
+GNUNET_NETWORK_STRUCT_BEGIN
+
 /**
  * Message transmitted core clients to gnunet-service-core
  * to start the interaction.  This header is followed by
@@ -60,7 +84,7 @@ struct InitMessage
 {
 
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT.
    */
   struct GNUNET_MessageHeader header;
 
@@ -80,7 +104,7 @@ struct InitReplyMessage
 {
 
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
    */
   struct GNUNET_MessageHeader header;
 
@@ -104,15 +128,14 @@ struct InitReplyMessage
 struct ConnectNotifyMessage
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Number of ATS key-value pairs that follow this struct
-   * (excluding the 0-terminator).
+   * Always zero.
    */
-  uint32_t ats_count GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
   /**
    * Identity of the connecting peer.
@@ -122,52 +145,6 @@ struct ConnectNotifyMessage
 };
 
 
-/**
- * Message sent by the service to clients to notify them
- * about a peer changing status.
- */
-struct PeerStatusNotifyMessage
-{
-  /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * Number of ATS key-value pairs that follow this struct
-   * (excluding the 0-terminator).
-   */
-  uint32_t ats_count GNUNET_PACKED;
-
-  /**
-   * When the peer would time out (unless we see activity)
-   */
-  struct GNUNET_TIME_AbsoluteNBO timeout;
-
-  /**
-   * Available bandwidth from the peer.
-   */
-  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
-
-  /**
-   * Available bandwidth to the peer.
-   */
-  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
-
-  /**
-   * Identity of the peer.
-   */
-  struct GNUNET_PeerIdentity peer;
-
-  /**
-   * First of the ATS information blocks (we must have at least
-   * one due to the 0-termination requirement).
-   */
-  struct GNUNET_ATS_Information ats;
-
-};
-
-
 /**
  * Message sent by the service to clients to notify them
  * about a peer disconnecting.
@@ -175,7 +152,7 @@ struct PeerStatusNotifyMessage
 struct DisconnectNotifyMessage
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
    */
   struct GNUNET_MessageHeader header;
 
@@ -204,28 +181,17 @@ struct DisconnectNotifyMessage
 struct NotifyTrafficMessage
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
-   * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
+   * or #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
    */
   struct GNUNET_MessageHeader header;
 
-  /**
-   * Number of ATS key-value pairs that follow this struct
-   * (excluding the 0-terminator).
-   */
-  uint32_t ats_count GNUNET_PACKED;
-
   /**
    * Identity of the receiver or sender.
    */
   struct GNUNET_PeerIdentity peer;
 
-  /**
-   * First of the ATS information blocks (we must have at least
-   * one due to the 0-termination requirement).
-   */
-  struct GNUNET_ATS_Information ats;
-
+  /* Followed by payload (message or just header), variable size */
 };
 
 
@@ -236,7 +202,7 @@ struct NotifyTrafficMessage
 struct SendMessageRequest
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
    */
   struct GNUNET_MessageHeader header;
 
@@ -257,9 +223,9 @@ struct SendMessageRequest
   struct GNUNET_PeerIdentity peer;
 
   /**
-   * How large is the client's message queue for this peer?
+   * Always zero.
    */
-  uint32_t queue_size GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
   /**
    * How large is the message?
@@ -277,12 +243,12 @@ struct SendMessageRequest
 /**
  * Core notifying client that it is allowed to now
  * transmit a message to the given target
- * (response to GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
+ * (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
  */
 struct SendMessageReady
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_READY
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_READY
    */
   struct GNUNET_MessageHeader header;
 
@@ -309,12 +275,12 @@ struct SendMessageReady
 
 /**
  * Client asking core to transmit a particular message to a particular
- * target (response to GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
+ * target (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
  */
 struct SendMessage
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND
    */
   struct GNUNET_MessageHeader header;
 
@@ -330,49 +296,52 @@ struct SendMessage
   struct GNUNET_TIME_AbsoluteNBO deadline;
 
   /**
-   * Identity of the receiver or sender.
+   * Identity of the intended receiver.
    */
   struct GNUNET_PeerIdentity peer;
 
   /**
-   * GNUNET_YES if corking is allowed, GNUNET_NO if not.
+   * #GNUNET_YES if corking is allowed, #GNUNET_NO if not.
    */
   uint32_t cork GNUNET_PACKED;
 
   /**
    * Always 0.
    */
-  uint64_t reserved GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
 };
 
 
 /**
- * Client asking core to connect to a particular target.  There is no
- * response from the core to this type of request (however, if an
- * actual connection is created or destroyed, be it because of this
- * type request or not, the core generally needs to notify the
- * clients).
+ * Message sent by the service to monitor clients to notify them
+ * about a peer changing status.
  */
-struct ConnectMessage
+struct MonitorNotifyMessage
 {
   /**
-   * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
-   * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
+   * Header with type #GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * For alignment.
+   * New peer state, an `enum GNUNET_CORE_KxState` in NBO.
    */
-  uint32_t reserved GNUNET_PACKED;
+  uint32_t state GNUNET_PACKED;
 
   /**
-   * Identity of the other peer.
+   * Identity of the peer.
    */
   struct GNUNET_PeerIdentity peer;
 
+  /**
+   * How long will we stay in this state (if nothing else happens)?
+   */
+  struct GNUNET_TIME_AbsoluteNBO timeout;
+
 };
 
+
+GNUNET_NETWORK_STRUCT_END
 #endif
 /* end of core.h */