Support normal socket (non-NSP) name lookups in resolver (for testing)
[oweals/gnunet.git] / src / exit / exit.h
index 37ae7e8a450da050414c196b5f7c296c69dda008..b4cea4c23fafe962c7dc31ba1cc9938ecf2afcb2 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "gnunet_util_lib.h"
 
+GNUNET_NETWORK_STRUCT_BEGIN
+
 /**
  * Message send via mesh to an exit daemon to initiate forwarding of
  * TCP data to a local service.
@@ -42,18 +44,18 @@ struct GNUNET_EXIT_TcpServiceStartMessage
   /**
    * Always 0.
    */
-  uint32_t reserved;
+  uint32_t reserved GNUNET_PACKED;
 
   /**
    * Identification for the desired service.
    */
-  GNUNET_HashCode service_descriptor;
+  struct GNUNET_HashCode service_descriptor;
 
   /**
    * Skeleton of the TCP header to send.  Port numbers are to
    * be replaced and the checksum may be updated as necessary.
    */
-  struct tcp_packet tcp_header;
+  struct GNUNET_TUN_TcpHeader tcp_header;
 
   /* followed by TCP payload */
 };
@@ -73,13 +75,13 @@ struct GNUNET_EXIT_TcpInternetStartMessage
   /**
    * Address family, AF_INET or AF_INET6, in network byte order.
    */
-  int32_t af;
+  int32_t af GNUNET_PACKED;
 
   /**
    * Skeleton of the TCP header to send.  Port numbers are to
    * be replaced and the checksum may be updated as necessary.
    */
-  struct tcp_packet tcp_header;
+  struct GNUNET_TUN_TcpHeader tcp_header;
 
   /* followed by IP address of the destination; either
      'struct in_addr' or 'struct in6_addr', depending on af */
@@ -89,7 +91,7 @@ struct GNUNET_EXIT_TcpInternetStartMessage
 
 
 /**
- * Message send via mesh between VPN and entry and an exit daemon to 
+ * Message send via mesh between VPN and entry and an exit daemon to
  * transmit TCP data between the VPN entry and an exit session.  This
  * format is used for both Internet-exits and service-exits and
  * in both directions (VPN to exit and exit to VPN).
@@ -104,13 +106,13 @@ struct GNUNET_EXIT_TcpDataMessage
   /**
    * Always 0.
    */
-  uint32_t reserved;
+  uint32_t reserved GNUNET_PACKED;
 
   /**
    * Skeleton of the TCP header to send.  Port numbers are to
    * be replaced and the checksum may be updated as necessary.  (The destination port number should not be changed, as it contains the desired destination port.)
    */
-  struct tcp_packet tcp_header;
+  struct GNUNET_TUN_TcpHeader tcp_header;
 
   /* followed by TCP payload */
 };
@@ -128,14 +130,19 @@ struct GNUNET_EXIT_UdpServiceMessage
   struct GNUNET_MessageHeader header;
 
   /**
-   * Always 0.
+   * Source port to use for the UDP request (0 to use a random port).  In NBO.
+   */
+  uint16_t source_port GNUNET_PACKED;
+
+  /**
+   * Destination port to use for the UDP request.  In NBO.
    */
-  uint32_t reserved;
+  uint16_t destination_port GNUNET_PACKED;
 
   /**
    * Identification for the desired service.
    */
-  GNUNET_HashCode service_descriptor;
+  struct GNUNET_HashCode service_descriptor;
 
   /* followed by UDP payload */
 };
@@ -155,8 +162,17 @@ struct GNUNET_EXIT_UdpInternetMessage
   /**
    * Address family, AF_INET or AF_INET6, in network byte order.
    */
-  int32_t af;
+  int32_t af GNUNET_PACKED;
 
+  /**
+   * Source port to use for the UDP request (0 to use a random port).  In NBO.
+   */
+  uint16_t source_port GNUNET_PACKED;
+
+  /**
+   * Destination port to use for the UDP request.  In NBO.
+   */
+  uint16_t destination_port GNUNET_PACKED;
 
   /* followed by IP address of the destination; either
      'struct in_addr' or 'struct in6_addr', depending on af */
@@ -180,16 +196,118 @@ struct GNUNET_EXIT_UdpReplyMessage
    * Source port to use for the UDP reply (0 to use the same
    * port as for the original request).  In NBO.
    */
-  uint16_t source_port;
+  uint16_t source_port GNUNET_PACKED;
 
   /**
    * Destination port to use for the UDP reply (0 to use the same
    * port as for the original request).  In NBO.
-   */   
-  uint16_t destination_port;
+   */
+  uint16_t destination_port GNUNET_PACKED;
 
   /* followed by UDP payload */
 };
 
 
+/**
+ * Message send via mesh to an exit daemon to send
+ * ICMP data to a local service.
+ */
+struct GNUNET_EXIT_IcmpServiceMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Address family, AF_INET or AF_INET6, in network byte order.  This
+   * AF value determines if the 'icmp_header' is ICMPv4 or ICMPv6.
+   * The receiver (exit) may still have to translate (PT) to the services'
+   * ICMP version (if possible).
+   */
+  int32_t af GNUNET_PACKED;
+
+  /**
+   * Identification for the desired service.
+   */
+  struct GNUNET_HashCode service_descriptor;
+
+  /**
+   * ICMP header to use.
+   */
+  struct GNUNET_TUN_IcmpHeader icmp_header;
+
+  /* followed by ICMP payload; however, for certain ICMP message
+     types where the payload is the original IP packet, the payload
+     is omitted as it is useless for the receiver (who will need
+     to create some fake payload manually)  */
+};
+
+
+/**
+ * Message send via mesh to an exit daemon to forward
+ * ICMP data to the Internet.
+ */
+struct GNUNET_EXIT_IcmpInternetMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Address family, AF_INET or AF_INET6, in network byte order.
+   * Determines both the ICMP version used in the 'icmp_header' and
+   * the IP address format that is used for the target IP.  If
+   * PT is necessary, the sender has already done it.
+   */
+  int32_t af GNUNET_PACKED;
+
+  /**
+   * ICMP header to use.  Must match the target 'af' given
+   * above.
+   */
+  struct GNUNET_TUN_IcmpHeader icmp_header;
+
+  /* followed by IP address of the destination; either
+     'struct in_addr' or 'struct in6_addr', depending on af */
+
+  /* followed by ICMP payload; however, for certain ICMP message
+     types where the payload is the original IP packet, the payload
+     is omitted as it is useless for the receiver (who will need
+     to create some fake payload manually)   */
+};
+
+
+/**
+ * Message send via mesh to the vpn service to send
+ * ICMP data to the VPN's TUN interface.
+ */
+struct GNUNET_EXIT_IcmpToVPNMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Address family, AF_INET or AF_INET6, in network byte order.
+   * Useful to determine if this is an ICMPv4 or ICMPv6 header.
+   */
+  int32_t af GNUNET_PACKED;
+
+  /**
+   * ICMP header to use.  ICMPv4 or ICMPv6, depending on 'af'.
+   */
+  struct GNUNET_TUN_IcmpHeader icmp_header;
+
+  /* followed by ICMP payload; however, for certain ICMP message
+     types where the payload is the original IP packet, the payload
+     is omitted as it is useless for the receiver (who will need
+     to create some fake payload manually) */
+};
+
+
+GNUNET_NETWORK_STRUCT_END
+
 #endif