![]() |
GNUnet
0.11.x
|
commonly used definitions; globals in this file are exempt from the rule that the module name ("common") must be part of the symbol name. More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_HashCode |
A 512-bit hashcode. More... | |
struct | GNUNET_ShortHashCode |
A 256-bit hashcode. More... | |
struct | GNUNET_Uuid |
A UUID, a 128 bit "random" value. More... | |
struct | GNUNET_MessageHeader |
Header for all communications. More... | |
struct | GNUNET_OperationResultMessage |
Answer from service to client about last operation. More... | |
struct | GNUNET_AsyncScopeId |
Identifier for an asynchronous execution context. More... | |
struct | GNUNET_AsyncScopeSave |
Saved async scope identifier or root scope. More... | |
Macros | |
#define | GNUNET_UTIL_VERSION 0x000A0104 |
Version of the API (for entire gnunetutil.so library). More... | |
#define | GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
#define | GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
#define | GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int)) |
wrap va_arg for enums More... | |
#define | GNUNET_EXTRA_LOGGING 1 |
define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source tree where gnunet_config.h is unavailable More... | |
#define | BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) |
Endian operations. More... | |
#define | BYTE_SWAP_32(x) |
#define | BYTE_SWAP_64(x) |
#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) |
#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) |
#define | GNUNET_NZL(l) GNUNET_MAX (1, l) |
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length). More... | |
#define | GNUNET_PACKED __attribute__ ((packed)) |
gcc-ism to get packed structs. More... | |
#define | GNUNET_GCC_STRUCT_LAYOUT |
gcc-ism to get gcc bitfield layout when compiling with -mms-bitfields More... | |
#define | GNUNET_ALIGN __attribute__ ((aligned (8))) |
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's. More... | |
#define | GNUNET_UNUSED __attribute__ ((unused)) |
gcc-ism to document unused arguments More... | |
#define | GNUNET_NORETURN __attribute__ ((noreturn)) |
gcc-ism to document functions that don't return More... | |
#define | GNUNET_NETWORK_STRUCT_BEGIN |
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32. More... | |
#define | GNUNET_NETWORK_STRUCT_END |
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;. More... | |
#define | GN_LIKELY(expr) (expr) |
#define | GN_UNLIKELY(expr) (expr) |
#define | GNUNET_LOG_CALL_STATUS -1 |
#define | GNUNET_log_from(kind, comp, ...) |
#define | GNUNET_log(kind, ...) |
#define | GNUNET_B2S(obj) GNUNET_b2s ((obj), sizeof (*(obj))) |
Convert a fixed-sized object to a string using GNUNET_b2s(). More... | |
#define | GNUNET_assert(cond) |
Use this for fatal errors that cannot be handled. More... | |
#define | GNUNET_assert_at(cond, f, l) |
Use this for fatal errors that cannot be handled. More... | |
#define | GNUNET_assert_from(cond, comp) |
Use this for fatal errors that cannot be handled. More... | |
#define | GNUNET_static_assert(cond) GNUNET_assert (cond) |
Assertion to be checked (if supported by C compiler) at compile time, otherwise checked at runtime and resulting in an abort() on failure. More... | |
#define | GNUNET_break(cond) |
Use this for internal assertion violations that are not fatal (can be handled) but should not occur. More... | |
#define | GNUNET_break_op(cond) |
Use this for assertion violations caused by other peers (i.e. More... | |
#define | GNUNET_log_strerror(level, cmd) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by strerror(errno). More... | |
#define | GNUNET_log_from_strerror(level, component, cmd) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by strerror(errno). More... | |
#define | GNUNET_log_strerror_file(level, cmd, filename) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by strerror(errno). More... | |
#define | GNUNET_log_from_strerror_file(level, component, cmd, filename) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by strerror(errno). More... | |
#define | GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40) |
Maximum allocation with GNUNET_malloc macro. More... | |
#define | GNUNET_new(type) (type *) GNUNET_malloc (sizeof(type)) |
Allocate a struct or union of the given type. More... | |
#define | GNUNET_memcmp(a, b) |
Compare memory in a and b, where both must be of the same pointer type. More... | |
#define | GNUNET_memcmp_priv(a, b) |
Compare memory in a and b in constant time, suitable for private data. More... | |
#define | GNUNET_is_zero(a) GNUNET_is_zero_ ((a), sizeof (*(a))) |
Check that memory in a is all zeros. More... | |
#define | GNUNET_memcpy(dst, src, n) |
Call memcpy() but check for n being 0 first. More... | |
#define | GNUNET_new_array(n, type) |
Allocate a size n array with structs or unions of the given type. More... | |
#define | GNUNET_new_array_2d(n, m, type) (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__) |
Allocate a size n times m array with structs or unions of the given type. More... | |
#define | GNUNET_new_array_3d(n, m, o, type) (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, __LINE__) |
Allocate a size n times m times o array with structs or unions of the given type. More... | |
#define | GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__) |
Wrapper around malloc. More... | |
#define | GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__) |
Allocate and initialize a block of memory. More... | |
#define | GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) |
Wrapper around malloc. More... | |
#define | GNUNET_realloc(ptr, size) GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) |
Wrapper around realloc. More... | |
#define | GNUNET_free_nz(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) |
Wrapper around free. More... | |
#define | GNUNET_free(ptr) |
Wrapper around free. More... | |
#define | GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) |
Wrapper around GNUNET_xstrdup_. More... | |
#define | GNUNET_strndup(a, length) GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) |
Wrapper around GNUNET_xstrndup_. More... | |
#define | GNUNET_array_grow(arr, size, tsize) |
Grow a well-typed (!) array. More... | |
#define | GNUNET_array_append(arr, len, element) |
Append an element to an array (growing the array by one). More... | |
#define | GNUNET_array_concatenate(arr1, len1, arr2, len2) |
Append arr2 to arr1 (growing arr1 as needed). More... | |
#define | __func__ "<unknown>" |
Typedefs | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_FileNameCallback) (void *cls, const char *filename) |
Function called with a filename. More... | |
typedef void(* | GNUNET_ContinuationCallback) (void *cls) |
Generic continuation callback. More... | |
typedef void(* | GNUNET_ResultCallback) (void *cls, int64_t result_code, const void *data, uint16_t data_size) |
Function called with the result of an asynchronous operation. More... | |
typedef void(* | GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind, const char *component, const char *date, const char *message) |
User-defined handler for log messages. More... | |
Enumerations | |
enum | GNUNET_GenericReturnValue { GNUNET_SYSERR = -1 , GNUNET_NO = 0 , GNUNET_OK = 1 , GNUNET_YES = 1 } |
Named constants for return values. More... | |
enum | GNUNET_ErrorType { GNUNET_ERROR_TYPE_UNSPECIFIED = -1 , GNUNET_ERROR_TYPE_NONE = 0 , GNUNET_ERROR_TYPE_ERROR = 1 , GNUNET_ERROR_TYPE_WARNING = 2 , 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 } |
Types of errors. More... | |
enum | GNUNET_SCHEDULER_Priority { GNUNET_SCHEDULER_PRIORITY_KEEP = 0 , GNUNET_SCHEDULER_PRIORITY_IDLE = 1 , GNUNET_SCHEDULER_PRIORITY_BACKGROUND = 2 , GNUNET_SCHEDULER_PRIORITY_DEFAULT = 3 , GNUNET_SCHEDULER_PRIORITY_HIGH = 4 , GNUNET_SCHEDULER_PRIORITY_UI = 5 , GNUNET_SCHEDULER_PRIORITY_URGENT = 6 , GNUNET_SCHEDULER_PRIORITY_SHUTDOWN = 7 , GNUNET_SCHEDULER_PRIORITY_COUNT = 8 } |
Valid task priorities. More... | |
Functions | |
int | GNUNET_get_log_skip (void) |
Get the number of log calls that are going to be skipped. More... | |
int | GNUNET_get_log_call_status (int caller_level, const char *comp, const char *file, const char *function, int line) |
Decides whether a particular logging call should or should not be allowed to be made. More... | |
void | GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message,...) __attribute__((format(printf |
Main log function. More... | |
void | GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp, const char *message,...) __attribute__((format(printf |
Log function that specifies an alternative component. More... | |
void | GNUNET_log_config_missing (enum GNUNET_ErrorType kind, const char *section, const char *option) |
Log error message about missing configuration option. More... | |
void | GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required) |
Log error message about invalid configuration option value. More... | |
void | GNUNET_abort_ (void) __attribute__((noreturn)) |
Abort the process, generate a core dump if possible. More... | |
const char * | GNUNET_b2s (const void *buf, size_t buf_size) |
Convert a buffer to an 8-character string representative of the contents. More... | |
void | GNUNET_log_skip (int n, int check_reset) |
Ignore the next n calls to the log function. More... | |
int | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile) |
Setup logging. More... | |
void | GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls) |
Add a custom logger. More... | |
void | GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) |
Remove a custom logger. More... | |
const char * | GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc) |
Convert a short hash value to a string (for printing debug messages). More... | |
const char * | GNUNET_uuid2s (const struct GNUNET_Uuid *uuid) |
Convert a UUID to a string (for printing debug messages). More... | |
const char * | GNUNET_h2s (const struct GNUNET_HashCode *hc) |
Convert a hash value to a string (for printing debug messages). More... | |
const char * | GNUNET_h2s2 (const struct GNUNET_HashCode *hc) |
Convert a hash value to a string (for printing debug messages). More... | |
const char * | GNUNET_h2s_full (const struct GNUNET_HashCode *hc) |
Convert a hash value to a string (for printing debug messages). More... | |
const char * | GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p) |
Convert a public key value to a string (for printing debug messages). More... | |
const char * | GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p) |
Convert a public key value to a string (for printing debug messages). More... | |
const char * | GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p) |
Convert a public key value to a string (for printing debug messages). More... | |
const char * | GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p) |
Convert a public key value to a string (for printing debug messages). More... | |
const char * | GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) |
Convert a peer identity to a string (for printing debug messages). More... | |
const char * | GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid) |
Convert a peer identity to a string (for printing debug messages). More... | |
const char * | GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid) |
Convert a peer identity to a string (for printing debug messages). More... | |
const char * | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) |
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages). More... | |
const char * | GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) |
Convert error type to string. More... | |
uint64_t | GNUNET_htonll (uint64_t n) |
Convert unsigned 64-bit integer to network byte order. More... | |
uint64_t | GNUNET_ntohll (uint64_t n) |
Convert unsigned 64-bit integer to host byte order. More... | |
double | GNUNET_hton_double (double d) |
Convert double to network byte order. More... | |
double | GNUNET_ntoh_double (double d) |
Convert double to host byte order. More... | |
int | GNUNET_memcmp_ct_ (const void *b1, const void *b2, size_t len) |
Compare memory in b1 and b2 in constant time, suitable for private data. More... | |
enum GNUNET_GenericReturnValue | GNUNET_is_zero_ (const void *a, size_t n) |
Check that memory in a is all zeros. More... | |
int | GNUNET_snprintf (char *buf, size_t size, const char *format,...) __attribute__((format(printf |
Like snprintf, just aborts if the buffer is of insufficient size. More... | |
int int | GNUNET_asprintf (char **buf, const char *format,...) __attribute__((format(printf |
Like asprintf, just portable. More... | |
int int void * | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber) |
Allocate memory. More... | |
void ** | GNUNET_xnew_array_2d_ (size_t n, size_t m, size_t elementSize, const char *filename, int linenumber) |
Allocate memory for a two dimensional array in one block and set up pointers. More... | |
void *** | GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize, const char *filename, int linenumber) |
Allocate memory for a three dimensional array in one block and set up pointers. More... | |
void * | GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, int linenumber) |
Allocate and initialize memory. More... | |
void * | GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber) |
Allocate memory. More... | |
void * | GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) |
Reallocate memory. More... | |
void | GNUNET_xfree_ (void *ptr, const char *filename, int linenumber) |
Free memory. More... | |
char * | GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber) |
Dup a string. More... | |
char * | GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, int linenumber) |
Dup partially a string. More... | |
void | GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, unsigned int newCount, const char *filename, int linenumber) |
Grow an array, the new elements are zeroed out. More... | |
struct GNUNET_MessageHeader * | GNUNET_copy_message (const struct GNUNET_MessageHeader *msg) |
Create a copy of the given message. More... | |
void | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, struct GNUNET_AsyncScopeSave *old_scope) |
Set the async scope for the current thread. More... | |
void | GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope) |
Clear the current thread's async scope. More... | |
void | GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret) |
Get the current async scope. More... | |
void | GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret) |
Generate a fresh async scope identifier. More... | |
commonly used definitions; globals in this file are exempt from the rule that the module name ("common") must be part of the symbol name.
Definition in file gnunet_common.h.
#define GNUNET_UTIL_VERSION 0x000A0104 |
Version of the API (for entire gnunetutil.so library).
Definition at line 82 of file gnunet_common.h.
#define GNUNET_MIN | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
Definition at line 101 of file gnunet_common.h.
#define GNUNET_MAX | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
Definition at line 103 of file gnunet_common.h.
#define GNUNET_VA_ARG_ENUM | ( | va, | |
X | |||
) | ((enum X) va_arg (va, int)) |
wrap va_arg for enums
Definition at line 137 of file gnunet_common.h.
#define BYTE_SWAP_16 | ( | x | ) | ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) |
Endian operations.
Definition at line 159 of file gnunet_common.h.
#define BYTE_SWAP_32 | ( | x | ) |
Definition at line 161 of file gnunet_common.h.
#define BYTE_SWAP_64 | ( | x | ) |
Definition at line 165 of file gnunet_common.h.
#define GNUNET_htobe16 | ( | x | ) | BYTE_SWAP_16 (x) |
Definition at line 189 of file gnunet_common.h.
#define GNUNET_htole16 | ( | x | ) | (x) |
Definition at line 190 of file gnunet_common.h.
#define GNUNET_be16toh | ( | x | ) | BYTE_SWAP_16 (x) |
Definition at line 191 of file gnunet_common.h.
#define GNUNET_le16toh | ( | x | ) | (x) |
Definition at line 192 of file gnunet_common.h.
#define GNUNET_htobe32 | ( | x | ) | BYTE_SWAP_32 (x) |
Definition at line 194 of file gnunet_common.h.
#define GNUNET_htole32 | ( | x | ) | (x) |
Definition at line 195 of file gnunet_common.h.
#define GNUNET_be32toh | ( | x | ) | BYTE_SWAP_32 (x) |
Definition at line 196 of file gnunet_common.h.
#define GNUNET_le32toh | ( | x | ) | (x) |
Definition at line 197 of file gnunet_common.h.
#define GNUNET_htobe64 | ( | x | ) | BYTE_SWAP_64 (x) |
Definition at line 199 of file gnunet_common.h.
#define GNUNET_htole64 | ( | x | ) | (x) |
Definition at line 200 of file gnunet_common.h.
#define GNUNET_be64toh | ( | x | ) | BYTE_SWAP_64 (x) |
Definition at line 201 of file gnunet_common.h.
#define GNUNET_le64toh | ( | x | ) | (x) |
Definition at line 202 of file gnunet_common.h.
#define GNUNET_htobe16 | ( | x | ) | (x) |
Definition at line 189 of file gnunet_common.h.
#define GNUNET_htole16 | ( | x | ) | BYTE_SWAP_16 (x) |
Definition at line 190 of file gnunet_common.h.
#define GNUNET_be16toh | ( | x | ) | (x) |
Definition at line 191 of file gnunet_common.h.
#define GNUNET_le16toh | ( | x | ) | BYTE_SWAP_16 (x) |
Definition at line 192 of file gnunet_common.h.
#define GNUNET_htobe32 | ( | x | ) | (x) |
Definition at line 194 of file gnunet_common.h.
#define GNUNET_htole32 | ( | x | ) | BYTE_SWAP_32 (x) |
Definition at line 195 of file gnunet_common.h.
#define GNUNET_be32toh | ( | x | ) | (x) |
Definition at line 196 of file gnunet_common.h.
#define GNUNET_le32toh | ( | x | ) | BYTE_SWAP_32 (x) |
Definition at line 197 of file gnunet_common.h.
#define GNUNET_htobe64 | ( | x | ) | (x) |
Definition at line 199 of file gnunet_common.h.
#define GNUNET_htole64 | ( | x | ) | BYTE_SWAP_64 (x) |
Definition at line 200 of file gnunet_common.h.
#define GNUNET_be64toh | ( | x | ) | (x) |
Definition at line 201 of file gnunet_common.h.
#define GNUNET_le64toh | ( | x | ) | BYTE_SWAP_64 (x) |
Definition at line 202 of file gnunet_common.h.
#define GNUNET_NZL | ( | l | ) | GNUNET_MAX (1, l) |
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".
Definition at line 218 of file gnunet_common.h.
#define GNUNET_PACKED __attribute__ ((packed)) |
gcc-ism to get packed structs.
Definition at line 224 of file gnunet_common.h.
#define GNUNET_GCC_STRUCT_LAYOUT |
gcc-ism to get gcc bitfield layout when compiling with -mms-bitfields
Definition at line 229 of file gnunet_common.h.
#define GNUNET_ALIGN __attribute__ ((aligned (8))) |
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.
Definition at line 239 of file gnunet_common.h.
#define GNUNET_UNUSED __attribute__ ((unused)) |
gcc-ism to document unused arguments
Definition at line 245 of file gnunet_common.h.
#define GNUNET_NORETURN __attribute__ ((noreturn)) |
gcc-ism to document functions that don't return
Definition at line 250 of file gnunet_common.h.
#define GNUNET_NETWORK_STRUCT_BEGIN |
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
Definition at line 255 of file gnunet_common.h.
#define GNUNET_NETWORK_STRUCT_END |
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
Definition at line 260 of file gnunet_common.h.
#define GN_LIKELY | ( | expr | ) | (expr) |
Definition at line 501 of file gnunet_common.h.
#define GN_UNLIKELY | ( | expr | ) | (expr) |
Definition at line 502 of file gnunet_common.h.
#define GNUNET_LOG_CALL_STATUS -1 |
Definition at line 506 of file gnunet_common.h.
#define GNUNET_log_from | ( | kind, | |
comp, | |||
... | |||
) |
Definition at line 528 of file gnunet_common.h.
#define GNUNET_log | ( | kind, | |
... | |||
) |
Definition at line 554 of file gnunet_common.h.
#define GNUNET_B2S | ( | obj | ) | GNUNET_b2s ((obj), sizeof (*(obj))) |
Convert a fixed-sized object to a string using GNUNET_b2s().
obj | address of object to convert |
Definition at line 647 of file gnunet_common.h.
#define GNUNET_static_assert | ( | cond | ) | GNUNET_assert (cond) |
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.
cond | condition to test, 0 implies failure |
Definition at line 1001 of file gnunet_common.h.
#define GNUNET_memcmp | ( | a, | |
b | |||
) |
Compare memory in a and b, where both must be of the same pointer type.
Do NOT use this function on arrays, it would only compare the first element!
Definition at line 1210 of file gnunet_common.h.
#define GNUNET_memcmp_priv | ( | a, | |
b | |||
) |
Compare memory in a and b in constant time, suitable for private data.
Both a and b must be of the same pointer type.
Do NOT use this function on arrays, it would only compare the first element!
Definition at line 1239 of file gnunet_common.h.
#define GNUNET_is_zero | ( | a | ) | GNUNET_is_zero_ ((a), sizeof (*(a))) |
Check that memory in a is all zeros.
a must be a pointer.
a | pointer to a struct which should be tested for the entire memory being zero'ed out. |
Definition at line 1267 of file gnunet_common.h.
#define GNUNET_memcpy | ( | dst, | |
src, | |||
n | |||
) |
Call memcpy() but check for n being 0 first.
In the latter case, it is now safe to pass NULL for src or dst. Unlike traditional memcpy(), returns nothing.
dst | destination of the copy, may be NULL if n is zero |
src | source of the copy, may be NULL if n is zero |
n | number of bytes to copy |
Definition at line 1280 of file gnunet_common.h.
#define __func__ "<unknown>" |
Definition at line 1780 of file gnunet_common.h.
typedef enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback) (void *cls, const char *filename) |
Function called with a filename.
cls | closure |
filename | complete filename (absolute path) |
Definition at line 1 of file gnunet_common.h.
typedef void(* GNUNET_ContinuationCallback) (void *cls) |
Generic continuation callback.
cls | Closure. |
Definition at line 390 of file gnunet_common.h.
typedef void(* GNUNET_ResultCallback) (void *cls, int64_t result_code, const void *data, uint16_t data_size) |
Function called with the result of an asynchronous operation.
cls | Closure. |
result_code | Result code for the operation. |
data | Data result for the operation. |
data_size | Size of data. |
Definition at line 406 of file gnunet_common.h.
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
.
Enumerator | |
---|---|
GNUNET_SYSERR | |
GNUNET_NO | |
GNUNET_OK | |
GNUNET_YES |
Definition at line 91 of file gnunet_common.h.
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.
Definition at line 1792 of file gnunet_common.h.
int GNUNET_get_log_call_status | ( | int | caller_level, |
const char * | comp, | ||
const char * | file, | ||
const char * | function, | ||
int | line | ||
) |
Decides whether a particular logging call should or should not be allowed to be made.
Used internally by GNUNET_log*()
caller_level | loglevel the caller wants to use |
comp | component name the caller uses (NULL means that global component name is used) |
file | file name containing the logging call, usually FILE |
function | function which tries to make a logging call, usually FUNCTION |
line | line at which the call is made, usually LINE |
Definition at line 501 of file common_logging.c.
References component_nopid, LogDef::component_regex, LogDef::file_regex, LogDef::force, LogDef::from_line, LogDef::function_regex, GNUNET_ERROR_TYPE_MESSAGE, gnunet_force_log_present, GNUNET_NO, LogDef::level, line, logdefs, logdefs_len, min_level, and LogDef::to_line.
Referenced by GCCH_debug(), GCT_debug(), and get_nick_record().
const char* GNUNET_b2s | ( | const void * | buf, |
size_t | buf_size | ||
) |
Convert a buffer to an 8-character string representative of the contents.
This is used for logging binary data when debugging.
buf | buffer to log |
buf_size | number of bytes in buf |
Definition at line 325 of file common_logging.c.
References buf, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_THREAD_LOCAL, and ret.
uint64_t GNUNET_htonll | ( | uint64_t | n | ) |
Convert unsigned 64-bit integer to network byte order.
n | The value in host byte order. |
Definition at line 36 of file common_endian.c.
Referenced by abd_string_to_value(), block_proc(), change_service(), commit_set(), consider_sending_fc(), create_loc_uri(), determine_id(), GCCH_handle_channel_plaintext_data_ack(), GNUNET_ABD_delegate_issue(), GNUNET_ABD_delegate_serialize(), GNUNET_ABD_delegates_serialize(), GNUNET_ARM_request_service_list(), GNUNET_BIO_write_int64(), GNUNET_CRYPTO_ecc_scalar_from_int(), GNUNET_CRYPTO_random_timeflake(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_reserve(), GNUNET_FS_tree_encoder_next(), GNUNET_GNSRECORD_records_serialize(), GNUNET_hton_double(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_relative_time(), GNUNET_PQ_query_param_uint64(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_credential_store(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_generate_peergetconfig_msg_(), GNUNET_TESTBED_generate_slavegetconfig_msg_(), GST_send_operation_fail_msg(), GST_send_operation_success_msg(), handle_client_accept(), hash_for_index_cb(), notify_change(), opstart_manage_service(), opstart_overlay_connect(), opstart_peer_create(), opstart_peer_destroy(), opstart_peer_reconfigure(), opstart_peer_start(), opstart_peer_stop(), opstart_shutdown_peers(), p2_controller_connect_cb(), print_record(), run(), save(), send_ack(), send_add_queue(), send_channel_data_ack(), send_client_done(), send_client_element(), send_controller_link_response(), send_hello_thru_rocc(), send_overlay_connect_success_msg(), send_update_queue(), signal_result(), transmit(), transmit_item(), transmit_set(), unindex_process(), union_accept(), uri_chk_parse(), and uri_loc_parse().
uint64_t GNUNET_ntohll | ( | uint64_t | n | ) |
Convert unsigned 64-bit integer to host byte order.
n | The value in network byte order. |
Definition at line 53 of file common_endian.c.
Referenced by abd_value_to_string(), backward_resolution(), cb_intersection_element_removed(), cmp_pow_value(), copy_element_cb(), find_proof(), forward_overlay_connect(), GNUNET_ABD_delegate_deserialize(), GNUNET_ABD_delegates_deserialize(), GNUNET_BIO_read_int64(), GNUNET_CRYPTO_hash_count_leading_zeros(), GNUNET_CRYPTO_hash_count_tailing_zeros(), GNUNET_FRAGMENT_print_ack(), GNUNET_FRAGMENT_process_ack(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_publish_stop(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_ntoh_double(), GNUNET_xfree_(), GNUNET_xrealloc_(), handle_add_queue_message(), handle_alice_client_message(), handle_arm_list_result(), handle_arm_result(), handle_attribute_store_message(), handle_bob_client_message(), handle_client_index_start(), handle_client_loc_sign(), handle_credential_store_message(), handle_data(), handle_flow_control(), handle_get(), handle_get_key(), handle_get_zero_anonymity(), handle_iteration_next(), handle_link_controllers(), handle_link_controllers_result(), handle_manage_peer_service(), handle_monitor_next(), handle_op_fail_event(), handle_opsuccess(), handle_overlay_connect(), handle_peer_conevent(), handle_peer_config(), handle_peer_create(), handle_peer_create_success(), handle_peer_destroy(), handle_peer_event(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_remote_overlay_connect(), handle_reserve(), handle_result(), handle_set(), handle_shutdown_peers(), handle_slave_config(), handle_slave_get_config(), handle_start(), handle_statistics_value(), handle_statistics_watch_value(), handle_stop(), handle_union_p2p_strata_estimator(), handle_update_queue_message(), process_result_with_request(), reconstruct_cb(), set_result_cb(), try_match_block(), uri_chk_to_string(), uri_loc_to_string(), and verify_message_crypto().
double GNUNET_hton_double | ( | double | d | ) |
Convert double to network byte order.
d | The value in host byte order. |
Convert double to network byte order.
d | the value in network byte order |
Definition at line 74 of file common_endian.c.
References GNUNET_htonll(), and res.
Referenced by setup_estimate_message().
double GNUNET_ntoh_double | ( | double | d | ) |
Convert double to host byte order.
d | The value in network byte order. |
Convert double to host byte order.
d | the value in network byte order |
Definition at line 92 of file common_endian.c.
References GNUNET_ntohll(), and res.
Referenced by handle_estimate().
int GNUNET_memcmp_ct_ | ( | const void * | b1, |
const void * | b2, | ||
size_t | len | ||
) |
Compare memory in b1 and b2 in constant time, suitable for private data.
b1 | some buffer of size len |
b2 | another buffer of size len |
len | number of bytes in b1 and b2 |
Definition at line 130 of file consttime_memcmp.c.
References consensus-simulation::int, len, and m.
enum GNUNET_GenericReturnValue GNUNET_is_zero_ | ( | const void * | a, |
size_t | n | ||
) |
Check that memory in a is all zeros.
a must be a pointer.
a | pointer to n bytes which should be tested for the entire memory being zero'ed out. |
n | number of bytes in to be tested |
Definition at line 486 of file common_allocation.c.
int int void* GNUNET_xmalloc_ | ( | size_t | size, |
const char * | filename, | ||
int | linenumber | ||
) |
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.
size | number of bytes to allocate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Checks the return value, aborts if no more memory is available.
size | how many bytes of memory to allocate, do NOT use this function (or GNUNET_malloc()) to allocate more than several MB of memory, if you are possibly needing a very large chunk use GNUNET_xmalloc_unchecked_() instead. |
filename | where in the code was the call to GNUNET_malloc() |
linenumber | where in the code was the call to GNUNET_malloc() |
Definition at line 59 of file common_allocation.c.
References filename, GNUNET_assert, GNUNET_assert_at, GNUNET_ERROR_TYPE_ERROR, GNUNET_MAX_MALLOC_CHECKED, GNUNET_xmalloc_unchecked_(), LOG_STRERROR, ret, and size.
Referenced by GNUNET_xgrow_(), GNUNET_xnew_array_2d_(), GNUNET_xnew_array_3d_(), GNUNET_xstrdup_(), and GNUNET_xstrndup_().
void** GNUNET_xnew_array_2d_ | ( | size_t | n, |
size_t | m, | ||
size_t | elementSize, | ||
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.
n | size of the first dimension |
m | size of the second dimension |
elementSize | size of a single element in bytes |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Definition at line 91 of file common_allocation.c.
References filename, GNUNET_xmalloc_(), m, and ret.
void*** GNUNET_xnew_array_3d_ | ( | size_t | n, |
size_t | m, | ||
size_t | o, | ||
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.
n | size of the first dimension |
m | size of the second dimension |
o | size of the third dimension |
elementSize | size of a single element in bytes |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Definition at line 127 of file common_allocation.c.
References filename, GNUNET_xmalloc_(), m, and ret.
void* GNUNET_xmemdup_ | ( | const void * | buf, |
size_t | size, | ||
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.
buf | buffer to initialize from (must contain size bytes) |
size | number of bytes to allocate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Checks the return value, aborts if no more memory is available. Don't use GNUNET_xmemdup_() directly. Use the GNUNET_memdup() macro.
buf | buffer to initialize from (must contain size bytes) |
size | number of bytes to allocate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Definition at line 170 of file common_allocation.c.
References buf, filename, GNUNET_assert, GNUNET_assert_at, GNUNET_ERROR_TYPE_ERROR, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, INT_MAX, LOG_STRERROR, ret, and size.
void* GNUNET_xmalloc_unchecked_ | ( | 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.
size | number of bytes to allocate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Allocate memory.
Allocates size bytes of memory. The memory will be zero'ed out.
size | the number of bytes to allocate |
filename | where in the code was the call to GNUNET_malloc_unchecked() |
linenumber | where in the code was the call to GNUNET_malloc_unchecked() |
Definition at line 202 of file common_allocation.c.
References filename, result, and size.
Referenced by GNUNET_xmalloc_().
void* GNUNET_xrealloc_ | ( | void * | ptr, |
size_t | n, | ||
const char * | filename, | ||
int | linenumber | ||
) |
Reallocate memory.
Checks the return value, aborts if no more memory is available.
Checks the return value, aborts if no more memory is available. The content of the intersection of the new and old size will be unchanged.
ptr | the pointer to reallocate |
n | how many bytes of memory to allocate |
filename | where in the code was the call to GNUNET_realloc() |
linenumber | where in the code was the call to GNUNET_realloc() |
Definition at line 230 of file common_allocation.c.
References filename, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_memcpy, GNUNET_MIN, GNUNET_ntohll(), and LOG_STRERROR.
void GNUNET_xfree_ | ( | void * | ptr, |
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.
ptr | pointer to memory to free |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Merely a wrapper for the case that we want to keep track of allocations.
ptr | the pointer to free |
filename | where in the code was the call to GNUNET_free() |
linenumber | where in the code was the call to GNUNET_free() |
Definition at line 294 of file common_allocation.c.
References GNUNET_memcpy, and GNUNET_ntohll().
Referenced by GNUNET_xgrow_().
char* GNUNET_xstrdup_ | ( | const char * | str, |
const char * | filename, | ||
int | linenumber | ||
) |
Dup a string.
Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro.
str | string to duplicate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Dup a string.
str | the string to dup |
filename | where in the code was the call to GNUNET_strdup() |
linenumber | where in the code was the call to GNUNET_strdup() |
strdup(@a str)
Definition at line 326 of file common_allocation.c.
References filename, GNUNET_assert_at, GNUNET_memcpy, GNUNET_xmalloc_(), and res.
char* GNUNET_xstrndup_ | ( | const char * | str, |
size_t | len, | ||
const char * | filename, | ||
int | linenumber | ||
) |
Dup partially a string.
Don't call GNUNET_xstrndup_ directly. Use the GNUNET_strndup macro.
str | string to duplicate |
len | length of the string to duplicate |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Dup partially a string.
str | the string to dup |
len | the length of the string to dup |
filename | where in the code was the call to GNUNET_strndup() |
linenumber | where in the code was the call to GNUNET_strndup() |
strndup(@a str,@a len)
Definition at line 365 of file common_allocation.c.
References filename, GNUNET_assert_at, GNUNET_memcpy, GNUNET_strdup, GNUNET_xmalloc_(), len, res, and strnlen().
void GNUNET_xgrow_ | ( | void ** | old, |
size_t | elementSize, | ||
unsigned int * | oldCount, | ||
unsigned int | newCount, | ||
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.
old | address of the pointer to the array *old may be NULL |
elementSize | the size of the elements of the array |
oldCount | address of the number of elements in the *old array |
newCount | number of elements in the new array, may be 0 (then *old will be NULL afterwards) |
filename | where is this call being made (for debugging) |
linenumber | line where this call is being made (for debugging) |
Grow an array, the new elements are zeroed out.
Grows old by (*oldCount-newCount)*elementSize bytes and sets *oldCount to newCount.
old | address of the pointer to the array *old may be NULL |
elementSize | the size of the elements of the array |
oldCount | address of the number of elements in the *old array |
newCount | number of elements in the new array, may be 0 |
filename | where in the code was the call to GNUNET_array_grow() |
linenumber | where in the code was the call to GNUNET_array_grow() |
Definition at line 396 of file common_allocation.c.
References filename, GNUNET_assert_at, GNUNET_memcpy, GNUNET_MIN, GNUNET_xfree_(), GNUNET_xmalloc_(), INT_MAX, and size.
void GNUNET_async_scope_enter | ( | const struct GNUNET_AsyncScopeId * | aid, |
struct GNUNET_AsyncScopeSave * | old_scope | ||
) |
Set the async scope for the current thread.
aid | the async scope identifier |
old_scope[out] | location to save the old scope |
Definition at line 1524 of file common_logging.c.
References current_async_scope, GNUNET_YES, GNUNET_AsyncScopeSave::have_scope, and GNUNET_AsyncScopeSave::scope_id.
Referenced by GNUNET_SCHEDULER_begin_async_scope(), and GNUNET_SCHEDULER_do_work().
void GNUNET_async_scope_restore | ( | struct GNUNET_AsyncScopeSave * | old_scope | ) |
Clear the current thread's async scope.
old_scope | scope to restore |
Definition at line 1539 of file common_logging.c.
References current_async_scope.
Referenced by GNUNET_SCHEDULER_do_work().
void GNUNET_async_scope_get | ( | struct GNUNET_AsyncScopeSave * | scope_ret | ) |
Get the current async scope.
[out] | scope_ret | pointer to where the result is stored |
Definition at line 1565 of file common_logging.c.
References current_async_scope.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_do_work(), and setup_job_headers().
void GNUNET_async_scope_fresh | ( | struct GNUNET_AsyncScopeId * | aid_ret | ) |
Generate a fresh async scope identifier.
[out] | aid_ret | pointer to where the result is stored |
Definition at line 1551 of file common_logging.c.
References GNUNET_CRYPTO_QUALITY_WEAK, and GNUNET_CRYPTO_random_block().