summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2019-06-25 15:53:30 +0200
committert3sserakt <t3ss@posteo.de>2019-06-25 15:53:30 +0200
commit28d3e0676f262e495c6d5c49bbedd5ce65502cee (patch)
tree3631b2f033a913aac3cd806e541e3391f0cec7e5
parentd2ed51b63d955a590a461e911a3d6fa6a9248fe5 (diff)
parent17611641fe7da3d2711e1f20eaf2ee81faf0e702 (diff)
Merge branch 'master' into cadet_option
-rw-r--r--doc/handbook/chapters/developer.texi338
-rw-r--r--doc/handbook/chapters/installation.texi15
-rw-r--r--doc/handbook/chapters/keyconcepts.texi1
-rw-r--r--doc/handbook/chapters/user.texi273
-rw-r--r--doc/handbook/images/ascension_interaction.pngbin0 -> 1992878 bytes
-rw-r--r--doc/handbook/images/ascension_ssd.pngbin0 -> 69446 bytes
-rw-r--r--doc/man/gnunet-config.13
-rw-r--r--src/arm/arm_api.c287
-rw-r--r--src/arm/arm_monitor_api.c55
-rw-r--r--src/arm/gnunet-arm.c21
-rw-r--r--src/arm/mockup-service.c49
-rw-r--r--src/cadet/cadet.h53
-rw-r--r--src/cadet/cadet_api.c285
-rw-r--r--src/cadet/gnunet-service-cadet.c1
-rw-r--r--src/core/core_api.c5
-rw-r--r--src/core/core_api_monitor_peers.c34
-rw-r--r--src/core/gnunet-core.c80
-rw-r--r--src/gns/Makefile.am2
-rw-r--r--src/gns/gnunet-gns-proxy-ca.template303
-rw-r--r--src/gns/gnunet-gns-proxy-setup-ca.in45
-rw-r--r--src/include/gnunet_getopt_lib.h65
-rw-r--r--src/namestore/gnunet-namestore.c18
-rw-r--r--src/namestore/gnunet-service-namestore.c67
-rw-r--r--src/nse/gnunet-nse.c38
-rw-r--r--src/nse/gnunet-service-nse.c21
-rw-r--r--src/nse/nse_api.c43
-rw-r--r--src/util/crypto_random.c84
-rw-r--r--src/util/getopt.c192
-rw-r--r--src/util/getopt_helpers.c440
-rw-r--r--src/util/gnunet-config.c195
-rw-r--r--src/util/gnunet-scrypt.c213
-rw-r--r--src/util/gnunet-uri.c84
-rw-r--r--src/util/test_common_logging_dummy.c59
-rw-r--r--src/util/tun.c163
34 files changed, 1850 insertions, 1682 deletions
diff --git a/doc/handbook/chapters/developer.texi b/doc/handbook/chapters/developer.texi
index 228603cda..830a345a8 100644
--- a/doc/handbook/chapters/developer.texi
+++ b/doc/handbook/chapters/developer.texi
@@ -79,6 +79,7 @@ new chapters, sections or insightful comments.
* File-sharing (FS) Subsystem::
* REGEX Subsystem::
* REST Subsystem::
+* RPS Subsystem::
@end menu
@node Developer Introduction
@@ -556,7 +557,7 @@ stacked together to construct complex buildings and it is generally easy
to swap one block for a different one that has the same shape. GNUnet's
architecture is based on LEGOs:
-@c @image{images/service_lego_block,5in,,picture of a LEGO block stack - 3 APIs as connectors upon Network Protocol on top of a Service}
+@image{images/service_lego_block,5in,,picture of a LEGO block stack - 3 APIs upon IPC/network protocol provided by a service}
This chapter documents the GNUnet LEGO system, also known as GNUnet's
system architecture.
@@ -573,10 +574,14 @@ Like services, they have holes to be filled by APIs of other services.
Unlike services, daemons do not implement their own network protocol and
they have no API:
+@image{images/daemon_lego_block,5in,,A daemon in GNUnet is a component that does not offer an API for others to build upon}
+
The GNUnet system provides a range of services, daemons and user
interfaces, which are then combined into a layered GNUnet instance (also
known as a peer).
+@image{images/service_stack,5in,,A GNUnet peer consists of many layers of services}
+
Note that while it is generally possible to swap one service for another
compatible service, there is often only one implementation. However,
during development we often have a "new" version of a service in parallel
@@ -1876,7 +1881,6 @@ Testbed API can accessed by including the
* Hosts file format::
* Topology file format::
* Testbed Barriers::
-* Automatic large-scale deployment in the PlanetLab testbed::
* TESTBED Caveats::
@end menu
@@ -2140,168 +2144,6 @@ message from its upward propagation --- the upward propagation is needed
for ensuring that the barrier is reached by all the controllers and the
downward propagation is for triggering that the barrier is crossed.
-@cindex PlanetLab testbed
-@node Automatic large-scale deployment in the PlanetLab testbed
-@subsection Automatic large-scale deployment in the PlanetLab testbed
-
-PlanetLab is a testbed for computer networking and distributed systems
-research. It was established in 2002 and as of June 2010 was composed of
-1090 nodes at 507 sites worldwide.
-
-To automate the GNUnet we created a set of automation tools to simplify
-the large-scale deployment. We provide you a set of scripts you can use
-to deploy GNUnet on a set of nodes and manage your installation.
-
-Please also check @uref{https://old.gnunet.org/installation-fedora8-svn} and
-@uref{https://old.gnunet.org/installation-fedora12-svn} to find detailed
-instructions how to install GNUnet on a PlanetLab node.
-
-
-@c ***********************************************************************
-@menu
-* PlanetLab Automation for Fedora8 nodes::
-* Install buildslave on PlanetLab nodes running fedora core 8::
-* Setup a new PlanetLab testbed using GPLMT::
-* Why do i get an ssh error when using the regex profiler?::
-@end menu
-
-@node PlanetLab Automation for Fedora8 nodes
-@subsubsection PlanetLab Automation for Fedora8 nodes
-
-@c ***********************************************************************
-@node Install buildslave on PlanetLab nodes running fedora core 8
-@subsubsection Install buildslave on PlanetLab nodes running fedora core 8
-@c ** Actually this is a subsubsubsection, but must be fixed differently
-@c ** as subsubsection is the lowest.
-
-Since most of the PlanetLab nodes are running the very old Fedora core 8
-image, installing the buildslave software is quite some pain. For our
-PlanetLab testbed we figured out how to install the buildslave software
-best.
-
-@c This is a very terrible way to suggest installing software.
-@c FIXME: Is there an official, safer way instead of blind-piping a
-@c script?
-@c FIXME: Use newer pypi URLs below.
-Install Distribute for Python:
-
-@example
-curl http://python-distribute.org/distribute_setup.py | sudo python
-@end example
-
-Install Distribute for zope.interface <= 3.8.0 (4.0 and 4.0.1 will not
-work):
-
-@example
-export PYPI=@value{PYPI-URL}
-wget $PYPI/z/zope.interface/zope.interface-3.8.0.tar.gz
-tar xzvf zope.interface-3.8.0.tar.gz
-cd zope.interface-3.8.0
-sudo python setup.py install
-@end example
-
-Install the buildslave software (0.8.6 was the latest version):
-
-@example
-export GCODE="http://buildbot.googlecode.com/files"
-wget $GCODE/buildbot-slave-0.8.6p1.tar.gz
-tar xvfz buildbot-slave-0.8.6p1.tar.gz
-cd buildslave-0.8.6p1
-sudo python setup.py install
-@end example
-
-The setup will download the matching twisted package and install it.
-It will also try to install the latest version of zope.interface which
-will fail to install. Buildslave will work anyway since version 3.8.0
-was installed before!
-
-@c ***********************************************************************
-@node Setup a new PlanetLab testbed using GPLMT
-@subsubsection Setup a new PlanetLab testbed using GPLMT
-
-@itemize @bullet
-@item Get a new slice and assign nodes
-Ask your PlanetLab PI to give you a new slice and assign the nodes you
-need
-@item Install a buildmaster
-You can stick to the buildbot documentation:@
-@uref{http://buildbot.net/buildbot/docs/current/manual/installation.html}
-@item Install the buildslave software on all nodes
-To install the buildslave on all nodes assigned to your slice you can use
-the tasklist @code{install_buildslave_fc8.xml} provided with GPLMT:
-
-@example
-./gplmt.py -c contrib/tumple_gnunet.conf -t \
-contrib/tasklists/install_buildslave_fc8.xml -a -p <planetlab password>
-@end example
-
-@item Create the buildmaster configuration and the slave setup commands
-
-The master and the and the slaves have need to have credentials and the
-master has to have all nodes configured. This can be done with the
-@file{create_buildbot_configuration.py} script in the @file{scripts}
-directory.
-
-This scripts takes a list of nodes retrieved directly from PlanetLab or
-read from a file and a configuration template and creates:
-
-@itemize @bullet
-@item a tasklist which can be executed with gplmt to setup the slaves
-@item a master.cfg file containing a PlanetLab nodes
-@end itemize
-
-A configuration template is included in the <contrib>, most important is
-that the script replaces the following tags in the template:
-
-%GPLMT_BUILDER_DEFINITION :@ GPLMT_BUILDER_SUMMARY@ GPLMT_SLAVES@
-%GPLMT_SCHEDULER_BUILDERS
-
-Create configuration for all nodes assigned to a slice:
-
-@example
-./create_buildbot_configuration.py -u <planetlab username> \
--p <planetlab password> -s <slice> -m <buildmaster+port> \
--t <template>
-@end example
-
-Create configuration for some nodes in a file:
-
-@example
-./create_buildbot_configuration.p -f <node_file> \
--m <buildmaster+port> -t <template>
-@end example
-
-@item Copy the @file{master.cfg} to the buildmaster and start it
-Use @code{buildbot start <basedir>} to start the server
-@item Setup the buildslaves
-@end itemize
-
-@c ***********************************************************************
-@node Why do i get an ssh error when using the regex profiler?
-@subsubsection Why do i get an ssh error when using the regex profiler?
-
-Why do i get an ssh error "Permission denied (publickey,password)." when
-using the regex profiler although passwordless ssh to localhost works
-using publickey and ssh-agent?
-
-You have to generate a public/private-key pair with no password:@
-@code{ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_localhost}@
-and then add the following to your ~/.ssh/config file:
-
-@code{Host 127.0.0.1@ IdentityFile ~/.ssh/id_localhost}
-
-now make sure your hostsfile looks like
-
-@example
-[USERNAME]@@127.0.0.1:22@
-[USERNAME]@@127.0.0.1:22
-@end example
-
-You can test your setup by running @code{ssh 127.0.0.1} in a
-terminal and then in the opened session run it again.
-If you were not asked for a password on either login,
-then you should be good to go.
-
@cindex TESTBED Caveats
@node TESTBED Caveats
@subsection TESTBED Caveats
@@ -8116,6 +7958,14 @@ This section discusses the challenges and problems faced when writing the
Ascension tool. It also takes a look at possible improvements in the
future.
+Consider the following diagram that shows the workflow of Ascension:
+
+@image{images/ascension_ssd,6in,,Ascensions workflow}
+
+Further the interaction between components of GNUnet are shown in the diagram
+below:
+@center @image{images/ascension_interaction,,6in,Ascensions workflow}
+
@menu
* Conversions between DNS and GNS::
* DNS Zone Size::
@@ -8126,9 +7976,9 @@ future.
@node Conversions between DNS and GNS
@subsubsection Conversions between DNS and GNS
-The differences between the two name systems lies in the details
-and is not always transparent.
-For instance an SRV record is converted to a GNS only BOX record.
+The differences between the two name systems lies in the details and is not
+always transparent. For instance an SRV record is converted to a BOX record
+which is unique to GNS.
This is done by converting to a BOX record from an existing SRV record:
@@ -8141,7 +7991,7 @@ _sip._tcp.example.com. 14000 IN SRV 0 0 5060 www.example.com.
14000 BOX n 5060 6 33 0 0 5060 www.example.com
@end example
-Other records that have such a transformation is the MX record type,
+Other records that need to undergo such transformation is the MX record type,
as well as the SOA record type.
Transformation of a SOA record into GNS works as described in the
@@ -8156,8 +8006,9 @@ following example. Very important to note are the rname and mname keys.
604800 ; expire
600 ) ; ttl
# Recordline for adding the record
-$ gnunet-namestore -z example.com -a -n @ -t SOA -V rname=master.example.com \
- mname=hostmaster.example.com 2017030300,3600,1800,604800,600 -e 7200s
+$ gnunet-namestore -z example.com -a -n @ -t SOA -V \
+ rname=master.example.com mname=hostmaster.example.com \
+ 2017030300,3600,1800,604800,600 -e 7200s
@end example
The transformation of MX records is done in a simple way.
@@ -8166,10 +8017,10 @@ The transformation of MX records is done in a simple way.
$ gnunet-namestore -z example.com -n mail -R 3600 MX n 10,mail
@end example
-Finally, one of the biggest struggling points were the NS records that are found
-in top level domain zones. The intended behaviour for those is to add GNS2DNS
-records for those so that gnunet-gns can resolve records for those domains on
-its own. This requires migration of the DNS GLUE records as well, provided that
+Finally, one of the biggest struggling points were the NS records that are
+found in top level domain zones. The intended behaviour for those is to add
+GNS2DNS records for those so that gnunet-gns can resolve records for those
+domains on its own. Those require the values from DNS GLUE records, provided
they are within the same zone.
The following two examples show one record with a GLUE record and the other one
@@ -8178,10 +8029,12 @@ does not have a GLUE record. This takes place in the 'com' TLD.
@example
# ns1.example.com 86400 IN A 127.0.0.1
# example.com 86400 IN NS ns1.example.com.
-$ gnunet-namestore -z com -n example -R 86400 GNS2DNS n example.com@@127.0.0.1
+$ gnunet-namestore -z com -n example -R 86400 GNS2DNS n \
+ example.com@@127.0.0.1
# example.com 86400 IN NS ns1.example.org.
-$ gnunet-namestore -z com -n example -R 86400 GNS2DNS n example.com@@ns1.example.org
+$ gnunet-namestore -z com -n example -R 86400 GNS2DNS n \
+ example.com@@ns1.example.org
@end example
As you can see, one of the GNS2DNS records has an IP address listed and the
@@ -8204,7 +8057,7 @@ Currently the following record types are supported:
@item TXT
@end itemize
-This is not due to a technical limitation but rather a practical one. The
+This is not due to technical limitations but rather a practical ones. The
problem occurs with DNSSEC enabled DNS zones. As records within those zones are
signed periodically, and every new signature is an update to the zone, there are
many revisions of zones. This results in a problem with bigger zones as there
@@ -8214,16 +8067,22 @@ as they cause a CLI call of the namestore. Furthermore certain record types
need transformation into a GNS compatible format which, depending on the record
type, takes more time.
+Further a blacklist was added to drop for instance DNSSEC related records. Also
+if a record type is neither in the white list nor the blacklist it is considered
+as a loss of data and a message is shown to the user. This helps with
+transparency and also with contributing, as the not supported record types can
+then be added accordingly.
+
@node DNS Zone Size
@subsubsection DNS Zone Size
-
Another very big problem exists with very large zones. When migrating a small
zone the delay between adding of records and their expiry is negligible. However
-when working with a TLD zone that has more that 1 million records this delay
-becomes a problem.
+when working with big zones that easily have more than a few million records
+this delay becomes a problem.
Records will start to expire well before the zone has finished migrating. This
-causes unwanted anomalies when trying to resolve records.
+is usually not a problem but can cause a high CPU load when a peer is restarted
+and the records have expired.
A good solution has not been found yet. One of the idea that floated around was
that the records should be added with the s (shadow) flag to keep the records
@@ -8233,45 +8092,51 @@ of said record(s).
Another problem that still persists is how to refresh records. Expired records
are still displayed when calling gnunet-namestore but do not resolve with
-gnunet-gns. When doing incremental zone transfers this becomes especially
-apparent.
+gnunet-gns. Zonemaster will sign the expired records again and make sure that
+the records are still valid. With a recent change this was fixed as gnunet-gns
+to improve the suffix lookup which allows for a fast lookup even with thousands
+of local egos.
+
+Currently the pace of adding records in general is around 10 records per second.
+Crypto is the upper limit for adding of records. The performance of your machine
+can be tested with the perf_crypto_* tools. There is still a big discrepancy
+between the pace of Ascension and the theoretical limit.
-I estimate that the limit lies at about 200'000 records in a zone as this is
-the limit that my machine is capable of adding within one hour. This was
-calculated by running cProfile on the application with a zone of 5000 records
-and calculating what abouts a much bigger zones with 8 million records would
-take. This results in a nice metric of records migrated per hour.
+A performance metric for measuring improvements has not yet been implemented in
+Ascension.
@node Performance
@subsubsection Performance
The performance when migrating a zone using the Ascension tool is limited by a
handful of factors. First of all ascension is written in Python3 and calls the
-CLI tools of GNUnet. Furthermore all the records that are added to the same
+CLI tools of GNUnet. This is comparable to a fork and exec call which costs a
+few CPU cycles. Furthermore all the records that are added to the same
label are signed using the zones private key. This signing operation is very
resource heavy and was optimized during development by adding the '-R'
-(Recordline) option to gnunet-namestore. This allows to add multiple records
-at once using the CLI.
-
-The result of this was a much faster migration of TLD zones, as most records
-with the same label have two name servers.
+(Recordline) option to gnunet-namestore which allows to specify multiple records
+using the CLI tool. Assuming that in a TLD zone every domain has at least two
+name servers this halves the amount of signatures needed.
Another improvement that could be made is with the addition of multiple threads
-when opening the GNUnet CLI tools. This could be implemented by simply creating
-more workers in the program but performance improvements were not tested.
+or using asynchronous subprocesses when opening the GNUnet CLI tools. This could
+be implemented by simply creating more workers in the program but performance
+improvements were not tested.
-During the entire development of Ascension sqlite was used as a database
-backend for GNUnet. Other backends have not been tested yet.
+Ascension was tested using different hardware and database backends. Performance
+differences between SQLite and postgresql are marginal and almost non existent.
+What did make a huge impact on record adding performance was the storage medium.
+On a traditional mechanical hard drive adding of records were slow compared to a
+solid state disk.
In conclusion there are many bottlenecks still around in the program, namely the
-signing process and the single threaded implementation. In the future a solution
-that uses the C API would be cleaner and better.
+single threaded implementation and inefficient, sequential calls of
+gnunet-namestore. In the future a solution that uses the C API would be cleaner
+and better.
@cindex GNS Namecache
@node GNS Namecache
@section GNS Namecache
-
-
The NAMECACHE subsystem is responsible for caching (encrypted) resolution
results of the GNU Name System (GNS). GNS makes zone information available
to other users via the DHT. However, as accessing the DHT for every
@@ -9007,3 +8872,72 @@ so please make sure that endpoints are unambiguous.
This is WIP. Endpoints should be documented appropriately.
Preferably using annotations.
+
+
+@cindex RPS Subsystem
+@node RPS Subsystem
+@section RPS Subsystem
+
+In literature, Random Peer Sampling (RPS) refers to the problem of
+reliably drawing random samples from an unstructured p2p network.
+
+Doing so in a reliable manner is not only hard because of inherent
+problems but also because of possible malicious peers that could try to
+bias the selection.
+
+It is useful for all kind of gossip protocols that require the selection
+of random peers in the whole network like gathering statistics,
+spreading and aggregating information in the network, load balancing and
+overlay topology management.
+
+The approach chosen in the rps implementation in GNUnet follows the
+Brahms@uref{https://bib.gnunet.org/full/date.html\#2009_5f0} design.
+
+The current state is "work in progress". There are a lot of things that
+need to be done, primarily finishing the experimental evaluation and a
+re-design of the API.
+
+The abstract idea is to subscribe to connect to/start the rps service
+and request random peers that will be returned when they represent a
+random selection from the whole network with high probability.
+
+An additional feature to the original Brahms-design is the selection of
+sub-groups: The GNUnet implementation of rps enables clients to ask for
+random peers from a group that is defined by a common shared secret.
+(The secret could of course also be public, depending on the use-case.)
+
+Another addition to the original protocol was made: The sampler
+mechanism that was introduced in Brahms was slightly adapted and used to
+actually sample the peers and returned to the client.
+This is necessary as the original design only keeps peers connected to
+random other peers in the network. In order to return random peers to
+client requests independently random, they cannot be drawn from the
+connected peers.
+The adapted sampler makes sure that each request for random peers is
+independent from the others.
+
+@node Brahms
+@subsection Brahms
+The high-level concept of Brahms is two-fold: Combining push-pull gossip
+with locally fixing a assumed bias using cryptographic min-wise
+permutations.
+The central data structure is the view - a peer's current local sample.
+This view is used to select peers to push to and pull from.
+This simple mechanism can be biased easily. For this reason Brahms
+'fixes' the bias by using the so-called sampler. A data structure that
+takes a list of elements as input and outputs a random one of them
+independently of the frequency in the input set. Both an element that
+was put into the sampler a single time and an element that was put into
+it a million times have the same probability of being the output.
+This is achieved this is achieved with exploiting min-wise independent
+permutations. In rps we use HMACs: On the initialisation of a sampler
+element, a key is chosen at random. On each input the HMAC with the
+random key is computed. The sampler element keeps the element with the
+minimal HMAC.
+
+In order to fix the bias in the view, a fraction of the elements in the
+view are sampled through the sampler from the random stream of peer IDs.
+
+According to the theoretical analysis of Bortnikov et al. this suffices
+to keep the network connected and having random peers in the view.
+
diff --git a/doc/handbook/chapters/installation.texi b/doc/handbook/chapters/installation.texi
index d02fc7f82..a508feb6a 100644
--- a/doc/handbook/chapters/installation.texi
+++ b/doc/handbook/chapters/installation.texi
@@ -1786,10 +1786,21 @@ Keeping a virtual environment helps with keeping things tidy and prevents
breaking of Ascension through a future Python update.
The advantage of using a virtual environment is, that all the dependencies can
-be installed separately in different versions without touching your system
+be installed separately in different versions without touching your systems
Python installation and its dependencies.
-@xref{Migrating an existing DNS zone into GNS}, for usage manual of the tool.
+Another way to install Ascension on Debian is to install the python3-ascension
+package. It can be found within the above mentioned Ascension git repository.
+This also adds a system user ascension and runs a GNUnet peer in the
+background. Attention: This only works if a recent version of GNUnet is
+installed on your system. The version number of Ascension is chosen according
+to the required feature level of GNUnet. I.e. Ascension 0.11.5 is only
+compatible with GNUnet 0.11.5 and upwards. As Debian's packages for GNUnet are
+outdated even in experimental, you will need to install GNUnet manually.
+@xref{Installing GNUnet}
+
+Please check @xref{Migrating an existing DNS zone into GNS}, for usage manual
+of the tool.
@node Configuring the GNUnet VPN
@subsection Configuring the GNUnet VPN
diff --git a/doc/handbook/chapters/keyconcepts.texi b/doc/handbook/chapters/keyconcepts.texi
index 4900ed328..bdfa5b631 100644
--- a/doc/handbook/chapters/keyconcepts.texi
+++ b/doc/handbook/chapters/keyconcepts.texi
@@ -319,3 +319,4 @@ Egos are your "identities" in GNUnet. Any user can assume multiple
identities, for example to separate their activities online. Egos can
correspond to "pseudonyms" or "real-world identities". Technically an
ego is first of all a key pair of a public- and private-key.
+
diff --git a/doc/handbook/chapters/user.texi b/doc/handbook/chapters/user.texi
index 55518bc34..fcf5e7871 100644
--- a/doc/handbook/chapters/user.texi
+++ b/doc/handbook/chapters/user.texi
@@ -526,7 +526,7 @@ shell) and create an entry home-phone in your master zone.
For the record type, select PHONE. You should then see the
PHONE dialog:
-@c image here
+@image{images/gnunet-namestore-gtk-phone,5in,,Dialog to publish a PHONE record}
Note: Do not choose the expiry time to be 'Never'. If you
do that, you assert that this record will never change and
@@ -645,7 +645,7 @@ Now, using your normal user (not the @code{gnunet} system user), run
master zone. For the record type, select @code{VPN}. You should then
see the VPN dialog:
-@c insert image
+@image{images/gnunet-namestore-gtk-vpn,5in,,Dialog to publish a VPN record}
Under peer, you need to supply the peer identity of your own peer. You can
obtain the respective string by running @command{gnunet-peerinfo -sq}
@@ -926,7 +926,7 @@ concepts that are used to achieve these goals.
* Files::
* Keywords::
* Directories::
-* Pseudonyms::
+* Egos and File-Sharing::
* Namespaces::
* Advertisements::
* Anonymity level::
@@ -984,69 +984,55 @@ typically includes the mime-type, description, a filename and
other meta information, and possibly even the full original file
(if it was small).
-@node Pseudonyms
-@subsubsection Pseudonyms
+@node Egos and File-Sharing
+@subsubsection Egos and File-Sharing
+When sharing files, it is sometimes desirable to build a reputation as
+a source for quality information. With egos, publishers can
+(cryptographically) sign files, thereby demonstrating that various
+files were published by the same entity. An ego thus allows users to
+link different publication events, thereby deliberately reducing
+anonymity to pseudonymity.
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
+Egos used in GNUnet's file-sharing for such pseudonymous publishing
+also correspond to the egos used to identify and sign zones in the
+GNU Name System. However, if the same ego is used for file-sharing
+and for a GNS zone, this will weaken the privacy assurances provided
+by the anonymous file-sharing protocol.
-Pseudonyms in GNUnet are essentially public-private (RSA) key pairs
-that allow a GNUnet user to maintain an identity (which may or may not
-be detached from their real-life identity). GNUnet's pseudonyms are not
-file-sharing specific --- and they will likely be used by many GNUnet
-applications where a user identity is required.
+Note that an ego is NOT bound to a GNUnet peer. There can be multiple
+egos for a single user, and users could (theoretically) share
+the private keys of an ego by copying the respective private keys.
-Note that a pseudonym is NOT bound to a GNUnet peer. There can be multiple
-pseudonyms for a single user, and users could (theoretically) share the
-private pseudonym keys (currently only out-of-band by knowing which files
-to copy around).
@node Namespaces
@subsubsection Namespaces
+A namespace is a set of files that were signed by the same ego.
+Today, namespaces are implemented independently of GNS zones, but
+in the future we plan to merge the two such that a GNS zone can
+basically contain files using a file-sharing specific record type.
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
-A namespace is a set of files that were signed by the same pseudonym.
-Files (or directories) that have been signed and placed into a namespace
-can be updated. Updates are identified as authentic if the same secret
-key was used to sign the update. Namespaces are also useful to establish
-a reputation, since all of the content in the namespace comes from the
-same entity (which does not have to be the same person).
+Files (or directories) that have been signed and placed into a
+namespace can be updated. Updates are identified as authentic if the
+same secret key was used to sign the update.
@node Advertisements
@subsubsection Advertisements
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
Advertisements are used to notify other users about the existence of a
-namespace. Advertisements are propagated using the normal keyword search.
-When an advertisement is received (in response to a search), the namespace
-is added to the list of namespaces available in the namespace-search
-dialogs of gnunet-fs-gtk and printed by @code{gnunet-identity}. Whenever a
-namespace is created, an appropriate advertisement can be generated.
-The default keyword for the advertising of namespaces is "namespace".
-
-Note that GNUnet differentiates between your pseudonyms (the identities
-that you control) and namespaces. If you create a pseudonym, you will
-not automatically see the respective namespace. You first have to create
-an advertisement for the namespace and find it using keyword
-search --- even for your own namespaces. The @command{gnunet-identity}
-tool is currently responsible for both managing pseudonyms and namespaces.
-This will likely change in the future to reduce the potential for
-confusion.
+namespace. Advertisements are propagated using the normal keyword
+search. When an advertisement is received (in response to a search),
+the namespace is added to the list of namespaces available in the
+namespace-search dialogs of gnunet-fs-gtk and printed by
+@code{gnunet-identity}. Whenever a namespace is created, an
+appropriate advertisement can be generated. The default keyword for
+the advertising of namespaces is "namespace".
+
@node Anonymity level
@subsubsection Anonymity level
-
The anonymity level determines how hard it should be for an adversary to
determine the identity of the publisher or the searcher/downloader. An
anonymity level of zero means that anonymity is not required. The default
@@ -1066,10 +1052,10 @@ delays traffic.
While higher anonymity levels may offer better privacy, they can also
significantly hurt performance.
+
@node Content Priority
@subsubsection Content Priority
-
Depending on the peer's configuration, GNUnet peers migrate content
between peers. Content in this sense are individual blocks of a file,
not necessarily entire files. When peers run out of space (due to
@@ -1083,10 +1069,10 @@ lowest priority. The priority of a block is decided by its popularity
published locally, the base-priority that was specified by the user
when the block was published initially.
+
@node Replication
@subsubsection Replication
-
When peers migrate content to other systems, the replication level
of a block is used to decide which blocks need to be migrated most
urgently. GNUnet will always push the block with the highest
@@ -1098,99 +1084,37 @@ selection is simply random.
@node Namespace Management
@subsection Namespace Management
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-
-The @code{gnunet-identity} tool can be used to create pseudonyms and
-to advertise namespaces. By default, @code{gnunet-identity -D} simply
-lists all locally available pseudonyms.
+The @code{gnunet-identity} tool can be used to create egos.
+By default, @code{gnunet-identity -D} simply
+lists all locally available egos.
@menu
-* Creating Pseudonyms::
-* Deleting Pseudonyms::
-* Advertising namespaces::
-* Namespace names::
-* Namespace root::
+* Creating Egos::
+* Deleting Egos::
@end menu
-@node Creating Pseudonyms
-@subsubsection Creating Pseudonyms
+@node Creating Egos
+@subsubsection Creating Egos
+With the @command{-C NICK} option it can also be used to create a new
+ego. An ego is the virtual identity of the entity in control of a
+namespace or GNS zone. Anyone can create any number of egos. The
+provided NICK name automatically corresponds to a GNU Name System
+domain name. Thus, henceforth name resolution for any name ending in
+``.NICK'' will use the NICK's zone. You should avoid using NICKs that
+collide with well-known DNS names.
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
+@node Deleting Egos
+@subsubsection Deleting Egos
-With the @command{-C NICK} option it can also be used to
-create a new pseudonym. A pseudonym is the virtual identity
-of the entity in control of a namespace. Anyone can create
-any number of pseudonyms. Note that creating a pseudonym can
-take a few minutes depending on the performance of the machine
-used.
+With the @command{-D NICK} option egos can be deleted. Once the ego
+has been deleted it is impossible to add content to the corresponding
+namespace or zone. However, the existing GNS zone data is currently
+not dropped. This may change in the future.
-@node Deleting Pseudonyms
-@subsubsection Deleting Pseudonyms
-
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
-With the @command{-D NICK} option pseudonyms can be deleted.
-Once the pseudonym has been deleted it is impossible to add
-content to the corresponding namespace. Deleting the
-pseudonym does not make the namespace or any content in it
-unavailable.
-
-@node Advertising namespaces
-@subsubsection Advertising namespaces
-
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
-Each namespace is associated with meta-data that describes
-the namespace. This meta-data is provided by the user at
-the time that the namespace is advertised. Advertisements
-are published under keywords so that they can be found using
-normal keyword-searches. This way, users can learn about new
-namespaces without relying on out-of-band communication or directories.
-A suggested keyword to use for all namespaces is simply "namespace".
-When a keyword-search finds a namespace advertisement,
-it is automatically stored in a local list of known namespaces.
-Users can then associate a rank with the namespace to remember
-the quality of the content found in it.
-
-@node Namespace names
-@subsubsection Namespace names
-
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
-While the namespace is uniquely identified by its ID, another way
-to refer to the namespace is to use the NICKNAME.
-The NICKNAME can be freely chosen by the creator of the namespace and
-hence conflicts are possible. If a GNUnet client learns about more
-than one namespace using the same NICKNAME, the ID is appended
-to the NICKNAME to get a unique identifier.
-
-@node Namespace root
-@subsubsection Namespace root
-
-
-@b{Please note that the text in this subsection is outdated and needs}
-@b{to be rewritten for version 0.10!}
-@b{This especially concerns the terminology of Pseudonym/Ego/Identity.}
-
-An item of particular interest in the namespace advertisement is
-the ROOT. The ROOT is the identifier of a designated entry in the
-namespace. The idea is that the ROOT can be used to advertise an
-entry point to the content of the namespace.
+Deleting the pseudonym does not make the namespace or any content in
+it unavailable.
@node File-Sharing URIs
@subsection File-Sharing URIs
@@ -1314,12 +1238,12 @@ To publish a file, select "File Sharing" in the menu bar just below the
Afterwards, the following publishing dialog will appear:
-@c Add image here
+@image{images/gnunet-gtk-0-10-fs-publish,5in,,The gnunet-fs-gtk publishing dialog}
In this dialog, select the "Add File" button. This will open a
file selection dialog:
-@c Add image here
+@image{images/gnunet-gtk-0-10-fs-publish-select,5in,,Dialog to select the file to publish (looks may differ for other Gtk+ versions)}
Now, you should select a file from your computer to be published on
GNUnet. To see more of GNUnet's features later, you should pick a
@@ -1335,12 +1259,12 @@ and potential errors that might be encountered during processing.
After the progress dialog automatically disappears, your file
should now appear in the publishing dialog:
-@c Add image here
+@image{images/gnunet-gtk-0-10-fs-publish-with-file,5in,,Publishing dialog with file added}
Now, select the file (by clicking on the file name) and then click
the "Edit" button. This will open the editing dialog:
-@c Add image here
+@image{images/gnunet-gtk-0-10-fs-publish-editing,5in,,Editing meta data of a file to be published}
In this dialog, you can see many details about your file. In the
top left area, you can see meta data extracted about the file,
@@ -1364,9 +1288,7 @@ You should now be back at the "Publish content on GNUnet" dialog. Select
"Execute" in the bottom right to close the dialog and publish your file
on GNUnet! Afterwards, you should see the main dialog with a new area
showing the list of published files (or ongoing publishing operations
-with progress indicators):
-
-@c Add image here
+with progress indicators).
@node gtk-Searching
@subsubsection Searching
@@ -1920,33 +1842,42 @@ options:
@example
Ascension
-
Usage:
- ascension <domain> [-d] [-p]
- ascension <domain> <port> [-d] [-p]
- ascension <domain> -n <transferns> [-d] [-p]
- ascension <domain> -n <transferns> <port> [-d] [-p]
+ ascension <domain> [-d] [-p] [-s] [--minimum-ttl=<ttl>] \
+ [--dry-run]
+ ascension <domain> <port> [-d] [-p] [-s] \
+ [--minimum-ttl=<ttl>] [--dry-run]
+ ascension <domain> -n <transferns> [-d] [-p] \
+ [-s] [--minimum-ttl=<ttl>] [--dry-run]
+ ascension <domain> -n <transferns> <port> [-d] \
+ [-p] [-s] [--minimum-ttl=<ttl>] [--dry-run]
ascension -p | --public
+ ascension -d | --debug
+ ascension -s | --standalone
ascension -h | --help
ascension -v | --version
Options:
- <domain> Domain to migrate
- <port> Port for zone transfer
- <transferns> DNS Server that does the zone transfer
- -p --public Make records public on the DHT
- -d --debug Enable debugging
- -h --help Show this screen.
- -v --version Show version.
+ <domain> Domain to migrate
+ <port> Port for zone transfer
+ <transferns> DNS Server that does the zone transfer
+ --minimum-ttl=<ttl> Minimum TTL for records to migrate \
+ [default: 3600]
+ --dry-run Only try if a zone transfer is allowed
+ -p --public Make records public on the DHT
+ -s --standalone Run ascension once
+ -d --debug Enable debugging
+ -h --help Show this screen.
+ -v --version Show version.
@end example
-Before you can migrate any zone though, you need to start the GNUnet peer:
+Before you can migrate any zone though, you need to start a local GNUnet peer:
@example
$ gnunet-arm -s
@end example
To migrate the Syrian top level domain - one of the few top level domains that
-still supports zone transfers - into GNS use the following command:
+support zone transfers - into GNS use the following command:
@example
$ ascension sy. -n ns1.tld.sy. -p
@@ -1959,33 +1890,39 @@ Once the zone is migrated, Ascension will output a message telling you, that it
will refresh the zone after the time has elapsed. You can resolve the names in
the zone directly using GNS or if you want to use it with your browser, check
out the GNS manual section. @ref{Configuring the GNU Name System}. To resolve
-the records from another system you need the zone PKEY. To get the zone key,
-you can run the following command:
+the records from another system you need the respective zones PKEY. To get the
+zones public key, you can run the following command:
@example
-$ gnunet-identity -d | grep ^sy | cut -d " " -f3
+$ gnunet-identity -dqe sy
@end example
Where "sy" is the name of the zone you want to migrate.
-As soon as the public flag is implemented, you can share the PKEY of the zone
-with your friends. They can then resolve records in the zone by doing a lookup
-replacing the zone label with your PKEY:
+You can share the PKEY of the zone with your friends. They can then resolve
+records in the zone by doing a lookup replacing the zone label with your PKEY:
@example
-$ gnunet-gns -t SOA -u "@.$PKEY"
+$ gnunet-gns -t SOA -u "$PKEY"
@end example
The program will continue to run as a daemon and update once the refresh time
specified in the zones SOA record has elapsed.
-The next step would be to add the PKEY record as a DNScurve style NS record
-into the existing DNS zone to enable clients to detect that this zone has
-already been migrated to GNS and to also have a means of distributing the PKEY
-seamlessly.
+DNSCurve style records are supported in the latest release and they are added
+as a PKEY record to be referred to the respective GNS public key. Key
+distribution is still a problem but provided someone else has a public key
+under a given label it can be looked up.
+
+There is an unofficial Debian package called python3-ascension that adds a
+system user ascension and runs a GNUnet peer in the background.
-At this point you might want to write for example a systemd unit file to start
-and enable the service, so that your zone is migrated automatically.
+Ascension-bind is also an unofficial Debian package that on installation checks
+for running DNS zones and whether or not they are transferable using DNS zone
+transfer (AXFR). It asks the administrator which zones to migrate into GNS and
+installs a systemd unit file to keep the zone up to date. If you want to
+migrate different zones you might want to check the unit file from the package
+as a guide.
@node reclaimID Identity Provider
@section reclaimID Identity Provider
diff --git a/doc/handbook/images/ascension_interaction.png b/doc/handbook/images/ascension_interaction.png
new file mode 100644
index 000000000..84e2e9c0f
--- /dev/null
+++ b/doc/handbook/images/ascension_interaction.png
Binary files differ
diff --git a/doc/handbook/images/ascension_ssd.png b/doc/handbook/images/ascension_ssd.png
new file mode 100644
index 000000000..3b142ab31
--- /dev/null
+++ b/doc/handbook/images/ascension_ssd.png
Binary files differ
diff --git a/doc/man/gnunet-config.1 b/doc/man/gnunet-config.1
index 0e612fe29..95dc98811 100644
--- a/doc/man/gnunet-config.1
+++ b/doc/man/gnunet-config.1
@@ -30,6 +30,7 @@
manipulate GNUnet configuration files
.Sh SYNOPSIS
.Nm
+.Op Fl b Ar BACKEND | Fl \-supported-backend= Ns Ar BACKEND
.Op Fl c Ar FILENAME | Fl \-config= Ns Ar FILENAME
.Op Fl f | \-filename
.Op Fl h | \-help
@@ -44,6 +45,8 @@ manipulate GNUnet configuration files
.Nm
can be used to read or modify GNUnet configuration files.
.Bl -tag -width indent
+.It Fl b Ar BACKEND | Fl \-supported-backend= Ns Ar BACKEND
+Tests whether the specified BACKEND is supported by the current installation. The backend must match the name of a plugin, i.e. "namestore_postgres" for the Postgres database backend of the "NAMESTORE" service. If the BACKEND is supported, gnunet-config will return a status code of 0 (success), otherwise 77 (unsupported). When this option is specified, no other options may be specified. Specifying this option together with other options will cause gnunet-config to return a status code of 1 (error).
.It Fl c Ar FILENAME | Fl \-config= Ns Ar FILENAME
Use the configuration file FILENAME.
.It Fl f | \-filename
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index c8103c877..bf0acbcb9 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -30,7 +30,7 @@
#include "gnunet_protocols.h"
#include "arm.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "arm-api",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "arm-api", __VA_ARGS__)
/**
@@ -156,7 +156,6 @@ struct GNUNET_ARM_Handle
* Have we detected that ARM is up?
*/
int currently_up;
-
};
@@ -204,27 +203,19 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h)
h->currently_up = GNUNET_NO;
GNUNET_assert (NULL == h->reconnect_task);
h->reconnect_task =
- GNUNET_SCHEDULER_add_delayed (h->retry_backoff,
- &reconnect_arm_task,
- h);
+ GNUNET_SCHEDULER_add_delayed (h->retry_backoff, &reconnect_arm_task, h);
while (NULL != (op = h->operation_pending_head))
{
if (NULL != op->result_cont)
- op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_DISCONNECTED,
- 0);
+ op->result_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
if (NULL != op->list_cont)
- op->list_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_DISCONNECTED,
- 0,
- NULL);
+ op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
GNUNET_ARM_operation_cancel (op);
}
GNUNET_assert (NULL == h->operation_pending_head);
h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff);
if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls,
- GNUNET_NO);
+ h->conn_status (h->conn_status_cls, GNUNET_NO);
}
@@ -236,12 +227,12 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h)
* @return NULL if not found
*/
static struct GNUNET_ARM_Operation *
-find_op_by_id (struct GNUNET_ARM_Handle *h,
- uint64_t id)
+find_op_by_id (struct GNUNET_ARM_Handle *h, uint64_t id)
{
struct GNUNET_ARM_Operation *result;
- for (result = h->operation_pending_head; NULL != result; result = result->next)
+ for (result = h->operation_pending_head; NULL != result;
+ result = result->next)
if (id == result->id)
return result;
return NULL;
@@ -255,8 +246,7 @@ find_op_by_id (struct GNUNET_ARM_Handle *h,
* @param res the message received from the arm service
*/
static void
-handle_arm_result (void *cls,
- const struct GNUNET_ARM_ResultMessage *res)
+handle_arm_result (void *cls, const struct GNUNET_ARM_ResultMessage *res)
{
struct GNUNET_ARM_Handle *h = cls;
struct GNUNET_ARM_Operation *op;
@@ -266,8 +256,7 @@ handle_arm_result (void *cls,
void *result_cont_cls;
id = GNUNET_ntohll (res->arm_msg.request_id);
- op = find_op_by_id (h,
- id);
+ op = find_op_by_id (h, id);
if (NULL == op)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -277,8 +266,7 @@ handle_arm_result (void *cls,
}
result = (enum GNUNET_ARM_Result) ntohl (res->result);
- if ( (GNUNET_YES == op->is_arm_stop) &&
- (GNUNET_ARM_RESULT_STOPPING == result) )
+ if ((GNUNET_YES == op->is_arm_stop) && (GNUNET_ARM_RESULT_STOPPING == result))
{
/* special case: if we are stopping 'gnunet-service-arm', we do not just
wait for the result message, but also wait for the service to close
@@ -289,8 +277,8 @@ handle_arm_result (void *cls,
{
GNUNET_break (0);
op->result_cont (h->thm->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_IS_NOT_KNOWN);
GNUNET_free (h->thm);
}
GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
@@ -303,9 +291,7 @@ handle_arm_result (void *cls,
result_cont_cls = op->cont_cls;
GNUNET_ARM_operation_cancel (op);
if (NULL != result_cont)
- result_cont (result_cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- result);
+ result_cont (result_cont_cls, GNUNET_ARM_REQUEST_SENT_OK, result);
}
@@ -325,6 +311,7 @@ check_arm_list_result (void *cls,
uint16_t msize = ntohs (lres->arm_msg.header.size) - sizeof (*lres);
uint16_t size_check;
+ (void) cls;
size_check = 0;
for (unsigned int i = 0; i < rcount; i++)
{
@@ -361,8 +348,7 @@ handle_arm_list_result (void *cls,
uint64_t id;
id = GNUNET_ntohll (lres->arm_msg.request_id);
- op = find_op_by_id (h,
- id);
+ op = find_op_by_id (h, id);
if (NULL == op)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -373,9 +359,7 @@ handle_arm_list_result (void *cls,
size_check = 0;
for (unsigned int i = 0; i < rcount; i++)
{
- const char *end = memchr (pos,
- 0,
- msize - size_check);
+ const char *end = memchr (pos, 0, msize - size_check);
/* Assert, as this was already checked in #check_arm_list_result() */
GNUNET_assert (NULL != end);
@@ -384,10 +368,7 @@ handle_arm_list_result (void *cls,
pos = end + 1;
}
if (NULL != op->list_cont)
- op->list_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- rcount,
- list);
+ op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_SENT_OK, rcount, list);
GNUNET_ARM_operation_cancel (op);
}
@@ -399,19 +380,17 @@ handle_arm_list_result (void *cls,
* @param msg message received
*/
static void
-handle_confirm (void *cls,
- const struct GNUNET_MessageHeader *msg)
+handle_confirm (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_ARM_Handle *h = cls;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Got confirmation from ARM that we are up!\n");
+ (void) msg;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Got confirmation from ARM that we are up!\n");
if (GNUNET_NO == h->currently_up)
{
h->currently_up = GNUNET_YES;
if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls,
- GNUNET_YES);
+ h->conn_status (h->conn_status_cls, GNUNET_YES);
}
}
@@ -425,19 +404,19 @@ handle_confirm (void *cls,
* @param error error code
*/
static void
-mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_ARM_Handle *h = cls;
struct GNUNET_ARM_Operation *op;
+ (void) error;
h->currently_up = GNUNET_NO;
if (NULL != (op = h->thm))
{
h->thm = NULL;
op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- GNUNET_ARM_RESULT_STOPPED);
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_STOPPED);
GNUNET_free (op);
}
reconnect_arm_later (h);
@@ -453,47 +432,37 @@ mq_error_handler (void *cls,
static int
reconnect_arm (struct GNUNET_ARM_Handle *h)
{
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (arm_result,
- GNUNET_MESSAGE_TYPE_ARM_RESULT,
- struct GNUNET_ARM_ResultMessage,
- h),
- GNUNET_MQ_hd_var_size (arm_list_result,
- GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT,
- struct GNUNET_ARM_ListResultMessage,
- h),
- GNUNET_MQ_hd_fixed_size (confirm,
- GNUNET_MESSAGE_TYPE_ARM_TEST,
- struct GNUNET_MessageHeader,
- h),
- GNUNET_MQ_handler_end ()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_fixed_size (arm_result,
+ GNUNET_MESSAGE_TYPE_ARM_RESULT,
+ struct GNUNET_ARM_ResultMessage,
+ h),
+ GNUNET_MQ_hd_var_size (arm_list_result,
+ GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT,
+ struct GNUNET_ARM_ListResultMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (confirm,
+ GNUNET_MESSAGE_TYPE_ARM_TEST,
+ struct GNUNET_MessageHeader,
+ h),
+ GNUNET_MQ_handler_end ()};
struct GNUNET_MessageHeader *test;
struct GNUNET_MQ_Envelope *env;
if (NULL != h->mq)
return GNUNET_OK;
GNUNET_assert (GNUNET_NO == h->currently_up);
- h->mq = GNUNET_CLIENT_connect (h->cfg,
- "arm",
- handlers,
- &mq_error_handler,
- h);
+ h->mq = GNUNET_CLIENT_connect (h->cfg, "arm", handlers, &mq_error_handler, h);
if (NULL == h->mq)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "GNUNET_CLIENT_connect returned NULL\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CLIENT_connect returned NULL\n");
if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls,
- GNUNET_SYSERR);
+ h->conn_status (h->conn_status_cls, GNUNET_SYSERR);
return GNUNET_SYSERR;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending TEST message to ARM\n");
- env = GNUNET_MQ_msg (test,
- GNUNET_MESSAGE_TYPE_ARM_TEST);
- GNUNET_MQ_send (h->mq,
- env);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending TEST message to ARM\n");
+ env = GNUNET_MQ_msg (test, GNUNET_MESSAGE_TYPE_ARM_TEST);
+ GNUNET_MQ_send (h->mq, env);
return GNUNET_OK;
}
@@ -512,7 +481,7 @@ reconnect_arm (struct GNUNET_ARM_Handle *h)
struct GNUNET_ARM_Handle *
GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_ARM_ConnectionStatusCallback conn_status,
- void *conn_status_cls)
+ void *conn_status_cls)
{
struct GNUNET_ARM_Handle *h;
@@ -539,22 +508,16 @@ GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
{
struct GNUNET_ARM_Operation *op;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting from ARM service\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n");
while (NULL != (op = h->operation_pending_head))
{
GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
h->operation_pending_tail,
op);
if (NULL != op->result_cont)
- op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_DISCONNECTED,
- 0);
+ op->result_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
if (NULL != op->list_cont)
- op->list_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_DISCONNECTED,
- 0,
- NULL);
+ op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
if (NULL != op->async)
{
GNUNET_SCHEDULER_cancel (op->async);
@@ -596,60 +559,43 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
char *loprefix;
char *lopostfix;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "PREFIX",
- &loprefix))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (h->cfg,
+ "arm",
+ "PREFIX",
+ &loprefix))
loprefix = GNUNET_strdup ("");
else
- loprefix = GNUNET_CONFIGURATION_expand_dollar (h->cfg,
- loprefix);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "OPTIONS",
- &lopostfix))
+ loprefix = GNUNET_CONFIGURATION_expand_dollar (h->cfg, loprefix);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (h->cfg,
+ "arm",
+ "OPTIONS",
+ &lopostfix))
lopostfix = GNUNET_strdup ("");
else
- lopostfix = GNUNET_CONFIGURATION_expand_dollar (h->cfg,
- lopostfix);
+ lopostfix = GNUNET_CONFIGURATION_expand_dollar (h->cfg, lopostfix);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "BINARY",
- &cbinary))
+ GNUNET_CONFIGURATION_get_value_string (h->cfg, "arm", "BINARY", &cbinary))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- "arm",
- "BINARY");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, "arm", "BINARY");
GNUNET_free (loprefix);
GNUNET_free (lopostfix);
return GNUNET_ARM_RESULT_IS_NOT_KNOWN;
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (h->cfg,
- "arm",
- "CONFIG",
- &config))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (h->cfg,
+ "arm",
+ "CONFIG",
+ &config))
config = NULL;
binary = GNUNET_OS_get_libexec_binary_path (cbinary);
- GNUNET_asprintf (&quotedbinary,
- "\"%s\"",
- binary);
+ GNUNET_asprintf (&quotedbinary, "\"%s\"", binary);
GNUNET_free (cbinary);
- if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (h->cfg,
- "TESTING",
- "WEAKRANDOM")) &&
- (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (h->cfg,
- "TESTING",
- "WEAKRANDOM")) &&
- (GNUNET_NO ==
- GNUNET_CONFIGURATION_have_value (h->cfg,
- "TESTING",
- "HOSTFILE")))
+ if ((GNUNET_YES ==
+ GNUNET_CONFIGURATION_have_value (h->cfg, "TESTING", "WEAKRANDOM")) &&
+ (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (h->cfg,
+ "TESTING",
+ "WEAKRANDOM")) &&
+ (GNUNET_NO ==
+ GNUNET_CONFIGURATION_have_value (h->cfg, "TESTING", "HOSTFILE")))
{
/* Means we are ONLY running locally */
/* we're clearly running a test, don't daemonize */
@@ -668,7 +614,8 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
NULL,
loprefix,
quotedbinary,
- "-c", config,
+ "-c",
+ config,
/* no daemonization! */
lopostfix,
NULL);
@@ -683,14 +630,15 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
quotedbinary,
"-d", /* do daemonize */
lopostfix,
- NULL);
+ NULL);
else
proc = GNUNET_OS_start_process_s (GNUNET_NO,
std_inheritance,
NULL,
loprefix,
quotedbinary,
- "-c", config,
+ "-c",
+ config,
"-d", /* do daemonize */
lopostfix,
NULL);
@@ -744,7 +692,7 @@ static struct GNUNET_ARM_Operation *
change_service (struct GNUNET_ARM_Handle *h,
const char *service_name,
GNUNET_ARM_ResultCallback cb,
- void *cb_cls,
+ void *cb_cls,
uint16_t type)
{
struct GNUNET_ARM_Operation *op;
@@ -753,8 +701,7 @@ change_service (struct GNUNET_ARM_Handle *h,
struct GNUNET_ARM_Message *msg;
slen = strlen (service_name) + 1;
- if (slen + sizeof (struct GNUNET_ARM_Message) >=
- GNUNET_MAX_MESSAGE_SIZE)
+ if (slen + sizeof (struct GNUNET_ARM_Message) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
@@ -769,16 +716,11 @@ change_service (struct GNUNET_ARM_Handle *h,
GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
h->operation_pending_tail,
op);
- env = GNUNET_MQ_msg_extra (msg,
- slen,
- type);
+ env = GNUNET_MQ_msg_extra (msg, slen, type);
msg->reserved = htonl (0);
msg->request_id = GNUNET_htonll (op->id);
- GNUNET_memcpy (&msg[1],
- service_name,
- slen);
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_memcpy (&msg[1], service_name, slen);
+ GNUNET_MQ_send (h->mq, env);
return op;
}
@@ -802,10 +744,8 @@ notify_running (void *cls)
op->result_cont (op->cont_cls,
GNUNET_ARM_REQUEST_SENT_OK,
GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
- if ( (GNUNET_YES == h->currently_up) &&
- (NULL != h->conn_status) )
- h->conn_status (h->conn_status_cls,
- GNUNET_YES);
+ if ((GNUNET_YES == h->currently_up) && (NULL != h->conn_status))
+ h->conn_status (h->conn_status_cls, GNUNET_YES);
GNUNET_free (op);
}
@@ -846,20 +786,18 @@ notify_starting (void *cls)
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- enum GNUNET_OS_InheritStdioFlags std_inheritance,
- GNUNET_ARM_ResultCallback cont,
- void *cont_cls)
+GNUNET_ARM_request_service_start (
+ struct GNUNET_ARM_Handle *h,
+ const char *service_name,
+ enum GNUNET_OS_InheritStdioFlags std_inheritance,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls)
{
struct GNUNET_ARM_Operation *op;
enum GNUNET_ARM_Result ret;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Starting service `%s'\n",
- service_name);
- if (0 != strcasecmp ("arm",
- service_name))
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting service `%s'\n", service_name);
+ if (0 != strcasecmp ("arm", service_name))
return change_service (h,
service_name,
cont,
@@ -874,8 +812,7 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
*/
if (GNUNET_YES == h->currently_up)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "ARM is already running\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "ARM is already running\n");
op = GNUNET_new (struct GNUNET_ARM_Operation);
op->h = h;
op->result_cont = cont;
@@ -883,8 +820,7 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
h->operation_pending_tail,
op);
- op->async = GNUNET_SCHEDULER_add_now (&notify_running,
- op);
+ op->async = GNUNET_SCHEDULER_add_now (&notify_running, op);
return op;
}
/* This is an inherently uncertain choice, as it is of course
@@ -893,10 +829,8 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
are unlikely to hammer 'gnunet-arm -s' on a busy system,
the above check should catch 99.99% of the cases where ARM
is already running. */
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Starting ARM service\n");
- ret = start_arm_service (h,
- std_inheritance);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting ARM service\n");
+ ret = start_arm_service (h, std_inheritance);
if (GNUNET_ARM_RESULT_STARTING == ret)
reconnect_arm (h);
op = GNUNET_new (struct GNUNET_ARM_Operation);
@@ -907,8 +841,7 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
h->operation_pending_tail,
op);
op->starting_ret = ret;
- op->async = GNUNET_SCHEDULER_add_now (&notify_starting,
- op);
+ op->async = GNUNET_SCHEDULER_add_now (&notify_starting, op);
return op;
}
@@ -929,15 +862,13 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
*/
struct GNUNET_ARM_Operation *
GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- GNUNET_ARM_ResultCallback cont,
- void *cont_cls)
+ const char *service_name,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls)
{
struct GNUNET_ARM_Operation *op;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Stopping service `%s'\n",
- service_name);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping service `%s'\n", service_name);
op = change_service (h,
service_name,
cont,
@@ -947,8 +878,7 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
return NULL;
/* If the service is ARM, set a flag as we will use MQ errors
to detect that the process is really gone. */
- if (0 == strcasecmp (service_name,
- "arm"))
+ if (0 == strcasecmp (service_name, "arm"))
op->is_arm_stop = GNUNET_YES;
return op;
}
@@ -971,8 +901,7 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
struct GNUNET_MQ_Envelope *env;
struct GNUNET_ARM_Message *msg;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting LIST from ARM service\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting LIST from ARM service\n");
if (0 == h->request_id_counter)
h->request_id_counter++;
op = GNUNET_new (struct GNUNET_ARM_Operation);
@@ -983,12 +912,10 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
h->operation_pending_tail,
op);
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_ARM_LIST);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_LIST);
msg->reserved = htonl (0);
msg->request_id = GNUNET_htonll (op->id);
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_MQ_send (h->mq, env);
return op;
}
diff --git a/src/arm/arm_monitor_api.c b/src/arm/arm_monitor_api.c
index 15f91c036..55b12240f 100644
--- a/src/arm/arm_monitor_api.c
+++ b/src/arm/arm_monitor_api.c
@@ -32,7 +32,7 @@
#define INIT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-#define LOG(kind,...) GNUNET_log_from (kind, "arm-monitor-api",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "arm-monitor-api", __VA_ARGS__)
/**
* Handle for interacting with ARM.
@@ -69,7 +69,6 @@ struct GNUNET_ARM_MonitorHandle
* Closure for @e service_status.
*/
void *service_status_cls;
-
};
@@ -115,9 +114,9 @@ reconnect_arm_monitor_later (struct GNUNET_ARM_MonitorHandle *h)
h->mq = NULL;
}
GNUNET_assert (NULL == h->reconnect_task);
- h->reconnect_task
- = GNUNET_SCHEDULER_add_delayed (h->retry_backoff,
- &reconnect_arm_monitor_task, h);
+ h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_backoff,
+ &reconnect_arm_monitor_task,
+ h);
h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff);
}
@@ -130,14 +129,14 @@ reconnect_arm_monitor_later (struct GNUNET_ARM_MonitorHandle *h)
* @return #GNUNET_OK if the message is well-formed
*/
static int
-check_monitor_notify (void *cls,
- const struct GNUNET_ARM_StatusMessage *msg)
+check_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *msg)
{
- size_t sl = ntohs (msg->header.size) - sizeof (struct GNUNET_ARM_StatusMessage);
+ size_t sl =
+ ntohs (msg->header.size) - sizeof (struct GNUNET_ARM_StatusMessage);
const char *name = (const char *) &msg[1];
- if ( (0 == sl) ||
- ('\0' != name[sl-1]) )
+ (void) cls;
+ if ((0 == sl) || ('\0' != name[sl - 1]))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -153,8 +152,7 @@ check_monitor_notify (void *cls,
* @param res the message received from the arm service
*/
static void
-handle_monitor_notify (void *cls,
- const struct GNUNET_ARM_StatusMessage *res)
+handle_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *res)
{
struct GNUNET_ARM_MonitorHandle *h = cls;
enum GNUNET_ARM_ServiceStatus status;
@@ -165,9 +163,7 @@ handle_monitor_notify (void *cls,
(const char *) &res[1],
(int) status);
if (NULL != h->service_status)
- h->service_status (h->service_status_cls,
- (const char *) &res[1],
- status);
+ h->service_status (h->service_status_cls, (const char *) &res[1], status);
}
@@ -180,11 +176,11 @@ handle_monitor_notify (void *cls,
* @param error error code
*/
static void
-mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_ARM_MonitorHandle *h = cls;
+ (void) error;
reconnect_arm_monitor_later (h);
}
@@ -198,22 +194,17 @@ mq_error_handler (void *cls,
static int
reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h)
{
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (monitor_notify,
- GNUNET_MESSAGE_TYPE_ARM_STATUS,
- struct GNUNET_ARM_StatusMessage,
- h),
- GNUNET_MQ_handler_end ()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_var_size (monitor_notify,
+ GNUNET_MESSAGE_TYPE_ARM_STATUS,
+ struct GNUNET_ARM_StatusMessage,
+ h),
+ GNUNET_MQ_handler_end ()};
struct GNUNET_MessageHeader *msg;
struct GNUNET_MQ_Envelope *env;
GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connect (h->cfg,
- "arm",
- handlers,
- &mq_error_handler,
- h);
+ h->mq = GNUNET_CLIENT_connect (h->cfg, "arm", handlers, &mq_error_handler, h);
if (NULL == h->mq)
{
if (NULL != h->service_status)
@@ -222,10 +213,8 @@ reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h)
GNUNET_ARM_SERVICE_STOPPED);
return GNUNET_SYSERR;
}
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_ARM_MONITOR);
- GNUNET_MQ_send (h->mq,
- env);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_MONITOR);
+ GNUNET_MQ_send (h->mq, env);
return GNUNET_OK;
}
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 5a4acb31a..7d705733a 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -799,25 +799,26 @@ main (int argc, char *const *argv)
gettext_noop ("don't let gnunet-service-arm inherit standard error"),
&no_stderr),
GNUNET_GETOPT_OPTION_END};
+ int lret;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
if (GNUNET_OK ==
- GNUNET_PROGRAM_run (
- argc,
- argv,
- "gnunet-arm",
- gettext_noop (
- "Control services and the Automated Restart Manager (ARM)"),
- options,
- &run,
- NULL))
+ (lret = GNUNET_PROGRAM_run (
+ argc,
+ argv,
+ "gnunet-arm",
+ gettext_noop (
+ "Control services and the Automated Restart Manager (ARM)"),
+ options,
+ &run,
+ NULL)))
{
GNUNET_free ((void *) argv);
return ret;
}
GNUNET_free ((void *) argv);
- return 1;
+ return lret;
}
/* end of gnunet-arm.c */
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c
index c9f00b5dd..667556314 100644
--- a/src/arm/mockup-service.c
+++ b/src/arm/mockup-service.c
@@ -33,13 +33,13 @@ static int special_ret = 0;
* @param message the actual message
*/
static void
-handle_stop (void *cls,
- const struct GNUNET_MessageHeader *message)
+handle_stop (void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVICE_Client *client = cls;
+ (void) message;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Initiating shutdown as requested by client.\n"));
+ _ ("Initiating shutdown as requested by client.\n"));
GNUNET_SERVICE_client_persist (client);
GNUNET_SCHEDULER_shutdown ();
/* ARM won't exponentially increase restart delay if we
@@ -59,9 +59,11 @@ handle_stop (void *cls,
*/
static void *
client_connect_cb (void *cls,
- struct GNUNET_SERVICE_Client *c,
- struct GNUNET_MQ_Handle *mq)
+ struct GNUNET_SERVICE_Client *c,
+ struct GNUNET_MQ_Handle *mq)
{
+ (void) cls;
+ (void) mq;
return c;
}
@@ -75,9 +77,10 @@ client_connect_cb (void *cls,
*/
static void
client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *c,
- void *internal_cls)
+ struct GNUNET_SERVICE_Client *c,
+ void *internal_cls)
{
+ (void) cls;
GNUNET_assert (c == internal_cls);
}
@@ -87,6 +90,9 @@ run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_SERVICE_Handle *service)
{
+ (void) cls;
+ (void) cfg;
+ (void) service;
/* nothing to do */
}
@@ -94,25 +100,20 @@ run (void *cls,
/**
* Define "main" method using service macro.
*/
-GNUNET_SERVICE_MAIN
-("do-nothing",
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_fixed_size (stop,
- GNUNET_MESSAGE_TYPE_ARM_STOP,
- struct GNUNET_MessageHeader,
- NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN ("do-nothing",
+ GNUNET_SERVICE_OPTION_NONE,
+ &run,
+ &client_connect_cb,
+ &client_disconnect_cb,
+ NULL,
+ GNUNET_MQ_hd_fixed_size (stop,
+ GNUNET_MESSAGE_TYPE_ARM_STOP,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end ());
/**
* MINIMIZE heap size (way below 128k) since this process doesn't need much.
*/
-void __attribute__ ((destructor))
-GNUNET_mockup_done ()
-{
- _exit (special_ret);
-}
+void __attribute__ ((destructor)) GNUNET_mockup_done () { _exit (special_ret); }
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index f6cc860cc..ff3e47d19 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -27,29 +27,29 @@
#define CADET_H_
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
#include <stdint.h>
-#if !defined(GNUNET_CULL_LOGGING)
- #define CADET_TIMING_START \
- struct GNUNET_TIME_Absolute __timestamp;\
- __timestamp = GNUNET_TIME_absolute_get()
-
- #define CADET_TIMING_END \
- struct GNUNET_TIME_Relative __duration;\
- __duration = GNUNET_TIME_absolute_get_duration (__timestamp);\
- LOG (GNUNET_ERROR_TYPE_INFO, " %s duration %s\n",\
- __FUNCTION__,\
- GNUNET_STRINGS_relative_time_to_string (__duration, GNUNET_YES));
+#if ! defined(GNUNET_CULL_LOGGING)
+#define CADET_TIMING_START \
+ struct GNUNET_TIME_Absolute __timestamp; \
+ __timestamp = GNUNET_TIME_absolute_get ()
+
+#define CADET_TIMING_END \
+ struct GNUNET_TIME_Relative __duration; \
+ __duration = GNUNET_TIME_absolute_get_duration (__timestamp); \
+ LOG (GNUNET_ERROR_TYPE_INFO, \
+ " %s duration %s\n", \
+ __FUNCTION__, \
+ GNUNET_STRINGS_relative_time_to_string (__duration, GNUNET_YES));
#else
- #define CADET_TIMING_START
- #define CADET_TIMING_END
+#define CADET_TIMING_START
+#define CADET_TIMING_END
#endif
@@ -68,17 +68,17 @@ extern "C"
/**
* Minimum value for channel IDs of local clients.
*/
-#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000U
+#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000U
/**
* FIXME.
*/
-#define HIGH_PID 0xFF000000
+#define HIGH_PID 0xFF000000
/**
* FIXME.
*/
-#define LOW_PID 0x00FFFFFF
+#define LOW_PID 0x00FFFFFF
/**
@@ -199,6 +199,12 @@ struct GNUNET_CADET_LocalData
struct GNUNET_CADET_ClientChannelNumber ccn;
/**
+ * Priority and preferences (an enum GNUNET_MQ_PriorityPreferences)
+ * of the message in NBO.
+ */
+ uint32_t pp GNUNET_PACKED;
+
+ /**
* Payload follows
*/
};
@@ -219,7 +225,6 @@ struct GNUNET_CADET_LocalAck
* ID of the channel allowed to send more data.
*/
struct GNUNET_CADET_ClientChannelNumber ccn;
-
};
@@ -308,7 +313,6 @@ struct GNUNET_CADET_RequestChannelInfoMessage
* Target of the channel.
*/
struct GNUNET_PeerIdentity target;
-
};
@@ -358,7 +362,6 @@ struct GNUNET_CADET_LocalInfoPeers
* ID of the peer (can be local peer).
*/
struct GNUNET_PeerIdentity destination;
-
};
@@ -465,9 +468,7 @@ GC_min_pid (uint32_t a, uint32_t b);
* @return The size of the output.
*/
size_t
-GC_bin2s (void *bin,
- unsigned int len,
- char **output);
+GC_bin2s (void *bin, unsigned int len, char **output);
/**
@@ -483,7 +484,7 @@ GC_bin2s (void *bin,
const char *
GC_m2s (uint16_t m);
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 8638be27d..b16520429 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -30,7 +30,7 @@
#include "cadet.h"
#include "cadet_protocol.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "cadet-api",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "cadet-api", __VA_ARGS__)
/**
* Opaque handle to the service.
@@ -71,7 +71,6 @@ struct GNUNET_CADET_Handle
* Time to the next reconnect in case one reconnect fails
*/
struct GNUNET_TIME_Relative reconnect_time;
-
};
@@ -138,7 +137,6 @@ struct GNUNET_CADET_Channel
* How many messages are we allowed to send to the service right now?
*/
unsigned int allow_send;
-
};
@@ -199,10 +197,9 @@ struct GNUNET_CADET_Port
*/
static struct GNUNET_CADET_Port *
find_port (const struct GNUNET_CADET_Handle *h,
- const struct GNUNET_HashCode *hash)
+ const struct GNUNET_HashCode *hash)
{
- return GNUNET_CONTAINER_multihashmap_get (h->ports,
- hash);
+ return GNUNET_CONTAINER_multihashmap_get (h->ports, hash);
}
@@ -240,11 +237,10 @@ create_channel (struct GNUNET_CADET_Handle *h,
ch->cadet = h;
if (NULL == ccnp)
{
- while (NULL !=
- find_channel (h,
- h->next_ccn))
- h->next_ccn.channel_of_client
- = htonl (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI | (1 + ntohl (h->next_ccn.channel_of_client)));
+ while (NULL != find_channel (h, h->next_ccn))
+ h->next_ccn.channel_of_client =
+ htonl (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI |
+ (1 + ntohl (h->next_ccn.channel_of_client)));
ccn = h->next_ccn;
}
else
@@ -253,10 +249,11 @@ create_channel (struct GNUNET_CADET_Handle *h,
}
ch->ccn = ccn;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap32_put (h->channels,
- ntohl (ch->ccn.channel_of_client),
- ch,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap32_put (
+ h->channels,
+ ntohl (ch->ccn.channel_of_client),
+ ch,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
return ch;
}
@@ -280,10 +277,11 @@ destroy_channel (struct GNUNET_CADET_Channel *ch)
"Destroying channel %X of %p\n",
htonl (ch->ccn.channel_of_client),
h);
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap32_remove (h->channels,
- ntohl (ch->ccn.channel_of_client),
- ch));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap32_remove (h->channels,
+ ntohl (ch->ccn.channel_of_client),
+ ch));
if (NULL != ch->mq_cont)
{
GNUNET_SCHEDULER_cancel (ch->mq_cont);
@@ -291,8 +289,7 @@ destroy_channel (struct GNUNET_CADET_Channel *ch)
}
/* signal channel destruction */
if (NULL != ch->disconnects)
- ch->disconnects (ch->ctx,
- ch);
+ ch->disconnects (ch->ctx, ch);
if (NULL != ch->pending_env)
GNUNET_MQ_discard (ch->pending_env);
GNUNET_MQ_destroy (ch->mq);
@@ -320,9 +317,7 @@ reconnect (struct GNUNET_CADET_Handle *h);
* @return #GNUNET_OK (continue to iterate)
*/
static int
-open_port_cb (void *cls,
- const struct GNUNET_HashCode *id,
- void *value)
+open_port_cb (void *cls, const struct GNUNET_HashCode *id, void *value)
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Port *port = value;
@@ -330,11 +325,9 @@ open_port_cb (void *cls,
struct GNUNET_MQ_Envelope *env;
(void) id;
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN);
msg->port = port->id;
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_MQ_send (h->mq, env);
return GNUNET_OK;
}
@@ -351,12 +344,9 @@ reconnect_cbk (void *cls)
struct GNUNET_CADET_Handle *h = cls;
h->reconnect_task = NULL;
- h->reconnect_time
- = GNUNET_TIME_STD_BACKOFF (h->reconnect_time);
+ h->reconnect_time = GNUNET_TIME_STD_BACKOFF (h->reconnect_time);
reconnect (h);
- GNUNET_CONTAINER_multihashmap_iterate (h->ports,
- &open_port_cb,
- h);
+ GNUNET_CONTAINER_multihashmap_iterate (h->ports, &open_port_cb, h);
}
@@ -405,8 +395,7 @@ cadet_mq_send_now (void *cls)
"Sending message on channel %s to CADET, new window size is %u\n",
GNUNET_i2s (&ch->peer),
ch->allow_send);
- GNUNET_MQ_send (ch->cadet->mq,
- env);
+ GNUNET_MQ_send (ch->cadet->mq, env);
GNUNET_MQ_impl_send_continue (ch->mq);
}
@@ -431,8 +420,10 @@ cadet_mq_send_impl (struct GNUNET_MQ_Handle *mq,
struct GNUNET_CADET_Channel *ch = impl_state;
struct GNUNET_CADET_Handle *h = ch->cadet;
uint16_t msize;
+ struct GNUNET_MQ_Envelope *orig_env;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_CADET_LocalData *cadet_msg = NULL;
+ struct GNUNET_CADET_LocalData *cadet_msg;
+ enum GNUNET_MQ_PriorityPreferences pp;
if (NULL == h->mq)
{
@@ -440,6 +431,8 @@ cadet_mq_send_impl (struct GNUNET_MQ_Handle *mq,
GNUNET_MQ_impl_send_continue (mq);
return;
}
+ orig_env = GNUNET_MQ_get_current_envelope (mq);
+ pp = GNUNET_MQ_env_get_options (orig_env);
/* check message size for sanity */
msize = ntohs (msg->size);
@@ -453,12 +446,11 @@ cadet_mq_send_impl (struct GNUNET_MQ_Handle *mq,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
msg);
cadet_msg->ccn = ch->ccn;
+ cadet_msg->pp = htonl ((uint32_t) pp);
GNUNET_assert (NULL == ch->pending_env);
ch->pending_env = env;
if (0 < ch->allow_send)
- ch->mq_cont
- = GNUNET_SCHEDULER_add_now (&cadet_mq_send_now,
- ch);
+ ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_now, ch);
}
@@ -470,8 +462,7 @@ cadet_mq_send_impl (struct GNUNET_MQ_Handle *mq,
* @param impl_state state of the implementation
*/
static void
-cadet_mq_destroy_impl (struct GNUNET_MQ_Handle *mq,
- void *impl_state)
+cadet_mq_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
{
struct GNUNET_CADET_Channel *ch = impl_state;
@@ -489,8 +480,7 @@ cadet_mq_destroy_impl (struct GNUNET_MQ_Handle *mq,
* @param error error code
*/
static void
-cadet_mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
+cadet_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_CADET_Channel *ch = cls;
@@ -503,11 +493,10 @@ cadet_mq_error_handler (void *cls,
else
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "MQ error in communication with CADET: %d\n",
- error);
+ "MQ error in communication with CADET: %d\n",
+ error);
if (NULL != ch->disconnects)
- ch->disconnects (ch->ctx,
- ch);
+ ch->disconnects (ch->ctx, ch);
GNUNET_CADET_channel_destroy (ch);
}
}
@@ -521,8 +510,7 @@ cadet_mq_error_handler (void *cls,
* @param impl_state state specific to the implementation
*/
static void
-cadet_mq_cancel_impl (struct GNUNET_MQ_Handle *mq,
- void *impl_state)
+cadet_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
{
struct GNUNET_CADET_Channel *ch = impl_state;
@@ -545,8 +533,9 @@ cadet_mq_cancel_impl (struct GNUNET_MQ_Handle *mq,
* @param msg A message with the details of the new incoming channel
*/
static void
-handle_channel_created (void *cls,
- const struct GNUNET_CADET_LocalChannelCreateMessage *msg)
+handle_channel_created (
+ void *cls,
+ const struct GNUNET_CADET_LocalChannelCreateMessage *msg)
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Channel *ch;
@@ -561,8 +550,7 @@ handle_channel_created (void *cls,
GNUNET_break (0);
return;
}
- port = find_port (h,
- port_number);
+ port = find_port (h, port_number);
if (NULL == port)
{
/* We could have closed the port but the service didn't know about it yet
@@ -575,16 +563,14 @@ handle_channel_created (void *cls,
"No handler for incoming channel %X (on port %s, recently closed?)\n",
ntohl (ccn.channel_of_client),
GNUNET_h2s (port_number));
- env = GNUNET_MQ_msg (d_msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
+ env =
+ GNUNET_MQ_msg (d_msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
d_msg->ccn = msg->ccn;
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_MQ_send (h->mq, env);
return;
}
- ch = create_channel (h,
- &ccn);
+ ch = create_channel (h, &ccn);
ch->peer = msg->peer;
ch->incoming_port = port;
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -603,11 +589,8 @@ handle_channel_created (void *cls,
port->handlers,
&cadet_mq_error_handler,
ch);
- ch->ctx = port->connects (port->cls,
- ch,
- &msg->peer);
- GNUNET_MQ_set_handlers_closure (ch->mq,
- ch->ctx);
+ ch->ctx = port->connects (port->cls, ch, &msg->peer);
+ GNUNET_MQ_set_handlers_closure (ch->mq, ch->ctx);
}
@@ -618,14 +601,14 @@ handle_channel_created (void *cls,
* @param msg A message with the details of the channel being destroyed
*/
static void
-handle_channel_destroy (void *cls,
- const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
+handle_channel_destroy (
+ void *cls,
+ const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Channel *ch;
- ch = find_channel (h,
- msg->ccn);
+ ch = find_channel (h, msg->ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -649,8 +632,7 @@ handle_channel_destroy (void *cls,
* #GNUNET_SYSERR otherwise
*/
static int
-check_local_data (void *cls,
- const struct GNUNET_CADET_LocalData *message)
+check_local_data (void *cls, const struct GNUNET_CADET_LocalData *message)
{
uint16_t size;
@@ -672,8 +654,7 @@ check_local_data (void *cls,
* @param message A message encapsulating the data
*/
static void
-handle_local_data (void *cls,
- const struct GNUNET_CADET_LocalData *message)
+handle_local_data (void *cls, const struct GNUNET_CADET_LocalData *message)
{
struct GNUNET_CADET_Handle *h = cls;
const struct GNUNET_MessageHeader *payload;
@@ -681,8 +662,7 @@ handle_local_data (void *cls,
uint16_t type;
int fwd;
- ch = find_channel (h,
- message->ccn);
+ ch = find_channel (h, message->ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -700,8 +680,7 @@ handle_local_data (void *cls,
GNUNET_i2s (&ch->peer),
ntohl (message->ccn.channel_of_client),
type);
- GNUNET_MQ_inject_message (ch->mq,
- payload);
+ GNUNET_MQ_inject_message (ch->mq, payload);
}
@@ -713,14 +692,12 @@ handle_local_data (void *cls,
* @param message Message itself.
*/
static void
-handle_local_ack (void *cls,
- const struct GNUNET_CADET_LocalAck *message)
+handle_local_ack (void *cls, const struct GNUNET_CADET_LocalAck *message)
{
struct GNUNET_CADET_Handle *h = cls;
struct GNUNET_CADET_Channel *ch;
- ch = find_channel (h,
- message->ccn);
+ ch = find_channel (h, message->ccn);
if (NULL == ch)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -745,9 +722,7 @@ handle_local_ack (void *cls,
}
if (NULL != ch->mq_cont)
return; /* already working on it! */
- ch->mq_cont
- = GNUNET_SCHEDULER_add_now (&cadet_mq_send_now,
- ch);
+ ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_now, ch);
}
@@ -761,9 +736,7 @@ handle_local_ack (void *cls,
* @return #GNUNET_OK (continue to iterate)
*/
static int
-destroy_channel_cb (void *cls,
- uint32_t cid,
- void *value)
+destroy_channel_cb (void *cls, uint32_t cid, void *value)
{
/* struct GNUNET_CADET_Handle *handle = cls; */
struct GNUNET_CADET_Channel *ch = value;
@@ -771,7 +744,7 @@ destroy_channel_cb (void *cls,
(void) cls;
(void) cid;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Destroying channel due to GNUNET_CADET_disconnect()\n");
+ "Destroying channel due to GNUNET_CADET_disconnect()\n");
destroy_channel (ch);
return GNUNET_OK;
}
@@ -786,23 +759,17 @@ destroy_channel_cb (void *cls,
* @param error error code
*/
static void
-handle_mq_error (void *cls,
- enum GNUNET_MQ_Error error)
+handle_mq_error (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_CADET_Handle *h = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MQ ERROR: %u\n",
- error);
- GNUNET_CONTAINER_multihashmap32_iterate (h->channels,
- &destroy_channel_cb,
- h);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MQ ERROR: %u\n", error);
+ GNUNET_CONTAINER_multihashmap32_iterate (h->channels, &destroy_channel_cb, h);
GNUNET_MQ_destroy (h->mq);
h->mq = NULL;
GNUNET_assert (NULL == h->reconnect_task);
- h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time,
- &reconnect_cbk,
- h);
+ h->reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (h->reconnect_time, &reconnect_cbk, h);
}
@@ -815,32 +782,28 @@ handle_mq_error (void *cls,
static void
reconnect (struct GNUNET_CADET_Handle *h)
{
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (channel_created,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE,
- struct GNUNET_CADET_LocalChannelCreateMessage,
- h),
- GNUNET_MQ_hd_fixed_size (channel_destroy,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY,
- struct GNUNET_CADET_LocalChannelDestroyMessage,
- h),
- GNUNET_MQ_hd_var_size (local_data,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
- struct GNUNET_CADET_LocalData,
- h),
- GNUNET_MQ_hd_fixed_size (local_ack,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
- struct GNUNET_CADET_LocalAck,
- h),
- GNUNET_MQ_handler_end ()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_fixed_size (channel_created,
+ GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE,
+ struct GNUNET_CADET_LocalChannelCreateMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (channel_destroy,
+ GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY,
+ struct GNUNET_CADET_LocalChannelDestroyMessage,
+ h),
+ GNUNET_MQ_hd_var_size (local_data,
+ GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
+ struct GNUNET_CADET_LocalData,
+ h),
+ GNUNET_MQ_hd_fixed_size (local_ack,
+ GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
+ struct GNUNET_CADET_LocalAck,
+ h),
+ GNUNET_MQ_handler_end ()};
GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connect (h->cfg,
- "cadet",
- handlers,
- &handle_mq_error,
- h);
+ h->mq =
+ GNUNET_CLIENT_connect (h->cfg, "cadet", handlers, &handle_mq_error, h);
}
@@ -854,9 +817,7 @@ reconnect (struct GNUNET_CADET_Handle *h)
* @return #GNUNET_OK (continue to iterate)
*/
static int
-destroy_port_cb (void *cls,
- const struct GNUNET_HashCode *id,
- void *value)
+destroy_port_cb (void *cls, const struct GNUNET_HashCode *id, void *value)
{
/* struct GNUNET_CADET_Handle *handle = cls; */
struct GNUNET_CADET_Port *port = value;
@@ -914,20 +875,17 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
void
GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
{
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports,
- &p->id,
- p));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, &p->id, p));
if (NULL != p->cadet->mq)
{
struct GNUNET_CADET_PortMessage *msg;
struct GNUNET_MQ_Envelope *env;
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
msg->port = p->id;
- GNUNET_MQ_send (p->cadet->mq,
- env);
+ GNUNET_MQ_send (p->cadet->mq, env);
}
GNUNET_free_non_null (p->handlers);
GNUNET_free (p);
@@ -952,14 +910,12 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
if (NULL != h->mq)
{
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
msg->ccn = channel->ccn;
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_MQ_send (h->mq, env);
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Destroying channel due to GNUNET_CADET_channel_destroy()\n");
+ "Destroying channel due to GNUNET_CADET_channel_destroy()\n");
channel->disconnects = NULL;
destroy_channel (channel);
}
@@ -993,14 +949,12 @@ GNUNET_CADET_receive_done (struct GNUNET_CADET_Channel *channel)
struct GNUNET_CADET_LocalAck *msg;
struct GNUNET_MQ_Envelope *env;
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending ACK on channel %X\n",
ntohl (channel->ccn.channel_of_client));
msg->ccn = channel->ccn;
- GNUNET_MQ_send (channel->cadet->mq,
- env);
+ GNUNET_MQ_send (channel->cadet->mq, env);
}
@@ -1016,12 +970,10 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_CADET_Handle *h;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "GNUNET_CADET_connect()\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CADET_connect()\n");
h = GNUNET_new (struct GNUNET_CADET_Handle);
h->cfg = cfg;
- h->ports = GNUNET_CONTAINER_multihashmap_create (4,
- GNUNET_YES);
+ h->ports = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_YES);
h->channels = GNUNET_CONTAINER_multihashmap32_create (4);
reconnect (h);
if (NULL == h->mq)
@@ -1051,7 +1003,7 @@ struct GNUNET_CADET_Port *
GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
const struct GNUNET_HashCode *port,
GNUNET_CADET_ConnectEventHandler connects,
- void * connects_cls,
+ void *connects_cls,
GNUNET_CADET_WindowSizeEventHandler window_changes,
GNUNET_CADET_DisconnectEventHandler disconnects,
const struct GNUNET_MQ_MessageHandler *handlers)
@@ -1061,17 +1013,17 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
GNUNET_assert (NULL != connects);
GNUNET_assert (NULL != disconnects);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Listening to CADET port %s\n",
- GNUNET_h2s (port));
+ "Listening to CADET port %s\n",
+ GNUNET_h2s (port));
p = GNUNET_new (struct GNUNET_CADET_Port);
p->cadet = h;
p->id = *port;
- if (GNUNET_OK !=
- GNUNET_CONTAINER_multihashmap_put (h->ports,
- &p->id,
- p,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (
+ h->ports,
+ &p->id,
+ p,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
GNUNET_free (p);
return NULL;
@@ -1081,11 +1033,8 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
p->window_changes = window_changes;
p->disconnects = disconnects;
p->handlers = GNUNET_MQ_copy_handlers (handlers);
-
- GNUNET_assert (GNUNET_OK ==
- open_port_cb (h,
- &p->id,
- p));
+
+ GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p));
return p;
}
@@ -1124,11 +1073,10 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
GNUNET_assert (NULL != disconnects);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating channel to peer %s at port %s\n",
- GNUNET_i2s (destination),
- GNUNET_h2s (port));
- ch = create_channel (h,
- NULL);
+ "Creating channel to peer %s at port %s\n",
+ GNUNET_i2s (destination),
+ GNUNET_h2s (port));
+ ch = create_channel (h, NULL);
ch->ctx = channel_cls;
ch->peer = *destination;
ch->window_changes = window_changes;
@@ -1142,17 +1090,14 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
handlers,
&cadet_mq_error_handler,
ch);
- GNUNET_MQ_set_handlers_closure (ch->mq,
- channel_cls);
+ GNUNET_MQ_set_handlers_closure (ch->mq, channel_cls);
/* Request channel creation to service */
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
msg->ccn = ch->ccn;
msg->port = *port;
msg->peer = *destination;
- GNUNET_MQ_send (h->mq,
- env);
+ GNUNET_MQ_send (h->mq, env);
return ch;
}
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index e29330f99..209f7d392 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -32,7 +32,6 @@
* - channel: logical link between two clients, on the same or different peers.
* have properties like reliability.
*/
-
#include "platform.h"
#include "gnunet_util_lib.h"
#include "cadet.h"
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 6381d9097..223677a5b 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -341,6 +341,7 @@ core_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
{
struct PeerRecord *pr = impl_state;
+ (void) mq;
GNUNET_assert (NULL != pr->env);
GNUNET_MQ_discard (pr->env);
pr->env = NULL;
@@ -359,7 +360,8 @@ static void
core_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
{
/* struct PeerRecord *pr = cls; */
-
+ (void) cls;
+ (void) error;
GNUNET_break_op (0);
}
@@ -530,6 +532,7 @@ check_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
uint16_t msize;
const struct GNUNET_MessageHeader *em;
+ (void) cls;
msize = ntohs (ntm->header.size) - sizeof (struct NotifyTrafficMessage);
if (msize < sizeof (struct GNUNET_MessageHeader))
{
diff --git a/src/core/core_api_monitor_peers.c b/src/core/core_api_monitor_peers.c
index 0ebb94d7b..165f741d2 100644
--- a/src/core/core_api_monitor_peers.c
+++ b/src/core/core_api_monitor_peers.c
@@ -54,7 +54,6 @@ struct GNUNET_CORE_MonitorHandle
* Closure for @e peer_cb.
*/
void *peer_cb_cls;
-
};
@@ -77,11 +76,11 @@ reconnect (struct GNUNET_CORE_MonitorHandle *mh);
* @param error error code
*/
static void
-handle_mq_error (void *cls,
- enum GNUNET_MQ_Error error)
+handle_mq_error (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_CORE_MonitorHandle *mh = cls;
+ (void) error;
reconnect (mh);
}
@@ -93,8 +92,7 @@ handle_mq_error (void *cls,
* @param mon_message monitor message
*/
static void
-handle_receive_info (void *cls,
- const struct MonitorNotifyMessage *mon_message)
+handle_receive_info (void *cls, const struct MonitorNotifyMessage *mon_message)
{
struct GNUNET_CORE_MonitorHandle *mh = cls;
@@ -114,24 +112,20 @@ handle_receive_info (void *cls,
static void
reconnect (struct GNUNET_CORE_MonitorHandle *mh)
{
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (receive_info,
- GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY,
- struct MonitorNotifyMessage,
- mh),
- GNUNET_MQ_handler_end ()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_fixed_size (receive_info,
+ GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY,
+ struct MonitorNotifyMessage,
+ mh),
+ GNUNET_MQ_handler_end ()};
struct GNUNET_MQ_Envelope *env;
struct GNUNET_MessageHeader *msg;
if (NULL != mh->mq)
GNUNET_MQ_destroy (mh->mq);
/* FIXME: use backoff? */
- mh->mq = GNUNET_CLIENT_connect (mh->cfg,
- "core",
- handlers,
- &handle_mq_error,
- mh);
+ mh->mq =
+ GNUNET_CLIENT_connect (mh->cfg, "core", handlers, &handle_mq_error, mh);
if (NULL == mh->mq)
return;
/* notify callback about reconnect */
@@ -140,10 +134,8 @@ reconnect (struct GNUNET_CORE_MonitorHandle *mh)
NULL,
GNUNET_CORE_KX_CORE_DISCONNECT,
GNUNET_TIME_UNIT_FOREVER_ABS);
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS);
- GNUNET_MQ_send (mh->mq,
- env);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS);
+ GNUNET_MQ_send (mh->mq, env);
}
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 7180754a9..674da705a 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -48,6 +48,7 @@ static struct GNUNET_CORE_MonitorHandle *mh;
static void
shutdown_task (void *cls)
{
+ (void) cls;
if (NULL != mh)
{
GNUNET_CORE_monitor_stop (mh);
@@ -71,13 +72,13 @@ monitor_cb (void *cls,
enum GNUNET_CORE_KxState state,
struct GNUNET_TIME_Absolute timeout)
{
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
const char *now_str;
const char *state_str;
- if ( ( (NULL == peer) ||
- (GNUNET_CORE_KX_ITERATION_FINISHED == state) ) &&
- (GNUNET_NO == monitor_connections) )
+ (void) cls;
+ if (((NULL == peer) || (GNUNET_CORE_KX_ITERATION_FINISHED == state)) &&
+ (GNUNET_NO == monitor_connections))
{
GNUNET_SCHEDULER_shutdown ();
return;
@@ -87,42 +88,43 @@ monitor_cb (void *cls,
{
case GNUNET_CORE_KX_STATE_DOWN:
/* should never happen, as we immediately send the key */
- state_str = _("fresh connection");
+ state_str = _ ("fresh connection");
break;
case GNUNET_CORE_KX_STATE_KEY_SENT:
- state_str = _("key sent");
+ state_str = _ ("key sent");
break;
case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
- state_str = _("key received");
+ state_str = _ ("key received");
break;
case GNUNET_CORE_KX_STATE_UP:
- state_str = _("connection established");
+ state_str = _ ("connection established");
break;
case GNUNET_CORE_KX_STATE_REKEY_SENT:
- state_str = _("rekeying");
+ state_str = _ ("rekeying");
break;
case GNUNET_CORE_KX_PEER_DISCONNECT:
- state_str = _("disconnected");
+ state_str = _ ("disconnected");
break;
case GNUNET_CORE_KX_ITERATION_FINISHED:
return;
case GNUNET_CORE_KX_CORE_DISCONNECT:
FPRINTF (stderr,
"%s\n",
- _("Connection to CORE service lost (reconnecting)"));
+ _ ("Connection to CORE service lost (reconnecting)"));
return;
default:
- state_str = _("unknown state");
+ state_str = _ ("unknown state");
break;
}
now_str = GNUNET_STRINGS_absolute_time_to_string (now);
FPRINTF (stdout,
- _("%24s: %-30s %4s (timeout in %6s)\n"),
+ _ ("%24s: %-30s %4s (timeout in %6s)\n"),
now_str,
state_str,
GNUNET_i2s (peer),
- GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (timeout),
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (
+ GNUNET_TIME_absolute_get_remaining (timeout),
+ GNUNET_YES));
}
@@ -135,24 +137,22 @@ monitor_cb (void *cls,
* @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;
if (NULL != args[0])
{
- FPRINTF (stderr,
- _("Invalid command line argument `%s'\n"),
- args[0]);
+ FPRINTF (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
return;
}
- mh = GNUNET_CORE_monitor_start (cfg,
- &monitor_cb,
- NULL);
+ mh = GNUNET_CORE_monitor_start (cfg, &monitor_cb, NULL);
if (NULL == mh)
{
- FPRINTF (stderr,
- "%s",
- _("Failed to connect to CORE service!\n"));
+ FPRINTF (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
return;
}
GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
@@ -167,24 +167,28 @@ run (void *cls, char *const *args, const char *cfgfile,
* @return 0 ok, 1 on error
*/
int
-main (int argc,
- char *const *argv)
+main (int argc, char *const *argv)
{
int res;
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_flag ('m',
- "monitor",
- gettext_noop ("provide information about all current connections (continuously)"),
- &monitor_connections),
- GNUNET_GETOPT_OPTION_END
- };
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {GNUNET_GETOPT_option_flag (
+ 'm',
+ "monitor",
+ gettext_noop (
+ "provide information about all current connections (continuously)"),
+ &monitor_connections),
+ GNUNET_GETOPT_OPTION_END};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- res = GNUNET_PROGRAM_run (argc, argv, "gnunet-core",
- gettext_noop
- ("Print information about connected peers."),
- options, &run, NULL);
+ res = GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-core",
+ gettext_noop (
+ "Print information about connected peers."),
+ options,
+ &run,
+ NULL);
GNUNET_free ((void *) argv);
if (GNUNET_OK == res)
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 0a68e7cba..932b8d218 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -81,7 +81,7 @@ noinst_PROGRAMS = \
gnunet-gns-benchmark
pkgdata_DATA = \
- openssl.cnf
+ gnunet-gns-proxy-ca.template
if HAVE_MHD
if LINUX
diff --git a/src/gns/gnunet-gns-proxy-ca.template b/src/gns/gnunet-gns-proxy-ca.template
new file mode 100644
index 000000000..32ee27fcd
--- /dev/null
+++ b/src/gns/gnunet-gns-proxy-ca.template
@@ -0,0 +1,303 @@
+# X.509 Certificate options
+#
+# DN options
+
+# The organization of the subject.
+organization = "GNU"
+
+# The organizational unit of the subject.
+unit = "GNUnet"
+
+# The locality of the subject.
+locality = World
+
+# The state of the certificate owner.
+# state = "Attiki"
+
+# The country of the subject. Two letter code.
+country = ZZ
+
+# The common name of the certificate owner.
+cn = "GNS Proxy CA"
+
+# A user id of the certificate owner.
+#uid = "clauper"
+
+# Set domain components
+#dc = "name"
+#dc = "domain"
+
+# If the supported DN OIDs are not adequate you can set
+# any OID here.
+# For example set the X.520 Title and the X.520 Pseudonym
+# by using OID and string pairs.
+#dn_oid = "2.5.4.12 Dr."
+#dn_oid = "2.5.4.65 jackal"
+
+# This is deprecated and should not be used in new
+# certificates.
+# pkcs9_email = "none@none.org"
+
+# An alternative way to set the certificate's distinguished name directly
+# is with the "dn" option. The attribute names allowed are:
+# C (country), street, O (organization), OU (unit), title, CN (common name),
+# L (locality), ST (state), placeOfBirth, gender, countryOfCitizenship,
+# countryOfResidence, serialNumber, telephoneNumber, surName, initials,
+# generationQualifier, givenName, pseudonym, dnQualifier, postalCode, name,
+# businessCategory, DC, UID, jurisdictionOfIncorporationLocalityName,
+# jurisdictionOfIncorporationStateOrProvinceName,
+# jurisdictionOfIncorporationCountryName, XmppAddr, and numeric OIDs.
+
+#dn = "cn = Nikos,st = New\, Something,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias"
+
+# The serial number of the certificate
+# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
+# Comment the field for a random serial number.
+#serial = 007
+
+# In how many days, counting from today, this certificate will expire.
+# Use -1 if there is no expiration date.
+expiration_days = 3650
+
+# Alternatively you may set concrete dates and time. The GNU date string
+# formats are accepted. See:
+# https://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html
+
+#activation_date = "2004-02-29 16:21:42"
+#expiration_date = "2025-02-29 16:24:41"
+
+# X.509 v3 extensions
+
+# A dnsname in case of a WWW server.
+#dns_name = "www.none.org"
+#dns_name = "www.morethanone.org"
+
+# An othername defined by an OID and a hex encoded string
+#other_name = "1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e"
+#other_name_utf8 = "1.2.4.5.6 A UTF8 string"
+#other_name_octet = "1.2.4.5.6 A string that will be encoded as ASN.1 octet string"
+
+# Allows writing an XmppAddr Identifier
+#xmpp_name = juliet@im.example.com
+
+# Names used in PKINIT
+#krb5_principal = user@REALM.COM
+#krb5_principal = HTTP/user@REALM.COM
+
+# A subject alternative name URI
+#uri = "https://www.example.com"
+
+# An IP address in case of a server.
+#ip_address = "192.168.1.1"
+
+# An email in case of a person
+email = "bounce@gnunet.org"
+
+# TLS feature (rfc7633) extension. That can is used to indicate mandatory TLS
+# extension features to be provided by the server. In practice this is used
+# to require the Status Request (extid: 5) extension from the server. That is,
+# to require the server holding this certificate to provide a stapled OCSP response.
+# You can have multiple lines for multiple TLS features.
+
+# To ask for OCSP status request use:
+#tls_feature = 5
+
+# Challenge password used in certificate requests
+challenge_password = 123456
+
+# Password when encrypting a private key
+#password = secret
+
+# An URL that has CRLs (certificate revocation lists)
+# available. Needed in CA certificates.
+#crl_dist_points = "https://www.getcrl.crl/getcrl/"
+
+# Whether this is a CA certificate or not
+ca
+
+# Subject Unique ID (in hex)
+#subject_unique_id = 00153224
+
+# Issuer Unique ID (in hex)
+#issuer_unique_id = 00153225
+
+#### Key usage
+
+# The following key usage flags are used by CAs and end certificates
+
+# Whether this certificate will be used to sign data (needed
+# in TLS DHE ciphersuites). This is the digitalSignature flag
+# in RFC5280 terminology.
+signing_key
+
+# Whether this certificate will be used to encrypt data (needed
+# in TLS RSA ciphersuites). Note that it is preferred to use different
+# keys for encryption and signing. This is the keyEncipherment flag
+# in RFC5280 terminology.
+encryption_key
+
+# Whether this key will be used to sign other certificates. The
+# keyCertSign flag in RFC5280 terminology.
+cert_signing_key
+
+# Whether this key will be used to sign CRLs. The
+# cRLSign flag in RFC5280 terminology.
+#crl_signing_key
+
+# The keyAgreement flag of RFC5280. It's purpose is loosely
+# defined. Not use it unless required by a protocol.
+#key_agreement
+
+# The dataEncipherment flag of RFC5280. It's purpose is loosely
+# defined. Not use it unless required by a protocol.
+#data_encipherment
+
+# The nonRepudiation flag of RFC5280. It's purpose is loosely
+# defined. Not use it unless required by a protocol.
+#non_repudiation
+
+#### Extended key usage (key purposes)
+
+# The following extensions are used in an end certificate
+# to clarify its purpose. Some CAs also use it to indicate
+# the types of certificates they are purposed to sign.
+
+
+# Whether this certificate will be used for a TLS client;
+# this sets the id-kp-clientAuth (1.3.6.1.5.5.7.3.2) of
+# extended key usage.
+#tls_www_client
+
+# Whether this certificate will be used for a TLS server;
+# this sets the id-kp-serverAuth (1.3.6.1.5.5.7.3.1) of
+# extended key usage.
+tls_www_server
+
+# Whether this key will be used to sign code. This sets the
+# id-kp-codeSigning (1.3.6.1.5.5.7.3.3) of extended key usage
+# extension.
+#code_signing_key
+
+# Whether this key will be used to sign OCSP data. This sets the
+# id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) of extended key usage extension.
+#ocsp_signing_key
+
+# Whether this key will be used for time stamping. This sets the
+# id-kp-timeStamping (1.3.6.1.5.5.7.3.8) of extended key usage extension.
+#time_stamping_key
+
+# Whether this key will be used for email protection. This sets the
+# id-kp-emailProtection (1.3.6.1.5.5.7.3.4) of extended key usage extension.
+#email_protection_key
+
+# Whether this key will be used for IPsec IKE operations (1.3.6.1.5.5.7.3.17).
+#ipsec_ike_key
+
+## adding custom key purpose OIDs
+
+# for microsoft smart card logon
+# key_purpose_oid = 1.3.6.1.4.1.311.20.2.2
+
+# for email protection
+# key_purpose_oid = 1.3.6.1.5.5.7.3.4
+
+# for any purpose (must not be used in intermediate CA certificates)
+# key_purpose_oid = 2.5.29.37.0
+
+### end of key purpose OIDs
+
+### Adding arbitrary extensions
+# This requires to provide the extension OIDs, as well as the extension data in
+# hex format. The following two options are available since GnuTLS 3.5.3.
+#add_extension = "1.2.3.4 0x0AAB01ACFE"
+
+# As above but encode the data as an octet string
+#add_extension = "1.2.3.4 octet_string(0x0AAB01ACFE)"
+
+# For portability critical extensions shouldn't be set to certificates.
+#add_critical_extension = "5.6.7.8 0x1AAB01ACFE"
+
+# When generating a certificate from a certificate
+# request, then honor the extensions stored in the request
+# and store them in the real certificate.
+#honor_crq_extensions
+
+# Alternatively only specific extensions can be copied.
+#honor_crq_ext = 2.5.29.17
+#honor_crq_ext = 2.5.29.15
+
+# Path length contraint. Sets the maximum number of
+# certificates that can be used to certify this certificate.
+# (i.e. the certificate chain length)
+#path_len = -1
+#path_len = 2
+
+# OCSP URI
+# ocsp_uri = https://my.ocsp.server/ocsp
+
+# CA issuers URI
+# ca_issuers_uri = https://my.ca.issuer
+
+# Certificate policies
+#policy1 = 1.3.6.1.4.1.5484.1.10.99.1.0
+#policy1_txt = "This is a long policy to summarize"
+#policy1_url = https://www.example.com/a-policy-to-read
+
+#policy2 = 1.3.6.1.4.1.5484.1.10.99.1.1
+#policy2_txt = "This is a short policy"
+#policy2_url = https://www.example.com/another-policy-to-read
+
+# The number of additional certificates that may appear in a
+# path before the anyPolicy is no longer acceptable.
+#inhibit_anypolicy_skip_certs 1
+
+# Name constraints
+
+# DNS
+#nc_permit_dns = example.com
+#nc_exclude_dns = test.example.com
+
+# EMAIL
+#nc_permit_email = "nmav@ex.net"
+
+# Exclude subdomains of example.com
+#nc_exclude_email = .example.com
+
+# Exclude all e-mail addresses of example.com
+#nc_exclude_email = example.com
+
+# IP
+#nc_permit_ip = 192.168.0.0/16
+#nc_exclude_ip = 192.168.5.0/24
+#nc_permit_ip = fc0a:eef2:e7e7:a56e::/64
+
+
+# Options for proxy certificates
+#proxy_policy_language = 1.3.6.1.5.5.7.21.1
+
+
+# Options for generating a CRL
+
+# The number of days the next CRL update will be due.
+# next CRL update will be in 43 days
+#crl_next_update = 43
+
+# this is the 5th CRL by this CA
+# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
+# Comment the field for a time-based number.
+# Time-based CRL numbers generated in GnuTLS 3.6.3 and later
+# are significantly larger than those generated in previous
+# versions. Since CRL numbers need to be monotonic, you need
+# to specify the CRL number here manually if you intend to
+# downgrade to an earlier version than 3.6.3 after publishing
+# the CRL as it is not possible to specify CRL numbers greater
+# than 2**63-2 using hex notation in those versions.
+#crl_number = 5
+
+# Specify the update dates more precisely.
+#crl_this_update_date = "2004-02-29 16:21:42"
+#crl_next_update_date = "2025-02-29 16:24:41"
+
+# The date that the certificates will be made seen as
+# being revoked.
+#crl_revocation_date = "2025-02-29 16:24:41"
diff --git a/src/gns/gnunet-gns-proxy-setup-ca.in b/src/gns/gnunet-gns-proxy-setup-ca.in
index cd5d8c70f..b19b6c001 100644
--- a/src/gns/gnunet-gns-proxy-setup-ca.in
+++ b/src/gns/gnunet-gns-proxy-setup-ca.in
@@ -133,13 +133,29 @@ generate_ca()
# ------------- openssl
+ GNUTLS_CA_TEMPLATE=@pkgdatadir@/gnunet-gns-proxy-ca.template
OPENSSLCFG=@pkgdatadir@/openssl.cnf
- if test -z "`openssl version`" > /dev/null
+ CERTTOOL=""
+ OPENSSL=0
+ if test -z "`gnutls-certtool --version`" > /dev/null
then
- warningmsg "'openssl' command not found. Please install it."
- infomsg "Cleaning up."
- rm -f $GNSCAKY $GNSCANO $GNSCERT
- exit 1
+ # We only support gnutls certtool for now
+ if test -z "`certtool --version | grep gnutls`" > /dev/null
+ then
+ warningmsg "'gnutls-certtool' or 'certtool' command not found. Trying openssl."
+ if test -z "`openssl version`" > /dev/null
+ then
+ $OPENSSL=1
+ else
+ warningmsg "Install either gnutls certtool or openssl for certificate generation!"
+ infomsg "Cleaning up."
+ rm -f $GNSCAKY $GNSCERT
+ exit 1
+ fi
+ fi
+ CERTTOOL="certtool"
+ else
+ CERTTOOL="gnutls-certtool"
fi
if [ -n "${GNUNET_CONFIG_FILE}" ]; then
GNUNET_CONFIG="-c ${GNUNET_CONFIG_FILE}"
@@ -149,13 +165,18 @@ generate_ca()
GNS_CA_CERT_PEM=`gnunet-config ${GNUNET_CONFIG} -s gns-proxy -o PROXY_CACERT -f ${options}`
mkdir -p `dirname $GNS_CA_CERT_PEM`
- openssl req -config $OPENSSLCFG -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System"
-
- infomsg "Removing passphrase from key"
- openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
-
- infomsg "Making private key available to gnunet-gns-proxy"
- cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
+ if test 1 -eq $OPENSSL
+ then
+ openssl req -config $OPENSSLCFG -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System"
+ infomsg "Removing passphrase from key"
+ openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO
+ cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
+ else
+ $CERTTOOL --generate-privkey --outfile $GNSCAKY
+ $CERTTOOL --template $GNUTLS_CA_TEMPLATE --generate-self-signed --load-privkey $GNSCAKY --outfile $GNSCERT
+ infomsg "Making private key available to gnunet-gns-proxy"
+ cat $GNSCERT $GNSCAKY > $GNS_CA_CERT_PEM
+ fi
}
importbrowsers()
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index ddeeffef4..1e99c63d0 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -33,9 +33,8 @@
#define GNUNET_GETOPT_LIB_H
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
@@ -77,7 +76,6 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
* Current argument.
*/
unsigned int currentArgument;
-
};
@@ -90,12 +88,11 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
* @param value argument, NULL if none was given
* @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort
*/
-typedef int
-(*GNUNET_GETOPT_CommandLineOptionProcessor) (struct
- GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value);
+typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (
+ struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value);
/**
@@ -136,6 +133,11 @@ struct GNUNET_GETOPT_CommandLineOption
int option_mandatory;
/**
+ * Is the option exclusive?
+ */
+ int option_exclusive;
+
+ /**
* Handler for the option.
*/
GNUNET_GETOPT_CommandLineOptionProcessor processor;
@@ -144,13 +146,12 @@ struct GNUNET_GETOPT_CommandLineOption
* Function to call on @e scls to clean up after processing all
* the arguments. Can be NULL.
*/
- void (*cleaner)(void *cls);
+ void (*cleaner) (void *cls);
/**
* Specific closure to pass to the processor.
*/
void *scls;
-
};
@@ -174,7 +175,6 @@ struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_version (const char *version);
-
/**
* Allow user to specify log file name (-l option)
*
@@ -249,8 +249,17 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
* @param[out] val binary value decoded from Crockford Base32-encoded argument;
* size is determined by type (sizeof (*val)).
*/
-#define GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \
- GNUNET_GETOPT_option_base32_fixed_size(shortName,name,argumentHelp,description,val,sizeof(*val))
+#define GNUNET_GETOPT_option_base32_auto(shortName, \
+ name, \
+ argumentHelp, \
+ description, \
+ val) \
+ GNUNET_GETOPT_option_base32_fixed_size (shortName, \
+ name, \
+ argumentHelp, \
+ description, \
+ val, \
+ sizeof (*val))
/**
@@ -297,10 +306,10 @@ GNUNET_GETOPT_option_uint (char shortName,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_uint16 (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- uint16_t *val);
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ uint16_t *val);
/**
@@ -421,10 +430,22 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
/**
+ * Make the given option mutually exclusive with other options.
+ *
+ * @param opt option to modify
+ * @return @a opt with the exclusive flag set.
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt);
+
+
+/**
* Marker for the end of the list of options.
*/
-#define GNUNET_GETOPT_OPTION_END \
- { '\0', NULL, NULL, NULL, 0, 0, NULL, NULL, NULL }
+#define GNUNET_GETOPT_OPTION_END \
+ { \
+ '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
+ }
/**
@@ -444,7 +465,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
char *const *argv);
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 26b5a704b..5d292525e 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1647,6 +1647,7 @@ main (int argc, char *const *argv)
"name of the ego controlling the zone"),
&ego_name),
GNUNET_GETOPT_OPTION_END};
+ int lret;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
@@ -1654,17 +1655,18 @@ main (int argc, char *const *argv)
is_public = -1;
is_shadow = -1;
GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
- if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-namestore",
- _ ("GNUnet zone manipulation tool"),
- options,
- &run,
- NULL))
+ if (GNUNET_OK !=
+ (lret = GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-namestore",
+ _ ("GNUnet zone manipulation tool"),
+ options,
+ &run,
+ NULL)))
{
GNUNET_free ((void *) argv);
GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
- return 1;
+ return lret;
}
GNUNET_free ((void *) argv);
GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index d2a09087e..4d23b91c6 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -23,12 +23,6 @@
* @brief namestore for the GNUnet naming system
* @author Matthias Wachs
* @author Christian Grothoff
- *
- * TODO:
- * - "get_nick_record" is a bottleneck, introduce a cache to
- * avoid looking it up again and again (for the same few
- * zones that the user will typically manage!)
- * - run testcases, make sure everything works!
*/
#include "platform.h"
#include "gnunet_util_lib.h"
@@ -562,13 +556,20 @@ cache_nick (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
}
GNUNET_free_non_null (oldest->rd);
oldest->zone = *zone;
- oldest->rd = GNUNET_malloc (sizeof (*nick) +
- nick->data_size);
- *oldest->rd = *nick;
- oldest->rd->data = &oldest->rd[1];
- memcpy (&oldest->rd[1],
- nick->data,
- nick->data_size);
+ if (NULL != nick)
+ {
+ oldest->rd = GNUNET_malloc (sizeof (*nick) +
+ nick->data_size);
+ *oldest->rd = *nick;
+ oldest->rd->data = &oldest->rd[1];
+ memcpy (&oldest->rd[1],
+ nick->data,
+ nick->data_size);
+ }
+ else
+ {
+ oldest->rd = NULL;
+ }
oldest->last_used = GNUNET_TIME_absolute_get ();
}
@@ -592,8 +593,10 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
struct NickCache *pos = &nick_cache[i];
if ( (NULL != pos->rd) &&
(0 == GNUNET_memcmp (zone,
- &pos->zone)) )
+ &pos->zone)) )
{
+ if (NULL == pos->rd)
+ return NULL;
nick = GNUNET_malloc (sizeof (*nick) +
pos->rd->data_size);
*nick = *pos->rd;
@@ -615,10 +618,25 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
if ( (GNUNET_OK != res) ||
(NULL == nick) )
{
- GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "No nick name set for zone `%s'\n",
- GNUNET_GNSRECORD_z2s (&pub));
+ static int do_log = GNUNET_LOG_CALL_STATUS;
+
+ if (0 == do_log)
+ do_log
+ = GNUNET_get_log_call_status (GNUNET_ERROR_TYPE_DEBUG,
+ "namestore",
+ __FILE__,
+ __FUNCTION__,
+ __LINE__);
+ if (1 == do_log)
+ {
+ GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "No nick name set for zone `%s'\n",
+ GNUNET_GNSRECORD_z2s (&pub));
+ }
+ /* update cache */
+ cache_nick (zone,
+ NULL);
return NULL;
}
@@ -1603,8 +1621,10 @@ handle_record_store (void *cls,
#GNUNET_GNS_EMPTY_LABEL_AT label */
struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL(rd_count)];
unsigned int rd_clean_off;
+ int have_nick;
rd_clean_off = 0;
+ have_nick = GNUNET_NO;
for (unsigned int i=0;i<rd_count;i++)
{
rd_clean[rd_clean_off] = rd[i];
@@ -1616,8 +1636,19 @@ handle_record_store (void *cls,
if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT,
conv_name)) &&
(GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) )
+ {
cache_nick (&rp_msg->private_key,
&rd[i]);
+ have_nick = GNUNET_YES;
+ }
+ }
+ if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT,
+ conv_name)) &&
+ (GNUNET_NO == have_nick) )
+ {
+ /* remove nick record from cache, in case we have one there */
+ cache_nick (&rp_msg->private_key,
+ NULL);
}
res = GSN_database->store_records (GSN_database->cls,
&rp_msg->private_key,
diff --git a/src/nse/gnunet-nse.c b/src/nse/gnunet-nse.c
index bf2fe11c3..c8ffa152e 100644
--- a/src/nse/gnunet-nse.c
+++ b/src/nse/gnunet-nse.c
@@ -46,6 +46,7 @@ static int status;
static void
do_shutdown (void *cls)
{
+ (void) cls;
if (NULL != nse)
{
GNUNET_NSE_disconnect (nse);
@@ -65,12 +66,14 @@ do_shutdown (void *cls)
*/
static void
handle_estimate (void *cls,
- struct GNUNET_TIME_Absolute timestamp,
+ struct GNUNET_TIME_Absolute timestamp,
double estimate,
- double std_dev)
+ double std_dev)
{
+ (void) cls;
status = 0;
- FPRINTF (stdout, "%llu %f %f %f\n",
+ FPRINTF (stdout,
+ "%llu %f %f %f\n",
(unsigned long long) timestamp.abs_value_us,
GNUNET_NSE_log_estimate_to_n (estimate),
estimate,
@@ -92,11 +95,11 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- nse = GNUNET_NSE_connect (cfg,
- &handle_estimate,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
+ (void) cls;
+ (void) args;
+ (void) cfgfile;
+ nse = GNUNET_NSE_connect (cfg, &handle_estimate, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
@@ -106,22 +109,21 @@ run (void *cls,
* @return 0 on success
*/
int
-main (int argc,
- char *const *argv)
+main (int argc, char *const *argv)
{
static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ GNUNET_GETOPT_OPTION_END};
status = 1;
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-nse",
- gettext_noop
- ("Show network size estimates from NSE service."),
- options,
- &run, NULL))
+ argv,
+ "gnunet-nse",
+ gettext_noop (
+ "Show network size estimates from NSE service."),
+ options,
+ &run,
+ NULL))
return 2;
return status;
}
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 09316dbcf..fd83d2b67 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -430,6 +430,7 @@ handle_start (void *cls, const struct GNUNET_MessageHeader *message)
struct GNUNET_NSE_ClientMessage em;
struct GNUNET_MQ_Envelope *env;
+ (void) message;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
mq = GNUNET_SERVICE_client_get_mq (client);
GNUNET_notification_context_add (nc, mq);
@@ -717,6 +718,8 @@ schedule_current_round (void *cls,
struct NSEPeerEntry *peer_entry = value;
struct GNUNET_TIME_Relative delay;
+ (void) cls;
+ (void) key;
if (NULL != peer_entry->transmit_task)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
@@ -749,8 +752,8 @@ static void
update_flood_message (void *cls)
{
struct GNUNET_TIME_Relative offset;
- unsigned int i;
+ (void) cls;
flood_task = NULL;
offset = GNUNET_TIME_absolute_get_remaining (next_timestamp);
if (0 != offset.rel_value_us)
@@ -780,7 +783,7 @@ update_flood_message (void *cls)
setup_flood_message (estimate_index, current_timestamp);
next_message.matching_bits = htonl (0); /* reset for 'next' round */
hop_count_max = 0;
- for (i = 0; i < HISTORY_SIZE; i++)
+ for (unsigned int i = 0; i < HISTORY_SIZE; i++)
hop_count_max =
GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max);
GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL);
@@ -869,6 +872,7 @@ find_proof (void *cls)
struct GNUNET_HashCode result;
unsigned int i;
+ (void) cls;
proof_task = NULL;
GNUNET_memcpy (&buf[sizeof (uint64_t)],
&my_identity,
@@ -967,6 +971,7 @@ update_flood_times (void *cls,
struct NSEPeerEntry *peer_entry = value;
struct GNUNET_TIME_Relative delay;
+ (void) key;
if (peer_entry == exclude)
return GNUNET_OK; /* trigger of the update */
if (GNUNET_NO == peer_entry->previous_round)
@@ -1178,6 +1183,7 @@ handle_core_connect (void *cls,
{
struct NSEPeerEntry *peer_entry;
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' connected to us\n",
GNUNET_i2s (peer));
@@ -1217,6 +1223,7 @@ handle_core_disconnect (void *cls,
{
struct NSEPeerEntry *pos = internal_cls;
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected from us\n",
GNUNET_i2s (peer));
@@ -1243,6 +1250,8 @@ handle_core_disconnect (void *cls,
static void
flush_comp_cb (void *cls, size_t size)
{
+ (void) cls;
+ (void) size;
GNUNET_TESTBED_LOGGER_disconnect (lh);
lh = NULL;
}
@@ -1257,6 +1266,7 @@ flush_comp_cb (void *cls, size_t size)
static void
shutdown_task (void *cls)
{
+ (void) cls;
if (NULL != flood_task)
{
GNUNET_SCHEDULER_cancel (flood_task);
@@ -1324,6 +1334,7 @@ core_init (void *cls, const struct GNUNET_PeerIdentity *identity)
struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Absolute prev_time;
+ (void) cls;
if (NULL == identity)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n");
@@ -1365,6 +1376,7 @@ core_init (void *cls, const struct GNUNET_PeerIdentity *identity)
static void
status_cb (void *cls, int status)
{
+ (void) cls;
logger_test = NULL;
if (GNUNET_YES != status)
{
@@ -1402,6 +1414,8 @@ run (void *cls,
char *proof;
struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
+ (void) cls;
+ (void) service;
cfg = c;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg,
"NSE",
@@ -1524,6 +1538,8 @@ client_connect_cb (void *cls,
struct GNUNET_SERVICE_Client *c,
struct GNUNET_MQ_Handle *mq)
{
+ (void) cls;
+ (void) mq;
return c;
}
@@ -1540,6 +1556,7 @@ client_disconnect_cb (void *cls,
struct GNUNET_SERVICE_Client *c,
void *internal_cls)
{
+ (void) cls;
GNUNET_assert (c == internal_cls);
}
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c
index e9eaada93..259be75ed 100644
--- a/src/nse/nse_api.c
+++ b/src/nse/nse_api.c
@@ -32,7 +32,7 @@
#include "gnunet_nse_service.h"
#include "nse.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "nse-api", __VA_ARGS__)
/**
* Handle for talking with the NSE service.
@@ -68,7 +68,6 @@ struct GNUNET_NSE_Handle
* Closure to pass to @e recv_cb callback.
*/
void *recv_cb_cls;
-
};
@@ -91,17 +90,15 @@ reconnect (void *cls);
* @param error error code
*/
static void
-mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_NSE_Handle *h = cls;
+ (void) error;
GNUNET_MQ_destroy (h->mq);
h->mq = NULL;
- h->reconnect_task
- = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
- &reconnect,
- h);
+ h->reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
}
@@ -114,8 +111,7 @@ mq_error_handler (void *cls,
* @param client_msg message received
*/
static void
-handle_estimate (void *cls,
- const struct GNUNET_NSE_ClientMessage *client_msg)
+handle_estimate (void *cls, const struct GNUNET_NSE_ClientMessage *client_msg)
{
struct GNUNET_NSE_Handle *h = cls;
@@ -123,7 +119,7 @@ handle_estimate (void *cls,
h->recv_cb (h->recv_cb_cls,
GNUNET_TIME_absolute_ntoh (client_msg->timestamp),
GNUNET_ntoh_double (client_msg->size_estimate),
- GNUNET_ntoh_double (client_msg->std_deviation));
+ GNUNET_ntoh_double (client_msg->std_deviation));
}
@@ -136,13 +132,12 @@ static void
reconnect (void *cls)
{
struct GNUNET_NSE_Handle *h = cls;
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (estimate,
- GNUNET_MESSAGE_TYPE_NSE_ESTIMATE,
- struct GNUNET_NSE_ClientMessage,
- h),
- GNUNET_MQ_handler_end ()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_fixed_size (estimate,
+ GNUNET_MESSAGE_TYPE_NSE_ESTIMATE,
+ struct GNUNET_NSE_ClientMessage,
+ h),
+ GNUNET_MQ_handler_end ()};
struct GNUNET_MessageHeader *msg;
struct GNUNET_MQ_Envelope *env;
@@ -150,17 +145,11 @@ reconnect (void *cls)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to network size estimation service.\n");
GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connect (h->cfg,
- "nse",
- handlers,
- &mq_error_handler,
- h);
+ h->mq = GNUNET_CLIENT_connect (h->cfg, "nse", handlers, &mq_error_handler, h);
if (NULL == h->mq)
return;
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_NSE_START);
- GNUNET_MQ_send (h->mq,
- env);
+ env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NSE_START);
+ GNUNET_MQ_send (h->mq, env);
}
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 8bb5f0587..71eaab87a 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -28,22 +28,23 @@
#include "gnunet_crypto_lib.h"
#include <gcrypt.h>
-#define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-random", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-random", __VA_ARGS__)
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-crypto-random", syscall)
+#define LOG_STRERROR(kind, syscall) \
+ GNUNET_log_from_strerror (kind, "util-crypto-random", syscall)
/* TODO: ndurner, move this to plibc? */
/* The code is derived from glibc, obviously */
-#if !HAVE_RANDOM || !HAVE_SRANDOM
+#if ! HAVE_RANDOM || ! HAVE_SRANDOM
#ifdef RANDOM
#undef RANDOM
#endif
#ifdef SRANDOM
#undef SRANDOM
#endif
-#define RANDOM() glibc_weak_rand32()
-#define SRANDOM(s) glibc_weak_srand32(s)
+#define RANDOM() glibc_weak_rand32 ()
+#define SRANDOM(s) glibc_weak_srand32 (s)
#if defined(RAND_MAX)
#undef RAND_MAX
#endif
@@ -105,17 +106,12 @@ GNUNET_CRYPTO_seed_weak_random (int32_t seed)
* @param length buffer length
*/
void
-GNUNET_CRYPTO_zero_keys (void *buffer,
- size_t length)
+GNUNET_CRYPTO_zero_keys (void *buffer, size_t length)
{
#if HAVE_MEMSET_S
- memset_s (buffer,
- length,
- 0,
- length);
+ memset_s (buffer, length, 0, length);
#elif HAVE_EXPLICIT_BZERO
- explicit_bzero (buffer,
- length);
+ explicit_bzero (buffer, length);
#else
volatile unsigned char *p = buffer;
while (length--)
@@ -175,8 +171,7 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode,
* @return a random value in the interval [0,i[.
*/
uint32_t
-GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
- uint32_t i)
+GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i)
{
#ifdef gcry_fast_random_poll
static unsigned int invokeCount;
@@ -197,18 +192,17 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
ul = UINT32_MAX - (UINT32_MAX % i);
do
{
- gcry_randomize ((unsigned char *) &ret, sizeof (uint32_t),
+ gcry_randomize ((unsigned char *) &ret,
+ sizeof (uint32_t),
GCRY_STRONG_RANDOM);
- }
- while (ret >= ul);
+ } while (ret >= ul);
return ret % i;
case GNUNET_CRYPTO_QUALITY_NONCE:
ul = UINT32_MAX - (UINT32_MAX % i);
do
{
gcry_create_nonce (&ret, sizeof (ret));
- }
- while (ret >= ul);
+ } while (ret >= ul);
return ret % i;
case GNUNET_CRYPTO_QUALITY_WEAK:
ret = i * get_weak_random ();
@@ -231,8 +225,7 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
* @return the permutation array (allocated from heap)
*/
unsigned int *
-GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode,
- unsigned int n)
+GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n)
{
unsigned int *ret;
unsigned int i;
@@ -262,8 +255,7 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode,
* @return random 64-bit number
*/
uint64_t
-GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
- uint64_t max)
+GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max)
{
uint64_t ret;
uint64_t ul;
@@ -275,18 +267,17 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
ul = UINT64_MAX - (UINT64_MAX % max);
do
{
- gcry_randomize ((unsigned char *) &ret, sizeof (uint64_t),
+ gcry_randomize ((unsigned char *) &ret,
+ sizeof (uint64_t),
GCRY_STRONG_RANDOM);
- }
- while (ret >= ul);
+ } while (ret >= ul);
return ret % max;
case GNUNET_CRYPTO_QUALITY_NONCE:
ul = UINT64_MAX - (UINT64_MAX % max);
do
{
gcry_create_nonce (&ret, sizeof (ret));
- }
- while (ret >= ul);
+ } while (ret >= ul);
return ret % max;
case GNUNET_CRYPTO_QUALITY_WEAK:
@@ -319,6 +310,7 @@ w_malloc (size_t n)
static int
w_check (const void *p)
{
+ (void) p;
return 0; /* not secure memory */
}
@@ -326,50 +318,45 @@ w_check (const void *p)
/**
* Initialize libgcrypt.
*/
-void __attribute__ ((constructor))
-GNUNET_CRYPTO_random_init ()
+void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
{
gcry_error_t rc;
if (! gcry_check_version (NEED_LIBGCRYPT_VERSION))
{
- FPRINTF (stderr,
- _("libgcrypt has not the expected version (version %s is required).\n"),
- NEED_LIBGCRYPT_VERSION);
+ FPRINTF (
+ stderr,
+ _ ("libgcrypt has not the expected version (version %s is required).\n"),
+ NEED_LIBGCRYPT_VERSION);
GNUNET_assert (0);
}
/* set custom allocators */
- gcry_set_allocation_handler (&w_malloc,
- &w_malloc,
- &w_check,
- &realloc,
- &free);
+ gcry_set_allocation_handler (&w_malloc, &w_malloc, &w_check, &realloc, &free);
/* Disable use of secure memory */
if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0)))
FPRINTF (stderr,
"Failed to set libgcrypt option %s: %s\n",
"DISABLE_SECMEM",
- gcry_strerror (rc));
+ gcry_strerror (rc));
/* Otherwise gnunet-ecc takes forever to complete, besides
we are fine with "just" using GCRY_STRONG_RANDOM */
if ((rc = gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0)))
FPRINTF (stderr,
- "Failed to set libgcrypt option %s: %s\n",
- "ENABLE_QUICK_RANDOM",
- gcry_strerror (rc));
+ "Failed to set libgcrypt option %s: %s\n",
+ "ENABLE_QUICK_RANDOM",
+ gcry_strerror (rc));
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
gcry_fast_random_poll ();
- GNUNET_CRYPTO_seed_weak_random (time (NULL) ^
- GNUNET_CRYPTO_random_u32
- (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
+ GNUNET_CRYPTO_seed_weak_random (
+ time (NULL) ^
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
}
/**
* Nicely shut down libgcrypt.
*/
-void __attribute__ ((destructor))
-GNUNET_CRYPTO_random_fini ()
+void __attribute__ ((destructor)) GNUNET_CRYPTO_random_fini ()
{
gcry_set_progress_handler (NULL, NULL);
#ifdef GCRYCTL_CLOSE_RANDOM_DEVICE
@@ -378,5 +365,4 @@ GNUNET_CRYPTO_random_fini ()
}
-
/* end of crypto_random.c */
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 5e8571ee5..048f52ee0 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -47,14 +47,15 @@ Copyright (C) 2006, 2017 Christian Grothoff
#endif
#endif
-#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-getopt", syscall)
+#define LOG_STRERROR(kind, syscall) \
+ GNUNET_log_from_strerror (kind, "util-getopt", syscall)
-#if defined (WIN32) && !defined (__CYGWIN32__)
+#if defined(WIN32) && ! defined(__CYGWIN32__)
/* It's not Unix, really. See? Capital letters. */
#include <windows.h>
-#define getpid() GetCurrentProcessId()
+#define getpid() GetCurrentProcessId ()
#endif
#ifndef _
@@ -62,9 +63,9 @@ Copyright (C) 2006, 2017 Christian Grothoff
When compiling libc, the _ macro is predefined. */
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
-#define _(msgid) gettext (msgid)
+#define _(msgid) gettext (msgid)
#else
-#define _(msgid) (msgid)
+#define _(msgid) (msgid)
#endif
#endif
@@ -176,21 +177,18 @@ static char *nextchar;
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `GNoptind' != ARGC. */
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
+static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
-#ifdef __GNU_LIBRARY__
+#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
-#define my_index strchr
+#define my_index strchr
#else
/* Avoid depending on library functions or files
@@ -200,8 +198,7 @@ char *
getenv ();
static char *
-my_index (const char *str,
- int chr)
+my_index (const char *str, int chr)
{
while (*str)
{
@@ -217,7 +214,7 @@ my_index (const char *str,
#ifdef __GNUC__
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
-#if !defined (__STDC__) || !__STDC__
+#if ! defined(__STDC__) || ! __STDC__
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int
@@ -247,7 +244,7 @@ static int last_nonopt;
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
-#if defined (__STDC__) && __STDC__
+#if defined(__STDC__) && __STDC__
static void
exchange (char **);
#endif
@@ -311,14 +308,12 @@ exchange (char **argv)
/* Initialize the internal data when the first call is made. */
-#if defined (__STDC__) && __STDC__
+#if defined(__STDC__) && __STDC__
static const char *
_getopt_initialize (int, char *const *, const char *);
#endif
static const char *
-_getopt_initialize (int argc,
- char *const *argv,
- const char *optstring)
+_getopt_initialize (int argc, char *const *argv, const char *optstring)
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
* is the program name); the sequence of previously skipped
@@ -407,8 +402,11 @@ _getopt_initialize (int argc,
long-named options. */
static int
-GN_getopt_internal (int argc, char *const *argv, const char *optstring,
- const struct GNoption *longopts, int *longind,
+GN_getopt_internal (int argc,
+ char *const *argv,
+ const char *optstring,
+ const struct GNoption *longopts,
+ int *longind,
int long_only)
{
static int __getopt_initialized = 0;
@@ -416,10 +414,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
GNoptarg = NULL;
- if (GNoptind == 0 || !__getopt_initialized)
+ if (GNoptind == 0 || ! __getopt_initialized)
{
if (GNoptind == 0)
- GNoptind = 1; /* Don't scan ARGV[0], the program name. */
+ GNoptind = 1; /* Don't scan ARGV[0], the program name. */
optstring = _getopt_initialize (argc, argv, optstring);
__getopt_initialized = 1;
}
@@ -463,7 +461,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
* Skip it like a null option,
* then exchange with previous non-options as if it were an option,
* then skip everything else like a non-option. */
- if (GNoptind != argc && !strcmp (argv[GNoptind], "--"))
+ if (GNoptind != argc && ! strcmp (argv[GNoptind], "--"))
{
GNoptind++;
@@ -503,7 +501,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
* Skip the initial punctuation. */
nextchar =
- (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));
+ (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));
}
/* Decode the current option-ARGV-element. */
@@ -524,7 +522,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
if (longopts != NULL &&
(argv[GNoptind][1] == '-' ||
(long_only &&
- (argv[GNoptind][2] || !my_index (optstring, argv[GNoptind][1])))))
+ (argv[GNoptind][2] || ! my_index (optstring, argv[GNoptind][1])))))
{
char *nameend;
const struct GNoption *p;
@@ -535,12 +533,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
+ /* Do nothing. */;
/* Test all long options for either exact match
* or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
+ if (! strncmp (p->name, nextchar, nameend - nextchar))
{
if ((unsigned int) (nameend - nextchar) ==
(unsigned int) strlen (p->name))
@@ -562,10 +560,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
ambig = 1;
}
- if (ambig && !exact)
+ if (ambig && ! exact)
{
if (GNopterr)
- FPRINTF (stderr, _("%s: option `%s' is ambiguous\n"), argv[0],
+ FPRINTF (stderr,
+ _ ("%s: option `%s' is ambiguous\n"),
+ argv[0],
argv[GNoptind]);
nextchar += strlen (nextchar);
GNoptind++;
@@ -589,13 +589,16 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
if (argv[GNoptind - 1][1] == '-')
/* --option */
FPRINTF (stderr,
- _("%s: option `--%s' does not allow an argument\n"),
- argv[0], pfound->name);
+ _ ("%s: option `--%s' does not allow an argument\n"),
+ argv[0],
+ pfound->name);
else
/* +option or -option */
FPRINTF (stderr,
- _("%s: option `%c%s' does not allow an argument\n"),
- argv[0], argv[GNoptind - 1][0], pfound->name);
+ _ ("%s: option `%c%s' does not allow an argument\n"),
+ argv[0],
+ argv[GNoptind - 1][0],
+ pfound->name);
}
nextchar += strlen (nextchar);
return '?';
@@ -611,8 +614,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
{
if (GNopterr)
{
- FPRINTF (stderr, _("%s: option `%s' requires an argument\n"),
- argv[0], argv[GNoptind - 1]);
+ FPRINTF (stderr,
+ _ ("%s: option `%s' requires an argument\n"),
+ argv[0],
+ argv[GNoptind - 1]);
}
nextchar += strlen (nextchar);
return (optstring[0] == ':') ? ':' : '?';
@@ -633,19 +638,24 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
* or the option starts with '--' or is not a valid short
* option, then it's an error.
* Otherwise interpret it as a short option. */
- if (!long_only || argv[GNoptind][1] == '-' ||
+ if (! long_only || argv[GNoptind][1] == '-' ||
my_index (optstring, *nextchar) == NULL)
{
if (GNopterr)
{
if (argv[GNoptind][1] == '-')
/* --option */
- FPRINTF (stderr, _("%s: unrecognized option `--%s'\n"), argv[0],
+ FPRINTF (stderr,
+ _ ("%s: unrecognized option `--%s'\n"),
+ argv[0],
nextchar);
else
/* +option or -option */
- FPRINTF (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0],
- argv[GNoptind][0], nextchar);
+ FPRINTF (stderr,
+ _ ("%s: unrecognized option `%c%s'\n"),
+ argv[0],
+ argv[GNoptind][0],
+ nextchar);
}
nextchar = (char *) "";
GNoptind++;
@@ -669,9 +679,9 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
{
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
- FPRINTF (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+ FPRINTF (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
else
- FPRINTF (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+ FPRINTF (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
}
return '?';
}
@@ -699,8 +709,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
if (GNopterr)
{
/* 1003.2 specifies the format of this message. */
- FPRINTF (stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
+ FPRINTF (stderr,
+ _ ("%s: option requires an argument -- %c\n"),
+ argv[0],
+ c);
}
if (optstring[0] == ':')
c = ':';
@@ -718,13 +730,13 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
for (nextchar = nameend = GNoptarg; *nameend && *nameend != '=';
nameend++)
- /* Do nothing. */ ;
+ /* Do nothing. */;
/* Test all long options for either exact match
* or abbreviated matches. */
if (longopts != NULL)
for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
+ if (! strncmp (p->name, nextchar, nameend - nextchar))
{
if ((unsigned int) (nameend - nextchar) == strlen (p->name))
{
@@ -744,10 +756,12 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
/* Second or later nonexact match found. */
ambig = 1;
}
- if (ambig && !exact)
+ if (ambig && ! exact)
{
if (GNopterr)
- FPRINTF (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0],
+ FPRINTF (stderr,
+ _ ("%s: option `-W %s' is ambiguous\n"),
+ argv[0],
argv[GNoptind]);
nextchar += strlen (nextchar);
GNoptind++;
@@ -765,7 +779,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
else
{
if (GNopterr)
- FPRINTF (stderr, _("%s: option `-W %s' does not allow an argument\n"), argv[0], pfound->name);
+ FPRINTF (stderr,
+ _ ("%s: option `-W %s' does not allow an argument\n"),
+ argv[0],
+ pfound->name);
nextchar += strlen (nextchar);
return '?';
@@ -778,8 +795,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
else
{
if (GNopterr)
- FPRINTF (stderr, _("%s: option `%s' requires an argument\n"),
- argv[0], argv[GNoptind - 1]);
+ FPRINTF (stderr,
+ _ ("%s: option `%s' requires an argument\n"),
+ argv[0],
+ argv[GNoptind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
@@ -795,7 +814,7 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
return pfound->val;
}
nextchar = NULL;
- return 'W'; /* Let the application handle it. */
+ return 'W'; /* Let the application handle it. */
}
if (temp[1] == ':')
{
@@ -826,8 +845,10 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring,
if (GNopterr)
{
/* 1003.2 specifies the format of this message. */
- FPRINTF (stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
+ FPRINTF (stderr,
+ _ ("%s: option requires an argument -- %c\n"),
+ argv[0],
+ c);
}
if (optstring[0] == ':')
c = ':';
@@ -880,8 +901,9 @@ GNUNET_GETOPT_run (const char *binaryOptions,
char *shorts;
int spos;
int cont;
- int c;
uint8_t *seen;
+ unsigned int optmatch = 0;
+ const char *have_exclusive = NULL;
GNUNET_assert (argc > 0);
GNoptind = 0;
@@ -890,12 +912,13 @@ GNUNET_GETOPT_run (const char *binaryOptions,
clpc.allOptions = allOptions;
clpc.argv = argv;
clpc.argc = argc;
- for (count = 0; NULL != allOptions[count].name; count++) ;
+ for (count = 0; NULL != allOptions[count].name; count++)
+ ;
- long_options = GNUNET_new_array (count + 1,
- struct GNoption);
- seen = GNUNET_new_array (count,
- uint8_t);
+ /* transform our option representation into the format
+ used by the GNU getopt copylib */
+ long_options = GNUNET_new_array (count + 1, struct GNoption);
+ seen = GNUNET_new_array (count, uint8_t);
shorts = GNUNET_malloc (count * 2 + 1);
spos = 0;
for (unsigned i = 0; i < count; i++)
@@ -916,53 +939,68 @@ GNUNET_GETOPT_run (const char *binaryOptions,
cont = GNUNET_OK;
/* main getopt loop */
- while (GNUNET_OK == cont)
+ while (1)
{
int option_index = 0;
unsigned int i;
+ int c;
- c = GNgetopt_long (argc, argv,
- shorts,
- long_options,
- &option_index);
+ c = GNgetopt_long (argc, argv, shorts, long_options, &option_index);
if (c == GNUNET_SYSERR)
- break; /* No more flags to process */
+ break; /* No more flags to process */
+ /* Check which of our program's options was given by the user */
for (i = 0; i < count; i++)
{
clpc.currentArgument = GNoptind - 1;
if ((char) c == allOptions[i].shortName)
{
- cont = allOptions[i].processor (&clpc,
- allOptions[i].scls,
- allOptions[i].name,
- GNoptarg);
+ optmatch++;
+ if (allOptions[i].option_exclusive)
+ have_exclusive = allOptions[i].name;
+ if (GNUNET_OK == cont)
+ {
+ /* parse the option using the option-specific processor */
+ cont = allOptions[i].processor (&clpc,
+ allOptions[i].scls,
+ allOptions[i].name,
+ GNoptarg);
+ }
seen[i] = 1;
break;
}
}
if (i == count)
{
- FPRINTF (stderr,
- _("Use %s to get a list of options.\n"),
- "--help");
+ FPRINTF (stderr, _ ("Use %s to get a list of options.\n"), "--help");
cont = GNUNET_SYSERR;
}
}
GNUNET_free (shorts);
GNUNET_free (long_options);
+ /* check that if any option that was marked as exclusive
+ is the only option that was provided */
+ if ((NULL != have_exclusive) && (optmatch > 1))
+ {
+ FPRINTF (stderr,
+ _ ("Option `%s' can't be used with other options.\n"),
+ have_exclusive);
+ cont = GNUNET_SYSERR;
+ }
if (GNUNET_YES == cont)
{
+ /* check that all mandatory options are present */
for (count = 0; NULL != allOptions[count].name; count++)
- if ( (0 == seen[count]) &&
- (allOptions[count].option_mandatory) )
+ {
+ if ((0 == seen[count]) && (allOptions[count].option_mandatory))
{
FPRINTF (stderr,
- _("Missing mandatory option `%s'.\n"),
+ _ ("Missing mandatory option `%s'.\n"),
allOptions[count].name);
cont = GNUNET_SYSERR;
}
+ }
}
GNUNET_free (seen);
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 77032e501..05856beee 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -26,7 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
/**
@@ -48,9 +48,7 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
(void) option;
(void) value;
- printf ("%s v%s\n",
- ctx->binaryName,
- version);
+ printf ("%s v%s\n", ctx->binaryName, version);
return GNUNET_NO;
}
@@ -64,13 +62,13 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_version (const char *version)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'v',
- .name = "version",
- .description = gettext_noop("print the version number"),
- .processor = &print_version,
- .scls = (void *) version
- };
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'v',
+ .name = "version",
+ .description = gettext_noop (
+ "print the version number"),
+ .option_exclusive = 1,
+ .processor = &print_version,
+ .scls = (void *) version};
return clo;
}
@@ -110,10 +108,9 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
(void) value;
if (NULL != about)
{
- printf ("%s\n%s\n",
- ctx->binaryOptions,
- gettext (about));
- printf (_("Arguments mandatory for long options are also mandatory for short options.\n"));
+ printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
+ printf (_ (
+ "Arguments mandatory for long options are also mandatory for short options.\n"));
}
i = 0;
opt = ctx->allOptions;
@@ -146,7 +143,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
trans = "";
ml = strlen (trans);
p = 0;
-OUTER:
+ OUTER:
while (ml - p > 78 - slen)
{
for (j = p + 78 - slen; j > (int) p; j--)
@@ -198,13 +195,13 @@ OUTER:
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_help (const char *about)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'h',
- .name = "help",
- .description = gettext_noop("print this help"),
- .processor = format_help,
- .scls = (void *) about
- };
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'h',
+ .name = "help",
+ .description = gettext_noop (
+ "print this help"),
+ .option_exclusive = 1,
+ .processor = format_help,
+ .scls = (void *) about};
return clo;
}
@@ -251,17 +248,15 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_increment_uint (char shortName,
- const char *name,
- const char *description,
- unsigned int *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .description = description,
- .processor = &increment_value,
- .scls = (void *) val
- };
+ const char *name,
+ const char *description,
+ unsigned int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .description = description,
+ .processor = &increment_value,
+ .scls = (void *) val};
return clo;
}
@@ -276,13 +271,12 @@ GNUNET_GETOPT_option_increment_uint (char shortName,
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_verbose (unsigned int *level)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'V',
- .name = "verbose",
- .description = gettext_noop("be verbose"),
- .processor = &increment_value,
- .scls = (void *) level
- };
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = 'V',
+ .name = "verbose",
+ .description =
+ gettext_noop ("be verbose"),
+ .processor = &increment_value,
+ .scls = (void *) level};
return clo;
}
@@ -330,17 +324,15 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_flag (char shortName,
- const char *name,
- const char *description,
- int *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .description = description,
- .processor = &set_one,
- .scls = (void *) val
- };
+ const char *name,
+ const char *description,
+ int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .description = description,
+ .processor = &set_one,
+ .scls = (void *) val};
return clo;
}
@@ -393,15 +385,13 @@ GNUNET_GETOPT_option_string (char shortName,
const char *description,
char **str)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_string,
- .scls = (void *) str
- };
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_string,
+ .scls = (void *) str};
return clo;
}
@@ -416,15 +406,14 @@ GNUNET_GETOPT_option_string (char shortName,
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_loglevel (char **level)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'L',
- .name = "log",
- .argumentHelp = "LOGLEVEL",
- .description = gettext_noop("configure logging to use LOGLEVEL"),
- .require_argument = 1,
- .processor = &set_string,
- .scls = (void *) level
- };
+ struct GNUNET_GETOPT_CommandLineOption clo =
+ {.shortName = 'L',
+ .name = "log",
+ .argumentHelp = "LOGLEVEL",
+ .description = gettext_noop ("configure logging to use LOGLEVEL"),
+ .require_argument = 1,
+ .processor = &set_string,
+ .scls = (void *) level};
return clo;
}
@@ -469,20 +458,18 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_filename (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- char **str)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_filename,
- .scls = (void *) str
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ char **str)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) str};
return clo;
}
@@ -496,15 +483,15 @@ GNUNET_GETOPT_option_filename (char shortName,
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_logfile (char **logfn)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'l',
- .name = "logfile",
- .argumentHelp = "FILENAME",
- .description = gettext_noop ("configure logging to write logs to FILENAME"),
- .require_argument = 1,
- .processor = &set_filename,
- .scls = (void *) logfn
- };
+ struct GNUNET_GETOPT_CommandLineOption clo =
+ {.shortName = 'l',
+ .name = "logfile",
+ .argumentHelp = "FILENAME",
+ .description =
+ gettext_noop ("configure logging to write logs to FILENAME"),
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) logfn};
return clo;
}
@@ -518,15 +505,14 @@ GNUNET_GETOPT_option_logfile (char **logfn)
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_cfgfile (char **fn)
{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = 'c',
- .name = "config",
- .argumentHelp = "FILENAME",
- .description = gettext_noop("use configuration file FILENAME"),
- .require_argument = 1,
- .processor = &set_filename,
- .scls = (void *) fn
- };
+ struct GNUNET_GETOPT_CommandLineOption clo =
+ {.shortName = 'c',
+ .name = "config",
+ .argumentHelp = "FILENAME",
+ .description = gettext_noop ("use configuration file FILENAME"),
+ .require_argument = 1,
+ .processor = &set_filename,
+ .scls = (void *) fn};
return clo;
}
@@ -555,13 +541,10 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
char dummy[2];
(void) ctx;
- if (1 != SSCANF (value,
- "%llu%1s",
- val,
- dummy))
+ if (1 != SSCANF (value, "%llu%1s", val, dummy))
{
FPRINTF (stderr,
- _("You must pass a number to the `%s' option.\n"),
+ _ ("You must pass a number to the `%s' option.\n"),
option);
return GNUNET_SYSERR;
}
@@ -580,20 +563,18 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_ulong (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- unsigned long long *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_ulong,
- .scls = (void *) val
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned long long *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_ulong,
+ .scls = (void *) val};
return clo;
}
@@ -619,14 +600,12 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
const char *value)
{
struct GNUNET_TIME_Relative *val = scls;
-
- (void) ctx;
- if (GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_relative (value,
- val))
+
+ (void) ctx;
+ if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (value, val))
{
FPRINTF (stderr,
- _("You must pass relative time to the `%s' option.\n"),
+ _ ("You must pass relative time to the `%s' option.\n"),
option);
return GNUNET_SYSERR;
}
@@ -646,20 +625,18 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_relative_time (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- struct GNUNET_TIME_Relative *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_relative_time,
- .scls = (void *) val
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Relative *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_relative_time,
+ .scls = (void *) val};
return clo;
}
@@ -687,12 +664,10 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
struct GNUNET_TIME_Absolute *val = scls;
(void) ctx;
- if (GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_absolute (value,
- val))
+ if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (value, val))
{
FPRINTF (stderr,
- _("You must pass absolute time to the `%s' option.\n"),
+ _ ("You must pass absolute time to the `%s' option.\n"),
option);
return GNUNET_SYSERR;
}
@@ -712,20 +687,18 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_absolute_time (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- struct GNUNET_TIME_Absolute *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_absolute_time,
- .scls = (void *) val
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Absolute *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_absolute_time,
+ .scls = (void *) val};
return clo;
}
@@ -754,20 +727,18 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
char dummy[2];
(void) ctx;
- if('-' == *value)
+ if ('-' == *value)
{
- FPRINTF (stderr,
- _("Your input for the '%s' option has to be a non negative number \n"),
- option);
- return GNUNET_SYSERR;
+ FPRINTF (stderr,
+ _ (
+ "Your input for the '%s' option has to be a non negative number \n"),
+ option);
+ return GNUNET_SYSERR;
}
- if (1 != SSCANF (value,
- "%u%1s",
- val,
- dummy))
+ if (1 != SSCANF (value, "%u%1s", val, dummy))
{
FPRINTF (stderr,
- _("You must pass a number to the `%s' option.\n"),
+ _ ("You must pass a number to the `%s' option.\n"),
option);
return GNUNET_SYSERR;
}
@@ -786,26 +757,23 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_uint (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- unsigned int *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_uint,
- .scls = (void *) val
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ unsigned int *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_uint,
+ .scls = (void *) val};
return clo;
}
-
/**
* Set an option of type 'uint16_t' from the command line.
* A pointer to this function should be passed as part of the
@@ -821,30 +789,27 @@ GNUNET_GETOPT_option_uint (char shortName,
*/
static int
set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
- void *scls,
- const char *option,
- const char *value)
+ void *scls,
+ const char *option,
+ const char *value)
{
uint16_t *val = scls;
unsigned int v;
char dummy[2];
-
+
(void) ctx;
- if (1 != SSCANF (value,
- "%u%1s",
- &v,
- dummy))
+ if (1 != SSCANF (value, "%u%1s", &v, dummy))
{
FPRINTF (stderr,
- _("You must pass a number to the `%s' option.\n"),
+ _ ("You must pass a number to the `%s' option.\n"),
option);
return GNUNET_SYSERR;
}
if (v > UINT16_MAX)
{
FPRINTF (stderr,
- _("You must pass a number below %u to the `%s' option.\n"),
- (unsigned int) UINT16_MAX,
+ _ ("You must pass a number below %u to the `%s' option.\n"),
+ (unsigned int) UINT16_MAX,
option);
return GNUNET_SYSERR;
}
@@ -864,20 +829,18 @@ set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_uint16 (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- uint16_t *val)
-{
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_uint16,
- .scls = (void *) val
- };
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ uint16_t *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_uint16,
+ .scls = (void *) val};
return clo;
}
@@ -922,15 +885,16 @@ set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
struct Base32Context *bc = scls;
(void) ctx;
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (value,
- strlen (value),
- bc->val,
- bc->val_size))
+ if (GNUNET_OK != GNUNET_STRINGS_string_to_data (value,
+ strlen (value),
+ bc->val,
+ bc->val_size))
{
- fprintf (stderr,
- _("Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"),
- option);
+ fprintf (
+ stderr,
+ _ (
+ "Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"),
+ option);
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -963,23 +927,21 @@ free_bc (void *cls)
*/
struct GNUNET_GETOPT_CommandLineOption
GNUNET_GETOPT_option_base32_fixed_size (char shortName,
- const char *name,
- const char *argumentHelp,
- const char *description,
- void *val,
- size_t val_size)
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ void *val,
+ size_t val_size)
{
struct Base32Context *bc = GNUNET_new (struct Base32Context);
- struct GNUNET_GETOPT_CommandLineOption clo = {
- .shortName = shortName,
- .name = name,
- .argumentHelp = argumentHelp,
- .description = description,
- .require_argument = 1,
- .processor = &set_base32,
- .cleaner = &free_bc,
- .scls = (void *) bc
- };
+ struct GNUNET_GETOPT_CommandLineOption clo = {.shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_base32,
+ .cleaner = &free_bc,
+ .scls = (void *) bc};
bc->val = val;
bc->val_size = val_size;
@@ -1001,4 +963,18 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt)
}
+/**
+ * Make the given option mutually exclusive with other options.
+ *
+ * @param opt option to modify
+ * @return @a opt with the exclusive flag set.
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt)
+{
+ opt.option_exclusive = 1;
+ return opt;
+}
+
+
/* end of getopt_helpers.c */
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index f700428a2..3b9b64d4e 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -43,6 +43,13 @@ static char *option;
static char *value;
/**
+ * Backend to check if the respective plugin is
+ * loadable. NULL if no check is to be performed.
+ * The value is the "basename" of the plugin to load.
+ */
+static char *backend_check;
+
+/**
* Treat option as a filename.
*/
static int is_filename;
@@ -55,7 +62,7 @@ static int list_sections;
/**
* Return value from 'main'.
*/
-static int ret;
+static int global_ret;
/**
* Should we generate a configuration file that is clean and
@@ -63,6 +70,7 @@ static int ret;
*/
static int rewrite;
+
/**
* Print each option in a given section.
*
@@ -95,18 +103,12 @@ print_option (void *cls,
fn = value_fn;
else
GNUNET_free (value_fn);
- fprintf (stdout,
- "%s = %s\n",
- option,
- fn);
+ fprintf (stdout, "%s = %s\n", option, fn);
GNUNET_free (fn);
}
else
{
- fprintf (stdout,
- "%s = %s\n",
- option,
- value);
+ fprintf (stdout, "%s = %s\n", option, value);
}
}
@@ -118,13 +120,10 @@ print_option (void *cls,
* @param section a section in the configuration file
*/
static void
-print_section_name (void *cls,
- const char *section)
+print_section_name (void *cls, const char *section)
{
(void) cls;
- fprintf (stdout,
- "%s\n",
- section);
+ fprintf (stdout, "%s\n", section);
}
@@ -149,45 +148,48 @@ run (void *cls,
(void) cls;
(void) args;
+ if (NULL != backend_check)
+ {
+ char *name;
+
+ GNUNET_asprintf (&name, "libgnunet_plugin_%s", backend_check);
+ global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77;
+ GNUNET_free (name);
+ return;
+ }
if (rewrite)
{
struct GNUNET_CONFIGURATION_Handle *def;
def = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (def, NULL))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_load (def, NULL))
{
- fprintf (stderr,
- _("failed to load configuration defaults"));
- ret = 1;
+ fprintf (stderr, _ ("failed to load configuration defaults"));
+ global_ret = 1;
return;
}
- diff = GNUNET_CONFIGURATION_get_diff (def,
- cfg);
+ diff = GNUNET_CONFIGURATION_get_diff (def, cfg);
cfg = diff;
}
- if ( ((! rewrite) && (NULL == section)) || list_sections)
+ if (((! rewrite) && (NULL == section)) || list_sections)
{
if (! list_sections)
{
fprintf (stderr,
- _("%s or %s argument is required\n"),
+ _ ("%s or %s argument is required\n"),
"--section",
"--list-sections");
- ret = 1;
+ global_ret = 1;
}
else
{
- fprintf (stderr,
- _("The following sections are available:\n"));
- GNUNET_CONFIGURATION_iterate_sections (cfg,
- &print_section_name,
- NULL);
+ fprintf (stderr, _ ("The following sections are available:\n"));
+ GNUNET_CONFIGURATION_iterate_sections (cfg, &print_section_name, NULL);
}
goto cleanup;
}
- if ( (NULL != section) && (NULL == value) )
+ if ((NULL != section) && (NULL == value))
{
if (NULL == option)
{
@@ -200,27 +202,25 @@ run (void *cls,
{
if (is_filename)
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- section,
- option,
- &value))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ section,
+ option,
+ &value))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- section, option);
- ret = 3;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
+ global_ret = 3;
goto cleanup;
}
}
else
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, section,
- option, &value))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ option,
+ &value))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- section, option);
- ret = 3;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
+ global_ret = 3;
goto cleanup;
}
}
@@ -231,15 +231,12 @@ run (void *cls,
{
if (NULL == option)
{
- fprintf (stderr, _("--option argument required to set value\n"));
- ret = 1;
+ fprintf (stderr, _ ("--option argument required to set value\n"));
+ global_ret = 1;
goto cleanup;
}
out = GNUNET_CONFIGURATION_dup (cfg);
- GNUNET_CONFIGURATION_set_value_string (out,
- section,
- option,
- value);
+ GNUNET_CONFIGURATION_set_value_string (out, section, option, value);
}
cfg_fn = NULL;
if (NULL == cfgfile)
@@ -255,12 +252,11 @@ run (void *cls,
cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
cfgfile = cfg_fn;
}
- if ( (NULL != diff) || (NULL != out) )
+ if ((NULL != diff) || (NULL != out))
{
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out,
- cfgfile))
- ret = 2;
+ GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, cfgfile))
+ global_ret = 2;
}
GNUNET_free_non_null (cfg_fn);
if (NULL != out)
@@ -279,52 +275,65 @@ cleanup:
* @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 ("interpret option value as a filename (with $-expansion)"),
- &is_filename),
- GNUNET_GETOPT_option_string ('s',
- "section",
- "SECTION",
- gettext_noop ("name of the section to access"),
- &section),
- GNUNET_GETOPT_option_string ('o',
- "option",
- "OPTION",
- gettext_noop ("name of the option to access"),
- &option),
- GNUNET_GETOPT_option_string ('V',
- "value",
- "VALUE",
- gettext_noop ("value to set"),
- &value),
- GNUNET_GETOPT_option_flag ('S',
- "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),
- GNUNET_GETOPT_OPTION_END
- };
- if (GNUNET_OK !=
- GNUNET_STRINGS_get_utf8_args (argc, argv,
- &argc, &argv))
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {GNUNET_GETOPT_option_flag (
+ 'f',
+ "filename",
+ gettext_noop ("interpret option value as a filename (with $-expansion)"),
+ &is_filename),
+ GNUNET_GETOPT_option_exclusive (GNUNET_GETOPT_option_string (
+ 'b',
+ "supported-backend",
+ "BACKEND",
+ gettext_noop (
+ "test if the current installation supports the specified BACKEND"),
+ &backend_check)),
+ GNUNET_GETOPT_option_string ('s',
+ "section",
+ "SECTION",
+ gettext_noop (
+ "name of the section to access"),
+ &section),
+ GNUNET_GETOPT_option_string ('o',
+ "option",
+ "OPTION",
+ gettext_noop ("name of the option to access"),
+ &option),
+ GNUNET_GETOPT_option_string ('V',
+ "value",
+ "VALUE",
+ gettext_noop ("value to set"),
+ &value),
+ GNUNET_GETOPT_option_flag ('S',
+ "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),
+ GNUNET_GETOPT_OPTION_END};
+ int ret;
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc,
+ ret =
+ GNUNET_PROGRAM_run (argc,
argv,
"gnunet-config [OPTIONS]",
gettext_noop ("Manipulate GNUnet configuration files"),
options,
- &run, NULL)) ? 0 : ret;
- GNUNET_free ((void*) argv);
+ &run,
+ NULL);
+ GNUNET_free ((void *) argv);
+ if (GNUNET_OK == ret)
+ return global_ret;
return ret;
}
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index 5e15eb16a..f4149a398 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -57,15 +57,13 @@ static char *pwfn;
static void
shutdown_task (void *cls)
{
- if (sizeof (proof) !=
- GNUNET_DISK_fn_write (pwfn,
- &proof,
- sizeof (proof),
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "write",
- pwfn);
+ (void) cls;
+ if (sizeof (proof) != GNUNET_DISK_fn_write (pwfn,
+ &proof,
+ sizeof (proof),
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", pwfn);
}
@@ -77,17 +75,18 @@ shutdown_task (void *cls)
* @param result where to write the resulting hash
*/
static void
-pow_hash (const void *buf,
- size_t buf_len,
- struct GNUNET_HashCode *result)
+pow_hash (const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
{
- GNUNET_break (0 ==
- gcry_kdf_derive (buf, buf_len,
- GCRY_KDF_SCRYPT,
- 1 /* subalgo */,
- "gnunet-proof-of-work", strlen ("gnunet-proof-of-work"),
- 2 /* iterations; keep cost of individual op small */,
- sizeof (struct GNUNET_HashCode), result));
+ GNUNET_break (
+ 0 == gcry_kdf_derive (buf,
+ buf_len,
+ GCRY_KDF_SCRYPT,
+ 1 /* subalgo */,
+ "gnunet-proof-of-work",
+ strlen ("gnunet-proof-of-work"),
+ 2 /* iterations; keep cost of individual op small */,
+ sizeof (struct GNUNET_HashCode),
+ result));
}
@@ -118,7 +117,7 @@ count_leading_zeroes (const struct GNUNET_HashCode *hash)
static void
find_proof (void *cls)
{
- #define ROUND_SIZE 10
+#define ROUND_SIZE 10
uint64_t counter;
char buf[sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) +
sizeof (uint64_t)] GNUNET_ALIGN;
@@ -127,12 +126,14 @@ find_proof (void *cls)
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_TIME_Relative elapsed;
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got Proof of Work %llu\n",
- (unsigned long long) proof);
+ "Got Proof of Work %llu\n",
+ (unsigned long long) proof);
proof_task = NULL;
- GNUNET_memcpy (&buf[sizeof (uint64_t)], &pub,
- sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
+ GNUNET_memcpy (&buf[sizeof (uint64_t)],
+ &pub,
+ sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
i = 0;
counter = proof;
timestamp = GNUNET_TIME_absolute_get ();
@@ -143,7 +144,8 @@ find_proof (void *cls)
if (nse_work_required <= count_leading_zeroes (&result))
{
proof = counter;
- FPRINTF (stdout, "Proof of work found: %llu!\n",
+ FPRINTF (stdout,
+ "Proof of work found: %llu!\n",
(unsigned long long) proof);
GNUNET_SCHEDULER_shutdown ();
return;
@@ -159,7 +161,8 @@ find_proof (void *cls)
GNUNET_STRINGS_relative_time_to_string (elapsed, 0));
if (proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing proofs currently at %llu\n",
(unsigned long long) counter);
/* remember progress every 100 rounds */
proof = counter;
@@ -171,8 +174,9 @@ find_proof (void *cls)
}
proof_task =
GNUNET_SCHEDULER_add_delayed_with_priority (proof_find_delay,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- &find_proof, NULL);
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &find_proof,
+ NULL);
}
@@ -193,54 +197,46 @@ run (void *cls,
struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
char *pids;
+ (void) cls;
+ (void) args;
+ (void) cfgfile;
cfg = config;
/* load proof of work */
if (NULL == pwfn)
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "NSE",
- "PROOFFILE",
- &pwfn))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "NSE",
+ "PROOFFILE",
+ &pwfn))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "NSE",
- "PROOFFILE");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "PROOFFILE");
GNUNET_SCHEDULER_shutdown ();
return;
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Proof of Work file: %s\n",
- pwfn);
- if ( (GNUNET_YES != GNUNET_DISK_file_test (pwfn)) ||
- (sizeof (proof) !=
- GNUNET_DISK_fn_read (pwfn, &proof, sizeof (proof))))
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Proof of Work file: %s\n", pwfn);
+ if ((GNUNET_YES != GNUNET_DISK_file_test (pwfn)) ||
+ (sizeof (proof) != GNUNET_DISK_fn_read (pwfn, &proof, sizeof (proof))))
proof = 0;
/* load private key */
if (NULL == pkfn)
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "PEER",
- "PRIVATE_KEY",
- &pkfn))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "PEER",
+ "PRIVATE_KEY",
+ &pkfn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"PEER",
- "PRIVATE_KEY");
+ "PRIVATE_KEY");
return;
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Private Key file: %s\n",
- pkfn);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Private Key file: %s\n", pkfn);
if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create_from_file (pkfn)))
{
- FPRINTF (stderr,
- _("Loading hostkey from `%s' failed.\n"),
- pkfn);
+ FPRINTF (stderr, _ ("Loading hostkey from `%s' failed.\n"), pkfn);
GNUNET_free (pkfn);
return;
}
@@ -248,32 +244,27 @@ run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub);
GNUNET_free (pk);
pids = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer ID: %s\n",
- pids);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer ID: %s\n", pids);
GNUNET_free (pids);
/* get target bit amount */
if (0 == nse_work_required)
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "NSE",
- "WORKBITS",
- &nse_work_required))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+ "NSE",
+ "WORKBITS",
+ &nse_work_required))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "NSE",
- "WORKBITS");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKBITS");
GNUNET_SCHEDULER_shutdown ();
return;
}
if (nse_work_required >= sizeof (struct GNUNET_HashCode) * 8)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "NSE",
- "WORKBITS",
- _("Value is too large.\n"));
+ "NSE",
+ "WORKBITS",
+ _ ("Value is too large.\n"));
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -283,19 +274,16 @@ run (void *cls,
return;
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Bits: %llu\n",
- nse_work_required);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Bits: %llu\n", nse_work_required);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Delay between tries: %s\n",
GNUNET_STRINGS_relative_time_to_string (proof_find_delay, 1));
proof_task =
GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
- &find_proof,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- NULL);
+ &find_proof,
+ NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
}
@@ -307,46 +295,51 @@ run (void *cls,
* @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_ulong ('b',
- "bits",
- "BITS",
- gettext_noop ("number of bits to require for the proof of work"),
- &nse_work_required),
- GNUNET_GETOPT_option_filename ('k',
- "keyfile",
- "FILE",
- gettext_noop ("file with private key, otherwise default is used"),
- &pkfn),
- GNUNET_GETOPT_option_filename ('o',
- "outfile",
- "FILE",
- gettext_noop ("file with proof of work, otherwise default is used"),
- &pwfn),
- GNUNET_GETOPT_option_relative_time ('t',
- "timeout",
- "TIME",
- gettext_noop ("time to wait between calculations"),
- &proof_find_delay),
- GNUNET_GETOPT_OPTION_END
- };
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {GNUNET_GETOPT_option_ulong (
+ 'b',
+ "bits",
+ "BITS",
+ gettext_noop ("number of bits to require for the proof of work"),
+ &nse_work_required),
+ GNUNET_GETOPT_option_filename (
+ 'k',
+ "keyfile",
+ "FILE",
+ gettext_noop ("file with private key, otherwise default is used"),
+ &pkfn),
+ GNUNET_GETOPT_option_filename (
+ 'o',
+ "outfile",
+ "FILE",
+ gettext_noop ("file with proof of work, otherwise default is used"),
+ &pwfn),
+ GNUNET_GETOPT_option_relative_time ('t',
+ "timeout",
+ "TIME",
+ gettext_noop (
+ "time to wait between calculations"),
+ &proof_find_delay),
+ GNUNET_GETOPT_OPTION_END};
int ret;
- 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-scrypt [OPTIONS] prooffile",
- gettext_noop ("Manipulate GNUnet proof of work files"),
- options,
- &run,
- NULL)) ? 0 : 1;
- GNUNET_free ((void*) argv);
+ ret =
+ (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-scrypt [OPTIONS] prooffile",
+ gettext_noop ("Manipulate GNUnet proof of work files"),
+ options,
+ &run,
+ NULL))
+ ? 0
+ : 1;
+ GNUNET_free ((void *) argv);
GNUNET_free_non_null (pwfn);
return ret;
}
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c
index 58f9e331c..33ff7b1e6 100644
--- a/src/util/gnunet-uri.c
+++ b/src/util/gnunet-uri.c
@@ -53,9 +53,9 @@ maint_child_death (void *cls)
{
enum GNUNET_OS_ProcessStatusType type;
- if ( (GNUNET_OK !=
- GNUNET_OS_process_status (p, &type, &exit_code)) ||
- (type != GNUNET_OS_PROCESS_EXITED) )
+ (void) cls;
+ if ((GNUNET_OK != GNUNET_OS_process_status (p, &type, &exit_code)) ||
+ (type != GNUNET_OS_PROCESS_EXITED))
GNUNET_break (0 == GNUNET_OS_process_kill (p, GNUNET_TERM_SIG));
GNUNET_OS_process_destroy (p);
}
@@ -70,56 +70,60 @@ maint_child_death (void *cls)
* @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 char *uri;
const char *slash;
char *subsystem;
char *program;
- struct GNUNET_SCHEDULER_Task * rt;
+ struct GNUNET_SCHEDULER_Task *rt;
+ (void) cls;
+ (void) cfgfile;
if (NULL == (uri = args[0]))
{
- fprintf (stderr,
- _("No URI specified on command line\n"));
+ fprintf (stderr, _ ("No URI specified on command line\n"));
return;
}
if (0 != strncasecmp ("gnunet://", uri, strlen ("gnunet://")))
{
fprintf (stderr,
- _("Invalid URI: does not start with `%s'\n"),
- "gnunet://");
+ _ ("Invalid URI: does not start with `%s'\n"),
+ "gnunet://");
return;
}
uri += strlen ("gnunet://");
if (NULL == (slash = strchr (uri, '/')))
{
- fprintf (stderr, _("Invalid URI: fails to specify subsystem\n"));
+ fprintf (stderr, _ ("Invalid URI: fails to specify subsystem\n"));
return;
}
subsystem = GNUNET_strndup (uri, slash - uri);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "uri",
- subsystem,
- &program))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "uri", subsystem, &program))
{
- fprintf (stderr, _("No handler known for subsystem `%s'\n"), subsystem);
+ fprintf (stderr, _ ("No handler known for subsystem `%s'\n"), subsystem);
GNUNET_free (subsystem);
return;
}
GNUNET_free (subsystem);
- rt = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_READ),
- &maint_child_death, NULL);
- p = GNUNET_OS_start_process (GNUNET_NO, 0,
- NULL, NULL, NULL,
- program,
- program,
- args[0],
- NULL);
+ rt = GNUNET_SCHEDULER_add_read_file (
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ),
+ &maint_child_death,
+ NULL);
+ p = GNUNET_OS_start_process (GNUNET_NO,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ program,
+ program,
+ args[0],
+ NULL);
GNUNET_free (program);
if (NULL == p)
GNUNET_SCHEDULER_cancel (rt);
@@ -134,13 +138,15 @@ static void
sighandler_child_death ()
{
static char c;
- int old_errno = errno; /* back-up errno */
-
- GNUNET_break (1 ==
- GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
- (sigpipe, GNUNET_DISK_PIPE_END_WRITE),
- &c, sizeof (c)));
- errno = old_errno; /* restore errno */
+ int old_errno = errno; /* back-up errno */
+
+ GNUNET_break (
+ 1 ==
+ GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
+ GNUNET_DISK_PIPE_END_WRITE),
+ &c,
+ sizeof (c)));
+ errno = old_errno; /* restore errno */
}
@@ -155,8 +161,7 @@ int
main (int argc, char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ GNUNET_GETOPT_OPTION_END};
struct GNUNET_SIGNAL_Context *shc_chld;
int ret;
@@ -166,9 +171,14 @@ main (int argc, char *const *argv)
GNUNET_assert (sigpipe != NULL);
shc_chld =
GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
- ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-uri URI",
- gettext_noop ("Perform default-actions for GNUnet URIs"),
- options, &run, NULL);
+ ret = GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-uri URI",
+ gettext_noop (
+ "Perform default-actions for GNUnet URIs"),
+ options,
+ &run,
+ NULL);
GNUNET_SIGNAL_handler_uninstall (shc_chld);
shc_chld = NULL;
GNUNET_DISK_pipe_close (sigpipe);
diff --git a/src/util/test_common_logging_dummy.c b/src/util/test_common_logging_dummy.c
index b8f2bef91..5c3709206 100644
--- a/src/util/test_common_logging_dummy.c
+++ b/src/util/test_common_logging_dummy.c
@@ -35,12 +35,20 @@
* This must be long enough for us to not to mistake skipped log call
* on a slow machine for a non-skipped one.
*/
-#define OUTPUT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 1000)
+#define OUTPUT_DELAY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 1000)
static void
-my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component,
- const char *date, const char *msg)
+my_log (void *ctx,
+ enum GNUNET_ErrorType kind,
+ const char *component,
+ const char *date,
+ const char *msg)
{
+ (void) ctx;
+ (void) kind;
+ (void) component;
+ (void) date;
if (strncmp ("test-common-logging-dummy", component, 25) != 0)
return;
FPRINTF (stdout, "%s", msg);
@@ -48,7 +56,7 @@ my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component,
}
-#if !defined(GNUNET_CULL_LOGGING)
+#if ! defined(GNUNET_CULL_LOGGING)
static int
expensive_func ()
{
@@ -57,27 +65,36 @@ expensive_func ()
#endif
-#define pr(kind,lvl) {\
- struct GNUNET_TIME_Absolute t1, t2;\
- t1 = GNUNET_TIME_absolute_get ();\
- GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
- t2 = GNUNET_TIME_absolute_get ();\
- printf ("1%s %llu\n", lvl,\
- (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
-}
+#define pr(kind, lvl) \
+ { \
+ struct GNUNET_TIME_Absolute t1, t2; \
+ t1 = GNUNET_TIME_absolute_get (); \
+ GNUNET_log (kind, "L%s %d\n", lvl, expensive_func ()); \
+ t2 = GNUNET_TIME_absolute_get (); \
+ printf ("1%s %llu\n", \
+ lvl, \
+ (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2) \
+ .rel_value_us); \
+ }
+
+#define pr2(kind, lvl) \
+ { \
+ struct GNUNET_TIME_Absolute t1, t2; \
+ t1 = GNUNET_TIME_absolute_get (); \
+ GNUNET_log (kind, "L%s %d\n", lvl, expensive_func ()); \
+ t2 = GNUNET_TIME_absolute_get (); \
+ printf ("2%s %llu\n", \
+ lvl, \
+ (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2) \
+ .rel_value_us); \
+ }
-#define pr2(kind,lvl) {\
- struct GNUNET_TIME_Absolute t1, t2;\
- t1 = GNUNET_TIME_absolute_get ();\
- GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
- t2 = GNUNET_TIME_absolute_get ();\
- printf ("2%s %llu\n", lvl,\
- (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
-}
int
main (int argc, char *argv[])
{
+ (void) argc;
+ (void) argv;
/* We set up logging with NULL level - will be overrided by
* GNUNET_LOG or GNUNET_FORCE_LOG at runtime.
*/
@@ -97,6 +114,6 @@ main (int argc, char *argv[])
pr2 (GNUNET_ERROR_TYPE_INFO, "INFO");
pr2 (GNUNET_ERROR_TYPE_DEBUG, "DEBUG");
return 0;
-} /* end of main */
+} /* end of main */
/* end of test_common_logging_dummy.c */
diff --git a/src/util/tun.c b/src/util/tun.c
index 97fbaa83b..e3643d0c6 100644
--- a/src/util/tun.c
+++ b/src/util/tun.c
@@ -44,24 +44,27 @@
*/
void
GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
- uint8_t protocol,
- uint16_t payload_length,
- const struct in_addr *src,
- const struct in_addr *dst)
+ uint8_t protocol,
+ uint16_t payload_length,
+ const struct in_addr *src,
+ const struct in_addr *dst)
{
GNUNET_assert (20 == sizeof (struct GNUNET_TUN_IPv4Header));
- GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv4Header));
+ GNUNET_assert (payload_length <=
+ UINT16_MAX - sizeof (struct GNUNET_TUN_IPv4Header));
memset (ip, 0, sizeof (struct GNUNET_TUN_IPv4Header));
- ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4;
+ ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4;
ip->version = 4;
- ip->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length);
- ip->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- 65536);
+ ip->total_length =
+ htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length);
+ ip->identification =
+ (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 65536);
ip->ttl = FRESH_TTL;
ip->protocol = protocol;
ip->source_address = *src;
ip->destination_address = *dst;
- ip->checksum = GNUNET_CRYPTO_crc16_n (ip, sizeof (struct GNUNET_TUN_IPv4Header));
+ ip->checksum =
+ GNUNET_CRYPTO_crc16_n (ip, sizeof (struct GNUNET_TUN_IPv4Header));
}
@@ -76,13 +79,14 @@ GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
*/
void
GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
- uint8_t protocol,
- uint16_t payload_length,
- const struct in6_addr *src,
- const struct in6_addr *dst)
+ uint8_t protocol,
+ uint16_t payload_length,
+ const struct in6_addr *src,
+ const struct in6_addr *dst)
{
GNUNET_assert (40 == sizeof (struct GNUNET_TUN_IPv6Header));
- GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv6Header));
+ GNUNET_assert (payload_length <=
+ UINT16_MAX - sizeof (struct GNUNET_TUN_IPv6Header));
memset (ip, 0, sizeof (struct GNUNET_TUN_IPv6Header));
ip->version = 6;
ip->next_header = protocol;
@@ -103,27 +107,29 @@ GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
*/
void
GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
- struct GNUNET_TUN_TcpHeader *tcp,
- const void *payload,
- uint16_t payload_length)
+ struct GNUNET_TUN_TcpHeader *tcp,
+ const void *payload,
+ uint16_t payload_length)
{
uint32_t sum;
uint16_t tmp;
GNUNET_assert (20 == sizeof (struct GNUNET_TUN_TcpHeader));
- GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) + sizeof (struct GNUNET_TUN_TcpHeader) ==
- ntohs (ip->total_length));
+ GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) +
+ sizeof (struct GNUNET_TUN_TcpHeader) ==
+ ntohs (ip->total_length));
GNUNET_assert (IPPROTO_TCP == ip->protocol);
tcp->crc = 0;
sum = GNUNET_CRYPTO_crc16_step (0,
- &ip->source_address,
- sizeof (struct in_addr) * 2);
+ &ip->source_address,
+ sizeof (struct in_addr) * 2);
tmp = htons (IPPROTO_TCP);
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t));
tmp = htons (payload_length + sizeof (struct GNUNET_TUN_TcpHeader));
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t));
- sum = GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader));
+ sum =
+ GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader));
sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
tcp->crc = GNUNET_CRYPTO_crc16_finish (sum);
}
@@ -139,25 +145,27 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
*/
void
GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
- struct GNUNET_TUN_TcpHeader *tcp,
- const void *payload,
- uint16_t payload_length)
+ struct GNUNET_TUN_TcpHeader *tcp,
+ const void *payload,
+ uint16_t payload_length)
{
uint32_t sum;
uint32_t tmp;
GNUNET_assert (20 == sizeof (struct GNUNET_TUN_TcpHeader));
GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_TcpHeader) ==
- ntohs (ip->payload_length));
+ ntohs (ip->payload_length));
GNUNET_assert (IPPROTO_TCP == ip->next_header);
tcp->crc = 0;
- sum = GNUNET_CRYPTO_crc16_step (0, &ip->source_address, 2 * sizeof (struct in6_addr));
+ sum = GNUNET_CRYPTO_crc16_step (0,
+ &ip->source_address,
+ 2 * sizeof (struct in6_addr));
tmp = htonl (sizeof (struct GNUNET_TUN_TcpHeader) + payload_length);
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t));
tmp = htonl (IPPROTO_TCP);
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t));
- sum = GNUNET_CRYPTO_crc16_step (sum, tcp,
- sizeof (struct GNUNET_TUN_TcpHeader));
+ sum =
+ GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader));
sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
tcp->crc = GNUNET_CRYPTO_crc16_finish (sum);
}
@@ -173,36 +181,31 @@ GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
*/
void
GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
- struct GNUNET_TUN_UdpHeader *udp,
- const void *payload,
- uint16_t payload_length)
+ struct GNUNET_TUN_UdpHeader *udp,
+ const void *payload,
+ uint16_t payload_length)
{
uint32_t sum;
uint16_t tmp;
GNUNET_assert (8 == sizeof (struct GNUNET_TUN_UdpHeader));
- GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) + sizeof (struct GNUNET_TUN_UdpHeader) ==
- ntohs (ip->total_length));
+ GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) +
+ sizeof (struct GNUNET_TUN_UdpHeader) ==
+ ntohs (ip->total_length));
GNUNET_assert (IPPROTO_UDP == ip->protocol);
- udp->crc = 0; /* technically optional, but we calculate it anyway, just to be sure */
+ udp->crc =
+ 0; /* technically optional, but we calculate it anyway, just to be sure */
sum = GNUNET_CRYPTO_crc16_step (0,
- &ip->source_address,
- sizeof (struct in_addr) * 2);
+ &ip->source_address,
+ sizeof (struct in_addr) * 2);
tmp = htons (IPPROTO_UDP);
- sum = GNUNET_CRYPTO_crc16_step (sum,
- &tmp,
- sizeof (uint16_t));
+ sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t));
tmp = htons (sizeof (struct GNUNET_TUN_UdpHeader) + payload_length);
- sum = GNUNET_CRYPTO_crc16_step (sum,
- &tmp,
- sizeof (uint16_t));
- sum = GNUNET_CRYPTO_crc16_step (sum,
- udp,
- sizeof (struct GNUNET_TUN_UdpHeader));
- sum = GNUNET_CRYPTO_crc16_step (sum,
- payload,
- payload_length);
+ sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t));
+ sum =
+ GNUNET_CRYPTO_crc16_step (sum, udp, sizeof (struct GNUNET_TUN_UdpHeader));
+ sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
udp->crc = GNUNET_CRYPTO_crc16_finish (sum);
}
@@ -217,28 +220,30 @@ GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
*/
void
GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
- struct GNUNET_TUN_UdpHeader *udp,
- const void *payload,
- uint16_t payload_length)
+ struct GNUNET_TUN_UdpHeader *udp,
+ const void *payload,
+ uint16_t payload_length)
{
uint32_t sum;
uint32_t tmp;
GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_UdpHeader) ==
- ntohs (ip->payload_length));
+ ntohs (ip->payload_length));
GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_UdpHeader) ==
- ntohs (udp->len));
+ ntohs (udp->len));
GNUNET_assert (IPPROTO_UDP == ip->next_header);
udp->crc = 0;
sum = GNUNET_CRYPTO_crc16_step (0,
- &ip->source_address,
- sizeof (struct in6_addr) * 2);
- tmp = htons (sizeof (struct GNUNET_TUN_UdpHeader) + payload_length); /* aka udp->len */
+ &ip->source_address,
+ sizeof (struct in6_addr) * 2);
+ tmp = htons (sizeof (struct GNUNET_TUN_UdpHeader) +
+ payload_length); /* aka udp->len */
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t));
tmp = htons (ip->next_header);
sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t));
- sum = GNUNET_CRYPTO_crc16_step (sum, udp, sizeof (struct GNUNET_TUN_UdpHeader));
+ sum =
+ GNUNET_CRYPTO_crc16_step (sum, udp, sizeof (struct GNUNET_TUN_UdpHeader));
sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
udp->crc = GNUNET_CRYPTO_crc16_finish (sum);
}
@@ -253,16 +258,15 @@ GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
*/
void
GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
- const void *payload,
- uint16_t payload_length)
+ const void *payload,
+ uint16_t payload_length)
{
uint32_t sum;
GNUNET_assert (8 == sizeof (struct GNUNET_TUN_IcmpHeader));
icmp->crc = 0;
- sum = GNUNET_CRYPTO_crc16_step (0,
- icmp,
- sizeof (struct GNUNET_TUN_IcmpHeader));
+ sum =
+ GNUNET_CRYPTO_crc16_step (0, icmp, sizeof (struct GNUNET_TUN_IcmpHeader));
sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length);
icmp->crc = GNUNET_CRYPTO_crc16_finish (sum);
}
@@ -286,21 +290,22 @@ GNUNET_TUN_sockaddr_cmp (const struct sockaddr *sa,
switch (sa->sa_family)
{
- case AF_INET:
- {
- const struct sockaddr_in *sa4 = (const struct sockaddr_in *) sa;
- const struct sockaddr_in *sb4 = (const struct sockaddr_in *) sb;
- return (sa4->sin_addr.s_addr == sb4->sin_addr.s_addr);
- }
- case AF_INET6:
- {
- const struct sockaddr_in6 *sa6 = (const struct sockaddr_in6 *) sa;
- const struct sockaddr_in6 *sb6 = (const struct sockaddr_in6 *) sb;
-
- return (0 == memcmp(&sa6->sin6_addr,
- &sb6->sin6_addr,
- sizeof (struct in6_addr)));
- }
+ case AF_INET: {
+ const struct sockaddr_in *sa4 = (const struct sockaddr_in *) sa;
+ const struct sockaddr_in *sb4 = (const struct sockaddr_in *) sb;
+ if ((include_port) && (sa4->sin_port != sb4->sin_port))
+ return GNUNET_NO;
+ return (sa4->sin_addr.s_addr == sb4->sin_addr.s_addr);
+ }
+ case AF_INET6: {
+ const struct sockaddr_in6 *sa6 = (const struct sockaddr_in6 *) sa;
+ const struct sockaddr_in6 *sb6 = (const struct sockaddr_in6 *) sb;
+
+ if ((include_port) && (sa6->sin6_port != sb6->sin6_port))
+ return GNUNET_NO;
+ return (
+ 0 == memcmp (&sa6->sin6_addr, &sb6->sin6_addr, sizeof (struct in6_addr)));
+ }
default:
GNUNET_break (0);
return GNUNET_SYSERR;