GNUnet  0.10.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 MINGW
46 #include "winproc.h"
47 #endif
48 #ifdef HAVE_STDINT_H
49 #include <stdint.h>
50 #endif
51 #ifdef HAVE_STDARG_H
52 #include <stdarg.h>
53 #endif
54 
55 #ifdef HAVE_BYTESWAP_H
56 #include <byteswap.h>
57 #endif
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #if 0 /* keep Emacsens' auto-indent happy */
62 }
63 #endif
64 #endif
65 
69 #define GNUNET_UTIL_VERSION 0x000A0103
70 
71 
78 #define GNUNET_OK 1
79 #define GNUNET_SYSERR -1
80 #define GNUNET_YES 1
81 #define GNUNET_NO 0
82 
83 #define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b))
84 
85 #define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b))
86 
87 /* some systems use one underscore only, and mingw uses no underscore... */
88 #ifndef __BYTE_ORDER
89 #ifdef _BYTE_ORDER
90 #define __BYTE_ORDER _BYTE_ORDER
91 #else
92 #ifdef BYTE_ORDER
93 #define __BYTE_ORDER BYTE_ORDER
94 #endif
95 #endif
96 #endif
97 #ifndef __BIG_ENDIAN
98 #ifdef _BIG_ENDIAN
99 #define __BIG_ENDIAN _BIG_ENDIAN
100 #else
101 #ifdef BIG_ENDIAN
102 #define __BIG_ENDIAN BIG_ENDIAN
103 #endif
104 #endif
105 #endif
106 #ifndef __LITTLE_ENDIAN
107 #ifdef _LITTLE_ENDIAN
108 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
109 #else
110 #ifdef LITTLE_ENDIAN
111 #define __LITTLE_ENDIAN LITTLE_ENDIAN
112 #endif
113 #endif
114 #endif
115 
119 #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int))
120 
121 
127 #ifndef GNUNET_EXTRA_LOGGING
128 #define GNUNET_EXTRA_LOGGING 0
129 #endif
130 
135 #if __BYTE_ORDER == __LITTLE_ENDIAN
136 #define GNUNET_htobe16(x) __bswap_16 (x)
137 #define GNUNET_htole16(x) (x)
138 #define GNUNET_be16toh(x) __bswap_16 (x)
139 #define GNUNET_le16toh(x) (x)
140 
141 #define GNUNET_htobe32(x) __bswap_32 (x)
142 #define GNUNET_htole32(x) (x)
143 #define GNUNET_be32toh(x) __bswap_32 (x)
144 #define GNUNET_le32toh(x) (x)
145 
146 #define GNUNET_htobe64(x) __bswap_64 (x)
147 #define GNUNET_htole64(x) (x)
148 #define GNUNET_be64toh(x) __bswap_64 (x)
149 #define GNUNET_le64toh(x) (x)
150 #endif
151 #if __BYTE_ORDER == __BIG_ENDIAN
152 #define GNUNET_htobe16(x) (x)
153 #define GNUNET_htole16(x) __bswap_16 (x)
154 #define GNUNET_be16toh(x) (x)
155 #define GNUNET_le16toh(x) __bswap_16 (x)
156 
157 #define GNUNET_htobe32(x) (x)
158 #define GNUNET_htole32(x) __bswap_32 (x)
159 #define GNUNET_be32toh(x) (x)
160 #define GNUNET_le32toh(x) __bswap_32 (x)
161 
162 #define GNUNET_htobe64(x) (x)
163 #define GNUNET_htole64(x) __bswap_64 (x)
164 #define GNUNET_be64toh(x) (x)
165 #define GNUNET_le64toh(x) __bswap_64 (x)
166 #endif
167 
168 
181 #define GNUNET_NZL(l) GNUNET_MAX (1, l)
182 
183 
187 #define GNUNET_PACKED __attribute__ ((packed))
188 
192 #if MINGW
193 #define GNUNET_GCC_STRUCT_LAYOUT __attribute__ ((gcc_struct))
194 #else
195 #define GNUNET_GCC_STRUCT_LAYOUT
196 #endif
197 
203 #ifdef __BIGGEST_ALIGNMENT__
204 #define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)))
205 #else
206 #define GNUNET_ALIGN __attribute__ ((aligned (8)))
207 #endif
208 
212 #define GNUNET_UNUSED __attribute__ ((unused))
213 
217 #define GNUNET_NORETURN __attribute__ ((noreturn))
218 
219 #if MINGW
220 #if __GNUC__ > 3
221 
227 #define GNUNET_NETWORK_STRUCT_BEGIN _Pragma ("pack(push)") _Pragma ("pack(1)")
228 
235 #define GNUNET_NETWORK_STRUCT_END _Pragma ("pack(pop)")
236 
237 #else
238 #error gcc 4.x or higher required on W32 systems
239 #endif
240 #else
241 
244 #define GNUNET_NETWORK_STRUCT_BEGIN
245 
249 #define GNUNET_NETWORK_STRUCT_END
250 #endif
251 
252 /* ************************ super-general types *********************** */
253 
255 
260 {
261  uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
262 };
263 
264 
270 {
271  uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
272 };
273 
274 
279 {
283  uint32_t value[4];
284 };
285 
286 
291 {
292 
297  uint16_t size GNUNET_PACKED;
298 
302  uint16_t type GNUNET_PACKED;
303 };
304 
305 
310 {
311  struct GNUNET_MessageHeader header;
312 
314 
318  uint64_t op_id GNUNET_PACKED;
319 
323  uint64_t result_code GNUNET_PACKED;
324 
325  /* Followed by data. */
326 };
327 
328 
333 {
334  uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
335 };
336 
338 
339 
344 {
348  struct GNUNET_AsyncScopeId scope_id;
349 
354 };
355 
356 
366 typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
367 
368 
374 typedef void (*GNUNET_ContinuationCallback) (void *cls);
375 
376 
389 typedef void (*GNUNET_ResultCallback) (void *cls,
390  int64_t result_code,
391  const void *data,
392  uint16_t data_size);
393 
394 
395 /* ****************************** logging ***************************** */
396 
402 {
407  /* UX: We need a message type that is output by
408  * default without looking like there is a problem.
409  */
415 };
416 
417 
428 typedef void (*GNUNET_Logger) (void *cls,
429  enum GNUNET_ErrorType kind,
430  const char *component,
431  const char *date,
432  const char *message);
433 
434 
441 int
442 GNUNET_get_log_skip (void);
443 
444 
445 #if ! defined(GNUNET_CULL_LOGGING)
446 int
447 GNUNET_get_log_call_status (int caller_level,
448  const char *comp,
449  const char *file,
450  const char *function,
451  int line);
452 #endif
453 
454 
463 void
464 GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
465  __attribute__ ((format (printf, 2, 3)));
466 
467 /* from glib */
468 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
469 #define _GNUNET_BOOLEAN_EXPR(expr) \
470  __extension__({ \
471  int _gnunet_boolean_var_; \
472  if (expr) \
473  _gnunet_boolean_var_ = 1; \
474  else \
475  _gnunet_boolean_var_ = 0; \
476  _gnunet_boolean_var_; \
477  })
478 #define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
479 #define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
480 #else
481 #define GN_LIKELY(expr) (expr)
482 #define GN_UNLIKELY(expr) (expr)
483 #endif
484 
485 #if ! defined(GNUNET_LOG_CALL_STATUS)
486 #define GNUNET_LOG_CALL_STATUS -1
487 #endif
488 
489 
500 void
502  const char *comp,
503  const char *message,
504  ...);
505 
506 #if ! defined(GNUNET_CULL_LOGGING)
507 #define GNUNET_log_from(kind, comp, ...) \
508  do \
509  { \
510  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
511  if ((GNUNET_EXTRA_LOGGING > 0) || \
512  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
513  { \
514  if (GN_UNLIKELY (log_call_enabled == -1)) \
515  log_call_enabled = \
516  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
517  (comp), \
518  __FILE__, \
519  __FUNCTION__, \
520  __LINE__); \
521  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
522  { \
523  GNUNET_log_skip (-1, GNUNET_NO); \
524  } \
525  else \
526  { \
527  if (GN_UNLIKELY (log_call_enabled)) \
528  GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
529  } \
530  } \
531  } while (0)
532 
533 #define GNUNET_log(kind, ...) \
534  do \
535  { \
536  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
537  if ((GNUNET_EXTRA_LOGGING > 0) || \
538  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
539  { \
540  if (GN_UNLIKELY (log_call_enabled == -1)) \
541  log_call_enabled = \
542  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
543  NULL, \
544  __FILE__, \
545  __FUNCTION__, \
546  __LINE__); \
547  if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
548  { \
549  GNUNET_log_skip (-1, GNUNET_NO); \
550  } \
551  else \
552  { \
553  if (GN_UNLIKELY (log_call_enabled)) \
554  GNUNET_log_nocheck ((kind), __VA_ARGS__); \
555  } \
556  } \
557  } while (0)
558 #else
559 #define GNUNET_log(...)
560 #define GNUNET_log_from(...)
561 #endif
562 
563 
572 void
574  const char *section,
575  const char *option);
576 
577 
587 void
589  const char *section,
590  const char *option,
591  const char *required);
592 
593 
600 void
602 
603 
611 void
612 GNUNET_log_skip (int n, int check_reset);
613 
614 
624 int
625 GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
626 
627 
638 void
639 GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
640 
641 
649 void
650 GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
651 
652 
662 const char *
663 GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc);
664 
665 
675 const char *
676 GNUNET_uuid2s (const struct GNUNET_Uuid *uuid);
677 
678 
688 const char *
689 GNUNET_h2s (const struct GNUNET_HashCode *hc);
690 
691 
703 const char *
704 GNUNET_h2s2 (const struct GNUNET_HashCode *hc);
705 
706 
717 const char *
718 GNUNET_h2s_full (const struct GNUNET_HashCode *hc);
719 
720 
725 
726 
731 
732 
742 const char *
744 
745 
755 const char *
757 
758 
768 const char *
770 
771 
781 const char *
783 
784 
795 const char *
796 GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
797 
798 
811 const char *
812 GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid);
813 
814 
825 const char *
826 GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
827 
828 
840 const char *
841 GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
842 
843 
851 const char *
853 
854 
859 #define GNUNET_assert(cond) \
860  do \
861  { \
862  if (! (cond)) \
863  { \
864  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
865  _ ("Assertion failed at %s:%d. Aborting.\n"), \
866  __FILE__, \
867  __LINE__); \
868  GNUNET_abort_ (); \
869  } \
870  } while (0)
871 
872 
877 #define GNUNET_assert_at(cond, f, l) \
878  do \
879  { \
880  if (! (cond)) \
881  { \
882  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
883  _ ("Assertion failed at %s:%d. Aborting.\n"), \
884  f, \
885  l); \
886  GNUNET_abort_ (); \
887  } \
888  } while (0)
889 
890 
898 #define GNUNET_assert_from(cond, comp) \
899  do \
900  { \
901  if (! (cond)) \
902  { \
903  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
904  comp, \
905  _ ("Assertion failed at %s:%d. Aborting.\n"), \
906  __FILE__, \
907  __LINE__); \
908  GNUNET_abort_ (); \
909  } \
910  } while (0)
911 
912 
918 #define GNUNET_break(cond) \
919  do \
920  { \
921  if (! (cond)) \
922  { \
923  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
924  _ ("Assertion failed at %s:%d.\n"), \
925  __FILE__, \
926  __LINE__); \
927  } \
928  } while (0)
929 
930 
940 #define GNUNET_break_op(cond) \
941  do \
942  { \
943  if (! (cond)) \
944  { \
945  GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
946  _ ("External protocol violation detected at %s:%d.\n"), \
947  __FILE__, \
948  __LINE__); \
949  } \
950  } while (0)
951 
952 
959 #define GNUNET_log_strerror(level, cmd) \
960  do \
961  { \
962  GNUNET_log (level, \
963  _ ("`%s' failed at %s:%d with error: %s\n"), \
964  cmd, \
965  __FILE__, \
966  __LINE__, \
967  STRERROR (errno)); \
968  } while (0)
969 
970 
977 #define GNUNET_log_from_strerror(level, component, cmd) \
978  do \
979  { \
980  GNUNET_log_from (level, \
981  component, \
982  _ ("`%s' failed at %s:%d with error: %s\n"), \
983  cmd, \
984  __FILE__, \
985  __LINE__, \
986  STRERROR (errno)); \
987  } while (0)
988 
989 
996 #define GNUNET_log_strerror_file(level, cmd, filename) \
997  do \
998  { \
999  GNUNET_log (level, \
1000  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
1001  cmd, \
1002  filename, \
1003  __FILE__, \
1004  __LINE__, \
1005  STRERROR (errno)); \
1006  } while (0)
1007 
1008 
1015 #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
1016  do \
1017  { \
1018  GNUNET_log_from (level, \
1019  component, \
1020  _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
1021  cmd, \
1022  filename, \
1023  __FILE__, \
1024  __LINE__, \
1025  STRERROR (errno)); \
1026  } while (0)
1027 
1028 /* ************************* endianess conversion ****************** */
1029 
1038 uint64_t
1039 GNUNET_htonll (uint64_t n);
1040 
1041 
1050 uint64_t
1051 GNUNET_ntohll (uint64_t n);
1052 
1053 
1062 double
1063 GNUNET_hton_double (double d);
1064 
1065 
1074 double
1075 GNUNET_ntoh_double (double d);
1076 
1077 
1078 /* ************************* allocation functions ****************** */
1079 
1084 #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
1085 
1094 #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
1095 
1096 
1101 #define GNUNET_memcmp(a, b) \
1102  ({ \
1103  const typeof (*b) *_a = (a); \
1104  const typeof (*a) *_b = (b); \
1105  memcmp (_a, _b, sizeof (*a)); \
1106  })
1107 
1108 
1115 #define GNUNET_is_zero(a) \
1116  ({ \
1117  static const typeof (*a) _z; \
1118  memcmp ((a), &_z, sizeof (_z)); \
1119  })
1120 
1121 
1131 #define GNUNET_memcpy(dst, src, n) \
1132  do \
1133  { \
1134  if (0 != n) \
1135  { \
1136  (void) memcpy (dst, src, n); \
1137  } \
1138  } while (0)
1139 
1140 
1150 #define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof (type))
1151 
1161 #define GNUNET_new_array_2d(n, m, type) \
1162  (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__)
1163 
1174 #define GNUNET_new_array_3d(n, m, o, type) \
1175  (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__)
1176 
1186 #define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__)
1187 
1196 #define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__)
1197 
1206 #define GNUNET_malloc_large(size) \
1207  GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
1208 
1218 #define GNUNET_realloc(ptr, size) \
1219  GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
1220 
1230 #define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
1231 
1239 #define GNUNET_free_non_null(ptr) \
1240  do \
1241  { \
1242  void *__x__ = ptr; \
1243  if (__x__ != NULL) \
1244  { \
1245  GNUNET_free (__x__); \
1246  } \
1247  } while (0)
1248 
1257 #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__)
1258 
1268 #define GNUNET_strndup(a, length) \
1269  GNUNET_xstrndup_ (a, length, __FILE__, __LINE__)
1270 
1306 #define GNUNET_array_grow(arr, size, tsize) \
1307  GNUNET_xgrow_ ((void **) &(arr), \
1308  sizeof ((arr)[0]), \
1309  &size, \
1310  tsize, \
1311  __FILE__, \
1312  __LINE__)
1313 
1327 #define GNUNET_array_append(arr, size, element) \
1328  do \
1329  { \
1330  GNUNET_array_grow (arr, size, size + 1); \
1331  (arr)[size - 1] = element; \
1332  } while (0)
1333 
1344 int
1345 GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
1346 
1347 
1357 int
1358 GNUNET_asprintf (char **buf, const char *format, ...);
1359 
1360 
1361 /* ************** internal implementations, use macros above! ************** */
1362 
1374 void *
1375 GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
1376 
1377 
1392 void **
1393 GNUNET_xnew_array_2d_ (size_t n,
1394  size_t m,
1395  size_t elementSize,
1396  const char *filename,
1397  int linenumber);
1398 
1399 
1415 void ***
1416 GNUNET_xnew_array_3d_ (size_t n,
1417  size_t m,
1418  size_t o,
1419  size_t elementSize,
1420  const char *filename,
1421  int linenumber);
1422 
1423 
1435 void *
1436 GNUNET_xmemdup_ (const void *buf,
1437  size_t size,
1438  const char *filename,
1439  int linenumber);
1440 
1441 
1454 void *
1455 GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
1456 
1457 
1462 void *
1463 GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber);
1464 
1465 
1475 void
1476 GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
1477 
1478 
1486 char *
1487 GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
1488 
1498 char *
1499 GNUNET_xstrndup_ (const char *str,
1500  size_t len,
1501  const char *filename,
1502  int linenumber);
1503 
1519 void
1520 GNUNET_xgrow_ (void **old,
1521  size_t elementSize,
1522  unsigned int *oldCount,
1523  unsigned int newCount,
1524  const char *filename,
1525  int linenumber);
1526 
1527 
1535 struct GNUNET_MessageHeader *
1537 
1538 
1545 void
1547  struct GNUNET_AsyncScopeSave *old_scope);
1548 
1549 
1555 void
1557 
1558 
1564 void
1565 GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret);
1566 
1567 
1573 void
1575 
1576 
1577 #if __STDC_VERSION__ < 199901L
1578 #if __GNUC__ >= 2
1579 #define __func__ __FUNCTION__
1580 #else
1581 #define __func__ "<unknown>"
1582 #endif
1583 #endif
1584 
1585 
1594 {
1599 
1604 
1610 
1618 
1624 
1630 
1638 
1648 
1654 };
1655 
1656 
1657 #if 0 /* keep Emacsens' auto-indent happy */
1658 {
1659 #endif
1660 #ifdef __cplusplus
1661 }
1662 #endif
1663 
1664 #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).
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:99
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.
static size_t data_size
Number of bytes in data.
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...