GNUnet  0.11.x
gnunet_common.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2006-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
36 #ifndef GNUNET_COMMON_H
37 #define GNUNET_COMMON_H
38 
39 #if HAVE_SYS_SOCKET_H
40 #include <sys/socket.h>
41 #endif
42 #if HAVE_NETINET_IN_H
43 #include <netinet/in.h>
44 #endif
45 #ifdef HAVE_STDINT_H
46 #include <stdint.h>
47 #endif
48 #ifdef HAVE_STDARG_H
49 #include <stdarg.h>
50 #endif
51 
52 #ifdef HAVE_BYTESWAP_H
53 #include <byteswap.h>
54 #endif
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #if 0 /* keep Emacsens' auto-indent happy */
59 }
60 #endif
61 #endif
62 
66 #define GNUNET_UTIL_VERSION 0x000A0103
67 
68 
75 #define GNUNET_OK 1
76 #define GNUNET_SYSERR -1
77 #define GNUNET_YES 1
78 #define GNUNET_NO 0
79 
80 #define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b))
81 
82 #define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b))
83 
84 /* some systems use one underscore only, and mingw uses no underscore... */
85 #ifndef __BYTE_ORDER
86 #ifdef _BYTE_ORDER
87 #define __BYTE_ORDER _BYTE_ORDER
88 #else
89 #ifdef BYTE_ORDER
90 #define __BYTE_ORDER BYTE_ORDER
91 #endif
92 #endif
93 #endif
94 #ifndef __BIG_ENDIAN
95 #ifdef _BIG_ENDIAN
96 #define __BIG_ENDIAN _BIG_ENDIAN
97 #else
98 #ifdef BIG_ENDIAN
99 #define __BIG_ENDIAN BIG_ENDIAN
100 #endif
101 #endif
102 #endif
103 #ifndef __LITTLE_ENDIAN
104 #ifdef _LITTLE_ENDIAN
105 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
106 #else
107 #ifdef LITTLE_ENDIAN
108 #define __LITTLE_ENDIAN LITTLE_ENDIAN
109 #endif
110 #endif
111 #endif
112 
116 #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int))
117 
118 
124 #ifndef GNUNET_EXTRA_LOGGING
125 #define GNUNET_EXTRA_LOGGING 0
126 #endif
127 
132 #if __BYTE_ORDER == __LITTLE_ENDIAN
133 #define GNUNET_htobe16(x) __bswap_16 (x)
134 #define GNUNET_htole16(x) (x)
135 #define GNUNET_be16toh(x) __bswap_16 (x)
136 #define GNUNET_le16toh(x) (x)
137 
138 #define GNUNET_htobe32(x) __bswap_32 (x)
139 #define GNUNET_htole32(x) (x)
140 #define GNUNET_be32toh(x) __bswap_32 (x)
141 #define GNUNET_le32toh(x) (x)
142 
143 #define GNUNET_htobe64(x) __bswap_64 (x)
144 #define GNUNET_htole64(x) (x)
145 #define GNUNET_be64toh(x) __bswap_64 (x)
146 #define GNUNET_le64toh(x) (x)
147 #endif
148 #if __BYTE_ORDER == __BIG_ENDIAN
149 #define GNUNET_htobe16(x) (x)
150 #define GNUNET_htole16(x) __bswap_16 (x)
151 #define GNUNET_be16toh(x) (x)
152 #define GNUNET_le16toh(x) __bswap_16 (x)
153 
154 #define GNUNET_htobe32(x) (x)
155 #define GNUNET_htole32(x) __bswap_32 (x)
156 #define GNUNET_be32toh(x) (x)
157 #define GNUNET_le32toh(x) __bswap_32 (x)
158 
159 #define GNUNET_htobe64(x) (x)
160 #define GNUNET_htole64(x) __bswap_64 (x)
161 #define GNUNET_be64toh(x) (x)
162 #define GNUNET_le64toh(x) __bswap_64 (x)
163 #endif
164 
165 
178 #define GNUNET_NZL(l) GNUNET_MAX (1, l)
179 
180 
184 #define GNUNET_PACKED __attribute__ ((packed))
185 
189 #define GNUNET_GCC_STRUCT_LAYOUT
190 
196 #ifdef __BIGGEST_ALIGNMENT__
197 #define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)))
198 #else
199 #define GNUNET_ALIGN __attribute__ ((aligned (8)))
200 #endif
201 
205 #define GNUNET_UNUSED __attribute__ ((unused))
206 
210 #define GNUNET_NORETURN __attribute__ ((noreturn))
211 
215 #define GNUNET_NETWORK_STRUCT_BEGIN
216 
220 #define GNUNET_NETWORK_STRUCT_END
221 
222 /* ************************ super-general types *********************** */
223 
225 
230 {
231  uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */
232 };
233 
234 
240 {
241  uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */
242 };
243 
244 
249 {
253  uint32_t value[4];
254 };
255 
256 
261 {
266  uint16_t size GNUNET_PACKED;
267 
271  uint16_t type GNUNET_PACKED;
272 };
273 
274 
279 {
280  struct GNUNET_MessageHeader header;
281 
283 
287  uint64_t op_id GNUNET_PACKED;
288 
292  uint64_t result_code GNUNET_PACKED;
293 
294  /* Followed by data. */
295 };
296 
297 
302 {
303  uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */
304 };
305 
307 
308 
313 {
317  struct GNUNET_AsyncScopeId scope_id;
318 
323 };
324 
325 
335 typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
336 
337 
343 typedef void (*GNUNET_ContinuationCallback) (void *cls);
344 
345 
358 typedef void (*GNUNET_ResultCallback) (void *cls,
359  int64_t result_code,
360  const void *data,
361  uint16_t data_size);
362 
363 
364 /* ****************************** logging ***************************** */
365 
371 {
376  /* UX: We need a message type that is output by
377  * default without looking like there is a problem.
378  */
384 };
385 
386 
397 typedef void (*GNUNET_Logger) (void *cls,
398  enum GNUNET_ErrorType kind,
399  const char *component,
400  const char *date,
401  const char *message);
402 
403 
410 int
411 GNUNET_get_log_skip (void);
412 
413 
414 #if ! defined(GNUNET_CULL_LOGGING)
415 int
416 GNUNET_get_log_call_status (int caller_level,
417  const char *comp,
418  const char *file,
419  const char *function,
420  int line);
421 
422 #endif
423 
424 
433 void
434 GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
435 __attribute__ ((format (printf, 2, 3)));
436 
437 /* from glib */
438 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
439 #define _GNUNET_BOOLEAN_EXPR(expr) \
440  __extension__ ({ \
441  int _gnunet_boolean_var_; \
442  if (expr) \
443  _gnunet_boolean_var_ = 1; \
444  else \
445  _gnunet_boolean_var_ = 0; \
446  _gnunet_boolean_var_; \
447  })
448 #define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
449 #define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
450 #else
451 #define GN_LIKELY(expr) (expr)
452 #define GN_UNLIKELY(expr) (expr)
453 #endif
454 
455 #if ! defined(GNUNET_LOG_CALL_STATUS)
456 #define GNUNET_LOG_CALL_STATUS -1
457 #endif
458 
459 
470 void
472  const char *comp,
473  const char *message,
474  ...);
475 
476 #if ! defined(GNUNET_CULL_LOGGING)
477 #define GNUNET_log_from(kind, comp, ...) \
478  do \
479  { \
480  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
481  if ((GNUNET_EXTRA_LOGGING > 0) || \
482  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
483  { \
484  if (GN_UNLIKELY (log_call_enabled == -1)) \
485  log_call_enabled = \
486  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
487  (comp), \
488  __FILE__, \
489  __FUNCTION__, \
490  __LINE__); \
491  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
492  { \
493  GNUNET_log_skip (-1, GNUNET_NO); \
494  } \
495  else \
496  { \
497  if (GN_UNLIKELY (log_call_enabled)) \
498  GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
499  } \
500  } \
501  } while (0)
502 
503 #define GNUNET_log(kind, ...) \
504  do \
505  { \
506  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
507  if ((GNUNET_EXTRA_LOGGING > 0) || \
508  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
509  { \
510  if (GN_UNLIKELY (log_call_enabled == -1)) \
511  log_call_enabled = \
512  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
513  NULL, \
514  __FILE__, \
515  __FUNCTION__, \
516  __LINE__); \
517  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
518  { \
519  GNUNET_log_skip (-1, GNUNET_NO); \
520  } \
521  else \
522  { \
523  if (GN_UNLIKELY (log_call_enabled)) \
524  GNUNET_log_nocheck ((kind), __VA_ARGS__); \
525  } \
526  } \
527  } while (0)
528 #else
529 #define GNUNET_log(...)
530 #define GNUNET_log_from(...)
531 #endif
532 
533 
542 void
544  const char *section,
545  const char *option);
546 
547 
557 void
559  const char *section,
560  const char *option,
561  const char *required);
562 
563 
570 void
572 
573 
581 void
582 GNUNET_log_skip (int n, int check_reset);
583 
584 
594 int
595 GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
596 
597 
608 void
609 GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
610 
611 
619 void
620 GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
621 
622 
632 const char *
633 GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc);
634 
635 
645 const char *
646 GNUNET_uuid2s (const struct GNUNET_Uuid *uuid);
647 
648 
658 const char *
659 GNUNET_h2s (const struct GNUNET_HashCode *hc);
660 
661 
673 const char *
674 GNUNET_h2s2 (const struct GNUNET_HashCode *hc);
675 
676 
687 const char *
688 GNUNET_h2s_full (const struct GNUNET_HashCode *hc);
689 
690 
695 
696 
701 
702 
712 const char *
714 
715 
725 const char *
727 
728 
738 const char *
740 
741 
751 const char *
753 
754 
765 const char *
766 GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
767 
768 
781 const char *
782 GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid);
783 
784 
795 const char *
796 GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
797 
798 
810 const char *
811 GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
812 
813 
821 const char *
823 
824 
829 #define GNUNET_assert(cond) \
830  do \
831  { \
832  if (! (cond)) \
833  { \
834  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
835  _ ("Assertion failed at %s:%d. Aborting.\n"), \
836  __FILE__, \
837  __LINE__); \
838  GNUNET_abort_ (); \
839  } \
840  } while (0)
841 
842 
847 #define GNUNET_assert_at(cond, f, l) \
848  do \
849  { \
850  if (! (cond)) \
851  { \
852  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
853  _ ("Assertion failed at %s:%d. Aborting.\n"), \
854  f, \
855  l); \
856  GNUNET_abort_ (); \
857  } \
858  } while (0)
859 
860 
868 #define GNUNET_assert_from(cond, comp) \
869  do \
870  { \
871  if (! (cond)) \
872  { \
873  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
874  comp, \
875  _ ("Assertion failed at %s:%d. Aborting.\n"), \
876  __FILE__, \
877  __LINE__); \
878  GNUNET_abort_ (); \
879  } \
880  } while (0)
881 
882 
888 #define GNUNET_break(cond) \
889  do \
890  { \
891  if (! (cond)) \
892  { \
893  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
894  _ ("Assertion failed at %s:%d.\n"), \
895  __FILE__, \
896  __LINE__); \
897  } \
898  } while (0)
899 
900 
910 #define GNUNET_break_op(cond) \
911  do \
912  { \
913  if (! (cond)) \
914  { \
915  GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
916  _ ("External protocol violation detected at %s:%d.\n"), \
917  __FILE__, \
918  __LINE__); \
919  } \
920  } while (0)
921 
922 
929 #define GNUNET_log_strerror(level, cmd) \
930  do \
931  { \
932  GNUNET_log (level, \
933  _ ("`%s' failed at %s:%d with error: %s\n"), \
934  cmd, \
935  __FILE__, \
936  __LINE__, \
937  strerror (errno)); \
938  } while (0)
939 
940 
947 #define GNUNET_log_from_strerror(level, component, cmd) \
948  do \
949  { \
950  GNUNET_log_from (level, \
951  component, \
952  _ ("`%s' failed at %s:%d with error: %s\n"), \
953  cmd, \
954  __FILE__, \
955  __LINE__, \
956  strerror (errno)); \
957  } while (0)
958 
959 
966 #define GNUNET_log_strerror_file(level, cmd, filename) \
967  do \
968  { \
969  GNUNET_log (level, \
970  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
971  cmd, \
972  filename, \
973  __FILE__, \
974  __LINE__, \
975  strerror (errno)); \
976  } while (0)
977 
978 
985 #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
986  do \
987  { \
988  GNUNET_log_from (level, \
989  component, \
990  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
991  cmd, \
992  filename, \
993  __FILE__, \
994  __LINE__, \
995  strerror (errno)); \
996  } while (0)
997 
998 /* ************************* endianess conversion ****************** */
999 
1008 uint64_t
1009 GNUNET_htonll (uint64_t n);
1010 
1011 
1020 uint64_t
1021 GNUNET_ntohll (uint64_t n);
1022 
1023 
1032 double
1033 GNUNET_hton_double (double d);
1034 
1035 
1044 double
1045 GNUNET_ntoh_double (double d);
1046 
1047 
1048 /* ************************* allocation functions ****************** */
1049 
1054 #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
1055 
1064 #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof(type))
1065 
1066 
1071 #define GNUNET_memcmp(a, b) \
1072  ({ \
1073  const typeof (*b) * _a = (a); \
1074  const typeof (*a) * _b = (b); \
1075  memcmp (_a, _b, sizeof(*a)); \
1076  })
1077 
1078 
1085 #define GNUNET_is_zero(a) \
1086  ({ \
1087  static const typeof (*a) _z; \
1088  memcmp ((a), &_z, sizeof(_z)); \
1089  })
1090 
1091 
1101 #define GNUNET_memcpy(dst, src, n) \
1102  do \
1103  { \
1104  if (0 != n) \
1105  { \
1106  (void) memcpy (dst, src, n); \
1107  } \
1108  } while (0)
1109 
1110 
1120 #define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof(type))
1121 
1131 #define GNUNET_new_array_2d(n, m, type) \
1132  (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__)
1133 
1144 #define GNUNET_new_array_3d(n, m, o, type) \
1145  (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, __LINE__)
1146 
1156 #define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__)
1157 
1166 #define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__)
1167 
1176 #define GNUNET_malloc_large(size) \
1177  GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
1178 
1188 #define GNUNET_realloc(ptr, size) \
1189  GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
1190 
1200 #define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
1201 
1209 #define GNUNET_free_non_null(ptr) \
1210  do \
1211  { \
1212  void *__x__ = ptr; \
1213  if (__x__ != NULL) \
1214  { \
1215  GNUNET_free (__x__); \
1216  } \
1217  } while (0)
1218 
1227 #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__)
1228 
1238 #define GNUNET_strndup(a, length) \
1239  GNUNET_xstrndup_ (a, length, __FILE__, __LINE__)
1240 
1276 #define GNUNET_array_grow(arr, size, tsize) \
1277  GNUNET_xgrow_ ((void **) &(arr), \
1278  sizeof((arr)[0]), \
1279  &size, \
1280  tsize, \
1281  __FILE__, \
1282  __LINE__)
1283 
1297 #define GNUNET_array_append(arr, size, element) \
1298  do \
1299  { \
1300  GNUNET_array_grow (arr, size, size + 1); \
1301  (arr) [size - 1] = element; \
1302  } while (0)
1303 
1314 int
1315 GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
1316 
1317 
1327 int
1328 GNUNET_asprintf (char **buf, const char *format, ...);
1329 
1330 
1331 /* ************** internal implementations, use macros above! ************** */
1332 
1344 void *
1345 GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
1346 
1347 
1362 void **
1363 GNUNET_xnew_array_2d_ (size_t n,
1364  size_t m,
1365  size_t elementSize,
1366  const char *filename,
1367  int linenumber);
1368 
1369 
1385 void ***
1386 GNUNET_xnew_array_3d_ (size_t n,
1387  size_t m,
1388  size_t o,
1389  size_t elementSize,
1390  const char *filename,
1391  int linenumber);
1392 
1393 
1405 void *
1406 GNUNET_xmemdup_ (const void *buf,
1407  size_t size,
1408  const char *filename,
1409  int linenumber);
1410 
1411 
1424 void *
1425 GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
1426 
1427 
1432 void *
1433 GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber);
1434 
1435 
1445 void
1446 GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
1447 
1448 
1456 char *
1457 GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
1458 
1468 char *
1469 GNUNET_xstrndup_ (const char *str,
1470  size_t len,
1471  const char *filename,
1472  int linenumber);
1473 
1489 void
1490 GNUNET_xgrow_ (void **old,
1491  size_t elementSize,
1492  unsigned int *oldCount,
1493  unsigned int newCount,
1494  const char *filename,
1495  int linenumber);
1496 
1497 
1505 struct GNUNET_MessageHeader *
1507 
1508 
1515 void
1517  struct GNUNET_AsyncScopeSave *old_scope);
1518 
1519 
1525 void
1527 
1528 
1534 void
1535 GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret);
1536 
1537 
1543 void
1545 
1546 
1547 #if __STDC_VERSION__ < 199901L
1548 #if __GNUC__ >= 2
1549 #define __func__ __FUNCTION__
1550 #else
1551 #define __func__ "<unknown>"
1552 #endif
1553 #endif
1554 
1555 
1564 {
1569 
1574 
1580 
1588 
1594 
1600 
1608 
1618 
1624 };
1625 
1626 
1627 #if 0 /* keep Emacsens' auto-indent happy */
1628 {
1629 #endif
1630 #ifdef __cplusplus
1631 }
1632 #endif
1633 
1634 #endif /* GNUNET_COMMON_H */
void GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls)
Add a custom logger.
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.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
Run with high priority (important requests).
const char * GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void GNUNET_xfree_(void *ptr, const char *filename, int linenumber)
Free memory.
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.
void GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls)
Remove a custom logger.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
const char * GNUNET_error_type_to_string(enum GNUNET_ErrorType kind)
Convert error type to string.
const char * GNUNET_e2s2(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
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.
void(* GNUNET_ContinuationCallback)(void *cls)
Generic continuation callback.
Run with the same priority as the current job.
const char * GNUNET_p2s2(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
Convert a public key value to a string (for printing debug messages).
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
GNUNET_ErrorType
Types of errors.
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.
Identifier for an asynchronous execution context.
GNUNET_SCHEDULER_Priority
Valid task priorities.
Run as background job (higher than idle, lower than default).
static char * component
Running component.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
A 256-bit hashcode.
static char * section
Name of the section.
Definition: gnunet-config.c:33
void GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid, struct GNUNET_AsyncScopeSave *old_scope)
Set the async scope for the current thread.
void GNUNET_abort_(void) __attribute__((noreturn))
Abort the process, generate a core dump if possible.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
void * GNUNET_xmemdup_(const void *buf, size_t size, const char *filename, int linenumber)
Allocate and initialize memory.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
const char * GNUNET_h2s2(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static char * line
Desired phone line (string to be converted to a hash).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
const char * GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
Convert a public key value to a string (for printing debug messages).
const char * GNUNET_uuid2s(const struct GNUNET_Uuid *uuid)
Convert a UUID to a string (for printing debug messages).
Run with priority for interactive tasks.
static char * option
Name of the option.
Definition: gnunet-config.c:38
static char buf[2048]
static char * filename
A UUID, a 128 bit random value.
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)...
char * GNUNET_xstrndup_(const char *str, size_t len, const char *filename, int linenumber)
Dup partially a string.
int(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
A 512-bit hashcode.
void GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret)
Get the current async scope.
Run when otherwise idle.
void GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, const char *comp, const char *message,...)
Log function that specifies an alternative component.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
This is an internal priority level that is only used for tasks that are being triggered due to shutdo...
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.
static unsigned int size
Size of the "table".
Definition: peer.c:67
int have_scope
GNUNET_YES unless this saved scope is the unnamed root scope.
double GNUNET_ntoh_double(double d)
Convert double to host byte order.
Definition: common_endian.c:84
Saved async scope identifier or root scope.
void * GNUNET_xmalloc_(size_t size, const char *filename, int linenumber)
Allocate memory.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope)
Clear the current thread&#39;s async scope.
void * GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber)
Allocate memory.
#define GNUNET_NORETURN
gcc-ism to document functions that don&#39;t return
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
Answer from service to client about last operation.
enum RadiotapType __attribute__
The identity of the host (wraps the signing key of the peer).
#define GNUNET_PACKED
gcc-ism to get packed structs.
void GNUNET_log_skip(int n, int check_reset)
Ignore the next n calls to the log function.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
char * GNUNET_xstrdup_(const char *str, const char *filename, int linenumber)
Dup a string.
Run with priority for urgent tasks.
void * GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber)
Reallocate memory.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void GNUNET_log_nocheck(enum GNUNET_ErrorType kind, const char *message,...) __attribute__((format(printf
Main log function.
Header for all communications.
int GNUNET_get_log_skip(void)
Get the number of log calls that are going to be skipped.
Number of priorities (must be the last priority).
static unsigned long long reserved
How much space have we currently reserved?
void GNUNET_async_scope_fresh(struct GNUNET_AsyncScopeId *aid_ret)
Generate a fresh async scope identifier.
Run with the default priority (normal P2P operations).
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
const char * GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
void(* GNUNET_Logger)(void *cls, enum GNUNET_ErrorType kind, const char *component, const char *date, const char *message)
User-defined handler for log messages.
uint32_t data
The data value.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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.
double GNUNET_hton_double(double d)
Convert double to network byte order.
Definition: common_endian.c:66
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
uint32_t bits[512/8/sizeof(uint32_t)]
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...