REST: nothing triggers rest
[oweals/gnunet.git] / src / nat / nat.h
index e7bee54c02680a7ed52eaa08fb9300c68415d98b..86de3c2f637e23dfa48cf9c374e48d05fecda3c7 100644 (file)
@@ -1,21 +1,21 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2011 GNUnet e.V.
+     Copyright (C) 2011, 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
-     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., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
@@ -29,6 +29,7 @@
 #include "gnunet_util_lib.h"
 
 
+
 GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
@@ -66,122 +67,160 @@ struct GNUNET_NAT_TestMessage
 
 
 /**
- *
+ * Flags specifying the events this client would be
+ * interested in being told about.
  */
-struct GNUNET_NAT_RegisterMessage
+enum GNUNET_NAT_RegisterFlags
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER
+   * This client does not want any notifications.
    */
-  struct GNUNET_MessageHeader header;
-};
+  GNUNET_NAT_RF_NONE = 0,
 
+  /**
+   * This client wants to be informed about changes to our
+   * applicable addresses.
+   */
+  GNUNET_NAT_RF_ADDRESSES = 1,
 
-/**
- *
- */
-struct GNUNET_NAT_HandleStunMessage
-{
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN
+   * This client supports address reversal.
    */
-  struct GNUNET_MessageHeader header;
+  GNUNET_NAT_RF_REVERSAL = 2
 };
 
 
 /**
- *
+ * Message sent by a client to register with its addresses.
  */
-struct GNUNET_NAT_RequestConnectionReversalMessage
+struct GNUNET_NAT_RegisterMessage
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL
+   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER
    */
   struct GNUNET_MessageHeader header;
-};
 
+  /**
+   * An `enum GNUNET_NAT_RegisterFlags`.
+   */
+  uint8_t flags;
 
-/**
- *
- */
-struct GNUNET_NAT_ConnectionReversalRequestedMessage
-{
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED
+   * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP.
    */
-  struct GNUNET_MessageHeader header;
-};
+  uint8_t proto;
 
+  /**
+   * Number of bytes in the string that follow which
+   * specifies a section name in the configuration.
+   */
+  uint16_t str_len GNUNET_PACKED;
 
-/**
- *
- */
-struct GNUNET_NAT_AddressChangeNotificationMessage
-{
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE
+   * Number of addresses that this service is bound to that follow.
+   * Given as an array of "struct sockaddr" entries, the size of
+   * each entry being determined by the "sa_family" at the beginning.
    */
-  struct GNUNET_MessageHeader header;
+  uint16_t num_addrs GNUNET_PACKED;
+
+  /* Followed by @e num_addrs addresses of type 'struct
+     sockaddr' */
+
+  /* Followed by @e str_len section name to use for options */
+  
 };
 
 
 /**
- *
+ * Client telling the service to (possibly) handle a STUN message.
  */
-struct GNUNET_NAT_Ipv4ChangeNotificationMessage
+struct GNUNET_NAT_HandleStunMessage
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_IPV4_CHANGE
+   * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN
    */
   struct GNUNET_MessageHeader header;
-};
 
+  /**
+   * Size of the sender address included, in NBO.
+   */
+  uint16_t sender_addr_size;
 
-/**
- *
- */
-struct GNUNET_NAT_RequestTestMessage
-{
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_TEST
+   * Number of bytes of payload included, in NBO.
    */
-  struct GNUNET_MessageHeader header;
+  uint16_t payload_size;
+
+  /* followed by a `struct sockaddr` of @e sender_addr_size bytes */
+
+  /* followed by payload with @e payload_size bytes */
 };
 
 
 /**
- *
+ * Client asking the service to initiate connection reversal.
  */
-struct GNUNET_NAT_TestResultMessage
+struct GNUNET_NAT_RequestConnectionReversalMessage
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST_RESULT
+   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL
    */
   struct GNUNET_MessageHeader header;
+
+  /**
+   * Size of the local address included, in NBO.
+   */
+  uint16_t local_addr_size;
+
+  /**
+   * Size of the remote address included, in NBO.
+   */
+  uint16_t remote_addr_size;
+
+  /* followed by a `struct sockaddr` of @e local_addr_size bytes */
+
+  /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
+
 };
 
 
 /**
- *
+ * Service telling a client that connection reversal was requested.
  */
-struct GNUNET_NAT_AutoconfigRequestMessage
+struct GNUNET_NAT_ConnectionReversalRequestedMessage
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG
+   * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED
    */
   struct GNUNET_MessageHeader header;
+
+  /* followed by a `struct sockaddr_in` */
+  
 };
 
 
 /**
- *
+ * Service notifying the client about changes in the set of 
+ * addresses it has.
  */
-struct GNUNET_NAT_AutoconfigResultMessage
+struct GNUNET_NAT_AddressChangeNotificationMessage
 {
   /**
-   * Header with type #GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT
+   * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE
    */
   struct GNUNET_MessageHeader header;
+
+  /**
+   * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list.
+   */ 
+  int32_t add_remove GNUNET_PACKED;
+
+  /**
+   * Type of the address, an `enum GNUNET_NAT_AddressClass` in NBO.
+   */
+  uint32_t addr_class GNUNET_PACKED;
+  /* followed by a `struct sockaddr` */
+  
 };