Index: /trunk/src/VBox/Devices/Network/slirp/ip_output.c
===================================================================
--- /trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 22904)
+++ /trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 22905)
@@ -85,4 +85,6 @@
     DEBUG_ARG("so = %lx", (long)so);
     DEBUG_ARG("m0 = %lx", (long)m0);
+
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
     if(m->m_data != (MBUF_HEAD(m) + if_maxlinkhdr))
     {
@@ -90,4 +92,8 @@
         AssertMsgFailed(("!!Ethernet frame corrupted!!"));
     }
+#else
+    M_ASSERTPKTHDR(m);
+    Assert(m->m_pkthdr.header);
+#endif
 
 #if 0 /* We do no options */
@@ -98,5 +104,11 @@
     }
 #endif
+#ifdef VBOX_WITH_SLIRP_BSD_MBUF
+    M_ASSERTPKTHDR(m);
+    Assert(m->m_pkthdr.header);
+    ip = (struct ip *)m->m_pkthdr.header;
+#else
     ip = mtod(m, struct ip *);
+#endif
     /*
      * Fill in IP header.
@@ -122,5 +134,13 @@
        * all so we need to calculate destination ethernet address
        */
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
      eh = (struct ethhdr *)MBUF_HEAD(m);
+#else
+    /*todo: make prepend */
+    m = m_prepend(pData, m, ETH_HLEN, M_DONTWAIT);
+    Assert(m);
+    eh = mtod(m, struct ethhdr *);
+    m_adj(m, ETH_HLEN); /*let the rest of code do it job*/
+#endif
      if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0)
      {
@@ -150,7 +170,25 @@
         {
             STAM_PROFILE_START(&pData->StatALIAS_output, a);
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 
                 mtod(m, char *), m->m_len);
             Log2(("NAT: LibAlias return %d\n", rc));
+#else
+            struct m_tag *t;
+            if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0)
+            {
+                rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL));
+            }
+            else
+            {
+                rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 
+                                 m_length(m, NULL));
+            } 
+            if (rc == PKT_ALIAS_IGNORED)
+            {
+                Log(("NAT: packet was droppped\n"));
+                goto bad;
+            }
+#endif
             STAM_PROFILE_STOP(&pData->StatALIAS_output, a);
         }
@@ -181,4 +219,7 @@
         int mhlen, firstlen = len;
         struct mbuf **mnext = &m->m_nextpkt;
+#ifdef VBOX_WITH_SLIRP_BSD_MBUF
+        uint8_t buf[len]; /* intermediate buffer we'll use for copy from orriginal packet*/
+#endif
 
         /*
@@ -191,5 +232,9 @@
         {
             register struct ip *mhip;
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             m = m_get(pData);
+#else
+            m = m_gethdr(pData, M_DONTWAIT, MT_HEADER);
+#endif
             if (m == 0)
             {
@@ -198,9 +243,23 @@
                 goto sendorfree;
             }
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             m->m_data += if_maxlinkhdr;
             mhip = mtod(m, struct ip *);
             *mhip = *ip;
+#else
+            m_copyback(pData, m, 0, mhlen, ip);
+            m->m_pkthdr.header = mtod(m, void *);
+            mhip = mtod(m, struct ip *);
+            m_adj(m, mhlen);
+#endif
             /* we've calculated eth_dst for first packet */
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             eh = (struct ethhdr *)MBUF_HEAD(m);
+#else
+            m = m_prepend(pData, m, ETH_HLEN, M_DONTWAIT);
+            Assert(m);
+            eh = mtod(m, struct ethhdr *);
+            m_adj(m, ETH_HLEN);
+#endif
             Assert((rc == 0));
 
@@ -214,5 +273,7 @@
             }
 #endif
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             m->m_len = mhlen;
+#endif
             mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
             if (ip->ip_off & IP_MF)
@@ -224,4 +285,5 @@
             mhip->ip_len = htons((u_int16_t)(len + mhlen));
 
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             if (m_copy(m, m0, off, len) < 0)
             {
@@ -229,4 +291,8 @@
                 goto sendorfree;
             }
+#else
+            m_copydata(m0, off, len, buf); /* copy to buffer */
+            m_append(pData, m, len, buf); /* copy from buffer */
+#endif
 
             mhip->ip_off = htons((u_int16_t)mhip->ip_off);
@@ -250,6 +316,24 @@
         {
             STAM_PROFILE_START(&pData->StatALIAS_output, a);
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
             rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 
                 mtod(m, char *), m->m_len);
+#else
+            struct m_tag *t;
+            if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0)
+            {
+                rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL));
+            }
+            else
+            {
+                rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 
+                                 m_length(m, NULL));
+            } 
+            if (rc == PKT_ALIAS_IGNORED)
+            {
+                Log(("NAT: packet was droppped\n"));
+                goto bad;
+            }
+#endif
             Log2(("NAT: LibAlias return %d\n", rc));
             STAM_PROFILE_STOP(&pData->StatALIAS_output, a);
@@ -264,6 +348,24 @@
             {
                 int rc;
+#ifndef VBOX_WITH_SLIRP_BSD_MBUF
                 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 
                     mtod(m, char *), m->m_len);
+#else
+                struct m_tag *t;
+                if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0)
+                {
+                    rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL));
+                }
+                else
+                {
+                    rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 
+                                     m_length(m, NULL));
+                } 
+                if (rc == PKT_ALIAS_IGNORED)
+                {
+                    Log(("NAT: packet was droppped\n"));
+                    goto bad;
+                }
+#endif
                 Log2(("NAT: LibAlias return %d\n", rc));
                 if_output(pData, so, m);
