--- /dev/null
+Bart Polot <bart.polot+gnunet@gmail.com>
+Bart Polot <bart.polot+gnunet@gmail.com> <bart.polot+voyager@gmail.com>
+Bart Polot <bart.polot+gnunet@gmail.com> <bart@net.in.tum.de>
+Carlo von lynX <lynX@time.to.get.psyced.org>
+Carlo von lynX <lynX@time.to.get.psyced.org> psyc://loupsycedyglgamf.onion/~lynX <BM-NB7xa9gEpmJgYp9PVnEdACiZcGmmEJcY>
+Carlo von lynX <lynX@time.to.get.psyced.org> psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>
+David Barksdale <amatus@amat.us> <amatus.amongus@gmail.com>
+David Barksdale <amatus@amat.us>
+David Barksdale <amatus@amat.us> <amatus@amatus.name>
+Jeffrey Burdges <burdges@gnunet.org> Jeff Burdges <burdges@gnunet.org>
+Jeffrey Burdges <burdges@gnunet.org>
+Руслан Ижбулатов <lrn1986@gmail.com>
+Руслан Ижбулатов <lrn1986@gmail.com> LRN <lrn1986@gmail.com>
+Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
+Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <mschanzenbach@posteo.de>
+Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Martin Schanzenbach <mschanzenbach@posteo.de>
+ng0 <ng0@n0.is>
+ng0 <ng0@n0.is> <contact.ng0@cryptolab.net>
+ng0 <ng0@n0.is> <ng0@infotropique.org>
+ng0 <ng0@n0.is> N. 'ng0' Gillmann <ngillmann@runbox.com>
+ng0 <ng0@n0.is> <ng0@we.make.ritual.n0.is>
+t3sserakt <t3ss@posteo.de>
+t3sserakt <t3ss@posteo.de> <t3sserakt@posteo.de>
+tg(x) <*@tg-x.net>
+tg(x) <*@tg-x.net> Gabor X Toth <*@tg-x.net>
+
optional (for @command{gnunet-gtk})
@item libqrencode @geq{} 3.0,
optional (for @command{gnunet-namestore-gtk})
+@item libpbc @geq{} 0.5.14, optional for Attribute-Based Encryption and Identity Provider functionality
+@item libgabe (https://github.com/schanzen/libgabe), optional for Attribute-Based Encryption and Identity Provider functionality
@end itemize
@node Internal dependencies
clean:
rm -rf html
+
+EXTRA_DIST = \
+ gnunet.doxy
pkgcfgdir= $(pkgdatadir)/config.d/
-dist_pkgcfg_DATA = \
- abe.conf
-
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
XLIB = -lgcov
struct GNUNET_CADET_Handle *h = ch->cadet;
uint16_t msize;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_CADET_LocalData *cadet_msg;
+ struct GNUNET_CADET_LocalData *cadet_msg = NULL;
if (NULL == h->mq)
{
ch = create_channel (h,
&ccn);
ch->peer = msg->peer;
- ch->cadet = h;
ch->incoming_port = port;
ch->options = ntohl (msg->opt);
LOG (GNUNET_ERROR_TYPE_DEBUG,
TEST_CREDENTIAL="t1"
gnunet-namestore -p -z testsubject -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
+CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$ISSUER_KEY --attribute=$TEST_ATTR --ego=testsubject -c test_credential_lookup.conf | paste -d, -s`
+
+
#TODO2 Add -z swich like in gnunet-gns
#RES_CRED=`$DO_TIMEOUT gnunet-credential --verify --issuer=$ISSUER_KEY --attribute="$TEST_ATTR" --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf`
-RES_CRED=`gnunet-credential --verify --issuer=$ISSUER_KEY --attribute=$TEST_ATTR --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf`
+RES_CRED=`gnunet-credential --verify --issuer=$ISSUER_KEY --attribute=$TEST_ATTR --subject=$SUBJECT_KEY --credential="$CREDS" -c test_credential_lookup.conf`
#TODO cleanup properly
gnunet-namestore -z testsubject -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
gnunet-identity -D testsubject -c test_credential_lookup.conf
gnunet-arm -e -c test_credential_lookup.conf
-echo $RES_CRED
#TODO3 proper test
-if [ "$RES_CRED" == "Successful." ]
+if [ "$RES_CRED" != "Failed." ]
then
exit 0
else
/*
This file is part of GNUnet
- Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+ Copyright (C) 2014, 2015, 2016, 2018 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
CURLINFO_PRIVATE,
(char **) &job));
GNUNET_assert (job->ctx == ctx);
+ response_code = 0;
j = download_get_result (&job->db,
job->easy_handle,
&response_code);
GNUNET_PQ_result_spec_end
};
+ if (GNUNET_YES !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ return;
+ }
if (0 != (path_len % sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
trc = GNUNET_NO;
for (i=0;i<p->num_queries;i++)
{
- ret = GNUNET_DNSPARSER_builder_add_query (tmp, sizeof (tmp), &off, &p->queries[i]);
+ ret = GNUNET_DNSPARSER_builder_add_query (tmp,
+ sizeof (tmp),
+ &off,
+ &p->queries[i]);
if (GNUNET_SYSERR == ret)
return GNUNET_SYSERR;
if (GNUNET_NO == ret)
}
for (i=0;i<p->num_answers;i++)
{
- ret = add_record (tmp, sizeof (tmp), &off, &p->answers[i]);
+ ret = add_record (tmp,
+ sizeof (tmp),
+ &off,
+ &p->answers[i]);
if (GNUNET_SYSERR == ret)
return GNUNET_SYSERR;
if (GNUNET_NO == ret)
}
for (i=0;i<p->num_authority_records;i++)
{
- ret = add_record (tmp, sizeof (tmp), &off, &p->authority_records[i]);
+ ret = add_record (tmp,
+ sizeof (tmp),
+ &off,
+ &p->authority_records[i]);
if (GNUNET_SYSERR == ret)
return GNUNET_SYSERR;
if (GNUNET_NO == ret)
}
for (i=0;i<p->num_additional_records;i++)
{
- ret = add_record (tmp, sizeof (tmp), &off, &p->additional_records[i]);
+ ret = add_record (tmp,
+ sizeof (tmp),
+ &off,
+ &p->additional_records[i]);
if (GNUNET_SYSERR == ret)
return GNUNET_SYSERR;
if (GNUNET_NO == ret)
if (GNUNET_YES == trc)
dns.flags.message_truncated = 1;
- GNUNET_memcpy (tmp, &dns, sizeof (struct GNUNET_TUN_DnsHeader));
+ GNUNET_memcpy (tmp,
+ &dns,
+ sizeof (struct GNUNET_TUN_DnsHeader));
*buf = GNUNET_malloc (off);
*buf_length = off;
- GNUNET_memcpy (*buf, tmp, off);
+ GNUNET_memcpy (*buf,
+ tmp,
+ off);
if (GNUNET_YES == trc)
return GNUNET_NO;
return GNUNET_OK;
chld->short_filename[slen-1] = '\0';
chld->is_directory = is_directory;
if (NULL != parent)
- GNUNET_CONTAINER_DLL_insert (parent->children_head,
- parent->children_tail,
- chld);
+ GNUNET_CONTAINER_DLL_insert (parent->children_head,
+ parent->children_tail,
+ chld);
return chld;
}
size_t left;
#if 0
- fprintf (stderr, "DMS parses %u-byte message of type %u\n",
+ fprintf (stderr,
+ "DMS parses %u-byte message of type %u\n",
(unsigned int) ntohs (msg->size),
(unsigned int) ntohs (msg->type));
#endif
filename, GNUNET_NO,
GNUNET_FS_DIRSCANNER_FILE_START);
if (NULL == ds->toplevel)
+ {
ds->toplevel = expand_tree (ds->pos,
- filename, GNUNET_NO);
+ filename,
+ GNUNET_NO);
+ }
else
+ {
+ GNUNET_assert (NULL != ds->pos);
(void) expand_tree (ds->pos,
- filename, GNUNET_NO);
+ filename,
+ GNUNET_NO);
+ }
return GNUNET_OK;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY:
if (filename[left-1] != '\0')
filename, GNUNET_YES,
GNUNET_FS_DIRSCANNER_FILE_START);
ds->pos = expand_tree (ds->pos,
- filename, GNUNET_YES);
+ filename,
+ GNUNET_YES);
if (NULL == ds->toplevel)
ds->toplevel = ds->pos;
return GNUNET_OK;
break;
}
ds->progress_callback (ds->progress_callback_cls,
- filename, GNUNET_YES,
+ filename,
+ GNUNET_YES,
GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
if (0 < left)
{
- ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left);
+ ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end,
+ left);
if (NULL == ds->pos->meta)
{
GNUNET_break (0);
is_recursive_download (struct GNUNET_FS_DownloadContext *dc)
{
return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) &&
- ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
+ ( (GNUNET_YES ==
+ GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
( (NULL == dc->meta) &&
( (NULL == dc->filename) ||
( (strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
* field in the `struct GNUNET_FS_ProgressInfo`
*/
static void *
-progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
+progress_cb (void *cls,
+ const struct GNUNET_FS_ProgressInfo *info)
{
char *s;
const char *s2;
{
case GNUNET_FS_STATUS_DOWNLOAD_START:
if (verbose > 1)
- FPRINTF (stderr, _("Starting download `%s'.\n"),
+ FPRINTF (stderr,
+ _("Starting download `%s'.\n"),
info->value.download.filename);
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
== GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
s2 = _("<unknown time>");
else
- s2 = GNUNET_STRINGS_relative_time_to_string (
- info->value.download.specifics.progress.block_download_duration,
+ s2 = GNUNET_STRINGS_relative_time_to_string (info->value.download.specifics.progress.block_download_duration,
GNUNET_YES);
t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
1000LL /
_("Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block took %s to download\n"),
info->value.download.filename,
(unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size, s, t, s2);
+ (unsigned long long) info->value.download.size,
+ s,
+ t,
+ s2);
GNUNET_free (s);
GNUNET_free (t);
}
if (0 != isatty (1))
fprintf (stdout, "\n");
#else
- if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
+ if (FILE_TYPE_CHAR ==
+ GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
fprintf (stdout, "\n");
#endif
FPRINTF (stderr, _("Error downloading: %s.\n"),
if (0 != isatty (1))
fprintf (stdout, "\n");
#else
- if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
+ if (FILE_TYPE_CHAR ==
+ GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
fprintf (stdout, "\n");
#endif
- FPRINTF (stdout, _("Downloading `%s' done (%s/s).\n"),
+ FPRINTF (stdout,
+ _("Downloading `%s' done (%s/s).\n"),
info->value.download.filename, s);
GNUNET_free (s);
if (info->value.download.dc == dc)
case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
break;
default:
- FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+ FPRINTF (stderr,
+ _("Unexpected status: %d\n"),
+ info->status);
break;
}
return NULL;
* @param c configuration
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
struct GNUNET_FS_Uri *uri;
if (NULL == args[0])
{
- FPRINTF (stderr, "%s", _("You need to specify a URI argument.\n"));
+ FPRINTF (stderr,
+ "%s",
+ _("You need to specify a URI argument.\n"));
return;
}
uri = GNUNET_FS_uri_parse (args[0], &emsg);
if (NULL == uri)
{
- FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg);
+ FPRINTF (stderr,
+ _("Failed to parse URI: %s\n"),
+ emsg);
GNUNET_free (emsg);
ret = 1;
return;
}
- if ((!GNUNET_FS_uri_test_chk (uri)) && (!GNUNET_FS_uri_test_loc (uri)))
+ if ( (! GNUNET_FS_uri_test_chk (uri)) &&
+ (! GNUNET_FS_uri_test_loc (uri)))
{
- FPRINTF (stderr, "%s", _("Only CHK or LOC URIs supported.\n"));
+ FPRINTF (stderr,
+ "%s",
+ _("Only CHK or LOC URIs supported.\n"));
ret = 1;
GNUNET_FS_uri_destroy (uri);
return;
}
if (NULL == filename)
{
- FPRINTF (stderr, "%s", _("Target filename must be specified.\n"));
+ FPRINTF (stderr,
+ "%s",
+ _("Target filename must be specified.\n"));
ret = 1;
GNUNET_FS_uri_destroy (uri);
return;
}
cfg = c;
- ctx =
- GNUNET_FS_start (cfg, "gnunet-download", &progress_cb, NULL,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, parallelism,
- GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
- request_parallelism, GNUNET_FS_OPTIONS_END);
+ ctx = GNUNET_FS_start (cfg,
+ "gnunet-download",
+ &progress_cb, NULL,
+ GNUNET_FS_FLAGS_NONE,
+ GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM,
+ parallelism,
+ GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
+ request_parallelism,
+ GNUNET_FS_OPTIONS_END);
if (NULL == ctx)
{
- FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
+ FPRINTF (stderr,
+ _("Could not initialize `%s' subsystem.\n"),
+ "FS");
GNUNET_FS_uri_destroy (uri);
ret = 1;
return;
options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
if (local_only)
options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
- dc = GNUNET_FS_download_start (ctx, uri, NULL, filename, NULL, 0,
+ dc = GNUNET_FS_download_start (ctx,
+ uri,
+ NULL,
+ filename,
+ NULL,
+ 0,
GNUNET_FS_uri_chk_get_file_size (uri),
- anonymity, options, NULL, NULL);
+ anonymity,
+ options,
+ NULL,
+ NULL);
GNUNET_FS_uri_destroy (uri);
if (dc == NULL)
{
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_uint ('a',
- "anonymity",
- "LEVEL",
- gettext_noop ("set the desired LEVEL of receiver-anonymity"),
- &anonymity),
+ "anonymity",
+ "LEVEL",
+ gettext_noop ("set the desired LEVEL of receiver-anonymity"),
+ &anonymity),
GNUNET_GETOPT_option_flag ('D',
- "delete-incomplete",
- gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
- &delete_incomplete),
+ "delete-incomplete",
+ gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
+ &delete_incomplete),
GNUNET_GETOPT_option_flag ('n',
- "no-network",
- gettext_noop ("only search the local peer (no P2P network search)"),
- &local_only),
-
+ "no-network",
+ gettext_noop ("only search the local peer (no P2P network search)"),
+ &local_only),
GNUNET_GETOPT_option_string ('o',
"output",
"FILENAME",
gettext_noop ("write the file to FILENAME"),
&filename),
-
GNUNET_GETOPT_option_uint ('p',
- "parallelism",
- "DOWNLOADS",
- gettext_noop ("set the maximum number of parallel downloads that is allowed"),
- ¶llelism),
-
+ "parallelism",
+ "DOWNLOADS",
+ gettext_noop ("set the maximum number of parallel downloads that is allowed"),
+ ¶llelism),
GNUNET_GETOPT_option_uint ('r',
- "request-parallelism",
- "REQUESTS",
- gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"),
- &request_parallelism),
-
+ "request-parallelism",
+ "REQUESTS",
+ gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"),
+ &request_parallelism),
GNUNET_GETOPT_option_flag ('R',
- "recursive",
- gettext_noop ("download a GNUnet directory recursively"),
- &do_recursive),
-
+ "recursive",
+ gettext_noop ("download a GNUnet directory recursively"),
+ &do_recursive),
GNUNET_GETOPT_option_increment_uint ('V',
- "verbose",
- gettext_noop ("be verbose (print progress information)"),
- &verbose),
-
+ "verbose",
+ gettext_noop ("be verbose (print progress information)"),
+ &verbose),
GNUNET_GETOPT_OPTION_END
};
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-download [OPTIONS] URI",
+ GNUNET_PROGRAM_run (argc, argv,
+ "gnunet-download [OPTIONS] URI",
gettext_noop
("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"),
- options, &run, NULL)) ? ret : 1;
+ options,
+ &run, NULL)) ? ret : 1;
GNUNET_free ((void*) argv);
return ret;
}
/**
* ID of a task associated with the resolution process.
*/
- struct GNUNET_SCHEDULER_Task * task_id;
+ struct GNUNET_SCHEDULER_Task *task_id;
/**
* The name to resolve
}
rh->protocol = pe->p_proto;
rh->service = se->s_port;
+ GNUNET_free (proto_name);
+ GNUNET_free (srv_name);
}
return ret;
}
* Begin the resolution process from 'name', starting with
* the identification of the zone specified by 'name'.
*
- * @param rh resolution to perform
+ * @param cls closure with `struct GNS_ResolverHandle *rh`
*/
static void
-start_resolver_lookup (struct GNS_ResolverHandle *rh);
+start_resolver_lookup (void *cls);
/**
unsigned int rd_count;
unsigned int i;
+ (void) rs;
rh->dns_request = NULL;
GNUNET_SCHEDULER_cancel (rh->task_id);
rh->task_id = NULL;
GNUNET_free (rh->name);
rh->name = GNUNET_strdup (p->answers[0].data.hostname);
rh->name_resolution_pos = strlen (rh->name);
- start_resolver_lookup (rh);
+ rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
+ rh);
GNUNET_DNSPARSER_free_packet (p);
return;
}
struct GNUNET_DNSPARSER_Packet *p;
char *dns_request;
size_t dns_request_length;
+ int ret;
ac = rh->ac_tail;
GNUNET_assert (NULL != ac);
UINT16_MAX);
p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY;
p->flags.recursion_desired = 1;
- if (GNUNET_OK !=
- GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length))
+ ret = GNUNET_DNSPARSER_pack (p,
+ 1024,
+ &dns_request,
+ &dns_request_length);
+ if (GNUNET_OK != ret)
{
GNUNET_break (0);
- rh->proc (rh->proc_cls, 0, NULL);
+ rh->proc (rh->proc_cls,
+ 0,
+ NULL);
GNS_resolver_lookup_cancel (rh);
}
else
&fail_resolution,
rh);
}
- GNUNET_free (dns_request);
+ if (GNUNET_SYSERR != ret)
+ GNUNET_free (dns_request);
GNUNET_DNSPARSER_free_packet (p);
}
GNUNET_free (rh->name);
rh->name = GNUNET_strdup (cname);
rh->name_resolution_pos = strlen (rh->name);
- start_resolver_lookup (rh);
+ rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
+ rh);
}
vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size);
vpn_ctx->rd_count = rd_count;
GNUNET_assert (vpn_ctx->rd_data_size ==
- GNUNET_GNSRECORD_records_serialize (rd_count,
- rd,
- vpn_ctx->rd_data_size,
- vpn_ctx->rd_data));
+ (size_t) GNUNET_GNSRECORD_records_serialize (rd_count,
+ rd,
+ vpn_ctx->rd_data_size,
+ vpn_ctx->rd_data));
vpn_ctx->vpn_request = GNUNET_VPN_redirect_to_peer (vpn_handle,
af,
ntohs (vpn->proto),
g2dc->rh->options = GNUNET_GNS_LO_DEFAULT;
g2dc->rh->loop_limiter = rh->loop_limiter + 1;
rh->g2dc = g2dc;
- start_resolver_lookup (g2dc->rh);
+ g2dc->rh->task_id
+ = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
+ g2dc->rh);
return;
}
case GNUNET_DNSPARSER_TYPE_CNAME:
struct CacheOps *co = cls;
co->namecache_qe_cache = NULL;
- if (NULL != emsg)
+ if (GNUNET_OK != success)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Failed to cache GNS resolution: %s\n"),
emsg);
const struct GNUNET_PeerIdentity *put_path,
unsigned int put_path_length,
enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
+ size_t size,
+ const void *data)
{
struct GNS_ResolverHandle *rh = cls;
struct AuthorityChain *ac = rh->ac_tail;
const struct GNUNET_GNSRECORD_Block *block;
struct CacheOps *co;
+ (void) exp;
+ (void) key;
+ (void) get_path;
+ (void) get_path_length;
+ (void) put_path;
+ (void) put_path_length;
+ (void) type;
GNUNET_DHT_get_stop (rh->get_handle);
rh->get_handle = NULL;
GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node);
* Begin the resolution process from 'name', starting with
* the identification of the zone specified by 'name'.
*
- * @param rh resolution to perform
+ * @param cls the `struct GNS_ResolverHandle`
*/
static void
-start_resolver_lookup (struct GNS_ResolverHandle *rh)
+start_resolver_lookup (void *cls)
{
+ struct GNS_ResolverHandle *rh = cls;
struct AuthorityChain *ac;
char *y;
struct in_addr v4;
struct in6_addr v6;
+ rh->task_id = NULL;
if (1 == inet_pton (AF_INET,
rh->name,
&v4))
uint32_t record_type,
const char *name,
enum GNUNET_GNS_LocalOptions options,
- GNS_ResultProcessor proc, void *proc_cls)
+ GNS_ResultProcessor proc,
+ void *proc_cls)
{
struct GNS_ResolverHandle *rh;
rh->record_type = record_type;
rh->name = GNUNET_strdup (name);
rh->name_resolution_pos = strlen (name);
- start_resolver_lookup (rh);
+ rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
+ rh);
return rh;
}
*/
static struct GNUNET_CREDENTIAL_Handle *credential_handle;
-/**
- * Stats handle
- */
-static struct GNUNET_STATISTICS_Handle *stats_handle;
-
/**
* Namestore qe
*/
GNUNET_NAMESTORE_cancel (ns_qe);
if (NULL != ns_handle)
GNUNET_NAMESTORE_disconnect (ns_handle);
- if (NULL != stats_handle)
- GNUNET_STATISTICS_destroy (stats_handle, GNUNET_NO);
GNUNET_free_non_null (token);
GNUNET_free_non_null (label);
parallel_lookup);
GNUNET_free (parallel_lookup->label);
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"attribute_lookup_time_total",
GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time).rel_value_us,
GNUNET_YES);
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"attribute_lookups_count",
1,
GNUNET_YES);
(void**)&data);
if (GNUNET_SYSERR != attr_len)
{
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"abe_decrypt_time_total",
GNUNET_TIME_absolute_get_duration (decrypt_duration).rel_value_us,
GNUNET_YES);
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"abe_decrypt_count",
1,
GNUNET_YES);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted bytes: %zd Expected bytes: %zd\n",
size, rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"abe_key_lookup_time_total",
GNUNET_TIME_absolute_get_duration (handle->lookup_start_time).rel_value_us,
GNUNET_YES);
- GNUNET_STATISTICS_update (stats_handle,
+ GNUNET_STATISTICS_update (stats,
"abe_key_lookups_count",
1,
GNUNET_YES);
identity_handle = GNUNET_IDENTITY_connect (cfg,
NULL,
NULL);
- stats_handle = GNUNET_STATISTICS_create ("identity-provider",
- cfg);
/* Loading DB plugin */
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
struct GNUNET_JSONAPI_Resource *json_res;
struct RequestHandle *handle = cls;
struct EgoEntry *ego_entry;
+ struct EgoEntry *ego_entry_tmp;
struct MHD_Response *resp;
json_t *subsys_json;
json_t *name_json;
if ((NULL != name_json) && json_is_string (name_json))
{
newname = json_string_value (name_json);
- for (ego_entry = handle->ego_head;
- NULL != ego_entry;
- ego_entry = ego_entry->next)
+ for (ego_entry_tmp = handle->ego_head;
+ NULL != ego_entry_tmp;
+ ego_entry_tmp = ego_entry_tmp->next)
{
- if (0 == strcasecmp (newname, ego_entry->identifier) &&
- 0 != strcasecmp (keystring, ego_entry->keystring))
+ if (0 == strcasecmp (newname, ego_entry_tmp->identifier) &&
+ 0 != strcasecmp (keystring, ego_entry_tmp->keystring))
{
//Ego with same name not allowed
GNUNET_JSONAPI_document_delete (json_obj);
{
/**
- * Maximum number of any socket socket descriptor in the set (plus one)
+ * Maximum number of any socket descriptor in the set (plus one)
*/
int nsds;
GNUNET_SET_ElementIterator iter,
void *iter_cls);
+
/**
* Stop iteration over all elements in the given set. Can only
* be called before the iteration has "naturally" completed its
void
GNUNET_SET_iterate_cancel (struct GNUNET_SET_Handle *set);
+
/**
* Create a copy of an element. The copy
* must be GNUNET_free-d by the caller.
struct GNUNET_SET_Element *
GNUNET_SET_element_dup (const struct GNUNET_SET_Element *element);
+
/**
* Hash a set element.
*
/*
- This file is part of GNUnet
- (C) 2015, 2016 GNUnet e.V.
+ This file is part of GNUnet
+ (C) 2015, 2016 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 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.
+ 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, If not, see <http://www.gnu.org/licenses/>
-*/
+ You should have received a copy of the GNU General Public License along with
+ GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
+ */
/**
* @file json/test_jsonapi.c
#include "gnunet_jsonapi_lib.h"
#include "gnunet_json_lib.h"
-#define TEST_JSONAPI_DOCUMENT "{\"data\":{\"id\":\"1\",\"type\":\"bar\",\"attributes\":{\"foo\":\"bar\"}}}"
+#define TEST_JSONAPI_DOCUMENT "{\"data\":[{\"id\":\"1\",\"type\":\"bar\",\"attributes\":{\"foo\":\"bar\"}}]}"
#define TEST_JSONAPI_DOCUMENT_ERR "{\"errors\":[{\"id\":\"1\",\"status\":\"403\",\"code\":\"23\", \"title\":\"Error\", \"detail\":\"Error details\"}]}"
json_t *doc_json;
json_t *data_js;
json_error_t err;
-
+ int ret;
+
obj = GNUNET_JSONAPI_document_new ();
res = GNUNET_JSONAPI_resource_new ("bar",
"1");
JSON_DECODE_ANY,
&err);
GNUNET_assert (NULL != data_js);
- GNUNET_assert (0 != json_equal (data_js, doc_json));
+ ret = json_equal (data_js, doc_json) ? 0 : 1;
GNUNET_JSONAPI_document_delete (obj);
json_decref (data_js);
json_decref (doc_json);
- return 0;
+ return ret;
}
static int
{
struct GNUNET_JSONAPI_Document *obj;
char* tmp_data;
+ int ret;
json_t* data_js;
json_t* tmp_data_js;
json_error_t err;
GNUNET_JSON_parse_free (jsonapispec);
tmp_data_js = json_loads (tmp_data, JSON_DECODE_ANY, &err);
GNUNET_assert (NULL != tmp_data_js);
- GNUNET_assert (0 != json_equal (tmp_data_js, data_js));
+ ret = (1 == json_equal (tmp_data_js, data_js)) ? 0 : 1;
json_decref (data_js);
json_decref (tmp_data_js);
GNUNET_free (tmp_data);
- return 0;
+ return ret;
}
/**
if (n <= 0)
n = GNUNET_CONTAINER_multihashmap_get_random (members, client_send_member_cb,
(void *) env);
+ GNUNET_MQ_discard (env);
return n;
}
{
unsigned int *cnt = cls;
+ (void) address;
+ (void) expiration;
(*cnt)++;
return GNUNET_OK;
}
const struct GNUNET_HELLO_Message *hello;
struct GNUNET_HELLO_Message *hello_clean;
size_t read_pos;
- int size_hello;
+ uint16_t size_hello;
r->friend_only_hello = NULL;
r->hello = NULL;
"Read %d bytes from `%s'\n",
(int) size_total,
fn);
- if (size_total < sizeof (struct GNUNET_MessageHeader))
+ if ( (size_total < 0) ||
+ (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to parse HELLO in file `%s': %s\n"),
}
read_pos = 0;
- while (read_pos < size_total)
+ while (read_pos < (size_t) size_total)
{
hello = (const struct GNUNET_HELLO_Message *) &buffer[read_pos];
size_hello = GNUNET_HELLO_size (hello);
if ( (0 == size_hello) ||
- (size_total - read_pos < size_hello) )
+ (((size_t) size_total) - read_pos < size_hello) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to parse HELLO in file `%s'\n"),
if (GNUNET_OK !=
GNUNET_HELLO_get_id (r.friend_only_hello,
&id_friend))
+ {
if (GNUNET_YES == dsc->remove_files)
- {
remove_garbage (fullname);
- return GNUNET_OK;
- }
+ return GNUNET_OK;
+ }
id = id_friend;
}
if (NULL != r.hello)
if (GNUNET_OK !=
GNUNET_HELLO_get_id (r.hello,
&id_public))
+ {
if (GNUNET_YES == dsc->remove_files)
- {
remove_garbage (fullname);
- return GNUNET_OK;
- }
+ return GNUNET_OK;
+ }
id = id_public;
}
static unsigned int retries;
struct DirScanContext dsc;
+ (void) cls;
cron_scan = NULL;
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create (networkIdDirectory))
int friend_hello_type;
int store_hello;
int store_friend_hello;
- int pos;
+ unsigned int pos;
char *buffer;
host = GNUNET_CONTAINER_multipeermap_get (hostmap, peer);
if (GNUNET_YES == store_friend_hello)
{
GNUNET_memcpy (&buffer[pos],
- host->friend_only_hello,
- GNUNET_HELLO_size (host->friend_only_hello));
+ host->friend_only_hello,
+ GNUNET_HELLO_size (host->friend_only_hello));
pos += GNUNET_HELLO_size (host->friend_only_hello);
}
GNUNET_assert (pos == size);
unsigned int cnt;
char *writebuffer;
uint64_t fsize;
+
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (fn,
+ &fsize,
+ GNUNET_YES,
+ GNUNET_YES))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
+ GNUNET_ERROR_TYPE_BULK,
+ "fstat",
+ fn);
+ return GNUNET_OK;
+ }
+ read_size = GNUNET_DISK_fn_read (fn,
+ buffer,
+ sizeof (buffer));
- GNUNET_DISK_file_size (fn, &fsize, GNUNET_YES, GNUNET_YES);
- read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
-
- if ((read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
- (fsize > GNUNET_MAX_MESSAGE_SIZE))
+ if ( (read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
+ (fsize > GNUNET_MAX_MESSAGE_SIZE) )
{
if (0 != UNLINK (fn))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
- GNUNET_ERROR_TYPE_BULK, "unlink", fn);
+ GNUNET_ERROR_TYPE_BULK,
+ "unlink",
+ fn);
return GNUNET_OK;
}
{
struct GNUNET_TIME_Absolute now;
+ (void) cls;
cron_clean = NULL;
now = GNUNET_TIME_absolute_get ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
{
struct GNUNET_PeerIdentity pid;
+ (void) cls;
if (GNUNET_OK !=
GNUNET_HELLO_get_id (hello,
&pid))
struct GNUNET_SERVICE_Client *client,
struct GNUNET_MQ_Handle *mq)
{
+ (void) cls;
+ (void) mq;
return client;
}
struct GNUNET_SERVICE_Client *client,
void *app_ctx)
{
+ (void) cls;
GNUNET_assert (app_ctx == client);
}
{
struct HostEntry *he = value;
+ (void) cls;
+ (void) key;
GNUNET_free_non_null (he->hello);
GNUNET_free_non_null (he->friend_only_hello);
GNUNET_free (he);
static void
shutdown_task (void *cls)
{
+ (void) cls;
GNUNET_notification_context_destroy (notify_list);
notify_list = NULL;
GNUNET_notification_context_destroy (notify_friend_only_list);
int noio;
int use_included;
+ (void) cls;
+ (void) service;
hostmap
= GNUNET_CONTAINER_multipeermap_create (1024,
GNUNET_YES);
NULL, NULL);
}
block = REGEX_BLOCK_create (proof,
- num_edges, edges,
+ num_edges,
+ edges,
accepting,
&size);
- (void)
- GNUNET_DHT_put (h->dht, key,
- DHT_REPLICATION,
- DHT_OPT,
- GNUNET_BLOCK_TYPE_REGEX,
- size, block,
- GNUNET_TIME_relative_to_absolute (DHT_TTL),
- NULL, NULL);
+ if (NULL == block)
+ return;
+ (void) GNUNET_DHT_put (h->dht,
+ key,
+ DHT_REPLICATION,
+ DHT_OPT,
+ GNUNET_BLOCK_TYPE_REGEX,
+ size,
+ block,
+ GNUNET_TIME_relative_to_absolute (DHT_TTL),
+ NULL,
+ NULL);
GNUNET_STATISTICS_update (h->stats,
"# regex blocks stored",
- 1, GNUNET_NO);
+ 1,
+ GNUNET_NO);
GNUNET_STATISTICS_update (h->stats,
"# regex block bytes stored",
- size, GNUNET_NO);
+ size,
+ GNUNET_NO);
GNUNET_free (block);
}
static void
space (int n)
{
- int i;
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
fprintf (stderr, "| ");
}
static void
debugctx (struct RegexCombineCtx *ctx, int level)
{
- return;
- unsigned int i;
+#if DEBUG_REGEX
if (NULL != ctx->s)
{
space (level - 1);
}
else
fprintf (stderr, "ROOT (base %u)\n", ctx->size);
- for (i = 0; i < ctx->size; i++)
+ for (unsigned int i = 0; i < ctx->size; i++)
{
if (NULL != ctx->children[i])
{
}
}
fflush(stderr);
+#endif
}
* @param regex Regex to add.
*/
static void
-regex_add (struct RegexCombineCtx *ctx, const char *regex);
+regex_add (struct RegexCombineCtx *ctx,
+ const char *regex);
/**
return ctx;
}
+
static void
-move_children (struct RegexCombineCtx *dst, const struct RegexCombineCtx *src)
+move_children (struct RegexCombineCtx *dst,
+ const struct RegexCombineCtx *src)
{
size_t array_size;
array_size = sizeof(struct RegexCombineCtx *) * src->size;
- memcpy (dst->children, src->children, array_size);
- for (int i = 0; i < src->size; i++)
+ memcpy (dst->children,
+ src->children,
+ array_size);
+ for (unsigned int i = 0; i < src->size; i++)
{
src->children[i] = NULL;
}
tmp = ctx->children;
ctx->children = GNUNET_malloc (sizeof(*tmp) * ctx->size);
regex_add_multiple (ctx, suffix, tmp);
+ GNUNET_free (suffix);
GNUNET_free (tmp);
return;
}
{
peer_entry = new_peer_entry (other_peer);
}
- GNUNET_assert (NULL == peer_entry->so);
+ if (NULL != peer_entry->so)
+ {
+ GNUNET_break_op (0);
+ return;
+ }
peer_entry->so = GNUNET_SET_accept (request,
GNUNET_SET_RESULT_ADDED,
(struct GNUNET_SET_Option[]) {{ 0 }},
GNUNET_SET_commit (peer_entry->so,
revocation_set))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("SET service crashed, terminating revocation service\n"));
+ GNUNET_break (0);
GNUNET_SCHEDULER_shutdown ();
return;
}
"adding element of type %u to set %p\n",
(unsigned int) element->element_type,
set);
+ GNUNET_assert (NULL != set);
if (GNUNET_YES == set->invalid)
{
if (NULL != cont)
/* destroying set while iterator is active is currently
not supported; we should expand the API to allow
clients to explicitly cancel the iteration! */
+ GNUNET_assert (NULL != set);
if ( (NULL != set->ops_head) ||
(NULL != set->iterator) ||
(GNUNET_SYSERR == set->destroy_requested) )
{
if (NULL != oh->set)
{
- /* Some other set was already commited for this
+ /* Some other set was already committed for this
* operation, there is a logic bug in the client of this API */
GNUNET_break (0);
return GNUNET_OK;
}
+ GNUNET_assert (NULL != set);
if (GNUNET_YES == set->invalid)
return GNUNET_SYSERR;
LOG (GNUNET_ERROR_TYPE_DEBUG,
char *fname;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (c, "PATHS",
+ GNUNET_CONFIGURATION_get_value_filename (c,
+ "PATHS",
"GNUNET_HOME",
&shome))
{
GNUNET_free (fname);
return;
}
+ GNUNET_free (fname);
GNUNET_asprintf (&fname,
"%s/blacklist",
shome);
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
+ (void) bandwidth_in;
+ (void) bandwidth_out;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n",
GNUNET_i2s (peer),
{
struct NeighbourMapEntry *n;
+ (void) cls;
+ (void) result;
+ (void) payload;
+ (void) physical;
n = lookup_neighbour (target);
if (NULL == n)
return; /* already gone */
*
* @param n neighbour entry to change qutoa for
* @param quota new quota
+ * @return #GNUNET_YES if @a n is still valid, @GNUNET_NO if
+ * @a n was freed
*/
-static void
+static int
set_incoming_quota (struct NeighbourMapEntry *n,
struct GNUNET_BANDWIDTH_Value32NBO quota)
{
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_NO,
NULL, NULL);
- return;
+ return GNUNET_YES;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Disconnecting peer `%s' due to SET_QUOTA\n",
gettext_noop ("# disconnects due to quota of 0"),
1, GNUNET_NO);
disconnect_neighbour (n);
+ return GNUNET_NO;
}
if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
{
n->primary_address.bandwidth_in = bandwidth_in;
- set_incoming_quota (n,
- bandwidth_in);
+ if (GNUNET_YES !=
+ set_incoming_quota (n,
+ bandwidth_in))
+ return;
}
if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
{
/* subsystems about address use */
GST_validation_set_address_use (n->primary_address.address,
GNUNET_YES);
- set_incoming_quota (n,
- bandwidth_in);
+ if (GNUNET_YES !=
+ set_incoming_quota (n,
+ bandwidth_in))
+ return;
send_outbound_quota_to_clients (n);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Neighbour `%s' switched to address `%s'\n",
{
struct NeighbourMapEntry *n;
+ (void) cls;
+ (void) size_payload;
+ (void) size_on_wire;
n = lookup_neighbour (target);
if (NULL == n)
{
{
struct NeighbourMapEntry *n;
+ (void) cls;
+ (void) size_payload;
+ (void) size_on_wire;
n = lookup_neighbour (target);
if (NULL == n)
{
if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
{
n->primary_address.bandwidth_in = bandwidth_in;
- set_incoming_quota (n,
- bandwidth_in);
+ if (GNUNET_YES !=
+ set_incoming_quota (n,
+ bandwidth_in))
+ return GNUNET_NO;
}
if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
{
uint32_t bps_out;
struct GNUNET_TIME_Relative delta;
+ (void) cls;
if ( (GNUNET_YES != test_connected (n)) ||
(NULL == n->primary_address.address) )
return GNUNET_OK;
/**
* Task transmitting utilization in a regular interval
*
- * @param cls the 'struct NeighbourMapEntry' for which we are running
+ * @param cls the `struct NeighbourMapEntry` for which we are running
*/
static void
utilization_transmission (void *cls)
{
+ (void) cls;
util_transmission_tk = NULL;
GNUNET_CONTAINER_multipeermap_iterate (neighbours,
&send_utilization_data,
struct GNUNET_TIME_Absolute ts;
struct NeighbourMapEntry *n;
+ (void) session;
if (ntohs (message->size) != sizeof (struct TransportSynMessage))
{
GNUNET_break_op (0);
{
struct NeighbourMapEntry *n;
+ (void) session;
if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
+ (void) key;
if (NULL != n->primary_address.address)
{
bandwidth_in = n->primary_address.bandwidth_in;
void
GST_neighbours_start (unsigned int max_fds)
{
+ (void) max_fds;
neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE,
GNUNET_NO);
util_transmission_tk = GNUNET_SCHEDULER_add_delayed (UTIL_TRANSMISSION_INTERVAL,
{
struct NeighbourMapEntry *n = value;
+ (void) cls;
+ (void) key;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting peer `%4s' during shutdown\n",
GNUNET_i2s (&n->id));
sizeof(struct GNUNET_PeerIdentity)))
{
/* refuse connections from ourselves */
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
if (GNUNET_OK ==
GNUNET_SERVER_client_get_address (client,
&vaddr,
GNUNET_a2s (vaddr, alen));
GNUNET_free (vaddr);
}
+ GNUNET_SERVER_receive_done (client,
+ GNUNET_SYSERR);
return;
}
if (NULL == session)
{
/* No inbound session found */
- void *vaddr;
+ void *vaddr = NULL;
size_t alen;
GNUNET_SERVER_client_get_address (client,
if (GNUNET_YES == session->expecting_welcome)
{
/* Session is expecting WELCOME message */
- void *vaddr;
+ void *vaddr = NULL;
size_t alen;
GNUNET_SERVER_client_get_address (client,
session->last_activity = GNUNET_TIME_absolute_get ();
{
- void *vaddr;
+ void *vaddr = NULL;
size_t alen;
GNUNET_SERVER_client_get_address (client,
if (GNUNET_YES == session->in_destroy)
{
GNUNET_break (0);
+ GNUNET_free (udpw);
return;
}
if (plugin->bytes_in_buffer > INT64_MAX - udpw->msg_size)
udpw->qc = &qc_fragment_sent;
udpw->qc_cls = plugin;
GNUNET_memcpy (udpw->msg_buf,
- msg,
- msg_len);
+ msg,
+ msg_len);
enqueue (plugin,
udpw);
if (session->address->address_length == sizeof (struct IPv4UdpAddress))
unsigned long long port;
unsigned long long aport;
unsigned long long udp_max_bps;
- unsigned long long enable_v6;
- unsigned long long enable_broadcasting;
- unsigned long long enable_broadcasting_recv;
+ int enable_v6;
+ int enable_broadcasting;
+ int enable_broadcasting_recv;
char *bind4_address;
char *bind6_address;
struct GNUNET_TIME_Relative interval;
* @param timeout maximum amount of time to wait
* @param receiver function to call with received data
* @param receiver_cls closure for @a receiver
+ * @return #GNUNET_SYSERR if @a connection died (receiver was
+ * called with error)
*/
-void
+int
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
size_t max,
struct GNUNET_TIME_Relative timeout,
connection->sock,
&receive_ready,
connection);
- return;
+ return GNUNET_OK;
}
if ((NULL == connection->dns_active) &&
(NULL == connection->ap_head) &&
NULL, 0,
NULL, 0,
ETIMEDOUT);
- return;
+ return GNUNET_SYSERR;
}
+ return GNUNET_OK;
}
"Server re-enters receive loop, timeout: %s.\n",
GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES));
client->receive_pending = GNUNET_YES;
- GNUNET_CONNECTION_receive (client->connection,
- GNUNET_MAX_MESSAGE_SIZE - 1,
- client->idle_timeout,
- &process_incoming,
- client);
+ if (GNUNET_OK !=
+ GNUNET_CONNECTION_receive (client->connection,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
+ client->idle_timeout,
+ &process_incoming,
+ client))
+ return;
break;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
for (n = server->connect_notify_list_head; NULL != n; n = n->next)
n->callback (n->callback_cls, client);
client->receive_pending = GNUNET_YES;
- GNUNET_CONNECTION_receive (client->connection,
- GNUNET_MAX_MESSAGE_SIZE - 1,
- client->idle_timeout,
- &process_incoming,
- client);
+ if (GNUNET_SYSERR ==
+ GNUNET_CONNECTION_receive (client->connection,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
+ client->idle_timeout,
+ &process_incoming,
+ client))
+ return NULL;
return client;
}
}
else
{
- strftime (date2,
- DATE_STR_SIZE,
- "%b %d %H:%M:%S-%%020llu",
- tmptr);
- snprintf (date,
- sizeof (date),
- date2,
- (long long) (pc.QuadPart /
- (performance_frequency.QuadPart / 1000)));
+ if (0 ==
+ strftime (date2,
+ DATE_STR_SIZE,
+ "%b %d %H:%M:%S-%%020llu",
+ tmptr))
+ abort ();
+ if (0 >
+ snprintf (date,
+ sizeof (date),
+ date2,
+ (long long) (pc.QuadPart /
+ (performance_frequency.QuadPart / 1000))))
+ abort ();
}
#else
struct timeval timeofday;
- gettimeofday (&timeofday, NULL);
+ gettimeofday (&timeofday,
+ NULL);
offset = GNUNET_TIME_get_offset ();
if (offset > 0)
{
}
else
{
- strftime (date2,
- DATE_STR_SIZE,
- "%b %d %H:%M:%S-%%06u",
- tmptr);
- snprintf (date,
- sizeof (date),
- date2,
- timeofday.tv_usec);
+ if (0 ==
+ strftime (date2,
+ DATE_STR_SIZE,
+ "%b %d %H:%M:%S-%%06u",
+ tmptr))
+ abort ();
+ if (0 >
+ snprintf (date,
+ sizeof (date),
+ date2,
+ timeofday.tv_usec))
+ abort ();
}
#endif
- VSNPRINTF (buf, size, message, va);
+ VSNPRINTF (buf,
+ size,
+ message,
+ va);
#if ! (defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY)
if (NULL != tmptr)
(void) setup_log_file (tmptr);
#endif
if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
(0 != last_bulk_time.abs_value_us) &&
- (0 == strncmp (buf, last_bulk, sizeof (last_bulk))))
+ (0 == strncmp (buf,
+ last_bulk,
+ sizeof (last_bulk))))
{
last_bulk_repeat++;
if ( (GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value_us >
* @param value value of the option
*/
static void
-print_option (void *cls, const char *section,
+print_option (void *cls,
+ const char *section,
const char *option,
const char *value)
{
+ (void) cls;
+ (void) section;
fprintf (stdout,
- "%s = %s\n", option, value);
+ "%s = %s\n",
+ option,
+ value);
}
print_section_name (void *cls,
const char *section)
{
- fprintf (stdout, "%s\n", section);
+ (void) cls;
+ fprintf (stdout,
+ "%s\n",
+ section);
}
struct GNUNET_CONFIGURATION_Handle *out = NULL;
struct GNUNET_CONFIGURATION_Handle *diff = NULL;
+ (void) cls;
+ (void) args;
if (rewrite)
{
struct GNUNET_CONFIGURATION_Handle *def;
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('f',
- "filename",
- gettext_noop ("obtain option of value as a filename (with $-expansion)"),
- &is_filename),
+ "filename",
+ gettext_noop ("obtain option of value as a filename (with $-expansion)"),
+ &is_filename),
GNUNET_GETOPT_option_string ('s',
- "section",
- "SECTION",
- gettext_noop ("name of the section to access"),
- §ion),
+ "section",
+ "SECTION",
+ gettext_noop ("name of the section to access"),
+ §ion),
GNUNET_GETOPT_option_string ('o',
- "option",
- "OPTION",
- gettext_noop ("name of the option to access"),
- &option),
+ "option",
+ "OPTION",
+ gettext_noop ("name of the option to access"),
+ &option),
GNUNET_GETOPT_option_string ('V',
- "value",
- "VALUE",
- gettext_noop ("value to set"),
- &value),
+ "value",
+ "VALUE",
+ gettext_noop ("value to set"),
+ &value),
GNUNET_GETOPT_option_flag ('S',
- "list-sections",
- gettext_noop ("print available configuration sections"),
- &list_sections),
+ "list-sections",
+ gettext_noop ("print available configuration sections"),
+ &list_sections),
GNUNET_GETOPT_option_flag ('w',
- "rewrite",
- gettext_noop ("write configuration file that only contains delta to defaults"),
- &rewrite),
+ "rewrite",
+ gettext_noop ("write configuration file that only contains delta to defaults"),
+ &rewrite),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK !=
uint64_t fs;
unsigned int total_hostkeys;
unsigned int c;
+ ssize_t sret;
- if (GNUNET_YES != GNUNET_DISK_file_test (filename))
+ if (GNUNET_YES !=
+ GNUNET_DISK_file_test (filename))
{
fprintf (stderr,
_("Hostkeys file `%s' not found\n"),
}
/* Check hostkey file size, read entire thing into memory */
- if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (filename,
+ &fs,
+ GNUNET_YES,
+ GNUNET_YES))
fs = 0;
if (0 == fs)
{
filename);
return;
}
- fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_NONE);
+ fd = GNUNET_DISK_file_open (filename,
+ GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
if (NULL == fd)
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "open",
+ filename);
return;
}
hostkeys_data = GNUNET_malloc (fs);
- if (fs != GNUNET_DISK_file_read (fd, hostkeys_data, fs))
+ sret = GNUNET_DISK_file_read (fd,
+ hostkeys_data,
+ fs);
+ if ( (sret < 0) ||
+ (fs != (size_t) sret) )
{
fprintf (stderr,
_("Could not read hostkey file: %s\n"),
/**
* Main function that will be run by the scheduler.
*
- * @param cls closure
+ * @param cls closure, NULL
* @param args remaining command-line arguments
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param cfg configuration
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ (void) cls;
+ (void) cfgfile;
+ (void) cfg;
+
if (print_examples_flag)
{
print_examples ();
print_hostname (void *cls,
const char *hostname)
{
+ (void) cls;
if (NULL == hostname)
return;
- FPRINTF (stdout, "%s\n", hostname);
+ FPRINTF (stdout,
+ "%s\n",
+ hostname);
}
* @param addrlen length of the address
*/
static void
-print_sockaddr (void *cls, const struct sockaddr *addr, socklen_t addrlen)
+print_sockaddr (void *cls,
+ const struct sockaddr *addr,
+ socklen_t addrlen)
{
+ (void) cls;
if (NULL == addr)
return;
- FPRINTF (stdout, "%s\n", GNUNET_a2s (addr, addrlen));
+ FPRINTF (stdout,
+ "%s\n",
+ GNUNET_a2s (addr,
+ addrlen));
}
* @param cfg configuration
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
const struct sockaddr *sa;
struct sockaddr_in v4;
struct sockaddr_in6 v6;
- if (args[0] == NULL)
+ (void) cls;
+ (void) cfgfile;
+ (void) cfg;
+ if (NULL == args[0])
return;
if (! reverse)
{
- GNUNET_RESOLVER_ip_get (args[0], AF_UNSPEC, GET_TIMEOUT, &print_sockaddr, NULL);
+ GNUNET_RESOLVER_ip_get (args[0],
+ AF_UNSPEC,
+ GET_TIMEOUT,
+ &print_sockaddr,
+ NULL);
return;
}
/**
* Verify well-formedness of GET-message.
*
- * @param cls closure
+ * @param cls closure, unused
* @param get the actual message
* @return #GNUNET_OK if @a get is well-formed
*/
int direction;
int af;
+ (void) cls;
size = ntohs (get->header.size) - sizeof (*get);
direction = ntohl (get->direction);
if (GNUNET_NO == direction)
/**
* Callback called when a client connects to the service.
*
- * @param cls closure for the service
+ * @param cls closure for the service, unused
* @param c the new client that connected to the service
* @param mq the message queue used to send messages to the client
* @return @a c
struct GNUNET_SERVICE_Client *c,
struct GNUNET_MQ_Handle *mq)
{
+ (void) cls;
+ (void) mq;
+
return c;
}
struct GNUNET_SERVICE_Client *c,
void *internal_cls)
{
+ (void) cls;
+
GNUNET_assert (c == internal_cls);
}
#else
int fd;
- GNUNET_DISK_internal_file_handle_ (h,
- &fd,
- sizeof (int));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_DISK_internal_file_handle_ (h,
+ &fd,
+ sizeof (int)));
FD_SET (fd,
&fds->sds);
fds->nsds = GNUNET_MAX (fd + 1,
open_port_str,
&hint,
&ret));
+ bind_status = GNUNET_NO;
for (ai = ret; NULL != ai; ai = ai->ai_next)
{
socket = GNUNET_NETWORK_socket_create (ai->ai_family,
/*
This file is part of GNUnet.
- Copyright (C) 2006-2016 GNUnet e.V.
+ Copyright (C) 2006-2018 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
ssize_t size;
char *lep;
- GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ());
- size = readlink (fn, lnk, sizeof (lnk) - 1);
+ GNUNET_snprintf (fn,
+ sizeof (fn),
+ "/proc/%u/exe",
+ getpid ());
+ size = readlink (fn,
+ lnk,
+ sizeof (lnk) - 1);
if (size <= 0)
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+ "readlink",
+ fn);
return NULL;
}
- GNUNET_assert (size < sizeof (lnk));
+ GNUNET_assert ( ((size_t) size) < sizeof (lnk));
lnk[size] = '\0';
while ((lnk[size] != '/') && (size > 0))
size--;
"/%s/libexec/",
current_pd->project_dirname);
/* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
- if ( (size > strlen (lep)) &&
+ if ( (((size_t) size) > strlen (lep)) &&
(0 == strcmp (lep,
&lnk[size - strlen (lep)])) )
size -= strlen (lep) - 1;
GNUNET_free (lep);
- if ((size < 4) || (lnk[size - 4] != '/'))
+ if ( (size < 4) ||
+ (lnk[size - 4] != '/') )
{
/* not installed in "/bin/" -- binary path probably useless */
return NULL;
if (check_suid)
{
#ifndef MINGW
+ (void) params;
if ( (0 != (statbuf.st_mode & S_ISUID)) &&
(0 == statbuf.st_uid) )
{
struct GNUNET_DISK_FileHandle *control_pipe;
uint64_t pipe_fd;
+ (void) cls;
if (NULL != pch)
{
/* already done, we've been called twice... */
return;
GNUNET_assert (id < size);
GNUNET_assert (table[id]->rc > 0);
- GNUNET_assert ((delta >= 0) || (table[id]->rc >= -delta));
+ GNUNET_assert ( (delta >= 0) ||
+ (table[id]->rc >= (unsigned int) (-delta)) );
table[id]->rc += delta;
if (0 == table[id]->rc)
{
static void
shutdown_task (void *cls)
{
+ (void) cls;
GNUNET_SPEEDUP_stop_ ();
}
/*
This file is part of GNUnet.
- Copyright (C) 2009-2016 GNUnet e.V.
+ Copyright (C) 2009-2018 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
for (unsigned int i = 0;
NULL != loopback[i];
i++)
- if (0 == strcasecmp (loopback[i], hostname))
+ if (0 == strcasecmp (loopback[i],
+ hostname))
{
GNUNET_free (hostname);
return GNUNET_OK;
static void
shutdown_task (void *cls)
{
+ (void) cls;
s_task = NULL;
GNUNET_RESOLVER_disconnect ();
backoff = GNUNET_TIME_UNIT_MILLISECONDS;
mq_error_handler (void *cls,
enum GNUNET_MQ_Error error)
{
+ (void) cls;
GNUNET_MQ_destroy (mq);
mq = NULL;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "MQ error, reconnecting\n");
+ "MQ error %d, reconnecting\n",
+ error);
reconnect ();
}
check_response (void *cls,
const struct GNUNET_MessageHeader *msg)
{
+ (void) cls;
+ (void) msg;
+
/* implemented in #handle_response() for now */
return GNUNET_OK;
}
uint16_t size;
char *nret;
+ (void) cls;
GNUNET_assert (NULL != rh);
size = ntohs (msg->size);
if (size == sizeof (struct GNUNET_MessageHeader))
GNUNET_MQ_handler_end ()
};
+ (void) cls;
r_task = NULL;
if (NULL == req_head)
return; /* no work pending */
t->fds = fdi;
if (1 == read_nh_len)
{
+ GNUNET_assert (NULL != read_nh);
fdi->fd = *read_nh;
- GNUNET_assert (NULL != fdi->fd);
fdi->et = GNUNET_SCHEDULER_ET_IN;
fdi->sock = GNUNET_NETWORK_get_fd (*read_nh);
t->read_fd = fdi->sock;
}
else if (1 == write_nh_len)
{
+ GNUNET_assert (NULL != write_nh);
fdi->fd = *write_nh;
- GNUNET_assert (NULL != fdi->fd);
fdi->et = GNUNET_SCHEDULER_ET_OUT;
fdi->sock = GNUNET_NETWORK_get_fd (*write_nh);
t->read_fd = -1;
}
else if (1 == read_fh_len)
{
+ GNUNET_assert (NULL != read_fh);
fdi->fh = *read_fh;
- GNUNET_assert (NULL != fdi->fh);
fdi->et = GNUNET_SCHEDULER_ET_IN;
fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32
t->read_fd = fdi->sock;
}
else
{
+ GNUNET_assert (NULL != write_fh);
fdi->fh = *write_fh;
- GNUNET_assert (NULL != fdi->fh);
fdi->et = GNUNET_SCHEDULER_ET_OUT;
fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32
t->read_fd = -1;
* @param et the event type to be set in each FdInfo after calling
* @a driver_func on it, or -1 if no updating not desired.
*/
-void driver_add_multiple (struct GNUNET_SCHEDULER_Task *t,
- enum GNUNET_SCHEDULER_EventType et)
+static void
+driver_add_multiple (struct GNUNET_SCHEDULER_Task *t)
{
struct GNUNET_SCHEDULER_FdInfo *fdi;
int success = GNUNET_YES;
- for (int i = 0; i != t->fds_len; ++i)
+ for (unsigned int i = 0; i != t->fds_len; ++i)
{
fdi = &t->fds[i];
- success = scheduler_driver->add (scheduler_driver->cls, t, fdi) && success;
- if (et != -1)
- {
- fdi->et = et;
- }
+ success = scheduler_driver->add (scheduler_driver->cls,
+ t,
+ fdi) && success;
+ fdi->et = GNUNET_SCHEDULER_ET_NONE;
}
if (GNUNET_YES != success)
{
}
-void
+static void
shutdown_cb (void *cls)
{
char c;
const struct GNUNET_DISK_FileHandle *pr;
+ (void) cls;
pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle,
GNUNET_DISK_PIPE_END_READ);
GNUNET_assert (! GNUNET_DISK_handle_invalid (pr));
backtrace_symbols (backtrace_array,
t->num_backtrace_strings);
dump_backtrace (t);
+#else
+ (void) t;
#endif
}
GNUNET_CONTAINER_DLL_insert (pending_head,
pending_tail,
t);
- driver_add_multiple (t, GNUNET_SCHEDULER_ET_NONE);
+ driver_add_multiple (t);
max_priority_added = GNUNET_MAX (max_priority_added,
t->priority);
init_backtrace (t);
// in fdset must be handled separately
const struct GNUNET_NETWORK_Handle **nhandles;
const struct GNUNET_DISK_FileHandle **fhandles;
- unsigned int nhandles_len, fhandles_len;
- int sock;
+ unsigned int nhandles_len;
+ unsigned int fhandles_len;
+ (void) t;
nhandles = NULL;
fhandles = NULL;
nhandles_len = 0;
fhandles_len = 0;
- for (sock = 0; sock != fdset->nsds; ++sock)
+ for (int sock = 0; sock != fdset->nsds; ++sock)
{
if (GNUNET_YES == GNUNET_NETWORK_fdset_test_native (fdset, sock))
{
const struct GNUNET_DISK_FileHandle **write_fhandles;
unsigned int read_nhandles_len, write_nhandles_len,
read_fhandles_len, write_fhandles_len;
+ int no_fdsets = (NULL == rs) && (NULL == ws);
+ int no_socket_descriptors =
+ ((NULL != rs) && (0 == rs->nsds)) && ((NULL != ws) && (0 == ws->nsds));
- if (((NULL == rs) && (NULL == ws)) || ((0 == rs->nsds) && (0 == ws->nsds)))
+ if (no_fdsets || no_socket_descriptors)
return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
prio,
task,
GNUNET_CONTAINER_DLL_insert (pending_head,
pending_tail,
t);
- driver_add_multiple (t, GNUNET_SCHEDULER_ET_NONE);
+ driver_add_multiple (t);
max_priority_added = GNUNET_MAX (max_priority_added,
t->priority);
LOG (GNUNET_ERROR_TYPE_DEBUG,
// FIXME: do we have to remove FdInfos from fds if they are not ready?
tc.fds_len = pos->fds_len;
tc.fds = pos->fds;
- for (int i = 0; i != pos->fds_len; ++i)
+ for (unsigned int i = 0; i != pos->fds_len; ++i)
{
struct GNUNET_SCHEDULER_FdInfo *fdi = &pos->fds[i];
if (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et))
GNUNET_MQ_impl_send_in_flight (client->mq);
}
client->msg_pos += ret;
- if (left > ret)
+ if (left > (size_t) ret)
{
GNUNET_assert (NULL == client->drop_task);
client->send_task
{
struct GNUNET_SERVICE_Client *client = impl_state;
+ (void) mq;
if (NULL != client->drop_task)
return; /* we're going down right now, do not try to send */
GNUNET_assert (NULL == client->send_task);
{
struct GNUNET_SERVICE_Client *client = impl_state;
+ (void) mq;
GNUNET_assert (0 == client->msg_pos);
client->msg = NULL;
GNUNET_SCHEDULER_cancel (client->send_task);
{
static long long current_offset;
+ (void) cls;
speedup_task = NULL;
current_offset += delta.rel_value_us;
GNUNET_TIME_set_offset (current_offset);
* (if they weren't NULL).
*/
int
-GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part,
- const char **path_part)
+GNUNET_STRINGS_parse_uri (const char *path,
+ char **scheme_part,
+ const char **path_part)
{
size_t len;
- int i, end;
+ size_t i;
+ int end;
int pp_state = 0;
const char *post_scheme_part = NULL;
len = strlen (path);
switch (pp_state)
{
case 0:
- if (path[i] == ':' && i > 0)
+ if ( (path[i] == ':') && (i > 0) )
{
pp_state += 1;
continue;