-fix
[oweals/gnunet.git] / src / include / gnunet_dnsparser_lib.h
index 70dc6332631a7f3895e019d2ba1801f0b3d1e27c..28cc4c0485b38bb27dce93139a60aaf1cc66b54a 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file include/gnunet_dnsparse_lib.h
+ * @file include/gnunet_dnsparser_lib.h
  * @brief API for helper library to parse DNS packets. 
  * @author Philipp Toelke
  * @author Christian Grothoff
@@ -128,7 +128,7 @@ struct GNUNET_DNSPARSER_Flags
    */
   unsigned int recursion_available  : 1 GNUNET_PACKED; 
   
-};
+} GNUNET_GCC_STRUCT_LAYOUT;
 
 
 /**
@@ -223,6 +223,24 @@ struct GNUNET_DNSPARSER_SoaRecord
 };
 
 
+/**
+ * Binary record information (unparsed).
+ */
+struct GNUNET_DNSPARSER_RawRecord
+{
+
+  /**
+   * Binary record data.
+   */
+  void *data;
+
+  /**
+   * Number of bytes in data.
+   */
+  size_t data_len;
+};
+
+
 /**
  * A DNS response record.
  */
@@ -255,14 +273,10 @@ struct GNUNET_DNSPARSER_Record
     /**
      * Raw data for all other types.
      */
-    char *raw;
+    struct GNUNET_DNSPARSER_RawRecord raw;
 
   } data;
 
-  /**
-   * Number of bytes in data.
-   */
-  size_t data_len;
 
   /**
    * When does the record expire?
@@ -366,6 +380,7 @@ GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p);
  * Given a DNS packet, generate the corresponding UDP payload.
  *
  * @param p packet to pack
+ * @param max maximum allowed size for the resulting UDP payload
  * @param buf set to a buffer with the packed message
  * @param buf_length set to the length of buf
  * @return GNUNET_SYSERR if 'p' is invalid
@@ -373,102 +388,10 @@ GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p);
  *         GNUNET_OK if 'p' was packed completely into '*buf'
  */
 int
-GNUNET_DNSPARSER_pack (struct GNUNET_DNSPARSER_Packet *p,
+GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p,
+                      uint16_t max,
                       char **buf,
                       size_t *buf_length);
 
 
-
-
-/* legacy API below */
-
-// DNS-Stuff
-GNUNET_NETWORK_STRUCT_BEGIN
-
-struct dns_static
-{
-  uint16_t id GNUNET_PACKED;
-
-  unsigned rd:1 GNUNET_PACKED;  // recursion desired (client -> server)
-  unsigned tc:1 GNUNET_PACKED;  // message is truncated
-  unsigned aa:1 GNUNET_PACKED;  // authoritative answer
-  unsigned op:4 GNUNET_PACKED;  // query:0, inverse q.:1, status: 2
-  unsigned qr:1 GNUNET_PACKED;  // query:0, response:1
-
-  unsigned rcode:4 GNUNET_PACKED;       // 0 No error
-  // 1 Format error
-  // 2 Server failure
-  // 3 Name Error
-  // 4 Not Implemented
-  // 5 Refused
-  unsigned z:3 GNUNET_PACKED;   // reserved
-  unsigned ra:1 GNUNET_PACKED;  // recursion available (server -> client)
-
-  uint16_t qdcount GNUNET_PACKED;       // number of questions
-  uint16_t ancount GNUNET_PACKED;       // number of answers
-  uint16_t nscount GNUNET_PACKED;       // number of authority-records
-  uint16_t arcount GNUNET_PACKED;       // number of additional records
-};
-GNUNET_NETWORK_STRUCT_END
-
-
-struct dns_pkt
-{
-  struct dns_static s;
-  unsigned char data[1];
-};
-
-struct dns_pkt_parsed
-{
-  struct dns_static s;
-  struct dns_query **queries;
-  struct dns_record **answers;
-  struct dns_record **nameservers;
-  struct dns_record **additional;
-};
-
-struct dns_query_line
-{
-  uint16_t type;
-  uint16_t class;
-};
-
-struct dns_query
-{
-  char *name;
-  unsigned char namelen;
-  uint16_t qtype;
-  uint16_t qclass;
-};
-
-struct dns_record_line
-{
-  uint16_t type;
-  uint16_t class;
-  uint32_t ttl;
-  uint16_t data_len;
-  unsigned char data;
-};
-
-struct dns_record
-{
-  char *name;
-  unsigned char namelen;
-  uint16_t type;
-  uint16_t class;
-  uint32_t ttl;
-  uint16_t data_len;
-  unsigned char *data;
-};
-
-
-struct dns_pkt_parsed *
-parse_dns_packet (struct dns_pkt *pkt);
-
-struct dns_pkt *
-unparse_dns_packet (struct dns_pkt_parsed *pkt);
-
-void
-free_parsed_dns_packet (struct dns_pkt_parsed *ppkt);
-
 #endif