Use Suffix Extensions in Makefiles (doc, src/{arm,dht,integration,statistics}) for...
[oweals/gnunet.git] / src / conversation / conversation.h
index f15c48b9a4a19b63a46c691c3b130279e85feb5b..1ca816f0e825cc28e07b4950b0d717c4150d0afb 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013-2016 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.
 */
 
 /**
@@ -39,582 +39,349 @@ extern "C"
 #define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 
-/************************************************************************************************************************
-* Messages for the Client <-> Server communication
-*/
-
-
 /**
- * VoipClient.
+ * Highest bit in a 32-bit unsigned integer,
+ * bit set if we are making an outgoing call,
+ * bit unset for local lines.
  */
-struct VoipClient
-{
-  /**
-   * Handle for a conversation client.
-   */
-  struct GNUNET_SERVER_Client *client;
-};
-
-/**
-* The connection status of the service
-*/
-struct ConnectionStatus
-{
-       /**
-       * The client which is in interaction
-       */
-  struct GNUNET_SERVER_Client *client;
-
-       /**
-       * The PeerIdentity of the peer
-       */
-  struct GNUNET_PeerIdentity peer;
-
-       /**
-       * The status (see enum)
-       */
-  int status;
-};
-
-/**
-* Information about a missed call
-*/
-struct MissedCall
-{
-       /**
-       * The PeerIdentity of the peer
-       */
-  struct GNUNET_PeerIdentity peer;
-
-       /**
-       * The time the call was
-       */
-  struct GNUNET_TIME_Absolute time;
-
-};
-
+#define HIGH_BIT ((uint32_t) (1LL << 31))
 
+GNUNET_NETWORK_STRUCT_BEGIN
 
 
 /**
- * Client <-> Server message to initiate a new call
+ * Message to transmit the audio (between client and helpers).
  */
-struct ClientServerSessionInitiateMessage
+struct AudioMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_INITIATE 
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
-};
 
+  /* followed by audio data */
 
-/**
- * Client <-> Server meessage to accept an incoming call
- */
-struct ClientServerSessionAcceptMessage
-{
-  /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_ACCEPT 
-   */
-  struct GNUNET_MessageHeader header;
 };
 
 
 /**
- * Client <-> Server message to reject an incoming call
+ * Client -> Service message to register a phone.
  */
-struct ClientServerSessionRejectMessage
+struct ClientPhoneRegisterMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_REJECT
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
    */
   struct GNUNET_MessageHeader header;
-  int reason;
-};
-
 
-/**
- * Client <-> Server message to terminat a call
- */
-struct ClientServerSessionTerminateMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_TERMINATE 
+   * Always zero.
    */
-  struct GNUNET_MessageHeader header;
-};
-
+  uint32_t reserved GNUNET_PACKED;
 
-/**
- * Client <-> Server message to initiate a new call
- */
-struct ClientServerTestMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_TEST 
+   * Phone line / CADET port to register.
    */
-  struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
+  struct GNUNET_HashCode line_port;
 };
 
-/************************************************************************************************************************
-* Messages for the Server <-> Client communication
-*/
 
 /**
- * Server <-> Client message to initiate a new call
+ * Service -> Client message for phone is ringing.
  */
-struct ServerClientSessionInitiateMessage
+struct ClientPhoneRingMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_INITIATE
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
-};
 
+  /**
+   * CID, internal caller ID number used in the future to identify
+   * which active call we are talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
 
-/**
- * Server <-> Client meessage to accept an incoming call
- */
-struct ServerClientSessionAcceptMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_ACCEPT 
+   * Who is calling us?
    */
-  struct GNUNET_MessageHeader header;
+  struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
+
 };
 
 
 /**
- * Server <-> Client message to reject an incoming call
+ * Service <-> Client message for phone was suspended.
  */
-struct ServerClientSessionRejectMessage
+struct ClientPhoneSuspendMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_REJECT 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
    */
   struct GNUNET_MessageHeader header;
-  int reason;
-  int notify;
-};
 
-
-/**
- * Server <-> Client message to terminat a call
- */
-struct ServerClientSessionTerminateMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_TERMINATE 
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
    */
-  struct GNUNET_MessageHeader header;
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Server <-> Client message to signalize the client that the service is already in use
+ * Service <-> Client message for phone was resumed.
  */
-struct ServerClientServiceBlockedMessage
+struct ClientPhoneResumeMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SERVICE_BLOCKED
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
    */
   struct GNUNET_MessageHeader header;
-};
 
-/**
- * Server <-> Client message to signalize the client that the called peer is not connected
- */
-struct ServerClientPeerNotConnectedMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_PEER_NOT_CONNECTED 
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
    */
-  struct GNUNET_MessageHeader header;
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Server <-> Client message to signalize the client that called peer does not answer
+ * Client -> Service pick up phone that is ringing.
  */
-struct ServerClientNoAnswerMessage
+struct ClientPhonePickupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_NO_ANSWER
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
    */
   struct GNUNET_MessageHeader header;
-};
 
-/**
- * Server <-> Client message to notify client of missed call
- */
-struct ServerClientMissedCallMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_MISSED_CALL 
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
    */
-  struct GNUNET_MessageHeader header;
-  int number;
-  struct MissedCall *missed_call;
-};
+  uint32_t cid GNUNET_PACKED;
 
-
-/**
- * Server <-> Client message to signalize the client that there occured an error
- */
-struct ServerClientErrorMessage
-{
-  /**
-   * Type is: #define GNUNET_MESSAGE_TYPE_CONVERSATION_SC_ERROR 
-   */
-  struct GNUNET_MessageHeader header;
 };
 
 
 /**
- * Server <-> Client message to notify client of peer being available
+ * Client <-> Service hang up phone that may or may not be ringing.
+ * Also sent in response to a (failed) `struct ClientCallMessage`.
  */
-struct ServerClientPeerAvailableMessage
+struct ClientPhoneHangupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_PEER_AVAILABLE
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
-  struct GNUNET_TIME_Absolute time;
-};
 
-/************************************************************************************************************************
-* Messages for the Mesh communication
-*/
-
-struct VoIPMeshMessageHeader
-{
   /**
-   * Type is: 
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Mesh message to sinal the remote peer the wish to initiate a new call
+ * Message Client <-> Service to transmit the audio.
  */
-struct MeshSessionInitiateMessage
+struct ClientAudioMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_INITIATE
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
    */
   struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  struct GNUNET_PeerIdentity peer;
-};
 
-/**
- * Mesh message to signal the remote peer the acceptance of an initiated call
- */
-struct MeshSessionAcceptMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_ACCEPT
+   * CID, internal caller ID to identify which active call we are
+   * sending data to.
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-};
+  uint32_t cid GNUNET_PACKED;
 
+  /* followed by audio data */
 
-/**
- * Mesh message to reject an a wish to initiate a new call
- */
-struct MeshSessionRejectMessage
-{
-  /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_REJECT 
-   */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  int reason;
-  int notify;
 };
 
 
 /**
- * Mesh message to signal a remote peer the terminatation of a call
+ * Client -> Service message to call a phone.
  */
-struct MeshSessionTerminateMessage
+struct ClientCallMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_TERMINATE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
    */
   struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-};
-
 
-/**
- * Server <-> Client message to notify client of peer being available
- */
-struct MeshPeerAvailableMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PEER_AVAILABLE 
+   * Always zero.
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  struct GNUNET_PeerIdentity peer;
-  struct GNUNET_TIME_Absolute call;
-};
-
+  uint32_t reserved GNUNET_PACKED;
 
-/**
- * Messages for the audio communication
- */
-struct TestMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_TEST 
+   * Which peer is hosting the line?
    */
-  struct GNUNET_MessageHeader header;
-};
-
-////////////////////////////////////////////////////////////
+  struct GNUNET_PeerIdentity target;
 
-/**
- * Message to transmit the audio (between client and helpers).
- */
-struct AudioMessage
-{
   /**
-   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
+   * Which phone line to call at the peer?
    */
-  struct GNUNET_MessageHeader header;
-
-  /* followed by audio data */
+  struct GNUNET_HashCode line_port;
 
+  /**
+   * Identity of the caller.
+   */
+  struct GNUNET_CRYPTO_EcdsaPrivateKey caller_id;
 };
 
 
 /**
- * Client -> Service message to register a phone.
+ * Service -> Client: other peer has picked up the phone, we are
+ * now talking.
  */
-struct ClientPhoneRegisterMessage
+struct ClientPhonePickedupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Phone line to register.
+   * Call ID of the corresponding
+   * #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
    */
-  uint32_t line GNUNET_PACKED;
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Service -> Client message for phone is ringing.
+ * Information signed in a `struct CadetPhoneRingMessage`
+ * whereby the caller self-identifies to the receiver.
  */
-struct ClientPhoneRingMessage
+struct CadetPhoneRingInfoPS
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
+   * Purpose for the signature, must be
+   * #GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING.
    */
-  struct GNUNET_MessageHeader header;
+  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
 
   /**
-   * Always zero.
+   * Which port did the call go to?
    */
-  uint32_t reserved GNUNET_PACKED;
+  struct GNUNET_HashCode line_port;
 
   /**
-   * Who is calling us?
+   * Which peer is the call for?
    */
-  struct GNUNET_CRYPTO_EccPublicSignKey caller_id;
-
-};
-
+  struct GNUNET_PeerIdentity target_peer;
 
-/**
- * Client -> Service pick up phone that is ringing.
- */
-struct ClientPhonePickupMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
+   * When does the signature expire?
    */
-  struct GNUNET_MessageHeader header;
-  
-  /* followed by variable length 0-terminated string with meta data */
-
+  struct GNUNET_TIME_AbsoluteNBO expiration_time;
 };
 
 
 /**
- * Client -> Service hang up phone that may or may not be ringing.
- * Also sent in response to a (failed) `struct ClientCallMessage`.
+ * Cadet message to make a phone ring.  Sent to the port
+ * of the respective phone.
  */
-struct ClientPhoneHangupMessage
+struct CadetPhoneRingMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
    */
   struct GNUNET_MessageHeader header;
-  
-  /* followed by variable length 0-terminated string with meta data */
-
-};
 
-
-/**
- * Message Client <->Service to transmit the audio.
- */
-struct ClientAudioMessage
-{
   /**
-   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
+   * Always zero.
    */
-  struct GNUNET_MessageHeader header;
-
-  /* followed by audio data */
-
-};
-
+  uint32_t reserved GNUNET_PACKED;
 
-/**
- * Client -> Service message to call a phone.
- */
-struct ClientCallMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
+   * Who is calling us? (also who is signing).
    */
-  struct GNUNET_MessageHeader header;
+  struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
 
   /**
-   * Which phone line to call at the peer?
+   * When does the signature expire?
    */
-  uint32_t line GNUNET_PACKED;
+  struct GNUNET_TIME_AbsoluteNBO expiration_time;
 
   /**
-   * Which peer is hosting the line?
+   * Signature over a `struct CadetPhoneRingInfoPS`
    */
-  struct GNUNET_PeerIdentity target;
+  struct GNUNET_CRYPTO_EcdsaSignature signature;
 
-  /**
-   * Identity of the caller.
-   */
-  struct GNUNET_CRYPTO_EccPrivateKey caller_id;
 };
 
 
 /**
- * Service -> Client: other peer has picked up the phone, we are
- * now talking.
+ * Cadet message for hanging up.
  */
-struct ClientPhoneHangupMessage
+struct CadetPhoneHangupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_ESTABLISHED
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
    */
   struct GNUNET_MessageHeader header;
-  
-  /* followed by variable length 0-terminated string with meta data */
 
 };
 
 
 /**
- * Mesh message for phone is ringing.
+ * Cadet message for picking up.
  */
-struct MeshPhoneRingMessage
+struct CadetPhonePickupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
    */
   struct GNUNET_MessageHeader header;
 
-  /**
-   * Desired target line.
-   */
-  uint32_t line GNUNET_PACKED;
-
-  /**
-   * Purpose for the signature.
-   */
-  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
-  /**
-   * Who is calling us? (also who is signing).
-   */
-  struct GNUNET_CRYPTO_EccPublicSignKey caller_id;
-
-  /**
-   * Who are we calling?
-   */
-  struct GNUNET_PeerIdentity target;
-
-  /**
-   * From where are we calling?
-   */
-  struct GNUNET_PeerIdentity source;
-
-  /**
-   * When does the signature expire?
-   */ 
-  struct GNUNET_TIME_AbsoluteNBO expiration_time;
-
-  /**
-   * Signature on the above.
-   */
-  struct GNUNET_CRYPTO_EccSignature signature;
-
 };
 
 
 /**
- * Mesh message for hanging up.
+ * Cadet message for phone suspended.
  */
-struct MeshPhoneHangupMessage
+struct CadetPhoneSuspendMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
    */
   struct GNUNET_MessageHeader header;
 
-  /* followed by variable-size 0-terminated reason string */
 };
 
 
 /**
- * Mesh message for picking up.
+ * Cadet message for phone resumed.
  */
-struct MeshPhonePickupMessage
+struct CadetPhoneResumeMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
    */
   struct GNUNET_MessageHeader header;
 
-  /* followed by variable-size 0-terminated metadata string */
 };
 
 
 /**
- * Mesh message to transmit the audio.
+ * Cadet message to transmit the audio.
  */
-struct MeshAudioMessage
+struct CadetAudioMessage
 {
   /**
-   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
    */
   struct GNUNET_MessageHeader header;
 
@@ -623,6 +390,8 @@ struct MeshAudioMessage
 };
 
 
+GNUNET_NETWORK_STRUCT_END
+
 
 #if 0                          /* keep Emacsens' auto-indent happy */
 {