+ if (*off + sizeof (struct GNUNET_TUN_DnsCertRecord) + cert->certificate_size > dst_len)
+ return GNUNET_NO;
+ dcert.cert_type = htons ((uint16_t) cert->cert_type);
+ dcert.cert_tag = htons ((uint16_t) cert->cert_tag);
+ dcert.algorithm = (uint8_t) cert->algorithm;
+ memcpy (&dst[*off], &dcert, sizeof (dcert));
+ (*off) += sizeof (dcert);
+ memcpy (&dst[*off], cert->certificate_data, cert->certificate_size);
+ (*off) += cert->certificate_size;
+ return GNUNET_OK;
+}
+
+
+/**
+ * Add an SOA record to the UDP packet at the given location.
+ *
+ * @param dst where to write the SOA record
+ * @param dst_len number of bytes in @a dst
+ * @param off pointer to offset where to write the SOA information (increment by bytes used)
+ * can also change if there was an error
+ * @param soa SOA information to write
+ * @return #GNUNET_SYSERR if @a soa is invalid
+ * #GNUNET_NO if @a soa did not fit
+ * #GNUNET_OK if @a soa was added to @a dst
+ */
+int
+GNUNET_DNSPARSER_builder_add_soa (char *dst,
+ size_t dst_len,
+ size_t *off,
+ const struct GNUNET_DNSPARSER_SoaRecord *soa)
+{
+ struct GNUNET_TUN_DnsSoaRecord sd;
+ int ret;
+
+ if ( (GNUNET_OK != (ret = GNUNET_DNSPARSER_builder_add_name (dst,
+ dst_len,
+ off,
+ soa->mname))) ||
+ (GNUNET_OK != (ret = GNUNET_DNSPARSER_builder_add_name (dst,
+ dst_len,
+ off,
+ soa->rname)) ) )
+ return ret;
+ if (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > dst_len)
+ return GNUNET_NO;
+ sd.serial = htonl (soa->serial);
+ sd.refresh = htonl (soa->refresh);
+ sd.retry = htonl (soa->retry);
+ sd.expire = htonl (soa->expire);
+ sd.minimum = htonl (soa->minimum_ttl);
+ memcpy (&dst[*off], &sd, sizeof (sd));
+ (*off) += sizeof (sd);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Add an SRV record to the UDP packet at the given location.
+ *
+ * @param dst where to write the SRV record
+ * @param dst_len number of bytes in @a dst
+ * @param off pointer to offset where to write the SRV information (increment by bytes used)
+ * can also change if there was an error
+ * @param srv SRV information to write
+ * @return #GNUNET_SYSERR if @a srv is invalid
+ * #GNUNET_NO if @a srv did not fit
+ * #GNUNET_OK if @a srv was added to @a dst
+ */
+int
+GNUNET_DNSPARSER_builder_add_srv (char *dst,
+ size_t dst_len,
+ size_t *off,
+ const struct GNUNET_DNSPARSER_SrvRecord *srv)
+{
+ struct GNUNET_TUN_DnsSrvRecord sd;
+ int ret;
+
+ if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > dst_len)
+ return GNUNET_NO;
+ sd.prio = htons (srv->priority);
+ sd.weight = htons (srv->weight);
+ sd.port = htons (srv->port);
+ memcpy (&dst[*off], &sd, sizeof (sd));
+ (*off) += sizeof (sd);
+ if (GNUNET_OK != (ret = GNUNET_DNSPARSER_builder_add_name (dst,
+ dst_len,
+ off,
+ srv->target)))
+ return ret;
+ return GNUNET_OK;
+}
+