-doxygen
[oweals/gnunet.git] / src / transport / plugin_transport_http_common.h
index 0f83da6b3107b127b069aa63a78fdf9177f30d49..33a5b38f540923ace778516ad94c802b5eb75fbe 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 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)
+#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 HTTP_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_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+
+#if BUILD_HTTPS
+#define PROTOCOL "https"
+#else
+#define PROTOCOL "http"
+#endif
+
+#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 HTTP_CLIENT_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
+#define HTTP_SERVER_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
 #define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
-#define TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
+
 #endif
 
+#define HTTP_DEFAULT_PORT 80
+#define HTTPS_DEFAULT_PORT 443
+
+enum HTTP_OPTIONS
+{
+                       HTTP_OPTIONS_NONE = 0,
+        HTTP_OPTIONS_VERIFY_CERTIFICATE = 1
+};
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * HttpAddress
+ */
+struct HttpAddress
+{
+       /**
+        * Address options
+        */
+       uint32_t options;
+
+       /**
+        * Length of URL located after struct
+        *
+        */
+       uint32_t urlen;
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+struct SplittedHTTPAddress;
+
+struct SplittedHTTPAddress *
+http_split_address (const char * addr);
+
 /**
  * Convert the transports address to a nice, human-readable
  * format.
@@ -68,12 +121,14 @@ http_common_plugin_address_pretty_printer (void *cls, const char *type,
  * to override the address again.
  *
  * @param cls closure
+ * @param plugin the plugin
  * @param addr binary address
  * @param addrlen length of the address
  * @return string representing the same address
  */
 const char *
 http_common_plugin_address_to_string (void *cls,
+                                                                                                                                                       char *plugin,
                                       const void *addr,
                                       size_t addrlen);
 
@@ -105,10 +160,27 @@ http_common_plugin_string_to_address (void *cls,
  * @param addrlen length of the address
  * @return the string
  */
-char *
+struct HttpAddress *
 http_common_address_from_socket (const char *protocol,
-                                 const struct sockaddr *addr,
-                                 socklen_t addrlen);
+                                                                                                                                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);
+
+const char *
+http_common_plugin_address_to_url (void *cls, const void *addr, size_t addrlen);
 
 /**
  * Get the length of an address
@@ -117,7 +189,7 @@ http_common_address_from_socket (const char *protocol,
  * @return the size
  */
 size_t
-http_common_address_get_size (void *addr);
+http_common_address_get_size (const struct HttpAddress * addr);
 
 
 /**