diff options
241 files changed, 12116 insertions, 7869 deletions
@@ -1,3 +1,23 @@ | |||
1 | v0.20.0: | ||
2 | - GNUNET_TESTING_get_testname_from_underscore renamed to GNUNET_STRINGS_get_suffix_from_binary_name and moved from libgnunettesting to libgnuneutil | ||
3 | - Move GNUNET_s into libgnunetutil. | ||
4 | - re-introduce compiler annotation for array size in signature | ||
5 | - function-signature adjustment due to compiler error | ||
6 | - GNUNET_PQ_get_oid removed, GNUNET_PQ_get_oid_by_name improved | ||
7 | - Added GNUNET_PQ_get_oid_by_name | ||
8 | - added GNUNET_PQ_get_oid() | ||
9 | - Added new CCA-secure KEM and use in IDENTITY encryption | ||
10 | - Add KEM API to avoid ephemeral private key management | ||
11 | - Add new GNUNET_PQ_event_do_poll() API to gnunet_pq_lib.h | ||
12 | - Added API to support arrays in query results | ||
13 | - Improve PQ API documentation. | ||
14 | - API for array types extended for times | ||
15 | - API extended for array query types | ||
16 | - relevant array-types in queries (not results) in postgresql added | ||
17 | - just style fixes, int to enum | ||
18 | - initial steps towards support of array-types in posgresql | ||
19 | - adds GNUNET_JSON_spec_object_const() and GNUNET_JSON_spec_array_const() | ||
20 | |||
1 | v0.19.4: | 21 | v0.19.4: |
2 | - No changes | 22 | - No changes |
3 | 23 | ||
@@ -82,7 +82,7 @@ Build tools for compiling GNUnet from source: | |||
82 | - make[*3] | 82 | - make[*3] |
83 | - pkgconf or pkg-config | 83 | - pkgconf or pkg-config |
84 | - sphinx | 84 | - sphinx |
85 | - sphinx-rtd-theme | 85 | - sphinx-book-theme |
86 | 86 | ||
87 | Direct dependencies of GNUnet: | 87 | Direct dependencies of GNUnet: |
88 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 88 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -121,7 +121,6 @@ Direct dependencies of GNUnet: | |||
121 | Dependencies of optional components/functionality: | 121 | Dependencies of optional components/functionality: |
122 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 122 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
123 | - Database plugins (alternatives to sqlite): | 123 | - Database plugins (alternatives to sqlite): |
124 | * mysql >= 5.1 | ||
125 | * postgres >= 9.5 | 124 | * postgres >= 9.5 |
126 | - Transport plugins: | 125 | - Transport plugins: |
127 | * bluez (bluetooth transport) | 126 | * bluez (bluetooth transport) |
@@ -315,9 +314,7 @@ traversal). | |||
315 | 314 | ||
316 | GNUnet requires the GNU MP library (https://www.gnu.org/software/gmp/) | 315 | GNUnet requires the GNU MP library (https://www.gnu.org/software/gmp/) |
317 | and libgcrypt (https://www.gnupg.org/). You can specify the path to | 316 | and libgcrypt (https://www.gnupg.org/). You can specify the path to |
318 | libgcrypt by passing "--with-gcrypt=PATH" to configure. You will also | 317 | libgcrypt by passing "--with-gcrypt=PATH" to configure. |
319 | need either sqlite (http://www.sqlite.org/), MySQL | ||
320 | (http://www.mysql.org/) or PostGres (http://www.postgres.org/). | ||
321 | 318 | ||
322 | If you install from source, you need to install GNU libextractor first | 319 | If you install from source, you need to install GNU libextractor first |
323 | (download from https://www.gnu.org/software/libextractor/). We also | 320 | (download from https://www.gnu.org/software/libextractor/). We also |
diff --git a/README.meson.md b/README.meson.md new file mode 100644 index 000000000..a92046943 --- /dev/null +++ b/README.meson.md | |||
@@ -0,0 +1,43 @@ | |||
1 | # Meson build system | ||
2 | |||
3 | DISCLAIMER: This is a work in progress. The meson build system will be maintained for a brief period alongside autotools. | ||
4 | |||
5 | ## Motivation | ||
6 | |||
7 | - We want to build a single, monolithic library libgnunet that is easier to use in, for example, mobile apps. | ||
8 | - Autotools is complex and difficult to use. It also causes stale builds. Meson has a better developer experience. | ||
9 | - Meson supports dynamic pkg-config generation. | ||
10 | - Meson does out-of-tree builds | ||
11 | - Meson makes it (almost) impossible to create dist tarballs that miss files/do not compile. | ||
12 | |||
13 | |||
14 | ## Reasons to drop it again | ||
15 | |||
16 | - Meson does not seem to support (automatic) dependency version detection without pkg-config. | ||
17 | |||
18 | |||
19 | ## TODOs | ||
20 | |||
21 | - Migrate tests | ||
22 | - Portability defines set implicitly in configure.ac need to be identified and ported to meson. | ||
23 | - Some (experimental) subsystems not yet ported. | ||
24 | - 1:1 match of installed files must be verified. | ||
25 | - Documentation must be updated. | ||
26 | |||
27 | ## Use | ||
28 | |||
29 | |||
30 | ``` | ||
31 | $ meson setup $builddir | ||
32 | $ cd $builddir | ||
33 | $ meson configure -Dprefix=$string -Dexperimental=$bool -Dmonolith=$bool | ||
34 | $ meson compile | ||
35 | $ meson install | ||
36 | $ meson dist | ||
37 | ``` | ||
38 | |||
39 | |||
40 | ## Open issues | ||
41 | |||
42 | - Tests are always built: https://github.com/mesonbuild/meson/pull/6511 | ||
43 | - libtool versioning is different from soversion and version in meson | ||
diff --git a/configure.ac b/configure.ac index 3e7b42a12..80ceaed67 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -768,13 +768,9 @@ AC_CHECK_LIB([kstat], [kstat_open]) | |||
768 | 768 | ||
769 | # check for libsodium version >= 1.0.18 | 769 | # check for libsodium version >= 1.0.18 |
770 | libsodium=0 | 770 | libsodium=0 |
771 | AC_CHECK_HEADER([sodium.h], | 771 | CHECK_WITH_LIB([sodium], [crypto_core_ed25519_scalar_mul], [sodium.h], [HAVE_SODIUM]) |
772 | [AC_CHECK_LIB([sodium], [crypto_core_ed25519_scalar_mul], | 772 | AS_IF([test "x$sodium" = "x0"], |
773 | [libsodium=1], | 773 | [AC_MSG_ERROR([GNUnet requires libsodium >= 1.0.18])]) |
774 | [libsodium=0])]) | ||
775 | |||
776 | AS_IF([test "x$libsodium" = "x0"], | ||
777 | [AC_MSG_ERROR([GNUnet requires libsodium >= 1.0.18])]) | ||
778 | 774 | ||
779 | # check for libextractor | 775 | # check for libextractor |
780 | CHECK_WITH_LIB([extractor], | 776 | CHECK_WITH_LIB([extractor], |
@@ -784,6 +780,14 @@ CHECK_WITH_LIB([extractor], | |||
784 | AS_IF([test "x$extractor" = "x0"], | 780 | AS_IF([test "x$extractor" = "x0"], |
785 | [AC_MSG_RESULT([GNU libextractor not found, some features disabled])]) | 781 | [AC_MSG_RESULT([GNU libextractor not found, some features disabled])]) |
786 | 782 | ||
783 | # check for cloudflare-quiche | ||
784 | CHECK_WITH_LIB([quiche], | ||
785 | [quiche_header_info], | ||
786 | [quiche.h], | ||
787 | [HAVE_QUICHE]) | ||
788 | AS_IF([test "x$quiche" = "x0"], | ||
789 | [AC_MSG_RESULT([cloudflare-quiche not found, some features disabled])]) | ||
790 | |||
787 | # check for libltdl | 791 | # check for libltdl |
788 | CHECK_WITH_LIB([ltdl], [lt_dlopenext], [ltdl.h], [HAVE_LTDL]) | 792 | CHECK_WITH_LIB([ltdl], [lt_dlopenext], [ltdl.h], [HAVE_LTDL]) |
789 | AS_IF([test "x$ldtl" = "x0"], | 793 | AS_IF([test "x$ldtl" = "x0"], |
@@ -878,9 +882,9 @@ AC_DEFINE_UNQUOTED([HAVE_ZLIB], [$zlib_ok], [Define to 1 if zlib is available]) | |||
878 | AM_ICONV | 882 | AM_ICONV |
879 | 883 | ||
880 | # check for libunistring | 884 | # check for libunistring |
881 | gl_LIBUNISTRING | 885 | CHECK_WITH_LIB([unistring], [u16_strstr], [unistr.h], [HAVE_UNISTRING]) |
882 | AS_IF([test "x$HAVE_LIBUNISTRING" != "xyes"], | 886 | AS_IF([test "x$unistring" = "x0"], |
883 | [AC_MSG_ERROR([GNUnet requires libunistring])]) | 887 | [AC_MSG_ERROR([GNUnet requires unistring])]) |
884 | 888 | ||
885 | # Currently broken on Debian :-( | 889 | # Currently broken on Debian :-( |
886 | # AS_VERSION_COMPARE([$LIBUNISTRING_VERSION], [0.9.1.1], | 890 | # AS_VERSION_COMPARE([$LIBUNISTRING_VERSION], [0.9.1.1], |
@@ -900,89 +904,6 @@ AM_CONDITIONAL([HAVE_POSTGRESQL], [test "x$postgres" = "x1"]) | |||
900 | AC_DEFINE_UNQUOTED([HAVE_POSTGRESQL], [$postgres], | 904 | AC_DEFINE_UNQUOTED([HAVE_POSTGRESQL], [$postgres], |
901 | [Define to 1 if Postgres is available]) | 905 | [Define to 1 if Postgres is available]) |
902 | 906 | ||
903 | # check for mysql | ||
904 | SAVE_LDFLAGS="$LDFLAGS" | ||
905 | SAVE_CPPFLAGS="$CPPFLAGS" | ||
906 | AC_ARG_WITH([mysql], | ||
907 | [AS_HELP_STRING([--with-mysql=PFX], [base of mysql installation])], | ||
908 | [AS_CASE([$withval], | ||
909 | [no], | ||
910 | [], | ||
911 | [yes|""], | ||
912 | [AC_CHECK_HEADERS([mysql/mysql.h], | ||
913 | [AC_CHECK_LIB([mysqlclient], [mysql_init], | ||
914 | [mysql=true], [mysql=false])])], | ||
915 | [LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql $LDFLAGS $ZLIBS" | ||
916 | CPPFLAGS="-I$with_mysql/include $CPPFLAGS" | ||
917 | AC_CHECK_HEADERS([mysql/mysql.h], | ||
918 | [AC_CHECK_LIB([mysqlclient], [mysql_init], | ||
919 | [MYSQL_LDFLAGS="-L$with_mysql/lib -L$with_mysql/lib/mysql" | ||
920 | MYSQL_CPPFLAGS="-I$with_mysql/include" | ||
921 | mysql=true], | ||
922 | [mysql=false])])])], | ||
923 | [AS_IF([test -d "/usr/lib64/mysql"], | ||
924 | [MYSQL_LIBDIR="/usr/lib64/mysql"], | ||
925 | [AS_IF([test -d "/usr/lib/mysql"], | ||
926 | [MYSQL_LIBDIR="/usr/lib/mysql"], | ||
927 | [MYSQL_LIBDIR="/usr/lib"])]) | ||
928 | LDFLAGS="-L$MYSQL_LIBDIR $LDFLAGS $ZLIBS" | ||
929 | AC_CHECK_LIB([mysqlclient], [mysql_init], | ||
930 | [AC_CHECK_HEADERS([mysql/mysql.h], | ||
931 | [MYSQL_LDFLAGS="-L$MYSQL_LIBDIR" | ||
932 | mysql=true], | ||
933 | [mysql=false])], | ||
934 | [mysql=false])]) | ||
935 | AC_SUBST(MYSQL_LDFLAGS) | ||
936 | AC_SUBST(MYSQL_CPPFLAGS) | ||
937 | |||
938 | mysql_bool="bool" | ||
939 | # check for my_bool | ||
940 | AS_IF([test "x$mysql" = "xtrue"], | ||
941 | [AC_MSG_CHECKING([for my_bool]) | ||
942 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | ||
943 | [[#include <mysql/mysql.h>] | ||
944 | [typedef int my_bool;]])], # Hint: this fails if my_bool is defined already | ||
945 | [AC_MSG_RESULT([no]) | ||
946 | mysql_bool="bool"], | ||
947 | [AC_MSG_RESULT([yes]) | ||
948 | mysql_bool="my_bool"])]) | ||
949 | |||
950 | AC_SUBST([mysql_bool]) | ||
951 | |||
952 | # additional version checks for mysql | ||
953 | AS_IF([test "x$mysql" = "xtrue"], | ||
954 | [AC_MSG_CHECKING([for mysql version]) | ||
955 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | ||
956 | [[#include <mysql/mysql.h>]], | ||
957 | [[#if (MYSQL_VERSION_ID < 40100) | ||
958 | #error required at least version 4.1 | ||
959 | #endif]])], | ||
960 | [mysql=true], | ||
961 | [mysql=false]) | ||
962 | AS_IF([test "x$mysql" = "xfalse"], | ||
963 | [AC_MSG_RESULT([< 4.1]) | ||
964 | AC_MSG_RESULT([mysql version >= 4.1 required. Will not use MySQL])]) | ||
965 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | ||
966 | [[#include <mysql/mysql.h>]], | ||
967 | [[#if (MYSQL_VERSION_ID < 80000) | ||
968 | #error needs at least version 8.0 | ||
969 | #endif]])], | ||
970 | [mysql8=true], | ||
971 | [mysql8=false])]) | ||
972 | |||
973 | AS_IF([test "x$mysql" = "xtrue"], | ||
974 | [AS_IF([test "x$mysql8" = "xfalse"], | ||
975 | [AC_MSG_RESULT([between 4.1 and 8.0])], | ||
976 | [AC_MSG_RESULT([> 8.0]) | ||
977 | AC_DEFINE([HAVE_MYSQL8], [1], | ||
978 | [Define to 1 if MySQL is at least version 8])])]) | ||
979 | |||
980 | AM_CONDITIONAL([HAVE_MYSQL], [test "x$mysql" = "xtrue"]) | ||
981 | AM_CONDITIONAL([HAVE_MYSQLE], [false]) | ||
982 | |||
983 | AS_IF([test "x$sqlite3" = "x0" && test "x$mysql" = "xfalse" && test "x$postgres" = "x0"], | ||
984 | [AC_MSG_ERROR([GNUnet requires either SQLite, MySQL/MariaDB or PostgreSQL])]) | ||
985 | |||
986 | LDFLAGS="$SAVE_LDFLAGS" | 907 | LDFLAGS="$SAVE_LDFLAGS" |
987 | CPPFLAGS="$SAVE_CPPFLAGS" | 908 | CPPFLAGS="$SAVE_CPPFLAGS" |
988 | 909 | ||
@@ -1343,12 +1264,9 @@ src/identity/Makefile | |||
1343 | src/identity/identity.conf | 1264 | src/identity/identity.conf |
1344 | src/include/Makefile | 1265 | src/include/Makefile |
1345 | src/include/gnunet_config.h | 1266 | src/include/gnunet_config.h |
1346 | src/include/gnunet_mysql_compat.h | ||
1347 | src/integration-tests/Makefile | 1267 | src/integration-tests/Makefile |
1348 | src/json/Makefile | 1268 | src/json/Makefile |
1349 | src/hostlist/Makefile | 1269 | src/hostlist/Makefile |
1350 | src/my/Makefile | ||
1351 | src/mysql/Makefile | ||
1352 | src/namecache/Makefile | 1270 | src/namecache/Makefile |
1353 | src/namecache/namecache.conf | 1271 | src/namecache/namecache.conf |
1354 | src/namestore/Makefile | 1272 | src/namestore/Makefile |
@@ -1425,9 +1343,9 @@ pkgconfig/gnunetfs.pc | |||
1425 | pkgconfig/gnunetgns.pc | 1343 | pkgconfig/gnunetgns.pc |
1426 | pkgconfig/gnunethello.pc | 1344 | pkgconfig/gnunethello.pc |
1427 | pkgconfig/gnunetidentity.pc | 1345 | pkgconfig/gnunetidentity.pc |
1346 | pkgconfig/gnunetjson.pc | ||
1428 | pkgconfig/gnunetmessenger.pc | 1347 | pkgconfig/gnunetmessenger.pc |
1429 | pkgconfig/gnunetmicrophone.pc | 1348 | pkgconfig/gnunetmicrophone.pc |
1430 | pkgconfig/gnunetmysql.pc | ||
1431 | pkgconfig/gnunetnamestore.pc | 1349 | pkgconfig/gnunetnamestore.pc |
1432 | pkgconfig/gnunetnat.pc | 1350 | pkgconfig/gnunetnat.pc |
1433 | pkgconfig/gnunetnse.pc | 1351 | pkgconfig/gnunetnse.pc |
@@ -1569,11 +1487,6 @@ AS_IF([test "x$sqlite3" = "x1"], | |||
1569 | features_msg="sqlite $features_msg"], | 1487 | features_msg="sqlite $features_msg"], |
1570 | [sqlite_msg="no"]) | 1488 | [sqlite_msg="no"]) |
1571 | 1489 | ||
1572 | AS_IF([test "x$mysql" = "xtrue"], | ||
1573 | [mysql_msg="yes" | ||
1574 | features_msg="mysql $features_msg"], | ||
1575 | [mysql_msg="no"]) | ||
1576 | |||
1577 | AS_IF([test "x$postgres" = "x1"], | 1490 | AS_IF([test "x$postgres" = "x1"], |
1578 | [postgres_msg="yes" | 1491 | [postgres_msg="yes" |
1579 | features_msg="postgres $features_msg"], | 1492 | features_msg="postgres $features_msg"], |
@@ -1602,7 +1515,6 @@ Build Target: ${build_target} | |||
1602 | Default Interface: ${interface_msg} | 1515 | Default Interface: ${interface_msg} |
1603 | 1516 | ||
1604 | sqlite3: ${sqlite_msg} | 1517 | sqlite3: ${sqlite_msg} |
1605 | MySQL: ${mysql_msg} | ||
1606 | PostgreSQL: ${postgres_msg} | 1518 | PostgreSQL: ${postgres_msg} |
1607 | 1519 | ||
1608 | cURL TLS backend: ${curl_tls_backend} | 1520 | cURL TLS backend: ${curl_tls_backend} |
diff --git a/contrib/Makefile.inc b/contrib/Makefile.inc index a563ef4a1..c737a07f8 100644 --- a/contrib/Makefile.inc +++ b/contrib/Makefile.inc | |||
@@ -8,8 +8,7 @@ BUILDCOMMON_SHLIB_FILES = \ | |||
8 | build-common/sh/lib.sh/existence_python.sh \ | 8 | build-common/sh/lib.sh/existence_python.sh \ |
9 | build-common/sh/lib.sh/msg.sh \ | 9 | build-common/sh/lib.sh/msg.sh \ |
10 | build-common/sh/lib.sh/progname.sh \ | 10 | build-common/sh/lib.sh/progname.sh \ |
11 | build-common/sh/lib.sh/version_gnunet.sh \ | 11 | build-common/sh/lib.sh/version_gnunet.sh |
12 | build-common/LICENSE | ||
13 | 12 | ||
14 | BUILDCOMMON_CONF_FILES = \ | 13 | BUILDCOMMON_CONF_FILES = \ |
15 | build-common/conf/.dir-locals.el \ | 14 | build-common/conf/.dir-locals.el \ |
diff --git a/contrib/conf/commit-msg b/contrib/conf/commit-msg index cc532921c..e57333c00 100755 --- a/contrib/conf/commit-msg +++ b/contrib/conf/commit-msg | |||
@@ -31,4 +31,4 @@ then | |||
31 | else | 31 | else |
32 | echo "Your commit does not include API changes" | 32 | echo "Your commit does not include API changes" |
33 | fi | 33 | fi |
34 | exit $RET | 34 | exit 0 |
diff --git a/contrib/conf/gnunet/meson.build b/contrib/conf/gnunet/meson.build new file mode 100644 index 000000000..0419784fb --- /dev/null +++ b/contrib/conf/gnunet/meson.build | |||
@@ -0,0 +1,6 @@ | |||
1 | configure_file(copy: true, | ||
2 | input: 'no_forcestart.conf', | ||
3 | output: 'no_forcestart.conf') | ||
4 | configure_file(copy: true, | ||
5 | input: 'no_autostart_above_core.conf', | ||
6 | output: 'no_autostart_above_core.conf') | ||
diff --git a/contrib/conf/meson.build b/contrib/conf/meson.build new file mode 100644 index 000000000..f0e4647df --- /dev/null +++ b/contrib/conf/meson.build | |||
@@ -0,0 +1 @@ | |||
subdir('gnunet') | |||
diff --git a/contrib/conf/uncrustify_precommit b/contrib/conf/uncrustify_precommit index 3a06511d1..d9c30a2dd 100755 --- a/contrib/conf/uncrustify_precommit +++ b/contrib/conf/uncrustify_precommit | |||
@@ -28,8 +28,11 @@ done | |||
28 | 28 | ||
29 | if [ $RET = 1 ]; | 29 | if [ $RET = 1 ]; |
30 | then | 30 | then |
31 | echo "Run" | 31 | echo "================================================================" |
32 | echo "uncrustify --replace -c uncrustify.cfg ${crustified}" | 32 | echo " Your changes are ugly! " |
33 | echo "before committing." | 33 | echo " Uncrustify your code in your next commit. " |
34 | echo " See https://docs.gnunet.org/developers/style.html#coding-style " | ||
35 | echo "================================================================" | ||
34 | fi | 36 | fi |
35 | exit $RET | 37 | # Do not fail |
38 | exit 0 | ||
diff --git a/contrib/gana b/contrib/gana | |||
Subproject 66228b8a4306f028d843d78fbfcca54260539ff | Subproject c1dc2dc975742c929a523c22d91f7d4f8278723 | ||
diff --git a/contrib/hellos/meson.build b/contrib/hellos/meson.build new file mode 100644 index 000000000..f1fa463de --- /dev/null +++ b/contrib/hellos/meson.build | |||
@@ -0,0 +1,2 @@ | |||
1 | install_data('Y924NSHMMZ1N1SQCE5TXF93ED6S6JY311K0QT86G9WJC68F6XVZ0', | ||
2 | install_dir: get_option('datadir')/'gnunet'/'hellos') | ||
diff --git a/contrib/meson.build b/contrib/meson.build new file mode 100644 index 000000000..ff8a0a989 --- /dev/null +++ b/contrib/meson.build | |||
@@ -0,0 +1,33 @@ | |||
1 | subdir('conf') | ||
2 | subdir('hellos') | ||
3 | subdir('scripts') | ||
4 | |||
5 | |||
6 | install_data(['gns'/'def.tex', | ||
7 | 'gns'/'gns-bcd.html', | ||
8 | 'gns'/'gns-bcd.tex', | ||
9 | 'gns'/'gns-bcd-forbidden.html', | ||
10 | 'gns'/'gns-bcd-internal-error.html', | ||
11 | 'gns'/'gns-bcd-invalid-key.html', | ||
12 | 'gns'/'gns-bcd-not-found.html', | ||
13 | 'gns'/'gns-bcd-png.tex', | ||
14 | 'gns'/'gns-bcd-simple.html', | ||
15 | 'gns'/'gns-bcd-simple.tex', | ||
16 | 'fcfsd'/'fcfsd-index.html', | ||
17 | 'fcfsd'/'fcfsd-forbidden.html', | ||
18 | 'fcfsd'/'fcfsd-notfound.html', | ||
19 | 'branding'/'logo'/'gnunet-logo.png', | ||
20 | 'branding'/'logo'/'gnunet-logo-dark-text.svg', | ||
21 | 'branding'/'logo'/'gnunet-logo-dark-only-text.svg', | ||
22 | 'testing_hostkeys.ecc', | ||
23 | 'netjail'/'netjail_core.sh', | ||
24 | 'netjail'/'netjail_exec.sh', | ||
25 | 'netjail'/'netjail_start.sh', | ||
26 | 'netjail'/'netjail_stop.sh', | ||
27 | 'netjail'/'topo.sh', | ||
28 | ], | ||
29 | install_dir: get_option('datadir')/'gnunet') | ||
30 | |||
31 | install_data('xdg-scheme-handler'/'gnunet-uri.desktop', | ||
32 | install_dir: get_option('datadir')/'applications') | ||
33 | |||
diff --git a/contrib/scripts/meson.build b/contrib/scripts/meson.build new file mode 100644 index 000000000..d56ba2b76 --- /dev/null +++ b/contrib/scripts/meson.build | |||
@@ -0,0 +1,4 @@ | |||
1 | install_data('gnunet-bugreport', | ||
2 | install_dir: get_option('bindir')) | ||
3 | install_data('gnunet-suidfix', | ||
4 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
diff --git a/debian/changelog b/debian/changelog index 4fec0130c..03bc26e45 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -1,3 +1,9 @@ | |||
1 | gnunet (0.20.0) unstable; urgency=low | ||
2 | |||
3 | * First work towards packaging v0.20.0. | ||
4 | |||
5 | -- Christian Grothoff <grothoff@gnu.org> Thu, 7 Sep 2023 23:50:12 +0200 | ||
6 | |||
1 | gnunet (0.19.3-1) unstable; urgency=low | 7 | gnunet (0.19.3-1) unstable; urgency=low |
2 | 8 | ||
3 | * Minor packaging fix. | 9 | * Minor packaging fix. |
diff --git a/debian/control b/debian/control index 57acc6e1e..e8601829b 100644 --- a/debian/control +++ b/debian/control | |||
@@ -17,10 +17,10 @@ Build-Depends: | |||
17 | libidn2-dev, | 17 | libidn2-dev, |
18 | libjansson-dev, | 18 | libjansson-dev, |
19 | libltdl-dev (>=2.2), | 19 | libltdl-dev (>=2.2), |
20 | libmicrohttpd-dev (>=0.9.63), | 20 | libmicrohttpd-dev (>=0.9.71), |
21 | libogg-dev (>=1.3.0), | 21 | libogg-dev (>=1.3.0), |
22 | libopus-dev (>=1.0.1), | 22 | libopus-dev (>=1.0.1), |
23 | libpq-dev (>=9.5), | 23 | libpq-dev (>=13), |
24 | libpulse-dev (>=2.0), | 24 | libpulse-dev (>=2.0), |
25 | libsodium-dev (>=1.0.11), | 25 | libsodium-dev (>=1.0.11), |
26 | libsqlite3-dev (>=3.8), | 26 | libsqlite3-dev (>=3.8), |
@@ -97,7 +97,7 @@ Depends: | |||
97 | libgnunet (= ${binary:Version}), | 97 | libgnunet (= ${binary:Version}), |
98 | libextractor-dev (>=1:0.6.3), | 98 | libextractor-dev (>=1:0.6.3), |
99 | libgcrypt20-dev (>=1.6), | 99 | libgcrypt20-dev (>=1.6), |
100 | libmicrohttpd-dev (>=0.9.33), | 100 | libmicrohttpd-dev (>=0.9.71), |
101 | ${misc:Depends} | 101 | ${misc:Depends} |
102 | Description: GNU's framework for secure peer-to-peer networking (development) | 102 | Description: GNU's framework for secure peer-to-peer networking (development) |
103 | GNUnet is a framework for secure peer-to-peer networking that does not use any | 103 | GNUnet is a framework for secure peer-to-peer networking that does not use any |
diff --git a/doc/handbook/meson.build b/doc/handbook/meson.build new file mode 100644 index 000000000..dd9a2ddcf --- /dev/null +++ b/doc/handbook/meson.build | |||
@@ -0,0 +1,42 @@ | |||
1 | fs = import('fs') | ||
2 | makeinfo = find_program('makeinfo', native: true, required: false) | ||
3 | sphinx = find_program('sphinx-build', native: true, required: false) | ||
4 | |||
5 | if fs.exists('html') | ||
6 | install_subdir('html', | ||
7 | install_dir: docdir, | ||
8 | strip_directory: false) | ||
9 | else | ||
10 | if sphinx.found() | ||
11 | sphinxhandbook = custom_target('handbook-html', | ||
12 | output: 'html', | ||
13 | command: [sphinx, | ||
14 | '-M', 'html', | ||
15 | meson.project_source_root()/'contrib'/'sphinx', meson.current_build_dir()], | ||
16 | install: true, | ||
17 | install_dir: docdir) | ||
18 | endif | ||
19 | endif | ||
20 | |||
21 | if fs.exists('texinfo') | ||
22 | install_data('texinfo'/'gnunet.info', | ||
23 | install_dir: get_option('infodir')) | ||
24 | else | ||
25 | if sphinx.found() | ||
26 | sphinxhandbooktexi = custom_target('handbook-texinfo', | ||
27 | output: ['texinfo'], | ||
28 | command: [sphinx, | ||
29 | '-M', 'texinfo', | ||
30 | meson.project_source_root()/'contrib'/'sphinx', meson.current_build_dir()], | ||
31 | install: false, | ||
32 | install_dir: get_option('infodir')) | ||
33 | custom_target('gnunet.info', | ||
34 | output: 'gnunet.info', | ||
35 | depends: sphinxhandbooktexi, | ||
36 | command: [makeinfo, '--no-split', '--no-headers', | ||
37 | meson.current_build_dir()/'texinfo'/'gnunet.texi', '-o', '@OUTPUT0@'], | ||
38 | install: true, | ||
39 | install_dir: get_option('infodir')) | ||
40 | endif | ||
41 | endif | ||
42 | |||
diff --git a/doc/man/meson.build b/doc/man/meson.build new file mode 100644 index 000000000..6a271ff3c --- /dev/null +++ b/doc/man/meson.build | |||
@@ -0,0 +1,66 @@ | |||
1 | five = configure_file(input : 'gnunet.conf.5.in', | ||
2 | output : 'gnunet.conf.5', | ||
3 | configuration : cdata, | ||
4 | install: false, | ||
5 | install_dir: get_option('mandir')) | ||
6 | |||
7 | install_man( | ||
8 | [ | ||
9 | five, | ||
10 | 'gnunet-arm.1', | ||
11 | 'gnunet-ats.1', | ||
12 | 'gnunet-auto-share.1', | ||
13 | 'gnunet-base32.1', | ||
14 | 'gnunet-bcd.1', | ||
15 | 'gnunet-bugreport.1', | ||
16 | 'gnunet-config.1', | ||
17 | 'gnunet-core.1', | ||
18 | 'gnunet-conversation.1', | ||
19 | 'gnunet-conversation-test.1', | ||
20 | 'gnunet-dht-get.1', | ||
21 | 'gnunet-dht-put.1', | ||
22 | 'gnunet-dht-monitor.1', | ||
23 | 'gnunet-dht-hello.1', | ||
24 | 'gnunet-directory.1', | ||
25 | 'gnunet-dns2gns.1', | ||
26 | 'gnunet-datastore.1', | ||
27 | 'gnunet-download.1', | ||
28 | 'gnunet-did.1', | ||
29 | 'gnunet-ecc.1', | ||
30 | 'gnunet-fs.1', | ||
31 | 'gnunet-gns.1', | ||
32 | 'gnunet-gns-proxy.1', | ||
33 | 'gnunet-gns-proxy-setup-ca.1', | ||
34 | 'gnunet-identity.1', | ||
35 | 'gnunet-cadet.1', | ||
36 | 'gnunet-messenger.1', | ||
37 | 'gnunet-namecache.1', | ||
38 | 'gnunet-namestore.1', | ||
39 | 'gnunet-namestore-fcfsd.1', | ||
40 | 'gnunet-namestore-dbtool.1', | ||
41 | 'gnunet-namestore-zonefile.1', | ||
42 | 'gnunet-nat.1', | ||
43 | 'gnunet-nat-auto.1', | ||
44 | 'gnunet-nat-server.1', | ||
45 | 'gnunet-nse.1', | ||
46 | 'gnunet-peerinfo.1', | ||
47 | 'gnunet-publish.1', | ||
48 | 'gnunet-qr.1', | ||
49 | 'gnunet-reclaim.1', | ||
50 | 'gnunet-resolver.1', | ||
51 | 'gnunet-revocation.1', | ||
52 | 'gnunet-scalarproduct.1', | ||
53 | 'gnunet-scrypt.1', | ||
54 | 'gnunet-search.1', | ||
55 | 'gnunet-statistics.1', | ||
56 | 'gnunet-testbed-profiler.1', | ||
57 | 'gnunet-testing.1', | ||
58 | 'gnunet-testing-run-service.1', | ||
59 | 'gnunet-timeout.1', | ||
60 | 'gnunet-transport.1', | ||
61 | 'gnunet-transport-certificate-creation.1', | ||
62 | 'gnunet-unindex.1', | ||
63 | 'gnunet-uri.1', | ||
64 | 'gnunet-vpn.1', | ||
65 | 'gnunet-zoneimport.1']) | ||
66 | |||
diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 000000000..84b3cfde2 --- /dev/null +++ b/doc/meson.build | |||
@@ -0,0 +1,2 @@ | |||
1 | subdir('handbook') | ||
2 | subdir('man') | ||
diff --git a/meson-dist-script b/meson-dist-script new file mode 100644 index 000000000..dbc3e0ba8 --- /dev/null +++ b/meson-dist-script | |||
@@ -0,0 +1,35 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | # This is more portable than `which' but comes with | ||
6 | # the caveat of not(?) properly working on busybox's ash: | ||
7 | existence() | ||
8 | { | ||
9 | type "$1" >/dev/null 2>&1 | ||
10 | } | ||
11 | |||
12 | cd "${MESON_DIST_ROOT}" | ||
13 | echo "Updating handbook..." | ||
14 | if existence sphinx-build; then | ||
15 | cwd=$PWD | ||
16 | cd contrib/sphinx || exit 1 | ||
17 | if test -e _build; then | ||
18 | make clean | ||
19 | fi | ||
20 | # GNS | ||
21 | make html >/dev/null || exit 1 | ||
22 | if test -e ../../doc/handbook/html; then | ||
23 | rm -r ../../doc/handbook/html || exit 1 | ||
24 | fi | ||
25 | cp -r _build/html ../../doc/handbook/ || exit 1 | ||
26 | if test -e ../../doc/handbook/texinfo; then | ||
27 | rm -r ../../doc/handbook/texinfo || exit 1 | ||
28 | fi | ||
29 | make info >/dev/null || exit 1 | ||
30 | cp -r _build/texinfo ../../doc/handbook/ || exit 1 | ||
31 | cd $cwd | ||
32 | else | ||
33 | echo "ERROR: Sphinx not found! Unable to generate recent documentation." | ||
34 | exit 1 | ||
35 | fi | ||
diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..fe250f8a8 --- /dev/null +++ b/meson.build | |||
@@ -0,0 +1,374 @@ | |||
1 | ## EXPERIMENTAL --- WORK IN PROGRESS --- USE AT YOUR OWN PERIL --- ## | ||
2 | project('gnunet', 'c', license: 'AGPLv3', | ||
3 | version: run_command('sh', 'contrib/get_version.sh', check: true).stdout().strip()) | ||
4 | |||
5 | add_project_arguments('-D_GNU_SOURCE', language : 'c') | ||
6 | |||
7 | cc = meson.get_compiler('c') | ||
8 | incdir = include_directories('src/include') | ||
9 | cdata = configuration_data() | ||
10 | |||
11 | # Version | ||
12 | gnunet_version = run_command('sh', 'contrib/get_version.sh', check: true).stdout().strip() | ||
13 | cdata.set('gnunet_version', gnunet_version) | ||
14 | r = run_command('sh', 'contrib/get_version.sh', '--major', check: true) | ||
15 | cdata.set('gnunet_major_version', r.stdout().strip()) | ||
16 | r = run_command('sh', 'contrib/get_version.sh', '--minor', check: true) | ||
17 | cdata.set('gnunet_minor_version', r.stdout().strip()) | ||
18 | r = run_command('sh', 'contrib/get_version.sh', '--micro', check: true) | ||
19 | cdata.set('gnunet_micro_version', r.stdout().strip()) | ||
20 | |||
21 | pkgcfgdir = get_option('datadir')/'gnunet'/'config.d' | ||
22 | docdir = get_option('datadir')/'doc'/'gnunet' | ||
23 | |||
24 | install_emptydir(docdir) | ||
25 | install_data('README', 'COPYING', install_dir: docdir) | ||
26 | |||
27 | # TODO: Set to true to build a single libgnunet | ||
28 | if get_option('monolith') | ||
29 | add_project_arguments('-DHAVE_GNUNET_MONOLITH', language: 'c') | ||
30 | endif | ||
31 | cdata.set('enable_experimental', get_option('experimental')) | ||
32 | if get_option('experimental') | ||
33 | add_project_arguments('-DHAVE_EXPERIMENTAL', language: 'c') | ||
34 | endif | ||
35 | logging_opt = get_option('logging') | ||
36 | if logging_opt == 'yes' | ||
37 | add_project_arguments('-DGNUNET_EXTRA_LOGGING=0', language: 'c') | ||
38 | endif | ||
39 | if logging_opt == 'no' | ||
40 | add_project_arguments('-DGNUNET_EXTRA_LOGGING=0', language: 'c') | ||
41 | add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c') | ||
42 | endif | ||
43 | if logging_opt == 'verbose' | ||
44 | add_project_arguments('-DGNUNET_EXTRA_LOGGING=1', language: 'c') | ||
45 | endif | ||
46 | if logging_opt == 'veryverbose' | ||
47 | add_project_arguments('-DGNUNET_EXTRA_LOGGING=2', language: 'c') | ||
48 | endif | ||
49 | |||
50 | |||
51 | # FIXME | ||
52 | cdata.set('extractor', 0) | ||
53 | |||
54 | cdata.set('PKGDATADIRECTORY', get_option('datadir')/'gnunet') | ||
55 | cdata.set('SYSCONFDIR', get_option('sysconfdir')) | ||
56 | # Various checks | ||
57 | if cc.has_member ('struct sockaddr_in', 'sin_len', prefix : ['#include <sys/types.h>', '#include <sys/socket.h>', '#include <netinet/in.h>']) | ||
58 | add_project_arguments('-DHAVE_SOCKADDR_IN_SIN_LEN', language: 'c') | ||
59 | endif | ||
60 | if cc.has_member ('struct sockaddr_un', 'sun_len', prefix : ['#include <sys/types.h>', '#include <sys/socket.h>', '#include <sys/un.h>']) | ||
61 | add_project_arguments('-DHAVE_SOCKADDR_UN_SUN_LEN', language: 'c') | ||
62 | endif | ||
63 | if cc.has_member ('struct tm', 'tm_gmtoff', prefix : ['#include <time.h>']) | ||
64 | add_project_arguments('-DHAVE_TM_GMTOFF', language: 'c') | ||
65 | endif | ||
66 | |||
67 | # TODO: | ||
68 | # - Go through configure.ac and convert all defines/detections | ||
69 | # - Compile all libs into a single libgnunet | ||
70 | |||
71 | # Gettext | ||
72 | i18n = import('i18n') | ||
73 | |||
74 | gettext_package = 'gnunet' | ||
75 | add_project_arguments('-DGETTEXT_PACKAGE=' + gettext_package, language: 'c') | ||
76 | subdir('po') | ||
77 | |||
78 | # FIXME lots still missing | ||
79 | cdata.set_quoted('PACKAGE_VERSION', '0.21.0') | ||
80 | cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'en0') | ||
81 | cdata.set_quoted('VCS_VERSION', 'mesonbuild') | ||
82 | add_project_arguments('-DHAVE_CONFIG_H', language : 'c') | ||
83 | |||
84 | # Linker settings | ||
85 | # Compiler settings | ||
86 | add_project_arguments('-fno-strict-aliasing', language : 'c') | ||
87 | if cc.has_argument('-Wno-address-of-packed-member') | ||
88 | add_project_arguments('-Wno-address-of-packed-member', language : 'c') | ||
89 | endif | ||
90 | if cc.has_argument('-Wno-tautological-constant-out-of-range-compare') | ||
91 | add_project_arguments('-Wno-tautological-constant-out-of-range-compare', language : 'c') | ||
92 | endif | ||
93 | |||
94 | # FIXME static here, were dynamic in configure.ac | ||
95 | cdata.set('UNIXONLY', '#') | ||
96 | cdata.set('JAVAPORT', '#') | ||
97 | cdata.set('START_ON_DEMAND', 'YES') | ||
98 | |||
99 | |||
100 | cdata.set_quoted('build_target', host_machine.system()) | ||
101 | if host_machine.system() == 'linux' | ||
102 | add_project_arguments('-DLINUX', language : 'c') | ||
103 | add_project_link_arguments(['-Wl,--unresolved-symbols=report-all'], language : 'c') | ||
104 | cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'eth0') | ||
105 | endif | ||
106 | if host_machine.system() == 'darwin' | ||
107 | cdata.set_quoted('GNUNET_DEFAULT_INTERFACE', 'en0') | ||
108 | add_project_arguments('-DDARWIN', language : 'c') | ||
109 | add_project_arguments('-D_APPLE_C_SOURCE', language : 'c') | ||
110 | add_project_arguments('-D__APPLE_USE_RFC_3542', language : 'c') | ||
111 | add_project_arguments('-fno-common', language : 'c') | ||
112 | endif | ||
113 | |||
114 | |||
115 | # FIXME: Not all dependencies here yet | ||
116 | ltdl_dep = dependency ('libltdl', required: false) | ||
117 | if not ltdl_dep.found() | ||
118 | ltdl_dep = cc.find_library('ltdl', required : true) | ||
119 | endif | ||
120 | unistr_dep = dependency('libunistring', required : false) | ||
121 | if not unistr_dep.found() | ||
122 | unistr_dep = cc.find_library('unistring', required : true) | ||
123 | endif | ||
124 | sqlite_dep = dependency ('sqlite3', required : false) | ||
125 | if not sqlite_dep.found() | ||
126 | sqlite_dep = cc.find_library('sqlite3', required : true) | ||
127 | endif | ||
128 | curl_dep = dependency('libcurl', version: '>=7.85.0', required : false) | ||
129 | if not curl_dep.found() | ||
130 | curl_dep = cc.find_library('curl', required : true) | ||
131 | endif | ||
132 | zlib_dep = dependency('zlib', required : false) | ||
133 | if not zlib_dep.found() | ||
134 | zlib_dep = cc.find_library('zlib', required : true) | ||
135 | endif | ||
136 | mhd_dep = dependency('libmicrohttpd', required : false) | ||
137 | if not mhd_dep.found() | ||
138 | mhd_dep = cc.find_library('microhttpd', required : true) | ||
139 | endif | ||
140 | json_dep = dependency('jansson', required : false) | ||
141 | if not json_dep.found() | ||
142 | json_dep = cc.find_library('jansson', required : true) | ||
143 | endif | ||
144 | gcrypt_dep = dependency('libgcrypt', required : false) | ||
145 | if not gcrypt_dep.found() | ||
146 | gcrypt_dep = cc.find_library('gcrypt', required : true) | ||
147 | endif | ||
148 | gnutls_dep = dependency('libgnutls', required : false) | ||
149 | if not gnutls_dep.found() | ||
150 | gnutls_dep = cc.find_library('gnutls', required : false) | ||
151 | if not gnutls_dep.found() | ||
152 | gnutls_dep = cc.find_library('gnutls-dane', required : true) | ||
153 | endif | ||
154 | endif | ||
155 | sodium_dep = dependency('libsodium', required : false, version: '>=1.0.18') | ||
156 | if not sodium_dep.found() | ||
157 | sodium_dep = cc.find_library('sodium', required : true) | ||
158 | endif | ||
159 | |||
160 | idn_dep = dependency('libidn2', required : false) | ||
161 | if not idn_dep.found() | ||
162 | idn_dep = cc.find_library('idn2', required : false) | ||
163 | endif | ||
164 | if idn_dep.found() | ||
165 | add_project_arguments('-DHAVE_LIBIDN2', language : 'c') | ||
166 | add_project_arguments('-DHAVE_IDN2_H', language : 'c') | ||
167 | else | ||
168 | idn_dep = dependency('libidn', required : false) | ||
169 | if not idn_dep.found() | ||
170 | idn_dep = cc.find_library('idn', required : true) | ||
171 | add_project_arguments('-DHAVE_LIBIDN', language : 'c') | ||
172 | add_project_arguments('-DHAVE_IDN_H', language : 'c') | ||
173 | endif | ||
174 | endif | ||
175 | |||
176 | m_dep = cc.find_library('m', required : false) | ||
177 | if m_dep.found() | ||
178 | add_project_arguments('-DHAVE_LIBM', language : 'c') | ||
179 | endif | ||
180 | |||
181 | sock_dep = cc.find_library('socket', required : false) | ||
182 | if sock_dep.found() | ||
183 | add_project_arguments('-DHAVE_LIBSOCKET', language : 'c') | ||
184 | endif | ||
185 | |||
186 | gopt_bin = find_program('getopt', '/usr/bin/getopt', required : false) | ||
187 | if gopt_bin.found() | ||
188 | add_project_arguments('-DHAVE_GETOPT_BINARY='+gopt_bin.full_path(), language : 'c') | ||
189 | endif | ||
190 | |||
191 | pkgc_bin = find_program('pkg-config', '/usr/bin/pkg-config', required : false) | ||
192 | if pkgc_bin.found() | ||
193 | add_project_arguments('-DHAVE_PKG_CONFIG', language : 'c') | ||
194 | endif | ||
195 | |||
196 | ssh_bin = find_program('ssh', '/usr/bin/ssh', required : false) | ||
197 | if ssh_bin.found() | ||
198 | add_project_arguments('-DHAVE_SSH_BINARY', language : 'c') | ||
199 | endif | ||
200 | |||
201 | # FIXME we are not doing anything with this right now | ||
202 | sudo_bin = find_program('sudo', '/usr/bin/sudo', required : false) | ||
203 | doas_bin = find_program('doas', '/usr/bin/doas', required : false) | ||
204 | |||
205 | # Optional dependencies | ||
206 | |||
207 | pq_dep = dependency('libpq', required : false) | ||
208 | if not pq_dep.found() | ||
209 | pq_dep = cc.find_library('pq', required : false) | ||
210 | endif | ||
211 | if pq_dep.found() | ||
212 | add_project_arguments('-DHAVE_POSTGRESQL', language : 'c') | ||
213 | endif | ||
214 | zbar_dep = dependency('libzbar', required : false) | ||
215 | if not zbar_dep.found() | ||
216 | zbar_dep = cc.find_library('zbar', required : false) | ||
217 | endif | ||
218 | if zbar_dep.found() | ||
219 | add_project_arguments('-DHAVE_ZBAR', language : 'c') | ||
220 | endif | ||
221 | jose_dep = dependency('libjose', required : false) | ||
222 | if not jose_dep.found() | ||
223 | jose_dep = cc.find_library('jose', required : false) | ||
224 | endif | ||
225 | if jose_dep.found() | ||
226 | add_project_arguments('-DHAVE_JOSE', language : 'c') | ||
227 | endif | ||
228 | |||
229 | ## FIXME conversation: pulse/gst detection in configure.ac obviously | ||
230 | ## broken. Needs reconsideration. No idea for now. | ||
231 | pulse_dep = dependency('libpulse', required : false) | ||
232 | if not pulse_dep.found() | ||
233 | pulse_dep = cc.find_library('pulse', required : false) | ||
234 | endif | ||
235 | if pulse_dep.found() | ||
236 | add_project_arguments('-DHAVE_PULSE', language : 'c') | ||
237 | endif | ||
238 | |||
239 | opus_dep = dependency('libopus', required : false) | ||
240 | if not opus_dep.found() | ||
241 | opus_dep = cc.find_library('opus', required : false) | ||
242 | endif | ||
243 | if opus_dep.found() | ||
244 | add_project_arguments('-DHAVE_OPUS', language : 'c') | ||
245 | endif | ||
246 | |||
247 | ogg_dep = dependency('libogg', required : false) | ||
248 | if not ogg_dep.found() | ||
249 | ogg_dep = cc.find_library('ogg', required : false) | ||
250 | endif | ||
251 | if ogg_dep.found() | ||
252 | add_project_arguments('-DHAVE_OGG', language : 'c') | ||
253 | endif | ||
254 | |||
255 | if pulse_dep.found() or ogg_dep.found() or opus_dep.found() | ||
256 | gst_dep = dependency('libgst', required : false) | ||
257 | if not gst_dep.found() | ||
258 | gst_dep = cc.find_library('gstreamer', required : false) | ||
259 | endif | ||
260 | if gst_dep.found() | ||
261 | add_project_arguments('-DHAVE_GST', language : 'c') | ||
262 | endif | ||
263 | endif | ||
264 | ## END conversation | ||
265 | |||
266 | gnunetdeps = [mhd_dep, | ||
267 | sodium_dep, | ||
268 | gcrypt_dep, | ||
269 | curl_dep, | ||
270 | json_dep, | ||
271 | zlib_dep, | ||
272 | sqlite_dep, | ||
273 | unistr_dep, #dependency('libunistring'), | ||
274 | ltdl_dep, #dependency('ltdl'), | ||
275 | idn_dep] | ||
276 | |||
277 | add_project_arguments('-DNEED_LIBGCRYPT_VERSION="1.6.0"', language : 'c') | ||
278 | |||
279 | if cc.check_header('sys/time.h') | ||
280 | add_project_arguments('-DHAVE_SYS_TIME_H', language : 'c') | ||
281 | endif | ||
282 | if cc.check_header('sys/param.h') | ||
283 | add_project_arguments('-DHAVE_SYS_PARAM_H', language : 'c') | ||
284 | endif | ||
285 | |||
286 | # NSS | ||
287 | have_nss = false | ||
288 | if cc.check_header('nss.h') | ||
289 | have_nss = true | ||
290 | add_project_arguments('-DHAVE_GLIBCNSS', language : 'c') | ||
291 | endif | ||
292 | |||
293 | # TUN | ||
294 | tun_found = false | ||
295 | if cc.check_header('if_tun.h') | ||
296 | if cc.has_header_symbol('if_tun.h', 'struct in6_ifreq') | ||
297 | add_project_arguments('-DIF_TUN_HDR="if_tun.h"', language : 'c') | ||
298 | tun_found = true | ||
299 | endif | ||
300 | endif | ||
301 | if not tun_found and cc.check_header('linux/if_tun.h') | ||
302 | if cc.has_header_symbol('linux/if_tun.h', 'struct in6_ifreq') | ||
303 | add_project_arguments('-DIF_TUN_HDR="linux/if_tun.h"', language : 'c') | ||
304 | tun_found = true | ||
305 | endif | ||
306 | endif | ||
307 | if not tun_found and cc.check_header('net/if_tun.h') | ||
308 | if cc.has_header_symbol('net/if_tun.h', 'struct in6_ifreq') | ||
309 | add_project_arguments('-DIF_TUN_HDR="net/if_tun.h"', language : 'c') | ||
310 | tun_found = true | ||
311 | endif | ||
312 | endif | ||
313 | if not tun_found and cc.check_header('net/tun/if_tun.h') | ||
314 | if cc.has_header_symbol('net/tun/if_tun.h', 'struct in6_ifreq') | ||
315 | add_project_arguments('-DIF_TUN_HDR="net/tun/if_tun.h"', language : 'c') | ||
316 | tun_found = true | ||
317 | endif | ||
318 | endif | ||
319 | |||
320 | |||
321 | |||
322 | |||
323 | # NSS | ||
324 | if cc.check_header('nss.h') | ||
325 | add_project_arguments('-DHAVE_GLIBCNSS', language : 'c') | ||
326 | endif | ||
327 | |||
328 | # GNUTLS DANE | ||
329 | if cc.check_header('gnutls/dane.h') | ||
330 | if cc.has_function('dane_verify_crt_raw', | ||
331 | prefix: '#include <gnutls/dane.h>', | ||
332 | dependencies: gnutls_dep) | ||
333 | add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c') | ||
334 | endif | ||
335 | endif | ||
336 | curl_ssl_check ='''#include <curl/curl.h> | ||
337 | int main(int argc, char **argv) { | ||
338 | return (CURLSSLSET_OK != curl_global_sslset(CURLSSLBACKEND_GNUTLS, NULL, NULL)); | ||
339 | } | ||
340 | ''' | ||
341 | |||
342 | result = cc.run(curl_ssl_check, name : 'cURL gnutls check', | ||
343 | dependencies: curl_dep) | ||
344 | cdata.set('curl_gnutls', 0) | ||
345 | if result.returncode() == 0 | ||
346 | cdata.set('curl_gnutls', 1) | ||
347 | endif | ||
348 | |||
349 | if cc.has_function('getloadavg') == false | ||
350 | error('getloadadv missing') | ||
351 | endif | ||
352 | if cc.has_function('strnlen', prefix : '#include <string.h>') | ||
353 | cdata.set('HAVE_STRNLEN', 1) | ||
354 | endif | ||
355 | if cc.has_function('memset_s') | ||
356 | cdata.set('HAVE_MEMSET_S', 1) | ||
357 | endif | ||
358 | if cc.has_function('explicit_bzero') | ||
359 | cdata.set('HAVE_EXPLICIT_BZERO', 1) | ||
360 | endif | ||
361 | |||
362 | |||
363 | configure_file(#input: 'gnunet_private_config.h.in', | ||
364 | output : 'gnunet_private_config.h', | ||
365 | configuration : cdata) | ||
366 | configuration_inc = include_directories('.') | ||
367 | |||
368 | pkg = import('pkgconfig') | ||
369 | |||
370 | subdir('src') | ||
371 | subdir('doc') | ||
372 | subdir('contrib') | ||
373 | |||
374 | meson.add_dist_script('meson-dist-script') | ||
diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..9959aaedc --- /dev/null +++ b/meson.options | |||
@@ -0,0 +1,6 @@ | |||
1 | # Build options | ||
2 | option('monolith', type : 'boolean', value : false, description: 'Build a single, monolithic libgnunet shlib') | ||
3 | option('testbed', type : 'boolean', value : false, description: 'Build the testbed') | ||
4 | option('experimental', type : 'boolean', value : false, description: 'Build experimental components') | ||
5 | option('logging', type : 'string', value: 'yes', description: 'Log setting. Can be set to "yes" (logging, default), "no" (no logging), "verbose" (extra loggin"), veryverbose (even more logging)') | ||
6 | |||
diff --git a/meson_options.txt b/meson_options.txt new file mode 120000 index 000000000..7b28df279 --- /dev/null +++ b/meson_options.txt | |||
@@ -0,0 +1 @@ | |||
meson.options \ No newline at end of file | |||
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am index b00993d0f..eeb048fb8 100644 --- a/pkgconfig/Makefile.am +++ b/pkgconfig/Makefile.am | |||
@@ -16,10 +16,10 @@ pcfiles = \ | |||
16 | gnunetgns.pc \ | 16 | gnunetgns.pc \ |
17 | gnunethello.pc \ | 17 | gnunethello.pc \ |
18 | gnunetidentity.pc \ | 18 | gnunetidentity.pc \ |
19 | gnunetjson.pc \ | ||
19 | gnunetcadet.pc \ | 20 | gnunetcadet.pc \ |
20 | gnunetmessenger.pc \ | 21 | gnunetmessenger.pc \ |
21 | gnunetmicrophone.pc \ | 22 | gnunetmicrophone.pc \ |
22 | gnunetmysql.pc \ | ||
23 | gnunetnamestore.pc \ | 23 | gnunetnamestore.pc \ |
24 | gnunetnat.pc \ | 24 | gnunetnat.pc \ |
25 | gnunetnse.pc \ | 25 | gnunetnse.pc \ |
@@ -59,10 +59,10 @@ EXTRA_DIST = \ | |||
59 | gnunetgns.pc.in \ | 59 | gnunetgns.pc.in \ |
60 | gnunethello.pc.in \ | 60 | gnunethello.pc.in \ |
61 | gnunetidentity.pc.in \ | 61 | gnunetidentity.pc.in \ |
62 | gnunetjson.pc.in \ | ||
62 | gnunetcadet.pc.in \ | 63 | gnunetcadet.pc.in \ |
63 | gnunetmessenger.pc.in \ | 64 | gnunetmessenger.pc.in \ |
64 | gnunetmicrophone.pc.in \ | 65 | gnunetmicrophone.pc.in \ |
65 | gnunetmysql.pc.in \ | ||
66 | gnunetnamestore.pc.in \ | 66 | gnunetnamestore.pc.in \ |
67 | gnunetnat.pc.in \ | 67 | gnunetnat.pc.in \ |
68 | gnunetnse.pc.in \ | 68 | gnunetnse.pc.in \ |
diff --git a/pkgconfig/gnunetmysql.pc.in b/pkgconfig/gnunetjson.pc.in index a3d547f06..6dbf73b67 100644 --- a/pkgconfig/gnunetmysql.pc.in +++ b/pkgconfig/gnunetjson.pc.in | |||
@@ -3,10 +3,10 @@ exec_prefix=@exec_prefix@ | |||
3 | libdir=@libdir@ | 3 | libdir=@libdir@ |
4 | includedir=@includedir@ | 4 | includedir=@includedir@ |
5 | 5 | ||
6 | Name: GNUnet MySQL | 6 | Name: GNUnet JSON library |
7 | Description: Provides API for common interactions with libmysqlclient | 7 | Description: Library for JSON de/serialization |
8 | URL: http://gnunet.org | 8 | URL: http://gnunet.org |
9 | Version: @VERSION@ | 9 | Version: @VERSION@ |
10 | Requires: | 10 | Requires: |
11 | Libs: -L${libdir} -lgnunetmysql | 11 | Libs: -L${libdir} -lgnunetjson |
12 | Cflags: -I${includedir} | 12 | Cflags: -I${includedir} |
diff --git a/po/POTFILES.in b/po/POTFILES.in index 5730e94b9..3d6c2f6d1 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -89,7 +89,6 @@ src/datastore/datastore_api.c | |||
89 | src/datastore/gnunet-datastore.c | 89 | src/datastore/gnunet-datastore.c |
90 | src/datastore/gnunet-service-datastore.c | 90 | src/datastore/gnunet-service-datastore.c |
91 | src/datastore/plugin_datastore_heap.c | 91 | src/datastore/plugin_datastore_heap.c |
92 | src/datastore/plugin_datastore_mysql.c | ||
93 | src/datastore/plugin_datastore_postgres.c | 92 | src/datastore/plugin_datastore_postgres.c |
94 | src/datastore/plugin_datastore_sqlite.c | 93 | src/datastore/plugin_datastore_sqlite.c |
95 | src/datastore/plugin_datastore_template.c | 94 | src/datastore/plugin_datastore_template.c |
@@ -233,10 +232,6 @@ src/messenger/messenger_api_util.c | |||
233 | src/messenger/plugin_gnsrecord_messenger.c | 232 | src/messenger/plugin_gnsrecord_messenger.c |
234 | src/messenger/testing_messenger_barrier.c | 233 | src/messenger/testing_messenger_barrier.c |
235 | src/messenger/testing_messenger_setup.c | 234 | src/messenger/testing_messenger_setup.c |
236 | src/my/my.c | ||
237 | src/my/my_query_helper.c | ||
238 | src/my/my_result_helper.c | ||
239 | src/mysql/mysql.c | ||
240 | src/namecache/gnunet-namecache.c | 235 | src/namecache/gnunet-namecache.c |
241 | src/namecache/gnunet-service-namecache.c | 236 | src/namecache/gnunet-service-namecache.c |
242 | src/namecache/namecache_api.c | 237 | src/namecache/namecache_api.c |
@@ -433,7 +428,6 @@ src/testing/testing_api_cmd_barrier.c | |||
433 | src/testing/testing_api_cmd_barrier_reached.c | 428 | src/testing/testing_api_cmd_barrier_reached.c |
434 | src/testing/testing_api_cmd_batch.c | 429 | src/testing/testing_api_cmd_batch.c |
435 | src/testing/testing_api_cmd_block_until_external_trigger.c | 430 | src/testing/testing_api_cmd_block_until_external_trigger.c |
436 | src/testing/testing_api_cmd_end.c | ||
437 | src/testing/testing_api_cmd_finish.c | 431 | src/testing/testing_api_cmd_finish.c |
438 | src/testing/testing_api_cmd_local_test_prepared.c | 432 | src/testing/testing_api_cmd_local_test_prepared.c |
439 | src/testing/testing_api_cmd_netjail_start.c | 433 | src/testing/testing_api_cmd_netjail_start.c |
@@ -447,6 +441,7 @@ src/testing/testing_api_loop.c | |||
447 | src/testing/testing_api_traits.c | 441 | src/testing/testing_api_traits.c |
448 | src/topology/friends.c | 442 | src/topology/friends.c |
449 | src/topology/gnunet-daemon-topology.c | 443 | src/topology/gnunet-daemon-topology.c |
444 | src/transport/gnunet-communicator-quic.c | ||
450 | src/transport/gnunet-communicator-tcp.c | 445 | src/transport/gnunet-communicator-tcp.c |
451 | src/transport/gnunet-communicator-udp.c | 446 | src/transport/gnunet-communicator-udp.c |
452 | src/transport/gnunet-communicator-unix.c | 447 | src/transport/gnunet-communicator-unix.c |
@@ -595,5 +590,7 @@ src/vpn/vpn_api.c | |||
595 | src/zonemaster/gnunet-service-zonemaster.c | 590 | src/zonemaster/gnunet-service-zonemaster.c |
596 | src/fs/fs_api.h | 591 | src/fs/fs_api.h |
597 | src/include/gnunet_json_lib.h | 592 | src/include/gnunet_json_lib.h |
593 | src/include/gnunet_pq_lib.h | ||
594 | src/pq/pq.h | ||
598 | src/testbed/testbed_api.h | 595 | src/testbed/testbed_api.h |
599 | src/testbed/testbed_api_operations.h | 596 | src/testbed/testbed_api_operations.h |
@@ -10,7 +10,7 @@ msgid "" | |||
10 | msgstr "" | 10 | msgstr "" |
11 | "Project-Id-Version: gnunet 0.10.1\n" | 11 | "Project-Id-Version: gnunet 0.10.1\n" |
12 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 12 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
13 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 13 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
14 | "PO-Revision-Date: 2015-03-08 16:16+0100\n" | 14 | "PO-Revision-Date: 2015-03-08 16:16+0100\n" |
15 | "Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n" | 15 | "Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n" |
16 | "Language-Team: German <translation-team-de@lists.sourceforge.net>\n" | 16 | "Language-Team: German <translation-team-de@lists.sourceforge.net>\n" |
@@ -1558,7 +1558,7 @@ msgstr "" | |||
1558 | #: src/testbed/generate-underlay-topology.c:48 | 1558 | #: src/testbed/generate-underlay-topology.c:48 |
1559 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1559 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1560 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1560 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1561 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1561 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1562 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1562 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1563 | #, c-format | 1563 | #, c-format |
1564 | msgid "`%s' failed at %s:%d with error: %s\n" | 1564 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -3987,13 +3987,13 @@ msgid "Properly base32-encoded public key required" | |||
3987 | msgstr "# Bytes empfangen über TCP" | 3987 | msgstr "# Bytes empfangen über TCP" |
3988 | 3988 | ||
3989 | #: src/gns/gnunet-service-gns.c:554 | 3989 | #: src/gns/gnunet-service-gns.c:554 |
3990 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 3990 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
3991 | #, fuzzy | 3991 | #, fuzzy |
3992 | msgid "Failed to connect to the namecache!\n" | 3992 | msgid "Failed to connect to the namecache!\n" |
3993 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" | 3993 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" |
3994 | 3994 | ||
3995 | #: src/gns/gnunet-service-gns.c:573 | 3995 | #: src/gns/gnunet-service-gns.c:573 |
3996 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 3996 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
3997 | #, fuzzy | 3997 | #, fuzzy |
3998 | msgid "Could not connect to DHT!\n" | 3998 | msgid "Could not connect to DHT!\n" |
3999 | msgstr "Verbindung zu gnunetd konnte nicht hergestellt werden.\n" | 3999 | msgstr "Verbindung zu gnunetd konnte nicht hergestellt werden.\n" |
@@ -4586,63 +4586,63 @@ msgstr "Der Transportdienst auf Port %d konnte nicht gestartet werden.\n" | |||
4586 | msgid "Failed to create ego: %s\n" | 4586 | msgid "Failed to create ego: %s\n" |
4587 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" | 4587 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" |
4588 | 4588 | ||
4589 | #: src/identity/gnunet-identity.c:586 | 4589 | #: src/identity/gnunet-identity.c:540 |
4590 | msgid "create ego NAME" | 4590 | msgid "create ego NAME" |
4591 | msgstr "" | 4591 | msgstr "" |
4592 | 4592 | ||
4593 | #: src/identity/gnunet-identity.c:591 | 4593 | #: src/identity/gnunet-identity.c:545 |
4594 | msgid "delete ego NAME " | 4594 | msgid "delete ego NAME " |
4595 | msgstr "" | 4595 | msgstr "" |
4596 | 4596 | ||
4597 | #: src/identity/gnunet-identity.c:597 | 4597 | #: src/identity/gnunet-identity.c:551 |
4598 | msgid "" | 4598 | msgid "" |
4599 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4599 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4600 | msgstr "" | 4600 | msgstr "" |
4601 | 4601 | ||
4602 | #: src/identity/gnunet-identity.c:603 | 4602 | #: src/identity/gnunet-identity.c:557 |
4603 | msgid "" | 4603 | msgid "" |
4604 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4604 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4605 | "EGO)" | 4605 | "EGO)" |
4606 | msgstr "" | 4606 | msgstr "" |
4607 | 4607 | ||
4608 | #: src/identity/gnunet-identity.c:609 | 4608 | #: src/identity/gnunet-identity.c:563 |
4609 | msgid "" | 4609 | msgid "" |
4610 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4610 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4611 | "with -k RECIPIENT_PUBLIC_KEY)" | 4611 | "with -k RECIPIENT_PUBLIC_KEY)" |
4612 | msgstr "" | 4612 | msgstr "" |
4613 | 4613 | ||
4614 | #: src/identity/gnunet-identity.c:614 | 4614 | #: src/identity/gnunet-identity.c:568 |
4615 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4615 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4616 | msgstr "" | 4616 | msgstr "" |
4617 | 4617 | ||
4618 | #: src/identity/gnunet-identity.c:618 | 4618 | #: src/identity/gnunet-identity.c:572 |
4619 | msgid "display all egos" | 4619 | msgid "display all egos" |
4620 | msgstr "" | 4620 | msgstr "" |
4621 | 4621 | ||
4622 | #: src/identity/gnunet-identity.c:622 | 4622 | #: src/identity/gnunet-identity.c:576 |
4623 | #, fuzzy | 4623 | #, fuzzy |
4624 | msgid "reduce output" | 4624 | msgid "reduce output" |
4625 | msgstr "Ausführliche Ausgabe" | 4625 | msgstr "Ausführliche Ausgabe" |
4626 | 4626 | ||
4627 | #: src/identity/gnunet-identity.c:629 | 4627 | #: src/identity/gnunet-identity.c:583 |
4628 | msgid "" | 4628 | msgid "" |
4629 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4629 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4630 | "message for NAME (use together with -R)" | 4630 | "message for NAME (use together with -R)" |
4631 | msgstr "" | 4631 | msgstr "" |
4632 | 4632 | ||
4633 | #: src/identity/gnunet-identity.c:635 | 4633 | #: src/identity/gnunet-identity.c:589 |
4634 | msgid "The public key of the recipient (with -W)" | 4634 | msgid "The public key of the recipient (with -W)" |
4635 | msgstr "" | 4635 | msgstr "" |
4636 | 4636 | ||
4637 | #: src/identity/gnunet-identity.c:639 | 4637 | #: src/identity/gnunet-identity.c:593 |
4638 | msgid "run in monitor mode egos" | 4638 | msgid "run in monitor mode egos" |
4639 | msgstr "" | 4639 | msgstr "" |
4640 | 4640 | ||
4641 | #: src/identity/gnunet-identity.c:643 | 4641 | #: src/identity/gnunet-identity.c:597 |
4642 | msgid "display private keys as well" | 4642 | msgid "display private keys as well" |
4643 | msgstr "" | 4643 | msgstr "" |
4644 | 4644 | ||
4645 | #: src/identity/gnunet-identity.c:658 | 4645 | #: src/identity/gnunet-identity.c:612 |
4646 | msgid "Maintain egos" | 4646 | msgid "Maintain egos" |
4647 | msgstr "" | 4647 | msgstr "" |
4648 | 4648 | ||
@@ -6732,17 +6732,17 @@ msgid "" | |||
6732 | "free topology cannot be more than %u. Given `%s = %llu'" | 6732 | "free topology cannot be more than %u. Given `%s = %llu'" |
6733 | msgstr "" | 6733 | msgstr "" |
6734 | 6734 | ||
6735 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6735 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6736 | #, c-format | 6736 | #, c-format |
6737 | msgid "Topology file %s not found\n" | 6737 | msgid "Topology file %s not found\n" |
6738 | msgstr "" | 6738 | msgstr "" |
6739 | 6739 | ||
6740 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6740 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6741 | #, c-format | 6741 | #, c-format |
6742 | msgid "Topology file %s has no data\n" | 6742 | msgid "Topology file %s has no data\n" |
6743 | msgstr "" | 6743 | msgstr "" |
6744 | 6744 | ||
6745 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6745 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6746 | #, c-format | 6746 | #, c-format |
6747 | msgid "Topology file %s cannot be read\n" | 6747 | msgid "Topology file %s cannot be read\n" |
6748 | msgstr "" | 6748 | msgstr "" |
@@ -6942,18 +6942,23 @@ msgstr "# HELLO-Meldungen empfangen" | |||
6942 | msgid "GNUnet topology control" | 6942 | msgid "GNUnet topology control" |
6943 | msgstr "" | 6943 | msgstr "" |
6944 | 6944 | ||
6945 | #: src/transport/gnunet-communicator-tcp.c:3712 | 6945 | #: src/transport/gnunet-communicator-quic.c:1718 |
6946 | #: src/transport/gnunet-communicator-udp.c:3879 | 6946 | #: src/transport/gnunet-communicator-tcp.c:3737 |
6947 | #: src/transport/gnunet-service-tng.c:11393 | 6947 | #: src/transport/gnunet-communicator-udp.c:3363 |
6948 | #: src/transport/gnunet-service-tng.c:11503 | ||
6948 | #: src/transport/gnunet-service-transport.c:2617 | 6949 | #: src/transport/gnunet-service-transport.c:2617 |
6949 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 6950 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
6950 | msgstr "" | 6951 | msgstr "" |
6951 | 6952 | ||
6952 | #: src/transport/gnunet-communicator-tcp.c:4049 | 6953 | #: src/transport/gnunet-communicator-quic.c:1788 |
6954 | msgid "GNUnet QUIC communicator" | ||
6955 | msgstr "" | ||
6956 | |||
6957 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
6953 | msgid "GNUnet TCP communicator" | 6958 | msgid "GNUnet TCP communicator" |
6954 | msgstr "" | 6959 | msgstr "" |
6955 | 6960 | ||
6956 | #: src/transport/gnunet-communicator-udp.c:3954 | 6961 | #: src/transport/gnunet-communicator-udp.c:3438 |
6957 | msgid "GNUnet UDP communicator" | 6962 | msgid "GNUnet UDP communicator" |
6958 | msgstr "" | 6963 | msgstr "" |
6959 | 6964 | ||
@@ -7895,7 +7900,7 @@ msgstr "# defragmentierter Nachrichten" | |||
7895 | 7900 | ||
7896 | #: src/transport/plugin_transport_wlan.c:1195 | 7901 | #: src/transport/plugin_transport_wlan.c:1195 |
7897 | #: src/transport/plugin_transport_wlan.c:1287 | 7902 | #: src/transport/plugin_transport_wlan.c:1287 |
7898 | #: src/transport/plugin_transport_wlan.c:2325 | 7903 | #: src/transport/plugin_transport_wlan.c:2326 |
7899 | #, fuzzy | 7904 | #, fuzzy |
7900 | msgid "# MAC endpoints allocated" | 7905 | msgid "# MAC endpoints allocated" |
7901 | msgstr "# Sitzungsschlüssel akzeptiert" | 7906 | msgstr "# Sitzungsschlüssel akzeptiert" |
@@ -7919,17 +7924,17 @@ msgstr "# Bytes gesendet über TCP" | |||
7919 | msgid "# DATA messages received" | 7924 | msgid "# DATA messages received" |
7920 | msgstr "# verschlüsselter PONG Nachrichten empfangen" | 7925 | msgstr "# verschlüsselter PONG Nachrichten empfangen" |
7921 | 7926 | ||
7922 | #: src/transport/plugin_transport_wlan.c:1904 | 7927 | #: src/transport/plugin_transport_wlan.c:1905 |
7923 | #, fuzzy | 7928 | #, fuzzy |
7924 | msgid "# DATA messages processed" | 7929 | msgid "# DATA messages processed" |
7925 | msgstr "# PING Nachrichten erstellt" | 7930 | msgstr "# PING Nachrichten erstellt" |
7926 | 7931 | ||
7927 | #: src/transport/plugin_transport_wlan.c:2300 | 7932 | #: src/transport/plugin_transport_wlan.c:2301 |
7928 | #, c-format | 7933 | #, c-format |
7929 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 7934 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
7930 | msgstr "" | 7935 | msgstr "" |
7931 | 7936 | ||
7932 | #: src/transport/plugin_transport_wlan.c:2322 | 7937 | #: src/transport/plugin_transport_wlan.c:2323 |
7933 | #, fuzzy | 7938 | #, fuzzy |
7934 | msgid "# sessions allocated" | 7939 | msgid "# sessions allocated" |
7935 | msgstr "# Sitzungsschlüssel akzeptiert" | 7940 | msgstr "# Sitzungsschlüssel akzeptiert" |
@@ -8019,7 +8024,7 @@ msgstr "" | |||
8019 | msgid "Service process failed to report status\n" | 8024 | msgid "Service process failed to report status\n" |
8020 | msgstr "" | 8025 | msgstr "" |
8021 | 8026 | ||
8022 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 8027 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
8023 | #: src/util/service.c:1642 | 8028 | #: src/util/service.c:1642 |
8024 | #, fuzzy, c-format | 8029 | #, fuzzy, c-format |
8025 | msgid "Cannot obtain information about user `%s': %s\n" | 8030 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -8039,7 +8044,7 @@ msgid "do daemonize (detach from terminal)" | |||
8039 | msgstr "" | 8044 | msgstr "" |
8040 | 8045 | ||
8041 | #: src/transport/tcp_service_legacy.c:1397 | 8046 | #: src/transport/tcp_service_legacy.c:1397 |
8042 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 8047 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
8043 | #: src/util/service.c:2089 | 8048 | #: src/util/service.c:2089 |
8044 | #, fuzzy, c-format | 8049 | #, fuzzy, c-format |
8045 | msgid "Malformed configuration file `%s', exit ...\n" | 8050 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -8055,7 +8060,7 @@ msgstr "GNUnet Konfiguration" | |||
8055 | msgid "Could not access configuration file `%s'\n" | 8060 | msgid "Could not access configuration file `%s'\n" |
8056 | msgstr "Konfigurationsdatei `%s' konnte nicht geparst werden.\n" | 8061 | msgstr "Konfigurationsdatei `%s' konnte nicht geparst werden.\n" |
8057 | 8062 | ||
8058 | #: src/transport/transport_api2_communication.c:752 | 8063 | #: src/transport/transport_api2_communication.c:762 |
8059 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 8064 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
8060 | msgstr "" | 8065 | msgstr "" |
8061 | 8066 | ||
@@ -8185,74 +8190,22 @@ msgstr "" | |||
8185 | "Die Konfigurationsdatei muss in der Sektion `%s' unter `%s' ein Verzeichnis " | 8190 | "Die Konfigurationsdatei muss in der Sektion `%s' unter `%s' ein Verzeichnis " |
8186 | "angeben, in dem FS Daten gespeichert werden.\n" | 8191 | "angeben, in dem FS Daten gespeichert werden.\n" |
8187 | 8192 | ||
8188 | #: src/util/configuration.c:786 | 8193 | #: src/util/configuration.c:1073 |
8189 | #, c-format | ||
8190 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8191 | msgstr "" | ||
8192 | |||
8193 | #: src/util/configuration.c:796 | ||
8194 | #, c-format | ||
8195 | msgid "Bad directive in line %u\n" | ||
8196 | msgstr "" | ||
8197 | |||
8198 | #: src/util/configuration.c:852 | ||
8199 | #, c-format | ||
8200 | msgid "Bad inline-secret directive in line %u\n" | ||
8201 | msgstr "" | ||
8202 | |||
8203 | #: src/util/configuration.c:874 | ||
8204 | #, c-format | ||
8205 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8206 | msgstr "" | ||
8207 | |||
8208 | #: src/util/configuration.c:905 | ||
8209 | #, fuzzy, c-format | ||
8210 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8211 | msgstr "Syntaxfehler in Konfigurationsdatei `%s' in Zeile %d.\n" | ||
8212 | |||
8213 | #: src/util/configuration.c:955 | ||
8214 | #, fuzzy, c-format | ||
8215 | msgid "Syntax error while deserializing in line %u\n" | ||
8216 | msgstr "Syntaxfehler in Konfigurationsdatei `%s' in Zeile %d.\n" | ||
8217 | |||
8218 | #: src/util/configuration.c:1055 | ||
8219 | #, fuzzy, c-format | ||
8220 | msgid "Error while reading file `%s'\n" | ||
8221 | msgstr "Konfigurationsdatei `%s' konnte nicht geöffnet werden.\n" | ||
8222 | |||
8223 | #: src/util/configuration.c:1068 | ||
8224 | #, fuzzy, c-format | 8194 | #, fuzzy, c-format |
8225 | msgid "Failed to parse configuration file `%s'\n" | 8195 | msgid "Failed to parse configuration file `%s'\n" |
8226 | msgstr "Fehler beim Speichern der Konfigurationsdatei `%s':" | 8196 | msgstr "Fehler beim Speichern der Konfigurationsdatei `%s':" |
8227 | 8197 | ||
8228 | #: src/util/configuration.c:1701 | 8198 | #: src/util/configuration.c:1718 |
8229 | msgid "Not a valid relative time specification" | 8199 | msgid "Not a valid relative time specification" |
8230 | msgstr "" | 8200 | msgstr "" |
8231 | 8201 | ||
8232 | #: src/util/configuration.c:1771 | 8202 | #: src/util/configuration.c:1788 |
8233 | #, c-format | 8203 | #, c-format |
8234 | msgid "" | 8204 | msgid "" |
8235 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8205 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
8236 | "choices\n" | 8206 | "choices\n" |
8237 | msgstr "" | 8207 | msgstr "" |
8238 | 8208 | ||
8239 | #: src/util/configuration.c:1866 | ||
8240 | #, c-format | ||
8241 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8242 | msgstr "" | ||
8243 | |||
8244 | #: src/util/configuration.c:1898 | ||
8245 | #, c-format | ||
8246 | msgid "Missing closing `%s' in option `%s'\n" | ||
8247 | msgstr "" | ||
8248 | |||
8249 | #: src/util/configuration.c:1964 | ||
8250 | #, c-format | ||
8251 | msgid "" | ||
8252 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8253 | "as an environmental variable\n" | ||
8254 | msgstr "" | ||
8255 | |||
8256 | #: src/util/configuration_helper.c:134 | 8209 | #: src/util/configuration_helper.c:134 |
8257 | #, c-format | 8210 | #, c-format |
8258 | msgid "The following sections are available:\n" | 8211 | msgid "The following sections are available:\n" |
@@ -8280,12 +8233,12 @@ msgid "" | |||
8280 | "%llu)\n" | 8233 | "%llu)\n" |
8281 | msgstr "" | 8234 | msgstr "" |
8282 | 8235 | ||
8283 | #: src/util/crypto_ecc.c:567 | 8236 | #: src/util/crypto_ecc.c:554 |
8284 | #, fuzzy, c-format | 8237 | #, fuzzy, c-format |
8285 | msgid "ECC signing failed at %s:%d: %s\n" | 8238 | msgid "ECC signing failed at %s:%d: %s\n" |
8286 | msgstr "`%s' schlug fehl bei %s:%d mit dem Fehler: `%s'.\n" | 8239 | msgstr "`%s' schlug fehl bei %s:%d mit dem Fehler: `%s'.\n" |
8287 | 8240 | ||
8288 | #: src/util/crypto_ecc.c:689 | 8241 | #: src/util/crypto_ecc.c:677 |
8289 | #, fuzzy, c-format | 8242 | #, fuzzy, c-format |
8290 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8243 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8291 | msgstr "RSA Signaturüberprüfung fehlgeschlagen bei %s:%d: %s\n" | 8244 | msgstr "RSA Signaturüberprüfung fehlgeschlagen bei %s:%d: %s\n" |
@@ -8311,7 +8264,7 @@ msgstr "`%s' schlug fehl bei %s:%d mit dem Fehler: `%s'.\n" | |||
8311 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8264 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8312 | msgstr "RSA Signaturüberprüfung fehlgeschlagen bei %s:%d: %s\n" | 8265 | msgstr "RSA Signaturüberprüfung fehlgeschlagen bei %s:%d: %s\n" |
8313 | 8266 | ||
8314 | #: src/util/disk.c:842 | 8267 | #: src/util/disk.c:843 |
8315 | #, fuzzy, c-format | 8268 | #, fuzzy, c-format |
8316 | msgid "Expected `%s' to be a directory!\n" | 8269 | msgid "Expected `%s' to be a directory!\n" |
8317 | msgstr "`%s' erwartet, dass `%s' ein Verzeichnis ist!\n" | 8270 | msgstr "`%s' erwartet, dass `%s' ein Verzeichnis ist!\n" |
@@ -9276,11 +9229,24 @@ msgstr "Tunnel über VPN einrichten." | |||
9276 | msgid "Failed to replicate block in namecache: %s\n" | 9229 | msgid "Failed to replicate block in namecache: %s\n" |
9277 | msgstr "" | 9230 | msgstr "" |
9278 | 9231 | ||
9279 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9232 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9280 | #, fuzzy | 9233 | #, fuzzy |
9281 | msgid "Failed to connect to the namestore!\n" | 9234 | msgid "Failed to connect to the namestore!\n" |
9282 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" | 9235 | msgstr "Es konnte keine Verbindung mit gnunetd hergestellt werden.\n" |
9283 | 9236 | ||
9237 | #, fuzzy, c-format | ||
9238 | #~ msgid "" | ||
9239 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9240 | #~ msgstr "Syntaxfehler in Konfigurationsdatei `%s' in Zeile %d.\n" | ||
9241 | |||
9242 | #, fuzzy, c-format | ||
9243 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9244 | #~ msgstr "Syntaxfehler in Konfigurationsdatei `%s' in Zeile %d.\n" | ||
9245 | |||
9246 | #, fuzzy, c-format | ||
9247 | #~ msgid "Error while reading file `%s'\n" | ||
9248 | #~ msgstr "Konfigurationsdatei `%s' konnte nicht geöffnet werden.\n" | ||
9249 | |||
9284 | #~ msgid "Postgres database running\n" | 9250 | #~ msgid "Postgres database running\n" |
9285 | #~ msgstr "PostgreSQL-Datenbank läuft\n" | 9251 | #~ msgstr "PostgreSQL-Datenbank läuft\n" |
9286 | 9252 | ||
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.9.5a\n" | 9 | "Project-Id-Version: gnunet 0.9.5a\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 11 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
12 | "PO-Revision-Date: 2013-02-23 17:50+0100\n" | 12 | "PO-Revision-Date: 2013-02-23 17:50+0100\n" |
13 | "Last-Translator: Miguel Ãngel Arruga Vivas <rosen644835@gmail.com>\n" | 13 | "Last-Translator: Miguel Ãngel Arruga Vivas <rosen644835@gmail.com>\n" |
14 | "Language-Team: Spanish <es@li.org>\n" | 14 | "Language-Team: Spanish <es@li.org>\n" |
@@ -1626,7 +1626,7 @@ msgstr "Caché de datos de montÃculo (heap) ejecutándose\n" | |||
1626 | #: src/testbed/generate-underlay-topology.c:48 | 1626 | #: src/testbed/generate-underlay-topology.c:48 |
1627 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1627 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1628 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1628 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1629 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1629 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1630 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1630 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1631 | #, c-format | 1631 | #, c-format |
1632 | msgid "`%s' failed at %s:%d with error: %s\n" | 1632 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -4109,13 +4109,13 @@ msgid "Properly base32-encoded public key required" | |||
4109 | msgstr "Tipo requerido\n" | 4109 | msgstr "Tipo requerido\n" |
4110 | 4110 | ||
4111 | #: src/gns/gnunet-service-gns.c:554 | 4111 | #: src/gns/gnunet-service-gns.c:554 |
4112 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 4112 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
4113 | #, fuzzy | 4113 | #, fuzzy |
4114 | msgid "Failed to connect to the namecache!\n" | 4114 | msgid "Failed to connect to the namecache!\n" |
4115 | msgstr "¡Se produjo un fallo al conectar con el almacén de nombres!\n" | 4115 | msgstr "¡Se produjo un fallo al conectar con el almacén de nombres!\n" |
4116 | 4116 | ||
4117 | #: src/gns/gnunet-service-gns.c:573 | 4117 | #: src/gns/gnunet-service-gns.c:573 |
4118 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 4118 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
4119 | msgid "Could not connect to DHT!\n" | 4119 | msgid "Could not connect to DHT!\n" |
4120 | msgstr "¡No se pudo conectar a la DHT!\n" | 4120 | msgstr "¡No se pudo conectar a la DHT!\n" |
4121 | 4121 | ||
@@ -4740,68 +4740,68 @@ msgstr "" | |||
4740 | msgid "Failed to create ego: %s\n" | 4740 | msgid "Failed to create ego: %s\n" |
4741 | msgstr "Se produjo un fallo al crear la página para «%s»\n" | 4741 | msgstr "Se produjo un fallo al crear la página para «%s»\n" |
4742 | 4742 | ||
4743 | #: src/identity/gnunet-identity.c:586 | 4743 | #: src/identity/gnunet-identity.c:540 |
4744 | msgid "create ego NAME" | 4744 | msgid "create ego NAME" |
4745 | msgstr "" | 4745 | msgstr "" |
4746 | 4746 | ||
4747 | #: src/identity/gnunet-identity.c:591 | 4747 | #: src/identity/gnunet-identity.c:545 |
4748 | #, fuzzy | 4748 | #, fuzzy |
4749 | msgid "delete ego NAME " | 4749 | msgid "delete ego NAME " |
4750 | msgstr "borrar un nombre de espacio de nombres (NAME)" | 4750 | msgstr "borrar un nombre de espacio de nombres (NAME)" |
4751 | 4751 | ||
4752 | #: src/identity/gnunet-identity.c:597 | 4752 | #: src/identity/gnunet-identity.c:551 |
4753 | msgid "" | 4753 | msgid "" |
4754 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4754 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4755 | msgstr "" | 4755 | msgstr "" |
4756 | 4756 | ||
4757 | #: src/identity/gnunet-identity.c:603 | 4757 | #: src/identity/gnunet-identity.c:557 |
4758 | msgid "" | 4758 | msgid "" |
4759 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4759 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4760 | "EGO)" | 4760 | "EGO)" |
4761 | msgstr "" | 4761 | msgstr "" |
4762 | 4762 | ||
4763 | #: src/identity/gnunet-identity.c:609 | 4763 | #: src/identity/gnunet-identity.c:563 |
4764 | msgid "" | 4764 | msgid "" |
4765 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4765 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4766 | "with -k RECIPIENT_PUBLIC_KEY)" | 4766 | "with -k RECIPIENT_PUBLIC_KEY)" |
4767 | msgstr "" | 4767 | msgstr "" |
4768 | 4768 | ||
4769 | #: src/identity/gnunet-identity.c:614 | 4769 | #: src/identity/gnunet-identity.c:568 |
4770 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4770 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4771 | msgstr "" | 4771 | msgstr "" |
4772 | 4772 | ||
4773 | #: src/identity/gnunet-identity.c:618 | 4773 | #: src/identity/gnunet-identity.c:572 |
4774 | #, fuzzy | 4774 | #, fuzzy |
4775 | msgid "display all egos" | 4775 | msgid "display all egos" |
4776 | msgstr "mostrar registros" | 4776 | msgstr "mostrar registros" |
4777 | 4777 | ||
4778 | #: src/identity/gnunet-identity.c:622 | 4778 | #: src/identity/gnunet-identity.c:576 |
4779 | #, fuzzy | 4779 | #, fuzzy |
4780 | msgid "reduce output" | 4780 | msgid "reduce output" |
4781 | msgstr "Sin salida innecesaria" | 4781 | msgstr "Sin salida innecesaria" |
4782 | 4782 | ||
4783 | #: src/identity/gnunet-identity.c:629 | 4783 | #: src/identity/gnunet-identity.c:583 |
4784 | msgid "" | 4784 | msgid "" |
4785 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4785 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4786 | "message for NAME (use together with -R)" | 4786 | "message for NAME (use together with -R)" |
4787 | msgstr "" | 4787 | msgstr "" |
4788 | 4788 | ||
4789 | #: src/identity/gnunet-identity.c:635 | 4789 | #: src/identity/gnunet-identity.c:589 |
4790 | msgid "The public key of the recipient (with -W)" | 4790 | msgid "The public key of the recipient (with -W)" |
4791 | msgstr "" | 4791 | msgstr "" |
4792 | 4792 | ||
4793 | # Miguel: Aquà he dejado monitorización porque esto es | 4793 | # Miguel: Aquà he dejado monitorización porque esto es |
4794 | # del servicio de traducción de direcciones. | 4794 | # del servicio de traducción de direcciones. |
4795 | #: src/identity/gnunet-identity.c:639 | 4795 | #: src/identity/gnunet-identity.c:593 |
4796 | #, fuzzy | 4796 | #, fuzzy |
4797 | msgid "run in monitor mode egos" | 4797 | msgid "run in monitor mode egos" |
4798 | msgstr "modo de monitorización" | 4798 | msgstr "modo de monitorización" |
4799 | 4799 | ||
4800 | #: src/identity/gnunet-identity.c:643 | 4800 | #: src/identity/gnunet-identity.c:597 |
4801 | msgid "display private keys as well" | 4801 | msgid "display private keys as well" |
4802 | msgstr "" | 4802 | msgstr "" |
4803 | 4803 | ||
4804 | #: src/identity/gnunet-identity.c:658 | 4804 | #: src/identity/gnunet-identity.c:612 |
4805 | msgid "Maintain egos" | 4805 | msgid "Maintain egos" |
4806 | msgstr "" | 4806 | msgstr "" |
4807 | 4807 | ||
@@ -6942,17 +6942,17 @@ msgid "" | |||
6942 | "free topology cannot be more than %u. Given `%s = %llu'" | 6942 | "free topology cannot be more than %u. Given `%s = %llu'" |
6943 | msgstr "" | 6943 | msgstr "" |
6944 | 6944 | ||
6945 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6945 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6946 | #, c-format | 6946 | #, c-format |
6947 | msgid "Topology file %s not found\n" | 6947 | msgid "Topology file %s not found\n" |
6948 | msgstr "El fichero de topologÃa %s no fue encontrado\n" | 6948 | msgstr "El fichero de topologÃa %s no fue encontrado\n" |
6949 | 6949 | ||
6950 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6950 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6951 | #, c-format | 6951 | #, c-format |
6952 | msgid "Topology file %s has no data\n" | 6952 | msgid "Topology file %s has no data\n" |
6953 | msgstr "El fichero de topologÃa %s no tiene datos\n" | 6953 | msgstr "El fichero de topologÃa %s no tiene datos\n" |
6954 | 6954 | ||
6955 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6955 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6956 | #, c-format | 6956 | #, c-format |
6957 | msgid "Topology file %s cannot be read\n" | 6957 | msgid "Topology file %s cannot be read\n" |
6958 | msgstr "El fichero de topologÃa %s no puede ser leido\n" | 6958 | msgstr "El fichero de topologÃa %s no puede ser leido\n" |
@@ -7179,9 +7179,10 @@ msgstr "# mensajes «HELLO» recibidos" | |||
7179 | msgid "GNUnet topology control" | 7179 | msgid "GNUnet topology control" |
7180 | msgstr "" | 7180 | msgstr "" |
7181 | 7181 | ||
7182 | #: src/transport/gnunet-communicator-tcp.c:3712 | 7182 | #: src/transport/gnunet-communicator-quic.c:1718 |
7183 | #: src/transport/gnunet-communicator-udp.c:3879 | 7183 | #: src/transport/gnunet-communicator-tcp.c:3737 |
7184 | #: src/transport/gnunet-service-tng.c:11393 | 7184 | #: src/transport/gnunet-communicator-udp.c:3363 |
7185 | #: src/transport/gnunet-service-tng.c:11503 | ||
7185 | #: src/transport/gnunet-service-transport.c:2617 | 7186 | #: src/transport/gnunet-service-transport.c:2617 |
7186 | #, fuzzy | 7187 | #, fuzzy |
7187 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 7188 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
@@ -7189,12 +7190,17 @@ msgstr "" | |||
7189 | "El servicio de transporte carece de opciones de configuración de clave. " | 7190 | "El servicio de transporte carece de opciones de configuración de clave. " |
7190 | "Saliendo.\n" | 7191 | "Saliendo.\n" |
7191 | 7192 | ||
7192 | #: src/transport/gnunet-communicator-tcp.c:4049 | 7193 | #: src/transport/gnunet-communicator-quic.c:1788 |
7194 | #, fuzzy | ||
7195 | msgid "GNUnet QUIC communicator" | ||
7196 | msgstr "Configurador Gtk de GNUnet" | ||
7197 | |||
7198 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
7193 | #, fuzzy | 7199 | #, fuzzy |
7194 | msgid "GNUnet TCP communicator" | 7200 | msgid "GNUnet TCP communicator" |
7195 | msgstr "Configurador Gtk de GNUnet" | 7201 | msgstr "Configurador Gtk de GNUnet" |
7196 | 7202 | ||
7197 | #: src/transport/gnunet-communicator-udp.c:3954 | 7203 | #: src/transport/gnunet-communicator-udp.c:3438 |
7198 | #, fuzzy | 7204 | #, fuzzy |
7199 | msgid "GNUnet UDP communicator" | 7205 | msgid "GNUnet UDP communicator" |
7200 | msgstr "Configurador Gtk de GNUnet" | 7206 | msgstr "Configurador Gtk de GNUnet" |
@@ -8192,7 +8198,7 @@ msgstr "# mensajes WLAN pendientes (con fragmentación)" | |||
8192 | 8198 | ||
8193 | #: src/transport/plugin_transport_wlan.c:1195 | 8199 | #: src/transport/plugin_transport_wlan.c:1195 |
8194 | #: src/transport/plugin_transport_wlan.c:1287 | 8200 | #: src/transport/plugin_transport_wlan.c:1287 |
8195 | #: src/transport/plugin_transport_wlan.c:2325 | 8201 | #: src/transport/plugin_transport_wlan.c:2326 |
8196 | #, fuzzy | 8202 | #, fuzzy |
8197 | msgid "# MAC endpoints allocated" | 8203 | msgid "# MAC endpoints allocated" |
8198 | msgstr "# MAC de destino WLAN alojadas" | 8204 | msgstr "# MAC de destino WLAN alojadas" |
@@ -8217,19 +8223,19 @@ msgstr "# «beacons HELLO» enviados vÃa WLAN" | |||
8217 | msgid "# DATA messages received" | 8223 | msgid "# DATA messages received" |
8218 | msgstr "# Mensajes «GAP PUT» recibidos" | 8224 | msgstr "# Mensajes «GAP PUT» recibidos" |
8219 | 8225 | ||
8220 | #: src/transport/plugin_transport_wlan.c:1904 | 8226 | #: src/transport/plugin_transport_wlan.c:1905 |
8221 | #, fuzzy | 8227 | #, fuzzy |
8222 | msgid "# DATA messages processed" | 8228 | msgid "# DATA messages processed" |
8223 | msgstr "# mensajes «DATA» WLAN procesados" | 8229 | msgstr "# mensajes «DATA» WLAN procesados" |
8224 | 8230 | ||
8225 | #: src/transport/plugin_transport_wlan.c:2300 | 8231 | #: src/transport/plugin_transport_wlan.c:2301 |
8226 | #, c-format | 8232 | #, c-format |
8227 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 8233 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
8228 | msgstr "" | 8234 | msgstr "" |
8229 | "El ejecutable auxiliar «%s» no tiene activado el bit SUID, no se puede " | 8235 | "El ejecutable auxiliar «%s» no tiene activado el bit SUID, no se puede " |
8230 | "ejecutar el transporte WLAN\n" | 8236 | "ejecutar el transporte WLAN\n" |
8231 | 8237 | ||
8232 | #: src/transport/plugin_transport_wlan.c:2322 | 8238 | #: src/transport/plugin_transport_wlan.c:2323 |
8233 | #, fuzzy | 8239 | #, fuzzy |
8234 | msgid "# sessions allocated" | 8240 | msgid "# sessions allocated" |
8235 | msgstr "# sesiones WLAN alojadas" | 8241 | msgstr "# sesiones WLAN alojadas" |
@@ -8324,7 +8330,7 @@ msgstr "" | |||
8324 | msgid "Service process failed to report status\n" | 8330 | msgid "Service process failed to report status\n" |
8325 | msgstr "El proceso del servicio no devolvió un estado\n" | 8331 | msgstr "El proceso del servicio no devolvió un estado\n" |
8326 | 8332 | ||
8327 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 8333 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
8328 | #: src/util/service.c:1642 | 8334 | #: src/util/service.c:1642 |
8329 | #, c-format | 8335 | #, c-format |
8330 | msgid "Cannot obtain information about user `%s': %s\n" | 8336 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -8344,7 +8350,7 @@ msgid "do daemonize (detach from terminal)" | |||
8344 | msgstr "demonizar (desasociar del terminal)" | 8350 | msgstr "demonizar (desasociar del terminal)" |
8345 | 8351 | ||
8346 | #: src/transport/tcp_service_legacy.c:1397 | 8352 | #: src/transport/tcp_service_legacy.c:1397 |
8347 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 8353 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
8348 | #: src/util/service.c:2089 | 8354 | #: src/util/service.c:2089 |
8349 | #, fuzzy, c-format | 8355 | #, fuzzy, c-format |
8350 | msgid "Malformed configuration file `%s', exit ...\n" | 8356 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -8360,7 +8366,7 @@ msgstr "Se produjo un fallo al borrar el fichero de configuración %s\n" | |||
8360 | msgid "Could not access configuration file `%s'\n" | 8366 | msgid "Could not access configuration file `%s'\n" |
8361 | msgstr "No se pudo acceder al fichero de configuración «%s»\n" | 8367 | msgstr "No se pudo acceder al fichero de configuración «%s»\n" |
8362 | 8368 | ||
8363 | #: src/transport/transport_api2_communication.c:752 | 8369 | #: src/transport/transport_api2_communication.c:762 |
8364 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 8370 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
8365 | msgstr "" | 8371 | msgstr "" |
8366 | 8372 | ||
@@ -8488,52 +8494,17 @@ msgstr "" | |||
8488 | "La configuración especifica un valor no válido en la opción «%s» de la " | 8494 | "La configuración especifica un valor no válido en la opción «%s» de la " |
8489 | "sección «%s»: %s\n" | 8495 | "sección «%s»: %s\n" |
8490 | 8496 | ||
8491 | #: src/util/configuration.c:786 | 8497 | #: src/util/configuration.c:1073 |
8492 | #, c-format | ||
8493 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8494 | msgstr "" | ||
8495 | |||
8496 | #: src/util/configuration.c:796 | ||
8497 | #, c-format | ||
8498 | msgid "Bad directive in line %u\n" | ||
8499 | msgstr "" | ||
8500 | |||
8501 | #: src/util/configuration.c:852 | ||
8502 | #, c-format | ||
8503 | msgid "Bad inline-secret directive in line %u\n" | ||
8504 | msgstr "" | ||
8505 | |||
8506 | #: src/util/configuration.c:874 | ||
8507 | #, c-format | ||
8508 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8509 | msgstr "" | ||
8510 | |||
8511 | #: src/util/configuration.c:905 | ||
8512 | #, fuzzy, c-format | ||
8513 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8514 | msgstr "Error de sintaxis en la lÃnea %u mientras se deserializaba\n" | ||
8515 | |||
8516 | #: src/util/configuration.c:955 | ||
8517 | #, c-format | ||
8518 | msgid "Syntax error while deserializing in line %u\n" | ||
8519 | msgstr "Error de sintaxis en la lÃnea %u mientras se deserializaba\n" | ||
8520 | |||
8521 | #: src/util/configuration.c:1055 | ||
8522 | #, fuzzy, c-format | ||
8523 | msgid "Error while reading file `%s'\n" | ||
8524 | msgstr "Error decodificando clave %u\n" | ||
8525 | |||
8526 | #: src/util/configuration.c:1068 | ||
8527 | #, fuzzy, c-format | 8498 | #, fuzzy, c-format |
8528 | msgid "Failed to parse configuration file `%s'\n" | 8499 | msgid "Failed to parse configuration file `%s'\n" |
8529 | msgstr "Se produjo un fallo al borrar el fichero de configuración %s\n" | 8500 | msgstr "Se produjo un fallo al borrar el fichero de configuración %s\n" |
8530 | 8501 | ||
8531 | #: src/util/configuration.c:1701 | 8502 | #: src/util/configuration.c:1718 |
8532 | #, fuzzy | 8503 | #, fuzzy |
8533 | msgid "Not a valid relative time specification" | 8504 | msgid "Not a valid relative time specification" |
8534 | msgstr "Tiempo de expiración no válido para la operación «%s»\n" | 8505 | msgstr "Tiempo de expiración no válido para la operación «%s»\n" |
8535 | 8506 | ||
8536 | #: src/util/configuration.c:1771 | 8507 | #: src/util/configuration.c:1788 |
8537 | #, c-format | 8508 | #, c-format |
8538 | msgid "" | 8509 | msgid "" |
8539 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8510 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
@@ -8542,23 +8513,6 @@ msgstr "" | |||
8542 | "El valor de configuración «%s» para «%s» de la sección «%s» no está dentro " | 8513 | "El valor de configuración «%s» para «%s» de la sección «%s» no está dentro " |
8543 | "de las opciones legales\n" | 8514 | "de las opciones legales\n" |
8544 | 8515 | ||
8545 | #: src/util/configuration.c:1866 | ||
8546 | #, c-format | ||
8547 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8548 | msgstr "" | ||
8549 | |||
8550 | #: src/util/configuration.c:1898 | ||
8551 | #, fuzzy, c-format | ||
8552 | msgid "Missing closing `%s' in option `%s'\n" | ||
8553 | msgstr "Falta la opción «%s» para la operación «%s»\n" | ||
8554 | |||
8555 | #: src/util/configuration.c:1964 | ||
8556 | #, c-format | ||
8557 | msgid "" | ||
8558 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8559 | "as an environmental variable\n" | ||
8560 | msgstr "" | ||
8561 | |||
8562 | #: src/util/configuration_helper.c:134 | 8516 | #: src/util/configuration_helper.c:134 |
8563 | #, c-format | 8517 | #, c-format |
8564 | msgid "The following sections are available:\n" | 8518 | msgid "The following sections are available:\n" |
@@ -8588,12 +8542,12 @@ msgstr "" | |||
8588 | "El tamaño del fichero en disco es incorrecto para este «Bloom " | 8542 | "El tamaño del fichero en disco es incorrecto para este «Bloom " |
8589 | "filter» (esperado %llu, tiene %llu)\n" | 8543 | "filter» (esperado %llu, tiene %llu)\n" |
8590 | 8544 | ||
8591 | #: src/util/crypto_ecc.c:567 | 8545 | #: src/util/crypto_ecc.c:554 |
8592 | #, c-format | 8546 | #, c-format |
8593 | msgid "ECC signing failed at %s:%d: %s\n" | 8547 | msgid "ECC signing failed at %s:%d: %s\n" |
8594 | msgstr "El firmado ECC falló en %s:%d: %s\n" | 8548 | msgstr "El firmado ECC falló en %s:%d: %s\n" |
8595 | 8549 | ||
8596 | #: src/util/crypto_ecc.c:689 | 8550 | #: src/util/crypto_ecc.c:677 |
8597 | #, fuzzy, c-format | 8551 | #, fuzzy, c-format |
8598 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8552 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8599 | msgstr "La verificación de la firma RSA fallo en %s:%d: %s\n" | 8553 | msgstr "La verificación de la firma RSA fallo en %s:%d: %s\n" |
@@ -8618,7 +8572,7 @@ msgstr "El firmado ECC falló en %s:%d: %s\n" | |||
8618 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8572 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8619 | msgstr "La verificación de la firma RSA fallo en %s:%d: %s\n" | 8573 | msgstr "La verificación de la firma RSA fallo en %s:%d: %s\n" |
8620 | 8574 | ||
8621 | #: src/util/disk.c:842 | 8575 | #: src/util/disk.c:843 |
8622 | #, c-format | 8576 | #, c-format |
8623 | msgid "Expected `%s' to be a directory!\n" | 8577 | msgid "Expected `%s' to be a directory!\n" |
8624 | msgstr "¡Se esperaba que «%s» fuera un directorio!\n" | 8578 | msgstr "¡Se esperaba que «%s» fuera un directorio!\n" |
@@ -9609,10 +9563,27 @@ msgstr "Configurar túneles vÃa VPN." | |||
9609 | msgid "Failed to replicate block in namecache: %s\n" | 9563 | msgid "Failed to replicate block in namecache: %s\n" |
9610 | msgstr "Se produjo un fallo al crear el espacio de nombres «%s»\n" | 9564 | msgstr "Se produjo un fallo al crear el espacio de nombres «%s»\n" |
9611 | 9565 | ||
9612 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9566 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9613 | msgid "Failed to connect to the namestore!\n" | 9567 | msgid "Failed to connect to the namestore!\n" |
9614 | msgstr "¡Se produjo un fallo al conectar con el almacén de nombres!\n" | 9568 | msgstr "¡Se produjo un fallo al conectar con el almacén de nombres!\n" |
9615 | 9569 | ||
9570 | #, fuzzy, c-format | ||
9571 | #~ msgid "" | ||
9572 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9573 | #~ msgstr "Error de sintaxis en la lÃnea %u mientras se deserializaba\n" | ||
9574 | |||
9575 | #, c-format | ||
9576 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9577 | #~ msgstr "Error de sintaxis en la lÃnea %u mientras se deserializaba\n" | ||
9578 | |||
9579 | #, fuzzy, c-format | ||
9580 | #~ msgid "Error while reading file `%s'\n" | ||
9581 | #~ msgstr "Error decodificando clave %u\n" | ||
9582 | |||
9583 | #, fuzzy, c-format | ||
9584 | #~ msgid "Missing closing `%s' in option `%s'\n" | ||
9585 | #~ msgstr "Falta la opción «%s» para la operación «%s»\n" | ||
9586 | |||
9616 | #~ msgid "Postgres database running\n" | 9587 | #~ msgid "Postgres database running\n" |
9617 | #~ msgstr "Base de datos Postgres ejecutándose\n" | 9588 | #~ msgstr "Base de datos Postgres ejecutándose\n" |
9618 | 9589 | ||
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: gnunet 0.10.1\n" | 8 | "Project-Id-Version: gnunet 0.10.1\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 10 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
11 | "PO-Revision-Date: 2021-11-21 00:53+0100\n" | 11 | "PO-Revision-Date: 2021-11-21 00:53+0100\n" |
12 | "Last-Translator: Stéphane Aulery <lkppo@free.fr>\n" | 12 | "Last-Translator: Stéphane Aulery <lkppo@free.fr>\n" |
13 | "Language-Team: French <traduc@traduc.org>\n" | 13 | "Language-Team: French <traduc@traduc.org>\n" |
@@ -1510,7 +1510,7 @@ msgstr "" | |||
1510 | #: src/testbed/generate-underlay-topology.c:48 | 1510 | #: src/testbed/generate-underlay-topology.c:48 |
1511 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1511 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1512 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1512 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1513 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1513 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1514 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1514 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1515 | #, c-format | 1515 | #, c-format |
1516 | msgid "`%s' failed at %s:%d with error: %s\n" | 1516 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -3819,12 +3819,12 @@ msgid "Properly base32-encoded public key required" | |||
3819 | msgstr "" | 3819 | msgstr "" |
3820 | 3820 | ||
3821 | #: src/gns/gnunet-service-gns.c:554 | 3821 | #: src/gns/gnunet-service-gns.c:554 |
3822 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 3822 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
3823 | msgid "Failed to connect to the namecache!\n" | 3823 | msgid "Failed to connect to the namecache!\n" |
3824 | msgstr "" | 3824 | msgstr "" |
3825 | 3825 | ||
3826 | #: src/gns/gnunet-service-gns.c:573 | 3826 | #: src/gns/gnunet-service-gns.c:573 |
3827 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 3827 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
3828 | msgid "Could not connect to DHT!\n" | 3828 | msgid "Could not connect to DHT!\n" |
3829 | msgstr "" | 3829 | msgstr "" |
3830 | 3830 | ||
@@ -4400,63 +4400,63 @@ msgstr "" | |||
4400 | msgid "Failed to create ego: %s\n" | 4400 | msgid "Failed to create ego: %s\n" |
4401 | msgstr "" | 4401 | msgstr "" |
4402 | 4402 | ||
4403 | #: src/identity/gnunet-identity.c:586 | 4403 | #: src/identity/gnunet-identity.c:540 |
4404 | msgid "create ego NAME" | 4404 | msgid "create ego NAME" |
4405 | msgstr "" | 4405 | msgstr "" |
4406 | 4406 | ||
4407 | #: src/identity/gnunet-identity.c:591 | 4407 | #: src/identity/gnunet-identity.c:545 |
4408 | msgid "delete ego NAME " | 4408 | msgid "delete ego NAME " |
4409 | msgstr "" | 4409 | msgstr "" |
4410 | 4410 | ||
4411 | #: src/identity/gnunet-identity.c:597 | 4411 | #: src/identity/gnunet-identity.c:551 |
4412 | msgid "" | 4412 | msgid "" |
4413 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4413 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4414 | msgstr "" | 4414 | msgstr "" |
4415 | 4415 | ||
4416 | #: src/identity/gnunet-identity.c:603 | 4416 | #: src/identity/gnunet-identity.c:557 |
4417 | msgid "" | 4417 | msgid "" |
4418 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4418 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4419 | "EGO)" | 4419 | "EGO)" |
4420 | msgstr "" | 4420 | msgstr "" |
4421 | 4421 | ||
4422 | #: src/identity/gnunet-identity.c:609 | 4422 | #: src/identity/gnunet-identity.c:563 |
4423 | msgid "" | 4423 | msgid "" |
4424 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4424 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4425 | "with -k RECIPIENT_PUBLIC_KEY)" | 4425 | "with -k RECIPIENT_PUBLIC_KEY)" |
4426 | msgstr "" | 4426 | msgstr "" |
4427 | 4427 | ||
4428 | #: src/identity/gnunet-identity.c:614 | 4428 | #: src/identity/gnunet-identity.c:568 |
4429 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4429 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4430 | msgstr "" | 4430 | msgstr "" |
4431 | 4431 | ||
4432 | #: src/identity/gnunet-identity.c:618 | 4432 | #: src/identity/gnunet-identity.c:572 |
4433 | msgid "display all egos" | 4433 | msgid "display all egos" |
4434 | msgstr "" | 4434 | msgstr "" |
4435 | 4435 | ||
4436 | #: src/identity/gnunet-identity.c:622 | 4436 | #: src/identity/gnunet-identity.c:576 |
4437 | #, fuzzy | 4437 | #, fuzzy |
4438 | msgid "reduce output" | 4438 | msgid "reduce output" |
4439 | msgstr "sortie verbeuse" | 4439 | msgstr "sortie verbeuse" |
4440 | 4440 | ||
4441 | #: src/identity/gnunet-identity.c:629 | 4441 | #: src/identity/gnunet-identity.c:583 |
4442 | msgid "" | 4442 | msgid "" |
4443 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4443 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4444 | "message for NAME (use together with -R)" | 4444 | "message for NAME (use together with -R)" |
4445 | msgstr "" | 4445 | msgstr "" |
4446 | 4446 | ||
4447 | #: src/identity/gnunet-identity.c:635 | 4447 | #: src/identity/gnunet-identity.c:589 |
4448 | msgid "The public key of the recipient (with -W)" | 4448 | msgid "The public key of the recipient (with -W)" |
4449 | msgstr "" | 4449 | msgstr "" |
4450 | 4450 | ||
4451 | #: src/identity/gnunet-identity.c:639 | 4451 | #: src/identity/gnunet-identity.c:593 |
4452 | msgid "run in monitor mode egos" | 4452 | msgid "run in monitor mode egos" |
4453 | msgstr "" | 4453 | msgstr "" |
4454 | 4454 | ||
4455 | #: src/identity/gnunet-identity.c:643 | 4455 | #: src/identity/gnunet-identity.c:597 |
4456 | msgid "display private keys as well" | 4456 | msgid "display private keys as well" |
4457 | msgstr "" | 4457 | msgstr "" |
4458 | 4458 | ||
4459 | #: src/identity/gnunet-identity.c:658 | 4459 | #: src/identity/gnunet-identity.c:612 |
4460 | msgid "Maintain egos" | 4460 | msgid "Maintain egos" |
4461 | msgstr "" | 4461 | msgstr "" |
4462 | 4462 | ||
@@ -6484,17 +6484,17 @@ msgid "" | |||
6484 | "free topology cannot be more than %u. Given `%s = %llu'" | 6484 | "free topology cannot be more than %u. Given `%s = %llu'" |
6485 | msgstr "" | 6485 | msgstr "" |
6486 | 6486 | ||
6487 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6487 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6488 | #, c-format | 6488 | #, c-format |
6489 | msgid "Topology file %s not found\n" | 6489 | msgid "Topology file %s not found\n" |
6490 | msgstr "" | 6490 | msgstr "" |
6491 | 6491 | ||
6492 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6492 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6493 | #, c-format | 6493 | #, c-format |
6494 | msgid "Topology file %s has no data\n" | 6494 | msgid "Topology file %s has no data\n" |
6495 | msgstr "" | 6495 | msgstr "" |
6496 | 6496 | ||
6497 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6497 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6498 | #, c-format | 6498 | #, c-format |
6499 | msgid "Topology file %s cannot be read\n" | 6499 | msgid "Topology file %s cannot be read\n" |
6500 | msgstr "" | 6500 | msgstr "" |
@@ -6690,18 +6690,23 @@ msgstr "" | |||
6690 | msgid "GNUnet topology control" | 6690 | msgid "GNUnet topology control" |
6691 | msgstr "" | 6691 | msgstr "" |
6692 | 6692 | ||
6693 | #: src/transport/gnunet-communicator-tcp.c:3712 | 6693 | #: src/transport/gnunet-communicator-quic.c:1718 |
6694 | #: src/transport/gnunet-communicator-udp.c:3879 | 6694 | #: src/transport/gnunet-communicator-tcp.c:3737 |
6695 | #: src/transport/gnunet-service-tng.c:11393 | 6695 | #: src/transport/gnunet-communicator-udp.c:3363 |
6696 | #: src/transport/gnunet-service-tng.c:11503 | ||
6696 | #: src/transport/gnunet-service-transport.c:2617 | 6697 | #: src/transport/gnunet-service-transport.c:2617 |
6697 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 6698 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
6698 | msgstr "" | 6699 | msgstr "" |
6699 | 6700 | ||
6700 | #: src/transport/gnunet-communicator-tcp.c:4049 | 6701 | #: src/transport/gnunet-communicator-quic.c:1788 |
6702 | msgid "GNUnet QUIC communicator" | ||
6703 | msgstr "" | ||
6704 | |||
6705 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
6701 | msgid "GNUnet TCP communicator" | 6706 | msgid "GNUnet TCP communicator" |
6702 | msgstr "" | 6707 | msgstr "" |
6703 | 6708 | ||
6704 | #: src/transport/gnunet-communicator-udp.c:3954 | 6709 | #: src/transport/gnunet-communicator-udp.c:3438 |
6705 | msgid "GNUnet UDP communicator" | 6710 | msgid "GNUnet UDP communicator" |
6706 | msgstr "" | 6711 | msgstr "" |
6707 | 6712 | ||
@@ -7604,7 +7609,7 @@ msgstr "" | |||
7604 | 7609 | ||
7605 | #: src/transport/plugin_transport_wlan.c:1195 | 7610 | #: src/transport/plugin_transport_wlan.c:1195 |
7606 | #: src/transport/plugin_transport_wlan.c:1287 | 7611 | #: src/transport/plugin_transport_wlan.c:1287 |
7607 | #: src/transport/plugin_transport_wlan.c:2325 | 7612 | #: src/transport/plugin_transport_wlan.c:2326 |
7608 | msgid "# MAC endpoints allocated" | 7613 | msgid "# MAC endpoints allocated" |
7609 | msgstr "" | 7614 | msgstr "" |
7610 | 7615 | ||
@@ -7624,16 +7629,16 @@ msgstr "" | |||
7624 | msgid "# DATA messages received" | 7629 | msgid "# DATA messages received" |
7625 | msgstr "" | 7630 | msgstr "" |
7626 | 7631 | ||
7627 | #: src/transport/plugin_transport_wlan.c:1904 | 7632 | #: src/transport/plugin_transport_wlan.c:1905 |
7628 | msgid "# DATA messages processed" | 7633 | msgid "# DATA messages processed" |
7629 | msgstr "" | 7634 | msgstr "" |
7630 | 7635 | ||
7631 | #: src/transport/plugin_transport_wlan.c:2300 | 7636 | #: src/transport/plugin_transport_wlan.c:2301 |
7632 | #, c-format | 7637 | #, c-format |
7633 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 7638 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
7634 | msgstr "" | 7639 | msgstr "" |
7635 | 7640 | ||
7636 | #: src/transport/plugin_transport_wlan.c:2322 | 7641 | #: src/transport/plugin_transport_wlan.c:2323 |
7637 | #, fuzzy | 7642 | #, fuzzy |
7638 | msgid "# sessions allocated" | 7643 | msgid "# sessions allocated" |
7639 | msgstr "# Session TCP active" | 7644 | msgstr "# Session TCP active" |
@@ -7723,7 +7728,7 @@ msgstr "" | |||
7723 | msgid "Service process failed to report status\n" | 7728 | msgid "Service process failed to report status\n" |
7724 | msgstr "" | 7729 | msgstr "" |
7725 | 7730 | ||
7726 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 7731 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
7727 | #: src/util/service.c:1642 | 7732 | #: src/util/service.c:1642 |
7728 | #, c-format | 7733 | #, c-format |
7729 | msgid "Cannot obtain information about user `%s': %s\n" | 7734 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -7743,7 +7748,7 @@ msgid "do daemonize (detach from terminal)" | |||
7743 | msgstr "" | 7748 | msgstr "" |
7744 | 7749 | ||
7745 | #: src/transport/tcp_service_legacy.c:1397 | 7750 | #: src/transport/tcp_service_legacy.c:1397 |
7746 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 7751 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
7747 | #: src/util/service.c:2089 | 7752 | #: src/util/service.c:2089 |
7748 | #, c-format | 7753 | #, c-format |
7749 | msgid "Malformed configuration file `%s', exit ...\n" | 7754 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -7758,7 +7763,7 @@ msgstr "" | |||
7758 | msgid "Could not access configuration file `%s'\n" | 7763 | msgid "Could not access configuration file `%s'\n" |
7759 | msgstr "" | 7764 | msgstr "" |
7760 | 7765 | ||
7761 | #: src/transport/transport_api2_communication.c:752 | 7766 | #: src/transport/transport_api2_communication.c:762 |
7762 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 7767 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
7763 | msgstr "" | 7768 | msgstr "" |
7764 | 7769 | ||
@@ -7884,74 +7889,22 @@ msgid "" | |||
7884 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" | 7889 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" |
7885 | msgstr "" | 7890 | msgstr "" |
7886 | 7891 | ||
7887 | #: src/util/configuration.c:786 | 7892 | #: src/util/configuration.c:1073 |
7888 | #, c-format | ||
7889 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
7890 | msgstr "" | ||
7891 | |||
7892 | #: src/util/configuration.c:796 | ||
7893 | #, c-format | ||
7894 | msgid "Bad directive in line %u\n" | ||
7895 | msgstr "" | ||
7896 | |||
7897 | #: src/util/configuration.c:852 | ||
7898 | #, c-format | ||
7899 | msgid "Bad inline-secret directive in line %u\n" | ||
7900 | msgstr "" | ||
7901 | |||
7902 | #: src/util/configuration.c:874 | ||
7903 | #, c-format | ||
7904 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
7905 | msgstr "" | ||
7906 | |||
7907 | #: src/util/configuration.c:905 | ||
7908 | #, c-format | ||
7909 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
7910 | msgstr "" | ||
7911 | |||
7912 | #: src/util/configuration.c:955 | ||
7913 | #, c-format | ||
7914 | msgid "Syntax error while deserializing in line %u\n" | ||
7915 | msgstr "" | ||
7916 | |||
7917 | #: src/util/configuration.c:1055 | ||
7918 | #, fuzzy, c-format | ||
7919 | msgid "Error while reading file `%s'\n" | ||
7920 | msgstr "Erreur de lecture : « %s » : %s" | ||
7921 | |||
7922 | #: src/util/configuration.c:1068 | ||
7923 | #, fuzzy, c-format | 7893 | #, fuzzy, c-format |
7924 | msgid "Failed to parse configuration file `%s'\n" | 7894 | msgid "Failed to parse configuration file `%s'\n" |
7925 | msgstr "Résolution de « %s » échouée\n" | 7895 | msgstr "Résolution de « %s » échouée\n" |
7926 | 7896 | ||
7927 | #: src/util/configuration.c:1701 | 7897 | #: src/util/configuration.c:1718 |
7928 | msgid "Not a valid relative time specification" | 7898 | msgid "Not a valid relative time specification" |
7929 | msgstr "" | 7899 | msgstr "" |
7930 | 7900 | ||
7931 | #: src/util/configuration.c:1771 | 7901 | #: src/util/configuration.c:1788 |
7932 | #, c-format | 7902 | #, c-format |
7933 | msgid "" | 7903 | msgid "" |
7934 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 7904 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
7935 | "choices\n" | 7905 | "choices\n" |
7936 | msgstr "" | 7906 | msgstr "" |
7937 | 7907 | ||
7938 | #: src/util/configuration.c:1866 | ||
7939 | #, c-format | ||
7940 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
7941 | msgstr "" | ||
7942 | |||
7943 | #: src/util/configuration.c:1898 | ||
7944 | #, c-format | ||
7945 | msgid "Missing closing `%s' in option `%s'\n" | ||
7946 | msgstr "" | ||
7947 | |||
7948 | #: src/util/configuration.c:1964 | ||
7949 | #, c-format | ||
7950 | msgid "" | ||
7951 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
7952 | "as an environmental variable\n" | ||
7953 | msgstr "" | ||
7954 | |||
7955 | #: src/util/configuration_helper.c:134 | 7908 | #: src/util/configuration_helper.c:134 |
7956 | #, c-format | 7909 | #, c-format |
7957 | msgid "The following sections are available:\n" | 7910 | msgid "The following sections are available:\n" |
@@ -7979,12 +7932,12 @@ msgid "" | |||
7979 | "%llu)\n" | 7932 | "%llu)\n" |
7980 | msgstr "" | 7933 | msgstr "" |
7981 | 7934 | ||
7982 | #: src/util/crypto_ecc.c:567 | 7935 | #: src/util/crypto_ecc.c:554 |
7983 | #, c-format | 7936 | #, c-format |
7984 | msgid "ECC signing failed at %s:%d: %s\n" | 7937 | msgid "ECC signing failed at %s:%d: %s\n" |
7985 | msgstr "" | 7938 | msgstr "" |
7986 | 7939 | ||
7987 | #: src/util/crypto_ecc.c:689 | 7940 | #: src/util/crypto_ecc.c:677 |
7988 | #, c-format | 7941 | #, c-format |
7989 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 7942 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
7990 | msgstr "" | 7943 | msgstr "" |
@@ -8008,7 +7961,7 @@ msgstr "" | |||
8008 | msgid "RSA signature verification failed at %s:%d: %s\n" | 7961 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8009 | msgstr "" | 7962 | msgstr "" |
8010 | 7963 | ||
8011 | #: src/util/disk.c:842 | 7964 | #: src/util/disk.c:843 |
8012 | #, c-format | 7965 | #, c-format |
8013 | msgid "Expected `%s' to be a directory!\n" | 7966 | msgid "Expected `%s' to be a directory!\n" |
8014 | msgstr "" | 7967 | msgstr "" |
@@ -8948,11 +8901,15 @@ msgstr "Configurer des tunnels via VPN." | |||
8948 | msgid "Failed to replicate block in namecache: %s\n" | 8901 | msgid "Failed to replicate block in namecache: %s\n" |
8949 | msgstr "" | 8902 | msgstr "" |
8950 | 8903 | ||
8951 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 8904 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
8952 | msgid "Failed to connect to the namestore!\n" | 8905 | msgid "Failed to connect to the namestore!\n" |
8953 | msgstr "" | 8906 | msgstr "" |
8954 | 8907 | ||
8955 | #, fuzzy, c-format | 8908 | #, fuzzy, c-format |
8909 | #~ msgid "Error while reading file `%s'\n" | ||
8910 | #~ msgstr "Erreur de lecture : « %s » : %s" | ||
8911 | |||
8912 | #, fuzzy, c-format | ||
8956 | #~ msgid "Failed to drop database with: `%s'\n" | 8913 | #~ msgid "Failed to drop database with: `%s'\n" |
8957 | #~ msgstr "Échec du démarrage de %s\n" | 8914 | #~ msgstr "Échec du démarrage de %s\n" |
8958 | 8915 | ||
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.10.1\n" | 9 | "Project-Id-Version: gnunet 0.10.1\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 11 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
12 | "PO-Revision-Date: 2019-10-16 11:00+0200\n" | 12 | "PO-Revision-Date: 2019-10-16 11:00+0200\n" |
13 | "Last-Translator: Sebastiano Pistore <sebastianopistore.info@protonmail.ch>\n" | 13 | "Last-Translator: Sebastiano Pistore <sebastianopistore.info@protonmail.ch>\n" |
14 | "Language-Team: Italian <tp@lists.linux.it>\n" | 14 | "Language-Team: Italian <tp@lists.linux.it>\n" |
@@ -1516,7 +1516,7 @@ msgstr "" | |||
1516 | #: src/testbed/generate-underlay-topology.c:48 | 1516 | #: src/testbed/generate-underlay-topology.c:48 |
1517 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1517 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1518 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1518 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1519 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1519 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1520 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1520 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1521 | #, c-format | 1521 | #, c-format |
1522 | msgid "`%s' failed at %s:%d with error: %s\n" | 1522 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -3843,12 +3843,12 @@ msgid "Properly base32-encoded public key required" | |||
3843 | msgstr "# messaggi PONG ricevuti" | 3843 | msgstr "# messaggi PONG ricevuti" |
3844 | 3844 | ||
3845 | #: src/gns/gnunet-service-gns.c:554 | 3845 | #: src/gns/gnunet-service-gns.c:554 |
3846 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 3846 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
3847 | msgid "Failed to connect to the namecache!\n" | 3847 | msgid "Failed to connect to the namecache!\n" |
3848 | msgstr "" | 3848 | msgstr "" |
3849 | 3849 | ||
3850 | #: src/gns/gnunet-service-gns.c:573 | 3850 | #: src/gns/gnunet-service-gns.c:573 |
3851 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 3851 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
3852 | msgid "Could not connect to DHT!\n" | 3852 | msgid "Could not connect to DHT!\n" |
3853 | msgstr "" | 3853 | msgstr "" |
3854 | 3854 | ||
@@ -4426,62 +4426,62 @@ msgstr "" | |||
4426 | msgid "Failed to create ego: %s\n" | 4426 | msgid "Failed to create ego: %s\n" |
4427 | msgstr "" | 4427 | msgstr "" |
4428 | 4428 | ||
4429 | #: src/identity/gnunet-identity.c:586 | 4429 | #: src/identity/gnunet-identity.c:540 |
4430 | msgid "create ego NAME" | 4430 | msgid "create ego NAME" |
4431 | msgstr "" | 4431 | msgstr "" |
4432 | 4432 | ||
4433 | #: src/identity/gnunet-identity.c:591 | 4433 | #: src/identity/gnunet-identity.c:545 |
4434 | msgid "delete ego NAME " | 4434 | msgid "delete ego NAME " |
4435 | msgstr "" | 4435 | msgstr "" |
4436 | 4436 | ||
4437 | #: src/identity/gnunet-identity.c:597 | 4437 | #: src/identity/gnunet-identity.c:551 |
4438 | msgid "" | 4438 | msgid "" |
4439 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4439 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4440 | msgstr "" | 4440 | msgstr "" |
4441 | 4441 | ||
4442 | #: src/identity/gnunet-identity.c:603 | 4442 | #: src/identity/gnunet-identity.c:557 |
4443 | msgid "" | 4443 | msgid "" |
4444 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4444 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4445 | "EGO)" | 4445 | "EGO)" |
4446 | msgstr "" | 4446 | msgstr "" |
4447 | 4447 | ||
4448 | #: src/identity/gnunet-identity.c:609 | 4448 | #: src/identity/gnunet-identity.c:563 |
4449 | msgid "" | 4449 | msgid "" |
4450 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4450 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4451 | "with -k RECIPIENT_PUBLIC_KEY)" | 4451 | "with -k RECIPIENT_PUBLIC_KEY)" |
4452 | msgstr "" | 4452 | msgstr "" |
4453 | 4453 | ||
4454 | #: src/identity/gnunet-identity.c:614 | 4454 | #: src/identity/gnunet-identity.c:568 |
4455 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4455 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4456 | msgstr "" | 4456 | msgstr "" |
4457 | 4457 | ||
4458 | #: src/identity/gnunet-identity.c:618 | 4458 | #: src/identity/gnunet-identity.c:572 |
4459 | msgid "display all egos" | 4459 | msgid "display all egos" |
4460 | msgstr "" | 4460 | msgstr "" |
4461 | 4461 | ||
4462 | #: src/identity/gnunet-identity.c:622 | 4462 | #: src/identity/gnunet-identity.c:576 |
4463 | msgid "reduce output" | 4463 | msgid "reduce output" |
4464 | msgstr "" | 4464 | msgstr "" |
4465 | 4465 | ||
4466 | #: src/identity/gnunet-identity.c:629 | 4466 | #: src/identity/gnunet-identity.c:583 |
4467 | msgid "" | 4467 | msgid "" |
4468 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4468 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4469 | "message for NAME (use together with -R)" | 4469 | "message for NAME (use together with -R)" |
4470 | msgstr "" | 4470 | msgstr "" |
4471 | 4471 | ||
4472 | #: src/identity/gnunet-identity.c:635 | 4472 | #: src/identity/gnunet-identity.c:589 |
4473 | msgid "The public key of the recipient (with -W)" | 4473 | msgid "The public key of the recipient (with -W)" |
4474 | msgstr "" | 4474 | msgstr "" |
4475 | 4475 | ||
4476 | #: src/identity/gnunet-identity.c:639 | 4476 | #: src/identity/gnunet-identity.c:593 |
4477 | msgid "run in monitor mode egos" | 4477 | msgid "run in monitor mode egos" |
4478 | msgstr "" | 4478 | msgstr "" |
4479 | 4479 | ||
4480 | #: src/identity/gnunet-identity.c:643 | 4480 | #: src/identity/gnunet-identity.c:597 |
4481 | msgid "display private keys as well" | 4481 | msgid "display private keys as well" |
4482 | msgstr "" | 4482 | msgstr "" |
4483 | 4483 | ||
4484 | #: src/identity/gnunet-identity.c:658 | 4484 | #: src/identity/gnunet-identity.c:612 |
4485 | msgid "Maintain egos" | 4485 | msgid "Maintain egos" |
4486 | msgstr "" | 4486 | msgstr "" |
4487 | 4487 | ||
@@ -6513,17 +6513,17 @@ msgid "" | |||
6513 | "free topology cannot be more than %u. Given `%s = %llu'" | 6513 | "free topology cannot be more than %u. Given `%s = %llu'" |
6514 | msgstr "" | 6514 | msgstr "" |
6515 | 6515 | ||
6516 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6516 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6517 | #, c-format | 6517 | #, c-format |
6518 | msgid "Topology file %s not found\n" | 6518 | msgid "Topology file %s not found\n" |
6519 | msgstr "" | 6519 | msgstr "" |
6520 | 6520 | ||
6521 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6521 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6522 | #, c-format | 6522 | #, c-format |
6523 | msgid "Topology file %s has no data\n" | 6523 | msgid "Topology file %s has no data\n" |
6524 | msgstr "" | 6524 | msgstr "" |
6525 | 6525 | ||
6526 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6526 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6527 | #, c-format | 6527 | #, c-format |
6528 | msgid "Topology file %s cannot be read\n" | 6528 | msgid "Topology file %s cannot be read\n" |
6529 | msgstr "" | 6529 | msgstr "" |
@@ -6719,18 +6719,23 @@ msgstr "" | |||
6719 | msgid "GNUnet topology control" | 6719 | msgid "GNUnet topology control" |
6720 | msgstr "" | 6720 | msgstr "" |
6721 | 6721 | ||
6722 | #: src/transport/gnunet-communicator-tcp.c:3712 | 6722 | #: src/transport/gnunet-communicator-quic.c:1718 |
6723 | #: src/transport/gnunet-communicator-udp.c:3879 | 6723 | #: src/transport/gnunet-communicator-tcp.c:3737 |
6724 | #: src/transport/gnunet-service-tng.c:11393 | 6724 | #: src/transport/gnunet-communicator-udp.c:3363 |
6725 | #: src/transport/gnunet-service-tng.c:11503 | ||
6725 | #: src/transport/gnunet-service-transport.c:2617 | 6726 | #: src/transport/gnunet-service-transport.c:2617 |
6726 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 6727 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
6727 | msgstr "" | 6728 | msgstr "" |
6728 | 6729 | ||
6729 | #: src/transport/gnunet-communicator-tcp.c:4049 | 6730 | #: src/transport/gnunet-communicator-quic.c:1788 |
6731 | msgid "GNUnet QUIC communicator" | ||
6732 | msgstr "" | ||
6733 | |||
6734 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
6730 | msgid "GNUnet TCP communicator" | 6735 | msgid "GNUnet TCP communicator" |
6731 | msgstr "" | 6736 | msgstr "" |
6732 | 6737 | ||
6733 | #: src/transport/gnunet-communicator-udp.c:3954 | 6738 | #: src/transport/gnunet-communicator-udp.c:3438 |
6734 | msgid "GNUnet UDP communicator" | 6739 | msgid "GNUnet UDP communicator" |
6735 | msgstr "" | 6740 | msgstr "" |
6736 | 6741 | ||
@@ -7651,7 +7656,7 @@ msgstr "" | |||
7651 | 7656 | ||
7652 | #: src/transport/plugin_transport_wlan.c:1195 | 7657 | #: src/transport/plugin_transport_wlan.c:1195 |
7653 | #: src/transport/plugin_transport_wlan.c:1287 | 7658 | #: src/transport/plugin_transport_wlan.c:1287 |
7654 | #: src/transport/plugin_transport_wlan.c:2325 | 7659 | #: src/transport/plugin_transport_wlan.c:2326 |
7655 | msgid "# MAC endpoints allocated" | 7660 | msgid "# MAC endpoints allocated" |
7656 | msgstr "" | 7661 | msgstr "" |
7657 | 7662 | ||
@@ -7675,17 +7680,17 @@ msgstr "# byte inviati via SMTP" | |||
7675 | msgid "# DATA messages received" | 7680 | msgid "# DATA messages received" |
7676 | msgstr "# messaggi PONG ricevuti" | 7681 | msgstr "# messaggi PONG ricevuti" |
7677 | 7682 | ||
7678 | #: src/transport/plugin_transport_wlan.c:1904 | 7683 | #: src/transport/plugin_transport_wlan.c:1905 |
7679 | #, fuzzy | 7684 | #, fuzzy |
7680 | msgid "# DATA messages processed" | 7685 | msgid "# DATA messages processed" |
7681 | msgstr "# messaggi PONG ricevuti" | 7686 | msgstr "# messaggi PONG ricevuti" |
7682 | 7687 | ||
7683 | #: src/transport/plugin_transport_wlan.c:2300 | 7688 | #: src/transport/plugin_transport_wlan.c:2301 |
7684 | #, c-format | 7689 | #, c-format |
7685 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 7690 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
7686 | msgstr "" | 7691 | msgstr "" |
7687 | 7692 | ||
7688 | #: src/transport/plugin_transport_wlan.c:2322 | 7693 | #: src/transport/plugin_transport_wlan.c:2323 |
7689 | msgid "# sessions allocated" | 7694 | msgid "# sessions allocated" |
7690 | msgstr "" | 7695 | msgstr "" |
7691 | 7696 | ||
@@ -7774,7 +7779,7 @@ msgstr "" | |||
7774 | msgid "Service process failed to report status\n" | 7779 | msgid "Service process failed to report status\n" |
7775 | msgstr "" | 7780 | msgstr "" |
7776 | 7781 | ||
7777 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 7782 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
7778 | #: src/util/service.c:1642 | 7783 | #: src/util/service.c:1642 |
7779 | #, c-format | 7784 | #, c-format |
7780 | msgid "Cannot obtain information about user `%s': %s\n" | 7785 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -7794,7 +7799,7 @@ msgid "do daemonize (detach from terminal)" | |||
7794 | msgstr "" | 7799 | msgstr "" |
7795 | 7800 | ||
7796 | #: src/transport/tcp_service_legacy.c:1397 | 7801 | #: src/transport/tcp_service_legacy.c:1397 |
7797 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 7802 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
7798 | #: src/util/service.c:2089 | 7803 | #: src/util/service.c:2089 |
7799 | #, c-format | 7804 | #, c-format |
7800 | msgid "Malformed configuration file `%s', exit ...\n" | 7805 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -7809,7 +7814,7 @@ msgstr "" | |||
7809 | msgid "Could not access configuration file `%s'\n" | 7814 | msgid "Could not access configuration file `%s'\n" |
7810 | msgstr "" | 7815 | msgstr "" |
7811 | 7816 | ||
7812 | #: src/transport/transport_api2_communication.c:752 | 7817 | #: src/transport/transport_api2_communication.c:762 |
7813 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 7818 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
7814 | msgstr "" | 7819 | msgstr "" |
7815 | 7820 | ||
@@ -7935,74 +7940,22 @@ msgid "" | |||
7935 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" | 7940 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" |
7936 | msgstr "" | 7941 | msgstr "" |
7937 | 7942 | ||
7938 | #: src/util/configuration.c:786 | 7943 | #: src/util/configuration.c:1073 |
7939 | #, c-format | ||
7940 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
7941 | msgstr "" | ||
7942 | |||
7943 | #: src/util/configuration.c:796 | ||
7944 | #, c-format | ||
7945 | msgid "Bad directive in line %u\n" | ||
7946 | msgstr "" | ||
7947 | |||
7948 | #: src/util/configuration.c:852 | ||
7949 | #, c-format | ||
7950 | msgid "Bad inline-secret directive in line %u\n" | ||
7951 | msgstr "" | ||
7952 | |||
7953 | #: src/util/configuration.c:874 | ||
7954 | #, c-format | ||
7955 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
7956 | msgstr "" | ||
7957 | |||
7958 | #: src/util/configuration.c:905 | ||
7959 | #, c-format | ||
7960 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
7961 | msgstr "" | ||
7962 | |||
7963 | #: src/util/configuration.c:955 | ||
7964 | #, c-format | ||
7965 | msgid "Syntax error while deserializing in line %u\n" | ||
7966 | msgstr "" | ||
7967 | |||
7968 | #: src/util/configuration.c:1055 | ||
7969 | #, c-format | ||
7970 | msgid "Error while reading file `%s'\n" | ||
7971 | msgstr "Errore di lettura del file `%s'\n" | ||
7972 | |||
7973 | #: src/util/configuration.c:1068 | ||
7974 | #, fuzzy, c-format | 7944 | #, fuzzy, c-format |
7975 | msgid "Failed to parse configuration file `%s'\n" | 7945 | msgid "Failed to parse configuration file `%s'\n" |
7976 | msgstr "Impossibile avviare il servizio ' %s'\n" | 7946 | msgstr "Impossibile avviare il servizio ' %s'\n" |
7977 | 7947 | ||
7978 | #: src/util/configuration.c:1701 | 7948 | #: src/util/configuration.c:1718 |
7979 | msgid "Not a valid relative time specification" | 7949 | msgid "Not a valid relative time specification" |
7980 | msgstr "" | 7950 | msgstr "" |
7981 | 7951 | ||
7982 | #: src/util/configuration.c:1771 | 7952 | #: src/util/configuration.c:1788 |
7983 | #, c-format | 7953 | #, c-format |
7984 | msgid "" | 7954 | msgid "" |
7985 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 7955 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
7986 | "choices\n" | 7956 | "choices\n" |
7987 | msgstr "" | 7957 | msgstr "" |
7988 | 7958 | ||
7989 | #: src/util/configuration.c:1866 | ||
7990 | #, c-format | ||
7991 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
7992 | msgstr "" | ||
7993 | |||
7994 | #: src/util/configuration.c:1898 | ||
7995 | #, c-format | ||
7996 | msgid "Missing closing `%s' in option `%s'\n" | ||
7997 | msgstr "" | ||
7998 | |||
7999 | #: src/util/configuration.c:1964 | ||
8000 | #, c-format | ||
8001 | msgid "" | ||
8002 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8003 | "as an environmental variable\n" | ||
8004 | msgstr "" | ||
8005 | |||
8006 | #: src/util/configuration_helper.c:134 | 7959 | #: src/util/configuration_helper.c:134 |
8007 | #, c-format | 7960 | #, c-format |
8008 | msgid "The following sections are available:\n" | 7961 | msgid "The following sections are available:\n" |
@@ -8030,12 +7983,12 @@ msgid "" | |||
8030 | "%llu)\n" | 7983 | "%llu)\n" |
8031 | msgstr "" | 7984 | msgstr "" |
8032 | 7985 | ||
8033 | #: src/util/crypto_ecc.c:567 | 7986 | #: src/util/crypto_ecc.c:554 |
8034 | #, c-format | 7987 | #, c-format |
8035 | msgid "ECC signing failed at %s:%d: %s\n" | 7988 | msgid "ECC signing failed at %s:%d: %s\n" |
8036 | msgstr "" | 7989 | msgstr "" |
8037 | 7990 | ||
8038 | #: src/util/crypto_ecc.c:689 | 7991 | #: src/util/crypto_ecc.c:677 |
8039 | #, c-format | 7992 | #, c-format |
8040 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 7993 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8041 | msgstr "" | 7994 | msgstr "" |
@@ -8059,7 +8012,7 @@ msgstr "" | |||
8059 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8012 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8060 | msgstr "" | 8013 | msgstr "" |
8061 | 8014 | ||
8062 | #: src/util/disk.c:842 | 8015 | #: src/util/disk.c:843 |
8063 | #, c-format | 8016 | #, c-format |
8064 | msgid "Expected `%s' to be a directory!\n" | 8017 | msgid "Expected `%s' to be a directory!\n" |
8065 | msgstr "" | 8018 | msgstr "" |
@@ -9003,10 +8956,14 @@ msgstr "" | |||
9003 | msgid "Failed to replicate block in namecache: %s\n" | 8956 | msgid "Failed to replicate block in namecache: %s\n" |
9004 | msgstr "" | 8957 | msgstr "" |
9005 | 8958 | ||
9006 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 8959 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9007 | msgid "Failed to connect to the namestore!\n" | 8960 | msgid "Failed to connect to the namestore!\n" |
9008 | msgstr "" | 8961 | msgstr "" |
9009 | 8962 | ||
8963 | #, c-format | ||
8964 | #~ msgid "Error while reading file `%s'\n" | ||
8965 | #~ msgstr "Errore di lettura del file `%s'\n" | ||
8966 | |||
9010 | #, fuzzy, c-format | 8967 | #, fuzzy, c-format |
9011 | #~ msgid "Failed to drop database with: `%s'\n" | 8968 | #~ msgid "Failed to drop database with: `%s'\n" |
9012 | #~ msgstr "Impossibile avviare il servizio ' %s'\n" | 8969 | #~ msgstr "Impossibile avviare il servizio ' %s'\n" |
diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 000000000..57d1266b3 --- /dev/null +++ b/po/meson.build | |||
@@ -0,0 +1 @@ | |||
i18n.gettext(gettext_package, preset: 'glib') | |||
@@ -6,7 +6,7 @@ msgid "" | |||
6 | msgstr "" | 6 | msgstr "" |
7 | "Project-Id-Version: gnunet-0.10.1\n" | 7 | "Project-Id-Version: gnunet-0.10.1\n" |
8 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 8 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
9 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 9 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
10 | "PO-Revision-Date: 2020-10-23 18:39+0200\n" | 10 | "PO-Revision-Date: 2020-10-23 18:39+0200\n" |
11 | "Last-Translator: МироÑлав Ðиколић <miroslavnikolic@rocketmail.com>\n" | 11 | "Last-Translator: МироÑлав Ðиколић <miroslavnikolic@rocketmail.com>\n" |
12 | "Language-Team: Serbian <(nothing)>\n" | 12 | "Language-Team: Serbian <(nothing)>\n" |
@@ -1578,7 +1578,7 @@ msgstr "ОÑтава података Ñкупине ради\n" | |||
1578 | #: src/testbed/generate-underlay-topology.c:48 | 1578 | #: src/testbed/generate-underlay-topology.c:48 |
1579 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1579 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1580 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1580 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1581 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1581 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1582 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1582 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1583 | #, c-format | 1583 | #, c-format |
1584 | msgid "`%s' failed at %s:%d with error: %s\n" | 1584 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -4006,12 +4006,12 @@ msgid "Properly base32-encoded public key required" | |||
4006 | msgstr "иÑправан јавни кључ Ñе захтева" | 4006 | msgstr "иÑправан јавни кључ Ñе захтева" |
4007 | 4007 | ||
4008 | #: src/gns/gnunet-service-gns.c:554 | 4008 | #: src/gns/gnunet-service-gns.c:554 |
4009 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 4009 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
4010 | msgid "Failed to connect to the namecache!\n" | 4010 | msgid "Failed to connect to the namecache!\n" |
4011 | msgstr "ÐиÑам уÑпео да Ñе повежем Ñа оÑтавом назива!\n" | 4011 | msgstr "ÐиÑам уÑпео да Ñе повежем Ñа оÑтавом назива!\n" |
4012 | 4012 | ||
4013 | #: src/gns/gnunet-service-gns.c:573 | 4013 | #: src/gns/gnunet-service-gns.c:573 |
4014 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 4014 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
4015 | msgid "Could not connect to DHT!\n" | 4015 | msgid "Could not connect to DHT!\n" |
4016 | msgstr "Ðе могу да Ñе повежем на ДХТ!\n" | 4016 | msgstr "Ðе могу да Ñе повежем на ДХТ!\n" |
4017 | 4017 | ||
@@ -4603,47 +4603,47 @@ msgstr "Ðе могу да покренем ХТТП Ñервер ÑпиÑка Ð | |||
4603 | msgid "Failed to create ego: %s\n" | 4603 | msgid "Failed to create ego: %s\n" |
4604 | msgstr "ÐиÑам уÑпео да направим его: %s\n" | 4604 | msgstr "ÐиÑам уÑпео да направим его: %s\n" |
4605 | 4605 | ||
4606 | #: src/identity/gnunet-identity.c:586 | 4606 | #: src/identity/gnunet-identity.c:540 |
4607 | msgid "create ego NAME" | 4607 | msgid "create ego NAME" |
4608 | msgstr "Ñтвара ÐÐЗИВ ега" | 4608 | msgstr "Ñтвара ÐÐЗИВ ега" |
4609 | 4609 | ||
4610 | #: src/identity/gnunet-identity.c:591 | 4610 | #: src/identity/gnunet-identity.c:545 |
4611 | msgid "delete ego NAME " | 4611 | msgid "delete ego NAME " |
4612 | msgstr "брише ÐÐЗИВ ега " | 4612 | msgstr "брише ÐÐЗИВ ега " |
4613 | 4613 | ||
4614 | #: src/identity/gnunet-identity.c:597 | 4614 | #: src/identity/gnunet-identity.c:551 |
4615 | msgid "" | 4615 | msgid "" |
4616 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4616 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4617 | msgstr "" | 4617 | msgstr "" |
4618 | 4618 | ||
4619 | #: src/identity/gnunet-identity.c:603 | 4619 | #: src/identity/gnunet-identity.c:557 |
4620 | msgid "" | 4620 | msgid "" |
4621 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4621 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4622 | "EGO)" | 4622 | "EGO)" |
4623 | msgstr "" | 4623 | msgstr "" |
4624 | 4624 | ||
4625 | #: src/identity/gnunet-identity.c:609 | 4625 | #: src/identity/gnunet-identity.c:563 |
4626 | msgid "" | 4626 | msgid "" |
4627 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4627 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4628 | "with -k RECIPIENT_PUBLIC_KEY)" | 4628 | "with -k RECIPIENT_PUBLIC_KEY)" |
4629 | msgstr "" | 4629 | msgstr "" |
4630 | 4630 | ||
4631 | #: src/identity/gnunet-identity.c:614 | 4631 | #: src/identity/gnunet-identity.c:568 |
4632 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4632 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4633 | msgstr "" | 4633 | msgstr "" |
4634 | 4634 | ||
4635 | # | 4635 | # |
4636 | # File: util/dialtest.c++, line: 134 | 4636 | # File: util/dialtest.c++, line: 134 |
4637 | #: src/identity/gnunet-identity.c:618 | 4637 | #: src/identity/gnunet-identity.c:572 |
4638 | msgid "display all egos" | 4638 | msgid "display all egos" |
4639 | msgstr "приказује Ñве егое" | 4639 | msgstr "приказује Ñве егое" |
4640 | 4640 | ||
4641 | #: src/identity/gnunet-identity.c:622 | 4641 | #: src/identity/gnunet-identity.c:576 |
4642 | #, fuzzy | 4642 | #, fuzzy |
4643 | msgid "reduce output" | 4643 | msgid "reduce output" |
4644 | msgstr "опширан излаз" | 4644 | msgstr "опширан излаз" |
4645 | 4645 | ||
4646 | #: src/identity/gnunet-identity.c:629 | 4646 | #: src/identity/gnunet-identity.c:583 |
4647 | #, fuzzy | 4647 | #, fuzzy |
4648 | msgid "" | 4648 | msgid "" |
4649 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4649 | "restrict results to NAME (use together with -d) or read and decrypt a " |
@@ -4652,19 +4652,19 @@ msgstr "" | |||
4652 | "поÑтавља оÑновни идентитет на ЕГО за подÑиÑтем ПОДСИСТЕМ (кориÑтите заједно " | 4652 | "поÑтавља оÑновни идентитет на ЕГО за подÑиÑтем ПОДСИСТЕМ (кориÑтите заједно " |
4653 | "Ñа -s)" | 4653 | "Ñа -s)" |
4654 | 4654 | ||
4655 | #: src/identity/gnunet-identity.c:635 | 4655 | #: src/identity/gnunet-identity.c:589 |
4656 | msgid "The public key of the recipient (with -W)" | 4656 | msgid "The public key of the recipient (with -W)" |
4657 | msgstr "" | 4657 | msgstr "" |
4658 | 4658 | ||
4659 | #: src/identity/gnunet-identity.c:639 | 4659 | #: src/identity/gnunet-identity.c:593 |
4660 | msgid "run in monitor mode egos" | 4660 | msgid "run in monitor mode egos" |
4661 | msgstr "ради у режиму праћења егоа" | 4661 | msgstr "ради у режиму праћења егоа" |
4662 | 4662 | ||
4663 | #: src/identity/gnunet-identity.c:643 | 4663 | #: src/identity/gnunet-identity.c:597 |
4664 | msgid "display private keys as well" | 4664 | msgid "display private keys as well" |
4665 | msgstr "" | 4665 | msgstr "" |
4666 | 4666 | ||
4667 | #: src/identity/gnunet-identity.c:658 | 4667 | #: src/identity/gnunet-identity.c:612 |
4668 | msgid "Maintain egos" | 4668 | msgid "Maintain egos" |
4669 | msgstr "Одржава егое" | 4669 | msgstr "Одржава егое" |
4670 | 4670 | ||
@@ -6790,17 +6790,17 @@ msgstr "" | |||
6790 | "Број ивица које Ñе могу уÑпоÑтавити приликом додавања новог чвора у " | 6790 | "Број ивица које Ñе могу уÑпоÑтавити приликом додавања новог чвора у " |
6791 | "Ñлободном размештају леÑтвице не може бити већи од %u. Дато је „%s = %llu“" | 6791 | "Ñлободном размештају леÑтвице не може бити већи од %u. Дато је „%s = %llu“" |
6792 | 6792 | ||
6793 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6793 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6794 | #, c-format | 6794 | #, c-format |
6795 | msgid "Topology file %s not found\n" | 6795 | msgid "Topology file %s not found\n" |
6796 | msgstr "ÐиÑам нашао датотеку размештаја „%s“\n" | 6796 | msgstr "ÐиÑам нашао датотеку размештаја „%s“\n" |
6797 | 6797 | ||
6798 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6798 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6799 | #, c-format | 6799 | #, c-format |
6800 | msgid "Topology file %s has no data\n" | 6800 | msgid "Topology file %s has no data\n" |
6801 | msgstr "Датотека размештаја „%s“ нема података\n" | 6801 | msgstr "Датотека размештаја „%s“ нема података\n" |
6802 | 6802 | ||
6803 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6803 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6804 | #, c-format | 6804 | #, c-format |
6805 | msgid "Topology file %s cannot be read\n" | 6805 | msgid "Topology file %s cannot be read\n" |
6806 | msgstr "Ðе могу да прочитам датотеку размештаја „%s“\n" | 6806 | msgstr "Ðе могу да прочитам датотеку размештаја „%s“\n" |
@@ -7013,18 +7013,23 @@ msgstr "# „HELLO“ поруке Ñу примљене" | |||
7013 | msgid "GNUnet topology control" | 7013 | msgid "GNUnet topology control" |
7014 | msgstr "" | 7014 | msgstr "" |
7015 | 7015 | ||
7016 | #: src/transport/gnunet-communicator-tcp.c:3712 | 7016 | #: src/transport/gnunet-communicator-quic.c:1718 |
7017 | #: src/transport/gnunet-communicator-udp.c:3879 | 7017 | #: src/transport/gnunet-communicator-tcp.c:3737 |
7018 | #: src/transport/gnunet-service-tng.c:11393 | 7018 | #: src/transport/gnunet-communicator-udp.c:3363 |
7019 | #: src/transport/gnunet-service-tng.c:11503 | ||
7019 | #: src/transport/gnunet-service-transport.c:2617 | 7020 | #: src/transport/gnunet-service-transport.c:2617 |
7020 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 7021 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
7021 | msgstr "УÑлузи преноÑа недоÑтају поÑтавке подешавања кључа. Излазим.\n" | 7022 | msgstr "УÑлузи преноÑа недоÑтају поÑтавке подешавања кључа. Излазим.\n" |
7022 | 7023 | ||
7023 | #: src/transport/gnunet-communicator-tcp.c:4049 | 7024 | #: src/transport/gnunet-communicator-quic.c:1788 |
7025 | msgid "GNUnet QUIC communicator" | ||
7026 | msgstr "" | ||
7027 | |||
7028 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
7024 | msgid "GNUnet TCP communicator" | 7029 | msgid "GNUnet TCP communicator" |
7025 | msgstr "" | 7030 | msgstr "" |
7026 | 7031 | ||
7027 | #: src/transport/gnunet-communicator-udp.c:3954 | 7032 | #: src/transport/gnunet-communicator-udp.c:3438 |
7028 | msgid "GNUnet UDP communicator" | 7033 | msgid "GNUnet UDP communicator" |
7029 | msgstr "" | 7034 | msgstr "" |
7030 | 7035 | ||
@@ -7997,7 +8002,7 @@ msgstr "# Поруке „WLAN“-а Ñу на чекању (Ñа раÑцепк | |||
7997 | 8002 | ||
7998 | #: src/transport/plugin_transport_wlan.c:1195 | 8003 | #: src/transport/plugin_transport_wlan.c:1195 |
7999 | #: src/transport/plugin_transport_wlan.c:1287 | 8004 | #: src/transport/plugin_transport_wlan.c:1287 |
8000 | #: src/transport/plugin_transport_wlan.c:2325 | 8005 | #: src/transport/plugin_transport_wlan.c:2326 |
8001 | #, fuzzy | 8006 | #, fuzzy |
8002 | msgid "# MAC endpoints allocated" | 8007 | msgid "# MAC endpoints allocated" |
8003 | msgstr "# Крајње тачке „WLAN“ ÐœÐЦ-а Ñу додељене" | 8008 | msgstr "# Крајње тачке „WLAN“ ÐœÐЦ-а Ñу додељене" |
@@ -8022,17 +8027,17 @@ msgstr "# „HELLO“ ознаке Ñу поÑлате путем „WLAN“—Р| |||
8022 | msgid "# DATA messages received" | 8027 | msgid "# DATA messages received" |
8023 | msgstr "# поруке ЈÐЗ СТÐВИ Ñу примљене" | 8028 | msgstr "# поруке ЈÐЗ СТÐВИ Ñу примљене" |
8024 | 8029 | ||
8025 | #: src/transport/plugin_transport_wlan.c:1904 | 8030 | #: src/transport/plugin_transport_wlan.c:1905 |
8026 | #, fuzzy | 8031 | #, fuzzy |
8027 | msgid "# DATA messages processed" | 8032 | msgid "# DATA messages processed" |
8028 | msgstr "# Поруке „WLAN“ ПОДÐТÐКРÑу обрађене" | 8033 | msgstr "# Поруке „WLAN“ ПОДÐТÐКРÑу обрађене" |
8029 | 8034 | ||
8030 | #: src/transport/plugin_transport_wlan.c:2300 | 8035 | #: src/transport/plugin_transport_wlan.c:2301 |
8031 | #, c-format | 8036 | #, c-format |
8032 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 8037 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
8033 | msgstr "Извршна помоћника „%s“ није СУИБ, не могу да покренем „WLAN“ преноÑ\n" | 8038 | msgstr "Извршна помоћника „%s“ није СУИБ, не могу да покренем „WLAN“ преноÑ\n" |
8034 | 8039 | ||
8035 | #: src/transport/plugin_transport_wlan.c:2322 | 8040 | #: src/transport/plugin_transport_wlan.c:2323 |
8036 | #, fuzzy | 8041 | #, fuzzy |
8037 | msgid "# sessions allocated" | 8042 | msgid "# sessions allocated" |
8038 | msgstr "# „WLAN“ ÑеÑије Ñу додељене" | 8043 | msgstr "# „WLAN“ ÑеÑије Ñу додељене" |
@@ -8126,7 +8131,7 @@ msgstr "ÐŸÑ€Ð¾Ñ†ÐµÑ ÑƒÑлуге не може да покрене функци | |||
8126 | msgid "Service process failed to report status\n" | 8131 | msgid "Service process failed to report status\n" |
8127 | msgstr "ÐŸÑ€Ð¾Ñ†ÐµÑ ÑƒÑлуге није уÑпео да извеÑти о Ñтању\n" | 8132 | msgstr "ÐŸÑ€Ð¾Ñ†ÐµÑ ÑƒÑлуге није уÑпео да извеÑти о Ñтању\n" |
8128 | 8133 | ||
8129 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 8134 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
8130 | #: src/util/service.c:1642 | 8135 | #: src/util/service.c:1642 |
8131 | #, c-format | 8136 | #, c-format |
8132 | msgid "Cannot obtain information about user `%s': %s\n" | 8137 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -8146,7 +8151,7 @@ msgid "do daemonize (detach from terminal)" | |||
8146 | msgstr "ради демонизацију (откачиње од терминала)" | 8151 | msgstr "ради демонизацију (откачиње од терминала)" |
8147 | 8152 | ||
8148 | #: src/transport/tcp_service_legacy.c:1397 | 8153 | #: src/transport/tcp_service_legacy.c:1397 |
8149 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 8154 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
8150 | #: src/util/service.c:2089 | 8155 | #: src/util/service.c:2089 |
8151 | #, c-format | 8156 | #, c-format |
8152 | msgid "Malformed configuration file `%s', exit ...\n" | 8157 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -8161,7 +8166,7 @@ msgstr "Лоше подешавање, излазим ...\n" | |||
8161 | msgid "Could not access configuration file `%s'\n" | 8166 | msgid "Could not access configuration file `%s'\n" |
8162 | msgstr "Ðе могу да приÑтупим датотеци подешавања „%s“\n" | 8167 | msgstr "Ðе могу да приÑтупим датотеци подешавања „%s“\n" |
8163 | 8168 | ||
8164 | #: src/transport/transport_api2_communication.c:752 | 8169 | #: src/transport/transport_api2_communication.c:762 |
8165 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 8170 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
8166 | msgstr "" | 8171 | msgstr "" |
8167 | 8172 | ||
@@ -8288,51 +8293,16 @@ msgid "" | |||
8288 | msgstr "" | 8293 | msgstr "" |
8289 | "Подешавање наводи неиÑправну вредноÑÑ‚ за опцију „%s“ у одељку „%s“: %s\n" | 8294 | "Подешавање наводи неиÑправну вредноÑÑ‚ за опцију „%s“ у одељку „%s“: %s\n" |
8290 | 8295 | ||
8291 | #: src/util/configuration.c:786 | 8296 | #: src/util/configuration.c:1073 |
8292 | #, c-format | ||
8293 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8294 | msgstr "" | ||
8295 | |||
8296 | #: src/util/configuration.c:796 | ||
8297 | #, c-format | ||
8298 | msgid "Bad directive in line %u\n" | ||
8299 | msgstr "" | ||
8300 | |||
8301 | #: src/util/configuration.c:852 | ||
8302 | #, c-format | ||
8303 | msgid "Bad inline-secret directive in line %u\n" | ||
8304 | msgstr "" | ||
8305 | |||
8306 | #: src/util/configuration.c:874 | ||
8307 | #, c-format | ||
8308 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8309 | msgstr "" | ||
8310 | |||
8311 | #: src/util/configuration.c:905 | ||
8312 | #, fuzzy, c-format | ||
8313 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8314 | msgstr "Грешка ÑинтакÑе приликом деÑеријализације у реду %u\n" | ||
8315 | |||
8316 | #: src/util/configuration.c:955 | ||
8317 | #, c-format | ||
8318 | msgid "Syntax error while deserializing in line %u\n" | ||
8319 | msgstr "Грешка ÑинтакÑе приликом деÑеријализације у реду %u\n" | ||
8320 | |||
8321 | #: src/util/configuration.c:1055 | ||
8322 | #, fuzzy, c-format | ||
8323 | msgid "Error while reading file `%s'\n" | ||
8324 | msgstr "Грешка отварања датотеке „%s“: %s\n" | ||
8325 | |||
8326 | #: src/util/configuration.c:1068 | ||
8327 | #, fuzzy, c-format | 8297 | #, fuzzy, c-format |
8328 | msgid "Failed to parse configuration file `%s'\n" | 8298 | msgid "Failed to parse configuration file `%s'\n" |
8329 | msgstr "ÐиÑам уÑпео да уклоним датотеку подешавања „%s“\n" | 8299 | msgstr "ÐиÑам уÑпео да уклоним датотеку подешавања „%s“\n" |
8330 | 8300 | ||
8331 | #: src/util/configuration.c:1701 | 8301 | #: src/util/configuration.c:1718 |
8332 | msgid "Not a valid relative time specification" | 8302 | msgid "Not a valid relative time specification" |
8333 | msgstr "" | 8303 | msgstr "" |
8334 | 8304 | ||
8335 | #: src/util/configuration.c:1771 | 8305 | #: src/util/configuration.c:1788 |
8336 | #, c-format | 8306 | #, c-format |
8337 | msgid "" | 8307 | msgid "" |
8338 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8308 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
@@ -8341,25 +8311,6 @@ msgstr "" | |||
8341 | "ВредноÑÑ‚ подешавања '%s' за '%s' у одељку '%s' није ÑƒÑ ÐºÑƒÐ¿Ñƒ иÑправних " | 8311 | "ВредноÑÑ‚ подешавања '%s' за '%s' у одељку '%s' није ÑƒÑ ÐºÑƒÐ¿Ñƒ иÑправних " |
8342 | "избора\n" | 8312 | "избора\n" |
8343 | 8313 | ||
8344 | #: src/util/configuration.c:1866 | ||
8345 | #, c-format | ||
8346 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8347 | msgstr "Сумња Ñе на дубинÑко ширење, прекидам $-ширење за термин „%s“\n" | ||
8348 | |||
8349 | #: src/util/configuration.c:1898 | ||
8350 | #, c-format | ||
8351 | msgid "Missing closing `%s' in option `%s'\n" | ||
8352 | msgstr "ÐедоÑтаје затварење „%s“ у опцији „%s“\n" | ||
8353 | |||
8354 | #: src/util/configuration.c:1964 | ||
8355 | #, c-format | ||
8356 | msgid "" | ||
8357 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8358 | "as an environmental variable\n" | ||
8359 | msgstr "" | ||
8360 | "ÐиÑам уÑпео да раширим „%s“ у „%s“ јер ниÑам нашао у [ПУТÐЊÐÐœÐ] нити је " | ||
8361 | "дефиниÑано као променљива окружења\n" | ||
8362 | |||
8363 | #: src/util/configuration_helper.c:134 | 8314 | #: src/util/configuration_helper.c:134 |
8364 | #, c-format | 8315 | #, c-format |
8365 | msgid "The following sections are available:\n" | 8316 | msgid "The following sections are available:\n" |
@@ -8389,12 +8340,12 @@ msgstr "" | |||
8389 | "Величина датотеке на диÑку није тачна за овај Блум филтер (желим %llu, имам " | 8340 | "Величина датотеке на диÑку није тачна за овај Блум филтер (желим %llu, имам " |
8390 | "%llu)\n" | 8341 | "%llu)\n" |
8391 | 8342 | ||
8392 | #: src/util/crypto_ecc.c:567 | 8343 | #: src/util/crypto_ecc.c:554 |
8393 | #, c-format | 8344 | #, c-format |
8394 | msgid "ECC signing failed at %s:%d: %s\n" | 8345 | msgid "ECC signing failed at %s:%d: %s\n" |
8395 | msgstr "„ECC“ потпиÑивање није уÑпело на %s:%d: %s\n" | 8346 | msgstr "„ECC“ потпиÑивање није уÑпело на %s:%d: %s\n" |
8396 | 8347 | ||
8397 | #: src/util/crypto_ecc.c:689 | 8348 | #: src/util/crypto_ecc.c:677 |
8398 | #, c-format | 8349 | #, c-format |
8399 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8350 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8400 | msgstr "Провера „ECDSA“ потпиÑа није уÑпела на %s:%d: %s\n" | 8351 | msgstr "Провера „ECDSA“ потпиÑа није уÑпела на %s:%d: %s\n" |
@@ -8418,7 +8369,7 @@ msgstr "„EdDSA“ потпиÑивање није уÑпело на %s:%d: %s\ | |||
8418 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8369 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8419 | msgstr "Провера „ECDSA“ потпиÑа није уÑпела на %s:%d: %s\n" | 8370 | msgstr "Провера „ECDSA“ потпиÑа није уÑпела на %s:%d: %s\n" |
8420 | 8371 | ||
8421 | #: src/util/disk.c:842 | 8372 | #: src/util/disk.c:843 |
8422 | #, c-format | 8373 | #, c-format |
8423 | msgid "Expected `%s' to be a directory!\n" | 8374 | msgid "Expected `%s' to be a directory!\n" |
8424 | msgstr "Очекивах да „%s“ буде директоријум!\n" | 8375 | msgstr "Очекивах да „%s“ буде директоријум!\n" |
@@ -9389,10 +9340,39 @@ msgstr "ПоÑтавља тунеле путем ВПÐ-а." | |||
9389 | msgid "Failed to replicate block in namecache: %s\n" | 9340 | msgid "Failed to replicate block in namecache: %s\n" |
9390 | msgstr "ÐиÑам уÑпео да реплицирам блок у оÑтави назива: %s\n" | 9341 | msgstr "ÐиÑам уÑпео да реплицирам блок у оÑтави назива: %s\n" |
9391 | 9342 | ||
9392 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9343 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9393 | msgid "Failed to connect to the namestore!\n" | 9344 | msgid "Failed to connect to the namestore!\n" |
9394 | msgstr "ÐиÑам уÑпео да Ñе повежем Ñа Ñмештајем назива!\n" | 9345 | msgstr "ÐиÑам уÑпео да Ñе повежем Ñа Ñмештајем назива!\n" |
9395 | 9346 | ||
9347 | #, fuzzy, c-format | ||
9348 | #~ msgid "" | ||
9349 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9350 | #~ msgstr "Грешка ÑинтакÑе приликом деÑеријализације у реду %u\n" | ||
9351 | |||
9352 | #, c-format | ||
9353 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9354 | #~ msgstr "Грешка ÑинтакÑе приликом деÑеријализације у реду %u\n" | ||
9355 | |||
9356 | #, fuzzy, c-format | ||
9357 | #~ msgid "Error while reading file `%s'\n" | ||
9358 | #~ msgstr "Грешка отварања датотеке „%s“: %s\n" | ||
9359 | |||
9360 | #, c-format | ||
9361 | #~ msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
9362 | #~ msgstr "Сумња Ñе на дубинÑко ширење, прекидам $-ширење за термин „%s“\n" | ||
9363 | |||
9364 | #, c-format | ||
9365 | #~ msgid "Missing closing `%s' in option `%s'\n" | ||
9366 | #~ msgstr "ÐедоÑтаје затварење „%s“ у опцији „%s“\n" | ||
9367 | |||
9368 | #, c-format | ||
9369 | #~ msgid "" | ||
9370 | #~ "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor " | ||
9371 | #~ "defined as an environmental variable\n" | ||
9372 | #~ msgstr "" | ||
9373 | #~ "ÐиÑам уÑпео да раширим „%s“ у „%s“ јер ниÑам нашао у [ПУТÐЊÐÐœÐ] нити је " | ||
9374 | #~ "дефиниÑано као променљива окружења\n" | ||
9375 | |||
9396 | #~ msgid "Postgres database running\n" | 9376 | #~ msgid "Postgres database running\n" |
9397 | #~ msgstr "База података ПоÑтгреÑа ради\n" | 9377 | #~ msgstr "База података ПоÑтгреÑа ради\n" |
9398 | 9378 | ||
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: GNUnet 0.7.0b\n" | 8 | "Project-Id-Version: GNUnet 0.7.0b\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 10 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
11 | "PO-Revision-Date: 2006-01-21 17:16+0100\n" | 11 | "PO-Revision-Date: 2006-01-21 17:16+0100\n" |
12 | "Last-Translator: Daniel Nylander <po@danielnylander.se>\n" | 12 | "Last-Translator: Daniel Nylander <po@danielnylander.se>\n" |
13 | "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" | 13 | "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" |
@@ -1586,7 +1586,7 @@ msgstr "" | |||
1586 | #: src/testbed/generate-underlay-topology.c:48 | 1586 | #: src/testbed/generate-underlay-topology.c:48 |
1587 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1587 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1588 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1588 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1589 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1589 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1590 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1590 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1591 | #, c-format | 1591 | #, c-format |
1592 | msgid "`%s' failed at %s:%d with error: %s\n" | 1592 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -4008,13 +4008,13 @@ msgid "Properly base32-encoded public key required" | |||
4008 | msgstr "Ogiltigt argument: \"%s\"\n" | 4008 | msgstr "Ogiltigt argument: \"%s\"\n" |
4009 | 4009 | ||
4010 | #: src/gns/gnunet-service-gns.c:554 | 4010 | #: src/gns/gnunet-service-gns.c:554 |
4011 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 4011 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
4012 | #, fuzzy | 4012 | #, fuzzy |
4013 | msgid "Failed to connect to the namecache!\n" | 4013 | msgid "Failed to connect to the namecache!\n" |
4014 | msgstr "Misslyckades att ansluta till gnunetd.\n" | 4014 | msgstr "Misslyckades att ansluta till gnunetd.\n" |
4015 | 4015 | ||
4016 | #: src/gns/gnunet-service-gns.c:573 | 4016 | #: src/gns/gnunet-service-gns.c:573 |
4017 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 4017 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
4018 | #, fuzzy | 4018 | #, fuzzy |
4019 | msgid "Could not connect to DHT!\n" | 4019 | msgid "Could not connect to DHT!\n" |
4020 | msgstr "Kunde inte ansluta till gnunetd.\n" | 4020 | msgstr "Kunde inte ansluta till gnunetd.\n" |
@@ -4605,62 +4605,62 @@ msgstr "" | |||
4605 | msgid "Failed to create ego: %s\n" | 4605 | msgid "Failed to create ego: %s\n" |
4606 | msgstr "Kunde inte skapa namnrymd \"%s\" (existerar?).\n" | 4606 | msgstr "Kunde inte skapa namnrymd \"%s\" (existerar?).\n" |
4607 | 4607 | ||
4608 | #: src/identity/gnunet-identity.c:586 | 4608 | #: src/identity/gnunet-identity.c:540 |
4609 | msgid "create ego NAME" | 4609 | msgid "create ego NAME" |
4610 | msgstr "" | 4610 | msgstr "" |
4611 | 4611 | ||
4612 | #: src/identity/gnunet-identity.c:591 | 4612 | #: src/identity/gnunet-identity.c:545 |
4613 | msgid "delete ego NAME " | 4613 | msgid "delete ego NAME " |
4614 | msgstr "" | 4614 | msgstr "" |
4615 | 4615 | ||
4616 | #: src/identity/gnunet-identity.c:597 | 4616 | #: src/identity/gnunet-identity.c:551 |
4617 | msgid "" | 4617 | msgid "" |
4618 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4618 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4619 | msgstr "" | 4619 | msgstr "" |
4620 | 4620 | ||
4621 | #: src/identity/gnunet-identity.c:603 | 4621 | #: src/identity/gnunet-identity.c:557 |
4622 | msgid "" | 4622 | msgid "" |
4623 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4623 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4624 | "EGO)" | 4624 | "EGO)" |
4625 | msgstr "" | 4625 | msgstr "" |
4626 | 4626 | ||
4627 | #: src/identity/gnunet-identity.c:609 | 4627 | #: src/identity/gnunet-identity.c:563 |
4628 | msgid "" | 4628 | msgid "" |
4629 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4629 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4630 | "with -k RECIPIENT_PUBLIC_KEY)" | 4630 | "with -k RECIPIENT_PUBLIC_KEY)" |
4631 | msgstr "" | 4631 | msgstr "" |
4632 | 4632 | ||
4633 | #: src/identity/gnunet-identity.c:614 | 4633 | #: src/identity/gnunet-identity.c:568 |
4634 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4634 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4635 | msgstr "" | 4635 | msgstr "" |
4636 | 4636 | ||
4637 | #: src/identity/gnunet-identity.c:618 | 4637 | #: src/identity/gnunet-identity.c:572 |
4638 | msgid "display all egos" | 4638 | msgid "display all egos" |
4639 | msgstr "" | 4639 | msgstr "" |
4640 | 4640 | ||
4641 | #: src/identity/gnunet-identity.c:622 | 4641 | #: src/identity/gnunet-identity.c:576 |
4642 | msgid "reduce output" | 4642 | msgid "reduce output" |
4643 | msgstr "" | 4643 | msgstr "" |
4644 | 4644 | ||
4645 | #: src/identity/gnunet-identity.c:629 | 4645 | #: src/identity/gnunet-identity.c:583 |
4646 | msgid "" | 4646 | msgid "" |
4647 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4647 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4648 | "message for NAME (use together with -R)" | 4648 | "message for NAME (use together with -R)" |
4649 | msgstr "" | 4649 | msgstr "" |
4650 | 4650 | ||
4651 | #: src/identity/gnunet-identity.c:635 | 4651 | #: src/identity/gnunet-identity.c:589 |
4652 | msgid "The public key of the recipient (with -W)" | 4652 | msgid "The public key of the recipient (with -W)" |
4653 | msgstr "" | 4653 | msgstr "" |
4654 | 4654 | ||
4655 | #: src/identity/gnunet-identity.c:639 | 4655 | #: src/identity/gnunet-identity.c:593 |
4656 | msgid "run in monitor mode egos" | 4656 | msgid "run in monitor mode egos" |
4657 | msgstr "" | 4657 | msgstr "" |
4658 | 4658 | ||
4659 | #: src/identity/gnunet-identity.c:643 | 4659 | #: src/identity/gnunet-identity.c:597 |
4660 | msgid "display private keys as well" | 4660 | msgid "display private keys as well" |
4661 | msgstr "" | 4661 | msgstr "" |
4662 | 4662 | ||
4663 | #: src/identity/gnunet-identity.c:658 | 4663 | #: src/identity/gnunet-identity.c:612 |
4664 | msgid "Maintain egos" | 4664 | msgid "Maintain egos" |
4665 | msgstr "" | 4665 | msgstr "" |
4666 | 4666 | ||
@@ -6775,17 +6775,17 @@ msgid "" | |||
6775 | "free topology cannot be more than %u. Given `%s = %llu'" | 6775 | "free topology cannot be more than %u. Given `%s = %llu'" |
6776 | msgstr "" | 6776 | msgstr "" |
6777 | 6777 | ||
6778 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6778 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6779 | #, fuzzy, c-format | 6779 | #, fuzzy, c-format |
6780 | msgid "Topology file %s not found\n" | 6780 | msgid "Topology file %s not found\n" |
6781 | msgstr "\"%s\" misslyckades: tabell hittades inte!\n" | 6781 | msgstr "\"%s\" misslyckades: tabell hittades inte!\n" |
6782 | 6782 | ||
6783 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6783 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6784 | #, c-format | 6784 | #, c-format |
6785 | msgid "Topology file %s has no data\n" | 6785 | msgid "Topology file %s has no data\n" |
6786 | msgstr "" | 6786 | msgstr "" |
6787 | 6787 | ||
6788 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6788 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6789 | #, c-format | 6789 | #, c-format |
6790 | msgid "Topology file %s cannot be read\n" | 6790 | msgid "Topology file %s cannot be read\n" |
6791 | msgstr "" | 6791 | msgstr "" |
@@ -6990,19 +6990,24 @@ msgstr "# krypterade PONG-meddelanden mottagna" | |||
6990 | msgid "GNUnet topology control" | 6990 | msgid "GNUnet topology control" |
6991 | msgstr "" | 6991 | msgstr "" |
6992 | 6992 | ||
6993 | #: src/transport/gnunet-communicator-tcp.c:3712 | 6993 | #: src/transport/gnunet-communicator-quic.c:1718 |
6994 | #: src/transport/gnunet-communicator-udp.c:3879 | 6994 | #: src/transport/gnunet-communicator-tcp.c:3737 |
6995 | #: src/transport/gnunet-service-tng.c:11393 | 6995 | #: src/transport/gnunet-communicator-udp.c:3363 |
6996 | #: src/transport/gnunet-service-tng.c:11503 | ||
6996 | #: src/transport/gnunet-service-transport.c:2617 | 6997 | #: src/transport/gnunet-service-transport.c:2617 |
6997 | #, fuzzy | 6998 | #, fuzzy |
6998 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 6999 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
6999 | msgstr "GNUnet-konfiguration" | 7000 | msgstr "GNUnet-konfiguration" |
7000 | 7001 | ||
7001 | #: src/transport/gnunet-communicator-tcp.c:4049 | 7002 | #: src/transport/gnunet-communicator-quic.c:1788 |
7003 | msgid "GNUnet QUIC communicator" | ||
7004 | msgstr "" | ||
7005 | |||
7006 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
7002 | msgid "GNUnet TCP communicator" | 7007 | msgid "GNUnet TCP communicator" |
7003 | msgstr "" | 7008 | msgstr "" |
7004 | 7009 | ||
7005 | #: src/transport/gnunet-communicator-udp.c:3954 | 7010 | #: src/transport/gnunet-communicator-udp.c:3438 |
7006 | msgid "GNUnet UDP communicator" | 7011 | msgid "GNUnet UDP communicator" |
7007 | msgstr "" | 7012 | msgstr "" |
7008 | 7013 | ||
@@ -7984,7 +7989,7 @@ msgstr "# byte mottogs via TCP" | |||
7984 | 7989 | ||
7985 | #: src/transport/plugin_transport_wlan.c:1195 | 7990 | #: src/transport/plugin_transport_wlan.c:1195 |
7986 | #: src/transport/plugin_transport_wlan.c:1287 | 7991 | #: src/transport/plugin_transport_wlan.c:1287 |
7987 | #: src/transport/plugin_transport_wlan.c:2325 | 7992 | #: src/transport/plugin_transport_wlan.c:2326 |
7988 | #, fuzzy | 7993 | #, fuzzy |
7989 | msgid "# MAC endpoints allocated" | 7994 | msgid "# MAC endpoints allocated" |
7990 | msgstr "# byte mottogs via TCP" | 7995 | msgstr "# byte mottogs via TCP" |
@@ -8009,17 +8014,17 @@ msgstr "# byte skickade via UDP" | |||
8009 | msgid "# DATA messages received" | 8014 | msgid "# DATA messages received" |
8010 | msgstr "# krypterade PONG-meddelanden mottagna" | 8015 | msgstr "# krypterade PONG-meddelanden mottagna" |
8011 | 8016 | ||
8012 | #: src/transport/plugin_transport_wlan.c:1904 | 8017 | #: src/transport/plugin_transport_wlan.c:1905 |
8013 | #, fuzzy | 8018 | #, fuzzy |
8014 | msgid "# DATA messages processed" | 8019 | msgid "# DATA messages processed" |
8015 | msgstr "# krypterade PONG-meddelanden mottagna" | 8020 | msgstr "# krypterade PONG-meddelanden mottagna" |
8016 | 8021 | ||
8017 | #: src/transport/plugin_transport_wlan.c:2300 | 8022 | #: src/transport/plugin_transport_wlan.c:2301 |
8018 | #, c-format | 8023 | #, c-format |
8019 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 8024 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
8020 | msgstr "" | 8025 | msgstr "" |
8021 | 8026 | ||
8022 | #: src/transport/plugin_transport_wlan.c:2322 | 8027 | #: src/transport/plugin_transport_wlan.c:2323 |
8023 | #, fuzzy | 8028 | #, fuzzy |
8024 | msgid "# sessions allocated" | 8029 | msgid "# sessions allocated" |
8025 | msgstr "# sessionsnycklar accepterade" | 8030 | msgstr "# sessionsnycklar accepterade" |
@@ -8110,7 +8115,7 @@ msgstr "" | |||
8110 | msgid "Service process failed to report status\n" | 8115 | msgid "Service process failed to report status\n" |
8111 | msgstr "" | 8116 | msgstr "" |
8112 | 8117 | ||
8113 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 8118 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
8114 | #: src/util/service.c:1642 | 8119 | #: src/util/service.c:1642 |
8115 | #, fuzzy, c-format | 8120 | #, fuzzy, c-format |
8116 | msgid "Cannot obtain information about user `%s': %s\n" | 8121 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -8130,7 +8135,7 @@ msgid "do daemonize (detach from terminal)" | |||
8130 | msgstr "" | 8135 | msgstr "" |
8131 | 8136 | ||
8132 | #: src/transport/tcp_service_legacy.c:1397 | 8137 | #: src/transport/tcp_service_legacy.c:1397 |
8133 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 8138 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
8134 | #: src/util/service.c:2089 | 8139 | #: src/util/service.c:2089 |
8135 | #, fuzzy, c-format | 8140 | #, fuzzy, c-format |
8136 | msgid "Malformed configuration file `%s', exit ...\n" | 8141 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -8146,7 +8151,7 @@ msgstr "Kunde inte spara konfigurationsfil \"%s\":" | |||
8146 | msgid "Could not access configuration file `%s'\n" | 8151 | msgid "Could not access configuration file `%s'\n" |
8147 | msgstr "Kunde inte tolka konfigurationsfil \"%s\".\n" | 8152 | msgstr "Kunde inte tolka konfigurationsfil \"%s\".\n" |
8148 | 8153 | ||
8149 | #: src/transport/transport_api2_communication.c:752 | 8154 | #: src/transport/transport_api2_communication.c:762 |
8150 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 8155 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
8151 | msgstr "" | 8156 | msgstr "" |
8152 | 8157 | ||
@@ -8273,75 +8278,23 @@ msgid "" | |||
8273 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" | 8278 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" |
8274 | msgstr "Konfigurationsfil \"%s\" hittades inte. Kör \"gnunet-setup -d\"!\n" | 8279 | msgstr "Konfigurationsfil \"%s\" hittades inte. Kör \"gnunet-setup -d\"!\n" |
8275 | 8280 | ||
8276 | #: src/util/configuration.c:786 | 8281 | #: src/util/configuration.c:1073 |
8277 | #, c-format | ||
8278 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8279 | msgstr "" | ||
8280 | |||
8281 | #: src/util/configuration.c:796 | ||
8282 | #, c-format | ||
8283 | msgid "Bad directive in line %u\n" | ||
8284 | msgstr "" | ||
8285 | |||
8286 | #: src/util/configuration.c:852 | ||
8287 | #, c-format | ||
8288 | msgid "Bad inline-secret directive in line %u\n" | ||
8289 | msgstr "" | ||
8290 | |||
8291 | #: src/util/configuration.c:874 | ||
8292 | #, c-format | ||
8293 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8294 | msgstr "" | ||
8295 | |||
8296 | #: src/util/configuration.c:905 | ||
8297 | #, fuzzy, c-format | ||
8298 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8299 | msgstr "Syntaxfel i konfigurationsfil \"%s\" på rad %d.\n" | ||
8300 | |||
8301 | #: src/util/configuration.c:955 | ||
8302 | #, fuzzy, c-format | ||
8303 | msgid "Syntax error while deserializing in line %u\n" | ||
8304 | msgstr "Syntaxfel i konfigurationsfil \"%s\" på rad %d.\n" | ||
8305 | |||
8306 | #: src/util/configuration.c:1055 | ||
8307 | #, fuzzy, c-format | ||
8308 | msgid "Error while reading file `%s'\n" | ||
8309 | msgstr "Fel vid nedladdning: %s\n" | ||
8310 | |||
8311 | #: src/util/configuration.c:1068 | ||
8312 | #, fuzzy, c-format | 8282 | #, fuzzy, c-format |
8313 | msgid "Failed to parse configuration file `%s'\n" | 8283 | msgid "Failed to parse configuration file `%s'\n" |
8314 | msgstr "Kunde inte spara konfigurationsfil \"%s\":" | 8284 | msgstr "Kunde inte spara konfigurationsfil \"%s\":" |
8315 | 8285 | ||
8316 | #: src/util/configuration.c:1701 | 8286 | #: src/util/configuration.c:1718 |
8317 | #, fuzzy | 8287 | #, fuzzy |
8318 | msgid "Not a valid relative time specification" | 8288 | msgid "Not a valid relative time specification" |
8319 | msgstr "Konfigurationsfil \"%s\" skapad.\n" | 8289 | msgstr "Konfigurationsfil \"%s\" skapad.\n" |
8320 | 8290 | ||
8321 | #: src/util/configuration.c:1771 | 8291 | #: src/util/configuration.c:1788 |
8322 | #, c-format | 8292 | #, c-format |
8323 | msgid "" | 8293 | msgid "" |
8324 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8294 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
8325 | "choices\n" | 8295 | "choices\n" |
8326 | msgstr "" | 8296 | msgstr "" |
8327 | 8297 | ||
8328 | #: src/util/configuration.c:1866 | ||
8329 | #, c-format | ||
8330 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8331 | msgstr "" | ||
8332 | |||
8333 | #: src/util/configuration.c:1898 | ||
8334 | #, fuzzy, c-format | ||
8335 | msgid "Missing closing `%s' in option `%s'\n" | ||
8336 | msgstr "Konfigurationsfil \"%s\" skapad.\n" | ||
8337 | |||
8338 | #: src/util/configuration.c:1964 | ||
8339 | #, c-format | ||
8340 | msgid "" | ||
8341 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8342 | "as an environmental variable\n" | ||
8343 | msgstr "" | ||
8344 | |||
8345 | #: src/util/configuration_helper.c:134 | 8298 | #: src/util/configuration_helper.c:134 |
8346 | #, c-format | 8299 | #, c-format |
8347 | msgid "The following sections are available:\n" | 8300 | msgid "The following sections are available:\n" |
@@ -8369,12 +8322,12 @@ msgid "" | |||
8369 | "%llu)\n" | 8322 | "%llu)\n" |
8370 | msgstr "" | 8323 | msgstr "" |
8371 | 8324 | ||
8372 | #: src/util/crypto_ecc.c:567 | 8325 | #: src/util/crypto_ecc.c:554 |
8373 | #, fuzzy, c-format | 8326 | #, fuzzy, c-format |
8374 | msgid "ECC signing failed at %s:%d: %s\n" | 8327 | msgid "ECC signing failed at %s:%d: %s\n" |
8375 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" | 8328 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" |
8376 | 8329 | ||
8377 | #: src/util/crypto_ecc.c:689 | 8330 | #: src/util/crypto_ecc.c:677 |
8378 | #, fuzzy, c-format | 8331 | #, fuzzy, c-format |
8379 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8332 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8380 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" | 8333 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" |
@@ -8399,7 +8352,7 @@ msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" | |||
8399 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8352 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8400 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" | 8353 | msgstr "\"%s\" misslyckades vid %s:%d med fel: \"%s\".\n" |
8401 | 8354 | ||
8402 | #: src/util/disk.c:842 | 8355 | #: src/util/disk.c:843 |
8403 | #, fuzzy, c-format | 8356 | #, fuzzy, c-format |
8404 | msgid "Expected `%s' to be a directory!\n" | 8357 | msgid "Expected `%s' to be a directory!\n" |
8405 | msgstr "\"%s\" förväntade att \"%s\" skulle vara en katalog!\n" | 8358 | msgstr "\"%s\" förväntade att \"%s\" skulle vara en katalog!\n" |
@@ -9363,12 +9316,29 @@ msgstr "" | |||
9363 | msgid "Failed to replicate block in namecache: %s\n" | 9316 | msgid "Failed to replicate block in namecache: %s\n" |
9364 | msgstr "Misslyckades att läsa kompislista från \"%s\"\n" | 9317 | msgstr "Misslyckades att läsa kompislista från \"%s\"\n" |
9365 | 9318 | ||
9366 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9319 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9367 | #, fuzzy | 9320 | #, fuzzy |
9368 | msgid "Failed to connect to the namestore!\n" | 9321 | msgid "Failed to connect to the namestore!\n" |
9369 | msgstr "Misslyckades att ansluta till gnunetd.\n" | 9322 | msgstr "Misslyckades att ansluta till gnunetd.\n" |
9370 | 9323 | ||
9371 | #, fuzzy, c-format | 9324 | #, fuzzy, c-format |
9325 | #~ msgid "" | ||
9326 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9327 | #~ msgstr "Syntaxfel i konfigurationsfil \"%s\" på rad %d.\n" | ||
9328 | |||
9329 | #, fuzzy, c-format | ||
9330 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9331 | #~ msgstr "Syntaxfel i konfigurationsfil \"%s\" på rad %d.\n" | ||
9332 | |||
9333 | #, fuzzy, c-format | ||
9334 | #~ msgid "Error while reading file `%s'\n" | ||
9335 | #~ msgstr "Fel vid nedladdning: %s\n" | ||
9336 | |||
9337 | #, fuzzy, c-format | ||
9338 | #~ msgid "Missing closing `%s' in option `%s'\n" | ||
9339 | #~ msgstr "Konfigurationsfil \"%s\" skapad.\n" | ||
9340 | |||
9341 | #, fuzzy, c-format | ||
9372 | #~ msgid "Failed to drop database with: `%s'\n" | 9342 | #~ msgid "Failed to drop database with: `%s'\n" |
9373 | #~ msgstr "Fel vid %s:%d.\n" | 9343 | #~ msgstr "Fel vid %s:%d.\n" |
9374 | 9344 | ||
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.8.0a\n" | 9 | "Project-Id-Version: gnunet 0.8.0a\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 11 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
12 | "PO-Revision-Date: 2008-09-10 22:05+0930\n" | 12 | "PO-Revision-Date: 2008-09-10 22:05+0930\n" |
13 | "Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n" | 13 | "Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n" |
14 | "Language-Team: Vietnamese <vi-VN@googlegroups.com>\n" | 14 | "Language-Team: Vietnamese <vi-VN@googlegroups.com>\n" |
@@ -1595,7 +1595,7 @@ msgstr "kho dữ liệu sqlite" | |||
1595 | #: src/testbed/generate-underlay-topology.c:48 | 1595 | #: src/testbed/generate-underlay-topology.c:48 |
1596 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1596 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1597 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1597 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1598 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1598 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1599 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1599 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1600 | #, c-format | 1600 | #, c-format |
1601 | msgid "`%s' failed at %s:%d with error: %s\n" | 1601 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -4052,13 +4052,13 @@ msgid "Properly base32-encoded public key required" | |||
4052 | msgstr "Äối số không hợp lệ cho « %s ».\n" | 4052 | msgstr "Äối số không hợp lệ cho « %s ».\n" |
4053 | 4053 | ||
4054 | #: src/gns/gnunet-service-gns.c:554 | 4054 | #: src/gns/gnunet-service-gns.c:554 |
4055 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 4055 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
4056 | #, fuzzy | 4056 | #, fuzzy |
4057 | msgid "Failed to connect to the namecache!\n" | 4057 | msgid "Failed to connect to the namecache!\n" |
4058 | msgstr "Không kết nối được đến trình ná»n gnunetd." | 4058 | msgstr "Không kết nối được đến trình ná»n gnunetd." |
4059 | 4059 | ||
4060 | #: src/gns/gnunet-service-gns.c:573 | 4060 | #: src/gns/gnunet-service-gns.c:573 |
4061 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 4061 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
4062 | #, fuzzy | 4062 | #, fuzzy |
4063 | msgid "Could not connect to DHT!\n" | 4063 | msgid "Could not connect to DHT!\n" |
4064 | msgstr "Không thể kết nối tới %s:%u: %s\n" | 4064 | msgstr "Không thể kết nối tới %s:%u: %s\n" |
@@ -4662,63 +4662,63 @@ msgstr "Cổng cho trình phục vụ HTTP danh sách máy chủ thống nhất" | |||
4662 | msgid "Failed to create ego: %s\n" | 4662 | msgid "Failed to create ego: %s\n" |
4663 | msgstr "Không thể tạo miá»n tên.\n" | 4663 | msgstr "Không thể tạo miá»n tên.\n" |
4664 | 4664 | ||
4665 | #: src/identity/gnunet-identity.c:586 | 4665 | #: src/identity/gnunet-identity.c:540 |
4666 | msgid "create ego NAME" | 4666 | msgid "create ego NAME" |
4667 | msgstr "" | 4667 | msgstr "" |
4668 | 4668 | ||
4669 | #: src/identity/gnunet-identity.c:591 | 4669 | #: src/identity/gnunet-identity.c:545 |
4670 | msgid "delete ego NAME " | 4670 | msgid "delete ego NAME " |
4671 | msgstr "" | 4671 | msgstr "" |
4672 | 4672 | ||
4673 | #: src/identity/gnunet-identity.c:597 | 4673 | #: src/identity/gnunet-identity.c:551 |
4674 | msgid "" | 4674 | msgid "" |
4675 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4675 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4676 | msgstr "" | 4676 | msgstr "" |
4677 | 4677 | ||
4678 | #: src/identity/gnunet-identity.c:603 | 4678 | #: src/identity/gnunet-identity.c:557 |
4679 | msgid "" | 4679 | msgid "" |
4680 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4680 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4681 | "EGO)" | 4681 | "EGO)" |
4682 | msgstr "" | 4682 | msgstr "" |
4683 | 4683 | ||
4684 | #: src/identity/gnunet-identity.c:609 | 4684 | #: src/identity/gnunet-identity.c:563 |
4685 | msgid "" | 4685 | msgid "" |
4686 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4686 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4687 | "with -k RECIPIENT_PUBLIC_KEY)" | 4687 | "with -k RECIPIENT_PUBLIC_KEY)" |
4688 | msgstr "" | 4688 | msgstr "" |
4689 | 4689 | ||
4690 | #: src/identity/gnunet-identity.c:614 | 4690 | #: src/identity/gnunet-identity.c:568 |
4691 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4691 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4692 | msgstr "" | 4692 | msgstr "" |
4693 | 4693 | ||
4694 | #: src/identity/gnunet-identity.c:618 | 4694 | #: src/identity/gnunet-identity.c:572 |
4695 | msgid "display all egos" | 4695 | msgid "display all egos" |
4696 | msgstr "" | 4696 | msgstr "" |
4697 | 4697 | ||
4698 | #: src/identity/gnunet-identity.c:622 | 4698 | #: src/identity/gnunet-identity.c:576 |
4699 | msgid "reduce output" | 4699 | msgid "reduce output" |
4700 | msgstr "" | 4700 | msgstr "" |
4701 | 4701 | ||
4702 | #: src/identity/gnunet-identity.c:629 | 4702 | #: src/identity/gnunet-identity.c:583 |
4703 | msgid "" | 4703 | msgid "" |
4704 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4704 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4705 | "message for NAME (use together with -R)" | 4705 | "message for NAME (use together with -R)" |
4706 | msgstr "" | 4706 | msgstr "" |
4707 | 4707 | ||
4708 | #: src/identity/gnunet-identity.c:635 | 4708 | #: src/identity/gnunet-identity.c:589 |
4709 | msgid "The public key of the recipient (with -W)" | 4709 | msgid "The public key of the recipient (with -W)" |
4710 | msgstr "" | 4710 | msgstr "" |
4711 | 4711 | ||
4712 | #: src/identity/gnunet-identity.c:639 | 4712 | #: src/identity/gnunet-identity.c:593 |
4713 | msgid "run in monitor mode egos" | 4713 | msgid "run in monitor mode egos" |
4714 | msgstr "" | 4714 | msgstr "" |
4715 | 4715 | ||
4716 | #: src/identity/gnunet-identity.c:643 | 4716 | #: src/identity/gnunet-identity.c:597 |
4717 | #, fuzzy | 4717 | #, fuzzy |
4718 | msgid "display private keys as well" | 4718 | msgid "display private keys as well" |
4719 | msgstr "hiển thị giá trị tổng kiểm của táºp tin" | 4719 | msgstr "hiển thị giá trị tổng kiểm của táºp tin" |
4720 | 4720 | ||
4721 | #: src/identity/gnunet-identity.c:658 | 4721 | #: src/identity/gnunet-identity.c:612 |
4722 | msgid "Maintain egos" | 4722 | msgid "Maintain egos" |
4723 | msgstr "" | 4723 | msgstr "" |
4724 | 4724 | ||
@@ -6831,17 +6831,17 @@ msgid "" | |||
6831 | "free topology cannot be more than %u. Given `%s = %llu'" | 6831 | "free topology cannot be more than %u. Given `%s = %llu'" |
6832 | msgstr "" | 6832 | msgstr "" |
6833 | 6833 | ||
6834 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6834 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6835 | #, fuzzy, c-format | 6835 | #, fuzzy, c-format |
6836 | msgid "Topology file %s not found\n" | 6836 | msgid "Topology file %s not found\n" |
6837 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" | 6837 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" |
6838 | 6838 | ||
6839 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6839 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6840 | #, fuzzy, c-format | 6840 | #, fuzzy, c-format |
6841 | msgid "Topology file %s has no data\n" | 6841 | msgid "Topology file %s has no data\n" |
6842 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" | 6842 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" |
6843 | 6843 | ||
6844 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6844 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6845 | #, fuzzy, c-format | 6845 | #, fuzzy, c-format |
6846 | msgid "Topology file %s cannot be read\n" | 6846 | msgid "Topology file %s cannot be read\n" |
6847 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" | 6847 | msgstr "Khoá phiên chạy từ đồng đẳng « %s » không thể được thẩm tra.\n" |
@@ -7052,19 +7052,24 @@ msgstr "# các thông báo PONG đã máºt mã được nháºn" | |||
7052 | msgid "GNUnet topology control" | 7052 | msgid "GNUnet topology control" |
7053 | msgstr "" | 7053 | msgstr "" |
7054 | 7054 | ||
7055 | #: src/transport/gnunet-communicator-tcp.c:3712 | 7055 | #: src/transport/gnunet-communicator-quic.c:1718 |
7056 | #: src/transport/gnunet-communicator-udp.c:3879 | 7056 | #: src/transport/gnunet-communicator-tcp.c:3737 |
7057 | #: src/transport/gnunet-service-tng.c:11393 | 7057 | #: src/transport/gnunet-communicator-udp.c:3363 |
7058 | #: src/transport/gnunet-service-tng.c:11503 | ||
7058 | #: src/transport/gnunet-service-transport.c:2617 | 7059 | #: src/transport/gnunet-service-transport.c:2617 |
7059 | #, fuzzy | 7060 | #, fuzzy |
7060 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 7061 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
7061 | msgstr "Lưu cấu hình ngay bây giỠkhông?" | 7062 | msgstr "Lưu cấu hình ngay bây giỠkhông?" |
7062 | 7063 | ||
7063 | #: src/transport/gnunet-communicator-tcp.c:4049 | 7064 | #: src/transport/gnunet-communicator-quic.c:1788 |
7065 | msgid "GNUnet QUIC communicator" | ||
7066 | msgstr "" | ||
7067 | |||
7068 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
7064 | msgid "GNUnet TCP communicator" | 7069 | msgid "GNUnet TCP communicator" |
7065 | msgstr "" | 7070 | msgstr "" |
7066 | 7071 | ||
7067 | #: src/transport/gnunet-communicator-udp.c:3954 | 7072 | #: src/transport/gnunet-communicator-udp.c:3438 |
7068 | msgid "GNUnet UDP communicator" | 7073 | msgid "GNUnet UDP communicator" |
7069 | msgstr "" | 7074 | msgstr "" |
7070 | 7075 | ||
@@ -8041,7 +8046,7 @@ msgstr "# các thông báo được chắp liá»n" | |||
8041 | 8046 | ||
8042 | #: src/transport/plugin_transport_wlan.c:1195 | 8047 | #: src/transport/plugin_transport_wlan.c:1195 |
8043 | #: src/transport/plugin_transport_wlan.c:1287 | 8048 | #: src/transport/plugin_transport_wlan.c:1287 |
8044 | #: src/transport/plugin_transport_wlan.c:2325 | 8049 | #: src/transport/plugin_transport_wlan.c:2326 |
8045 | #, fuzzy | 8050 | #, fuzzy |
8046 | msgid "# MAC endpoints allocated" | 8051 | msgid "# MAC endpoints allocated" |
8047 | msgstr "# các yêu cầu get (lấy) dht được nháºn" | 8052 | msgstr "# các yêu cầu get (lấy) dht được nháºn" |
@@ -8066,17 +8071,17 @@ msgstr "# các byte đã gá»i qua UDP" | |||
8066 | msgid "# DATA messages received" | 8071 | msgid "# DATA messages received" |
8067 | msgstr "# các thông báo PONG đã máºt mã được nháºn" | 8072 | msgstr "# các thông báo PONG đã máºt mã được nháºn" |
8068 | 8073 | ||
8069 | #: src/transport/plugin_transport_wlan.c:1904 | 8074 | #: src/transport/plugin_transport_wlan.c:1905 |
8070 | #, fuzzy | 8075 | #, fuzzy |
8071 | msgid "# DATA messages processed" | 8076 | msgid "# DATA messages processed" |
8072 | msgstr "# các thông báo PONG đã máºt mã được nháºn" | 8077 | msgstr "# các thông báo PONG đã máºt mã được nháºn" |
8073 | 8078 | ||
8074 | #: src/transport/plugin_transport_wlan.c:2300 | 8079 | #: src/transport/plugin_transport_wlan.c:2301 |
8075 | #, c-format | 8080 | #, c-format |
8076 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 8081 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
8077 | msgstr "" | 8082 | msgstr "" |
8078 | 8083 | ||
8079 | #: src/transport/plugin_transport_wlan.c:2322 | 8084 | #: src/transport/plugin_transport_wlan.c:2323 |
8080 | #, fuzzy | 8085 | #, fuzzy |
8081 | msgid "# sessions allocated" | 8086 | msgid "# sessions allocated" |
8082 | msgstr "# các khoá phiên chạy được chấp nháºn" | 8087 | msgstr "# các khoá phiên chạy được chấp nháºn" |
@@ -8166,7 +8171,7 @@ msgstr "" | |||
8166 | msgid "Service process failed to report status\n" | 8171 | msgid "Service process failed to report status\n" |
8167 | msgstr "" | 8172 | msgstr "" |
8168 | 8173 | ||
8169 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 8174 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
8170 | #: src/util/service.c:1642 | 8175 | #: src/util/service.c:1642 |
8171 | #, c-format | 8176 | #, c-format |
8172 | msgid "Cannot obtain information about user `%s': %s\n" | 8177 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -8186,7 +8191,7 @@ msgid "do daemonize (detach from terminal)" | |||
8186 | msgstr "" | 8191 | msgstr "" |
8187 | 8192 | ||
8188 | #: src/transport/tcp_service_legacy.c:1397 | 8193 | #: src/transport/tcp_service_legacy.c:1397 |
8189 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 8194 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
8190 | #: src/util/service.c:2089 | 8195 | #: src/util/service.c:2089 |
8191 | #, fuzzy, c-format | 8196 | #, fuzzy, c-format |
8192 | msgid "Malformed configuration file `%s', exit ...\n" | 8197 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -8202,7 +8207,7 @@ msgstr "Không thể lÆ°u táºp tin cấu hình « %s »:" | |||
8202 | msgid "Could not access configuration file `%s'\n" | 8207 | msgid "Could not access configuration file `%s'\n" |
8203 | msgstr "Không thể truy cáºp đến táºp tin gnunet-directory « %s »\n" | 8208 | msgstr "Không thể truy cáºp đến táºp tin gnunet-directory « %s »\n" |
8204 | 8209 | ||
8205 | #: src/transport/transport_api2_communication.c:752 | 8210 | #: src/transport/transport_api2_communication.c:762 |
8206 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 8211 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
8207 | msgstr "" | 8212 | msgstr "" |
8208 | 8213 | ||
@@ -8330,52 +8335,17 @@ msgid "" | |||
8330 | msgstr "" | 8335 | msgstr "" |
8331 | "Cấu hình không thá»a mãn các rà ng buá»™c của táºp tin đặc tả cấu hình « %s ».\n" | 8336 | "Cấu hình không thá»a mãn các rà ng buá»™c của táºp tin đặc tả cấu hình « %s ».\n" |
8332 | 8337 | ||
8333 | #: src/util/configuration.c:786 | 8338 | #: src/util/configuration.c:1073 |
8334 | #, c-format | ||
8335 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8336 | msgstr "" | ||
8337 | |||
8338 | #: src/util/configuration.c:796 | ||
8339 | #, c-format | ||
8340 | msgid "Bad directive in line %u\n" | ||
8341 | msgstr "" | ||
8342 | |||
8343 | #: src/util/configuration.c:852 | ||
8344 | #, c-format | ||
8345 | msgid "Bad inline-secret directive in line %u\n" | ||
8346 | msgstr "" | ||
8347 | |||
8348 | #: src/util/configuration.c:874 | ||
8349 | #, c-format | ||
8350 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8351 | msgstr "" | ||
8352 | |||
8353 | #: src/util/configuration.c:905 | ||
8354 | #, fuzzy, c-format | ||
8355 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8356 | msgstr "Gặp lá»—i cú pháp trong táºp tin cấu hình « %s » tại dòng %d.\n" | ||
8357 | |||
8358 | #: src/util/configuration.c:955 | ||
8359 | #, fuzzy, c-format | ||
8360 | msgid "Syntax error while deserializing in line %u\n" | ||
8361 | msgstr "Gặp lá»—i cú pháp trong táºp tin cấu hình « %s » tại dòng %d.\n" | ||
8362 | |||
8363 | #: src/util/configuration.c:1055 | ||
8364 | #, fuzzy, c-format | ||
8365 | msgid "Error while reading file `%s'\n" | ||
8366 | msgstr "Gặp lỗi khi tải xuống: %s\n" | ||
8367 | |||
8368 | #: src/util/configuration.c:1068 | ||
8369 | #, fuzzy, c-format | 8339 | #, fuzzy, c-format |
8370 | msgid "Failed to parse configuration file `%s'\n" | 8340 | msgid "Failed to parse configuration file `%s'\n" |
8371 | msgstr "Không thể lÆ°u táºp tin cấu hình « %s »:" | 8341 | msgstr "Không thể lÆ°u táºp tin cấu hình « %s »:" |
8372 | 8342 | ||
8373 | #: src/util/configuration.c:1701 | 8343 | #: src/util/configuration.c:1718 |
8374 | #, fuzzy | 8344 | #, fuzzy |
8375 | msgid "Not a valid relative time specification" | 8345 | msgid "Not a valid relative time specification" |
8376 | msgstr "Giá trị cấu hình « %s » cho « %s » trong phần « %s » nên là con số\n" | 8346 | msgstr "Giá trị cấu hình « %s » cho « %s » trong phần « %s » nên là con số\n" |
8377 | 8347 | ||
8378 | #: src/util/configuration.c:1771 | 8348 | #: src/util/configuration.c:1788 |
8379 | #, c-format | 8349 | #, c-format |
8380 | msgid "" | 8350 | msgid "" |
8381 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8351 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
@@ -8384,23 +8354,6 @@ msgstr "" | |||
8384 | "Giá trị cấu hình « %s » cho « %s » trong phần « %s » không phải nằm trong " | 8354 | "Giá trị cấu hình « %s » cho « %s » trong phần « %s » không phải nằm trong " |
8385 | "táºp hợp các sá»± chá»n được phép\n" | 8355 | "táºp hợp các sá»± chá»n được phép\n" |
8386 | 8356 | ||
8387 | #: src/util/configuration.c:1866 | ||
8388 | #, c-format | ||
8389 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8390 | msgstr "" | ||
8391 | |||
8392 | #: src/util/configuration.c:1898 | ||
8393 | #, fuzzy, c-format | ||
8394 | msgid "Missing closing `%s' in option `%s'\n" | ||
8395 | msgstr "Giá trị cấu hình « %s » cho « %s » trong phần « %s » nên là con số\n" | ||
8396 | |||
8397 | #: src/util/configuration.c:1964 | ||
8398 | #, c-format | ||
8399 | msgid "" | ||
8400 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8401 | "as an environmental variable\n" | ||
8402 | msgstr "" | ||
8403 | |||
8404 | #: src/util/configuration_helper.c:134 | 8357 | #: src/util/configuration_helper.c:134 |
8405 | #, c-format | 8358 | #, c-format |
8406 | msgid "The following sections are available:\n" | 8359 | msgid "The following sections are available:\n" |
@@ -8428,12 +8381,12 @@ msgid "" | |||
8428 | "%llu)\n" | 8381 | "%llu)\n" |
8429 | msgstr "" | 8382 | msgstr "" |
8430 | 8383 | ||
8431 | #: src/util/crypto_ecc.c:567 | 8384 | #: src/util/crypto_ecc.c:554 |
8432 | #, fuzzy, c-format | 8385 | #, fuzzy, c-format |
8433 | msgid "ECC signing failed at %s:%d: %s\n" | 8386 | msgid "ECC signing failed at %s:%d: %s\n" |
8434 | msgstr "%s bị lỗi tại %s:%d: « %s »\n" | 8387 | msgstr "%s bị lỗi tại %s:%d: « %s »\n" |
8435 | 8388 | ||
8436 | #: src/util/crypto_ecc.c:689 | 8389 | #: src/util/crypto_ecc.c:677 |
8437 | #, fuzzy, c-format | 8390 | #, fuzzy, c-format |
8438 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8391 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8439 | msgstr "Lỗi thẩm tra chữ ký RSA tại %s:%d: %s\n" | 8392 | msgstr "Lỗi thẩm tra chữ ký RSA tại %s:%d: %s\n" |
@@ -8458,7 +8411,7 @@ msgstr "%s bị lỗi tại %s:%d: « %s »\n" | |||
8458 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8411 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8459 | msgstr "Lỗi thẩm tra chữ ký RSA tại %s:%d: %s\n" | 8412 | msgstr "Lỗi thẩm tra chữ ký RSA tại %s:%d: %s\n" |
8460 | 8413 | ||
8461 | #: src/util/disk.c:842 | 8414 | #: src/util/disk.c:843 |
8462 | #, c-format | 8415 | #, c-format |
8463 | msgid "Expected `%s' to be a directory!\n" | 8416 | msgid "Expected `%s' to be a directory!\n" |
8464 | msgstr "Mong đợi « %s » là một thư mục.\n" | 8417 | msgstr "Mong đợi « %s » là một thư mục.\n" |
@@ -9424,12 +9377,30 @@ msgstr "" | |||
9424 | msgid "Failed to replicate block in namecache: %s\n" | 9377 | msgid "Failed to replicate block in namecache: %s\n" |
9425 | msgstr "Lá»—i cáºp nháºt dữ liệu cho mô-Ä‘un « %s »\n" | 9378 | msgstr "Lá»—i cáºp nháºt dữ liệu cho mô-Ä‘un « %s »\n" |
9426 | 9379 | ||
9427 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9380 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9428 | #, fuzzy | 9381 | #, fuzzy |
9429 | msgid "Failed to connect to the namestore!\n" | 9382 | msgid "Failed to connect to the namestore!\n" |
9430 | msgstr "Không kết nối được đến trình ná»n gnunetd." | 9383 | msgstr "Không kết nối được đến trình ná»n gnunetd." |
9431 | 9384 | ||
9432 | #, fuzzy, c-format | 9385 | #, fuzzy, c-format |
9386 | #~ msgid "" | ||
9387 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9388 | #~ msgstr "Gặp lá»—i cú pháp trong táºp tin cấu hình « %s » tại dòng %d.\n" | ||
9389 | |||
9390 | #, fuzzy, c-format | ||
9391 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9392 | #~ msgstr "Gặp lá»—i cú pháp trong táºp tin cấu hình « %s » tại dòng %d.\n" | ||
9393 | |||
9394 | #, fuzzy, c-format | ||
9395 | #~ msgid "Error while reading file `%s'\n" | ||
9396 | #~ msgstr "Gặp lỗi khi tải xuống: %s\n" | ||
9397 | |||
9398 | #, fuzzy, c-format | ||
9399 | #~ msgid "Missing closing `%s' in option `%s'\n" | ||
9400 | #~ msgstr "" | ||
9401 | #~ "Giá trị cấu hình « %s » cho « %s » trong phần « %s » nên là con số\n" | ||
9402 | |||
9403 | #, fuzzy, c-format | ||
9433 | #~ msgid "Failed to drop database with: `%s'\n" | 9404 | #~ msgid "Failed to drop database with: `%s'\n" |
9434 | #~ msgstr "Lỗi chạy %s: %s %d\n" | 9405 | #~ msgstr "Lỗi chạy %s: %s %d\n" |
9435 | 9406 | ||
diff --git a/po/zh_CN.po b/po/zh_CN.po index 2e3fa988a..66ef53b30 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po | |||
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: gnunet-0.8.1\n" | 8 | "Project-Id-Version: gnunet-0.8.1\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2023-04-01 10:42+0200\n" | 10 | "POT-Creation-Date: 2023-09-10 12:56+0200\n" |
11 | "PO-Revision-Date: 2011-07-09 12:12+0800\n" | 11 | "PO-Revision-Date: 2011-07-09 12:12+0800\n" |
12 | "Last-Translator: Wylmer Wang <wantinghard@gmail.com>\n" | 12 | "Last-Translator: Wylmer Wang <wantinghard@gmail.com>\n" |
13 | "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n" | 13 | "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n" |
@@ -1541,7 +1541,7 @@ msgstr "sqlite æ•°æ®ä»“库" | |||
1541 | #: src/testbed/generate-underlay-topology.c:48 | 1541 | #: src/testbed/generate-underlay-topology.c:48 |
1542 | #: src/testbed/gnunet-daemon-latency-logger.c:53 | 1542 | #: src/testbed/gnunet-daemon-latency-logger.c:53 |
1543 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 | 1543 | #: src/testbed/gnunet-daemon-testbed-underlay.c:57 |
1544 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:78 | 1544 | #: src/testbed/testbed_api_hosts.c:72 src/util/crypto_ecc.c:79 |
1545 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 | 1545 | #: src/util/crypto_ecc_setup.c:48 src/util/crypto_mpi.c:41 |
1546 | #, fuzzy, c-format | 1546 | #, fuzzy, c-format |
1547 | msgid "`%s' failed at %s:%d with error: %s\n" | 1547 | msgid "`%s' failed at %s:%d with error: %s\n" |
@@ -3889,13 +3889,13 @@ msgid "Properly base32-encoded public key required" | |||
3889 | msgstr "“%sâ€çš„å‚æ•°æ— æ•ˆã€‚\n" | 3889 | msgstr "“%sâ€çš„å‚æ•°æ— æ•ˆã€‚\n" |
3890 | 3890 | ||
3891 | #: src/gns/gnunet-service-gns.c:554 | 3891 | #: src/gns/gnunet-service-gns.c:554 |
3892 | #: src/zonemaster/gnunet-service-zonemaster.c:1345 | 3892 | #: src/zonemaster/gnunet-service-zonemaster.c:1348 |
3893 | #, fuzzy | 3893 | #, fuzzy |
3894 | msgid "Failed to connect to the namecache!\n" | 3894 | msgid "Failed to connect to the namecache!\n" |
3895 | msgstr "åˆå§‹åŒ–“%sâ€æœåŠ¡å¤±è´¥ã€‚\n" | 3895 | msgstr "åˆå§‹åŒ–“%sâ€æœåŠ¡å¤±è´¥ã€‚\n" |
3896 | 3896 | ||
3897 | #: src/gns/gnunet-service-gns.c:573 | 3897 | #: src/gns/gnunet-service-gns.c:573 |
3898 | #: src/zonemaster/gnunet-service-zonemaster.c:1384 | 3898 | #: src/zonemaster/gnunet-service-zonemaster.c:1387 |
3899 | #, fuzzy | 3899 | #, fuzzy |
3900 | msgid "Could not connect to DHT!\n" | 3900 | msgid "Could not connect to DHT!\n" |
3901 | msgstr "æ— æ³•è¿žæŽ¥åˆ° %s:%u:%s\n" | 3901 | msgstr "æ— æ³•è¿žæŽ¥åˆ° %s:%u:%s\n" |
@@ -4479,63 +4479,63 @@ msgstr "" | |||
4479 | msgid "Failed to create ego: %s\n" | 4479 | msgid "Failed to create ego: %s\n" |
4480 | msgstr "å‘é€æ¶ˆæ¯å¤±è´¥ã€‚\n" | 4480 | msgstr "å‘é€æ¶ˆæ¯å¤±è´¥ã€‚\n" |
4481 | 4481 | ||
4482 | #: src/identity/gnunet-identity.c:586 | 4482 | #: src/identity/gnunet-identity.c:540 |
4483 | msgid "create ego NAME" | 4483 | msgid "create ego NAME" |
4484 | msgstr "" | 4484 | msgstr "" |
4485 | 4485 | ||
4486 | #: src/identity/gnunet-identity.c:591 | 4486 | #: src/identity/gnunet-identity.c:545 |
4487 | msgid "delete ego NAME " | 4487 | msgid "delete ego NAME " |
4488 | msgstr "" | 4488 | msgstr "" |
4489 | 4489 | ||
4490 | #: src/identity/gnunet-identity.c:597 | 4490 | #: src/identity/gnunet-identity.c:551 |
4491 | msgid "" | 4491 | msgid "" |
4492 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" | 4492 | "set the private key for the identity to PRIVATE_KEY (use together with -C)" |
4493 | msgstr "" | 4493 | msgstr "" |
4494 | 4494 | ||
4495 | #: src/identity/gnunet-identity.c:603 | 4495 | #: src/identity/gnunet-identity.c:557 |
4496 | msgid "" | 4496 | msgid "" |
4497 | "Read and decrypt message encrypted for the given ego (use together with -e " | 4497 | "Read and decrypt message encrypted for the given ego (use together with -e " |
4498 | "EGO)" | 4498 | "EGO)" |
4499 | msgstr "" | 4499 | msgstr "" |
4500 | 4500 | ||
4501 | #: src/identity/gnunet-identity.c:609 | 4501 | #: src/identity/gnunet-identity.c:563 |
4502 | msgid "" | 4502 | msgid "" |
4503 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " | 4503 | "Encrypt and write message for recipient identity PULBIC_KEY, (use together " |
4504 | "with -k RECIPIENT_PUBLIC_KEY)" | 4504 | "with -k RECIPIENT_PUBLIC_KEY)" |
4505 | msgstr "" | 4505 | msgstr "" |
4506 | 4506 | ||
4507 | #: src/identity/gnunet-identity.c:614 | 4507 | #: src/identity/gnunet-identity.c:568 |
4508 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" | 4508 | msgid "generate an EdDSA identity. (use together with -C) EXPERIMENTAL" |
4509 | msgstr "" | 4509 | msgstr "" |
4510 | 4510 | ||
4511 | #: src/identity/gnunet-identity.c:618 | 4511 | #: src/identity/gnunet-identity.c:572 |
4512 | msgid "display all egos" | 4512 | msgid "display all egos" |
4513 | msgstr "" | 4513 | msgstr "" |
4514 | 4514 | ||
4515 | #: src/identity/gnunet-identity.c:622 | 4515 | #: src/identity/gnunet-identity.c:576 |
4516 | msgid "reduce output" | 4516 | msgid "reduce output" |
4517 | msgstr "" | 4517 | msgstr "" |
4518 | 4518 | ||
4519 | #: src/identity/gnunet-identity.c:629 | 4519 | #: src/identity/gnunet-identity.c:583 |
4520 | msgid "" | 4520 | msgid "" |
4521 | "restrict results to NAME (use together with -d) or read and decrypt a " | 4521 | "restrict results to NAME (use together with -d) or read and decrypt a " |
4522 | "message for NAME (use together with -R)" | 4522 | "message for NAME (use together with -R)" |
4523 | msgstr "" | 4523 | msgstr "" |
4524 | 4524 | ||
4525 | #: src/identity/gnunet-identity.c:635 | 4525 | #: src/identity/gnunet-identity.c:589 |
4526 | msgid "The public key of the recipient (with -W)" | 4526 | msgid "The public key of the recipient (with -W)" |
4527 | msgstr "" | 4527 | msgstr "" |
4528 | 4528 | ||
4529 | #: src/identity/gnunet-identity.c:639 | 4529 | #: src/identity/gnunet-identity.c:593 |
4530 | msgid "run in monitor mode egos" | 4530 | msgid "run in monitor mode egos" |
4531 | msgstr "" | 4531 | msgstr "" |
4532 | 4532 | ||
4533 | #: src/identity/gnunet-identity.c:643 | 4533 | #: src/identity/gnunet-identity.c:597 |
4534 | #, fuzzy | 4534 | #, fuzzy |
4535 | msgid "display private keys as well" | 4535 | msgid "display private keys as well" |
4536 | msgstr "显示一个文件的散列值" | 4536 | msgstr "显示一个文件的散列值" |
4537 | 4537 | ||
4538 | #: src/identity/gnunet-identity.c:658 | 4538 | #: src/identity/gnunet-identity.c:612 |
4539 | msgid "Maintain egos" | 4539 | msgid "Maintain egos" |
4540 | msgstr "" | 4540 | msgstr "" |
4541 | 4541 | ||
@@ -6618,17 +6618,17 @@ msgid "" | |||
6618 | "free topology cannot be more than %u. Given `%s = %llu'" | 6618 | "free topology cannot be more than %u. Given `%s = %llu'" |
6619 | msgstr "" | 6619 | msgstr "" |
6620 | 6620 | ||
6621 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2823 | 6621 | #: src/testbed/testbed_api_topology.c:1021 src/testing/testing.c:2795 |
6622 | #, c-format | 6622 | #, c-format |
6623 | msgid "Topology file %s not found\n" | 6623 | msgid "Topology file %s not found\n" |
6624 | msgstr "" | 6624 | msgstr "" |
6625 | 6625 | ||
6626 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2831 | 6626 | #: src/testbed/testbed_api_topology.c:1029 src/testing/testing.c:2803 |
6627 | #, c-format | 6627 | #, c-format |
6628 | msgid "Topology file %s has no data\n" | 6628 | msgid "Topology file %s has no data\n" |
6629 | msgstr "" | 6629 | msgstr "" |
6630 | 6630 | ||
6631 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2839 | 6631 | #: src/testbed/testbed_api_topology.c:1037 src/testing/testing.c:2811 |
6632 | #, c-format | 6632 | #, c-format |
6633 | msgid "Topology file %s cannot be read\n" | 6633 | msgid "Topology file %s cannot be read\n" |
6634 | msgstr "" | 6634 | msgstr "" |
@@ -6833,19 +6833,24 @@ msgstr "" | |||
6833 | msgid "GNUnet topology control" | 6833 | msgid "GNUnet topology control" |
6834 | msgstr "" | 6834 | msgstr "" |
6835 | 6835 | ||
6836 | #: src/transport/gnunet-communicator-tcp.c:3712 | 6836 | #: src/transport/gnunet-communicator-quic.c:1718 |
6837 | #: src/transport/gnunet-communicator-udp.c:3879 | 6837 | #: src/transport/gnunet-communicator-tcp.c:3737 |
6838 | #: src/transport/gnunet-service-tng.c:11393 | 6838 | #: src/transport/gnunet-communicator-udp.c:3363 |
6839 | #: src/transport/gnunet-service-tng.c:11503 | ||
6839 | #: src/transport/gnunet-service-transport.c:2617 | 6840 | #: src/transport/gnunet-service-transport.c:2617 |
6840 | #, fuzzy | 6841 | #, fuzzy |
6841 | msgid "Transport service is lacking key configuration settings. Exiting.\n" | 6842 | msgid "Transport service is lacking key configuration settings. Exiting.\n" |
6842 | msgstr "ç«‹å³ä¿å˜é…置?" | 6843 | msgstr "ç«‹å³ä¿å˜é…置?" |
6843 | 6844 | ||
6844 | #: src/transport/gnunet-communicator-tcp.c:4049 | 6845 | #: src/transport/gnunet-communicator-quic.c:1788 |
6846 | msgid "GNUnet QUIC communicator" | ||
6847 | msgstr "" | ||
6848 | |||
6849 | #: src/transport/gnunet-communicator-tcp.c:4074 | ||
6845 | msgid "GNUnet TCP communicator" | 6850 | msgid "GNUnet TCP communicator" |
6846 | msgstr "" | 6851 | msgstr "" |
6847 | 6852 | ||
6848 | #: src/transport/gnunet-communicator-udp.c:3954 | 6853 | #: src/transport/gnunet-communicator-udp.c:3438 |
6849 | msgid "GNUnet UDP communicator" | 6854 | msgid "GNUnet UDP communicator" |
6850 | msgstr "" | 6855 | msgstr "" |
6851 | 6856 | ||
@@ -7776,7 +7781,7 @@ msgstr "" | |||
7776 | 7781 | ||
7777 | #: src/transport/plugin_transport_wlan.c:1195 | 7782 | #: src/transport/plugin_transport_wlan.c:1195 |
7778 | #: src/transport/plugin_transport_wlan.c:1287 | 7783 | #: src/transport/plugin_transport_wlan.c:1287 |
7779 | #: src/transport/plugin_transport_wlan.c:2325 | 7784 | #: src/transport/plugin_transport_wlan.c:2326 |
7780 | msgid "# MAC endpoints allocated" | 7785 | msgid "# MAC endpoints allocated" |
7781 | msgstr "" | 7786 | msgstr "" |
7782 | 7787 | ||
@@ -7796,16 +7801,16 @@ msgstr "" | |||
7796 | msgid "# DATA messages received" | 7801 | msgid "# DATA messages received" |
7797 | msgstr "" | 7802 | msgstr "" |
7798 | 7803 | ||
7799 | #: src/transport/plugin_transport_wlan.c:1904 | 7804 | #: src/transport/plugin_transport_wlan.c:1905 |
7800 | msgid "# DATA messages processed" | 7805 | msgid "# DATA messages processed" |
7801 | msgstr "" | 7806 | msgstr "" |
7802 | 7807 | ||
7803 | #: src/transport/plugin_transport_wlan.c:2300 | 7808 | #: src/transport/plugin_transport_wlan.c:2301 |
7804 | #, c-format | 7809 | #, c-format |
7805 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" | 7810 | msgid "Helper binary `%s' not SUID, cannot run WLAN transport\n" |
7806 | msgstr "" | 7811 | msgstr "" |
7807 | 7812 | ||
7808 | #: src/transport/plugin_transport_wlan.c:2322 | 7813 | #: src/transport/plugin_transport_wlan.c:2323 |
7809 | msgid "# sessions allocated" | 7814 | msgid "# sessions allocated" |
7810 | msgstr "" | 7815 | msgstr "" |
7811 | 7816 | ||
@@ -7894,7 +7899,7 @@ msgstr "" | |||
7894 | msgid "Service process failed to report status\n" | 7899 | msgid "Service process failed to report status\n" |
7895 | msgstr "" | 7900 | msgstr "" |
7896 | 7901 | ||
7897 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1219 | 7902 | #: src/transport/tcp_service_legacy.c:1253 src/util/disk.c:1222 |
7898 | #: src/util/service.c:1642 | 7903 | #: src/util/service.c:1642 |
7899 | #, c-format | 7904 | #, c-format |
7900 | msgid "Cannot obtain information about user `%s': %s\n" | 7905 | msgid "Cannot obtain information about user `%s': %s\n" |
@@ -7914,7 +7919,7 @@ msgid "do daemonize (detach from terminal)" | |||
7914 | msgstr "" | 7919 | msgstr "" |
7915 | 7920 | ||
7916 | #: src/transport/tcp_service_legacy.c:1397 | 7921 | #: src/transport/tcp_service_legacy.c:1397 |
7917 | #: src/transport/transport-testing-communicator.c:1045 src/util/service.c:2077 | 7922 | #: src/transport/transport-testing-communicator.c:1056 src/util/service.c:2077 |
7918 | #: src/util/service.c:2089 | 7923 | #: src/util/service.c:2089 |
7919 | #, fuzzy, c-format | 7924 | #, fuzzy, c-format |
7920 | msgid "Malformed configuration file `%s', exit ...\n" | 7925 | msgid "Malformed configuration file `%s', exit ...\n" |
@@ -7930,7 +7935,7 @@ msgstr "解æžé…置文件“%sâ€å¤±è´¥\n" | |||
7930 | msgid "Could not access configuration file `%s'\n" | 7935 | msgid "Could not access configuration file `%s'\n" |
7931 | msgstr "找ä¸åˆ°æŽ¥å£â€œ%sâ€çš„一个 IP 地å€ã€‚\n" | 7936 | msgstr "找ä¸åˆ°æŽ¥å£â€œ%sâ€çš„一个 IP 地å€ã€‚\n" |
7932 | 7937 | ||
7933 | #: src/transport/transport_api2_communication.c:752 | 7938 | #: src/transport/transport_api2_communication.c:762 |
7934 | msgid "Dropped backchanel message: handler not provided by communicator\n" | 7939 | msgid "Dropped backchanel message: handler not provided by communicator\n" |
7935 | msgstr "" | 7940 | msgstr "" |
7936 | 7941 | ||
@@ -8056,75 +8061,23 @@ msgid "" | |||
8056 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" | 8061 | "Configuration specifies invalid value for option `%s' in section `%s': %s\n" |
8057 | msgstr "é…ç½®ä¸æ»¡è¶³é…置规范文件“%sâ€çš„约æŸï¼\n" | 8062 | msgstr "é…ç½®ä¸æ»¡è¶³é…置规范文件“%sâ€çš„约æŸï¼\n" |
8058 | 8063 | ||
8059 | #: src/util/configuration.c:786 | 8064 | #: src/util/configuration.c:1073 |
8060 | #, c-format | ||
8061 | msgid "Illegal directive in line %u (parsing restricted section %s)\n" | ||
8062 | msgstr "" | ||
8063 | |||
8064 | #: src/util/configuration.c:796 | ||
8065 | #, c-format | ||
8066 | msgid "Bad directive in line %u\n" | ||
8067 | msgstr "" | ||
8068 | |||
8069 | #: src/util/configuration.c:852 | ||
8070 | #, c-format | ||
8071 | msgid "Bad inline-secret directive in line %u\n" | ||
8072 | msgstr "" | ||
8073 | |||
8074 | #: src/util/configuration.c:874 | ||
8075 | #, c-format | ||
8076 | msgid "Unknown or malformed directive '%s' in line %u\n" | ||
8077 | msgstr "" | ||
8078 | |||
8079 | #: src/util/configuration.c:905 | ||
8080 | #, fuzzy, c-format | ||
8081 | msgid "Syntax error while deserializing in line %u (option without section)\n" | ||
8082 | msgstr "é…置文件“%sâ€ç¬¬ %d 行有è¯æ³•é”™è¯¯ã€‚\n" | ||
8083 | |||
8084 | #: src/util/configuration.c:955 | ||
8085 | #, fuzzy, c-format | ||
8086 | msgid "Syntax error while deserializing in line %u\n" | ||
8087 | msgstr "é…置文件“%sâ€ç¬¬ %d 行有è¯æ³•é”™è¯¯ã€‚\n" | ||
8088 | |||
8089 | #: src/util/configuration.c:1055 | ||
8090 | #, fuzzy, c-format | ||
8091 | msgid "Error while reading file `%s'\n" | ||
8092 | msgstr "è§£æž dscl 输出时出错。\n" | ||
8093 | |||
8094 | #: src/util/configuration.c:1068 | ||
8095 | #, fuzzy, c-format | 8065 | #, fuzzy, c-format |
8096 | msgid "Failed to parse configuration file `%s'\n" | 8066 | msgid "Failed to parse configuration file `%s'\n" |
8097 | msgstr "解æžé…置文件“%sâ€å¤±è´¥\n" | 8067 | msgstr "解æžé…置文件“%sâ€å¤±è´¥\n" |
8098 | 8068 | ||
8099 | #: src/util/configuration.c:1701 | 8069 | #: src/util/configuration.c:1718 |
8100 | #, fuzzy | 8070 | #, fuzzy |
8101 | msgid "Not a valid relative time specification" | 8071 | msgid "Not a valid relative time specification" |
8102 | msgstr "é…置文件“%sâ€å·²å†™å…¥ã€‚\n" | 8072 | msgstr "é…置文件“%sâ€å·²å†™å…¥ã€‚\n" |
8103 | 8073 | ||
8104 | #: src/util/configuration.c:1771 | 8074 | #: src/util/configuration.c:1788 |
8105 | #, c-format | 8075 | #, c-format |
8106 | msgid "" | 8076 | msgid "" |
8107 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " | 8077 | "Configuration value '%s' for '%s' in section '%s' is not in set of legal " |
8108 | "choices\n" | 8078 | "choices\n" |
8109 | msgstr "" | 8079 | msgstr "" |
8110 | 8080 | ||
8111 | #: src/util/configuration.c:1866 | ||
8112 | #, c-format | ||
8113 | msgid "Recursive expansion suspected, aborting $-expansion for term `%s'\n" | ||
8114 | msgstr "" | ||
8115 | |||
8116 | #: src/util/configuration.c:1898 | ||
8117 | #, fuzzy, c-format | ||
8118 | msgid "Missing closing `%s' in option `%s'\n" | ||
8119 | msgstr "é…置文件“%sâ€å·²å†™å…¥ã€‚\n" | ||
8120 | |||
8121 | #: src/util/configuration.c:1964 | ||
8122 | #, c-format | ||
8123 | msgid "" | ||
8124 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined " | ||
8125 | "as an environmental variable\n" | ||
8126 | msgstr "" | ||
8127 | |||
8128 | #: src/util/configuration_helper.c:134 | 8081 | #: src/util/configuration_helper.c:134 |
8129 | #, c-format | 8082 | #, c-format |
8130 | msgid "The following sections are available:\n" | 8083 | msgid "The following sections are available:\n" |
@@ -8152,12 +8105,12 @@ msgid "" | |||
8152 | "%llu)\n" | 8105 | "%llu)\n" |
8153 | msgstr "" | 8106 | msgstr "" |
8154 | 8107 | ||
8155 | #: src/util/crypto_ecc.c:567 | 8108 | #: src/util/crypto_ecc.c:554 |
8156 | #, fuzzy, c-format | 8109 | #, fuzzy, c-format |
8157 | msgid "ECC signing failed at %s:%d: %s\n" | 8110 | msgid "ECC signing failed at %s:%d: %s\n" |
8158 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" | 8111 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" |
8159 | 8112 | ||
8160 | #: src/util/crypto_ecc.c:689 | 8113 | #: src/util/crypto_ecc.c:677 |
8161 | #, fuzzy, c-format | 8114 | #, fuzzy, c-format |
8162 | msgid "ECDSA signature verification failed at %s:%d: %s\n" | 8115 | msgid "ECDSA signature verification failed at %s:%d: %s\n" |
8163 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" | 8116 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" |
@@ -8182,7 +8135,7 @@ msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" | |||
8182 | msgid "RSA signature verification failed at %s:%d: %s\n" | 8135 | msgid "RSA signature verification failed at %s:%d: %s\n" |
8183 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" | 8136 | msgstr "对驱动器“%2$sâ€çš„“%1$sâ€æ“作失败:%3$u\n" |
8184 | 8137 | ||
8185 | #: src/util/disk.c:842 | 8138 | #: src/util/disk.c:843 |
8186 | #, c-format | 8139 | #, c-format |
8187 | msgid "Expected `%s' to be a directory!\n" | 8140 | msgid "Expected `%s' to be a directory!\n" |
8188 | msgstr "“%sâ€åº”为目录ï¼\n" | 8141 | msgstr "“%sâ€åº”为目录ï¼\n" |
@@ -9129,12 +9082,29 @@ msgstr "" | |||
9129 | msgid "Failed to replicate block in namecache: %s\n" | 9082 | msgid "Failed to replicate block in namecache: %s\n" |
9130 | msgstr "å‘é€æ¶ˆæ¯å¤±è´¥ã€‚\n" | 9083 | msgstr "å‘é€æ¶ˆæ¯å¤±è´¥ã€‚\n" |
9131 | 9084 | ||
9132 | #: src/zonemaster/gnunet-service-zonemaster.c:1332 | 9085 | #: src/zonemaster/gnunet-service-zonemaster.c:1335 |
9133 | #, fuzzy | 9086 | #, fuzzy |
9134 | msgid "Failed to connect to the namestore!\n" | 9087 | msgid "Failed to connect to the namestore!\n" |
9135 | msgstr "åˆå§‹åŒ–“%sâ€æœåŠ¡å¤±è´¥ã€‚\n" | 9088 | msgstr "åˆå§‹åŒ–“%sâ€æœåŠ¡å¤±è´¥ã€‚\n" |
9136 | 9089 | ||
9137 | #, fuzzy, c-format | 9090 | #, fuzzy, c-format |
9091 | #~ msgid "" | ||
9092 | #~ "Syntax error while deserializing in line %u (option without section)\n" | ||
9093 | #~ msgstr "é…置文件“%sâ€ç¬¬ %d 行有è¯æ³•é”™è¯¯ã€‚\n" | ||
9094 | |||
9095 | #, fuzzy, c-format | ||
9096 | #~ msgid "Syntax error while deserializing in line %u\n" | ||
9097 | #~ msgstr "é…置文件“%sâ€ç¬¬ %d 行有è¯æ³•é”™è¯¯ã€‚\n" | ||
9098 | |||
9099 | #, fuzzy, c-format | ||
9100 | #~ msgid "Error while reading file `%s'\n" | ||
9101 | #~ msgstr "è§£æž dscl 输出时出错。\n" | ||
9102 | |||
9103 | #, fuzzy, c-format | ||
9104 | #~ msgid "Missing closing `%s' in option `%s'\n" | ||
9105 | #~ msgstr "é…置文件“%sâ€å·²å†™å…¥ã€‚\n" | ||
9106 | |||
9107 | #, fuzzy, c-format | ||
9138 | #~ msgid "Failed to drop database with: `%s'\n" | 9108 | #~ msgid "Failed to drop database with: `%s'\n" |
9139 | #~ msgstr "è¿è¡Œ %s失败:%s %d\n" | 9109 | #~ msgstr "è¿è¡Œ %s失败:%s %d\n" |
9140 | 9110 | ||
diff --git a/src/Makefile.am b/src/Makefile.am index d7c0b51f0..8fb984d4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -25,10 +25,6 @@ if HAVE_SQLITE | |||
25 | SQLITE_DIR = sq | 25 | SQLITE_DIR = sq |
26 | endif | 26 | endif |
27 | 27 | ||
28 | if HAVE_MYSQL | ||
29 | MYSQL_DIR = mysql my | ||
30 | endif | ||
31 | |||
32 | if HAVE_POSTGRESQL | 28 | if HAVE_POSTGRESQL |
33 | POSTGRES_DIR = pq | 29 | POSTGRES_DIR = pq |
34 | endif | 30 | endif |
@@ -50,7 +46,6 @@ SUBDIRS = \ | |||
50 | $(REST_DIR) \ | 46 | $(REST_DIR) \ |
51 | peerinfo \ | 47 | peerinfo \ |
52 | $(SQLITE_DIR) \ | 48 | $(SQLITE_DIR) \ |
53 | $(MYSQL_DIR) \ | ||
54 | $(POSTGRES_DIR) \ | 49 | $(POSTGRES_DIR) \ |
55 | datacache \ | 50 | datacache \ |
56 | datastore \ | 51 | datastore \ |
diff --git a/src/arm/meson.build b/src/arm/meson.build new file mode 100644 index 000000000..9943c32f9 --- /dev/null +++ b/src/arm/meson.build | |||
@@ -0,0 +1,71 @@ | |||
1 | libgnunetarm_src = ['arm_api.c', | ||
2 | 'arm_monitor_api.c'] | ||
3 | |||
4 | gnunetservicearm_src = ['gnunet-service-arm.c'] | ||
5 | |||
6 | gnunetarm_src = ['gnunet-arm.c'] | ||
7 | |||
8 | testarmapi_src = ['test_arm_api.c'] | ||
9 | testexpbo_src = ['test_exponential_backoff.c'] | ||
10 | testgnunetservice_src = ['test_gnunet_service_arm.c'] | ||
11 | |||
12 | configure_file(input : 'arm.conf.in', | ||
13 | output : 'arm.conf', | ||
14 | configuration : cdata, | ||
15 | install: true, | ||
16 | install_dir: pkgcfgdir) | ||
17 | |||
18 | if get_option('monolith') | ||
19 | foreach p : libgnunetarm_src + gnunetservicearm_src | ||
20 | gnunet_src += 'arm/' + p | ||
21 | endforeach | ||
22 | subdir_done() | ||
23 | endif | ||
24 | |||
25 | libgnunetarm = library('gnunetarm', | ||
26 | libgnunetarm_src, | ||
27 | dependencies: libgnunetutil_dep, | ||
28 | version: '2.0.0', | ||
29 | soversion: '2', | ||
30 | include_directories: [incdir, configuration_inc], | ||
31 | install: true, | ||
32 | install_dir: get_option('libdir')) | ||
33 | pkg.generate(libgnunetarm, url: 'https://www.gnunet.org', | ||
34 | description : 'Provides API for accessing the Automated Restart Manager service') | ||
35 | libgnunetarm_dep = declare_dependency(link_with : libgnunetarm) | ||
36 | executable ('gnunet-arm', | ||
37 | gnunetarm_src, | ||
38 | dependencies: [libgnunetarm_dep, libgnunetutil_dep], | ||
39 | include_directories: [incdir, configuration_inc], | ||
40 | install: true, | ||
41 | install_dir: get_option('bindir')) | ||
42 | executable ('gnunet-service-arm', | ||
43 | gnunetservicearm_src, | ||
44 | dependencies: [libgnunetarm_dep, libgnunetutil_dep], | ||
45 | include_directories: [incdir, configuration_inc], | ||
46 | install: true, | ||
47 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
48 | testarmapi = executable ('test_arm_api', | ||
49 | testarmapi_src, | ||
50 | dependencies: [libgnunetarm_dep, libgnunetutil_dep], | ||
51 | include_directories: [incdir, configuration_inc], | ||
52 | install: false) | ||
53 | testexpbo = executable ('test_exponential_backoff', | ||
54 | testexpbo_src, | ||
55 | dependencies: [libgnunetarm_dep, libgnunetutil_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: false) | ||
58 | testgnunetservice = executable ('test_gnunet_service', | ||
59 | testgnunetservice_src, | ||
60 | dependencies: [libgnunetarm_dep, libgnunetutil_dep], | ||
61 | include_directories: [incdir, configuration_inc], | ||
62 | install: false) | ||
63 | configure_file(copy: true, | ||
64 | input: 'test_arm_api_data.conf', | ||
65 | output: 'test_arm_api_data.conf') | ||
66 | test('test_arm_api', testarmapi, workdir: meson.current_source_dir(), | ||
67 | suite: 'arm') | ||
68 | # FIXME this test currently times out/fails. | ||
69 | #test('test_exponential_backoff', testexpbo, workdir: meson.current_source_dir()) | ||
70 | test('test_gnunet_service', testgnunetservice, workdir: meson.current_source_dir(), | ||
71 | suite: 'arm') | ||
diff --git a/src/ats-tool/meson.build b/src/ats-tool/meson.build new file mode 100644 index 000000000..6b6df7b3d --- /dev/null +++ b/src/ats-tool/meson.build | |||
@@ -0,0 +1,15 @@ | |||
1 | if get_option('monolith') | ||
2 | subdir_done() | ||
3 | endif | ||
4 | |||
5 | executable ('gnunet-ats', | ||
6 | ['gnunet-ats.c'], | ||
7 | dependencies: [libgnunetats_dep, libgnunetutil_dep, | ||
8 | libgnunettransport_dep, | ||
9 | libgnunetnt_dep, | ||
10 | libgnunethello_dep | ||
11 | ], | ||
12 | include_directories: [incdir, configuration_inc], | ||
13 | install: true, | ||
14 | install_dir: get_option('bindir')) | ||
15 | |||
diff --git a/src/ats/meson.build b/src/ats/meson.build new file mode 100644 index 000000000..4aa4e6972 --- /dev/null +++ b/src/ats/meson.build | |||
@@ -0,0 +1,58 @@ | |||
1 | libgnunetats_src = ['ats_api_connectivity.c', | ||
2 | 'ats_api_scheduling.c', | ||
3 | 'ats_api_scanner.c', | ||
4 | 'ats_api_performance.c'] | ||
5 | |||
6 | gnunetserviceats_src = ['gnunet-service-ats.c', | ||
7 | 'gnunet-service-ats_addresses.c', | ||
8 | 'gnunet-service-ats_connectivity.c', | ||
9 | 'gnunet-service-ats_normalization.c', | ||
10 | 'gnunet-service-ats_performance.c', | ||
11 | 'gnunet-service-ats_plugins.c', | ||
12 | 'gnunet-service-ats_preferences.c', | ||
13 | 'gnunet-service-ats_scheduling.c', | ||
14 | 'gnunet-service-ats_reservations.c'] | ||
15 | |||
16 | configure_file(input : 'ats.conf.in', | ||
17 | output : 'ats.conf', | ||
18 | configuration : cdata, | ||
19 | install: true, | ||
20 | install_dir: pkgcfgdir) | ||
21 | |||
22 | if get_option('monolith') | ||
23 | foreach p : libgnunetats_src + gnunetserviceats_src | ||
24 | gnunet_src += 'ats/' + p | ||
25 | endforeach | ||
26 | subdir_done() | ||
27 | endif | ||
28 | |||
29 | libgnunetats = library('gnunetats', | ||
30 | libgnunetats_src, | ||
31 | version: '4.0.0', | ||
32 | soversion: '4', | ||
33 | dependencies: [libgnunetutil_dep, libgnunethello_dep], | ||
34 | include_directories: [incdir, configuration_inc], | ||
35 | install: true, | ||
36 | install_dir: get_option('libdir')) | ||
37 | pkg.generate(libgnunetats, url : 'https://www.gnunet.org', | ||
38 | description : 'Provides API for allocating bandwidth, expressing preferences for certain peers and accessing allocation information') | ||
39 | libgnunetats_dep = declare_dependency(link_with : libgnunetats) | ||
40 | |||
41 | shared_module('gnunet_plugin_ats_proportional', | ||
42 | ['plugin_ats_proportional.c'], | ||
43 | dependencies: [libgnunetutil_dep, | ||
44 | libgnunetats_dep, | ||
45 | libgnunetstatistics_dep, | ||
46 | libgnunetnt_dep, | ||
47 | libgnunetstatistics_dep], | ||
48 | include_directories: [incdir, configuration_inc], | ||
49 | install: true, | ||
50 | install_dir: get_option('libdir')/'gnunet') | ||
51 | |||
52 | executable ('gnunet-service-ats', | ||
53 | gnunetserviceats_src, | ||
54 | dependencies: [libgnunetats_dep, libgnunetutil_dep, | ||
55 | libgnunetnt_dep, libgnunetstatistics_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
diff --git a/src/block/meson.build b/src/block/meson.build new file mode 100644 index 000000000..b9bde48f6 --- /dev/null +++ b/src/block/meson.build | |||
@@ -0,0 +1,47 @@ | |||
1 | libgnunetblock_src = ['block.c'] | ||
2 | libgnunetblockgroup_src = ['bg_bf.c'] | ||
3 | |||
4 | if get_option('monolith') | ||
5 | foreach p : libgnunetblock_src + libgnunetblockgroup_src | ||
6 | gnunet_src += 'block/' + p | ||
7 | endforeach | ||
8 | subdir_done() | ||
9 | endif | ||
10 | |||
11 | libgnunetblock = library('gnunetblock', | ||
12 | libgnunetblock_src, | ||
13 | dependencies: libgnunetutil_dep, | ||
14 | include_directories: [incdir, configuration_inc], | ||
15 | install: true, | ||
16 | version: '0.0.0', | ||
17 | soversion: '0', | ||
18 | install_dir: get_option('libdir')) | ||
19 | libgnunetblock_dep = declare_dependency(link_with : libgnunetblock) | ||
20 | pkg.generate(libgnunetblock, url: 'https://www.gnunet.org', | ||
21 | description : 'Library for data block manipulation') | ||
22 | |||
23 | libgnunetblockgroup = library('gnunetblockgroup', | ||
24 | libgnunetblockgroup_src, | ||
25 | dependencies: [libgnunetutil_dep, libgnunetblock_dep], | ||
26 | include_directories: [incdir, configuration_inc], | ||
27 | install: true, | ||
28 | version: '0.0.0', | ||
29 | soversion: '0', | ||
30 | install_dir: get_option('libdir')) | ||
31 | libgnunetblockgroup_dep = declare_dependency(link_with : libgnunetblockgroup) | ||
32 | |||
33 | plugin_dep = [libgnunetutil_dep, libgnunetblock_dep, libgnunetblockgroup_dep] | ||
34 | shared_module('gnunet_plugin_block_test', | ||
35 | ['plugin_block_test.c'], | ||
36 | dependencies: plugin_dep, | ||
37 | include_directories: [incdir, configuration_inc], | ||
38 | install: true, | ||
39 | install_dir: get_option('libdir')/'gnunet') | ||
40 | |||
41 | shared_module('gnunet_plugin_block_template', | ||
42 | ['plugin_block_template.c'], | ||
43 | dependencies: plugin_dep, | ||
44 | include_directories: [incdir, configuration_inc], | ||
45 | install: false, | ||
46 | install_dir: get_option('libdir')/'gnunet') | ||
47 | |||
diff --git a/src/cadet/meson.build b/src/cadet/meson.build new file mode 100644 index 000000000..91587590d --- /dev/null +++ b/src/cadet/meson.build | |||
@@ -0,0 +1,75 @@ | |||
1 | libgnunetcadet_src = ['cadet_api.c', | ||
2 | 'cadet_api_drop_message.c', | ||
3 | 'cadet_api_get_channel.c', | ||
4 | 'cadet_api_get_path.c', | ||
5 | 'cadet_api_list_peers.c', | ||
6 | 'cadet_api_list_tunnels.c', | ||
7 | 'cadet_api_helper.c'] | ||
8 | |||
9 | gnunetcadet_src = ['gnunet-cadet.c'] | ||
10 | gnunetservicecadet_src = ['gnunet-service-cadet.c', | ||
11 | 'gnunet-service-cadet_channel.c', | ||
12 | 'gnunet-service-cadet_connection.c', | ||
13 | 'gnunet-service-cadet_core.c', | ||
14 | 'gnunet-service-cadet_dht.c', | ||
15 | 'gnunet-service-cadet_hello.c', | ||
16 | 'gnunet-service-cadet_tunnels.c', | ||
17 | 'gnunet-service-cadet_paths.c', | ||
18 | 'gnunet-service-cadet_peer.c'] | ||
19 | |||
20 | configure_file(input : 'cadet.conf.in', | ||
21 | output : 'cadet.conf', | ||
22 | configuration : cdata, | ||
23 | install: true, | ||
24 | install_dir: pkgcfgdir) | ||
25 | |||
26 | if get_option('monolith') | ||
27 | foreach p : libgnunetcadet_src + gnunetservicecadet_src | ||
28 | gnunet_src += 'cadet/' + p | ||
29 | endforeach | ||
30 | endif | ||
31 | |||
32 | libgnunetcadet = library('gnunetcadet', | ||
33 | libgnunetcadet_src, | ||
34 | dependencies: libgnunetutil_dep, | ||
35 | include_directories: [incdir, configuration_inc], | ||
36 | install: true, | ||
37 | soversion: '7', | ||
38 | version: '7.0.0', | ||
39 | install_dir: get_option('libdir')) | ||
40 | libgnunetcadet_dep = declare_dependency(link_with : libgnunetcadet) | ||
41 | pkg.generate(libgnunetcadet, url: 'https://www.gnunet.org', | ||
42 | description : 'API for multicast and multi-hop routing between GNUnet peers') | ||
43 | |||
44 | executable ('gnunet-cadet', | ||
45 | gnunetservicecadet_src, | ||
46 | dependencies: [libgnunetcadet_dep, | ||
47 | libgnunetutil_dep, | ||
48 | libgnunetcore_dep, | ||
49 | libgnunetdht_dep, | ||
50 | m_dep, | ||
51 | libgnunetstatistics_dep, | ||
52 | libgnunetpeerinfo_dep, | ||
53 | libgnunetats_dep, | ||
54 | libgnunettransport_dep, | ||
55 | libgnunethello_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('bindir')) | ||
59 | executable ('gnunet-service-cadet', | ||
60 | gnunetservicecadet_src, | ||
61 | dependencies: [libgnunetcadet_dep, | ||
62 | libgnunetutil_dep, | ||
63 | libgnunetats_dep, | ||
64 | m_dep, | ||
65 | libgnunetcore_dep, | ||
66 | libgnunetdht_dep, | ||
67 | libgnunetstatistics_dep, | ||
68 | libgnunettransport_dep, | ||
69 | libgnunetpeerinfo_dep, | ||
70 | libgnunethello_dep, | ||
71 | libgnunetblock_dep], | ||
72 | include_directories: [incdir, configuration_inc], | ||
73 | install: true, | ||
74 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
75 | |||
diff --git a/src/consensus/meson.build b/src/consensus/meson.build new file mode 100644 index 000000000..b67017ab3 --- /dev/null +++ b/src/consensus/meson.build | |||
@@ -0,0 +1,48 @@ | |||
1 | libgnunetconsensus_src = ['consensus_api.c'] | ||
2 | |||
3 | gnunetserviceconsensus_src = ['gnunet-service-consensus.c'] | ||
4 | |||
5 | configure_file(input : 'consensus.conf.in', | ||
6 | output : 'consensus.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | if get_option('monolith') | ||
12 | foreach p : libgnunetconsensus_src + gnunetserviceconsensus_src | ||
13 | gnunet_src += 'consensus/' + p | ||
14 | endforeach | ||
15 | subdir_done() | ||
16 | endif | ||
17 | |||
18 | libgnunetconsensus = shared_library('gnunetconsensus', | ||
19 | libgnunetconsensus_src, | ||
20 | soversion: '0', | ||
21 | version: '0.0.0', | ||
22 | dependencies: libgnunetutil_dep, | ||
23 | include_directories: [incdir, configuration_inc], | ||
24 | install: true, | ||
25 | install_dir: get_option('libdir')) | ||
26 | pkg.generate(libgnunetconsensus, url: 'https://www.gnunet.org', | ||
27 | description : 'Provides API for accessing the consensus service') | ||
28 | libgnunetarm_dep = declare_dependency(link_with : libgnunetarm) | ||
29 | libgnunetconsensus_dep = declare_dependency(link_with : libgnunetconsensus) | ||
30 | |||
31 | shared_module('gnunet_plugin_block_consensus', | ||
32 | ['plugin_block_consensus.c'], | ||
33 | dependencies: [libgnunetutil_dep, | ||
34 | libgnunetblock_dep], | ||
35 | include_directories: [incdir, configuration_inc], | ||
36 | install:true, | ||
37 | install_dir: get_option('libdir')/'gnunet') | ||
38 | |||
39 | executable ('gnunet-service-consensus', | ||
40 | gnunetserviceconsensus_src, | ||
41 | dependencies: [libgnunetconsensus_dep, | ||
42 | libgnunetutil_dep, | ||
43 | libgnunetset_dep, | ||
44 | libgnunetstatistics_dep], | ||
45 | include_directories: [incdir, configuration_inc], | ||
46 | install: true, | ||
47 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
48 | |||
diff --git a/src/conversation/meson.build b/src/conversation/meson.build new file mode 100644 index 000000000..95d27072c --- /dev/null +++ b/src/conversation/meson.build | |||
@@ -0,0 +1,96 @@ | |||
1 | libgnunetconversation_src = ['conversation_api.c', 'conversation_api_call.c'] | ||
2 | |||
3 | gnunetserviceconversation_src = ['gnunet-service-conversation.c', | ||
4 | 'gnunet-service-conversation_resolver.c', | ||
5 | 'gnunet-service-conversation_interceptor.c'] | ||
6 | |||
7 | gnunetconversationproxy_src = ['gnunet-conversation-proxy.c'] | ||
8 | |||
9 | configure_file(input : 'conversation.conf.in', | ||
10 | output : 'conversation.conf', | ||
11 | configuration : cdata, | ||
12 | install: true, | ||
13 | install_dir: pkgcfgdir) | ||
14 | |||
15 | |||
16 | if get_option('monolith') | ||
17 | foreach p : libgnunetconversation_src + gnunetserviceconversation_src | ||
18 | gnunet_src += 'conversation/' + p | ||
19 | endforeach | ||
20 | subdir_done() | ||
21 | endif | ||
22 | |||
23 | libgnunetmicrophone = library('gnunetmicrophone', | ||
24 | ['microphone.c'], | ||
25 | soversion: '0', | ||
26 | version: '0.0.0', | ||
27 | dependencies: [libgnunetutil_dep], | ||
28 | include_directories: [incdir, configuration_inc], | ||
29 | install: true, | ||
30 | install_dir: get_option('libdir')) | ||
31 | libgnunetmicrophone_dep = declare_dependency(link_with : libgnunetmicrophone) | ||
32 | pkg.generate(libgnunetmicrophone, url: 'https://www.gnunet.org', | ||
33 | description : 'Provides API to access to microphone') | ||
34 | |||
35 | libgnunetspeaker = library('gnunetspeaker', | ||
36 | ['speaker.c'], | ||
37 | soversion: '0', | ||
38 | version: '0.0.0', | ||
39 | dependencies: [libgnunetutil_dep], | ||
40 | include_directories: [incdir, configuration_inc], | ||
41 | install: true, | ||
42 | install_dir: get_option('libdir')) | ||
43 | libgnunetspeaker_dep = declare_dependency(link_with : libgnunetspeaker) | ||
44 | pkg.generate(libgnunetspeaker, url: 'https://www.gnunet.org', | ||
45 | description : 'Provides API to access to speaker') | ||
46 | |||
47 | libgnunetconversation = library('gnunetconversation', | ||
48 | libgnunetconversation_src, | ||
49 | soversion: '0', | ||
50 | version: '0.0.0', | ||
51 | dependencies: [libgnunetutil_dep, | ||
52 | libgnunetgnsrecord_dep, | ||
53 | libgnunetgns_dep, | ||
54 | libgnunetnamestore_dep, | ||
55 | libgnunetidentity_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('libdir')) | ||
59 | libgnunetconversation_dep = declare_dependency(link_with : libgnunetconversation) | ||
60 | pkg.generate(libgnunetconversation, url: 'https://www.gnunet.org', | ||
61 | description : 'Provides API to access to conversation') | ||
62 | |||
63 | shared_module('gnunet_plugin_gnsrecord_conversation', | ||
64 | ['plugin_gnsrecord_conversation.c'], | ||
65 | dependencies: [libgnunetutil_dep, | ||
66 | libgnunetconversation_dep, | ||
67 | libgnunetgns_dep, | ||
68 | libgnunetgnsrecord_dep, | ||
69 | libgnunetidentity_dep], | ||
70 | include_directories: [incdir, configuration_inc], | ||
71 | install: true, | ||
72 | install_dir: get_option('libdir')/'gnunet') | ||
73 | |||
74 | executable ('gnunet-conversation', | ||
75 | 'gnunet-conversation.c', | ||
76 | dependencies: [libgnunetconversation_dep, | ||
77 | libgnunetgns_dep, | ||
78 | libgnunetgnsrecord_dep, | ||
79 | libgnunetnamestore_dep, | ||
80 | libgnunetspeaker_dep, | ||
81 | libgnunetmicrophone_dep, | ||
82 | libgnunetidentity_dep, | ||
83 | libgnunetutil_dep], | ||
84 | include_directories: [incdir, configuration_inc], | ||
85 | install: true, | ||
86 | install_dir: get_option('bindir')) | ||
87 | executable ('gnunet-service-conversation', | ||
88 | gnunetserviceconversation_src, | ||
89 | dependencies: [libgnunetconversation_dep, | ||
90 | libgnunetspeaker_dep, | ||
91 | libgnunetmicrophone_dep, | ||
92 | libgnunetidentity_dep, | ||
93 | libgnunetcadet_dep], | ||
94 | include_directories: [incdir, configuration_inc], | ||
95 | install: true, | ||
96 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
diff --git a/src/core/meson.build b/src/core/meson.build new file mode 100644 index 000000000..cdc5fe99a --- /dev/null +++ b/src/core/meson.build | |||
@@ -0,0 +1,49 @@ | |||
1 | libgnunetcore_src = ['core_api.c', | ||
2 | 'core_api_monitor_peers.c'] | ||
3 | |||
4 | gnunetservicecore_src = ['gnunet-service-core.c', | ||
5 | 'gnunet-service-core_kx.c', | ||
6 | 'gnunet-service-core_sessions.c', | ||
7 | 'gnunet-service-core_typemap.c'] | ||
8 | |||
9 | configure_file(input : 'core.conf.in', | ||
10 | output : 'core.conf', | ||
11 | configuration : cdata, | ||
12 | install: true, | ||
13 | install_dir: pkgcfgdir) | ||
14 | |||
15 | |||
16 | if get_option('monolith') | ||
17 | foreach p : libgnunetcore_src + gnunetservicecore_src | ||
18 | gnunet_src += 'core/' + p | ||
19 | endforeach | ||
20 | endif | ||
21 | |||
22 | libgnunetcore = library('gnunetcore', | ||
23 | libgnunetcore_src, | ||
24 | dependencies: libgnunetutil_dep, | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | soversion: '0', | ||
28 | version: '0.0.1', | ||
29 | install_dir: get_option('libdir')) | ||
30 | libgnunetcore_dep = declare_dependency(link_with : libgnunetcore) | ||
31 | pkg.generate(libgnunetcore, url: 'https://www.gnunet.org', | ||
32 | description : 'Provides API for (encrypted) P2P communication') | ||
33 | |||
34 | executable ('gnunet-core', | ||
35 | ['gnunet-core.c'], | ||
36 | dependencies: [libgnunetcore_dep, libgnunetutil_dep], | ||
37 | include_directories: [incdir, configuration_inc], | ||
38 | install: true, | ||
39 | install_dir: get_option('bindir')) | ||
40 | |||
41 | executable ('gnunet-service-core', | ||
42 | gnunetservicecore_src, | ||
43 | dependencies: [libgnunetcore_dep, libgnunetutil_dep, | ||
44 | libgnunetstatistics_dep, | ||
45 | libgnunettransport_dep, | ||
46 | zlib_dep], | ||
47 | include_directories: [incdir, configuration_inc], | ||
48 | install: true, | ||
49 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
diff --git a/src/curl/curl.c b/src/curl/curl.c index 68c99dd75..648c9a14e 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c | |||
@@ -285,7 +285,7 @@ GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx, | |||
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | int | 288 | enum GNUNET_GenericReturnValue |
289 | GNUNET_CURL_is_valid_scope_id (const char *scope_id) | 289 | GNUNET_CURL_is_valid_scope_id (const char *scope_id) |
290 | { | 290 | { |
291 | if (strlen (scope_id) >= 64) | 291 | if (strlen (scope_id) >= 64) |
@@ -669,6 +669,8 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
669 | GNUNET_break (0); | 669 | GNUNET_break (0); |
670 | *response_code = 0; | 670 | *response_code = 0; |
671 | } | 671 | } |
672 | if (MHD_HTTP_NO_CONTENT == *response_code) | ||
673 | return NULL; | ||
672 | if ((CURLE_OK != | 674 | if ((CURLE_OK != |
673 | curl_easy_getinfo (eh, | 675 | curl_easy_getinfo (eh, |
674 | CURLINFO_CONTENT_TYPE, | 676 | CURLINFO_CONTENT_TYPE, |
@@ -679,14 +681,21 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
679 | /* No content type or explicitly not JSON, refuse to parse | 681 | /* No content type or explicitly not JSON, refuse to parse |
680 | (but keep response code) */ | 682 | (but keep response code) */ |
681 | if (0 != db->buf_size) | 683 | if (0 != db->buf_size) |
684 | { | ||
685 | char *url; | ||
686 | |||
687 | if (CURLE_OK != | ||
688 | curl_easy_getinfo (eh, | ||
689 | CURLINFO_EFFECTIVE_URL, | ||
690 | &url)) | ||
691 | url = "<unknown URL>"; | ||
682 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 692 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
683 | "Did NOT detect response `%.*s' as JSON\n", | 693 | "Request to `%s' was expected to return a body of type `application/json', got `%s'\n", |
684 | (int) db->buf_size, | 694 | url, |
685 | (const char *) db->buf); | 695 | ct); |
696 | } | ||
686 | return NULL; | 697 | return NULL; |
687 | } | 698 | } |
688 | if (MHD_HTTP_NO_CONTENT == *response_code) | ||
689 | return NULL; | ||
690 | if (0 == *response_code) | 699 | if (0 == *response_code) |
691 | { | 700 | { |
692 | char *url; | 701 | char *url; |
diff --git a/src/curl/meson.build b/src/curl/meson.build new file mode 100644 index 000000000..dd38843a8 --- /dev/null +++ b/src/curl/meson.build | |||
@@ -0,0 +1,19 @@ | |||
1 | libgnunetcurl_src = ['curl.c', | ||
2 | 'curl_reschedule.c'] | ||
3 | |||
4 | if get_option('monolith') | ||
5 | foreach p : libgnunetcurl_src | ||
6 | gnunet_src += 'curl/' + p | ||
7 | endforeach | ||
8 | endif | ||
9 | |||
10 | libgnunetcurl = library('gnunetcurl', | ||
11 | libgnunetcurl_src, | ||
12 | soversion: '0', | ||
13 | version: '0.0.0', | ||
14 | dependencies: [libgnunetutil_dep, curl_dep, json_dep], | ||
15 | include_directories: [incdir, configuration_inc], | ||
16 | install: true, | ||
17 | install_dir: get_option('libdir')) | ||
18 | libgnunetcurl_dep = declare_dependency(link_with : libgnunetcurl) | ||
19 | |||
diff --git a/src/datacache/meson.build b/src/datacache/meson.build new file mode 100644 index 000000000..ae57161cd --- /dev/null +++ b/src/datacache/meson.build | |||
@@ -0,0 +1,58 @@ | |||
1 | libgnunetdatacache_src = ['datacache.c'] | ||
2 | |||
3 | configure_file(input : 'datacache.conf', | ||
4 | output : 'datacache.conf', | ||
5 | configuration : cdata, | ||
6 | install: true, | ||
7 | install_dir: pkgcfgdir) | ||
8 | install_data ('datacache-0001.sql', | ||
9 | 'datacache-drop.sql', | ||
10 | install_dir: get_option('datadir')/'gnunet'/'sql') | ||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetdatacache_src | ||
14 | gnunet_src += 'datacache/' + p | ||
15 | endforeach | ||
16 | endif | ||
17 | |||
18 | libgnunetdatacache = library('gnunetdatacache', | ||
19 | libgnunetdatacache_src, | ||
20 | soversion: '0', | ||
21 | version: '0.0.1', | ||
22 | dependencies: [libgnunetutil_dep, libgnunetstatistics_dep], | ||
23 | include_directories: [incdir, configuration_inc], | ||
24 | install: true, | ||
25 | install_dir: get_option('libdir')) | ||
26 | libgnunetdatacache_dep = declare_dependency(link_with : libgnunetdatacache) | ||
27 | pkg.generate(libgnunetdatacache, url: 'https://www.gnunet.org', | ||
28 | description : 'Provides datacache API for temporary storage to disk') | ||
29 | |||
30 | shared_module('gnunet_plugin_datacache_sqlite', | ||
31 | ['plugin_datacache_sqlite.c'], | ||
32 | dependencies: [libgnunetutil_dep, | ||
33 | libgnunetdatacache_dep, | ||
34 | sqlite_dep, | ||
35 | libgnunetsq_dep], | ||
36 | include_directories: [incdir, configuration_inc], | ||
37 | install: true, | ||
38 | install_dir: get_option('libdir')/'gnunet') | ||
39 | shared_module('gnunet_plugin_datacache_heap', | ||
40 | ['plugin_datacache_heap.c'], | ||
41 | dependencies: [libgnunetutil_dep, | ||
42 | libgnunetdatacache_dep], | ||
43 | include_directories: [incdir, configuration_inc], | ||
44 | install: true, | ||
45 | install_dir: get_option('libdir')/'gnunet') | ||
46 | |||
47 | |||
48 | if pq_dep.found() | ||
49 | shared_module('gnunet_plugin_datacache_postgres', | ||
50 | ['plugin_datacache_postgres.c'], | ||
51 | dependencies: [libgnunetutil_dep, | ||
52 | libgnunetdatacache_dep, | ||
53 | pq_dep, | ||
54 | libgnunetpq_dep], | ||
55 | include_directories: [incdir, configuration_inc], | ||
56 | install: true, | ||
57 | install_dir: get_option('libdir')/'gnunet') | ||
58 | endif | ||
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 84bc4a852..adbb958cc 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c | |||
@@ -160,7 +160,7 @@ main (int argc, char *argv[]) | |||
160 | GNUNET_log_setup ("perf-datacache", | 160 | GNUNET_log_setup ("perf-datacache", |
161 | "WARNING", | 161 | "WARNING", |
162 | NULL); | 162 | NULL); |
163 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 163 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
164 | GNUNET_snprintf (cfg_name, sizeof(cfg_name), "perf_datacache_data_%s.conf", | 164 | GNUNET_snprintf (cfg_name, sizeof(cfg_name), "perf_datacache_data_%s.conf", |
165 | plugin_name); | 165 | plugin_name); |
166 | GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv, | 166 | GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv, |
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index 5392f6b17..a97a3f33c 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c | |||
@@ -182,7 +182,7 @@ main (int argc, char *argv[]) | |||
182 | GNUNET_log_setup ("test-datacache", | 182 | GNUNET_log_setup ("test-datacache", |
183 | "WARNING", | 183 | "WARNING", |
184 | NULL); | 184 | NULL); |
185 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 185 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
186 | GNUNET_snprintf (cfg_name, | 186 | GNUNET_snprintf (cfg_name, |
187 | sizeof(cfg_name), | 187 | sizeof(cfg_name), |
188 | "test_datacache_data_%s.conf", | 188 | "test_datacache_data_%s.conf", |
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index 0ad7fb8a4..2cdff8083 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c | |||
@@ -170,7 +170,7 @@ main (int argc, | |||
170 | "WARNING", | 170 | "WARNING", |
171 | NULL); | 171 | NULL); |
172 | 172 | ||
173 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 173 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
174 | GNUNET_snprintf (cfg_name, | 174 | GNUNET_snprintf (cfg_name, |
175 | sizeof(cfg_name), | 175 | sizeof(cfg_name), |
176 | "test_datacache_data_%s.conf", | 176 | "test_datacache_data_%s.conf", |
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index b73a0497b..595c7da3d 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am | |||
@@ -56,19 +56,6 @@ gnunet_datastore_LDADD = \ | |||
56 | $(GN_LIBINTL) | 56 | $(GN_LIBINTL) |
57 | 57 | ||
58 | 58 | ||
59 | if HAVE_MYSQL | ||
60 | MYSQL_PLUGIN = libgnunet_plugin_datastore_mysql.la | ||
61 | if HAVE_BENCHMARKS | ||
62 | MYSQL_BENCHMARKS = \ | ||
63 | perf_datastore_api_mysql \ | ||
64 | perf_plugin_datastore_mysql | ||
65 | endif | ||
66 | MYSQL_TESTS = \ | ||
67 | test_datastore_api_mysql \ | ||
68 | test_datastore_api_management_mysql \ | ||
69 | test_plugin_datastore_mysql \ | ||
70 | $(MYSQL_BENCHMARKS) | ||
71 | endif | ||
72 | if HAVE_SQLITE | 59 | if HAVE_SQLITE |
73 | SQLITE_PLUGIN = libgnunet_plugin_datastore_sqlite.la | 60 | SQLITE_PLUGIN = libgnunet_plugin_datastore_sqlite.la |
74 | if HAVE_BENCHMARKS | 61 | if HAVE_BENCHMARKS |
@@ -98,7 +85,6 @@ endif | |||
98 | 85 | ||
99 | plugin_LTLIBRARIES = \ | 86 | plugin_LTLIBRARIES = \ |
100 | $(SQLITE_PLUGIN) \ | 87 | $(SQLITE_PLUGIN) \ |
101 | $(MYSQL_PLUGIN) \ | ||
102 | $(POSTGRES_PLUGIN) \ | 88 | $(POSTGRES_PLUGIN) \ |
103 | libgnunet_plugin_datastore_heap.la | 89 | libgnunet_plugin_datastore_heap.la |
104 | 90 | ||
@@ -128,18 +114,6 @@ libgnunet_plugin_datastore_heap_la_LDFLAGS = \ | |||
128 | $(GN_PLUGIN_LDFLAGS) | 114 | $(GN_PLUGIN_LDFLAGS) |
129 | 115 | ||
130 | 116 | ||
131 | libgnunet_plugin_datastore_mysql_la_SOURCES = \ | ||
132 | plugin_datastore_mysql.c | ||
133 | libgnunet_plugin_datastore_mysql_la_LIBADD = \ | ||
134 | $(top_builddir)/src/my/libgnunetmy.la \ | ||
135 | $(top_builddir)/src/mysql/libgnunetmysql.la \ | ||
136 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
137 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) $(Z_LIBS) -lmysqlclient | ||
138 | libgnunet_plugin_datastore_mysql_la_LDFLAGS = \ | ||
139 | $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient | ||
140 | libgnunet_plugin_datastore_mysql_la_CPPFLAGS = \ | ||
141 | $(MYSQL_CPPFLAGS) $(AM_CPPFLAGS) | ||
142 | |||
143 | libgnunet_plugin_datastore_postgres_la_SOURCES = \ | 117 | libgnunet_plugin_datastore_postgres_la_SOURCES = \ |
144 | plugin_datastore_postgres.c | 118 | plugin_datastore_postgres.c |
145 | libgnunet_plugin_datastore_postgres_la_LIBADD = \ | 119 | libgnunet_plugin_datastore_postgres_la_LIBADD = \ |
@@ -167,7 +141,6 @@ check_PROGRAMS = \ | |||
167 | perf_plugin_datastore_heap \ | 141 | perf_plugin_datastore_heap \ |
168 | test_plugin_datastore_heap \ | 142 | test_plugin_datastore_heap \ |
169 | $(SQLITE_TESTS) \ | 143 | $(SQLITE_TESTS) \ |
170 | $(MYSQL_TESTS) \ | ||
171 | $(POSTGRES_TESTS) | 144 | $(POSTGRES_TESTS) |
172 | 145 | ||
173 | if ENABLE_TEST_RUN | 146 | if ENABLE_TEST_RUN |
@@ -243,40 +216,6 @@ test_plugin_datastore_sqlite_LDADD = \ | |||
243 | $(top_builddir)/src/util/libgnunetutil.la | 216 | $(top_builddir)/src/util/libgnunetutil.la |
244 | 217 | ||
245 | 218 | ||
246 | test_datastore_api_mysql_SOURCES = \ | ||
247 | test_datastore_api.c | ||
248 | test_datastore_api_mysql_LDADD = \ | ||
249 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
250 | libgnunetdatastore.la \ | ||
251 | $(top_builddir)/src/util/libgnunetutil.la | ||
252 | |||
253 | test_datastore_api_management_mysql_SOURCES = \ | ||
254 | test_datastore_api_management.c | ||
255 | test_datastore_api_management_mysql_LDADD = \ | ||
256 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
257 | libgnunetdatastore.la \ | ||
258 | $(top_builddir)/src/util/libgnunetutil.la | ||
259 | |||
260 | perf_datastore_api_mysql_SOURCES = \ | ||
261 | perf_datastore_api.c | ||
262 | perf_datastore_api_mysql_LDADD = \ | ||
263 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
264 | libgnunetdatastore.la \ | ||
265 | $(top_builddir)/src/util/libgnunetutil.la | ||
266 | |||
267 | test_plugin_datastore_mysql_SOURCES = \ | ||
268 | test_plugin_datastore.c | ||
269 | test_plugin_datastore_mysql_LDADD = \ | ||
270 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
271 | $(top_builddir)/src/util/libgnunetutil.la | ||
272 | |||
273 | perf_plugin_datastore_mysql_SOURCES = \ | ||
274 | perf_plugin_datastore.c | ||
275 | perf_plugin_datastore_mysql_LDADD = \ | ||
276 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
277 | $(top_builddir)/src/util/libgnunetutil.la | ||
278 | |||
279 | |||
280 | test_datastore_api_postgres_SOURCES = \ | 219 | test_datastore_api_postgres_SOURCES = \ |
281 | test_datastore_api.c | 220 | test_datastore_api.c |
282 | test_datastore_api_postgres_LDADD = \ | 221 | test_datastore_api_postgres_LDADD = \ |
@@ -319,9 +258,6 @@ EXTRA_DIST = \ | |||
319 | test_datastore_api_data_heap.conf \ | 258 | test_datastore_api_data_heap.conf \ |
320 | perf_plugin_datastore_data_heap.conf \ | 259 | perf_plugin_datastore_data_heap.conf \ |
321 | test_plugin_datastore_data_heap.conf \ | 260 | test_plugin_datastore_data_heap.conf \ |
322 | test_datastore_api_data_mysql.conf \ | ||
323 | perf_plugin_datastore_data_mysql.conf \ | ||
324 | test_plugin_datastore_data_mysql.conf \ | ||
325 | test_datastore_api_data_postgres.conf \ | 261 | test_datastore_api_data_postgres.conf \ |
326 | perf_plugin_datastore_data_postgres.conf \ | 262 | perf_plugin_datastore_data_postgres.conf \ |
327 | test_plugin_datastore_data_postgres.conf \ | 263 | test_plugin_datastore_data_postgres.conf \ |
diff --git a/src/datastore/meson.build b/src/datastore/meson.build new file mode 100644 index 000000000..2f412e183 --- /dev/null +++ b/src/datastore/meson.build | |||
@@ -0,0 +1,81 @@ | |||
1 | libgnunetdatastore_src = ['datastore_api.c'] | ||
2 | |||
3 | gnunetservicedatastore_src = ['gnunet-service-datastore.c'] | ||
4 | |||
5 | configure_file(input : 'datastore.conf.in', | ||
6 | output : 'datastore.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | install_data ('datastore-0001.sql', | ||
12 | 'datastore-drop.sql', | ||
13 | install_dir: get_option('datadir')/'gnunet'/'sql') | ||
14 | |||
15 | if get_option('monolith') | ||
16 | foreach p : libgnunetdatastore_src + gnunetservicedatastore_src | ||
17 | gnunet_src += 'datastore/' + p | ||
18 | endforeach | ||
19 | endif | ||
20 | libgnunetdatastore = library('gnunetdatastore', | ||
21 | libgnunetdatastore_src, | ||
22 | soversion: '1', | ||
23 | version: '1.0.0', | ||
24 | dependencies: [libgnunetutil_dep, | ||
25 | libgnunetstatistics_dep, | ||
26 | libgnunetdatacache_dep], | ||
27 | include_directories: [incdir, configuration_inc], | ||
28 | install: true, | ||
29 | install_dir: get_option('libdir')) | ||
30 | libgnunetdatastore_dep = declare_dependency(link_with : libgnunetdatastore) | ||
31 | pkg.generate(libgnunetdatastore, url: 'https://www.gnunet.org', | ||
32 | description : 'Management API for the datastore for persistent storage to disk') | ||
33 | |||
34 | shared_module('gnunet_plugin_datastore_sqlite', | ||
35 | ['plugin_datastore_sqlite.c'], | ||
36 | dependencies: [libgnunetutil_dep, | ||
37 | libgnunetdatastore_dep, | ||
38 | sqlite_dep, | ||
39 | libgnunetsq_dep], | ||
40 | include_directories: [incdir, configuration_inc], | ||
41 | install: true, | ||
42 | install_dir: get_option('libdir')/'gnunet') | ||
43 | shared_module('gnunet_plugin_datastore_heap', | ||
44 | ['plugin_datastore_heap.c'], | ||
45 | dependencies: [libgnunetutil_dep, | ||
46 | libgnunetdatacache_dep], | ||
47 | include_directories: [incdir, configuration_inc], | ||
48 | install: true, | ||
49 | install_dir: get_option('libdir')/'gnunet') | ||
50 | |||
51 | if pq_dep.found() | ||
52 | shared_module('gnunet_plugin_datastore_postgres', | ||
53 | ['plugin_datastore_postgres.c'], | ||
54 | dependencies: [libgnunetutil_dep, | ||
55 | libgnunetdatastore_dep, | ||
56 | pq_dep, | ||
57 | libgnunetpq_dep], | ||
58 | include_directories: [incdir, configuration_inc], | ||
59 | install: true, | ||
60 | install_dir: get_option('libdir')/'gnunet') | ||
61 | endif | ||
62 | |||
63 | executable ('gnunet-datastore', | ||
64 | ['gnunet-datastore.c'], | ||
65 | dependencies: [libgnunetdatastore_dep, | ||
66 | libgnunetutil_dep, | ||
67 | libgnunetstatistics_dep, | ||
68 | libgnunetdatacache_dep], | ||
69 | include_directories: [incdir, configuration_inc], | ||
70 | install: true, | ||
71 | install_dir: get_option('bindir')) | ||
72 | executable ('gnunet-service-datastore', | ||
73 | gnunetservicedatastore_src, | ||
74 | dependencies: [libgnunetdatastore_dep, | ||
75 | libgnunetutil_dep, | ||
76 | libgnunetstatistics_dep, | ||
77 | libgnunetdatacache_dep], | ||
78 | include_directories: [incdir, configuration_inc], | ||
79 | install: true, | ||
80 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
81 | |||
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index fef38891e..f7d9fa544 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -610,7 +610,7 @@ main (int argc, | |||
610 | { | 610 | { |
611 | char cfg_name[PATH_MAX]; | 611 | char cfg_name[PATH_MAX]; |
612 | 612 | ||
613 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 613 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
614 | GNUNET_snprintf (cfg_name, | 614 | GNUNET_snprintf (cfg_name, |
615 | sizeof(cfg_name), | 615 | sizeof(cfg_name), |
616 | "test_datastore_api_data_%s.conf", | 616 | "test_datastore_api_data_%s.conf", |
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index d7488d4e7..8e63b08e6 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -550,7 +550,7 @@ main (int argc, char *argv[]) | |||
550 | GNUNET_GETOPT_OPTION_END | 550 | GNUNET_GETOPT_OPTION_END |
551 | }; | 551 | }; |
552 | 552 | ||
553 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 553 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
554 | GNUNET_snprintf (dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s", | 554 | GNUNET_snprintf (dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s", |
555 | plugin_name); | 555 | plugin_name); |
556 | GNUNET_DISK_directory_remove (dir_name); | 556 | GNUNET_DISK_directory_remove (dir_name); |
diff --git a/src/datastore/perf_plugin_datastore_data_mysql.conf b/src/datastore/perf_plugin_datastore_data_mysql.conf deleted file mode 100644 index a32b830c3..000000000 --- a/src/datastore/perf_plugin_datastore_data_mysql.conf +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | @INLINE@ test_defaults.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = $GNUNET_TMP/perf-gnunet-datastore-mysql/ | ||
4 | |||
5 | [datastore] | ||
6 | DATABASE = mysql | ||
7 | |||
8 | [datastore-mysql] | ||
9 | DATABASE = gnunetcheck | ||
10 | |||
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c deleted file mode 100644 index f62c51778..000000000 --- a/src/datastore/plugin_datastore_mysql.c +++ /dev/null | |||
@@ -1,1204 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file datastore/plugin_datastore_mysql.c | ||
23 | * @brief mysql-based datastore backend | ||
24 | * @author Igor Wronsky | ||
25 | * @author Christian Grothoff | ||
26 | * @author Christophe Genevey | ||
27 | * | ||
28 | * NOTE: This db module does NOT work with mysql prior to 4.1 since | ||
29 | * it uses prepared statements. MySQL 5.0.46 promises to fix a bug | ||
30 | * in MyISAM that is causing us grief. At the time of this writing, | ||
31 | * that version is yet to be released. In anticipation, the code | ||
32 | * will use MyISAM with 5.0.46 (and higher). If you run such a | ||
33 | * version, please run "make check" to verify that the MySQL bug | ||
34 | * was actually fixed in your version (and if not, change the | ||
35 | * code below to use MyISAM for gn071). | ||
36 | * | ||
37 | * HIGHLIGHTS | ||
38 | * | ||
39 | * Pros | ||
40 | * + On up-to-date hardware where mysql can be used comfortably, this | ||
41 | * module will have better performance than the other db choices | ||
42 | * (according to our tests). | ||
43 | * + Its often possible to recover the mysql database from internal | ||
44 | * inconsistencies. The other db choices do not support repair! | ||
45 | * Cons | ||
46 | * - Memory usage (Comment: "I have 1G and it never caused me trouble") | ||
47 | * - Manual setup | ||
48 | * | ||
49 | * MANUAL SETUP INSTRUCTIONS | ||
50 | * | ||
51 | * 1) in gnunet.conf, set | ||
52 | * @verbatim | ||
53 | [datastore] | ||
54 | DATABASE = "mysql" | ||
55 | @endverbatim | ||
56 | * 2) Then access mysql as root, | ||
57 | * @verbatim | ||
58 | $ mysql -u root -p | ||
59 | @endverbatim | ||
60 | * and do the following. [You should replace $USER with the username | ||
61 | * that will be running the gnunetd process]. | ||
62 | * @verbatim | ||
63 | CREATE DATABASE gnunet; | ||
64 | GRANT select,insert,update,delete,create,alter,drop,create temporary tables | ||
65 | ON gnunet.* TO $USER@localhost; | ||
66 | SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like'); | ||
67 | FLUSH PRIVILEGES; | ||
68 | @endverbatim | ||
69 | * 3) In the $HOME directory of $USER, create a ".my.cnf" file | ||
70 | * with the following lines | ||
71 | * @verbatim | ||
72 | [client] | ||
73 | user=$USER | ||
74 | password=$the_password_you_like | ||
75 | @endverbatim | ||
76 | * | ||
77 | * That's it. Note that .my.cnf file is a security risk unless its on | ||
78 | * a safe partition etc. The $HOME/.my.cnf can of course be a symbolic | ||
79 | * link. Even greater security risk can be achieved by setting no | ||
80 | * password for $USER. Luckily $USER has only privileges to mess | ||
81 | * up GNUnet's tables, nothing else (unless you give them more, | ||
82 | * of course).<p> | ||
83 | * | ||
84 | * 4) Still, perhaps you should briefly try if the DB connection | ||
85 | * works. First, login as $USER. Then use, | ||
86 | * | ||
87 | * @verbatim | ||
88 | $ mysql -u $USER -p $the_password_you_like | ||
89 | mysql> use gnunet; | ||
90 | @endverbatim | ||
91 | * | ||
92 | * If you get the message "Database changed" it probably works. | ||
93 | * | ||
94 | * [If you get "ERROR 2002: Can't connect to local MySQL server | ||
95 | * through socket '/tmp/mysql.sock' (2)" it may be resolvable by | ||
96 | * "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock" | ||
97 | * so there may be some additional trouble depending on your mysql setup.] | ||
98 | * | ||
99 | * REPAIRING TABLES | ||
100 | * | ||
101 | * - Its probably healthy to check your tables for inconsistencies | ||
102 | * every now and then. | ||
103 | * - If you get odd SEGVs on gnunetd startup, it might be that the mysql | ||
104 | * databases have been corrupted. | ||
105 | * - The tables can be verified/fixed in two ways; | ||
106 | * 1) by running mysqlcheck -A, or | ||
107 | * 2) by executing (inside of mysql using the GNUnet database): | ||
108 | * @verbatim | ||
109 | mysql> REPAIR TABLE gn090; | ||
110 | @endverbatim | ||
111 | * | ||
112 | * PROBLEMS? | ||
113 | * | ||
114 | * If you have problems related to the mysql module, your best | ||
115 | * friend is probably the mysql manual. The first thing to check | ||
116 | * is that mysql is basically operational, that you can connect | ||
117 | * to it, create tables, issue queries etc. | ||
118 | */ | ||
119 | |||
120 | #include "platform.h" | ||
121 | #include "gnunet_datastore_plugin.h" | ||
122 | #include "gnunet_util_lib.h" | ||
123 | #include "gnunet_mysql_lib.h" | ||
124 | #include "gnunet_mysql_compat.h" | ||
125 | #include "gnunet_my_lib.h" | ||
126 | |||
127 | #define MAX_DATUM_SIZE 65536 | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Context for all functions in this plugin. | ||
132 | */ | ||
133 | struct Plugin | ||
134 | { | ||
135 | /** | ||
136 | * Our execution environment. | ||
137 | */ | ||
138 | struct GNUNET_DATASTORE_PluginEnvironment *env; | ||
139 | |||
140 | /** | ||
141 | * Handle to talk to MySQL. | ||
142 | */ | ||
143 | struct GNUNET_MYSQL_Context *mc; | ||
144 | |||
145 | /** | ||
146 | * Prepared statements. | ||
147 | */ | ||
148 | #define INSERT_ENTRY \ | ||
149 | "INSERT INTO gn090 (repl,type,prio,anonLevel,expire,rvalue,hash,vhash,value) VALUES (?,?,?,?,?,?,?,?,?)" | ||
150 | struct GNUNET_MYSQL_StatementHandle *insert_entry; | ||
151 | |||
152 | #define DELETE_ENTRY_BY_UID "DELETE FROM gn090 WHERE uid=?" | ||
153 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_uid; | ||
154 | |||
155 | #define DELETE_ENTRY_BY_HASH_VALUE "DELETE FROM gn090 " \ | ||
156 | "WHERE hash = ? AND " \ | ||
157 | "value = ? " \ | ||
158 | "LIMIT 1" | ||
159 | struct GNUNET_MYSQL_StatementHandle *delete_entry_by_hash_value; | ||
160 | |||
161 | #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, uid" | ||
162 | |||
163 | #define SELECT_ENTRY "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
164 | "WHERE uid >= ? AND " \ | ||
165 | "(rvalue >= ? OR 0 = ?) " \ | ||
166 | "ORDER BY uid LIMIT 1" | ||
167 | struct GNUNET_MYSQL_StatementHandle *select_entry; | ||
168 | |||
169 | #define SELECT_ENTRY_BY_HASH "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
170 | "FORCE INDEX (idx_hash_type_uid) " \ | ||
171 | "WHERE hash=? AND " \ | ||
172 | "uid >= ? AND " \ | ||
173 | "(rvalue >= ? OR 0 = ?) " \ | ||
174 | "ORDER BY uid LIMIT 1" | ||
175 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash; | ||
176 | |||
177 | #define SELECT_ENTRY_BY_HASH_AND_TYPE "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
178 | "FORCE INDEX (idx_hash_type_uid) " \ | ||
179 | "WHERE hash = ? AND " \ | ||
180 | "type = ? AND " \ | ||
181 | "uid >= ? AND " \ | ||
182 | "(rvalue >= ? OR 0 = ?) " \ | ||
183 | "ORDER BY uid LIMIT 1" | ||
184 | struct GNUNET_MYSQL_StatementHandle *select_entry_by_hash_and_type; | ||
185 | |||
186 | #define UPDATE_ENTRY "UPDATE gn090 SET " \ | ||
187 | "prio = prio + ?, " \ | ||
188 | "repl = repl + ?, " \ | ||
189 | "expire = GREATEST(expire, ?) " \ | ||
190 | "WHERE hash = ? AND vhash = ?" | ||
191 | struct GNUNET_MYSQL_StatementHandle *update_entry; | ||
192 | |||
193 | #define DEC_REPL "UPDATE gn090 SET repl=GREATEST (1, repl) - 1 WHERE uid=?" | ||
194 | struct GNUNET_MYSQL_StatementHandle *dec_repl; | ||
195 | |||
196 | #define SELECT_SIZE "SELECT SUM(LENGTH(value)+256) FROM gn090" | ||
197 | struct GNUNET_MYSQL_StatementHandle *get_size; | ||
198 | |||
199 | #define SELECT_IT_NON_ANONYMOUS "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
200 | "FORCE INDEX (idx_anonLevel_type_rvalue) " \ | ||
201 | "WHERE anonLevel=0 AND " \ | ||
202 | "type=? AND " \ | ||
203 | "uid >= ? " \ | ||
204 | "ORDER BY uid LIMIT 1" | ||
205 | struct GNUNET_MYSQL_StatementHandle *zero_iter; | ||
206 | |||
207 | #define SELECT_IT_EXPIRATION "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
208 | "FORCE INDEX (idx_expire) " \ | ||
209 | "WHERE expire < ? " \ | ||
210 | "ORDER BY expire ASC LIMIT 1" | ||
211 | struct GNUNET_MYSQL_StatementHandle *select_expiration; | ||
212 | |||
213 | #define SELECT_IT_PRIORITY "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
214 | "FORCE INDEX (idx_prio) " \ | ||
215 | "ORDER BY prio ASC LIMIT 1" | ||
216 | struct GNUNET_MYSQL_StatementHandle *select_priority; | ||
217 | |||
218 | #define SELECT_IT_REPLICATION "SELECT " RESULT_COLUMNS " FROM gn090 " \ | ||
219 | "FORCE INDEX (idx_repl_rvalue) " \ | ||
220 | "WHERE repl=? AND " \ | ||
221 | " (rvalue>=? OR" \ | ||
222 | " NOT EXISTS (SELECT 1 FROM gn090 FORCE INDEX (idx_repl_rvalue) WHERE repl=? AND rvalue>=?)) " \ | ||
223 | "ORDER BY rvalue ASC " \ | ||
224 | "LIMIT 1" | ||
225 | struct GNUNET_MYSQL_StatementHandle *select_replication; | ||
226 | |||
227 | #define SELECT_MAX_REPL "SELECT MAX(repl) FROM gn090" | ||
228 | struct GNUNET_MYSQL_StatementHandle *max_repl; | ||
229 | |||
230 | #define GET_ALL_KEYS "SELECT hash from gn090" | ||
231 | struct GNUNET_MYSQL_StatementHandle *get_all_keys; | ||
232 | }; | ||
233 | |||
234 | #define MAX_PARAM 16 | ||
235 | |||
236 | /** | ||
237 | * Delete an entry from the gn090 table. | ||
238 | * | ||
239 | * @param plugin plugin context | ||
240 | * @param uid unique ID of the entry to delete | ||
241 | * @return #GNUNET_OK on success, #GNUNET_NO if no such value exists, #GNUNET_SYSERR on error | ||
242 | */ | ||
243 | static int | ||
244 | do_delete_entry (struct Plugin *plugin, | ||
245 | unsigned long long uid) | ||
246 | { | ||
247 | int ret; | ||
248 | uint64_t uid64 = (uint64_t) uid; | ||
249 | struct GNUNET_MY_QueryParam params_delete[] = { | ||
250 | GNUNET_MY_query_param_uint64 (&uid64), | ||
251 | GNUNET_MY_query_param_end | ||
252 | }; | ||
253 | |||
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
255 | "Deleting value %llu from gn090 table\n", | ||
256 | uid); | ||
257 | ret = GNUNET_MY_exec_prepared (plugin->mc, | ||
258 | plugin->delete_entry_by_uid, | ||
259 | params_delete); | ||
260 | if (ret >= 0) | ||
261 | { | ||
262 | return GNUNET_OK; | ||
263 | } | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
265 | "Deleting value %llu from gn090 table failed\n", | ||
266 | (unsigned long long) uid); | ||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | |||
271 | /** | ||
272 | * Get an estimate of how much space the database is | ||
273 | * currently using. | ||
274 | * | ||
275 | * @param cls our `struct Plugin *` | ||
276 | * @return number of bytes used on disk | ||
277 | */ | ||
278 | static void | ||
279 | mysql_plugin_estimate_size (void *cls, | ||
280 | unsigned long long *estimate) | ||
281 | { | ||
282 | struct Plugin *plugin = cls; | ||
283 | uint64_t total; | ||
284 | int ret; | ||
285 | struct GNUNET_MY_QueryParam params_get[] = { | ||
286 | GNUNET_MY_query_param_end | ||
287 | }; | ||
288 | struct GNUNET_MY_ResultSpec results_get[] = { | ||
289 | GNUNET_MY_result_spec_uint64 (&total), | ||
290 | GNUNET_MY_result_spec_end | ||
291 | }; | ||
292 | |||
293 | ret = GNUNET_MY_exec_prepared (plugin->mc, | ||
294 | plugin->get_size, | ||
295 | params_get); | ||
296 | *estimate = 0; | ||
297 | total = UINT64_MAX; | ||
298 | if ((GNUNET_OK == ret) && | ||
299 | (GNUNET_OK == | ||
300 | GNUNET_MY_extract_result (plugin->get_size, | ||
301 | results_get))) | ||
302 | { | ||
303 | *estimate = (unsigned long long) total; | ||
304 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
305 | "Size estimate for MySQL payload is %lld\n", | ||
306 | (long long) total); | ||
307 | GNUNET_assert (UINT64_MAX != total); | ||
308 | GNUNET_break (GNUNET_NO == | ||
309 | GNUNET_MY_extract_result (plugin->get_size, | ||
310 | NULL)); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | |||
315 | /** | ||
316 | * Store an item in the datastore. | ||
317 | * | ||
318 | * @param cls closure | ||
319 | * @param key key for the item | ||
320 | * @param absent true if the key was not found in the bloom filter | ||
321 | * @param size number of bytes in @a data | ||
322 | * @param data content stored | ||
323 | * @param type type of the content | ||
324 | * @param priority priority of the content | ||
325 | * @param anonymity anonymity-level for the content | ||
326 | * @param replication replication-level for the content | ||
327 | * @param expiration expiration time for the content | ||
328 | * @param cont continuation called with success or failure status | ||
329 | * @param cont_cls closure for @a cont | ||
330 | */ | ||
331 | static void | ||
332 | mysql_plugin_put (void *cls, | ||
333 | const struct GNUNET_HashCode *key, | ||
334 | bool absent, | ||
335 | uint32_t size, | ||
336 | const void *data, | ||
337 | enum GNUNET_BLOCK_Type type, | ||
338 | uint32_t priority, | ||
339 | uint32_t anonymity, | ||
340 | uint32_t replication, | ||
341 | struct GNUNET_TIME_Absolute expiration, | ||
342 | PluginPutCont cont, | ||
343 | void *cont_cls) | ||
344 | { | ||
345 | struct Plugin *plugin = cls; | ||
346 | uint64_t lexpiration = expiration.abs_value_us; | ||
347 | struct GNUNET_HashCode vhash; | ||
348 | |||
349 | GNUNET_CRYPTO_hash (data, | ||
350 | size, | ||
351 | &vhash); | ||
352 | if (! absent) | ||
353 | { | ||
354 | struct GNUNET_MY_QueryParam params_update[] = { | ||
355 | GNUNET_MY_query_param_uint32 (&priority), | ||
356 | GNUNET_MY_query_param_uint32 (&replication), | ||
357 | GNUNET_MY_query_param_uint64 (&lexpiration), | ||
358 | GNUNET_MY_query_param_auto_from_type (key), | ||
359 | GNUNET_MY_query_param_auto_from_type (&vhash), | ||
360 | GNUNET_MY_query_param_end | ||
361 | }; | ||
362 | |||
363 | if (GNUNET_OK != | ||
364 | GNUNET_MY_exec_prepared (plugin->mc, | ||
365 | plugin->update_entry, | ||
366 | params_update)) | ||
367 | { | ||
368 | cont (cont_cls, | ||
369 | key, | ||
370 | size, | ||
371 | GNUNET_SYSERR, | ||
372 | _ ("MySQL statement run failure")); | ||
373 | return; | ||
374 | } | ||
375 | |||
376 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt (plugin->update_entry); | ||
377 | my_ulonglong rows = mysql_stmt_affected_rows (stmt); | ||
378 | |||
379 | GNUNET_break (GNUNET_NO == | ||
380 | GNUNET_MY_extract_result (plugin->update_entry, | ||
381 | NULL)); | ||
382 | if (0 != rows) | ||
383 | { | ||
384 | cont (cont_cls, | ||
385 | key, | ||
386 | size, | ||
387 | GNUNET_NO, | ||
388 | NULL); | ||
389 | return; | ||
390 | } | ||
391 | } | ||
392 | |||
393 | uint64_t lrvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
394 | UINT64_MAX); | ||
395 | struct GNUNET_MY_QueryParam params_insert[] = { | ||
396 | GNUNET_MY_query_param_uint32 (&replication), | ||
397 | GNUNET_MY_query_param_uint32 (&type), | ||
398 | GNUNET_MY_query_param_uint32 (&priority), | ||
399 | GNUNET_MY_query_param_uint32 (&anonymity), | ||
400 | GNUNET_MY_query_param_uint64 (&lexpiration), | ||
401 | GNUNET_MY_query_param_uint64 (&lrvalue), | ||
402 | GNUNET_MY_query_param_auto_from_type (key), | ||
403 | GNUNET_MY_query_param_auto_from_type (&vhash), | ||
404 | GNUNET_MY_query_param_fixed_size (data, size), | ||
405 | GNUNET_MY_query_param_end | ||
406 | }; | ||
407 | |||
408 | if (size > MAX_DATUM_SIZE) | ||
409 | { | ||
410 | GNUNET_break (0); | ||
411 | cont (cont_cls, key, size, GNUNET_SYSERR, _ ("Data too large")); | ||
412 | return; | ||
413 | } | ||
414 | |||
415 | if (GNUNET_OK != | ||
416 | GNUNET_MY_exec_prepared (plugin->mc, | ||
417 | plugin->insert_entry, | ||
418 | params_insert)) | ||
419 | { | ||
420 | cont (cont_cls, | ||
421 | key, | ||
422 | size, | ||
423 | GNUNET_SYSERR, | ||
424 | _ ("MySQL statement run failure")); | ||
425 | return; | ||
426 | } | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
428 | "Inserted value `%s' with size %u into gn090 table\n", | ||
429 | GNUNET_h2s (key), | ||
430 | (unsigned int) size); | ||
431 | if (size > 0) | ||
432 | plugin->env->duc (plugin->env->cls, | ||
433 | size); | ||
434 | GNUNET_break (GNUNET_NO == | ||
435 | GNUNET_MY_extract_result (plugin->insert_entry, | ||
436 | NULL)); | ||
437 | cont (cont_cls, | ||
438 | key, | ||
439 | size, | ||
440 | GNUNET_OK, | ||
441 | NULL); | ||
442 | } | ||
443 | |||
444 | |||
445 | /** | ||
446 | * Run the given select statement and call 'proc' on the resulting | ||
447 | * values (which must be in particular positions). | ||
448 | * | ||
449 | * @param plugin the plugin handle | ||
450 | * @param stmt select statement to run | ||
451 | * @param proc function to call on result | ||
452 | * @param proc_cls closure for @a proc | ||
453 | * @param params_select arguments to initialize stmt | ||
454 | */ | ||
455 | static void | ||
456 | execute_select (struct Plugin *plugin, | ||
457 | struct GNUNET_MYSQL_StatementHandle *stmt, | ||
458 | PluginDatumProcessor proc, | ||
459 | void *proc_cls, | ||
460 | struct GNUNET_MY_QueryParam *params_select) | ||
461 | { | ||
462 | int ret; | ||
463 | uint32_t replication; | ||
464 | uint32_t type; | ||
465 | uint32_t priority; | ||
466 | uint32_t anonymity; | ||
467 | uint64_t uid; | ||
468 | size_t value_size; | ||
469 | void *value; | ||
470 | struct GNUNET_HashCode key; | ||
471 | struct GNUNET_TIME_Absolute expiration; | ||
472 | struct GNUNET_MY_ResultSpec results_select[] = { | ||
473 | GNUNET_MY_result_spec_uint32 (&replication), | ||
474 | GNUNET_MY_result_spec_uint32 (&type), | ||
475 | GNUNET_MY_result_spec_uint32 (&priority), | ||
476 | GNUNET_MY_result_spec_uint32 (&anonymity), | ||
477 | GNUNET_MY_result_spec_absolute_time (&expiration), | ||
478 | GNUNET_MY_result_spec_auto_from_type (&key), | ||
479 | GNUNET_MY_result_spec_variable_size (&value, &value_size), | ||
480 | GNUNET_MY_result_spec_uint64 (&uid), | ||
481 | GNUNET_MY_result_spec_end | ||
482 | }; | ||
483 | |||
484 | ret = GNUNET_MY_exec_prepared (plugin->mc, | ||
485 | stmt, | ||
486 | params_select); | ||
487 | if (GNUNET_OK != ret) | ||
488 | { | ||
489 | proc (proc_cls, | ||
490 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
491 | return; | ||
492 | } | ||
493 | |||
494 | ret = GNUNET_MY_extract_result (stmt, | ||
495 | results_select); | ||
496 | if (GNUNET_OK != ret) | ||
497 | { | ||
498 | proc (proc_cls, | ||
499 | NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
500 | return; | ||
501 | } | ||
502 | |||
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
504 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", | ||
505 | (unsigned int) value_size, | ||
506 | GNUNET_h2s (&key), | ||
507 | (unsigned int) priority, | ||
508 | (unsigned int) anonymity, | ||
509 | GNUNET_STRINGS_absolute_time_to_string (expiration)); | ||
510 | GNUNET_assert (value_size < MAX_DATUM_SIZE); | ||
511 | GNUNET_break (GNUNET_NO == | ||
512 | GNUNET_MY_extract_result (stmt, | ||
513 | NULL)); | ||
514 | ret = proc (proc_cls, | ||
515 | &key, | ||
516 | value_size, | ||
517 | value, | ||
518 | type, | ||
519 | priority, | ||
520 | anonymity, | ||
521 | replication, | ||
522 | expiration, | ||
523 | uid); | ||
524 | GNUNET_MY_cleanup_result (results_select); | ||
525 | if (GNUNET_NO == ret) | ||
526 | { | ||
527 | do_delete_entry (plugin, uid); | ||
528 | if (0 != value_size) | ||
529 | plugin->env->duc (plugin->env->cls, | ||
530 | -value_size); | ||
531 | } | ||
532 | } | ||
533 | |||
534 | |||
535 | /** | ||
536 | * Get one of the results for a particular key in the datastore. | ||
537 | * | ||
538 | * @param cls closure | ||
539 | * @param next_uid return the result with lowest uid >= next_uid | ||
540 | * @param random if true, return a random result instead of using next_uid | ||
541 | * @param key key to match, never NULL | ||
542 | * @param type entries of which type are relevant? | ||
543 | * Use 0 for any type. | ||
544 | * @param proc function to call on the matching value, | ||
545 | * with NULL for if no value matches | ||
546 | * @param proc_cls closure for @a proc | ||
547 | */ | ||
548 | static void | ||
549 | mysql_plugin_get_key (void *cls, | ||
550 | uint64_t next_uid, | ||
551 | bool random, | ||
552 | const struct GNUNET_HashCode *key, | ||
553 | enum GNUNET_BLOCK_Type type, | ||
554 | PluginDatumProcessor proc, | ||
555 | void *proc_cls) | ||
556 | { | ||
557 | struct Plugin *plugin = cls; | ||
558 | uint64_t rvalue; | ||
559 | |||
560 | if (random) | ||
561 | { | ||
562 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
563 | UINT64_MAX); | ||
564 | next_uid = 0; | ||
565 | } | ||
566 | else | ||
567 | rvalue = 0; | ||
568 | |||
569 | if (NULL == key) | ||
570 | { | ||
571 | struct GNUNET_MY_QueryParam params_select[] = { | ||
572 | GNUNET_MY_query_param_uint64 (&next_uid), | ||
573 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
574 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
575 | GNUNET_MY_query_param_end | ||
576 | }; | ||
577 | |||
578 | execute_select (plugin, | ||
579 | plugin->select_entry, | ||
580 | proc, | ||
581 | proc_cls, | ||
582 | params_select); | ||
583 | } | ||
584 | else if (type != GNUNET_BLOCK_TYPE_ANY) | ||
585 | { | ||
586 | struct GNUNET_MY_QueryParam params_select[] = { | ||
587 | GNUNET_MY_query_param_auto_from_type (key), | ||
588 | GNUNET_MY_query_param_uint32 (&type), | ||
589 | GNUNET_MY_query_param_uint64 (&next_uid), | ||
590 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
591 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
592 | GNUNET_MY_query_param_end | ||
593 | }; | ||
594 | |||
595 | execute_select (plugin, | ||
596 | plugin->select_entry_by_hash_and_type, | ||
597 | proc, | ||
598 | proc_cls, | ||
599 | params_select); | ||
600 | } | ||
601 | else | ||
602 | { | ||
603 | struct GNUNET_MY_QueryParam params_select[] = { | ||
604 | GNUNET_MY_query_param_auto_from_type (key), | ||
605 | GNUNET_MY_query_param_uint64 (&next_uid), | ||
606 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
607 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
608 | GNUNET_MY_query_param_end | ||
609 | }; | ||
610 | |||
611 | execute_select (plugin, | ||
612 | plugin->select_entry_by_hash, | ||
613 | proc, | ||
614 | proc_cls, | ||
615 | params_select); | ||
616 | } | ||
617 | } | ||
618 | |||
619 | |||
620 | /** | ||
621 | * Get a zero-anonymity datum from the datastore. | ||
622 | * | ||
623 | * @param cls our `struct Plugin *` | ||
624 | * @param next_uid return the result with lowest uid >= next_uid | ||
625 | * @param type entries of which type should be considered? | ||
626 | * Must not be zero (ANY). | ||
627 | * @param proc function to call on a matching value; | ||
628 | * will be called with NULL if no value matches | ||
629 | * @param proc_cls closure for @a proc | ||
630 | */ | ||
631 | static void | ||
632 | mysql_plugin_get_zero_anonymity (void *cls, | ||
633 | uint64_t next_uid, | ||
634 | enum GNUNET_BLOCK_Type type, | ||
635 | PluginDatumProcessor proc, | ||
636 | void *proc_cls) | ||
637 | { | ||
638 | struct Plugin *plugin = cls; | ||
639 | uint32_t typei = (uint32_t) type; | ||
640 | |||
641 | struct GNUNET_MY_QueryParam params_zero_iter[] = { | ||
642 | GNUNET_MY_query_param_uint32 (&typei), | ||
643 | GNUNET_MY_query_param_uint64 (&next_uid), | ||
644 | GNUNET_MY_query_param_end | ||
645 | }; | ||
646 | |||
647 | execute_select (plugin, | ||
648 | plugin->zero_iter, | ||
649 | proc, | ||
650 | proc_cls, | ||
651 | params_zero_iter); | ||
652 | } | ||
653 | |||
654 | |||
655 | /** | ||
656 | * Context for #repl_proc() function. | ||
657 | */ | ||
658 | struct ReplCtx | ||
659 | { | ||
660 | /** | ||
661 | * Plugin handle. | ||
662 | */ | ||
663 | struct Plugin *plugin; | ||
664 | |||
665 | /** | ||
666 | * Function to call for the result (or the NULL). | ||
667 | */ | ||
668 | PluginDatumProcessor proc; | ||
669 | |||
670 | /** | ||
671 | * Closure for @e proc. | ||
672 | */ | ||
673 | void *proc_cls; | ||
674 | }; | ||
675 | |||
676 | |||
677 | /** | ||
678 | * Wrapper for the processor for #mysql_plugin_get_replication(). | ||
679 | * Decrements the replication counter and calls the original | ||
680 | * iterator. | ||
681 | * | ||
682 | * @param cls closure | ||
683 | * @param key key for the content | ||
684 | * @param size number of bytes in @a data | ||
685 | * @param data content stored | ||
686 | * @param type type of the content | ||
687 | * @param priority priority of the content | ||
688 | * @param anonymity anonymity-level for the content | ||
689 | * @param replication replication-level for the content | ||
690 | * @param expiration expiration time for the content | ||
691 | * @param uid unique identifier for the datum; | ||
692 | * maybe 0 if no unique identifier is available | ||
693 | * @return #GNUNET_SYSERR to abort the iteration, #GNUNET_OK to continue | ||
694 | * (continue on call to "next", of course), | ||
695 | * #GNUNET_NO to delete the item and continue (if supported) | ||
696 | */ | ||
697 | static int | ||
698 | repl_proc (void *cls, | ||
699 | const struct GNUNET_HashCode *key, | ||
700 | uint32_t size, | ||
701 | const void *data, | ||
702 | enum GNUNET_BLOCK_Type type, | ||
703 | uint32_t priority, | ||
704 | uint32_t anonymity, | ||
705 | uint32_t replication, | ||
706 | struct GNUNET_TIME_Absolute expiration, | ||
707 | uint64_t uid) | ||
708 | { | ||
709 | struct ReplCtx *rc = cls; | ||
710 | struct Plugin *plugin = rc->plugin; | ||
711 | int ret; | ||
712 | int iret; | ||
713 | |||
714 | ret = rc->proc (rc->proc_cls, | ||
715 | key, | ||
716 | size, | ||
717 | data, | ||
718 | type, | ||
719 | priority, | ||
720 | anonymity, | ||
721 | replication, | ||
722 | expiration, | ||
723 | uid); | ||
724 | if (NULL != key) | ||
725 | { | ||
726 | struct GNUNET_MY_QueryParam params_proc[] = { | ||
727 | GNUNET_MY_query_param_uint64 (&uid), | ||
728 | GNUNET_MY_query_param_end | ||
729 | }; | ||
730 | |||
731 | iret = GNUNET_MY_exec_prepared (plugin->mc, | ||
732 | plugin->dec_repl, | ||
733 | params_proc); | ||
734 | if (GNUNET_SYSERR == iret) | ||
735 | { | ||
736 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
737 | "Failed to reduce replication counter\n"); | ||
738 | return GNUNET_SYSERR; | ||
739 | } | ||
740 | } | ||
741 | return ret; | ||
742 | } | ||
743 | |||
744 | |||
745 | /** | ||
746 | * Get a random item for replication. Returns a single, not expired, | ||
747 | * random item from those with the highest replication counters. The | ||
748 | * item's replication counter is decremented by one IF it was positive | ||
749 | * before. Call @a proc with all values ZERO or NULL if the datastore | ||
750 | * is empty. | ||
751 | * | ||
752 | * @param cls closure | ||
753 | * @param proc function to call the value (once only). | ||
754 | * @param proc_cls closure for @a proc | ||
755 | */ | ||
756 | static void | ||
757 | mysql_plugin_get_replication (void *cls, | ||
758 | PluginDatumProcessor proc, | ||
759 | void *proc_cls) | ||
760 | { | ||
761 | struct Plugin *plugin = cls; | ||
762 | uint64_t rvalue; | ||
763 | uint32_t repl; | ||
764 | struct ReplCtx rc; | ||
765 | struct GNUNET_MY_QueryParam params_get[] = { | ||
766 | GNUNET_MY_query_param_end | ||
767 | }; | ||
768 | struct GNUNET_MY_ResultSpec results_get[] = { | ||
769 | GNUNET_MY_result_spec_uint32 (&repl), | ||
770 | GNUNET_MY_result_spec_end | ||
771 | }; | ||
772 | struct GNUNET_MY_QueryParam params_select[] = { | ||
773 | GNUNET_MY_query_param_uint32 (&repl), | ||
774 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
775 | GNUNET_MY_query_param_uint32 (&repl), | ||
776 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
777 | GNUNET_MY_query_param_end | ||
778 | }; | ||
779 | |||
780 | rc.plugin = plugin; | ||
781 | rc.proc = proc; | ||
782 | rc.proc_cls = proc_cls; | ||
783 | |||
784 | if (1 != | ||
785 | GNUNET_MY_exec_prepared (plugin->mc, | ||
786 | plugin->max_repl, | ||
787 | params_get)) | ||
788 | { | ||
789 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
790 | return; | ||
791 | } | ||
792 | |||
793 | if (GNUNET_OK != | ||
794 | GNUNET_MY_extract_result (plugin->max_repl, | ||
795 | results_get)) | ||
796 | { | ||
797 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
798 | return; | ||
799 | } | ||
800 | GNUNET_break (GNUNET_NO == | ||
801 | GNUNET_MY_extract_result (plugin->max_repl, | ||
802 | NULL)); | ||
803 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
804 | UINT64_MAX); | ||
805 | |||
806 | execute_select (plugin, | ||
807 | plugin->select_replication, | ||
808 | &repl_proc, | ||
809 | &rc, | ||
810 | params_select); | ||
811 | } | ||
812 | |||
813 | |||
814 | /** | ||
815 | * Get all of the keys in the datastore. | ||
816 | * | ||
817 | * @param cls closure | ||
818 | * @param proc function to call on each key | ||
819 | * @param proc_cls closure for @a proc | ||
820 | */ | ||
821 | static void | ||
822 | mysql_plugin_get_keys (void *cls, | ||
823 | PluginKeyProcessor proc, | ||
824 | void *proc_cls) | ||
825 | { | ||
826 | struct Plugin *plugin = cls; | ||
827 | int ret; | ||
828 | MYSQL_STMT *statement; | ||
829 | unsigned int cnt; | ||
830 | struct GNUNET_HashCode key; | ||
831 | struct GNUNET_HashCode last; | ||
832 | struct GNUNET_MY_QueryParam params_select[] = { | ||
833 | GNUNET_MY_query_param_end | ||
834 | }; | ||
835 | struct GNUNET_MY_ResultSpec results_select[] = { | ||
836 | GNUNET_MY_result_spec_auto_from_type (&key), | ||
837 | GNUNET_MY_result_spec_end | ||
838 | }; | ||
839 | |||
840 | GNUNET_assert (NULL != proc); | ||
841 | statement = GNUNET_MYSQL_statement_get_stmt (plugin->get_all_keys); | ||
842 | if (GNUNET_OK != | ||
843 | GNUNET_MY_exec_prepared (plugin->mc, | ||
844 | plugin->get_all_keys, | ||
845 | params_select)) | ||
846 | { | ||
847 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
848 | _ ("`%s' for `%s' failed at %s:%d with error: %s\n"), | ||
849 | "mysql_stmt_execute", | ||
850 | GET_ALL_KEYS, | ||
851 | __FILE__, | ||
852 | __LINE__, | ||
853 | mysql_stmt_error (statement)); | ||
854 | GNUNET_MYSQL_statements_invalidate (plugin->mc); | ||
855 | proc (proc_cls, NULL, 0); | ||
856 | return; | ||
857 | } | ||
858 | memset (&last, 0, sizeof(last)); /* make static analysis happy */ | ||
859 | ret = GNUNET_YES; | ||
860 | cnt = 0; | ||
861 | while (ret == GNUNET_YES) | ||
862 | { | ||
863 | ret = GNUNET_MY_extract_result (plugin->get_all_keys, | ||
864 | results_select); | ||
865 | if (0 != GNUNET_memcmp (&last, | ||
866 | &key)) | ||
867 | { | ||
868 | if (0 != cnt) | ||
869 | proc (proc_cls, | ||
870 | &last, | ||
871 | cnt); | ||
872 | cnt = 1; | ||
873 | last = key; | ||
874 | } | ||
875 | else | ||
876 | { | ||
877 | cnt++; | ||
878 | } | ||
879 | } | ||
880 | if (0 != cnt) | ||
881 | proc (proc_cls, | ||
882 | &last, | ||
883 | cnt); | ||
884 | /* finally, let app know we are done */ | ||
885 | proc (proc_cls, | ||
886 | NULL, | ||
887 | 0); | ||
888 | if (GNUNET_SYSERR == ret) | ||
889 | { | ||
890 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
891 | _ ("`%s' failed at %s:%d with error: %s\n"), | ||
892 | "mysql_stmt_fetch", | ||
893 | __FILE__, | ||
894 | __LINE__, | ||
895 | mysql_stmt_error (statement)); | ||
896 | GNUNET_MYSQL_statements_invalidate (plugin->mc); | ||
897 | return; | ||
898 | } | ||
899 | } | ||
900 | |||
901 | |||
902 | /** | ||
903 | * Context for #expi_proc() function. | ||
904 | */ | ||
905 | struct ExpiCtx | ||
906 | { | ||
907 | /** | ||
908 | * Plugin handle. | ||
909 | */ | ||
910 | struct Plugin *plugin; | ||
911 | |||
912 | /** | ||
913 | * Function to call for the result (or the NULL). | ||
914 | */ | ||
915 | PluginDatumProcessor proc; | ||
916 | |||
917 | /** | ||
918 | * Closure for @e proc. | ||
919 | */ | ||
920 | void *proc_cls; | ||
921 | }; | ||
922 | |||
923 | |||
924 | /** | ||
925 | * Wrapper for the processor for #mysql_plugin_get_expiration(). | ||
926 | * If no expired value was found, we do a second query for | ||
927 | * low-priority content. | ||
928 | * | ||
929 | * @param cls closure | ||
930 | * @param key key for the content | ||
931 | * @param size number of bytes in data | ||
932 | * @param data content stored | ||
933 | * @param type type of the content | ||
934 | * @param priority priority of the content | ||
935 | * @param anonymity anonymity-level for the content | ||
936 | * @param replication replication-level for the content | ||
937 | * @param expiration expiration time for the content | ||
938 | * @param uid unique identifier for the datum; | ||
939 | * maybe 0 if no unique identifier is available | ||
940 | * @return #GNUNET_SYSERR to abort the iteration, #GNUNET_OK to continue | ||
941 | * (continue on call to "next", of course), | ||
942 | * #GNUNET_NO to delete the item and continue (if supported) | ||
943 | */ | ||
944 | static int | ||
945 | expi_proc (void *cls, | ||
946 | const struct GNUNET_HashCode *key, | ||
947 | uint32_t size, | ||
948 | const void *data, | ||
949 | enum GNUNET_BLOCK_Type type, | ||
950 | uint32_t priority, | ||
951 | uint32_t anonymity, | ||
952 | uint32_t replication, | ||
953 | struct GNUNET_TIME_Absolute expiration, | ||
954 | uint64_t uid) | ||
955 | { | ||
956 | struct ExpiCtx *rc = cls; | ||
957 | struct Plugin *plugin = rc->plugin; | ||
958 | struct GNUNET_MY_QueryParam params_select[] = { | ||
959 | GNUNET_MY_query_param_end | ||
960 | }; | ||
961 | |||
962 | if (NULL == key) | ||
963 | { | ||
964 | execute_select (plugin, | ||
965 | plugin->select_priority, | ||
966 | rc->proc, | ||
967 | rc->proc_cls, | ||
968 | params_select); | ||
969 | return GNUNET_SYSERR; | ||
970 | } | ||
971 | return rc->proc (rc->proc_cls, | ||
972 | key, | ||
973 | size, | ||
974 | data, | ||
975 | type, | ||
976 | priority, | ||
977 | anonymity, | ||
978 | replication, | ||
979 | expiration, | ||
980 | uid); | ||
981 | } | ||
982 | |||
983 | |||
984 | /** | ||
985 | * Get a random item for expiration. | ||
986 | * Call @a proc with all values ZERO or NULL if the datastore is empty. | ||
987 | * | ||
988 | * @param cls closure | ||
989 | * @param proc function to call the value (once only). | ||
990 | * @param proc_cls closure for @a proc | ||
991 | */ | ||
992 | static void | ||
993 | mysql_plugin_get_expiration (void *cls, | ||
994 | PluginDatumProcessor proc, | ||
995 | void *proc_cls) | ||
996 | { | ||
997 | struct Plugin *plugin = cls; | ||
998 | struct GNUNET_TIME_Absolute now = { 0 }; | ||
999 | struct GNUNET_MY_QueryParam params_select[] = { | ||
1000 | GNUNET_MY_query_param_absolute_time (&now), | ||
1001 | GNUNET_MY_query_param_end | ||
1002 | }; | ||
1003 | struct ExpiCtx rc; | ||
1004 | |||
1005 | rc.plugin = plugin; | ||
1006 | rc.proc = proc; | ||
1007 | rc.proc_cls = proc_cls; | ||
1008 | now = GNUNET_TIME_absolute_get (); | ||
1009 | execute_select (plugin, | ||
1010 | plugin->select_expiration, | ||
1011 | expi_proc, | ||
1012 | &rc, | ||
1013 | params_select); | ||
1014 | } | ||
1015 | |||
1016 | |||
1017 | /** | ||
1018 | * Drop database. | ||
1019 | * | ||
1020 | * @param cls the `struct Plugin *` | ||
1021 | */ | ||
1022 | static void | ||
1023 | mysql_plugin_drop (void *cls) | ||
1024 | { | ||
1025 | struct Plugin *plugin = cls; | ||
1026 | |||
1027 | if (GNUNET_OK != | ||
1028 | GNUNET_MYSQL_statement_run (plugin->mc, | ||
1029 | "DROP TABLE gn090")) | ||
1030 | return; /* error */ | ||
1031 | plugin->env->duc (plugin->env->cls, 0); | ||
1032 | } | ||
1033 | |||
1034 | |||
1035 | /** | ||
1036 | * Remove a particular key in the datastore. | ||
1037 | * | ||
1038 | * @param cls closure | ||
1039 | * @param key key for the content | ||
1040 | * @param size number of bytes in data | ||
1041 | * @param data content stored | ||
1042 | * @param cont continuation called with success or failure status | ||
1043 | * @param cont_cls continuation closure for @a cont | ||
1044 | */ | ||
1045 | static void | ||
1046 | mysql_plugin_remove_key (void *cls, | ||
1047 | const struct GNUNET_HashCode *key, | ||
1048 | uint32_t size, | ||
1049 | const void *data, | ||
1050 | PluginRemoveCont cont, | ||
1051 | void *cont_cls) | ||
1052 | { | ||
1053 | struct Plugin *plugin = cls; | ||
1054 | struct GNUNET_MY_QueryParam params_delete[] = { | ||
1055 | GNUNET_MY_query_param_auto_from_type (key), | ||
1056 | GNUNET_MY_query_param_fixed_size (data, size), | ||
1057 | GNUNET_MY_query_param_end | ||
1058 | }; | ||
1059 | |||
1060 | if (GNUNET_OK != | ||
1061 | GNUNET_MY_exec_prepared (plugin->mc, | ||
1062 | plugin->delete_entry_by_hash_value, | ||
1063 | params_delete)) | ||
1064 | { | ||
1065 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1066 | "Removing key `%s' from gn090 table failed\n", | ||
1067 | GNUNET_h2s (key)); | ||
1068 | cont (cont_cls, | ||
1069 | key, | ||
1070 | size, | ||
1071 | GNUNET_SYSERR, | ||
1072 | _ ("MySQL statement run failure")); | ||
1073 | return; | ||
1074 | } | ||
1075 | |||
1076 | MYSQL_STMT *stmt = GNUNET_MYSQL_statement_get_stmt ( | ||
1077 | plugin->delete_entry_by_hash_value); | ||
1078 | my_ulonglong rows = mysql_stmt_affected_rows (stmt); | ||
1079 | |||
1080 | if (0 == rows) | ||
1081 | { | ||
1082 | cont (cont_cls, | ||
1083 | key, | ||
1084 | size, | ||
1085 | GNUNET_NO, | ||
1086 | NULL); | ||
1087 | return; | ||
1088 | } | ||
1089 | plugin->env->duc (plugin->env->cls, | ||
1090 | -size); | ||
1091 | cont (cont_cls, | ||
1092 | key, | ||
1093 | size, | ||
1094 | GNUNET_OK, | ||
1095 | NULL); | ||
1096 | } | ||
1097 | |||
1098 | |||
1099 | /** | ||
1100 | * Entry point for the plugin. | ||
1101 | * | ||
1102 | * @param cls the `struct GNUNET_DATASTORE_PluginEnvironment *` | ||
1103 | * @return our `struct Plugin *` | ||
1104 | */ | ||
1105 | void * | ||
1106 | libgnunet_plugin_datastore_mysql_init (void *cls) | ||
1107 | { | ||
1108 | struct GNUNET_DATASTORE_PluginEnvironment *env = cls; | ||
1109 | struct GNUNET_DATASTORE_PluginFunctions *api; | ||
1110 | struct Plugin *plugin; | ||
1111 | |||
1112 | plugin = GNUNET_new (struct Plugin); | ||
1113 | plugin->env = env; | ||
1114 | plugin->mc = GNUNET_MYSQL_context_create (env->cfg, | ||
1115 | "datastore-mysql"); | ||
1116 | if (NULL == plugin->mc) | ||
1117 | { | ||
1118 | GNUNET_free (plugin); | ||
1119 | return NULL; | ||
1120 | } | ||
1121 | #define MRUNS(a) (GNUNET_OK != GNUNET_MYSQL_statement_run (plugin->mc, a)) | ||
1122 | #define PINIT(a, b) (NULL == (a = GNUNET_MYSQL_statement_prepare (plugin->mc, \ | ||
1123 | b))) | ||
1124 | if (MRUNS | ||
1125 | ("CREATE TABLE IF NOT EXISTS gn090 (" | ||
1126 | " repl INT(11) UNSIGNED NOT NULL DEFAULT 0," | ||
1127 | " type INT(11) UNSIGNED NOT NULL DEFAULT 0," | ||
1128 | " prio INT(11) UNSIGNED NOT NULL DEFAULT 0," | ||
1129 | " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0," | ||
1130 | " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," | ||
1131 | " rvalue BIGINT UNSIGNED NOT NULL," | ||
1132 | " hash BINARY(64) NOT NULL DEFAULT ''," | ||
1133 | " vhash BINARY(64) NOT NULL DEFAULT ''," | ||
1134 | " value BLOB NOT NULL DEFAULT ''," | ||
1135 | " uid BIGINT NOT NULL AUTO_INCREMENT," | ||
1136 | " PRIMARY KEY (uid)," | ||
1137 | " INDEX idx_hash_type_uid (hash(64),type,rvalue)," | ||
1138 | " INDEX idx_prio (prio)," | ||
1139 | " INDEX idx_repl_rvalue (repl,rvalue)," | ||
1140 | " INDEX idx_expire (expire)," | ||
1141 | " INDEX idx_anonLevel_type_rvalue (anonLevel,type,rvalue)" | ||
1142 | ") ENGINE=InnoDB") || MRUNS ("SET AUTOCOMMIT = 1") || | ||
1143 | PINIT (plugin->insert_entry, INSERT_ENTRY) || | ||
1144 | PINIT (plugin->delete_entry_by_uid, DELETE_ENTRY_BY_UID) || | ||
1145 | PINIT (plugin->delete_entry_by_hash_value, DELETE_ENTRY_BY_HASH_VALUE) || | ||
1146 | PINIT (plugin->select_entry, SELECT_ENTRY) || | ||
1147 | PINIT (plugin->select_entry_by_hash, SELECT_ENTRY_BY_HASH) || | ||
1148 | PINIT (plugin->select_entry_by_hash_and_type, | ||
1149 | SELECT_ENTRY_BY_HASH_AND_TYPE) || | ||
1150 | PINIT (plugin->get_size, SELECT_SIZE) || | ||
1151 | PINIT (plugin->update_entry, UPDATE_ENTRY) || | ||
1152 | PINIT (plugin->dec_repl, DEC_REPL) || | ||
1153 | PINIT (plugin->zero_iter, SELECT_IT_NON_ANONYMOUS) || | ||
1154 | PINIT (plugin->select_expiration, SELECT_IT_EXPIRATION) || | ||
1155 | PINIT (plugin->select_priority, SELECT_IT_PRIORITY) || | ||
1156 | PINIT (plugin->max_repl, SELECT_MAX_REPL) || | ||
1157 | PINIT (plugin->get_all_keys, GET_ALL_KEYS) || | ||
1158 | PINIT (plugin->select_replication, SELECT_IT_REPLICATION) || | ||
1159 | false) | ||
1160 | { | ||
1161 | GNUNET_MYSQL_context_destroy (plugin->mc); | ||
1162 | GNUNET_free (plugin); | ||
1163 | return NULL; | ||
1164 | } | ||
1165 | #undef PINIT | ||
1166 | #undef MRUNS | ||
1167 | |||
1168 | api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); | ||
1169 | api->cls = plugin; | ||
1170 | api->estimate_size = &mysql_plugin_estimate_size; | ||
1171 | api->put = &mysql_plugin_put; | ||
1172 | api->get_key = &mysql_plugin_get_key; | ||
1173 | api->get_replication = &mysql_plugin_get_replication; | ||
1174 | api->get_expiration = &mysql_plugin_get_expiration; | ||
1175 | api->get_zero_anonymity = &mysql_plugin_get_zero_anonymity; | ||
1176 | api->get_keys = &mysql_plugin_get_keys; | ||
1177 | api->drop = &mysql_plugin_drop; | ||
1178 | api->remove_key = &mysql_plugin_remove_key; | ||
1179 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql", | ||
1180 | _ ("Mysql database running\n")); | ||
1181 | return api; | ||
1182 | } | ||
1183 | |||
1184 | |||
1185 | /** | ||
1186 | * Exit point from the plugin. | ||
1187 | * | ||
1188 | * @param cls our `struct Plugin *` | ||
1189 | * @return always NULL | ||
1190 | */ | ||
1191 | void * | ||
1192 | libgnunet_plugin_datastore_mysql_done (void *cls) | ||
1193 | { | ||
1194 | struct GNUNET_DATASTORE_PluginFunctions *api = cls; | ||
1195 | struct Plugin *plugin = api->cls; | ||
1196 | |||
1197 | GNUNET_MYSQL_context_destroy (plugin->mc); | ||
1198 | GNUNET_free (plugin); | ||
1199 | GNUNET_free (api); | ||
1200 | return NULL; | ||
1201 | } | ||
1202 | |||
1203 | |||
1204 | /* end of plugin_datastore_mysql.c */ | ||
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index e72a6acd3..58a6b7a28 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -710,7 +710,7 @@ main (int argc, | |||
710 | char cfg_name[PATH_MAX]; | 710 | char cfg_name[PATH_MAX]; |
711 | int ret; | 711 | int ret; |
712 | 712 | ||
713 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 713 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
714 | GNUNET_snprintf (cfg_name, | 714 | GNUNET_snprintf (cfg_name, |
715 | sizeof(cfg_name), | 715 | sizeof(cfg_name), |
716 | "test_datastore_api_data_%s.conf", | 716 | "test_datastore_api_data_%s.conf", |
diff --git a/src/datastore/test_datastore_api_data_mysql.conf b/src/datastore/test_datastore_api_data_mysql.conf deleted file mode 100644 index c0052c5ea..000000000 --- a/src/datastore/test_datastore_api_data_mysql.conf +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | @INLINE@ test_defaults.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-datastore-mysql/ | ||
4 | |||
5 | [datastore] | ||
6 | QUOTA = 10 MB | ||
7 | DATABASE = mysql | ||
8 | |||
9 | [datastore-mysql] | ||
10 | DATABASE = gnunetcheck | ||
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 175765267..b9b134fbc 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -387,7 +387,7 @@ main (int argc, char *argv[]) | |||
387 | char cfg_name[PATH_MAX]; | 387 | char cfg_name[PATH_MAX]; |
388 | int ret; | 388 | int ret; |
389 | 389 | ||
390 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 390 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
391 | GNUNET_snprintf (cfg_name, | 391 | GNUNET_snprintf (cfg_name, |
392 | sizeof(cfg_name), | 392 | sizeof(cfg_name), |
393 | "test_datastore_api_data_%s.conf", | 393 | "test_datastore_api_data_%s.conf", |
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 9fe2462e7..7de1acf2d 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -457,7 +457,7 @@ main (int argc, char *argv[]) | |||
457 | }; | 457 | }; |
458 | 458 | ||
459 | /* determine name of plugin to use */ | 459 | /* determine name of plugin to use */ |
460 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 460 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
461 | GNUNET_snprintf (dir_name, sizeof(dir_name), | 461 | GNUNET_snprintf (dir_name, sizeof(dir_name), |
462 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); | 462 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); |
463 | GNUNET_DISK_directory_remove (dir_name); | 463 | GNUNET_DISK_directory_remove (dir_name); |
diff --git a/src/datastore/test_plugin_datastore_data_mysql.conf b/src/datastore/test_plugin_datastore_data_mysql.conf deleted file mode 100644 index 07d3ec58e..000000000 --- a/src/datastore/test_plugin_datastore_data_mysql.conf +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | @INLINE@ test_defaults.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-datastore-plugin-mysql/ | ||
4 | |||
5 | [datastore] | ||
6 | DATABASE = mysql | ||
7 | |||
8 | [datastore-mysql] | ||
9 | DATABASE = gnunetcheck | ||
diff --git a/src/dht/meson.build b/src/dht/meson.build new file mode 100644 index 000000000..f42ae354c --- /dev/null +++ b/src/dht/meson.build | |||
@@ -0,0 +1,90 @@ | |||
1 | libgnunetdht_src = ['dht_api.c'] | ||
2 | |||
3 | gnunetservicedht_src = ['gnunet-service-dht.c', | ||
4 | 'gnunet-service-dht_datacache.c', | ||
5 | 'gnunet-service-dht_neighbours.c', | ||
6 | 'gnunet-service-dht_routing.c'] | ||
7 | |||
8 | configure_file(input : 'dht.conf.in', | ||
9 | output : 'dht.conf', | ||
10 | configuration : cdata, | ||
11 | install: true, | ||
12 | install_dir: pkgcfgdir) | ||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetdht_src + gnunetservicedht_src | ||
16 | gnunet_src += 'dht/' + p | ||
17 | endforeach | ||
18 | endif | ||
19 | |||
20 | libgnunetdht = library('gnunetdht', | ||
21 | libgnunetdht_src, | ||
22 | soversion: '4', | ||
23 | version: '4.0.0', | ||
24 | dependencies: libgnunetutil_dep, | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunetdht_dep = declare_dependency(link_with : libgnunetdht) | ||
29 | pkg.generate(libgnunetdht, url: 'https://www.gnunet.org', | ||
30 | description : 'Provides API for the R5N distributed hash table') | ||
31 | |||
32 | shared_module('gnunet_plugin_block_dht', | ||
33 | ['plugin_block_dht.c'], | ||
34 | dependencies: [libgnunetutil_dep, | ||
35 | libgnunethello_dep, | ||
36 | libgnunetblock_dep, | ||
37 | libgnunetblockgroup_dep], | ||
38 | include_directories: [incdir, configuration_inc], | ||
39 | install:true, | ||
40 | install_dir: get_option('libdir')/'gnunet') | ||
41 | |||
42 | executable ('gnunet-dht', | ||
43 | gnunetservicedht_src, | ||
44 | dependencies: [libgnunetdht_dep, libgnunetutil_dep, | ||
45 | libgnunetblock_dep, | ||
46 | m_dep, | ||
47 | libgnunetdatacache_dep, | ||
48 | libgnunetstatistics_dep, | ||
49 | libgnunetblockgroup_dep, | ||
50 | libgnunethello_dep], | ||
51 | include_directories: [incdir, configuration_inc], | ||
52 | install: true, | ||
53 | install_dir: get_option('bindir')) | ||
54 | executable ('gnunet-dht-put', | ||
55 | ['gnunet-dht-put.c'], | ||
56 | dependencies: [libgnunetdht_dep, libgnunetutil_dep], | ||
57 | include_directories: [incdir, configuration_inc], | ||
58 | install: true, | ||
59 | install_dir: get_option('bindir')) | ||
60 | executable ('gnunet-dht-get', | ||
61 | ['gnunet-dht-get.c'], | ||
62 | dependencies: [libgnunetdht_dep, libgnunetutil_dep], | ||
63 | include_directories: [incdir, configuration_inc], | ||
64 | install: true, | ||
65 | install_dir: get_option('bindir')) | ||
66 | executable ('gnunet-dht-monitor', | ||
67 | ['gnunet-dht-monitor.c'], | ||
68 | dependencies: [libgnunetdht_dep, libgnunetutil_dep], | ||
69 | include_directories: [incdir, configuration_inc], | ||
70 | install: true, | ||
71 | install_dir: get_option('bindir')) | ||
72 | executable ('gnunet-dht-hello', | ||
73 | ['gnunet-dht-hello.c'], | ||
74 | dependencies: [libgnunetdht_dep, libgnunetutil_dep], | ||
75 | include_directories: [incdir, configuration_inc], | ||
76 | install: true, | ||
77 | install_dir: get_option('bindir')) | ||
78 | executable ('gnunet-service-dht', | ||
79 | gnunetservicedht_src, | ||
80 | dependencies: [libgnunetdht_dep, libgnunetutil_dep, | ||
81 | libgnunetblock_dep, | ||
82 | m_dep, | ||
83 | libgnunetdatacache_dep, | ||
84 | libgnunetstatistics_dep, | ||
85 | libgnunetblockgroup_dep, | ||
86 | libgnunethello_dep], | ||
87 | include_directories: [incdir, configuration_inc], | ||
88 | install: true, | ||
89 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
90 | |||
diff --git a/src/dhtu/meson.build b/src/dhtu/meson.build new file mode 100644 index 000000000..34919bb55 --- /dev/null +++ b/src/dhtu/meson.build | |||
@@ -0,0 +1,50 @@ | |||
1 | libgnunetplugindhtuip_src = ['plugin_dhtu_ip.c'] | ||
2 | libgnunetplugindhtugnunet_src = ['plugin_dhtu_gnunet.c'] | ||
3 | |||
4 | configure_file(input : 'dhtu.conf', | ||
5 | output : 'dhtu.conf', | ||
6 | configuration : cdata, | ||
7 | install: true, | ||
8 | install_dir: pkgcfgdir) | ||
9 | |||
10 | if get_option('monolith') | ||
11 | foreach p : libgnunetplugindhtuip_src + libgnunetplugindhtugnunet_src | ||
12 | gnunet_src += 'dhtu/' + p | ||
13 | endforeach | ||
14 | endif | ||
15 | |||
16 | libgnunettestingdhtu = library('gnunettestingdhtu', | ||
17 | ['testing_dhtu_cmd_send.c'], | ||
18 | soversion: '0', | ||
19 | version: '0.0.0', | ||
20 | dependencies: [ | ||
21 | libgnunetutil_dep, | ||
22 | libgnunetarm_dep, | ||
23 | libgnunettesting_dep | ||
24 | ], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunettestingdhtu_dep = declare_dependency(link_with : libgnunettestingdhtu) | ||
29 | |||
30 | shared_module('gnunet_plugin_dhtu_ip', | ||
31 | libgnunetplugindhtuip_src, | ||
32 | dependencies: [libgnunetutil_dep, m_dep], | ||
33 | include_directories: [incdir, configuration_inc], | ||
34 | install: true, | ||
35 | install_dir: get_option('libdir')/'gnunet') | ||
36 | |||
37 | shared_module('gnunet_plugin_dhtu_gnunet', | ||
38 | libgnunetplugindhtugnunet_src, | ||
39 | dependencies: [libgnunetutil_dep, | ||
40 | libgnunetats_dep, | ||
41 | m_dep, | ||
42 | libgnunetcore_dep, | ||
43 | libgnunethello_dep, | ||
44 | libgnunetpeerinfo_dep, | ||
45 | libgnunetnse_dep, | ||
46 | libgnunettransport_dep], | ||
47 | include_directories: [incdir, configuration_inc], | ||
48 | install: true, | ||
49 | install_dir: get_option('libdir')/'gnunet') | ||
50 | |||
diff --git a/src/dns/meson.build b/src/dns/meson.build new file mode 100644 index 000000000..32d33f3f0 --- /dev/null +++ b/src/dns/meson.build | |||
@@ -0,0 +1,67 @@ | |||
1 | libgnunetdns_src = ['dns_api.c'] | ||
2 | libgnunetpluginblockdns_src = ['plugin_block_dns.c'] | ||
3 | |||
4 | gnunetservicedns_src = ['gnunet-service-dns.c'] | ||
5 | gnunetdnsredirector_src = ['gnunet-dns-monitor.c'] | ||
6 | gnunetdnsmonitor_src = ['gnunet-dns-redirector.c'] | ||
7 | |||
8 | configure_file(input : 'dns.conf.in', | ||
9 | output : 'dns.conf', | ||
10 | configuration : cdata, | ||
11 | install: true, | ||
12 | install_dir: pkgcfgdir) | ||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetdns_src + gnunetservicedns_src + libgnunetpluginblockdns_src | ||
16 | gnunet_src += 'dns/' + p | ||
17 | endforeach | ||
18 | subdir_done() | ||
19 | endif | ||
20 | |||
21 | libgnunetdns = library('gnunetdns', | ||
22 | libgnunetdns_src, | ||
23 | soversion: '0', | ||
24 | version: '0.0.0', | ||
25 | dependencies: libgnunetutil_dep, | ||
26 | include_directories: [incdir, configuration_inc], | ||
27 | install: true, | ||
28 | install_dir: get_option('libdir')) | ||
29 | libgnunetdns_dep = declare_dependency(link_with : libgnunetdns) | ||
30 | pkg.generate(libgnunetdns, url: 'https://www.gnunet.org', | ||
31 | description : 'Provides API to access GNUnet\'s DNS service (to intercept and manipulate DNS queries)') | ||
32 | |||
33 | shared_module('gnunet_plugin_block_dns', | ||
34 | libgnunetpluginblockdns_src, | ||
35 | dependencies: [libgnunetutil_dep, libgnunetblockgroup_dep], | ||
36 | include_directories: [incdir, configuration_inc], | ||
37 | install: true, | ||
38 | install_dir: get_option('libdir')/'gnunet') | ||
39 | |||
40 | executable ('gnunet-service-dns', | ||
41 | gnunetservicedns_src, | ||
42 | dependencies: [libgnunetdns_dep, libgnunetutil_dep, | ||
43 | libgnunetstatistics_dep], | ||
44 | include_directories: [incdir, configuration_inc], | ||
45 | install: true, | ||
46 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
47 | executable ('gnunet-dns-monitor', | ||
48 | gnunetdnsmonitor_src, | ||
49 | dependencies: [libgnunetdns_dep, libgnunetutil_dep, libgnunetdns_dep], | ||
50 | include_directories: [incdir, configuration_inc], | ||
51 | install: true, | ||
52 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
53 | executable ('gnunet-dns-redirector', | ||
54 | gnunetdnsredirector_src, | ||
55 | dependencies: [libgnunetdns_dep, libgnunetutil_dep, libgnunetdns_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
59 | |||
60 | if host_machine.system() == 'linux' | ||
61 | executable ('gnunet-helper-dns', | ||
62 | ['gnunet-helper-dns.c'], | ||
63 | dependencies: [libgnunetdns_dep, libgnunetutil_dep, libgnunetdns_dep], | ||
64 | include_directories: [incdir, configuration_inc], | ||
65 | install: true, | ||
66 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
67 | endif | ||
diff --git a/src/exit/meson.build b/src/exit/meson.build new file mode 100644 index 000000000..e75f2b080 --- /dev/null +++ b/src/exit/meson.build | |||
@@ -0,0 +1,29 @@ | |||
1 | configure_file(input : 'exit.conf', | ||
2 | output : 'exit.conf', | ||
3 | configuration : cdata, | ||
4 | install: true, | ||
5 | install_dir: pkgcfgdir) | ||
6 | |||
7 | |||
8 | if get_option('monolith') | ||
9 | subdir_done() | ||
10 | endif | ||
11 | |||
12 | if host_machine.system() == 'linux' | ||
13 | executable ('gnunet-helper-exit', | ||
14 | ['gnunet-helper-exit.c'], | ||
15 | include_directories: [incdir, configuration_inc], | ||
16 | install: true, | ||
17 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
18 | endif | ||
19 | |||
20 | executable ('gnunet-daemon-exit', | ||
21 | ['gnunet-daemon-exit.c'], | ||
22 | dependencies: [libgnunetdht_dep, | ||
23 | libgnunetutil_dep, | ||
24 | libgnunetstatistics_dep, | ||
25 | libgnunetregex_dep, | ||
26 | libgnunetcadet_dep], | ||
27 | include_directories: [incdir, configuration_inc], | ||
28 | install: true, | ||
29 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
diff --git a/src/fragmentation/meson.build b/src/fragmentation/meson.build new file mode 100644 index 000000000..148a4efe8 --- /dev/null +++ b/src/fragmentation/meson.build | |||
@@ -0,0 +1,21 @@ | |||
1 | libgnunetfragmentation_src = ['fragmentation.c', | ||
2 | 'defragmentation.c'] | ||
3 | |||
4 | if get_option('monolith') | ||
5 | foreach p : libgnunetfragmentation_src | ||
6 | gnunet_src += 'fragmentation/' + p | ||
7 | endforeach | ||
8 | endif | ||
9 | |||
10 | libgnunetfragmentation = library('gnunetfragmentation', | ||
11 | libgnunetfragmentation_src, | ||
12 | soversion: '2', | ||
13 | version: '2.0.0', | ||
14 | dependencies: [m_dep, libgnunetutil_dep, libgnunetstatistics_dep], | ||
15 | include_directories: [incdir, configuration_inc], | ||
16 | install: true, | ||
17 | install_dir: get_option('libdir')) | ||
18 | libgnunetfragmentation_dep = declare_dependency(link_with : libgnunetfragmentation) | ||
19 | pkg.generate(libgnunetfragmentation, url: 'https://www.gnunet.org', | ||
20 | description : 'Provides API for sending and receiving messages that are larger than the MTU of the transport') | ||
21 | |||
diff --git a/src/fs/meson.build b/src/fs/meson.build new file mode 100644 index 000000000..63a5d9a39 --- /dev/null +++ b/src/fs/meson.build | |||
@@ -0,0 +1,141 @@ | |||
1 | libgnunetfs_src = ['fs_api.c', | ||
2 | 'fs_directory.c', | ||
3 | 'fs_dirmetascan.c', | ||
4 | 'fs_download.c', | ||
5 | 'fs_file_information.c', | ||
6 | 'fs_getopt.c', | ||
7 | 'fs_list_indexed.c', | ||
8 | 'fs_publish.c', | ||
9 | 'fs_publish_ksk.c', | ||
10 | 'fs_publish_ublock.c', | ||
11 | 'fs_misc.c', | ||
12 | 'fs_namespace.c', | ||
13 | 'fs_search.c', | ||
14 | 'fs_sharetree.c', | ||
15 | 'fs_tree.c', | ||
16 | 'fs_unindex.c', | ||
17 | 'fs_uri.c', | ||
18 | 'meta_data.c'] | ||
19 | |||
20 | gnunetservicefs_src = ['gnunet-service-fs.c', | ||
21 | 'gnunet-service-fs_cp.c', | ||
22 | 'gnunet-service-fs_indexing.c', | ||
23 | 'gnunet-service-fs_pe.c', | ||
24 | 'gnunet-service-fs_pr.c', | ||
25 | 'gnunet-service-fs_push.c', | ||
26 | 'gnunet-service-fs_put.c', | ||
27 | 'gnunet-service-fs_cadet_client.c', | ||
28 | 'gnunet-service-fs_cadet_server.c'] | ||
29 | |||
30 | configure_file(input : 'fs.conf.in', | ||
31 | output : 'fs.conf', | ||
32 | configuration : cdata, | ||
33 | install: true, | ||
34 | install_dir: pkgcfgdir) | ||
35 | |||
36 | |||
37 | if get_option('monolith') | ||
38 | foreach p : libgnunetfs_src + gnunetservicefs_src | ||
39 | gnunet_src += 'fs/' + p | ||
40 | endforeach | ||
41 | endif | ||
42 | |||
43 | libgnunetfs = library('gnunetfs', | ||
44 | libgnunetfs_src, | ||
45 | soversion: '2', | ||
46 | version: '2.1.1', | ||
47 | dependencies: [libgnunetutil_dep, | ||
48 | libgnunetdatastore_dep, | ||
49 | libgnunetstatistics_dep, | ||
50 | unistr_dep], | ||
51 | include_directories: [incdir, configuration_inc], | ||
52 | install: true, | ||
53 | install_dir: get_option('libdir')) | ||
54 | libgnunetfs_dep = declare_dependency(link_with : libgnunetfs) | ||
55 | pkg.generate(libgnunetfs, url: 'https://www.gnunet.org', | ||
56 | description : 'Provides API for GNUnet File-Sharing service') | ||
57 | |||
58 | shared_module('gnunet_plugin_block_fs', | ||
59 | ['plugin_block_fs.c'], | ||
60 | dependencies: [libgnunetutil_dep, | ||
61 | libgnunetblockgroup_dep], | ||
62 | include_directories: [incdir, configuration_inc], | ||
63 | install:true, | ||
64 | install_dir: get_option('libdir')/'gnunet') | ||
65 | |||
66 | executable ('gnunet-search', | ||
67 | 'gnunet-search.c', | ||
68 | dependencies: [libgnunetfs_dep, | ||
69 | libgnunetutil_dep], | ||
70 | include_directories: [incdir, configuration_inc], | ||
71 | install: true, | ||
72 | install_dir: get_option('bindir')) | ||
73 | executable ('gnunet-unindex', | ||
74 | 'gnunet-unindex.c', | ||
75 | dependencies: [libgnunetfs_dep, | ||
76 | libgnunetutil_dep], | ||
77 | include_directories: [incdir, configuration_inc], | ||
78 | install: true, | ||
79 | install_dir: get_option('bindir')) | ||
80 | executable ('gnunet-auto-share', | ||
81 | 'gnunet-auto-share.c', | ||
82 | dependencies: [libgnunetfs_dep, | ||
83 | libgnunetutil_dep], | ||
84 | include_directories: [incdir, configuration_inc], | ||
85 | install: true, | ||
86 | install_dir: get_option('bindir')) | ||
87 | executable ('gnunet-directory', | ||
88 | 'gnunet-directory.c', | ||
89 | dependencies: [libgnunetfs_dep, | ||
90 | libgnunetutil_dep], | ||
91 | include_directories: [incdir, configuration_inc], | ||
92 | install: true, | ||
93 | install_dir: get_option('bindir')) | ||
94 | executable ('gnunet-download', | ||
95 | 'gnunet-download.c', | ||
96 | dependencies: [libgnunetfs_dep, | ||
97 | libgnunetutil_dep], | ||
98 | include_directories: [incdir, configuration_inc], | ||
99 | install: true, | ||
100 | install_dir: get_option('bindir')) | ||
101 | executable ('gnunet-fs', | ||
102 | 'gnunet-fs.c', | ||
103 | dependencies: [libgnunetfs_dep, | ||
104 | libgnunetutil_dep], | ||
105 | include_directories: [incdir, configuration_inc], | ||
106 | install: true, | ||
107 | install_dir: get_option('bindir')) | ||
108 | executable ('gnunet-publish', | ||
109 | 'gnunet-publish.c', | ||
110 | dependencies: [libgnunetfs_dep, | ||
111 | libgnunetidentity_dep, | ||
112 | libgnunetutil_dep], | ||
113 | include_directories: [incdir, configuration_inc], | ||
114 | install: true, | ||
115 | install_dir: get_option('bindir')) | ||
116 | executable ('gnunet-service-fs', | ||
117 | gnunetservicefs_src, | ||
118 | dependencies: [libgnunetfs_dep, | ||
119 | libgnunetutil_dep, | ||
120 | libgnunetstatistics_dep, | ||
121 | libgnunetcore_dep, | ||
122 | libgnunetdht_dep, | ||
123 | libgnunetidentity_dep, | ||
124 | m_dep, | ||
125 | libgnunetats_dep, | ||
126 | libgnunetcadet_dep, | ||
127 | libgnunetpeerstore_dep, | ||
128 | libgnunetdatastore_dep, | ||
129 | libgnunetblock_dep], | ||
130 | include_directories: [incdir, configuration_inc], | ||
131 | install: true, | ||
132 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
133 | executable ('gnunet-helper-fs-publish', | ||
134 | ['gnunet-helper-fs-publish.c'], | ||
135 | dependencies: [libgnunetfs_dep, | ||
136 | libgnunetutil_dep, | ||
137 | libgnunetblock_dep], | ||
138 | include_directories: [incdir, configuration_inc], | ||
139 | install: true, | ||
140 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
141 | |||
diff --git a/src/fs/meta_data.c b/src/fs/meta_data.c index 7112a150a..cf9448aa4 100644 --- a/src/fs/meta_data.c +++ b/src/fs/meta_data.c | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include "gnunet_common.h" | ||
29 | #include "platform.h" | 30 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
@@ -1050,7 +1051,7 @@ GNUNET_FS_meta_data_deserialize (const char *input, size_t size) | |||
1050 | * @param result the buffer to store a pointer to the (allocated) metadata | 1051 | * @param result the buffer to store a pointer to the (allocated) metadata |
1051 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 1052 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
1052 | */ | 1053 | */ |
1053 | int | 1054 | enum GNUNET_GenericReturnValue |
1054 | GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | 1055 | GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h, |
1055 | const char *what, | 1056 | const char *what, |
1056 | struct GNUNET_FS_MetaData **result) | 1057 | struct GNUNET_FS_MetaData **result) |
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 312fde293..b38f0a425 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -1345,7 +1345,7 @@ create_mhd_response_from_s5r (struct Socks5Request *s5r) | |||
1345 | &resp_code)); | 1345 | &resp_code)); |
1346 | GNUNET_break (CURLE_OK == | 1346 | GNUNET_break (CURLE_OK == |
1347 | curl_easy_getinfo (s5r->curl, | 1347 | curl_easy_getinfo (s5r->curl, |
1348 | CURLINFO_CONTENT_LENGTH_DOWNLOAD, | 1348 | CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, |
1349 | &content_length)); | 1349 | &content_length)); |
1350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1351 | "Creating MHD response with code %d and size %d for %s%s\n", | 1351 | "Creating MHD response with code %d and size %d for %s%s\n", |
diff --git a/src/gns/meson.build b/src/gns/meson.build new file mode 100644 index 000000000..6e001cf8b --- /dev/null +++ b/src/gns/meson.build | |||
@@ -0,0 +1,162 @@ | |||
1 | libgnunetgns_src = ['gns_api.c', 'gns_tld_api.c'] | ||
2 | |||
3 | gnunetservicegns_src = ['gnunet-service-gns.c', | ||
4 | 'gnunet-service-gns_resolver.c', | ||
5 | 'gnunet-service-gns_interceptor.c'] | ||
6 | |||
7 | gnunetgnsproxy_src = ['gnunet-gns-proxy.c'] | ||
8 | |||
9 | configure_file(input : 'gns.conf.in', | ||
10 | output : 'gns.conf', | ||
11 | configuration : cdata, | ||
12 | install: true, | ||
13 | install_dir: pkgcfgdir) | ||
14 | configure_file(input : 'tlds.conf', | ||
15 | output : 'tlds.conf', | ||
16 | configuration : cdata, | ||
17 | install: true, | ||
18 | install_dir: pkgcfgdir) | ||
19 | |||
20 | configure_file(input : 'gnunet-gns-proxy-setup-ca.in', | ||
21 | output : 'gnunet-gns-proxy-setup-ca', | ||
22 | configuration : cdata, | ||
23 | install: true, | ||
24 | install_dir: get_option('bindir')) | ||
25 | |||
26 | install_data('gnunet-gns-proxy-ca.template', | ||
27 | install_dir: get_option('datadir')/'gnunet') | ||
28 | |||
29 | if get_option('monolith') | ||
30 | foreach p : libgnunetgns_src + gnunetservicegns_src | ||
31 | gnunet_src += 'gns/' + p | ||
32 | endforeach | ||
33 | subdir_done() | ||
34 | endif | ||
35 | |||
36 | libgnunetgns = library('gnunetgns', | ||
37 | libgnunetgns_src, | ||
38 | soversion: '0', | ||
39 | version: '0.0.0', | ||
40 | dependencies: [libgnunetutil_dep, | ||
41 | libgnunetgnsrecord_dep, | ||
42 | libgnunetidentity_dep], | ||
43 | include_directories: [incdir, configuration_inc], | ||
44 | install: true, | ||
45 | install_dir: get_option('libdir')) | ||
46 | libgnunetgns_dep = declare_dependency(link_with : libgnunetgns) | ||
47 | pkg.generate(libgnunetgns, url: 'https://www.gnunet.org', | ||
48 | description : 'Provides API to access the GNU Name System') | ||
49 | |||
50 | shared_module('gnunet_plugin_gnsrecord_gns', | ||
51 | ['plugin_gnsrecord_gns.c'], | ||
52 | dependencies: [libgnunetutil_dep, | ||
53 | libgnunetgnsrecord_dep, | ||
54 | libgnunetidentity_dep], | ||
55 | include_directories: [incdir, configuration_inc], | ||
56 | install: true, | ||
57 | install_dir: get_option('libdir')/'gnunet') | ||
58 | shared_module('gnunet_plugin_block_gns', | ||
59 | ['plugin_block_gns.c'], | ||
60 | dependencies: [libgnunetutil_dep, | ||
61 | libgnunetgnsrecord_dep, | ||
62 | libgnunetblockgroup_dep], | ||
63 | include_directories: [incdir, configuration_inc], | ||
64 | install:true, | ||
65 | install_dir: get_option('libdir')/'gnunet') | ||
66 | shared_module('gnunet_plugin_rest_gns', | ||
67 | ['plugin_rest_gns.c'], | ||
68 | dependencies: [libgnunetrest_dep, | ||
69 | libgnunetgnsrecord_dep, | ||
70 | libgnunetgnsrecordjson_dep, | ||
71 | libgnunetgns_dep, | ||
72 | libgnunetutil_dep, | ||
73 | json_dep, | ||
74 | mhd_dep], | ||
75 | include_directories: [incdir, configuration_inc], | ||
76 | install: true, | ||
77 | install_dir: get_option('libdir') / 'gnunet') | ||
78 | |||
79 | |||
80 | executable ('gnunet-gns', | ||
81 | 'gnunet-gns.c', | ||
82 | dependencies: [libgnunetgns_dep, | ||
83 | libgnunetgnsrecord_dep, | ||
84 | idn_dep, | ||
85 | libgnunetutil_dep], | ||
86 | include_directories: [incdir, configuration_inc], | ||
87 | install: true, | ||
88 | install_dir: get_option('bindir')) | ||
89 | executable ('gnunet-gns-proxy', | ||
90 | gnunetgnsproxy_src, | ||
91 | dependencies: [libgnunetgns_dep, | ||
92 | libgnunetutil_dep, | ||
93 | mhd_dep, | ||
94 | idn_dep, | ||
95 | curl_dep, | ||
96 | gnutls_dep, | ||
97 | libgnunetidentity_dep], | ||
98 | include_directories: [incdir, configuration_inc], | ||
99 | install: true, | ||
100 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
101 | |||
102 | executable ('gnunet-service-gns', | ||
103 | gnunetservicegns_src, | ||
104 | dependencies: [libgnunetgns_dep, | ||
105 | libgnunetutil_dep, | ||
106 | libgnunetstatistics_dep, | ||
107 | libgnunetcore_dep, | ||
108 | libgnunetdht_dep, | ||
109 | libgnunetdns_dep, | ||
110 | idn_dep, | ||
111 | libgnunetidentity_dep, | ||
112 | libgnunetnamecache_dep, | ||
113 | libgnunetrevocation_dep, | ||
114 | libgnunetgnsrecord_dep, | ||
115 | libgnunetcadet_dep, | ||
116 | libgnunetblock_dep], | ||
117 | include_directories: [incdir, configuration_inc], | ||
118 | install: true, | ||
119 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
120 | executable ('gnunet-bcd', | ||
121 | ['gnunet-bcd.c'], | ||
122 | dependencies: [libgnunetgns_dep, | ||
123 | libgnunetutil_dep, | ||
124 | libgnunetstatistics_dep, | ||
125 | libgnunetcore_dep, | ||
126 | libgnunetdht_dep, | ||
127 | libgnunetdns_dep, | ||
128 | mhd_dep, | ||
129 | idn_dep, | ||
130 | libgnunetidentity_dep, | ||
131 | libgnunetnamecache_dep, | ||
132 | libgnunetrevocation_dep, | ||
133 | libgnunetgnsrecord_dep, | ||
134 | libgnunetcadet_dep, | ||
135 | libgnunetblock_dep], | ||
136 | include_directories: [incdir, configuration_inc], | ||
137 | install: true, | ||
138 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
139 | executable ('gnunet-dns2gns', | ||
140 | ['gnunet-dns2gns.c'], | ||
141 | dependencies: [libgnunetgns_dep, | ||
142 | libgnunetutil_dep, | ||
143 | libgnunetstatistics_dep, | ||
144 | libgnunetvpn_dep, | ||
145 | libgnunetcore_dep, | ||
146 | libgnunetdht_dep, | ||
147 | libgnunetdns_dep, | ||
148 | idn_dep, | ||
149 | libgnunetidentity_dep, | ||
150 | libgnunetnamecache_dep, | ||
151 | libgnunetrevocation_dep, | ||
152 | libgnunetgnsrecord_dep, | ||
153 | libgnunetcadet_dep, | ||
154 | libgnunetblock_dep], | ||
155 | include_directories: [incdir, configuration_inc], | ||
156 | install: true, | ||
157 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
158 | |||
159 | |||
160 | if have_nss | ||
161 | subdir('nss') | ||
162 | endif | ||
diff --git a/src/gns/nss/meson.build b/src/gns/nss/meson.build new file mode 100644 index 000000000..7fd00ceb1 --- /dev/null +++ b/src/gns/nss/meson.build | |||
@@ -0,0 +1,34 @@ | |||
1 | # FIXME: | ||
2 | # | ||
3 | # EXTRA_DIST = map-file | ||
4 | # AM_LDFLAGS=-avoid-version -module -export-dynamic | ||
5 | # | ||
6 | shared_library('nss_gns', | ||
7 | ['nss_gns_query.c', 'nss_gns.c'], | ||
8 | soversion: '2', | ||
9 | dependencies: [libgnunetutil_dep, | ||
10 | libgnunetgnsrecord_dep], | ||
11 | #link_args: ['-fno-version', '-module', '-export-dynamic', '-shrext', '.so.2', '-W', 'l'], | ||
12 | include_directories: [incdir, configuration_inc], | ||
13 | install: true, | ||
14 | install_dir: get_option('libdir')) | ||
15 | shared_library('nss_gns4', | ||
16 | ['nss_gns_query.c', 'nss_gns.c'], | ||
17 | soversion: '2', | ||
18 | c_args: ['-DNSS_IPV4_ONLY=1'], | ||
19 | dependencies: [libgnunetutil_dep, | ||
20 | libgnunetgnsrecord_dep], | ||
21 | #link_args: ['-fno-version', '-module', '-export-dynamic', '-shrext', '.so.2', '-W', 'l'], | ||
22 | include_directories: [incdir, configuration_inc], | ||
23 | install: true, | ||
24 | install_dir: get_option('libdir')) | ||
25 | shared_library('nss_gns6', | ||
26 | ['nss_gns_query.c', 'nss_gns.c'], | ||
27 | c_args: ['-DNSS_IPV6_ONLY=1'], | ||
28 | soversion: '2', | ||
29 | dependencies: [libgnunetutil_dep, | ||
30 | libgnunetgnsrecord_dep], | ||
31 | #link_args: ['-fno-version', '-module', '-export-dynamic', '-shrext', '.so.2', '-W', 'l'], | ||
32 | include_directories: [incdir, configuration_inc], | ||
33 | install: true, | ||
34 | install_dir: get_option('libdir')) | ||
diff --git a/src/gns/tlds.conf b/src/gns/tlds.conf new file mode 100644 index 000000000..a600a3d66 --- /dev/null +++ b/src/gns/tlds.conf | |||
@@ -0,0 +1,15 @@ | |||
1 | # WARNING: | ||
2 | # This header is generated! | ||
3 | # In order to add TLDs, you must register | ||
4 | # them in GANA, and then use the header generation script | ||
5 | # to create an update of this file. You may then replace this | ||
6 | # file with the update. | ||
7 | [gns] | ||
8 | |||
9 | # The FCFS authority managed by GNUnet e.V. | ||
10 | .pin = 000G001MF6DVMZZ4Y8XRZQDXM1PB3D3VGEK29ZHXBA57EPSNW1QBPKT8J0 | ||
11 | |||
12 | |||
13 | # The authoritative zone of the GNUnet project | ||
14 | .gnunet.org = 000G0047M3HN599H57MPXZK4VB59SWK4M9NRD68E1JQFY3RWAHDMKAPN30 | ||
15 | |||
diff --git a/src/gnsrecord/Makefile.am b/src/gnsrecord/Makefile.am index 1cd446400..7ef7c327e 100644 --- a/src/gnsrecord/Makefile.am +++ b/src/gnsrecord/Makefile.am | |||
@@ -19,6 +19,7 @@ noinst_PROGRAMS = \ | |||
19 | check_PROGRAMS = \ | 19 | check_PROGRAMS = \ |
20 | test_gnsrecord_crypto \ | 20 | test_gnsrecord_crypto \ |
21 | test_gnsrecord_serialization \ | 21 | test_gnsrecord_serialization \ |
22 | test_gnsrecord_lsd0001testvectors \ | ||
22 | test_gnsrecord_block_expiration \ | 23 | test_gnsrecord_block_expiration \ |
23 | perf_gnsrecord_crypto | 24 | perf_gnsrecord_crypto |
24 | 25 | ||
@@ -86,13 +87,13 @@ libgnunet_plugin_gnsrecord_dns_la_LDFLAGS = \ | |||
86 | EXTRA_DIST = \ | 87 | EXTRA_DIST = \ |
87 | $(check_SCRIPTS) | 88 | $(check_SCRIPTS) |
88 | 89 | ||
89 | #test_gnsrecord_testvectors_SOURCES = \ | 90 | test_gnsrecord_lsd0001testvectors_SOURCES = \ |
90 | # test_gnsrecord_testvectors.c | 91 | test_gnsrecord_testvectors.c |
91 | #test_gnsrecord_testvectors_LDADD = \ | 92 | test_gnsrecord_lsd0001testvectors_LDADD = \ |
92 | # $(top_builddir)/src/testing/libgnunettesting.la \ | 93 | $(top_builddir)/src/testing/libgnunettesting.la \ |
93 | # $(top_builddir)/src/identity/libgnunetidentity.la \ | 94 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
94 | # libgnunetgnsrecord.la \ | 95 | libgnunetgnsrecord.la \ |
95 | # $(top_builddir)/src/util/libgnunetutil.la | 96 | $(top_builddir)/src/util/libgnunetutil.la |
96 | 97 | ||
97 | 98 | ||
98 | test_gnsrecord_serialization_SOURCES = \ | 99 | test_gnsrecord_serialization_SOURCES = \ |
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c index e6036b72b..384336c97 100644 --- a/src/gnsrecord/gnsrecord_crypto.c +++ b/src/gnsrecord/gnsrecord_crypto.c | |||
@@ -195,6 +195,7 @@ block_get_size_ecdsa (const struct GNUNET_GNSRECORD_Data *rd, | |||
195 | return len; | 195 | return len; |
196 | } | 196 | } |
197 | 197 | ||
198 | |||
198 | enum GNUNET_GenericReturnValue | 199 | enum GNUNET_GenericReturnValue |
199 | block_sign_ecdsa (const struct | 200 | block_sign_ecdsa (const struct |
200 | GNUNET_CRYPTO_EcdsaPrivateKey *key, | 201 | GNUNET_CRYPTO_EcdsaPrivateKey *key, |
@@ -400,6 +401,7 @@ block_create_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
400 | return GNUNET_OK; | 401 | return GNUNET_OK; |
401 | } | 402 | } |
402 | 403 | ||
404 | |||
403 | static ssize_t | 405 | static ssize_t |
404 | block_get_size_eddsa (const struct GNUNET_GNSRECORD_Data *rd, | 406 | block_get_size_eddsa (const struct GNUNET_GNSRECORD_Data *rd, |
405 | unsigned int rd_count) | 407 | unsigned int rd_count) |
@@ -505,6 +507,7 @@ block_create_eddsa (const struct GNUNET_CRYPTO_EddsaPrivateKey *key, | |||
505 | return GNUNET_OK; | 507 | return GNUNET_OK; |
506 | } | 508 | } |
507 | 509 | ||
510 | |||
508 | ssize_t | 511 | ssize_t |
509 | GNUNET_GNSRECORD_block_calculate_size (const struct | 512 | GNUNET_GNSRECORD_block_calculate_size (const struct |
510 | GNUNET_IDENTITY_PrivateKey *key, | 513 | GNUNET_IDENTITY_PrivateKey *key, |
@@ -531,6 +534,7 @@ GNUNET_GNSRECORD_block_calculate_size (const struct | |||
531 | 534 | ||
532 | } | 535 | } |
533 | 536 | ||
537 | |||
534 | enum GNUNET_GenericReturnValue | 538 | enum GNUNET_GenericReturnValue |
535 | GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, | 539 | GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, |
536 | struct GNUNET_TIME_Absolute expire, | 540 | struct GNUNET_TIME_Absolute expire, |
@@ -655,7 +659,6 @@ block_create2 (const struct GNUNET_IDENTITY_PrivateKey *pkey, | |||
655 | } | 659 | } |
656 | 660 | ||
657 | 661 | ||
658 | |||
659 | enum GNUNET_GenericReturnValue | 662 | enum GNUNET_GenericReturnValue |
660 | GNUNET_GNSRECORD_block_create_unsigned (const struct | 663 | GNUNET_GNSRECORD_block_create_unsigned (const struct |
661 | GNUNET_IDENTITY_PrivateKey *pkey, | 664 | GNUNET_IDENTITY_PrivateKey *pkey, |
@@ -669,7 +672,6 @@ GNUNET_GNSRECORD_block_create_unsigned (const struct | |||
669 | } | 672 | } |
670 | 673 | ||
671 | 674 | ||
672 | |||
673 | enum GNUNET_GenericReturnValue | 675 | enum GNUNET_GenericReturnValue |
674 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *pkey, | 676 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *pkey, |
675 | struct GNUNET_TIME_Absolute expire, | 677 | struct GNUNET_TIME_Absolute expire, |
@@ -681,6 +683,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *pkey, | |||
681 | return block_create2 (pkey, expire, label, rd, rd_count, result, GNUNET_YES); | 683 | return block_create2 (pkey, expire, label, rd, rd_count, result, GNUNET_YES); |
682 | } | 684 | } |
683 | 685 | ||
686 | |||
684 | /** | 687 | /** |
685 | * Check if a signature is valid. This API is used by the GNS Block | 688 | * Check if a signature is valid. This API is used by the GNS Block |
686 | * to validate signatures received from the network. | 689 | * to validate signatures received from the network. |
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index fde553a83..4727842ea 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | * @author Matthias Wachs | 25 | * @author Matthias Wachs |
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | */ | 27 | */ |
28 | #include "gnunet_common.h" | ||
28 | #include "platform.h" | 29 | #include "platform.h" |
29 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_constants.h" | 31 | #include "gnunet_constants.h" |
@@ -89,7 +90,7 @@ GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z) | |||
89 | * @param b record | 90 | * @param b record |
90 | * @return #GNUNET_YES if the records are equal or #GNUNET_NO if they are not | 91 | * @return #GNUNET_YES if the records are equal or #GNUNET_NO if they are not |
91 | */ | 92 | */ |
92 | int | 93 | enum GNUNET_GenericReturnValue |
93 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | 94 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, |
94 | const struct GNUNET_GNSRECORD_Data *b) | 95 | const struct GNUNET_GNSRECORD_Data *b) |
95 | { | 96 | { |
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c index ef111b3bd..eebbedf21 100644 --- a/src/gnsrecord/gnunet-gnsrecord-tvg.c +++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c | |||
@@ -71,8 +71,17 @@ print_bytes_ (void *buf, | |||
71 | 71 | ||
72 | for (i = 0; i < buf_len; i++) | 72 | for (i = 0; i < buf_len; i++) |
73 | { | 73 | { |
74 | if ((0 != i) && (0 != fold) && (i % fold == 0)) | 74 | if (0 != i) |
75 | printf ("\n"); | 75 | { |
76 | if ((0 != fold) && (i % fold == 0)) | ||
77 | printf ("\n "); | ||
78 | else | ||
79 | printf (" "); | ||
80 | } | ||
81 | else | ||
82 | { | ||
83 | printf (" "); | ||
84 | } | ||
76 | if (in_be) | 85 | if (in_be) |
77 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | 86 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); |
78 | else | 87 | else |
@@ -94,21 +103,30 @@ print_bytes (void *buf, | |||
94 | static void | 103 | static void |
95 | print_record (const struct GNUNET_GNSRECORD_Data *rd) | 104 | print_record (const struct GNUNET_GNSRECORD_Data *rd) |
96 | { | 105 | { |
106 | struct GNUNET_TIME_Relative rt; | ||
107 | struct GNUNET_TIME_Absolute at; | ||
97 | uint16_t flags = htons (rd->flags); | 108 | uint16_t flags = htons (rd->flags); |
98 | uint64_t abs_nbo = GNUNET_htonll (rd->expiration_time); | 109 | uint64_t abs_nbo = GNUNET_htonll (rd->expiration_time); |
99 | uint16_t size_nbo = htons (rd->data_size); | 110 | uint16_t size_nbo = htons (rd->data_size); |
100 | uint32_t type_nbo = htonl (rd->record_type); | 111 | uint32_t type_nbo = htonl (rd->record_type); |
101 | printf ("EXPIRATION:\n"); | 112 | at.abs_value_us = GNUNET_ntohll (abs_nbo); |
113 | if (0 != (rd->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
114 | { | ||
115 | rt.rel_value_us = rd->expiration_time; | ||
116 | at = GNUNET_TIME_relative_to_absolute (rt); | ||
117 | abs_nbo = GNUNET_htonll (at.abs_value_us); | ||
118 | } | ||
119 | printf (" EXPIRATION: %" PRIu64 " us\n", rd->expiration_time); | ||
102 | print_bytes (&abs_nbo, sizeof (abs_nbo), 8); | 120 | print_bytes (&abs_nbo, sizeof (abs_nbo), 8); |
103 | printf ("\nDATA_SIZE:\n"); | 121 | printf ("\n DATA_SIZE:\n"); |
104 | print_bytes (&size_nbo, sizeof (size_nbo), 8); | 122 | print_bytes (&size_nbo, sizeof (size_nbo), 8); |
105 | printf ("\nTYPE:\n"); | 123 | printf ("\n TYPE:\n"); |
106 | print_bytes (&type_nbo, sizeof (type_nbo), 8); | 124 | print_bytes (&type_nbo, sizeof (type_nbo), 8); |
107 | printf ("\nFLAGS: "); | 125 | printf ("\n FLAGS: "); |
108 | print_bytes ((void*) &flags, sizeof (flags), 8); | 126 | print_bytes ((void*) &flags, sizeof (flags), 8); |
109 | printf ("\n"); | 127 | printf ("\n"); |
110 | fprintf (stdout, | 128 | fprintf (stdout, |
111 | "DATA:\n"); | 129 | " DATA:\n"); |
112 | print_bytes ((char*) rd->data, rd->data_size, 8); | 130 | print_bytes ((char*) rd->data, rd->data_size, 8); |
113 | printf ("\n"); | 131 | printf ("\n"); |
114 | } | 132 | } |
@@ -156,7 +174,8 @@ run_pkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label) | |||
156 | GNUNET_assert (0 < GNUNET_IDENTITY_public_key_get_length (&id_pub)); | 174 | GNUNET_assert (0 < GNUNET_IDENTITY_public_key_get_length (&id_pub)); |
157 | print_bytes (&id_pub, GNUNET_IDENTITY_public_key_get_length (&id_pub), 8); | 175 | print_bytes (&id_pub, GNUNET_IDENTITY_public_key_get_length (&id_pub), 8); |
158 | GNUNET_STRINGS_data_to_string (&id_pub, | 176 | GNUNET_STRINGS_data_to_string (&id_pub, |
159 | GNUNET_IDENTITY_public_key_get_length (&id_pub), | 177 | GNUNET_IDENTITY_public_key_get_length ( |
178 | &id_pub), | ||
160 | ztld, | 179 | ztld, |
161 | sizeof (ztld)); | 180 | sizeof (ztld)); |
162 | printf ("\n"); | 181 | printf ("\n"); |
@@ -220,9 +239,27 @@ run_pkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label) | |||
220 | rd, | 239 | rd, |
221 | rd_count, | 240 | rd_count, |
222 | &rrblock)); | 241 | &rrblock)); |
242 | struct GNUNET_CRYPTO_EcdsaPublicKey derived_key; | ||
243 | struct GNUNET_CRYPTO_EcdsaPrivateKey *derived_privkey; | ||
244 | |||
245 | GNUNET_CRYPTO_ecdsa_public_key_derive (&id_pub.ecdsa_key, | ||
246 | label, | ||
247 | "gns", | ||
248 | &derived_key); | ||
249 | derived_privkey = GNUNET_CRYPTO_ecdsa_private_key_derive (&id_priv.ecdsa_key, | ||
250 | label, | ||
251 | "gns"); | ||
252 | printf ("ZKDF(zkey):\n"); | ||
253 | print_bytes (&derived_key, sizeof (derived_key), 8); | ||
254 | printf ("\n"); | ||
255 | printf ("Derived private key (d', big-endian):\n"); | ||
256 | print_bytes_ (derived_privkey, sizeof (*derived_privkey), 8, 1); | ||
257 | printf ("\n"); | ||
223 | size_t bdata_size = ntohl (rrblock->size) - sizeof (struct | 258 | size_t bdata_size = ntohl (rrblock->size) - sizeof (struct |
224 | GNUNET_GNSRECORD_Block); | 259 | GNUNET_GNSRECORD_Block); |
225 | 260 | ||
261 | GNUNET_free (derived_privkey); | ||
262 | |||
226 | bdata = (char*) &(&rrblock->ecdsa_block)[1]; | 263 | bdata = (char*) &(&rrblock->ecdsa_block)[1]; |
227 | printf ("BDATA:\n"); | 264 | printf ("BDATA:\n"); |
228 | print_bytes (bdata, bdata_size, 8); | 265 | print_bytes (bdata, bdata_size, 8); |
@@ -282,7 +319,8 @@ run_edkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char*label) | |||
282 | GNUNET_assert (0 < GNUNET_IDENTITY_public_key_get_length (&id_pub)); | 319 | GNUNET_assert (0 < GNUNET_IDENTITY_public_key_get_length (&id_pub)); |
283 | print_bytes (&id_pub, GNUNET_IDENTITY_public_key_get_length (&id_pub), 8); | 320 | print_bytes (&id_pub, GNUNET_IDENTITY_public_key_get_length (&id_pub), 8); |
284 | GNUNET_STRINGS_data_to_string (&id_pub, | 321 | GNUNET_STRINGS_data_to_string (&id_pub, |
285 | GNUNET_IDENTITY_public_key_get_length (&id_pub), | 322 | GNUNET_IDENTITY_public_key_get_length ( |
323 | &id_pub), | ||
286 | ztld, | 324 | ztld, |
287 | sizeof (ztld)); | 325 | sizeof (ztld)); |
288 | printf ("\n"); | 326 | printf ("\n"); |
@@ -349,9 +387,33 @@ run_edkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char*label) | |||
349 | rd, | 387 | rd, |
350 | rd_count, | 388 | rd_count, |
351 | &rrblock)); | 389 | &rrblock)); |
390 | |||
391 | struct GNUNET_CRYPTO_EddsaPublicKey derived_key; | ||
392 | struct GNUNET_CRYPTO_EddsaPrivateScalar derived_privkey; | ||
393 | GNUNET_CRYPTO_eddsa_public_key_derive (&id_pub.eddsa_key, | ||
394 | label, | ||
395 | "gns", | ||
396 | &derived_key); | ||
397 | GNUNET_CRYPTO_eddsa_private_key_derive (&id_priv.eddsa_key, | ||
398 | label, | ||
399 | "gns", &derived_privkey); | ||
400 | printf ("ZKDF(zkey):\n"); | ||
401 | print_bytes (&derived_key, sizeof (derived_key), 8); | ||
402 | printf ("\n"); | ||
403 | printf ("nonce := SHA-256 (dh[32..63] || h):\n"); | ||
404 | print_bytes (derived_privkey.s + 32, 32, 8); | ||
405 | printf ("\n"); | ||
406 | char derived_privkeyNBO[32]; | ||
407 | /* Convert from little endian */ | ||
408 | for (size_t i = 0; i < 32; i++) | ||
409 | derived_privkeyNBO[i] = derived_privkey.s[31 - i]; | ||
410 | printf ("Derived private key (d', big-endian):\n"); | ||
411 | print_bytes (derived_privkeyNBO, sizeof (derived_privkeyNBO), 8); | ||
412 | printf ("\n"); | ||
352 | size_t bdata_size = ntohl (rrblock->size) - sizeof (struct | 413 | size_t bdata_size = ntohl (rrblock->size) - sizeof (struct |
353 | GNUNET_GNSRECORD_Block); | 414 | GNUNET_GNSRECORD_Block); |
354 | 415 | ||
416 | |||
355 | bdata = (char*) &(&rrblock->eddsa_block)[1]; | 417 | bdata = (char*) &(&rrblock->eddsa_block)[1]; |
356 | printf ("BDATA:\n"); | 418 | printf ("BDATA:\n"); |
357 | print_bytes (bdata, bdata_size, 8); | 419 | print_bytes (bdata, bdata_size, 8); |
@@ -381,7 +443,10 @@ run (void *cls, | |||
381 | struct GNUNET_GNSRECORD_Data rd[3]; | 443 | struct GNUNET_GNSRECORD_Data rd[3]; |
382 | struct GNUNET_TIME_Absolute exp1; | 444 | struct GNUNET_TIME_Absolute exp1; |
383 | struct GNUNET_TIME_Absolute exp2; | 445 | struct GNUNET_TIME_Absolute exp2; |
384 | struct GNUNET_TIME_Relative exp3; | 446 | struct GNUNET_TIME_Absolute exp3; |
447 | struct GNUNET_TIME_AbsoluteNBO exp1nbo; | ||
448 | struct GNUNET_TIME_AbsoluteNBO exp2nbo; | ||
449 | struct GNUNET_TIME_AbsoluteNBO exp3nbo; | ||
385 | size_t pkey_data_size; | 450 | size_t pkey_data_size; |
386 | size_t ip_data_size; | 451 | size_t ip_data_size; |
387 | char *pkey_data; | 452 | char *pkey_data; |
@@ -390,13 +455,12 @@ run (void *cls, | |||
390 | /* | 455 | /* |
391 | * Make different expiration times | 456 | * Make different expiration times |
392 | */ | 457 | */ |
393 | GNUNET_STRINGS_fancy_time_to_absolute ("2048-01-23 10:51:34", | 458 | parsehex ("001cee8c10e25980", (char*) &exp1nbo, sizeof (exp1nbo), 0); |
394 | &exp1); | 459 | parsehex ("003ff2aa5408db40", (char*) &exp2nbo, sizeof (exp2nbo), 0); |
395 | GNUNET_STRINGS_fancy_time_to_absolute ("3540-05-22 07:55:01", | 460 | parsehex ("0028bb13ff371940", (char*) &exp3nbo, sizeof (exp3nbo), 0); |
396 | &exp2); | 461 | exp1 = GNUNET_TIME_absolute_ntoh (exp1nbo); |
397 | GNUNET_STRINGS_fancy_time_to_relative ("100y", | 462 | exp2 = GNUNET_TIME_absolute_ntoh (exp2nbo); |
398 | &exp3); | 463 | exp3 = GNUNET_TIME_absolute_ntoh (exp3nbo); |
399 | |||
400 | 464 | ||
401 | memset (&rd_pkey, 0, sizeof (struct GNUNET_GNSRECORD_Data)); | 465 | memset (&rd_pkey, 0, sizeof (struct GNUNET_GNSRECORD_Data)); |
402 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_string_to_value ( | 466 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_string_to_value ( |
@@ -425,14 +489,13 @@ run (void *cls, | |||
425 | rd[1].data_size = strlen (rd[1].data); | 489 | rd[1].data_size = strlen (rd[1].data); |
426 | rd[1].expiration_time = exp2.abs_value_us; | 490 | rd[1].expiration_time = exp2.abs_value_us; |
427 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; | 491 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; |
428 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; | 492 | rd[1].flags = GNUNET_GNSRECORD_RF_NONE; |
429 | 493 | ||
430 | rd[2].data = "Hello World"; | 494 | rd[2].data = "Hello World"; |
431 | rd[2].data_size = strlen (rd[2].data); | 495 | rd[2].data_size = strlen (rd[2].data); |
432 | rd[2].expiration_time = exp3.rel_value_us; | 496 | rd[2].expiration_time = exp3.abs_value_us; |
433 | rd[2].record_type = GNUNET_DNSPARSER_TYPE_TXT; | 497 | rd[2].record_type = GNUNET_DNSPARSER_TYPE_TXT; |
434 | rd[2].flags = GNUNET_GNSRECORD_RF_SUPPLEMENTAL | 498 | rd[2].flags = GNUNET_GNSRECORD_RF_SUPPLEMENTAL; |
435 | | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
436 | 499 | ||
437 | run_pkey (&rd_pkey, 1, "testdelegation"); | 500 | run_pkey (&rd_pkey, 1, "testdelegation"); |
438 | run_pkey (rd, 3, "\u5929\u4e0b\u7121\u6575"); | 501 | run_pkey (rd, 3, "\u5929\u4e0b\u7121\u6575"); |
@@ -460,6 +523,8 @@ main (int argc, | |||
460 | GNUNET_log_setup ("gnunet-gns-tvg", | 523 | GNUNET_log_setup ("gnunet-gns-tvg", |
461 | "INFO", | 524 | "INFO", |
462 | NULL)); | 525 | NULL)); |
526 | // gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); | ||
527 | // gcry_control (GCRYCTL_SET_VERBOSITY, 99); | ||
463 | if (GNUNET_OK != | 528 | if (GNUNET_OK != |
464 | GNUNET_PROGRAM_run (argc, argv, | 529 | GNUNET_PROGRAM_run (argc, argv, |
465 | "gnunet-gns-tvg", | 530 | "gnunet-gns-tvg", |
diff --git a/src/gnsrecord/meson.build b/src/gnsrecord/meson.build new file mode 100644 index 000000000..11b355796 --- /dev/null +++ b/src/gnsrecord/meson.build | |||
@@ -0,0 +1,45 @@ | |||
1 | libgnunetgnsrecord_src = ['gnsrecord.c', | ||
2 | 'gnsrecord_serialization.c', | ||
3 | 'gnsrecord_crypto.c', | ||
4 | 'gnsrecord_misc.c'] | ||
5 | libgnunetgnsrecordjson_src = ['json_gnsrecord.c'] | ||
6 | |||
7 | if get_option('monolith') | ||
8 | foreach p : libgnunetgnsrecord_src + libgnunetgnsrecordjson_src | ||
9 | gnunet_src += 'gnsrecord/' + p | ||
10 | endforeach | ||
11 | subdir_done() | ||
12 | endif | ||
13 | |||
14 | libgnunetgnsrecord = library('gnunetgnsrecord', | ||
15 | libgnunetgnsrecord_src, | ||
16 | soversion: '0', | ||
17 | version: '0.0.0', | ||
18 | dependencies: [libgnunetutil_dep, | ||
19 | sodium_dep, | ||
20 | libgnunetidentity_dep, | ||
21 | gcrypt_dep], | ||
22 | include_directories: [incdir, configuration_inc], | ||
23 | install: true, | ||
24 | install_dir: get_option('libdir')) | ||
25 | libgnunetgnsrecord_dep = declare_dependency(link_with : libgnunetgnsrecord) | ||
26 | pkg.generate(libgnunetgnsrecord, url: 'https://www.gnunet.org', | ||
27 | description : 'Provides API for manipulating GNS records') | ||
28 | |||
29 | |||
30 | libgnunetgnsrecordjson = library('gnunetgnsrecordjson', | ||
31 | libgnunetgnsrecordjson_src, | ||
32 | soversion: '0', | ||
33 | version: '0.0.0', | ||
34 | dependencies: [libgnunetutil_dep, libgnunetgnsrecord_dep, json_dep], | ||
35 | include_directories: [incdir, configuration_inc], | ||
36 | install: true, | ||
37 | install_dir: get_option('libdir')) | ||
38 | libgnunetgnsrecordjson_dep = declare_dependency(link_with : libgnunetgnsrecordjson) | ||
39 | |||
40 | shared_module('gnunet_plugin_gnsrecord_dns', | ||
41 | ['plugin_gnsrecord_dns.c'], | ||
42 | dependencies: [libgnunetutil_dep, libgnunetgnsrecord_dep], | ||
43 | include_directories: [incdir, configuration_inc], | ||
44 | install: true, | ||
45 | install_dir: get_option('libdir')/'gnunet') | ||
diff --git a/src/gnsrecord/test_gnsrecord_testvectors.c b/src/gnsrecord/test_gnsrecord_testvectors.c index bb4922417..e0d959f0e 100644 --- a/src/gnsrecord/test_gnsrecord_testvectors.c +++ b/src/gnsrecord/test_gnsrecord_testvectors.c | |||
@@ -1,106 +1,601 @@ | |||
1 | #include "platform.h" | 1 | #include "platform.h" |
2 | #include "gnunet_util_lib.h" | 2 | #include "gnunet_util_lib.h" |
3 | #include "gnunet_signatures.h" | ||
4 | #include "gnunet_gns_service.h" | 3 | #include "gnunet_gns_service.h" |
5 | #include "gnunet_gnsrecord_lib.h" | 4 | #include "gnunet_gnsrecord_lib.h" |
6 | #include "gnunet_dnsparser_lib.h" | ||
7 | #include "gnunet_testing_lib.h" | ||
8 | #include <inttypes.h> | 5 | #include <inttypes.h> |
6 | #include "gnsrecord_crypto.h" | ||
9 | 7 | ||
8 | int res; | ||
10 | 9 | ||
10 | struct GnsTv | ||
11 | { | ||
12 | uint32_t expected_rd_count; | ||
13 | struct GNUNET_GNSRECORD_Data expected_rd[2048]; | ||
14 | char *d; | ||
15 | char *zid; | ||
16 | char *ztld; | ||
17 | char *label; | ||
18 | char *q; | ||
19 | char *rdata; | ||
20 | char *rrblock; | ||
21 | char *k; | ||
22 | char *nonce; | ||
23 | }; | ||
11 | 24 | ||
12 | static char *d = | 25 | struct RevocationTv |
13 | "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"; | 26 | { |
27 | char *d; | ||
28 | char *zid; | ||
29 | char *ztld; | ||
30 | char *m; | ||
31 | char *proof; | ||
32 | int diff; | ||
33 | int epochs; | ||
34 | }; | ||
14 | 35 | ||
36 | struct RevocationTv rtvs[] = { | ||
37 | { | ||
38 | .d = | ||
39 | "70 ed 98 b9 07 8c 47 f7" | ||
40 | "d5 78 3b 26 cc f9 8b 7d" | ||
41 | "d5 5f 60 88 d1 53 95 97" | ||
42 | "fa 8b f5 5a c0 32 ea 6f", | ||
43 | .zid = | ||
44 | "00 01 00 00 2c a2 23 e8" | ||
45 | "79 ec c4 bb de b5 da 17" | ||
46 | "31 92 81 d6 3b 2e 3b 69" | ||
47 | "55 f1 c3 77 5c 80 4a 98" | ||
48 | "d5 f8 dd aa", | ||
49 | .ztld = | ||
50 | "000G001CM8HYGYFCRJXXXDET2WRS50EP7CQ3PTANY71QEQ409ACDBY6XN8", | ||
51 | .m = | ||
52 | "00 00 00 34 00 00 00 03" | ||
53 | "00 05 fe b4 6d 86 5c 1c" | ||
54 | "00 01 00 00 2c a2 23 e8" | ||
55 | "79 ec c4 bb de b5 da 17" | ||
56 | "31 92 81 d6 3b 2e 3b 69" | ||
57 | "55 f1 c3 77 5c 80 4a 98" | ||
58 | "d5 f8 dd aa", | ||
59 | .proof = | ||
60 | "00 05 fe b4 6d 86 5c 1c" | ||
61 | "00 00 39 5d 18 27 c0 00" | ||
62 | "e6 6a 57 0b cc d4 b3 93" | ||
63 | "e6 6a 57 0b cc d4 b3 ea" | ||
64 | "e6 6a 57 0b cc d4 b5 36" | ||
65 | "e6 6a 57 0b cc d4 b5 42" | ||
66 | "e6 6a 57 0b cc d4 b6 13" | ||
67 | "e6 6a 57 0b cc d4 b6 5f" | ||
68 | "e6 6a 57 0b cc d4 b6 72" | ||
69 | "e6 6a 57 0b cc d4 b7 0a" | ||
70 | "e6 6a 57 0b cc d4 b7 1a" | ||
71 | "e6 6a 57 0b cc d4 b7 23" | ||
72 | "e6 6a 57 0b cc d4 b7 47" | ||
73 | "e6 6a 57 0b cc d4 b7 77" | ||
74 | "e6 6a 57 0b cc d4 b7 85" | ||
75 | "e6 6a 57 0b cc d4 b7 89" | ||
76 | "e6 6a 57 0b cc d4 b7 cf" | ||
77 | "e6 6a 57 0b cc d4 b7 dc" | ||
78 | "e6 6a 57 0b cc d4 b9 3a" | ||
79 | "e6 6a 57 0b cc d4 b9 56" | ||
80 | "e6 6a 57 0b cc d4 ba 4a" | ||
81 | "e6 6a 57 0b cc d4 ba 9d" | ||
82 | "e6 6a 57 0b cc d4 bb 28" | ||
83 | "e6 6a 57 0b cc d4 bb 5a" | ||
84 | "e6 6a 57 0b cc d4 bb 92" | ||
85 | "e6 6a 57 0b cc d4 bb a2" | ||
86 | "e6 6a 57 0b cc d4 bb d8" | ||
87 | "e6 6a 57 0b cc d4 bb e2" | ||
88 | "e6 6a 57 0b cc d4 bc 93" | ||
89 | "e6 6a 57 0b cc d4 bc 94" | ||
90 | "e6 6a 57 0b cc d4 bd 0f" | ||
91 | "e6 6a 57 0b cc d4 bd ce" | ||
92 | "e6 6a 57 0b cc d4 be 6a" | ||
93 | "e6 6a 57 0b cc d4 be 73" | ||
94 | "00 01 00 00 2c a2 23 e8" | ||
95 | "79 ec c4 bb de b5 da 17" | ||
96 | "31 92 81 d6 3b 2e 3b 69" | ||
97 | "55 f1 c3 77 5c 80 4a 98" | ||
98 | "d5 f8 dd aa 04 4a 87 8a" | ||
99 | "15 8b 40 f0 c8 41 d9 f9" | ||
100 | "78 cb 13 72 ea ee 51 99" | ||
101 | "a3 d8 7e 5e 2b db c7 2a" | ||
102 | "6c 8c 73 d0 00 18 1d fc" | ||
103 | "39 c3 aa a4 81 66 7b 16" | ||
104 | "5b 58 44 e4 50 71 3d 8a" | ||
105 | "b6 a3 b2 ba 8f ef 44 7b" | ||
106 | "65 07 6a 0f", | ||
107 | .diff = 5, | ||
108 | .epochs = 2 | ||
109 | } | ||
110 | }; | ||
15 | 111 | ||
16 | static char *zid = | 112 | struct GnsTv tvs[] = { |
17 | "00010000677c477d2d93097c85b195c6f96d84ff61f5982c2c4fe02d5a11fedfb0c2901f"; | 113 | { .d = |
114 | "50 d7 b6 52 a4 ef ea df" | ||
115 | "f3 73 96 90 97 85 e5 95" | ||
116 | "21 71 a0 21 78 c8 e7 d4" | ||
117 | "50 fa 90 79 25 fa fd 98", | ||
118 | .zid = | ||
119 | "00 01 00 00 67 7c 47 7d" | ||
120 | "2d 93 09 7c 85 b1 95 c6" | ||
121 | "f9 6d 84 ff 61 f5 98 2c" | ||
122 | "2c 4f e0 2d 5a 11 fe df" | ||
123 | "b0 c2 90 1f", | ||
124 | .ztld = "000G0037FH3QTBCK15Y8BCCNRVWPV17ZC7TSGB1C9ZG2TPGHZVFV1GMG3W", | ||
125 | .label = "74 65 73 74 64 65 6c 65" | ||
126 | "67 61 74 69 6f 6e", | ||
127 | .q = | ||
128 | "4a dc 67 c5 ec ee 9f 76" | ||
129 | "98 6a bd 71 c2 22 4a 3d" | ||
130 | "ce 2e 91 70 26 c9 a0 9d" | ||
131 | "fd 44 ce f3 d2 0f 55 a2" | ||
132 | "73 32 72 5a 6c 8a fb bb" | ||
133 | "b0 f7 ec 9a f1 cc 42 64" | ||
134 | "12 99 40 6b 04 fd 9b 5b" | ||
135 | "57 91 f8 6c 4b 08 d5 f4", | ||
136 | .nonce = | ||
137 | "e9 0a 00 61 00 1c ee 8c" | ||
138 | "10 e2 59 80 00 00 00 01", | ||
139 | .k = | ||
140 | "86 4e 71 38 ea e7 fd 91" | ||
141 | "a3 01 36 89 9c 13 2b 23" | ||
142 | "ac eb db 2c ef 43 cb 19" | ||
143 | "f6 bf 55 b6 7d b9 b3 b3", | ||
144 | .rdata = | ||
145 | "00 1c ee 8c 10 e2 59 80" | ||
146 | "00 20 00 01 00 01 00 00" | ||
147 | "21 e3 b3 0f f9 3b c6 d3" | ||
148 | "5a c8 c6 e0 e1 3a fd ff" | ||
149 | "79 4c b7 b4 4b bb c7 48" | ||
150 | "d2 59 d0 a0 28 4d be 84", | ||
151 | .rrblock = | ||
152 | "00 00 00 a0 00 01 00 00" | ||
153 | "18 2b b6 36 ed a7 9f 79" | ||
154 | "57 11 bc 27 08 ad bb 24" | ||
155 | "2a 60 44 6a d3 c3 08 03" | ||
156 | "12 1d 03 d3 48 b7 ce b6" | ||
157 | "0a d1 0b c1 3b 40 3b 5b" | ||
158 | "25 61 26 b2 14 5a 6f 60" | ||
159 | "c5 14 f9 51 ff a7 66 f7" | ||
160 | "a3 fd 4b ac 4a 4e 19 90" | ||
161 | "05 5c b8 7e 8d 1b fd 19" | ||
162 | "aa 09 a4 29 f7 29 e9 f5" | ||
163 | "c6 ee c2 47 0a ce e2 22" | ||
164 | "07 59 e9 e3 6c 88 6f 35" | ||
165 | "00 1c ee 8c 10 e2 59 80" | ||
166 | "0c 1e da 5c c0 94 a1 c7" | ||
167 | "a8 88 64 9d 25 fa ee bd" | ||
168 | "60 da e6 07 3d 57 d8 ae" | ||
169 | "8d 45 5f 4f 13 92 c0 74" | ||
170 | "e2 6a c6 69 bd ee c2 34" | ||
171 | "62 b9 62 95 2c c6 e9 eb"}, | ||
172 | { .d = | ||
173 | "50 d7 b6 52 a4 ef ea df" | ||
174 | "f3 73 96 90 97 85 e5 95" | ||
175 | "21 71 a0 21 78 c8 e7 d4" | ||
176 | "50 fa 90 79 25 fa fd 98", | ||
177 | .zid = | ||
178 | "00 01 00 00 67 7c 47 7d" | ||
179 | "2d 93 09 7c 85 b1 95 c6" | ||
180 | "f9 6d 84 ff 61 f5 98 2c" | ||
181 | "2c 4f e0 2d 5a 11 fe df" | ||
182 | "b0 c2 90 1f", | ||
183 | .ztld = "000G0037FH3QTBCK15Y8BCCNRVWPV17ZC7TSGB1C9ZG2TPGHZVFV1GMG3W", | ||
184 | .label = | ||
185 | "e5 a4 a9 e4 b8 8b e7 84" | ||
186 | "a1 e6 95 b5", | ||
187 | .nonce = | ||
188 | "ee 96 33 c1 00 1c ee 8c" | ||
189 | "10 e2 59 80 00 00 00 01", | ||
190 | .k = | ||
191 | "fb 3a b5 de 23 bd da e1" | ||
192 | "99 7a af 7b 92 c2 d2 71" | ||
193 | "51 40 8b 77 af 7a 41 ac" | ||
194 | "79 05 7c 4d f5 38 3d 01", | ||
195 | .q = | ||
196 | "af f0 ad 6a 44 09 73 68" | ||
197 | "42 9a c4 76 df a1 f3 4b" | ||
198 | "ee 4c 36 e7 47 6d 07 aa" | ||
199 | "64 63 ff 20 91 5b 10 05" | ||
200 | "c0 99 1d ef 91 fc 3e 10" | ||
201 | "90 9f 87 02 c0 be 40 43" | ||
202 | "67 78 c7 11 f2 ca 47 d5" | ||
203 | "5c f0 b5 4d 23 5d a9 77", | ||
204 | .rdata = | ||
205 | "00 1c ee 8c 10 e2 59 80" | ||
206 | "00 10 00 00 00 00 00 1c" | ||
207 | "00 00 00 00 00 00 00 00" | ||
208 | "00 00 00 00 de ad be ef" | ||
209 | "00 3f f2 aa 54 08 db 40" | ||
210 | "00 06 00 00 00 01 00 01" | ||
211 | "e6 84 9b e7 a7 b0 00 28" | ||
212 | "bb 13 ff 37 19 40 00 0b" | ||
213 | "00 04 00 00 00 10 48 65" | ||
214 | "6c 6c 6f 20 57 6f 72 6c" | ||
215 | "64 00 00 00 00 00 00 00" | ||
216 | "00 00 00 00 00 00 00 00" | ||
217 | "00 00 00 00 00 00 00 00" | ||
218 | "00 00 00 00 00 00 00 00" | ||
219 | "00 00 00 00 00 00 00 00" | ||
220 | "00 00 00 00 00 00 00 00", | ||
221 | .rrblock = | ||
222 | "00 00 00 f0 00 01 00 00" | ||
223 | "a5 12 96 df 75 7e e2 75" | ||
224 | "ca 11 8d 4f 07 fa 7a ae" | ||
225 | "55 08 bc f5 12 aa 41 12" | ||
226 | "14 29 d4 a0 de 9d 05 7e" | ||
227 | "08 5b d6 5f d4 85 10 51" | ||
228 | "ba ce 2a 45 2a fc 8a 7e" | ||
229 | "4f 6b 2c 1f 74 f0 20 35" | ||
230 | "d9 64 1a cd ba a4 66 e0" | ||
231 | "00 ce d6 f2 d2 3b 63 1c" | ||
232 | "8e 8a 0b 38 e2 ba e7 9a" | ||
233 | "22 ca d8 1d 4c 50 d2 25" | ||
234 | "35 8e bc 17 ac 0f 89 9e" | ||
235 | "00 1c ee 8c 10 e2 59 80" | ||
236 | "d8 c2 8d 2f d6 96 7d 1a" | ||
237 | "b7 22 53 f2 10 98 b8 14" | ||
238 | "a4 10 be 1f 59 98 de 03" | ||
239 | "f5 8f 7e 7c db 7f 08 a6" | ||
240 | "16 51 be 4d 0b 6f 8a 61" | ||
241 | "df 15 30 44 0b d7 47 dc" | ||
242 | "f0 d7 10 4f 6b 8d 24 c2" | ||
243 | "ac 9b c1 3d 9c 6f e8 29" | ||
244 | "05 25 d2 a6 d0 f8 84 42" | ||
245 | "67 a1 57 0e 8e 29 4d c9" | ||
246 | "3a 31 9f cf c0 3e a2 70" | ||
247 | "17 d6 fd a3 47 b4 a7 94" | ||
248 | "97 d7 f6 b1 42 2d 4e dd" | ||
249 | "82 1c 19 93 4e 96 c1 aa" | ||
250 | "87 76 57 25 d4 94 c7 64" | ||
251 | "b1 55 dc 6d 13 26 91 74"}, | ||
252 | { .d = | ||
253 | "5a f7 02 0e e1 91 60 32" | ||
254 | "88 32 35 2b bc 6a 68 a8" | ||
255 | "d7 1a 7c be 1b 92 99 69" | ||
256 | "a7 c6 6d 41 5a 0d 8f 65", | ||
257 | .zid = | ||
258 | "00 01 00 14 3c f4 b9 24" | ||
259 | "03 20 22 f0 dc 50 58 14" | ||
260 | "53 b8 5d 93 b0 47 b6 3d" | ||
261 | "44 6c 58 45 cb 48 44 5d" | ||
262 | "db 96 68 8f", | ||
263 | .ztld = "000G051WYJWJ80S04BRDRM2R2H9VGQCKP13VCFA4DHC4BJT88HEXQ5K8HW", | ||
264 | .label = | ||
265 | "74 65 73 74 64 65 6c 65" | ||
266 | "67 61 74 69 6f 6e", | ||
267 | .nonce = | ||
268 | "98 13 2e a8 68 59 d3 5c" | ||
269 | "88 bf d3 17 fa 99 1b cb" | ||
270 | "00 1c ee 8c 10 e2 59 80", | ||
271 | .k = | ||
272 | "85 c4 29 a9 56 7a a6 33" | ||
273 | "41 1a 96 91 e9 09 4c 45" | ||
274 | "28 16 72 be 58 60 34 aa" | ||
275 | "e4 a2 a2 cc 71 61 59 e2", | ||
276 | .q = | ||
277 | "ab aa ba c0 e1 24 94 59" | ||
278 | "75 98 83 95 aa c0 24 1e" | ||
279 | "55 59 c4 1c 40 74 e2 55" | ||
280 | "7b 9f e6 d1 54 b6 14 fb" | ||
281 | "cd d4 7f c7 f5 1d 78 6d" | ||
282 | "c2 e0 b1 ec e7 60 37 c0" | ||
283 | "a1 57 8c 38 4e c6 1d 44" | ||
284 | "56 36 a9 4e 88 03 29 e9", | ||
285 | .rdata = | ||
286 | "00 1c ee 8c 10 e2 59 80" | ||
287 | "00 20 00 01 00 01 00 00" | ||
288 | "21 e3 b3 0f f9 3b c6 d3" | ||
289 | "5a c8 c6 e0 e1 3a fd ff" | ||
290 | "79 4c b7 b4 4b bb c7 48" | ||
291 | "d2 59 d0 a0 28 4d be 84", | ||
292 | .rrblock = | ||
293 | "00 00 00 b0 00 01 00 14" | ||
294 | "9b f2 33 19 8c 6d 53 bb" | ||
295 | "db ac 49 5c ab d9 10 49" | ||
296 | "a6 84 af 3f 40 51 ba ca" | ||
297 | "b0 dc f2 1c 8c f2 7a 1a" | ||
298 | "9f 56 a8 86 ea 73 9d 59" | ||
299 | "17 50 8f 9b 75 56 39 f3" | ||
300 | "a9 ac fa ed ed ca 7f bf" | ||
301 | "a7 94 b1 92 e0 8b f9 ed" | ||
302 | "4c 7e c8 59 4c 9f 7b 4e" | ||
303 | "19 77 4f f8 38 ec 38 7a" | ||
304 | "8f 34 23 da ac 44 9f 59" | ||
305 | "db 4e 83 94 3f 90 72 00" | ||
306 | "00 1c ee 8c 10 e2 59 80" | ||
307 | "57 7c c6 c9 5a 14 e7 04" | ||
308 | "09 f2 0b 01 67 e6 36 d0" | ||
309 | "10 80 7c 4f 00 37 2d 69" | ||
310 | "8c 82 6b d9 2b c2 2b d6" | ||
311 | "bb 45 e5 27 7c 01 88 1d" | ||
312 | "6a 43 60 68 e4 dd f1 c6" | ||
313 | "b7 d1 41 6f af a6 69 7c" | ||
314 | "25 ed d9 ea e9 91 67 c3"}, | ||
315 | { .d = | ||
316 | "5a f7 02 0e e1 91 60 32" | ||
317 | "88 32 35 2b bc 6a 68 a8" | ||
318 | "d7 1a 7c be 1b 92 99 69" | ||
319 | "a7 c6 6d 41 5a 0d 8f 65", | ||
320 | .zid = | ||
321 | "00 01 00 14 3c f4 b9 24" | ||
322 | "03 20 22 f0 dc 50 58 14" | ||
323 | "53 b8 5d 93 b0 47 b6 3d" | ||
324 | "44 6c 58 45 cb 48 44 5d" | ||
325 | "db 96 68 8f", | ||
326 | .ztld = "000G051WYJWJ80S04BRDRM2R2H9VGQCKP13VCFA4DHC4BJT88HEXQ5K8HW", | ||
327 | .label = | ||
328 | "e5 a4 a9 e4 b8 8b e7 84" | ||
329 | "a1 e6 95 b5", | ||
330 | .nonce = | ||
331 | "bb 0d 3f 0f bd 22 42 77" | ||
332 | "50 da 5d 69 12 16 e6 c9" | ||
333 | "00 1c ee 8c 10 e2 59 80", | ||
334 | .k = | ||
335 | "3d f8 05 bd 66 87 aa 14" | ||
336 | "20 96 28 c2 44 b1 11 91" | ||
337 | "88 c3 92 56 37 a4 1e 5d" | ||
338 | "76 49 6c 29 45 dc 37 7b", | ||
339 | .q = | ||
340 | "ba f8 21 77 ee c0 81 e0" | ||
341 | "74 a7 da 47 ff c6 48 77" | ||
342 | "58 fb 0d f0 1a 6c 7f bb" | ||
343 | "52 fc 8a 31 be f0 29 af" | ||
344 | "74 aa 0d c1 5a b8 e2 fa" | ||
345 | "7a 54 b4 f5 f6 37 f6 15" | ||
346 | "8f a7 f0 3c 3f ce be 78" | ||
347 | "d3 f9 d6 40 aa c0 d1 ed", | ||
348 | .rdata = | ||
349 | "00 1c ee 8c 10 e2 59 80" | ||
350 | "00 10 00 00 00 00 00 1c" | ||
351 | "00 00 00 00 00 00 00 00" | ||
352 | "00 00 00 00 de ad be ef" | ||
353 | "00 3f f2 aa 54 08 db 40" | ||
354 | "00 06 00 00 00 01 00 01" | ||
355 | "e6 84 9b e7 a7 b0 00 28" | ||
356 | "bb 13 ff 37 19 40 00 0b" | ||
357 | "00 04 00 00 00 10 48 65" | ||
358 | "6c 6c 6f 20 57 6f 72 6c" | ||
359 | "64 00 00 00 00 00 00 00" | ||
360 | "00 00 00 00 00 00 00 00" | ||
361 | "00 00 00 00 00 00 00 00" | ||
362 | "00 00 00 00 00 00 00 00" | ||
363 | "00 00 00 00 00 00 00 00" | ||
364 | "00 00 00 00 00 00 00 00", | ||
365 | .rrblock = | ||
366 | "00 00 01 00 00 01 00 14" | ||
367 | "74 f9 00 68 f1 67 69 53" | ||
368 | "52 a8 a6 c2 eb 98 48 98" | ||
369 | "c5 3a cc a0 98 04 70 c6" | ||
370 | "c8 12 64 cb dd 78 ad 11" | ||
371 | "75 6d 2c 15 7a d2 ea 4f" | ||
372 | "c0 b1 b9 1c 08 03 79 44" | ||
373 | "61 d3 de f2 0d d1 63 6c" | ||
374 | "fe dc 03 89 c5 49 d1 43" | ||
375 | "6c c3 5b 4e 1b f8 89 5a" | ||
376 | "64 6b d9 a6 f4 6b 83 48" | ||
377 | "1d 9c 0e 91 d4 e1 be bb" | ||
378 | "6a 83 52 6f b7 25 2a 06" | ||
379 | "00 1c ee 8c 10 e2 59 80" | ||
380 | "4e b3 5a 50 d4 0f e1 a4" | ||
381 | "29 c7 f4 b2 67 a0 59 de" | ||
382 | "4e 2c 8a 89 a5 ed 53 d3" | ||
383 | "d4 92 58 59 d2 94 9f 7f" | ||
384 | "30 d8 a2 0c aa 96 f8 81" | ||
385 | "45 05 2d 1c da 04 12 49" | ||
386 | "8f f2 5f f2 81 6e f0 ce" | ||
387 | "61 fe 69 9b fa c7 2c 15" | ||
388 | "dc 83 0e a9 b0 36 17 1c" | ||
389 | "cf ca bb dd a8 de 3c 86" | ||
390 | "ed e2 95 70 d0 17 4b 82" | ||
391 | "82 09 48 a9 28 b7 f0 0e" | ||
392 | "fb 40 1c 10 fe 80 bb bb" | ||
393 | "02 76 33 1b f7 f5 1b 8d" | ||
394 | "74 57 9c 14 14 f2 2d 50" | ||
395 | "1a d2 5a e2 49 f5 bb f2" | ||
396 | "a6 c3 72 59 d1 75 e4 40" | ||
397 | "b2 94 39 c6 05 19 cb b1"}, | ||
398 | {.d = NULL} | ||
399 | }; | ||
18 | 400 | ||
19 | #define RRCOUNT 2 | 401 | static void |
20 | #define LABEL "namesystem" | 402 | print_bytes_ (void *buf, |
403 | size_t buf_len, | ||
404 | int fold, | ||
405 | int in_be) | ||
406 | { | ||
407 | int i; | ||
408 | |||
409 | for (i = 0; i < buf_len; i++) | ||
410 | { | ||
411 | if (0 != i) | ||
412 | { | ||
413 | if ((0 != fold) && (i % fold == 0)) | ||
414 | printf ("\n "); | ||
415 | else | ||
416 | printf (" "); | ||
417 | } | ||
418 | else | ||
419 | { | ||
420 | printf (" "); | ||
421 | } | ||
422 | if (in_be) | ||
423 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | ||
424 | else | ||
425 | printf ("%02x", ((unsigned char*) buf)[i]); | ||
426 | } | ||
427 | printf ("\n"); | ||
428 | } | ||
21 | 429 | ||
22 | #define R0_EXPIRATION | ||
23 | #define R0_DATA_SIZE 4 | ||
24 | #define R0_TYPE 1 | ||
25 | #define R0_FLAGS 0 | ||
26 | #define R0_DATA "01020304" | ||
27 | 430 | ||
28 | /* Record #1*/ | 431 | static void |
29 | #define R1_EXPIRATION 26147096139323793 | 432 | print_bytes (void *buf, |
30 | #define R1_DATA_SIZE 36 | 433 | size_t buf_len, |
31 | #define R1_TYPE 65536 | 434 | int fold) |
32 | #define R1_FLAGS 2 | 435 | { |
33 | #define R1_DATA \ | 436 | print_bytes_ (buf, buf_len, fold, 0); |
34 | "000100000e601be42eb57fb4697610cf3a3b18347b65a33f025b5b174abefb30807bfecf" | 437 | } |
35 | 438 | ||
36 | #define R1_RRBLOCK \ | ||
37 | "000100008e16da87203b5159c5538e9b765742e968c54af9afbc0890dc80205ad14c84e107b0c115fc0089aa38b9c7ab9cbe1d77040d282a51a2ad493f61f3495f02d8170fe473a55ec6bdf9a509ab1701ffc37ea3bb4cac4a672520986df96e67cc1a73000000940000000f0034e53be193799100e4837eb5d04f92903de4b5234e8ccac5736c9793379a59c33375fc8951aca2eb7aad067bf9af60bf26758646a17f5e5c3b6215f94079545b1c4d4f1b2ebb22c2b4dad44126817b6f001530d476401dd67ac0148554e806353da9e4298079f3e1b16942c48d90c4360c61238c40d9d52911aea52cc0037ac7160bb3cf5b2f4a722fd96b" | ||
38 | 439 | ||
39 | int parsehex (char *src, char *dst, size_t dstlen, int invert) | 440 | int |
441 | parsehex (char *src, char *dst, size_t dstlen, int invert) | ||
40 | { | 442 | { |
41 | char *line = src; | ||
42 | char *data = line; | ||
43 | int off; | 443 | int off; |
44 | int read_byte; | 444 | int read_byte; |
45 | int data_len = 0; | 445 | int data_len = 0; |
446 | char data[strlen (src) + 1]; | ||
447 | char *pos = data; | ||
448 | int i = 0; | ||
449 | int j = 0; | ||
450 | memset (data, 0, strlen (src) + 1); | ||
451 | |||
452 | for (i = 0; i < strlen (src); i++) | ||
453 | { | ||
454 | if ((src[i] == ' ') || (src[i] == '\n')) | ||
455 | continue; | ||
456 | data[j++] = src[i]; | ||
457 | } | ||
46 | 458 | ||
47 | while (sscanf (data, " %02x%n", &read_byte, &off) == 1) | 459 | while (sscanf (pos, " %02x%n", &read_byte, &off) == 1) |
48 | { | 460 | { |
49 | if (invert) | 461 | if (invert) |
50 | dst[dstlen - 1 - data_len++] = read_byte; | 462 | dst[dstlen - 1 - data_len++] = read_byte; |
51 | else | 463 | else |
52 | dst[data_len++] = read_byte; | 464 | dst[data_len++] = read_byte; |
53 | data += off; | 465 | pos += off; |
54 | } | 466 | } |
55 | return data_len; | 467 | return data_len; |
56 | } | 468 | } |
57 | 469 | ||
470 | |||
58 | void | 471 | void |
59 | res_checker (void *cls, | 472 | res_checker (void *cls, |
60 | unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) | 473 | unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
61 | { | 474 | { |
62 | int r0_found = 0; | 475 | struct GnsTv *tv = cls; |
63 | int r1_found = 0; | 476 | if (rd_count != tv->expected_rd_count) |
64 | char r0_data[R0_DATA_SIZE]; | 477 | { |
65 | char r1_data[R1_DATA_SIZE]; | 478 | printf ("FAIL: Record count expected: %u, was: %u\n", tv->expected_rd_count, |
66 | parsehex (R0_DATA, (char*) r0_data, 0, 0); | 479 | rd_count); |
67 | parsehex (R1_DATA, (char*) r1_data, 0, 0); | 480 | res = 1; |
68 | GNUNET_assert (rd_count == RRCOUNT); | 481 | return; |
69 | for (int i = 0; i < RRCOUNT; i++) | 482 | } |
483 | for (int i = 0; i < rd_count; i++) | ||
70 | { | 484 | { |
71 | if (rd[i].record_type == R0_TYPE) | 485 | if (rd[i].record_type != tv->expected_rd[i].record_type) |
486 | { | ||
487 | printf ("FAIL: Record type expected: %u, was: %u\n", | ||
488 | tv->expected_rd[i].record_type, | ||
489 | rd[i].record_type); | ||
490 | res = 1; | ||
491 | return; | ||
492 | } | ||
493 | if (rd[i].expiration_time != tv->expected_rd[i].expiration_time) | ||
494 | { | ||
495 | printf ("FAIL: Expiration expected: %" PRIu64 ", was: %" PRIu64 "\n", | ||
496 | tv->expected_rd[i].expiration_time, | ||
497 | rd[i].expiration_time); | ||
498 | res = 1; | ||
499 | return; | ||
500 | } | ||
501 | if (rd[i].flags != tv->expected_rd[i].flags) | ||
502 | { | ||
503 | printf ("FAIL: Record flags expected: %u, was: %u\n", | ||
504 | tv->expected_rd[i].flags, | ||
505 | rd[i].flags); | ||
506 | res = 1; | ||
507 | return; | ||
508 | } | ||
509 | if (rd[i].data_size != tv->expected_rd[i].data_size) | ||
72 | { | 510 | { |
73 | if (0 != memcmp (rd[i].data, r0_data, R0_DATA_SIZE)) | 511 | printf ("FAIL: Record data size expected: %lu, was: %lu\n", |
74 | { | 512 | tv->expected_rd[i].data_size, |
75 | printf ("R0 Data mismatch\n"); | 513 | rd[i].data_size); |
76 | continue; | 514 | res = 1; |
77 | } | 515 | return; |
78 | if (rd[i].expiration_time != R0_EXPIRATION) | ||
79 | { | ||
80 | printf ("R0 expiration mismatch\n"); | ||
81 | continue; | ||
82 | } | ||
83 | r0_found = 1; | ||
84 | } | 516 | } |
85 | if (rd[i].record_type == R1_TYPE) | 517 | if (0 != memcmp (rd[i].data, tv->expected_rd[i].data, |
518 | rd[i].data_size)) | ||
86 | { | 519 | { |
87 | if (0 != memcmp (rd[i].data, r1_data, R1_DATA_SIZE)) | 520 | printf ("FAIL: Record data does not match\n"); |
88 | { | 521 | res = 1; |
89 | printf ("R1 Data mismatch\n"); | 522 | return; |
90 | continue; | ||
91 | } | ||
92 | if (rd[i].expiration_time != R1_EXPIRATION) | ||
93 | { | ||
94 | printf ("R1 expiration mismatch\n"); | ||
95 | continue; | ||
96 | } | ||
97 | |||
98 | r1_found = 1; | ||
99 | } | 523 | } |
524 | } | ||
525 | } | ||
526 | |||
100 | 527 | ||
528 | enum GNUNET_GenericReturnValue | ||
529 | check_derivations_edkey (const char*label, | ||
530 | struct GNUNET_TIME_Absolute expire, | ||
531 | struct GNUNET_IDENTITY_PublicKey *pub, | ||
532 | struct GnsTv *tv) | ||
533 | { | ||
534 | unsigned char nonce[crypto_secretbox_NONCEBYTES]; | ||
535 | unsigned char skey[crypto_secretbox_KEYBYTES]; | ||
536 | unsigned char nonce_expected[crypto_secretbox_NONCEBYTES]; | ||
537 | unsigned char skey_expected[crypto_secretbox_KEYBYTES]; | ||
538 | |||
539 | |||
540 | parsehex (tv->nonce,(char*) nonce_expected, crypto_secretbox_NONCEBYTES, 0); | ||
541 | parsehex (tv->k,(char*) skey_expected, crypto_secretbox_KEYBYTES, 0); | ||
542 | GNR_derive_block_xsalsa_key (nonce, | ||
543 | skey, | ||
544 | label, | ||
545 | GNUNET_TIME_absolute_hton ( | ||
546 | expire).abs_value_us__, | ||
547 | &pub->eddsa_key); | ||
548 | /* Ignore random 128-bit nonce, can't check this here. Will be checked on | ||
549 | * decryption. */ | ||
550 | if (0 != memcmp (nonce + 16, nonce_expected + 16, sizeof (nonce) - 16)) | ||
551 | { | ||
552 | printf ("FAIL: Failed to derive nonce:\n"); | ||
553 | print_bytes (nonce, sizeof (nonce), 8); | ||
554 | print_bytes (nonce_expected, sizeof (nonce), 8); | ||
555 | return GNUNET_NO; | ||
101 | } | 556 | } |
102 | GNUNET_assert (r0_found); | 557 | if (0 != memcmp (skey, skey_expected, sizeof (skey))) |
103 | GNUNET_assert (r1_found); | 558 | { |
559 | printf ("FAIL: Failed to derive secret key\n"); | ||
560 | return GNUNET_NO; | ||
561 | } | ||
562 | return GNUNET_OK; | ||
563 | } | ||
564 | |||
565 | |||
566 | enum GNUNET_GenericReturnValue | ||
567 | check_derivations_pkey (const char*label, | ||
568 | struct GNUNET_TIME_Absolute expire, | ||
569 | struct GNUNET_IDENTITY_PublicKey *pub, | ||
570 | struct GnsTv *tv) | ||
571 | { | ||
572 | unsigned char ctr[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; | ||
573 | unsigned char ctr_expected[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; | ||
574 | unsigned char skey[GNUNET_CRYPTO_AES_KEY_LENGTH]; | ||
575 | unsigned char skey_expected[GNUNET_CRYPTO_AES_KEY_LENGTH]; | ||
576 | |||
577 | parsehex (tv->nonce,(char*) ctr_expected, sizeof (ctr), 0); | ||
578 | parsehex (tv->k,(char*) skey_expected, sizeof (skey), 0); | ||
579 | GNR_derive_block_aes_key (ctr, | ||
580 | skey, | ||
581 | label, | ||
582 | GNUNET_TIME_absolute_hton ( | ||
583 | expire).abs_value_us__, | ||
584 | &pub->ecdsa_key); | ||
585 | |||
586 | /* Ignore random 32-bit nonce, can't check this here. Will be checked on | ||
587 | * decryption. */ | ||
588 | if (0 != memcmp (ctr + 4, ctr_expected + 4, sizeof (ctr) - 4)) | ||
589 | { | ||
590 | printf ("FAIL: Failed to derive nonce\n"); | ||
591 | return GNUNET_NO; | ||
592 | } | ||
593 | if (0 != memcmp (skey, skey_expected, sizeof (skey))) | ||
594 | { | ||
595 | printf ("FAIL: Failed to derive secret key\n"); | ||
596 | return GNUNET_NO; | ||
597 | } | ||
598 | return GNUNET_OK; | ||
104 | } | 599 | } |
105 | 600 | ||
106 | 601 | ||
@@ -111,21 +606,106 @@ main () | |||
111 | struct GNUNET_IDENTITY_PublicKey pub; | 606 | struct GNUNET_IDENTITY_PublicKey pub; |
112 | struct GNUNET_IDENTITY_PublicKey pub_parsed; | 607 | struct GNUNET_IDENTITY_PublicKey pub_parsed; |
113 | struct GNUNET_GNSRECORD_Block *rrblock; | 608 | struct GNUNET_GNSRECORD_Block *rrblock; |
114 | char *bdata; | 609 | struct GNUNET_HashCode query; |
115 | 610 | struct GNUNET_HashCode expected_query; | |
116 | parsehex (d,(char*) &priv.ecdsa_key, sizeof (priv.ecdsa_key), 1); | 611 | struct GNUNET_TIME_Absolute expire; |
117 | priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 612 | struct GNUNET_TIME_Relative exprel; |
118 | parsehex (zid,(char*) &pub_parsed, 0, 0); | 613 | struct GNUNET_REVOCATION_PowP *pow; |
119 | GNUNET_IDENTITY_key_get_public (&priv, &pub); | 614 | char label[128]; |
120 | GNUNET_assert (0 == memcmp (&pub, &pub_parsed, sizeof (pub))); | 615 | char rdata[8096]; |
121 | rrblock = GNUNET_malloc (strlen (R1_RRBLOCK) / 2); | 616 | char ztld[128]; |
122 | parsehex (R1_RRBLOCK, (char*) rrblock, 0, 0); | 617 | res = 0; |
123 | GNUNET_assert (GNUNET_YES | 618 | |
124 | == GNUNET_GNSRECORD_is_critical (GNUNET_GNSRECORD_TYPE_PKEY)); | 619 | for (int i = 0; NULL != tvs[i].d; i++) |
125 | GNUNET_GNSRECORD_block_decrypt (rrblock, | 620 | { |
126 | &pub_parsed, | 621 | printf ("Test vector #%d\n", i); |
127 | LABEL, | 622 | memset (label, 0, sizeof (label)); |
128 | &res_checker, | 623 | parsehex (tvs[i].zid,(char*) &pub_parsed, 36, 0); |
129 | NULL); | 624 | parsehex (tvs[i].d,(char*) &priv.ecdsa_key, sizeof (priv.ecdsa_key), |
130 | return 0; | 625 | (GNUNET_GNSRECORD_TYPE_PKEY == ntohl (pub_parsed.type)) ? 1 : 0); |
626 | priv.type = pub_parsed.type; | ||
627 | GNUNET_IDENTITY_key_get_public (&priv, &pub); | ||
628 | if (0 != memcmp (&pub, &pub_parsed, GNUNET_IDENTITY_public_key_get_length ( | ||
629 | &pub))) | ||
630 | { | ||
631 | printf ("Wrong pubkey.\n"); | ||
632 | print_bytes (&pub, 36, 8); | ||
633 | print_bytes (&pub_parsed, 36, 8); | ||
634 | res = 1; | ||
635 | break; | ||
636 | } | ||
637 | GNUNET_STRINGS_data_to_string (&pub, | ||
638 | GNUNET_IDENTITY_public_key_get_length ( | ||
639 | &pub), | ||
640 | ztld, | ||
641 | sizeof (ztld)); | ||
642 | if (0 != strcmp (ztld, tvs[i].ztld)) | ||
643 | { | ||
644 | printf ("Wrong zTLD: expected %s, got %s\n", tvs[i].ztld, ztld); | ||
645 | res = 1; | ||
646 | break; | ||
647 | } | ||
648 | rrblock = GNUNET_malloc (strlen (tvs[i].rrblock)); | ||
649 | parsehex (tvs[i].rrblock, (char*) rrblock, 0, 0); | ||
650 | parsehex (tvs[i].label, (char*) label, 0, 0); | ||
651 | parsehex (tvs[i].q, (char*) &query, 0, 0); | ||
652 | GNUNET_GNSRECORD_query_from_public_key (&pub_parsed, | ||
653 | label, | ||
654 | &expected_query); | ||
655 | if (0 != GNUNET_memcmp (&query, &expected_query)) | ||
656 | { | ||
657 | printf ("FAIL: query does not match:"); | ||
658 | printf (" expected: %s", GNUNET_h2s (&expected_query)); | ||
659 | printf (", was: %s\n", GNUNET_h2s (&query)); | ||
660 | res = 1; | ||
661 | break; | ||
662 | } | ||
663 | int len = parsehex (tvs[i].rdata, (char*) rdata, 0, 0); | ||
664 | tvs[i].expected_rd_count = | ||
665 | GNUNET_GNSRECORD_records_deserialize_get_size (len, | ||
666 | rdata); | ||
667 | GNUNET_assert (tvs[i].expected_rd_count < 2048); | ||
668 | if (GNUNET_OK != | ||
669 | GNUNET_GNSRECORD_records_deserialize (len, | ||
670 | rdata, | ||
671 | tvs[i].expected_rd_count, | ||
672 | tvs[i].expected_rd)) | ||
673 | { | ||
674 | printf ("FAIL: Deserialization of RDATA failed\n"); | ||
675 | res = 1; | ||
676 | break; | ||
677 | } | ||
678 | expire = GNUNET_GNSRECORD_record_get_expiration_time ( | ||
679 | tvs[i].expected_rd_count, | ||
680 | tvs[i].expected_rd, | ||
681 | GNUNET_TIME_UNIT_ZERO_ABS); | ||
682 | if ((GNUNET_GNSRECORD_TYPE_PKEY == ntohl (pub.type)) && | ||
683 | (GNUNET_OK != check_derivations_pkey (label, expire, &pub, &tvs[i]))) | ||
684 | { | ||
685 | res = 1; | ||
686 | break; | ||
687 | } | ||
688 | else if ((GNUNET_GNSRECORD_TYPE_EDKEY == ntohl (pub.type)) && | ||
689 | (GNUNET_OK != check_derivations_edkey (label, expire, &pub, | ||
690 | &tvs[i]))) | ||
691 | { | ||
692 | res = 1; | ||
693 | break; | ||
694 | } | ||
695 | if (GNUNET_OK != GNUNET_GNSRECORD_block_decrypt (rrblock, | ||
696 | &pub_parsed, | ||
697 | label, | ||
698 | &res_checker, | ||
699 | &tvs[i])) | ||
700 | { | ||
701 | printf ("FAIL: Decryption of RRBLOCK failed\n"); | ||
702 | res = 1; | ||
703 | break; | ||
704 | } | ||
705 | if (0 != res) | ||
706 | break; | ||
707 | printf ("Good.\n"); | ||
708 | } | ||
709 | finish: | ||
710 | return res; | ||
131 | } | 711 | } |
diff --git a/src/hello/meson.build b/src/hello/meson.build new file mode 100644 index 000000000..04d5a6bef --- /dev/null +++ b/src/hello/meson.build | |||
@@ -0,0 +1,35 @@ | |||
1 | libgnunethello_src = ['hello.c', | ||
2 | 'address.c', | ||
3 | 'hello-ng.c', | ||
4 | 'hello-uri.c'] | ||
5 | |||
6 | gnunethello_src = ['gnunet-hello.c'] | ||
7 | |||
8 | |||
9 | if get_option('monolith') | ||
10 | foreach p : libgnunethello_src | ||
11 | gnunet_src += 'hello/' + p | ||
12 | endforeach | ||
13 | subdir_done() | ||
14 | endif | ||
15 | |||
16 | libgnunethello = library('gnunethello', | ||
17 | libgnunethello_src, | ||
18 | soversion: '0', | ||
19 | version: '0.1.0', | ||
20 | dependencies: libgnunetutil_dep, | ||
21 | include_directories: [incdir, configuration_inc], | ||
22 | install: true, | ||
23 | install_dir: get_option('libdir')) | ||
24 | libgnunethello_dep = declare_dependency(link_with : libgnunethello) | ||
25 | pkg.generate(libgnunethello, url: 'https://www.gnunet.org', | ||
26 | description : 'Helper library for handling GNUnet HELLO messages') | ||
27 | |||
28 | |||
29 | executable ('gnunet-hello', | ||
30 | gnunethello_src, | ||
31 | dependencies: [libgnunethello_dep, libgnunetutil_dep], | ||
32 | include_directories: [incdir, configuration_inc], | ||
33 | install: true, | ||
34 | install_dir: get_option('bindir')) | ||
35 | |||
diff --git a/src/hostlist/meson.build b/src/hostlist/meson.build new file mode 100644 index 000000000..811e3e669 --- /dev/null +++ b/src/hostlist/meson.build | |||
@@ -0,0 +1,27 @@ | |||
1 | gnunetdaemonhostlist_src = ['gnunet-daemon-hostlist.c', | ||
2 | 'gnunet-daemon-hostlist_server.c', | ||
3 | 'gnunet-daemon-hostlist_client.c'] | ||
4 | |||
5 | configure_file(input : 'hostlist.conf', | ||
6 | output : 'hostlist.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | subdir_done() | ||
14 | endif | ||
15 | executable ('gnunet-daemon-hostlist', | ||
16 | gnunetdaemonhostlist_src, | ||
17 | dependencies: [libgnunetutil_dep, | ||
18 | libgnunetcore_dep, | ||
19 | libgnunethello_dep, | ||
20 | libgnunetpeerinfo_dep, | ||
21 | libgnunetstatistics_dep, | ||
22 | libgnunettransport_dep, | ||
23 | mhd_dep, | ||
24 | curl_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install:true, | ||
27 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am index b9e9b0205..fecfaea47 100644 --- a/src/identity/Makefile.am +++ b/src/identity/Makefile.am | |||
@@ -43,6 +43,7 @@ libgnunetidentity_la_LIBADD = \ | |||
43 | $(GN_LIBINTL) $(XLIB) | 43 | $(GN_LIBINTL) $(XLIB) |
44 | libgnunetidentity_la_LDFLAGS = \ | 44 | libgnunetidentity_la_LDFLAGS = \ |
45 | $(GN_LIB_LDFLAGS) \ | 45 | $(GN_LIB_LDFLAGS) \ |
46 | -lsodium \ | ||
46 | -version-info 1:0:0 | 47 | -version-info 1:0:0 |
47 | 48 | ||
48 | bin_PROGRAMS = \ | 49 | bin_PROGRAMS = \ |
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index 06e6fb613..7adc86eb8 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c | |||
@@ -259,29 +259,23 @@ static void | |||
259 | write_encrypted_message (void) | 259 | write_encrypted_message (void) |
260 | { | 260 | { |
261 | struct GNUNET_IDENTITY_PublicKey recipient; | 261 | struct GNUNET_IDENTITY_PublicKey recipient; |
262 | size_t ct_len = strlen (write_msg) + 1 | ||
263 | + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES; | ||
264 | unsigned char ct[ct_len]; | ||
262 | if (GNUNET_IDENTITY_public_key_from_string (pubkey_msg, &recipient) != | 265 | if (GNUNET_IDENTITY_public_key_from_string (pubkey_msg, &recipient) != |
263 | GNUNET_SYSERR) | 266 | GNUNET_SYSERR) |
264 | { | 267 | { |
265 | struct GNUNET_CRYPTO_EcdhePublicKey message_key; | ||
266 | size_t msg_len = strlen (write_msg) + 1; | 268 | size_t msg_len = strlen (write_msg) + 1; |
267 | ssize_t res = GNUNET_IDENTITY_encrypt (write_msg, | 269 | if (GNUNET_OK == GNUNET_IDENTITY_encrypt (write_msg, |
268 | msg_len, | 270 | msg_len, |
269 | &recipient, | 271 | &recipient, |
270 | &message_key, | 272 | ct, ct_len)) |
271 | write_msg); | ||
272 | if (-1 != res) | ||
273 | { | 273 | { |
274 | char *keystr; | ||
275 | char *serialized_msg; | 274 | char *serialized_msg; |
276 | keystr = GNUNET_STRINGS_data_to_string_alloc (&message_key, | 275 | serialized_msg = GNUNET_STRINGS_data_to_string_alloc (ct, ct_len); |
277 | sizeof(struct | ||
278 | GNUNET_CRYPTO_EcdhePublicKey)); | ||
279 | serialized_msg = GNUNET_STRINGS_data_to_string_alloc (write_msg, | ||
280 | msg_len); | ||
281 | fprintf (stdout, | 276 | fprintf (stdout, |
282 | "%s.%s\n", | 277 | "%s\n", |
283 | keystr, serialized_msg); | 278 | serialized_msg); |
284 | GNUNET_free (keystr); | ||
285 | GNUNET_free (serialized_msg); | 279 | GNUNET_free (serialized_msg); |
286 | } | 280 | } |
287 | else | 281 | else |
@@ -307,75 +301,35 @@ write_encrypted_message (void) | |||
307 | static void | 301 | static void |
308 | read_encrypted_message (struct GNUNET_IDENTITY_Ego *ego) | 302 | read_encrypted_message (struct GNUNET_IDENTITY_Ego *ego) |
309 | { | 303 | { |
310 | // message contains ECDHE key and ciphertext divided by ".", so split up first | 304 | char *deserialized_msg; |
311 | char delim[2] = "."; | 305 | size_t msg_len; |
312 | char *key_msg = strtok (read_msg, delim); | 306 | if (GNUNET_OK == GNUNET_STRINGS_string_to_data_alloc (read_msg, strlen ( |
313 | char *cipher; | 307 | read_msg), |
314 | if (NULL == key_msg) | 308 | (void **) & |
309 | deserialized_msg, | ||
310 | &msg_len)) | ||
315 | { | 311 | { |
316 | fprintf (stderr, "Invalid message format.\n"); | 312 | if (GNUNET_OK == GNUNET_IDENTITY_decrypt (deserialized_msg, |
317 | global_ret = 1; | 313 | msg_len, |
318 | return; | 314 | GNUNET_IDENTITY_ego_get_private_key ( |
319 | } | 315 | ego), |
320 | cipher = strtok (NULL, delim); | 316 | deserialized_msg, msg_len)) |
321 | if (NULL == cipher) | ||
322 | { | ||
323 | fprintf (stderr, "Invalid message format, text missing.\n"); | ||
324 | global_ret = 1; | ||
325 | return; | ||
326 | } | ||
327 | |||
328 | if (NULL != strtok (NULL, delim)) | ||
329 | { | ||
330 | fprintf (stderr, | ||
331 | "Invalid message format, expecting only key and cipher components.\n"); | ||
332 | global_ret = 1; | ||
333 | return; | ||
334 | } | ||
335 | |||
336 | struct GNUNET_CRYPTO_EcdhePublicKey message_key; | ||
337 | if (GNUNET_OK == GNUNET_STRINGS_string_to_data (key_msg, strlen ( | ||
338 | key_msg), | ||
339 | &message_key, | ||
340 | sizeof(message_key))) | ||
341 | { | ||
342 | char *deserialized_msg; | ||
343 | size_t msg_len; | ||
344 | if (GNUNET_OK == GNUNET_STRINGS_string_to_data_alloc (cipher, strlen ( | ||
345 | cipher), | ||
346 | (void **) & | ||
347 | deserialized_msg, | ||
348 | &msg_len)) | ||
349 | { | 317 | { |
350 | ssize_t res = GNUNET_IDENTITY_decrypt (deserialized_msg, | 318 | deserialized_msg[msg_len - 1] = '\0'; |
351 | msg_len, | 319 | fprintf (stdout, |
352 | GNUNET_IDENTITY_ego_get_private_key ( | 320 | "%s\n", |
353 | ego), | 321 | deserialized_msg); |
354 | &message_key, | ||
355 | deserialized_msg); | ||
356 | if (-1 != res) | ||
357 | { | ||
358 | deserialized_msg[res - 1] = '\0'; | ||
359 | fprintf (stdout, | ||
360 | "%s\n", | ||
361 | deserialized_msg); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | fprintf (stderr, "Failed to decrypt message.\n"); | ||
366 | global_ret = 1; | ||
367 | } | ||
368 | GNUNET_free (deserialized_msg); | ||
369 | } | 322 | } |
370 | else | 323 | else |
371 | { | 324 | { |
372 | fprintf (stderr, "Invalid message format.\n"); | 325 | fprintf (stderr, "Failed to decrypt message.\n"); |
373 | global_ret = 1; | 326 | global_ret = 1; |
374 | } | 327 | } |
328 | GNUNET_free (deserialized_msg); | ||
375 | } | 329 | } |
376 | else | 330 | else |
377 | { | 331 | { |
378 | fprintf (stderr, "Invalid message ephemeral key.\n"); | 332 | fprintf (stderr, "Invalid message format.\n"); |
379 | global_ret = 1; | 333 | global_ret = 1; |
380 | } | 334 | } |
381 | } | 335 | } |
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 47a78e2bb..3a9258aa4 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -1136,11 +1136,11 @@ GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | |||
1136 | 1136 | ||
1137 | 1137 | ||
1138 | ssize_t | 1138 | ssize_t |
1139 | GNUNET_IDENTITY_encrypt (const void *block, | 1139 | GNUNET_IDENTITY_encrypt_old (const void *block, |
1140 | size_t size, | 1140 | size_t size, |
1141 | const struct GNUNET_IDENTITY_PublicKey *pub, | 1141 | const struct GNUNET_IDENTITY_PublicKey *pub, |
1142 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | 1142 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, |
1143 | void *result) | 1143 | void *result) |
1144 | { | 1144 | { |
1145 | struct GNUNET_CRYPTO_EcdhePrivateKey pk; | 1145 | struct GNUNET_CRYPTO_EcdhePrivateKey pk; |
1146 | GNUNET_CRYPTO_ecdhe_key_create (&pk); | 1146 | GNUNET_CRYPTO_ecdhe_key_create (&pk); |
@@ -1174,12 +1174,109 @@ GNUNET_IDENTITY_encrypt (const void *block, | |||
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | 1176 | ||
1177 | ssize_t | 1177 | enum GNUNET_GenericReturnValue |
1178 | GNUNET_IDENTITY_decrypt (const void *block, | 1178 | GNUNET_IDENTITY_encrypt (const void *pt, |
1179 | size_t size, | 1179 | size_t pt_size, |
1180 | const struct GNUNET_IDENTITY_PublicKey *pub, | ||
1181 | void *ct_buf, | ||
1182 | size_t ct_size) | ||
1183 | { | ||
1184 | struct GNUNET_HashCode k; | ||
1185 | struct GNUNET_CRYPTO_FoKemC kemc; | ||
1186 | struct GNUNET_CRYPTO_FoKemC *kemc_buf = (struct GNUNET_CRYPTO_FoKemC*) ct_buf; | ||
1187 | unsigned char *encrypted_data = (unsigned char*) &kemc_buf[1]; | ||
1188 | unsigned char nonce[crypto_secretbox_NONCEBYTES]; | ||
1189 | unsigned char key[crypto_secretbox_KEYBYTES]; | ||
1190 | |||
1191 | if (ct_size < pt_size + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES) | ||
1192 | { | ||
1193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1194 | "Output buffer size for ciphertext too small: Got %lu, want >=%lu\n", | ||
1195 | ct_size, pt_size + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES); | ||
1196 | return GNUNET_SYSERR; | ||
1197 | } | ||
1198 | switch (ntohl (pub->type)) | ||
1199 | { | ||
1200 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
1201 | if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_fo_kem_encaps (&(pub->ecdsa_key), | ||
1202 | &kemc, | ||
1203 | &k)) | ||
1204 | return GNUNET_SYSERR; | ||
1205 | break; | ||
1206 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1207 | if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_fo_kem_encaps (&pub->eddsa_key, | ||
1208 | &kemc, | ||
1209 | &k)) | ||
1210 | return GNUNET_SYSERR; | ||
1211 | break; | ||
1212 | default: | ||
1213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unsupported key type\n"); | ||
1214 | return GNUNET_SYSERR; | ||
1215 | } | ||
1216 | memcpy (key, &k, crypto_secretbox_KEYBYTES); | ||
1217 | memcpy (nonce, ((char* ) &k) + crypto_secretbox_KEYBYTES, | ||
1218 | crypto_secretbox_NONCEBYTES); | ||
1219 | if (crypto_secretbox_easy (encrypted_data, pt, pt_size, nonce, key)) | ||
1220 | return GNUNET_SYSERR; | ||
1221 | memcpy (kemc_buf, &kemc, sizeof (kemc)); | ||
1222 | return GNUNET_OK; | ||
1223 | } | ||
1224 | |||
1225 | |||
1226 | enum GNUNET_GenericReturnValue | ||
1227 | GNUNET_IDENTITY_decrypt (const void *ct_buf, | ||
1228 | size_t ct_size, | ||
1180 | const struct GNUNET_IDENTITY_PrivateKey *priv, | 1229 | const struct GNUNET_IDENTITY_PrivateKey *priv, |
1181 | const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | 1230 | void *pt, |
1182 | void *result) | 1231 | size_t pt_size) |
1232 | { | ||
1233 | struct GNUNET_HashCode k; | ||
1234 | struct GNUNET_CRYPTO_FoKemC *kemc = (struct GNUNET_CRYPTO_FoKemC*) ct_buf; | ||
1235 | unsigned char *encrypted_data = (unsigned char*) &kemc[1]; | ||
1236 | unsigned char nonce[crypto_secretbox_NONCEBYTES]; | ||
1237 | unsigned char key[crypto_secretbox_KEYBYTES]; | ||
1238 | size_t expected_pt_len = ct_size - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES; | ||
1239 | |||
1240 | if (pt_size < expected_pt_len) | ||
1241 | { | ||
1242 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1243 | "Output buffer size for plaintext too small: Got %lu, want >=%lu\n", | ||
1244 | pt_size, expected_pt_len); | ||
1245 | return GNUNET_SYSERR; | ||
1246 | } | ||
1247 | switch (ntohl (priv->type)) | ||
1248 | { | ||
1249 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
1250 | if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_fo_kem_decaps (&(priv->ecdsa_key), | ||
1251 | kemc, | ||
1252 | &k)) | ||
1253 | return GNUNET_SYSERR; | ||
1254 | break; | ||
1255 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1256 | if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_fo_kem_decaps (&(priv->eddsa_key), | ||
1257 | kemc, | ||
1258 | &k)) | ||
1259 | return GNUNET_SYSERR; | ||
1260 | break; | ||
1261 | default: | ||
1262 | return GNUNET_SYSERR; | ||
1263 | } | ||
1264 | memcpy (key, &k, crypto_secretbox_KEYBYTES); | ||
1265 | memcpy (nonce, ((char* ) &k) + crypto_secretbox_KEYBYTES, | ||
1266 | crypto_secretbox_NONCEBYTES); | ||
1267 | if (crypto_secretbox_open_easy (pt, encrypted_data, ct_size - sizeof (*kemc), | ||
1268 | nonce, key)) | ||
1269 | return GNUNET_SYSERR; | ||
1270 | return GNUNET_OK; | ||
1271 | } | ||
1272 | |||
1273 | |||
1274 | ssize_t | ||
1275 | GNUNET_IDENTITY_decrypt_old (const void *block, | ||
1276 | size_t size, | ||
1277 | const struct GNUNET_IDENTITY_PrivateKey *priv, | ||
1278 | const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
1279 | void *result) | ||
1183 | { | 1280 | { |
1184 | struct GNUNET_HashCode hash; | 1281 | struct GNUNET_HashCode hash; |
1185 | switch (ntohl (priv->type)) | 1282 | switch (ntohl (priv->type)) |
diff --git a/src/identity/meson.build b/src/identity/meson.build new file mode 100644 index 000000000..7987bfcfc --- /dev/null +++ b/src/identity/meson.build | |||
@@ -0,0 +1,59 @@ | |||
1 | libgnunetidentity_src = ['identity_api.c', | ||
2 | 'identity_api_lookup.c', | ||
3 | 'identity_api_suffix_lookup.c'] | ||
4 | |||
5 | gnunetserviceidentity_src = ['gnunet-service-identity.c'] | ||
6 | |||
7 | configure_file(input : 'identity.conf.in', | ||
8 | output : 'identity.conf', | ||
9 | configuration : cdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetidentity_src + gnunetserviceidentity_src | ||
16 | gnunet_src += 'identity/' + p | ||
17 | endforeach | ||
18 | endif | ||
19 | |||
20 | libgnunetidentity = library('gnunetidentity', | ||
21 | libgnunetidentity_src, | ||
22 | soversion: '1', | ||
23 | version: '1.0.0', | ||
24 | dependencies: [libgnunetutil_dep, sodium_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunetidentity_dep = declare_dependency(link_with : libgnunetidentity) | ||
29 | pkg.generate(libgnunetidentity, url: 'https://www.gnunet.org', | ||
30 | description : 'API to access and organize private keys of the user egos') | ||
31 | shared_module('gnunet_plugin_rest_identity', | ||
32 | ['plugin_rest_identity.c'], | ||
33 | dependencies: [libgnunetrest_dep, | ||
34 | libgnunetidentity_dep, | ||
35 | libgnunetutil_dep, | ||
36 | json_dep, | ||
37 | mhd_dep], | ||
38 | include_directories: [incdir, configuration_inc], | ||
39 | install: true, | ||
40 | install_dir: get_option('libdir') / 'gnunet') | ||
41 | |||
42 | |||
43 | executable ('gnunet-identity', | ||
44 | ['gnunet-identity.c'], | ||
45 | dependencies: [libgnunetidentity_dep, | ||
46 | libgnunetutil_dep, | ||
47 | libgnunetstatistics_dep], | ||
48 | include_directories: [incdir, configuration_inc], | ||
49 | install: true, | ||
50 | install_dir: get_option('bindir')) | ||
51 | executable ('gnunet-service-identity', | ||
52 | gnunetserviceidentity_src, | ||
53 | dependencies: [libgnunetidentity_dep, | ||
54 | libgnunetutil_dep, | ||
55 | libgnunetstatistics_dep], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
59 | |||
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c index 2c44f73ba..92c074981 100644 --- a/src/identity/test_identity.c +++ b/src/identity/test_identity.c | |||
@@ -53,15 +53,15 @@ static struct GNUNET_IDENTITY_Operation *op; | |||
53 | static struct GNUNET_SCHEDULER_Task *endbadly_task; | 53 | static struct GNUNET_SCHEDULER_Task *endbadly_task; |
54 | 54 | ||
55 | #define CHECK(cond) \ | 55 | #define CHECK(cond) \ |
56 | do \ | 56 | do \ |
57 | { \ | 57 | { \ |
58 | if (! (cond)) \ | 58 | if (! (cond)) \ |
59 | { \ | 59 | { \ |
60 | GNUNET_break (0); \ | 60 | GNUNET_break (0); \ |
61 | end (); \ | 61 | end (); \ |
62 | return; \ | 62 | return; \ |
63 | } \ | 63 | } \ |
64 | } while (0) | 64 | } while (0) |
65 | 65 | ||
66 | 66 | ||
67 | /** | 67 | /** |
@@ -258,6 +258,22 @@ create_cb (void *cls, | |||
258 | { | 258 | { |
259 | CHECK (NULL != pk); | 259 | CHECK (NULL != pk); |
260 | CHECK (GNUNET_EC_NONE == ec); | 260 | CHECK (GNUNET_EC_NONE == ec); |
261 | struct GNUNET_IDENTITY_PublicKey pub; | ||
262 | size_t pt_len = strlen ("test") + 1; | ||
263 | unsigned char ct[pt_len + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES]; | ||
264 | char pt[pt_len]; | ||
265 | enum GNUNET_GenericReturnValue res; | ||
266 | |||
267 | GNUNET_IDENTITY_key_get_public (pk, &pub); | ||
268 | res = GNUNET_IDENTITY_encrypt ("test", pt_len, &pub, ct, | ||
269 | pt_len | ||
270 | + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES); | ||
271 | CHECK (GNUNET_OK == res); | ||
272 | res = GNUNET_IDENTITY_decrypt (ct, pt_len | ||
273 | + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES, | ||
274 | pk, pt, pt_len); | ||
275 | CHECK (GNUNET_OK == res); | ||
276 | CHECK (0 == strcmp (pt, "test")); | ||
261 | op = | 277 | op = |
262 | GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL); | 278 | GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL); |
263 | } | 279 | } |
diff --git a/src/identity/test_identity_messages.sh b/src/identity/test_identity_messages.sh index d29d14acc..edb4d5805 100755 --- a/src/identity/test_identity_messages.sh +++ b/src/identity/test_identity_messages.sh | |||
@@ -20,10 +20,21 @@ which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 30" | |||
20 | TEST_MSG="This is a test message. 123" | 20 | TEST_MSG="This is a test message. 123" |
21 | gnunet-arm -s -c test_identity.conf | 21 | gnunet-arm -s -c test_identity.conf |
22 | gnunet-identity -C recipientego -c test_identity.conf | 22 | gnunet-identity -C recipientego -c test_identity.conf |
23 | gnunet-identity -C recipientegoed -X -c test_identity.conf | ||
23 | RECIPIENT_KEY=`gnunet-identity -d -e recipientego -q -c test_identity.conf` | 24 | RECIPIENT_KEY=`gnunet-identity -d -e recipientego -q -c test_identity.conf` |
24 | MSG_ENC=`gnunet-identity -W "$TEST_MSG" -k $RECIPIENT_KEY -c test_identity.conf` | 25 | MSG_ENC=`gnunet-identity -W "$TEST_MSG" -k $RECIPIENT_KEY -c test_identity.conf` |
25 | MSG_DEC=`gnunet-identity -R "$MSG_ENC" -e recipientego -c test_identity.conf` | 26 | if [ $? == 0 ] |
27 | then | ||
28 | MSG_DEC=`gnunet-identity -R "$MSG_ENC" -e recipientego -c test_identity.conf` | ||
29 | fi | ||
30 | RECIPIENT_KEY_ED=`gnunet-identity -d -e recipientegoed -q -c test_identity.conf` | ||
31 | MSG_ENC_ED=`gnunet-identity -W "$TEST_MSG" -k $RECIPIENT_KEY_ED -c test_identity.conf` | ||
32 | if [ $? == 0 ] | ||
33 | then | ||
34 | MSG_DEC_ED=`gnunet-identity -R "$MSG_ENC_ED" -e recipientegoed -c test_identity.conf` | ||
35 | fi | ||
26 | gnunet-identity -D recipientego -c test_identity.conf | 36 | gnunet-identity -D recipientego -c test_identity.conf |
37 | gnunet-identity -D recipientegoed -c test_identity.conf | ||
27 | gnunet-arm -e -c test_identity.conf | 38 | gnunet-arm -e -c test_identity.conf |
28 | if [ "$TEST_MSG" != "$MSG_DEC" ] | 39 | if [ "$TEST_MSG" != "$MSG_DEC" ] |
29 | then | 40 | then |
@@ -31,5 +42,9 @@ then | |||
31 | echo "Failed - \"$TEST_MSG\" != \"$MSG_DEC\"" | 42 | echo "Failed - \"$TEST_MSG\" != \"$MSG_DEC\"" |
32 | exit 1 | 43 | exit 1 |
33 | fi | 44 | fi |
34 | 45 | if [ "$TEST_MSG" != "$MSG_DEC_ED" ] | |
35 | 46 | then | |
47 | diff <(echo "$TEST_MSG" ) <(echo "$MSG_DEC_ED") | ||
48 | echo "Failed - \"$TEST_MSG\" != \"$MSG_DEC_ED\"" | ||
49 | exit 1 | ||
50 | fi | ||
diff --git a/src/include/.gitignore b/src/include/.gitignore index 75c6af4b6..76ca45ab4 100644 --- a/src/include/.gitignore +++ b/src/include/.gitignore | |||
@@ -1,7 +1,3 @@ | |||
1 | gnunet_error_codes.h | ||
2 | gnu_name_system_record_flags.h | ||
3 | gnu_name_system_record_types.h | ||
4 | gnunet_dht_block_types.h | ||
5 | gnunet_signatures.h | ||
6 | !gnunet_config.h.in | 1 | !gnunet_config.h.in |
7 | gnunet_config.h | 2 | gnunet_config.h |
3 | gnunet_mysql_compat.h | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 70828b92d..f8092f966 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -75,9 +75,6 @@ gnunetinclude_HEADERS = \ | |||
75 | gnunet_microphone_lib.h \ | 75 | gnunet_microphone_lib.h \ |
76 | gnunet_mst_lib.h \ | 76 | gnunet_mst_lib.h \ |
77 | gnunet_mq_lib.h \ | 77 | gnunet_mq_lib.h \ |
78 | gnunet_my_lib.h \ | ||
79 | gnunet_mysql_compat.h \ | ||
80 | gnunet_mysql_lib.h \ | ||
81 | gnunet_namecache_plugin.h \ | 78 | gnunet_namecache_plugin.h \ |
82 | gnunet_namecache_service.h \ | 79 | gnunet_namecache_service.h \ |
83 | gnunet_namestore_plugin.h \ | 80 | gnunet_namestore_plugin.h \ |
diff --git a/src/include/gnu_name_system_record_types.h b/src/include/gnu_name_system_record_types.h new file mode 100644 index 000000000..2cefce589 --- /dev/null +++ b/src/include/gnu_name_system_record_types.h | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
21 | #define GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add GNS record types, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | |||
40 | /** | ||
41 | * GNS zone delegation (PKEY) | ||
42 | */ | ||
43 | #define GNUNET_GNSRECORD_TYPE_PKEY 65536 | ||
44 | |||
45 | |||
46 | /** | ||
47 | * GNS zone nickname | ||
48 | */ | ||
49 | #define GNUNET_GNSRECORD_TYPE_NICK 65537 | ||
50 | |||
51 | |||
52 | /** | ||
53 | * GNS legacy hostname | ||
54 | */ | ||
55 | #define GNUNET_GNSRECORD_TYPE_LEHO 65538 | ||
56 | |||
57 | |||
58 | /** | ||
59 | * VPN resolution | ||
60 | */ | ||
61 | #define GNUNET_GNSRECORD_TYPE_VPN 65539 | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Delegation to DNS | ||
66 | */ | ||
67 | #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540 | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Box record | ||
72 | */ | ||
73 | #define GNUNET_GNSRECORD_TYPE_BOX 65541 | ||
74 | |||
75 | |||
76 | /** | ||
77 | * social place for SecuShare | ||
78 | */ | ||
79 | #define GNUNET_GNSRECORD_TYPE_PLACE 65542 | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Endpoint for conversation | ||
84 | */ | ||
85 | #define GNUNET_GNSRECORD_TYPE_PHONE 65543 | ||
86 | |||
87 | |||
88 | /** | ||
89 | * identity attribute | ||
90 | */ | ||
91 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544 | ||
92 | |||
93 | |||
94 | /** | ||
95 | * local ticket reference | ||
96 | */ | ||
97 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545 | ||
98 | |||
99 | |||
100 | /** | ||
101 | * For ABD policies | ||
102 | */ | ||
103 | #define GNUNET_GNSRECORD_TYPE_DELEGATE 65548 | ||
104 | |||
105 | |||
106 | /** | ||
107 | * For ABD reverse lookups | ||
108 | */ | ||
109 | #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549 | ||
110 | |||
111 | |||
112 | /** | ||
113 | * for reclaim records | ||
114 | */ | ||
115 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550 | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Redirection record | ||
120 | */ | ||
121 | #define GNUNET_GNSRECORD_TYPE_REDIRECT 65551 | ||
122 | |||
123 | |||
124 | /** | ||
125 | * For reclaim OIDC client names. | ||
126 | */ | ||
127 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552 | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Used reclaimID OIDC client redirect URIs. | ||
132 | */ | ||
133 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Record type for an attribute attestation (e.g. JWT). | ||
138 | */ | ||
139 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554 | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Record type for a presentation of a credential. | ||
144 | */ | ||
145 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 | ||
146 | |||
147 | |||
148 | /** | ||
149 | * GNS zone delegation (EDKEY) | ||
150 | */ | ||
151 | #define GNUNET_GNSRECORD_TYPE_EDKEY 65556 | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Encoding for Robust Immutable Storage (ERIS) binary read capability | ||
156 | */ | ||
157 | #define GNUNET_GNSRECORD_TYPE_ERIS_READ_CAPABILITY 65557 | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Record type to share an entry of a messenger room | ||
162 | */ | ||
163 | #define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY 65558 | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Record type to indicate a previously delete record (PRIVATE only) | ||
168 | */ | ||
169 | #define GNUNET_GNSRECORD_TYPE_TOMBSTONE 65559 | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Record type to store details about a messenger room | ||
174 | */ | ||
175 | #define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS 65560 | ||
176 | |||
177 | |||
178 | /** | ||
179 | * Record type to store DID Documents | ||
180 | */ | ||
181 | #define GNUNET_GNSRECORD_TYPE_DID_DOCUMENT 65561 | ||
182 | |||
183 | |||
184 | |||
185 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
186 | { | ||
187 | #endif | ||
188 | #ifdef __cplusplus | ||
189 | } | ||
190 | #endif | ||
191 | |||
192 | #endif | ||
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h index 48a1a512d..73550db7e 100644 --- a/src/include/gnunet_bio_lib.h +++ b/src/include/gnunet_bio_lib.h | |||
@@ -33,6 +33,7 @@ | |||
33 | * @{ | 33 | * @{ |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "gnunet_common.h" | ||
36 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 37 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
37 | #error "Only <gnunet_util_lib.h> can be included directly." | 38 | #error "Only <gnunet_util_lib.h> can be included directly." |
38 | #endif | 39 | #endif |
@@ -88,7 +89,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size); | |||
88 | * @param emsg set to the error message | 89 | * @param emsg set to the error message |
89 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 90 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
90 | */ | 91 | */ |
91 | int | 92 | enum GNUNET_GenericReturnValue |
92 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); | 93 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); |
93 | 94 | ||
94 | /** | 95 | /** |
@@ -110,7 +111,7 @@ GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg); | |||
110 | * @param len the number of bytes to read | 111 | * @param len the number of bytes to read |
111 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 112 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
112 | */ | 113 | */ |
113 | int | 114 | enum GNUNET_GenericReturnValue |
114 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | 115 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, |
115 | const char *what, | 116 | const char *what, |
116 | void *result, | 117 | void *result, |
@@ -127,7 +128,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
127 | * @param max_length maximum allowed length for the string | 128 | * @param max_length maximum allowed length for the string |
128 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 129 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
129 | */ | 130 | */ |
130 | int | 131 | enum GNUNET_GenericReturnValue |
131 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | 132 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, |
132 | const char *what, | 133 | const char *what, |
133 | char **result, | 134 | char **result, |
@@ -142,7 +143,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | |||
142 | * @param what describes what is being read (for error message creation) | 143 | * @param what describes what is being read (for error message creation) |
143 | * @param f address of float to read | 144 | * @param f address of float to read |
144 | */ | 145 | */ |
145 | int | 146 | enum GNUNET_GenericReturnValue |
146 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | 147 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, |
147 | const char *what, | 148 | const char *what, |
148 | float *f); | 149 | float *f); |
@@ -155,7 +156,7 @@ GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | |||
155 | * @param what describes what is being read (for error message creation) | 156 | * @param what describes what is being read (for error message creation) |
156 | * @param f address of double to read | 157 | * @param f address of double to read |
157 | */ | 158 | */ |
158 | int | 159 | enum GNUNET_GenericReturnValue |
159 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | 160 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, |
160 | const char *what, | 161 | const char *what, |
161 | double *f); | 162 | double *f); |
@@ -169,7 +170,7 @@ GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | |||
169 | * @param i where to store the data | 170 | * @param i where to store the data |
170 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 171 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
171 | */ | 172 | */ |
172 | int | 173 | enum GNUNET_GenericReturnValue |
173 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | 174 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, |
174 | const char *what, | 175 | const char *what, |
175 | int32_t *i); | 176 | int32_t *i); |
@@ -183,7 +184,7 @@ GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | |||
183 | * @param i where to store the data | 184 | * @param i where to store the data |
184 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 185 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
185 | */ | 186 | */ |
186 | int | 187 | enum GNUNET_GenericReturnValue |
187 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, | 188 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, |
188 | const char *what, | 189 | const char *what, |
189 | int64_t *i); | 190 | int64_t *i); |
@@ -224,7 +225,7 @@ GNUNET_BIO_write_open_buffer (void); | |||
224 | * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned | 225 | * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned |
225 | * and the file is closed | 226 | * and the file is closed |
226 | */ | 227 | */ |
227 | int | 228 | enum GNUNET_GenericReturnValue |
228 | GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); | 229 | GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); |
229 | 230 | ||
230 | 231 | ||
@@ -240,7 +241,7 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); | |||
240 | * @param size where to store the size of @e contents | 241 | * @param size where to store the size of @e contents |
241 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 242 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
242 | */ | 243 | */ |
243 | int | 244 | enum GNUNET_GenericReturnValue |
244 | GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, | 245 | GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, |
245 | char **emsg, | 246 | char **emsg, |
246 | void **contents, | 247 | void **contents, |
@@ -256,7 +257,7 @@ GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, | |||
256 | * if the handle has an error message, the return value is #GNUNET_SYSERR | 257 | * if the handle has an error message, the return value is #GNUNET_SYSERR |
257 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 258 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
258 | */ | 259 | */ |
259 | int | 260 | enum GNUNET_GenericReturnValue |
260 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); | 261 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); |
261 | 262 | ||
262 | 263 | ||
@@ -269,7 +270,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); | |||
269 | * @param n number of bytes to write | 270 | * @param n number of bytes to write |
270 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 271 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
271 | */ | 272 | */ |
272 | int | 273 | enum GNUNET_GenericReturnValue |
273 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | 274 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, |
274 | const char *what, | 275 | const char *what, |
275 | const void *buffer, | 276 | const void *buffer, |
@@ -284,7 +285,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | |||
284 | * @param s string to write (can be NULL) | 285 | * @param s string to write (can be NULL) |
285 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 286 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
286 | */ | 287 | */ |
287 | int | 288 | enum GNUNET_GenericReturnValue |
288 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, | 289 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, |
289 | const char *what, | 290 | const char *what, |
290 | const char *s); | 291 | const char *s); |
@@ -298,7 +299,7 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, | |||
298 | * @param what what is being written (for error message creation) | 299 | * @param what what is being written (for error message creation) |
299 | * @param f float to write (must be a variable) | 300 | * @param f float to write (must be a variable) |
300 | */ | 301 | */ |
301 | int | 302 | enum GNUNET_GenericReturnValue |
302 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | 303 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, |
303 | const char *what, | 304 | const char *what, |
304 | float f); | 305 | float f); |
@@ -310,7 +311,7 @@ GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | |||
310 | * @param what what is being written (for error message creation) | 311 | * @param what what is being written (for error message creation) |
311 | * @param f double to write (must be a variable) | 312 | * @param f double to write (must be a variable) |
312 | */ | 313 | */ |
313 | int | 314 | enum GNUNET_GenericReturnValue |
314 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | 315 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, |
315 | const char *what, | 316 | const char *what, |
316 | double f); | 317 | double f); |
@@ -324,7 +325,7 @@ GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | |||
324 | * @param i 32-bit integer to write | 325 | * @param i 32-bit integer to write |
325 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 326 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
326 | */ | 327 | */ |
327 | int | 328 | enum GNUNET_GenericReturnValue |
328 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | 329 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, |
329 | const char *what, | 330 | const char *what, |
330 | int32_t i); | 331 | int32_t i); |
@@ -338,7 +339,7 @@ GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | |||
338 | * @param i 64-bit integer to write | 339 | * @param i 64-bit integer to write |
339 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 340 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
340 | */ | 341 | */ |
341 | int | 342 | enum GNUNET_GenericReturnValue |
342 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, | 343 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, |
343 | const char *what, | 344 | const char *what, |
344 | int64_t i); | 345 | int64_t i); |
@@ -489,7 +490,7 @@ GNUNET_BIO_read_spec_double (const char *what, double *f); | |||
489 | * the last element must be #GNUNET_BIO_read_spec_end | 490 | * the last element must be #GNUNET_BIO_read_spec_end |
490 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 491 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
491 | */ | 492 | */ |
492 | int | 493 | enum GNUNET_GenericReturnValue |
493 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, | 494 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, |
494 | struct GNUNET_BIO_ReadSpec *rs); | 495 | struct GNUNET_BIO_ReadSpec *rs); |
495 | 496 | ||
@@ -635,7 +636,7 @@ GNUNET_BIO_write_spec_double (const char *what, double *f); | |||
635 | * the last element must be #GNUNET_BIO_write_spec_end | 636 | * the last element must be #GNUNET_BIO_write_spec_end |
636 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 637 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
637 | */ | 638 | */ |
638 | int | 639 | enum GNUNET_GenericReturnValue |
639 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, | 640 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, |
640 | struct GNUNET_BIO_WriteSpec *ws); | 641 | struct GNUNET_BIO_WriteSpec *ws); |
641 | 642 | ||
diff --git a/src/include/gnunet_child_management_lib.h b/src/include/gnunet_child_management_lib.h index 39eb03760..ab0ab93eb 100644 --- a/src/include/gnunet_child_management_lib.h +++ b/src/include/gnunet_child_management_lib.h | |||
@@ -49,8 +49,7 @@ struct GNUNET_ChildWaitHandle; | |||
49 | * @param cls handle for the callback | 49 | * @param cls handle for the callback |
50 | * @param type type of the process | 50 | * @param type type of the process |
51 | * @param exit_code status code of the process | 51 | * @param exit_code status code of the process |
52 | * | 52 | */ |
53 | */ | ||
54 | typedef void | 53 | typedef void |
55 | (*GNUNET_ChildCompletedCallback)(void *cls, | 54 | (*GNUNET_ChildCompletedCallback)(void *cls, |
56 | enum GNUNET_OS_ProcessStatusType type, | 55 | enum GNUNET_OS_ProcessStatusType type, |
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index ce1b8f296..df38317ca 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -52,6 +52,7 @@ | |||
52 | * @} | 52 | * @} |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include "gnunet_common.h" | ||
55 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 56 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
56 | #error "Only <gnunet_util_lib.h> can be included directly." | 57 | #error "Only <gnunet_util_lib.h> can be included directly." |
57 | #endif | 58 | #endif |
@@ -177,7 +178,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, | |||
177 | * @param size the size of the given @a data array | 178 | * @param size the size of the given @a data array |
178 | * @return #GNUNET_SYSERR if the data array of the wrong size | 179 | * @return #GNUNET_SYSERR if the data array of the wrong size |
179 | */ | 180 | */ |
180 | int | 181 | enum GNUNET_GenericReturnValue |
181 | GNUNET_CONTAINER_bloomfilter_get_raw_data ( | 182 | GNUNET_CONTAINER_bloomfilter_get_raw_data ( |
182 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 183 | const struct GNUNET_CONTAINER_BloomFilter *bf, |
183 | char *data, | 184 | char *data, |
@@ -291,7 +292,7 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf); | |||
291 | * @param size size of @a data | 292 | * @param size size of @a data |
292 | * @return #GNUNET_OK on success | 293 | * @return #GNUNET_OK on success |
293 | */ | 294 | */ |
294 | int | 295 | enum GNUNET_GenericReturnValue |
295 | GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, | 296 | GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, |
296 | const char *data, | 297 | const char *data, |
297 | size_t size); | 298 | size_t size); |
@@ -307,7 +308,7 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
307 | * @param to_or the bloomfilter to or-in | 308 | * @param to_or the bloomfilter to or-in |
308 | * @return #GNUNET_OK on success | 309 | * @return #GNUNET_OK on success |
309 | */ | 310 | */ |
310 | int | 311 | enum GNUNET_GenericReturnValue |
311 | GNUNET_CONTAINER_bloomfilter_or2 ( | 312 | GNUNET_CONTAINER_bloomfilter_or2 ( |
312 | struct GNUNET_CONTAINER_BloomFilter *bf, | 313 | struct GNUNET_CONTAINER_BloomFilter *bf, |
313 | const struct GNUNET_CONTAINER_BloomFilter *to_or); | 314 | const struct GNUNET_CONTAINER_BloomFilter *to_or); |
@@ -577,7 +578,7 @@ GNUNET_CONTAINER_multihashmap_size ( | |||
577 | * @return the number of key value pairs processed, | 578 | * @return the number of key value pairs processed, |
578 | * #GNUNET_SYSERR if it aborted iteration | 579 | * #GNUNET_SYSERR if it aborted iteration |
579 | */ | 580 | */ |
580 | int | 581 | enum GNUNET_GenericReturnValue |
581 | GNUNET_CONTAINER_multihashmap_iterate ( | 582 | GNUNET_CONTAINER_multihashmap_iterate ( |
582 | struct GNUNET_CONTAINER_MultiHashMap *map, | 583 | struct GNUNET_CONTAINER_MultiHashMap *map, |
583 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, | 584 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, |
@@ -646,7 +647,7 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy ( | |||
646 | * @return the number of key value pairs processed, | 647 | * @return the number of key value pairs processed, |
647 | * #GNUNET_SYSERR if it aborted iteration | 648 | * #GNUNET_SYSERR if it aborted iteration |
648 | */ | 649 | */ |
649 | int | 650 | enum GNUNET_GenericReturnValue |
650 | GNUNET_CONTAINER_multihashmap_get_multiple ( | 651 | GNUNET_CONTAINER_multihashmap_get_multiple ( |
651 | struct GNUNET_CONTAINER_MultiHashMap *map, | 652 | struct GNUNET_CONTAINER_MultiHashMap *map, |
652 | const struct GNUNET_HashCode *key, | 653 | const struct GNUNET_HashCode *key, |
@@ -1423,7 +1424,7 @@ GNUNET_CONTAINER_multiuuidmap_size ( | |||
1423 | * @return the number of key value pairs processed, | 1424 | * @return the number of key value pairs processed, |
1424 | * #GNUNET_SYSERR if it aborted iteration | 1425 | * #GNUNET_SYSERR if it aborted iteration |
1425 | */ | 1426 | */ |
1426 | int | 1427 | enum GNUNET_GenericReturnValue |
1427 | GNUNET_CONTAINER_multiuuidmap_iterate ( | 1428 | GNUNET_CONTAINER_multiuuidmap_iterate ( |
1428 | struct GNUNET_CONTAINER_MultiUuidmap *map, | 1429 | struct GNUNET_CONTAINER_MultiUuidmap *map, |
1429 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, | 1430 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index a9e1a3212..44dfb4e44 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -44,7 +44,7 @@ | |||
44 | * @see [Documentation](https://gnunet.org/crypto-api) | 44 | * @see [Documentation](https://gnunet.org/crypto-api) |
45 | */ | 45 | */ |
46 | 46 | ||
47 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 47 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
48 | #error "Only <gnunet_util_lib.h> can be included directly." | 48 | #error "Only <gnunet_util_lib.h> can be included directly." |
49 | #endif | 49 | #endif |
50 | 50 | ||
@@ -846,7 +846,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, | |||
846 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 846 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
847 | */ | 847 | */ |
848 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ | 848 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ |
849 | GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) | 849 | GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) |
850 | 850 | ||
851 | 851 | ||
852 | /** | 852 | /** |
@@ -1837,6 +1837,122 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1837 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1837 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1838 | struct GNUNET_HashCode *key_material); | 1838 | struct GNUNET_HashCode *key_material); |
1839 | 1839 | ||
1840 | /** | ||
1841 | * @ingroup crypto | ||
1842 | * Decapsulate a key for a private EdDSA key. | ||
1843 | * Dual to #GNUNET_CRRYPTO_eddsa_kem_encaps. | ||
1844 | * | ||
1845 | * @param priv private key from EdDSA to use for the ECDH (x) | ||
1846 | * @param c the encapsulated key | ||
1847 | * @param key_material where to write the key material H(h(x)yG) | ||
1848 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1849 | */ | ||
1850 | enum GNUNET_GenericReturnValue | ||
1851 | GNUNET_CRYPTO_eddsa_kem_decaps (const struct | ||
1852 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
1853 | const struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
1854 | struct GNUNET_HashCode *key_material); | ||
1855 | |||
1856 | /** | ||
1857 | * @ingroup crypto | ||
1858 | * Encapsulate key material for a EdDSA public key. | ||
1859 | * Dual to #GNUNET_CRRYPTO_eddsa_kem_decaps. | ||
1860 | * | ||
1861 | * @param priv private key to use for the ECDH (y) | ||
1862 | * @param c public key from EdDSA to use for the ECDH (X=h(x)G) | ||
1863 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1864 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1865 | */ | ||
1866 | enum GNUNET_GenericReturnValue | ||
1867 | GNUNET_CRYPTO_eddsa_kem_encaps (const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
1868 | struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
1869 | struct GNUNET_HashCode *key_material); | ||
1870 | |||
1871 | /** | ||
1872 | * This is the encapsulated key of our FO-KEM. | ||
1873 | */ | ||
1874 | struct GNUNET_CRYPTO_FoKemC | ||
1875 | { | ||
1876 | /* The output of the FO-OWTF F(x) */ | ||
1877 | struct GNUNET_HashCode y; | ||
1878 | |||
1879 | /* The ephemeral public key from the DH in the KEM */ | ||
1880 | struct GNUNET_CRYPTO_EcdhePublicKey pub; | ||
1881 | }; | ||
1882 | |||
1883 | /** | ||
1884 | * @ingroup crypto | ||
1885 | * Encapsulate key material using a CCA-secure KEM. | ||
1886 | * The KEM is using a OWTF with image oracle constructed from | ||
1887 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
1888 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. | ||
1889 | * | ||
1890 | * @param pub public key to encapsulated for | ||
1891 | * @param[out] c the encapsulation | ||
1892 | * @param[out] key_material the encapsulated key | ||
1893 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1894 | */ | ||
1895 | enum GNUNET_GenericReturnValue | ||
1896 | GNUNET_CRYPTO_eddsa_fo_kem_encaps ( | ||
1897 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
1898 | struct GNUNET_CRYPTO_FoKemC *c, | ||
1899 | struct GNUNET_HashCode *key_material); | ||
1900 | |||
1901 | |||
1902 | /** | ||
1903 | * @ingroup crypto | ||
1904 | * Decapsulate key material using a CCA-secure KEM. | ||
1905 | * The KEM is using a OWTF with image oracle constructed from | ||
1906 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
1907 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. | ||
1908 | * | ||
1909 | * @param priv private key this encapsulation is for | ||
1910 | * @param c the encapsulation | ||
1911 | * @param[out] key_material the encapsulated key | ||
1912 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1913 | */ | ||
1914 | enum GNUNET_GenericReturnValue | ||
1915 | GNUNET_CRYPTO_eddsa_fo_kem_decaps (const struct | ||
1916 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
1917 | const struct GNUNET_CRYPTO_FoKemC *c, | ||
1918 | struct GNUNET_HashCode *key_material); | ||
1919 | |||
1920 | /** | ||
1921 | * @ingroup crypto | ||
1922 | * Encapsulate key material using a CCA-secure KEM. | ||
1923 | * The KEM is using a OWTF with image oracle constructed from | ||
1924 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
1925 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. | ||
1926 | * | ||
1927 | * @param pub public key to encapsulated for | ||
1928 | * @param[out] c the encapsulation | ||
1929 | * @param[out] key_material the encapsulated key | ||
1930 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1931 | */ | ||
1932 | enum GNUNET_GenericReturnValue | ||
1933 | GNUNET_CRYPTO_ecdsa_fo_kem_encaps (const struct | ||
1934 | GNUNET_CRYPTO_EcdsaPublicKey *pub, | ||
1935 | struct GNUNET_CRYPTO_FoKemC *c, | ||
1936 | struct GNUNET_HashCode *key_material); | ||
1937 | |||
1938 | |||
1939 | /** | ||
1940 | * @ingroup crypto | ||
1941 | * Decapsulate key material using a CCA-secure KEM. | ||
1942 | * The KEM is using a OWTF with image oracle constructed from | ||
1943 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
1944 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. | ||
1945 | * | ||
1946 | * @param priv private key this encapsulation is for | ||
1947 | * @param c the encapsulation | ||
1948 | * @param[out] key_material the encapsulated key | ||
1949 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1950 | */ | ||
1951 | enum GNUNET_GenericReturnValue | ||
1952 | GNUNET_CRYPTO_ecdsa_fo_kem_decaps (const struct | ||
1953 | GNUNET_CRYPTO_EcdsaPrivateKey *priv, | ||
1954 | struct GNUNET_CRYPTO_FoKemC *c, | ||
1955 | struct GNUNET_HashCode *key_material); | ||
1840 | 1956 | ||
1841 | /** | 1957 | /** |
1842 | * @ingroup crypto | 1958 | * @ingroup crypto |
@@ -1869,6 +1985,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1869 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 1985 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1870 | struct GNUNET_HashCode *key_material); | 1986 | struct GNUNET_HashCode *key_material); |
1871 | 1987 | ||
1988 | |||
1872 | /** | 1989 | /** |
1873 | * @ingroup crypto | 1990 | * @ingroup crypto |
1874 | * Derive key material from a EcDSA public key and a private ECDH key. | 1991 | * Derive key material from a EcDSA public key and a private ECDH key. |
@@ -1920,15 +2037,15 @@ GNUNET_CRYPTO_eddsa_sign_ ( | |||
1920 | * @param[out] sig where to write the signature | 2037 | * @param[out] sig where to write the signature |
1921 | */ | 2038 | */ |
1922 | #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \ | 2039 | #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \ |
1923 | /* check size is set correctly */ \ | 2040 | /* check size is set correctly */ \ |
1924 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \ | 2041 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \ |
1925 | /* check 'ps' begins with the purpose */ \ | 2042 | /* check 'ps' begins with the purpose */ \ |
1926 | GNUNET_static_assert (((void*) (ps)) == \ | 2043 | GNUNET_static_assert (((void*) (ps)) == \ |
1927 | ((void*) &(ps)->purpose)); \ | 2044 | ((void*) &(ps)->purpose)); \ |
1928 | GNUNET_assert (GNUNET_OK == \ | 2045 | GNUNET_assert (GNUNET_OK == \ |
1929 | GNUNET_CRYPTO_eddsa_sign_ (priv, \ | 2046 | GNUNET_CRYPTO_eddsa_sign_ (priv, \ |
1930 | &(ps)->purpose, \ | 2047 | &(ps)->purpose, \ |
1931 | sig)); \ | 2048 | sig)); \ |
1932 | } while (0) | 2049 | } while (0) |
1933 | 2050 | ||
1934 | 2051 | ||
@@ -1982,15 +2099,15 @@ GNUNET_CRYPTO_eddsa_sign_raw ( | |||
1982 | * @param[out] sig where to write the signature | 2099 | * @param[out] sig where to write the signature |
1983 | */ | 2100 | */ |
1984 | #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \ | 2101 | #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \ |
1985 | /* check size is set correctly */ \ | 2102 | /* check size is set correctly */ \ |
1986 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | 2103 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ |
1987 | /* check 'ps' begins with the purpose */ \ | 2104 | /* check 'ps' begins with the purpose */ \ |
1988 | GNUNET_static_assert (((void*) (ps)) == \ | 2105 | GNUNET_static_assert (((void*) (ps)) == \ |
1989 | ((void*) &(ps)->purpose)); \ | 2106 | ((void*) &(ps)->purpose)); \ |
1990 | GNUNET_assert (GNUNET_OK == \ | 2107 | GNUNET_assert (GNUNET_OK == \ |
1991 | GNUNET_CRYPTO_ecdsa_sign_ (priv, \ | 2108 | GNUNET_CRYPTO_ecdsa_sign_ (priv, \ |
1992 | &(ps)->purpose, \ | 2109 | &(ps)->purpose, \ |
1993 | sig)); \ | 2110 | sig)); \ |
1994 | } while (0) | 2111 | } while (0) |
1995 | 2112 | ||
1996 | /** | 2113 | /** |
@@ -2029,15 +2146,15 @@ GNUNET_CRYPTO_edx25519_sign_ ( | |||
2029 | * @param[out] sig where to write the signature | 2146 | * @param[out] sig where to write the signature |
2030 | */ | 2147 | */ |
2031 | #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \ | 2148 | #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \ |
2032 | /* check size is set correctly */ \ | 2149 | /* check size is set correctly */ \ |
2033 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | 2150 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ |
2034 | /* check 'ps' begins with the purpose */ \ | 2151 | /* check 'ps' begins with the purpose */ \ |
2035 | GNUNET_static_assert (((void*) (ps)) == \ | 2152 | GNUNET_static_assert (((void*) (ps)) == \ |
2036 | ((void*) &(ps)->purpose)); \ | 2153 | ((void*) &(ps)->purpose)); \ |
2037 | GNUNET_assert (GNUNET_OK == \ | 2154 | GNUNET_assert (GNUNET_OK == \ |
2038 | GNUNET_CRYPTO_edx25519_sign_ (priv, \ | 2155 | GNUNET_CRYPTO_edx25519_sign_ (priv, \ |
2039 | &(ps)->purpose, \ | 2156 | &(ps)->purpose, \ |
2040 | sig)); \ | 2157 | sig)); \ |
2041 | } while (0) | 2158 | } while (0) |
2042 | 2159 | ||
2043 | 2160 | ||
@@ -2700,7 +2817,7 @@ GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, | |||
2700 | * @param[out] buf_size number of bytes stored in @a buf | 2817 | * @param[out] buf_size number of bytes stored in @a buf |
2701 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious | 2818 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious |
2702 | */ | 2819 | */ |
2703 | int | 2820 | enum GNUNET_GenericReturnValue |
2704 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | 2821 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, |
2705 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 2822 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2706 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, | 2823 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, |
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index bdf3843b1..967170085 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h | |||
@@ -433,7 +433,7 @@ GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx, | |||
433 | * | 433 | * |
434 | * @returns #GNUNET_YES iff given a valid scope ID | 434 | * @returns #GNUNET_YES iff given a valid scope ID |
435 | */ | 435 | */ |
436 | int | 436 | enum GNUNET_GenericReturnValue |
437 | GNUNET_CURL_is_valid_scope_id (const char *scope_id); | 437 | GNUNET_CURL_is_valid_scope_id (const char *scope_id); |
438 | 438 | ||
439 | 439 | ||
diff --git a/src/include/gnunet_dht_block_types.h b/src/include/gnunet_dht_block_types.h new file mode 100644 index 000000000..ab46af410 --- /dev/null +++ b/src/include/gnunet_dht_block_types.h | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNUNET_DHT_BLOCK_TYPES_H | ||
21 | #define GNUNET_DHT_BLOCK_TYPES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add DHT block types, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | /** | ||
40 | * Blocks in the datastore and the datacache must have a unique type. | ||
41 | */ | ||
42 | enum GNUNET_BLOCK_Type | ||
43 | { | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Identifier for any block. | ||
48 | */ | ||
49 | GNUNET_BLOCK_TYPE_ANY = 0, | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Data block (leaf) in the CHK tree. | ||
54 | */ | ||
55 | GNUNET_BLOCK_TYPE_FS_DBLOCK = 1, | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Inner block in the CHK tree. | ||
60 | */ | ||
61 | GNUNET_BLOCK_TYPE_FS_IBLOCK = 2, | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Type of a block representing a block to be encoded on demand from disk. Should never appear on the network directly. | ||
66 | */ | ||
67 | GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6, | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Legacy type of a block that contains a HELLO for a peer. | ||
72 | */ | ||
73 | GNUNET_BLOCK_TYPE_LEGACY_HELLO = 7, | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Block for testing. | ||
78 | */ | ||
79 | GNUNET_BLOCK_TYPE_TEST = 8, | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Type of a block representing any type of search result (universal). | ||
84 | */ | ||
85 | GNUNET_BLOCK_TYPE_FS_UBLOCK = 9, | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Block for storing DNS exit service advertisements. | ||
90 | */ | ||
91 | GNUNET_BLOCK_TYPE_DNS = 10, | ||
92 | |||
93 | |||
94 | /** | ||
95 | * Block for storing GNS record data. | ||
96 | */ | ||
97 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Block type for a revocation message by which a key is revoked. | ||
102 | */ | ||
103 | GNUNET_BLOCK_TYPE_REVOCATION = 12, | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Type of a block that contains a DHT-NG HELLO for a peer. | ||
108 | */ | ||
109 | GNUNET_BLOCK_TYPE_DHT_HELLO = 13, | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Block to store a cadet regex state | ||
114 | */ | ||
115 | GNUNET_BLOCK_TYPE_REGEX = 22, | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Block to store a cadet regex accepting state | ||
120 | */ | ||
121 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT = 23, | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Block for testing set/consensus. If first byte of the block is non-zero, the block is considered invalid. | ||
126 | */ | ||
127 | GNUNET_BLOCK_TYPE_SET_TEST = 24, | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Block type for consensus elements. Contains either special marker elements or a nested block. | ||
132 | */ | ||
133 | GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT = 25, | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Block for testing set intersection. If first byte of the block is non-zero, the block is considered invalid. | ||
138 | */ | ||
139 | GNUNET_BLOCK_TYPE_SETI_TEST = 26, | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Block for testing set union. If first byte of the block is non-zero, the block is considered invalid. | ||
144 | */ | ||
145 | GNUNET_BLOCK_TYPE_SETU_TEST = 27, | ||
146 | }; | ||
147 | |||
148 | |||
149 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
150 | { | ||
151 | #endif | ||
152 | #ifdef __cplusplus | ||
153 | } | ||
154 | #endif | ||
155 | |||
156 | #endif | ||
diff --git a/src/include/gnunet_error_codes.h b/src/include/gnunet_error_codes.h new file mode 100644 index 000000000..aa897afe0 --- /dev/null +++ b/src/include/gnunet_error_codes.h | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file include/taler_error_codes.h | ||
22 | * @brief GNUnet error codes, generated via https://gana.gnunet.org/ | ||
23 | * | ||
24 | * Do NOT edit this file, it is generated! | ||
25 | */ | ||
26 | #ifndef GNUNET_ERROR_CODES_H | ||
27 | #define GNUNET_ERROR_CODES_H | ||
28 | |||
29 | #ifdef __cplusplus | ||
30 | extern "C" { | ||
31 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
32 | } | ||
33 | #endif | ||
34 | #endif | ||
35 | |||
36 | #include <limits.h> | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Taler error codes. | ||
41 | */ | ||
42 | enum GNUNET_ErrorCode | ||
43 | { | ||
44 | |||
45 | |||
46 | /** | ||
47 | * No error (success). | ||
48 | * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). | ||
49 | */ | ||
50 | GNUNET_EC_NONE = 0, | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Unknown and unspecified error. | ||
55 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
56 | */ | ||
57 | GNUNET_EC_UNKNOWN = 1, | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Communication with service failed. | ||
62 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
63 | */ | ||
64 | GNUNET_EC_SERVICE_COMMUNICATION_FAILED = 101, | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Ego not found. | ||
69 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
70 | */ | ||
71 | GNUNET_EC_IDENTITY_NOT_FOUND = 200, | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Identifier already in use for another ego. | ||
76 | * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). | ||
77 | */ | ||
78 | GNUNET_EC_IDENTITY_NAME_CONFLICT = 201, | ||
79 | |||
80 | |||
81 | /** | ||
82 | * The given ego is invalid or malformed. | ||
83 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
84 | */ | ||
85 | GNUNET_EC_IDENTITY_INVALID = 202, | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Unknown namestore error. | ||
90 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
91 | */ | ||
92 | GNUNET_EC_NAMESTORE_UNKNOWN = 5000, | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Zone iteration failed. | ||
97 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
98 | */ | ||
99 | GNUNET_EC_NAMESTORE_ITERATION_FAILED = 5001, | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Zone not found. | ||
104 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
105 | */ | ||
106 | GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND = 5002, | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Record not found. | ||
111 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
112 | */ | ||
113 | GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND = 5003, | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Zone iteration failed. | ||
118 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
119 | */ | ||
120 | GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED = 5004, | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Zone does not contain any records. | ||
125 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
126 | */ | ||
127 | GNUNET_EC_NAMESTORE_ZONE_EMPTY = 5005, | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Failed to lookup record. | ||
132 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
133 | */ | ||
134 | GNUNET_EC_NAMESTORE_LOOKUP_ERROR = 5006, | ||
135 | |||
136 | |||
137 | /** | ||
138 | * No records given. | ||
139 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
140 | */ | ||
141 | GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN = 5007, | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Record data invalid. | ||
146 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
147 | */ | ||
148 | GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID = 5008, | ||
149 | |||
150 | |||
151 | /** | ||
152 | * No label given. | ||
153 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
154 | */ | ||
155 | GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN = 5009, | ||
156 | |||
157 | |||
158 | /** | ||
159 | * No results given. | ||
160 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
161 | */ | ||
162 | GNUNET_EC_NAMESTORE_NO_RESULTS = 5010, | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Record already exists. | ||
167 | * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). | ||
168 | */ | ||
169 | GNUNET_EC_NAMESTORE_RECORD_EXISTS = 5011, | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Record size exceeds maximum limit. | ||
174 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
175 | */ | ||
176 | GNUNET_EC_NAMESTORE_RECORD_TOO_BIG = 5012, | ||
177 | |||
178 | |||
179 | /** | ||
180 | * There was an error in the database backend. | ||
181 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
182 | */ | ||
183 | GNUNET_EC_NAMESTORE_BACKEND_FAILED = 5013, | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Failed to store the given records. | ||
188 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
189 | */ | ||
190 | GNUNET_EC_NAMESTORE_STORE_FAILED = 5014, | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Label invalid or malformed. | ||
195 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
196 | */ | ||
197 | GNUNET_EC_NAMESTORE_LABEL_INVALID = 5015, | ||
198 | |||
199 | |||
200 | }; | ||
201 | |||
202 | |||
203 | /** | ||
204 | * Returns a hint for a given error code. | ||
205 | * | ||
206 | * @param ec the error code. | ||
207 | * @return the hint if it could be found, otherwise "<no hint found>" | ||
208 | */ | ||
209 | const char * | ||
210 | GNUNET_ErrorCode_get_hint (enum GNUNET_ErrorCode ec); | ||
211 | |||
212 | |||
213 | /** | ||
214 | * Return HTTP status for a given error code. | ||
215 | * | ||
216 | * @param ec the error code. | ||
217 | * @return the HTTP status code for the given @a ec, UINT_MAX if not found | ||
218 | */ | ||
219 | unsigned int | ||
220 | GNUNET_ErrorCode_get_http_status (enum GNUNET_ErrorCode ec); | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Return HTTP status for a given error code that is guaranteed | ||
225 | * to work (no corner cases). | ||
226 | * | ||
227 | * @param ec the error code. | ||
228 | * @return the HTTP status code for the given @a ec, 500 if | ||
229 | * the @a ec is not found or is a client-side code | ||
230 | */ | ||
231 | unsigned int | ||
232 | GNUNET_ErrorCode_get_http_status_safe (enum GNUNET_ErrorCode ec); | ||
233 | |||
234 | |||
235 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
236 | { | ||
237 | #endif | ||
238 | #ifdef __cplusplus | ||
239 | } | ||
240 | #endif | ||
241 | |||
242 | #endif | ||
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 3aee30117..338f22223 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #define GNUNET_GNSRECORD_LIB_H | 38 | #define GNUNET_GNSRECORD_LIB_H |
39 | 39 | ||
40 | 40 | ||
41 | #include "gnunet_common.h" | ||
41 | #include "gnunet_identity_service.h" | 42 | #include "gnunet_identity_service.h" |
42 | 43 | ||
43 | #ifdef __cplusplus | 44 | #ifdef __cplusplus |
@@ -653,7 +654,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
653 | * @param block block to verify | 654 | * @param block block to verify |
654 | * @return #GNUNET_OK if the signature is valid | 655 | * @return #GNUNET_OK if the signature is valid |
655 | */ | 656 | */ |
656 | int | 657 | enum GNUNET_GenericReturnValue |
657 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | 658 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); |
658 | 659 | ||
659 | 660 | ||
@@ -668,7 +669,7 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | |||
668 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was | 669 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was |
669 | * not well-formed | 670 | * not well-formed |
670 | */ | 671 | */ |
671 | int | 672 | enum GNUNET_GenericReturnValue |
672 | GNUNET_GNSRECORD_block_decrypt ( | 673 | GNUNET_GNSRECORD_block_decrypt ( |
673 | const struct GNUNET_GNSRECORD_Block *block, | 674 | const struct GNUNET_GNSRECORD_Block *block, |
674 | const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, | 675 | const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, |
@@ -682,7 +683,7 @@ GNUNET_GNSRECORD_block_decrypt ( | |||
682 | * @param b another record | 683 | * @param b another record |
683 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. | 684 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. |
684 | */ | 685 | */ |
685 | int | 686 | enum GNUNET_GenericReturnValue |
686 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | 687 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, |
687 | const struct GNUNET_GNSRECORD_Data *b); | 688 | const struct GNUNET_GNSRECORD_Data *b); |
688 | 689 | ||
diff --git a/src/include/gnunet_helper_lib.h b/src/include/gnunet_helper_lib.h index 2279abb24..c329c4a33 100644 --- a/src/include/gnunet_helper_lib.h +++ b/src/include/gnunet_helper_lib.h | |||
@@ -38,7 +38,7 @@ | |||
38 | * @{ | 38 | * @{ |
39 | */ | 39 | */ |
40 | 40 | ||
41 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 41 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
42 | #error "Only <gnunet_util_lib.h> can be included directly." | 42 | #error "Only <gnunet_util_lib.h> can be included directly." |
43 | #endif | 43 | #endif |
44 | 44 | ||
@@ -99,8 +99,9 @@ GNUNET_HELPER_start (int with_control_pipe, | |||
99 | * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper | 99 | * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper |
100 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error | 100 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error |
101 | */ | 101 | */ |
102 | int | 102 | enum GNUNET_GenericReturnValue |
103 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill); | 103 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, |
104 | int soft_kill); | ||
104 | 105 | ||
105 | 106 | ||
106 | /** | 107 | /** |
@@ -111,7 +112,7 @@ GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill); | |||
111 | * @param h the helper handle | 112 | * @param h the helper handle |
112 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error | 113 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error |
113 | */ | 114 | */ |
114 | int | 115 | enum GNUNET_GenericReturnValue |
115 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); | 116 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); |
116 | 117 | ||
117 | 118 | ||
@@ -144,8 +145,10 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill); | |||
144 | * #GNUNET_NO if helper process died | 145 | * #GNUNET_NO if helper process died |
145 | * #GNUNET_SYSERR during GNUNET_HELPER_destroy | 146 | * #GNUNET_SYSERR during GNUNET_HELPER_destroy |
146 | */ | 147 | */ |
147 | typedef void (*GNUNET_HELPER_Continuation)(void *cls, | 148 | typedef void |
148 | int result); | 149 | (*GNUNET_HELPER_Continuation)( |
150 | void *cls, | ||
151 | enum GNUNET_GenericReturnValue result); | ||
149 | 152 | ||
150 | 153 | ||
151 | /** | 154 | /** |
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 67327af5d..fd0458f62 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -45,6 +45,7 @@ | |||
45 | #ifndef GNUNET_IDENTITY_SERVICE_H | 45 | #ifndef GNUNET_IDENTITY_SERVICE_H |
46 | #define GNUNET_IDENTITY_SERVICE_H | 46 | #define GNUNET_IDENTITY_SERVICE_H |
47 | 47 | ||
48 | #include "gnunet_common.h" | ||
48 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
49 | extern "C" { | 50 | extern "C" { |
50 | #if 0 /* keep Emacsens' auto-indent happy */ | 51 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -406,7 +407,8 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); | |||
406 | * @return -1 on error, else the compacted length of the key. | 407 | * @return -1 on error, else the compacted length of the key. |
407 | */ | 408 | */ |
408 | ssize_t | 409 | ssize_t |
409 | GNUNET_IDENTITY_public_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); | 410 | GNUNET_IDENTITY_public_key_get_length (const struct |
411 | GNUNET_IDENTITY_PublicKey *key); | ||
410 | 412 | ||
411 | /** | 413 | /** |
412 | * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. | 414 | * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. |
@@ -419,14 +421,14 @@ GNUNET_IDENTITY_public_key_get_length (const struct GNUNET_IDENTITY_PublicKey *k | |||
419 | * @param len the length of buffer | 421 | * @param len the length of buffer |
420 | * @param key the key | 422 | * @param key the key |
421 | * @param the amount of bytes read from the buffer | 423 | * @param the amount of bytes read from the buffer |
422 | * @return GNUNET_SYSERR on error | 424 | * @return #GNUNET_SYSERR on error |
423 | */ | 425 | */ |
424 | enum GNUNET_GenericReturnValue | 426 | enum GNUNET_GenericReturnValue |
425 | GNUNET_IDENTITY_read_public_key_from_buffer (const void *buffer, | 427 | GNUNET_IDENTITY_read_public_key_from_buffer ( |
426 | size_t len, | 428 | const void *buffer, |
427 | struct | 429 | size_t len, |
428 | GNUNET_IDENTITY_PublicKey *key, | 430 | struct GNUNET_IDENTITY_PublicKey *key, |
429 | size_t *read); | 431 | size_t *read); |
430 | 432 | ||
431 | /** | 433 | /** |
432 | * Get the compacted length of a #GNUNET_IDENTITY_PrivateKey. | 434 | * Get the compacted length of a #GNUNET_IDENTITY_PrivateKey. |
@@ -439,8 +441,8 @@ GNUNET_IDENTITY_read_public_key_from_buffer (const void *buffer, | |||
439 | * @return -1 on error, else the compacted length of the key. | 441 | * @return -1 on error, else the compacted length of the key. |
440 | */ | 442 | */ |
441 | ssize_t | 443 | ssize_t |
442 | GNUNET_IDENTITY_private_key_get_length (const struct | 444 | GNUNET_IDENTITY_private_key_get_length ( |
443 | GNUNET_IDENTITY_PrivateKey *key); | 445 | const struct GNUNET_IDENTITY_PrivateKey *key); |
444 | 446 | ||
445 | 447 | ||
446 | /** | 448 | /** |
@@ -472,14 +474,14 @@ GNUNET_IDENTITY_write_public_key_to_buffer (const struct | |||
472 | * @param len the length of buffer | 474 | * @param len the length of buffer |
473 | * @param key the key | 475 | * @param key the key |
474 | * @param the amount of bytes read from the buffer | 476 | * @param the amount of bytes read from the buffer |
475 | * @return GNUNET_SYSERR on error | 477 | * @return #GNUNET_SYSERR on error |
476 | */ | 478 | */ |
477 | enum GNUNET_GenericReturnValue | 479 | enum GNUNET_GenericReturnValue |
478 | GNUNET_IDENTITY_read_private_key_from_buffer (const void*buffer, | 480 | GNUNET_IDENTITY_read_private_key_from_buffer ( |
479 | size_t len, | 481 | const void*buffer, |
480 | struct | 482 | size_t len, |
481 | GNUNET_IDENTITY_PrivateKey *key, | 483 | struct GNUNET_IDENTITY_PrivateKey *key, |
482 | size_t *read); | 484 | size_t *read); |
483 | 485 | ||
484 | 486 | ||
485 | /** | 487 | /** |
@@ -495,10 +497,10 @@ GNUNET_IDENTITY_read_private_key_from_buffer (const void*buffer, | |||
495 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | 497 | * @return -1 or -2 on error, else the amount of bytes written to the buffer |
496 | */ | 498 | */ |
497 | ssize_t | 499 | ssize_t |
498 | GNUNET_IDENTITY_write_private_key_to_buffer (const struct | 500 | GNUNET_IDENTITY_write_private_key_to_buffer ( |
499 | GNUNET_IDENTITY_PrivateKey *key, | 501 | const struct GNUNET_IDENTITY_PrivateKey *key, |
500 | void*buffer, | 502 | void*buffer, |
501 | size_t len); | 503 | size_t len); |
502 | 504 | ||
503 | 505 | ||
504 | /** | 506 | /** |
@@ -512,8 +514,8 @@ GNUNET_IDENTITY_write_private_key_to_buffer (const struct | |||
512 | * @return -1 on error, else the compacted length of the signature. | 514 | * @return -1 on error, else the compacted length of the signature. |
513 | */ | 515 | */ |
514 | ssize_t | 516 | ssize_t |
515 | GNUNET_IDENTITY_signature_get_length (const struct | 517 | GNUNET_IDENTITY_signature_get_length ( |
516 | GNUNET_IDENTITY_Signature *sig); | 518 | const struct GNUNET_IDENTITY_Signature *sig); |
517 | 519 | ||
518 | 520 | ||
519 | /** | 521 | /** |
@@ -527,8 +529,7 @@ GNUNET_IDENTITY_signature_get_length (const struct | |||
527 | * @return -1 on error, else the compacted length of the signature. | 529 | * @return -1 on error, else the compacted length of the signature. |
528 | */ | 530 | */ |
529 | ssize_t | 531 | ssize_t |
530 | GNUNET_IDENTITY_signature_get_raw_length_by_type (const uint32_t type); | 532 | GNUNET_IDENTITY_signature_get_raw_length_by_type (uint32_t type); |
531 | |||
532 | 533 | ||
533 | 534 | ||
534 | /** | 535 | /** |
@@ -544,10 +545,10 @@ GNUNET_IDENTITY_signature_get_raw_length_by_type (const uint32_t type); | |||
544 | * @return -1 or -2 on error, else the amount of bytes read from the buffer | 545 | * @return -1 or -2 on error, else the amount of bytes read from the buffer |
545 | */ | 546 | */ |
546 | ssize_t | 547 | ssize_t |
547 | GNUNET_IDENTITY_read_signature_from_buffer (struct | 548 | GNUNET_IDENTITY_read_signature_from_buffer ( |
548 | GNUNET_IDENTITY_Signature *sig, | 549 | struct GNUNET_IDENTITY_Signature *sig, |
549 | const void*buffer, | 550 | const void*buffer, |
550 | size_t len); | 551 | size_t len); |
551 | 552 | ||
552 | 553 | ||
553 | /** | 554 | /** |
@@ -563,10 +564,10 @@ GNUNET_IDENTITY_read_signature_from_buffer (struct | |||
563 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | 564 | * @return -1 or -2 on error, else the amount of bytes written to the buffer |
564 | */ | 565 | */ |
565 | ssize_t | 566 | ssize_t |
566 | GNUNET_IDENTITY_write_signature_to_buffer (const struct | 567 | GNUNET_IDENTITY_write_signature_to_buffer ( |
567 | GNUNET_IDENTITY_Signature *sig, | 568 | const struct GNUNET_IDENTITY_Signature *sig, |
568 | void*buffer, | 569 | void*buffer, |
569 | size_t len); | 570 | size_t len); |
570 | 571 | ||
571 | 572 | ||
572 | /** | 573 | /** |
@@ -583,11 +584,10 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct | |||
583 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 584 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
584 | */ | 585 | */ |
585 | enum GNUNET_GenericReturnValue | 586 | enum GNUNET_GenericReturnValue |
586 | GNUNET_IDENTITY_sign_ (const struct | 587 | GNUNET_IDENTITY_sign_ ( |
587 | GNUNET_IDENTITY_PrivateKey *priv, | 588 | const struct GNUNET_IDENTITY_PrivateKey *priv, |
588 | const struct | 589 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
589 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 590 | struct GNUNET_IDENTITY_Signature *sig); |
590 | struct GNUNET_IDENTITY_Signature *sig); | ||
591 | 591 | ||
592 | /** | 592 | /** |
593 | * @brief Sign a given block. | 593 | * @brief Sign a given block. |
@@ -603,11 +603,10 @@ GNUNET_IDENTITY_sign_ (const struct | |||
603 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 603 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
604 | */ | 604 | */ |
605 | enum GNUNET_GenericReturnValue | 605 | enum GNUNET_GenericReturnValue |
606 | GNUNET_IDENTITY_sign_raw_ (const struct | 606 | GNUNET_IDENTITY_sign_raw_ ( |
607 | GNUNET_IDENTITY_PrivateKey *priv, | 607 | const struct GNUNET_IDENTITY_PrivateKey *priv, |
608 | const struct | 608 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
609 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 609 | unsigned char *sig); |
610 | unsigned char *sig); | ||
611 | 610 | ||
612 | 611 | ||
613 | /** | 612 | /** |
@@ -622,15 +621,15 @@ GNUNET_IDENTITY_sign_raw_ (const struct | |||
622 | * @param[out] sig where to write the signature | 621 | * @param[out] sig where to write the signature |
623 | */ | 622 | */ |
624 | #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \ | 623 | #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \ |
625 | /* check size is set correctly */ \ | 624 | /* check size is set correctly */ \ |
626 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | 625 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ |
627 | /* check 'ps' begins with the purpose */ \ | 626 | /* check 'ps' begins with the purpose */ \ |
628 | GNUNET_static_assert (((void*) (ps)) == \ | 627 | GNUNET_static_assert (((void*) (ps)) == \ |
629 | ((void*) &(ps)->purpose)); \ | 628 | ((void*) &(ps)->purpose)); \ |
630 | GNUNET_assert (GNUNET_OK == \ | 629 | GNUNET_assert (GNUNET_OK == \ |
631 | GNUNET_IDENTITY_sign_ (priv, \ | 630 | GNUNET_IDENTITY_sign_ (priv, \ |
632 | &(ps)->purpose, \ | 631 | &(ps)->purpose, \ |
633 | sig)); \ | 632 | sig)); \ |
634 | } while (0) | 633 | } while (0) |
635 | 634 | ||
636 | 635 | ||
@@ -652,12 +651,11 @@ GNUNET_IDENTITY_sign_raw_ (const struct | |||
652 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 651 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
653 | */ | 652 | */ |
654 | enum GNUNET_GenericReturnValue | 653 | enum GNUNET_GenericReturnValue |
655 | GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | 654 | GNUNET_IDENTITY_signature_verify_ ( |
656 | const struct | 655 | uint32_t purpose, |
657 | GNUNET_CRYPTO_EccSignaturePurpose *validate, | 656 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
658 | const struct GNUNET_IDENTITY_Signature *sig, | 657 | const struct GNUNET_IDENTITY_Signature *sig, |
659 | const struct | 658 | const struct GNUNET_IDENTITY_PublicKey *pub); |
660 | GNUNET_IDENTITY_PublicKey *pub); | ||
661 | 659 | ||
662 | /** | 660 | /** |
663 | * @brief Verify a given signature. | 661 | * @brief Verify a given signature. |
@@ -675,13 +673,11 @@ GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | |||
675 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 673 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
676 | */ | 674 | */ |
677 | enum GNUNET_GenericReturnValue | 675 | enum GNUNET_GenericReturnValue |
678 | GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | 676 | GNUNET_IDENTITY_signature_verify_raw_ ( |
679 | const struct | 677 | uint32_t purpose, |
680 | GNUNET_CRYPTO_EccSignaturePurpose * | 678 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
681 | validate, | 679 | const unsigned char *sig, |
682 | const unsigned char *sig, | 680 | const struct GNUNET_IDENTITY_PublicKey *pub); |
683 | const struct | ||
684 | GNUNET_IDENTITY_PublicKey *pub); | ||
685 | 681 | ||
686 | 682 | ||
687 | /** | 683 | /** |
@@ -726,11 +722,11 @@ GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | |||
726 | * this size should be the same as @c len. | 722 | * this size should be the same as @c len. |
727 | */ | 723 | */ |
728 | ssize_t | 724 | ssize_t |
729 | GNUNET_IDENTITY_encrypt (const void *block, | 725 | GNUNET_IDENTITY_encrypt_old (const void *block, |
730 | size_t size, | 726 | size_t size, |
731 | const struct GNUNET_IDENTITY_PublicKey *pub, | 727 | const struct GNUNET_IDENTITY_PublicKey *pub, |
732 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | 728 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, |
733 | void *result); | 729 | void *result); |
734 | 730 | ||
735 | 731 | ||
736 | /** | 732 | /** |
@@ -748,13 +744,57 @@ GNUNET_IDENTITY_encrypt (const void *block, | |||
748 | * this size should be the same as @c size. | 744 | * this size should be the same as @c size. |
749 | */ | 745 | */ |
750 | ssize_t | 746 | ssize_t |
747 | GNUNET_IDENTITY_decrypt_old ( | ||
748 | const void *block, | ||
749 | size_t size, | ||
750 | const struct GNUNET_IDENTITY_PrivateKey *priv, | ||
751 | const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
752 | void *result); | ||
753 | |||
754 | #define GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \ | ||
755 | + sizeof (struct \ | ||
756 | GNUNET_CRYPTO_FoKemC)) | ||
757 | |||
758 | /** | ||
759 | * Encrypt a block with #GNUNET_IDENTITY_PublicKey and derives a | ||
760 | * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption | ||
761 | * using ecdh to derive a symmetric key. | ||
762 | * | ||
763 | * Note that the result buffer for the ciphertext must be the length of | ||
764 | * the message to encrypt plus #GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES. | ||
765 | * | ||
766 | * @param block the block to encrypt | ||
767 | * @param size the size of the @a block | ||
768 | * @param pub public key to encrypt for | ||
769 | * @param result the output parameter in which to store the encrypted result | ||
770 | * can be the same or overlap with @c block | ||
771 | * @returns GNUNET_OK on success. | ||
772 | */ | ||
773 | enum GNUNET_GenericReturnValue | ||
774 | GNUNET_IDENTITY_encrypt (const void *block, | ||
775 | size_t size, | ||
776 | const struct GNUNET_IDENTITY_PublicKey *pub, | ||
777 | void *result, | ||
778 | size_t result_size); | ||
779 | |||
780 | |||
781 | /** | ||
782 | * Decrypt a given block with #GNUNET_IDENTITY_PrivateKey and a given | ||
783 | * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. | ||
784 | * | ||
785 | * @param block the data to decrypt, encoded as returned by encrypt | ||
786 | * @param size the size of the @a block to decrypt | ||
787 | * @param priv private key to use for ecdh | ||
788 | * @param result address to store the result at | ||
789 | * can be the same or overlap with @c block | ||
790 | * @returns GNUNET_OK on success. | ||
791 | */ | ||
792 | enum GNUNET_GenericReturnValue | ||
751 | GNUNET_IDENTITY_decrypt (const void *block, | 793 | GNUNET_IDENTITY_decrypt (const void *block, |
752 | size_t size, | 794 | size_t size, |
753 | const struct | 795 | const struct GNUNET_IDENTITY_PrivateKey *priv, |
754 | GNUNET_IDENTITY_PrivateKey *priv, | 796 | void *result, |
755 | const struct | 797 | size_t result_size); |
756 | GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
757 | void *result); | ||
758 | 798 | ||
759 | 799 | ||
760 | /** | 800 | /** |
@@ -766,8 +806,8 @@ GNUNET_IDENTITY_decrypt (const void *block, | |||
766 | * @return the string representation of the key, or NULL on error. | 806 | * @return the string representation of the key, or NULL on error. |
767 | */ | 807 | */ |
768 | char * | 808 | char * |
769 | GNUNET_IDENTITY_public_key_to_string (const struct | 809 | GNUNET_IDENTITY_public_key_to_string ( |
770 | GNUNET_IDENTITY_PublicKey *key); | 810 | const struct GNUNET_IDENTITY_PublicKey *key); |
771 | 811 | ||
772 | 812 | ||
773 | /** | 813 | /** |
@@ -779,8 +819,8 @@ GNUNET_IDENTITY_public_key_to_string (const struct | |||
779 | * @return the string representation of the key, or NULL on error. | 819 | * @return the string representation of the key, or NULL on error. |
780 | */ | 820 | */ |
781 | char * | 821 | char * |
782 | GNUNET_IDENTITY_private_key_to_string (const struct | 822 | GNUNET_IDENTITY_private_key_to_string ( |
783 | GNUNET_IDENTITY_PrivateKey *key); | 823 | const struct GNUNET_IDENTITY_PrivateKey *key); |
784 | 824 | ||
785 | 825 | ||
786 | /** | 826 | /** |
@@ -897,11 +937,11 @@ struct GNUNET_IDENTITY_EgoSuffixLookup; | |||
897 | * @return handle to abort the operation | 937 | * @return handle to abort the operation |
898 | */ | 938 | */ |
899 | struct GNUNET_IDENTITY_EgoSuffixLookup * | 939 | struct GNUNET_IDENTITY_EgoSuffixLookup * |
900 | GNUNET_IDENTITY_ego_lookup_by_suffix (const struct | 940 | GNUNET_IDENTITY_ego_lookup_by_suffix ( |
901 | GNUNET_CONFIGURATION_Handle *cfg, | 941 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
902 | const char *suffix, | 942 | const char *suffix, |
903 | GNUNET_IDENTITY_EgoSuffixCallback cb, | 943 | GNUNET_IDENTITY_EgoSuffixCallback cb, |
904 | void *cb_cls); | 944 | void *cb_cls); |
905 | 945 | ||
906 | 946 | ||
907 | /** | 947 | /** |
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index d798c975a..5f4207d2f 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2022 GNUnet e.V. | 3 | Copyright (C) 2020--2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -50,9 +50,9 @@ extern "C" { | |||
50 | /** | 50 | /** |
51 | * Version number of GNUnet Messenger API. | 51 | * Version number of GNUnet Messenger API. |
52 | * | 52 | * |
53 | * Current version of the Messenger: 0.1 | 53 | * Current version of the Messenger: 0.2 |
54 | */ | 54 | */ |
55 | #define GNUNET_MESSENGER_VERSION 0x00000001 | 55 | #define GNUNET_MESSENGER_VERSION 0x00000002 |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Identifier of GNUnet MESSENGER Service. | 58 | * Identifier of GNUnet MESSENGER Service. |
@@ -462,10 +462,6 @@ struct GNUNET_MESSENGER_MessageFile | |||
462 | */ | 462 | */ |
463 | struct GNUNET_MESSENGER_MessagePrivate | 463 | struct GNUNET_MESSENGER_MessagePrivate |
464 | { | 464 | { |
465 | /** | ||
466 | * The ECDH key to decrypt the message. | ||
467 | */ | ||
468 | struct GNUNET_CRYPTO_EcdhePublicKey key; | ||
469 | 465 | ||
470 | /** | 466 | /** |
471 | * The length of the encrypted message. | 467 | * The length of the encrypted message. |
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index f424c49c2..3eca71f0f 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -18,6 +18,7 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "gnunet_common.h" | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 22 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
22 | #error "Only <gnunet_util_lib.h> can be included directly." | 23 | #error "Only <gnunet_util_lib.h> can be included directly." |
23 | #endif | 24 | #endif |
@@ -691,7 +692,7 @@ struct GNUNET_MQ_MessageHandler | |||
691 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, | 692 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, |
692 | * #GNUNET_SYSERR if message was rejected by check function | 693 | * #GNUNET_SYSERR if message was rejected by check function |
693 | */ | 694 | */ |
694 | int | 695 | enum GNUNET_GenericReturnValue |
695 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, | 696 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, |
696 | const struct GNUNET_MessageHeader *mh); | 697 | const struct GNUNET_MessageHeader *mh); |
697 | 698 | ||
diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h index af2dd3353..5b848bbd6 100644 --- a/src/include/gnunet_mst_lib.h +++ b/src/include/gnunet_mst_lib.h | |||
@@ -127,7 +127,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
127 | * #GNUNET_NO if one_shot was set and we have another message ready | 127 | * #GNUNET_NO if one_shot was set and we have another message ready |
128 | * #GNUNET_SYSERR if the data stream is corrupt | 128 | * #GNUNET_SYSERR if the data stream is corrupt |
129 | */ | 129 | */ |
130 | int | 130 | enum GNUNET_GenericReturnValue |
131 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | 131 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, |
132 | struct GNUNET_NETWORK_Handle *sock, | 132 | struct GNUNET_NETWORK_Handle *sock, |
133 | int purge, | 133 | int purge, |
@@ -145,7 +145,7 @@ GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | |||
145 | * #GNUNET_NO if one_shot was set and we have another message ready | 145 | * #GNUNET_NO if one_shot was set and we have another message ready |
146 | * #GNUNET_SYSERR if the data stream is corrupt | 146 | * #GNUNET_SYSERR if the data stream is corrupt |
147 | */ | 147 | */ |
148 | int | 148 | enum GNUNET_GenericReturnValue |
149 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, | 149 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, |
150 | int one_shot); | 150 | int one_shot); |
151 | 151 | ||
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h deleted file mode 100644 index 283b2f7e6..000000000 --- a/src/include/gnunet_my_lib.h +++ /dev/null | |||
@@ -1,511 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @addtogroup lib_extra | ||
22 | * @{ | ||
23 | * | ||
24 | * @author Christian Grothoff | ||
25 | * @author Christophe Genevey | ||
26 | * @author Martin Schanzenbach | ||
27 | * | ||
28 | * @file | ||
29 | * Helper library to access a MySQL database | ||
30 | * | ||
31 | * @defgroup mysql MySQL library | ||
32 | * Helper library to access a MySQL database. | ||
33 | * @{ | ||
34 | */ | ||
35 | #ifndef GNUNET_MY_LIB_H | ||
36 | #define GNUNET_MY_LIB_H | ||
37 | |||
38 | |||
39 | #include "gnunet_util_lib.h" | ||
40 | #include "gnunet_mysql_lib.h" | ||
41 | #include <mysql/mysql.h> | ||
42 | |||
43 | #ifndef MYSQL_BOOL | ||
44 | #error "You need to define MYSQL_BOOL. See (or include) gnunet_mysql_compat.h" | ||
45 | #endif | ||
46 | |||
47 | #ifdef __cplusplus | ||
48 | extern "C" | ||
49 | { | ||
50 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
51 | } | ||
52 | #endif | ||
53 | #endif | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Information we pass to #GNUNET_MY_exec_prepared() to | ||
58 | * initialize the arguments of the prepared statement. | ||
59 | */ | ||
60 | struct GNUNET_MY_QueryParam; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Function called to convert input argument into SQL parameters. | ||
65 | * | ||
66 | * @param cls closure | ||
67 | * @param pq data about the query | ||
68 | * @param qbind array of parameters to initialize | ||
69 | * @return -1 on error | ||
70 | */ | ||
71 | typedef int | ||
72 | (*GNUNET_MY_QueryConverter)(void *cls, | ||
73 | const struct GNUNET_MY_QueryParam *qp, | ||
74 | MYSQL_BIND *qbind); | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Function called to cleanup result data. | ||
79 | * | ||
80 | * @param cls closure | ||
81 | * @param rs spec to clean up | ||
82 | */ | ||
83 | typedef void | ||
84 | (*GNUNET_MY_QueryCleanup)(void *cls, | ||
85 | MYSQL_BIND *qbind); | ||
86 | /** | ||
87 | * Information we pass to #GNUNET_MY_exec_prepared() to | ||
88 | * initialize the arguments of the prepared statement. | ||
89 | */ | ||
90 | |||
91 | |||
92 | struct GNUNET_MY_QueryParam | ||
93 | { | ||
94 | /** | ||
95 | * Function to call for the type conversion. | ||
96 | */ | ||
97 | GNUNET_MY_QueryConverter conv; | ||
98 | |||
99 | /** | ||
100 | * Function to call for cleaning up the query. Can be NULL. | ||
101 | */ | ||
102 | GNUNET_MY_QueryCleanup cleaner; | ||
103 | |||
104 | /** | ||
105 | * Closure for @e conv. | ||
106 | */ | ||
107 | void *conv_cls; | ||
108 | |||
109 | /** | ||
110 | * Number of arguments the @a conv converter expects to initialize. | ||
111 | */ | ||
112 | unsigned int num_params; | ||
113 | |||
114 | /** | ||
115 | * Information to pass to @e conv. | ||
116 | */ | ||
117 | const void *data; | ||
118 | |||
119 | /** | ||
120 | * Information to pass to @e conv. Size of @a data. | ||
121 | */ | ||
122 | unsigned long data_len; | ||
123 | }; | ||
124 | |||
125 | /** | ||
126 | * End of query parameter specification. | ||
127 | * | ||
128 | * @return array last entry for the result specification to use | ||
129 | */ | ||
130 | #define GNUNET_MY_query_param_end { NULL, NULL, NULL, 0, NULL, 0 } | ||
131 | |||
132 | |||
133 | /** | ||
134 | * Generate query parameter for a buffer @a ptr of | ||
135 | * @a ptr_size bytes.FG | ||
136 | * | ||
137 | * @param ptr pointer to the query parameter to pass | ||
138 | * @param ptr_size number of bytes in @a ptr | ||
139 | */ | ||
140 | struct GNUNET_MY_QueryParam | ||
141 | GNUNET_MY_query_param_fixed_size (const void *ptr, | ||
142 | size_t ptr_size); | ||
143 | |||
144 | |||
145 | /** | ||
146 | * Run a prepared SELECT statement. | ||
147 | * | ||
148 | * @param mc mysql context | ||
149 | * @param sh handle to SELECT statement | ||
150 | * @param params parameters to the statement | ||
151 | * @return TBD | ||
152 | */ | ||
153 | int | ||
154 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | ||
155 | struct GNUNET_MYSQL_StatementHandle *sh, | ||
156 | struct GNUNET_MY_QueryParam *params); | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Information we pass to #GNUNET_MY_extract_result() to | ||
161 | * initialize the arguments of the prepared statement. | ||
162 | */ | ||
163 | struct GNUNET_MY_ResultParam; | ||
164 | |||
165 | /** | ||
166 | * Information we pass to #GNUNET_MY_extract_result() to | ||
167 | * initialize the arguments of the prepared statement. | ||
168 | */ | ||
169 | struct GNUNET_MY_ResultSpec; | ||
170 | |||
171 | /** | ||
172 | * Function called to convert input argument into SQL parameters. | ||
173 | * | ||
174 | * @param cls closure | ||
175 | * @param[in,out] rs | ||
176 | * @param stmt the mysql statement that is being run | ||
177 | * @param column the column that is being processed | ||
178 | * @param[out] results | ||
179 | * @return -1 on error | ||
180 | */ | ||
181 | typedef int | ||
182 | (*GNUNET_MY_ResultConverter)(void *cls, | ||
183 | struct GNUNET_MY_ResultSpec *rs, | ||
184 | MYSQL_STMT *stmt, | ||
185 | unsigned int column, | ||
186 | MYSQL_BIND *results); | ||
187 | |||
188 | /** | ||
189 | * Function called to cleanup result data. | ||
190 | * | ||
191 | * @param cls closure | ||
192 | * @param rs spec to clean up | ||
193 | */ | ||
194 | typedef void | ||
195 | (*GNUNET_MY_ResultCleanup)(void *cls, | ||
196 | struct GNUNET_MY_ResultSpec *rs); | ||
197 | |||
198 | |||
199 | /** | ||
200 | * Information we pass to #GNUNET_MY_extract_result() to | ||
201 | * initialize the arguments of the prepared statement. | ||
202 | */ | ||
203 | struct GNUNET_MY_ResultSpec | ||
204 | { | ||
205 | /** | ||
206 | * Function to call to initialize the MYSQL_BIND array. | ||
207 | */ | ||
208 | GNUNET_MY_ResultConverter pre_conv; | ||
209 | |||
210 | /** | ||
211 | * Function to call for converting the result. Can be NULL. | ||
212 | */ | ||
213 | GNUNET_MY_ResultConverter post_conv; | ||
214 | |||
215 | /** | ||
216 | * Function to call for cleaning up the result. Can be NULL. | ||
217 | */ | ||
218 | GNUNET_MY_ResultCleanup cleaner; | ||
219 | |||
220 | /** | ||
221 | * Closure for @e conv. | ||
222 | */ | ||
223 | void *conv_cls; | ||
224 | |||
225 | /** | ||
226 | * Destination for the data. | ||
227 | */ | ||
228 | void *dst; | ||
229 | |||
230 | /** | ||
231 | * Allowed size for the data, 0 for variable-size | ||
232 | * (in this case, the type of @e dst is a `void **` | ||
233 | * and we need to allocate a buffer of the right size). | ||
234 | */ | ||
235 | size_t dst_size; | ||
236 | |||
237 | /** | ||
238 | * Where to store actual size of the result. | ||
239 | */ | ||
240 | size_t *result_size; | ||
241 | |||
242 | /** | ||
243 | * How many fields does this result specification occupy | ||
244 | * in the result returned by MySQL. | ||
245 | */ | ||
246 | unsigned int num_fields; | ||
247 | |||
248 | /** | ||
249 | * Location where we temporarily store the output buffer | ||
250 | * length from MySQL. Internal to libgnunetmy. | ||
251 | */ | ||
252 | unsigned long mysql_bind_output_length; | ||
253 | |||
254 | /** | ||
255 | * Memory for MySQL to notify us about NULL values. | ||
256 | */ | ||
257 | MYSQL_BOOL is_null; | ||
258 | }; | ||
259 | |||
260 | |||
261 | /** | ||
262 | * End of result speceter specification. | ||
263 | * | ||
264 | * @return array last entry for the result specification to use | ||
265 | */ | ||
266 | #define GNUNET_MY_result_spec_end { NULL, NULL, NULL, 0, NULL, 0, 0 } | ||
267 | |||
268 | |||
269 | /** | ||
270 | * Obtain fixed size result of @a ptr_size bytes from | ||
271 | * MySQL, store in already allocated buffer at @a ptr. | ||
272 | * | ||
273 | * @spec ptr where to write the result | ||
274 | * @param ptr_size number of bytes available at @a ptr | ||
275 | */ | ||
276 | struct GNUNET_MY_ResultSpec | ||
277 | GNUNET_MY_result_spec_fixed_size (void *ptr, | ||
278 | size_t ptr_size); | ||
279 | |||
280 | /** | ||
281 | * Generate query parameter for a string | ||
282 | * | ||
283 | * @param ptr pointer to the string query parameter to pass | ||
284 | */ | ||
285 | struct GNUNET_MY_QueryParam | ||
286 | GNUNET_MY_query_param_string (const char *ptr); | ||
287 | |||
288 | /** | ||
289 | * Generate fixed-size query parameter with size determined | ||
290 | * by variable type. | ||
291 | * | ||
292 | * @param x pointer to the query parameter to pass | ||
293 | */ | ||
294 | #define GNUNET_MY_query_param_auto_from_type( \ | ||
295 | x) GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x))) | ||
296 | |||
297 | /** | ||
298 | * Generate query parameter for an RSA public key. The | ||
299 | * database must contain a BLOB type in the respective position. | ||
300 | * | ||
301 | * @param x the query parameter to pass | ||
302 | * @return array entry for the query parameters to use | ||
303 | */ | ||
304 | struct GNUNET_MY_QueryParam | ||
305 | GNUNET_MY_query_param_rsa_public_key (const struct | ||
306 | GNUNET_CRYPTO_RsaPublicKey *x); | ||
307 | |||
308 | /** | ||
309 | * Generate query parameter for an RSA signature. The | ||
310 | * database must contain a BLOB type in the respective position | ||
311 | * | ||
312 | *@param x the query parameter to pass | ||
313 | *@return array entry for the query parameters to use | ||
314 | */ | ||
315 | struct GNUNET_MY_QueryParam | ||
316 | GNUNET_MY_query_param_rsa_signature (const struct | ||
317 | GNUNET_CRYPTO_RsaSignature *x); | ||
318 | |||
319 | /** | ||
320 | * Generate query parameter for an absolute time value. | ||
321 | * The database must store a 64-bit integer. | ||
322 | * | ||
323 | *@param x pointer to the query parameter to pass | ||
324 | *@return array entry for the query parameters to use | ||
325 | */ | ||
326 | struct GNUNET_MY_QueryParam | ||
327 | GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | ||
328 | |||
329 | |||
330 | /** | ||
331 | * Generate query parameter for an absolute time value. | ||
332 | * The database must store a 64-bit integer. | ||
333 | * | ||
334 | *@param x pointer to the query parameter to pass | ||
335 | */ | ||
336 | struct GNUNET_MY_QueryParam | ||
337 | GNUNET_MY_query_param_absolute_time_nbo (const struct | ||
338 | GNUNET_TIME_AbsoluteNBO *x); | ||
339 | |||
340 | /** | ||
341 | * Generate query parameter for an uint16_t in host byte order. | ||
342 | * | ||
343 | * @param x pointer to the query parameter to pass | ||
344 | */ | ||
345 | struct GNUNET_MY_QueryParam | ||
346 | GNUNET_MY_query_param_uint16 (const uint16_t *x); | ||
347 | |||
348 | /** | ||
349 | * Generate query parameter for an uint32_t in host byte order | ||
350 | * | ||
351 | * @param x pointer to the query parameter to pass | ||
352 | */ | ||
353 | struct GNUNET_MY_QueryParam | ||
354 | GNUNET_MY_query_param_uint32 (const uint32_t *x); | ||
355 | |||
356 | /** | ||
357 | * Generate query parameter for an uint64_t in host byte order | ||
358 | * | ||
359 | * @param x pointer to the query parameter to pass | ||
360 | */ | ||
361 | struct GNUNET_MY_QueryParam | ||
362 | GNUNET_MY_query_param_uint64 (const uint64_t *x); | ||
363 | |||
364 | /** | ||
365 | * We expect a fixed-size result, with size determined by the type of `* dst` | ||
366 | * | ||
367 | * @spec name name of the field in the table | ||
368 | * @spec dst point to where to store the result, type fits expected result size | ||
369 | * @return array entry for the result specification to use | ||
370 | */ | ||
371 | #define GNUNET_MY_result_spec_auto_from_type( \ | ||
372 | dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst))) | ||
373 | |||
374 | |||
375 | /** | ||
376 | * Variable-size result expected | ||
377 | * | ||
378 | * @param[out] dst where to store the result, allocated | ||
379 | * @param[out] ptr_size where to store the size of @a dst | ||
380 | * @return array entry for the result specification to use | ||
381 | */ | ||
382 | struct GNUNET_MY_ResultSpec | ||
383 | GNUNET_MY_result_spec_variable_size (void **dst, | ||
384 | size_t *ptr_size); | ||
385 | |||
386 | /** | ||
387 | * RSA public key expected | ||
388 | * | ||
389 | * @param name name of the field in the table | ||
390 | * @param[out] rsa where to store the result | ||
391 | * @return array entry for the result specification to use | ||
392 | */ | ||
393 | struct GNUNET_MY_ResultSpec | ||
394 | GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa); | ||
395 | |||
396 | |||
397 | /** | ||
398 | * RSA signature expected. | ||
399 | * | ||
400 | * @param[out] sig where to store the result; | ||
401 | * @return array entry for the result specification to use | ||
402 | */ | ||
403 | struct GNUNET_MY_ResultSpec | ||
404 | GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig); | ||
405 | |||
406 | /** | ||
407 | * 0- terminated string exprected. | ||
408 | * | ||
409 | * @param[out] dst where to store the result, allocated | ||
410 | * @return array entry for the result specification to use | ||
411 | */ | ||
412 | struct GNUNET_MY_ResultSpec | ||
413 | GNUNET_MY_result_spec_string (char **dst); | ||
414 | |||
415 | /** | ||
416 | * Absolute time expected | ||
417 | * | ||
418 | * @param name name of the field in the table | ||
419 | * @param[out] at where to store the result | ||
420 | * @return array entry for the result specification to use | ||
421 | */ | ||
422 | struct GNUNET_MY_ResultSpec | ||
423 | GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at); | ||
424 | |||
425 | /** | ||
426 | * Absolute time in network byte order expected | ||
427 | * | ||
428 | * @param[out] at where to store the result | ||
429 | * @return array entry for the result specification to use | ||
430 | */ | ||
431 | struct GNUNET_MY_ResultSpec | ||
432 | GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at); | ||
433 | |||
434 | /** | ||
435 | * uint16_t expected | ||
436 | * | ||
437 | * @param[out] u16 where to store the result | ||
438 | * @return array entry for the result specification to use | ||
439 | */ | ||
440 | struct GNUNET_MY_ResultSpec | ||
441 | GNUNET_MY_result_spec_uint16 (uint16_t *u16); | ||
442 | |||
443 | /** | ||
444 | * uint32_t expected | ||
445 | * | ||
446 | * @param[out] u32 where to store the result | ||
447 | * @return array entry for the result specification to use | ||
448 | */ | ||
449 | struct GNUNET_MY_ResultSpec | ||
450 | GNUNET_MY_result_spec_uint32 (uint32_t *u32); | ||
451 | |||
452 | /** | ||
453 | * uint64_t expected. | ||
454 | * | ||
455 | * @param[out] u64 where to store the result | ||
456 | * @return array entry for the result specification to use | ||
457 | */ | ||
458 | struct GNUNET_MY_ResultSpec | ||
459 | GNUNET_MY_result_spec_uint64 (uint64_t *u64); | ||
460 | |||
461 | |||
462 | /** | ||
463 | * Extract results from a query result according to the given | ||
464 | * specification. Always fetches the next row. | ||
465 | * | ||
466 | * @param sh statement that returned results | ||
467 | * @param rs specification to extract for | ||
468 | * @return | ||
469 | * #GNUNET_YES if all results could be extracted | ||
470 | * #GNUNET_NO if there is no more data in the result set | ||
471 | * #GNUNET_SYSERR if a result was invalid | ||
472 | */ | ||
473 | int | ||
474 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | ||
475 | struct GNUNET_MY_ResultSpec *specs); | ||
476 | |||
477 | |||
478 | /** | ||
479 | * Free all memory that was allocated in @a qp during | ||
480 | * #GNUNET_MY_exect_prepared(). | ||
481 | * | ||
482 | * @param qp query specification to clean up | ||
483 | * @param qbind mysql query | ||
484 | */ | ||
485 | void | ||
486 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | ||
487 | MYSQL_BIND *qbind); | ||
488 | |||
489 | |||
490 | /** | ||
491 | * Free all memory that was allocated in @a rs during | ||
492 | * #GNUNET_MY_extract_result(). | ||
493 | * | ||
494 | * @param rs reult specification to clean up | ||
495 | */ | ||
496 | void | ||
497 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs); | ||
498 | |||
499 | |||
500 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
501 | { | ||
502 | #endif | ||
503 | #ifdef __cplusplus | ||
504 | } | ||
505 | #endif | ||
506 | |||
507 | #endif | ||
508 | |||
509 | /** @} */ /* end of group */ | ||
510 | |||
511 | /** @} */ /* end of group addition to lib_extra */ | ||
diff --git a/src/include/gnunet_mysql_compat.h.in b/src/include/gnunet_mysql_compat.h.in deleted file mode 100644 index 6218386aa..000000000 --- a/src/include/gnunet_mysql_compat.h.in +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Martin Schanzenbach | ||
22 | * | ||
23 | * @file | ||
24 | * MySQL/MariaDB compatibility insanity helper header | ||
25 | * Note: gnunet_mysql_compat.h is AUTOGENERATED from gnunet_mysql_compat.h.in | ||
26 | * Please do not modify or commit gnunet_mysql_compat.h | ||
27 | * | ||
28 | * @defgroup mysql MySQL library | ||
29 | * Helper library to access a MySQL database. | ||
30 | * @{ | ||
31 | */ | ||
32 | #ifndef GNUNET_MYSQL_COMPAT_H | ||
33 | #define GNUNET_MYSQL_COMPAT_H | ||
34 | |||
35 | |||
36 | #include <mysql/mysql.h> | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" | ||
40 | { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | #define MYSQL_BOOL @mysql_bool@ | ||
47 | |||
48 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
49 | { | ||
50 | #endif | ||
51 | #ifdef __cplusplus | ||
52 | } | ||
53 | #endif | ||
54 | |||
55 | #endif | ||
56 | |||
57 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h deleted file mode 100644 index 52be3ff11..000000000 --- a/src/include/gnunet_mysql_lib.h +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * Helper library to access a MySQL database | ||
25 | * | ||
26 | * @defgroup mysql MySQL library | ||
27 | * Helper library to access a MySQL database. | ||
28 | * @{ | ||
29 | */ | ||
30 | #ifndef GNUNET_MYSQL_LIB_H | ||
31 | #define GNUNET_MYSQL_LIB_H | ||
32 | |||
33 | |||
34 | #include "gnunet_util_lib.h" | ||
35 | #include <mysql/mysql.h> | ||
36 | |||
37 | #ifdef __cplusplus | ||
38 | extern "C" | ||
39 | { | ||
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | ||
42 | #endif | ||
43 | #endif | ||
44 | |||
45 | /** | ||
46 | * Mysql context. | ||
47 | */ | ||
48 | struct GNUNET_MYSQL_Context; | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Handle for a prepared statement. | ||
53 | */ | ||
54 | struct GNUNET_MYSQL_StatementHandle; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Type of a callback that will be called for each | ||
59 | * data set returned from MySQL. | ||
60 | * | ||
61 | * @param cls user-defined argument | ||
62 | * @param num_values number of elements in values | ||
63 | * @param values values returned by MySQL | ||
64 | * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort | ||
65 | */ | ||
66 | typedef int | ||
67 | (*GNUNET_MYSQL_DataProcessor) (void *cls, | ||
68 | unsigned int num_values, | ||
69 | MYSQL_BIND *values); | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Create a mysql context. | ||
74 | * | ||
75 | * @param cfg configuration | ||
76 | * @param section configuration section to use to get MySQL configuration options | ||
77 | * @return the mysql context | ||
78 | */ | ||
79 | struct GNUNET_MYSQL_Context * | ||
80 | GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
81 | const char *section); | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Destroy a mysql context. Also frees all associated prepared statements. | ||
86 | * | ||
87 | * @param mc context to destroy | ||
88 | */ | ||
89 | void | ||
90 | GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc); | ||
91 | |||
92 | |||
93 | /** | ||
94 | * Close database connection and all prepared statements (we got a DB | ||
95 | * error). The connection will automatically be re-opened and | ||
96 | * statements will be re-prepared if they are needed again later. | ||
97 | * | ||
98 | * @param mc mysql context | ||
99 | */ | ||
100 | void | ||
101 | GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc); | ||
102 | |||
103 | |||
104 | /** | ||
105 | * Get internal handle for a prepared statement. This function should rarely | ||
106 | * be used, and if, with caution! On failures during the interaction with | ||
107 | * the handle, you must call #GNUNET_MYSQL_statements_invalidate()! | ||
108 | * | ||
109 | * @param sh prepared statement to introspect | ||
110 | * @return MySQL statement handle, NULL on error | ||
111 | */ | ||
112 | MYSQL_STMT * | ||
113 | GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh); | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Prepare a statement. Prepared statements are automatically discarded | ||
118 | * when the MySQL context is destroyed. | ||
119 | * | ||
120 | * @param mc mysql context | ||
121 | * @param query query text | ||
122 | * @return prepared statement, NULL on error | ||
123 | */ | ||
124 | struct GNUNET_MYSQL_StatementHandle * | ||
125 | GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc, | ||
126 | const char *query); | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Run a SQL statement. | ||
131 | * | ||
132 | * @param mc mysql context | ||
133 | * @param sql SQL statement to run | ||
134 | * @return #GNUNET_OK on success | ||
135 | * #GNUNET_SYSERR if there was a problem | ||
136 | */ | ||
137 | int | ||
138 | GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, | ||
139 | const char *sql); | ||
140 | |||
141 | |||
142 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
143 | { | ||
144 | #endif | ||
145 | #ifdef __cplusplus | ||
146 | } | ||
147 | #endif | ||
148 | |||
149 | #endif | ||
150 | |||
151 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 8d71d7764..764b7b29d 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h | |||
@@ -39,6 +39,7 @@ | |||
39 | #ifndef GNUNET_NETWORK_LIB_H | 39 | #ifndef GNUNET_NETWORK_LIB_H |
40 | #define GNUNET_NETWORK_LIB_H | 40 | #define GNUNET_NETWORK_LIB_H |
41 | 41 | ||
42 | #include "gnunet_common.h" | ||
42 | #ifdef __cplusplus | 43 | #ifdef __cplusplus |
43 | extern "C" | 44 | extern "C" |
44 | { | 45 | { |
@@ -157,7 +158,7 @@ GNUNET_NETWORK_socket_box_native (int fd); | |||
157 | * @param doBlock blocking mode | 158 | * @param doBlock blocking mode |
158 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 159 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
159 | */ | 160 | */ |
160 | int | 161 | enum GNUNET_GenericReturnValue |
161 | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, | 162 | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, |
162 | int doBlock); | 163 | int doBlock); |
163 | 164 | ||
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h index a3135e2cf..2a9cde47f 100644 --- a/src/include/gnunet_plugin_lib.h +++ b/src/include/gnunet_plugin_lib.h | |||
@@ -70,7 +70,7 @@ typedef void * | |||
70 | * @param library_name name of the plugin to test if it is installed | 70 | * @param library_name name of the plugin to test if it is installed |
71 | * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not | 71 | * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not |
72 | */ | 72 | */ |
73 | int | 73 | enum GNUNET_GenericReturnValue |
74 | GNUNET_PLUGIN_test (const char *library_name); | 74 | GNUNET_PLUGIN_test (const char *library_name); |
75 | 75 | ||
76 | 76 | ||
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 78eaf0d49..15af66b5d 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -28,16 +28,17 @@ | |||
28 | 28 | ||
29 | #include <libpq-fe.h> | 29 | #include <libpq-fe.h> |
30 | #include <stdint.h> | 30 | #include <stdint.h> |
31 | #include "gnunet_common.h" | ||
31 | #include "gnunet_time_lib.h" | 32 | #include "gnunet_time_lib.h" |
32 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_db_lib.h" | 34 | #include "gnunet_db_lib.h" |
35 | #include "postgres_ext.h" | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Postgres context. | 38 | * Postgres context. |
37 | */ | 39 | */ |
38 | struct GNUNET_PQ_Context; | 40 | struct GNUNET_PQ_Context; |
39 | 41 | ||
40 | |||
41 | /* ************************* pq_query_helper.c functions ************************ */ | 42 | /* ************************* pq_query_helper.c functions ************************ */ |
42 | 43 | ||
43 | 44 | ||
@@ -181,21 +182,37 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
181 | struct GNUNET_PQ_QueryParam | 182 | struct GNUNET_PQ_QueryParam |
182 | GNUNET_PQ_query_param_bool (bool b); | 183 | GNUNET_PQ_query_param_bool (bool b); |
183 | 184 | ||
185 | /** | ||
186 | * Returns the oid for a given datatype by name. | ||
187 | * | ||
188 | * @param db The db-connection | ||
189 | * @param name The name of the datatype | ||
190 | * @param[out] oid The OID of the datatype. | ||
191 | * @return GNUNET_OK when the datatype was found, GNUNET_SYSERR otherwise | ||
192 | */ | ||
193 | enum GNUNET_GenericReturnValue | ||
194 | GNUNET_PQ_get_oid_by_name ( | ||
195 | struct GNUNET_PQ_Context *db, | ||
196 | const char *name, | ||
197 | Oid *oid); | ||
198 | |||
184 | 199 | ||
185 | /** | 200 | /** |
186 | * Array types (in Postgres) that are supported in GNUnet. | 201 | * The header for a postgresql array in binary format. note that this a |
202 | * simplified special case of the general structure (which contains pointers), | ||
203 | * as we only support one-dimensional arrays. | ||
204 | * | ||
205 | * Note that all values must be in network-byte-order. | ||
187 | */ | 206 | */ |
188 | enum GNUNET_PQ_DataTypes | 207 | struct GNUNET_PQ_ArrayHeader_P |
189 | { | 208 | { |
190 | GNUNET_PQ_DATATYPE_UNKNOWN, /* Unsupported type */ | 209 | uint32_t ndim; /* number of dimensions. we only support ndim = 1 */ |
191 | GNUNET_PQ_DATATYPE_BOOL, | 210 | uint32_t has_null; |
192 | GNUNET_PQ_DATATYPE_INT2, | 211 | uint32_t oid; /* oid of the elements */ |
193 | GNUNET_PQ_DATATYPE_INT4, | 212 | uint32_t dim; /* size of the array */ |
194 | GNUNET_PQ_DATATYPE_INT8, | 213 | uint32_t lbound; /* index value of first element in the db (default: 1). */ |
195 | GNUNET_PQ_DATATYPE_BYTEA, | 214 | } __attribute__((packed)); |
196 | GNUNET_PQ_DATATYPE_VARCHAR, | 215 | |
197 | GNUNET_PQ_DATATYPE_MAX, /* Must be last */ | ||
198 | }; | ||
199 | 216 | ||
200 | /** | 217 | /** |
201 | * Generate query parameter for an array of bool in host byte order. | 218 | * Generate query parameter for an array of bool in host byte order. |
@@ -209,7 +226,7 @@ struct GNUNET_PQ_QueryParam | |||
209 | GNUNET_PQ_query_param_array_bool ( | 226 | GNUNET_PQ_query_param_array_bool ( |
210 | unsigned int num, | 227 | unsigned int num, |
211 | const bool *elements, | 228 | const bool *elements, |
212 | const struct GNUNET_PQ_Context *db); | 229 | struct GNUNET_PQ_Context *db); |
213 | 230 | ||
214 | /** | 231 | /** |
215 | * Generate query parameter for an array of uint16_t in host byte order. | 232 | * Generate query parameter for an array of uint16_t in host byte order. |
@@ -224,7 +241,7 @@ struct GNUNET_PQ_QueryParam | |||
224 | GNUNET_PQ_query_param_array_uint16 ( | 241 | GNUNET_PQ_query_param_array_uint16 ( |
225 | unsigned int num, | 242 | unsigned int num, |
226 | const uint16_t *elements, | 243 | const uint16_t *elements, |
227 | const struct GNUNET_PQ_Context *db); | 244 | struct GNUNET_PQ_Context *db); |
228 | 245 | ||
229 | /** | 246 | /** |
230 | * Generate query parameter for an array of uint32_t in host byte order. | 247 | * Generate query parameter for an array of uint32_t in host byte order. |
@@ -239,7 +256,7 @@ struct GNUNET_PQ_QueryParam | |||
239 | GNUNET_PQ_query_param_array_uint32 ( | 256 | GNUNET_PQ_query_param_array_uint32 ( |
240 | unsigned int num, | 257 | unsigned int num, |
241 | const uint32_t *elements, | 258 | const uint32_t *elements, |
242 | const struct GNUNET_PQ_Context *db); | 259 | struct GNUNET_PQ_Context *db); |
243 | 260 | ||
244 | /** | 261 | /** |
245 | * Generate query parameter for an array of uint64 in host byte order. | 262 | * Generate query parameter for an array of uint64 in host byte order. |
@@ -254,7 +271,7 @@ struct GNUNET_PQ_QueryParam | |||
254 | GNUNET_PQ_query_param_array_uint64 ( | 271 | GNUNET_PQ_query_param_array_uint64 ( |
255 | unsigned int num, | 272 | unsigned int num, |
256 | const uint64_t *elements, | 273 | const uint64_t *elements, |
257 | const struct GNUNET_PQ_Context *db); | 274 | struct GNUNET_PQ_Context *db); |
258 | 275 | ||
259 | /** | 276 | /** |
260 | * Generate query parameter for an array of buffers @a elements, each of | 277 | * Generate query parameter for an array of buffers @a elements, each of |
@@ -271,7 +288,7 @@ GNUNET_PQ_query_param_array_bytes ( | |||
271 | unsigned int num, | 288 | unsigned int num, |
272 | const void *elements, | 289 | const void *elements, |
273 | const size_t *sizes, | 290 | const size_t *sizes, |
274 | const struct GNUNET_PQ_Context *db); | 291 | struct GNUNET_PQ_Context *db); |
275 | 292 | ||
276 | /** | 293 | /** |
277 | * Generate query parameter for an array of buffers @a elements, | 294 | * Generate query parameter for an array of buffers @a elements, |
@@ -288,7 +305,7 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
288 | unsigned int num, | 305 | unsigned int num, |
289 | const void *elements, | 306 | const void *elements, |
290 | size_t same_size, | 307 | size_t same_size, |
291 | const struct GNUNET_PQ_Context *db); | 308 | struct GNUNET_PQ_Context *db); |
292 | 309 | ||
293 | /** | 310 | /** |
294 | * Generate array of equal-sized query parameter with size determined | 311 | * Generate array of equal-sized query parameter with size determined |
@@ -318,9 +335,9 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
318 | struct GNUNET_PQ_QueryParam | 335 | struct GNUNET_PQ_QueryParam |
319 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | 336 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( |
320 | unsigned int num, | 337 | unsigned int num, |
321 | const void *elements[], | 338 | const void *elements[static num], |
322 | size_t same_size, | 339 | size_t same_size, |
323 | const struct GNUNET_PQ_Context *db); | 340 | struct GNUNET_PQ_Context *db); |
324 | 341 | ||
325 | /** | 342 | /** |
326 | * Generate array of equal-sized query parameter with size determined by | 343 | * Generate array of equal-sized query parameter with size determined by |
@@ -334,7 +351,7 @@ GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | |||
334 | */ | 351 | */ |
335 | #define GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) \ | 352 | #define GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) \ |
336 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ((num), \ | 353 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ((num), \ |
337 | (elements), \ | 354 | (const void **) (elements), \ |
338 | sizeof(*(elements[0])), \ | 355 | sizeof(*(elements[0])), \ |
339 | (db)) | 356 | (db)) |
340 | 357 | ||
@@ -351,7 +368,7 @@ struct GNUNET_PQ_QueryParam | |||
351 | GNUNET_PQ_query_param_array_string ( | 368 | GNUNET_PQ_query_param_array_string ( |
352 | unsigned int num, | 369 | unsigned int num, |
353 | const char *elements, | 370 | const char *elements, |
354 | const struct GNUNET_PQ_Context *db); | 371 | struct GNUNET_PQ_Context *db); |
355 | 372 | ||
356 | 373 | ||
357 | /** | 374 | /** |
@@ -365,8 +382,9 @@ GNUNET_PQ_query_param_array_string ( | |||
365 | struct GNUNET_PQ_QueryParam | 382 | struct GNUNET_PQ_QueryParam |
366 | GNUNET_PQ_query_param_array_ptrs_string ( | 383 | GNUNET_PQ_query_param_array_ptrs_string ( |
367 | unsigned int num, | 384 | unsigned int num, |
368 | const char *elements[], | 385 | const char *elements[static num], |
369 | const struct GNUNET_PQ_Context *db); | 386 | struct GNUNET_PQ_Context *db); |
387 | |||
370 | 388 | ||
371 | /** | 389 | /** |
372 | * Generate fixed-size query parameter with size determined | 390 | * Generate fixed-size query parameter with size determined |
@@ -389,7 +407,7 @@ struct GNUNET_PQ_QueryParam | |||
389 | GNUNET_PQ_query_param_array_abs_time ( | 407 | GNUNET_PQ_query_param_array_abs_time ( |
390 | unsigned int num, | 408 | unsigned int num, |
391 | const struct GNUNET_TIME_Absolute *elements, | 409 | const struct GNUNET_TIME_Absolute *elements, |
392 | const struct GNUNET_PQ_Context *db); | 410 | struct GNUNET_PQ_Context *db); |
393 | 411 | ||
394 | /** | 412 | /** |
395 | * Generate query parameter for an array of absolute time stamps (pointers) | 413 | * Generate query parameter for an array of absolute time stamps (pointers) |
@@ -402,7 +420,7 @@ struct GNUNET_PQ_QueryParam | |||
402 | GNUNET_PQ_query_param_array_ptrs_abs_time ( | 420 | GNUNET_PQ_query_param_array_ptrs_abs_time ( |
403 | unsigned int num, | 421 | unsigned int num, |
404 | const struct GNUNET_TIME_Absolute *elements[], | 422 | const struct GNUNET_TIME_Absolute *elements[], |
405 | const struct GNUNET_PQ_Context *db); | 423 | struct GNUNET_PQ_Context *db); |
406 | 424 | ||
407 | /** | 425 | /** |
408 | * Generate query parameter for an array of relative time stamps (continuous) | 426 | * Generate query parameter for an array of relative time stamps (continuous) |
@@ -415,7 +433,7 @@ struct GNUNET_PQ_QueryParam | |||
415 | GNUNET_PQ_query_param_array_rel_time ( | 433 | GNUNET_PQ_query_param_array_rel_time ( |
416 | unsigned int num, | 434 | unsigned int num, |
417 | const struct GNUNET_TIME_Relative *elements, | 435 | const struct GNUNET_TIME_Relative *elements, |
418 | const struct GNUNET_PQ_Context *db); | 436 | struct GNUNET_PQ_Context *db); |
419 | 437 | ||
420 | /** | 438 | /** |
421 | * Generate query parameter for an array of relative time stamps (pointers) | 439 | * Generate query parameter for an array of relative time stamps (pointers) |
@@ -428,7 +446,7 @@ struct GNUNET_PQ_QueryParam | |||
428 | GNUNET_PQ_query_param_array_ptrs_rel_time ( | 446 | GNUNET_PQ_query_param_array_ptrs_rel_time ( |
429 | unsigned int num, | 447 | unsigned int num, |
430 | const struct GNUNET_TIME_Relative *elements[], | 448 | const struct GNUNET_TIME_Relative *elements[], |
431 | const struct GNUNET_PQ_Context *db); | 449 | struct GNUNET_PQ_Context *db); |
432 | 450 | ||
433 | /** | 451 | /** |
434 | * Generate query parameter for an array of time stamps (continuous) | 452 | * Generate query parameter for an array of time stamps (continuous) |
@@ -441,7 +459,7 @@ struct GNUNET_PQ_QueryParam | |||
441 | GNUNET_PQ_query_param_array_timestamp ( | 459 | GNUNET_PQ_query_param_array_timestamp ( |
442 | unsigned int num, | 460 | unsigned int num, |
443 | const struct GNUNET_TIME_Timestamp *elements, | 461 | const struct GNUNET_TIME_Timestamp *elements, |
444 | const struct GNUNET_PQ_Context *db); | 462 | struct GNUNET_PQ_Context *db); |
445 | 463 | ||
446 | /** | 464 | /** |
447 | * Generate query parameter for an array of time stamps (pointers) | 465 | * Generate query parameter for an array of time stamps (pointers) |
@@ -454,7 +472,7 @@ struct GNUNET_PQ_QueryParam | |||
454 | GNUNET_PQ_query_param_array_ptrs_timestamp ( | 472 | GNUNET_PQ_query_param_array_ptrs_timestamp ( |
455 | unsigned int num, | 473 | unsigned int num, |
456 | const struct GNUNET_TIME_Timestamp *elements[], | 474 | const struct GNUNET_TIME_Timestamp *elements[], |
457 | const struct GNUNET_PQ_Context *db); | 475 | struct GNUNET_PQ_Context *db); |
458 | 476 | ||
459 | /** | 477 | /** |
460 | * Generate query parameter for an RSA public key. The | 478 | * Generate query parameter for an RSA public key. The |
@@ -887,7 +905,7 @@ GNUNET_PQ_result_spec_uint64 (const char *name, | |||
887 | */ | 905 | */ |
888 | struct GNUNET_PQ_ResultSpec | 906 | struct GNUNET_PQ_ResultSpec |
889 | GNUNET_PQ_result_spec_array_bool ( | 907 | GNUNET_PQ_result_spec_array_bool ( |
890 | const struct GNUNET_PQ_Context *db, | 908 | struct GNUNET_PQ_Context *db, |
891 | const char *name, | 909 | const char *name, |
892 | size_t *num, | 910 | size_t *num, |
893 | bool **bools); | 911 | bool **bools); |
@@ -903,7 +921,7 @@ GNUNET_PQ_result_spec_array_bool ( | |||
903 | */ | 921 | */ |
904 | struct GNUNET_PQ_ResultSpec | 922 | struct GNUNET_PQ_ResultSpec |
905 | GNUNET_PQ_result_spec_array_uint16 ( | 923 | GNUNET_PQ_result_spec_array_uint16 ( |
906 | const struct GNUNET_PQ_Context *db, | 924 | struct GNUNET_PQ_Context *db, |
907 | const char *name, | 925 | const char *name, |
908 | size_t *num, | 926 | size_t *num, |
909 | uint16_t **dst); | 927 | uint16_t **dst); |
@@ -919,7 +937,7 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
919 | */ | 937 | */ |
920 | struct GNUNET_PQ_ResultSpec | 938 | struct GNUNET_PQ_ResultSpec |
921 | GNUNET_PQ_result_spec_array_uint32 ( | 939 | GNUNET_PQ_result_spec_array_uint32 ( |
922 | const struct GNUNET_PQ_Context *db, | 940 | struct GNUNET_PQ_Context *db, |
923 | const char *name, | 941 | const char *name, |
924 | size_t *num, | 942 | size_t *num, |
925 | uint32_t **dst); | 943 | uint32_t **dst); |
@@ -935,7 +953,7 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
935 | */ | 953 | */ |
936 | struct GNUNET_PQ_ResultSpec | 954 | struct GNUNET_PQ_ResultSpec |
937 | GNUNET_PQ_result_spec_array_uint64 ( | 955 | GNUNET_PQ_result_spec_array_uint64 ( |
938 | const struct GNUNET_PQ_Context *db, | 956 | struct GNUNET_PQ_Context *db, |
939 | const char *name, | 957 | const char *name, |
940 | size_t *num, | 958 | size_t *num, |
941 | uint64_t **dst); | 959 | uint64_t **dst); |
@@ -952,7 +970,7 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
952 | */ | 970 | */ |
953 | struct GNUNET_PQ_ResultSpec | 971 | struct GNUNET_PQ_ResultSpec |
954 | GNUNET_PQ_result_spec_array_abs_time ( | 972 | GNUNET_PQ_result_spec_array_abs_time ( |
955 | const struct GNUNET_PQ_Context *db, | 973 | struct GNUNET_PQ_Context *db, |
956 | const char *name, | 974 | const char *name, |
957 | size_t *num, | 975 | size_t *num, |
958 | struct GNUNET_TIME_Absolute **dst); | 976 | struct GNUNET_TIME_Absolute **dst); |
@@ -968,7 +986,7 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
968 | */ | 986 | */ |
969 | struct GNUNET_PQ_ResultSpec | 987 | struct GNUNET_PQ_ResultSpec |
970 | GNUNET_PQ_result_spec_array_rel_time ( | 988 | GNUNET_PQ_result_spec_array_rel_time ( |
971 | const struct GNUNET_PQ_Context *db, | 989 | struct GNUNET_PQ_Context *db, |
972 | const char *name, | 990 | const char *name, |
973 | size_t *num, | 991 | size_t *num, |
974 | struct GNUNET_TIME_Relative **dst); | 992 | struct GNUNET_TIME_Relative **dst); |
@@ -985,7 +1003,7 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
985 | 1003 | ||
986 | struct GNUNET_PQ_ResultSpec | 1004 | struct GNUNET_PQ_ResultSpec |
987 | GNUNET_PQ_result_spec_array_timestamp ( | 1005 | GNUNET_PQ_result_spec_array_timestamp ( |
988 | const struct GNUNET_PQ_Context *db, | 1006 | struct GNUNET_PQ_Context *db, |
989 | const char *name, | 1007 | const char *name, |
990 | size_t *num, | 1008 | size_t *num, |
991 | struct GNUNET_TIME_Timestamp **dst); | 1009 | struct GNUNET_TIME_Timestamp **dst); |
@@ -1002,7 +1020,7 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1002 | */ | 1020 | */ |
1003 | struct GNUNET_PQ_ResultSpec | 1021 | struct GNUNET_PQ_ResultSpec |
1004 | GNUNET_PQ_result_spec_array_variable_size ( | 1022 | GNUNET_PQ_result_spec_array_variable_size ( |
1005 | const struct GNUNET_PQ_Context *db, | 1023 | struct GNUNET_PQ_Context *db, |
1006 | const char *name, | 1024 | const char *name, |
1007 | size_t *num, | 1025 | size_t *num, |
1008 | size_t **sizes, | 1026 | size_t **sizes, |
@@ -1021,7 +1039,7 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1021 | */ | 1039 | */ |
1022 | struct GNUNET_PQ_ResultSpec | 1040 | struct GNUNET_PQ_ResultSpec |
1023 | GNUNET_PQ_result_spec_array_fixed_size ( | 1041 | GNUNET_PQ_result_spec_array_fixed_size ( |
1024 | const struct GNUNET_PQ_Context *db, | 1042 | struct GNUNET_PQ_Context *db, |
1025 | const char *name, | 1043 | const char *name, |
1026 | size_t size, | 1044 | size_t size, |
1027 | size_t *num, | 1045 | size_t *num, |
@@ -1057,7 +1075,7 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1057 | */ | 1075 | */ |
1058 | struct GNUNET_PQ_ResultSpec | 1076 | struct GNUNET_PQ_ResultSpec |
1059 | GNUNET_PQ_result_spec_array_string ( | 1077 | GNUNET_PQ_result_spec_array_string ( |
1060 | const struct GNUNET_PQ_Context *db, | 1078 | struct GNUNET_PQ_Context *db, |
1061 | const char *name, | 1079 | const char *name, |
1062 | size_t *num, | 1080 | size_t *num, |
1063 | char **dst); | 1081 | char **dst); |
@@ -1562,6 +1580,19 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh); | |||
1562 | 1580 | ||
1563 | 1581 | ||
1564 | /** | 1582 | /** |
1583 | * Poll for events right now. Useful if we may have | ||
1584 | * triggered an event for ourselves. Not needed when | ||
1585 | * using GNUNET_PQ_event_notify(), but useful when | ||
1586 | * stored procedures may have triggered events. | ||
1587 | * Does nothing if there are no events. | ||
1588 | * | ||
1589 | * @param[in,out] db database to check for events | ||
1590 | */ | ||
1591 | void | ||
1592 | GNUNET_PQ_event_do_poll (struct GNUNET_PQ_Context *db); | ||
1593 | |||
1594 | |||
1595 | /** | ||
1565 | * Notify all that listen on @a es of an event. | 1596 | * Notify all that listen on @a es of an event. |
1566 | * | 1597 | * |
1567 | * Unlike many other calls, this function is thread-safe and may be called | 1598 | * Unlike many other calls, this function is thread-safe and may be called |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index e78738d7b..99a1adcf4 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2352,7 +2352,7 @@ extern "C" { | |||
2352 | /** M<->S<->C: PSYC message which contains a header and one or more message | 2352 | /** M<->S<->C: PSYC message which contains a header and one or more message |
2353 | * parts. */ | 2353 | * parts. */ |
2354 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \ | 2354 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \ |
2355 | 692 // FIXME: start using this where appropriate | 2355 | 692 // FIXME: start using this where appropriate |
2356 | 2356 | ||
2357 | /** Message part: method */ | 2357 | /** Message part: method */ |
2358 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 | 2358 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 |
@@ -3530,6 +3530,11 @@ extern "C" { | |||
3530 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD 1461 | 3530 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD 1461 |
3531 | 3531 | ||
3532 | /** | 3532 | /** |
3533 | * UDP Rekey. | ||
3534 | */ | ||
3535 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY 1462 | ||
3536 | |||
3537 | /** | ||
3533 | * Next available: 1500 | 3538 | * Next available: 1500 |
3534 | */ | 3539 | */ |
3535 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 | 3540 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 |
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index 7c6ce0c0e..3ebfae581 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -314,6 +314,7 @@ GNUNET_SERVICE_run_ (int argc, | |||
314 | * GNUNET_MQ_handler_end ()); | 314 | * GNUNET_MQ_handler_end ()); |
315 | * </code> | 315 | * </code> |
316 | */ | 316 | */ |
317 | #ifndef HAVE_GNUNET_MONOLITH | ||
317 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ | 318 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ |
318 | disconnect_cb, cls, ...) \ | 319 | disconnect_cb, cls, ...) \ |
319 | int \ | 320 | int \ |
@@ -333,7 +334,10 @@ GNUNET_SERVICE_run_ (int argc, | |||
333 | cls, \ | 334 | cls, \ |
334 | mh); \ | 335 | mh); \ |
335 | } | 336 | } |
336 | 337 | #else | |
338 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ | ||
339 | disconnect_cb, cls, ...) | ||
340 | #endif | ||
337 | 341 | ||
338 | /** | 342 | /** |
339 | * Suspend accepting connections from the listen socket temporarily. | 343 | * Suspend accepting connections from the listen socket temporarily. |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h new file mode 100644 index 000000000..6ec30bf71 --- /dev/null +++ b/src/include/gnunet_signatures.h | |||
@@ -0,0 +1,254 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNUNET_SIGNATURES_H | ||
21 | #define GNUNET_SIGNATURES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add a signature purpose, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | |||
33 | |||
34 | #ifdef __cplusplus | ||
35 | extern "C" { | ||
36 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
37 | } | ||
38 | #endif | ||
39 | #endif | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Network signature purpose definitions. Note that all values | ||
44 | * must be uint32_t and encoded in network byte order in the structs. | ||
45 | */ | ||
46 | |||
47 | |||
48 | |||
49 | /** | ||
50 | * Test signature, not valid for anything other than writing a test. (Note that the signature verification code will accept this value). (GNUnet) | ||
51 | */ | ||
52 | #define GNUNET_SIGNATURE_PURPOSE_TEST 0 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Signature for confirming that this peer uses a particular address. (GNUnet-TRANSPORT) | ||
57 | */ | ||
58 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1 | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Signature for confirming that this peer intends to disconnect. (GNUnet-TRANSPORT) | ||
63 | */ | ||
64 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT 2 | ||
65 | |||
66 | |||
67 | /** | ||
68 | * GNS zone key revocation (GNS) | ||
69 | */ | ||
70 | #define GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION 3 | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Signature for a namespace/pseudonym advertisement (by the namespace owner). (GNUnet-FS) | ||
75 | */ | ||
76 | #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 4 | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Signature by which a peer affirms that it is providing a certain bit of content for use in LOCation URIs. (GNUnet-FS) | ||
81 | */ | ||
82 | #define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5 | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Signature by which a peer affirms that it forwarded a message in the DHT. (GNUnet-DHT) | ||
87 | */ | ||
88 | #define GNUNET_SIGNATURE_PURPOSE_DHT_HOP 6 | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Signature by which a peer affirms its address. (GNUnet-HELLO) | ||
93 | */ | ||
94 | #define GNUNET_SIGNATURE_PURPOSE_HELLO 7 | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Signature on a GNUNET_DNS_Advertisement. (GNUnet-DNS+Exit) | ||
99 | */ | ||
100 | #define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD 11 | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Signature of a chat message. (GNUnet-MESSENGER) | ||
105 | */ | ||
106 | #define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE 12 | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Signature of confirmation receipt for a chat message. (GNUnet-MESSENGER) | ||
111 | */ | ||
112 | #define GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT 13 | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Signature of a network size estimate message. (GNUnet-NSE) | ||
117 | */ | ||
118 | #define GNUNET_SIGNATURE_PURPOSE_NSE_SEND 14 | ||
119 | |||
120 | |||
121 | /** | ||
122 | * GNS record set signature (GNS) | ||
123 | */ | ||
124 | #define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN 15 | ||
125 | |||
126 | |||
127 | /** | ||
128 | * Purpose is to set a session key. (GNUnet-CORE) | ||
129 | */ | ||
130 | #define GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY 16 | ||
131 | |||
132 | |||
133 | /** | ||
134 | * UBlock Signature, done using DSS, not ECC (GNUnet-FS) | ||
135 | */ | ||
136 | #define GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK 17 | ||
137 | |||
138 | |||
139 | /** | ||
140 | * Accept state in regex DFA. Peer affirms that it offers the matching service. (GNUnet-REGEX) | ||
141 | */ | ||
142 | #define GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT 18 | ||
143 | |||
144 | |||
145 | /** | ||
146 | * Signature of a conversation ring. (GNUnet-CONVERSATION) | ||
147 | */ | ||
148 | #define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING 20 | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Signature for the first round of distributed key generation. (GNUnet-SECRETSHARING) | ||
153 | */ | ||
154 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1 21 | ||
155 | |||
156 | |||
157 | /** | ||
158 | * Signature for the second round of distributed key generation. (GNUnet-SECRETSHARING) | ||
159 | */ | ||
160 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2 22 | ||
161 | |||
162 | |||
163 | /** | ||
164 | * Signature for the cooperative decryption. (GNUnet-SECRETSHARING) | ||
165 | */ | ||
166 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION 23 | ||
167 | |||
168 | |||
169 | /** | ||
170 | * Signature for a GNUid Ticket (Reclaim) | ||
171 | */ | ||
172 | #define GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN 27 | ||
173 | |||
174 | |||
175 | /** | ||
176 | * Signature for a GNUnet credential (Reclaim) | ||
177 | */ | ||
178 | #define GNUNET_SIGNATURE_PURPOSE_DELEGATE 28 | ||
179 | |||
180 | |||
181 | /** | ||
182 | * Signature by a peer affirming that this is one of its addresses for the given time period. (GNUnet-TRANSPORT) | ||
183 | */ | ||
184 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS 29 | ||
185 | |||
186 | |||
187 | /** | ||
188 | * Signature by a peer affirming that the given ephemeral key is currently in use by that peer's transport service. (GNUnet-TRANSPORT) | ||
189 | */ | ||
190 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL 30 | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Signature used by TCP communicator handshake. (GNUnet-TRANSPORT-TCP) | ||
195 | */ | ||
196 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE 31 | ||
197 | |||
198 | |||
199 | /** | ||
200 | * Signature used by TCP communicator rekey. (GNUnet-TRANSPORT-TCP) | ||
201 | */ | ||
202 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY 32 | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Signature used by UDP communicator handshake. (GNUnet-TRANSPORT-UDP) | ||
207 | */ | ||
208 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_HANDSHAKE 33 | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Signature used by UDP broadcasts. (GNUnet-TRANSPORT-UDP) | ||
213 | */ | ||
214 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST 34 | ||
215 | |||
216 | |||
217 | /** | ||
218 | * Signature by a peer affirming that it received a challenge (and stating how long it expects the address on which the challenge was received to remain valid). (GNUnet-TRANSPORT) | ||
219 | */ | ||
220 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE 35 | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Signature by a peer affirming that it is on a DV path. (GNUnet-TRANSPORT) | ||
225 | */ | ||
226 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP 36 | ||
227 | |||
228 | |||
229 | /** | ||
230 | * Signature by a peer affirming that it originated the DV path. (GNUnet-TRANSPORT) | ||
231 | */ | ||
232 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR 37 | ||
233 | |||
234 | |||
235 | /** | ||
236 | * Signature by a peer that like to create a connection. (GNUnet-CADET) | ||
237 | */ | ||
238 | #define GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR 38 | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Signature by a peer sending back the nonce received at initial handshake. (GNUnet-TRANSPORT-TCP) | ||
243 | */ | ||
244 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE_ACK 39 | ||
245 | |||
246 | |||
247 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
248 | { | ||
249 | #endif | ||
250 | #ifdef __cplusplus | ||
251 | } | ||
252 | #endif | ||
253 | |||
254 | #endif | ||
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index b751ef044..be41fb1d9 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -18,7 +18,7 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 21 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
22 | #error "Only <gnunet_util_lib.h> can be included directly." | 22 | #error "Only <gnunet_util_lib.h> can be included directly." |
23 | #endif | 23 | #endif |
24 | 24 | ||
@@ -41,7 +41,7 @@ | |||
41 | * @{ | 41 | * @{ |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | 44 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) |
45 | #error "Only <gnunet_util_lib.h> can be included directly." | 45 | #error "Only <gnunet_util_lib.h> can be included directly." |
46 | #endif | 46 | #endif |
47 | 47 | ||
@@ -670,6 +670,23 @@ GNUNET_strlcpy (char *dst, | |||
670 | size_t n); | 670 | size_t n); |
671 | 671 | ||
672 | 672 | ||
673 | /** | ||
674 | * Sometimes we use the binary name to determine which specific | ||
675 | * test to run. In those cases, the string after the last "_" | ||
676 | * in 'argv[0]' specifies a string that determines the configuration | ||
677 | * file or plugin to use. | ||
678 | * | ||
679 | * This function returns the respective substring, taking care | ||
680 | * of issues such as binaries ending in '.exe' on W32. | ||
681 | * | ||
682 | * @param argv0 the name of the binary | ||
683 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
684 | * NULL if argv0 has no '_' | ||
685 | */ | ||
686 | char * | ||
687 | GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0); | ||
688 | |||
689 | |||
673 | /* ***************** IPv4/IPv6 parsing ****************** */ | 690 | /* ***************** IPv4/IPv6 parsing ****************** */ |
674 | 691 | ||
675 | struct GNUNET_STRINGS_PortPolicy | 692 | struct GNUNET_STRINGS_PortPolicy |
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index cd9d88822..0d74de8c2 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -449,23 +449,6 @@ GNUNET_TESTING_service_run (const char *testdir, | |||
449 | void *tm_cls); | 449 | void *tm_cls); |
450 | 450 | ||
451 | 451 | ||
452 | /** | ||
453 | * Sometimes we use the binary name to determine which specific | ||
454 | * test to run. In those cases, the string after the last "_" | ||
455 | * in 'argv[0]' specifies a string that determines the configuration | ||
456 | * file or plugin to use. | ||
457 | * | ||
458 | * This function returns the respective substring, taking care | ||
459 | * of issues such as binaries ending in '.exe' on W32. | ||
460 | * | ||
461 | * @param argv0 the name of the binary | ||
462 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
463 | * NULL if argv0 has no '_' | ||
464 | */ | ||
465 | char * | ||
466 | GNUNET_TESTING_get_testname_from_underscore (const char *argv0); | ||
467 | |||
468 | |||
469 | #if 0 /* keep Emacsens' auto-indent happy */ | 452 | #if 0 /* keep Emacsens' auto-indent happy */ |
470 | { | 453 | { |
471 | #endif | 454 | #endif |
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h index b76ce060b..9d016b33a 100644 --- a/src/include/gnunet_testing_netjail_lib.h +++ b/src/include/gnunet_testing_netjail_lib.h | |||
@@ -536,10 +536,10 @@ GNUNET_TESTING_cmd_start_peer (const char *label, | |||
536 | */ | 536 | */ |
537 | #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \ | 537 | #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \ |
538 | op (test_system, const struct GNUNET_TESTING_System) \ | 538 | op (test_system, const struct GNUNET_TESTING_System) \ |
539 | op (async_context, const struct GNUNET_TESTING_AsyncContext) \ | 539 | op (async_context, struct GNUNET_TESTING_AsyncContext) \ |
540 | op (helper_handles, const struct GNUNET_HELPER_Handle *) \ | 540 | op (helper_handles, const struct GNUNET_HELPER_Handle *) \ |
541 | op (local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \ | 541 | op (local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \ |
542 | op (block_state, const struct GNUNET_TESTING_BlockState) | 542 | op (block_state, struct GNUNET_TESTING_BlockState) |
543 | 543 | ||
544 | GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT) | 544 | GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT) |
545 | 545 | ||
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index eff45498b..07cdac962 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -76,7 +76,7 @@ struct GNUNET_TESTING_AsyncContext | |||
76 | /** | 76 | /** |
77 | * Interpreter we are part of. | 77 | * Interpreter we are part of. |
78 | */ | 78 | */ |
79 | struct GNUNET_TESTING_Interpreter *is; | 79 | struct GNUNET_TESTING_Interpreter *is; // Why needed? When available? |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Function to call when done. | 82 | * Function to call when done. |
@@ -96,18 +96,21 @@ struct GNUNET_TESTING_AsyncContext | |||
96 | enum GNUNET_GenericReturnValue finished; | 96 | enum GNUNET_GenericReturnValue finished; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | |||
99 | typedef void | 100 | typedef void |
100 | (*GNUNET_TESTING_CommandRunRoutine)(void *cls, | 101 | (*GNUNET_TESTING_CommandRunRoutine)(void *cls, |
101 | struct GNUNET_TESTING_Interpreter *is); | 102 | struct GNUNET_TESTING_Interpreter *is); |
102 | 103 | ||
104 | |||
103 | typedef void | 105 | typedef void |
104 | (*GNUNET_TESTING_CommandCleanupRoutine)(void *cls); | 106 | (*GNUNET_TESTING_CommandCleanupRoutine)(void *cls); |
105 | 107 | ||
106 | typedef enum GNUNET_GenericReturnValue | 108 | |
107 | (*GNUNET_TESTING_CommandGetTraits)(void *cls, | 109 | typedef enum GNUNET_GenericReturnValue |
108 | const void **ret, | 110 | (*GNUNET_TESTING_CommandGetTraits) (void *cls, |
109 | const char *trait, | 111 | const void **ret, |
110 | unsigned int index); | 112 | const char *trait, |
113 | unsigned int index); | ||
111 | 114 | ||
112 | /** | 115 | /** |
113 | * Create a new command | 116 | * Create a new command |
@@ -246,6 +249,7 @@ struct GNUNET_TESTING_Command | |||
246 | * @param label label of the command to lookup. | 249 | * @param label label of the command to lookup. |
247 | * @return the command, if it is found, or NULL. | 250 | * @return the command, if it is found, or NULL. |
248 | */ | 251 | */ |
252 | // FIXME: think harder about whether this is actually needed, likely not. | ||
249 | const struct GNUNET_TESTING_Command * | 253 | const struct GNUNET_TESTING_Command * |
250 | GNUNET_TESTING_interpreter_lookup_future_command ( | 254 | GNUNET_TESTING_interpreter_lookup_future_command ( |
251 | struct GNUNET_TESTING_Interpreter *is, | 255 | struct GNUNET_TESTING_Interpreter *is, |
@@ -327,10 +331,13 @@ GNUNET_TESTING_cmd_end (void); | |||
327 | 331 | ||
328 | 332 | ||
329 | /** | 333 | /** |
330 | * Turn asynchronous command into non blocking command by setting asynchronous_finish to true. | 334 | * Turn asynchronous command into non blocking command by setting |
331 | * FIXME: what is this API doing? Is it returning a new cmd which is unblocking? | 335 | * asynchronous_finish to true. Modifies (and then returns) @a cmd simply |
332 | * Is it modifying cmd? | 336 | * setting the bit. By default, most commands are blocking, and by wrapping |
333 | * Looking at the code, it both modifying cmd AND returning a copy oO | 337 | * the command construction in this function a blocking command can be turned |
338 | * into an asynchronous command where the interpreter continues after | ||
339 | * initiating the asynchronous action. Does nothing if the command is | ||
340 | * fundamentally synchronous. | ||
334 | * | 341 | * |
335 | * @param cmd command to make synchronous. | 342 | * @param cmd command to make synchronous. |
336 | * @return a finish-command. | 343 | * @return a finish-command. |
@@ -894,11 +901,11 @@ struct GNUNET_TESTING_StartPeerState | |||
894 | */ | 901 | */ |
895 | #define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ | 902 | #define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ |
896 | enum GNUNET_GenericReturnValue \ | 903 | enum GNUNET_GenericReturnValue \ |
897 | GNUNET_TESTING_get_trait_ ## name ( \ | 904 | GNUNET_TESTING_get_trait_ ## name ( \ |
898 | const struct GNUNET_TESTING_Command *cmd, \ | 905 | const struct GNUNET_TESTING_Command *cmd, \ |
899 | type **ret); \ | 906 | type **ret); \ |
900 | struct GNUNET_TESTING_Trait \ | 907 | struct GNUNET_TESTING_Trait \ |
901 | GNUNET_TESTING_make_trait_ ## name ( \ | 908 | GNUNET_TESTING_make_trait_ ## name ( \ |
902 | type * value); | 909 | type * value); |
903 | 910 | ||
904 | 911 | ||
@@ -908,9 +915,9 @@ struct GNUNET_TESTING_StartPeerState | |||
908 | */ | 915 | */ |
909 | #define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ | 916 | #define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ |
910 | enum GNUNET_GenericReturnValue \ | 917 | enum GNUNET_GenericReturnValue \ |
911 | GNUNET_TESTING_get_trait_ ## name ( \ | 918 | GNUNET_TESTING_get_trait_ ## name ( \ |
912 | const struct GNUNET_TESTING_Command *cmd, \ | 919 | const struct GNUNET_TESTING_Command *cmd, \ |
913 | type **ret) \ | 920 | type * *ret) \ |
914 | { \ | 921 | { \ |
915 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | 922 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ |
916 | return cmd->traits (cmd->cls, \ | 923 | return cmd->traits (cmd->cls, \ |
@@ -919,7 +926,7 @@ struct GNUNET_TESTING_StartPeerState | |||
919 | 0); \ | 926 | 0); \ |
920 | } \ | 927 | } \ |
921 | struct GNUNET_TESTING_Trait \ | 928 | struct GNUNET_TESTING_Trait \ |
922 | GNUNET_TESTING_make_trait_ ## name ( \ | 929 | GNUNET_TESTING_make_trait_ ## name ( \ |
923 | type * value) \ | 930 | type * value) \ |
924 | { \ | 931 | { \ |
925 | struct GNUNET_TESTING_Trait ret = { \ | 932 | struct GNUNET_TESTING_Trait ret = { \ |
@@ -936,14 +943,14 @@ struct GNUNET_TESTING_StartPeerState | |||
936 | */ | 943 | */ |
937 | #define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ | 944 | #define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ |
938 | enum GNUNET_GenericReturnValue \ | 945 | enum GNUNET_GenericReturnValue \ |
939 | GNUNET_TESTING_get_trait_ ## name ( \ | 946 | GNUNET_TESTING_get_trait_ ## name ( \ |
940 | const struct GNUNET_TESTING_Command *cmd, \ | 947 | const struct GNUNET_TESTING_Command *cmd, \ |
941 | unsigned int index, \ | 948 | unsigned int index, \ |
942 | type **ret); \ | 949 | type **ret); \ |
943 | struct GNUNET_TESTING_Trait \ | 950 | struct GNUNET_TESTING_Trait \ |
944 | GNUNET_TESTING_make_trait_ ## name ( \ | 951 | GNUNET_TESTING_make_trait_ ## name ( \ |
945 | unsigned int index, \ | 952 | unsigned int index, \ |
946 | type * value); | 953 | type *value); |
947 | 954 | ||
948 | 955 | ||
949 | /** | 956 | /** |
@@ -952,10 +959,10 @@ struct GNUNET_TESTING_StartPeerState | |||
952 | */ | 959 | */ |
953 | #define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ | 960 | #define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ |
954 | enum GNUNET_GenericReturnValue \ | 961 | enum GNUNET_GenericReturnValue \ |
955 | GNUNET_TESTING_get_trait_ ## name ( \ | 962 | GNUNET_TESTING_get_trait_ ## name ( \ |
956 | const struct GNUNET_TESTING_Command *cmd, \ | 963 | const struct GNUNET_TESTING_Command *cmd, \ |
957 | unsigned int index, \ | 964 | unsigned int index, \ |
958 | type **ret) \ | 965 | type * *ret) \ |
959 | { \ | 966 | { \ |
960 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | 967 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ |
961 | return cmd->traits (cmd->cls, \ | 968 | return cmd->traits (cmd->cls, \ |
@@ -964,7 +971,7 @@ struct GNUNET_TESTING_StartPeerState | |||
964 | index); \ | 971 | index); \ |
965 | } \ | 972 | } \ |
966 | struct GNUNET_TESTING_Trait \ | 973 | struct GNUNET_TESTING_Trait \ |
967 | GNUNET_TESTING_make_trait_ ## name ( \ | 974 | GNUNET_TESTING_make_trait_ ## name ( \ |
968 | unsigned int index, \ | 975 | unsigned int index, \ |
969 | type * value) \ | 976 | type * value) \ |
970 | { \ | 977 | { \ |
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h index ada40a4ca..c8737dc60 100644 --- a/src/include/gnunet_util_lib.h +++ b/src/include/gnunet_util_lib.h | |||
@@ -93,6 +93,15 @@ extern "C" | |||
93 | #include "gnunet_child_management_lib.h" | 93 | #include "gnunet_child_management_lib.h" |
94 | #include "gnunet_error_codes.h" | 94 | #include "gnunet_error_codes.h" |
95 | 95 | ||
96 | |||
97 | /** | ||
98 | * Stringify operator. | ||
99 | * | ||
100 | * @param a some expression to stringify. Must NOT be a macro. | ||
101 | * @return same expression as a constant string. | ||
102 | */ | ||
103 | #define GNUNET_S(a) #a | ||
104 | |||
96 | /** | 105 | /** |
97 | * Try to compress the given block of data using libz. Only returns | 106 | * Try to compress the given block of data using libz. Only returns |
98 | * the compressed block if compression worked and the new block is | 107 | * the compressed block if compression worked and the new block is |
diff --git a/src/include/meson.build b/src/include/meson.build new file mode 100644 index 000000000..58125cc11 --- /dev/null +++ b/src/include/meson.build | |||
@@ -0,0 +1,134 @@ | |||
1 | configure_file( | ||
2 | input : 'gnunet_config.h.in', | ||
3 | output : 'gnunet_config.h', | ||
4 | configuration : cdata, | ||
5 | install: true, | ||
6 | install_dir: get_option('includedir')/'gnunet' | ||
7 | ) | ||
8 | |||
9 | install_headers( | ||
10 | 'gettext.h', | ||
11 | 'compat.h', | ||
12 | 'gnunet_abd_service.h', | ||
13 | 'gnunet_applications.h', | ||
14 | 'gnunet_arm_service.h', | ||
15 | 'gnunet_ats_service.h', | ||
16 | 'gnunet_ats_application_service.h', | ||
17 | 'gnunet_ats_transport_service.h', | ||
18 | 'gnunet_ats_plugin.h', | ||
19 | 'gnunet_bandwidth_lib.h', | ||
20 | 'gnunet_bio_lib.h', | ||
21 | 'gnunet_dht_block_types.h', | ||
22 | 'gnunet_block_lib.h', | ||
23 | 'gnunet_block_group_lib.h', | ||
24 | 'gnunet_block_plugin.h', | ||
25 | 'gnunet_buffer_lib.h', | ||
26 | 'gnunet_child_management_lib.h', | ||
27 | 'gnunet_client_lib.h', | ||
28 | 'gnunet_common.h', | ||
29 | 'gnunet_constants.h', | ||
30 | 'gnunet_configuration_lib.h', | ||
31 | 'gnunet_consensus_service.h', | ||
32 | 'gnunet_container_lib.h', | ||
33 | 'gnunet_conversation_service.h', | ||
34 | 'gnunet_core_service.h', | ||
35 | 'gnunet_crypto_lib.h', | ||
36 | 'gnunet_curl_lib.h', | ||
37 | 'gnunet_datacache_lib.h', | ||
38 | 'gnunet_datacache_plugin.h', | ||
39 | 'gnunet_datastore_service.h', | ||
40 | 'gnunet_datastore_plugin.h', | ||
41 | 'gnunet_db_lib.h', | ||
42 | 'gnunet_dht_service.h', | ||
43 | 'gnunet_dhtu_plugin.h', | ||
44 | 'gnunet_disk_lib.h', | ||
45 | 'gnunet_dnsparser_lib.h', | ||
46 | 'gnunet_dnsstub_lib.h', | ||
47 | 'gnunet_dns_service.h', | ||
48 | 'gnunet_error_codes.h', | ||
49 | 'gnunet_fragmentation_lib.h', | ||
50 | 'gnunet_friends_lib.h', | ||
51 | 'gnunet_fs_service.h', | ||
52 | 'gnunet_getopt_lib.h', | ||
53 | 'gnunet_gns_service.h', | ||
54 | 'gnunet_gnsrecord_lib.h', | ||
55 | 'gnunet_gnsrecord_json_lib.h', | ||
56 | 'gnunet_gnsrecord_plugin.h', | ||
57 | 'gnu_name_system_record_types.h', | ||
58 | 'gnunet_hello_lib.h', | ||
59 | 'gnunet_hello_uri_lib.h', | ||
60 | 'gnunet_helper_lib.h', | ||
61 | 'gnunet_identity_service.h', | ||
62 | 'gnunet_reclaim_lib.h', | ||
63 | 'gnunet_reclaim_plugin.h', | ||
64 | 'gnunet_reclaim_service.h', | ||
65 | 'gnunet_json_lib.h', | ||
66 | 'gnunet_load_lib.h', | ||
67 | 'gnunet_cadet_service.h', | ||
68 | 'gnunet_messenger_service.h', | ||
69 | 'gnunet_mhd_compat.h', | ||
70 | 'gnunet_microphone_lib.h', | ||
71 | 'gnunet_mst_lib.h', | ||
72 | 'gnunet_mq_lib.h', | ||
73 | 'gnunet_namecache_plugin.h', | ||
74 | 'gnunet_namecache_service.h', | ||
75 | 'gnunet_namestore_plugin.h', | ||
76 | 'gnunet_namestore_service.h', | ||
77 | 'gnunet_nat_auto_service.h', | ||
78 | 'gnunet_nat_service.h', | ||
79 | 'gnunet_nc_lib.h', | ||
80 | 'gnunet_network_lib.h', | ||
81 | 'gnunet_nse_service.h', | ||
82 | 'gnunet_nt_lib.h', | ||
83 | 'gnunet_op_lib.h', | ||
84 | 'gnunet_os_lib.h', | ||
85 | 'gnunet_peer_lib.h', | ||
86 | 'gnunet_peerinfo_service.h', | ||
87 | 'gnunet_peerstore_plugin.h', | ||
88 | 'gnunet_peerstore_service.h', | ||
89 | 'gnunet_plugin_lib.h', | ||
90 | 'gnunet_pq_lib.h', | ||
91 | 'gnunet_program_lib.h', | ||
92 | 'gnunet_protocols.h', | ||
93 | 'gnunet_resolver_service.h', | ||
94 | 'gnunet_regex_service.h', | ||
95 | 'gnunet_rest_lib.h', | ||
96 | 'gnunet_rest_plugin.h', | ||
97 | 'gnunet_rps_service.h', | ||
98 | 'gnunet_revocation_service.h', | ||
99 | 'gnunet_scalarproduct_service.h', | ||
100 | 'gnunet_scheduler_lib.h', | ||
101 | 'gnunet_secretsharing_service.h', | ||
102 | 'gnunet_service_lib.h', | ||
103 | 'gnunet_set_service.h', | ||
104 | 'gnunet_seti_service.h', | ||
105 | 'gnunet_setu_service.h', | ||
106 | 'gnunet_signal_lib.h', | ||
107 | 'gnunet_signatures.h', | ||
108 | 'gnunet_socks.h', | ||
109 | 'gnunet_speaker_lib.h', | ||
110 | 'gnunet_sq_lib.h', | ||
111 | 'gnunet_statistics_service.h', | ||
112 | 'gnunet_strings_lib.h', | ||
113 | 'gnunet_testbed_service.h', | ||
114 | 'gnunet_testbed_logger_service.h', | ||
115 | 'gnunet_testing_barrier.h', | ||
116 | 'gnunet_testing_lib.h', | ||
117 | 'gnunet_testing_plugin.h', | ||
118 | 'gnunet_testing_ng_lib.h', | ||
119 | 'gnunet_testing_netjail_lib.h', | ||
120 | 'gnunet_time_lib.h', | ||
121 | 'gnunet_transport_service.h', | ||
122 | 'gnunet_transport_application_service.h', | ||
123 | 'gnunet_transport_communication_service.h', | ||
124 | 'gnunet_transport_core_service.h', | ||
125 | 'gnunet_transport_hello_service.h', | ||
126 | 'gnunet_transport_manipulation_service.h', | ||
127 | 'gnunet_transport_monitor_service.h', | ||
128 | 'gnunet_transport_plugin.h', | ||
129 | 'gnunet_tun_lib.h', | ||
130 | 'gnunet_uri_lib.h', | ||
131 | 'gnunet_util_lib.h', | ||
132 | 'gnunet_vpn_service.h', | ||
133 | install_dir: get_option('includedir')/'gnunet' | ||
134 | ) | ||
diff --git a/src/json/json_pack.c b/src/json/json_pack.c index 8fc806086..816373eaf 100644 --- a/src/json/json_pack.c +++ b/src/json/json_pack.c | |||
@@ -45,7 +45,13 @@ GNUNET_JSON_pack_ (struct GNUNET_JSON_PackSpec spec[]) | |||
45 | { | 45 | { |
46 | if (NULL == spec[i].object) | 46 | if (NULL == spec[i].object) |
47 | { | 47 | { |
48 | GNUNET_assert (spec[i].allow_null); | 48 | if (! spec[i].allow_null) |
49 | { | ||
50 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
51 | "NULL not allowed for `%s'\n", | ||
52 | spec[i].field_name); | ||
53 | GNUNET_assert (0); | ||
54 | } | ||
49 | } | 55 | } |
50 | else | 56 | else |
51 | { | 57 | { |
diff --git a/src/json/meson.build b/src/json/meson.build new file mode 100644 index 000000000..98385163e --- /dev/null +++ b/src/json/meson.build | |||
@@ -0,0 +1,25 @@ | |||
1 | libgnunetjson_src = ['json.c', | ||
2 | 'json_generator.c', | ||
3 | 'json_helper.c', | ||
4 | 'json_mhd.c', | ||
5 | 'json_pack.c'] | ||
6 | |||
7 | if get_option('monolith') | ||
8 | foreach p : libgnunetjson_src | ||
9 | gnunet_src += 'json/' + p | ||
10 | endforeach | ||
11 | subdir_done() | ||
12 | endif | ||
13 | |||
14 | libgnunetjson = library('gnunetjson', | ||
15 | libgnunetjson_src, | ||
16 | soversion: '0', | ||
17 | version: '0.0.0', | ||
18 | dependencies: [libgnunetutil_dep, json_dep, mhd_dep, zlib_dep], | ||
19 | include_directories: [incdir, configuration_inc], | ||
20 | install: true, | ||
21 | install_dir: get_option('libdir')) | ||
22 | libgnunetjson_dep = declare_dependency(link_with : libgnunetjson) | ||
23 | pkg.generate(libgnunetjson, url: 'https://www.gnunet.org', | ||
24 | description : 'Library for JSON de/serialization') | ||
25 | |||
diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000..41d6dae73 --- /dev/null +++ b/src/meson.build | |||
@@ -0,0 +1,81 @@ | |||
1 | if get_option('monolith') == true | ||
2 | gnunet_src = [] | ||
3 | endif | ||
4 | |||
5 | subdir('include') | ||
6 | subdir('util') | ||
7 | subdir('nt') | ||
8 | subdir('hello') | ||
9 | subdir('block') | ||
10 | if get_option('monolith') == false | ||
11 | subdir('arm') | ||
12 | endif | ||
13 | subdir('statistics') | ||
14 | subdir('testing') | ||
15 | subdir('json', if_found : json_dep) | ||
16 | subdir('curl', if_found : [curl_dep]) | ||
17 | if get_option('monolith') == false | ||
18 | subdir('rest') | ||
19 | endif | ||
20 | subdir('peerinfo') | ||
21 | subdir('sq', if_found : [sqlite_dep]) | ||
22 | subdir('pq', if_found : [pq_dep]) | ||
23 | subdir('datacache') | ||
24 | subdir('datastore') | ||
25 | #subdir('template') | ||
26 | subdir('peerstore') | ||
27 | subdir('ats') | ||
28 | subdir('nat') | ||
29 | subdir('nat-auto') | ||
30 | subdir('fragmentation') | ||
31 | subdir('transport') | ||
32 | subdir('ats-tool') | ||
33 | subdir('core') | ||
34 | subdir('testbed-logger') | ||
35 | subdir('testbed') | ||
36 | subdir('nse') | ||
37 | subdir('dhtu') | ||
38 | subdir('dht') | ||
39 | subdir('hostlist') | ||
40 | subdir('topology') | ||
41 | subdir('regex') | ||
42 | subdir('dns') | ||
43 | subdir('identity') | ||
44 | subdir('gnsrecord') | ||
45 | subdir('namecache') | ||
46 | subdir('namestore') | ||
47 | subdir('peerinfo-tool') | ||
48 | subdir('cadet') | ||
49 | subdir('set') | ||
50 | subdir('seti') | ||
51 | subdir('setu') | ||
52 | subdir('consensus') | ||
53 | subdir('scalarproduct') | ||
54 | subdir('revocation') | ||
55 | subdir('vpn') | ||
56 | subdir('gns') | ||
57 | subdir('zonemaster') | ||
58 | #subdir('$(CONVERSATION_DIR)') | ||
59 | subdir('fs') | ||
60 | # TODO | ||
61 | subdir('exit') | ||
62 | subdir('pt') | ||
63 | subdir('secretsharing') | ||
64 | subdir('reclaim') | ||
65 | subdir('messenger') | ||
66 | ##subdir('$(EXP_DIR)') | ||
67 | #subdir('integration-tests') | ||
68 | |||
69 | if not get_option('monolith') | ||
70 | subdir_done() | ||
71 | endif | ||
72 | libgnunet = library('gnunet', | ||
73 | gnunet_src, | ||
74 | dependencies: gnunetdeps, | ||
75 | include_directories: [incdir, configuration_inc, exitdir]) | ||
76 | libgnunet_dep = declare_dependency(link_with : libgnunet) | ||
77 | |||
78 | # FIXME here we need to re-enter all that need to link against libgnunet | ||
79 | # For example: dload plugins | ||
80 | # We also need a logic that handles this | ||
81 | # subdir('block') | ||
diff --git a/src/messenger/meson.build b/src/messenger/meson.build new file mode 100644 index 000000000..c855b45e4 --- /dev/null +++ b/src/messenger/meson.build | |||
@@ -0,0 +1,83 @@ | |||
1 | libgnunetmessenger_src = ['messenger_api.c', | ||
2 | 'messenger_api_contact.c', | ||
3 | 'messenger_api_contact_store.c', | ||
4 | 'messenger_api_message.c', | ||
5 | 'messenger_api_list_tunnels.c', | ||
6 | 'messenger_api_util.c', | ||
7 | 'messenger_api_handle.c', | ||
8 | 'messenger_api_room.c'] | ||
9 | |||
10 | gnunetservicemessenger_src = ['gnunet-service-messenger.c', | ||
11 | 'gnunet-service-messenger_service.c', | ||
12 | 'gnunet-service-messenger_list_handles.c', | ||
13 | 'gnunet-service-messenger_list_messages.c', | ||
14 | 'gnunet-service-messenger_member_session.c', | ||
15 | 'gnunet-service-messenger_member.c', | ||
16 | 'gnunet-service-messenger_member_store.c', | ||
17 | 'gnunet-service-messenger_message_handle.c', | ||
18 | 'gnunet-service-messenger_message_kind.c', | ||
19 | 'gnunet-service-messenger_message_recv.c', | ||
20 | 'gnunet-service-messenger_message_send.c', | ||
21 | 'gnunet-service-messenger_message_state.c', | ||
22 | 'gnunet-service-messenger_message_store.c', | ||
23 | 'gnunet-service-messenger_operation_store.c', | ||
24 | 'gnunet-service-messenger_operation.c', | ||
25 | 'gnunet-service-messenger_basement.c', | ||
26 | 'gnunet-service-messenger_ego_store.c', | ||
27 | 'gnunet-service-messenger_handle.c', | ||
28 | 'gnunet-service-messenger_room.c', | ||
29 | 'gnunet-service-messenger_tunnel.c'] | ||
30 | |||
31 | configure_file(input : 'messenger.conf.in', | ||
32 | output : 'messenger.conf', | ||
33 | configuration : cdata, | ||
34 | install: true, | ||
35 | install_dir: pkgcfgdir) | ||
36 | |||
37 | |||
38 | if get_option('monolith') | ||
39 | foreach p : libgnunetmessenger_src + gnunetservicemessenger_src | ||
40 | gnunet_src += 'messenger/' + p | ||
41 | endforeach | ||
42 | subdir_done() | ||
43 | endif | ||
44 | |||
45 | libgnunetmessenger = library('gnunetmessenger', | ||
46 | libgnunetmessenger_src, | ||
47 | soversion: '0', | ||
48 | version: '0.0.0', | ||
49 | dependencies: [libgnunetutil_dep, | ||
50 | libgnunetcadet_dep, | ||
51 | libgnunetidentity_dep], | ||
52 | include_directories: [incdir, configuration_inc], | ||
53 | install: true, | ||
54 | install_dir: get_option('libdir')) | ||
55 | libgnunetmessenger_dep = declare_dependency(link_with : libgnunetmessenger) | ||
56 | pkg.generate(libgnunetmessenger, url: 'https://www.gnunet.org', | ||
57 | description : 'Provides API to access the GNUnet Messenger subsystem') | ||
58 | |||
59 | shared_module('gnunet_plugin_gnsrecord_messenger', | ||
60 | ['plugin_gnsrecord_messenger.c'], | ||
61 | dependencies: [libgnunetutil_dep, libgnunetgnsrecord_dep, | ||
62 | libgnunetmessenger_dep], | ||
63 | include_directories: [incdir, configuration_inc], | ||
64 | install: true, | ||
65 | install_dir: get_option('libdir')/'gnunet') | ||
66 | |||
67 | executable ('gnunet-messenger', | ||
68 | 'gnunet-messenger.c', | ||
69 | dependencies: [libgnunetmessenger_dep, | ||
70 | libgnunetutil_dep], | ||
71 | include_directories: [incdir, configuration_inc], | ||
72 | install: true, | ||
73 | install_dir: get_option('bindir')) | ||
74 | executable ('gnunet-service-messenger', | ||
75 | gnunetservicemessenger_src, | ||
76 | dependencies: [libgnunetmessenger_dep, | ||
77 | libgnunetutil_dep, | ||
78 | libgnunetidentity_dep, | ||
79 | libgnunetcadet_dep], | ||
80 | include_directories: [incdir, configuration_inc], | ||
81 | install: true, | ||
82 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
83 | |||
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index ac63f16ca..31d0c94b8 100644 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2021 GNUnet e.V. | 3 | Copyright (C) 2020--2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -41,7 +41,8 @@ struct GNUNET_MESSENGER_ShortMessage | |||
41 | struct GNUNET_MESSENGER_Message* | 41 | struct GNUNET_MESSENGER_Message* |
42 | create_message (enum GNUNET_MESSENGER_MessageKind kind) | 42 | create_message (enum GNUNET_MESSENGER_MessageKind kind) |
43 | { | 43 | { |
44 | struct GNUNET_MESSENGER_Message *message = GNUNET_new(struct GNUNET_MESSENGER_Message); | 44 | struct GNUNET_MESSENGER_Message *message = GNUNET_new (struct |
45 | GNUNET_MESSENGER_Message); | ||
45 | 46 | ||
46 | message->header.kind = kind; | 47 | message->header.kind = kind; |
47 | 48 | ||
@@ -67,32 +68,36 @@ create_message (enum GNUNET_MESSENGER_MessageKind kind) | |||
67 | return message; | 68 | return message; |
68 | } | 69 | } |
69 | 70 | ||
71 | |||
70 | struct GNUNET_MESSENGER_Message* | 72 | struct GNUNET_MESSENGER_Message* |
71 | copy_message (const struct GNUNET_MESSENGER_Message *message) | 73 | copy_message (const struct GNUNET_MESSENGER_Message *message) |
72 | { | 74 | { |
73 | GNUNET_assert(message); | 75 | GNUNET_assert (message); |
74 | 76 | ||
75 | struct GNUNET_MESSENGER_Message *copy = GNUNET_new(struct GNUNET_MESSENGER_Message); | 77 | struct GNUNET_MESSENGER_Message *copy = GNUNET_new (struct |
78 | GNUNET_MESSENGER_Message); | ||
76 | 79 | ||
77 | GNUNET_memcpy(copy, message, sizeof(struct GNUNET_MESSENGER_Message)); | 80 | GNUNET_memcpy (copy, message, sizeof(struct GNUNET_MESSENGER_Message)); |
78 | 81 | ||
79 | switch (message->header.kind) | 82 | switch (message->header.kind) |
80 | { | 83 | { |
81 | case GNUNET_MESSENGER_KIND_NAME: | 84 | case GNUNET_MESSENGER_KIND_NAME: |
82 | copy->body.name.name = GNUNET_strdup(message->body.name.name); | 85 | copy->body.name.name = GNUNET_strdup (message->body.name.name); |
83 | break; | 86 | break; |
84 | case GNUNET_MESSENGER_KIND_TEXT: | 87 | case GNUNET_MESSENGER_KIND_TEXT: |
85 | copy->body.text.text = GNUNET_strdup(message->body.text.text); | 88 | copy->body.text.text = GNUNET_strdup (message->body.text.text); |
86 | break; | 89 | break; |
87 | case GNUNET_MESSENGER_KIND_FILE: | 90 | case GNUNET_MESSENGER_KIND_FILE: |
88 | copy->body.file.uri = GNUNET_strdup(message->body.file.uri); | 91 | copy->body.file.uri = GNUNET_strdup (message->body.file.uri); |
89 | break; | 92 | break; |
90 | case GNUNET_MESSENGER_KIND_PRIVATE: | 93 | case GNUNET_MESSENGER_KIND_PRIVATE: |
91 | copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc(copy->body.privacy.length) : NULL; | 94 | copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc ( |
95 | copy->body.privacy.length) : NULL; | ||
92 | 96 | ||
93 | if (copy->body.privacy.data) | 97 | if (copy->body.privacy.data) |
94 | { | 98 | { |
95 | GNUNET_memcpy(copy->body.privacy.data, message->body.privacy.data, copy->body.privacy.length); | 99 | GNUNET_memcpy (copy->body.privacy.data, message->body.privacy.data, |
100 | copy->body.privacy.length); | ||
96 | } | 101 | } |
97 | 102 | ||
98 | break; | 103 | break; |
@@ -103,6 +108,7 @@ copy_message (const struct GNUNET_MESSENGER_Message *message) | |||
103 | return copy; | 108 | return copy; |
104 | } | 109 | } |
105 | 110 | ||
111 | |||
106 | static void | 112 | static void |
107 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, | 113 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, |
108 | struct GNUNET_MESSENGER_MessageBody *body) | 114 | struct GNUNET_MESSENGER_MessageBody *body) |
@@ -110,44 +116,47 @@ destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
110 | switch (kind) | 116 | switch (kind) |
111 | { | 117 | { |
112 | case GNUNET_MESSENGER_KIND_NAME: | 118 | case GNUNET_MESSENGER_KIND_NAME: |
113 | GNUNET_free(body->name.name); | 119 | GNUNET_free (body->name.name); |
114 | break; | 120 | break; |
115 | case GNUNET_MESSENGER_KIND_TEXT: | 121 | case GNUNET_MESSENGER_KIND_TEXT: |
116 | GNUNET_free(body->text.text); | 122 | GNUNET_free (body->text.text); |
117 | break; | 123 | break; |
118 | case GNUNET_MESSENGER_KIND_FILE: | 124 | case GNUNET_MESSENGER_KIND_FILE: |
119 | GNUNET_free(body->file.uri); | 125 | GNUNET_free (body->file.uri); |
120 | break; | 126 | break; |
121 | case GNUNET_MESSENGER_KIND_PRIVATE: | 127 | case GNUNET_MESSENGER_KIND_PRIVATE: |
122 | GNUNET_free(body->privacy.data); | 128 | GNUNET_free (body->privacy.data); |
123 | break; | 129 | break; |
124 | default: | 130 | default: |
125 | break; | 131 | break; |
126 | } | 132 | } |
127 | } | 133 | } |
128 | 134 | ||
135 | |||
129 | void | 136 | void |
130 | cleanup_message (struct GNUNET_MESSENGER_Message *message) | 137 | cleanup_message (struct GNUNET_MESSENGER_Message *message) |
131 | { | 138 | { |
132 | GNUNET_assert(message); | 139 | GNUNET_assert (message); |
133 | 140 | ||
134 | destroy_message_body (message->header.kind, &(message->body)); | 141 | destroy_message_body (message->header.kind, &(message->body)); |
135 | } | 142 | } |
136 | 143 | ||
144 | |||
137 | void | 145 | void |
138 | destroy_message (struct GNUNET_MESSENGER_Message *message) | 146 | destroy_message (struct GNUNET_MESSENGER_Message *message) |
139 | { | 147 | { |
140 | GNUNET_assert(message); | 148 | GNUNET_assert (message); |
141 | 149 | ||
142 | destroy_message_body (message->header.kind, &(message->body)); | 150 | destroy_message_body (message->header.kind, &(message->body)); |
143 | 151 | ||
144 | GNUNET_free(message); | 152 | GNUNET_free (message); |
145 | } | 153 | } |
146 | 154 | ||
155 | |||
147 | int | 156 | int |
148 | is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) | 157 | is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) |
149 | { | 158 | { |
150 | GNUNET_assert(message); | 159 | GNUNET_assert (message); |
151 | 160 | ||
152 | if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) || | 161 | if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) || |
153 | (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind) || | 162 | (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind) || |
@@ -159,15 +168,18 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) | |||
159 | return GNUNET_NO; | 168 | return GNUNET_NO; |
160 | } | 169 | } |
161 | 170 | ||
171 | |||
162 | static void | 172 | static void |
163 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, | 173 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, |
164 | struct GNUNET_MESSENGER_ShortMessage *shortened) | 174 | struct GNUNET_MESSENGER_ShortMessage *shortened) |
165 | { | 175 | { |
166 | shortened->kind = message->header.kind; | 176 | shortened->kind = message->header.kind; |
167 | 177 | ||
168 | GNUNET_memcpy(&(shortened->body), &(message->body), sizeof(struct GNUNET_MESSENGER_MessageBody)); | 178 | GNUNET_memcpy (&(shortened->body), &(message->body), sizeof(struct |
179 | GNUNET_MESSENGER_MessageBody)); | ||
169 | } | 180 | } |
170 | 181 | ||
182 | |||
171 | static void | 183 | static void |
172 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, | 184 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, |
173 | struct GNUNET_MESSENGER_Message *message) | 185 | struct GNUNET_MESSENGER_Message *message) |
@@ -176,9 +188,11 @@ unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, | |||
176 | 188 | ||
177 | message->header.kind = shortened->kind; | 189 | message->header.kind = shortened->kind; |
178 | 190 | ||
179 | GNUNET_memcpy(&(message->body), &(shortened->body), sizeof(struct GNUNET_MESSENGER_MessageBody)); | 191 | GNUNET_memcpy (&(message->body), &(shortened->body), sizeof(struct |
192 | GNUNET_MESSENGER_MessageBody)); | ||
180 | } | 193 | } |
181 | 194 | ||
195 | |||
182 | #define member_size(type, member) sizeof(((type*) NULL)->member) | 196 | #define member_size(type, member) sizeof(((type*) NULL)->member) |
183 | 197 | ||
184 | static uint16_t | 198 | static uint16_t |
@@ -189,40 +203,40 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
189 | switch (kind) | 203 | switch (kind) |
190 | { | 204 | { |
191 | case GNUNET_MESSENGER_KIND_INFO: | 205 | case GNUNET_MESSENGER_KIND_INFO: |
192 | length += member_size(struct GNUNET_MESSENGER_Message, body.info.messenger_version); | 206 | length += member_size (struct GNUNET_MESSENGER_Message, |
207 | body.info.messenger_version); | ||
193 | break; | 208 | break; |
194 | case GNUNET_MESSENGER_KIND_PEER: | 209 | case GNUNET_MESSENGER_KIND_PEER: |
195 | length += member_size(struct GNUNET_MESSENGER_Message, body.peer.peer); | 210 | length += member_size (struct GNUNET_MESSENGER_Message, body.peer.peer); |
196 | break; | 211 | break; |
197 | case GNUNET_MESSENGER_KIND_ID: | 212 | case GNUNET_MESSENGER_KIND_ID: |
198 | length += member_size(struct GNUNET_MESSENGER_Message, body.id.id); | 213 | length += member_size (struct GNUNET_MESSENGER_Message, body.id.id); |
199 | break; | 214 | break; |
200 | case GNUNET_MESSENGER_KIND_MISS: | 215 | case GNUNET_MESSENGER_KIND_MISS: |
201 | length += member_size(struct GNUNET_MESSENGER_Message, body.miss.peer); | 216 | length += member_size (struct GNUNET_MESSENGER_Message, body.miss.peer); |
202 | break; | 217 | break; |
203 | case GNUNET_MESSENGER_KIND_MERGE: | 218 | case GNUNET_MESSENGER_KIND_MERGE: |
204 | length += member_size(struct GNUNET_MESSENGER_Message, body.merge.previous); | 219 | length += member_size (struct GNUNET_MESSENGER_Message, |
220 | body.merge.previous); | ||
205 | break; | 221 | break; |
206 | case GNUNET_MESSENGER_KIND_REQUEST: | 222 | case GNUNET_MESSENGER_KIND_REQUEST: |
207 | length += member_size(struct GNUNET_MESSENGER_Message, body.request.hash); | 223 | length += member_size (struct GNUNET_MESSENGER_Message, body.request.hash); |
208 | break; | 224 | break; |
209 | case GNUNET_MESSENGER_KIND_INVITE: | 225 | case GNUNET_MESSENGER_KIND_INVITE: |
210 | length += member_size(struct GNUNET_MESSENGER_Message, body.invite.door); | 226 | length += member_size (struct GNUNET_MESSENGER_Message, body.invite.door); |
211 | length += member_size(struct GNUNET_MESSENGER_Message, body.invite.key); | 227 | length += member_size (struct GNUNET_MESSENGER_Message, body.invite.key); |
212 | break; | 228 | break; |
213 | case GNUNET_MESSENGER_KIND_TEXT: | 229 | case GNUNET_MESSENGER_KIND_TEXT: |
214 | break; | 230 | break; |
215 | case GNUNET_MESSENGER_KIND_FILE: | 231 | case GNUNET_MESSENGER_KIND_FILE: |
216 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.key); | 232 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.key); |
217 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.hash); | 233 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.hash); |
218 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.name); | 234 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.name); |
219 | break; | ||
220 | case GNUNET_MESSENGER_KIND_PRIVATE: | ||
221 | length += member_size(struct GNUNET_MESSENGER_Message, body.privacy.key); | ||
222 | break; | 235 | break; |
223 | case GNUNET_MESSENGER_KIND_DELETE: | 236 | case GNUNET_MESSENGER_KIND_DELETE: |
224 | length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.hash); | 237 | length += member_size (struct GNUNET_MESSENGER_Message, body.deletion.hash); |
225 | length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.delay); | 238 | length += member_size (struct GNUNET_MESSENGER_Message, |
239 | body.deletion.delay); | ||
226 | break; | 240 | break; |
227 | default: | 241 | default: |
228 | break; | 242 | break; |
@@ -231,6 +245,7 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
231 | return length; | 245 | return length; |
232 | } | 246 | } |
233 | 247 | ||
248 | |||
234 | typedef uint32_t kind_t; | 249 | typedef uint32_t kind_t; |
235 | 250 | ||
236 | uint16_t | 251 | uint16_t |
@@ -241,9 +256,9 @@ get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
241 | 256 | ||
242 | if (GNUNET_YES == include_header) | 257 | if (GNUNET_YES == include_header) |
243 | { | 258 | { |
244 | length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp); | 259 | length += member_size (struct GNUNET_MESSENGER_Message, header.timestamp); |
245 | length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id); | 260 | length += member_size (struct GNUNET_MESSENGER_Message, header.sender_id); |
246 | length += member_size(struct GNUNET_MESSENGER_Message, header.previous); | 261 | length += member_size (struct GNUNET_MESSENGER_Message, header.previous); |
247 | } | 262 | } |
248 | 263 | ||
249 | length += sizeof(kind_t); | 264 | length += sizeof(kind_t); |
@@ -251,6 +266,7 @@ get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
251 | return length + get_message_body_kind_size (kind); | 266 | return length + get_message_body_kind_size (kind); |
252 | } | 267 | } |
253 | 268 | ||
269 | |||
254 | static uint16_t | 270 | static uint16_t |
255 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | 271 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, |
256 | const struct GNUNET_MESSENGER_MessageBody *body) | 272 | const struct GNUNET_MESSENGER_MessageBody *body) |
@@ -260,16 +276,16 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
260 | switch (kind) | 276 | switch (kind) |
261 | { | 277 | { |
262 | case GNUNET_MESSENGER_KIND_INFO: | 278 | case GNUNET_MESSENGER_KIND_INFO: |
263 | length += GNUNET_IDENTITY_public_key_get_length(&(body->info.host_key)); | 279 | length += GNUNET_IDENTITY_public_key_get_length (&(body->info.host_key)); |
264 | break; | 280 | break; |
265 | case GNUNET_MESSENGER_KIND_JOIN: | 281 | case GNUNET_MESSENGER_KIND_JOIN: |
266 | length += GNUNET_IDENTITY_public_key_get_length(&(body->join.key)); | 282 | length += GNUNET_IDENTITY_public_key_get_length (&(body->join.key)); |
267 | break; | 283 | break; |
268 | case GNUNET_MESSENGER_KIND_NAME: | 284 | case GNUNET_MESSENGER_KIND_NAME: |
269 | length += (body->name.name ? strlen (body->name.name) : 0); | 285 | length += (body->name.name ? strlen (body->name.name) : 0); |
270 | break; | 286 | break; |
271 | case GNUNET_MESSENGER_KIND_KEY: | 287 | case GNUNET_MESSENGER_KIND_KEY: |
272 | length += GNUNET_IDENTITY_public_key_get_length(&(body->key.key)); | 288 | length += GNUNET_IDENTITY_public_key_get_length (&(body->key.key)); |
273 | break; | 289 | break; |
274 | case GNUNET_MESSENGER_KIND_TEXT: | 290 | case GNUNET_MESSENGER_KIND_TEXT: |
275 | length += strlen (body->text.text); | 291 | length += strlen (body->text.text); |
@@ -287,16 +303,18 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
287 | return length; | 303 | return length; |
288 | } | 304 | } |
289 | 305 | ||
306 | |||
290 | uint16_t | 307 | uint16_t |
291 | get_message_size (const struct GNUNET_MESSENGER_Message *message, | 308 | get_message_size (const struct GNUNET_MESSENGER_Message *message, |
292 | int include_header) | 309 | int include_header) |
293 | { | 310 | { |
294 | GNUNET_assert(message); | 311 | GNUNET_assert (message); |
295 | 312 | ||
296 | uint16_t length = 0; | 313 | uint16_t length = 0; |
297 | 314 | ||
298 | if (GNUNET_YES == include_header) | 315 | if (GNUNET_YES == include_header) |
299 | length += GNUNET_IDENTITY_signature_get_length(&(message->header.signature)); | 316 | length += GNUNET_IDENTITY_signature_get_length ( |
317 | &(message->header.signature)); | ||
300 | 318 | ||
301 | length += get_message_kind_size (message->header.kind, include_header); | 319 | length += get_message_kind_size (message->header.kind, include_header); |
302 | length += get_message_body_size (message->header.kind, &(message->body)); | 320 | length += get_message_body_size (message->header.kind, &(message->body)); |
@@ -304,6 +322,7 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message, | |||
304 | return length; | 322 | return length; |
305 | } | 323 | } |
306 | 324 | ||
325 | |||
307 | static uint16_t | 326 | static uint16_t |
308 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, | 327 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, |
309 | int include_body) | 328 | int include_body) |
@@ -312,19 +331,24 @@ get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, | |||
312 | 331 | ||
313 | if (message) | 332 | if (message) |
314 | return minimum_size + get_message_body_kind_size (message->kind) | 333 | return minimum_size + get_message_body_kind_size (message->kind) |
315 | + (include_body == GNUNET_YES? get_message_body_size (message->kind, &(message->body)) : 0); | 334 | + (include_body == GNUNET_YES? get_message_body_size (message->kind, |
335 | &(message->body)) | ||
336 | : 0); | ||
316 | else | 337 | else |
317 | return minimum_size; | 338 | return minimum_size; |
318 | } | 339 | } |
319 | 340 | ||
341 | |||
320 | static uint16_t | 342 | static uint16_t |
321 | calc_usual_padding () | 343 | calc_usual_padding () |
322 | { | 344 | { |
323 | uint16_t padding = 0; | 345 | uint16_t padding = 0; |
324 | uint16_t kind_size; | 346 | uint16_t kind_size; |
325 | 347 | ||
326 | for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) { | 348 | for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) |
327 | kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, GNUNET_YES); | 349 | { |
350 | kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, | ||
351 | GNUNET_YES); | ||
328 | 352 | ||
329 | if (kind_size > padding) | 353 | if (kind_size > padding) |
330 | padding = kind_size; | 354 | padding = kind_size; |
@@ -333,6 +357,7 @@ calc_usual_padding () | |||
333 | return padding + GNUNET_MESSENGER_PADDING_MIN; | 357 | return padding + GNUNET_MESSENGER_PADDING_MIN; |
334 | } | 358 | } |
335 | 359 | ||
360 | |||
336 | #define max(x, y) (x > y? x : y) | 361 | #define max(x, y) (x > y? x : y) |
337 | 362 | ||
338 | static uint16_t | 363 | static uint16_t |
@@ -340,13 +365,13 @@ calc_padded_length (uint16_t length) | |||
340 | { | 365 | { |
341 | static uint16_t usual_padding = 0; | 366 | static uint16_t usual_padding = 0; |
342 | 367 | ||
343 | if (!usual_padding) | 368 | if (! usual_padding) |
344 | usual_padding = calc_usual_padding(); | 369 | usual_padding = calc_usual_padding (); |
345 | 370 | ||
346 | const uint16_t padded_length = max( | 371 | const uint16_t padded_length = max ( |
347 | length + GNUNET_MESSENGER_PADDING_MIN, | 372 | length + GNUNET_MESSENGER_PADDING_MIN, |
348 | usual_padding | 373 | usual_padding |
349 | ); | 374 | ); |
350 | 375 | ||
351 | if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0) | 376 | if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0) |
352 | return GNUNET_MESSENGER_PADDING_LEVEL0; | 377 | return GNUNET_MESSENGER_PADDING_LEVEL0; |
@@ -361,34 +386,35 @@ calc_padded_length (uint16_t length) | |||
361 | 386 | ||
362 | } | 387 | } |
363 | 388 | ||
389 | |||
364 | #define min(x, y) (x < y? x : y) | 390 | #define min(x, y) (x < y? x : y) |
365 | 391 | ||
366 | #define encode_step_ext(dst, offset, src, size) do { \ | 392 | #define encode_step_ext(dst, offset, src, size) do { \ |
367 | GNUNET_memcpy(dst + offset, src, size); \ | 393 | GNUNET_memcpy (dst + offset, src, size); \ |
368 | offset += size; \ | 394 | offset += size; \ |
369 | } while (0) | 395 | } while (0) |
370 | 396 | ||
371 | #define encode_step(dst, offset, src) do { \ | 397 | #define encode_step(dst, offset, src) do { \ |
372 | encode_step_ext(dst, offset, src, sizeof(*src)); \ | 398 | encode_step_ext (dst, offset, src, sizeof(*src)); \ |
373 | } while (0) | 399 | } while (0) |
374 | 400 | ||
375 | #define encode_step_key(dst, offset, src, length) do { \ | 401 | #define encode_step_key(dst, offset, src, length) do { \ |
376 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer( \ | 402 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer ( \ |
377 | src, dst + offset, length - offset \ | 403 | src, dst + offset, length - offset \ |
378 | ); \ | 404 | ); \ |
379 | if (result < 0) \ | 405 | if (result < 0) \ |
380 | GNUNET_break (0); \ | 406 | GNUNET_break (0); \ |
381 | else \ | 407 | else \ |
382 | offset += result; \ | 408 | offset += result; \ |
383 | } while (0) | 409 | } while (0) |
384 | 410 | ||
385 | #define encode_step_signature(dst, offset, src, length) do { \ | 411 | #define encode_step_signature(dst, offset, src, length) do { \ |
386 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer( \ | 412 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer ( \ |
387 | src, dst + offset, length - offset \ | 413 | src, dst + offset, length - offset \ |
388 | ); \ | 414 | ); \ |
389 | if (result < 0) \ | 415 | if (result < 0) \ |
390 | GNUNET_break (0); \ | 416 | GNUNET_break (0); \ |
391 | else \ | 417 | else \ |
392 | offset += result; \ | 418 | offset += result; \ |
393 | } while (0) | 419 | } while (0) |
394 | 420 | ||
@@ -403,56 +429,63 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
403 | switch (kind) | 429 | switch (kind) |
404 | { | 430 | { |
405 | case GNUNET_MESSENGER_KIND_INFO: | 431 | case GNUNET_MESSENGER_KIND_INFO: |
406 | version = GNUNET_htobe32(body->info.messenger_version); | 432 | version = GNUNET_htobe32 (body->info.messenger_version); |
407 | 433 | ||
408 | encode_step_key(buffer, offset, &(body->info.host_key), length); | 434 | encode_step_key (buffer, offset, &(body->info.host_key), length); |
409 | encode_step(buffer, offset, &version); | 435 | encode_step (buffer, offset, &version); |
410 | break; | 436 | break; |
411 | case GNUNET_MESSENGER_KIND_JOIN: | 437 | case GNUNET_MESSENGER_KIND_JOIN: |
412 | encode_step_key(buffer, offset, &(body->join.key), length); | 438 | encode_step_key (buffer, offset, &(body->join.key), length); |
413 | break; | 439 | break; |
414 | case GNUNET_MESSENGER_KIND_NAME: | 440 | case GNUNET_MESSENGER_KIND_NAME: |
415 | if (body->name.name) | 441 | if (body->name.name) |
416 | encode_step_ext(buffer, offset, body->name.name, min(length - offset, strlen(body->name.name))); | 442 | encode_step_ext (buffer, offset, body->name.name, min (length - offset, |
443 | strlen ( | ||
444 | body->name.name))); | ||
417 | break; | 445 | break; |
418 | case GNUNET_MESSENGER_KIND_KEY: | 446 | case GNUNET_MESSENGER_KIND_KEY: |
419 | encode_step_key(buffer, offset, &(body->key.key), length); | 447 | encode_step_key (buffer, offset, &(body->key.key), length); |
420 | break; | 448 | break; |
421 | case GNUNET_MESSENGER_KIND_PEER: | 449 | case GNUNET_MESSENGER_KIND_PEER: |
422 | encode_step(buffer, offset, &(body->peer.peer)); | 450 | encode_step (buffer, offset, &(body->peer.peer)); |
423 | break; | 451 | break; |
424 | case GNUNET_MESSENGER_KIND_ID: | 452 | case GNUNET_MESSENGER_KIND_ID: |
425 | encode_step(buffer, offset, &(body->id.id)); | 453 | encode_step (buffer, offset, &(body->id.id)); |
426 | break; | 454 | break; |
427 | case GNUNET_MESSENGER_KIND_MISS: | 455 | case GNUNET_MESSENGER_KIND_MISS: |
428 | encode_step(buffer, offset, &(body->miss.peer)); | 456 | encode_step (buffer, offset, &(body->miss.peer)); |
429 | break; | 457 | break; |
430 | case GNUNET_MESSENGER_KIND_MERGE: | 458 | case GNUNET_MESSENGER_KIND_MERGE: |
431 | encode_step(buffer, offset, &(body->merge.previous)); | 459 | encode_step (buffer, offset, &(body->merge.previous)); |
432 | break; | 460 | break; |
433 | case GNUNET_MESSENGER_KIND_REQUEST: | 461 | case GNUNET_MESSENGER_KIND_REQUEST: |
434 | encode_step(buffer, offset, &(body->request.hash)); | 462 | encode_step (buffer, offset, &(body->request.hash)); |
435 | break; | 463 | break; |
436 | case GNUNET_MESSENGER_KIND_INVITE: | 464 | case GNUNET_MESSENGER_KIND_INVITE: |
437 | encode_step(buffer, offset, &(body->invite.door)); | 465 | encode_step (buffer, offset, &(body->invite.door)); |
438 | encode_step(buffer, offset, &(body->invite.key)); | 466 | encode_step (buffer, offset, &(body->invite.key)); |
439 | break; | 467 | break; |
440 | case GNUNET_MESSENGER_KIND_TEXT: | 468 | case GNUNET_MESSENGER_KIND_TEXT: |
441 | encode_step_ext(buffer, offset, body->text.text, min(length - offset, strlen(body->text.text))); | 469 | encode_step_ext (buffer, offset, body->text.text, min (length - offset, |
470 | strlen ( | ||
471 | body->text.text))); | ||
442 | break; | 472 | break; |
443 | case GNUNET_MESSENGER_KIND_FILE: | 473 | case GNUNET_MESSENGER_KIND_FILE: |
444 | encode_step(buffer, offset, &(body->file.key)); | 474 | encode_step (buffer, offset, &(body->file.key)); |
445 | encode_step(buffer, offset, &(body->file.hash)); | 475 | encode_step (buffer, offset, &(body->file.hash)); |
446 | encode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name)); | 476 | encode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name)); |
447 | encode_step_ext(buffer, offset, body->file.uri, min(length - offset, strlen(body->file.uri))); | 477 | encode_step_ext (buffer, offset, body->file.uri, min (length - offset, |
478 | strlen ( | ||
479 | body->file.uri))); | ||
448 | break; | 480 | break; |
449 | case GNUNET_MESSENGER_KIND_PRIVATE: | 481 | case GNUNET_MESSENGER_KIND_PRIVATE: |
450 | encode_step(buffer, offset, &(body->privacy.key)); | 482 | encode_step_ext (buffer, offset, body->privacy.data, min (length - offset, |
451 | encode_step_ext(buffer, offset, body->privacy.data, min(length - offset, body->privacy.length)); | 483 | body->privacy. |
484 | length)); | ||
452 | break; | 485 | break; |
453 | case GNUNET_MESSENGER_KIND_DELETE: | 486 | case GNUNET_MESSENGER_KIND_DELETE: |
454 | encode_step(buffer, offset, &(body->deletion.hash)); | 487 | encode_step (buffer, offset, &(body->deletion.hash)); |
455 | encode_step(buffer, offset, &(body->deletion.delay)); | 488 | encode_step (buffer, offset, &(body->deletion.delay)); |
456 | break; | 489 | break; |
457 | default: | 490 | default: |
458 | break; | 491 | break; |
@@ -464,43 +497,48 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
464 | const uint16_t padding = length - offset; | 497 | const uint16_t padding = length - offset; |
465 | const uint16_t used_padding = sizeof(padding) + sizeof(char); | 498 | const uint16_t used_padding = sizeof(padding) + sizeof(char); |
466 | 499 | ||
467 | GNUNET_assert(padding >= used_padding); | 500 | GNUNET_assert (padding >= used_padding); |
468 | 501 | ||
469 | buffer[offset++] = '\0'; | 502 | buffer[offset++] = '\0'; |
470 | 503 | ||
471 | if (padding > used_padding) | 504 | if (padding > used_padding) |
472 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, buffer + offset, padding - used_padding); | 505 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, buffer + offset, |
506 | padding - used_padding); | ||
473 | 507 | ||
474 | GNUNET_memcpy(buffer + length - sizeof(padding), &padding, sizeof(padding)); | 508 | GNUNET_memcpy (buffer + length - sizeof(padding), &padding, sizeof(padding)); |
475 | } | 509 | } |
476 | 510 | ||
511 | |||
477 | void | 512 | void |
478 | encode_message (const struct GNUNET_MESSENGER_Message *message, | 513 | encode_message (const struct GNUNET_MESSENGER_Message *message, |
479 | uint16_t length, | 514 | uint16_t length, |
480 | char *buffer, | 515 | char *buffer, |
481 | int include_header) | 516 | int include_header) |
482 | { | 517 | { |
483 | GNUNET_assert((message) && (buffer)); | 518 | GNUNET_assert ((message) && (buffer)); |
484 | 519 | ||
485 | uint16_t offset = 0; | 520 | uint16_t offset = 0; |
486 | 521 | ||
487 | if (GNUNET_YES == include_header) | 522 | if (GNUNET_YES == include_header) |
488 | encode_step_signature(buffer, offset, &(message->header.signature), length); | 523 | encode_step_signature (buffer, offset, &(message->header.signature), |
524 | length); | ||
489 | 525 | ||
490 | const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind); | 526 | const kind_t kind = GNUNET_htobe32 ((kind_t) message->header.kind); |
491 | 527 | ||
492 | if (GNUNET_YES == include_header) | 528 | if (GNUNET_YES == include_header) |
493 | { | 529 | { |
494 | encode_step(buffer, offset, &(message->header.timestamp)); | 530 | encode_step (buffer, offset, &(message->header.timestamp)); |
495 | encode_step(buffer, offset, &(message->header.sender_id)); | 531 | encode_step (buffer, offset, &(message->header.sender_id)); |
496 | encode_step(buffer, offset, &(message->header.previous)); | 532 | encode_step (buffer, offset, &(message->header.previous)); |
497 | } | 533 | } |
498 | 534 | ||
499 | encode_step(buffer, offset, &kind); | 535 | encode_step (buffer, offset, &kind); |
500 | 536 | ||
501 | encode_message_body (message->header.kind, &(message->body), length, buffer, offset); | 537 | encode_message_body (message->header.kind, &(message->body), length, buffer, |
538 | offset); | ||
502 | } | 539 | } |
503 | 540 | ||
541 | |||
504 | static void | 542 | static void |
505 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, | 543 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, |
506 | uint16_t length, | 544 | uint16_t length, |
@@ -509,45 +547,46 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, | |||
509 | struct GNUNET_HashCode hash; | 547 | struct GNUNET_HashCode hash; |
510 | uint16_t offset = sizeof(hash); | 548 | uint16_t offset = sizeof(hash); |
511 | 549 | ||
512 | const kind_t kind = GNUNET_htobe32((kind_t) message->kind); | 550 | const kind_t kind = GNUNET_htobe32 ((kind_t) message->kind); |
513 | 551 | ||
514 | encode_step(buffer, offset, &kind); | 552 | encode_step (buffer, offset, &kind); |
515 | 553 | ||
516 | encode_message_body (message->kind, &(message->body), length, buffer, offset); | 554 | encode_message_body (message->kind, &(message->body), length, buffer, offset); |
517 | 555 | ||
518 | GNUNET_CRYPTO_hash( | 556 | GNUNET_CRYPTO_hash ( |
519 | buffer + sizeof(hash), | 557 | buffer + sizeof(hash), |
520 | length - sizeof(hash), | 558 | length - sizeof(hash), |
521 | &hash | 559 | &hash |
522 | ); | 560 | ); |
523 | 561 | ||
524 | GNUNET_memcpy(buffer, &hash, sizeof(hash)); | 562 | GNUNET_memcpy (buffer, &hash, sizeof(hash)); |
525 | } | 563 | } |
526 | 564 | ||
565 | |||
527 | #define decode_step_ext(src, offset, dst, size) do { \ | 566 | #define decode_step_ext(src, offset, dst, size) do { \ |
528 | GNUNET_memcpy(dst, src + offset, size); \ | 567 | GNUNET_memcpy (dst, src + offset, size); \ |
529 | offset += size; \ | 568 | offset += size; \ |
530 | } while (0) | 569 | } while (0) |
531 | 570 | ||
532 | #define decode_step(src, offset, dst) do { \ | 571 | #define decode_step(src, offset, dst) do { \ |
533 | decode_step_ext(src, offset, dst, sizeof(*dst)); \ | 572 | decode_step_ext (src, offset, dst, sizeof(*dst)); \ |
534 | } while (0) | 573 | } while (0) |
535 | 574 | ||
536 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ | 575 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ |
537 | dst = GNUNET_malloc(size + zero); \ | 576 | dst = GNUNET_malloc (size + zero); \ |
538 | if (zero) dst[size] = 0; \ | 577 | if (zero) dst[size] = 0; \ |
539 | decode_step_ext(src, offset, dst, size); \ | 578 | decode_step_ext (src, offset, dst, size); \ |
540 | } while (0) | 579 | } while (0) |
541 | 580 | ||
542 | #define decode_step_key(src, offset, dst, length) do { \ | 581 | #define decode_step_key(src, offset, dst, length) do { \ |
543 | enum GNUNET_GenericReturnValue result; \ | 582 | enum GNUNET_GenericReturnValue result; \ |
544 | size_t read; \ | 583 | size_t read; \ |
545 | result = GNUNET_IDENTITY_read_public_key_from_buffer( \ | 584 | result = GNUNET_IDENTITY_read_public_key_from_buffer ( \ |
546 | src + offset, length - offset, dst, &read \ | 585 | src + offset, length - offset, dst, &read \ |
547 | ); \ | 586 | ); \ |
548 | if (GNUNET_SYSERR == result) \ | 587 | if (GNUNET_SYSERR == result) \ |
549 | GNUNET_break(0); \ | 588 | GNUNET_break (0); \ |
550 | else \ | 589 | else \ |
551 | offset += read; \ | 590 | offset += read; \ |
552 | } while (0) | 591 | } while (0) |
553 | 592 | ||
@@ -560,7 +599,7 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
560 | { | 599 | { |
561 | uint16_t padding = 0; | 600 | uint16_t padding = 0; |
562 | 601 | ||
563 | GNUNET_memcpy(&padding, buffer + length - sizeof(padding), sizeof(padding)); | 602 | GNUNET_memcpy (&padding, buffer + length - sizeof(padding), sizeof(padding)); |
564 | 603 | ||
565 | if (padding > length - offset) | 604 | if (padding > length - offset) |
566 | padding = 0; | 605 | padding = 0; |
@@ -576,60 +615,58 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
576 | switch (*kind) | 615 | switch (*kind) |
577 | { | 616 | { |
578 | case GNUNET_MESSENGER_KIND_INFO: { | 617 | case GNUNET_MESSENGER_KIND_INFO: { |
579 | decode_step_key(buffer, offset, &(body->info.host_key), length); | 618 | decode_step_key (buffer, offset, &(body->info.host_key), length); |
580 | decode_step(buffer, offset, &version); | 619 | decode_step (buffer, offset, &version); |
581 | 620 | ||
582 | body->info.messenger_version = GNUNET_be32toh(version); | 621 | body->info.messenger_version = GNUNET_be32toh (version); |
583 | break; | 622 | break; |
584 | } case GNUNET_MESSENGER_KIND_JOIN: { | 623 | } case GNUNET_MESSENGER_KIND_JOIN: { |
585 | decode_step_key(buffer, offset, &(body->join.key), length); | 624 | decode_step_key (buffer, offset, &(body->join.key), length); |
586 | break; | 625 | break; |
587 | } case GNUNET_MESSENGER_KIND_NAME: | 626 | } case GNUNET_MESSENGER_KIND_NAME: |
588 | if (length - offset > 0) | 627 | if (length - offset > 0) |
589 | decode_step_malloc(buffer, offset, body->name.name, length - offset, 1); | 628 | decode_step_malloc (buffer, offset, body->name.name, length - offset, 1); |
590 | else | 629 | else |
591 | body->name.name = NULL; | 630 | body->name.name = NULL; |
592 | break; | 631 | break; |
593 | case GNUNET_MESSENGER_KIND_KEY: | 632 | case GNUNET_MESSENGER_KIND_KEY: |
594 | decode_step_key(buffer, offset, &(body->key.key), length); | 633 | decode_step_key (buffer, offset, &(body->key.key), length); |
595 | break; | 634 | break; |
596 | case GNUNET_MESSENGER_KIND_PEER: | 635 | case GNUNET_MESSENGER_KIND_PEER: |
597 | decode_step(buffer, offset, &(body->peer.peer)); | 636 | decode_step (buffer, offset, &(body->peer.peer)); |
598 | break; | 637 | break; |
599 | case GNUNET_MESSENGER_KIND_ID: | 638 | case GNUNET_MESSENGER_KIND_ID: |
600 | decode_step(buffer, offset, &(body->id.id)); | 639 | decode_step (buffer, offset, &(body->id.id)); |
601 | break; | 640 | break; |
602 | case GNUNET_MESSENGER_KIND_MISS: | 641 | case GNUNET_MESSENGER_KIND_MISS: |
603 | decode_step(buffer, offset, &(body->miss.peer)); | 642 | decode_step (buffer, offset, &(body->miss.peer)); |
604 | break; | 643 | break; |
605 | case GNUNET_MESSENGER_KIND_MERGE: | 644 | case GNUNET_MESSENGER_KIND_MERGE: |
606 | decode_step(buffer, offset, &(body->merge.previous)); | 645 | decode_step (buffer, offset, &(body->merge.previous)); |
607 | break; | 646 | break; |
608 | case GNUNET_MESSENGER_KIND_REQUEST: | 647 | case GNUNET_MESSENGER_KIND_REQUEST: |
609 | decode_step(buffer, offset, &(body->request.hash)); | 648 | decode_step (buffer, offset, &(body->request.hash)); |
610 | break; | 649 | break; |
611 | case GNUNET_MESSENGER_KIND_INVITE: | 650 | case GNUNET_MESSENGER_KIND_INVITE: |
612 | decode_step(buffer, offset, &(body->invite.door)); | 651 | decode_step (buffer, offset, &(body->invite.door)); |
613 | decode_step(buffer, offset, &(body->invite.key)); | 652 | decode_step (buffer, offset, &(body->invite.key)); |
614 | break; | 653 | break; |
615 | case GNUNET_MESSENGER_KIND_TEXT: | 654 | case GNUNET_MESSENGER_KIND_TEXT: |
616 | decode_step_malloc(buffer, offset, body->text.text, length - offset, 1); | 655 | decode_step_malloc (buffer, offset, body->text.text, length - offset, 1); |
617 | break; | 656 | break; |
618 | case GNUNET_MESSENGER_KIND_FILE: | 657 | case GNUNET_MESSENGER_KIND_FILE: |
619 | decode_step(buffer, offset, &(body->file.key)); | 658 | decode_step (buffer, offset, &(body->file.key)); |
620 | decode_step(buffer, offset, &(body->file.hash)); | 659 | decode_step (buffer, offset, &(body->file.hash)); |
621 | decode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name)); | 660 | decode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name)); |
622 | decode_step_malloc(buffer, offset, body->file.uri, length - offset, 1); | 661 | decode_step_malloc (buffer, offset, body->file.uri, length - offset, 1); |
623 | break; | 662 | break; |
624 | case GNUNET_MESSENGER_KIND_PRIVATE: | 663 | case GNUNET_MESSENGER_KIND_PRIVATE: |
625 | decode_step(buffer, offset, &(body->privacy.key)); | ||
626 | |||
627 | body->privacy.length = (length - offset); | 664 | body->privacy.length = (length - offset); |
628 | decode_step_malloc(buffer, offset, body->privacy.data, length - offset, 0); | 665 | decode_step_malloc (buffer, offset, body->privacy.data, length - offset, 0); |
629 | break; | 666 | break; |
630 | case GNUNET_MESSENGER_KIND_DELETE: | 667 | case GNUNET_MESSENGER_KIND_DELETE: |
631 | decode_step(buffer, offset, &(body->deletion.hash)); | 668 | decode_step (buffer, offset, &(body->deletion.hash)); |
632 | decode_step(buffer, offset, &(body->deletion.delay)); | 669 | decode_step (buffer, offset, &(body->deletion.delay)); |
633 | break; | 670 | break; |
634 | default: | 671 | default: |
635 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; | 672 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; |
@@ -639,6 +676,7 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
639 | return padding; | 676 | return padding; |
640 | } | 677 | } |
641 | 678 | ||
679 | |||
642 | int | 680 | int |
643 | decode_message (struct GNUNET_MESSENGER_Message *message, | 681 | decode_message (struct GNUNET_MESSENGER_Message *message, |
644 | uint16_t length, | 682 | uint16_t length, |
@@ -646,19 +684,20 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
646 | int include_header, | 684 | int include_header, |
647 | uint16_t *padding) | 685 | uint16_t *padding) |
648 | { | 686 | { |
649 | GNUNET_assert( | 687 | GNUNET_assert ( |
650 | (message) && | 688 | (message) && |
651 | (buffer) && | 689 | (buffer) && |
652 | (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, include_header)) | 690 | (length >= get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, |
653 | ); | 691 | include_header)) |
692 | ); | ||
654 | 693 | ||
655 | uint16_t offset = 0; | 694 | uint16_t offset = 0; |
656 | 695 | ||
657 | if (GNUNET_YES == include_header) | 696 | if (GNUNET_YES == include_header) |
658 | { | 697 | { |
659 | ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer( | 698 | ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer ( |
660 | &(message->header.signature), buffer, length - offset | 699 | &(message->header.signature), buffer, length - offset |
661 | ); | 700 | ); |
662 | 701 | ||
663 | if (result < 0) | 702 | if (result < 0) |
664 | return GNUNET_NO; | 703 | return GNUNET_NO; |
@@ -668,26 +707,30 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
668 | 707 | ||
669 | const uint16_t count = length - offset; | 708 | const uint16_t count = length - offset; |
670 | 709 | ||
671 | if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, include_header)) | 710 | if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, |
711 | include_header)) | ||
672 | return GNUNET_NO; | 712 | return GNUNET_NO; |
673 | 713 | ||
674 | kind_t kind; | 714 | kind_t kind; |
675 | 715 | ||
676 | if (GNUNET_YES == include_header) | 716 | if (GNUNET_YES == include_header) |
677 | { | 717 | { |
678 | decode_step(buffer, offset, &(message->header.timestamp)); | 718 | decode_step (buffer, offset, &(message->header.timestamp)); |
679 | decode_step(buffer, offset, &(message->header.sender_id)); | 719 | decode_step (buffer, offset, &(message->header.sender_id)); |
680 | decode_step(buffer, offset, &(message->header.previous)); | 720 | decode_step (buffer, offset, &(message->header.previous)); |
681 | } | 721 | } |
682 | 722 | ||
683 | decode_step(buffer, offset, &kind); | 723 | decode_step (buffer, offset, &kind); |
684 | 724 | ||
685 | message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind); | 725 | message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh ( |
726 | kind); | ||
686 | 727 | ||
687 | if (count < get_message_kind_size (message->header.kind, include_header)) | 728 | if (count < get_message_kind_size (message->header.kind, include_header)) |
688 | return GNUNET_NO; | 729 | return GNUNET_NO; |
689 | 730 | ||
690 | const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset); | 731 | const uint16_t result = decode_message_body (&(message->header.kind), |
732 | &(message->body), length, buffer, | ||
733 | offset); | ||
691 | 734 | ||
692 | if (padding) | 735 | if (padding) |
693 | *padding = result; | 736 | *padding = result; |
@@ -695,6 +738,7 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
695 | return GNUNET_YES; | 738 | return GNUNET_YES; |
696 | } | 739 | } |
697 | 740 | ||
741 | |||
698 | static int | 742 | static int |
699 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | 743 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, |
700 | uint16_t length, | 744 | uint16_t length, |
@@ -706,27 +750,28 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | |||
706 | if (length < get_short_message_size (NULL, GNUNET_NO)) | 750 | if (length < get_short_message_size (NULL, GNUNET_NO)) |
707 | return GNUNET_NO; | 751 | return GNUNET_NO; |
708 | 752 | ||
709 | GNUNET_memcpy(&hash, buffer, sizeof(hash)); | 753 | GNUNET_memcpy (&hash, buffer, sizeof(hash)); |
710 | 754 | ||
711 | GNUNET_CRYPTO_hash( | 755 | GNUNET_CRYPTO_hash ( |
712 | buffer + sizeof(hash), | 756 | buffer + sizeof(hash), |
713 | length - sizeof(hash), | 757 | length - sizeof(hash), |
714 | &expected | 758 | &expected |
715 | ); | 759 | ); |
716 | 760 | ||
717 | if (0 != GNUNET_CRYPTO_hash_cmp(&hash, &expected)) | 761 | if (0 != GNUNET_CRYPTO_hash_cmp (&hash, &expected)) |
718 | return GNUNET_NO; | 762 | return GNUNET_NO; |
719 | 763 | ||
720 | kind_t kind; | 764 | kind_t kind; |
721 | 765 | ||
722 | decode_step(buffer, offset, &kind); | 766 | decode_step (buffer, offset, &kind); |
723 | 767 | ||
724 | message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind); | 768 | message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh (kind); |
725 | 769 | ||
726 | if (length < get_short_message_size (message, GNUNET_NO)) | 770 | if (length < get_short_message_size (message, GNUNET_NO)) |
727 | return GNUNET_NO; | 771 | return GNUNET_NO; |
728 | 772 | ||
729 | decode_message_body (&(message->kind), &(message->body), length, buffer, offset); | 773 | decode_message_body (&(message->kind), &(message->body), length, buffer, |
774 | offset); | ||
730 | 775 | ||
731 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind) | 776 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind) |
732 | return GNUNET_NO; | 777 | return GNUNET_NO; |
@@ -734,21 +779,23 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | |||
734 | return GNUNET_YES; | 779 | return GNUNET_YES; |
735 | } | 780 | } |
736 | 781 | ||
782 | |||
737 | void | 783 | void |
738 | hash_message (const struct GNUNET_MESSENGER_Message *message, | 784 | hash_message (const struct GNUNET_MESSENGER_Message *message, |
739 | uint16_t length, | 785 | uint16_t length, |
740 | const char *buffer, | 786 | const char *buffer, |
741 | struct GNUNET_HashCode *hash) | 787 | struct GNUNET_HashCode *hash) |
742 | { | 788 | { |
743 | GNUNET_assert((message) && (buffer) && (hash)); | 789 | GNUNET_assert ((message) && (buffer) && (hash)); |
744 | 790 | ||
745 | const ssize_t offset = GNUNET_IDENTITY_signature_get_length( | 791 | const ssize_t offset = GNUNET_IDENTITY_signature_get_length ( |
746 | &(message->header.signature) | 792 | &(message->header.signature) |
747 | ); | 793 | ); |
748 | 794 | ||
749 | GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash); | 795 | GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash); |
750 | } | 796 | } |
751 | 797 | ||
798 | |||
752 | void | 799 | void |
753 | sign_message (struct GNUNET_MESSENGER_Message *message, | 800 | sign_message (struct GNUNET_MESSENGER_Message *message, |
754 | uint16_t length, | 801 | uint16_t length, |
@@ -756,26 +803,27 @@ sign_message (struct GNUNET_MESSENGER_Message *message, | |||
756 | const struct GNUNET_HashCode *hash, | 803 | const struct GNUNET_HashCode *hash, |
757 | const struct GNUNET_MESSENGER_Ego *ego) | 804 | const struct GNUNET_MESSENGER_Ego *ego) |
758 | { | 805 | { |
759 | GNUNET_assert((message) && (buffer) && (hash) && (ego)); | 806 | GNUNET_assert ((message) && (buffer) && (hash) && (ego)); |
760 | 807 | ||
761 | struct GNUNET_MESSENGER_MessageSignature signature; | 808 | struct GNUNET_MESSENGER_MessageSignature signature; |
762 | 809 | ||
763 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | 810 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); |
764 | signature.purpose.size = htonl (sizeof(signature)); | 811 | signature.purpose.size = htonl (sizeof(signature)); |
765 | 812 | ||
766 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | 813 | GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); |
767 | GNUNET_IDENTITY_sign(&(ego->priv), &signature, &(message->header.signature)); | 814 | GNUNET_IDENTITY_sign (&(ego->priv), &signature, &(message->header.signature)); |
768 | 815 | ||
769 | uint16_t offset = 0; | 816 | uint16_t offset = 0; |
770 | encode_step_signature(buffer, offset, &(message->header.signature), length); | 817 | encode_step_signature (buffer, offset, &(message->header.signature), length); |
771 | } | 818 | } |
772 | 819 | ||
820 | |||
773 | int | 821 | int |
774 | verify_message (const struct GNUNET_MESSENGER_Message *message, | 822 | verify_message (const struct GNUNET_MESSENGER_Message *message, |
775 | const struct GNUNET_HashCode *hash, | 823 | const struct GNUNET_HashCode *hash, |
776 | const struct GNUNET_IDENTITY_PublicKey *key) | 824 | const struct GNUNET_IDENTITY_PublicKey *key) |
777 | { | 825 | { |
778 | GNUNET_assert((message) && (hash) && (key)); | 826 | GNUNET_assert ((message) && (hash) && (key)); |
779 | 827 | ||
780 | if (ntohl (key->type) != ntohl (message->header.signature.type)) | 828 | if (ntohl (key->type) != ntohl (message->header.signature.type)) |
781 | return GNUNET_SYSERR; | 829 | return GNUNET_SYSERR; |
@@ -785,101 +833,131 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, | |||
785 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | 833 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); |
786 | signature.purpose.size = htonl (sizeof(signature)); | 834 | signature.purpose.size = htonl (sizeof(signature)); |
787 | 835 | ||
788 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | 836 | GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); |
789 | 837 | ||
790 | return GNUNET_IDENTITY_signature_verify(GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, &signature, | 838 | return GNUNET_IDENTITY_signature_verify ( |
791 | &(message->header.signature), key); | 839 | GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, &signature, |
840 | &(message->header.signature), key); | ||
792 | } | 841 | } |
793 | 842 | ||
843 | |||
794 | int | 844 | int |
795 | encrypt_message (struct GNUNET_MESSENGER_Message *message, | 845 | encrypt_message (struct GNUNET_MESSENGER_Message *message, |
796 | const struct GNUNET_IDENTITY_PublicKey *key) | 846 | const struct GNUNET_IDENTITY_PublicKey *key) |
797 | { | 847 | { |
798 | GNUNET_assert((message) && (key)); | 848 | GNUNET_assert ((message) && (key)); |
799 | 849 | ||
800 | struct GNUNET_MESSENGER_ShortMessage shortened; | 850 | struct GNUNET_MESSENGER_ShortMessage shortened; |
801 | 851 | ||
802 | fold_short_message (message, &shortened); | 852 | fold_short_message (message, &shortened); |
803 | 853 | ||
804 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); | 854 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); |
805 | const uint16_t padded_length = calc_padded_length(length); | 855 | const uint16_t padded_length = calc_padded_length ( |
856 | length + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | ||
857 | ); | ||
806 | 858 | ||
807 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; | 859 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; |
808 | message->body.privacy.data = GNUNET_malloc(padded_length); | 860 | message->body.privacy.data = GNUNET_malloc (padded_length); |
809 | message->body.privacy.length = padded_length; | 861 | message->body.privacy.length = padded_length; |
810 | 862 | ||
811 | encode_short_message (&shortened, padded_length, message->body.privacy.data); | 863 | const uint16_t encoded_length = ( |
864 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | ||
865 | ); | ||
812 | 866 | ||
813 | if (padded_length == GNUNET_IDENTITY_encrypt (message->body.privacy.data, padded_length, key, | 867 | encode_short_message (&shortened, encoded_length, message->body.privacy.data); |
814 | &(message->body.privacy.key), | 868 | |
815 | message->body.privacy.data)) | 869 | if (GNUNET_OK != GNUNET_IDENTITY_encrypt (message->body.privacy.data, |
816 | { | 870 | encoded_length, |
817 | destroy_message_body (shortened.kind, &(shortened.body)); | 871 | key, |
818 | return GNUNET_YES; | 872 | message->body.privacy.data, |
819 | } | 873 | padded_length)) |
820 | else | ||
821 | { | 874 | { |
822 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Encrypting message failed!\n"); | 875 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encrypting message failed!\n"); |
823 | 876 | ||
824 | unfold_short_message (&shortened, message); | 877 | unfold_short_message (&shortened, message); |
825 | return GNUNET_NO; | 878 | return GNUNET_NO; |
826 | } | 879 | } |
880 | |||
881 | destroy_message_body (shortened.kind, &(shortened.body)); | ||
882 | return GNUNET_YES; | ||
827 | } | 883 | } |
828 | 884 | ||
885 | |||
829 | int | 886 | int |
830 | decrypt_message (struct GNUNET_MESSENGER_Message *message, | 887 | decrypt_message (struct GNUNET_MESSENGER_Message *message, |
831 | const struct GNUNET_IDENTITY_PrivateKey *key) | 888 | const struct GNUNET_IDENTITY_PrivateKey *key) |
832 | { | 889 | { |
833 | GNUNET_assert((message) && (key)); | 890 | GNUNET_assert ((message) && (key)); |
891 | |||
892 | const uint16_t padded_length = message->body.privacy.length; | ||
893 | |||
894 | if (padded_length < GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES) | ||
895 | { | ||
896 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
897 | "Message length too short to decrypt!\n"); | ||
898 | |||
899 | return GNUNET_NO; | ||
900 | } | ||
901 | |||
902 | const uint16_t encoded_length = ( | ||
903 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | ||
904 | ); | ||
834 | 905 | ||
835 | if (message->body.privacy.length != GNUNET_IDENTITY_decrypt (message->body.privacy.data, message->body.privacy.length, | 906 | if (GNUNET_OK != GNUNET_IDENTITY_decrypt (message->body.privacy.data, |
836 | key, &(message->body.privacy.key), | 907 | padded_length, |
837 | message->body.privacy.data)) | 908 | key, |
909 | message->body.privacy.data, | ||
910 | encoded_length)) | ||
838 | { | 911 | { |
839 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decrypting message failed!\n"); | 912 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Decrypting message failed!\n"); |
840 | 913 | ||
841 | return GNUNET_NO; | 914 | return GNUNET_NO; |
842 | } | 915 | } |
843 | 916 | ||
844 | struct GNUNET_MESSENGER_ShortMessage shortened; | 917 | struct GNUNET_MESSENGER_ShortMessage shortened; |
845 | 918 | ||
846 | if (GNUNET_YES != decode_short_message (&shortened, message->body.privacy.length, message->body.privacy.data)) | 919 | if (GNUNET_YES != decode_short_message (&shortened, |
920 | encoded_length, | ||
921 | message->body.privacy.data)) | ||
847 | { | 922 | { |
848 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decoding decrypted message failed!\n"); | 923 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
924 | "Decoding decrypted message failed!\n"); | ||
849 | 925 | ||
850 | return GNUNET_NO; | 926 | return GNUNET_NO; |
851 | } | 927 | } |
852 | 928 | ||
853 | unfold_short_message (&shortened, message); | 929 | unfold_short_message (&shortened, message); |
854 | |||
855 | return GNUNET_YES; | 930 | return GNUNET_YES; |
856 | } | 931 | } |
857 | 932 | ||
933 | |||
858 | struct GNUNET_MQ_Envelope* | 934 | struct GNUNET_MQ_Envelope* |
859 | pack_message (struct GNUNET_MESSENGER_Message *message, | 935 | pack_message (struct GNUNET_MESSENGER_Message *message, |
860 | struct GNUNET_HashCode *hash, | 936 | struct GNUNET_HashCode *hash, |
861 | const struct GNUNET_MESSENGER_Ego *ego, | 937 | const struct GNUNET_MESSENGER_Ego *ego, |
862 | int mode) | 938 | int mode) |
863 | { | 939 | { |
864 | GNUNET_assert(message); | 940 | GNUNET_assert (message); |
865 | 941 | ||
866 | if (ego) | 942 | if (ego) |
867 | message->header.signature.type = ego->priv.type; | 943 | message->header.signature.type = ego->priv.type; |
868 | 944 | ||
869 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Packing message kind=%u and sender: %s\n", | 945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
870 | message->header.kind, GNUNET_sh2s(&(message->header.sender_id))); | 946 | "Packing message kind=%u and sender: %s\n", |
947 | message->header.kind, GNUNET_sh2s (&(message->header.sender_id))); | ||
871 | 948 | ||
872 | struct GNUNET_MessageHeader *header; | 949 | struct GNUNET_MessageHeader *header; |
873 | 950 | ||
874 | const uint16_t length = get_message_size (message, GNUNET_YES); | 951 | const uint16_t length = get_message_size (message, GNUNET_YES); |
875 | const uint16_t padded_length = calc_padded_length(length); | 952 | const uint16_t padded_length = calc_padded_length (length); |
876 | 953 | ||
877 | struct GNUNET_MQ_Envelope *env; | 954 | struct GNUNET_MQ_Envelope *env; |
878 | char *buffer; | 955 | char *buffer; |
879 | 956 | ||
880 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE == mode) | 957 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE == mode) |
881 | { | 958 | { |
882 | env = GNUNET_MQ_msg_extra(header, padded_length, GNUNET_MESSAGE_TYPE_CADET_CLI); | 959 | env = GNUNET_MQ_msg_extra (header, padded_length, |
960 | GNUNET_MESSAGE_TYPE_CADET_CLI); | ||
883 | 961 | ||
884 | buffer = (char*) &(header[1]); | 962 | buffer = (char*) &(header[1]); |
885 | } | 963 | } |
@@ -887,7 +965,7 @@ pack_message (struct GNUNET_MESSENGER_Message *message, | |||
887 | { | 965 | { |
888 | env = NULL; | 966 | env = NULL; |
889 | 967 | ||
890 | buffer = GNUNET_malloc(padded_length); | 968 | buffer = GNUNET_malloc (padded_length); |
891 | } | 969 | } |
892 | 970 | ||
893 | encode_message (message, padded_length, buffer, GNUNET_YES); | 971 | encode_message (message, padded_length, buffer, GNUNET_YES); |
@@ -901,11 +979,12 @@ pack_message (struct GNUNET_MESSENGER_Message *message, | |||
901 | } | 979 | } |
902 | 980 | ||
903 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE != mode) | 981 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE != mode) |
904 | GNUNET_free(buffer); | 982 | GNUNET_free (buffer); |
905 | 983 | ||
906 | return env; | 984 | return env; |
907 | } | 985 | } |
908 | 986 | ||
987 | |||
909 | int | 988 | int |
910 | filter_message_sending (const struct GNUNET_MESSENGER_Message *message) | 989 | filter_message_sending (const struct GNUNET_MESSENGER_Message *message) |
911 | { | 990 | { |
diff --git a/src/my/.gitignore b/src/my/.gitignore deleted file mode 100644 index 3338ba2ea..000000000 --- a/src/my/.gitignore +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test_my | ||
diff --git a/src/my/Makefile.am b/src/my/Makefile.am deleted file mode 100644 index 51e20e6bf..000000000 --- a/src/my/Makefile.am +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | if USE_COVERAGE | ||
5 | AM_CFLAGS = --coverage | ||
6 | endif | ||
7 | |||
8 | if HAVE_MYSQL | ||
9 | lib_LTLIBRARIES = libgnunetmy.la | ||
10 | endif | ||
11 | |||
12 | libgnunetmy_la_SOURCES = \ | ||
13 | my.c \ | ||
14 | my_query_helper.c \ | ||
15 | my_result_helper.c | ||
16 | |||
17 | libgnunetmy_la_LIBADD = $(MYSQL_LDFLAGS) -lmysqlclient \ | ||
18 | $(top_builddir)/src/mysql/libgnunetmysql.la \ | ||
19 | $(top_builddir)/src/util/libgnunetutil.la | ||
20 | libgnunetmy_la_LDFLAGS = \ | ||
21 | $(GN_LIB_LDFLAGS) \ | ||
22 | -version-info 0:0:0 | ||
23 | |||
24 | if ENABLE_TEST_RUN | ||
25 | TESTS = \ | ||
26 | test_my | ||
27 | endif | ||
28 | |||
29 | EXTRA_DIST = \ | ||
30 | test_my.conf | ||
31 | |||
32 | check_PROGRAMS= \ | ||
33 | test_my | ||
34 | |||
35 | test_my_SOURCES = \ | ||
36 | test_my.c | ||
37 | test_my_LDADD = \ | ||
38 | libgnunetmy.la \ | ||
39 | $(top_builddir)/src/mysql/libgnunetmysql.la \ | ||
40 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
41 | -lmysqlclient $(XLIB) | ||
diff --git a/src/my/my.c b/src/my/my.c deleted file mode 100644 index b667af4f9..000000000 --- a/src/my/my.c +++ /dev/null | |||
@@ -1,270 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2016, 2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file my/my.c | ||
22 | * @brief library to help with access to a MySQL database | ||
23 | * @author Christophe Genevey | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include <mysql/mysql.h> | ||
28 | #include "gnunet_mysql_compat.h" | ||
29 | #include "gnunet_my_lib.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Run a prepared SELECT statement. | ||
34 | * | ||
35 | * @param mc mysql context | ||
36 | * @param sh handle to SELECT statement | ||
37 | * @param params parameters to the statement | ||
38 | * @return | ||
39 | #GNUNET_YES if we can prepare all statement | ||
40 | #GNUNET_SYSERR if we can't prepare all statement | ||
41 | */ | ||
42 | int | ||
43 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | ||
44 | struct GNUNET_MYSQL_StatementHandle *sh, | ||
45 | struct GNUNET_MY_QueryParam *params) | ||
46 | { | ||
47 | const struct GNUNET_MY_QueryParam *p; | ||
48 | unsigned int num; | ||
49 | MYSQL_STMT *stmt; | ||
50 | |||
51 | num = 0; | ||
52 | for (unsigned int i = 0; NULL != params[i].conv; i++) | ||
53 | num += params[i].num_params; | ||
54 | { | ||
55 | MYSQL_BIND qbind[num]; | ||
56 | unsigned int off; | ||
57 | |||
58 | memset (qbind, | ||
59 | 0, | ||
60 | sizeof(qbind)); | ||
61 | off = 0; | ||
62 | for (unsigned int i = 0; NULL != (p = ¶ms[i])->conv; i++) | ||
63 | { | ||
64 | if (GNUNET_OK != | ||
65 | p->conv (p->conv_cls, | ||
66 | p, | ||
67 | &qbind[off])) | ||
68 | { | ||
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
70 | "Conversion for MySQL query failed at offset %u\n", | ||
71 | i); | ||
72 | return GNUNET_SYSERR; | ||
73 | } | ||
74 | off += p->num_params; | ||
75 | } | ||
76 | stmt = GNUNET_MYSQL_statement_get_stmt (sh); | ||
77 | if (mysql_stmt_bind_param (stmt, | ||
78 | qbind)) | ||
79 | { | ||
80 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
81 | "my", | ||
82 | _ ("`%s' failed at %s:%d with error: %s\n"), | ||
83 | "mysql_stmt_bind_param", | ||
84 | __FILE__, __LINE__, | ||
85 | mysql_stmt_error (stmt)); | ||
86 | GNUNET_MYSQL_statements_invalidate (mc); | ||
87 | return GNUNET_SYSERR; | ||
88 | } | ||
89 | |||
90 | if (mysql_stmt_execute (stmt)) | ||
91 | { | ||
92 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
93 | "my", | ||
94 | _ ("`%s' failed at %s:%d with error: %s\n"), | ||
95 | "mysql_stmt_execute", __FILE__, __LINE__, | ||
96 | mysql_stmt_error (stmt)); | ||
97 | GNUNET_MYSQL_statements_invalidate (mc); | ||
98 | return GNUNET_SYSERR; | ||
99 | } | ||
100 | GNUNET_MY_cleanup_query (params, | ||
101 | qbind); | ||
102 | } | ||
103 | return GNUNET_OK; | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Free all memory that was allocated in @a qp during | ||
109 | * #GNUNET_MY_exec_prepared(). | ||
110 | * | ||
111 | * @param qp query specification to clean up | ||
112 | * @param qbind array of parameter to clean up | ||
113 | */ | ||
114 | void | ||
115 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | ||
116 | MYSQL_BIND *qbind) | ||
117 | { | ||
118 | for (unsigned int i = 0; NULL != qp[i].conv; i++) | ||
119 | if (NULL != qp[i].cleaner) | ||
120 | qp[i].cleaner (qp[i].conv_cls, | ||
121 | &qbind[i]); | ||
122 | } | ||
123 | |||
124 | |||
125 | /** | ||
126 | * Extract results from a query result according to the given | ||
127 | * specification. Always fetches the next row. | ||
128 | * | ||
129 | * @param sh statement that returned results | ||
130 | * @param rs specification to extract for | ||
131 | * @return | ||
132 | * #GNUNET_YES if all results could be extracted | ||
133 | * #GNUNET_NO if there is no more data in the result set | ||
134 | * #GNUNET_SYSERR if a result was invalid | ||
135 | */ | ||
136 | int | ||
137 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | ||
138 | struct GNUNET_MY_ResultSpec *rs) | ||
139 | { | ||
140 | unsigned int num_fields; | ||
141 | int ret; | ||
142 | MYSQL_STMT *stmt; | ||
143 | |||
144 | stmt = GNUNET_MYSQL_statement_get_stmt (sh); | ||
145 | if (NULL == stmt) | ||
146 | { | ||
147 | GNUNET_break (0); | ||
148 | return GNUNET_SYSERR; | ||
149 | } | ||
150 | if (NULL == rs) | ||
151 | { | ||
152 | mysql_stmt_free_result (stmt); | ||
153 | return GNUNET_NO; | ||
154 | } | ||
155 | |||
156 | num_fields = 0; | ||
157 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) | ||
158 | num_fields += rs[i].num_fields; | ||
159 | |||
160 | if (mysql_stmt_field_count (stmt) != num_fields) | ||
161 | { | ||
162 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
163 | "Number of fields mismatch between SQL result and result specification\n"); | ||
164 | return GNUNET_SYSERR; | ||
165 | } | ||
166 | |||
167 | { | ||
168 | MYSQL_BIND result[num_fields]; | ||
169 | unsigned int field_off; | ||
170 | |||
171 | memset (result, 0, sizeof(MYSQL_BIND) * num_fields); | ||
172 | field_off = 0; | ||
173 | for (unsigned int i = 0; NULL != rs[i].pre_conv; i++) | ||
174 | { | ||
175 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | ||
176 | |||
177 | if (GNUNET_OK != | ||
178 | rp->pre_conv (rp->conv_cls, | ||
179 | rp, | ||
180 | stmt, | ||
181 | field_off, | ||
182 | &result[field_off])) | ||
183 | |||
184 | { | ||
185 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
186 | "Pre-conversion for MySQL result failed at offset %u\n", | ||
187 | i); | ||
188 | return GNUNET_SYSERR; | ||
189 | } | ||
190 | field_off += rp->num_fields; | ||
191 | } | ||
192 | |||
193 | if (mysql_stmt_bind_result (stmt, result)) | ||
194 | { | ||
195 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
196 | "my", | ||
197 | _ ("%s failed at %s:%d with error: %s\n"), | ||
198 | "mysql_stmt_bind_result", | ||
199 | __FILE__, __LINE__, | ||
200 | mysql_stmt_error (stmt)); | ||
201 | return GNUNET_SYSERR; | ||
202 | } | ||
203 | #if TEST_OPTIMIZATION | ||
204 | (void) mysql_stmt_store_result (stmt); | ||
205 | #endif | ||
206 | ret = mysql_stmt_fetch (stmt); | ||
207 | if (MYSQL_NO_DATA == ret) | ||
208 | { | ||
209 | mysql_stmt_free_result (stmt); | ||
210 | return GNUNET_NO; | ||
211 | } | ||
212 | if (1 == ret) | ||
213 | { | ||
214 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
215 | "my", | ||
216 | _ ("%s failed at %s:%d with error: %s\n"), | ||
217 | "mysql_stmt_fetch", | ||
218 | __FILE__, __LINE__, | ||
219 | mysql_stmt_error (stmt)); | ||
220 | GNUNET_MY_cleanup_result (rs); | ||
221 | mysql_stmt_free_result (stmt); | ||
222 | return GNUNET_SYSERR; | ||
223 | } | ||
224 | field_off = 0; | ||
225 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) | ||
226 | { | ||
227 | struct GNUNET_MY_ResultSpec *rp = &rs[i]; | ||
228 | |||
229 | if (NULL != rp->post_conv) | ||
230 | if (GNUNET_OK != | ||
231 | rp->post_conv (rp->conv_cls, | ||
232 | rp, | ||
233 | stmt, | ||
234 | field_off, | ||
235 | &result[field_off])) | ||
236 | { | ||
237 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
238 | "Post-conversion for MySQL result failed at offset %u\n", | ||
239 | i); | ||
240 | mysql_stmt_free_result (stmt); | ||
241 | for (unsigned int j = 0; j < i; j++) | ||
242 | if (NULL != rs[j].cleaner) | ||
243 | rs[j].cleaner (rs[j].conv_cls, | ||
244 | rs[j].dst); | ||
245 | return GNUNET_SYSERR; | ||
246 | } | ||
247 | field_off += rp->num_fields; | ||
248 | } | ||
249 | } | ||
250 | return GNUNET_OK; | ||
251 | } | ||
252 | |||
253 | |||
254 | /** | ||
255 | * Free all memory that was allocated in @a rs during | ||
256 | * #GNUNET_MY_extract_result(). | ||
257 | * | ||
258 | * @param rs result specification to clean up | ||
259 | */ | ||
260 | void | ||
261 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs) | ||
262 | { | ||
263 | for (unsigned int i = 0; NULL != rs[i].post_conv; i++) | ||
264 | if (NULL != rs[i].cleaner) | ||
265 | rs[i].cleaner (rs[i].conv_cls, | ||
266 | &rs[i]); | ||
267 | } | ||
268 | |||
269 | |||
270 | /* end of my.c */ | ||
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c deleted file mode 100644 index c12970876..000000000 --- a/src/my/my_query_helper.c +++ /dev/null | |||
@@ -1,401 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file my/my_query_helper.c | ||
22 | * @brief library to help with access to a MySQL database | ||
23 | * @author Christian Grothoff | ||
24 | * @author Christophe Genevey | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include <mysql/mysql.h> | ||
28 | #include "gnunet_mysql_compat.h" | ||
29 | #include "gnunet_my_lib.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Function called to clean up memory allocated | ||
34 | * by a #GNUNET_MY_QueryConverter. | ||
35 | * | ||
36 | * @param cls closure | ||
37 | * @param qbind array of parameter to clean up | ||
38 | */ | ||
39 | static void | ||
40 | my_clean_query (void *cls, | ||
41 | MYSQL_BIND *qbind) | ||
42 | { | ||
43 | (void) cls; | ||
44 | GNUNET_free (qbind[0].buffer); | ||
45 | } | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Function called to convert input argument into SQL parameters. | ||
50 | * | ||
51 | * @param cls closure | ||
52 | * @param qp data about the query | ||
53 | * @param qbind array of parameters to initialize | ||
54 | * @return -1 on error | ||
55 | */ | ||
56 | static int | ||
57 | my_conv_fixed_size (void *cls, | ||
58 | const struct GNUNET_MY_QueryParam *qp, | ||
59 | MYSQL_BIND *qbind) | ||
60 | { | ||
61 | (void) cls; | ||
62 | GNUNET_assert (1 == qp->num_params); | ||
63 | qbind->buffer = (void *) qp->data; | ||
64 | qbind->buffer_length = qp->data_len; | ||
65 | qbind->buffer_type = MYSQL_TYPE_BLOB; | ||
66 | |||
67 | return 1; | ||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Generate query parameter for a buffer @a ptr of | ||
73 | * @a ptr_size bytes. | ||
74 | * | ||
75 | * @param ptr pointer to the query parameter to pass | ||
76 | * @param ptr_size number of bytes in @a ptr | ||
77 | */ | ||
78 | struct GNUNET_MY_QueryParam | ||
79 | GNUNET_MY_query_param_fixed_size (const void *ptr, | ||
80 | size_t ptr_size) | ||
81 | { | ||
82 | struct GNUNET_MY_QueryParam qp = { | ||
83 | .conv = &my_conv_fixed_size, | ||
84 | .cleaner = NULL, | ||
85 | .conv_cls = NULL, | ||
86 | .num_params = 1, | ||
87 | .data = ptr, | ||
88 | .data_len = (unsigned long) ptr_size | ||
89 | }; | ||
90 | |||
91 | return qp; | ||
92 | } | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Function called to convert input argument into SQL parameters. | ||
97 | * | ||
98 | * @param cls closure | ||
99 | * @param qp data about the query | ||
100 | * @param qbind array of parameters to initialize | ||
101 | * @return -1 on error | ||
102 | */ | ||
103 | static int | ||
104 | my_conv_string (void *cls, | ||
105 | const struct GNUNET_MY_QueryParam *qp, | ||
106 | MYSQL_BIND *qbind) | ||
107 | { | ||
108 | (void) cls; | ||
109 | GNUNET_assert (1 == qp->num_params); | ||
110 | qbind->buffer = (void *) qp->data; | ||
111 | qbind->buffer_length = qp->data_len; | ||
112 | qbind->buffer_type = MYSQL_TYPE_STRING; | ||
113 | return 1; | ||
114 | } | ||
115 | |||
116 | |||
117 | /** | ||
118 | * Generate query parameter for a string | ||
119 | * | ||
120 | * @param ptr pointer to the string query parameter to pass | ||
121 | */ | ||
122 | struct GNUNET_MY_QueryParam | ||
123 | GNUNET_MY_query_param_string (const char *ptr) | ||
124 | { | ||
125 | struct GNUNET_MY_QueryParam qp = { | ||
126 | .conv = &my_conv_string, | ||
127 | .cleaner = NULL, | ||
128 | .conv_cls = NULL, | ||
129 | .num_params = 1, | ||
130 | .data = ptr, | ||
131 | .data_len = strlen (ptr) | ||
132 | }; | ||
133 | |||
134 | return qp; | ||
135 | } | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Function called to convert input argument into SQL parameters | ||
140 | * | ||
141 | * @param cls closure | ||
142 | * @param qp data about the query | ||
143 | * @param qbind array of parameters to initialize | ||
144 | * @return -1 on error | ||
145 | */ | ||
146 | static int | ||
147 | my_conv_uint16 (void *cls, | ||
148 | const struct GNUNET_MY_QueryParam *qp, | ||
149 | MYSQL_BIND *qbind) | ||
150 | { | ||
151 | (void) cls; | ||
152 | GNUNET_assert (1 == qp->num_params); | ||
153 | qbind->buffer = (void *) qp->data; | ||
154 | qbind->buffer_length = sizeof(uint16_t); | ||
155 | qbind->buffer_type = MYSQL_TYPE_SHORT; | ||
156 | qbind->is_unsigned = 1; | ||
157 | return 1; | ||
158 | } | ||
159 | |||
160 | |||
161 | /** | ||
162 | * Generate query parameter for an uint16_t in host byte order. | ||
163 | * | ||
164 | * @param x pointer to the query parameter to pass | ||
165 | */ | ||
166 | struct GNUNET_MY_QueryParam | ||
167 | GNUNET_MY_query_param_uint16 (const uint16_t *x) | ||
168 | { | ||
169 | struct GNUNET_MY_QueryParam res = { | ||
170 | .conv = &my_conv_uint16, | ||
171 | .cleaner = NULL, | ||
172 | .conv_cls = NULL, | ||
173 | .num_params = 1, | ||
174 | .data = x, | ||
175 | .data_len = sizeof(*x) | ||
176 | }; | ||
177 | |||
178 | return res; | ||
179 | } | ||
180 | |||
181 | |||
182 | /** | ||
183 | * Function called to convert input argument into SQL parameters | ||
184 | * | ||
185 | * @param cls closure | ||
186 | * @param qp data about the query | ||
187 | * @param qbind array of parameters to initialize | ||
188 | * @return -1 on error | ||
189 | */ | ||
190 | static int | ||
191 | my_conv_uint32 (void *cls, | ||
192 | const struct GNUNET_MY_QueryParam *qp, | ||
193 | MYSQL_BIND *qbind) | ||
194 | { | ||
195 | (void) cls; | ||
196 | GNUNET_assert (1 == qp->num_params); | ||
197 | qbind->buffer = (void *) qp->data; | ||
198 | qbind->buffer_length = sizeof(uint32_t); | ||
199 | qbind->buffer_type = MYSQL_TYPE_LONG; | ||
200 | qbind->is_unsigned = 1; | ||
201 | return 1; | ||
202 | } | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Generate query parameter for an uint32_t in host byte order | ||
207 | * | ||
208 | * @param x pointer to the query parameter to pass | ||
209 | */ | ||
210 | struct GNUNET_MY_QueryParam | ||
211 | GNUNET_MY_query_param_uint32 (const uint32_t *x) | ||
212 | { | ||
213 | struct GNUNET_MY_QueryParam res = { | ||
214 | .conv = &my_conv_uint32, | ||
215 | .cleaner = NULL, | ||
216 | .conv_cls = NULL, | ||
217 | .num_params = 1, | ||
218 | .data = x, | ||
219 | .data_len = sizeof(*x) | ||
220 | }; | ||
221 | |||
222 | return res; | ||
223 | } | ||
224 | |||
225 | |||
226 | /** | ||
227 | * Function called to convert input argument into SQL parameters | ||
228 | * | ||
229 | * @param cls closure | ||
230 | * @param qp data about the query | ||
231 | * @param qbind array of parameters to initialize | ||
232 | * @return -1 on error | ||
233 | */ | ||
234 | static int | ||
235 | my_conv_uint64 (void *cls, | ||
236 | const struct GNUNET_MY_QueryParam *qp, | ||
237 | MYSQL_BIND *qbind) | ||
238 | { | ||
239 | (void) cls; | ||
240 | GNUNET_assert (1 == qp->num_params); | ||
241 | qbind->buffer = (void *) qp->data; | ||
242 | qbind->buffer_length = sizeof(uint64_t); | ||
243 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; | ||
244 | qbind->is_unsigned = 1; | ||
245 | return 1; | ||
246 | } | ||
247 | |||
248 | |||
249 | /** | ||
250 | * Generate query parameter for an uint64_t in host byte order | ||
251 | * | ||
252 | * @param x pointer to the query parameter to pass | ||
253 | */ | ||
254 | struct GNUNET_MY_QueryParam | ||
255 | GNUNET_MY_query_param_uint64 (const uint64_t *x) | ||
256 | { | ||
257 | struct GNUNET_MY_QueryParam res = { | ||
258 | .conv = &my_conv_uint64, | ||
259 | .cleaner = NULL, | ||
260 | .conv_cls = NULL, | ||
261 | .num_params = 1, | ||
262 | .data = x, | ||
263 | .data_len = sizeof(*x) | ||
264 | }; | ||
265 | |||
266 | return res; | ||
267 | } | ||
268 | |||
269 | |||
270 | /** | ||
271 | * Function called to convert input argument into SQL parameters | ||
272 | * | ||
273 | * @param cls closure | ||
274 | * @param qp data about the query | ||
275 | * @param qbind array of parameters to initialize | ||
276 | * @return -1 on error | ||
277 | */ | ||
278 | static int | ||
279 | my_conv_rsa_public_key (void *cls, | ||
280 | const struct GNUNET_MY_QueryParam *qp, | ||
281 | MYSQL_BIND *qbind) | ||
282 | { | ||
283 | const struct GNUNET_CRYPTO_RsaPublicKey *rsa = qp->data; | ||
284 | void *buf; | ||
285 | size_t buf_size; | ||
286 | |||
287 | (void) cls; | ||
288 | GNUNET_assert (1 == qp->num_params); | ||
289 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, | ||
290 | &buf); | ||
291 | qbind->buffer = buf; | ||
292 | qbind->buffer_length = buf_size; | ||
293 | qbind->buffer_type = MYSQL_TYPE_BLOB; | ||
294 | return 1; | ||
295 | } | ||
296 | |||
297 | |||
298 | /** | ||
299 | * Generate query parameter for an RSA public key. The | ||
300 | * database must contain a BLOB type in the respective position. | ||
301 | * | ||
302 | * @param x the query parameter to pass | ||
303 | * @return array entry for the query parameters to use | ||
304 | */ | ||
305 | struct GNUNET_MY_QueryParam | ||
306 | GNUNET_MY_query_param_rsa_public_key (const struct | ||
307 | GNUNET_CRYPTO_RsaPublicKey *x) | ||
308 | { | ||
309 | struct GNUNET_MY_QueryParam res = { | ||
310 | .conv = &my_conv_rsa_public_key, | ||
311 | .cleaner = &my_clean_query, | ||
312 | .conv_cls = NULL, | ||
313 | .num_params = 1, | ||
314 | .data = x, | ||
315 | .data_len = 0 | ||
316 | }; | ||
317 | |||
318 | return res; | ||
319 | } | ||
320 | |||
321 | |||
322 | /** | ||
323 | * Function called to convert input argument into SQL parameters | ||
324 | * | ||
325 | *@param cls closure | ||
326 | *@param qp data about the query | ||
327 | *@param qbind array of parameters to initialize | ||
328 | *@return -1 on error | ||
329 | */ | ||
330 | static int | ||
331 | my_conv_rsa_signature (void *cls, | ||
332 | const struct GNUNET_MY_QueryParam *qp, | ||
333 | MYSQL_BIND *qbind) | ||
334 | { | ||
335 | const struct GNUNET_CRYPTO_RsaSignature *sig = qp->data; | ||
336 | void *buf; | ||
337 | size_t buf_size; | ||
338 | |||
339 | (void) cls; | ||
340 | GNUNET_assert (1 == qp->num_params); | ||
341 | buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig, | ||
342 | &buf); | ||
343 | qbind->buffer = buf; | ||
344 | qbind->buffer_length = buf_size; | ||
345 | qbind->buffer_type = MYSQL_TYPE_BLOB; | ||
346 | return 1; | ||
347 | } | ||
348 | |||
349 | |||
350 | /** | ||
351 | * Generate query parameter for an RSA signature. The | ||
352 | * database must contain a BLOB type in the respective position | ||
353 | * | ||
354 | * @param x the query parameter to pass | ||
355 | * @return array entry for the query parameters to use | ||
356 | */ | ||
357 | struct GNUNET_MY_QueryParam | ||
358 | GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x) | ||
359 | { | ||
360 | struct GNUNET_MY_QueryParam res = { | ||
361 | .conv = &my_conv_rsa_signature, | ||
362 | .cleaner = &my_clean_query, | ||
363 | .conv_cls = NULL, | ||
364 | .num_params = 1, | ||
365 | .data = (x), | ||
366 | .data_len = 0 | ||
367 | }; | ||
368 | |||
369 | return res; | ||
370 | } | ||
371 | |||
372 | |||
373 | /** | ||
374 | * Generate query parameter for an absolute time value. | ||
375 | * The database must store a 64-bit integer. | ||
376 | * | ||
377 | * @param x pointer to the query parameter to pass | ||
378 | * @return array entry for the query parameters to use | ||
379 | */ | ||
380 | struct GNUNET_MY_QueryParam | ||
381 | GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x) | ||
382 | { | ||
383 | return GNUNET_MY_query_param_uint64 (&x->abs_value_us); | ||
384 | } | ||
385 | |||
386 | |||
387 | /** | ||
388 | * Generate query parameter for an absolute time value. | ||
389 | * The database must store a 64-bit integer. | ||
390 | * | ||
391 | * @param x pointer to the query parameter to pass | ||
392 | */ | ||
393 | struct GNUNET_MY_QueryParam | ||
394 | GNUNET_MY_query_param_absolute_time_nbo (const struct | ||
395 | GNUNET_TIME_AbsoluteNBO *x) | ||
396 | { | ||
397 | return GNUNET_MY_query_param_auto_from_type (&x->abs_value_us__); | ||
398 | } | ||
399 | |||
400 | |||
401 | /* end of my_query_helper.c */ | ||
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c deleted file mode 100644 index ceebc6f37..000000000 --- a/src/my/my_result_helper.c +++ /dev/null | |||
@@ -1,868 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file my/my_result_helper.c | ||
22 | * @brief functions to extract result values | ||
23 | * @author Christophe Genevey | ||
24 | */ | ||
25 | |||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_mysql_compat.h" | ||
29 | #include "gnunet_my_lib.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * extract data from a Mysql database @a result at row @a row | ||
34 | * | ||
35 | * @param cls closure | ||
36 | * @param[in,out] rs | ||
37 | * @param stmt the mysql statement that is being run | ||
38 | * @param column the column that is being processed | ||
39 | * @param[out] result mysql result | ||
40 | * @return | ||
41 | * #GNUNET_OK if all results could be extracted | ||
42 | * #GNUNET_SYSERR if a result was invalid | ||
43 | */ | ||
44 | static int | ||
45 | pre_extract_varsize_blob (void *cls, | ||
46 | struct GNUNET_MY_ResultSpec *rs, | ||
47 | MYSQL_STMT *stmt, | ||
48 | unsigned int column, | ||
49 | MYSQL_BIND *results) | ||
50 | { | ||
51 | results[0].buffer = NULL; | ||
52 | results[0].buffer_length = 0; | ||
53 | results[0].length = &rs->mysql_bind_output_length; | ||
54 | results[0].is_null = &rs->is_null; | ||
55 | rs->is_null = 0; | ||
56 | |||
57 | return GNUNET_OK; | ||
58 | } | ||
59 | |||
60 | |||
61 | /** | ||
62 | * extract data from a Mysql database @a result at row @a row | ||
63 | * | ||
64 | * @param cls closure | ||
65 | * @param[in,out] rs | ||
66 | * @param stmt the mysql statement that is being run | ||
67 | * @param column the column that is being processed | ||
68 | * @param[out] results | ||
69 | * @return | ||
70 | * #GNUNET_OK if all results could be extracted | ||
71 | * #GNUNET_SYSERR if a result was invalid | ||
72 | */ | ||
73 | static int | ||
74 | post_extract_varsize_blob (void *cls, | ||
75 | struct GNUNET_MY_ResultSpec *rs, | ||
76 | MYSQL_STMT *stmt, | ||
77 | unsigned int column, | ||
78 | MYSQL_BIND *results) | ||
79 | { | ||
80 | void *buf; | ||
81 | size_t size; | ||
82 | |||
83 | if (*results->is_null) | ||
84 | return GNUNET_SYSERR; | ||
85 | size = (size_t) rs->mysql_bind_output_length; | ||
86 | |||
87 | if (rs->mysql_bind_output_length != size) | ||
88 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | ||
89 | |||
90 | buf = GNUNET_malloc (size); | ||
91 | |||
92 | results[0].buffer = buf; | ||
93 | results[0].buffer_length = size; | ||
94 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
95 | |||
96 | if (0 != | ||
97 | mysql_stmt_fetch_column (stmt, | ||
98 | results, | ||
99 | column, | ||
100 | 0)) | ||
101 | { | ||
102 | GNUNET_free (buf); | ||
103 | return GNUNET_SYSERR; | ||
104 | } | ||
105 | |||
106 | *(void **) rs->dst = buf; | ||
107 | *rs->result_size = size; | ||
108 | |||
109 | return GNUNET_OK; | ||
110 | } | ||
111 | |||
112 | |||
113 | /** | ||
114 | * extract data from a Mysql database @a result at row @a row | ||
115 | * | ||
116 | * @param cls closure | ||
117 | * @param[in,out] rs | ||
118 | */ | ||
119 | static void | ||
120 | cleanup_varsize_blob (void *cls, | ||
121 | struct GNUNET_MY_ResultSpec *rs) | ||
122 | { | ||
123 | void **ptr = (void **) rs->dst; | ||
124 | |||
125 | if (NULL != *ptr) | ||
126 | { | ||
127 | GNUNET_free (*ptr); | ||
128 | *ptr = NULL; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | |||
133 | struct GNUNET_MY_ResultSpec | ||
134 | GNUNET_MY_result_spec_variable_size (void **dst, | ||
135 | size_t *ptr_size) | ||
136 | { | ||
137 | struct GNUNET_MY_ResultSpec res = { | ||
138 | .pre_conv = &pre_extract_varsize_blob, | ||
139 | .post_conv = &post_extract_varsize_blob, | ||
140 | .cleaner = &cleanup_varsize_blob, | ||
141 | .dst = (void *) (dst), | ||
142 | .result_size = ptr_size, | ||
143 | .num_fields = 1 | ||
144 | }; | ||
145 | |||
146 | return res; | ||
147 | } | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Extract data from a Mysql database @a result at row @a row | ||
152 | * | ||
153 | * @param cls closure | ||
154 | * @param[in,out] rs | ||
155 | * @param stmt the mysql statement that is being run | ||
156 | * @param column the column that is being processed | ||
157 | * @param[out] results | ||
158 | * @return | ||
159 | * #GNUNET_OK if all results could be extracted | ||
160 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) | ||
161 | */ | ||
162 | static int | ||
163 | pre_extract_fixed_blob (void *cls, | ||
164 | struct GNUNET_MY_ResultSpec *rs, | ||
165 | MYSQL_STMT *stmt, | ||
166 | unsigned int column, | ||
167 | MYSQL_BIND *results) | ||
168 | { | ||
169 | results[0].buffer = rs->dst; | ||
170 | results[0].buffer_length = rs->dst_size; | ||
171 | results[0].length = &rs->mysql_bind_output_length; | ||
172 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
173 | results[0].is_null = &rs->is_null; | ||
174 | rs->is_null = 0; | ||
175 | |||
176 | return GNUNET_OK; | ||
177 | } | ||
178 | |||
179 | |||
180 | /** | ||
181 | * Check size of extracted fixed size data from a Mysql database @a | ||
182 | * result at row @a row | ||
183 | * | ||
184 | * @param cls closure | ||
185 | * @param[in,out] rs | ||
186 | * @param stmt the mysql statement that is being run | ||
187 | * @param column the column that is being processed | ||
188 | * @param[out] results | ||
189 | * @return | ||
190 | * #GNUNET_OK if all results could be extracted | ||
191 | * #GNUNET_SYSERR if a result was invalid(non-existing field or NULL) | ||
192 | */ | ||
193 | static int | ||
194 | post_extract_fixed_blob (void *cls, | ||
195 | struct GNUNET_MY_ResultSpec *rs, | ||
196 | MYSQL_STMT *stmt, | ||
197 | unsigned int column, | ||
198 | MYSQL_BIND *results) | ||
199 | { | ||
200 | if (*results->is_null) | ||
201 | return GNUNET_SYSERR; | ||
202 | if (rs->dst_size != rs->mysql_bind_output_length) | ||
203 | return GNUNET_SYSERR; | ||
204 | return GNUNET_OK; | ||
205 | } | ||
206 | |||
207 | |||
208 | /** | ||
209 | * Fixed-size result expected. | ||
210 | * | ||
211 | * @param name name of the field in the table | ||
212 | * @param[out] dst where to store the result | ||
213 | * @param ptr_size number of bytes in @a dst | ||
214 | * @return array entry for the result specification to use | ||
215 | */ | ||
216 | struct GNUNET_MY_ResultSpec | ||
217 | GNUNET_MY_result_spec_fixed_size (void *ptr, | ||
218 | size_t ptr_size) | ||
219 | { | ||
220 | struct GNUNET_MY_ResultSpec res = { | ||
221 | .pre_conv = &pre_extract_fixed_blob, | ||
222 | .post_conv = &post_extract_fixed_blob, | ||
223 | .cleaner = NULL, | ||
224 | .dst = (void *) (ptr), | ||
225 | .dst_size = ptr_size, | ||
226 | .num_fields = 1 | ||
227 | }; | ||
228 | |||
229 | return res; | ||
230 | } | ||
231 | |||
232 | |||
233 | /** | ||
234 | * Extract data from a Mysql database @a result at row @a row | ||
235 | * | ||
236 | * @param cls closure | ||
237 | * @param[in,out] rs | ||
238 | * @param stmt the mysql statement that is being run | ||
239 | * @param column the column that is being processed | ||
240 | * @param[out] results | ||
241 | * @return | ||
242 | * #GNUNET_OK if all results could be extracted | ||
243 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
244 | */ | ||
245 | static int | ||
246 | pre_extract_rsa_public_key (void *cls, | ||
247 | struct GNUNET_MY_ResultSpec *rs, | ||
248 | MYSQL_STMT *stmt, | ||
249 | unsigned int column, | ||
250 | MYSQL_BIND *results) | ||
251 | { | ||
252 | results[0].buffer = NULL; | ||
253 | results[0].buffer_length = 0; | ||
254 | results[0].length = &rs->mysql_bind_output_length; | ||
255 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
256 | results[0].is_null = &rs->is_null; | ||
257 | rs->is_null = 0; | ||
258 | |||
259 | return GNUNET_OK; | ||
260 | } | ||
261 | |||
262 | |||
263 | /** | ||
264 | * Check size of extracted fixed size data from a Mysql database @a | ||
265 | * result at row @a row | ||
266 | * | ||
267 | * @param cls closure | ||
268 | * @param[in,out] rs | ||
269 | * @param stmt the mysql statement that is being run | ||
270 | * @param column the column that is being processed | ||
271 | * @param[out] results | ||
272 | * @return | ||
273 | * #GNUNET_OK if all results could be extracted | ||
274 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
275 | */ | ||
276 | static int | ||
277 | post_extract_rsa_public_key (void *cls, | ||
278 | struct GNUNET_MY_ResultSpec *rs, | ||
279 | MYSQL_STMT *stmt, | ||
280 | unsigned int column, | ||
281 | MYSQL_BIND *results) | ||
282 | |||
283 | { | ||
284 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; | ||
285 | void *buf; | ||
286 | size_t size; | ||
287 | |||
288 | if (*results->is_null) | ||
289 | return GNUNET_SYSERR; | ||
290 | size = (size_t) rs->mysql_bind_output_length; | ||
291 | |||
292 | if (rs->mysql_bind_output_length != size) | ||
293 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | ||
294 | buf = GNUNET_malloc (size); | ||
295 | |||
296 | results[0].buffer = buf; | ||
297 | results[0].buffer_length = size; | ||
298 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
299 | if (0 != | ||
300 | mysql_stmt_fetch_column (stmt, | ||
301 | results, | ||
302 | column, | ||
303 | 0)) | ||
304 | { | ||
305 | GNUNET_free (buf); | ||
306 | return GNUNET_SYSERR; | ||
307 | } | ||
308 | |||
309 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, | ||
310 | size); | ||
311 | GNUNET_free (buf); | ||
312 | if (NULL == *pk) | ||
313 | { | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
315 | "Results contains bogus public key value (fail to decode)\n"); | ||
316 | return GNUNET_SYSERR; | ||
317 | } | ||
318 | |||
319 | return GNUNET_OK; | ||
320 | } | ||
321 | |||
322 | |||
323 | /** | ||
324 | * Function called to clean up memory allocated | ||
325 | * by a #GNUNET_MY_ResultConverter. | ||
326 | * | ||
327 | * @param cls closure | ||
328 | * @param rs result data to clean up | ||
329 | */ | ||
330 | static void | ||
331 | clean_rsa_public_key (void *cls, | ||
332 | struct GNUNET_MY_ResultSpec *rs) | ||
333 | { | ||
334 | struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst; | ||
335 | |||
336 | if (NULL != *pk) | ||
337 | { | ||
338 | GNUNET_CRYPTO_rsa_public_key_free (*pk); | ||
339 | *pk = NULL; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | |||
344 | /** | ||
345 | * RSA public key expected | ||
346 | * | ||
347 | * @param name name of the field in the table | ||
348 | * @param[out] rsa where to store the result | ||
349 | * @return array entry for the result specification to use | ||
350 | */ | ||
351 | struct GNUNET_MY_ResultSpec | ||
352 | GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) | ||
353 | { | ||
354 | struct GNUNET_MY_ResultSpec res = { | ||
355 | .pre_conv = &pre_extract_rsa_public_key, | ||
356 | .post_conv = &post_extract_rsa_public_key, | ||
357 | .cleaner = &clean_rsa_public_key, | ||
358 | .dst = (void *) rsa, | ||
359 | .dst_size = 0, | ||
360 | .num_fields = 1 | ||
361 | }; | ||
362 | |||
363 | return res; | ||
364 | } | ||
365 | |||
366 | |||
367 | /** | ||
368 | * Extract data from a Mysql database @a result at row @a row. | ||
369 | * | ||
370 | * @param cls closure | ||
371 | * @param[in,out] rs | ||
372 | * @param stmt the mysql statement that is being run | ||
373 | * @param column the column that is being processed | ||
374 | * @param[out] results | ||
375 | * @return | ||
376 | * #GNUNET_OK if all results could be extracted | ||
377 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
378 | */ | ||
379 | static int | ||
380 | pre_extract_rsa_signature (void *cls, | ||
381 | struct GNUNET_MY_ResultSpec *rs, | ||
382 | MYSQL_STMT *stmt, | ||
383 | unsigned int column, | ||
384 | MYSQL_BIND *results) | ||
385 | { | ||
386 | results[0].buffer = 0; | ||
387 | results[0].buffer_length = 0; | ||
388 | results[0].length = &rs->mysql_bind_output_length; | ||
389 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
390 | results[0].is_null = &rs->is_null; | ||
391 | rs->is_null = 0; | ||
392 | |||
393 | return GNUNET_OK; | ||
394 | } | ||
395 | |||
396 | |||
397 | /** | ||
398 | * Extract data from a Mysql database @a result at row @a row. | ||
399 | * | ||
400 | * @param cls closure | ||
401 | * @param[in,out] rs | ||
402 | * @param stmt the mysql statement that is being run | ||
403 | * @param column the column that is being processed | ||
404 | * @param[out] results | ||
405 | * @return | ||
406 | * #GNUNET_OK if all results could be extracted | ||
407 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
408 | */ | ||
409 | static int | ||
410 | post_extract_rsa_signature (void *cls, | ||
411 | struct GNUNET_MY_ResultSpec *rs, | ||
412 | MYSQL_STMT *stmt, | ||
413 | unsigned int column, | ||
414 | MYSQL_BIND *results) | ||
415 | { | ||
416 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | ||
417 | void *buf; | ||
418 | size_t size; | ||
419 | |||
420 | if (*results->is_null) | ||
421 | return GNUNET_SYSERR; | ||
422 | size = (size_t) rs->mysql_bind_output_length; | ||
423 | |||
424 | if (rs->mysql_bind_output_length != size) | ||
425 | return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */ | ||
426 | buf = GNUNET_malloc (size); | ||
427 | |||
428 | results[0].buffer = buf; | ||
429 | results[0].buffer_length = size; | ||
430 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
431 | if (0 != | ||
432 | mysql_stmt_fetch_column (stmt, | ||
433 | results, | ||
434 | column, | ||
435 | 0)) | ||
436 | { | ||
437 | GNUNET_free (buf); | ||
438 | return GNUNET_SYSERR; | ||
439 | } | ||
440 | |||
441 | *sig = GNUNET_CRYPTO_rsa_signature_decode (buf, | ||
442 | size); | ||
443 | GNUNET_free (buf); | ||
444 | if (NULL == *sig) | ||
445 | { | ||
446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
447 | "Resuls contains bogus signature value (fails to decode)\n"); | ||
448 | return GNUNET_SYSERR; | ||
449 | } | ||
450 | return GNUNET_OK; | ||
451 | } | ||
452 | |||
453 | |||
454 | /** | ||
455 | * Function called to clean up memory allocated | ||
456 | * by a #GNUNET_MY_ResultConverter. | ||
457 | * | ||
458 | * @param cls closure | ||
459 | * @param rd result data to clean up | ||
460 | */ | ||
461 | static void | ||
462 | clean_rsa_signature (void *cls, | ||
463 | struct GNUNET_MY_ResultSpec *rs) | ||
464 | { | ||
465 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | ||
466 | |||
467 | if (NULL != *sig) | ||
468 | { | ||
469 | GNUNET_CRYPTO_rsa_signature_free (*sig); | ||
470 | *sig = NULL; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | |||
475 | /** | ||
476 | * RSA signature expected. | ||
477 | * | ||
478 | * @param[out] sig where to store the result; | ||
479 | * @return array entry for the result specification to use | ||
480 | */ | ||
481 | struct GNUNET_MY_ResultSpec | ||
482 | GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | ||
483 | { | ||
484 | struct GNUNET_MY_ResultSpec res = { | ||
485 | .pre_conv = &pre_extract_rsa_signature, | ||
486 | .post_conv = &post_extract_rsa_signature, | ||
487 | .cleaner = &clean_rsa_signature, | ||
488 | .dst = (void *) sig, | ||
489 | .dst_size = 0, | ||
490 | .num_fields = 1 | ||
491 | }; | ||
492 | |||
493 | return res; | ||
494 | } | ||
495 | |||
496 | |||
497 | /** | ||
498 | * Extract data from a Mysql database @a result at row @a row | ||
499 | * | ||
500 | * @param cls closure | ||
501 | * @param[in,out] rs | ||
502 | * @param stmt the mysql statement that is being run | ||
503 | * @param column the column that is being processed | ||
504 | * @param[out] results | ||
505 | * @return | ||
506 | * #GNUNET_OK if all results could be extracted | ||
507 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | ||
508 | */ | ||
509 | static int | ||
510 | pre_extract_string (void *cls, | ||
511 | struct GNUNET_MY_ResultSpec *rs, | ||
512 | MYSQL_STMT *stmt, | ||
513 | unsigned int column, | ||
514 | MYSQL_BIND *results) | ||
515 | { | ||
516 | results[0].buffer = NULL; | ||
517 | results[0].buffer_length = 0; | ||
518 | results[0].length = &rs->mysql_bind_output_length; | ||
519 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
520 | results[0].is_null = &rs->is_null; | ||
521 | rs->is_null = 0; | ||
522 | |||
523 | return GNUNET_OK; | ||
524 | } | ||
525 | |||
526 | |||
527 | /** | ||
528 | * Check size of extracted fixed size data from a Mysql database | ||
529 | * | ||
530 | * @param cls closure | ||
531 | * @param[in,out] rs | ||
532 | * @param stmt the mysql statement that is being run | ||
533 | * @param column the column that is being processed | ||
534 | * @param[out] results | ||
535 | * @return | ||
536 | * #GNUNET_OK if all results could be extracted | ||
537 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | ||
538 | */ | ||
539 | static int | ||
540 | post_extract_string (void *cls, | ||
541 | struct GNUNET_MY_ResultSpec *rs, | ||
542 | MYSQL_STMT *stmt, | ||
543 | unsigned int column, | ||
544 | MYSQL_BIND *results) | ||
545 | { | ||
546 | size_t size = (size_t) rs->mysql_bind_output_length; | ||
547 | char *buf; | ||
548 | |||
549 | if (rs->mysql_bind_output_length != size) | ||
550 | return GNUNET_SYSERR; | ||
551 | if (*results->is_null) | ||
552 | { | ||
553 | *(void **) rs->dst = NULL; | ||
554 | return GNUNET_OK; | ||
555 | } | ||
556 | |||
557 | buf = GNUNET_malloc (size); | ||
558 | results[0].buffer = buf; | ||
559 | results[0].buffer_length = size; | ||
560 | results[0].buffer_type = MYSQL_TYPE_BLOB; | ||
561 | |||
562 | if (0 != | ||
563 | mysql_stmt_fetch_column (stmt, | ||
564 | results, | ||
565 | column, | ||
566 | 0)) | ||
567 | { | ||
568 | GNUNET_free (buf); | ||
569 | return GNUNET_SYSERR; | ||
570 | } | ||
571 | buf[size] = '\0'; | ||
572 | *(void **) rs->dst = buf; | ||
573 | return GNUNET_OK; | ||
574 | } | ||
575 | |||
576 | |||
577 | /** | ||
578 | * 0- terminated string exprected. | ||
579 | * | ||
580 | * @param[out] dst where to store the result, allocated | ||
581 | * @return array entry for the result specification to use | ||
582 | */ | ||
583 | struct GNUNET_MY_ResultSpec | ||
584 | GNUNET_MY_result_spec_string (char **dst) | ||
585 | { | ||
586 | struct GNUNET_MY_ResultSpec res = { | ||
587 | .pre_conv = &pre_extract_string, | ||
588 | .post_conv = &post_extract_string, | ||
589 | .cleaner = NULL, | ||
590 | .dst = (void *) dst, | ||
591 | .dst_size = 0, | ||
592 | .num_fields = 1 | ||
593 | }; | ||
594 | |||
595 | return res; | ||
596 | } | ||
597 | |||
598 | |||
599 | /** | ||
600 | * Absolute time expected | ||
601 | * | ||
602 | * @param name name of the field in the table | ||
603 | * @param[out] at where to store the result | ||
604 | * @return array entry for the result specification to use | ||
605 | */ | ||
606 | struct GNUNET_MY_ResultSpec | ||
607 | GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) | ||
608 | { | ||
609 | return GNUNET_MY_result_spec_uint64 (&at->abs_value_us); | ||
610 | } | ||
611 | |||
612 | |||
613 | /** | ||
614 | * Absolute time in network byte order expected | ||
615 | * | ||
616 | * @param[out] at where to store the result | ||
617 | * @return array entry for the result specification to use | ||
618 | */ | ||
619 | struct GNUNET_MY_ResultSpec | ||
620 | GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | ||
621 | { | ||
622 | struct GNUNET_MY_ResultSpec res = | ||
623 | GNUNET_MY_result_spec_auto_from_type (&at->abs_value_us__); | ||
624 | |||
625 | return res; | ||
626 | } | ||
627 | |||
628 | |||
629 | /** | ||
630 | * Extract data from a Postgres database @a result at row @a row. | ||
631 | * | ||
632 | * @param cls closure | ||
633 | * @param[in,out] rs | ||
634 | * @param stmt the mysql statement that is being run | ||
635 | * @param column the column that is being processed | ||
636 | * @param[out] results | ||
637 | * @return | ||
638 | * #GNUNET_YES if all results could be extracted | ||
639 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
640 | */ | ||
641 | static int | ||
642 | pre_extract_uint16 (void *cls, | ||
643 | struct GNUNET_MY_ResultSpec *rs, | ||
644 | MYSQL_STMT *stmt, | ||
645 | unsigned int column, | ||
646 | MYSQL_BIND *results) | ||
647 | { | ||
648 | results[0].buffer = rs->dst; | ||
649 | results[0].buffer_length = rs->dst_size; | ||
650 | results[0].length = &rs->mysql_bind_output_length; | ||
651 | results[0].buffer_type = MYSQL_TYPE_SHORT; | ||
652 | results[0].is_null = &rs->is_null; | ||
653 | rs->is_null = 0; | ||
654 | |||
655 | return GNUNET_OK; | ||
656 | } | ||
657 | |||
658 | |||
659 | /** | ||
660 | * Check size of extracted fixed size data from a Mysql database. | ||
661 | * | ||
662 | * @param cls closure | ||
663 | * @param[in,out] rs | ||
664 | * @param stmt the mysql statement that is being run | ||
665 | * @param column the column that is being processed | ||
666 | * @param[out] results | ||
667 | * @return | ||
668 | * #GNUNET_YES if all results could be extracted | ||
669 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
670 | */ | ||
671 | static int | ||
672 | post_extract_uint16 (void *cls, | ||
673 | struct GNUNET_MY_ResultSpec *rs, | ||
674 | MYSQL_STMT *stmt, | ||
675 | unsigned int column, | ||
676 | MYSQL_BIND *results) | ||
677 | { | ||
678 | if (rs->dst_size != rs->mysql_bind_output_length) | ||
679 | return GNUNET_SYSERR; | ||
680 | if (*results->is_null) | ||
681 | return GNUNET_SYSERR; | ||
682 | return GNUNET_OK; | ||
683 | } | ||
684 | |||
685 | |||
686 | /** | ||
687 | * uint16_t expected | ||
688 | * | ||
689 | * @param[out] u16 where to store the result | ||
690 | * @return array entry for the result specification to use | ||
691 | */ | ||
692 | struct GNUNET_MY_ResultSpec | ||
693 | GNUNET_MY_result_spec_uint16 (uint16_t *u16) | ||
694 | { | ||
695 | struct GNUNET_MY_ResultSpec res = { | ||
696 | .pre_conv = &pre_extract_uint16, | ||
697 | .post_conv = &post_extract_uint16, | ||
698 | .cleaner = NULL, | ||
699 | .dst = (void *) u16, | ||
700 | .dst_size = sizeof(*u16), | ||
701 | .num_fields = 1 | ||
702 | }; | ||
703 | |||
704 | return res; | ||
705 | } | ||
706 | |||
707 | |||
708 | /** | ||
709 | * Extract data from a MYSQL database @a result at row @a row | ||
710 | * | ||
711 | * @param cls closure | ||
712 | * @param[in,out] rs | ||
713 | * @param stmt the mysql statement that is being run | ||
714 | * @param column the column that is being processed | ||
715 | * @param[out] results | ||
716 | * @return | ||
717 | * #GNUNET_OK if all results could be extracted | ||
718 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
719 | */ | ||
720 | static int | ||
721 | pre_extract_uint32 (void *cls, | ||
722 | struct GNUNET_MY_ResultSpec *rs, | ||
723 | MYSQL_STMT *stmt, | ||
724 | unsigned int column, | ||
725 | MYSQL_BIND *results) | ||
726 | { | ||
727 | results[0].buffer = rs->dst; | ||
728 | results[0].buffer_length = rs->dst_size; | ||
729 | results[0].length = &rs->mysql_bind_output_length; | ||
730 | results[0].buffer_type = MYSQL_TYPE_LONG; | ||
731 | results[0].is_null = &rs->is_null; | ||
732 | rs->is_null = 0; | ||
733 | |||
734 | return GNUNET_OK; | ||
735 | } | ||
736 | |||
737 | |||
738 | /** | ||
739 | * Extract data from a MYSQL database @a result at row @a row | ||
740 | * | ||
741 | * @param cls closure | ||
742 | * @param[in,out] rs | ||
743 | * @param stmt the mysql statement that is being run | ||
744 | * @param column the column that is being processed | ||
745 | * @param[out] results | ||
746 | * @return | ||
747 | * #GNUNET_OK if all results could be extracted | ||
748 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
749 | */ | ||
750 | static int | ||
751 | post_extract_uint32 (void *cls, | ||
752 | struct GNUNET_MY_ResultSpec *rs, | ||
753 | MYSQL_STMT *stmt, | ||
754 | unsigned int column, | ||
755 | MYSQL_BIND *results) | ||
756 | { | ||
757 | if (rs->dst_size != rs->mysql_bind_output_length) | ||
758 | return GNUNET_SYSERR; | ||
759 | if (*results->is_null) | ||
760 | return GNUNET_SYSERR; | ||
761 | return GNUNET_OK; | ||
762 | } | ||
763 | |||
764 | |||
765 | /** | ||
766 | * uint32_t expected | ||
767 | * | ||
768 | * @param[out] u32 where to store the result | ||
769 | * @return array entry for the result specification to use | ||
770 | */ | ||
771 | struct GNUNET_MY_ResultSpec | ||
772 | GNUNET_MY_result_spec_uint32 (uint32_t *u32) | ||
773 | { | ||
774 | struct GNUNET_MY_ResultSpec res = { | ||
775 | .pre_conv = &pre_extract_uint32, | ||
776 | .post_conv = &post_extract_uint32, | ||
777 | .cleaner = NULL, | ||
778 | .dst = (void *) u32, | ||
779 | .dst_size = sizeof(*u32), | ||
780 | .num_fields = 1 | ||
781 | }; | ||
782 | |||
783 | return res; | ||
784 | } | ||
785 | |||
786 | |||
787 | /** | ||
788 | * Extract data from a MYSQL database @a result at row @a row | ||
789 | * | ||
790 | * @param cls closure | ||
791 | * @param[in,out] rs | ||
792 | * @param stmt the mysql statement that is being run | ||
793 | * @param column the column that is being processed | ||
794 | * @param[out] results | ||
795 | * @return | ||
796 | * #GNUNET_OK if all results could be extracted | ||
797 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
798 | */ | ||
799 | static int | ||
800 | pre_extract_uint64 (void *cls, | ||
801 | struct GNUNET_MY_ResultSpec *rs, | ||
802 | MYSQL_STMT *stmt, | ||
803 | unsigned int column, | ||
804 | MYSQL_BIND *results) | ||
805 | { | ||
806 | if (sizeof(uint64_t) != rs->dst_size) | ||
807 | return GNUNET_SYSERR; | ||
808 | results[0].buffer = rs->dst; | ||
809 | results[0].buffer_length = rs->dst_size; | ||
810 | results[0].length = &rs->mysql_bind_output_length; | ||
811 | results[0].buffer_type = MYSQL_TYPE_LONGLONG; | ||
812 | results[0].is_null = &rs->is_null; | ||
813 | rs->is_null = 0; | ||
814 | |||
815 | return GNUNET_OK; | ||
816 | } | ||
817 | |||
818 | |||
819 | /** | ||
820 | * Check size of extracted fixed-size data from a Mysql database | ||
821 | * | ||
822 | * @param cls closure | ||
823 | * @param[in,out] rs | ||
824 | * @param stmt the mysql statement that is being run | ||
825 | * @param column the column that is being processed | ||
826 | * @param[out] results | ||
827 | * @return | ||
828 | * #GNUNET_OK if all results could be extracted | ||
829 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
830 | */ | ||
831 | static int | ||
832 | post_extract_uint64 (void *cls, | ||
833 | struct GNUNET_MY_ResultSpec *rs, | ||
834 | MYSQL_STMT *stmt, | ||
835 | unsigned int column, | ||
836 | MYSQL_BIND *results) | ||
837 | { | ||
838 | if (sizeof(uint64_t) != rs->dst_size) | ||
839 | return GNUNET_SYSERR; | ||
840 | if (*results->is_null) | ||
841 | return GNUNET_SYSERR; | ||
842 | return GNUNET_OK; | ||
843 | } | ||
844 | |||
845 | |||
846 | /** | ||
847 | * uint64_t expected. | ||
848 | * | ||
849 | * @param[out] u64 where to store the result | ||
850 | * @return array entry for the result specification to use | ||
851 | */ | ||
852 | struct GNUNET_MY_ResultSpec | ||
853 | GNUNET_MY_result_spec_uint64 (uint64_t *u64) | ||
854 | { | ||
855 | struct GNUNET_MY_ResultSpec res = { | ||
856 | .pre_conv = &pre_extract_uint64, | ||
857 | .post_conv = &post_extract_uint64, | ||
858 | .cleaner = NULL, | ||
859 | .dst = (void *) u64, | ||
860 | .dst_size = sizeof(*u64), | ||
861 | .num_fields = 1 | ||
862 | }; | ||
863 | |||
864 | return res; | ||
865 | } | ||
866 | |||
867 | |||
868 | /* end of my_result_helper.c */ | ||
diff --git a/src/my/test_my.c b/src/my/test_my.c deleted file mode 100644 index e646c0fd5..000000000 --- a/src/my/test_my.c +++ /dev/null | |||
@@ -1,301 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file my/test_my.c | ||
22 | * @brief Tests for convenience MySQL database | ||
23 | * @author Christophe Genevey | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include <mysql/mysql.h> | ||
27 | #include "gnunet_mysql_compat.h" | ||
28 | #include "gnunet_my_lib.h" | ||
29 | #include "gnunet_mysql_lib.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Run actual test queries. | ||
35 | * | ||
36 | * @param contexte the current context of mysql | ||
37 | * @return 0 on success | ||
38 | */ | ||
39 | static int | ||
40 | run_queries (struct GNUNET_MYSQL_Context *context) | ||
41 | { | ||
42 | struct GNUNET_CRYPTO_RsaPublicKey *pub = NULL; | ||
43 | struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; | ||
44 | struct GNUNET_CRYPTO_RsaSignature *sig = NULL;; | ||
45 | struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; | ||
46 | struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get (); | ||
47 | struct GNUNET_TIME_Absolute abs_time2; | ||
48 | struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
49 | struct GNUNET_TIME_Absolute forever2; | ||
50 | const struct GNUNET_TIME_AbsoluteNBO abs_time_nbo = | ||
51 | GNUNET_TIME_absolute_hton (abs_time); | ||
52 | struct GNUNET_HashCode hc; | ||
53 | struct GNUNET_HashCode hc2; | ||
54 | const char msg[] = "hello"; | ||
55 | void *msg2 = NULL; | ||
56 | size_t msg2_len; | ||
57 | |||
58 | const char msg3[] = "world"; | ||
59 | char *msg4 = ""; | ||
60 | |||
61 | uint16_t u16; | ||
62 | uint16_t u162; | ||
63 | uint32_t u32; | ||
64 | uint32_t u322; | ||
65 | uint64_t u64; | ||
66 | uint64_t u642; | ||
67 | |||
68 | int ret; | ||
69 | |||
70 | struct GNUNET_MYSQL_StatementHandle *statements_handle_insert = NULL; | ||
71 | struct GNUNET_MYSQL_StatementHandle *statements_handle_select = NULL; | ||
72 | |||
73 | struct GNUNET_CRYPTO_RsaPrivateKey *priv = NULL; | ||
74 | struct GNUNET_HashCode hmsg; | ||
75 | |||
76 | priv = GNUNET_CRYPTO_rsa_private_key_create (1024); | ||
77 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); | ||
78 | memset (&hmsg, 42, sizeof(hmsg)); | ||
79 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, | ||
80 | &hmsg); | ||
81 | u16 = 16; | ||
82 | u32 = 32; | ||
83 | u64 = UINT64_MAX; | ||
84 | |||
85 | memset (&hc, 0, sizeof(hc)); | ||
86 | memset (&hc2, 0, sizeof(hc2)); | ||
87 | |||
88 | statements_handle_insert | ||
89 | = GNUNET_MYSQL_statement_prepare (context, | ||
90 | "INSERT INTO test_my2 (" | ||
91 | " pub" | ||
92 | ",sig" | ||
93 | ",abs_time" | ||
94 | ",forever" | ||
95 | ",abs_time_nbo" | ||
96 | ",hash" | ||
97 | ",vsize" | ||
98 | ",str" | ||
99 | ",u16" | ||
100 | ",u32" | ||
101 | ",u64" | ||
102 | ") VALUES " | ||
103 | "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); | ||
104 | |||
105 | if (NULL == statements_handle_insert) | ||
106 | { | ||
107 | fprintf (stderr, "Failed to prepared statement INSERT\n"); | ||
108 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
109 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
110 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
111 | return 1; | ||
112 | } | ||
113 | |||
114 | struct GNUNET_MY_QueryParam params_insert[] = { | ||
115 | GNUNET_MY_query_param_rsa_public_key (pub), | ||
116 | GNUNET_MY_query_param_rsa_signature (sig), | ||
117 | GNUNET_MY_query_param_absolute_time (&abs_time), | ||
118 | GNUNET_MY_query_param_absolute_time (&forever), | ||
119 | GNUNET_MY_query_param_absolute_time_nbo (&abs_time_nbo), | ||
120 | GNUNET_MY_query_param_auto_from_type (&hc), | ||
121 | GNUNET_MY_query_param_fixed_size (msg, strlen (msg)), | ||
122 | GNUNET_MY_query_param_string (msg3), | ||
123 | GNUNET_MY_query_param_uint16 (&u16), | ||
124 | GNUNET_MY_query_param_uint32 (&u32), | ||
125 | GNUNET_MY_query_param_uint64 (&u64), | ||
126 | GNUNET_MY_query_param_end | ||
127 | }; | ||
128 | |||
129 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, | ||
130 | statements_handle_insert, | ||
131 | params_insert)) | ||
132 | { | ||
133 | fprintf (stderr, "Failed to execute prepared statement INSERT\n"); | ||
134 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
135 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
136 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
137 | return 1; | ||
138 | } | ||
139 | |||
140 | statements_handle_select | ||
141 | = GNUNET_MYSQL_statement_prepare (context, | ||
142 | "SELECT" | ||
143 | " pub" | ||
144 | ",sig" | ||
145 | ",abs_time" | ||
146 | ",forever" | ||
147 | ",hash" | ||
148 | ",vsize" | ||
149 | ",str" | ||
150 | ",u16" | ||
151 | ",u32" | ||
152 | ",u64" | ||
153 | " FROM test_my2"); | ||
154 | |||
155 | if (NULL == statements_handle_select) | ||
156 | { | ||
157 | fprintf (stderr, "Failed to prepared statement SELECT\n"); | ||
158 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
159 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
160 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
161 | return 1; | ||
162 | } | ||
163 | |||
164 | struct GNUNET_MY_QueryParam params_select[] = { | ||
165 | GNUNET_MY_query_param_end | ||
166 | }; | ||
167 | |||
168 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, | ||
169 | statements_handle_select, | ||
170 | params_select)) | ||
171 | { | ||
172 | fprintf (stderr, "Failed to execute prepared statement SELECT\n"); | ||
173 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
174 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
175 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
176 | return 1; | ||
177 | } | ||
178 | |||
179 | struct GNUNET_MY_ResultSpec results_select[] = { | ||
180 | GNUNET_MY_result_spec_rsa_public_key (&pub2), | ||
181 | GNUNET_MY_result_spec_rsa_signature (&sig2), | ||
182 | GNUNET_MY_result_spec_absolute_time (&abs_time2), | ||
183 | GNUNET_MY_result_spec_absolute_time (&forever2), | ||
184 | GNUNET_MY_result_spec_auto_from_type (&hc2), | ||
185 | GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len), | ||
186 | GNUNET_MY_result_spec_string (&msg4), | ||
187 | GNUNET_MY_result_spec_uint16 (&u162), | ||
188 | GNUNET_MY_result_spec_uint32 (&u322), | ||
189 | GNUNET_MY_result_spec_uint64 (&u642), | ||
190 | GNUNET_MY_result_spec_end | ||
191 | }; | ||
192 | |||
193 | ret = GNUNET_MY_extract_result (statements_handle_select, | ||
194 | results_select); | ||
195 | |||
196 | GNUNET_assert (GNUNET_YES == ret); | ||
197 | GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); | ||
198 | GNUNET_break (forever.abs_value_us == forever2.abs_value_us); | ||
199 | GNUNET_break (0 == | ||
200 | memcmp (&hc, | ||
201 | &hc2, | ||
202 | sizeof(struct GNUNET_HashCode))); | ||
203 | |||
204 | GNUNET_assert (NULL != sig2); | ||
205 | GNUNET_assert (NULL != pub2); | ||
206 | GNUNET_break (0 == | ||
207 | GNUNET_CRYPTO_rsa_signature_cmp (sig, | ||
208 | sig2)); | ||
209 | GNUNET_break (0 == | ||
210 | GNUNET_CRYPTO_rsa_public_key_cmp (pub, | ||
211 | pub2)); | ||
212 | |||
213 | GNUNET_break (strlen (msg) == msg2_len); | ||
214 | GNUNET_break (0 == | ||
215 | strncmp (msg, | ||
216 | msg2, | ||
217 | msg2_len)); | ||
218 | |||
219 | GNUNET_break (strlen (msg3) == strlen (msg4)); | ||
220 | GNUNET_break (0 == | ||
221 | strcmp (msg3, | ||
222 | msg4)); | ||
223 | |||
224 | GNUNET_break (16 == u162); | ||
225 | GNUNET_break (32 == u322); | ||
226 | GNUNET_break (UINT64_MAX == u642); | ||
227 | |||
228 | GNUNET_MY_cleanup_result (results_select); | ||
229 | |||
230 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
231 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
232 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
233 | |||
234 | if (GNUNET_OK != ret) | ||
235 | return 1; | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | |||
241 | int | ||
242 | main (int argc, const char *const argv[]) | ||
243 | { | ||
244 | struct GNUNET_CONFIGURATION_Handle *config; | ||
245 | struct GNUNET_MYSQL_Context *context; | ||
246 | int ret; | ||
247 | |||
248 | GNUNET_log_setup ("test-my", | ||
249 | "WARNING", | ||
250 | NULL); | ||
251 | |||
252 | config = GNUNET_CONFIGURATION_create (); | ||
253 | if (GNUNET_OK != | ||
254 | GNUNET_CONFIGURATION_parse (config, "test_my.conf")) | ||
255 | { | ||
256 | fprintf (stderr, "Failed to parse configuration\n"); | ||
257 | return 1; | ||
258 | } | ||
259 | |||
260 | context = GNUNET_MYSQL_context_create (config, | ||
261 | "datastore-mysql"); | ||
262 | if (NULL == context) | ||
263 | { | ||
264 | fprintf (stderr, "Failed to connect to database\n"); | ||
265 | return 77; | ||
266 | } | ||
267 | |||
268 | (void) GNUNET_MYSQL_statement_run (context, | ||
269 | "DROP TABLE test_my2;"); | ||
270 | |||
271 | if (GNUNET_OK != | ||
272 | GNUNET_MYSQL_statement_run (context, | ||
273 | "CREATE TABLE IF NOT EXISTS test_my2(" | ||
274 | " pub BLOB NOT NULL" | ||
275 | ",sig BLOB NOT NULL" | ||
276 | ",abs_time BIGINT NOT NULL" | ||
277 | ",forever BIGINT NOT NULL" | ||
278 | ",abs_time_nbo BIGINT NOT NULL" | ||
279 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" | ||
280 | ",vsize BLOB NOT NULL" | ||
281 | ",str BLOB NOT NULL" | ||
282 | ",u16 SMALLINT NOT NULL" | ||
283 | ",u32 INT NOT NULL" | ||
284 | ",u64 BIGINT NOT NULL" | ||
285 | ")")) | ||
286 | { | ||
287 | fprintf (stderr, | ||
288 | "Failed to create table. Database likely not setup correctly.\n"); | ||
289 | GNUNET_MYSQL_statements_invalidate (context); | ||
290 | GNUNET_MYSQL_context_destroy (context); | ||
291 | |||
292 | return 77; | ||
293 | } | ||
294 | |||
295 | ret = run_queries (context); | ||
296 | |||
297 | GNUNET_MYSQL_context_destroy (context); | ||
298 | GNUNET_free (config); | ||
299 | |||
300 | return ret; | ||
301 | } | ||
diff --git a/src/my/test_my.conf b/src/my/test_my.conf deleted file mode 100644 index e69de29bb..000000000 --- a/src/my/test_my.conf +++ /dev/null | |||
diff --git a/src/mysql/Makefile.am b/src/mysql/Makefile.am deleted file mode 100644 index 3bfb929cd..000000000 --- a/src/mysql/Makefile.am +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | if USE_COVERAGE | ||
5 | AM_CFLAGS = --coverage | ||
6 | endif | ||
7 | |||
8 | if HAVE_MYSQL | ||
9 | lib_LTLIBRARIES = libgnunetmysql.la | ||
10 | endif | ||
11 | |||
12 | libgnunetmysql_la_SOURCES = \ | ||
13 | mysql.c | ||
14 | libgnunetmysql_la_LIBADD = $(MYSQL_LDFLAGS) -lmysqlclient \ | ||
15 | $(top_builddir)/src/util/libgnunetutil.la | ||
16 | libgnunetmysql_la_LDFLAGS = \ | ||
17 | $(GN_LIB_LDFLAGS) \ | ||
18 | -version-info 0:0:0 | ||
diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c deleted file mode 100644 index 056c2f07f..000000000 --- a/src/mysql/mysql.c +++ /dev/null | |||
@@ -1,485 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file mysql/mysql.c | ||
22 | * @brief library to help with access to a MySQL database | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include <mysql/mysql.h> | ||
27 | #include "gnunet_mysql_lib.h" | ||
28 | #include "gnunet_mysql_compat.h" | ||
29 | |||
30 | /** | ||
31 | * Maximum number of supported parameters for a prepared | ||
32 | * statement. Increase if needed. | ||
33 | */ | ||
34 | #define MAX_PARAM 16 | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Die with an error message that indicates | ||
39 | * a failure of the command 'cmd' with the message given | ||
40 | * by strerror(errno). | ||
41 | */ | ||
42 | #define DIE_MYSQL(cmd, dbh) \ | ||
43 | do \ | ||
44 | { \ | ||
45 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ | ||
46 | "mysql", \ | ||
47 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | ||
48 | cmd, \ | ||
49 | __FILE__, \ | ||
50 | __LINE__, \ | ||
51 | mysql_error ((dbh)->dbf)); \ | ||
52 | GNUNET_assert (0); \ | ||
53 | } while (0); | ||
54 | |||
55 | /** | ||
56 | * Log an error message at log-level 'level' that indicates | ||
57 | * a failure of the command 'cmd' on file 'filename' | ||
58 | * with the message given by strerror(errno). | ||
59 | */ | ||
60 | #define LOG_MYSQL(level, cmd, dbh) \ | ||
61 | do \ | ||
62 | { \ | ||
63 | GNUNET_log_from (level, \ | ||
64 | "mysql", \ | ||
65 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | ||
66 | cmd, \ | ||
67 | __FILE__, \ | ||
68 | __LINE__, \ | ||
69 | mysql_error ((dbh)->dbf)); \ | ||
70 | } while (0); | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Mysql context. | ||
75 | */ | ||
76 | struct GNUNET_MYSQL_Context | ||
77 | { | ||
78 | /** | ||
79 | * Our configuration. | ||
80 | */ | ||
81 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
82 | |||
83 | /** | ||
84 | * Our section. | ||
85 | */ | ||
86 | const char *section; | ||
87 | |||
88 | /** | ||
89 | * Handle to the mysql database. | ||
90 | */ | ||
91 | MYSQL *dbf; | ||
92 | |||
93 | /** | ||
94 | * Head of list of our prepared statements. | ||
95 | */ | ||
96 | struct GNUNET_MYSQL_StatementHandle *shead; | ||
97 | |||
98 | /** | ||
99 | * Tail of list of our prepared statements. | ||
100 | */ | ||
101 | struct GNUNET_MYSQL_StatementHandle *stail; | ||
102 | |||
103 | /** | ||
104 | * Filename of "my.cnf" (msyql configuration). | ||
105 | */ | ||
106 | char *cnffile; | ||
107 | }; | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Handle for a prepared statement. | ||
112 | */ | ||
113 | struct GNUNET_MYSQL_StatementHandle | ||
114 | { | ||
115 | /** | ||
116 | * Kept in a DLL. | ||
117 | */ | ||
118 | struct GNUNET_MYSQL_StatementHandle *next; | ||
119 | |||
120 | /** | ||
121 | * Kept in a DLL. | ||
122 | */ | ||
123 | struct GNUNET_MYSQL_StatementHandle *prev; | ||
124 | |||
125 | /** | ||
126 | * Mysql Context the statement handle belongs to. | ||
127 | */ | ||
128 | struct GNUNET_MYSQL_Context *mc; | ||
129 | |||
130 | /** | ||
131 | * Original query string. | ||
132 | */ | ||
133 | char *query; | ||
134 | |||
135 | /** | ||
136 | * Handle to MySQL prepared statement. | ||
137 | */ | ||
138 | MYSQL_STMT *statement; | ||
139 | |||
140 | /** | ||
141 | * Is the MySQL prepared statement valid, or do we need to re-initialize it? | ||
142 | */ | ||
143 | int valid; | ||
144 | }; | ||
145 | |||
146 | |||
147 | /** | ||
148 | * Obtain the location of ".my.cnf". | ||
149 | * | ||
150 | * @param cfg our configuration | ||
151 | * @param section the section | ||
152 | * @return NULL on error | ||
153 | */ | ||
154 | static char * | ||
155 | get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
156 | const char *section) | ||
157 | { | ||
158 | char *cnffile; | ||
159 | char *home_dir; | ||
160 | struct stat st; | ||
161 | |||
162 | struct passwd *pw; | ||
163 | |||
164 | int configured; | ||
165 | |||
166 | pw = getpwuid (getuid ()); | ||
167 | if (! pw) | ||
168 | { | ||
169 | GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_ERROR, "mysql", "getpwuid"); | ||
170 | return NULL; | ||
171 | } | ||
172 | if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, section, "CONFIG")) | ||
173 | { | ||
174 | GNUNET_assert (GNUNET_OK == | ||
175 | GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
176 | section, | ||
177 | "CONFIG", | ||
178 | &cnffile)); | ||
179 | configured = GNUNET_YES; | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | home_dir = GNUNET_strdup (pw->pw_dir); | ||
184 | GNUNET_asprintf (&cnffile, "%s/.my.cnf", home_dir); | ||
185 | GNUNET_free (home_dir); | ||
186 | configured = GNUNET_NO; | ||
187 | } | ||
188 | |||
189 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | ||
190 | "mysql", | ||
191 | _ ("Trying to use file `%s' for MySQL configuration.\n"), | ||
192 | cnffile); | ||
193 | if ((0 != stat (cnffile, &st)) || (0 != access (cnffile, R_OK)) || | ||
194 | (! S_ISREG (st.st_mode))) | ||
195 | { | ||
196 | if (configured == GNUNET_YES) | ||
197 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
198 | "mysql", | ||
199 | _ ("Could not access file `%s': %s\n"), | ||
200 | cnffile, | ||
201 | strerror (errno)); | ||
202 | GNUNET_free (cnffile); | ||
203 | return NULL; | ||
204 | } | ||
205 | return cnffile; | ||
206 | } | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Open the connection with the database (and initialize | ||
211 | * our default options). | ||
212 | * | ||
213 | * @param mc database context to initialize | ||
214 | * @return #GNUNET_OK on success | ||
215 | */ | ||
216 | static int | ||
217 | iopen (struct GNUNET_MYSQL_Context *mc) | ||
218 | { | ||
219 | char *mysql_dbname; | ||
220 | char *mysql_server; | ||
221 | char *mysql_user; | ||
222 | char *mysql_password; | ||
223 | unsigned long long mysql_port; | ||
224 | MYSQL_BOOL reconnect; | ||
225 | unsigned int timeout; | ||
226 | |||
227 | mc->dbf = mysql_init (NULL); | ||
228 | if (mc->dbf == NULL) | ||
229 | return GNUNET_SYSERR; | ||
230 | if (mc->cnffile != NULL) | ||
231 | mysql_options (mc->dbf, MYSQL_READ_DEFAULT_FILE, mc->cnffile); | ||
232 | mysql_options (mc->dbf, MYSQL_READ_DEFAULT_GROUP, "client"); | ||
233 | reconnect = 0; | ||
234 | mysql_options (mc->dbf, MYSQL_OPT_RECONNECT, &reconnect); | ||
235 | mysql_options (mc->dbf, MYSQL_OPT_CONNECT_TIMEOUT, (const void *) &timeout); | ||
236 | mysql_options (mc->dbf, MYSQL_SET_CHARSET_NAME, "UTF8"); | ||
237 | timeout = 60; /* in seconds */ | ||
238 | mysql_options (mc->dbf, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); | ||
239 | mysql_options (mc->dbf, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); | ||
240 | mysql_dbname = NULL; | ||
241 | if (GNUNET_YES == | ||
242 | GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "DATABASE")) | ||
243 | GNUNET_assert (GNUNET_OK == | ||
244 | GNUNET_CONFIGURATION_get_value_string (mc->cfg, | ||
245 | mc->section, | ||
246 | "DATABASE", | ||
247 | &mysql_dbname)); | ||
248 | else | ||
249 | mysql_dbname = GNUNET_strdup ("gnunet"); | ||
250 | mysql_user = NULL; | ||
251 | if (GNUNET_YES == | ||
252 | GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "USER")) | ||
253 | { | ||
254 | GNUNET_assert (GNUNET_OK == | ||
255 | GNUNET_CONFIGURATION_get_value_string (mc->cfg, | ||
256 | mc->section, | ||
257 | "USER", | ||
258 | &mysql_user)); | ||
259 | } | ||
260 | mysql_password = NULL; | ||
261 | if (GNUNET_YES == | ||
262 | GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "PASSWORD")) | ||
263 | { | ||
264 | GNUNET_assert (GNUNET_OK == | ||
265 | GNUNET_CONFIGURATION_get_value_string (mc->cfg, | ||
266 | mc->section, | ||
267 | "PASSWORD", | ||
268 | &mysql_password)); | ||
269 | } | ||
270 | mysql_server = NULL; | ||
271 | if (GNUNET_YES == | ||
272 | GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "HOST")) | ||
273 | { | ||
274 | GNUNET_assert (GNUNET_OK == | ||
275 | GNUNET_CONFIGURATION_get_value_string (mc->cfg, | ||
276 | mc->section, | ||
277 | "HOST", | ||
278 | &mysql_server)); | ||
279 | } | ||
280 | mysql_port = 0; | ||
281 | if (GNUNET_YES == | ||
282 | GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "PORT")) | ||
283 | { | ||
284 | GNUNET_assert (GNUNET_OK == | ||
285 | GNUNET_CONFIGURATION_get_value_number (mc->cfg, | ||
286 | mc->section, | ||
287 | "PORT", | ||
288 | &mysql_port)); | ||
289 | } | ||
290 | |||
291 | GNUNET_assert (mysql_dbname != NULL); | ||
292 | mysql_real_connect (mc->dbf, | ||
293 | mysql_server, | ||
294 | mysql_user, | ||
295 | mysql_password, | ||
296 | mysql_dbname, | ||
297 | (unsigned int) mysql_port, | ||
298 | NULL, | ||
299 | CLIENT_IGNORE_SIGPIPE); | ||
300 | GNUNET_free (mysql_server); | ||
301 | GNUNET_free (mysql_user); | ||
302 | GNUNET_free (mysql_password); | ||
303 | GNUNET_free (mysql_dbname); | ||
304 | if (mysql_error (mc->dbf)[0]) | ||
305 | { | ||
306 | LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_real_connect", mc); | ||
307 | return GNUNET_SYSERR; | ||
308 | } | ||
309 | return GNUNET_OK; | ||
310 | } | ||
311 | |||
312 | |||
313 | /** | ||
314 | * Create a mysql context. | ||
315 | * | ||
316 | * @param cfg configuration | ||
317 | * @param section configuration section to use to get MySQL configuration options | ||
318 | * @return the mysql context | ||
319 | */ | ||
320 | struct GNUNET_MYSQL_Context * | ||
321 | GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
322 | const char *section) | ||
323 | { | ||
324 | struct GNUNET_MYSQL_Context *mc; | ||
325 | |||
326 | mc = GNUNET_new (struct GNUNET_MYSQL_Context); | ||
327 | mc->cfg = cfg; | ||
328 | mc->section = section; | ||
329 | mc->cnffile = get_my_cnf_path (cfg, section); | ||
330 | |||
331 | return mc; | ||
332 | } | ||
333 | |||
334 | |||
335 | /** | ||
336 | * Close database connection and all prepared statements (we got a DB | ||
337 | * error). | ||
338 | * | ||
339 | * @param mc mysql context | ||
340 | */ | ||
341 | void | ||
342 | GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc) | ||
343 | { | ||
344 | struct GNUNET_MYSQL_StatementHandle *sh; | ||
345 | |||
346 | for (sh = mc->shead; NULL != sh; sh = sh->next) | ||
347 | { | ||
348 | if (GNUNET_YES == sh->valid) | ||
349 | { | ||
350 | mysql_stmt_close (sh->statement); | ||
351 | sh->valid = GNUNET_NO; | ||
352 | } | ||
353 | sh->statement = NULL; | ||
354 | } | ||
355 | if (NULL != mc->dbf) | ||
356 | { | ||
357 | mysql_close (mc->dbf); | ||
358 | mc->dbf = NULL; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | |||
363 | /** | ||
364 | * Destroy a mysql context. Also frees all associated prepared statements. | ||
365 | * | ||
366 | * @param mc context to destroy | ||
367 | */ | ||
368 | void | ||
369 | GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc) | ||
370 | { | ||
371 | struct GNUNET_MYSQL_StatementHandle *sh; | ||
372 | |||
373 | GNUNET_MYSQL_statements_invalidate (mc); | ||
374 | while (NULL != (sh = mc->shead)) | ||
375 | { | ||
376 | GNUNET_CONTAINER_DLL_remove (mc->shead, mc->stail, sh); | ||
377 | GNUNET_free (sh->query); | ||
378 | GNUNET_free (sh); | ||
379 | } | ||
380 | GNUNET_free (mc); | ||
381 | mysql_library_end (); | ||
382 | } | ||
383 | |||
384 | |||
385 | /** | ||
386 | * Prepare a statement. Prepared statements are automatically discarded | ||
387 | * when the MySQL context is destroyed. | ||
388 | * | ||
389 | * @param mc mysql context | ||
390 | * @param query query text | ||
391 | * @return prepared statement, NULL on error | ||
392 | */ | ||
393 | struct GNUNET_MYSQL_StatementHandle * | ||
394 | GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc, | ||
395 | const char *query) | ||
396 | { | ||
397 | struct GNUNET_MYSQL_StatementHandle *sh; | ||
398 | |||
399 | sh = GNUNET_new (struct GNUNET_MYSQL_StatementHandle); | ||
400 | sh->mc = mc; | ||
401 | sh->query = GNUNET_strdup (query); | ||
402 | GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh); | ||
403 | return sh; | ||
404 | } | ||
405 | |||
406 | |||
407 | /** | ||
408 | * Run a SQL statement. | ||
409 | * | ||
410 | * @param mc mysql context | ||
411 | * @param sql SQL statement to run | ||
412 | * @return #GNUNET_OK on success | ||
413 | * #GNUNET_SYSERR if there was a problem | ||
414 | */ | ||
415 | int | ||
416 | GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, const char *sql) | ||
417 | { | ||
418 | if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc))) | ||
419 | return GNUNET_SYSERR; | ||
420 | mysql_query (mc->dbf, sql); | ||
421 | if (mysql_error (mc->dbf)[0]) | ||
422 | { | ||
423 | LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_query", mc); | ||
424 | GNUNET_MYSQL_statements_invalidate (mc); | ||
425 | return GNUNET_SYSERR; | ||
426 | } | ||
427 | return GNUNET_OK; | ||
428 | } | ||
429 | |||
430 | |||
431 | /** | ||
432 | * Prepare a statement for running. | ||
433 | * | ||
434 | * @param sh statement handle to prepare | ||
435 | * @return #GNUNET_OK on success | ||
436 | */ | ||
437 | static int | ||
438 | prepare_statement (struct GNUNET_MYSQL_StatementHandle *sh) | ||
439 | { | ||
440 | struct GNUNET_MYSQL_Context *mc = sh->mc; | ||
441 | |||
442 | if (GNUNET_YES == sh->valid) | ||
443 | return GNUNET_OK; | ||
444 | if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc))) | ||
445 | return GNUNET_SYSERR; | ||
446 | sh->statement = mysql_stmt_init (mc->dbf); | ||
447 | if (NULL == sh->statement) | ||
448 | { | ||
449 | GNUNET_MYSQL_statements_invalidate (mc); | ||
450 | return GNUNET_SYSERR; | ||
451 | } | ||
452 | if (0 != mysql_stmt_prepare (sh->statement, sh->query, strlen (sh->query))) | ||
453 | { | ||
454 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
455 | "mysql", | ||
456 | "prepare_statement: %s\n", | ||
457 | sh->query); | ||
458 | LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare", mc); | ||
459 | mysql_stmt_close (sh->statement); | ||
460 | sh->statement = NULL; | ||
461 | GNUNET_MYSQL_statements_invalidate (mc); | ||
462 | return GNUNET_SYSERR; | ||
463 | } | ||
464 | sh->valid = GNUNET_YES; | ||
465 | return GNUNET_OK; | ||
466 | } | ||
467 | |||
468 | |||
469 | /** | ||
470 | * Get internal handle for a prepared statement. This function should rarely | ||
471 | * be used, and if, with caution! On failures during the interaction with | ||
472 | * the handle, you must call 'GNUNET_MYSQL_statements_invalidate'! | ||
473 | * | ||
474 | * @param sh prepared statement to introspect | ||
475 | * @return MySQL statement handle, NULL on error | ||
476 | */ | ||
477 | MYSQL_STMT * | ||
478 | GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh) | ||
479 | { | ||
480 | (void) prepare_statement (sh); | ||
481 | return sh->statement; | ||
482 | } | ||
483 | |||
484 | |||
485 | /* end of mysql.c */ | ||
diff --git a/src/namecache/meson.build b/src/namecache/meson.build new file mode 100644 index 000000000..aa92454e6 --- /dev/null +++ b/src/namecache/meson.build | |||
@@ -0,0 +1,73 @@ | |||
1 | libgnunetnamecache_src = ['namecache_api.c'] | ||
2 | |||
3 | gnunetnamecache_src = ['gnunet-namecache.c'] | ||
4 | gnunetservicenamecache_src = ['gnunet-service-namecache.c'] | ||
5 | |||
6 | configure_file(input : 'namecache.conf.in', | ||
7 | output : 'namecache.conf', | ||
8 | configuration : cdata, | ||
9 | install: true, | ||
10 | install_dir: pkgcfgdir) | ||
11 | |||
12 | |||
13 | if get_option('monolith') | ||
14 | foreach p : libgnunetnamecache_src + libgnunetpluginnamecache_sqlite_src + gnunetservicenamecache_src | ||
15 | gnunet_src += 'namecache/' + p | ||
16 | endforeach | ||
17 | subdir_done() | ||
18 | endif | ||
19 | |||
20 | libgnunetnamecache = library('gnunetnamecache', | ||
21 | libgnunetnamecache_src, | ||
22 | soversion: '0', | ||
23 | version: '0.0.0', | ||
24 | dependencies: [libgnunetutil_dep, | ||
25 | libgnunetgnsrecord_dep], | ||
26 | include_directories: [incdir, configuration_inc], | ||
27 | install: true, | ||
28 | install_dir: get_option('libdir')) | ||
29 | libgnunetnamecache_dep = declare_dependency(link_with : libgnunetnamecache) | ||
30 | pkg.generate(libgnunetnamecache, url: 'https://www.gnunet.org', | ||
31 | description : 'Provides API for storing GNS records to a cache') | ||
32 | |||
33 | shared_module('gnunet_plugin_namecache_sqlite', | ||
34 | ['plugin_namecache_sqlite.c'], | ||
35 | dependencies: [libgnunetutil_dep, | ||
36 | libgnunetgnsrecord_dep, | ||
37 | sqlite_dep, | ||
38 | libgnunetsq_dep], | ||
39 | include_directories: [incdir, configuration_inc], | ||
40 | install: true, | ||
41 | install_dir: get_option('libdir')/'gnunet') | ||
42 | |||
43 | if pq_dep.found() | ||
44 | shared_module('gnunet_plugin_namecache_postgres', | ||
45 | ['plugin_namecache_postgres.c'], | ||
46 | dependencies: [libgnunetutil_dep, | ||
47 | libgnunetgnsrecord_dep, | ||
48 | pq_dep, | ||
49 | libgnunetpq_dep], | ||
50 | include_directories: [incdir, configuration_inc], | ||
51 | install: true, | ||
52 | install_dir: get_option('libdir')/'gnunet') | ||
53 | endif | ||
54 | |||
55 | executable ('gnunet-namecache', | ||
56 | gnunetnamecache_src, | ||
57 | dependencies: [libgnunetnamecache_dep, | ||
58 | libgnunetutil_dep, | ||
59 | libgnunetgnsrecord_dep, | ||
60 | libgnunetidentity_dep], | ||
61 | include_directories: [incdir, configuration_inc], | ||
62 | install: true, | ||
63 | install_dir: get_option('bindir')) | ||
64 | executable ('gnunet-service-namecache', | ||
65 | gnunetservicenamecache_src, | ||
66 | dependencies: [libgnunetnamecache_dep, | ||
67 | libgnunetutil_dep, | ||
68 | libgnunetgnsrecord_dep, | ||
69 | libgnunetstatistics_dep], | ||
70 | include_directories: [incdir, configuration_inc], | ||
71 | install: true, | ||
72 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
73 | |||
diff --git a/src/namecache/test_plugin_namecache.c b/src/namecache/test_plugin_namecache.c index 242b3503b..141698a23 100644 --- a/src/namecache/test_plugin_namecache.c +++ b/src/namecache/test_plugin_namecache.c | |||
@@ -113,7 +113,7 @@ main (int argc, char *argv[]) | |||
113 | GNUNET_GETOPT_OPTION_END | 113 | GNUNET_GETOPT_OPTION_END |
114 | }; | 114 | }; |
115 | 115 | ||
116 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 116 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
117 | GNUNET_snprintf (cfg_name, sizeof(cfg_name), "test_plugin_namecache_%s.conf", | 117 | GNUNET_snprintf (cfg_name, sizeof(cfg_name), "test_plugin_namecache_%s.conf", |
118 | plugin_name); | 118 | plugin_name); |
119 | 119 | ||
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index ed06b1dc5..f6594c6f9 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1738,14 +1738,12 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1738 | size_t rp_msg_len; | 1738 | size_t rp_msg_len; |
1739 | size_t rs_len; | 1739 | size_t rs_len; |
1740 | size_t rs_off; | 1740 | size_t rs_off; |
1741 | size_t body_len; | ||
1742 | struct StoreActivity *sa; | 1741 | struct StoreActivity *sa; |
1743 | struct RecordSet *rs; | 1742 | struct RecordSet *rs; |
1744 | enum GNUNET_ErrorCode res; | 1743 | enum GNUNET_ErrorCode res; |
1745 | 1744 | ||
1746 | key_len = ntohs (rp_msg->key_len); | 1745 | key_len = ntohs (rp_msg->key_len); |
1747 | rp_msg_len = ntohs (rp_msg->gns_header.header.size); | 1746 | rp_msg_len = ntohs (rp_msg->gns_header.header.size); |
1748 | body_len = rp_msg_len - sizeof (*rp_msg); | ||
1749 | rs_off = sizeof (*rp_msg) + key_len; | 1747 | rs_off = sizeof (*rp_msg) + key_len; |
1750 | rs_len = rp_msg_len - rs_off; | 1748 | rs_len = rp_msg_len - rs_off; |
1751 | if ((GNUNET_SYSERR == | 1749 | if ((GNUNET_SYSERR == |
diff --git a/src/namestore/meson.build b/src/namestore/meson.build new file mode 100644 index 000000000..fd7cfe553 --- /dev/null +++ b/src/namestore/meson.build | |||
@@ -0,0 +1,139 @@ | |||
1 | libgnunetnamestore_src = ['namestore_api.c', 'namestore_api_monitor.c'] | ||
2 | libgnunetpluginnamestore_sqlite_src = ['plugin_namestore_sqlite.c'] | ||
3 | |||
4 | gnunetnamestore_src = ['gnunet-namestore.c'] | ||
5 | gnunetservicenamestore_src = ['gnunet-service-namestore.c'] | ||
6 | |||
7 | configure_file(input : 'namestore.conf.in', | ||
8 | output : 'namestore.conf', | ||
9 | configuration : cdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetnamestore_src + libgnunetpluginnamestore_sqlite_src + gnunetservicenamestore_src | ||
16 | gnunet_src += 'namestore/' + p | ||
17 | endforeach | ||
18 | subdir_done() | ||
19 | endif | ||
20 | |||
21 | libgnunetnamestore = library('gnunetnamestore', | ||
22 | libgnunetnamestore_src, | ||
23 | soversion: '0', | ||
24 | version: '0.0.1', | ||
25 | dependencies: [libgnunetutil_dep, | ||
26 | libgnunetgnsrecord_dep, | ||
27 | libgnunetidentity_dep], | ||
28 | include_directories: [incdir, configuration_inc], | ||
29 | install: true, | ||
30 | install_dir: get_option('libdir')) | ||
31 | libgnunetnamestore_dep = declare_dependency(link_with : libgnunetnamestore) | ||
32 | pkg.generate(libgnunetnamestore, url: 'https://www.gnunet.org', | ||
33 | description : 'Provides API for storing GNS records to a database') | ||
34 | |||
35 | shared_module('gnunet_plugin_rest_namestore', | ||
36 | ['plugin_rest_namestore.c'], | ||
37 | dependencies: [libgnunetrest_dep, | ||
38 | libgnunetidentity_dep, | ||
39 | libgnunetgnsrecordjson_dep, | ||
40 | libgnunetgnsrecord_dep, | ||
41 | libgnunetnamestore_dep, | ||
42 | libgnunetjson_dep, | ||
43 | libgnunetutil_dep, | ||
44 | json_dep, | ||
45 | mhd_dep], | ||
46 | include_directories: [incdir, configuration_inc], | ||
47 | install: true, | ||
48 | install_dir: get_option('libdir') / 'gnunet') | ||
49 | |||
50 | |||
51 | shared_module('gnunet_plugin_namestore_sqlite', | ||
52 | libgnunetpluginnamestore_sqlite_src, | ||
53 | dependencies: [libgnunetutil_dep, | ||
54 | libgnunetgnsrecord_dep, | ||
55 | libgnunetidentity_dep, | ||
56 | libgnunetsq_dep, | ||
57 | libgnunetstatistics_dep, | ||
58 | sqlite_dep], | ||
59 | include_directories: [incdir, configuration_inc], | ||
60 | install: true, | ||
61 | install_dir: get_option('libdir')/'gnunet') | ||
62 | |||
63 | if pq_dep.found() | ||
64 | shared_module('gnunet_plugin_namestore_postgres', | ||
65 | ['plugin_namestore_postgres.c'], | ||
66 | dependencies: [libgnunetutil_dep, | ||
67 | libgnunetgnsrecord_dep, | ||
68 | libgnunetidentity_dep, | ||
69 | libgnunetpq_dep, | ||
70 | libgnunetstatistics_dep, | ||
71 | pq_dep], | ||
72 | include_directories: [incdir, configuration_inc], | ||
73 | install: true, | ||
74 | install_dir: get_option('libdir')/'gnunet') | ||
75 | endif | ||
76 | |||
77 | executable ('gnunet-namestore', | ||
78 | gnunetnamestore_src, | ||
79 | dependencies: [libgnunetnamestore_dep, | ||
80 | libgnunetutil_dep, | ||
81 | libgnunetgnsrecord_dep, | ||
82 | libgnunetidentity_dep], | ||
83 | include_directories: [incdir, configuration_inc], | ||
84 | install: true, | ||
85 | install_dir: get_option('bindir')) | ||
86 | executable ('gnunet-namestore-dbtool', | ||
87 | ['gnunet-namestore-dbtool.c'], | ||
88 | dependencies: [libgnunetnamestore_dep, | ||
89 | libgnunetutil_dep, | ||
90 | libgnunetgnsrecord_dep, | ||
91 | libgnunetidentity_dep], | ||
92 | include_directories: [incdir, configuration_inc], | ||
93 | install: true, | ||
94 | install_dir: get_option('bindir')) | ||
95 | executable ('gnunet-namestore-zonefile', | ||
96 | ['gnunet-namestore-zonefile.c'], | ||
97 | dependencies: [libgnunetnamestore_dep, | ||
98 | libgnunetutil_dep, | ||
99 | libgnunetgnsrecord_dep, | ||
100 | libgnunetidentity_dep], | ||
101 | include_directories: [incdir, configuration_inc], | ||
102 | install: true, | ||
103 | install_dir: get_option('bindir')) | ||
104 | executable ('gnunet-zoneimport', | ||
105 | ['gnunet-zoneimport.c'], | ||
106 | dependencies: [libgnunetnamestore_dep, | ||
107 | libgnunetutil_dep, | ||
108 | libgnunetstatistics_dep, | ||
109 | libgnunetgnsrecord_dep, | ||
110 | libgnunetidentity_dep], | ||
111 | include_directories: [incdir, configuration_inc], | ||
112 | install: true, | ||
113 | install_dir: get_option('bindir')) | ||
114 | executable ('gnunet-service-namestore', | ||
115 | gnunetservicenamestore_src, | ||
116 | dependencies: [libgnunetnamestore_dep, | ||
117 | libgnunetutil_dep, | ||
118 | libgnunetnamecache_dep, | ||
119 | libgnunetgnsrecord_dep, | ||
120 | libgnunetidentity_dep, | ||
121 | libgnunetstatistics_dep], | ||
122 | include_directories: [incdir, configuration_inc], | ||
123 | install: true, | ||
124 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
125 | executable ('gnunet-namestore-fcfsd', | ||
126 | ['gnunet-namestore-fcfsd.c'], | ||
127 | dependencies: [libgnunetnamestore_dep, | ||
128 | libgnunetutil_dep, | ||
129 | libgnunetnamecache_dep, | ||
130 | libgnunetgnsrecord_dep, | ||
131 | libgnunetidentity_dep, | ||
132 | mhd_dep, | ||
133 | json_dep, | ||
134 | libgnunetjson_dep, | ||
135 | libgnunetstatistics_dep], | ||
136 | include_directories: [incdir, configuration_inc], | ||
137 | install: true, | ||
138 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
139 | |||
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c index 60749a0b1..4df24a7f7 100644 --- a/src/namestore/test_common.c +++ b/src/namestore/test_common.c | |||
@@ -98,7 +98,7 @@ TNC_test_plugin (const char *cfg_name) | |||
98 | do \ | 98 | do \ |
99 | { \ | 99 | { \ |
100 | GNUNET_log_setup (__FILE__, "WARNING", NULL); \ | 100 | GNUNET_log_setup (__FILE__, "WARNING", NULL); \ |
101 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ | 101 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); \ |
102 | GNUNET_asprintf (&cfg_name, file_template, plugin_name); \ | 102 | GNUNET_asprintf (&cfg_name, file_template, plugin_name); \ |
103 | if (! TNC_test_plugin (cfg_name)) \ | 103 | if (! TNC_test_plugin (cfg_name)) \ |
104 | { \ | 104 | { \ |
@@ -116,7 +116,7 @@ TNC_test_plugin (const char *cfg_name) | |||
116 | do \ | 116 | do \ |
117 | { \ | 117 | { \ |
118 | GNUNET_log_setup (__FILE__, "WARNING", NULL); \ | 118 | GNUNET_log_setup (__FILE__, "WARNING", NULL); \ |
119 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ | 119 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); \ |
120 | GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \ | 120 | GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \ |
121 | if (! TNC_test_plugin (cfg_name)) \ | 121 | if (! TNC_test_plugin (cfg_name)) \ |
122 | { \ | 122 | { \ |
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index b89cc95d0..d82a3d349 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c | |||
@@ -195,7 +195,7 @@ main (int argc, char *argv[]) | |||
195 | { GNUNET_GETOPT_OPTION_END }; | 195 | { GNUNET_GETOPT_OPTION_END }; |
196 | 196 | ||
197 | GNUNET_log_setup ("test-plugin-namestore", "WARNING", NULL); | 197 | GNUNET_log_setup ("test-plugin-namestore", "WARNING", NULL); |
198 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 198 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
199 | GNUNET_snprintf (cfg_name, | 199 | GNUNET_snprintf (cfg_name, |
200 | sizeof(cfg_name), | 200 | sizeof(cfg_name), |
201 | "test_plugin_namestore_%s.conf", | 201 | "test_plugin_namestore_%s.conf", |
diff --git a/src/nat-auto/meson.build b/src/nat-auto/meson.build new file mode 100644 index 000000000..eaa64f124 --- /dev/null +++ b/src/nat-auto/meson.build | |||
@@ -0,0 +1,51 @@ | |||
1 | libgnunetnatauto_src = ['nat_auto_api.c', | ||
2 | 'nat_auto_api_test.c'] | ||
3 | |||
4 | gnunetservernat_src = ['gnunet-nat-server.c'] | ||
5 | gnunetservicenatauto_src = ['gnunet-service-nat-auto.c'] | ||
6 | |||
7 | configure_file(input : 'nat-auto.conf.in', | ||
8 | output : 'nat-auto.conf', | ||
9 | configuration : cdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | if get_option('monolith') | ||
14 | foreach p : libgnunetnatauto_src + gnunetservernatauto_src + gnunetservicenatauto_src | ||
15 | gnunet_src += 'nat-auto/' + p | ||
16 | endforeach | ||
17 | subdir_done() | ||
18 | endif | ||
19 | |||
20 | libgnunetnatauto = library('gnunetnatauto', | ||
21 | libgnunetnatauto_src, | ||
22 | soversion: '0', | ||
23 | version: '0.0.0', | ||
24 | dependencies: [libgnunetutil_dep, libgnunetnat_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunetnatauto_dep = declare_dependency(link_with : libgnunetnatauto) | ||
29 | |||
30 | executable ('gnunet-nat-auto', | ||
31 | ['gnunet-nat-auto.c'], | ||
32 | dependencies: [libgnunetnatauto_dep, libgnunetutil_dep, | ||
33 | libgnunetnat_dep], | ||
34 | include_directories: [incdir, configuration_inc], | ||
35 | install: true, | ||
36 | install_dir: get_option('bindir')) | ||
37 | executable ('gnunet-nat-server', | ||
38 | gnunetservernat_src, | ||
39 | dependencies: [libgnunetnatauto_dep, libgnunetutil_dep, libgnunetnat_dep], | ||
40 | include_directories: [incdir, configuration_inc], | ||
41 | install: true, | ||
42 | install_dir: get_option('bindir')) | ||
43 | executable ('gnunet-service-nat-auto', | ||
44 | gnunetservicenatauto_src, | ||
45 | dependencies: [libgnunetnatauto_dep, libgnunetutil_dep, | ||
46 | libgnunetnat_dep, | ||
47 | libgnunetstatistics_dep], | ||
48 | include_directories: [incdir, configuration_inc], | ||
49 | install: true, | ||
50 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
51 | |||
diff --git a/src/nat/meson.build b/src/nat/meson.build new file mode 100644 index 000000000..e629f6411 --- /dev/null +++ b/src/nat/meson.build | |||
@@ -0,0 +1,75 @@ | |||
1 | libgnunetnat_src = ['nat_api.c', | ||
2 | 'nat_api_stun.c'] | ||
3 | |||
4 | gnunetservicenat_src = ['gnunet-service-nat.c', | ||
5 | 'gnunet-service-nat.c', | ||
6 | 'gnunet-service-nat_externalip.c', | ||
7 | 'gnunet-service-nat_stun.c', | ||
8 | 'gnunet-service-nat_mini.c', | ||
9 | 'gnunet-service-nat_helper.c'] | ||
10 | |||
11 | configure_file(input : 'nat.conf.in', | ||
12 | output : 'nat.conf', | ||
13 | configuration : cdata, | ||
14 | install: true, | ||
15 | install_dir: pkgcfgdir) | ||
16 | |||
17 | |||
18 | if get_option('monolith') | ||
19 | foreach p : libgnunetnat_src + gnunetservicenat_src | ||
20 | gnunet_src += 'nat/' + p | ||
21 | endforeach | ||
22 | subdir_done() | ||
23 | endif | ||
24 | |||
25 | libgnunetnat = library('gnunetnat', | ||
26 | libgnunetnat_src, | ||
27 | soversion: '2', | ||
28 | version: '2.0.0', | ||
29 | dependencies: libgnunetutil_dep, | ||
30 | include_directories: [incdir, configuration_inc], | ||
31 | install: true, | ||
32 | install_dir: get_option('libdir')) | ||
33 | libgnunetnat_dep = declare_dependency(link_with : libgnunetnat) | ||
34 | pkg.generate(libgnunetnat, url: 'https://www.gnunet.org', | ||
35 | description : 'Provides API for accessing the NAT service') | ||
36 | libgnunetnat = library('gnunetnatnew', | ||
37 | ['nat_api.c', | ||
38 | 'nat_api_stun.c'], | ||
39 | soversion: '2', | ||
40 | version: '2.0.0', | ||
41 | dependencies: libgnunetutil_dep, | ||
42 | include_directories: [incdir, configuration_inc], | ||
43 | install: true, | ||
44 | install_dir: get_option('libdir')) | ||
45 | libgnunetnat_dep = declare_dependency(link_with : libgnunetnat) | ||
46 | |||
47 | executable ('gnunet-nat', | ||
48 | ['gnunet-nat.c'], | ||
49 | dependencies: [libgnunetnat_dep, libgnunetutil_dep], | ||
50 | include_directories: [incdir, configuration_inc], | ||
51 | install: true, | ||
52 | install_dir: get_option('bindir')) | ||
53 | |||
54 | executable ('gnunet-service-nat', | ||
55 | gnunetservicenat_src, | ||
56 | dependencies: [libgnunetnat_dep, libgnunetutil_dep, | ||
57 | libgnunetstatistics_dep], | ||
58 | include_directories: [incdir, configuration_inc], | ||
59 | install: true, | ||
60 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
61 | executable ('gnunet-helper-nat-server', | ||
62 | ['gnunet-helper-nat-server.c'], | ||
63 | dependencies: [libgnunetnat_dep, libgnunetutil_dep, | ||
64 | libgnunetstatistics_dep], | ||
65 | include_directories: [incdir, configuration_inc], | ||
66 | install: true, | ||
67 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
68 | executable ('gnunet-helper-nat-client', | ||
69 | ['gnunet-helper-nat-client.c'], | ||
70 | dependencies: [libgnunetnat_dep, libgnunetutil_dep, | ||
71 | libgnunetstatistics_dep], | ||
72 | include_directories: [incdir, configuration_inc], | ||
73 | install: true, | ||
74 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
75 | |||
diff --git a/src/nse/meson.build b/src/nse/meson.build new file mode 100644 index 000000000..7490214a3 --- /dev/null +++ b/src/nse/meson.build | |||
@@ -0,0 +1,47 @@ | |||
1 | libgnunetnse_src = ['nse_api.c'] | ||
2 | |||
3 | gnunetservicense_src = ['gnunet-service-nse.c'] | ||
4 | |||
5 | configure_file(input : 'nse.conf.in', | ||
6 | output : 'nse.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetnse_src + gnunetservicense_src | ||
14 | gnunet_src += 'nse/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | libgnunetnse = library('gnunetnse', | ||
20 | libgnunetnse_src, | ||
21 | soversion: '0', | ||
22 | version: '0.0.0', | ||
23 | dependencies: libgnunetutil_dep, | ||
24 | include_directories: [incdir, configuration_inc], | ||
25 | install: true, | ||
26 | install_dir: get_option('libdir')) | ||
27 | libgnunetnse_dep = declare_dependency(link_with : libgnunetnse) | ||
28 | pkg.generate(libgnunetnse, url: 'https://www.gnunet.org', | ||
29 | description : 'Provides API for accessing the NSE service') | ||
30 | |||
31 | executable ('gnunet-nse', | ||
32 | ['gnunet-nse.c'], | ||
33 | dependencies: [libgnunetnse_dep, m_dep, libgnunetutil_dep], | ||
34 | include_directories: [incdir, configuration_inc], | ||
35 | install: true, | ||
36 | install_dir: get_option('bindir')) | ||
37 | |||
38 | executable ('gnunet-service-nse', | ||
39 | gnunetservicense_src, | ||
40 | dependencies: [libgnunetnse_dep, libgnunetutil_dep, | ||
41 | libgnunetcore_dep, | ||
42 | m_dep, | ||
43 | libgnunetstatistics_dep], | ||
44 | include_directories: [incdir, configuration_inc], | ||
45 | install: true, | ||
46 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
47 | |||
diff --git a/src/nt/meson.build b/src/nt/meson.build new file mode 100644 index 000000000..9b2a97568 --- /dev/null +++ b/src/nt/meson.build | |||
@@ -0,0 +1,21 @@ | |||
1 | libgnunetnt_src = ['nt.c'] | ||
2 | |||
3 | if get_option('monolith') | ||
4 | foreach p : libgnunetnt_src | ||
5 | gnunet_src += 'nt/' + p | ||
6 | endforeach | ||
7 | subdir_done() | ||
8 | endif | ||
9 | |||
10 | libgnunetnt = library('gnunetnt', | ||
11 | libgnunetnt_src, | ||
12 | soversion: '0', | ||
13 | version: '0.0.0', | ||
14 | dependencies: libgnunetutil_dep, | ||
15 | include_directories: [incdir, configuration_inc], | ||
16 | install: true, | ||
17 | install_dir: get_option('libdir')) | ||
18 | libgnunetnt_dep = declare_dependency(link_with : libgnunetnt) | ||
19 | pkg.generate(libgnunetnt, url: 'https://www.gnunet.org', | ||
20 | description : 'Provides API for accessing GNUnet NT') | ||
21 | |||
diff --git a/src/peerinfo-tool/meson.build b/src/peerinfo-tool/meson.build new file mode 100644 index 000000000..2d5386eba --- /dev/null +++ b/src/peerinfo-tool/meson.build | |||
@@ -0,0 +1,31 @@ | |||
1 | gnunetpeerinfotool_src = ['gnunet-peerinfo.c', 'gnunet-peerinfo_plugins.c'] | ||
2 | |||
3 | |||
4 | if get_option('monolith') | ||
5 | subdir_done() | ||
6 | endif | ||
7 | |||
8 | shared_module('gnunet_plugin_rest_peerinfo', | ||
9 | ['plugin_rest_peerinfo.c'], | ||
10 | dependencies: [libgnunetrest_dep, | ||
11 | libgnunetpeerinfo_dep, | ||
12 | libgnunettransport_dep, | ||
13 | libgnunethello_dep, | ||
14 | libgnunetutil_dep, | ||
15 | json_dep, | ||
16 | mhd_dep], | ||
17 | include_directories: [incdir, configuration_inc], | ||
18 | install: true, | ||
19 | install_dir: get_option('libdir') / 'gnunet') | ||
20 | |||
21 | |||
22 | executable ('gnunet-peerinfo', | ||
23 | gnunetpeerinfotool_src, | ||
24 | dependencies: [libgnunetutil_dep, | ||
25 | libgnunetpeerinfo_dep, | ||
26 | libgnunettransport_dep, | ||
27 | libgnunethello_dep, | ||
28 | libgnunetstatistics_dep], | ||
29 | include_directories: [incdir, configuration_inc], | ||
30 | install: true, | ||
31 | install_dir: get_option('bindir')) | ||
diff --git a/src/peerinfo/meson.build b/src/peerinfo/meson.build new file mode 100644 index 000000000..ea9aaa331 --- /dev/null +++ b/src/peerinfo/meson.build | |||
@@ -0,0 +1,41 @@ | |||
1 | libgnunetpeerinfo_src = ['peerinfo_api.c', | ||
2 | 'peerinfo_api_notify.c'] | ||
3 | |||
4 | gnunetservicepeerinfo_src = ['gnunet-service-peerinfo.c'] | ||
5 | |||
6 | configure_file(input : 'peerinfo.conf.in', | ||
7 | output : 'peerinfo.conf', | ||
8 | configuration : cdata, | ||
9 | install: true, | ||
10 | install_dir: pkgcfgdir) | ||
11 | |||
12 | |||
13 | if get_option('monolith') | ||
14 | foreach p : libgnunetpeerinfo_src + gnunetservicepeerinfo_src | ||
15 | gnunet_src += 'peerinfo/' + p | ||
16 | endforeach | ||
17 | subdir_done() | ||
18 | endif | ||
19 | |||
20 | libgnunetpeerinfo = library('gnunetpeerinfo', | ||
21 | libgnunetpeerinfo_src, | ||
22 | soversion: '0', | ||
23 | version: '0.0.0', | ||
24 | dependencies: [libgnunetutil_dep, libgnunethello_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunetpeerinfo_dep = declare_dependency(link_with : libgnunetpeerinfo) | ||
29 | pkg.generate(libgnunetpeerinfo, url: 'https://www.gnunet.org', | ||
30 | description : 'Provides API for accessing the peerinfo service') | ||
31 | |||
32 | executable ('gnunet-service-peerinfo', | ||
33 | gnunetservicepeerinfo_src, | ||
34 | dependencies: [libgnunetpeerinfo_dep, | ||
35 | libgnunetutil_dep, | ||
36 | libgnunetstatistics_dep, | ||
37 | libgnunethello_dep], | ||
38 | include_directories: [incdir, configuration_inc], | ||
39 | install: true, | ||
40 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
41 | |||
diff --git a/src/peerstore/meson.build b/src/peerstore/meson.build new file mode 100644 index 000000000..7fcbf284b --- /dev/null +++ b/src/peerstore/meson.build | |||
@@ -0,0 +1,48 @@ | |||
1 | libgnunetpeerstore_src = ['peerstore_api.c', | ||
2 | 'peerstore_common.c'] | ||
3 | |||
4 | gnunetservicepeerstore_src = ['gnunet-service-peerstore.c'] | ||
5 | |||
6 | configure_file(input : 'peerstore.conf.in', | ||
7 | output : 'peerstore.conf', | ||
8 | configuration : cdata, | ||
9 | install: true, | ||
10 | install_dir: pkgcfgdir) | ||
11 | |||
12 | |||
13 | if get_option('monolith') | ||
14 | foreach p : libgnunetpeerstore_src + gnunetservicepeerstore_src | ||
15 | gnunet_src += 'peerstore/' + p | ||
16 | endforeach | ||
17 | subdir_done() | ||
18 | endif | ||
19 | |||
20 | libgnunetpeerstore = library('gnunetpeerstore', | ||
21 | libgnunetpeerstore_src, | ||
22 | soversion: '0', | ||
23 | version: '0.0.0', | ||
24 | dependencies: libgnunetutil_dep, | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | pkg.generate(libgnunetpeerstore, url: 'https://www.gnunet.org', | ||
29 | description : 'Provides API for accessing the peerstore service') | ||
30 | libgnunetpeerstore_dep = declare_dependency(link_with : libgnunetpeerstore) | ||
31 | |||
32 | shared_module('gnunet_plugin_peerstore_sqlite', | ||
33 | ['plugin_peerstore_sqlite.c'], | ||
34 | dependencies: [libgnunetutil_dep, | ||
35 | libgnunetpeerstore_dep, | ||
36 | libgnunetsq_dep, | ||
37 | sqlite_dep], | ||
38 | include_directories: [incdir, configuration_inc], | ||
39 | install: true, | ||
40 | install_dir: get_option('libdir')/'gnunet') | ||
41 | |||
42 | executable ('gnunet-service-peerstore', | ||
43 | gnunetservicepeerstore_src, | ||
44 | dependencies: [libgnunetpeerstore_dep, libgnunetutil_dep], | ||
45 | include_directories: [incdir, configuration_inc], | ||
46 | install: true, | ||
47 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
48 | |||
diff --git a/src/peerstore/test_plugin_peerstore.c b/src/peerstore/test_plugin_peerstore.c index a4221ea63..bce62dda9 100644 --- a/src/peerstore/test_plugin_peerstore.c +++ b/src/peerstore/test_plugin_peerstore.c | |||
@@ -201,7 +201,7 @@ main (int argc, char *argv[]) | |||
201 | GNUNET_log_setup ("test-plugin-peerstore", | 201 | GNUNET_log_setup ("test-plugin-peerstore", |
202 | "WARNING", | 202 | "WARNING", |
203 | NULL); | 203 | NULL); |
204 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 204 | plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
205 | GNUNET_snprintf (cfg_name, | 205 | GNUNET_snprintf (cfg_name, |
206 | sizeof(cfg_name), | 206 | sizeof(cfg_name), |
207 | "test_plugin_peerstore_%s.conf", | 207 | "test_plugin_peerstore_%s.conf", |
diff --git a/src/pq/meson.build b/src/pq/meson.build new file mode 100644 index 000000000..b9b20d93c --- /dev/null +++ b/src/pq/meson.build | |||
@@ -0,0 +1,25 @@ | |||
1 | libgnunetpq_src = ['pq.c', | ||
2 | 'pq_connect.c', | ||
3 | 'pq_eval.c', | ||
4 | 'pq_event.c', | ||
5 | 'pq_exec.c', | ||
6 | 'pq_prepare.c', | ||
7 | 'pq_query_helper.c', | ||
8 | 'pq_result_helper.c'] | ||
9 | |||
10 | if get_option('monolith') | ||
11 | foreach p : libgnunetpq_src | ||
12 | gnunet_src += 'pq/' + p | ||
13 | endforeach | ||
14 | subdir_done() | ||
15 | endif | ||
16 | |||
17 | libgnunetpq = library('gnunetpq', | ||
18 | libgnunetpq_src, | ||
19 | soversion: '4', | ||
20 | version: '4.0.0', | ||
21 | dependencies: [libgnunetutil_dep, pq_dep], | ||
22 | include_directories: [incdir, configuration_inc], | ||
23 | install: true, | ||
24 | install_dir: get_option('libdir')) | ||
25 | libgnunetpq_dep = declare_dependency(link_with : libgnunetpq) | ||
diff --git a/src/pq/pq.c b/src/pq/pq.c index 6d47f4748..65e051bfc 100644 --- a/src/pq/pq.c +++ b/src/pq/pq.c | |||
@@ -24,8 +24,8 @@ | |||
24 | * @author Florian Dold | 24 | * @author Florian Dold |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | */ | 26 | */ |
27 | #include "gnunet_pq_lib.h" | ||
28 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_pq_lib.h" | ||
29 | #include "pq.h" | 29 | #include "pq.h" |
30 | 30 | ||
31 | 31 | ||
@@ -195,7 +195,7 @@ GNUNET_PQ_extract_result (PGresult *result, | |||
195 | *spec->result_size = spec->dst_size; | 195 | *spec->result_size = spec->dst_size; |
196 | } | 196 | } |
197 | return GNUNET_OK; | 197 | return GNUNET_OK; |
198 | cleanup: | 198 | cleanup: |
199 | for (unsigned int j = 0; j < i; j++) | 199 | for (unsigned int j = 0; j < i; j++) |
200 | if (NULL != rs[j].cleaner) | 200 | if (NULL != rs[j].cleaner) |
201 | rs[j].cleaner (rs[j].cls, | 201 | rs[j].cleaner (rs[j].cls, |
diff --git a/src/pq/pq.h b/src/pq/pq.h index 0c011a6ef..65b72cedd 100644 --- a/src/pq/pq.h +++ b/src/pq/pq.h | |||
@@ -100,9 +100,27 @@ struct GNUNET_PQ_Context | |||
100 | enum GNUNET_PQ_Options flags; | 100 | enum GNUNET_PQ_Options flags; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Mapping between array types and Oid's, filled at reconnect | 103 | * Mapping between array types and Oid's, pre-filled at reconnect. |
104 | * More entries are captured in via GNUNET_PQ_get_oid_by_name. | ||
104 | */ | 105 | */ |
105 | Oid oids[GNUNET_PQ_DATATYPE_MAX]; | 106 | struct |
107 | { | ||
108 | /* Allocated number of elements array the table */ | ||
109 | unsigned int cap; | ||
110 | |||
111 | /* Number of entries in the table */ | ||
112 | unsigned int num; | ||
113 | |||
114 | /* The table of (name, oid) pairs. | ||
115 | * Note that the names are 'const char *' and the pointers should be point | ||
116 | * to the same string throughout the lifetime of the program.*/ | ||
117 | struct name2oid | ||
118 | { | ||
119 | const char *name; | ||
120 | Oid oid; | ||
121 | } *table; | ||
122 | |||
123 | } oids; | ||
106 | }; | 124 | }; |
107 | 125 | ||
108 | 126 | ||
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index 9493eb2d7..c46d865a3 100644 --- a/src/pq/pq_connect.c +++ b/src/pq/pq_connect.c | |||
@@ -322,97 +322,100 @@ GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db) | |||
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | /** | 325 | enum GNUNET_GenericReturnValue |
326 | * Retrieves the Oid's for the supported array types and sets db->arraytype2oid | 326 | GNUNET_PQ_get_oid_by_name ( |
327 | * on succes. | 327 | struct GNUNET_PQ_Context *db, |
328 | * | 328 | const char *name, |
329 | * @param[in,out] db Context for the database connection | 329 | Oid *oid) |
330 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
331 | */ | ||
332 | static enum GNUNET_GenericReturnValue | ||
333 | get_array_type_oids (struct GNUNET_PQ_Context *db) | ||
334 | { | 330 | { |
335 | PGresult *res; | 331 | /* Check if the entry is in the cache already */ |
336 | ExecStatusType est; | 332 | for (unsigned int i = 0; i < db->oids.num; i++) |
337 | |||
338 | GNUNET_assert (NULL != db); | ||
339 | /* Initialize to Oid(0) (= unknown) */ | ||
340 | memset (db->oids, | ||
341 | 0, | ||
342 | sizeof(db->oids)); | ||
343 | |||
344 | res = PQexec (db->conn, | ||
345 | "SELECT" | ||
346 | " typname, oid" | ||
347 | " FROM pg_type " | ||
348 | " WHERE typname in " | ||
349 | " ('bool', 'int2', 'int4', 'int8', 'bytea', 'varchar');"); | ||
350 | |||
351 | est = PQresultStatus (res); | ||
352 | if ( (PGRES_COMMAND_OK != est) && | ||
353 | (PGRES_TUPLES_OK != est)) | ||
354 | { | 333 | { |
355 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 334 | /* Pointer comparison */ |
356 | "Failed to run statement to retrieve Oids for array types!\n"); | 335 | if (name == db->oids.table[i].name) |
357 | return GNUNET_SYSERR; | 336 | { |
337 | *oid = db->oids.table[i].oid; | ||
338 | return GNUNET_OK; | ||
339 | } | ||
358 | } | 340 | } |
359 | 341 | ||
360 | if ( (2 != PQnfields (res)) || | 342 | /* No entry found in cache, ask database */ |
361 | (0 != PQfnumber (res, "typname")) || | ||
362 | (1 != PQfnumber (res, "oid")) | ||
363 | ) | ||
364 | { | 343 | { |
365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 344 | enum GNUNET_DB_QueryStatus qs; |
366 | "Unexpected table retrieved for array types\n"); | 345 | struct GNUNET_PQ_QueryParam params[] = { |
367 | return GNUNET_SYSERR; | 346 | GNUNET_PQ_query_param_string (name), |
347 | GNUNET_PQ_query_param_end | ||
348 | }; | ||
349 | struct GNUNET_PQ_ResultSpec spec[] = { | ||
350 | GNUNET_PQ_result_spec_uint32 ("oid", | ||
351 | oid), | ||
352 | GNUNET_PQ_result_spec_end | ||
353 | }; | ||
354 | |||
355 | GNUNET_assert (NULL != db); | ||
356 | |||
357 | qs = GNUNET_PQ_eval_prepared_singleton_select (db, | ||
358 | "gnunet_pq_get_oid_by_name", | ||
359 | params, | ||
360 | spec); | ||
361 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | ||
362 | return GNUNET_SYSERR; | ||
368 | } | 363 | } |
369 | 364 | ||
365 | /* Add the entry to the cache */ | ||
366 | if (NULL == db->oids.table) | ||
370 | { | 367 | { |
371 | int nrows = PQntuples (res); | 368 | db->oids.table = GNUNET_new_array (8, |
372 | int nfound = 1; /* skip GNUNET_PQ_DATATYPE_UNKNOWN */ | 369 | typeof(*db->oids.table)); |
373 | char dummy; | 370 | db->oids.cap = 8; |
371 | db->oids.num = 0; | ||
372 | } | ||
374 | 373 | ||
375 | for (int r = 0; r < nrows; r++) | 374 | if (db->oids.cap <= db->oids.num) |
376 | { | 375 | GNUNET_array_grow (db->oids.table, |
377 | enum GNUNET_PQ_DataTypes atype = GNUNET_PQ_DATATYPE_UNKNOWN; | 376 | db->oids.cap, |
378 | char *typ_s = PQgetvalue (res,r,0); | 377 | db->oids.cap + 8); |
379 | char *oid_s = PQgetvalue (res,r,1); | ||
380 | GNUNET_assert (NULL != typ_s); | ||
381 | GNUNET_assert (NULL != oid_s); | ||
382 | |||
383 | if (! strcmp (typ_s,"bool")) | ||
384 | atype = GNUNET_PQ_DATATYPE_BOOL; | ||
385 | else if (! strcmp (typ_s,"int2")) | ||
386 | atype = GNUNET_PQ_DATATYPE_INT2; | ||
387 | else if (! strcmp (typ_s,"int4")) | ||
388 | atype = GNUNET_PQ_DATATYPE_INT4; | ||
389 | else if (! strcmp (typ_s,"int8")) | ||
390 | atype = GNUNET_PQ_DATATYPE_INT8; | ||
391 | else if (! strcmp (typ_s,"bytea")) | ||
392 | atype = GNUNET_PQ_DATATYPE_BYTEA; | ||
393 | else if (! strcmp (typ_s,"varchar")) | ||
394 | atype = GNUNET_PQ_DATATYPE_VARCHAR; | ||
395 | else | ||
396 | continue; | ||
397 | |||
398 | GNUNET_assert (GNUNET_PQ_DATATYPE_MAX > atype); | ||
399 | |||
400 | if ( (GNUNET_PQ_DATATYPE_UNKNOWN != atype) && | ||
401 | (1 == sscanf (oid_s, | ||
402 | "%u%c", | ||
403 | &db->oids[atype], | ||
404 | &dummy))) | ||
405 | { | ||
406 | nfound++; | ||
407 | } | ||
408 | } | ||
409 | 378 | ||
410 | if (GNUNET_PQ_DATATYPE_MAX != nfound) | 379 | db->oids.table[db->oids.num].name = name; |
380 | db->oids.table[db->oids.num].oid = *oid; | ||
381 | db->oids.num++; | ||
382 | |||
383 | return GNUNET_OK; | ||
384 | } | ||
385 | |||
386 | |||
387 | /** | ||
388 | * Load the initial set of OIDs for the supported | ||
389 | * array-datatypes | ||
390 | * | ||
391 | * @param db The database context | ||
392 | * @return GNUNET_OK on success, GNUNET_SYSERR if any of the types couldn't be found | ||
393 | */ | ||
394 | static | ||
395 | enum GNUNET_GenericReturnValue | ||
396 | load_initial_oids (struct GNUNET_PQ_Context *db) | ||
397 | { | ||
398 | static const char *typnames[] = { | ||
399 | "bool", | ||
400 | "int2", | ||
401 | "int4", | ||
402 | "int8", | ||
403 | "bytea", | ||
404 | "varchar" | ||
405 | }; | ||
406 | Oid oid; | ||
407 | |||
408 | for (size_t i = 0; i< sizeof(typnames) / sizeof(*typnames); i++) | ||
409 | { | ||
410 | if (GNUNET_OK != | ||
411 | GNUNET_PQ_get_oid_by_name (db, | ||
412 | typnames[i], | ||
413 | &oid)) | ||
411 | { | 414 | { |
412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 415 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
413 | "Couldn't find all array types, only found %d of %d!\n", | 416 | "pq", |
414 | nfound - 1, | 417 | "Couldn't retrieve OID for type %s\n", |
415 | GNUNET_PQ_DATATYPE_MAX - 1); | 418 | typnames[i]); |
416 | return GNUNET_SYSERR; | 419 | return GNUNET_SYSERR; |
417 | } | 420 | } |
418 | } | 421 | } |
@@ -510,8 +513,36 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
510 | } | 513 | } |
511 | } | 514 | } |
512 | 515 | ||
513 | /* Retrieve the OIDs for the supported Array types */ | 516 | /* Prepare statement for OID lookup by name */ |
514 | if (GNUNET_SYSERR == get_array_type_oids (db)) | 517 | { |
518 | PGresult *res; | ||
519 | |||
520 | res = PQprepare (db->conn, | ||
521 | "gnunet_pq_get_oid_by_name", | ||
522 | "SELECT" | ||
523 | " typname, oid" | ||
524 | " FROM pg_type" | ||
525 | " WHERE typname = $1" | ||
526 | " LIMIT 1", | ||
527 | 1, | ||
528 | NULL); | ||
529 | if (PGRES_COMMAND_OK != PQresultStatus (res)) | ||
530 | { | ||
531 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
532 | "Failed to run SQL statement prepare OID lookups: %s/%s\n", | ||
533 | PQresultErrorMessage (res), | ||
534 | PQerrorMessage (db->conn)); | ||
535 | PQclear (res); | ||
536 | PQfinish (db->conn); | ||
537 | db->conn = NULL; | ||
538 | return; | ||
539 | } | ||
540 | PQclear (res); | ||
541 | } | ||
542 | |||
543 | /* Reset the OID-cache and retrieve the OIDs for the supported Array types */ | ||
544 | db->oids.num = 0; | ||
545 | if (GNUNET_SYSERR == load_initial_oids (db)) | ||
515 | { | 546 | { |
516 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 547 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
517 | "Failed to retrieve OID information for array types!\n"); | 548 | "Failed to retrieve OID information for array types!\n"); |
@@ -520,6 +551,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
520 | return; | 551 | return; |
521 | } | 552 | } |
522 | 553 | ||
554 | |||
523 | if (NULL != db->auto_suffix) | 555 | if (NULL != db->auto_suffix) |
524 | { | 556 | { |
525 | PGresult *res; | 557 | PGresult *res; |
@@ -661,6 +693,10 @@ GNUNET_PQ_disconnect (struct GNUNET_PQ_Context *db) | |||
661 | GNUNET_free (db->load_path); | 693 | GNUNET_free (db->load_path); |
662 | GNUNET_free (db->auto_suffix); | 694 | GNUNET_free (db->auto_suffix); |
663 | GNUNET_free (db->config_str); | 695 | GNUNET_free (db->config_str); |
696 | GNUNET_free (db->oids.table); | ||
697 | db->oids.table = NULL; | ||
698 | db->oids.num = 0; | ||
699 | db->oids.cap = 0; | ||
664 | PQfinish (db->conn); | 700 | PQfinish (db->conn); |
665 | GNUNET_free (db); | 701 | GNUNET_free (db); |
666 | } | 702 | } |
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c index 16bd898fb..fff9e16f7 100644 --- a/src/pq/pq_event.c +++ b/src/pq/pq_event.c | |||
@@ -185,8 +185,8 @@ do_notify (void *cls, | |||
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | static void | 188 | void |
189 | event_do_poll (struct GNUNET_PQ_Context *db) | 189 | GNUNET_PQ_event_do_poll (struct GNUNET_PQ_Context *db) |
190 | { | 190 | { |
191 | PGnotify *n; | 191 | PGnotify *n; |
192 | unsigned int cnt = 0; | 192 | unsigned int cnt = 0; |
@@ -276,7 +276,7 @@ do_scheduler_notify (void *cls) | |||
276 | db->event_task = NULL; | 276 | db->event_task = NULL; |
277 | if (NULL == db->rfd) | 277 | if (NULL == db->rfd) |
278 | GNUNET_PQ_reconnect (db); | 278 | GNUNET_PQ_reconnect (db); |
279 | event_do_poll (db); | 279 | GNUNET_PQ_event_do_poll (db); |
280 | if (NULL != db->event_task) | 280 | if (NULL != db->event_task) |
281 | return; | 281 | return; |
282 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 282 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -577,7 +577,7 @@ GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, | |||
577 | PQerrorMessage (db->conn)); | 577 | PQerrorMessage (db->conn)); |
578 | } | 578 | } |
579 | PQclear (result); | 579 | PQclear (result); |
580 | event_do_poll (db); | 580 | GNUNET_PQ_event_do_poll (db); |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index f57fb338c..1e2f7a965 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c | |||
@@ -22,10 +22,10 @@ | |||
22 | * @brief functions to initialize parameter arrays | 22 | * @brief functions to initialize parameter arrays |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
25 | #include "gnunet_common.h" | 26 | #include "gnunet_common.h" |
26 | #include "gnunet_pq_lib.h" | 27 | #include "gnunet_pq_lib.h" |
27 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
28 | #include "platform.h" | ||
29 | #include "pq.h" | 29 | #include "pq.h" |
30 | 30 | ||
31 | 31 | ||
@@ -682,14 +682,14 @@ qconv_array ( | |||
682 | noerror = false; \ | 682 | noerror = false; \ |
683 | goto DONE; \ | 683 | goto DONE; \ |
684 | } \ | 684 | } \ |
685 | } while(0) | 685 | } while (0) |
686 | 686 | ||
687 | /* Calculate sizes and check bounds */ | 687 | /* Calculate sizes and check bounds */ |
688 | { | 688 | { |
689 | /* num * length-field */ | 689 | /* num * length-field */ |
690 | size_t x = sizeof(uint32_t); | 690 | size_t x = sizeof(uint32_t); |
691 | size_t y = x * num; | 691 | size_t y = x * num; |
692 | RETURN_UNLESS (y >= num); | 692 | RETURN_UNLESS ((0 == num) || (y / num == x)); |
693 | 693 | ||
694 | /* size of header */ | 694 | /* size of header */ |
695 | total_size = x = sizeof(struct pq_array_header); | 695 | total_size = x = sizeof(struct pq_array_header); |
@@ -700,11 +700,11 @@ qconv_array ( | |||
700 | if (same_sized) | 700 | if (same_sized) |
701 | { | 701 | { |
702 | x = num * meta->same_size; | 702 | x = num * meta->same_size; |
703 | RETURN_UNLESS (x >= num); | 703 | RETURN_UNLESS ((0 == num) || (x / num == meta->same_size)); |
704 | 704 | ||
705 | y = total_size; | 705 | y = total_size; |
706 | total_size += x; | 706 | total_size += x; |
707 | RETURN_UNLESS ((total_size >= y)); | 707 | RETURN_UNLESS (total_size >= y); |
708 | } | 708 | } |
709 | else /* sizes are different per element */ | 709 | else /* sizes are different per element */ |
710 | { | 710 | { |
@@ -768,8 +768,11 @@ qconv_array ( | |||
768 | for (unsigned int i = 0; i < num; i++) | 768 | for (unsigned int i = 0; i < num; i++) |
769 | { | 769 | { |
770 | size_t sz = same_sized ? meta->same_size : sizes[i]; | 770 | size_t sz = same_sized ? meta->same_size : sizes[i]; |
771 | size_t hsz = htonl (sz); | ||
771 | 772 | ||
772 | *(uint32_t *) out = htonl (sz); | 773 | GNUNET_memcpy (out, |
774 | &hsz, | ||
775 | sizeof(hsz)); | ||
773 | out += sizeof(uint32_t); | 776 | out += sizeof(uint32_t); |
774 | 777 | ||
775 | switch (meta->typ) | 778 | switch (meta->typ) |
@@ -790,15 +793,25 @@ qconv_array ( | |||
790 | } | 793 | } |
791 | case array_of_uint32: | 794 | case array_of_uint32: |
792 | { | 795 | { |
796 | uint32_t v; | ||
793 | GNUNET_assert (sizeof(uint32_t) == sz); | 797 | GNUNET_assert (sizeof(uint32_t) == sz); |
794 | *(uint32_t *) out = htonl (*(uint32_t *) in); | 798 | |
799 | v = htonl (*(uint32_t *) in); | ||
800 | GNUNET_memcpy (out, | ||
801 | &v, | ||
802 | sizeof(v)); | ||
795 | in += sz; | 803 | in += sz; |
796 | break; | 804 | break; |
797 | } | 805 | } |
798 | case array_of_uint64: | 806 | case array_of_uint64: |
799 | { | 807 | { |
808 | uint64_t tmp; | ||
800 | GNUNET_assert (sizeof(uint64_t) == sz); | 809 | GNUNET_assert (sizeof(uint64_t) == sz); |
801 | *(uint64_t *) out = GNUNET_htonll (*(uint64_t *) in); | 810 | |
811 | tmp = GNUNET_htonll (*(uint64_t *) in); | ||
812 | GNUNET_memcpy (out, | ||
813 | &tmp, | ||
814 | sizeof(tmp)); | ||
802 | in += sz; | 815 | in += sz; |
803 | break; | 816 | break; |
804 | } | 817 | } |
@@ -815,7 +828,9 @@ qconv_array ( | |||
815 | else | 828 | else |
816 | ptr = ((const void **) data)[i]; | 829 | ptr = ((const void **) data)[i]; |
817 | 830 | ||
818 | GNUNET_memcpy (out, ptr, sz); | 831 | GNUNET_memcpy (out, |
832 | ptr, | ||
833 | sz); | ||
819 | break; | 834 | break; |
820 | } | 835 | } |
821 | case array_of_abs_time: | 836 | case array_of_abs_time: |
@@ -874,7 +889,10 @@ qconv_array ( | |||
874 | if (val > INT64_MAX) | 889 | if (val > INT64_MAX) |
875 | val = INT64_MAX; | 890 | val = INT64_MAX; |
876 | 891 | ||
877 | *(uint64_t *) out = GNUNET_htonll (val); | 892 | val = GNUNET_htonll (val); |
893 | GNUNET_memcpy (out, | ||
894 | &val, | ||
895 | sizeof(val)); | ||
878 | 896 | ||
879 | if (meta->continuous) | 897 | if (meta->continuous) |
880 | in += sz; | 898 | in += sz; |
@@ -929,22 +947,25 @@ query_param_array_generic ( | |||
929 | Oid oid) | 947 | Oid oid) |
930 | { | 948 | { |
931 | struct qconv_array_cls *meta = GNUNET_new (struct qconv_array_cls); | 949 | struct qconv_array_cls *meta = GNUNET_new (struct qconv_array_cls); |
950 | |||
932 | meta->typ = typ; | 951 | meta->typ = typ; |
933 | meta->oid = oid; | 952 | meta->oid = oid; |
934 | meta->sizes = sizes; | 953 | meta->sizes = sizes; |
935 | meta->same_size = same_size; | 954 | meta->same_size = same_size; |
936 | meta->continuous = continuous; | 955 | meta->continuous = continuous; |
937 | 956 | ||
938 | struct GNUNET_PQ_QueryParam res = { | 957 | { |
939 | .conv = qconv_array, | 958 | struct GNUNET_PQ_QueryParam res = { |
940 | .conv_cls = meta, | 959 | .conv = qconv_array, |
941 | .conv_cls_cleanup = qconv_array_cls_cleanup, | 960 | .conv_cls = meta, |
942 | .data = elements, | 961 | .conv_cls_cleanup = &qconv_array_cls_cleanup, |
943 | .size = num, | 962 | .data = elements, |
944 | .num_params = 1, | 963 | .size = num, |
945 | }; | 964 | .num_params = 1, |
965 | }; | ||
946 | 966 | ||
947 | return res; | 967 | return res; |
968 | } | ||
948 | } | 969 | } |
949 | 970 | ||
950 | 971 | ||
@@ -952,15 +973,21 @@ struct GNUNET_PQ_QueryParam | |||
952 | GNUNET_PQ_query_param_array_bool ( | 973 | GNUNET_PQ_query_param_array_bool ( |
953 | unsigned int num, | 974 | unsigned int num, |
954 | const bool *elements, | 975 | const bool *elements, |
955 | const struct GNUNET_PQ_Context *db) | 976 | struct GNUNET_PQ_Context *db) |
956 | { | 977 | { |
978 | Oid oid; | ||
979 | |||
980 | GNUNET_assert (GNUNET_OK == | ||
981 | GNUNET_PQ_get_oid_by_name (db, | ||
982 | "bool", | ||
983 | &oid)); | ||
957 | return query_param_array_generic (num, | 984 | return query_param_array_generic (num, |
958 | true, | 985 | true, |
959 | elements, | 986 | elements, |
960 | NULL, | 987 | NULL, |
961 | sizeof(bool), | 988 | sizeof(bool), |
962 | array_of_bool, | 989 | array_of_bool, |
963 | db->oids[GNUNET_PQ_DATATYPE_BOOL]); | 990 | oid); |
964 | } | 991 | } |
965 | 992 | ||
966 | 993 | ||
@@ -968,15 +995,21 @@ struct GNUNET_PQ_QueryParam | |||
968 | GNUNET_PQ_query_param_array_uint16 ( | 995 | GNUNET_PQ_query_param_array_uint16 ( |
969 | unsigned int num, | 996 | unsigned int num, |
970 | const uint16_t *elements, | 997 | const uint16_t *elements, |
971 | const struct GNUNET_PQ_Context *db) | 998 | struct GNUNET_PQ_Context *db) |
972 | { | 999 | { |
1000 | Oid oid; | ||
1001 | |||
1002 | GNUNET_assert (GNUNET_OK == | ||
1003 | GNUNET_PQ_get_oid_by_name (db, | ||
1004 | "int2", | ||
1005 | &oid)); | ||
973 | return query_param_array_generic (num, | 1006 | return query_param_array_generic (num, |
974 | true, | 1007 | true, |
975 | elements, | 1008 | elements, |
976 | NULL, | 1009 | NULL, |
977 | sizeof(uint16_t), | 1010 | sizeof(uint16_t), |
978 | array_of_uint16, | 1011 | array_of_uint16, |
979 | db->oids[GNUNET_PQ_DATATYPE_INT2]); | 1012 | oid); |
980 | } | 1013 | } |
981 | 1014 | ||
982 | 1015 | ||
@@ -984,15 +1017,21 @@ struct GNUNET_PQ_QueryParam | |||
984 | GNUNET_PQ_query_param_array_uint32 ( | 1017 | GNUNET_PQ_query_param_array_uint32 ( |
985 | unsigned int num, | 1018 | unsigned int num, |
986 | const uint32_t *elements, | 1019 | const uint32_t *elements, |
987 | const struct GNUNET_PQ_Context *db) | 1020 | struct GNUNET_PQ_Context *db) |
988 | { | 1021 | { |
1022 | Oid oid; | ||
1023 | |||
1024 | GNUNET_assert (GNUNET_OK == | ||
1025 | GNUNET_PQ_get_oid_by_name (db, | ||
1026 | "int4", | ||
1027 | &oid)); | ||
989 | return query_param_array_generic (num, | 1028 | return query_param_array_generic (num, |
990 | true, | 1029 | true, |
991 | elements, | 1030 | elements, |
992 | NULL, | 1031 | NULL, |
993 | sizeof(uint32_t), | 1032 | sizeof(uint32_t), |
994 | array_of_uint32, | 1033 | array_of_uint32, |
995 | db->oids[GNUNET_PQ_DATATYPE_INT4]); | 1034 | oid); |
996 | } | 1035 | } |
997 | 1036 | ||
998 | 1037 | ||
@@ -1000,15 +1039,21 @@ struct GNUNET_PQ_QueryParam | |||
1000 | GNUNET_PQ_query_param_array_uint64 ( | 1039 | GNUNET_PQ_query_param_array_uint64 ( |
1001 | unsigned int num, | 1040 | unsigned int num, |
1002 | const uint64_t *elements, | 1041 | const uint64_t *elements, |
1003 | const struct GNUNET_PQ_Context *db) | 1042 | struct GNUNET_PQ_Context *db) |
1004 | { | 1043 | { |
1044 | Oid oid; | ||
1045 | |||
1046 | GNUNET_assert (GNUNET_OK == | ||
1047 | GNUNET_PQ_get_oid_by_name (db, | ||
1048 | "int8", | ||
1049 | &oid)); | ||
1005 | return query_param_array_generic (num, | 1050 | return query_param_array_generic (num, |
1006 | true, | 1051 | true, |
1007 | elements, | 1052 | elements, |
1008 | NULL, | 1053 | NULL, |
1009 | sizeof(uint64_t), | 1054 | sizeof(uint64_t), |
1010 | array_of_uint64, | 1055 | array_of_uint64, |
1011 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1056 | oid); |
1012 | } | 1057 | } |
1013 | 1058 | ||
1014 | 1059 | ||
@@ -1017,32 +1062,44 @@ GNUNET_PQ_query_param_array_bytes ( | |||
1017 | unsigned int num, | 1062 | unsigned int num, |
1018 | const void *elements, | 1063 | const void *elements, |
1019 | const size_t *sizes, | 1064 | const size_t *sizes, |
1020 | const struct GNUNET_PQ_Context *db) | 1065 | struct GNUNET_PQ_Context *db) |
1021 | { | 1066 | { |
1067 | Oid oid; | ||
1068 | |||
1069 | GNUNET_assert (GNUNET_OK == | ||
1070 | GNUNET_PQ_get_oid_by_name (db, | ||
1071 | "bytea", | ||
1072 | &oid)); | ||
1022 | return query_param_array_generic (num, | 1073 | return query_param_array_generic (num, |
1023 | true, | 1074 | true, |
1024 | elements, | 1075 | elements, |
1025 | sizes, | 1076 | sizes, |
1026 | 0, | 1077 | 0, |
1027 | array_of_byte, | 1078 | array_of_byte, |
1028 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1079 | oid); |
1029 | } | 1080 | } |
1030 | 1081 | ||
1031 | 1082 | ||
1032 | struct GNUNET_PQ_QueryParam | 1083 | struct GNUNET_PQ_QueryParam |
1033 | GNUNET_PQ_query_param_array_ptrs_bytes ( | 1084 | GNUNET_PQ_query_param_array_ptrs_bytes ( |
1034 | unsigned int num, | 1085 | unsigned int num, |
1035 | const void *elements[], | 1086 | const void *elements[static num], |
1036 | const size_t *sizes, | 1087 | const size_t *sizes, |
1037 | const struct GNUNET_PQ_Context *db) | 1088 | struct GNUNET_PQ_Context *db) |
1038 | { | 1089 | { |
1090 | Oid oid; | ||
1091 | |||
1092 | GNUNET_assert (GNUNET_OK == | ||
1093 | GNUNET_PQ_get_oid_by_name (db, | ||
1094 | "bytea", | ||
1095 | &oid)); | ||
1039 | return query_param_array_generic (num, | 1096 | return query_param_array_generic (num, |
1040 | false, | 1097 | false, |
1041 | elements, | 1098 | elements, |
1042 | sizes, | 1099 | sizes, |
1043 | 0, | 1100 | 0, |
1044 | array_of_byte, | 1101 | array_of_byte, |
1045 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1102 | oid); |
1046 | } | 1103 | } |
1047 | 1104 | ||
1048 | 1105 | ||
@@ -1051,32 +1108,44 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
1051 | unsigned int num, | 1108 | unsigned int num, |
1052 | const void *elements, | 1109 | const void *elements, |
1053 | size_t same_size, | 1110 | size_t same_size, |
1054 | const struct GNUNET_PQ_Context *db) | 1111 | struct GNUNET_PQ_Context *db) |
1055 | { | 1112 | { |
1113 | Oid oid; | ||
1114 | |||
1115 | GNUNET_assert (GNUNET_OK == | ||
1116 | GNUNET_PQ_get_oid_by_name (db, | ||
1117 | "bytea", | ||
1118 | &oid)); | ||
1056 | return query_param_array_generic (num, | 1119 | return query_param_array_generic (num, |
1057 | true, | 1120 | true, |
1058 | elements, | 1121 | elements, |
1059 | NULL, | 1122 | NULL, |
1060 | same_size, | 1123 | same_size, |
1061 | array_of_byte, | 1124 | array_of_byte, |
1062 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1125 | oid); |
1063 | } | 1126 | } |
1064 | 1127 | ||
1065 | 1128 | ||
1066 | struct GNUNET_PQ_QueryParam | 1129 | struct GNUNET_PQ_QueryParam |
1067 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | 1130 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( |
1068 | unsigned int num, | 1131 | unsigned int num, |
1069 | const void *elements[], | 1132 | const void *elements[static num], |
1070 | size_t same_size, | 1133 | size_t same_size, |
1071 | const struct GNUNET_PQ_Context *db) | 1134 | struct GNUNET_PQ_Context *db) |
1072 | { | 1135 | { |
1136 | Oid oid; | ||
1137 | |||
1138 | GNUNET_assert (GNUNET_OK == | ||
1139 | GNUNET_PQ_get_oid_by_name (db, | ||
1140 | "bytea", | ||
1141 | &oid)); | ||
1073 | return query_param_array_generic (num, | 1142 | return query_param_array_generic (num, |
1074 | false, | 1143 | false, |
1075 | elements, | 1144 | elements, |
1076 | NULL, | 1145 | NULL, |
1077 | same_size, | 1146 | same_size, |
1078 | array_of_byte, | 1147 | array_of_byte, |
1079 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1148 | oid); |
1080 | } | 1149 | } |
1081 | 1150 | ||
1082 | 1151 | ||
@@ -1084,31 +1153,43 @@ struct GNUNET_PQ_QueryParam | |||
1084 | GNUNET_PQ_query_param_array_string ( | 1153 | GNUNET_PQ_query_param_array_string ( |
1085 | unsigned int num, | 1154 | unsigned int num, |
1086 | const char *elements, | 1155 | const char *elements, |
1087 | const struct GNUNET_PQ_Context *db) | 1156 | struct GNUNET_PQ_Context *db) |
1088 | { | 1157 | { |
1158 | Oid oid; | ||
1159 | |||
1160 | GNUNET_assert (GNUNET_OK == | ||
1161 | GNUNET_PQ_get_oid_by_name (db, | ||
1162 | "text", | ||
1163 | &oid)); | ||
1089 | return query_param_array_generic (num, | 1164 | return query_param_array_generic (num, |
1090 | true, | 1165 | true, |
1091 | elements, | 1166 | elements, |
1092 | NULL, | 1167 | NULL, |
1093 | 0, | 1168 | 0, |
1094 | array_of_string, | 1169 | array_of_string, |
1095 | db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); | 1170 | oid); |
1096 | } | 1171 | } |
1097 | 1172 | ||
1098 | 1173 | ||
1099 | struct GNUNET_PQ_QueryParam | 1174 | struct GNUNET_PQ_QueryParam |
1100 | GNUNET_PQ_query_param_array_ptrs_string ( | 1175 | GNUNET_PQ_query_param_array_ptrs_string ( |
1101 | unsigned int num, | 1176 | unsigned int num, |
1102 | const char *elements[], | 1177 | const char *elements[static num], |
1103 | const struct GNUNET_PQ_Context *db) | 1178 | struct GNUNET_PQ_Context *db) |
1104 | { | 1179 | { |
1180 | Oid oid; | ||
1181 | |||
1182 | GNUNET_assert (GNUNET_OK == | ||
1183 | GNUNET_PQ_get_oid_by_name (db, | ||
1184 | "text", | ||
1185 | &oid)); | ||
1105 | return query_param_array_generic (num, | 1186 | return query_param_array_generic (num, |
1106 | false, | 1187 | false, |
1107 | elements, | 1188 | elements, |
1108 | NULL, | 1189 | NULL, |
1109 | 0, | 1190 | 0, |
1110 | array_of_string, | 1191 | array_of_string, |
1111 | db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); | 1192 | oid); |
1112 | } | 1193 | } |
1113 | 1194 | ||
1114 | 1195 | ||
@@ -1116,15 +1197,21 @@ struct GNUNET_PQ_QueryParam | |||
1116 | GNUNET_PQ_query_param_array_abs_time ( | 1197 | GNUNET_PQ_query_param_array_abs_time ( |
1117 | unsigned int num, | 1198 | unsigned int num, |
1118 | const struct GNUNET_TIME_Absolute *elements, | 1199 | const struct GNUNET_TIME_Absolute *elements, |
1119 | const struct GNUNET_PQ_Context *db) | 1200 | struct GNUNET_PQ_Context *db) |
1120 | { | 1201 | { |
1202 | Oid oid; | ||
1203 | |||
1204 | GNUNET_assert (GNUNET_OK == | ||
1205 | GNUNET_PQ_get_oid_by_name (db, | ||
1206 | "int8", | ||
1207 | &oid)); | ||
1121 | return query_param_array_generic (num, | 1208 | return query_param_array_generic (num, |
1122 | true, | 1209 | true, |
1123 | elements, | 1210 | elements, |
1124 | NULL, | 1211 | NULL, |
1125 | sizeof(struct GNUNET_TIME_Absolute), | 1212 | sizeof(struct GNUNET_TIME_Absolute), |
1126 | array_of_abs_time, | 1213 | array_of_abs_time, |
1127 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1214 | oid); |
1128 | } | 1215 | } |
1129 | 1216 | ||
1130 | 1217 | ||
@@ -1132,15 +1219,21 @@ struct GNUNET_PQ_QueryParam | |||
1132 | GNUNET_PQ_query_param_array_ptrs_abs_time ( | 1219 | GNUNET_PQ_query_param_array_ptrs_abs_time ( |
1133 | unsigned int num, | 1220 | unsigned int num, |
1134 | const struct GNUNET_TIME_Absolute *elements[], | 1221 | const struct GNUNET_TIME_Absolute *elements[], |
1135 | const struct GNUNET_PQ_Context *db) | 1222 | struct GNUNET_PQ_Context *db) |
1136 | { | 1223 | { |
1224 | Oid oid; | ||
1225 | |||
1226 | GNUNET_assert (GNUNET_OK == | ||
1227 | GNUNET_PQ_get_oid_by_name (db, | ||
1228 | "int8", | ||
1229 | &oid)); | ||
1137 | return query_param_array_generic (num, | 1230 | return query_param_array_generic (num, |
1138 | false, | 1231 | false, |
1139 | elements, | 1232 | elements, |
1140 | NULL, | 1233 | NULL, |
1141 | sizeof(struct GNUNET_TIME_Absolute), | 1234 | sizeof(struct GNUNET_TIME_Absolute), |
1142 | array_of_abs_time, | 1235 | array_of_abs_time, |
1143 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1236 | oid); |
1144 | } | 1237 | } |
1145 | 1238 | ||
1146 | 1239 | ||
@@ -1148,15 +1241,21 @@ struct GNUNET_PQ_QueryParam | |||
1148 | GNUNET_PQ_query_param_array_rel_time ( | 1241 | GNUNET_PQ_query_param_array_rel_time ( |
1149 | unsigned int num, | 1242 | unsigned int num, |
1150 | const struct GNUNET_TIME_Relative *elements, | 1243 | const struct GNUNET_TIME_Relative *elements, |
1151 | const struct GNUNET_PQ_Context *db) | 1244 | struct GNUNET_PQ_Context *db) |
1152 | { | 1245 | { |
1246 | Oid oid; | ||
1247 | |||
1248 | GNUNET_assert (GNUNET_OK == | ||
1249 | GNUNET_PQ_get_oid_by_name (db, | ||
1250 | "int8", | ||
1251 | &oid)); | ||
1153 | return query_param_array_generic (num, | 1252 | return query_param_array_generic (num, |
1154 | true, | 1253 | true, |
1155 | elements, | 1254 | elements, |
1156 | NULL, | 1255 | NULL, |
1157 | sizeof(struct GNUNET_TIME_Relative), | 1256 | sizeof(struct GNUNET_TIME_Relative), |
1158 | array_of_abs_time, | 1257 | array_of_abs_time, |
1159 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1258 | oid); |
1160 | } | 1259 | } |
1161 | 1260 | ||
1162 | 1261 | ||
@@ -1164,15 +1263,21 @@ struct GNUNET_PQ_QueryParam | |||
1164 | GNUNET_PQ_query_param_array_ptrs_rel_time ( | 1263 | GNUNET_PQ_query_param_array_ptrs_rel_time ( |
1165 | unsigned int num, | 1264 | unsigned int num, |
1166 | const struct GNUNET_TIME_Relative *elements[], | 1265 | const struct GNUNET_TIME_Relative *elements[], |
1167 | const struct GNUNET_PQ_Context *db) | 1266 | struct GNUNET_PQ_Context *db) |
1168 | { | 1267 | { |
1268 | Oid oid; | ||
1269 | |||
1270 | GNUNET_assert (GNUNET_OK == | ||
1271 | GNUNET_PQ_get_oid_by_name (db, | ||
1272 | "int8", | ||
1273 | &oid)); | ||
1169 | return query_param_array_generic (num, | 1274 | return query_param_array_generic (num, |
1170 | false, | 1275 | false, |
1171 | elements, | 1276 | elements, |
1172 | NULL, | 1277 | NULL, |
1173 | sizeof(struct GNUNET_TIME_Relative), | 1278 | sizeof(struct GNUNET_TIME_Relative), |
1174 | array_of_abs_time, | 1279 | array_of_abs_time, |
1175 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1280 | oid); |
1176 | } | 1281 | } |
1177 | 1282 | ||
1178 | 1283 | ||
@@ -1180,15 +1285,21 @@ struct GNUNET_PQ_QueryParam | |||
1180 | GNUNET_PQ_query_param_array_timestamp ( | 1285 | GNUNET_PQ_query_param_array_timestamp ( |
1181 | unsigned int num, | 1286 | unsigned int num, |
1182 | const struct GNUNET_TIME_Timestamp *elements, | 1287 | const struct GNUNET_TIME_Timestamp *elements, |
1183 | const struct GNUNET_PQ_Context *db) | 1288 | struct GNUNET_PQ_Context *db) |
1184 | { | 1289 | { |
1290 | Oid oid; | ||
1291 | |||
1292 | GNUNET_assert (GNUNET_OK == | ||
1293 | GNUNET_PQ_get_oid_by_name (db, | ||
1294 | "int8", | ||
1295 | &oid)); | ||
1185 | return query_param_array_generic (num, | 1296 | return query_param_array_generic (num, |
1186 | true, | 1297 | true, |
1187 | elements, | 1298 | elements, |
1188 | NULL, | 1299 | NULL, |
1189 | sizeof(struct GNUNET_TIME_Timestamp), | 1300 | sizeof(struct GNUNET_TIME_Timestamp), |
1190 | array_of_timestamp, | 1301 | array_of_timestamp, |
1191 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1302 | oid); |
1192 | } | 1303 | } |
1193 | 1304 | ||
1194 | 1305 | ||
@@ -1196,15 +1307,21 @@ struct GNUNET_PQ_QueryParam | |||
1196 | GNUNET_PQ_query_param_array_ptrs_timestamp ( | 1307 | GNUNET_PQ_query_param_array_ptrs_timestamp ( |
1197 | unsigned int num, | 1308 | unsigned int num, |
1198 | const struct GNUNET_TIME_Timestamp *elements[], | 1309 | const struct GNUNET_TIME_Timestamp *elements[], |
1199 | const struct GNUNET_PQ_Context *db) | 1310 | struct GNUNET_PQ_Context *db) |
1200 | { | 1311 | { |
1312 | Oid oid; | ||
1313 | |||
1314 | GNUNET_assert (GNUNET_OK == | ||
1315 | GNUNET_PQ_get_oid_by_name (db, | ||
1316 | "int8", | ||
1317 | &oid)); | ||
1201 | return query_param_array_generic (num, | 1318 | return query_param_array_generic (num, |
1202 | false, | 1319 | false, |
1203 | elements, | 1320 | elements, |
1204 | NULL, | 1321 | NULL, |
1205 | sizeof(struct GNUNET_TIME_Timestamp), | 1322 | sizeof(struct GNUNET_TIME_Timestamp), |
1206 | array_of_timestamp, | 1323 | array_of_timestamp, |
1207 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1324 | oid); |
1208 | } | 1325 | } |
1209 | 1326 | ||
1210 | 1327 | ||
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 808445b3b..f230826cb 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -21,10 +21,11 @@ | |||
21 | * @file pq/pq_result_helper.c | 21 | * @file pq/pq_result_helper.c |
22 | * @brief functions to extract result values | 22 | * @brief functions to extract result values |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | * @author Özgür Kesim | ||
24 | */ | 25 | */ |
25 | #include "gnunet_common.h" | ||
26 | #include "gnunet_time_lib.h" | ||
27 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_time_lib.h" | ||
28 | #include "gnunet_common.h" | ||
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_pq_lib.h" | 30 | #include "gnunet_pq_lib.h" |
30 | #include "pq.h" | 31 | #include "pq.h" |
@@ -1179,13 +1180,13 @@ extract_array_generic ( | |||
1179 | *((void **) dst) = NULL; | 1180 | *((void **) dst) = NULL; |
1180 | 1181 | ||
1181 | #define FAIL_IF(cond) \ | 1182 | #define FAIL_IF(cond) \ |
1182 | do { \ | 1183 | do { \ |
1183 | if ((cond)) \ | 1184 | if ((cond)) \ |
1184 | { \ | 1185 | { \ |
1185 | GNUNET_break (! (cond)); \ | 1186 | GNUNET_break (! (cond)); \ |
1186 | goto FAIL; \ | 1187 | goto FAIL; \ |
1187 | } \ | 1188 | } \ |
1188 | } while(0) | 1189 | } while (0) |
1189 | 1190 | ||
1190 | col_num = PQfnumber (result, fname); | 1191 | col_num = PQfnumber (result, fname); |
1191 | FAIL_IF (0 > col_num); | 1192 | FAIL_IF (0 > col_num); |
@@ -1208,156 +1209,190 @@ extract_array_generic ( | |||
1208 | header.lbound = ntohl (h->lbound); | 1209 | header.lbound = ntohl (h->lbound); |
1209 | 1210 | ||
1210 | FAIL_IF (1 != header.ndim); | 1211 | FAIL_IF (1 != header.ndim); |
1211 | FAIL_IF ((0 > header.dim) || (INT_MAX == header.dim)); | 1212 | FAIL_IF (INT_MAX <= header.dim); |
1212 | FAIL_IF (0 != header.has_null); | 1213 | FAIL_IF (0 != header.has_null); |
1213 | FAIL_IF (1 != header.lbound); | 1214 | FAIL_IF (1 != header.lbound); |
1214 | FAIL_IF (info->oid != header.oid); | 1215 | FAIL_IF (info->oid != header.oid); |
1215 | } | 1216 | } |
1216 | 1217 | ||
1217 | *info->num = header.dim; | 1218 | if (NULL != info->num) |
1218 | switch (info->typ) | 1219 | *info->num = header.dim; |
1219 | { | ||
1220 | case array_of_bool: | ||
1221 | if (NULL != dst_size) | ||
1222 | *dst_size = sizeof(bool) * (*info->num); | ||
1223 | out = GNUNET_new_array (*info->num, bool); | ||
1224 | break; | ||
1225 | case array_of_uint16: | ||
1226 | if (NULL != dst_size) | ||
1227 | *dst_size = sizeof(uint16_t) * (*info->num); | ||
1228 | out = GNUNET_new_array (*info->num, uint16_t); | ||
1229 | break; | ||
1230 | case array_of_uint32: | ||
1231 | if (NULL != dst_size) | ||
1232 | *dst_size = sizeof(uint32_t) * (*info->num); | ||
1233 | out = GNUNET_new_array (*info->num, uint32_t); | ||
1234 | break; | ||
1235 | case array_of_uint64: | ||
1236 | if (NULL != dst_size) | ||
1237 | *dst_size = sizeof(uint64_t) * (*info->num); | ||
1238 | out = GNUNET_new_array (*info->num, uint64_t); | ||
1239 | break; | ||
1240 | case array_of_abs_time: | ||
1241 | if (NULL != dst_size) | ||
1242 | *dst_size = sizeof(struct GNUNET_TIME_Absolute) * (*info->num); | ||
1243 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Absolute); | ||
1244 | break; | ||
1245 | case array_of_rel_time: | ||
1246 | if (NULL != dst_size) | ||
1247 | *dst_size = sizeof(struct GNUNET_TIME_Relative) * (*info->num); | ||
1248 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Relative); | ||
1249 | break; | ||
1250 | case array_of_timestamp: | ||
1251 | if (NULL != dst_size) | ||
1252 | *dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (*info->num); | ||
1253 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Timestamp); | ||
1254 | break; | ||
1255 | case array_of_byte: | ||
1256 | if (0 == info->same_size) | ||
1257 | *info->sizes = GNUNET_new_array (header.dim, size_t); | ||
1258 | /* fallthrough */ | ||
1259 | case array_of_string: | ||
1260 | { | ||
1261 | size_t total = 0; | ||
1262 | bool is_string = (array_of_string == info->typ); | ||
1263 | |||
1264 | /* first, calculate total size required for allocation */ | ||
1265 | { | ||
1266 | char *ptr = data + sizeof(header); | ||
1267 | for (uint32_t i = 0; i < header.dim; i++) | ||
1268 | { | ||
1269 | uint32_t sz; | ||
1270 | |||
1271 | sz = ntohl (*(uint32_t *) ptr); | ||
1272 | sz += is_string ? 1 : 0; | ||
1273 | total += sz; | ||
1274 | ptr += sizeof(uint32_t); | ||
1275 | ptr += sz; | ||
1276 | 1220 | ||
1277 | if ((! is_string) && | ||
1278 | (0 == info->same_size)) | ||
1279 | (*info->sizes)[i] = sz; | ||
1280 | |||
1281 | FAIL_IF ((0 != info->same_size) && | ||
1282 | (sz != info->same_size)); | ||
1283 | FAIL_IF (total < sz); | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | if (NULL != dst_size) | ||
1288 | *dst_size = total; | ||
1289 | |||
1290 | if (0 < total) | ||
1291 | out = GNUNET_malloc (total); | ||
1292 | |||
1293 | break; | ||
1294 | } | ||
1295 | default: | ||
1296 | FAIL_IF (1 != 0); | ||
1297 | } | ||
1298 | |||
1299 | *((void **) dst) = out; | ||
1300 | |||
1301 | /* copy data */ | ||
1302 | { | 1221 | { |
1303 | char *in = data + sizeof(header); | 1222 | char *in = data + sizeof(header); |
1304 | 1223 | ||
1305 | for (uint32_t i = 0; i < header.dim; i++) | 1224 | switch (info->typ) |
1306 | { | 1225 | { |
1307 | size_t sz = ntohl (*(uint32_t *) in); | 1226 | case array_of_bool: |
1308 | in += sizeof(uint32_t); | 1227 | if (NULL != dst_size) |
1309 | 1228 | *dst_size = sizeof(bool) * (header.dim); | |
1310 | switch (info->typ) | 1229 | out = GNUNET_new_array (header.dim, bool); |
1230 | *((void **) dst) = out; | ||
1231 | for (uint32_t i = 0; i < header.dim; i++) | ||
1311 | { | 1232 | { |
1312 | case array_of_bool: | 1233 | size_t sz = ntohl (*(uint32_t *) in); |
1313 | FAIL_IF (sz != sizeof(bool)); | 1234 | FAIL_IF (sz != sizeof(bool)); |
1235 | in += sizeof(uint32_t); | ||
1314 | *(bool *) out = *(bool *) in; | 1236 | *(bool *) out = *(bool *) in; |
1315 | break; | 1237 | in += sz; |
1316 | case array_of_uint16: | 1238 | out += sz; |
1239 | } | ||
1240 | break; | ||
1241 | |||
1242 | case array_of_uint16: | ||
1243 | if (NULL != dst_size) | ||
1244 | *dst_size = sizeof(uint16_t) * (header.dim); | ||
1245 | out = GNUNET_new_array (header.dim, uint16_t); | ||
1246 | *((void **) dst) = out; | ||
1247 | for (uint32_t i = 0; i < header.dim; i++) | ||
1248 | { | ||
1249 | size_t sz = ntohl (*(uint32_t *) in); | ||
1317 | FAIL_IF (sz != sizeof(uint16_t)); | 1250 | FAIL_IF (sz != sizeof(uint16_t)); |
1251 | in += sizeof(uint32_t); | ||
1318 | *(uint16_t *) out = ntohs (*(uint16_t *) in); | 1252 | *(uint16_t *) out = ntohs (*(uint16_t *) in); |
1319 | break; | 1253 | in += sz; |
1320 | case array_of_uint32: | 1254 | out += sz; |
1255 | } | ||
1256 | break; | ||
1257 | |||
1258 | case array_of_uint32: | ||
1259 | if (NULL != dst_size) | ||
1260 | *dst_size = sizeof(uint32_t) * (header.dim); | ||
1261 | out = GNUNET_new_array (header.dim, uint32_t); | ||
1262 | *((void **) dst) = out; | ||
1263 | for (uint32_t i = 0; i < header.dim; i++) | ||
1264 | { | ||
1265 | size_t sz = ntohl (*(uint32_t *) in); | ||
1321 | FAIL_IF (sz != sizeof(uint32_t)); | 1266 | FAIL_IF (sz != sizeof(uint32_t)); |
1267 | in += sizeof(uint32_t); | ||
1322 | *(uint32_t *) out = ntohl (*(uint32_t *) in); | 1268 | *(uint32_t *) out = ntohl (*(uint32_t *) in); |
1323 | break; | 1269 | in += sz; |
1324 | case array_of_uint64: | 1270 | out += sz; |
1271 | } | ||
1272 | break; | ||
1273 | |||
1274 | case array_of_uint64: | ||
1275 | if (NULL != dst_size) | ||
1276 | *dst_size = sizeof(uint64_t) * (header.dim); | ||
1277 | out = GNUNET_new_array (header.dim, uint64_t); | ||
1278 | *((void **) dst) = out; | ||
1279 | for (uint32_t i = 0; i < header.dim; i++) | ||
1280 | { | ||
1281 | size_t sz = ntohl (*(uint32_t *) in); | ||
1325 | FAIL_IF (sz != sizeof(uint64_t)); | 1282 | FAIL_IF (sz != sizeof(uint64_t)); |
1283 | in += sizeof(uint32_t); | ||
1326 | *(uint64_t *) out = GNUNET_ntohll (*(uint64_t *) in); | 1284 | *(uint64_t *) out = GNUNET_ntohll (*(uint64_t *) in); |
1327 | break; | 1285 | in += sz; |
1328 | case array_of_abs_time: | 1286 | out += sz; |
1329 | case array_of_rel_time: | 1287 | } |
1330 | case array_of_timestamp: | 1288 | break; |
1289 | |||
1290 | case array_of_abs_time: | ||
1291 | if (NULL != dst_size) | ||
1292 | *dst_size = sizeof(struct GNUNET_TIME_Absolute) * (header.dim); | ||
1293 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Absolute); | ||
1294 | *((void **) dst) = out; | ||
1295 | for (uint32_t i = 0; i < header.dim; i++) | ||
1296 | { | ||
1297 | size_t sz = ntohl (*(uint32_t *) in); | ||
1298 | FAIL_IF (sz != sizeof(uint64_t)); | ||
1299 | in += sizeof(uint32_t); | ||
1300 | ((struct GNUNET_TIME_Absolute *) out)->abs_value_us = | ||
1301 | GNUNET_ntohll (*(uint64_t *) in); | ||
1302 | in += sz; | ||
1303 | out += sz; | ||
1304 | } | ||
1305 | break; | ||
1306 | |||
1307 | case array_of_rel_time: | ||
1308 | if (NULL != dst_size) | ||
1309 | *dst_size = sizeof(struct GNUNET_TIME_Relative) * (header.dim); | ||
1310 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Relative); | ||
1311 | *((void **) dst) = out; | ||
1312 | for (uint32_t i = 0; i < header.dim; i++) | ||
1313 | { | ||
1314 | size_t sz = ntohl (*(uint32_t *) in); | ||
1315 | FAIL_IF (sz != sizeof(uint64_t)); | ||
1316 | in += sizeof(uint32_t); | ||
1317 | ((struct GNUNET_TIME_Relative *) out)->rel_value_us = | ||
1318 | GNUNET_ntohll (*(uint64_t *) in); | ||
1319 | in += sz; | ||
1320 | out += sz; | ||
1321 | } | ||
1322 | break; | ||
1323 | |||
1324 | case array_of_timestamp: | ||
1325 | if (NULL != dst_size) | ||
1326 | *dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (header.dim); | ||
1327 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Timestamp); | ||
1328 | *((void **) dst) = out; | ||
1329 | for (uint32_t i = 0; i < header.dim; i++) | ||
1330 | { | ||
1331 | size_t sz = ntohl (*(uint32_t *) in); | ||
1331 | FAIL_IF (sz != sizeof(uint64_t)); | 1332 | FAIL_IF (sz != sizeof(uint64_t)); |
1333 | in += sizeof(uint32_t); | ||
1334 | ((struct GNUNET_TIME_Timestamp *) out)->abs_time.abs_value_us = | ||
1335 | GNUNET_ntohll (*(uint64_t *) in); | ||
1336 | in += sz; | ||
1337 | out += sz; | ||
1338 | } | ||
1339 | break; | ||
1340 | |||
1341 | case array_of_byte: | ||
1342 | if (0 == info->same_size) | ||
1343 | *info->sizes = GNUNET_new_array (header.dim, size_t); | ||
1344 | /* fallthrough */ | ||
1345 | case array_of_string: | ||
1346 | { | ||
1347 | size_t total = 0; | ||
1348 | bool is_string = (array_of_string == info->typ); | ||
1349 | |||
1350 | /* first, calculate total size required for allocation */ | ||
1332 | { | 1351 | { |
1333 | uint64_t val = GNUNET_ntohll (*(uint64_t *) in); | 1352 | char *ptr = data + sizeof(header); |
1334 | switch (info->typ) | 1353 | for (uint32_t i = 0; i < header.dim; i++) |
1335 | { | 1354 | { |
1336 | case array_of_abs_time: | 1355 | uint32_t sz; |
1337 | ((struct GNUNET_TIME_Absolute *) out)->abs_value_us = val; | 1356 | |
1338 | break; | 1357 | sz = ntohl (*(uint32_t *) ptr); |
1339 | case array_of_rel_time: | 1358 | sz += is_string ? 1 : 0; |
1340 | ((struct GNUNET_TIME_Relative *) out)->rel_value_us = val; | 1359 | total += sz; |
1341 | break; | 1360 | ptr += sizeof(uint32_t); |
1342 | case array_of_timestamp: | 1361 | ptr += sz; |
1343 | ((struct GNUNET_TIME_Timestamp *) out)->abs_time.abs_value_us = val; | 1362 | |
1344 | break; | 1363 | if ((! is_string) && |
1345 | default: | 1364 | (0 == info->same_size)) |
1346 | FAIL_IF (1 != 0); | 1365 | (*info->sizes)[i] = sz; |
1366 | |||
1367 | FAIL_IF ((0 != info->same_size) && | ||
1368 | (sz != info->same_size)); | ||
1369 | FAIL_IF (total < sz); | ||
1347 | } | 1370 | } |
1348 | } | 1371 | } |
1372 | |||
1373 | if (NULL != dst_size) | ||
1374 | *dst_size = total; | ||
1375 | |||
1376 | FAIL_IF (0 == total); | ||
1377 | out = GNUNET_malloc (total); | ||
1378 | |||
1379 | *((void **) dst) = out; | ||
1380 | |||
1381 | /* copy data */ | ||
1382 | for (uint32_t i = 0; i < header.dim; i++) | ||
1383 | { | ||
1384 | size_t sz = ntohl (*(uint32_t *) in); | ||
1385 | in += sizeof(uint32_t); | ||
1386 | GNUNET_memcpy (out, in, sz); | ||
1387 | |||
1388 | in += sz; | ||
1389 | out += sz; | ||
1390 | out += (array_of_string == info->typ) ? 1 : 0; | ||
1391 | } | ||
1349 | break; | 1392 | break; |
1350 | case array_of_byte: | ||
1351 | case array_of_string: | ||
1352 | GNUNET_memcpy (out, in, sz); | ||
1353 | break; | ||
1354 | default: | ||
1355 | FAIL_IF (1 != 0); | ||
1356 | } | 1393 | } |
1357 | 1394 | default: | |
1358 | in += sz; | 1395 | FAIL_IF (1 != 0); |
1359 | out += sz; | ||
1360 | out += (array_of_string == info->typ) ? 1 : 0; | ||
1361 | } | 1396 | } |
1362 | } | 1397 | } |
1363 | 1398 | ||
@@ -1394,7 +1429,7 @@ array_cleanup (void *cls, | |||
1394 | 1429 | ||
1395 | struct GNUNET_PQ_ResultSpec | 1430 | struct GNUNET_PQ_ResultSpec |
1396 | GNUNET_PQ_result_spec_array_bool ( | 1431 | GNUNET_PQ_result_spec_array_bool ( |
1397 | const struct GNUNET_PQ_Context *db, | 1432 | struct GNUNET_PQ_Context *db, |
1398 | const char *name, | 1433 | const char *name, |
1399 | size_t *num, | 1434 | size_t *num, |
1400 | bool **dst) | 1435 | bool **dst) |
@@ -1404,7 +1439,10 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1404 | 1439 | ||
1405 | info->num = num; | 1440 | info->num = num; |
1406 | info->typ = array_of_bool; | 1441 | info->typ = array_of_bool; |
1407 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BOOL]; | 1442 | GNUNET_assert (GNUNET_OK == |
1443 | GNUNET_PQ_get_oid_by_name (db, | ||
1444 | "bool", | ||
1445 | &info->oid)); | ||
1408 | 1446 | ||
1409 | struct GNUNET_PQ_ResultSpec res = { | 1447 | struct GNUNET_PQ_ResultSpec res = { |
1410 | .conv = extract_array_generic, | 1448 | .conv = extract_array_generic, |
@@ -1419,7 +1457,7 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1419 | 1457 | ||
1420 | struct GNUNET_PQ_ResultSpec | 1458 | struct GNUNET_PQ_ResultSpec |
1421 | GNUNET_PQ_result_spec_array_uint16 ( | 1459 | GNUNET_PQ_result_spec_array_uint16 ( |
1422 | const struct GNUNET_PQ_Context *db, | 1460 | struct GNUNET_PQ_Context *db, |
1423 | const char *name, | 1461 | const char *name, |
1424 | size_t *num, | 1462 | size_t *num, |
1425 | uint16_t **dst) | 1463 | uint16_t **dst) |
@@ -1429,7 +1467,10 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1429 | 1467 | ||
1430 | info->num = num; | 1468 | info->num = num; |
1431 | info->typ = array_of_uint16; | 1469 | info->typ = array_of_uint16; |
1432 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT2]; | 1470 | GNUNET_assert (GNUNET_OK == |
1471 | GNUNET_PQ_get_oid_by_name (db, | ||
1472 | "int2", | ||
1473 | &info->oid)); | ||
1433 | 1474 | ||
1434 | struct GNUNET_PQ_ResultSpec res = { | 1475 | struct GNUNET_PQ_ResultSpec res = { |
1435 | .conv = extract_array_generic, | 1476 | .conv = extract_array_generic, |
@@ -1444,7 +1485,7 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1444 | 1485 | ||
1445 | struct GNUNET_PQ_ResultSpec | 1486 | struct GNUNET_PQ_ResultSpec |
1446 | GNUNET_PQ_result_spec_array_uint32 ( | 1487 | GNUNET_PQ_result_spec_array_uint32 ( |
1447 | const struct GNUNET_PQ_Context *db, | 1488 | struct GNUNET_PQ_Context *db, |
1448 | const char *name, | 1489 | const char *name, |
1449 | size_t *num, | 1490 | size_t *num, |
1450 | uint32_t **dst) | 1491 | uint32_t **dst) |
@@ -1454,7 +1495,10 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1454 | 1495 | ||
1455 | info->num = num; | 1496 | info->num = num; |
1456 | info->typ = array_of_uint32; | 1497 | info->typ = array_of_uint32; |
1457 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT4]; | 1498 | GNUNET_assert (GNUNET_OK == |
1499 | GNUNET_PQ_get_oid_by_name (db, | ||
1500 | "int4", | ||
1501 | &info->oid)); | ||
1458 | 1502 | ||
1459 | struct GNUNET_PQ_ResultSpec res = { | 1503 | struct GNUNET_PQ_ResultSpec res = { |
1460 | .conv = extract_array_generic, | 1504 | .conv = extract_array_generic, |
@@ -1469,7 +1513,7 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1469 | 1513 | ||
1470 | struct GNUNET_PQ_ResultSpec | 1514 | struct GNUNET_PQ_ResultSpec |
1471 | GNUNET_PQ_result_spec_array_uint64 ( | 1515 | GNUNET_PQ_result_spec_array_uint64 ( |
1472 | const struct GNUNET_PQ_Context *db, | 1516 | struct GNUNET_PQ_Context *db, |
1473 | const char *name, | 1517 | const char *name, |
1474 | size_t *num, | 1518 | size_t *num, |
1475 | uint64_t **dst) | 1519 | uint64_t **dst) |
@@ -1479,7 +1523,10 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1479 | 1523 | ||
1480 | info->num = num; | 1524 | info->num = num; |
1481 | info->typ = array_of_uint64; | 1525 | info->typ = array_of_uint64; |
1482 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1526 | GNUNET_assert (GNUNET_OK == |
1527 | GNUNET_PQ_get_oid_by_name (db, | ||
1528 | "int8", | ||
1529 | &info->oid)); | ||
1483 | 1530 | ||
1484 | struct GNUNET_PQ_ResultSpec res = { | 1531 | struct GNUNET_PQ_ResultSpec res = { |
1485 | .conv = extract_array_generic, | 1532 | .conv = extract_array_generic, |
@@ -1494,7 +1541,7 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1494 | 1541 | ||
1495 | struct GNUNET_PQ_ResultSpec | 1542 | struct GNUNET_PQ_ResultSpec |
1496 | GNUNET_PQ_result_spec_array_abs_time ( | 1543 | GNUNET_PQ_result_spec_array_abs_time ( |
1497 | const struct GNUNET_PQ_Context *db, | 1544 | struct GNUNET_PQ_Context *db, |
1498 | const char *name, | 1545 | const char *name, |
1499 | size_t *num, | 1546 | size_t *num, |
1500 | struct GNUNET_TIME_Absolute **dst) | 1547 | struct GNUNET_TIME_Absolute **dst) |
@@ -1504,7 +1551,10 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1504 | 1551 | ||
1505 | info->num = num; | 1552 | info->num = num; |
1506 | info->typ = array_of_abs_time; | 1553 | info->typ = array_of_abs_time; |
1507 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1554 | GNUNET_assert (GNUNET_OK == |
1555 | GNUNET_PQ_get_oid_by_name (db, | ||
1556 | "int8", | ||
1557 | &info->oid)); | ||
1508 | 1558 | ||
1509 | struct GNUNET_PQ_ResultSpec res = { | 1559 | struct GNUNET_PQ_ResultSpec res = { |
1510 | .conv = extract_array_generic, | 1560 | .conv = extract_array_generic, |
@@ -1519,7 +1569,7 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1519 | 1569 | ||
1520 | struct GNUNET_PQ_ResultSpec | 1570 | struct GNUNET_PQ_ResultSpec |
1521 | GNUNET_PQ_result_spec_array_rel_time ( | 1571 | GNUNET_PQ_result_spec_array_rel_time ( |
1522 | const struct GNUNET_PQ_Context *db, | 1572 | struct GNUNET_PQ_Context *db, |
1523 | const char *name, | 1573 | const char *name, |
1524 | size_t *num, | 1574 | size_t *num, |
1525 | struct GNUNET_TIME_Relative **dst) | 1575 | struct GNUNET_TIME_Relative **dst) |
@@ -1529,7 +1579,10 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1529 | 1579 | ||
1530 | info->num = num; | 1580 | info->num = num; |
1531 | info->typ = array_of_rel_time; | 1581 | info->typ = array_of_rel_time; |
1532 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1582 | GNUNET_assert (GNUNET_OK == |
1583 | GNUNET_PQ_get_oid_by_name (db, | ||
1584 | "int8", | ||
1585 | &info->oid)); | ||
1533 | 1586 | ||
1534 | struct GNUNET_PQ_ResultSpec res = { | 1587 | struct GNUNET_PQ_ResultSpec res = { |
1535 | .conv = extract_array_generic, | 1588 | .conv = extract_array_generic, |
@@ -1544,7 +1597,7 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1544 | 1597 | ||
1545 | struct GNUNET_PQ_ResultSpec | 1598 | struct GNUNET_PQ_ResultSpec |
1546 | GNUNET_PQ_result_spec_array_timestamp ( | 1599 | GNUNET_PQ_result_spec_array_timestamp ( |
1547 | const struct GNUNET_PQ_Context *db, | 1600 | struct GNUNET_PQ_Context *db, |
1548 | const char *name, | 1601 | const char *name, |
1549 | size_t *num, | 1602 | size_t *num, |
1550 | struct GNUNET_TIME_Timestamp **dst) | 1603 | struct GNUNET_TIME_Timestamp **dst) |
@@ -1554,7 +1607,10 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1554 | 1607 | ||
1555 | info->num = num; | 1608 | info->num = num; |
1556 | info->typ = array_of_timestamp; | 1609 | info->typ = array_of_timestamp; |
1557 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1610 | GNUNET_assert (GNUNET_OK == |
1611 | GNUNET_PQ_get_oid_by_name (db, | ||
1612 | "int8", | ||
1613 | &info->oid)); | ||
1558 | 1614 | ||
1559 | struct GNUNET_PQ_ResultSpec res = { | 1615 | struct GNUNET_PQ_ResultSpec res = { |
1560 | .conv = extract_array_generic, | 1616 | .conv = extract_array_generic, |
@@ -1569,7 +1625,7 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1569 | 1625 | ||
1570 | struct GNUNET_PQ_ResultSpec | 1626 | struct GNUNET_PQ_ResultSpec |
1571 | GNUNET_PQ_result_spec_array_variable_size ( | 1627 | GNUNET_PQ_result_spec_array_variable_size ( |
1572 | const struct GNUNET_PQ_Context *db, | 1628 | struct GNUNET_PQ_Context *db, |
1573 | const char *name, | 1629 | const char *name, |
1574 | size_t *num, | 1630 | size_t *num, |
1575 | size_t **sizes, | 1631 | size_t **sizes, |
@@ -1581,7 +1637,10 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1581 | info->num = num; | 1637 | info->num = num; |
1582 | info->sizes = sizes; | 1638 | info->sizes = sizes; |
1583 | info->typ = array_of_byte; | 1639 | info->typ = array_of_byte; |
1584 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1640 | GNUNET_assert (GNUNET_OK == |
1641 | GNUNET_PQ_get_oid_by_name (db, | ||
1642 | "bytea", | ||
1643 | &info->oid)); | ||
1585 | 1644 | ||
1586 | struct GNUNET_PQ_ResultSpec res = { | 1645 | struct GNUNET_PQ_ResultSpec res = { |
1587 | .conv = extract_array_generic, | 1646 | .conv = extract_array_generic, |
@@ -1596,7 +1655,7 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1596 | 1655 | ||
1597 | struct GNUNET_PQ_ResultSpec | 1656 | struct GNUNET_PQ_ResultSpec |
1598 | GNUNET_PQ_result_spec_array_fixed_size ( | 1657 | GNUNET_PQ_result_spec_array_fixed_size ( |
1599 | const struct GNUNET_PQ_Context *db, | 1658 | struct GNUNET_PQ_Context *db, |
1600 | const char *name, | 1659 | const char *name, |
1601 | size_t size, | 1660 | size_t size, |
1602 | size_t *num, | 1661 | size_t *num, |
@@ -1608,7 +1667,10 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1608 | info->num = num; | 1667 | info->num = num; |
1609 | info->same_size = size; | 1668 | info->same_size = size; |
1610 | info->typ = array_of_byte; | 1669 | info->typ = array_of_byte; |
1611 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1670 | GNUNET_assert (GNUNET_OK == |
1671 | GNUNET_PQ_get_oid_by_name (db, | ||
1672 | "bytea", | ||
1673 | &info->oid)); | ||
1612 | 1674 | ||
1613 | struct GNUNET_PQ_ResultSpec res = { | 1675 | struct GNUNET_PQ_ResultSpec res = { |
1614 | .conv = extract_array_generic, | 1676 | .conv = extract_array_generic, |
@@ -1623,7 +1685,7 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1623 | 1685 | ||
1624 | struct GNUNET_PQ_ResultSpec | 1686 | struct GNUNET_PQ_ResultSpec |
1625 | GNUNET_PQ_result_spec_array_string ( | 1687 | GNUNET_PQ_result_spec_array_string ( |
1626 | const struct GNUNET_PQ_Context *db, | 1688 | struct GNUNET_PQ_Context *db, |
1627 | const char *name, | 1689 | const char *name, |
1628 | size_t *num, | 1690 | size_t *num, |
1629 | char **dst) | 1691 | char **dst) |
@@ -1633,7 +1695,10 @@ GNUNET_PQ_result_spec_array_string ( | |||
1633 | 1695 | ||
1634 | info->num = num; | 1696 | info->num = num; |
1635 | info->typ = array_of_string; | 1697 | info->typ = array_of_string; |
1636 | info->oid = db->oids[GNUNET_PQ_DATATYPE_VARCHAR]; | 1698 | GNUNET_assert (GNUNET_OK == |
1699 | GNUNET_PQ_get_oid_by_name (db, | ||
1700 | "text", | ||
1701 | &info->oid)); | ||
1637 | 1702 | ||
1638 | struct GNUNET_PQ_ResultSpec res = { | 1703 | struct GNUNET_PQ_ResultSpec res = { |
1639 | .conv = extract_array_generic, | 1704 | .conv = extract_array_generic, |
diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 7188b9b8e..d70e18e6d 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c | |||
@@ -22,10 +22,10 @@ | |||
22 | * @brief Tests for Postgres convenience API | 22 | * @brief Tests for Postgres convenience API |
23 | * @author Christian Grothoff <christian@grothoff.org> | 23 | * @author Christian Grothoff <christian@grothoff.org> |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
25 | #include "gnunet_common.h" | 26 | #include "gnunet_common.h" |
26 | #include "gnunet_pq_lib.h" | 27 | #include "gnunet_pq_lib.h" |
27 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
28 | #include "platform.h" | ||
29 | #include "pq.h" | 29 | #include "pq.h" |
30 | 30 | ||
31 | /** | 31 | /** |
@@ -76,7 +76,7 @@ postgres_prepare (struct GNUNET_PQ_Context *db) | |||
76 | ",arr_int4" | 76 | ",arr_int4" |
77 | ",arr_int8" | 77 | ",arr_int8" |
78 | ",arr_bytea" | 78 | ",arr_bytea" |
79 | ",arr_varchar" | 79 | ",arr_text" |
80 | ",arr_abs_time" | 80 | ",arr_abs_time" |
81 | ",arr_rel_time" | 81 | ",arr_rel_time" |
82 | ",arr_timestamp" | 82 | ",arr_timestamp" |
@@ -102,7 +102,7 @@ postgres_prepare (struct GNUNET_PQ_Context *db) | |||
102 | ",arr_int4" | 102 | ",arr_int4" |
103 | ",arr_int8" | 103 | ",arr_int8" |
104 | ",arr_bytea" | 104 | ",arr_bytea" |
105 | ",arr_varchar" | 105 | ",arr_text" |
106 | ",arr_abs_time" | 106 | ",arr_abs_time" |
107 | ",arr_rel_time" | 107 | ",arr_rel_time" |
108 | ",arr_timestamp" | 108 | ",arr_timestamp" |
@@ -280,7 +280,7 @@ run_queries (struct GNUNET_PQ_Context *db) | |||
280 | &sz_buf, | 280 | &sz_buf, |
281 | &arr_buf), | 281 | &arr_buf), |
282 | GNUNET_PQ_result_spec_array_string (db, | 282 | GNUNET_PQ_result_spec_array_string (db, |
283 | "arr_varchar", | 283 | "arr_text", |
284 | &num_str, | 284 | &num_str, |
285 | &arr_str), | 285 | &arr_str), |
286 | GNUNET_PQ_result_spec_end | 286 | GNUNET_PQ_result_spec_end |
@@ -510,7 +510,7 @@ main (int argc, | |||
510 | ",arr_int4 INT4[]" | 510 | ",arr_int4 INT4[]" |
511 | ",arr_int8 INT8[]" | 511 | ",arr_int8 INT8[]" |
512 | ",arr_bytea BYTEA[]" | 512 | ",arr_bytea BYTEA[]" |
513 | ",arr_varchar VARCHAR[]" | 513 | ",arr_text TEXT[]" |
514 | ",arr_abs_time INT8[]" | 514 | ",arr_abs_time INT8[]" |
515 | ",arr_rel_time INT8[]" | 515 | ",arr_rel_time INT8[]" |
516 | ",arr_timestamp INT8[]" | 516 | ",arr_timestamp INT8[]" |
@@ -554,6 +554,41 @@ main (int argc, | |||
554 | GNUNET_PQ_disconnect (db); | 554 | GNUNET_PQ_disconnect (db); |
555 | return ret; | 555 | return ret; |
556 | } | 556 | } |
557 | |||
558 | /* ensure oid lookup works */ | ||
559 | { | ||
560 | enum GNUNET_GenericReturnValue ret; | ||
561 | Oid oid; | ||
562 | |||
563 | ret = GNUNET_PQ_get_oid_by_name (db, "int8", &oid); | ||
564 | |||
565 | if (GNUNET_OK != ret) | ||
566 | { | ||
567 | fprintf (stderr, | ||
568 | "Cannot lookup oid for int8: %s\n", | ||
569 | PQerrorMessage (db->conn)); | ||
570 | GNUNET_break (0); | ||
571 | GNUNET_PQ_disconnect (db); | ||
572 | return 77; /* signal test was skipped */ | ||
573 | } | ||
574 | |||
575 | PQexec (db->conn, "CREATE TYPE foo AS (foo int, bar int);"); | ||
576 | |||
577 | ret = GNUNET_PQ_get_oid_by_name (db, "foo", &oid); | ||
578 | if (GNUNET_OK != ret) | ||
579 | { | ||
580 | fprintf (stderr, | ||
581 | "Cannot lookup oid for foo: %s\n", | ||
582 | PQerrorMessage (db->conn)); | ||
583 | GNUNET_break (0); | ||
584 | GNUNET_PQ_disconnect (db); | ||
585 | return 77; /* signal test was skipped */ | ||
586 | } | ||
587 | |||
588 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
589 | "got oid %d for type foo\n", oid); | ||
590 | } | ||
591 | |||
557 | GNUNET_SCHEDULER_run (&sched_tests, | 592 | GNUNET_SCHEDULER_run (&sched_tests, |
558 | NULL); | 593 | NULL); |
559 | if (0 != ret) | 594 | if (0 != ret) |
diff --git a/src/pq/versioning.sql b/src/pq/versioning.sql index 116f409b7..c7fa81213 100644 --- a/src/pq/versioning.sql +++ b/src/pq/versioning.sql | |||
@@ -146,12 +146,17 @@ | |||
146 | 146 | ||
147 | BEGIN; | 147 | BEGIN; |
148 | 148 | ||
149 | -- Added by Christian Grothoff to support concurrency, see | ||
150 | -- https://stackoverflow.com/questions/29900845/create-schema-if-not-exists-raises-duplicate-key-error?rq=4 | ||
151 | LOCK TABLE pg_catalog.pg_namespace; | ||
152 | |||
153 | |||
149 | -- This file adds versioning support to database it will be loaded to. | 154 | -- This file adds versioning support to database it will be loaded to. |
150 | -- It requires that PL/pgSQL is already loaded - will raise exception otherwise. | 155 | -- It requires that PL/pgSQL is already loaded - will raise exception otherwise. |
151 | -- All versioning "stuff" (tables, functions) is in "_v" schema. | 156 | -- All versioning "stuff" (tables, functions) is in "_v" schema. |
152 | 157 | ||
153 | -- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows). | 158 | -- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows). |
154 | -- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling. | 159 | -- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling |
155 | CREATE SCHEMA IF NOT EXISTS _v; | 160 | CREATE SCHEMA IF NOT EXISTS _v; |
156 | COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.'; | 161 | COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.'; |
157 | 162 | ||
diff --git a/src/pt/meson.build b/src/pt/meson.build new file mode 100644 index 000000000..0b6cc1818 --- /dev/null +++ b/src/pt/meson.build | |||
@@ -0,0 +1,22 @@ | |||
1 | configure_file(input : 'pt.conf', | ||
2 | output : 'pt.conf', | ||
3 | configuration : cdata, | ||
4 | install: true, | ||
5 | install_dir: pkgcfgdir) | ||
6 | |||
7 | |||
8 | if get_option('monolith') | ||
9 | subdir_done() | ||
10 | endif | ||
11 | |||
12 | executable ('gnunet-daemon-pt', | ||
13 | ['gnunet-daemon-pt.c'], | ||
14 | dependencies: [libgnunetdns_dep, | ||
15 | libgnunetutil_dep, | ||
16 | libgnunetstatistics_dep, | ||
17 | libgnunetdht_dep, | ||
18 | libgnunetcadet_dep, | ||
19 | libgnunetvpn_dep], | ||
20 | include_directories: [incdir, configuration_inc], | ||
21 | install: true, | ||
22 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
diff --git a/src/reclaim/meson.build b/src/reclaim/meson.build new file mode 100644 index 000000000..fafc68a92 --- /dev/null +++ b/src/reclaim/meson.build | |||
@@ -0,0 +1,144 @@ | |||
1 | libgnunetreclaim_src = ['reclaim_api.c', | ||
2 | 'reclaim_attribute.c', | ||
3 | 'reclaim_credential.c'] | ||
4 | libgnunetdid_src = ['did_helper.c', | ||
5 | 'did_core.c'] | ||
6 | |||
7 | gnunetservicereclaim_src = ['gnunet-service-reclaim.c', | ||
8 | 'gnunet-service-reclaim_tickets.c'] | ||
9 | |||
10 | configure_file(input : 'reclaim.conf', | ||
11 | output : 'reclaim.conf', | ||
12 | configuration : cdata, | ||
13 | install: true, | ||
14 | install_dir: pkgcfgdir) | ||
15 | |||
16 | |||
17 | if get_option('monolith') | ||
18 | foreach p : libgnunetreclaim_src + gnunetservicereclaim_src | ||
19 | gnunet_src += 'reclaim/' + p | ||
20 | endforeach | ||
21 | subdir_done() | ||
22 | endif | ||
23 | |||
24 | libgnunetreclaim = library('gnunetreclaim', | ||
25 | libgnunetreclaim_src, | ||
26 | soversion: '0', | ||
27 | version: '0.0.0', | ||
28 | dependencies: [libgnunetutil_dep, | ||
29 | libgnunetidentity_dep], | ||
30 | include_directories: [incdir, configuration_inc], | ||
31 | install: true, | ||
32 | install_dir: get_option('libdir')) | ||
33 | libgnunetreclaim_dep = declare_dependency(link_with : libgnunetreclaim) | ||
34 | pkg.generate(libgnunetreclaim, url: 'https://www.gnunet.org', | ||
35 | description : 'Provides API to access reclaimID') | ||
36 | |||
37 | shared_module('gnunet_plugin_gnsrecord_reclaim', | ||
38 | ['plugin_gnsrecord_reclaim.c'], | ||
39 | dependencies: [libgnunetutil_dep, libgnunetgnsrecord_dep], | ||
40 | include_directories: [incdir, configuration_inc], | ||
41 | install: true, | ||
42 | install_dir: get_option('libdir')/'gnunet') | ||
43 | |||
44 | libgnunetdid = library('gnunetdid', | ||
45 | libgnunetdid_src, | ||
46 | soversion: '0', | ||
47 | version: '0.0.0', | ||
48 | dependencies: [libgnunetutil_dep, | ||
49 | libgnunetnamestore_dep, | ||
50 | libgnunetgnsrecord_dep, | ||
51 | libgnunetgns_dep, | ||
52 | json_dep, | ||
53 | libgnunetidentity_dep], | ||
54 | include_directories: [incdir, configuration_inc], | ||
55 | install: true, | ||
56 | install_dir: get_option('libdir')) | ||
57 | libgnunetdid_dep = declare_dependency(link_with : libgnunetdid) | ||
58 | pkg.generate(libgnunetdid, url: 'https://www.gnunet.org', | ||
59 | description : 'Provides API to manipulate DID') | ||
60 | |||
61 | shared_module('gnunet_plugin_rest_reclaim', | ||
62 | ['plugin_rest_reclaim.c', 'json_reclaim.c'], | ||
63 | dependencies: [libgnunetrest_dep, | ||
64 | libgnunetidentity_dep, | ||
65 | libgnunetreclaim_dep, | ||
66 | libgnunetjson_dep, | ||
67 | libgnunetutil_dep, | ||
68 | json_dep, | ||
69 | mhd_dep], | ||
70 | include_directories: [incdir, configuration_inc], | ||
71 | install: true, | ||
72 | install_dir: get_option('libdir') / 'gnunet') | ||
73 | shared_module('gnunet_plugin_reclaim_attribute_basic', | ||
74 | ['plugin_reclaim_attribute_basic.c'], | ||
75 | dependencies: [libgnunetrest_dep, | ||
76 | libgnunetidentity_dep, | ||
77 | libgnunetreclaim_dep, | ||
78 | libgnunetjson_dep, | ||
79 | libgnunetutil_dep, | ||
80 | json_dep], | ||
81 | include_directories: [incdir, configuration_inc], | ||
82 | install: true, | ||
83 | install_dir: get_option('libdir') / 'gnunet') | ||
84 | shared_module('gnunet_plugin_reclaim_credential_jwt', | ||
85 | ['plugin_reclaim_credential_jwt.c'], | ||
86 | dependencies: [libgnunetrest_dep, | ||
87 | libgnunetidentity_dep, | ||
88 | libgnunetreclaim_dep, | ||
89 | libgnunetjson_dep, | ||
90 | libgnunetutil_dep, | ||
91 | json_dep], | ||
92 | include_directories: [incdir, configuration_inc], | ||
93 | install: true, | ||
94 | install_dir: get_option('libdir') / 'gnunet') | ||
95 | |||
96 | |||
97 | shared_module('gnunet_plugin_rest_openid_connect', | ||
98 | ['plugin_rest_openid_connect.c', 'oidc_helper.c'], | ||
99 | dependencies: [libgnunetrest_dep, | ||
100 | libgnunetreclaim_dep, | ||
101 | libgnunetidentity_dep, | ||
102 | libgnunetgns_dep, | ||
103 | libgnunetutil_dep, | ||
104 | jose_dep, | ||
105 | gcrypt_dep, | ||
106 | json_dep, | ||
107 | mhd_dep], | ||
108 | include_directories: [incdir, configuration_inc], | ||
109 | install: true, | ||
110 | install_dir: get_option('libdir') / 'gnunet') | ||
111 | |||
112 | |||
113 | executable ('gnunet-reclaim', | ||
114 | 'gnunet-reclaim.c', | ||
115 | dependencies: [libgnunetreclaim_dep, | ||
116 | libgnunetidentity_dep, | ||
117 | libgnunetutil_dep], | ||
118 | include_directories: [incdir, configuration_inc], | ||
119 | install: true, | ||
120 | install_dir: get_option('bindir')) | ||
121 | executable ('gnunet-did', | ||
122 | 'gnunet-did.c', | ||
123 | dependencies: [libgnunetreclaim_dep, | ||
124 | libgnunetdid_dep, | ||
125 | libgnunetgns_dep, | ||
126 | libgnunetnamestore_dep, | ||
127 | libgnunetidentity_dep, | ||
128 | libgnunetutil_dep], | ||
129 | include_directories: [incdir, configuration_inc], | ||
130 | install: true, | ||
131 | install_dir: get_option('bindir')) | ||
132 | executable ('gnunet-service-reclaim', | ||
133 | gnunetservicereclaim_src, | ||
134 | dependencies: [libgnunetreclaim_dep, | ||
135 | libgnunetutil_dep, | ||
136 | libgnunetstatistics_dep, | ||
137 | libgnunetgnsrecord_dep, | ||
138 | libgnunetgns_dep, | ||
139 | libgnunetidentity_dep, | ||
140 | libgnunetnamestore_dep], | ||
141 | include_directories: [incdir, configuration_inc], | ||
142 | install: true, | ||
143 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
144 | |||
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index a6c9c0903..b7d14bc41 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -78,21 +78,20 @@ libgnunet_plugin_block_regex_la_LDFLAGS = \ | |||
78 | $(GN_LIBINTL) \ | 78 | $(GN_LIBINTL) \ |
79 | $(GN_PLUGIN_LDFLAGS) | 79 | $(GN_PLUGIN_LDFLAGS) |
80 | 80 | ||
81 | if HAVE_MYSQL | 81 | # FIXME we phased out mysql. If we want to keep, needs rewrite |
82 | noinst_mysql_progs = \ | 82 | #if HAVE_MYSQL |
83 | gnunet-regex-simulation-profiler | 83 | #noinst_mysql_progs = \ |
84 | 84 | # gnunet-regex-simulation-profiler | |
85 | gnunet_regex_simulation_profiler_SOURCES = \ | 85 | |
86 | $(REGEX_INTERNAL) gnunet-regex-simulation-profiler.c | 86 | #gnunet_regex_simulation_profiler_SOURCES = \ |
87 | gnunet_regex_simulation_profiler_LDADD = \ | 87 | # $(REGEX_INTERNAL) gnunet-regex-simulation-profiler.c |
88 | libgnunetregexblock.la \ | 88 | #gnunet_regex_simulation_profiler_LDADD = \ |
89 | $(top_builddir)/src/util/libgnunetutil.la \ | 89 | # libgnunetregexblock.la \ |
90 | $(top_builddir)/src/dht/libgnunetdht.la \ | 90 | # $(top_builddir)/src/util/libgnunetutil.la \ |
91 | $(top_builddir)/src/my/libgnunetmy.la \ | 91 | # $(top_builddir)/src/dht/libgnunetdht.la \ |
92 | $(top_builddir)/src/mysql/libgnunetmysql.la \ | 92 | # $(top_builddir)/src/block/libgnunetblock.la \ |
93 | $(top_builddir)/src/block/libgnunetblock.la \ | 93 | # $(top_builddir)/src/statistics/libgnunetstatistics.la |
94 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 94 | #endif |
95 | endif | ||
96 | 95 | ||
97 | noinst_PROGRAMS = $(noinst_mysql_progs) \ | 96 | noinst_PROGRAMS = $(noinst_mysql_progs) \ |
98 | perf-regex \ | 97 | perf-regex \ |
diff --git a/src/regex/meson.build b/src/regex/meson.build new file mode 100644 index 000000000..24bc8e31e --- /dev/null +++ b/src/regex/meson.build | |||
@@ -0,0 +1,80 @@ | |||
1 | libgnunetregex_src = ['regex_api_announce.c', | ||
2 | 'regex_api_search.c'] | ||
3 | libgnunetregexblock_src = ['regex_block_lib.c'] | ||
4 | |||
5 | gnunetserviceregex_src = ['gnunet-service-regex.c', | ||
6 | 'regex_internal_dht.c', | ||
7 | 'regex_internal.c'] | ||
8 | |||
9 | configure_file(input : 'regex.conf.in', | ||
10 | output : 'regex.conf', | ||
11 | configuration : cdata, | ||
12 | install: true, | ||
13 | install_dir: pkgcfgdir) | ||
14 | |||
15 | |||
16 | if get_option('monolith') | ||
17 | foreach p : libgnunetregex_src + libgnunetregexblock_src + gnunetserviceregex_src | ||
18 | gnunet_src += 'regex/' + p | ||
19 | endforeach | ||
20 | subdir_done() | ||
21 | endif | ||
22 | |||
23 | libgnunetregex = library('gnunetregex', | ||
24 | libgnunetregex_src, | ||
25 | soversion: '3', | ||
26 | version: '3.0.1', | ||
27 | dependencies: libgnunetutil_dep, | ||
28 | include_directories: [incdir, configuration_inc], | ||
29 | install: true, | ||
30 | install_dir: get_option('libdir')) | ||
31 | pkg.generate(libgnunetregex, url: 'https://www.gnunet.org', | ||
32 | description : 'Provides API for accessing the regex service') | ||
33 | libgnunetregex_dep = declare_dependency(link_with : libgnunetregex) | ||
34 | libgnunetregexblock = library('gnunetregexblock', | ||
35 | libgnunetregexblock_src, | ||
36 | soversion: '1', | ||
37 | version: '1.0.0', | ||
38 | dependencies: libgnunetutil_dep, | ||
39 | include_directories: [incdir, configuration_inc], | ||
40 | install: true, | ||
41 | install_dir: get_option('libdir')) | ||
42 | libgnunetregexblock_dep = declare_dependency(link_with : libgnunetregexblock) | ||
43 | |||
44 | shared_module('gnunet_plugin_block_regex', | ||
45 | ['plugin_block_regex.c'], | ||
46 | dependencies: [libgnunetutil_dep, | ||
47 | libgnunetregexblock_dep, | ||
48 | libgnunetblock_dep, | ||
49 | libgnunetblockgroup_dep], | ||
50 | include_directories: [incdir, configuration_inc], | ||
51 | install:true, | ||
52 | install_dir: get_option('libdir')/'gnunet') | ||
53 | |||
54 | |||
55 | executable ('gnunet-service-regex', | ||
56 | gnunetserviceregex_src, | ||
57 | dependencies: [libgnunetregex_dep, libgnunetutil_dep, | ||
58 | libgnunetdht_dep, | ||
59 | libgnunetstatistics_dep, | ||
60 | libgnunetregex_dep, | ||
61 | libgnunetregexblock_dep], | ||
62 | include_directories: [incdir, configuration_inc], | ||
63 | install: true, | ||
64 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
65 | executable ('gnunet-daemon-regexprofiler', | ||
66 | ['gnunet-daemon-regexprofiler.c', | ||
67 | 'regex_internal.c', | ||
68 | 'regex_internal_dht.c', | ||
69 | 'regex_test_lib.c', | ||
70 | 'regex_test_graph.c', | ||
71 | 'regex_test_random.c'], | ||
72 | dependencies: [libgnunetregex_dep, libgnunetutil_dep, | ||
73 | libgnunetdht_dep, | ||
74 | libgnunetstatistics_dep, | ||
75 | libgnunetregex_dep, | ||
76 | libgnunetregexblock_dep], | ||
77 | include_directories: [incdir, configuration_inc], | ||
78 | install: true, | ||
79 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
80 | |||
diff --git a/src/rest/meson.build b/src/rest/meson.build new file mode 100644 index 000000000..2dd3d8de4 --- /dev/null +++ b/src/rest/meson.build | |||
@@ -0,0 +1,58 @@ | |||
1 | libgnunetrest_src = ['rest.c'] | ||
2 | |||
3 | gnunetservicerest_src = ['gnunet-rest-server.c'] | ||
4 | |||
5 | configure_file(input : 'rest.conf', | ||
6 | output : 'rest.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetrest_src + gnunetservicerest_src | ||
14 | gnunet_src += 'rest/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | |||
20 | libgnunetrest = library('gnunetrest', | ||
21 | libgnunetrest_src, | ||
22 | soversion: '0', | ||
23 | version: '0.0.0', | ||
24 | dependencies: [libgnunetutil_dep, mhd_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | pkg.generate(libgnunetrest, url: 'https://www.gnunet.org', | ||
29 | description : 'Provides API for accessing the REST service') | ||
30 | libgnunetrest_dep = declare_dependency(link_with : libgnunetrest) | ||
31 | |||
32 | shared_module('gnunet_plugin_rest_config', | ||
33 | ['plugin_rest_config.c'], | ||
34 | dependencies: [libgnunetrest_dep, | ||
35 | libgnunetutil_dep, | ||
36 | json_dep, | ||
37 | mhd_dep], | ||
38 | include_directories: [incdir, configuration_inc], | ||
39 | install: true, | ||
40 | install_dir: get_option('libdir') / 'gnunet') | ||
41 | shared_module('gnunet_plugin_rest_copying', | ||
42 | ['plugin_rest_copying.c'], | ||
43 | dependencies: [libgnunetrest_dep, | ||
44 | libgnunetutil_dep, | ||
45 | json_dep, | ||
46 | mhd_dep], | ||
47 | include_directories: [incdir, configuration_inc], | ||
48 | install: true, | ||
49 | install_dir: get_option('libdir') / 'gnunet') | ||
50 | |||
51 | |||
52 | executable ('gnunet-rest-server', | ||
53 | gnunetservicerest_src, | ||
54 | dependencies: [libgnunetrest_dep, libgnunetutil_dep, mhd_dep], | ||
55 | include_directories: [incdir, configuration_inc], | ||
56 | install: true, | ||
57 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
58 | |||
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am index 918ef02bb..a375b7587 100644 --- a/src/revocation/Makefile.am +++ b/src/revocation/Makefile.am | |||
@@ -50,6 +50,13 @@ gnunet_revocation_tvg_LDADD = \ | |||
50 | $(top_builddir)/src/util/libgnunetutil.la \ | 50 | $(top_builddir)/src/util/libgnunetutil.la \ |
51 | $(GN_LIBINTL) | 51 | $(GN_LIBINTL) |
52 | 52 | ||
53 | test_revocation_lsd0001testvectors_SOURCES = \ | ||
54 | test_revocation_testvectors.c | ||
55 | test_revocation_lsd0001testvectors_LDADD = \ | ||
56 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
57 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
58 | libgnunetrevocation.la \ | ||
59 | $(top_builddir)/src/util/libgnunetutil.la | ||
53 | 60 | ||
54 | lib_LTLIBRARIES = libgnunetrevocation.la | 61 | lib_LTLIBRARIES = libgnunetrevocation.la |
55 | 62 | ||
@@ -92,10 +99,11 @@ test_revocation_LDADD = \ | |||
92 | $(top_builddir)/src/testbed/libgnunettestbed.la | 99 | $(top_builddir)/src/testbed/libgnunettestbed.la |
93 | 100 | ||
94 | check_PROGRAMS = \ | 101 | check_PROGRAMS = \ |
95 | # test_revocation | 102 | #test_revocation \ |
103 | #test_revocation_lsd0001testvectors | ||
96 | 104 | ||
97 | check_SCRIPTS = \ | 105 | check_SCRIPTS = \ |
98 | # test_local_revocation.py | 106 | #test_local_revocation.py |
99 | 107 | ||
100 | if ENABLE_TEST_RUN | 108 | if ENABLE_TEST_RUN |
101 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 109 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c index e1c9aa044..e8b0820bb 100644 --- a/src/revocation/gnunet-revocation-tvg.c +++ b/src/revocation/gnunet-revocation-tvg.c | |||
@@ -34,10 +34,14 @@ | |||
34 | #define TEST_EPOCHS 2 | 34 | #define TEST_EPOCHS 2 |
35 | #define TEST_DIFFICULTY 5 | 35 | #define TEST_DIFFICULTY 5 |
36 | 36 | ||
37 | static char* d_pkey = | 37 | static char*d_pkey = |
38 | "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; | 38 | "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; |
39 | 39 | ||
40 | int parsehex(char *src, char *dst, size_t dstlen, int invert) | 40 | static char *d_edkey = |
41 | "5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65"; | ||
42 | |||
43 | int | ||
44 | parsehex (char *src, char *dst, size_t dstlen, int invert) | ||
41 | { | 45 | { |
42 | char *line = src; | 46 | char *line = src; |
43 | char *data = line; | 47 | char *data = line; |
@@ -45,7 +49,8 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert) | |||
45 | int read_byte; | 49 | int read_byte; |
46 | int data_len = 0; | 50 | int data_len = 0; |
47 | 51 | ||
48 | while (sscanf(data, " %02x%n", &read_byte, &off) == 1) { | 52 | while (sscanf (data, " %02x%n", &read_byte, &off) == 1) |
53 | { | ||
49 | if (invert) | 54 | if (invert) |
50 | dst[dstlen - 1 - data_len++] = read_byte; | 55 | dst[dstlen - 1 - data_len++] = read_byte; |
51 | else | 56 | else |
@@ -58,16 +63,25 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert) | |||
58 | 63 | ||
59 | static void | 64 | static void |
60 | print_bytes_ (void *buf, | 65 | print_bytes_ (void *buf, |
61 | size_t buf_len, | 66 | size_t buf_len, |
62 | int fold, | 67 | int fold, |
63 | int in_be) | 68 | int in_be) |
64 | { | 69 | { |
65 | int i; | 70 | int i; |
66 | 71 | ||
67 | for (i = 0; i < buf_len; i++) | 72 | for (i = 0; i < buf_len; i++) |
68 | { | 73 | { |
69 | if ((0 != i) && (0 != fold) && (i % fold == 0)) | 74 | if (0 != i) |
70 | printf ("\n"); | 75 | { |
76 | if ((0 != fold) && (i % fold == 0)) | ||
77 | printf ("\n "); | ||
78 | else | ||
79 | printf (" "); | ||
80 | } | ||
81 | else | ||
82 | { | ||
83 | printf (" "); | ||
84 | } | ||
71 | if (in_be) | 85 | if (in_be) |
72 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | 86 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); |
73 | else | 87 | else |
@@ -76,6 +90,7 @@ print_bytes_ (void *buf, | |||
76 | printf ("\n"); | 90 | printf ("\n"); |
77 | } | 91 | } |
78 | 92 | ||
93 | |||
79 | static void | 94 | static void |
80 | print_bytes (void *buf, | 95 | print_bytes (void *buf, |
81 | size_t buf_len, | 96 | size_t buf_len, |
@@ -85,22 +100,9 @@ print_bytes (void *buf, | |||
85 | } | 100 | } |
86 | 101 | ||
87 | 102 | ||
88 | |||
89 | /** | ||
90 | * Main function that will be run. | ||
91 | * | ||
92 | * @param cls closure | ||
93 | * @param args remaining command-line arguments | ||
94 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
95 | * @param cfg configuration | ||
96 | */ | ||
97 | static void | 103 | static void |
98 | run (void *cls, | 104 | run_with_key (struct GNUNET_IDENTITY_PrivateKey *id_priv) |
99 | char *const *args, | ||
100 | const char *cfgfile, | ||
101 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
102 | { | 105 | { |
103 | struct GNUNET_IDENTITY_PrivateKey id_priv; | ||
104 | struct GNUNET_IDENTITY_PublicKey id_pub; | 106 | struct GNUNET_IDENTITY_PublicKey id_pub; |
105 | struct GNUNET_REVOCATION_PowP *pow; | 107 | struct GNUNET_REVOCATION_PowP *pow; |
106 | struct GNUNET_REVOCATION_PowCalculationHandle *ph; | 108 | struct GNUNET_REVOCATION_PowCalculationHandle *ph; |
@@ -108,17 +110,13 @@ run (void *cls, | |||
108 | char ztld[128]; | 110 | char ztld[128]; |
109 | ssize_t key_len; | 111 | ssize_t key_len; |
110 | 112 | ||
111 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); | 113 | GNUNET_IDENTITY_key_get_public (id_priv, |
112 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | ||
113 | parsehex(d_pkey,(char*)&id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1); | ||
114 | GNUNET_IDENTITY_key_get_public (&id_priv, | ||
115 | &id_pub); | 114 | &id_pub); |
116 | GNUNET_STRINGS_data_to_string (&id_pub, | 115 | GNUNET_STRINGS_data_to_string (&id_pub, |
117 | GNUNET_IDENTITY_public_key_get_length (&id_pub), | 116 | GNUNET_IDENTITY_public_key_get_length ( |
117 | &id_pub), | ||
118 | ztld, | 118 | ztld, |
119 | sizeof (ztld)); | 119 | sizeof (ztld)); |
120 | fprintf (stdout, "Zone private key (d, big-endian scalar):\n"); | ||
121 | print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1); | ||
122 | fprintf (stdout, "\n"); | 120 | fprintf (stdout, "\n"); |
123 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); | 121 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); |
124 | key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub); | 122 | key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub); |
@@ -129,7 +127,7 @@ run (void *cls, | |||
129 | fprintf (stdout, "%s\n", ztld); | 127 | fprintf (stdout, "%s\n", ztld); |
130 | fprintf (stdout, "\n"); | 128 | fprintf (stdout, "\n"); |
131 | pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); | 129 | pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); |
132 | GNUNET_REVOCATION_pow_init (&id_priv, | 130 | GNUNET_REVOCATION_pow_init (id_priv, |
133 | pow); | 131 | pow); |
134 | ph = GNUNET_REVOCATION_pow_start (pow, | 132 | ph = GNUNET_REVOCATION_pow_start (pow, |
135 | TEST_EPOCHS, | 133 | TEST_EPOCHS, |
@@ -162,6 +160,39 @@ run (void *cls, | |||
162 | GNUNET_REVOCATION_proof_get_size (pow), | 160 | GNUNET_REVOCATION_proof_get_size (pow), |
163 | 8); | 161 | 8); |
164 | GNUNET_free (ph); | 162 | GNUNET_free (ph); |
163 | |||
164 | } | ||
165 | |||
166 | |||
167 | /** | ||
168 | * Main function that will be run. | ||
169 | * | ||
170 | * @param cls closure | ||
171 | * @param args remaining command-line arguments | ||
172 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
173 | * @param cfg configuration | ||
174 | */ | ||
175 | static void | ||
176 | run (void *cls, | ||
177 | char *const *args, | ||
178 | const char *cfgfile, | ||
179 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
180 | { | ||
181 | struct GNUNET_IDENTITY_PrivateKey id_priv; | ||
182 | |||
183 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); | ||
184 | parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1); | ||
185 | |||
186 | fprintf (stdout, "Zone private key (d, big-endian):\n"); | ||
187 | print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1); | ||
188 | run_with_key (&id_priv); | ||
189 | printf ("\n"); | ||
190 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA); | ||
191 | parsehex (d_edkey,(char*) &id_priv.eddsa_key, sizeof (id_priv.eddsa_key), 0); | ||
192 | |||
193 | fprintf (stdout, "Zone private key (d):\n"); | ||
194 | print_bytes (&id_priv.eddsa_key, sizeof(id_priv.eddsa_key), 8); | ||
195 | run_with_key (&id_priv); | ||
165 | } | 196 | } |
166 | 197 | ||
167 | 198 | ||
diff --git a/src/revocation/meson.build b/src/revocation/meson.build new file mode 100644 index 000000000..9a526af36 --- /dev/null +++ b/src/revocation/meson.build | |||
@@ -0,0 +1,63 @@ | |||
1 | libgnunetrevocation_src = ['revocation_api.c'] | ||
2 | |||
3 | gnunetservicerevocation_src = ['gnunet-service-revocation.c'] | ||
4 | |||
5 | configure_file(input : 'revocation.conf.in', | ||
6 | output : 'revocation.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetrevocation_src + gnunetservicerevocation_src | ||
14 | gnunet_src += 'revocation/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | libgnunetrevocation = library('gnunetrevocation', | ||
20 | libgnunetrevocation_src, | ||
21 | soversion: '0', | ||
22 | version: '0.0.0', | ||
23 | dependencies: [libgnunetutil_dep, libgnunetidentity_dep], | ||
24 | include_directories: [incdir, configuration_inc], | ||
25 | install: true, | ||
26 | install_dir: get_option('libdir')) | ||
27 | libgnunetrevocation_dep = declare_dependency(link_with : libgnunetrevocation) | ||
28 | pkg.generate(libgnunetrevocation, url: 'https://www.gnunet.org', | ||
29 | description : 'Provides API to perform key revocation in GNUnet') | ||
30 | |||
31 | shared_module('gnunet_plugin_block_revocation', | ||
32 | ['plugin_block_revocation.c'], | ||
33 | dependencies: [libgnunetutil_dep, | ||
34 | libgnunetidentity_dep, | ||
35 | libgnunetrevocation_dep, | ||
36 | libgnunetblock_dep], | ||
37 | include_directories: [incdir, configuration_inc], | ||
38 | install: true, | ||
39 | install_dir: get_option('libdir')/'gnunet') | ||
40 | |||
41 | executable ('gnunet-revocation', | ||
42 | ['gnunet-revocation.c'], | ||
43 | dependencies: [libgnunetrevocation_dep, | ||
44 | libgnunetutil_dep, | ||
45 | libgnunetstatistics_dep, | ||
46 | libgnunetcore_dep, | ||
47 | libgnunetsetu_dep, | ||
48 | libgnunetidentity_dep], | ||
49 | include_directories: [incdir, configuration_inc], | ||
50 | install: true, | ||
51 | install_dir: get_option('bindir')) | ||
52 | executable ('gnunet-service-revocation', | ||
53 | gnunetservicerevocation_src, | ||
54 | dependencies: [libgnunetrevocation_dep, | ||
55 | libgnunetutil_dep, | ||
56 | libgnunetstatistics_dep, | ||
57 | libgnunetcore_dep, | ||
58 | libgnunetsetu_dep, | ||
59 | libgnunetidentity_dep], | ||
60 | include_directories: [incdir, configuration_inc], | ||
61 | install: true, | ||
62 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
63 | |||
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 327b03494..819c34b71 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -401,6 +401,7 @@ calculate_score (const struct GNUNET_REVOCATION_PowCalculationHandle *ph) | |||
401 | return avg; | 401 | return avg; |
402 | } | 402 | } |
403 | 403 | ||
404 | |||
404 | struct GNUNET_REVOCATION_SignaturePurposePS * | 405 | struct GNUNET_REVOCATION_SignaturePurposePS * |
405 | REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow) | 406 | REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow) |
406 | { | 407 | { |
@@ -412,7 +413,7 @@ REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow) | |||
412 | ksize = GNUNET_IDENTITY_public_key_get_length (pk); | 413 | ksize = GNUNET_IDENTITY_public_key_get_length (pk); |
413 | spurp = GNUNET_malloc (sizeof (*spurp) + ksize); | 414 | spurp = GNUNET_malloc (sizeof (*spurp) + ksize); |
414 | spurp->timestamp = pow->timestamp; | 415 | spurp->timestamp = pow->timestamp; |
415 | spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 416 | spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION); |
416 | spurp->purpose.size = htonl (sizeof(*spurp) + ksize); | 417 | spurp->purpose.size = htonl (sizeof(*spurp) + ksize); |
417 | GNUNET_IDENTITY_write_public_key_to_buffer (pk, | 418 | GNUNET_IDENTITY_write_public_key_to_buffer (pk, |
418 | (char*) &spurp[1], | 419 | (char*) &spurp[1], |
@@ -420,6 +421,7 @@ REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow) | |||
420 | return spurp; | 421 | return spurp; |
421 | } | 422 | } |
422 | 423 | ||
424 | |||
423 | enum GNUNET_GenericReturnValue | 425 | enum GNUNET_GenericReturnValue |
424 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | 426 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, |
425 | const struct GNUNET_IDENTITY_PublicKey *key) | 427 | const struct GNUNET_IDENTITY_PublicKey *key) |
@@ -433,10 +435,11 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | |||
433 | spurp = REV_create_signature_message (pow); | 435 | spurp = REV_create_signature_message (pow); |
434 | sig = ((unsigned char*) &pow[1] + ksize); | 436 | sig = ((unsigned char*) &pow[1] + ksize); |
435 | ret = | 437 | ret = |
436 | GNUNET_IDENTITY_signature_verify_raw_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 438 | GNUNET_IDENTITY_signature_verify_raw_ ( |
437 | &spurp->purpose, | 439 | GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION, |
438 | sig, | 440 | &spurp->purpose, |
439 | key); | 441 | sig, |
442 | key); | ||
440 | GNUNET_free (spurp); | 443 | GNUNET_free (spurp); |
441 | return ret == GNUNET_OK ? GNUNET_OK : GNUNET_SYSERR; | 444 | return ret == GNUNET_OK ? GNUNET_OK : GNUNET_SYSERR; |
442 | } | 445 | } |
diff --git a/src/revocation/test_revocation_testvectors.c b/src/revocation/test_revocation_testvectors.c new file mode 100644 index 000000000..355576fb7 --- /dev/null +++ b/src/revocation/test_revocation_testvectors.c | |||
@@ -0,0 +1,297 @@ | |||
1 | #include "platform.h" | ||
2 | #include "gnunet_util_lib.h" | ||
3 | #include "gnunet_revocation_service.h" | ||
4 | #include "gnunet_gnsrecord_lib.h" | ||
5 | #include <inttypes.h> | ||
6 | |||
7 | int res; | ||
8 | |||
9 | struct RevocationTv | ||
10 | { | ||
11 | char *d; | ||
12 | char *zid; | ||
13 | char *ztld; | ||
14 | char *m; | ||
15 | char *proof; | ||
16 | int diff; | ||
17 | int epochs; | ||
18 | }; | ||
19 | |||
20 | struct RevocationTv rtvs[] = { | ||
21 | { | ||
22 | .d = | ||
23 | "6f ea 32 c0 5a f5 8b fa" | ||
24 | "97 95 53 d1 88 60 5f d5" | ||
25 | "7d 8b f9 cc 26 3b 78 d5" | ||
26 | "f7 47 8c 07 b9 98 ed 70", | ||
27 | .zid = | ||
28 | "00 01 00 00 2c a2 23 e8" | ||
29 | "79 ec c4 bb de b5 da 17" | ||
30 | "31 92 81 d6 3b 2e 3b 69" | ||
31 | "55 f1 c3 77 5c 80 4a 98" | ||
32 | "d5 f8 dd aa", | ||
33 | .ztld = | ||
34 | "000G001CM8HYGYFCRJXXXDET2WRS50EP7CQ3PTANY71QEQ409ACDBY6XN8", | ||
35 | .m = | ||
36 | "00 00 00 34 00 00 00 03" | ||
37 | "00 05 fe b4 6d 86 5c 1c" | ||
38 | "00 01 00 00 2c a2 23 e8" | ||
39 | "79 ec c4 bb de b5 da 17" | ||
40 | "31 92 81 d6 3b 2e 3b 69" | ||
41 | "55 f1 c3 77 5c 80 4a 98" | ||
42 | "d5 f8 dd aa", | ||
43 | .proof = | ||
44 | "00 05 ff 1c 56 e4 b2 68" | ||
45 | "00 00 39 5d 18 27 c0 00" | ||
46 | "38 0b 54 aa 70 16 ac a2" | ||
47 | "38 0b 54 aa 70 16 ad 62" | ||
48 | "38 0b 54 aa 70 16 af 3e" | ||
49 | "38 0b 54 aa 70 16 af 93" | ||
50 | "38 0b 54 aa 70 16 b0 bf" | ||
51 | "38 0b 54 aa 70 16 b0 ee" | ||
52 | "38 0b 54 aa 70 16 b1 c9" | ||
53 | "38 0b 54 aa 70 16 b1 e5" | ||
54 | "38 0b 54 aa 70 16 b2 78" | ||
55 | "38 0b 54 aa 70 16 b2 b2" | ||
56 | "38 0b 54 aa 70 16 b2 d6" | ||
57 | "38 0b 54 aa 70 16 b2 e4" | ||
58 | "38 0b 54 aa 70 16 b3 2c" | ||
59 | "38 0b 54 aa 70 16 b3 5a" | ||
60 | "38 0b 54 aa 70 16 b3 9d" | ||
61 | "38 0b 54 aa 70 16 b3 c0" | ||
62 | "38 0b 54 aa 70 16 b3 dd" | ||
63 | "38 0b 54 aa 70 16 b3 f4" | ||
64 | "38 0b 54 aa 70 16 b4 42" | ||
65 | "38 0b 54 aa 70 16 b4 76" | ||
66 | "38 0b 54 aa 70 16 b4 8c" | ||
67 | "38 0b 54 aa 70 16 b4 a4" | ||
68 | "38 0b 54 aa 70 16 b4 c9" | ||
69 | "38 0b 54 aa 70 16 b4 f0" | ||
70 | "38 0b 54 aa 70 16 b4 f7" | ||
71 | "38 0b 54 aa 70 16 b5 79" | ||
72 | "38 0b 54 aa 70 16 b6 34" | ||
73 | "38 0b 54 aa 70 16 b6 8e" | ||
74 | "38 0b 54 aa 70 16 b7 b4" | ||
75 | "38 0b 54 aa 70 16 b8 7e" | ||
76 | "38 0b 54 aa 70 16 b8 f8" | ||
77 | "38 0b 54 aa 70 16 b9 2a" | ||
78 | "00 01 00 00 2c a2 23 e8" | ||
79 | "79 ec c4 bb de b5 da 17" | ||
80 | "31 92 81 d6 3b 2e 3b 69" | ||
81 | "55 f1 c3 77 5c 80 4a 98" | ||
82 | "d5 f8 dd aa 08 ca ff de" | ||
83 | "3c 6d f1 45 f7 e0 79 81" | ||
84 | "15 37 b2 b0 42 2d 5e 1f" | ||
85 | "b2 01 97 81 ec a2 61 d1" | ||
86 | "f9 d8 ea 81 0a bc 2f 33" | ||
87 | "47 7f 04 e3 64 81 11 be" | ||
88 | "71 c2 48 82 1a d6 04 f4" | ||
89 | "94 e7 4d 0b f5 11 d2 c1" | ||
90 | "62 77 2e 81", | ||
91 | .diff = 5, | ||
92 | .epochs = 2 | ||
93 | }, | ||
94 | { | ||
95 | .d = | ||
96 | "5a f7 02 0e e1 91 60 32" | ||
97 | "88 32 35 2b bc 6a 68 a8" | ||
98 | "d7 1a 7c be 1b 92 99 69" | ||
99 | "a7 c6 6d 41 5a 0d 8f 65", | ||
100 | .zid = | ||
101 | "00 01 00 14 3c f4 b9 24" | ||
102 | "03 20 22 f0 dc 50 58 14" | ||
103 | "53 b8 5d 93 b0 47 b6 3d" | ||
104 | "44 6c 58 45 cb 48 44 5d" | ||
105 | "db 96 68 8f", | ||
106 | .ztld = | ||
107 | "000G051WYJWJ80S04BRDRM2R2H9VGQCKP13VCFA4DHC4BJT88HEXQ5K8HW", | ||
108 | .diff = 5, | ||
109 | .epochs = 2, | ||
110 | .m = | ||
111 | "00 00 00 34 00 00 00 03" | ||
112 | "00 05 ff 1c 57 35 42 bd" | ||
113 | "00 01 00 14 3c f4 b9 24" | ||
114 | "03 20 22 f0 dc 50 58 14" | ||
115 | "53 b8 5d 93 b0 47 b6 3d" | ||
116 | "44 6c 58 45 cb 48 44 5d" | ||
117 | "db 96 68 8f", | ||
118 | .proof = | ||
119 | "00 05 ff 1c 57 35 42 bd" | ||
120 | "00 00 39 5d 18 27 c0 00" | ||
121 | "58 4c 93 3c b0 99 2a 08" | ||
122 | "58 4c 93 3c b0 99 2d f7" | ||
123 | "58 4c 93 3c b0 99 2e 21" | ||
124 | "58 4c 93 3c b0 99 2e 2a" | ||
125 | "58 4c 93 3c b0 99 2e 53" | ||
126 | "58 4c 93 3c b0 99 2e 8e" | ||
127 | "58 4c 93 3c b0 99 2f 13" | ||
128 | "58 4c 93 3c b0 99 2f 2d" | ||
129 | "58 4c 93 3c b0 99 2f 3c" | ||
130 | "58 4c 93 3c b0 99 2f 41" | ||
131 | "58 4c 93 3c b0 99 2f fd" | ||
132 | "58 4c 93 3c b0 99 30 33" | ||
133 | "58 4c 93 3c b0 99 30 82" | ||
134 | "58 4c 93 3c b0 99 30 a2" | ||
135 | "58 4c 93 3c b0 99 30 e1" | ||
136 | "58 4c 93 3c b0 99 31 ce" | ||
137 | "58 4c 93 3c b0 99 31 de" | ||
138 | "58 4c 93 3c b0 99 32 12" | ||
139 | "58 4c 93 3c b0 99 32 4e" | ||
140 | "58 4c 93 3c b0 99 32 9f" | ||
141 | "58 4c 93 3c b0 99 33 31" | ||
142 | "58 4c 93 3c b0 99 33 87" | ||
143 | "58 4c 93 3c b0 99 33 8c" | ||
144 | "58 4c 93 3c b0 99 33 e5" | ||
145 | "58 4c 93 3c b0 99 33 f3" | ||
146 | "58 4c 93 3c b0 99 34 26" | ||
147 | "58 4c 93 3c b0 99 34 30" | ||
148 | "58 4c 93 3c b0 99 34 68" | ||
149 | "58 4c 93 3c b0 99 34 88" | ||
150 | "58 4c 93 3c b0 99 34 8a" | ||
151 | "58 4c 93 3c b0 99 35 4c" | ||
152 | "58 4c 93 3c b0 99 35 bd" | ||
153 | "00 01 00 14 3c f4 b9 24" | ||
154 | "03 20 22 f0 dc 50 58 14" | ||
155 | "53 b8 5d 93 b0 47 b6 3d" | ||
156 | "44 6c 58 45 cb 48 44 5d" | ||
157 | "db 96 68 8f 04 ae 26 f7" | ||
158 | "63 56 5a b7 aa ab 01 71" | ||
159 | "72 4f 3c a8 bc c5 1a 98" | ||
160 | "b7 d4 c9 2e a3 3c d9 34" | ||
161 | "4c a8 b6 3e 04 53 3a bf" | ||
162 | "1a 3c 05 49 16 b3 68 2c" | ||
163 | "5c a8 cb 4d d0 f8 4c 3b" | ||
164 | "77 48 7a ac 6e ce 38 48" | ||
165 | "0b a9 d5 00" | ||
166 | }, | ||
167 | { .d = NULL } | ||
168 | }; | ||
169 | |||
170 | static void | ||
171 | print_bytes_ (void *buf, | ||
172 | size_t buf_len, | ||
173 | int fold, | ||
174 | int in_be) | ||
175 | { | ||
176 | int i; | ||
177 | |||
178 | for (i = 0; i < buf_len; i++) | ||
179 | { | ||
180 | if (0 != i) | ||
181 | { | ||
182 | if ((0 != fold) && (i % fold == 0)) | ||
183 | printf ("\n "); | ||
184 | else | ||
185 | printf (" "); | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | printf (" "); | ||
190 | } | ||
191 | if (in_be) | ||
192 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | ||
193 | else | ||
194 | printf ("%02x", ((unsigned char*) buf)[i]); | ||
195 | } | ||
196 | printf ("\n"); | ||
197 | } | ||
198 | |||
199 | |||
200 | static void | ||
201 | print_bytes (void *buf, | ||
202 | size_t buf_len, | ||
203 | int fold) | ||
204 | { | ||
205 | print_bytes_ (buf, buf_len, fold, 0); | ||
206 | } | ||
207 | |||
208 | |||
209 | int | ||
210 | parsehex (char *src, char *dst, size_t dstlen, int invert) | ||
211 | { | ||
212 | int off; | ||
213 | int read_byte; | ||
214 | int data_len = 0; | ||
215 | char data[strlen (src) + 1]; | ||
216 | char *pos = data; | ||
217 | int i = 0; | ||
218 | int j = 0; | ||
219 | |||
220 | for (i = 0; i < strlen (src); i++) | ||
221 | { | ||
222 | if ((src[i] == ' ') || (src[i] == '\n')) | ||
223 | continue; | ||
224 | data[j++] = src[i]; | ||
225 | } | ||
226 | |||
227 | while (sscanf (pos, " %02x%n", &read_byte, &off) == 1) | ||
228 | { | ||
229 | if (invert) | ||
230 | dst[dstlen - 1 - data_len++] = read_byte; | ||
231 | else | ||
232 | dst[data_len++] = read_byte; | ||
233 | pos += off; | ||
234 | } | ||
235 | return data_len; | ||
236 | } | ||
237 | |||
238 | |||
239 | int | ||
240 | main () | ||
241 | { | ||
242 | struct GNUNET_IDENTITY_PrivateKey priv; | ||
243 | struct GNUNET_IDENTITY_PublicKey pub; | ||
244 | struct GNUNET_IDENTITY_PublicKey pub_parsed; | ||
245 | struct GNUNET_TIME_Relative exprel; | ||
246 | struct GNUNET_REVOCATION_PowP *pow; | ||
247 | char m[8096]; | ||
248 | char ztld[128]; | ||
249 | res = 0; | ||
250 | |||
251 | for (int i = 0; NULL != rtvs[i].d; i++) | ||
252 | { | ||
253 | printf ("Revocation test vector #%d\n", i); | ||
254 | parsehex (rtvs[i].zid,(char*) &pub_parsed, 36, 0); | ||
255 | parsehex (rtvs[i].d,(char*) &priv.ecdsa_key, sizeof (priv.ecdsa_key), | ||
256 | (GNUNET_GNSRECORD_TYPE_PKEY == ntohl (pub_parsed.type)) ? 1 : 0); | ||
257 | priv.type = pub_parsed.type; | ||
258 | GNUNET_IDENTITY_key_get_public (&priv, &pub); | ||
259 | if (0 != memcmp (&pub, &pub_parsed, GNUNET_IDENTITY_public_key_get_length ( | ||
260 | &pub))) | ||
261 | { | ||
262 | printf ("Wrong pubkey.\n"); | ||
263 | print_bytes (&pub, 36, 8); | ||
264 | print_bytes (&pub_parsed, 36, 8); | ||
265 | res = 1; | ||
266 | break; | ||
267 | } | ||
268 | GNUNET_STRINGS_data_to_string (&pub, | ||
269 | GNUNET_IDENTITY_public_key_get_length ( | ||
270 | &pub), | ||
271 | ztld, | ||
272 | sizeof (ztld)); | ||
273 | if (0 != strcmp (ztld, rtvs[i].ztld)) | ||
274 | { | ||
275 | printf ("Wrong zTLD: expected %s, got %s\n", rtvs[i].ztld, ztld); | ||
276 | res = 1; | ||
277 | break; | ||
278 | } | ||
279 | pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); | ||
280 | parsehex (rtvs[i].proof, (char*) pow, 0, 0); | ||
281 | // parsehex (rtvs[i].m, (char*) message, 0, 0); | ||
282 | |||
283 | exprel = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, | ||
284 | rtvs[i].epochs); | ||
285 | if (GNUNET_OK != GNUNET_REVOCATION_check_pow (pow, rtvs[i].diff, | ||
286 | exprel)) | ||
287 | { | ||
288 | printf ("FAIL: Revocation PoW invalid\n"); | ||
289 | res = 1; | ||
290 | break; | ||
291 | } | ||
292 | printf ("Good.\n"); | ||
293 | } | ||
294 | |||
295 | finish: | ||
296 | return res; | ||
297 | } | ||
diff --git a/src/scalarproduct/meson.build b/src/scalarproduct/meson.build new file mode 100644 index 000000000..183f0f784 --- /dev/null +++ b/src/scalarproduct/meson.build | |||
@@ -0,0 +1,102 @@ | |||
1 | libgnunetscalarproduct_src = ['scalarproduct_api.c'] | ||
2 | |||
3 | gnunetservicescalarproducta_src = ['gnunet-service-scalarproduct_alice.c'] | ||
4 | gnunetservicescalarproductb_src = ['gnunet-service-scalarproduct_bob.c'] | ||
5 | gnunetservicescalarproductecca_src = ['gnunet-service-scalarproduct-ecc_alice.c'] | ||
6 | gnunetservicescalarproducteccb_src = ['gnunet-service-scalarproduct-ecc_bob.c'] | ||
7 | |||
8 | configure_file(input : 'scalarproduct.conf.in', | ||
9 | output : 'scalarproduct.conf', | ||
10 | configuration : cdata, | ||
11 | install: true, | ||
12 | install_dir: pkgcfgdir) | ||
13 | |||
14 | |||
15 | if get_option('monolith') | ||
16 | foreach p : libgnunetscalarproduct_src + gnunetservicescalarproduct_src | ||
17 | gnunet_src += 'scalarproduct/' + p | ||
18 | endforeach | ||
19 | subdir_done() | ||
20 | endif | ||
21 | |||
22 | libgnunetscalarproduct = library('gnunetscalarproduct', | ||
23 | libgnunetscalarproduct_src, | ||
24 | soversion: '0', | ||
25 | version: '0.0.0', | ||
26 | dependencies: [libgnunetutil_dep, | ||
27 | gcrypt_dep], | ||
28 | include_directories: [incdir, configuration_inc], | ||
29 | install: true, | ||
30 | install_dir: get_option('libdir')) | ||
31 | pkg.generate(libgnunetscalarproduct, url: 'https://www.gnunet.org', | ||
32 | description : 'Provides API for accessing the scalarproduct service') | ||
33 | libgnunetscalarproduct_dep = declare_dependency(link_with : libgnunetscalarproduct) | ||
34 | |||
35 | executable ('gnunet-scalarproduct', | ||
36 | ['gnunet-scalarproduct.c'], | ||
37 | dependencies: [libgnunetscalarproduct_dep, | ||
38 | libgnunetutil_dep, | ||
39 | gcrypt_dep, | ||
40 | libgnunetstatistics_dep, | ||
41 | libgnunetcore_dep, | ||
42 | libgnunetcadet_dep, | ||
43 | libgnunetblock_dep], | ||
44 | include_directories: [incdir, configuration_inc], | ||
45 | install: true, | ||
46 | install_dir: get_option('bindir')) | ||
47 | |||
48 | executable ('gnunet-service-scalarproduct-alice', | ||
49 | gnunetservicescalarproducta_src, | ||
50 | dependencies: [libgnunetscalarproduct_dep, | ||
51 | libgnunetutil_dep, | ||
52 | gcrypt_dep, | ||
53 | libgnunetseti_dep, | ||
54 | libgnunetstatistics_dep, | ||
55 | libgnunetcore_dep, | ||
56 | libgnunetcadet_dep, | ||
57 | libgnunetblock_dep], | ||
58 | include_directories: [incdir, configuration_inc], | ||
59 | install: true, | ||
60 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
61 | executable ('gnunet-service-scalarproduct-bob', | ||
62 | gnunetservicescalarproductb_src, | ||
63 | dependencies: [libgnunetscalarproduct_dep, | ||
64 | libgnunetutil_dep, | ||
65 | gcrypt_dep, | ||
66 | libgnunetseti_dep, | ||
67 | libgnunetstatistics_dep, | ||
68 | libgnunetcore_dep, | ||
69 | libgnunetcadet_dep, | ||
70 | libgnunetblock_dep], | ||
71 | include_directories: [incdir, configuration_inc], | ||
72 | install: true, | ||
73 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
74 | executable ('gnunet-service-scalarproduct-ecc-alice', | ||
75 | gnunetservicescalarproductecca_src, | ||
76 | dependencies: [libgnunetscalarproduct_dep, | ||
77 | libgnunetutil_dep, | ||
78 | libgnunetstatistics_dep, | ||
79 | libgnunetcore_dep, | ||
80 | gcrypt_dep, | ||
81 | sodium_dep, | ||
82 | libgnunetseti_dep, | ||
83 | libgnunetcadet_dep, | ||
84 | libgnunetblock_dep], | ||
85 | include_directories: [incdir, configuration_inc], | ||
86 | install: true, | ||
87 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
88 | executable ('gnunet-service-scalarproduct-ecc-bob', | ||
89 | gnunetservicescalarproducteccb_src, | ||
90 | dependencies: [libgnunetscalarproduct_dep, | ||
91 | libgnunetutil_dep, | ||
92 | libgnunetstatistics_dep, | ||
93 | libgnunetcore_dep, | ||
94 | gcrypt_dep, | ||
95 | sodium_dep, | ||
96 | libgnunetseti_dep, | ||
97 | libgnunetcadet_dep, | ||
98 | libgnunetblock_dep], | ||
99 | include_directories: [incdir, configuration_inc], | ||
100 | install: true, | ||
101 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
102 | |||
diff --git a/src/secretsharing/meson.build b/src/secretsharing/meson.build new file mode 100644 index 000000000..177cd1bee --- /dev/null +++ b/src/secretsharing/meson.build | |||
@@ -0,0 +1,44 @@ | |||
1 | libgnunetsecretsharing_src = ['secretsharing_api.c', 'secretsharing_common.c'] | ||
2 | |||
3 | gnunetservicesecretsharing_src = ['gnunet-service-secretsharing.c', 'secretsharing_common.c'] | ||
4 | |||
5 | configure_file(input : 'secretsharing.conf.in', | ||
6 | output : 'secretsharing.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | if get_option('monolith') | ||
12 | foreach p : libgnunetsecretsharing_src + gnunetservicesecretsharing_src | ||
13 | gnunet_src += 'secretsharing/' + p | ||
14 | endforeach | ||
15 | endif | ||
16 | |||
17 | libgnunetsecretsharing = library('gnunetsecretsharing', | ||
18 | libgnunetsecretsharing_src, | ||
19 | soversion: '0', | ||
20 | version: '0.0.0', | ||
21 | dependencies: [libgnunetutil_dep, | ||
22 | libgnunetstatistics_dep, | ||
23 | gcrypt_dep, | ||
24 | libgnunetdatacache_dep], | ||
25 | include_directories: [incdir, configuration_inc], | ||
26 | install: true, | ||
27 | install_dir: get_option('libdir')) | ||
28 | libgnunetsecretsharing_dep = declare_dependency(link_with : libgnunetsecretsharing) | ||
29 | pkg.generate(libgnunetsecretsharing, url: 'https://www.gnunet.org', | ||
30 | description : 'Provides API for the secretsharing service') | ||
31 | |||
32 | executable ('gnunet-service-secretsharing', | ||
33 | gnunetservicesecretsharing_src, | ||
34 | dependencies: [libgnunetsecretsharing_dep, | ||
35 | libgnunetutil_dep, | ||
36 | gcrypt_dep, | ||
37 | m_dep, | ||
38 | libgnunetconsensus_dep, | ||
39 | libgnunetstatistics_dep, | ||
40 | libgnunetdatacache_dep], | ||
41 | include_directories: [incdir, configuration_inc], | ||
42 | install: true, | ||
43 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
44 | |||
diff --git a/src/set/meson.build b/src/set/meson.build new file mode 100644 index 000000000..51782f446 --- /dev/null +++ b/src/set/meson.build | |||
@@ -0,0 +1,52 @@ | |||
1 | libgnunetset_src = ['set_api.c'] | ||
2 | |||
3 | gnunetserviceset_src = ['gnunet-service-set.c', | ||
4 | 'gnunet-service-set_union.c', | ||
5 | 'gnunet-service-set_intersection.c', | ||
6 | 'gnunet-service-set_union_strata_estimator.c', | ||
7 | 'ibf.c'] | ||
8 | |||
9 | configure_file(input : 'set.conf.in', | ||
10 | output : 'set.conf', | ||
11 | configuration : cdata, | ||
12 | install: true, | ||
13 | install_dir: pkgcfgdir) | ||
14 | |||
15 | |||
16 | if get_option('monolith') | ||
17 | foreach p : libgnunetset_src + gnunetserviceset_src | ||
18 | gnunet_src += 'set/' + p | ||
19 | endforeach | ||
20 | subdir_done() | ||
21 | endif | ||
22 | |||
23 | libgnunetset = library('gnunetset', | ||
24 | libgnunetset_src, | ||
25 | soversion: '0', | ||
26 | version: '0.0.0', | ||
27 | dependencies: libgnunetutil_dep, | ||
28 | include_directories: [incdir, configuration_inc], | ||
29 | install: true, | ||
30 | install_dir: get_option('libdir')) | ||
31 | pkg.generate(libgnunetset, url: 'https://www.gnunet.org', | ||
32 | description : 'Provides API for accessing the set service') | ||
33 | libgnunetset_dep = declare_dependency(link_with : libgnunetset) | ||
34 | shared_module('gnunet_plugin_block_set_test', | ||
35 | ['plugin_block_set_test.c'], | ||
36 | dependencies: libgnunetutil_dep, | ||
37 | include_directories: [incdir, configuration_inc], | ||
38 | install:true, | ||
39 | install_dir: get_option('libdir')/'gnunet') | ||
40 | executable ('gnunet-service-set', | ||
41 | gnunetserviceset_src, | ||
42 | dependencies: [libgnunetset_dep, | ||
43 | libgnunetutil_dep, | ||
44 | m_dep, | ||
45 | libgnunetstatistics_dep, | ||
46 | libgnunetcore_dep, | ||
47 | libgnunetcadet_dep, | ||
48 | libgnunetblock_dep], | ||
49 | include_directories: [incdir, configuration_inc], | ||
50 | install: true, | ||
51 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
52 | |||
diff --git a/src/seti/meson.build b/src/seti/meson.build new file mode 100644 index 000000000..e5d3812ce --- /dev/null +++ b/src/seti/meson.build | |||
@@ -0,0 +1,48 @@ | |||
1 | libgnunetseti_src = ['seti_api.c'] | ||
2 | |||
3 | gnunetserviceseti_src = ['gnunet-service-seti.c'] | ||
4 | |||
5 | configure_file(input : 'seti.conf.in', | ||
6 | output : 'seti.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetseti_src + gnunetserviceseti_src | ||
14 | gnunet_src += 'seti/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | libgnunetseti = library('gnunetseti', | ||
20 | libgnunetseti_src, | ||
21 | soversion: '0', | ||
22 | version: '0.0.0', | ||
23 | dependencies: libgnunetutil_dep, | ||
24 | include_directories: [incdir, configuration_inc], | ||
25 | install: true, | ||
26 | install_dir: get_option('libdir')) | ||
27 | pkg.generate(libgnunetseti, url: 'https://www.gnunet.org', | ||
28 | description : 'Provides API for accessing the set intersection service') | ||
29 | libgnunetseti_dep = declare_dependency(link_with : libgnunetseti) | ||
30 | shared_module('gnunet_plugin_block_seti_test', | ||
31 | ['plugin_block_seti_test.c'], | ||
32 | dependencies: libgnunetutil_dep, | ||
33 | include_directories: [incdir, configuration_inc], | ||
34 | install:true, | ||
35 | install_dir: get_option('libdir')/'gnunet') | ||
36 | executable ('gnunet-service-seti', | ||
37 | gnunetserviceseti_src, | ||
38 | dependencies: [libgnunetseti_dep, | ||
39 | libgnunetutil_dep, | ||
40 | m_dep, | ||
41 | libgnunetstatistics_dep, | ||
42 | libgnunetcore_dep, | ||
43 | libgnunetcadet_dep, | ||
44 | libgnunetblock_dep], | ||
45 | include_directories: [incdir, configuration_inc], | ||
46 | install: true, | ||
47 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
48 | |||
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c index f85ddb224..46d027cca 100644 --- a/src/setu/gnunet-service-setu.c +++ b/src/setu/gnunet-service-setu.c | |||
@@ -2432,7 +2432,7 @@ handle_union_p2p_strata_estimator (void *cls, | |||
2432 | if (op->byzantine_upper_bound < op->remote_element_count) | 2432 | if (op->byzantine_upper_bound < op->remote_element_count) |
2433 | { | 2433 | { |
2434 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2434 | LOG (GNUNET_ERROR_TYPE_ERROR, |
2435 | "Exceeded configured upper bound <%lu> of element: %u\n", | 2435 | "Exceeded configured upper bound <%"PRIu64"> of element: %u\n", |
2436 | op->byzantine_upper_bound, | 2436 | op->byzantine_upper_bound, |
2437 | op->remote_element_count); | 2437 | op->remote_element_count); |
2438 | fail_union_operation (op); | 2438 | fail_union_operation (op); |
diff --git a/src/setu/meson.build b/src/setu/meson.build new file mode 100644 index 000000000..fe5611fd2 --- /dev/null +++ b/src/setu/meson.build | |||
@@ -0,0 +1,50 @@ | |||
1 | libgnunetsetu_src = ['setu_api.c'] | ||
2 | |||
3 | gnunetservicesetu_src = ['gnunet-service-setu.c', | ||
4 | 'ibf.c', | ||
5 | 'gnunet-service-setu_strata_estimator.c'] | ||
6 | |||
7 | configure_file(input : 'setu.conf.in', | ||
8 | output : 'setu.conf', | ||
9 | configuration : cdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetsetu_src + gnunetservicesetu_src | ||
16 | gnunet_src += 'setu/' + p | ||
17 | endforeach | ||
18 | subdir_done() | ||
19 | endif | ||
20 | |||
21 | libgnunetsetu = library('gnunetsetu', | ||
22 | libgnunetsetu_src, | ||
23 | soversion: '0', | ||
24 | version: '0.0.0', | ||
25 | dependencies: libgnunetutil_dep, | ||
26 | include_directories: [incdir, configuration_inc], | ||
27 | install: true, | ||
28 | install_dir: get_option('libdir')) | ||
29 | pkg.generate(libgnunetsetu, url: 'https://www.gnunet.org', | ||
30 | description : 'Provides API for accessing the set union service') | ||
31 | libgnunetsetu_dep = declare_dependency(link_with : libgnunetsetu) | ||
32 | shared_module('gnunet_plugin_block_setu_test', | ||
33 | ['plugin_block_setu_test.c'], | ||
34 | dependencies: libgnunetutil_dep, | ||
35 | include_directories: [incdir, configuration_inc], | ||
36 | install:true, | ||
37 | install_dir: get_option('libdir')/'gnunet') | ||
38 | executable ('gnunet-service-setu', | ||
39 | gnunetservicesetu_src, | ||
40 | dependencies: [libgnunetsetu_dep, | ||
41 | libgnunetutil_dep, | ||
42 | m_dep, | ||
43 | libgnunetstatistics_dep, | ||
44 | libgnunetcore_dep, | ||
45 | libgnunetcadet_dep, | ||
46 | libgnunetblock_dep], | ||
47 | include_directories: [incdir, configuration_inc], | ||
48 | install: true, | ||
49 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
50 | |||
diff --git a/src/sq/meson.build b/src/sq/meson.build new file mode 100644 index 000000000..482d1c40a --- /dev/null +++ b/src/sq/meson.build | |||
@@ -0,0 +1,25 @@ | |||
1 | libgnunetsq_src = ['sq.c', | ||
2 | 'sq_exec.c', | ||
3 | 'sq_prepare.c', | ||
4 | 'sq_query_helper.c', | ||
5 | 'sq_result_helper.c'] | ||
6 | |||
7 | if get_option('monolith') | ||
8 | foreach p : libgnunetsq_src | ||
9 | gnunet_src += 'sq/' + p | ||
10 | endforeach | ||
11 | subdir_done() | ||
12 | endif | ||
13 | |||
14 | libgnunetsq = library('gnunetsq', | ||
15 | libgnunetsq_src, | ||
16 | soversion: '0', | ||
17 | version: '0.0.0', | ||
18 | dependencies: [libgnunetutil_dep, sqlite_dep], | ||
19 | include_directories: [incdir, configuration_inc], | ||
20 | install: true, | ||
21 | install_dir: get_option('libdir')) | ||
22 | pkg.generate(libgnunetsq, url: 'https://www.gnunet.org', | ||
23 | description : 'Provides API for accessing the SQ service') | ||
24 | libgnunetsq_dep = declare_dependency(link_with : libgnunetsq) | ||
25 | |||
diff --git a/src/sq/sq.c b/src/sq/sq.c index 777fb6311..557ec2771 100644 --- a/src/sq/sq.c +++ b/src/sq/sq.c | |||
@@ -22,11 +22,12 @@ | |||
22 | * @brief helper functions for Sqlite3 DB interactions | 22 | * @brief helper functions for Sqlite3 DB interactions |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "gnunet_common.h" | ||
25 | #include "platform.h" | 26 | #include "platform.h" |
26 | #include "gnunet_sq_lib.h" | 27 | #include "gnunet_sq_lib.h" |
27 | 28 | ||
28 | 29 | ||
29 | int | 30 | enum GNUNET_GenericReturnValue |
30 | GNUNET_SQ_bind (sqlite3_stmt *stmt, | 31 | GNUNET_SQ_bind (sqlite3_stmt *stmt, |
31 | const struct GNUNET_SQ_QueryParam *params) | 32 | const struct GNUNET_SQ_QueryParam *params) |
32 | { | 33 | { |
@@ -71,7 +72,7 @@ GNUNET_SQ_bind (sqlite3_stmt *stmt, | |||
71 | * #GNUNET_OK if all results could be extracted | 72 | * #GNUNET_OK if all results could be extracted |
72 | * #GNUNET_SYSERR if a result was invalid (non-existing field) | 73 | * #GNUNET_SYSERR if a result was invalid (non-existing field) |
73 | */ | 74 | */ |
74 | int | 75 | enum GNUNET_GenericReturnValue |
75 | GNUNET_SQ_extract_result (sqlite3_stmt *result, | 76 | GNUNET_SQ_extract_result (sqlite3_stmt *result, |
76 | struct GNUNET_SQ_ResultSpec *rs) | 77 | struct GNUNET_SQ_ResultSpec *rs) |
77 | { | 78 | { |
diff --git a/src/sq/sq_exec.c b/src/sq/sq_exec.c index 8c47c22b4..d4690ee99 100644 --- a/src/sq/sq_exec.c +++ b/src/sq/sq_exec.c | |||
@@ -72,7 +72,7 @@ GNUNET_SQ_make_try_execute (const char *sql) | |||
72 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) | 72 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) |
73 | * #GNUNET_SYSERR on error | 73 | * #GNUNET_SYSERR on error |
74 | */ | 74 | */ |
75 | int | 75 | enum GNUNET_GenericReturnValue |
76 | GNUNET_SQ_exec_statements (sqlite3 *dbh, | 76 | GNUNET_SQ_exec_statements (sqlite3 *dbh, |
77 | const struct GNUNET_SQ_ExecuteStatement *es) | 77 | const struct GNUNET_SQ_ExecuteStatement *es) |
78 | { | 78 | { |
diff --git a/src/sq/sq_prepare.c b/src/sq/sq_prepare.c index b3825ee71..1df564bfb 100644 --- a/src/sq/sq_prepare.c +++ b/src/sq/sq_prepare.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * @brief helper functions for executing SQL statements | 22 | * @brief helper functions for executing SQL statements |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "gnunet_common.h" | ||
25 | #include "platform.h" | 26 | #include "platform.h" |
26 | #include "gnunet_sq_lib.h" | 27 | #include "gnunet_sq_lib.h" |
27 | 28 | ||
@@ -46,7 +47,7 @@ GNUNET_SQ_make_prepare (const char *sql, | |||
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | int | 50 | enum GNUNET_GenericReturnValue |
50 | GNUNET_SQ_prepare (sqlite3 *dbh, | 51 | GNUNET_SQ_prepare (sqlite3 *dbh, |
51 | const struct GNUNET_SQ_PrepareStatement *ps) | 52 | const struct GNUNET_SQ_PrepareStatement *ps) |
52 | { | 53 | { |
diff --git a/src/statistics/meson.build b/src/statistics/meson.build new file mode 100644 index 000000000..14cdb0ac3 --- /dev/null +++ b/src/statistics/meson.build | |||
@@ -0,0 +1,44 @@ | |||
1 | libgnunetstatistics_src = ['statistics_api.c'] | ||
2 | |||
3 | gnunetservicestatistics_src = ['gnunet-service-statistics.c'] | ||
4 | |||
5 | configure_file(input : 'statistics.conf.in', | ||
6 | output : 'statistics.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetstatistics_src + gnunetservicestatistics_src | ||
14 | gnunet_src += 'statistics/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | libgnunetstatistics = library('gnunetstatistics', | ||
20 | libgnunetstatistics_src, | ||
21 | soversion: '2', | ||
22 | version: '2.0.0', | ||
23 | dependencies: libgnunetutil_dep, | ||
24 | include_directories: [incdir, configuration_inc], | ||
25 | install: true, | ||
26 | install_dir: get_option('libdir')) | ||
27 | libgnunetstatistics_dep = declare_dependency(link_with : libgnunetstatistics) | ||
28 | pkg.generate(libgnunetstatistics, url: 'https://www.gnunet.org', | ||
29 | description : 'Provides API of GNUnet statistics service') | ||
30 | |||
31 | executable ('gnunet-service-statistics', | ||
32 | gnunetservicestatistics_src, | ||
33 | dependencies: [libgnunetstatistics_dep, libgnunetutil_dep], | ||
34 | include_directories: [incdir, configuration_inc], | ||
35 | install: true, | ||
36 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
37 | executable ('gnunet-statistics', | ||
38 | ['gnunet-statistics.c'], | ||
39 | dependencies: [libgnunetstatistics_dep, libgnunetutil_dep], | ||
40 | include_directories: [incdir, configuration_inc], | ||
41 | install: true, | ||
42 | install_dir: get_option('bindir')) | ||
43 | |||
44 | |||
diff --git a/src/testbed-logger/meson.build b/src/testbed-logger/meson.build new file mode 100644 index 000000000..a534aa2a7 --- /dev/null +++ b/src/testbed-logger/meson.build | |||
@@ -0,0 +1,34 @@ | |||
1 | libgnunettestbedlogger_src = ['testbed_logger_api.c'] | ||
2 | |||
3 | tdata = configuration_data() | ||
4 | tdata.merge_from(cdata) | ||
5 | tdata.set_quoted('prefix', get_option('prefix')) | ||
6 | |||
7 | configure_file(input : 'testbed-logger.conf.in', | ||
8 | output : 'testbed-logger.conf', | ||
9 | configuration : tdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | |||
14 | if get_option('monolith') | ||
15 | subdir_done() | ||
16 | endif | ||
17 | |||
18 | libgnunettestbedlogger = library('gnunettestbedlogger', | ||
19 | libgnunettestbedlogger_src, | ||
20 | soversion: '0', | ||
21 | version: '0.0.0', | ||
22 | dependencies: [libgnunetutil_dep], | ||
23 | include_directories: [incdir, configuration_inc], | ||
24 | install: true, | ||
25 | install_dir: get_option('libdir')) | ||
26 | libgnunettestbedlogger_dep = declare_dependency(link_with : libgnunettestbedlogger) | ||
27 | |||
28 | |||
29 | executable ('gnunet-service-testbed-logger', | ||
30 | ['gnunet-service-testbed-logger.c'], | ||
31 | dependencies: [libgnunetutil_dep], | ||
32 | include_directories: [incdir, configuration_inc], | ||
33 | install:true, | ||
34 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
diff --git a/src/testbed/meson.build b/src/testbed/meson.build new file mode 100644 index 000000000..9d254d54a --- /dev/null +++ b/src/testbed/meson.build | |||
@@ -0,0 +1,127 @@ | |||
1 | libgnunettestbed_src = [ | ||
2 | 'testbed_api.c', | ||
3 | 'testbed_api_hosts.c', | ||
4 | 'testbed_api_operations.c', | ||
5 | 'testbed_api_peers.c', | ||
6 | 'testbed_api_services.c', | ||
7 | 'testbed_api_statistics.c', | ||
8 | 'testbed_api_testbed.c', | ||
9 | 'testbed_api_test.c', | ||
10 | 'testbed_api_topology.c', | ||
11 | 'testbed_api_sd.c', | ||
12 | 'testbed_api_barriers.c' | ||
13 | ] | ||
14 | |||
15 | tdata = configuration_data() | ||
16 | tdata.merge_from(cdata) | ||
17 | tdata.set_quoted('prefix', get_option('prefix')) | ||
18 | |||
19 | configure_file(input : 'testbed.conf.in', | ||
20 | output : 'testbed.conf', | ||
21 | configuration : tdata, | ||
22 | install: true, | ||
23 | install_dir: pkgcfgdir) | ||
24 | |||
25 | |||
26 | if get_option('monolith') | ||
27 | subdir_done() | ||
28 | endif | ||
29 | |||
30 | libgnunettestbed = library('gnunettestbed', | ||
31 | libgnunettestbed_src, | ||
32 | soversion: '0', | ||
33 | version: '0.0.0', | ||
34 | dependencies: [libgnunetutil_dep, | ||
35 | m_dep, | ||
36 | zlib_dep, | ||
37 | libgnunetstatistics_dep, | ||
38 | libgnunethello_dep, | ||
39 | libgnunettesting_dep, | ||
40 | libgnunettransport_dep, | ||
41 | libgnunetarm_dep], | ||
42 | include_directories: [incdir, configuration_inc], | ||
43 | install: true, | ||
44 | install_dir: get_option('libdir')) | ||
45 | libgnunettestbed_dep = declare_dependency(link_with : libgnunettestbed) | ||
46 | pkg.generate(libgnunettestbed, url: 'https://www.gnunet.org', | ||
47 | description : 'Provides API for testbed') | ||
48 | |||
49 | |||
50 | executable ('gnunet-helper-testbed', | ||
51 | ['gnunet-helper-testbed.c'], | ||
52 | dependencies: [libgnunetutil_dep, | ||
53 | libgnunetcore_dep, | ||
54 | libgnunethello_dep, | ||
55 | libgnunetpeerinfo_dep, | ||
56 | libgnunetstatistics_dep, | ||
57 | libgnunettestbed_dep, | ||
58 | libgnunettesting_dep, | ||
59 | libgnunettransport_dep, | ||
60 | zlib_dep], | ||
61 | include_directories: [incdir, configuration_inc], | ||
62 | install:true, | ||
63 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
64 | executable ('gnunet-daemon-testbed-blacklist', | ||
65 | ['gnunet-daemon-testbed-blacklist.c'], | ||
66 | dependencies: [libgnunetutil_dep, | ||
67 | libgnunetcore_dep, | ||
68 | libgnunethello_dep, | ||
69 | libgnunetpeerinfo_dep, | ||
70 | libgnunetstatistics_dep, | ||
71 | libgnunettransport_dep], | ||
72 | include_directories: [incdir, configuration_inc], | ||
73 | install:true, | ||
74 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
75 | |||
76 | executable ('gnunet-daemon-testbed-underlay', | ||
77 | ['gnunet-daemon-testbed-underlay.c'], | ||
78 | dependencies: [libgnunetutil_dep, | ||
79 | libgnunetcore_dep, | ||
80 | libgnunethello_dep, | ||
81 | libgnunetpeerinfo_dep, | ||
82 | libgnunetstatistics_dep, | ||
83 | libgnunettransport_dep, | ||
84 | sqlite_dep], | ||
85 | include_directories: [incdir, configuration_inc], | ||
86 | install:true, | ||
87 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
88 | |||
89 | executable ('gnunet-testbed-profiler', | ||
90 | ['gnunet-testbed-profiler.c'], | ||
91 | dependencies: [libgnunetutil_dep, | ||
92 | libgnunetats_dep, | ||
93 | libgnunettestbed_dep], | ||
94 | include_directories: [incdir, configuration_inc], | ||
95 | install:true, | ||
96 | install_dir: get_option('bindir')) | ||
97 | executable ('gnunet-service-testbed', | ||
98 | ['gnunet-service-testbed.c', | ||
99 | 'gnunet-service-testbed_links.c', | ||
100 | 'gnunet-service-testbed_peers.c', | ||
101 | 'gnunet-service-testbed_cache.c', | ||
102 | 'gnunet-service-testbed_oc.c', | ||
103 | 'gnunet-service-testbed_cpustatus.c', | ||
104 | 'gnunet-service-testbed_meminfo.c', | ||
105 | 'gnunet-service-testbed_barriers.c', | ||
106 | 'gnunet-service-testbed_connectionpool.c'], | ||
107 | dependencies: [libgnunetutil_dep, | ||
108 | libgnunetcore_dep, | ||
109 | libgnunetats_dep, | ||
110 | libgnunetarm_dep, | ||
111 | libgnunethello_dep, | ||
112 | libgnunettestbed_dep, | ||
113 | libgnunettesting_dep, | ||
114 | libgnunettransport_dep, | ||
115 | zlib_dep], | ||
116 | include_directories: [incdir, configuration_inc], | ||
117 | install:true, | ||
118 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
119 | |||
120 | executable ('gnunet-daemon-latency-logger', | ||
121 | ['gnunet-daemon-latency-logger.c'], | ||
122 | dependencies: [libgnunetutil_dep, | ||
123 | libgnunetats_dep, | ||
124 | sqlite_dep], | ||
125 | include_directories: [incdir, configuration_inc], | ||
126 | install:true, | ||
127 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index e0b63f05e..0c55b8aea 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -35,7 +35,6 @@ libgnunettesting_la_SOURCES = \ | |||
35 | testing_api_cmd_exec_bash_script.c \ | 35 | testing_api_cmd_exec_bash_script.c \ |
36 | testing_api_cmd_barrier.c \ | 36 | testing_api_cmd_barrier.c \ |
37 | testing_api_cmd_barrier_reached.c \ | 37 | testing_api_cmd_barrier_reached.c \ |
38 | testing_api_cmd_end.c \ | ||
39 | testing_api_cmd_finish.c \ | 38 | testing_api_cmd_finish.c \ |
40 | testing_api_cmd_local_test_prepared.c \ | 39 | testing_api_cmd_local_test_prepared.c \ |
41 | testing_api_cmd_send_peer_ready.c \ | 40 | testing_api_cmd_send_peer_ready.c \ |
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index de50aca3a..4428d4402 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -69,8 +69,8 @@ | |||
69 | * if the start script was not started from within a new namespace | 69 | * if the start script was not started from within a new namespace |
70 | * created by unshare. The UPNP test case needs public IP | 70 | * created by unshare. The UPNP test case needs public IP |
71 | * addresse for miniupnpd to function. | 71 | * addresse for miniupnpd to function. |
72 | * FIXME We should introduce a switch indicating if public | 72 | * FIXME We should introduce a switch indicating if public |
73 | * addresses should be used or not. This info has to be | 73 | * addresses should be used or not. This info has to be |
74 | * propagated from the start script to the c code. | 74 | * propagated from the start script to the c code. |
75 | #define KNOWN_BASE_IP "172.16.151." | 75 | #define KNOWN_BASE_IP "172.16.151." |
76 | 76 | ||
@@ -276,7 +276,8 @@ write_task (void *cls) | |||
276 | * | 276 | * |
277 | */ | 277 | */ |
278 | static void | 278 | static void |
279 | write_message (struct GNUNET_MessageHeader *message, size_t msg_length) | 279 | write_message (struct GNUNET_MessageHeader *message, |
280 | size_t msg_length) | ||
280 | { | 281 | { |
281 | struct WriteContext *wc; | 282 | struct WriteContext *wc; |
282 | 283 | ||
@@ -292,6 +293,7 @@ write_message (struct GNUNET_MessageHeader *message, size_t msg_length) | |||
292 | wc); | 293 | wc); |
293 | } | 294 | } |
294 | 295 | ||
296 | |||
295 | static void | 297 | static void |
296 | delay_shutdown_cb () | 298 | delay_shutdown_cb () |
297 | { | 299 | { |
@@ -333,11 +335,11 @@ finished_cb (enum GNUNET_GenericReturnValue rv) | |||
333 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | 335 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); |
334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
335 | "message send\n"); | 337 | "message send\n"); |
336 | 338 | // FIXME: bad hack, do not write 1s, have continuation after write_message() is done! | |
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
338 | "delaying shutdown\n"); | 340 | "delaying shutdown\n"); |
339 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 341 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
340 | delay_shutdown_cb, | 342 | &delay_shutdown_cb, |
341 | NULL); | 343 | NULL); |
342 | } | 344 | } |
343 | 345 | ||
@@ -354,10 +356,10 @@ finished_cb (enum GNUNET_GenericReturnValue rv) | |||
354 | * #GNUNET_NO to stop further processing (no error) | 356 | * #GNUNET_NO to stop further processing (no error) |
355 | * #GNUNET_SYSERR to stop further processing with error | 357 | * #GNUNET_SYSERR to stop further processing with error |
356 | */ | 358 | */ |
357 | static int | 359 | static enum GNUNET_GenericReturnValue |
358 | tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | 360 | tokenizer_cb (void *cls, |
361 | const struct GNUNET_MessageHeader *message) | ||
359 | { | 362 | { |
360 | |||
361 | struct NodeIdentifier *ni = cls; | 363 | struct NodeIdentifier *ni = cls; |
362 | const struct GNUNET_TESTING_CommandHelperInit *msg; | 364 | const struct GNUNET_TESTING_CommandHelperInit *msg; |
363 | struct GNUNET_TESTING_CommandHelperReply *reply; | 365 | struct GNUNET_TESTING_CommandHelperReply *reply; |
@@ -377,114 +379,130 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
377 | "Received message type %u and size %u\n", | 379 | "Received message type %u and size %u\n", |
378 | type, | 380 | type, |
379 | msize); | 381 | msize); |
380 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) | 382 | switch (type) |
381 | { | 383 | { |
382 | msg = (const struct GNUNET_TESTING_CommandHelperInit *) message; | 384 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT: |
383 | plugin_name_size = ntohs (msg->plugin_name_size); | ||
384 | if ((sizeof(struct GNUNET_TESTING_CommandHelperInit) + plugin_name_size) > msize) | ||
385 | { | 385 | { |
386 | GNUNET_break (0); | 386 | msg = (const struct GNUNET_TESTING_CommandHelperInit *) message; |
387 | LOG (GNUNET_ERROR_TYPE_WARNING, | 387 | plugin_name_size = ntohs (msg->plugin_name_size); |
388 | "Received unexpected message -- exiting\n"); | 388 | if ((sizeof(struct GNUNET_TESTING_CommandHelperInit) + plugin_name_size) > |
389 | goto error; | 389 | msize) |
390 | { | ||
391 | GNUNET_break (0); | ||
392 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
393 | "Received unexpected message -- exiting\n"); | ||
394 | goto error; | ||
395 | } | ||
396 | plugin_name = GNUNET_malloc (plugin_name_size + 1); | ||
397 | GNUNET_strlcpy (plugin_name, | ||
398 | ((char *) &msg[1]), | ||
399 | plugin_name_size + 1); | ||
400 | |||
401 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-cmd"); | ||
402 | |||
403 | plugin = GNUNET_new (struct TestcasePlugin); | ||
404 | plugin->api = GNUNET_PLUGIN_load (plugin_name, | ||
405 | NULL); | ||
406 | plugin->library_name = GNUNET_strdup (basename (plugin_name)); | ||
407 | |||
408 | plugin->global_n = ni->global_n; | ||
409 | plugin->local_m = ni->local_m; | ||
410 | plugin->n = ni->n; | ||
411 | plugin->m = ni->m; | ||
412 | |||
413 | GNUNET_asprintf (&router_ip, | ||
414 | ROUTER_BASE_IP "%s", | ||
415 | plugin->n); | ||
416 | { | ||
417 | char dummy; | ||
418 | |||
419 | if (1 != | ||
420 | sscanf (plugin->n, | ||
421 | "%u%c", | ||
422 | &namespace_n, | ||
423 | &dummy)) | ||
424 | { | ||
425 | // FIXME: how to handle error nicely? | ||
426 | GNUNET_break (0); | ||
427 | namespace_n = 0; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | if (0 == namespace_n) | ||
432 | { | ||
433 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
434 | "known node n: %s\n", | ||
435 | plugin->n); | ||
436 | GNUNET_asprintf (&node_ip, | ||
437 | KNOWN_BASE_IP "%s", | ||
438 | plugin->m); | ||
439 | } | ||
440 | else | ||
441 | { | ||
442 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
443 | "subnet node n: %s\n", | ||
444 | plugin->n); | ||
445 | GNUNET_asprintf (&node_ip, | ||
446 | NODE_BASE_IP "%s", | ||
447 | plugin->m); | ||
448 | } | ||
449 | |||
450 | is = plugin->api->start_testcase (&write_message, | ||
451 | router_ip, | ||
452 | node_ip, | ||
453 | plugin->m, | ||
454 | plugin->n, | ||
455 | plugin->local_m, | ||
456 | ni->topology_data, | ||
457 | ni->read_file, | ||
458 | &finished_cb); | ||
459 | GNUNET_free (node_ip); | ||
460 | GNUNET_free (binary); | ||
461 | GNUNET_free (router_ip); | ||
462 | GNUNET_free (plugin_name); | ||
463 | |||
464 | msg_length = sizeof(struct GNUNET_TESTING_CommandHelperReply); | ||
465 | reply = GNUNET_new (struct GNUNET_TESTING_CommandHelperReply); | ||
466 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); | ||
467 | reply->header.size = htons ((uint16_t) msg_length); | ||
468 | write_message (&reply->header, | ||
469 | msg_length); | ||
470 | return GNUNET_OK; | ||
390 | } | 471 | } |
391 | plugin_name = GNUNET_malloc (plugin_name_size + 1); | 472 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE: |
392 | GNUNET_strlcpy (plugin_name, | ||
393 | ((char *) &msg[1]), | ||
394 | plugin_name_size + 1); | ||
395 | |||
396 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-cmd"); | ||
397 | |||
398 | plugin = GNUNET_new (struct TestcasePlugin); | ||
399 | plugin->api = GNUNET_PLUGIN_load (plugin_name, | ||
400 | NULL); | ||
401 | plugin->library_name = GNUNET_strdup (basename (plugin_name)); | ||
402 | |||
403 | plugin->global_n = ni->global_n; | ||
404 | plugin->local_m = ni->local_m; | ||
405 | plugin->n = ni->n; | ||
406 | plugin->m = ni->m; | ||
407 | |||
408 | router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->n) | ||
409 | + 1); | ||
410 | strcpy (router_ip, ROUTER_BASE_IP); | ||
411 | strcat (router_ip, plugin->n); | ||
412 | |||
413 | sscanf (plugin->n, "%u", &namespace_n); | ||
414 | |||
415 | if (0 == namespace_n) | ||
416 | { | 473 | { |
417 | LOG (GNUNET_ERROR_TYPE_ERROR, | 474 | const char *barrier_name; |
418 | "known node n: %s\n", | 475 | struct CommandBarrierCrossable *adm = (struct |
419 | plugin->n); | 476 | CommandBarrierCrossable *) message; |
420 | node_ip = GNUNET_malloc (strlen (KNOWN_BASE_IP) + strlen (plugin->m) + 1); | 477 | |
421 | strcat (node_ip, KNOWN_BASE_IP); | 478 | barrier_name = (const char *) &adm[1]; |
479 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
480 | "cross barrier %s\n", | ||
481 | barrier_name); | ||
482 | TST_interpreter_finish_attached_cmds (is, | ||
483 | barrier_name); | ||
484 | return GNUNET_OK; | ||
422 | } | 485 | } |
423 | else | 486 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED: |
424 | { | 487 | { |
425 | LOG (GNUNET_ERROR_TYPE_ERROR, | 488 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
426 | "subnet node n: %s\n", | 489 | "all peers started\n"); |
427 | plugin->n); | 490 | plugin->api->all_peers_started (); |
428 | node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->m) + 1); | 491 | return GNUNET_OK; |
429 | strcat (node_ip, NODE_BASE_IP); | ||
430 | } | 492 | } |
431 | strcat (node_ip, plugin->m); | 493 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED: |
432 | 494 | { | |
433 | is = plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, | 495 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
434 | 496 | "all local tests prepared\n"); | |
435 | plugin->n, plugin->local_m, ni->topology_data, | 497 | plugin->api->all_local_tests_prepared (); |
436 | ni->read_file, &finished_cb); | 498 | return GNUNET_OK; |
437 | GNUNET_free (node_ip); | 499 | } |
438 | GNUNET_free (binary); | 500 | default: |
439 | GNUNET_free (router_ip); | ||
440 | GNUNET_free (plugin_name); | ||
441 | |||
442 | msg_length = sizeof(struct GNUNET_TESTING_CommandHelperReply); | ||
443 | reply = GNUNET_new (struct GNUNET_TESTING_CommandHelperReply); | ||
444 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); | ||
445 | reply->header.size = htons ((uint16_t) msg_length); | ||
446 | |||
447 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | ||
448 | |||
449 | return GNUNET_OK; | ||
450 | } | ||
451 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE == ntohs ( | ||
452 | message->type)) | ||
453 | { | ||
454 | const char *barrier_name; | ||
455 | struct CommandBarrierCrossable *adm = (struct CommandBarrierCrossable *) message; | ||
456 | |||
457 | barrier_name = (const char *) &adm[1]; | ||
458 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
459 | "cross barrier %s\n", | ||
460 | barrier_name); | ||
461 | TST_interpreter_finish_attached_cmds (is, barrier_name); | ||
462 | return GNUNET_OK; | ||
463 | } | ||
464 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( | ||
465 | message->type)) | ||
466 | { | ||
467 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
468 | "all peers started\n"); | ||
469 | plugin->api->all_peers_started (); | ||
470 | return GNUNET_OK; | ||
471 | } | ||
472 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED == ntohs ( | ||
473 | message->type)) | ||
474 | { | ||
475 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
476 | "all local tests prepared\n"); | ||
477 | plugin->api->all_local_tests_prepared (); | ||
478 | return GNUNET_OK; | ||
479 | } | ||
480 | else | ||
481 | { | ||
482 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 501 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
483 | goto error; | 502 | goto error; |
484 | } | 503 | } |
485 | 504 | ||
486 | 505 | error: | |
487 | error: | ||
488 | status = GNUNET_SYSERR; | 506 | status = GNUNET_SYSERR; |
489 | LOG (GNUNET_ERROR_TYPE_ERROR, | 507 | LOG (GNUNET_ERROR_TYPE_ERROR, |
490 | "tokenizer shutting down!\n"); | 508 | "tokenizer shutting down!\n"); |
@@ -560,14 +578,16 @@ run (void *cls, | |||
560 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 578 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
561 | "Starting interpreter loop helper...\n"); | 579 | "Starting interpreter loop helper...\n"); |
562 | 580 | ||
563 | tokenizer = GNUNET_MST_create (&tokenizer_cb, ni); | 581 | tokenizer = GNUNET_MST_create (&tokenizer_cb, |
582 | ni); | ||
564 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); | 583 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); |
565 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); | 584 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); |
566 | read_task_id = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 585 | read_task_id = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
567 | stdin_fd, | 586 | stdin_fd, |
568 | &read_task, | 587 | &read_task, |
569 | NULL); | 588 | NULL); |
570 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 589 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
590 | NULL); | ||
571 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 591 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
572 | "Interpreter loop helper started.\n"); | 592 | "Interpreter loop helper started.\n"); |
573 | } | 593 | } |
@@ -605,8 +625,9 @@ main (int argc, char **argv) | |||
605 | { | 625 | { |
606 | struct NodeIdentifier *ni; | 626 | struct NodeIdentifier *ni; |
607 | struct GNUNET_SIGNAL_Context *shc_chld; | 627 | struct GNUNET_SIGNAL_Context *shc_chld; |
608 | struct GNUNET_GETOPT_CommandLineOption options[] = | 628 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
609 | { GNUNET_GETOPT_OPTION_END }; | 629 | GNUNET_GETOPT_OPTION_END |
630 | }; | ||
610 | int ret; | 631 | int ret; |
611 | unsigned int sscanf_ret; | 632 | unsigned int sscanf_ret; |
612 | int i; | 633 | int i; |
@@ -667,8 +688,8 @@ main (int argc, char **argv) | |||
667 | return 1; | 688 | return 1; |
668 | } | 689 | } |
669 | shc_chld = | 690 | shc_chld = |
670 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | 691 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, |
671 | 692 | &sighandler_child_death); | |
672 | ret = GNUNET_PROGRAM_run (argc, | 693 | ret = GNUNET_PROGRAM_run (argc, |
673 | argv, | 694 | argv, |
674 | "gnunet-cmds-helper", | 695 | "gnunet-cmds-helper", |
diff --git a/src/testing/meson.build b/src/testing/meson.build new file mode 100644 index 000000000..c591ae849 --- /dev/null +++ b/src/testing/meson.build | |||
@@ -0,0 +1,68 @@ | |||
1 | libgnunettesting_src = [ | ||
2 | 'testing_api_cmd_barrier.c', | ||
3 | 'testing_api_cmd_barrier_reached.c', | ||
4 | 'testing_api_cmd_finish.c', | ||
5 | 'testing_api_cmd_local_test_prepared.c', | ||
6 | 'testing_api_cmd_send_peer_ready.c', | ||
7 | 'testing_api_cmd_block_until_external_trigger.c', | ||
8 | 'testing_api_cmd_netjail_start.c', | ||
9 | 'testing_api_cmd_netjail_start_cmds_helper.c', | ||
10 | 'testing_api_cmd_netjail_stop_cmds_helper.c', | ||
11 | 'testing_api_cmd_netjail_stop.c', | ||
12 | 'testing.c', | ||
13 | 'testing_api_cmd_system_create.c', | ||
14 | 'testing_api_cmd_system_destroy.c', | ||
15 | 'testing_api_cmd_batch.c', | ||
16 | 'testing_api_loop.c', | ||
17 | 'testing_api_traits.c' | ||
18 | ] | ||
19 | |||
20 | gnunettesting_src = ['gnunet-testing.c'] | ||
21 | gnunetservicetesting_src = ['gnunet-service-testing.c'] | ||
22 | |||
23 | configure_file(input : 'testing.conf', | ||
24 | output : 'testing.conf', | ||
25 | configuration : cdata, | ||
26 | install: true, | ||
27 | install_dir: pkgcfgdir) | ||
28 | |||
29 | |||
30 | if get_option('monolith') | ||
31 | foreach p : libgnunettesting_src | ||
32 | gnunet_src += 'testing/' + p | ||
33 | endforeach | ||
34 | subdir_done() | ||
35 | endif | ||
36 | |||
37 | libgnunettesting = library('gnunettesting', | ||
38 | libgnunettesting_src, | ||
39 | soversion: '1', | ||
40 | version: '1.1.0', | ||
41 | dependencies: [libgnunetutil_dep, | ||
42 | m_dep, | ||
43 | libgnunetarm_dep], | ||
44 | include_directories: [incdir, configuration_inc], | ||
45 | install: true, | ||
46 | install_dir: get_option('libdir')) | ||
47 | libgnunettesting_dep = declare_dependency(link_with : libgnunettesting) | ||
48 | pkg.generate(libgnunettesting, url: 'https://www.gnunet.org', | ||
49 | description : 'Provides API for gnunet testing') | ||
50 | |||
51 | executable ('gnunet-testing', | ||
52 | gnunettesting_src, | ||
53 | dependencies: [libgnunettesting_dep, | ||
54 | libgnunetutil_dep, | ||
55 | ], | ||
56 | include_directories: [incdir, configuration_inc], | ||
57 | install: true, | ||
58 | install_dir: get_option('bindir')) | ||
59 | |||
60 | executable ('gnunet-cmds-helper', | ||
61 | ['gnunet-cmds-helper.c'], | ||
62 | dependencies: [libgnunettesting_dep, | ||
63 | libgnunetutil_dep, | ||
64 | ], | ||
65 | include_directories: [incdir, configuration_inc], | ||
66 | install: true, | ||
67 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
68 | |||
diff --git a/src/testing/testing.c b/src/testing/testing.c index e360d7083..fdfa80d87 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -272,7 +272,7 @@ struct GNUNET_TESTING_Peer | |||
272 | * @param system the testing system handle | 272 | * @param system the testing system handle |
273 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error | 273 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error |
274 | */ | 274 | */ |
275 | static int | 275 | static enum GNUNET_GenericReturnValue |
276 | hostkeys_load (struct GNUNET_TESTING_System *system) | 276 | hostkeys_load (struct GNUNET_TESTING_System *system) |
277 | { | 277 | { |
278 | uint64_t fs; | 278 | uint64_t fs; |
@@ -505,7 +505,7 @@ cleanup_shared_service_instance (struct SharedServiceInstance *i) | |||
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | static int | 508 | static enum GNUNET_GenericReturnValue |
509 | start_shared_service_instance (struct SharedServiceInstance *i) | 509 | start_shared_service_instance (struct SharedServiceInstance *i) |
510 | { | 510 | { |
511 | char *binary; | 511 | char *binary; |
@@ -1722,39 +1722,6 @@ GNUNET_TESTING_service_run (const char *testdir, | |||
1722 | 1722 | ||
1723 | 1723 | ||
1724 | /** | 1724 | /** |
1725 | * Sometimes we use the binary name to determine which specific | ||
1726 | * test to run. In those cases, the string after the last "_" | ||
1727 | * in 'argv[0]' specifies a string that determines the configuration | ||
1728 | * file or plugin to use. | ||
1729 | * | ||
1730 | * This function returns the respective substring, taking care | ||
1731 | * of issues such as binaries ending in '.exe' on W32. | ||
1732 | * | ||
1733 | * @param argv0 the name of the binary | ||
1734 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
1735 | * NULL if argv0 has no '_' | ||
1736 | */ | ||
1737 | char * | ||
1738 | GNUNET_TESTING_get_testname_from_underscore (const char *argv0) | ||
1739 | { | ||
1740 | size_t slen = strlen (argv0) + 1; | ||
1741 | char sbuf[slen]; | ||
1742 | char *ret; | ||
1743 | char *dot; | ||
1744 | |||
1745 | GNUNET_memcpy (sbuf, argv0, slen); | ||
1746 | ret = strrchr (sbuf, '_'); | ||
1747 | if (NULL == ret) | ||
1748 | return NULL; | ||
1749 | ret++; /* skip underscore */ | ||
1750 | dot = strchr (ret, '.'); | ||
1751 | if (NULL != dot) | ||
1752 | *dot = '\0'; | ||
1753 | return GNUNET_strdup (ret); | ||
1754 | } | ||
1755 | |||
1756 | |||
1757 | /** | ||
1758 | * Every line in the topology configuration starts with a string indicating which | 1725 | * Every line in the topology configuration starts with a string indicating which |
1759 | * kind of information will be configured with this line. Configuration values following | 1726 | * kind of information will be configured with this line. Configuration values following |
1760 | * this string are seperated by special sequences of characters. An integer value seperated | 1727 | * this string are seperated by special sequences of characters. An integer value seperated |
diff --git a/src/testing/testing_api_cmd_barrier.c b/src/testing/testing_api_cmd_barrier.c index 9dd154059..c9c43b178 100644 --- a/src/testing/testing_api_cmd_barrier.c +++ b/src/testing/testing_api_cmd_barrier.c | |||
@@ -130,6 +130,7 @@ barrier_traits (void *cls, | |||
130 | index); | 130 | index); |
131 | } | 131 | } |
132 | 132 | ||
133 | |||
133 | /** | 134 | /** |
134 | * Cleanup the state from a "barrier" CMD, and possibly | 135 | * Cleanup the state from a "barrier" CMD, and possibly |
135 | * cancel a pending operation thereof. | 136 | * cancel a pending operation thereof. |
@@ -144,6 +145,7 @@ barrier_cleanup (void *cls) | |||
144 | GNUNET_free (brs); | 145 | GNUNET_free (brs); |
145 | } | 146 | } |
146 | 147 | ||
148 | |||
147 | /** | 149 | /** |
148 | * Run the command. | 150 | * Run the command. |
149 | * | 151 | * |
@@ -159,6 +161,7 @@ barrier_run (void *cls, | |||
159 | TST_interpreter_add_barrier (is, brs->barrier); | 161 | TST_interpreter_add_barrier (is, brs->barrier); |
160 | } | 162 | } |
161 | 163 | ||
164 | |||
162 | struct GNUNET_TESTING_NetjailNode * | 165 | struct GNUNET_TESTING_NetjailNode * |
163 | GNUNET_TESTING_barrier_get_node (struct GNUNET_TESTING_Barrier *barrier, | 166 | GNUNET_TESTING_barrier_get_node (struct GNUNET_TESTING_Barrier *barrier, |
164 | unsigned int node_number) | 167 | unsigned int node_number) |
diff --git a/src/testing/testing_api_cmd_barrier_reached.c b/src/testing/testing_api_cmd_barrier_reached.c index 3c2ba3a1d..0075f8ef0 100644 --- a/src/testing/testing_api_cmd_barrier_reached.c +++ b/src/testing/testing_api_cmd_barrier_reached.c | |||
@@ -92,7 +92,8 @@ barrier_reached_run (void *cls, | |||
92 | { | 92 | { |
93 | struct BarrierReachedState *brs = cls; | 93 | struct BarrierReachedState *brs = cls; |
94 | struct GNUNET_TESTING_Barrier *barrier; | 94 | struct GNUNET_TESTING_Barrier *barrier; |
95 | struct GNUNET_TESTING_Command *cmd = GNUNET_TESTING_interpreter_get_current_command (is); | 95 | struct GNUNET_TESTING_Command *cmd = |
96 | GNUNET_TESTING_interpreter_get_current_command (is); | ||
96 | struct CommandListEntry *cle; | 97 | struct CommandListEntry *cle; |
97 | size_t msg_length; | 98 | size_t msg_length; |
98 | struct GNUNET_TESTING_CommandBarrierReached *msg; | 99 | struct GNUNET_TESTING_CommandBarrierReached *msg; |
@@ -105,8 +106,8 @@ barrier_reached_run (void *cls, | |||
105 | barrier->name = brs->barrier_name; | 106 | barrier->name = brs->barrier_name; |
106 | TST_interpreter_add_barrier (is, barrier); | 107 | TST_interpreter_add_barrier (is, barrier); |
107 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 108 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
108 | "barrier %s added locally\n", | 109 | "barrier %s added locally\n", |
109 | brs->barrier_name); | 110 | brs->barrier_name); |
110 | } | 111 | } |
111 | barrier->reached++; | 112 | barrier->reached++; |
112 | if (GNUNET_TESTING_barrier_crossable (barrier)) | 113 | if (GNUNET_TESTING_barrier_crossable (barrier)) |
@@ -133,13 +134,14 @@ barrier_reached_run (void *cls, | |||
133 | char *terminator = "\0"; | 134 | char *terminator = "\0"; |
134 | 135 | ||
135 | name_len = strlen (barrier->name); | 136 | name_len = strlen (barrier->name); |
136 | msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached) + name_len + 1; | 137 | msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached) |
138 | + name_len + 1; | ||
137 | msg = GNUNET_malloc (msg_length); | 139 | msg = GNUNET_malloc (msg_length); |
138 | msg->header.size = htons ((uint16_t) msg_length); | 140 | msg->header.size = htons ((uint16_t) msg_length); |
139 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED); | 141 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED); |
140 | msg->node_number = brs->node_number; | 142 | msg->node_number = brs->node_number; |
141 | memcpy (&msg[1], barrier->name, name_len + 1); | 143 | memcpy (&msg[1], barrier->name, name_len + 1); |
142 | memcpy(&msg[name_len + 1],terminator,1); | 144 | memcpy (&msg[name_len + 1],terminator,1); |
143 | brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length); | 145 | brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length); |
144 | } | 146 | } |
145 | } | 147 | } |
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c index 81a43a3ac..58f095842 100644 --- a/src/testing/testing_api_cmd_block_until_external_trigger.c +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c | |||
@@ -48,6 +48,7 @@ block_until_all_peers_started_cleanup (void *cls) | |||
48 | GNUNET_free (bs); | 48 | GNUNET_free (bs); |
49 | } | 49 | } |
50 | 50 | ||
51 | |||
51 | static int | 52 | static int |
52 | block_until_external_trigger_traits (void *cls, | 53 | block_until_external_trigger_traits (void *cls, |
53 | const void **ret, | 54 | const void **ret, |
diff --git a/src/testing/testing_api_cmd_end.c b/src/testing/testing_api_cmd_end.c deleted file mode 100644 index 085420f81..000000000 --- a/src/testing/testing_api_cmd_end.c +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file testing/testing_api_cmd_end.c | ||
22 | * @brief command to end a command array | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_util_lib.h" | ||
26 | #include "gnunet_testing_ng_lib.h" | ||
27 | |||
28 | |||
29 | struct GNUNET_TESTING_Command | ||
30 | GNUNET_TESTING_cmd_end (void) | ||
31 | { | ||
32 | return GNUNET_TESTING_command_new (NULL, NULL, | ||
33 | NULL, NULL, | ||
34 | NULL, NULL); | ||
35 | } | ||
36 | |||
37 | |||
diff --git a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c index f1ef9fef1..51a20dd9b 100644 --- a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c +++ b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c | |||
@@ -293,7 +293,6 @@ send_message_to_locals ( | |||
293 | helper = ns->helper[count - 1]; | 293 | helper = ns->helper[count - 1]; |
294 | 294 | ||
295 | 295 | ||
296 | |||
297 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | 296 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( |
298 | (struct GNUNET_HELPER_Handle *) helper, | 297 | (struct GNUNET_HELPER_Handle *) helper, |
299 | header, | 298 | header, |
@@ -385,7 +384,7 @@ barrier_reached (struct NetJailState *ns, const struct | |||
385 | *) message; | 384 | *) message; |
386 | 385 | ||
387 | barrier_name = (const char *) &rm[1]; | 386 | barrier_name = (const char *) &rm[1]; |
388 | 387 | ||
389 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); | 388 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); |
390 | GNUNET_assert (NULL != barrier); | 389 | GNUNET_assert (NULL != barrier); |
391 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 390 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -396,13 +395,13 @@ barrier_reached (struct NetJailState *ns, const struct | |||
396 | barrier->reached++; | 395 | barrier->reached++; |
397 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 396 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
398 | "%u %p\n", | 397 | "%u %p\n", |
399 | barrier->reached, | 398 | barrier->reached, |
400 | barrier); | 399 | barrier); |
401 | if (GNUNET_TESTING_barrier_crossable (barrier)) | 400 | if (GNUNET_TESTING_barrier_crossable (barrier)) |
402 | { | 401 | { |
403 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 402 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
404 | "%s can be crossed\n", | 403 | "%s can be crossed\n", |
405 | barrier_name); | 404 | barrier_name); |
406 | TST_interpreter_finish_attached_cmds (ns->is, barrier->name); | 405 | TST_interpreter_finish_attached_cmds (ns->is, barrier->name); |
407 | } | 406 | } |
408 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 407 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -485,7 +484,8 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
485 | if (GNUNET_OK != lf->rv) | 484 | if (GNUNET_OK != lf->rv) |
486 | { | 485 | { |
487 | GNUNET_TESTING_async_fail (&(ns->ac)); | 486 | GNUNET_TESTING_async_fail (&(ns->ac)); |
488 | } else if (ns->number_of_local_tests_finished == total_number) | 487 | } |
488 | else if (ns->number_of_local_tests_finished == total_number) | ||
489 | { | 489 | { |
490 | GNUNET_SCHEDULER_cancel (ns->timeout_task); | 490 | GNUNET_SCHEDULER_cancel (ns->timeout_task); |
491 | ns->timeout_task = NULL; | 491 | ns->timeout_task = NULL; |
@@ -509,8 +509,6 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
509 | ns->known); | 509 | ns->known); |
510 | 510 | ||
511 | 511 | ||
512 | |||
513 | |||
514 | return GNUNET_OK; | 512 | return GNUNET_OK; |
515 | } | 513 | } |
516 | 514 | ||
@@ -737,22 +735,22 @@ start_helper (struct NetJailState *ns, | |||
737 | if (NULL == barrier) | 735 | if (NULL == barrier) |
738 | { | 736 | { |
739 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 737 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
740 | "barrier %s added\n", | 738 | "barrier %s added\n", |
741 | pos->barrier_name); | 739 | pos->barrier_name); |
742 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); | 740 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); |
743 | barrier->name = pos->barrier_name; | 741 | barrier->name = pos->barrier_name; |
744 | barrier->shadow = GNUNET_YES; | 742 | barrier->shadow = GNUNET_YES; |
745 | TST_interpreter_add_barrier (ns->is, barrier); | 743 | TST_interpreter_add_barrier (ns->is, barrier); |
746 | 744 | ||
747 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 745 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
748 | "%u %p\n", | 746 | "%u %p\n", |
749 | barrier->reached, | 747 | barrier->reached, |
750 | barrier); | 748 | barrier); |
751 | 749 | ||
752 | barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | 750 | barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); |
753 | } | 751 | } |
754 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 752 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
755 | "barrier %p %s node %u added \n", | 753 | "barrier %p %s node %u added \n", |
756 | barrier, | 754 | barrier, |
757 | pos->barrier_name, | 755 | pos->barrier_name, |
758 | node->node_number); | 756 | node->node_number); |
@@ -859,7 +857,7 @@ netjail_exec_run (void *cls, | |||
859 | for (int j = 1; j <= ns->local_m; j++) | 857 | for (int j = 1; j <= ns->local_m; j++) |
860 | { | 858 | { |
861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
862 | "i %u j %u\n", | 860 | "i %u j %u\n", |
863 | i, | 861 | i, |
864 | j); | 862 | j); |
865 | start_helper (ns, | 863 | start_helper (ns, |
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c index dcd69e595..f615a1cee 100644 --- a/src/testing/testing_api_cmd_send_peer_ready.c +++ b/src/testing/testing_api_cmd_send_peer_ready.c | |||
@@ -109,7 +109,8 @@ send_peer_ready_run (void *cls, | |||
109 | */ | 109 | */ |
110 | struct GNUNET_TESTING_Command | 110 | struct GNUNET_TESTING_Command |
111 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 111 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
112 | GNUNET_TESTING_cmd_helper_write_cb write_message) | 112 | GNUNET_TESTING_cmd_helper_write_cb |
113 | write_message) | ||
113 | { | 114 | { |
114 | struct SendPeerReadyState *sprs; | 115 | struct SendPeerReadyState *sprs; |
115 | 116 | ||
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index f53e1ecdb..db0a00c22 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c | |||
@@ -123,7 +123,7 @@ struct FreeBarrierNodeCbCls | |||
123 | }; | 123 | }; |
124 | 124 | ||
125 | 125 | ||
126 | const struct GNUNET_TESTING_Command * | 126 | static const struct GNUNET_TESTING_Command * |
127 | get_command (struct GNUNET_TESTING_Interpreter *is, | 127 | get_command (struct GNUNET_TESTING_Interpreter *is, |
128 | const char *label, | 128 | const char *label, |
129 | unsigned int future) | 129 | unsigned int future) |
@@ -265,7 +265,7 @@ free_barrier_node_cb (void *cls, | |||
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | int | 268 | static int |
269 | free_barriers_cb (void *cls, | 269 | free_barriers_cb (void *cls, |
270 | const struct GNUNET_ShortHashCode *key, | 270 | const struct GNUNET_ShortHashCode *key, |
271 | void *value) | 271 | void *value) |
@@ -574,14 +574,19 @@ GNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands, | |||
574 | is = GNUNET_new (struct GNUNET_TESTING_Interpreter); | 574 | is = GNUNET_new (struct GNUNET_TESTING_Interpreter); |
575 | is->rc = rc; | 575 | is->rc = rc; |
576 | is->rc_cls = rc_cls; | 576 | is->rc_cls = rc_cls; |
577 | is->barriers = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | 577 | is->barriers = GNUNET_CONTAINER_multishortmap_create (1, |
578 | false); | ||
578 | /* get the number of commands */ | 579 | /* get the number of commands */ |
579 | for (i = 0; NULL != commands[i].run; i++) | 580 | for (i = 0; NULL != commands[i].run; i++) |
580 | ; | 581 | ; |
581 | is->cmds_n = i + 1; | 582 | is->cmds_n = i + 1; |
582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got %u commands\n", i); | 583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
583 | is->commands = GNUNET_new_array (is->cmds_n, | 584 | "Got %u commands\n", |
584 | struct GNUNET_TESTING_Command); | 585 | i); |
586 | is->commands = GNUNET_malloc_large ( (i + 1) | ||
587 | * sizeof (struct | ||
588 | GNUNET_TESTING_Command)); | ||
589 | GNUNET_assert (NULL != is->commands); | ||
585 | memcpy (is->commands, | 590 | memcpy (is->commands, |
586 | commands, | 591 | commands, |
587 | sizeof (struct GNUNET_TESTING_Command) * i); | 592 | sizeof (struct GNUNET_TESTING_Command) * i); |
@@ -611,12 +616,28 @@ GNUNET_TESTING_command_new (void *cls, | |||
611 | .cleanup = cleanup, | 616 | .cleanup = cleanup, |
612 | .traits = traits | 617 | .traits = traits |
613 | }; | 618 | }; |
614 | memset (&cmd.label, 0, sizeof (cmd.label)); | ||
615 | if (NULL != label) | ||
616 | strncpy (cmd.label, label, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH); | ||
617 | 619 | ||
620 | GNUNET_assert (NULL != run); | ||
621 | if (NULL != label) | ||
622 | { | ||
623 | GNUNET_assert (strlen (label) <= | ||
624 | GNUNET_TESTING_CMD_MAX_LABEL_LENGTH); | ||
625 | strncpy (cmd.label, | ||
626 | label, | ||
627 | GNUNET_TESTING_CMD_MAX_LABEL_LENGTH); | ||
628 | } | ||
618 | return cmd; | 629 | return cmd; |
630 | } | ||
631 | |||
632 | |||
633 | struct GNUNET_TESTING_Command | ||
634 | GNUNET_TESTING_cmd_end (void) | ||
635 | { | ||
636 | struct GNUNET_TESTING_Command cmd = { | ||
637 | .run = NULL | ||
638 | }; | ||
619 | 639 | ||
640 | return cmd; | ||
620 | } | 641 | } |
621 | 642 | ||
622 | 643 | ||
@@ -685,9 +706,9 @@ loop_run (void *cls) | |||
685 | * Continuation function from GNUNET_HELPER_send() | 706 | * Continuation function from GNUNET_HELPER_send() |
686 | * | 707 | * |
687 | * @param cls closure | 708 | * @param cls closure |
688 | * @param result GNUNET_OK on success, | 709 | * @param result #GNUNET_OK on success, |
689 | * GNUNET_NO if helper process died | 710 | * #GNUNET_NO if helper process died |
690 | * GNUNET_SYSERR during GNUNET_HELPER_stop | 711 | * #GNUNET_SYSERR during GNUNET_HELPER_stop() |
691 | */ | 712 | */ |
692 | static void | 713 | static void |
693 | clear_msg (void *cls, int result) | 714 | clear_msg (void *cls, int result) |
@@ -745,7 +766,6 @@ TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is, | |||
745 | struct CommandBarrierCrossable *adm; | 766 | struct CommandBarrierCrossable *adm; |
746 | size_t msg_length; | 767 | size_t msg_length; |
747 | size_t name_len; | 768 | size_t name_len; |
748 | char *terminator = "\0"; | ||
749 | 769 | ||
750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
751 | "send barrier name %s barrier_name\n", | 771 | "send barrier name %s barrier_name\n", |
@@ -797,7 +817,6 @@ TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | |||
797 | const char *barrier_name) | 817 | const char *barrier_name) |
798 | { | 818 | { |
799 | struct CommandListEntry *pos; | 819 | struct CommandListEntry *pos; |
800 | struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls; | ||
801 | struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is, | 820 | struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is, |
802 | barrier_name); | 821 | barrier_name); |
803 | 822 | ||
@@ -830,17 +849,18 @@ TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | |||
830 | } | 849 | } |
831 | if (NULL != barrier->nodes) | 850 | if (NULL != barrier->nodes) |
832 | { | 851 | { |
833 | free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls); | 852 | struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = { |
834 | free_barrier_node_cb_cls->barrier = barrier; | 853 | .barrier = barrier, |
835 | free_barrier_node_cb_cls->is = is; | 854 | .is = is |
855 | }; | ||
856 | |||
836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 857 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
837 | "freeing nodes\n"); | 858 | "freeing nodes\n"); |
838 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, | 859 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, |
839 | free_barrier_node_cb, | 860 | &free_barrier_node_cb, |
840 | free_barrier_node_cb_cls); | 861 | &free_barrier_node_cb_cls); |
841 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
842 | "nodes freed\n"); | 863 | "nodes freed\n"); |
843 | GNUNET_free (free_barrier_node_cb_cls); | ||
844 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); | 864 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); |
845 | barrier->nodes = NULL; | 865 | barrier->nodes = NULL; |
846 | } | 866 | } |
diff --git a/src/topology/meson.build b/src/topology/meson.build new file mode 100644 index 000000000..e19316142 --- /dev/null +++ b/src/topology/meson.build | |||
@@ -0,0 +1,44 @@ | |||
1 | libgnunetfriends_src = ['friends.c'] | ||
2 | |||
3 | gnunetdaemontopology_src = ['gnunet-daemon-topology.c'] | ||
4 | |||
5 | configure_file(input : 'topology.conf', | ||
6 | output : 'topology.conf', | ||
7 | configuration : cdata, | ||
8 | install: true, | ||
9 | install_dir: pkgcfgdir) | ||
10 | |||
11 | |||
12 | if get_option('monolith') | ||
13 | foreach p : libgnunetfriends_src | ||
14 | gnunet_src += 'topology/' + p | ||
15 | endforeach | ||
16 | subdir_done() | ||
17 | endif | ||
18 | |||
19 | libgnunetfriends = library('gnunetfriends', | ||
20 | libgnunetfriends_src, | ||
21 | soversion: '0', | ||
22 | version: '0.0.0', | ||
23 | dependencies: libgnunetutil_dep, | ||
24 | include_directories: [incdir, configuration_inc], | ||
25 | install: true, | ||
26 | install_dir: get_option('libdir')) | ||
27 | pkg.generate(libgnunetfriends, url: 'https://www.gnunet.org', | ||
28 | description : 'Provides API for accessing the friends service') | ||
29 | libgnunetfriends_dep = declare_dependency(link_with : libgnunetfriends) | ||
30 | |||
31 | executable ('gnunet-daemon-topology', | ||
32 | gnunetdaemontopology_src, | ||
33 | dependencies: [libgnunetfriends_dep, | ||
34 | libgnunetutil_dep, | ||
35 | libgnunetcore_dep, | ||
36 | libgnunetpeerinfo_dep, | ||
37 | libgnunetstatistics_dep, | ||
38 | libgnunettransport_dep, | ||
39 | libgnunetats_dep, | ||
40 | libgnunethello_dep], | ||
41 | include_directories: [incdir, configuration_inc], | ||
42 | install: true, | ||
43 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
44 | |||
diff --git a/src/transport/.gitignore b/src/transport/.gitignore index 5a82a787b..163ffbd5d 100644 --- a/src/transport/.gitignore +++ b/src/transport/.gitignore | |||
@@ -87,7 +87,8 @@ gnunet-communicator-unix | |||
87 | gnunet-service-tng | 87 | gnunet-service-tng |
88 | gnunet-communicator-tcp | 88 | gnunet-communicator-tcp |
89 | gnunet-communicator-udp | 89 | gnunet-communicator-udp |
90 | test_communicator_unix | 90 | test_communicator_basic-* |
91 | test_communicator_basic_unix | 91 | test_communicator_rekey-* |
92 | test_transport_start_with_config | 92 | test_transport_start_with_config |
93 | test_transport_api2_tcp | 93 | test_transport_api2_tcp |
94 | gnunet-communicator-quic | ||
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 5b51f3edd..d7d25b7b0 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -220,7 +220,12 @@ libexec_PROGRAMS = \ | |||
220 | gnunet-communicator-unix \ | 220 | gnunet-communicator-unix \ |
221 | gnunet-communicator-udp \ | 221 | gnunet-communicator-udp \ |
222 | gnunet-communicator-tcp | 222 | gnunet-communicator-tcp |
223 | 223 | if HAVE_EXPERIMENTAL | |
224 | if HAVE_QUICHE | ||
225 | libexec_PROGRAMS += \ | ||
226 | gnunet-communicator-quic | ||
227 | endif | ||
228 | endif | ||
224 | 229 | ||
225 | 230 | ||
226 | bin_PROGRAMS = \ | 231 | bin_PROGRAMS = \ |
@@ -269,6 +274,22 @@ gnunet_communicator_udp_LDADD = \ | |||
269 | $(top_builddir)/src/util/libgnunetutil.la \ | 274 | $(top_builddir)/src/util/libgnunetutil.la \ |
270 | $(LIBGCRYPT_LIBS) | 275 | $(LIBGCRYPT_LIBS) |
271 | 276 | ||
277 | if HAVE_EXPERIMENTAL | ||
278 | if HAVE_QUICHE | ||
279 | gnunet_communicator_quic_SOURCES = \ | ||
280 | gnunet-communicator-quic.c | ||
281 | gnunet_communicator_quic_LDADD = \ | ||
282 | libgnunettransportapplication.la \ | ||
283 | libgnunettransportcommunicator.la \ | ||
284 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
285 | $(top_builddir)/src/nat/libgnunetnatnew.la \ | ||
286 | $(top_builddir)/src/nt/libgnunetnt.la \ | ||
287 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
288 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
289 | -lquiche \ | ||
290 | $(LIBGCRYPT_LIBS) | ||
291 | endif | ||
292 | endif | ||
272 | 293 | ||
273 | gnunet_helper_transport_wlan_SOURCES = \ | 294 | gnunet_helper_transport_wlan_SOURCES = \ |
274 | gnunet-helper-transport-wlan.c | 295 | gnunet-helper-transport-wlan.c |
@@ -690,6 +711,7 @@ check_PROGRAMS += \ | |||
690 | test_communicator_basic-unix \ | 711 | test_communicator_basic-unix \ |
691 | test_communicator_basic-tcp \ | 712 | test_communicator_basic-tcp \ |
692 | test_communicator_basic-udp \ | 713 | test_communicator_basic-udp \ |
714 | test_communicator_basic-quic \ | ||
693 | test_communicator_rekey-tcp \ | 715 | test_communicator_rekey-tcp \ |
694 | test_communicator_rekey-udp \ | 716 | test_communicator_rekey-udp \ |
695 | test_communicator_backchannel-udp \ | 717 | test_communicator_backchannel-udp \ |
@@ -768,6 +790,7 @@ TESTS += \ | |||
768 | test_quota_compliance_udp \ | 790 | test_quota_compliance_udp \ |
769 | test_communicator_basic-unix \ | 791 | test_communicator_basic-unix \ |
770 | test_communicator_basic-tcp \ | 792 | test_communicator_basic-tcp \ |
793 | test_communicator_basic-quic \ | ||
771 | test_communicator_basic-udp \ | 794 | test_communicator_basic-udp \ |
772 | test_communicator_rekey-tcp \ | 795 | test_communicator_rekey-tcp \ |
773 | test_communicator_rekey-udp \ | 796 | test_communicator_rekey-udp \ |
@@ -934,6 +957,14 @@ test_communicator_basic_udp_LDADD = \ | |||
934 | $(top_builddir)/src/util/libgnunetutil.la \ | 957 | $(top_builddir)/src/util/libgnunetutil.la \ |
935 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 958 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
936 | 959 | ||
960 | test_communicator_basic_quic_SOURCES = \ | ||
961 | test_communicator_basic.c | ||
962 | test_communicator_basic_quic_LDADD = \ | ||
963 | libgnunettransporttesting2.la \ | ||
964 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
965 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
966 | $(top_builddir)/src/statistics/libgnunetstatistics.la | ||
967 | |||
937 | test_communicator_rekey_tcp_SOURCES = \ | 968 | test_communicator_rekey_tcp_SOURCES = \ |
938 | test_communicator_basic.c | 969 | test_communicator_basic.c |
939 | test_communicator_rekey_tcp_LDADD = \ | 970 | test_communicator_rekey_tcp_LDADD = \ |
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c new file mode 100644 index 000000000..1225a3817 --- /dev/null +++ b/src/transport/gnunet-communicator-quic.c | |||
@@ -0,0 +1,1796 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2014, 2018, 2019 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/gnunet-communicator-quic.c | ||
23 | * @brief Transport plugin using QUIC. | ||
24 | * @author Marshall Stone | ||
25 | * @author Martin Schanzenbach | ||
26 | * | ||
27 | * TODO: | ||
28 | * - Automatically generate self-signed x509 certificates and load from config | ||
29 | * - Figure out MTU and how we have to handle fragmentation in Quiche. | ||
30 | * - Mandate timeouts | ||
31 | * - Setup stats handler properly | ||
32 | * - Doxygen documentation of methods | ||
33 | * - Refactor code shared with UDP and TCP communicator | ||
34 | * - Performance testing | ||
35 | * - Check for memory leaks with coverity/valgrind | ||
36 | */ | ||
37 | #include "gnunet_common.h" | ||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_core_service.h" | ||
40 | #include "quiche.h" | ||
41 | #include "platform.h" | ||
42 | #include "gnunet_protocols.h" | ||
43 | #include "gnunet_signatures.h" | ||
44 | #include "gnunet_constants.h" | ||
45 | #include "gnunet_statistics_service.h" | ||
46 | #include "gnunet_transport_application_service.h" | ||
47 | #include "gnunet_transport_communication_service.h" | ||
48 | #include "gnunet_nt_lib.h" | ||
49 | #include "gnunet_nat_service.h" | ||
50 | #include "stdint.h" | ||
51 | #include "inttypes.h" | ||
52 | |||
53 | #define COMMUNICATOR_CONFIG_SECTION "communicator-quic" | ||
54 | #define COMMUNICATOR_ADDRESS_PREFIX "quic" | ||
55 | #define MAX_DATAGRAM_SIZE 1350 | ||
56 | |||
57 | |||
58 | /* FIXME: Review all static lengths/contents below. Maybe this can be done smarter */ | ||
59 | /* Currently equivalent to QUICHE_MAX_CONN_ID_LEN */ | ||
60 | #define LOCAL_CONN_ID_LEN 20 | ||
61 | #define MAX_TOKEN_LEN \ | ||
62 | sizeof("quiche") - 1 \ | ||
63 | + sizeof(struct sockaddr_storage) \ | ||
64 | + QUICHE_MAX_CONN_ID_LEN | ||
65 | #define CID_LEN sizeof(uint8_t) * QUICHE_MAX_CONN_ID_LEN | ||
66 | #define TOKEN_LEN sizeof (uint8_t) * MAX_TOKEN_LEN | ||
67 | |||
68 | |||
69 | /* FIXME: Why 4? | ||
70 | Generic, bidirectional, client-initiated quic stream id */ | ||
71 | #define STREAMID_BI 4 | ||
72 | |||
73 | /** | ||
74 | * How long do we believe our addresses to remain up (before | ||
75 | * the other peer should revalidate). | ||
76 | */ | ||
77 | #define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS | ||
78 | |||
79 | /** | ||
80 | * Map of DCID (uint8_t) -> quic_conn for quickly retrieving connections to other peers. | ||
81 | */ | ||
82 | struct GNUNET_CONTAINER_MultiHashMap *conn_map; | ||
83 | |||
84 | /** | ||
85 | * Map of sockaddr -> struct PeerAddress | ||
86 | */ | ||
87 | struct GNUNET_CONTAINER_MultiHashMap *addr_map; | ||
88 | |||
89 | /** | ||
90 | * Handle to the config | ||
91 | */ | ||
92 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
93 | |||
94 | /** | ||
95 | * FIXME undocumented | ||
96 | */ | ||
97 | static struct GNUNET_TIME_Relative rekey_interval; | ||
98 | |||
99 | /** | ||
100 | * FIXME undocumented | ||
101 | */ | ||
102 | static struct GNUNET_NETWORK_Handle *udp_sock; | ||
103 | |||
104 | /** | ||
105 | * FIXME undocumented | ||
106 | */ | ||
107 | static struct GNUNET_SCHEDULER_Task *read_task; | ||
108 | |||
109 | /** | ||
110 | * FIXME undocumented | ||
111 | */ | ||
112 | static struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | ||
113 | |||
114 | /** | ||
115 | * FIXME undocumented | ||
116 | */ | ||
117 | static struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
118 | |||
119 | /** | ||
120 | * FIXME undocumented | ||
121 | */ | ||
122 | static int have_v6_socket; | ||
123 | |||
124 | /** | ||
125 | * FIXME undocumented | ||
126 | */ | ||
127 | static uint16_t my_port; | ||
128 | |||
129 | /** | ||
130 | * FIXME undocumented | ||
131 | */ | ||
132 | static unsigned long long rekey_max_bytes; | ||
133 | |||
134 | /** | ||
135 | * FIXME undocumented | ||
136 | */ | ||
137 | static quiche_config *config = NULL; | ||
138 | |||
139 | /** | ||
140 | * Our peer identity | ||
141 | */ | ||
142 | struct GNUNET_PeerIdentity my_identity; | ||
143 | |||
144 | /** | ||
145 | * Our private key. | ||
146 | */ | ||
147 | static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | ||
148 | |||
149 | /** | ||
150 | * Connection to NAT service. | ||
151 | */ | ||
152 | static struct GNUNET_NAT_Handle *nat; | ||
153 | |||
154 | /** | ||
155 | * Information we track per peer we have recently been in contact with. | ||
156 | * | ||
157 | * (Since quiche handles crypto, handshakes, etc. we don't differentiate | ||
158 | * between SenderAddress and ReceiverAddress) | ||
159 | * FIXME: But we do a handshake as well. The flag in this struct seems to | ||
160 | * indicate this. Update comment! | ||
161 | */ | ||
162 | struct PeerAddress | ||
163 | { | ||
164 | /** | ||
165 | * To whom are we talking to. | ||
166 | */ | ||
167 | struct GNUNET_PeerIdentity target; | ||
168 | |||
169 | /** | ||
170 | * Flag to indicate whether we know the PeerIdentity (target) yet | ||
171 | */ | ||
172 | int id_rcvd; | ||
173 | |||
174 | /** | ||
175 | * Flag to indicate whether we have sent OUR PeerIdentity to this peer | ||
176 | */ | ||
177 | int id_sent; | ||
178 | |||
179 | /** | ||
180 | * Flag to indicate if we are the initiator of the connection | ||
181 | */ | ||
182 | int is_receiver; | ||
183 | |||
184 | /** | ||
185 | * Address of the receiver in the human-readable format | ||
186 | * with the #COMMUNICATOR_ADDRESS_PREFIX. | ||
187 | */ | ||
188 | char *foreign_addr; | ||
189 | |||
190 | /** | ||
191 | * Address of the other peer. | ||
192 | */ | ||
193 | struct sockaddr *address; | ||
194 | |||
195 | /** | ||
196 | * Length of the address. | ||
197 | */ | ||
198 | socklen_t address_len; | ||
199 | |||
200 | /** | ||
201 | * The QUIC connection associated with this peer | ||
202 | */ | ||
203 | struct quic_conn *conn; | ||
204 | |||
205 | /** | ||
206 | * Default message queue we are providing for the #ch. | ||
207 | */ | ||
208 | struct GNUNET_MQ_Handle *d_mq; | ||
209 | |||
210 | /** | ||
211 | * handle for default queue with the #ch. | ||
212 | */ | ||
213 | struct GNUNET_TRANSPORT_QueueHandle *d_qh; | ||
214 | |||
215 | /** | ||
216 | * Timeout for this peer address. | ||
217 | */ | ||
218 | struct GNUNET_TIME_Absolute timeout; | ||
219 | |||
220 | /** | ||
221 | * MTU we allowed transport for this peer's default queue. | ||
222 | * FIXME: MTU from quiche | ||
223 | */ | ||
224 | size_t d_mtu; | ||
225 | |||
226 | /** | ||
227 | * Which network type does this queue use? | ||
228 | */ | ||
229 | enum GNUNET_NetworkType nt; | ||
230 | |||
231 | /** | ||
232 | * receiver_destroy already called on receiver. | ||
233 | */ | ||
234 | int peer_destroy_called; | ||
235 | |||
236 | /** | ||
237 | * FIXME implementation missing | ||
238 | * Entry in sender expiration heap. | ||
239 | */ | ||
240 | // struct GNUNET_CONTAINER_HeapNode *hn; | ||
241 | }; | ||
242 | |||
243 | // /** | ||
244 | // * FIXME: Implementation missing | ||
245 | // * Expiration heap for peers (contains `struct PeerAddress`) | ||
246 | // */ | ||
247 | // static struct GNUNET_CONTAINER_Heap *peers_heap; | ||
248 | |||
249 | /** | ||
250 | * ID of timeout task | ||
251 | */ | ||
252 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
253 | |||
254 | /** | ||
255 | * Network scanner to determine network types. | ||
256 | */ | ||
257 | static struct GNUNET_NT_InterfaceScanner *is; | ||
258 | |||
259 | /** | ||
260 | * For logging statistics. | ||
261 | */ | ||
262 | static struct GNUNET_STATISTICS_Handle *stats; | ||
263 | |||
264 | /** | ||
265 | * QUIC connection object. A connection has a unique SCID/DCID pair. Here we store our SCID | ||
266 | * (incoming packet DCID field == outgoing packet SCID field) for a given connection. This | ||
267 | * is hashed for each unique quic_conn. | ||
268 | */ | ||
269 | struct quic_conn | ||
270 | { | ||
271 | uint8_t cid[LOCAL_CONN_ID_LEN]; | ||
272 | |||
273 | quiche_conn *conn; | ||
274 | }; | ||
275 | |||
276 | /** | ||
277 | * QUIC_header is used to store information received from an incoming QUIC packet | ||
278 | */ | ||
279 | struct QUIC_header | ||
280 | { | ||
281 | uint8_t type; | ||
282 | uint32_t version; | ||
283 | |||
284 | uint8_t scid[QUICHE_MAX_CONN_ID_LEN]; | ||
285 | size_t scid_len; | ||
286 | |||
287 | uint8_t dcid[QUICHE_MAX_CONN_ID_LEN]; | ||
288 | size_t dcid_len; | ||
289 | |||
290 | uint8_t odcid[QUICHE_MAX_CONN_ID_LEN]; | ||
291 | size_t odcid_len; | ||
292 | |||
293 | uint8_t token[MAX_TOKEN_LEN]; | ||
294 | size_t token_len; | ||
295 | }; | ||
296 | |||
297 | |||
298 | /** | ||
299 | * Given a PeerAddress, receive data from streams after doing connection logic. | ||
300 | * ASSUMES: connection is established to peer | ||
301 | */ | ||
302 | static void | ||
303 | recv_from_streams (struct PeerAddress *peer) | ||
304 | { | ||
305 | char stream_buf[UINT16_MAX]; | ||
306 | size_t buf_size = UINT16_MAX; | ||
307 | char *buf_ptr = stream_buf; | ||
308 | struct GNUNET_MessageHeader *hdr; | ||
309 | |||
310 | uint64_t s = 0; | ||
311 | quiche_stream_iter *readable; | ||
312 | bool fin; | ||
313 | ssize_t recv_len; | ||
314 | |||
315 | readable = quiche_conn_readable (peer->conn->conn); | ||
316 | while (quiche_stream_iter_next (readable, &s)) | ||
317 | { | ||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stream %" PRIu64 " is readable\n", | ||
319 | s); | ||
320 | fin = false; | ||
321 | recv_len = quiche_conn_stream_recv (peer->conn->conn, s, | ||
322 | (uint8_t *) stream_buf, buf_size, | ||
323 | &fin); | ||
324 | if (recv_len < 0) | ||
325 | { | ||
326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
327 | "error while receiving data from stream %" PRIu64 "\n", s); | ||
328 | break; | ||
329 | } | ||
330 | /** | ||
331 | * FIXME: Do not use implicit booleans. Use GNUNET_YES, GNUNET_NO, GNUNET_SYSERR | ||
332 | * and check for that. | ||
333 | * | ||
334 | * Initial packet should contain peerid if they are the initiator | ||
335 | */ | ||
336 | if (! peer->is_receiver && GNUNET_NO == peer->id_rcvd) | ||
337 | { | ||
338 | if (recv_len < sizeof(struct GNUNET_PeerIdentity)) | ||
339 | { | ||
340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
341 | "message recv len of %zd less than length of peer identity\n", | ||
342 | recv_len); | ||
343 | return; | ||
344 | } | ||
345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
346 | "received peer identity\n"); | ||
347 | struct GNUNET_PeerIdentity *pid = (struct | ||
348 | GNUNET_PeerIdentity *) stream_buf; | ||
349 | peer->target = *pid; | ||
350 | peer->id_rcvd = GNUNET_YES; | ||
351 | buf_ptr += sizeof(struct GNUNET_PeerIdentity); | ||
352 | recv_len -= sizeof(struct GNUNET_PeerIdentity); | ||
353 | } | ||
354 | /** | ||
355 | * Parse messages to pass to communicator | ||
356 | */ | ||
357 | while (recv_len >= sizeof(struct GNUNET_MessageHeader)) | ||
358 | { | ||
359 | hdr = (struct GNUNET_MessageHeader *) buf_ptr; | ||
360 | if (ntohs (hdr->size) > recv_len) | ||
361 | { | ||
362 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
363 | "message size stated (%d) is greater than length of rcvd data (%zd)!\n", | ||
364 | ntohs (hdr->size), recv_len); | ||
365 | return; | ||
366 | } | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %zd bytes to core\n", | ||
368 | recv_len); | ||
369 | GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr, | ||
370 | ADDRESS_VALIDITY_PERIOD, NULL, | ||
371 | NULL); | ||
372 | recv_len -= ntohs (hdr->size); | ||
373 | buf_ptr += ntohs (hdr->size); | ||
374 | } | ||
375 | /** | ||
376 | * Check for leftover bytes | ||
377 | */ | ||
378 | if (0 != recv_len) | ||
379 | { | ||
380 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
381 | "message recv len of %zd less than length of message header\n", | ||
382 | recv_len); | ||
383 | } | ||
384 | /** | ||
385 | * FIXME: comment useless | ||
386 | * fin | ||
387 | */ | ||
388 | if (fin) | ||
389 | { | ||
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
391 | "fin received, closing connection\n"); | ||
392 | if (0 > quiche_conn_close (peer->conn->conn, true, 0, NULL, 0)) | ||
393 | { | ||
394 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
395 | "quiche failed to close connection to peer\n"); | ||
396 | } | ||
397 | } | ||
398 | } | ||
399 | quiche_stream_iter_free (readable); | ||
400 | } | ||
401 | |||
402 | |||
403 | /** | ||
404 | * FIXME: review token generation, assure tokens are generated properly. doxygen | ||
405 | */ | ||
406 | static void | ||
407 | mint_token (const uint8_t *dcid, size_t dcid_len, | ||
408 | struct sockaddr_storage *addr, socklen_t addr_len, | ||
409 | uint8_t *token, size_t *token_len) | ||
410 | { | ||
411 | GNUNET_memcpy (token, "quiche", sizeof("quiche") - 1); | ||
412 | GNUNET_memcpy (token + sizeof("quiche") - 1, addr, addr_len); | ||
413 | GNUNET_memcpy (token + sizeof("quiche") - 1 + addr_len, dcid, dcid_len); | ||
414 | |||
415 | *token_len = sizeof("quiche") - 1 + addr_len + dcid_len; | ||
416 | } | ||
417 | |||
418 | |||
419 | static enum GNUNET_GenericReturnValue | ||
420 | validate_token (const uint8_t *token, size_t token_len, | ||
421 | struct sockaddr_storage *addr, socklen_t addr_len, | ||
422 | uint8_t *odcid, size_t *odcid_len) | ||
423 | { | ||
424 | if ((token_len < sizeof("quiche") - 1) || | ||
425 | memcmp (token, "quiche", sizeof("quiche") - 1)) | ||
426 | { | ||
427 | return GNUNET_NO; | ||
428 | } | ||
429 | |||
430 | token += sizeof("quiche") - 1; | ||
431 | token_len -= sizeof("quiche") - 1; | ||
432 | |||
433 | if ((token_len < addr_len) || memcmp (token, addr, addr_len)) | ||
434 | { | ||
435 | return GNUNET_NO; | ||
436 | } | ||
437 | |||
438 | token += addr_len; | ||
439 | token_len -= addr_len; | ||
440 | |||
441 | if (*odcid_len < token_len) | ||
442 | { | ||
443 | return GNUNET_NO; | ||
444 | } | ||
445 | |||
446 | memcpy (odcid, token, token_len); | ||
447 | *odcid_len = token_len; | ||
448 | |||
449 | return GNUNET_OK; | ||
450 | } | ||
451 | |||
452 | |||
453 | static struct quic_conn* | ||
454 | create_conn (uint8_t *scid, size_t scid_len, | ||
455 | uint8_t *odcid, size_t odcid_len, | ||
456 | struct sockaddr *local_addr, | ||
457 | socklen_t local_addr_len, | ||
458 | struct sockaddr_storage *peer_addr, | ||
459 | socklen_t peer_addr_len) | ||
460 | { | ||
461 | struct quic_conn *conn; | ||
462 | quiche_conn *q_conn; | ||
463 | conn = GNUNET_new (struct quic_conn); | ||
464 | if (scid_len != LOCAL_CONN_ID_LEN) | ||
465 | { | ||
466 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
467 | "error while creating connection, scid length too short: %zu\n", | ||
468 | scid_len); | ||
469 | return NULL; | ||
470 | } | ||
471 | |||
472 | GNUNET_memcpy (conn->cid, scid, LOCAL_CONN_ID_LEN); | ||
473 | q_conn = quiche_accept (conn->cid, LOCAL_CONN_ID_LEN, | ||
474 | odcid, odcid_len, | ||
475 | local_addr, | ||
476 | local_addr_len, | ||
477 | (struct sockaddr *) peer_addr, | ||
478 | peer_addr_len, | ||
479 | config); | ||
480 | if (NULL == q_conn) | ||
481 | { | ||
482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
483 | "quiche failed to create connection after call to quiche_accept\n"); | ||
484 | return NULL; | ||
485 | } | ||
486 | conn->conn = q_conn; | ||
487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new quic connection created\n"); | ||
488 | return conn; | ||
489 | } | ||
490 | |||
491 | |||
492 | static void | ||
493 | flush_egress (struct quic_conn *conn) | ||
494 | { | ||
495 | static uint8_t out[MAX_DATAGRAM_SIZE]; | ||
496 | quiche_send_info send_info; | ||
497 | |||
498 | ssize_t written; | ||
499 | ssize_t sent; | ||
500 | |||
501 | while (1) | ||
502 | { | ||
503 | written = quiche_conn_send (conn->conn, out, sizeof(out), &send_info); | ||
504 | if (QUICHE_ERR_DONE == written) | ||
505 | { | ||
506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "done writing quic packets\n"); | ||
507 | break; | ||
508 | } | ||
509 | if (0 > written) | ||
510 | { | ||
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
512 | "quiche failed to create packet. quiche error: %zd\n", | ||
513 | written); | ||
514 | return; | ||
515 | } | ||
516 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, out, written, | ||
517 | (struct sockaddr *) &send_info.to, | ||
518 | send_info.to_len); | ||
519 | if (sent != written) | ||
520 | { | ||
521 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
522 | "quiche failed to send data to peer\n"); | ||
523 | return; | ||
524 | } | ||
525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | |||
530 | /** | ||
531 | * Increment receiver timeout due to activity. | ||
532 | * | ||
533 | * @param receiver address for which the timeout should be rescheduled | ||
534 | */ | ||
535 | static void | ||
536 | reschedule_peer_timeout (struct PeerAddress *peer) | ||
537 | { | ||
538 | peer->timeout = | ||
539 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
540 | // GNUNET_CONTAINER_heap_update_cost (peer->hn, | ||
541 | // peer->timeout.abs_value_us); | ||
542 | } | ||
543 | |||
544 | |||
545 | /** | ||
546 | * Destroys a receiving state due to timeout or shutdown. | ||
547 | * | ||
548 | * @param receiver entity to close down | ||
549 | */ | ||
550 | static void | ||
551 | peer_destroy (struct PeerAddress *peer) | ||
552 | { | ||
553 | struct GNUNET_HashCode addr_key; | ||
554 | |||
555 | peer->peer_destroy_called = GNUNET_YES; | ||
556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
557 | "Disconnecting peer for peer `%s'\n", | ||
558 | GNUNET_i2s (&peer->target)); | ||
559 | if (NULL != peer->d_qh) | ||
560 | { | ||
561 | GNUNET_TRANSPORT_communicator_mq_del (peer->d_qh); | ||
562 | peer->d_qh = NULL; | ||
563 | } | ||
564 | // GNUNET_assert (peer == GNUNET_CONTAINER_heap_remove_node (peer->hn)); | ||
565 | /** | ||
566 | * Remove peer from hashmap | ||
567 | */ | ||
568 | GNUNET_CRYPTO_hash (peer->address, peer->address_len, &addr_key); | ||
569 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (addr_map, &addr_key, | ||
570 | peer)) | ||
571 | { | ||
572 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
573 | "tried to remove non-existent peer from addr map\n"); | ||
574 | return; | ||
575 | } | ||
576 | GNUNET_STATISTICS_set (stats, | ||
577 | "# peers active", | ||
578 | GNUNET_CONTAINER_multihashmap_size (addr_map), | ||
579 | GNUNET_NO); | ||
580 | quiche_conn_free (peer->conn->conn); | ||
581 | GNUNET_free (peer->address); | ||
582 | GNUNET_free (peer->foreign_addr); | ||
583 | GNUNET_free (peer->conn); | ||
584 | GNUNET_free (peer); | ||
585 | } | ||
586 | |||
587 | |||
588 | /** | ||
589 | * Iterator over all peers to clean up. | ||
590 | * | ||
591 | * @param cls NULL | ||
592 | * @param key peer->address | ||
593 | * @param value the peer to destroy | ||
594 | * @return #GNUNET_OK to continue to iterate | ||
595 | */ | ||
596 | static int | ||
597 | get_peer_delete_it (void *cls, | ||
598 | const struct GNUNET_HashCode *key, | ||
599 | void *value) | ||
600 | { | ||
601 | struct PeerAddress *peer = value; | ||
602 | (void) cls; | ||
603 | (void) key; | ||
604 | peer_destroy (peer); | ||
605 | return GNUNET_OK; | ||
606 | } | ||
607 | |||
608 | |||
609 | /** | ||
610 | * Signature of functions implementing the sending functionality of a | ||
611 | * message queue. | ||
612 | * | ||
613 | * @param mq the message queue | ||
614 | * @param msg the message to send | ||
615 | * @param impl_state our `struct PeerAddress` | ||
616 | */ | ||
617 | static void | ||
618 | mq_send_d (struct GNUNET_MQ_Handle *mq, | ||
619 | const struct GNUNET_MessageHeader *msg, | ||
620 | void *impl_state) | ||
621 | { | ||
622 | struct PeerAddress *peer = impl_state; | ||
623 | uint16_t msize = ntohs (msg->size); | ||
624 | ssize_t send_len; | ||
625 | |||
626 | if (NULL == peer->conn->conn) | ||
627 | { | ||
628 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
629 | "peer never established quic connection\n"); | ||
630 | return; | ||
631 | } | ||
632 | |||
633 | GNUNET_assert (mq == peer->d_mq); | ||
634 | if (msize > peer->d_mtu) | ||
635 | { | ||
636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
637 | "msize: %u, mtu: %lu\n", | ||
638 | msize, | ||
639 | peer->d_mtu); | ||
640 | GNUNET_break (0); | ||
641 | if (GNUNET_YES != peer->peer_destroy_called) | ||
642 | { | ||
643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
644 | "peer destroy called, destroying peer\n"); | ||
645 | peer_destroy (peer); | ||
646 | } | ||
647 | return; | ||
648 | } | ||
649 | reschedule_peer_timeout (peer); | ||
650 | |||
651 | send_len = quiche_conn_stream_send (peer->conn->conn, 4, (uint8_t *) msg, | ||
652 | msize, false); | ||
653 | if (send_len != msize) | ||
654 | { | ||
655 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
656 | "tried to send message and quiche returned %zd", send_len); | ||
657 | return; | ||
658 | } | ||
659 | flush_egress (peer->conn); | ||
660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
661 | "sent a message of %zd bytes\n", send_len); | ||
662 | GNUNET_MQ_impl_send_continue (mq); | ||
663 | } | ||
664 | |||
665 | |||
666 | /** | ||
667 | * Signature of functions implementing the destruction of a message | ||
668 | * queue. Implementations must not free @a mq, but should take care | ||
669 | * of @a impl_state. | ||
670 | * | ||
671 | * @param mq the message queue to destroy | ||
672 | * @param impl_state our `struct PeerAddress` | ||
673 | */ | ||
674 | static void | ||
675 | mq_destroy_d (struct GNUNET_MQ_Handle *mq, void *impl_state) | ||
676 | { | ||
677 | struct PeerAddress *peer = impl_state; | ||
678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
679 | "Default MQ destroyed\n"); | ||
680 | if (mq == peer->d_mq) | ||
681 | { | ||
682 | peer->d_mq = NULL; | ||
683 | if (GNUNET_YES != peer->peer_destroy_called) | ||
684 | peer_destroy (peer); | ||
685 | } | ||
686 | } | ||
687 | |||
688 | |||
689 | /** | ||
690 | * Implementation function that cancels the currently sent message. | ||
691 | * | ||
692 | * @param mq message queue | ||
693 | * @param impl_state our `struct PeerAddress` | ||
694 | */ | ||
695 | static void | ||
696 | mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state) | ||
697 | { | ||
698 | /* Cancellation is impossible with QUIC; bail */ | ||
699 | GNUNET_assert (0); | ||
700 | } | ||
701 | |||
702 | |||
703 | /** | ||
704 | * Generic error handler, called with the appropriate | ||
705 | * error code and the same closure specified at the creation of | ||
706 | * the message queue. | ||
707 | * Not every message queue implementation supports an error handler. | ||
708 | * | ||
709 | * @param cls our `struct ReceiverAddress` | ||
710 | * @param error error code | ||
711 | */ | ||
712 | static void | ||
713 | mq_error (void *cls, enum GNUNET_MQ_Error error) | ||
714 | { | ||
715 | struct PeerAddress *peer = cls; | ||
716 | |||
717 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
718 | "MQ error in queue to %s: %d\n", | ||
719 | GNUNET_i2s (&peer->target), | ||
720 | (int) error); | ||
721 | peer_destroy (peer); | ||
722 | } | ||
723 | |||
724 | |||
725 | /** | ||
726 | * Convert UDP bind specification to a `struct sockaddr *` | ||
727 | * | ||
728 | * @param bindto bind specification to convert | ||
729 | * @param[out] sock_len set to the length of the address | ||
730 | * @return converted bindto specification | ||
731 | */ | ||
732 | static struct sockaddr * | ||
733 | udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | ||
734 | { | ||
735 | struct sockaddr *in; | ||
736 | unsigned int port; | ||
737 | char dummy[2]; | ||
738 | char *colon; | ||
739 | char *cp; | ||
740 | |||
741 | if (1 == sscanf (bindto, "%u%1s", &port, dummy)) | ||
742 | { | ||
743 | /* interpreting value as just a PORT number */ | ||
744 | if (port > UINT16_MAX) | ||
745 | { | ||
746 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
747 | "BINDTO specification `%s' invalid: value too large for port\n", | ||
748 | bindto); | ||
749 | return NULL; | ||
750 | } | ||
751 | if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) || | ||
752 | (GNUNET_YES == | ||
753 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
754 | COMMUNICATOR_CONFIG_SECTION, | ||
755 | "DISABLE_V6"))) | ||
756 | { | ||
757 | struct sockaddr_in *i4; | ||
758 | |||
759 | i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); | ||
760 | i4->sin_family = AF_INET; | ||
761 | i4->sin_port = htons ((uint16_t) port); | ||
762 | *sock_len = sizeof(struct sockaddr_in); | ||
763 | in = (struct sockaddr *) i4; | ||
764 | } | ||
765 | else | ||
766 | { | ||
767 | struct sockaddr_in6 *i6; | ||
768 | |||
769 | i6 = GNUNET_malloc (sizeof(struct sockaddr_in6)); | ||
770 | i6->sin6_family = AF_INET6; | ||
771 | i6->sin6_port = htons ((uint16_t) port); | ||
772 | *sock_len = sizeof(struct sockaddr_in6); | ||
773 | in = (struct sockaddr *) i6; | ||
774 | } | ||
775 | return in; | ||
776 | } | ||
777 | cp = GNUNET_strdup (bindto); | ||
778 | colon = strrchr (cp, ':'); | ||
779 | if (NULL != colon) | ||
780 | { | ||
781 | /* interpret value after colon as port */ | ||
782 | *colon = '\0'; | ||
783 | colon++; | ||
784 | if (1 == sscanf (colon, "%u%1s", &port, dummy)) | ||
785 | { | ||
786 | /* interpreting value as just a PORT number */ | ||
787 | if (port > UINT16_MAX) | ||
788 | { | ||
789 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
790 | "BINDTO specification `%s' invalid: value too large for port\n", | ||
791 | bindto); | ||
792 | GNUNET_free (cp); | ||
793 | return NULL; | ||
794 | } | ||
795 | } | ||
796 | else | ||
797 | { | ||
798 | GNUNET_log ( | ||
799 | GNUNET_ERROR_TYPE_ERROR, | ||
800 | "BINDTO specification `%s' invalid: last ':' not followed by number\n", | ||
801 | bindto); | ||
802 | GNUNET_free (cp); | ||
803 | return NULL; | ||
804 | } | ||
805 | } | ||
806 | else | ||
807 | { | ||
808 | /* interpret missing port as 0, aka pick any free one */ | ||
809 | port = 0; | ||
810 | } | ||
811 | { | ||
812 | /* try IPv4 */ | ||
813 | struct sockaddr_in v4; | ||
814 | |||
815 | memset (&v4, 0, sizeof(v4)); | ||
816 | if (1 == inet_pton (AF_INET, cp, &v4.sin_addr)) | ||
817 | { | ||
818 | v4.sin_family = AF_INET; | ||
819 | v4.sin_port = htons ((uint16_t) port); | ||
820 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
821 | v4.sin_len = sizeof(struct sockaddr_in); | ||
822 | #endif | ||
823 | in = GNUNET_memdup (&v4, sizeof(struct sockaddr_in)); | ||
824 | *sock_len = sizeof(struct sockaddr_in); | ||
825 | GNUNET_free (cp); | ||
826 | return in; | ||
827 | } | ||
828 | } | ||
829 | { | ||
830 | /* try IPv6 */ | ||
831 | struct sockaddr_in6 v6; | ||
832 | const char *start; | ||
833 | |||
834 | memset (&v6, 0, sizeof(v6)); | ||
835 | start = cp; | ||
836 | if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) | ||
837 | { | ||
838 | start++; /* skip over '[' */ | ||
839 | cp[strlen (cp) - 1] = '\0'; /* eat ']' */ | ||
840 | } | ||
841 | if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | ||
842 | { | ||
843 | v6.sin6_family = AF_INET6; | ||
844 | v6.sin6_port = htons ((uint16_t) port); | ||
845 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
846 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); | ||
847 | #endif | ||
848 | in = GNUNET_memdup (&v6, sizeof(v6)); | ||
849 | *sock_len = sizeof(v6); | ||
850 | GNUNET_free (cp); | ||
851 | return in; | ||
852 | } | ||
853 | } | ||
854 | /* #5528 FIXME (feature!): maybe also try getnameinfo()? */ | ||
855 | GNUNET_free (cp); | ||
856 | return NULL; | ||
857 | } | ||
858 | |||
859 | |||
860 | /** | ||
861 | * Setup the MQ for the @a peer. If a queue exists, | ||
862 | * the existing one is destroyed. Then the MTU is | ||
863 | * recalculated and a fresh queue is initialized. | ||
864 | * | ||
865 | * @param peer peer to setup MQ for | ||
866 | */ | ||
867 | static void | ||
868 | setup_peer_mq (struct PeerAddress *peer) | ||
869 | { | ||
870 | size_t base_mtu; | ||
871 | |||
872 | switch (peer->address->sa_family) | ||
873 | { | ||
874 | case AF_INET: | ||
875 | base_mtu = 1480 /* Ethernet MTU, 1500 - Ethernet header - VLAN tag */ | ||
876 | - sizeof(struct GNUNET_TUN_IPv4Header) /* 20 */ | ||
877 | - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */; | ||
878 | break; | ||
879 | |||
880 | case AF_INET6: | ||
881 | base_mtu = 1280 /* Minimum MTU required by IPv6 */ | ||
882 | - sizeof(struct GNUNET_TUN_IPv6Header) /* 40 */ | ||
883 | - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */; | ||
884 | break; | ||
885 | |||
886 | default: | ||
887 | GNUNET_assert (0); | ||
888 | break; | ||
889 | } | ||
890 | /* MTU == base_mtu */ | ||
891 | peer->d_mtu = base_mtu; | ||
892 | |||
893 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
894 | "Setting up MQs and QHs\n"); | ||
895 | /* => Effective MTU for CORE will range from 1080 (IPv6 + KX) to | ||
896 | 1404 (IPv4 + Box) bytes, depending on circumstances... */ | ||
897 | |||
898 | if (NULL == peer->d_mq) | ||
899 | peer->d_mq = GNUNET_MQ_queue_for_callbacks (&mq_send_d, | ||
900 | &mq_destroy_d, | ||
901 | &mq_cancel, | ||
902 | peer, | ||
903 | NULL, | ||
904 | &mq_error, | ||
905 | peer); | ||
906 | peer->d_qh = | ||
907 | GNUNET_TRANSPORT_communicator_mq_add (ch, | ||
908 | &peer->target, | ||
909 | peer->foreign_addr, | ||
910 | 1000, | ||
911 | GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, | ||
912 | 0, /* Priority */ | ||
913 | peer->nt, | ||
914 | GNUNET_TRANSPORT_CS_OUTBOUND, | ||
915 | peer->d_mq); | ||
916 | } | ||
917 | |||
918 | |||
919 | /** | ||
920 | * Taken from: UDP communicator | ||
921 | * Converts @a address to the address string format used by this | ||
922 | * communicator in HELLOs. | ||
923 | * | ||
924 | * @param address the address to convert, must be AF_INET or AF_INET6. | ||
925 | * @param address_len number of bytes in @a address | ||
926 | * @return string representation of @a address | ||
927 | */ | ||
928 | static char * | ||
929 | sockaddr_to_udpaddr_string (const struct sockaddr *address, | ||
930 | socklen_t address_len) | ||
931 | { | ||
932 | char *ret; | ||
933 | |||
934 | switch (address->sa_family) | ||
935 | { | ||
936 | case AF_INET: | ||
937 | GNUNET_asprintf (&ret, | ||
938 | "%s-%s", | ||
939 | COMMUNICATOR_ADDRESS_PREFIX, | ||
940 | GNUNET_a2s (address, address_len)); | ||
941 | break; | ||
942 | |||
943 | case AF_INET6: | ||
944 | GNUNET_asprintf (&ret, | ||
945 | "%s-%s", | ||
946 | COMMUNICATOR_ADDRESS_PREFIX, | ||
947 | GNUNET_a2s (address, address_len)); | ||
948 | break; | ||
949 | |||
950 | default: | ||
951 | GNUNET_assert (0); | ||
952 | } | ||
953 | return ret; | ||
954 | } | ||
955 | |||
956 | |||
957 | /** | ||
958 | * Function called when the transport service has received a | ||
959 | * backchannel message for this communicator (!) via a different return | ||
960 | * path. Should be an acknowledgement. | ||
961 | * | ||
962 | * @param cls closure, NULL | ||
963 | * @param sender which peer sent the notification | ||
964 | * @param msg payload | ||
965 | */ | ||
966 | static void | ||
967 | notify_cb (void *cls, | ||
968 | const struct GNUNET_PeerIdentity *sender, | ||
969 | const struct GNUNET_MessageHeader *msg) | ||
970 | { | ||
971 | // const struct UDPAck *ack; | ||
972 | |||
973 | // (void) cls; | ||
974 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
975 | // "Storing UDPAck received from backchannel from %s\n", | ||
976 | // GNUNET_i2s_full (sender)); | ||
977 | // if ((ntohs (msg->type) != GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK) || | ||
978 | // (ntohs (msg->size) != sizeof(struct UDPAck))) | ||
979 | // { | ||
980 | // GNUNET_break_op (0); | ||
981 | // return; | ||
982 | // } | ||
983 | // ack = (const struct UDPAck *) msg; | ||
984 | // GNUNET_CONTAINER_multipeermap_get_multiple (receivers, | ||
985 | // sender, | ||
986 | // &handle_ack, | ||
987 | // (void *) ack); | ||
988 | } | ||
989 | |||
990 | |||
991 | /** | ||
992 | * Task run to check #receiver_heap and #sender_heap for timeouts. | ||
993 | * | ||
994 | * @param cls unused, NULL | ||
995 | */ | ||
996 | static void | ||
997 | check_timeouts (void *cls) | ||
998 | { | ||
999 | // struct GNUNET_TIME_Relative st; | ||
1000 | // struct GNUNET_TIME_Relative rt; | ||
1001 | // struct GNUNET_TIME_Relative delay; | ||
1002 | // struct ReceiverAddress *receiver; | ||
1003 | // struct SenderAddress *sender; | ||
1004 | |||
1005 | // (void) cls; | ||
1006 | // timeout_task = NULL; | ||
1007 | // rt = GNUNET_TIME_UNIT_FOREVER_REL; | ||
1008 | // while (NULL != (receiver = GNUNET_CONTAINER_heap_peek (receivers_heap))) | ||
1009 | // { | ||
1010 | // /* if (GNUNET_YES != receiver->receiver_destroy_called) */ | ||
1011 | // /* { */ | ||
1012 | // rt = GNUNET_TIME_absolute_get_remaining (receiver->timeout); | ||
1013 | // if (0 != rt.rel_value_us) | ||
1014 | // break; | ||
1015 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1016 | // "Receiver timed out\n"); | ||
1017 | // receiver_destroy (receiver); | ||
1018 | // // } | ||
1019 | // } | ||
1020 | // st = GNUNET_TIME_UNIT_FOREVER_REL; | ||
1021 | // while (NULL != (sender = GNUNET_CONTAINER_heap_peek (senders_heap))) | ||
1022 | // { | ||
1023 | // if (GNUNET_YES != sender->sender_destroy_called) | ||
1024 | // { | ||
1025 | // st = GNUNET_TIME_absolute_get_remaining (sender->timeout); | ||
1026 | // if (0 != st.rel_value_us) | ||
1027 | // break; | ||
1028 | // sender_destroy (sender); | ||
1029 | // } | ||
1030 | // } | ||
1031 | // delay = GNUNET_TIME_relative_min (rt, st); | ||
1032 | // if (delay.rel_value_us < GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) | ||
1033 | // timeout_task = GNUNET_SCHEDULER_add_delayed (delay, &check_timeouts, NULL); | ||
1034 | } | ||
1035 | |||
1036 | |||
1037 | /** | ||
1038 | * Function called by the transport service to initialize a | ||
1039 | * message queue given address information about another peer. | ||
1040 | * If and when the communication channel is established, the | ||
1041 | * communicator must call #GNUNET_TRANSPORT_communicator_mq_add() | ||
1042 | * to notify the service that the channel is now up. It is | ||
1043 | * the responsibility of the communicator to manage sane | ||
1044 | * retries and timeouts for any @a peer/@a address combination | ||
1045 | * provided by the transport service. Timeouts and retries | ||
1046 | * do not need to be signalled to the transport service. | ||
1047 | * | ||
1048 | * @param cls closure | ||
1049 | * @param peer identity of the other peer | ||
1050 | * @param address where to send the message, human-readable | ||
1051 | * communicator-specific format, 0-terminated, UTF-8 | ||
1052 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is | ||
1053 | * invalid | ||
1054 | */ | ||
1055 | static int | ||
1056 | mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const | ||
1057 | char *address) | ||
1058 | { | ||
1059 | struct PeerAddress *peer; | ||
1060 | const char *path; | ||
1061 | struct sockaddr *in; | ||
1062 | socklen_t in_len; | ||
1063 | struct GNUNET_HashCode addr_key; | ||
1064 | uint8_t scid[LOCAL_CONN_ID_LEN]; | ||
1065 | |||
1066 | struct quic_conn *q_conn; | ||
1067 | char *bindto; | ||
1068 | socklen_t local_in_len; | ||
1069 | struct sockaddr *local_addr; | ||
1070 | |||
1071 | if (GNUNET_OK != | ||
1072 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
1073 | COMMUNICATOR_CONFIG_SECTION, | ||
1074 | "BINDTO", | ||
1075 | &bindto)) | ||
1076 | { | ||
1077 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
1078 | COMMUNICATOR_CONFIG_SECTION, | ||
1079 | "BINDTO"); | ||
1080 | return GNUNET_SYSERR; | ||
1081 | } | ||
1082 | local_addr = udp_address_to_sockaddr (bindto, &local_in_len); | ||
1083 | |||
1084 | if (0 != strncmp (address, | ||
1085 | COMMUNICATOR_ADDRESS_PREFIX "-", | ||
1086 | strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) | ||
1087 | { | ||
1088 | GNUNET_break_op (0); | ||
1089 | return GNUNET_SYSERR; | ||
1090 | } | ||
1091 | path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; | ||
1092 | in = udp_address_to_sockaddr (path, &in_len); | ||
1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mq_init in_len length before: %d\n", | ||
1094 | in_len); | ||
1095 | /** | ||
1096 | * If we already have a queue with this peer, ignore | ||
1097 | */ | ||
1098 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address string in mq_init: %s\n", | ||
1099 | address); | ||
1100 | GNUNET_CRYPTO_hash (address, strlen (address), &addr_key); | ||
1101 | peer = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key); | ||
1102 | if (NULL != peer) | ||
1103 | { | ||
1104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1105 | "ignoring transport service mq request, we already have an mq with this peer (address)\n"); | ||
1106 | return GNUNET_SYSERR; | ||
1107 | } | ||
1108 | peer = GNUNET_new (struct PeerAddress); | ||
1109 | peer->address = in; | ||
1110 | peer->address_len = in_len; | ||
1111 | peer->target = *peer_id; | ||
1112 | peer->id_rcvd = GNUNET_YES; | ||
1113 | peer->is_receiver = GNUNET_YES; | ||
1114 | peer->nt = GNUNET_NT_scanner_get_type (is, in, in_len); | ||
1115 | peer->timeout = | ||
1116 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
1117 | GNUNET_STATISTICS_set (stats, | ||
1118 | "# peers active", | ||
1119 | GNUNET_CONTAINER_multihashmap_size (addr_map), | ||
1120 | GNUNET_NO); | ||
1121 | peer->foreign_addr = | ||
1122 | sockaddr_to_udpaddr_string (peer->address, peer->address_len); | ||
1123 | /** | ||
1124 | * Insert peer into hashmap | ||
1125 | */ | ||
1126 | GNUNET_CONTAINER_multihashmap_put (addr_map, &addr_key, | ||
1127 | peer, | ||
1128 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
1129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1130 | "mq_init added new peer to the addr map\n"); | ||
1131 | /** | ||
1132 | * Before setting up peer mq, initiate a quic connection to the target (perform handshake w/ quiche) | ||
1133 | */ | ||
1134 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, scid, | ||
1135 | LOCAL_CONN_ID_LEN); | ||
1136 | q_conn = GNUNET_new (struct quic_conn); | ||
1137 | GNUNET_memcpy (q_conn->cid, scid, LOCAL_CONN_ID_LEN); | ||
1138 | peer->conn = q_conn; | ||
1139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1140 | "attempting to perform QUIC handshake with peer\n"); | ||
1141 | q_conn->conn = quiche_connect (peer->foreign_addr, scid, LOCAL_CONN_ID_LEN, | ||
1142 | local_addr, | ||
1143 | local_in_len, peer->address, peer->address_len, | ||
1144 | config); | ||
1145 | flush_egress (peer->conn); | ||
1146 | GNUNET_free (local_addr); | ||
1147 | return GNUNET_OK; | ||
1148 | /** | ||
1149 | * TODO: handle this | ||
1150 | */ | ||
1151 | // if (NULL == timeout_task) | ||
1152 | // timeout_task = GNUNET_SCHEDULER_add_now (&check_timeouts, NULL); | ||
1153 | } | ||
1154 | |||
1155 | |||
1156 | static void | ||
1157 | try_connection_reversal (void *cls, | ||
1158 | const struct sockaddr *addr, | ||
1159 | socklen_t addrlen) | ||
1160 | { | ||
1161 | /* FIXME: support reversal: #5529 */ | ||
1162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1163 | "No connection reversal implemented!"); | ||
1164 | } | ||
1165 | |||
1166 | |||
1167 | /** | ||
1168 | * Signature of the callback passed to #GNUNET_NAT_register() for | ||
1169 | * a function to call whenever our set of 'valid' addresses changes. | ||
1170 | * | ||
1171 | * @param cls closure | ||
1172 | * @param app_ctx[in,out] location where the app can store stuff | ||
1173 | * on add and retrieve it on remove | ||
1174 | * @param add_remove #GNUNET_YES to add a new public IP address, | ||
1175 | * #GNUNET_NO to remove a previous (now invalid) one | ||
1176 | * @param ac address class the address belongs to | ||
1177 | * @param addr either the previous or the new public IP address | ||
1178 | * @param addrlen actual length of the @a addr | ||
1179 | */ | ||
1180 | static void | ||
1181 | nat_address_cb (void *cls, | ||
1182 | void **app_ctx, | ||
1183 | int add_remove, | ||
1184 | enum GNUNET_NAT_AddressClass ac, | ||
1185 | const struct sockaddr *addr, | ||
1186 | socklen_t addrlen) | ||
1187 | { | ||
1188 | char *my_addr; | ||
1189 | struct GNUNET_TRANSPORT_AddressIdentifier *ai; | ||
1190 | |||
1191 | if (GNUNET_YES == add_remove) | ||
1192 | { | ||
1193 | enum GNUNET_NetworkType nt; | ||
1194 | |||
1195 | GNUNET_asprintf (&my_addr, | ||
1196 | "%s-%s", | ||
1197 | COMMUNICATOR_ADDRESS_PREFIX, | ||
1198 | GNUNET_a2s (addr, addrlen)); | ||
1199 | nt = GNUNET_NT_scanner_get_type (is, addr, addrlen); | ||
1200 | ai = | ||
1201 | GNUNET_TRANSPORT_communicator_address_add (ch, | ||
1202 | my_addr, | ||
1203 | nt, | ||
1204 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
1205 | GNUNET_free (my_addr); | ||
1206 | *app_ctx = ai; | ||
1207 | } | ||
1208 | else | ||
1209 | { | ||
1210 | ai = *app_ctx; | ||
1211 | GNUNET_TRANSPORT_communicator_address_remove (ai); | ||
1212 | *app_ctx = NULL; | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | |||
1217 | /** | ||
1218 | * Shutdown the QUIC communicator. | ||
1219 | * | ||
1220 | * @param cls NULL (always) | ||
1221 | */ | ||
1222 | static void | ||
1223 | do_shutdown (void *cls) | ||
1224 | { | ||
1225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1226 | "do_shutdown\n"); | ||
1227 | GNUNET_CONTAINER_multihashmap_iterate (addr_map, &get_peer_delete_it, NULL); | ||
1228 | GNUNET_CONTAINER_multihashmap_destroy (addr_map); | ||
1229 | quiche_config_free (config); | ||
1230 | |||
1231 | if (NULL != timeout_task) | ||
1232 | { | ||
1233 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
1234 | timeout_task = NULL; | ||
1235 | } | ||
1236 | if (NULL != read_task) | ||
1237 | { | ||
1238 | GNUNET_SCHEDULER_cancel (read_task); | ||
1239 | read_task = NULL; | ||
1240 | } | ||
1241 | if (NULL != udp_sock) | ||
1242 | { | ||
1243 | GNUNET_break (GNUNET_OK == | ||
1244 | GNUNET_NETWORK_socket_close (udp_sock)); | ||
1245 | udp_sock = NULL; | ||
1246 | } | ||
1247 | if (NULL != ch) | ||
1248 | { | ||
1249 | GNUNET_TRANSPORT_communicator_disconnect (ch); | ||
1250 | ch = NULL; | ||
1251 | } | ||
1252 | if (NULL != ah) | ||
1253 | { | ||
1254 | GNUNET_TRANSPORT_application_done (ah); | ||
1255 | ah = NULL; | ||
1256 | } | ||
1257 | if (NULL != my_private_key) | ||
1258 | { | ||
1259 | GNUNET_free (my_private_key); | ||
1260 | my_private_key = NULL; | ||
1261 | } | ||
1262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1263 | "do_shutdown finished\n"); | ||
1264 | } | ||
1265 | |||
1266 | |||
1267 | static void | ||
1268 | sock_read (void *cls) | ||
1269 | { | ||
1270 | struct sockaddr_storage sa; | ||
1271 | struct sockaddr_in *addr_verify; | ||
1272 | socklen_t salen = sizeof(sa); | ||
1273 | uint8_t buf[UINT16_MAX]; | ||
1274 | uint8_t out[MAX_DATAGRAM_SIZE]; | ||
1275 | ssize_t rcvd; | ||
1276 | |||
1277 | ssize_t process_pkt; | ||
1278 | struct QUIC_header quic_header; | ||
1279 | uint8_t new_cid[LOCAL_CONN_ID_LEN]; | ||
1280 | |||
1281 | struct PeerAddress *peer; | ||
1282 | struct GNUNET_HashCode addr_key; | ||
1283 | |||
1284 | (void) cls; | ||
1285 | quic_header.scid_len = sizeof(quic_header.scid); | ||
1286 | quic_header.dcid_len = sizeof(quic_header.dcid); | ||
1287 | quic_header.odcid_len = sizeof(quic_header.odcid); | ||
1288 | quic_header.token_len = sizeof(quic_header.token); | ||
1289 | /** | ||
1290 | * Get local_addr, in_len for quiche | ||
1291 | */ | ||
1292 | char *bindto; | ||
1293 | socklen_t in_len; | ||
1294 | if (GNUNET_OK != | ||
1295 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
1296 | COMMUNICATOR_CONFIG_SECTION, | ||
1297 | "BINDTO", | ||
1298 | &bindto)) | ||
1299 | { | ||
1300 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
1301 | COMMUNICATOR_CONFIG_SECTION, | ||
1302 | "BINDTO"); | ||
1303 | return; | ||
1304 | } | ||
1305 | struct sockaddr *local_addr = udp_address_to_sockaddr (bindto, &in_len); | ||
1306 | |||
1307 | read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | ||
1308 | udp_sock, | ||
1309 | &sock_read, | ||
1310 | NULL); | ||
1311 | while (1) | ||
1312 | { | ||
1313 | rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock, | ||
1314 | buf, | ||
1315 | sizeof(buf), | ||
1316 | (struct sockaddr *) &sa, | ||
1317 | &salen); | ||
1318 | if (-1 == rcvd) | ||
1319 | { | ||
1320 | if (EAGAIN == errno) | ||
1321 | break; // We are done reading data | ||
1322 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); | ||
1323 | return; | ||
1324 | } | ||
1325 | |||
1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1327 | "Read %lu bytes\n", rcvd); | ||
1328 | |||
1329 | if (-1 == rcvd) | ||
1330 | { | ||
1331 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); | ||
1332 | return; | ||
1333 | } | ||
1334 | /** | ||
1335 | * FIXME: hashing address string vs ip/port. It is not ideal that | ||
1336 | * we hash the string, instead of the binary representation, but | ||
1337 | * for now it is certainly less code. | ||
1338 | * Note that simply hashing the sockaddr does NOT work because the | ||
1339 | * the struct is not portable. | ||
1340 | */ | ||
1341 | const char *addr_string = sockaddr_to_udpaddr_string ((const struct | ||
1342 | sockaddr *) &sa, | ||
1343 | salen); | ||
1344 | GNUNET_CRYPTO_hash (addr_string, strlen (addr_string), | ||
1345 | &addr_key); | ||
1346 | GNUNET_free (addr_string); | ||
1347 | peer = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key); | ||
1348 | |||
1349 | if (NULL == peer) | ||
1350 | { | ||
1351 | /** | ||
1352 | * Create new PeerAddress (receiver) with id_rcvd = false | ||
1353 | */ | ||
1354 | peer = GNUNET_new (struct PeerAddress); | ||
1355 | peer->address = GNUNET_memdup (&sa, salen); | ||
1356 | peer->address_len = salen; | ||
1357 | peer->id_rcvd = GNUNET_NO; | ||
1358 | peer->id_sent = GNUNET_NO; | ||
1359 | peer->is_receiver = GNUNET_NO; | ||
1360 | peer->conn = NULL; | ||
1361 | peer->foreign_addr = sockaddr_to_udpaddr_string (peer->address, | ||
1362 | peer->address_len); | ||
1363 | /** | ||
1364 | * TODO: after connection established | ||
1365 | */ | ||
1366 | // setup_peer_mq (peer); | ||
1367 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (addr_map, | ||
1368 | &addr_key, | ||
1369 | peer, | ||
1370 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
1371 | { | ||
1372 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1373 | "tried to add duplicate address into address map\n"); | ||
1374 | return; | ||
1375 | } | ||
1376 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1377 | "sock_read added new peer to address map\n"); | ||
1378 | } | ||
1379 | |||
1380 | /** | ||
1381 | * Parse QUIC info | ||
1382 | */ | ||
1383 | int rc = quiche_header_info (buf, rcvd, LOCAL_CONN_ID_LEN, | ||
1384 | &quic_header.version, | ||
1385 | &quic_header.type, quic_header.scid, | ||
1386 | &quic_header.scid_len, quic_header.dcid, | ||
1387 | &quic_header.dcid_len, | ||
1388 | quic_header.token, &quic_header.token_len); | ||
1389 | if (0 > rc) | ||
1390 | { | ||
1391 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1392 | "failed to parse quic header: %d\n", | ||
1393 | rc); | ||
1394 | return; | ||
1395 | } | ||
1396 | |||
1397 | /** | ||
1398 | * New QUIC connection with peer | ||
1399 | */ | ||
1400 | if (NULL == peer->conn) | ||
1401 | { | ||
1402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1403 | "attempting to create new connection\n"); | ||
1404 | if (0 == quiche_version_is_supported (quic_header.version)) | ||
1405 | { | ||
1406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1407 | "quic version negotiation initiated\n"); | ||
1408 | /** | ||
1409 | * FIXME variables are redeclared often. Refactor either | ||
1410 | * to declare variables once in the beginning or refactor into | ||
1411 | * method. | ||
1412 | * | ||
1413 | * Write a version negotiation packet to "out" | ||
1414 | */ | ||
1415 | ssize_t written = quiche_negotiate_version (quic_header.scid, | ||
1416 | quic_header.scid_len, | ||
1417 | quic_header.dcid, | ||
1418 | quic_header.dcid_len, | ||
1419 | out, sizeof(out)); | ||
1420 | if (0 > written) | ||
1421 | { | ||
1422 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1423 | "quiche failed to generate version negotiation packet\n"); | ||
1424 | return; | ||
1425 | } | ||
1426 | ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock, | ||
1427 | out, | ||
1428 | written, | ||
1429 | (struct sockaddr*) &sa, | ||
1430 | salen); | ||
1431 | if (sent != written) | ||
1432 | { | ||
1433 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1434 | "failed to send version negotiation packet to peer\n"); | ||
1435 | return; | ||
1436 | } | ||
1437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1438 | "sent %zd bytes to peer during version negotiation\n", | ||
1439 | sent); | ||
1440 | return; | ||
1441 | } | ||
1442 | |||
1443 | if (0 == quic_header.token_len) | ||
1444 | { | ||
1445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "quic stateless retry\n"); | ||
1446 | mint_token (quic_header.dcid, quic_header.dcid_len, &sa, salen, | ||
1447 | quic_header.token, &quic_header.token_len); | ||
1448 | |||
1449 | uint8_t new_cid[LOCAL_CONN_ID_LEN]; | ||
1450 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, new_cid, | ||
1451 | LOCAL_CONN_ID_LEN); | ||
1452 | |||
1453 | ssize_t written = quiche_retry (quic_header.scid, quic_header.scid_len, | ||
1454 | quic_header.dcid, quic_header.dcid_len, | ||
1455 | new_cid, LOCAL_CONN_ID_LEN, | ||
1456 | quic_header.token, | ||
1457 | quic_header.token_len, | ||
1458 | quic_header.version, out, sizeof(out)); | ||
1459 | if (0 > written) | ||
1460 | { | ||
1461 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1462 | "quiche failed to write retry packet\n"); | ||
1463 | return; | ||
1464 | } | ||
1465 | ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock, | ||
1466 | out, | ||
1467 | written, | ||
1468 | (struct sockaddr*) &sa, | ||
1469 | salen); | ||
1470 | if (written != sent) | ||
1471 | { | ||
1472 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failed to send retry packet\n"); | ||
1473 | return; | ||
1474 | } | ||
1475 | |||
1476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent); | ||
1477 | continue; | ||
1478 | } | ||
1479 | |||
1480 | if (GNUNET_OK != validate_token (quic_header.token, quic_header.token_len, | ||
1481 | &sa, salen, | ||
1482 | quic_header.odcid, | ||
1483 | &quic_header.odcid_len)) | ||
1484 | { | ||
1485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1486 | "invalid address validation token created\n"); | ||
1487 | return; | ||
1488 | } | ||
1489 | peer->conn = create_conn (quic_header.dcid, quic_header.dcid_len, | ||
1490 | quic_header.odcid, quic_header.odcid_len, | ||
1491 | local_addr, in_len, | ||
1492 | &sa, salen); | ||
1493 | if (NULL == peer->conn) | ||
1494 | { | ||
1495 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1496 | "failed to create quic connection with peer\n"); | ||
1497 | return; | ||
1498 | } | ||
1499 | } // null connection | ||
1500 | |||
1501 | quiche_recv_info recv_info = { | ||
1502 | (struct sockaddr *) &sa, | ||
1503 | salen, | ||
1504 | |||
1505 | local_addr, | ||
1506 | in_len, | ||
1507 | }; | ||
1508 | /** | ||
1509 | * Send our PeerIdentity if the connection is established now | ||
1510 | */ | ||
1511 | if (quiche_conn_is_established (peer->conn->conn) && ! peer->id_sent && | ||
1512 | peer->is_receiver) | ||
1513 | { | ||
1514 | ssize_t send_len; | ||
1515 | |||
1516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1517 | "handshake established with peer, sending our peer id\n"); | ||
1518 | send_len = quiche_conn_stream_send (peer->conn->conn, STREAMID_BI, | ||
1519 | (const uint8_t *) &my_identity, | ||
1520 | sizeof(my_identity), | ||
1521 | false); | ||
1522 | if (0 > send_len) | ||
1523 | { | ||
1524 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1525 | "failed to write peer identity packet. quiche error: %zd\n", | ||
1526 | send_len); | ||
1527 | return; | ||
1528 | } | ||
1529 | flush_egress (peer->conn); | ||
1530 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer identity sent to peer\n"); | ||
1531 | peer->id_sent = GNUNET_YES; | ||
1532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "setting up peer mq\n"); | ||
1533 | setup_peer_mq (peer); | ||
1534 | /** | ||
1535 | * After this, we should be all good to send/recv data | ||
1536 | */ | ||
1537 | } | ||
1538 | process_pkt = quiche_conn_recv (peer->conn->conn, buf, rcvd, &recv_info); | ||
1539 | if (0 > process_pkt) | ||
1540 | { | ||
1541 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1542 | "quiche failed to process received packet: %zd\n", | ||
1543 | process_pkt); | ||
1544 | return; | ||
1545 | } | ||
1546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1547 | "quiche processed %zd bytes\n", process_pkt); | ||
1548 | // Check for data on all available streams if the connection is established | ||
1549 | if (GNUNET_YES == quiche_conn_is_established (peer->conn->conn)) | ||
1550 | { | ||
1551 | recv_from_streams (peer); | ||
1552 | } | ||
1553 | /** | ||
1554 | * TODO: Should we use a list instead of hashmap? | ||
1555 | * Overhead for hashing function, O(1) retrieval vs O(n) iteration with n=30? | ||
1556 | * | ||
1557 | * TODO: Is iteration necessary as in the quiche server example? | ||
1558 | */ | ||
1559 | quiche_stats stats; | ||
1560 | quiche_path_stats path_stats; | ||
1561 | |||
1562 | flush_egress (peer->conn); | ||
1563 | |||
1564 | if (quiche_conn_is_closed (peer->conn->conn)) | ||
1565 | { | ||
1566 | quiche_conn_stats (peer->conn->conn, &stats); | ||
1567 | quiche_conn_path_stats (peer->conn->conn, 0, &path_stats); | ||
1568 | |||
1569 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1570 | "connection closed. quiche stats: sent=%zu, recv=%zu\n", | ||
1571 | stats.sent, stats.recv); | ||
1572 | peer_destroy (peer); | ||
1573 | } | ||
1574 | } | ||
1575 | GNUNET_free (local_addr); | ||
1576 | } | ||
1577 | |||
1578 | |||
1579 | /** | ||
1580 | * Setup communicator and launch network interactions. | ||
1581 | * | ||
1582 | * @param cls NULL (always) | ||
1583 | * @param args remaining command-line arguments | ||
1584 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
1585 | * @param c configuration | ||
1586 | */ | ||
1587 | static void | ||
1588 | run (void *cls, | ||
1589 | char *const *args, | ||
1590 | const char *cfgfile, | ||
1591 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
1592 | { | ||
1593 | char *bindto; | ||
1594 | struct sockaddr *in; | ||
1595 | socklen_t in_len; | ||
1596 | struct sockaddr_storage in_sto; | ||
1597 | socklen_t sto_len; | ||
1598 | |||
1599 | (void) cls; | ||
1600 | cfg = c; | ||
1601 | |||
1602 | if (GNUNET_OK != | ||
1603 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
1604 | COMMUNICATOR_CONFIG_SECTION, | ||
1605 | "BINDTO", | ||
1606 | &bindto)) | ||
1607 | { | ||
1608 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
1609 | COMMUNICATOR_CONFIG_SECTION, | ||
1610 | "BINDTO"); | ||
1611 | return; | ||
1612 | } | ||
1613 | |||
1614 | in = udp_address_to_sockaddr (bindto, &in_len); | ||
1615 | |||
1616 | if (NULL == in) | ||
1617 | { | ||
1618 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1619 | "Failed to setup UDP socket address with path `%s'\n", | ||
1620 | bindto); | ||
1621 | GNUNET_free (bindto); | ||
1622 | return; | ||
1623 | } | ||
1624 | udp_sock = | ||
1625 | GNUNET_NETWORK_socket_create (in->sa_family, | ||
1626 | SOCK_DGRAM, | ||
1627 | IPPROTO_UDP); | ||
1628 | if (NULL == udp_sock) | ||
1629 | { | ||
1630 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | ||
1631 | GNUNET_free (in); | ||
1632 | GNUNET_free (bindto); | ||
1633 | return; | ||
1634 | } | ||
1635 | if (AF_INET6 == in->sa_family) | ||
1636 | have_v6_socket = GNUNET_YES; | ||
1637 | if (GNUNET_OK != | ||
1638 | GNUNET_NETWORK_socket_bind (udp_sock, | ||
1639 | in, | ||
1640 | in_len)) | ||
1641 | { | ||
1642 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
1643 | "bind", | ||
1644 | bindto); | ||
1645 | GNUNET_NETWORK_socket_close (udp_sock); | ||
1646 | udp_sock = NULL; | ||
1647 | GNUNET_free (in); | ||
1648 | GNUNET_free (bindto); | ||
1649 | return; | ||
1650 | } | ||
1651 | sto_len = sizeof(in_sto); | ||
1652 | if (0 != getsockname (GNUNET_NETWORK_get_fd (udp_sock), | ||
1653 | (struct sockaddr *) &in_sto, | ||
1654 | &sto_len)) | ||
1655 | { | ||
1656 | memcpy (&in_sto, in, in_len); | ||
1657 | sto_len = in_len; | ||
1658 | } | ||
1659 | GNUNET_free (in); | ||
1660 | GNUNET_free (bindto); | ||
1661 | in = (struct sockaddr *) &in_sto; | ||
1662 | in_len = sto_len; | ||
1663 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
1664 | "transport", | ||
1665 | "Bound to `%s'\n", | ||
1666 | GNUNET_a2s ((const struct sockaddr *) &in_sto, | ||
1667 | sto_len)); | ||
1668 | switch (in->sa_family) | ||
1669 | { | ||
1670 | case AF_INET: | ||
1671 | my_port = ntohs (((struct sockaddr_in *) in)->sin_port); | ||
1672 | break; | ||
1673 | |||
1674 | case AF_INET6: | ||
1675 | my_port = ntohs (((struct sockaddr_in6 *) in)->sin6_port); | ||
1676 | break; | ||
1677 | |||
1678 | default: | ||
1679 | GNUNET_break (0); | ||
1680 | my_port = 0; | ||
1681 | } | ||
1682 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
1683 | /** | ||
1684 | * Setup QUICHE configuration | ||
1685 | */ | ||
1686 | config = quiche_config_new (QUICHE_PROTOCOL_VERSION); | ||
1687 | quiche_config_verify_peer (config, false); | ||
1688 | /** | ||
1689 | * TODO: configure TLS cert | ||
1690 | */ | ||
1691 | quiche_config_load_cert_chain_from_pem_file (config, "./cert.crt"); | ||
1692 | quiche_config_load_priv_key_from_pem_file (config, "./cert.key"); | ||
1693 | quiche_config_set_application_protos (config, | ||
1694 | (uint8_t *) | ||
1695 | "\x0ahq-interop\x05hq-29\x05hq-28\x05hq-27\x08http/0.9", | ||
1696 | 38); | ||
1697 | quiche_config_set_max_idle_timeout (config, 5000); | ||
1698 | quiche_config_set_max_recv_udp_payload_size (config, 1200); | ||
1699 | quiche_config_set_max_send_udp_payload_size (config, 1200); | ||
1700 | quiche_config_set_initial_max_data (config, 10000000); | ||
1701 | quiche_config_set_initial_max_stream_data_bidi_local (config, 1000000); | ||
1702 | quiche_config_set_initial_max_stream_data_bidi_remote (config, 1000000); | ||
1703 | quiche_config_set_initial_max_stream_data_uni (config, 1000000); | ||
1704 | quiche_config_set_initial_max_streams_bidi (config, 100); | ||
1705 | quiche_config_set_initial_max_streams_uni (config, 100); | ||
1706 | quiche_config_set_cc_algorithm (config, QUICHE_CC_RENO); | ||
1707 | quiche_config_set_disable_active_migration (config, true); | ||
1708 | addr_map = GNUNET_CONTAINER_multihashmap_create (2, GNUNET_NO); | ||
1709 | /** | ||
1710 | * Get our public key for initial packet | ||
1711 | */ | ||
1712 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); | ||
1713 | if (NULL == my_private_key) | ||
1714 | { | ||
1715 | GNUNET_log ( | ||
1716 | GNUNET_ERROR_TYPE_ERROR, | ||
1717 | _ ( | ||
1718 | "Transport service is lacking key configuration settings. Exiting.\n")); | ||
1719 | GNUNET_SCHEDULER_shutdown (); | ||
1720 | return; | ||
1721 | } | ||
1722 | GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_identity.public_key); | ||
1723 | /* start reading */ | ||
1724 | read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | ||
1725 | udp_sock, | ||
1726 | &sock_read, | ||
1727 | NULL); | ||
1728 | ch = GNUNET_TRANSPORT_communicator_connect (cfg, | ||
1729 | COMMUNICATOR_CONFIG_SECTION, | ||
1730 | COMMUNICATOR_ADDRESS_PREFIX, | ||
1731 | GNUNET_TRANSPORT_CC_RELIABLE, | ||
1732 | &mq_init, | ||
1733 | NULL, | ||
1734 | ¬ify_cb, | ||
1735 | NULL); | ||
1736 | is = GNUNET_NT_scanner_init (); | ||
1737 | nat = GNUNET_NAT_register (cfg, | ||
1738 | COMMUNICATOR_CONFIG_SECTION, | ||
1739 | IPPROTO_UDP, | ||
1740 | 1 /* one address */, | ||
1741 | (const struct sockaddr **) &in, | ||
1742 | &in_len, | ||
1743 | &nat_address_cb, | ||
1744 | try_connection_reversal, | ||
1745 | NULL /* closure */); | ||
1746 | if (NULL == ch) | ||
1747 | { | ||
1748 | GNUNET_break (0); | ||
1749 | GNUNET_SCHEDULER_shutdown (); | ||
1750 | return; | ||
1751 | } | ||
1752 | ah = GNUNET_TRANSPORT_application_init (cfg); | ||
1753 | if (NULL == ah) | ||
1754 | { | ||
1755 | GNUNET_break (0); | ||
1756 | GNUNET_SCHEDULER_shutdown (); | ||
1757 | return; | ||
1758 | } | ||
1759 | |||
1760 | /* start broadcasting */ | ||
1761 | // if (GNUNET_YES != | ||
1762 | // GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
1763 | // COMMUNICATOR_CONFIG_SECTION, | ||
1764 | // "DISABLE_BROADCAST")) | ||
1765 | // { | ||
1766 | // broadcast_task = GNUNET_SCHEDULER_add_now (&do_broadcast, NULL); | ||
1767 | // } | ||
1768 | } | ||
1769 | |||
1770 | |||
1771 | int | ||
1772 | main (int argc, char *const *argv) | ||
1773 | { | ||
1774 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
1775 | GNUNET_GETOPT_OPTION_END | ||
1776 | }; | ||
1777 | int ret; | ||
1778 | |||
1779 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
1780 | "transport", | ||
1781 | "Starting quic communicator\n"); | ||
1782 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | ||
1783 | return 2; | ||
1784 | |||
1785 | ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc, | ||
1786 | argv, | ||
1787 | "gnunet-communicator-quic", | ||
1788 | _ ("GNUnet QUIC communicator"), | ||
1789 | options, | ||
1790 | &run, | ||
1791 | NULL)) | ||
1792 | ? 0 | ||
1793 | : 1; | ||
1794 | GNUNET_free_nz ((void *) argv); | ||
1795 | return ret; | ||
1796 | } | ||
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index e2f1e4507..1273465c3 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -82,9 +82,9 @@ | |||
82 | 82 | ||
83 | /** | 83 | /** |
84 | * How often do we rekey based on number of bytes transmitted? | 84 | * How often do we rekey based on number of bytes transmitted? |
85 | * (additionally randomized). | 85 | * (additionally randomized). Currently 400 MB |
86 | */ | 86 | */ |
87 | #define REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) | 87 | #define REKEY_MAX_BYTES (1024LLU * 1024 * 400) |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Size of the initial key exchange message sent first in both | 90 | * Size of the initial key exchange message sent first in both |
@@ -469,12 +469,6 @@ struct Queue | |||
469 | struct GNUNET_HashCode out_hmac; | 469 | struct GNUNET_HashCode out_hmac; |
470 | 470 | ||
471 | /** | 471 | /** |
472 | * Our ephemeral key. Stored here temporarily during rekeying / key | ||
473 | * generation. | ||
474 | */ | ||
475 | struct GNUNET_CRYPTO_EcdhePrivateKey ephemeral; | ||
476 | |||
477 | /** | ||
478 | * ID of read task for this connection. | 472 | * ID of read task for this connection. |
479 | */ | 473 | */ |
480 | struct GNUNET_SCHEDULER_Task *read_task; | 474 | struct GNUNET_SCHEDULER_Task *read_task; |
@@ -667,6 +661,17 @@ struct Queue | |||
667 | * Store Context for retrieving the monotonic time send with the handshake ack. | 661 | * Store Context for retrieving the monotonic time send with the handshake ack. |
668 | */ | 662 | */ |
669 | struct GNUNET_PEERSTORE_StoreContext *handshake_ack_monotime_sc; | 663 | struct GNUNET_PEERSTORE_StoreContext *handshake_ack_monotime_sc; |
664 | |||
665 | /** | ||
666 | * Size of data received without KX challenge played back. | ||
667 | */ | ||
668 | // TODO remove? | ||
669 | size_t unverified_size; | ||
670 | |||
671 | /** | ||
672 | * Has the initial (core) handshake already happened? | ||
673 | */ | ||
674 | int initial_core_kx_done; | ||
670 | }; | 675 | }; |
671 | 676 | ||
672 | 677 | ||
@@ -893,11 +898,6 @@ struct ListenTask *lts_tail; | |||
893 | */ | 898 | */ |
894 | int addrs_lens; | 899 | int addrs_lens; |
895 | 900 | ||
896 | /** | ||
897 | * Size of data received without KX challenge played back. | ||
898 | */ | ||
899 | // TODO remove? | ||
900 | size_t unverified_size; | ||
901 | 901 | ||
902 | /** | 902 | /** |
903 | * Database for peer's HELLOs. | 903 | * Database for peer's HELLOs. |
@@ -1357,10 +1357,10 @@ static void | |||
1357 | setup_in_cipher (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, | 1357 | setup_in_cipher (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, |
1358 | struct Queue *queue) | 1358 | struct Queue *queue) |
1359 | { | 1359 | { |
1360 | struct GNUNET_HashCode dh; | 1360 | struct GNUNET_HashCode k; |
1361 | 1361 | ||
1362 | GNUNET_CRYPTO_eddsa_ecdh (my_private_key, ephemeral, &dh); | 1362 | GNUNET_CRYPTO_eddsa_kem_decaps (my_private_key, ephemeral, &k); |
1363 | setup_cipher (&dh, &my_identity, &queue->in_cipher, &queue->in_hmac); | 1363 | setup_cipher (&k, &my_identity, &queue->in_cipher, &queue->in_hmac); |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | 1366 | ||
@@ -1557,14 +1557,9 @@ send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge, | |||
1557 | * @param queue queue to setup outgoing (encryption) cipher for | 1557 | * @param queue queue to setup outgoing (encryption) cipher for |
1558 | */ | 1558 | */ |
1559 | static void | 1559 | static void |
1560 | setup_out_cipher (struct Queue *queue) | 1560 | setup_out_cipher (struct Queue *queue, struct GNUNET_HashCode *dh) |
1561 | { | 1561 | { |
1562 | struct GNUNET_HashCode dh; | 1562 | setup_cipher (dh, &queue->target, &queue->out_cipher, &queue->out_hmac); |
1563 | |||
1564 | GNUNET_CRYPTO_ecdh_eddsa (&queue->ephemeral, &queue->target.public_key, &dh); | ||
1565 | /* we don't need the private key anymore, drop it! */ | ||
1566 | memset (&queue->ephemeral, 0, sizeof(queue->ephemeral)); | ||
1567 | setup_cipher (&dh, &queue->target, &queue->out_cipher, &queue->out_hmac); | ||
1568 | queue->rekey_time = GNUNET_TIME_relative_to_absolute (rekey_interval); | 1563 | queue->rekey_time = GNUNET_TIME_relative_to_absolute (rekey_interval); |
1569 | queue->rekey_left_bytes = | 1564 | queue->rekey_left_bytes = |
1570 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, REKEY_MAX_BYTES); | 1565 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, REKEY_MAX_BYTES); |
@@ -1582,13 +1577,14 @@ inject_rekey (struct Queue *queue) | |||
1582 | { | 1577 | { |
1583 | struct TCPRekey rekey; | 1578 | struct TCPRekey rekey; |
1584 | struct TcpRekeySignature thp; | 1579 | struct TcpRekeySignature thp; |
1580 | struct GNUNET_HashCode k; | ||
1585 | 1581 | ||
1586 | GNUNET_assert (0 == queue->pwrite_off); | 1582 | GNUNET_assert (0 == queue->pwrite_off); |
1587 | memset (&rekey, 0, sizeof(rekey)); | 1583 | memset (&rekey, 0, sizeof(rekey)); |
1588 | GNUNET_CRYPTO_ecdhe_key_create (&queue->ephemeral); | 1584 | GNUNET_CRYPTO_eddsa_kem_encaps (&queue->target.public_key, &rekey.ephemeral, |
1585 | &k); | ||
1589 | rekey.header.type = ntohs (GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY); | 1586 | rekey.header.type = ntohs (GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY); |
1590 | rekey.header.size = ntohs (sizeof(rekey)); | 1587 | rekey.header.size = ntohs (sizeof(rekey)); |
1591 | GNUNET_CRYPTO_ecdhe_key_get_public (&queue->ephemeral, &rekey.ephemeral); | ||
1592 | rekey.monotonic_time = | 1588 | rekey.monotonic_time = |
1593 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); | 1589 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); |
1594 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY); | 1590 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY); |
@@ -1627,9 +1623,10 @@ inject_rekey (struct Queue *queue) | |||
1627 | queue->cwrite_off += sizeof(rekey); | 1623 | queue->cwrite_off += sizeof(rekey); |
1628 | /* Setup new cipher for successive messages */ | 1624 | /* Setup new cipher for successive messages */ |
1629 | gcry_cipher_close (queue->out_cipher); | 1625 | gcry_cipher_close (queue->out_cipher); |
1630 | setup_out_cipher (queue); | 1626 | setup_out_cipher (queue, &k); |
1631 | } | 1627 | } |
1632 | 1628 | ||
1629 | |||
1633 | static int | 1630 | static int |
1634 | pending_reversals_delete_it (void *cls, | 1631 | pending_reversals_delete_it (void *cls, |
1635 | const struct GNUNET_HashCode *key, | 1632 | const struct GNUNET_HashCode *key, |
@@ -1829,7 +1826,7 @@ queue_write (void *cls) | |||
1829 | if (((0 == queue->rekey_left_bytes) || | 1826 | if (((0 == queue->rekey_left_bytes) || |
1830 | (0 == GNUNET_TIME_absolute_get_remaining ( | 1827 | (0 == GNUNET_TIME_absolute_get_remaining ( |
1831 | queue->rekey_time).rel_value_us)) && | 1828 | queue->rekey_time).rel_value_us)) && |
1832 | (((0 == queue->pwrite_off) || ! we_do_not_need_to_rekey)&& | 1829 | (((0 == queue->pwrite_off) || ! we_do_not_need_to_rekey) && |
1833 | (queue->cwrite_off + sizeof (struct TCPRekey) <= BUF_SIZE))) | 1830 | (queue->cwrite_off + sizeof (struct TCPRekey) <= BUF_SIZE))) |
1834 | { | 1831 | { |
1835 | inject_rekey (queue); | 1832 | inject_rekey (queue); |
@@ -1868,24 +1865,23 @@ queue_write (void *cls) | |||
1868 | static size_t | 1865 | static size_t |
1869 | try_handle_plaintext (struct Queue *queue) | 1866 | try_handle_plaintext (struct Queue *queue) |
1870 | { | 1867 | { |
1871 | const struct GNUNET_MessageHeader *hdr = | 1868 | const struct GNUNET_MessageHeader *hdr; |
1872 | (const struct GNUNET_MessageHeader *) queue->pread_buf; | 1869 | const struct TCPConfirmationAck *tca; |
1873 | const struct TCPConfirmationAck *tca = (const struct | 1870 | const struct TCPBox *box; |
1874 | TCPConfirmationAck *) queue->pread_buf; | 1871 | const struct TCPRekey *rekey; |
1875 | const struct TCPBox *box = (const struct TCPBox *) queue->pread_buf; | 1872 | const struct TCPFinish *fin; |
1876 | const struct TCPRekey *rekey = (const struct TCPRekey *) queue->pread_buf; | ||
1877 | const struct TCPFinish *fin = (const struct TCPFinish *) queue->pread_buf; | ||
1878 | struct TCPRekey rekeyz; | 1873 | struct TCPRekey rekeyz; |
1879 | struct TCPFinish finz; | 1874 | struct TCPFinish finz; |
1880 | struct GNUNET_ShortHashCode tmac; | 1875 | struct GNUNET_ShortHashCode tmac; |
1881 | uint16_t type; | 1876 | uint16_t type; |
1882 | size_t size = 0; /* make compiler happy */ | 1877 | size_t size = 0; |
1883 | struct TcpHandshakeAckSignature thas; | 1878 | struct TcpHandshakeAckSignature thas; |
1884 | const struct GNUNET_CRYPTO_ChallengeNonceP challenge = queue->challenge; | 1879 | const struct GNUNET_CRYPTO_ChallengeNonceP challenge = queue->challenge; |
1885 | 1880 | ||
1886 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1881 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1887 | "try handle plaintext!\n"); | 1882 | "try handle plaintext!\n"); |
1888 | 1883 | ||
1884 | hdr = (const struct GNUNET_MessageHeader *) queue->pread_buf; | ||
1889 | if ((sizeof(*hdr) > queue->pread_off)) | 1885 | if ((sizeof(*hdr) > queue->pread_off)) |
1890 | { | 1886 | { |
1891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1887 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1893,11 +1889,12 @@ try_handle_plaintext (struct Queue *queue) | |||
1893 | return 0; /* not even a header */ | 1889 | return 0; /* not even a header */ |
1894 | } | 1890 | } |
1895 | 1891 | ||
1896 | if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) | 1892 | if ((GNUNET_YES != queue->initial_core_kx_done) && (queue->unverified_size > |
1893 | INITIAL_CORE_KX_SIZE)) | ||
1897 | { | 1894 | { |
1898 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1895 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1899 | "Already received data of size %lu bigger than KX size %lu!\n", | 1896 | "Already received data of size %lu bigger than KX size %lu!\n", |
1900 | unverified_size, | 1897 | queue->unverified_size, |
1901 | INITIAL_CORE_KX_SIZE); | 1898 | INITIAL_CORE_KX_SIZE); |
1902 | GNUNET_break_op (0); | 1899 | GNUNET_break_op (0); |
1903 | queue_finish (queue); | 1900 | queue_finish (queue); |
@@ -1908,6 +1905,7 @@ try_handle_plaintext (struct Queue *queue) | |||
1908 | switch (type) | 1905 | switch (type) |
1909 | { | 1906 | { |
1910 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK: | 1907 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK: |
1908 | tca = (const struct TCPConfirmationAck *) queue->pread_buf; | ||
1911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1909 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1912 | "start processing ack\n"); | 1910 | "start processing ack\n"); |
1913 | if (sizeof(*tca) > queue->pread_off) | 1911 | if (sizeof(*tca) > queue->pread_off) |
@@ -1980,7 +1978,11 @@ try_handle_plaintext (struct Queue *queue) | |||
1980 | queue->address->sa_family, NULL); | 1978 | queue->address->sa_family, NULL); |
1981 | } | 1979 | } |
1982 | 1980 | ||
1983 | unverified_size = -1; | 1981 | /** |
1982 | * Once we received this ack, we consider this a verified connection. | ||
1983 | * FIXME: I am not sure this logic is sane here. | ||
1984 | */ | ||
1985 | queue->initial_core_kx_done = GNUNET_YES; | ||
1984 | 1986 | ||
1985 | char *foreign_addr; | 1987 | char *foreign_addr; |
1986 | 1988 | ||
@@ -2020,6 +2022,7 @@ try_handle_plaintext (struct Queue *queue) | |||
2020 | break; | 2022 | break; |
2021 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX: | 2023 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX: |
2022 | /* Special case: header size excludes box itself! */ | 2024 | /* Special case: header size excludes box itself! */ |
2025 | box = (const struct TCPBox *) queue->pread_buf; | ||
2023 | if (ntohs (hdr->size) + sizeof(struct TCPBox) > queue->pread_off) | 2026 | if (ntohs (hdr->size) + sizeof(struct TCPBox) > queue->pread_off) |
2024 | return 0; | 2027 | return 0; |
2025 | calculate_hmac (&queue->in_hmac, &box[1], ntohs (hdr->size), &tmac); | 2028 | calculate_hmac (&queue->in_hmac, &box[1], ntohs (hdr->size), &tmac); |
@@ -2036,6 +2039,7 @@ try_handle_plaintext (struct Queue *queue) | |||
2036 | break; | 2039 | break; |
2037 | 2040 | ||
2038 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY: | 2041 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY: |
2042 | rekey = (const struct TCPRekey *) queue->pread_buf; | ||
2039 | if (sizeof(*rekey) > queue->pread_off) | 2043 | if (sizeof(*rekey) > queue->pread_off) |
2040 | return 0; | 2044 | return 0; |
2041 | if (ntohs (hdr->size) != sizeof(*rekey)) | 2045 | if (ntohs (hdr->size) != sizeof(*rekey)) |
@@ -2060,6 +2064,7 @@ try_handle_plaintext (struct Queue *queue) | |||
2060 | break; | 2064 | break; |
2061 | 2065 | ||
2062 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH: | 2066 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH: |
2067 | fin = (const struct TCPFinish *) queue->pread_buf; | ||
2063 | if (sizeof(*fin) > queue->pread_off) | 2068 | if (sizeof(*fin) > queue->pread_off) |
2064 | return 0; | 2069 | return 0; |
2065 | if (ntohs (hdr->size) != sizeof(*fin)) | 2070 | if (ntohs (hdr->size) != sizeof(*fin)) |
@@ -2091,8 +2096,8 @@ try_handle_plaintext (struct Queue *queue) | |||
2091 | return 0; | 2096 | return 0; |
2092 | } | 2097 | } |
2093 | GNUNET_assert (0 != size); | 2098 | GNUNET_assert (0 != size); |
2094 | if (-1 != unverified_size) | 2099 | if (-1 != queue->unverified_size) |
2095 | unverified_size += size; | 2100 | queue->unverified_size += size; |
2096 | return size; | 2101 | return size; |
2097 | } | 2102 | } |
2098 | 2103 | ||
@@ -2712,10 +2717,10 @@ static void | |||
2712 | start_initial_kx_out (struct Queue *queue) | 2717 | start_initial_kx_out (struct Queue *queue) |
2713 | { | 2718 | { |
2714 | struct GNUNET_CRYPTO_EcdhePublicKey epub; | 2719 | struct GNUNET_CRYPTO_EcdhePublicKey epub; |
2720 | struct GNUNET_HashCode k; | ||
2715 | 2721 | ||
2716 | GNUNET_CRYPTO_ecdhe_key_create (&queue->ephemeral); | 2722 | GNUNET_CRYPTO_eddsa_kem_encaps (&queue->target.public_key, &epub, &k); |
2717 | GNUNET_CRYPTO_ecdhe_key_get_public (&queue->ephemeral, &epub); | 2723 | setup_out_cipher (queue, &k); |
2718 | setup_out_cipher (queue); | ||
2719 | transmit_kx (queue, &epub); | 2724 | transmit_kx (queue, &epub); |
2720 | } | 2725 | } |
2721 | 2726 | ||
@@ -3060,6 +3065,7 @@ proto_read_kx (void *cls) | |||
3060 | GNUNET_free (pq); | 3065 | GNUNET_free (pq); |
3061 | } | 3066 | } |
3062 | 3067 | ||
3068 | |||
3063 | static struct ProtoQueue * | 3069 | static struct ProtoQueue * |
3064 | create_proto_queue (struct GNUNET_NETWORK_Handle *sock, | 3070 | create_proto_queue (struct GNUNET_NETWORK_Handle *sock, |
3065 | struct sockaddr *in, | 3071 | struct sockaddr *in, |
@@ -3120,7 +3126,6 @@ listen_cb (void *cls) | |||
3120 | struct sockaddr_storage in; | 3126 | struct sockaddr_storage in; |
3121 | socklen_t addrlen; | 3127 | socklen_t addrlen; |
3122 | struct GNUNET_NETWORK_Handle *sock; | 3128 | struct GNUNET_NETWORK_Handle *sock; |
3123 | struct ProtoQueue *pq; | ||
3124 | struct ListenTask *lt; | 3129 | struct ListenTask *lt; |
3125 | struct sockaddr *in_addr; | 3130 | struct sockaddr *in_addr; |
3126 | 3131 | ||
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 4657a7220..a58423c95 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | : | |
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -38,6 +38,7 @@ | |||
38 | * - support other UDP-specific NAT traversal methods (#) | 38 | * - support other UDP-specific NAT traversal methods (#) |
39 | */ | 39 | */ |
40 | #include "platform.h" | 40 | #include "platform.h" |
41 | #include "gnunet_common.h" | ||
41 | #include "gnunet_util_lib.h" | 42 | #include "gnunet_util_lib.h" |
42 | #include "gnunet_protocols.h" | 43 | #include "gnunet_protocols.h" |
43 | #include "gnunet_signatures.h" | 44 | #include "gnunet_signatures.h" |
@@ -67,7 +68,7 @@ | |||
67 | * How often do we scan for changes to our network interfaces? | 68 | * How often do we scan for changes to our network interfaces? |
68 | */ | 69 | */ |
69 | #define INTERFACE_SCAN_FREQUENCY \ | 70 | #define INTERFACE_SCAN_FREQUENCY \ |
70 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 71 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
71 | 72 | ||
72 | /** | 73 | /** |
73 | * How long do we believe our addresses to remain up (before | 74 | * How long do we believe our addresses to remain up (before |
@@ -76,7 +77,7 @@ | |||
76 | #define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS | 77 | #define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS |
77 | 78 | ||
78 | #define WORKING_QUEUE_INTERVALL \ | 79 | #define WORKING_QUEUE_INTERVALL \ |
79 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1) | 80 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1) |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * AES key size. | 83 | * AES key size. |
@@ -93,7 +94,7 @@ | |||
93 | */ | 94 | */ |
94 | #define GCM_TAG_SIZE (128 / 8) | 95 | #define GCM_TAG_SIZE (128 / 8) |
95 | 96 | ||
96 | #define GENERATE_AT_ONCE 2 | 97 | #define GENERATE_AT_ONCE 16 |
97 | 98 | ||
98 | /** | 99 | /** |
99 | * If we fall below this number of available KCNs, | 100 | * If we fall below this number of available KCNs, |
@@ -104,7 +105,7 @@ | |||
104 | * arrive before the sender runs out. So really this | 105 | * arrive before the sender runs out. So really this |
105 | * should ideally be based on the RTT. | 106 | * should ideally be based on the RTT. |
106 | */ | 107 | */ |
107 | #define KCN_THRESHOLD 92 | 108 | #define KCN_THRESHOLD 96 |
108 | 109 | ||
109 | /** | 110 | /** |
110 | * How many KCNs do we keep around *after* we hit | 111 | * How many KCNs do we keep around *after* we hit |
@@ -134,7 +135,7 @@ | |||
134 | * sense. Might make sense to adapt to RTT if we had | 135 | * sense. Might make sense to adapt to RTT if we had |
135 | * a good measurement... | 136 | * a good measurement... |
136 | */ | 137 | */ |
137 | #define MAX_SECRETS 128000 | 138 | #define MAX_SECRETS 256 |
138 | 139 | ||
139 | /** | 140 | /** |
140 | * Default value for how often we do rekey based on number of bytes transmitted? | 141 | * Default value for how often we do rekey based on number of bytes transmitted? |
@@ -206,12 +207,8 @@ struct InitialKX | |||
206 | * HMAC for the following encrypted message, using GCM. HMAC uses | 207 | * HMAC for the following encrypted message, using GCM. HMAC uses |
207 | * key derived from the handshake with sequence number zero. | 208 | * key derived from the handshake with sequence number zero. |
208 | */ | 209 | */ |
209 | char gcm_tag[GCM_TAG_SIZE]; | 210 | uint8_t gcm_tag[GCM_TAG_SIZE]; |
210 | 211 | ||
211 | /** | ||
212 | * A flag indicating, if the sender is doing rekeying. | ||
213 | */ | ||
214 | int rekeying; | ||
215 | }; | 212 | }; |
216 | 213 | ||
217 | 214 | ||
@@ -258,13 +255,7 @@ struct UDPAck | |||
258 | * Sequence acknowledgement limit. Specifies current maximum sequence | 255 | * Sequence acknowledgement limit. Specifies current maximum sequence |
259 | * number supported by receiver. | 256 | * number supported by receiver. |
260 | */ | 257 | */ |
261 | uint32_t sequence_max GNUNET_PACKED; | 258 | uint32_t sequence_ack GNUNET_PACKED; |
262 | |||
263 | /** | ||
264 | * Sequence acknowledgement limit. Specifies current maximum sequence | ||
265 | * number supported by receiver. | ||
266 | */ | ||
267 | uint32_t acks_available GNUNET_PACKED; | ||
268 | 259 | ||
269 | /** | 260 | /** |
270 | * CMAC of the base key being acknowledged. | 261 | * CMAC of the base key being acknowledged. |
@@ -343,42 +334,24 @@ struct UDPBox | |||
343 | * wrong, the receiver should check if the message might be a | 334 | * wrong, the receiver should check if the message might be a |
344 | * `struct UdpHandshakeSignature`. | 335 | * `struct UdpHandshakeSignature`. |
345 | */ | 336 | */ |
346 | char gcm_tag[GCM_TAG_SIZE]; | 337 | uint8_t gcm_tag[GCM_TAG_SIZE]; |
347 | 338 | ||
348 | /** | ||
349 | * A flag indicating, if the sender is doing rekeying. | ||
350 | */ | ||
351 | int rekeying; | ||
352 | }; | 339 | }; |
353 | 340 | ||
354 | /** | 341 | /** |
355 | * UDP message box. Always sent encrypted, only allowed after | 342 | * Plaintext of a rekey payload in a UDPBox. |
356 | * the receiver sent a `struct UDPAck` for the base key! | ||
357 | */ | 343 | */ |
358 | struct UDPRekey | 344 | struct UDPRekey |
359 | { | 345 | { |
360 | /** | 346 | /** |
361 | * Key and IV identification code. KDF applied to an acknowledged | 347 | * Type is #GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY. |
362 | * base key and a sequence number. Sequence numbers must be used | ||
363 | * monotonically increasing up to the maximum specified in | ||
364 | * `struct UDPAck`. Without further `struct UDPAck`s, the sender | ||
365 | * must fall back to sending handshakes! | ||
366 | */ | ||
367 | struct GNUNET_ShortHashCode kid; | ||
368 | |||
369 | /** | ||
370 | * 128-bit authentication tag for the following encrypted message, | ||
371 | * from GCM. MAC starts at the @e body_start that follows and | ||
372 | * extends until the end of the UDP payload. If the @e hmac is | ||
373 | * wrong, the receiver should check if the message might be a | ||
374 | * `struct UdpHandshakeSignature`. | ||
375 | */ | 348 | */ |
376 | char gcm_tag[GCM_TAG_SIZE]; | 349 | struct GNUNET_MessageHeader header; |
377 | 350 | ||
378 | /** | 351 | /** |
379 | * Sender's identity | 352 | * Ephemeral key to rekey with. |
380 | */ | 353 | */ |
381 | struct GNUNET_PeerIdentity sender; | 354 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral; |
382 | }; | 355 | }; |
383 | 356 | ||
384 | GNUNET_NETWORK_STRUCT_END | 357 | GNUNET_NETWORK_STRUCT_END |
@@ -500,6 +473,21 @@ struct SharedSecret | |||
500 | * Number of active KCN entries. | 473 | * Number of active KCN entries. |
501 | */ | 474 | */ |
502 | unsigned int active_kce_count; | 475 | unsigned int active_kce_count; |
476 | |||
477 | /** | ||
478 | * Bytes sent with this shared secret | ||
479 | */ | ||
480 | size_t bytes_sent; | ||
481 | |||
482 | /** | ||
483 | * rekey initiated for this secret? | ||
484 | */ | ||
485 | int rekey_initiated; | ||
486 | |||
487 | /** | ||
488 | * Also precompute keys despite sufficient acks (for rekey) | ||
489 | */ | ||
490 | int override_available_acks; | ||
503 | }; | 491 | }; |
504 | 492 | ||
505 | 493 | ||
@@ -510,16 +498,6 @@ struct SharedSecret | |||
510 | struct SenderAddress | 498 | struct SenderAddress |
511 | { | 499 | { |
512 | /** | 500 | /** |
513 | * Shared secret we use with @e target for rekeying. | ||
514 | */ | ||
515 | struct SharedSecret *ss_rekey; | ||
516 | |||
517 | /** | ||
518 | * Flag indicating sender is initiated rekeying for this receiver. | ||
519 | */ | ||
520 | int rekeying; | ||
521 | |||
522 | /** | ||
523 | * To whom are we talking to. | 501 | * To whom are we talking to. |
524 | */ | 502 | */ |
525 | struct GNUNET_PeerIdentity target; | 503 | struct GNUNET_PeerIdentity target; |
@@ -575,21 +553,20 @@ struct SenderAddress | |||
575 | */ | 553 | */ |
576 | int sender_destroy_called; | 554 | int sender_destroy_called; |
577 | 555 | ||
578 | |||
579 | /** | 556 | /** |
580 | * ID of kce working queue task | 557 | * ID of kce working queue task |
581 | */ | 558 | */ |
582 | struct GNUNET_SCHEDULER_Task *kce_task; | 559 | struct GNUNET_SCHEDULER_Task *kce_task; |
583 | 560 | ||
584 | /** | 561 | /** |
585 | * ID of kce rekey working queue task | 562 | * Is the kce_task finished? |
586 | */ | 563 | */ |
587 | struct GNUNET_SCHEDULER_Task *kce_task_rekey; | 564 | int kce_task_finished; |
588 | 565 | ||
589 | /** | 566 | /** |
590 | * Is the kce_task finished? | 567 | * When KCE finishes, send ACK if GNUNET_YES |
591 | */ | 568 | */ |
592 | int kce_task_finished; | 569 | int kce_send_ack_on_finish; |
593 | }; | 570 | }; |
594 | 571 | ||
595 | 572 | ||
@@ -599,38 +576,12 @@ struct SenderAddress | |||
599 | */ | 576 | */ |
600 | struct ReceiverAddress | 577 | struct ReceiverAddress |
601 | { | 578 | { |
602 | |||
603 | /** | ||
604 | * Shared secret we use with @e target for rekeying. | ||
605 | */ | ||
606 | struct SharedSecret *ss_rekey; | ||
607 | |||
608 | /** | ||
609 | * Acks available when we started rekeying. | ||
610 | */ | ||
611 | unsigned int rekey_acks_available; | ||
612 | |||
613 | /** | ||
614 | * Send bytes for this receiver address. | ||
615 | */ | ||
616 | uint64_t rekey_send_bytes; | ||
617 | |||
618 | /** | 579 | /** |
619 | * Timeout for this receiver address. | 580 | * Timeout for this receiver address. |
620 | */ | 581 | */ |
621 | struct GNUNET_TIME_Absolute rekey_timeout; | 582 | struct GNUNET_TIME_Absolute rekey_timeout; |
622 | 583 | ||
623 | /** | 584 | /** |
624 | * Flag indicating sender is initiated rekeying for this receiver. | ||
625 | */ | ||
626 | int rekeying; | ||
627 | |||
628 | /** | ||
629 | * Number of kce we retain for sending the rekeying shared secret. | ||
630 | */ | ||
631 | int number_rekeying_kce; | ||
632 | |||
633 | /** | ||
634 | * To whom are we talking to. | 585 | * To whom are we talking to. |
635 | */ | 586 | */ |
636 | struct GNUNET_PeerIdentity target; | 587 | struct GNUNET_PeerIdentity target; |
@@ -784,10 +735,6 @@ static struct GNUNET_TIME_Relative rekey_interval; | |||
784 | * How often we do rekey based on number of bytes transmitted | 735 | * How often we do rekey based on number of bytes transmitted |
785 | */ | 736 | */ |
786 | static unsigned long long rekey_max_bytes; | 737 | static unsigned long long rekey_max_bytes; |
787 | /** | ||
788 | * Shared secret we finished the last kce working queue for. | ||
789 | */ | ||
790 | struct SharedSecret *ss_finished; | ||
791 | 738 | ||
792 | /** | 739 | /** |
793 | * Cache of pre-generated key IDs. | 740 | * Cache of pre-generated key IDs. |
@@ -1050,35 +997,37 @@ kce_generate (struct SharedSecret *ss, uint32_t seq) | |||
1050 | * @param withoutKce If GNUNET_YES shared secrets with kce will not be destroyed. | 997 | * @param withoutKce If GNUNET_YES shared secrets with kce will not be destroyed. |
1051 | */ | 998 | */ |
1052 | static int | 999 | static int |
1053 | secret_destroy (struct SharedSecret *ss, int withoutKce) | 1000 | secret_destroy (struct SharedSecret *ss) |
1054 | { | 1001 | { |
1055 | struct SenderAddress *sender; | 1002 | struct SenderAddress *sender; |
1056 | struct ReceiverAddress *receiver; | 1003 | struct ReceiverAddress *receiver; |
1057 | struct KeyCacheEntry *kce; | 1004 | struct KeyCacheEntry *kce; |
1058 | 1005 | ||
1059 | if (withoutKce && (ss->sequence_allowed > 0)) | ||
1060 | return GNUNET_NO; | ||
1061 | |||
1062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1063 | "secret %s destroy %u %u\n", | 1007 | "secret %s destroy %u\n", |
1064 | GNUNET_h2s (&ss->master), | 1008 | GNUNET_h2s (&ss->master), |
1065 | withoutKce, | ||
1066 | ss->sequence_allowed); | 1009 | ss->sequence_allowed); |
1067 | if (NULL != (sender = ss->sender)) | 1010 | if (NULL != (sender = ss->sender)) |
1068 | { | 1011 | { |
1069 | GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss); | 1012 | GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss); |
1070 | sender->num_secrets--; | 1013 | sender->num_secrets--; |
1014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1015 | "%u sender->num_secrets\n", | ||
1016 | receiver->num_secrets); | ||
1017 | if (NULL != ss->sender->kce_task) | ||
1018 | { | ||
1019 | GNUNET_SCHEDULER_cancel (ss->sender->kce_task); | ||
1020 | ss->sender->kce_task = NULL; | ||
1021 | } | ||
1071 | } | 1022 | } |
1072 | if (NULL != (receiver = ss->receiver)) | 1023 | if (NULL != (receiver = ss->receiver)) |
1073 | { | 1024 | { |
1074 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); | 1025 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); |
1075 | receiver->num_secrets--; | 1026 | receiver->num_secrets--; |
1076 | // Uncomment this for alternativ 1 of backchannel functionality | ||
1077 | receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used); | 1027 | receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used); |
1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1028 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1079 | "%u receiver->acks_available 3\n", | 1029 | "%u receiver->num_secrets\n", |
1080 | receiver->acks_available); | 1030 | receiver->num_secrets); |
1081 | // Until here for alternativ 1 | ||
1082 | } | 1031 | } |
1083 | while (NULL != (kce = ss->kce_head)) | 1032 | while (NULL != (kce = ss->kce_head)) |
1084 | kce_destroy (kce); | 1033 | kce_destroy (kce); |
@@ -1337,7 +1286,7 @@ setup_cipher (const struct GNUNET_HashCode *msec, | |||
1337 | */ | 1286 | */ |
1338 | static int | 1287 | static int |
1339 | try_decrypt (const struct SharedSecret *ss, | 1288 | try_decrypt (const struct SharedSecret *ss, |
1340 | const char tag[GCM_TAG_SIZE], | 1289 | const uint8_t *tag, |
1341 | uint32_t serial, | 1290 | uint32_t serial, |
1342 | const char *in_buf, | 1291 | const char *in_buf, |
1343 | size_t in_buf_size, | 1292 | size_t in_buf_size, |
@@ -1375,28 +1324,29 @@ setup_shared_secret_dec (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral) | |||
1375 | struct SharedSecret *ss; | 1324 | struct SharedSecret *ss; |
1376 | 1325 | ||
1377 | ss = GNUNET_new (struct SharedSecret); | 1326 | ss = GNUNET_new (struct SharedSecret); |
1378 | GNUNET_CRYPTO_eddsa_ecdh (my_private_key, ephemeral, &ss->master); | 1327 | GNUNET_CRYPTO_eddsa_kem_decaps (my_private_key, ephemeral, &ss->master); |
1328 | calculate_cmac (ss); | ||
1379 | return ss; | 1329 | return ss; |
1380 | } | 1330 | } |
1381 | 1331 | ||
1382 | 1332 | ||
1383 | /** | 1333 | /** |
1384 | * Setup shared secret for encryption. | 1334 | * Setup new shared secret for encryption using KEM. |
1385 | * | 1335 | * |
1386 | * @param ephemeral ephemeral key we are sending to the other peer | 1336 | * @param[out] ephemeral ephemeral key to be sent to other peer (encapsulated key from KEM) |
1387 | * @param[in,out] receiver queue to initialize encryption key for | 1337 | * @param[in,out] receiver queue to initialize encryption key for |
1388 | * @return new shared secret | 1338 | * @return new shared secret |
1389 | */ | 1339 | */ |
1390 | static struct SharedSecret * | 1340 | static struct SharedSecret * |
1391 | setup_shared_secret_enc (const struct GNUNET_CRYPTO_EcdhePrivateKey *ephemeral, | 1341 | setup_shared_secret_ephemeral (struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, |
1392 | struct ReceiverAddress *receiver, int add_to_receiver) | 1342 | struct ReceiverAddress *receiver) |
1393 | { | 1343 | { |
1394 | struct SharedSecret *ss; | 1344 | struct SharedSecret *ss; |
1345 | struct GNUNET_HashCode k; | ||
1395 | 1346 | ||
1347 | GNUNET_CRYPTO_eddsa_kem_encaps (&receiver->target.public_key, ephemeral, &k); | ||
1396 | ss = GNUNET_new (struct SharedSecret); | 1348 | ss = GNUNET_new (struct SharedSecret); |
1397 | GNUNET_CRYPTO_ecdh_eddsa (ephemeral, | 1349 | memcpy (&ss->master, &k, sizeof (k)); |
1398 | &receiver->target.public_key, | ||
1399 | &ss->master); | ||
1400 | calculate_cmac (ss); | 1350 | calculate_cmac (ss); |
1401 | ss->receiver = receiver; | 1351 | ss->receiver = receiver; |
1402 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); | 1352 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); |
@@ -1416,60 +1366,39 @@ setup_shared_secret_enc (const struct GNUNET_CRYPTO_EcdhePrivateKey *ephemeral, | |||
1416 | static void | 1366 | static void |
1417 | setup_receiver_mq (struct ReceiverAddress *receiver); | 1367 | setup_receiver_mq (struct ReceiverAddress *receiver); |
1418 | 1368 | ||
1369 | |||
1419 | /** | 1370 | /** |
1420 | * Destroying all secrets. Depending on parameter we keep those secrets having a kce. | 1371 | * Best effort try to purge some secrets. |
1372 | * Ideally those, not ACKed. | ||
1421 | * | 1373 | * |
1422 | * @param ss The secret we will not destroy. | 1374 | * @param ss_list_tail the oldest secret in the list of interest. |
1423 | * @param withoutKce If GNUNET_YES shared secrets with kce will not be destroyed. | 1375 | * @return number of deleted secrets. |
1424 | */ | 1376 | */ |
1425 | static void | 1377 | unsigned int |
1426 | destroy_all_secrets (struct SharedSecret *ss, int withoutKce) | 1378 | purge_secrets (struct SharedSecret *ss_list_tail) |
1427 | { | 1379 | { |
1428 | struct SenderAddress *sender; | ||
1429 | struct ReceiverAddress *receiver; | ||
1430 | struct SharedSecret *ss_to_destroy; | ||
1431 | struct SharedSecret *ss_start; | ||
1432 | struct SharedSecret *pos; | 1380 | struct SharedSecret *pos; |
1433 | int at_least_one_destroyed = GNUNET_NO; | 1381 | struct SharedSecret *ss_to_purge; |
1382 | unsigned int deleted = 0; | ||
1434 | 1383 | ||
1435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1436 | "Starting destroy all withoutKce: %u.\n", | 1385 | "Purging secrets.\n"); |
1437 | withoutKce); | 1386 | pos = ss_list_tail; |
1438 | |||
1439 | if (NULL != (sender = ss->sender)) | ||
1440 | { | ||
1441 | ss_start = sender->ss_head; | ||
1442 | } | ||
1443 | else if (NULL != (receiver = ss->receiver)) | ||
1444 | { | ||
1445 | ss_start = receiver->ss_head; | ||
1446 | } | ||
1447 | else | ||
1448 | { | ||
1449 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1450 | "Shared secret has no sender or receiver!\n"); | ||
1451 | return; | ||
1452 | } | ||
1453 | |||
1454 | pos = ss_start; | ||
1455 | while (NULL != pos) | 1387 | while (NULL != pos) |
1456 | { | 1388 | { |
1457 | ss_to_destroy = pos; | 1389 | ss_to_purge = pos; |
1458 | pos = pos->next; | 1390 | pos = pos->prev; |
1459 | |||
1460 | if (ss != ss_to_destroy) | ||
1461 | at_least_one_destroyed = secret_destroy (ss_to_destroy, withoutKce); | ||
1462 | } | ||
1463 | 1391 | ||
1464 | if ((ss != ss_start) && ! at_least_one_destroyed) | 1392 | // FIXME we may also want to purge old unacked. |
1465 | { | 1393 | if (rekey_max_bytes <= ss_to_purge->bytes_sent) |
1466 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1394 | { |
1467 | "Really destroying all.\n"); | 1395 | secret_destroy (ss_to_purge); |
1468 | destroy_all_secrets (ss_start, GNUNET_NO); | 1396 | deleted++; |
1397 | } | ||
1469 | } | 1398 | } |
1470 | |||
1471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1472 | "Finished destroy all.\n"); | 1400 | "Finished purging all, deleted %u.\n", deleted); |
1401 | return deleted; | ||
1473 | } | 1402 | } |
1474 | 1403 | ||
1475 | 1404 | ||
@@ -1506,9 +1435,6 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1507 | "Tell transport we have %u more acks!\n", | 1436 | "Tell transport we have %u more acks!\n", |
1508 | acks_to_add); | 1437 | acks_to_add); |
1509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1510 | "%u kce for rekeying.\n", | ||
1511 | receiver->number_rekeying_kce); | ||
1512 | 1438 | ||
1513 | // Until here for alternativ 1 | 1439 | // Until here for alternativ 1 |
1514 | 1440 | ||
@@ -1516,63 +1442,6 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1516 | 1442 | ||
1517 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); | 1443 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); |
1518 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); | 1444 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); |
1519 | destroy_all_secrets (ss, GNUNET_YES); | ||
1520 | } | ||
1521 | |||
1522 | |||
1523 | static uint32_t | ||
1524 | reset_rekey_kces (struct ReceiverAddress *receiver, | ||
1525 | uint32_t acks_to_add) | ||
1526 | { | ||
1527 | int needed_for_rekeying; | ||
1528 | |||
1529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1530 | "%u kce for rekeying and %u acks_to_add\n", | ||
1531 | receiver->number_rekeying_kce, | ||
1532 | acks_to_add); | ||
1533 | |||
1534 | needed_for_rekeying = (3 - receiver->number_rekeying_kce); | ||
1535 | if (acks_to_add <= needed_for_rekeying) | ||
1536 | { | ||
1537 | receiver->number_rekeying_kce += acks_to_add; | ||
1538 | acks_to_add = 0; | ||
1539 | } | ||
1540 | else | ||
1541 | { | ||
1542 | acks_to_add -= (3 - receiver->number_rekeying_kce); | ||
1543 | receiver->number_rekeying_kce = 3; | ||
1544 | } | ||
1545 | |||
1546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1547 | "%u kce for rekeying and %u acks_to_add\n", | ||
1548 | receiver->number_rekeying_kce, | ||
1549 | acks_to_add); | ||
1550 | return acks_to_add; | ||
1551 | } | ||
1552 | |||
1553 | |||
1554 | static void | ||
1555 | add_acks_rekey (struct ReceiverAddress *receiver) | ||
1556 | { | ||
1557 | uint32_t acks_to_add = receiver->ss_rekey->sequence_allowed; | ||
1558 | |||
1559 | if (receiver->number_rekeying_kce < 3) | ||
1560 | acks_to_add = reset_rekey_kces (receiver, acks_to_add); | ||
1561 | receiver->acks_available = receiver->ss_rekey->sequence_allowed; | ||
1562 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1563 | "%u receiver->acks_available 4\n", | ||
1564 | receiver->acks_available); | ||
1565 | if (0 != acks_to_add) | ||
1566 | { | ||
1567 | add_acks (receiver->ss_rekey, acks_to_add); | ||
1568 | } | ||
1569 | receiver->ss_rekey = NULL; | ||
1570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1571 | "# rekeying successful\n"); | ||
1572 | GNUNET_STATISTICS_update (stats, | ||
1573 | "# rekeying successful", | ||
1574 | 1, | ||
1575 | GNUNET_NO); | ||
1576 | } | 1445 | } |
1577 | 1446 | ||
1578 | 1447 | ||
@@ -1598,36 +1467,6 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) | |||
1598 | "in handle ack with cmac %s\n", | 1467 | "in handle ack with cmac %s\n", |
1599 | GNUNET_h2s (&ack->cmac)); | 1468 | GNUNET_h2s (&ack->cmac)); |
1600 | 1469 | ||
1601 | if (NULL != receiver->ss_rekey) | ||
1602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1603 | "We have rekey secret with cmac %s \n", | ||
1604 | GNUNET_h2s (&receiver->ss_rekey->cmac)); | ||
1605 | |||
1606 | if ((NULL != receiver->ss_rekey) && (0 == memcmp (&ack->cmac, | ||
1607 | &receiver->ss_rekey->cmac, | ||
1608 | sizeof(struct | ||
1609 | GNUNET_HashCode))) ) | ||
1610 | { | ||
1611 | allowed = ntohl (ack->sequence_max); | ||
1612 | |||
1613 | if (allowed > receiver->ss_rekey->sequence_allowed) | ||
1614 | { | ||
1615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1616 | "%u > %u (%u %u) for rekey secrect %s\n", allowed, | ||
1617 | receiver->ss_rekey->sequence_allowed, | ||
1618 | receiver->acks_available, | ||
1619 | ack->acks_available, | ||
1620 | GNUNET_h2s (&receiver->ss_rekey->master)); | ||
1621 | |||
1622 | receiver->ss_rekey->sequence_allowed = allowed; | ||
1623 | |||
1624 | if (GNUNET_NO == receiver->rekeying) | ||
1625 | add_acks_rekey (receiver); | ||
1626 | |||
1627 | return GNUNET_NO; | ||
1628 | } | ||
1629 | } | ||
1630 | |||
1631 | (void) pid; | 1470 | (void) pid; |
1632 | for (struct SharedSecret *ss = receiver->ss_head; NULL != ss; ss = ss->next) | 1471 | for (struct SharedSecret *ss = receiver->ss_head; NULL != ss; ss = ss->next) |
1633 | { | 1472 | { |
@@ -1635,90 +1474,76 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) | |||
1635 | { | 1474 | { |
1636 | 1475 | ||
1637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1638 | "Found matching mac\n"); | 1477 | "Found matching cmac\n"); |
1639 | 1478 | ||
1640 | allowed = ntohl (ack->sequence_max); | 1479 | allowed = ntohl (ack->sequence_ack); |
1641 | 1480 | ||
1642 | if (allowed > ss->sequence_allowed) | 1481 | if (allowed <= ss->sequence_allowed) |
1643 | { | 1482 | { |
1644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1645 | "%u > %u (%u %u) for secrect %s\n", allowed, | 1484 | "Ignoring ack, not giving us increased window\n."); |
1646 | ss->sequence_allowed, | 1485 | return GNUNET_NO; |
1647 | receiver->acks_available, | ||
1648 | ack->acks_available, | ||
1649 | GNUNET_h2s (&ss->master)); | ||
1650 | acks_to_add = (allowed - ss->sequence_allowed); | ||
1651 | if ((GNUNET_NO == receiver->rekeying) && | ||
1652 | (receiver->number_rekeying_kce < 3) ) | ||
1653 | acks_to_add = reset_rekey_kces (receiver, acks_to_add); | ||
1654 | |||
1655 | if ((0 != acks_to_add) && (GNUNET_NO == receiver->rekeying)) | ||
1656 | { | ||
1657 | receiver->acks_available += (allowed - ss->sequence_allowed); | ||
1658 | ss->sequence_allowed = allowed; | ||
1659 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1660 | "%u receiver->acks_available 5\n", | ||
1661 | receiver->acks_available); | ||
1662 | add_acks (ss, acks_to_add); | ||
1663 | } | ||
1664 | } | 1486 | } |
1487 | acks_to_add = (allowed - ss->sequence_allowed); | ||
1488 | GNUNET_assert (0 != acks_to_add); | ||
1489 | receiver->acks_available += (allowed - ss->sequence_allowed); | ||
1490 | ss->sequence_allowed = allowed; | ||
1491 | add_acks (ss, acks_to_add); | ||
1492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1493 | "New sequence allows until %u (+%u). Acks available to us: %u. For secret %s\n", | ||
1494 | allowed, | ||
1495 | acks_to_add, | ||
1496 | receiver->acks_available, | ||
1497 | GNUNET_h2s (&ss->master)); | ||
1665 | return GNUNET_NO; | 1498 | return GNUNET_NO; |
1666 | } | 1499 | } |
1667 | } | 1500 | } |
1501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1502 | "Matching cmac not found for ack!\n"); | ||
1668 | return GNUNET_YES; | 1503 | return GNUNET_YES; |
1669 | } | 1504 | } |
1670 | 1505 | ||
1671 | 1506 | ||
1672 | /** | 1507 | /** |
1673 | * Test if we have received a valid message in plaintext. | 1508 | * We established a shared secret with a sender. We should try to send |
1674 | * If so, handle it. | 1509 | * the sender an `struct UDPAck` at the next opportunity to allow the |
1510 | * sender to use @a ss longer (assuming we did not yet already | ||
1511 | * recently). | ||
1675 | * | 1512 | * |
1676 | * @param sender peer to process inbound plaintext for | 1513 | * @param ss shared secret to generate ACKs for |
1677 | * @param buf buffer we received | ||
1678 | * @param buf_size number of bytes in @a buf | ||
1679 | */ | 1514 | */ |
1680 | static void | 1515 | static void |
1681 | try_handle_plaintext (struct SenderAddress *sender, | 1516 | consider_ss_ack (struct SharedSecret *ss) |
1682 | const void *buf, | ||
1683 | size_t buf_size) | ||
1684 | { | 1517 | { |
1685 | const struct GNUNET_MessageHeader *hdr = | 1518 | struct UDPAck ack; |
1686 | (const struct GNUNET_MessageHeader *) buf; | 1519 | GNUNET_assert (NULL != ss->sender); |
1687 | const struct UDPAck *ack = (const struct UDPAck *) buf; | 1520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1688 | uint16_t type; | 1521 | "Considering SS UDPAck %s\n", |
1522 | GNUNET_i2s_full (&ss->sender->target)); | ||
1689 | 1523 | ||
1690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1691 | "try_handle_plaintext of size %lu (%u %lu) and type %u\n", | 1525 | "Sender has %u acks available.\n", |
1692 | buf_size, | 1526 | ss->sender->acks_available); |
1693 | ntohs (hdr->size), | 1527 | /* drop ancient KeyCacheEntries */ |
1694 | sizeof(*hdr), | 1528 | while ((NULL != ss->kce_head) && |
1695 | ntohs (hdr->type)); | 1529 | (MAX_SQN_DELTA < |
1696 | if (sizeof(*hdr) > buf_size) | 1530 | ss->kce_head->sequence_number - ss->kce_tail->sequence_number)) |
1697 | return; /* not even a header */ | 1531 | kce_destroy (ss->kce_tail); |
1698 | if (ntohs (hdr->size) > buf_size) | ||
1699 | return; /* not even a header */ | ||
1700 | type = ntohs (hdr->type); | ||
1701 | switch (type) | ||
1702 | { | ||
1703 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK: | ||
1704 | /* lookup master secret by 'cmac', then update sequence_max */ | ||
1705 | GNUNET_CONTAINER_multipeermap_get_multiple (receivers, | ||
1706 | &sender->target, | ||
1707 | &handle_ack, | ||
1708 | (void *) ack); | ||
1709 | /* There could be more messages after the ACK, handle those as well */ | ||
1710 | buf += ntohs (hdr->size); | ||
1711 | buf_size -= ntohs (hdr->size); | ||
1712 | pass_plaintext_to_core (sender, buf, buf_size); | ||
1713 | break; | ||
1714 | 1532 | ||
1715 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD: | ||
1716 | /* skip padding */ | ||
1717 | break; | ||
1718 | 1533 | ||
1719 | default: | 1534 | ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); |
1720 | pass_plaintext_to_core (sender, buf, buf_size); | 1535 | ack.header.size = htons (sizeof(ack)); |
1721 | } | 1536 | ack.sequence_ack = htonl (ss->sequence_allowed); |
1537 | ack.cmac = ss->cmac; | ||
1538 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1539 | "Notifying transport with UDPAck %s, sequence %u and master %s\n", | ||
1540 | GNUNET_i2s_full (&ss->sender->target), | ||
1541 | ss->sequence_allowed, | ||
1542 | GNUNET_h2s (&(ss->master))); | ||
1543 | GNUNET_TRANSPORT_communicator_notify (ch, | ||
1544 | &ss->sender->target, | ||
1545 | COMMUNICATOR_ADDRESS_PREFIX, | ||
1546 | &ack.header); | ||
1722 | } | 1547 | } |
1723 | 1548 | ||
1724 | 1549 | ||
@@ -1726,173 +1551,139 @@ static void | |||
1726 | kce_generate_cb (void *cls) | 1551 | kce_generate_cb (void *cls) |
1727 | { | 1552 | { |
1728 | struct SharedSecret *ss = cls; | 1553 | struct SharedSecret *ss = cls; |
1729 | |||
1730 | ss->sender->kce_task = NULL; | 1554 | ss->sender->kce_task = NULL; |
1731 | 1555 | ||
1732 | if (((GNUNET_NO == ss->sender->rekeying) && (ss->sender->acks_available < | 1556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1733 | KCN_TARGET) ) || | 1557 | "Precomputing %u keys for master %s\n", |
1734 | ((ss->sender->ss_rekey == ss) && (GNUNET_YES == ss->sender->rekeying) && | 1558 | GENERATE_AT_ONCE, |
1735 | (ss->sender->acks_available < KCN_TARGET))) | 1559 | GNUNET_h2s (&(ss->master))); |
1736 | { | 1560 | if ((ss->override_available_acks != GNUNET_YES) && |
1737 | 1561 | (KCN_TARGET < ss->sender->acks_available)) | |
1738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1562 | return; |
1739 | "Precomputing keys for master %s\n", | 1563 | for (int i = 0; i < GENERATE_AT_ONCE; i++) |
1740 | GNUNET_h2s (&(ss->master))); | 1564 | kce_generate (ss, ++ss->sequence_allowed); |
1741 | |||
1742 | for (int i = 0; i < GENERATE_AT_ONCE; i++) | ||
1743 | kce_generate (ss, ++ss->sequence_allowed); | ||
1744 | |||
1745 | if (KCN_TARGET > ss->sender->acks_available) | ||
1746 | { | ||
1747 | ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( | ||
1748 | WORKING_QUEUE_INTERVALL, | ||
1749 | kce_generate_cb, | ||
1750 | ss); | ||
1751 | } | ||
1752 | else | ||
1753 | { | ||
1754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1755 | "We have enough keys.\n"); | ||
1756 | ss_finished = ss; | ||
1757 | ss->sender->kce_task_finished = GNUNET_YES; | ||
1758 | } | ||
1759 | } | ||
1760 | |||
1761 | |||
1762 | } | ||
1763 | |||
1764 | |||
1765 | static void | ||
1766 | kce_generate_rekey_cb (void *cls) | ||
1767 | { | ||
1768 | struct SharedSecret *ss = cls; | ||
1769 | |||
1770 | ss->sender->kce_task_rekey = NULL; | ||
1771 | 1565 | ||
1772 | if (NULL == ss->sender->kce_task) | 1566 | /** |
1567 | * As long as we loose over 30% of max acks in reschedule, | ||
1568 | * We keep generating acks for this ss. | ||
1569 | */ | ||
1570 | if (KCN_TARGET > ss->sender->acks_available) | ||
1773 | { | 1571 | { |
1774 | |||
1775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1776 | "Precomputing keys for rekey master %s\n", | ||
1777 | GNUNET_h2s (&(ss->master))); | ||
1778 | |||
1779 | for (int i = 0; i < GENERATE_AT_ONCE; i++) | ||
1780 | kce_generate (ss, ++ss->sequence_allowed); | ||
1781 | |||
1782 | ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( | 1572 | ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( |
1783 | WORKING_QUEUE_INTERVALL, | 1573 | WORKING_QUEUE_INTERVALL, |
1784 | kce_generate_cb, | 1574 | kce_generate_cb, |
1785 | ss); | 1575 | ss); |
1786 | ss->sender->kce_task_rekey = NULL; | 1576 | return; |
1787 | } | ||
1788 | else | ||
1789 | { | ||
1790 | ss->sender->kce_task_rekey = GNUNET_SCHEDULER_add_delayed ( | ||
1791 | WORKING_QUEUE_INTERVALL, | ||
1792 | kce_generate_rekey_cb, | ||
1793 | ss); | ||
1794 | } | 1577 | } |
1578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1579 | "We have enough keys (ACKs: %u).\n", ss->sender->acks_available); | ||
1580 | ss->sender->kce_task_finished = GNUNET_YES; | ||
1581 | ss->override_available_acks = GNUNET_NO; | ||
1582 | if (ss->sender->kce_send_ack_on_finish == GNUNET_YES) | ||
1583 | consider_ss_ack (ss); | ||
1795 | } | 1584 | } |
1796 | 1585 | ||
1797 | 1586 | ||
1798 | /** | 1587 | /** |
1799 | * We established a shared secret with a sender. We should try to send | 1588 | * Test if we have received a valid message in plaintext. |
1800 | * the sender an `struct UDPAck` at the next opportunity to allow the | 1589 | * If so, handle it. |
1801 | * sender to use @a ss longer (assuming we did not yet already | ||
1802 | * recently). | ||
1803 | * | 1590 | * |
1804 | * @param ss shared secret to generate ACKs for | 1591 | * @param sender peer to process inbound plaintext for |
1805 | * @param initial The SharedSecret came with initial KX. | 1592 | * @param buf buffer we received |
1593 | * @param buf_size number of bytes in @a buf | ||
1806 | */ | 1594 | */ |
1807 | static void | 1595 | static void |
1808 | consider_ss_ack (struct SharedSecret *ss, int initial) | 1596 | try_handle_plaintext (struct SenderAddress *sender, |
1597 | const void *buf, | ||
1598 | size_t buf_size) | ||
1809 | { | 1599 | { |
1810 | struct GNUNET_SCHEDULER_Task *kce_task_rekey; | 1600 | const struct GNUNET_MessageHeader *hdr; |
1811 | struct GNUNET_SCHEDULER_Task *kce_task; | 1601 | const struct UDPAck *ack; |
1812 | int kce_task_finished; | 1602 | const struct UDPRekey *rekey; |
1813 | 1603 | struct SharedSecret *ss_rekey; | |
1814 | kce_task_rekey = ss->sender->kce_task_rekey; | 1604 | const char *buf_pos = buf; |
1815 | kce_task_finished = ss->sender->kce_task_finished; | 1605 | size_t bytes_remaining = buf_size; |
1816 | kce_task = ss->sender->kce_task; | 1606 | uint16_t type; |
1817 | |||
1818 | GNUNET_assert (NULL != ss->sender); | ||
1819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1820 | "Considering SS UDPAck %s\n", | ||
1821 | GNUNET_i2s_full (&ss->sender->target)); | ||
1822 | 1607 | ||
1608 | hdr = (struct GNUNET_MessageHeader*) buf_pos; | ||
1609 | if (sizeof(*hdr) > bytes_remaining) | ||
1610 | { | ||
1611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Plaintext too short, dropping...\n"); | ||
1612 | return; /* no data left */ | ||
1613 | } | ||
1823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1614 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1824 | "We have %u acks available.\n", | 1615 | "try_handle_plaintext of size %lu (%u %lu) and type %u\n", |
1825 | ss->sender->acks_available); | 1616 | bytes_remaining, |
1826 | /* drop ancient KeyCacheEntries */ | 1617 | ntohs (hdr->size), |
1827 | while ((NULL != ss->kce_head) && | 1618 | sizeof(*hdr), |
1828 | (MAX_SQN_DELTA < | 1619 | ntohs (hdr->type)); |
1829 | ss->kce_head->sequence_number - ss->kce_tail->sequence_number)) | 1620 | if (ntohs (hdr->size) > bytes_remaining) |
1830 | kce_destroy (ss->kce_tail); | 1621 | return; /* buffer too short for indicated message length */ |
1831 | 1622 | type = ntohs (hdr->type); | |
1832 | 1623 | switch (type) | |
1833 | if (GNUNET_NO == initial) | 1624 | { |
1834 | kce_generate (ss, ++ss->sequence_allowed); | 1625 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY: |
1835 | 1626 | rekey = (struct UDPRekey*) buf_pos; | |
1836 | if (NULL != kce_task) | 1627 | ss_rekey = setup_shared_secret_dec (&rekey->ephemeral); |
1628 | ss_rekey->sender = sender; | ||
1629 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss_rekey); | ||
1630 | sender->num_secrets++; | ||
1631 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1632 | "Received rekey secret with cmac %s\n", | ||
1633 | GNUNET_h2s (&(ss_rekey->cmac))); | ||
1837 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1838 | "kce_task is not NULL\n"); | 1635 | "Received secret with master %s.\n", |
1839 | if (kce_task_finished) | 1636 | GNUNET_h2s (&(ss_rekey->master))); |
1840 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1841 | "kce_task_finished: GNUNET_YES\n"); | 1638 | "We have %u sequence_allowed.\n", |
1842 | if (initial) | 1639 | ss_rekey->sequence_allowed); |
1843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1640 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1844 | "initial: GNUNET_YES\n"); | 1641 | "We have a sender %p\n", |
1845 | 1642 | ss_rekey->sender); | |
1846 | if (kce_task_finished || (GNUNET_NO == initial)) | ||
1847 | { | ||
1848 | struct UDPAck ack; | ||
1849 | struct SharedSecret *ss_tell; | ||
1850 | |||
1851 | if (GNUNET_NO != initial) | ||
1852 | ss_tell = ss_finished; | ||
1853 | else | ||
1854 | ss_tell = ss; | ||
1855 | |||
1856 | ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); | ||
1857 | ack.header.size = htons (sizeof(ack)); | ||
1858 | ack.sequence_max = htonl (ss_tell->sequence_allowed); | ||
1859 | ack.acks_available = ss->sender->acks_available; | ||
1860 | ack.cmac = ss_tell->cmac; | ||
1861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1862 | "Notifying transport of UDPAck %s with initial %u and master %s\n", | 1644 | "We have %u acks available.\n", |
1863 | GNUNET_i2s_full (&ss_tell->sender->target), | 1645 | ss_rekey->sender->acks_available); |
1864 | initial, | 1646 | ss_rekey->sender->kce_send_ack_on_finish = GNUNET_YES; |
1865 | GNUNET_h2s (&(ss_tell->master))); | 1647 | ss_rekey->override_available_acks = GNUNET_YES; |
1866 | GNUNET_TRANSPORT_communicator_notify (ch, | 1648 | // FIXME |
1867 | &ss_tell->sender->target, | 1649 | ss_rekey->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( |
1868 | COMMUNICATOR_ADDRESS_PREFIX, | 1650 | WORKING_QUEUE_INTERVALL, |
1869 | &ack.header); | 1651 | kce_generate_cb, |
1870 | if (GNUNET_NO != initial) | 1652 | ss_rekey); |
1653 | // FIXME: Theoretically, this could be an Ack | ||
1654 | buf_pos += ntohs (hdr->size); | ||
1655 | bytes_remaining -= ntohs (hdr->size); | ||
1656 | pass_plaintext_to_core (sender, buf_pos, bytes_remaining); | ||
1657 | if (sender->num_secrets > MAX_SECRETS) | ||
1871 | { | 1658 | { |
1872 | destroy_all_secrets (ss, GNUNET_YES); | 1659 | if (0 == purge_secrets (sender->ss_tail)) |
1873 | ss->sender->kce_task_finished = GNUNET_NO; | 1660 | { |
1661 | // No secret purged. Delete oldest. | ||
1662 | secret_destroy (sender->ss_tail); | ||
1663 | } | ||
1874 | } | 1664 | } |
1875 | } | 1665 | break; |
1876 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > | 1666 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK: |
1877 | ss->sender->acks_available) || | 1667 | /* lookup master secret by 'cmac', then update sequence_max */ |
1878 | (GNUNET_YES == ss->sender->rekeying) || | 1668 | ack = (struct UDPAck*) buf_pos; |
1879 | (ss->sender->num_secrets > MAX_SECRETS) )) | 1669 | GNUNET_CONTAINER_multipeermap_get_multiple (receivers, |
1880 | { | 1670 | &sender->target, |
1671 | &handle_ack, | ||
1672 | (void *) ack); | ||
1673 | /* There could be more messages after the ACK, handle those as well */ | ||
1674 | buf_pos += ntohs (hdr->size); | ||
1675 | bytes_remaining -= ntohs (hdr->size); | ||
1676 | pass_plaintext_to_core (sender, buf_pos, bytes_remaining); | ||
1677 | break; | ||
1881 | 1678 | ||
1882 | // TODO This task must be per sender! FIXME: This is a nice todo, but I do not know what must be done here to fix. | 1679 | case GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD: |
1883 | kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL, | 1680 | /* skip padding */ |
1884 | kce_generate_cb, | 1681 | break; |
1885 | ss); | ||
1886 | kce_task_finished = GNUNET_NO; | ||
1887 | 1682 | ||
1683 | default: | ||
1684 | pass_plaintext_to_core (sender, buf_pos, bytes_remaining); | ||
1888 | } | 1685 | } |
1889 | else if ((NULL == kce_task_rekey) && (GNUNET_YES == | 1686 | return; |
1890 | ss->sender->rekeying) ) | ||
1891 | { | ||
1892 | kce_task_rekey = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL, | ||
1893 | kce_generate_rekey_cb, | ||
1894 | ss); | ||
1895 | } | ||
1896 | } | 1687 | } |
1897 | 1688 | ||
1898 | 1689 | ||
@@ -1919,6 +1710,7 @@ decrypt_box (const struct UDPBox *box, | |||
1919 | sizeof(out_buf), | 1710 | sizeof(out_buf), |
1920 | out_buf)) | 1711 | out_buf)) |
1921 | { | 1712 | { |
1713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed decryption.\n"); | ||
1922 | GNUNET_STATISTICS_update (stats, | 1714 | GNUNET_STATISTICS_update (stats, |
1923 | "# Decryption failures with valid KCE", | 1715 | "# Decryption failures with valid KCE", |
1924 | 1, | 1716 | 1, |
@@ -1927,6 +1719,7 @@ decrypt_box (const struct UDPBox *box, | |||
1927 | return; | 1719 | return; |
1928 | } | 1720 | } |
1929 | kce_destroy (kce); | 1721 | kce_destroy (kce); |
1722 | kce = NULL; | ||
1930 | GNUNET_STATISTICS_update (stats, | 1723 | GNUNET_STATISTICS_update (stats, |
1931 | "# bytes decrypted with BOX", | 1724 | "# bytes decrypted with BOX", |
1932 | sizeof(out_buf), | 1725 | sizeof(out_buf), |
@@ -1939,95 +1732,18 @@ decrypt_box (const struct UDPBox *box, | |||
1939 | "decrypted UDPBox with kid %s\n", | 1732 | "decrypted UDPBox with kid %s\n", |
1940 | GNUNET_sh2s (&box->kid)); | 1733 | GNUNET_sh2s (&box->kid)); |
1941 | try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); | 1734 | try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); |
1942 | if ((GNUNET_NO == box->rekeying) && (GNUNET_YES == ss->sender->rekeying)) | 1735 | if ((KCN_THRESHOLD > ss->sender->acks_available) && |
1943 | { | 1736 | (NULL == ss->sender->kce_task) && |
1944 | ss->sender->rekeying = GNUNET_NO; | 1737 | (GNUNET_YES == ss->sender->kce_task_finished)) |
1945 | ss->sender->ss_rekey = NULL; | ||
1946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1947 | "Receiver stopped rekeying.\n"); | ||
1948 | } | ||
1949 | else | ||
1950 | { | ||
1951 | ss->sender->rekeying = GNUNET_YES; | ||
1952 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1953 | "Got Box: Receiver doing rekeying.\n"); | ||
1954 | } | ||
1955 | } | ||
1956 | |||
1957 | |||
1958 | /** | ||
1959 | * We received a @a rekey with matching @a kce. Decrypt and process it. | ||
1960 | * | ||
1961 | * @param rekey the data we received | ||
1962 | * @param rekey_len number of bytes in @a rekey | ||
1963 | * @param kce key index to decrypt @a rekey | ||
1964 | */ | ||
1965 | static void | ||
1966 | decrypt_rekey (const struct UDPRekey *rekey, | ||
1967 | size_t rekey_len, | ||
1968 | struct KeyCacheEntry *kce, | ||
1969 | struct SenderAddress *sender) | ||
1970 | { | ||
1971 | struct SharedSecret *ss = kce->ss; | ||
1972 | struct SharedSecret *ss_rekey; | ||
1973 | char out_buf[rekey_len - sizeof(*rekey)]; | ||
1974 | struct GNUNET_HashCode *master; | ||
1975 | |||
1976 | |||
1977 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1978 | "decrypt_rekey.\n"); | ||
1979 | |||
1980 | GNUNET_assert (NULL != ss->sender); | ||
1981 | if (GNUNET_OK != try_decrypt (ss, | ||
1982 | rekey->gcm_tag, | ||
1983 | kce->sequence_number, | ||
1984 | (const char *) &rekey[1], | ||
1985 | sizeof(out_buf), | ||
1986 | out_buf)) | ||
1987 | { | 1738 | { |
1988 | GNUNET_STATISTICS_update (stats, | ||
1989 | "# Decryption failures with valid KCE", | ||
1990 | 1, | ||
1991 | GNUNET_NO); | ||
1992 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1993 | "Decryption with kid %s failed\n", | 1740 | "Sender has %u ack left which is under threshold.\n", |
1994 | GNUNET_sh2s (&rekey->kid)); | 1741 | ss->sender->acks_available); |
1995 | kce_destroy (kce); | 1742 | ss->sender->kce_send_ack_on_finish = GNUNET_YES; |
1996 | return; | 1743 | ss->sender->kce_task = GNUNET_SCHEDULER_add_now ( |
1744 | kce_generate_cb, | ||
1745 | ss); | ||
1997 | } | 1746 | } |
1998 | kce_destroy (kce); | ||
1999 | GNUNET_STATISTICS_update (stats, | ||
2000 | "# bytes decrypted with Rekey", | ||
2001 | sizeof(out_buf), | ||
2002 | GNUNET_NO); | ||
2003 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2004 | "decrypted UDPRekey with kid %s\n", | ||
2005 | GNUNET_sh2s (&rekey->kid)); | ||
2006 | master = (struct GNUNET_HashCode *) out_buf; | ||
2007 | ss_rekey = GNUNET_new (struct SharedSecret); | ||
2008 | ss_rekey->master = *master; | ||
2009 | calculate_cmac (ss_rekey); | ||
2010 | ss_rekey->sender = sender; | ||
2011 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss_rekey); | ||
2012 | sender->ss_rekey = ss_rekey; | ||
2013 | sender->num_secrets++; | ||
2014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2015 | "Received secret with cmac %s\n", | ||
2016 | GNUNET_h2s (&(ss_rekey->cmac))); | ||
2017 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2018 | "Received secret with master %s.\n", | ||
2019 | GNUNET_h2s (&(ss_rekey->master))); | ||
2020 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2021 | "We have %u sequence_allowed.\n", | ||
2022 | ss_rekey->sequence_allowed); | ||
2023 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2024 | "We have a sender %p\n", | ||
2025 | ss_rekey->sender); | ||
2026 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2027 | "We have %u acks available.\n", | ||
2028 | ss_rekey->sender->acks_available); | ||
2029 | consider_ss_ack (ss_rekey, GNUNET_YES); | ||
2030 | |||
2031 | } | 1747 | } |
2032 | 1748 | ||
2033 | 1749 | ||
@@ -2218,222 +1934,196 @@ sock_read (void *cls) | |||
2218 | udp_sock, | 1934 | udp_sock, |
2219 | &sock_read, | 1935 | &sock_read, |
2220 | NULL); | 1936 | NULL); |
2221 | rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock, | 1937 | while (1) |
2222 | buf, | 1938 | { |
2223 | sizeof(buf), | 1939 | rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock, |
2224 | (struct sockaddr *) &sa, | 1940 | buf, |
2225 | &salen); | 1941 | sizeof(buf), |
2226 | if (-1 == rcvd) | 1942 | (struct sockaddr *) &sa, |
2227 | { | 1943 | &salen); |
2228 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); | 1944 | if (-1 == rcvd) |
2229 | return; | ||
2230 | } | ||
2231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2232 | "Read %lu bytes\n", rcvd); | ||
2233 | |||
2234 | if (rcvd > sizeof(struct UDPRekey)) | ||
2235 | { | ||
2236 | const struct UDPRekey *rekey; | ||
2237 | const struct UDPBox *box; | ||
2238 | struct KeyCacheEntry *kce; | ||
2239 | struct SenderAddress *sender; | ||
2240 | int do_decrypt = GNUNET_NO; | ||
2241 | |||
2242 | rekey = (const struct UDPRekey *) buf; | ||
2243 | box = (const struct UDPBox *) buf; | ||
2244 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &rekey->kid); | ||
2245 | |||
2246 | if ((GNUNET_YES == box->rekeying) || (GNUNET_NO == box->rekeying)) | ||
2247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2248 | "UDPRekey has rekeying %u\n", | ||
2249 | box->rekeying); | ||
2250 | else | ||
2251 | do_decrypt = GNUNET_YES; | ||
2252 | |||
2253 | if ((GNUNET_YES == do_decrypt) && (NULL != kce) && (GNUNET_YES == | ||
2254 | kce->ss->sender-> | ||
2255 | rekeying)) | ||
2256 | { | 1945 | { |
2257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1946 | if (EAGAIN == errno) |
2258 | "UDPRekey with kid %s\n", | 1947 | break; // We are done reading data |
2259 | GNUNET_sh2s (&rekey->kid)); | 1948 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); |
2260 | sender = setup_sender (&rekey->sender, (const struct sockaddr *) &sa, | ||
2261 | salen); | ||
2262 | |||
2263 | if (NULL != sender->ss_rekey) | ||
2264 | return; | ||
2265 | |||
2266 | decrypt_rekey (rekey, (size_t) rcvd, kce, sender); | ||
2267 | return; | 1949 | return; |
2268 | } | 1950 | } |
2269 | } | 1951 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2270 | 1952 | "Read %lu bytes\n", rcvd); | |
2271 | /* first, see if it is a UDPBox */ | ||
2272 | if (rcvd > sizeof(struct UDPBox)) | ||
2273 | { | ||
2274 | const struct UDPBox *box; | ||
2275 | struct KeyCacheEntry *kce; | ||
2276 | 1953 | ||
2277 | box = (const struct UDPBox *) buf; | 1954 | /* first, see if it is a UDPBox */ |
2278 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &box->kid); | 1955 | if (rcvd > sizeof(struct UDPBox)) |
2279 | if (NULL != kce) | ||
2280 | { | 1956 | { |
2281 | decrypt_box (box, (size_t) rcvd, kce); | 1957 | const struct UDPBox *box; |
2282 | return; | 1958 | struct KeyCacheEntry *kce; |
2283 | } | ||
2284 | } | ||
2285 | 1959 | ||
2286 | /* next, check if it is a broadcast */ | 1960 | box = (const struct UDPBox *) buf; |
2287 | if (sizeof(struct UDPBroadcast) == rcvd) | 1961 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &box->kid); |
2288 | { | 1962 | if (NULL != kce) |
2289 | const struct UDPBroadcast *ub; | 1963 | { |
2290 | struct UdpBroadcastSignature uhs; | 1964 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2291 | struct GNUNET_PeerIdentity sender; | 1965 | "Found KCE with kid %s\n", |
1966 | GNUNET_sh2s (&box->kid)); | ||
1967 | decrypt_box (box, (size_t) rcvd, kce); | ||
1968 | continue; | ||
1969 | } | ||
1970 | } | ||
2292 | 1971 | ||
2293 | addr_verify = GNUNET_memdup (&sa, salen); | 1972 | /* next, check if it is a broadcast */ |
2294 | addr_verify->sin_port = 0; | 1973 | if (sizeof(struct UDPBroadcast) == rcvd) |
2295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2296 | "received UDPBroadcast from %s\n", | ||
2297 | GNUNET_a2s ((const struct sockaddr *) addr_verify, salen)); | ||
2298 | ub = (const struct UDPBroadcast *) buf; | ||
2299 | uhs.purpose.purpose = htonl ( | ||
2300 | GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST); | ||
2301 | uhs.purpose.size = htonl (sizeof(uhs)); | ||
2302 | uhs.sender = ub->sender; | ||
2303 | sender = ub->sender; | ||
2304 | if (0 == memcmp (&sender, &my_identity, sizeof (struct | ||
2305 | GNUNET_PeerIdentity))) | ||
2306 | { | 1974 | { |
1975 | const struct UDPBroadcast *ub; | ||
1976 | struct UdpBroadcastSignature uhs; | ||
1977 | struct GNUNET_PeerIdentity sender; | ||
1978 | |||
1979 | addr_verify = GNUNET_memdup (&sa, salen); | ||
1980 | addr_verify->sin_port = 0; | ||
2307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1981 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2308 | "Received our own broadcast\n"); | 1982 | "received UDPBroadcast from %s\n", |
2309 | GNUNET_free (addr_verify); | 1983 | GNUNET_a2s ((const struct sockaddr *) addr_verify, salen)); |
2310 | return; | 1984 | ub = (const struct UDPBroadcast *) buf; |
2311 | } | 1985 | uhs.purpose.purpose = htonl ( |
2312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1986 | GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST); |
2313 | "checking UDPBroadcastSignature for %s\n", | 1987 | uhs.purpose.size = htonl (sizeof(uhs)); |
2314 | GNUNET_i2s (&sender)); | 1988 | uhs.sender = ub->sender; |
2315 | GNUNET_CRYPTO_hash ((struct sockaddr *) addr_verify, salen, &uhs.h_address); | 1989 | sender = ub->sender; |
2316 | if (GNUNET_OK == | 1990 | if (0 == memcmp (&sender, &my_identity, sizeof (struct |
2317 | GNUNET_CRYPTO_eddsa_verify ( | 1991 | GNUNET_PeerIdentity))) |
2318 | GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST, | 1992 | { |
2319 | &uhs, | 1993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2320 | &ub->sender_sig, | 1994 | "Received our own broadcast\n"); |
2321 | &ub->sender.public_key)) | 1995 | GNUNET_free (addr_verify); |
2322 | { | 1996 | continue; |
2323 | char *addr_s; | 1997 | } |
2324 | enum GNUNET_NetworkType nt; | ||
2325 | |||
2326 | addr_s = | ||
2327 | sockaddr_to_udpaddr_string ((const struct sockaddr *) &sa, salen); | ||
2328 | GNUNET_STATISTICS_update (stats, "# broadcasts received", 1, GNUNET_NO); | ||
2329 | /* use our own mechanism to determine network type */ | ||
2330 | nt = | ||
2331 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); | ||
2332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1998 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2333 | "validating address %s received from UDPBroadcast\n", | 1999 | "checking UDPBroadcastSignature for %s\n", |
2334 | GNUNET_i2s (&sender)); | 2000 | GNUNET_i2s (&sender)); |
2335 | GNUNET_TRANSPORT_application_validate (ah, &sender, nt, addr_s); | 2001 | GNUNET_CRYPTO_hash ((struct sockaddr *) addr_verify, salen, |
2336 | GNUNET_free (addr_s); | 2002 | &uhs.h_address); |
2003 | if (GNUNET_OK == | ||
2004 | GNUNET_CRYPTO_eddsa_verify ( | ||
2005 | GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST, | ||
2006 | &uhs, | ||
2007 | &ub->sender_sig, | ||
2008 | &ub->sender.public_key)) | ||
2009 | { | ||
2010 | char *addr_s; | ||
2011 | enum GNUNET_NetworkType nt; | ||
2012 | |||
2013 | addr_s = | ||
2014 | sockaddr_to_udpaddr_string ((const struct sockaddr *) &sa, salen); | ||
2015 | GNUNET_STATISTICS_update (stats, "# broadcasts received", 1, GNUNET_NO); | ||
2016 | /* use our own mechanism to determine network type */ | ||
2017 | nt = | ||
2018 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); | ||
2019 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2020 | "validating address %s received from UDPBroadcast\n", | ||
2021 | GNUNET_i2s (&sender)); | ||
2022 | GNUNET_TRANSPORT_application_validate (ah, &sender, nt, addr_s); | ||
2023 | GNUNET_free (addr_s); | ||
2024 | GNUNET_free (addr_verify); | ||
2025 | continue; | ||
2026 | } | ||
2027 | else | ||
2028 | { | ||
2029 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2030 | "VerifyingPeer %s is verifying UDPBroadcast\n", | ||
2031 | GNUNET_i2s (&my_identity)); | ||
2032 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2033 | "Verifying UDPBroadcast from %s failed\n", | ||
2034 | GNUNET_i2s (&ub->sender)); | ||
2035 | } | ||
2337 | GNUNET_free (addr_verify); | 2036 | GNUNET_free (addr_verify); |
2338 | return; | 2037 | /* continue with KX, mostly for statistics... */ |
2339 | } | 2038 | } |
2340 | else | ||
2341 | { | ||
2342 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2343 | "VerifyingPeer %s is verifying UDPBroadcast\n", | ||
2344 | GNUNET_i2s (&my_identity)); | ||
2345 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2346 | "Verifying UDPBroadcast from %s failed\n", | ||
2347 | GNUNET_i2s (&ub->sender)); | ||
2348 | } | ||
2349 | GNUNET_free (addr_verify); | ||
2350 | /* continue with KX, mostly for statistics... */ | ||
2351 | } | ||
2352 | |||
2353 | |||
2354 | /* finally, test if it is a KX */ | ||
2355 | if (rcvd < sizeof(struct UDPConfirmation) + sizeof(struct InitialKX)) | ||
2356 | { | ||
2357 | GNUNET_STATISTICS_update (stats, | ||
2358 | "# messages dropped (no kid, too small for KX)", | ||
2359 | 1, | ||
2360 | GNUNET_NO); | ||
2361 | return; | ||
2362 | } | ||
2363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2364 | "Got KX\n"); | ||
2365 | { | ||
2366 | const struct InitialKX *kx; | ||
2367 | struct SharedSecret *ss; | ||
2368 | char pbuf[rcvd - sizeof(struct InitialKX)]; | ||
2369 | const struct UDPConfirmation *uc; | ||
2370 | struct SenderAddress *sender; | ||
2371 | 2039 | ||
2372 | kx = (const struct InitialKX *) buf; | ||
2373 | ss = setup_shared_secret_dec (&kx->ephemeral); | ||
2374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2375 | "Before DEC\n"); | ||
2376 | |||
2377 | if (GNUNET_OK != try_decrypt (ss, | ||
2378 | kx->gcm_tag, | ||
2379 | 0, | ||
2380 | &buf[sizeof(*kx)], | ||
2381 | sizeof(pbuf), | ||
2382 | pbuf)) | ||
2383 | { | ||
2384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2385 | "Unable to decrypt tag, dropping...\n"); | ||
2386 | GNUNET_free (ss); | ||
2387 | GNUNET_STATISTICS_update ( | ||
2388 | stats, | ||
2389 | "# messages dropped (no kid, AEAD decryption failed)", | ||
2390 | 1, | ||
2391 | GNUNET_NO); | ||
2392 | return; | ||
2393 | } | ||
2394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2395 | "Before VERIFY\n"); | ||
2396 | 2040 | ||
2397 | uc = (const struct UDPConfirmation *) pbuf; | 2041 | /* finally, test if it is a KX */ |
2398 | if (GNUNET_OK != verify_confirmation (&kx->ephemeral, uc)) | 2042 | if (rcvd < sizeof(struct UDPConfirmation) + sizeof(struct InitialKX)) |
2399 | { | 2043 | { |
2400 | GNUNET_break_op (0); | ||
2401 | GNUNET_free (ss); | ||
2402 | GNUNET_STATISTICS_update (stats, | 2044 | GNUNET_STATISTICS_update (stats, |
2403 | "# messages dropped (sender signature invalid)", | 2045 | "# messages dropped (no kid, too small for KX)", |
2404 | 1, | 2046 | 1, |
2405 | GNUNET_NO); | 2047 | GNUNET_NO); |
2406 | return; | 2048 | continue; |
2407 | } | 2049 | } |
2408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2409 | "Before SETUP_SENDER\n"); | 2051 | "Got KX\n"); |
2410 | |||
2411 | calculate_cmac (ss); | ||
2412 | sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen); | ||
2413 | ss->sender = sender; | ||
2414 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss); | ||
2415 | sender->num_secrets++; | ||
2416 | GNUNET_STATISTICS_update (stats, "# Secrets active", 1, GNUNET_NO); | ||
2417 | GNUNET_STATISTICS_update (stats, | ||
2418 | "# messages decrypted without BOX", | ||
2419 | 1, | ||
2420 | GNUNET_NO); | ||
2421 | try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); | ||
2422 | if ((GNUNET_NO == kx->rekeying) && (GNUNET_YES == ss->sender->rekeying)) | ||
2423 | { | 2052 | { |
2424 | ss->sender->rekeying = GNUNET_NO; | 2053 | const struct InitialKX *kx; |
2425 | sender->ss_rekey = NULL; | 2054 | struct SharedSecret *ss; |
2426 | // destroy_all_secrets (ss, GNUNET_NO); | 2055 | char pbuf[rcvd - sizeof(struct InitialKX)]; |
2056 | const struct UDPConfirmation *uc; | ||
2057 | struct SenderAddress *sender; | ||
2058 | |||
2059 | kx = (const struct InitialKX *) buf; | ||
2060 | ss = setup_shared_secret_dec (&kx->ephemeral); | ||
2427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2428 | "Receiver stopped rekeying.\n"); | 2062 | "Before DEC\n"); |
2429 | } | 2063 | |
2430 | else if (GNUNET_NO == kx->rekeying) | 2064 | if (GNUNET_OK != try_decrypt (ss, |
2431 | consider_ss_ack (ss, GNUNET_YES); | 2065 | kx->gcm_tag, |
2432 | else | 2066 | 0, |
2433 | { | 2067 | &buf[sizeof(*kx)], |
2434 | ss->sender->rekeying = GNUNET_YES; | 2068 | sizeof(pbuf), |
2069 | pbuf)) | ||
2070 | { | ||
2071 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2072 | "Unable to decrypt tag, dropping...\n"); | ||
2073 | GNUNET_free (ss); | ||
2074 | GNUNET_STATISTICS_update ( | ||
2075 | stats, | ||
2076 | "# messages dropped (no kid, AEAD decryption failed)", | ||
2077 | 1, | ||
2078 | GNUNET_NO); | ||
2079 | continue; | ||
2080 | } | ||
2081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2082 | "Before VERIFY\n"); | ||
2083 | |||
2084 | uc = (const struct UDPConfirmation *) pbuf; | ||
2085 | if (GNUNET_OK != verify_confirmation (&kx->ephemeral, uc)) | ||
2086 | { | ||
2087 | GNUNET_break_op (0); | ||
2088 | GNUNET_free (ss); | ||
2089 | GNUNET_STATISTICS_update (stats, | ||
2090 | "# messages dropped (sender signature invalid)", | ||
2091 | 1, | ||
2092 | GNUNET_NO); | ||
2093 | continue; | ||
2094 | } | ||
2435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2095 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2436 | "Got KX: Receiver doing rekeying.\n"); | 2096 | "Before SETUP_SENDER\n"); |
2097 | |||
2098 | calculate_cmac (ss); | ||
2099 | sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen); | ||
2100 | ss->sender = sender; | ||
2101 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss); | ||
2102 | if ((KCN_THRESHOLD > ss->sender->acks_available) && | ||
2103 | (NULL == ss->sender->kce_task) && | ||
2104 | (GNUNET_NO == ss->sender->kce_task_finished)) | ||
2105 | { | ||
2106 | // TODO This task must be per sender! FIXME: This is a nice todo, but I do not know what must be done here to fix. | ||
2107 | ss->sender->kce_send_ack_on_finish = GNUNET_YES; | ||
2108 | ss->sender->kce_task = GNUNET_SCHEDULER_add_now ( | ||
2109 | kce_generate_cb, | ||
2110 | ss); | ||
2111 | } | ||
2112 | sender->num_secrets++; | ||
2113 | GNUNET_STATISTICS_update (stats, "# Secrets active", 1, GNUNET_NO); | ||
2114 | GNUNET_STATISTICS_update (stats, | ||
2115 | "# messages decrypted without BOX", | ||
2116 | 1, | ||
2117 | GNUNET_NO); | ||
2118 | try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); | ||
2119 | if (sender->num_secrets > MAX_SECRETS) | ||
2120 | { | ||
2121 | if (0 == purge_secrets (sender->ss_tail)) | ||
2122 | { | ||
2123 | // No secret purged. Delete oldest. | ||
2124 | secret_destroy (sender->ss_tail); | ||
2125 | } | ||
2126 | } | ||
2437 | } | 2127 | } |
2438 | } | 2128 | } |
2439 | } | 2129 | } |
@@ -2601,31 +2291,19 @@ do_pad (gcry_cipher_hd_t out_cipher, char *dgram, size_t pad_size) | |||
2601 | } | 2291 | } |
2602 | 2292 | ||
2603 | 2293 | ||
2604 | /** | ||
2605 | * Signature of functions implementing the sending functionality of a | ||
2606 | * message queue. | ||
2607 | * | ||
2608 | * @param mq the message queue | ||
2609 | * @param msg the message to send | ||
2610 | * @param impl_state our `struct ReceiverAddress` | ||
2611 | */ | ||
2612 | static void | 2294 | static void |
2613 | mq_send_kx (struct GNUNET_MQ_Handle *mq, | 2295 | send_msg_with_kx (const struct GNUNET_MessageHeader *msg, struct |
2614 | const struct GNUNET_MessageHeader *msg, | 2296 | ReceiverAddress *receiver) |
2615 | void *impl_state) | ||
2616 | { | 2297 | { |
2617 | struct ReceiverAddress *receiver = impl_state; | ||
2618 | uint16_t msize = ntohs (msg->size); | 2298 | uint16_t msize = ntohs (msg->size); |
2619 | struct UdpHandshakeSignature uhs; | 2299 | struct UdpHandshakeSignature uhs; |
2620 | struct UDPConfirmation uc; | 2300 | struct UDPConfirmation uc; |
2621 | struct InitialKX kx; | 2301 | struct InitialKX kx; |
2622 | struct GNUNET_CRYPTO_EcdhePrivateKey epriv; | ||
2623 | char dgram[receiver->kx_mtu + sizeof(uc) + sizeof(kx)]; | 2302 | char dgram[receiver->kx_mtu + sizeof(uc) + sizeof(kx)]; |
2624 | size_t dpos; | 2303 | size_t dpos; |
2625 | gcry_cipher_hd_t out_cipher; | 2304 | gcry_cipher_hd_t out_cipher; |
2626 | struct SharedSecret *ss; | 2305 | struct SharedSecret *ss; |
2627 | 2306 | ||
2628 | GNUNET_assert (mq == receiver->kx_mq); | ||
2629 | if (msize > receiver->kx_mtu) | 2307 | if (msize > receiver->kx_mtu) |
2630 | { | 2308 | { |
2631 | GNUNET_break (0); | 2309 | GNUNET_break (0); |
@@ -2636,13 +2314,16 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2636 | reschedule_receiver_timeout (receiver); | 2314 | reschedule_receiver_timeout (receiver); |
2637 | 2315 | ||
2638 | /* setup key material */ | 2316 | /* setup key material */ |
2639 | GNUNET_CRYPTO_ecdhe_key_create (&epriv); | ||
2640 | 2317 | ||
2641 | ss = setup_shared_secret_enc (&epriv, receiver, GNUNET_YES); | 2318 | ss = setup_shared_secret_ephemeral (&uhs.ephemeral, receiver); |
2642 | 2319 | ||
2643 | if (receiver->num_secrets > MAX_SECRETS) | 2320 | if (receiver->num_secrets > MAX_SECRETS) |
2644 | { | 2321 | { |
2645 | destroy_all_secrets (ss, GNUNET_YES); | 2322 | if (0 == purge_secrets (receiver->ss_tail)) |
2323 | { | ||
2324 | // No secret purged. Delete oldest. | ||
2325 | secret_destroy (receiver->ss_tail); | ||
2326 | } | ||
2646 | } | 2327 | } |
2647 | 2328 | ||
2648 | setup_cipher (&ss->master, 0, &out_cipher); | 2329 | setup_cipher (&ss->master, 0, &out_cipher); |
@@ -2655,7 +2336,6 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2655 | uhs.purpose.size = htonl (sizeof(uhs)); | 2336 | uhs.purpose.size = htonl (sizeof(uhs)); |
2656 | uhs.sender = my_identity; | 2337 | uhs.sender = my_identity; |
2657 | uhs.receiver = receiver->target; | 2338 | uhs.receiver = receiver->target; |
2658 | GNUNET_CRYPTO_ecdhe_key_get_public (&epriv, &uhs.ephemeral); | ||
2659 | uhs.monotonic_time = uc.monotonic_time; | 2339 | uhs.monotonic_time = uc.monotonic_time; |
2660 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 2340 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
2661 | &uhs, | 2341 | &uhs, |
@@ -2679,10 +2359,6 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2679 | GNUNET_assert ( | 2359 | GNUNET_assert ( |
2680 | 0 == gcry_cipher_gettag (out_cipher, kx.gcm_tag, sizeof(kx.gcm_tag))); | 2360 | 0 == gcry_cipher_gettag (out_cipher, kx.gcm_tag, sizeof(kx.gcm_tag))); |
2681 | gcry_cipher_close (out_cipher); | 2361 | gcry_cipher_close (out_cipher); |
2682 | if (GNUNET_NO == receiver->rekeying) | ||
2683 | kx.rekeying = GNUNET_NO; | ||
2684 | else | ||
2685 | kx.rekeying = GNUNET_YES; | ||
2686 | memcpy (dgram, &kx, sizeof(kx)); | 2362 | memcpy (dgram, &kx, sizeof(kx)); |
2687 | if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, | 2363 | if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, |
2688 | dgram, | 2364 | dgram, |
@@ -2695,168 +2371,51 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2695 | msize, | 2371 | msize, |
2696 | GNUNET_a2s (receiver->address, | 2372 | GNUNET_a2s (receiver->address, |
2697 | receiver->address_len)); | 2373 | receiver->address_len)); |
2698 | GNUNET_MQ_impl_send_continue (mq); | ||
2699 | } | 2374 | } |
2700 | 2375 | ||
2701 | 2376 | ||
2377 | /** | ||
2378 | * Signature of functions implementing the sending functionality of a | ||
2379 | * message queue. | ||
2380 | * | ||
2381 | * @param mq the message queue | ||
2382 | * @param msg the message to send | ||
2383 | * @param impl_state our `struct ReceiverAddress` | ||
2384 | */ | ||
2702 | static void | 2385 | static void |
2703 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | 2386 | mq_send_kx (struct GNUNET_MQ_Handle *mq, |
2387 | const struct GNUNET_MessageHeader *msg, | ||
2388 | void *impl_state) | ||
2704 | { | 2389 | { |
2390 | struct ReceiverAddress *receiver = impl_state; | ||
2705 | 2391 | ||
2706 | struct GNUNET_TIME_Relative rt; | 2392 | GNUNET_assert (mq == receiver->kx_mq); |
2707 | 2393 | send_msg_with_kx (msg, receiver); | |
2708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2394 | GNUNET_MQ_impl_send_continue (mq); |
2709 | "Timeout is %llu\n.", | ||
2710 | (unsigned long long) receiver->rekey_timeout.abs_value_us); | ||
2711 | |||
2712 | if (0 == receiver->rekey_timeout.abs_value_us) | ||
2713 | { | ||
2714 | receiver->rekey_timeout = GNUNET_TIME_relative_to_absolute ( | ||
2715 | rekey_interval); | ||
2716 | } | ||
2717 | else | ||
2718 | { | ||
2719 | rt = GNUNET_TIME_absolute_get_remaining (receiver->rekey_timeout); | ||
2720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2721 | "Relative time is %llu and timeout is %llu\n.", | ||
2722 | (unsigned long long) rt.rel_value_us, | ||
2723 | (unsigned long long) receiver->rekey_timeout.abs_value_us); | ||
2724 | |||
2725 | if ((0 == rt.rel_value_us) || (receiver->rekey_send_bytes > | ||
2726 | rekey_max_bytes) ) | ||
2727 | { | ||
2728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2729 | "Bytes send %llu greater than %llu max bytes\n.", | ||
2730 | (unsigned long long) receiver->rekey_send_bytes, | ||
2731 | rekey_max_bytes); | ||
2732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2733 | "Relative time is %llu and timeout is %llu\n.", | ||
2734 | (unsigned long long) rt.rel_value_us, | ||
2735 | (unsigned long long) receiver->rekey_timeout.abs_value_us); | ||
2736 | |||
2737 | receiver->rekey_timeout.abs_value_us = 0; | ||
2738 | receiver->rekey_send_bytes = 0; | ||
2739 | receiver->ss_rekey = NULL; | ||
2740 | // destroy_all_secrets (ss, GNUNET_NO); | ||
2741 | receiver->rekeying = GNUNET_YES; | ||
2742 | receiver->rekey_acks_available = receiver->acks_available; | ||
2743 | box->rekeying = GNUNET_YES; | ||
2744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2745 | "Sender started rekeying.\n"); | ||
2746 | if (GNUNET_YES == box->rekeying) | ||
2747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2748 | "Sending rekeying with kid %s\n", | ||
2749 | GNUNET_sh2s (&box->kid)); | ||
2750 | } | ||
2751 | } | ||
2752 | } | 2395 | } |
2753 | 2396 | ||
2754 | 2397 | ||
2755 | static void | 2398 | static void |
2756 | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) | 2399 | create_rekey (struct ReceiverAddress *receiver, struct SharedSecret *ss, struct |
2757 | { | 2400 | UDPRekey *rekey) |
2758 | uint8_t is_ss_rekey_sequence_allowed_zero = GNUNET_NO; | 2401 | { |
2759 | uint8_t is_acks_available_below = GNUNET_NO; | 2402 | struct SharedSecret *ss_rekey; |
2760 | uint8_t send_rekey = GNUNET_NO; | ||
2761 | uint16_t not_below; | ||
2762 | struct GNUNET_CRYPTO_EcdhePrivateKey epriv; | ||
2763 | struct UDPRekey *rekey; | ||
2764 | size_t dpos; | ||
2765 | |||
2766 | char rekey_dgram[sizeof(struct UDPRekey) + receiver->d_mtu]; | ||
2767 | |||
2768 | if (NULL != receiver->ss_rekey) | ||
2769 | { | ||
2770 | not_below = (receiver->rekey_acks_available | ||
2771 | - (receiver->rekey_acks_available % 3)) / 3; | ||
2772 | is_ss_rekey_sequence_allowed_zero = (0 == | ||
2773 | receiver->ss_rekey->sequence_allowed); | ||
2774 | is_acks_available_below = (receiver->acks_available >= not_below); | ||
2775 | send_rekey = (0 == (receiver->acks_available - not_below) % not_below) && | ||
2776 | is_acks_available_below && is_ss_rekey_sequence_allowed_zero; | ||
2777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2778 | "send_rekey: %u, %u, %u\n", | ||
2779 | send_rekey, | ||
2780 | receiver->rekey_acks_available, | ||
2781 | receiver->acks_available); | ||
2782 | } | ||
2783 | else if (NULL == receiver->ss_rekey) | ||
2784 | { | ||
2785 | /* setup key material */ | ||
2786 | GNUNET_CRYPTO_ecdhe_key_create (&epriv); | ||
2787 | receiver->ss_rekey = setup_shared_secret_enc (&epriv, receiver, | ||
2788 | GNUNET_NO); | ||
2789 | receiver->ss_rekey->sequence_allowed = 0; | ||
2790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2791 | "Setup secret with cmac %s\n", | ||
2792 | GNUNET_h2s (&(receiver->ss_rekey->cmac))); | ||
2793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2794 | "Setup secret with master %s.\n", | ||
2795 | GNUNET_h2s (&(receiver->ss_rekey->master))); | ||
2796 | } | ||
2797 | |||
2798 | if (send_rekey) | ||
2799 | { | ||
2800 | GNUNET_assert (0 != receiver->number_rekeying_kce); | ||
2801 | gcry_cipher_hd_t rekey_out_cipher; | ||
2802 | |||
2803 | while (NULL != ss && ss->sequence_used >= ss->sequence_allowed) | ||
2804 | { | ||
2805 | ss = ss->prev; | ||
2806 | } | ||
2807 | |||
2808 | if (NULL != ss) | ||
2809 | { | ||
2810 | rekey = (struct UDPRekey *) rekey_dgram; | ||
2811 | rekey->sender = my_identity; | ||
2812 | ss->sequence_used++; | ||
2813 | get_kid (&ss->master, ss->sequence_used, &rekey->kid); | ||
2814 | receiver->number_rekeying_kce--; | ||
2815 | setup_cipher (&ss->master, ss->sequence_used, &rekey_out_cipher); | ||
2816 | /* Append encrypted payload to dgram */ | ||
2817 | dpos = sizeof(struct UDPRekey); | ||
2818 | |||
2819 | GNUNET_assert ( | ||
2820 | 0 == gcry_cipher_encrypt (rekey_out_cipher, &rekey_dgram[dpos], | ||
2821 | sizeof(receiver->ss_rekey->master), | ||
2822 | &(receiver->ss_rekey->master), | ||
2823 | sizeof(receiver->ss_rekey->master))); | ||
2824 | dpos += sizeof(receiver->ss_rekey->master); | ||
2825 | do_pad (rekey_out_cipher, &rekey_dgram[dpos], sizeof(rekey_dgram) | ||
2826 | - dpos); | ||
2827 | GNUNET_assert (0 == gcry_cipher_gettag (rekey_out_cipher, | ||
2828 | rekey->gcm_tag, | ||
2829 | sizeof(rekey->gcm_tag))); | ||
2830 | gcry_cipher_close (rekey_out_cipher); | ||
2831 | |||
2832 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2833 | "Sending rekey with kid %s and master %s\n", | ||
2834 | GNUNET_sh2s (&rekey->kid), | ||
2835 | GNUNET_h2s (&(receiver->ss_rekey->master))); | ||
2836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2837 | "Sending rekey with cmac %s\n", | ||
2838 | GNUNET_h2s (&(receiver->ss_rekey->cmac))); | ||
2839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2840 | "%u rekey kces left.\n", | ||
2841 | receiver->number_rekeying_kce); | ||
2842 | 2403 | ||
2843 | if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, | 2404 | ss->rekey_initiated = GNUNET_YES; |
2844 | rekey_dgram, | 2405 | /* setup key material */ |
2845 | sizeof(rekey_dgram), | 2406 | ss_rekey = setup_shared_secret_ephemeral (&rekey->ephemeral, |
2846 | receiver->address, | 2407 | receiver); |
2847 | receiver->address_len)) | 2408 | ss_rekey->sequence_allowed = 0; |
2848 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2409 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2410 | "Setup secret with k = %s\n", | ||
2411 | GNUNET_h2s (&(ss_rekey->master))); | ||
2412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2413 | "Setup secret with H(k) = %s\n", | ||
2414 | GNUNET_h2s (&(ss_rekey->cmac))); | ||
2849 | 2415 | ||
2850 | receiver->acks_available--; | 2416 | /* Append encrypted payload to dgram */ |
2851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2417 | rekey->header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY); |
2852 | "%u receiver->acks_available 1\n", | 2418 | rekey->header.size = htons (sizeof (struct UDPRekey)); |
2853 | receiver->acks_available); | ||
2854 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2855 | "Sending UDPRekey to %s\n", GNUNET_a2s (receiver->address, | ||
2856 | receiver-> | ||
2857 | address_len)); | ||
2858 | } | ||
2859 | } | ||
2860 | } | 2419 | } |
2861 | 2420 | ||
2862 | 2421 | ||
@@ -2874,6 +2433,9 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2874 | void *impl_state) | 2433 | void *impl_state) |
2875 | { | 2434 | { |
2876 | struct ReceiverAddress *receiver = impl_state; | 2435 | struct ReceiverAddress *receiver = impl_state; |
2436 | struct UDPRekey rekey; | ||
2437 | struct SharedSecret *ss; | ||
2438 | int inject_rekey = GNUNET_NO; | ||
2877 | uint16_t msize = ntohs (msg->size); | 2439 | uint16_t msize = ntohs (msg->size); |
2878 | 2440 | ||
2879 | GNUNET_assert (mq == receiver->d_mq); | 2441 | GNUNET_assert (mq == receiver->d_mq); |
@@ -2893,19 +2455,52 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2893 | } | 2455 | } |
2894 | reschedule_receiver_timeout (receiver); | 2456 | reschedule_receiver_timeout (receiver); |
2895 | 2457 | ||
2458 | if (receiver->num_secrets > MAX_SECRETS) | ||
2459 | { | ||
2460 | if (0 == purge_secrets (receiver->ss_tail)) | ||
2461 | { | ||
2462 | // No secret purged. Delete oldest. | ||
2463 | secret_destroy (receiver->ss_tail); | ||
2464 | } | ||
2465 | } | ||
2896 | /* begin "BOX" encryption method, scan for ACKs from tail! */ | 2466 | /* begin "BOX" encryption method, scan for ACKs from tail! */ |
2897 | for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev) | 2467 | for (ss = receiver->ss_tail; NULL != ss; ss = ss->prev) |
2898 | { | 2468 | { |
2469 | size_t payload_len = sizeof(struct UDPBox) + receiver->d_mtu; | ||
2470 | if (ss->sequence_used >= ss->sequence_allowed) | ||
2471 | { | ||
2472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2473 | "Skipping ss because no acks to use.\n"); | ||
2474 | continue; | ||
2475 | } | ||
2476 | if (ss->bytes_sent >= rekey_max_bytes) | ||
2477 | { | ||
2478 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2479 | "Skipping ss because rekey bytes reached.\n"); | ||
2480 | // FIXME cleanup ss with too many bytes sent! | ||
2481 | continue; | ||
2482 | } | ||
2483 | if (ss->bytes_sent > rekey_max_bytes * 0.7) | ||
2484 | { | ||
2485 | if (ss->rekey_initiated == GNUNET_NO) | ||
2486 | { | ||
2487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2488 | "Injecting rekey for ss with byte sent %lu\n", | ||
2489 | (unsigned long) ss->bytes_sent); | ||
2490 | create_rekey (receiver, ss, &rekey); | ||
2491 | inject_rekey = GNUNET_YES; | ||
2492 | payload_len += sizeof (rekey); | ||
2493 | ss->rekey_initiated = GNUNET_YES; | ||
2494 | } | ||
2495 | } | ||
2899 | if (0 < ss->sequence_used) | 2496 | if (0 < ss->sequence_used) |
2900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2497 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2901 | "Trying to send UDPBox with shared secrect %s sequence_used %u and ss->sequence_allowed %u\n", | 2498 | "Trying to send UDPBox with shared secrect %s sequence_used %u and ss->sequence_allowed %u\n", |
2902 | GNUNET_h2s (&ss->master), | 2499 | GNUNET_h2s (&ss->master), |
2903 | ss->sequence_used, | 2500 | ss->sequence_used, |
2904 | ss->sequence_allowed); | 2501 | ss->sequence_allowed); |
2905 | if (ss->sequence_used >= ss->sequence_allowed) | ||
2906 | continue; | ||
2907 | 2502 | ||
2908 | char dgram[sizeof(struct UDPBox) + receiver->d_mtu]; | 2503 | char dgram[payload_len]; |
2909 | struct UDPBox *box; | 2504 | struct UDPBox *box; |
2910 | gcry_cipher_hd_t out_cipher; | 2505 | gcry_cipher_hd_t out_cipher; |
2911 | size_t dpos; | 2506 | size_t dpos; |
@@ -2916,6 +2511,13 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2916 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); | 2511 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); |
2917 | /* Append encrypted payload to dgram */ | 2512 | /* Append encrypted payload to dgram */ |
2918 | dpos = sizeof(struct UDPBox); | 2513 | dpos = sizeof(struct UDPBox); |
2514 | if (GNUNET_YES == inject_rekey) | ||
2515 | { | ||
2516 | GNUNET_assert ( | ||
2517 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], sizeof (rekey), | ||
2518 | &rekey, sizeof (rekey))); | ||
2519 | dpos += sizeof (rekey); | ||
2520 | } | ||
2919 | GNUNET_assert ( | 2521 | GNUNET_assert ( |
2920 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); | 2522 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); |
2921 | dpos += msize; | 2523 | dpos += msize; |
@@ -2925,53 +2527,26 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2925 | sizeof(box->gcm_tag))); | 2527 | sizeof(box->gcm_tag))); |
2926 | gcry_cipher_close (out_cipher); | 2528 | gcry_cipher_close (out_cipher); |
2927 | 2529 | ||
2928 | receiver->rekey_send_bytes += sizeof(struct UDPBox) + receiver->d_mtu; | ||
2929 | |||
2930 | if (GNUNET_NO == receiver->rekeying) | ||
2931 | box->rekeying = GNUNET_NO; | ||
2932 | else | ||
2933 | box->rekeying = GNUNET_YES; | ||
2934 | |||
2935 | if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, | 2530 | if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, |
2936 | dgram, | 2531 | dgram, |
2937 | sizeof(dgram), | 2532 | payload_len, // FIXME why always send sizeof dgram? |
2938 | receiver->address, | 2533 | receiver->address, |
2939 | receiver->address_len)) | 2534 | receiver->address_len)) |
2940 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2535 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
2941 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2942 | "Sending UDPBox with payload size %u, %u acks left\n", | 2537 | "Sending UDPBox with payload size %u, %u acks left, %lu bytes sent\n", |
2943 | msize, | 2538 | msize, |
2944 | receiver->acks_available); | 2539 | receiver->acks_available, |
2945 | GNUNET_MQ_impl_send_continue (mq); | 2540 | (unsigned long) ss->bytes_sent); |
2541 | ss->bytes_sent += sizeof (dgram); | ||
2946 | receiver->acks_available--; | 2542 | receiver->acks_available--; |
2947 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2543 | GNUNET_MQ_impl_send_continue (mq); |
2948 | "%u receiver->acks_available 2\n", | ||
2949 | receiver->acks_available); | ||
2950 | check_for_rekeying (receiver, box); | ||
2951 | if (0 == receiver->acks_available - receiver->number_rekeying_kce) | ||
2952 | { | ||
2953 | /* We have no more ACKs */ | ||
2954 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2955 | "No more acks\n"); | ||
2956 | if (GNUNET_YES == receiver->rekeying) | ||
2957 | { | ||
2958 | receiver->rekeying = GNUNET_NO; | ||
2959 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2960 | "Sender stopped rekeying\n"); | ||
2961 | |||
2962 | if ((NULL != receiver->ss_rekey) && (0 < | ||
2963 | receiver->ss_rekey-> | ||
2964 | sequence_allowed) ) | ||
2965 | add_acks_rekey (receiver); | ||
2966 | } | ||
2967 | } | ||
2968 | else if ((GNUNET_YES == receiver->rekeying) ) | ||
2969 | { | ||
2970 | send_UDPRekey (receiver, ss); | ||
2971 | } | ||
2972 | |||
2973 | return; | 2544 | return; |
2974 | } | 2545 | } |
2546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2547 | "No suitable ss found, sending as KX...\n"); | ||
2548 | send_msg_with_kx (msg, receiver); | ||
2549 | GNUNET_MQ_impl_send_continue (mq); | ||
2975 | } | 2550 | } |
2976 | 2551 | ||
2977 | 2552 | ||
@@ -3234,16 +2809,6 @@ get_sender_delete_it (void *cls, | |||
3234 | (void) cls; | 2809 | (void) cls; |
3235 | (void) target; | 2810 | (void) target; |
3236 | 2811 | ||
3237 | if (NULL != sender->kce_task_rekey) | ||
3238 | { | ||
3239 | GNUNET_SCHEDULER_cancel (sender->kce_task_rekey); | ||
3240 | sender->kce_task_rekey = NULL; | ||
3241 | } | ||
3242 | if (NULL != sender->kce_task) | ||
3243 | { | ||
3244 | GNUNET_SCHEDULER_cancel (sender->kce_task); | ||
3245 | sender->kce_task = NULL; | ||
3246 | } | ||
3247 | 2812 | ||
3248 | sender_destroy (sender); | 2813 | sender_destroy (sender); |
3249 | return GNUNET_OK; | 2814 | return GNUNET_OK; |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index c4711e6fe..f2ee685bc 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -187,20 +187,20 @@ | |||
187 | * the value chosen here might be too aggressively low! | 187 | * the value chosen here might be too aggressively low! |
188 | */ | 188 | */ |
189 | #define DELAY_WARN_THRESHOLD \ | 189 | #define DELAY_WARN_THRESHOLD \ |
190 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 190 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * If a DVBox could not be forwarded after this number of | 193 | * If a DVBox could not be forwarded after this number of |
194 | * seconds we drop it. | 194 | * seconds we drop it. |
195 | */ | 195 | */ |
196 | #define DV_FORWARD_TIMEOUT \ | 196 | #define DV_FORWARD_TIMEOUT \ |
197 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 197 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
198 | 198 | ||
199 | /** | 199 | /** |
200 | * Default value for how long we wait for reliability ack. | 200 | * Default value for how long we wait for reliability ack. |
201 | */ | 201 | */ |
202 | #define DEFAULT_ACK_WAIT_DURATION \ | 202 | #define DEFAULT_ACK_WAIT_DURATION \ |
203 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 203 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * We only consider queues as "quality" connections when | 206 | * We only consider queues as "quality" connections when |
@@ -208,53 +208,53 @@ | |||
208 | * the latency of the queue is below this threshold. | 208 | * the latency of the queue is below this threshold. |
209 | */ | 209 | */ |
210 | #define DV_QUALITY_RTT_THRESHOLD \ | 210 | #define DV_QUALITY_RTT_THRESHOLD \ |
211 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 211 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * How long do we consider a DV path valid if we see no | 214 | * How long do we consider a DV path valid if we see no |
215 | * further updates on it? Note: the value chosen here might be too low! | 215 | * further updates on it? Note: the value chosen here might be too low! |
216 | */ | 216 | */ |
217 | #define DV_PATH_VALIDITY_TIMEOUT \ | 217 | #define DV_PATH_VALIDITY_TIMEOUT \ |
218 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 218 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * How long do we cache backchannel (struct Backtalker) information | 221 | * How long do we cache backchannel (struct Backtalker) information |
222 | * after a backchannel goes inactive? | 222 | * after a backchannel goes inactive? |
223 | */ | 223 | */ |
224 | #define BACKCHANNEL_INACTIVITY_TIMEOUT \ | 224 | #define BACKCHANNEL_INACTIVITY_TIMEOUT \ |
225 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 225 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * How long before paths expire would we like to (re)discover DV paths? Should | 228 | * How long before paths expire would we like to (re)discover DV paths? Should |
229 | * be below #DV_PATH_VALIDITY_TIMEOUT. | 229 | * be below #DV_PATH_VALIDITY_TIMEOUT. |
230 | */ | 230 | */ |
231 | #define DV_PATH_DISCOVERY_FREQUENCY \ | 231 | #define DV_PATH_DISCOVERY_FREQUENCY \ |
232 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) | 232 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) |
233 | 233 | ||
234 | /** | 234 | /** |
235 | * How long are ephemeral keys valid? | 235 | * How long are ephemeral keys valid? |
236 | */ | 236 | */ |
237 | #define EPHEMERAL_VALIDITY \ | 237 | #define EPHEMERAL_VALIDITY \ |
238 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) | 238 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
239 | 239 | ||
240 | /** | 240 | /** |
241 | * How long do we keep partially reassembled messages around before giving up? | 241 | * How long do we keep partially reassembled messages around before giving up? |
242 | */ | 242 | */ |
243 | #define REASSEMBLY_EXPIRATION \ | 243 | #define REASSEMBLY_EXPIRATION \ |
244 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) | 244 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) |
245 | 245 | ||
246 | /** | 246 | /** |
247 | * What is the fastest rate at which we send challenges *if* we keep learning | 247 | * What is the fastest rate at which we send challenges *if* we keep learning |
248 | * an address (gossip, DHT, etc.)? | 248 | * an address (gossip, DHT, etc.)? |
249 | */ | 249 | */ |
250 | #define FAST_VALIDATION_CHALLENGE_FREQ \ | 250 | #define FAST_VALIDATION_CHALLENGE_FREQ \ |
251 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) | 251 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * What is the slowest rate at which we send challenges? | 254 | * What is the slowest rate at which we send challenges? |
255 | */ | 255 | */ |
256 | #define MAX_VALIDATION_CHALLENGE_FREQ \ | 256 | #define MAX_VALIDATION_CHALLENGE_FREQ \ |
257 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1) | 257 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1) |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * How long until we forget about historic accumulators and thus | 260 | * How long until we forget about historic accumulators and thus |
@@ -262,7 +262,7 @@ | |||
262 | * active connection experiences without an ACK. | 262 | * active connection experiences without an ACK. |
263 | */ | 263 | */ |
264 | #define ACK_CUMMULATOR_TIMEOUT \ | 264 | #define ACK_CUMMULATOR_TIMEOUT \ |
265 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) | 265 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
266 | 266 | ||
267 | /** | 267 | /** |
268 | * What is the non-randomized base frequency at which we | 268 | * What is the non-randomized base frequency at which we |
@@ -280,13 +280,13 @@ | |||
280 | * When do we forget an invalid address for sure? | 280 | * When do we forget an invalid address for sure? |
281 | */ | 281 | */ |
282 | #define MAX_ADDRESS_VALID_UNTIL \ | 282 | #define MAX_ADDRESS_VALID_UNTIL \ |
283 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1) | 283 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1) |
284 | 284 | ||
285 | /** | 285 | /** |
286 | * How long do we consider an address valid if we just checked? | 286 | * How long do we consider an address valid if we just checked? |
287 | */ | 287 | */ |
288 | #define ADDRESS_VALIDATION_LIFETIME \ | 288 | #define ADDRESS_VALIDATION_LIFETIME \ |
289 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) | 289 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * What is the maximum frequency at which we do address validation? | 292 | * What is the maximum frequency at which we do address validation? |
@@ -1774,10 +1774,6 @@ struct DistanceVector | |||
1774 | */ | 1774 | */ |
1775 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key; | 1775 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key; |
1776 | 1776 | ||
1777 | /** | ||
1778 | * Our private ephemeral key. | ||
1779 | */ | ||
1780 | struct GNUNET_CRYPTO_EcdhePrivateKey private_key; | ||
1781 | }; | 1777 | }; |
1782 | 1778 | ||
1783 | 1779 | ||
@@ -4411,24 +4407,18 @@ check_communicator_backchannel ( | |||
4411 | 4407 | ||
4412 | 4408 | ||
4413 | /** | 4409 | /** |
4414 | * Ensure ephemeral keys in our @a dv are current. If no current one exists, | 4410 | * Sign ephemeral keys in our @a dv are current. |
4415 | * set it up. | ||
4416 | * | 4411 | * |
4417 | * @param[in,out] dv virtual link to update ephemeral for | 4412 | * @param[in,out] dv virtual link to update ephemeral for |
4418 | */ | 4413 | */ |
4419 | static void | 4414 | static void |
4420 | update_ephemeral (struct DistanceVector *dv) | 4415 | sign_ephemeral (struct DistanceVector *dv) |
4421 | { | 4416 | { |
4422 | struct EphemeralConfirmationPS ec; | 4417 | struct EphemeralConfirmationPS ec; |
4423 | 4418 | ||
4424 | if (0 != | ||
4425 | GNUNET_TIME_absolute_get_remaining (dv->ephemeral_validity).rel_value_us) | ||
4426 | return; | ||
4427 | dv->monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg); | 4419 | dv->monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg); |
4428 | dv->ephemeral_validity = | 4420 | dv->ephemeral_validity = |
4429 | GNUNET_TIME_absolute_add (dv->monotime, EPHEMERAL_VALIDITY); | 4421 | GNUNET_TIME_absolute_add (dv->monotime, EPHEMERAL_VALIDITY); |
4430 | GNUNET_CRYPTO_ecdhe_key_create (&dv->private_key); | ||
4431 | GNUNET_CRYPTO_ecdhe_key_get_public (&dv->private_key, &dv->ephemeral_key); | ||
4432 | ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); | 4422 | ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); |
4433 | ec.target = dv->target; | 4423 | ec.target = dv->target; |
4434 | ec.ephemeral_key = dv->ephemeral_key; | 4424 | ec.ephemeral_key = dv->ephemeral_key; |
@@ -4681,7 +4671,7 @@ dv_setup_key_state_from_km (const struct GNUNET_HashCode *km, | |||
4681 | const struct GNUNET_ShortHashCode *iv, | 4671 | const struct GNUNET_ShortHashCode *iv, |
4682 | struct DVKeyState *key) | 4672 | struct DVKeyState *key) |
4683 | { | 4673 | { |
4684 | /* must match #dh_key_derive_eph_pub */ | 4674 | /* must match what we defive from decapsulated key */ |
4685 | GNUNET_assert (GNUNET_YES == | 4675 | GNUNET_assert (GNUNET_YES == |
4686 | GNUNET_CRYPTO_kdf (&key->material, | 4676 | GNUNET_CRYPTO_kdf (&key->material, |
4687 | sizeof(key->material), | 4677 | sizeof(key->material), |
@@ -4710,62 +4700,6 @@ dv_setup_key_state_from_km (const struct GNUNET_HashCode *km, | |||
4710 | 4700 | ||
4711 | 4701 | ||
4712 | /** | 4702 | /** |
4713 | * Derive backchannel encryption key material from @a priv_ephemeral | ||
4714 | * and @a target and @a iv. | ||
4715 | * | ||
4716 | * @param priv_ephemeral ephemeral private key to use | ||
4717 | * @param target the target peer to encrypt to | ||
4718 | * @param iv unique IV to use | ||
4719 | * @param[out] key set to the key material | ||
4720 | * @return GNUNET_OK on success | ||
4721 | */ | ||
4722 | static enum GNUNET_GenericReturnValue | ||
4723 | dh_key_derive_eph_pid ( | ||
4724 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, | ||
4725 | const struct GNUNET_PeerIdentity *target, | ||
4726 | const struct GNUNET_ShortHashCode *iv, | ||
4727 | struct DVKeyState *key) | ||
4728 | { | ||
4729 | struct GNUNET_HashCode km; | ||
4730 | |||
4731 | if (GNUNET_YES != GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral, | ||
4732 | &target->public_key, | ||
4733 | &km)) | ||
4734 | return GNUNET_SYSERR; | ||
4735 | // FIXME: Possibly also add return values here. We are processing | ||
4736 | // Input from other peers... | ||
4737 | dv_setup_key_state_from_km (&km, iv, key); | ||
4738 | return GNUNET_OK; | ||
4739 | } | ||
4740 | |||
4741 | |||
4742 | /** | ||
4743 | * Derive backchannel encryption key material from #GST_my_private_key | ||
4744 | * and @a pub_ephemeral and @a iv. | ||
4745 | * | ||
4746 | * @param priv_ephemeral ephemeral private key to use | ||
4747 | * @param target the target peer to encrypt to | ||
4748 | * @param iv unique IV to use | ||
4749 | * @param[out] key set to the key material | ||
4750 | * @return GNUNET_OK on success | ||
4751 | */ | ||
4752 | static enum GNUNET_GenericReturnValue | ||
4753 | dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, | ||
4754 | const struct GNUNET_ShortHashCode *iv, | ||
4755 | struct DVKeyState *key) | ||
4756 | { | ||
4757 | struct GNUNET_HashCode km; | ||
4758 | |||
4759 | if (GNUNET_YES != GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key, | ||
4760 | pub_ephemeral, | ||
4761 | &km)) | ||
4762 | return GNUNET_SYSERR; | ||
4763 | dv_setup_key_state_from_km (&km, iv, key); | ||
4764 | return GNUNET_OK; | ||
4765 | } | ||
4766 | |||
4767 | |||
4768 | /** | ||
4769 | * Do HMAC calculation for backchannel messages over @a data using key | 4703 | * Do HMAC calculation for backchannel messages over @a data using key |
4770 | * material from @a key. | 4704 | * material from @a key. |
4771 | * | 4705 | * |
@@ -4882,13 +4816,22 @@ encapsulate_for_dv (struct DistanceVector *dv, | |||
4882 | char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN; | 4816 | char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN; |
4883 | struct DVKeyState *key; | 4817 | struct DVKeyState *key; |
4884 | struct GNUNET_TIME_Relative rtt; | 4818 | struct GNUNET_TIME_Relative rtt; |
4819 | struct GNUNET_HashCode k; | ||
4885 | 4820 | ||
4886 | key = GNUNET_new (struct DVKeyState); | 4821 | key = GNUNET_new (struct DVKeyState); |
4887 | /* Encrypt payload */ | 4822 | /* Encrypt payload */ |
4888 | box_hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX); | 4823 | box_hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX); |
4889 | box_hdr.total_hops = htons (0); | 4824 | box_hdr.total_hops = htons (0); |
4890 | box_hdr.without_fc = htons (without_fc); | 4825 | box_hdr.without_fc = htons (without_fc); |
4891 | update_ephemeral (dv); | 4826 | // update_ephemeral (dv); |
4827 | if (0 == | ||
4828 | GNUNET_TIME_absolute_get_remaining (dv->ephemeral_validity).rel_value_us) | ||
4829 | { | ||
4830 | GNUNET_CRYPTO_eddsa_kem_encaps (&dv->target.public_key, | ||
4831 | &dv->ephemeral_key, | ||
4832 | &k); | ||
4833 | sign_ephemeral (dv); | ||
4834 | } | ||
4892 | box_hdr.ephemeral_key = dv->ephemeral_key; | 4835 | box_hdr.ephemeral_key = dv->ephemeral_key; |
4893 | payload_hdr.sender_sig = dv->sender_sig; | 4836 | payload_hdr.sender_sig = dv->sender_sig; |
4894 | 4837 | ||
@@ -4896,10 +4839,9 @@ encapsulate_for_dv (struct DistanceVector *dv, | |||
4896 | &box_hdr.iv, | 4839 | &box_hdr.iv, |
4897 | sizeof(box_hdr.iv)); | 4840 | sizeof(box_hdr.iv)); |
4898 | // We are creating this key, so this must work. | 4841 | // We are creating this key, so this must work. |
4899 | GNUNET_assert (GNUNET_OK == | 4842 | // FIXME: Possibly also add return values here. We are processing |
4900 | dh_key_derive_eph_pid (&dv->private_key, | 4843 | // Input from other peers... |
4901 | &dv->target, | 4844 | dv_setup_key_state_from_km (&k, &box_hdr.iv, key); |
4902 | &box_hdr.iv, key)); | ||
4903 | payload_hdr.sender = GST_my_identity; | 4845 | payload_hdr.sender = GST_my_identity; |
4904 | payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime); | 4846 | payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime); |
4905 | dv_encrypt (key, &payload_hdr, enc, sizeof(payload_hdr)); | 4847 | dv_encrypt (key, &payload_hdr, enc, sizeof(payload_hdr)); |
@@ -8322,13 +8264,17 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) | |||
8322 | cmc->total_hops = ntohs (dvb->total_hops); | 8264 | cmc->total_hops = ntohs (dvb->total_hops); |
8323 | 8265 | ||
8324 | // DH key derivation with received DV, could be garbage. | 8266 | // DH key derivation with received DV, could be garbage. |
8325 | if (GNUNET_OK != | 8267 | struct GNUNET_HashCode km; |
8326 | dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, &key)) | 8268 | |
8269 | if (GNUNET_YES != GNUNET_CRYPTO_eddsa_kem_decaps (GST_my_private_key, | ||
8270 | &dvb->ephemeral_key, | ||
8271 | &km)) | ||
8327 | { | 8272 | { |
8328 | GNUNET_break_op (0); | 8273 | GNUNET_break_op (0); |
8329 | finish_cmc_handling (cmc); | 8274 | finish_cmc_handling (cmc); |
8330 | return; | 8275 | return; |
8331 | } | 8276 | } |
8277 | dv_setup_key_state_from_km (&km, &dvb->iv, &key); | ||
8332 | hdr = (const char *) &dvb[1]; | 8278 | hdr = (const char *) &dvb[1]; |
8333 | hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct | 8279 | hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct |
8334 | GNUNET_PeerIdentity) | 8280 | GNUNET_PeerIdentity) |
diff --git a/src/transport/meson.build b/src/transport/meson.build new file mode 100644 index 000000000..d997aad8a --- /dev/null +++ b/src/transport/meson.build | |||
@@ -0,0 +1,320 @@ | |||
1 | libgnunettransport_src = ['transport_api_address_to_string.c', | ||
2 | 'transport_api_blacklist.c', | ||
3 | 'transport_api_core.c', | ||
4 | 'transport_api_hello_get.c', | ||
5 | 'transport_api_manipulation.c', | ||
6 | 'transport_api_monitor_peers.c', | ||
7 | 'transport_api_monitor_plugins.c', | ||
8 | 'transport_api_offer_hello.c'] | ||
9 | libgnunettransportapplication_src = ['transport_api2_application.c'] | ||
10 | libgnunettransportcore_src = ['transport_api2_core.c'] | ||
11 | libgnunettransportcommunicator_src = ['transport_api2_communication.c'] | ||
12 | libgnunettransportmonitor_src = ['transport_api2_monitor.c'] | ||
13 | |||
14 | gnunetservicetransport_src = ['gnunet-service-tng.c'] | ||
15 | gnunetcommunicatortcp_src = ['gnunet-communicator-tcp.c'] | ||
16 | gnunetcommunicatorudp_src = ['gnunet-communicator-udp.c'] | ||
17 | gnunetcommunicatorunix_src = ['gnunet-communicator-unix.c'] | ||
18 | |||
19 | configure_file(input : 'transport.conf.in', | ||
20 | output : 'transport.conf', | ||
21 | configuration : cdata, | ||
22 | install: true, | ||
23 | install_dir: pkgcfgdir) | ||
24 | |||
25 | configure_file(input : 'gnunet-transport-certificate-creation.in', | ||
26 | output : 'gnunet-transport-certificate-creation', | ||
27 | configuration : cdata, | ||
28 | install: true, | ||
29 | install_dir: get_option('bindir')) | ||
30 | |||
31 | configure_file(input : 'communicator-unix.conf', | ||
32 | output : 'communicator-unix.conf', | ||
33 | configuration : cdata, | ||
34 | install: true, | ||
35 | install_dir: pkgcfgdir) | ||
36 | |||
37 | if get_option('monolith') | ||
38 | foreach p : libgnunettransport_src #+ libgnunettransportapplication_src + libgnunettransportcore_src + libgnunettransportcommunicator_src + libgnunettransportmonitor_src + gnunetservicetransport_src | ||
39 | gnunet_src += 'transport/' + p | ||
40 | endforeach | ||
41 | endif | ||
42 | |||
43 | libgnunettransport = library('gnunettransport', | ||
44 | libgnunettransport_src, | ||
45 | soversion: '2', | ||
46 | version: '2.2.0', | ||
47 | dependencies: [libgnunetutil_dep, libgnunetats_dep, libgnunethello_dep], | ||
48 | include_directories: [incdir, configuration_inc], | ||
49 | install: true, | ||
50 | install_dir: get_option('libdir')) | ||
51 | pkg.generate(libgnunettransport, url: 'https://www.gnunet.org', | ||
52 | description : 'Provides API for accessing the transport service') | ||
53 | libgnunettransport_dep = declare_dependency(link_with : libgnunettransport) | ||
54 | |||
55 | libgnunettransporttesting = library('gnunettransporttesting', | ||
56 | [ | ||
57 | 'transport-testing.c', | ||
58 | 'transport-testing-filenames.c', | ||
59 | 'transport-testing-loggers.c', | ||
60 | 'transport-testing-main.c', | ||
61 | 'transport-testing-send.c' | ||
62 | ], | ||
63 | soversion: '0', | ||
64 | version: '0.0.0', | ||
65 | dependencies: [libgnunetutil_dep, | ||
66 | libgnunettesting_dep, | ||
67 | libgnunettransport_dep, | ||
68 | libgnunetats_dep, | ||
69 | libgnunethello_dep], | ||
70 | include_directories: [incdir, configuration_inc], | ||
71 | install: true, | ||
72 | install_dir: get_option('libdir')) | ||
73 | |||
74 | |||
75 | libgnunettransportapplication = library('gnunettransportapplication', | ||
76 | libgnunettransportapplication_src, | ||
77 | soversion: '0', | ||
78 | version: '0.0.0', | ||
79 | dependencies: libgnunetutil_dep, | ||
80 | include_directories: [incdir, configuration_inc], | ||
81 | install: true, | ||
82 | install_dir: get_option('libdir')) | ||
83 | pkg.generate(libgnunettransportapplication, url: 'https://www.gnunet.org', | ||
84 | description : 'Provides application APIs for accessing the transport service') | ||
85 | libgnunettransportapplication_dep = declare_dependency(link_with : libgnunettransportapplication) | ||
86 | |||
87 | libgnunettransportcore = library('gnunettransportcore', | ||
88 | libgnunettransportcore_src, | ||
89 | soversion: '0', | ||
90 | version: '0.0.0', | ||
91 | dependencies: libgnunetutil_dep, | ||
92 | include_directories: [incdir, configuration_inc], | ||
93 | install: true, | ||
94 | install_dir: get_option('libdir')) | ||
95 | pkg.generate(libgnunettransportcore, url: 'https://www.gnunet.org', | ||
96 | description : 'Provides core API for accessing the transport service') | ||
97 | libgnunettransportcore_dep = declare_dependency(link_with : libgnunettransportcore) | ||
98 | |||
99 | libgnunettransportcommunicator = library('gnunettransportcommunicator', | ||
100 | libgnunettransportcommunicator_src, | ||
101 | soversion: '0', | ||
102 | version: '0.0.0', | ||
103 | dependencies: libgnunetutil_dep, | ||
104 | include_directories: [incdir, configuration_inc], | ||
105 | install: true, | ||
106 | install_dir: get_option('libdir')) | ||
107 | pkg.generate(libgnunettransportcommunicator, url: 'https://www.gnunet.org', | ||
108 | description : 'Provides communicator API for accessing the transport service') | ||
109 | libgnunettransportcommunicator_dep = declare_dependency(link_with : libgnunettransportcommunicator) | ||
110 | |||
111 | libgnunettransportmonitor = library('gnunettransportmonitor', | ||
112 | libgnunettransportmonitor_src, | ||
113 | soversion: '0', | ||
114 | version: '0.0.0', | ||
115 | dependencies: libgnunetutil_dep, | ||
116 | include_directories: [incdir, configuration_inc], | ||
117 | install: true, | ||
118 | install_dir: get_option('libdir')) | ||
119 | pkg.generate(libgnunettransportmonitor, url: 'https://www.gnunet.org', | ||
120 | description : 'Provides monitor API for accessing the transport service') | ||
121 | libgnunettransportmonitor_dep = declare_dependency(link_with : libgnunettransportmonitor) | ||
122 | |||
123 | libgnunettransporttesting2 = library('gnunettransporttesting2', | ||
124 | [ | ||
125 | 'transport_api_traits.c', | ||
126 | 'transport_api_cmd_connecting_peers.c', | ||
127 | 'transport_api_cmd_backchannel_check.c', | ||
128 | 'transport_api_cmd_start_peer.c', | ||
129 | 'transport_api_cmd_stop_peer.c', | ||
130 | 'transport_api_cmd_send_simple.c', | ||
131 | 'transport_api_cmd_send_simple_performance.c', | ||
132 | 'transport-testing2.c', | ||
133 | 'transport-testing-filenames2.c', | ||
134 | 'transport-testing-loggers2.c', | ||
135 | 'transport-testing-main2.c', | ||
136 | 'transport-testing-send2.c', | ||
137 | 'transport-testing-communicator.c', | ||
138 | ], | ||
139 | soversion: '0', | ||
140 | version: '0.0.0', | ||
141 | dependencies: [libgnunetutil_dep, | ||
142 | libgnunettransportapplication_dep, | ||
143 | libgnunettransport_dep, | ||
144 | libgnunetpeerstore_dep, | ||
145 | libgnunetats_dep, | ||
146 | libgnunettesting_dep, | ||
147 | libgnunethello_dep], | ||
148 | include_directories: [incdir, configuration_inc], | ||
149 | install: true, | ||
150 | install_dir: get_option('libdir')) | ||
151 | libgnunettransporttesting2_dep = declare_dependency(link_with : libgnunettransporttesting2) | ||
152 | |||
153 | executable ('gnunet-service-transport', | ||
154 | gnunetservicetransport_src, | ||
155 | dependencies: [libgnunettransport_dep, libgnunetutil_dep, | ||
156 | libgnunethello_dep, | ||
157 | libgnunetpeerstore_dep, | ||
158 | m_dep, | ||
159 | libgnunetstatistics_dep, | ||
160 | gcrypt_dep], | ||
161 | include_directories: [incdir, configuration_inc], | ||
162 | install: true, | ||
163 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
164 | |||
165 | executable ('gnunet-communicator-unix', | ||
166 | gnunetcommunicatorunix_src, | ||
167 | dependencies: [libgnunettransportcommunicator_dep, | ||
168 | libgnunetpeerstore_dep, | ||
169 | libgnunetstatistics_dep, | ||
170 | libgnunetnt_dep, | ||
171 | libgnunetnat_dep, | ||
172 | gcrypt_dep, | ||
173 | libgnunetutil_dep], | ||
174 | include_directories: [incdir, configuration_inc], | ||
175 | install: true, | ||
176 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
177 | executable ('gnunet-communicator-udp', | ||
178 | gnunetcommunicatorudp_src, | ||
179 | dependencies: [libgnunettransportcommunicator_dep, | ||
180 | libgnunettransportapplication_dep, | ||
181 | libgnunetpeerstore_dep, | ||
182 | libgnunetstatistics_dep, | ||
183 | libgnunetnt_dep, | ||
184 | libgnunetnat_dep, | ||
185 | gcrypt_dep, | ||
186 | libgnunetutil_dep], | ||
187 | include_directories: [incdir, configuration_inc], | ||
188 | install: true, | ||
189 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
190 | executable ('gnunet-communicator-tcp', | ||
191 | gnunetcommunicatortcp_src, | ||
192 | dependencies: [libgnunettransportcommunicator_dep, | ||
193 | libgnunetpeerstore_dep, | ||
194 | libgnunetstatistics_dep, | ||
195 | libgnunetnt_dep, | ||
196 | libgnunetnat_dep, | ||
197 | gcrypt_dep, | ||
198 | libgnunetutil_dep], | ||
199 | include_directories: [incdir, configuration_inc], | ||
200 | install: true, | ||
201 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
202 | |||
203 | executable ('gnunet-transport', | ||
204 | ['gnunet-transport.c'], | ||
205 | dependencies: [libgnunettransportcommunicator_dep, | ||
206 | libgnunethello_dep, | ||
207 | libgnunettransport_dep, | ||
208 | libgnunetpeerstore_dep, | ||
209 | libgnunetutil_dep], | ||
210 | include_directories: [incdir, configuration_inc], | ||
211 | install: true, | ||
212 | install_dir: get_option('bindir')) | ||
213 | |||
214 | libgnunettesttransport_cmd_simplesend = library('gnunet_test_transport_plugin_cmd_simple_send', | ||
215 | ['test_transport_plugin_cmd_simple_send.c'], | ||
216 | dependencies: [ | ||
217 | libgnunetutil_dep, | ||
218 | libgnunettransporttesting2_dep, | ||
219 | libgnunettransportapplication_dep, | ||
220 | libgnunettransportcore_dep, | ||
221 | libgnunettesting_dep, | ||
222 | libgnunetpeerstore_dep, | ||
223 | libgnunetstatistics_dep, | ||
224 | libgnunethello_dep, | ||
225 | libgnunetarm_dep, | ||
226 | libgnunetutil_dep | ||
227 | ], | ||
228 | include_directories: [incdir, configuration_inc], | ||
229 | install: true, | ||
230 | install_dir: get_option('libdir')/'gnunet') | ||
231 | |||
232 | libgnunettesttransport_cmd_simplesendbc = library('gnunet_test_transport_plugin_cmd_simple_send_broadcast', | ||
233 | ['test_transport_plugin_cmd_simple_send_broadcast.c'], | ||
234 | dependencies: [ | ||
235 | libgnunetutil_dep, | ||
236 | libgnunettransporttesting2_dep, | ||
237 | libgnunettransportapplication_dep, | ||
238 | libgnunettransportcore_dep, | ||
239 | libgnunettesting_dep, | ||
240 | libgnunetpeerstore_dep, | ||
241 | libgnunetstatistics_dep, | ||
242 | libgnunethello_dep, | ||
243 | libgnunetarm_dep, | ||
244 | libgnunetutil_dep | ||
245 | ], | ||
246 | include_directories: [incdir, configuration_inc], | ||
247 | install: true, | ||
248 | install_dir: get_option('libdir')/'gnunet') | ||
249 | |||
250 | libgnunettesttransport_cmd_simplesenddv = library('gnunet_test_transport_plugin_cmd_simple_send_dv', | ||
251 | ['test_transport_plugin_cmd_simple_send_dv.c'], | ||
252 | dependencies: [ | ||
253 | libgnunetutil_dep, | ||
254 | libgnunettransporttesting2_dep, | ||
255 | libgnunettransportapplication_dep, | ||
256 | libgnunettransportcore_dep, | ||
257 | libgnunettesting_dep, | ||
258 | libgnunetpeerstore_dep, | ||
259 | libgnunetstatistics_dep, | ||
260 | libgnunethello_dep, | ||
261 | libgnunetarm_dep, | ||
262 | libgnunetutil_dep | ||
263 | ], | ||
264 | include_directories: [incdir, configuration_inc], | ||
265 | install: true, | ||
266 | install_dir: get_option('libdir')/'gnunet') | ||
267 | |||
268 | libgnunettesttransport_cmd_simplesendperf = library('gnunet_test_transport_plugin_cmd_simple_send_performance', | ||
269 | ['test_transport_plugin_cmd_simple_send_performance.c'], | ||
270 | dependencies: [ | ||
271 | libgnunetutil_dep, | ||
272 | libgnunettransporttesting2_dep, | ||
273 | libgnunettransportapplication_dep, | ||
274 | libgnunettransportcore_dep, | ||
275 | libgnunettesting_dep, | ||
276 | libgnunetpeerstore_dep, | ||
277 | libgnunetstatistics_dep, | ||
278 | libgnunethello_dep, | ||
279 | libgnunetarm_dep, | ||
280 | libgnunetutil_dep | ||
281 | ], | ||
282 | include_directories: [incdir, configuration_inc], | ||
283 | install: true, | ||
284 | install_dir: get_option('libdir')/'gnunet') | ||
285 | |||
286 | libgnunettesttransport_cmd_udpback = library('gnunet_test_transport_plugin_cmd_udp_backchannel', | ||
287 | ['test_transport_plugin_cmd_udp_backchannel.c'], | ||
288 | dependencies: [ | ||
289 | libgnunetutil_dep, | ||
290 | libgnunettransporttesting2_dep, | ||
291 | libgnunettransportapplication_dep, | ||
292 | libgnunettransportcore_dep, | ||
293 | libgnunettesting_dep, | ||
294 | libgnunetpeerstore_dep, | ||
295 | libgnunetstatistics_dep, | ||
296 | libgnunethello_dep, | ||
297 | libgnunetarm_dep, | ||
298 | libgnunetutil_dep | ||
299 | ], | ||
300 | include_directories: [incdir, configuration_inc], | ||
301 | install: true, | ||
302 | install_dir: get_option('libdir')/'gnunet') | ||
303 | |||
304 | libgnunettesttransport_cmd_natupnp = library('gnunet_test_transport_plugin_cmd_nat_upnp', | ||
305 | ['test_transport_plugin_cmd_nat_upnp.c'], | ||
306 | dependencies: [ | ||
307 | libgnunetutil_dep, | ||
308 | libgnunettransporttesting2_dep, | ||
309 | libgnunettransportapplication_dep, | ||
310 | libgnunettransportcore_dep, | ||
311 | libgnunettesting_dep, | ||
312 | libgnunetpeerstore_dep, | ||
313 | libgnunetstatistics_dep, | ||
314 | libgnunethello_dep, | ||
315 | libgnunetarm_dep, | ||
316 | libgnunetutil_dep | ||
317 | ], | ||
318 | include_directories: [incdir, configuration_inc], | ||
319 | install: true, | ||
320 | install_dir: get_option('libdir')/'gnunet') | ||
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index 40353daeb..a033985e1 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c | |||
@@ -604,7 +604,7 @@ http_common_plugin_address_to_string (const char *plugin, | |||
604 | if (addr_str[ntohl (address->urlen) - 1] != '\0') | 604 | if (addr_str[ntohl (address->urlen) - 1] != '\0') |
605 | return NULL; | 605 | return NULL; |
606 | GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options), | 606 | GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options), |
607 | (char*)&address[1]); | 607 | (char*) &address[1]); |
608 | if (strlen (res) + 1 < 500) | 608 | if (strlen (res) + 1 < 500) |
609 | { | 609 | { |
610 | GNUNET_memcpy (rbuf, res, strlen (res) + 1); | 610 | GNUNET_memcpy (rbuf, res, strlen (res) + 1); |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 138fb5080..3ac106859 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1873,7 +1873,8 @@ handle_helper_message (void *cls, | |||
1873 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1873 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1874 | "Size of packet is too small (%llu bytes < %llu)\n", | 1874 | "Size of packet is too small (%llu bytes < %llu)\n", |
1875 | (unsigned long long) msize, | 1875 | (unsigned long long) msize, |
1876 | (unsigned long long) sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)); | 1876 | (unsigned long long) sizeof(struct |
1877 | GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)); | ||
1877 | break; | 1878 | break; |
1878 | } | 1879 | } |
1879 | rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr; | 1880 | rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr; |
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 14d1a4792..fdbad0957 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -104,13 +104,13 @@ static unsigned int iterations_left[NUM_PEERS]; | |||
104 | #define TIMEOUT_MULTIPLIER 1 | 104 | #define TIMEOUT_MULTIPLIER 1 |
105 | 105 | ||
106 | #define DELAY \ | 106 | #define DELAY \ |
107 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,200) | 107 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,200) |
108 | 108 | ||
109 | #define SHORT_BURST_WINDOW \ | 109 | #define SHORT_BURST_WINDOW \ |
110 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) | 110 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) |
111 | 111 | ||
112 | #define LONG_BURST_WINDOW \ | 112 | #define LONG_BURST_WINDOW \ |
113 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) | 113 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) |
114 | 114 | ||
115 | enum TestPhase | 115 | enum TestPhase |
116 | { | 116 | { |
@@ -394,7 +394,8 @@ process_statistics (void *cls, | |||
394 | { | 394 | { |
395 | ret = 2; | 395 | ret = 2; |
396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
397 | "Not enough BOX messages!\n"); | 397 | "Not enough BOX messages! (want: %u, have %llu)\n", |
398 | 9000, value); | ||
398 | GNUNET_SCHEDULER_shutdown (); | 399 | GNUNET_SCHEDULER_shutdown (); |
399 | } | 400 | } |
400 | if ((0 == strcmp ("rekey", test_name)) && | 401 | if ((0 == strcmp ("rekey", test_name)) && |
@@ -405,7 +406,8 @@ process_statistics (void *cls, | |||
405 | { | 406 | { |
406 | ret = 2; | 407 | ret = 2; |
407 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
408 | "Not enough BOX messages!\n"); | 409 | "Not enough BOX messages! (want: %u, have %llu)\n", |
410 | 6000, value); | ||
409 | GNUNET_SCHEDULER_shutdown (); | 411 | GNUNET_SCHEDULER_shutdown (); |
410 | } | 412 | } |
411 | return GNUNET_OK; | 413 | return GNUNET_OK; |
@@ -432,11 +434,13 @@ short_test_cb (void *cls) | |||
432 | tc_h); | 434 | tc_h); |
433 | payload = make_payload (SHORT_MESSAGE_SIZE); | 435 | payload = make_payload (SHORT_MESSAGE_SIZE); |
434 | num_sent_short[peer_nr]++; | 436 | num_sent_short[peer_nr]++; |
437 | if (burst_packets_short == num_sent_short[peer_nr]) | ||
438 | tc_h->cont = NULL; | ||
439 | else | ||
440 | tc_h->cont = short_test; | ||
441 | tc_h->cont_cls = cls; | ||
435 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, | 442 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
436 | (burst_packets_short == | 443 | NULL, |
437 | num_sent_short[peer_nr]) | ||
438 | ? NULL | ||
439 | : &short_test, | ||
440 | cls, | 444 | cls, |
441 | payload, | 445 | payload, |
442 | SHORT_MESSAGE_SIZE); | 446 | SHORT_MESSAGE_SIZE); |
@@ -477,11 +481,13 @@ size_test (void *cls) | |||
477 | ack[peer_nr] += 10; | 481 | ack[peer_nr] += 10; |
478 | payload = make_payload (ack[peer_nr]); | 482 | payload = make_payload (ack[peer_nr]); |
479 | num_sent_size[peer_nr]++; | 483 | num_sent_size[peer_nr]++; |
484 | if (ack[peer_nr] >= max_size) | ||
485 | tc_h->cont = NULL; | ||
486 | else | ||
487 | tc_h->cont = size_test; | ||
488 | tc_h->cont_cls = cls; | ||
480 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, | 489 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
481 | (ack[peer_nr] < | 490 | NULL, |
482 | max_size) | ||
483 | ? &size_test | ||
484 | : NULL, | ||
485 | cls, | 491 | cls, |
486 | payload, | 492 | payload, |
487 | ack[peer_nr]); | 493 | ack[peer_nr]); |
@@ -511,11 +517,13 @@ long_test_cb (void *cls) | |||
511 | (unsigned int) num_received_long[peer_nr]); | 517 | (unsigned int) num_received_long[peer_nr]); |
512 | payload = make_payload (long_message_size); | 518 | payload = make_payload (long_message_size); |
513 | num_sent_long[peer_nr]++; | 519 | num_sent_long[peer_nr]++; |
520 | if (burst_packets_long == num_sent_long[peer_nr]) | ||
521 | tc_h->cont = NULL; | ||
522 | else | ||
523 | tc_h->cont = long_test; | ||
524 | tc_h->cont_cls = cls; | ||
514 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, | 525 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
515 | (burst_packets_long == | 526 | NULL, |
516 | num_sent_long[peer_nr]) | ||
517 | ? NULL | ||
518 | : &long_test, | ||
519 | cls, | 527 | cls, |
520 | payload, | 528 | payload, |
521 | long_message_size); | 529 | long_message_size); |
@@ -784,7 +792,7 @@ add_queue_cb (void *cls, | |||
784 | return; | 792 | return; |
785 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 793 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
786 | "Queue established, starting test...\n"); | 794 | "Queue established, starting test...\n"); |
787 | if (UINT32_MAX != mtu) /* Message header overhead */ | 795 | if (UINT16_MAX != mtu) /* Message header overhead */ |
788 | long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) | 796 | long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) |
789 | - sizeof(struct GNUNET_MessageHeader); | 797 | - sizeof(struct GNUNET_MessageHeader); |
790 | else | 798 | else |
@@ -935,7 +943,8 @@ incoming_message_cb ( | |||
935 | if (long_message_size != payload_len) | 943 | if (long_message_size != payload_len) |
936 | { | 944 | { |
937 | LOG (GNUNET_ERROR_TYPE_WARNING, | 945 | LOG (GNUNET_ERROR_TYPE_WARNING, |
938 | "Ignoring packet with wrong length\n"); | 946 | "Ignoring packet with wrong length (have: %lu, want: %lu)\n", |
947 | payload_len, long_message_size); | ||
939 | return; // Ignore | 948 | return; // Ignore |
940 | } | 949 | } |
941 | num_received_long[peer_nr]++; | 950 | num_received_long[peer_nr]++; |
@@ -1086,7 +1095,7 @@ main (int argc, | |||
1086 | phase[0] = TP_INIT; | 1095 | phase[0] = TP_INIT; |
1087 | phase[1] = TP_INIT; | 1096 | phase[1] = TP_INIT; |
1088 | ret = 1; | 1097 | ret = 1; |
1089 | test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 1098 | test_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); |
1090 | communicator_name = strchr (test_name, '-'); | 1099 | communicator_name = strchr (test_name, '-'); |
1091 | communicator_name[0] = '\0'; | 1100 | communicator_name[0] = '\0'; |
1092 | communicator_name++; | 1101 | communicator_name++; |
diff --git a/src/transport/test_communicator_quic_basic_peer1.conf b/src/transport/test_communicator_quic_basic_peer1.conf new file mode 100644 index 000000000..d43752ecc --- /dev/null +++ b/src/transport/test_communicator_quic_basic_peer1.conf | |||
@@ -0,0 +1,45 @@ | |||
1 | @INLINE@ test_transport_defaults.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-1/private.key | ||
8 | |||
9 | [transport-tcp] | ||
10 | PORT = 52400 | ||
11 | |||
12 | [transport-udp] | ||
13 | PORT = 52401 | ||
14 | |||
15 | [transport-quic] | ||
16 | PORT = 52402 | ||
17 | |||
18 | [transport] | ||
19 | #PORT = 60000 | ||
20 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock | ||
21 | |||
22 | [nat] | ||
23 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock | ||
24 | ENABLE_IPSCAN = YES | ||
25 | |||
26 | [peerstore] | ||
27 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock | ||
28 | |||
29 | [statistics] | ||
30 | PORT = 22461 | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-statistics_test_1.sock | ||
32 | |||
33 | [resolver] | ||
34 | PORT = 62089 | ||
35 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock | ||
36 | |||
37 | [communicator-udp] | ||
38 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_com1 | ||
39 | BINDTO = 60002 | ||
40 | DISABLE_V6 = YES | ||
41 | MAX_QUEUE_LENGTH=5000 | ||
42 | |||
43 | [communicator-quic] | ||
44 | BINDTO = 60002 | ||
45 | DISABLE_V6 = YES | ||
diff --git a/src/transport/test_communicator_quic_basic_peer2.conf b/src/transport/test_communicator_quic_basic_peer2.conf new file mode 100644 index 000000000..4fabc8a86 --- /dev/null +++ b/src/transport/test_communicator_quic_basic_peer2.conf | |||
@@ -0,0 +1,45 @@ | |||
1 | @INLINE@ test_transport_defaults.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunetd-plugin-transport/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-2/private.key | ||
8 | |||
9 | [transport-tcp] | ||
10 | PORT = 52400 | ||
11 | |||
12 | [transport-udp] | ||
13 | PORT = 52402 | ||
14 | |||
15 | [transport-quic] | ||
16 | PORT = 52403 | ||
17 | |||
18 | [transport] | ||
19 | #PORT = 60001 | ||
20 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock | ||
21 | |||
22 | [nat] | ||
23 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock | ||
24 | |||
25 | |||
26 | [peerstore] | ||
27 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock | ||
28 | |||
29 | [statistics] | ||
30 | PORT = 22462 | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-statistics_test_2.sock | ||
32 | |||
33 | [resolver] | ||
34 | PORT = 62090 | ||
35 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | ||
36 | |||
37 | [communicator-udp] | ||
38 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_com2 | ||
39 | BINDTO = 60003 | ||
40 | DISABLE_V6 = YES | ||
41 | MAX_QUEUE_LENGTH=5000 | ||
42 | |||
43 | [communicator-quic] | ||
44 | BINDTO = 60003 | ||
45 | DISABLE_V6 = YES \ No newline at end of file | ||
diff --git a/src/transport/test_communicator_udp_backchannel_peer1.conf b/src/transport/test_communicator_udp_backchannel_peer1.conf index 59e6d68e3..65f33bd6b 100644 --- a/src/transport/test_communicator_udp_backchannel_peer1.conf +++ b/src/transport/test_communicator_udp_backchannel_peer1.conf | |||
@@ -39,7 +39,7 @@ BINDTO = 60002 | |||
39 | DISABLE_V6 = YES | 39 | DISABLE_V6 = YES |
40 | 40 | ||
41 | [communicator-udp] | 41 | [communicator-udp] |
42 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 42 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_comm1 |
43 | BINDTO = 60002 | 43 | BINDTO = 60002 |
44 | DISABLE_V6 = YES | 44 | DISABLE_V6 = YES |
45 | MAX_QUEUE_LENGTH=5000 | 45 | MAX_QUEUE_LENGTH=5000 |
diff --git a/src/transport/test_communicator_udp_backchannel_peer2.conf b/src/transport/test_communicator_udp_backchannel_peer2.conf index 3abf7999b..9875af724 100644 --- a/src/transport/test_communicator_udp_backchannel_peer2.conf +++ b/src/transport/test_communicator_udp_backchannel_peer2.conf | |||
@@ -39,7 +39,7 @@ BINDTO = 60003 | |||
39 | DISABLE_V6 = YES | 39 | DISABLE_V6 = YES |
40 | 40 | ||
41 | [communicator-udp] | 41 | [communicator-udp] |
42 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 42 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_comm2 |
43 | BINDTO = 60003 | 43 | BINDTO = 60003 |
44 | DISABLE_V6 = YES | 44 | DISABLE_V6 = YES |
45 | MAX_QUEUE_LENGTH=5000 | 45 | MAX_QUEUE_LENGTH=5000 |
diff --git a/src/transport/test_communicator_udp_basic_peer1.conf b/src/transport/test_communicator_udp_basic_peer1.conf index c6ff024ee..6968b3aef 100644 --- a/src/transport/test_communicator_udp_basic_peer1.conf +++ b/src/transport/test_communicator_udp_basic_peer1.conf | |||
@@ -32,7 +32,8 @@ PORT = 62089 | |||
32 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock | 32 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock |
33 | 33 | ||
34 | [communicator-udp] | 34 | [communicator-udp] |
35 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 35 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_com1 |
36 | BINDTO = 60002 | 36 | BINDTO = 60002 |
37 | DISABLE_V6 = YES | 37 | DISABLE_V6 = YES |
38 | MAX_QUEUE_LENGTH=5000 | 38 | MAX_QUEUE_LENGTH=5000 |
39 | |||
diff --git a/src/transport/test_communicator_udp_basic_peer2.conf b/src/transport/test_communicator_udp_basic_peer2.conf index b353b03e9..781bfa7da 100644 --- a/src/transport/test_communicator_udp_basic_peer2.conf +++ b/src/transport/test_communicator_udp_basic_peer2.conf | |||
@@ -33,7 +33,7 @@ PORT = 62090 | |||
33 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | 33 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock |
34 | 34 | ||
35 | [communicator-udp] | 35 | [communicator-udp] |
36 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 36 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_com2 |
37 | BINDTO = 60003 | 37 | BINDTO = 60003 |
38 | DISABLE_V6 = YES | 38 | DISABLE_V6 = YES |
39 | MAX_QUEUE_LENGTH=5000 | 39 | MAX_QUEUE_LENGTH=5000 |
diff --git a/src/transport/test_communicator_udp_rekey_peer1.conf b/src/transport/test_communicator_udp_rekey_peer1.conf index 6bfeafe33..9b0fa7497 100644 --- a/src/transport/test_communicator_udp_rekey_peer1.conf +++ b/src/transport/test_communicator_udp_rekey_peer1.conf | |||
@@ -45,7 +45,8 @@ REKEY_INTERVAL = 100ms | |||
45 | BINDTO = 60002 | 45 | BINDTO = 60002 |
46 | DISABLE_V6 = YES | 46 | DISABLE_V6 = YES |
47 | MAX_QUEUE_LENGTH=5000 | 47 | MAX_QUEUE_LENGTH=5000 |
48 | REKEY_MAX_BYTES=9MiB | 48 | REKEY_INTERVAL = 100ms |
49 | REKEY_MAX_BYTES=9KiB | ||
49 | 50 | ||
50 | [communicator-test] | 51 | [communicator-test] |
51 | BACKCHANNEL_ENABLED = YES | 52 | BACKCHANNEL_ENABLED = YES |
diff --git a/src/transport/test_communicator_udp_rekey_peer2.conf b/src/transport/test_communicator_udp_rekey_peer2.conf index 474ca0c15..383ab19d2 100644 --- a/src/transport/test_communicator_udp_rekey_peer2.conf +++ b/src/transport/test_communicator_udp_rekey_peer2.conf | |||
@@ -45,7 +45,8 @@ REKEY_INTERVAL = 100ms | |||
45 | BINDTO = 60003 | 45 | BINDTO = 60003 |
46 | DISABLE_V6 = YES | 46 | DISABLE_V6 = YES |
47 | MAX_QUEUE_LENGTH=5000 | 47 | MAX_QUEUE_LENGTH=5000 |
48 | REKEY_MAX_BYTES=9MiB | 48 | REKEY_INTERVAL = 100ms |
49 | REKEY_MAX_BYTES=9KiB | ||
49 | 50 | ||
50 | [communicator-test] | 51 | [communicator-test] |
51 | BACKCHANNEL_ENABLED = YES | 52 | BACKCHANNEL_ENABLED = YES |
diff --git a/src/transport/test_transport_api2.c b/src/transport/test_transport_api2.c index e1606e0be..4d423f7c2 100644 --- a/src/transport/test_transport_api2.c +++ b/src/transport/test_transport_api2.c | |||
@@ -28,7 +28,7 @@ | |||
28 | * C code apparently. | 28 | * C code apparently. |
29 | */ | 29 | */ |
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | //#include "gnunet_transport_service.h" | 31 | // #include "gnunet_transport_service.h" |
32 | #include "transport-testing2.h" | 32 | #include "transport-testing2.h" |
33 | 33 | ||
34 | /** | 34 | /** |
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c b/src/transport/test_transport_plugin_cmd_nat_upnp.c index 5c5e71e85..31206e63f 100644 --- a/src/transport/test_transport_plugin_cmd_nat_upnp.c +++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c | |||
@@ -90,7 +90,7 @@ handle_test (void *cls, | |||
90 | struct GNUNET_TESTING_BarrierList* | 90 | struct GNUNET_TESTING_BarrierList* |
91 | get_waiting_for_barriers () | 91 | get_waiting_for_barriers () |
92 | { | 92 | { |
93 | struct GNUNET_TESTING_BarrierList* barriers; | 93 | struct GNUNET_TESTING_BarrierList*barriers; |
94 | struct GNUNET_TESTING_BarrierListEntry *ble; | 94 | struct GNUNET_TESTING_BarrierListEntry *ble; |
95 | 95 | ||
96 | barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList); | 96 | barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList); |
@@ -209,7 +209,7 @@ all_local_tests_prepared () | |||
209 | * the topology configuration. | 209 | * the topology configuration. |
210 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, | 210 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, |
211 | * if read_file is GNUNET_NO the string contains the topology configuration. | 211 | * if read_file is GNUNET_NO the string contains the topology configuration. |
212 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail | 212 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail |
213 | * node to the master process * signaling that the test case running on the netjail node finished. | 213 | * node to the master process * signaling that the test case running on the netjail node finished. |
214 | * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. | 214 | * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. |
215 | */ | 215 | */ |
@@ -358,9 +358,9 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
358 | ts->write_message = write_message; | 358 | ts->write_message = write_message; |
359 | 359 | ||
360 | is = GNUNET_TESTING_run (commands, | 360 | is = GNUNET_TESTING_run (commands, |
361 | TIMEOUT, | 361 | TIMEOUT, |
362 | &handle_result, | 362 | &handle_result, |
363 | ts); | 363 | ts); |
364 | return is; | 364 | return is; |
365 | } | 365 | } |
366 | 366 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 0c9bfa890..d83c539fa 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -90,7 +90,7 @@ handle_test (void *cls, | |||
90 | struct GNUNET_TESTING_BarrierList * | 90 | struct GNUNET_TESTING_BarrierList * |
91 | get_waiting_for_barriers () | 91 | get_waiting_for_barriers () |
92 | { | 92 | { |
93 | //No Barrier | 93 | // No Barrier |
94 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); | 94 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); |
95 | } | 95 | } |
96 | 96 | ||
@@ -327,9 +327,9 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
327 | ts->write_message = write_message; | 327 | ts->write_message = write_message; |
328 | 328 | ||
329 | is = GNUNET_TESTING_run (commands, | 329 | is = GNUNET_TESTING_run (commands, |
330 | TIMEOUT, | 330 | TIMEOUT, |
331 | &handle_result, | 331 | &handle_result, |
332 | ts); | 332 | ts); |
333 | return is; | 333 | return is; |
334 | } | 334 | } |
335 | 335 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 7381b1d7e..7000851c4 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -90,7 +90,7 @@ handle_test (void *cls, | |||
90 | struct GNUNET_TESTING_BarrierList * | 90 | struct GNUNET_TESTING_BarrierList * |
91 | get_waiting_for_barriers () | 91 | get_waiting_for_barriers () |
92 | { | 92 | { |
93 | //No Barrier | 93 | // No Barrier |
94 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); | 94 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); |
95 | } | 95 | } |
96 | 96 | ||
@@ -147,12 +147,11 @@ static void * | |||
147 | notify_connect (struct GNUNET_TESTING_Interpreter *is, | 147 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
148 | const struct GNUNET_PeerIdentity *peer) | 148 | const struct GNUNET_PeerIdentity *peer) |
149 | { | 149 | { |
150 | const struct GNUNET_TESTING_AsyncContext *ac; | 150 | struct GNUNET_TESTING_AsyncContext *ac; |
151 | void *ret = NULL; | 151 | void *ret = NULL; |
152 | const struct GNUNET_TESTING_Command *cmd; | 152 | const struct GNUNET_TESTING_Command *cmd; |
153 | struct GNUNET_TESTING_BlockState *bs; | 153 | struct GNUNET_TESTING_BlockState *bs; |
154 | 154 | ||
155 | |||
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
157 | "notify_connect\n"); | 156 | "notify_connect\n"); |
158 | 157 | ||
@@ -165,9 +164,9 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
165 | "notify_connect running\n"); | 164 | "notify_connect running\n"); |
166 | GNUNET_assert (NULL != ac); | 165 | GNUNET_assert (NULL != ac); |
167 | if (NULL == ac->cont) | 166 | if (NULL == ac->cont) |
168 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); | 167 | GNUNET_TESTING_async_fail (ac); |
169 | else | 168 | else |
170 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); | 169 | GNUNET_TESTING_async_finish (ac); |
171 | } | 170 | } |
172 | else | 171 | else |
173 | { | 172 | { |
@@ -179,7 +178,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
179 | cmd->label); | 178 | cmd->label); |
180 | GNUNET_TESTING_get_trait_block_state ( | 179 | GNUNET_TESTING_get_trait_block_state ( |
181 | cmd, | 180 | cmd, |
182 | (const struct GNUNET_TESTING_BlockState **) &bs); | 181 | &bs); |
183 | 182 | ||
184 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 183 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
185 | "block state %u\n", | 184 | "block state %u\n", |
@@ -353,9 +352,9 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
353 | ts->write_message = write_message; | 352 | ts->write_message = write_message; |
354 | 353 | ||
355 | is = GNUNET_TESTING_run (commands, | 354 | is = GNUNET_TESTING_run (commands, |
356 | TIMEOUT, | 355 | TIMEOUT, |
357 | &handle_result, | 356 | &handle_result, |
358 | ts); | 357 | ts); |
359 | return is; | 358 | return is; |
360 | } | 359 | } |
361 | 360 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index ac3e8b24b..c07fd3cf4 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -113,7 +113,7 @@ handle_test (void *cls, | |||
113 | GNUNET_TESTING_get_trait_async_context (&block_receive, | 113 | GNUNET_TESTING_get_trait_async_context (&block_receive, |
114 | &ac_block); | 114 | &ac_block); |
115 | 115 | ||
116 | if ( connected == number_received) | 116 | if (connected == number_received) |
117 | { | 117 | { |
118 | if (NULL != ac_block->is) | 118 | if (NULL != ac_block->is) |
119 | { | 119 | { |
@@ -142,7 +142,7 @@ handle_test (void *cls, | |||
142 | struct GNUNET_TESTING_BarrierList * | 142 | struct GNUNET_TESTING_BarrierList * |
143 | get_waiting_for_barriers () | 143 | get_waiting_for_barriers () |
144 | { | 144 | { |
145 | //No Barrier | 145 | // No Barrier |
146 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); | 146 | return GNUNET_new (struct GNUNET_TESTING_BarrierList); |
147 | } | 147 | } |
148 | 148 | ||
@@ -201,19 +201,21 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
201 | { | 201 | { |
202 | const struct ConnectPeersState *cps; | 202 | const struct ConnectPeersState *cps; |
203 | const struct GNUNET_TESTING_Command *cmd; | 203 | const struct GNUNET_TESTING_Command *cmd; |
204 | void *ret = NULL; | ||
205 | 204 | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
207 | "notify_connect peer %s\n", | 206 | "notify_connect peer %s\n", |
208 | GNUNET_i2s (peer)); | 207 | GNUNET_i2s (peer)); |
208 | // FIXME: modifying future is a bit unclean, not easy to follow logic; | ||
209 | // might be better to when reaching the future command to look into | ||
210 | // the past... | ||
209 | cmd = GNUNET_TESTING_interpreter_lookup_command_all (is, | 211 | cmd = GNUNET_TESTING_interpreter_lookup_command_all (is, |
210 | "connect-peers"); | 212 | "connect-peers"); |
213 | // FIXME: check return value! | ||
211 | GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd, | 214 | GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd, |
212 | &cps); | 215 | &cps); |
213 | cps->notify_connect (is, | 216 | cps->notify_connect (is, |
214 | peer); | 217 | peer); |
215 | 218 | return NULL; | |
216 | return ret; | ||
217 | } | 219 | } |
218 | 220 | ||
219 | 221 | ||
@@ -382,9 +384,9 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
382 | ts->write_message = write_message; | 384 | ts->write_message = write_message; |
383 | 385 | ||
384 | is = GNUNET_TESTING_run (commands, | 386 | is = GNUNET_TESTING_run (commands, |
385 | TIMEOUT, | 387 | TIMEOUT, |
386 | &handle_result, | 388 | &handle_result, |
387 | ts); | 389 | ts); |
388 | return is; | 390 | return is; |
389 | } | 391 | } |
390 | 392 | ||
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 5f411e20e..303790afc 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -155,6 +155,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
155 | return ret; | 155 | return ret; |
156 | } | 156 | } |
157 | 157 | ||
158 | |||
158 | /** | 159 | /** |
159 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. | 160 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. |
160 | */ | 161 | */ |
@@ -173,6 +174,7 @@ all_local_tests_prepared () | |||
173 | GNUNET_TESTING_AsyncContext *) &lfs->ac); | 174 | GNUNET_TESTING_AsyncContext *) &lfs->ac); |
174 | } | 175 | } |
175 | 176 | ||
177 | |||
176 | /** | 178 | /** |
177 | * Function to start a local test case. | 179 | * Function to start a local test case. |
178 | * | 180 | * |
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c index a2c692dbc..349cd65a5 100644 --- a/src/transport/test_transport_start_with_config.c +++ b/src/transport/test_transport_start_with_config.c | |||
@@ -94,13 +94,13 @@ main (int argc, | |||
94 | topology_data_script, | 94 | topology_data_script, |
95 | &read_file), | 95 | &read_file), |
96 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ("netjail-start-testbed", | 96 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ("netjail-start-testbed", |
97 | topology, | 97 | topology, |
98 | &read_file, | 98 | &read_file, |
99 | topology_data_script, | 99 | topology_data_script, |
100 | TIMEOUT), | 100 | TIMEOUT), |
101 | GNUNET_TESTING_cmd_stop_cmds_helper ("stop-testbed", | 101 | GNUNET_TESTING_cmd_stop_cmds_helper ("stop-testbed", |
102 | "netjail-start-testbed", | 102 | "netjail-start-testbed", |
103 | topology), | 103 | topology), |
104 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | 104 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", |
105 | topology_data_script, | 105 | topology_data_script, |
106 | &read_file), | 106 | &read_file), |
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c index 1bf88bb3d..26895e457 100644 --- a/src/transport/transport-testing-communicator.c +++ b/src/transport/transport-testing-communicator.c | |||
@@ -676,8 +676,13 @@ handle_send_message_ack (void *cls, | |||
676 | const struct GNUNET_TRANSPORT_SendMessageToAck *sma) | 676 | const struct GNUNET_TRANSPORT_SendMessageToAck *sma) |
677 | { | 677 | { |
678 | struct MyClient *client = cls; | 678 | struct MyClient *client = cls; |
679 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = | ||
680 | client->tc; | ||
681 | static int mtr = 0; | ||
682 | mtr++; | ||
683 | if (tc_h->cont != NULL) | ||
684 | tc_h->cont (tc_h->cont_cls); | ||
679 | GNUNET_SERVICE_client_continue (client->client); | 685 | GNUNET_SERVICE_client_continue (client->client); |
680 | // NOP | ||
681 | } | 686 | } |
682 | 687 | ||
683 | 688 | ||
@@ -772,6 +777,7 @@ shutdown_process (struct GNUNET_OS_Process *proc) | |||
772 | GNUNET_OS_process_destroy (proc); | 777 | GNUNET_OS_process_destroy (proc); |
773 | } | 778 | } |
774 | 779 | ||
780 | |||
775 | /** | 781 | /** |
776 | * @brief Task run at shutdown to kill the statistics process | 782 | * @brief Task run at shutdown to kill the statistics process |
777 | * | 783 | * |
@@ -784,6 +790,7 @@ shutdown_statistics (void *cls) | |||
784 | shutdown_process (proc); | 790 | shutdown_process (proc); |
785 | } | 791 | } |
786 | 792 | ||
793 | |||
787 | /** | 794 | /** |
788 | * @brief Task run at shutdown to kill the peerstore process | 795 | * @brief Task run at shutdown to kill the peerstore process |
789 | * | 796 | * |
@@ -796,6 +803,7 @@ shutdown_peerstore (void *cls) | |||
796 | shutdown_process (proc); | 803 | shutdown_process (proc); |
797 | } | 804 | } |
798 | 805 | ||
806 | |||
799 | /** | 807 | /** |
800 | * @brief Task run at shutdown to kill a communicator process | 808 | * @brief Task run at shutdown to kill a communicator process |
801 | * | 809 | * |
@@ -913,6 +921,7 @@ resolver_start (struct | |||
913 | 921 | ||
914 | } | 922 | } |
915 | 923 | ||
924 | |||
916 | /** | 925 | /** |
917 | * @brief Start Statistics | 926 | * @brief Start Statistics |
918 | * | 927 | * |
@@ -942,6 +951,7 @@ statistics_start ( | |||
942 | GNUNET_free (binary); | 951 | GNUNET_free (binary); |
943 | } | 952 | } |
944 | 953 | ||
954 | |||
945 | /** | 955 | /** |
946 | * @brief Start Peerstore | 956 | * @brief Start Peerstore |
947 | * | 957 | * |
@@ -971,6 +981,7 @@ peerstore_start ( | |||
971 | GNUNET_free (binary); | 981 | GNUNET_free (binary); |
972 | } | 982 | } |
973 | 983 | ||
984 | |||
974 | /** | 985 | /** |
975 | * @brief Start NAT | 986 | * @brief Start NAT |
976 | * | 987 | * |
@@ -1160,8 +1171,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send | |||
1160 | size_t inbox_size; | 1171 | size_t inbox_size; |
1161 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; | 1172 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; |
1162 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_tmp; | 1173 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_tmp; |
1163 | 1174 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *last_queue; | |
1164 | tc_queue = NULL; | 1175 | tc_queue = NULL; |
1176 | |||
1165 | for (tc_queue_tmp = tc_h->queue_head; | 1177 | for (tc_queue_tmp = tc_h->queue_head; |
1166 | NULL != tc_queue_tmp; | 1178 | NULL != tc_queue_tmp; |
1167 | tc_queue_tmp = tc_queue_tmp->next) | 1179 | tc_queue_tmp = tc_queue_tmp->next) |
@@ -1188,19 +1200,28 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send | |||
1188 | tc_queue = tc_queue_tmp; | 1200 | tc_queue = tc_queue_tmp; |
1189 | } | 1201 | } |
1190 | } | 1202 | } |
1203 | if (last_queue != tc_queue) | ||
1204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1205 | "Selected sending queue changed to %u with length %lu and MTU %u\n", | ||
1206 | ntohl (tc_queue->qid), tc_queue->q_len, tc_queue->mtu); | ||
1191 | GNUNET_assert (NULL != tc_queue); | 1207 | GNUNET_assert (NULL != tc_queue); |
1208 | last_queue = tc_queue; | ||
1192 | // Uncomment this for alternativ 1 of backchannel functionality | 1209 | // Uncomment this for alternativ 1 of backchannel functionality |
1193 | if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED) | 1210 | if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED) |
1194 | tc_queue->q_len--; | 1211 | tc_queue->q_len--; |
1195 | // Until here for alternativ 1 | 1212 | // Until here for alternativ 1 |
1196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1213 | static int msg_count = 0; |
1197 | "Sending message\n"); | 1214 | msg_count++; |
1215 | if (msg_count % 100 == 0) | ||
1216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1217 | "Sending %u-th (%lu-th for queue) message on queue %u\n", | ||
1218 | msg_count, tc_queue->mid, ntohl (tc_queue->qid)); | ||
1198 | inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size; | 1219 | inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size; |
1199 | env = GNUNET_MQ_msg_extra (msg, | 1220 | env = GNUNET_MQ_msg_extra (msg, |
1200 | inbox_size, | 1221 | inbox_size, |
1201 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); | 1222 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); |
1202 | GNUNET_assert (NULL != env); | 1223 | GNUNET_assert (NULL != env); |
1203 | msg->qid = htonl (tc_queue->qid); | 1224 | msg->qid = tc_queue->qid; |
1204 | msg->mid = tc_queue->mid++; | 1225 | msg->mid = tc_queue->mid++; |
1205 | msg->receiver = tc_queue->peer_id; | 1226 | msg->receiver = tc_queue->peer_id; |
1206 | mh = (struct GNUNET_MessageHeader *) &msg[1]; | 1227 | mh = (struct GNUNET_MessageHeader *) &msg[1]; |
diff --git a/src/transport/transport-testing-communicator.h b/src/transport/transport-testing-communicator.h index 1875258b4..122ac3efa 100644 --- a/src/transport/transport-testing-communicator.h +++ b/src/transport/transport-testing-communicator.h | |||
@@ -282,6 +282,16 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | |||
282 | void *cb_cls; | 282 | void *cb_cls; |
283 | 283 | ||
284 | /** | 284 | /** |
285 | * Callback to call when message ack received. | ||
286 | */ | ||
287 | GNUNET_SCHEDULER_TaskCallback cont; | ||
288 | |||
289 | /** | ||
290 | * Closure for cont | ||
291 | */ | ||
292 | void *cont_cls; | ||
293 | |||
294 | /** | ||
285 | * Backchannel supported | 295 | * Backchannel supported |
286 | */ | 296 | */ |
287 | int bc_enabled; | 297 | int bc_enabled; |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 566e0db71..ec27ac8ba 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -329,6 +329,7 @@ notify_disconnect (void *cls, | |||
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | |||
332 | static void | 333 | static void |
333 | retrieve_hello (void *cls); | 334 | retrieve_hello (void *cls); |
334 | 335 | ||
diff --git a/src/transport/transport.conf.in b/src/transport/transport.conf.in index c6b207ad7..96b87e266 100644 --- a/src/transport/transport.conf.in +++ b/src/transport/transport.conf.in | |||
@@ -235,3 +235,7 @@ INTERFACE = hci0 | |||
235 | # Real hardware, no testing | 235 | # Real hardware, no testing |
236 | TESTMODE = 0 | 236 | TESTMODE = 0 |
237 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | 237 | TESTING_IGNORE_KEYS = ACCEPT_FROM; |
238 | |||
239 | |||
240 | [communicator-quic] | ||
241 | BINDTO = 127.0.0.1 \ No newline at end of file | ||
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index d672e3ae8..1bdb8817f 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -330,6 +330,7 @@ will_the_other_node_connect_via_udp ( | |||
330 | return GNUNET_NO; | 330 | return GNUNET_NO; |
331 | } | 331 | } |
332 | 332 | ||
333 | |||
333 | static void | 334 | static void |
334 | add_search_string (struct CheckState *cs, const struct | 335 | add_search_string (struct CheckState *cs, const struct |
335 | GNUNET_TESTING_NetjailNode *node) | 336 | GNUNET_TESTING_NetjailNode *node) |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 8ff206a23..33991bc29 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -139,10 +139,10 @@ connect_peers_run (void *cls, | |||
139 | char *rest2; | 139 | char *rest2; |
140 | char *address; | 140 | char *address; |
141 | 141 | ||
142 | prefix = strtok(addr, "_"); | 142 | prefix = strtok (addr, "_"); |
143 | rest = strtok(NULL, "_"); | 143 | rest = strtok (NULL, "_"); |
144 | rest2 = strtok(rest, "-"); | 144 | rest2 = strtok (rest, "-"); |
145 | address = strtok(NULL, "-"); | 145 | address = strtok (NULL, "-"); |
146 | 146 | ||
147 | GNUNET_asprintf (&addr_and_port, | 147 | GNUNET_asprintf (&addr_and_port, |
148 | "%s-%s:0", | 148 | "%s-%s:0", |
@@ -186,20 +186,23 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
186 | const struct GNUNET_TESTING_Command *cmd; | 186 | const struct GNUNET_TESTING_Command *cmd; |
187 | struct ConnectPeersState *cps; | 187 | struct ConnectPeersState *cps; |
188 | struct GNUNET_PeerIdentity *peer_connection; | 188 | struct GNUNET_PeerIdentity *peer_connection; |
189 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
190 | unsigned int num; | 189 | unsigned int num; |
191 | unsigned int con_num; | 190 | unsigned int con_num; |
192 | void *ret = NULL; | 191 | void *ret = NULL; |
193 | 192 | ||
194 | cmd = GNUNET_TESTING_interpreter_lookup_command_all (is, | 193 | cmd = GNUNET_TESTING_interpreter_lookup_command_all (is, |
195 | "connect-peers"); | 194 | "connect-peers"); |
196 | cps = cmd->cls; | 195 | cps = cmd->cls; // WTF? Never go directly into cls of another command! FIXME! |
197 | con_num = cps->con_num_notified; | 196 | con_num = cps->con_num_notified; |
198 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | 197 | for (struct GNUNET_TESTING_NodeConnection *pos_connection = |
198 | cps->node_connections_head; | ||
199 | NULL != pos_connection; | ||
199 | pos_connection = pos_connection->next) | 200 | pos_connection = pos_connection->next) |
200 | { | 201 | { |
201 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); | 202 | num = GNUNET_TESTING_calculate_num (pos_connection, |
202 | peer_connection = GNUNET_TESTING_get_peer (num, cps->tl_system); | 203 | cps->topology); |
204 | peer_connection = GNUNET_TESTING_get_peer (num, | ||
205 | cps->tl_system); | ||
203 | if (0 == GNUNET_memcmp (peer, | 206 | if (0 == GNUNET_memcmp (peer, |
204 | peer_connection)) | 207 | peer_connection)) |
205 | cps->con_num_notified++; | 208 | cps->con_num_notified++; |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index c4098e26d..54e204a21 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -385,7 +385,7 @@ start_peer_cleanup (void *cls) | |||
385 | GNUNET_free (sps->handlers); | 385 | GNUNET_free (sps->handlers); |
386 | sps->handlers = NULL; | 386 | sps->handlers = NULL; |
387 | } | 387 | } |
388 | //TODO Investigate why this caused problems during shutdown. | 388 | // TODO Investigate why this caused problems during shutdown. |
389 | /*if (NULL != sps->cfg) | 389 | /*if (NULL != sps->cfg) |
390 | { | 390 | { |
391 | GNUNET_CONFIGURATION_destroy (sps->cfg); | 391 | GNUNET_CONFIGURATION_destroy (sps->cfg); |
diff --git a/src/util/.gitignore b/src/util/.gitignore index 937a6841a..6151c4f7a 100644 --- a/src/util/.gitignore +++ b/src/util/.gitignore | |||
@@ -1,4 +1,3 @@ | |||
1 | gnunet_error_codes.c | ||
2 | test_common_logging_dummy | 1 | test_common_logging_dummy |
3 | gnunet-config | 2 | gnunet-config |
4 | gnunet-config-diff | 3 | gnunet-config-diff |
diff --git a/src/util/bio.c b/src/util/bio.c index 7e3aa0d16..3a463bcd1 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -23,6 +23,7 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "gnunet_common.h" | ||
26 | #include "platform.h" | 27 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
28 | 29 | ||
@@ -158,7 +159,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size) | |||
158 | * value is #GNUNET_SYSERR | 159 | * value is #GNUNET_SYSERR |
159 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 160 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
160 | */ | 161 | */ |
161 | int | 162 | enum GNUNET_GenericReturnValue |
162 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) | 163 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) |
163 | { | 164 | { |
164 | int err; | 165 | int err; |
@@ -287,7 +288,7 @@ read_from_buffer (struct GNUNET_BIO_ReadHandle *h, | |||
287 | * @param len the number of bytes to read | 288 | * @param len the number of bytes to read |
288 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 289 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
289 | */ | 290 | */ |
290 | int | 291 | enum GNUNET_GenericReturnValue |
291 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | 292 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, |
292 | const char *what, | 293 | const char *what, |
293 | void *result, | 294 | void *result, |
@@ -326,7 +327,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
326 | * @param max_length maximum allowed length for the string | 327 | * @param max_length maximum allowed length for the string |
327 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 328 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
328 | */ | 329 | */ |
329 | int | 330 | enum GNUNET_GenericReturnValue |
330 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | 331 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, |
331 | const char *what, | 332 | const char *what, |
332 | char **result, | 333 | char **result, |
@@ -388,7 +389,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | |||
388 | * @param what describes what is being read (for error message creation) | 389 | * @param what describes what is being read (for error message creation) |
389 | * @param f address of float to read | 390 | * @param f address of float to read |
390 | */ | 391 | */ |
391 | int | 392 | enum GNUNET_GenericReturnValue |
392 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | 393 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, |
393 | const char *what, | 394 | const char *what, |
394 | float *f) | 395 | float *f) |
@@ -405,7 +406,7 @@ GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | |||
405 | * @param what describes what is being read (for error message creation) | 406 | * @param what describes what is being read (for error message creation) |
406 | * @param f address of double to read | 407 | * @param f address of double to read |
407 | */ | 408 | */ |
408 | int | 409 | enum GNUNET_GenericReturnValue |
409 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | 410 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, |
410 | const char *what, | 411 | const char *what, |
411 | double *f) | 412 | double *f) |
@@ -423,7 +424,7 @@ GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | |||
423 | * @param i where to store the data | 424 | * @param i where to store the data |
424 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 425 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
425 | */ | 426 | */ |
426 | int | 427 | enum GNUNET_GenericReturnValue |
427 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | 428 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, |
428 | const char *what, | 429 | const char *what, |
429 | int32_t *i) | 430 | int32_t *i) |
@@ -445,7 +446,7 @@ GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | |||
445 | * @param i where to store the data | 446 | * @param i where to store the data |
446 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 447 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
447 | */ | 448 | */ |
448 | int | 449 | enum GNUNET_GenericReturnValue |
449 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, | 450 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, |
450 | const char *what, | 451 | const char *what, |
451 | int64_t *i) | 452 | int64_t *i) |
@@ -748,7 +749,7 @@ write_to_buffer (struct GNUNET_BIO_WriteHandle *h, | |||
748 | * @param n number of bytes to write | 749 | * @param n number of bytes to write |
749 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 750 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
750 | */ | 751 | */ |
751 | int | 752 | enum GNUNET_GenericReturnValue |
752 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | 753 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, |
753 | const char *what, | 754 | const char *what, |
754 | const void *buffer, | 755 | const void *buffer, |
@@ -785,7 +786,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | |||
785 | * @param s string to write (can be NULL) | 786 | * @param s string to write (can be NULL) |
786 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 787 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
787 | */ | 788 | */ |
788 | int | 789 | enum GNUNET_GenericReturnValue |
789 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, | 790 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, |
790 | const char *what, | 791 | const char *what, |
791 | const char *s) | 792 | const char *s) |
@@ -808,7 +809,7 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, | |||
808 | * @param what what is being written (for error message creation) | 809 | * @param what what is being written (for error message creation) |
809 | * @param f float to write | 810 | * @param f float to write |
810 | */ | 811 | */ |
811 | int | 812 | enum GNUNET_GenericReturnValue |
812 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | 813 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, |
813 | const char *what, | 814 | const char *what, |
814 | float f) | 815 | float f) |
@@ -825,7 +826,7 @@ GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | |||
825 | * @param what what is being written (for error message creation) | 826 | * @param what what is being written (for error message creation) |
826 | * @param f double to write | 827 | * @param f double to write |
827 | */ | 828 | */ |
828 | int | 829 | enum GNUNET_GenericReturnValue |
829 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | 830 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, |
830 | const char *what, | 831 | const char *what, |
831 | double f) | 832 | double f) |
@@ -843,7 +844,7 @@ GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | |||
843 | * @param i 32-bit integer to write | 844 | * @param i 32-bit integer to write |
844 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 845 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
845 | */ | 846 | */ |
846 | int | 847 | enum GNUNET_GenericReturnValue |
847 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | 848 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, |
848 | const char *what, | 849 | const char *what, |
849 | int32_t i) | 850 | int32_t i) |
@@ -863,7 +864,7 @@ GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | |||
863 | * @param i 64-bit integer to write | 864 | * @param i 64-bit integer to write |
864 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 865 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
865 | */ | 866 | */ |
866 | int | 867 | enum GNUNET_GenericReturnValue |
867 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, | 868 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, |
868 | const char *what, | 869 | const char *what, |
869 | int64_t i) | 870 | int64_t i) |
@@ -1104,7 +1105,7 @@ GNUNET_BIO_read_spec_double (const char *what, double *f) | |||
1104 | * the last element must be #GNUNET_BIO_read_spec_end | 1105 | * the last element must be #GNUNET_BIO_read_spec_end |
1105 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 1106 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
1106 | */ | 1107 | */ |
1107 | int | 1108 | enum GNUNET_GenericReturnValue |
1108 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, | 1109 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, |
1109 | struct GNUNET_BIO_ReadSpec *rs) | 1110 | struct GNUNET_BIO_ReadSpec *rs) |
1110 | { | 1111 | { |
@@ -1355,7 +1356,7 @@ GNUNET_BIO_write_spec_double (const char *what, double *f) | |||
1355 | * the last element must be #GNUNET_BIO_write_spec_end | 1356 | * the last element must be #GNUNET_BIO_write_spec_end |
1356 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 1357 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
1357 | */ | 1358 | */ |
1358 | int | 1359 | enum GNUNET_GenericReturnValue |
1359 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, | 1360 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, |
1360 | struct GNUNET_BIO_WriteSpec *ws) | 1361 | struct GNUNET_BIO_WriteSpec *ws) |
1361 | { | 1362 | { |
diff --git a/src/util/child_management.c b/src/util/child_management.c index 680dbcabe..e78ebac9f 100644 --- a/src/util/child_management.c +++ b/src/util/child_management.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021-2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -153,6 +153,7 @@ sighandler_child_death (void) | |||
153 | errno = old_errno; /* restore errno */ | 153 | errno = old_errno; /* restore errno */ |
154 | } | 154 | } |
155 | 155 | ||
156 | |||
156 | /** | 157 | /** |
157 | * Initializing the signal pipe for child handling. | 158 | * Initializing the signal pipe for child handling. |
158 | */ | 159 | */ |
@@ -193,20 +194,13 @@ child_management_done (void) | |||
193 | } | 194 | } |
194 | 195 | ||
195 | 196 | ||
196 | /** | ||
197 | * Adding a child process to be monitored by the child management. | ||
198 | * | ||
199 | * @param proc The child process to be monitored. | ||
200 | * @param cb The callback to be called, when the child process completed. | ||
201 | * @param cb_cls The closure for the callback. | ||
202 | * @return An handle for the the child being monitored. | ||
203 | */ | ||
204 | struct GNUNET_ChildWaitHandle * | 197 | struct GNUNET_ChildWaitHandle * |
205 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, | 198 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, |
206 | GNUNET_ChildCompletedCallback cb, | 199 | GNUNET_ChildCompletedCallback cb, |
207 | void *cb_cls) | 200 | void *cb_cls) |
208 | { | 201 | { |
209 | struct GNUNET_ChildWaitHandle *cwh; | 202 | struct GNUNET_ChildWaitHandle *cwh; |
203 | bool may_race = (NULL == sigpipe); | ||
210 | 204 | ||
211 | child_management_start (); | 205 | child_management_start (); |
212 | cwh = GNUNET_new (struct GNUNET_ChildWaitHandle); | 206 | cwh = GNUNET_new (struct GNUNET_ChildWaitHandle); |
@@ -225,15 +219,14 @@ GNUNET_wait_child (struct GNUNET_OS_Process *proc, | |||
225 | &maint_child_death, | 219 | &maint_child_death, |
226 | NULL); | 220 | NULL); |
227 | } | 221 | } |
222 | /* Handle race-condition case where the child terminated just before we | ||
223 | installed the signal handler and thus we missed the signal. */ | ||
224 | if (may_race) | ||
225 | sighandler_child_death (); | ||
228 | return cwh; | 226 | return cwh; |
229 | } | 227 | } |
230 | 228 | ||
231 | 229 | ||
232 | /** | ||
233 | * Removing child handle. | ||
234 | * | ||
235 | * @param cwh The handle to be removed. | ||
236 | */ | ||
237 | void | 230 | void |
238 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) | 231 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) |
239 | { | 232 | { |
diff --git a/src/util/configuration.c b/src/util/configuration.c index b7ca377a9..45aec7981 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -23,6 +23,7 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "gnunet_common.h" | ||
26 | #include "platform.h" | 27 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_configuration_lib.h" | 29 | #include "gnunet_configuration_lib.h" |
@@ -374,7 +375,7 @@ struct CollectFilesContext | |||
374 | * #GNUNET_NO to stop iteration with no error, | 375 | * #GNUNET_NO to stop iteration with no error, |
375 | * #GNUNET_SYSERR to abort iteration with error! | 376 | * #GNUNET_SYSERR to abort iteration with error! |
376 | */ | 377 | */ |
377 | static int | 378 | static enum GNUNET_GenericReturnValue |
378 | collect_files_cb (void *cls, | 379 | collect_files_cb (void *cls, |
379 | const char *filename) | 380 | const char *filename) |
380 | { | 381 | { |
@@ -782,8 +783,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
782 | if (NULL != cfg->restrict_section) | 783 | if (NULL != cfg->restrict_section) |
783 | { | 784 | { |
784 | LOG (GNUNET_ERROR_TYPE_WARNING, | 785 | LOG (GNUNET_ERROR_TYPE_WARNING, |
785 | _ ( | 786 | "Illegal directive in line %u (parsing restricted section %s)\n", |
786 | "Illegal directive in line %u (parsing restricted section %s)\n"), | ||
787 | nr, | 787 | nr, |
788 | cfg->restrict_section); | 788 | cfg->restrict_section); |
789 | ret = GNUNET_SYSERR; | 789 | ret = GNUNET_SYSERR; |
@@ -793,7 +793,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
793 | if (NULL == end) | 793 | if (NULL == end) |
794 | { | 794 | { |
795 | LOG (GNUNET_ERROR_TYPE_WARNING, | 795 | LOG (GNUNET_ERROR_TYPE_WARNING, |
796 | _ ("Bad directive in line %u\n"), | 796 | "Bad directive in line %u\n", |
797 | nr); | 797 | nr); |
798 | ret = GNUNET_SYSERR; | 798 | ret = GNUNET_SYSERR; |
799 | break; | 799 | break; |
@@ -849,7 +849,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
849 | if (NULL == secname_end) | 849 | if (NULL == secname_end) |
850 | { | 850 | { |
851 | LOG (GNUNET_ERROR_TYPE_WARNING, | 851 | LOG (GNUNET_ERROR_TYPE_WARNING, |
852 | _ ("Bad inline-secret directive in line %u\n"), | 852 | "Bad inline-secret directive in line %u\n", |
853 | nr); | 853 | nr); |
854 | ret = GNUNET_SYSERR; | 854 | ret = GNUNET_SYSERR; |
855 | break; | 855 | break; |
@@ -871,7 +871,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
871 | else | 871 | else |
872 | { | 872 | { |
873 | LOG (GNUNET_ERROR_TYPE_WARNING, | 873 | LOG (GNUNET_ERROR_TYPE_WARNING, |
874 | _ ("Unknown or malformed directive '%s' in line %u\n"), | 874 | "Unknown or malformed directive '%s' in line %u\n", |
875 | directive, | 875 | directive, |
876 | nr); | 876 | nr); |
877 | ret = GNUNET_SYSERR; | 877 | ret = GNUNET_SYSERR; |
@@ -901,8 +901,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
901 | if (NULL == section) | 901 | if (NULL == section) |
902 | { | 902 | { |
903 | LOG (GNUNET_ERROR_TYPE_WARNING, | 903 | LOG (GNUNET_ERROR_TYPE_WARNING, |
904 | _ ( | 904 | "Syntax error while deserializing in line %u (option without section)\n", |
905 | "Syntax error while deserializing in line %u (option without section)\n"), | ||
906 | nr); | 905 | nr); |
907 | ret = GNUNET_SYSERR; | 906 | ret = GNUNET_SYSERR; |
908 | break; | 907 | break; |
@@ -952,7 +951,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
952 | } | 951 | } |
953 | /* parse error */ | 952 | /* parse error */ |
954 | LOG (GNUNET_ERROR_TYPE_WARNING, | 953 | LOG (GNUNET_ERROR_TYPE_WARNING, |
955 | _ ("Syntax error while deserializing in line %u\n"), | 954 | "Syntax error while deserializing in line %u\n", |
956 | nr); | 955 | nr); |
957 | ret = GNUNET_SYSERR; | 956 | ret = GNUNET_SYSERR; |
958 | break; | 957 | break; |
@@ -1033,7 +1032,10 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1033 | 1032 | ||
1034 | dirty = cfg->dirty; /* back up value! */ | 1033 | dirty = cfg->dirty; /* back up value! */ |
1035 | if (GNUNET_SYSERR == | 1034 | if (GNUNET_SYSERR == |
1036 | GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES)) | 1035 | GNUNET_DISK_file_size (fn, |
1036 | &fs64, | ||
1037 | GNUNET_YES, | ||
1038 | GNUNET_YES)) | ||
1037 | { | 1039 | { |
1038 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1040 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1039 | "Error while determining the file size of `%s'\n", | 1041 | "Error while determining the file size of `%s'\n", |
@@ -1052,12 +1054,16 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1052 | sret = GNUNET_DISK_fn_read (fn, mem, fs); | 1054 | sret = GNUNET_DISK_fn_read (fn, mem, fs); |
1053 | if ((sret < 0) || (fs != (size_t) sret)) | 1055 | if ((sret < 0) || (fs != (size_t) sret)) |
1054 | { | 1056 | { |
1055 | LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Error while reading file `%s'\n"), fn); | 1057 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1058 | "Error while reading file `%s'\n", | ||
1059 | fn); | ||
1056 | GNUNET_free (fn); | 1060 | GNUNET_free (fn); |
1057 | GNUNET_free (mem); | 1061 | GNUNET_free (mem); |
1058 | return GNUNET_SYSERR; | 1062 | return GNUNET_SYSERR; |
1059 | } | 1063 | } |
1060 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn); | 1064 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1065 | "Deserializing contents of file `%s'\n", | ||
1066 | fn); | ||
1061 | ret = GNUNET_CONFIGURATION_deserialize (cfg, | 1067 | ret = GNUNET_CONFIGURATION_deserialize (cfg, |
1062 | mem, | 1068 | mem, |
1063 | fs, | 1069 | fs, |
@@ -1512,7 +1518,10 @@ copy_entry (void *cls, | |||
1512 | { | 1518 | { |
1513 | struct GNUNET_CONFIGURATION_Handle *dst = cls; | 1519 | struct GNUNET_CONFIGURATION_Handle *dst = cls; |
1514 | 1520 | ||
1515 | GNUNET_CONFIGURATION_set_value_string (dst, section, option, value); | 1521 | GNUNET_CONFIGURATION_set_value_string (dst, |
1522 | section, | ||
1523 | option, | ||
1524 | value); | ||
1516 | } | 1525 | } |
1517 | 1526 | ||
1518 | 1527 | ||
@@ -1550,7 +1559,10 @@ compare_entries (void *cls, | |||
1550 | if ((NULL != entNew) && (NULL != entNew->val) && | 1559 | if ((NULL != entNew) && (NULL != entNew->val) && |
1551 | (0 == strcmp (entNew->val, value))) | 1560 | (0 == strcmp (entNew->val, value))) |
1552 | return; | 1561 | return; |
1553 | GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value); | 1562 | GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, |
1563 | section, | ||
1564 | option, | ||
1565 | value); | ||
1554 | } | 1566 | } |
1555 | 1567 | ||
1556 | 1568 | ||
@@ -1634,8 +1646,14 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1634 | { | 1646 | { |
1635 | char s[64]; | 1647 | char s[64]; |
1636 | 1648 | ||
1637 | GNUNET_snprintf (s, 64, "%llu", number); | 1649 | GNUNET_snprintf (s, |
1638 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s); | 1650 | 64, |
1651 | "%llu", | ||
1652 | number); | ||
1653 | GNUNET_CONFIGURATION_set_value_string (cfg, | ||
1654 | section, | ||
1655 | option, | ||
1656 | s); | ||
1639 | } | 1657 | } |
1640 | 1658 | ||
1641 | 1659 | ||
@@ -1862,15 +1880,17 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1862 | if (depth > 128) | 1880 | if (depth > 128) |
1863 | { | 1881 | { |
1864 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1882 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1865 | _ ( | 1883 | "Recursive expansion suspected, aborting $-expansion for term `%s'\n", |
1866 | "Recursive expansion suspected, aborting $-expansion for term `%s'\n"), | ||
1867 | orig); | 1884 | orig); |
1868 | return orig; | 1885 | return orig; |
1869 | } | 1886 | } |
1870 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig); | 1887 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1888 | "Asked to $-expand %s\n", | ||
1889 | orig); | ||
1871 | if ('$' != orig[0]) | 1890 | if ('$' != orig[0]) |
1872 | { | 1891 | { |
1873 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n"); | 1892 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1893 | "Doesn't start with $ - not expanding\n"); | ||
1874 | return orig; | 1894 | return orig; |
1875 | } | 1895 | } |
1876 | erased_char = 0; | 1896 | erased_char = 0; |
@@ -1895,8 +1915,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1895 | 1915 | ||
1896 | case '\0': | 1916 | case '\0': |
1897 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1917 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1898 | _ ("Missing closing `%s' in option `%s'\n"), | 1918 | "Missing closing `}' in option `%s'\n", |
1899 | "}", | ||
1900 | orig); | 1919 | orig); |
1901 | return orig; | 1920 | return orig; |
1902 | 1921 | ||
@@ -1925,8 +1944,10 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1925 | start = &orig[1]; | 1944 | start = &orig[1]; |
1926 | def = NULL; | 1945 | def = NULL; |
1927 | i = 0; | 1946 | i = 0; |
1928 | while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0') && | 1947 | while ( (orig[i] != '/') && |
1929 | (orig[i] != ' ')) | 1948 | (orig[i] != '\\') && |
1949 | (orig[i] != '\0') && | ||
1950 | (orig[i] != ' ') ) | ||
1930 | i++; | 1951 | i++; |
1931 | if (orig[i] == '\0') | 1952 | if (orig[i] == '\0') |
1932 | { | 1953 | { |
@@ -1946,12 +1967,17 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1946 | post, | 1967 | post, |
1947 | def); | 1968 | def); |
1948 | if (GNUNET_OK != | 1969 | if (GNUNET_OK != |
1949 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", start, &prefix)) | 1970 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1971 | "PATHS", | ||
1972 | start, | ||
1973 | &prefix)) | ||
1950 | { | 1974 | { |
1951 | if (NULL == (env = getenv (start))) | 1975 | if (NULL == (env = getenv (start))) |
1952 | { | 1976 | { |
1953 | /* try default */ | 1977 | /* try default */ |
1954 | def = expand_dollar (cfg, def, depth + 1); | 1978 | def = expand_dollar (cfg, |
1979 | def, | ||
1980 | depth + 1); | ||
1955 | env = def; | 1981 | env = def; |
1956 | } | 1982 | } |
1957 | if (NULL == env) | 1983 | if (NULL == env) |
@@ -1960,8 +1986,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1960 | if (erased_pos) | 1986 | if (erased_pos) |
1961 | *erased_pos = erased_char; | 1987 | *erased_pos = erased_char; |
1962 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1988 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1963 | _ ( | 1989 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n", |
1964 | "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"), | ||
1965 | start, | 1990 | start, |
1966 | orig); | 1991 | orig); |
1967 | GNUNET_free (start); | 1992 | GNUNET_free (start); |
@@ -1969,7 +1994,8 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1969 | } | 1994 | } |
1970 | prefix = GNUNET_strdup (env); | 1995 | prefix = GNUNET_strdup (env); |
1971 | } | 1996 | } |
1972 | prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix); | 1997 | prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, |
1998 | prefix); | ||
1973 | if ((erased_pos) && ('}' != erased_char)) | 1999 | if ((erased_pos) && ('}' != erased_char)) |
1974 | { | 2000 | { |
1975 | len = strlen (prefix) + 1; | 2001 | len = strlen (prefix) + 1; |
@@ -2206,7 +2232,10 @@ GNUNET_CONFIGURATION_append_value_filename ( | |||
2206 | if (strlen (old) > 0) | 2232 | if (strlen (old) > 0) |
2207 | strcat (nw, " "); | 2233 | strcat (nw, " "); |
2208 | strcat (nw, escaped); | 2234 | strcat (nw, escaped); |
2209 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw); | 2235 | GNUNET_CONFIGURATION_set_value_string (cfg, |
2236 | section, | ||
2237 | option, | ||
2238 | nw); | ||
2210 | GNUNET_free (old); | 2239 | GNUNET_free (old); |
2211 | GNUNET_free (nw); | 2240 | GNUNET_free (nw); |
2212 | GNUNET_free (escaped); | 2241 | GNUNET_free (escaped); |
@@ -2228,7 +2257,10 @@ GNUNET_CONFIGURATION_remove_value_filename ( | |||
2228 | char old; | 2257 | char old; |
2229 | 2258 | ||
2230 | if (GNUNET_OK != | 2259 | if (GNUNET_OK != |
2231 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list)) | 2260 | GNUNET_CONFIGURATION_get_value_string (cfg, |
2261 | section, | ||
2262 | option, | ||
2263 | &list)) | ||
2232 | return GNUNET_NO; | 2264 | return GNUNET_NO; |
2233 | match = escape_name (value); | 2265 | match = escape_name (value); |
2234 | pos = list; | 2266 | pos = list; |
@@ -2266,7 +2298,9 @@ GNUNET_CONFIGURATION_remove_value_filename ( | |||
2266 | if (0 == strcmp (pos, match)) | 2298 | if (0 == strcmp (pos, match)) |
2267 | { | 2299 | { |
2268 | if (old != '\0') | 2300 | if (old != '\0') |
2269 | memmove (pos, &end[1], strlen (&end[1]) + 1); | 2301 | memmove (pos, |
2302 | &end[1], | ||
2303 | strlen (&end[1]) + 1); | ||
2270 | else | 2304 | else |
2271 | { | 2305 | { |
2272 | if (pos != list) | 2306 | if (pos != list) |
@@ -2274,7 +2308,10 @@ GNUNET_CONFIGURATION_remove_value_filename ( | |||
2274 | else | 2308 | else |
2275 | pos[0] = '\0'; | 2309 | pos[0] = '\0'; |
2276 | } | 2310 | } |
2277 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, list); | 2311 | GNUNET_CONFIGURATION_set_value_string (cfg, |
2312 | section, | ||
2313 | option, | ||
2314 | list); | ||
2278 | GNUNET_free (list); | 2315 | GNUNET_free (list); |
2279 | GNUNET_free (match); | 2316 | GNUNET_free (match); |
2280 | return GNUNET_OK; | 2317 | return GNUNET_OK; |
@@ -2455,7 +2492,7 @@ GNUNET_CONFIGURATION_default (void) | |||
2455 | * @param filename name of the configuration file, NULL to load defaults | 2492 | * @param filename name of the configuration file, NULL to load defaults |
2456 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 2493 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
2457 | */ | 2494 | */ |
2458 | int | 2495 | enum GNUNET_GenericReturnValue |
2459 | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | 2496 | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, |
2460 | const char *filename) | 2497 | const char *filename) |
2461 | { | 2498 | { |
@@ -2499,8 +2536,12 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2499 | char *dname = GNUNET_STRINGS_filename_expand (baseconfig); | 2536 | char *dname = GNUNET_STRINGS_filename_expand (baseconfig); |
2500 | GNUNET_free (baseconfig); | 2537 | GNUNET_free (baseconfig); |
2501 | 2538 | ||
2502 | if ((GNUNET_YES == GNUNET_DISK_directory_test (dname, GNUNET_YES)) && | 2539 | if ((GNUNET_YES == |
2503 | (GNUNET_SYSERR == GNUNET_CONFIGURATION_load_from (cfg, dname))) | 2540 | GNUNET_DISK_directory_test (dname, |
2541 | GNUNET_YES)) && | ||
2542 | (GNUNET_SYSERR == | ||
2543 | GNUNET_CONFIGURATION_load_from (cfg, | ||
2544 | dname))) | ||
2504 | { | 2545 | { |
2505 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2546 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2506 | "Failed to load base configuration from '%s'\n", | 2547 | "Failed to load base configuration from '%s'\n", |
@@ -2510,7 +2551,9 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2510 | } | 2551 | } |
2511 | GNUNET_free (dname); | 2552 | GNUNET_free (dname); |
2512 | if ((NULL != filename) && | 2553 | if ((NULL != filename) && |
2513 | (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename))) | 2554 | (GNUNET_OK != |
2555 | GNUNET_CONFIGURATION_parse (cfg, | ||
2556 | filename))) | ||
2514 | { | 2557 | { |
2515 | /* specified configuration not found */ | 2558 | /* specified configuration not found */ |
2516 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2559 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -2519,9 +2562,13 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2519 | return GNUNET_SYSERR; | 2562 | return GNUNET_SYSERR; |
2520 | } | 2563 | } |
2521 | if (((GNUNET_YES != | 2564 | if (((GNUNET_YES != |
2522 | GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && | 2565 | GNUNET_CONFIGURATION_have_value (cfg, |
2566 | "PATHS", | ||
2567 | "DEFAULTCONFIG"))) && | ||
2523 | (filename != NULL)) | 2568 | (filename != NULL)) |
2524 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", | 2569 | GNUNET_CONFIGURATION_set_value_string (cfg, |
2570 | "PATHS", | ||
2571 | "DEFAULTCONFIG", | ||
2525 | filename); | 2572 | filename); |
2526 | return GNUNET_OK; | 2573 | return GNUNET_OK; |
2527 | } | 2574 | } |
diff --git a/src/util/container_heap.c b/src/util/container_heap.c index 77b828d31..56a002f8c 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include "gnunet_common.h" | ||
29 | #include "platform.h" | 30 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
@@ -167,7 +168,7 @@ GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap) | |||
167 | * @return #GNUNET_YES if an element is returned, | 168 | * @return #GNUNET_YES if an element is returned, |
168 | * #GNUNET_NO if the heap is empty. | 169 | * #GNUNET_NO if the heap is empty. |
169 | */ | 170 | */ |
170 | int | 171 | enum GNUNET_GenericReturnValue |
171 | GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, | 172 | GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, |
172 | void **element, | 173 | void **element, |
173 | GNUNET_CONTAINER_HeapCostType *cost) | 174 | GNUNET_CONTAINER_HeapCostType *cost) |
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index b61395471..65d7f33c0 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c | |||
@@ -24,6 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | 26 | ||
27 | #include "gnunet_common.h" | ||
27 | #include "platform.h" | 28 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | 30 | ||
@@ -305,7 +306,7 @@ GNUNET_CONTAINER_multihashmap_get ( | |||
305 | } | 306 | } |
306 | 307 | ||
307 | 308 | ||
308 | int | 309 | enum GNUNET_GenericReturnValue |
309 | GNUNET_CONTAINER_multihashmap_iterate ( | 310 | GNUNET_CONTAINER_multihashmap_iterate ( |
310 | struct GNUNET_CONTAINER_MultiHashMap *map, | 311 | struct GNUNET_CONTAINER_MultiHashMap *map, |
311 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, | 312 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, |
@@ -402,7 +403,7 @@ update_next_cache_sme (struct GNUNET_CONTAINER_MultiHashMap *map, | |||
402 | } | 403 | } |
403 | 404 | ||
404 | 405 | ||
405 | int | 406 | enum GNUNET_GenericReturnValue |
406 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, | 407 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, |
407 | const struct GNUNET_HashCode *key, | 408 | const struct GNUNET_HashCode *key, |
408 | const void *value) | 409 | const void *value) |
@@ -578,7 +579,7 @@ GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map) | |||
578 | } | 579 | } |
579 | 580 | ||
580 | 581 | ||
581 | int | 582 | enum GNUNET_GenericReturnValue |
582 | GNUNET_CONTAINER_multihashmap_contains ( | 583 | GNUNET_CONTAINER_multihashmap_contains ( |
583 | const struct GNUNET_CONTAINER_MultiHashMap *map, | 584 | const struct GNUNET_CONTAINER_MultiHashMap *map, |
584 | const struct GNUNET_HashCode *key) | 585 | const struct GNUNET_HashCode *key) |
@@ -606,7 +607,7 @@ GNUNET_CONTAINER_multihashmap_contains ( | |||
606 | } | 607 | } |
607 | 608 | ||
608 | 609 | ||
609 | int | 610 | enum GNUNET_GenericReturnValue |
610 | GNUNET_CONTAINER_multihashmap_contains_value ( | 611 | GNUNET_CONTAINER_multihashmap_contains_value ( |
611 | const struct GNUNET_CONTAINER_MultiHashMap *map, | 612 | const struct GNUNET_CONTAINER_MultiHashMap *map, |
612 | const struct GNUNET_HashCode *key, | 613 | const struct GNUNET_HashCode *key, |
@@ -706,7 +707,7 @@ grow (struct GNUNET_CONTAINER_MultiHashMap *map) | |||
706 | * #GNUNET_SYSERR if UNIQUE_ONLY was the option and the | 707 | * #GNUNET_SYSERR if UNIQUE_ONLY was the option and the |
707 | * value already exists | 708 | * value already exists |
708 | */ | 709 | */ |
709 | int | 710 | enum GNUNET_GenericReturnValue |
710 | GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, | 711 | GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, |
711 | const struct GNUNET_HashCode *key, | 712 | const struct GNUNET_HashCode *key, |
712 | void *value, | 713 | void *value, |
@@ -777,7 +778,7 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, | |||
777 | } | 778 | } |
778 | 779 | ||
779 | 780 | ||
780 | int | 781 | enum GNUNET_GenericReturnValue |
781 | GNUNET_CONTAINER_multihashmap_get_multiple ( | 782 | GNUNET_CONTAINER_multihashmap_get_multiple ( |
782 | struct GNUNET_CONTAINER_MultiHashMap *map, | 783 | struct GNUNET_CONTAINER_MultiHashMap *map, |
783 | const struct GNUNET_HashCode *key, | 784 | const struct GNUNET_HashCode *key, |
@@ -918,7 +919,7 @@ GNUNET_CONTAINER_multihashmap_iterator_create ( | |||
918 | } | 919 | } |
919 | 920 | ||
920 | 921 | ||
921 | int | 922 | enum GNUNET_GenericReturnValue |
922 | GNUNET_CONTAINER_multihashmap_iterator_next ( | 923 | GNUNET_CONTAINER_multihashmap_iterator_next ( |
923 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter, | 924 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter, |
924 | struct GNUNET_HashCode *key, | 925 | struct GNUNET_HashCode *key, |
diff --git a/src/util/container_multihashmap32.c b/src/util/container_multihashmap32.c index 4ddf0053b..698e08e3a 100644 --- a/src/util/container_multihashmap32.c +++ b/src/util/container_multihashmap32.c | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include "gnunet_common.h" | ||
29 | #include "platform.h" | 30 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
@@ -276,7 +277,7 @@ update_next_cache (struct GNUNET_CONTAINER_MultiHashMap32 *map, | |||
276 | } | 277 | } |
277 | 278 | ||
278 | 279 | ||
279 | int | 280 | enum GNUNET_GenericReturnValue |
280 | GNUNET_CONTAINER_multihashmap32_remove ( | 281 | GNUNET_CONTAINER_multihashmap32_remove ( |
281 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 282 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
282 | uint32_t key, | 283 | uint32_t key, |
@@ -354,7 +355,7 @@ GNUNET_CONTAINER_multihashmap32_remove_all ( | |||
354 | } | 355 | } |
355 | 356 | ||
356 | 357 | ||
357 | int | 358 | enum GNUNET_GenericReturnValue |
358 | GNUNET_CONTAINER_multihashmap32_contains ( | 359 | GNUNET_CONTAINER_multihashmap32_contains ( |
359 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, | 360 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, |
360 | uint32_t key) | 361 | uint32_t key) |
@@ -372,7 +373,7 @@ GNUNET_CONTAINER_multihashmap32_contains ( | |||
372 | } | 373 | } |
373 | 374 | ||
374 | 375 | ||
375 | int | 376 | enum GNUNET_GenericReturnValue |
376 | GNUNET_CONTAINER_multihashmap32_contains_value ( | 377 | GNUNET_CONTAINER_multihashmap32_contains_value ( |
377 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, | 378 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, |
378 | uint32_t key, | 379 | uint32_t key, |
@@ -445,7 +446,7 @@ grow (struct GNUNET_CONTAINER_MultiHashMap32 *map) | |||
445 | * #GNUNET_SYSERR if UNIQUE_ONLY was the option and the | 446 | * #GNUNET_SYSERR if UNIQUE_ONLY was the option and the |
446 | * value already exists | 447 | * value already exists |
447 | */ | 448 | */ |
448 | int | 449 | enum GNUNET_GenericReturnValue |
449 | GNUNET_CONTAINER_multihashmap32_put ( | 450 | GNUNET_CONTAINER_multihashmap32_put ( |
450 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 451 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
451 | uint32_t key, | 452 | uint32_t key, |
@@ -560,7 +561,7 @@ GNUNET_CONTAINER_multihashmap32_iterator_create ( | |||
560 | * @return #GNUNET_YES we returned an element, | 561 | * @return #GNUNET_YES we returned an element, |
561 | * #GNUNET_NO if we are out of elements | 562 | * #GNUNET_NO if we are out of elements |
562 | */ | 563 | */ |
563 | int | 564 | enum GNUNET_GenericReturnValue |
564 | GNUNET_CONTAINER_multihashmap32_iterator_next ( | 565 | GNUNET_CONTAINER_multihashmap32_iterator_next ( |
565 | struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, | 566 | struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, |
566 | uint32_t *key, | 567 | uint32_t *key, |
diff --git a/src/util/container_multipeermap.c b/src/util/container_multipeermap.c index 82a240fff..7ccfb62c8 100644 --- a/src/util/container_multipeermap.c +++ b/src/util/container_multipeermap.c | |||
@@ -385,7 +385,7 @@ update_next_cache_sme (struct GNUNET_CONTAINER_MultiPeerMap *map, | |||
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | int | 388 | enum GNUNET_GenericReturnValue |
389 | GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, | 389 | GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, |
390 | const struct GNUNET_PeerIdentity *key, | 390 | const struct GNUNET_PeerIdentity *key, |
391 | const void *value) | 391 | const void *value) |
@@ -520,7 +520,7 @@ GNUNET_CONTAINER_multipeermap_remove_all ( | |||
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | int | 523 | enum GNUNET_GenericReturnValue |
524 | GNUNET_CONTAINER_multipeermap_contains ( | 524 | GNUNET_CONTAINER_multipeermap_contains ( |
525 | const struct GNUNET_CONTAINER_MultiPeerMap *map, | 525 | const struct GNUNET_CONTAINER_MultiPeerMap *map, |
526 | const struct GNUNET_PeerIdentity *key) | 526 | const struct GNUNET_PeerIdentity *key) |
@@ -544,7 +544,7 @@ GNUNET_CONTAINER_multipeermap_contains ( | |||
544 | } | 544 | } |
545 | 545 | ||
546 | 546 | ||
547 | int | 547 | enum GNUNET_GenericReturnValue |
548 | GNUNET_CONTAINER_multipeermap_contains_value ( | 548 | GNUNET_CONTAINER_multipeermap_contains_value ( |
549 | const struct GNUNET_CONTAINER_MultiPeerMap *map, | 549 | const struct GNUNET_CONTAINER_MultiPeerMap *map, |
550 | const struct GNUNET_PeerIdentity *key, | 550 | const struct GNUNET_PeerIdentity *key, |
@@ -839,7 +839,7 @@ GNUNET_CONTAINER_multipeermap_iterator_create ( | |||
839 | } | 839 | } |
840 | 840 | ||
841 | 841 | ||
842 | int | 842 | enum GNUNET_GenericReturnValue |
843 | GNUNET_CONTAINER_multipeermap_iterator_next ( | 843 | GNUNET_CONTAINER_multipeermap_iterator_next ( |
844 | struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, | 844 | struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, |
845 | struct GNUNET_PeerIdentity *key, | 845 | struct GNUNET_PeerIdentity *key, |
diff --git a/src/util/container_multishortmap.c b/src/util/container_multishortmap.c index 3c0adc196..327616048 100644 --- a/src/util/container_multishortmap.c +++ b/src/util/container_multishortmap.c | |||
@@ -24,6 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | 26 | ||
27 | #include "gnunet_common.h" | ||
27 | #include "platform.h" | 28 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | 30 | ||
@@ -640,7 +641,7 @@ grow (struct GNUNET_CONTAINER_MultiShortmap *map) | |||
640 | } | 641 | } |
641 | 642 | ||
642 | 643 | ||
643 | int | 644 | enum GNUNET_GenericReturnValue |
644 | GNUNET_CONTAINER_multishortmap_put ( | 645 | GNUNET_CONTAINER_multishortmap_put ( |
645 | struct GNUNET_CONTAINER_MultiShortmap *map, | 646 | struct GNUNET_CONTAINER_MultiShortmap *map, |
646 | const struct GNUNET_ShortHashCode *key, | 647 | const struct GNUNET_ShortHashCode *key, |
@@ -848,7 +849,7 @@ GNUNET_CONTAINER_multishortmap_iterator_create ( | |||
848 | } | 849 | } |
849 | 850 | ||
850 | 851 | ||
851 | int | 852 | enum GNUNET_GenericReturnValue |
852 | GNUNET_CONTAINER_multishortmap_iterator_next ( | 853 | GNUNET_CONTAINER_multishortmap_iterator_next ( |
853 | struct GNUNET_CONTAINER_MultiShortmapIterator *iter, | 854 | struct GNUNET_CONTAINER_MultiShortmapIterator *iter, |
854 | struct GNUNET_ShortHashCode *key, | 855 | struct GNUNET_ShortHashCode *key, |
diff --git a/src/util/container_multiuuidmap.c b/src/util/container_multiuuidmap.c index 96398e4f5..53975b3f7 100644 --- a/src/util/container_multiuuidmap.c +++ b/src/util/container_multiuuidmap.c | |||
@@ -24,6 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | 26 | ||
27 | #include "gnunet_common.h" | ||
27 | #include "platform.h" | 28 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | 30 | ||
@@ -303,7 +304,7 @@ GNUNET_CONTAINER_multiuuidmap_get ( | |||
303 | } | 304 | } |
304 | 305 | ||
305 | 306 | ||
306 | int | 307 | enum GNUNET_GenericReturnValue |
307 | GNUNET_CONTAINER_multiuuidmap_iterate ( | 308 | GNUNET_CONTAINER_multiuuidmap_iterate ( |
308 | struct GNUNET_CONTAINER_MultiUuidmap *map, | 309 | struct GNUNET_CONTAINER_MultiUuidmap *map, |
309 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, | 310 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, |
@@ -397,7 +398,7 @@ update_next_cache_sme (struct GNUNET_CONTAINER_MultiUuidmap *map, | |||
397 | } | 398 | } |
398 | 399 | ||
399 | 400 | ||
400 | int | 401 | enum GNUNET_GenericReturnValue |
401 | GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, | 402 | GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, |
402 | const struct GNUNET_Uuid *key, | 403 | const struct GNUNET_Uuid *key, |
403 | const void *value) | 404 | const void *value) |
@@ -532,7 +533,7 @@ GNUNET_CONTAINER_multiuuidmap_remove_all ( | |||
532 | } | 533 | } |
533 | 534 | ||
534 | 535 | ||
535 | int | 536 | enum GNUNET_GenericReturnValue |
536 | GNUNET_CONTAINER_multiuuidmap_contains ( | 537 | GNUNET_CONTAINER_multiuuidmap_contains ( |
537 | const struct GNUNET_CONTAINER_MultiUuidmap *map, | 538 | const struct GNUNET_CONTAINER_MultiUuidmap *map, |
538 | const struct GNUNET_Uuid *key) | 539 | const struct GNUNET_Uuid *key) |
@@ -556,7 +557,7 @@ GNUNET_CONTAINER_multiuuidmap_contains ( | |||
556 | } | 557 | } |
557 | 558 | ||
558 | 559 | ||
559 | int | 560 | enum GNUNET_GenericReturnValue |
560 | GNUNET_CONTAINER_multiuuidmap_contains_value ( | 561 | GNUNET_CONTAINER_multiuuidmap_contains_value ( |
561 | const struct GNUNET_CONTAINER_MultiUuidmap *map, | 562 | const struct GNUNET_CONTAINER_MultiUuidmap *map, |
562 | const struct GNUNET_Uuid *key, | 563 | const struct GNUNET_Uuid *key, |
@@ -639,7 +640,7 @@ grow (struct GNUNET_CONTAINER_MultiUuidmap *map) | |||
639 | } | 640 | } |
640 | 641 | ||
641 | 642 | ||
642 | int | 643 | enum GNUNET_GenericReturnValue |
643 | GNUNET_CONTAINER_multiuuidmap_put (struct GNUNET_CONTAINER_MultiUuidmap *map, | 644 | GNUNET_CONTAINER_multiuuidmap_put (struct GNUNET_CONTAINER_MultiUuidmap *map, |
644 | const struct GNUNET_Uuid *key, | 645 | const struct GNUNET_Uuid *key, |
645 | void *value, | 646 | void *value, |
@@ -846,7 +847,7 @@ GNUNET_CONTAINER_multiuuidmap_iterator_create ( | |||
846 | } | 847 | } |
847 | 848 | ||
848 | 849 | ||
849 | int | 850 | enum GNUNET_GenericReturnValue |
850 | GNUNET_CONTAINER_multiuuidmap_iterator_next ( | 851 | GNUNET_CONTAINER_multiuuidmap_iterator_next ( |
851 | struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, | 852 | struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, |
852 | struct GNUNET_Uuid *key, | 853 | struct GNUNET_Uuid *key, |
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 7f9e3c070..11c3e50d4 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -61,10 +61,11 @@ | |||
61 | #define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-ecc", __VA_ARGS__) | 61 | #define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-ecc", __VA_ARGS__) |
62 | 62 | ||
63 | #define LOG_STRERROR(kind, syscall) \ | 63 | #define LOG_STRERROR(kind, syscall) \ |
64 | GNUNET_log_from_strerror (kind, "util-crypto-ecc", syscall) | 64 | GNUNET_log_from_strerror (kind, "util-crypto-ecc", syscall) |
65 | 65 | ||
66 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ | 66 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ |
67 | GNUNET_log_from_strerror_file (kind, "util-crypto-ecc", syscall, filename) | 67 | GNUNET_log_from_strerror_file (kind, "util-crypto-ecc", syscall, \ |
68 | filename) | ||
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Log an error message at log-level 'level' that indicates | 71 | * Log an error message at log-level 'level' that indicates |
@@ -72,15 +73,15 @@ | |||
72 | * by gcry_strerror(rc). | 73 | * by gcry_strerror(rc). |
73 | */ | 74 | */ |
74 | #define LOG_GCRY(level, cmd, rc) \ | 75 | #define LOG_GCRY(level, cmd, rc) \ |
75 | do \ | 76 | do \ |
76 | { \ | 77 | { \ |
77 | LOG (level, \ | 78 | LOG (level, \ |
78 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | 79 | _ ("`%s' failed at %s:%d with error: %s\n"), \ |
79 | cmd, \ | 80 | cmd, \ |
80 | __FILE__, \ | 81 | __FILE__, \ |
81 | __LINE__, \ | 82 | __LINE__, \ |
82 | gcry_strerror (rc)); \ | 83 | gcry_strerror (rc)); \ |
83 | } while (0) | 84 | } while (0) |
84 | 85 | ||
85 | 86 | ||
86 | /** | 87 | /** |
@@ -513,9 +514,7 @@ data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
513 | { | 514 | { |
514 | gcry_sexp_t data; | 515 | gcry_sexp_t data; |
515 | int rc; | 516 | int rc; |
516 | 517 | /* Unlike EdDSA, libgcrypt expects a hash for ECDSA. */ | |
517 | /* See #5398 */ | ||
518 | #if 1 | ||
519 | struct GNUNET_HashCode hc; | 518 | struct GNUNET_HashCode hc; |
520 | 519 | ||
521 | GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc); | 520 | GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc); |
@@ -529,18 +528,6 @@ data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
529 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 528 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
530 | return NULL; | 529 | return NULL; |
531 | } | 530 | } |
532 | #else | ||
533 | if (0 != (rc = gcry_sexp_build (&data, | ||
534 | NULL, | ||
535 | "(data(flags rfc6979)(hash %s %b))", | ||
536 | "sha512", | ||
537 | ntohl (purpose->size), | ||
538 | purpose))) | ||
539 | { | ||
540 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | ||
541 | return NULL; | ||
542 | } | ||
543 | #endif | ||
544 | return data; | 531 | return data; |
545 | } | 532 | } |
546 | 533 | ||
@@ -594,6 +581,7 @@ GNUNET_CRYPTO_ecdsa_sign_ ( | |||
594 | return GNUNET_OK; | 581 | return GNUNET_OK; |
595 | } | 582 | } |
596 | 583 | ||
584 | |||
597 | enum GNUNET_GenericReturnValue | 585 | enum GNUNET_GenericReturnValue |
598 | GNUNET_CRYPTO_eddsa_sign_raw ( | 586 | GNUNET_CRYPTO_eddsa_sign_raw ( |
599 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 587 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
@@ -758,6 +746,16 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
758 | 746 | ||
759 | 747 | ||
760 | enum GNUNET_GenericReturnValue | 748 | enum GNUNET_GenericReturnValue |
749 | GNUNET_CRYPTO_eddsa_kem_decaps (const struct | ||
750 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
751 | const struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
752 | struct GNUNET_HashCode *key_material) | ||
753 | { | ||
754 | return GNUNET_CRYPTO_eddsa_ecdh (priv, c, key_material); | ||
755 | } | ||
756 | |||
757 | |||
758 | enum GNUNET_GenericReturnValue | ||
761 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 759 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
762 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 760 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
763 | struct GNUNET_HashCode *key_material) | 761 | struct GNUNET_HashCode *key_material) |
@@ -793,6 +791,152 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
793 | 791 | ||
794 | 792 | ||
795 | enum GNUNET_GenericReturnValue | 793 | enum GNUNET_GenericReturnValue |
794 | GNUNET_CRYPTO_eddsa_kem_encaps (const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
795 | struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
796 | struct GNUNET_HashCode *key_material) | ||
797 | { | ||
798 | struct GNUNET_CRYPTO_EcdhePrivateKey sk; | ||
799 | |||
800 | GNUNET_CRYPTO_ecdhe_key_create (&sk); | ||
801 | GNUNET_CRYPTO_ecdhe_key_get_public (&sk, c); | ||
802 | return GNUNET_CRYPTO_ecdh_eddsa (&sk, pub, key_material); | ||
803 | } | ||
804 | |||
805 | |||
806 | enum GNUNET_GenericReturnValue | ||
807 | GNUNET_CRYPTO_ecdsa_fo_kem_encaps (const struct | ||
808 | GNUNET_CRYPTO_EcdsaPublicKey *pub, | ||
809 | struct GNUNET_CRYPTO_FoKemC *c, | ||
810 | struct GNUNET_HashCode *key_material) | ||
811 | { | ||
812 | struct GNUNET_HashCode x; | ||
813 | struct GNUNET_HashCode ux; | ||
814 | struct GNUNET_HashCode w; | ||
815 | struct GNUNET_CRYPTO_EcdhePrivateKey sk; | ||
816 | |||
817 | // This is the input to the FO OWTF | ||
818 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &x, sizeof(x)); | ||
819 | |||
820 | // We build our OWTF using a FO-transformation of ElGamal: | ||
821 | // U(x) | ||
822 | GNUNET_CRYPTO_hash (&x, sizeof (x), &ux); | ||
823 | GNUNET_memcpy (&sk, &ux, sizeof (sk)); | ||
824 | |||
825 | // B := g^U(x) | ||
826 | GNUNET_CRYPTO_ecdhe_key_get_public (&sk, &c->pub); | ||
827 | |||
828 | if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa (&sk, pub, &w)) | ||
829 | return -1; | ||
830 | // w xor x (one-time pad) | ||
831 | GNUNET_CRYPTO_hash_xor (&w, &x, &c->y); | ||
832 | |||
833 | // k := H(x) FIXME: U and H must be different? | ||
834 | GNUNET_memcpy (key_material, &ux, sizeof (ux)); | ||
835 | return GNUNET_OK; | ||
836 | } | ||
837 | |||
838 | |||
839 | enum GNUNET_GenericReturnValue | ||
840 | GNUNET_CRYPTO_eddsa_fo_kem_encaps (const struct | ||
841 | GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
842 | struct GNUNET_CRYPTO_FoKemC *c, | ||
843 | struct GNUNET_HashCode *key_material) | ||
844 | { | ||
845 | struct GNUNET_HashCode x; | ||
846 | struct GNUNET_HashCode ux; | ||
847 | struct GNUNET_HashCode w; | ||
848 | struct GNUNET_CRYPTO_EcdhePrivateKey sk; | ||
849 | enum GNUNET_GenericReturnValue ret; | ||
850 | |||
851 | // This is the input to the FO OWTF | ||
852 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &x, sizeof(x)); | ||
853 | |||
854 | // We build our OWTF using a FO-transformation of ElGamal: | ||
855 | // U(x) | ||
856 | GNUNET_CRYPTO_hash (&x, sizeof (x), &ux); | ||
857 | GNUNET_memcpy (&sk, &ux, sizeof (sk)); | ||
858 | |||
859 | // B := g^U(x) | ||
860 | GNUNET_CRYPTO_ecdhe_key_get_public (&sk, &c->pub); | ||
861 | |||
862 | ret = GNUNET_CRYPTO_ecdh_eddsa (&sk, pub, &w); | ||
863 | if (GNUNET_OK != ret) | ||
864 | return ret; | ||
865 | // w xor x (one-time pad) | ||
866 | GNUNET_CRYPTO_hash_xor (&w, &x, &c->y); | ||
867 | |||
868 | // k := H(x) FIXME: U and H must be different? | ||
869 | GNUNET_memcpy (key_material, &ux, sizeof (ux)); | ||
870 | return GNUNET_OK; | ||
871 | } | ||
872 | |||
873 | |||
874 | static enum GNUNET_GenericReturnValue | ||
875 | fo_kem_decaps (const struct GNUNET_HashCode *w, | ||
876 | const struct GNUNET_CRYPTO_FoKemC *c, | ||
877 | struct GNUNET_HashCode *key_material) | ||
878 | { | ||
879 | struct GNUNET_HashCode x; | ||
880 | struct GNUNET_HashCode ux; | ||
881 | struct GNUNET_CRYPTO_EcdhePrivateKey sk; | ||
882 | struct GNUNET_CRYPTO_EcdhePublicKey pub_test; | ||
883 | |||
884 | // w xor x (one-time pad) | ||
885 | GNUNET_CRYPTO_hash_xor (w, &c->y, &x); | ||
886 | |||
887 | // We build our OWTF using a FO-transformation of ElGamal: | ||
888 | // U(x) | ||
889 | GNUNET_CRYPTO_hash (&x, sizeof (x), &ux); | ||
890 | GNUNET_memcpy (&sk, &ux, sizeof (sk)); | ||
891 | |||
892 | // B := g^U(x) | ||
893 | GNUNET_CRYPTO_ecdhe_key_get_public (&sk, &pub_test); | ||
894 | |||
895 | if (0 != memcmp (&pub_test, &c->pub, sizeof (c->pub))) | ||
896 | return GNUNET_SYSERR; // Reject | ||
897 | |||
898 | // k := H(x) FIXME: U and H must be different? | ||
899 | GNUNET_memcpy (key_material, &ux, sizeof (ux)); | ||
900 | return GNUNET_OK; | ||
901 | } | ||
902 | |||
903 | |||
904 | /** | ||
905 | * This implementation is not testes/publicly exposed yet | ||
906 | */ | ||
907 | enum GNUNET_GenericReturnValue | ||
908 | GNUNET_CRYPTO_eddsa_fo_kem_decaps (const struct | ||
909 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
910 | const struct GNUNET_CRYPTO_FoKemC *c, | ||
911 | struct GNUNET_HashCode *key_material) | ||
912 | { | ||
913 | struct GNUNET_HashCode w; | ||
914 | enum GNUNET_GenericReturnValue ret; | ||
915 | |||
916 | ret = GNUNET_CRYPTO_eddsa_ecdh (priv, &c->pub, &w); | ||
917 | if (GNUNET_OK != ret) | ||
918 | return ret; | ||
919 | return fo_kem_decaps (&w, c, key_material); | ||
920 | } | ||
921 | |||
922 | |||
923 | enum GNUNET_GenericReturnValue | ||
924 | GNUNET_CRYPTO_ecdsa_fo_kem_decaps (const struct | ||
925 | GNUNET_CRYPTO_EcdsaPrivateKey *priv, | ||
926 | struct GNUNET_CRYPTO_FoKemC *c, | ||
927 | struct GNUNET_HashCode *key_material) | ||
928 | { | ||
929 | struct GNUNET_HashCode w; | ||
930 | enum GNUNET_GenericReturnValue ret; | ||
931 | |||
932 | ret = GNUNET_CRYPTO_ecdsa_ecdh (priv, &c->pub, &w); | ||
933 | if (GNUNET_OK != ret) | ||
934 | return ret; | ||
935 | return fo_kem_decaps (&w, c, key_material); | ||
936 | } | ||
937 | |||
938 | |||
939 | enum GNUNET_GenericReturnValue | ||
796 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 940 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
797 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 941 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
798 | struct GNUNET_HashCode *key_material) | 942 | struct GNUNET_HashCode *key_material) |
diff --git a/src/util/crypto_ecc_gnsrecord.c b/src/util/crypto_ecc_gnsrecord.c index fc99bfc18..fb8ba3ac9 100644 --- a/src/util/crypto_ecc_gnsrecord.c +++ b/src/util/crypto_ecc_gnsrecord.c | |||
@@ -170,6 +170,7 @@ GNUNET_CRYPTO_eddsa_sign_derived ( | |||
170 | return GNUNET_OK; | 170 | return GNUNET_OK; |
171 | } | 171 | } |
172 | 172 | ||
173 | |||
173 | enum GNUNET_GenericReturnValue | 174 | enum GNUNET_GenericReturnValue |
174 | GNUNET_CRYPTO_ecdsa_sign_derived ( | 175 | GNUNET_CRYPTO_ecdsa_sign_derived ( |
175 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 176 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -190,6 +191,7 @@ GNUNET_CRYPTO_ecdsa_sign_derived ( | |||
190 | return res; | 191 | return res; |
191 | } | 192 | } |
192 | 193 | ||
194 | |||
193 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 195 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
194 | GNUNET_CRYPTO_ecdsa_private_key_derive ( | 196 | GNUNET_CRYPTO_ecdsa_private_key_derive ( |
195 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 197 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -300,12 +302,10 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
300 | uint8_t dc[32]; | 302 | uint8_t dc[32]; |
301 | unsigned char sk[64]; | 303 | unsigned char sk[64]; |
302 | gcry_mpi_t h; | 304 | gcry_mpi_t h; |
303 | gcry_mpi_t h_mod_n; | 305 | gcry_mpi_t h_mod_L; |
304 | gcry_mpi_t x; | 306 | gcry_mpi_t a; |
305 | gcry_mpi_t d; | 307 | gcry_mpi_t d; |
306 | gcry_mpi_t n; | 308 | gcry_mpi_t L; |
307 | gcry_mpi_t a1; | ||
308 | gcry_mpi_t a2; | ||
309 | gcry_ctx_t ctx; | 309 | gcry_ctx_t ctx; |
310 | 310 | ||
311 | /** | 311 | /** |
@@ -315,9 +315,9 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
315 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, "Ed25519")); | 315 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, "Ed25519")); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | * Get our modulo | 318 | * Get our modulo L |
319 | */ | 319 | */ |
320 | n = gcry_mpi_ec_get_mpi ("n", ctx, 1); | 320 | L = gcry_mpi_ec_get_mpi ("n", ctx, 1); |
321 | GNUNET_CRYPTO_eddsa_key_get_public (priv, &pub); | 321 | GNUNET_CRYPTO_eddsa_key_get_public (priv, &pub); |
322 | 322 | ||
323 | /** | 323 | /** |
@@ -332,39 +332,28 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
332 | sk[31] |= 64; | 332 | sk[31] |= 64; |
333 | 333 | ||
334 | /** | 334 | /** |
335 | * Get h mod n | 335 | * Get h mod L |
336 | */ | 336 | */ |
337 | derive_h (&pub, sizeof (pub), label, context, &hc); | 337 | derive_h (&pub, sizeof (pub), label, context, &hc); |
338 | GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc)); | 338 | GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc)); |
339 | h_mod_n = gcry_mpi_new (256); | 339 | h_mod_L = gcry_mpi_new (256); |
340 | gcry_mpi_mod (h_mod_n, h, n); | 340 | gcry_mpi_mod (h_mod_L, h, L); |
341 | /* Convert scalar to big endian for libgcrypt */ | 341 | /* Convert scalar to big endian for libgcrypt */ |
342 | for (size_t i = 0; i < 32; i++) | 342 | for (size_t i = 0; i < 32; i++) |
343 | dc[i] = sk[31 - i]; | 343 | dc[i] = sk[31 - i]; |
344 | 344 | ||
345 | /** | 345 | /** |
346 | * dc now contains the private scalar "a". | 346 | * dc now contains the private scalar "a". |
347 | * We carefully remove the clamping and derive a'. | 347 | * We calculate: |
348 | * Calculate: | 348 | * d' := h * a mod L |
349 | * a1 := a / 8 | ||
350 | * a2 := h * a1 mod n | ||
351 | * a' := a2 * 8 mod n | ||
352 | */ | 349 | */ |
353 | GNUNET_CRYPTO_mpi_scan_unsigned (&x, dc, sizeof(dc)); // a | 350 | GNUNET_CRYPTO_mpi_scan_unsigned (&a, dc, sizeof(dc)); // a |
354 | a1 = gcry_mpi_new (256); | ||
355 | gcry_mpi_t eight = gcry_mpi_set_ui (NULL, 8); | ||
356 | gcry_mpi_div (a1, NULL, x, eight, 0); // a1 := a / 8 | ||
357 | a2 = gcry_mpi_new (256); | ||
358 | gcry_mpi_mulm (a2, h_mod_n, a1, n); // a2 := h * a1 mod n | ||
359 | d = gcry_mpi_new (256); | 351 | d = gcry_mpi_new (256); |
360 | gcry_mpi_mul (d, a2, eight); // a' := a2 * 8 | 352 | gcry_mpi_mulm (d, h_mod_L, a, L); // d := h * a mod L |
361 | gcry_mpi_release (h); | 353 | gcry_mpi_release (h); |
362 | gcry_mpi_release (x); | 354 | gcry_mpi_release (a); |
363 | gcry_mpi_release (n); | 355 | gcry_mpi_release (L); |
364 | gcry_mpi_release (h_mod_n); | 356 | gcry_mpi_release (h_mod_L); |
365 | gcry_mpi_release (a1); | ||
366 | gcry_mpi_release (eight); | ||
367 | gcry_mpi_release (a2); | ||
368 | gcry_ctx_release (ctx); | 357 | gcry_ctx_release (ctx); |
369 | GNUNET_CRYPTO_mpi_print_unsigned (dc, sizeof(dc), d); | 358 | GNUNET_CRYPTO_mpi_print_unsigned (dc, sizeof(dc), d); |
370 | /** | 359 | /** |
@@ -378,7 +367,7 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
378 | crypto_hash_sha256_update (&hs, sk + 32, 32); | 367 | crypto_hash_sha256_update (&hs, sk + 32, 32); |
379 | crypto_hash_sha256_update (&hs, (unsigned char*) &hc, sizeof (hc)); | 368 | crypto_hash_sha256_update (&hs, (unsigned char*) &hc, sizeof (hc)); |
380 | crypto_hash_sha256_final (&hs, result->s + 32); | 369 | crypto_hash_sha256_final (&hs, result->s + 32); |
381 | //memcpy (result->s, sk, sizeof (sk)); | 370 | // memcpy (result->s, sk, sizeof (sk)); |
382 | /* Convert to little endian for libsodium */ | 371 | /* Convert to little endian for libsodium */ |
383 | for (size_t i = 0; i < 32; i++) | 372 | for (size_t i = 0; i < 32; i++) |
384 | result->s[i] = dc[31 - i]; | 373 | result->s[i] = dc[31 - i]; |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 95c5c3480..4f3acde77 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -73,7 +73,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, | |||
73 | size_t enclen, | 73 | size_t enclen, |
74 | struct GNUNET_HashCode *result) | 74 | struct GNUNET_HashCode *result) |
75 | { | 75 | { |
76 | char upper_enc[enclen+1]; | 76 | char upper_enc[enclen + 1]; |
77 | char *up_ptr = upper_enc; | 77 | char *up_ptr = upper_enc; |
78 | 78 | ||
79 | if (GNUNET_OK != GNUNET_STRINGS_utf8_toupper (enc, up_ptr)) | 79 | if (GNUNET_OK != GNUNET_STRINGS_utf8_toupper (enc, up_ptr)) |
@@ -142,6 +142,7 @@ GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, | |||
142 | 142 | ||
143 | GNUNET_static_assert (8 == sizeof (unsigned long long)); | 143 | GNUNET_static_assert (8 == sizeof (unsigned long long)); |
144 | GNUNET_static_assert (0 == sizeof (*a) % sizeof (unsigned long long)); | 144 | GNUNET_static_assert (0 == sizeof (*a) % sizeof (unsigned long long)); |
145 | |||
145 | for (int i = sizeof (*result) / sizeof (*llr) - 1; i>=0; i--) | 146 | for (int i = sizeof (*result) / sizeof (*llr) - 1; i>=0; i--) |
146 | llr[i] = lla[i] ^ llb[i]; | 147 | llr[i] = lla[i] ^ llb[i]; |
147 | } | 148 | } |
@@ -156,18 +157,18 @@ GNUNET_CRYPTO_hash_to_aes_key ( | |||
156 | GNUNET_assert (GNUNET_YES == | 157 | GNUNET_assert (GNUNET_YES == |
157 | GNUNET_CRYPTO_kdf ( | 158 | GNUNET_CRYPTO_kdf ( |
158 | skey, | 159 | skey, |
159 | sizeof(struct GNUNET_CRYPTO_SymmetricSessionKey), | 160 | sizeof(*skey), |
160 | "Hash key derivation", | 161 | "Hash key derivation", |
161 | strlen ("Hash key derivation"), | 162 | strlen ("Hash key derivation"), |
162 | hc, sizeof(struct GNUNET_HashCode), | 163 | hc, sizeof(*hc), |
163 | NULL, 0)); | 164 | NULL, 0)); |
164 | GNUNET_assert (GNUNET_YES == | 165 | GNUNET_assert (GNUNET_YES == |
165 | GNUNET_CRYPTO_kdf ( | 166 | GNUNET_CRYPTO_kdf ( |
166 | iv, | 167 | iv, |
167 | sizeof(struct GNUNET_CRYPTO_SymmetricInitializationVector), | 168 | sizeof(*iv), |
168 | "Initialization vector derivation", | 169 | "Initialization vector derivation", |
169 | strlen ("Initialization vector derivation"), | 170 | strlen ("Initialization vector derivation"), |
170 | hc, sizeof(struct GNUNET_HashCode), | 171 | hc, sizeof(*hc), |
171 | NULL, 0)); | 172 | NULL, 0)); |
172 | } | 173 | } |
173 | 174 | ||
diff --git a/src/util/gnunet_error_codes.c b/src/util/gnunet_error_codes.c new file mode 100644 index 000000000..11ce2d0c8 --- /dev/null +++ b/src/util/gnunet_error_codes.c | |||
@@ -0,0 +1,262 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #include "gnunet_error_codes.h" | ||
21 | #include <stddef.h> | ||
22 | #include <microhttpd.h> | ||
23 | #include <gettext.h> | ||
24 | |||
25 | /** | ||
26 | * MHD does not define our value for 0 (client-side generated code). | ||
27 | */ | ||
28 | #define MHD_HTTP_UNINITIALIZED 0 | ||
29 | |||
30 | /** | ||
31 | * A pair containing an error code and its hint. | ||
32 | */ | ||
33 | struct ErrorCodeAndHint | ||
34 | { | ||
35 | /** | ||
36 | * The error code. | ||
37 | */ | ||
38 | enum GNUNET_ErrorCode ec; | ||
39 | |||
40 | /** | ||
41 | * The hint. | ||
42 | */ | ||
43 | const char *hint; | ||
44 | |||
45 | /** | ||
46 | * The HTTP status code. | ||
47 | */ | ||
48 | unsigned int http_code; | ||
49 | }; | ||
50 | |||
51 | |||
52 | /** | ||
53 | * The list of all error codes with their hints. | ||
54 | */ | ||
55 | static const struct ErrorCodeAndHint code_hint_pairs[] = { | ||
56 | |||
57 | { | ||
58 | .ec = GNUNET_EC_NONE, | ||
59 | .hint = gettext_noop ("No error (success)."), | ||
60 | .http_code = MHD_HTTP_UNINITIALIZED | ||
61 | }, | ||
62 | |||
63 | { | ||
64 | .ec = GNUNET_EC_UNKNOWN, | ||
65 | .hint = gettext_noop ("Unknown and unspecified error."), | ||
66 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
67 | }, | ||
68 | |||
69 | { | ||
70 | .ec = GNUNET_EC_SERVICE_COMMUNICATION_FAILED, | ||
71 | .hint = gettext_noop ("Communication with service failed."), | ||
72 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
73 | }, | ||
74 | |||
75 | { | ||
76 | .ec = GNUNET_EC_IDENTITY_NOT_FOUND, | ||
77 | .hint = gettext_noop ("Ego not found."), | ||
78 | .http_code = MHD_HTTP_NOT_FOUND | ||
79 | }, | ||
80 | |||
81 | { | ||
82 | .ec = GNUNET_EC_IDENTITY_NAME_CONFLICT, | ||
83 | .hint = gettext_noop ("Identifier already in use for another ego."), | ||
84 | .http_code = MHD_HTTP_CONFLICT | ||
85 | }, | ||
86 | |||
87 | { | ||
88 | .ec = GNUNET_EC_IDENTITY_INVALID, | ||
89 | .hint = gettext_noop ("The given ego is invalid or malformed."), | ||
90 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
91 | }, | ||
92 | |||
93 | { | ||
94 | .ec = GNUNET_EC_NAMESTORE_UNKNOWN, | ||
95 | .hint = gettext_noop ("Unknown namestore error."), | ||
96 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
97 | }, | ||
98 | |||
99 | { | ||
100 | .ec = GNUNET_EC_NAMESTORE_ITERATION_FAILED, | ||
101 | .hint = gettext_noop ("Zone iteration failed."), | ||
102 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
103 | }, | ||
104 | |||
105 | { | ||
106 | .ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND, | ||
107 | .hint = gettext_noop ("Zone not found."), | ||
108 | .http_code = MHD_HTTP_NOT_FOUND | ||
109 | }, | ||
110 | |||
111 | { | ||
112 | .ec = GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND, | ||
113 | .hint = gettext_noop ("Record not found."), | ||
114 | .http_code = MHD_HTTP_NOT_FOUND | ||
115 | }, | ||
116 | |||
117 | { | ||
118 | .ec = GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED, | ||
119 | .hint = gettext_noop ("Zone iteration failed."), | ||
120 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
121 | }, | ||
122 | |||
123 | { | ||
124 | .ec = GNUNET_EC_NAMESTORE_ZONE_EMPTY, | ||
125 | .hint = gettext_noop ("Zone does not contain any records."), | ||
126 | .http_code = MHD_HTTP_NOT_FOUND | ||
127 | }, | ||
128 | |||
129 | { | ||
130 | .ec = GNUNET_EC_NAMESTORE_LOOKUP_ERROR, | ||
131 | .hint = gettext_noop ("Failed to lookup record."), | ||
132 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
133 | }, | ||
134 | |||
135 | { | ||
136 | .ec = GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN, | ||
137 | .hint = gettext_noop ("No records given."), | ||
138 | .http_code = MHD_HTTP_BAD_REQUEST | ||
139 | }, | ||
140 | |||
141 | { | ||
142 | .ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID, | ||
143 | .hint = gettext_noop ("Record data invalid."), | ||
144 | .http_code = MHD_HTTP_BAD_REQUEST | ||
145 | }, | ||
146 | |||
147 | { | ||
148 | .ec = GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN, | ||
149 | .hint = gettext_noop ("No label given."), | ||
150 | .http_code = MHD_HTTP_BAD_REQUEST | ||
151 | }, | ||
152 | |||
153 | { | ||
154 | .ec = GNUNET_EC_NAMESTORE_NO_RESULTS, | ||
155 | .hint = gettext_noop ("No results given."), | ||
156 | .http_code = MHD_HTTP_NOT_FOUND | ||
157 | }, | ||
158 | |||
159 | { | ||
160 | .ec = GNUNET_EC_NAMESTORE_RECORD_EXISTS, | ||
161 | .hint = gettext_noop ("Record already exists."), | ||
162 | .http_code = MHD_HTTP_CONFLICT | ||
163 | }, | ||
164 | |||
165 | { | ||
166 | .ec = GNUNET_EC_NAMESTORE_RECORD_TOO_BIG, | ||
167 | .hint = gettext_noop ("Record size exceeds maximum limit."), | ||
168 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
169 | }, | ||
170 | |||
171 | { | ||
172 | .ec = GNUNET_EC_NAMESTORE_BACKEND_FAILED, | ||
173 | .hint = gettext_noop ("There was an error in the database backend."), | ||
174 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
175 | }, | ||
176 | |||
177 | { | ||
178 | .ec = GNUNET_EC_NAMESTORE_STORE_FAILED, | ||
179 | .hint = gettext_noop ("Failed to store the given records."), | ||
180 | .http_code = MHD_HTTP_INTERNAL_SERVER_ERROR | ||
181 | }, | ||
182 | |||
183 | { | ||
184 | .ec = GNUNET_EC_NAMESTORE_LABEL_INVALID, | ||
185 | .hint = gettext_noop ("Label invalid or malformed."), | ||
186 | .http_code = MHD_HTTP_BAD_REQUEST | ||
187 | }, | ||
188 | |||
189 | |||
190 | }; | ||
191 | |||
192 | |||
193 | /** | ||
194 | * The length of @e code_hint_pairs. | ||
195 | */ | ||
196 | static const unsigned int code_hint_pairs_length = 22; | ||
197 | |||
198 | |||
199 | |||
200 | const char * | ||
201 | GNUNET_ErrorCode_get_hint (enum GNUNET_ErrorCode ec) | ||
202 | { | ||
203 | unsigned int lower = 0; | ||
204 | unsigned int upper = code_hint_pairs_length - 1; | ||
205 | unsigned int mid = upper / 2; | ||
206 | while (lower <= upper) | ||
207 | { | ||
208 | mid = (upper + lower) / 2; | ||
209 | if (code_hint_pairs[mid].ec < ec) | ||
210 | { | ||
211 | lower = mid + 1; | ||
212 | } | ||
213 | else if (code_hint_pairs[mid].ec > ec) | ||
214 | { | ||
215 | upper = mid - 1; | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | return code_hint_pairs[mid].hint; | ||
220 | } | ||
221 | } | ||
222 | return "<no hint found>"; | ||
223 | } | ||
224 | |||
225 | |||
226 | unsigned int | ||
227 | GNUNET_ErrorCode_get_http_status (enum GNUNET_ErrorCode ec) | ||
228 | { | ||
229 | unsigned int lower = 0; | ||
230 | unsigned int upper = code_hint_pairs_length - 1; | ||
231 | unsigned int mid = upper / 2; | ||
232 | while (lower <= upper) | ||
233 | { | ||
234 | mid = (upper + lower) / 2; | ||
235 | if (code_hint_pairs[mid].ec < ec) | ||
236 | { | ||
237 | lower = mid + 1; | ||
238 | } | ||
239 | else if (code_hint_pairs[mid].ec > ec) | ||
240 | { | ||
241 | upper = mid - 1; | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | return code_hint_pairs[mid].http_code; | ||
246 | } | ||
247 | } | ||
248 | return UINT_MAX; | ||
249 | } | ||
250 | |||
251 | |||
252 | unsigned int | ||
253 | GNUNET_ErrorCode_get_http_status_safe (enum GNUNET_ErrorCode ec) | ||
254 | { | ||
255 | unsigned int hc; | ||
256 | |||
257 | hc = GNUNET_ErrorCode_get_http_status (ec); | ||
258 | if ( (0 == hc) || | ||
259 | (UINT_MAX == hc) ) | ||
260 | return MHD_HTTP_INTERNAL_SERVER_ERROR; | ||
261 | return hc; | ||
262 | } | ||
diff --git a/src/util/helper.c b/src/util/helper.c index fe8643d31..d7fbb5ead 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -26,6 +26,7 @@ | |||
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "gnunet_common.h" | ||
29 | #include "platform.h" | 30 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
@@ -163,7 +164,7 @@ struct GNUNET_HELPER_Handle | |||
163 | }; | 164 | }; |
164 | 165 | ||
165 | 166 | ||
166 | int | 167 | enum GNUNET_GenericReturnValue |
167 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill) | 168 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill) |
168 | { | 169 | { |
169 | struct GNUNET_HELPER_SendHandle *sh; | 170 | struct GNUNET_HELPER_SendHandle *sh; |
@@ -203,7 +204,7 @@ GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill) | |||
203 | } | 204 | } |
204 | 205 | ||
205 | 206 | ||
206 | int | 207 | enum GNUNET_GenericReturnValue |
207 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h) | 208 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h) |
208 | { | 209 | { |
209 | struct GNUNET_HELPER_SendHandle *sh; | 210 | struct GNUNET_HELPER_SendHandle *sh; |
diff --git a/src/util/meson.build b/src/util/meson.build new file mode 100644 index 000000000..b5d156ea6 --- /dev/null +++ b/src/util/meson.build | |||
@@ -0,0 +1,231 @@ | |||
1 | libgnunetutil_src = ['bandwidth.c', | ||
2 | # $(BENCHMARK)', | ||
3 | 'bio.c', | ||
4 | 'buffer.c', | ||
5 | 'child_management.c', | ||
6 | 'client.c', | ||
7 | 'common_allocation.c', | ||
8 | 'common_endian.c', | ||
9 | 'common_logging.c', | ||
10 | 'compress.c', | ||
11 | 'configuration.c', | ||
12 | 'configuration_helper.c', | ||
13 | 'consttime_memcmp.c', | ||
14 | 'container_bloomfilter.c', | ||
15 | 'container_heap.c', | ||
16 | 'container_multihashmap.c', | ||
17 | 'container_multishortmap.c', | ||
18 | 'container_multiuuidmap.c', | ||
19 | 'container_multipeermap.c', | ||
20 | 'container_multihashmap32.c', | ||
21 | 'crypto_symmetric.c', | ||
22 | 'crypto_crc.c', | ||
23 | 'crypto_cs.c', | ||
24 | 'crypto_ecc.c', | ||
25 | 'crypto_ecc_gnsrecord.c', | ||
26 | 'crypto_ecc_dlog.c', | ||
27 | 'crypto_ecc_setup.c', | ||
28 | 'crypto_edx25519.c', | ||
29 | 'crypto_hash.c', | ||
30 | 'crypto_hash_file.c', | ||
31 | 'crypto_hkdf.c', | ||
32 | 'crypto_kdf.c', | ||
33 | 'crypto_mpi.c', | ||
34 | 'crypto_paillier.c', | ||
35 | 'crypto_pow.c', | ||
36 | 'crypto_random.c', | ||
37 | 'crypto_rsa.c', | ||
38 | 'disk.c', | ||
39 | 'disk.h', | ||
40 | 'dnsparser.c', | ||
41 | 'dnsstub.c', | ||
42 | 'getopt.c', | ||
43 | 'getopt_helpers.c', | ||
44 | 'helper.c', | ||
45 | 'load.c', | ||
46 | 'mst.c', | ||
47 | 'mq.c', | ||
48 | 'nc.c', | ||
49 | 'network.c', | ||
50 | 'op.c', | ||
51 | 'os_installation.c', | ||
52 | 'os_network.c', | ||
53 | 'os_priority.c', | ||
54 | 'peer.c', | ||
55 | 'plugin.c', | ||
56 | 'program.c', | ||
57 | 'regex.c', | ||
58 | 'resolver_api.c', | ||
59 | 'resolver.h', | ||
60 | 'scheduler.c', | ||
61 | 'service.c', | ||
62 | 'signal.c', | ||
63 | 'strings.c', | ||
64 | 'time.c', | ||
65 | 'tun.c', | ||
66 | 'uri.c', | ||
67 | 'speedup.c', | ||
68 | 'speedup.h', | ||
69 | 'proc_compat.c', | ||
70 | 'gnunet_error_codes.c'] | ||
71 | |||
72 | gnunetserviceresolver_src = ['gnunet-service-resolver.c'] | ||
73 | |||
74 | configure_file(input : 'util.conf', | ||
75 | output : 'util.conf', | ||
76 | configuration : cdata, | ||
77 | install: true, | ||
78 | install_dir: pkgcfgdir) | ||
79 | configure_file(input : 'resolver.conf.in', | ||
80 | output : 'resolver.conf', | ||
81 | configuration : cdata, | ||
82 | install: true, | ||
83 | install_dir: pkgcfgdir) | ||
84 | |||
85 | |||
86 | if get_option('monolith') | ||
87 | foreach p : [libgnunetutil_src, gnunetserviceresolver_src] | ||
88 | gnunet_src += 'util/' + p | ||
89 | endforeach | ||
90 | subdir_done() | ||
91 | endif | ||
92 | |||
93 | libgnunetutil = library('gnunetutil', | ||
94 | libgnunetutil_src, | ||
95 | soversion: '15', | ||
96 | version: '15.0.0', | ||
97 | dependencies: gnunetdeps, | ||
98 | include_directories: [incdir, configuration_inc], | ||
99 | install: true, | ||
100 | install_dir: get_option('libdir')) | ||
101 | libgnunetutil_dep = declare_dependency(link_with : libgnunetutil) | ||
102 | pkg.generate(libgnunetutil, url: 'https://www.gnunet.org', | ||
103 | description : 'Provides miscellaneous utility functions and API for GNUnet') | ||
104 | |||
105 | shared_module('gnunet_plugin_utiltest', | ||
106 | ['test_plugin_plug.c'], | ||
107 | dependencies: [libgnunetutil_dep], | ||
108 | include_directories: [incdir, configuration_inc], | ||
109 | install: true, | ||
110 | install_dir: get_option('libdir')/'gnunet') | ||
111 | |||
112 | executable ('gnunet-base32', | ||
113 | ['gnunet-base32.c'], | ||
114 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
115 | include_directories: [incdir, configuration_inc], | ||
116 | install: true, | ||
117 | install_dir: get_option('bindir')) | ||
118 | executable ('gnunet-config', | ||
119 | ['gnunet-config.c'], | ||
120 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
121 | include_directories: [incdir, configuration_inc], | ||
122 | install: true, | ||
123 | install_dir: get_option('bindir')) | ||
124 | executable ('gnunet-resolver', | ||
125 | ['gnunet-resolver.c'], | ||
126 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
127 | include_directories: [incdir, configuration_inc], | ||
128 | install: true, | ||
129 | install_dir: get_option('bindir')) | ||
130 | executable ('gnunet-ecc', | ||
131 | ['gnunet-ecc.c'], | ||
132 | dependencies: [libgnunetutil_dep, libgnunetutil_dep, gcrypt_dep, m_dep], | ||
133 | include_directories: [incdir, configuration_inc], | ||
134 | install: true, | ||
135 | install_dir: get_option('bindir')) | ||
136 | executable ('gnunet-scrypt', | ||
137 | ['gnunet-scrypt.c'], | ||
138 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
139 | include_directories: [incdir, configuration_inc], | ||
140 | install: true, | ||
141 | install_dir: get_option('bindir')) | ||
142 | executable ('gnunet-uri', | ||
143 | ['gnunet-uri.c'], | ||
144 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
145 | include_directories: [incdir, configuration_inc], | ||
146 | install: true, | ||
147 | install_dir: get_option('bindir')) | ||
148 | if zbar_dep.found() | ||
149 | executable ('gnunet-qr', | ||
150 | ['gnunet-qr.c'], | ||
151 | dependencies: [zbar_dep, libgnunetutil_dep, libgnunetutil_dep], | ||
152 | include_directories: [incdir, configuration_inc], | ||
153 | install: true, | ||
154 | install_dir: get_option('bindir')) | ||
155 | endif | ||
156 | executable ('gnunet-config-diff', | ||
157 | ['gnunet-config-diff.c'], | ||
158 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
159 | include_directories: [incdir, configuration_inc], | ||
160 | install: false) | ||
161 | |||
162 | executable ('gnunet-service-resolver', | ||
163 | gnunetserviceresolver_src, | ||
164 | dependencies: [libgnunetutil_dep], | ||
165 | include_directories: [incdir, configuration_inc], | ||
166 | install: true, | ||
167 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
168 | executable ('gnunet-timeout', | ||
169 | ['gnunet-timeout.c'], | ||
170 | dependencies: [libgnunetutil_dep], | ||
171 | include_directories: [incdir, configuration_inc], | ||
172 | install: true, | ||
173 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
174 | |||
175 | |||
176 | executable ('test_common_logging_dummy', | ||
177 | ['test_common_logging_dummy.c'], | ||
178 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
179 | include_directories: [incdir, configuration_inc], | ||
180 | install: false) | ||
181 | executable ('gnunet-crypto-tvg', | ||
182 | ['gnunet-crypto-tvg.c'], | ||
183 | dependencies: [libgnunetutil_dep, libgnunetutil_dep, json_dep], | ||
184 | include_directories: [incdir, configuration_inc], | ||
185 | install: false) | ||
186 | |||
187 | testcommonalloc = executable ('test_common_allocation', | ||
188 | ['test_common_allocation.c'], | ||
189 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
190 | build_by_default: false, | ||
191 | include_directories: [incdir, configuration_inc], | ||
192 | install: false) | ||
193 | test('test_common_allocation', testcommonalloc, | ||
194 | workdir: meson.current_source_dir(), | ||
195 | suite: ['util', 'util-common']) | ||
196 | testcommonlog = executable ('test_common_logging', | ||
197 | ['test_common_logging.c'], | ||
198 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
199 | build_by_default: false, | ||
200 | include_directories: [incdir, configuration_inc], | ||
201 | install: false) | ||
202 | test('test_common_logging', testcommonlog, | ||
203 | workdir: meson.current_source_dir(), | ||
204 | suite: ['util', 'util-common']) | ||
205 | testcommonendian = executable ('test_common_endian', | ||
206 | ['test_common_endian.c'], | ||
207 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
208 | build_by_default: false, | ||
209 | include_directories: [incdir, configuration_inc], | ||
210 | install: false) | ||
211 | test('test_common_endian', testcommonendian, | ||
212 | workdir: meson.current_source_dir(), | ||
213 | suite: ['util', 'util-common']) | ||
214 | testconf = executable ('test_configuration', | ||
215 | ['test_configuration.c'], | ||
216 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
217 | build_by_default: false, | ||
218 | include_directories: [incdir, configuration_inc], | ||
219 | install: false) | ||
220 | test('test_configuration', testconf, | ||
221 | workdir: meson.current_source_dir(), | ||
222 | suite: ['util', 'util-configuration']) | ||
223 | testcontainerbloom = executable ('test_container_bloomfilter', | ||
224 | ['test_container_bloomfilter.c'], | ||
225 | dependencies: [libgnunetutil_dep, libgnunetutil_dep], | ||
226 | include_directories: [incdir, configuration_inc], | ||
227 | build_by_default: false, | ||
228 | install: false) | ||
229 | test('test_container_bloomfilter', testcontainerbloom, | ||
230 | workdir: meson.current_source_dir(), | ||
231 | suite: ['util', 'util-container']) | ||
diff --git a/src/util/network.c b/src/util/network.c index ac3de89bf..34f34eec6 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -25,6 +25,7 @@ | |||
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "gnunet_common.h" | ||
28 | #include "platform.h" | 29 | #include "platform.h" |
29 | #include "disk.h" | 30 | #include "disk.h" |
30 | 31 | ||
@@ -597,7 +598,7 @@ GNUNET_NETWORK_socket_box_native (int fd) | |||
597 | * @param address_len length of @a address | 598 | * @param address_len length of @a address |
598 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 599 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
599 | */ | 600 | */ |
600 | int | 601 | enum GNUNET_GenericReturnValue |
601 | GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, | 602 | GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, |
602 | const struct sockaddr *address, | 603 | const struct sockaddr *address, |
603 | socklen_t address_len) | 604 | socklen_t address_len) |
@@ -622,7 +623,7 @@ GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, | |||
622 | * @param optlen length of @a optval | 623 | * @param optlen length of @a optval |
623 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 624 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
624 | */ | 625 | */ |
625 | int | 626 | enum GNUNET_GenericReturnValue |
626 | GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, | 627 | GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, |
627 | int level, | 628 | int level, |
628 | int optname, | 629 | int optname, |
@@ -647,7 +648,7 @@ GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, | |||
647 | * @param backlog length of the listen queue | 648 | * @param backlog length of the listen queue |
648 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 649 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
649 | */ | 650 | */ |
650 | int | 651 | enum GNUNET_GenericReturnValue |
651 | GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, | 652 | GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, |
652 | int backlog) | 653 | int backlog) |
653 | { | 654 | { |
@@ -856,7 +857,7 @@ GNUNET_NETWORK_socket_create (int domain, | |||
856 | * @param how type of shutdown | 857 | * @param how type of shutdown |
857 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 858 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
858 | */ | 859 | */ |
859 | int | 860 | enum GNUNET_GenericReturnValue |
860 | GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, | 861 | GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, |
861 | int how) | 862 | int how) |
862 | { | 863 | { |
@@ -877,7 +878,7 @@ GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, | |||
877 | * @param desc socket | 878 | * @param desc socket |
878 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 879 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
879 | */ | 880 | */ |
880 | int | 881 | enum GNUNET_GenericReturnValue |
881 | GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc) | 882 | GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc) |
882 | { | 883 | { |
883 | int ret = 0; | 884 | int ret = 0; |
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index e82ff94b6..de4e6c395 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -877,7 +877,8 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc) | |||
877 | ; | 877 | ; |
878 | if (pid != ret) | 878 | if (pid != ret) |
879 | { | 879 | { |
880 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 880 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, |
881 | "waitpid"); | ||
881 | return GNUNET_SYSERR; | 882 | return GNUNET_SYSERR; |
882 | } | 883 | } |
883 | return GNUNET_OK; | 884 | return GNUNET_OK; |
diff --git a/src/util/strings.c b/src/util/strings.c index 479c0fcd6..86323bc83 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -1859,11 +1859,18 @@ GNUNET_STRINGS_urlencode (const char *data, | |||
1859 | if (0 == (0x80 & *i8)) | 1859 | if (0 == (0x80 & *i8)) |
1860 | { | 1860 | { |
1861 | /* traditional ASCII */ | 1861 | /* traditional ASCII */ |
1862 | if (isalnum (*i8) || (*i8 == '-') || (*i8 == '_') || (*i8 == '.') || | 1862 | if ( isalnum (*i8) || |
1863 | (*i8 == '~') ) | 1863 | (*i8 == '-') || |
1864 | GNUNET_buffer_write (&buf, (const char*) i8, 1); | 1864 | (*i8 == '_') || |
1865 | (*i8 == '.') || | ||
1866 | (*i8 == '~') ) | ||
1867 | GNUNET_buffer_write (&buf, | ||
1868 | (const char*) i8, | ||
1869 | 1); | ||
1865 | else if (*i8 == ' ') | 1870 | else if (*i8 == ' ') |
1866 | GNUNET_buffer_write (&buf, "+", 1); | 1871 | GNUNET_buffer_write (&buf, |
1872 | "+", | ||
1873 | 1); | ||
1867 | else | 1874 | else |
1868 | GNUNET_buffer_write_fstr (&buf, | 1875 | GNUNET_buffer_write_fstr (&buf, |
1869 | "%%%X%X", | 1876 | "%%%X%X", |
@@ -1952,4 +1959,36 @@ GNUNET_STRINGS_urlencode (const char *data, | |||
1952 | } | 1959 | } |
1953 | 1960 | ||
1954 | 1961 | ||
1962 | /** | ||
1963 | * Sometimes we use the binary name to determine which specific | ||
1964 | * test to run. In those cases, the string after the last "_" | ||
1965 | * in 'argv[0]' specifies a string that determines the configuration | ||
1966 | * file or plugin to use. | ||
1967 | * | ||
1968 | * This function returns the respective substring, taking care | ||
1969 | * of issues such as binaries ending in '.exe' on W32. | ||
1970 | * | ||
1971 | * @param argv0 the name of the binary | ||
1972 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
1973 | * NULL if argv0 has no '_' | ||
1974 | */ | ||
1975 | char * | ||
1976 | GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0) | ||
1977 | { | ||
1978 | const char *ret; | ||
1979 | const char *dot; | ||
1980 | |||
1981 | ret = strrchr (argv0, '_'); | ||
1982 | if (NULL == ret) | ||
1983 | return NULL; | ||
1984 | ret++; /* skip underscore */ | ||
1985 | dot = strchr (ret, | ||
1986 | '.'); | ||
1987 | if (NULL != dot) | ||
1988 | return GNUNET_strndup (ret, | ||
1989 | dot - ret); | ||
1990 | return GNUNET_strdup (ret); | ||
1991 | } | ||
1992 | |||
1993 | |||
1955 | /* end of strings.c */ | 1994 | /* end of strings.c */ |
diff --git a/src/vpn/meson.build b/src/vpn/meson.build new file mode 100644 index 000000000..e77b88432 --- /dev/null +++ b/src/vpn/meson.build | |||
@@ -0,0 +1,66 @@ | |||
1 | libgnunetvpn_src = ['vpn_api.c'] | ||
2 | |||
3 | gnunetservicevpn_src = ['gnunet-service-vpn.c'] | ||
4 | |||
5 | exitdir = include_directories('../exit') | ||
6 | |||
7 | configure_file(input : 'vpn.conf.in', | ||
8 | output : 'vpn.conf', | ||
9 | configuration : cdata, | ||
10 | install: true, | ||
11 | install_dir: pkgcfgdir) | ||
12 | |||
13 | |||
14 | if get_option('monolith') | ||
15 | foreach p : libgnunetvpn_src + gnunetservicevpn_src | ||
16 | gnunet_src += 'vpn/' + p | ||
17 | endforeach | ||
18 | subdir_done() | ||
19 | endif | ||
20 | |||
21 | libgnunetvpn = library('gnunetvpn', | ||
22 | libgnunetvpn_src, | ||
23 | soversion: '0', | ||
24 | version: '0.0.0', | ||
25 | dependencies: libgnunetutil_dep, | ||
26 | include_directories: [incdir, configuration_inc], | ||
27 | install: true, | ||
28 | install_dir: get_option('libdir')) | ||
29 | pkg.generate(libgnunetvpn, url: 'https://www.gnunet.org', | ||
30 | description : 'Provides API for accessing the VPN service') | ||
31 | libgnunetvpn_dep = declare_dependency(link_with : libgnunetvpn) | ||
32 | |||
33 | executable ('gnunet-vpn', | ||
34 | ['gnunet-vpn.c'], | ||
35 | dependencies: [libgnunetvpn_dep, | ||
36 | libgnunetutil_dep, | ||
37 | libgnunetstatistics_dep, | ||
38 | libgnunetregex_dep, | ||
39 | libgnunetcore_dep, | ||
40 | libgnunetcadet_dep, | ||
41 | libgnunetblock_dep], | ||
42 | include_directories: [incdir, configuration_inc, exitdir], | ||
43 | install: true, | ||
44 | install_dir: get_option('bindir')) | ||
45 | |||
46 | executable ('gnunet-service-vpn', | ||
47 | gnunetservicevpn_src, | ||
48 | dependencies: [libgnunetvpn_dep, | ||
49 | libgnunetutil_dep, | ||
50 | libgnunetstatistics_dep, | ||
51 | libgnunetregex_dep, | ||
52 | libgnunetcore_dep, | ||
53 | libgnunetcadet_dep, | ||
54 | libgnunetblock_dep], | ||
55 | include_directories: [incdir, configuration_inc, exitdir], | ||
56 | install: true, | ||
57 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
58 | if host_machine.system() == 'linux' | ||
59 | executable ('gnunet-helper-vpn', | ||
60 | ['gnunet-helper-vpn.c'], | ||
61 | dependencies: [libgnunetvpn_dep, | ||
62 | libgnunetutil_dep], | ||
63 | include_directories: [incdir, configuration_inc, exitdir], | ||
64 | install: true, | ||
65 | install_dir: get_option('libdir') / 'gnunet' / 'libexec') | ||
66 | endif | ||
diff --git a/src/zonemaster/meson.build b/src/zonemaster/meson.build new file mode 100644 index 000000000..44c67edf2 --- /dev/null +++ b/src/zonemaster/meson.build | |||
@@ -0,0 +1,30 @@ | |||
1 | gnunetservicezonemaster_src = ['gnunet-service-zonemaster.c'] | ||
2 | |||
3 | configure_file(input : 'zonemaster.conf.in', | ||
4 | output : 'zonemaster.conf', | ||
5 | configuration : cdata, | ||
6 | install: true, | ||
7 | install_dir: pkgcfgdir) | ||
8 | |||
9 | |||
10 | if get_option('monolith') | ||
11 | foreach p : gnunetservicezonemaster_src | ||
12 | gnunet_src += 'zonemaster/' + p | ||
13 | endforeach | ||
14 | subdir_done() | ||
15 | endif | ||
16 | |||
17 | executable ('gnunet-service-zonemaster', | ||
18 | gnunetservicezonemaster_src, | ||
19 | dependencies: [ | ||
20 | libgnunetutil_dep, | ||
21 | libgnunetdht_dep, | ||
22 | libgnunetidentity_dep, | ||
23 | libgnunetstatistics_dep, | ||
24 | libgnunetnamecache_dep, | ||
25 | libgnunetnamestore_dep, | ||
26 | libgnunetgnsrecord_dep], | ||
27 | include_directories: [incdir, configuration_inc], | ||
28 | install: true, | ||
29 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
30 | |||