gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28647 - in gnunet/src: dns gns include namestore


From: gnunet
Subject: [GNUnet-SVN] r28647 - in gnunet/src: dns gns include namestore
Date: Thu, 15 Aug 2013 12:52:06 +0200

Author: grothoff
Date: 2013-08-15 12:52:06 +0200 (Thu, 15 Aug 2013)
New Revision: 28647

Removed:
   gnunet/src/dns/dnsparser.h
   gnunet/src/include/gns_protocol.h
Modified:
   gnunet/src/dns/Makefile.am
   gnunet/src/dns/dnsparser.c
   gnunet/src/dns/gnunet-dns-monitor.c
   gnunet/src/dns/gnunet-service-dns.c
   gnunet/src/gns/gnunet-dns2gns.c
   gnunet/src/gns/gnunet-service-gns_interceptor.c
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/gns/test_gns_simple_srv_lookup.c
   gnunet/src/include/Makefile.am
   gnunet/src/include/gnunet_dnsparser_lib.h
   gnunet/src/include/gnunet_tun_lib.h
   gnunet/src/namestore/namestore_api_common.c
Log:
-eliminating duplicate struct definitions

Modified: gnunet/src/dns/Makefile.am
===================================================================
--- gnunet/src/dns/Makefile.am  2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/dns/Makefile.am  2013-08-15 10:52:06 UTC (rev 28647)
@@ -82,7 +82,7 @@
   libgnunetdnsstub.la
 
 libgnunetdnsparser_la_SOURCES = \
- dnsparser.c dnsparser.h
+ dnsparser.c 
 libgnunetdnsparser_la_LIBADD = \
  $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
   -lidn

Modified: gnunet/src/dns/dnsparser.c
===================================================================
--- gnunet/src/dns/dnsparser.c  2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/dns/dnsparser.c  2013-08-15 10:52:06 UTC (rev 28647)
@@ -31,7 +31,7 @@
 #endif
 #include "gnunet_util_lib.h"
 #include "gnunet_dnsparser_lib.h"
-#include "dnsparser.h"
+#include "gnunet_tun_lib.h"
 
 
 /**
@@ -235,7 +235,7 @@
             struct GNUNET_DNSPARSER_Query *q)
 {
   char *name;
-  struct query_line ql;
+  struct GNUNET_TUN_DnsQueryLine ql;
 
   name = parse_name (udp_payload, 
                     udp_payload_length,
@@ -243,7 +243,7 @@
   if (NULL == name)
     return GNUNET_SYSERR;
   q->name = name;
-  if (*off + sizeof (struct query_line) > udp_payload_length)
+  if (*off + sizeof (struct GNUNET_TUN_DnsQueryLine) > udp_payload_length)
     return GNUNET_SYSERR;
   memcpy (&ql, &udp_payload[*off], sizeof (ql));
   *off += sizeof (ql);
@@ -270,12 +270,12 @@
              struct GNUNET_DNSPARSER_Record *r)
 {
   char *name;
-  struct record_line rl;
+  struct GNUNET_TUN_DnsRecordLine rl;
   size_t old_off;
-  struct soa_data soa;
+  struct GNUNET_TUN_DnsSoaRecord soa;
   uint16_t mxpref;
   uint16_t data_len;
-  struct srv_data srv;
+  struct GNUNET_TUN_DnsSrvRecord srv;
   char *ndup;
   char *tok;
 
@@ -285,7 +285,7 @@
   if (NULL == name)
     return GNUNET_SYSERR;
   r->name = name;
-  if (*off + sizeof (struct record_line) > udp_payload_length)
+  if (*off + sizeof (struct GNUNET_TUN_DnsRecordLine) > udp_payload_length)
     return GNUNET_SYSERR;
   memcpy (&rl, &udp_payload[*off], sizeof (rl));
   (*off) += sizeof (rl);
@@ -320,15 +320,15 @@
                                     off, 0);
     if ( (NULL == r->data.soa->mname) ||
         (NULL == r->data.soa->rname) ||
-        (*off + sizeof (struct soa_data) > udp_payload_length) )
+        (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > udp_payload_length) )
       return GNUNET_SYSERR;
-    memcpy (&soa, &udp_payload[*off], sizeof (struct soa_data));
+    memcpy (&soa, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsSoaRecord));
     r->data.soa->serial = ntohl (soa.serial);
     r->data.soa->refresh = ntohl (soa.refresh);
     r->data.soa->retry = ntohl (soa.retry);
     r->data.soa->expire = ntohl (soa.expire);
     r->data.soa->minimum_ttl = ntohl (soa.minimum);
-    (*off) += sizeof (struct soa_data);
+    (*off) += sizeof (struct GNUNET_TUN_DnsSoaRecord);
     if (old_off + data_len != *off) 
       return GNUNET_SYSERR;
     return GNUNET_OK;
@@ -352,10 +352,10 @@
     if (NULL == strstr (r->name, "._"))
       return GNUNET_SYSERR; /* necessary string from "._$PROTO" not present */
     old_off = *off;
-    if (*off + sizeof (struct srv_data) > udp_payload_length)
+    if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
       return GNUNET_SYSERR;
-    memcpy (&srv, &udp_payload[*off], sizeof (struct srv_data));    
-    (*off) += sizeof (struct srv_data);
+    memcpy (&srv, &udp_payload[*off], sizeof (struct 
GNUNET_TUN_DnsSrvRecord));    
+    (*off) += sizeof (struct GNUNET_TUN_DnsSrvRecord);
     r->data.srv = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_SrvRecord));
     r->data.srv->priority = ntohs (srv.prio);
     r->data.srv->weight = ntohs (srv.weight);
@@ -685,9 +685,9 @@
           const struct GNUNET_DNSPARSER_Query *query)
 {
   int ret;
-  struct query_line ql;
+  struct GNUNET_TUN_DnsQueryLine ql;
 
-  ret = add_name (dst, dst_len - sizeof (struct query_line), off, query->name);
+  ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsQueryLine), off, 
query->name);
   if (ret != GNUNET_OK)
     return ret;
   ql.type = htons (query->type);
@@ -745,7 +745,7 @@
         size_t *off,
         const struct GNUNET_DNSPARSER_SoaRecord *soa)
 {
-  struct soa_data sd;
+  struct GNUNET_TUN_DnsSoaRecord sd;
   int ret;
 
   if ( (GNUNET_OK != (ret = add_name (dst,
@@ -757,7 +757,7 @@
                                      off,
                                      soa->rname)) ) )
     return ret;
-  if (*off + sizeof (struct soa_data) > dst_len)
+  if (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > dst_len)
     return GNUNET_NO;
   sd.serial = htonl (soa->serial);
   sd.refresh = htonl (soa->refresh);
@@ -788,10 +788,10 @@
         size_t *off,
         const struct GNUNET_DNSPARSER_SrvRecord *srv)
 {
-  struct srv_data sd;
+  struct GNUNET_TUN_DnsSrvRecord sd;
   int ret;
 
-  if (*off + sizeof (struct srv_data) > dst_len)
+  if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > dst_len)
     return GNUNET_NO;
   sd.prio = htons (srv->priority);
   sd.weight = htons (srv->weight);
@@ -828,7 +828,7 @@
   int ret;
   size_t start;
   size_t pos;
-  struct record_line rl;
+  struct GNUNET_TUN_DnsRecordLine rl;
   char *name;
   
   start = *off;
@@ -842,14 +842,14 @@
                     record->data.srv->service,
                     record->data.srv->proto,
                     record->data.srv->domain_name);
-  ret = add_name (dst, dst_len - sizeof (struct record_line), off, name);
+  ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsRecordLine), 
off, name);
   if (name != record->name)
     GNUNET_free (name);
   if (GNUNET_OK != ret)
     return ret;
   /* '*off' is now the position where we will need to write the record line */
 
-  pos = *off + sizeof (struct record_line);
+  pos = *off + sizeof (struct GNUNET_TUN_DnsRecordLine);
   switch (record->type)
   { 
   case GNUNET_DNSPARSER_TYPE_MX:
@@ -883,7 +883,7 @@
     return GNUNET_NO;
   }
 
-  if (pos - (*off + sizeof (struct record_line)) > UINT16_MAX)
+  if (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine)) > UINT16_MAX)
   {
     /* record data too long */
     *off = start;
@@ -892,8 +892,8 @@
   rl.type = htons (record->type);
   rl.class = htons (record->class);
   rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining 
(record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */
-  rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct 
record_line))));
-  memcpy (&dst[*off], &rl, sizeof (struct record_line));
+  rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct 
GNUNET_TUN_DnsRecordLine))));
+  memcpy (&dst[*off], &rl, sizeof (struct GNUNET_TUN_DnsRecordLine));
   *off = pos;
   return GNUNET_OK;  
 }

Deleted: gnunet/src/dns/dnsparser.h
===================================================================
--- gnunet/src/dns/dnsparser.h  2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/dns/dnsparser.h  2013-08-15 10:52:06 UTC (rev 28647)
@@ -1,195 +0,0 @@
-/*
-      This file is part of GNUnet
-      (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
-
-      GNUnet is free software; you can redistribute it and/or modify
-      it under the terms of the GNU General Public License as published
-      by the Free Software Foundation; either version 2, or (at your
-      option) any later version.
-
-      GNUnet is distributed in the hope that it will be useful, but
-      WITHOUT ANY WARRANTY; without even the implied warranty of
-      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-      General Public License for more details.
-
-      You should have received a copy of the GNU General Public License
-      along with GNUnet; see the file COPYING.  If not, write to the
-      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-      Boston, MA 02111-1307, USA.
- */
-
-/**
- * @file dns/dnsparser.h
- * @brief helper library to parse DNS packets. 
- * @author Philipp Toelke
- * @author Christian Grothoff
- * @author Martin Schanzenbach
- */
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/* FIXME: replace this one with the one from tcpip_tun.h!? */
-/**
- * Head of a any DNS message.
- */
-struct GNUNET_TUN_DnsHeader
-{
-  /**
-   * Request/response ID. (NBO)
-   */
-  uint16_t id GNUNET_PACKED;
-
-  /**
-   * Flags for the operation.
-   */
-  struct GNUNET_DNSPARSER_Flags flags; 
-
-  /**
-   * number of questions (NBO)
-   */
-  uint16_t query_count GNUNET_PACKED;
-
-  /**
-   * number of answers (NBO)
-   */
-  uint16_t answer_rcount GNUNET_PACKED;
-
-  /**
-   * number of authority-records (NBO)
-   */
-  uint16_t authority_rcount GNUNET_PACKED;
-
-  /**
-   * number of additional records (NBO)
-   */
-  uint16_t additional_rcount GNUNET_PACKED;
-};
-
-
-/**
- * DNS query prefix.
- */
-struct query_line
-{
-  /**
-   * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
-   */
-  uint16_t type GNUNET_PACKED;
-
-  /**
-   * Desired class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
-   */
-  uint16_t class GNUNET_PACKED;
-};
-
-
-/**
- * General DNS record prefix.
- */
-struct record_line
-{
-  /**
-   * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
-   */
-  uint16_t type GNUNET_PACKED;
-
-  /**
-   * Record class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
-   */
-  uint16_t class GNUNET_PACKED;
-
-  /**
-   * Expiration for the record (in seconds). (NBO)
-   */
-  uint32_t ttl GNUNET_PACKED;
-
-  /**
-   * Number of bytes of data that follow. (NBO)
-   */
-  uint16_t data_len GNUNET_PACKED;
-};
-
-
-/**
- * Payload of DNS SOA record (header).
- */
-struct soa_data
-{
-  /**
-   * The version number of the original copy of the zone.   (NBO)
-   */
-  uint32_t serial GNUNET_PACKED;
-  
-  /**
-   * Time interval before the zone should be refreshed. (NBO)
-   */
-  uint32_t refresh GNUNET_PACKED;
-  
-  /**
-   * Time interval that should elapse before a failed refresh should
-   * be retried. (NBO)
-   */
-  uint32_t retry GNUNET_PACKED;
- 
-  /**
-   * Time value that specifies the upper limit on the time interval
-   * that can elapse before the zone is no longer authoritative. (NBO)
-   */
-  uint32_t expire GNUNET_PACKED;
-
-  /**
-   * The bit minimum TTL field that should be exported with any RR
-   * from this zone. (NBO)
-   */
-  uint32_t minimum GNUNET_PACKED;
-};
-
-
-/**
- * Payload of DNS SRV record (header).
- */
-struct srv_data
-{
-
-  /**
-   * 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;
-
-  /**
-   * TCP or UDP port of the service. (NBO)
-   */
-  uint16_t port GNUNET_PACKED;
-
-  /* followed by 'target' name */
-};
-
-
-/**
- * Payload of GNS VPN record
- */
-struct vpn_data
-{
-  /**
-   * The peer to contact
-   */
-  struct GNUNET_HashCode peer;
-
-  /**
-   * The protocol to use
-   */
-  uint16_t proto GNUNET_PACKED;
-
-
-  /* followed by the servicename / identifier / password (0-terminated) */
-};
-
-GNUNET_NETWORK_STRUCT_END

Modified: gnunet/src/dns/gnunet-dns-monitor.c
===================================================================
--- gnunet/src/dns/gnunet-dns-monitor.c 2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/dns/gnunet-dns-monitor.c 2013-08-15 10:52:06 UTC (rev 28647)
@@ -94,9 +94,9 @@
   static char buf[6];
   switch (class)
   {
-  case GNUNET_DNSPARSER_CLASS_INTERNET: return "IN";
-  case GNUNET_DNSPARSER_CLASS_CHAOS: return "CHAOS";
-  case GNUNET_DNSPARSER_CLASS_HESIOD: return "HESIOD";
+  case GNUNET_TUN_DNS_CLASS_INTERNET: return "IN";
+  case GNUNET_TUN_DNS_CLASS_CHAOS: return "CHAOS";
+  case GNUNET_TUN_DNS_CLASS_HESIOD: return "HESIOD";
   }
   GNUNET_snprintf (buf, sizeof (buf), "%u", (unsigned int) class);
   return buf;

Modified: gnunet/src/dns/gnunet-service-dns.c
===================================================================
--- gnunet/src/dns/gnunet-service-dns.c 2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/dns/gnunet-service-dns.c 2013-08-15 10:52:06 UTC (rev 28647)
@@ -835,7 +835,7 @@
       /* if query changed to answer, move past DNS resolution phase... */
       if ( (RP_QUERY == rr->phase) &&
           (rr->payload_length > sizeof (struct GNUNET_TUN_DnsHeader)) &&
-          ((struct GNUNET_DNSPARSER_Flags*)&(((struct GNUNET_TUN_DnsHeader*) 
rr->payload)->flags))->query_or_response == 1)
+          ((struct GNUNET_TUN_DnsFlags*)&(((struct GNUNET_TUN_DnsHeader*) 
rr->payload)->flags))->query_or_response == 1)
       {
        rr->phase = RP_INTERNET_DNS;
        GNUNET_array_grow (rr->client_wait_list,

Modified: gnunet/src/gns/gnunet-dns2gns.c
===================================================================
--- gnunet/src/gns/gnunet-dns2gns.c     2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/gns/gnunet-dns2gns.c     2013-08-15 10:52:06 UTC (rev 28647)
@@ -281,14 +281,14 @@
   request->lookup = NULL;
   packet = request->packet;
   packet->flags.query_or_response = 1;
-  packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR;
+  packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
   packet->flags.checking_disabled = 0;
   packet->flags.authenticated_data = 1;
   packet->flags.zero = 0;
   packet->flags.recursion_available = 1;
   packet->flags.message_truncated = 0;
   packet->flags.authoritative_answer = 0;
-  //packet->flags.opcode = GNUNET_DNSPARSER_OPCODE_STATUS; // ???
+  //packet->flags.opcode = GNUNET_TUN_DNS_OPCODE_STATUS; // ???
   for (i=0;i<rd_count;i++)
     {
       rec.expiration_time.abs_value_us = rd[i].expiration_time;
@@ -297,7 +297,7 @@
        case GNUNET_DNSPARSER_TYPE_A:
          GNUNET_assert (sizeof (struct in_addr) == rd[i].data_size);
          rec.name = GNUNET_strdup (packet->queries[0].name);
-         rec.class = GNUNET_DNSPARSER_CLASS_INTERNET;
+         rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
          rec.type = GNUNET_DNSPARSER_TYPE_A;
          rec.data.raw.data = GNUNET_malloc (sizeof (struct in_addr));
          memcpy (rec.data.raw.data,
@@ -312,7 +312,7 @@
          GNUNET_assert (sizeof (struct in6_addr) == rd[i].data_size);
          rec.name = GNUNET_strdup (packet->queries[0].name);
          rec.data.raw.data = GNUNET_malloc (sizeof (struct in6_addr));
-         rec.class = GNUNET_DNSPARSER_CLASS_INTERNET;
+         rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
          rec.type = GNUNET_DNSPARSER_TYPE_AAAA;
          memcpy (rec.data.raw.data,
                  rd[i].data,
@@ -325,7 +325,7 @@
        case GNUNET_DNSPARSER_TYPE_CNAME:
          rec.name = GNUNET_strdup (packet->queries[0].name);
          rec.data.hostname = strdup (rd[i].data);
-         rec.class = GNUNET_DNSPARSER_CLASS_INTERNET;
+         rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
          rec.type = GNUNET_DNSPARSER_TYPE_CNAME;
          memcpy (rec.data.hostname,
                  rd[i].data,

Modified: gnunet/src/gns/gnunet-service-gns_interceptor.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_interceptor.c     2013-08-15 10:27:18 UTC 
(rev 28646)
+++ gnunet/src/gns/gnunet-service-gns_interceptor.c     2013-08-15 10:52:06 UTC 
(rev 28647)
@@ -148,7 +148,7 @@
        }
        GNUNET_break (0 == (rd[i].flags & 
GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
        answer_records[i].expiration_time.abs_value_us = rd[i].expiration_time;
-       answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;
+       answer_records[i].class = GNUNET_TUN_DNS_CLASS_INTERNET;
       }
       else
       {
@@ -176,16 +176,16 @@
        }
        GNUNET_break (0 == (rd[i].flags & 
GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
        additional_records[i].expiration_time.abs_value_us = 
rd[i].expiration_time;
-       additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET; 
+       additional_records[i].class = GNUNET_TUN_DNS_CLASS_INTERNET; 
       }
     }
     packet->num_answers = num_answers;
     packet->num_additional_records = rd_count - num_answers;
     packet->flags.authoritative_answer = 1;
     if (NULL == rd)
-      packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NAME_ERROR;
+      packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR;
     else
-      packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR;
+      packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
     packet->flags.query_or_response = 1;
     ret = GNUNET_DNSPARSER_pack (packet,
                                 1024, /* maximum allowed size for DNS reply */

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2013-08-15 10:27:18 UTC 
(rev 28646)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2013-08-15 10:52:06 UTC 
(rev 28647)
@@ -39,9 +39,7 @@
 #include "gnunet_dns_service.h"
 #include "gnunet_resolver_service.h"
 #include "gnunet_dnsparser_lib.h"
-#include "gns_protocol.h"
 #include "gnunet_gns_service.h"
-#include "gns_common.h"
 #include "gns.h"
 #include "gnunet-service-gns_resolver.h"
 #include "gnunet_vpn_service.h"
@@ -1168,7 +1166,7 @@
   struct RecordLookupHandle *rlh = rh->proc_cls;
   struct GNUNET_DNSPARSER_Query query;
   struct GNUNET_DNSPARSER_Packet packet;
-  struct GNUNET_DNSPARSER_Flags flags;
+  struct GNUNET_TUN_DnsFlags flags;
   struct in_addr dnsip;
   struct sockaddr_in addr;
   struct sockaddr *sa;
@@ -1242,7 +1240,7 @@
   }
   query.name = rh->dns_name;
   query.type = rlh->record_type;
-  query.class = GNUNET_DNSPARSER_CLASS_INTERNET;
+  query.class = GNUNET_TUN_DNS_CLASS_INTERNET;
   memset (&flags, 0, sizeof (flags));
   flags.recursion_desired = 1;
   flags.checking_disabled = 1;
@@ -1293,7 +1291,7 @@
 {
   struct RecordLookupHandle *rlh = rh->proc_cls;
   struct GNUNET_HashCode serv_desc;
-  struct vpn_data* vpn;
+  struct GNUNET_TUN_GnsVpnRecord* vpn;
   int af;
   
   /* We cancel here as to not include the ns lookup in the timeout */
@@ -1313,7 +1311,7 @@
                    rh->priv_key);
   }
 
-  vpn = (struct vpn_data*)rd->data;
+  vpn = (struct GNUNET_TUN_GnsVpnRecord*)rd->data;
   GNUNET_CRYPTO_hash ((char*)&vpn[1],
                       strlen ((char*)&vpn[1]) + 1,
                       &serv_desc);
@@ -1788,10 +1786,10 @@
   char new_mx_data[MAX_MX_LENGTH];
   char new_soa_data[MAX_SOA_LENGTH];
   char new_srv_data[MAX_SRV_LENGTH];
-  struct srv_data *old_srv;
-  struct srv_data *new_srv;
-  struct soa_data *old_soa;
-  struct soa_data *new_soa;
+  struct GNUNET_TUN_DnsSrvRecord *old_srv;
+  struct GNUNET_TUN_DnsSrvRecord *new_srv;
+  struct GNUNET_TUN_DnsSoaRecord *old_soa;
+  struct GNUNET_TUN_DnsSoaRecord *new_soa;
   struct GNUNET_NAMESTORE_RecordData p_rd[rd_count];
   char* repl_string;
   char* pos;
@@ -1853,8 +1851,8 @@
       /*
        * Prio, weight and port
        */
-      new_srv = (struct srv_data*)new_srv_data;
-      old_srv = (struct srv_data*)rd[i].data;
+      new_srv = (struct GNUNET_TUN_DnsSrvRecord*)new_srv_data;
+      old_srv = (struct GNUNET_TUN_DnsSrvRecord*)rd[i].data;
       new_srv->prio = old_srv->prio;
       new_srv->weight = old_srv->weight;
       new_srv->port = old_srv->port;
@@ -1862,14 +1860,14 @@
       expand_plus((char*)&new_srv[1], (char*)&old_srv[1],
                   repl_string);
       p_rd[i].data = new_srv_data;
-      p_rd[i].data_size = sizeof (struct srv_data) + strlen 
((char*)&new_srv[1]) + 1;
+      p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord) + strlen 
((char*)&new_srv[1]) + 1;
     }
     else if (GNUNET_DNSPARSER_TYPE_SOA == rd[i].record_type)
     {
       /* expand mname and rname */
-      old_soa = (struct soa_data*)rd[i].data;
-      new_soa = (struct soa_data*)new_soa_data;
-      memcpy (new_soa, old_soa, sizeof (struct soa_data));
+      old_soa = (struct GNUNET_TUN_DnsSoaRecord*)rd[i].data;
+      new_soa = (struct GNUNET_TUN_DnsSoaRecord*)new_soa_data;
+      memcpy (new_soa, old_soa, sizeof (struct GNUNET_TUN_DnsSoaRecord));
       // FIXME: how do we know that 'new_soa[1]' has enough space for the new 
name?
       expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string);
       offset = strlen ((char*)&new_soa[1]) + 1;
@@ -1877,7 +1875,7 @@
       expand_plus((char*)&new_soa[1] + offset,
                   (char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1,
                   repl_string);
-      p_rd[i].data_size = sizeof (struct soa_data)
+      p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSoaRecord)
                           + offset
                           + strlen ((char*)&new_soa[1] + offset);
       p_rd[i].data = new_soa_data;
@@ -2889,13 +2887,13 @@
   query = GNUNET_new (struct GNUNET_DNSPARSER_Query);
   query->name = GNUNET_strdup (ac->label);
   query->type = rh->record_type;
-  query->class = GNUNET_DNSPARSER_CLASS_INTERNET;
+  query->class = GNUNET_TUN_DNS_CLASS_INTERNET;
   p = GNUNET_new (struct GNUNET_DNSPARSER_Packet);
   p->queries = query;
   p->num_queries = 1;
   p->id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
                                               UINT16_MAX);
-  p->flags.opcode = GNUNET_DNSPARSER_OPCODE_QUERY;
+  p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY;
   p->flags.recursion_desired = 1;
   if (GNUNET_OK != 
       GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length))

Modified: gnunet/src/gns/test_gns_simple_srv_lookup.c
===================================================================
--- gnunet/src/gns/test_gns_simple_srv_lookup.c 2013-08-15 10:27:18 UTC (rev 
28646)
+++ gnunet/src/gns/test_gns_simple_srv_lookup.c 2013-08-15 10:52:06 UTC (rev 
28647)
@@ -189,7 +189,7 @@
   struct GNUNET_CRYPTO_ShortHashCode bob_hash;
   struct GNUNET_CRYPTO_EccSignature *sig;
   char* alice_keyfile;
-  struct srv_data *srv_data;
+  struct GNUNET_TUN_DnsSrvRecord *srv_data;
   struct GNUNET_TIME_Absolute et;
 
   cfg = ccfg;
@@ -222,7 +222,7 @@
   struct GNUNET_NAMESTORE_RecordData rd;
   char* ip = TEST_IP;
   struct in_addr *sipserver = GNUNET_malloc (sizeof (struct in_addr));
-  srv_data = GNUNET_malloc (sizeof (struct srv_data) + strlen (TEST_SRV_NAME) 
+ 1);
+  srv_data = GNUNET_malloc (sizeof (struct GNUNET_TUN_DnsSrvRecord) + strlen 
(TEST_SRV_NAME) + 1);
   uint16_t srv_weight = 60;
   uint16_t srv_prio = 50;
   uint16_t srv_port = 5060;
@@ -263,7 +263,7 @@
                                NULL);
   GNUNET_free (sig);
   
-  rd.data_size = sizeof (struct srv_data)+strlen(TEST_SRV_NAME)+1;
+  rd.data_size = sizeof (struct 
GNUNET_TUN_DnsSrvRecord)+strlen(TEST_SRV_NAME)+1;
   srv_data->port = srv_port;
   srv_data->prio = srv_prio;
   srv_data->weight = srv_weight;

Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am      2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/include/Makefile.am      2013-08-15 10:52:06 UTC (rev 28647)
@@ -18,7 +18,6 @@
 
 gnunetinclude_HEADERS = \
   platform.h plibc.h $(WINPROC) gettext.h \
-  gns_protocol.h \
   gnunet_applications.h \
   gnunet_arm_service.h \
   gnunet_ats_service.h \

Deleted: gnunet/src/include/gns_protocol.h
===================================================================
--- gnunet/src/include/gns_protocol.h   2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/include/gns_protocol.h   2013-08-15 10:52:06 UTC (rev 28647)
@@ -1,161 +0,0 @@
-/*
-      This file is part of GNUnet
-      (C) 2012 Christian Grothoff (and other contributing authors)
-
-      GNUnet is free software; you can redistribute it and/or modify
-      it under the terms of the GNU General Public License as published
-      by the Free Software Foundation; either version 2, or (at your
-      option) any later version.
-
-      GNUnet is distributed in the hope that it will be useful, but
-      WITHOUT ANY WARRANTY; without even the implied warranty of
-      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-      General Public License for more details.
-
-      You should have received a copy of the GNU General Public License
-      along with GNUnet; see the file COPYING.  If not, write to the
-      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-      Boston, MA 02111-1307, USA.
- */
-
-/**
- * @file include/gns_protocol.h
- * @brief Resource Record definitions
- * @author Martin Schanzenbach
- */
-#ifndef GNS_RECORDS_H
-#define GNS_RECORDS_H
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Payload of DNS SOA record (header).
- */
-struct soa_data
-{
-  /**
-   * The version number of the original copy of the zone.   (NBO)
-   */
-  uint32_t serial GNUNET_PACKED;
-  
-  /**
-   * Time interval before the zone should be refreshed. (NBO)
-   */
-  uint32_t refresh GNUNET_PACKED;
-  
-  /**
-   * Time interval that should elapse before a failed refresh should
-   * be retried. (NBO)
-   */
-  uint32_t retry GNUNET_PACKED;
- 
-  /**
-   * Time value that specifies the upper limit on the time interval
-   * that can elapse before the zone is no longer authoritative. (NBO)
-   */
-  uint32_t expire GNUNET_PACKED;
-
-  /**
-   * The bit minimum TTL field that should be exported with any RR
-   * from this zone. (NBO)
-   */
-  uint32_t minimum GNUNET_PACKED;
-};
-
-
-/**
- * Payload of DNS SRV record (header).
- */
-struct srv_data
-{
-
-  /**
-   * 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;
-
-  /**
-   * TCP or UDP port of the service. (NBO)
-   */
-  uint16_t port GNUNET_PACKED;
-
-  /* followed by 'target' name */
-};
-
-
-/**
- * Payload of DNSSEC TLSA record.
- * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/
- */
-struct tlsa_data
-{
-
-  /**
-   * Certificate usage
-   * 0: CA cert
-   * 1: Entity cert
-   * 2: Trust anchor
-   * 3: domain-issued cert
-   */
-  uint8_t usage;
-
-  /**
-   * Selector
-   * What part will be matched against the cert
-   * presented by server
-   * 0: Full cert (in binary)
-   * 1: Full cert (in DER)
-   */
-  uint8_t selector;
-
-  /**
-   * Matching type (of selected content)
-   * 0: exact match
-   * 1: SHA-256 hash
-   * 2: SHA-512 hash
-   */
-  uint8_t matching_type;
-
-  /**
-   * followed by certificate association data
-   * The "certificate association data" to be matched.
-   * These bytes are either raw data (that is, the full certificate or
-   * its SubjectPublicKeyInfo, depending on the selector) for matching
-   * type 0, or the hash of the raw data for matching types 1 and 2.
-   * The data refers to the certificate in the association, not to the
-   * TLS ASN.1 Certificate object.
-   *
-   * The data is represented as a string of hex chars
-   */
-};
-
-/**
- * Payload of GNS VPN record
- */
-struct vpn_data
-{
-  /**
-   * The peer to contact
-   */
-  struct GNUNET_HashCode peer;
-
-  /**
-   * The protocol to use
-   */
-  uint16_t proto;
-
-  /* followed by the servicename */
-};
-
-GNUNET_NETWORK_STRUCT_END
-
-#endif

Modified: gnunet/src/include/gnunet_dnsparser_lib.h
===================================================================
--- gnunet/src/include/gnunet_dnsparser_lib.h   2013-08-15 10:27:18 UTC (rev 
28646)
+++ gnunet/src/include/gnunet_dnsparser_lib.h   2013-08-15 10:52:06 UTC (rev 
28647)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
+      (C) 2010-2013 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
 #define GNUNET_DNSPARSER_LIB_H
 
 #include "gnunet_common.h"
+#include "gnunet_tun_lib.h"
 
 /**
  * Maximum length of a label in DNS.
@@ -54,152 +55,8 @@
 #define GNUNET_DNSPARSER_TYPE_SRV 33
 #define GNUNET_DNSPARSER_TYPE_TLSA 52
 
-/**
- * A few common DNS classes (ok, only one is common, but I list a
- * couple more to make it clear what we're talking about here).
- */
-#define GNUNET_DNSPARSER_CLASS_INTERNET 1
-#define GNUNET_DNSPARSER_CLASS_CHAOS 3
-#define GNUNET_DNSPARSER_CLASS_HESIOD 4
 
-#define GNUNET_DNSPARSER_OPCODE_QUERY 0
-#define GNUNET_DNSPARSER_OPCODE_INVERSE_QUERY 1
-#define GNUNET_DNSPARSER_OPCODE_STATUS 2
-
 /**
- * RFC 1035 codes.
- */
-#define GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR 0
-#define GNUNET_DNSPARSER_RETURN_CODE_FORMAT_ERROR 1
-#define GNUNET_DNSPARSER_RETURN_CODE_SERVER_FAILURE 2
-#define GNUNET_DNSPARSER_RETURN_CODE_NAME_ERROR 3
-#define GNUNET_DNSPARSER_RETURN_CODE_NOT_IMPLEMENTED 4
-#define GNUNET_DNSPARSER_RETURN_CODE_REFUSED 5
-
-/**
- * RFC 2136 codes
- */
-#define GNUNET_DNSPARSER_RETURN_CODE_YXDOMAIN 6
-#define GNUNET_DNSPARSER_RETURN_CODE_YXRRSET 7
-#define GNUNET_DNSPARSER_RETURN_CODE_NXRRSET 8
-#define GNUNET_DNSPARSER_RETURN_CODE_NOT_AUTH 9
-#define GNUNET_DNSPARSER_RETURN_CODE_NOT_ZONE 10
-
-/**
- * DNS flags (largely RFC 1035 / RFC 2136).
- */
-struct GNUNET_DNSPARSER_Flags
-{
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-  /**
-   * Set to 1 if recursion is desired (client -> server)
-   */
-  unsigned int recursion_desired    : 1 GNUNET_PACKED;  
-  
-  /**
-   * Set to 1 if message is truncated
-   */
-  unsigned int message_truncated    : 1 GNUNET_PACKED; 
-  
-  /**
-   * Set to 1 if this is an authoritative answer
-   */
-  unsigned int authoritative_answer : 1 GNUNET_PACKED;
-  
-  /**
-   * See GNUNET_DNSPARSER_OPCODE_ defines.
-   */
-  unsigned int opcode               : 4 GNUNET_PACKED;  
-  
-  /**
-   * query:0, response:1
-   */
-  unsigned int query_or_response    : 1 GNUNET_PACKED;  
-  
-  /**
-   * See GNUNET_DNSPARSER_RETURN_CODE_ defines.
-   */
-  unsigned int return_code          : 4 GNUNET_PACKED; 
-  
-  /**
-   * See RFC 4035.
-   */
-  unsigned int checking_disabled    : 1 GNUNET_PACKED; 
-  
-  /**
-   * Response has been cryptographically verified, RFC 4035.
-   */
-  unsigned int authenticated_data   : 1 GNUNET_PACKED;
-  
-  /**
-   * Always zero.
-   */
-  unsigned int zero                 : 1 GNUNET_PACKED;
-  
-  /**
-   * Set to 1 if recursion is available (server -> client)
-   */
-  unsigned int recursion_available  : 1 GNUNET_PACKED; 
-#elif __BYTE_ORDER == __BIG_ENDIAN
-  
-  /**
-   * query:0, response:1
-   */
-  unsigned int query_or_response    : 1 GNUNET_PACKED;  
-  
-  /**
-   * See GNUNET_DNSPARSER_OPCODE_ defines.
-   */
-  unsigned int opcode               : 4 GNUNET_PACKED;  
-  
-  /**
-   * Set to 1 if this is an authoritative answer
-   */
-  unsigned int authoritative_answer : 1 GNUNET_PACKED;
-  
-  /**
-   * Set to 1 if message is truncated
-   */
-  unsigned int message_truncated    : 1 GNUNET_PACKED; 
-  
-  /**
-   * Set to 1 if recursion is desired (client -> server)
-   */
-  unsigned int recursion_desired    : 1 GNUNET_PACKED;  
-
- 
-  /**
-   * Set to 1 if recursion is available (server -> client)
-   */
-  unsigned int recursion_available  : 1 GNUNET_PACKED;
-  
-  /**
-   * Always zero.
-   */
-  unsigned int zero                 : 1 GNUNET_PACKED;
-  
-  /**
-   * Response has been cryptographically verified, RFC 4035.
-   */
-  unsigned int authenticated_data   : 1 GNUNET_PACKED;
-  
-  /**
-   * See RFC 4035.
-   */
-  unsigned int checking_disabled    : 1 GNUNET_PACKED; 
-  
-  /**
-   * See GNUNET_DNSPARSER_RETURN_CODE_ defines.
-   */  
-  unsigned int return_code          : 4 GNUNET_PACKED; 
-#else
-  #error byteorder undefined
-#endif
-  
-} GNUNET_GCC_STRUCT_LAYOUT;
-
-
-/**
  * A DNS query.
  */
 struct GNUNET_DNSPARSER_Query
@@ -220,7 +77,7 @@
   uint16_t type;
 
   /**
-   * See GNUNET_DNSPARSER_CLASS_*.
+   * See GNUNET_TUN_DNS_CLASS_*.
    */
   uint16_t class;
 
@@ -459,7 +316,7 @@
   uint16_t type;
 
   /**
-   * See GNUNET_DNSPARSER_CLASS_*.
+   * See GNUNET_TUN_DNS_CLASS_*.
    */
   uint16_t class;
 
@@ -514,7 +371,7 @@
   /**
    * Bitfield of DNS flags.
    */ 
-  struct GNUNET_DNSPARSER_Flags flags;
+  struct GNUNET_TUN_DnsFlags flags;
 
   /**
    * DNS ID (to match replies to requests).

Modified: gnunet/src/include/gnunet_tun_lib.h
===================================================================
--- gnunet/src/include/gnunet_tun_lib.h 2013-08-15 10:27:18 UTC (rev 28646)
+++ gnunet/src/include/gnunet_tun_lib.h 2013-08-15 10:52:06 UTC (rev 28647)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2010, 2011, 2012 Christian Grothoff
+     (C) 2010-2013 Christian Grothoff
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -183,7 +183,14 @@
  */
 struct GNUNET_TUN_TcpHeader
 {
+  /**
+   * Source port (in NBO).
+   */
   uint16_t source_port GNUNET_PACKED;
+
+  /**
+   * Destination port (in NBO).
+   */
   uint16_t destination_port GNUNET_PACKED;
 
   /**
@@ -244,26 +251,387 @@
  */
 struct GNUNET_TUN_UdpHeader
 {
+  /**
+   * Source port (in NBO).
+   */
   uint16_t source_port GNUNET_PACKED;
+
+  /**
+   * Destination port (in NBO).
+   */
   uint16_t destination_port GNUNET_PACKED;
+
+  /**
+   * Number of bytes of payload.
+   */
   uint16_t len GNUNET_PACKED;
+
+  /**
+   * Checksum.
+   */
   uint16_t crc GNUNET_PACKED;
 };
 
 
+
 /**
+ * A few common DNS classes (ok, only one is common, but I list a
+ * couple more to make it clear what we're talking about here).
+ */
+#define GNUNET_TUN_DNS_CLASS_INTERNET 1
+#define GNUNET_TUN_DNS_CLASS_CHAOS 3
+#define GNUNET_TUN_DNS_CLASS_HESIOD 4
+
+#define GNUNET_TUN_DNS_OPCODE_QUERY 0
+#define GNUNET_TUN_DNS_OPCODE_INVERSE_QUERY 1
+#define GNUNET_TUN_DNS_OPCODE_STATUS 2
+
+
+/**
+ * RFC 1035 codes.
+ */
+#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR 0
+#define GNUNET_TUN_DNS_RETURN_CODE_FORMAT_ERROR 1
+#define GNUNET_TUN_DNS_RETURN_CODE_SERVER_FAILURE 2
+#define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR 3
+#define GNUNET_TUN_DNS_RETURN_CODE_NOT_IMPLEMENTED 4
+#define GNUNET_TUN_DNS_RETURN_CODE_REFUSED 5
+
+/**
+ * RFC 2136 codes
+ */
+#define GNUNET_TUN_DNS_RETURN_CODE_YXDOMAIN 6
+#define GNUNET_TUN_DNS_RETURN_CODE_YXRRSET 7
+#define GNUNET_TUN_DNS_RETURN_CODE_NXRRSET 8
+#define GNUNET_TUN_DNS_RETURN_CODE_NOT_AUTH 9
+#define GNUNET_TUN_DNS_RETURN_CODE_NOT_ZONE 10
+
+
+/**
+ * DNS flags (largely RFC 1035 / RFC 2136).
+ */
+struct GNUNET_TUN_DnsFlags
+{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+  /**
+   * Set to 1 if recursion is desired (client -> server)
+   */
+  unsigned int recursion_desired    : 1 GNUNET_PACKED;  
+  
+  /**
+   * Set to 1 if message is truncated
+   */
+  unsigned int message_truncated    : 1 GNUNET_PACKED; 
+  
+  /**
+   * Set to 1 if this is an authoritative answer
+   */
+  unsigned int authoritative_answer : 1 GNUNET_PACKED;
+  
+  /**
+   * See GNUNET_TUN_DNS_OPCODE_ defines.
+   */
+  unsigned int opcode               : 4 GNUNET_PACKED;  
+  
+  /**
+   * query:0, response:1
+   */
+  unsigned int query_or_response    : 1 GNUNET_PACKED;  
+  
+  /**
+   * See GNUNET_TUN_DNS_RETURN_CODE_ defines.
+   */
+  unsigned int return_code          : 4 GNUNET_PACKED; 
+  
+  /**
+   * See RFC 4035.
+   */
+  unsigned int checking_disabled    : 1 GNUNET_PACKED; 
+  
+  /**
+   * Response has been cryptographically verified, RFC 4035.
+   */
+  unsigned int authenticated_data   : 1 GNUNET_PACKED;
+  
+  /**
+   * Always zero.
+   */
+  unsigned int zero                 : 1 GNUNET_PACKED;
+  
+  /**
+   * Set to 1 if recursion is available (server -> client)
+   */
+  unsigned int recursion_available  : 1 GNUNET_PACKED; 
+#elif __BYTE_ORDER == __BIG_ENDIAN
+  
+  /**
+   * query:0, response:1
+   */
+  unsigned int query_or_response    : 1 GNUNET_PACKED;  
+  
+  /**
+   * See GNUNET_TUN_DNS_OPCODE_ defines.
+   */
+  unsigned int opcode               : 4 GNUNET_PACKED;  
+  
+  /**
+   * Set to 1 if this is an authoritative answer
+   */
+  unsigned int authoritative_answer : 1 GNUNET_PACKED;
+  
+  /**
+   * Set to 1 if message is truncated
+   */
+  unsigned int message_truncated    : 1 GNUNET_PACKED; 
+  
+  /**
+   * Set to 1 if recursion is desired (client -> server)
+   */
+  unsigned int recursion_desired    : 1 GNUNET_PACKED;  
+
+ 
+  /**
+   * Set to 1 if recursion is available (server -> client)
+   */
+  unsigned int recursion_available  : 1 GNUNET_PACKED;
+  
+  /**
+   * Always zero.
+   */
+  unsigned int zero                 : 1 GNUNET_PACKED;
+  
+  /**
+   * Response has been cryptographically verified, RFC 4035.
+   */
+  unsigned int authenticated_data   : 1 GNUNET_PACKED;
+  
+  /**
+   * See RFC 4035.
+   */
+  unsigned int checking_disabled    : 1 GNUNET_PACKED; 
+  
+  /**
+   * See GNUNET_TUN_DNS_RETURN_CODE_ defines.
+   */  
+  unsigned int return_code          : 4 GNUNET_PACKED; 
+#else
+  #error byteorder undefined
+#endif
+  
+} GNUNET_GCC_STRUCT_LAYOUT;
+
+
+
+/**
  * DNS header.
  */
 struct GNUNET_TUN_DnsHeader
 {
+  /**
+   * Unique identifier for the request/response.
+   */
   uint16_t id GNUNET_PACKED;
-  uint16_t flags GNUNET_PACKED;
-  uint16_t qdcount GNUNET_PACKED;
-  uint16_t ancount GNUNET_PACKED;
-  uint16_t nscount GNUNET_PACKED;
-  uint16_t arcount GNUNET_PACKED;
+
+  /**
+   * Flags.
+   */
+  struct GNUNET_TUN_DnsFlags flags;
+
+  /**
+   * Number of queries.
+   */
+  uint16_t query_count GNUNET_PACKED;
+
+  /**
+   * Number of answers.
+   */
+  uint16_t answer_rcount GNUNET_PACKED;
+
+  /**
+   * Number of authoritative answers.
+   */
+  uint16_t authority_rcount GNUNET_PACKED;
+
+  /**
+   * Number of additional records.
+   */
+  uint16_t additional_rcount GNUNET_PACKED;
 };
 
+
+/**
+ * Payload of DNS SOA record (header).
+ */
+struct GNUNET_TUN_DnsSoaRecord
+{
+  /**
+   * The version number of the original copy of the zone.   (NBO)
+   */
+  uint32_t serial GNUNET_PACKED;
+  
+  /**
+   * Time interval before the zone should be refreshed. (NBO)
+   */
+  uint32_t refresh GNUNET_PACKED;
+  
+  /**
+   * Time interval that should elapse before a failed refresh should
+   * be retried. (NBO)
+   */
+  uint32_t retry GNUNET_PACKED;
+ 
+  /**
+   * Time value that specifies the upper limit on the time interval
+   * that can elapse before the zone is no longer authoritative. (NBO)
+   */
+  uint32_t expire GNUNET_PACKED;
+
+  /**
+   * The bit minimum TTL field that should be exported with any RR
+   * from this zone. (NBO)
+   */
+  uint32_t minimum GNUNET_PACKED;
+};
+
+
+/**
+ * Payload of DNS SRV record (header).
+ */
+struct GNUNET_TUN_DnsSrvRecord
+{
+
+  /**
+   * 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;
+
+  /**
+   * TCP or UDP port of the service. (NBO)
+   */
+  uint16_t port GNUNET_PACKED;
+
+  /* followed by 'target' name */
+};
+
+
+/**
+ * Payload of DNSSEC TLSA record.
+ * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/
+ */
+struct GNUNET_TUN_DnsTlsaRecord
+{
+
+  /**
+   * Certificate usage
+   * 0: CA cert
+   * 1: Entity cert
+   * 2: Trust anchor
+   * 3: domain-issued cert
+   */
+  uint8_t usage;
+
+  /**
+   * Selector
+   * What part will be matched against the cert
+   * presented by server
+   * 0: Full cert (in binary)
+   * 1: Full cert (in DER)
+   */
+  uint8_t selector;
+
+  /**
+   * Matching type (of selected content)
+   * 0: exact match
+   * 1: SHA-256 hash
+   * 2: SHA-512 hash
+   */
+  uint8_t matching_type;
+
+  /**
+   * followed by certificate association data
+   * The "certificate association data" to be matched.
+   * These bytes are either raw data (that is, the full certificate or
+   * its SubjectPublicKeyInfo, depending on the selector) for matching
+   * type 0, or the hash of the raw data for matching types 1 and 2.
+   * The data refers to the certificate in the association, not to the
+   * TLS ASN.1 Certificate object.
+   *
+   * The data is represented as a string of hex chars
+   */
+};
+
+
+/**
+ * Payload of GNS VPN record
+ */
+struct GNUNET_TUN_GnsVpnRecord
+{
+  /**
+   * The peer to contact
+   */
+  struct GNUNET_HashCode peer;
+
+  /**
+   * The protocol to use
+   */
+  uint16_t proto;
+
+  /* followed by the servicename */
+};
+
+/**
+ * DNS query prefix.
+ */
+struct GNUNET_TUN_DnsQueryLine
+{
+  /**
+   * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
+   */
+  uint16_t type GNUNET_PACKED;
+
+  /**
+   * Desired class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO)
+   */
+  uint16_t class GNUNET_PACKED;
+};
+
+
+/**
+ * General DNS record prefix.
+ */
+struct GNUNET_TUN_DnsRecordLine
+{
+  /**
+   * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
+   */
+  uint16_t type GNUNET_PACKED;
+
+  /**
+   * Record class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO)
+   */
+  uint16_t class GNUNET_PACKED;
+
+  /**
+   * Expiration for the record (in seconds). (NBO)
+   */
+  uint32_t ttl GNUNET_PACKED;
+
+  /**
+   * Number of bytes of data that follow. (NBO)
+   */
+  uint16_t data_len GNUNET_PACKED;
+};
+
+
 #define        GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
 #define        GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
 #define        GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
@@ -364,7 +732,7 @@
  * @param ip ipv4 header fully initialized
  * @param tcp TCP header (initialized except for CRC)
  * @param payload the TCP payload
- * @param payload_length number of bytes of TCP payload
+ * @param payload_length number of bytes of TCP @a payload
  */
 void
 GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
@@ -392,7 +760,7 @@
  * @param ip ipv4 header fully initialized
  * @param udp UDP header (initialized except for CRC)
  * @param payload the UDP payload
- * @param payload_length number of bytes of UDP payload
+ * @param payload_length number of bytes of UDP @a payload
  */
 void
 GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
@@ -430,11 +798,11 @@
 
 
 /**
- * Create a regex in 'rxstr' from the given 'ip' and 'netmask'.
+ * Create a regex in @a rxstr from the given @a ip and @a netmask.
  *
  * @param ip IPv4 representation.
  * @param netmask netmask for the ip.
- * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN
+ * @param rxstr generated regex, must be at least #GNUNET_REGEX_IPV4_REGEXLEN
  *              bytes long.
  */
 void
@@ -443,11 +811,11 @@
 
 
 /**
- * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'.
+ * Create a regex in @a rxstr from the given @a ipv6 and @a prefixlen.
  *
  * @param ipv6 IPv6 representation.
  * @param prefixlen length of the ipv6 prefix.
- * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN
+ * @param rxstr generated regex, must be at least #GNUNET_REGEX_IPV6_REGEXLEN
  *              bytes long.
  */
 void
@@ -459,7 +827,7 @@
  * Convert an exit policy to a regular expression.  The exit policy
  * specifies a set of subnets this peer is willing to serve as an
  * exit for; the resulting regular expression will match the
- * IPv6 address strings as returned by 'GNUNET_TUN_ipv6toregexsearch'.
+ * IPv6 address strings as returned by #GNUNET_TUN_ipv6toregexsearch.
  *
  * @param policy exit policy specification
  * @return regular expression, NULL on error
@@ -472,7 +840,7 @@
  * Convert an exit policy to a regular expression.  The exit policy
  * specifies a set of subnets this peer is willing to serve as an
  * exit for; the resulting regular expression will match the
- * IPv4 address strings as returned by 'GNUNET_TUN_ipv4toregexsearch'.
+ * IPv4 address strings as returned by #GNUNET_TUN_ipv4toregexsearch.
  *
  * @param policy exit policy specification
  * @return regular expression, NULL on error

Modified: gnunet/src/namestore/namestore_api_common.c
===================================================================
--- gnunet/src/namestore/namestore_api_common.c 2013-08-15 10:27:18 UTC (rev 
28646)
+++ gnunet/src/namestore/namestore_api_common.c 2013-08-15 10:52:06 UTC (rev 
28647)
@@ -25,7 +25,6 @@
  * @author Matthias Wachs
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_constants.h"
@@ -33,7 +32,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_dnsparser_lib.h"
-#include "gns_protocol.h"
+#include "gnunet_tun_lib.h"
 #include "namestore.h"
 
 
@@ -508,10 +507,10 @@
                                  size_t data_size)
 {
   uint16_t mx_pref;
-  const struct soa_data *soa;
-  const struct vpn_data *vpn;
-  const struct srv_data *srv;
-  const struct tlsa_data *tlsa;
+  const struct GNUNET_TUN_DnsSoaRecord *soa;
+  const struct GNUNET_TUN_GnsVpnRecord *vpn;
+  const struct GNUNET_TUN_DnsSrvRecord *srv;
+  const struct GNUNET_TUN_DnsTlsaRecord *tlsa;
   struct GNUNET_CRYPTO_HashAsciiEncoded s_peer;
   const char *cdata;
   char* vpn_str;
@@ -537,16 +536,16 @@
   case GNUNET_DNSPARSER_TYPE_CNAME:
     return GNUNET_strndup (data, data_size);
   case GNUNET_DNSPARSER_TYPE_SOA:
-    if (data_size <= sizeof (struct soa_data))
+    if (data_size <= sizeof (struct GNUNET_TUN_DnsSoaRecord))
       return NULL;
     soa = data;
     soa_rname = (const char*) &soa[1];
-    soa_mname = memchr (soa_rname, 0, data_size - sizeof (struct soa_data) - 
1);
+    soa_mname = memchr (soa_rname, 0, data_size - sizeof (struct 
GNUNET_TUN_DnsSoaRecord) - 1);
     if (NULL == soa_mname)
       return NULL;
     soa_mname++;
     if (NULL == memchr (soa_mname, 0, 
-                       data_size - (sizeof (struct soa_data) + strlen 
(soa_rname) + 1)))
+                       data_size - (sizeof (struct GNUNET_TUN_DnsSoaRecord) + 
strlen (soa_rname) + 1)))
       return NULL;
     GNUNET_asprintf (&result, 
                     "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
@@ -587,7 +586,7 @@
     return GNUNET_strndup (data, data_size);
   case GNUNET_NAMESTORE_TYPE_VPN:
     cdata = data;
-    if ( (data_size <= sizeof (struct vpn_data)) ||
+    if ( (data_size <= sizeof (struct GNUNET_TUN_GnsVpnRecord)) ||
         ('\0' != cdata[data_size - 1]) )
       return NULL; /* malformed */
     vpn = data;
@@ -603,7 +602,7 @@
     return vpn_str;
   case GNUNET_DNSPARSER_TYPE_SRV:
     cdata = data;
-    if ( (data_size <= sizeof (struct srv_data)) ||
+    if ( (data_size <= sizeof (struct GNUNET_TUN_DnsSrvRecord)) ||
         ('\0' != cdata[data_size - 1]) )
       return NULL; /* malformed */
     srv = data;
@@ -621,7 +620,7 @@
     return srv_str;
   case GNUNET_DNSPARSER_TYPE_TLSA:
     cdata = data;
-    if ( (data_size <= sizeof (struct tlsa_data)) ||
+    if ( (data_size <= sizeof (struct GNUNET_TUN_DnsTlsaRecord)) ||
         ('\0' != cdata[data_size - 1]) )
       return NULL; /* malformed */
     tlsa = data;
@@ -663,9 +662,9 @@
   struct in_addr value_a;
   struct in6_addr value_aaaa;
   struct GNUNET_CRYPTO_EccPublicKey pkey;
-  struct soa_data *soa;
-  struct vpn_data *vpn;
-  struct tlsa_data *tlsa;
+  struct GNUNET_TUN_DnsSoaRecord *soa;
+  struct GNUNET_TUN_GnsVpnRecord *vpn;
+  struct GNUNET_TUN_DnsTlsaRecord *tlsa;
   char result[253 + 1];
   char soa_rname[253 + 1];
   char soa_mname[253 + 1];
@@ -720,9 +719,9 @@
                  s);
       return GNUNET_SYSERR;
     }
-    *data_size = sizeof (struct 
soa_data)+strlen(soa_rname)+strlen(soa_mname)+2;
+    *data_size = sizeof (struct 
GNUNET_TUN_DnsSoaRecord)+strlen(soa_rname)+strlen(soa_mname)+2;
     *data = GNUNET_malloc (*data_size);
-    soa = (struct soa_data*)*data;
+    soa = (struct GNUNET_TUN_DnsSoaRecord*)*data;
     soa->serial = htonl(soa_serial);
     soa->refresh = htonl(soa_refresh);
     soa->retry = htonl(soa_retry);
@@ -795,7 +794,7 @@
                  s);
       return GNUNET_SYSERR;
     }
-    *data_size = sizeof (struct vpn_data) + strlen (s_serv) + 1;
+    *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
     *data = vpn = GNUNET_malloc (*data_size);
     if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((char*)&s_peer,
                                                     &vpn->peer))
@@ -808,7 +807,7 @@
     strcpy ((char*)&vpn[1], s_serv);
     return GNUNET_OK;
   case GNUNET_DNSPARSER_TYPE_TLSA:
-    *data_size = sizeof (struct tlsa_data) + strlen (s) - 6;
+    *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6;
     *data = tlsa = GNUNET_malloc (*data_size);
     if (4 != SSCANF (s, "%c %c %c %s",
                     &tlsa->usage,




reply via email to

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