* List of open sessions.
*/
struct Session *sessions;
-
- /**
- * Handle for the statistics service.
- */
- struct GNUNET_STATISTICS_Handle *statistics;
-
};
+
/**
* Daemon for listening for new connections.
*/
acceptPolicyCallback (void *cls,
const struct sockaddr *addr, socklen_t addr_len)
{
+
+ /* Currently all incoming connections are accepted, so nothing to do here */
return MHD_YES;
}
const char *upload_data,
size_t * upload_data_size, void **httpSessionCache)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has an incoming `%s' request from \n",method);
+
+ if ( 0 == strcmp (MHD_HTTP_METHOD_PUT, method) )
+ {
+ /* PUT method here */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got PUT Request with size %u \n",upload_data_size);
+
+ // GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# PUT requests"), 1, GNUNET_NO);
+ }
+ if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
+
return MHD_YES;
}
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
- plugin->statistics = NULL;
+
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
api->send = &http_plugin_send;
curl_multi = curl_multi_init ();
+
+ if (NULL == plugin->env->stats)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to retrieve statistics handle\n"));
+ return NULL;
+ }
+
+ GNUNET_STATISTICS_set ( env->stats, "# PUT requests", 0, GNUNET_NO);
+
if ( (NULL == http_daemon) || (NULL == curl_multi))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Initializing http plugin failed\n");
#include "gnunet_program_lib.h"
#include "gnunet_signatures.h"
#include "plugin_transport.h"
+#include "gnunet_statistics_service.h"
#include "transport.h"
#define VERBOSE GNUNET_YES
*/
struct GNUNET_SCHEDULER_Handle *sched;
+/**
+ * Our statistics handle.
+ */
+struct GNUNET_STATISTICS_Handle *stats;
+
+
/**
* Our configuration.
*/
/**
* Did the test pass or fail?
*/
-static int ok;
+static int fail;
+
+static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
/**
* Initialize Environment for this plugin
api));
if (my_private_key != NULL)
GNUNET_CRYPTO_rsa_key_free (my_private_key);
-
- ok = 0;
}
/**
* isn't enabled (eg. FreeBSD > 4)
*/
static void
-test_validation ()
+shutdown_clean ()
{
- struct sockaddr_in soaddr;
- memset (&soaddr, 0, sizeof (soaddr));
-#if HAVE_SOCKADDR_IN_SIN_LEN
- soaddr.sin_len = sizeof (soaddr);
-#endif
- soaddr.sin_family = AF_INET;
- soaddr.sin_port = htons (2368 /* FIXME: get from config! */ );
- soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
-
- api->check_address(api->cls,
- &soaddr, sizeof (soaddr));
-
+ if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel( sched, timeout_task );
unload_plugins(env.cls, env.cfg);
}
+/**
+ * Timeout, give up.
+ */
+static void
+timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Timeout while executing testcase, test failed.\n");
+ fail = GNUNET_YES;
+ shutdown_clean();
+}
static void
setup_plugin_environment ()
{
env.cfg = cfg;
env.sched = sched;
+ env.stats = stats;
env.my_identity = &my_identity;
env.cls = &env;
env.receive = &receive;
sched = s;
cfg = c;
+
+ timeout_task = GNUNET_SCHEDULER_add_delayed ( sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &timeout_error, NULL);
+
/* parse configuration */
if ((GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (c,
"HOSTKEY", &keyfile)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _
- ("Transport service is lacking key configuration settings. Exiting.\n"));
+ _("Transport service is lacking key configuration settings. Exiting.\n"));
GNUNET_SCHEDULER_shutdown (s);
return;
}
+
+
+ stats = GNUNET_STATISTICS_create (sched, "http-transport", cfg);
+
/*
max_connect_per_transport = (uint32_t) tneigh;
my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to load http transport plugin\n"));
- /* FIXME: set some error code for main */
+ fail = GNUNET_YES;
return;
+
}
- test_validation ();
+ fail = GNUNET_NO;
+ shutdown_clean ();
}
"WARNING",
#endif
NULL);
- ok = 1; /* set to fail */
+ fail = GNUNET_YES;
ret = (GNUNET_OK ==
GNUNET_PROGRAM_run (5,
argv_prog,
"test-plugin-transport_http",
- "testcase", options, &run, NULL)) ? ok : 1;
+ "testcase", options, &run, NULL)) ? fail : 1;
GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport_http");
- /* FIXME: return correct value */
- /* return ret; */
- return GNUNET_NO;
+
+ return fail;
}
/* end of test_plugin_transport_http.c */