duration = (duration_total.rel_value_us / (1000 * 1000));
+ if (0 == duration)
+ duration = 1;
for (c_m = 0; c_m < e->num_masters; c_m++)
{
mp = &masters_p[c_m];
fprintf (stderr,
- _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
- mp->no, mp->total_bytes_sent / 1024, duration,
- (mp->total_bytes_sent / 1024) / duration,
- mp->total_bytes_received / 1024, duration,
- (mp->total_bytes_received / 1024) / duration);
+ _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
+ mp->no, mp->total_bytes_sent / 1024,
+ duration,
+ (mp->total_bytes_sent / 1024) / duration,
+ mp->total_bytes_received / 1024,
+ duration,
+ (mp->total_bytes_received / 1024) / duration);
for (c_s = 0; c_s < e->num_slaves; c_s++)
{
o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
else
{
- fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
+ fprintf (stderr,
+ "Invalid preference in operation %u `%s' in episode %u\n",
+ op_counter,
+ op,
+ cur->id);
GNUNET_free (type);
GNUNET_free (op_name);
GNUNET_free (op);
- GNUNET_free (pref);
GNUNET_free (sec_name);
GNUNET_free_non_null (pref);
GNUNET_free (o);
GNUNET_GETOPT_OPTION_END
};
- GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]);
+ if (GNUNET_OK !=
+ GNUNET_PROGRAM_run (argc,
+ argv, argv[0],
+ NULL,
+ options,
+ &run, argv[0]))
+ return 1;
return 0;
}
-/* end of file ats-testing-experiment.c*/
+/* end of file gnunet-solver-eval.c*/
raw,
gi->bf_size))
{
+ GNUNET_free (raw);
GNUNET_break (0);
return GNUNET_SYSERR;
}
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ GNUNET_assert (NULL != receiver);
ld->ccn = receiver->ccn;
GNUNET_memcpy (&ld[1],
buf,
GSC_send_to_client (ccc->c,
com->env);
/* Notify sender that we can receive more */
- if (ccc->ccn.channel_of_client ==
- ch->owner->ccn.channel_of_client)
+ if ( (NULL != ch->owner) &&
+ (ccc->ccn.channel_of_client ==
+ ch->owner->ccn.channel_of_client) )
{
to_owner = GNUNET_NO;
}
else
{
- GNUNET_assert (ccc->ccn.channel_of_client ==
- ch->dest->ccn.channel_of_client);
+ GNUNET_assert ( (NULL != ch->dest) &&
+ (ccc->ccn.channel_of_client ==
+ ch->dest->ccn.channel_of_client) );
to_owner = GNUNET_YES;
}
send_ack_to_client (ch,
unused paths around in the hope that we might be able to switch, even
if the number of paths exceeds the threshold.) */
root = GNUNET_CONTAINER_heap_peek (cp->path_heap);
+ GNUNET_assert (NULL != root);
if (NULL !=
GCPP_get_connection (root,
cp,
* in the result set.
*
* @param cls closure
- * @param element a result element, only valid if status is GNUNET_SET_STATUS_OK
+ * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK
* @param current_size current set size
* @param status see enum GNUNET_SET_Status
*/
"P%u: lower bound %llu\n",
session->local_peer_idx,
(long long) session->lower_bound);
+ GNUNET_free (copy);
}
return;
}
{
case CS_CALLEE_INIT:
GNUNET_break_op (0);
- destroy_line_cadet_channels (ch);
return;
case CS_CALLEE_RINGING:
case CS_CALLEE_CONNECTED:
libgnunet_plugin_datastore_sqlite_la_SOURCES = \
plugin_datastore_sqlite.c
libgnunet_plugin_datastore_sqlite_la_LIBADD = \
+ $(top_builddir)/src/sq/libgnunetsq.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \
$(LTLIBINTL)
#define LOG(kind,...) GNUNET_log_from (kind, "datastore-api",__VA_ARGS__)
+#define DELAY_WARN_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+
/**
* Collect an instane number of statistics? May cause excessive IPC.
*/
*/
struct GNUNET_MQ_Envelope *env;
+ /**
+ * Task we run if this entry stalls the queue and we
+ * need to warn the user.
+ */
+ struct GNUNET_SCHEDULER_Task *delay_warn_task;
+
/**
* Priority in the queue.
*/
h->queue_size--;
if (NULL != qe->env)
GNUNET_MQ_discard (qe->env);
+ if (NULL != qe->delay_warn_task)
+ GNUNET_SCHEDULER_cancel (qe->delay_warn_task);
GNUNET_free (qe);
}
+/**
+ * Task that logs an error after some time.
+ *
+ * @param qe `struct GNUNET_DATASTORE_QueueEntry` about which the error is
+ */
+static void
+delay_warning (void *cls)
+{
+ struct GNUNET_DATASTORE_QueueEntry *qe = cls;
+
+ qe->delay_warn_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Request %p of type %u at head of datastore queue for more than %s\n",
+ qe,
+ (unsigned int) qe->response_type,
+ GNUNET_STRINGS_relative_time_to_string (DELAY_WARN_TIMEOUT,
+ GNUNET_YES));
+ qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT,
+ &delay_warning,
+ qe);
+}
+
+
/**
* Handle error in sending drop request to datastore.
*
"MQ error, reconnecting to DATASTORE\n");
do_disconnect (h);
qe = h->queue_head;
- if ( (NULL != qe) &&
- (NULL == qe->env) )
+ if (NULL == qe)
+ return;
+ if (NULL != qe->delay_warn_task)
+ {
+ GNUNET_SCHEDULER_cancel (qe->delay_warn_task);
+ qe->delay_warn_task = NULL;
+ }
+ if (NULL == qe->env)
{
union QueueContext qc = qe->qc;
uint16_t rt = qe->response_type;
"Not connected\n");
return;
}
+ GNUNET_assert (NULL == qe->delay_warn_task);
+ qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT,
+ &delay_warning,
+ qe);
GNUNET_MQ_send (h->mq,
qe->env);
qe->env = NULL;
{
struct GNUNET_TIME_Absolute now;
- if (key == NULL)
+ if (NULL == key)
{
expired_kill_task =
GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
/*
* This file is part of GNUnet
- * Copyright (C) 2009, 2011 GNUnet e.V.
+ * Copyright (C) 2009, 2011, 2017 GNUnet e.V.
*
* GNUnet is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
#include "platform.h"
#include "gnunet_datastore_plugin.h"
+#include "gnunet_sq_lib.h"
#include <sqlite3.h>
*/
static int
delete_by_rowid (struct Plugin *plugin,
- unsigned long long rid)
+ uint64_t rid)
{
- if (SQLITE_OK != sqlite3_bind_int64 (plugin->delRow, 1, rid))
- {
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (plugin->delRow))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
+ struct GNUNET_SQ_QueryParam params[] = {
+ GNUNET_SQ_query_param_uint64 (&rid),
+ GNUNET_SQ_query_param_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (plugin->delRow,
+ params))
return GNUNET_SYSERR;
- }
if (SQLITE_DONE != sqlite3_step (plugin->delRow))
{
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
PluginPutCont cont,
void *cont_cls)
{
+ uint64_t rvalue;
+ struct GNUNET_HashCode vhash;
+ struct GNUNET_SQ_QueryParam params[] = {
+ GNUNET_SQ_query_param_uint32 (&replication),
+ GNUNET_SQ_query_param_uint32 (&type),
+ GNUNET_SQ_query_param_uint32 (&priority),
+ GNUNET_SQ_query_param_uint32 (&anonymity),
+ GNUNET_SQ_query_param_absolute_time (&expiration),
+ GNUNET_SQ_query_param_uint64 (&rvalue),
+ GNUNET_SQ_query_param_auto_from_type (key),
+ GNUNET_SQ_query_param_auto_from_type (&vhash),
+ GNUNET_SQ_query_param_fixed_size (data, size),
+ GNUNET_SQ_query_param_end
+ };
struct Plugin *plugin = cls;
int n;
int ret;
sqlite3_stmt *stmt;
- struct GNUNET_HashCode vhash;
- uint64_t rvalue;
char *msg = NULL;
if (size > MAX_ITEM_SIZE)
GNUNET_CRYPTO_hash (data, size, &vhash);
stmt = plugin->insertContent;
rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
- if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, replication)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value_us)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) ||
- (SQLITE_OK !=
- sqlite3_bind_blob (stmt, 7, key, sizeof (struct GNUNET_HashCode),
- SQLITE_TRANSIENT)) ||
- (SQLITE_OK !=
- sqlite3_bind_blob (stmt, 8, &vhash, sizeof (struct GNUNET_HashCode),
- SQLITE_TRANSIENT)) ||
- (SQLITE_OK != sqlite3_bind_blob (stmt, 9, data, size, SQLITE_TRANSIENT)))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (stmt,
+ params))
{
- LOG_SQLITE_MSG (plugin, &msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (stmt))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
cont (cont_cls, key, size, GNUNET_SYSERR, msg);
GNUNET_free_non_null(msg);
return;
* MAX of any existing expiration time and
* this value
* @param cont continuation called with success or failure status
- * @param cons_cls continuation closure
+ * @param cons_cls closure for @a cont
*/
static void
sqlite_plugin_update (void *cls,
void *cont_cls)
{
struct Plugin *plugin = cls;
+ struct GNUNET_SQ_QueryParam params[] = {
+ GNUNET_SQ_query_param_uint32 (&delta),
+ GNUNET_SQ_query_param_absolute_time (&expire),
+ GNUNET_SQ_query_param_uint64 (&uid),
+ GNUNET_SQ_query_param_end
+ };
int n;
char *msg = NULL;
- if ((SQLITE_OK != sqlite3_bind_int (plugin->updPrio, 1, delta)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value_us))
- || (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid)))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (plugin->updPrio,
+ params))
{
- LOG_SQLITE_MSG (plugin, &msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (plugin->updPrio))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
cont (cont_cls, GNUNET_SYSERR, msg);
GNUNET_free_non_null(msg);
return;
static void
sqlite_plugin_get_zero_anonymity (void *cls, uint64_t offset,
enum GNUNET_BLOCK_Type type,
- PluginDatumProcessor proc, void *proc_cls)
+ PluginDatumProcessor proc,
+ void *proc_cls)
{
struct Plugin *plugin = cls;
- sqlite3_stmt *stmt;
+ struct GNUNET_SQ_QueryParam params[] = {
+ GNUNET_SQ_query_param_uint32 (&type),
+ GNUNET_SQ_query_param_uint64 (&offset),
+ GNUNET_SQ_query_param_end
+ };
+ sqlite3_stmt *stmt = plugin->selZeroAnon;
GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
- stmt = plugin->selZeroAnon;
- if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, offset)))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (stmt,
+ params))
{
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (stmt))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
struct ReplCtx rc;
uint64_t rvalue;
uint32_t repl;
- sqlite3_stmt *stmt;
-
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
+ struct GNUNET_SQ_QueryParam params_sel_repl[] = {
+ GNUNET_SQ_query_param_uint64 (&rvalue),
+ GNUNET_SQ_query_param_uint32 (&repl),
+ GNUNET_SQ_query_param_end
+ };
+ struct GNUNET_SQ_QueryParam params_upd_repl[] = {
+ GNUNET_SQ_query_param_uint64 (&rc.uid),
+ GNUNET_SQ_query_param_end
+ };
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "datastore-sqlite",
"Getting random block based on replication order.\n");
rc.have_uid = GNUNET_NO;
rc.proc = proc;
rc.proc_cls = proc_cls;
- stmt = plugin->maxRepl;
- if (SQLITE_ROW != sqlite3_step (stmt))
+ if (SQLITE_ROW != sqlite3_step (plugin->maxRepl))
{
- if (SQLITE_OK != sqlite3_reset (stmt))
+ if (SQLITE_OK != sqlite3_reset (plugin->maxRepl))
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
- repl = sqlite3_column_int (stmt, 0);
- if (SQLITE_OK != sqlite3_reset (stmt))
+ repl = sqlite3_column_int (plugin->maxRepl, 0);
+ if (SQLITE_OK != sqlite3_reset (plugin->maxRepl))
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
- stmt = plugin->selRepl;
rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
- if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, rvalue))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (plugin->selRepl,
+ params_sel_repl))
{
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (stmt))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
- if (SQLITE_OK != sqlite3_bind_int (stmt, 2, repl))
- {
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (stmt))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
- proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
- return;
- }
- execute_get (plugin, stmt, &repl_proc, &rc);
+ execute_get (plugin, plugin->selRepl, &repl_proc, &rc);
if (GNUNET_YES == rc.have_uid)
{
- if (SQLITE_OK != sqlite3_bind_int64 (plugin->updRepl, 1, rc.uid))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (plugin->updRepl,
+ params_upd_repl))
{
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (plugin->updRepl))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
+ proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
if (SQLITE_DONE != sqlite3_step (plugin->updRepl))
struct Plugin *plugin = cls;
sqlite3_stmt *stmt;
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_SQ_QueryParam params[] = {
+ GNUNET_SQ_query_param_absolute_time (&now),
+ GNUNET_SQ_query_param_end
+ };
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Getting random block based on expiration and priority order.\n");
now = GNUNET_TIME_absolute_get ();
stmt = plugin->selExpi;
- if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value_us))
+ if (GNUNET_OK !=
+ GNUNET_SQ_bind (stmt,
+ params))
{
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (stmt))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
void *proc_cls)
{
struct Plugin *plugin = cls;
- const struct GNUNET_HashCode *key;
+ struct GNUNET_HashCode key;
+ struct GNUNET_SQ_ResultSpec results[] = {
+ GNUNET_SQ_result_spec_auto_from_type (&key),
+ GNUNET_SQ_result_spec_end
+ };
sqlite3_stmt *stmt;
int ret;
- GNUNET_assert (proc != NULL);
+ GNUNET_assert (NULL != proc);
if (sq_prepare (plugin->dbh, "SELECT hash FROM gn090", &stmt) != SQLITE_OK)
{
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
}
while (SQLITE_ROW == (ret = sqlite3_step (stmt)))
{
- key = sqlite3_column_blob (stmt, 0);
- if (sizeof (struct GNUNET_HashCode) == sqlite3_column_bytes (stmt, 0))
- proc (proc_cls, key, 1);
+ if (GNUNET_OK ==
+ GNUNET_SQ_extract_result (stmt,
+ results))
+ proc (proc_cls, &key, 1);
else
GNUNET_break (0);
}
page_size = sqlite3_column_int64 (stmt, 0);
sqlite3_finalize (stmt);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _
- ("Using sqlite page utilization to estimate payload (%llu pages of size %llu bytes)\n"),
+ _("Using sqlite page utilization to estimate payload (%llu pages of size %llu bytes)\n"),
(unsigned long long) pages, (unsigned long long) page_size);
*estimate = pages * page_size;
}
database_shutdown (plugin);
plugin->env = NULL;
GNUNET_free (api);
- if (fn != NULL)
+ if (NULL != fn)
{
if (0 != UNLINK (fn))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "unlink",
+ fn);
GNUNET_free (fn);
}
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
"sqlite plugin is finished\n");
return NULL;
}
/*
This file is part of GNUnet.
- Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V.
+ Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- struct GNUNET_TIME_Absolute expiration;
enum GNUNET_DHT_RouteOption ro;
cfg = c;
query_type,
strlen (data),
data,
- expiration,
+ GNUNET_TIME_relative_to_absolute (expiration),
&message_sent_cont,
NULL);
}
libgnunet_plugin_block_dns_la_SOURCES = \
plugin_block_dns.c
libgnunet_plugin_block_dns_la_LIBADD = \
+ $(top_builddir)/src/block/libgnunetblockgroup.la \
$(top_builddir)/src/util/libgnunetutil.la
libgnunet_plugin_block_dns_la_LDFLAGS = \
$(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS)
unsigned int left;
unsigned int todo;
unsigned int fit;
- int first_call;
unsigned int search_request_map_offset;
unsigned int keyword_offset;
+ int first_call;
memset (&mbc, 0, sizeof (mbc));
mbc.sc = sc;
if (GNUNET_FS_uri_test_ksk (sc->uri))
{
- mbc.put_cnt = 0;
+ /* This will calculate the result set size ONLY for
+ "keyword_offset == 0", so we will have to recalculate
+ it for the other keywords later! */
GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
&find_result_set,
&mbc);
}
search_request_map_offset = 0;
keyword_offset = 0;
-
first_call = GNUNET_YES;
while ( (0 != (left =
(total_seen_results - search_request_map_offset))) ||
GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
mbc.skip_cnt = search_request_map_offset;
mbc.xoff = (struct GNUNET_HashCode *) &sm[1];
+ sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
+ sm->anonymity_level = htonl (sc->anonymity);
+ memset (&sm->target,
+ 0,
+ sizeof (struct GNUNET_PeerIdentity));
if (GNUNET_FS_uri_test_ksk (sc->uri))
{
/* calculate how many results we can send in this message */
mbc.put_cnt = todo;
/* now build message */
- sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
- sm->anonymity_level = htonl (sc->anonymity);
- memset (&sm->target,
- 0,
- sizeof (struct GNUNET_PeerIdentity));
sm->query = sc->requests[keyword_offset].uquery;
GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
&build_result_set,
&mbc);
search_request_map_offset += todo;
- GNUNET_assert (0 == mbc.put_cnt); /* #4608 reports this fails? */
+ GNUNET_assert (0 == mbc.put_cnt);
GNUNET_assert (total_seen_results >= search_request_map_offset);
if (total_seen_results != search_request_map_offset)
{
{
sm->options = htonl (options);
keyword_offset++;
- search_request_map_offset = 0;
if (sc->uri->data.ksk.keywordCount != keyword_offset)
{
/* more keywords => more requesting to be done... */
first_call = GNUNET_YES;
+ search_request_map_offset = 0;
+ mbc.put_cnt = 0;
+ mbc.keyword_offset = keyword_offset;
+ GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
+ &find_result_set,
+ &mbc);
+ total_seen_results = mbc.put_cnt;
}
}
}
{
GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
- sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
- sm->anonymity_level = htonl (sc->anonymity);
- memset (&sm->target,
- 0,
- sizeof (struct GNUNET_PeerIdentity));
GNUNET_CRYPTO_ecdsa_public_key_derive (&sc->uri->data.sks.ns,
sc->uri->data.sks.identifier,
"fs-ublock",
if (NULL != sr->download)
{
sr->download->search = NULL;
- sr->download->top =
- GNUNET_FS_make_top (sr->download->h,
+ sr->download->top
+ = GNUNET_FS_make_top (sr->download->h,
&GNUNET_FS_download_signal_suspend_,
sr->download);
if (NULL != sr->download->serialization)
sr->download->serialization = NULL;
}
pi.status = GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT;
- GNUNET_FS_download_make_status_ (&pi, sr->download);
+ GNUNET_FS_download_make_status_ (&pi,
+ sr->download);
GNUNET_FS_download_sync_ (sr->download);
sr->download = NULL;
}
if (NULL != sc->top)
GNUNET_FS_end_top (sc->h, sc->top);
GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
- &search_result_stop, sc);
+ &search_result_stop,
+ sc);
if (NULL != sc->psearch_result)
sc->psearch_result->update_search = NULL;
if (NULL != sc->serialization)
{
GNUNET_FS_remove_sync_file_ (sc->h,
- (sc->psearch_result !=
- NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH :
- GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
+ (NULL != sc->psearch_result)
+ ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH
+ : GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
sc->serialization);
GNUNET_FS_remove_sync_dir_ (sc->h,
- (sc->psearch_result !=
- NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH :
- GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
+ (NULL != sc->psearch_result)
+ ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH
+ : GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
sc->serialization);
GNUNET_free (sc->serialization);
}
pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED;
- sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
+ sc->client_info = GNUNET_FS_search_make_status_ (&pi,
+ sc->h,
+ sc);
GNUNET_break (NULL == sc->client_info);
if (NULL != sc->task)
{
GNUNET_assert (-1 != z);
if (z == fd)
return;
- dup2 (z, fd);
+ GNUNET_break (fd == dup2 (z, fd));
GNUNET_assert (0 == close (z));
}
#include "gnunet_util_lib.h"
#include "gnunet-service-fs_cp.h"
#include "gnunet-service-fs_indexing.h"
-#include "gnunet-service-fs_lc.h"
#include "gnunet-service-fs_pe.h"
#include "gnunet-service-fs_pr.h"
#include "gnunet-service-fs_push.h"
+++ /dev/null
-/*
- This file is part of GNUnet.
- Copyright (C) 2011 GNUnet e.V.
-
- 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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-/**
- * @file fs/gnunet-service-fs_lc.c
- * @brief API to handle 'local clients'
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet-service-fs.h"
-#include "gnunet-service-fs_lc.h"
-#include "gnunet-service-fs_cp.h"
-#include "gnunet-service-fs_pr.h"
-
-
-
-/* end of gnunet-service-fs_lc.c */
+++ /dev/null
-/*
- This file is part of GNUnet.
- Copyright (C) 2011 GNUnet e.V.
-
- 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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-/**
- * @file fs/gnunet-service-fs_lc.h
- * @brief API to handle 'local clients'
- * @author Christian Grothoff
- */
-#ifndef GNUNET_SERVICE_FS_LC_H
-#define GNUNET_SERVICE_FS_LC_H
-
-#include "gnunet-service-fs.h"
-
-
-#endif
-/* end of gnunet-service-fs_lc.h */
}
*data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
*data = vpn = GNUNET_malloc (*data_size);
- if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string ((char*) s_peer,
- strlen (s_peer),
- &vpn->peer.public_key))
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_public_key_from_string ((char*) s_peer,
+ strlen (s_peer),
+ &vpn->peer.public_key))
{
GNUNET_free (vpn);
*data_size = 0;
}
*data_size = sizeof (struct GNUNET_GNSRECORD_ReverseRecord) + strlen (known_by) + 1;
*data = rev = GNUNET_malloc (*data_size);
- GNUNET_CRYPTO_ecdsa_public_key_from_string (pkey_str,
- strlen (pkey_str),
- &rev->pkey);
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_ecdsa_public_key_from_string (pkey_str,
+ strlen (pkey_str),
+ &rev->pkey))
+ {
+ GNUNET_free (rev);
+ return GNUNET_SYSERR;
+ }
rev->expiration = expiration;
GNUNET_memcpy (&rev[1],
known_by,
GNUNET_SQ_query_param_uint64 (const uint64_t *x);
+/**
+ * Execute binding operations for a prepared statement.
+ *
+ * @param db_conn database connection
+ * @param params parameters to the statement
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+int
+GNUNET_SQ_bind (sqlite3_stmt *stmt,
+ const struct GNUNET_SQ_QueryParam *params);
+
+
/**
* Extract data from a Postgres database @a result at row @a row.
*
GNUNET_SQ_result_spec_uint64 (uint64_t *u64);
-/**
- * Execute a prepared statement.
- *
- * @param db_conn database connection
- * @param params parameters to the statement
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_SQ_bind (sqlite3_stmt *stmt,
- const struct GNUNET_SQ_QueryParam *params);
-
-
/**
* Extract results from a query result according to the given specification.
*
GNUNET_NAT_AUTO_status2string (result),
nat_type);
+ if (NULL == diff)
+ return;
+
/* Shortcut: if there are no changes suggested, bail out early. */
if (GNUNET_NO ==
GNUNET_CONFIGURATION_is_dirty (diff))
to the user */
new_cfg = write_cfg ? GNUNET_CONFIGURATION_dup (cfg) : NULL;
- if (NULL != diff)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- _("Suggested configuration changes:\n"));
- GNUNET_CONFIGURATION_iterate_section_values (diff,
- "nat",
- &auto_conf_iter,
- new_cfg);
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ _("Suggested configuration changes:\n"));
+ GNUNET_CONFIGURATION_iterate_section_values (diff,
+ "nat",
+ &auto_conf_iter,
+ new_cfg);
/* If desired, write configuration to file; we write only the
changes to the defaults to keep things compact. */
- if ( (write_cfg) &&
- (NULL != diff) )
+ if (write_cfg)
{
struct GNUNET_CONFIGURATION_Handle *def_cfg;
if (do_auto)
{
ah = GNUNET_NAT_AUTO_autoconfig_start (c,
- &auto_config_cb,
- NULL);
+ &auto_config_cb,
+ NULL);
}
if (use_tcp && use_udp)
global_ret = 1;
return;
}
+ local_len = 0;
+ local_sa = NULL;
+ remote_len = 0;
+ remote_sa = NULL;
if (NULL != local_addr)
{
local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Invalid socket address `%s'\n",
local_addr);
- global_ret = 1;
- return;
+ goto fail_and_shutdown;
}
}
- remote_len = 0;
-
if (NULL != remote_addr)
{
remote_len = GNUNET_STRINGS_parse_socket_addr (remote_addr,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Invalid socket address `%s'\n",
remote_addr);
- global_ret = 1;
- return;
+ goto fail_and_shutdown;
}
}
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Use of `-W` only effective in combination with `-i`\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (NULL != remote_addr)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require IPv4 local address to initiate connection reversal\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (sizeof (struct sockaddr_in) != remote_len)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require IPv4 reversal target address\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
GNUNET_assert (AF_INET == local_sa->sa_family);
GNUNET_assert (AF_INET == remote_sa->sa_family);
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require local address to support STUN requests\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (IPPROTO_UDP != proto)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"STUN only supported over UDP\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
ls = GNUNET_NETWORK_socket_create (af,
SOCK_DGRAM,
GNUNET_a2s (local_sa,
local_len),
STRERROR (errno));
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
ls,
&stun_read_task,
NULL);
}
-
+ GNUNET_free_non_null (remote_sa);
+ GNUNET_free_non_null (local_sa);
test_finished ();
+ return;
+ fail_and_shutdown:
+ global_ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free_non_null (remote_sa);
+ GNUNET_free_non_null (local_sa);
}
switch (result)
{
case GNUNET_NAT_ERROR_SUCCESS:
+ GNUNET_assert (NULL != addr);
if (addr->s_addr == mini_external_ipv4.s_addr)
return; /* not change */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
if (sizeof (struct sockaddr_in) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
if (sizeof (struct sockaddr_in6) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
if (sizeof (struct sockaddr_un) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
#endif
default:
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
GNUNET_memcpy (off,
* Port number.
*/
uint16_t port;
-
+
/**
* IPv4 address. Should this be "struct in_addr"?
*/
/**
- * STUN message classes
+ * STUN message classes
*/
enum StunClasses {
INVALID_CLASS = 0,
static char result[64];
const char *msg_class = NULL;
const char *method = NULL;
- int value;
+ enum StunClasses cvalue;
+ enum StunMethods mvalue;
- value = decode_class (msg);
+ cvalue = decode_class (msg);
for (unsigned int i = 0; classes[i].name; i++)
- if (classes[i].value == value)
+ if (classes[i].value == cvalue)
{
msg_class = classes[i].name;
break;
}
- value = decode_method (msg);
+ mvalue = decode_method (msg);
for (unsigned int i = 0; methods[i].name; i++)
- if (methods[i].value == value)
+ if (methods[i].value == mvalue)
{
method = methods[i].name;
break;
GNUNET_CONTAINER_DLL_insert (alt->receive_queue_head,
alt->receive_queue_tail,
rc);
- GNUNET_MQ_send (GNUNET_CADET_get_mq (exit->cadet_channel),
+ GNUNET_MQ_send (GNUNET_CADET_get_mq (alt->cadet_channel),
GNUNET_MQ_env_copy (rc->env));
}
try_open_exit ();
"sq",
_("Failure to bind %u-th SQL parameter\n"),
i);
- return GNUNET_SYSERR;
+ if (SQLITE_OK !=
+ sqlite3_reset (stmt))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
+ "sq",
+ _("Failure in sqlite3_reset (!)\n"));
+ return GNUNET_SYSERR;
+ }
}
GNUNET_assert (0 != params[i].num_params);
j += params[i].num_params;
/**
* Timeout task for cancelling a forwarded overlay connect connect
*
- * @param cls the ForwardedOverlayConnectContext
+ * @param cls the `struct ForwardedOperationContext`
*/
static void
forwarded_overlay_connect_timeout (void *cls)
other_peer_id);
while (('\n' != data[offset]) && ('|' != data[offset]) && (offset < fs))
offset++;
- if ('\n' == data[offset])
+ if ( (offset < fs) &&
+ ('\n' == data[offset]) )
state = PEER_INDEX;
- else if ('|' == data[offset])
+ else if ( (offset < fs) &&
+ ('|' == data[offset]) )
{
state = OTHER_PEER_INDEX;
offset++;
{
if (NULL != topology)
*topology = (enum GNUNET_TESTBED_TopologyOption) cnt;
- GNUNET_assert (GNUNET_TESTBED_TOPOLOGY_OPTION_END != *topology);
+ GNUNET_assert (GNUNET_TESTBED_TOPOLOGY_OPTION_END != (enum GNUNET_TESTBED_TopologyOption) cnt);
return GNUNET_YES;
}
}
{
ikeys[key] = ptr;
ptr = strstr (ptr, ";");
+ GNUNET_assert (NULL != ptr); /* worked just before... */
*ptr = '\0';
ptr++;
}
GNUNET_assert (-1 != z);
if (z == fd)
return;
- dup2 (z, fd);
+ GNUNET_break (fd == dup2 (z, fd));
GNUNET_assert (0 == close (z));
}
#endif
GNUNET_break (0);
return;
}
- if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX)
+ if (plugin->bytes_in_buffer > INT64_MAX - udpw->msg_size)
{
GNUNET_break (0);
}
GNUNET_i2s (other),
me->no,
ps);
+ GNUNET_free (ps);
}
/* end of transport-testing-loggers.c */
/**
* Information tracked per connected peer.
- */
+ */
struct ConnectPairInfo
{
/**
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cls;
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
struct ConnectPairInfo *cpi;
-
+
if (NULL != ccc->nc)
ccc->nc (ccc->cls,
ccc->p[ipi->off],
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cls;
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
struct ConnectPairInfo *cpi = custom_cls;
-
+
if (NULL != ccc->nd)
ccc->nd (ccc->cls,
ccc->p[ipi->off],
ip[i].off = i;
ip[i].ccc = ccc;
}
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv,
- test_name_,
- "nohelp",
- options,
- &connect_check_run,
- ccc);
+ if (GNUNET_OK !=
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ argv,
+ test_name_,
+ "nohelp",
+ options,
+ &connect_check_run,
+ ccc))
+ return GNUNET_SYSERR;
return ccc->global_ret;
}
*
* @param p1 first peer
* @param p2 second peer
- * @param cb function to call
+ * @param cb function to call
* @param cb_cls closure for @a cb
*/
void
{
ccn = cc->next;
if ( (cc->p1 == p1) &&
- (cc->p2 == p2) )
+ (cc->p2 == p2) )
cb (cb_cls,
cc);
}
static void
-set_p1c (void *cls,
+set_p1c (void *cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
int *found = cls;
static void
-set_mq (void *cls,
+set_mq (void *cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
struct GNUNET_MQ_Handle *mq = cls;
static void
-set_p2c (void *cls,
+set_p2c (void *cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
int *found = cls;
static void
-clear_p1c (void *cls,
+clear_p1c (void *cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
int *found = cls;
static void
-clear_p2c (void *cls,
+clear_p2c (void *cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
int *found = cls;
else
ret = NULL;
- if (p2 != NULL)
+ if (NULL != p2)
GNUNET_asprintf (&p2_s,
"%u (`%s')",
p2->no,
int no = 0;
struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
-
+
p2 = find_peer_context (p->tth,
peer);
no = p->no;
struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
struct GNUNET_PeerIdentity *dummy;
unsigned int i;
-
+
if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
GNUNET_memcpy (p->handlers,
handlers,
i * sizeof (struct GNUNET_MQ_MessageHandler));
- }
+ }
if (NULL != cb_cls)
p->cb_cls = cb_cls;
else
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
-
+
/* shutdown */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Stopping peer %u (`%s')\n",
break;
}
}
-
+
cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
cc->p1 = p1;
cc->p2 = p2;
GNUNET_GETOPT_OPTION_END
};
+ err = 1;
memset (&sh,
0,
sizeof (sh));
return 0;
}
- GNUNET_assert (1024 >= size && size > 0);
- GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
+ GNUNET_assert ( (1024 >= size) && (size > 0) );
+ GNUNET_assert ( (SOCKS5_step_done > ih->step) && (ih->step >= 0) );
unsigned char * b = ih->outstep[ih->step];
unsigned char * e = ih->outstep[ih->step+1];
GNUNET_assert (e <= &ih->outbuf[1024]);
- unsigned l = e - b;
- GNUNET_assert (size >= l && l >= 0);
- GNUNET_memcpy(buf, b, l);
- register_reciever (ih, register_reciever_wants(ih));
+ unsigned int l = e - b;
+ GNUNET_assert (size >= l);
+ GNUNET_memcpy (buf,
+ b,
+ l);
+ register_reciever (ih,
+ register_reciever_wants (ih));
return l;
}
*/
struct GNUNET_CONNECTION_Handle *
GNUNET_SOCKS_do_connect (const char *service_name,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_SOCKS_Handshake *ih;
struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
- char *host0,*host1,*user,*pass;
- unsigned long long port0,port1;
-
- if (GNUNET_YES != GNUNET_SOCKS_check_service (service_name, cfg))
+ char *host0;
+ char *host1;
+ char *user;
+ char *pass;
+ unsigned long long port0;
+ unsigned long long port1;
+
+ if (GNUNET_YES !=
+ GNUNET_SOCKS_check_service (service_name, cfg))
return NULL;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "SOCKSPORT", &port0))
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ service_name,
+ "SOCKSPORT",
+ &port0))
port0 = 9050;
/* A typical Tor client should usually try port 9150 for the TBB too, but
* GNUnet can probably assume a system Tor installation. */
service_name);
return NULL;
}
- if ((GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port1))
- || (port1 > 65535) || (port1 <= 0) ||
+ if ( (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ service_name,
+ "PORT",
+ &port1)) ||
+ (port1 > 65535) ||
+ (port1 <= 0) ||
(GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME", &host1)))
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ service_name,
+ "HOSTNAME",
+ &host1)))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _
- ("Attempting to proxy service `%s' to invalid port %d or hostname `%s'.\n"),
- service_name,port1,host1);
+ _("Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
+ service_name,
+ port1);
return NULL;
}
/* Appeared to still work after host0 corrupted, so either test case is broken, or
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0))
host0 = NULL;
- socks5 = GNUNET_CONNECTION_create_from_connect (cfg, (host0 != NULL)? host0:"127.0.0.1", port0);
+ socks5 = GNUNET_CONNECTION_create_from_connect (cfg,
+ (host0 != NULL)
+ ? host0
+ :"127.0.0.1",
+ port0);
GNUNET_free_non_null (host0);
/* Sets to NULL if they do not exist */
- (void) GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSUSER", &user);
- (void) GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSPASS", &pass);
+ (void) GNUNET_CONFIGURATION_get_value_string (cfg,
+ service_name,
+ "SOCKSUSER",
+ &user);
+ (void) GNUNET_CONFIGURATION_get_value_string (cfg,
+ service_name,
+ "SOCKSPASS",
+ &pass);
ih = GNUNET_SOCKS_init_handshake(user,pass);
- if (NULL != user) GNUNET_free (user);
- if (NULL != pass) GNUNET_free (pass);
+ GNUNET_free_non_null (user);
+ GNUNET_free_non_null (pass);
- GNUNET_SOCKS_set_handshake_destination (ih,host1,port1);
+ GNUNET_SOCKS_set_handshake_destination (ih,
+ host1,
+ port1);
GNUNET_free (host1);
-
- return GNUNET_SOCKS_run_handshake(ih,socks5);
+ return GNUNET_SOCKS_run_handshake (ih,
+ socks5);
}
/* socks.c */
void *payload;
uint8_t new_type;
+ new_type = icmp->type;
/* Perform ICMP protocol-translation (depending on destination AF and source AF)
and throw away ICMP payload depending on ICMP message type */
switch (af)
switch (icmp->type)
{
case GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE:
- if (destination->details.exit_destination.af == AF_INET6)
- new_type = GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE;
+ if (destination->details.exit_destination.af == AF_INET)
+ new_type = GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE;
/* throw away IP-payload, exit will have to make it up anyway */
payload_length = sizeof (struct GNUNET_TUN_IcmpHeader);
break;