GNUnet  0.11.x
json_helper.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2014, 2015, 2016 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  */
27 #include "platform.h"
28 #include "gnunet_json_lib.h"
29 
30 
36 {
37  struct GNUNET_JSON_Specification ret = {
38  .parser = NULL,
39  .cleaner = NULL,
40  .cls = NULL
41  };
42 
43  return ret;
44 }
45 
46 
55 static int
57  json_t *root,
58  struct GNUNET_JSON_Specification *spec)
59 {
60  const char *enc;
61  unsigned int len;
62 
63  if (NULL == (enc = json_string_value (root)))
64  {
65  GNUNET_break_op (0);
66  return GNUNET_SYSERR;
67  }
68  len = strlen (enc);
69  if (((len * 5) / 8) != spec->ptr_size)
70  {
71  GNUNET_break_op (0);
72  return GNUNET_SYSERR;
73  }
74  if (GNUNET_OK !=
76  len,
77  spec->ptr,
78  spec->ptr_size))
79  {
80  GNUNET_break_op (0);
81  return GNUNET_SYSERR;
82  }
83  return GNUNET_OK;
84 }
85 
86 
97  void *obj,
98  size_t size)
99 {
100  struct GNUNET_JSON_Specification ret = {
102  .cleaner = NULL,
103  .cls = NULL,
104  .field = name,
105  .ptr = obj,
106  .ptr_size = size,
107  .size_ptr = NULL
108  };
109 
110  return ret;
111 }
112 
113 
122 static int
124  json_t *root,
125  struct GNUNET_JSON_Specification *spec)
126 {
127  const char *str;
128  size_t size;
129  void *data;
130  int res;
131 
132  str = json_string_value (root);
133  if (NULL == str)
134  {
135  GNUNET_break_op (0);
136  return GNUNET_SYSERR;
137  }
138  size = (strlen (str) * 5) / 8;
139  if (size >= 1024)
140  {
141  GNUNET_break_op (0);
142  return GNUNET_SYSERR;
143  }
144  data = GNUNET_malloc (size);
146  strlen (str),
147  data,
148  size);
149  if (GNUNET_OK != res)
150  {
151  GNUNET_break_op (0);
152  GNUNET_free (data);
153  return GNUNET_SYSERR;
154  }
155  *(void **) spec->ptr = data;
156  *spec->size_ptr = size;
157  return GNUNET_OK;
158 }
159 
160 
167 static void
169  struct GNUNET_JSON_Specification *spec)
170 {
171  if (0 != *spec->size_ptr)
172  {
173  GNUNET_free (*(void **) spec->ptr);
174  *(void **) spec->ptr = NULL;
175  *spec->size_ptr = 0;
176  }
177 }
178 
179 
190  void **obj,
191  size_t *size)
192 {
193  struct GNUNET_JSON_Specification ret = {
195  .cleaner = &clean_variable_data,
196  .cls = NULL,
197  .field = name,
198  .ptr = obj,
199  .ptr_size = 0,
200  .size_ptr = size
201  };
202 
203  *obj = NULL;
204  *size = 0;
205  return ret;
206 }
207 
208 
217 static int
219  json_t *root,
220  struct GNUNET_JSON_Specification *spec)
221 {
222  const char *str;
223 
224  str = json_string_value (root);
225  if (NULL == str)
226  {
227  GNUNET_break_op (0);
228  return GNUNET_SYSERR;
229  }
230  *(const char **) spec->ptr = str;
231  return GNUNET_OK;
232 }
233 
234 
243  const char **strptr)
244 {
245  struct GNUNET_JSON_Specification ret = {
246  .parser = &parse_string,
247  .cleaner = NULL,
248  .cls = NULL,
249  .field = name,
250  .ptr = strptr,
251  .ptr_size = 0,
252  .size_ptr = NULL
253  };
254 
255  *strptr = NULL;
256  return ret;
257 }
258 
259 
268 static int
270  json_t *root,
271  struct GNUNET_JSON_Specification *spec)
272 {
273  if (! (json_is_object (root) || json_is_array (root)))
274  {
275  GNUNET_break_op (0);
276  return GNUNET_SYSERR;
277  }
278  json_incref (root);
279  *(json_t **) spec->ptr = root;
280  return GNUNET_OK;
281 }
282 
283 
290 static void
292  struct GNUNET_JSON_Specification *spec)
293 {
294  json_t **ptr = (json_t **) spec->ptr;
295 
296  if (NULL != *ptr)
297  {
298  json_decref (*ptr);
299  *ptr = NULL;
300  }
301 }
302 
303 
312  json_t **jsonp)
313 {
314  struct GNUNET_JSON_Specification ret = {
315  .parser = &parse_object,
316  .cleaner = &clean_object,
317  .cls = NULL,
318  .field = name,
319  .ptr = jsonp,
320  .ptr_size = 0,
321  .size_ptr = NULL
322  };
323 
324  *jsonp = NULL;
325  return ret;
326 }
327 
328 
337 static int
338 parse_u8 (void *cls,
339  json_t *root,
340  struct GNUNET_JSON_Specification *spec)
341 {
342  json_int_t val;
343  uint8_t *up = spec->ptr;
344 
345  if (! json_is_integer (root))
346  {
347  GNUNET_break_op (0);
348  return GNUNET_SYSERR;
349  }
350  val = json_integer_value (root);
351  if ((0 > val) || (val > UINT8_MAX))
352  {
353  GNUNET_break_op (0);
354  return GNUNET_SYSERR;
355  }
356  *up = (uint8_t) val;
357  return GNUNET_OK;
358 }
359 
360 
369  uint8_t *u8)
370 {
371  struct GNUNET_JSON_Specification ret = {
372  .parser = &parse_u8,
373  .cleaner = NULL,
374  .cls = NULL,
375  .field = name,
376  .ptr = u8,
377  .ptr_size = sizeof(uint8_t),
378  .size_ptr = NULL
379  };
380 
381  return ret;
382 }
383 
384 
393 static int
394 parse_u16 (void *cls,
395  json_t *root,
396  struct GNUNET_JSON_Specification *spec)
397 {
398  json_int_t val;
399  uint16_t *up = spec->ptr;
400 
401  if (! json_is_integer (root))
402  {
403  GNUNET_break_op (0);
404  return GNUNET_SYSERR;
405  }
406  val = json_integer_value (root);
407  if ((0 > val) || (val > UINT16_MAX))
408  {
409  GNUNET_break_op (0);
410  return GNUNET_SYSERR;
411  }
412  *up = (uint16_t) val;
413  return GNUNET_OK;
414 }
415 
416 
425  uint16_t *u16)
426 {
427  struct GNUNET_JSON_Specification ret = {
428  .parser = &parse_u16,
429  .cleaner = NULL,
430  .cls = NULL,
431  .field = name,
432  .ptr = u16,
433  .ptr_size = sizeof(uint16_t),
434  .size_ptr = NULL
435  };
436 
437  return ret;
438 }
439 
440 
449 static int
450 parse_u32 (void *cls,
451  json_t *root,
452  struct GNUNET_JSON_Specification *spec)
453 {
454  json_int_t val;
455  uint32_t *up = spec->ptr;
456 
457  if (! json_is_integer (root))
458  {
459  GNUNET_break_op (0);
460  return GNUNET_SYSERR;
461  }
462  val = json_integer_value (root);
463  if ((0 > val) || (val > UINT32_MAX))
464  {
465  GNUNET_break_op (0);
466  return GNUNET_SYSERR;
467  }
468  *up = (uint32_t) val;
469  return GNUNET_OK;
470 }
471 
472 
481  uint32_t *u32)
482 {
483  struct GNUNET_JSON_Specification ret = {
484  .parser = &parse_u32,
485  .cleaner = NULL,
486  .cls = NULL,
487  .field = name,
488  .ptr = u32,
489  .ptr_size = sizeof(uint32_t),
490  .size_ptr = NULL
491  };
492 
493  return ret;
494 }
495 
496 
505 static int
506 parse_u64 (void *cls,
507  json_t *root,
508  struct GNUNET_JSON_Specification *spec)
509 {
510  json_int_t val;
511  uint64_t *up = spec->ptr;
512 
513  if (! json_is_integer (root))
514  {
515  GNUNET_break_op (0);
516  return GNUNET_SYSERR;
517  }
518  val = json_integer_value (root);
519  *up = (uint64_t) val;
520  return GNUNET_OK;
521 }
522 
523 
532  uint64_t *u64)
533 {
534  struct GNUNET_JSON_Specification ret = {
535  .parser = &parse_u64,
536  .cleaner = NULL,
537  .cls = NULL,
538  .field = name,
539  .ptr = u64,
540  .ptr_size = sizeof(uint64_t),
541  .size_ptr = NULL
542  };
543 
544  return ret;
545 }
546 
547 
548 /* ************ GNUnet-specific parser specifications ******************* */
549 
558 static int
560  json_t *root,
561  struct GNUNET_JSON_Specification *spec)
562 {
563  struct GNUNET_TIME_Absolute *abs = spec->ptr;
564  json_t *json_t_ms;
565  unsigned long long int tval;
566 
567  if (! json_is_object (root))
568  {
569  GNUNET_break_op (0);
570  return GNUNET_SYSERR;
571  }
572  json_t_ms = json_object_get (root, "t_ms");
573  if (json_is_integer (json_t_ms))
574  {
575  tval = json_integer_value (json_t_ms);
576  /* Time is in milliseconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
577  abs->abs_value_us = tval * 1000LL;
578  if ((abs->abs_value_us) / 1000LL != tval)
579  {
580  /* Integer overflow */
581  GNUNET_break_op (0);
582  return GNUNET_SYSERR;
583  }
584  return GNUNET_OK;
585  }
586  if (json_is_string (json_t_ms))
587  {
588  const char *val;
589  val = json_string_value (json_t_ms);
590  if ((0 == strcasecmp (val, "never")))
591  {
593  return GNUNET_OK;
594  }
595  GNUNET_break_op (0);
596  return GNUNET_SYSERR;
597  }
598  GNUNET_break_op (0);
599  return GNUNET_SYSERR;
600 }
601 
602 
611  struct GNUNET_TIME_Absolute *at)
612 {
613  struct GNUNET_JSON_Specification ret = {
615  .cleaner = NULL,
616  .cls = NULL,
617  .field = name,
618  .ptr = at,
619  .ptr_size = sizeof(uint64_t),
620  .size_ptr = NULL
621  };
622 
623  return ret;
624 }
625 
626 
635 static int
637  json_t *root,
638  struct GNUNET_JSON_Specification *spec)
639 {
640  struct GNUNET_TIME_AbsoluteNBO *abs = spec->ptr;
641  struct GNUNET_TIME_Absolute a;
642  struct GNUNET_JSON_Specification ispec;
643 
644  ispec = *spec;
645  ispec.parser = &parse_abs_time;
646  ispec.ptr = &a;
647  if (GNUNET_OK !=
648  parse_abs_time (NULL,
649  root,
650  &ispec))
651  return GNUNET_SYSERR;
652  *abs = GNUNET_TIME_absolute_hton (a);
653  return GNUNET_OK;
654 }
655 
656 
665  struct GNUNET_TIME_AbsoluteNBO *at)
666 {
667  struct GNUNET_JSON_Specification ret = {
669  .cleaner = NULL,
670  .cls = NULL,
671  .field = name,
672  .ptr = at,
673  .ptr_size = sizeof(uint64_t),
674  .size_ptr = NULL
675  };
676 
677  return ret;
678 }
679 
680 
689 static int
691  json_t *root,
692  struct GNUNET_JSON_Specification *spec)
693 {
694  struct GNUNET_TIME_Relative *rel = spec->ptr;
695  json_t *json_d_ms;
696  unsigned long long int tval;
697 
698  if (! json_is_object (root))
699  {
700  GNUNET_break_op (0);
701  return GNUNET_SYSERR;
702  }
703  json_d_ms = json_object_get (root, "d_ms");
704  if (json_is_integer (json_d_ms))
705  {
706  tval = json_integer_value (json_d_ms);
707  /* Time is in milliseconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
708  rel->rel_value_us = tval * 1000LL;
709  if ((rel->rel_value_us) / 1000LL != tval)
710  {
711  /* Integer overflow */
712  GNUNET_break_op (0);
713  return GNUNET_SYSERR;
714  }
715  return GNUNET_OK;
716  }
717  if (json_is_string (json_d_ms))
718  {
719  const char *val;
720  val = json_string_value (json_d_ms);
721  if ((0 == strcasecmp (val, "forever")))
722  {
724  return GNUNET_OK;
725  }
726  GNUNET_break_op (0);
727  return GNUNET_SYSERR;
728  }
729  GNUNET_break_op (0);
730  return GNUNET_SYSERR;
731 }
732 
733 
742  struct GNUNET_TIME_Relative *rt)
743 {
744  struct GNUNET_JSON_Specification ret = {
746  .cleaner = NULL,
747  .cls = NULL,
748  .field = name,
749  .ptr = rt,
750  .ptr_size = sizeof(uint64_t),
751  .size_ptr = NULL
752  };
753 
754  return ret;
755 }
756 
757 
766 static int
768  json_t *root,
769  struct GNUNET_JSON_Specification *spec)
770 {
771  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
772  const char *enc;
773  char *buf;
774  size_t len;
775  size_t buf_len;
776 
777  if (NULL == (enc = json_string_value (root)))
778  {
779  GNUNET_break_op (0);
780  return GNUNET_SYSERR;
781  }
782  len = strlen (enc);
783  buf_len = (len * 5) / 8;
784  buf = GNUNET_malloc (buf_len);
785  if (GNUNET_OK !=
787  len,
788  buf,
789  buf_len))
790  {
791  GNUNET_break_op (0);
792  GNUNET_free (buf);
793  return GNUNET_SYSERR;
794  }
795  if (NULL == (*pk = GNUNET_CRYPTO_rsa_public_key_decode (buf,
796  buf_len)))
797  {
798  GNUNET_break_op (0);
799  GNUNET_free (buf);
800  return GNUNET_SYSERR;
801  }
802  GNUNET_free (buf);
803  return GNUNET_OK;
804 }
805 
806 
813 static void
815  struct GNUNET_JSON_Specification *spec)
816 {
817  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
818 
819  if (NULL != *pk)
820  {
822  *pk = NULL;
823  }
824 }
825 
826 
836 {
837  struct GNUNET_JSON_Specification ret = {
839  .cleaner = &clean_rsa_public_key,
840  .cls = NULL,
841  .field = name,
842  .ptr = pk,
843  .ptr_size = 0,
844  .size_ptr = NULL
845  };
846 
847  *pk = NULL;
848  return ret;
849 }
850 
851 
860 static int
862  json_t *root,
863  struct GNUNET_JSON_Specification *spec)
864 {
865  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
866  size_t size;
867  const char *str;
868  int res;
869  void *buf;
870 
871  str = json_string_value (root);
872  if (NULL == str)
873  {
874  GNUNET_break_op (0);
875  return GNUNET_SYSERR;
876  }
877  size = (strlen (str) * 5) / 8;
878  buf = GNUNET_malloc (size);
880  strlen (str),
881  buf,
882  size);
883  if (GNUNET_OK != res)
884  {
885  GNUNET_free (buf);
886  GNUNET_break_op (0);
887  return GNUNET_SYSERR;
888  }
889  if (NULL == (*sig = GNUNET_CRYPTO_rsa_signature_decode (buf,
890  size)))
891  {
892  GNUNET_break_op (0);
893  GNUNET_free (buf);
894  return GNUNET_SYSERR;
895  }
896  GNUNET_free (buf);
897  return GNUNET_OK;
898 }
899 
900 
907 static void
909  struct GNUNET_JSON_Specification *spec)
910 {
911  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
912 
913  if (NULL != *sig)
914  {
916  *sig = NULL;
917  }
918 }
919 
920 
929  struct GNUNET_CRYPTO_RsaSignature **sig)
930 {
931  struct GNUNET_JSON_Specification ret = {
933  .cleaner = &clean_rsa_signature,
934  .cls = NULL,
935  .field = name,
936  .ptr = sig,
937  .ptr_size = 0,
938  .size_ptr = NULL
939  };
940 
941  *sig = NULL;
942  return ret;
943 }
944 
945 
954 static int
956  json_t *root,
957  struct GNUNET_JSON_Specification *spec)
958 {
959  int *bp = spec->ptr;
960 
961  if (! json_is_boolean (root))
962  {
963  GNUNET_break_op (0);
964  return GNUNET_SYSERR;
965  }
966  *bp = json_boolean_value (root) ? GNUNET_YES : GNUNET_NO;
967  return GNUNET_OK;
968 }
969 
970 
979  int *boolean)
980 {
981  struct GNUNET_JSON_Specification ret = {
982  .parser = &parse_boolean,
983  .cleaner = NULL,
984  .cls = NULL,
985  .field = name,
986  .ptr = boolean,
987  .ptr_size = sizeof(int),
988  .size_ptr = NULL
989  };
990 
991  return ret;
992 }
993 
994 
995 /* end of json_helper.c */
void * cls
Closure for parser and cleaner.
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
Definition: json_helper.c:168
uint8_t u8
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
Definition: json_helper.c:480
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
uint64_t rel_value_us
The actual value.
an RSA signature
Definition: crypto_rsa.c:63
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:1061
functions to parse JSON objects into GNUnet objects
static int parse_rsa_public_key(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA public key.
Definition: json_helper.c:767
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object.
Definition: json_helper.c:311
static int parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
Definition: json_helper.c:394
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
Definition: json_helper.c:424
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time_nbo(const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time in network byte order.
Definition: json_helper.c:664
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:86
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
static int parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
Definition: json_helper.c:861
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
Definition: json_helper.c:908
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:1124
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
Definition: json_helper.c:450
static int parse_object(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
Definition: json_helper.c:269
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format. ...
Definition: crypto_rsa.c:443
static char buf[2048]
static void clean_rsa_public_key(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA public key.
Definition: json_helper.c:814
static void clean_object(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
Definition: json_helper.c:291
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed(const char *name, void *obj, size_t size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
Definition: json_helper.c:96
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
static int res
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
Definition: json_helper.c:35
static int parse_boolean(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an int as a boolean.
Definition: json_helper.c:955
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67
static int parse_variable_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to variable size data.
Definition: json_helper.c:123
void * ptr
Pointer, details specific to the parser.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
Definition: json_helper.c:368
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
Specification for parsing an RSA signature.
Definition: json_helper.c:928
static int parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:506
static int parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
Definition: json_helper.c:218
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
Definition: json_helper.c:531
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
Definition: json_helper.c:242
static int parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
Definition: json_helper.c:690
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
Definition: json_helper.c:741
const char * name
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean(const char *name, int *boolean)
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
Definition: json_helper.c:978
uint64_t u64
static int parse_fixed_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to fixed size data.
Definition: json_helper.c:56
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time.
Definition: json_helper.c:610
size_t ptr_size
Number of bytes available in ptr.
size_t * size_ptr
Where should we store the final size of ptr.
static int parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:338
struct GNUNET_JSON_Specification GNUNET_JSON_spec_varsize(const char *name, void **obj, size_t *size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
Definition: json_helper.c:189
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_public_key(const char *name, struct GNUNET_CRYPTO_RsaPublicKey **pk)
Specification for parsing an RSA public key.
Definition: json_helper.c:834
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:305
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:85
static int parse_abs_time_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:636
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
static int parse_abs_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:559
uint32_t u32
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:970
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...