[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11764 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11764 - gnunet/src/transport |
Date: |
Wed, 16 Jun 2010 11:04:35 +0200 |
Author: wachs
Date: 2010-06-16 11:04:35 +0200 (Wed, 16 Jun 2010)
New Revision: 11764
Modified:
gnunet/src/transport/plugin_transport_http.c
gnunet/src/transport/test_plugin_transport_http.c
Log:
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2010-06-15 15:27:59 UTC
(rev 11763)
+++ gnunet/src/transport/plugin_transport_http.c 2010-06-16 09:04:35 UTC
(rev 11764)
@@ -246,11 +246,6 @@
*/
struct GNUNET_TRANSPORT_PluginEnvironment *env;
- /**
- * Handle to the network service.
- */
- struct GNUNET_SERVICE_Context *service;
-
unsigned int port_inbound;
/**
@@ -303,11 +298,6 @@
static CURLM *multi_handle;
/**
- * Our hostname
- */
-static char * hostname;
-
-/**
* Our ASCII encoded, hashed peer identity
* This string is used to distinguish between connections and is added to the
urls
*/
@@ -1454,8 +1444,6 @@
void *arg;
uint16_t args;
-
-
af = addr->sa_family;
if (af == AF_INET)
{
@@ -1494,7 +1482,6 @@
return GNUNET_OK;
}
plugin->env->notify_address(plugin->env->cls,"http",arg, args,
GNUNET_TIME_UNIT_FOREVER_REL);
-
return GNUNET_OK;
}
@@ -1577,10 +1564,6 @@
cs = cs_next;
}
-
-
- /* GNUNET_SERVICE_stop (plugin->service); */
- GNUNET_free (hostname);
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
@@ -1595,29 +1578,15 @@
{
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
- struct GNUNET_SERVICE_Context *service;
unsigned int timeout;
struct GNUNET_TIME_Relative gn_timeout;
long long unsigned int port;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n");
- service = NULL;
- /*
- service = GNUNET_SERVICE_start ("transport-http", env->sched, env->cfg);
- if (service == NULL)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "", _
- ("Failed to start service for `%s' transport
plugin.\n"),
- "http");
- return NULL;
- }
- */
-
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
plugin->sessions = NULL;
- plugin->service = service;
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
api->send = &http_plugin_send;
@@ -1626,8 +1595,6 @@
api->check_address = &http_plugin_address_suggested;
api->address_to_string = &http_plugin_address_to_string;
- hostname = GNUNET_RESOLVER_local_fqdn_get ();
-
/* Hashing our identity to use it in URLs */
GNUNET_CRYPTO_hash_to_enc ( &(plugin->env->my_identity->hashPubKey),
&my_ascii_hash_ident);
@@ -1647,6 +1614,10 @@
libgnunet_plugin_transport_http_done (api);
return NULL;
}
+
+ GNUNET_assert ((port > 0) && (port <= 65535));
+ GNUNET_assert (&my_ascii_hash_ident != NULL);
+
plugin->port_inbound = port;
gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT;
timeout = ( gn_timeout.value / 1000);
@@ -1682,10 +1653,15 @@
if (http_task_v4 != GNUNET_SCHEDULER_NO_TASK)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port
%u\n",port);
- if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
+ else if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on
port %u\n",port);
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No MHD was started, transport plugin
not functional!\n");
+ libgnunet_plugin_transport_http_done (api);
+ return NULL;
+ }
-
/* Initializing cURL */
multi_handle = curl_multi_init();
if ( NULL == multi_handle )
Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c 2010-06-15 15:27:59 UTC
(rev 11763)
+++ gnunet/src/transport/test_plugin_transport_http.c 2010-06-16 09:04:35 UTC
(rev 11764)
@@ -351,18 +351,26 @@
struct Plugin_Address * tmp;
/* Evaluate results */
- if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO)
&& (fail_addr_to_str == GNUNET_NO) &&
- (test_no_ident.test_failed == GNUNET_NO) &&
(test_too_short_ident.test_failed == GNUNET_NO) &&
(test_too_long_ident.test_failed == GNUNET_NO) &&
- (test_valid_ident.test_failed == GNUNET_NO) &&
(fail_msgs_transmited_to_local_addrs == count_str_addr))
+ fail = 0;
+ if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer ==
GNUNET_YES) || (fail_addr_to_str == GNUNET_YES))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tests successful\n");
- fail = 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test plugin functions failed\n");
+ fail = 1;
}
- else
+ if ((test_no_ident.test_failed == GNUNET_YES) ||
(test_too_short_ident.test_failed == GNUNET_YES) ||
(test_too_long_ident.test_failed == GNUNET_YES))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tests failed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data
failed\n");
fail = 1;
}
+ if ((test_valid_ident.test_failed == GNUNET_YES) ||
(fail_msgs_transmited_to_local_addrs != count_str_addr))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n");
+ fail = 1;
+ }
+ if (fail != 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n");
+ }
curl_multi_cleanup(multi_handle);
@@ -873,16 +881,15 @@
if (test_no_ident.test_executed == GNUNET_NO)
{
/* Connecting to peer without identification */
+
host_str = GNUNET_malloc (strlen ("http://localhost:12389/";)+1);
GNUNET_asprintf (&host_str, "http://localhost:%u/",port);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer
identification.\n"));
test_no_ident.test_executed = GNUNET_YES;
send_data ( &test_no_ident, host_str);
GNUNET_free (host_str);
-
return;
}
-
if (test_too_short_ident.test_executed == GNUNET_NO)
{
char * ident = "AAAAAAAAAA";
@@ -893,7 +900,6 @@
test_too_short_ident.test_executed = GNUNET_YES;
send_data ( &test_too_short_ident, host_str);
GNUNET_free (host_str);
-
return;
}
@@ -904,18 +910,15 @@
/* Connecting to peer with too long identification */
host_str = GNUNET_malloc (strlen ("http://localhost:12389/";) + strlen
(ident));
GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,ident);
-
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long
peer identification.\n"));
test_too_long_ident.test_executed = GNUNET_YES;
send_data ( &test_too_long_ident, host_str);
GNUNET_free (host_str);
-
return;
}
if (test_valid_ident.test_executed == GNUNET_NO)
{
struct GNUNET_CRYPTO_HashAsciiEncoded result;
-
GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&result);
host_str = GNUNET_malloc (strlen ("http://localhost:12389/";) + strlen
((const char *) &result));
GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,(char *)
&result);
@@ -924,7 +927,6 @@
test_valid_ident.test_executed = GNUNET_YES;
send_data ( &test_valid_ident, host_str);
GNUNET_free (host_str);
-
return;
}
/* Using one of the addresses the plugin proposed */
@@ -1027,7 +1029,7 @@
"transport-http",
"PORT",
&port)) ||
- (port > 65535) )
+ (port > 65535) || (port == 0))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
"http",
@@ -1035,6 +1037,7 @@
("Require valid port number for transport plugin `%s' in
configuration!\n"),
"transport-http");
}
+
max_connect_per_transport = (uint32_t) tneigh;
my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
GNUNET_free (keyfile);
@@ -1046,10 +1049,15 @@
fail = 1;
return;
}
+
GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
- GNUNET_CRYPTO_hash (&my_public_key,
- sizeof (my_public_key), &my_identity.hashPubKey);
+ GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
&my_identity.hashPubKey);
+ /* assertions before start */
+ GNUNET_assert ((port > 0) && (port <= 65535));
+ GNUNET_assert(&my_public_key != NULL);
+ GNUNET_assert(&my_identity.hashPubKey != NULL);
+
/* load plugins... */
setup_plugin_environment ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading HTTP transport plugin
`%s'\n"),"libgnunet_plugin_transport_http");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11764 - gnunet/src/transport,
gnunet <=