Index: /trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c
===================================================================
--- /trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c	(revision 33956)
+++ /trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c	(revision 33957)
@@ -52,9 +52,14 @@
 AssertCompileSize(union dnsmsg_header, 12);
 
-struct dnsmsg_answer
-{
-    uint16_t name;
+struct dns_meta_data
+{
     uint16_t type;
     uint16_t class;
+};
+
+struct dnsmsg_answer
+{
+    uint16_t name;
+    struct dns_meta_data meta;
     uint16_t ttl[2];
     uint16_t rdata_len;
@@ -74,7 +79,7 @@
         return -1;
 
-    fprintf(stderr, "NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n",
+    Log(("NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n",
         __FUNCTION__, ntohs(*ah->dport), ntohs(*ah->sport),
-        &ah->oaddr, &ah->aaddr);
+        &ah->oaddr, &ah->aaddr));
 
     if (   (ntohs(*ah->dport) == DNS_CONTROL_PORT_NUMBER
@@ -86,5 +91,5 @@
 }
 
-static void doanswer(struct libalias *la, union dnsmsg_header *hdr, uint16_t qtype, uint16_t qclass, char *qname, struct ip *pip, struct hostent *h)
+static void doanswer(struct libalias *la, union dnsmsg_header *hdr, struct dns_meta_data *pReqMeta, char *qname, struct ip *pip, struct hostent *h)
 {
     int i;
@@ -106,4 +111,5 @@
         uint16_t packet_len = 0;
         uint16_t addr_off = (uint16_t)~0;
+        struct dns_meta_data *meta;
 
 #if 0
@@ -115,13 +121,16 @@
                    + sizeof(union dnsmsg_header)
                    + strlen(qname)
-                   + 2 * sizeof(uint16_t); /* ip + udp + header + query */
+                   + sizeof(struct dns_meta_data); /* ip + udp + header + query */
         query = (char *)&hdr[1];
 
         strcpy(query, qname);
         query += strlen(qname) + 1;
-
-        *(uint16_t *)query = qtype;
-        ((uint16_t *)query)[1] = qclass;
-        answers = (char *)&((uint16_t *)query)[2];
+        /* class & type informations lay right after symbolic inforamtion. */
+        meta = (struct dns_meta_data *)query;
+        meta->type = pReqMeta->type;
+        meta->class = pReqMeta->class;
+
+        /* answers zone lays after query in response packet */
+        answers = (char *)&meta[1];
 
         off = (char *)&hdr[1] - (char *)hdr;
@@ -134,6 +143,6 @@
             struct dnsmsg_answer *ans = (struct dnsmsg_answer *)answers;
             ans->name = htons(off);
-            ans->type = htons(5); /* CNAME */
-            ans->class = htons(1);
+            ans->meta.type = htons(5); /* CNAME */
+            ans->meta.class = htons(1);
             *(uint32_t *)ans->ttl = htonl(3600); /* 1h */
             c = (addr_off == (uint16_t)~0 ? h->h_name : *cstr);
@@ -157,6 +166,6 @@
 
             ans->name = htons(off);
-            ans->type = htons(1);
-            ans->class = htons(1);
+            ans->meta.type = htons(1);
+            ans->meta.class = htons(1);
             *(uint32_t *)ans->ttl = htonl(3600); /* 1h */
             ans->rdata_len = htons(4); /* IPv4 */
@@ -187,4 +196,5 @@
     char cname[255];
     int cname_len = 0;
+    struct dns_meta_data *meta;
 
     struct udphdr *udp = NULL;
@@ -201,5 +211,10 @@
     if ((ntohs(hdr->X.qdcount) != 1))
     {
-        LogRel(("NAT:alias_dns: multiple quieries isn't supported\n"));
+        static bool fMultiWarn;
+        if (!fMultiWarn)
+        {
+            LogRel(("NAT:alias_dns: multiple quieries isn't supported\n"));
+            fMultiWarn = true;
+        }
         return 1;
     }
@@ -207,8 +222,7 @@
     for (i = 0; i < ntohs(hdr->X.qdcount); ++i)
     {
-        qw_qtype = (uint16_t *)(qw_qname + strlen(qw_qname) + 1);
-        qw_qclass = &qw_qtype[1];
-        fprintf(stderr, "qname:%s qtype:%hd qclass:%hd\n",
-            qw_qname, ntohs(*qw_qtype), ntohs(*qw_qclass));
+        meta = (struct dns_meta_data *)(qw_qname + strlen(qw_qname) + 1);
+        Log(("qname:%s qtype:%hd qclass:%hd\n",
+            qw_qname, ntohs(meta->type), ntohs(meta->class)));
 
         QStr2CStr(qw_qname, cname, sizeof(cname));
@@ -227,5 +241,5 @@
         h = gethostbyname(cname);
         fprintf(stderr, "cname:%s\n", cname);
-        doanswer(la, hdr, *qw_qtype, *qw_qclass, qw_qname, pip, h);
+        doanswer(la, hdr, meta, qw_qname, pip, h);
     }
 
