error msg
[oweals/gnunet.git] / src / transport / plugin_transport_http_common.h
index b29801d24d129eec45d5e73a805c1f2da7d643e0..31676c2848e860c03c21338a6ccc81fdce361651 100644 (file)
 
 #include "platform.h"
 #include "gnunet_common.h"
+#include "gnunet_transport_plugin.h"
+/**
+ * Timeout values for testing
+ */
+#define TESTING GNUNET_NO
+
+#if TESTING
+
+#define HTTP_SERVER_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
+#define HTTP_CLIENT_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
+#define CLIENT_SESSION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 7)
+#define SERVER_SESSION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 7)
+#define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
+
+#else
+
+#define HTTP_SERVER_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define HTTP_CLIENT_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define CLIENT_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
+#define SERVER_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
+#define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
+
+#endif
+
+#define HTTP_DEFAULT_PORT 80
+#define HTTPS_DEFAULT_PORT 443
+
+
+struct SplittedHTTPAddress;
+
+struct SplittedHTTPAddress *
+http_split_address (const char * addr);
 
 /**
  * Convert the transports address to a nice, human-readable
@@ -61,7 +93,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 +116,53 @@ 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);
+
+/**
+ * Create a socketaddr from a HTTP address
+ *
+ * @param addr sockaddr * address
+ * @param addrlen length of the address
+ * @param res the result:
+ * GNUNET_SYSERR, invalid input,
+ * GNUNET_YES: could convert to ip,
+ * GNUNET_NO: valid input but could not convert to ip (hostname?)
+ * @return the string
+ */
+struct sockaddr *
+http_common_socket_from_address (const void *addr, size_t addrlen, int *res);
+
+/**
+ * Get the length of an address
+ *
+ * @param addr address
+ * @return the size
+ */
+size_t
+http_common_address_get_size (const 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 */