GNUnet  0.10.x
plugin_gnsrecord_dns.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013, 2014 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 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_dnsparser_lib.h"
30 
31 
41 static char *
43  uint32_t type,
44  const void *data,
45  size_t data_size)
46 {
47  char *result;
48  char tmp[INET6_ADDRSTRLEN];
49 
50  switch (type)
51  {
53  if (data_size != sizeof(struct in_addr))
54  return NULL;
55  if (NULL == inet_ntop(AF_INET, data, tmp, sizeof(tmp)))
56  return NULL;
57  return GNUNET_strdup(tmp);
58 
60  char *ns;
61  size_t off;
62 
63  off = 0;
64  ns = GNUNET_DNSPARSER_parse_name(data, data_size, &off);
65  if ((NULL == ns) || (off != data_size))
66  {
67  GNUNET_break_op(0);
69  return NULL;
70  }
71  return ns;
72  }
73 
75  char *cname;
76  size_t off;
77 
78  off = 0;
79  cname = GNUNET_DNSPARSER_parse_name(data, data_size, &off);
80  if ((NULL == cname) || (off != data_size))
81  {
82  GNUNET_break_op(0);
83  GNUNET_free_non_null(cname);
84  return NULL;
85  }
86  return cname;
87  }
88 
90  struct GNUNET_DNSPARSER_SoaRecord *soa;
91  size_t off;
92 
93  off = 0;
94  soa = GNUNET_DNSPARSER_parse_soa(data, data_size, &off);
95  if ((NULL == soa) || (off != data_size))
96  {
97  GNUNET_break_op(0);
98  if (NULL != soa)
100  return NULL;
101  }
102  GNUNET_asprintf(&result,
103  "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
104  soa->rname,
105  soa->mname,
106  soa->serial,
107  soa->refresh,
108  soa->retry,
109  soa->expire,
110  soa->minimum_ttl);
112  return result;
113  }
114 
116  char *ptr;
117  size_t off;
118 
119  off = 0;
120  ptr = GNUNET_DNSPARSER_parse_name(data, data_size, &off);
121  if ((NULL == ptr) || (off != data_size))
122  {
123  GNUNET_break_op(0);
125  return NULL;
126  }
127  return ptr;
128  }
129 
131  struct GNUNET_DNSPARSER_CertRecord *cert;
132  size_t off;
133  char *base64;
134  int len;
135 
136  off = 0;
137  cert = GNUNET_DNSPARSER_parse_cert(data, data_size, &off);
138  if ((NULL == cert) || (off != data_size))
139  {
140  GNUNET_break_op(0);
142  return NULL;
143  }
145  cert->certificate_size,
146  &base64);
147  GNUNET_asprintf(&result,
148  "%u %u %u %.*s",
149  cert->cert_type,
150  cert->cert_tag,
151  cert->algorithm,
152  len,
153  base64);
154  GNUNET_free(base64);
156  return result;
157  }
158 
160  struct GNUNET_DNSPARSER_MxRecord *mx;
161  size_t off;
162 
163  off = 0;
164  mx = GNUNET_DNSPARSER_parse_mx(data, data_size, &off);
165  if ((NULL == mx) || (off != data_size))
166  {
167  GNUNET_break_op(0);
169  return NULL;
170  }
171  GNUNET_asprintf(&result,
172  "%u,%s",
173  (unsigned int)mx->preference,
174  mx->mxhost);
176  return result;
177  }
178 
180  return GNUNET_strndup(data, data_size);
181 
183  if (data_size != sizeof(struct in6_addr))
184  return NULL;
185  if (NULL == inet_ntop(AF_INET6, data, tmp, sizeof(tmp)))
186  return NULL;
187  return GNUNET_strdup(tmp);
188 
190  struct GNUNET_DNSPARSER_SrvRecord *srv;
191  size_t off;
192 
193  off = 0;
194  srv = GNUNET_DNSPARSER_parse_srv(data, data_size, &off);
195  if ((NULL == srv) || (off != data_size))
196  {
197  GNUNET_break_op(0);
198  if (NULL != srv)
200  return NULL;
201  }
202  GNUNET_asprintf(&result,
203  "%d %d %d %s",
204  srv->priority,
205  srv->weight,
206  srv->port,
207  srv->target);
209  return result;
210  }
211 
213  const struct GNUNET_TUN_DnsTlsaRecord *tlsa;
214  char *tlsa_str;
215  char *hex;
216 
217  if (data_size < sizeof(struct GNUNET_TUN_DnsTlsaRecord))
218  return NULL; /* malformed */
219  tlsa = data;
220  hex =
222  data_size -
223  sizeof(struct GNUNET_TUN_DnsTlsaRecord));
224  if (0 == GNUNET_asprintf(&tlsa_str,
225  "%u %u %u %s",
226  (unsigned int)tlsa->usage,
227  (unsigned int)tlsa->selector,
228  (unsigned int)tlsa->matching_type,
229  hex))
230  {
231  GNUNET_free(hex);
232  GNUNET_free(tlsa_str);
233  return NULL;
234  }
235  GNUNET_free(hex);
236  return tlsa_str;
237  }
238 
239  case GNUNET_DNSPARSER_TYPE_CAA: { //RFC6844
240  const struct GNUNET_DNSPARSER_CaaRecord *caa;
241  char tag[15]; // between 1 and 15 bytes
242  char value[data_size];
243  char *caa_str;
244  if (data_size < sizeof(struct GNUNET_DNSPARSER_CaaRecord))
245  return NULL; /* malformed */
246  caa = data;
247  if ((1 > caa->tag_len) || (15 < caa->tag_len))
248  return NULL; /* malformed */
249  memset(tag, 0, sizeof(tag));
250  memset(value, 0, data_size);
251  memcpy(tag, &caa[1], caa->tag_len);
252  memcpy(value,
253  (char *)&caa[1] + caa->tag_len,
254  data_size - caa->tag_len - 2);
255  if (0 == GNUNET_asprintf(&caa_str,
256  "%u %s %s",
257  (unsigned int)caa->flags,
258  tag,
259  value))
260  {
261  GNUNET_free(caa_str);
262  return NULL;
263  }
264  return caa_str;
265  }
266 
267  default:
268  return NULL;
269  }
270 }
271 
272 
279 static unsigned int
280 rfc4398_mnemonic_to_value(const char *mnemonic)
281 {
282  static struct {
283  const char *mnemonic;
284  unsigned int val;
285  } table[] = { { "PKIX", 1 },
286  { "SPKI", 2 },
287  { "PGP", 3 },
288  { "IPKIX", 4 },
289  { "ISPKI", 5 },
290  { "IPGP", 6 },
291  { "ACPKIX", 7 },
292  { "IACPKIX", 8 },
293  { "URI", 253 },
294  { "OID", 254 },
295  { NULL, 0 } };
296  unsigned int i;
297 
298  for (i = 0; NULL != table[i].mnemonic; i++)
299  if (0 == strcasecmp(mnemonic, table[i].mnemonic))
300  return table[i].val;
301  return 0;
302 }
303 
304 
311 static unsigned int
312 rfc4034_mnemonic_to_value(const char *mnemonic)
313 {
314  static struct {
315  const char *mnemonic;
316  unsigned int val;
317  } table[] = { { "RSAMD5", 1 },
318  { "DH", 2 },
319  { "DSA", 3 },
320  { "ECC", 4 },
321  { "RSASHA1", 5 },
322  { "INDIRECT", 252 },
323  { "PRIVATEDNS", 253 },
324  { "PRIVATEOID", 254 },
325  { NULL, 0 } };
326  unsigned int i;
327 
328  for (i = 0; NULL != table[i].mnemonic; i++)
329  if (0 == strcasecmp(mnemonic, table[i].mnemonic))
330  return table[i].val;
331  return 0;
332 }
333 
334 
346 static int
348  uint32_t type,
349  const char *s,
350  void **data,
351  size_t *data_size)
352 {
353  struct in_addr value_a;
354  struct in6_addr value_aaaa;
355  struct GNUNET_TUN_DnsTlsaRecord *tlsa;
356 
357  if (NULL == s)
358  return GNUNET_SYSERR;
359  switch (type)
360  {
362  if (1 != inet_pton(AF_INET, s, &value_a))
363  {
365  _("Unable to parse IPv4 address `%s'\n"),
366  s);
367  return GNUNET_SYSERR;
368  }
369  *data = GNUNET_new(struct in_addr);
370  GNUNET_memcpy(*data, &value_a, sizeof(value_a));
371  *data_size = sizeof(value_a);
372  return GNUNET_OK;
373 
375  char nsbuf[256];
376  size_t off;
377 
378  off = 0;
379  if (GNUNET_OK !=
380  GNUNET_DNSPARSER_builder_add_name(nsbuf, sizeof(nsbuf), &off, s))
381  {
383  _("Failed to serialize NS record with value `%s'\n"),
384  s);
385  return GNUNET_SYSERR;
386  }
387  *data_size = off;
388  *data = GNUNET_malloc(off);
389  GNUNET_memcpy(*data, nsbuf, off);
390  return GNUNET_OK;
391  }
392 
394  char cnamebuf[256];
395  size_t off;
396 
397  off = 0;
399  sizeof(cnamebuf),
400  &off,
401  s))
402  {
404  _("Failed to serialize CNAME record with value `%s'\n"),
405  s);
406  return GNUNET_SYSERR;
407  }
408  *data_size = off;
409  *data = GNUNET_malloc(off);
410  GNUNET_memcpy(*data, cnamebuf, off);
411  return GNUNET_OK;
412  }
413 
415  char *sdup;
416  const char *typep;
417  const char *keyp;
418  const char *algp;
419  const char *certp;
420  unsigned int type;
421  unsigned int key;
422  unsigned int alg;
423  size_t cert_size;
424  char *cert_data;
425  struct GNUNET_DNSPARSER_CertRecord cert;
426 
427  sdup = GNUNET_strdup(s);
428  typep = strtok(sdup, " ");
429  if ((NULL == typep) ||
430  ((0 == (type = rfc4398_mnemonic_to_value(typep))) &&
431  ((1 != sscanf(typep, "%u", &type)) || (type > UINT16_MAX))))
432  {
433  GNUNET_free(sdup);
434  return GNUNET_SYSERR;
435  }
436  keyp = strtok(NULL, " ");
437  if ((NULL == keyp) || (1 != sscanf(keyp, "%u", &key)) ||
438  (key > UINT16_MAX))
439  {
440  GNUNET_free(sdup);
441  return GNUNET_SYSERR;
442  }
443  alg = 0;
444  algp = strtok(NULL, " ");
445  if ((NULL == algp) ||
446  ((0 == (type = rfc4034_mnemonic_to_value(typep))) &&
447  ((1 != sscanf(algp, "%u", &alg)) || (alg > UINT8_MAX))))
448  {
449  GNUNET_free(sdup);
450  return GNUNET_SYSERR;
451  }
452  certp = strtok(NULL, " ");
453  if ((NULL == certp) || (0 == strlen(certp)))
454  {
455  GNUNET_free(sdup);
456  return GNUNET_SYSERR;
457  }
458  cert_size = GNUNET_STRINGS_base64_decode(certp,
459  strlen(certp),
460  (void **)&cert_data);
461  GNUNET_free(sdup);
462  cert.cert_type = type;
463  cert.cert_tag = key;
464  cert.algorithm = alg;
465  cert.certificate_size = cert_size;
466  cert.certificate_data = cert_data;
467  {
468  char certbuf[cert_size + sizeof(struct GNUNET_TUN_DnsCertRecord)];
469  size_t off;
470 
471  off = 0;
473  sizeof(certbuf),
474  &off,
475  &cert))
476  {
478  _("Failed to serialize CERT record with %u bytes\n"),
479  (unsigned int)cert_size);
480  GNUNET_free(cert_data);
481  return GNUNET_SYSERR;
482  }
483  *data_size = off;
484  *data = GNUNET_malloc(off);
485  GNUNET_memcpy(*data, certbuf, off);
486  }
487  GNUNET_free(cert_data);
488  return GNUNET_OK;
489  }
490 
492  struct GNUNET_DNSPARSER_SoaRecord soa;
493  char soabuf[540];
494  char soa_rname[253 + 1];
495  char soa_mname[253 + 1];
496  unsigned int soa_serial;
497  unsigned int soa_refresh;
498  unsigned int soa_retry;
499  unsigned int soa_expire;
500  unsigned int soa_min;
501  size_t off;
502 
503  if (7 != sscanf(s,
504  "rname=%253s mname=%253s %u,%u,%u,%u,%u",
505  soa_rname,
506  soa_mname,
507  &soa_serial,
508  &soa_refresh,
509  &soa_retry,
510  &soa_expire,
511  &soa_min))
512  {
514  _("Unable to parse SOA record `%s'\n"),
515  s);
516  return GNUNET_SYSERR;
517  }
518  soa.mname = soa_mname;
519  soa.rname = soa_rname;
520  soa.serial = (uint32_t)soa_serial;
521  soa.refresh = (uint32_t)soa_refresh;
522  soa.retry = (uint32_t)soa_retry;
523  soa.expire = (uint32_t)soa_expire;
524  soa.minimum_ttl = (uint32_t)soa_min;
525  off = 0;
526  if (GNUNET_OK !=
527  GNUNET_DNSPARSER_builder_add_soa(soabuf, sizeof(soabuf), &off, &soa))
528  {
529  GNUNET_log(
531  _("Failed to serialize SOA record with mname `%s' and rname `%s'\n"),
532  soa_mname,
533  soa_rname);
534  return GNUNET_SYSERR;
535  }
536  *data_size = off;
537  *data = GNUNET_malloc(off);
538  GNUNET_memcpy(*data, soabuf, off);
539  return GNUNET_OK;
540  }
541 
543  char ptrbuf[256];
544  size_t off;
545 
546  off = 0;
547  if (GNUNET_OK !=
548  GNUNET_DNSPARSER_builder_add_name(ptrbuf, sizeof(ptrbuf), &off, s))
549  {
551  _("Failed to serialize PTR record with value `%s'\n"),
552  s);
553  return GNUNET_SYSERR;
554  }
555  *data_size = off;
556  *data = GNUNET_malloc(off);
557  GNUNET_memcpy(*data, ptrbuf, off);
558  return GNUNET_OK;
559  }
560 
562  struct GNUNET_DNSPARSER_MxRecord mx;
563  char mxbuf[258];
564  char mxhost[253 + 1];
565  unsigned int mx_pref;
566  size_t off;
567 
568  if (2 != sscanf(s, "%u,%253s", &mx_pref, mxhost))
569  {
571  _("Unable to parse MX record `%s'\n"),
572  s);
573  return GNUNET_SYSERR;
574  }
575  mx.preference = (uint16_t)mx_pref;
576  mx.mxhost = mxhost;
577  off = 0;
578 
579  if (GNUNET_OK !=
580  GNUNET_DNSPARSER_builder_add_mx(mxbuf, sizeof(mxbuf), &off, &mx))
581  {
583  _("Failed to serialize MX record with hostname `%s'\n"),
584  mxhost);
585  return GNUNET_SYSERR;
586  }
587  *data_size = off;
588  *data = GNUNET_malloc(off);
589  GNUNET_memcpy(*data, mxbuf, off);
590  return GNUNET_OK;
591  }
592 
594  struct GNUNET_DNSPARSER_SrvRecord srv;
595  char srvbuf[270];
596  char srvtarget[253 + 1];
597  unsigned int priority;
598  unsigned int weight;
599  unsigned int port;
600  size_t off;
601 
602  if (4 != sscanf(s, "%u %u %u %253s", &priority, &weight, &port, srvtarget))
603  {
605  _("Unable to parse SRV record `%s'\n"),
606  s);
607  return GNUNET_SYSERR;
608  }
609  srv.priority = (uint16_t)priority;
610  srv.weight = (uint16_t)weight;
611  srv.port = (uint16_t)port;
612  srv.target = srvtarget;
613  off = 0;
614  if (GNUNET_OK !=
615  GNUNET_DNSPARSER_builder_add_srv(srvbuf, sizeof(srvbuf), &off, &srv))
616  {
618  _("Failed to serialize SRV record with target `%s'\n"),
619  srvtarget);
620  return GNUNET_SYSERR;
621  }
622  *data_size = off;
623  *data = GNUNET_malloc(off);
624  GNUNET_memcpy(*data, srvbuf, off);
625  return GNUNET_OK;
626  }
627 
629  *data = GNUNET_strdup(s);
630  *data_size = strlen(s);
631  return GNUNET_OK;
632 
634  if (1 != inet_pton(AF_INET6, s, &value_aaaa))
635  {
637  _("Unable to parse IPv6 address `%s'\n"),
638  s);
639  return GNUNET_SYSERR;
640  }
641  *data = GNUNET_new(struct in6_addr);
642  *data_size = sizeof(struct in6_addr);
643  GNUNET_memcpy(*data, &value_aaaa, sizeof(value_aaaa));
644  return GNUNET_OK;
645 
647  unsigned int usage;
648  unsigned int selector;
649  unsigned int matching_type;
650  size_t slen = strlen(s) + 1;
651  char hex[slen];
652 
653  if (4 != sscanf(s, "%u %u %u %s", &usage, &selector, &matching_type, hex))
654  {
656  _("Unable to parse TLSA record string `%s'\n"),
657  s);
658  *data_size = 0;
659  return GNUNET_SYSERR;
660  }
661 
662  *data_size = sizeof(struct GNUNET_TUN_DnsTlsaRecord) + strlen(hex) / 2;
663  *data = tlsa = GNUNET_malloc(*data_size);
664  tlsa->usage = (uint8_t)usage;
665  tlsa->selector = (uint8_t)selector;
666  tlsa->matching_type = (uint8_t)matching_type;
667  if (strlen(hex) / 2 != GNUNET_DNSPARSER_hex_to_bin(hex, &tlsa[1]))
668  {
670  _("Unable to parse TLSA record string `%s'\n"),
671  s);
672  GNUNET_free(*data);
673  *data = NULL;
674  *data_size = 0;
675  return GNUNET_SYSERR;
676  }
677  return GNUNET_OK;
678  }
679 
680  case GNUNET_DNSPARSER_TYPE_CAA: { //RFC6844
681  struct GNUNET_DNSPARSER_CaaRecord *caa;
682  unsigned int flags;
683  char tag[15]; //Max tag length 15
684  char value[strlen(s) + 1]; //Should be more than enough
685 
686  if (3 != sscanf(s, "%u %s %[^\n]", &flags, tag, value))
687  {
689  _("Unable to parse CAA record string `%s'\n"),
690  s);
691  *data_size = 0;
692  return GNUNET_SYSERR;
693  }
694  *data_size = sizeof(struct GNUNET_DNSPARSER_CaaRecord) + strlen(tag) +
695  strlen(value);
696  *data = caa = GNUNET_malloc(*data_size);
697  caa->flags = flags;
698  memcpy(&caa[1], tag, strlen(tag));
699  caa->tag_len = strlen(tag);
700  memcpy((char *)&caa[1] + caa->tag_len, value, strlen(value));
701  return GNUNET_OK;
702  }
703 
704  default:
705  return GNUNET_SYSERR;
706  }
707 }
708 
709 
714 static struct {
715  const char *name;
716  uint32_t number;
717 } name_map[] = { { "A", GNUNET_DNSPARSER_TYPE_A },
718  { "NS", GNUNET_DNSPARSER_TYPE_NS },
719  { "CNAME", GNUNET_DNSPARSER_TYPE_CNAME },
720  { "SOA", GNUNET_DNSPARSER_TYPE_SOA },
721  { "PTR", GNUNET_DNSPARSER_TYPE_PTR },
722  { "MX", GNUNET_DNSPARSER_TYPE_MX },
723  { "TXT", GNUNET_DNSPARSER_TYPE_TXT },
724  { "AAAA", GNUNET_DNSPARSER_TYPE_AAAA },
725  { "SRV", GNUNET_DNSPARSER_TYPE_SRV },
726  { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA },
727  { "CERT", GNUNET_DNSPARSER_TYPE_CERT },
728  { "CAA", GNUNET_DNSPARSER_TYPE_CAA },
729  { NULL, UINT32_MAX } };
730 
731 
739 static uint32_t
740 dns_typename_to_number(void *cls, const char *dns_typename)
741 {
742  unsigned int i;
743 
744  i = 0;
745  while ((NULL != name_map[i].name) &&
746  (0 != strcasecmp(dns_typename, name_map[i].name)))
747  i++;
748  return name_map[i].number;
749 }
750 
751 
759 static const char *
760 dns_number_to_typename(void *cls, uint32_t type)
761 {
762  unsigned int i;
763 
764  i = 0;
765  while ((NULL != name_map[i].name) && (type != name_map[i].number))
766  i++;
767  return name_map[i].name;
768 }
769 
770 
777 void *
779 {
781 
787  return api;
788 }
789 
790 
797 void *
799 {
801 
802  GNUNET_free(api);
803  return NULL;
804 }
805 
806 /* end of plugin_gnsrecord_dns.c */
void * libgnunet_plugin_gnsrecord_dns_done(void *cls)
Exit point from the plugin.
void GNUNET_DNSPARSER_free_soa(struct GNUNET_DNSPARSER_SoaRecord *soa)
Free SOA information record.
Definition: dnsparser.c:108
GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number
Typename to number.
Information from SOA records (RFC 1035).
GNUNET_GNSRECORD_ValueToStringFunction value_to_string
Conversion to string.
uint32_t retry
Time interval that should elapse before a failed refresh should be retried.
char * GNUNET_DNSPARSER_parse_name(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse name inside of a DNS query or record.
Definition: dnsparser.c:334
uint32_t refresh
Time interval before the zone should be refreshed.
Information from CAA records (RFC 6844).
GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename
Number to typename.
char * mname
The domainname of the name server that was the original or primary source of data for this zone...
enum GNUNET_DNSPARSER_CertAlgorithm algorithm
Algorithm.
void GNUNET_DNSPARSER_free_srv(struct GNUNET_DNSPARSER_SrvRecord *srv)
Free SRV information record.
Definition: dnsparser.c:139
#define GNUNET_DNSPARSER_TYPE_CNAME
char * mxhost
Name of the mail server.
enum GNUNET_DNSPARSER_CertType cert_type
Certificate type.
uint16_t cert_tag
Certificate KeyTag.
GNUNET_GNSRECORD_StringToValueFunction string_to_value
Conversion to binary.
const char * name
Information from CERT records (RFC 4034).
int GNUNET_DNSPARSER_builder_add_srv(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SrvRecord *srv)
Add an SRV record to the UDP packet at the given location.
Definition: dnsparser.c:1117
void * cls
Closure for all of the callbacks.
static struct @26 name_map[]
Mapping of record type numbers to human-readable record type names.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_parse_soa(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS SOA record.
Definition: dnsparser.c:391
static int dns_string_to_value(void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of a record to the binary representation.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Payload of DNS CERT record.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint8_t usage
Certificate usage 0: CA cert 1: Entity cert 2: Trust anchor 3: domain-issued cert.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_DNSPARSER_TYPE_MX
Information from MX records (RFC 1035).
uint32_t number
def usage()
Definition: gnunet-chk.py:356
static unsigned int rfc4398_mnemonic_to_value(const char *mnemonic)
Convert RFC 4394 Mnemonics to the corresponding integer values.
uint32_t serial
The version number of the original copy of the zone.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_DNSPARSER_TYPE_PTR
size_t GNUNET_DNSPARSER_hex_to_bin(const char *hex, void *data)
Convert a HEX string to block of binary data.
Definition: dnsparser.c:1376
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
uint32_t minimum_ttl
The bit minimum TTL field that should be exported with any RR from this zone.
uint8_t flags
The flags of the CAA record.
#define GNUNET_DNSPARSER_TYPE_SOA
static char * value
Value of the record to add/remove.
uint16_t port
TCP or UDP port of the service.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
char * target
Hostname offering the service.
static struct PeerEntry ** table
Table with our interned peer IDs.
Definition: peer.c:54
struct GNUNET_DNSPARSER_CertRecord * GNUNET_DNSPARSER_parse_cert(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS CERT record.
Definition: dnsparser.c:518
char * rname
A domainname which specifies the mailbox of the person responsible for this zone. ...
struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_parse_srv(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS SRV record.
Definition: dnsparser.c:477
Payload of DNSSEC TLSA record.
static int result
Global testing status.
int GNUNET_DNSPARSER_builder_add_soa(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SoaRecord *soa)
Add an SOA record to the UDP packet at the given location.
Definition: dnsparser.c:1076
static const char * dns_number_to_typename(void *cls, uint32_t type)
Convert a type number (i.e.
uint32_t expire
Time value that specifies the upper limit on the time interval that can elapse before the zone is no ...
struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_parse_mx(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS MX record.
Definition: dnsparser.c:436
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1920
int GNUNET_DNSPARSER_builder_add_cert(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert)
Add CERT record to the UDP packet at the given location.
Definition: dnsparser.c:1029
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
Definition: strings.c:1856
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint8_t matching_type
Matching type (of selected content) 0: exact match 1: SHA-256 hash 2: SHA-512 hash.
int GNUNET_DNSPARSER_builder_add_mx(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_MxRecord *mx)
Add an MX record to the UDP packet at the given location.
Definition: dnsparser.c:1000
#define GNUNET_DNSPARSER_TYPE_TXT
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
#define GNUNET_DNSPARSER_TYPE_TLSA
static char * dns_value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
uint8_t selector
Selector What part will be matched against the cert presented by server 0: Full cert (in binary) 1: F...
size_t certificate_size
Number of bytes in certificate_data.
static uint32_t dns_typename_to_number(void *cls, const char *dns_typename)
Convert a type name (i.e.
static unsigned int rfc4034_mnemonic_to_value(const char *mnemonic)
Convert RFC 4034 algorithm types to the corresponding integer values.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
#define GNUNET_DNSPARSER_TYPE_CAA
#define GNUNET_DNSPARSER_TYPE_AAAA
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define GNUNET_DNSPARSER_TYPE_NS
void GNUNET_DNSPARSER_free_cert(struct GNUNET_DNSPARSER_CertRecord *cert)
Free CERT information record.
Definition: dnsparser.c:124
#define GNUNET_log(kind,...)
uint16_t priority
Preference for this entry (lower value is higher preference).
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint16_t weight
Relative weight for records with the same priority.
char * certificate_data
Data of the certificate.
int GNUNET_DNSPARSER_builder_add_name(char *dst, size_t dst_len, size_t *off, const char *name)
Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as neces...
Definition: dnsparser.c:888
void * libgnunet_plugin_gnsrecord_dns_init(void *cls)
Entry point for the plugin.
#define GNUNET_DNSPARSER_TYPE_SRV
uint32_t data
The data value.
uint16_t preference
Preference for this entry (lower value is higher preference).
static size_t data_size
Number of bytes in data.
void GNUNET_DNSPARSER_free_mx(struct GNUNET_DNSPARSER_MxRecord *mx)
Free MX information record.
Definition: dnsparser.c:154
#define GNUNET_DNSPARSER_TYPE_A
#define GNUNET_DNSPARSER_TYPE_CERT
#define GNUNET_malloc(size)
Wrapper around malloc.
char * GNUNET_DNSPARSER_bin_to_hex(const void *data, size_t data_size)
Convert a block of binary data to HEX.
Definition: dnsparser.c:1353
Information from SRV records (RFC 2782).
#define GNUNET_free(ptr)
Wrapper around free.
uint8_t tag_len
The length of the tag.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...