[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated (7322b322b -> 9a97ab1a8)
From: |
gnunet |
Subject: |
[gnunet] branch master updated (7322b322b -> 9a97ab1a8) |
Date: |
Wed, 28 Aug 2024 11:19:30 +0200 |
This is an automated email from the git hooks/post-receive script.
t3sserakt pushed a change to branch master
in repository gnunet.
from 7322b322b messenger: fix warnings; uncrustify
new a88ee6b3c Transport: Added test case to simulate router NAT mapping
behavior.
new d0c59f236 Added test case to start Android SDK emulator.
new 16b5da18d Added functionality to check if all services and
communicators are started.
new c1ef824f9 Added sync protocol.
new 3587d4a19 Fixed bug with new queues inheriting the validated_until
value of existing queues.
new 8de6f974d Moved sync protocol to util.
new 369c793ab NAT: Added missing missing files
new ad377b8c8 Implemented burst mode.
new 50613e931 Merge branch 'master' into dev/t3ss/probnatt
new 86fc39f56 Make the test framework work to run full peers.
new 177b91473 Added msssing config.
new ecbec010c Fixed Generic and specific test setup and code.
new d6925db2e Refactoring the burst logic.
new 305498606 Fixed bug adding global addresses to nat service.
new 227acb2c8 Make hole punch socket available, and some bug fixes.
new 422c58894 Fixed back in peerstore when iteration already has finished.
new 316caa8f6 Merge master into branch.
new 1749ffe37 Added meson build files for arm and arm monolith, and fixed
macro to start daemons.
new 9a97ab1a8 Fixed merge failures.
The 19 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
meson.build.arm_util_only => meson.build.arm | 17 +-
...build.arm_util_only => meson.build.arm_monolith | 47 +-
po/POTFILES.in | 7 +-
scripts/Makefile.am | 8 +-
scripts/netjail/getmsg.sh | 15 +
scripts/netjail/nat_node_test.sh | 25 +
scripts/netjail/netjail_start.sh | 10 +-
scripts/netjail/netjail_start_new.sh | 47 +-
scripts/netjail/netjail_stop.sh | 2 +-
scripts/netjail/netjail_test_master.sh | 22 +-
scripts/testing-ng/emu_run.sh | 19 +
src/include/gnunet_nat_lib.h | 245 ++++++++
src/include/gnunet_program_lib.h | 37 +-
src/include/gnunet_protocols.h | 24 +
src/include/gnunet_service_lib.h | 5 +-
src/include/gnunet_testing_testbed_lib.h | 7 +-
src/include/gnunet_testing_transport_lib.h | 45 ++
.../gnunet_transport_communication_service.h | 20 +-
src/include/gnunet_util_lib.h | 1 +
src/lib/hello/meson.build.arm_monolith | 11 +
src/lib/meson.build.arm | 2 +
src/lib/meson.build.arm_monolith | 3 +
src/lib/sq/meson.build.arm_monolith | 15 +
src/lib/testing/test_netjail_topo.conf.tmp | 39 ++
.../testing_api_cmd_netjail_start_cmds_helper.c | 169 ++++-
src/lib/testing/testing_api_topology.c | 33 +-
src/lib/util/Makefile.am | 1 +
.../{meson.build.arm_util_only => meson.build.arm} | 3 +-
...uild.arm_util_only => meson.build.arm_monolith} | 4 +-
src/lib/util/nat.c | 586 +++++++++++++++++
src/lib/util/program.c | 209 ++++++-
src/lib/util/service.c | 118 +---
src/meson.build.arm | 2 +
src/meson.build.arm_monolith | 4 +
src/plugin/meson.build.arm_monolith | 1 +
.../{meson.build => meson.build.arm_monolith} | 2 +-
src/service/arm/Makefile.am | 17 +
src/service/arm/meson.build.arm_monolith | 31 +
src/service/arm/test_arm_plugin_probnat.c | 79 +++
.../arm/test_arm_probnat.sh} | 2 +-
.../test_arm_probnat_host.conf} | 18 +-
.../arm/test_arm_probnat_topo.conf} | 6 +-
src/service/arm/testing_arm_cmd_start_peer.c | 9 +-
src/service/core/Makefile.am | 48 +-
src/service/core/test_core_just_run_topo.conf | 9 +
...d_just_run.c => test_core_plugin_cmd_run_emu.c} | 103 +--
src/service/core/test_core_run_emu_topo.conf | 8 +
src/service/{meson.build => meson.build.arm} | 28 -
.../{meson.build => meson.build.arm_monolith} | 41 +-
src/service/nat/gnunet-service-nat.c | 22 +-
.../nat/{meson.build => meson.build.arm_monolith} | 8 +-
src/service/nat/nat_api.c | 1 +
src/service/peerstore/gnunet-service-peerstore.c | 5 +-
.../{meson.build => meson.build.arm_monolith} | 6 +-
src/service/rest/gnunet-rest-server.c | 25 +-
.../{meson.build => meson.build.arm_monolith} | 6 +-
.../testbed/testbed_api_cmd_system_create.c | 22 +-
src/service/transport/Makefile.am | 31 +-
src/service/transport/gnunet-communicator-tcp.c | 1 +
src/service/transport/gnunet-communicator-udp.c | 694 ++++++++++++---------
src/service/transport/gnunet-communicator-unix.c | 1 +
src/service/transport/gnunet-service-transport.c | 647 +++++++++++++++----
src/service/transport/meson.build.arm_monolith | 172 +++++
src/service/transport/nat_router.sh | 63 ++
src/service/transport/template_tng_cfg_peer1.conf | 13 -
src/service/transport/test_tng_defaults.conf | 3 -
...dv_inverse.sh => test_transport_nat_mapping.sh} | 2 +-
.../transport/test_transport_nat_mapping_topo.conf | 8 +
...d.c => test_transport_plugin_cmd_nat_mapping.c} | 78 ++-
src/service/transport/timeout.sh | 59 ++
src/service/transport/transport.h | 32 +
.../transport/transport_api2_communication.c | 64 +-
.../util/{meson.build => meson.build.arm_monolith} | 9 +-
73 files changed, 3317 insertions(+), 859 deletions(-)
copy meson.build.arm_util_only => meson.build.arm (96%)
copy meson.build.arm_util_only => meson.build.arm_monolith (92%)
create mode 100755 scripts/netjail/getmsg.sh
create mode 100755 scripts/netjail/nat_node_test.sh
create mode 100644 scripts/testing-ng/emu_run.sh
create mode 100644 src/include/gnunet_nat_lib.h
create mode 100644 src/lib/hello/meson.build.arm_monolith
create mode 100644 src/lib/meson.build.arm
create mode 100644 src/lib/meson.build.arm_monolith
create mode 100644 src/lib/sq/meson.build.arm_monolith
create mode 100644 src/lib/testing/test_netjail_topo.conf.tmp
copy src/lib/util/{meson.build.arm_util_only => meson.build.arm} (99%)
copy src/lib/util/{meson.build.arm_util_only => meson.build.arm_monolith} (99%)
create mode 100644 src/lib/util/nat.c
create mode 100644 src/meson.build.arm
create mode 100644 src/meson.build.arm_monolith
create mode 100644 src/plugin/meson.build.arm_monolith
copy src/plugin/peerstore/{meson.build => meson.build.arm_monolith} (83%)
create mode 100644 src/service/arm/meson.build.arm_monolith
create mode 100644 src/service/arm/test_arm_plugin_probnat.c
copy src/{lib/testing/test_netjail_api.sh => service/arm/test_arm_probnat.sh}
(55%)
copy src/service/{core/test_core_just_run_host.conf =>
arm/test_arm_probnat_host.conf} (73%)
copy src/{lib/testing/test_netjail_topo.conf =>
service/arm/test_arm_probnat_topo.conf} (83%)
create mode 100644 src/service/core/test_core_just_run_topo.conf
copy src/service/core/{test_core_plugin_cmd_just_run.c =>
test_core_plugin_cmd_run_emu.c} (72%)
create mode 100644 src/service/core/test_core_run_emu_topo.conf
copy src/service/{meson.build => meson.build.arm} (76%)
copy src/service/{meson.build => meson.build.arm_monolith} (55%)
copy src/service/nat/{meson.build => meson.build.arm_monolith} (90%)
copy src/service/peerstore/{meson.build => meson.build.arm_monolith} (95%)
copy src/service/statistics/{meson.build => meson.build.arm_monolith} (87%)
create mode 100644 src/service/transport/meson.build.arm_monolith
create mode 100755 src/service/transport/nat_router.sh
copy src/service/transport/{test_transport_simple_send_dv_inverse.sh =>
test_transport_nat_mapping.sh} (96%)
create mode 100644 src/service/transport/test_transport_nat_mapping_topo.conf
copy src/service/transport/{test_transport_plugin_cmd_simple_send.c =>
test_transport_plugin_cmd_nat_mapping.c} (85%)
create mode 100755 src/service/transport/timeout.sh
copy src/service/util/{meson.build => meson.build.arm_monolith} (66%)
diff --git a/meson.build.arm_util_only b/meson.build.arm
similarity index 96%
copy from meson.build.arm_util_only
copy to meson.build.arm
index 755114a82..2a0e38cd2 100644
--- a/meson.build.arm_util_only
+++ b/meson.build.arm
@@ -15,8 +15,6 @@ r = run_command('sh', 'scripts/get_version.sh', '--major',
check: true)
cdata.set('gnunet_major_version', r.stdout().strip())
r = run_command('sh', 'scripts/get_version.sh', '--minor', check: true)
cdata.set('gnunet_minor_version', r.stdout().strip())
-r = run_command('sh', 'scripts/get_version.sh', '--micro', check: true)
-cdata.set('gnunet_micro_version', r.stdout().strip())
pkgcfgdir = get_option('datadir')/'gnunet'/'config.d'
docdir = get_option('datadir')/'doc'/'gnunet'
@@ -330,20 +328,9 @@ if cc.check_header('nss.h')
add_project_arguments('-DHAVE_GLIBCNSS', language : 'c')
endif
-# GNUTLS DANE
-if cc.check_header('gnutls/dane.h')
- if cc.has_function('dane_verify_crt_raw',
- prefix: '#include <gnutls/dane.h>',
- dependencies: gnutls_dep)
- add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c')
+if cc.has_function('getloadavg') == false
+ error('getloadadv missing')
endif
-endif
-curl_ssl_check ='''#include <curl/curl.h>
- int main(int argc, char **argv) {
- return (CURLSSLSET_OK != curl_global_sslset(CURLSSLBACKEND_GNUTLS, NULL,
NULL));
- }
- '''
-
syscalls = [
'memset_s', 'explicit_bzero', 'atoll', 'stat64',
'mremap', 'getrlimit', 'setrlimit', 'gethostbyname2',
diff --git a/meson.build.arm_util_only b/meson.build.arm_monolith
similarity index 92%
copy from meson.build.arm_util_only
copy to meson.build.arm_monolith
index 755114a82..fb47e4c09 100644
--- a/meson.build.arm_util_only
+++ b/meson.build.arm_monolith
@@ -15,8 +15,6 @@ r = run_command('sh', 'scripts/get_version.sh', '--major',
check: true)
cdata.set('gnunet_major_version', r.stdout().strip())
r = run_command('sh', 'scripts/get_version.sh', '--minor', check: true)
cdata.set('gnunet_minor_version', r.stdout().strip())
-r = run_command('sh', 'scripts/get_version.sh', '--micro', check: true)
-cdata.set('gnunet_micro_version', r.stdout().strip())
pkgcfgdir = get_option('datadir')/'gnunet'/'config.d'
docdir = get_option('datadir')/'doc'/'gnunet'
@@ -135,6 +133,20 @@ unistr_dep = dependency('libunistring', required : false)
if not unistr_dep.found()
unistr_dep = cc.find_library('unistring', required : true)
endif
+sqlite_dep = dependency ('sqlite3', version: '>=3.35.0', required : false)
+# FIXME for fallbacks, we need to manually check version
+if not sqlite_dep.found()
+ sqlite_dep = cc.find_library('sqlite3', required : true)
+ sqlite_version_check ='''#include <sqlite3.h>
+ int main(int argc, char **argv) {
+ return (SQLITE_VERSION_NUMBER >= 3035000) ? 0 : 1;
+ }
+ '''
+ if cc.run(sqlite_version_check, name : 'sqlite version check',
+ dependencies: sqlite_dep).returncode() != 0
+ error('Sqlite version >= 3.35.0 requried')
+ endif
+endif
zlib_dep = dependency('zlib', required : false)
if not zlib_dep.found()
zlib_dep = cc.find_library('zlib', required : true)
@@ -147,7 +159,7 @@ lgmp_dep = dependency('libgmp', required : false)
if not lgmp_dep.found()
lgmp_dep = cc.find_library('gmp', required : true)
endif
-sodium_dep = dependency('libsodium', required : false, version: '>=1.0.18')
+sodium_dep = dependency('libsodium', required : true, version: '>=1.0.18')
if not sodium_dep.found()
sodium_dep = cc.find_library('sodium', required : true)
sodium_version_check ='''#include <sodium.h>
@@ -167,6 +179,22 @@ if not quic_dep.found()
quic_dep = cc.find_library('quiche', required : false)
endif
+idn_dep = dependency('libidn2', required : false)
+if not idn_dep.found()
+ idn_dep = cc.find_library('idn2', required : false)
+endif
+if idn_dep.found()
+ add_project_arguments('-DHAVE_LIBIDN2', language : 'c')
+ add_project_arguments('-DHAVE_IDN2_H', language : 'c')
+else
+ idn_dep = dependency('libidn', required : false)
+ if not idn_dep.found()
+ idn_dep = cc.find_library('idn', required : true)
+ add_project_arguments('-DHAVE_LIBIDN', language : 'c')
+ add_project_arguments('-DHAVE_IDN_H', language : 'c')
+ endif
+endif
+
pthread_dep = cc.find_library('pthread', required : false)
if pthread_dep.found()
add_project_arguments('-DHAVE_PTHREAD', language : 'c')
@@ -330,19 +358,6 @@ if cc.check_header('nss.h')
add_project_arguments('-DHAVE_GLIBCNSS', language : 'c')
endif
-# GNUTLS DANE
-if cc.check_header('gnutls/dane.h')
- if cc.has_function('dane_verify_crt_raw',
- prefix: '#include <gnutls/dane.h>',
- dependencies: gnutls_dep)
- add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c')
-endif
-endif
-curl_ssl_check ='''#include <curl/curl.h>
- int main(int argc, char **argv) {
- return (CURLSSLSET_OK != curl_global_sslset(CURLSSLBACKEND_GNUTLS, NULL,
NULL));
- }
- '''
syscalls = [
'memset_s', 'explicit_bzero', 'atoll', 'stat64',
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3169f263f..cb7b23ed6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,7 +14,6 @@ src/cli/fs/gnunet-publish.c
src/cli/fs/gnunet-search.c
src/cli/fs/gnunet-unindex.c
src/cli/gns/gnunet-gns.c
-src/cli/hello/gnunet-hello.c
src/cli/identity/gnunet-identity.c
src/cli/messenger/gnunet-messenger.c
src/cli/namecache/gnunet-namecache.c
@@ -26,6 +25,7 @@ src/cli/nat-auto/gnunet-nat-auto.c
src/cli/nat-auto/gnunet-nat-server.c
src/cli/nat/gnunet-nat.c
src/cli/nse/gnunet-nse.c
+src/cli/peerstore/gnunet-peerstore.c
src/cli/reclaim/gnunet-did.c
src/cli/reclaim/gnunet-reclaim.c
src/cli/revocation/gnunet-revocation-tvg.c
@@ -110,6 +110,7 @@ src/lib/gnsrecord/gnsrecord_pow.c
src/lib/gnsrecord/gnsrecord_serialization.c
src/lib/gnsrecord/gnunet-gnsrecord-tvg.c
src/lib/gnsrecord/json_gnsrecord.c
+src/lib/hello/gnunet-hello.c
src/lib/hello/hello-ng.c
src/lib/hello/hello-uri.c
src/lib/json/json.c
@@ -180,7 +181,6 @@ src/lib/util/crypto_elligator.c
src/lib/util/crypto_hash.c
src/lib/util/crypto_hash_file.c
src/lib/util/crypto_hkdf.c
-src/lib/util/crypto_hpke.c
src/lib/util/crypto_kdf.c
src/lib/util/crypto_mpi.c
src/lib/util/crypto_paillier.c
@@ -194,7 +194,6 @@ src/lib/util/dnsparser.c
src/lib/util/dnsstub.c
src/lib/util/getopt.c
src/lib/util/getopt_helpers.c
-src/lib/util/gnunet-elligator-tvg.c
src/lib/util/gnunet_error_codes.c
src/lib/util/helper.c
src/lib/util/load.c
@@ -290,8 +289,6 @@ src/service/datacache/datacache.c
src/service/datastore/datastore_api.c
src/service/datastore/gnunet-service-datastore.c
src/service/dht/dht_api.c
-src/service/dht/dht_helper.c
-src/service/dht/gnunet-dht-tvg.c
src/service/dht/gnunet-service-dht.c
src/service/dht/gnunet-service-dht_clients.c
src/service/dht/gnunet-service-dht_datacache.c
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 819ca903e..58cf12ce0 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -2,6 +2,8 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include
dist_pkgdata_DATA = \
+ netjail/nat_node_test.sh \
+ netjail/getmsg.sh \
netjail/netjail_core.sh \
netjail/netjail_start.sh \
netjail/netjail_exec.sh \
@@ -9,7 +11,8 @@ dist_pkgdata_DATA = \
netjail/netjail_stop.sh \
netjail/netjail_test_master.sh \
netjail/topo.sh \
- testing-ng/block.sh
+ testing-ng/block.sh \
+ testing-ng/emu_run.sh
EXTRA_DIST = \
get_version.sh \
@@ -22,6 +25,8 @@ EXTRA_DIST = \
sphinx_update.sh
install-data-hook:
+ chmod o+x '$(DESTDIR)$(pkgdatadir)/nat_node_test.sh'
+ chmod o+x '$(DESTDIR)$(pkgdatadir)/getmsg.sh'
chmod +x '$(DESTDIR)$(pkgdatadir)/netjail_core.sh'
chmod +x '$(DESTDIR)$(pkgdatadir)/netjail_start.sh'
chmod +x '$(DESTDIR)$(pkgdatadir)/netjail_start_new.sh'
@@ -30,5 +35,6 @@ install-data-hook:
chmod +x '$(DESTDIR)$(pkgdatadir)/netjail_test_master.sh'
chmod +x '$(DESTDIR)$(pkgdatadir)/topo.sh'
chmod +x '$(DESTDIR)$(pkgdatadir)/block.sh'
+ chmod o+x '$(DESTDIR)$(pkgdatadir)/emu_run.sh'
## EOF
diff --git a/scripts/netjail/getmsg.sh b/scripts/netjail/getmsg.sh
new file mode 100755
index 000000000..84d500c88
--- /dev/null
+++ b/scripts/netjail/getmsg.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+dirname=$(dirname "$0")
+if [ $3 -gt 3 ]
+then
+ exit 1
+fi
+it=$(($3+1))
+read MESSAGE
+echo START "$MESSAGE" END
+if [ "START second END" != "$MESSAGE" ] || [ "START END" != "$MESSAGE" ]
+then
+ (nc -N -l $1 | $dirname/getmsg.sh $1 $2 $it >> getmsg_$2.out) &
+else
+ echo failure
+fi
diff --git a/scripts/netjail/nat_node_test.sh b/scripts/netjail/nat_node_test.sh
new file mode 100755
index 000000000..f10e581ee
--- /dev/null
+++ b/scripts/netjail/nat_node_test.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+dirname=$(dirname "$0")
+PORT=$1
+PREFIX=$2
+DST=$3
+echo nat_node_test args $PORT $PREFIX $DST > gaga_$PREFIX.out
+(nc -N -l $PORT | $dirname/getmsg.sh $PORT $PREFIX 1 > getmsg_$PREFIX.out) &
+printf "first" |nc -N $DST $PORT
+sleep 5
+printf "second" |nc -N $DST $PORT
+sleep 10
+printf "third" |nc -N $DST $PORT
+sleep 5
+if [ "" != "$(grep failure getmsg_$PREFIX.out)" ]
+then
+ echo FAILURE: We received third message. >> gaga_$PREFIX.out
+ exit 1
+elif [ "" != "$(grep second getmsg_$PREFIX.out)" ]
+then
+ echo SUCCESS >> gaga_$PREFIX.out
+ exit 0
+else
+ echo FAILURE: Something unexpected happened. >> gaga_$PREFIX.out
+ exit 1
+fi
diff --git a/scripts/netjail/netjail_start.sh b/scripts/netjail/netjail_start.sh
index ab10daecb..4c7ee6071 100755
--- a/scripts/netjail/netjail_start.sh
+++ b/scripts/netjail/netjail_start.sh
@@ -105,18 +105,18 @@ for N in $(seq $GLOBAL_N); do
ip netns exec ${ROUTERS[$N]} ip route add "$KNOWN_GROUP.$X" dev
${ROUTER_EXT_IF[$N]}
ip netns exec ${ROUTERS[$N]} ip route add default via "$KNOWN_GROUP.$X"
-
+
netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR
24
ROUTER_LINKS[$N]=$RESULT
-
+
netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24
-
+
for M in $(seq $LOCAL_M); do
netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR
done
# TODO Topology configuration must be enhanced to configure forwarding to
more than one subnet node via different ports.
-
+
if [ "1" == "${R_TCP[$N]}" ]
then
#ip netns exec ${ROUTERS[$N]} nft add rule ip nat prerouting ip daddr
$GLOBAL_GROUP.$N tcp dport 60002 counter dnat to $LOCAL_GROUP.1
@@ -165,7 +165,7 @@ for N in $(seq $GLOBAL_N); do
fi
if [ "" != "${R_SCRIPT[$N]}" ]
then
- ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTER_NETS[$N]} 1
+ ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTER_NETS[$N]} 1 $N
&
fi
done
diff --git a/scripts/netjail/netjail_start_new.sh
b/scripts/netjail/netjail_start_new.sh
index ed9ba71e4..1a57ae8f7 100755
--- a/scripts/netjail/netjail_start_new.sh
+++ b/scripts/netjail/netjail_start_new.sh
@@ -60,6 +60,9 @@ configure_carrier_subnet()
{
X=$1
+ netjail_bridge
+ CARRIER_BRIDGE=$RESULT
+
for Y in $(seq ${CARRIER_SUBNETS[$X]}); do
echo gaga 4
@@ -102,18 +105,30 @@ configure_carrier_subnet()
netjail_node
SUBNET_ROUTERS[$X,$Y]=$RESULT
netjail_node_link_bridge ${SUBNET_ROUTERS[$X,$Y]}
${CARRIER_ROUTER_NETS[$X]} $ADDRESS 16
- SUBNET_ROUTER_EXT_IF[$X]=$RESULT
+ SUBNET_ROUTER_EXT_IF[$X,$Y]=$RESULT
netjail_bridge
SUBNET_ROUTER_NETS[$X,$Y]=$RESULT
configure_subnet_peer $X $Y
echo gaga 5.5 ${SUBNET_ROUTERS[$X,$Y]}
-
+
+ ROUTER_ADDRESS=${CARRIER_NET/X/$X}
+ ROUTER_ADDRESS=${ROUTER_ADDRESS/Y/$((${CARRIER_SUBNETS[$X]}+1))}
+ ROUTER_ADDRESS=${ROUTER_ADDRESS/Z/0}
+
+ ip netns exec ${SUBNET_ROUTERS[$X,$Y]} ip route add $ROUTER_ADDRESS
dev ${SUBNET_ROUTER_EXT_IF[$X,$Y]}
+ ip netns exec ${SUBNET_ROUTERS[$X,$Y]} ip route add default via
$ROUTER_ADDRESS
+ ip netns exec ${SUBNET_ROUTERS[$X,$Y]} sleep 2000 &
+
ADDRESS=${CARRIER_NET/X/$X}
ADDRESS=${ADDRESS/Y/${SUBNET_NODE_NUMBER[$X]}}
- ADDRESS=${ADDRESS/Z/$((${CARRIER_SUBNET_PEERS[$X,$Y]+}1))}
+ ADDRESS=${ADDRESS/Z/$((${CARRIER_SUBNET_PEERS[$X,$Y]}+1))}
+
netjail_node_link_bridge ${SUBNET_ROUTERS[$X,$Y]}
${SUBNET_ROUTER_NETS[$X,$Y]} $ADDRESS 24
+
+ netjail_node_add_nat ${SUBNET_ROUTERS[$X,$Y]} $ADDRESS 24
+
for Z in $(seq ${CARRIER_SUBNET_PEERS[$X,$Y]}); do
netjail_node_add_default ${SUBNET_PEER[$X,$Y,$Z]} $ADDRESS
done
@@ -141,7 +156,7 @@ configure_carrier_peer()
ADDRESS=${ADDRESS/Z/0}
netjail_node
CARRIER_PEER[$X,$Y]=$RESULT
- netjail_node_link_bridge ${CARRIER_PEER[$X,$Y]}
${CARRIER_ROUTER_NETS[$X]} $ADDRESS 24
+ netjail_node_link_bridge ${CARRIER_PEER[$X,$Y]}
${CARRIER_ROUTER_NETS[$X]} $ADDRESS 16
done
}
@@ -187,10 +202,11 @@ configure_carriers ()
# FIXME configure backbone peers
echo gaga 2
- ADDRESS=${INET/X/$TOTAL_NODES}
+ ADDRESS=${INET/X/$(($BACKBONE_PEERS+$X))}
netjail_node
CARRIER_ROUTERS[$X]=$RESULT
netjail_node_link_bridge ${CARRIER_ROUTERS[$X]} $NETWORK_NET $ADDRESS 16
+ CARRIER_ROUTER_EXT_IF[$X]=$RESULT
netjail_bridge
CARRIER_ROUTER_NETS[$X]=$RESULT
@@ -199,10 +215,19 @@ configure_carriers ()
echo gaga 7 ${CARRIER_PEERS[$X]}
+ ADDRESS=${INET/X/$XX}
+ ip netns exec ${CARRIER_ROUTERS[$X]} ip route add $ADDRESS dev
${CARRIER_ROUTER_EXT_IF[$X]}
+ ip netns exec ${CARRIER_ROUTERS[$X]} ip route add default via $ADDRESS
+ ip netns exec ${CARRIER_ROUTERS[$X]} sleep 2001 &
+
ROUTER_ADDRESS=${CARRIER_NET/X/$X}
- ROUTER_ADDRESS=${ROUTER_ADDRESS/Y/$((${SUBNET_NODE_NUMBER[$X]}+1))}
+ ROUTER_ADDRESS=${ROUTER_ADDRESS/Y/$((${CARRIER_SUBNETS[$X]}+1))}
ROUTER_ADDRESS=${ROUTER_ADDRESS/Z/0}
- netjail_node_link_bridge ${CARRIER_ROUTERS[$X]} ${CARRIER_ROUTER_NETS[$X]}
$ROUTER_ADDRESS 24
+
+ netjail_node_link_bridge ${CARRIER_ROUTERS[$X]} ${CARRIER_ROUTER_NETS[$X]}
$ROUTER_ADDRESS 16
+
+ netjail_node_add_nat ${CARRIER_ROUTERS[$X]} $ROUTER_ADDRESS 16
+
for Y in $(seq ${CARRIER_PEERS[$X]}); do
netjail_node_add_default ${CARRIER_PEER[$X,$Y]} $ROUTER_ADDRESS
done
@@ -252,15 +277,21 @@ for X in $(seq $BACKBONE_PEERS); do
echo gaga 0 $BACKBONE_PEER_TESTBED_PLUGIN
netjail_node
BB_PEERS[$X]=$RESULT
- ADDRESS=${INET/X/$TOTAL_NODES}
+ ADDRESS=${INET/X/$X}
netjail_node_link_bridge ${BB_PEERS[$X]} $NETWORK_NET $ADDRESS 16
done
IPT=iptables-nft
+let XX=$BACKBONE_PEERS+$CARRIERS+1
+
for X in $(seq $CARRIERS); do
TOTAL_NODES=$(($TOTAL_NODES+1))
configure_carriers $X
done
+netjail_node
+GATEWAY=$RESULT
+ADDRESS=${INET/X/$XX}
+netjail_node_link_bridge $GATEWAY $NETWORK_NET $ADDRESS 16
diff --git a/scripts/netjail/netjail_stop.sh b/scripts/netjail/netjail_stop.sh
index 5da050952..7ad291cb7 100755
--- a/scripts/netjail/netjail_stop.sh
+++ b/scripts/netjail/netjail_stop.sh
@@ -50,7 +50,7 @@ for N in $(seq $GLOBAL_N); do
then
if [ "" != "${R_SCRIPT[$N]}" ]
then
- ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTERS[$N]} 0
$PREFIX
+ ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTERS[$N]} 0 $N
fi
rm -rf /tmp/netjail_scripts
fi
diff --git a/scripts/netjail/netjail_test_master.sh
b/scripts/netjail/netjail_test_master.sh
index 9487f3106..ecde89797 100755
--- a/scripts/netjail/netjail_test_master.sh
+++ b/scripts/netjail/netjail_test_master.sh
@@ -4,15 +4,15 @@ then
echo "You have to create the directory '/run/netns'."
exit 77
fi
-if [ -f /proc/sys/kernel/unprivileged_userns_clone ];
-then
- if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" != 1 ];
- then
- echo -e "Error during test setup: The kernel parameter
'kernel.unprivileged_userns_clone' has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_userns_clone=1\n"
- exit 77
- fi
-else
- echo -e "Error during test setup: The kernel lacks the parameter
'kernel.unprivileged_userns_clone'\n"
- exit 77
-fi
+#if [ -f /proc/sys/kernel/unprivileged_userns_clone ];
+#then
+# if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" != 1 ];
+# then
+# echo -e "Error during test setup: The kernel parameter
'kernel.unprivileged_us#erns_clone' has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_user#ns_clone=1\n"
+# exit 77
+# fi
+#else
+# echo -e "Error during test setup: The kernel lacks the parameter
'kernel.unprivile#ged_userns_clone'\n"
+# exit 77
+#fi
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
$*"
diff --git a/scripts/testing-ng/emu_run.sh b/scripts/testing-ng/emu_run.sh
new file mode 100644
index 000000000..1ef63e9d3
--- /dev/null
+++ b/scripts/testing-ng/emu_run.sh
@@ -0,0 +1,19 @@
+if [ "$1" != "" ];then
+ # echo arg: $1 > /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb start-server)
+ echo 1 > /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/emulator/emulator -no-window -avd $1) & #>>
/tmp/emu_run_$1.log
+ echo 2 >> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb wait-for-device shell
'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;') #>>
/tmp/emu_run_$1.log
+ echo 3 >> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb forward tcp:5000
tcp:5000) #>> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb forward --list >>
/tmp/emu_run_$1.log)
+ echo 4 >> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb shell am start -n
com.example.androidserver/.MainActivity) #>> /tmp/emu_run_$1.log
+ echo 5 >> /tmp/emu_run_$1.log
+ sleep 300
+ echo 6 >> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb emu kill) #>>
/tmp/emu_run_$1.log
+ echo 7 >> /tmp/emu_run_$1.log
+ $(/home/t3sserakt/Android/Sdk/platform-tools/adb kill-server)
+fi
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
new file mode 100644
index 000000000..6acad72a5
--- /dev/null
+++ b/src/include/gnunet_nat_lib.h
@@ -0,0 +1,245 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2024 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
+#error "Only <gnunet_util_lib.h> can be included directly."
+#endif
+
+/**
+ * @addtogroup Backbone
+ * @{
+ *
+ * @file NAT traversal
+ * @author t3sserakt
+ *
+ * @defgroup nat NAT traversal
+ *
+ * @{
+ */
+#ifndef GNUNET_NAT_LIB_H
+#define GNUNET_NAT_LIB_H
+
+/**
+ * Wrapper struct with the avarage RTT of message to some peer
+ * and if this peer und us is ready to sync.
+ */
+struct GNUNET_BurstSync
+{
+ /**
+ * The avarage RTT for the peer to communicate with.
+ */
+ struct GNUNET_TIME_RelativeNBO rtt_avarage;
+
+ /**
+ * Is this peer already ready to sync.
+ */
+ enum GNUNET_GenericReturnValue sync_ready;
+};
+
+/**
+ * Message send during burst mode.
+ */
+struct GNUNET_BurstMessage
+{
+ /**
+ * The peer who send the msg.
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ /**
+ * The local port the message was send from.
+ */
+ unsigned int local_port;
+};
+
+/**
+ * Struct wrapping information we use for starting the burst.
+ */
+struct GNUNET_StartBurstCls
+{
+ /**
+ * A Context which can be inserted into this struct, which is specific for
the caller.
+ */
+ void *context;
+
+ /**
+ * The avarage RTT between the peers.
+ */
+ struct GNUNET_TIME_Relative rtt;
+
+ /**
+ * The delay - calculate from the RTT and which peer was ready to sync
first, after
+ * we will start the burst.
+ */
+ struct GNUNET_TIME_Relative delay;
+
+ /**
+ * Peerstore request to start burst with natted addresses only.
+ */
+ struct GNUNET_PEERSTORE_Monitor *mo;
+
+ /**
+ * The VirtualLink of the peer to which we like to burst with.
+ */
+ struct VirtualLink *vl;
+
+ /**
+ * We are ready to start the burst.
+ */
+ unsigned int sync_ready;
+};
+
+struct GNUNET_UdpSocketInfo;
+
+typedef void (*GNUNET_NotifyUdpSocket) (struct GNUNET_UdpSocketInfo
*sock_info);
+
+/**
+ * Struct with the socket we like to use to send messages to another peer.
+ */
+struct GNUNET_UdpSocketInfo
+{
+ /**
+ * This is a linked list.
+ */
+ struct GNUNET_UdpSocketInfo *prev;
+
+ /**
+ * This is a linked list.
+ */
+ struct GNUNET_UdpSocketInfo *next;
+
+ // The peer the socket is for.
+ const struct GNUNET_PeerIdentity *peer;
+
+ // The socket to send message with to the peer.
+ struct GNUNET_NETWORK_Handle *udp_sock;
+
+ /**
+ * The actual RTT between the peers.
+ */
+ struct GNUNET_TIME_Relative rtt;
+
+ /**
+ * The peer we like to connect to.
+ */
+ struct GNUNET_PeerIdentity *pid;
+
+ /**
+ * The notify function to call if burst mode was successfull.
+ */
+ GNUNET_NotifyUdpSocket nus;
+
+ /**
+ * The read task for retrieving a burst message for this socket.
+ */
+ struct GNUNET_SCHEDULER_Task *read_task;
+
+ /**
+ * Timeout task for this socket.
+ */
+ struct GNUNET_SCHEDULER_Task *timeout_task;
+
+ /**
+ * The address of the other peer without port.
+ */
+ char *address;
+
+ /**
+ * Our address without port.
+ */
+ const char *bind_address;
+
+ /**
+ * The port we are bound to.
+ */
+ unsigned int port;
+
+ /**
+ * The address of the other peer we received a burst message from.
+ */
+ struct sockaddr *actual_address;
+
+ /**
+ * Default local port we are bound to.
+ */
+ unsigned int std_port;
+
+ /**
+ * Flag indicating, if the address is without port information.
+ */
+ enum GNUNET_GenericReturnValue has_port;
+};
+
+
+/**
+ * Create @a GNUNET_BurstSync message.
+ *
+ * @param rtt_avarage The avarage RTT for the peer to communicate with.
+ * @param sync_ready Is this peer already ready to sync.
+ *
+ * @return The GNUNET_BurstSync message to send to the other peer.
+ */
+struct GNUNET_BurstSync *
+GNUNET_get_burst_sync_msg (struct GNUNET_TIME_Relative rtt_avarage,
+ enum GNUNET_GenericReturnValue sync_ready);
+
+
+/**
+ * Checks if we are ready and starts burst when we and the other peer is ready.
+ *
+ * @param rtt_avarage The avarage RTT for the peer to communicate with.
+ * @param sync_ready Is this peer already ready to sync.
+ * @param burst_sync The GNUNET_BurstSync from the other peer.
+ * @param task Task to be executed if both peers are ready.
+ * @param task_cls Closure for the task.
+ *
+ * @return Are we burst ready. This is independent from the other peer being
ready.
+ */
+void
+GNUNET_is_burst_ready (struct GNUNET_TIME_Relative rtt_avarage,
+ struct GNUNET_BurstSync *burst_sync,
+ GNUNET_SCHEDULER_TaskCallback task,
+ struct GNUNET_StartBurstCls *task_cls);
+
+
+/**
+ * Method to get a UDP socket for a peer that is natted.
+ *
+ * @param sock_info Struct with information correlated to a specific port at
the other peer.
+ * @param nus Callback to give the caller the struct GNUNET_UdpSocketInfo to
use to connect the other peer.
+ * @return The intial read task to read from the default socket.
+ */
+struct GNUNET_SCHEDULER_Task *
+GNUNET_get_udp_socket (struct GNUNET_UdpSocketInfo *sock_info,
+ GNUNET_NotifyUdpSocket nus);
+
+/**
+ * Method to stop all sockets we established to the other peer.
+ *
+ * @param do_not_touch The network handle we will use to connect to the other
peer. This socket must not be closed.
+ */
+void
+GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch);
+
+#endif
+
+/** @} */ /* end of group */
+
+/** @} */ /* end of group addition to backbone */
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h
index f06d95422..ce16fd65b 100644
--- a/src/include/gnunet_program_lib.h
+++ b/src/include/gnunet_program_lib.h
@@ -125,10 +125,18 @@ GNUNET_PROGRAM_run (int argc,
enum GNUNET_GenericReturnValue
GNUNET_DAEMON_register (const char *daemon_name,
const char *daemon_desc,
- GNUNET_PROGRAM_Main task);
+ GNUNET_SCHEDULER_TaskCallback task);
+
+/**
+ * Start all services and daemons in a single prozess.
+ */
+void
+GNUNET_PROGRAM_monolith_main (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg);
#ifndef HAVE_GNUNET_MONOLITH
-#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
+#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb,
init_cb_monolith) \
int \
main (int argc, \
char *const *argv) \
@@ -151,17 +159,38 @@ GNUNET_DAEMON_register (const char *daemon_name,
return ret; \
}
#else
-#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
+#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb,
init_cb_monolith) \
static int __attribute__ ((constructor)) \
init (void) \
{ \
return GNUNET_DAEMON_register (daemon_name, \
daemon_help, \
- init_cb); \
+ init_cb_monolith); \
}
#endif
+/**
+ * Create configuration handle from options and configuration file.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_PROGRAM_conf_and_options (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
+/**
+ * Run the mainloop in a monolithic libgnunet.
+ * Must be called such that services are actually launched.
+ */
+void
+GNUNET_DAEMON_main (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ enum GNUNET_GenericReturnValue with_scheduler);
+
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 35473a716..0e2df2a52 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3414,6 +3414,16 @@ extern "C" {
*/
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_END 1252
+/**
+ * Burst message we send to another peer for hole punching.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_START_BURST 1253
+
+/**
+ * Burst message we send to another peer for hole punching.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_BURST_FINISHED 1254
+
/**
* Message exchanged between communicators to confirm
* successful KX (and address validation).
@@ -3638,6 +3648,20 @@ extern "C" {
*/
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752
+/*********************************************************************************/
+
+/*********************************************************************************/
+/********************************** UTIL (cont.) **************************/
+/*********************************************************************************/
+/* NAMESTORE: message types 1801-1810
+ */
+
+/**
+ * Message exchanged between peers for burst synchronisation.
+ */
+#define GNUNET_TYPE_BURST_SYNC 1801
+
+
/**
* Type used to match 'all' message types.
*/
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 0ad4fcc3c..10b6860bc 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -407,7 +407,10 @@ GNUNET_SERVICE_register_ (
* Must be called such that services are actually launched.
*/
void
-GNUNET_SERVICE_main (int argc, char *const *argv);
+GNUNET_SERVICE_main (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ enum GNUNET_GenericReturnValue with_scheduler);
/**
* Suspend accepting connections from the listen socket temporarily.
diff --git a/src/include/gnunet_testing_testbed_lib.h
b/src/include/gnunet_testing_testbed_lib.h
index dbdfa5ea7..484f99c24 100644
--- a/src/include/gnunet_testing_testbed_lib.h
+++ b/src/include/gnunet_testing_testbed_lib.h
@@ -20,12 +20,13 @@ GNUNET_TESTBED_cmd_system_destroy (const char *label,
* This command is setting up a test environment for a peer to start.
*
* @param label Name for command.
- * @param testdir Only the directory name without any path. Temporary
- * directory used for all service homes.
+ * @param my_node_id The specific id of the node this command is running on.
+ * A sub string of the id is the process id of the master process. This id is
+ * used to build the name of the temporary directory of the peer to start.
*/
struct GNUNET_TESTING_Command
GNUNET_TESTBED_cmd_system_create (const char *label,
- const char *testdir);
+ const char *my_node_id);
/**
diff --git a/src/include/gnunet_testing_transport_lib.h
b/src/include/gnunet_testing_transport_lib.h
index db2749661..fb8322cb0 100644
--- a/src/include/gnunet_testing_transport_lib.h
+++ b/src/include/gnunet_testing_transport_lib.h
@@ -104,6 +104,51 @@ struct GNUNET_TESTING_StartPeerState
*/
struct GNUNET_PEERSTORE_IterateContext *pic;
+ /**
+ * Task to search for log entry indicating the communicators started.
+ */
+ struct GNUNET_SCHEDULER_Task *log_task;
+
+ /**
+ * Task to start the request for the list of services.
+ */
+ struct GNUNET_SCHEDULER_Task *request_task;
+
+ /**
+ * Arm operation to get a list of the services, to check if all started.
+ */
+ struct GNUNET_ARM_Operation *op;
+
+ /**
+ * Handle for the arm service.
+ */
+ struct GNUNET_ARM_Handle *h;
+
+ /**
+ * Stream to read log file lines.
+ */
+ FILE *stream;
+
+ /**
+ * File handle for log file.
+ */
+ struct GNUNET_DISK_FileHandle *fh;
+
+ /**
+ * Flag indicating, if there are services not started completely.
+ */
+ enum GNUNET_GenericReturnValue not_all_started;
+
+ /**
+ * Flag indicating if all (udo and tcp) communicators connected to transport
service.
+ */
+ enum GNUNET_GenericReturnValue coms_started;
+
+ /**
+ * Number of communicators connecteds with transport service.
+ */
+ unsigned int num_coms_started;
+
/**
* Hello
*/
diff --git a/src/include/gnunet_transport_communication_service.h
b/src/include/gnunet_transport_communication_service.h
index 9a2c4b008..df58d61dd 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -134,6 +134,15 @@ typedef void (*GNUNET_TRANSPORT_CommunicatorNotify) (
const struct GNUNET_MessageHeader *msg);
+/**
+ * Function to start burst, if request by transport service.
+ *
+ * @param address The address to start the burst against.
+ */
+typedef void (*GNUNET_TRANSPORT_StartBurstNotify) (const char *address,
+ struct GNUNET_TIME_Relative
rtt,
+ struct GNUNET_PeerIdentity
*peer);
+
/**
* Connect to the transport service.
*
@@ -149,6 +158,7 @@ typedef void (*GNUNET_TRANSPORT_CommunicatorNotify) (
* @param mq_init_cls closure for @a mq_init
* @param notify_cb function to pass backchannel messages to communicator
* @param notify_cb_cls closure for @a notify_cb
+ * @param sb Function to start burst, if request by transport service.
* @return NULL on error
*/
struct GNUNET_TRANSPORT_CommunicatorHandle *
@@ -160,7 +170,8 @@ GNUNET_TRANSPORT_communicator_connect (
GNUNET_TRANSPORT_CommunicatorMqInit mq_init,
void *mq_init_cls,
GNUNET_TRANSPORT_CommunicatorNotify notify_cb,
- void *notify_cb_cls);
+ void *notify_cb_cls,
+ GNUNET_TRANSPORT_StartBurstNotify sb);
/**
@@ -219,6 +230,13 @@ GNUNET_TRANSPORT_communicator_receive (
void *cb_cls);
+/**
+ * The communicator tells the transport service that it finished the burst.*
+ * @param handle connection to transport service.
+ */
+void
+GNUNET_TRANSPORT_communicator_burst_finished (struct
GNUNET_TRANSPORT_CommunicatorHandle *ch);
+
/* ************************* Discovery *************************** */
/**
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index 86a1204bb..5f24b6307 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -77,6 +77,7 @@ extern "C"
#include "gnunet_helper_lib.h"
#include "gnunet_mst_lib.h"
#include "gnunet_mq_lib.h"
+#include "gnunet_nat_lib.h"
#include "gnunet_nt_lib.h"
#include "gnunet_nc_lib.h"
#include "gnunet_os_lib.h"
diff --git a/src/lib/hello/meson.build.arm_monolith
b/src/lib/hello/meson.build.arm_monolith
new file mode 100644
index 000000000..54ca0278b
--- /dev/null
+++ b/src/lib/hello/meson.build.arm_monolith
@@ -0,0 +1,11 @@
+libgnunethello_src = ['hello-uri.c']
+
+libgnunethello = library('gnunethello',
+ libgnunethello_src,
+ dependencies: [gcrypt_dep, sodium_dep,libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+libgnunethello_dep = declare_dependency(link_with : libgnunethello)
+pkg.generate(libgnunethello, url: 'https://www.gnunet.org',
+ description : 'Helper library for handling GNUnet HELLO messages')
\ No newline at end of file
diff --git a/src/lib/meson.build.arm b/src/lib/meson.build.arm
new file mode 100644
index 000000000..02beeb81c
--- /dev/null
+++ b/src/lib/meson.build.arm
@@ -0,0 +1,2 @@
+subdir('util')
+subdir('sq', if_found : [sqlite_dep])
\ No newline at end of file
diff --git a/src/lib/meson.build.arm_monolith b/src/lib/meson.build.arm_monolith
new file mode 100644
index 000000000..ee70f12df
--- /dev/null
+++ b/src/lib/meson.build.arm_monolith
@@ -0,0 +1,3 @@
+subdir('util')
+subdir('hello')
+subdir('sq', if_found : [sqlite_dep])
\ No newline at end of file
diff --git a/src/lib/sq/meson.build.arm_monolith
b/src/lib/sq/meson.build.arm_monolith
new file mode 100644
index 000000000..f3ef872c6
--- /dev/null
+++ b/src/lib/sq/meson.build.arm_monolith
@@ -0,0 +1,15 @@
+libgnunetsq_src = ['sq.c',
+ 'sq_exec.c',
+ 'sq_prepare.c',
+ 'sq_query_helper.c',
+ 'sq_result_helper.c']
+
+libgnunetsq = library('gnunetsq',
+ libgnunetsq_src,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep, sqlite_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunetsq, url: 'https://www.gnunet.org',
+ description : 'Provides API for accessing the SQ service')
+libgnunetsq_dep = declare_dependency(link_with : libgnunetsq)
\ No newline at end of file
diff --git a/src/lib/testing/test_netjail_topo.conf.tmp
b/src/lib/testing/test_netjail_topo.conf.tmp
new file mode 100644
index 000000000..b6738a03b
--- /dev/null
+++ b/src/lib/testing/test_netjail_topo.conf.tmp
@@ -0,0 +1,39 @@
+[DEFAULTS]
+SUBNETS = 3
+CARRIER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
+SUBNET_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
+PEER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
+TESTBED_PLUGIN = normal
+PLUGIN_ENV = key=value;key=value;
+CARRIER_PEERS = 1
+SUBNET_PEERS = 4
+
+[BACKBONE]
+CARRIERS = 2
+BACKBONE_PEERS = 2
+
+[BACKBONE-PEER-1]
+TESTBED_PLUGIN = server
+
+[CARRIER-1]
+CARRIER_PEERS = 2
+SUBNETS = 2
+
+[CARRIER-2]
+SETUP_PROGRAMMS = -A ... $UPLINK; -A ... $DOWNLINK;
+TESTBED_PLUGIN = mobile_network
+
+[CARRIER-2-PEER-1]
+TESTBED_PLUGIN = mobile_network
+
+[CARRIER-1-SUBNET-1]
+SUBNET = 8.8.0.0/16
+SUBNET_PEERS = 2
+TESTBED_PLUGIN = pc
+
+[CARRIER-1-SUBNET-2]
+SETUP_PROGRAMMS = -A ... $UPLINK; -A ... $DOWNLINK;
+
+[CARRIER-1-SUBNET-1-PEER-1]
+TESTBED_PLUGIN = evil
+SETUP_PROGRAMS = -A ... $DOWNLINK;
\ No newline at end of file
diff --git a/src/lib/testing/testing_api_cmd_netjail_start_cmds_helper.c
b/src/lib/testing/testing_api_cmd_netjail_start_cmds_helper.c
index 799ff43f1..cbd69581a 100644
--- a/src/lib/testing/testing_api_cmd_netjail_start_cmds_helper.c
+++ b/src/lib/testing/testing_api_cmd_netjail_start_cmds_helper.c
@@ -68,7 +68,7 @@ struct NetJailState
/**
* Array with handles of helper processes.
*/
- struct GNUNET_HELPER_Handle **helpers;
+ struct HelperState **helpers;
/**
* Time after this cmd has to finish.
@@ -111,6 +111,24 @@ struct NetJailState
bool failed;
};
+struct HelperState
+{
+ /**
+ * The state of this command.
+ */
+ struct NetJailState *ns;
+
+ /**
+ * The helper handle for this state.
+ */
+ struct GNUNET_HELPER_Handle *helper;
+
+ /**
+ * Did we got a GNUNET_TESTING_CommandLocalFinished message?
+ */
+ enum GNUNET_GenericReturnValue finished;
+};
+
/**
* Struct containing the number of the netjail node and the NetJailState which
* will be handed to callbacks specific to a test environment.
@@ -142,6 +160,12 @@ struct TestingSystemCount
};
+/**
+ * The network namespace number of a node.
+ */
+unsigned int node_number;
+
+
/**
* Continuation function from GNUNET_HELPER_send()
*
@@ -167,6 +191,8 @@ clear_msg (void *cls,
(GNUNET_OK != result) )
{
ns->failed = true;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed sending message to helper!\n");
GNUNET_TESTING_FAIL (ns->is);
}
}
@@ -177,7 +203,8 @@ handle_helper_barrier_reached (
void *cls,
const struct GNUNET_TESTING_CommandBarrierReached *rm)
{
- struct NetJailState *ns = cls;
+ struct HelperState *hs = cls;
+ struct NetJailState *ns = hs->ns;
struct GNUNET_TESTING_Barrier *barrier;
barrier = GNUNET_TESTING_get_barrier2_ (ns->is,
@@ -187,7 +214,9 @@ handle_helper_barrier_reached (
if (! ns->failed)
{
ns->failed = true;
- GNUNET_TESTING_async_fail (&ns->ac);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "We did not found the barrier that was supposedly
reached.!\n");
+ GNUNET_TESTING_async_fail (&ns->ac);
}
return;
}
@@ -232,13 +261,18 @@ handle_helper_local_finished (
void *cls,
const struct GNUNET_TESTING_CommandLocalFinished *lf)
{
- struct NetJailState *ns = cls;
+ struct HelperState *hs = cls;
+ struct NetJailState *ns = hs->ns;
+ GNUNET_HELPER_stop (hs->helper, GNUNET_YES);
+ hs->finished = GNUNET_YES;
ns->n_finished++;
if ( (! ns->failed) &&
(GNUNET_OK != ntohl (lf->rv)) )
{
ns->failed = true;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Helper finished with error!\n");
GNUNET_TESTING_async_fail (&ns->ac);
return;
}
@@ -265,18 +299,19 @@ static enum GNUNET_GenericReturnValue
helper_mst (void *cls,
const struct GNUNET_MessageHeader *message)
{
- struct NetJailState *ns = cls;
+ struct HelperState *hs = cls;
+ struct NetJailState *ns = hs->ns;
struct GNUNET_MQ_MessageHandler handlers[] = {
GNUNET_MQ_hd_fixed_size (
helper_barrier_reached,
GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED,
struct GNUNET_TESTING_CommandBarrierReached,
- ns),
+ hs),
GNUNET_MQ_hd_fixed_size (
helper_local_finished,
GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED,
struct GNUNET_TESTING_CommandLocalFinished,
- ns),
+ hs),
GNUNET_MQ_handler_end ()
};
enum GNUNET_GenericReturnValue ret;
@@ -289,6 +324,8 @@ helper_mst (void *cls,
if (! ns->failed)
{
ns->failed = true;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "We got an unknown message from the helper process!\n");
GNUNET_TESTING_async_fail (&ns->ac);
}
}
@@ -302,7 +339,8 @@ helper_mst (void *cls,
static void
exp_cb (void *cls)
{
- struct NetJailState *ns = cls;
+ struct HelperState *hs = cls;
+ struct NetJailState *ns = hs->ns;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Called exp_cb.\n");
@@ -413,6 +451,7 @@ start_helper (struct NetJailState *ns,
char *data_dir;
char *script_name;
struct GNUNET_HELPER_Handle *helper;
+ struct HelperState *hs = GNUNET_new (struct HelperState);
data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
GNUNET_asprintf (&script_name,
@@ -432,23 +471,28 @@ start_helper (struct NetJailState *ns,
node_id,
NULL
};
+ hs->ns = ns;
helper = GNUNET_HELPER_start (
GNUNET_YES, /*
with control pipe */
script_argv[0],
script_argv,
&helper_mst,
&exp_cb,
- ns);
+ hs);
+ hs->helper = helper;
}
GNUNET_free (gnunet_cmds_helper);
if (NULL == helper)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Starting helper failed. Is NULL.\n");
GNUNET_break (0);
+ GNUNET_free (hs);
return false;
}
GNUNET_array_append (ns->helpers,
ns->n_helpers,
- helper);
+ hs);
GNUNET_TESTING_add_netjail_helper_ (ns->is,
helper);
GNUNET_free (data_dir);
@@ -475,6 +519,75 @@ do_timeout (void *cls)
}
+static int
+start_peer (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
+{
+ struct NetJailState *ns = cls;
+
+ if (! start_helper (ns, node_number))
+ {
+ return GNUNET_SYSERR;
+ }
+ node_number++;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer helper %u started.\n",
+ node_number);
+ return GNUNET_OK;
+}
+
+
+static int
+start_subnets (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
+{
+ struct NetJailState *ns = cls;
+ struct GNUNET_TESTING_NetjailSubnet *subnet = value;
+
+ node_number++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting subnet %u.\n",
+ node_number);
+ if (GNUNET_SYSERR == GNUNET_CONTAINER_multishortmap_iterate (subnet->peers,
+ &start_peer,
+ ns))
+ return GNUNET_SYSERR;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Subnet started.\n");
+ return GNUNET_OK;
+}
+
+
+static int
+start_carriers (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
+{
+ struct NetJailState *ns = cls;
+ struct GNUNET_TESTING_NetjailCarrier *carrier = value;
+
+ node_number++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting carrier %u.\n",
+ node_number);
+ if (GNUNET_SYSERR == GNUNET_CONTAINER_multishortmap_iterate (carrier->peers,
+ &start_peer,
+ ns))
+ return GNUNET_SYSERR;
+ if (GNUNET_SYSERR == GNUNET_CONTAINER_multishortmap_iterate
(carrier->subnets,
+ &start_subnets,
+ ns))
+ return GNUNET_SYSERR;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier started.\n");
+ return GNUNET_OK;
+}
+
+
/**
* This function starts a helper process for each node.
*
@@ -502,23 +615,29 @@ netjail_exec_run (void *cls,
GNUNET_TESTING_FAIL (is);
topology
= GNUNET_TESTING_get_topo_from_string_ (ns->topology_data);
- for (unsigned int i = 1; i <= topology->total; i++)
- {
- if (! start_helper (ns,
- i))
- {
- failed = true;
- break;
- }
- }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Number of nodes: %u\n",
+ topology->total);
+ if (GNUNET_SYSERR == GNUNET_CONTAINER_multishortmap_iterate
(topology->backbone_peers,
+ &start_peer,
+ ns))
+ failed = true;
+ if (true == failed || GNUNET_SYSERR ==
GNUNET_CONTAINER_multishortmap_iterate (topology->carriers,
+
&start_carriers,
+
ns))
+ failed = true;
+
GNUNET_TESTING_free_topology (topology);
if (failed)
{
ns->failed = true;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to start helpers!\n");
GNUNET_TESTING_FAIL (is);
}
- ns->timeout_task
- = GNUNET_SCHEDULER_add_delayed (ns->timeout,
+ else
+ ns->timeout_task
+ = GNUNET_SCHEDULER_add_delayed (ns->timeout,
&do_timeout,
ns);
}
@@ -540,8 +659,12 @@ netjail_exec_cleanup (void *cls)
ns->timeout_task = NULL;
}
for (unsigned int i = 0; i<ns->n_helpers; i++)
- GNUNET_HELPER_stop (ns->helpers[i],
- GNUNET_YES);
+ {
+ if (GNUNET_NO == ns->helpers[i]->finished)
+ GNUNET_HELPER_stop (ns->helpers[i]->helper,
+ GNUNET_YES);
+ GNUNET_free (ns->helpers[i]);
+ }
GNUNET_free (ns);
}
diff --git a/src/lib/testing/testing_api_topology.c
b/src/lib/testing/testing_api_topology.c
index beba9b489..5710c5244 100644
--- a/src/lib/testing/testing_api_topology.c
+++ b/src/lib/testing/testing_api_topology.c
@@ -549,12 +549,15 @@ create_subnet_peers (struct GNUNET_CONFIGURATION_Handle
*cfg,
struct GNUNET_HashCode hc;
subnet->peers = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
- for (int i = 1; i < subnet->number_peers; i++)
+ for (int i = 0; i < subnet->number_peers; i++)
{
struct GNUNET_ShortHashCode hkey;
struct GNUNET_TESTING_NetjailSubnetPeer *subnet_peer = GNUNET_new (struct
GNUNET_TESTING_NetjailSubnetPeer);
topology->total++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Subnet peers -> Number of nodes: %u\n",
+ topology->total);
GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
memcpy (&hkey,
&hc,
@@ -575,13 +578,16 @@ create_subnets (struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_HashCode hc;
carrier->subnets = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
- for (int i = 1; i < carrier->number_subnets; i++)
+ for (int i = 0; i < carrier->number_subnets; i++)
{
struct GNUNET_ShortHashCode hkey;
struct GNUNET_TESTING_NetjailSubnet *subnet = GNUNET_new (struct
GNUNET_TESTING_NetjailSubnet);
char *section;
topology->total++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Subnets -> Number of nodes: %u\n",
+ topology->total);
subnet->number = topology->total;
subnet->index = i;
GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
@@ -616,12 +622,15 @@ create_peers (struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_HashCode hc;
carrier->peers = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
- for (int i = 1; i < carrier->number_peers; i++)
+ for (int i = 0; i < carrier->number_peers; i++)
{
struct GNUNET_ShortHashCode hkey;
struct GNUNET_TESTING_NetjailCarrierPeer *peer = GNUNET_new (struct
GNUNET_TESTING_NetjailCarrierPeer);
topology->total++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier peers -> Number of nodes: %u\n",
+ topology->total);
peer->number = topology->total;
GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
memcpy (&hkey,
@@ -719,6 +728,9 @@ GNUNET_TESTING_get_topo_from_string_ (const char *input)
struct GNUNET_ShortHashCode hkey;
topology->total++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Backbone peers -> Number of nodes: %u\n",
+ topology->total);
peer->number = topology->total;
GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
memcpy (&hkey,
@@ -737,6 +749,9 @@ GNUNET_TESTING_get_topo_from_string_ (const char *input)
char *section;
topology->total++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier -> Number of nodes: %u\n",
+ topology->total);
carrier->number = topology->total;
GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
memcpy (&hkey,
@@ -754,14 +769,26 @@ GNUNET_TESTING_get_topo_from_string_ (const char *input)
(unsigned long long
*) &carrier->number_subnets))
{
carrier->number_subnets = topology->default_subnets;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier -> Default number of subnets: %u\n",
+ carrier->number_subnets);
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier -> number of subnets: %u\n",
+ carrier->number_subnets);
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
section,
"CARRIER_PEERS",
(unsigned long long
*) &carrier->number_peers))
{
carrier->number_peers = topology->default_carrier_peers;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier -> Default number of peers: %u\n",
+ carrier->number_peers);
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Carrier -> Default number of peers: %u\n",
+ carrier->number_peers);
create_peers (cfg, topology, carrier);
create_subnets (cfg, topology, carrier);
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index 2f3de981c..1e94dc9e2 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -90,6 +90,7 @@ libgnunetutil_la_SOURCES = \
load.c \
mst.c \
mq.c \
+ nat.c \
nc.c \
network.c \
nt.c \
diff --git a/src/lib/util/meson.build.arm_util_only
b/src/lib/util/meson.build.arm
similarity index 99%
copy from src/lib/util/meson.build.arm_util_only
copy to src/lib/util/meson.build.arm
index ffe02e5f7..35b6a56c0 100644
--- a/src/lib/util/meson.build.arm_util_only
+++ b/src/lib/util/meson.build.arm
@@ -68,7 +68,8 @@ libgnunetutil_src = ['bandwidth.c',
'uri.c',
'speedup.c',
'speedup.h',
- 'proc_compat.c']
+ 'proc_compat.c',
+ 'gnunet_error_codes.c']
configure_file(input : 'util.conf',
output : 'util.conf',
diff --git a/src/lib/util/meson.build.arm_util_only
b/src/lib/util/meson.build.arm_monolith
similarity index 99%
copy from src/lib/util/meson.build.arm_util_only
copy to src/lib/util/meson.build.arm_monolith
index ffe02e5f7..8349f55ba 100644
--- a/src/lib/util/meson.build.arm_util_only
+++ b/src/lib/util/meson.build.arm_monolith
@@ -40,6 +40,7 @@ libgnunetutil_src = ['bandwidth.c',
'crypto_rsa.c',
'disk.c',
'disk.h',
+ 'dnsparser.c',
'dnsstub.c',
'getopt.c',
'getopt_helpers.c',
@@ -78,8 +79,6 @@ configure_file(input : 'util.conf',
libgnunetutil = library('gnunetutil',
libgnunetutil_src,
- soversion: '15',
- version: '15.0.0',
dependencies: [
lgmp_dep,
sodium_dep,
@@ -87,6 +86,7 @@ libgnunetutil = library('gnunetutil',
zlib_dep,
unistr_dep,
ltdl_dep,
+ idn_dep
],
include_directories: [incdir, configuration_inc],
install: true,
diff --git a/src/lib/util/nat.c b/src/lib/util/nat.c
new file mode 100644
index 000000000..134ce16d4
--- /dev/null
+++ b/src/lib/util/nat.c
@@ -0,0 +1,586 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2024 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file util/nat.c
+ * @brief Library for NAT traversal related functonality.
+ * @author t3sserakt
+ */
+
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-nat", __VA_ARGS__)
+
+#define SEND_DELAY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10)
+
+#define TIMEOUT_DELAY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100)
+
+/**
+ * Difference of the avarage RTT for the DistanceVector calculate by us and
the target
+ * we are willing to accept for starting the burst.
+ */
+#define RTT_DIFF \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 150)
+
+static struct GNUNET_UdpSocketInfo *sock_infos_head;
+
+static struct GNUNET_UdpSocketInfo *sock_infos_tail;
+
+static struct GNUNET_SCHEDULER_Task *read_send_task;
+
+unsigned int udp_port;
+
+/**
+ * Maximum of open sockets.
+ */
+unsigned int nr_open_sockets;
+
+/**
+ * Create @a GNUNET_BurstSync message.
+ *
+ * @param rtt_avarage The avarage RTT for the peer to communicate with.
+ * @param sync_ready Is this peer already ready to sync.
+ */
+struct GNUNET_BurstSync *
+GNUNET_get_burst_sync_msg (struct GNUNET_TIME_Relative rtt_avarage,
+ enum GNUNET_GenericReturnValue sync_ready)
+{
+ struct GNUNET_BurstSync *burst_sync = GNUNET_new (struct GNUNET_BurstSync);
+
+ burst_sync->rtt_avarage = GNUNET_TIME_relative_hton (rtt_avarage);
+ burst_sync->sync_ready = sync_ready;
+
+ return burst_sync;
+}
+
+
+/**
+ * Checks if we are ready and starts burst when we and the other peer is ready.
+ *
+ * @param rtt_avarage The avarage RTT for the peer to communicate with.
+ * @param burst_sync The GNUNET_BurstSync from the other peer.
+ * @param task Task to be executed if both peers are ready.
+ * @param task_cls Closure for the task.
+ *
+ * @return Are we burst ready. This is independent from the other peer being
ready.
+ */
+void
+GNUNET_is_burst_ready (struct GNUNET_TIME_Relative rtt_avarage,
+ struct GNUNET_BurstSync *burst_sync,
+ GNUNET_SCHEDULER_TaskCallback task,
+ struct GNUNET_StartBurstCls *task_cls)
+{
+ struct GNUNET_TIME_Relative other_rtt;
+ struct GNUNET_TIME_Relative rel1;
+ struct GNUNET_TIME_Relative rel2;
+
+ other_rtt = GNUNET_TIME_relative_ntoh (burst_sync->rtt_avarage);
+ rel1 = GNUNET_TIME_relative_subtract (other_rtt, rtt_avarage);
+ rel2 = GNUNET_TIME_relative_subtract (rtt_avarage, other_rtt);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "other sync ready %u, other rtt %lu and rtt %lu rel1 %lu rel2
%lu\n",
+ burst_sync->sync_ready,
+ other_rtt.rel_value_us,
+ rtt_avarage.rel_value_us,
+ rel1.rel_value_us,
+ rel2.rel_value_us);
+ if ((other_rtt.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us &&
+ rtt_avarage.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) &&
+ rel1.rel_value_us < RTT_DIFF.rel_value_us &&
+ rel2.rel_value_us < RTT_DIFF.rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "other sync ready 1\n");
+ if (GNUNET_YES == burst_sync->sync_ready)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "other sync ready 2\n");
+ task_cls->delay = GNUNET_TIME_relative_saturating_multiply (rtt_avarage,
+ 2);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "other sync ready 3\n");
+ task_cls->delay = GNUNET_TIME_relative_saturating_multiply (rtt_avarage,
+ 4);
+ }
+ task_cls->sync_ready = GNUNET_YES;
+ task (task_cls);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "other sync ready 6\n");
+ task_cls->sync_ready = GNUNET_NO;
+ }
+}
+
+void
+GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch);
+
+
+/**
+ * Socket read task.
+ *
+ * @param cls NULL
+ */
+static void
+sock_read (void *cls)
+{
+ struct GNUNET_UdpSocketInfo *sock_info = cls;
+ struct sockaddr_storage sa;
+ socklen_t salen = sizeof(sa);
+ char buf[UINT16_MAX];
+ ssize_t rcvd;
+
+ sock_info->read_task = NULL;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Reading from socket\n");
+ while (1)
+ {
+ rcvd = GNUNET_NETWORK_socket_recvfrom (sock_info->udp_sock,
+ buf,
+ sizeof(buf),
+ (struct sockaddr *) &sa,
+ &salen);
+ if (-1 == rcvd)
+ {
+ struct sockaddr *addr = (struct sockaddr*) &sa;
+
+ if (EAGAIN == errno)
+ break; // We are done reading data
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to recv from %s family %d failed sock %p\n",
+ GNUNET_a2s ((struct sockaddr*) &sa,
+ sizeof (*addr)),
+ addr->sa_family,
+ sock_info->udp_sock);
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "recv");
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read %llu bytes\n",
+ (unsigned long long) rcvd);
+ if (0 == rcvd)
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read 0 bytes from UDP socket\n");
+ return;
+ }
+ /* first, see if it is a GNUNET_BurstMessage */
+ if (rcvd == sizeof (struct GNUNET_BurstMessage))
+ {
+ struct GNUNET_BurstMessage *bm = (struct GNUNET_BurstMessage *) buf;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received a burst message from remote port %u to local port
%u!\n",
+ bm->local_port,
+ sock_info->port);
+ sock_info->actual_address = (struct sockaddr *) &sa;
+ sock_info->nus (sock_info);
+ GNUNET_stop_burst(sock_info->udp_sock);
+ return;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received a non burst message on local port %u %lu!\n",
+ sock_info->port,
+ sizeof (struct GNUNET_BurstMessage));
+ }
+}
+
+
+/**
+ * Convert UDP bind specification to a `struct sockaddr *`
+ *
+ * @param bindto bind specification to convert
+ * @param[out] sock_len set to the length of the address
+ * @return converted bindto specification
+ */
+static struct sockaddr *
+udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
+{
+ struct sockaddr *in;
+ unsigned int port;
+ char dummy[2];
+ char *colon;
+ char *cp;
+
+ cp = GNUNET_strdup (bindto);
+ colon = strrchr (cp, ':');
+ if (NULL != colon)
+ {
+ /* interpret value after colon as port */
+ *colon = '\0';
+ colon++;
+ if (1 == sscanf (colon, "%u%1s", &port, dummy))
+ {
+ /* interpreting value as just a PORT number */
+ if (port > UINT16_MAX)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "BINDTO specification `%s' invalid: value too large for
port\n",
+ bindto);
+ GNUNET_free (cp);
+ return NULL;
+ }
+ }
+ else
+ {
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_ERROR,
+ "BINDTO specification `%s' invalid: last ':' not followed by number\n",
+ bindto);
+ GNUNET_free (cp);
+ return NULL;
+ }
+ }
+ else
+ {
+ /* interpret missing port as 0, aka pick any free one */
+ port = 0;
+ }
+ {
+ /* try IPv4 */
+ struct sockaddr_in v4;
+
+ memset (&v4, 0, sizeof(v4));
+ if (1 == inet_pton (AF_INET, cp, &v4.sin_addr))
+ {
+ v4.sin_family = AF_INET;
+ v4.sin_port = htons ((uint16_t) port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ v4.sin_len = sizeof(struct sockaddr_in);
+#endif
+ in = GNUNET_memdup (&v4, sizeof(struct sockaddr_in));
+ *sock_len = sizeof(struct sockaddr_in);
+ GNUNET_free (cp);
+ return in;
+ }
+ }
+ {
+ /* try IPv6 */
+ struct sockaddr_in6 v6;
+ const char *start;
+
+ memset (&v6, 0, sizeof(v6));
+ start = cp;
+ if (('[' == *cp) && (']' == cp[strlen (cp) - 1]))
+ {
+ start++; /* skip over '[' */
+ cp[strlen (cp) - 1] = '\0'; /* eat ']' */
+ }
+ if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
+ {
+ v6.sin6_family = AF_INET6;
+ v6.sin6_port = htons ((uint16_t) port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ v6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ in = GNUNET_memdup (&v6, sizeof(v6));
+ *sock_len = sizeof(v6);
+ GNUNET_free (cp);
+ return in;
+ }
+ }
+ /* #5528 FIXME (feature!): maybe also try getnameinfo()? */
+ GNUNET_free (cp);
+ return NULL;
+}
+
+
+static void
+timeout_task_cb (void *cls)
+{
+ struct GNUNET_UdpSocketInfo *sock_info = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "timeout task\n");
+ if (NULL != sock_info->read_task)
+ GNUNET_SCHEDULER_cancel (sock_info->read_task);
+ GNUNET_NETWORK_socket_close (sock_info->udp_sock);
+ nr_open_sockets--;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "timeout nr_open_sockets %u\n",
+ nr_open_sockets);
+ if (NULL != sock_infos_head)
+ GNUNET_CONTAINER_DLL_remove (sock_infos_head,
+ sock_infos_tail,
+ sock_info);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "freeing sock_info %p\n",
+ sock_info);
+ GNUNET_free (sock_info);
+}
+
+
+static void
+read_send (void *cls)
+{
+ struct GNUNET_UdpSocketInfo *sock_info = cls;
+ struct GNUNET_UdpSocketInfo *si = GNUNET_new (struct GNUNET_UdpSocketInfo);
+ struct GNUNET_NETWORK_Handle *udp_sock;;
+ struct GNUNET_BurstMessage bm;
+ struct sockaddr *in;
+ socklen_t in_len;
+ char dgram[sizeof (struct GNUNET_BurstMessage)];
+ char *address;
+ struct sockaddr *bind_in;
+ socklen_t bind_in_len;
+ char *bind_address;
+ struct GNUNET_TIME_Relative again = GNUNET_TIME_relative_multiply
(sock_info->rtt,
+ 4);
+
+ read_send_task = NULL;
+ GNUNET_memcpy (si, sock_info, sizeof (struct GNUNET_UdpSocketInfo));
+ if (sock_info->std_port == udp_port)
+ udp_port++;
+ if (512 < nr_open_sockets){
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying again in %s",
+ GNUNET_STRINGS_relative_time_to_string (again, GNUNET_NO));
+ read_send_task = GNUNET_SCHEDULER_add_delayed (again,
+ &read_send,
+ sock_info);
+ }
+
+ GNUNET_asprintf (&address,
+ "%s:%u",
+ sock_info->address,
+ udp_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "3 sock %p addr %s addr %s %u\n",
+ sock_info,
+ sock_info->address,
+ address,
+ nr_open_sockets);
+ in = udp_address_to_sockaddr (address, &in_len);
+ if (NULL == in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to setup UDP socket address with path `%s'\n",
+ address);
+ GNUNET_assert (0);
+ }
+ GNUNET_asprintf (&bind_address,
+ "%s:%u",
+ sock_info->bind_address,
+ udp_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "4 sock addr %s addr %s\n",
+ sock_info->bind_address,
+ bind_address);
+ bind_in = udp_address_to_sockaddr (bind_address, &bind_in_len);
+ if (NULL == bind_in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to setup UDP socket bind address with path `%s'\n",
+ bind_address);
+ GNUNET_assert (0);
+ }
+ udp_sock =
+ GNUNET_NETWORK_socket_create (bind_in->sa_family,
+ SOCK_DGRAM,
+ IPPROTO_UDP);
+ if (NULL == udp_sock)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to create socket for %s family %d\n",
+ GNUNET_a2s (bind_in,
+ bind_in_len),
+ in->sa_family);
+ if (EMFILE == errno)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying again in %s, because of EMFILE\n",
+ GNUNET_STRINGS_relative_time_to_string (again, GNUNET_NO));
+ read_send_task = GNUNET_SCHEDULER_add_delayed (again,
+ &read_send,
+ sock_info);
+ return;
+ }
+ GNUNET_free (sock_info);
+ goto next_port;
+ }
+ if (GNUNET_OK !=
+ GNUNET_NETWORK_socket_bind (udp_sock,
+ bind_in,
+ bind_in_len))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to bind socket for %s family %d sock %p\n",
+ GNUNET_a2s (bind_in,
+ bind_in_len),
+ bind_in->sa_family,
+ udp_sock);
+ GNUNET_NETWORK_socket_close (udp_sock);
+ udp_sock = NULL;
+ GNUNET_free (sock_info);
+ goto next_port;
+ }
+ nr_open_sockets++;
+ bm.local_port = udp_port;
+ sock_info->udp_sock = udp_sock;
+ sock_info->port = udp_port;
+ sock_info->read_task = GNUNET_SCHEDULER_add_read_net
(GNUNET_TIME_UNIT_FOREVER_REL,
+ udp_sock,
+ &sock_read,
+ sock_info);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Timeout in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (TIMEOUT_DELAY,
GNUNET_NO));
+ sock_info->timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_DELAY,
+ &timeout_task_cb,
+ sock_info);
+
+ GNUNET_CONTAINER_DLL_insert (sock_infos_head, sock_infos_tail, sock_info);
+
+ memcpy (dgram, &bm, sizeof(bm));
+ if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock,
+ dgram,
+ sizeof(dgram),
+ in,
+ in_len))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending burst to %s family %d failed sock %p\n",
+ GNUNET_a2s (in,
+ in_len),
+ in->sa_family,
+ udp_sock);
+ timeout_task_cb (sock_info);
+ }
+
+ next_port:
+ GNUNET_free (in);
+ GNUNET_free (bind_in);
+ GNUNET_free (address);
+ GNUNET_free (bind_address);
+
+ if (65535 == udp_port)
+ return;
+ udp_port++;
+
+ read_send_task = GNUNET_SCHEDULER_add_delayed (SEND_DELAY,
+ &read_send,
+ si);
+}
+
+
+struct GNUNET_SCHEDULER_Task *
+GNUNET_get_udp_socket (struct GNUNET_UdpSocketInfo *sock_info,
+ GNUNET_NotifyUdpSocket nus)
+{
+ struct GNUNET_BurstMessage bm;
+ struct GNUNET_UdpSocketInfo *si = GNUNET_new (struct GNUNET_UdpSocketInfo);
+ char dgram[sizeof (struct GNUNET_BurstMessage)];
+ char *address;
+ struct sockaddr *in;
+ socklen_t in_len;
+
+ GNUNET_asprintf (&address,
+ "%s:%u",
+ sock_info->address,
+ sock_info->std_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "2 sock addr %s addr %s rtt %lu %u\n",
+ sock_info->address,
+ address,
+ sock_info->rtt.rel_value_us,
+ sock_info->std_port);
+ bm.local_port = sock_info->std_port;
+ in = udp_address_to_sockaddr (address, &in_len);
+ memcpy (dgram, &bm, sizeof(bm));
+ if (-1 == GNUNET_NETWORK_socket_sendto (sock_info->udp_sock,
+ dgram,
+ sizeof(dgram),
+ in,
+ in_len))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending burst to %s family %d failed sock %p\n",
+ GNUNET_a2s (in,
+ in_len),
+ in->sa_family,
+ sock_info->udp_sock);
+ }
+
+ nr_open_sockets = 0;
+ udp_port = 1024;
+ sock_info->has_port = GNUNET_NO;
+ sock_info->nus = nus;
+
+ GNUNET_memcpy (si, sock_info, sizeof (struct GNUNET_UdpSocketInfo));
+
+ read_send_task = GNUNET_SCHEDULER_add_delayed (SEND_DELAY,
+ &read_send,
+ si);
+ GNUNET_free (in);
+ GNUNET_free (address);
+ return read_send_task;
+}
+
+
+void
+GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch)
+{
+ struct GNUNET_UdpSocketInfo *sock_info;
+ struct GNUNET_UdpSocketInfo *pos;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "stopping burst\n");
+ if (NULL != read_send_task)
+ {
+ GNUNET_SCHEDULER_cancel (read_send_task);
+ read_send_task = NULL;
+ }
+ pos = sock_infos_head;
+ while (NULL != pos)
+ {
+ sock_info = pos;
+ pos = sock_info->next;
+ GNUNET_CONTAINER_DLL_remove (sock_infos_head,
+ sock_infos_tail,
+ sock_info);
+ if (NULL != sock_info->read_task)
+ GNUNET_SCHEDULER_cancel (sock_info->read_task);
+ if (NULL != sock_info->timeout_task)
+ GNUNET_SCHEDULER_cancel (sock_info->timeout_task);
+ if (do_not_touch != sock_info->udp_sock)
+ {
+ GNUNET_NETWORK_socket_close (sock_info->udp_sock);
+ if (NULL != sock_info->address)
+ GNUNET_free (sock_info->address);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "freeing sock_info %p\n",
+ sock_info);
+ GNUNET_free (sock_info);
+ }
+ }
+}
diff --git a/src/lib/util/program.c b/src/lib/util/program.c
index 2801b7650..e314ec477 100644
--- a/src/lib/util/program.c
+++ b/src/lib/util/program.c
@@ -415,6 +415,164 @@ GNUNET_PROGRAM_run (int argc,
GNUNET_NO);
}
+enum GNUNET_GenericReturnValue
+GNUNET_PROGRAM_conf_and_options (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *cfg_filename;
+ char *opt_cfg_filename;
+ char *logfile;
+ char *loglev;
+ const char *xdg;
+ int do_daemonize;
+ int ret;
+ const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
+ struct GNUNET_GETOPT_CommandLineOption service_options[] = {
+ GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
+ GNUNET_GETOPT_option_flag ('d',
+ "daemonize",
+ gettext_noop (
+ "do daemonize (detach from terminal)"),
+ &do_daemonize),
+ GNUNET_GETOPT_option_help (NULL),
+ GNUNET_GETOPT_option_loglevel (&loglev),
+ GNUNET_GETOPT_option_logfile (&logfile),
+ GNUNET_GETOPT_option_version (pd->version),
+ GNUNET_GETOPT_OPTION_END
+ };
+
+ xdg = getenv ("XDG_CONFIG_HOME");
+ if (NULL != xdg)
+ GNUNET_asprintf (&cfg_filename,
+ "%s%s%s",
+ xdg,
+ DIR_SEPARATOR_STR,
+ pd->config_file);
+ else
+ cfg_filename = GNUNET_strdup (pd->user_config_file);
+
+ loglev = NULL;
+ logfile = NULL;
+ opt_cfg_filename = NULL;
+ // FIXME we need to set this up for each service!
+ ret = GNUNET_GETOPT_run ("libgnunet",
+ service_options,
+ argc,
+ argv);
+ if (GNUNET_SYSERR == ret)
+ goto error;
+ if (GNUNET_NO == ret)
+ {
+ goto error;
+ }
+ // FIXME we need to set this up for each service!
+ // NOTE: that was not the idea. What are you proposing? -CG
+ if (GNUNET_OK !=
+ GNUNET_log_setup ("libgnunet",
+ "DEBUG",//loglev,
+ logfile))
+ {
+ GNUNET_break (0);
+ goto error;
+ }
+ if (NULL == cfg)
+ {
+ cfg = GNUNET_CONFIGURATION_create ();
+ if (NULL != opt_cfg_filename)
+ {
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_file_test (opt_cfg_filename)) ||
+ (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ opt_cfg_filename)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Malformed configuration file `%s', exit ...\n"),
+ opt_cfg_filename);
+ goto error;
+ }
+ }
+ else
+ {
+ if (GNUNET_YES ==
+ GNUNET_DISK_file_test (cfg_filename))
+ {
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ cfg_filename))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Malformed configuration file `%s', exit ...\n"),
+ cfg_filename);
+ GNUNET_free (cfg_filename);
+ goto error;;
+ }
+ }
+ else
+ {
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Malformed configuration, exit ...\n"));
+ GNUNET_free (cfg_filename);
+ goto error;
+ }
+ }
+ }
+ }
+
+ GNUNET_free (logfile);
+ GNUNET_free (loglev);
+ GNUNET_free (cfg_filename);
+ GNUNET_free (opt_cfg_filename);
+
+ return GNUNET_OK;
+
+ error:
+ GNUNET_SPEEDUP_stop_ ();
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (logfile);
+ GNUNET_free (loglev);
+ GNUNET_free (cfg_filename);
+ GNUNET_free (opt_cfg_filename);
+
+ return GNUNET_SYSERR;
+}
+
+
+static void
+monolith_main (void *cls)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
+ GNUNET_SERVICE_main (0,
+ NULL,
+ cfg,
+ GNUNET_NO);
+ GNUNET_DAEMON_main (0,
+ NULL,
+ cfg,
+ GNUNET_NO);
+}
+
+
+void
+GNUNET_PROGRAM_monolith_main (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+
+ if (GNUNET_YES != GNUNET_PROGRAM_conf_and_options (argc,
+ argv,
+ cfg))
+ return;
+ GNUNET_SCHEDULER_run (&monolith_main,
+ cfg);
+}
+
/* A list of daemons to be launched when GNUNET_main()
* is called
@@ -428,7 +586,9 @@ struct DaemonHandleList
struct DaemonHandleList *next;
/* Program to launch */
- GNUNET_PROGRAM_Main d;
+ GNUNET_SCHEDULER_TaskCallback d;
+
+ const char *daemon_name;
};
/* The daemon list */
@@ -437,15 +597,60 @@ static struct DaemonHandleList *hll_head = NULL;
/* The daemon list */
static struct DaemonHandleList *hll_tail = NULL;
+
+static void
+launch_daemons (void *cls)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
+ for (struct DaemonHandleList *hll = hll_head;
+ NULL != hll;
+ hll = hll->next)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Launching daemon %s\n",
+ hll->daemon_name);
+ GNUNET_SCHEDULER_add_now (hll->d,
+ cfg);
+ }
+}
+
+
+void
+GNUNET_DAEMON_main (int argc,
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ enum GNUNET_GenericReturnValue with_scheduler)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Entering GNUNET_DAEMON_main\n");
+ if (GNUNET_YES == with_scheduler)
+ {
+ if (GNUNET_YES != GNUNET_PROGRAM_conf_and_options (argc,
+ argv,
+ cfg))
+ return;
+ GNUNET_SCHEDULER_run (&launch_daemons,
+ cfg);
+ }
+ else
+ launch_daemons (cfg);
+}
+
+
enum GNUNET_GenericReturnValue
GNUNET_DAEMON_register (const char *daemon_name,
const char *daemon_help,
- GNUNET_PROGRAM_Main task)
+ GNUNET_SCHEDULER_TaskCallback task)
{
struct DaemonHandleList *hle;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "registering daemon %s\n",
+ daemon_name);
hle = GNUNET_new (struct DaemonHandleList);
hle->d = task;
+ hle->daemon_name = daemon_name;
GNUNET_CONTAINER_DLL_insert (hll_head, hll_tail, hle);
return GNUNET_OK;
}
diff --git a/src/lib/util/service.c b/src/lib/util/service.c
index 0922c8418..ffe8f8b00 100644
--- a/src/lib/util/service.c
+++ b/src/lib/util/service.c
@@ -2291,116 +2291,26 @@ launch_registered_services (void *cls)
void
GNUNET_SERVICE_main (int argc,
- char *const *argv)
+ char *const *argv,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ enum GNUNET_GenericReturnValue with_scheduler)
{
- char *cfg_filename;
- char *opt_cfg_filename;
- char *logfile;
- char *loglev;
- const char *xdg;
- int do_daemonize;
- int ret;
- struct GNUNET_CONFIGURATION_Handle *cfg;
- const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
- struct GNUNET_GETOPT_CommandLineOption service_options[] = {
- GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
- GNUNET_GETOPT_option_flag ('d',
- "daemonize",
- gettext_noop (
- "do daemonize (detach from terminal)"),
- &do_daemonize),
- GNUNET_GETOPT_option_help (NULL),
- GNUNET_GETOPT_option_loglevel (&loglev),
- GNUNET_GETOPT_option_logfile (&logfile),
- GNUNET_GETOPT_option_version (pd->version),
- GNUNET_GETOPT_OPTION_END
- };
-
- xdg = getenv ("XDG_CONFIG_HOME");
- if (NULL != xdg)
- GNUNET_asprintf (&cfg_filename,
- "%s%s%s",
- xdg,
- DIR_SEPARATOR_STR,
- pd->config_file);
- else
- cfg_filename = GNUNET_strdup (pd->user_config_file);
- cfg = GNUNET_CONFIGURATION_create ();
- // FIXME we need to set this up for each service!
- ret = GNUNET_GETOPT_run ("libgnunet",
- service_options,
- argc,
- argv);
- if (GNUNET_SYSERR == ret)
- goto shutdown;
- if (GNUNET_NO == ret)
- {
- goto shutdown;
- }
- // FIXME we need to set this up for each service!
- // NOTE: that was not the idea. What are you proposing? -CG
- if (GNUNET_OK !=
- GNUNET_log_setup ("libgnunet",
- loglev,
- logfile))
- {
- GNUNET_break (0);
- goto shutdown;
- }
- if (NULL != opt_cfg_filename)
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Entering GNUNET_SERVICE_main\n");
+ if (GNUNET_YES == with_scheduler)
{
- if ( (GNUNET_YES !=
- GNUNET_DISK_file_test (opt_cfg_filename)) ||
- (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- opt_cfg_filename)) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Malformed configuration file `%s', exit ...\n"),
- opt_cfg_filename);
- goto shutdown;
- }
+ if (GNUNET_YES != GNUNET_PROGRAM_conf_and_options (argc,
+ argv,
+ cfg))
+ return;
+ GNUNET_SCHEDULER_run (&launch_registered_services,
+ cfg);
}
else
- {
- if (GNUNET_YES ==
- GNUNET_DISK_file_test (cfg_filename))
- {
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- cfg_filename))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Malformed configuration file `%s', exit ...\n"),
- cfg_filename);
- GNUNET_free (cfg_filename);
- return;
- }
- }
- else
- {
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Malformed configuration, exit ...\n"));
- GNUNET_free (cfg_filename);
- return;
- }
- }
- }
+ launch_registered_services (cfg);
+
GNUNET_RESOLVER_connect (cfg);
- GNUNET_SCHEDULER_run (&launch_registered_services,
- cfg);
-shutdown:
- GNUNET_SPEEDUP_stop_ ();
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (logfile);
- GNUNET_free (loglev);
- GNUNET_free (cfg_filename);
- GNUNET_free (opt_cfg_filename);
}
diff --git a/src/meson.build.arm b/src/meson.build.arm
new file mode 100644
index 000000000..0109121ab
--- /dev/null
+++ b/src/meson.build.arm
@@ -0,0 +1,2 @@
+subdir('lib')
+subdir('service')
\ No newline at end of file
diff --git a/src/meson.build.arm_monolith b/src/meson.build.arm_monolith
new file mode 100644
index 000000000..10be46513
--- /dev/null
+++ b/src/meson.build.arm_monolith
@@ -0,0 +1,4 @@
+subdir('include')
+subdir('lib')
+subdir('plugin')
+subdir('service')
\ No newline at end of file
diff --git a/src/plugin/meson.build.arm_monolith
b/src/plugin/meson.build.arm_monolith
new file mode 100644
index 000000000..951ba81ce
--- /dev/null
+++ b/src/plugin/meson.build.arm_monolith
@@ -0,0 +1 @@
+subdir('peerstore')
\ No newline at end of file
diff --git a/src/plugin/peerstore/meson.build
b/src/plugin/peerstore/meson.build.arm_monolith
similarity index 83%
copy from src/plugin/peerstore/meson.build
copy to src/plugin/peerstore/meson.build.arm_monolith
index 1d22ca798..0c4123178 100644
--- a/src/plugin/peerstore/meson.build
+++ b/src/plugin/peerstore/meson.build.arm_monolith
@@ -1,6 +1,6 @@
shared_module('gnunet_plugin_peerstore_sqlite',
['plugin_peerstore_sqlite.c'],
- dependencies: [libgnunetutil_dep,
+ dependencies: [sodium_dep, gcrypt_dep, libgnunetutil_dep,
libgnunetsq_dep,
sqlite_dep],
include_directories: [incdir,
diff --git a/src/service/arm/Makefile.am b/src/service/arm/Makefile.am
index 26c940688..274705137 100644
--- a/src/service/arm/Makefile.am
+++ b/src/service/arm/Makefile.am
@@ -13,6 +13,8 @@ if USE_COVERAGE
XLIB = -lgcov
endif
+plugindir = $(libdir)/gnunet
+
lib_LTLIBRARIES = \
libgnunetarm.la \
libgnunettestingarm.la
@@ -69,6 +71,9 @@ check_PROGRAMS = \
test_exponential_backoff \
test_gnunet_service_arm
+check_SCRIPTS = \
+ test_arm_probnat.sh
+
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export
PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
@@ -94,3 +99,15 @@ test_gnunet_service_arm_SOURCES = \
EXTRA_DIST = \
test_arm_api_data.conf
+
+plugin_LTLIBRARIES = \
+ libgnunet_test_arm_plugin_probnat.la
+
+libgnunet_test_arm_plugin_probnat_la_SOURCES = \
+ test_arm_plugin_probnat.c
+libgnunet_test_arm_plugin_probnat_la_LIBADD = \
+ libgnunettestingarm.la \
+ $(top_builddir)/src/lib/testing/libgnunettesting.la \
+ $(top_builddir)/src/lib/util/libgnunetutil.la \
+ $(top_builddir)/src/service/testbed/libgnunettestingtestbed.la \
+ $(LTLIBINTL)
diff --git a/src/service/arm/meson.build.arm_monolith
b/src/service/arm/meson.build.arm_monolith
new file mode 100644
index 000000000..c953b2177
--- /dev/null
+++ b/src/service/arm/meson.build.arm_monolith
@@ -0,0 +1,31 @@
+libgnunetarm_src = ['arm_api.c',
+ 'arm_monitor_api.c']
+
+gnunetservicearm_src = ['gnunet-service-arm.c']
+
+testarmapi_src = ['test_arm_api.c']
+testexpbo_src = ['test_exponential_backoff.c']
+testgnunetservice_src = ['test_gnunet_service_arm.c']
+
+configure_file(input : 'arm.conf.in',
+ output : 'arm.conf',
+ configuration : cdata,
+ install: true,
+ install_dir: pkgcfgdir)
+
+libgnunetarm = library('gnunetarm',
+ libgnunetarm_src,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunetarm, url: 'https://www.gnunet.org',
+ description : 'Provides API for accessing the Automated Restart Manager
service')
+libgnunetarm_dep = declare_dependency(link_with : libgnunetarm)
+
+executable ('gnunet-service-arm',
+ gnunetservicearm_src,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetarm_dep, libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir') / 'gnunet' / 'libexec')
\ No newline at end of file
diff --git a/src/service/arm/test_arm_plugin_probnat.c
b/src/service/arm/test_arm_plugin_probnat.c
new file mode 100644
index 000000000..63830928f
--- /dev/null
+++ b/src/service/arm/test_arm_plugin_probnat.c
@@ -0,0 +1,79 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing/test_arm_plugin_probnat.c
+ * @brief a plugin to test burst nat traversal..
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_testing_arm_lib.h"
+#include "gnunet_testing_testbed_lib.h"
+
+
+static const char*
+get_conf_name (const char *my_node_id)
+{
+ const char *conf_name;
+ const char *dash;
+
+ dash = strchr (my_node_id, '-');
+ dash++;
+
+ if (0 == strcmp ("000000", dash))
+ conf_name = "test_arm_probnat_host.conf";
+ else if (0 == strcmp ("000003", dash))
+ conf_name = "test_arm_probnat_peer1.conf";
+ else if (0 == strcmp ("000006", dash))
+ conf_name = "test_arm_probnat_peer1.conf";
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Getting conf for id %s failed \n",
+ my_node_id);
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using conf %s",
+ conf_name);
+ return conf_name;
+}
+
+GNUNET_TESTING_MAKE_PLUGIN (
+ libgnunet_test_arm,
+ probnat,
+ GNUNET_TESTBED_cmd_system_create ("system",
+ my_node_id),
+ GNUNET_TESTING_ARM_cmd_start_peer ("start",
+ "system",
+ get_conf_name (my_node_id)),
+ GNUNET_TESTING_cmd_exec_va ("sleep",
+ GNUNET_OS_PROCESS_EXITED,
+ 0,
+ "sleep",
+ "3000",
+ NULL),
+ GNUNET_TESTING_cmd_stop_peer ("stop",
+ "start")
+ )
+
+/* end of test_arm_plugin_probnat.c */
diff --git a/src/lib/testing/test_netjail_api.sh
b/src/service/arm/test_arm_probnat.sh
similarity index 55%
copy from src/lib/testing/test_netjail_api.sh
copy to src/service/arm/test_arm_probnat.sh
index d9cb35c28..e69e0ee7c 100755
--- a/src/lib/testing/test_netjail_api.sh
+++ b/src/service/arm/test_arm_probnat.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-exec ../../../scripts/netjail/netjail_test_master.sh
gnunet-testing-netjail-launcher test_netjail_topo.conf # --num-peers=2
+exec ../../../scripts/netjail/netjail_test_master.sh
gnunet-testing-netjail-launcher test_arm_probnat_topo.conf
diff --git a/src/service/core/test_core_just_run_host.conf
b/src/service/arm/test_arm_probnat_host.conf
similarity index 73%
copy from src/service/core/test_core_just_run_host.conf
copy to src/service/arm/test_arm_probnat_host.conf
index 406b8dcc9..a4c1995d7 100644
--- a/src/service/core/test_core_just_run_host.conf
+++ b/src/service/arm/test_arm_probnat_host.conf
@@ -1,31 +1,26 @@
@INLINE@ ../transport/template_tng_cfg_peer1.conf
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/
+
+[PEER]
+#PRIVATE_KEY = $GNUNET_RUNTIME_DIR/private_host.key
[transport]
BINARY = gnunet-service-transport
#PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes
--log-file=$GNUNET_TEST_HOME/vg_peer1-%p
-UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock
-
-[PEER]
-PRIVATE_KEY = $GNUNET_RUNTIME_DIR/private.key
[communicator-tcp]
BINARY = gnunet-communicator-tcp
-BINDTO = 192.168.15.1:60002
+BINDTO = 60002
DISABLE_V6 = YES
IMMEDIATE_START = YES
-UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
#PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes
--log-file=$GNUNET_TEST_HOME/vg_ctpeer1-%p
#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
[communicator-udp]
#PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes
--log-file=$GNUNET_TEST_HOME/vg_cupeer1-%p
BINARY = gnunet-communicator-udp
-BINDTO = 192.168.15.1:60002
+BINDTO = 60002
DISABLE_V6 = YES
IMMEDIATE_START = YES
-UNIXPATH = $GNUNET_RUNTIME_DIR/udp-comm-p1.sock
[peerstore]
IMMEDIATE_START = YES
@@ -42,4 +37,5 @@ IMMEDIATE_START = YES
[hostlist]
IMMEDIATE_START = YES
-OPTIONS = -p
\ No newline at end of file
+OPTIONS = -p
+EXTERNAL_DNS_NAME = 192.168.1.1
\ No newline at end of file
diff --git a/src/lib/testing/test_netjail_topo.conf
b/src/service/arm/test_arm_probnat_topo.conf
similarity index 83%
copy from src/lib/testing/test_netjail_topo.conf
copy to src/service/arm/test_arm_probnat_topo.conf
index 216e3ae7c..05090a333 100644
--- a/src/lib/testing/test_netjail_topo.conf
+++ b/src/service/arm/test_arm_probnat_topo.conf
@@ -3,10 +3,10 @@ SUBNETS = 1
CARRIER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
SUBNET_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
PEER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev
$UPLINK root netm delay 100ms 10ms;
-TESTBED_PLUGIN = libgnunet_test_testing_plugin_ping
-CARRIER_PEERS = 1
+TESTBED_PLUGIN = libgnunet_test_arm_plugin_probnat
+CARRIER_PEERS = 0
SUBNET_PEERS = 1
[BACKBONE]
-CARRIERS = 1
+CARRIERS = 2
BACKBONE_PEERS = 1
diff --git a/src/service/arm/testing_arm_cmd_start_peer.c
b/src/service/arm/testing_arm_cmd_start_peer.c
index 73d7ca4e7..28f68fbd9 100644
--- a/src/service/arm/testing_arm_cmd_start_peer.c
+++ b/src/service/arm/testing_arm_cmd_start_peer.c
@@ -87,14 +87,19 @@ conn_status (
enum GNUNET_GenericReturnValue connected)
{
struct GNUNET_TESTING_StartPeerState *sps = cls;
+ struct GNUNET_TESTING_AsyncContext ac = sps->ac;
- if (GNUNET_OK != connected)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "We %s arm\n",
+ GNUNET_OK != connected ? "disconnected from" : "connected to");
+ if (GNUNET_NO == ac.finished && GNUNET_OK != connected)
{
GNUNET_break (0);
GNUNET_TESTING_async_fail (&sps->ac);
return;
}
- GNUNET_TESTING_async_finish (&sps->ac);
+ else if (GNUNET_NO == ac.finished)
+ GNUNET_TESTING_async_finish (&sps->ac);
}
diff --git a/src/service/core/Makefile.am b/src/service/core/Makefile.am
index 6de6762b1..1466db582 100644
--- a/src/service/core/Makefile.am
+++ b/src/service/core/Makefile.am
@@ -15,8 +15,12 @@ if USE_COVERAGE
XLIB = -lgcov
endif
-#plugin_LTLIBRARIES = \
-# libgnunet_test_core_plugin_cmd_just_run.la
+plugin_LTLIBRARIES = \
+ #libgnunet_test_core_plugin_cmd_just_run.la \
+ libgnunet_test_core_plugin_cmd_run_emu.la
+
+TESTING_LIBS = \
+ libgnunetcoretesting.la
lib_LTLIBRARIES = \
libgnunetcore.la
@@ -32,28 +36,44 @@ libgnunetcore_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
-version-info 0:1:0
-libgnunet_test_core_plugin_cmd_just_run_la_SOURCES = \
- test_core_plugin_cmd_just_run.c
-libgnunet_test_core_plugin_cmd_just_run_la_LIBADD = \
- libgnunettestingcore.la \
- $(top_builddir)/src/service/transport/libgnunettestingtransport.la \
- $(top_builddir)/src/lib/testing/libgnunettesting.la \
+libgnunet_test_core_plugin_cmd_run_emu_la_SOURCES = \
+ test_core_plugin_cmd_run_emu.c
+libgnunet_test_core_plugin_cmd_run_emu_la_LIBADD = \
+ libgnunetcoretesting.la \
$(top_builddir)/src/service/transport/libgnunettransportapplication.la \
$(top_builddir)/src/service/transport/libgnunettransportcore.la \
$(top_builddir)/src/lib/hello/libgnunethello.la \
$(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
+ $(top_builddir)/src/service/transport/libgnunettransporttesting2.la \
+ $(top_builddir)/src/service/testing/libgnunettesting.la \
$(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/service/arm/libgnunetarm.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(LTLIBINTL)
-libgnunet_test_core_plugin_cmd_just_run_la_LDFLAGS = \
+libgnunet_test_core_plugin_cmd_run_emu_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-libgnunettestingcore_la_SOURCES = \
- testing_core_cmd_connecting_peers.c
-libgnunettestingcore_la_LIBADD = \
- $(top_builddir)/src/lib/testing/libgnunettesting.la \
- $(top_builddir)/src/service/transport/libgnunettestingtransport.la \
+#libgnunet_test_core_plugin_cmd_just_run_la_SOURCES = \
+# test_core_plugin_cmd_just_run.c
+#libgnunet_test_core_plugin_cmd_just_run_la_LIBADD = \
+# libgnunettestingcore.la \
+# $(top_builddir)/src/service/transport/libgnunettestingtransport.la \
+# $(top_builddir)/src/lib/testing/libgnunettesting.la \
+# $(top_builddir)/src/service/transport/libgnunettransportapplication.la \
+# $(top_builddir)/src/service/transport/libgnunettransportcore.la \
+# $(top_builddir)/src/lib/hello/libgnunethello.la \
+# $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
+# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
+# $(top_builddir)/src/service/arm/libgnunetarm.la \
+# $(top_builddir)/src/lib/util/libgnunetutil.la \
+# $(LTLIBINTL)
+#libgnunet_test_core_plugin_cmd_just_run_la_LDFLAGS = \
+# $(GN_PLUGIN_LDFLAGS)
+
+libgnunetcoretesting_la_SOURCES = \
+ core_api_cmd_connecting_peers.c
+libgnunetcoretesting_la_LIBADD = \
+ $(top_builddir)/src/service/testing/libgnunettesting.la \
$(top_builddir)/src/service/arm/libgnunetarm.la \
$(top_builddir)/src/service/transport/libgnunettransportapplication.la \
$(top_builddir)/src/lib/hello/libgnunethello.la \
diff --git a/src/service/core/test_core_just_run_topo.conf
b/src/service/core/test_core_just_run_topo.conf
new file mode 100644
index 000000000..2ca26217f
--- /dev/null
+++ b/src/service/core/test_core_just_run_topo.conf
@@ -0,0 +1,9 @@
+M:1
+N:2
+X:1
+T:libgnunet_test_core_plugin_cmd_just_run
+K:1|{connect:{P:1:1:tcp}}
+R:1|{tcp_port:0}|{udp_port:0}
+R:2|{tcp_port:0}|{udp_port:0}
+P:1:1|{connect:{K:1:tcp}}
+P:2:1|{connect:{K:1:tcp}}
diff --git a/src/service/core/test_core_plugin_cmd_just_run.c
b/src/service/core/test_core_plugin_cmd_run_emu.c
similarity index 72%
copy from src/service/core/test_core_plugin_cmd_just_run.c
copy to src/service/core/test_core_plugin_cmd_run_emu.c
index a2b331c1f..6d06c14f1 100644
--- a/src/service/core/test_core_plugin_cmd_just_run.c
+++ b/src/service/core/test_core_plugin_cmd_run_emu.c
@@ -24,13 +24,15 @@
* @author t3sserakt
*/
#include "platform.h"
+#include "gnunet_testing_barrier.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_transport_core_service.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_core_service.h"
-#include "gnunet_testing_lib.h"
-#include "gnunet_testing_transport_lib.h"
-#include "gnunet_testing_core_lib.h"
+#include "gnunet_transport_testing_ng_lib.h"
+#include "gnunet_core_testing_lib.h"
/**
* Generic logging shortcut
@@ -47,11 +49,7 @@
static struct GNUNET_TESTING_Command block_script;
-static struct GNUNET_TESTING_Command connect_peers;
-
-static struct GNUNET_TESTING_Command local_prepared;
-
-static struct GNUNET_TESTING_Command start_peer;
+static struct GNUNET_TESTING_Command emu_run_script;
static struct GNUNET_TESTING_Interpreter *is;
@@ -200,6 +198,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
unsigned int sscanf_ret = 0;
char **argv = NULL;
int argc = 0;
+ char **argv_emu = NULL;
+ int argc_emu = 0;
ts->finished_cb = finished_cb;
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -247,28 +247,23 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
block_script = GNUNET_TESTING_cmd_block_until_external_trigger (
"block-script");
- connect_peers = GNUNET_CORE_cmd_connect_peers ("connect-peers",
- "start-peer",
- "system-create",
- num,
- topology,
- 0,
- GNUNET_NO,
- NULL);
- local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
- "local-test-prepared",
- write_message);
-
-
- if (1 == m_int)
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_core_just_run.conf");
+
+ if (1 == n_int)
{
- GNUNET_asprintf (&ts->cfgname,
- "test_core_just_run_host.conf");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Is n_int 1: %u\n",
+ n_int);
+ GNUNET_array_append (argv_emu, argc_emu, "Pixel_6a_API_31");
}
- else
+ else if (0 != n_int)
{
- GNUNET_asprintf (&ts->cfgname,
- "test_core_just_run.conf");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Is n_int not 0: %u\n",
+ n_int);
+ GNUNET_array_append (argv_emu, argc_emu, "Pixel_6a_API_31_II");
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -285,56 +280,18 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
m,
n);
- /*struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (ephemeral_key,
- GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY,
- struct EphemeralKeyMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (ping,
- GNUNET_MESSAGE_TYPE_CORE_PING,
- struct PingMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (pong,
- GNUNET_MESSAGE_TYPE_CORE_PONG,
- struct PongMessage,
- NULL),
- GNUNET_MQ_handler_end ()
- };*/
-
- start_peer = GNUNET_TESTING_cmd_start_peer ("start-peer",
- "system-create",
- num,
- node_ip,
- ts->cfgname,
- GNUNET_NO);
-
struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_system_create ("system-create",
- ts->testdir),
- start_peer,
- GNUNET_TESTING_cmd_barrier_reached ("ready-to-connect-reached",
- "ready-to-connect",
- GNUNET_NO,
- num,
- GNUNET_NO,
- write_message),
- connect_peers,
+ GNUNET_TESTING_cmd_exec_bash_script ("emu_run",
+ "emu_run.sh",
+ argv_emu,
+ argc_emu,
+ &child_completed_callback),
GNUNET_TESTING_cmd_exec_bash_script ("script",
"block.sh",
argv,
argc,
&child_completed_callback),
block_script,
- GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached",
- "test-case-finished",
- GNUNET_NO,
- num,
- GNUNET_NO,
- write_message),
- GNUNET_TESTING_cmd_stop_peer ("stop-peer",
- "start-peer"),
- GNUNET_TESTING_cmd_system_destroy ("system-destroy",
- "system-create"),
GNUNET_TESTING_cmd_end ()
};
@@ -355,7 +312,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
* @return the exported block API
*/
void *
-libgnunet_test_core_plugin_cmd_just_run_init (void *cls)
+libgnunet_test_core_plugin_cmd_run_emu_init (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api;
@@ -373,11 +330,11 @@ libgnunet_test_core_plugin_cmd_just_run_init (void *cls)
/**
* Exit point from the plugin.
*
- * @param cls the return value from
#libgnunet_test_transport_plugin_just_run_init
+ * @param cls the return value from
#libgnunet_test_transport_plugin_run_emu_init
* @return NULL
*/
void *
-libgnunet_test_core_plugin_cmd_just_run_done (void *cls)
+libgnunet_test_core_plugin_cmd_run_emu_done (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api = cls;
diff --git a/src/service/core/test_core_run_emu_topo.conf
b/src/service/core/test_core_run_emu_topo.conf
new file mode 100644
index 000000000..78d6d4407
--- /dev/null
+++ b/src/service/core/test_core_run_emu_topo.conf
@@ -0,0 +1,8 @@
+M:1
+N:2
+X:1
+T:libgnunet_test_core_plugin_cmd_run_emu
+K:1|{connect:{P:1:1:tcp}}
+R:1|{tcp_port:1}|{udp_port:1}
+P:1:1|{connect:{K:1:tcp}}
+P:2:1|{connect:{K:1:tcp}}
\ No newline at end of file
diff --git a/src/service/meson.build b/src/service/meson.build.arm
similarity index 76%
copy from src/service/meson.build
copy to src/service/meson.build.arm
index b40ce9422..4697f01a3 100644
--- a/src/service/meson.build
+++ b/src/service/meson.build.arm
@@ -5,38 +5,10 @@ if get_option('monolith')
endif
subdir('util')
-subdir('statistics')
-# FIXME: subdir('testbed')
subdir('arm')
subdir('peerstore')
subdir('nat')
-subdir('nat-auto')
subdir('transport')
-subdir('core')
-subdir('nse')
-subdir('hostlist')
-subdir('topology')
-subdir('dns')
-subdir('identity')
-subdir('namecache')
-subdir('namestore')
-subdir('datacache')
-subdir('datastore')
-subdir('dht')
-subdir('cadet')
-subdir('seti')
-subdir('setu')
-subdir('regex')
-subdir('revocation')
-subdir('vpn')
-subdir('gns')
-subdir('zonemaster')
-subdir('fs')
-subdir('exit')
-subdir('pt')
-subdir('reclaim')
-subdir('messenger')
-subdir('rest')
if not get_option('monolith')
subdir_done()
diff --git a/src/service/meson.build b/src/service/meson.build.arm_monolith
similarity index 55%
copy from src/service/meson.build
copy to src/service/meson.build.arm_monolith
index b40ce9422..0d299bbe8 100644
--- a/src/service/meson.build
+++ b/src/service/meson.build.arm_monolith
@@ -6,37 +6,10 @@ endif
subdir('util')
subdir('statistics')
-# FIXME: subdir('testbed')
subdir('arm')
subdir('peerstore')
subdir('nat')
-subdir('nat-auto')
subdir('transport')
-subdir('core')
-subdir('nse')
-subdir('hostlist')
-subdir('topology')
-subdir('dns')
-subdir('identity')
-subdir('namecache')
-subdir('namestore')
-subdir('datacache')
-subdir('datastore')
-subdir('dht')
-subdir('cadet')
-subdir('seti')
-subdir('setu')
-subdir('regex')
-subdir('revocation')
-subdir('vpn')
-subdir('gns')
-subdir('zonemaster')
-subdir('fs')
-subdir('exit')
-subdir('pt')
-subdir('reclaim')
-subdir('messenger')
-subdir('rest')
if not get_option('monolith')
subdir_done()
@@ -49,11 +22,8 @@ endif
libgnunet = library('gnunet',
gnunet_src,
dependencies: [
- mhd_dep,
sodium_dep,
gcrypt_dep,
- curl_dep,
- json_dep,
zlib_dep,
sqlite_dep,
unistr_dep,
@@ -61,16 +31,9 @@ libgnunet = library('gnunet',
idn_dep,
libgnunetutil_dep,
libgnunethello_dep,
- libgnunetjson_dep,
- libgnunetblock_dep,
- libgnunetblockgroup_dep,
- libgnunetregexblock_dep,
- libgnunetgnsrecord_dep,
- libgnunetgnsrecordjson_dep,
jose_dep,
m_dep,
- pthread_dep,
- libgnunetcurl_dep],
+ pthread_dep],
c_args: ['-DHAVE_GNUNET_MONOLITH=1'],
- include_directories: [incdir, configuration_inc, exitdir])
+ include_directories: [incdir, configuration_inc])
libgnunet_dep = declare_dependency(link_with : libgnunet)
diff --git a/src/service/nat/gnunet-service-nat.c
b/src/service/nat/gnunet-service-nat.c
index a36e8da1c..2c6c9bbd9 100644
--- a/src/service/nat/gnunet-service-nat.c
+++ b/src/service/nat/gnunet-service-nat.c
@@ -1875,8 +1875,8 @@ check_add_global_address (
void *cls,
const struct GNUNET_NAT_AddGlobalAddressMessage *message)
{
- const char *buf = (const char *) &message[1];
- uint16_t blen = ntohs (message->address_length);
+ //const char *buf = (const char *) &message[1];
+ //uint16_t blen = ntohs (message->address_length);
size_t left = ntohs (message->header.size) - sizeof(*message);
if (left != ntohs (message->address_length))
@@ -1884,11 +1884,11 @@ check_add_global_address (
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if ('\0' != buf[blen - 1])
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ /* if ('\0' != buf[blen - 1]) */
+ /* { */
+ /* GNUNET_break_op (0); */
+ /* return GNUNET_SYSERR; */
+ /* } */
return GNUNET_OK;
}
@@ -1907,16 +1907,20 @@ handle_add_global_address (
{
struct ClientHandle *ch = cls;
const char *buf = (const char *) &message[1];
- uint16_t blen = ntohs (message->address_length);
+ //uint16_t blen = ntohs (message->address_length);
struct sockaddr_in sockaddr_ipv4 = {
.sin_family = AF_INET
};
- GNUNET_assert ('\0' == buf[blen - 1]);
+ //GNUNET_assert ('\0' == buf[blen - 1]);
if (1 != inet_pton (AF_INET,
buf,
&sockaddr_ipv4.sin_addr))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "natting address %s length %u no ipv4\n",
+ buf,
+ message->address_length);
GNUNET_break (0);
GNUNET_SERVICE_client_continue (ch->client);
return;
diff --git a/src/service/nat/meson.build
b/src/service/nat/meson.build.arm_monolith
similarity index 90%
copy from src/service/nat/meson.build
copy to src/service/nat/meson.build.arm_monolith
index 6cf204d34..72b3f893a 100644
--- a/src/service/nat/meson.build
+++ b/src/service/nat/meson.build.arm_monolith
@@ -23,9 +23,9 @@ endif
libgnunetnat = library('gnunetnat',
libgnunetnat_src,
- soversion: '2',
+ soversion: '',
version: '2.0.0',
- dependencies: libgnunetutil_dep,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir'))
@@ -37,7 +37,7 @@ libgnunetnat = library('gnunetnatnew',
'nat_api_stun.c'],
soversion: '2',
version: '2.0.0',
- dependencies: libgnunetutil_dep,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir'))
@@ -45,7 +45,7 @@ libgnunetnat_dep = declare_dependency(link_with :
libgnunetnat)
executable ('gnunet-service-nat',
gnunetservicenat_src,
- dependencies: [libgnunetnat_dep, libgnunetutil_dep,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetnat_dep,
libgnunetutil_dep,
libgnunetstatistics_dep],
include_directories: [incdir, configuration_inc],
install: true,
diff --git a/src/service/nat/nat_api.c b/src/service/nat/nat_api.c
index 52c74d5db..ef7789421 100644
--- a/src/service/nat/nat_api.c
+++ b/src/service/nat/nat_api.c
@@ -455,6 +455,7 @@ GNUNET_NAT_register (const struct
GNUNET_CONFIGURATION_Handle *cfg,
return nh;
}
+
void
GNUNET_NAT_add_global_address (struct GNUNET_NAT_Handle *nh,
char *addr,
diff --git a/src/service/peerstore/gnunet-service-peerstore.c
b/src/service/peerstore/gnunet-service-peerstore.c
index fa4e322a2..dc80006ec 100644
--- a/src/service/peerstore/gnunet-service-peerstore.c
+++ b/src/service/peerstore/gnunet-service-peerstore.c
@@ -659,8 +659,9 @@ handle_iterate_stop (void *cls,
break;
if (NULL == ic)
{
- GNUNET_break (0);
- GNUNET_SERVICE_client_drop (pc->client);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Iteration already finished.\n");
+ GNUNET_SERVICE_client_continue (pc->client);
return;
}
GNUNET_CONTAINER_DLL_remove (pc->op_head, pc->op_tail, ic);
diff --git a/src/service/peerstore/meson.build
b/src/service/peerstore/meson.build.arm_monolith
similarity index 95%
copy from src/service/peerstore/meson.build
copy to src/service/peerstore/meson.build.arm_monolith
index 2c1ef4a67..10f08f6d4 100644
--- a/src/service/peerstore/meson.build
+++ b/src/service/peerstore/meson.build.arm_monolith
@@ -19,9 +19,7 @@ endif
libgnunetpeerstore = library('gnunetpeerstore',
libgnunetpeerstore_src,
- soversion: '0',
- version: '0.0.0',
- dependencies: [libgnunetutil_dep, libgnunethello_dep],
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep,
libgnunethello_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir'))
@@ -31,7 +29,7 @@ libgnunetpeerstore_dep = declare_dependency(link_with :
libgnunetpeerstore)
executable ('gnunet-service-peerstore',
gnunetservicepeerstore_src,
- dependencies: [libgnunetpeerstore_dep,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetpeerstore_dep,
libgnunetutil_dep,
libgnunethello_dep],
include_directories: [incdir, configuration_inc],
diff --git a/src/service/rest/gnunet-rest-server.c
b/src/service/rest/gnunet-rest-server.c
index d71f8d352..97931ff43 100644
--- a/src/service/rest/gnunet-rest-server.c
+++ b/src/service/rest/gnunet-rest-server.c
@@ -1145,10 +1145,7 @@ setup_plugin (const char *name,
* @param c configuration
*/
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+run_ (const struct GNUNET_CONFIGURATION_Handle *c)
{
static const char *err_page = "{}";
char *addr_str;
@@ -1433,6 +1430,24 @@ run (void *cls,
}
-GNUNET_DAEMON_MAIN ("rest", _ ("GNUnet REST service"), &run)
+static void
+run_monolith (void *cls)
+{
+ const struct GNUNET_CONFIGURATION_Handle *c = cls;
+
+ run_ (c);
+}
+
+
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
+{
+ run_ (c);
+}
+
+GNUNET_DAEMON_MAIN ("rest", _ ("GNUnet REST service"), &run, &run_monolith)
/* end of gnunet-rest-server.c */
diff --git a/src/service/statistics/meson.build
b/src/service/statistics/meson.build.arm_monolith
similarity index 87%
copy from src/service/statistics/meson.build
copy to src/service/statistics/meson.build.arm_monolith
index 9c4d8c649..abe4faec5 100644
--- a/src/service/statistics/meson.build
+++ b/src/service/statistics/meson.build.arm_monolith
@@ -17,9 +17,7 @@ endif
libgnunetstatistics = library('gnunetstatistics',
libgnunetstatistics_src,
- soversion: '2',
- version: '2.0.0',
- dependencies: libgnunetutil_dep,
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir'))
@@ -29,7 +27,7 @@ pkg.generate(libgnunetstatistics, url:
'https://www.gnunet.org',
executable ('gnunet-service-statistics',
gnunetservicestatistics_src,
- dependencies: [libgnunetstatistics_dep, libgnunetutil_dep],
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetstatistics_dep,
libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir') / 'gnunet' / 'libexec')
diff --git a/src/service/testbed/testbed_api_cmd_system_create.c
b/src/service/testbed/testbed_api_cmd_system_create.c
index 2f780ec73..32099097a 100644
--- a/src/service/testbed/testbed_api_cmd_system_create.c
+++ b/src/service/testbed/testbed_api_cmd_system_create.c
@@ -29,6 +29,8 @@
#include "gnunet_testbed_lib.h"
#include "gnunet_testing_testbed_lib.h"
+#define BASE_DIR "testdir"
+
/**
* Struct to hold information for callbacks.
*
@@ -37,7 +39,7 @@ struct TestSystemState
{
struct GNUNET_TESTBED_System *test_system;
- const char *testdir;
+ char *testdir;
};
@@ -98,21 +100,25 @@ system_create_cleanup (void *cls)
/**
- * Create command.
+ * This command is setting up a test environment for a peer to start.
*
- * @param label name for command.
- * @param label name for the test environment directory.
- * @return command.
+ * @param label Name for command.
+ * @param my_node_id The specific id of the node this command is running on.
+ * A sub string of the id is the process id of the master process. This id is
+ * used to build the name of the temporary directory of the peer to start.
*/
struct GNUNET_TESTING_Command
GNUNET_TESTBED_cmd_system_create (const char *label,
- const char *testdir)
+ const char *my_node_id)
{
struct TestSystemState *tss;
tss = GNUNET_new (struct TestSystemState);
- tss->testdir = testdir;
-
+ GNUNET_asprintf (&tss->testdir,
+ "%s%s",
+ BASE_DIR,
+ my_node_id);
+
return GNUNET_TESTING_command_new (tss,
label,
&system_create_run,
diff --git a/src/service/transport/Makefile.am
b/src/service/transport/Makefile.am
index 82dbd0dc2..604fb4948 100644
--- a/src/service/transport/Makefile.am
+++ b/src/service/transport/Makefile.am
@@ -207,13 +207,30 @@ gnunet_service_transport_LDADD = \
$(LIBGCRYPT_LIBS) \
$(GN_LIBINTL)
-#plugin_LTLIBRARIES = \
-# libgnunet_test_transport_plugin_cmd_simple_send_performance.la \
-# libgnunet_test_transport_plugin_cmd_nat_upnp.la \
-# libgnunet_test_transport_plugin_cmd_simple_send.la \
-# libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \
-# libgnunet_test_transport_plugin_cmd_simple_send_dv.la \
-# libgnunet_test_transport_plugin_cmd_udp_backchannel.la
+plugin_LTLIBRARIES = \
+ #libgnunet_test_transport_plugin_cmd_nat_mapping.la \
+ libgnunet_test_transport_plugin_cmd_simple_send_performance.la \
+ libgnunet_test_transport_plugin_cmd_nat_upnp.la \
+ libgnunet_test_transport_plugin_cmd_simple_send.la \
+ libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \
+ libgnunet_test_transport_plugin_cmd_simple_send_dv.la \
+ libgnunet_test_transport_plugin_cmd_udp_backchannel.la
+
+#libgnunet_test_transport_plugin_cmd_nat_mapping_la_SOURCES = \
+# test_transport_plugin_cmd_nat_mapping.c
+#libgnunet_test_transport_plugin_cmd_nat_mapping_la_LIBADD = \
+# libgnunettransporttesting2.la \
+# libgnunettransportapplication.la \
+# libgnunettransportcore.la \
+# $(top_builddir)/src/service/testing/libgnunettesting.la \
+# $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
+# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
+# $(top_builddir)/src/lib/hello/libgnunethello.la \
+# $(top_builddir)/src/service/arm/libgnunetarm.la \
+# $(top_builddir)/src/lib/util/libgnunetutil.la \
+# $(LTLIBINTL)
+#libgnunet_test_transport_plugin_cmd_nat_mapping_la_LDFLAGS = \
+# $(GN_PLUGIN_LDFLAGS)
libgnunet_test_transport_plugin_cmd_nat_upnp_la_SOURCES = \
test_transport_plugin_cmd_nat_upnp.c
diff --git a/src/service/transport/gnunet-communicator-tcp.c
b/src/service/transport/gnunet-communicator-tcp.c
index 7f8861e23..391c9fba8 100644
--- a/src/service/transport/gnunet-communicator-tcp.c
+++ b/src/service/transport/gnunet-communicator-tcp.c
@@ -3915,6 +3915,7 @@ init_socket (struct sockaddr *addr,
&mq_init,
NULL,
&enc_notify_cb,
+ NULL,
NULL);
if (NULL == ch)
diff --git a/src/service/transport/gnunet-communicator-udp.c
b/src/service/transport/gnunet-communicator-udp.c
index 6e4de9626..b8b93fcfa 100644
--- a/src/service/transport/gnunet-communicator-udp.c
+++ b/src/service/transport/gnunet-communicator-udp.c
@@ -656,6 +656,17 @@ struct ReceiverAddress
*/
struct GNUNET_TIME_Absolute timeout;
+ /**
+ * Socket this receiver got via NAT traversal.
+ * NULL if the default socket is used.
+ */
+ struct GNUNET_NETWORK_Handle *udp_sock;
+
+ /**
+ * Read task, if this receiver has its own socket.
+ */
+ struct GNUNET_SCHEDULER_Task *read_task;
+
/**
* MTU we allowed transport for this receiver's KX queue.
*/
@@ -813,7 +824,7 @@ static struct BroadcastInterface *bi_tail;
/**
* Our socket.
*/
-static struct GNUNET_NETWORK_Handle *udp_sock;
+static struct GNUNET_NETWORK_Handle *default_udp_sock;
/**
* #GNUNET_YES if #udp_sock supports IPv6.
@@ -860,11 +871,19 @@ static struct GNUNET_NAT_Handle *nat;
*/
static uint16_t my_port;
+/**
+ * Our ipv4 address.
+ */
+char *my_ipv4;
+
/**
* IPv6 disabled or not.
*/
static int disable_v6;
+static struct GNUNET_SCHEDULER_Task *burst_task;
+
+
static void
eddsa_priv_to_hpke_key (struct GNUNET_CRYPTO_EddsaPrivateKey *edpk,
struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
@@ -898,7 +917,7 @@ bi_destroy (struct BroadcastInterface *bi)
if (AF_INET6 == bi->sa->sa_family)
{
/* Leave the multicast group */
- if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock,
+ if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (default_udp_sock,
IPPROTO_IPV6,
IPV6_LEAVE_GROUP,
&bi->mcreq,
@@ -948,6 +967,12 @@ receiver_destroy (struct ReceiverAddress *receiver)
GNUNET_MQ_destroy (receiver->d_mq);
receiver->d_mq = NULL;
}
+ if (NULL != receiver->udp_sock)
+ {
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_NETWORK_socket_close (receiver->udp_sock));
+ receiver->udp_sock = NULL;
+ }
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (receivers,
&receiver->key,
@@ -2034,6 +2059,254 @@ sockaddr_to_udpaddr_string (const struct sockaddr
*address,
}
+static struct GNUNET_NETWORK_Handle *
+get_socket (struct ReceiverAddress *receiver)
+{
+ struct GNUNET_NETWORK_Handle *udp_sock;
+
+ if (NULL == receiver->udp_sock)
+ udp_sock = default_udp_sock;
+ else
+ udp_sock = receiver->udp_sock;
+
+ return udp_sock;
+}
+
+
+/**
+ * Convert UDP bind specification to a `struct sockaddr *`
+ *
+ * @param bindto bind specification to convert
+ * @param[out] sock_len set to the length of the address
+ * @return converted bindto specification
+ */
+static struct sockaddr *
+udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
+{
+ struct sockaddr *in;
+ unsigned int port;
+ char dummy[2];
+ char *colon;
+ char *cp;
+
+ if (1 == sscanf (bindto, "%u%1s", &port, dummy))
+ {
+ /* interpreting value as just a PORT number */
+ if (port > UINT16_MAX)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "BINDTO specification `%s' invalid: value too large for
port\n",
+ bindto);
+ return NULL;
+ }
+ if (GNUNET_YES == disable_v6)
+ {
+ struct sockaddr_in *i4;
+
+ i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
+ i4->sin_family = AF_INET;
+ i4->sin_port = htons ((uint16_t) port);
+ *sock_len = sizeof(struct sockaddr_in);
+ in = (struct sockaddr *) i4;
+ }
+ else
+ {
+ struct sockaddr_in6 *i6;
+
+ i6 = GNUNET_malloc (sizeof(struct sockaddr_in6));
+ i6->sin6_family = AF_INET6;
+ i6->sin6_port = htons ((uint16_t) port);
+ *sock_len = sizeof(struct sockaddr_in6);
+ in = (struct sockaddr *) i6;
+ }
+ return in;
+ }
+ cp = GNUNET_strdup (bindto);
+ colon = strrchr (cp, ':');
+ if (NULL != colon)
+ {
+ /* interpret value after colon as port */
+ *colon = '\0';
+ colon++;
+ if (1 == sscanf (colon, "%u%1s", &port, dummy))
+ {
+ /* interpreting value as just a PORT number */
+ if (port > UINT16_MAX)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "BINDTO specification `%s' invalid: value too large for
port\n",
+ bindto);
+ GNUNET_free (cp);
+ return NULL;
+ }
+ }
+ else
+ {
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_ERROR,
+ "BINDTO specification `%s' invalid: last ':' not followed by number\n",
+ bindto);
+ GNUNET_free (cp);
+ return NULL;
+ }
+ }
+ else
+ {
+ /* interpret missing port as 0, aka pick any free one */
+ port = 0;
+ }
+ {
+ /* try IPv4 */
+ struct sockaddr_in v4;
+
+ memset (&v4, 0, sizeof(v4));
+ if (1 == inet_pton (AF_INET, cp, &v4.sin_addr))
+ {
+ v4.sin_family = AF_INET;
+ v4.sin_port = htons ((uint16_t) port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ v4.sin_len = sizeof(struct sockaddr_in);
+#endif
+ in = GNUNET_memdup (&v4, sizeof(struct sockaddr_in));
+ *sock_len = sizeof(struct sockaddr_in);
+ GNUNET_free (cp);
+ return in;
+ }
+ }
+ {
+ /* try IPv6 */
+ struct sockaddr_in6 v6;
+ const char *start;
+
+ memset (&v6, 0, sizeof(v6));
+ start = cp;
+ if (('[' == *cp) && (']' == cp[strlen (cp) - 1]))
+ {
+ start++; /* skip over '[' */
+ cp[strlen (cp) - 1] = '\0'; /* eat ']' */
+ }
+ if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
+ {
+ v6.sin6_family = AF_INET6;
+ v6.sin6_port = htons ((uint16_t) port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ v6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ in = GNUNET_memdup (&v6, sizeof(v6));
+ *sock_len = sizeof(v6);
+ GNUNET_free (cp);
+ return in;
+ }
+ }
+ /* #5528 FIXME (feature!): maybe also try getnameinfo()? */
+ GNUNET_free (cp);
+ return NULL;
+}
+
+
+static void
+sock_read (void *cls);
+
+
+static enum GNUNET_GenericReturnValue
+create_receiver (const struct GNUNET_PeerIdentity *peer,
+ const char *address,
+ struct GNUNET_NETWORK_Handle *udp_sock)
+{
+ struct GNUNET_HashContext *hsh;
+ struct ReceiverAddress *receiver;
+ struct GNUNET_HashCode receiver_key;
+ const char *path;
+ struct sockaddr *in;
+ socklen_t in_len;
+
+ if (0 != strncmp (address,
+ COMMUNICATOR_ADDRESS_PREFIX "-",
+ strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
+ in = udp_address_to_sockaddr (path, &in_len);
+
+ if (NULL == in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to setup UDP socket address\n");
+ return GNUNET_SYSERR;
+ }
+ if ((AF_INET6 == in->sa_family) &&
+ (GNUNET_YES == disable_v6))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "IPv6 disabled, skipping %s\n", address);
+ GNUNET_free (in);
+ return GNUNET_SYSERR;
+ }
+ else if (AF_INET == in->sa_family)
+ {
+ struct sockaddr_in *sin = (struct sockaddr_in *)in;
+ if (0 == sin->sin_port)
+ return GNUNET_NO;
+ }
+
+ hsh = GNUNET_CRYPTO_hash_context_start ();
+ GNUNET_CRYPTO_hash_context_read (hsh, in, in_len);
+ GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof(*peer));
+ GNUNET_CRYPTO_hash_context_finish (hsh, &receiver_key);
+
+ receiver = GNUNET_CONTAINER_multihashmap_get (receivers, &receiver_key);
+ if (NULL != receiver)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "receiver %s already exist or is being connected to\n",
+ address);
+ return GNUNET_NO;
+ }
+
+ receiver = GNUNET_new (struct ReceiverAddress);
+ receiver->udp_sock = udp_sock;
+ receiver->key = receiver_key;
+ receiver->address = in;
+ receiver->address_len = in_len;
+ receiver->target = *peer;
+ eddsa_pub_to_hpke_key (&receiver->target.public_key,
+ &receiver->target_hpke_key);
+ receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
+ (void) GNUNET_CONTAINER_multihashmap_put (
+ receivers,
+ &receiver->key,
+ receiver,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Added %s to receivers with address %s and sock %p\n",
+ GNUNET_i2s_full (&receiver->target),
+ address,
+ udp_sock);
+ receiver->timeout =
+ GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap,
+ receiver,
+ receiver->timeout.abs_value_us);
+ GNUNET_STATISTICS_set (stats,
+ "# receivers active",
+ GNUNET_CONTAINER_multihashmap_size (receivers),
+ GNUNET_NO);
+ receiver->foreign_addr =
+ sockaddr_to_udpaddr_string (receiver->address, receiver->address_len);
+ if (NULL != udp_sock)
+ receiver->read_task = GNUNET_SCHEDULER_add_read_net
(GNUNET_TIME_UNIT_FOREVER_REL,
+ udp_sock,
+ &sock_read,
+ udp_sock);
+ setup_receiver_mq (receiver);
+ if (NULL == timeout_task)
+ timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL);
+ return GNUNET_OK;
+}
+
+
/**
* Socket read task.
*
@@ -2048,11 +2321,11 @@ sock_read (void *cls)
char buf[UINT16_MAX];
ssize_t rcvd;
- (void) cls;
+ struct GNUNET_NETWORK_Handle *udp_sock = cls;
read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
udp_sock,
&sock_read,
- NULL);
+ udp_sock);
while (1)
{
rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock,
@@ -2086,7 +2359,25 @@ sock_read (void *cls)
return;
}
- /* first, see if it is a UDPBox */
+ /* first, see if it is a GNUNET_BurstMessage */
+ if (rcvd == sizeof (struct GNUNET_BurstMessage))
+ {
+ struct GNUNET_BurstMessage *bm = (struct GNUNET_BurstMessage *) buf;
+ struct sockaddr *addr = (struct sockaddr*) &sa;
+ char *address = sockaddr_to_udpaddr_string (addr, sizeof (*addr));
+
+ GNUNET_assert (0 == bm->local_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received a burst message for default port\n");
+ create_receiver (&bm->peer,
+ address,
+ NULL);
+ GNUNET_stop_burst (default_udp_sock);
+ GNUNET_TRANSPORT_communicator_burst_finished (ch);
+ GNUNET_free (address);
+ return;
+ }
+ /* second, see if it is a UDPBox */
if (rcvd > sizeof(struct UDPBox))
{
const struct UDPBox *box;
@@ -2265,137 +2556,6 @@ sock_read (void *cls)
}
-/**
- * Convert UDP bind specification to a `struct sockaddr *`
- *
- * @param bindto bind specification to convert
- * @param[out] sock_len set to the length of the address
- * @return converted bindto specification
- */
-static struct sockaddr *
-udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
-{
- struct sockaddr *in;
- unsigned int port;
- char dummy[2];
- char *colon;
- char *cp;
-
- if (1 == sscanf (bindto, "%u%1s", &port, dummy))
- {
- /* interpreting value as just a PORT number */
- if (port > UINT16_MAX)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "BINDTO specification `%s' invalid: value too large for
port\n",
- bindto);
- return NULL;
- }
- if (GNUNET_YES == disable_v6)
- {
- struct sockaddr_in *i4;
-
- i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
- i4->sin_family = AF_INET;
- i4->sin_port = htons ((uint16_t) port);
- *sock_len = sizeof(struct sockaddr_in);
- in = (struct sockaddr *) i4;
- }
- else
- {
- struct sockaddr_in6 *i6;
-
- i6 = GNUNET_malloc (sizeof(struct sockaddr_in6));
- i6->sin6_family = AF_INET6;
- i6->sin6_port = htons ((uint16_t) port);
- *sock_len = sizeof(struct sockaddr_in6);
- in = (struct sockaddr *) i6;
- }
- return in;
- }
- cp = GNUNET_strdup (bindto);
- colon = strrchr (cp, ':');
- if (NULL != colon)
- {
- /* interpret value after colon as port */
- *colon = '\0';
- colon++;
- if (1 == sscanf (colon, "%u%1s", &port, dummy))
- {
- /* interpreting value as just a PORT number */
- if (port > UINT16_MAX)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "BINDTO specification `%s' invalid: value too large for
port\n",
- bindto);
- GNUNET_free (cp);
- return NULL;
- }
- }
- else
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_ERROR,
- "BINDTO specification `%s' invalid: last ':' not followed by number\n",
- bindto);
- GNUNET_free (cp);
- return NULL;
- }
- }
- else
- {
- /* interpret missing port as 0, aka pick any free one */
- port = 0;
- }
- {
- /* try IPv4 */
- struct sockaddr_in v4;
-
- memset (&v4, 0, sizeof(v4));
- if (1 == inet_pton (AF_INET, cp, &v4.sin_addr))
- {
- v4.sin_family = AF_INET;
- v4.sin_port = htons ((uint16_t) port);
-#if HAVE_SOCKADDR_IN_SIN_LEN
- v4.sin_len = sizeof(struct sockaddr_in);
-#endif
- in = GNUNET_memdup (&v4, sizeof(struct sockaddr_in));
- *sock_len = sizeof(struct sockaddr_in);
- GNUNET_free (cp);
- return in;
- }
- }
- {
- /* try IPv6 */
- struct sockaddr_in6 v6;
- const char *start;
-
- memset (&v6, 0, sizeof(v6));
- start = cp;
- if (('[' == *cp) && (']' == cp[strlen (cp) - 1]))
- {
- start++; /* skip over '[' */
- cp[strlen (cp) - 1] = '\0'; /* eat ']' */
- }
- if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
- {
- v6.sin6_family = AF_INET6;
- v6.sin6_port = htons ((uint16_t) port);
-#if HAVE_SOCKADDR_IN_SIN_LEN
- v6.sin6_len = sizeof(struct sockaddr_in6);
-#endif
- in = GNUNET_memdup (&v6, sizeof(v6));
- *sock_len = sizeof(v6);
- GNUNET_free (cp);
- return in;
- }
- }
- /* #5528 FIXME (feature!): maybe also try getnameinfo()? */
- GNUNET_free (cp);
- return NULL;
-}
-
-
/**
* Pad @a dgram by @a pad_size using @a out_cipher.
*
@@ -2492,7 +2652,7 @@ send_msg_with_kx (const struct GNUNET_MessageHeader *msg,
struct
0 == gcry_cipher_gettag (out_cipher, kx.gcm_tag, sizeof(kx.gcm_tag)));
gcry_cipher_close (out_cipher);
memcpy (dgram, &kx, sizeof(kx));
- if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock,
+ if (-1 == GNUNET_NETWORK_socket_sendto (get_socket (receiver),
dgram,
sizeof(dgram),
receiver->address,
@@ -2505,16 +2665,17 @@ send_msg_with_kx (const struct GNUNET_MessageHeader
*msg, struct
GNUNET_a2s (receiver->address,
receiver->address_len),
receiver->address->sa_family,
- udp_sock);
+ get_socket (receiver));
GNUNET_MQ_impl_send_continue (mq);
receiver_destroy (receiver);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending KX with payload size %u to %s\n",
+ "Sending KX with payload size %u to %s with socket %p\n",
msize,
GNUNET_a2s (receiver->address,
- receiver->address_len));
+ receiver->address_len),
+ get_socket (receiver));
GNUNET_MQ_impl_send_continue (mq);
}
@@ -2682,7 +2843,7 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
sizeof(box->gcm_tag)));
gcry_cipher_close (out_cipher);
- if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock,
+ if (-1 == GNUNET_NETWORK_socket_sendto (get_socket (receiver),
dgram,
payload_len, // FIXME why always
send sizeof dgram?
receiver->address,
@@ -2694,15 +2855,16 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
GNUNET_a2s (receiver->address,
receiver->address_len),
receiver->address->sa_family,
- udp_sock);
+ get_socket (receiver));
receiver_destroy (receiver);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending UDPBox with payload size %u, %u acks left, %lu bytes
sent\n",
+ "Sending UDPBox with payload size %u, %u acks left, %lu bytes
sent with socket %p\n",
msize,
receiver->acks_available,
- (unsigned long) ss->bytes_sent);
+ (unsigned long) ss->bytes_sent,
+ get_socket (receiver));
ss->bytes_sent += sizeof (dgram);
receiver->acks_available--;
GNUNET_MQ_impl_send_continue (mq);
@@ -2887,84 +3049,12 @@ setup_receiver_mq (struct ReceiverAddress *receiver)
static int
mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char
*address)
{
- struct ReceiverAddress *receiver;
- struct GNUNET_HashContext *hsh;
- struct GNUNET_HashCode receiver_key;
- const char *path;
- struct sockaddr *in;
- socklen_t in_len;
-
- if (0 != strncmp (address,
- COMMUNICATOR_ADDRESS_PREFIX "-",
- strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
- in = udp_address_to_sockaddr (path, &in_len);
-
- if (NULL == in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to setup UDP socket address\n");
- return GNUNET_SYSERR;
- }
- if ((AF_INET6 == in->sa_family) &&
- (GNUNET_YES == disable_v6))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "IPv6 disabled, skipping %s\n", address);
- GNUNET_free (in);
- return GNUNET_SYSERR;
- }
-
- hsh = GNUNET_CRYPTO_hash_context_start ();
- GNUNET_CRYPTO_hash_context_read (hsh, in, in_len);
- GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof(*peer));
- GNUNET_CRYPTO_hash_context_finish (hsh, &receiver_key);
-
- receiver = GNUNET_CONTAINER_multihashmap_get (receivers, &receiver_key);
- if (NULL != receiver)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "receiver %s already exist or is being connected to\n",
- address);
- GNUNET_free (in);
- return GNUNET_NO;
- }
-
- receiver = GNUNET_new (struct ReceiverAddress);
- receiver->key = receiver_key;
- receiver->address = in;
- receiver->address_len = in_len;
- receiver->target = *peer;
- eddsa_pub_to_hpke_key (&receiver->target.public_key,
- &receiver->target_hpke_key);
- receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
- (void) GNUNET_CONTAINER_multihashmap_put (
- receivers,
- &receiver->key,
- receiver,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Added %s to receivers\n",
- GNUNET_i2s_full (&receiver->target));
- receiver->timeout =
- GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- receiver->hn = GNUNET_CONTAINER_heap_insert (receivers_heap,
- receiver,
- receiver->timeout.abs_value_us);
- GNUNET_STATISTICS_set (stats,
- "# receivers active",
- GNUNET_CONTAINER_multihashmap_size (receivers),
- GNUNET_NO);
- receiver->foreign_addr =
- sockaddr_to_udpaddr_string (receiver->address, receiver->address_len);
- setup_receiver_mq (receiver);
- if (NULL == timeout_task)
- timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL);
- return GNUNET_OK;
+ "create receiver for mq_init\n");
+ return create_receiver (peer,
+ address,
+ NULL);
}
@@ -3024,6 +3114,7 @@ do_shutdown (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"do_shutdown\n");
+ GNUNET_stop_burst (NULL);
if (NULL != nat)
{
GNUNET_NAT_unregister (nat);
@@ -3046,11 +3137,11 @@ do_shutdown (void *cls)
GNUNET_SCHEDULER_cancel (read_task);
read_task = NULL;
}
- if (NULL != udp_sock)
+ if (NULL != default_udp_sock)
{
GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (udp_sock));
- udp_sock = NULL;
+ GNUNET_NETWORK_socket_close (default_udp_sock));
+ default_udp_sock = NULL;
}
GNUNET_CONTAINER_multihashmap_iterate (receivers,
&get_receiver_delete_it,
@@ -3229,7 +3320,7 @@ ifc_broadcast (void *cls)
ssize_t sent;
if (GNUNET_OK !=
- GNUNET_NETWORK_socket_setsockopt (udp_sock,
+ GNUNET_NETWORK_socket_setsockopt (default_udp_sock,
SOL_SOCKET,
SO_BROADCAST,
&yes,
@@ -3242,7 +3333,7 @@ ifc_broadcast (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"sending UDPBroadcast to add %s\n",
GNUNET_a2s (bi->ba, bi->salen));
- sent = GNUNET_NETWORK_socket_sendto (udp_sock,
+ sent = GNUNET_NETWORK_socket_sendto (default_udp_sock,
&bi->bcm,
sizeof(bi->bcm),
bi->ba,
@@ -3250,7 +3341,7 @@ ifc_broadcast (void *cls)
if (-1 == sent)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
"sendto");
- if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock,
+ if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (default_udp_sock,
SOL_SOCKET,
SO_BROADCAST,
&no,
@@ -3271,7 +3362,7 @@ ifc_broadcast (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"sending UDPBroadcast\n");
- sent = GNUNET_NETWORK_socket_sendto (udp_sock,
+ sent = GNUNET_NETWORK_socket_sendto (default_udp_sock,
&bi->bcm,
sizeof(bi->bcm),
(const struct sockaddr *) &dst,
@@ -3394,7 +3485,7 @@ iface_proc (void *cls,
bi->mcreq.ipv6mr_interface = s6->sin6_scope_id;
/* Join the multicast group */
- if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock,
+ if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (default_udp_sock,
IPPROTO_IPV6,
IPV6_JOIN_GROUP,
&bi->mcreq,
@@ -3440,23 +3531,60 @@ try_connection_reversal (void *cls,
{
/* FIXME: support reversal: #5529 */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "No connection reversal implemented!");
+ "No connection reversal implemented!\n");
+}
+
+
+static void udp_socket_notify (struct GNUNET_UdpSocketInfo *sock_info)
+{
+ char *address = sockaddr_to_udpaddr_string (sock_info->actual_address,
+ sizeof
(*sock_info->actual_address));
+ create_receiver (sock_info->pid,
+ address,
+ default_udp_sock == sock_info->udp_sock ?
+ NULL : sock_info->udp_sock);
+ GNUNET_TRANSPORT_communicator_burst_finished (ch);
+ GNUNET_free (sock_info);
}
-/**
- * Setup communicator and launch network interactions.
- *
- * @param cls NULL (always)
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be
NULL!)
- * @param c configuration
- */
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+start_burst (const char *addr,
+ struct GNUNET_TIME_Relative rtt,
+ struct GNUNET_PeerIdentity *pid)
+{
+ struct GNUNET_UdpSocketInfo *sock_info;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Communicator was called to start burst to address %s from %s\n",
+ addr,
+ my_ipv4);
+
+ GNUNET_stop_burst (NULL);
+
+ sock_info = GNUNET_new (struct GNUNET_UdpSocketInfo);
+ sock_info->pid = GNUNET_new (struct GNUNET_PeerIdentity);
+ sock_info->address = GNUNET_strdup (addr);
+ sock_info->bind_address = my_ipv4;
+ sock_info->has_port = GNUNET_YES;
+ sock_info->udp_sock = default_udp_sock;
+ sock_info->rtt = rtt;
+ GNUNET_memcpy (sock_info->pid, pid, sizeof (struct GNUNET_PeerIdentity));
+ sock_info->std_port = my_port;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "1 sock addr %s addr %s rtt %lu %u\n",
+ sock_info->address,
+ addr,
+ sock_info->rtt.rel_value_us,
+ my_port);
+ burst_task = GNUNET_get_udp_socket (sock_info,
+ &udp_socket_notify);
+ GNUNET_free (sock_info);
+}
+
+
+static void
+run_ (const struct GNUNET_CONFIGURATION_Handle *c)
{
char *bindto;
struct sockaddr *in;
@@ -3464,7 +3592,9 @@ run (void *cls,
struct sockaddr_storage in_sto;
socklen_t sto_len;
- (void) cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Entering the run method of udp communicator.\n");
+
cfg = c;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -3477,7 +3607,9 @@ run (void *cls,
"BINDTO");
return;
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "The udp communicator will bind to %s\n",
+ bindto);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (cfg,
COMMUNICATOR_CONFIG_SECTION,
@@ -3512,11 +3644,11 @@ run (void *cls,
GNUNET_free (bindto);
return;
}
- udp_sock =
+ default_udp_sock =
GNUNET_NETWORK_socket_create (in->sa_family,
SOCK_DGRAM,
IPPROTO_UDP);
- if (NULL == udp_sock)
+ if (NULL == default_udp_sock)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -3531,7 +3663,7 @@ run (void *cls,
if (AF_INET6 == in->sa_family)
have_v6_socket = GNUNET_YES;
if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (udp_sock,
+ GNUNET_NETWORK_socket_bind (default_udp_sock,
in,
in_len))
{
@@ -3543,9 +3675,9 @@ run (void *cls,
GNUNET_a2s (in,
in_len),
in->sa_family,
- udp_sock);
- GNUNET_NETWORK_socket_close (udp_sock);
- udp_sock = NULL;
+ default_udp_sock);
+ GNUNET_NETWORK_socket_close (default_udp_sock);
+ default_udp_sock = NULL;
GNUNET_free (in);
GNUNET_free (bindto);
return;
@@ -3554,7 +3686,7 @@ run (void *cls,
/* We might have bound to port 0, allowing the OS to figure it out;
thus, get the real IN-address from the socket */
sto_len = sizeof(in_sto);
- if (0 != getsockname (GNUNET_NETWORK_get_fd (udp_sock),
+ if (0 != getsockname (GNUNET_NETWORK_get_fd (default_udp_sock),
(struct sockaddr *) &in_sto,
&sto_len))
{
@@ -3570,11 +3702,14 @@ run (void *cls,
"Bound to `%s' sock %p\n",
GNUNET_a2s ((const struct sockaddr *) &in_sto,
sto_len),
- udp_sock);
+ default_udp_sock);
switch (in->sa_family)
{
case AF_INET:
+ const struct sockaddr_in *v4 = (const struct sockaddr_in *)in;
+ my_ipv4 = GNUNET_malloc (INET_ADDRSTRLEN);
my_port = ntohs (((struct sockaddr_in *) in)->sin_port);
+ inet_ntop(AF_INET, &v4->sin_addr, my_ipv4, in_len);
break;
case AF_INET6:
@@ -3608,9 +3743,9 @@ run (void *cls,
eddsa_priv_to_hpke_key (my_private_key, &my_x25519_private_key);
/* start reading */
read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
- udp_sock,
+ default_udp_sock,
&sock_read,
- NULL);
+ default_udp_sock);
ch = GNUNET_TRANSPORT_communicator_connect (cfg,
COMMUNICATOR_CONFIG_SECTION,
COMMUNICATOR_ADDRESS_PREFIX,
@@ -3618,7 +3753,8 @@ run (void *cls,
&mq_init,
NULL,
&enc_notify_cb,
- NULL);
+ NULL,
+ &start_burst);
if (NULL == ch)
{
GNUNET_break (0);
@@ -3651,40 +3787,32 @@ run (void *cls,
NULL /* closure */);
}
+static void
+run_monolith (void *cls)
+{
+ const struct GNUNET_CONFIGURATION_Handle *c = cls;
+
+ run_ (c);
+}
+
/**
- * The main function for the UNIX communicator.
+ * Setup communicator and launch network interactions.
*
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
+ * @param cls NULL (always)
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be
NULL!)
+ * @param c configuration
*/
-int
-main (int argc, char *const *argv)
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
- int ret;
-
- GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
- "transport",
- "Starting udp communicator\n");
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
-
- ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-communicator-udp",
- _ ("GNUnet UDP communicator"),
- options,
- &run,
- NULL))
- ? 0
- : 1;
- GNUNET_free_nz ((void *) argv);
- return ret;
+ run_ (c);
}
+GNUNET_DAEMON_MAIN ("gnunet-communicator-udp", _ ("GNUnet UDP communicator"),
&run, &run_monolith)
/* end of gnunet-communicator-udp.c */
diff --git a/src/service/transport/gnunet-communicator-unix.c
b/src/service/transport/gnunet-communicator-unix.c
index 1cdc85b8a..1ea9a99e6 100644
--- a/src/service/transport/gnunet-communicator-unix.c
+++ b/src/service/transport/gnunet-communicator-unix.c
@@ -1092,6 +1092,7 @@ run (void *cls,
&mq_init,
NULL,
&enc_notify_cb,
+ NULL,
NULL);
if (NULL == ch)
{
diff --git a/src/service/transport/gnunet-service-transport.c
b/src/service/transport/gnunet-service-transport.c
index be8afafab..2e499a332 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -325,6 +325,12 @@
#define QUEUE_ENTRY_TIMEOUT \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+/**
+ * Difference of the avarage RTT for the DistanceVector calculate by us and
the target
+ * we are willing to accept for starting the burst.
+ */
+#define RTT_DIFF \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
GNUNET_NETWORK_STRUCT_BEGIN
@@ -984,6 +990,15 @@ struct TransportFlowControlMessage
*/
struct GNUNET_TIME_AbsoluteNBO sender_time;
+ /**
+ * Avarage RTT for the DistanceVector of the VirtualLink we tell the target.
+ */
+ struct GNUNET_TIME_RelativeNBO rtt;
+
+ /**
+ * We tell the target, if we are ready to start the burst.
+ */
+ unsigned int sync_ready;
/**
* Number of TransportGlobalNattedAddress following the struct.
@@ -1419,6 +1434,16 @@ struct VirtualLink
*/
struct GNUNET_SCHEDULER_Task *fc_retransmit_task;
+ /**
+ * The actual GNUNET_StartBurstCls of this VirtualLink.
+ */
+ struct GNUNET_StartBurstCls *sb_cls;
+
+ /**
+ * global addresses for the peer.
+ */
+ char *burst_addr;
+
/**
* Number of FC retransmissions for this running task.
*/
@@ -1469,6 +1494,17 @@ struct VirtualLink
*/
struct GNUNET_TIME_Relative last_fc_rtt;
+ /**
+ * Avarage RTT for over all paths of the DistanceVector of this VirtualLink
+ * calculated by the target.
+ */
+ struct GNUNET_TIME_Relative other_rtt;
+
+ /**
+ * IterationContext for searching a burst address.
+ */
+ struct GNUNET_PEERSTORE_IterateContext *ic;
+
/**
* Used to generate unique UUIDs for messages that are being
* fragmented.
@@ -1570,6 +1606,11 @@ struct VirtualLink
* would decrement the window by one per CORE client).
*/
int core_recv_window;
+
+ /**
+ * Are we ready to start the burst?
+ */
+ enum GNUNET_GenericReturnValue sync_ready;
};
@@ -2006,7 +2047,7 @@ struct Queue
int idle;
/**
- * Set to GNUNET_yes, if this queues address is not a global natted one.
+ * Set to GNUNET_YES, if this queues address is a global natted one.
*/
enum GNUNET_GenericReturnValue is_global_natted;
};
@@ -2619,6 +2660,12 @@ struct TransportClient
* Characteristics of this communicator.
*/
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
+
+ /**
+ * Can be used for burst messages.
+ */
+ enum GNUNET_GenericReturnValue can_burst;
+
} communicator;
/**
@@ -2990,6 +3037,11 @@ static unsigned int ir_total;
*/
static unsigned long long logging_uuid_gen;
+/**
+ * Is there a burst running?
+ */
+static enum GNUNET_GenericReturnValue burst_running;
+
/**
* Monotonic time we use for HELLOs generated at this time. TODO: we
* should increase this value from time to time (i.e. whenever a
@@ -3006,6 +3058,15 @@ static struct GNUNET_TIME_Absolute hello_mono_time;
*/
static int in_shutdown;
+/**
+ * The task to start the burst.
+ */
+static struct GNUNET_SCHEDULER_Task *burst_task;
+
+struct GNUNET_SCHEDULER_Task *burst_timeout_task;
+
+enum GNUNET_GenericReturnValue use_burst;
+
/**
* Get an offset into the transmission history buffer for `struct
* PerformanceData`. Note that the caller must perform the required
@@ -4572,9 +4633,13 @@ handle_communicator_available (
GNUNET_strdup ((const char *) &cam[1]);
tc->details.communicator.cc =
(enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
+ tc->details.communicator.can_burst
+ = (enum GNUNET_GenericReturnValue) ntohl (cam->can_burst);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Communicator with prefix `%s' connected\n",
- tc->details.communicator.address_prefix);
+ "Communicator for peer %s with prefix '%s' connected %s\n",
+ GNUNET_i2s (&GST_my_identity),
+ tc->details.communicator.address_prefix,
+ tc->details.communicator.can_burst ? "can burst" : "can not
burst");
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -5365,26 +5430,22 @@ add_global_addresses (void *cls,
struct AddGlobalAddressesContext *ctx = cls;
struct TransportGlobalNattedAddress *tgna = value;
char *addr = (char *) &tgna[1];
- size_t address_len = strlen (addr);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "sending address %s length %lu\n",
+ "sending address %s length %u\n",
addr,
- address_len);
- tgna = GNUNET_malloc (sizeof (struct TransportGlobalNattedAddress)
- + address_len);
- tgna->address_length = htonl (address_len);
- GNUNET_memcpy (&tgna[1], addr, address_len);
- GNUNET_memcpy (&(ctx->tgnas[ctx->off]), tgna, sizeof (struct
-
TransportGlobalNattedAddress)
- + address_len);
- GNUNET_free (tgna);
- ctx->off += sizeof(struct TransportGlobalNattedAddress) + address_len;
+ ntohl (tgna->address_length));
+ GNUNET_memcpy (&(ctx->tgnas[ctx->off]), tgna, sizeof (struct
TransportGlobalNattedAddress) + ntohl (tgna->address_length));
+ ctx->off += sizeof(struct TransportGlobalNattedAddress) + ntohl
(tgna->address_length);
return GNUNET_OK;
}
+static struct GNUNET_TIME_Relative
+calculate_rtt (struct DistanceVector *dv);
+
+
/**
* Something changed on the virtual link with respect to flow
* control. Consider retransmitting the FC window size.
@@ -5399,22 +5460,20 @@ consider_sending_fc (void *cls)
struct TransportFlowControlMessage *fc;
struct GNUNET_TIME_Relative duration;
struct GNUNET_TIME_Relative rtt;
+ struct GNUNET_TIME_Relative rtt_avarage;
struct Neighbour *n = vl->n;
- if (0 < n->number_of_addresses)
+ if (NULL != n && 0 < n->number_of_addresses)
{
size_t addresses_size =
- n->number_of_addresses * sizeof (struct TransportGlobalNattedAddress) + n
- ->size_of_global_addresses;
+ n->number_of_addresses * sizeof (struct TransportGlobalNattedAddress) +
n->size_of_global_addresses;
char *tgnas = GNUNET_malloc (addresses_size);
struct AddGlobalAddressesContext ctx;
ctx.off = 0;
ctx.tgnas = tgnas;
- fc = GNUNET_malloc (sizeof (struct TransportFlowControlMessage)
- + addresses_size);
- fc->header.size = htons (sizeof(struct TransportFlowControlMessage)
- + addresses_size);
+ fc = GNUNET_malloc (sizeof (struct TransportFlowControlMessage) +
addresses_size);
+ fc->header.size = htons (sizeof(struct TransportFlowControlMessage) +
addresses_size);
fc->size_of_addresses = htonl (n->size_of_global_addresses);
fc->number_of_addresses = htonl (n->number_of_addresses);
GNUNET_CONTAINER_multipeermap_iterate (n->natted_addresses,
@@ -5439,18 +5498,26 @@ consider_sending_fc (void *cls)
VL, as that determines "significantly". We have the delay, but
the bandwidth statistics need to be added for the VL!*/(void) duration;
+ if (NULL != vl->dv)
+ rtt_avarage = calculate_rtt (vl->dv);
+ else
+ rtt_avarage = GNUNET_TIME_UNIT_FOREVER_REL;
+ fc->rtt = GNUNET_TIME_relative_hton (rtt_avarage);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending FC seq %u to %s with new window %llu\n",
+ "Sending FC seq %u to %s with new window %llu %lu %u\n",
(unsigned int) vl->fc_seq_gen,
GNUNET_i2s (&vl->target),
- (unsigned long long) vl->incoming_fc_window_size);
+ (unsigned long long) vl->incoming_fc_window_size,
+ rtt_avarage.rel_value_us,
+ vl->sync_ready);
monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
vl->last_fc_transmission = monotime;
+ fc->sync_ready = vl->sync_ready;
fc->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL);
fc->seq = htonl (vl->fc_seq_gen++);
fc->inbound_window_size = GNUNET_htonll (vl->incoming_fc_window_size
- + vl->incoming_fc_window_size_used
- + vl->incoming_fc_window_size_loss);
+ + vl->incoming_fc_window_size_used
+ + vl->incoming_fc_window_size_loss);
fc->outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used);
fc->outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size);
fc->sender_time = GNUNET_TIME_absolute_hton (monotime);
@@ -5935,6 +6002,7 @@ create_address_entry (struct TransportClient *tc,
size_t slen)
{
struct AddressListEntry *ale;
+ char *address_without_port;
ale = GNUNET_malloc (sizeof(struct AddressListEntry) + slen);
ale->tc = tc;
@@ -5943,7 +6011,14 @@ create_address_entry (struct TransportClient *tc,
ale->aid = aid;
ale->nt = nt;
memcpy (&ale[1], address, slen);
- ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale);
+ address_without_port = get_address_without_port (ale->address);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Is this %s a local address (%s)\n",
+ address_without_port,
+ ale->address);
+ if (0 != strcmp ("127.0.0.1", address_without_port))
+ ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale);
+ GNUNET_free (address_without_port);
return ale;
}
@@ -5962,18 +6037,21 @@ handle_add_address (void *cls,
struct TransportClient *tc = cls;
struct AddressListEntry *ale;
size_t slen;
+ char *address;
/* 0-termination of &aam[1] was checked in #check_add_address */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Communicator added address `%s'!\n",
(const char *) &aam[1]);
slen = ntohs (aam->header.size) - sizeof(*aam);
+ address = GNUNET_malloc (slen);
+ memcpy (address, &aam[1], slen);
ale = create_address_entry (tc,
- GNUNET_TIME_relative_ntoh (aam->expiration),
- (enum GNUNET_NetworkType) ntohl (aam->nt),
- (const char *) &aam[1],
- aam->aid,
- slen);
+ GNUNET_TIME_relative_ntoh (aam->expiration),
+ (enum GNUNET_NetworkType) ntohl (aam->nt),
+ address,
+ aam->aid,
+ slen);
GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head,
tc->details.communicator.addr_tail,
ale);
@@ -7284,6 +7362,7 @@ activate_core_visible_dv_path (struct DistanceVectorHop
*hop)
"Creating new virtual link %p to %s using DV!\n",
vl,
GNUNET_i2s (&dv->target));
+ vl->burst_addr = NULL;
vl->confirmed = GNUNET_YES;
vl->message_uuid_ctr =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -7382,22 +7461,37 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
return GNUNET_SYSERR;
}
for (unsigned int i = 2; i < path_len; i++)
- if (NULL != lookup_neighbour (&path[i]))
+ {
+ struct Neighbour *n = lookup_neighbour (&path[i]);
+ struct GNUNET_TIME_Absolute q_timeout;
+
+ if (NULL != n)
{
- /* Useless path: we have a direct connection to some hop
- in the middle of the path, so this one is not even
- terribly useful for redundancy */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Path of %u hops useless: directly link to hop %u (%s)\n",
- path_len,
- i,
- GNUNET_i2s (&path[i]));
- GNUNET_STATISTICS_update (GST_stats,
- "# Useless DV path ignored: hop is neighbour",
- 1,
- GNUNET_NO);
- return GNUNET_SYSERR;
+ q_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
+ for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
+ q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "remainig %lu to %s\n",
+ GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us,
+ GNUNET_i2s (&n->pid));
+ if (0 != GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us)
+ {
+ /* Useless path: we have a direct active connection to some hop
+ in the middle of the path, so this one is not even
+ terribly useful for redundancy */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Path of %u hops useless: directly link to hop %u (%s)\n",
+ path_len,
+ i,
+ GNUNET_i2s (&path[i]));
+ GNUNET_STATISTICS_update (GST_stats,
+ "# Useless DV path ignored: hop is
neighbour",
+ 1,
+ GNUNET_NO);
+ return GNUNET_SYSERR;
+ }
}
+ }
dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]);
if (NULL == dv)
{
@@ -7462,8 +7556,7 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
/* Some peer send DV learn messages too often, we are learning
the same path faster than it would be useful; do not forward! */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Rediscovered path too quickly, not forwarding
further\n")
- ;
+ "Rediscovered path too quickly, not forwarding
further\n");
return GNUNET_NO;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -7896,6 +7989,33 @@ neighbour_store_dvmono_cb (void *cls, int success)
}
+static struct GNUNET_TIME_Relative
+get_network_latency (const struct TransportDVLearnMessage *dvl)
+{
+ struct GNUNET_TIME_Relative host_latency_sum;
+ struct GNUNET_TIME_Relative latency;
+ struct GNUNET_TIME_Relative network_latency;
+ uint16_t nhops = ntohs (dvl->num_hops);;
+
+ /* We initiated this, learn the forward path! */
+ host_latency_sum = GNUNET_TIME_relative_ntoh (dvl->non_network_delay);
+
+ // Need also something to lookup initiation time
+ // to compute RTT! -> add RTT argument here?
+ latency = GNUNET_TIME_absolute_get_duration (GNUNET_TIME_absolute_ntoh (
+
dvl->monotonic_time));
+ GNUNET_assert (latency.rel_value_us >= host_latency_sum.rel_value_us);
+ // latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly
+ // (based on dvl->challenge, we can identify time of origin!)
+
+ network_latency = GNUNET_TIME_relative_subtract (latency, host_latency_sum);
+ /* assumption: latency on all links is the same */
+ network_latency = GNUNET_TIME_relative_divide (network_latency, nhops);
+
+ return network_latency;
+}
+
+
/**
* Communicator gave us a DV learn message. Process the request.
*
@@ -8068,26 +8188,13 @@ handle_dv_learn (void *cls, const struct
TransportDVLearnMessage *dvl)
if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator))
{
struct GNUNET_PeerIdentity path[nhops + 1];
- struct GNUNET_TIME_Relative host_latency_sum;
- struct GNUNET_TIME_Relative latency;
struct GNUNET_TIME_Relative network_latency;
/* We initiated this, learn the forward path! */
path[0] = GST_my_identity;
path[1] = hops[0].hop;
- host_latency_sum = GNUNET_TIME_relative_ntoh (dvl->non_network_delay);
-
- // Need also something to lookup initiation time
- // to compute RTT! -> add RTT argument here?
- latency = GNUNET_TIME_absolute_get_duration (GNUNET_TIME_absolute_ntoh (
- dvl->monotonic_time));
- GNUNET_assert (latency.rel_value_us >= host_latency_sum.rel_value_us);
- // latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly
- // (based on dvl->challenge, we can identify time of origin!)
- network_latency = GNUNET_TIME_relative_subtract (latency,
host_latency_sum);
- /* assumption: latency on all links is the same */
- network_latency = GNUNET_TIME_relative_divide (network_latency, nhops);
+ network_latency = get_network_latency (dvl);
for (unsigned int i = 2; i <= nhops; i++)
{
@@ -8115,6 +8222,8 @@ handle_dv_learn (void *cls, const struct
TransportDVLearnMessage *dvl)
{
/* last hop was bi-directional, we could learn something here! */
struct GNUNET_PeerIdentity path[nhops + 2];
+ struct GNUNET_TIME_Relative ilat;
+ struct GNUNET_TIME_Relative network_latency;
path[0] = GST_my_identity;
path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */
@@ -8137,9 +8246,11 @@ handle_dv_learn (void *cls, const struct
TransportDVLearnMessage *dvl)
"Learned inverse path with %u hops to %s\n",
i + 2,
GNUNET_i2s (&path[i + 2]));
+ network_latency = get_network_latency (dvl);
+ ilat = GNUNET_TIME_relative_multiply (network_latency, i + 2);
iret = learn_dv_path (path,
i + 3,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ ilat,
GNUNET_TIME_relative_to_absolute (
ADDRESS_VALIDATION_LIFETIME));
if (GNUNET_SYSERR == iret)
@@ -8298,8 +8409,7 @@ forward_dv_box (struct Neighbour *next_hop,
hdr->header.size = htons (msg_size);
memcpy (msg_buf, hdr, sizeof(*hdr));
dhops = (struct GNUNET_PeerIdentity *) &msg_buf[sizeof(struct
-
TransportDVBoxMessage)]
- ;
+
TransportDVBoxMessage)];
memcpy (dhops, hops, num_hops * sizeof(struct GNUNET_PeerIdentity));
memcpy (&dhops[num_hops], enc_payload, enc_payload_size);
@@ -9538,6 +9648,7 @@ handle_validation_response (
"Creating new virtual link %p to %s using direct neighbour!\n",
vl,
GNUNET_i2s (&vs->pid));
+ vl->burst_addr = NULL;
vl->confirmed = GNUNET_YES;
vl->message_uuid_ctr =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -9657,6 +9768,203 @@ check_flow_control (void *cls, const struct
TransportFlowControlMessage *fc)
}
+static struct GNUNET_TIME_Relative
+calculate_rtt (struct DistanceVector *dv)
+{
+ struct GNUNET_TIME_Relative ret = GNUNET_TIME_UNIT_ZERO;
+ unsigned int n_hops = 0;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "calculate_rtt\n");
+ for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
+ pos = pos->next_dv)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "calculate_rtt %lu\n",
+ pos->pd.aged_rtt.rel_value_us);
+ n_hops++;
+ ret = GNUNET_TIME_relative_add (GNUNET_TIME_relative_multiply
(pos->pd.aged_rtt, pos->distance + 2), ret);
+ }
+
+ GNUNET_assert (0 != n_hops);
+
+ return ret ;
+}
+
+static void
+iterate_address_start_burst (void *cls,
+ const struct GNUNET_PeerIdentity *pid,
+ const char *uri)
+{
+ struct VirtualLink *vl = cls;
+ const char *slash;
+ char *address_uri;
+ char *prefix;
+ char *uri_without_port;
+
+ slash = strrchr (uri, '/');
+ prefix = GNUNET_strndup (uri, (slash - uri) - 2);
+ GNUNET_assert (NULL != slash);
+ slash++;
+ GNUNET_asprintf (&address_uri,
+ "%s-%s",
+ prefix,
+ slash);
+
+ uri_without_port = get_address_without_port (address_uri);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "iterate_address_start_burst %s %s %s %s\n",
+ uri_without_port,
+ uri,
+ address_uri,
+ slash);
+ if (0 == strcmp (uri_without_port, slash))
+ {
+ vl->burst_addr = GNUNET_strndup (uri_without_port, strlen
(uri_without_port));
+ }
+ else
+ vl->burst_addr = NULL;
+
+ GNUNET_free (prefix);
+ GNUNET_free (uri_without_port);
+}
+
+
+static void
+check_for_burst_address (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
+{
+ struct GNUNET_StartBurstCls *sb_cls = cls;
+ struct VirtualLink *vl = sb_cls->vl;
+ struct GNUNET_MessageHeader *hello;
+ struct GNUNET_HELLO_Builder *builder;
+
+ if (NULL != emsg)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Got failure from PEERSTORE: %s\n",
+ emsg);
+ return;
+ }
+ if (NULL == record)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hello iteration end for %s\n",
+ GNUNET_i2s (&vl->target));
+ vl->ic = NULL;
+ GNUNET_free (sb_cls);
+ return;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "check_for_burst_address\n");
+ hello = record->value;
+ builder = GNUNET_HELLO_builder_from_msg (hello);
+ GNUNET_HELLO_builder_iterate (builder,
+ &iterate_address_start_burst,
+ vl);
+ GNUNET_HELLO_builder_free (builder);
+
+ GNUNET_PEERSTORE_iteration_stop (vl->ic);
+ GNUNET_free (sb_cls);
+}
+
+
+static void
+burst_timeout (void *cls)
+{
+ burst_running = GNUNET_NO;
+}
+
+
+static void
+start_burst (void *cls)
+{
+ struct GNUNET_StartBurstCls *sb_cls = cls;
+ struct VirtualLink *vl = sb_cls->vl;
+ struct GNUNET_TRANSPORT_StartBurst *sb;
+ struct GNUNET_MQ_Envelope *env;
+ char *uri_without_port = vl->burst_addr;
+
+ burst_task = NULL;
+ /*char buf[strlen (uri_without_port) + 1];
+
+ GNUNET_memcpy (buf, uri_without_port, strlen (uri_without_port));
+ buf[strlen (uri_without_port)] = '\0';*/
+ env =
+ GNUNET_MQ_msg_extra (sb ,
+ strlen (uri_without_port) + 1,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_START_BURST);
+ sb->rtt = GNUNET_TIME_relative_hton (sb_cls->rtt);
+ sb->pid = vl->target;
+ memcpy (&sb[1], uri_without_port, strlen (uri_without_port) + 1);
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "iterate_address_start_burst client tc prefix %s\n",
+ tc->details.communicator.address_prefix);
+ if (CT_COMMUNICATOR != tc->type)
+ continue;
+ if (GNUNET_YES == tc->details.communicator.can_burst){
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "iterate_address_start_burst %s call %lu %u rtt %lu\n",
+ uri_without_port,
+ strlen (uri_without_port),
+ ntohs (sb->header.size),
+ sb_cls->rtt.rel_value_us);
+ GNUNET_MQ_send (tc->mq, env);
+ burst_running = GNUNET_YES;
+ burst_timeout_task = GNUNET_SCHEDULER_add_delayed
(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+
60),
+ &burst_timeout,
+ NULL);
+ //TODO We need some algo to choose from available communicators. Can we
run two bursts at once? Atm we only implemented udp burst.
+ break;
+ }
+ }
+ GNUNET_free (sb_cls);
+}
+
+
+static void
+queue_burst (void *cls)
+{
+ struct GNUNET_StartBurstCls *sb_cls = cls;
+ struct VirtualLink *vl = sb_cls->vl;
+
+ if (GNUNET_YES != use_burst)
+ return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "burst_task %p ready %s burst addr %s (%p)\n",
+ burst_task,
+ sb_cls->sync_ready ? "yes" : "no",
+ vl->burst_addr,
+ vl->burst_addr);
+ if (NULL != burst_task && GNUNET_NO == sb_cls->sync_ready)
+ {
+ GNUNET_SCHEDULER_cancel (burst_task);
+ burst_task = NULL;
+ GNUNET_free (sb_cls);
+ return;
+ }
+ if (GNUNET_NO == burst_running && NULL != vl->burst_addr && NULL ==
burst_task)
+ {
+ burst_task = GNUNET_SCHEDULER_add_delayed (sb_cls->delay,
+ &start_burst,
+ sb_cls);
+ }
+ else if (NULL == vl->burst_addr)
+ {
+ vl->ic = GNUNET_PEERSTORE_iteration_start (peerstore,
+ "peerstore",
+ &vl->target,
+ GNUNET_PEERSTORE_HELLO_KEY,
+ check_for_burst_address,
+ sb_cls);
+ }
+}
+
/**
* Communicator gave us a transport address validation response. Process the
* request.
@@ -9670,6 +9978,7 @@ handle_flow_control (void *cls, const struct
TransportFlowControlMessage *fc)
{
struct CommunicatorMessageContext *cmc = cls;
struct VirtualLink *vl;
+ struct GNUNET_TIME_Absolute q_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
uint32_t seq;
struct GNUNET_TIME_Absolute st;
uint64_t os;
@@ -9686,6 +9995,7 @@ handle_flow_control (void *cls, const struct
TransportFlowControlMessage *fc)
"No virtual link for %p FC creating new unconfirmed virtual
link to %s!\n",
vl,
GNUNET_i2s (&cmc->im.sender));
+ vl->burst_addr = NULL;
vl->confirmed = GNUNET_NO;
vl->message_uuid_ctr =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -9700,6 +10010,39 @@ handle_flow_control (void *cls, const struct
TransportFlowControlMessage *fc)
vl,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
+ if (NULL != vl->n)
+ {
+ for (struct Queue *q = vl->n->queue_head; NULL != q; q = q->next_neighbour)
+ q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until);
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "remaining %lu timeout for neighbour %p\n",
+ GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us,
+ vl->n);
+ if (NULL == vl->n ||
+ 0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us)
+ {
+ struct GNUNET_TIME_Relative rtt;
+ struct GNUNET_BurstSync burst_sync;
+ struct GNUNET_StartBurstCls *bcls;
+
+ bcls = GNUNET_new (struct GNUNET_StartBurstCls);
+ bcls->vl = vl;
+ vl->sb_cls = bcls;
+ if (NULL != vl->dv)
+ rtt = calculate_rtt (vl->dv);
+ else
+ rtt = GNUNET_TIME_UNIT_FOREVER_REL;
+ burst_sync.rtt_avarage = fc->rtt;
+ bcls->rtt = GNUNET_TIME_relative_ntoh (burst_sync.rtt_avarage);
+ burst_sync.sync_ready = fc->sync_ready;
+
+ GNUNET_is_burst_ready (rtt,
+ &burst_sync,
+ &queue_burst,
+ bcls);
+ }
if (0 != ntohl (fc->number_of_addresses))
{
unsigned int number_of_addresses = ntohl (fc->number_of_addresses);
@@ -11075,6 +11418,18 @@ handle_send_message_ack (void *cls,
}
+/**
+ * The burst finished.
+ *
+ * @param cls the client
+ */
+static void
+handle_burst_finished ()
+{
+ burst_running = GNUNET_NO;
+}
+
+
/**
* Iterator telling new MONITOR client about all existing
* queues to peers.
@@ -11624,14 +11979,15 @@ iterate_address_and_compare_cb (void *cls,
const char *uri)
{
struct Queue *queue = cls;
+ struct sockaddr_in v4;
const char *slash;
char *address_uri;
char *prefix;
char *uri_without_port;
- char *address_uri_without_port;
+ char *address_uri_without_port = get_address_without_port (queue->address);
slash = strrchr (uri, '/');
- prefix = GNUNET_strndup (uri, (slash - uri) - 2);
+ prefix = GNUNET_strndup (uri, (slash - uri) - 2);
GNUNET_assert (NULL != slash);
slash++;
GNUNET_asprintf (&address_uri,
@@ -11639,15 +11995,51 @@ iterate_address_and_compare_cb (void *cls,
prefix,
slash);
- address_uri_without_port = get_address_without_port (queue->address);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "1 not global natted_address %u %s %s %s\n",
+ queue->is_global_natted,
+ uri,
+ queue->address,
+ slash);
+
uri_without_port = get_address_without_port (address_uri);
+ if (1 != inet_pton (AF_INET, uri_without_port, &v4.sin_addr))
+ return;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "2 not global natted_address %u %s %s\n",
+ queue->is_global_natted,
+ uri,
+ queue->address);
+
+ if (GNUNET_NO == queue->is_global_natted)
+ return;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "3 not global natted_address %u %s %s\n",
+ queue->is_global_natted,
+ uri,
+ queue->address);
+
+ uri_without_port = get_address_without_port (address_uri);
+
+ if (0 == strcmp (uri_without_port, address_uri))
+ return;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "4 not global natted_address %u %s %s\n",
+ queue->is_global_natted,
+ uri,
+ queue->address);
+
+ address_uri_without_port = get_address_without_port (queue->address);
if (0 == strcmp (uri_without_port, address_uri_without_port))
{
queue->is_global_natted = GNUNET_NO;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "not global natted %u %s %s %s %s %s %u\n",
+ "not global natted_address %u %s %s %s %s %s %u\n",
queue->is_global_natted,
uri,
queue->address,
@@ -11662,22 +12054,6 @@ iterate_address_and_compare_cb (void *cls,
}
-static void
-check_for_global_natted_error_cb (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Error in PEERSTORE monitoring for checking global natted\n");
-}
-
-
-static void
-check_for_global_natted_sync_cb (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Done with initial PEERSTORE iteration during monitoring for
checking global natted\n");
-}
-
-
struct TransportGlobalNattedAddressClosure
{
/**
@@ -11701,6 +12077,12 @@ contains_address (void *cls,
struct TransportGlobalNattedAddress *tgna = value;
char *addr = (char *) &tgna[1];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Checking tgna %p with addr %s and length %u compare length
%lu\n",
+ tgna,
+ addr,
+ ntohl (tgna->address_length),
+ strlen(tgna_cls->addr));
if (strlen (tgna_cls->addr) == ntohl (tgna->address_length)
&& 0 == strncmp (addr, tgna_cls->addr, ntohl (tgna->address_length)))
{
@@ -11711,6 +12093,22 @@ contains_address (void *cls,
}
+static void
+check_for_global_natted_error_cb (void *cls)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Error in PEERSTORE monitoring for checking global natted\n");
+}
+
+
+static void
+check_for_global_natted_sync_cb (void *cls)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Done with initial PEERSTORE iteration during monitoring for
checking global natted\n");
+}
+
+
static void
check_for_global_natted (void *cls,
const struct GNUNET_PEERSTORE_Record *record,
@@ -11726,13 +12124,8 @@ check_for_global_natted (void *cls,
if (NULL != emsg)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Got failure from PEERSTORE: %s\n",
- emsg);
- return;
- }
- if (NULL == record)
- {
- queue->mo = NULL;
+ "Got failure from PEERSTORE: %s\n",
+ emsg);
return;
}
if (0 == record->value_size)
@@ -11756,8 +12149,16 @@ check_for_global_natted (void *cls,
GNUNET_HELLO_builder_free (builder);
tgna_cls.addr = get_address_without_port (queue->address);
- tgna_cls.tgna = NULL;
address_len_without_port = strlen (tgna_cls.addr);
+ /*{
+ char buf[address_len_without_port + 1];
+
+ GNUNET_memcpy (&buf, addr, address_len_without_port);
+ buf[address_len_without_port] = '\0';
+ GNUNET_free (addr);
+ GNUNET_memcpy (tgna_cls.addr, buf, address_len_without_port + 1);
+ }*/
+ tgna_cls.tgna = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (neighbour->natted_addresses,
&neighbour->pid,
&contains_address,
@@ -11782,10 +12183,12 @@ check_for_global_natted (void *cls,
tgna,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
neighbour->number_of_addresses++;
- neighbour->size_of_global_addresses += address_len_without_port;
+ neighbour->size_of_global_addresses += address_len_without_port + 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Created tgna %p\n",
- tgna);
+ "Created tgna %p with address %s and length %lu\n",
+ tgna,
+ tgna_cls.addr,
+ address_len_without_port + 1);
}
else if (NULL != tgna_cls.tgna && GNUNET_NO == queue->is_global_natted)
{
@@ -11804,8 +12207,8 @@ check_for_global_natted (void *cls,
tgna_cls.tgna);
GNUNET_free (tgna_cls.tgna);
}
- GNUNET_free (tgna_cls.addr);
GNUNET_PEERSTORE_monitor_next (queue->mo, 1);
+ GNUNET_free (tgna_cls.addr);
}
@@ -11822,7 +12225,6 @@ handle_add_queue_message (void *cls,
struct TransportClient *tc = cls;
struct Queue *queue;
struct Neighbour *neighbour;
- struct GNUNET_TIME_Absolute validated_until = GNUNET_TIME_UNIT_ZERO_ABS;
const char *addr;
uint16_t addr_len;
@@ -11839,7 +12241,6 @@ handle_add_queue_message (void *cls,
NULL != queue;
queue = queue->next_client)
{
- validated_until = queue->validated_until;
if (queue->qid != ntohl (aqm->qid))
continue;
break;
@@ -11851,6 +12252,8 @@ handle_add_queue_message (void *cls,
}
else
{
+ struct GNUNET_TIME_Absolute validated_until = GNUNET_TIME_UNIT_ZERO_ABS;
+
neighbour = lookup_neighbour (&aqm->receiver);
if (NULL == neighbour)
{
@@ -11884,7 +12287,9 @@ handle_add_queue_message (void *cls,
ntohl (aqm->mtu));
queue = GNUNET_malloc (sizeof(struct Queue) + addr_len);
queue->tc = tc;
- if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us != validated_until.abs_value_us)
+ for (struct Queue *q = neighbour->queue_head; NULL != q; q =
q->next_neighbour)
+ validated_until = GNUNET_TIME_absolute_max (validated_until,
q->validated_until);
+ if (0 == GNUNET_TIME_absolute_get_remaining (validated_until).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New queue with QID %u inherit validated until\n",
@@ -11919,17 +12324,27 @@ handle_add_queue_message (void *cls,
queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt);
queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs);
queue->idle = GNUNET_YES;
- queue->mo = GNUNET_PEERSTORE_monitor_start (GST_cfg,
- GNUNET_YES,
- "peerstore",
- &neighbour->pid,
- GNUNET_PEERSTORE_HELLO_KEY,
-
&check_for_global_natted_error_cb,
- NULL,
- &check_for_global_natted_sync_cb,
- NULL,
- &check_for_global_natted,
- queue);
+
+ {
+ struct sockaddr_in v4;
+ char *addr_without = get_address_without_port (queue->address);
+ if (1 == inet_pton (AF_INET, addr_without, &v4.sin_addr))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "start not global natted\n");
+ queue->mo = GNUNET_PEERSTORE_monitor_start (GST_cfg,
+ GNUNET_YES,
+ "peerstore",
+ &neighbour->pid,
+ GNUNET_PEERSTORE_HELLO_KEY,
+
&check_for_global_natted_error_cb,
+ NULL,
+
&check_for_global_natted_sync_cb,
+ NULL,
+ &check_for_global_natted,
+ queue);
+ }
+ }
/* check if valdiations are waiting for the queue */
if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (validation_map,
&aqm->receiver))
@@ -12574,6 +12989,12 @@ run (void *cls,
"My identity is `%s'\n",
GNUNET_i2s_full (&GST_my_identity));
GST_my_hello = GNUNET_HELLO_builder_new (&GST_my_identity);
+ use_burst = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg,
+ "transport",
+ "USE_BURST_NAT");
+ if (GNUNET_SYSERR == use_burst)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Could not configure burst nat use. Default to no.\n");
GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
peerstore = GNUNET_PEERSTORE_connect (GST_cfg);
@@ -12676,6 +13097,10 @@ GNUNET_SERVICE_MAIN (
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
struct GNUNET_TRANSPORT_SendMessageToAck,
NULL),
+ GNUNET_MQ_hd_fixed_size (burst_finished,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_BURST_FINISHED,
+ struct GNUNET_TRANSPORT_BurstFinished,
+ NULL),
/* communication with monitors */
GNUNET_MQ_hd_fixed_size (monitor_start,
GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START,
diff --git a/src/service/transport/meson.build.arm_monolith
b/src/service/transport/meson.build.arm_monolith
new file mode 100644
index 000000000..8751908ad
--- /dev/null
+++ b/src/service/transport/meson.build.arm_monolith
@@ -0,0 +1,172 @@
+libgnunettransportapplication_src = ['transport_api2_application.c']
+libgnunettransportcore_src = ['transport_api2_core.c']
+libgnunettransportcommunicator_src = ['transport_api2_communication.c']
+libgnunettransportmonitor_src = ['transport_api2_monitor.c']
+
+gnunetservicetransport_src = ['gnunet-service-transport.c']
+gnunetcommunicatortcp_src = ['gnunet-communicator-tcp.c']
+gnunetcommunicatorudp_src = ['gnunet-communicator-udp.c']
+gnunetcommunicatorunix_src = ['gnunet-communicator-unix.c']
+
+configure_file(input : 'transport.conf.in',
+ output : 'transport.conf',
+ configuration : cdata,
+ install: true,
+ install_dir: pkgcfgdir)
+
+configure_file(input : 'gnunet-transport-certificate-creation.in',
+ output : 'gnunet-transport-certificate-creation',
+ configuration : cdata,
+ install: true,
+ install_dir: get_option('bindir'))
+
+if get_option('monolith')
+ foreach p : libgnunettransportapplication_src + libgnunettransportcore_src +
libgnunettransportcommunicator_src + libgnunettransportmonitor_src +
gnunetservicetransport_src + gnunetcommunicatorudp_src +
gnunetcommunicatortcp_src
+ gnunet_src += 'transport/' + p
+ endforeach
+endif
+
+libgnunettransportapplication = library('gnunettransportapplication',
+ libgnunettransportapplication_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunetutil_dep],
+ include_directories: [incdir,
configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunettransportapplication, url: 'https://www.gnunet.org',
+ description : 'Provides application APIs for accessing the
transport service')
+libgnunettransportapplication_dep = declare_dependency(link_with :
libgnunettransportapplication)
+
+libgnunettransportcore = library('gnunettransportcore',
+ libgnunettransportcore_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunetutil_dep],
+ include_directories: [incdir,
configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunettransportcore, url: 'https://www.gnunet.org',
+ description : 'Provides core API for accessing the transport
service')
+libgnunettransportcore_dep = declare_dependency(link_with :
libgnunettransportcore)
+
+libgnunettransportcommunicator = library('gnunettransportcommunicator',
+ libgnunettransportcommunicator_src,
+ dependencies: [gcrypt_dep,
sodium_dep, libgnunetutil_dep],
+ include_directories: [incdir,
configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunettransportcommunicator, url: 'https://www.gnunet.org',
+ description : 'Provides communicator API for accessing the
transport service')
+libgnunettransportcommunicator_dep = declare_dependency(link_with :
libgnunettransportcommunicator)
+
+libgnunettransportmonitor = library('gnunettransportmonitor',
+ libgnunettransportmonitor_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunetutil_dep],
+ include_directories: [incdir,
configuration_inc],
+ install: true,
+ install_dir: get_option('libdir'))
+pkg.generate(libgnunettransportmonitor, url: 'https://www.gnunet.org',
+ description : 'Provides monitor API for accessing the transport
service')
+libgnunettransportmonitor_dep = declare_dependency(link_with :
libgnunettransportmonitor)
+
+
+
+executable ('gnunet-service-transport',
+ gnunetservicetransport_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunettransportcommunicator_dep,
+ libgnunetpeerstore_dep,
+ libgnunetstatistics_dep,
+ libgnunethello_dep,
+ libgnunetnat_dep,
+ gcrypt_dep,
+ m_dep,
+ libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+
+executable ('gnunet-communicator-unix',
+ gnunetcommunicatorunix_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunettransportcommunicator_dep,
+ libgnunetpeerstore_dep,
+ libgnunetstatistics_dep,
+ libgnunetnat_dep,
+ gcrypt_dep,
+ libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+
+if quic_dep.found() and get_option('experimental')
+executable ('gnunet-communicator-quic',
+ gnunetcommunicatortcp_src,
+ dependencies: [gcrypt_dep, sodium_dep,
libgnunettransportcommunicator_dep,
+ libgnunetpeerstore_dep,
+ libgnunetstatistics_dep,
+ libgnunetnat_dep,
+ gcrypt_dep,
+ quic_dep,
+ libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+endif
+
+configure_file(input : 'test_transport_defaults.conf',
+ output : 'test_transport_defaults.conf',
+ copy: true)
+
+foreach p : ['unix', 'tcp', 'udp', 'quic']
+ configure_file(input : 'test_communicator_'+p+'_basic_peer1.conf',
+ output : 'test_communicator_'+p+'_basic_peer1.conf',
+ copy: true)
+ configure_file(input : 'test_communicator_'+p+'_basic_peer2.conf',
+ output : 'test_communicator_'+p+'_basic_peer2.conf',
+ copy: true)
+endforeach
+
+foreach p : ['tcp', 'udp']
+ configure_file(input : 'test_communicator_'+p+'_rekey_peer1.conf',
+ output : 'test_communicator_'+p+'_rekey_peer1.conf',
+ copy: true)
+ configure_file(input : 'test_communicator_'+p+'_rekey_peer2.conf',
+ output : 'test_communicator_'+p+'_rekey_peer2.conf',
+ copy: true)
+endforeach
+
+configure_file(input : 'test_communicator_udp_backchannel_peer1.conf',
+ output : 'test_communicator_udp_backchannel_peer1.conf',
+ copy: true)
+configure_file(input : 'test_communicator_udp_backchannel_peer2.conf',
+ output : 'test_communicator_udp_backchannel_peer2.conf',
+ copy: true)
+
+configure_file(input : 'test_communicator_tcp_bidirect_peer1.conf',
+ output : 'test_communicator_tcp_bidirect_peer1.conf',
+ copy: true)
+configure_file(input : 'test_communicator_tcp_bidirect_peer2.conf',
+ output : 'test_communicator_tcp_bidirect_peer2.conf',
+ copy: true)
+
+
+testtransport_test_names = [
+ 'test_transport_start_testcase',
+ 'test_transport_simple_send_performance',
+ 'test_transport_nat_icmp_tcp',
+ 'test_transport_nat_upnp',
+ 'test_transport_simple_send_string',
+ 'test_transport_simple_send',
+ 'test_transport_simple_send_broadcast',
+ 'test_transport_udp_backchannel',
+ 'test_transport_simple_send_dv_circle',
+ 'test_transport_simple_send_dv_inverse'
+ ]
+
+foreach t : testtransport_test_names
+
+ test_filename = t + '.sh'
+ test_file = configure_file(input : test_filename,
+ output : test_filename,
+ copy: true)
+
+ if host_machine.system() != 'darwin'
+ test(t, test_file, suite: 'transport', workdir: meson.current_build_dir(),
is_parallel: false)
+ endif
+endforeach
\ No newline at end of file
diff --git a/src/service/transport/nat_router.sh
b/src/service/transport/nat_router.sh
new file mode 100755
index 000000000..37fa5db3c
--- /dev/null
+++ b/src/service/transport/nat_router.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+dirname=$(dirname "$0")
+PREFIX=$3
+echo start $2 >> timeout_$PREFIX.log
+if [ $2 -eq 1 ]
+then
+ if [ ! -d /tmp/netjail_scripts ]
+ then
+ mkdir /tmp/netjail_scripts
+ fi
+ if [ -f timeout_$PREFIX.out ]
+ then
+ rm timeout_$PREFIX.out
+ fi
+ touch timeout_$PREFIX.out
+ if [ -f timeout_$PREFIX.log ]
+ then
+ rm timeout_$PREFIX.log
+ fi
+ touch timeout_$PREFIX.log
+ timeout=6000000000
+ $dirname/timeout.sh $timeout $PREFIX &
+ echo gaga >> timeout_$PREFIX.log
+ timeout_pid=$!
+ conntrack -E -e NEW -s 192.168.15.1 -d 92.68.150.1/24 | while read line
+ do
+ protocol=$(echo $line|awk '{printf $2"\n"}'|awk '{printf $1"\n"}')
+ dst=$(echo $line|awk -Fdst= '{printf $2"\n"}'|awk '{printf $1"\n"}')
+ src=$(echo $line|awk -Fdst= '{printf $1"\n"}'|awk -Fsrc= '{printf
$2"\n"}')
+ port=$(echo $line|awk -Fdport= '{printf $2"\n"}'|awk '{printf $1"\n"}')
+ echo dnat >> timeout_$PREFIX.log
+ now=$(date +%s%N)
+ kill -TSTP $timeout_pid
+ if [ $(wc -l < timeout_$PREFIX.out) -eq 0 ]
+ then
+ iptables-nft -t nat -A PREROUTING -p $protocol -s $dst -d
92.68.150.$PREFIX -j DNAT --to $src
+ # echo iptables-nft -t nat -A PREROUTING -p $protocol -s $dst -d
92.68.150.1 -j DNAT --to $src >> timeout_$PREFIX.out
+ echo forwarding >> timeout_$PREFIX.log
+ fi
+ # echo $line >> timeout_$PREFIX.out
+ echo $now $protocol $dst $src $port >> timeout_$PREFIX.out
+ kill -CONT $timeout_pid
+ done
+ echo gigi >> timeout_$PREFIX.log
+ rm timeout_$PREFIX.out
+else
+ #echo "find -L /proc/[1-9]*/task/*/ns/net -samefile /run/netns/$1|while
read x" >> timeout_$PREFIX.log
+ #find -L /proc/[1-9]*/task/*/ns/net -samefile /run/netns/$1|while read x
+ #do
+ #if [ "" != "$(ps aux|grep $x|grep conntrack)" ]
+ #then
+ echo kill conntrack >> timeout_$PREFIX.log
+ killall conntrack #$x
+ #fi
+ #if [ "" != "$(ps aux|grep $x|grep timeout)" ]
+ #then
+ echo kill timeout >> timeout_$PREFIX.log
+ killall timeout.sh #$x
+ echo kill getmsg >> timeout_$PREFIX.log
+ killall getmsg.sh
+ #fi
+ #done
+fi
diff --git a/src/service/transport/template_tng_cfg_peer1.conf
b/src/service/transport/template_tng_cfg_peer1.conf
index b6198d72c..53b2ed43d 100644
--- a/src/service/transport/template_tng_cfg_peer1.conf
+++ b/src/service/transport/template_tng_cfg_peer1.conf
@@ -1,8 +1,4 @@
@INLINE@ test_tng_defaults.conf
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/
-GNUNET_RUNTIME_DIR = $GNUNET_TEST_HOME/runtime/
-GNUNET_USER_RUNTIME_DIR = $GNUNET_TEST_HOME/runtime/
[nat]
RETURN_LOCAL_ADDRESSES = YES
@@ -10,25 +6,16 @@ DISABLEV6 = NO
[arm]
PORT = 12005
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock
[statistics]
PORT = 12004
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock
[resolver]
PORT = 12003
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock
-
-[peerinfo]
-PORT = 12002
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock
-USE_INCLUDED_HELLOS = NO
[transport]
#PREFIX = valgrind --leak-check=full
PORT = 12001
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock
[hostlist]
SERVERS = dummy
diff --git a/src/service/transport/test_tng_defaults.conf
b/src/service/transport/test_tng_defaults.conf
index 81dbb5bd7..ab501183d 100644
--- a/src/service/transport/test_tng_defaults.conf
+++ b/src/service/transport/test_tng_defaults.conf
@@ -1,8 +1,5 @@
@INLINE@ ../../../contrib/conf/gnunet/no_forcestart.conf
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-tng/
-
[transport]
# PREFIX = valgrind
diff --git a/src/service/transport/test_transport_simple_send_dv_inverse.sh
b/src/service/transport/test_transport_nat_mapping.sh
similarity index 96%
copy from src/service/transport/test_transport_simple_send_dv_inverse.sh
copy to src/service/transport/test_transport_nat_mapping.sh
index cf7b863a0..4e7d6d738 100755
--- a/src/service/transport/test_transport_simple_send_dv_inverse.sh
+++ b/src/service/transport/test_transport_nat_mapping.sh
@@ -9,4 +9,4 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
fi
fi
# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes
--trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash
./test_transport_start_with_config
test_transport_distance_vector_inverse_topo.conf"
-exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
./test_transport_start_with_config
test_transport_distance_vector_inverse_topo.conf"
+exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
./test_transport_start_with_config test_transport_nat_mapping_topo.conf"
diff --git a/src/service/transport/test_transport_nat_mapping_topo.conf
b/src/service/transport/test_transport_nat_mapping_topo.conf
new file mode 100644
index 000000000..4993d77f4
--- /dev/null
+++ b/src/service/transport/test_transport_nat_mapping_topo.conf
@@ -0,0 +1,8 @@
+M:1
+N:2
+X:0
+T:libgnunet_test_transport_plugin_cmd_nat_mapping
+R:1|{tcp_port:0}|{udp_port:0}|{script:nat_router.sh}
+R:2|{tcp_port:0}|{udp_port:0}|{script:nat_router.sh}
+P:1:1|{connect:{P:2:1:tcp}}
+P:2:1|{connect:{P:1:1:tcp}}
\ No newline at end of file
diff --git a/src/service/transport/test_transport_plugin_cmd_simple_send.c
b/src/service/transport/test_transport_plugin_cmd_nat_mapping.c
similarity index 85%
copy from src/service/transport/test_transport_plugin_cmd_simple_send.c
copy to src/service/transport/test_transport_plugin_cmd_nat_mapping.c
index efef49826..cb16da284 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/service/transport/test_transport_plugin_cmd_nat_mapping.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testbed/plugin_cmd_simple_send.c
+ * @file testbed/plugin_cmd_nat_mapping.c
* @brief a plugin to provide the API for running test cases.
* @author t3sserakt
*/
@@ -39,10 +39,10 @@
#define BASE_DIR "testdir"
-#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
+#define ROUTER_BASE_IP "92.68.150."
+
static struct GNUNET_TESTING_Command block_send;
static struct GNUNET_TESTING_Command block_receive;
@@ -90,7 +90,7 @@ handle_test (void *cls,
struct GNUNET_TESTING_BarrierList *
get_waiting_for_barriers ()
{
- // No Barrier
+ //No Barrier
return GNUNET_new (struct GNUNET_TESTING_BarrierList);
}
@@ -152,7 +152,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd = GNUNET_TESTING_interpreter_lookup_command (is,
"connect-peers");
GNUNET_TRANSPORT_TESTING_get_trait_connect_peer_state (cmd,
- &cps);
+ &cps);
void *ret = NULL;
cps->notify_connect (is,
@@ -180,6 +180,15 @@ all_local_tests_prepared ()
}
+static void
+child_completed_callback (void *cls,
+ enum GNUNET_OS_ProcessStatusType type,
+ long unsigned int exit_code)
+{
+
+}
+
+
/**
* Function to start a local test case.
*
@@ -209,7 +218,13 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
struct TestState *ts = GNUNET_new (struct TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
unsigned int sscanf_ret = 0;
+ char **argv = NULL;
+ unsigned int argc = 0;
+ char *dst_ip;
+ char *num_string;
+
+
ts->finished_cb = finished_cb;
LOG (GNUNET_ERROR_TYPE_ERROR,
"n %s m %s\n",
@@ -295,6 +310,32 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
GNUNET_MQ_handler_end ()
};
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "num: %u\n",
+ num);
+ GNUNET_asprintf (&num_string,
+ "%u",
+ num);
+ GNUNET_array_append (argv, argc, "7777");
+ GNUNET_array_append (argv, argc, num_string);
+ if (1 == num )
+ {
+ GNUNET_asprintf (&dst_ip,
+ ROUTER_BASE_IP "%u",
+ num + 1);
+ GNUNET_array_append (argv, argc, dst_ip);
+ }
+ else
+ {
+ GNUNET_asprintf (&dst_ip,
+ ROUTER_BASE_IP "%u",
+ num - 1);
+ GNUNET_array_append (argv, argc, dst_ip);
+ }
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "dst_ip %s\n",
+ dst_ip);
struct GNUNET_TESTING_Command commands[] = {
GNUNET_TESTING_cmd_system_create ("system-create",
ts->testdir),
@@ -306,16 +347,15 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
ts->cfgname,
notify_connect,
GNUNET_NO),
+ GNUNET_TESTING_cmd_exec_bash_script ("nat_node_test",
+ "nat_node_test.sh",
+ argv,
+ argc,
+ &child_completed_callback),
GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
write_message),
block_send,
connect_peers,
- GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
- "start-peer",
- "system-create",
- num,
- topology),
- block_receive,
local_prepared,
GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
"start-peer"),
@@ -327,9 +367,11 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
ts->write_message = write_message;
is = GNUNET_TESTING_run (commands,
- TIMEOUT,
- &handle_result,
- ts);
+ TIMEOUT,
+ &handle_result,
+ ts);
+ GNUNET_free (num_string);
+ GNUNET_free (dst_ip);
return is;
}
@@ -341,7 +383,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
* @return the exported block API
*/
void *
-libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
+libgnunet_test_transport_plugin_cmd_nat_mapping_init (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api;
@@ -361,11 +403,11 @@ libgnunet_test_transport_plugin_cmd_simple_send_init
(void *cls)
/**
* Exit point from the plugin.
*
- * @param cls the return value from
#libgnunet_test_transport_plugin_block_test_init
+ * @param cls the return value from
#libgnunet_test_transport_plugin_cmd_nat_mapping_done
* @return NULL
*/
void *
-libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
+libgnunet_test_transport_plugin_cmd_nat_mapping_done (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api = cls;
@@ -374,4 +416,4 @@ libgnunet_test_transport_plugin_cmd_simple_send_done (void
*cls)
}
-/* end of plugin_cmd_simple_send.c */
+/* end of plugin_cmd_nat_mapping.c */
diff --git a/src/service/transport/timeout.sh b/src/service/transport/timeout.sh
new file mode 100755
index 000000000..b5692eb7c
--- /dev/null
+++ b/src/service/transport/timeout.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+timeout=$1
+PREFIX=$2
+line=$(head -n 1 timeout_$PREFIX.out)
+date=$(echo $line|awk '{printf $1"\n"}')
+now=$(date +%s%N)
+sleeptime=$(bc -l <<< "0.000000001*$1")
+if [ "" != "$line" ] && [ $timeout -le $(($now - $date)) ]
+then
+ sleeptime=0
+elif [ "" != "$line" ]
+then
+ sleeptime=$(bc -l <<< "(${now}-${date})/1000000000")
+fi
+echo $sleeptime >> timeout_$PREFIX.log
+while sleep $sleeptime
+do
+ line_num=$(wc -l < timeout_$PREFIX.out)
+ if [ 0 -lt $line_num ];then
+ for i in $(seq 1 $line_num)
+ do
+ line=$(head -n 1 timeout_$PREFIX.out)
+ date=$(echo $line|awk '{printf $1"\n"}')
+ port=$(echo $line|awk '{printf $5"\n"}')
+ dst=$(echo $line|awk '{printf $3"\n"}')
+ src=$(echo $line|awk '{printf $4"\n"}')
+ protocol=$(echo $line|awk '{printf $2"\n"}')
+ ports[$i]=-1
+ now=$(date +%s%N)
+ echo $timeout $now $date >> timeout_$PREFIX.log
+ if [ $timeout -le $(($now - $date)) ]
+ then
+ ports[$i]=$port
+ echo delete dnat $port ${ports[$i]} >>
timeout_$PREFIX.log
+ sed -i -n -e '2,$p' timeout_$PREFIX.out
+ sleeptime=$(bc -l <<< "0.000000001*$1")
+ else
+ for j in $(seq 1 $i)
+ do
+ if [ ${ports[$j]} -eq $port ]
+ then
+ ports[$j]=-1
+ fi
+ done
+ sleeptime=$(bc -l <<< "(${now}-${date})/1000000000")
+ echo $sleeptime >> timeout_$PREFIX.log
+ fi
+ done
+ for i in $(seq 1 $line_num)
+ do
+ echo $i ${ports[$i]} >> timeout_$PREFIX.log
+ if [ ${ports[$i]} -ne -1 ]
+ then
+ echo iptables-nft -t nat -D PREROUTING -p $protocol -s $dst -d
92.68.150.$PREFIX -j DNAT --to $src >> timeout_$PREFIX.log
+ iptables-nft -t nat -D PREROUTING -p $protocol -s $dst -d
92.68.150.$PREFIX -j DNAT --to $src
+ fi
+ done
+ fi
+done
diff --git a/src/service/transport/transport.h
b/src/service/transport/transport.h
index 66f17ee5b..2a42ad191 100644
--- a/src/service/transport/transport.h
+++ b/src/service/transport/transport.h
@@ -271,6 +271,11 @@ struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
*/
uint32_t cc;
+ /**
+ * The communicator can do burst msgs.
+ */
+ uint32_t can_burst;
+
/* Followed by the address prefix of the communicator */
};
@@ -668,6 +673,33 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
message to the communicator */
};
+/**
+ * Message from transport to communicator to start a burst.
+ */
+struct GNUNET_TRANSPORT_StartBurst
+{
+ /**
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_START_BURST.
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Target peer.
+ */
+ struct GNUNET_PeerIdentity pid;
+
+ struct GNUNET_TIME_RelativeNBO rtt;
+
+ /* followed by UTF-8 encoded, 0-terminated human-readable address */
+};
+
+struct GNUNET_TRANSPORT_BurstFinished
+{
+ /**
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_BURST_FINISHED.
+ */
+ struct GNUNET_MessageHeader header;
+};
/**
* Request to start monitoring.
diff --git a/src/service/transport/transport_api2_communication.c
b/src/service/transport/transport_api2_communication.c
index 3c494ae1c..79873e13e 100644
--- a/src/service/transport/transport_api2_communication.c
+++ b/src/service/transport/transport_api2_communication.c
@@ -163,6 +163,11 @@ struct GNUNET_TRANSPORT_CommunicatorHandle
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
+ /**
+ * Function to start a burst, requested by the transport service.
+ */
+ GNUNET_TRANSPORT_StartBurstNotify sb;
+
/**
* Config section to use.
*/
@@ -774,6 +779,41 @@ handle_backchannel_incoming (
}
+static int
+check_start_burst (void *cls,
+ const struct GNUNET_TRANSPORT_StartBurst *sb)
+{
+ (void) cls;
+ const char *str = (const char *) &sb[1];
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "check_start_burst %s %lu\n",
+ str,
+ strlen (str));
+ GNUNET_MQ_check_zero_termination (sb);
+ return GNUNET_OK;
+}
+
+
+static void
+handle_start_burst (void *cls,
+ const struct GNUNET_TRANSPORT_StartBurst *sb)
+{
+ struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
+ const char *addr = (const char *) &sb[1];
+ struct GNUNET_TIME_Relative rtt = GNUNET_TIME_relative_ntoh (sb->rtt);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Calling communicator to start burst to %s is %s rtt %lu\n",
+ addr,
+ NULL == sb ? "not possible" : "possible",
+ rtt.rel_value_us);
+
+ if (NULL != ch->sb)
+ ch->sb (addr, GNUNET_TIME_relative_ntoh (sb->rtt), (struct
GNUNET_PeerIdentity *) &sb->pid);
+}
+
+
/**
* (re)connect our communicator to the transport service
*
@@ -800,6 +840,11 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING,
struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
ch),
+ GNUNET_MQ_hd_var_size (
+ start_burst,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_START_BURST,
+ struct GNUNET_TRANSPORT_StartBurst,
+ ch),
GNUNET_MQ_handler_end () };
struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;
struct GNUNET_MQ_Envelope *env;
@@ -811,6 +856,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
env = GNUNET_MQ_msg_extra (cam,
strlen (ch->addr_prefix) + 1,
GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR);
+ if (NULL != ch->sb)
+ {
+ cam->can_burst = htonl (GNUNET_YES);
+ }
cam->cc = htonl ((uint32_t) ch->cc);
memcpy (&cam[1], ch->addr_prefix, strlen (ch->addr_prefix) + 1);
GNUNET_MQ_send (ch->mq, env);
@@ -832,7 +881,8 @@ GNUNET_TRANSPORT_communicator_connect (
GNUNET_TRANSPORT_CommunicatorMqInit mq_init,
void *mq_init_cls,
GNUNET_TRANSPORT_CommunicatorNotify notify_cb,
- void *notify_cb_cls)
+ void *notify_cb_cls,
+ GNUNET_TRANSPORT_StartBurstNotify sb)
{
struct GNUNET_TRANSPORT_CommunicatorHandle *ch;
@@ -845,6 +895,7 @@ GNUNET_TRANSPORT_communicator_connect (
ch->notify_cb = notify_cb;
ch->notify_cb_cls = notify_cb_cls;
ch->cc = cc;
+ ch->sb = sb;
reconnect (ch);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -1122,5 +1173,16 @@ GNUNET_TRANSPORT_communicator_notify (
GNUNET_MQ_send (ch->mq, env);
}
+/* ************************* Burst *************************** */
+
+void
+GNUNET_TRANSPORT_communicator_burst_finished (struct
GNUNET_TRANSPORT_CommunicatorHandle *ch)
+{
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_TRANSPORT_BurstFinished *bf;
+
+ env = GNUNET_MQ_msg (bf, GNUNET_MESSAGE_TYPE_TRANSPORT_BURST_FINISHED);
+ GNUNET_MQ_send (ch->mq, env);
+}
/* end of transport_api2_communication.c */
diff --git a/src/service/util/meson.build
b/src/service/util/meson.build.arm_monolith
similarity index 66%
copy from src/service/util/meson.build
copy to src/service/util/meson.build.arm_monolith
index b7642c905..5c9cc9f91 100644
--- a/src/service/util/meson.build
+++ b/src/service/util/meson.build.arm_monolith
@@ -15,20 +15,13 @@ endif
executable ('gnunet-service-resolver',
gnunetserviceresolver_src,
- dependencies: [libgnunetutil_dep],
+ dependencies: [gcrypt_dep, sodium_dep, libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir') / 'gnunet' / 'libexec')
-testresolverapi = executable ('test_resolver_api',
- ['test_resolver_api.c'],
- dependencies: [libgnunetutil_dep],
- include_directories: [incdir, configuration_inc],
- install: false)
configure_file(copy: true,
input: 'test_resolver_api_data.conf',
output: 'test_resolver_api_data.conf')
-test('test_resolver_api', testresolverapi, workdir: meson.current_build_dir(),
- suite: 'resolver')
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (7322b322b -> 9a97ab1a8),
gnunet <=
- [gnunet] 02/19: Added test case to start Android SDK emulator., gnunet, 2024/08/28
- [gnunet] 01/19: Transport: Added test case to simulate router NAT mapping behavior., gnunet, 2024/08/28
- [gnunet] 04/19: Added sync protocol., gnunet, 2024/08/28
- [gnunet] 03/19: Added functionality to check if all services and communicators are started., gnunet, 2024/08/28
- [gnunet] 08/19: Implemented burst mode., gnunet, 2024/08/28
- [gnunet] 13/19: Refactoring the burst logic., gnunet, 2024/08/28
- [gnunet] 06/19: Moved sync protocol to util., gnunet, 2024/08/28
- [gnunet] 12/19: Fixed Generic and specific test setup and code., gnunet, 2024/08/28
- [gnunet] 07/19: NAT: Added missing missing files, gnunet, 2024/08/28
- [gnunet] 05/19: Fixed bug with new queues inheriting the validated_until value of existing queues., gnunet, 2024/08/28