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 #include <stdlib.h>
40 #if HAVE_SYS_SOCKET_H
41 #include <sys/socket.h>
42 #endif
43 #if HAVE_NETINET_IN_H
44 #include <netinet/in.h>
45 #endif
46 #ifdef HAVE_STDINT_H
47 #include <stdint.h>
48 #endif
49 #ifdef HAVE_STDARG_H
50 #include <stdarg.h>
51 #endif
52 #ifdef HAVE_SYS_TYPES_H
53 #include <sys/types.h>
54 #endif
55 #ifdef HAVE_SYS_SOCKET_H
56 #include <sys/socket.h>
57 #endif
58 
59 
60 #ifdef HAVE_BYTESWAP_H
61 #include <byteswap.h>
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #if 0 /* keep Emacsens' auto-indent happy */
67 }
68 #endif
69 #endif
70 
74 #define GNUNET_UTIL_VERSION 0x000A0103
75 
76 
83 #define GNUNET_OK 1
84 #define GNUNET_SYSERR -1
85 #define GNUNET_YES 1
86 #define GNUNET_NO 0
87 
88 #define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b))
89 
90 #define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b))
91 
92 /* some systems use one underscore only, and mingw uses no underscore... */
93 #ifndef __BYTE_ORDER
94 #ifdef _BYTE_ORDER
95 #define __BYTE_ORDER _BYTE_ORDER
96 #else
97 #ifdef BYTE_ORDER
98 #define __BYTE_ORDER BYTE_ORDER
99 #endif
100 #endif
101 #endif
102 #ifndef __BIG_ENDIAN
103 #ifdef _BIG_ENDIAN
104 #define __BIG_ENDIAN _BIG_ENDIAN
105 #else
106 #ifdef BIG_ENDIAN
107 #define __BIG_ENDIAN BIG_ENDIAN
108 #endif
109 #endif
110 #endif
111 #ifndef __LITTLE_ENDIAN
112 #ifdef _LITTLE_ENDIAN
113 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
114 #else
115 #ifdef LITTLE_ENDIAN
116 #define __LITTLE_ENDIAN LITTLE_ENDIAN
117 #endif
118 #endif
119 #endif
120 
124 #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int))
125 
126 
132 #ifndef GNUNET_EXTRA_LOGGING
133 #define GNUNET_EXTRA_LOGGING 0
134 #endif
135 
140 #if __BYTE_ORDER == __LITTLE_ENDIAN
141 #define GNUNET_htobe16(x) __bswap_16 (x)
142 #define GNUNET_htole16(x) (x)
143 #define GNUNET_be16toh(x) __bswap_16 (x)
144 #define GNUNET_le16toh(x) (x)
145 
146 #define GNUNET_htobe32(x) __bswap_32 (x)
147 #define GNUNET_htole32(x) (x)
148 #define GNUNET_be32toh(x) __bswap_32 (x)
149 #define GNUNET_le32toh(x) (x)
150 
151 #define GNUNET_htobe64(x) __bswap_64 (x)
152 #define GNUNET_htole64(x) (x)
153 #define GNUNET_be64toh(x) __bswap_64 (x)
154 #define GNUNET_le64toh(x) (x)
155 #endif
156 #if __BYTE_ORDER == __BIG_ENDIAN
157 #define GNUNET_htobe16(x) (x)
158 #define GNUNET_htole16(x) __bswap_16 (x)
159 #define GNUNET_be16toh(x) (x)
160 #define GNUNET_le16toh(x) __bswap_16 (x)
161 
162 #define GNUNET_htobe32(x) (x)
163 #define GNUNET_htole32(x) __bswap_32 (x)
164 #define GNUNET_be32toh(x) (x)
165 #define GNUNET_le32toh(x) __bswap_32 (x)
166 
167 #define GNUNET_htobe64(x) (x)
168 #define GNUNET_htole64(x) __bswap_64 (x)
169 #define GNUNET_be64toh(x) (x)
170 #define GNUNET_le64toh(x) __bswap_64 (x)
171 #endif
172 
173 
186 #define GNUNET_NZL(l) GNUNET_MAX (1, l)
187 
188 
192 #define GNUNET_PACKED __attribute__ ((packed))
193 
197 #define GNUNET_GCC_STRUCT_LAYOUT
198 
204 #ifdef __BIGGEST_ALIGNMENT__
205 #define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)))
206 #else
207 #define GNUNET_ALIGN __attribute__ ((aligned (8)))
208 #endif
209 
213 #define GNUNET_UNUSED __attribute__ ((unused))
214 
218 #define GNUNET_NORETURN __attribute__ ((noreturn))
219 
223 #define GNUNET_NETWORK_STRUCT_BEGIN
224 
228 #define GNUNET_NETWORK_STRUCT_END
229 
230 /* ************************ super-general types *********************** */
231 
233 
238 {
239  uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */
240 };
241 
242 
248 {
249  uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */
250 };
251 
252 
257 {
261  uint32_t value[4];
262 };
263 
264 
269 {
274  uint16_t size GNUNET_PACKED;
275 
279  uint16_t type GNUNET_PACKED;
280 };
281 
282 
287 {
288  struct GNUNET_MessageHeader header;
289 
291 
295  uint64_t op_id GNUNET_PACKED;
296 
300  uint64_t result_code GNUNET_PACKED;
301 
302  /* Followed by data. */
303 };
304 
305 
310 {
311  uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */
312 };
313 
315 
316 
321 {
325  struct GNUNET_AsyncScopeId scope_id;
326 
331 };
332 
333 
343 typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
344 
345 
351 typedef void (*GNUNET_ContinuationCallback) (void *cls);
352 
353 
366 typedef void (*GNUNET_ResultCallback) (void *cls,
367  int64_t result_code,
368  const void *data,
369  uint16_t data_size);
370 
371 
372 /* ****************************** logging ***************************** */
373 
379 {
384  /* UX: We need a message type that is output by
385  * default without looking like there is a problem.
386  */
392 };
393 
394 
405 typedef void (*GNUNET_Logger) (void *cls,
406  enum GNUNET_ErrorType kind,
407  const char *component,
408  const char *date,
409  const char *message);
410 
411 
418 int
419 GNUNET_get_log_skip (void);
420 
421 
422 #if ! defined(GNUNET_CULL_LOGGING)
423 int
424 GNUNET_get_log_call_status (int caller_level,
425  const char *comp,
426  const char *file,
427  const char *function,
428  int line);
429 
430 #endif
431 
432 
441 void
442 GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
443 __attribute__ ((format (printf, 2, 3)));
444 
445 /* from glib */
446 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
447 #define _GNUNET_BOOLEAN_EXPR(expr) \
448  __extension__ ({ \
449  int _gnunet_boolean_var_; \
450  if (expr) \
451  _gnunet_boolean_var_ = 1; \
452  else \
453  _gnunet_boolean_var_ = 0; \
454  _gnunet_boolean_var_; \
455  })
456 #define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
457 #define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
458 #else
459 #define GN_LIKELY(expr) (expr)
460 #define GN_UNLIKELY(expr) (expr)
461 #endif
462 
463 #if ! defined(GNUNET_LOG_CALL_STATUS)
464 #define GNUNET_LOG_CALL_STATUS -1
465 #endif
466 
467 
478 void
480  const char *comp,
481  const char *message,
482  ...);
483 
484 #if ! defined(GNUNET_CULL_LOGGING)
485 #define GNUNET_log_from(kind, comp, ...) \
486  do \
487  { \
488  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
489  if ((GNUNET_EXTRA_LOGGING > 0) || \
490  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
491  { \
492  if (GN_UNLIKELY (log_call_enabled == -1)) \
493  log_call_enabled = \
494  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
495  (comp), \
496  __FILE__, \
497  __FUNCTION__, \
498  __LINE__); \
499  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
500  { \
501  GNUNET_log_skip (-1, GNUNET_NO); \
502  } \
503  else \
504  { \
505  if (GN_UNLIKELY (log_call_enabled)) \
506  GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
507  } \
508  } \
509  } while (0)
510 
511 #define GNUNET_log(kind, ...) \
512  do \
513  { \
514  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
515  if ((GNUNET_EXTRA_LOGGING > 0) || \
516  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
517  { \
518  if (GN_UNLIKELY (log_call_enabled == -1)) \
519  log_call_enabled = \
520  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
521  NULL, \
522  __FILE__, \
523  __FUNCTION__, \
524  __LINE__); \
525  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
526  { \
527  GNUNET_log_skip (-1, GNUNET_NO); \
528  } \
529  else \
530  { \
531  if (GN_UNLIKELY (log_call_enabled)) \
532  GNUNET_log_nocheck ((kind), __VA_ARGS__); \
533  } \
534  } \
535  } while (0)
536 #else
537 #define GNUNET_log(...)
538 #define GNUNET_log_from(...)
539 #endif
540 
541 
550 void
552  const char *section,
553  const char *option);
554 
555 
565 void
567  const char *section,
568  const char *option,
569  const char *required);
570 
571 
578 void
580 
581 
589 void
590 GNUNET_log_skip (int n, int check_reset);
591 
592 
602 int
603 GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
604 
605 
616 void
617 GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
618 
619 
627 void
628 GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
629 
630 
640 const char *
641 GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc);
642 
643 
653 const char *
654 GNUNET_uuid2s (const struct GNUNET_Uuid *uuid);
655 
656 
666 const char *
667 GNUNET_h2s (const struct GNUNET_HashCode *hc);
668 
669 
681 const char *
682 GNUNET_h2s2 (const struct GNUNET_HashCode *hc);
683 
684 
695 const char *
696 GNUNET_h2s_full (const struct GNUNET_HashCode *hc);
697 
698 
703 
704 
709 
710 
720 const char *
722 
723 
733 const char *
735 
736 
746 const char *
748 
749 
759 const char *
761 
762 
773 const char *
774 GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
775 
776 
789 const char *
790 GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid);
791 
792 
803 const char *
804 GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
805 
806 
818 const char *
819 GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
820 
821 
829 const char *
831 
832 
837 #define GNUNET_assert(cond) \
838  do \
839  { \
840  if (! (cond)) \
841  { \
842  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
843  _ ("Assertion failed at %s:%d. Aborting.\n"), \
844  __FILE__, \
845  __LINE__); \
846  GNUNET_abort_ (); \
847  } \
848  } while (0)
849 
850 
855 #define GNUNET_assert_at(cond, f, l) \
856  do \
857  { \
858  if (! (cond)) \
859  { \
860  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
861  _ ("Assertion failed at %s:%d. Aborting.\n"), \
862  f, \
863  l); \
864  GNUNET_abort_ (); \
865  } \
866  } while (0)
867 
868 
876 #define GNUNET_assert_from(cond, comp) \
877  do \
878  { \
879  if (! (cond)) \
880  { \
881  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
882  comp, \
883  _ ("Assertion failed at %s:%d. Aborting.\n"), \
884  __FILE__, \
885  __LINE__); \
886  GNUNET_abort_ (); \
887  } \
888  } while (0)
889 
890 
896 #define GNUNET_break(cond) \
897  do \
898  { \
899  if (! (cond)) \
900  { \
901  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
902  _ ("Assertion failed at %s:%d.\n"), \
903  __FILE__, \
904  __LINE__); \
905  } \
906  } while (0)
907 
908 
918 #define GNUNET_break_op(cond) \
919  do \
920  { \
921  if (! (cond)) \
922  { \
923  GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
924  _ ("External protocol violation detected at %s:%d.\n"), \
925  __FILE__, \
926  __LINE__); \
927  } \
928  } while (0)
929 
930 
937 #define GNUNET_log_strerror(level, cmd) \
938  do \
939  { \
940  GNUNET_log (level, \
941  _ ("`%s' failed at %s:%d with error: %s\n"), \
942  cmd, \
943  __FILE__, \
944  __LINE__, \
945  strerror (errno)); \
946  } while (0)
947 
948 
955 #define GNUNET_log_from_strerror(level, component, cmd) \
956  do \
957  { \
958  GNUNET_log_from (level, \
959  component, \
960  _ ("`%s' failed at %s:%d with error: %s\n"), \
961  cmd, \
962  __FILE__, \
963  __LINE__, \
964  strerror (errno)); \
965  } while (0)
966 
967 
974 #define GNUNET_log_strerror_file(level, cmd, filename) \
975  do \
976  { \
977  GNUNET_log (level, \
978  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
979  cmd, \
980  filename, \
981  __FILE__, \
982  __LINE__, \
983  strerror (errno)); \
984  } while (0)
985 
986 
993 #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
994  do \
995  { \
996  GNUNET_log_from (level, \
997  component, \
998  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
999  cmd, \
1000  filename, \
1001  __FILE__, \
1002  __LINE__, \
1003  strerror (errno)); \
1004  } while (0)
1005 
1006 /* ************************* endianess conversion ****************** */
1007 
1008 #ifdef htonbe64
1009 
1010 #define GNUNET_htonll(n) htobe64 (n)
1011 
1012 #else
1013 
1021 uint64_t
1022 GNUNET_htonll (uint64_t n);
1023 
1024 #endif
1025 
1026 
1027 #ifdef be64toh
1028 
1029 #define GNUNET_ntohll(n) be64toh (n)
1030 
1031 #else
1032 
1040 uint64_t
1041 GNUNET_ntohll (uint64_t n);
1042 
1043 #endif
1044 
1045 
1054 double
1055 GNUNET_hton_double (double d);
1056 
1057 
1066 double
1067 GNUNET_ntoh_double (double d);
1068 
1069 
1070 /* ************************* allocation functions ****************** */
1071 
1076 #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
1077 
1086 #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof(type))
1087 
1088 
1093 #define GNUNET_memcmp(a, b) \
1094  ({ \
1095  const typeof (*b) * _a = (a); \
1096  const typeof (*a) * _b = (b); \
1097  memcmp (_a, _b, sizeof(*a)); \
1098  })
1099 
1100 
1108 #define GNUNET_is_zero(a) \
1109  ({ \
1110  static const typeof (*a) _z; \
1111  memcmp ((a), &_z, sizeof(_z)); \
1112  })
1113 
1114 
1124 #define GNUNET_memcpy(dst, src, n) \
1125  do \
1126  { \
1127  if (0 != n) \
1128  { \
1129  (void) memcpy (dst, src, n); \
1130  } \
1131  } while (0)
1132 
1133 
1143 #define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof(type))
1144 
1154 #define GNUNET_new_array_2d(n, m, type) \
1155  (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__)
1156 
1167 #define GNUNET_new_array_3d(n, m, o, type) \
1168  (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, __LINE__)
1169 
1179 #define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__)
1180 
1189 #define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__)
1190 
1199 #define GNUNET_malloc_large(size) \
1200  GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
1201 
1211 #define GNUNET_realloc(ptr, size) \
1212  GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
1213 
1223 #define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
1224 
1232 #define GNUNET_free_non_null(ptr) \
1233  do \
1234  { \
1235  void *__x__ = ptr; \
1236  if (__x__ != NULL) \
1237  { \
1238  GNUNET_free (__x__); \
1239  } \
1240  } while (0)
1241 
1250 #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__)
1251 
1261 #define GNUNET_strndup(a, length) \
1262  GNUNET_xstrndup_ (a, length, __FILE__, __LINE__)
1263 
1299 #define GNUNET_array_grow(arr, size, tsize) \
1300  GNUNET_xgrow_ ((void **) &(arr), \
1301  sizeof((arr)[0]), \
1302  &size, \
1303  tsize, \
1304  __FILE__, \
1305  __LINE__)
1306 
1320 #define GNUNET_array_append(arr, size, element) \
1321  do \
1322  { \
1323  GNUNET_array_grow (arr, size, size + 1); \
1324  (arr) [size - 1] = element; \
1325  } while (0)
1326 
1337 int
1338 GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
1339 
1340 
1350 int
1351 GNUNET_asprintf (char **buf, const char *format, ...);
1352 
1353 
1354 /* ************** internal implementations, use macros above! ************** */
1355 
1367 void *
1368 GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
1369 
1370 
1385 void **
1386 GNUNET_xnew_array_2d_ (size_t n,
1387  size_t m,
1388  size_t elementSize,
1389  const char *filename,
1390  int linenumber);
1391 
1392 
1408 void ***
1409 GNUNET_xnew_array_3d_ (size_t n,
1410  size_t m,
1411  size_t o,
1412  size_t elementSize,
1413  const char *filename,
1414  int linenumber);
1415 
1416 
1428 void *
1429 GNUNET_xmemdup_ (const void *buf,
1430  size_t size,
1431  const char *filename,
1432  int linenumber);
1433 
1434 
1447 void *
1448 GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
1449 
1450 
1455 void *
1456 GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber);
1457 
1458 
1468 void
1469 GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
1470 
1471 
1479 char *
1480 GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
1481 
1491 char *
1492 GNUNET_xstrndup_ (const char *str,
1493  size_t len,
1494  const char *filename,
1495  int linenumber);
1496 
1512 void
1513 GNUNET_xgrow_ (void **old,
1514  size_t elementSize,
1515  unsigned int *oldCount,
1516  unsigned int newCount,
1517  const char *filename,
1518  int linenumber);
1519 
1520 
1528 struct GNUNET_MessageHeader *
1530 
1531 
1538 void
1540  struct GNUNET_AsyncScopeSave *old_scope);
1541 
1542 
1548 void
1550 
1551 
1557 void
1558 GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret);
1559 
1560 
1566 void
1568 
1569 
1570 #if __STDC_VERSION__ < 199901L
1571 #if __GNUC__ >= 2
1572 #define __func__ __FUNCTION__
1573 #else
1574 #define __func__ "<unknown>"
1575 #endif
1576 #endif
1577 
1578 
1587 {
1592 
1597 
1603 
1611 
1617 
1623 
1631 
1641 
1647 };
1648 
1649 
1650 #if 0 /* keep Emacsens' auto-indent happy */
1651 {
1652 #endif
1653 #ifdef __cplusplus
1654 }
1655 #endif
1656 
1657 #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:36
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:92
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:74
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
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...