gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 01/09: URI & SMIMEA DNS RR


From: gnunet
Subject: [gnunet] 01/09: URI & SMIMEA DNS RR
Date: Fri, 01 Dec 2023 10:26:48 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 4bbdc27dea7445bfa22af9b675b049ffc23b96b1
Author: Sebastian Nadler <sebastian.nadler@tum.de>
AuthorDate: Wed Oct 25 22:01:39 2023 +0200

    URI & SMIMEA DNS RR
---
 src/cli/namestore/gnunet-namestore.c             |   3 +-
 src/cli/namestore/gnunet-zoneimport.c            |  11 ++
 src/include/gnunet_dnsparser_lib.h               |  86 +++++++++++++++
 src/include/gnunet_tun_lib.h                     |  23 ++++
 src/lib/util/dnsparser.c                         | 130 +++++++++++++++++++++++
 src/plugin/gnsrecord/plugin_gnsrecord_dns.c      |  67 +++++++++++-
 src/service/dns/gnunet-dns-monitor.c             |  17 +++
 src/service/dns/gnunet-zonewalk.c                |  11 +-
 src/service/gns/gnunet-service-gns_interceptor.c |  10 ++
 src/service/gns/gnunet-service-gns_resolver.c    |  55 ++++++++++
 10 files changed, 409 insertions(+), 4 deletions(-)

diff --git a/src/cli/namestore/gnunet-namestore.c 
b/src/cli/namestore/gnunet-namestore.c
index baa036ac7..00eacfcfd 100644
--- a/src/cli/namestore/gnunet-namestore.c
+++ b/src/cli/namestore/gnunet-namestore.c
@@ -1465,10 +1465,11 @@ run_with_zone_pkey (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
     }
     if ((GNUNET_DNSPARSER_TYPE_SRV == type) ||
         (GNUNET_DNSPARSER_TYPE_TLSA == type) ||
+        (GNUNET_DNSPARSER_TYPE_SMIMEA == type) ||
         (GNUNET_DNSPARSER_TYPE_OPENPGPKEY == type))
     {
       fprintf (stderr,
-               _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'"));
+               _ ("For DNS record types `SRV', `TLSA', `SMIMEA' and 
`OPENPGPKEY'"));
       fprintf (stderr, ", please use a `BOX' record instead\n");
       ret = 1;
       finish_command ();
diff --git a/src/cli/namestore/gnunet-zoneimport.c 
b/src/cli/namestore/gnunet-zoneimport.c
index c7e0cf65f..9e8185653 100644
--- a/src/cli/namestore/gnunet-zoneimport.c
+++ b/src/cli/namestore/gnunet-zoneimport.c
@@ -876,6 +876,17 @@ process_record (void *cls, const struct 
GNUNET_DNSPARSER_Record *rec)
     }
     break;
 
+  case GNUNET_DNSPARSER_TYPE_URI:
+    if (GNUNET_OK ==
+        GNUNET_DNSPARSER_builder_add_uri (dst, dst_len, &off, rec->data.uri))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Converting URI record for `%s'\n",
+                  rec->name);
+      add_record (req, rec->type, expiration_time, dst, off);
+    }
+    break;
+
   case GNUNET_DNSPARSER_TYPE_PTR:
     if (GNUNET_OK == GNUNET_DNSPARSER_builder_add_name (dst,
                                                         dst_len,
diff --git a/src/include/gnunet_dnsparser_lib.h 
b/src/include/gnunet_dnsparser_lib.h
index 8064b554b..9a84f346f 100644
--- a/src/include/gnunet_dnsparser_lib.h
+++ b/src/include/gnunet_dnsparser_lib.h
@@ -84,6 +84,7 @@
 #define GNUNET_DNSPARSER_TYPE_NSEC3 50
 #define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51
 #define GNUNET_DNSPARSER_TYPE_TLSA 52
+#define GNUNET_DNSPARSER_TYPE_SMIMEA 53
 #define GNUNET_DNSPARSER_TYPE_HIP 55
 #define GNUNET_DNSPARSER_TYPE_CDS 59
 #define GNUNET_DNSPARSER_TYPE_CDNSKEY 60
@@ -177,6 +178,33 @@ struct GNUNET_DNSPARSER_SrvRecord
 };
 
 
+/**
+ * Information from URI records (RFC 7553).
+ */
+struct GNUNET_DNSPARSER_UriRecord
+{
+  /**
+   * URI of the target,
+   * where the URI is as specified in RFC 3986.
+   */
+  char *target;
+
+  /**
+   * Preference for this entry (lower value is higher preference).  Clients
+   * will contact hosts from the lowest-priority group first and fall back
+   * to higher priorities if the low-priority entries are unavailable.
+   */
+  uint16_t priority;
+
+  /**
+   * Relative weight for records with the same priority.  Clients will use
+   * the hosts of the same (lowest) priority with a probability proportional
+   * to the weight given.
+   */
+  uint16_t weight;
+};
+
+
 /**
  * DNS CERT types as defined in RFC 4398.
  */
@@ -478,6 +506,11 @@ struct GNUNET_DNSPARSER_Record
      */
     struct GNUNET_DNSPARSER_SrvRecord *srv;
 
+    /**
+     * URI data for URI records.
+     */
+    struct GNUNET_DNSPARSER_UriRecord *uri;
+
     /**
      * Raw data for all other types.
      */
@@ -743,6 +776,25 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst,
                                   size_t *off,
                                   const struct GNUNET_DNSPARSER_SrvRecord 
*srv);
 
+
+/**
+ * Add an URI record to the UDP packet at the given location.
+ *
+ * @param dst where to write the URI record
+ * @param dst_len number of bytes in @a dst
+ * @param off pointer to offset where to write the URI information (increment 
by bytes used)
+ *            can also change if there was an error
+ * @param uri URI information to write
+ * @return #GNUNET_SYSERR if @a uri is invalid
+ *         #GNUNET_NO if @a uri did not fit
+ *         #GNUNET_OK if @a uri was added to @a dst
+ */
+int
+GNUNET_DNSPARSER_builder_add_uri (char *dst,
+                                  size_t dst_len,
+                                  size_t *off,
+                                  const struct GNUNET_DNSPARSER_UriRecord 
*uri);
+
 /* ***************** low-level parsing API ******************** */
 
 /**
@@ -853,6 +905,21 @@ GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
                             size_t udp_payload_length,
                             size_t *off);
 
+
+/**
+ * Parse a DNS URI record.
+ *
+ * @param udp_payload reference to UDP packet
+ * @param udp_payload_length length of @a udp_payload
+ * @param off pointer to the offset of the query to parse in the URI record 
(to be
+ *                    incremented by the size of the record), unchanged on 
error
+ * @return the parsed URI record, NULL on error
+ */
+struct GNUNET_DNSPARSER_UriRecord *
+GNUNET_DNSPARSER_parse_uri (const char *udp_payload,
+                            size_t udp_payload_length,
+                            size_t *off);
+
 /* ***************** low-level duplication API ******************** */
 
 /**
@@ -909,6 +976,16 @@ GNUNET_DNSPARSER_duplicate_srv_record (const struct
                                        GNUNET_DNSPARSER_SrvRecord *r);
 
 
+/**
+ * Duplicate (deep-copy) the given DNS record
+ *
+ * @param r the record
+ * @return the newly allocated record
+ */
+struct GNUNET_DNSPARSER_UriRecord *
+GNUNET_DNSPARSER_duplicate_uri_record (const struct
+                                       GNUNET_DNSPARSER_UriRecord *r);
+
 /* ***************** low-level deallocation API ******************** */
 
 /**
@@ -938,6 +1015,15 @@ void
 GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv);
 
 
+/**
+ * Free URI information record.
+ *
+ * @param uri record to free
+ */
+void
+GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri);
+
+
 /**
  * Free SOA information record.
  *
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h
index 17acfe5f8..6c7d2cd42 100644
--- a/src/include/gnunet_tun_lib.h
+++ b/src/include/gnunet_tun_lib.h
@@ -549,6 +549,29 @@ struct GNUNET_TUN_DnsSrvRecord
 };
 
 
+/**
+ * Payload of DNS URI record (header).
+ */
+struct GNUNET_TUN_DnsUriRecord
+{
+  /**
+   * Preference for this entry (lower value is higher preference).  Clients
+   * will contact hosts from the lowest-priority group first and fall back
+   * to higher priorities if the low-priority entries are unavailable. (NBO)
+   */
+  uint16_t prio GNUNET_PACKED;
+
+  /**
+   * Relative weight for records with the same priority.  Clients will use
+   * the hosts of the same (lowest) priority with a probability proportional
+   * to the weight given. (NBO)
+   */
+  uint16_t weight GNUNET_PACKED;
+
+  /* followed by 'target' name */
+};
+
+
 /**
  * Payload of DNS CERT record.
  */
diff --git a/src/lib/util/dnsparser.c b/src/lib/util/dnsparser.c
index dab38def7..eb2d8a93b 100644
--- a/src/lib/util/dnsparser.c
+++ b/src/lib/util/dnsparser.c
@@ -145,6 +145,21 @@ GNUNET_DNSPARSER_free_srv (struct 
GNUNET_DNSPARSER_SrvRecord *srv)
 }
 
 
+/**
+ * Free URI information record.
+ *
+ * @param uri record to free
+ */
+void
+GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri)
+{
+  if (NULL == uri)
+    return;
+  GNUNET_free (uri->target);
+  GNUNET_free (uri);
+}
+
+
 /**
  * Free MX information record.
  *
@@ -183,6 +198,10 @@ GNUNET_DNSPARSER_free_record (struct 
GNUNET_DNSPARSER_Record *r)
     GNUNET_DNSPARSER_free_srv (r->data.srv);
     break;
 
+  case GNUNET_DNSPARSER_TYPE_URI:
+    GNUNET_DNSPARSER_free_uri (r->data.uri);
+    break;
+
   case GNUNET_DNSPARSER_TYPE_CERT:
     GNUNET_DNSPARSER_free_cert (r->data.cert);
     break;
@@ -505,6 +524,46 @@ GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
 }
 
 
+/**
+ * Parse a DNS URI record.
+ *
+ * @param udp_payload reference to UDP packet
+ * @param udp_payload_length length of @a udp_payload
+ * @param off pointer to the offset of the query to parse in the URI record 
(to be
+ *                    incremented by the size of the record), unchanged on 
error
+ * @return the parsed URI record, NULL on error
+ */
+struct GNUNET_DNSPARSER_UriRecord *
+GNUNET_DNSPARSER_parse_uri (const char *udp_payload,
+                            size_t udp_payload_length,
+                            size_t *off)
+{
+  struct GNUNET_DNSPARSER_UriRecord *uri;
+  struct GNUNET_TUN_DnsUriRecord uri_bin;
+  size_t old_off;
+
+  old_off = *off;
+  if (*off + sizeof(struct GNUNET_TUN_DnsUriRecord) > udp_payload_length)
+    return NULL;
+  GNUNET_memcpy (&uri_bin,
+                 &udp_payload[*off],
+                 sizeof(struct GNUNET_TUN_DnsUriRecord));
+  (*off) += sizeof(struct GNUNET_TUN_DnsUriRecord);
+  uri = GNUNET_new (struct GNUNET_DNSPARSER_UriRecord);
+  uri->priority = ntohs (uri_bin.prio);
+  uri->weight = ntohs (uri_bin.weight);
+  GNUNET_asprintf(&(uri->target), "%.*s", udp_payload_length - sizeof(struct 
GNUNET_TUN_DnsUriRecord), &udp_payload[*off]);
+  (*off) += sizeof(uri->target) + 1;
+  if (NULL == uri->target) // || GNUNET_STRINGS_parse_uri(uri->target, NULL, 
NULL) == GNUNET_NO)
+  {
+    GNUNET_DNSPARSER_free_uri (uri);
+    *off = old_off;
+    return NULL;
+  }
+  return uri;
+}
+
+
 /**
  * Parse a DNS CERT record.
  *
@@ -633,6 +692,16 @@ GNUNET_DNSPARSER_parse_record (const char *udp_payload,
     }
     return GNUNET_OK;
 
+  case GNUNET_DNSPARSER_TYPE_URI:
+    r->data.uri =
+      GNUNET_DNSPARSER_parse_uri (udp_payload, udp_payload_length, off);
+    if ((NULL == r->data.uri) || (old_off + data_len != *off))
+    {
+      GNUNET_break_op (0);
+      return GNUNET_SYSERR;
+    }
+    return GNUNET_OK;
+
   default:
     r->data.raw.data = GNUNET_malloc (data_len);
     r->data.raw.data_len = data_len;
@@ -768,6 +837,11 @@ GNUNET_DNSPARSER_duplicate_record (const struct 
GNUNET_DNSPARSER_Record *r)
       break;
     }
 
+  case GNUNET_DNSPARSER_TYPE_URI: {
+      dup->data.uri = GNUNET_DNSPARSER_duplicate_uri_record (r->data.uri);
+      break;
+    }
+
   default: {
       dup->data.raw.data = GNUNET_memdup (r->data.raw.data,
                                           r->data.raw.data_len);
@@ -845,6 +919,23 @@ GNUNET_DNSPARSER_duplicate_srv_record (
 }
 
 
+/**
+ * Duplicate (deep-copy) the given DNS record
+ *
+ * @param r the record
+ * @return the newly allocated record
+ */
+struct GNUNET_DNSPARSER_UriRecord *
+GNUNET_DNSPARSER_duplicate_uri_record (
+  const struct GNUNET_DNSPARSER_UriRecord *r)
+{
+  struct GNUNET_DNSPARSER_UriRecord *dup = GNUNET_memdup (r, sizeof(*r));
+
+  dup->target = GNUNET_strdup (r->target);
+  return dup;
+}
+
+
 /**
  * Free memory taken by a packet.
  *
@@ -1140,6 +1231,40 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst,
 }
 
 
+/**
+ * Add an URI record to the UDP packet at the given location.
+ *
+ * @param dst where to write the URI record
+ * @param dst_len number of bytes in @a dst
+ * @param off pointer to offset where to write the URI information (increment 
by bytes used)
+ *            can also change if there was an error
+ * @param uri URI information to write
+ * @return #GNUNET_SYSERR if @a uri is invalid
+ *         #GNUNET_NO if @a uri did not fit
+ *         #GNUNET_OK if @a uri was added to @a dst
+ */
+int
+GNUNET_DNSPARSER_builder_add_uri (char *dst,
+                                  size_t dst_len,
+                                  size_t *off,
+                                  const struct GNUNET_DNSPARSER_UriRecord *uri)
+{
+  struct GNUNET_TUN_DnsUriRecord sd;
+  int ret;
+
+  if (*off + sizeof(struct GNUNET_TUN_DnsUriRecord) > dst_len)
+    return GNUNET_NO;
+  sd.prio = htons (uri->priority);
+  sd.weight = htons (uri->weight);
+  GNUNET_memcpy (&dst[*off], &sd, sizeof(sd));
+  (*off) += sizeof(sd);
+  GNUNET_memcpy(&dst[*off], uri->target, sizeof(uri->target));
+  (*off) += sizeof(uri->target);
+  dst[*off++] = '\0'; 
+  return GNUNET_OK;
+}
+
+
 /**
  * Add a DNS record to the UDP packet at the given location.
  *
@@ -1205,6 +1330,11 @@ add_record (char *dst,
       GNUNET_DNSPARSER_builder_add_srv (dst, dst_len, &pos, record->data.srv);
     break;
 
+  case GNUNET_DNSPARSER_TYPE_URI:
+    ret =
+      GNUNET_DNSPARSER_builder_add_uri (dst, dst_len, &pos, record->data.uri);
+    break;
+
   default:
     if (pos + record->data.raw.data_len > dst_len)
     {
diff --git a/src/plugin/gnsrecord/plugin_gnsrecord_dns.c 
b/src/plugin/gnsrecord/plugin_gnsrecord_dns.c
index 5844d9eda..226481c5d 100644
--- a/src/plugin/gnsrecord/plugin_gnsrecord_dns.c
+++ b/src/plugin/gnsrecord/plugin_gnsrecord_dns.c
@@ -207,7 +207,30 @@ dns_value_to_string (void *cls,
       GNUNET_DNSPARSER_free_srv (srv);
       return result;
     }
+  
+  case GNUNET_DNSPARSER_TYPE_URI: {   // RFC7553
+      struct GNUNET_DNSPARSER_UriRecord *uri;
+      size_t off;
 
+      off = 0;
+      uri = GNUNET_DNSPARSER_parse_uri (data, data_size, &off);
+      if ((NULL == uri) || (off != data_size))
+      {
+        GNUNET_break_op (0);
+        if (NULL != uri)
+          GNUNET_DNSPARSER_free_uri (uri);
+        return NULL;
+      }
+      GNUNET_asprintf (&result,
+                       "%d %d \"%s\"",
+                       uri->priority,
+                       uri->weight,
+                       uri->target);
+      GNUNET_DNSPARSER_free_uri (uri);
+      return result;
+  }
+
+  case GNUNET_DNSPARSER_TYPE_SMIMEA:
   case GNUNET_DNSPARSER_TYPE_TLSA: {
       const struct GNUNET_TUN_DnsTlsaRecord *tlsa;
       char *tlsa_str;
@@ -627,6 +650,43 @@ dns_string_to_value (void *cls,
       return GNUNET_OK;
     }
 
+  case GNUNET_DNSPARSER_TYPE_URI: {
+      struct GNUNET_DNSPARSER_UriRecord uri;
+      char target[strlen(s)];
+      unsigned int priority;
+      unsigned int weight;
+      size_t off;
+
+      if (3 != sscanf (s, "%u %u \"%s", &priority, &weight, &target)) // only 
\" bevor %s becuse %s will consume the ending " of the presentation of the URI 
record
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    _ ("Unable to parse URI record `%s'\n"),
+                    s);
+        return GNUNET_SYSERR;
+      }
+      target[strlen(target)-1] = '\0'; // Removing the last " of the 
presentation of the URI record
+
+      uri.priority = (uint16_t) priority;
+      uri.weight = (uint16_t) weight;
+      uri.target = target;
+      off = 0;
+
+      char uribuf[sizeof(struct GNUNET_TUN_DnsUriRecord) + strlen(target) + 
1]; 
+
+      if (GNUNET_OK !=
+          GNUNET_DNSPARSER_builder_add_uri (uribuf, sizeof(uribuf), &off, 
&uri))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    _ ("Failed to serialize URI record with target `%s'\n"),
+                    target);
+        return GNUNET_SYSERR;
+      }
+      *data_size = off;
+      *data = GNUNET_malloc (off);
+      GNUNET_memcpy (*data, uribuf, off);
+      return GNUNET_OK;
+    }
+
   case GNUNET_DNSPARSER_TYPE_TXT:
     *data = GNUNET_strdup (s);
     *data_size = strlen (s);
@@ -645,6 +705,7 @@ dns_string_to_value (void *cls,
     GNUNET_memcpy (*data, &value_aaaa, sizeof(value_aaaa));
     return GNUNET_OK;
 
+  case GNUNET_DNSPARSER_TYPE_SMIMEA:
   case GNUNET_DNSPARSER_TYPE_TLSA: {
       unsigned int usage;
       unsigned int selector;
@@ -656,7 +717,7 @@ dns_string_to_value (void *cls,
                        hex))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _ ("Unable to parse TLSA record string `%s'\n"),
+                    _ ("Unable to parse TLSA/SMIMEA record string `%s'\n"),
                     s);
         *data_size = 0;
         return GNUNET_SYSERR;
@@ -670,7 +731,7 @@ dns_string_to_value (void *cls,
       if (strlen (hex) / 2 != GNUNET_DNSPARSER_hex_to_bin (hex, &tlsa[1]))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _ ("Unable to parse TLSA record string `%s'\n"),
+                    _ ("Unable to parse TLSA/SMIMEA record string `%s'\n"),
                     s);
         GNUNET_free (*data);
         *data = NULL;
@@ -727,7 +788,9 @@ static struct
                  { "TXT", GNUNET_DNSPARSER_TYPE_TXT },
                  { "AAAA", GNUNET_DNSPARSER_TYPE_AAAA },
                  { "SRV", GNUNET_DNSPARSER_TYPE_SRV },
+                 { "URI", GNUNET_DNSPARSER_TYPE_URI },
                  { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA },
+                 { "SMIMEA", GNUNET_DNSPARSER_TYPE_SMIMEA },
                  { "CERT", GNUNET_DNSPARSER_TYPE_CERT },
                  { "CAA", GNUNET_DNSPARSER_TYPE_CAA },
                  { NULL, UINT32_MAX } };
diff --git a/src/service/dns/gnunet-dns-monitor.c 
b/src/service/dns/gnunet-dns-monitor.c
index c1ef17255..afdb336f0 100644
--- a/src/service/dns/gnunet-dns-monitor.c
+++ b/src/service/dns/gnunet-dns-monitor.c
@@ -84,6 +84,8 @@ get_type (uint16_t type)
   case GNUNET_DNSPARSER_TYPE_AAAA: return "AAAA";
 
   case GNUNET_DNSPARSER_TYPE_SRV: return "SRV";
+
+  case GNUNET_DNSPARSER_TYPE_URI: return "URI";
   }
   GNUNET_snprintf (buf, sizeof(buf), "%u", (unsigned int) type);
   return buf;
@@ -210,6 +212,21 @@ display_record (const struct GNUNET_DNSPARSER_Record 
*record)
       format = tmp;
     }
     break;
+  
+  case GNUNET_DNSPARSER_TYPE_URI:
+    if (NULL == record->data.uri)
+      format = "<invalid>";
+    else
+    {
+      GNUNET_asprintf (&tmp,
+                       "priority %u, weight = %u, target = \"%s\"",
+                       (unsigned int) record->data.uri->priority,
+                       (unsigned int) record->data.uri->weight,
+                       record->data.uri->target);
+      format = tmp;
+    }
+    break;
+
 
   case GNUNET_DNSPARSER_TYPE_TXT:
     GNUNET_asprintf (&tmp,
diff --git a/src/service/dns/gnunet-zonewalk.c 
b/src/service/dns/gnunet-zonewalk.c
index 0526df698..f4b676d6c 100644
--- a/src/service/dns/gnunet-zonewalk.c
+++ b/src/service/dns/gnunet-zonewalk.c
@@ -214,6 +214,15 @@ process_record (struct Request *req,
              rec->data.srv->weight,
              rec->data.srv->port);
     break;
+  
+  case GNUNET_DNSPARSER_TYPE_URI:
+    fprintf (stdout,
+             "%s URI \"%s\" %u %u\n",
+             req->hostname,
+             rec->data.uri->target,
+             rec->data.uri->priority,
+             rec->data.uri->weight);
+    break;
 
   case GNUNET_DNSPARSER_TYPE_PTR:
     fprintf (stdout,
@@ -247,7 +256,6 @@ process_record (struct Request *req,
   case GNUNET_DNSPARSER_TYPE_RP:
   case GNUNET_DNSPARSER_TYPE_TKEY:
   case GNUNET_DNSPARSER_TYPE_TSIG:
-  case GNUNET_DNSPARSER_TYPE_URI:
   case GNUNET_DNSPARSER_TYPE_TA:
 
   /* DNSSEC */
@@ -265,6 +273,7 @@ process_record (struct Request *req,
   case GNUNET_DNSPARSER_TYPE_SSHFP:
   case GNUNET_DNSPARSER_TYPE_IPSECKEY:
   case GNUNET_DNSPARSER_TYPE_TLSA:
+  case GNUNET_DNSPARSER_TYPE_SMIMEA:
   case GNUNET_DNSPARSER_TYPE_OPENPGPKEY:
 
   /* obsolete records */
diff --git a/src/service/gns/gnunet-service-gns_interceptor.c 
b/src/service/gns/gnunet-service-gns_interceptor.c
index f49d60b94..acc4e3fbc 100644
--- a/src/service/gns/gnunet-service-gns_interceptor.c
+++ b/src/service/gns/gnunet-service-gns_interceptor.c
@@ -168,6 +168,11 @@ reply_to_dns (void *cls, uint32_t rd_count,
           skip_answers++;
           break;
 
+        case GNUNET_DNSPARSER_TYPE_URI:
+          /* FIXME: URI is not yet supported */
+          skip_answers++;
+          break;
+
         case GNUNET_DNSPARSER_TYPE_MX:
           answer_records[i - skip_answers].data.mx
             = GNUNET_DNSPARSER_parse_mx (rd[i].data,
@@ -245,6 +250,11 @@ reply_to_dns (void *cls, uint32_t rd_count,
           skip_answers++;
           break;
 
+        case GNUNET_DNSPARSER_TYPE_URI:
+          /* FIXME: URI is not yet supported */
+          skip_answers++;
+          break;
+
         default:
           additional_records[i - skip_additional].data.raw.data_len =
             rd[i].data_size;
diff --git a/src/service/gns/gnunet-service-gns_resolver.c 
b/src/service/gns/gnunet-service-gns_resolver.c
index aa0189b15..edef6a8ab 100644
--- a/src/service/gns/gnunet-service-gns_resolver.c
+++ b/src/service/gns/gnunet-service-gns_resolver.c
@@ -1085,6 +1085,22 @@ dns_result_parser (void *cls,
         rd[i - skip].data_size = buf_off - buf_start;
         rd[i - skip].data = &buf[buf_start];
         break;
+      
+      case GNUNET_DNSPARSER_TYPE_URI:
+        buf_start = buf_off;
+        if (GNUNET_OK !=
+            GNUNET_DNSPARSER_builder_add_uri (buf,
+                                              sizeof(buf),
+                                              &buf_off,
+                                              rec->data.uri))
+        {
+          GNUNET_break (0);
+          skip++;
+          continue;
+        }
+        rd[i - skip].data_size = buf_off - buf_start;
+        rd[i - skip].data = &buf[buf_start];
+        break;
 
       default:
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -2170,6 +2186,45 @@ handle_gns_resolution_result (void *cls,
         }
         break;
 
+      case GNUNET_DNSPARSER_TYPE_URI:
+        {
+          struct GNUNET_DNSPARSER_UriRecord *uri;
+
+          off = 0;
+          uri = GNUNET_DNSPARSER_parse_uri (rd[i].data,
+                                            rd[i].data_size,
+                                            &off);
+          if ((NULL == uri) ||
+              (off != rd[i].data_size))
+          {
+            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    _ ("Failed to deserialize URI record with target\n"));
+            GNUNET_break_op (0);      /* record not well-formed */
+          }
+          else
+          {
+            scratch_start = scratch_off;
+            if (GNUNET_OK !=
+                GNUNET_DNSPARSER_builder_add_uri (scratch,
+                                                  sizeof(scratch),
+                                                  &scratch_off,
+                                                  uri))
+            {
+              GNUNET_break (0);
+            }
+            else
+            {
+              GNUNET_assert (rd_off < rd_count);
+              rd_new[rd_off].data = &scratch[scratch_start];
+              rd_new[rd_off].data_size = scratch_off - scratch_start;
+              rd_off++;
+            }
+          }
+          if (NULL != uri)
+            GNUNET_DNSPARSER_free_uri (uri);
+        }
+        break;
+
       case GNUNET_GNSRECORD_TYPE_PKEY:
       case GNUNET_GNSRECORD_TYPE_EDKEY:
         {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]