-better logging in NAT
[oweals/gnunet.git] / src / nat / nat.h
index 3a0f21e7b9a24bcfb4e372ce866341e8280b89d7..a0ef4659337e6bc1cf334f93210b2547da84c7cb 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2011 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
 */
 
 /**
- * @file nat/nat.h
- * @brief Library handling UPnP and NAT-PMP port forwarding and
- *     external IP address retrieval
- * @author Milan Bouchet-Valat
+ * @file src/nat/nat.h
+ * @brief Messages for interaction with gnunet-nat-server
+ * @author Christian Grothoff
+ *
  */
-
 #ifndef NAT_H
 #define NAT_H
+#include "gnunet_util_lib.h"
+
 
-#define DEBUG GNUNET_YES
+GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
- * Used to communicate with the UPnP and NAT-PMP plugins 
+ * Request to test NAT traversal.
  */
-enum GNUNET_NAT_PortState
+struct GNUNET_NAT_TestMessage
 {
-  GNUNET_NAT_PORT_ERROR,
-
-    /**
-     * the port isn't forwarded 
-     */
-  GNUNET_NAT_PORT_UNMAPPED,
-
-    /**
-     * we're cancelling the port forwarding 
-     */
-  GNUNET_NAT_PORT_UNMAPPING,
+  /**
+   * Header with type "GNUNET_MESSAGE_TYPE_NAT_TEST"
+   */
+  struct GNUNET_MessageHeader header;
 
-    /**
-     * we're in the process of trying to set up port forwarding 
-     */
-  GNUNET_NAT_PORT_MAPPING,
+  /**
+   * IPv4 target IP address
+   */
+  uint32_t dst_ipv4;
 
-    /**
-     * we've successfully forwarded the port 
-     */
-  GNUNET_NAT_PORT_MAPPED
-};
+  /**
+   * Port to use, 0 to send dummy ICMP response.
+   */
+  uint16_t dport;
 
+  /**
+   * Data to send OR advertised-port (in NBO) to use for dummy ICMP.
+   */
+  uint16_t data;
 
-/**
- * Compare the sin(6)_addr fields of AF_INET or AF_INET(6) sockaddr.
- * 
- * @param a first sockaddr
- * @param b second sockaddr
- * @return 0 if addresses are equal, non-null value otherwise 
- */
-int GNUNET_NAT_cmp_addr (const struct sockaddr *a, const struct sockaddr *b);
+  /**
+   * GNUNET_YES for TCP, GNUNET_NO for UDP.
+   */
+  int32_t is_tcp;
 
+};
+GNUNET_NETWORK_STRUCT_END
 
 #endif