[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24573 - in gnunet/src: arm core datastore dht exit fs gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24573 - in gnunet/src: arm core datastore dht exit fs gns hostlist include namestore nat nse pt statistics stream testing_old transport util vpn |
Date: |
Sat, 27 Oct 2012 00:13:01 +0200 |
Author: grothoff
Date: 2012-10-27 00:13:01 +0200 (Sat, 27 Oct 2012)
New Revision: 24573
Removed:
gnunet/src/gns/proxy/
Modified:
gnunet/src/arm/gnunet-service-arm.c
gnunet/src/core/core_api.c
gnunet/src/datastore/datastore_api.c
gnunet/src/dht/dht_api.c
gnunet/src/exit/gnunet-daemon-exit.c
gnunet/src/fs/fs_download.c
gnunet/src/fs/fs_search.c
gnunet/src/gns/gns.conf.in
gnunet/src/gns/gns.h
gnunet/src/gns/gns_api.c
gnunet/src/gns/gnunet-gns-proxy.c
gnunet/src/gns/gnunet-gns.c
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/gnunet-service-gns_interceptor.c
gnunet/src/gns/gnunet-service-gns_interceptor.h
gnunet/src/gns/gnunet-service-gns_resolver.c
gnunet/src/gns/gnunet-service-gns_resolver.h
gnunet/src/gns/plugin_block_gns.c
gnunet/src/hostlist/hostlist-client.c
gnunet/src/include/gnunet_constants.h
gnunet/src/include/gnunet_crypto_lib.h
gnunet/src/include/gnunet_network_lib.h
gnunet/src/include/gnunet_time_lib.h
gnunet/src/namestore/test_namestore_api.c
gnunet/src/namestore/test_namestore_api_lookup.c
gnunet/src/nat/nat.c
gnunet/src/nse/nse_api.c
gnunet/src/pt/test_gns_vpn.c
gnunet/src/pt/test_gnunet_vpn.c
gnunet/src/statistics/statistics_api.c
gnunet/src/stream/stream_api.c
gnunet/src/testing_old/testing.c
gnunet/src/testing_old/testing_group.c
gnunet/src/transport/transport_api.c
gnunet/src/transport/transport_api_address_lookup.c
gnunet/src/util/crypto_ecc.c
gnunet/src/util/crypto_rsa.c
gnunet/src/util/network.c
gnunet/src/util/resolver_api.c
gnunet/src/util/test_crypto_ecc.c
gnunet/src/vpn/gnunet-service-vpn.c
Log:
-bugfixes, code cleanup
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/arm/gnunet-service-arm.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -30,12 +30,6 @@
#include "arm.h"
/**
- * Threshold after which exponential backoff shouldn't increase (in ms); 30m
- */
-#define EXPONENTIAL_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MINUTES, 30)
-
-
-/**
* List of our services.
*/
struct ServiceList;
@@ -1023,10 +1017,7 @@
pos->name, statstr, statcode,
pos->backoff.rel_value);
/* schedule restart */
pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff);
- pos->backoff =
- GNUNET_TIME_relative_min (EXPONENTIAL_BACKOFF_THRESHOLD,
- GNUNET_TIME_relative_multiply
- (pos->backoff, 2));
+ pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff);
}
if (GNUNET_SCHEDULER_NO_TASK != child_restart_task)
GNUNET_SCHEDULER_cancel (child_restart_task);
Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/core/core_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -440,9 +440,7 @@
while (NULL != (pr = h->ready_peer_head))
GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
GNUNET_assert (h->control_pending_head == NULL);
- h->retry_backoff =
- GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->retry_backoff);
- h->retry_backoff = GNUNET_TIME_relative_multiply (h->retry_backoff, 2);
+ h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff);
}
@@ -1174,7 +1172,6 @@
h->hcnt = 0;
h->currently_down = GNUNET_YES;
h->peers = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
- h->retry_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
if (NULL != handlers)
while (handlers[h->hcnt].callback != NULL)
h->hcnt++;
Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/datastore/datastore_api.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -512,12 +512,7 @@
{
struct GNUNET_DATASTORE_Handle *h = cls;
- if (h->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
- h->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY;
- else
- h->retry_time = GNUNET_TIME_relative_multiply (h->retry_time, 2);
- if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value)
- h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT;
+ h->retry_time = GNUNET_TIME_STD_BACKOFF (h->retry_time);
h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
if (h->client == NULL)
@@ -802,7 +797,7 @@
GNUNET_STATISTICS_update (h->stats,
gettext_noop ("# status messages received"), 1,
GNUNET_NO);
- h->retry_time.rel_value = 0;
+ h->retry_time = GNUNET_TIME_UNIT_ZERO;
process_queue (h);
if (rc.cont != NULL)
rc.cont (rc.cont_cls, status,
@@ -1184,7 +1179,7 @@
free_queue_entry (qe);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received end of result set, new queue size is %u\n", h->queue_size);
- h->retry_time.rel_value = 0;
+ h->retry_time = GNUNET_TIME_UNIT_ZERO;
h->result_count = 0;
process_queue (h);
if (rc.proc != NULL)
@@ -1231,7 +1226,7 @@
(unsigned long long) GNUNET_ntohll (dm->uid), ntohl (dm->type),
ntohl (dm->size), GNUNET_h2s (&dm->key));
free_queue_entry (qe);
- h->retry_time.rel_value = 0;
+ h->retry_time = GNUNET_TIME_UNIT_ZERO;
process_queue (h);
if (rc.proc != NULL)
rc.proc (rc.proc_cls, &dm->key, ntohl (dm->size), &dm[1], ntohl (dm->type),
Modified: gnunet/src/dht/dht_api.c
===================================================================
--- gnunet/src/dht/dht_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/dht/dht_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -401,14 +401,8 @@
struct GNUNET_DHT_Handle *handle = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle);
+ handle->retry_time = GNUNET_TIME_STD_BACKOFF (handle->retry_time);
handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
- if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
- handle->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY;
- else
- handle->retry_time = GNUNET_TIME_relative_multiply (handle->retry_time, 2);
- if (handle->retry_time.rel_value >
GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value)
- handle->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT;
- handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_YES != try_connect (handle))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "dht reconnect failed(!)\n");
@@ -438,8 +432,9 @@
GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
handle->th = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting from DHT service, will try to reconnect in %llu
ms\n",
- (unsigned long long) handle->retry_time.rel_value);
+ "Disconnecting from DHT service, will try to reconnect in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (handle->retry_time,
+ GNUNET_YES));
GNUNET_CLIENT_disconnect (handle->client);
handle->client = NULL;
Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/exit/gnunet-daemon-exit.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -2964,31 +2964,6 @@
/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "socket");
- return GNUNET_SYSERR;
- }
- close (s);
- return GNUNET_OK;
-}
-
-
-/**
* @brief Main function that will be run by the scheduler.
*
* @param cls closure
@@ -3042,7 +3017,7 @@
ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit",
"ENABLE_IPV6");
if ( (ipv4_exit || ipv4_enabled) &&
- GNUNET_OK != test_af (AF_INET))
+ GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("This system does not support IPv4, will disable IPv4
functions despite them being enabled in the configuration\n"));
@@ -3050,7 +3025,7 @@
ipv4_enabled = GNUNET_NO;
}
if ( (ipv6_exit || ipv6_enabled) &&
- GNUNET_OK != test_af (AF_INET6))
+ GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET6))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("This system does not support IPv6, will disable IPv6
functions despite them being enabled in the configuration\n"));
Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/fs/fs_download.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -1439,9 +1439,8 @@
if (0 == dc->reconnect_backoff.rel_value)
dc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
else
- dc->reconnect_backoff = GNUNET_TIME_relative_min
(GNUNET_TIME_relative_multiply (dc->reconnect_backoff, 2),
-
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
-
+ dc->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (dc->reconnect_backoff);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in %s\n",
GNUNET_STRINGS_relative_time_to_string (dc->reconnect_backoff,
GNUNET_YES));
dc->task =
Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/fs/fs_search.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -1158,12 +1158,7 @@
GNUNET_CLIENT_disconnect (sc->client);
sc->client = NULL;
}
- if (0 == sc->reconnect_backoff.rel_value)
- sc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
- else
- sc->reconnect_backoff = GNUNET_TIME_relative_min
(GNUNET_TIME_relative_multiply (sc->reconnect_backoff, 2),
-
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
-
+ sc->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (sc->reconnect_backoff);
sc->task =
GNUNET_SCHEDULER_add_delayed (sc->reconnect_backoff,
&do_reconnect,
Modified: gnunet/src/gns/gns.conf.in
===================================================================
--- gnunet/src/gns/gns.conf.in 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gns.conf.in 2012-10-26 22:13:01 UTC (rev 24573)
@@ -12,7 +12,7 @@
AUTO_IMPORT_PKEY = YES
AUTO_IMPORT_CONFIRMATION_REQ = NO
MAX_PARALLEL_BACKGROUND_QUERIES = 25
-DEFAULT_LOOKUP_TIMEOUT = 10
+DEFAULT_LOOKUP_TIMEOUT = 10 s
ZONE_PUBLISH_TIME_WINDOW = 4 h
# PREFIX = valgrind --leak-check=full --track-origins=yes
Modified: gnunet/src/gns/gns.h
===================================================================
--- gnunet/src/gns/gns.h 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gns.h 2012-10-26 22:13:01 UTC (rev 24573)
@@ -27,14 +27,32 @@
#include "gnunet_gns_service.h"
+/**
+ * Name of the GADS TLD.
+ */
#define GNUNET_GNS_TLD "gads"
+
+/**
+ * Name of the zone key TLD.
+ */
#define GNUNET_GNS_TLD_ZKEY "zkey"
+
+/**
+ * TLD name used to indicate relative names.
+ */
#define GNUNET_GNS_TLD_PLUS "+"
-#define GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL 3600
+/**
+ * Maximum length of a label in DNS.
+ */
#define MAX_DNS_LABEL_LENGTH 63
+
+/**
+ * Maximum length of a name in DNS.
+ */
#define MAX_DNS_NAME_LENGTH 253
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
@@ -43,7 +61,7 @@
struct GNUNET_GNS_ClientLookupMessage
{
/**
- * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP
+ * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP
*/
struct GNUNET_MessageHeader header;
@@ -107,13 +125,14 @@
};
+
/**
* Message from client to GNS service to shorten names.
*/
struct GNUNET_GNS_ClientShortenMessage
{
/**
- * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN
+ * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN
*/
struct GNUNET_MessageHeader header;
@@ -152,7 +171,7 @@
struct GNUNET_GNS_ClientShortenResultMessage
{
/**
- * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN_RESULT
+ * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN_RESULT
*/
struct GNUNET_MessageHeader header;
@@ -165,13 +184,14 @@
};
+
/**
* Message from client to GNS service to lookup an authority of a name.
*/
struct GNUNET_GNS_ClientGetAuthMessage
{
/**
- * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH
+ * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH
*/
struct GNUNET_MessageHeader header;
@@ -190,7 +210,7 @@
struct GNUNET_GNS_ClientGetAuthResultMessage
{
/**
- * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH_RESULT
+ * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH_RESULT
*/
struct GNUNET_MessageHeader header;
@@ -202,6 +222,7 @@
/* followed by the authority part of the name or '\0' for no result*/
};
+
GNUNET_NETWORK_STRUCT_END
#endif
Modified: gnunet/src/gns/gns_api.c
===================================================================
--- gnunet/src/gns/gns_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gns_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -68,7 +68,7 @@
/**
* request id
*/
- uint64_t r_id;
+ uint32_t r_id;
};
@@ -106,7 +106,7 @@
/**
* request id
*/
- uint64_t r_id;
+ uint32_t r_id;
};
@@ -165,14 +165,14 @@
struct PendingMessage *next;
/**
- * request id
+ * Size of the message.
*/
- uint64_t r_id;
+ size_t size;
/**
- * Size of the message.
+ * request id
*/
- size_t size;
+ uint32_t r_id;
/**
* This message has been transmitted. GNUNET_NO if the message is
@@ -249,8 +249,16 @@
* Reconnect task
*/
GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
+
+ /**
+ * How long do we wait until we try to reconnect?
+ */
+ struct GNUNET_TIME_Relative reconnect_backoff;
- uint32_t r_id;
+ /**
+ * Request Id generator. Incremented by one for each request.
+ */
+ uint32_t r_id_gen;
/**
* Did we start our receive loop yet?
@@ -319,7 +327,7 @@
h->in_receive = GNUNET_NO;
for (st = h->shorten_head; NULL != st; st = st->next)
{
- p = (struct PendingMessage*) &st[1];
+ p = (struct PendingMessage *) &st[1];
if (GNUNET_NO == p->transmitted)
continue;
p->transmitted = GNUNET_NO;
@@ -329,7 +337,7 @@
}
for (lh = h->lookup_head; NULL != lh; lh = lh->next)
{
- p = (struct PendingMessage*) &lh[1];
+ p = (struct PendingMessage *) &lh[1];
if (GNUNET_NO == p->transmitted)
continue;
p->transmitted = GNUNET_NO;
@@ -339,7 +347,7 @@
}
for (ga = h->get_auth_head; NULL != ga; ga = ga->next)
{
- p = (struct PendingMessage*) &ga[1];
+ p = (struct PendingMessage *) &ga[1];
if (GNUNET_NO == p->transmitted)
continue;
p->transmitted = GNUNET_NO;
@@ -347,8 +355,8 @@
h->pending_tail,
p);
}
- /* FIXME: 1s too long, exponential-backoff, starting at 1ms! (max = 1s might
be OK) */
- h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ h->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (h->reconnect_backoff);
+ h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_backoff,
&reconnect_task,
h);
}
@@ -618,7 +626,7 @@
const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg;
const struct GNUNET_GNS_ClientShortenResultMessage *shorten_msg;
const struct GNUNET_GNS_ClientGetAuthResultMessage *get_auth_msg;
- uint64_t r_id;
+ uint32_t r_id;
if (NULL == msg)
{
@@ -860,7 +868,7 @@
lr->gns_handle = handle;
lr->lookup_proc = proc;
lr->proc_cls = proc_cls;
- lr->r_id = handle->r_id++;
+ lr->r_id = handle->r_id_gen++;
pending = (struct PendingMessage *)&lr[1];
pending->size = msize;
pending->r_id = lr->r_id;
@@ -975,7 +983,7 @@
sr->gns_handle = handle;
sr->shorten_proc = proc;
sr->proc_cls = proc_cls;
- sr->r_id = handle->r_id++;
+ sr->r_id = handle->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (handle->shorten_head,
handle->shorten_tail, sr);
pending = (struct PendingMessage *)&sr[1];
@@ -1070,7 +1078,7 @@
gar->gns_handle = handle;
gar->auth_proc = proc;
gar->proc_cls = proc_cls;
- gar->r_id = handle->r_id++;
+ gar->r_id = handle->r_id_gen++;
GNUNET_CONTAINER_DLL_insert_tail (handle->get_auth_head,
handle->get_auth_tail, gar);
Modified: gnunet/src/gns/gnunet-gns-proxy.c
===================================================================
--- gnunet/src/gns/gnunet-gns-proxy.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gnunet-gns-proxy.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -500,41 +500,6 @@
}
-/**
-// FIXME: use cURL API
- * Escape given 0-terminated string
- *
- * @param to_esc string to escapse
- * @return allocated new escaped string (MUST free!)
- */
-static char*
-escape_to_urlenc (const char *to_esc)
-{
- char *pos = (char*)to_esc;
- char *res = GNUNET_malloc (strlen (to_esc) * 3 + 1);
- char *rpos = res;
-
- while ('\0' != *pos)
- {
- if (isalnum (*pos) ||
- ('-' == *pos) || ('_' == *pos) ||
- ('.' == *pos) || ('~' == *pos))
- *rpos++ = *pos;
- else if (' ' == *pos)
- *rpos++ = '+';
- else
- {
- *rpos++ = '%';
- *rpos++ = i_to_hexchar (*pos >> 4);
- *rpos++ = i_to_hexchar (*pos >> 15);
- }
- pos++;
- }
- *rpos = '\0';
- return res;
-}
-
-
static int
con_post_data_iter (void *cls,
enum MHD_ValueKind kind,
@@ -610,9 +575,14 @@
if (0 == off)
{
+ enc = curl_easy_escape (ctask->curl, key, 0);
+ if (NULL == enc)
+ {
+ GNUNET_break (0);
+ return MHD_NO;
+ }
/* a key */
pdata = GNUNET_malloc (sizeof (struct ProxyUploadData));
- enc = escape_to_urlenc (key);
pdata->value = GNUNET_malloc (strlen (enc) + 3);
if (NULL != ctask->upload_data_head)
{
@@ -624,7 +594,7 @@
pdata->value[strlen (pdata->value)] = '=';
pdata->bytes_left = strlen (pdata->value);
pdata->total_bytes = pdata->bytes_left;
- GNUNET_free (enc);
+ curl_free (enc);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Escaped POST key: '%s'\n",
@@ -636,13 +606,18 @@
}
/* a value */
+ enc = curl_easy_escape (ctask->curl, data, 0);
+ if (NULL == enc)
+ {
+ GNUNET_break (0);
+ return MHD_NO;
+ }
pdata = GNUNET_malloc (sizeof (struct ProxyUploadData));
- enc = escape_to_urlenc (data);
pdata->value = GNUNET_malloc (strlen (enc) + 1);
memcpy (pdata->value, enc, strlen (enc));
pdata->bytes_left = strlen (pdata->value);
pdata->total_bytes = pdata->bytes_left;
- GNUNET_free (enc);
+ curl_free (enc);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Escaped POST value: '%s'\n",
@@ -1341,6 +1316,7 @@
run_mhd_now (ctask->mhd);
}
+
/**
* Handle data from cURL
*
@@ -1592,7 +1568,6 @@
struct ProxyCurlTask *ctask;
int num_ctasks;
long resp_code;
-
struct ProxyCurlTask *clean_head = NULL;
struct ProxyCurlTask *clean_tail = NULL;
@@ -1602,8 +1577,8 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Shutdown requested while trying to download\n");
- //TODO cleanup
- return;
+ //TODO cleanup
+ return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Ready to dl\n");
@@ -2392,13 +2367,11 @@
len);
}
else
- {
-
+ {
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "write");
s5r->cleanup = GNUNET_YES;
s5r->cleanup_sock = GNUNET_YES;
- cleanup_s5r (s5r);
-
+ cleanup_s5r (s5r);
return;
}
@@ -2429,8 +2402,6 @@
struct Socks5Request *s5r = cls;
s5r->fwdrtask = GNUNET_SCHEDULER_NO_TASK;
-
-
if ((NULL != tc->write_ready) &&
(GNUNET_NETWORK_fdset_isset (tc->read_ready, s5r->remote_sock)) &&
(s5r->wbuf_len = GNUNET_NETWORK_socket_recv (s5r->remote_sock, s5r->wbuf,
@@ -2442,7 +2413,7 @@
}
else
{
- if (s5r->wbuf_len == 0)
+ if (0 == s5r->wbuf_len)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"0 bytes received from remote... graceful shutdown!\n");
if (s5r->fwdwtask != GNUNET_SCHEDULER_NO_TASK)
@@ -2460,8 +2431,7 @@
s5r->wtask = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
s5r->sock,
- &do_write, s5r);
-
+ &do_write, s5r);
}
@@ -2699,7 +2669,7 @@
static int
add_handle_to_ssl_mhd (struct GNUNET_NETWORK_Handle *h, const char* domain)
{
- struct MhdHttpList *hd = NULL;
+ struct MhdHttpList *hd;
struct ProxyGNSCertificate *pgc;
struct NetworkHandleList *nh;
@@ -2781,7 +2751,6 @@
struct socks5_server_hello *s_hello;
struct socks5_client_request *c_req;
struct socks5_server_response *s_resp;
-
int ret;
char domain[256];
uint8_t dom_len;
@@ -2790,7 +2759,6 @@
uint32_t remote_ip;
struct sockaddr_in remote_addr;
struct in_addr *r_sin_addr;
-
struct NetworkHandleList *nh;
s5r->rtask = GNUNET_SCHEDULER_NO_TASK;
@@ -3100,7 +3068,6 @@
do_shutdown (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-
struct MhdHttpList *hd;
struct MhdHttpList *tmp_hd;
struct NetworkHandleList *nh;
@@ -3111,9 +3078,6 @@
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Shutting down...\n");
-
- gnutls_global_deinit ();
-
if (NULL != local_gns_zone)
GNUNET_free (local_gns_zone);
if (NULL != local_private_zone)
@@ -3142,13 +3106,11 @@
GNUNET_SCHEDULER_cancel (hd->httpd_task);
hd->httpd_task = GNUNET_SCHEDULER_NO_TASK;
}
-
if (NULL != hd->daemon)
{
MHD_stop_daemon (hd->daemon);
hd->daemon = NULL;
}
-
for (nh = hd->socket_handles_head; nh != NULL; nh = tmp_nh)
{
tmp_nh = nh->next;
@@ -3200,12 +3162,11 @@
GNUNET_free_non_null (pdata->value);
GNUNET_free (pdata);
}
-
GNUNET_free (ctask);
}
curl_multi_cleanup (curl_multi);
-
GNUNET_GNS_disconnect (gns_handle);
+ gnutls_global_deinit ();
}
@@ -3243,9 +3204,9 @@
load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
char *keyfile;
- struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
+ struct GNUNET_CRYPTO_RsaPrivateKey *key;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
- struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode *zone;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
@@ -3361,9 +3322,7 @@
struct sockaddr_un mhd_unix_sock_addr;
#endif
- curl_multi = curl_multi_init ();
-
- if (NULL == curl_multi)
+ if (NULL == (curl_multi = curl_multi_init ()))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to create cURL multo handle!\n");
@@ -3376,8 +3335,8 @@
if (NULL == cafile)
{
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy",
- "PROXY_CACERT",
- &cafile_cfg))
+ "PROXY_CACERT",
+ &cafile_cfg))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unable to load proxy CA config value!\n");
@@ -3408,19 +3367,16 @@
compile_regex (&re_dotplus, (char*) RE_A_HREF);
- gns_handle = GNUNET_GNS_connect (cfg);
-
- if (GNUNET_NO == load_local_zone_key (cfg))
+ if (NULL == (gns_handle = GNUNET_GNS_connect (cfg)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to load zone!\n");
+ "Unable to connect to GNS!\n");
return;
}
-
- if (NULL == gns_handle)
+ if (GNUNET_NO == load_local_zone_key (cfg))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to connect to GNS!\n");
+ "Unable to load zone!\n");
return;
}
@@ -3477,12 +3433,9 @@
"Specify PROXY_UNIXPATH in gns-proxy config section!\n");
return;
}
-
- mhd_unix_socket = GNUNET_NETWORK_socket_create (AF_UNIX,
- SOCK_STREAM,
- 0);
-
- if (NULL == mhd_unix_socket)
+ if (NULL == (mhd_unix_socket = GNUNET_NETWORK_socket_create (AF_UNIX,
+ SOCK_STREAM,
+ 0)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unable to create unix domain socket!\n");
@@ -3500,7 +3453,6 @@
#endif
len = strlen (proxy_sockfile) + sizeof(AF_UNIX);
-
GNUNET_free (proxy_sockfile);
if (GNUNET_OK != GNUNET_NETWORK_socket_bind (mhd_unix_socket,
Modified: gnunet/src/gns/gnunet-gns.c
===================================================================
--- gnunet/src/gns/gnunet-gns.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gnunet-gns.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -44,7 +44,6 @@
*/
static char *lookup_name;
-
/**
* record type to look up (-t option)
*/
@@ -60,15 +59,24 @@
*/
static int raw;
+/**
+ * Requested record type.
+ */
static enum GNUNET_GNS_RecordType rtype;
-/* Handle to lookup request */
+/**
+ * Handle to lookup request
+ */
static struct GNUNET_GNS_LookupRequest *lookup_request;
-/* Handle to shorten request */
+/**
+ * Handle to shorten request
+ */
static struct GNUNET_GNS_ShortenRequest *shorten_request;
-/* Handle to get authority request */
+/**
+ * Handle to get authority request
+ */
static struct GNUNET_GNS_GetAuthRequest *getauth_request;
@@ -83,21 +91,37 @@
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (NULL != lookup_request)
+ {
GNUNET_GNS_cancel_lookup_request (lookup_request);
-
+ lookup_request = NULL;
+ }
if (NULL != shorten_request)
+ {
GNUNET_GNS_cancel_shorten_request (shorten_request);
-
+ shorten_request = NULL;
+ }
if (NULL != getauth_request)
+ {
GNUNET_GNS_cancel_get_auth_request (getauth_request);
-
+ getauth_request = NULL;
+ }
if (NULL != gns)
+ {
GNUNET_GNS_disconnect (gns);
+ gns = NULL;
+ }
}
+/**
+ * Function called with the result of a shorten operation.
+ * Prints the result.
+ *
+ * @param cls a 'const char *' with the original (long) name
+ * @param nshort the shortened name
+ */
static void
-process_shorten_result (void* cls, const char* nshort)
+process_shorten_result (void* cls, const char *nshort)
{
const char *original_name = cls;
@@ -110,6 +134,13 @@
}
+/**
+ * Function called with the result of a GADS lookup.
+ *
+ * @param cls the 'const char *' name that was resolved
+ * @param rd_count number of records returned
+ * @param rd array of 'rd_count' records with the results
+ */
static void
process_lookup_result (void* cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -122,7 +153,7 @@
lookup_request = NULL;
if (!raw)
{
- if (rd_count == 0)
+ if (0 == rd_count)
printf("No results.\n");
else
printf("%s:\n", name);
@@ -143,8 +174,16 @@
}
+/**
+ * Function called with the result of an authority lookup.
+ *
+ * @param cls the 'const char *' with the name for which the
+ * authority was resolved
+ * @param auth name of the authority
+ */
static void
-process_auth_result (void* cls, const char* auth)
+process_auth_result (void* cls,
+ const char *auth)
{
getauth_request = NULL;
printf ("%s\n", auth);
@@ -254,14 +293,16 @@
else
rtype = GNUNET_GNS_RECORD_A;
- if ((NULL != shorten_name) && (NULL != shorten_zone) && (NULL !=
private_zone))
+ if ( (NULL != shorten_name) &&
+ (NULL != shorten_zone) &&
+ (NULL != private_zone) )
{
shorten_request = GNUNET_GNS_shorten_zone (gns, shorten_name,
- private_zone,
- shorten_zone,
- zone,
- &process_shorten_result,
- shorten_name);
+ private_zone,
+ shorten_zone,
+ zone,
+ &process_shorten_result,
+ shorten_name);
}
if (NULL != lookup_name)
{
@@ -270,7 +311,8 @@
rtype,
GNUNET_NO, /* Use DHT */
shorten_key,
- &process_lookup_result,
lookup_name);
+ &process_lookup_result,
+ lookup_name);
}
if (NULL != auth_name)
{
@@ -285,16 +327,15 @@
if (NULL != private_zone)
GNUNET_free (private_zone);
- if ((NULL == auth_name) &&
- (NULL == shorten_name) &&
- (NULL == lookup_name))
+ if ( (NULL == auth_name) &&
+ (NULL == shorten_name) &&
+ (NULL == lookup_name))
{
fprintf (stderr,
_("Please specify lookup, shorten or authority operation!\n"));
GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
-
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&do_shutdown, NULL);
}
@@ -328,7 +369,6 @@
&GNUNET_GETOPT_set_one, &raw},
GNUNET_GETOPT_OPTION_END
};
-
int ret;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -72,6 +72,7 @@
* List for all shorten requests
*/
struct ClientShortenHandle *next;
+
/**
* List for all shorten requests
*/
@@ -83,9 +84,29 @@
struct GNUNET_SERVER_Client *client;
/**
+ * Namestore lookup task
+ */
+ struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
+
+ /**
+ * master zone
+ */
+ struct GNUNET_CRYPTO_ShortHashCode root_zone;
+
+ /**
+ * private zone
+ */
+ struct GNUNET_CRYPTO_ShortHashCode private_zone;
+
+ /**
+ * shorten zone
+ */
+ struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
+
+ /**
* The request id
*/
- uint64_t request_id;
+ uint32_t request_id;
/**
* request type
@@ -106,26 +127,7 @@
* name of shorten zone (relative to root)
*/
char shorten_zone_id[MAX_DNS_NAME_LENGTH];
-
- /**
- * master zone
- */
- struct GNUNET_CRYPTO_ShortHashCode root_zone;
- /**
- * private zone
- */
- struct GNUNET_CRYPTO_ShortHashCode private_zone;
-
- /**
- * shorten zone
- */
- struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
-
- /**
- * Namestore lookup task
- */
- struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
};
@@ -135,18 +137,20 @@
struct ClientGetAuthHandle
{
/**
- * Handle to the requesting client */
+ * Handle to the requesting client
+ */
struct GNUNET_SERVER_Client *client;
/**
- * request id
+ * name to lookup authority
*/
- uint64_t request_id;
+ char *name;
/**
- * name to lookup authority
+ * request id
*/
- char *name;
+ uint32_t request_id;
+
};
@@ -162,34 +166,34 @@
struct GNUNET_SERVER_Client *client;
/**
- * The zone we look up in
+ * optional zone private key used for shorten
*/
- struct GNUNET_CRYPTO_ShortHashCode zone;
+ struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
/**
- * GNUNET_YES if we only want to lookup from local cache
+ * the name to look up
*/
- int only_cached;
+ char *name;
/**
- * request id
+ * The zone we look up in
*/
- uint64_t request_id;
+ struct GNUNET_CRYPTO_ShortHashCode zone;
/**
- * request type
+ * request id
*/
- enum GNUNET_GNS_RecordType type;
+ uint32_t request_id;
/**
- * optional zone private key used for shorten
+ * GNUNET_YES if we only want to lookup from local cache
*/
- struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
+ int only_cached;
/**
- * the name to look up
+ * request type
*/
- char *name;
+ enum GNUNET_GNS_RecordType type;
};
@@ -306,19 +310,36 @@
while (NULL != (csh_tmp = csh_head))
{
GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp);
- GNUNET_free(csh_tmp);
+ GNUNET_free (csh_tmp);
}
GNUNET_SERVER_notification_context_destroy (nc);
gns_interceptor_stop ();
gns_resolver_cleanup ();
if (NULL != statistics)
+ {
GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
- if (zone_publish_task != GNUNET_SCHEDULER_NO_TASK)
+ statistics = NULL;
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != zone_publish_task)
+ {
GNUNET_SCHEDULER_cancel (zone_publish_task);
+ zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (NULL != namestore_iter)
+ {
GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
- GNUNET_NAMESTORE_disconnect(namestore_handle);
- GNUNET_DHT_disconnect(dht_handle);
+ namestore_iter = NULL;
+ }
+ if (NULL != namestore_handle)
+ {
+ GNUNET_NAMESTORE_disconnect (namestore_handle);
+ namestore_handle = NULL;
+ }
+ if (NULL != dht_handle)
+ {
+ GNUNET_DHT_disconnect (dht_handle);
+ dht_handle = NULL;
+ }
}
@@ -345,7 +366,7 @@
*/
static void
publish_zone_dht_start (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+ const struct GNUNET_SCHEDULER_TaskContext *tc);
/**
@@ -360,7 +381,7 @@
* @param signature the signature for the record data
*/
static void
-put_gns_record(void *cls,
+put_gns_record (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
struct GNUNET_TIME_Absolute expiration,
const char *name,
@@ -389,19 +410,17 @@
* we can safely set the interval to the value for a single
* record
*/
- put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
- 1);
-
+ put_interval = zone_publish_time_window;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"No records in db.\n");
}
else
{
put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
-
num_public_records);
+ num_public_records);
}
put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL,
- put_interval);
+ put_interval);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Zone iteration finished. Adjusted zone iteration interval to
%s\n",
@@ -484,7 +503,8 @@
GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT,
GNUNET_YES));
GNUNET_STATISTICS_update (statistics,
- "Record bytes put into DHT", rd_payload_length,
GNUNET_NO);
+ "Record bytes put into DHT",
+ rd_payload_length, GNUNET_NO);
(void) GNUNET_DHT_put (dht_handle, &dht_key,
DHT_GNS_REPLICATION_LEVEL,
@@ -505,7 +525,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Last record count was lower than current record count.
Reducing interval.\n");
put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
- num_public_records);
+ num_public_records);
next_put_interval = GNUNET_TIME_relative_divide (put_interval,
LATE_ITERATION_SPEEDUP_FACTOR);
}
@@ -517,8 +537,8 @@
next_put_interval.rel_value,
GNUNET_NO);
zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval,
- &publish_zone_dht_next,
- NULL);
+ &publish_zone_dht_next,
+ NULL);
}
@@ -529,11 +549,13 @@
* @param tc task context
*/
static void
-publish_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc)
+publish_zone_dht_start (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling DHT zone update!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Scheduling DHT zone update!\n");
/* start counting again */
num_public_records = 0;
namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
@@ -561,7 +583,8 @@
struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
size_t name_len;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending `%s' message with %s\n",
"SHORTEN_RESULT", name);
if (NULL == name)
name_len = 0;
@@ -616,9 +639,8 @@
csh->namestore_task = NULL;
if (0 == strcmp (csh->private_zone_id, ""))
- pzone = NULL;
-
- if (rd_count == 0)
+ pzone = NULL;
+ if (0 == rd_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No shorten zone in private zone!\n");
@@ -627,17 +649,14 @@
}
else
{
- GNUNET_assert (rd_count == 1);
-
+ GNUNET_break (1 == rd_count);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shorten zone %s found in private zone %s\n",
name, csh->private_zone_id);
sprintf (csh->shorten_zone_id, "%s.%s", name, csh->private_zone_id);
}
-
GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
-
gns_resolver_shorten_name (&csh->root_zone,
pzone,
szone,
@@ -663,12 +682,12 @@
*/
static void
process_shorten_in_root_zone_lookup (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*key,
- struct GNUNET_TIME_Absolute expiration,
- const char *name,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
+ const struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
+ struct GNUNET_TIME_Absolute expiration,
+ const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData
*rd,
+ const struct GNUNET_CRYPTO_RsaSignature
*signature)
{
struct ClientShortenHandle *csh = cls;
struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
@@ -677,17 +696,14 @@
csh->namestore_task = NULL;
if (0 == strcmp (csh->private_zone_id, ""))
pzone = NULL;
-
- if (rd_count == 0)
+ if (0 == rd_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No shorten zone in zone and no private zone!\n");
strcpy (csh->shorten_zone_id, "");
-
GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
szone = NULL;
-
gns_resolver_shorten_name (&csh->root_zone,
pzone,
szone,
@@ -697,19 +713,15 @@
&send_shorten_response, csh);
return;
}
-
- GNUNET_assert (rd_count == 1);
-
+ GNUNET_break (rd_count == 1);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Private zone %s found in root zone\n", name);
-
strcpy (csh->private_zone_id, name);
-
csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
- pzone,
- szone,
- &process_shorten_in_private_zone_lookup,
- csh);
+ pzone,
+ szone,
+
&process_shorten_in_private_zone_lookup,
+ csh);
}
@@ -723,7 +735,6 @@
* @param rd_count number of records found
* @param rd record data
* @param signature
- *
*/
static void
process_private_in_root_zone_lookup (void *cls,
@@ -763,25 +774,6 @@
/**
- * Lookup the zone infos and shorten name
- *
- * @param csh the shorten handle
- *
- */
-static void
-start_shorten_name (struct ClientShortenHandle *csh)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Looking for private zone name in root zone\n");
- csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
- &csh->root_zone,
- &csh->private_zone,
-
&process_private_in_root_zone_lookup,
- csh);
-}
-
-
-/**
* Handle a shorten message from the api
*
* @param cls the closure (unused)
@@ -800,7 +792,8 @@
uint16_t msg_size;
const struct GNUNET_GNS_ClientShortenMessage *sh_msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message\n", "SHORTEN");
msg_size = ntohs (message->size);
if (msg_size < sizeof (struct GNUNET_GNS_ClientShortenMessage))
{
@@ -861,7 +854,11 @@
csh->root_zone = zone_hash; //Default zone
else
csh->root_zone = sh_msg->zone;
- start_shorten_name (csh);
+ csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ &csh->root_zone,
+ &csh->private_zone,
+
&process_private_in_root_zone_lookup,
+ csh);
GNUNET_STATISTICS_update (statistics,
"Name shorten attempts", 1, GNUNET_NO);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -872,10 +869,11 @@
* Send get authority response back to client
*
* @param cls the closure containing a client get auth handle
- * @param name the shortened name result or NULL if cannot be shortened
+ * @param name the name of the authority, or NULL on error
*/
static void
-send_get_auth_response(void *cls, const char* name)
+send_get_auth_response (void *cls,
+ const char* name)
{
struct ClientGetAuthHandle *cah = cls;
struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg;
@@ -890,21 +888,20 @@
}
if (NULL == name)
name = "";
- rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage)
- + strlen(name) + 1);
+ rmsg = GNUNET_malloc (sizeof (struct GNUNET_GNS_ClientGetAuthResultMessage)
+ + strlen (name) + 1);
rmsg->id = cah->request_id;
rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT);
rmsg->header.size =
htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) +
- strlen(name) + 1);
+ strlen (name) + 1);
strcpy ((char*)&rmsg[1], name);
GNUNET_SERVER_notification_context_unicast (nc, cah->client,
&rmsg->header,
GNUNET_NO);
GNUNET_SERVER_receive_done (cah->client, GNUNET_OK);
-
GNUNET_free(rmsg);
GNUNET_free_non_null(cah->name);
GNUNET_free(cah);
@@ -930,12 +927,13 @@
uint16_t msg_size;
const struct GNUNET_GNS_ClientGetAuthMessage *sh_msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message\n", "GET_AUTH");
msg_size = ntohs(message->size);
if (msg_size < sizeof (struct GNUNET_GNS_ClientGetAuthMessage))
{
GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
GNUNET_SERVER_notification_context_add (nc, client);
@@ -967,17 +965,17 @@
send_get_auth_response(cah, name);
return;
}
- if (0 != strcmp (name + strlen (name) - strlen(GNUNET_GNS_TLD),
+ if (0 != strcmp (name + strlen (name) - strlen (GNUNET_GNS_TLD),
GNUNET_GNS_TLD))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET_AUTH: %s is not our domain. Returning\n", name);
cah->name = NULL;
- send_get_auth_response(cah, name);
+ send_get_auth_response (cah, name);
return;
}
- if (0 == strcmp(name, GNUNET_GNS_TLD))
+ if (0 == strcmp (name, GNUNET_GNS_TLD))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET_AUTH: %s is us. Returning\n", name);
@@ -988,8 +986,8 @@
cah->name = GNUNET_malloc (strlen (name)
- strlen (GNUNET_GNS_TLD) + 1);
- memcpy(cah->name, name,
- strlen (name) - strlen (GNUNET_GNS_TLD));
+ memcpy (cah->name, name,
+ strlen (name) - strlen (GNUNET_GNS_TLD));
/* Start delegation resolution in our namestore */
gns_resolver_get_authority (zone_hash, zone_hash, name,
@@ -999,7 +997,6 @@
}
-
/**
* Reply to client with the result from our lookup.
*
@@ -1008,9 +1005,9 @@
* @param rd the record data
*/
static void
-send_lookup_response(void* cls,
- uint32_t rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+send_lookup_response (void* cls,
+ uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct ClientLookupHandle* clh = cls;
struct GNUNET_GNS_ClientLookupResultMessage *rmsg;
@@ -1020,8 +1017,7 @@
"LOOKUP_RESULT", rd_count);
len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
- rmsg = GNUNET_malloc (
- len + sizeof (struct
GNUNET_GNS_ClientLookupResultMessage));
+ rmsg = GNUNET_malloc (len + sizeof (struct
GNUNET_GNS_ClientLookupResultMessage));
rmsg->id = clh->request_id;
rmsg->rd_count = htonl(rd_count);
@@ -1041,11 +1037,10 @@
if (NULL != clh->shorten_key)
GNUNET_CRYPTO_rsa_key_free (clh->shorten_key);
- GNUNET_free(clh);
-
+ GNUNET_free (clh);
GNUNET_STATISTICS_update (statistics,
"Completed lookups", 1, GNUNET_NO);
- if (rd != NULL)
+ if (NULL != rd)
GNUNET_STATISTICS_update (statistics,
"Records resolved", rd_count, GNUNET_NO);
}
@@ -1059,9 +1054,9 @@
* @param message the message
*/
static void
-handle_lookup(void *cls,
- struct GNUNET_SERVER_Client * client,
- const struct GNUNET_MessageHeader * message)
+handle_lookup (void *cls,
+ struct GNUNET_SERVER_Client * client,
+ const struct GNUNET_MessageHeader * message)
{
size_t namelen;
char name[MAX_DNS_NAME_LENGTH];
@@ -1075,13 +1070,13 @@
uint16_t msg_size;
const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message\n", "LOOKUP");
msg_size = ntohs(message->size);
if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage))
{
GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message;
@@ -1103,10 +1098,10 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_STRINGS_utf8_tolower(utf_in, &nameptr);
+ GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
}
- namelen = strlen(name)+1;
+ namelen = strlen (name) + 1;
clh = GNUNET_malloc (sizeof (struct ClientLookupHandle));
memset (clh, 0, sizeof (struct ClientLookupHandle));
clh->client = client;
@@ -1126,7 +1121,7 @@
return;
}
- if ((clh->type == GNUNET_GNS_RECORD_A) &&
+ if ((GNUNET_GNS_RECORD_A == clh->type) &&
(GNUNET_OK != v4_enabled))
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -1136,7 +1131,7 @@
return;
}
- if ((clh->type == GNUNET_GNS_RECORD_AAAA) &&
+ if ((GNUNET_GNS_RECORD_AAAA == clh->type) &&
(GNUNET_OK != v6_enabled))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1167,44 +1162,15 @@
only_cached,
&send_lookup_response, clh);
}
-
GNUNET_STATISTICS_update (statistics,
"Record lookup attempts", 1, GNUNET_NO);
}
/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
- return GNUNET_SYSERR;
- }
-#if WINDOWS
- closesocket (s);
-#else
- close (s);
-#endif
- return GNUNET_OK;
-}
-
-
-/**
* Process GNS requests.
*
- * @param cls closure)
+ * @param cls closure
* @param server the initialized server
* @param c configuration to use
*/
@@ -1212,23 +1178,21 @@
run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- char* keyfile;
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
- unsigned long long max_parallel_bg_queries = 0;
- unsigned long long default_lookup_timeout_secs = 0;
- int ignore_pending = GNUNET_NO;
-
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
{&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0},
{&handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0},
{&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
};
+ char* keyfile;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
+ unsigned long long max_parallel_bg_queries = 0;
+ int ignore_pending = GNUNET_NO;
- v6_enabled = test_af (AF_INET6);
- v4_enabled = test_af (AF_INET);
+ v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6);
+ v4_enabled = GNUNET_NETWORK_test_pf (PF_INET);
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns",
- "ZONEKEY", &keyfile))
+ "ZONEKEY",
&keyfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No private key for root zone specified!\n");
@@ -1241,7 +1205,6 @@
zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey);
-
GNUNET_CRYPTO_short_hash(&pkey,
sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&zone_hash);
@@ -1260,76 +1223,69 @@
GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
"AUTO_IMPORT_PKEY"))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Automatic PKEY import is enabled.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Automatic PKEY import is enabled.\n");
auto_import_pkey = GNUNET_YES;
-
}
-
put_interval = INITIAL_PUT_INTERVAL;
-
zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW;
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_time (c, "gns",
- "ZONE_PUBLISH_TIME_WINDOW",
- &zone_publish_time_window))
+ "ZONE_PUBLISH_TIME_WINDOW",
+ &zone_publish_time_window))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Time window for zone iteration: %s\n",
GNUNET_STRINGS_relative_time_to_string
(zone_publish_time_window, GNUNET_YES));
}
-
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (c, "gns",
"MAX_PARALLEL_BACKGROUND_QUERIES",
&max_parallel_bg_queries))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Number of allowed parallel background queries: %llu\n",
- max_parallel_bg_queries);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Number of allowed parallel background queries: %llu\n",
+ max_parallel_bg_queries);
}
if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
"AUTO_IMPORT_CONFIRMATION_REQ"))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Auto import requires user confirmation\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Auto import requires user confirmation\n");
ignore_pending = GNUNET_YES;
}
if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number(c, "gns",
- "DEFAULT_LOOKUP_TIMEOUT",
- &default_lookup_timeout_secs))
+ GNUNET_CONFIGURATION_get_value_time (c, "gns",
+ "DEFAULT_LOOKUP_TIMEOUT",
+ &default_lookup_timeout))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Default lookup timeout: %llus\n", default_lookup_timeout_secs);
- default_lookup_timeout = GNUNET_TIME_relative_multiply(
- GNUNET_TIME_UNIT_SECONDS,
- default_lookup_timeout_secs);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Default lookup timeout: %s\n",
+ GNUNET_STRINGS_relative_time_to_string (default_lookup_timeout,
+ GNUNET_YES));
}
- /**
- * handle to the dht
- */
- dht_handle = GNUNET_DHT_connect(c,
- //max_parallel_bg_queries); //FIXME get ht_len from cfg
- 1024);
-
+ dht_handle = GNUNET_DHT_connect (c,
+ (unsigned int) max_parallel_bg_queries);
if (NULL == dht_handle)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not connect to DHT!\n"));
+ GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ return;
}
- if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, c,
- max_parallel_bg_queries,
- ignore_pending)
- == GNUNET_SYSERR)
+ if (GNUNET_SYSERR ==
+ gns_resolver_init (namestore_handle, dht_handle, zone_hash, c,
+ max_parallel_bg_queries,
+ ignore_pending))
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Unable to initialize resolver!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Unable to initialize resolver!\n"));
GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
return;
}
@@ -1354,18 +1310,9 @@
*/
first_zone_iteration = GNUNET_YES;
zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, NULL);
-
GNUNET_SERVER_add_handlers (server, handlers);
-
- //FIXME
- //GNUNET_SERVER_disconnect_notify (server,
- // &client_disconnect_notification,
- // NULL);
-
statistics = GNUNET_STATISTICS_create ("gns", c);
-
nc = GNUNET_SERVER_notification_context_create (server, 1);
-
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);
}
Modified: gnunet/src/gns/gnunet-service-gns_interceptor.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_interceptor.c 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/gns/gnunet-service-gns_interceptor.c 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing
authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -17,9 +17,7 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
/**
- *
* @file gns/gnunet-service-gns_interceptor.c
* @brief GNUnet GNS interceptor logic
* @author Martin Schanzenbach
@@ -86,8 +84,8 @@
* @param rd the record data
*/
static void
-reply_to_dns(void* cls, uint32_t rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+reply_to_dns (void* cls, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
uint32_t i;
size_t len;
@@ -199,23 +197,25 @@
1024, /* FIXME magic from dns redirector */
&buf,
&len);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Built DNS response! (ret=%d,len=%d)\n", ret, len);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Built DNS response! (ret=%d,len=%d)\n",
+ ret, len);
if (ret == GNUNET_OK)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Answering DNS request\n");
- GNUNET_DNS_request_answer(ilh->request_handle,
- len,
- buf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Answering DNS request\n");
+ GNUNET_DNS_request_answer (ilh->request_handle,
+ len,
+ buf);
- GNUNET_free(buf);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Answered DNS request\n");
+ GNUNET_free (buf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Answered DNS request\n");
}
else
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Error building DNS response! (ret=%d)", ret);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error building DNS response! (ret=%d)", ret);
}
packet->num_answers = 0;
@@ -236,8 +236,8 @@
* @param q the DNS query we received parsed from p
*/
static void
-start_resolution_for_dns(struct GNUNET_DNS_RequestHandle *request,
- struct GNUNET_DNSPARSER_Packet *p,
+start_resolution_for_dns (struct GNUNET_DNS_RequestHandle *request,
+ struct GNUNET_DNSPARSER_Packet *p,
struct GNUNET_DNSPARSER_Query *q)
{
struct InterceptLookupHandle* ilh;
@@ -245,7 +245,6 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting resolution for %s (type=%d)!\n",
q->name, q->type);
-
ilh = GNUNET_malloc(sizeof(struct InterceptLookupHandle));
ilh->packet = p;
ilh->query = q;
@@ -260,7 +259,6 @@
}
-
/**
* The DNS request handler
* Called for every incoming DNS request.
@@ -271,17 +269,16 @@
* @param request udp payload of the DNS request
*/
static void
-handle_dns_request(void *cls,
- struct GNUNET_DNS_RequestHandle *rh,
- size_t request_length,
- const char *request)
+handle_dns_request (void *cls,
+ struct GNUNET_DNS_RequestHandle *rh,
+ size_t request_length,
+ const char *request)
{
struct GNUNET_DNSPARSER_Packet *p;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacked a DNS
request...processing\n");
- p = GNUNET_DNSPARSER_parse (request, request_length);
-
- if (NULL == p)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hijacked a DNS request...processing\n");
+ if (NULL == (p = GNUNET_DNSPARSER_parse (request, request_length)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Received malformed DNS packet, leaving it untouched\n");
@@ -302,7 +299,7 @@
* The way it is implemented here now is buggy and will lead to erratic
* behaviour (if multiple queries are present).
*/
- if (p->num_queries == 0)
+ if (0 == p->num_queries)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No Queries in DNS packet... forwarding\n");
@@ -311,14 +308,6 @@
return;
}
- if (p->num_queries > 1)
- {
- /* Note: We could also look for .gads */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- ">1 queriy in DNS packet... odd. We only process #1\n");
- }
-
-
/**
* Check for .gads/.zkey
*/
@@ -327,19 +316,23 @@
(is_zkey_tld(p->queries[0].name) == GNUNET_YES) ||
(strcmp(p->queries[0].name, GNUNET_GNS_TLD) == 0))
{
- start_resolution_for_dns(rh, p, p->queries);
+ if (p->num_queries > 1)
+ {
+ /* Note: We could also look for .gads */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ ">1 queriy in DNS packet... odd. We only process #1\n");
+ }
+ start_resolution_for_dns (rh, p, p->queries);
+ return;
}
- else
- {
- /**
- * This request does not concern us. Forward to real DNS.
- */
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Request for %s is forwarded to DNS\n", p->queries[0].name);
- GNUNET_DNS_request_forward (rh);
- GNUNET_DNSPARSER_free_packet (p);
- }
-
+ /**
+ * This request does not concern us. Forward to real DNS.
+ */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Request for %s is forwarded to DNS\n",
+ p->queries[0].name);
+ GNUNET_DNS_request_forward (rh);
+ GNUNET_DNSPARSER_free_packet (p);
}
@@ -352,53 +345,48 @@
* @return GNUNET_OK on success
*/
int
-gns_interceptor_init(struct GNUNET_CRYPTO_ShortHashCode zone,
- struct GNUNET_CRYPTO_RsaPrivateKey *key,
- const struct GNUNET_CONFIGURATION_Handle *c)
+gns_interceptor_init (struct GNUNET_CRYPTO_ShortHashCode zone,
+ struct GNUNET_CRYPTO_RsaPrivateKey *key,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
- unsigned long long default_lookup_timeout_secs = 0;
-
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"DNS hijacking enabled... connecting to service.\n");
-
our_zone = zone;
our_key = key;
/**
* Do gnunet dns init here
*/
- dns_handle = GNUNET_DNS_connect(c,
- GNUNET_DNS_FLAG_PRE_RESOLUTION,
- &handle_dns_request, /* rh */
- NULL); /* Closure */
+ dns_handle = GNUNET_DNS_connect (c,
+ GNUNET_DNS_FLAG_PRE_RESOLUTION,
+ &handle_dns_request, /* rh */
+ NULL); /* Closure */
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number(c, "gns",
- "DEFAULT_LOOKUP_TIMEOUT",
- &default_lookup_timeout_secs))
- {
- default_lookup_timeout = GNUNET_TIME_relative_multiply(
- GNUNET_TIME_UNIT_SECONDS,
- default_lookup_timeout_secs);
- }
-
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_time (c, "gns",
+ "DEFAULT_LOOKUP_TIMEOUT",
+ &default_lookup_timeout))
+ default_lookup_timeout = GNUNET_TIME_UNIT_ZERO;
if (NULL == dns_handle)
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Failed to connect to the dnsservice!\n");
return GNUNET_SYSERR;
}
-
return GNUNET_YES;
}
+
/**
* Disconnect from interceptor
*/
void
-gns_interceptor_stop(void)
+gns_interceptor_stop ()
{
- if (dns_handle)
+ if (NULL != dns_handle)
+ {
GNUNET_DNS_disconnect(dns_handle);
+ dns_handle = NULL;
+ }
}
/* end of gns_interceptor.c */
Modified: gnunet/src/gns/gnunet-service-gns_interceptor.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_interceptor.h 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/gns/gnunet-service-gns_interceptor.h 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -1,6 +1,32 @@
+/*
+ This file is part of GNUnet.
+ (C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing
authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file gns/gnunet-service-gns_interceptor.h
+ * @brief GNUnet GNS service
+ * @author Martin Schanzenbach
+ */
#ifndef GNUNET_GNS_INTERCEPTOR_H
#define GNUNET_GNS_INTERCEPTOR_H
+#include "gnunet_util_lib.h"
+
/**
* Initialize dns interceptor
*
@@ -10,14 +36,14 @@
* @return GNUNET_YES on success GNUNET_SYSERR on error
*/
int
-gns_interceptor_init(struct GNUNET_CRYPTO_ShortHashCode zone,
- struct GNUNET_CRYPTO_RsaPrivateKey *key,
- const struct GNUNET_CONFIGURATION_Handle *c);
+gns_interceptor_init (struct GNUNET_CRYPTO_ShortHashCode zone,
+ struct GNUNET_CRYPTO_RsaPrivateKey *key,
+ const struct GNUNET_CONFIGURATION_Handle *c);
/**
* Stops the interceptor
*/
void
-gns_interceptor_stop(void);
+gns_interceptor_stop (void);
#endif
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -186,6 +186,7 @@
return ret;
}
+
/**
* Determine if this name is canonical (is a legal name in a zone, without
delegation);
* note that we do not test that the name does not contain illegal characters,
we only
@@ -1490,6 +1491,7 @@
finish_lookup (rh, rlh, 1, &rd);
}
+
/**
* Resolve DNS name via local stub resolver
*
@@ -3960,7 +3962,7 @@
* @param rd_count number of results (0)
* @param rd data (NULL)
*/
-void
+static void
handle_delegation_ns_shorten (void* cls,
struct ResolverHandle *rh,
uint32_t rd_count,
@@ -4289,7 +4291,7 @@
* @param rd_count number of results (0)
* @param rd data (NULL)
*/
-void
+static void
handle_delegation_result_ns_get_auth(void* cls,
struct ResolverHandle *rh,
uint32_t rd_count,
Modified: gnunet/src/gns/gnunet-service-gns_resolver.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.h 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/gns/gnunet-service-gns_resolver.h 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -1,3 +1,27 @@
+/*
+ This file is part of GNUnet.
+ (C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing
authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file gns/gnunet-service-gns_resolver.h
+ * @brief GNUnet GNS service
+ * @author Martin Schanzenbach
+ */
#ifndef GNS_RESOLVER_H
#define GNS_RESOLVER_H
@@ -5,12 +29,16 @@
#include "gnunet_dht_service.h"
#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 60)
+
#define GNUNET_GNS_DEFAULT_LOOKUP_TIMEOUT \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+
#define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT
+
#define DHT_GNS_REPLICATION_LEVEL 5
#define GNUNET_GNS_MAX_PARALLEL_LOOKUPS 500
+
#define GNUNET_GNS_MAX_NS_TASKS 500
/*
@@ -23,17 +51,26 @@
struct AuthorityChain *next;
- /* the zone hash of the authority */
+ /**
+ * the zone hash of the authority
+ */
struct GNUNET_CRYPTO_ShortHashCode zone;
- /* (local) name of the authority */
+ /**
+ * (local) name of the authority
+ */
char name[MAX_DNS_LABEL_LENGTH];
- /* was the ns entry fresh */
+ /**
+ * was the ns entry fresh
+ */
int fresh;
};
-/* handle to a resolution process */
+
+/**
+ * handle to a resolution process
+ */
struct ResolverHandle;
@@ -45,8 +82,8 @@
* @param rd result data
*/
typedef void (*RecordLookupProcessor) (void *cls,
- uint32_t rd_count,
- const struct GNUNET_NAMESTORE_RecordData
*rd);
+ uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData
*rd);
/**
@@ -55,16 +92,18 @@
* @param cls the closure
* @param name shortened name
*/
-typedef void (*ShortenResultProcessor) (void *cls, const char* name);
+typedef void (*ShortenResultProcessor) (void *cls,
+ const char* name);
/**
* processor for an authority result
*
* @param cls the closure
- * @param name name
+ * @param name name of the authority
*/
-typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name);
+typedef void (*GetAuthorityResultProcessor) (void *cls,
+ const char* name);
/**
* processor for a resolution result
@@ -72,34 +111,57 @@
* @param cls the closure
* @param rh the resolution handle
* @param rd_count number of results
- * @param rd result data
+ * @param rd result data (array of 'rd_count' records)
*/
typedef void (*ResolutionResultProcessor) (void *cls,
- struct ResolverHandle *rh,
- uint32_t rd_count,
- const struct GNUNET_NAMESTORE_RecordData
*rd);
+ struct ResolverHandle *rh,
+ uint32_t rd_count,
+ const struct
GNUNET_NAMESTORE_RecordData *rd);
/**
* Resolution status indicator
- * RSL_RECORD_EXISTS: the name to lookup exists
- * RSL_RECORD_EXPIRED: the name in the record expired
- * RSL_TIMED_OUT: resolution timed out
- * RSL_DELEGATE_VPN: Found VPN delegation
- * RSL_DELEGATE_NS: Found NS delegation
- * RSL_DELEGATE_PKEY: Found PKEY delegation
- * RSL_CNAME_FOUND: Found CNAME record
- * RSL_PKEY_REVOKED: Found PKEY has been revoked
*/
enum ResolutionStatus
{
+ /**
+ * the name to lookup exists
+ */
RSL_RECORD_EXISTS = 1,
+
+ /**
+ * the name in the record expired
+ */
RSL_RECORD_EXPIRED = 2,
+
+ /**
+ * resolution timed out
+ */
RSL_TIMED_OUT = 4,
+
+ /**
+ * Found VPN delegation
+ */
RSL_DELEGATE_VPN = 8,
+
+ /**
+ * Found NS delegation
+ */
RSL_DELEGATE_NS = 16,
+
+ /**
+ * Found PKEY delegation
+ */
RSL_DELEGATE_PKEY = 32,
+
+ /**
+ * Found CNAME record
+ */
RSL_CNAME_FOUND = 64,
+
+ /**
+ * Found PKEY has been revoked
+ */
RSL_PKEY_REVOKED = 128
};
@@ -116,91 +178,149 @@
struct ResolverHandle
{
- /* DLL */
+ /**
+ * DLL
+ */
struct ResolverHandle *next;
- /* DLL */
+ /**
+ * DLL
+ */
struct ResolverHandle *prev;
- /* Last record data found */
+ /**
+ * Last record data found
+ */
struct GNUNET_NAMESTORE_RecordData rd;
- /* Number of last record data found */
+ /**
+ * Number of last record data found
+ */
unsigned int rd_count;
- /* The name to resolve */
+ /**
+ * The name to resolve
+ */
char name[MAX_DNS_NAME_LENGTH];
- /* has this query been answered? how many matches */
+ /**
+ * has this query been answered? how many matches
+ */
int answered;
- /* Use only cache */
+ /**
+ * Use only cache
+ */
int only_cached;
- /* the authoritative zone to query */
+ /**
+ * the authoritative zone to query
+ */
struct GNUNET_CRYPTO_ShortHashCode authority;
- /* the name of the authoritative zone to query */
+ /**
+ * the name of the authoritative zone to query
+ */
char authority_name[MAX_DNS_LABEL_LENGTH];
- /* a handle for dht lookups. should be NULL if no lookups are in progress */
+ /**
+ * a handle for dht lookups. should be NULL if no lookups are in progress
+ */
struct GNUNET_DHT_GetHandle *get_handle;
- /* timeout set for this lookup task */
+ /**
+ * timeout set for this lookup task
+ */
struct GNUNET_TIME_Relative timeout;
- /* a handle to a vpn request */
+ /**
+ * a handle to a vpn request
+ */
struct GNUNET_VPN_RedirectionRequest *vpn_handle;
- /* a socket for a dns request */
+ /**
+ * a socket for a dns request
+ */
struct GNUNET_NETWORK_Handle *dns_sock;
- /* a synthesized dns name */
+ /**
+ * a synthesized dns name
+ */
char dns_name[MAX_DNS_NAME_LENGTH];
- /* the authoritative dns zone */
+ /**
+ * the authoritative dns zone
+ */
char dns_zone[MAX_DNS_NAME_LENGTH];
- /* the address of the DNS server FIXME not needed? */
+ /**
+ * the address of the DNS server FIXME not needed?
+ */
struct sockaddr_in dns_addr;
- /* handle to the local stub resolver request */
+ /**
+ * handle to the local stub resolver request
+ */
struct GNUNET_RESOLVER_RequestHandle *dns_resolver_handle;
- /* select task for DNS */
+ /**
+ * select task for DNS
+ */
GNUNET_SCHEDULER_TaskIdentifier dns_read_task;
- /* pointer to raw dns query payload FIXME needs to be freed/NULL */
+ /**
+ * pointer to raw dns query payload FIXME needs to be freed/NULL
+ */
char *dns_raw_packet;
- /* size of the raw dns query */
+ /**
+ * size of the raw dns query
+ */
size_t dns_raw_packet_size;
- /* timeout task for the lookup */
+ /**
+ * timeout task for the lookup
+ */
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
- /* continuation to call on timeout */
+ /**
+ * continuation to call on timeout
+ */
GNUNET_SCHEDULER_Task timeout_cont;
- /* closure for timeout cont */
+ /**
+ * closure for timeout cont
+ */
void* timeout_cont_cls;
- /* called when resolution phase finishes */
+ /**
+ * called when resolution phase finishes
+ */
ResolutionResultProcessor proc;
- /* closure passed to proc */
+ /**
+ * closure passed to proc
+ */
void* proc_cls;
- /* DLL to store the authority chain */
+ /**
+ * DLL to store the authority chain
+ */
struct AuthorityChain *authority_chain_head;
- /* DLL to store the authority chain */
+ /**
+ * DLL to store the authority chain
+ */
struct AuthorityChain *authority_chain_tail;
- /* status of the resolution result */
+ /**
+ * status of the resolution result
+ */
enum ResolutionStatus status;
- /* The provate local zone of this request */
+ /**
+ * The provate local zone of this request
+ */
struct GNUNET_CRYPTO_ShortHashCode private_local_zone;
/**
@@ -233,16 +353,24 @@
*/
struct RecordLookupHandle
{
- /* the record type to look up */
+ /**
+ * the record type to look up
+ */
enum GNUNET_GNS_RecordType record_type;
- /* the name to look up */
+ /**
+ * the name to look up
+ */
char name[MAX_DNS_NAME_LENGTH];
- /* Method to call on record resolution result */
+ /**
+ * Method to call on record resolution result
+ */
RecordLookupProcessor proc;
- /* closure to pass to proc */
+ /**
+ * closure to pass to proc
+ */
void* proc_cls;
};
@@ -253,98 +381,150 @@
*/
struct NameShortenHandle
{
- /* Method to call on shorten result */
+ /**
+ * Method to call on shorten result
+ */
ShortenResultProcessor proc;
- /* closure to pass to proc */
+ /**
+ * closure to pass to proc
+ */
void* proc_cls;
- /* result of shorten */
+ /**
+ * result of shorten
+ */
char result[MAX_DNS_NAME_LENGTH];
- /* root zone */
+ /**
+ * root zone
+ */
struct GNUNET_CRYPTO_ShortHashCode *root_zone;
- /* private zone */
+ /**
+ * private zone
+ */
struct GNUNET_CRYPTO_ShortHashCode *private_zone;
- /* name of private zone */
+ /**
+ * name of private zone
+ */
char private_zone_name[MAX_DNS_LABEL_LENGTH];
- /* shorten zone */
+ /**
+ * shorten zone
+ */
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone;
- /* name of shorten zone */
+ /**
+ * name of shorten zone
+ */
char shorten_zone_name[MAX_DNS_LABEL_LENGTH];
};
+
/**
* Handle to a get authority context
*/
struct GetNameAuthorityHandle
{
- /* the name to look up authority for */
+ /**
+ * the name to look up authority for
+ */
char name[MAX_DNS_NAME_LENGTH];
- /* the result */
+ /**
+ * the result
+ */
char result[MAX_DNS_NAME_LENGTH];
- /* Method to call on result */
+ /**
+ * Method to call on result
+ */
GetAuthorityResultProcessor proc;
- /* closure to pass to proc */
+ /**
+ * closure to pass to proc
+ */
void* proc_cls;
};
+
/**
* Handle to a pseu lookup
*/
struct GetPseuAuthorityHandle
{
- /* DLL */
+ /**
+ * DLL
+ */
struct GetPseuAuthorityHandle *next;
- /* DLL */
+ /**
+ * DLL
+ */
struct GetPseuAuthorityHandle *prev;
- /* the name to store the zone under */
+ /**
+ * the name to store the zone under
+ */
char name[MAX_DNS_LABEL_LENGTH];
- /* test name to store the zone under */
+ /**
+ * test name to store the zone under
+ */
char test_name[MAX_DNS_LABEL_LENGTH];
- /* the zone of our authority */
+ /**
+ * the zone of our authority
+ */
struct GNUNET_CRYPTO_ShortHashCode our_zone;
- /* the private key of the zone to store the pseu in */
+ /**
+ * the private key of the zone to store the pseu in
+ */
struct GNUNET_CRYPTO_RsaPrivateKey *key;
- /* a handle for dht lookups. should be NULL if no lookups are in progress */
+ /**
+ * a handle for dht lookups. should be NULL if no lookups are in progress
+ */
struct GNUNET_DHT_GetHandle *get_handle;
- /* timeout task for lookup */
+ /**
+ * timeout task for lookup
+ */
GNUNET_SCHEDULER_TaskIdentifier timeout;
- /* Authority to shorten */
+ /**
+ * Authority to shorten
+ */
struct AuthorityChain *auth;
- /* handle to namestore request */
+ /**
+ * handle to namestore request
+ */
struct GNUNET_NAMESTORE_QueueEntry* namestore_task;
};
+
/**
* Namestore queue entries in background
*/
struct NamestoreBGTask
{
- /* node in heap */
+ /**
+ * node in heap
+ */
struct GNUNET_CONTAINER_HeapNode *node;
- /* queue entry */
+ /**
+ * queue entry
+ */
struct GNUNET_NAMESTORE_QueueEntry *qe;
};
+
/**
* Initialize the resolver
* MUST be called before other gns_resolver_* methods
@@ -359,19 +539,21 @@
* @returns GNUNET_OK on success
*/
int
-gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
- struct GNUNET_DHT_Handle *dh,
- struct GNUNET_CRYPTO_ShortHashCode lz,
- const struct GNUNET_CONFIGURATION_Handle *c,
- unsigned long long max_bg_queries,
- int ignore_pending);
+gns_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
+ struct GNUNET_DHT_Handle *dh,
+ struct GNUNET_CRYPTO_ShortHashCode lz,
+ const struct GNUNET_CONFIGURATION_Handle *c,
+ unsigned long long max_bg_queries,
+ int ignore_pending);
+
/**
* Cleanup resolver: Terminate pending lookups
*/
void
-gns_resolver_cleanup(void);
+gns_resolver_cleanup (void);
+
/**
* Lookup of a record in a specific zone
* calls RecordLookupProcessor on result or timeout
@@ -387,16 +569,17 @@
* @param cls the closure to pass to proc
*/
void
-gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone,
- struct GNUNET_CRYPTO_ShortHashCode pzone,
- uint32_t record_type,
- const char* name,
- struct GNUNET_CRYPTO_RsaPrivateKey *key,
- struct GNUNET_TIME_Relative timeout,
- int only_cached,
- RecordLookupProcessor proc,
- void* cls);
+gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
+ struct GNUNET_CRYPTO_ShortHashCode pzone,
+ uint32_t record_type,
+ const char* name,
+ struct GNUNET_CRYPTO_RsaPrivateKey *key,
+ struct GNUNET_TIME_Relative timeout,
+ int only_cached,
+ RecordLookupProcessor proc,
+ void* cls);
+
/**
* Shortens a name if possible. If the shortening fails
* name will be returned as shortened string. Else
@@ -414,15 +597,16 @@
* @param proc_cls the closure to pass to proc
*/
void
-gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode *zone,
- struct GNUNET_CRYPTO_ShortHashCode *pzone,
- struct GNUNET_CRYPTO_ShortHashCode *szone,
- const char* name,
- const char* private_zone_name,
- const char* shorten_zone_name,
- ShortenResultProcessor proc,
- void* proc_cls);
+gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone,
+ struct GNUNET_CRYPTO_ShortHashCode *pzone,
+ struct GNUNET_CRYPTO_ShortHashCode *szone,
+ const char* name,
+ const char* private_zone_name,
+ const char* shorten_zone_name,
+ ShortenResultProcessor proc,
+ void* proc_cls);
+
/**
* Tries to resolve the authority for name
* in our namestore
@@ -434,11 +618,11 @@
* @param proc_cls the closure to pass to the processor
*/
void
-gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone,
- struct GNUNET_CRYPTO_ShortHashCode pzone,
- const char* name,
- GetAuthorityResultProcessor proc,
- void* proc_cls);
+gns_resolver_get_authority (struct GNUNET_CRYPTO_ShortHashCode zone,
+ struct GNUNET_CRYPTO_ShortHashCode pzone,
+ const char* name,
+ GetAuthorityResultProcessor proc,
+ void* proc_cls);
/**
* Generic function to check for TLDs
@@ -448,8 +632,10 @@
* @return GNUNET_YES or GNUNET_NO
*/
int
-is_tld(const char* name, const char* tld);
+is_tld (const char* name,
+ const char* tld);
+
/**
* Checks for gnunet/zkey
*/
Modified: gnunet/src/gns/plugin_block_gns.c
===================================================================
--- gnunet/src/gns/plugin_block_gns.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/gns/plugin_block_gns.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2010 Christian Grothoff (and other contributing authors)
+ (C) 2010, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -63,17 +63,19 @@
size_t xquery_size, const void *reply_block,
size_t reply_block_size)
{
+ const struct GNSNameRecordBlock *nrb;
const char* name;
+ const char *name_end;
+ const char *rd_data;
struct GNUNET_HashCode query_key;
struct GNUNET_HashCode mhash;
struct GNUNET_HashCode chash;
struct GNUNET_CRYPTO_ShortHashCode pkey_hash;
- struct GNSNameRecordBlock *nrb;
struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
uint32_t rd_count;
- char* rd_data = NULL;
- int rd_len;
+ size_t rd_len;
+ size_t name_len;
uint32_t record_xquery;
unsigned int record_match;
@@ -97,9 +99,15 @@
/* this is a reply */
- nrb = (struct GNSNameRecordBlock *)reply_block;
- name = (const char*)&nrb[1];
-
+ nrb = (const struct GNSNameRecordBlock *)reply_block;
+ name = (const char*) &nrb[1];
+ name_end = memchr (name, 0, reply_block_size - sizeof (struct
GNSNameRecordBlock));
+ if (NULL == name_end)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
+ name_len = (name_end - name) + 1;
GNUNET_CRYPTO_short_hash (&nrb->public_key,
sizeof(nrb->public_key),
&pkey_hash);
@@ -121,9 +129,8 @@
record_match = 0;
rd_count = ntohl(nrb->rd_count);
- rd_data = (char*)&nrb[1];
- rd_data += strlen(name) + 1;
- rd_len = reply_block_size - (strlen(name) + 1
+ rd_data = &name[name_len];
+ rd_len = reply_block_size - (name_len
+ sizeof(struct GNSNameRecordBlock));
{
struct GNUNET_NAMESTORE_RecordData rd[rd_count];
Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/hostlist/hostlist-client.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -298,7 +298,7 @@
left -= cpy;
if (download_pos < sizeof (struct GNUNET_MessageHeader))
{
- GNUNET_assert (left == 0);
+ GNUNET_assert (0 == left);
break;
}
msg = (const struct GNUNET_MessageHeader *) download_buffer;
Modified: gnunet/src/include/gnunet_constants.h
===================================================================
--- gnunet/src/include/gnunet_constants.h 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/include/gnunet_constants.h 2012-10-26 22:13:01 UTC (rev
24573)
@@ -52,30 +52,11 @@
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MINUTES, 5)
/**
- * After how long do we consider a connection to a peer dead
- * if we got an explicit disconnect and were unable to reconnect?
- */
-#define GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
-
-/**
* How long do we delay reading more from a peer after a quota violation?
*/
#define GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 2)
/**
- * How long do we wait after a FORK+EXEC before testing for the
- * resulting process to be up (port open, waitpid, etc.)?
- */
-#define GNUNET_CONSTANTS_EXEC_WAIT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 200)
-
-/**
- * After how long do we retry a service connection that was
- * unavailable? Used in cases where an exponential back-off
- * seems inappropriate.
- */
-#define GNUNET_CONSTANTS_SERVICE_RETRY GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 500)
-
-/**
* After how long do we consider a service unresponsive
* even if we assume that the service commonly does not
* respond instantly (DNS, Database, etc.).
@@ -119,18 +100,6 @@
#define GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_MESSAGE (24 + sizeof (struct
GNUNET_HashCode))
/**
- * Size of the 'struct OutboundMessage' of the transport
- * (which, in combination with the
- * GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_MESSAGE) defines
- * the headers that must be pre-pendable to all GNUnet
- * messages. Taking GNUNET_SERVER_MAX_MESSAGE_SIZE
- * and subtracting these two constants defines the largest
- * message core can handle.
- */
-#define GNUNET_CONSTANTS_TRANSPORT_SIZE_OUTBOUND_MESSAGE (16 + sizeof (struct
GNUNET_PeerIdentity))
-
-
-/**
* What is the maximum size for encrypted messages? Note that this
* number imposes a clear limit on the maximum size of any message.
* Set to a value close to 64k but not so close that transports will
Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/include/gnunet_crypto_lib.h 2012-10-26 22:13:01 UTC (rev
24573)
@@ -71,7 +71,6 @@
*/
#define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8)
-
/**
* @brief Length of RSA encrypted data (2048 bit)
*
@@ -84,30 +83,27 @@
*/
#define GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH 256
-
/**
* Length of an RSA KEY (n,e,len), 2048 bit (=256 octests) key n, 2 byte e
*/
#define GNUNET_CRYPTO_RSA_KEY_LENGTH 258
-
/**
* Length of a hash value
*/
#define GNUNET_CRYPTO_HASH_LENGTH 512/8
-
/**
* FIXME: what is an acceptable value here?
* Note: round to multiple of 8 minus 2.
*/
-#define GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH 510
+#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 138
/**
* FIXME: what is an acceptable value here?
* Maximum length of the public key (q-point, Q = dP) when encoded.
*/
-#define GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH 254
+#define GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH 140
/**
@@ -277,7 +273,7 @@
/**
* S-expression, padded with zeros.
*/
- char sexpr[GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH];
+ char sexpr[GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH];
};
Modified: gnunet/src/include/gnunet_network_lib.h
===================================================================
--- gnunet/src/include/gnunet_network_lib.h 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/include/gnunet_network_lib.h 2012-10-26 22:13:01 UTC (rev
24573)
@@ -73,6 +73,16 @@
/**
+ * Test if the given protocol family is supported by this system.
+ *
+ * @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX)
+ * @return GNUNET_OK if the PF is supported
+ */
+int
+GNUNET_NETWORK_test_pf (int pf);
+
+
+/**
* Given a unixpath that is too long (larger than UNIX_PATH_MAX),
* shorten it to an acceptable length while keeping it unique
* and making sure it remains a valid filename (if possible).
Modified: gnunet/src/include/gnunet_time_lib.h
===================================================================
--- gnunet/src/include/gnunet_time_lib.h 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/include/gnunet_time_lib.h 2012-10-26 22:13:01 UTC (rev
24573)
@@ -150,7 +150,23 @@
#define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever_ ()
+
/**
+ * Threshold after which exponential backoff should not increase (15 m).
+ */
+#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
+
+
+/**
+ * Perform our standard exponential back-off calculation, starting at 1mst
+ * and then going by a factor of 2 up unto a maximum of 1s.
+ *
+ * @param r current backoff time, initially zero
+ */
+#define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min
(GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_max
(GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2));
+
+/**
* Return relative time of 0ms.
*/
struct GNUNET_TIME_Relative
Modified: gnunet/src/namestore/test_namestore_api.c
===================================================================
--- gnunet/src/namestore/test_namestore_api.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/namestore/test_namestore_api.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -49,6 +49,24 @@
static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
+
+static void
+cleanup ()
+{
+ if (NULL != nsh)
+ {
+ GNUNET_NAMESTORE_disconnect (nsh);
+ nsh = NULL;
+ }
+ if (NULL != privkey)
+ {
+ GNUNET_CRYPTO_rsa_key_free (privkey);
+ privkey = NULL;
+ }
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
/**
* Re-establish the connection to the service.
*
@@ -63,17 +81,7 @@
GNUNET_NAMESTORE_cancel (nsqe);
nsqe = NULL;
}
- if (nsh != NULL)
- {
- GNUNET_NAMESTORE_disconnect (nsh);
- nsh = NULL;
- }
- if (privkey != NULL)
- {
- GNUNET_CRYPTO_rsa_key_free (privkey);
- privkey = NULL;
- }
- GNUNET_SCHEDULER_shutdown ();
+ cleanup ();
res = 1;
}
@@ -81,21 +89,7 @@
static void
end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (privkey != NULL)
- {
- GNUNET_CRYPTO_rsa_key_free (privkey);
- privkey = NULL;
- }
- if (nsh != NULL)
- {
- GNUNET_NAMESTORE_disconnect (nsh);
- nsh = NULL;
- }
+ cleanup ();
res = 0;
}
@@ -113,8 +107,12 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Namestore lookup result %p `%s' %i %p %p\n",
zone_key, name, rd_count, rd, signature);
- res = 0;
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (endbadly_task);
+ endbadly_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
@@ -124,9 +122,11 @@
const char *name = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Name store added record for `%s': %s\n", name, (success ==
GNUNET_OK) ? "SUCCESS" : "FAIL");
-
- nsqe = GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0,
&name_lookup_proc, NULL);
+ "Name store added record for `%s': %s\n",
+ name,
+ (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
+ nsqe = GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0,
+ &name_lookup_proc, NULL);
}
@@ -142,19 +142,21 @@
endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&endbadly, NULL);
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
+ GNUNET_asprintf (&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+ "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
- privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file);
+ privkey = GNUNET_CRYPTO_rsa_key_create_from_file (hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
- GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
+ GNUNET_CRYPTO_rsa_key_get_public (privkey, &pubkey);
GNUNET_CRYPTO_short_hash (&pubkey, sizeof (pubkey), &zone);
memset (&signature, '\0', sizeof (signature));
rd.expiration_time = GNUNET_TIME_absolute_get().abs_value;
rd.record_type = TEST_RECORD_TYPE;
rd.data_size = TEST_RECORD_DATALEN;
- rd.data = GNUNET_malloc(TEST_RECORD_DATALEN);
+ rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
Modified: gnunet/src/namestore/test_namestore_api_lookup.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup.c 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/namestore/test_namestore_api_lookup.c 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
+ (C) 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -18,7 +18,7 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file namestore/test_namestore_api.c
+ * @file namestore/test_namestore_api_lookup.c
* @brief testcase for namestore_api.c
*/
#include "platform.h"
@@ -53,11 +53,30 @@
static struct GNUNET_NAMESTORE_RecordData *s_rd;
+static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
+
static char *s_name;
static int res;
+static void
+cleanup ()
+{
+ if (NULL != nsh)
+ {
+ GNUNET_NAMESTORE_disconnect (nsh);
+ nsh = NULL;
+ }
+ if (NULL != privkey)
+ {
+ GNUNET_CRYPTO_rsa_key_free (privkey);
+ privkey = NULL;
+ }
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
/**
* Re-establish the connection to the service.
*
@@ -67,12 +86,7 @@
static void
endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (nsh != NULL)
- GNUNET_NAMESTORE_disconnect (nsh);
- nsh = NULL;
- if (privkey != NULL)
- GNUNET_CRYPTO_rsa_key_free (privkey);
- privkey = NULL;
+ cleanup ();
res = 1;
}
@@ -80,22 +94,12 @@
static void
end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- int c;
+ unsigned int c;
- if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = GNUNET_SCHEDULER_NO_TASK;
- }
for (c = 0; c < RECORDS; c++)
GNUNET_free_non_null((void *) s_rd[c].data);
GNUNET_free (s_rd);
- if (privkey != NULL)
- GNUNET_CRYPTO_rsa_key_free (privkey);
- privkey = NULL;
- if (nsh != NULL)
- GNUNET_NAMESTORE_disconnect (nsh);
- nsh = NULL;
+ cleanup ();
}
@@ -111,19 +115,21 @@
static int found = GNUNET_NO;
int c;
- if (n != NULL)
+ if (NULL != n)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
- if (0 != memcmp (zone_key, &pubkey, sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
+ if (0 != memcmp (zone_key, &pubkey,
+ sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
{
GNUNET_break (0);
}
GNUNET_assert (NULL != signature);
- if (0 != memcmp (signature, s_signature, sizeof (struct
GNUNET_CRYPTO_RsaSignature)))
+ if (0 != memcmp (signature, s_signature,
+ sizeof (struct GNUNET_CRYPTO_RsaSignature)))
{
GNUNET_break (0);
}
- if (0 != strcmp(n, s_name))
+ if (0 != strcmp (n, s_name))
{
GNUNET_break (0);
}
@@ -143,14 +149,20 @@
}
else
{
- if (found != GNUNET_YES)
+ if (GNUNET_YES != found)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name
`%s'\n", s_name);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to lookup records for name `%s'\n", s_name);
res = 1;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name);
}
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ if (GNUNET_SCHEDULER_NO_TASK != endbadly_task)
+ {
+ GNUNET_SCHEDULER_cancel (endbadly_task);
+ endbadly_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
@@ -159,17 +171,22 @@
{
char * name = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s':
%s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
- if (success == GNUNET_OK)
+ nsqe = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Name store added record for `%s': %s\n", name,
+ (GNUNET_OK == success) ? "SUCCESS" : "FAIL");
+ if (GNUNET_OK == success)
{
res = 0;
- GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0, &name_lookup_proc,
NULL);
+ GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0,
+ &name_lookup_proc, NULL);
}
else
{
res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name
`%s'\n", name);
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to put records for name `%s'\n", name);
+ GNUNET_SCHEDULER_shutdown ();
}
}
@@ -200,12 +217,14 @@
{
size_t rd_ser_len;
struct GNUNET_TIME_Absolute et;
+ char rd_ser[rd_ser_len];
- endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &endbadly, NULL);
/* load privat key from file not included in zonekey dir */
privkey = GNUNET_CRYPTO_rsa_key_create_from_file("test_hostkey");
- GNUNET_assert (privkey != NULL);
+ GNUNET_assert (NULL != privkey);
/* get public key */
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
@@ -214,24 +233,23 @@
s_rd = create_record (RECORDS);
rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
- char rd_ser[rd_ser_len];
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
et.abs_value = s_rd[0].expiration_time;
- s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd,
RECORDS);
+ s_signature = GNUNET_NAMESTORE_create_signature (privkey, et, s_name,
+ s_rd, RECORDS);
/* create random zone hash */
- GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
+ GNUNET_CRYPTO_short_hash (&pubkey,
+ sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &s_zone);
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
-
- GNUNET_break (s_rd != NULL);
- GNUNET_break (s_name != NULL);
-
- GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- RECORDS, s_rd, s_signature, put_cont, s_name);
+ nsqe = GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ RECORDS, s_rd, s_signature,
+ &put_cont, s_name);
}
@@ -251,4 +269,4 @@
}
-/* end of test_namestore_api.c */
+/* end of test_namestore_api_lookup.c */
Modified: gnunet/src/nat/nat.c
===================================================================
--- gnunet/src/nat/nat.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/nat/nat.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -759,11 +759,7 @@
h->server_stdout = NULL;
h->server_stdout_handle = NULL;
/* now try to restart it */
- h->server_retry_delay =
- GNUNET_TIME_relative_multiply (h->server_retry_delay, 2);
- h->server_retry_delay =
- GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_HOURS,
- h->server_retry_delay);
+ h->server_retry_delay = GNUNET_TIME_STD_BACKOFF (h->server_retry_delay);
h->server_read_task =
GNUNET_SCHEDULER_add_delayed (h->server_retry_delay,
&restart_nat_server, h);
Modified: gnunet/src/nse/nse_api.c
===================================================================
--- gnunet/src/nse/nse_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/nse/nse_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -154,16 +154,7 @@
h->reconnect_delay.rel_value);
h->reconnect_task =
GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
- if (h->reconnect_delay.rel_value == 0)
- {
- h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
- }
- else
- {
- h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2);
- h->reconnect_delay =
- GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
h->reconnect_delay);
- }
+ h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
}
Modified: gnunet/src/pt/test_gns_vpn.c
===================================================================
--- gnunet/src/pt/test_gns_vpn.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/pt/test_gns_vpn.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -415,30 +415,6 @@
/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
- return GNUNET_SYSERR;
- }
- close (s);
- return GNUNET_OK;
-}
-
-
-/**
* Open '/dev/null' and make the result the given
* file descriptor.
*
@@ -579,13 +555,13 @@
dest_af = AF_INET;
src_af = AF_INET;
- if (GNUNET_OK == test_af (AF_INET6))
+ if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET6))
use_v6 = GNUNET_YES;
else
use_v6 = GNUNET_NO;
- if ( (GNUNET_OK != test_af (src_af)) ||
- (GNUNET_OK != test_af (dest_af)) )
+ if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) ||
+ (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) )
{
fprintf (stderr,
"Required address families not supported by this system, skipping
test.\n");
Modified: gnunet/src/pt/test_gnunet_vpn.c
===================================================================
--- gnunet/src/pt/test_gnunet_vpn.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/pt/test_gnunet_vpn.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -390,30 +390,6 @@
}
-/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
- return GNUNET_SYSERR;
- }
- close (s);
- return GNUNET_OK;
-}
-
-
int
main (int argc, char *const *argv)
{
@@ -476,7 +452,8 @@
fprintf (stderr, "invalid binary suffix `%s'\n", type);
return 1;
}
- if ((GNUNET_OK != test_af (src_af)) || (GNUNET_OK != test_af (dest_af)))
+ if ((GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) ||
+ (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)))
{
fprintf (stderr,
"Required address families not supported by this system, skipping
test.\n");
Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/statistics/statistics_api.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -516,9 +516,7 @@
}
h->backoff_task =
GNUNET_SCHEDULER_add_delayed (h->backoff, &reconnect_task, h);
- h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2);
- h->backoff =
- GNUNET_TIME_relative_min (h->backoff, GNUNET_CONSTANTS_SERVICE_TIMEOUT);
+ h->backoff = GNUNET_TIME_STD_BACKOFF (h->backoff);
}
Modified: gnunet/src/stream/stream_api.c
===================================================================
--- gnunet/src/stream/stream_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/stream/stream_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -895,6 +895,7 @@
packet++;
}
io_handle->packets_sent = packet;
+ // FIXME: 8s is not good, should use GNUNET_TIME_STD_BACKOFF...
if (GNUNET_SCHEDULER_NO_TASK == socket->data_retransmission_task_id)
socket->data_retransmission_task_id =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
Modified: gnunet/src/testing_old/testing.c
===================================================================
--- gnunet/src/testing_old/testing.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/testing_old/testing.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -45,7 +45,21 @@
*/
#define EMPTY_HACK GNUNET_YES
+
/**
+ * After how long do we retry a service connection that was
+ * unavailable? Used in cases where an exponential back-off
+ * seems inappropriate.
+ */
+#define GNUNET_CONSTANTS_SERVICE_RETRY GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 500)
+
+/**
+ * How long do we wait after a FORK+EXEC before testing for the
+ * resulting process to be up (port open, waitpid, etc.)?
+ */
+#define GNUNET_CONSTANTS_EXEC_WAIT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 200)
+
+/**
* How long do we wait after starting gnunet-service-arm
* for the core service to be alive?
*/
Modified: gnunet/src/testing_old/testing_group.c
===================================================================
--- gnunet/src/testing_old/testing_group.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/testing_old/testing_group.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -41,6 +41,12 @@
/**
+ * How long do we wait after a FORK+EXEC before testing for the
+ * resulting process to be up (port open, waitpid, etc.)?
+ */
+#define GNUNET_CONSTANTS_EXEC_WAIT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 200)
+
+/**
* Lowest port used for GNUnet testing. Should be high enough to not
* conflict with other applications running on the hosts but be low
* enough to not conflict with client-ports (typically starting around
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2012-10-26 18:30:39 UTC (rev
24572)
+++ gnunet/src/transport/transport_api.c 2012-10-26 22:13:01 UTC (rev
24573)
@@ -951,16 +951,7 @@
h->reconnect_delay.rel_value);
h->reconnect_task =
GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
- if (h->reconnect_delay.rel_value == 0)
- {
- h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
- }
- else
- {
- h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2);
- h->reconnect_delay =
- GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
h->reconnect_delay);
- }
+ h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
}
Modified: gnunet/src/transport/transport_api_address_lookup.c
===================================================================
--- gnunet/src/transport/transport_api_address_lookup.c 2012-10-26 18:30:39 UTC
(rev 24572)
+++ gnunet/src/transport/transport_api_address_lookup.c 2012-10-26 22:13:01 UTC
(rev 24573)
@@ -157,9 +157,7 @@
GNUNET_assert (GNUNET_NO == pal_ctx->one_shot);
GNUNET_CLIENT_disconnect (pal_ctx->client);
pal_ctx->client = NULL;
- pal_ctx->backoff = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS,
- GNUNET_TIME_relative_min
(GNUNET_TIME_relative_multiply (pal_ctx->backoff, 2),
-
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)));
+ pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff);
pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff,
&do_connect,
pal_ctx);
Modified: gnunet/src/util/crypto_ecc.c
===================================================================
--- gnunet/src/util/crypto_ecc.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/util/crypto_ecc.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -25,7 +25,9 @@
*
* This is just a first, completely untested, draft hack for future ECC
support.
* TODO:
- * - adjust encoding length and other parameters
+ * - fix public key generation; somehow the result is currently considered
invalid by libgcrypt
+ * => suspect that libgcrypt does NOT take pabgn from "CURVE" for public key
if not
+ * explicitly given!
* - actually test it!
*/
#include "platform.h"
@@ -65,26 +67,6 @@
/**
- * If target != size, move target bytes to the
- * end of the size-sized buffer and zero out the
- * first target-size bytes.
- *
- * @param buf original buffer
- * @param size number of bytes in the buffer
- * @param target target size of the buffer
- */
-static void
-adjust (unsigned char *buf, size_t size, size_t target)
-{
- if (size < target)
- {
- memmove (&buf[target - size], buf, size);
- memset (buf, 0, target - size);
- }
-}
-
-
-/**
* Free memory occupied by ECC key
*
* @param privatekey pointer to the memory to free
@@ -171,6 +153,7 @@
size_t size;
int rc;
+ memset (pub, 0, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded));
rc = key_from_sexp (&skey, priv->sexp, "public-key", "q");
if (rc)
rc = key_from_sexp (&skey, priv->sexp, "private-key", "q");
@@ -183,7 +166,6 @@
gcry_mpi_print (GCRYMPI_FMT_USG, pub->key, size, &size,
skey));
pub->len = htons (size);
- adjust (&pub->key[0], size, GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH);
gcry_mpi_release (skey);
}
@@ -245,7 +227,7 @@
sizeof (struct
GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)))
return GNUNET_SYSERR;
if ( (ntohs (pub->size) != sizeof (struct
GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)) ||
- (ntohs (pub->len) > GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH) )
+ (ntohs (pub->len) > GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH) )
return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -267,24 +249,38 @@
size_t erroff;
int rc;
- if (ntohs (publicKey->len) > GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH)
+ if (ntohs (publicKey->len) >
GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH)
{
GNUNET_break (0);
return NULL;
}
- size = ntohs (publicKey->size);
+ size = ntohs (publicKey->len);
if (0 != (rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, publicKey->key, size,
&size)))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
return NULL;
}
- rc = gcry_sexp_build (&result, &erroff, "(public-key(ecc((curve \"" CURVE
"\")(q %m)))", q);
+
+ rc = gcry_sexp_build (&result, &erroff,
+ "(public-key(ecdsa(curve \"" CURVE "\")(q %m)))",
+ q);
gcry_mpi_release (q);
if (0 != rc)
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); /* erroff
gives more info */
return NULL;
}
+ // FIXME: is this key expected to pass pk_testkey?
+#if 0
+#if EXTRA_CHECKS
+ if (0 != (rc = gcry_pk_testkey (result)))
+ {
+ LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
+ gcry_sexp_release (result);
+ return NULL;
+ }
+#endif
+#endif
return result;
}
@@ -386,7 +382,7 @@
int rc;
if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL,
- "(genkey(ecdsa(curve 10:NIST P-521)))")))
+ "(genkey(ecdsa(curve \"" CURVE "\")))")))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
return NULL;
@@ -428,7 +424,7 @@
if (GNUNET_YES != GNUNET_DISK_file_test (filename))
return NULL;
- /* hostkey file exists already, read it! */
+ /* key file exists already, read it! */
if (NULL == (fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
GNUNET_DISK_PERM_NONE)))
{
@@ -582,12 +578,9 @@
GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
GNUNET_CRYPTO_ecc_key_get_public (ret, &pub);
GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("I am host `%s'. Stored new private key in `%s'.\n"),
- GNUNET_i2s (&pid), filename);
return ret;
}
- /* hostkey file exists already, read it! */
+ /* key file exists already, read it! */
fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
GNUNET_DISK_PERM_NONE);
if (NULL == fd)
@@ -611,7 +604,7 @@
STRERROR (ec));
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("This may be ok if someone is currently generating a
hostkey.\n"));
+ ("This may be ok if someone is currently generating a private
key.\n"));
}
short_wait ();
continue;
@@ -632,7 +625,7 @@
fs = 0;
if (fs < sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))
{
- /* maybe we got the read lock before the hostkey generating
+ /* maybe we got the read lock before the key generating
* process had a chance to get the write lock; give it up! */
if (GNUNET_YES !=
GNUNET_DISK_file_unlock (fd, 0,
@@ -642,12 +635,12 @@
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("When trying to read hostkey file `%s' I found %u bytes but I
need at least %u.\n"),
+ ("When trying to read key file `%s' I found %u bytes but I need
at least %u.\n"),
filename, (unsigned int) fs,
(unsigned int) sizeof (struct
GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded));
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("This may be ok if someone is currently generating a
hostkey.\n"));
+ ("This may be ok if someone is currently generating a key.\n"));
}
short_wait (); /* wait a bit longer! */
continue;
@@ -679,9 +672,6 @@
{
GNUNET_CRYPTO_ecc_key_get_public (ret, &pub);
GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("I am host `%s'. Read private key from `%s'.\n"), GNUNET_i2s
(&pid),
- filename);
}
return ret;
}
@@ -909,15 +899,15 @@
/**
- * Setup a hostkey file for a peer given the name of the
+ * Setup a key file for a peer given the name of the
* configuration file (!). This function is used so that
* at a later point code can be certain that reading a
- * hostkey is fast (for example in time-dependent testcases).
+ * key is fast (for example in time-dependent testcases).
*
* @param cfg_name name of the configuration file to use
*/
void
-GNUNET_CRYPTO_ecc_setup_hostkey (const char *cfg_name)
+GNUNET_CRYPTO_ecc_setup_key (const char *cfg_name)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_CRYPTO_EccPrivateKey *pk;
@@ -947,12 +937,12 @@
static gcry_sexp_t
data_to_pkcs1 (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose)
{
- struct GNUNET_HashCode hc;
+ struct GNUNET_CRYPTO_ShortHashCode hc;
size_t bufSize;
gcry_sexp_t data;
- GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc);
-#define FORMATSTRING
"(4:data(5:flags5:pkcs1)(4:hash6:sha51264:0123456789012345678901234567890123456789012345678901234567890123))"
+ GNUNET_CRYPTO_short_hash (purpose, ntohl (purpose->size), &hc);
+#define FORMATSTRING
"(4:data(5:flags5:pkcs1)(4:hash6:sha25632:01234567890123456789012345678901))"
bufSize = strlen (FORMATSTRING) + 1;
{
char buff[bufSize];
@@ -961,8 +951,8 @@
memcpy (&buff
[bufSize -
strlen
-
("0123456789012345678901234567890123456789012345678901234567890123))")
- - 1], &hc, sizeof (struct GNUNET_HashCode));
+ ("01234567890123456789012345678901))")
+ - 1], &hc, sizeof (struct GNUNET_CRYPTO_ShortHashCode));
GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0));
}
#undef FORMATSTRING
@@ -986,14 +976,20 @@
gcry_sexp_t result;
gcry_sexp_t data;
size_t ssize;
+ int rc;
data = data_to_pkcs1 (purpose);
- GNUNET_assert (0 == gcry_pk_sign (&result, data, key->sexp));
+ if (0 != (rc = gcry_pk_sign (&result, data, key->sexp)))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("ECC signing failed at %s:%d: %s\n"), __FILE__,
+ __LINE__, gcry_strerror (rc));
+ }
gcry_sexp_release (data);
ssize = gcry_sexp_sprint (result,
GCRYSEXP_FMT_DEFAULT,
sig->sexpr,
- GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH);
+ GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH);
if (0 == ssize)
{
GNUNET_break (0);
@@ -1001,7 +997,7 @@
}
sig->size = htons ((uint16_t) (ssize + sizeof (uint16_t)));
/* padd with zeros */
- memset (&sig->sexpr[ssize], 0, GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH -
ssize);
+ memset (&sig->sexpr[ssize], 0,
GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH - ssize);
gcry_sexp_release (result);
return GNUNET_OK;
}
@@ -1035,7 +1031,7 @@
return GNUNET_SYSERR; /* purpose mismatch */
size = ntohs (sig->size);
if ( (size < sizeof (uint16_t)) ||
- (size > GNUNET_CRYPTO_ECC_DATA_ENCODING_LENGTH - sizeof (uint16_t)) )
+ (size > GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH - sizeof
(uint16_t)) )
return GNUNET_SYSERR; /* size out of range */
data = data_to_pkcs1 (validate);
GNUNET_assert (0 ==
Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/util/crypto_rsa.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -315,7 +315,7 @@
* Encode the private key in a format suitable for
* storing it into a file.
*
- * @returns encoding of the private key.
+ * @return encoding of the private key.
* The first 4 bytes give the size of the array, as usual.
*/
struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *
@@ -778,9 +778,6 @@
GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
GNUNET_CRYPTO_rsa_key_get_public (ret, &pub);
GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("I am host `%s'. Stored new private key in `%s'.\n"),
- GNUNET_i2s (&pid), filename);
return ret;
}
/* hostkey file exists already, read it! */
@@ -807,7 +804,7 @@
STRERROR (ec));
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("This may be ok if someone is currently generating a
hostkey.\n"));
+ ("This may be ok if someone is currently generating a private
key.\n"));
}
short_wait ();
continue;
@@ -828,7 +825,7 @@
fs = 0;
if (fs < sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded))
{
- /* maybe we got the read lock before the hostkey generating
+ /* maybe we got the read lock before the key generating
* process had a chance to get the write lock; give it up! */
if (GNUNET_YES !=
GNUNET_DISK_file_unlock (fd, 0,
@@ -838,12 +835,12 @@
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("When trying to read hostkey file `%s' I found %u bytes but I
need at least %u.\n"),
+ ("When trying to read key file `%s' I found %u bytes but I need
at least %u.\n"),
filename, (unsigned int) fs,
(unsigned int) sizeof (struct
GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded));
LOG (GNUNET_ERROR_TYPE_ERROR,
_
- ("This may be ok if someone is currently generating a
hostkey.\n"));
+ ("This may be ok if someone is currently generating a private
key.\n"));
}
short_wait (); /* wait a bit longer! */
continue;
@@ -875,9 +872,6 @@
{
GNUNET_CRYPTO_rsa_key_get_public (ret, &pub);
GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("I am host `%s'. Read private key from `%s'.\n"), GNUNET_i2s
(&pid),
- filename);
}
return ret;
}
@@ -1105,10 +1099,10 @@
/**
- * Setup a hostkey file for a peer given the name of the
+ * Setup a key file for a peer given the name of the
* configuration file (!). This function is used so that
* at a later point code can be certain that reading a
- * hostkey is fast (for example in time-dependent testcases).
+ * key is fast (for example in time-dependent testcases).
*
* @param cfg_name name of the configuration file to use
*/
@@ -1184,7 +1178,7 @@
/**
- * Decrypt a given block with the hostkey.
+ * Decrypt a given block with the key.
*
* @param key the key with which to decrypt this block
* @param block the data to decrypt, encoded as returned by encrypt
Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/util/network.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -67,6 +67,34 @@
/**
+ * Test if the given protocol family is supported by this system.
+ *
+ * @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX)
+ * @return GNUNET_OK if the PF is supported
+ */
+int
+GNUNET_NETWORK_test_pf (int pf)
+{
+ int s;
+
+ s = socket (pf, SOCK_STREAM, 0);
+ if (-1 == s)
+ {
+ if (EAFNOSUPPORT == errno)
+ return GNUNET_NO;
+ fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
+ return GNUNET_SYSERR;
+ }
+#if WINDOWS
+ closesocket (s);
+#else
+ close (s);
+#endif
+ return GNUNET_OK;
+}
+
+
+/**
* Given a unixpath that is too long (larger than UNIX_PATH_MAX),
* shorten it to an acceptable length while keeping it unique
* and making sure it remains a valid filename (if possible).
Modified: gnunet/src/util/resolver_api.c
===================================================================
--- gnunet/src/util/resolver_api.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/util/resolver_api.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -707,7 +707,7 @@
(unsigned long long) backoff.rel_value);
GNUNET_assert (NULL != resolver_cfg);
r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
- backoff = GNUNET_TIME_relative_multiply (backoff, 2);
+ backoff = GNUNET_TIME_STD_BACKOFF (backoff);
}
Modified: gnunet/src/util/test_crypto_ecc.c
===================================================================
--- gnunet/src/util/test_crypto_ecc.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/util/test_crypto_ecc.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -203,4 +203,6 @@
return -1;
}
return 0;
-} /* end of main */
+}
+
+/* end of test_crypto_ecc.c */
Modified: gnunet/src/vpn/gnunet-service-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-service-vpn.c 2012-10-26 18:30:39 UTC (rev 24572)
+++ gnunet/src/vpn/gnunet-service-vpn.c 2012-10-26 22:13:01 UTC (rev 24573)
@@ -3003,31 +3003,6 @@
/**
- * Test if the given AF is supported by this system.
- *
- * @param af to test
- * @return GNUNET_OK if the AF is supported
- */
-static int
-test_af (int af)
-{
- int s;
-
- s = socket (af, SOCK_STREAM, 0);
- if (-1 == s)
- {
- if (EAFNOSUPPORT == errno)
- return GNUNET_NO;
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "socket");
- return GNUNET_SYSERR;
- }
- (void) close (s);
- return GNUNET_OK;
-}
-
-
-/**
* Main function that will be run by the scheduler.
*
* @param cls closure
@@ -3100,7 +3075,7 @@
return;
}
vpn_argv[1] = ifname;
- if (GNUNET_OK == test_af (AF_INET6))
+ if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET6))
{
if ( (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR",
@@ -3140,7 +3115,7 @@
vpn_argv[2] = GNUNET_strdup ("-");
vpn_argv[3] = GNUNET_strdup ("-");
}
- if (GNUNET_OK == test_af (AF_INET))
+ if (GNUNET_OK == GNUNET_NETWORK_test_pf (PF_INET))
{
if ( (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24573 - in gnunet/src: arm core datastore dht exit fs gns hostlist include namestore nat nse pt statistics stream testing_old transport util vpn,
gnunet <=