MAJOR: dns: save a copy of the DNS response in struct resolution

Prior this patch, the DNS responses were stored in a pre-allocated
memory area (allocated at HAProxy's startup).
The problem is that this memory is erased for each new DNS responses
received and processed.

This patch removes the global memory allocation (which was not thread
safe by the way) and introduces a storage of the dns response  in the
struct
resolution.
The memory in the struct resolution is also reserved at start up and is
thread safe, since each resolution structure will have its own memory
area.

For now, we simply store the response and use it atomically per
response per server.
diff --git a/include/proto/dns.h b/include/proto/dns.h
index ffb1cac..14a6af1 100644
--- a/include/proto/dns.h
+++ b/include/proto/dns.h
@@ -32,7 +32,7 @@
 struct task *dns_process_resolve(struct task *t);
 int dns_init_resolvers(int close_socket);
 uint16_t dns_rnd16(void);
-int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, struct dns_response_packet *dns_p);
+int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, struct dns_resolution *resolution);
 int dns_get_ip_from_response(struct dns_response_packet *dns_p,
                              struct dns_options *dns_opts, void *currentip,
                              short currentip_sin_family,
diff --git a/include/proto/server.h b/include/proto/server.h
index ec29230..53df241 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -53,7 +53,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, struct dns_response_packet *dns_p);
+int snr_resolution_cb(struct dns_resolution *resolution, struct dns_nameserver *nameserver);
 int snr_resolution_error_cb(struct dns_resolution *resolution, int error_code);
 struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char *ip_family);
 
diff --git a/include/types/dns.h b/include/types/dns.h
index c86eb4d..54bbd02 100644
--- a/include/types/dns.h
+++ b/include/types/dns.h
@@ -219,7 +219,7 @@
 struct dns_resolution {
 	struct list list;		/* resolution list */
 	void *requester;		/* owner of this name resolution */
-	int (*requester_cb)(struct dns_resolution *, struct dns_nameserver *, struct dns_response_packet *);
+	int (*requester_cb)(struct dns_resolution *, struct dns_nameserver *);
 					/* requester callback for valid response */
 	int (*requester_error_cb)(struct dns_resolution *, int);
 					/* requester callback, for error management */
@@ -237,6 +237,10 @@
 	int try;			/* current resolution try */
 	int try_cname;			/* number of CNAME requests sent */
 	int nb_responses;		/* count number of responses received */
+	struct dns_response_packet response;	/* structure hosting the DNS response */
+	struct dns_query_item response_query_records[DNS_MAX_QUERY_RECORDS];		/* <response> query records */
+	struct dns_answer_item response_answer_records[DNS_MAX_ANSWER_RECORDS];	/* <response> answer records */
+	struct chunk response_buffer;	/* buffer used as a data store for <response> above TODO: optimize the size (might be smaller) */
 };
 
 /* last resolution status code */