diff options
Diffstat (limited to 'src/gnsrecord/plugin_gnsrecord_dns.c')
-rw-r--r-- | src/gnsrecord/plugin_gnsrecord_dns.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c index a9dff4088..faae9cb77 100644 --- a/src/gnsrecord/plugin_gnsrecord_dns.c +++ b/src/gnsrecord/plugin_gnsrecord_dns.c | |||
@@ -502,17 +502,20 @@ dns_string_to_value (void *cls, | |||
502 | struct GNUNET_DNSPARSER_MxRecord mx; | 502 | struct GNUNET_DNSPARSER_MxRecord mx; |
503 | char mxbuf[258]; | 503 | char mxbuf[258]; |
504 | char mxhost[253 + 1]; | 504 | char mxhost[253 + 1]; |
505 | uint16_t mx_pref; | 505 | unsigned int mx_pref; |
506 | size_t off; | 506 | size_t off; |
507 | 507 | ||
508 | if (2 != SSCANF(s, "%hu,%253s", &mx_pref, mxhost)) | 508 | if (2 != SSCANF(s, |
509 | "%u,%253s", | ||
510 | &mx_pref, | ||
511 | mxhost)) | ||
509 | { | 512 | { |
510 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
511 | _("Unable to parse MX record `%s'\n"), | 514 | _("Unable to parse MX record `%s'\n"), |
512 | s); | 515 | s); |
513 | return GNUNET_SYSERR; | 516 | return GNUNET_SYSERR; |
514 | } | 517 | } |
515 | mx.preference = mx_pref; | 518 | mx.preference = (uint16_t) mx_pref; |
516 | mx.mxhost = mxhost; | 519 | mx.mxhost = mxhost; |
517 | off = 0; | 520 | off = 0; |
518 | 521 | ||
@@ -534,8 +537,46 @@ dns_string_to_value (void *cls, | |||
534 | } | 537 | } |
535 | case GNUNET_DNSPARSER_TYPE_SRV: | 538 | case GNUNET_DNSPARSER_TYPE_SRV: |
536 | { | 539 | { |
537 | GNUNET_break (0); // FIXME: not implemented! | 540 | struct GNUNET_DNSPARSER_SrvRecord srv; |
538 | return GNUNET_SYSERR; | 541 | char srvbuf[270]; |
542 | char srvtarget[253 + 1]; | ||
543 | unsigned int priority; | ||
544 | unsigned int weight; | ||
545 | unsigned int port; | ||
546 | size_t off; | ||
547 | |||
548 | if (2 != SSCANF(s, | ||
549 | "%u %u %u %253s", | ||
550 | &priority, | ||
551 | &weight, | ||
552 | &port, | ||
553 | srvtarget)) | ||
554 | { | ||
555 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
556 | _("Unable to parse SRV record `%s'\n"), | ||
557 | s); | ||
558 | return GNUNET_SYSERR; | ||
559 | } | ||
560 | srv.priority = (uint16_t) priority; | ||
561 | srv.weight = (uint16_t) weight; | ||
562 | srv.port = (uint16_t) port; | ||
563 | srv.target = srvtarget; | ||
564 | off = 0; | ||
565 | if (GNUNET_OK != | ||
566 | GNUNET_DNSPARSER_builder_add_srv (srvbuf, | ||
567 | sizeof (srvbuf), | ||
568 | &off, | ||
569 | &srv)) | ||
570 | { | ||
571 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
572 | _("Failed to serialize SRV record with target `%s'\n"), | ||
573 | srvtarget); | ||
574 | return GNUNET_SYSERR; | ||
575 | } | ||
576 | *data_size = off; | ||
577 | *data = GNUNET_malloc (off); | ||
578 | memcpy (*data, srvbuf, off); | ||
579 | return GNUNET_OK; | ||
539 | } | 580 | } |
540 | case GNUNET_DNSPARSER_TYPE_TXT: | 581 | case GNUNET_DNSPARSER_TYPE_TXT: |
541 | *data = GNUNET_strdup (s); | 582 | *data = GNUNET_strdup (s); |