Link namesotre to libgnunetgnsrecord too
[oweals/gnunet.git] / src / include / gnunet_dnsparser_lib.h
index 2d3a26215acf94f43b749f22eac50ab0865a9b31..b6b9bcea94e2aa7e178b8b3fab2a6f3e388a9fd9 100644 (file)
 
 /**
  * @file include/gnunet_dnsparser_lib.h
- * @brief API for helper library to parse DNS packets. 
+ * @brief API for helper library to parse DNS packets.
  * @author Philipp Toelke
  * @author Christian Grothoff
  */
 #ifndef GNUNET_DNSPARSER_LIB_H
 #define GNUNET_DNSPARSER_LIB_H
 
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_tun_lib.h"
 
 /**
@@ -64,7 +64,7 @@ struct GNUNET_DNSPARSER_Query
 
   /**
    * Name of the record that the query is for (0-terminated).
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -79,7 +79,7 @@ struct GNUNET_DNSPARSER_Query
   /**
    * See GNUNET_TUN_DNS_CLASS_*.
    */
-  uint16_t class;
+  uint16_t dns_traffic_class;
 
 };
 
@@ -89,7 +89,7 @@ struct GNUNET_DNSPARSER_Query
  */
 struct GNUNET_DNSPARSER_MxRecord
 {
-  
+
   /**
    * Preference for this entry (lower value is higher preference).
    */
@@ -97,7 +97,7 @@ struct GNUNET_DNSPARSER_MxRecord
 
   /**
    * Name of the mail server.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -120,11 +120,11 @@ struct GNUNET_DNSPARSER_MxRecord
  */
 struct GNUNET_DNSPARSER_SrvRecord
 {
-  
+
   /**
    * Service name without the underscore (!).  Note that RFC 6335 clarifies the
    * set of legal characters for service names.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -139,7 +139,7 @@ struct GNUNET_DNSPARSER_SrvRecord
 
   /**
    * Domain name for which the record is valid
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -148,7 +148,7 @@ struct GNUNET_DNSPARSER_SrvRecord
 
   /**
    * Hostname offering the service.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -176,18 +176,18 @@ struct GNUNET_DNSPARSER_SrvRecord
 
 };
 
-  
+
 /**
  * Information from SOA records (RFC 1035).
  */
 struct GNUNET_DNSPARSER_SoaRecord
 {
-  
+
   /**
-   *The domainname of the name server that was the
+   * The domainname of the name server that was the
    * original or primary source of data for this zone.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
-   * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
+   * as necessary.  Use #GNUNET_DNSPARSER_check_label to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
    */
@@ -196,7 +196,7 @@ struct GNUNET_DNSPARSER_SoaRecord
   /**
    * A domainname which specifies the mailbox of the
    * person responsible for this zone.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use 'GNUNET_DNSPARSER_check_label' to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -204,7 +204,7 @@ struct GNUNET_DNSPARSER_SoaRecord
   char *rname;
 
   /**
-   * The version number of the original copy of the zone.  
+   * The version number of the original copy of the zone.
    */
   uint32_t serial;
 
@@ -230,7 +230,7 @@ struct GNUNET_DNSPARSER_SoaRecord
    * from this zone.
    */
   uint32_t minimum_ttl;
-  
+
 };
 
 
@@ -260,7 +260,7 @@ struct GNUNET_DNSPARSER_Record
 
   /**
    * Name of the record that the query is for (0-terminated).
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use #GNUNET_DNSPARSER_check_label to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
@@ -270,23 +270,23 @@ struct GNUNET_DNSPARSER_Record
   /**
    * Payload of the record (which one of these is valid depends on the 'type').
    */
-  union 
+  union
   {
 
     /**
      * For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
-   * In UTF-8 format.  The library will convert from and to DNS-IDNA 
+   * In UTF-8 format.  The library will convert from and to DNS-IDNA
    * as necessary.  Use #GNUNET_DNSPARSER_check_label to test if an
    * individual label is well-formed.  If a given name is not well-formed,
    * creating the DNS packet will fail.
      */
     char *hostname;
-    
+
     /**
      * SOA data for SOA records.
      */
     struct GNUNET_DNSPARSER_SoaRecord *soa;
-    
+
     /**
      * MX data for MX records.
      */
@@ -318,7 +318,7 @@ struct GNUNET_DNSPARSER_Record
   /**
    * See GNUNET_TUN_DNS_CLASS_*.
    */
-  uint16_t class;
+  uint16_t dns_traffic_class;
 
 };
 
@@ -370,7 +370,7 @@ struct GNUNET_DNSPARSER_Packet
 
   /**
    * Bitfield of DNS flags.
-   */ 
+   */
   struct GNUNET_TUN_DnsFlags flags;
 
   /**
@@ -386,8 +386,8 @@ struct GNUNET_DNSPARSER_Packet
  * This can fail if the ASCII-conversion becomes longer than 63 characters.
  *
  * @param label label to check (UTF-8 string)
- * @return GNUNET_OK if the label can be converted to IDNA,
- *         GNUNET_SYSERR if the label is not valid for DNS names
+ * @return #GNUNET_OK if the label can be converted to IDNA,
+ *         #GNUNET_SYSERR if the label is not valid for DNS names
  */
 int
 GNUNET_DNSPARSER_check_label (const char *label);
@@ -399,8 +399,8 @@ GNUNET_DNSPARSER_check_label (const char *label);
  * the entire name exceeds 253 characters.
  *
  * @param name name to check (UTF-8 string)
- * @return GNUNET_OK if the label can be converted to IDNA,
- *         GNUNET_SYSERR if the label is not valid for DNS names
+ * @return #GNUNET_OK if the label can be converted to IDNA,
+ *         #GNUNET_SYSERR if the label is not valid for DNS names
  */
 int
 GNUNET_DNSPARSER_check_name (const char *name);
@@ -411,7 +411,7 @@ GNUNET_DNSPARSER_check_name (const char *name);
  * processing and manipulation.
  *
  * @param udp_payload wire-format of the DNS packet
- * @param udp_payload_length number of bytes in udp_payload 
+ * @param udp_payload_length number of bytes in @a udp_payload
  * @return NULL on error, otherwise the parsed packet
  */
 struct GNUNET_DNSPARSER_Packet *
@@ -431,7 +431,7 @@ GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p);
 /**
  * Given a DNS packet @a p, generate the corresponding UDP payload.
  * Note that we do not attempt to pack the strings with pointers
- * as this would complicate the code and this is about being 
+ * as this would complicate the code and this is about being
  * simple and secure, not fast, fancy and broken like bind.
  *
  * @param p packet to pack
@@ -641,5 +641,42 @@ GNUNET_DNSPARSER_parse_srv (const char *r_name,
                            size_t udp_payload_length,
                            size_t *off);
 
+/* ***************** low-level deallocation API ******************** */
+
+/**
+ * Free the given DNS record.
+ *
+ * @param r record to free
+ */
+void
+GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r);
+
+
+/**
+ * Free MX information record.
+ *
+ * @param mx record to free
+ */
+void
+GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx);
+
+
+/**
+ * Free SRV information record.
+ *
+ * @param srv record to free
+ */
+void
+GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv);
+
+
+/**
+ * Free SOA information record.
+ *
+ * @param soa record to free
+ */
+void
+GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa);
+
 
 #endif