changes
[oweals/gnunet.git] / src / transport / plugin_transport_http_common.h
index b29801d24d129eec45d5e73a805c1f2da7d643e0..0f83da6b3107b127b069aa63a78fdf9177f30d49 100644 (file)
 #include "platform.h"
 #include "gnunet_common.h"
 
+#define TESTING GNUNET_NO
+
+#if TESTING
+#define TIMEOUT_LOG GNUNET_ERROR_TYPE_ERROR
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define HTTP_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#else
+#define HTTP_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
+#define TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
+#endif
+
 /**
  * Convert the transports address to a nice, human-readable
  * format.
@@ -61,7 +73,9 @@ http_common_plugin_address_pretty_printer (void *cls, const char *type,
  * @return string representing the same address
  */
 const char *
-http_common_plugin_address_to_string (void *cls, const void *addr, size_t addrlen);
+http_common_plugin_address_to_string (void *cls,
+                                      const void *addr,
+                                      size_t addrlen);
 
 /**
  * Function called to convert a string address to
@@ -82,4 +96,39 @@ http_common_plugin_string_to_address (void *cls,
                                       void **buf,
                                       size_t *added);
 
+
+/**
+ * Create a HTTP address from a socketaddr
+ *
+ * @param protocol protocol
+ * @param addr sockaddr * address
+ * @param addrlen length of the address
+ * @return the string
+ */
+char *
+http_common_address_from_socket (const char *protocol,
+                                 const struct sockaddr *addr,
+                                 socklen_t addrlen);
+
+/**
+ * Get the length of an address
+ *
+ * @param addr address
+ * @return the size
+ */
+size_t
+http_common_address_get_size (void *addr);
+
+
+/**
+ * Compare addr1 to addr2
+ *
+ * @param addr1 address1
+ * @param addrlen1 address 1 length
+ * @param addr2 address2
+ * @param addrlen2 address 2 length
+ * @return GNUNET_YES if equal, GNUNET_NO else
+ */
+size_t
+http_common_cmp_addresses (const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2);
 /* end of plugin_transport_http_common.c */