-fixed _clear() in peers "helper"
[oweals/gnunet.git] / src / conversation / conversation.h
index 1f30b21bf13b644687deaa3d3901888a4ea5da35..da7bb53c8500af416ae40225aaf7fee68c478aef 100644 (file)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet.
-     (C) 
+     Copyright (C) 2013 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
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -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,372 +39,332 @@ extern "C"
 #define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 
-/************************************************************************************************************************
-* Messages for the Client <-> Server communication
-*/
-
-
 /**
- * VoipClient.
+ * Message to transmit the audio (between client and helpers).
  */
-struct VoipClient
+struct AudioMessage
 {
   /**
-   * Handle for a conversation client.
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
    */
-  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;
+  struct GNUNET_MessageHeader header;
 
-       /**
-       * The time the call was
-       */
-  struct GNUNET_TIME_Absolute time;
+  /* followed by audio data */
 
 };
 
 
-
-
 /**
- * Client <-> Server message to initiate a new call
+ * Client -> Service message to register a phone.
  */
-struct ClientServerSessionInitiateMessage
+struct ClientPhoneRegisterMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_INITIATE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
+
+  /**
+   * Phone line to register.
+   */
+  uint32_t line GNUNET_PACKED;
 };
 
 
 /**
- * Client <-> Server meessage to accept an incoming call
+ * Service -> Client message for phone is ringing.
  */
-struct ClientServerSessionAcceptMessage
+struct ClientPhoneRingMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_ACCEPT 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
    */
   struct GNUNET_MessageHeader header;
-};
 
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
 
-/**
- * Client <-> Server message to reject an incoming call
- */
-struct ClientServerSessionRejectMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_REJECT
+   * Who is calling us?
    */
-  struct GNUNET_MessageHeader header;
-  int reason;
+  struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
+
 };
 
 
 /**
- * Client <-> Server message to terminat a call
+ * Service <-> Client message for phone was suspended.
  */
-struct ClientServerSessionTerminateMessage
+struct ClientPhoneSuspendMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_TERMINATE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
    */
   struct GNUNET_MessageHeader header;
+
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Client <-> Server message to initiate a new call
+ * Service <-> Client message for phone was resumed.
  */
-struct ClientServerTestMessage
+struct ClientPhoneResumeMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_TEST 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
+
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
+
 };
 
-/************************************************************************************************************************
-* Messages for the Server <-> Client communication
-*/
 
 /**
- * Server <-> Client message to initiate a new call
+ * Client -> Service pick up phone that is ringing.
  */
-struct ServerClientSessionInitiateMessage
+struct ClientPhonePickupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_INITIATE
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
    */
   struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
+
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Server <-> Client meessage to accept an incoming call
+ * Client <-> Service hang up phone that may or may not be ringing.
+ * Also sent in response to a (failed) `struct ClientCallMessage`.
  */
-struct ServerClientSessionAcceptMessage
+struct ClientPhoneHangupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_ACCEPT 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
    */
   struct GNUNET_MessageHeader header;
+
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * talking about.
+   */
+  uint32_t cid GNUNET_PACKED;
+
 };
 
 
 /**
- * Server <-> Client message to reject an incoming call
+ * Message Client <->Service to transmit the audio.
  */
-struct ServerClientSessionRejectMessage
+struct ClientAudioMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_REJECT 
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
    */
   struct GNUNET_MessageHeader header;
-  int reason;
-  int notify;
+
+  /**
+   * CID, internal caller ID to identify which active call we are
+   * sending data to.
+   */
+  uint32_t cid GNUNET_PACKED;
+
+  /* followed by audio data */
+
 };
 
 
 /**
- * Server <-> Client message to terminat a call
+ * Client -> Service message to call a phone.
  */
-struct ServerClientSessionTerminateMessage
+struct ClientCallMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_TERMINATE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
    */
   struct GNUNET_MessageHeader header;
-};
 
+  /**
+   * Which phone line to call at the peer?
+   */
+  uint32_t line GNUNET_PACKED;
 
-/**
- * Server <-> Client message to signalize the client that the service is already in use
- */
-struct ServerClientServiceBlockedMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SERVICE_BLOCKED
+   * Which peer is hosting the line?
    */
-  struct GNUNET_MessageHeader header;
-};
+  struct GNUNET_PeerIdentity target;
 
-/**
- * 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 
+   * Identity of the caller.
    */
-  struct GNUNET_MessageHeader header;
+  struct GNUNET_CRYPTO_EcdsaPrivateKey caller_id;
 };
 
 
 /**
- * Server <-> Client message to signalize the client that called peer does not answer
+ * Service -> Client: other peer has picked up the phone, we are
+ * now talking.
  */
-struct ServerClientNoAnswerMessage
+struct ClientPhonePickedupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_NO_ANSWER
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
    */
   struct GNUNET_MessageHeader header;
+
 };
 
+
 /**
- * Server <-> Client message to notify client of missed call
+ * Cadet message for phone is ringing.
  */
-struct ServerClientMissedCallMessage
+struct CadetPhoneRingMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_MISSED_CALL 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
    */
   struct GNUNET_MessageHeader header;
-  int number;
-  struct MissedCall *missed_call;
-};
 
+  /**
+   * Desired target line.
+   */
+  uint32_t remote_line 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 
+   * Purpose for the signature.
    */
-  struct GNUNET_MessageHeader header;
-};
+  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
 
+  /**
+   * Who is calling us? (also who is signing).
+   */
+  struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
 
-/**
- * Server <-> Client message to notify client of peer being available
- */
-struct ServerClientPeerAvailableMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_PEER_AVAILABLE
+   * Who are we calling?
    */
-  struct GNUNET_MessageHeader header;
-  struct GNUNET_PeerIdentity peer;
-  struct GNUNET_TIME_Absolute time;
-};
+  struct GNUNET_PeerIdentity target;
 
-/************************************************************************************************************************
-* Messages for the Mesh communication
-*/
+  /**
+   * From where are we calling?
+   */
+  struct GNUNET_PeerIdentity source;
 
-struct VoIPMeshMessageHeader
-{
   /**
-   * Type is: 
+   * When does the signature expire?
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-};
+  struct GNUNET_TIME_AbsoluteNBO expiration_time;
 
+  /**
+   * Signature on the above.
+   */
+  struct GNUNET_CRYPTO_EcdsaSignature signature;
 
-/**
- * Mesh message to sinal the remote peer the wish to initiate a new call
- */
-struct MeshSessionInitiateMessage
-{
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_INITIATE
+   * Source line for audio data in the other direction.
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  struct GNUNET_PeerIdentity peer;
+  uint32_t source_line GNUNET_PACKED;
+
 };
 
+
 /**
- * Mesh message to signal the remote peer the acceptance of an initiated call
+ * Cadet message for hanging up.
  */
-struct MeshSessionAcceptMessage
+struct CadetPhoneHangupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_ACCEPT
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
    */
   struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
+
 };
 
 
 /**
- * Mesh message to reject an a wish to initiate a new call
+ * Cadet message for picking up.
  */
-struct MeshSessionRejectMessage
+struct CadetPhonePickupMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_REJECT 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
    */
   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
+ * Cadet message for phone suspended.
  */
-struct MeshSessionTerminateMessage
+struct CadetPhoneSuspendMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_TERMINATE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
    */
   struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
+
 };
 
 
 /**
- * Server <-> Client message to notify client of peer being available
+ * Cadet message for phone resumed.
  */
-struct MeshPeerAvailableMessage
+struct CadetPhoneResumeMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PEER_AVAILABLE 
+   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
    */
   struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  struct GNUNET_PeerIdentity peer;
-  struct GNUNET_TIME_Absolute call;
+
 };
 
 
 /**
- * Messages for the audio communication
+ * Cadet message to transmit the audio.
  */
-struct TestMessage
+struct CadetAudioMessage
 {
   /**
-   * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_TEST 
+   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
    */
   struct GNUNET_MessageHeader header;
-};
 
+  /**
+   * Target line on the receiving end.
+   */
+  uint32_t remote_line GNUNET_PACKED;
 
-/**
- * Message to transmit the audio
- */
-struct AudioMessage
-{
   /**
-   * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
+   * The source line sending this data
    */
-  struct GNUNET_MessageHeader header;
-  int SequenceNumber;
-  struct GNUNET_TIME_Absolute time;
-  int length;
-  int encrypted;
-  uint8_t audio[200];
+  uint32_t source_line GNUNET_PACKED;
+
+  /* followed by audio data */
 
 };
 
 
+
 #if 0                          /* keep Emacsens' auto-indent happy */
 {
 #endif