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 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  uint32_t bits[512 / 8 / sizeof(uint32_t)]; /* = 16 */
231 };
232 
233 
239  uint32_t bits[256 / 8 / sizeof(uint32_t)]; /* = 8 */
240 };
241 
242 
246 struct GNUNET_Uuid {
250  uint32_t value[4];
251 };
252 
253 
262  uint16_t size GNUNET_PACKED;
263 
267  uint16_t type GNUNET_PACKED;
268 };
269 
270 
275  struct GNUNET_MessageHeader header;
276 
278 
282  uint64_t op_id GNUNET_PACKED;
283 
287  uint64_t result_code GNUNET_PACKED;
288 
289  /* Followed by data. */
290 };
291 
292 
297  uint32_t bits[16 / sizeof(uint32_t)]; /* = 16 bytes */
298 };
299 
301 
302 
310  struct GNUNET_AsyncScopeId scope_id;
311 
316 };
317 
318 
328 typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
329 
330 
336 typedef void (*GNUNET_ContinuationCallback) (void *cls);
337 
338 
351 typedef void (*GNUNET_ResultCallback) (void *cls,
352  int64_t result_code,
353  const void *data,
354  uint16_t data_size);
355 
356 
357 /* ****************************** logging ***************************** */
358 
368  /* UX: We need a message type that is output by
369  * default without looking like there is a problem.
370  */
376 };
377 
378 
389 typedef void (*GNUNET_Logger) (void *cls,
390  enum GNUNET_ErrorType kind,
391  const char *component,
392  const char *date,
393  const char *message);
394 
395 
402 int
403 GNUNET_get_log_skip(void);
404 
405 
406 #if !defined(GNUNET_CULL_LOGGING)
407 int
408 GNUNET_get_log_call_status(int caller_level,
409  const char *comp,
410  const char *file,
411  const char *function,
412  int line);
413 #endif
414 
415 
424 void
425 GNUNET_log_nocheck(enum GNUNET_ErrorType kind, const char *message, ...)
426 __attribute__ ((format(printf, 2, 3)));
427 
428 /* from glib */
429 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
430 #define _GNUNET_BOOLEAN_EXPR(expr) \
431  __extension__({ \
432  int _gnunet_boolean_var_; \
433  if (expr) \
434  _gnunet_boolean_var_ = 1; \
435  else \
436  _gnunet_boolean_var_ = 0; \
437  _gnunet_boolean_var_; \
438  })
439 #define GN_LIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 1))
440 #define GN_UNLIKELY(expr) (__builtin_expect(_GNUNET_BOOLEAN_EXPR(expr), 0))
441 #else
442 #define GN_LIKELY(expr) (expr)
443 #define GN_UNLIKELY(expr) (expr)
444 #endif
445 
446 #if !defined(GNUNET_LOG_CALL_STATUS)
447 #define GNUNET_LOG_CALL_STATUS -1
448 #endif
449 
450 
461 void
463  const char *comp,
464  const char *message,
465  ...);
466 
467 #if !defined(GNUNET_CULL_LOGGING)
468 #define GNUNET_log_from(kind, comp, ...) \
469  do \
470  { \
471  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
472  if ((GNUNET_EXTRA_LOGGING > 0) || \
473  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
474  { \
475  if (GN_UNLIKELY(log_call_enabled == -1)) \
476  log_call_enabled = \
477  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
478  (comp), \
479  __FILE__, \
480  __FUNCTION__, \
481  __LINE__); \
482  if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \
483  { \
484  GNUNET_log_skip(-1, GNUNET_NO); \
485  } \
486  else \
487  { \
488  if (GN_UNLIKELY(log_call_enabled)) \
489  GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
490  } \
491  } \
492  } while (0)
493 
494 #define GNUNET_log(kind, ...) \
495  do \
496  { \
497  static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
498  if ((GNUNET_EXTRA_LOGGING > 0) || \
499  ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
500  { \
501  if (GN_UNLIKELY(log_call_enabled == -1)) \
502  log_call_enabled = \
503  GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
504  NULL, \
505  __FILE__, \
506  __FUNCTION__, \
507  __LINE__); \
508  if (GN_UNLIKELY(GNUNET_get_log_skip() > 0)) \
509  { \
510  GNUNET_log_skip(-1, GNUNET_NO); \
511  } \
512  else \
513  { \
514  if (GN_UNLIKELY(log_call_enabled)) \
515  GNUNET_log_nocheck ((kind), __VA_ARGS__); \
516  } \
517  } \
518  } while (0)
519 #else
520 #define GNUNET_log(...)
521 #define GNUNET_log_from(...)
522 #endif
523 
524 
533 void
535  const char *section,
536  const char *option);
537 
538 
548 void
550  const char *section,
551  const char *option,
552  const char *required);
553 
554 
561 void
563 
564 
572 void
573 GNUNET_log_skip(int n, int check_reset);
574 
575 
585 int
586 GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile);
587 
588 
599 void
600 GNUNET_logger_add(GNUNET_Logger logger, void *logger_cls);
601 
602 
610 void
611 GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls);
612 
613 
623 const char *
624 GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc);
625 
626 
636 const char *
637 GNUNET_uuid2s(const struct GNUNET_Uuid *uuid);
638 
639 
649 const char *
650 GNUNET_h2s(const struct GNUNET_HashCode *hc);
651 
652 
664 const char *
665 GNUNET_h2s2(const struct GNUNET_HashCode *hc);
666 
667 
678 const char *
679 GNUNET_h2s_full(const struct GNUNET_HashCode *hc);
680 
681 
686 
687 
692 
693 
703 const char *
705 
706 
716 const char *
718 
719 
729 const char *
731 
732 
742 const char *
744 
745 
756 const char *
757 GNUNET_i2s(const struct GNUNET_PeerIdentity *pid);
758 
759 
772 const char *
773 GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid);
774 
775 
786 const char *
788 
789 
801 const char *
802 GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen);
803 
804 
812 const char *
814 
815 
820 #define GNUNET_assert(cond) \
821  do \
822  { \
823  if (!(cond)) \
824  { \
825  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \
826  _("Assertion failed at %s:%d. Aborting.\n"), \
827  __FILE__, \
828  __LINE__); \
829  GNUNET_abort_(); \
830  } \
831  } while (0)
832 
833 
838 #define GNUNET_assert_at(cond, f, l) \
839  do \
840  { \
841  if (!(cond)) \
842  { \
843  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \
844  _("Assertion failed at %s:%d. Aborting.\n"), \
845  f, \
846  l); \
847  GNUNET_abort_(); \
848  } \
849  } while (0)
850 
851 
859 #define GNUNET_assert_from(cond, comp) \
860  do \
861  { \
862  if (!(cond)) \
863  { \
864  GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, \
865  comp, \
866  _("Assertion failed at %s:%d. Aborting.\n"), \
867  __FILE__, \
868  __LINE__); \
869  GNUNET_abort_(); \
870  } \
871  } while (0)
872 
873 
879 #define GNUNET_break(cond) \
880  do \
881  { \
882  if (!(cond)) \
883  { \
884  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, \
885  _("Assertion failed at %s:%d.\n"), \
886  __FILE__, \
887  __LINE__); \
888  } \
889  } while (0)
890 
891 
901 #define GNUNET_break_op(cond) \
902  do \
903  { \
904  if (!(cond)) \
905  { \
906  GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
907  _("External protocol violation detected at %s:%d.\n"), \
908  __FILE__, \
909  __LINE__); \
910  } \
911  } while (0)
912 
913 
920 #define GNUNET_log_strerror(level, cmd) \
921  do \
922  { \
923  GNUNET_log(level, \
924  _("`%s' failed at %s:%d with error: %s\n"), \
925  cmd, \
926  __FILE__, \
927  __LINE__, \
928  strerror(errno)); \
929  } while (0)
930 
931 
938 #define GNUNET_log_from_strerror(level, component, cmd) \
939  do \
940  { \
941  GNUNET_log_from(level, \
942  component, \
943  _("`%s' failed at %s:%d with error: %s\n"), \
944  cmd, \
945  __FILE__, \
946  __LINE__, \
947  strerror(errno)); \
948  } while (0)
949 
950 
957 #define GNUNET_log_strerror_file(level, cmd, filename) \
958  do \
959  { \
960  GNUNET_log(level, \
961  _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
962  cmd, \
963  filename, \
964  __FILE__, \
965  __LINE__, \
966  strerror(errno)); \
967  } while (0)
968 
969 
976 #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
977  do \
978  { \
979  GNUNET_log_from(level, \
980  component, \
981  _("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
982  cmd, \
983  filename, \
984  __FILE__, \
985  __LINE__, \
986  strerror(errno)); \
987  } while (0)
988 
989 /* ************************* endianess conversion ****************** */
990 
999 uint64_t
1000 GNUNET_htonll(uint64_t n);
1001 
1002 
1011 uint64_t
1012 GNUNET_ntohll(uint64_t n);
1013 
1014 
1023 double
1024 GNUNET_hton_double(double d);
1025 
1026 
1035 double
1036 GNUNET_ntoh_double(double d);
1037 
1038 
1039 /* ************************* allocation functions ****************** */
1040 
1045 #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
1046 
1055 #define GNUNET_new(type) (type *)GNUNET_malloc(sizeof(type))
1056 
1057 
1062 #define GNUNET_memcmp(a, b) \
1063  ({ \
1064  const typeof (*b) * _a = (a); \
1065  const typeof (*a) * _b = (b); \
1066  memcmp(_a, _b, sizeof(*a)); \
1067  })
1068 
1069 
1076 #define GNUNET_is_zero(a) \
1077  ({ \
1078  static const typeof (*a) _z; \
1079  memcmp((a), &_z, sizeof(_z)); \
1080  })
1081 
1082 
1092 #define GNUNET_memcpy(dst, src, n) \
1093  do \
1094  { \
1095  if (0 != n) \
1096  { \
1097  (void)memcpy(dst, src, n); \
1098  } \
1099  } while (0)
1100 
1101 
1111 #define GNUNET_new_array(n, type) (type *)GNUNET_malloc((n) * sizeof(type))
1112 
1122 #define GNUNET_new_array_2d(n, m, type) \
1123  (type **)GNUNET_xnew_array_2d_(n, m, sizeof(type), __FILE__, __LINE__)
1124 
1135 #define GNUNET_new_array_3d(n, m, o, type) \
1136  (type ***)GNUNET_xnew_array_3d_(n, m, o, sizeof(type), __FILE__, __LINE__)
1137 
1147 #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
1148 
1157 #define GNUNET_memdup(buf, size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__)
1158 
1167 #define GNUNET_malloc_large(size) \
1168  GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__)
1169 
1179 #define GNUNET_realloc(ptr, size) \
1180  GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__)
1181 
1191 #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__)
1192 
1200 #define GNUNET_free_non_null(ptr) \
1201  do \
1202  { \
1203  void *__x__ = ptr; \
1204  if (__x__ != NULL) \
1205  { \
1206  GNUNET_free(__x__); \
1207  } \
1208  } while (0)
1209 
1218 #define GNUNET_strdup(a) GNUNET_xstrdup_(a, __FILE__, __LINE__)
1219 
1229 #define GNUNET_strndup(a, length) \
1230  GNUNET_xstrndup_(a, length, __FILE__, __LINE__)
1231 
1267 #define GNUNET_array_grow(arr, size, tsize) \
1268  GNUNET_xgrow_((void **)&(arr), \
1269  sizeof((arr)[0]), \
1270  &size, \
1271  tsize, \
1272  __FILE__, \
1273  __LINE__)
1274 
1288 #define GNUNET_array_append(arr, size, element) \
1289  do \
1290  { \
1291  GNUNET_array_grow(arr, size, size + 1); \
1292  (arr)[size - 1] = element; \
1293  } while (0)
1294 
1305 int
1306 GNUNET_snprintf(char *buf, size_t size, const char *format, ...);
1307 
1308 
1318 int
1319 GNUNET_asprintf(char **buf, const char *format, ...);
1320 
1321 
1322 /* ************** internal implementations, use macros above! ************** */
1323 
1335 void *
1336 GNUNET_xmalloc_(size_t size, const char *filename, int linenumber);
1337 
1338 
1353 void **
1354 GNUNET_xnew_array_2d_(size_t n,
1355  size_t m,
1356  size_t elementSize,
1357  const char *filename,
1358  int linenumber);
1359 
1360 
1376 void ***
1377 GNUNET_xnew_array_3d_(size_t n,
1378  size_t m,
1379  size_t o,
1380  size_t elementSize,
1381  const char *filename,
1382  int linenumber);
1383 
1384 
1396 void *
1397 GNUNET_xmemdup_(const void *buf,
1398  size_t size,
1399  const char *filename,
1400  int linenumber);
1401 
1402 
1415 void *
1416 GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber);
1417 
1418 
1423 void *
1424 GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber);
1425 
1426 
1436 void
1437 GNUNET_xfree_(void *ptr, const char *filename, int linenumber);
1438 
1439 
1447 char *
1448 GNUNET_xstrdup_(const char *str, const char *filename, int linenumber);
1449 
1459 char *
1460 GNUNET_xstrndup_(const char *str,
1461  size_t len,
1462  const char *filename,
1463  int linenumber);
1464 
1480 void
1481 GNUNET_xgrow_(void **old,
1482  size_t elementSize,
1483  unsigned int *oldCount,
1484  unsigned int newCount,
1485  const char *filename,
1486  int linenumber);
1487 
1488 
1496 struct GNUNET_MessageHeader *
1498 
1499 
1506 void
1508  struct GNUNET_AsyncScopeSave *old_scope);
1509 
1510 
1516 void
1518 
1519 
1525 void
1527 
1528 
1534 void
1536 
1537 
1538 #if __STDC_VERSION__ < 199901L
1539 #if __GNUC__ >= 2
1540 #define __func__ __FUNCTION__
1541 #else
1542 #define __func__ "<unknown>"
1543 #endif
1544 #endif
1545 
1546 
1559 
1564 
1570 
1578 
1584 
1590 
1598 
1608 
1614 };
1615 
1616 
1617 #if 0 /* keep Emacsens' auto-indent happy */
1618 {
1619 #endif
1620 #ifdef __cplusplus
1621 }
1622 #endif
1623 
1624 #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:66
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...