MEDIUM: dns: new DNS response parser

New DNS response parser function which turn the DNS response from a
network buffer into a DNS structure, much easier for later analysis
by upper layer.

Memory is pre-allocated at start-up in a chunk dedicated to DNS
response store.

New error code to report a wrong number of queries in a DNS response.
diff --git a/include/proto/dns.h b/include/proto/dns.h
index 170eefa..c62834f 100644
--- a/include/proto/dns.h
+++ b/include/proto/dns.h
@@ -32,8 +32,8 @@
 struct task *dns_process_resolve(struct task *t);
 int dns_init_resolvers(void);
 uint16_t dns_rnd16(void);
-int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, char *dn_name, int dn_name_len);
-int dns_get_ip_from_response(unsigned char *resp, unsigned char *resp_end,
+int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, struct dns_response_packet *dns_p);
+int dns_get_ip_from_response(struct dns_response_packet *dns_p,
                              struct dns_resolution *resol, void *currentip,
                              short currentip_sin_family,
                              void **newip, short *newip_sin_family);
diff --git a/include/proto/server.h b/include/proto/server.h
index 47630fe..0ed68b8 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -48,7 +48,7 @@
 
 /* functions related to server name resolution */
 int snr_update_srv_status(struct server *s);
-int snr_resolution_cb(struct dns_resolution *resolution, struct dns_nameserver *nameserver, unsigned char *response, int response_len);
+int snr_resolution_cb(struct dns_resolution *resolution, struct dns_nameserver *nameserver, struct dns_response_packet *dns_p);
 int snr_resolution_error_cb(struct dns_resolution *resolution, int error_code);
 
 /* increase the number of cumulated connections on the designated server */
diff --git a/include/types/dns.h b/include/types/dns.h
index 03ffdc1..5d6b5a1 100644
--- a/include/types/dns.h
+++ b/include/types/dns.h
@@ -42,6 +42,12 @@
 /* maximum number of answer record in a DNS response */
 #define DNS_MAX_ANSWER_RECORDS ((DNS_MAX_UDP_MESSAGE - DNS_HEADER_SIZE) / DNS_MIN_RECORD_SIZE)
 
+/* size of dns_buffer used to store responses from the buffer
+ * dns_buffer is used to store data collected from records found in a response.
+ * Before using it, caller will always check that there is at least DNS_MAX_NAME_SIZE bytes
+ * available */
+#define DNS_ANALYZE_BUFFER_SIZE DNS_MAX_UDP_MESSAGE + DNS_MAX_NAME_SIZE
+
 /* DNS error messages */
 #define DNS_TOO_LONG_FQDN	"hostname too long"
 #define DNS_LABEL_TOO_LONG	"one label too long"
@@ -204,7 +210,7 @@
 	struct list list;		/* resolution list */
 	struct dns_resolvers *resolvers;	/* resolvers section associated to this resolution */
 	void *requester;		/* owner of this name resolution */
-	int (*requester_cb)(struct dns_resolution *, struct dns_nameserver *, unsigned char *, int);
+	int (*requester_cb)(struct dns_resolution *, struct dns_nameserver *, struct dns_response_packet *);
 					/* requester callback for valid response */
 	int (*requester_error_cb)(struct dns_resolution *, int);
 					/* requester callback, for error management */
@@ -256,6 +262,7 @@
 	DNS_RESP_TIMEOUT,		/* DNS server has not answered in time */
 	DNS_RESP_TRUNCATED,		/* DNS response is truncated */
 	DNS_RESP_NO_EXPECTED_RECORD,	/* No expected records were found in the response */
+	DNS_RESP_QUERY_COUNT_ERROR,	/* we did not get the expected number of queries in the response */
 };
 
 /* return codes after searching an IP in a DNS response buffer, using a family preference */