gnunet-android

GNUnet for Android
Log | Files | Refs | README

commit 962ca22f9bc05b5f07eb895a679e844f2a62bcbe
parent 6b3360bdbb66f0dd15274a0ac9de0415f5243c42
Author: t3sserakt <t3ss@posteo.de>
Date:   Sun, 11 Aug 2024 16:33:38 +0200

Remove util header files from monolith, and changed GNUNET_SERVICE_main method signature.

Diffstat:
Mandroid_studio/app/src/main/cpp/native-lib.cpp | 14+++++++-------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bandwidth_lib.h | 364-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bio_lib.h | 658-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_buffer_lib.h | 215-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_child_management_lib.h | 81-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_client_lib.h | 113-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_common.h | 1908-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_config.h | 58----------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_configuration_lib.h | 818-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_container_lib.h | 2354-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_crypto_lib.h | 4550-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_disk_lib.h | 830-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsparser_lib.h | 1074-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsstub_lib.h | 159-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_error_codes.h | 242-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_getopt_lib.h | 511-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_helper_lib.h | 196-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mq_lib.h | 1137-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mst_lib.h | 177-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nc_lib.h | 115-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_network_lib.h | 603-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nt_lib.h | 134-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_os_lib.h | 713-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_peer_lib.h | 140-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_plugin_lib.h | 179-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_program_lib.h | 179-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_protocols.h | 3667-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_scheduler_lib.h | 938-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_service_lib.h | 537-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_signal_lib.h | 118-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_sq_lib.h | 571-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_strings_lib.h | 804-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_time_lib.h | 931-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_tun_lib.h | 977-------------------------------------------------------------------------------
Dandroid_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_util_lib.h | 115-------------------------------------------------------------------------------
Mandroid_studio/distribution/libgnunetutil/lib/arm64-v8a/include/gnunet_service_lib.h | 4+++-
36 files changed, 10 insertions(+), 26174 deletions(-)

diff --git a/android_studio/app/src/main/cpp/native-lib.cpp b/android_studio/app/src/main/cpp/native-lib.cpp @@ -3,7 +3,7 @@ #include <android/log.h> #include <android/asset_manager.h> #include <android/asset_manager_jni.h> -#include "gnunet_arm_service.h" +#include "gnunet_util_lib.h" #define TAG "MY_TAG" @@ -121,8 +121,8 @@ static struct GNUNET_ARM_Handle *h; static struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_ARM_Operation *op; - -static void +/* -------------- Multi library code ----------------------------- +/*static void start_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result) @@ -162,7 +162,7 @@ shutdown_task (void *cls) } GNUNET_CONFIGURATION_destroy (cfg); cfg = NULL; -} +}*/ /** @@ -174,7 +174,7 @@ shutdown_task (void *cls) * @param connected #GNUNET_YES if connected, #GNUNET_NO if disconnected, * #GNUNET_SYSERR on error. */ -static void +/*static void conn_status (void *cls, enum GNUNET_GenericReturnValue connected) { @@ -191,7 +191,7 @@ conn_status (void *cls, once = 1; } -/* -------------- Multi library code ----------------------------- + static void run (void *cls, @@ -264,7 +264,7 @@ Java_org_gnu_gnunet_MainActivity_stringFromJNI( GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Simulate error message. We do not no what is the actual log level.\n"); cfg = GNUNET_CONFIGURATION_create (); - AAsset *asset = AAssetManager_open(mgr, "gnunet.conf", AASSET_MODE_BUFFER);Are ther + AAsset *asset = AAssetManager_open(mgr, "gnunet.conf", AASSET_MODE_BUFFER); char buf[AAsset_getLength(asset)]; AAsset_read(asset, buf, AAsset_getLength(asset)); diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bandwidth_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bandwidth_lib.h @@ -1,364 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2010 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to bandwidth (unit) - * - * @defgroup bandwidth Bandwidth library - * Functions related to bandwidth (unit) - * @{ - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_BANDWIDTH_LIB_H -#define GNUNET_BANDWIDTH_LIB_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include "gnunet_time_lib.h" - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. - */ -struct GNUNET_BANDWIDTH_Value32NBO -{ - /** - * The actual value (bytes per second). - */ - uint32_t value__ GNUNET_PACKED; -}; - -GNUNET_NETWORK_STRUCT_END - - -/** - * Callback to be called by the bandwidth tracker if the tracker - * was updated and the client should update it's delay values - * - * @param cls a closure to pass - */ -typedef void (*GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls); - - -/** - * Callback to be called by the bandwidth tracker if the tracker - * was updated and the client should update it's delay values - * - * @param cls a closure to pass - */ -typedef void (*GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls); - - -/** - * Struct to track available bandwidth. Combines a time stamp with a - * number of bytes transmitted, a quota and a maximum amount that - * carries over. Not opaque so that it can be inlined into data - * structures (reducing malloc-ing); however, values should not be - * accessed directly by clients (hence the '__'). - */ -struct GNUNET_BANDWIDTH_Tracker -{ - /** - * Closure for @e update_cb. - */ - void *update_cb_cls; - - /** - * Function we call if the tracker's bandwidth is increased and a - * previously returned timeout might now expire earlier. - */ - GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb; - - /** - * Closure for @e excess_cb. - */ - void *excess_cb_cls; - - /** - * Function we call if the tracker is about to throw - * away bandwidth due to excess (max carry exceeded). - */ - GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb; - - /** - * Number of bytes consumed since we last updated the tracker. - */ - int64_t consumption_since_last_update__; - - /** - * Task scheduled to call the @e excess_cb once we have - * reached the maximum bandwidth the tracker can hold. - */ - struct GNUNET_SCHEDULER_Task *excess_task; - - /** - * Time when we last updated the tracker. - */ - struct GNUNET_TIME_Absolute last_update__; - - /** - * Bandwidth limit to enforce in bytes per second. - */ - uint32_t available_bytes_per_s__; - - /** - * Maximum number of seconds over which bandwidth may "accumulate". - * Note that additionally, we also always allow at least - * #GNUNET_MAX_MESSAGE_SIZE to accumulate. - */ - uint32_t max_carry_s__; -}; - - -/** - * Convenience definition to use for 0-bandwidth. - */ -#define GNUNET_BANDWIDTH_ZERO GNUNET_BANDWIDTH_value_init (0) - - -/** - * Create a new bandwidth value. - * - * @param bytes_per_second value to create - * @return the new bandwidth value - */ -struct GNUNET_BANDWIDTH_Value32NBO -GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second); - - -/** - * Maximum possible bandwidth value. - */ -#define GNUNET_BANDWIDTH_VALUE_MAX GNUNET_BANDWIDTH_value_init (UINT32_MAX) - - -/** - * At the given bandwidth, calculate how much traffic will be - * available until the given deadline. - * - * @param bps bandwidth - * @param deadline when is the deadline - * @return number of bytes available at bps until deadline - */ -uint64_t -GNUNET_BANDWIDTH_value_get_available_until ( - struct GNUNET_BANDWIDTH_Value32NBO bps, - struct GNUNET_TIME_Relative deadline); - - -/** - * At the given bandwidth, calculate how long it would take for - * 'size' bytes to be transmitted. - * - * @param bps bandwidth - * @param size number of bytes we want to have available - * @return how long it would take - */ -struct GNUNET_TIME_Relative -GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, - uint64_t size); - - -/** - * Compute the MIN of two bandwidth values. - * - * @param b1 first value - * @param b2 second value - * @return the min of b1 and b2 - */ -struct GNUNET_BANDWIDTH_Value32NBO -GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, - struct GNUNET_BANDWIDTH_Value32NBO b2); - - -/** - * Compute the MAX of two bandwidth values. - * - * @param b1 first value - * @param b2 second value - * @return the min of b1 and b2 - */ -struct GNUNET_BANDWIDTH_Value32NBO -GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, - struct GNUNET_BANDWIDTH_Value32NBO b2); - - -/** - * Compute the SUM of two bandwidth values. - * - * @param b1 first value - * @param b2 second value - * @return the sum of b1 and b2 - */ -struct GNUNET_BANDWIDTH_Value32NBO -GNUNET_BANDWIDTH_value_sum (struct GNUNET_BANDWIDTH_Value32NBO b1, - struct GNUNET_BANDWIDTH_Value32NBO b2); - - -/** - * Initialize bandwidth tracker. Note that in addition to the - * 'max_carry_s' limit, we also always allow at least - * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the - * bytes-per-second limit is so small that within 'max_carry_s' not - * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is - * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in - * bytes). - * - * @param av tracker to initialize - * @param update_cb callback to notify a client about the tracker being updated - * @param update_cb_cls cls for the @a update_cb callback - * @param bytes_per_second_limit initial limit to assume - * @param max_carry_s maximum number of seconds unused bandwidth - * may accumulate before it expires - */ -void -GNUNET_BANDWIDTH_tracker_init ( - struct GNUNET_BANDWIDTH_Tracker *av, - GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, - void *update_cb_cls, - struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, - uint32_t max_carry_s); - - -/** - * Initialize bandwidth tracker. Note that in addition to the - * 'max_carry_s' limit, we also always allow at least - * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the - * bytes-per-second limit is so small that within 'max_carry_s' not - * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is - * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in - * bytes). - * - * @param av tracker to initialize - * @param update_cb callback to notify a client about the tracker being updated - * @param update_cb_cls cls for the @a update_cb callback - * @param bytes_per_second_limit initial limit to assume - * @param max_carry_s maximum number of seconds unused bandwidth - * may accumulate before it expires - * @param excess_cb callback to notify if we have excess bandwidth - * @param excess_cb_cls closure for @a excess_cb - */ -void -GNUNET_BANDWIDTH_tracker_init2 ( - struct GNUNET_BANDWIDTH_Tracker *av, - GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, - void *update_cb_cls, - struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, - uint32_t max_carry_s, - GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb, - void *excess_cb_cls); - - -/** - * Stop notifying about tracker updates and excess notifications - * - * @param av the respective trackers - */ -void -GNUNET_BANDWIDTH_tracker_notification_stop ( - struct GNUNET_BANDWIDTH_Tracker *av); - - -/** - * Notify the tracker that a certain number of bytes of bandwidth have - * been consumed. Note that it is legal to consume bytes even if not - * enough bandwidth is available (in that case, - * #GNUNET_BANDWIDTH_tracker_get_delay() may return non-zero delay values - * even for a size of zero for a while). - * - * @param av tracker to update - * @param size number of bytes consumed - * @return #GNUNET_YES if this consumption is above the limit - */ -int -GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, - ssize_t size); - - -/** - * Compute how long we should wait until consuming @a size - * bytes of bandwidth in order to stay within the given - * quota. - * - * @param av tracker to query - * @param size number of bytes we would like to consume - * @return time to wait for consumption to be OK - */ -struct GNUNET_TIME_Relative -GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, - size_t size); - - -/** - * Compute how many bytes are available for consumption right now. - * quota. - * - * @param av tracker to query - * @return number of bytes available for consumption right now - */ -int64_t -GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av); - - -/** - * Update quota of bandwidth tracker. - * - * @param av tracker to initialize - * @param bytes_per_second_limit new limit to assume - */ -void -GNUNET_BANDWIDTH_tracker_update_quota ( - struct GNUNET_BANDWIDTH_Tracker *av, - struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_BANDWIDTH_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_bandwidth_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bio_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_bio_lib.h @@ -1,658 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Buffered IO library - * - * @defgroup bio BIO library - * Buffered binary disk IO (with endianness conversion) - * @{ - */ - -#include "gnunet_common.h" -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_BIO_LIB_H -#define GNUNET_BIO_LIB_H - - -#include "gnunet_container_lib.h" - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/****************************** READING API *******************************/ - -/** - * Handle for buffered reading. - */ -struct GNUNET_BIO_ReadHandle; - - -/** - * Open a file for reading. - * - * @param fn file name to be opened - * @return IO handle on success, NULL on error - */ -struct GNUNET_BIO_ReadHandle * -GNUNET_BIO_read_open_file (const char *fn); - - -/** - * Create a handle from an existing allocated buffer. - * - * @param buffer the buffer to use as source - * @param size the total size in bytes of the buffer - * @return IO handle on success, NULL on error - */ -struct GNUNET_BIO_ReadHandle * -GNUNET_BIO_read_open_buffer (void *buffer, size_t size); - - -/** - * Close an open handle. Reports if any errors reading - * from the file were encountered. - * - * @param h file handle - * @param emsg set to the error message - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); - -/** - * Set read error to handle - * - * @param h the handle - * @param emsg the message - */ -void -GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg); - - -/** - * Read some contents into a buffer. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param result the buffer to write the result to - * @param len the number of bytes to read - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, - const char *what, - void *result, - size_t len); - - -/** - * Read 0-terminated string. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param result where to store the pointer to the (allocated) string - * (note that *result could be set to NULL as well) - * @param max_length maximum allowed length for the string - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, - const char *what, - char **result, - size_t max_length); - - - -/** - * Read a float. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param f address of float to read - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, - const char *what, - float *f); - - -/** - * Read a double. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param f address of double to read - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, - const char *what, - double *f); - - -/** - * Read an (u)int32_t. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param i where to store the data - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, - const char *what, - int32_t *i); - - -/** - * Read an (u)int64_t. - * - * @param h the IO handle to read from - * @param what describes what is being read (for error message creation) - * @param i where to store the data - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, - const char *what, - int64_t *i); - - -/****************************** WRITING API *******************************/ - -/** - * Handle for buffered writing. - */ -struct GNUNET_BIO_WriteHandle; - -/** - * Open a file for writing. - * - * @param fn name of the file to be opened - * @return IO handle on success, NULL on error - */ -struct GNUNET_BIO_WriteHandle * -GNUNET_BIO_write_open_file (const char *fn); - - -/** - * Create a handle backed by an in-memory buffer. - * - * @return IO handle on success, NULL on error - */ -struct GNUNET_BIO_WriteHandle * -GNUNET_BIO_write_open_buffer (void); - - -/** - * Force a file-based buffered writer to flush its buffer. - * If the handle does not use a file, this function returns #GNUNET_OK - * without doing anything. - * - * @param h the IO handle - * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned - * and the file is closed - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); - - -/** - * Get the IO handle's contents. - * If the handle doesn't use an in-memory buffer, this function returns - * #GNUNET_SYSERR. - * - * @param h the IO handle - * @param emsg set to the (allocated) error message - * if the handle has an error message the return value is #GNUNET_SYSERR - * @param contents where to store the pointer to the handle's contents - * @param size where to store the size of @e contents - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, - char **emsg, - void **contents, - size_t *size); - - -/** - * Close an IO handle. - * If the handle was using a file, the file will be closed. - * - * @param h file handle - * @param emsg set to the (allocated) error message - * if the handle has an error message, the return value is #GNUNET_SYSERR - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); - - -/** - * Write a buffer to a handle. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param buffer the data to write - * @param n number of bytes to write - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, - const char *what, - const void *buffer, - size_t n); - - -/** - * Write a 0-terminated string. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param s string to write (can be NULL) - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, - const char *what, - const char *s); - - - -/** - * Write a float. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param f float to write (must be a variable) - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, - const char *what, - float f); - -/** - * Write a double. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param f double to write (must be a variable) - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, - const char *what, - double f); - - -/** - * Write an (u)int32_t. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param i 32-bit integer to write - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, - const char *what, - int32_t i); - - -/** - * Write an (u)int64_t. - * - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param i 64-bit integer to write - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, - const char *what, - int64_t i); - - -/****************************** READ SPEC API ***************************/ - - -/** - * Function used to deserialize data read from @a h and store it into @a - * target. - * - * @param cls closure (can be NULL) - * @param h the IO handle to read from - * @param what what is being read (for error message creation) - * @param target where to store the data - * @param target_size how many bytes can be written in @a target - * can be 0 if the size is unknown or is not fixed - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -typedef int -(*GNUNET_BIO_ReadHandler)(void *cls, - struct GNUNET_BIO_ReadHandle *h, - const char *what, - void *target, - size_t target_size); - - -/** - * Structure specifying a reading operation on an IO handle. - */ -struct GNUNET_BIO_ReadSpec -{ - /** - * Function performing data deserialization. - */ - GNUNET_BIO_ReadHandler rh; - - /** - * Closure for @e rh. Can be NULL. - */ - void *cls; - - /** - * What is being read (for error message creation) - */ - const char *what; - - /** - * Destination buffer. Can also be a pointer to a pointer, especially for - * dynamically allocated structures. - */ - void *target; - - /** - * Size of @e target. Can be 0 if unknown or not fixed. - */ - size_t size; -}; - - -/** - * End of specifications marker. - */ -#define GNUNET_BIO_read_spec_end() \ - { NULL, NULL, NULL, NULL, 0 } - - -/** - * Create the specification to read a certain amount of bytes. - * - * @param what describes what is being read (for error message creation) - * @param result the buffer to write the result to - * @param len the number of bytes to read - * @return the read spec - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_object (const char *what, - void *result, - size_t size); - - -/** - * Create the specification to read a 0-terminated string. - * - * @param what describes what is being read (for error message creation) - * @param result where to store the pointer to the (allocated) string - * (note that *result could be set to NULL as well) - * @param max_length maximum allowed length for the string - * @return the read spec - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_string (const char *what, - char **result, - size_t max_length); - - - -/** - * Create the specification to read an (u)int32_t. - * - * @param what describes what is being read (for error message creation) - * @param i where to store the data - * @return the read spec - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_int32 (const char *what, - int32_t *i); - - -/** - * Create the specification to read an (u)int64_t. - * - * @param what describes what is being read (for error message creation) - * @param i where to store the data - * @return the read spec - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_int64 (const char *what, - int64_t *i); - - -/** - * Create the specification to read a float. - * - * @param what describes what is being read (for error message creation) - * @param f address of float to read - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_float (const char *what, float *f); - - -/** - * Create the specification to read a double. - * - * @param what describes what is being read (for error message creation) - * @param f address of double to read - */ -struct GNUNET_BIO_ReadSpec -GNUNET_BIO_read_spec_double (const char *what, double *f); - - -/** - * Execute the read specifications in order. - * - * @param h the IO handle to read from - * @param rs array of read specs - * the last element must be #GNUNET_BIO_read_spec_end - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, - struct GNUNET_BIO_ReadSpec *rs); - - -/******************************* WRITE SPEC API *****************************/ - - -/** - * Function used to serialize data from a buffer and write it to @a h. - * - * @param cls closure (can be NULL) - * @param h the IO handle to write to - * @param what what is being written (for error message creation) - * @param source the data to write - * @param source_size how many bytes should be written - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -typedef int -(*GNUNET_BIO_WriteHandler) (void *cls, - struct GNUNET_BIO_WriteHandle *h, - const char *what, - void *source, - size_t source_size); - - -/** - * Structure specifying a writing operation on an IO handle. - */ -struct GNUNET_BIO_WriteSpec -{ - /** - * Function performing data serialization. - */ - GNUNET_BIO_WriteHandler wh; - - /** - * Closure for @e rh. Can be NULL. - */ - void *cls; - - /** - * What is being read (for error message creation) - */ - const char *what; - - /** - * Source buffer. The data in this buffer will be written to the handle. - */ - void *source; - - /** - * Size of @e source. If it's smaller than the real size of @e source, only - * this many bytes will be written. - */ - size_t source_size; -}; - - -/** - * End of specifications marker. - */ -#define GNUNET_BIO_write_spec_end() \ - { NULL, NULL, NULL, NULL, 0 } - - -/** - * Create the specification to read some bytes. - * - * @param what describes what is being written (for error message creation) - * @param source the data to write - * @param size how many bytes should be written - * @return the write spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_object (const char *what, - void *source, - size_t size); - - -/** - * Create the specification to write a 0-terminated string. - * - * @param what describes what is being read (for error message creation) - * @param s string to write (can be NULL) - * @return the read spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_string (const char *what, - const char *s); - - -/** - * Create the specification to write an (u)int32_t. - * - * @param what describes what is being written (for error message creation) - * @param i pointer to a 32-bit integer - * @return the write spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_int32 (const char *what, - int32_t *i); - - -/** - * Create the specification to write an (u)int64_t. - * - * @param what describes what is being written (for error message creation) - * @param i pointer to a 64-bit integer - * @return the write spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_int64 (const char *what, - int64_t *i); - - -/** - * Create the specification to write a float. - * - * @param what describes what is being written (for error message creation) - * @param f pointer to a float - * @return the write spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_float (const char *what, float *f); - - -/** - * Create the specification to write an double. - * - * @param what describes what is being written (for error message creation) - * @param f pointer to a double - * @return the write spec - */ -struct GNUNET_BIO_WriteSpec -GNUNET_BIO_write_spec_double (const char *what, double *f); - - -/** - * Execute the write specifications in order. - * - * @param h the IO handle to write to - * @param ws array of write specs - * the last element must be #GNUNET_BIO_write_spec_end - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, - struct GNUNET_BIO_WriteSpec *ws); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_BIO_LIB_H */ -#endif - -/** @} */ /* end of group bio */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_bio_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_buffer_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_buffer_lib.h @@ -1,215 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2020 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * Common buffer management functions. - * - * @author Florian Dold - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_BUFFER_LIB_H -#define GNUNET_BUFFER_LIB_H - -/** - * Dynamically growing buffer. Can be used to construct - * strings and other objects with dynamic size. - * - * This structure should, in most cases, be stack-allocated and - * zero-initialized, like: - * - * struct GNUNET_Buffer my_buffer = { 0 }; - */ -struct GNUNET_Buffer -{ - /** - * Capacity of the buffer. - */ - size_t capacity; - - /** - * Current write position. - */ - size_t position; - - /** - * Backing memory. - */ - char *mem; - - /** - * Log a warning if the buffer is grown over its initially allocated capacity. - */ - int warn_grow; -}; - - -/** - * Initialize a buffer with the given capacity. - * - * When a buffer is allocated with this function, a warning is logged - * when the buffer exceeds the initial capacity. - * - * @param buf the buffer to initialize - * @param capacity the capacity (in bytes) to allocate for @a buf - */ -void -GNUNET_buffer_prealloc (struct GNUNET_Buffer *buf, size_t capacity); - - -/** - * Make sure that at least @a n bytes remaining in the buffer. - * - * @param buf buffer to potentially grow - * @param n number of bytes that should be available to write - */ -void -GNUNET_buffer_ensure_remaining (struct GNUNET_Buffer *buf, size_t n); - - -/** - * Write bytes to the buffer. - * - * Grows the buffer if necessary. - * - * @param buf buffer to write to - * @param data data to read from - * @param len number of bytes to copy from @a data to @a buf - * - */ -void -GNUNET_buffer_write (struct GNUNET_Buffer *buf, const char *data, size_t len); - - -/** - * Write a 0-terminated string to a buffer, excluding the 0-terminator. - * - * Grows the buffer if necessary. - * - * @param buf the buffer to write to - * @param str the string to write to @a buf - */ -void -GNUNET_buffer_write_str (struct GNUNET_Buffer *buf, const char *str); - - -/** - * Write data encoded via #GNUNET_STRINGS_data_to_string to the buffer. - * - * Grows the buffer if necessary. - * - * @param buf buffer to write to - * @param data data to read from - * @param data_len number of bytes to copy from @a data to @a buf - */ -void -GNUNET_buffer_write_data_encoded (struct GNUNET_Buffer *buf, - const void *data, - size_t data_len); - - -/** - * Write a path component to a buffer, ensuring that - * there is exactly one slash between the previous contents - * of the buffer and the new string. - * - * @param buf buffer to write to - * @param str string containing the new path component - */ -void -GNUNET_buffer_write_path (struct GNUNET_Buffer *buf, const char *str); - - -/** - * Write a 0-terminated formatted string to a buffer, excluding the - * 0-terminator. - * - * Grows the buffer if necessary. - * - * @param buf the buffer to write to - * @param fmt format string - * @param ... format arguments - */ -void -GNUNET_buffer_write_fstr (struct GNUNET_Buffer *buf, const char *fmt, ...) -__attribute__ ((format (printf, 2, 3))); - - -/** - * Write a 0-terminated formatted string to a buffer, excluding the - * 0-terminator. - * - * Grows the buffer if necessary. - * - * @param buf the buffer to write to - * @param fmt format string - * @param args format argument list - */ -void -GNUNET_buffer_write_vfstr (struct GNUNET_Buffer *buf, const char *fmt, va_list - args); - - -/** - * Clear the buffer and return the string it contained. - * The caller is responsible to eventually #GNUNET_free - * the returned string. - * - * The returned string is always 0-terminated. - * - * @param buf the buffer to reap the string from - * @returns the buffer contained in the string - */ -char * -GNUNET_buffer_reap_str (struct GNUNET_Buffer *buf); - - -/** - * Clear the buffer and return its contents. - * The caller is responsible to eventually #GNUNET_free - * the returned data. - * - * @param buf the buffer to reap the contents from - * @param size where to store the size of the returned data - * @returns the data contained in the string - */ -void * -GNUNET_buffer_reap (struct GNUNET_Buffer *buf, size_t *size); - - -/** - * Free the backing memory of the given buffer. - * Does not free the memory of the buffer control structure, - * which is typically stack-allocated. - */ -void -GNUNET_buffer_clear (struct GNUNET_Buffer *buf); - - -#endif - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_child_management_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_child_management_lib.h @@ -1,81 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2021 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @file include/gnunet_child_management_lib.h - * @brief GNUnet child management api - * @author Christian Grothoff - * @author Dominik Meister - * @author Dennis Neufeld - * @author t3sserakt - */ -#ifndef GNUNET_CHILD_MANAGEMENT_LIB_H -#define GNUNET_CHILD_MANAGEMENT_LIB_H - -/** - * Handle for the child management - */ -struct GNUNET_ChildWaitHandle; - -/** - * Defines a GNUNET_ChildCompletedCallback which is sent back - * upon death or completion of a child process. - * - * @param cls handle for the callback - * @param type type of the process - * @param exit_code status code of the process - */ -typedef void -(*GNUNET_ChildCompletedCallback)(void *cls, - enum GNUNET_OS_ProcessStatusType type, - long unsigned int exit_code); - -/** - * Starts the handling of the child processes. - * Function checks the status of the child process and sends back a - * GNUNET_ChildCompletedCallback upon completion/death of the child. - * - * @param proc child process which is monitored - * @param cb reference to the callback which is called after completion - * @param cb_cls closure for the callback - * @return GNUNET_ChildWaitHandle is returned - */ -struct GNUNET_ChildWaitHandle * -GNUNET_wait_child (struct GNUNET_OS_Process *proc, - GNUNET_ChildCompletedCallback cb, - void *cb_cls); - -/** - * Stop waiting on this child. - */ -void -GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh); - -#endif - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_client_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_client_lib.h @@ -1,113 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2013, 2016 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @addtogroup networking - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to accessing services - - * @defgroup client Client library - * Generic client-side communication with services - * - * @see [Documentation](https://gnunet.org/ipc) - * - * @{ - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_CLIENT_LIB_H -#define GNUNET_CLIENT_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include "gnunet_mq_lib.h" - - -/** - * Test if the port or UNIXPATH of the given @a service_name - * is in use and thus (most likely) the respective service is up. - * - * @param cfg our configuration - * @param service_name name of the service to connect to - * @return #GNUNET_YES if the service is (likely) up (or running remotely), - * #GNUNET_NO if the service is (definitively) down, - * #GNUNET_SYSERR if the configuration does not give us - * the necessary information about the service, or if - * we could not check (e.g. socket() failed) - */ -int -GNUNET_CLIENT_test (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *service_name); - - -/** - * Create a message queue to connect to a GNUnet service. - * If handlers are specified, receive messages from the connection. - * - * @param cfg our configuration - * @param service_name name of the service to connect to - * @param handlers handlers for receiving messages, can be NULL - * @param error_handler error handler - * @param error_handler_cls closure for the @a error_handler - * @return the message queue, NULL on error - */ -struct GNUNET_MQ_Handle * -GNUNET_CLIENT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *service_name, - const struct GNUNET_MQ_MessageHandler *handlers, - GNUNET_MQ_ErrorHandler error_handler, - void *error_handler_cls); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_CLIENT_LIB_H */ -#endif - -/** @} */ /* end of group client */ - -/** @} */ /* end of group addition */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_client_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_common.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_common.h @@ -1,1908 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2006-2022 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @file include/gnunet_common.h - * @brief commonly used definitions; globals in this file - * are exempt from the rule that the module name ("common") - * must be part of the symbol name. - * - * @author Christian Grothoff - * @author Nils Durner - * @author Martin Schanzenbach - * - * @defgroup logging Logging - * @see [Documentation](https://gnunet.org/logging) - * - * @defgroup memory Memory management - */ -#ifndef GNUNET_COMMON_H -#define GNUNET_COMMON_H - -#include "gnunet_config.h" - -#include <stdbool.h> -#include <stdlib.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <stdint.h> -#include <stdarg.h> -#include <sys/types.h> - -#if defined(__FreeBSD__) - -#include <sys/endian.h> -#define bswap_32(x) bswap32 (x) -#define bswap_64(x) bswap64 (x) - -#elif defined(__OpenBSD__) - -#define bswap_32(x) swap32 (x) -#define bswap_64(x) swap64 (x) - -#elif defined(__NetBSD__) - -#include <machine/bswap.h> -#if defined(__BSWAP_RENAME) && ! defined(__bswap_32) -#define bswap_32(x) bswap32 (x) -#define bswap_64(x) bswap64 (x) -#endif - -#elif defined(__linux__) || defined(GNU) -#include <byteswap.h> -#endif - - -/* This is also included in platform.h, but over there a couple of - GNUnet-specific gettext-related macros are defined in addition to including - the header file. Because this header file uses gettext, this include - statement makes sure gettext macros are defined even when platform.h is - unavailable. */ -#include "gettext.h" - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/** - * Version of the API (for entire gnunetutil.so library). - */ -#define GNUNET_UTIL_VERSION 0x000A0104 - - -/** - * Named constants for return values. The following invariants hold: - * `GNUNET_NO == 0` (to allow `if (GNUNET_NO)`) `GNUNET_OK != - * GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO != - * GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`. - */ -enum GNUNET_GenericReturnValue -{ - GNUNET_SYSERR = -1, - GNUNET_NO = 0, - GNUNET_OK = 1, - /* intentionally identical to #GNUNET_OK! */ - GNUNET_YES = 1, -}; - - -#define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b)) - -#define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b)) - -/* some systems use one underscore only, and mingw uses no underscore... */ -#ifndef __BYTE_ORDER -#ifdef _BYTE_ORDER -#define __BYTE_ORDER _BYTE_ORDER -#else -#ifdef BYTE_ORDER -#define __BYTE_ORDER BYTE_ORDER -#endif -#endif -#endif -#ifndef __BIG_ENDIAN -#ifdef _BIG_ENDIAN -#define __BIG_ENDIAN _BIG_ENDIAN -#else -#ifdef BIG_ENDIAN -#define __BIG_ENDIAN BIG_ENDIAN -#endif -#endif -#endif -#ifndef __LITTLE_ENDIAN -#ifdef _LITTLE_ENDIAN -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#else -#ifdef LITTLE_ENDIAN -#define __LITTLE_ENDIAN LITTLE_ENDIAN -#endif -#endif -#endif - -/** - * @ingroup logging - * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source - * tree where gnunet_config.h is unavailable - */ -#ifndef GNUNET_EXTRA_LOGGING -#define GNUNET_EXTRA_LOGGING 1 -#endif - -/** - * Endian operations - */ - -#if defined(bswap_16) || defined(bswap_32) || defined(bswap_64) -#define BYTE_SWAP_16(x) bswap_16 (x) -#define BYTE_SWAP_32(x) bswap_32 (x) -#define BYTE_SWAP_64(x) bswap_64 (x) -#else -#define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) - -#define BYTE_SWAP_32(x) \ - ((((x) & 0x000000ffU) << 24) | (((x) & 0x0000ff00U) << 8) \ - | (((x) & 0x00ff0000U) >> 8) | (((x) & 0xff000000U) >> 24)) - -#define BYTE_SWAP_64(x) \ - ((((x) & 0x00000000000000ffUL) << 56) | (((x) & 0x000000000000ff00UL) << \ - 40) \ - | (((x) & 0x0000000000ff0000UL) << 24) | (((x) & 0x00000000ff000000UL) \ - << 8) \ - | (((x) & 0x000000ff00000000UL) >> 8) | (((x) & 0x0000ff0000000000UL) \ - >> 24) \ - | (((x) & 0x00ff000000000000UL) >> 40) | (((x) & 0xff00000000000000UL) \ - >> \ - 56)) -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define GNUNET_htobe16(x) BYTE_SWAP_16 (x) -#define GNUNET_htole16(x) (x) -#define GNUNET_be16toh(x) BYTE_SWAP_16 (x) -#define GNUNET_le16toh(x) (x) - -#define GNUNET_htobe32(x) BYTE_SWAP_32 (x) -#define GNUNET_htole32(x) (x) -#define GNUNET_be32toh(x) BYTE_SWAP_32 (x) -#define GNUNET_le32toh(x) (x) - -#define GNUNET_htobe64(x) BYTE_SWAP_64 (x) -#define GNUNET_htole64(x) (x) -#define GNUNET_be64toh(x) BYTE_SWAP_64 (x) -#define GNUNET_le64toh(x) (x) -#endif -#if __BYTE_ORDER == __BIG_ENDIAN -#define GNUNET_htobe16(x) (x) -#define GNUNET_htole16(x) BYTE_SWAP_16 (x) -#define GNUNET_be16toh(x) (x) -#define GNUNET_le16toh(x) BYTE_SWAP_16 (x) - -#define GNUNET_htobe32(x) (x) -#define GNUNET_htole32(x) BYTE_SWAP_32 (x) -#define GNUNET_be32toh(x) (x) -#define GNUNET_le32toh(x) BYTE_SWAP_32 (x) - -#define GNUNET_htobe64(x) (x) -#define GNUNET_htole64(x) BYTE_SWAP_64 (x) -#define GNUNET_be64toh(x) (x) -#define GNUNET_le64toh(x) BYTE_SWAP_64 (x) -#endif - - -/** - * Macro used to avoid using 0 for the length of a variable-size - * array (Non-Zero-Length). - * - * Basically, C standard says that "int[n] x;" is undefined if n=0. - * This was supposed to prevent issues with pointer aliasing. - * However, C compilers may conclude that n!=0 as n=0 would be - * undefined, and then optimize under the assumption n!=0, which - * could cause actual issues. Hence, when initializing an array - * on the stack with a variable-length that might be zero, write - * "int[GNUNET_NZL(n)] x;" instead of "int[n] x". - */ -#define GNUNET_NZL(l) GNUNET_MAX (1, l) - - -/** - * gcc-ism to get packed structs. - */ -#define GNUNET_PACKED __attribute__ ((packed)) - -/** - * gcc-ism to get gcc bitfield layout when compiling with -mms-bitfields - */ -#define GNUNET_GCC_STRUCT_LAYOUT - -/** - * gcc-ism to force alignment; we use this to align char-arrays - * that may then be cast to 'struct's. See also gcc - * bug #33594. - */ -#ifdef __BIGGEST_ALIGNMENT__ -#define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))) -#else -#define GNUNET_ALIGN __attribute__ ((aligned (8))) -#endif - -/** - * gcc-ism to document unused arguments - */ -#define GNUNET_UNUSED __attribute__ ((unused)) - -/** - * gcc-ism to document functions that don't return - */ -#define GNUNET_NORETURN __attribute__ ((noreturn)) - -/** - * Define as empty, GNUNET_PACKED should suffice, but this won't work on W32 - */ -#define GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Define as empty, GNUNET_PACKED should suffice, but this won't work on W32; - */ -#define GNUNET_NETWORK_STRUCT_END - -/* ************************ super-general types *********************** */ - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. - */ -struct GNUNET_HashCode -{ - uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */ -}; - - -/** - * @brief A 256-bit hashcode. Used under special conditions, like when space - * is critical and security is not impacted by it. - */ -struct GNUNET_ShortHashCode -{ - uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */ -}; - - -/** - * A UUID, a 128 bit "random" value. We OFTEN use - * timeflakes (see: https://github.com/anthonynsimon/timeflake), - * where only 80 bits are random and the rest encodes - * a timestamp to improve database access. - * - * See #GNUNET_CRYPTO_random_timeflake(). - */ -struct GNUNET_Uuid -{ - /** - * 128 random bits. - */ - uint32_t value[4]; -}; - - -/** - * Header for all communications. - */ -struct GNUNET_MessageHeader -{ - /** - * The length of the struct (in bytes, including the length field itself), - * in big-endian format. - */ - uint16_t size GNUNET_PACKED; - - /** - * The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format. - */ - uint16_t type GNUNET_PACKED; -}; - - -/** - * Answer from service to client about last operation. - */ -struct GNUNET_OperationResultMessage -{ - struct GNUNET_MessageHeader header; - - uint32_t reserved GNUNET_PACKED; - - /** - * Operation ID. - */ - uint64_t op_id GNUNET_PACKED; - - /** - * Status code for the operation. - */ - uint64_t result_code GNUNET_PACKED; - - /* Followed by data. */ -}; - - -/** - * Identifier for an asynchronous execution context. - */ -struct GNUNET_AsyncScopeId -{ - uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */ -}; - -GNUNET_NETWORK_STRUCT_END - - -/** - * Saved async scope identifier or root scope. - */ -struct GNUNET_AsyncScopeSave -{ - /** - * Saved scope. Unused if 'have_scope==GNUNET_NO'. - */ - struct GNUNET_AsyncScopeId scope_id; - - /** - * GNUNET_YES unless this saved scope is the unnamed root scope. - */ - int have_scope; -}; - - -/** - * Function called with a filename. - * - * @param cls closure - * @param filename complete filename (absolute path) - * @return #GNUNET_OK to continue to iterate, - * #GNUNET_NO to stop iteration with no error, - * #GNUNET_SYSERR to abort iteration with error! - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_FileNameCallback) (void *cls, - const char *filename); - - -/** - * Generic continuation callback. - * - * @param cls Closure. - */ -typedef void -(*GNUNET_ContinuationCallback) (void *cls); - - -/** - * Function called with the result of an asynchronous operation. - * - * @param cls - * Closure. - * @param result_code - * Result code for the operation. - * @param data - * Data result for the operation. - * @param data_size - * Size of @a data. - */ -typedef void -(*GNUNET_ResultCallback) (void *cls, - int64_t result_code, - const void *data, - uint16_t data_size); - - -/* ****************************** logging ***************************** */ - -/** - * @ingroup logging - * Types of errors. - */ -enum GNUNET_ErrorType -{ - GNUNET_ERROR_TYPE_UNSPECIFIED = -1, - GNUNET_ERROR_TYPE_NONE = 0, - GNUNET_ERROR_TYPE_ERROR = 1, - GNUNET_ERROR_TYPE_WARNING = 2, - /* UX: We need a message type that is output by - * default without looking like there is a problem. - */ - GNUNET_ERROR_TYPE_MESSAGE = 4, - GNUNET_ERROR_TYPE_INFO = 8, - GNUNET_ERROR_TYPE_DEBUG = 16, - GNUNET_ERROR_TYPE_INVALID = 32, - GNUNET_ERROR_TYPE_BULK = 64 -}; - - -/** - * @ingroup logging - * User-defined handler for log messages. - * - * @param cls closure - * @param kind severeity - * @param component what component is issuing the message? - * @param date when was the message logged? - * @param message what is the message - */ -typedef void -(*GNUNET_Logger) (void *cls, - enum GNUNET_ErrorType kind, - const char *component, - const char *date, - const char *message); - - -/** - * @ingroup logging - * Get the number of log calls that are going to be skipped - * - * @return number of log calls to be ignored - */ -int -GNUNET_get_log_skip (void); - - -#if ! defined(GNUNET_CULL_LOGGING) -int -GNUNET_get_log_call_status (int caller_level, - const char *comp, - const char *file, - const char *function, - int line); - -#endif - -/* *INDENT-OFF* */ -/** - * @ingroup logging - * Main log function. - * - * @param kind how serious is the error? - * @param message what is the message (format string) - * @param ... arguments for format string - */ -void -GNUNET_log_nocheck (enum GNUNET_ErrorType kind, - const char *message, - ...) -__attribute__ ((format (printf, 2, 3))); - -/* from glib */ -#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) -#define _GNUNET_BOOLEAN_EXPR(expr) \ - __extension__ ({ \ - int _gnunet_boolean_var_; \ - if (expr) \ - _gnunet_boolean_var_ = 1; \ - else \ - _gnunet_boolean_var_ = 0; \ - _gnunet_boolean_var_; \ - }) -#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1)) -#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0)) -#else -#define GN_LIKELY(expr) (expr) -#define GN_UNLIKELY(expr) (expr) -#endif - -#if ! defined(GNUNET_LOG_CALL_STATUS) -#define GNUNET_LOG_CALL_STATUS -1 -#endif -/* *INDENT-ON* */ - - -/** - * @ingroup logging - * Log function that specifies an alternative component. - * This function should be used by plugins. - * - * @param kind how serious is the error? - * @param comp component responsible for generating the message - * @param message what is the message (format string) - * @param ... arguments for format string - */ -void -GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, - const char *comp, - const char *message, - ...) -__attribute__ ((format (printf, 3, 4))); - -#if ! defined(GNUNET_CULL_LOGGING) -#define GNUNET_log_from(kind, comp, ...) \ - do \ - { \ - static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ - if ((GNUNET_EXTRA_LOGGING > 0) || \ - ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ - { \ - if (GN_UNLIKELY (log_call_enabled == -1)) \ - log_call_enabled = \ - GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ - (comp), \ - __FILE__, \ - __FUNCTION__, \ - __LINE__); \ - if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ - { \ - GNUNET_log_skip (-1, GNUNET_NO); \ - } \ - else \ - { \ - if (GN_UNLIKELY (log_call_enabled)) \ - GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ - } \ - } \ - } while (0) - -#define GNUNET_log(kind, ...) \ - do \ - { \ - static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ - if ((GNUNET_EXTRA_LOGGING > 0) || \ - ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ - { \ - if (GN_UNLIKELY (log_call_enabled == -1)) \ - log_call_enabled = \ - GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ - NULL, \ - __FILE__, \ - __FUNCTION__, \ - __LINE__); \ - if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ - { \ - GNUNET_log_skip (-1, GNUNET_NO); \ - } \ - else \ - { \ - if (GN_UNLIKELY (log_call_enabled)) \ - GNUNET_log_nocheck ((kind), __VA_ARGS__); \ - } \ - } \ - } while (0) -#else -#define GNUNET_log(...) -#define GNUNET_log_from(...) -#endif - - -/** - * @ingroup logging - * Log error message about missing configuration option. - * - * @param kind log level - * @param section section with missing option - * @param option name of missing option - */ -void -GNUNET_log_config_missing (enum GNUNET_ErrorType kind, - const char *section, - const char *option); - - -/** - * @ingroup logging - * Log error message about invalid configuration option value. - * - * @param kind log level - * @param section section with invalid option - * @param option name of invalid option - * @param required what is required that is invalid about the option - */ -void -GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, - const char *section, - const char *option, - const char *required); - - -/** - * @ingroup logging - * Abort the process, generate a core dump if possible. - * Most code should use `GNUNET_assert (0)` instead to - * first log the location of the failure. - */ -void -GNUNET_abort_ (void) GNUNET_NORETURN; - - -/** - * Convert a buffer to an 8-character string - * representative of the contents. This is used - * for logging binary data when debugging. - * - * @param buf buffer to log - * @param buf_size number of bytes in @a buf - * @return text representation of buf, valid until next - * call to this function - */ -const char * -GNUNET_b2s (const void *buf, - size_t buf_size); - - -/** - * Convert a fixed-sized object to a string using - * #GNUNET_b2s(). - * - * @param obj address of object to convert - * @return string representing the binary obj buffer - */ -#define GNUNET_B2S(obj) GNUNET_b2s ((obj), sizeof (*(obj))) - - -/** - * @ingroup logging - * Ignore the next @a n calls to the log function. - * - * @param n number of log calls to ignore (could be negative) - * @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero - */ -void -GNUNET_log_skip (int n, int check_reset); - - -/** - * @ingroup logging - * Setup logging. - * - * @param comp default component to use - * @param loglevel what types of messages should be logged - * @param logfile change logging to logfile (use NULL to keep stderr) - * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened - */ -enum GNUNET_GenericReturnValue -GNUNET_log_setup (const char *comp, - const char *loglevel, - const char *logfile); - - -/** - * @ingroup logging - * Add a custom logger. Note that installing any custom logger - * will disable the standard logger. When multiple custom loggers - * are installed, all will be called. The standard logger will - * only be used if no custom loggers are present. - * - * @param logger log function - * @param logger_cls closure for @a logger - */ -void -GNUNET_logger_add (GNUNET_Logger logger, - void *logger_cls); - - -/** - * @ingroup logging - * Remove a custom logger. - * - * @param logger log function - * @param logger_cls closure for @a logger - */ -void -GNUNET_logger_remove (GNUNET_Logger logger, - void *logger_cls); - - -/** - * @ingroup logging - * Convert a short hash value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param shc the hash code - * @return string - */ -const char * -GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc); - - -/** - * @ingroup logging - * Convert a UUID to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param uuid the UUID - * @return string - */ -const char * -GNUNET_uuid2s (const struct GNUNET_Uuid *uuid); - - -/** - * @ingroup logging - * Convert a hash value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_h2s (const struct GNUNET_HashCode *hc); - - -/** - * @ingroup logging - * Convert a hash value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! Identical to #GNUNET_h2s(), except that another - * buffer is used so both #GNUNET_h2s() and #GNUNET_h2s2() can be - * used within the same log statement. - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_h2s2 (const struct GNUNET_HashCode *hc); - - -/** - * @ingroup logging - * Convert a hash value to a string (for printing debug messages). - * This prints all 104 characters of a hashcode! - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_h2s_full (const struct GNUNET_HashCode *hc); - - -/** - * Public key. Details in gnunet_util_crypto.h. - */ -struct GNUNET_CRYPTO_EddsaPublicKey; - - -/** - * Public key. Details in gnunet_util_crypto.h. - */ -struct GNUNET_CRYPTO_EcdhePublicKey; - - -/** - * @ingroup logging - * Convert a public key value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p); - - -/** - * @ingroup logging - * Convert a public key value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p); - - -/** - * @ingroup logging - * Convert a public key value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p); - - -/** - * @ingroup logging - * Convert a public key value to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param hc the hash code - * @return string - */ -const char * -GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p); - - -/** - * Forward declaration to make compiler happy depending on include order. - */ -struct GNUNET_PeerIdentity; - - -/** - * @ingroup logging - * Convert a peer identity to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param pid the peer identity - * @return string form of the pid; will be overwritten by next - * call to #GNUNET_i2s(). - */ -const char * -GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); - - -/** - * @ingroup logging - * Convert a peer identity to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! Identical to #GNUNET_i2s(), except that another - * buffer is used so both #GNUNET_i2s() and #GNUNET_i2s2() can be - * used within the same log statement. - * - * @param pid the peer identity - * @return string form of the pid; will be overwritten by next - * call to #GNUNET_i2s(). - */ -const char * -GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); - - -/** - * @ingroup logging - * Convert a peer identity to a string (for printing debug messages). - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param pid the peer identity - * @return string form of the pid; will be overwritten by next - * call to #GNUNET_i2s_full(). - */ -const char * -GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); - - -/** - * @ingroup logging - * Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string - * (for printing debug messages). This is one of the very few calls - * in the entire API that is NOT reentrant! - * - * @param addr the address - * @param addrlen the length of the @a addr - * @return nicely formatted string for the address - * will be overwritten by next call to #GNUNET_a2s(). - */ -const char * -GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); - - -/** - * @ingroup logging - * Convert error type to string. - * - * @param kind type to convert - * @return string corresponding to the type - */ -const char * -GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); - - -/** - * @ingroup logging - * Use this for fatal errors that cannot be handled - */ -#if __GNUC__ >= 6 || __clang_major__ >= 6 -#define GNUNET_assert(cond) \ - do \ - { \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wtautological-compare\"") \ - if (! (cond)) \ - { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ - __FILE__, \ - __LINE__); \ - GNUNET_abort_ (); \ - } \ - _Pragma("GCC diagnostic pop") \ - } while (0) -#else -/* older GCC/clangs do not support -Wtautological-compare */ -#define GNUNET_assert(cond) \ - do \ - { \ - if (! (cond)) \ - { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - dgettext ("gnunet", \ - "Assertion failed at %s:%d. Aborting.\n"), \ - __FILE__, \ - __LINE__); \ - GNUNET_abort_ (); \ - } \ - } while (0) -#endif - -/** - * @ingroup logging - * Use this for fatal errors that cannot be handled - */ -#define GNUNET_assert_at(cond, f, l) \ - do \ - { \ - if (! (cond)) \ - { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - dgettext ("gnunet", \ - "Assertion failed at %s:%d. Aborting.\n"), \ - f, \ - l); \ - GNUNET_abort_ (); \ - } \ - } while (0) - - -/** - * @ingroup logging - * Use this for fatal errors that cannot be handled - * - * @param cond Condition to evaluate - * @param comp Component string to use for logging - */ -#define GNUNET_assert_from(cond, comp) \ - do \ - { \ - if (! (cond)) \ - { \ - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ - comp, \ - dgettext ("gnunet", \ - "Assertion failed at %s:%d. Aborting.\n") \ - , \ - __FILE__, \ - __LINE__); \ - GNUNET_abort_ (); \ - } \ - } while (0) - - -#ifdef _Static_assert -/** - * Assertion to be checked (if supported by C compiler) at - * compile time, otherwise checked at runtime and resulting - * in an abort() on failure. - * - * @param cond condition to test, 0 implies failure - */ -#define GNUNET_static_assert(cond) _Static_assert (cond, "") -#else -/** - * Assertion to be checked (if supported by C compiler) at - * compile time, otherwise checked at runtime and resulting - * in an abort() on failure. This is the case where the - * compiler does not support static assertions. - * - * @param cond condition to test, 0 implies failure - */ -#define GNUNET_static_assert(cond) GNUNET_assert (cond) -#endif - - -/** - * @ingroup logging - * Use this for internal assertion violations that are - * not fatal (can be handled) but should not occur. - */ -#define GNUNET_break(cond) \ - do \ - { \ - if (! (cond)) \ - { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - dgettext ("gnunet", "Assertion failed at %s:%d.\n"), \ - __FILE__, \ - __LINE__); \ - } \ - } while (0) - - -/** - * @ingroup logging - * Use this for assertion violations caused by other - * peers (i.e. protocol violations). We do not want to - * confuse end-users (say, some other peer runs an - * older, broken or incompatible GNUnet version), but - * we still want to see these problems during - * development and testing. "OP == other peer". - */ -#define GNUNET_break_op(cond) \ - do \ - { \ - if (! (cond)) \ - { \ - GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ - dgettext ("gnunet", \ - "External protocol violation detected at %s:%d.\n"), \ - __FILE__, \ - __LINE__); \ - } \ - } while (0) - - -/** - * @ingroup logging - * Log an error message at log-level 'level' that indicates - * a failure of the command 'cmd' with the message given - * by strerror(errno). - */ -#define GNUNET_log_strerror(level, cmd) \ - do \ - { \ - GNUNET_log (level, \ - dgettext ("gnunet", \ - "`%s' failed at %s:%d with error: %s\n"), \ - cmd, \ - __FILE__, \ - __LINE__, \ - strerror (errno)); \ - } while (0) - - -/** - * @ingroup logging - * Log an error message at log-level 'level' that indicates - * a failure of the command 'cmd' with the message given - * by strerror(errno). - */ -#define GNUNET_log_from_strerror(level, component, cmd) \ - do \ - { \ - GNUNET_log_from (level, \ - component, \ - dgettext ("gnunet", \ - "`%s' failed at %s:%d with error: %s\n"), \ - cmd, \ - __FILE__, \ - __LINE__, \ - strerror (errno)); \ - } while (0) - - -/** - * @ingroup logging - * Log an error message at log-level 'level' that indicates - * a failure of the command 'cmd' with the message given - * by strerror(errno). - */ -#define GNUNET_log_strerror_file(level, cmd, filename) \ - do \ - { \ - GNUNET_log (level, \ - dgettext ("gnunet", \ - "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ - cmd, \ - filename, \ - __FILE__, \ - __LINE__, \ - strerror (errno)); \ - } while (0) - - -/** - * @ingroup logging - * Log an error message at log-level 'level' that indicates - * a failure of the command 'cmd' with the message given - * by strerror(errno). - */ -#define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ - do \ - { \ - GNUNET_log_from (level, \ - component, \ - dgettext ("gnunet", \ - "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ - cmd, \ - filename, \ - __FILE__, \ - __LINE__, \ - strerror (errno)); \ - } while (0) - -/* ************************* endianness conversion ****************** */ - -#ifdef htonbe64 - -#define GNUNET_htonll(n) htobe64 (n) - -#else -/** - * Convert unsigned 64-bit integer to network byte order. - * - * @param n - * The value in host byte order. - * - * @return The same value in network byte order. - */ -uint64_t -GNUNET_htonll (uint64_t n); - -#endif - - -#ifdef be64toh - -#define GNUNET_ntohll(n) be64toh (n) - -#else -/** - * Convert unsigned 64-bit integer to host byte order. - * - * @param n - * The value in network byte order. - * - * @return The same value in host byte order. - */ -uint64_t -GNUNET_ntohll (uint64_t n); - -#endif - - -/** - * Convert double to network byte order. - * - * @param d - * The value in host byte order. - * - * @return The same value in network byte order. - */ -double -GNUNET_hton_double (double d); - - -/** - * Convert double to host byte order - * - * @param d - * The value in network byte order. - * - * @return The same value in host byte order. - */ -double -GNUNET_ntoh_double (double d); - - -/* ************************* allocation functions ****************** */ - -/** - * @ingroup memory - * Maximum allocation with GNUNET_malloc macro. - */ -#define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40) - -/** - * @ingroup memory - * Allocate a struct or union of the given @a type. - * Wrapper around #GNUNET_malloc that returns a pointer - * to the newly created object of the correct type. - * - * @param type name of the struct or union, i.e. pass 'struct Foo'. - */ -#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof(type)) - - -/** - * Compare memory in @a a and @a b, where both must be of - * the same pointer type. - * - * Do NOT use this function on arrays, it would only compare - * the first element! - */ -#define GNUNET_memcmp(a, b) \ - ({ \ - const typeof (*b) * _a = (a); \ - const typeof (*a) * _b = (b); \ - memcmp (_a, _b, sizeof(*a)); \ - }) - - -/** - * Compare memory in @a b1 and @a b2 in constant time, suitable for private - * data. - * - * @param b1 some buffer of size @a len - * @param b2 another buffer of size @a len - * @param len number of bytes in @a b1 and @a b2 - * @return 0 if buffers are equal, - */ -int -GNUNET_memcmp_ct_ (const void *b1, - const void *b2, - size_t len); - -/** - * Compare memory in @a a and @a b in constant time, suitable for private - * data. Both @a a and @a b must be of the same pointer type. - * - * Do NOT use this function on arrays, it would only compare - * the first element! - */ -#define GNUNET_memcmp_priv(a, b) \ - ({ \ - const typeof (*b) * _a = (a); \ - const typeof (*a) * _b = (b); \ - GNUNET_memcmp_ct_ (_a, _b, sizeof(*a)); \ - }) - - -/** - * Check that memory in @a a is all zeros. @a a must be a pointer. - * - * @param a pointer to @a n bytes which should be tested for the - * entire memory being zero'ed out. - * @param n number of bytes in @a to be tested - * @return true if @a a is zero, false_NO otherwise - */ -bool -GNUNET_is_zero_ (const void *a, - size_t n); - - -/** - * Check that memory in @a a is all zeros. @a a must be a pointer. - * - * @param a pointer to a struct which should be tested for the - * entire memory being zero'ed out. - * @return GNUNET_YES if a is zero, GNUNET_NO otherwise - */ -#define GNUNET_is_zero(a) \ - GNUNET_is_zero_ ((a), sizeof (*(a))) - - -/** - * Call memcpy() but check for @a n being 0 first. In the latter - * case, it is now safe to pass NULL for @a src or @a dst. - * Unlike traditional memcpy(), returns nothing. - * - * @param dst destination of the copy, may be NULL if @a n is zero - * @param src source of the copy, may be NULL if @a n is zero - * @param n number of bytes to copy - */ -#define GNUNET_memcpy(dst, src, n) \ - do \ - { \ - if (0 != n) \ - { \ - (void) memcpy (dst, src, n); \ - } \ - } while (0) - - -/* *INDENT-OFF* */ -/** - * @ingroup memory - * Allocate a size @a n array with structs or unions of the given @a type. - * Wrapper around #GNUNET_malloc that returns a pointer - * to the newly created objects of the correct type. - * - * @param n number of elements in the array - * @param type name of the struct or union, i.e. pass 'struct Foo'. - */ -#define GNUNET_new_array(n, type) ({ \ - GNUNET_assert (SIZE_MAX / sizeof (type) >= n); \ - (type *) GNUNET_malloc ((n) * sizeof(type)); \ - }) -/* *INDENT-ON* */ - -/** - * @ingroup memory - * Allocate a size @a n times @a m array - * with structs or unions of the given @a type. - * - * @param n size of the first dimension - * @param m size of the second dimension - * @param type name of the struct or union, i.e. pass 'struct Foo'. - */ -#define GNUNET_new_array_2d(n, m, type) \ - (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__) - -/** - * @ingroup memory - * Allocate a size @a n times @a m times @a o array - * with structs or unions of the given @a type. - * - * @param n size of the first dimension - * @param m size of the second dimension - * @param o size of the third dimension - * @param type name of the struct or union, i.e. pass 'struct Foo'. - */ -#define GNUNET_new_array_3d(n, m, o, type) \ - (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, \ - __LINE__) - -/** - * @ingroup memory - * Wrapper around malloc. Allocates size bytes of memory. - * The memory will be zero'ed out. - * - * @param size the number of bytes to allocate, must be - * smaller than 40 MB. - * @return pointer to size bytes of memory, never NULL (!) - */ -#define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__) - -/** - * @ingroup memory - * Allocate and initialize a block of memory. - * - * @param buf data to initialize the block with - * @param size the number of bytes in buf (and size of the allocation) - * @return pointer to size bytes of memory, never NULL (!) - */ -#define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__) - -/** - * @ingroup memory - * Wrapper around malloc. Allocates size bytes of memory. - * The memory will be zero'ed out. - * - * @param size the number of bytes to allocate - * @return pointer to size bytes of memory, NULL if we do not have enough memory - */ -#define GNUNET_malloc_large(size) \ - GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) - - -/** - * @ingroup memory - * Wrapper around realloc. Reallocates size bytes of memory. - * The content of the intersection of the new and old size will be unchanged. - * - * @param ptr the pointer to reallocate - * @param size the number of bytes to reallocate - * @return pointer to size bytes of memory - */ -#define GNUNET_realloc(ptr, size) \ - GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) - - -/** - * @ingroup memory - * Wrapper around free. Frees the memory referred to by ptr. - * Note that it is generally better to free memory that was - * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free_nz. - * - * @param ptr location where to free the memory. ptr must have - * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed. - */ -#define GNUNET_free_nz(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) - - -/** - * @ingroup memory - * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL. - * Note that it is generally better to free memory that was - * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free. - * - * @a ptr will be set to NULL. Use #GNUNET_free_nz() if @a ptr is not an L-value. - * - * @param ptr location where to free the memory. ptr must have - * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed. - */ -#define GNUNET_free(ptr) do { \ - GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ - ptr = NULL; \ -} while (0) - - -/** - * @ingroup memory - * Wrapper around #GNUNET_xstrdup_. Makes a copy of the zero-terminated string - * pointed to by a. - * - * @param a pointer to a zero-terminated string - * @return a copy of the string including zero-termination - */ -#define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) - - -/** - * @ingroup memory - * Wrapper around #GNUNET_xstrndup_. Makes a partial copy of the string - * pointed to by a. - * - * @param a pointer to a string - * @param length of the string to duplicate - * @return a partial copy of the string including zero-termination - */ -#define GNUNET_strndup(a, length) \ - GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) - -/** - * @ingroup memory - * Grow a well-typed (!) array. This is a convenience - * method to grow a vector @a arr of size @a size - * to the new (target) size @a tsize. - * <p> - * - * Example (simple, well-typed stack): - * - * <pre> - * static struct foo * myVector = NULL; - * static int myVecLen = 0; - * - * static void push(struct foo * elem) { - * GNUNET_array_grow(myVector, myVecLen, myVecLen+1); - * GNUNET_memcpy(&myVector[myVecLen-1], elem, sizeof(struct foo)); - * } - * - * static void pop(struct foo * elem) { - * if (myVecLen == 0) die(); - * GNUNET_memcpy(elem, myVector[myVecLen-1], sizeof(struct foo)); - * GNUNET_array_grow(myVector, myVecLen, myVecLen-1); - * } - * </pre> - * - * @param arr base-pointer of the vector, may be NULL if size is 0; - * will be updated to reflect the new address. The TYPE of - * arr is important since size is the number of elements and - * not the size in bytes - * @param size the number of elements in the existing vector (number - * of elements to copy over), will be updated with the new - * array size - * @param tsize the target size for the resulting vector, use 0 to - * free the vector (then, arr will be NULL afterwards). - */ -#define GNUNET_array_grow(arr, size, tsize) \ - GNUNET_xgrow_ ((void **) &(arr), \ - sizeof((arr)[0]), \ - &size, \ - tsize, \ - __FILE__, \ - __LINE__) - -/** - * @ingroup memory - * Append an element to an array (growing the array by one). - * - * @param arr base-pointer of the vector, may be NULL if @a len is 0; - * will be updated to reflect the new address. The TYPE of - * arr is important since size is the number of elements and - * not the size in bytes - * @param len the number of elements in the existing vector (number - * of elements to copy over), will be updated with the new - * array length - * @param element the element that will be appended to the array - */ -#define GNUNET_array_append(arr, len, element) \ - do \ - { \ - GNUNET_assert ((len) + 1 > (len)); \ - GNUNET_array_grow (arr, len, len + 1); \ - (arr) [len - 1] = element; \ - } while (0) - - -/** - * @ingroup memory - * Append @a arr2 to @a arr1 (growing @a arr1 - * as needed). The @a arr2 array is left unchanged. Naturally - * this function performs a shallow copy. Both arrays must have - * the same type for their elements. - * - * @param arr1 base-pointer of the vector, may be NULL if @a len is 0; - * will be updated to reflect the new address. The TYPE of - * arr is important since size is the number of elements and - * not the size in bytes - * @param len1 the number of elements in the existing vector (number - * of elements to copy over), will be updated with the new - * array size - * @param arr2 base-pointer a second array to concatenate, may be NULL if @a len2 is 0; - * will be updated to reflect the new address. The TYPE of - * arr is important since size is the number of elements and - * not the size in bytes - * @param len2 the number of elements in the existing vector (number - * of elements to copy over), will be updated with the new - * array size - - */ -#define GNUNET_array_concatenate(arr1, len1, arr2, len2) \ - do \ - { \ - const typeof (*arr2) * _a1 = (arr1); \ - const typeof (*arr1) * _a2 = (arr2); \ - GNUNET_assert ((len1) + (len2) >= (len1)); \ - GNUNET_assert (SIZE_MAX / sizeof (*_a1) >= ((len1) + (len2))); \ - GNUNET_array_grow (arr1, len1, (len1) + (len2)); \ - memcpy (&(arr1) [(len1) - (len2)], _a2, (len2) * sizeof (*arr1)); \ - } while (0) - - -/** - * @ingroup memory - * Like snprintf, just aborts if the buffer is of insufficient size. - * - * @param buf pointer to buffer that is written to - * @param size number of bytes in @a buf - * @param format format strings - * @param ... data for format string - * @return number of bytes written to buf or negative value on error - */ -int -GNUNET_snprintf (char *buf, - size_t size, - const char *format, - ...) -__attribute__ ((format (printf, 3, 4))); - - -/** - * @ingroup memory - * Like asprintf, just portable. - * - * @param buf set to a buffer of sufficient size (allocated, caller must free) - * @param format format string (see printf, fprintf, etc.) - * @param ... data for format string - * @return number of bytes in "*buf" excluding 0-termination - */ -int -GNUNET_asprintf (char **buf, - const char *format, - ...) -__attribute__ ((format (printf, 2, 3))); - - -/* ************** internal implementations, use macros above! ************** */ - -/** - * Allocate memory. Checks the return value, aborts if no more - * memory is available. Don't use GNUNET_xmalloc_ directly. Use the - * #GNUNET_malloc macro. - * The memory will be zero'ed out. - * - * @param size number of bytes to allocate - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return allocated memory, never NULL - */ -void * -GNUNET_xmalloc_ (size_t size, - const char *filename, - int linenumber); - - -/** - * Allocate memory for a two dimensional array in one block - * and set up pointers. Aborts if no more memory is available. - * Don't use GNUNET_xnew_array_2d_ directly. Use the - * #GNUNET_new_array_2d macro. - * The memory of the elements will be zero'ed out. - * - * @param n size of the first dimension - * @param m size of the second dimension - * @param elementSize size of a single element in bytes - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return allocated memory, never NULL - */ -void ** -GNUNET_xnew_array_2d_ (size_t n, - size_t m, - size_t elementSize, - const char *filename, - int linenumber); - - -/** - * Allocate memory for a three dimensional array in one block - * and set up pointers. Aborts if no more memory is available. - * Don't use GNUNET_xnew_array_3d_ directly. Use the - * #GNUNET_new_array_3d macro. - * The memory of the elements will be zero'ed out. - * - * @param n size of the first dimension - * @param m size of the second dimension - * @param o size of the third dimension - * @param elementSize size of a single element in bytes - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return allocated memory, never NULL - */ -void *** -GNUNET_xnew_array_3d_ (size_t n, - size_t m, - size_t o, - size_t elementSize, - const char *filename, - int linenumber); - - -/** - * Allocate and initialize memory. Checks the return value, aborts if no more - * memory is available. Don't use GNUNET_xmemdup_ directly. Use the - * #GNUNET_memdup macro. - * - * @param buf buffer to initialize from (must contain size bytes) - * @param size number of bytes to allocate - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return allocated memory, never NULL - */ -void * -GNUNET_xmemdup_ (const void *buf, - size_t size, - const char *filename, - int linenumber); - - -/** - * Allocate memory. This function does not check if the allocation - * request is within reasonable bounds, allowing allocations larger - * than 40 MB. If you don't expect the possibility of very large - * allocations, use #GNUNET_malloc instead. The memory will be zero'ed - * out. - * - * @param size number of bytes to allocate - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return pointer to size bytes of memory, NULL if we do not have enough memory - */ -void * -GNUNET_xmalloc_unchecked_ (size_t size, - const char *filename, - int linenumber); - - -/** - * Reallocate memory. Checks the return value, aborts if no more - * memory is available. - */ -void * -GNUNET_xrealloc_ (void *ptr, - size_t n, - const char *filename, - int linenumber); - - -/** - * Free memory. Merely a wrapper for the case that we - * want to keep track of allocations. Don't use GNUNET_xfree_ - * directly. Use the #GNUNET_free macro. - * - * @param ptr pointer to memory to free - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - */ -void -GNUNET_xfree_ (void *ptr, - const char *filename, - int linenumber); - - -/** - * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the #GNUNET_strdup macro. - * @param str string to duplicate - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return the duplicated string - */ -char * -GNUNET_xstrdup_ (const char *str, - const char *filename, - int linenumber); - -/** - * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. - * - * @param str string to duplicate - * @param len length of the string to duplicate - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - * @return the duplicated string - */ -char * -GNUNET_xstrndup_ (const char *str, - size_t len, - const char *filename, - int linenumber); - -/** - * Grow an array, the new elements are zeroed out. - * Grows old by (*oldCount-newCount)*elementSize - * bytes and sets *oldCount to newCount. - * - * Don't call GNUNET_xgrow_ directly. Use the #GNUNET_array_grow macro. - * - * @param old address of the pointer to the array - * *old may be NULL - * @param elementSize the size of the elements of the array - * @param oldCount address of the number of elements in the *old array - * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) - * @param filename where is this call being made (for debugging) - * @param linenumber line where this call is being made (for debugging) - */ -void -GNUNET_xgrow_ (void **old, - size_t elementSize, - unsigned int *oldCount, - unsigned int newCount, - const char *filename, - int linenumber); - - -/** - * @ingroup memory - * Create a copy of the given message. - * - * @param msg message to copy - * @return duplicate of the message - */ -struct GNUNET_MessageHeader * -GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); - - -/** - * Set the async scope for the current thread. - * - * @param aid the async scope identifier - * @param[out] old_scope location to save the old scope - */ -void -GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, - struct GNUNET_AsyncScopeSave *old_scope); - - -/** - * Clear the current thread's async scope. - * - * @param old_scope scope to restore - */ -void -GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope); - - -/** - * Get the current async scope. - * - * @param[out] scope_ret pointer to where the result is stored - */ -void -GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret); - - -/** - * Generate a fresh async scope identifier. - * - * @param[out] aid_ret pointer to where the result is stored - */ -void -GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret); - - -#if __STDC_VERSION__ < 199901L -#if __GNUC__ >= 2 -#define __func__ __FUNCTION__ -#else -#define __func__ "<unknown>" -#endif -#endif - - -/** - * Valid task priorities. Use these, do not pass random integers! - * For various reasons (#3862 -- building with QT Creator, and - * our restricted cross-compilation with emscripten) this cannot - * be in gnunet_scheduler_lib.h, but it works if we declare it here. - * Naturally, logically this is part of the scheduler. - */ -enum GNUNET_SCHEDULER_Priority -{ - /** - * Run with the same priority as the current job. - */ - GNUNET_SCHEDULER_PRIORITY_KEEP = 0, - - /** - * Run when otherwise idle. - */ - GNUNET_SCHEDULER_PRIORITY_IDLE = 1, - - /** - * Run as background job (higher than idle, - * lower than default). - */ - GNUNET_SCHEDULER_PRIORITY_BACKGROUND = 2, - - /** - * Run with the default priority (normal - * P2P operations). Any task that is scheduled - * without an explicit priority being specified - * will run with this priority. - */ - GNUNET_SCHEDULER_PRIORITY_DEFAULT = 3, - - /** - * Run with high priority (important requests). - * Higher than DEFAULT. - */ - GNUNET_SCHEDULER_PRIORITY_HIGH = 4, - - /** - * Run with priority for interactive tasks. - * Higher than "HIGH". - */ - GNUNET_SCHEDULER_PRIORITY_UI = 5, - - /** - * Run with priority for urgent tasks. Use - * for things like aborts and shutdowns that - * need to preempt "UI"-level tasks. - * Higher than "UI". - */ - GNUNET_SCHEDULER_PRIORITY_URGENT = 6, - - /** - * This is an internal priority level that is only used for tasks - * that are being triggered due to shutdown (they have automatically - * highest priority). User code must not use this priority level - * directly. Tasks run with this priority level that internally - * schedule other tasks will see their original priority level - * be inherited (unless otherwise specified). - */ - GNUNET_SCHEDULER_PRIORITY_SHUTDOWN = 7, - - /** - * Number of priorities (must be the last priority). - * This priority must not be used by clients. - */ - GNUNET_SCHEDULER_PRIORITY_COUNT = 8 -}; - - -/* *INDENT-OFF* */ - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif /* GNUNET_COMMON_H */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_config.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_config.h @@ -1,58 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2022 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#ifndef GNUNET_CONFIG_H -#define GNUNET_CONFIG_H - -/** - * @author Martin Schanzenbach - * - * @file - * Convenience header including public (!) information on the - * installed GNUnet configuration. - * - */ - -/* The version of GNUnet */ -#define GNUNET_VERSION "0.21.1-145-g8bfe56861" - -/* Major version */ -#define GNUNET_MAJOR_VERSION 0 - -/* Micro version */ -#define GNUNET_MINOR_VERSION 21 - -/* Mico version */ -#define GNUNET_MICRO_VERSION 1 - -/* Set to 1 is this is an experimental build */ -#define GNUNET_EXPERIMENTAL 1 - -/* Set to 1 if GnuTLS has DANE support */ -#define GNUNET_CURL_GNUTLS 0 - -/** - * Set to 1 if file-sharing meta data parsing is built with - * libextractor, which means that callers to the API must use also use - * libextractor. - */ -#define GNUNET_FS_EXTRACTOR_ENABLED 0 - -#endif diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_configuration_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_configuration_lib.h @@ -1,818 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2006, 2008, 2009, 2018 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Configuration API - * - * @defgroup configuration Configuration library - * Configuration management - * @{ - */ -#ifndef GNUNET_CONFIGURATION_LIB_H -#define GNUNET_CONFIGURATION_LIB_H - - -#include "gnunet_time_lib.h" - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/** - * A configuration object. - */ -struct GNUNET_CONFIGURATION_Handle; - -/** - * Create a new configuration object. - * @return fresh configuration object - */ -struct GNUNET_CONFIGURATION_Handle * -GNUNET_CONFIGURATION_create (void); - - -/** - * Duplicate an existing configuration object. - * - * @param cfg configuration to duplicate - * @return duplicate configuration - */ -struct GNUNET_CONFIGURATION_Handle * -GNUNET_CONFIGURATION_dup ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Destroy configuration object. - * - * @param cfg configuration to destroy - */ -void -GNUNET_CONFIGURATION_destroy ( - struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Load configuration. This function will first parse the - * defaults and then parse the specific configuration file - * to overwrite the defaults. - * - * @param cfg configuration to update - * @param filename name of the configuration file, NULL to load defaults - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_load ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *filename); - - -/** - * Load default configuration. This function will parse the - * defaults from the given @a defaults_d directory. - * - * @param cfg configuration to update - * @param defaults_d directory with the defaults - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_load_from ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *defaults_d); - - -/** - * Return GNUnet's default configuration. A new configuration is allocated - * each time and it's up to the caller to destroy it when done. This function - * returns GNUnet's configuration even when #GNUNET_OS_init has been called - * with a value different from #GNUNET_OS_project_data_default. - * - * @return a freshly allocated configuration - */ -struct GNUNET_CONFIGURATION_Handle * -GNUNET_CONFIGURATION_default (void); - - -/** - * Return the filename of the default configuration filename - * that is used when no explicit configuration entry point - * has been specified. - * - * @returns NULL if no default configuration file can be located, - * a newly allocated string otherwise - */ -char * -GNUNET_CONFIGURATION_default_filename (void); - - -/** - * Parse a configuration file, add all of the options in the - * file to the configuration environment. - * - * @param cfg configuration to update - * @param filename name of the configuration file - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_parse ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *filename); - - -/** - * Serializes the given configuration. - * - * @param cfg configuration to serialize - * @param size will be set to the size of the serialized memory block - * @return the memory block where the serialized configuration is - * present. This memory should be freed by the caller - */ -char * -GNUNET_CONFIGURATION_serialize ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - size_t *size); - - -/** - * Serializes the given configuration with diagnostics information. - * Diagnostics information will only be available if diagnostics - * have been enabled before parsing. - * - * @param cfg configuration to serialize - * @return the memory block where the serialized configuration is - * present. This memory should be freed by the caller - */ -char * -GNUNET_CONFIGURATION_serialize_diagnostics ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * De-serializes configuration - * - * @param cfg configuration to update - * @param mem the memory block of serialized configuration - * @param size the size of the memory block - * @param source_filename source filename, will be used - * to resolve relative \@INLINE\@ statements - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_deserialize ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *mem, - size_t size, - const char *source_filename); - - -/** - * Write configuration file. - * - * @param cfg configuration to write - * @param filename where to write the configuration - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_write ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *filename); - - -/** - * Write only configuration entries that have been changed to configuration file - * - * @param cfg_default default configuration - * @param cfg_new new configuration - * @param filename where to write the configuration diff between default and new - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_write_diffs ( - const struct GNUNET_CONFIGURATION_Handle *cfg_default, - const struct GNUNET_CONFIGURATION_Handle *cfg_new, - const char *filename); - - -/** - * Compute configuration with only entries that have been changed - * - * @param cfg_default original configuration - * @param cfg_new new configuration - * @return configuration with only the differences, never NULL - */ -struct GNUNET_CONFIGURATION_Handle * -GNUNET_CONFIGURATION_get_diff ( - const struct GNUNET_CONFIGURATION_Handle *cfg_default, - const struct GNUNET_CONFIGURATION_Handle *cfg_new); - - -/** - * Test if there are configuration options that were - * changed since the last save. - * - * @param cfg configuration to inspect - * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on error (i.e. last save failed) - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_is_dirty ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Signature of a function to be run with a configuration. - * - * @param cls closure - * @param cfg the configuration - * @return status code - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONFIGURATION_Callback)( - void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Parse a configuration file @a filename and run the function - * @a cb with the resulting configuration object. Then free the - * configuration object and return the status value from @a cb. - * - * @param filename configuration to parse, NULL for "default" - * @param cb function to run - * @param cb_cls closure for @a cb - * @return #GNUNET_SYSERR if parsing the configuration failed, - * otherwise return value from @a cb. - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_parse_and_run ( - const char *filename, - GNUNET_CONFIGURATION_Callback cb, - void *cb_cls); - -/** - * Enable extra diagnostics. Will produce more log output - * and allocate more memory. - * - * @param cfg configuration handle - */ -void -GNUNET_CONFIGURATION_enable_diagnostics ( - struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Function to iterate over options. - * - * @param cls closure - * @param section name of the section - * @param option name of the option - * @param value value of the option - */ -typedef void -(*GNUNET_CONFIGURATION_Iterator) (void *cls, - const char *section, - const char *option, - const char *value); - - -/** - * Function to iterate over section. - * - * @param cls closure - * @param section name of the section - */ -typedef void -(*GNUNET_CONFIGURATION_SectionIterator) (void *cls, - const char *section); - - -/** - * Iterate over all options in the configuration. - * - * @param cfg configuration to inspect - * @param iter function to call on each option - * @param iter_cls closure for @a iter - */ -void -GNUNET_CONFIGURATION_iterate ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_CONFIGURATION_Iterator iter, - void *iter_cls); - - -/** - * Iterate over all sections in the configuration. - * - * @param cfg configuration to inspect - * @param iter function to call on each section - * @param iter_cls closure for @a iter - */ -void -GNUNET_CONFIGURATION_iterate_sections ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_CONFIGURATION_SectionIterator iter, - void *iter_cls); - - -/** - * Remove the given section and all options in it. - * - * @param cfg configuration to inspect - * @param section name of the section to remove - */ -void -GNUNET_CONFIGURATION_remove_section ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section); - - -/** - * Get a configuration value that should be a number. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param number where to store the numeric value of the option - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_number ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - unsigned long long *number); - - -/** - * Get a configuration value that should be a floating point number. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param number where to store the floating value of the option - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_float ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - float *number); - - -/** - * Get a configuration value that should be a relative time. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param time set to the time value stored in the configuration - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_time ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - struct GNUNET_TIME_Relative *time); - - -/** - * Get a configuration value that should be a size in bytes. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param size set to the size in bytes as stored in the configuration - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_size ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - unsigned long long *size); - - -/** - * Test if we have a value for a particular option - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @return #GNUNET_YES if so, #GNUNET_NO if not. - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option); - - -/** - * Get a configuration value that should be a string. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param value will be set to a freshly allocated configuration - * value, or NULL if option is not specified - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_string ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - char **value); - - -/** - * Get a configuration value that should be the name of a file - * or directory. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param value will be set to a freshly allocated configuration - * value, or NULL if option is not specified - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_filename ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - char **value); - - -/** - * Iterate over the set of filenames stored in a configuration value. - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param cb function to call on each filename - * @param cb_cls closure for @a cb - * @return number of filenames iterated over, -1 on error - */ -int -GNUNET_CONFIGURATION_iterate_value_filenames ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - GNUNET_FileNameCallback cb, - void *cb_cls); - - -/** - * Iterate over values of a section in the configuration. - * - * @param cfg configuration to inspect - * @param section the section - * @param iter function to call on each option - * @param iter_cls closure for @a iter - */ -void -GNUNET_CONFIGURATION_iterate_section_values ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - GNUNET_CONFIGURATION_Iterator iter, - void *iter_cls); - - -/** - * Get a configuration value that should be in a set of - * predefined strings - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @param choices NULL-terminated list of legal values - * @param value will be set to an entry in the legal list, - * or NULL if option is not specified and no default given - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_choice ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - const char *const *choices, - const char **value); - - -/** - * Get a configuration value that should be in a set of - * "YES" or "NO". - * - * @param cfg configuration to inspect - * @param section section of interest - * @param option option of interest - * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET_SYSERR - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_value_yesno ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option); - - -/** - * Get Crockford32-encoded fixed-size binary data from a configuration. - * - * @param cfg configuration to access - * @param section section to access - * @param option option to access - * @param buf where to store the decoded binary result - * @param buf_size exact number of bytes to store in @a buf - * @return #GNUNET_OK on success - * #GNUNET_NO is the value does not exist - * #GNUNET_SYSERR on decoding error - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - void *buf, - size_t buf_size); - - -/** - * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" - * where either in the "PATHS" section or the environment "FOO" is - * set to "DIRECTORY". We also support default expansion, - * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is - * set in PATHS or the environment, and otherwise to "default". Note - * that "default" itself can also be a $-expression, thus - * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined - * to VAR2. - * - * @param cfg configuration to use for path expansion - * @param orig string to $-expand (will be freed!) Note that multiple - * $-expressions can be present in this string. They will all be - * $-expanded. - * @return $-expanded string - */ -char * -GNUNET_CONFIGURATION_expand_dollar ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - char *orig); - - -/** - * Set a configuration value that should be a number. - * - * @param cfg configuration to update - * @param section section of interest - * @param option option of interest - * @param number value to set - */ -void -GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - unsigned long long number); - - -/** - * Set a configuration value that should be a string. - * - * @param cfg configuration to update - * @param section section of interest - * @param option option of interest - * @param value value to set - */ -void -GNUNET_CONFIGURATION_set_value_string ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - const char *value); - - -/** - * Remove a filename from a configuration value that - * represents a list of filenames - * - * @param cfg configuration to update - * @param section section of interest - * @param option option of interest - * @param value filename to remove - * @return #GNUNET_OK on success, - * #GNUNET_SYSERR if the filename is not in the list - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_remove_value_filename ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - const char *value); - - -/** - * Append a filename to a configuration value that - * represents a list of filenames - * - * @param cfg configuration to update - * @param section section of interest - * @param option option of interest - * @param value filename to append - * @return #GNUNET_OK on success, - * #GNUNET_SYSERR if the filename already in the list - */ -enum GNUNET_GenericReturnValue -GNUNET_CONFIGURATION_append_value_filename ( - struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - const char *value); - - -/** - * Closure for #GNUNET_CONFIGURATION_config_tool_run() - * with settings for what should be done with the - * configuration. - */ -struct GNUNET_CONFIGURATION_ConfigSettings -{ - - /** - * Must be set to the API version, i.e. #GNUNET_UTIL_VERSION. Used to - * detect which version of the struct the client is using. - */ - unsigned int api_version; - - /** - * Name of the section - */ - char *section; - - /** - * Name of the option - */ - char *option; - - /** - * Value to set - */ - char *value; - - /** - * Treat option as a filename. - */ - int is_filename; - - /** - * Whether to show the sections. - */ - int list_sections; - - /** - * Should we write out the configuration file, even if no value was changed? - */ - int rewrite; - - /** - * Should we give extra diagnostics? - */ - int diagnostics; - - /** - * Should the generated configuration file contain the whole configuration? - */ - int full; - - /** - * Return value from the operation, to be returned - * from 'main'. - */ - int global_ret; - -}; - - -/** - * Macro that expands to a set of GNUNET-getopt directives - * to initialize a `struct GNUNET_CONFIGURATION_ConfigSettings` - * from the command line. - * - * @param cs configuration settings to initialize - */ -#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \ - GNUNET_GETOPT_option_flag ( \ - 'F', \ - "full", \ - gettext_noop ( \ - "write the full configuration file, including default values"), \ - &(cs)->full), \ - GNUNET_GETOPT_option_flag ( \ - 'f', \ - "filename", \ - gettext_noop ( \ - "interpret option value as a filename (with $-expansion)"), \ - &(cs)->is_filename), \ - GNUNET_GETOPT_option_string ('o', \ - "option", \ - "OPTION", \ - gettext_noop ( \ - "name of the option to access"), \ - &(cs)->option), \ - GNUNET_GETOPT_option_flag ( \ - 'r', \ - "rewrite", \ - gettext_noop ( \ - "rewrite the configuration file, even if nothing changed"), \ - &(cs)->rewrite), \ - GNUNET_GETOPT_option_flag ( \ - 'd', \ - "diagnostics", \ - gettext_noop ( \ - "output extra diagnostics"), \ - &(cs)->diagnostics), \ - GNUNET_GETOPT_option_flag ('S', \ - "list-sections", \ - gettext_noop ( \ - "print available configuration sections"), \ - &(cs)->list_sections), \ - GNUNET_GETOPT_option_string ('s', \ - "section", \ - "SECTION", \ - gettext_noop ( \ - "name of the section to access"), \ - &(cs)->section), \ - GNUNET_GETOPT_option_string ('V', \ - "value", \ - "VALUE", \ - gettext_noop ("value to set"), \ - &(cs)->value) - - -/** - * Free resources associated with @a cs. - * - * @param[in] cs settings to free (actual memory - * of @a cs itself is not released) - */ -void -GNUNET_CONFIGURATION_config_settings_free ( - struct GNUNET_CONFIGURATION_ConfigSettings *cs); - - -/** - * Main task to run to perform operations typical for - * gnunet-config as per the configuration settings - * given in @a cls. - * - * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings` - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, - * can be NULL!) - * @param cfg configuration - */ -void -GNUNET_CONFIGURATION_config_tool_run ( - void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */ /* end of group configuration */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_container_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_container_lib.h @@ -1,2354 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2015 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * @author Nils Durner - * - * @file - * Container classes for GNUnet - * - * @addtogroup container - * Common data structures in GNUnet programs - * @{ - * - * @defgroup hashmap MultiHashMap - * Hash map with multiple values per key. - * - * @see [Documentation](https://gnunet.org/util_multihashmap) - * - * @defgroup heap Heap - * Min- or max-heap with arbitrary element removal - * - * @defgroup bloomfilter Bloom filter - * Probabilistic set tests - * - * @defgroup dll Doubly-linked list - * - * @see [Documentation](https://gnunet.org/mdll-api) - * - * - * @} - */ - -#include "gnunet_common.h" -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_CONTAINER_LIB_H -#define GNUNET_CONTAINER_LIB_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/* add error and config prototypes */ - -#include "gnunet_crypto_lib.h" - - -/** - * Try to compress the given block of data using libz. Only returns - * the compressed block if compression worked and the new block is - * actually smaller. Decompress using #GNUNET_decompress(). - * - * @param data block to compress; if compression - * resulted in a smaller block, the first - * bytes of data are updated to the compressed - * data - * @param old_size number of bytes in data - * @param[out] result set to the compressed data, if compression worked - * @param[out] new_size set to size of result, if compression worked - * @return #GNUNET_YES if compression reduce the size, - * #GNUNET_NO if compression did not help - */ -int -GNUNET_try_compression (const char *data, - size_t old_size, - char **result, - size_t *new_size); - - -/** - * Decompress input, return the decompressed data as output. Dual to - * #GNUNET_try_compression(). Caller must set @a output_size to the - * number of bytes that were originally compressed. - * - * @param input compressed data - * @param input_size number of bytes in input - * @param output_size expected size of the output - * @return NULL on error, buffer of @a output_size decompressed bytes otherwise - */ -char * -GNUNET_decompress (const char *input, size_t input_size, size_t output_size); - - -/* ******************* bloomfilter ***************** */ - -/** - * @brief bloomfilter representation (opaque) - * @ingroup bloomfilter - */ -struct GNUNET_CONTAINER_BloomFilter; - - -/** - * @ingroup bloomfilter - * Iterator over `struct GNUNET_HashCode`. - * - * @param cls closure - * @param next set to the next hash code - * @return #GNUNET_YES if next was updated - * #GNUNET_NO if there are no more entries - */ -typedef int (*GNUNET_CONTAINER_HashCodeIterator) (void *cls, - struct GNUNET_HashCode *next); - - -/** - * @ingroup bloomfilter - * Load a Bloom filter from a file. - * - * @param filename the name of the file (or the prefix) - * @param size the size of the bloom-filter (number of - * bytes of storage space to use); will be rounded up - * to next power of 2 - * @param k the number of #GNUNET_CRYPTO_hash-functions to apply per - * element (number of bits set per element in the set) - * @return the bloomfilter - */ -struct GNUNET_CONTAINER_BloomFilter * -GNUNET_CONTAINER_bloomfilter_load (const char *filename, - size_t size, - unsigned int k); - - -/** - * @ingroup bloomfilter - * Create a Bloom filter from raw bits. - * - * @param data the raw bits in memory (maybe NULL, - * in which case all bits should be considered - * to be zero). - * @param size the size of the bloom-filter (number of - * bytes of storage space to use); also size of @a data - * -- unless data is NULL. Must be a power of 2. - * @param k the number of #GNUNET_CRYPTO_hash-functions to apply per - * element (number of bits set per element in the set) - * @return the bloomfilter - */ -struct GNUNET_CONTAINER_BloomFilter * -GNUNET_CONTAINER_bloomfilter_init (const char *data, - size_t size, - unsigned int k); - - -/** - * @ingroup bloomfilter - * Copy the raw data of this Bloom filter into - * the given data array. - * - * @param data where to write the data - * @param size the size of the given @a data array - * @return #GNUNET_SYSERR if the data array of the wrong size - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_bloomfilter_get_raw_data ( - const struct GNUNET_CONTAINER_BloomFilter *bf, - char *data, - size_t size); - - -/** - * @ingroup bloomfilter - * Test if an element is in the filter. - * - * @param e the element - * @param bf the filter - * @return true if the element is in the filter, false if not - */ -bool -GNUNET_CONTAINER_bloomfilter_test ( - const struct GNUNET_CONTAINER_BloomFilter *bf, - const struct GNUNET_HashCode *e); - - -/** - * @ingroup bloomfilter - * Add an element to the filter. - * - * @param bf the filter - * @param e the element - */ -void -GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf, - const struct GNUNET_HashCode *e); - - -/** - * @ingroup bloomfilter - * Remove an element from the filter. - * - * @param bf the filter - * @param e the element to remove - */ -void -GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf, - const struct GNUNET_HashCode *e); - - -/** - * @ingroup bloomfilter - * Create a copy of a bloomfilter. - * - * @param bf the filter - * @return copy of bf - */ -struct GNUNET_CONTAINER_BloomFilter * -GNUNET_CONTAINER_bloomfilter_copy ( - const struct GNUNET_CONTAINER_BloomFilter *bf); - - -/** - * @ingroup bloomfilter - * Free the space associated with a filter - * in memory, flush to drive if needed (do not - * free the space on the drive). - * - * @param bf the filter - */ -void -GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf); - - -/** - * Get the number of the addresses set per element in the bloom filter. - * - * @param bf the filter - * @return addresses set per element in the bf - */ -size_t -GNUNET_CONTAINER_bloomfilter_get_element_addresses ( - const struct GNUNET_CONTAINER_BloomFilter *bf); - - -/** - * @ingroup bloomfilter - * Get size of the bloom filter. - * - * @param bf the filter - * @return number of bytes used for the data of the bloom filter - */ -size_t -GNUNET_CONTAINER_bloomfilter_get_size ( - const struct GNUNET_CONTAINER_BloomFilter *bf); - - -/** - * @ingroup bloomfilter - * Reset a Bloom filter to empty. - * - * @param bf the filter - */ -void -GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf); - - -/** - * @ingroup bloomfilter - * "or" the entries of the given raw data array with the - * data of the given Bloom filter. Assumes that - * the @a size of the @a data array and the current filter - * match. - * - * @param bf the filter - * @param data data to OR-in - * @param size size of @a data - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, - const char *data, - size_t size); - - -/** - * @ingroup bloomfilter - * "or" the entries of the given raw data array with the - * data of the given Bloom filter. Assumes that - * the size of the two filters matches. - * - * @param bf the filter - * @param to_or the bloomfilter to or-in - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_bloomfilter_or2 ( - struct GNUNET_CONTAINER_BloomFilter *bf, - const struct GNUNET_CONTAINER_BloomFilter *to_or); - - -/** - * @ingroup bloomfilter - * Resize a bloom filter. Note that this operation - * is pretty costly. Essentially, the Bloom filter - * needs to be completely re-build. - * - * @param bf the filter - * @param iterator an iterator over all elements stored in the BF - * @param iterator_cls closure for @a iterator - * @param size the new size for the filter - * @param k the new number of #GNUNET_CRYPTO_hash-function to apply per element - */ -void -GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, - GNUNET_CONTAINER_HashCodeIterator iterator, - void *iterator_cls, - size_t size, - unsigned int k); - - - -/* ******************************* HashMap **************************** */ - -/** - * @ingroup hashmap - * Opaque handle for a HashMap. - */ -struct GNUNET_CONTAINER_MultiHashMap; - -/** - * @ingroup hashmap - * Opaque handle to an iterator over - * a multihashmap. - */ -struct GNUNET_CONTAINER_MultiHashMapIterator; - -/** - * @ingroup hashmap - * Options for storing values in the HashMap. - */ -enum GNUNET_CONTAINER_MultiHashMapOption -{ - /** - * @ingroup hashmap - * If a value with the given key exists, replace it. Note that the - * old value would NOT be freed by replace (the application has to - * make sure that this happens if required). - */ - GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, - - /** - * @ingroup hashmap - * Allow multiple values with the same key. - */ - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, - - /** - * @ingroup hashmap - * There must only be one value per key; storing a value should fail - * if a value under the same key already exists. - */ - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, - - /** - * @ingroup hashmap There must only be one value per key, but don't - * bother checking if a value already exists (faster than - * #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY; implemented - * just like #GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE but this - * option documents better what is intended if - * #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY is what is - * desired). - */ - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST -}; - - -/** - * @ingroup hashmap - * Iterator over hash map entries. - * - * @param cls closure - * @param key current key code - * @param value value in the hash map - * @return #GNUNET_YES if we should continue to - * iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_MultiHashMapIteratorCallback)( - void *cls, - const struct GNUNET_HashCode *key, - void *value); - - -/** - * @ingroup hashmap - * Create a multi hash map. - * - * @param len initial size (map will grow as needed) - * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default; - * #GNUNET_YES means that on 'put', the 'key' does not have - * to be copied as the destination of the pointer is - * guaranteed to be life as long as the value is stored in - * the hashmap. This can significantly reduce memory - * consumption, but of course is also a recipe for - * heap corruption if the assumption is not true. Only - * use this if (1) memory use is important in this case and - * (2) you have triple-checked that the invariant holds - * @return NULL on error - */ -struct GNUNET_CONTAINER_MultiHashMap * -GNUNET_CONTAINER_multihashmap_create (unsigned int len, - int do_not_copy_keys); - - -/** - * @ingroup hashmap - * Destroy a hash map. Will not free any values - * stored in the hash map! - * - * @param map the map - */ -void -GNUNET_CONTAINER_multihashmap_destroy (struct - GNUNET_CONTAINER_MultiHashMap *map); - - -/** - * @ingroup hashmap - * Given a key find a value in the map matching the key. - * - * @param map the map - * @param key what to look for - * @return NULL if no value was found; note that - * this is indistinguishable from values that just - * happen to be NULL; use "contains" to test for - * key-value pairs with value NULL - */ -void * -GNUNET_CONTAINER_multihashmap_get ( - const struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key); - - -/** - * @ingroup hashmap - * Remove the given key-value pair from the map. Note that if the - * key-value pair is in the map multiple times, only one of the pairs - * will be removed. - * - * @param map the map - * @param key key of the key-value pair - * @param value value of the key-value pair - * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair - * is not in the map - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key, - const void *value); - -/** - * @ingroup hashmap - * Remove all entries for the given key from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @param key identifies values to be removed - * @return number of values removed - */ -int -GNUNET_CONTAINER_multihashmap_remove_all ( - struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key); - - -/** - * @ingroup hashmap - * Remove all entries from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @return number of values removed - */ -unsigned int -GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map); - - -/** - * @ingroup hashmap - * Check if the map contains any value under the given - * key (including values that are NULL). - * - * @param map the map - * @param key the key to test if a value exists for it - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_contains ( - const struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key); - - -/** - * @ingroup hashmap - * Check if the map contains the given value under the given - * key. - * - * @param map the map - * @param key the key to test if a value exists for it - * @param value value to test for - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_contains_value ( - const struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key, - const void *value); - - -/** - * @ingroup hashmap - * Store a key-value pair in the map. - * - * @param map the map - * @param key key to use - * @param value value to use - * @param opt options for put - * @return #GNUNET_OK on success, - * #GNUNET_NO if a value was replaced (with REPLACE) - * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the - * value already exists - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_put ( - struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key, - void *value, - enum GNUNET_CONTAINER_MultiHashMapOption opt); - -/** - * @ingroup hashmap - * Get the number of key-value pairs in the map. - * - * @param map the map - * @return the number of key value pairs - */ -unsigned int -GNUNET_CONTAINER_multihashmap_size ( - const struct GNUNET_CONTAINER_MultiHashMap *map); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map. - * - * @param map the map - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multihashmap_iterate ( - struct GNUNET_CONTAINER_MultiHashMap *map, - GNUNET_CONTAINER_MultiHashMapIteratorCallback it, - void *it_cls); - - -/** - * @ingroup hashmap - * Create an iterator for a multihashmap. - * The iterator can be used to retrieve all the elements in the multihashmap - * one by one, without having to handle all elements at once (in contrast to - * #GNUNET_CONTAINER_multihashmap_iterate). Note that the iterator can not be - * used anymore if elements have been removed from 'map' after the creation of - * the iterator, or 'map' has been destroyed. Adding elements to 'map' may - * result in skipped or repeated elements. - * - * @param map the map to create an iterator for - * @return an iterator over the given multihashmap @a map - */ -struct GNUNET_CONTAINER_MultiHashMapIterator * -GNUNET_CONTAINER_multihashmap_iterator_create ( - const struct GNUNET_CONTAINER_MultiHashMap *map); - - -/** - * @ingroup hashmap - * Retrieve the next element from the hash map at the iterator's - * position. If there are no elements left, #GNUNET_NO is returned, - * and @a key and @a value are not modified. This operation is only - * allowed if no elements have been removed from the multihashmap - * since the creation of @a iter, and the map has not been destroyed. - * Adding elements may result in repeating or skipping elements. - * - * @param iter the iterator to get the next element from - * @param key pointer to store the key in, can be NULL - * @param value pointer to store the value in, can be NULL - * @return #GNUNET_YES we returned an element, - * #GNUNET_NO if we are out of elements - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_iterator_next ( - struct GNUNET_CONTAINER_MultiHashMapIterator *iter, - struct GNUNET_HashCode *key, - const void **value); - - -/** - * @ingroup hashmap - * Destroy a multihashmap iterator. - * - * @param iter the iterator to destroy - */ -void -GNUNET_CONTAINER_multihashmap_iterator_destroy ( - struct GNUNET_CONTAINER_MultiHashMapIterator *iter); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map that match a particular key. - * - * @param map the map - * @param key key that the entries must correspond to - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap_get_multiple ( - struct GNUNET_CONTAINER_MultiHashMap *map, - const struct GNUNET_HashCode *key, - GNUNET_CONTAINER_MultiHashMapIteratorCallback it, - void *it_cls); - - -/** - * @ingroup hashmap - * Call @a it on a random value from the map, or not at all - * if the map is empty. Note that this function has linear - * complexity (in the size of the map). - * - * @param map the map - * @param it function to call on a random entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, zero or one. - */ -unsigned int -GNUNET_CONTAINER_multihashmap_get_random ( - const struct GNUNET_CONTAINER_MultiHashMap *map, - GNUNET_CONTAINER_MultiHashMapIteratorCallback it, - void *it_cls); - - -/* ***************** Version of Multihashmap for peer identities ****************** */ - -/** - * @ingroup hashmap - * Iterator over hash map entries. - * - * @param cls closure - * @param key current public key - * @param value value in the hash map - * @return #GNUNET_YES if we should continue to - * iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_PeerMapIterator)( - void *cls, - const struct GNUNET_PeerIdentity *key, - void *value); - - -/** - * Hash map from peer identities to values. - */ -struct GNUNET_CONTAINER_MultiPeerMap; - - -/** - * @ingroup hashmap - * Create a multi peer map (hash map for public keys of peers). - * - * @param len initial size (map will grow as needed) - * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default; - * #GNUNET_YES means that on 'put', the 'key' does not have - * to be copied as the destination of the pointer is - * guaranteed to be life as long as the value is stored in - * the hashmap. This can significantly reduce memory - * consumption, but of course is also a recipe for - * heap corruption if the assumption is not true. Only - * use this if (1) memory use is important in this case and - * (2) you have triple-checked that the invariant holds - * @return NULL on error - */ -struct GNUNET_CONTAINER_MultiPeerMap * -GNUNET_CONTAINER_multipeermap_create (unsigned int len, int do_not_copy_keys); - - -/** - * @ingroup hashmap - * Destroy a hash map. Will not free any values - * stored in the hash map! - * - * @param map the map - */ -void -GNUNET_CONTAINER_multipeermap_destroy ( - struct GNUNET_CONTAINER_MultiPeerMap *map); - - -/** - * @ingroup hashmap - * Given a key find a value in the map matching the key. - * - * @param map the map - * @param key what to look for - * @return NULL if no value was found; note that - * this is indistinguishable from values that just - * happen to be NULL; use "contains" to test for - * key-value pairs with value NULL - */ -void * -GNUNET_CONTAINER_multipeermap_get ( - const struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key); - - -/** - * @ingroup hashmap - * Remove the given key-value pair from the map. Note that if the - * key-value pair is in the map multiple times, only one of the pairs - * will be removed. - * - * @param map the map - * @param key key of the key-value pair - * @param value value of the key-value pair - * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair - * is not in the map - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key, - const void *value); - -/** - * @ingroup hashmap - * Remove all entries for the given key from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @param key identifies values to be removed - * @return number of values removed - */ -int -GNUNET_CONTAINER_multipeermap_remove_all ( - struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key); - - -/** - * @ingroup hashmap - * Check if the map contains any value under the given - * key (including values that are NULL). - * - * @param map the map - * @param key the key to test if a value exists for it - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multipeermap_contains ( - const struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key); - - -/** - * @ingroup hashmap - * Check if the map contains the given value under the given - * key. - * - * @param map the map - * @param key the key to test if a value exists for it - * @param value value to test for - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multipeermap_contains_value ( - const struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key, - const void *value); - - -/** - * @ingroup hashmap - * Store a key-value pair in the map. - * - * @param map the map - * @param key key to use - * @param value value to use - * @param opt options for put - * @return #GNUNET_OK on success, - * #GNUNET_NO if a value was replaced (with REPLACE) - * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the - * value already exists - */ -int -GNUNET_CONTAINER_multipeermap_put ( - struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key, - void *value, - enum GNUNET_CONTAINER_MultiHashMapOption opt); - - -/** - * @ingroup hashmap - * Get the number of key-value pairs in the map. - * - * @param map the map - * @return the number of key value pairs - */ -unsigned int -GNUNET_CONTAINER_multipeermap_size ( - const struct GNUNET_CONTAINER_MultiPeerMap *map); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map. - * - * @param map the map - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multipeermap_iterate ( - struct GNUNET_CONTAINER_MultiPeerMap *map, - GNUNET_CONTAINER_PeerMapIterator it, - void *it_cls); - - -struct GNUNET_CONTAINER_MultiPeerMapIterator; -/** - * @ingroup hashmap - * Create an iterator for a multihashmap. - * The iterator can be used to retrieve all the elements in the multihashmap - * one by one, without having to handle all elements at once (in contrast to - * #GNUNET_CONTAINER_multipeermap_iterate). Note that the iterator can not be - * used anymore if elements have been removed from @a map after the creation of - * the iterator, or 'map' has been destroyed. Adding elements to @a map may - * result in skipped or repeated elements. - * - * @param map the map to create an iterator for - * @return an iterator over the given multihashmap @a map - */ -struct GNUNET_CONTAINER_MultiPeerMapIterator * -GNUNET_CONTAINER_multipeermap_iterator_create ( - const struct GNUNET_CONTAINER_MultiPeerMap *map); - - -/** - * @ingroup hashmap - * Retrieve the next element from the hash map at the iterator's - * position. If there are no elements left, #GNUNET_NO is returned, - * and @a key and @a value are not modified. - * - * This operation is only allowed if no elements have been removed - * from the multihashmap since the creation of @a iter, and the map - * has not been destroyed. - * - * Adding elements may result in repeating or skipping elements. - * - * @param iter the iterator to get the next element from - * @param key pointer to store the key in, can be NULL - * @param value pointer to store the value in, can be NULL - * @return #GNUNET_YES we returned an element, - * #GNUNET_NO if we are out of elements - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multipeermap_iterator_next ( - struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, - struct GNUNET_PeerIdentity *key, - const void **value); - - -/** - * @ingroup hashmap - * Destroy a multipeermap iterator. - * - * @param iter the iterator to destroy - */ -void -GNUNET_CONTAINER_multipeermap_iterator_destroy ( - struct GNUNET_CONTAINER_MultiPeerMapIterator *iter); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map that match a particular key. - * - * @param map the map - * @param key public key that the entries must correspond to - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multipeermap_get_multiple ( - struct GNUNET_CONTAINER_MultiPeerMap *map, - const struct GNUNET_PeerIdentity *key, - GNUNET_CONTAINER_PeerMapIterator it, - void *it_cls); - - -/** - * @ingroup hashmap - * Call @a it on a random value from the map, or not at all - * if the map is empty. Note that this function has linear - * complexity (in the size of the map). - * - * @param map the map - * @param it function to call on a random entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, zero or one. - */ -unsigned int -GNUNET_CONTAINER_multipeermap_get_random ( - const struct GNUNET_CONTAINER_MultiPeerMap *map, - GNUNET_CONTAINER_PeerMapIterator it, - void *it_cls); - - -/* ***************** Version of Multihashmap for short hashes ****************** */ - -/** - * @ingroup hashmap - * Iterator over hash map entries. - * - * @param cls closure - * @param key current public key - * @param value value in the hash map - * @return #GNUNET_YES if we should continue to - * iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_ShortmapIterator)( - void *cls, - const struct GNUNET_ShortHashCode *key, - void *value); - - -/** - * Hash map from peer identities to values. - */ -struct GNUNET_CONTAINER_MultiShortmap; - - -/** - * @ingroup hashmap - * Create a multi peer map (hash map for public keys of peers). - * - * @param len initial size (map will grow as needed) - * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default; - * #GNUNET_YES means that on 'put', the 'key' does not have - * to be copied as the destination of the pointer is - * guaranteed to be life as long as the value is stored in - * the hashmap. This can significantly reduce memory - * consumption, but of course is also a recipe for - * heap corruption if the assumption is not true. Only - * use this if (1) memory use is important in this case and - * (2) you have triple-checked that the invariant holds - * @return NULL on error - */ -struct GNUNET_CONTAINER_MultiShortmap * -GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys); - - -/** - * @ingroup hashmap - * Destroy a hash map. Will not free any values - * stored in the hash map! - * - * @param map the map - */ -void -GNUNET_CONTAINER_multishortmap_destroy ( - struct GNUNET_CONTAINER_MultiShortmap *map); - - -/** - * @ingroup hashmap - * Given a key find a value in the map matching the key. - * - * @param map the map - * @param key what to look for - * @return NULL if no value was found; note that - * this is indistinguishable from values that just - * happen to be NULL; use "contains" to test for - * key-value pairs with value NULL - */ -void * -GNUNET_CONTAINER_multishortmap_get ( - const struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key); - - -/** - * @ingroup hashmap - * Remove the given key-value pair from the map. Note that if the - * key-value pair is in the map multiple times, only one of the pairs - * will be removed. - * - * @param map the map - * @param key key of the key-value pair - * @param value value of the key-value pair - * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair - * is not in the map - */ -int -GNUNET_CONTAINER_multishortmap_remove ( - struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key, - const void *value); - -/** - * @ingroup hashmap - * Remove all entries for the given key from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @param key identifies values to be removed - * @return number of values removed - */ -int -GNUNET_CONTAINER_multishortmap_remove_all ( - struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key); - - -/** - * @ingroup hashmap - * Check if the map contains any value under the given - * key (including values that are NULL). - * - * @param map the map - * @param key the key to test if a value exists for it - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -int -GNUNET_CONTAINER_multishortmap_contains ( - const struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key); - - -/** - * @ingroup hashmap - * Check if the map contains the given value under the given - * key. - * - * @param map the map - * @param key the key to test if a value exists for it - * @param value value to test for - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -int -GNUNET_CONTAINER_multishortmap_contains_value ( - const struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key, - const void *value); - - -/** - * @ingroup hashmap - * Store a key-value pair in the map. - * - * @param map the map - * @param key key to use - * @param value value to use - * @param opt options for put - * @return #GNUNET_OK on success, - * #GNUNET_NO if a value was replaced (with REPLACE) - * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the - * value already exists - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multishortmap_put ( - struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key, - void *value, - enum GNUNET_CONTAINER_MultiHashMapOption opt); - - -/** - * @ingroup hashmap - * Get the number of key-value pairs in the map. - * - * @param map the map - * @return the number of key value pairs - */ -unsigned int -GNUNET_CONTAINER_multishortmap_size ( - const struct GNUNET_CONTAINER_MultiShortmap *map); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map. - * - * @param map the map - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multishortmap_iterate ( - struct GNUNET_CONTAINER_MultiShortmap *map, - GNUNET_CONTAINER_ShortmapIterator it, - void *it_cls); - - -struct GNUNET_CONTAINER_MultiShortmapIterator; - - -/** - * @ingroup hashmap - * Create an iterator for a multihashmap. - * The iterator can be used to retrieve all the elements in the multihashmap - * one by one, without having to handle all elements at once (in contrast to - * #GNUNET_CONTAINER_multishortmap_iterate). Note that the iterator can not be - * used anymore if elements have been removed from @a map after the creation of - * the iterator, or 'map' has been destroyed. Adding elements to @a map may - * result in skipped or repeated elements. - * - * @param map the map to create an iterator for - * @return an iterator over the given multihashmap @a map - */ -struct GNUNET_CONTAINER_MultiShortmapIterator * -GNUNET_CONTAINER_multishortmap_iterator_create ( - const struct GNUNET_CONTAINER_MultiShortmap *map); - - -/** - * @ingroup hashmap - * Retrieve the next element from the hash map at the iterator's - * position. If there are no elements left, #GNUNET_NO is returned, - * and @a key and @a value are not modified. This operation is only - * allowed if no elements have been removed from the multihashmap - * since the creation of @a iter, and the map has not been destroyed. - * Adding elements may result in repeating or skipping elements. - * - * @param iter the iterator to get the next element from - * @param key pointer to store the key in, can be NULL - * @param value pointer to store the value in, can be NULL - * @return #GNUNET_YES we returned an element, - * #GNUNET_NO if we are out of elements - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multishortmap_iterator_next ( - struct GNUNET_CONTAINER_MultiShortmapIterator *iter, - struct GNUNET_ShortHashCode *key, - const void **value); - - -/** - * @ingroup hashmap - * Destroy a multishortmap iterator. - * - * @param iter the iterator to destroy - */ -void -GNUNET_CONTAINER_multishortmap_iterator_destroy ( - struct GNUNET_CONTAINER_MultiShortmapIterator *iter); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map that match a particular key. - * - * @param map the map - * @param key public key that the entries must correspond to - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multishortmap_get_multiple ( - struct GNUNET_CONTAINER_MultiShortmap *map, - const struct GNUNET_ShortHashCode *key, - GNUNET_CONTAINER_ShortmapIterator it, - void *it_cls); - - -/** - * @ingroup hashmap - * Call @a it on a random value from the map, or not at all - * if the map is empty. Note that this function has linear - * complexity (in the size of the map). - * - * @param map the map - * @param it function to call on a random entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, zero or one. - */ -unsigned int -GNUNET_CONTAINER_multishortmap_get_random ( - const struct GNUNET_CONTAINER_MultiShortmap *map, - GNUNET_CONTAINER_ShortmapIterator it, - void *it_cls); - - -/* ***************** Version of Multihashmap for UUIDs ****************** */ - - -/** - * @ingroup hashmap - * Iterator over uuid map entries. - * - * @param cls closure - * @param key current public key - * @param value value in the hash map - * @return #GNUNET_YES if we should continue to - * iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_MultiUuidmapIteratorCallback)( - void *cls, - const struct GNUNET_Uuid *key, - void *value); - - -/** - * Hash map from peer identities to values. - */ -struct GNUNET_CONTAINER_MultiUuidmap; - - -/** - * @ingroup hashmap - * Create a multi peer map (hash map for public keys of peers). - * - * @param len initial size (map will grow as needed) - * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default; - * #GNUNET_YES means that on 'put', the 'key' does not have - * to be copied as the destination of the pointer is - * guaranteed to be life as long as the value is stored in - * the hashmap. This can significantly reduce memory - * consumption, but of course is also a recipe for - * heap corruption if the assumption is not true. Only - * use this if (1) memory use is important in this case and - * (2) you have triple-checked that the invariant holds - * @return NULL on error - */ -struct GNUNET_CONTAINER_MultiUuidmap * -GNUNET_CONTAINER_multiuuidmap_create (unsigned int len, int do_not_copy_keys); - - -/** - * @ingroup hashmap - * Destroy a hash map. Will not free any values - * stored in the hash map! - * - * @param map the map - */ -void -GNUNET_CONTAINER_multiuuidmap_destroy ( - struct GNUNET_CONTAINER_MultiUuidmap *map); - - -/** - * @ingroup hashmap - * Given a key find a value in the map matching the key. - * - * @param map the map - * @param key what to look for - * @return NULL if no value was found; note that - * this is indistinguishable from values that just - * happen to be NULL; use "contains" to test for - * key-value pairs with value NULL - */ -void * -GNUNET_CONTAINER_multiuuidmap_get ( - const struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key); - - -/** - * @ingroup hashmap - * Remove the given key-value pair from the map. Note that if the - * key-value pair is in the map multiple times, only one of the pairs - * will be removed. - * - * @param map the map - * @param key key of the key-value pair - * @param value value of the key-value pair - * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair - * is not in the map - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key, - const void *value); - -/** - * @ingroup hashmap - * Remove all entries for the given key from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @param key identifies values to be removed - * @return number of values removed - */ -int -GNUNET_CONTAINER_multiuuidmap_remove_all ( - struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key); - - -/** - * @ingroup hashmap - * Check if the map contains any value under the given - * key (including values that are NULL). - * - * @param map the map - * @param key the key to test if a value exists for it - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_contains ( - const struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key); - - -/** - * @ingroup hashmap - * Check if the map contains the given value under the given - * key. - * - * @param map the map - * @param key the key to test if a value exists for it - * @param value value to test for - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_contains_value ( - const struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key, - const void *value); - - -/** - * @ingroup hashmap - * Store a key-value pair in the map. - * - * @param map the map - * @param key key to use - * @param value value to use - * @param opt options for put - * @return #GNUNET_OK on success, - * #GNUNET_NO if a value was replaced (with REPLACE) - * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the - * value already exists - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_put ( - struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key, - void *value, - enum GNUNET_CONTAINER_MultiHashMapOption opt); - - -/** - * @ingroup hashmap - * Get the number of key-value pairs in the map. - * - * @param map the map - * @return the number of key value pairs - */ -unsigned int -GNUNET_CONTAINER_multiuuidmap_size ( - const struct GNUNET_CONTAINER_MultiUuidmap *map); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map. - * - * @param map the map - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_iterate ( - struct GNUNET_CONTAINER_MultiUuidmap *map, - GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, - void *it_cls); - - -struct GNUNET_CONTAINER_MultiUuidmapIterator; - - -/** - * @ingroup hashmap - * Create an iterator for a multihashmap. - * The iterator can be used to retrieve all the elements in the multihashmap - * one by one, without having to handle all elements at once (in contrast to - * #GNUNET_CONTAINER_multiuuidmap_iterate). Note that the iterator can not be - * used anymore if elements have been removed from @a map after the creation of - * the iterator, or 'map' has been destroyed. Adding elements to @a map may - * result in skipped or repeated elements. - * - * @param map the map to create an iterator for - * @return an iterator over the given multihashmap @a map - */ -struct GNUNET_CONTAINER_MultiUuidmapIterator * -GNUNET_CONTAINER_multiuuidmap_iterator_create ( - const struct GNUNET_CONTAINER_MultiUuidmap *map); - - -/** - * @ingroup hashmap - * Retrieve the next element from the hash map at the iterator's - * position. If there are no elements left, #GNUNET_NO is returned, - * and @a key and @a value are not modified. This operation is only - * allowed if no elements have been removed from the multihashmap - * since the creation of @a iter, and the map has not been destroyed. - * Adding elements may result in repeating or skipping elements. - * - * @param iter the iterator to get the next element from - * @param key pointer to store the key in, can be NULL - * @param value pointer to store the value in, can be NULL - * @return #GNUNET_YES we returned an element, - * #GNUNET_NO if we are out of elements - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multiuuidmap_iterator_next ( - struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, - struct GNUNET_Uuid *key, - const void **value); - - -/** - * @ingroup hashmap - * Destroy a multiuuidmap iterator. - * - * @param iter the iterator to destroy - */ -void -GNUNET_CONTAINER_multiuuidmap_iterator_destroy ( - struct GNUNET_CONTAINER_MultiUuidmapIterator *iter); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map that match a particular key. - * - * @param map the map - * @param key public key that the entries must correspond to - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multiuuidmap_get_multiple ( - struct GNUNET_CONTAINER_MultiUuidmap *map, - const struct GNUNET_Uuid *key, - GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, - void *it_cls); - - -/** - * @ingroup hashmap - * Call @a it on a random value from the map, or not at all - * if the map is empty. Note that this function has linear - * complexity (in the size of the map). - * - * @param map the map - * @param it function to call on a random entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, zero or one. - */ -unsigned int -GNUNET_CONTAINER_multiuuidmap_get_random ( - const struct GNUNET_CONTAINER_MultiUuidmap *map, - GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, - void *it_cls); - - -/* Version of multihashmap with 32 bit keys */ - -/** - * @ingroup hashmap - * Opaque handle for the 32-bit key HashMap. - */ -struct GNUNET_CONTAINER_MultiHashMap32; - - -/** - * @ingroup hashmap - * Opaque handle to an iterator over - * a 32-bit key multihashmap. - */ -struct GNUNET_CONTAINER_MultiHashMap32Iterator; - - -/** - * @ingroup hashmap - * Iterator over hash map entries. - * - * @param cls closure - * @param key current key code - * @param value value in the hash map - * @return #GNUNET_YES if we should continue to - * iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_MultiHashMapIterator32Callback)( - void *cls, - uint32_t key, - void *value); - - -/** - * @ingroup hashmap - * Create a 32-bit key multi hash map. - * - * @param len initial size (map will grow as needed) - * @return NULL on error - */ -struct GNUNET_CONTAINER_MultiHashMap32 * -GNUNET_CONTAINER_multihashmap32_create (unsigned int len); - - -/** - * @ingroup hashmap - * Destroy a 32-bit key hash map. Will not free any values - * stored in the hash map! - * - * @param map the map - */ -void -GNUNET_CONTAINER_multihashmap32_destroy ( - struct GNUNET_CONTAINER_MultiHashMap32 *map); - - -/** - * @ingroup hashmap - * Get the number of key-value pairs in the map. - * - * @param map the map - * @return the number of key value pairs - */ -unsigned int -GNUNET_CONTAINER_multihashmap32_size ( - const struct GNUNET_CONTAINER_MultiHashMap32 *map); - - -/** - * @ingroup hashmap - * Given a key find a value in the map matching the key. - * - * @param map the map - * @param key what to look for - * @return NULL if no value was found; note that - * this is indistinguishable from values that just - * happen to be NULL; use "contains" to test for - * key-value pairs with value NULL - */ -void * -GNUNET_CONTAINER_multihashmap32_get ( - const struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map. - * - * @param map the map - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multihashmap32_iterate ( - struct GNUNET_CONTAINER_MultiHashMap32 *map, - GNUNET_CONTAINER_MultiHashMapIterator32Callback it, - void *it_cls); - - -/** - * @ingroup hashmap - * Remove the given key-value pair from the map. Note that if the - * key-value pair is in the map multiple times, only one of the pairs - * will be removed. - * - * @param map the map - * @param key key of the key-value pair - * @param value value of the key-value pair - * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair - * is not in the map - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap32_remove ( - struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key, - const void *value); - - -/** - * @ingroup hashmap - * Remove all entries for the given key from the map. - * Note that the values would not be "freed". - * - * @param map the map - * @param key identifies values to be removed - * @return number of values removed - */ -int -GNUNET_CONTAINER_multihashmap32_remove_all ( - struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key); - - -/** - * @ingroup hashmap - * Check if the map contains any value under the given - * key (including values that are NULL). - * - * @param map the map - * @param key the key to test if a value exists for it - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap32_contains ( - const struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key); - - -/** - * @ingroup hashmap - * Check if the map contains the given value under the given - * key. - * - * @param map the map - * @param key the key to test if a value exists for it - * @param value value to test for - * @return #GNUNET_YES if such a value exists, - * #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap32_contains_value ( - const struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key, - const void *value); - - -/** - * @ingroup hashmap - * Store a key-value pair in the map. - * - * @param map the map - * @param key key to use - * @param value value to use - * @param opt options for put - * @return #GNUNET_OK on success, - * #GNUNET_NO if a value was replaced (with REPLACE) - * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the - * value already exists - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap32_put ( - struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key, - void *value, - enum GNUNET_CONTAINER_MultiHashMapOption opt); - - -/** - * @ingroup hashmap - * Iterate over all entries in the map that match a particular key. - * - * @param map the map - * @param key key that the entries must correspond to - * @param it function to call on each entry - * @param it_cls extra argument to @a it - * @return the number of key value pairs processed, - * #GNUNET_SYSERR if it aborted iteration - */ -int -GNUNET_CONTAINER_multihashmap32_get_multiple ( - struct GNUNET_CONTAINER_MultiHashMap32 *map, - uint32_t key, - GNUNET_CONTAINER_MultiHashMapIterator32Callback it, - void *it_cls); - - -/** - * Create an iterator for a 32-bit multihashmap. - * The iterator can be used to retrieve all the elements in the multihashmap - * one by one, without having to handle all elements at once (in contrast to - * #GNUNET_CONTAINER_multihashmap32_iterate). Note that the iterator can not be - * used anymore if elements have been removed from 'map' after the creation of - * the iterator, or 'map' has been destroyed. Adding elements to 'map' may - * result in skipped or repeated elements. - * - * @param map the map to create an iterator for - * @return an iterator over the given multihashmap map - */ -struct GNUNET_CONTAINER_MultiHashMap32Iterator * -GNUNET_CONTAINER_multihashmap32_iterator_create ( - const struct GNUNET_CONTAINER_MultiHashMap32 *map); - - -/** - * Retrieve the next element from the hash map at the iterator's position. - * If there are no elements left, GNUNET_NO is returned, and 'key' and 'value' - * are not modified. - * This operation is only allowed if no elements have been removed from the - * multihashmap since the creation of 'iter', and the map has not been destroyed. - * Adding elements may result in repeating or skipping elements. - * - * @param iter the iterator to get the next element from - * @param key pointer to store the key in, can be NULL - * @param value pointer to store the value in, can be NULL - * @return #GNUNET_YES we returned an element, - * #GNUNET_NO if we are out of elements - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_multihashmap32_iterator_next ( - struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, - uint32_t *key, - const void **value); - - -/** - * Destroy a 32-bit multihashmap iterator. - * - * @param iter the iterator to destroy - */ -void -GNUNET_CONTAINER_multihashmap32_iterator_destroy ( - struct GNUNET_CONTAINER_MultiHashMapIterator *iter); - - -/* ******************** doubly-linked list *************** */ -/* To avoid mistakes: head->prev == tail->next == NULL */ - -/** - * @ingroup dll - * Insert an element at the head of a DLL. Assumes that head, tail and - * element are structs with prev and next fields. - * - * @param head pointer to the head of the DLL - * @param tail pointer to the tail of the DLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_DLL_insert(head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \ - (element)->next = (head); \ - (element)->prev = NULL; \ - if ((tail) == NULL) \ - (tail) = element; \ - else \ - (head)->prev = element; \ - (head) = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element at the tail of a DLL. Assumes that head, tail and - * element are structs with prev and next fields. - * - * @param head pointer to the head of the DLL - * @param tail pointer to the tail of the DLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \ - (element)->prev = (tail); \ - (element)->next = NULL; \ - if ((head) == NULL) \ - (head) = element; \ - else \ - (tail)->next = element; \ - (tail) = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element into a DLL after the given other element. Insert - * at the head if the other element is NULL. - * - * @param head pointer to the head of the DLL - * @param tail pointer to the tail of the DLL - * @param other prior element, NULL for insertion at head of DLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element) \ - do \ - { \ - GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \ - (element)->prev = (other); \ - if (NULL == other) \ - { \ - (element)->next = (head); \ - (head) = (element); \ - } \ - else \ - { \ - (element)->next = (other)->next; \ - (other)->next = (element); \ - } \ - if (NULL == (element)->next) \ - (tail) = (element); \ - else \ - (element)->next->prev = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element into a DLL before the given other element. Insert - * at the tail if the other element is NULL. - * - * @param head pointer to the head of the DLL - * @param tail pointer to the tail of the DLL - * @param other prior element, NULL for insertion at head of DLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element) \ - do \ - { \ - GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \ - (element)->next = (other); \ - if (NULL == other) \ - { \ - (element)->prev = (tail); \ - (tail) = (element); \ - } \ - else \ - { \ - (element)->prev = (other)->prev; \ - (other)->prev = (element); \ - } \ - if (NULL == (element)->prev) \ - (head) = (element); \ - else \ - (element)->prev->next = (element); \ - } while (0) - - -/** - * @ingroup dll - * Remove an element from a DLL. Assumes that head, tail and - * element point to structs with prev and next fields. - * - * Using the head or tail pointer as the element - * argument does NOT work with this macro. - * Make sure to store head/tail in another pointer - * and use it to remove the head or tail of the list. - * - * @param head pointer to the head of the DLL - * @param tail pointer to the tail of the DLL - * @param element element to remove - */ -#define GNUNET_CONTAINER_DLL_remove(head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev != NULL) || ((head) == (element))); \ - GNUNET_assert (((element)->next != NULL) || ((tail) == (element))); \ - if ((element)->prev == NULL) \ - (head) = (element)->next; \ - else \ - (element)->prev->next = (element)->next; \ - if ((element)->next == NULL) \ - (tail) = (element)->prev; \ - else \ - (element)->next->prev = (element)->prev; \ - (element)->next = NULL; \ - (element)->prev = NULL; \ - } while (0) - - -/* ************ Multi-DLL interface, allows DLL elements to be - in multiple lists at the same time *********************** */ - -/** - * @ingroup dll - * Insert an element at the head of a MDLL. Assumes that head, tail and - * element are structs with prev and next fields. - * - * @param mdll suffix name for the next and prev pointers in the element - * @param head pointer to the head of the MDLL - * @param tail pointer to the tail of the MDLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \ - (element)->next_ ## mdll = (head); \ - (element)->prev_ ## mdll = NULL; \ - if ((tail) == NULL) \ - (tail) = element; \ - else \ - (head)->prev_ ## mdll = element; \ - (head) = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element at the tail of a MDLL. Assumes that head, tail and - * element are structs with prev and next fields. - * - * @param mdll suffix name for the next and prev pointers in the element - * @param head pointer to the head of the MDLL - * @param tail pointer to the tail of the MDLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \ - (element)->prev_ ## mdll = (tail); \ - (element)->next_ ## mdll = NULL; \ - if ((head) == NULL) \ - (head) = element; \ - else \ - (tail)->next_ ## mdll = element; \ - (tail) = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element into a MDLL after the given other element. Insert - * at the head if the other element is NULL. - * - * @param mdll suffix name for the next and prev pointers in the element - * @param head pointer to the head of the MDLL - * @param tail pointer to the tail of the MDLL - * @param other prior element, NULL for insertion at head of MDLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element) \ - do \ - { \ - GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \ - (element)->prev_ ## mdll = (other); \ - if (NULL == other) \ - { \ - (element)->next_ ## mdll = (head); \ - (head) = (element); \ - } \ - else \ - { \ - (element)->next_ ## mdll = (other)->next_ ## mdll; \ - (other)->next_ ## mdll = (element); \ - } \ - if (NULL == (element)->next_ ## mdll) \ - (tail) = (element); \ - else \ - (element)->next_ ## mdll->prev_ ## mdll = (element); \ - } while (0) - - -/** - * @ingroup dll - * Insert an element into a MDLL before the given other element. Insert - * at the tail if the other element is NULL. - * - * @param mdll suffix name for the next and prev pointers in the element - * @param head pointer to the head of the MDLL - * @param tail pointer to the tail of the MDLL - * @param other prior element, NULL for insertion at head of MDLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element) \ - do \ - { \ - GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \ - GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \ - (element)->next_ ## mdll = (other); \ - if (NULL == other) \ - { \ - (element)->prev = (tail); \ - (tail) = (element); \ - } \ - else \ - { \ - (element)->prev_ ## mdll = (other)->prev_ ## mdll; \ - (other)->prev_ ## mdll = (element); \ - } \ - if (NULL == (element)->prev_ ## mdll) \ - (head) = (element); \ - else \ - (element)->prev_ ## mdll->next_ ## mdll = (element); \ - } while (0) - - -/** - * @ingroup dll - * Remove an element from a MDLL. Assumes - * that head, tail and element are structs - * with prev and next fields. - * - * @param mdll suffix name for the next and prev pointers in the element - * @param head pointer to the head of the MDLL - * @param tail pointer to the tail of the MDLL - * @param element element to remove - */ -#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element) \ - do \ - { \ - GNUNET_assert (((element)->prev_ ## mdll != NULL) || ((head) == (element))); \ - GNUNET_assert (((element)->next_ ## mdll != NULL) || ((tail) == (element))); \ - if ((element)->prev_ ## mdll == NULL) \ - (head) = (element)->next_ ## mdll; \ - else \ - (element)->prev_ ## mdll->next_ ## mdll = (element)->next_ ## mdll; \ - if ((element)->next_ ## mdll == NULL) \ - (tail) = (element)->prev_ ## mdll; \ - else \ - (element)->next_ ## mdll->prev_ ## mdll = (element)->prev_ ## mdll; \ - (element)->next_ ## mdll = NULL; \ - (element)->prev_ ## mdll = NULL; \ - } while (0) - - -/** - * Insertion sort of @a element into DLL from @a head to @a tail - * sorted by @a comparator. - * - * @param TYPE element type of the elements, e.g. `struct ListElement` - * @param comparator function like memcmp() to compare elements; takes - * three arguments, the @a comparator_cls and two elements, - * returns an `int` (-1, 0 or 1) - * @param comparator_cls closure for @a comparator - * @param[in,out] head head of DLL - * @param[in,out] tail tail of DLL - * @param element element to insert - */ -#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, \ - comparator, \ - comparator_cls, \ - head, \ - tail, \ - element) \ - do \ - { \ - if ((NULL == head) || (0 < comparator (comparator_cls, element, head))) \ - { \ - /* insert at head, element < head */ \ - GNUNET_CONTAINER_DLL_insert (head, tail, element); \ - } \ - else \ - { \ - TYPE *pos; \ - \ - for (pos = head; NULL != pos; pos = pos->next) \ - if (0 < comparator (comparator_cls, element, pos)) \ - break; /* element < pos */ \ - if (NULL == pos) /* => element > tail */ \ - { \ - GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); \ - } \ - else /* prev < element < pos */ \ - { \ - GNUNET_CONTAINER_DLL_insert_after (head, tail, pos->prev, element); \ - } \ - } \ - } while (0) - - -/* ******************** Heap *************** */ - - -/** - * @ingroup heap - * Cost by which elements in a heap can be ordered. - */ -typedef uint64_t GNUNET_CONTAINER_HeapCostType; - - -/** - * @ingroup heap - * Heap type, either max or min. - */ -enum GNUNET_CONTAINER_HeapOrder -{ - /** - * @ingroup heap - * Heap with the maximum cost at the root. - */ - GNUNET_CONTAINER_HEAP_ORDER_MAX, - - /** - * @ingroup heap - * Heap with the minimum cost at the root. - */ - GNUNET_CONTAINER_HEAP_ORDER_MIN -}; - - -/** - * @ingroup heap - * Handle to a Heap. - */ -struct GNUNET_CONTAINER_Heap; - - -/** - * @ingroup heap - * Handle to a node in a heap. - */ -struct GNUNET_CONTAINER_HeapNode; - - -/** - * @ingroup heap - * Create a new heap. - * - * @param order how should the heap be sorted? - * @return handle to the heap - */ -struct GNUNET_CONTAINER_Heap * -GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order); - - -/** - * @ingroup heap - * Destroys the heap. Only call on a heap that - * is already empty. - * - * @param heap heap to destroy - */ -void -GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap); - - -/** - * @ingroup heap - * Get element stored at the root of @a heap. - * - * @param heap Heap to inspect. - * @return Element at the root, or NULL if heap is empty. - */ -void * -GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap); - - -/** - * Get @a element and @a cost stored at the root of @a heap. - * - * @param[in] heap Heap to inspect. - * @param[out] element Root element is returned here. - * @param[out] cost Cost of @a element is returned here. - * @return #GNUNET_YES if an element is returned, - * #GNUNET_NO if the heap is empty. - */ -enum GNUNET_GenericReturnValue -GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, - void **element, - GNUNET_CONTAINER_HeapCostType *cost); - - -/** - * @ingroup heap - * Get the current size of the heap - * - * @param heap the heap to get the size of - * @return number of elements stored - */ -unsigned int -GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap); - - -/** - * @ingroup heap - * Get the current cost of the node - * - * @param node the node to get the cost of - * @return cost of the node - */ -GNUNET_CONTAINER_HeapCostType -GNUNET_CONTAINER_heap_node_get_cost ( - const struct GNUNET_CONTAINER_HeapNode *node); - - -/** - * @ingroup heap - * Iterator for heap - * - * @param cls closure - * @param node internal node of the heap - * @param element value stored at the node - * @param cost cost associated with the node - * @return #GNUNET_YES if we should continue to iterate, - * #GNUNET_NO if not. - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_CONTAINER_HeapIterator)( - void *cls, - struct GNUNET_CONTAINER_HeapNode *node, - void *element, - GNUNET_CONTAINER_HeapCostType cost); - - -/** - * @ingroup heap - * Iterate over all entries in the heap. - * - * @param heap the heap - * @param iterator function to call on each entry - * @param iterator_cls closure for @a iterator - */ -void -GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, - GNUNET_CONTAINER_HeapIterator iterator, - void *iterator_cls); - -/** - * @ingroup heap - * Perform a random walk of the tree. The walk is biased - * towards elements closer to the root of the tree (since - * each walk starts at the root and ends at a random leaf). - * The heap internally tracks the current position of the - * walk. - * - * @param heap heap to walk - * @return data stored at the next random node in the walk; - * NULL if the tree is empty. - */ -void * -GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap); - - -/** - * @ingroup heap - * Inserts a new element into the heap. - * - * @param heap heap to modify - * @param element element to insert - * @param cost cost for the element - * @return node for the new element - */ -struct GNUNET_CONTAINER_HeapNode * -GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, - void *element, - GNUNET_CONTAINER_HeapCostType cost); - - -/** - * @ingroup heap - * Remove root of the heap. - * - * @param heap heap to modify - * @return element data stored at the root node - */ -void * -GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); - - -/** - * @ingroup heap - * Removes a node from the heap. - * - * @param node node to remove - * @return element data stored at the node, NULL if heap is empty - */ -void * -GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node); - - -/** - * @ingroup heap - * Updates the cost of any node in the tree - * - * @param node node for which the cost is to be changed - * @param new_cost new cost for the node - */ -void -GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node, - GNUNET_CONTAINER_HeapCostType new_cost); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - - -/* ifndef GNUNET_CONTAINER_LIB_H */ -#endif - -/** @} */ /* end of group addition */ - -/* end of gnunet_container_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_crypto_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_crypto_lib.h @@ -1,4550 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2023 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @file include/gnunet_crypto_lib.h - * @brief cryptographic primitives for GNUnet - * - * @author Christian Grothoff - * @author Krista Bennett - * @author Gerd Knorr <kraxel@bytesex.org> - * @author Ioana Patrascu - * @author Tzvetan Horozov - * @author Jeffrey Burdges <burdges@gnunet.org> - * - * @defgroup crypto Crypto library: cryptographic operations - * Provides cryptographic primitives. - * - * @see [Documentation](https://gnunet.org/crypto-api) - * - * @defgroup hash Crypto library: hash operations - * Provides hashing and operations on hashes. - * - * @see [Documentation](https://gnunet.org/crypto-api) - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_CRYPTO_LIB_H -#define GNUNET_CRYPTO_LIB_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include <stdbool.h> -#include <sodium.h> - -/** - * The identity of the host (wraps the signing key of the peer). - */ -struct GNUNET_PeerIdentity; - -#include <gcrypt.h> - - -/** - * Maximum length of an ECC signature. - * Note: round up to multiple of 8 minus 2 for alignment. - */ -#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126 - - -/** - * Desired quality level for random numbers. - * @ingroup crypto - */ -enum GNUNET_CRYPTO_Quality -{ - /** - * No good quality of the operation is needed (i.e., - * random numbers can be pseudo-random). - * @ingroup crypto - */ - GNUNET_CRYPTO_QUALITY_WEAK, - - /** - * High-quality operations are desired. - * @ingroup crypto - */ - GNUNET_CRYPTO_QUALITY_STRONG, - - /** - * Randomness for IVs etc. is required. - * @ingroup crypto - */ - GNUNET_CRYPTO_QUALITY_NONCE -}; - - -/** - * @brief length of the sessionkey in bytes (256 BIT sessionkey) - */ -#define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8) - -/** - * Length of a hash value - */ -#define GNUNET_CRYPTO_HASH_LENGTH (512 / 8) - -/** - * How many characters (without 0-terminator) are our ASCII-encoded - * public keys (ECDSA/EDDSA/ECDHE). - */ -#define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52 - -/** - * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. - */ -struct GNUNET_CRYPTO_HashAsciiEncoded -{ - unsigned char encoding[104]; -}; - - -GNUNET_NETWORK_STRUCT_BEGIN - - -/** - * @brief header of what an ECC signature signs - * this must be followed by "size - 8" bytes of - * the actual signed data - */ -struct GNUNET_CRYPTO_EccSignaturePurpose -{ - /** - * How many bytes does this signature sign? - * (including this purpose header); in network - * byte order (!). - */ - uint32_t size GNUNET_PACKED; - - /** - * What does this signature vouch for? This - * must contain a GNUNET_SIGNATURE_PURPOSE_XXX - * constant (from gnunet_signatures.h). In - * network byte order! - */ - uint32_t purpose GNUNET_PACKED; -}; - - -/** - * @brief an ECC signature using EdDSA. - * See cr.yp.to/papers.html#ed25519 - */ -struct GNUNET_CRYPTO_EddsaSignature -{ - /** - * R value. - */ - unsigned char r[256 / 8]; - - /** - * S value. - */ - unsigned char s[256 / 8]; -}; - - -/** - * @brief an ECC signature using ECDSA - */ -struct GNUNET_CRYPTO_EcdsaSignature -{ - /** - * R value. - */ - unsigned char r[256 / 8]; - - /** - * S value. - */ - unsigned char s[256 / 8]; -}; - - -/** - * Public ECC key (always for curve Ed25519) encoded in a format - * suitable for network transmission and EdDSA signatures. Refer - * to section 5.1.3 of rfc8032, for a thorough explanation of how - * this value maps to the x- and y-coordinates. - */ -struct GNUNET_CRYPTO_EddsaPublicKey -{ - /** - * Point Q consists of a y-value mod p (256 bits); the x-value is - * always positive. The point is stored in Ed25519 standard - * compact format. - */ - unsigned char q_y[256 / 8]; -}; - - -/** - * Public ECC key (always for Curve25519) encoded in a format suitable - * for network transmission and ECDSA signatures. - */ -struct GNUNET_CRYPTO_EcdsaPublicKey -{ - /** - * Q consists of an x- and a y-value, each mod p (256 bits), given - * here in affine coordinates and Ed25519 standard compact format. - */ - unsigned char q_y[256 / 8]; -}; - - -/** - * The identity of the host (wraps the signing key of the peer). - */ -struct GNUNET_PeerIdentity -{ - struct GNUNET_CRYPTO_EddsaPublicKey public_key; -}; - - -/** - * Public ECC key (always for Curve25519) encoded in a format suitable - * for network transmission and encryption (ECDH), - * See http://cr.yp.to/ecdh.html - */ -struct GNUNET_CRYPTO_EcdhePublicKey -{ - /** - * Q consists of an x- and a y-value, each mod p (256 bits), given - * here in affine coordinates and Ed25519 standard compact format. - */ - unsigned char q_y[256 / 8]; -}; - - -/** - * Private ECC key encoded for transmission. To be used only for ECDH - * key exchange (ECDHE to be precise). - */ -struct GNUNET_CRYPTO_EcdhePrivateKey -{ - /** - * d is a value mod n, where n has at most 256 bits. - */ - unsigned char d[256 / 8]; -}; - -/** - * Private ECC key encoded for transmission. To be used only for ECDSA - * signatures. - */ -struct GNUNET_CRYPTO_EcdsaPrivateKey -{ - /** - * d is a value mod n, where n has at most 256 bits. - */ - unsigned char d[256 / 8]; -}; - -/** - * Private ECC key encoded for transmission. To be used only for EdDSA - * signatures. - */ -struct GNUNET_CRYPTO_EddsaPrivateKey -{ - /** - * d is a value mod n, where n has at most 256 bits. - */ - unsigned char d[256 / 8]; -}; - - -/** - * Private ECC scalar encoded for transmission. To be used only for EdDSA - * signatures. - */ -struct GNUNET_CRYPTO_EddsaPrivateScalar -{ - /** - * s is the expandedprivate 512-bit scalar of a private key. - */ - unsigned char s[512 / 8]; -}; - -/** - * Private ECC key material encoded for transmission. To be used only for - * Edx25519 signatures. An initial key corresponds to data from the key - * expansion and clamping in the EdDSA key generation. - */ -struct GNUNET_CRYPTO_Edx25519PrivateKey -{ - /** - * a is a value mod n, where n has at most 256 bits. It is the first half of - * the seed-expansion of EdDSA and will be clamped. - */ - unsigned char a[256 / 8]; - - /** - * b consists of 32 bytes which where originally the lower 32bytes of the key - * expansion. Subsequent calls to derive_private will change this value, too. - */ - unsigned char b[256 / 8]; -}; - - -/** - * Public ECC key (always for curve Ed25519) encoded in a format suitable for - * network transmission and Edx25519 (same as EdDSA) signatures. Refer to - * section 5.1.3 of rfc8032, for a thorough explanation of how this value maps - * to the x- and y-coordinates. - */ -struct GNUNET_CRYPTO_Edx25519PublicKey -{ - /** - * Point Q consists of a y-value mod p (256 bits); the x-value is - * always positive. The point is stored in Ed25519 standard - * compact format. - */ - unsigned char q_y[256 / 8]; -}; - -/** - * @brief an ECC signature using Edx25519 (same as in EdDSA). - */ -struct GNUNET_CRYPTO_Edx25519Signature -{ - /** - * R value. - */ - unsigned char r[256 / 8]; - - /** - * S value. - */ - unsigned char s[256 / 8]; -}; - -/** - * Elligator representative (always for Curve25519) - */ -struct GNUNET_CRYPTO_ElligatorRepresentative -{ - /** - * Represents an element of Curve25519 finite field. - * Always smaller than 2 ^ 254 - 10 -> Needs to be serialized into a random-looking byte stream before transmission. - */ - unsigned char r[256 / 8]; -}; - -/** - * Key type for the generic public key union - */ -enum GNUNET_CRYPTO_KeyType -{ - /** - * The identity type. The value is the same as the - * PKEY record type. - */ - GNUNET_PUBLIC_KEY_TYPE_ECDSA = 65536, - - /** - * EDDSA identity. The value is the same as the EDKEY - * record type. - */ - GNUNET_PUBLIC_KEY_TYPE_EDDSA = 65556 -}; - -/** - * A private key for an identity as per LSD0001. - * Note that these types are NOT packed and MUST NOT be used in RPC - * messages. Use the respective serialization functions. - */ -struct GNUNET_CRYPTO_PrivateKey -{ - /** - * Type of public key. - * Defined by the GNS zone type value. - * In NBO. - */ - uint32_t type; - - union - { - /** - * An ECDSA identity key. - */ - struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key; - - /** - * AN EdDSA identtiy key - */ - struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key; - }; -}; - - -/** - * An identity key as per LSD0001. - */ -struct GNUNET_CRYPTO_PublicKey -{ - /** - * Type of public key. - * Defined by the GNS zone type value. - * In NBO. - */ - uint32_t type; - - union - { - /** - * An ECDSA identity key. - */ - struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key; - - /** - * AN EdDSA identtiy key - */ - struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key; - }; -}; - - -/** - * An identity signature as per LSD0001. - */ -struct GNUNET_CRYPTO_Signature -{ - /** - * Type of signature. - * Defined by the GNS zone type value. - * In NBO. - */ - uint32_t type; - - union - { - /** - * An ECDSA signature - */ - struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; - - /** - * AN EdDSA signature - */ - struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; - }; -}; - -/** - * @brief type for session keys - */ -struct GNUNET_CRYPTO_SymmetricSessionKey -{ - /** - * Actual key for AES. - */ - unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH]; - - /** - * Actual key for TwoFish. - */ - unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH]; -}; - -/** - * Type of a nonce used for challenges. - */ -struct GNUNET_CRYPTO_ChallengeNonceP -{ - /** - * The value of the nonce. Note that this is NOT a hash. - */ - struct GNUNET_ShortHashCode value; -}; - -GNUNET_NETWORK_STRUCT_END - -/** - * @brief IV for sym cipher - * - * NOTE: must be smaller (!) in size than the - * `struct GNUNET_HashCode`. - */ -struct GNUNET_CRYPTO_SymmetricInitializationVector -{ - unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; - - unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; -}; - - -/** - * @brief type for (message) authentication keys - */ -struct GNUNET_CRYPTO_AuthKey -{ - unsigned char key[GNUNET_CRYPTO_HASH_LENGTH]; -}; - - -/** - * Size of paillier plain texts and public keys. - * Private keys and ciphertexts are twice this size. - */ -#define GNUNET_CRYPTO_PAILLIER_BITS 2048 - - -/** - * Paillier public key. - */ -struct GNUNET_CRYPTO_PaillierPublicKey -{ - /** - * N value. - */ - unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8]; -}; - - -/** - * Paillier private key. - */ -struct GNUNET_CRYPTO_PaillierPrivateKey -{ - /** - * Lambda-component of the private key. - */ - unsigned char lambda[GNUNET_CRYPTO_PAILLIER_BITS / 8]; - /** - * Mu-component of the private key. - */ - unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8]; -}; - - -/** - * Paillier ciphertext. - */ -struct GNUNET_CRYPTO_PaillierCiphertext -{ - /** - * Guaranteed minimum number of homomorphic operations with this ciphertext, - * in network byte order (NBO). - */ - int32_t remaining_ops GNUNET_PACKED; - - /** - * The bits of the ciphertext. - */ - unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8]; -}; - - -/** - * Curve25519 Scalar - */ -struct GNUNET_CRYPTO_Cs25519Scalar -{ - /** - * 32 byte scalar - */ - unsigned char d[crypto_core_ed25519_SCALARBYTES]; -}; - - -/** - * Curve25519 point - */ -struct GNUNET_CRYPTO_Cs25519Point -{ - /** - * This is a point on the Curve25519. - * The x coordinate can be restored using the y coordinate - */ - unsigned char y[crypto_core_ed25519_BYTES]; -}; - - -/** - * The private information of an Schnorr key pair. - */ -struct GNUNET_CRYPTO_CsPrivateKey -{ - struct GNUNET_CRYPTO_Cs25519Scalar scalar; -}; - - -/** - * The public information of an Schnorr key pair. - */ -struct GNUNET_CRYPTO_CsPublicKey -{ - struct GNUNET_CRYPTO_Cs25519Point point; -}; - - -/** - * Secret used for blinding (alpha and beta). - */ -struct GNUNET_CRYPTO_CsBlindingSecret -{ - struct GNUNET_CRYPTO_Cs25519Scalar alpha; - struct GNUNET_CRYPTO_Cs25519Scalar beta; -}; - - -/** - * the private r used in the signature - */ -struct GNUNET_CRYPTO_CsRSecret -{ - struct GNUNET_CRYPTO_Cs25519Scalar scalar; -}; - - -/** - * the public R (derived from r) used in c - */ -struct GNUNET_CRYPTO_CsRPublic -{ - struct GNUNET_CRYPTO_Cs25519Point point; -}; - - -/** - * Schnorr c to be signed - */ -struct GNUNET_CRYPTO_CsC -{ - struct GNUNET_CRYPTO_Cs25519Scalar scalar; -}; - - -/** - * s in the signature - */ -struct GNUNET_CRYPTO_CsS -{ - struct GNUNET_CRYPTO_Cs25519Scalar scalar; -}; - - -/** - * blinded s in the signature - */ -struct GNUNET_CRYPTO_CsBlindS -{ - struct GNUNET_CRYPTO_Cs25519Scalar scalar; -}; - - -/** - * CS Signtature containing scalar s and point R - */ -struct GNUNET_CRYPTO_CsSignature -{ - /** - * Schnorr signatures are composed of a scalar s and a curve point - */ - struct GNUNET_CRYPTO_CsS s_scalar; - - /** - * Curve point of the Schnorr signature. - */ - struct GNUNET_CRYPTO_CsRPublic r_point; -}; - - -/** - * Nonce for the session, picked by client, - * shared with the signer. - */ -struct GNUNET_CRYPTO_CsSessionNonce -{ - /*a nonce*/ - unsigned char snonce[256 / 8]; -}; - - -/** - * Nonce for computing blinding factors. Not - * shared with the signer. - */ -struct GNUNET_CRYPTO_CsBlindingNonce -{ - /*a nonce*/ - unsigned char bnonce[256 / 8]; -}; - - -/* **************** Functions and Macros ************* */ - -/** - * @ingroup crypto - * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode generator - * can be seeded. - * - * @param seed the seed to use - */ -void -GNUNET_CRYPTO_seed_weak_random (int32_t seed); - - -/** - * @ingroup hash - * Calculate the checksum of a buffer in one step. - * - * @param buf buffer to calculate CRC over - * @param len number of bytes in @a buf - * @return crc8 value - */ -uint8_t -GNUNET_CRYPTO_crc8_n (const void *buf, size_t len); - - -/** - * Perform an incremental step in a CRC16 (for TCP/IP) calculation. - * - * @param sum current sum, initially 0 - * @param buf buffer to calculate CRC over (must be 16-bit aligned) - * @param len number of bytes in @a buf, must be multiple of 2 - * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) - */ -uint32_t -GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); - - -/** - * Convert results from GNUNET_CRYPTO_crc16_step to final crc16. - * - * @param sum cumulative sum - * @return crc16 value - */ -uint16_t -GNUNET_CRYPTO_crc16_finish (uint32_t sum); - - -/** - * @ingroup hash - * Calculate the checksum of a buffer in one step. - * - * @param buf buffer to calculate CRC over (must be 16-bit aligned) - * @param len number of bytes in @a buf, must be multiple of 2 - * @return crc16 value - */ -uint16_t -GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); - - -/** - * @ingroup hash - * Compute the CRC32 checksum for the first len - * bytes of the buffer. - * - * @param buf the data over which we're taking the CRC - * @param len the length of the buffer @a buf in bytes - * @return the resulting CRC32 checksum - */ -int32_t -GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); - -/** - * @ingroup crypto - * Zero out @a buffer, securely against compiler optimizations. - * Used to delete key material. - * - * @param buffer the buffer to zap - * @param length buffer length - */ -void -GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); - - -/** - * @ingroup crypto - * Fill block with a random values. - * - * @param mode desired quality of the random number - * @param[out] buffer the buffer to fill - * @param length buffer length - */ -void -GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, - void *buffer, - size_t length); - - -/** - * @ingroup crypto - * Fill UUID with a timeflake pseudo-random value. Note that - * timeflakes use only 80 bits of randomness and 48 bits - * to encode a timestamp in milliseconds. So what we return - * here is not a completely random number. - * - * @param mode desired quality of the random number - * @param[out] uuid the value to fill - */ -void -GNUNET_CRYPTO_random_timeflake (enum GNUNET_CRYPTO_Quality mode, - struct GNUNET_Uuid *uuid); - - -/** - * @ingroup crypto - * Produce a random value. - * - * @param mode desired quality of the random number - * @param i the upper limit (exclusive) for the random number - * @return a random value in the interval [0,@a i) (exclusive). - */ -uint32_t -GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); - - -/** - * @ingroup crypto - * Generate a random unsigned 64-bit value. - * - * @param mode desired quality of the random number - * @param max value returned will be in range [0,@a max) (exclusive) - * @return random 64-bit number - */ -uint64_t -GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); - - -/** - * @ingroup crypto - * Get an array with a random permutation of the - * numbers 0...n-1. - * @param mode #GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive) PRNG should be used, - * #GNUNET_CRYPTO_QUALITY_WEAK or #GNUNET_CRYPTO_QUALITY_NONCE otherwise - * @param n the size of the array - * @return the permutation array (allocated from heap) - */ -unsigned int * -GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); - - -/** - * @ingroup crypto - * Create a new random session key. - * - * @param key key to initialize - */ -void -GNUNET_CRYPTO_symmetric_create_session_key ( - struct GNUNET_CRYPTO_SymmetricSessionKey *key); - - -/** - * @ingroup crypto - * Encrypt a block using a symmetric sessionkey. - * - * @param block the block to encrypt - * @param size the size of the @a block - * @param sessionkey the key used to encrypt - * @param iv the initialization vector to use, use INITVALUE - * for streams. - * @return the size of the encrypted block, -1 for errors - */ -ssize_t -GNUNET_CRYPTO_symmetric_encrypt ( - const void *block, - size_t size, - const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, - const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, - void *result); - - -/** - * @ingroup crypto - * Decrypt a given block using a symmetric sessionkey. - * - * @param block the data to decrypt, encoded as returned by encrypt - * @param size how big is the block? - * @param sessionkey the key used to decrypt - * @param iv the initialization vector to use - * @param result address to store the result at - * @return -1 on failure, size of decrypted block on success - */ -ssize_t -GNUNET_CRYPTO_symmetric_decrypt ( - const void *block, - size_t size, - const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, - const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, - void *result); - - -/** - * @ingroup crypto - * @brief Derive an IV - * @param iv initialization vector - * @param skey session key - * @param salt salt for the derivation - * @param salt_len size of the @a salt - * @param ... pairs of void * & size_t for context chunks, terminated by NULL - */ -void -GNUNET_CRYPTO_symmetric_derive_iv ( - struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, - const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, - const void *salt, - size_t salt_len, - ...); - - -/** - * @brief Derive an IV - * @param iv initialization vector - * @param skey session key - * @param salt salt for the derivation - * @param salt_len size of the @a salt - * @param argp pairs of void * & size_t for context chunks, terminated by NULL - */ -void -GNUNET_CRYPTO_symmetric_derive_iv_v ( - struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, - const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, - const void *salt, - size_t salt_len, - va_list argp); - - -/** - * @ingroup hash - * Convert hash to ASCII encoding. - * @param block the hash code - * @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be - * safely cast to char*, a '\\0' termination is set). - */ -void -GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, - struct GNUNET_CRYPTO_HashAsciiEncoded *result); - - -/** - * @ingroup hash - * Convert ASCII encoding back to a 'struct GNUNET_HashCode' - * - * @param enc the encoding - * @param enclen number of characters in @a enc (without 0-terminator, which can be missing) - * @param result where to store the hash code - * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hash_from_string2 (const char *enc, - size_t enclen, - struct GNUNET_HashCode *result); - - -/** - * @ingroup hash - * Convert ASCII encoding back to `struct GNUNET_HashCode` - * - * @param enc the encoding - * @param result where to store the hash code - * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding - */ -#define GNUNET_CRYPTO_hash_from_string(enc, result) \ - GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) - - -/** - * @ingroup hash - * - * Compute the distance between 2 hashcodes. The - * computation must be fast, not involve @a a[0] or @a a[4] (they're used - * elsewhere), and be somewhat consistent. And of course, the result - * should be a positive number. - * - * @param a some hash code - * @param b some hash code - * @return number between 0 and UINT32_MAX - */ -uint32_t -GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a, - const struct GNUNET_HashCode *b); - - -/** - * @ingroup hash - * Compute hash of a given block. - * - * @param block the data to hash - * @param size size of the @a block - * @param ret pointer to where to write the hashcode - */ -void -GNUNET_CRYPTO_hash (const void *block, - size_t size, - struct GNUNET_HashCode *ret); - - -/** - * Value for a salt for #GNUNET_CRYPTO_pow_hash(). - */ -struct GNUNET_CRYPTO_PowSalt -{ - char salt[crypto_pwhash_argon2id_SALTBYTES]; -}; - - -/** - * Calculate the 'proof-of-work' hash (an expensive hash). - * - * @param salt salt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long. - * @param buf data to hash - * @param buf_len number of bytes in @a buf - * @param result where to write the resulting hash - */ -void -GNUNET_CRYPTO_pow_hash (const struct GNUNET_CRYPTO_PowSalt *salt, - const void *buf, - size_t buf_len, - struct GNUNET_HashCode *result); - - -/** - * Context for cumulative hashing. - */ -struct GNUNET_HashContext; - - -/** - * Start incremental hashing operation. - * - * @return context for incremental hash computation - */ -struct GNUNET_HashContext * -GNUNET_CRYPTO_hash_context_start (void); - - -/** - * Make a copy of the hash computation. - * - * @param hc hash context to use (to continue hashing independently) - * @return copy of @a hc - */ -struct GNUNET_HashContext * -GNUNET_CRYPTO_hash_context_copy (const struct GNUNET_HashContext *hc); - - -/** - * Add data to be hashed. - * - * @param hc cumulative hash context - * @param buf data to add - * @param size number of bytes in @a buf - */ -void -GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, - const void *buf, - size_t size); - - -/** - * Finish the hash computation. - * - * @param hc hash context to use, is freed in the process - * @param r_hash where to write the latest / final hash code - */ -void -GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, - struct GNUNET_HashCode *r_hash); - - -/** - * Abort hashing, do not bother calculating final result. - * - * @param hc hash context to destroy - */ -void -GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); - - -/** - * Calculate HMAC of a message (RFC 2104) - * TODO: Shouldn't this be the standard hmac function and - * the above be renamed? - * - * @param key secret key - * @param key_len secret key length - * @param plaintext input plaintext - * @param plaintext_len length of @a plaintext - * @param hmac where to store the hmac - */ -void -GNUNET_CRYPTO_hmac_raw (const void *key, - size_t key_len, - const void *plaintext, - size_t plaintext_len, - struct GNUNET_HashCode *hmac); - - -/** - * @ingroup hash - * Calculate HMAC of a message (RFC 2104) - * - * @param key secret key - * @param plaintext input plaintext - * @param plaintext_len length of @a plaintext - * @param hmac where to store the hmac - */ -void -GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, - const void *plaintext, - size_t plaintext_len, - struct GNUNET_HashCode *hmac); - - -/** - * Function called once the hash computation over the - * specified file has completed. - * - * @param cls closure - * @param res resulting hash, NULL on error - */ -typedef void -(*GNUNET_CRYPTO_HashCompletedCallback) ( - void *cls, - const struct GNUNET_HashCode *res); - - -/** - * Handle to file hashing operation. - */ -struct GNUNET_CRYPTO_FileHashContext; - - -/** - * @ingroup hash - * Compute the hash of an entire file. - * - * @param priority scheduling priority to use - * @param filename name of file to hash - * @param blocksize number of bytes to process in one task - * @param callback function to call upon completion - * @param callback_cls closure for @a callback - * @return NULL on (immediate) error - */ -struct GNUNET_CRYPTO_FileHashContext * -GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, - const char *filename, - size_t blocksize, - GNUNET_CRYPTO_HashCompletedCallback callback, - void *callback_cls); - - -/** - * Cancel a file hashing operation. - * - * @param fhc operation to cancel (callback must not yet have been invoked) - */ -void -GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc); - - -/** - * @ingroup hash - * Create a random hash code. - * - * @param mode desired quality level - * @param result hash code that is randomized - */ -void -GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, - struct GNUNET_HashCode *result); - - -/** - * @ingroup hash - * compute @a result = @a b - @a a - * - * @param a some hash code - * @param b some hash code - * @param result set to @a b - @a a - */ -void -GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a, - const struct GNUNET_HashCode *b, - struct GNUNET_HashCode *result); - - -/** - * @ingroup hash - * compute @a result = @a a + @a delta - * - * @param a some hash code - * @param delta some hash code - * @param result set to @a a + @a delta - */ -void -GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a, - const struct GNUNET_HashCode *delta, - struct GNUNET_HashCode *result); - - -/** - * @ingroup hash - * compute result = a ^ b - * - * @param a some hash code - * @param b some hash code - * @param result set to @a a ^ @a b - */ -void -GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, - const struct GNUNET_HashCode *b, - struct GNUNET_HashCode *result); - - -/** - * Count the number of leading 0 bits in @a h. - * - * @param h a hash - * @return number of leading 0 bits in @a h - */ -unsigned int -GNUNET_CRYPTO_hash_count_leading_zeros (const struct GNUNET_HashCode *h); - - -/** - * Count the number of tailing 0 bits in @a h. - * - * @param h a hash - * @return number of tailing 0 bits in @a h - */ -unsigned int -GNUNET_CRYPTO_hash_count_tailing_zeros (const struct GNUNET_HashCode *h); - - -/** - * @ingroup hash - * Convert a hashcode into a key. - * - * @param hc hash code that serves to generate the key - * @param skey set to a valid session key - * @param iv set to a valid initialization vector - */ -void -GNUNET_CRYPTO_hash_to_aes_key ( - const struct GNUNET_HashCode *hc, - struct GNUNET_CRYPTO_SymmetricSessionKey *skey, - struct GNUNET_CRYPTO_SymmetricInitializationVector *iv); - - -/** - * @ingroup hash - * Compare function for HashCodes, producing a total ordering - * of all hashcodes. - * - * @param h1 some hash code - * @param h2 some hash code - * @return 1 if @a h1 > @a h2, -1 if @a h1 < @a h2 and 0 if @a h1 == @a h2. - */ -int -GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1, - const struct GNUNET_HashCode *h2); - - -/** - * @ingroup hash - * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target - * in the XOR metric (Kademlia). - * - * @param h1 some hash code - * @param h2 some hash code - * @param target some hash code - * @return -1 if @a h1 is closer, 1 if @a h2 is closer and 0 if @a h1== @a h2. - */ -int -GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1, - const struct GNUNET_HashCode *h2, - const struct GNUNET_HashCode *target); - - -/** - * @ingroup hash - * @brief Derive an authentication key - * @param key authentication key - * @param rkey root key - * @param salt salt - * @param salt_len size of the salt - * @param argp pair of void * & size_t for context chunks, terminated by NULL - */ -void -GNUNET_CRYPTO_hmac_derive_key_v ( - struct GNUNET_CRYPTO_AuthKey *key, - const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, - const void *salt, - size_t salt_len, - va_list argp); - - -/** - * @ingroup hash - * @brief Derive an authentication key - * @param key authentication key - * @param rkey root key - * @param salt salt - * @param salt_len size of the salt - * @param ... pair of void * & size_t for context chunks, terminated by NULL - */ -void -GNUNET_CRYPTO_hmac_derive_key ( - struct GNUNET_CRYPTO_AuthKey *key, - const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, - const void *salt, - size_t salt_len, - ...); - - -/** - * @ingroup hash - * @brief HKDF-Extract using SHA256. RFC 5869 - * @param prk the PRK - * @param salt salt - * @param salt_len length of @a xts - * @param ikm source key material - * @param ikm_len length of @a skm - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hkdf_extract (struct GNUNET_ShortHashCode *prk, - const void *salt, - size_t salt_len, - const void *ikm, - size_t ikm_len); - -/** - * @ingroup hash - * @brief HKDF-Expand using SHA256. RFC 5869 - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param ... pair of void * & size_t for context chunks, terminated by NULL - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hkdf_expand (void *result, - size_t out_len, - const struct GNUNET_ShortHashCode *prk, - ...); - -/** - * @ingroup hash - * @brief HKDF-Expand using SHA256. See #GNUNET_CRYPTO_hkdf_expand - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param argp va_list of void * & size_t pairs for context chunks - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hkdf_expand_v (void *result, - size_t out_len, - const struct GNUNET_ShortHashCode *prk, - va_list argp); - - -/** - * @ingroup hash - * @brief A peculiar HKDF instantiation that tried to mimic Truncated NMAC. - * But, what it actually does is HKDF-Extract with SHA512 and instead of - * truncating the PRK, it uses it as a 64 byte key in the HKDF-Expand - * phase with SHA256. - * (Truncated NMAC would require us to, well, truncate it to 32 byte.) - * ONLY USE FOR COMPATIBLITY WITH OLDER KEY DERIVATIONS. - * Use the more standard #GNUNET_CRYPTO_hkdf_extract and - * #GNUNET_CRYPTO_HKDF_expand instead! - * - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param xts salt - * @param xts_len length of @a xts - * @param skm source key material - * @param skm_len length of @a skm - * @param ... pair of void * & size_t for context chunks, terminated by NULL - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hkdf_gnunet (void *result, - size_t out_len, - const void *xts, - size_t xts_len, - const void *skm, - size_t skm_len, - ...); - - -/** - * @ingroup hash - * @brief Derive key. See #GNUNET_CRYPTO_hkdf_gnunet - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param xts salt - * @param xts_len length of @a xts - * @param skm source key material - * @param skm_len length of @a skm - * @param argp va_list of void * & size_t pairs for context chunks - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_hkdf_gnunet_v (void *result, - size_t out_len, - const void *xts, - size_t xts_len, - const void *skm, - size_t skm_len, - va_list argp); - - -/** - * @brief Derive key - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param xts salt - * @param xts_len length of @a xts - * @param skm source key material - * @param skm_len length of @a skm - * @param argp va_list of void * & size_t pairs for context chunks - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_kdf_v (void *result, - size_t out_len, - const void *xts, - size_t xts_len, - const void *skm, - size_t skm_len, - va_list argp); - - -/** - * Deterministically generate a pseudo-random number uniformly from the - * integers modulo a libgcrypt mpi. - * - * @param[out] r MPI value set to the FDH - * @param n MPI to work modulo - * @param xts salt - * @param xts_len length of @a xts - * @param skm source key material - * @param skm_len length of @a skm - * @param ctx context string - */ -void -GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, - gcry_mpi_t n, - const void *xts, - size_t xts_len, - const void *skm, - size_t skm_len, - const char *ctx); - - -/** - * @ingroup hash - * @brief Derive key - * @param result buffer for the derived key, allocated by caller - * @param out_len desired length of the derived key - * @param xts salt - * @param xts_len length of @a xts - * @param skm source key material - * @param skm_len length of @a skm - * @param ... void * & size_t pairs for context chunks - * @return #GNUNET_YES on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_kdf (void *result, - size_t out_len, - const void *xts, - size_t xts_len, - const void *skm, - size_t skm_len, - ...); - - -/** - * @ingroup crypto - * Extract the public key for the given private key. - * - * @param priv the private key - * @param pub where to write the public key - */ -void -GNUNET_CRYPTO_ecdsa_key_get_public ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, - struct GNUNET_CRYPTO_EcdsaPublicKey *pub); - -/** - * @ingroup crypto - * Extract the public key for the given private key. - * - * @param priv the private key - * @param pub where to write the public key - */ -void -GNUNET_CRYPTO_eddsa_key_get_public ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - struct GNUNET_CRYPTO_EddsaPublicKey *pub); - -/** - * @ingroup crypto - * Extract the public key for the given private key. - * - * @param priv the private key - * @param pub where to write the public key - */ -void -GNUNET_CRYPTO_edx25519_key_get_public ( - const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, - struct GNUNET_CRYPTO_Edx25519PublicKey *pub); - -/** - * @ingroup crypto - * Extract the public key for the given private key. - * - * @param priv the private key - * @param pub where to write the public key - */ -void -GNUNET_CRYPTO_ecdhe_key_get_public ( - const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, - struct GNUNET_CRYPTO_EcdhePublicKey *pub); - - -/** - * Convert a public key to a string. - * - * @param pub key to convert - * @return string representing @a pub - */ -char * -GNUNET_CRYPTO_ecdsa_public_key_to_string ( - const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); - -/** - * Convert a private key to a string. - * - * @param priv key to convert - * @return string representing @a priv - */ -char * -GNUNET_CRYPTO_ecdsa_private_key_to_string ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv); - - -/** - * Convert a private key to a string. - * - * @param priv key to convert - * @return string representing @a pub - */ -char * -GNUNET_CRYPTO_eddsa_private_key_to_string ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); - - -/** - * Convert a public key to a string. - * - * @param pub key to convert - * @return string representing @a pub - */ -char * -GNUNET_CRYPTO_eddsa_public_key_to_string ( - const struct GNUNET_CRYPTO_EddsaPublicKey *pub); - - -/** - * Convert a string representing a public key to a public key. - * - * @param enc encoded public key - * @param enclen number of bytes in @a enc (without 0-terminator) - * @param pub where to store the public key - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_public_key_from_string ( - const char *enc, - size_t enclen, - struct GNUNET_CRYPTO_EcdsaPublicKey *pub); - - -/** - * Convert a string representing a private key to a private key. - * - * @param enc encoded public key - * @param enclen number of bytes in @a enc (without 0-terminator) - * @param priv where to store the private key - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_private_key_from_string ( - const char *enc, - size_t enclen, - struct GNUNET_CRYPTO_EddsaPrivateKey *priv); - - -/** - * Convert a string representing a public key to a public key. - * - * @param enc encoded public key - * @param enclen number of bytes in @a enc (without 0-terminator) - * @param pub where to store the public key - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_public_key_from_string ( - const char *enc, - size_t enclen, - struct GNUNET_CRYPTO_EddsaPublicKey *pub); - - -/** - * @ingroup crypto - * @brief Create a new private key by reading it from a file. - * - * If the files does not exist and @a do_create is set, creates a new key and - * write it to the file. - * - * If the contents of the file are invalid, an error is returned. - * - * @param filename name of file to use to store the key - * @param do_create should a file be created? - * @param[out] pkey set to the private key from @a filename on success - * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but - * we found an existing file, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, - int do_create, - struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey); - - -/** - * @ingroup crypto - * @brief Create a new private key by reading it from a file. - * - * If the files does not exist and @a do_create is set, creates a new key and - * write it to the file. - * - * If the contents of the file are invalid, an error is returned. - * - * @param filename name of file to use to store the key - * @param do_create should a file be created? - * @param[out] pkey set to the private key from @a filename on success - * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but - * we found an existing file, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, - int do_create, - struct GNUNET_CRYPTO_EddsaPrivateKey *pkey); - - -/** - * Forward declaration to simplify #include-structure. - */ -struct GNUNET_CONFIGURATION_Handle; - - -/** - * @ingroup crypto - * Create a new private key by reading our peer's key from - * the file specified in the configuration. - * - * @param cfg the configuration to use - * @return new private key, NULL on error (for example, - * permission denied); free using #GNUNET_free - */ -struct GNUNET_CRYPTO_EddsaPrivateKey * -GNUNET_CRYPTO_eddsa_key_create_from_configuration ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * @ingroup crypto - * Create a new private key. - * - * @param[out] pk private key to initialize - */ -void -GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); - - -/** - * @ingroup crypto - * Create a new private key. - * - * @param[out] pk private key to initialize - */ -void -GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); - - -/** - * @ingroup crypto - * Create a new private key. - * - * @param[out] pk private key to initialize - */ -void -GNUNET_CRYPTO_edx25519_key_create (struct GNUNET_CRYPTO_Edx25519PrivateKey *pk); - -/** - * @ingroup crypto - * Create a new private key for Edx25519 from a given seed. After expanding - * the seed, the first half of the key will be clamped according to EdDSA. - * - * @param seed seed input - * @param seedsize size of the seed in bytes - * @param[out] pk private key to initialize - */ -void -GNUNET_CRYPTO_edx25519_key_create_from_seed ( - const void *seed, - size_t seedsize, - struct GNUNET_CRYPTO_Edx25519PrivateKey *pk); - -/** - * @ingroup crypto - * Create a new private key. Clear with #GNUNET_CRYPTO_ecdhe_key_clear(). - * This is X25519 DH (RFC 7748 Section 5) and corresponds to - * X25519(a,9). - * See #GNUNET_CRYPTO_ecc_ecdh for the DH function. - * - * @param[out] pk set to fresh private key; - */ -void -GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); - - -/** - * @ingroup crypto - * Clear memory that was used to store a private key. - * - * @param pk location of the key - */ -void -GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); - - -/** - * @ingroup crypto - * Clear memory that was used to store a private key. - * - * @param pk location of the key - */ -void -GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); - -/** - * @ingroup crypto - * Clear memory that was used to store a private key. - * - * @param pk location of the key - */ -void -GNUNET_CRYPTO_edx25519_key_clear (struct GNUNET_CRYPTO_Edx25519PrivateKey *pk); - -/** - * @ingroup crypto - * Clear memory that was used to store a private key. - * - * @param pk location of the key - */ -void -GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); - -/** - * @ingroup crypto - * Clear memory that was used to store a private key. - * - * @param pk location of the key - */ -void -GNUNET_CRYPTO_private_key_clear (struct GNUNET_CRYPTO_PrivateKey *pk); - - -/** - * @ingroup crypto - * Get the shared private key we use for anonymous users. - * - * @return "anonymous" private key; do not free - */ -const struct GNUNET_CRYPTO_EcdsaPrivateKey * -GNUNET_CRYPTO_ecdsa_key_get_anonymous (void); - - -/** - * @ingroup crypto - * Setup a hostkey file for a peer given the name of the - * configuration file (!). This function is used so that - * at a later point code can be certain that reading a - * hostkey is fast (for example in time-dependent testcases). - * - * @param cfg_name name of the configuration file to use - */ -void -GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name); - - -/** - * @ingroup crypto - * Retrieve the identity of the host's peer. - * - * @param cfg configuration to use - * @param dst pointer to where to write the peer identity - * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity - * could not be retrieved - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_PeerIdentity *dst); - - -/** - * @ingroup crypto - * Sign a given block with a specific purpose using the host's peer identity. - * - * @param cfg configuration to use - * @param purpose what to sign (size, purpose) - * @param sig where to write the signature - * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity - * could not be retrieved - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_sign_by_peer_identity (const struct - GNUNET_CONFIGURATION_Handle *cfg, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EddsaSignature *sig); - - -/** - * @ingroup crypto - * Verify a given signature with a peer's identity. - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param identity the peer's identity to verify - * @return #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct - GNUNET_CRYPTO_EddsaSignature *sig, - const struct GNUNET_PeerIdentity *identity); - - -/** - * Internal structure used to cache pre-calculated values for DLOG calculation. - */ -struct GNUNET_CRYPTO_EccDlogContext; - - -/** - * Point on a curve (always for Curve25519) encoded in a format suitable - * for network transmission (ECDH), see http://cr.yp.to/ecdh.html. - */ -struct GNUNET_CRYPTO_EccPoint -{ - /** - * Q consists of an x- and a y-value, each mod p (256 bits), given - * here in affine coordinates and Ed25519 standard compact format. - */ - unsigned char v[256 / 8]; -}; - -/** - * A ECC scalar for use in point multiplications - */ -struct GNUNET_CRYPTO_EccScalar -{ - unsigned char v[256 / 8]; -}; - -/** - * Do pre-calculation for ECC discrete logarithm for small factors. - * - * @param max maximum value the factor can be - * @param mem memory to use (should be smaller than @a max), must not be zero. - * @return NULL on error - */ -struct GNUNET_CRYPTO_EccDlogContext * -GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, - unsigned int mem); - - -/** - * Calculate ECC discrete logarithm for small factors. - * Opposite of #GNUNET_CRYPTO_ecc_dexp(). - * - * @param edc precalculated values, determine range of factors - * @param input point on the curve to factor - * @return INT_MAX if dlog failed, otherwise the factor - */ -int -GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, - const struct GNUNET_CRYPTO_EccPoint *input); - - -/** - * Multiply the generator g of the elliptic curve by @a val - * to obtain the point on the curve representing @a val. - * Afterwards, point addition will correspond to integer - * addition. #GNUNET_CRYPTO_ecc_dlog() can be used to - * convert a point back to an integer (as long as the - * integer is smaller than the MAX of the @a edc context). - * - * @param val value to encode into a point - * @param r where to write the point (must be allocated) - */ -void -GNUNET_CRYPTO_ecc_dexp (int val, - struct GNUNET_CRYPTO_EccPoint*r); - - -/** - * Multiply the generator g of the elliptic curve by @a val - * to obtain the point on the curve representing @a val. - * - * @param val (positive) value to encode into a point - * @param r where to write the point (must be allocated) - * @return #GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecc_dexp_mpi (const struct GNUNET_CRYPTO_EccScalar *val, - struct GNUNET_CRYPTO_EccPoint *r); - - -/** - * Multiply the point @a p on the elliptic curve by @a val. - * - * @param p point to multiply - * @param val (positive) value to encode into a point - * @param r where to write the point (must be allocated) - * @return #GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecc_pmul_mpi (const struct GNUNET_CRYPTO_EccPoint *p, - const struct GNUNET_CRYPTO_EccScalar *val, - struct GNUNET_CRYPTO_EccPoint *r); - - -/** - * Add two points on the elliptic curve. - * - * @param a some value - * @param b some value - * @param r where to write the point (must be allocated) - * @return #GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecc_add (const struct GNUNET_CRYPTO_EccPoint *a, - const struct GNUNET_CRYPTO_EccPoint *b, - struct GNUNET_CRYPTO_EccPoint *r); - - -/** - * Obtain a random point on the curve and its - * additive inverse. - * - * @param[out] r set to a random point on the curve - * @param[out] r_inv set to the additive inverse of @a r - * @return #GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccPoint *r, - struct GNUNET_CRYPTO_EccPoint *r_inv); - - -/** - * Obtain a random scalar for point multiplication on the curve and - * its additive inverse. - * - * @param[out] r set to a random scalar on the curve - * @param[out] r_neg set to the negation of @a - */ -void -GNUNET_CRYPTO_ecc_rnd_mpi (struct GNUNET_CRYPTO_EccScalar *r, - struct GNUNET_CRYPTO_EccScalar *r_neg); - - -/** - * Generate a random value mod n. - * - * @param[out] r random value mod n. - */ -void -GNUNET_CRYPTO_ecc_random_mod_n (struct GNUNET_CRYPTO_EccScalar*r); - - -/** - * Release precalculated values. - * - * @param dlc dlog context - */ -void -GNUNET_CRYPTO_ecc_dlog_release (struct GNUNET_CRYPTO_EccDlogContext *dlc); - - -/** - * Create a scalar from int value. - * - * @param val the int value - * @param[out] r where to write the salar - */ -void -GNUNET_CRYPTO_ecc_scalar_from_int (int64_t val, - struct GNUNET_CRYPTO_EccScalar *r); - - -/** - * @ingroup crypto - * Derive key material from a public and a private ECC key. - * This is X25519 DH (RFC 7748 Section 5) and corresponds to - * H(X25519(b,X25519(a,9))) where b := priv, pub := X25519(a,9), - * and a := #GNUNET_CRYPTO_ecdhe_key_create(). - * - * @param priv private key to use for the ECDH (x) - * @param pub public key to use for the ECDH (yG) - * @param key_material where to write the key material (xyG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *pub, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * Derive key material from a ECDH public key and a private EdDSA key. - * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. - * This uses the Ed25519 private seed as X25519 seed. - * As such, this also is a X25519 DH (see #GNUNET_CRYPTO_ecc_ecdh). - * NOTE: Whenever you can get away with it, use separate key pairs - * for signing and encryption (DH)! - * - * @param priv private key from EdDSA to use for the ECDH (x) - * @param pub public key to use for the ECDH (yG) - * @param key_material where to write the key material H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *pub, - struct GNUNET_HashCode *key_material); - -/** - * @ingroup crypto - * Decapsulate a key for a private EdDSA key. - * Dual to #GNUNET_CRRYPTO_eddsa_kem_encaps. - * - * @param priv private key from EdDSA to use for the ECDH (x) - * @param c the encapsulated key - * @param key_material where to write the key material H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_kem_decaps (const struct - GNUNET_CRYPTO_EddsaPrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *c, - struct GNUNET_HashCode *key_material); - -/** - * @ingroup crypto - * Encapsulate key material for a EdDSA public key. - * Dual to #GNUNET_CRRYPTO_eddsa_kem_decaps. - * - * @param priv private key to use for the ECDH (y) - * @param c public key from EdDSA to use for the ECDH (X=h(x)G) - * @param key_material where to write the key material H(yX)=H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_kem_encaps (const struct GNUNET_CRYPTO_EddsaPublicKey *pub, - struct GNUNET_CRYPTO_EcdhePublicKey *c, - struct GNUNET_HashCode *key_material); - -/** - * This is the encapsulated key of our FO-KEM. - */ -struct GNUNET_CRYPTO_FoKemC -{ - /* The output of the FO-OWTF F(x) */ - struct GNUNET_HashCode y; - - /* The ephemeral public key from the DH in the KEM */ - struct GNUNET_CRYPTO_EcdhePublicKey pub; -}; - -/** - * @ingroup crypto - * Encapsulate key material using a CCA-secure KEM. - * The KEM is using a OWTF with image oracle constructed from - * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). - * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. - * - * @param pub public key to encapsulated for - * @param[out] c the encapsulation - * @param[out] key_material the encapsulated key - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_fo_kem_encaps ( - const struct GNUNET_CRYPTO_EddsaPublicKey *pub, - struct GNUNET_CRYPTO_FoKemC *c, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * Decapsulate key material using a CCA-secure KEM. - * The KEM is using a OWTF with image oracle constructed from - * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). - * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. - * - * @param priv private key this encapsulation is for - * @param c the encapsulation - * @param[out] key_material the encapsulated key - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_fo_kem_decaps (const struct - GNUNET_CRYPTO_EddsaPrivateKey *priv, - const struct GNUNET_CRYPTO_FoKemC *c, - struct GNUNET_HashCode *key_material); - -/** - * @ingroup crypto - * Encapsulate key material using a CCA-secure KEM. - * The KEM is using a OWTF with image oracle constructed from - * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). - * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. - * - * @param pub public key to encapsulated for - * @param[out] c the encapsulation - * @param[out] key_material the encapsulated key - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_fo_kem_encaps (const struct - GNUNET_CRYPTO_EcdsaPublicKey *pub, - struct GNUNET_CRYPTO_FoKemC *c, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * Decapsulate key material using a CCA-secure KEM. - * The KEM is using a OWTF with image oracle constructed from - * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). - * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. - * - * @param priv private key this encapsulation is for - * @param c the encapsulation - * @param[out] key_material the encapsulated key - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_fo_kem_decaps (const struct - GNUNET_CRYPTO_EcdsaPrivateKey *priv, - struct GNUNET_CRYPTO_FoKemC *c, - struct GNUNET_HashCode *key_material); - -/** - * @ingroup crypto - * Derive key material from a ECDH public key and a private ECDSA key. - * Dual to #GNUNET_CRRYPTO_ecdh_ecdsa. - * - * @param priv private key from ECDSA to use for the ECDH (x) - * @param pub public key to use for the ECDH (yG) - * @param key_material where to write the key material H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *pub, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * Derive key material from a EdDSA public key and a private ECDH key. - * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. - * This converts the Edwards25519 public key @a pub to a Curve25519 - * public key before computing a X25519 DH (see #GNUNET_CRYPTO_ecc_ecdh). - * NOTE: Whenever you can get away with it, use separate key pairs - * for signing and encryption (DH)! - * - * @param priv private key to use for the ECDH (y) - * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) - * @param key_material where to write the key material H(yX)=H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, - const struct GNUNET_CRYPTO_EddsaPublicKey *pub, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * Derive key material from a EcDSA public key and a private ECDH key. - * Dual to #GNUNET_CRRYPTO_ecdsa_ecdh. - * - * @param priv private key to use for the ECDH (y) - * @param pub public key from ECDSA to use for the ECDH (X=h(x)G) - * @param key_material where to write the key material H(yX)=H(h(x)yG) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, - const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, - struct GNUNET_HashCode *key_material); - - -/** - * @ingroup crypto - * @brief EdDSA sign a given block. - * - * The @a purpose data is the beginning of the data of which the signature is - * to be created. The `size` field in @a purpose must correctly indicate the - * number of bytes of the data structure, including its header. If possible, - * use #GNUNET_CRYPTO_eddsa_sign() instead of this function (only if @a validate - * is not fixed-size, you must use this function directly). - * - * @param priv private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param[out] sig where to write the signature - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_sign_ ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EddsaSignature *sig); - - -/** - * @ingroup crypto - * @brief EdDSA sign a given block. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param[out] sig where to write the signature - */ -#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_assert (GNUNET_OK == \ - GNUNET_CRYPTO_eddsa_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ -} while (0) - - -/** - * @ingroup crypto - * @brief ECDSA Sign a given block. - * - * The @a purpose data is the beginning of the data of which the signature is - * to be created. The `size` field in @a purpose must correctly indicate the - * number of bytes of the data structure, including its header. If possible, - * use #GNUNET_CRYPTO_ecdsa_sign() instead of this function (only if @a validate - * is not fixed-size, you must use this function directly). - * - * @param priv private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param[out] sig where to write the signature - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_sign_ ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EcdsaSignature *sig); - -/** - * @brief - * - * @param priv - * @param data - * @param size - * @param sig - * @return enum GNUNET_GenericReturnValue - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_sign_raw ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - void *data, - size_t size, - struct GNUNET_CRYPTO_EddsaSignature *sig); - -/** - * @ingroup crypto - * @brief ECDSA sign a given block. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param[out] sig where to write the signature - */ -#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_assert (GNUNET_OK == \ - GNUNET_CRYPTO_ecdsa_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ -} while (0) - -/** - * @ingroup crypto - * @brief Edx25519 sign a given block. - * - * The @a purpose data is the beginning of the data of which the signature is - * to be created. The `size` field in @a purpose must correctly indicate the - * number of bytes of the data structure, including its header. If possible, - * use #GNUNET_CRYPTO_edx25519_sign() instead of this function (only if @a - * validate is not fixed-size, you must use this function directly). - * - * @param priv private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param[out] sig where to write the signature - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_edx25519_sign_ ( - const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_Edx25519Signature *sig); - - -/** - * @ingroup crypto - * @brief Edx25519 sign a given block. The resulting signature is compatible - * with EdDSA. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param[out] sig where to write the signature - */ -#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_assert (GNUNET_OK == \ - GNUNET_CRYPTO_edx25519_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ -} while (0) - - -/** - * @ingroup crypto - * @brief Verify EdDSA signature. - * - * The @a validate data is the beginning of the data of which the signature - * is to be verified. The `size` field in @a validate must correctly indicate - * the number of bytes of the data structure, including its header. If @a - * purpose does not match the purpose given in @a validate (the latter must be - * in big endian), signature verification fails. If possible, - * use #GNUNET_CRYPTO_eddsa_verify() instead of this function (only if @a validate - * is not fixed-size, you must use this function directly). - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param pub public key of the signer - * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_verify_ ( - uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_CRYPTO_EddsaSignature *sig, - const struct GNUNET_CRYPTO_EddsaPublicKey *pub); - - -/** - * @ingroup crypto - * @brief Verify EdDSA signature. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param purp purpose of the signature, must match 'ps->purpose.purpose' - * (except in host byte order) - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param sig where to write the signature - */ -#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_CRYPTO_eddsa_verify_ (purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ - }) - -/** - * @ingroup crypto - * @brief Verify ECDSA signature. - * - * The @a validate data is the beginning of the data of which the signature is - * to be verified. The `size` field in @a validate must correctly indicate the - * number of bytes of the data structure, including its header. If @a purpose - * does not match the purpose given in @a validate (the latter must be in big - * endian), signature verification fails. If possible, use - * #GNUNET_CRYPTO_eddsa_verify() instead of this function (only if @a validate - * is not fixed-size, you must use this function directly). - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param pub public key of the signer - * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_verify_ ( - uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_CRYPTO_EcdsaSignature *sig, - const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); - - -/** - * @ingroup crypto - * @brief Verify ECDSA signature. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param purp purpose of the signature, must match 'ps->purpose.purpose' - * (except in host byte order) - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param sig where to write the signature - */ -#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_CRYPTO_ecdsa_verify_ (purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ - }) - -/** - * @ingroup crypto - * @brief Verify Edx25519 signature. - * - * The @a validate data is the beginning of the data of which the signature - * is to be verified. The `size` field in @a validate must correctly indicate - * the number of bytes of the data structure, including its header. If @a - * purpose does not match the purpose given in @a validate (the latter must be - * in big endian), signature verification fails. If possible, use - * #GNUNET_CRYPTO_edx25519_verify() instead of this function (only if @a - * validate is not fixed-size, you must use this function directly). - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param pub public key of the signer - * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_edx25519_verify_ ( - uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_CRYPTO_Edx25519Signature *sig, - const struct GNUNET_CRYPTO_Edx25519PublicKey *pub); - - -/** - * @ingroup crypto - * @brief Verify Edx25519 signature. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param purp purpose of the signature, must match 'ps->purpose.purpose' - * (except in host byte order) - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param sig where to write the signature - */ -#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_CRYPTO_edx25519_verify_ (purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ - }) - -/** - * @ingroup crypto - * Derive a private key from a given private key and a label. - * Essentially calculates a private key 'h = H(l,P) * d mod n' - * where n is the size of the ECC group and P is the public - * key associated with the private key 'd'. - * - * @param priv original private key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'; - * typically the name of the subsystem/application - * @return derived private key - */ -struct GNUNET_CRYPTO_EcdsaPrivateKey * -GNUNET_CRYPTO_ecdsa_private_key_derive ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, - const char *label, - const char *context); - - -/** - * @ingroup crypto - * Derive a public key from a given public key and a label. - * Essentially calculates a public key 'V = H(l,P) * P'. - * - * @param pub original public key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'. - * typically the name of the subsystem/application - * @param result where to write the derived public key - */ -void -GNUNET_CRYPTO_ecdsa_public_key_derive ( - const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, - const char *label, - const char *context, - struct GNUNET_CRYPTO_EcdsaPublicKey *result); - -/** - * This is a signature function for ECDSA which takes a - * private key, derives/blinds it and signs the message. - * - * @param pkey original private key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'; - * typically the name of the subsystem/application - * @param purpose the signature purpose - * @param sig the resulting signature - * @return GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdsa_sign_derived ( - const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, - const char *label, - const char *context, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EcdsaSignature *sig); - - -/** - * @ingroup crypto - * Derive a private scalar from a given private key and a label. - * Essentially calculates a private key 'h = H(l,P) * d mod n' - * where n is the size of the ECC group and P is the public - * key associated with the private key 'd'. - * The result is the derived private _scalar_, not the private - * key as for EdDSA we cannot derive before we hash the - * private key. - * - * @param priv original private key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'; - * typically the name of the subsystem/application - * @param result derived private scalar - */ -void -GNUNET_CRYPTO_eddsa_private_key_derive ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - const char *label, - const char *context, - struct GNUNET_CRYPTO_EddsaPrivateScalar *result); - - -/** - * @ingroup crypto - * Derive a public key from a given public key and a label. - * Essentially calculates a public key 'V = H(l,P) * P'. - * - * @param pub original public key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'. - * typically the name of the subsystem/application - * @param result where to write the derived public key - */ -void -GNUNET_CRYPTO_eddsa_public_key_derive ( - const struct GNUNET_CRYPTO_EddsaPublicKey *pub, - const char *label, - const char *context, - struct GNUNET_CRYPTO_EddsaPublicKey *result); - - -/** - * This is a signature function for EdDSA which takes a - * private key and derives it using the label and context - * before signing. - * - * @param pkey original private key - * @param label label to use for key deriviation - * @param context additional context to use for HKDF of 'h'; - * typically the name of the subsystem/application - * @param purpose the signature purpose - * @param sig the resulting signature - * @return GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_sign_derived ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, - const char *label, - const char *context, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EddsaSignature *sig); - - -/** - * Extract the public key of the given private scalar. - * - * @param s the private scalar - * @param pkey the resulting public key - */ -void -GNUNET_CRYPTO_eddsa_key_get_public_from_scalar ( - const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, - struct GNUNET_CRYPTO_EddsaPublicKey *pkey); - -/** - * @ingroup crypto - * Derive a private scalar from a given private key and a label. - * Essentially calculates a private key 'h = H(l,P) * d mod n' - * where n is the size of the ECC group and P is the public - * key associated with the private key 'd'. - * - * @param priv original private key - * @param seed input seed - * @param seedsize size of the seed - * @param result derived private key - */ -void -GNUNET_CRYPTO_edx25519_private_key_derive ( - const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, - const void *seed, - size_t seedsize, - struct GNUNET_CRYPTO_Edx25519PrivateKey *result); - - -/** - * @ingroup crypto - * Derive a public key from a given public key and a label. - * Essentially calculates a public key 'V = H(l,P) * P'. - * - * @param pub original public key - * @param seed input seed - * @param seedsize size of the seed - * @param result where to write the derived public key - */ -void -GNUNET_CRYPTO_edx25519_public_key_derive ( - const struct GNUNET_CRYPTO_Edx25519PublicKey *pub, - const void *seed, - size_t seedsize, - struct GNUNET_CRYPTO_Edx25519PublicKey *result); - - -/** - * @ingroup crypto - * Clears the most significant bit and second most significant bit of the serialized representaive before applying elligator direct map. - * - * @param representative serialized elligator representative of an element of Curves25519's finite field - * @param point destination for the calculated point on the curve - * @param high_y bool pointed to will be set to 'true' if corresponding y-coordinate is > 2 ^ 254 - 10, otherwise 0. Can be set to NULL if not needed. - */ -void -GNUNET_CRYPTO_ecdhe_elligator_decoding ( - struct GNUNET_CRYPTO_EcdhePublicKey *point, - bool *high_y, - const struct GNUNET_CRYPTO_ElligatorRepresentative *representative); - -/** - * @ingroup crypto - * Encodes a point on Curve25519 to a an element of the underlying finite field. - * This transformation is deterministic. - * - * @param r storage for the calculated representative - * @param pub a point on the curve - * @param high_y encodes if y-coordinate is > 2 ^254 - 10, which determines the representative value out of two - * @return 'true' if the given point can be encoded into a representative. Otherwise 'false' is returned and the content of the representative storage is undefined - */ -bool -GNUNET_CRYPTO_ecdhe_elligator_encoding ( - struct GNUNET_CRYPTO_ElligatorRepresentative *r, - const struct GNUNET_CRYPTO_EcdhePublicKey *pub, - bool high_y); - - -/** - * @ingroup crypto - * Generates a valid public key for elligator's inverse map by adding a lower order point to a prime order point. - * Following Method 1 in description https://elligator.org/key-exchange section Step 2: Generate a “special” public key. - * - * @param pub valid public key for elligator inverse map - * @param pk private key for generating valid public key - * @return GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_ecdhe_elligator_generate_public_key ( - struct GNUNET_CRYPTO_EcdhePublicKey *pub, - struct GNUNET_CRYPTO_EcdhePrivateKey *pk); - - -/** - * @ingroup crypto - * Generates a private key for Curve25519 and the elligator representative of the corresponding public key. - * - * @param repr representative of the public key - * @param pk Curve25519 private key - */ -void -GNUNET_CRYPTO_ecdhe_elligator_key_create ( - struct GNUNET_CRYPTO_ElligatorRepresentative *repr, - struct GNUNET_CRYPTO_EcdhePrivateKey *pk); - -/** - * @ingroup crypto - * Carries out ecdh encapsulation with given public key and the private key from a freshly created ephemeral key pair. - * Following the terminology in https://eprint.iacr.org/2021/509.pdf. - * - * @param pub given edwards curve public key (X) - * @param r representative of ephemeral public key A to use for the ECDH (direct_map(r)=A=aG) - * @param key_material where to write the key material H(aX)=H(x(aG)) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_elligator_kem_encaps ( - const struct GNUNET_CRYPTO_EddsaPublicKey *pub, - struct GNUNET_CRYPTO_ElligatorRepresentative *r, - struct GNUNET_HashCode *key_material); - -/** - * @ingroup crypto - * Carries out ecdh decapsulation with own private key and the representative of the received public key. - * Following the terminology in https://eprint.iacr.org/2021/509.pdf. - * - * @param priv own private key (x) - * @param r received representative r, from which we can obtain the public key A (direct_map(r)=A=aG) - * @param key_material where to write the key material H(xA)=H(a(xG)) - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_eddsa_elligator_kem_decaps ( - const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, - const struct GNUNET_CRYPTO_ElligatorRepresentative *r, - struct GNUNET_HashCode *key_material); - - -/** - * Output the given MPI value to the given buffer in network - * byte order. The MPI @a val may not be negative. - * - * @param buf where to output to - * @param size number of bytes in @a buf - * @param val value to write to @a buf - */ -void -GNUNET_CRYPTO_mpi_print_unsigned (void *buf, - size_t size, - gcry_mpi_t val); - - -/** - * Convert data buffer into MPI value. - * The buffer is interpreted as network - * byte order, unsigned integer. - * - * @param result where to store MPI value (allocated) - * @param data raw data (GCRYMPI_FMT_USG) - * @param size number of bytes in @a data - */ -void -GNUNET_CRYPTO_mpi_scan_unsigned (gcry_mpi_t *result, - const void *data, - size_t size); - - -/** - * Create a freshly generated paillier public key. - * - * @param[out] public_key Where to store the public key? - * @param[out] private_key Where to store the private key? - */ -void -GNUNET_CRYPTO_paillier_create ( - struct GNUNET_CRYPTO_PaillierPublicKey *public_key, - struct GNUNET_CRYPTO_PaillierPrivateKey *private_key); - - -/** - * Encrypt a plaintext with a paillier public key. - * - * @param public_key Public key to use. - * @param m Plaintext to encrypt. - * @param desired_ops How many homomorphic ops the caller intends to use - * @param[out] ciphertext Encryption of @a plaintext with @a public_key. - * @return guaranteed number of supported homomorphic operations >= 1, - * or desired_ops, in case that is lower, - * or -1 if less than one homomorphic operation is possible - */ -int -GNUNET_CRYPTO_paillier_encrypt ( - const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, - const gcry_mpi_t m, - int desired_ops, - struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext); - - -/** - * Decrypt a paillier ciphertext with a private key. - * - * @param private_key Private key to use for decryption. - * @param public_key Public key to use for decryption. - * @param ciphertext Ciphertext to decrypt. - * @param[out] m Decryption of @a ciphertext with @a private_key. - */ -void -GNUNET_CRYPTO_paillier_decrypt ( - const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, - const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, - const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, - gcry_mpi_t m); - - -/** - * Compute a ciphertext that represents the sum of the plaintext in @a c1 - * and @a c2 - * - * Note that this operation can only be done a finite number of times - * before an overflow occurs. - * - * @param public_key Public key to use for encryption. - * @param c1 Paillier cipher text. - * @param c2 Paillier cipher text. - * @param[out] result Result of the homomorphic operation. - * @return #GNUNET_OK if the result could be computed, - * #GNUNET_SYSERR if no more homomorphic operations are remaining. - */ -int -GNUNET_CRYPTO_paillier_hom_add ( - const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, - const struct GNUNET_CRYPTO_PaillierCiphertext *c1, - const struct GNUNET_CRYPTO_PaillierCiphertext *c2, - struct GNUNET_CRYPTO_PaillierCiphertext *result); - - -/** - * Get the number of remaining supported homomorphic operations. - * - * @param c Paillier cipher text. - * @return the number of remaining homomorphic operations - */ -int -GNUNET_CRYPTO_paillier_hom_get_remaining ( - const struct GNUNET_CRYPTO_PaillierCiphertext *c); - - -/* ********* Chaum-style RSA-based blind signatures ******************* */ - - -/** - * The private information of an RSA key pair. - */ -struct GNUNET_CRYPTO_RsaPrivateKey; - -/** - * The public information of an RSA key pair. - */ -struct GNUNET_CRYPTO_RsaPublicKey; - -/** - * Constant-size pre-secret for blinding key generation. - */ -struct GNUNET_CRYPTO_RsaBlindingKeySecret -{ - /** - * Bits used to generate the blinding key. 256 bits - * of entropy is enough. - */ - uint32_t pre_secret[8] GNUNET_PACKED; -}; - -/** - * @brief an RSA signature - */ -struct GNUNET_CRYPTO_RsaSignature; - - -/** - * Create a new private key. Caller must free return value. - * - * @param len length of the key in bits (e.g. 2048) - * @return fresh private key - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_private_key_create (unsigned int len); - - -/** - * Free memory occupied by the private key. - * - * @param key pointer to the memory to free - */ -void -GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); - - -/** - * Encode the private key in a format suitable for - * storing it into a file. - * - * @param key the private key - * @param[out] buffer set to a buffer with the encoded key - * @return size of memory allocatedin @a buffer - */ -size_t -GNUNET_CRYPTO_rsa_private_key_encode ( - const struct GNUNET_CRYPTO_RsaPrivateKey *key, - void **buffer); - - -/** - * Decode the private key from the data-format back - * to the "normal", internal format. - * - * @param buf the buffer where the private key data is stored - * @param buf_size the size of the data in @a buf - * @return NULL on error - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_private_key_decode (const void *buf, - size_t buf_size); - - -/** - * Duplicate the given private key - * - * @param key the private key to duplicate - * @return the duplicate key; NULL upon error - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_private_key_dup ( - const struct GNUNET_CRYPTO_RsaPrivateKey *key); - - -/** - * Extract the public key of the given private key. - * - * @param priv the private key - * @return NULL on error, otherwise the public key - */ -struct GNUNET_CRYPTO_RsaPublicKey * -GNUNET_CRYPTO_rsa_private_key_get_public ( - const struct GNUNET_CRYPTO_RsaPrivateKey *priv); - - -/** - * Compute hash over the public key. - * - * @param key public key to hash - * @param hc where to store the hash code - */ -void -GNUNET_CRYPTO_rsa_public_key_hash ( - const struct GNUNET_CRYPTO_RsaPublicKey *key, - struct GNUNET_HashCode *hc); - - -/** - * Check if @a key is well-formed. - * - * @return true if @a key is well-formed. - */ -bool -GNUNET_CRYPTO_rsa_public_key_check ( - const struct GNUNET_CRYPTO_RsaPublicKey *key); - -/** - * Obtain the length of the RSA key in bits. - * - * @param key the public key to introspect - * @return length of the key in bits - */ -unsigned int -GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key); - - -/** - * Free memory occupied by the public key. - * - * @param key pointer to the memory to free - */ -void -GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key); - - -/** - * Encode the public key in a format suitable for - * storing it into a file. - * - * @param key the private key - * @param[out] buffer set to a buffer with the encoded key - * @return size of memory allocated in @a buffer - */ -size_t -GNUNET_CRYPTO_rsa_public_key_encode ( - const struct GNUNET_CRYPTO_RsaPublicKey *key, - void **buffer); - - -/** - * Decode the public key from the data-format back - * to the "normal", internal format. - * - * @param buf the buffer where the public key data is stored - * @param len the length of the data in @a buf - * @return NULL on error - */ -struct GNUNET_CRYPTO_RsaPublicKey * -GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, - size_t len); - - -/** - * Duplicate the given public key - * - * @param key the public key to duplicate - * @return the duplicate key; NULL upon error - */ -struct GNUNET_CRYPTO_RsaPublicKey * -GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key); - - -/** - * Compare the values of two signatures. - * - * @param s1 one signature - * @param s2 the other signature - * @return 0 if the two are equal - */ -int -GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, - const struct GNUNET_CRYPTO_RsaSignature *s2); - -/** - * Compare the values of two private keys. - * - * @param p1 one private key - * @param p2 the other private key - * @return 0 if the two are equal - */ -int -GNUNET_CRYPTO_rsa_private_key_cmp ( - const struct GNUNET_CRYPTO_RsaPrivateKey *p1, - const struct GNUNET_CRYPTO_RsaPrivateKey *p2); - - -/** - * Compare the values of two public keys. - * - * @param p1 one public key - * @param p2 the other public key - * @return 0 if the two are equal - */ -int -GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, - const struct GNUNET_CRYPTO_RsaPublicKey *p2); - - -/** - * @brief RSA Parameters to create blinded signature - */ -struct GNUNET_CRYPTO_RsaBlindedMessage -{ - /** - * Blinded message to be signed - * Note: is malloc()'ed! - */ - void *blinded_msg; - - /** - * Size of the @e blinded_msg to be signed. - */ - size_t blinded_msg_size; -}; - - -/** - * Blinds the given message with the given blinding key - * - * @param message the message to sign - * @param message_size number of bytes in @a message - * @param bks the blinding key - * @param pkey the public key of the signer - * @param[out] bm set to the blinded message - * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_rsa_blind (const void *message, - size_t message_size, - const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, - struct GNUNET_CRYPTO_RsaPublicKey *pkey, - struct GNUNET_CRYPTO_RsaBlindedMessage *bm); - - -/** - * Sign a blinded value, which must be a full domain hash of a message. - * - * @param key private key to use for the signing - * @param bm the (blinded) message to sign - * @return NULL on error, signature on success - */ -struct GNUNET_CRYPTO_RsaSignature * -GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, - const struct - GNUNET_CRYPTO_RsaBlindedMessage *bm); - - -/** - * Create and sign a full domain hash of a message. - * - * @param key private key to use for the signing - * @param message the message to sign - * @param message_size number of bytes in @a message - * @return NULL on error, including a malicious RSA key, signature on success - */ -struct GNUNET_CRYPTO_RsaSignature * -GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, - const void *message, - size_t message_size); - - -/** - * Free memory occupied by blinded message. Only frees contents, not - * @a bm itself. - * - * @param[in] bm memory to free - */ -void -GNUNET_CRYPTO_rsa_blinded_message_free ( - struct GNUNET_CRYPTO_RsaBlindedMessage *bm); - - -/** - * Free memory occupied by signature. - * - * @param[in] sig memory to free - */ -void -GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); - - -/** - * Encode the given signature in a format suitable for storing it into a file. - * - * @param sig the signature - * @param[out] buffer set to a buffer with the encoded key - * @return size of memory allocated in @a buffer - */ -size_t -GNUNET_CRYPTO_rsa_signature_encode ( - const struct GNUNET_CRYPTO_RsaSignature *sig, - void **buffer); - - -/** - * Decode the signature from the data-format back to the "normal", internal - * format. - * - * @param buf the buffer where the public key data is stored - * @param buf_size the number of bytes of the data in @a buf - * @return NULL on error - */ -struct GNUNET_CRYPTO_RsaSignature * -GNUNET_CRYPTO_rsa_signature_decode ( - const void *buf, - size_t buf_size); - - -/** - * Duplicate the given rsa signature - * - * @param sig the signature to duplicate - * @return the duplicate key; NULL upon error - */ -struct GNUNET_CRYPTO_RsaSignature * -GNUNET_CRYPTO_rsa_signature_dup ( - const struct GNUNET_CRYPTO_RsaSignature *sig); - - -/** - * Unblind a blind-signed signature. The signature should have been generated - * with #GNUNET_CRYPTO_rsa_sign() using a hash that was blinded with - * #GNUNET_CRYPTO_rsa_blind(). - * - * @param sig the signature made on the blinded signature purpose - * @param bks the blinding key secret used to blind the signature purpose - * @param pkey the public key of the signer - * @return unblinded signature on success, NULL if RSA key is bad or malicious. - */ -struct GNUNET_CRYPTO_RsaSignature * -GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, - const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, - struct GNUNET_CRYPTO_RsaPublicKey *pkey); - - -/** - * Verify whether the given hash corresponds to the given signature and the - * signature is valid with respect to the given public key. - * - * @param message the message to sign - * @param message_size number of bytes in @a message - * @param sig signature that is being validated - * @param public_key public key of the signer - * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_rsa_verify (const void *message, - size_t message_size, - const struct GNUNET_CRYPTO_RsaSignature *sig, - const struct GNUNET_CRYPTO_RsaPublicKey *public_key); - - -/** - * Create a new random private key. - * - * @param[out] priv where to write the fresh private key - */ -void -GNUNET_CRYPTO_cs_private_key_generate (struct GNUNET_CRYPTO_CsPrivateKey *priv); - - -/** - * Extract the public key of the given private key. - * - * @param priv the private key - * @param[out] pub where to write the public key - */ -void -GNUNET_CRYPTO_cs_private_key_get_public ( - const struct GNUNET_CRYPTO_CsPrivateKey *priv, - struct GNUNET_CRYPTO_CsPublicKey *pub); - - -/** - * Derive a new secret r pair r0 and r1. - * In original papers r is generated randomly - * To provide abort-idempotency, r needs to be derived but still needs to be UNPREDICTABLE - * To ensure unpredictability a new nonce should be used when a new r needs to be derived. - * Uses HKDF internally. - * Comment: Can be done in one HKDF shot and split output. - * - * @param nonce is a random nonce - * @param seed seed to use in derivation - * @param lts is a long-term-secret in form of a private key - * @param[out] r array containing derived secrets r0 and r1 - */ -void -GNUNET_CRYPTO_cs_r_derive ( - const struct GNUNET_CRYPTO_CsSessionNonce *nonce, - const char *seed, - const struct GNUNET_CRYPTO_CsPrivateKey *lts, - struct GNUNET_CRYPTO_CsRSecret r[2]); - - -/** - * Extract the public R of the given secret r. - * - * @param r_priv the private key - * @param[out] r_pub where to write the public key - */ -void -GNUNET_CRYPTO_cs_r_get_public ( - const struct GNUNET_CRYPTO_CsRSecret *r_priv, - struct GNUNET_CRYPTO_CsRPublic *r_pub); - - -/** - * Derives new random blinding factors. - * In original papers blinding factors are generated randomly - * To provide abort-idempotency, blinding factors need to be derived but still need to be UNPREDICTABLE. - * To ensure unpredictability a new nonce has to be used. - * Uses HKDF internally. - * - * @param blind_seed is the blinding seed to derive blinding factors - * @param[out] bs array containing the two derived blinding secrets - */ -void -GNUNET_CRYPTO_cs_blinding_secrets_derive ( - const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed, - struct GNUNET_CRYPTO_CsBlindingSecret bs[2]); - - -/** - * @brief CS Parameters derived from the message - * during blinding to create blinded signature - */ -struct GNUNET_CRYPTO_CsBlindedMessage -{ - /** - * The Clause Schnorr c_0 and c_1 containing the blinded message - */ - struct GNUNET_CRYPTO_CsC c[2]; - - /** - * Nonce used in initial request. - */ - struct GNUNET_CRYPTO_CsSessionNonce nonce; - -}; - - -/** - * Pair of Public R values for Cs denominations - */ -struct GNUNET_CRYPTO_CSPublicRPairP -{ - struct GNUNET_CRYPTO_CsRPublic r_pub[2]; -}; - - -/** - * Calculate two blinded c's. - * Comment: One would be insecure due to Wagner's algorithm solving ROS - * - * @param bs array of the two blinding factor structs each containing alpha and beta - * @param r_pub array of the two signer's nonce R - * @param pub the public key of the signer - * @param msg the message to blind in preparation for signing - * @param msg_len length of message msg - * @param[out] blinded_c array of the two blinded c's - * @param[out] r_pub_blind array of the two blinded R - */ -void -GNUNET_CRYPTO_cs_calc_blinded_c ( - const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], - const struct GNUNET_CRYPTO_CsRPublic r_pub[2], - const struct GNUNET_CRYPTO_CsPublicKey *pub, - const void *msg, - size_t msg_len, - struct GNUNET_CRYPTO_CsC blinded_c[2], - struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind); - - -/** - * The Sign Answer for Clause Blind Schnorr signature. - * The sign operation returns a parameter @param b and the signature - * scalar @param s_scalar. - */ -struct GNUNET_CRYPTO_CsBlindSignature -{ - /** - * To make ROS problem harder, the signer chooses an unpredictable b and - * only calculates signature of c_b - */ - unsigned int b; - - /** - * The blinded s scalar calculated from c_b - */ - struct GNUNET_CRYPTO_CsBlindS s_scalar; -}; - - -/** - * Sign a blinded @a c. - * This function derives b from a nonce and a longterm secret. - * In the original papers b is generated randomly. - * To provide abort-idempotency, b needs to be derived but still need to be UNPREDICTABLE. - * To ensure unpredictability a new nonce has to be used for every signature. - * HKDF is used internally for derivation. - * r0 and r1 can be derived prior by using GNUNET_CRYPTO_cs_r_derive. - * - * @param priv private key to use for the signing and as LTS in HKDF - * @param r array of the two secret inputs from the signer - * @param bm blinded message, including array of the two blinded c to sign c_b and the random nonce - * @param[out] cs_blind_sig where to write the blind signature - */ -void -GNUNET_CRYPTO_cs_sign_derive ( - const struct GNUNET_CRYPTO_CsPrivateKey *priv, - const struct GNUNET_CRYPTO_CsRSecret r[2], - const struct GNUNET_CRYPTO_CsBlindedMessage *bm, - struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig); - - -/** - * Unblind a blind-signed signature using a c that was blinded - * - * @param blinded_signature_scalar the signature made on the blinded c - * @param bs the blinding factors used in the blinding - * @param[out] signature_scalar where to write the unblinded signature - */ -void -GNUNET_CRYPTO_cs_unblind ( - const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar, - const struct GNUNET_CRYPTO_CsBlindingSecret *bs, - struct GNUNET_CRYPTO_CsS *signature_scalar); - - -/** - * Verify whether the given message corresponds to the given signature and the - * signature is valid with respect to the given public key. - * - * @param sig signature that is being validated - * @param pub public key of the signer - * @param msg is the message that should be signed by @a sig (message is used to calculate c) - * @param msg_len is the message length - * @returns #GNUNET_YES on success, #GNUNET_SYSERR if signature invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_cs_verify ( - const struct GNUNET_CRYPTO_CsSignature *sig, - const struct GNUNET_CRYPTO_CsPublicKey *pub, - const void *msg, - size_t msg_len); - - -/** - * Types of public keys used for blind signatures. - */ -enum GNUNET_CRYPTO_BlindSignatureAlgorithm -{ - - /** - * Invalid type of signature. - */ - GNUNET_CRYPTO_BSA_INVALID = 0, - - /** - * RSA blind signature. - */ - GNUNET_CRYPTO_BSA_RSA = 1, - - /** - * Clause Blind Schnorr signature. - */ - GNUNET_CRYPTO_BSA_CS = 2 -}; - - -/** - * @brief Type of (unblinded) signatures. - */ -struct GNUNET_CRYPTO_UnblindedSignature -{ - - /** - * Type of the signature. - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - */ - struct GNUNET_CRYPTO_CsSignature cs_signature; - - /** - * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. - */ - struct GNUNET_CRYPTO_RsaSignature *rsa_signature; - - } details; - -}; - - -/** - * @brief Type for *blinded* signatures. - * Must be unblinded before it becomes valid. - */ -struct GNUNET_CRYPTO_BlindedSignature -{ - - /** - * Type of the signature. - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - * At this point only the blinded s scalar is used. - * The final signature consisting of r,s is built after unblinding. - */ - struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer; - - /** - * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. - */ - struct GNUNET_CRYPTO_RsaSignature *blinded_rsa_signature; - - } details; - -}; - - -/** - * @brief Type of public signing keys for blind signatures. - */ -struct GNUNET_CRYPTO_BlindSignPublicKey -{ - - /** - * Type of the public key. - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Hash of the public key. - */ - struct GNUNET_HashCode pub_key_hash; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - */ - struct GNUNET_CRYPTO_CsPublicKey cs_public_key; - - /** - * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. - */ - struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key; - - } details; -}; - - -/** - * @brief Type of private signing keys for blind signing. - */ -struct GNUNET_CRYPTO_BlindSignPrivateKey -{ - - /** - * Type of the public key. - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - */ - struct GNUNET_CRYPTO_CsPrivateKey cs_private_key; - - /** - * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. - */ - struct GNUNET_CRYPTO_RsaPrivateKey *rsa_private_key; - - } details; -}; - - -/** - * @brief Blinded message ready for blind signing. - */ -struct GNUNET_CRYPTO_BlindedMessage -{ - /** - * Type of the sign blinded message - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - */ - struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message; - - /** - * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. - */ - struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message; - - } details; -}; - - -/** - * Secret r for Cs denominations - */ -struct GNUNET_CRYPTO_CSPrivateRPairP -{ - struct GNUNET_CRYPTO_CsRSecret r[2]; -}; - - -/** - * @brief Input needed for blinding a message. - */ -struct GNUNET_CRYPTO_BlindingInputValues -{ - - /** - * Type of the signature. - */ - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Details, depending on @e cipher. - */ - union - { - /** - * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. - */ - struct GNUNET_CRYPTO_CSPublicRPairP cs_values; - - } details; - -}; - - -/** - * Nonce used to deterministiacally derive input values - * used in multi-round blind signature protocols. - */ -union GNUNET_CRYPTO_BlindSessionNonce -{ - /** - * Nonce used when signing with CS. - */ - struct GNUNET_CRYPTO_CsSessionNonce cs_nonce; -}; - - -/** - * Compute blinding input values for a given @a nonce and - * @a salt. - * - * @param bsign_priv private key to compute input values for - * @param nonce session nonce to derive input values from - * @param salt salt to include in derivation logic - * @return blinding input values - */ -struct GNUNET_CRYPTO_BlindingInputValues * -GNUNET_CRYPTO_get_blinding_input_values ( - const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, - const union GNUNET_CRYPTO_BlindSessionNonce *nonce, - const char *salt); - - -/** - * Decrement reference counter of a @a bsign_pub, and free it if it reaches zero. - * - * @param[in] bsign_pub key to free - */ -void -GNUNET_CRYPTO_blind_sign_pub_decref ( - struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); - - -/** - * Decrement reference counter of a @a bsign_priv, and free it if it reaches zero. - * - * @param[in] bsign_priv key to free - */ -void -GNUNET_CRYPTO_blind_sign_priv_decref ( - struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv); - - -/** - * Decrement reference counter of a @a ub_sig, and free it if it reaches zero. - * - * @param[in] ub_sig signature to free - */ -void -GNUNET_CRYPTO_unblinded_sig_decref ( - struct GNUNET_CRYPTO_UnblindedSignature *ub_sig); - - -/** - * Decrement reference counter of a @a blind_sig, and free it if it reaches zero. - * - * @param[in] blind_sig signature to free - */ -void -GNUNET_CRYPTO_blinded_sig_decref ( - struct GNUNET_CRYPTO_BlindedSignature *blind_sig); - - -/** - * Decrement reference counter of a @a bm, and free it if it reaches zero. - * - * @param[in] bm blinded message to free - */ -void -GNUNET_CRYPTO_blinded_message_decref ( - struct GNUNET_CRYPTO_BlindedMessage *bm); - - -/** - * Increment reference counter of the given @a bm. - * - * @param[in,out] bm blinded message to increment reference counter for - * @return alias of @a bm with RC incremented - */ -struct GNUNET_CRYPTO_BlindedMessage * -GNUNET_CRYPTO_blinded_message_incref ( - struct GNUNET_CRYPTO_BlindedMessage *bm); - - -/** - * Increment reference counter of the given @a bi. - * - * @param[in,out] bi blinding input values to increment reference counter for - * @return alias of @a bi with RC incremented - */ -struct GNUNET_CRYPTO_BlindingInputValues * -GNUNET_CRYPTO_blinding_input_values_incref ( - struct GNUNET_CRYPTO_BlindingInputValues *bm); - - -/** - * Decrement reference counter of the given @a bi, and free it if it reaches - * zero. - * - * @param[in,out] bi blinding input values to decrement reference counter for - */ -void -GNUNET_CRYPTO_blinding_input_values_decref ( - struct GNUNET_CRYPTO_BlindingInputValues *bm); - - -/** - * Increment reference counter of the given @a bsign_pub. - * - * @param[in,out] bsign_pub public key to increment reference counter for - * @return alias of @a bsign_pub with RC incremented - */ -struct GNUNET_CRYPTO_BlindSignPublicKey * -GNUNET_CRYPTO_bsign_pub_incref ( - struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); - - -/** - * Increment reference counter of the given @a bsign_priv. - * - * @param[in,out] bsign_priv private key to increment reference counter for - * @return alias of @a bsign_priv with RC incremented - */ -struct GNUNET_CRYPTO_BlindSignPrivateKey * -GNUNET_CRYPTO_bsign_priv_incref ( - struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv); - - -/** - * Increment reference counter of the given @a ub_sig. - * - * @param[in,out] ub_sig signature to increment reference counter for - * @return alias of @a ub_sig with RC incremented - */ -struct GNUNET_CRYPTO_UnblindedSignature * -GNUNET_CRYPTO_ub_sig_incref (struct GNUNET_CRYPTO_UnblindedSignature *ub_sig); - - -/** - * Increment reference counter of the given @a blind_sig. - * - * @param[in,out] blind_sig signature to increment reference counter for - * @return alias of @a blind_sig with RC incremented - */ -struct GNUNET_CRYPTO_BlindedSignature * -GNUNET_CRYPTO_blind_sig_incref ( - struct GNUNET_CRYPTO_BlindedSignature *blind_sig); - - -/** - * Compare two denomination public keys. - * - * @param bp1 first key - * @param bp2 second key - * @return 0 if the keys are equal, otherwise -1 or 1 - */ -int -GNUNET_CRYPTO_bsign_pub_cmp ( - const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1, - const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2); - - -/** - * Compare two denomination signatures. - * - * @param sig1 first signature - * @param sig2 second signature - * @return 0 if the keys are equal, otherwise -1 or 1 - */ -int -GNUNET_CRYPTO_ub_sig_cmp (const struct GNUNET_CRYPTO_UnblindedSignature *sig1, - const struct GNUNET_CRYPTO_UnblindedSignature *sig2); - - -/** - * Compare two blinded denomination signatures. - * - * @param sig1 first signature - * @param sig2 second signature - * @return 0 if the keys are equal, otherwise -1 or 1 - */ -int -GNUNET_CRYPTO_blind_sig_cmp ( - const struct GNUNET_CRYPTO_BlindedSignature *sig1, - const struct GNUNET_CRYPTO_BlindedSignature *sig2); - - -/** - * Compare two blinded messages. - * - * @param bp1 first blinded message - * @param bp2 second blinded message - * @return 0 if the keys are equal, otherwise -1 or 1 - */ -int -GNUNET_CRYPTO_blinded_message_cmp ( - const struct GNUNET_CRYPTO_BlindedMessage *bp1, - const struct GNUNET_CRYPTO_BlindedMessage *bp2); - - -/** - * Initialize public-private key pair for blind signatures. - * - * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int" - * argument with the number of bits for 'n' (e.g. 2048) must - * be passed. - * - * @param[out] bsign_priv where to write the private key with RC 1 - * @param[out] bsign_pub where to write the public key with RC 1 - * @param cipher which type of cipher to use - * @param ... RSA key size (eg. 2048/3072/4096) - * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_blind_sign_keys_create ( - struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, - struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, - ...); - - -/** - * Initialize public-private key pair for blind signatures. - * - * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int" - * argument with the number of bits for 'n' (e.g. 2048) must - * be passed. - * - * @param[out] bsign_priv where to write the private key with RC 1 - * @param[out] bsign_pub where to write the public key with RC 1 - * @param cipher which type of cipher to use - * @param ap RSA key size (eg. 2048/3072/4096) - * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_blind_sign_keys_create_va ( - struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, - struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, - enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, - va_list ap); - - -/** - * @brief Type of blinding secrets. Must be exactly 32 bytes (DB). - */ -union GNUNET_CRYPTO_BlindingSecretP -{ - /** - * Clause Schnorr nonce. - */ - struct GNUNET_CRYPTO_CsBlindingNonce nonce; - - /** - * Variant for RSA for blind signatures. - */ - struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks; -}; - - -/** - * Blind message for blind signing with @a dk using blinding secret @a coin_bks. - * - * @param bsign_pub public key to blind for - * @param bks blinding secret to use - * @param nonce nonce used to obtain @a alg_values - * can be NULL if input values are not used for the cipher - * @param message message to sign - * @param message_size number of bytes in @a message - * @param alg_values algorithm specific values to blind the @a message - * @return blinded message to give to signer, NULL on error - */ -struct GNUNET_CRYPTO_BlindedMessage * -GNUNET_CRYPTO_message_blind_to_sign ( - const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, - const union GNUNET_CRYPTO_BlindingSecretP *bks, - const union GNUNET_CRYPTO_BlindSessionNonce *nonce, - const void *message, - size_t message_size, - const struct GNUNET_CRYPTO_BlindingInputValues *alg_values); - - -/** - * Create blind signature. - * - * @param bsign_priv private key to use for signing - * @param salt salt value to use for the HKDF, - * can be NULL if input values are not used for the cipher - * @param blinded_message the already blinded message to sign - * @return blind signature with RC=1, NULL on failure - */ -struct GNUNET_CRYPTO_BlindedSignature * -GNUNET_CRYPTO_blind_sign ( - const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, - const char *salt, - const struct GNUNET_CRYPTO_BlindedMessage *blinded_message); - - -/** - * Unblind blind signature. - * - * @param blinded_sig the blind signature - * @param bks blinding secret to use - * @param message message that was supposedly signed - * @param message_size number of bytes in @a message - * @param alg_values algorithm specific values - * @param bsign_pub public key used for signing - * @return unblinded signature with RC=1, NULL on error - */ -struct GNUNET_CRYPTO_UnblindedSignature * -GNUNET_CRYPTO_blind_sig_unblind ( - const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig, - const union GNUNET_CRYPTO_BlindingSecretP *bks, - const void *message, - size_t message_size, - const struct GNUNET_CRYPTO_BlindingInputValues *alg_values, - const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); - - -/** - * Verify signature made blindly. - * - * @param bsign_pub public key - * @param ub_sig signature made blindly with the private key - * @param message message that was supposedly signed - * @param message_size number of bytes in @a message - * @return #GNUNET_OK if the signature is valid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_blind_sig_verify ( - const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, - const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig, - const void *message, - size_t message_size); - - -/** - * Get the compacted length of a #GNUNET_CRYPTO_PublicKey. - * Compacted means that it returns the minimum number of bytes this - * key is long, as opposed to the union structure inside - * #GNUNET_CRYPTO_PublicKey. - * Useful for compact serializations. - * - * @param key the key. - * @return -1 on error, else the compacted length of the key. - */ -ssize_t -GNUNET_CRYPTO_public_key_get_length (const struct - GNUNET_CRYPTO_PublicKey *key); - -/** - * Reads a #GNUNET_CRYPTO_PublicKey from a compact buffer. - * The buffer has to contain at least the compacted length of - * a #GNUNET_CRYPTO_PublicKey in bytes. - * If the buffer is too small, the function returns -1 as error. - * If the buffer does not contain a valid key, it returns -2 as error. - * - * @param buffer the buffer - * @param len the length of buffer - * @param key the key - * @param the amount of bytes read from the buffer - * @return #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_read_public_key_from_buffer ( - const void *buffer, - size_t len, - struct GNUNET_CRYPTO_PublicKey *key, - size_t *read); - -/** - * Get the compacted length of a #GNUNET_CRYPTO_PrivateKey. - * Compacted means that it returns the minimum number of bytes this - * key is long, as opposed to the union structure inside - * #GNUNET_CRYPTO_PrivateKey. - * Useful for compact serializations. - * - * @param key the key. - * @return -1 on error, else the compacted length of the key. - */ -ssize_t -GNUNET_CRYPTO_private_key_get_length ( - const struct GNUNET_CRYPTO_PrivateKey *key); - - -/** - * Writes a #GNUNET_CRYPTO_PublicKey to a compact buffer. - * The buffer requires space for at least the compacted length of - * a #GNUNET_CRYPTO_PublicKey in bytes. - * If the buffer is too small, the function returns -1 as error. - * If the key is not valid, it returns -2 as error. - * - * @param key the key - * @param buffer the buffer - * @param len the length of buffer - * @return -1 or -2 on error, else the amount of bytes written to the buffer - */ -ssize_t -GNUNET_CRYPTO_write_public_key_to_buffer (const struct - GNUNET_CRYPTO_PublicKey *key, - void*buffer, - size_t len); - - -/** - * Reads a #GNUNET_CRYPTO_PrivateKey from a compact buffer. - * The buffer has to contain at least the compacted length of - * a #GNUNET_CRYPTO_PrivateKey in bytes. - * If the buffer is too small, the function returns GNUNET_SYSERR as error. - * - * @param buffer the buffer - * @param len the length of buffer - * @param key the key - * @param the amount of bytes read from the buffer - * @return #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_read_private_key_from_buffer ( - const void*buffer, - size_t len, - struct GNUNET_CRYPTO_PrivateKey *key, - size_t *read); - - -/** - * Writes a #GNUNET_CRYPTO_PrivateKey to a compact buffer. - * The buffer requires space for at least the compacted length of - * a #GNUNET_CRYPTO_PrivateKey in bytes. - * If the buffer is too small, the function returns -1 as error. - * If the key is not valid, it returns -2 as error. - * - * @param key the key - * @param buffer the buffer - * @param len the length of buffer - * @return -1 or -2 on error, else the amount of bytes written to the buffer - */ -ssize_t -GNUNET_CRYPTO_write_private_key_to_buffer ( - const struct GNUNET_CRYPTO_PrivateKey *key, - void*buffer, - size_t len); - - -/** - * Get the compacted length of a #GNUNET_CRYPTO_Signature. - * Compacted means that it returns the minimum number of bytes this - * signature is long, as opposed to the union structure inside - * #GNUNET_CRYPTO_Signature. - * Useful for compact serializations. - * - * @param sig the signature. - * @return -1 on error, else the compacted length of the signature. - */ -ssize_t -GNUNET_CRYPTO_signature_get_length ( - const struct GNUNET_CRYPTO_Signature *sig); - - -/** - * Get the compacted length of a signature by type. - * Compacted means that it returns the minimum number of bytes this - * signature is long, as opposed to the union structure inside - * #GNUNET_CRYPTO_Signature. - * Useful for compact serializations. - * - * @param sig the signature. - * @return -1 on error, else the compacted length of the signature. - */ -ssize_t -GNUNET_CRYPTO_signature_get_raw_length_by_type (uint32_t type); - - -/** - * Reads a #GNUNET_CRYPTO_Signature from a compact buffer. - * The buffer has to contain at least the compacted length of - * a #GNUNET_CRYPTO_Signature in bytes. - * If the buffer is too small, the function returns -1 as error. - * If the buffer does not contain a valid key, it returns -2 as error. - * - * @param sig the signature - * @param buffer the buffer - * @param len the length of buffer - * @return -1 or -2 on error, else the amount of bytes read from the buffer - */ -ssize_t -GNUNET_CRYPTO_read_signature_from_buffer ( - struct GNUNET_CRYPTO_Signature *sig, - const void*buffer, - size_t len); - - -/** - * Writes a #GNUNET_CRYPTO_Signature to a compact buffer. - * The buffer requires space for at least the compacted length of - * a #GNUNET_CRYPTO_Signature in bytes. - * If the buffer is too small, the function returns -1 as error. - * If the key is not valid, it returns -2 as error. - * - * @param sig the signature - * @param buffer the buffer - * @param len the length of buffer - * @return -1 or -2 on error, else the amount of bytes written to the buffer - */ -ssize_t -GNUNET_CRYPTO_write_signature_to_buffer ( - const struct GNUNET_CRYPTO_Signature *sig, - void*buffer, - size_t len); - - -/** - * @brief Sign a given block. - * - * The @a purpose data is the beginning of the data of which the signature is - * to be created. The `size` field in @a purpose must correctly indicate the - * number of bytes of the data structure, including its header. If possible, - * use #GNUNET_CRYPTO_sign() instead of this function. - * - * @param priv private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param[out] sig where to write the signature - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_sign_ ( - const struct GNUNET_CRYPTO_PrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_Signature *sig); - -/** - * @brief Sign a given block. - * - * The @a purpose data is the beginning of the data of which the signature is - * to be created. The `size` field in @a purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * The signature payload and length depends on the key type. - * - * @param priv private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param[out] sig where to write the signature - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_sign_raw_ ( - const struct GNUNET_CRYPTO_PrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - unsigned char *sig); - - -/** - * @brief Sign a given block with #GNUNET_CRYPTO_PrivateKey. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param priv private key to use for the signing - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param[out] sig where to write the signature - */ -#define GNUNET_CRYPTO_sign(priv,ps,sig) do { \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_assert (GNUNET_OK == \ - GNUNET_CRYPTO_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ -} while (0) - - -/** - * @brief Verify a given signature. - * - * The @a validate data is the beginning of the data of which the signature - * is to be verified. The `size` field in @a validate must correctly indicate - * the number of bytes of the data structure, including its header. If @a - * purpose does not match the purpose given in @a validate (the latter must be - * in big endian), signature verification fails. If possible, - * use #GNUNET_CRYPTO_signature_verify() instead of this function (only if @a validate - * is not fixed-size, you must use this function directly). - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param pub public key of the signer - * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_signature_verify_ ( - uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_CRYPTO_Signature *sig, - const struct GNUNET_CRYPTO_PublicKey *pub); - -/** - * @brief Verify a given signature. - * - * The @a validate data is the beginning of the data of which the signature - * is to be verified. The `size` field in @a validate must correctly indicate - * the number of bytes of the data structure, including its header. If @a - * purpose does not match the purpose given in @a validate (the latter must be - * in big endian), signature verification fails. - * - * @param purpose what is the purpose that the signature should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param pub public key of the signer - * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_signature_verify_raw_ ( - uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const unsigned char *sig, - const struct GNUNET_CRYPTO_PublicKey *pub); - - -/** - * @brief Verify a given signature with #GNUNET_CRYPTO_PublicKey. - * - * The @a ps data must be a fixed-size struct for which the signature is to be - * created. The `size` field in @a ps->purpose must correctly indicate the - * number of bytes of the data structure, including its header. - * - * @param purp purpose of the signature, must match 'ps->purpose.purpose' - * (except in host byte order) - * @param ps packed struct with what to sign, MUST begin with a purpose - * @param sig where to read the signature from - * @param pub public key to use for the verifying - */ -#define GNUNET_CRYPTO_signature_verify(purp,ps,sig,pub) ({ \ - /* check size is set correctly */ \ - GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ - /* check 'ps' begins with the purpose */ \ - GNUNET_static_assert (((void*) (ps)) == \ - ((void*) &(ps)->purpose)); \ - GNUNET_CRYPTO_signature_verify_ (purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ - }) - - -/** - * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a - * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption - * using ecdh to derive a symmetric key. - * - * @param block the block to encrypt - * @param size the size of the @a block - * @param pub public key to use for ecdh - * @param ecc where to write the ecc public key - * @param result the output parameter in which to store the encrypted result - * can be the same or overlap with @c block - * @returns the size of the encrypted block, -1 for errors. - * Due to the use of CFB and therefore an effective stream cipher, - * this size should be the same as @c len. - */ -ssize_t -GNUNET_CRYPTO_encrypt_old (const void *block, - size_t size, - const struct GNUNET_CRYPTO_PublicKey *pub, - struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); - - -/** - * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given - * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. - * - * @param block the data to decrypt, encoded as returned by encrypt - * @param size the size of the @a block to decrypt - * @param priv private key to use for ecdh - * @param ecc the ecc public key - * @param result address to store the result at - * can be the same or overlap with @c block - * @return -1 on failure, size of decrypted block on success. - * Due to the use of CFB and therefore an effective stream cipher, - * this size should be the same as @c size. - */ -ssize_t -GNUNET_CRYPTO_decrypt_old ( - const void *block, - size_t size, - const struct GNUNET_CRYPTO_PrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); - -#define GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \ - + sizeof (struct \ - GNUNET_CRYPTO_FoKemC)) - -/** - * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a - * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption - * using ecdh to derive a symmetric key. - * - * Note that the result buffer for the ciphertext must be the length of - * the message to encrypt plus #GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES. - * - * @param block the block to encrypt - * @param size the size of the @a block - * @param pub public key to encrypt for - * @param result the output parameter in which to store the encrypted result - * can be the same or overlap with @c block - * @returns GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_encrypt (const void *block, - size_t size, - const struct GNUNET_CRYPTO_PublicKey *pub, - void *result, - size_t result_size); - - -/** - * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given - * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. - * - * @param block the data to decrypt, encoded as returned by encrypt - * @param size the size of the @a block to decrypt - * @param priv private key to use for ecdh - * @param result address to store the result at - * can be the same or overlap with @c block - * @returns GNUNET_OK on success. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_decrypt (const void *block, - size_t size, - const struct GNUNET_CRYPTO_PrivateKey *priv, - void *result, - size_t result_size); - - -/** - * Creates a (Base32) string representation of the public key. - * The resulting string encodes a compacted representation of the key. - * See also #GNUNET_CRYPTO_key_get_length. - * - * @param key the key. - * @return the string representation of the key, or NULL on error. - */ -char * -GNUNET_CRYPTO_public_key_to_string ( - const struct GNUNET_CRYPTO_PublicKey *key); - - -/** - * Creates a (Base32) string representation of the private key. - * The resulting string encodes a compacted representation of the key. - * See also #GNUNET_CRYPTO_key_get_length. - * - * @param key the key. - * @return the string representation of the key, or NULL on error. - */ -char * -GNUNET_CRYPTO_private_key_to_string ( - const struct GNUNET_CRYPTO_PrivateKey *key); - - -/** - * Parses a (Base32) string representation of the public key. - * See also #GNUNET_CRYPTO_public_key_to_string. - * - * @param str the encoded key. - * @param key where to write the key. - * @return GNUNET_SYSERR on error. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_public_key_from_string (const char*str, - struct GNUNET_CRYPTO_PublicKey *key); - - -/** - * Parses a (Base32) string representation of the private key. - * See also #GNUNET_CRYPTO_private_key_to_string. - * - * @param str the encoded key. - * @param key where to write the key. - * @return GNUNET_SYSERR on error. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_private_key_from_string (const char*str, - struct GNUNET_CRYPTO_PrivateKey *key); - - -/** - * Retrieves the public key representation of a private key. - * - * @param privkey the private key. - * @param key the public key result. - * @return GNUNET_SYSERR on error. - */ -enum GNUNET_GenericReturnValue -GNUNET_CRYPTO_key_get_public (const struct - GNUNET_CRYPTO_PrivateKey *privkey, - struct GNUNET_CRYPTO_PublicKey *key); - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - - -/* ifndef GNUNET_CRYPTO_LIB_H */ -#endif - -/** @} */ /* end of group addition */ - -/* end of gnunet_crypto_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_disk_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_disk_lib.h @@ -1,830 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2012 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Disk IO APIs - * - * @defgroup disk Disk library - * Disk IO APIs - * @{ - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_DISK_LIB_H -#define GNUNET_DISK_LIB_H - -/** - * Handle used to manage a pipe. - */ -struct GNUNET_DISK_PipeHandle; - -/** - * Type of a handle. - */ -enum GNUNET_FILE_Type -{ - /** - * Handle represents an event. - */ - GNUNET_DISK_HANLDE_TYPE_EVENT, - - /** - * Handle represents a file. - */ - GNUNET_DISK_HANLDE_TYPE_FILE, - - /** - * Handle represents a pipe. - */ - GNUNET_DISK_HANLDE_TYPE_PIPE -}; - -/** - * Handle used to access files (and pipes). - */ -struct GNUNET_DISK_FileHandle -{ - /** - * File handle on Unix-like systems. - */ - int fd; -}; - - -/* we need size_t, and since it can be both unsigned int - or unsigned long long, this IS platform dependent; - but "stdlib.h" should be portable 'enough' to be - unconditionally available... */ - -#include <stdlib.h> -#include "gnunet_configuration_lib.h" -#include "gnunet_scheduler_lib.h" - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Specifies how a file should be opened. - */ -enum GNUNET_DISK_OpenFlags -{ - /** - * Open the file for reading - */ - GNUNET_DISK_OPEN_READ = 1, - - /** - * Open the file for writing - */ - GNUNET_DISK_OPEN_WRITE = 2, - - /** - * Open the file for both reading and writing - */ - GNUNET_DISK_OPEN_READWRITE = 3, - - /** - * Fail if file already exists - */ - GNUNET_DISK_OPEN_FAILIFEXISTS = 4, - - /** - * Truncate file if it exists - */ - GNUNET_DISK_OPEN_TRUNCATE = 8, - - /** - * Create file if it doesn't exist - */ - GNUNET_DISK_OPEN_CREATE = 16, - - /** - * Append to the file - */ - GNUNET_DISK_OPEN_APPEND = 32 -}; - -/** - * Specifies what type of memory map is desired. - */ -enum GNUNET_DISK_MapType -{ - /** - * Read-only memory map. - */ - GNUNET_DISK_MAP_TYPE_READ = 1, - - /** - * Write-able memory map. - */ - GNUNET_DISK_MAP_TYPE_WRITE = 2, - - /** - * Read-write memory map. - */ - GNUNET_DISK_MAP_TYPE_READWRITE = 3 -}; - - -/** - * File access permissions, UNIX-style. - */ -enum GNUNET_DISK_AccessPermissions -{ - /** - * Nobody is allowed to do anything to the file. - */ - GNUNET_DISK_PERM_NONE = 0, - - /** - * Owner can read. - */ - GNUNET_DISK_PERM_USER_READ = 1, - - /** - * Owner can write. - */ - GNUNET_DISK_PERM_USER_WRITE = 2, - - /** - * Owner can execute. - */ - GNUNET_DISK_PERM_USER_EXEC = 4, - - /** - * Group can read. - */ - GNUNET_DISK_PERM_GROUP_READ = 8, - - /** - * Group can write. - */ - GNUNET_DISK_PERM_GROUP_WRITE = 16, - - /** - * Group can execute. - */ - GNUNET_DISK_PERM_GROUP_EXEC = 32, - - /** - * Everybody can read. - */ - GNUNET_DISK_PERM_OTHER_READ = 64, - - /** - * Everybody can write. - */ - GNUNET_DISK_PERM_OTHER_WRITE = 128, - - /** - * Everybody can execute. - */ - GNUNET_DISK_PERM_OTHER_EXEC = 256 -}; - - -/** - * Constants for specifying how to seek. Do not change values or order, - * some of the code depends on the specific numeric values! - */ -enum GNUNET_DISK_Seek -{ - /** - * Seek an absolute position (from the start of the file). - */ - GNUNET_DISK_SEEK_SET = 0, - - /** - * Seek a relative position (from the current offset). - */ - GNUNET_DISK_SEEK_CUR = 1, - - /** - * Seek an absolute position from the end of the file. - */ - GNUNET_DISK_SEEK_END = 2 -}; - - -/** - * Enumeration identifying the two ends of a pipe. - */ -enum GNUNET_DISK_PipeEnd -{ - /** - * The reading-end of a pipe. - */ - GNUNET_DISK_PIPE_END_READ = 0, - - /** - * The writing-end of a pipe. - */ - GNUNET_DISK_PIPE_END_WRITE = 1 -}; - - -/** - * Checks whether a handle is invalid - * - * @param h handle to check - * @return #GNUNET_YES if invalid, #GNUNET_NO if valid - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); - - -/** - * Check that fil corresponds to a filename - * (of a file that exists and that is not a directory). - * - * @param fil filename to check - * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something - * else (will print an error message in that case, too). - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_test (const char *fil); - -/** - * Check that fil corresponds to a filename and the file has read permissions. - * - * @param fil filename to check - * @return #GNUNET_YES if yes, #GNUNET_NO if file doesn't exist or - * has no read permissions, #GNUNET_SYSERR if something else - * (will print an error message in that case, too). - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_test_read (const char *fil); - -/** - * Move a file out of the way (create a backup) by renaming it to "orig.NUM~" - * where NUM is the smallest number that is not used yet. - * - * @param fil name of the file to back up - */ -void -GNUNET_DISK_file_backup (const char *fil); - - -/** - * Move the read/write pointer in a file - * @param h handle of an open file - * @param offset position to move to - * @param whence specification to which position the offset parameter relates to - * @return the new position on success, #GNUNET_SYSERR otherwise - */ -off_t -GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, - off_t offset, - enum GNUNET_DISK_Seek whence); - - -/** - * Get the size of the file (or directory) of the given file (in - * bytes). - * - * @param filename name of the file or directory - * @param size set to the size of the file (or, - * in the case of directories, the sum - * of all sizes of files in the directory) - * @param include_symbolic_links should symbolic links be - * included? - * @param single_file_mode #GNUNET_YES to only get size of one file - * and return #GNUNET_SYSERR for directories. - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_size (const char *filename, - uint64_t *size, - int include_symbolic_links, - int single_file_mode); - - -/** - * Obtain some unique identifiers for the given file - * that can be used to identify it in the local system. - * This function is used between GNUnet processes to - * quickly check if two files with the same absolute path - * are actually identical. The two processes represent - * the same peer but may communicate over the network - * (and the file may be on an NFS volume). This function - * may not be supported on all operating systems. - * - * @param filename name of the file - * @param dev set to the device ID - * @param ino set to the inode ID - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_get_identifiers (const char *filename, - uint64_t *dev, - uint64_t *ino); - - -/** - * Create an (empty) temporary file on disk. If the given name is not - * an absolute path, the current 'TMPDIR' will be prepended. In any case, - * 6 random characters will be appended to the name to create a unique - * filename. - * - * @param t component to use for the name; - * does NOT contain "XXXXXX" or "/tmp/". - * @return NULL on error, otherwise name of fresh - * file on disk in directory for temporary files - */ -char * -GNUNET_DISK_mktemp (const char *t); - - -/** - * Create an (empty) temporary directory on disk. If the given name is not an - * absolute path, the current 'TMPDIR' will be prepended. In any case, 6 - * random characters will be appended to the name to create a unique name. - * - * @param t component to use for the name; - * does NOT contain "XXXXXX" or "/tmp/". - * @return NULL on error, otherwise name of freshly created directory - */ -char * -GNUNET_DISK_mkdtemp (const char *t); - - -/** - * Open a file. Note that the access permissions will only be - * used if a new file is created and if the underlying operating - * system supports the given permissions. - * - * @param fn file name to be opened - * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags - * @param perm permissions for the newly created file, use - * #GNUNET_DISK_PERM_NONE if a file could not be created by this - * call (because of flags) - * @return IO handle on success, NULL on error - */ -struct GNUNET_DISK_FileHandle * -GNUNET_DISK_file_open (const char *fn, - enum GNUNET_DISK_OpenFlags flags, - enum GNUNET_DISK_AccessPermissions perm); - - -/** - * Get the size of an open file. - * - * @param fh open file handle - * @param size where to write size of the file - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, - off_t *size); - - -/** - * Flags for #GNUNET_DISK_pipe(). - */ -enum GNUNET_DISK_PipeFlags -{ - - /** - * No special options, use non-blocking read/write operations. - */ - GNUNET_DISK_PF_NONE, - - /** - * Configure read end to block when reading if set. - */ - GNUNET_DISK_PF_BLOCKING_READ = 1, - - /** - * Configure write end to block when writing if set. - */ - GNUNET_DISK_PF_BLOCKING_WRITE = 2, - - /** - * Configure both pipe ends for blocking operations if set. - */ - GNUNET_DISK_PF_BLOCKING_RW = GNUNET_DISK_PF_BLOCKING_READ - | GNUNET_DISK_PF_BLOCKING_WRITE - -}; - - -/** - * Creates an interprocess channel - * - * @param pf how to configure the pipe - * @return handle to the new pipe, NULL on error - */ -struct GNUNET_DISK_PipeHandle * -GNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf); - - -/** - * Creates a pipe object from a couple of file descriptors. - * Useful for wrapping existing pipe FDs. - * - * @param pf how to configure the pipe - * @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes - * @return handle to the new pipe, NULL on error - */ -struct GNUNET_DISK_PipeHandle * -GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, - int fd[2]); - - -/** - * Closes an interprocess channel - * @param p pipe - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); - - -/** - * Closes one half of an interprocess channel - * - * @param p pipe to close end of - * @param end which end of the pipe to close - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, - enum GNUNET_DISK_PipeEnd end); - - -/** - * Detaches one of the ends from the pipe. - * Detached end is a fully-functional FileHandle, it will - * not be affected by anything you do with the pipe afterwards. - * Each end of a pipe can only be detched from it once (i.e. - * it is not duplicated). - * - * @param p pipe to detach an end from - * @param end which end of the pipe to detach - * @return Detached end on success, NULL on failure - * (or if that end is not present or is closed). - */ -struct GNUNET_DISK_FileHandle * -GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, - enum GNUNET_DISK_PipeEnd end); - -/** - * Close an open file. - * - * @param h file handle - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); - - -/** - * Get the handle to a particular pipe end - * - * @param p pipe - * @param n end to access - * @return handle for the respective end - */ -const struct GNUNET_DISK_FileHandle * -GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, - enum GNUNET_DISK_PipeEnd n); - - -/** - * Update POSIX permissions mask of a file on disk. If both arguments - * are #GNUNET_NO, the file is made world-read-write-executable (777). - * Does nothing on W32. - * - * @param fn name of the file to update - * @param require_uid_match #GNUNET_YES means 700 - * @param require_gid_match #GNUNET_YES means 770 unless @a require_uid_match is set - */ -void -GNUNET_DISK_fix_permissions (const char *fn, - int require_uid_match, - int require_gid_match); - - -/** - * Get a handle from a native integer FD. - * - * @param fno native integer file descriptor - * @return file handle corresponding to the descriptor - */ -struct GNUNET_DISK_FileHandle * -GNUNET_DISK_get_handle_from_int_fd (int fno); - - -/** - * Get a handle from a native FD. - * - * @param fd native file descriptor - * @return file handle corresponding to the descriptor - */ -struct GNUNET_DISK_FileHandle * -GNUNET_DISK_get_handle_from_native (FILE *fd); - - -/** - * Read the contents of a binary file into a buffer. - * - * @param h handle to an open file - * @param result the buffer to write the result to - * @param len the maximum number of bytes to read - * @return the number of bytes read on success, #GNUNET_SYSERR on failure - */ -ssize_t -GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, - void *result, - size_t len); - - -/** - * Read the contents of a binary file into a buffer. - * Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN - * when no data can be read). - * - * @param h handle to an open file - * @param result the buffer to write the result to - * @param len the maximum number of bytes to read - * @return the number of bytes read on success, #GNUNET_SYSERR on failure - */ -ssize_t -GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, - void *result, - size_t len); - - -/** - * Read the contents of a binary file into a buffer. - * - * @param fn file name - * @param result the buffer to write the result to - * @param len the maximum number of bytes to read - * @return number of bytes read, #GNUNET_SYSERR on failure - */ -ssize_t -GNUNET_DISK_fn_read (const char *fn, - void *result, - size_t len); - - -/** - * Write a buffer to a file. - * - * @param h handle to open file - * @param buffer the data to write - * @param n number of bytes to write - * @return number of bytes written on success, #GNUNET_SYSERR on error - */ -ssize_t -GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, - const void *buffer, - size_t n); - - -/** - * Write a buffer to a file, blocking, if necessary. - * - * @param h handle to open file - * @param buffer the data to write - * @param n number of bytes to write - * @return number of bytes written on success, #GNUNET_SYSERR on error - */ -ssize_t -GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, - const void *buffer, - size_t n); - - -/** - * Write a buffer to a file atomically. The directory is created if - * necessary. Fail if @a filename already exists or if not exactly @a buf - * with @a buf_size bytes could be written to @a filename. - * - * @param fn file name - * @param buf the data to write - * @param buf_size number of bytes to write from @a buf - * @param mode file permissions - * @return #GNUNET_OK on success, - * #GNUNET_NO if a file existed under @a filename - * #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_fn_write (const char *fn, - const void *buf, - size_t buf_size, - enum GNUNET_DISK_AccessPermissions mode); - - -/** - * Copy a file. - * - * @param src file to copy - * @param dst destination file name - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_copy (const char *src, - const char *dst); - - -/** - * Scan a directory for files. - * - * @param dir_name the name of the directory - * @param callback the method to call for each file - * @param callback_cls closure for @a callback - * @return the number of files found, -1 on error - */ -int -GNUNET_DISK_directory_scan (const char *dir_name, - GNUNET_FileNameCallback callback, - void *callback_cls); - -/** - * Find all files matching a glob pattern. - * - * Currently, the glob_pattern only supports asterisks in the last - * path component. - * - * @param glob_pattern the glob pattern to search for - * @param callback the method to call for each file - * @param callback_cls closure for @a callback - * @return the number of files found, -1 on error - */ -int -GNUNET_DISK_glob (const char *glob_pattern, - GNUNET_FileNameCallback callback, - void *callback_cls); - - -/** - * Create the directory structure for storing - * a file. - * - * @param filename name of a file in the directory - * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, - * #GNUNET_NO if directory exists but is not writeable - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_directory_create_for_file (const char *filename); - - -/** - * Test if @a fil is a directory and listable. Optionally, also check if the - * directory is readable. Will not print an error message if the directory does - * not exist. Will log errors if #GNUNET_SYSERR is returned (i.e., a file exists - * with the same name). - * - * @param fil filename to test - * @param is_readable #GNUNET_YES to additionally check if @a fil is readable; - * #GNUNET_NO to disable this check - * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it - * does not exist or `stat`ed - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_directory_test (const char *fil, - int is_readable); - - -/** - * Remove all files in a directory (rm -rf). Call with caution. - * - * @param filename the file to remove - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_directory_remove (const char *filename); - - -/** - * Remove the directory given under @a option in - * section [PATHS] in configuration under @a cfg_filename - * - * @param cfg_filename configuration file to parse - * @param option option with the dir name to purge - */ -void -GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, - const char *option); - - -/** - * Implementation of "mkdir -p" - * - * @param dir the directory to create - * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_directory_create (const char *dir); - - -/** - * @brief Removes special characters as ':' from a filename. - * @param fn the filename to canonicalize - */ -void -GNUNET_DISK_filename_canonicalize (char *fn); - - -/** - * @brief Change owner of a file - * @param filename file to change - * @param user new owner of the file - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_change_owner (const char *filename, - const char *user); - - -/** - * Opaque handle for a memory-mapping operation. - */ -struct GNUNET_DISK_MapHandle; - - -/** - * Map a file into memory. - * - * @param h open file handle - * @param m handle to the new mapping (will be set) - * @param access access specification, GNUNET_DISK_MAP_TYPE_xxx - * @param len size of the mapping - * @return pointer to the mapped memory region, NULL on failure - */ -void * -GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, - struct GNUNET_DISK_MapHandle **m, - enum GNUNET_DISK_MapType access, - size_t len); - - -/** - * Unmap a file - * - * @param h mapping handle - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); - - -/** - * Write file changes to disk - * - * @param h handle to an open file - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_DISK_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_disk_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsparser_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsparser_lib.h @@ -1,1074 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2010-2014 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - - -/** - * @addtogroup libgnunetutil - * @{ - * - * @author Philipp Toelke - * @author Christian Grothoff - * - * @file - * API for helper library to parse DNS packets. - * - * @defgroup dns-parser DNS parser library - * Helper library to parse DNS packets. - * @{ - */ -#ifndef GNUNET_DNSPARSER_LIB_H -#define GNUNET_DNSPARSER_LIB_H - -/** - * Maximum length of a label in DNS. - */ -#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH 63 - -/** - * Maximum length of a name in DNS. - */ -#define GNUNET_DNSPARSER_MAX_NAME_LENGTH 253 - - -/** - * A few common DNS types. - */ -#define GNUNET_DNSPARSER_TYPE_ANY 0 -#define GNUNET_DNSPARSER_TYPE_A 1 -#define GNUNET_DNSPARSER_TYPE_NS 2 -#define GNUNET_DNSPARSER_TYPE_CNAME 5 -#define GNUNET_DNSPARSER_TYPE_SOA 6 -#define GNUNET_DNSPARSER_TYPE_PTR 12 -#define GNUNET_DNSPARSER_TYPE_MX 15 -#define GNUNET_DNSPARSER_TYPE_TXT 16 -#define GNUNET_DNSPARSER_TYPE_RP 17 -#define GNUNET_DNSPARSER_TYPE_AFSDB 18 -#define GNUNET_DNSPARSER_TYPE_SIG 24 -#define GNUNET_DNSPARSER_TYPE_KEY 25 -#define GNUNET_DNSPARSER_TYPE_AAAA 28 -#define GNUNET_DNSPARSER_TYPE_LOC 29 -#define GNUNET_DNSPARSER_TYPE_SRV 33 -#define GNUNET_DNSPARSER_TYPE_NAPTR 35 -#define GNUNET_DNSPARSER_TYPE_KX 36 -#define GNUNET_DNSPARSER_TYPE_CERT 37 -#define GNUNET_DNSPARSER_TYPE_DNAME 39 -#define GNUNET_DNSPARSER_TYPE_APL 42 -#define GNUNET_DNSPARSER_TYPE_DS 43 -#define GNUNET_DNSPARSER_TYPE_SSHFP 44 -#define GNUNET_DNSPARSER_TYPE_IPSECKEY 45 -#define GNUNET_DNSPARSER_TYPE_RRSIG 46 -#define GNUNET_DNSPARSER_TYPE_NSEC 47 -#define GNUNET_DNSPARSER_TYPE_DNSKEY 48 -#define GNUNET_DNSPARSER_TYPE_DHCID 49 -#define GNUNET_DNSPARSER_TYPE_NSEC3 50 -#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 -#define GNUNET_DNSPARSER_TYPE_TLSA 52 -#define GNUNET_DNSPARSER_TYPE_SMIMEA 53 -#define GNUNET_DNSPARSER_TYPE_HIP 55 -#define GNUNET_DNSPARSER_TYPE_CDS 59 -#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 -#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY 61 -#define GNUNET_DNSPARSER_TYPE_TKEY 249 -#define GNUNET_DNSPARSER_TYPE_TSIG 250 -#define GNUNET_DNSPARSER_TYPE_ALL 255 -#define GNUNET_DNSPARSER_TYPE_URI 256 -#define GNUNET_DNSPARSER_TYPE_CAA 257 -#define GNUNET_DNSPARSER_TYPE_TA 32768 - -/** - * A DNS query. - */ -struct GNUNET_DNSPARSER_Query -{ - /** - * Name of the record that the query is for (0-terminated). - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *name; - - /** - * See GNUNET_DNSPARSER_TYPE_*. - */ - uint16_t type; - - /** - * See GNUNET_TUN_DNS_CLASS_*. - */ - uint16_t dns_traffic_class; -}; - - -/** - * Information from MX records (RFC 1035). - */ -struct GNUNET_DNSPARSER_MxRecord -{ - /** - * Preference for this entry (lower value is higher preference). - */ - uint16_t preference; - - /** - * Name of the mail server. - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *mxhost; -}; - - -/** - * Information from SRV records (RFC 2782). - */ -struct GNUNET_DNSPARSER_SrvRecord -{ - /** - * Hostname offering the service. - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *target; - - /** - * Preference for this entry (lower value is higher preference). Clients - * will contact hosts from the lowest-priority group first and fall back - * to higher priorities if the low-priority entries are unavailable. - */ - uint16_t priority; - - /** - * Relative weight for records with the same priority. Clients will use - * the hosts of the same (lowest) priority with a probability proportional - * to the weight given. - */ - uint16_t weight; - - /** - * TCP or UDP port of the service. - */ - uint16_t port; -}; - - -/** - * Information from URI records (RFC 7553). - */ -struct GNUNET_DNSPARSER_UriRecord -{ - /** - * URI of the target, - * where the URI is as specified in RFC 3986. - */ - char *target; - - /** - * Preference for this entry (lower value is higher preference). Clients - * will contact hosts from the lowest-priority group first and fall back - * to higher priorities if the low-priority entries are unavailable. - */ - uint16_t priority; - - /** - * Relative weight for records with the same priority. Clients will use - * the hosts of the same (lowest) priority with a probability proportional - * to the weight given. - */ - uint16_t weight; -}; - - -/** - * DNS CERT types as defined in RFC 4398. - */ -enum GNUNET_DNSPARSER_CertType -{ - /** - * Reserved value - */ - GNUNET_DNSPARSER_CERTTYPE_RESERVED = 0, - - /** - * An x509 PKIX certificate - */ - GNUNET_DNSPARSER_CERTTYPE_PKIX = 1, - - /** - * A SKPI certificate - */ - GNUNET_DNSPARSER_CERTTYPE_SKPI = 2, - - /** - * A PGP certificate - */ - GNUNET_DNSPARSER_CERTTYPE_PGP = 3, - - /** - * An x509 PKIX cert URL - */ - GNUNET_DNSPARSER_CERTTYPE_IPKIX = 4, - - /** - * A SKPI cert URL - */ - GNUNET_DNSPARSER_CERTTYPE_ISKPI = 5, - - /** - * A PGP cert fingerprint and URL - */ - GNUNET_DNSPARSER_CERTTYPE_IPGP = 6, - - /** - * An attribute Certificate - */ - GNUNET_DNSPARSER_CERTTYPE_ACPKIX = 7, - - /** - * An attribute cert URL - */ - GNUNET_DNSPARSER_CERTTYPE_IACKPIX = 8 -}; - - -/** - * DNSCERT algorithms as defined in http://www.iana.org/assignments/ - * dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml, under dns-sec-alg-numbers-1 - */ -enum GNUNET_DNSPARSER_CertAlgorithm -{ - /** - * No defined - */ - GNUNET_DNSPARSER_CERTALGO_UNDEFINED = 0, - - /** - * RSA/MD5 - */ - GNUNET_DNSPARSER_CERTALGO_RSAMD5 = 1, - - /** - * Diffie-Hellman - */ - GNUNET_DNSPARSER_CERTALGO_DH = 2, - - /** - * DSA/SHA1 - */ - GNUNET_DNSPARSER_CERTALGO_DSASHA = 3, - - /** - * Reserved - */ - GNUNET_DNSPARSER_CERTALGO_RSRVD4 = 4, - - /** - * RSA/SHA1 - */ - GNUNET_DNSPARSER_CERTALGO_RSASHA = 5, - - /** - * DSA/NSEC3/SHA - */ - GNUNET_DNSPARSER_CERTALGO_DSANSEC3 = 6, - - /** - * RSA/NSEC3/SHA - */ - GNUNET_DNSPARSER_CERTALGO_RSANSEC3 = 7, - - /** - * RSA/SHA256 - */ - GNUNET_DNSPARSER_CERTALGO_RSASHA256 = 8, - - /** - * Reserved - */ - GNUNET_DNSPARSER_CERTALGO_RSRVD9 = 9, - - /** - * RSA/SHA512 - */ - GNUNET_DNSPARSER_CERTALGO_RSASHA512 = 10, - - /** - * GHOST R 34.10-2001 - */ - GNUNET_DNSPARSER_CERTALGO_GOST_R34 = 12, - - /** - * ECDSA Curve P-256/SHA256 - */ - GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256 = 13, - - /** - * ECDSA Curve P-384/SHA384 - */ - GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384 = 14 -}; - - -/** - * Information from CERT records (RFC 4034). - */ -struct GNUNET_DNSPARSER_CertRecord -{ - /** - * Certificate type - */ - enum GNUNET_DNSPARSER_CertType cert_type; - - /** - * Certificate KeyTag - */ - uint16_t cert_tag; - - /** - * Algorithm - */ - enum GNUNET_DNSPARSER_CertAlgorithm algorithm; - - /** - * Number of bytes in @e certificate_data - */ - size_t certificate_size; - - /** - * Data of the certificate. - */ - char *certificate_data; -}; - - -/** - * Information from SOA records (RFC 1035). - */ -struct GNUNET_DNSPARSER_SoaRecord -{ - /** - * The domainname of the name server that was the - * original or primary source of data for this zone. - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *mname; - - /** - * A domainname which specifies the mailbox of the - * person responsible for this zone. - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *rname; - - /** - * The version number of the original copy of the zone. - */ - uint32_t serial; - - /** - * Time interval before the zone should be refreshed. - */ - uint32_t refresh; - - /** - * Time interval that should elapse before a failed refresh should - * be retried. - */ - uint32_t retry; - - /** - * Time value that specifies the upper limit on the time interval - * that can elapse before the zone is no longer authoritative. - */ - uint32_t expire; - - /** - * The bit minimum TTL field that should be exported with any RR - * from this zone. - */ - uint32_t minimum_ttl; -}; - - -/** - * Information from CAA records (RFC 6844). - * The tag is followed by the tag_len. - * The value is followed by the tag for (d - tag_len - 2) bytes - */ -struct GNUNET_DNSPARSER_CaaRecord -{ - /** - * The flags of the CAA record. - */ - uint8_t flags; - - /** - * The length of the tag. - */ - uint8_t tag_len; -}; - - -/** - * Binary record information (unparsed). - */ -struct GNUNET_DNSPARSER_RawRecord -{ - /** - * Binary record data. - */ - void *data; - - /** - * Number of bytes in data. - */ - size_t data_len; -}; - - -/** - * A DNS response record. - */ -struct GNUNET_DNSPARSER_Record -{ - /** - * Name of the record that the query is for (0-terminated). - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *name; - - /** - * Payload of the record (which one of these is valid depends on the 'type'). - */ - union - { - /** - * For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname. - * In UTF-8 format. The library will convert from and to DNS-IDNA - * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an - * individual label is well-formed. If a given name is not well-formed, - * creating the DNS packet will fail. - */ - char *hostname; - - /** - * SOA data for SOA records. - */ - struct GNUNET_DNSPARSER_SoaRecord *soa; - - /** - * CERT data for CERT records. - */ - struct GNUNET_DNSPARSER_CertRecord *cert; - - /** - * MX data for MX records. - */ - struct GNUNET_DNSPARSER_MxRecord *mx; - - /** - * SRV data for SRV records. - */ - struct GNUNET_DNSPARSER_SrvRecord *srv; - - /** - * URI data for URI records. - */ - struct GNUNET_DNSPARSER_UriRecord *uri; - - /** - * Raw data for all other types. - */ - struct GNUNET_DNSPARSER_RawRecord raw; - } data; - - - /** - * When does the record expire? - */ - struct GNUNET_TIME_Absolute expiration_time; - - /** - * See GNUNET_DNSPARSER_TYPE_*. - */ - uint16_t type; - - /** - * See GNUNET_TUN_DNS_CLASS_*. - */ - uint16_t dns_traffic_class; -}; - - -/** - * Easy-to-process, parsed version of a DNS packet. - */ -struct GNUNET_DNSPARSER_Packet -{ - /** - * Array of all queries in the packet, must contain "num_queries" entries. - */ - struct GNUNET_DNSPARSER_Query *queries; - - /** - * Array of all answers in the packet, must contain "num_answers" entries. - */ - struct GNUNET_DNSPARSER_Record *answers; - - /** - * Array of all authority records in the packet, must contain "num_authority_records" entries. - */ - struct GNUNET_DNSPARSER_Record *authority_records; - - /** - * Array of all additional answers in the packet, must contain "num_additional_records" entries. - */ - struct GNUNET_DNSPARSER_Record *additional_records; - - /** - * Number of queries in the packet. - */ - unsigned int num_queries; - - /** - * Number of answers in the packet, should be 0 for queries. - */ - unsigned int num_answers; - - /** - * Number of authoritative answers in the packet, should be 0 for queries. - */ - unsigned int num_authority_records; - - /** - * Number of additional records in the packet, should be 0 for queries. - */ - unsigned int num_additional_records; - - /** - * Bitfield of DNS flags. - */ - struct GNUNET_TUN_DnsFlags flags; - - /** - * DNS ID (to match replies to requests). - */ - uint16_t id; -}; - - -/** - * Check if a label in UTF-8 format can be coded into valid IDNA. - * This can fail if the ASCII-conversion becomes longer than 63 characters. - * - * @param label label to check (UTF-8 string) - * @return #GNUNET_OK if the label can be converted to IDNA, - * #GNUNET_SYSERR if the label is not valid for DNS names - */ -int -GNUNET_DNSPARSER_check_label (const char *label); - - -/** - * Check if a hostname in UTF-8 format can be coded into valid IDNA. - * This can fail if a label becomes longer than 63 characters or if - * the entire name exceeds 253 characters. - * - * @param name name to check (UTF-8 string) - * @return #GNUNET_OK if the label can be converted to IDNA, - * #GNUNET_SYSERR if the label is not valid for DNS names - */ -int -GNUNET_DNSPARSER_check_name (const char *name); - - -/** - * Parse a UDP payload of a DNS packet in to a nice struct for further - * processing and manipulation. - * - * @param udp_payload wire-format of the DNS packet - * @param udp_payload_length number of bytes in @a udp_payload - * @return NULL on error, otherwise the parsed packet - */ -struct GNUNET_DNSPARSER_Packet * -GNUNET_DNSPARSER_parse (const char *udp_payload, - size_t udp_payload_length); - - -/** - * Free memory taken by a packet. - * - * @param p packet to free - */ -void -GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p); - - -/** - * Given a DNS packet @a p, generate the corresponding UDP payload. - * Note that we do not attempt to pack the strings with pointers - * as this would complicate the code and this is about being - * simple and secure, not fast, fancy and broken like bind. - * - * @param p packet to pack - * @param max maximum allowed size for the resulting UDP payload - * @param buf set to a buffer with the packed message - * @param buf_length set to the length of @a buf - * @return #GNUNET_SYSERR if @a p is invalid - * #GNUNET_NO if @a p was truncated (but there is still a result in @a buf) - * #GNUNET_OK if @a p was packed completely into @a buf - */ -int -GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, - uint16_t max, - char **buf, - size_t *buf_length); - -/* ***************** low-level packing API ******************** */ - -/** - * Add a DNS name to the UDP packet at the given location, converting - * the name to IDNA notation as necessary. - * - * @param dst where to write the name (UDP packet) - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the name (increment by bytes used) - * must not be changed if there is an error - * @param name name to write - * @return #GNUNET_SYSERR if @a name is invalid - * #GNUNET_NO if @a name did not fit - * #GNUNET_OK if @a name was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_name (char *dst, - size_t dst_len, - size_t *off, - const char *name); - - -/** - * Add a DNS query to the UDP packet at the given location. - * - * @param dst where to write the query - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the query (increment by bytes used) - * must not be changed if there is an error - * @param query query to write - * @return #GNUNET_SYSERR if @a query is invalid - * #GNUNET_NO if @a query did not fit - * #GNUNET_OK if @a query was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_query (char *dst, - size_t dst_len, - size_t *off, - const struct GNUNET_DNSPARSER_Query *query); - - -/** - * Add an MX record to the UDP packet at the given location. - * - * @param dst where to write the mx record - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the mx information (increment by bytes used); - * can also change if there was an error - * @param mx mx information to write - * @return #GNUNET_SYSERR if @a mx is invalid - * #GNUNET_NO if @a mx did not fit - * #GNUNET_OK if @a mx was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_mx (char *dst, - size_t dst_len, - size_t *off, - const struct GNUNET_DNSPARSER_MxRecord *mx); - - -/** - * Add an SOA record to the UDP packet at the given location. - * - * @param dst where to write the SOA record - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the SOA information (increment by bytes used) - * can also change if there was an error - * @param soa SOA information to write - * @return #GNUNET_SYSERR if @a soa is invalid - * #GNUNET_NO if @a soa did not fit - * #GNUNET_OK if @a soa was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_soa (char *dst, - size_t dst_len, - size_t *off, - const struct GNUNET_DNSPARSER_SoaRecord *soa); - - -/** - * Add CERT record to the UDP packet at the given location. - * - * @param dst where to write the CERT record - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the CERT information (increment by bytes used) - * can also change if there was an error - * @param cert CERT information to write - * @return #GNUNET_SYSERR if @a soa is invalid - * #GNUNET_NO if @a soa did not fit - * #GNUNET_OK if @a soa was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_cert (char *dst, - size_t dst_len, - size_t *off, - const struct - GNUNET_DNSPARSER_CertRecord *cert); - - -/** - * Add an SRV record to the UDP packet at the given location. - * - * @param dst where to write the SRV record - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the SRV information (increment by bytes used) - * can also change if there was an error - * @param srv SRV information to write - * @return #GNUNET_SYSERR if @a srv is invalid - * #GNUNET_NO if @a srv did not fit - * #GNUNET_OK if @a srv was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_srv (char *dst, - size_t dst_len, - size_t *off, - const struct GNUNET_DNSPARSER_SrvRecord *srv); - - -/** - * Add an URI record to the UDP packet at the given location. - * - * @param dst where to write the URI record - * @param dst_len number of bytes in @a dst - * @param off pointer to offset where to write the URI information (increment by bytes used) - * can also change if there was an error - * @param uri URI information to write - * @return #GNUNET_SYSERR if @a uri is invalid - * #GNUNET_NO if @a uri did not fit - * #GNUNET_OK if @a uri was added to @a dst - */ -int -GNUNET_DNSPARSER_builder_add_uri (char *dst, - size_t dst_len, - size_t *off, - const struct GNUNET_DNSPARSER_UriRecord *uri); - -/* ***************** low-level parsing API ******************** */ - -/** - * Parse a DNS record entry. - * - * @param udp_payload entire UDP payload - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the record to parse in the udp_payload (to be - * incremented by the size of the record) - * @param r where to write the record information - * @return #GNUNET_OK on success, #GNUNET_SYSERR if the record is malformed - */ -int -GNUNET_DNSPARSER_parse_record (const char *udp_payload, - size_t udp_payload_length, - size_t *off, - struct GNUNET_DNSPARSER_Record *r); - - -/** - * Parse name inside of a DNS query or record. - * - * @param udp_payload entire UDP payload - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the name to parse in the udp_payload (to be - * incremented by the size of the name) - * @return name as 0-terminated C string on success, NULL if the payload is malformed - */ -char * -GNUNET_DNSPARSER_parse_name (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - - -/** - * Parse a DNS query entry. - * - * @param udp_payload entire UDP payload - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the udp_payload (to be - * incremented by the size of the query) - * @param q where to write the query information - * @return #GNUNET_OK on success, #GNUNET_SYSERR if the query is malformed - */ -int -GNUNET_DNSPARSER_parse_query (const char *udp_payload, - size_t udp_payload_length, - size_t *off, - struct GNUNET_DNSPARSER_Query *q); - - -/** - * Parse a DNS SOA record. - * - * @param udp_payload reference to UDP packet - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the SOA record (to be - * incremented by the size of the record), unchanged on error - * @return the parsed SOA record, NULL on error - */ -struct GNUNET_DNSPARSER_SoaRecord * -GNUNET_DNSPARSER_parse_soa (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - - -/** - * Parse a DNS CERT record. - * - * @param udp_payload reference to UDP packet - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the CERT record (to be - * incremented by the size of the record), unchanged on error - * @return the parsed CERT record, NULL on error - */ -struct GNUNET_DNSPARSER_CertRecord * -GNUNET_DNSPARSER_parse_cert (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - - -/** - * Parse a DNS MX record. - * - * @param udp_payload reference to UDP packet - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the MX record (to be - * incremented by the size of the record), unchanged on error - * @return the parsed MX record, NULL on error - */ -struct GNUNET_DNSPARSER_MxRecord * -GNUNET_DNSPARSER_parse_mx (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - - -/** - * Parse a DNS SRV record. - * - * @param udp_payload reference to UDP packet - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the SRV record (to be - * incremented by the size of the record), unchanged on error - * @return the parsed SRV record, NULL on error - */ -struct GNUNET_DNSPARSER_SrvRecord * -GNUNET_DNSPARSER_parse_srv (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - - -/** - * Parse a DNS URI record. - * - * @param udp_payload reference to UDP packet - * @param udp_payload_length length of @a udp_payload - * @param off pointer to the offset of the query to parse in the URI record (to be - * incremented by the size of the record), unchanged on error - * @return the parsed URI record, NULL on error - */ -struct GNUNET_DNSPARSER_UriRecord * -GNUNET_DNSPARSER_parse_uri (const char *udp_payload, - size_t udp_payload_length, - size_t *off); - -/* ***************** low-level duplication API ******************** */ - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_Record * -GNUNET_DNSPARSER_duplicate_record (const struct GNUNET_DNSPARSER_Record *r); - - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_SoaRecord * -GNUNET_DNSPARSER_duplicate_soa_record (const struct - GNUNET_DNSPARSER_SoaRecord *r); - - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_CertRecord * -GNUNET_DNSPARSER_duplicate_cert_record (const struct - GNUNET_DNSPARSER_CertRecord *r); - - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_MxRecord * -GNUNET_DNSPARSER_duplicate_mx_record (const struct - GNUNET_DNSPARSER_MxRecord *r); - - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_SrvRecord * -GNUNET_DNSPARSER_duplicate_srv_record (const struct - GNUNET_DNSPARSER_SrvRecord *r); - - -/** - * Duplicate (deep-copy) the given DNS record - * - * @param r the record - * @return the newly allocated record - */ -struct GNUNET_DNSPARSER_UriRecord * -GNUNET_DNSPARSER_duplicate_uri_record (const struct - GNUNET_DNSPARSER_UriRecord *r); - -/* ***************** low-level deallocation API ******************** */ - -/** - * Free the given DNS record. - * - * @param r record to free - */ -void -GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r); - - -/** - * Free MX information record. - * - * @param mx record to free - */ -void -GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx); - - -/** - * Free SRV information record. - * - * @param srv record to free - */ -void -GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv); - - -/** - * Free URI information record. - * - * @param uri record to free - */ -void -GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri); - - -/** - * Free SOA information record. - * - * @param soa record to free - */ -void -GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa); - - -/** - * Free CERT information record. - * - * @param cert record to free - */ -void -GNUNET_DNSPARSER_free_cert (struct GNUNET_DNSPARSER_CertRecord *cert); - - -/** - * Convert a block of binary data to HEX. - * - * @param data binary data to convert - * @param data_size number of bytes in @a data - * @return HEX string (lower case) - */ -char * -GNUNET_DNSPARSER_bin_to_hex (const void *data, - size_t data_size); - - -/** - * Convert a HEX string to block of binary data. - * - * @param hex HEX string to convert (may contain mixed case) - * @param data where to write result, must be - * at least `strlen(hex)/2` bytes long - * @return number of bytes written to data - */ -size_t -GNUNET_DNSPARSER_hex_to_bin (const char *hex, - void *data); - - -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsstub_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_dnsstub_lib.h @@ -1,159 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2012, 2018 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * @{ - * - * @author Christian Grothoff - * - * @file - * API for helper library to send DNS requests to DNS resolver - * - * @defgroup dns-stub DNS Stub library - * Helper library to send DNS requests to DNS resolver - * @{ - */ -#ifndef GNUNET_DNSSTUB_LIB_H -#define GNUNET_DNSSTUB_LIB_H - - -#include "gnunet_util_lib.h" - -/** - * Opaque handle to the stub resolver. - */ -struct GNUNET_DNSSTUB_Context; - -/** - * Opaque handle to a socket doing UDP requests. - */ -struct GNUNET_DNSSTUB_RequestSocket; - - -/** - * Start a DNS stub resolver. - * - * @param num_sockets how many sockets should we open - * in parallel for DNS queries for this stub? - * @return NULL on error - */ -struct GNUNET_DNSSTUB_Context * -GNUNET_DNSSTUB_start (unsigned int num_sockets); - - -/** - * Add nameserver for use by the DNSSTUB. We will use - * all provided nameservers for resolution (round-robin). - * - * @param ctx resolver context to modify - * @param dns_ip target IP address to use (as string) - * @return #GNUNET_OK on success - */ -int -GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx, - const char *dns_ip); - - -/** - * Add nameserver for use by the DNSSTUB. We will use - * all provided nameservers for resolution (round-robin). - * - * @param ctx resolver context to modify - * @param sa socket address of DNS resolver to use - * @return #GNUNET_OK on success - */ -int -GNUNET_DNSSTUB_add_dns_sa (struct GNUNET_DNSSTUB_Context *ctx, - const struct sockaddr *sa); - - -/** - * How long should we try requests before timing out? - * Only effective for requests issued after this call. - * - * @param ctx resolver context to modify - * @param retry_freq how long to wait between retries - */ -void -GNUNET_DNSSTUB_set_retry (struct GNUNET_DNSSTUB_Context *ctx, - struct GNUNET_TIME_Relative retry_freq); - -/** - * Cleanup DNSSTUB resolver. - * - * @param ctx stub resolver to clean up - */ -void -GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx); - - -/** - * Function called with the result of a DNS resolution. - * Once this function is called, the resolution request - * is automatically cancelled / cleaned up. In particular, - * the function will only be called once. - * - * @param cls closure - * @param dns dns response, NULL on hard error (i.e. timeout) - * @param dns_len number of bytes in @a dns - */ -typedef void -(*GNUNET_DNSSTUB_ResultCallback)(void *cls, - const struct GNUNET_TUN_DnsHeader *dns, - size_t dns_len); - - -/** - * Perform DNS resolution using our default IP from init. - * - * @param ctx stub resolver to use - * @param request DNS request to transmit - * @param request_len number of bytes in msg - * @param rc function to call with result (once) - * @param rc_cls closure for @a rc - * @return socket used for the request, NULL on error - */ -struct GNUNET_DNSSTUB_RequestSocket * -GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx, - const void *request, - size_t request_len, - GNUNET_DNSSTUB_ResultCallback rc, - void *rc_cls); - - -/** - * Cancel DNS resolution. - * - * @param rs resolution to cancel - */ -void -GNUNET_DNSSTUB_resolve_cancel (struct GNUNET_DNSSTUB_RequestSocket *rs); - - -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_error_codes.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_error_codes.h @@ -1,242 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2012-2022 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - /** - * @file include/taler_error_codes.h - * @brief GNUnet error codes, generated via https://gana.gnunet.org/ - * - * Do NOT edit this file, it is generated! - */ -#ifndef GNUNET_ERROR_CODES_H -#define GNUNET_ERROR_CODES_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -#include <limits.h> - - -/** - * Taler error codes. - */ -enum GNUNET_ErrorCode -{ - - - /** - * No error (success). - * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). - */ - GNUNET_EC_NONE = 0, - - - /** - * Unknown and unspecified error. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_UNKNOWN = 1, - - - /** - * Communication with service failed. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_SERVICE_COMMUNICATION_FAILED = 101, - - - /** - * Ego not found. - * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). - */ - GNUNET_EC_IDENTITY_NOT_FOUND = 200, - - - /** - * Identifier already in use for another ego. - * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). - */ - GNUNET_EC_IDENTITY_NAME_CONFLICT = 201, - - - /** - * The given ego is invalid or malformed. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_IDENTITY_INVALID = 202, - - - /** - * Unknown namestore error. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_UNKNOWN = 5000, - - - /** - * Zone iteration failed. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_ITERATION_FAILED = 5001, - - - /** - * Zone not found. - * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). - */ - GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND = 5002, - - - /** - * Record not found. - * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). - */ - GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND = 5003, - - - /** - * Zone iteration failed. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED = 5004, - - - /** - * Zone does not contain any records. - * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). - */ - GNUNET_EC_NAMESTORE_ZONE_EMPTY = 5005, - - - /** - * Failed to lookup record. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_LOOKUP_ERROR = 5006, - - - /** - * No records given. - * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). - */ - GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN = 5007, - - - /** - * Record data invalid. - * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). - */ - GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID = 5008, - - - /** - * No label given. - * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). - */ - GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN = 5009, - - - /** - * No results given. - * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). - */ - GNUNET_EC_NAMESTORE_NO_RESULTS = 5010, - - - /** - * Record already exists. - * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). - */ - GNUNET_EC_NAMESTORE_RECORD_EXISTS = 5011, - - - /** - * Record size exceeds maximum limit. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_RECORD_TOO_BIG = 5012, - - - /** - * There was an error in the database backend. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_BACKEND_FAILED = 5013, - - - /** - * Failed to store the given records. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). - */ - GNUNET_EC_NAMESTORE_STORE_FAILED = 5014, - - - /** - * Label invalid or malformed. - * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). - */ - GNUNET_EC_NAMESTORE_LABEL_INVALID = 5015, - - -}; - - -/** - * Returns a hint for a given error code. - * - * @param ec the error code. - * @return the hint if it could be found, otherwise "<no hint found>" - */ -const char * -GNUNET_ErrorCode_get_hint (enum GNUNET_ErrorCode ec); - - -/** - * Return HTTP status for a given error code. - * - * @param ec the error code. - * @return the HTTP status code for the given @a ec, UINT_MAX if not found - */ -unsigned int -GNUNET_ErrorCode_get_http_status (enum GNUNET_ErrorCode ec); - - -/** - * Return HTTP status for a given error code that is guaranteed - * to work (no corner cases). - * - * @param ec the error code. - * @return the HTTP status code for the given @a ec, 500 if - * the @a ec is not found or is a client-side code - */ -unsigned int -GNUNET_ErrorCode_get_http_status_safe (enum GNUNET_ErrorCode ec); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_getopt_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_getopt_lib.h @@ -1,511 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2013 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Command line parsing and --help formatting - * - * @defgroup getopt Getopt library - * Command line parsing and --help formatting - * @{ - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_GETOPT_LIB_H -#define GNUNET_GETOPT_LIB_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include "gnunet_configuration_lib.h" - -/** - * @brief General context for command line processors. - */ -struct GNUNET_GETOPT_CommandLineProcessorContext -{ - /** - * Name of the application - */ - const char *binaryName; - - /** - * Name of application with option summary - */ - const char *binaryOptions; - - /** - * Array with all command line options. - */ - const struct GNUNET_GETOPT_CommandLineOption *allOptions; - - /** - * Original command line - */ - char *const *argv; - - /** - * Total number of argv's. - */ - unsigned int argc; - - /** - * Current argument. - */ - unsigned int currentArgument; -}; - - -/** - * @brief Process a command line option - * - * @param ctx context for all options - * @param scls specific closure (for this processor) - * @param option long name of the option (e.g. "config" for --config) - * @param value argument, NULL if none was given - * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort - */ -typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) ( - struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, - void *scls, - const char *option, - const char *value); - - -/** - * @brief Definition of a command line option. - */ -struct GNUNET_GETOPT_CommandLineOption -{ - /** - * Short name of the option. - */ - const char shortName; - - /** - * Long name of the option (may not be NULL) - */ - const char *name; - - /** - * Name of the argument for the user in help text - */ - const char *argumentHelp; - - /** - * Help text for the option (description) - */ - const char *description; - - /** - * Is an argument required? #GNUNET_NO (includes optional) or - * #GNUNET_YES (required) - */ - int require_argument; - - /** - * Is the presence of this option mandatory? - */ - int option_mandatory; - - /** - * Is the option exclusive? - */ - int option_exclusive; - - /** - * Handler for the option. - */ - GNUNET_GETOPT_CommandLineOptionProcessor processor; - - /** - * Function to call on @e scls to clean up after processing all - * the arguments. Can be NULL. - */ - void (*cleaner) (void *cls); - - /** - * Specific closure to pass to the processor. - */ - void *scls; -}; - - -/** - * Defining the option to print the command line - * help text (-h option). - * - * @param about string with brief description of the application - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_help (const char *about); - - -/** - * Allow user to specify a `long long` with an offset to add to the current - * system time to construct the time seen by the application. Used for - * debugging / testing. - * - * @param shortName short name of the option - * @param name long name of the option - * @param[out] val set to the time specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_timetravel (char shortName, - const char *name); - - -/** - * Define the option to print the version of - * the application (-v option) - * - * @param version string with the version number - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_version (const char *version); - - -/** - * Allow user to specify log file name (-l option) - * - * @param[out] logfn set to the name of the logfile - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_logfile (char **logfn); - - -/** - * Allow user to specify a string. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] str set to the string - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_string (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - char **str); - -/** - * Allow user to specify a filename (automatically path expanded). - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] str set to the string - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_filename (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - char **str); - - -/** - * Allow user to specify a binary value using Crockford - * Base32 encoding. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val binary value decoded from Crockford Base32-encoded argument - * @param val_size size of @a val in bytes - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_base32_fixed_size (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - void *val, - size_t val_size); - - -/** - * Allow user to specify a binary value using Crockford - * Base32 encoding where the size of the binary value is - * automatically determined from its type. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val binary value decoded from Crockford Base32-encoded argument; - * size is determined by type (sizeof (*val)). - */ -#define GNUNET_GETOPT_option_base32_auto(shortName, \ - name, \ - argumentHelp, \ - description, \ - val) \ - GNUNET_GETOPT_option_base32_fixed_size (shortName, \ - name, \ - argumentHelp, \ - description, \ - val, \ - sizeof(*val)) - - -/** - * Allow user to specify a flag (which internally means setting - * an integer to 1/#GNUNET_YES/#GNUNET_OK. - * - * @param shortName short name of the option - * @param name long name of the option - * @param description long help text for the option - * @param[out] val set to 1 if the option is present - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_flag (char shortName, - const char *name, - const char *description, - int *val); - - -/** - * Allow user to specify an `unsigned int`. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the value specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_uint (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - unsigned int *val); - - -/** - * Allow user to specify an uint16_t. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the value specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_uint16 (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - uint16_t *val); - - -/** - * Allow user to specify an `unsigned long long`. - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the value specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_ulong (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - unsigned long long *val); - - -/** - * Allow user to specify a `struct GNUNET_TIME_Relative` - * (using human-readable "fancy" time). - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the time specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_relative_time (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - struct GNUNET_TIME_Relative *val); - - -/** - * Allow user to specify a `struct GNUNET_TIME_Absolute` - * (using human-readable "fancy" time). - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the time specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_absolute_time (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - struct GNUNET_TIME_Absolute *val); - - -/** - * Allow user to specify a `struct GNUNET_TIME_Timestamp` - * (using human-readable "fancy" time). - * - * @param shortName short name of the option - * @param name long name of the option - * @param argumentHelp help text for the option argument - * @param description long help text for the option - * @param[out] val set to the time specified at the command line - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_timestamp (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - struct GNUNET_TIME_Timestamp *val); - - -/** - * Increment @a val each time the option flag is given by one. - * - * @param shortName short name of the option - * @param name long name of the option - * @param description long help text for the option - * @param[out] val set to 1 if the option is present - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_increment_uint (char shortName, - const char *name, - const char *description, - unsigned int *val); - - -/** - * Define the '-L' log level option. Note that we do not check - * that the log level is valid here. - * - * @param[out] level set to the log level - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_loglevel (char **level); - - -/** - * Define the '-V' verbosity option. Using the option more - * than once increments @a level each time. - * - * @param[out] level set to the verbosity level - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_verbose (unsigned int *level); - - -/** - * Allow user to specify configuration file name (-c option) - * - * @param[out] fn set to the name of the configuration file - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_cfgfile (char **fn); - - -/** - * Make the given option mandatory. - * - * @param opt option to modify - * @return @a opt with the mandatory flag set. - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt); - - -/** - * Make the given option mutually exclusive with other options. - * - * @param opt option to modify - * @return @a opt with the exclusive flag set. - */ -struct GNUNET_GETOPT_CommandLineOption -GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt); - - -/** - * Marker for the end of the list of options. - */ -#define GNUNET_GETOPT_OPTION_END \ - { \ - '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \ - } - - -/** - * Parse the command line. - * - * @param binaryOptions Name of application with option summary - * @param allOptions defined options and handlers - * @param argc number of arguments in @a argv - * @param argv actual arguments - * @return index into argv with first non-option - * argument, or #GNUNET_SYSERR on error - */ -int -GNUNET_GETOPT_run (const char *binaryOptions, - const struct GNUNET_GETOPT_CommandLineOption *allOptions, - unsigned int argc, - char *const *argv); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_GETOPT_LIB_H */ -#endif - -/** @} */ /* end of group getopt */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_getopt_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_helper_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_helper_lib.h @@ -1,196 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2011, 2012 Christian Grothoff - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Philipp Toelke - * @author Christian Grothoff - * - * @file - * API for dealing with SUID helper processes - * - * @defgroup helper Helper library - * Dealing with SUID helper processes. - * - * Provides an API for dealing with (SUID) helper processes - * that communicate via GNUNET_MessageHeaders on STDIN/STDOUT. - * - * @{ - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_HELPER_LIB_H -#define GNUNET_HELPER_LIB_H - - -#include "gnunet_mst_lib.h" - - -/** - * The handle to a helper process. - */ -struct GNUNET_HELPER_Handle; - - -/** - * Callback that will be called when the helper process dies. This is not called - * when the helper process is stopped using GNUNET_HELPER_stop() - * - * @param cls the closure from GNUNET_HELPER_start() - */ -typedef void -(*GNUNET_HELPER_ExceptionCallback) (void *cls); - - -/** - * Starts a helper and begins reading from it. The helper process is - * restarted when it dies except when it is stopped using GNUNET_HELPER_stop() - * or when the exp_cb callback is not NULL. - * - * @param with_control_pipe does the helper support the use of a control pipe for signalling? - * @param binary_name name of the binary to run - * @param binary_argv NULL-terminated list of arguments to give when starting the binary (this - * argument must not be modified by the client for - * the lifetime of the helper handle) - * @param cb function to call if we get messages from the helper - * @param exp_cb the exception callback to call. Set this to NULL if the helper - * process has to be restarted automatically when it dies/crashes - * @param cb_cls closure for the above callbacks - * @return the new Handle, NULL on error - */ -struct GNUNET_HELPER_Handle * -GNUNET_HELPER_start (int with_control_pipe, - const char *binary_name, - char *const binary_argv[], - GNUNET_MessageTokenizerCallback cb, - GNUNET_HELPER_ExceptionCallback exp_cb, - void *cb_cls); - - -/** - * Sends termination signal to the helper process. The helper process is not - * reaped; call GNUNET_HELPER_wait() for reaping the dead helper process. - * - * @param h the helper handle - * @param soft_kill if #GNUNET_YES, signals termination by closing the helper's - * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper - * @return #GNUNET_OK on success; #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, - int soft_kill); - - -/** - * Reap the helper process. This call is blocking (!). The helper process - * should either be sent a termination signal before or should be dead before - * calling this function - * - * @param h the helper handle - * @return #GNUNET_OK on success; #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); - - -/** - * Free's the resources occupied by the helper handle - * - * @param h the helper handle to free - */ -void -GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h); - - -/** - * Kills the helper, closes the pipe, frees the handle and calls wait() on the - * helper process - * - * @param h handle to helper to stop - * @param soft_kill if #GNUNET_YES, signals termination by closing the helper's - * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper - */ -void -GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill); - - -/** - * Continuation function. - * - * @param cls closure - * @param result #GNUNET_OK on success, - * #GNUNET_NO if helper process died - * #GNUNET_SYSERR during GNUNET_HELPER_destroy - */ -typedef void -(*GNUNET_HELPER_Continuation)( - void *cls, - enum GNUNET_GenericReturnValue result); - - -/** - * Handle to cancel 'send' - */ -struct GNUNET_HELPER_SendHandle; - - -/** - * Send an message to the helper. - * - * @param h helper to send message to - * @param msg message to send - * @param can_drop can the message be dropped if there is already one in the queue? - * @param cont continuation to run once the message is out (#GNUNET_OK on success, #GNUNET_NO - * if the helper process died, #GNUNET_SYSERR during #GNUNET_HELPER_destroy). - * @param cont_cls closure for @a cont - * @return NULL if the message was dropped, - * otherwise handle to cancel @a cont (actual transmission may - * not be abortable) - */ -struct GNUNET_HELPER_SendHandle * -GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h, - const struct GNUNET_MessageHeader *msg, - bool can_drop, - GNUNET_HELPER_Continuation cont, - void *cont_cls); - - -/** - * Cancel a #GNUNET_HELPER_send operation. If possible, transmitting - * the message is also aborted, but at least 'cont' won't be called. - * - * @param sh operation to cancel - */ -void -GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh); - - -#endif -/* end of include guard: GNUNET_HELPER_LIB_H */ - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mq_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mq_lib.h @@ -1,1137 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2012-2016 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#include "gnunet_common.h" -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Florian Dold - * @author Christian Grothoff - * - * @file - * General-purpose message queue - * - * @defgroup mq MQ library - * General-purpose message queue - * - * @see [Documentation](https://gnunet.org/message-queue-api) - * - * @{ - */ -#ifndef GNUNET_MQ_LIB_H -#define GNUNET_MQ_LIB_H - - -#include "gnunet_scheduler_lib.h" - -/** - * Allocate an envelope, with extra space allocated after the space needed - * by the message struct. - * The allocated message will already have the type and size field set. - * - * @param mvar variable to store the allocated message in; - * must have a header field; - * can be NULL - * @param esize extra space to allocate after the message - * @param type type of the message - * @return the MQ message - */ -#define GNUNET_MQ_msg_extra(mvar, esize, type) \ - GNUNET_MQ_msg_ (((struct GNUNET_MessageHeader **) &(mvar)), \ - (esize) + sizeof *(mvar), \ - (type)) - -/** - * Allocate a GNUNET_MQ_Envelope. - * The contained message will already have the type and size field set. - * - * @param mvar variable to store the allocated message in; - * must have a header field; - * can be NULL - * @param type type of the message - * @return the allocated envelope - */ -#define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra (mvar, 0, type) - - -/** - * Allocate a GNUNET_MQ_Envelope, where the message only consists of a header. - * The allocated message will already have the type and size field set. - * - * @param type type of the message - */ -#define GNUNET_MQ_msg_header(type) \ - GNUNET_MQ_msg_ (NULL, sizeof(struct GNUNET_MessageHeader), type) - - -/** - * Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space. - * The allocated message will already have the type and size field set. - * - * @param mh pointer that will changed to point at to the allocated message header - * @param esize extra space to allocate after the message header - * @param type type of the message - */ -#define GNUNET_MQ_msg_header_extra(mh, esize, type) \ - GNUNET_MQ_msg_ (&mh, (esize) + sizeof(struct GNUNET_MessageHeader), type \ - ) - - -/** - * Allocate a GNUNET_MQ_Envelope, and append a payload message after the given - * message struct. - * - * @param mvar pointer to a message struct, will be changed to point at the newly allocated message, - * whose size is 'sizeof(*mvar) + ntohs (mh->size)' - * @param type message type of the allocated message, has no effect on the nested message - * @param mh message to nest - * @return a newly allocated 'struct GNUNET_MQ_Envelope *' - */ -#define GNUNET_MQ_msg_nested_mh(mvar, type, mh) \ - ({ \ - struct GNUNET_MQ_Envelope *_ev; \ - _ev = GNUNET_MQ_msg_nested_mh_ ((struct GNUNET_MessageHeader **) &(mvar), \ - sizeof(*(mvar)), \ - (type), \ - (mh)); \ - (void) (mvar)->header; /* type check */ \ - _ev; \ - }) - - -/** - * Return a pointer to the message at the end of the given message. - * - * @param var pointer to a message struct, the type of the expression determines the base size, - * the space after the base size is the nested message - * @return a 'struct GNUNET_MessageHeader *' that points at the nested message of the given message, - * or NULL if the given message in @a var does not have any space after the message struct - */ -#define GNUNET_MQ_extract_nested_mh(var) \ - GNUNET_MQ_extract_nested_mh_ ((struct GNUNET_MessageHeader *) (var), \ - sizeof(*(var))) - - -/** - * Implementation of the #GNUNET_MQ_extract_nexted_mh macro. - * - * @param mh message header to extract nested message header from - * @param base_size size of the message before the nested message's header appears - * @return pointer to the nested message, does not copy the message - * OR NULL in case of a malformed message. - */ -const struct GNUNET_MessageHeader * -GNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh, - uint16_t base_size); - - -/** - * Opaque handle to an envelope. - */ -struct GNUNET_MQ_Envelope; - - -/** - * Obtain message contained in envelope. - * - * @param env the envelope - * @return message contained in the envelope - */ -const struct GNUNET_MessageHeader * -GNUNET_MQ_env_get_msg (const struct GNUNET_MQ_Envelope *env); - - -/** - * Return next envelope in queue. - * - * @param env a queued envelope - * @return next one, or NULL - */ -const struct GNUNET_MQ_Envelope * -GNUNET_MQ_env_next (const struct GNUNET_MQ_Envelope *env); - - -/** - * Implementation of the #GNUNET_MQ_msg_nested_mh macro. - * - * @param mhp pointer to the message header pointer that will be changed to allocate at - * the newly allocated space for the message. - * @param base_size size of the data before the nested message - * @param type type of the message in the envelope - * @param nested_mh the message to append to the message after base_size - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, - uint16_t base_size, - uint16_t type, - const struct GNUNET_MessageHeader *nested_mh); - - -/** - * Opaque handle to a message queue. - */ -struct GNUNET_MQ_Handle; - - -/** - * Error codes for the queue. - */ -enum GNUNET_MQ_Error -{ - /** - * Failed to read message from the network. - * FIXME: Likely not properly distinguished - * from TIMEOUT case in the code! - */ - GNUNET_MQ_ERROR_READ = 1, - - /** - * FIXME: document! - */ - GNUNET_MQ_ERROR_WRITE = 2, - - /** - * FIXME: document! - */ - GNUNET_MQ_ERROR_TIMEOUT = 4, - - /** - * We received a message that was malformed and thus - * could not be passed to its handler. - */ - GNUNET_MQ_ERROR_MALFORMED = 8, - - /** - * We received a message for which we have no matching - * handler. - */ - GNUNET_MQ_ERROR_NO_MATCH = 16 -}; - - -/** - * Per envelope preferences and priorities. - */ -enum GNUNET_MQ_PriorityPreferences -{ - /** - * Lowest priority, i.e. background traffic (e.g. NSE, FS). - * This is the default! - */ - GNUNET_MQ_PRIO_BACKGROUND = 0, - - /** - * Best-effort traffic (e.g. CADET relay, DHT) - */ - GNUNET_MQ_PRIO_BEST_EFFORT = 1, - - /** - * Urgent traffic (local peer, e.g. Conversation). - */ - GNUNET_MQ_PRIO_URGENT = 2, - - /** - * Highest priority, control traffic (e.g. CORE/CADET KX). - */ - GNUNET_MQ_PRIO_CRITICAL_CONTROL = 3, - - /** - * Bit mask to apply to extract the priority bits. - */ - GNUNET_MQ_PRIORITY_MASK = 3, - - /** - * Flag to indicate that unreliable delivery is acceptable. This - * means TRANSPORT will not attempt to receive an - * acknowledgment. CORE will just pass this flag through. CADET - * will use unreliable delivery if this flag is set. - * - * Note that even without this flag, messages may be lost by - * TRANSPORT and CORE. - * - * Thus, how "strong" the semantics of reliable delivery are depends - * on the layer! - */ - GNUNET_MQ_PREF_UNRELIABLE = 16, - - /** - * Flag to indicate that low latency is important. This flag must - * generally not be used in combination with - * #GNUNET_MQ_PREF_CORKING_ALLOWED as it would be a contradiction. - * When this flags is set, the envelope may skip forward in the - * queue (depending on priority) and also TRANSPORT should attempt - * to pick a communicator with particularly low latency. - */ - GNUNET_MQ_PREF_LOW_LATENCY = 32, - - /** - * Flag to indicate that CORKing is acceptable. This allows the - * receiver to delay transmission in hope of combining this message - * with other messages into a larger transmission with less - * per-message overhead. - */ - GNUNET_MQ_PREF_CORK_ALLOWED = 64, - - /** - * Flag to indicate that high bandwidth is desired. This flag - * indicates that the method chosen for transmission should focus on - * overall goodput. It rarely makes sense to combine this flag with - * #GNUNET_MQ_PREF_LOW_LATENCY. - */ - GNUNET_MQ_PREF_GOODPUT = 128, - - /** - * Flag to indicate that out-of-order delivery is OK. - */ - GNUNET_MQ_PREF_OUT_OF_ORDER = 256, -}; - - -/** - * Called when a message has been received. - * - * @param cls closure - * @param msg the received message - */ -typedef void -(*GNUNET_MQ_MessageCallback) ( - void *cls, - const struct GNUNET_MessageHeader *msg); - - -/** - * Called when a message needs to be validated. - * - * @param cls closure - * @param msg the received message - * @return #GNUNET_OK if the message is well-formed, - * #GNUNET_SYSERR if not - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_MQ_MessageValidationCallback) ( - void *cls, - const struct GNUNET_MessageHeader *msg); - - -/** - * Signature of functions implementing the - * sending functionality of a message queue. - * - * @param mq the message queue - * @param msg the message to send - * @param impl_state state of the implementation - */ -typedef void -(*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, - const struct GNUNET_MessageHeader *msg, - void *impl_state); - - -/** - * Signature of functions implementing the - * destruction of a message queue. - * Implementations must not free @a mq, but should - * take care of @a impl_state. - * - * @param mq the message queue to destroy - * @param impl_state state of the implementation - */ -typedef void -(*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, - void *impl_state); - - -/** - * Implementation function that cancels the currently sent message. - * - * @param mq message queue - * @param impl_state state specific to the implementation - */ -typedef void -(*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, - void *impl_state); - - -/** - * Generic error handler, called with the appropriate - * error code and the same closure specified at the creation of - * the message queue. - * Not every message queue implementation supports an error handler. - * - * @param cls closure - * @param error error code - */ -typedef void -(*GNUNET_MQ_ErrorHandler) (void *cls, - enum GNUNET_MQ_Error error); - - -/** - * Insert @a env into the envelope DLL starting at @a env_head - * Note that @a env must not be in any MQ while this function - * is used with DLLs defined outside of the MQ module. This - * is just in case some application needs to also manage a - * FIFO of envelopes independent of MQ itself and wants to - * re-use the pointers internal to @a env. Use with caution. - * - * @param[in,out] env_head of envelope DLL - * @param[in,out] env_tail tail of envelope DLL - * @param[in,out] env element to insert at the tail - */ -void -GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, - struct GNUNET_MQ_Envelope **env_tail, - struct GNUNET_MQ_Envelope *env); - - -/** - * Insert @a env into the envelope DLL starting at @a env_head - * Note that @a env must not be in any MQ while this function - * is used with DLLs defined outside of the MQ module. This - * is just in case some application needs to also manage a - * FIFO of envelopes independent of MQ itself and wants to - * re-use the pointers internal to @a env. Use with caution. - * - * @param[in,out] env_head of envelope DLL - * @param[in,out] env_tail tail of envelope DLL - * @param[in,out] env element to insert at the tail - */ -void -GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, - struct GNUNET_MQ_Envelope **env_tail, - struct GNUNET_MQ_Envelope *env); - - -/** - * Remove @a env from the envelope DLL starting at @a env_head. - * Note that @a env must not be in any MQ while this function - * is used with DLLs defined outside of the MQ module. This - * is just in case some application needs to also manage a - * FIFO of envelopes independent of MQ itself and wants to - * re-use the pointers internal to @a env. Use with caution. - * - * @param[in,out] env_head of envelope DLL - * @param[in,out] env_tail tail of envelope DLL - * @param[in,out] env element to remove from the DLL - */ -void -GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, - struct GNUNET_MQ_Envelope **env_tail, - struct GNUNET_MQ_Envelope *env); - - -/** - * Copy an array of handlers. - * - * Useful if the array has been declared in local memory and needs to be - * persisted for future use. - * - * @param handlers Array of handlers to be copied. - * @return A newly allocated array of handlers. - * Needs to be freed with #GNUNET_free. - */ -struct GNUNET_MQ_MessageHandler * -GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers); - - -/** - * Copy an array of handlers, appending AGPL handler. - * - * Useful if the array has been declared in local memory and needs to be - * persisted for future use. - * - * @param handlers Array of handlers to be copied. Can be NULL (nothing done). - * @param agpl_handler function to call for AGPL handling - * @param agpl_cls closure for @a agpl_handler - * @return A newly allocated array of handlers. - * Needs to be freed with #GNUNET_free. - */ -struct GNUNET_MQ_MessageHandler * -GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers, - GNUNET_MQ_MessageCallback agpl_handler, - void *agpl_cls); - - -/** - * Count the handlers in a handler array. - * - * @param handlers Array of handlers to be counted. - * @return The number of handlers in the array. - */ -unsigned int -GNUNET_MQ_count_handlers (const struct GNUNET_MQ_MessageHandler *handlers); - - -/** - * Message handler for a specific message type. - */ -struct GNUNET_MQ_MessageHandler -{ - /** - * Callback to validate a message of the specified @e type. - * The closure given to @e mv will be this struct (not @e ctx). - * Using NULL means only size-validation using - * @e expected_size. In this case, @e expected_size must - * be non-zero. - */ - GNUNET_MQ_MessageValidationCallback mv; - - /** - * Callback, called every time a new message of - * the specified @e type has been received. - * The closure given to @e mv will be this struct (not @e ctx). - */ - GNUNET_MQ_MessageCallback cb; - - /** - * Closure for @e mv and @e cb. - */ - void *cls; - - /** - * Type of the message this handler covers, in host byte order. - */ - uint16_t type; - - /** - * Expected size of messages of this type. Minimum size of the - * message if @e mv is non-NULL. Messages of the given type will be - * discarded (and the connection closed with an error reported to - * the application) if they do not have the right size. - */ - uint16_t expected_size; -}; - - -/** - * End-marker for the handlers array - */ -#define GNUNET_MQ_handler_end() \ - { \ - NULL, NULL, NULL, 0, 0 \ - } - - -/** - * Defines a static function @a name which takes as a single argument - * a message handler for fixed-sized messages of type @a code and with - * a message type argument of @a str. Given such an argument, the - * function @name will return a `struct GNUNET_MQ_MessageHandler` - * for the given message type. - * - * The macro is to be used as follows: - * <code> - * struct GNUNET_MessageTest { ... }; // must be fixed size - * static void - * handle_test_message (void *cls, - * const struct GNUNET_MessageTest *msg) - * { ... } - * - * struct GNUNET_MQ_MessageHandler handlers[] = { - * GNUNET_MQ_hd_fixed_size(test_message, - * GNUNET_MESSAGE_TYPE_TEST, - * struct GNUNET_MessageTest, - * "context"), - * GNUNET_MQ_handler_end() - * }; - * - * @param name unique basename for the functions - * @param code message type constant - * @param str type of the message (a struct) - * @param ctx context for the callbacks - */ -#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx) \ - ({ \ - void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ - ((struct GNUNET_MQ_MessageHandler){ NULL, \ - (GNUNET_MQ_MessageCallback) _cb, \ - (ctx), \ - (code), \ - sizeof(str) }); \ - }) - - -/** - * Defines a static function @a name which takes two arguments and a - * context-pointer for validating and handling variable-sized messages - * of type @a code and with a message type argument of @a str. Given - * such arguments, the function @name will return a `struct - * GNUNET_MQ_MessageHandler` for the given message type. - * - * The macro is to be used as follows: - * <code> - * struct GNUNET_MessageTest { ... }; // can be variable size - * static int - * check_test (void *cls, - * const struct GNUNET_MessageTest *msg) - * { - * const char *ctx = cls; - * GNUNET_assert (0 == strcmp ("context", ctx)); - * // ... - * } - * static void - * handle_test (void *cls, - * const struct GNUNET_MessageTest *msg) - * { - * const char *ctx = cls; - * GNUNET_assert (0 == strcmp ("context", ctx)); - * // ... - * } - * - * struct GNUNET_MQ_MessageHandler handlers[] = { - * GNUNET_MQ_hd_var_size(test_message, - * GNUNET_MESSAGE_TYPE_TEST, - * struct GNUNET_MessageTest, - * "context"), - * GNUNET_MQ_handler_end() - * }; - * </code> - * - * @param name unique basename for the functions - * @param code message type constant - * @param str type of the message (a struct) - * @param ctx context for the callbacks - */ -#define GNUNET_MQ_hd_var_size(name, code, str, ctx) \ - __extension__ ({ \ - int (*_mv)(void *cls, const str *msg) = &check_ ## name; \ - void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \ - ((struct GNUNET_MQ_MessageHandler){ (GNUNET_MQ_MessageValidationCallback) \ - _mv, \ - (GNUNET_MQ_MessageCallback) _cb, \ - (ctx), \ - (code), \ - sizeof(str) }); \ - }) - - -/** - * Insert code for a "check_" function that verifies that - * a given variable-length message received over the network - * is followed by a 0-terminated string. If the message @a m - * is not followed by a 0-terminated string, an error is logged - * and the function is returned with #GNUNET_NO. - * - * @param an IPC message with proper type to determine - * the size, starting with a `struct GNUNET_MessageHeader` - */ -#define GNUNET_MQ_check_zero_termination(m) \ - { \ - const char *str = (const char *) &m[1]; \ - const struct GNUNET_MessageHeader *hdr = \ - (const struct GNUNET_MessageHeader *) m; \ - uint16_t slen = ntohs (hdr->size) - sizeof(*m); \ - if ((0 == slen) || (memchr (str, 0, slen) != &str[slen - 1])) \ - { \ - GNUNET_break (0); \ - return GNUNET_NO; \ - } \ - } - - -/** - * Insert code for a "check_" function that verifies that - * a given variable-length message received over the network - * is followed by another variable-length message that fits - * exactly with the given size. If the message @a m - * is not followed by another `struct GNUNET_MessageHeader` - * with a size that adds up to the total size, an error is logged - * and the function is returned with #GNUNET_NO. - * - * @param an IPC message with proper type to determine - * the size, starting with a `struct GNUNET_MessageHeader` - */ -#define GNUNET_MQ_check_boxed_message(m) \ - { \ - const struct GNUNET_MessageHeader *inbox = \ - (const struct GNUNET_MessageHeader *) &m[1]; \ - const struct GNUNET_MessageHeader *hdr = \ - (const struct GNUNET_MessageHeader *) m; \ - uint16_t slen = ntohs (hdr->size) - sizeof(*m); \ - if ((slen < sizeof(struct GNUNET_MessageHeader)) || \ - (slen != ntohs (inbox->size))) \ - { \ - GNUNET_break (0); \ - return GNUNET_NO; \ - } \ - } - - -/** - * Call the message message handler that was registered - * for the type of the given message in the given @a handlers list. - * - * This function is indented to be used for the implementation - * of message queues. - * - * @param handlers a set of handlers - * @param mh message to dispatch - * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, - * #GNUNET_SYSERR if message was rejected by check function - */ -enum GNUNET_GenericReturnValue -GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, - const struct GNUNET_MessageHeader *mh); - - -/** - * Create a new envelope. - * - * @param mhp message header to store the allocated message header in, can be NULL - * @param size size of the message to allocate - * @param type type of the message, will be set in the allocated message - * @return the allocated MQ message - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, - uint16_t size, - uint16_t type); - - -/** - * Create a new envelope by copying an existing message. - * - * @param hdr header of the message to copy - * @return envelope containing @a hdr - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr); - - -/** - * Discard the message queue message, free all - * allocated resources. Must be called in the event - * that a message is created but should not actually be sent. - * - * @param mqm the message to discard - */ -void -GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm); - - -/** - * Function to obtain the current envelope - * from within #GNUNET_MQ_SendImpl implementations. - * - * @param mq message queue to interrogate - * @return the current envelope - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_get_current_envelope (struct GNUNET_MQ_Handle *mq); - - -/** - * Function to copy an envelope. The envelope must not yet - * be in any queue or have any options or callbacks set. - * - * @param env envelope to copy - * @return copy of @a env - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_env_copy (struct GNUNET_MQ_Envelope *env); - - -/** - * Function to obtain the last envelope in the queue. - * - * @param mq message queue to interrogate - * @return the last envelope in the queue - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_get_last_envelope (struct GNUNET_MQ_Handle *mq); - - -/** - * Set application-specific options for this envelope. - * Overrides the options set for the queue with - * #GNUNET_MQ_set_options() for this message only. - * - * @param env message to set options for - * @param pp priority and preferences to set for @a env - */ -void -GNUNET_MQ_env_set_options (struct GNUNET_MQ_Envelope *env, - enum GNUNET_MQ_PriorityPreferences pp); - - -/** - * Get performance preferences set for this envelope. - * - * @param env message to set options for - * @return priority and preferences to use - */ -enum GNUNET_MQ_PriorityPreferences -GNUNET_MQ_env_get_options (struct GNUNET_MQ_Envelope *env); - - -/** - * Combine performance preferences set for different - * envelopes that are being combined into one larger envelope. - * - * @param p1 one set of preferences - * @param p2 second set of preferences - * @return combined priority and preferences to use - */ -enum GNUNET_MQ_PriorityPreferences -GNUNET_MQ_env_combine_options (enum GNUNET_MQ_PriorityPreferences p1, - enum GNUNET_MQ_PriorityPreferences p2); - - -/** - * Remove the first envelope that has not yet been sent from the message - * queue and return it. - * - * @param mq queue to remove envelope from - * @return NULL if queue is empty (or has no envelope that is not under transmission) - */ -struct GNUNET_MQ_Envelope * -GNUNET_MQ_unsent_head (struct GNUNET_MQ_Handle *mq); - - -/** - * Set application-specific options for this queue. - * - * @param mq message queue to set options for - * @param pp priority and preferences to use by default - */ -void -GNUNET_MQ_set_options (struct GNUNET_MQ_Handle *mq, - enum GNUNET_MQ_PriorityPreferences pp); - - -/** - * Obtain the current length of the message queue. - * - * @param mq queue to inspect - * @return number of queued, non-transmitted messages - */ -unsigned int -GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq); - - -/** - * Send a message with the given message queue. - * May only be called once per message. - * - * @param mq message queue - * @param ev the envelope with the message to send. - */ -void -GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, - struct GNUNET_MQ_Envelope *ev); - - -/** - * Send a copy of a message with the given message queue. - * Can be called repeatedly on the same envelope. - * - * @param mq message queue - * @param ev the envelope with the message to send. - */ -void -GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq, - const struct GNUNET_MQ_Envelope *ev); - - -/** - * Cancel sending the message. Message must have been sent with - * #GNUNET_MQ_send before. May not be called after the notify sent - * callback has been called - * - * @param ev queued envelope to cancel - */ -void -GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev); - - -/** - * Associate the assoc_data in @a mq with a unique request id. - * - * @param mq message queue, id will be unique for the queue - * @param assoc_data to associate - */ -uint32_t -GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, - void *assoc_data); - - -/** - * Get the data associated with a @a request_id in a queue - * - * @param mq the message queue with the association - * @param request_id the request id we are interested in - * @return the associated data - */ -void * -GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, - uint32_t request_id); - - -/** - * Remove the association for a @a request_id - * - * @param mq the message queue with the association - * @param request_id the request id we want to remove - * @return the associated data - */ -void * -GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, - uint32_t request_id); - - -/** - * Create a message queue for the specified handlers. - * - * @param send function the implements sending messages - * @param destroy function that implements destroying the queue - * @param cancel function that implements canceling a message - * @param impl_state for the queue, passed to @a send, @a destroy and @a cancel - * @param handlers array of message handlers - * @param error_handler handler for read and write errors - * @param cls closure for message handlers and error handler - * @return a new message queue - */ -struct GNUNET_MQ_Handle * -GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, - GNUNET_MQ_DestroyImpl destroy, - GNUNET_MQ_CancelImpl cancel, - void *impl_state, - const struct GNUNET_MQ_MessageHandler *handlers, - GNUNET_MQ_ErrorHandler error_handler, - void *cls); - - -/** - * Change the closure argument in all of the `handlers` of the - * @a mq. - * - * @param mq to modify - * @param handlers_cls new closure to use - */ -void -GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, - void *handlers_cls); - - -/** - * Call a callback once the envelope has been sent, that is, - * sending it can not be canceled anymore. - * There can be only one notify sent callback per envelope. - * - * @param ev message to call the notify callback for - * @param cb the notify callback - * @param cb_cls closure for the callback - */ -void -GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev, - GNUNET_SCHEDULER_TaskCallback cb, - void *cb_cls); - - -/** - * Destroy the message queue. - * - * @param mq message queue to destroy - */ -void -GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq); - - -/** - * Handle we return for callbacks registered to be - * notified when #GNUNET_MQ_destroy() is called on a queue. - */ -struct GNUNET_MQ_DestroyNotificationHandle; - - -/** - * Register function to be called whenever @a mq is being - * destroyed. - * - * @param mq message queue to watch - * @param cb function to call on @a mq destruction - * @param cb_cls closure for @a cb - * @return handle for #GNUNET_MQ_destroy_notify_cancel(). - */ -struct GNUNET_MQ_DestroyNotificationHandle * -GNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq, - GNUNET_SCHEDULER_TaskCallback cb, - void *cb_cls); - -/** - * Cancel registration from #GNUNET_MQ_destroy_notify(). - * - * @param dnh handle for registration to cancel - */ -void -GNUNET_MQ_destroy_notify_cancel ( - struct GNUNET_MQ_DestroyNotificationHandle *dnh); - - -/** - * Call the message message handler that was registered - * for the type of the given message in the given message queue. - * - * This function is intended to be used for the implementation - * of message queues. - * - * @param mq message queue with the handlers - * @param mh message to dispatch - */ -void -GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, - const struct GNUNET_MessageHeader *mh); - - -/** - * Call the error handler of a message queue with the given - * error code. If there is no error handler, log a warning. - * - * This function is intended to be used for the implementation - * of message queues. - * - * @param mq message queue - * @param error the error type - */ -void -GNUNET_MQ_inject_error (struct GNUNET_MQ_Handle *mq, - enum GNUNET_MQ_Error error); - - -/** - * Call the send implementation for the next queued message, if any. - * Calls the send notification for the current message unless - * #GNUNET_MQ_impl_send_in_flight was called for this envelope. - * - * Only useful for implementing message queues, results in undefined - * behavior if not used carefully. - * - * @param mq message queue to send the next message with - */ -void -GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq); - - -/** - * Call the send notification for the current message, but do not - * try to send the next message until #gnunet_mq_impl_send_continue - * is called. - * - * Only useful for implementing message queues, results in undefined - * behavior if not used carefully. - * - * @param mq message queue to send the next message with - */ -void -GNUNET_MQ_impl_send_in_flight (struct GNUNET_MQ_Handle *mq); - - -/** - * Get the implementation state associated with the - * message queue. - * - * While the GNUNET_MQ_Impl* callbacks receive the - * implementation state, continuations that are scheduled - * by the implementation function often only have one closure - * argument, with this function it is possible to get at the - * implementation state when only passing the `struct GNUNET_MQ_Handle` - * as closure. - * - * @param mq message queue with the current message - * @return message to send, never NULL - */ -void * -GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq); - - -/** - * Get the message that should currently be sent. - * Fails if there is no current message. - * Only useful for implementing message queues, - * results in undefined behavior if not used carefully. - * - * @param mq message queue with the current message - * @return message to send, never NULL - */ -const struct GNUNET_MessageHeader * -GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq); - - -/** - * Enum defining all known preference categories. - * - * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` - */ -enum GNUNET_MQ_PreferenceKind -{ - /** - * No preference was expressed. - */ - GNUNET_MQ_PREFERENCE_NONE = 0, - - /** - * The preferred transmission for this envelope focuses on - * maximizing bandwidth. - */ - GNUNET_MQ_PREFERENCE_BANDWIDTH = 1, - - /** - * The preferred transmission for this envelope foces on - * minimizing latency. - */ - GNUNET_MQ_PREFERENCE_LATENCY = 2, - - /** - * The preferred transmission for this envelope foces on - * reliability. - */ - GNUNET_MQ_PREFERENCE_RELIABILITY = 3 - -/** - * Number of preference values allowed. - */ -#define GNUNET_MQ_PREFERENCE_COUNT 4 -}; - - -/** - * Convert an `enum GNUNET_MQ_PreferenceType` to a string - * - * @param type the preference type - * @return a string or NULL if invalid - * - * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference` - */ -const char * -GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); - - -#endif - -/** @} */ /* end of group mq */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mst_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_mst_lib.h @@ -1,177 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009-2013, 2016 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @addtogroup networking - * @{ - * - * @author Christian Grothoff - * - * @file - * Library for tokenizing a message stream - - * @defgroup server Server library - * Library for tokenizing a message stream - * - * @see [Documentation](https://gnunet.org/mst) - * - * @{ - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_MST_LIB_H -#define GNUNET_MST_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Handle to a message stream tokenizer. - */ -struct GNUNET_MessageStreamTokenizer; - - -/** - * Functions with this signature are called whenever a - * complete message is received by the tokenizer. - * - * Do not call #GNUNET_mst_destroy from within - * the scope of this callback. - * - * @param cls closure - * @param message the actual message - * @return #GNUNET_OK on success, - * #GNUNET_NO to stop further processing due to disconnect (no error) - * #GNUNET_SYSERR to stop further processing due to error - */ -typedef int -(*GNUNET_MessageTokenizerCallback) (void *cls, - const struct GNUNET_MessageHeader *message); - - -/** - * Create a message stream tokenizer. - * - * @param cb function to call on completed messages - * @param cb_cls closure for @a cb - * @return handle to tokenizer - */ -struct GNUNET_MessageStreamTokenizer * -GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, - void *cb_cls); - - -/** - * Add incoming data to the receive buffer and call the - * callback for all complete messages. - * - * @param mst tokenizer to use - * @param buf input data to add - * @param size number of bytes in @a buf - * @param purge should any excess bytes in the buffer be discarded - * (i.e. for packet-based services like UDP) - * @param one_shot only call callback once, keep rest of message in buffer - * @return #GNUNET_OK if we are done processing (need more data) - * #GNUNET_NO if one_shot was set and we have another message ready - * #GNUNET_SYSERR if the data stream is corrupt - */ -enum GNUNET_GenericReturnValue -GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, - const char *buf, - size_t size, - int purge, - int one_shot); - - -/** - * Add incoming data to the receive buffer and call the - * callback for all complete messages. - * - * @param mst tokenizer to use - * @param buf input data to add - * @param size number of bytes in @a buf - * @param purge should any excess bytes in the buffer be discarded - * (i.e. for packet-based services like UDP) - * @param one_shot only call callback once, keep rest of message in buffer - * @return #GNUNET_OK if we are done processing (need more data) - * #GNUNET_NO if one_shot was set and we have another message ready - * #GNUNET_SYSERR if the data stream is corrupt - */ -enum GNUNET_GenericReturnValue -GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, - struct GNUNET_NETWORK_Handle *sock, - int purge, - int one_shot); - - -/** - * Obtain the next message from the @a mst, assuming that - * there are more unprocessed messages in the internal buffer - * of the @a mst. - * - * @param mst tokenizer to use - * @param one_shot only call callback once, keep rest of message in buffer - * @return #GNUNET_OK if we are done processing (need more data) - * #GNUNET_NO if one_shot was set and we have another message ready - * #GNUNET_SYSERR if the data stream is corrupt - */ -enum GNUNET_GenericReturnValue -GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, - int one_shot); - - -/** - * Destroys a tokenizer. - * - * @param mst tokenizer to destroy - */ -void -GNUNET_MST_destroy (struct GNUNET_MessageStreamTokenizer *mst); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */ /* end of group server */ - -/** @} */ /* end of group addition to networking */ - -/** @} */ /* end of group addition to libgnunetutil*/ - -/* end of gnunet_mst_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nc_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nc_lib.h @@ -1,115 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2012-2016 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * General-purpose broadcast mechanism for message queues - * - * @defgroup mq NC library - * General-purpose broadcast mechanism for message queues - * - * @see [Documentation](https://gnunet.org/nc) - * - * @{ - */ -#ifndef GNUNET_NC_H -#define GNUNET_NC_H - - -/** - * The notification context is the key datastructure for a convenience - * API used for transmission of notifications to the subscriber until the - * subscriber disconnects (or the notification context is destroyed, in - * which case we disconnect these subscribers). Essentially, all - * (notification) messages are queued up until the subscriber is able to - * read them. - */ -struct GNUNET_NotificationContext; - - -/** - * Create a new notification context. - * - * @param queue_length maximum number of messages to keep in - * the notification queue; optional messages are dropped - * if the queue gets longer than this number of messages - * @return handle to the notification context - */ -struct GNUNET_NotificationContext * -GNUNET_notification_context_create (unsigned int queue_length); - - -/** - * Destroy the context, force disconnect for all subscribers. - * - * @param nc context to destroy. - */ -void -GNUNET_notification_context_destroy (struct GNUNET_NotificationContext *nc); - - -/** - * Add a subscriber to the notification context. - * - * @param nc context to modify - * @param mq message queue add - */ -void -GNUNET_notification_context_add (struct GNUNET_NotificationContext *nc, - struct GNUNET_MQ_Handle *mq); - - -/** - * Send a message to all subscribers of this context. - * - * @param nc context to modify - * @param msg message to send - * @param can_drop can this message be dropped due to queue length limitations - */ -void -GNUNET_notification_context_broadcast (struct GNUNET_NotificationContext *nc, - const struct GNUNET_MessageHeader *msg, - int can_drop); - -/** - * Return active number of subscribers in this context. - * - * @param nc context to query - * @return number of current subscribers - */ -unsigned int -GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc); - -#endif - -/** @} */ /* end of group mq */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_network_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_network_lib.h @@ -1,603 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009-2013, 2022 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @addtogroup networking - * @{ - * - * @author Nils Durner - * @author Tobias Frisch - * - * @file - * Basic low-level networking interface - * - * @defgroup network Network library - * Basic low-level networking interface - * @{ - */ -#ifndef GNUNET_NETWORK_LIB_H -#define GNUNET_NETWORK_LIB_H - -#include "gnunet_common.h" -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -//#ifdef HAVE_SYS_SELECT_H -/* - * Include "sys/select.h" because it is required to use - * "fd_set" in "struct GNUNET_NETWORK_FDSet"! - */ - -#include <sys/select.h> -//#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_SYS_UN_H -#include <sys/un.h> -#endif - -/** - * @brief handle to a socket - */ -struct GNUNET_NETWORK_Handle; - - -/** - * @brief collection of IO descriptors - */ -struct GNUNET_NETWORK_FDSet -{ - /** - * Maximum number of any socket descriptor in the set (plus one) - */ - int nsds; - - /** - * Bitset with the descriptors. - */ - fd_set sds; - -}; - -#include "gnunet_disk_lib.h" -#include "gnunet_time_lib.h" - -/** - * Test if the given protocol family is supported by this system. - * - * @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX) - * @return #GNUNET_OK if the PF is supported - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_test_pf (int pf); - - -/** - * Given a unixpath that is too long (larger than UNIX_PATH_MAX), - * shorten it to an acceptable length while keeping it unique - * and making sure it remains a valid filename (if possible). - * - * @param unixpath long path, will be freed (or same pointer returned - * with moved 0-termination). - * @return shortened unixpath, NULL on error - */ -char * -GNUNET_NETWORK_shorten_unixpath (char *unixpath); - - -/** - * If services crash, they can leave a unix domain socket file on the - * disk. This needs to be manually removed, because otherwise both - * bind() and connect() for the respective address will fail. In this - * function, we test if such a left-over file exists, and if so, - * remove it (unless there is a listening service at the address). - * - * @param un unix domain socket address to check - */ -void -GNUNET_NETWORK_unix_precheck (const struct sockaddr_un *un); - - -/** - * Accept a new connection on a socket. Configure it for non-blocking - * IO and mark it as non-inheritable to child processes (set the - * close-on-exec flag). - * - * @param desc bound socket - * @param address address of the connecting peer, may be NULL - * @param address_len length of address - * @return client socket - */ -struct GNUNET_NETWORK_Handle * -GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, - struct sockaddr *address, - socklen_t *address_len); - - -/** - * Box a native socket (and check that it is a socket). - * - * @param fd socket to box - * @return NULL on error (including not supported on target platform) - */ -struct GNUNET_NETWORK_Handle * -GNUNET_NETWORK_socket_box_native (int fd); - - -/** - * Set if a socket should use blocking or non-blocking IO. - * - * @param fd socket - * @param doBlock blocking mode - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, - int doBlock); - - -/** - * Bind a socket to a particular address. - * - * @param desc socket to bind - * @param address address to be bound - * @param address_len length of @a address - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, - const struct sockaddr *address, - socklen_t address_len); - -/** - * Close a socket. - * - * @param desc socket to close - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc); - - -/** - * Only free memory of a socket, keep the file descriptor untouched. - * - * @param desc socket - */ -void -GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc); - - -/** - * Connect a socket to some remote address. - * - * @param desc socket to connect - * @param address peer address - * @param address_len of @a address - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, - const struct sockaddr *address, - socklen_t address_len); - - -/** - * Get socket options - * - * @param desc socket to inspect - * @param level protocol level of the option - * @param optname identifier of the option - * @param optval options - * @param optlen length of optval - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, - int level, - int optname, - void *optval, - socklen_t *optlen); - - -/** - * Listen on a socket - * - * @param desc socket to start listening on - * @param backlog length of the listen queue - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, - int backlog); - - -/** - * How much data is available to be read on this descriptor? - * - * @param desc socket - * @returns #GNUNET_SYSERR if no data is available, or on error! - */ -ssize_t -GNUNET_NETWORK_socket_recvfrom_amount (const struct - GNUNET_NETWORK_Handle *desc); - - -/** - * Read data from a socket (always non-blocking). - * - * @param desc socket - * @param buffer buffer - * @param length length of buffer - * @param src_addr either the source to recv from, or all zeroes - * to be filled in by recvfrom - * @param addrlen length of the addr - */ -ssize_t -GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc, - void *buffer, - size_t length, - struct sockaddr *src_addr, - socklen_t *addrlen); - - -/** - * Read data from a connected socket (always non-blocking). - * - * @param desc socket - * @param buffer buffer - * @param length length of buffer - * @return number of bytes read - */ -ssize_t -GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, - void *buffer, - size_t length); - - -/** - * Check if sockets meet certain conditions. - * - * @param rfds set of sockets to be checked for readability - * @param wfds set of sockets to be checked for writability - * @param efds set of sockets to be checked for exceptions - * @param timeout relative value when to return - * @return number of selected sockets, #GNUNET_SYSERR on error - */ -int -GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, - struct GNUNET_NETWORK_FDSet *wfds, - struct GNUNET_NETWORK_FDSet *efds, - struct GNUNET_TIME_Relative timeout); - - -/** - * Send data (always non-blocking). - * - * @param desc socket - * @param buffer data to send - * @param length size of the buffer - * @return number of bytes sent, #GNUNET_SYSERR on error - */ -ssize_t -GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc, - const void *buffer, - size_t length); - - -/** - * Send data to a particular destination (always non-blocking). - * This function only works for UDP sockets. - * - * @param desc socket - * @param message data to send - * @param length size of the data in @a message - * @param dest_addr destination address - * @param dest_len length of @a dest_addr - * @return number of bytes sent, #GNUNET_SYSERR on error - */ -ssize_t -GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, - const void *message, - size_t length, - const struct sockaddr *dest_addr, - socklen_t dest_len); - - -/** - * Set socket option - * - * @param fd socket - * @param level protocol level of the option - * @param option_name option identifier - * @param option_value value to set - * @param option_len size of @a option_value - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -int -GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, - int level, - int option_name, - const void *option_value, - socklen_t option_len); - - -/** - * Shut down socket operations - * - * @param desc socket - * @param how type of shutdown - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, - int how); - - -/** - * Disable the "CORK" feature for communication with the given socket, - * forcing the OS to immediately flush the buffer on transmission - * instead of potentially buffering multiple messages. Essentially - * reduces the OS send buffers to zero. - * - * @param desc socket - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc); - - -/** - * Create a new socket. Configure it for non-blocking IO and - * mark it as non-inheritable to child processes (set the - * close-on-exec flag). - * - * @param domain domain of the socket - * @param type socket type - * @param protocol network protocol - * @return new socket, NULL on error - */ -struct GNUNET_NETWORK_Handle * -GNUNET_NETWORK_socket_create (int domain, - int type, - int protocol); - - -/** - * Reset FD set (clears all file descriptors). - * - * @param fds fd set to clear - */ -void -GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds); - - -/** - * Add a socket to the FD set - * - * @param fds fd set - * @param desc socket to add - */ -void -GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds, - const struct GNUNET_NETWORK_Handle *desc); - - -/** - * Check whether a socket is part of the fd set - * - * @param fds fd set - * @param desc socket - * @return #GNUNET_YES if the socket is in the set - */ -int -GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds, - const struct GNUNET_NETWORK_Handle *desc); - - -/** - * Add one fd set to another (computes the union). - * - * @param dst the fd set to add to - * @param src the fd set to add from - */ -void -GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, - const struct GNUNET_NETWORK_FDSet *src); - - -/** - * Copy one fd set to another - * - * @param to destination - * @param from source - */ -void -GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, - const struct GNUNET_NETWORK_FDSet *from); - - -/** - * Return file descriptor for this network handle - * - * @param desc wrapper to process - * @return POSIX file descriptor - */ -int -GNUNET_NETWORK_get_fd (const struct GNUNET_NETWORK_Handle *desc); - - -/** - * Return the sockaddr for this network handle - * - * @param desc wrapper to process - * @return POSIX file descriptor - */ -struct sockaddr* -GNUNET_NETWORK_get_addr (const struct GNUNET_NETWORK_Handle *desc); - - -/** - * Return sockaddr length for this network handle - * - * @param desc wrapper to process - * @return socklen_t for sockaddr - */ -socklen_t -GNUNET_NETWORK_get_addrlen (const struct GNUNET_NETWORK_Handle *desc); - - -/** - * Copy a native fd set into the GNUnet representation. - * - * @param to destination - * @param from native source set - * @param nfds the biggest socket number in from + 1 - */ -void -GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, - const fd_set *from, - int nfds); - - -/** - * Set a native fd in a set - * - * @param to destination - * @param nfd native FD to set - */ -void -GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, - int nfd); - - -/** - * Test native fd in a set - * - * @param to set to test, NULL for empty set - * @param nfd native FD to test, -1 for none - * @return #GNUNET_YES if to contains nfd - */ -int -GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to, - int nfd); - - -/** - * Add a file handle to the fd set - * - * @param fds fd set - * @param h the file handle to add - */ -void -GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, - const struct GNUNET_DISK_FileHandle *h); - - -/** - * Add a file handle to the fd set - * On W32: ensure that the handle is first in the array. - * - * @param fds fd set - * @param h the file handle to add - */ -void -GNUNET_NETWORK_fdset_handle_set_first (struct GNUNET_NETWORK_FDSet *fds, - const struct GNUNET_DISK_FileHandle *h); - - -/** - * Check if a file handle is part of an fd set - * - * @param fds fd set - * @param h file handle - * @return #GNUNET_YES if the file handle is part of the set - */ -int -GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, - const struct GNUNET_DISK_FileHandle *h); - - -/** - * Checks if two fd sets overlap - * - * @param fds1 first fd set - * @param fds2 second fd set - * @return #GNUNET_YES if they do overlap, #GNUNET_NO otherwise - */ -int -GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, - const struct GNUNET_NETWORK_FDSet *fds2); - - -/** - * Creates an fd set - * - * @return a new fd set - */ -struct GNUNET_NETWORK_FDSet * -GNUNET_NETWORK_fdset_create (void); - - -/** - * Releases the associated memory of an fd set - * - * @param fds fd set - */ -void -GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds); - - -/** - * Test if the given @a port is available. - * - * @param ipproto transport protocol to test (e.g. IPPROTO_TCP) - * @param port port number to test - * @return #GNUNET_OK if the port is available, #GNUNET_NO if not - */ -int -GNUNET_NETWORK_test_port_free (int ipproto, - uint16_t port); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif /* GNUNET_NETWORK_LIB_H */ - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nt_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_nt_lib.h @@ -1,134 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2010-2015, 2018 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup Backbone - * @{ - * - * @file network type characterization - * @author Christian Grothoff - * @author Matthias Wachs - * - * @defgroup nt Network type characterization - * - * @{ - */ -#ifndef GNUNET_NT_LIB_H -#define GNUNET_NT_LIB_H - -/** - * Types of networks (with separate quotas) we support. - */ -enum GNUNET_NetworkType -{ - /** - * Category of last resort. - */ - GNUNET_NT_UNSPECIFIED = 0, - - /** - * Loopback (same host). - */ - GNUNET_NT_LOOPBACK = 1, - - /** - * Local area network. - */ - GNUNET_NT_LAN = 2, - - /** - * Wide area network (i.e. Internet) - */ - GNUNET_NT_WAN = 3, - - /** - * Wireless LAN (i.e. 802.11abgn) - */ - GNUNET_NT_WLAN = 4, - - /** - * Bluetooth LAN - */ - GNUNET_NT_BT = 5 - -/** - * Number of network types supported by ATS - */ -#define GNUNET_NT_COUNT 6 -}; - - -/** - * Convert a `enum GNUNET_NetworkType` to a string - * - * @param net the network type - * @return a string or NULL if invalid - */ -const char * -GNUNET_NT_to_string (enum GNUNET_NetworkType net); - - -/** - * Handle for the LAN Characterization library. - */ -struct GNUNET_NT_InterfaceScanner; - - -/** - * Returns where the address is located: loopback, LAN or WAN. - * - * @param is handle from #GNUNET_ATS_interface_scanner_init() - * @param addr address - * @param addrlen address length - * @return type of the network the address belongs to - */ -enum GNUNET_NetworkType -GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is, - const struct sockaddr *addr, - socklen_t addrlen); - - -/** - * Initialize the address characterization client handle. - * - * @return scanner handle, NULL on error - */ -struct GNUNET_NT_InterfaceScanner * -GNUNET_NT_scanner_init (void); - - -/** - * Terminate interface scanner. - * - * @param is scanner we are done with - */ -void -GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is); - - -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition to backbone */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_os_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_os_lib.h @@ -1,713 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2011, 2020 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * @author Krista Bennett - * @author Gerd Knorr <kraxel@bytesex.org> - * @author Ioana Patrascu - * @author Tzvetan Horozov - * @author Milan - * - * @file - * Low level process routines - * - * @defgroup os OS library - * Low level process routines. - * - * This code manages child processes. We can communicate with child - * processes using signals. Because signals are not supported on W32 - * and Java (at least not nicely), we can alternatively use a pipe - * to send signals to the child processes (if the child process is - * a full-blown GNUnet process that supports reading signals from - * a pipe, of course). Naturally, this also only works for 'normal' - * termination via signals, and not as a replacement for SIGKILL. - * Thus using pipes to communicate signals should only be enabled if - * the child is a Java process OR if we are on Windoze. - * - * @{ - */ - -#ifndef GNUNET_OS_LIB_H -#define GNUNET_OS_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Flags that determine which of the standard streams - * should be inherited by the child process. - */ -enum GNUNET_OS_InheritStdioFlags -{ - /** - * No standard streams should be inherited. - */ - GNUNET_OS_INHERIT_STD_NONE = 0, - - /** - * When this flag is set, the child process will - * inherit stdin of the parent. - */ - GNUNET_OS_INHERIT_STD_IN = 1, - - /** - * When this flag is set, the child process will - * inherit stdout of the parent. - */ - GNUNET_OS_INHERIT_STD_OUT = 2, - - /** - * When this flag is set, the child process will - * inherit stderr of the parent. - */ - GNUNET_OS_INHERIT_STD_ERR = 4, - - /** - * When these flags are set, the child process will - * inherit stdout and stderr of the parent. - */ - GNUNET_OS_INHERIT_STD_OUT_AND_ERR = 6, - - /** - * Use this option to have all of the standard streams - * (stdin, stdout and stderror) be inherited. - */ - GNUNET_OS_INHERIT_STD_ALL = 7, - - /** - * Should a pipe be used to send signals to the child? - */ - GNUNET_OS_USE_PIPE_CONTROL = 8 -}; - - -/** - * Process information (OS-dependent) - */ -struct GNUNET_OS_Process; - - -/** - * Possible installation paths to request - */ -enum GNUNET_OS_InstallationPathKind -{ - /** - * Return the "PREFIX" directory given to configure. - */ - GNUNET_OS_IPK_PREFIX, - - /** - * Return the directory where the program binaries are installed. (bin/) - */ - GNUNET_OS_IPK_BINDIR, - - /** - * Return the directory where libraries are installed. (lib/gnunet/) - */ - GNUNET_OS_IPK_LIBDIR, - - /** - * Return the directory where data is installed (share/gnunet/) - */ - GNUNET_OS_IPK_DATADIR, - - /** - * Return the directory where translations are installed (share/locale/) - */ - GNUNET_OS_IPK_LOCALEDIR, - - /** - * Return the installation directory of this application, not - * the one of the overall GNUnet installation (in case they - * are different). - */ - GNUNET_OS_IPK_SELF_PREFIX, - - /** - * Return the prefix of the path with application icons (share/icons/). - */ - GNUNET_OS_IPK_ICONDIR, - - /** - * Return the prefix of the path with documentation files, including the - * license (share/doc/gnunet/). - */ - GNUNET_OS_IPK_DOCDIR, - - /** - * Return the directory where helper binaries are installed (lib/gnunet/libexec/) - */ - GNUNET_OS_IPK_LIBEXECDIR -}; - - -/** - * Process status types - */ -enum GNUNET_OS_ProcessStatusType -{ - /** - * The process is not known to the OS (or at - * least not one of our children). - */ - GNUNET_OS_PROCESS_UNKNOWN, - - /** - * The process is still running. - */ - GNUNET_OS_PROCESS_RUNNING, - - /** - * The process is paused (but could be resumed). - */ - GNUNET_OS_PROCESS_STOPPED, - - /** - * The process exited with a return code. - */ - GNUNET_OS_PROCESS_EXITED, - - /** - * The process was killed by a signal. - */ - GNUNET_OS_PROCESS_SIGNALED -}; - - -/** - * Project-specific data used to help the OS subsystem - * find installation paths. - */ -struct GNUNET_OS_ProjectData -{ - /** - * Name of a library that is installed in the "lib/" directory of - * the project, such as "libgnunetutil". Used to locate the - * installation by scanning dependencies of the current process. - */ - const char *libname; - - /** - * Name of the project that is used in the "libexec" prefix, For - * example, "gnunet". Certain helper binaries are then expected to - * be installed in "$PREFIX/libexec/gnunet/" and resources in - * "$PREFIX/share/gnunet/". - */ - const char *project_dirname; - - /** - * Name of a project-specific binary that should be in "$PREFIX/bin/". - * Used to determine installation path from $PATH variable. - * For example "gnunet-arm". On W32, ".exe" should be omitted. - */ - const char *binary_name; - - /** - * Name of an environment variable that can be used to override - * installation path detection, for example "GNUNET_PREFIX". - */ - const char *env_varname; - - /** - * Alternative name of an environment variable that can be used to - * override installation path detection, if "env_varname" is not - * set. Again, for example, "GNUNET_PREFIX". - */ - const char *env_varname_alt; - - /** - * Name of an environment variable that can be used to override - * the location from which default configuration files are loaded - * from, for example "GNUNET_BASE_CONFIG". - */ - const char *base_config_varname; - - /** - * E-mail address for reporting bugs. - */ - const char *bug_email; - - /** - * Project homepage. - */ - const char *homepage; - - /** - * Configuration file name (in $XDG_CONFIG_HOME) to use. - */ - const char *config_file; - - /** - * Configuration file name to use (if $XDG_CONFIG_HOME is not set). - */ - const char *user_config_file; - - /** - * String identifying the current project version. - */ - const char *version; - - /** - * Non-zero means this project is part of GNU. - */ - int is_gnu; - - /** - * Gettext domain for localisation, e.g. the PACKAGE macro. - * Setting this field to NULL disables gettext. - */ - char *gettext_domain; - - /** - * Gettext directory, e.g. the LOCALEDIR macro. - * If this field is NULL, the path is automatically inferred. - */ - char *gettext_path; - - /** - * URL pointing to the source code of the application. Required for AGPL. - * Setting this to NULL disables the built-in mechanism, but you must - * provide it in some other way. If non-NULL, message type 1 and 2 are - * reserved. - */ - char *agpl_url; -}; - - -/** - * Return default project data used by 'libgnunetutil' for GNUnet. - */ -const struct GNUNET_OS_ProjectData * -GNUNET_OS_project_data_default (void); - - -/** - * @return current (actual) project data. - */ -const struct GNUNET_OS_ProjectData * -GNUNET_OS_project_data_get (void); - - -/** - * Setup OS subsystem with project data. - * - * @param pd project data used to determine paths. - */ -void -GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd); - - -/** - * Get the path to a specific GNUnet installation directory or, with - * #GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation - * directory. - * - * @param dirkind what kind of directory is desired? - * @return a pointer to the dir path (to be freed by the caller) - */ -char * -GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); - - -/** - * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon - * binary, try to prefix it with the libexec/-directory to get the - * full path. - * - * @param progname name of the binary - * @return full path to the binary, if possible, otherwise copy of 'progname' - */ -char * -GNUNET_OS_get_libexec_binary_path (const char *progname); - - -/** - * Given the name of a helper, service or daemon binary construct the full - * path to the binary using the SUID_BINARY_PATH in the PATHS section of the - * configuration. If that option is not present, fall back to - * GNUNET_OS_get_libexec_binary_path. If @a progname is an absolute path, a - * copy of this path is returned. - * - * @param cfg configuration to inspect - * @param progname name of the binary - * @return full path to the binary, if possible, a copy of @a progname - * otherwise - */ -char * -GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *progname); - - -/** - * Callback function invoked for each interface found. - * - * @param cls closure - * @param name name of the interface (can be NULL for unknown) - * @param isDefault is this presumably the default interface - * @param addr address of this interface (can be NULL for unknown or unassigned) - * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) - * @param netmask the network mask (can be NULL for unknown or unassigned) - * @param addrlen length of the address - * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_OS_NetworkInterfaceProcessor)(void *cls, - const char *name, - int isDefault, - const struct sockaddr *addr, - const struct sockaddr *broadcast_addr, - const struct sockaddr *netmask, - socklen_t addrlen); - - -/** - * @brief Enumerate all network interfaces - * - * @param proc the callback function - * @param proc_cls closure for @a proc - */ -void -GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, - void *proc_cls); - -#ifndef HAVE_SYSCONF -#define HAVE_SYSCONF 0 -#endif - -/** - * @brief Get maximum string length returned by gethostname() - */ -#if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX) -#define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf ( \ - _SC_HOST_NAME_MAX); __sc_tmp <= \ - 0 ? 255 : __sc_tmp; }) -#elif defined(HOST_NAME_MAX) -#define GNUNET_OS_get_hostname_max_length() HOST_NAME_MAX -#else -#define GNUNET_OS_get_hostname_max_length() 255 -#endif - - -/** - * Get process structure for current process - * - * The pointer it returns points to static memory location and must not be - * deallocated/closed - * - * @return pointer to the process sturcutre for this process - */ -struct GNUNET_OS_Process * -GNUNET_OS_process_current (void); - - -/** - * Sends a signal to the process - * - * @param proc pointer to process structure - * @param sig signal - * @return 0 on success, -1 on error - */ -int -GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, - int sig); - - -/** - * Cleans up process structure contents (OS-dependent) and deallocates it - * - * @param proc pointer to process structure - */ -void -GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc); - - -/** - * Get the pid of the process in question - * - * @param proc the process to get the pid of - * - * @return the current process id - */ -pid_t -GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc); - - -/** - * Start a process. - * - * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags - * @param pipe_stdin pipe to use to send input to child process (or NULL) - * @param pipe_stdout pipe to use to get output from child process (or NULL) - * @param pipe_stderr pipe to use to get error output from child process (or NULL) - * @param filename name of the binary - * @param argv NULL-terminated array of arguments to the process - * @return pointer to process structure of the new process, NULL on error - */ -struct GNUNET_OS_Process * -GNUNET_OS_start_process_vap ( - enum GNUNET_OS_InheritStdioFlags std_inheritance, - struct GNUNET_DISK_PipeHandle *pipe_stdin, - struct GNUNET_DISK_PipeHandle *pipe_stdout, - struct GNUNET_DISK_PipeHandle *pipe_stderr, - const char *filename, - char *const argv[]); - - -/** - * Start a process. - * - * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags - * @param pipe_stdin pipe to use to send input to child process (or NULL) - * @param pipe_stdout pipe to use to get output from child process (or NULL) - * @param pipe_stderr pipe to use to get error output from child process (or NULL) - * @param filename name of the binary - * @param ... NULL-terminated list of arguments to the process - * @return pointer to process structure of the new process, NULL on error - */ -struct GNUNET_OS_Process * -GNUNET_OS_start_process ( - enum GNUNET_OS_InheritStdioFlags std_inheritance, - struct GNUNET_DISK_PipeHandle *pipe_stdin, - struct GNUNET_DISK_PipeHandle *pipe_stdout, - struct GNUNET_DISK_PipeHandle *pipe_stderr, - const char *filename, - ...); - - -/** - * Start a process. - * - * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags - * @param pipe_stdin pipe to use to send input to child process (or NULL) - * @param pipe_stdout pipe to use to get output from child process (or NULL) - * @param pipe_stderr pipe to use to get error output from child process (or NULL) - * @param filename name of the binary - * @param va NULL-terminated list of arguments to the process - * @return pointer to process structure of the new process, NULL on error - */ -struct GNUNET_OS_Process * -GNUNET_OS_start_process_va ( - enum GNUNET_OS_InheritStdioFlags std_inheritance, - struct GNUNET_DISK_PipeHandle *pipe_stdin, - struct GNUNET_DISK_PipeHandle *pipe_stdout, - struct GNUNET_DISK_PipeHandle *pipe_stderr, - const char *filename, - va_list va); - - -/** - * Start a process. - * - * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags - * @param lsocks array of listen sockets to dup systemd-style (or NULL); - * must be NULL on platforms where dup is not supported - * @param filename name of the binary - * @param argv NULL-terminated list of arguments to the process, - * including the process name as the first argument - * @return pointer to process structure of the new process, NULL on error - */ -struct GNUNET_OS_Process * -GNUNET_OS_start_process_v ( - enum GNUNET_OS_InheritStdioFlags std_inheritance, - const int *lsocks, - const char *filename, - char *const argv[]); - - -/** - * Start a process. This function is similar to the GNUNET_OS_start_process_* - * except that the filename and arguments can have whole strings which contain - * the arguments. These arguments are to be separated by spaces and are parsed - * in the order they appear. Arguments containing spaces can be used by - * quoting them with @em ". - * - * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags - * @param lsocks array of listen sockets to dup systemd-style (or NULL); - * must be NULL on platforms where dup is not supported - * @param filename name of the binary. It is valid to have the arguments - * in this string when they are separated by spaces. - * @param ... more arguments. Should be of type `char *`. It is valid - * to have the arguments in these strings when they are separated by - * spaces. The last argument MUST be NULL. - * @return pointer to process structure of the new process, NULL on error - */ -struct GNUNET_OS_Process * -GNUNET_OS_start_process_s ( - enum GNUNET_OS_InheritStdioFlags std_inheritance, - const int *lsocks, - const char *filename, - ...); - - -/** - * Handle to a command action. - */ -struct GNUNET_OS_CommandHandle; - - -/** - * Type of a function to process a line of output. - * - * @param cls closure - * @param line line of output from a command, NULL for the end - */ -typedef void -(*GNUNET_OS_LineProcessor) (void *cls, const char *line); - - -/** - * Stop/kill a command. - * - * @param cmd handle to the process - */ -void -GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd); - - -/** - * Run the given command line and call the given function - * for each line of the output. - * - * @param proc function to call for each line of the output - * @param proc_cls closure for proc - * @param timeout when to time out - * @param binary command to run - * @param ... arguments to command - * @return NULL on error - */ -struct GNUNET_OS_CommandHandle * -GNUNET_OS_command_run ( - GNUNET_OS_LineProcessor proc, - void *proc_cls, - struct GNUNET_TIME_Relative timeout, - const char *binary, - ...); - - -/** - * Retrieve the status of a process. - * Nonblocking version. - * - * @param proc pointer to process structure - * @param type status type - * @param code return code/signal number - * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, - enum GNUNET_OS_ProcessStatusType *type, - unsigned long *code); - - -/** - * Wait for a process to terminate. The return code is discarded. - * You must not use #GNUNET_OS_process_status() on the same process - * after calling this function! This function is blocking and should - * thus only be used if the child process is known to have terminated - * or to terminate very soon. - * - * @param proc pointer to process structure of the process to wait for - * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); - - -/** - * Retrieve the status of a process, waiting on it if dead. - * Blocking version. - * - * @param proc pointer to process structure - * @param type status type - * @param code return code/signal number - * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise - */ -enum GNUNET_GenericReturnValue -GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc, - enum GNUNET_OS_ProcessStatusType *type, - unsigned long *code); - - -/** - * Connects this process to its parent via pipe; - * essentially, the parent control handler will read signal numbers - * from the #GNUNET_OS_CONTROL_PIPE (as given in an environment - * variable) and raise those signals. - * - * @param cls closure (unused) - */ -void -GNUNET_OS_install_parent_control_handler (void *cls); - - -/** - * Check whether an executable exists and possibly - * if the suid bit is set on the file. - * Attempts to find the file using the current - * PATH environment variable as a search path. - * - * @param binary the name of the file to check. - * W32: must not have an .exe suffix. - * @param check_suid input true if the binary should be checked for SUID (*nix) - * W32: checks if the program has sufficient privileges by executing this - * binary with the -d flag. -d omits a programs main loop and only - * executes all privileged operations in an binary. - * @param params parameters used for w32 privilege checking (can be NULL for != w32, or when not checking for suid/permissions ) - * @return #GNUNET_YES if the file is SUID (*nix) or can be executed with current privileges (W32), - * #GNUNET_NO if not SUID (but binary exists), - * #GNUNET_SYSERR on error (no such binary or not executable) - */ -enum GNUNET_GenericReturnValue -GNUNET_OS_check_helper_binary (const char *binary, - bool check_suid, - const char *params); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_OS_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_os_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_peer_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_peer_lib.h @@ -1,140 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2006, 2009 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Helper library for interning of peer identifiers - * - * @defgroup peer Peer library - * Helper library for interning of peer identifiers - * @{ - */ - -#ifndef GNUNET_PEER_LIB_H -#define GNUNET_PEER_LIB_H - - -#include "gnunet_util_lib.h" - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/** - * A GNUNET_PEER_Id is simply a shorter version of a "struct - * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to - * save memory when the same identifier needs to be used over and over - * again. - */ -typedef unsigned int GNUNET_PEER_Id; - - -/** - * Search for a peer identity. The reference counter is not changed. - * - * @param pid identity to find - * @return the interned identity or 0. - */ -GNUNET_PEER_Id -GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid); - - -/** - * Intern an peer identity. If the identity is already known, its - * reference counter will be increased by one. - * - * @param pid identity to intern - * @return the interned identity. - */ -GNUNET_PEER_Id -GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid); - - -/** - * Change the reference counter of an interned PID. - * - * @param id identity to change the RC of - * @param delta how much to change the RC - */ -void -GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta); - - -/** - * Decrement multiple RCs of peer identities by one. - * - * @param ids array of PIDs to decrement the RCs of - * @param count size of the @a ids array - */ -void -GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, - unsigned int count); - - -/** - * Convert an interned PID to a normal peer identity. - * - * @param id interned PID to convert - * @param pid where to write the normal peer identity - */ -void -GNUNET_PEER_resolve (GNUNET_PEER_Id id, - struct GNUNET_PeerIdentity *pid); - - -/** - * Convert an interned PID to a normal peer identity. - * - * @param id interned PID to convert - * @return pointer to peer identity, valid as long @a id is valid - */ -const struct GNUNET_PeerIdentity * -GNUNET_PEER_resolve2 (GNUNET_PEER_Id id); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_PEER_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_peer_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_plugin_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_plugin_lib.h @@ -1,179 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Plugin loading and unloading - * - * @defgroup plugin Plugin library - * Plugin loading and unloading - * @{ - */ - -#ifndef GNUNET_PLUGIN_LIB_H -#define GNUNET_PLUGIN_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Signature of any function exported by a plugin. - * - * @param arg argument to the function (context) - * @return some pointer, NULL if the plugin was - * shutdown or if there was an error, otherwise - * the plugin's API on success - */ -typedef void * -(*GNUNET_PLUGIN_Callback) (void *arg); - - -/** - * Test if a plugin exists. - * - * Note that the library must export a symbol called - * "library_name_init" for the test to succeed. - * - * @param library_name name of the plugin to test if it is installed - * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -GNUNET_PLUGIN_test (const char *library_name); - - -/** - * Setup plugin (runs the "init" callback and returns whatever "init" - * returned). If "init" returns NULL, the plugin is unloaded. - * - * Note that the library must export symbols called - * "library_name_init" and "library_name_done". These will be called - * when the library is loaded and unloaded respectively. - * - * @param library_name name of the plugin to load - * @param arg argument to the plugin initialization function - * @return whatever the initialization function returned, NULL on error - */ -void * -GNUNET_PLUGIN_load (const char *library_name, - void *arg); - - -/** - * Signature of a function called by #GNUNET_PLUGIN_load_all(). - * - * @param cls closure - * @param library_name full name of the library (to be used with - * #GNUNET_PLUGIN_unload) - * @param lib_ret return value from the initialization function - * of the library (same as what #GNUNET_PLUGIN_load would - * have returned for the given library name) - */ -typedef void -(*GNUNET_PLUGIN_LoaderCallback) (void *cls, - const char *library_name, - void *lib_ret); - - -/** - * Load all compatible plugins with the given base name. - * - * Note that the library must export symbols called - * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will - * be called when the library is loaded and unloaded respectively. - * - * @param basename basename of the plugins to load - * @param arg argument to the plugin initialization function - * @param cb function to call for each plugin found - * @param cb_cls closure for @a cb - */ -void -GNUNET_PLUGIN_load_all (const char *basename, - void *arg, - GNUNET_PLUGIN_LoaderCallback cb, - void *cb_cls); - - -/** - * Load all compatible plugins with the given base name while inside the given - * context (i.e. a specific project data structure.) - * - * Note that the library must export symbols called `basename_ANYTHING_init` - * and `basename_ANYTHING__done`. These will be called when the library is - * loaded and unloaded respectively. - * - * @param ctx the context used to find the plugins - * @param basename basename of the plugins to load - * @param arg argument to the plugin initialization function - * @param cb function to call for each plugin found - * @param cb_cls closure for @a cb - */ -void -GNUNET_PLUGIN_load_all_in_context (const struct GNUNET_OS_ProjectData *ctx, - const char *basename, - void *arg, - GNUNET_PLUGIN_LoaderCallback cb, - void *cb_cls); - - -/** - * Unload plugin (runs the "done" callback and returns whatever "done" - * returned). The plugin is then unloaded. - * - * @param library_name name of the plugin to unload - * @param arg argument to the plugin shutdown function - * @return whatever the shutdown function returned, typically NULL - * or a "char *" representing the error message - */ -void * -GNUNET_PLUGIN_unload (const char *library_name, - void *arg); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_PLUGIN_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_plugin_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_program_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_program_lib.h @@ -1,179 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2013 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to starting programs - * - * @defgroup program Program library - * Start command-line programs. - * @{ - */ - -#ifndef GNUNET_PROGRAM_LIB_H -#define GNUNET_PROGRAM_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include "gnunet_configuration_lib.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_scheduler_lib.h" - -/** - * Main function that will be run. - * - * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) - * @param cfg configuration - */ -typedef void -(*GNUNET_PROGRAM_Main) (void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Run a standard GNUnet command startup sequence (initialize loggers - * and configuration, parse options). - * - * @param argc number of command line arguments in @a argv - * @param argv command line arguments - * @param binaryName our expected name - * @param binaryHelp help text for the program - * @param options command line options - * @param task main function to run - * @param task_cls closure for @a task - * @param run_without_scheduler #GNUNET_NO start the scheduler, - * #GNUNET_YES do not start the scheduler just run the main task - * @return #GNUNET_SYSERR on error, - * #GNUNET_NO if successful option processing called - * for the program to terminate, - * #GNUNET_OK on success (#a task was invoked) - */ -enum GNUNET_GenericReturnValue -GNUNET_PROGRAM_run2 (int argc, - char *const *argv, - const char *binaryName, - const char *binaryHelp, - const struct GNUNET_GETOPT_CommandLineOption *options, - GNUNET_PROGRAM_Main task, - void *task_cls, - int run_without_scheduler); - - -/** - * Run a standard GNUnet command startup sequence (initialize loggers - * and configuration, parse options). - * - * @param argc number of command line arguments - * @param argv command line arguments - * @param binaryName our expected name - * @param binaryHelp helptext for "-h" option (about the app) - * @param options command line options - * @param task main function to run - * @param task_cls closure for @a task - * @return #GNUNET_SYSERR on error, - * #GNUNET_NO if successful option processing called - * for the program to terminate, - * #GNUNET_OK on success (#a task was invoked) - */ -enum GNUNET_GenericReturnValue -GNUNET_PROGRAM_run (int argc, - char *const *argv, - const char *binaryName, - const char *binaryHelp, - const struct GNUNET_GETOPT_CommandLineOption *options, - GNUNET_PROGRAM_Main task, - void *task_cls); - -enum GNUNET_GenericReturnValue -GNUNET_DAEMON_register (const char *daemon_name, - const char *daemon_desc, - GNUNET_PROGRAM_Main task); - -#ifndef HAVE_GNUNET_MONOLITH -#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \ - int \ - main (int argc, \ - char *const *argv) \ - { \ - int ret; \ - struct GNUNET_GETOPT_CommandLineOption options[] = { \ - GNUNET_GETOPT_OPTION_END \ - }; \ - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, \ - &argv)) \ - return 2; \ - ret = GNUNET_PROGRAM_run (argc, \ - argv, \ - daemon_name, \ - daemon_help, \ - options, \ - init_cb, \ - NULL); \ - GNUNET_free_nz ((void*) argv); \ - return ret; \ - } -#else -#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \ - static int __attribute__ ((constructor)) \ - init (void) \ - { \ - return GNUNET_DAEMON_register (daemon_name, \ - daemon_help, \ - init_cb); \ - } -#endif - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_PROGRAM_LIB_H */ -#endif - -/** @} */ /* end of group program */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_program_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_protocols.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_protocols.h @@ -1,3667 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001--2024 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * @author Tobias Frisch - * - * @file - * Constants for network protocols - * - * @defgroup protocols Network protocol definitions - * Types of messages used in GNUnet. - * - * @see [Documentation](https://gnunet.org/ipc) - * - * @{ - */ - -/******************************************************************************* - * TODO: we need a way to register message types centrally (via some webpage). - * For now: unofficial extensions should start at 48k, internal extensions - * defined here should leave some room (4-10 additional messages to the previous - * extension). - ******************************************************************************/ - -#ifndef GNUNET_PROTOCOLS_H -#define GNUNET_PROTOCOLS_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/******************************************************************************* -* Deprecated -* *****************************************************************************/ - -/** - * Test if service is online. - * - * @deprecated! - */ -#define GNUNET_MESSAGE_TYPE_TEST 0 - -/******************************************************************************* -* AGPL source code download -* *****************************************************************************/ - -/** - * Message to request source code link. - */ -#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL 1 - -/** - * Source code link. - */ -#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL 2 - -/******************************************************************************* - * RESOLVER message types - ******************************************************************************/ - -/** - * Request DNS resolution. - */ -#define GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST 4 - -/** - * Response to a DNS resolution request. - */ -#define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE 5 - -/******************************************************************************* - * UTIL message types - ******************************************************************************/ - -/** - * Dummy messages for testing / benchmarking. - */ -#define GNUNET_MESSAGE_TYPE_DUMMY 6 - -/** - * Another dummy messages for testing / benchmarking. - */ -#define GNUNET_MESSAGE_TYPE_DUMMY2 7 - - -/******************************************************************************* - * ARM message types - ******************************************************************************/ - -/** - * Request to ARM to start a service. - */ -#define GNUNET_MESSAGE_TYPE_ARM_START 8 - -/** - * Request to ARM to stop a service. - */ -#define GNUNET_MESSAGE_TYPE_ARM_STOP 9 - -/** - * Response from ARM. - */ -#define GNUNET_MESSAGE_TYPE_ARM_RESULT 10 - -/** - * Status update from ARM. - */ -#define GNUNET_MESSAGE_TYPE_ARM_STATUS 11 - -/** - * Request to ARM to list all currently running services - */ -#define GNUNET_MESSAGE_TYPE_ARM_LIST 12 - -/** - * Response from ARM for listing currently running services - */ -#define GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT 13 - -/** - * Request to ARM to notify client of service status changes - */ -#define GNUNET_MESSAGE_TYPE_ARM_MONITOR 14 - -/** - * Test if ARM service is online. - */ -#define GNUNET_MESSAGE_TYPE_ARM_TEST 15 - -/******************************************************************************* - * HELLO message types - ******************************************************************************/ - -/** - * Latest HELLO messages used for communicating peer addresses. - * Managed by libgnunethello. - */ -#define GNUNET_MESSAGE_TYPE_HELLO_URI 16 - -/** - * HELLO message with friend only flag used for communicating peer addresses. - * Managed by libgnunethello. - */ - -#define GNUNET_MESSAGE_TYPE_HELLO 17 - -/******************************************************************************* - * FRAGMENTATION message types - ******************************************************************************/ - -/** - * FRAGMENT of a larger message. - * Managed by libgnunetfragment. - */ -#define GNUNET_MESSAGE_TYPE_FRAGMENT 18 - -/** - * Acknowledgement of a FRAGMENT of a larger message. - * Managed by libgnunetfragment. - */ -#define GNUNET_MESSAGE_TYPE_FRAGMENT_ACK 19 - -/******************************************************************************* - * Transport-WLAN message types - ******************************************************************************/ - -/** - * Type of data messages from the plugin to the gnunet-wlan-helper - */ -#define GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER 39 - -/** - * Type of data messages from the gnunet-wlan-helper to the plugin - */ -#define GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER 40 - -/** - * Control message between the gnunet-wlan-helper and the daemon (with the MAC). - */ -#define GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL 41 - -/** - * Type of messages for advertisement over wlan - */ -#define GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT 42 - -/** - * Type of messages for data over the wlan - */ -#define GNUNET_MESSAGE_TYPE_WLAN_DATA 43 - - -/******************************************************************************* - * Transport-DV message types - ******************************************************************************/ - -/** - * DV service to DV Plugin message, when a message is - * unwrapped by the DV service and handed to the plugin - * for processing - */ -#define GNUNET_MESSAGE_TYPE_DV_RECV 44 - -/** - * DV Plugin to DV service message, indicating a message - * should be sent out. - */ -#define GNUNET_MESSAGE_TYPE_DV_SEND 45 - -/** - * DV service to DV api message, containing a confirmation - * or failure of a DV_SEND message. - */ -#define GNUNET_MESSAGE_TYPE_DV_SEND_ACK 46 - -/** - * P2P DV message encapsulating some real message - */ -#define GNUNET_MESSAGE_TYPE_DV_ROUTE 47 - -/** - * DV Plugin to DV service message, indicating - * startup. - */ -#define GNUNET_MESSAGE_TYPE_DV_START 48 - -/** - * P2P DV message telling plugin that a peer connected - */ -#define GNUNET_MESSAGE_TYPE_DV_CONNECT 49 - -/** - * P2P DV message telling plugin that a peer disconnected - */ -#define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50 - -/** - * P2P DV message telling plugin that a message transmission failed (negative - * ACK) - */ -#define GNUNET_MESSAGE_TYPE_DV_SEND_NACK 51 - -/** - * P2P DV message telling plugin that our distance to a peer changed - */ -#define GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED 52 - -/** - * DV message box for boxing multiple messages. - */ -#define GNUNET_MESSAGE_TYPE_DV_BOX 53 - - -/** - * Experimental message type. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_XU_MESSAGE 55 - - -/******************************************************************************* - * Transport-UDP message types - ******************************************************************************/ - -/** - * Normal UDP message type. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE 56 - -/** - * UDP ACK. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK 57 - -/******************************************************************************* - * Transport-TCP message types - ******************************************************************************/ - -/** - * TCP NAT probe message, send from NAT'd peer to - * other peer to establish bi-directional communication - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE 60 - -/** - * Welcome message between TCP transports. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME 61 - -/** - * Message to force transport to update bandwidth assignment (LEGACY) - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ATS 62 - -/******************************************************************************* - * NAT message types - ******************************************************************************/ - -/** - * Message to ask NAT server to perform traversal test - */ -#define GNUNET_MESSAGE_TYPE_NAT_TEST 63 - -/******************************************************************************* - * CORE message types - ******************************************************************************/ - -/** - * Initial setup message from core client to core. - */ -#define GNUNET_MESSAGE_TYPE_CORE_INIT 64 - -/** - * Response from core to core client to INIT message. - */ -#define GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY 65 - -/** - * Notify clients about new peer-to-peer connections (triggered - * after key exchange). - */ -#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT 67 - -/** - * Notify clients about peer disconnecting. - */ -#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT 68 - -/** - * Notify clients about peer status change. - */ -#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE 69 - -/** - * Notify clients about incoming P2P messages. - */ -#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND 70 - -/** - * Notify clients about outgoing P2P transmissions. - */ -#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 71 - -/** - * Request from client to transmit message. - */ -#define GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST 74 - -/** - * Confirmation from core that message can now be sent - */ -#define GNUNET_MESSAGE_TYPE_CORE_SEND_READY 75 - -/** - * Client with message to transmit (after SEND_READY confirmation - * was received). - */ -#define GNUNET_MESSAGE_TYPE_CORE_SEND 76 - -/** - * Request for connection monitoring from CORE service. - */ -#define GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS 78 - -/** - * Reply for monitor by CORE service. - */ -#define GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY 79 - -/** - * Encapsulation for an encrypted message between peers. - */ -#define GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE 82 - -/** - * Check that other peer is alive (challenge). - */ -#define GNUNET_MESSAGE_TYPE_CORE_PING 83 - -/** - * Confirmation that other peer is alive. - */ -#define GNUNET_MESSAGE_TYPE_CORE_PONG 84 - -/** - * Request by the other peer to terminate the connection. - */ -#define GNUNET_MESSAGE_TYPE_CORE_HANGUP 85 - -/** - * gzip-compressed type map of the sender - */ -#define GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP 86 - -/** - * uncompressed type map of the sender - */ -#define GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP 87 - -/** - * Session key exchange between peers. - */ -#define GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY 88 - -/** - * Other peer confirms having received the type map - */ -#define GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP 89 - - -/******************************************************************************* - * DATASTORE message types - ******************************************************************************/ - -/** - * Message sent by datastore client on join. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE 92 - -/** - * Message sent by datastore client on join. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE 93 - -/** - * Message sent by datastore to client informing about status - * processing a request - * (in response to RESERVE, RELEASE_RESERVE, PUT, UPDATE and REMOVE requests). - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS 94 - -/** - * Message sent by datastore client to store data. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_PUT 95 - -/** - * Message sent by datastore client to get data. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_GET 97 - -/** - * Message sent by datastore client to get random data. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION 98 - -/** - * Message sent by datastore client to get random data. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY 99 - -/** - * Message sent by datastore to client providing requested data - * (in response to GET or GET_RANDOM request). - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA 100 - -/** - * Message sent by datastore to client signaling end of matching data. - * This message will also be sent for "GET_RANDOM", even though - * "GET_RANDOM" returns at most one data item. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END 101 - -/** - * Message sent by datastore client to remove data. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE 102 - -/** - * Message sent by datastore client to drop the database. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_DROP 103 - -/** - * Message sent by datastore client to get data by key. - */ -#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY 104 - - -/******************************************************************************* - * FS message types - ******************************************************************************/ - -/** - * Message sent by fs client to request LOC signature. - */ -#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN 126 - -/** - * Reply sent by fs service with LOC signature. - */ -#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE 127 - -/** - * Message sent by fs client to start indexing. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_START 128 - -/** - * Affirmative response to a request for start indexing. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK 129 - -/** - * Response to a request for start indexing that - * refuses. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED 130 - -/** - * Request from client for list of indexed files. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET 131 - -/** - * Reply to client with an indexed file name. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY 132 - -/** - * Reply to client indicating end of list. - */ -#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END 133 - -/** - * Request from client to unindex a file. - */ -#define GNUNET_MESSAGE_TYPE_FS_UNINDEX 134 - -/** - * Reply to client indicating unindex receipt. - */ -#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK 135 - -/** - * Client asks FS service to start a (keyword) search. - */ -#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH 136 - -/** - * P2P request for content (one FS to another). - */ -#define GNUNET_MESSAGE_TYPE_FS_GET 137 - -/** - * P2P response with content or active migration of content. Also - * used between the service and clients (in response to - * #GNUNET_MESSAGE_TYPE_FS_START_SEARCH). - */ -#define GNUNET_MESSAGE_TYPE_FS_PUT 138 - -/** - * Peer asks us to stop migrating content towards it for a while. - */ -#define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP 139 - -/** - * P2P request for content (one FS to another via a cadet). - */ -#define GNUNET_MESSAGE_TYPE_FS_CADET_QUERY 140 - -/** - * P2P answer for content (one FS to another via a cadet). - */ -#define GNUNET_MESSAGE_TYPE_FS_CADET_REPLY 141 - - -/******************************************************************************* - * DHT message types - ******************************************************************************/ -/** - * Client wants to store item in DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT 142 - -/** - * Client wants to lookup item in DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET 143 - -/** - * Client wants to stop search in DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP 144 - -/** - * Service returns result to client. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT 145 - -/** - * Peer is storing data in DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_P2P_PUT 146 - -/** - * Peer tries to find data in DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_P2P_GET 147 - -/** - * Data is returned to peer from DHT. - */ -#define GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT 148 - -/** - * Receive information about transiting GETs - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET 149 - -/** - * Receive information about transiting GET responses - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP 150 - -/** - * Receive information about transiting PUTs - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT 151 - -/** - * Receive information about transiting PUT responses (TODO) - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT_RESP 152 - -/** - * Request information about transiting messages - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_START 153 - -/** - * Stop information about transiting messages - */ -#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 - -/** - * Certain results are already known to the client, filter those. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 - -/** - * HELLO advertising a neighbours addresses. - */ -#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO 157 - -/** - * Encapsulation of DHT messages in CORE service. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CORE 158 - -/** - * HELLO URL send between client and service (in - * either direction). - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL 159 - -/** - * Client requests DHT service's HELLO URL. - */ -#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_GET 161 - - -/******************************************************************************* - * HOSTLIST message types - ******************************************************************************/ - -/** - * Hostlist advertisement message - */ -#define GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT 160 - - -/******************************************************************************* - * STATISTICS message types - ******************************************************************************/ - -/** - * Set a statistical value. - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_SET 168 - -/** - * Get a statistical value(s). - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_GET 169 - -/** - * Response to a STATISTICS_GET message (with value). - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_VALUE 170 - -/** - * Response to a STATISTICS_GET message (end of value stream). - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_END 171 - -/** - * Watch changes to a statistical value. Message format is the same - * as for GET, except that the subsystem and entry name must be given. - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_WATCH 172 - -/** - * Changes to a watched value. - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE 173 - -/** - * Client is done sending service requests and will now disconnect. - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT 174 - -/** - * Service confirms disconnect and that it is done processing - * all requests from the client. - */ -#define GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT_CONFIRM 175 - -/******************************************************************************* - * VPN message types - ******************************************************************************/ - -/** - * Type of messages between the gnunet-vpn-helper and the daemon - */ -#define GNUNET_MESSAGE_TYPE_VPN_HELPER 185 - -/** - * Type of messages containing an ICMP packet for a service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE 190 - -/** - * Type of messages containing an ICMP packet for the Internet. - */ -#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET 191 - -/** - * Type of messages containing an ICMP packet for the VPN - */ -#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN 192 - -/** - * Type of messages containing an DNS request for a DNS exit service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET 193 - -/** - * Type of messages containing an DNS reply from a DNS exit service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET 194 - -/** - * Type of messages containing an TCP packet for a service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START 195 - -/** - * Type of messages containing an TCP packet for the Internet. - */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START 196 - -/** - * Type of messages containing an TCP packet of an established connection. - */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT 197 - -/** - * Type of messages containing an TCP packet of an established connection. - */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN 198 - -/** - * Type of messages containing an UDP packet for a service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE 199 - -/** - * Type of messages containing an UDP packet for the Internet. - */ -#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET 200 - -/** - * Type of messages containing an UDP packet from a remote host - */ -#define GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY 201 - - -/** - * Client asks VPN service to setup an IP to redirect traffic - * via an exit node to some global IP address. - */ -#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP 202 - -/** - * Client asks VPN service to setup an IP to redirect traffic - * to some peer offering a service. - */ -#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE 203 - -/** - * VPN service responds to client with an IP to use for the - * requested redirection. - */ -#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP 204 - - -/******************************************************************************* - * VPN-DNS message types - ******************************************************************************/ - - -/** - * Initial message from client to DNS service for registration. - */ -#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_INIT 211 - -/** - * Type of messages between the gnunet-helper-dns and the service - */ -#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST 212 - -/** - * Type of messages between the gnunet-helper-dns and the service - */ -#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE 213 - -/** - * Type of messages between the gnunet-helper-dns and the service - */ -#define GNUNET_MESSAGE_TYPE_DNS_HELPER 214 - - -/******************************************************************************* - * CHAT message types START - ******************************************************************************/ - -/** - * Message sent from client to join a chat room. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST 300 - -/** - * Message sent to client to indicate joining of another room member. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION 301 - -/** - * Message sent to client to indicate leaving of another room member. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION 302 - -/** - * Notification sent by service to client indicating that we've received a chat - * message. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION 303 - -/** - * Request sent by client to transmit a chat message to another room members. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST 304 - -/** - * Receipt sent from a message receiver to the service to confirm delivery of - * a chat message. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT 305 - -/** - * Notification sent from the service to the original sender - * to acknowledge delivery of a chat message. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION 306 - -/** - * P2P message sent to indicate joining of another room member. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION 307 - -/** - * P2P message sent to indicate leaving of another room member. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION 308 - -/** - * P2P message sent to a newly connected peer to request its known clients in - * order to synchronize room members. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_P2P_SYNC_REQUEST 309 - -/** - * Notification sent from one peer to another to indicate that we have received - * a chat message. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION 310 - -/** - * P2P receipt confirming delivery of a chat message. - */ -#define GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT 311 - - -/******************************************************************************* - * NSE (network size estimation) message types - ******************************************************************************/ - -/** - * client->service message indicating start - */ -#define GNUNET_MESSAGE_TYPE_NSE_START 321 - -/** - * P2P message sent from nearest peer - */ -#define GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD 322 - -/** - * service->client message indicating - */ -#define GNUNET_MESSAGE_TYPE_NSE_ESTIMATE 323 - - -/******************************************************************************* - * PEERINFO message types - ******************************************************************************/ - -/** - * Request update and listing of a peer. - */ -#define GNUNET_MESSAGE_TYPE_PEERINFO_GET 330 - -/** - * Request update and listing of all peers. - */ -#define GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL 331 - -/** - * Information about one of the peers. - */ -#define GNUNET_MESSAGE_TYPE_PEERINFO_INFO 332 - -/** - * End of information about other peers. - */ -#define GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END 333 - -/** - * Start notifying this client about all changes to - * the known peers until it disconnects. - */ -#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334 - -/******************************************************************************* - * ATS message types - ******************************************************************************/ - -/** - * Type of the 'struct ClientStartMessage' sent by clients to ATS to - * identify the type of the client. - */ -#define GNUNET_MESSAGE_TYPE_ATS_START 340 - -/** - * Type of the 'struct RequestAddressMessage' sent by clients to ATS - * to request an address to help connect. - */ -#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS 341 - -/** - * Type of the 'struct RequestAddressMessage' sent by clients to ATS - * to request an address to help connect. - */ -#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL 342 - -/** - * Type of the 'struct AddressUpdateMessage' sent by clients to ATS - * to inform ATS about performance changes. - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE 343 - -/** - * Type of the 'struct AddressDestroyedMessage' sent by clients to ATS - * to inform ATS about an address being unavailable. - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED 344 - -/** - * Type of the 'struct AddressSuggestionMessage' sent by ATS to clients - * to suggest switching to a different address. - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION 345 - -/** - * Type of the 'struct PeerInformationMessage' sent by ATS to clients - * to inform about QoS for a particular connection. - */ -#define GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION 346 - -/** - * Type of the 'struct ReservationRequestMessage' sent by clients to ATS - * to ask for inbound bandwidth reservations. - */ -#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST 347 - -/** - * Type of the 'struct ReservationResultMessage' sent by ATS to clients - * in response to a reservation request. - */ -#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT 348 - -/** - * Type of the 'struct ChangePreferenceMessage' sent by clients to ATS - * to ask for allocation preference changes. - */ -#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE 349 - -/** - * Type of the 'struct SessionReleaseMessage' sent by ATS to client - * to confirm that a session ID was destroyed. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE 350 - -/** - * Type of the 'struct AddressUpdateMessage' sent by client to ATS - * to add a new address - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD 353 - -/** - * Type of the 'struct AddressListRequestMessage' sent by client to ATS - * to request information about addresses - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST 354 - -/** - * Type of the 'struct AddressListResponseMessage' sent by ATS to client - * with information about addresses - */ -#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE 355 - -/** - * Type of the 'struct ChangePreferenceMessage' sent by clients to ATS - * to ask for allocation preference changes. - */ -#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK 356 - - -/******************************************************************************* - * TRANSPORT message types - ******************************************************************************/ - -/** - * Message from the core saying that the transport - * server should start giving it messages. This - * should automatically trigger the transmission of - * a HELLO message. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_START 360 - -/** - * Message from TRANSPORT notifying about a - * client that connected to us. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT 361 - -/** - * Message from TRANSPORT notifying about a - * client that disconnected from us. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT 362 - -/** - * Request to TRANSPORT to transmit a message. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND 363 - -/** - * Confirmation from TRANSPORT that message for transmission has been - * queued (and that the next message to this peer can now be passed to - * the service). Note that this confirmation does NOT imply that the - * message was fully transmitted. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK 364 - -/** - * Message from TRANSPORT notifying about a - * message that was received. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV 365 - -/** - * Message telling transport to limit its receive rate. - * (FIXME: was the above comment ever accurate?) - * - * Note: dead in TNG, replaced by RECV_OK! - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA 366 - -/** - * Message telling transport to limit its receive rate. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK 366 - -/** - * Request to look addresses of peers in server. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING 367 - -/** - * Response to the address lookup request. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY 368 - -/** - * Register a client that wants to do blacklisting. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT 369 - -/** - * Query to a blacklisting client (is this peer blacklisted)? - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY 370 - -/** - * Reply from blacklisting client (answer to blacklist query). - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY 371 - -/** - * Transport PING message - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING 372 - -/** - * Transport PONG message - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 373 - -/** - * Transport SYN message exchanged between transport services to - * indicate that a session should be marked as 'connected'. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN 375 - -/** - * Transport SYN_ACK message exchanged between transport services to - * indicate that a SYN message was accepted - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK 376 - -/** - * Transport ACK message exchanged between transport services to - * indicate that a SYN_ACK message was accepted - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK 377 - -/** - * Transport DISCONNECT message exchanged between transport services to - * indicate that a connection should be dropped. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT 378 - -/** - * Message exchanged between transport services to - * indicate that the sender should limit its transmission - * rate to the indicated quota. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA 379 - -/** - * Request to monitor addresses used by a peer or all peers. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST 380 - -/** - * Message send by a peer to notify the other to keep the session alive - * and measure latency in a regular interval - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE 381 - -/** - * Response to a #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to - * measure latency in a regular interval - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE 382 - -/** - * Response to #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST - * request to iterate over all known addresses. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE 383 - -/** - * Message send by a peer to notify the other to keep the session alive. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON 384 - -/** - * Message containing traffic metrics for transport service - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC 385 - -/** - * Request to start monitoring the connection state of plugins. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START 388 - -/** - * Monitoring event about the connection state of plugins, - * generated in response to a subscription initiated via - * #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT 389 - -/** - * Monitoring event notifying client that the initial iteration - * is now completed and we are in sync with the state of the subsystem. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC 390 - -/** - * Response to #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END - * terminating list of replies. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END 391 - - -/******************************************************************************* - * FS-PUBLISH-HELPER IPC Messages - ******************************************************************************/ - -/** - * Progress information from the helper: found a file - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE 420 - -/** - * Progress information from the helper: found a directory - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY 421 - -/** - * Error signal from the helper. - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR 422 - -/** - * Signal that helper skipped a file. - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE 423 - -/** - * Signal that helper is done scanning the directory tree. - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE 424 - -/** - * Extracted meta data from the helper. - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA 425 - -/** - * Signal that helper is done. - */ -#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED 426 - - -/******************************************************************************* - * NAMECACHE message types - ******************************************************************************/ - -/** - * Client to service: lookup block - */ -#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK 431 - -/** - * Service to client: result of block lookup - */ -#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE 432 - -/** - * Client to service: cache a block - */ -#define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE 433 - -/** - * Service to client: result of block cache request - */ -#define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE 434 - -/******************************************************************************* - * NAMESTORE message types - ******************************************************************************/ - -/** - * Client to service: store records (as authority) - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE 435 - -/** - * Service to client: result of store operation. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE 436 - -/** - * Client to service: lookup label - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP 437 - -/** - * Service to client: lookup label - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE 438 - -/** - * Client to service: "reverse" lookup for zone name based on zone key - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439 - -/** - * Service to client: result of zone-to-name lookup. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440 - -/** - * Client to service: start monitoring (yields sequence of - * "ZONE_ITERATION_RESPONSES" --- forever). - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START 441 - -/** - * Service to client: you're now in sync. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC 442 - -/** - * Service to client: here is a (plaintext) record you requested. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT 443 - -/** - * Client to service: I am now ready for the next (set of) monitor - * events. Monitoring equivlaent of - * #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT 444 - -/** - * Client to service: please start iteration; receives - * "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445 - -/** - * Client to service: next record(s) in iteration please. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447 - -/** - * Client to service: stop iterating. - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448 - -/** - * Service to client: end of list of results - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END 449 - - -/******************************************************************************* - * LOCKMANAGER message types - ******************************************************************************/ - -/** - * Message to acquire Lock - */ -#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE 450 - -/** - * Message to release lock - */ -#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE 451 - -/** - * SUCCESS reply from lockmanager - */ -#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS 452 - -/******************************************************************************* - * TESTBED message types - ******************************************************************************/ - -/** - * Initial message from a client to a testing control service - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_INIT 460 - -/** - * Message to add host - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST 461 - -/** - * Message to signal that a add host succeeded - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS 462 - -/** - * Message to link delegated controller to slave controller - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS 463 - -/** - * Message to create a peer at a host - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER 464 - -/** - * Message to reconfigure a peer - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER 465 - -/** - * Message to start a peer at a host - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_START_PEER 466 - -/** - * Message to stop a peer at a host - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER 467 - -/** - * Message to destroy a peer - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER 468 - -/** - * Configure underlay link message - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_CONFIGURE_UNDERLAY_LINK 469 - -/** - * Message to connect peers in a overlay - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT 470 - -/** - * Message for peer events - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT 471 - -/** - * Message for peer connect events - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT 472 - -/** - * Message for operation events - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT 473 - -/** - * Message to signal successful peer creation - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS 474 - -/** - * Message to signal a generic operation has been successful - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS 475 - -/** - * Message to get a peer's information - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION 476 - -/** - * Message containing the peer's information - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION 477 - -/** - * Message to request a controller to make one of its peer to connect to another - * peer using the contained HELLO - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT 478 - -/** - * Message to request configuration of a slave controller - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION 479 - -/** - * Message which contains the configuration of slave controller - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION 480 - -/** - * Message to signal the result of #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS - * request - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT 481 - -/** - * A controller receiving this message floods it to its directly-connected - * sub-controllers and then stops and destroys all peers - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS 482 - -/** - * Message to start/stop a service of a peer - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE 483 - -/** - * Message to initialise a barrier. Messages of these type are flooded to all - * sub-controllers - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT 484 - -/** - * Message to cancel a barrier. This message is flooded to all sub-controllers - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL 485 - -/** - * Message for signalling status of a barrier - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS 486 - -/** - * Message sent by a peer when it has reached a barrier and is waiting for it to - * be crossed - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT 487 - -/** - * Not really a message, but for careful checks on the testbed messages; Should - * always be the maximum and never be used to send messages with this type - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_MAX 488 - -/** - * The initialization message towards gnunet-testbed-helper - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT 495 - -/** - * The reply message from gnunet-testbed-helper - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY 496 - - -/****************************************************************************** - * GNS. - *****************************************************************************/ - -/** - * Client would like to resolve a name. - */ -#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP 500 - -/** - * Service response to name resolution request from client. - */ -#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT 501 - -/** - * Reverse lookup - */ -#define GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP 503 - -/** - * Response to reverse lookup - */ -#define GNUNET_MESSAGE_TYPE_GNS_REVERSE_LOOKUP_RESULT 504 - - -/******************************************************************************* - * CONSENSUS message types - ******************************************************************************/ - -/** - * Join a consensus session. Sent by client to service as first message. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN 520 - -/** - * Insert an element. Sent by client to service. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_INSERT 521 - -/** - * Begin accepting new elements from other participants. - * Sent by client to service. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_BEGIN 522 - -/** - * Sent by service when a new element is added. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT 523 - -/** - * Sent by client to service in order to start the consensus conclusion. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE 524 - -/** - * Sent by service to client in order to signal a completed consensus - * conclusion. Last message sent in a consensus session. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE 525 - - -/* message types 526-539 reserved for consensus client/service messages */ - - -/** - * Sent by client to service, telling whether a received element should - * be accepted and propagated further or not. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_ACK 540 - -/** - * Strata estimator. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_DELTA_ESTIMATE 541 - -/** - * IBF containing all elements of a peer. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_DIFFERENCE_DIGEST 542 - -/** - * One or more elements that are sent from peer to peer. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS 543 - -/** - * Elements, and requests for further elements - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REQUEST 544 - -/** - * Elements that a peer reports to be missing at the remote peer. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REPORT 545 - -/** - * Provide context for a consensus round. - */ -#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT 547 - - -/******************************************************************************* - * SETU message types - ******************************************************************************/ - - -/** - * Cancel a set operation - */ -#define GNUNET_MESSAGE_TYPE_SETU_CANCEL 550 - -/** - * Add element to set - */ -#define GNUNET_MESSAGE_TYPE_SETU_ADD 551 - -/** - * Create a new local set - */ -#define GNUNET_MESSAGE_TYPE_SETU_CREATE 552 - -/** - * Handle result message from operation - */ -#define GNUNET_MESSAGE_TYPE_SETU_RESULT 553 - -/** - * Evaluate a set operation - */ -#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE 554 - -/** - * Listen for operation requests - */ -#define GNUNET_MESSAGE_TYPE_SETU_LISTEN 555 - -/** - * Reject a set request. - */ -#define GNUNET_MESSAGE_TYPE_SETU_REJECT 556 - -/** - * Accept an incoming set request - */ -#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT 557 - -/** - * Notify the client of an incoming request from a remote peer - */ -#define GNUNET_MESSAGE_TYPE_SETU_REQUEST 558 - - -/** - * Demand the whole element from the other - * peer, given only the hash code. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL 559 - -/** - * Demand the whole element from the other - * peer, given only the hash code. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND 560 - -/** - * Tell the other peer to send us a list of - * hashes that match an IBF key. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_INQUIRY 561 - -/** - * Tell the other peer which hashes match a - * given IBF key. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER 562 - -/** - * Request a set union operation from a remote peer. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST 563 - -/** - * Strata estimator. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_SE 564 - -/** - * Invertible bloom filter. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_IBF 565 - -/** - * Actual set elements. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS 566 - -/** - * Set operation is done. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_DONE 568 - -/** - * Compressed strata estimator. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_SEC 569 - -/** - * Request all missing elements from the other peer, - * based on their sets and the elements we previously sent - * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE 570 - -/** - * Send a set element, not as response to a demand but because - * we're sending the full set. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT 571 - -/** - * Request all missing elements from the other peer, - * based on their sets and the elements we previously sent - * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. - */ -#define GNUNET_MESSAGE_TYPE_SETU_P2P_OVER 572 - -/** - * Signals other peer that all elements are sent. - */ - -#define GNUNET_MESSAGE_TYPE_SETU_P2P_SEND_FULL 710 - - -/******************************************************************************* - * SETI message types - ******************************************************************************/ - - -/** - * Cancel a set operation - */ -#define GNUNET_MESSAGE_TYPE_SETI_CANCEL 580 - -/** - * Add element to set. - */ -#define GNUNET_MESSAGE_TYPE_SETI_ADD 581 - -/** - * Create a new local set - */ -#define GNUNET_MESSAGE_TYPE_SETI_CREATE 582 - -/** - * Handle result message from operation - */ -#define GNUNET_MESSAGE_TYPE_SETI_RESULT 583 - -/** - * Evaluate a set operation - */ -#define GNUNET_MESSAGE_TYPE_SETI_EVALUATE 584 - -/** - * Listen for operation requests - */ -#define GNUNET_MESSAGE_TYPE_SETI_LISTEN 585 - -/** - * Reject a set request. - */ -#define GNUNET_MESSAGE_TYPE_SETI_REJECT 586 - -/** - * Accept an incoming set request - */ -#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT 587 - -/** - * Notify the client of an incoming request from a remote peer - */ -#define GNUNET_MESSAGE_TYPE_SETI_REQUEST 588 - -/** - * Information about the element count for intersection - */ -#define GNUNET_MESSAGE_TYPE_SETI_P2P_ELEMENT_INFO 591 - -/** - * Bloom filter message for intersection exchange started by Bob. - */ -#define GNUNET_MESSAGE_TYPE_SETI_P2P_BF 592 - -/** - * Intersection operation is done. - */ -#define GNUNET_MESSAGE_TYPE_SETI_P2P_DONE 593 - -/** - * Request to begin set intersection operation. - */ -#define GNUNET_MESSAGE_TYPE_SETI_P2P_OPERATION_REQUEST 594 - - -/******************************************************************************* - * SET message types - ******************************************************************************/ - - -/** - * Demand the whole element from the other - * peer, given only the hash code. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL 565 - -/** - * Demand the whole element from the other - * peer, given only the hash code. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND 566 - -/** - * Tell the other peer to send us a list of - * hashes that match an IBF key. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY 567 - -/** - * Tell the other peer which hashes match a - * given IBF key. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER 568 - -/** - * Reject a set request. - */ -#define GNUNET_MESSAGE_TYPE_SET_REJECT 569 - -/** - * Cancel a set operation - */ -#define GNUNET_MESSAGE_TYPE_SET_CANCEL 570 - -/** - * Acknowledge result from iteration - */ -#define GNUNET_MESSAGE_TYPE_SET_ITER_ACK 571 - -/** - * Create an empty set - */ -#define GNUNET_MESSAGE_TYPE_SET_RESULT 572 - -/** - * Add element to set - */ -#define GNUNET_MESSAGE_TYPE_SET_ADD 573 - -/** - * Remove element from set - */ -#define GNUNET_MESSAGE_TYPE_SET_REMOVE 574 - -/** - * Listen for operation requests - */ -#define GNUNET_MESSAGE_TYPE_SET_LISTEN 575 - -/** - * Accept a set request - */ -#define GNUNET_MESSAGE_TYPE_SET_ACCEPT 576 - -/** - * Evaluate a set operation - */ -#define GNUNET_MESSAGE_TYPE_SET_EVALUATE 577 - -/** - * Start a set operation with the given set - */ -#define GNUNET_MESSAGE_TYPE_SET_CONCLUDE 578 - -/** - * Notify the client of a request from a remote peer - */ -#define GNUNET_MESSAGE_TYPE_SET_REQUEST 579 - -/** - * Create a new local set - */ -#define GNUNET_MESSAGE_TYPE_SET_CREATE 580 - -/** - * Request a set operation from a remote peer. - */ -#define GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 581 - -/** - * Strata estimator. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE 582 - -/** - * Invertible bloom filter. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF 583 - -/** - * Actual set elements. - */ -#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS 584 - -/** - * Set operation is done. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE 586 - -/** - * Start iteration over set elements. - */ -#define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST 587 - -/** - * Element result for the iterating client. - */ -#define GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT 588 - -/** - * Iteration end marker for the client. - */ -#define GNUNET_MESSAGE_TYPE_SET_ITER_DONE 589 - -/** - * Compressed strata estimator. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC 590 - -/** - * Information about the element count for intersection - */ -#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO 591 - -/** - * Bloom filter message for intersection exchange started by Bob. - */ -#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF 592 - -/** - * Intersection operation is done. - */ -#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE 593 - -/** - * Ask the set service to prepare a copy of a set. - */ -#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE 594 - -/** - * Give the client an ID for connecting to the set's copy. - */ -#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE 595 - -/** - * Sent by the client to the server to connect to an existing, - * lazily copied set. - */ -#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT 596 - -/** - * Request all missing elements from the other peer, - * based on their sets and the elements we previously sent - * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE 597 - -/** - * Send a set element, not as response to a demand but because - * we're sending the full set. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT 598 - -/** - * Request all missing elements from the other peer, - * based on their sets and the elements we previously sent - * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. - */ -#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER 599 - - -/******************************************************************************* - * TESTBED LOGGER message types - ******************************************************************************/ - -/** - * Message for TESTBED LOGGER - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG 600 - -/** - * Message for TESTBED LOGGER acknowledgement - */ -#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_ACK 601 - - -/** - * Advertise regex capability. - */ -#define GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE 620 - -/** - * Search for peer with matching capability. - */ -#define GNUNET_MESSAGE_TYPE_REGEX_SEARCH 621 - -/** - * Result in response to regex search. - */ -#define GNUNET_MESSAGE_TYPE_REGEX_RESULT 622 - -/******************************************************************************* - * IDENTITY message types - ******************************************************************************/ - -/** - * First message send from identity client to service (to subscribe to - * updates). - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_START 624 - -/** - * Generic response from identity service with success and/or error message. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE 625 - -/** - * Update about identity status from service to clients. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE 626 - -/** - * Client requests to know default identity for a subsystem. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT 627 - -/** - * Client sets default identity; or service informs about default identity. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT 628 - -/** - * Create new identity (client->service). - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE 629 - -/** - * Rename existing identity (client->service). - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME 630 - -/** - * Delete identity (client->service). - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE 631 - -/** - * First message send from identity client to service to - * lookup a single ego. The service will respond with a - * #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE message if the ego - * exists, or a #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE if not. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP 632 - -/** - * First message send from identity client to service to lookup a - * single ego matching the given suffix (longest match). The service - * will respond with a #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE message if - * the ego exists, or a #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE if - * not. - */ -#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX 633 - - -/******************************************************************************* - * REVOCATION message types - ******************************************************************************/ - -/** - * Client to service: was this key revoked? - */ -#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY 636 - -/** - * Service to client: answer if key was revoked! - */ -#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE 637 - -/** - * Client to service OR peer-to-peer: revoke this key! - */ -#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE 638 - -/** - * Service to client: revocation confirmed - */ -#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE 639 - - -/******************************************************************************* - * SCALARPRODUCT message types - ******************************************************************************/ - -/** - * Client -> Alice - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE 640 - -/** - * Client -> Bob - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB 641 - -/** - * Client -> Alice multipart - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE 642 - -/** - * Client -> Bob multipart - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB 643 - -/** - * Alice -> Bob session initialization - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION 644 - -/** - * Alice -> Bob SP crypto-data (after intersection) - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA 645 - -/** - * Bob -> Alice SP crypto-data - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA 647 - -/** - * Bob -> Alice SP crypto-data multipart - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART 648 - -/** - * Alice/Bob -> Client Result - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT 649 - -/** - * Alice -> Bob ECC session initialization - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ECC_SESSION_INITIALIZATION 650 - -/** - * Alice -> Bob ECC crypto data - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ECC_ALICE_CRYPTODATA 651 - -/** - * Bob -> Alice ECC crypto data - */ -#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ECC_BOB_CRYPTODATA 652 - - -/******************************************************************************* - * PSYCSTORE message types - ******************************************************************************/ - -/** - * Store a membership event. - */ -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE 660 - -/** - * Test for membership of a member at a particular point in time. - */ -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST 661 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE 662 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET 663 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET 664 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET_FRAGMENT 665 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_COUNTERS_GET 666 - -/* 657 */ - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY 668 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC 669 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_RESET 670 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE 671 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET 672 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET_PREFIX 673 - -/** - * Generic response from PSYCstore service with success and/or error message. - */ -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE 674 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_FRAGMENT 675 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS 676 - -#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_STATE 677 - - -/******************************************************************************* - * PSYC message types - ******************************************************************************/ - -/** - * C: client - * S: service - * M: multicast - */ - -/** S->C: result of an operation */ -#define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680 - -/** C->S: request to start a channel as a master */ -#define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681 - -/** S->C: master start acknowledgement */ -#define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682 - -/** C->S: request to join a channel as a slave */ -#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 683 - -/** S->C: slave join acknowledgement */ -#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 684 - -/** C->S: request to part from a channel */ -#define GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST 685 - -/** S->C: acknowledgement that a slave of master parted from a channel */ -#define GNUNET_MESSAGE_TYPE_PSYC_PART_ACK 686 - -/** M->S->C: incoming join request from multicast */ -#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 - -/** C->S->M: decision about a join request */ -#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688 - - -/** C->S: request to add/remove channel slave in the membership database. */ -#define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_MEMBERSHIP_STORE 689 - -/* 690 */ - -/** S<--C: PSYC message which contains one or more message parts. */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 - -/** M<->S<->C: PSYC message which contains a header and one or more message - * parts. */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \ - 692 // FIXME: start using this where appropriate - -/** Message part: method */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 - -/** Message part: modifier */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 694 - -/** Message part: modifier continuation */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 695 - -/** Message part: data */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 696 - -/** Message part: end of message */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 697 - -/** Message part: message cancelled */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 698 - -/** S->C: message acknowledgement */ -#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 699 - -/* 700 */ - -/** C->S: request channel history replay from PSYCstore. */ -#define GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY 701 - -/** S->C: result for a channel history request */ -#define GNUNET_MESSAGE_TYPE_PSYC_HISTORY_RESULT 702 - - -/** C->S: request best matching state variable from PSYCstore. */ -#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703 - -/** C->S: request state variables with a given prefix from PSYCstore. */ -#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704 - -/** S->C: result for a state request. */ -#define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT 705 - - -/******************************************************************************* - * CONVERSATION message types - ******************************************************************************/ - -/** - * Message to transmit the audio between helper and speaker/microphone library. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730 - -/** - * Client -> Server message to register a phone. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731 - -/** - * Client -> Server message to reject/hangup a call - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP 732 - -/** - * Client -> Server message to reject/hangup a call - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP 733 - -/** - * Client <- Server message to indicate a ringing phone - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL 734 - -/** - * Client <- Server message to indicate a ringing phone - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING 735 - -/** - * Client <-> Server message to suspend connection. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND 736 - -/** - * Client <-> Server message to resume connection. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME 737 - -/** - * Service -> Client message to notify that phone was picked up. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP 738 - -/** - * Client <-> Server message to send audio data. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO 739 - -/** - * Cadet: call initiation - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING 740 - -/** - * Cadet: hang up / refuse call - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP 741 - -/** - * Cadet: pick up phone (establish audio channel) - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP 742 - -/** - * Cadet: phone suspended. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND 743 - -/** - * Cadet: phone resumed. - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME 744 - -/** - * Cadet: audio data - */ -#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO 745 - - -/******************************************************************************* - * MULTICAST message types - ******************************************************************************/ - -/** - * C: client - * S: service - * T: cadet - */ - -/** - * C->S: Start the origin. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START 750 - -/** - * C->S: Join group as a member. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN 751 - -/** - * C<--S<->T: A peer wants to join the group. - * - * Unicast message to the origin or another group member. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST 752 - -/** - * C<->S<->T: Response to a join request. - * - * Unicast message from a group member to the peer wanting to join. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION 753 - -/** - * A peer wants to part the group. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST 754 - -/** - * Acknowledgement sent in response to a part request. - * - * Unicast message from a group member to the peer wanting to part. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_ACK 755 - -// FIXME: this is never used! -/** - * Group terminated. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_GROUP_END 756 - -/** - * C<->S<->T: Multicast message from the origin to all members. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 757 - -/** - * C<->S<->T: Unicast request from a group member to the origin. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST 758 - -/** - * C->S: Acknowledgement of a message or request fragment for the client. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_FRAGMENT_ACK 759 - -/** - * C<->S<->T: Replay request from a group member to another member. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST 760 - -/** - * C<->S<->T: Replay response from a group member to another member. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE 761 - -/** - * C<->S: End of replay response. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END 762 - - -/******************************************************************************* - * SECRETSHARING message types - ******************************************************************************/ - - -/** - * Establish a new session. - */ -#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE 780 - -/** - * Request the decryption of a ciphertext. - */ -#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT 781 - -/** - * The service succeeded in decrypting a ciphertext. - */ -#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE 782 - -/** - * The cryptosystem has been established. - * Contains the peer's share. - */ -#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY 783 - - -/******************************************************************************* - * PEERSTORE message types - ******************************************************************************/ - -/** - * Store request message - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE 820 - -/** - * Iteration request (see also 828, 829) - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START 821 - -/** - * Record result message - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_RECORD 822 - -/** - * Iteration end message - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END 823 - -/** - * Monitor request - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_START 824 - -/** - * Monitor sync - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_SYNC 825 - -/** - * Monitor next request - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT 826 - -/** - * Store result message - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE_RESULT 827 - -/** - * Iteration request (see also 821, 829) - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT 828 - -/** - * Iteration request (see also 821, 828) - */ -#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP 829 - -/******************************************************************************* - * SOCIAL message types - ******************************************************************************/ - -/** - * C: client - * S: service - * P: PSYC - */ - -/** S->C: result of an operation */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_RESULT_CODE 840 - -/** C->S: request to enter a place as the host */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER 841 - -/** S->C: host enter acknowledgement */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK 842 - -/** C->S: request to enter a place as a guest */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER 843 - -/** C->S: request to enter a place as a guest, using a GNS address */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME 844 - -/** S->C: guest enter acknowledgement */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK 845 - -/** P->S->C: incoming entry request from PSYC */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_ENTRY_REQUEST 846 - -/** C->S->P: decision about an entry request */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_ENTRY_DECISION 847 - -/** C->S: request to leave a place */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE 848 - -/** S->C: place leave acknowledgement */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK 849 - -/** C->S: add place to GNS zone */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE 850 - -/** C->S: add nym to GNS zone */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM 851 - -/** C->S: connect application */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT 852 - -/** C->S: detach a place from application */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH 853 - -/** S->C: notify about an existing ego */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO 854 - -/** S->C: end of ego list */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END 855 - -/** S->C: notify about an existing place */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE 856 - -/** S->C: end of place list */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END 857 - -/** C->S: set message processing flags */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET 858 - -/** C->S: clear message processing flags */ -#define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR 859 - -/******************************************************************************* - * X-VINE DHT messages - ******************************************************************************/ - -/** - * Trail setup request is received by a peer. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP 880 - -/** - * Trail to a particular peer is returned to this peer. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_RESULT 881 - -/** - * Verify if your immediate successor is still your immediate successor. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR 882 - -/** - * Notify your new immediate successor that you are its new predecessor. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR 883 - -/** - * Message which contains the immediate predecessor of requested successor - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT 884 - -/** - * Message which contains the get result. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT 885 - -/** - * Trail Rejection Message. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION 886 - -/** - * Trail Tear down Message. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN 887 - -/** - * Routing table add message. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL 888 - -/** - * Peer is storing the data in DHT. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT 890 - -/** - * Peer tries to find data in DHT. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_GET 891 - -/** - * Send back peer that considers you are its successor, a confirmation - * that you got the notify successor message. - */ -#define GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION 892 - - -/******************************************************************************* - * Whanau DHT messages - ******************************************************************************/ - - -/** - * This message contains the query for performing a random walk - */ -#define GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK 910 - -/** - * This message contains the result of a random walk - */ -#define GNUNET_MESSAGE_TYPE_WDHT_RANDOM_WALK_RESPONSE 911 - -/** - * This message contains a notification for the death of a trail - */ -#define GNUNET_MESSAGE_TYPE_WDHT_TRAIL_DESTROY 912 - -/** - * This message are used to route a query to a peer - */ -#define GNUNET_MESSAGE_TYPE_WDHT_TRAIL_ROUTE 913 - -/** - * This message contains the query to transfer successor values. - */ -#define GNUNET_MESSAGE_TYPE_WDHT_SUCCESSOR_FIND 914 - -/** - * Message which contains the get query - */ -#define GNUNET_MESSAGE_TYPE_WDHT_GET 915 - -/** - * Message which contains the "put", a response to - * #GNUNET_MESSAGE_TYPE_WDHT_SUCCESSOR_FIND. - */ -#define GNUNET_MESSAGE_TYPE_WDHT_PUT 916 - -/** - * Message which contains the get result, a response - * to #GNUNET_MESSAGE_TYPE_WDHT_GET. - */ -#define GNUNET_MESSAGE_TYPE_WDHT_GET_RESULT 917 - - -/******************************************************************************* - * RPS messages - ******************************************************************************/ - -/* P2P Messages */ - -/** - * RPS check liveliness message to check liveliness of other peer - */ -#define GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE 950 - -/** - * RPS PUSH message to push own ID to another peer - */ -#define GNUNET_MESSAGE_TYPE_RPS_PP_PUSH 951 - -/** - * RPS PULL REQUEST message to request the local view of another peer - */ -#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST 952 - -/** - * RPS PULL REPLY message which contains the view of the other peer - */ -#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY 953 - - -/* Client-Service Messages */ - - -/** - * RPS CS SEED Message for the Client to seed peers into rps - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED 954 - -#ifndef ENABLE_MALICIOUS -#define ENABLE_MALICIOUS 0 -#endif - -#if ENABLE_MALICIOUS -/** - * Turn RPS service malicious - */ -#define GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS 955 - -#endif /* ENABLE_MALICIOUS */ - -/** - * RPS client-service message to start a sub sampler - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START 956 - -/** - * RPS client-service message to stop a sub sampler - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP 957 - -/* Debugging API continues at 1130 */ - -/******************************************************************************/ - - -/************************************************** - * - * IDENTITY PROVIDER MESSAGE TYPES - */ -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE 961 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE 962 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START 963 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP 964 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT 965 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT 966 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET 967 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT 968 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET 969 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT 970 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET 971 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT 972 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START 973 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP 974 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT 975 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE 976 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE 977 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE 978 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT 979 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START 980 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP 981 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT 982 - - -/************************************************** - * - * ABD MESSAGE TYPES - */ -#define GNUNET_MESSAGE_TYPE_ABD_VERIFY 991 - -#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT 992 - -#define GNUNET_MESSAGE_TYPE_ABD_COLLECT 993 - -#define GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT 994 - -#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT 995 - -/******************************************************************************/ - - -/******************************************************************************/ -/*********************************** CADET **********************************/ -/******************************************************************************/ -/* CADET: message types 1000-1059 - * 1000-1009 Connection-level Messages - * 1010-1019 Channel-level Messages - * 1020-1029 Local Client-Service - * 1030-1049 Local Service Monitoring - * 1050-1059 Application Data - */ - -/******************************** Connection ********************************/ - -/** - * Request the creation of a connection - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 1000 - -/** - * Send origin an ACK that the connection is complete - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK 1001 - -/** - * Notify that a connection is no longer valid - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 1002 - -/** - * Request the destruction of a connection - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 1003 - -/** - * At some point, the route will spontaneously change TODO - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED 1004 - -/** - * Hop-by-hop, connection dependent ACK. - * - * @deprecated - */ -#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK 1005 - -/** - * We do not bother with ACKs for - * #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED messages, but we instead - * poll for one if we got nothing for a while and start to be worried. - * - * @deprecated - */ -#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL 1006 - -/** - * Axolotl key exchange. - */ -#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX 1007 - -/** - * Axolotl encrypted data. - */ -#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED 1008 - -/** - * Axolotl key exchange response with authentication. - */ -#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH 1009 - - -/********************************** Channel *********************************/ - -/** - * Payload data (inside an encrypted tunnel). - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA 1010 - -/** - * Confirm payload data end-to-end. - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK 1011 - -/** - * Announce connection is still alive (direction sensitive). - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE 1012 - -/** - * Ask the cadet service to create a new channel. - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN 1013 - -/** - * Ask the cadet service to destroy a channel. - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY 1014 - -/** - * Confirm the creation of a channel - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK 1015 - -/** - * Reject the creation of a channel - * - * @deprecated - */ -#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_NACK_DEPRECATED 1016 - -/*********************************** Local **********************************/ - -/** - * Payload client <-> service - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA 1020 - -/** - * Local ACK for data. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK 1021 - -/** - * Start listening on a port. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN 1022 - -/** - * Stop listening on a port. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1023 - -/** - * Ask the cadet service to create a new channel. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE 1024 - -/** - * Tell client that a channel was destroyed. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY 1025 - -/********************************** Monitor *********************************/ - - -/** - * Local information about all channels of service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_CHANNEL 1030 - -/** - * Local information of service about a specific channel. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL 1031 - -/** - * End of local information of service about channels. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL_END 1032 - -/** - * Request local information about all peers known to the service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS 1033 - -/** - * Local information about all peers known to the service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 1034 - -/** - * End of local information about all peers known to the service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END 1035 - -/** - * Request local information of service about paths to specific peer. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH 1036 - -/** - * Local information of service about a specific path. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH 1037 - -/** - * End of local information of service about a specific path. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END 1038 - -/** - * Request local information about all tunnels of service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS 1039 - -/** - * Local information about all tunnels of service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS 1040 - -/** - * End of local information about all tunnels of service. - */ -#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END 1041 - -/** - * Request to drop a message of type X to peer y. - */ -#define GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE 1042 - - -/******************************** Application *******************************/ - -/** - * Traffic (net-cat style) used by the Command Line Interface. - */ -#define GNUNET_MESSAGE_TYPE_CADET_CLI 1059 - -/******************************************************************************/ - - -/******************************************************************************/ -/************************************* NAT **********************************/ -/******************************************************************************/ - -/** - * Message to ask NAT service to register a client. - */ -#define GNUNET_MESSAGE_TYPE_NAT_REGISTER 1060 - -/** - * Message to ask NAT service to handle a STUN packet. - */ -#define GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN 1061 - -/** - * Message to ask NAT service to request connection reversal. - */ -#define GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL 1062 - -/** - * Message to from NAT service notifying us that connection reversal - * was requested by another peer. - */ -#define GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED 1063 - -/** - * Message to from NAT service notifying us that one of our - * addresses changed. - */ -#define GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 1064 - -/** - * Message to ask NAT service to notify all clients about a new global address. - */ -#define GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS 1065 - -/** - * Message to ask NAT service to request autoconfiguration. - */ -#define GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG 1067 - -/** - * Message from NAT service with the autoconfiguration result. - */ -#define GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT 1068 - - -/* 1080-1109 reserved for TMCG (Heiko Stamer, see gnunet-developers, January - * 2017) */ - - -/******************************************************************************/ -/*********************************** AUCTION ********************************/ -/******************************************************************************/ - -/** - * Client wants to create a new auction. - */ -#define GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE 1110 - -/** - * Client wants to join an existing auction. - */ -#define GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_JOIN 1111 - -/** - * Service reports the auction outcome to the client. - */ -#define GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_OUTCOME 1112 - - -/******************************************************************************/ -/********************************* RPS DEBUG ********************************/ -/******************************************************************************/ - -/** - * @brief Request updates of the view - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST 1130 - -/** - * @brief Send update of the view - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY 1131 - -/** - * @brief Cancel getting updates of the view - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL 1132 - - -/** - * @brief Request biased input stream - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST 1133 - -/** - * @brief Send peer of biased stream - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY 1134 - -/** - * @brief Cancel getting biased stream - */ -#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL 1135 - - -/******************************************************* - NEW (TNG) Transport service - ******************************************************* */ - -/** - * @brief inform transport to add an address of this peer - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS 1200 - -/** - * @brief inform transport to delete an address of this peer - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS 1201 - -/** - * @brief inform transport about an incoming message - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG 1202 - -/** - * @brief transport acknowledges processing an incoming message - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK 1203 - -/** - * @brief inform transport that a queue was setup to talk to some peer - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP 1204 - -/** - * @brief inform transport that a queue was torn down - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN 1205 - -/** - * @brief transport tells communicator it wants a queue - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE 1206 - -/** - * Response from communicator: will try to create queue. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK 1207 - -/** - * Response from communicator: address bogus, will not try to create queue. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL 1208 - -/** - * @brief transport tells communicator it wants to transmit - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG 1209 - -/** - * @brief communicator tells transports that message was sent - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK 1210 - -/** - * Message sent to indicate to the transport which address - * prefix is supported by a communicator. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR 1211 - -/** - * Tell transport that it should assist with exchanging a - * message between communicators. Usually used when - * communciators are uni-directional and need an alternative - * back-channel. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL 1212 - -/** - * Message type used between transport services when they - * internally forward communicator backchannel messages. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION 1213 - -/** - * Type of a fragment of a CORE message created by transport to adjust - * message length to a queue's MTU. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT 1214 - -/** - * Wrapper around non-fragmented CORE message used to measure RTT - * and ensure reliability. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX 1216 - -/** - * Confirmation for a #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK 1217 - -/** - * Message sent for topology discovery at transport level. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN 1218 - -/** - * Source-routed transport message based DV information gathered. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219 - -/** - * Transport signalling incoming backchannel message to a communicator. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220 - -/** - * Transport signalling incoming backchannel message to a communicator. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL 1221 - -/** - * @brief inform transport that a queue was updated - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE 1222 - -/** - * Message sent to indicate to the transport that a monitor - * wants to observe certain events. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START 1250 - -/** - * Message sent to indicate to a monitor about events. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA 1251 - -/** - * Message sent to indicate to a monitor that a one-shot - * iteration over events is done. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_END 1252 - -/** - * Message exchanged between communicators to confirm - * successful KX (and address validation). - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_KX_CONFIRMATION 1275 - -/** - * Message exchanged between communicators to exchange - * flow control (FC) limits and acknowledgemets. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_FC_LIMITS 1276 - -/** - * Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT - * to establish bandwidth preference. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST 1300 - -/** - * Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT - * to abandon bandwidth preference. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL 1301 - -/** - * Type of the 'struct RequestHelloValidationMessage' send by clients to - * TRANSPORT to trigger validation of addresses. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION 1302 - - -/** - * P2P message: transport requests confirmation that an address works. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE 1303 - -/** - * P2P message: transport proves that an address worked. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE 1304 - - -/* ************** NEW (NG) ATS Messages ************* */ -/* NOTE: it is not clear ATS will survive in TNG */ - -/** - * Type of the 'struct ExpressPreferenceMessage' send by clients to ATS - * to establish bandwidth preference. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SUGGEST 1400 - -/** - * Type of the 'struct ExpressPreferenceMessage' send by clients to ATS - * to abandon bandwidth preference. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SUGGEST_CANCEL 1401 - - -/** - * Type of the 'struct SessionAddMessage' send by transport clients to ATS - * to ask ATS to allocate resources to a session. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD 1402 - -/** - * Type of the 'struct SessionAddMessage' send by transport clients to ATS - * to inform ATS about a session where resources are consumed but allocation - * is impossible (unidirectional). - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY 1403 - -/** - * Type of the 'struct SessionUpdateMessage' send by transport clients to ATS - * to inform ATS about property changes of a session. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE 1404 - -/** - * Type of the 'struct SessionDelMessage' send by transport clients to ATS - * to tell ATS that a session is no longer available. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_DEL 1405 - -/** - * Type of the 'struct SessionAllocationMessage' send by ATS to the - * transport to tell it about resources to allocate to the session. - */ -#define GNUNET_MESSAGE_TYPE_ATS_SESSION_ALLOCATION 1406 - - -/** - * TCP communicator rekey message. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY 1450 - -/** - * TCP communicator payload box - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX 1451 - -/** - * TCP communicator end of stream. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH 1452 - -/** - * TCP communicator confirmation ack. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK 1453 - -/** - * UDP KX acknowledgement. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK 1460 - -/** - * UDP communicator padding. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD 1461 - -/** - * UDP Rekey. - */ -#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY 1462 - -/** - * Next available: 1500 - */ -#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 - -#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT 1501 - - -/*********************************************************************************/ -/********************************** MESSENGER **********************************/ -/*********************************************************************************/ -/* MESSENGER: message types 1600-1629 - * 1600-1609 Connection-level Messages - * 1610-1619 Room-level Messages - */ - -/********************************* Connection **********************************/ - -#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE 1600 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY 1601 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID 1602 - -/************************************ Room *************************************/ - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN 1610 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY 1611 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE 1612 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE 1614 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE 1615 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE 1616 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC 1617 - -#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_LINK 1618 - -/*********************************************************************************/ - -/*********************************************************************************/ -/********************************** Cmd Testing **********************************/ -/*********************************************************************************/ - -/** - * The initialization message towards gnunet-cmds-helper - */ -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT 1700 - -/** - * The reply message from gnunet-cmds-helper - */ -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY 1701 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED 1702 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED 1703 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED 1704 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED 1705 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1706 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED 1707 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACH 1708 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE 1709 - -#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED 1710 - -/*********************************************************************************/ - -/*********************************************************************************/ -/********************************** NAMESTORE (cont.) **************************/ -/*********************************************************************************/ -/* NAMESTORE: message types 1750-1800 - */ - -/** - * Message type for start of record edit with advisory lock - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT 1750 - -/** - * Return record set to edit with previous editor hint/advisory lock - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE 1751 - -/** - * Message type for cancellation/reset of editor hint/advisory lock - */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752 - -/** - * Type used to match 'all' message types. - */ -#define GNUNET_MESSAGE_TYPE_ALL 65535 - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_PROTOCOLS_H */ -#endif - -/** @} */ /* end of group protocols */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_protocols.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_scheduler_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_scheduler_lib.h @@ -1,938 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2009-2016 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * API to schedule computations using continuation passing style - * - * @defgroup scheduler Scheduler library - * Event loop (scheduler) - * - * Schedule computations using continuation passing style. - * - * @{ - */ - -#ifndef GNUNET_SCHEDULER_LIB_H -#define GNUNET_SCHEDULER_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/** - * Opaque reference to a task. - */ -struct GNUNET_SCHEDULER_Task; - -/** - * Reasons why the schedule may have triggered - * the task now. - */ -enum GNUNET_SCHEDULER_Reason -{ - /** - * This task is not ready. - */ - GNUNET_SCHEDULER_REASON_NONE = 0, - - /** - * This is the very first task run during startup. - */ - GNUNET_SCHEDULER_REASON_STARTUP = 1, - - /** - * We are shutting down and are running all shutdown-related tasks. - */ - GNUNET_SCHEDULER_REASON_SHUTDOWN = 2, - - /** - * The specified timeout has expired. - * (also set if the delay given was 0). - */ - GNUNET_SCHEDULER_REASON_TIMEOUT = 4, - - /** - * The reading socket is ready. - */ - GNUNET_SCHEDULER_REASON_READ_READY = 8, - - /** - * The writing socket is ready. - */ - GNUNET_SCHEDULER_REASON_WRITE_READY = 16, - - /** - * The prerequisite task is done. - */ - GNUNET_SCHEDULER_REASON_PREREQ_DONE = 32 -}; - - - -#include "gnunet_time_lib.h" -#include "gnunet_network_lib.h" - - -/** - * Possible events on FDs, used as a bitmask. - * Modelled after GPollFD. - */ -enum GNUNET_SCHEDULER_EventType -{ - /** - * No event (useful for timeout). - */ - GNUNET_SCHEDULER_ET_NONE = 0, - - /** - * Data available for reading. - */ - GNUNET_SCHEDULER_ET_IN = 1, - - /** - * Buffer available for writing. - */ - GNUNET_SCHEDULER_ET_OUT = 2, - - /** - * - */ - GNUNET_SCHEDULER_ET_HUP = 4, - - /** - * - */ - GNUNET_SCHEDULER_ET_ERR = 8, - - /** - * - */ - GNUNET_SCHEDULER_ET_PRI = 16, - - /** - * - */ - GNUNET_SCHEDULER_ET_NVAL = 32 -}; - - -/** - * Information about an event relating to a file descriptor/socket. - */ -struct GNUNET_SCHEDULER_FdInfo -{ - /** - * GNUnet network socket the event is about, matches @a sock, - * NULL if this is about a file handle or if no network - * handle was given to the scheduler originally. - */ - const struct GNUNET_NETWORK_Handle *fd; - - /** - * GNUnet file handle the event is about, matches @a sock, - * NULL if this is about a network socket or if no network - * handle was given to the scheduler originally. - */ - const struct GNUNET_DISK_FileHandle *fh; - - /** - * Type of the event that was generated related to @e sock. - */ - enum GNUNET_SCHEDULER_EventType et; - - /** - * Underlying OS handle the event was about. - */ - int sock; -}; - - -/** - * Context information passed to each scheduler task. - */ -struct GNUNET_SCHEDULER_TaskContext -{ - /** - * Reason why the task is run now - */ - enum GNUNET_SCHEDULER_Reason reason; - - /** - * Length of the following array. - */ - unsigned int fds_len; - - /** - * Array of length @e fds_len with information about ready FDs. - * Note that we use the same format regardless of the internal - * event loop that was used. The given array should only contain - * information about file descriptors relevant to the current task. - */ - const struct GNUNET_SCHEDULER_FdInfo *fds; - - /** - * Set of file descriptors ready for reading; note that additional - * bits may be set that were not in the original request. - * @deprecated - */ - const struct GNUNET_NETWORK_FDSet *read_ready; - - /** - * Set of file descriptors ready for writing; note that additional - * bits may be set that were not in the original request. - * @deprecated - */ - const struct GNUNET_NETWORK_FDSet *write_ready; -}; - - -/** - * Function used by event-loop implementations to signal the scheduler - * that a particular @a task is ready due to an event specified in the - * et field of @a fdi. - * - * This function will then queue the task to notify the application - * that the task is ready (with the respective priority). - * - * @param task the task that is ready - * @param fdi information about the related FD - */ -void -GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, - struct GNUNET_SCHEDULER_FdInfo *fdi); - - -/** - * Handle to the scheduler's state to be used by the driver. - */ -struct GNUNET_SCHEDULER_Handle; - - -/** - * Function called by external event loop implementations to tell the - * scheduler to run some of the tasks that are ready. Must be called - * only after #GNUNET_SCHEDULER_driver_init has been called and before - * #GNUNET_SCHEDULER_driver_done is called. - * This function may return even though there are tasks left to run - * just to give other tasks a chance as well. If we return #GNUNET_YES, - * the event loop implementation should call this function again as - * soon as possible, while if we return #GNUNET_NO it must block until - * either the operating system has more work (the scheduler has no more - * work to do right now) or the timeout set by the scheduler (using the - * set_wakeup callback) is reached. - * - * @param sh scheduler handle that was returned by - * #GNUNET_SCHEDULER_driver_init - * @return #GNUNET_YES if there are more tasks that are ready, - * and thus we would like to run more (yield to avoid - * blocking other activities for too long) #GNUNET_NO - * if we are done running tasks (yield to block) - */ -int -GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh); - - -/** - * API an external event loop has to implement for - * #GNUNET_SCHEDULER_driver_init. - */ -struct GNUNET_SCHEDULER_Driver -{ - /** - * Closure to pass to the functions in this struct. - */ - void *cls; - - /** - * Add a @a task to be run if the conditions specified in the - * et field of the given @a fdi are satisfied. The et field will - * be cleared after this call and the driver is expected to set - * the type of the actual event before passing @a fdi to - * #GNUNET_SCHEDULER_task_ready. - * - * @param cls closure - * @param task task to add - * @param fdi conditions to watch for - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - * (i.e. @a fdi too high or invalid) - */ - int - (*add)(void *cls, - struct GNUNET_SCHEDULER_Task *task, - struct GNUNET_SCHEDULER_FdInfo *fdi); - - /** - * Delete a @a task from the set of tasks to be run. A task may - * comprise multiple FdInfo entries previously added with the add - * function. The driver is expected to delete them all. - * - * @param cls closure - * @param task task to delete - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - * (i.e. @a task does not match prior @e add call) - */ - int - (*del)(void *cls, - struct GNUNET_SCHEDULER_Task *task); - - /** - * Set time at which we definitively want to get a wakeup call. - * - * @param cls closure - * @param dt time when we want to wake up next - */ - void - (*set_wakeup)(void *cls, - struct GNUNET_TIME_Absolute dt); -}; - - -/** - * Signature of the main function of a task. - * - * @param cls closure - */ -typedef void -(*GNUNET_SCHEDULER_TaskCallback) (void *cls); - - -/** - * Function called by external event loop implementations to initialize - * the scheduler. An external implementation has to provide @a driver - * which contains callbacks for the scheduler (see definition of struct - * #GNUNET_SCHEDULER_Driver). The callbacks are used to instruct the - * external implementation to watch for events. If it detects any of - * those events it is expected to call #GNUNET_SCHEDULER_do_work to let - * the scheduler handle it. If an event is related to a specific task - * (e.g. the scheduler gave instructions to watch a file descriptor), - * the external implementation is expected to mark that task ready - * before by calling #GNUNET_SCHEDULER_task_ready. - * - * This function has to be called before any tasks are scheduled and - * before GNUNET_SCHEDULER_do_work is called for the first time. It - * allocates resources that have to be freed again by calling - * #GNUNET_SCHEDULER_driver_done. - * - * This function installs the same signal handlers as - * #GNUNET_SCHEDULER_run. This means SIGTERM (and other similar signals) - * will induce a call to #GNUNET_SCHEDULER_shutdown during the next - * call to #GNUNET_SCHEDULER_do_work. As a result, SIGTERM causes all - * active tasks to be scheduled with reason - * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added afterwards - * will execute normally!). Note that any particular signal will only - * shut down one scheduler; applications should always only create a - * single scheduler. - * - * @param driver to use for the event loop - * @return handle to be passed to #GNUNET_SCHEDULER_do_work and - * #GNUNET_SCHEDULER_driver_done - */ -struct GNUNET_SCHEDULER_Handle * -GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver); - - -/** - * Counter-part of #GNUNET_SCHEDULER_driver_init. Has to be called - * by external event loop implementations after the scheduler has - * shut down. This is the case if both of the following conditions - * are met: - * - * - all tasks the scheduler has added through the driver's add - * callback have been removed again through the driver's del - * callback - * - the timeout the scheduler has set through the driver's - * add_wakeup callback is FOREVER - * - * @param sh the handle returned by #GNUNET_SCHEDULER_driver_init - */ -void -GNUNET_SCHEDULER_driver_done (struct GNUNET_SCHEDULER_Handle *sh); - - -/** - * Obtain the driver for using select() as the event loop. - * - * @return NULL on error - */ -struct GNUNET_SCHEDULER_Driver * -GNUNET_SCHEDULER_driver_select (void); - - -/** - * Signature of the select function used by the scheduler. - * #GNUNET_NETWORK_socket_select matches it. - * - * @param cls closure - * @param rfds set of sockets to be checked for readability - * @param wfds set of sockets to be checked for writability - * @param efds set of sockets to be checked for exceptions - * @param timeout relative value when to return - * @return number of selected sockets, #GNUNET_SYSERR on error - */ -typedef int -(*GNUNET_SCHEDULER_select) (void *cls, - struct GNUNET_NETWORK_FDSet *rfds, - struct GNUNET_NETWORK_FDSet *wfds, - struct GNUNET_NETWORK_FDSet *efds, - struct GNUNET_TIME_Relative timeout); - - -/** - * Initialize and run scheduler. This function will return when all - * tasks have completed. On systems with signals, receiving a SIGTERM - * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown - * to be run after the active task is complete. As a result, SIGTERM - * causes all shutdown tasks to be scheduled with reason - * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added - * afterwards will execute normally!). Note that any particular - * signal will only shut down one scheduler; applications should - * always only create a single scheduler. - * - * @param task task to run first (and immediately) - * @param task_cls closure of @a task - */ -void -GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - -/** - * Initialize and run scheduler. This function will return when all - * tasks have completed. When @ install_signals is GNUNET_YES, then - * this function behaves in the same was as GNUNET_SCHEDULER_run does. - * If @ install_signals is GNUNET_NO then no signal handlers are - * installed. - * - * @param install_signals whether to install signals (GNUNET_YES/NO) - * @param task task to run first (and immediately) - * @param task_cls closure of @a task - */ -void -GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Request the shutdown of a scheduler. Marks all tasks - * awaiting shutdown as ready. Note that tasks - * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call - * will be delayed until the next shutdown signal. - */ -void -GNUNET_SCHEDULER_shutdown (void); - - -/** - * Get information about the current load of this scheduler. Use this - * function to determine if an elective task should be added or simply - * dropped (if the decision should be made based on the number of - * tasks ready to run). - * - * @param p priority-level to query, use KEEP to query the level - * of the current task, use COUNT to get the sum over - * all priority levels - * @return number of tasks pending right now - */ -unsigned int -GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p); - - -/** - * Obtain the reasoning why the current task was - * started. - * - * @return task context with information why the current task is run - */ -const struct GNUNET_SCHEDULER_TaskContext * -GNUNET_SCHEDULER_get_task_context (void); - - -/** - * Cancel the task with the specified identifier. - * The task must not yet have run. Only allowed to be called as long as the - * scheduler is running, that is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param task id of the task to cancel - * @return original closure of the task - */ -void * -GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task); - - -/** - * Continue the current execution with the given function. This is - * similar to the other "add" functions except that there is no delay - * and the reason code can be specified. - * - * @param task main function of the task - * @param task_cls closure for @a task - * @param reason reason for task invocation - * @param priority priority to use for the task - */ -void -GNUNET_SCHEDULER_add_with_reason_and_priority ( - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls, - enum GNUNET_SCHEDULER_Reason reason, - enum GNUNET_SCHEDULER_Priority priority); - - -/** - * Schedule a new task to be run with a specified priority. - * - * @param prio how important is the new task? - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run as soon as possible. Note that this - * does not guarantee that this will be the next task that is being - * run, as other tasks with higher priority (or that are already ready - * to run) might get to run first. Just as with delays, clients must - * not rely on any particular order of execution between tasks - * scheduled concurrently. - * - * The task will be run with the DEFAULT priority. - * - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run on shutdown, that is when a CTRL-C - * signal is received, or when #GNUNET_SCHEDULER_shutdown() is being - * invoked. - * - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run as soon as possible with the - * (transitive) ignore-shutdown flag either explicitly set or - * explicitly enabled. This task (and all tasks created from it, - * other than by another call to this function) will either count or - * not count for the 'lifeness' of the process. This API is only - * useful in a few special cases. - * - * @param lifeness #GNUNET_YES if the task counts for lifeness, #GNUNET_NO if not. - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay. The task - * will be scheduled for execution once the delay has expired. It - * will be run with the DEFAULT priority. - * - * @param delay with which the operation should be run - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run at the specified time. The task - * will be scheduled for execution once specified time has been - * reached. It will be run with the DEFAULT priority. - * - * @param at time at which this operation should run - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay. The task - * will be scheduled for execution once the delay has expired. - * - * @param delay when should this operation time out? - * @param priority priority to use for the task - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, - enum GNUNET_SCHEDULER_Priority - priority, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run at the specified time. The task - * will be scheduled for execution at time @a at. - * - * @param at time when the operation should run - * @param priority priority to use for the task - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, - enum GNUNET_SCHEDULER_Priority priority, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready for reading. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. It will be run with the DEFAULT priority. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param rfd read file-descriptor - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, - struct GNUNET_NETWORK_Handle *rfd, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified priority and to be - * run after the specified delay or when the specified file descriptor - * is ready for reading. The delay can be used as a timeout on the - * socket being ready. The task will be scheduled for execution once - * either the delay has expired or the socket operation is ready. It - * will be run with the DEFAULT priority. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param priority priority to use for the task - * @param rfd read file-descriptor - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, - enum GNUNET_SCHEDULER_Priority - priority, - struct GNUNET_NETWORK_Handle *rfd, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready for writing. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. It will be run with the priority of - * the calling task. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param wfd write file-descriptor - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, - struct GNUNET_NETWORK_Handle *wfd, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param priority priority of the task - * @param fd file-descriptor - * @param on_read whether to poll the file-descriptor for readability - * @param on_write whether to poll the file-descriptor for writability - * @param task main function of the task - * @param task_cls closure of task - * @return unique task identifier for the job - * only valid until "task" is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, - enum GNUNET_SCHEDULER_Priority priority, - struct GNUNET_NETWORK_Handle *fd, - int on_read, - int on_write, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready for reading. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. It will be run with the DEFAULT priority. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param rfd read file-descriptor - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, - const struct GNUNET_DISK_FileHandle *rfd, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready for writing. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. It will be run with the DEFAULT priority. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param wfd write file-descriptor - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, - const struct GNUNET_DISK_FileHandle *wfd, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when the - * specified file descriptor is ready. The delay can be - * used as a timeout on the socket being ready. The task will be - * scheduled for execution once either the delay has expired or the - * socket operation is ready. - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param delay when should this operation time out? - * @param priority priority of the task - * @param fd file-descriptor - * @param on_read whether to poll the file-descriptor for readability - * @param on_write whether to poll the file-descriptor for writability - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, - enum GNUNET_SCHEDULER_Priority - priority, - const struct - GNUNET_DISK_FileHandle *fd, - int on_read, - int on_write, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - - -/** - * Schedule a new task to be run with a specified delay or when any of - * the specified file descriptor sets is ready. The delay can be used - * as a timeout on the socket(s) being ready. The task will be - * scheduled for execution once either the delay has expired or any of - * the socket operations is ready. This is the most general - * function of the "add" family. Note that the "prerequisite_task" - * must be satisfied in addition to any of the other conditions. In - * other words, the task will be started when - * <code> - * (prerequisite-run) - * && (delay-ready - * || any-rs-ready - * || any-ws-ready) ) - * </code> - * Only allowed to be called as long as the scheduler is running, that - * is one of the following conditions is met: - * - * - #GNUNET_SCHEDULER_run has been called and has not returned yet - * - #GNUNET_SCHEDULER_driver_init has been run and - * #GNUNET_SCHEDULER_driver_done has not been called yet - * - * @param prio how important is this task? - * @param delay how long should we wait? - * @param rs set of file descriptors we want to read (can be NULL) - * @param ws set of file descriptors we want to write (can be NULL) - * @param task main function of the task - * @param task_cls closure of @a task - * @return unique task identifier for the job - * only valid until @a task is started! - */ -struct GNUNET_SCHEDULER_Task * -GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, - struct GNUNET_TIME_Relative delay, - const struct GNUNET_NETWORK_FDSet *rs, - const struct GNUNET_NETWORK_FDSet *ws, - GNUNET_SCHEDULER_TaskCallback task, - void *task_cls); - -/** - * Sets the select function to use in the scheduler (scheduler_select). - * - * @param new_select new select function to use (NULL to reset to default) - * @param new_select_cls closure for @a new_select - */ -void -GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select, - void *new_select_cls); - - -/** - * Change the async scope for the currently executing task and (transitively) - * for all tasks scheduled by the current task after calling this function. - * Nested tasks can begin their own nested async scope. - * - * Once the current task is finished, the async scope ID is reset to - * its previous value. - * - * Must only be called from a running task. - * - * @param aid the asynchronous scope id to enter - */ -void -GNUNET_SCHEDULER_begin_async_scope (struct GNUNET_AsyncScopeId *aid); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */ /* end of group scheduler */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_service_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_service_lib.h @@ -1,537 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009-2013, 2016, 2017 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @addtogroup networking - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to starting services - * - * @defgroup service Service library - * Start service processes. - * - * @see [Documentation](https://gnunet.org/developer-handbook-util-services) - * - * @{ - */ - -#ifndef GNUNET_SERVICE_LIB_H -#define GNUNET_SERVICE_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -#include "gnunet_util_lib.h" -#include "gnunet_configuration_lib.h" - - -/** - * Options for the service (bitmask). - */ -enum GNUNET_SERVICE_Options -{ - /** - * Use defaults. Terminates all client connections and the listen - * sockets immediately upon receiving the shutdown signal. - */ - GNUNET_SERVICE_OPTION_NONE = 0, - - /** - * Do not trigger server shutdown on signal at all; instead, allow - * for the user to terminate the server explicitly when needed - * by calling #GNUNET_SERVICE_shutdown(). - */ - GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1, - - /** - * Trigger a SOFT server shutdown on signals, allowing active - * non-monitor clients to complete their transactions. - */ - GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2, - - /** - * Bitmask over the shutdown options. - */ - GNUNET_SERVICE_OPTION_SHUTDOWN_BITMASK = 3, - - /** - * Instead of listening on lsocks passed by the parent, - * close them *after* opening our own listen socket(s). - */ - GNUNET_SERVICE_OPTION_CLOSE_LSOCKS = 4 -}; - - -/* **************** NEW SERVICE API ********************** */ - -/** - * Handle to a service. - */ -struct GNUNET_SERVICE_Handle; - - -/** - * Handle to a client that is connected to a service. - */ -struct GNUNET_SERVICE_Client; - - -/** - * Callback to initialize a service, called exactly once when the service is run. - * - * @param cls closure passed to #GNUNET_SERVICE_MAIN - * @param cfg configuration to use for this service - * @param sh handle to the newly create service - */ -typedef void -(*GNUNET_SERVICE_InitCallback)(void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SERVICE_Handle *sh); - - -/** - * Callback to be called when a client connects to the service. - * - * @param cls closure for the service - * @param c the new client that connected to the service - * @param mq the message queue used to send messages to the client - * @return the client-specific (`internal') closure - */ -typedef void * -(*GNUNET_SERVICE_ConnectHandler)(void *cls, - struct GNUNET_SERVICE_Client *c, - struct GNUNET_MQ_Handle *mq); - - -/** - * Callback to be called when a client disconnected from the service - * - * @param cls closure for the service - * @param c the client that disconnected - * @param internal_cls the client-specific (`internal') closure - */ -typedef void -(*GNUNET_SERVICE_DisconnectHandler)(void *cls, - struct GNUNET_SERVICE_Client *c, - void *internal_cls); - - -/** - * Low-level function to start a service if the scheduler - * is already running. Should only be used directly in - * special cases. - * - * The function will launch the service with the name @a service_name - * using the @a service_options to configure its shutdown - * behavior. When clients connect or disconnect, the respective - * @a connect_cb or @a disconnect_cb functions will be called. For - * messages received from the clients, the respective @a handlers will - * be invoked; for the closure of the handlers we use the return value - * from the @a connect_cb invocation of the respective client. - * - * Each handler MUST call #GNUNET_SERVICE_client_continue() after each - * message to receive further messages from this client. If - * #GNUNET_SERVICE_client_continue() is not called within a short - * time, a warning will be logged. If delays are expected, services - * should call #GNUNET_SERVICE_client_disable_continue_warning() to - * disable the warning. - * - * Clients sending invalid messages (based on @a handlers) will be - * dropped. Additionally, clients can be dropped at any time using - * #GNUNET_SERVICE_client_drop(). - * - * The service must be stopped using #GNUNET_SERVICE_stop(). - * - * @param service_name name of the service to run - * @param cfg configuration to use - * @param connect_cb function to call whenever a client connects - * @param disconnect_cb function to call whenever a client disconnects - * @param cls closure argument for @a connect_cb and @a disconnect_cb - * @param handlers NULL-terminated array of message handlers for the service, - * the closure will be set to the value returned by - * the @a connect_cb for the respective connection - * @return NULL on error - */ -struct GNUNET_SERVICE_Handle * -GNUNET_SERVICE_start (const char *service_name, - const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_SERVICE_ConnectHandler connect_cb, - GNUNET_SERVICE_DisconnectHandler disconnect_cb, - void *cls, - const struct GNUNET_MQ_MessageHandler *handlers); - - -/** - * Stops a service that was started with #GNUNET_SERVICE_start(). - * - * @param srv service to stop - */ -void -GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); - -/** - * Creates the "main" function for a GNUnet service. You - * should almost always use the #GNUNET_SERVICE_MAIN macro - * instead of calling this function directly (except - * for ARM, which should call this function directly). - * - * The function will launch the service with the name @a service_name - * using the @a service_options to configure its shutdown - * behavior. Once the service is ready, the @a init_cb will be called - * for service-specific initialization. @a init_cb will be given the - * service handler which can be used to control the service's - * availability. When clients connect or disconnect, the respective - * @a connect_cb or @a disconnect_cb functions will be called. For - * messages received from the clients, the respective @a handlers will - * be invoked; for the closure of the handlers we use the return value - * from the @a connect_cb invocation of the respective client. - * - * Each handler MUST call #GNUNET_SERVICE_client_continue() after each - * message to receive further messages from this client. If - * #GNUNET_SERVICE_client_continue() is not called within a short - * time, a warning will be logged. If delays are expected, services - * should call #GNUNET_SERVICE_client_disable_continue_warning() to - * disable the warning. - * - * Clients sending invalid messages (based on @a handlers) will be - * dropped. Additionally, clients can be dropped at any time using - * #GNUNET_SERVICE_client_drop(). - * - * @param argc number of command-line arguments in @a argv - * @param argv array of command-line arguments - * @param service_name name of the service to run - * @param options options controlling shutdown of the service - * @param service_init_cb function to call once the service is ready - * @param connect_cb function to call whenever a client connects - * @param disconnect_cb function to call whenever a client disconnects - * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb - * @param handlers NULL-terminated array of message handlers for the service, - * the closure will be set to the value returned by - * the @a connect_cb for the respective connection - * @return 0 on success, non-zero on error - */ -int -GNUNET_SERVICE_run_ (int argc, - char *const *argv, - const char *service_name, - enum GNUNET_SERVICE_Options options, - GNUNET_SERVICE_InitCallback service_init_cb, - GNUNET_SERVICE_ConnectHandler connect_cb, - GNUNET_SERVICE_DisconnectHandler disconnect_cb, - void *cls, - const struct GNUNET_MQ_MessageHandler *handlers); - - -/** - * Registers the GNUnet service to be scheduled as part of a monilithic - * libgnunet. - * You should almost always use the #GNUNET_SERVICE_MAIN macro - * instead of calling this function directly. - * - * The function will launch the service with the name @a service_name - * using the @a service_options to configure its shutdown - * behavior. Once the service is ready, the @a init_cb will be called - * for service-specific initialization. @a init_cb will be given the - * service handler which can be used to control the service's - * availability. When clients connect or disconnect, the respective - * @a connect_cb or @a disconnect_cb functions will be called. For - * messages received from the clients, the respective @a handlers will - * be invoked; for the closure of the handlers we use the return value - * from the @a connect_cb invocation of the respective client. - * - * Each handler MUST call #GNUNET_SERVICE_client_continue() after each - * message to receive further messages from this client. If - * #GNUNET_SERVICE_client_continue() is not called within a short - * time, a warning will be logged. If delays are expected, services - * should call #GNUNET_SERVICE_client_disable_continue_warning() to - * disable the warning. - * - * Clients sending invalid messages (based on @a handlers) will be - * dropped. Additionally, clients can be dropped at any time using - * #GNUNET_SERVICE_client_drop(). - * - * @param service_name name of the service to run - * @param options options controlling shutdown of the service - * @param service_init_cb function to call once the service is ready - * @param connect_cb function to call whenever a client connects - * @param disconnect_cb function to call whenever a client disconnects - * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb - * @param handlers NULL-terminated array of message handlers for the service, - * the closure will be set to the value returned by - * the @a connect_cb for the respective connection - * @return 0 on success, non-zero on error - */ -int -GNUNET_SERVICE_register_ ( - const char *service_name, - enum GNUNET_SERVICE_Options options, - GNUNET_SERVICE_InitCallback service_init_cb, - GNUNET_SERVICE_ConnectHandler connect_cb, - GNUNET_SERVICE_DisconnectHandler disconnect_cb, - void *cls, - const struct GNUNET_MQ_MessageHandler *handlers); - - -/** - * Creates the "main" function for a GNUnet service. You - * MUST use this macro to define GNUnet services (except - * for ARM, which MUST NOT use the macro). The reason is - * the GNUnet-as-a-library project, where we will not define - * a main function anywhere but in ARM. - * - * The macro will launch the service with the name @a service_name - * using the @a service_options to configure its shutdown - * behavior. Once the service is ready, the @a init_cb will be called - * for service-specific initialization. @a init_cb will be given the - * service handler which can be used to control the service's - * availability. When clients connect or disconnect, the respective - * @a connect_cb or @a disconnect_cb functions will be called. For - * messages received from the clients, the respective @a handlers will - * be invoked; for the closure of the handlers we use the return value - * from the @a connect_cb invocation of the respective client. - * - * Each handler MUST call #GNUNET_SERVICE_client_continue() after each - * message to receive further messages from this client. If - * #GNUNET_SERVICE_client_continue() is not called within a short - * time, a warning will be logged. If delays are expected, services - * should call #GNUNET_SERVICE_client_disable_continue_warning() to - * disable the warning. - * - * Clients sending invalid messages (based on @a handlers) will be - * dropped. Additionally, clients can be dropped at any time using - * #GNUNET_SERVICE_client_drop(). - * - * @param service_name name of the service to run - * @param service_options options controlling shutdown of the service - * @param init_cb function to call once the service is ready - * @param connect_cb function to call whenever a client connects - * @param disconnect_cb function to call whenever a client disconnects - * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb - * @param ... array of message handlers for the service, terminated - * by #GNUNET_MQ_handler_end(); - * the closure will be set to the value returned by - * the @a connect_cb for the respective connection - * @return 0 on success, non-zero on error - * - * Sample invocation: - * <code> - * GNUNET_SERVICE_MAIN - * ("resolver", - * GNUNET_SERVICE_OPTION_NONE, - * &init_cb, - * &connect_cb, - * &disconnect_cb, - * closure_for_cb, - * GNUNET_MQ_hd_var_size (get, - * GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST, - * struct GNUNET_RESOLVER_GetMessage, - * NULL), - * GNUNET_MQ_handler_end ()); - * </code> - */ -#ifndef HAVE_GNUNET_MONOLITH -#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ - disconnect_cb, cls, ...) \ - int \ - main (int argc, \ - char *const *argv) \ - { \ - struct GNUNET_MQ_MessageHandler mh[] = { \ - __VA_ARGS__ \ - }; \ - return GNUNET_SERVICE_run_ (argc, \ - argv, \ - service_name, \ - service_options, \ - init_cb, \ - connect_cb, \ - disconnect_cb, \ - cls, \ - mh); \ - } -#else -#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ - disconnect_cb, cls, ...) \ - static int __attribute__ ((constructor)) \ - init (void) \ - { \ - struct GNUNET_MQ_MessageHandler mh[] = { \ - __VA_ARGS__ \ - }; \ - return GNUNET_SERVICE_register_ (service_name, \ - service_options, \ - init_cb, \ - connect_cb, \ - disconnect_cb, \ - cls, \ - mh); \ - } -#endif - -/** - * Run the mainloop in a monolithic libgnunet. - * Must be called such that services are actually launched. - */ -void -GNUNET_SERVICE_main (int argc, - char *const *argv, - struct GNUNET_CONFIGURATION_Handle *cfg); - -/** - * Suspend accepting connections from the listen socket temporarily. - * Resume activity using #GNUNET_SERVICE_resume. - * - * @param sh service to stop accepting connections. - */ -void -GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh); - - -/** - * Resume accepting connections from the listen socket. - * - * @param sh service to resume accepting connections. - */ -void -GNUNET_SERVICE_resume (struct GNUNET_SERVICE_Handle *sh); - - -/** - * Continue receiving further messages from the given client. - * Must be called after each message received. - * - * @param c the client to continue receiving from - */ -void -GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c); - - -/** - * Obtain the message queue of @a c. Convenience function. - * - * @param c the client to continue receiving from - * @return the message queue of @a c - */ -struct GNUNET_MQ_Handle * -GNUNET_SERVICE_client_get_mq (struct GNUNET_SERVICE_Client *c); - - -/** - * Disable the warning the server issues if a message is not - * acknowledged in a timely fashion. Use this call if a client is - * intentionally delayed for a while. Only applies to the current - * message. - * - * @param c client for which to disable the warning - */ -void -GNUNET_SERVICE_client_disable_continue_warning (struct - GNUNET_SERVICE_Client *c); - - -/** - * Ask the server to disconnect from the given client. This is the - * same as returning #GNUNET_SYSERR within the check procedure when - * handling a message, except that it allows dropping of a client even - * when not handling a message from that client. The `disconnect_cb` - * will be called on @a c even if the application closes the connection - * using this function. - * - * This function should be called (outside of util's internal logic) - * if (and usually only if) the client has violated the - * protocol. Otherwise, we should leave it to the client to disconnect - * from the service. - * - * @param c client to disconnect now - */ -void -GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c); - - -/** - * Explicitly stops the service. - * - * @param sh server to shutdown - */ -void -GNUNET_SERVICE_shutdown (struct GNUNET_SERVICE_Handle *sh); - - -/** - * Set the 'monitor' flag on this client. Clients which have been - * marked as 'monitors' won't prevent the server from shutting down - * once #GNUNET_SERVICE_stop_listening() has been invoked. The idea is - * that for "normal" clients we likely want to allow them to process - * their requests; however, monitor-clients are likely to 'never' - * disconnect during shutdown and thus will not be considered when - * determining if the server should continue to exist after - * shutdown has been triggered. - * - * @param c client to mark as a monitor - */ -void -GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c); - - -/** - * Set the persist option on this client. Indicates that the - * underlying socket or fd should never really be closed. Used for - * indicating process death. - * - * @param c client to persist the socket (never to be closed) - */ -void -GNUNET_SERVICE_client_persist (struct GNUNET_SERVICE_Client *c); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_SERVICE_LIB_H */ -#endif - -/** @} */ /* end of group service */ - -/** @} */ /* end of group addition to networking*/ - -/** @} */ /* end of group addition to libgnunetutil */ - -/* end of gnunet_service_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_signal_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_signal_lib.h @@ -1,118 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to signals - * - * @defgroup signal Signal library - * Manage signal handlers. - * @{ - */ - -#ifndef GNUNET_SIGNAL_LIB_H -#define GNUNET_SIGNAL_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -/** - * Context created when a signal handler is installed; - * can be used to restore it to the previous state later. - */ -struct GNUNET_SIGNAL_Context; - - -/** - * A signal handler. Since different OSes have different signatures - * for their handlers, the API only gives the most restrictive - * signature -- no arguments, no return value. Note that this will - * work even if the OS expects a function with arguments. However, - * the implementation must guarantee that this handler is not called - * for signals other than the one that it has been registered for. - */ -typedef void -(*GNUNET_SIGNAL_Handler) (void); - - -/** - * Install a signal handler that will be run if the - * given signal is received. - * - * @param signal the number of the signal - * @param handler the function to call - * @return context that can be used to restore, NULL on error - */ -struct GNUNET_SIGNAL_Context * -GNUNET_SIGNAL_handler_install (int signal, - GNUNET_SIGNAL_Handler handler); - - -/** - * Uninstall a previously installed signal handler. - * - * @param ctx context that was returned when the - * signal handler was installed - */ -void -GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx); - - -/** - * Raise the given signal by calling the installed signal handlers. This will - * not use the @em raise() system call but only calls the handlers registered - * through GNUNET_SIGNAL_handler_install(). - * - * @param sig the signal to raise - */ -void -GNUNET_SIGNAL_raise (const int sig); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_SIGNAL_LIB_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_signal_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_sq_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_sq_lib.h @@ -1,571 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2017 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ -/** - * @file include/gnunet_sq_lib.h - * @brief helper functions for Sqlite3 DB interactions - * @author Christian Grothoff - */ -#ifndef GNUNET_SQ_LIB_H -#define GNUNET_SQ_LIB_H - - -#include <sqlite3.h> -#include "gnunet_util_lib.h" - - -/** - * Function called to convert input argument into SQL parameters. - * - * @param cls closure - * @param data pointer to input argument - * @param data_len number of bytes in @a data (if applicable) - * @param stmt sqlite statement to bind parameters for - * @param off offset of the argument to bind in @a stmt, numbered from 1, - * so immediately suitable for passing to `sqlite3_bind`-functions. - * @return #GNUNET_SYSERR on error, #GNUNET_OK on success - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_SQ_QueryConverter)(void *cls, - const void *data, - size_t data_len, - sqlite3_stmt *stmt, - unsigned int off); - - -/** - * @brief Description of a DB query parameter. - */ -struct GNUNET_SQ_QueryParam -{ - /** - * Function for how to handle this type of entry. - */ - GNUNET_SQ_QueryConverter conv; - - /** - * Closure for @e conv. - */ - void *conv_cls; - - /** - * Data or NULL. - */ - const void *data; - - /** - * Size of @e data - */ - size_t size; - - /** - * Number of parameters eaten by this operation. - */ - unsigned int num_params; -}; - - -/** - * End of query parameter specification. - */ -#define GNUNET_SQ_query_param_end { NULL, NULL, NULL, 0, 0 } - - -/** - * Generate query parameter for a buffer @a ptr of - * @a ptr_size bytes. - * - * @param ptr pointer to the query parameter to pass - * @param ptr_size number of bytes in @a ptr - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_fixed_size (const void *ptr, - size_t ptr_size); - - -/** - * Generate query parameter for a string. - * - * @param ptr pointer to the string query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_string (const char *ptr); - - -/** - * Generate fixed-size query parameter with size determined - * by variable type. - * - * @param x pointer to the query parameter to pass. - */ -#define GNUNET_SQ_query_param_auto_from_type( \ - x) GNUNET_SQ_query_param_fixed_size ((x), sizeof(*(x))) - - -/** - * Generate query parameter for an RSA public key. The - * database must contain a BLOB type in the respective position. - * - * @param x the query parameter to pass. - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_rsa_public_key (const struct - GNUNET_CRYPTO_RsaPublicKey *x); - - -/** - * Generate query parameter for an RSA signature. The - * database must contain a BLOB type in the respective position. - * - * @param x the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_rsa_signature (const struct - GNUNET_CRYPTO_RsaSignature *x); - - -/** - * Generate query parameter for an absolute time value. - * The database must store a 64-bit integer. - * - * @param x pointer to the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); - - -/** - * Generate query parameter for an absolute time value. - * The database must store a 64-bit integer. - * - * @param x pointer to the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_absolute_time_nbo ( - const struct GNUNET_TIME_AbsoluteNBO *x); - - -/** - * Generate query parameter for an uint16_t in host byte order. - * - * @param x pointer to the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_uint16 (const uint16_t *x); - - -/** - * Generate query parameter for an uint32_t in host byte order. - * - * @param x pointer to the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_uint32 (const uint32_t *x); - - -/** - * Generate query parameter for an uint16_t in host byte order. - * - * @param x pointer to the query parameter to pass - */ -struct GNUNET_SQ_QueryParam -GNUNET_SQ_query_param_uint64 (const uint64_t *x); - - -/** - * Execute binding operations for a prepared statement. - * - * @param db_conn database connection - * @param params parameters to the statement - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_SQ_bind (sqlite3_stmt *stmt, - const struct GNUNET_SQ_QueryParam *params); - - -/** - * Reset @a stmt and log error. - * - * @param dbh database handle - * @param stmt statement to reset - */ -void -GNUNET_SQ_reset (sqlite3 *dbh, - sqlite3_stmt *stmt); - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param column column to extract data from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -typedef enum GNUNET_GenericReturnValue -(*GNUNET_SQ_ResultConverter)(void *cls, - sqlite3_stmt *result, - unsigned int column, - size_t *dst_size, - void *dst); - - -/** - * @brief Description of a DB result cell. - */ -struct GNUNET_SQ_ResultSpec; - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_SQ_ResultConverter. - * - * @param cls closure - */ -typedef void -(*GNUNET_SQ_ResultCleanup)(void *cls); - - -/** - * @brief Description of a DB result cell. - */ -struct GNUNET_SQ_ResultSpec -{ - /** - * What is the format of the result? - */ - GNUNET_SQ_ResultConverter conv; - - /** - * Function to clean up result data, NULL if cleanup is - * not necessary. - */ - GNUNET_SQ_ResultCleanup cleaner; - - /** - * Closure for @e conv and @e cleaner. - */ - void *cls; - - /** - * Destination for the data. - */ - void *dst; - - /** - * Allowed size for the data, 0 for variable-size - * (in this case, the type of @e dst is a `void **` - * and we need to allocate a buffer of the right size). - */ - size_t dst_size; - - /** - * Where to store actual size of the result. If left at - * NULL, will be made to point to @e dst_size before - * @a conv is called. - */ - size_t *result_size; - - /** - * Number of parameters (columns) eaten by this operation. - */ - unsigned int num_params; -}; - - -/** - * End of result parameter specification. - * - * @return array last entry for the result specification to use - */ -#define GNUNET_SQ_result_spec_end { NULL, NULL, NULL, NULL, 0, NULL, 0 } - - -/** - * Variable-size result expected. - * - * @param[out] dst where to store the result, allocated - * @param[out] sptr where to store the size of @a dst - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_variable_size (void **dst, - size_t *sptr); - - -/** - * Fixed-size result expected. - * - * @param[out] dst where to store the result - * @param dst_size number of bytes in @a dst - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_fixed_size (void *dst, - size_t dst_size); - - -/** - * We expect a fixed-size result, with size determined by the type of `* dst` - * - * @param dst point to where to store the result, type fits expected result size - * @return array entry for the result specification to use - */ -#define GNUNET_SQ_result_spec_auto_from_type( \ - dst) GNUNET_SQ_result_spec_fixed_size ((dst), sizeof(*(dst))) - - -/** - * Variable-size result expected. - * - * @param[out] dst where to store the result, allocated - * @param[out] sptr where to store the size of @a dst - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_variable_size (void **dst, - size_t *sptr); - - -/** - * 0-terminated string expected. - * - * @param[out] dst where to store the result, allocated - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_string (char **dst); - - -/** - * RSA public key expected. - * - * @param[out] rsa where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa); - - -/** - * RSA signature expected. - * - * @param[out] sig where to store the result; - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig); - - -/** - * Absolute time expected. - * - * @param[out] at where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at); - - -/** - * Absolute time expected. - * - * @param[out] at where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at); - - -/** - * uint16_t expected. - * - * @param[out] u16 where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_uint16 (uint16_t *u16); - - -/** - * uint32_t expected. - * - * @param[out] u32 where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_uint32 (uint32_t *u32); - - -/** - * uint64_t expected. - * - * @param[out] u64 where to store the result - * @return array entry for the result specification to use - */ -struct GNUNET_SQ_ResultSpec -GNUNET_SQ_result_spec_uint64 (uint64_t *u64); - - -/** - * Extract results from a query result according to the given specification. - * - * @param result result to process - * @param[in,out] rs result specification to extract for - * @return - * #GNUNET_OK if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field) - */ -enum GNUNET_GenericReturnValue -GNUNET_SQ_extract_result (sqlite3_stmt *result, - struct GNUNET_SQ_ResultSpec *rs); - - -/** - * Free all memory that was allocated in @a rs during - * #GNUNET_SQ_extract_result(). - * - * @param rs reult specification to clean up - */ -void -GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs); - - -/* ******************** sq_prepare.c functions ************** */ - - -/** - * Information needed to run a list of SQL statements using - * #GNUNET_SQ_exec_statements(). - */ -struct GNUNET_SQ_PrepareStatement -{ - /** - * Actual SQL statement. - */ - const char *sql; - - /** - * Where to store handle? - */ - sqlite3_stmt **pstmt; -}; - - -/** - * Terminator for executable statement list. - */ -#define GNUNET_SQ_PREPARE_END { NULL, NULL } - - -/** - * Create a `struct GNUNET_SQ_PrepareStatement` - * - * @param sql actual SQL statement - * @param pstmt where to store the handle - * @return initialized struct - */ -struct GNUNET_SQ_PrepareStatement -GNUNET_SQ_make_prepare (const char *sql, - sqlite3_stmt **pstmt); - - -/** - * Prepare all statements given in the (NULL,NULL)-terminated - * array at @a ps - * - * @param dbh database handle - * @param ps array of statements to prepare - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_SQ_prepare (sqlite3 *dbh, - const struct GNUNET_SQ_PrepareStatement *ps); - - -/* ******************** sq_exec.c functions ************** */ - - -/** - * Information needed to run a list of SQL statements using - * #GNUNET_SQ_exec_statements(). - */ -struct GNUNET_SQ_ExecuteStatement -{ - /** - * Actual SQL statement. - */ - const char *sql; - - /** - * Should we ignore errors? - */ - bool ignore_errors; -}; - - -/** - * Terminator for executable statement list. - */ -#define GNUNET_SQ_EXECUTE_STATEMENT_END { NULL, GNUNET_SYSERR } - - -/** - * Create a `struct GNUNET_SQ_ExecuteStatement` where errors are fatal. - * - * @param sql actual SQL statement - * @return initialized struct - */ -struct GNUNET_SQ_ExecuteStatement -GNUNET_SQ_make_execute (const char *sql); - - -/** - * Create a `struct GNUNET_SQ_ExecuteStatement` where errors should - * be tolerated. - * - * @param sql actual SQL statement - * @return initialized struct - */ -struct GNUNET_SQ_ExecuteStatement -GNUNET_SQ_make_try_execute (const char *sql); - - -/** - * Request execution of an array of statements @a es from Postgres. - * - * @param dbh database to execute the statements over - * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared - * statements. - * @return #GNUNET_OK on success (modulo statements where errors can be ignored) - * #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_SQ_exec_statements (sqlite3 *dbh, - const struct GNUNET_SQ_ExecuteStatement *es); - - -#endif /* GNUNET_SQ_LIB_H_ */ - -/* end of include/gnunet_sq_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_strings_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_strings_lib.h @@ -1,804 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2013 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * @author Krista Bennett - * @author Gerd Knorr <kraxel@bytesex.org> - * @author Ioana Patrascu - * @author Tzvetan Horozov - * - * @file - * Strings and string handling functions - * - * @defgroup strings Strings library - * Strings and string handling functions, including malloc and string tokenizing. - * @{ - */ - -#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -#ifndef GNUNET_STRINGS_LIB_H -#define GNUNET_STRINGS_LIB_H - -/* we need size_t, and since it can be both unsigned int - or unsigned long long, this IS platform dependent; - but "stdlib.h" should be portable 'enough' to be - unconditionally available... */ - -#include <stdlib.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ip.h> - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -#include "gnunet_time_lib.h" - - -/** - * Convert a given fancy human-readable size to bytes. - * - * @param fancy_size human readable string (e.g. 1 MB) - * @param size set to the size in bytes - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, - unsigned long long *size); - - -/** - * Convert a given fancy human-readable time to our internal - * representation. - * - * @param fancy_time human readable string (e.g. 1 minute) - * @param rtime set to the relative time - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, - struct GNUNET_TIME_Relative *rtime); - - -/** - * @ingroup time - * Convert a given fancy human-readable time to our internal - * representation. The human-readable time is expected to be - * in local time, whereas the returned value will be in UTC. - * - * @param fancy_time human readable string (e.g. %Y-%m-%d %H:%M:%S) - * @param atime set to the absolute time - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, - struct GNUNET_TIME_Absolute *atime); - - -/** - * @ingroup time - * Convert a given fancy human-readable time to our internal - * representation. The human-readable time is expected to be - * in local time, whereas the returned value will be in UTC. - * - * @param fancy_time human readable string (e.g. %Y-%m-%d %H:%M:%S) - * @param atime set to the absolute time - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_fancy_time_to_timestamp (const char *fancy_time, - struct GNUNET_TIME_Timestamp *atime); - - -/** - * Convert a given filesize into a fancy human-readable format. - * - * @param size number of bytes - * @return fancy representation of the size (possibly rounded) for humans - */ -char * -GNUNET_STRINGS_byte_size_fancy (unsigned long long size); - - -/** - * Convert the len characters long character sequence - * given in input that is in the given input charset - * to a string in given output charset. - * - * @param input input string - * @param len number of bytes in @a input - * @param input_charset character set used for @a input - * @param output_charset desired character set for the return value - * @return the converted string (0-terminated), - * if conversion fails, a copy of the original - * string is returned. - */ -char * -GNUNET_STRINGS_conv (const char *input, - size_t len, - const char *input_charset, - const char *output_charset); - - -/** - * Convert the len characters long character sequence - * given in input that is in the given charset - * to UTF-8. - * - * @param input the input string (not necessarily 0-terminated) - * @param len the number of bytes in the @a input - * @param charset character set to convert from - * @return the converted string (0-terminated) - */ -char * -GNUNET_STRINGS_to_utf8 (const char *input, - size_t len, - const char *charset); - - -/** - * Normalize the utf-8 input string to NFC. - * - * @param input input string - * @return result (freshly allocated) or NULL on error. - */ -char* -GNUNET_STRINGS_utf8_normalize (const char *input); - - -/** - * Convert the len bytes-long UTF-8 string - * given in input to the given charset. - * - * @param input the input string (not necessarily 0-terminated) - * @param len the number of bytes in the @a input - * @param charset character set to convert to - * @return the converted string (0-terminated), - * if conversion fails, a copy of the original - * string is returned. - */ -char * -GNUNET_STRINGS_from_utf8 (const char *input, - size_t len, - const char *charset); - - -/** - * Convert the utf-8 input string to lower case. - * Output needs to be allocated appropriately. - * - * @param input input string - * @param output output buffer - * @return GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_utf8_tolower (const char *input, - char *output); - - -/** - * Convert the utf-8 input string to upper case. - * Output needs to be allocated appropriately. - * - * @param input input string - * @param output output buffer - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_utf8_toupper (const char *input, - char *output); - - -/** - * Complete filename (a la shell) from abbrevition. - * - * @param fil the name of the file, may contain ~/ or - * be relative to the current directory - * @return the full file name, - * NULL is returned on error - */ -char * -GNUNET_STRINGS_filename_expand (const char *fil); - - -/** - * Fill a buffer of the given size with count 0-terminated strings - * (given as varargs). If "buffer" is NULL, only compute the amount - * of space required (sum of "strlen(arg)+1"). - * - * Unlike using "snprintf" with "%s", this function will add - * 0-terminators after each string. The - * "GNUNET_string_buffer_tokenize" function can be used to parse the - * buffer back into individual strings. - * - * @param buffer the buffer to fill with strings, can - * be NULL in which case only the necessary - * amount of space will be calculated - * @param size number of bytes available in buffer - * @param count number of strings that follow - * @param ... count 0-terminated strings to copy to buffer - * @return number of bytes written to the buffer - * (or number of bytes that would have been written) - */ -size_t -GNUNET_STRINGS_buffer_fill (char *buffer, - size_t size, - unsigned int count, - ...); - - -/** - * Given a buffer of a given size, find "count" 0-terminated strings - * in the buffer and assign the count (varargs) of type "const char**" - * to the locations of the respective strings in the buffer. - * - * @param buffer the buffer to parse - * @param size size of the @a buffer - * @param count number of strings to locate - * @param ... pointers to where to store the strings - * @return offset of the character after the last 0-termination - * in the buffer, or 0 on error. - */ -unsigned int -GNUNET_STRINGS_buffer_tokenize (const char *buffer, - size_t size, - unsigned int count, ...); - - -/** - * @ingroup time - * Like `asctime`, except for GNUnet time. Converts a GNUnet internal - * absolute time (which is in UTC) to a string in local time. - * Note that the returned value will be overwritten if this function - * is called again. - * - * @param t the absolute time to convert - * @return timestamp in human-readable form in local time - */ -const char * -GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t); - - -/** - * @ingroup time - * Give relative time in human-readable fancy format. - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param delta time in milli seconds - * @param do_round are we allowed to round a bit? - * @return string in human-readable form - */ -const char * -GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, - int do_round); - - -/** - * "man basename" - * Returns a pointer to a part of filename (allocates nothing)! - * - * @param filename filename to extract basename from - * @return short (base) name of the file (that is, everything following the - * last directory separator in filename. If filename ends with a - * directory separator, the result will be a zero-length string. - * If filename has no directory separators, the result is filename - * itself. - */ -const char * -GNUNET_STRINGS_get_short_name (const char *filename); - - -/** - * Convert binary data to ASCII encoding using CrockfordBase32. - * Does not append 0-terminator, but returns a pointer to the place where - * it should be placed, if needed. - * - * @param data data to encode - * @param size size of data (in bytes) - * @param out buffer to fill - * @param out_size size of the buffer. Must be large enough to hold - * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 - * @return pointer to the next byte in 'out' or NULL on error. - */ -char * -GNUNET_STRINGS_data_to_string (const void *data, - size_t size, - char *out, - size_t out_size); - - -/** - * Return the base32crockford encoding of the given buffer. - * - * The returned string will be freshly allocated, and must be free'd - * with #GNUNET_free(). - * - * @param buf buffer with data - * @param size size of the buffer @a buf - * @return freshly allocated, null-terminated string - */ -char * -GNUNET_STRINGS_data_to_string_alloc (const void *buf, - size_t size); - - -/** - * Convert CrockfordBase32 encoding back to data. - * @a out_size must match exactly the size of the data before it was encoded. - * - * @param enc the encoding - * @param enclen number of characters in @a enc (without 0-terminator, which can be missing) - * @param out location where to store the decoded data - * @param out_size size of the output buffer @a out - * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_string_to_data (const char *enc, - size_t enclen, - void *out, - size_t out_size); - - -/** - * Convert CrockfordBase32 encoding back to data. - * @a out_size will be determined from @a enc and - * @a out will be allocated to be large enough. - * - * @param enc the encoding - * @param enclen number of characters in @a enc (without 0-terminator, which can be missing) - * @param[out] out location where to allocate and store the decoded data - * @param[out] out_size set to the size of the output buffer @a out - * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_string_to_data_alloc (const char *enc, - size_t enclen, - void **out, - size_t *out_size); - - -/** - * Encode into Base64. - * - * @param data the data to encode - * @param len the length of the input - * @param output where to write the output (*output should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_base64_encode (const void *in, - size_t len, - char **output); - - -/** - * url/percent encode (RFC3986). - * - * FIXME: awkward API, @a len is not actually used - * @a out is 0-terminated, should probably be changed - * to only input @a data and directly return @out or NULL. - * - * @param data the data to decode - * @param len the length of the input - * @param out where to write the output (*out should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_urlencode (size_t len, - const char data[static len], - char **out); - - -/** - * Encode into Base64url. RFC7515 - * - * @param in the data to encode - * @param len the length of the input - * @param output where to write the output (*output should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_base64url_encode (const void *in, - size_t len, - char **output); - - -/** - * Decode from Base64. - * - * @param data the data to encode - * @param len the length of the input - * @param[out] output where to write the output (*output should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_base64_decode (const char *data, - size_t len, - void **output); - - -/** - * Decode from Base64url. RFC7515 - * - * @param data the data to decode - * @param len the length of the input - * @param out where to write the output (*out should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_base64url_decode (const char *data, - size_t len, - void **out); - -/** - * url/percent encode (RFC3986). - * - * @param data the data to encode - * @param len the length of the input - * @param[out] out where to write the output (*output should be NULL, - * is allocated) - * @return the size of the output - */ -size_t -GNUNET_STRINGS_urldecode (const char *data, - size_t len, - char **out); - - -/** - * Parse a path that might be an URI. - * - * @param path path to parse. Must be NULL-terminated. - * @param[out] scheme_part pointer to a string that - * represents the URI scheme will be stored. Can be NULL. The string is - * allocated by the function, and should be freed by GNUNET_free() when - * it is no longer needed. - * @param path_part a pointer to 'const char *' where a pointer to the path - * part of the URI will be stored. Can be NULL. Points to the same block - * of memory as @a path, and thus must not be freed. Might point to '\0', - * if path part is zero-length. - * @return #GNUNET_YES if it's an URI, #GNUNET_NO otherwise. If 'path' is not - * an URI, '* scheme_part' and '*path_part' will remain unchanged - * (if they weren't NULL). - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_parse_uri (const char *path, - char **scheme_part, - const char **path_part); - - -/** - * Check whether filename is absolute or not, and if it's an URI - * - * @param filename filename to check - * @param can_be_uri #GNUNET_YES to check for being URI, #GNUNET_NO - to - * assume it's not URI - * @param r_is_uri a pointer to an int that is set to #GNUNET_YES if 'filename' - * is URI and to GNUNET_NO otherwise. Can be NULL. If 'can_be_uri' is - * not #GNUNET_YES, *r_is_uri is set to #GNUNET_NO. - * @param r_uri_scheme a pointer to a char * that is set to a pointer to URI scheme. - * The string is allocated by the function, and should be freed with - * GNUNET_free (). Can be NULL. - * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise. - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_path_is_absolute (const char *filename, - int can_be_uri, - int *r_is_uri, - char **r_uri_scheme); - - -/** - * Flags for what we should check a file for. - */ -enum GNUNET_STRINGS_FilenameCheck -{ - /** - * Check that it exists. - */ - GNUNET_STRINGS_CHECK_EXISTS = 0x00000001, - - /** - * Check that it is a directory. - */ - GNUNET_STRINGS_CHECK_IS_DIRECTORY = 0x00000002, - - /** - * Check that it is a link. - */ - GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004, - - /** - * Check that the path is an absolute path. - */ - GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008 -}; - - -/** - * Perform checks on @a filename. FIXME: some duplication with - * "GNUNET_DISK_"-APIs. We should unify those. - * - * @param filename file to check - * @param checks checks to perform - * @return #GNUNET_YES if all checks pass, #GNUNET_NO if at least one of them - * fails, #GNUNET_SYSERR when a check can't be performed - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_check_filename (const char *filename, - enum GNUNET_STRINGS_FilenameCheck checks); - - -/** - * Tries to convert @a zt_addr string to an IPv6 address. - * The string is expected to have the format "[ABCD::01]:80". - * - * @param zt_addr 0-terminated string. May be mangled by the function. - * @param addrlen length of zt_addr (not counting 0-terminator). - * @param r_buf a buffer to fill. Initially gets filled with zeroes, - * then its sin6_port, sin6_family and sin6_addr are set appropriately. - * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which - * case the contents of r_buf are undefined. - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, - size_t addrlen, - struct sockaddr_in6 *r_buf); - - -/** - * Tries to convert @a zt_addr string to an IPv4 address. - * The string is expected to have the format "1.2.3.4:80". - * - * @param zt_addr 0-terminated string. May be mangled by the function. - * @param addrlen length of zt_addr (not counting 0-terminator). - * @param r_buf a buffer to fill. - * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which case - * the contents of r_buf are undefined. - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, - size_t addrlen, - struct sockaddr_in *r_buf); - - -/** - * Parse an address given as a string into a - * `struct sockaddr`. - * - * @param addr the address - * @param[out] af set to the parsed address family (e.g. AF_INET) - * @param[out] sa set to the parsed address - * @return 0 on error, otherwise number of bytes in @a sa - */ -size_t -GNUNET_STRINGS_parse_socket_addr (const char *addr, - uint8_t *af, - struct sockaddr **sa); - - -/** - * Tries to convert @a addr string to an IP (v4 or v6) address. - * Will automatically decide whether to treat 'addr' as v4 or v6 address. - * - * @param addr a string, may not be 0-terminated. - * @param addrlen number of bytes in @a addr (if addr is 0-terminated, - * 0-terminator should not be counted towards addrlen). - * @param r_buf a buffer to fill. - * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which - * case the contents of r_buf are undefined. - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_to_address_ip (const char *addr, - uint16_t addrlen, - struct sockaddr_storage *r_buf); - - -/** - * Returns utf-8 encoded arguments. Does nothing (returns a copy of - * @a argc and @a argv) on any platform other than W32. Returned @a - * argv has `u8argv[u8argc] == NULL`. Returned @a argv is a single - * memory block, and can be freed with a single GNUNET_free() call. - * - * @param argc argc (as given by main()) - * @param argv argv (as given by main()) - * @param u8argc a location to store new argc in (though it's th same as argc) - * @param u8argv a location to store new argv in - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -GNUNET_STRINGS_get_utf8_args (int argc, - char *const *argv, - int *u8argc, - char *const **u8argv); - - -/** - * Like strlcpy but portable. The given string @a src is copied in full length - * (until its null byte). The destination buffer is guaranteed to be - * null-terminated. - * - * to a destination buffer - * and ensures that the destination string is null-terminated. - * - * @param dst destination of the copy - * @param src source of the copy, must be null-terminated - * @param n the length of the string to copy, including its terminating null - * byte - * @return the length of the string that was copied, excluding the terminating - * null byte - */ -size_t -GNUNET_strlcpy (char *dst, - const char *src, - size_t n); - - -/** - * Sometimes we use the binary name to determine which specific - * test to run. In those cases, the string after the last "_" - * in 'argv[0]' specifies a string that determines the configuration - * file or plugin to use. - * - * This function returns the respective substring, taking care - * of issues such as binaries ending in '.exe' on W32. - * - * @param argv0 the name of the binary - * @return string between the last '_' and the '.exe' (or the end of the string), - * NULL if argv0 has no '_' - */ -char * -GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0); - - -/* ***************** IPv4/IPv6 parsing ****************** */ - -struct GNUNET_STRINGS_PortPolicy -{ - /** - * Starting port range (0 if none given). - */ - uint16_t start_port; - - /** - * End of port range (0 if none given). - */ - uint16_t end_port; - - /** - * #GNUNET_YES if the port range should be negated - * ("!" in policy). - */ - int negate_portrange; -}; - - -/** - * @brief IPV4 network in CIDR notation. - */ -struct GNUNET_STRINGS_IPv4NetworkPolicy -{ - /** - * IPv4 address. - */ - struct in_addr network; - - /** - * IPv4 netmask. - */ - struct in_addr netmask; - - /** - * Policy for port access. - */ - struct GNUNET_STRINGS_PortPolicy pp; -}; - - -/** - * @brief network in CIDR notation for IPV6. - */ -struct GNUNET_STRINGS_IPv6NetworkPolicy -{ - /** - * IPv6 address. - */ - struct in6_addr network; - - /** - * IPv6 netmask. - */ - struct in6_addr netmask; - - /** - * Policy for port access. - */ - struct GNUNET_STRINGS_PortPolicy pp; -}; - - -/** - * Parse an IPv4 network policy. The argument specifies a list of - * subnets. The format is <tt>(network[/netmask][:[!]SPORT-DPORT];)*</tt> - * (no whitespace, must be terminated with a semicolon). The network - * must be given in dotted-decimal notation. The netmask can be given - * in CIDR notation (/16) or in dotted-decimal (/255.255.0.0). - * - * @param routeListX a string specifying the IPv4 subnets - * @return the converted list, terminated with all zeros; - * NULL if the synatx is flawed - */ -struct GNUNET_STRINGS_IPv4NetworkPolicy * -GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX); - - -/** - * Parse an IPv6 network policy. The argument specifies a list of - * subnets. The format is <tt>(network[/netmask[:[!]SPORT[-DPORT]]];)*</tt> - * (no whitespace, must be terminated with a semicolon). The network - * must be given in colon-hex notation. The netmask must be given in - * CIDR notation (/16) or can be omitted to specify a single host. - * Note that the netmask is mandatory if ports are specified. - * - * @param routeListX a string specifying the policy - * @return the converted list, 0-terminated, NULL if the synatx is flawed - */ -struct GNUNET_STRINGS_IPv6NetworkPolicy * -GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_UTIL_STRING_H */ -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_util_string.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_time_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_time_lib.h @@ -1,931 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2001-2022 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @addtogroup libgnunetutil - * Multi-function utilities library for GNUnet programs - * @{ - * - * @author Christian Grothoff - * - * @file - * Functions related to time - * - * @defgroup time Time library - * Time and time calculations. - * @{ - */ - -#ifndef GNUNET_TIME_LIB_H -#define GNUNET_TIME_LIB_H - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -#include "gnunet_common.h" - -/** - * Time for absolute times used by GNUnet, in microseconds. - */ -struct GNUNET_TIME_Absolute -{ - /** - * The actual value. - */ - uint64_t abs_value_us; -}; - -/** - * Rounded time for timestamps used by GNUnet, in seconds. - */ -struct GNUNET_TIME_Timestamp -{ - /** - * The actual value. Must be round number in seconds. - */ - struct GNUNET_TIME_Absolute abs_time; -}; - -/** - * Time for relative time used by GNUnet, in microseconds. - * Always positive, so we can only refer to future time. - */ -struct GNUNET_TIME_Relative -{ - /** - * The actual value. - */ - uint64_t rel_value_us; -}; - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Time for relative time used by GNUnet, in microseconds and in network byte order. - */ -struct GNUNET_TIME_RelativeNBO -{ - /** - * The actual value (in network byte order). - */ - uint64_t rel_value_us__ GNUNET_PACKED; -}; - - -/** - * Time for absolute time used by GNUnet, in microseconds and in network byte order. - */ -struct GNUNET_TIME_AbsoluteNBO -{ - /** - * The actual value (in network byte order). - */ - uint64_t abs_value_us__ GNUNET_PACKED; -}; - -/** - * Time for timestamps used by GNUnet, in seconds and in network byte order. - */ -struct GNUNET_TIME_TimestampNBO -{ - /** - * The actual value. Must be round number in seconds. - */ - struct GNUNET_TIME_AbsoluteNBO abs_time_nbo; -}; - -GNUNET_NETWORK_STRUCT_END - -/** - * Relative time zero. - */ -#define GNUNET_TIME_UNIT_ZERO ((struct GNUNET_TIME_Relative){0}) - -/** - * Absolute time zero. - */ -#define GNUNET_TIME_UNIT_ZERO_ABS ((struct GNUNET_TIME_Absolute){0}) - -/** - * Timestamp of zero. - */ -#define GNUNET_TIME_UNIT_ZERO_TS ((struct GNUNET_TIME_Timestamp){{0}}) - -/** - * One microsecond, our basic time unit. - */ -#define GNUNET_TIME_UNIT_MICROSECONDS GNUNET_TIME_relative_get_unit_ () - -/** - * One millisecond. - */ -#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_millisecond_ () - -/** - * One second. - */ -#define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_get_second_ () - -/** - * One minute. - */ -#define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_get_minute_ () - -/** - * One hour. - */ -#define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_get_hour_ () - -/** - * One day. - */ -#define GNUNET_TIME_UNIT_DAYS GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_HOURS, 24) - -/** - * One week. - */ -#define GNUNET_TIME_UNIT_WEEKS GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_DAYS, 7) - -/** - * One month (30 days). - */ -#define GNUNET_TIME_UNIT_MONTHS GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_DAYS, 30) - -/** - * One year (365 days). - */ -#define GNUNET_TIME_UNIT_YEARS GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_DAYS, 365) - -/** - * Constant used to specify "forever". This constant - * will be treated specially in all time operations. - */ -#define GNUNET_TIME_UNIT_FOREVER_REL \ - ((struct GNUNET_TIME_Relative){UINT64_MAX}) - -/** - * Constant used to specify "forever". This constant - * will be treated specially in all time operations. - */ -#define GNUNET_TIME_UNIT_FOREVER_ABS \ - ((struct GNUNET_TIME_Absolute){UINT64_MAX}) - -/** - * Constant used to specify "forever". This constant - * will be treated specially in all time operations. - */ -#define GNUNET_TIME_UNIT_FOREVER_TS \ - ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}}) - - -/** - * Threshold after which exponential backoff should not increase (15 m). - */ -#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) - - -/** - * Perform our standard exponential back-off calculation, starting at 1 ms - * and then going by a factor of 2 up unto a maximum of 15 m. - * - * @param r current backoff time, initially zero - */ -#define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min ( \ - GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \ - GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2)) - - -/** - * Convert @a ts to human-readable timestamp. - * Note that the returned value will be overwritten if this function - * is called again. - * - * @param ts the timestamp to convert - * @return statically allocated string, will change on the next call - */ -const char * -GNUNET_TIME_timestamp2s (struct GNUNET_TIME_Timestamp ts); - - -/** - * @ingroup time - * Like `asctime`, except for GNUnet time. Converts a GNUnet internal - * absolute time (which is in UTC) to a string in local time. - * Note that the returned value will be overwritten if this function - * is called again. - * - * @param ts the absolute time to convert - * @return timestamp in human-readable form in local time - */ -const char * -GNUNET_TIME_absolute2s (struct GNUNET_TIME_Absolute ts); - - -/** - * @ingroup time - * Give relative time in human-readable fancy format. - * This is one of the very few calls in the entire API that is - * NOT reentrant! - * - * @param delta time in milli seconds - * @param do_round are we allowed to round a bit? - * @return string in human-readable form - */ -const char * -GNUNET_TIME_relative2s (struct GNUNET_TIME_Relative delta, - bool do_round); - - -/** - * Randomized exponential back-off, starting at 1 ms - * and going up by a factor of 2+r, where 0 <= r <= 0.5, up - * to a maximum of the given threshold. - * - * @param rt current backoff time, initially zero - * @param threshold maximum value for backoff - * @return the next backoff time - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_randomized_backoff (struct GNUNET_TIME_Relative rt, - struct GNUNET_TIME_Relative threshold); - - -/** - * Return a random time value between 0.5*r and 1.5*r. - * - * @param r input time for scaling - * @return randomized time - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r); - - -/** - * Return relative time of 0ms. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_zero_ (void); - - -/** - * Return absolute time of 0ms. - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_zero_ (void); - - -/** - * Return relative time of 1 microsecond. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_unit_ (void); - - -/** - * Return relative time of 1ms. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_millisecond_ (void); - - -/** - * Return relative time of 1s. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_second_ (void); - - -/** - * Return relative time of 1 minute. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_minute_ (void); - - -/** - * Return relative time of 1 hour. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_hour_ (void); - - -/** - * Return "forever". - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_forever_ (void); - - -/** - * Return "forever". - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_forever_ (void); - - -/** - * Get the current time. - * - * @return the current time - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get (void); - - -/** - * Convert relative time to an absolute time in the - * future. - * - * @param rel relative time to convert - * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel); - - -/** - * Convert relative time to a timestamp in the - * future. - * - * @param rel relative time to convert - * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_relative_to_timestamp (struct GNUNET_TIME_Relative rel); - - -/** - * Round an absolute time to a timestamp. - * - * @param at time to round - * @return the result - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at); - - -/** - * Get timestamp representing the current time. - * - * @return current time, rounded down to seconds - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_timestamp_get (void); - - -/** - * Compare two absolute times. - * - * @param t1 first time - * @param op compare operator - * @param t2 second time - * @return true if @a t1 @a op @a t2 - */ -#define GNUNET_TIME_absolute_cmp(t1,op,t2) \ - ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us) - - -/** - * Compare two timestamps - * - * @param t1 first timestamp - * @param op compare operator - * @param t2 second timestamp - * @return true if @a t1 @a op @a t2 - */ -#define GNUNET_TIME_timestamp_cmp(t1,op,t2) \ - GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time) - - -/** - * Compare two relative times. - * - * @param t1 first time - * @param op compare operator - * @param t2 second time - * @return true if @a t1 @a op @a t2 - */ -#define GNUNET_TIME_relative_cmp(t1,op,t2) \ - ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us) - - -/** - * Return the minimum of two relative time values. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is smaller - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, - struct GNUNET_TIME_Relative t2); - - -/** - * Return the maximum of two relative time values. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is larger - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, - struct GNUNET_TIME_Relative t2); - - -/** - * Return the minimum of two absolute time values. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is smaller - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, - struct GNUNET_TIME_Absolute t2); - - -/** - * Return the maximum of two absolute time values. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is smaller - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, - struct GNUNET_TIME_Absolute t2); - - -/** - * Round down absolute time @a at to multiple of @a rt. - * - * @param at absolute time to round - * @param rt multiple to round to (non-zero) - * @return rounded time - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at, - struct GNUNET_TIME_Relative rt); - - -/** - * Return the maximum of two timestamps. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is smaller - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_timestamp_max (struct GNUNET_TIME_Timestamp t1, - struct GNUNET_TIME_Timestamp t2); - - -/** - * Return the minimum of two timestamps. - * - * @param t1 first timestamp - * @param t2 other timestamp - * @return timestamp that is smaller - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1, - struct GNUNET_TIME_Timestamp t2); - - -/** - * Given a timestamp in the future, how much time - * remains until then? - * - * @param future some absolute time, typically in the future - * @return future - now, or 0 if now >= future, or FOREVER if future==FOREVER. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future); - - -/** - * Test if @a a1 and @a a2 are equal within a margin of - * error of @a t. - * - * @param a1 time to compare - * @param a2 time to compare - * @param t tolerance to apply - * @return true if "|a1-a2|<=t" holds. - */ -bool -GNUNET_TIME_absolute_approx_eq (struct GNUNET_TIME_Absolute a1, - struct GNUNET_TIME_Absolute a2, - struct GNUNET_TIME_Relative t); - - -/** - * Calculate the estimate time of arrival/completion - * for an operation. - * - * @param start when did the operation start? - * @param finished how much has been done? - * @param total how much must be done overall (same unit as for "finished") - * @return remaining duration for the operation, - * assuming it continues at the same speed - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, - uint64_t finished, - uint64_t total); - - -/** - * Compute the time difference between the given start and end times. - * Use this function instead of actual subtraction to ensure that - * "FOREVER" and overflows are handled correctly. - * - * @param start some absolute time - * @param end some absolute time (typically larger or equal to start) - * @return 0 if start >= end; FOREVER if end==FOREVER; otherwise end - start - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, - struct GNUNET_TIME_Absolute end); - - -/** - * Get the duration of an operation as the - * difference of the current time and the given start time "hence". - * - * @param whence some absolute time, typically in the past - * @return 0 if hence > now, otherwise now-hence. - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence); - - -/** - * Add a given relative duration to the - * given start time. - * - * @param start some absolute time - * @param duration some relative time to add - * @return FOREVER if either argument is FOREVER or on overflow; start+duration otherwise - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, - struct GNUNET_TIME_Relative duration); - - -/** - * Subtract a given relative duration from the - * given start time. - * - * @param start some absolute time - * @param duration some relative time to subtract - * @return ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, - struct GNUNET_TIME_Relative duration); - - -/** - * Multiply relative time by a given factor. - * - * @param rel some duration - * @param factor double to multiply with - * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel, - double factor); - -/** - * Multiply relative time by a given factor. - * - * @param rel some duration - * @param factor integer to multiply with - * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, - unsigned long long factor); - - -/** - * Saturating multiply relative time by a given factor. - * - * @param rel some duration - * @param factor integer to multiply with - * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_saturating_multiply (struct GNUNET_TIME_Relative rel, - unsigned long long factor); - - -/** - * Divide relative time by a given factor. - * - * @param rel some duration - * @param factor integer to divide by - * @return FOREVER if rel=FOREVER or factor==0; otherwise rel/factor - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, - unsigned long long factor); - - -/** - * Add relative times together. - * - * @param a1 some relative time - * @param a2 some other relative time - * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, - struct GNUNET_TIME_Relative a2); - - -/** - * Subtract relative timestamp from the other. - * - * @param a1 first timestamp - * @param a2 second timestamp - * @return ZERO if a2>=a1 (including both FOREVER), FOREVER if a1 is FOREVER, a1-a2 otherwise - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, - struct GNUNET_TIME_Relative a2); - - -/** - * Convert relative time to network byte order. - * - * @param a time to convert - * @return converted time value - */ -struct GNUNET_TIME_RelativeNBO -GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a); - - -/** - * Convert relative time from network byte order. - * - * @param a time to convert - * @return converted time value - */ -struct GNUNET_TIME_Relative -GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a); - - -/** - * Convert absolute time to network byte order. - * - * @param a time to convert - * @return converted time value - */ -struct GNUNET_TIME_AbsoluteNBO -GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a); - - -/** - * Convert timestamp to network byte order. - * - * @param t time to convert - * @return converted time value - */ -struct GNUNET_TIME_TimestampNBO -GNUNET_TIME_timestamp_hton (struct GNUNET_TIME_Timestamp t); - - -/** - * Convert milliseconds after the UNIX epoch to absolute time. - * - * @param ms_after_epoch millisecond timestamp to convert - * @return converted time value - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch); - - -/** - * Test if @a abs is never. - * - * @return true if it is. - */ -bool -GNUNET_TIME_absolute_is_never (struct GNUNET_TIME_Absolute abs); - - -/** - * Test if @a abs is truly in the past (excluding now). - * - * @return true if it is. - */ -bool -GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs); - - -/** - * Test if @a abs is truly zero. - * - * @return true if it is. - */ -bool -GNUNET_TIME_absolute_is_zero (struct GNUNET_TIME_Absolute abs); - - -/** - * Test if @a abs is truly in the future (excluding now). - * - * @return true if it is. - */ -bool -GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs); - - -/** - * Test if @a rel is forever. - * - * @return true if it is. - */ -bool -GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel); - - -/** - * Test if @a rel is zero. - * - * @return true if it is. - */ -bool -GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel); - - -/** - * Convert seconds after the UNIX epoch to absolute time. - * - * @param s_after_epoch seconds after epoch to convert - * @return converted time value - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_from_s (uint64_t s_after_epoch); - - -/** - * Convert seconds after the UNIX epoch to timestamp. - * - * @param s_after_epoch seconds after epoch to convert - * @return converted time value - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_timestamp_from_s (uint64_t s_after_epoch); - - -/** - * Convert timestamp to number of seconds after the UNIX epoch. - * - * @param ts timestamp to convert - * @return converted time value - */ -uint64_t -GNUNET_TIME_timestamp_to_s (struct GNUNET_TIME_Timestamp ts); - - -/** - * Convert absolute time from network byte order. - * - * @param a time to convert - * @return converted time value - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a); - - -/** - * Convert timestamp from network byte order. - * - * @param tn time to convert - * @return converted time value - */ -struct GNUNET_TIME_Timestamp -GNUNET_TIME_timestamp_ntoh (struct GNUNET_TIME_TimestampNBO tn); - - -/** - * Set the timestamp offset for this instance. - * - * @param offset the offset to skew the locale time by - */ -void -GNUNET_TIME_set_offset (long long offset); - - -/** - * Get the timestamp offset for this instance. - * - * @return the offset we currently skew the locale time by - */ -long long -GNUNET_TIME_get_offset (void); - - -/** - * Return the current year (e.g. '2011'). - */ -unsigned int -GNUNET_TIME_get_current_year (void); - - -/** - * Convert a year to an expiration time of January 1st of that year. - * - * @param year a year (after 1970, please ;-)). - * @return absolute time for January 1st of that year. - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_year_to_time (unsigned int year); - - -/** - * Convert an expiration time to the respective year (rounds) - * - * @param at absolute time - * @return year a year (after 1970), 0 on error - */ -unsigned int -GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at); - - -/** - * A configuration object. - */ -struct GNUNET_CONFIGURATION_Handle; - - -/** - * Obtain the current time and make sure it is monotonically - * increasing. Guards against systems without an RTC or - * clocks running backwards and other nasty surprises. Does - * not guarantee that the returned time is near the current - * time returned by #GNUNET_TIME_absolute_get(). Two - * subsequent calls (within a short time period) may return the - * same value. Persists the last returned time on disk to - * ensure that time never goes backwards. As a result, the - * resulting value can be used to check if a message is the - * "most recent" value and replays of older messages (from - * the same origin) would be discarded. - * - * @param cfg configuration, used to determine where to - * store the time; user can also insist RTC is working - * nicely and disable the feature - * @return monotonically increasing time - */ -struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_monotonic ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_TIME_LIB_H */ -#endif - -/** @} */ /* end of group time */ - -/** @} */ /* end of group addition */ - -/* end of gnunet_time_lib.h */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_tun_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_tun_lib.h @@ -1,977 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2010-2013 Christian Grothoff - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) -#error "Only <gnunet_util_lib.h> can be included directly." -#endif - -/** - * @addtogroup vpn_suite VPN services and libraries - * @{ - * - * @author Philipp Toelke - * @author Christian Grothoff - * - * @file - * Standard TCP/IP network structs and IP checksum calculations for TUN - * interaction - * - * @defgroup tun TUN library - * Standard TCP/IP network structs and IP checksum calculations for TUN - * interaction - * @{ - */ -#ifndef GNUNET_TUN_LIB_H -#define GNUNET_TUN_LIB_H - - -/* see http://www.iana.org/assignments/ethernet-numbers */ -#ifndef ETH_P_IPV4 -/** - * Number for IPv4 - */ -#define ETH_P_IPV4 0x0800 -#endif - -#ifndef ETH_P_IPV6 -/** - * Number for IPv6 - */ -#define ETH_P_IPV6 0x86DD -#endif - - -/** - * Maximum regex string length for use with #GNUNET_TUN_ipv4toregexsearch. - * - * 8 bytes for IPv4, 4 bytes for port, 1 byte for "4", 2 bytes for "-", - * one byte for 0-termination. - */ - -#define GNUNET_TUN_IPV4_REGEXLEN 16 - - -/** - * Maximum regex string length for use with #GNUNET_TUN_ipv6toregexsearch - * - * 32 bytes for IPv4, 4 bytes for port, 1 byte for "4", 2 bytes for "-", - * one byte for 0-termination. - */ -#define GNUNET_TUN_IPV6_REGEXLEN 40 - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Header from Linux TUN interface. - */ -struct GNUNET_TUN_Layer2PacketHeader -{ - /** - * Some flags (unused). - */ - uint16_t flags GNUNET_PACKED; - - /** - * Here we get an ETH_P_-number. - */ - uint16_t proto GNUNET_PACKED; -}; - - -/** - * Standard IPv4 header. - */ -struct GNUNET_TUN_IPv4Header -{ -#if __BYTE_ORDER == __LITTLE_ENDIAN - unsigned int header_length : 4 GNUNET_PACKED; - unsigned int version : 4 GNUNET_PACKED; -#elif __BYTE_ORDER == __BIG_ENDIAN - unsigned int version : 4 GNUNET_PACKED; - unsigned int header_length : 4 GNUNET_PACKED; -#else -#error byteorder undefined -#endif - uint8_t diff_serv; - - /** - * Length of the packet, including this header. - */ - uint16_t total_length GNUNET_PACKED; - - /** - * Unique random ID for matching up fragments. - */ - uint16_t identification GNUNET_PACKED; - - unsigned int flags : 3 GNUNET_PACKED; - - unsigned int fragmentation_offset : 13 GNUNET_PACKED; - - /** - * How many more hops can this packet be forwarded? - */ - uint8_t ttl; - - /** - * L4-protocol, for example, IPPROTO_UDP or IPPROTO_TCP. - */ - uint8_t protocol; - - /** - * Checksum. - */ - uint16_t checksum GNUNET_PACKED; - - /** - * Origin of the packet. - */ - struct in_addr source_address; - - /** - * Destination of the packet. - */ - struct in_addr destination_address; -} GNUNET_GCC_STRUCT_LAYOUT; - - -/** - * Standard IPv6 header. - */ -struct GNUNET_TUN_IPv6Header -{ -#if __BYTE_ORDER == __LITTLE_ENDIAN - unsigned int traffic_class_h : 4 GNUNET_PACKED; - unsigned int version : 4 GNUNET_PACKED; - unsigned int traffic_class_l : 4 GNUNET_PACKED; - unsigned int flow_label : 20 GNUNET_PACKED; -#elif __BYTE_ORDER == __BIG_ENDIAN - unsigned int version : 4 GNUNET_PACKED; - unsigned int traffic_class : 8 GNUNET_PACKED; - unsigned int flow_label : 20 GNUNET_PACKED; -#else -#error byteorder undefined -#endif - /** - * Length of the payload, excluding this header. - */ - uint16_t payload_length GNUNET_PACKED; - - /** - * For example, IPPROTO_UDP or IPPROTO_TCP. - */ - uint8_t next_header; - - /** - * How many more hops can this packet be forwarded? - */ - uint8_t hop_limit; - - /** - * Origin of the packet. - */ - struct in6_addr source_address GNUNET_PACKED; - - /** - * Destination of the packet. - */ - struct in6_addr destination_address GNUNET_PACKED; -} GNUNET_GCC_STRUCT_LAYOUT; - - -/** - * TCP flags. - */ -#define GNUNET_TUN_TCP_FLAGS_FIN 1 -#define GNUNET_TUN_TCP_FLAGS_SYN 2 -#define GNUNET_TUN_TCP_FLAGS_RST 4 -#define GNUNET_TUN_TCP_FLAGS_PSH 8 -#define GNUNET_TUN_TCP_FLAGS_ACK 16 -#define GNUNET_TUN_TCP_FLAGS_URG 32 -#define GNUNET_TUN_TCP_FLAGS_ECE 64 -#define GNUNET_TUN_TCP_FLAGS_CWR 128 - -/** - * TCP packet header. - */ -struct GNUNET_TUN_TcpHeader -{ - /** - * Source port (in NBO). - */ - uint16_t source_port GNUNET_PACKED; - - /** - * Destination port (in NBO). - */ - uint16_t destination_port GNUNET_PACKED; - - /** - * Sequence number. - */ - uint32_t seq GNUNET_PACKED; - - /** - * Acknowledgement number. - */ - uint32_t ack GNUNET_PACKED; -#if __BYTE_ORDER == __LITTLE_ENDIAN - /** - * Reserved. Must be zero. - */ - unsigned int reserved : 4 GNUNET_PACKED; - /** - * Number of 32-bit words in TCP header. - */ - unsigned int off : 4 GNUNET_PACKED; -#elif __BYTE_ORDER == __BIG_ENDIAN - /** - * Number of 32-bit words in TCP header. - */ - unsigned int off : 4 GNUNET_PACKED; - /** - * Reserved. Must be zero. - */ - unsigned int reserved : 4 GNUNET_PACKED; -#else -#error byteorder undefined -#endif - - /** - * Flags (SYN, FIN, ACK, etc.) - */ - uint8_t flags; - - /** - * Window size. - */ - uint16_t window_size GNUNET_PACKED; - - /** - * Checksum. - */ - uint16_t crc GNUNET_PACKED; - - /** - * Urgent pointer. - */ - uint16_t urgent_pointer GNUNET_PACKED; -} GNUNET_GCC_STRUCT_LAYOUT; - - -/** - * UDP packet header. - */ -struct GNUNET_TUN_UdpHeader -{ - /** - * Source port (in NBO). - */ - uint16_t source_port GNUNET_PACKED; - - /** - * Destination port (in NBO). - */ - uint16_t destination_port GNUNET_PACKED; - - /** - * Number of bytes of payload. - */ - uint16_t len GNUNET_PACKED; - - /** - * Checksum. - */ - uint16_t crc GNUNET_PACKED; -}; - - -/** - * A few common DNS classes (ok, only one is common, but I list a - * couple more to make it clear what we're talking about here). - */ -#define GNUNET_TUN_DNS_CLASS_INTERNET 1 -#define GNUNET_TUN_DNS_CLASS_CHAOS 3 -#define GNUNET_TUN_DNS_CLASS_HESIOD 4 - -#define GNUNET_TUN_DNS_OPCODE_QUERY 0 -#define GNUNET_TUN_DNS_OPCODE_INVERSE_QUERY 1 -#define GNUNET_TUN_DNS_OPCODE_STATUS 2 - - -/** - * RFC 1035 codes. - */ -#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR 0 -#define GNUNET_TUN_DNS_RETURN_CODE_FORMAT_ERROR 1 -#define GNUNET_TUN_DNS_RETURN_CODE_SERVER_FAILURE 2 -#define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR 3 -#define GNUNET_TUN_DNS_RETURN_CODE_NOT_IMPLEMENTED 4 -#define GNUNET_TUN_DNS_RETURN_CODE_REFUSED 5 - -/** - * RFC 2136 codes - */ -#define GNUNET_TUN_DNS_RETURN_CODE_YXDOMAIN 6 -#define GNUNET_TUN_DNS_RETURN_CODE_YXRRSET 7 -#define GNUNET_TUN_DNS_RETURN_CODE_NXRRSET 8 -#define GNUNET_TUN_DNS_RETURN_CODE_NOT_AUTH 9 -#define GNUNET_TUN_DNS_RETURN_CODE_NOT_ZONE 10 - - -/** - * DNS flags (largely RFC 1035 / RFC 2136). - */ -struct GNUNET_TUN_DnsFlags -{ -#if __BYTE_ORDER == __LITTLE_ENDIAN - /** - * Set to 1 if recursion is desired (client -> server) - */ - unsigned int recursion_desired : 1 GNUNET_PACKED; - - /** - * Set to 1 if message is truncated - */ - unsigned int message_truncated : 1 GNUNET_PACKED; - - /** - * Set to 1 if this is an authoritative answer - */ - unsigned int authoritative_answer : 1 GNUNET_PACKED; - - /** - * See GNUNET_TUN_DNS_OPCODE_ defines. - */ - unsigned int opcode : 4 GNUNET_PACKED; - - /** - * query:0, response:1 - */ - unsigned int query_or_response : 1 GNUNET_PACKED; - - /** - * See GNUNET_TUN_DNS_RETURN_CODE_ defines. - */ - unsigned int return_code : 4 GNUNET_PACKED; - - /** - * See RFC 4035. - */ - unsigned int checking_disabled : 1 GNUNET_PACKED; - - /** - * Response has been cryptographically verified, RFC 4035. - */ - unsigned int authenticated_data : 1 GNUNET_PACKED; - - /** - * Always zero. - */ - unsigned int zero : 1 GNUNET_PACKED; - - /** - * Set to 1 if recursion is available (server -> client) - */ - unsigned int recursion_available : 1 GNUNET_PACKED; -#elif __BYTE_ORDER == __BIG_ENDIAN - /** - * query:0, response:1 - */ - unsigned int query_or_response : 1 GNUNET_PACKED; - - /** - * See GNUNET_TUN_DNS_OPCODE_ defines. - */ - unsigned int opcode : 4 GNUNET_PACKED; - - /** - * Set to 1 if this is an authoritative answer - */ - unsigned int authoritative_answer : 1 GNUNET_PACKED; - - /** - * Set to 1 if message is truncated - */ - unsigned int message_truncated : 1 GNUNET_PACKED; - - /** - * Set to 1 if recursion is desired (client -> server) - */ - unsigned int recursion_desired : 1 GNUNET_PACKED; - - - /** - * Set to 1 if recursion is available (server -> client) - */ - unsigned int recursion_available : 1 GNUNET_PACKED; - - /** - * Always zero. - */ - unsigned int zero : 1 GNUNET_PACKED; - - /** - * Response has been cryptographically verified, RFC 4035. - */ - unsigned int authenticated_data : 1 GNUNET_PACKED; - - /** - * See RFC 4035. - */ - unsigned int checking_disabled : 1 GNUNET_PACKED; - - /** - * See GNUNET_TUN_DNS_RETURN_CODE_ defines. - */ - unsigned int return_code : 4 GNUNET_PACKED; -#else -#error byteorder undefined -#endif -} GNUNET_GCC_STRUCT_LAYOUT; - - -/** - * DNS header. - */ -struct GNUNET_TUN_DnsHeader -{ - /** - * Unique identifier for the request/response. - */ - uint16_t id GNUNET_PACKED; - - /** - * Flags. - */ - struct GNUNET_TUN_DnsFlags flags; - - /** - * Number of queries. - */ - uint16_t query_count GNUNET_PACKED; - - /** - * Number of answers. - */ - uint16_t answer_rcount GNUNET_PACKED; - - /** - * Number of authoritative answers. - */ - uint16_t authority_rcount GNUNET_PACKED; - - /** - * Number of additional records. - */ - uint16_t additional_rcount GNUNET_PACKED; -}; - - -/** - * Payload of DNS SOA record (header). - */ -struct GNUNET_TUN_DnsSoaRecord -{ - /** - * The version number of the original copy of the zone. (NBO) - */ - uint32_t serial GNUNET_PACKED; - - /** - * Time interval before the zone should be refreshed. (NBO) - */ - uint32_t refresh GNUNET_PACKED; - - /** - * Time interval that should elapse before a failed refresh should - * be retried. (NBO) - */ - uint32_t retry GNUNET_PACKED; - - /** - * Time value that specifies the upper limit on the time interval - * that can elapse before the zone is no longer authoritative. (NBO) - */ - uint32_t expire GNUNET_PACKED; - - /** - * The bit minimum TTL field that should be exported with any RR - * from this zone. (NBO) - */ - uint32_t minimum GNUNET_PACKED; -}; - - -/** - * Payload of DNS SRV record (header). - */ -struct GNUNET_TUN_DnsSrvRecord -{ - /** - * Preference for this entry (lower value is higher preference). Clients - * will contact hosts from the lowest-priority group first and fall back - * to higher priorities if the low-priority entries are unavailable. (NBO) - */ - uint16_t prio GNUNET_PACKED; - - /** - * Relative weight for records with the same priority. Clients will use - * the hosts of the same (lowest) priority with a probability proportional - * to the weight given. (NBO) - */ - uint16_t weight GNUNET_PACKED; - - /** - * TCP or UDP port of the service. (NBO) - */ - uint16_t port GNUNET_PACKED; - - /* followed by 'target' name */ -}; - - -/** - * Payload of DNS URI record (header). - */ -struct GNUNET_TUN_DnsUriRecord -{ - /** - * Preference for this entry (lower value is higher preference). Clients - * will contact hosts from the lowest-priority group first and fall back - * to higher priorities if the low-priority entries are unavailable. (NBO) - */ - uint16_t prio GNUNET_PACKED; - - /** - * Relative weight for records with the same priority. Clients will use - * the hosts of the same (lowest) priority with a probability proportional - * to the weight given. (NBO) - */ - uint16_t weight GNUNET_PACKED; - - /* followed by 'target' name */ -}; - - -/** - * Payload of DNS CERT record. - */ -struct GNUNET_TUN_DnsCertRecord -{ - /** - * Certificate type - */ - uint16_t cert_type; - - /** - * Certificate KeyTag - */ - uint16_t cert_tag; - - /** - * Algorithm - */ - uint8_t algorithm; - - /* Followed by the certificate */ -}; - - -/** - * Payload of DNSSEC TLSA record. - * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ - */ -struct GNUNET_TUN_DnsTlsaRecord -{ - /** - * Certificate usage - * 0: CA cert - * 1: Entity cert - * 2: Trust anchor - * 3: domain-issued cert - */ - uint8_t usage; - - /** - * Selector - * What part will be matched against the cert - * presented by server - * 0: Full cert (in binary) - * 1: Full cert (in DER) - */ - uint8_t selector; - - /** - * Matching type (of selected content) - * 0: exact match - * 1: SHA-256 hash - * 2: SHA-512 hash - */ - uint8_t matching_type; - - /** - * followed by certificate association data - * The "certificate association data" to be matched. - * These bytes are either raw data (that is, the full certificate or - * its SubjectPublicKeyInfo, depending on the selector) for matching - * type 0, or the hash of the raw data for matching types 1 and 2. - * The data refers to the certificate in the association, not to the - * TLS ASN.1 Certificate object. - * - * The data is represented as a string of hex chars - */ -}; - - -/** - * Payload of GNS VPN record - */ -struct GNUNET_TUN_GnsVpnRecord -{ - /** - * The peer to contact - */ - struct GNUNET_PeerIdentity peer; - - /** - * The protocol to use - */ - uint16_t proto; - - /* followed by the servicename */ -}; - - -/** - * DNS query prefix. - */ -struct GNUNET_TUN_DnsQueryLine -{ - /** - * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) - */ - uint16_t type GNUNET_PACKED; - - /** - * Desired class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO) - */ - uint16_t dns_traffic_class GNUNET_PACKED; -}; - - -/** - * General DNS record prefix. - */ -struct GNUNET_TUN_DnsRecordLine -{ - /** - * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) - */ - uint16_t type GNUNET_PACKED; - - /** - * Record class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO) - */ - uint16_t dns_traffic_class GNUNET_PACKED; - - /** - * Expiration for the record (in seconds). (NBO) - */ - uint32_t ttl GNUNET_PACKED; - - /** - * Number of bytes of data that follow. (NBO) - */ - uint16_t data_len GNUNET_PACKED; -}; - - -#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0 -#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3 -#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4 -#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5 -#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8 -#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9 -#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10 -#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11 - -#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1 -#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2 -#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3 -#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4 -#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128 -#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129 - - -/** - * ICMP header. - */ -struct GNUNET_TUN_IcmpHeader -{ - uint8_t type; - uint8_t code; - uint16_t crc GNUNET_PACKED; - - union - { - /** - * ICMP Echo (request/reply) - */ - struct - { - uint16_t identifier GNUNET_PACKED; - uint16_t sequence_number GNUNET_PACKED; - } echo; - - /** - * ICMP Destination Unreachable (RFC 1191) - */ - struct ih_pmtu - { - uint16_t empty GNUNET_PACKED; - uint16_t next_hop_mtu GNUNET_PACKED; - /* followed by original IP header + first 8 bytes of original IP datagram - */ - } destination_unreachable; - - /** - * ICMP Redirect - */ - struct in_addr redirect_gateway_address; - - /** - * MTU for packets that are too big (IPv6). - */ - uint32_t packet_too_big_mtu GNUNET_PACKED; - } quench; -}; - - -GNUNET_NETWORK_STRUCT_END - - -/** - * Initialize an IPv4 header. - * - * @param ip header to initialize - * @param protocol protocol to use (e.g. IPPROTO_UDP) - * @param payload_length number of bytes of payload that follow (excluding IPv4 - * header) - * @param src source IP address to use - * @param dst destination IP address to use - */ -void -GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip, - uint8_t protocol, - uint16_t payload_length, - const struct in_addr *src, - const struct in_addr *dst); - - -/** - * Initialize an IPv6 header. - * - * @param ip header to initialize - * @param protocol protocol to use (e.g. IPPROTO_UDP) - * @param payload_length number of bytes of payload that follow (excluding IPv4 - * header) - * @param src source IP address to use - * @param dst destination IP address to use - */ -void -GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip, - uint8_t protocol, - uint16_t payload_length, - const struct in6_addr *src, - const struct in6_addr *dst); - -/** - * Calculate IPv4 TCP checksum. - * - * @param ip ipv4 header fully initialized - * @param tcp TCP header (initialized except for CRC) - * @param payload the TCP payload - * @param payload_length number of bytes of TCP @a payload - */ -void -GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, - struct GNUNET_TUN_TcpHeader *tcp, - const void *payload, - uint16_t payload_length); - -/** - * Calculate IPv6 TCP checksum. - * - * @param ip ipv6 header fully initialized - * @param tcp TCP header (initialized except for CRC) - * @param payload the TCP payload - * @param payload_length number of bytes of TCP payload - */ -void -GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, - struct GNUNET_TUN_TcpHeader *tcp, - const void *payload, - uint16_t payload_length); - -/** - * Calculate IPv4 UDP checksum. - * - * @param ip ipv4 header fully initialized - * @param udp UDP header (initialized except for CRC) - * @param payload the UDP payload - * @param payload_length number of bytes of UDP @a payload - */ -void -GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, - struct GNUNET_TUN_UdpHeader *udp, - const void *payload, - uint16_t payload_length); - - -/** - * Calculate IPv6 UDP checksum. - * - * @param ip ipv6 header fully initialized - * @param udp UDP header (initialized except for CRC) - * @param payload the UDP payload - * @param payload_length number of bytes of @a payload - */ -void -GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, - struct GNUNET_TUN_UdpHeader *udp, - const void *payload, - uint16_t payload_length); - - -/** - * Calculate ICMP checksum. - * - * @param icmp IMCP header (initialized except for CRC) - * @param payload the ICMP payload - * @param payload_length number of bytes of @a payload - */ -void -GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, - const void *payload, - uint16_t payload_length); - - -/** - * Create a regex in @a rxstr from the given @a ip and @a port. - * - * @param ip IPv4 representation. - * @param port destination port - * @param rxstr generated regex, must be at least #GNUNET_TUN_IPV4_REGEXLEN - * bytes long. - */ -void -GNUNET_TUN_ipv4toregexsearch (const struct in_addr *ip, - uint16_t port, - char *rxstr); - - -/** - * Create a regex in @a rxstr from the given @a ipv6 and @a port. - * - * @param ipv6 IPv6 representation. - * @param port destination port - * @param rxstr generated regex, must be at least #GNUNET_TUN_IPV6_REGEXLEN - * bytes long. - */ -void -GNUNET_TUN_ipv6toregexsearch (const struct in6_addr *ipv6, - uint16_t port, - char *rxstr); - - -/** - * Convert an exit policy to a regular expression. The exit policy - * specifies a set of subnets this peer is willing to serve as an - * exit for; the resulting regular expression will match the - * IPv6 address strings as returned by #GNUNET_TUN_ipv6toregexsearch. - * - * @param policy exit policy specification - * @return regular expression, NULL on error - */ -char * -GNUNET_TUN_ipv6policy2regex (const char *policy); - - -/** - * Convert an exit policy to a regular expression. The exit policy - * specifies a set of subnets this peer is willing to serve as an - * exit for; the resulting regular expression will match the - * IPv4 address strings as returned by #GNUNET_TUN_ipv4toregexsearch. - * - * @param policy exit policy specification - * @return regular expression, NULL on error - */ -char * -GNUNET_TUN_ipv4policy2regex (const char *policy); - - -/** - * Hash the service name of a hosted service to the - * hash code that is used to identify the service on - * the network. - * - * @param service_name a string - * @param[out] hc corresponding hash - */ -void -GNUNET_TUN_service_name_to_hash (const char *service_name, - struct GNUNET_HashCode *hc); - - -/** - * Check if two sockaddrs are equal. - * - * @param sa one address - * @param sb another address - * @param include_port also check ports - * @return #GNUNET_YES if they are equal - */ -int -GNUNET_TUN_sockaddr_cmp (const struct sockaddr *sa, - const struct sockaddr *sb, - int include_port); - - -/** - * Compute the CADET port given a service descriptor - * (returned from #GNUNET_TUN_service_name_to_hash) and - * a TCP/UDP port @a ip_port. - * - * @param desc service shared secret - * @param ip_port TCP/UDP port, use 0 for ICMP - * @param[out] cadet_port CADET port to use - */ -void -GNUNET_TUN_compute_service_cadet_port (const struct GNUNET_HashCode *desc, - uint16_t ip_port, - struct GNUNET_HashCode *cadet_port); - -#endif - -/** @} */ /* end of group */ - -/** @} */ /* end of group addition */ diff --git a/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_util_lib.h b/android_studio/distribution/libgnunet/lib/arm64-v8a/include/gnunet_util_lib.h @@ -1,115 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2009 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - SPDX-License-Identifier: AGPL3.0-or-later - */ - -/** - * @author Christian Grothoff - * - * @file - * Convenience header including all headers of subsystems in the gnunet_util library - * - * @see [Documentation](https://gnunet.org/libgnuneutil) - */ - -#ifndef GNUNET_UTIL_LIB_H -#define GNUNET_UTIL_LIB_H - -#define __GNUNET_UTIL_LIB_H_INSIDE__ - -#include <sys/socket.h> - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Largest supported message (to be precise, one byte more - * than the largest possible message, so tests involving - * this value should check for messages being smaller than - * this value). - */ -#define GNUNET_MAX_MESSAGE_SIZE 65536 - -/** - * Smallest supported message. - */ -#define GNUNET_MIN_MESSAGE_SIZE sizeof(struct GNUNET_MessageHeader) - -/** - * NOTE: You MUST adjust this URL to point to the location of a - * publicly accessible repository (or TGZ) containing the sources of - * THIS release. Otherwise, you are violating the Affero GPL if you make - * this service available to anyone but yourself. - */ -#define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ - GNUNET_VERSION - -#include "gnunet_config.h" -#include "gnunet_common.h" -#include "gnunet_crypto_lib.h" -#include "gnunet_bandwidth_lib.h" -#include "gnunet_bio_lib.h" -#include "gnunet_buffer_lib.h" -#include "gnunet_client_lib.h" -#include "gnunet_container_lib.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_helper_lib.h" -#include "gnunet_mst_lib.h" -#include "gnunet_mq_lib.h" -#include "gnunet_nt_lib.h" -#include "gnunet_nc_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_peer_lib.h" -#include "gnunet_plugin_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_protocols.h" -#include "gnunet_service_lib.h" -#include "gnunet_signal_lib.h" -#include "gnunet_strings_lib.h" -#include "gnunet_tun_lib.h" -#include "gnunet_dnsstub_lib.h" -#include "gnunet_dnsparser_lib.h" -#include "gnunet_child_management_lib.h" -#include "gnunet_error_codes.h" - - -/** - * Stringify operator. - * - * @param a some expression to stringify. Must NOT be a macro. - * @return same expression as a constant string. - */ -#define GNUNET_S(a) #a - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#undef __GNUNET_UTIL_LIB_H_INSIDE__ - -#endif diff --git a/android_studio/distribution/libgnunetutil/lib/arm64-v8a/include/gnunet_service_lib.h b/android_studio/distribution/libgnunetutil/lib/arm64-v8a/include/gnunet_service_lib.h @@ -407,7 +407,9 @@ GNUNET_SERVICE_register_ ( * Must be called such that services are actually launched. */ void -GNUNET_SERVICE_main (int argc, char *const *argv); +GNUNET_SERVICE_main (int argc, + char *const *argv, + struct GNUNET_CONFIGURATION_Handle *cfg); /** * Suspend accepting connections from the listen socket temporarily.