Index: trunk/src/VBox/Devices/Network/slirp/bootp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/bootp.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/bootp.h	(revision 14964)
@@ -93,22 +93,23 @@
 #define DHCP_OPT_LEN		312
 
-struct bootp_t {
-    struct ip ip;
-    struct udphdr udp;
-    uint8_t bp_op;
-    uint8_t bp_htype;
-    uint8_t bp_hlen;
-    uint8_t bp_hops;
-    uint32_t bp_xid;
-    uint16_t bp_secs;
-    uint16_t unused;
+struct bootp_t
+{
+    struct ip      ip;
+    struct udphdr  udp;
+    uint8_t        bp_op;
+    uint8_t        bp_htype;
+    uint8_t        bp_hlen;
+    uint8_t        bp_hops;
+    uint32_t       bp_xid;
+    uint16_t       bp_secs;
+    uint16_t       unused;
     struct in_addr bp_ciaddr;
     struct in_addr bp_yiaddr;
     struct in_addr bp_siaddr;
     struct in_addr bp_giaddr;
-    uint8_t bp_hwaddr[16];
-    uint8_t bp_sname[64];
-    uint8_t bp_file[128];
-    uint8_t bp_vend[DHCP_OPT_LEN];
+    uint8_t        bp_hwaddr[16];
+    uint8_t        bp_sname[64];
+    uint8_t        bp_file[128];
+    uint8_t        bp_vend[DHCP_OPT_LEN];
 };
 
Index: trunk/src/VBox/Devices/Network/slirp/cksum.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/cksum.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/cksum.c	(revision 14964)
@@ -47,95 +47,106 @@
 
 #define ADDCARRY(x)  (x > 65535 ? x -= 65535 : x)
-#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
+#define REDUCE { l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum); }
 
 int cksum(struct mbuf *m, int len)
 {
-        register u_int16_t *w;
-        register int sum = 0;
-        register int mlen = 0;
-        int byte_swapped = 0;
+    register u_int16_t *w;
+    register int sum = 0;
+    register int mlen = 0;
+    int byte_swapped = 0;
 
-        union {
-                u_int8_t        c[2];
-                u_int16_t       s;
-        } s_util;
-        union {
-                u_int16_t s[2];
-                u_int32_t l;
-        } l_util;
+    union
+    {
+        u_int8_t  c[2];
+        u_int16_t s;
+    } s_util;
+    union
+    {
+        u_int16_t s[2];
+        u_int32_t l;
+    } l_util;
         
-        if (m->m_len == 0)
-           goto cont;
-        w = mtod(m, u_int16_t *);
+    if (m->m_len == 0)
+        goto cont;
+    w = mtod(m, u_int16_t *);
+
+    mlen = m->m_len;
         
-        mlen = m->m_len;
+    if (len < mlen)
+        mlen = len;
+    len -= mlen;
+    /*
+     * Force to even boundary.
+     */
+    if ((1 & (long) w) && (mlen > 0))
+    {
+        REDUCE;
+        sum <<= 8;
+        s_util.c[0] = *(u_int8_t *)w;
+        w = (u_int16_t *)((int8_t *)w + 1);
+        mlen--;
+        byte_swapped = 1;
+    }
+    /*
+     * Unroll the loop to make overhead from
+     * branches &c small.
+     */
+    while ((mlen -= 32) >= 0)
+    {
+        sum += w[ 0]; sum += w[ 1]; sum += w[ 2]; sum += w[ 3];
+        sum += w[ 4]; sum += w[ 5]; sum += w[ 6]; sum += w[ 7];
+        sum += w[ 8]; sum += w[ 9]; sum += w[10]; sum += w[11];
+        sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15];
+        w += 16;
+    }
+    mlen += 32;
+    while ((mlen -= 8) >= 0)
+    {
+        sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
+        w += 4;
+    }
+    mlen += 8;
+    if (mlen == 0 && byte_swapped == 0)
+        goto cont;
+    REDUCE;
+    while ((mlen -= 2) >= 0)
+    {
+        sum += *w++;
+    }
         
-        if (len < mlen)
-           mlen = len;
-        len -= mlen;
-        /*
-         * Force to even boundary.
-         */
-        if ((1 & (long) w) && (mlen > 0)) {
-                REDUCE;
-                sum <<= 8;
-                s_util.c[0] = *(u_int8_t *)w;
-                w = (u_int16_t *)((int8_t *)w + 1);
-                mlen--;
-                byte_swapped = 1;
+    if (byte_swapped)
+    {
+        REDUCE;
+        sum <<= 8;
+        byte_swapped = 0;
+        if (mlen == -1)
+        {
+            s_util.c[1] = *(u_int8_t *)w;
+            sum += s_util.s;
+            mlen = 0;
         }
-        /*
-         * Unroll the loop to make overhead from
-         * branches &c small.
-         */
-        while ((mlen -= 32) >= 0) {
-                sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
-                sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7];
-                sum += w[8]; sum += w[9]; sum += w[10]; sum += w[11];
-                sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15];
-                w += 16;
-        }
-        mlen += 32;
-        while ((mlen -= 8) >= 0) {
-                sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
-                w += 4;
-        }
-        mlen += 8;
-        if (mlen == 0 && byte_swapped == 0)
-           goto cont;
-        REDUCE;
-        while ((mlen -= 2) >= 0) {
-                sum += *w++;
-        }
-        
-        if (byte_swapped) {
-                REDUCE;
-                sum <<= 8;
-                byte_swapped = 0;
-                if (mlen == -1) {
-                        s_util.c[1] = *(u_int8_t *)w;
-                        sum += s_util.s;
-                        mlen = 0;
-                } else
-                   
-                   mlen = -1;
-        } else if (mlen == -1)
-           s_util.c[0] = *(u_int8_t *)w;
+        else
+            mlen = -1;
+    }
+    else if (mlen == -1)
+        s_util.c[0] = *(u_int8_t *)w;
         
 cont:
 #ifdef DEBUG
-        if (len) {
-                DEBUG_ERROR((dfd, "cksum: out of data\n"));
-                DEBUG_ERROR((dfd, " len = %d\n", len));
-        }
+    if (len)
+    {
+        DEBUG_ERROR((dfd, "cksum: out of data\n"));
+        DEBUG_ERROR((dfd, " len = %d\n", len));
+    }
 #endif
-        if (mlen == -1) {
-                /* The last mbuf has odd # of bytes. Follow the
-                 standard (the odd byte may be shifted left by 8 bits
-                           or not as determined by endian-ness of the machine) */
-                s_util.c[1] = 0;
-                sum += s_util.s;
-        }
-        REDUCE;
-        return (~sum & 0xffff);
+    if (mlen == -1)
+    {
+        /* The last mbuf has odd # of bytes. Follow the
+           standard (the odd byte may be shifted left by 8 bits
+           or not as determined by endian-ness of the machine) */
+        s_util.c[1] = 0;
+        sum += s_util.s;
+    }
+    REDUCE;
+    return (~sum & 0xffff);
 }
Index: trunk/src/VBox/Devices/Network/slirp/icmp_var.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/icmp_var.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/icmp_var.h	(revision 14964)
@@ -42,12 +42,13 @@
  * of the internet control message protocol.
  */
-struct icmpstat_t {
+struct icmpstat_t
+{
 /* statistics related to input messages processed */
-	u_long  icps_received;		/* #ICMP packets received */
-	u_long	icps_tooshort;		/* packet < ICMP_MINLEN */
-	u_long	icps_checksum;		/* bad checksum */
-	u_long	icps_notsupp;		/* #ICMP packets not supported */
-	u_long  icps_badtype;		/* #with bad type feild */
-	u_long	icps_reflect;		/* number of responses */
+    u_long  icps_received;		/* #ICMP packets received */
+    u_long	icps_tooshort;		/* packet < ICMP_MINLEN */
+    u_long	icps_checksum;		/* bad checksum */
+    u_long	icps_notsupp;		/* #ICMP packets not supported */
+    u_long  icps_badtype;		/* #with bad type feild */
+    u_long	icps_reflect;		/* number of responses */
 };
 
Index: trunk/src/VBox/Devices/Network/slirp/if.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/if.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/if.h	(revision 14964)
@@ -17,5 +17,5 @@
 #undef if_mtu
 extern int      if_mtu;
-extern int      if_mru; /* MTU and MRU */
+extern int      if_mru;         /* MTU and MRU */
 extern int      if_comp;        /* Flags for compression */
 extern int      if_maxlinkhdr;
@@ -24,6 +24,6 @@
                                  * (to prevent allocing too many mbufs) */
 
-extern  struct mbuf if_fastq;                  /* fast queue (for interactive data) */
-extern  struct mbuf if_batchq;                 /* queue for non-interactive data */
+extern  struct mbuf if_fastq;   /* fast queue (for interactive data) */
+extern  struct mbuf if_batchq;  /* queue for non-interactive data */
 extern  struct mbuf *next_m;
 
Index: trunk/src/VBox/Devices/Network/slirp/ip_output.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 14964)
@@ -55,68 +55,73 @@
 ip_output(PNATState pData, struct socket *so, struct mbuf *m0)
 {
-        register struct ip *ip;
-        register struct mbuf *m = m0;
-        register int hlen = sizeof(struct ip );
-        int len, off, error = 0;
-
-        DEBUG_CALL("ip_output");
-        DEBUG_ARG("so = %lx", (long)so);
-        DEBUG_ARG("m0 = %lx", (long)m0);
-
-        /* We do no options */
-/*      if (opt) {
- *              m = ip_insertoptions(m, opt, &len);
- *              hlen = len;
- *      }
- */
-        ip = mtod(m, struct ip *);
-        /*
-         * Fill in IP header.
-         */
-        ip->ip_v = IPVERSION;
-        ip->ip_off &= IP_DF;
-        ip->ip_id = htons(ip_currid++);
-        ip->ip_hl = hlen >> 2;
-        ipstat.ips_localout++;
-
-        /*
-         * Verify that we have any chance at all of being able to queue
-         *      the packet or packet fragments
-         */
-        /* XXX Hmmm... */
-/*      if (if_queued > if_thresh && towrite <= 0) {
- *              error = ENOBUFS;
- *              goto bad;
- *      }
- */
-
-        /*
-         * If small enough for interface, can just send directly.
-         */
-        if ((u_int16_t)ip->ip_len <= if_mtu) {
-                ip->ip_len = htons((u_int16_t)ip->ip_len);
-                ip->ip_off = htons((u_int16_t)ip->ip_off);
-                ip->ip_sum = 0;
-                ip->ip_sum = cksum(m, hlen);
-
-                if_output(pData, so, m);
-                goto done;
-        }
-
-        /*
-         * Too large for interface; fragment if possible.
-         * Must be able to put at least 8 bytes per fragment.
-         */
-        if (ip->ip_off & IP_DF) {
-                error = -1;
-                ipstat.ips_cantfrag++;
-                goto bad;
-        }
-
-        len = (if_mtu - hlen) &~ 7;       /* ip databytes per packet */
-        if (len < 8) {
-                error = -1;
-                goto bad;
-        }
+    register struct ip *ip;
+    register struct mbuf *m = m0;
+    register int hlen = sizeof(struct ip );
+    int len, off, error = 0;
+
+    DEBUG_CALL("ip_output");
+    DEBUG_ARG("so = %lx", (long)so);
+    DEBUG_ARG("m0 = %lx", (long)m0);
+
+#if 0 /* We do no options */
+    if (opt)
+    {
+        m = ip_insertoptions(m, opt, &len);
+        hlen = len;
+    }
+#endif
+    ip = mtod(m, struct ip *);
+    /*
+     * Fill in IP header.
+     */
+    ip->ip_v = IPVERSION;
+    ip->ip_off &= IP_DF;
+    ip->ip_id = htons(ip_currid++);
+    ip->ip_hl = hlen >> 2;
+    ipstat.ips_localout++;
+
+    /*
+     * Verify that we have any chance at all of being able to queue
+     *      the packet or packet fragments
+     */
+#if 0 /* XXX Hmmm... */
+    if (if_queued > if_thresh && towrite <= 0)
+    {
+        error = ENOBUFS;
+        goto bad;
+    }
+#endif
+
+    /*
+     * If small enough for interface, can just send directly.
+     */
+    if ((u_int16_t)ip->ip_len <= if_mtu)
+    {
+        ip->ip_len = htons((u_int16_t)ip->ip_len);
+        ip->ip_off = htons((u_int16_t)ip->ip_off);
+        ip->ip_sum = 0;
+        ip->ip_sum = cksum(m, hlen);
+
+        if_output(pData, so, m);
+        goto done;
+    }
+
+    /*
+     * Too large for interface; fragment if possible.
+     * Must be able to put at least 8 bytes per fragment.
+     */
+    if (ip->ip_off & IP_DF)
+    {
+        error = -1;
+        ipstat.ips_cantfrag++;
+        goto bad;
+    }
+
+    len = (if_mtu - hlen) &~ 7;       /* ip databytes per packet */
+    if (len < 8)
+    {
+        error = -1;
+        goto bad;
+    }
 
     {
@@ -130,43 +135,47 @@
         m0 = m;
         mhlen = sizeof (struct ip);
-        for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) {
-          register struct ip *mhip;
-          m = m_get(pData);
-          if (m == 0) {
-            error = -1;
-            ipstat.ips_odropped++;
-            goto sendorfree;
-          }
-          m->m_data += if_maxlinkhdr;
-          mhip = mtod(m, struct ip *);
-          *mhip = *ip;
-
-                /* No options */
-/*              if (hlen > sizeof (struct ip)) {
- *                      mhlen = ip_optcopy(ip, mhip) + sizeof (struct ip);
- *                      mhip->ip_hl = mhlen >> 2;
- *              }
- */
-          m->m_len = mhlen;
-          mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
-          if (ip->ip_off & IP_MF)
-            mhip->ip_off |= IP_MF;
-          if (off + len >= (u_int16_t)ip->ip_len)
-            len = (u_int16_t)ip->ip_len - off;
-          else
-            mhip->ip_off |= IP_MF;
-          mhip->ip_len = htons((u_int16_t)(len + mhlen));
-
-          if (m_copy(m, m0, off, len) < 0) {
-            error = -1;
-            goto sendorfree;
-          }
-
-          mhip->ip_off = htons((u_int16_t)mhip->ip_off);
-          mhip->ip_sum = 0;
-          mhip->ip_sum = cksum(m, mhlen);
-          *mnext = m;
-          mnext = &m->m_nextpkt;
-          ipstat.ips_ofragments++;
+        for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len)
+        {
+            register struct ip *mhip;
+            m = m_get(pData);
+            if (m == 0)
+            {
+                error = -1;
+                ipstat.ips_odropped++;
+                goto sendorfree;
+            }
+            m->m_data += if_maxlinkhdr;
+            mhip = mtod(m, struct ip *);
+            *mhip = *ip;
+
+#if 0 /* No options */
+            if (hlen > sizeof (struct ip))
+            {
+                mhlen = ip_optcopy(ip, mhip) + sizeof (struct ip);
+                mhip->ip_hl = mhlen >> 2;
+            }
+#endif
+            m->m_len = mhlen;
+            mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
+            if (ip->ip_off & IP_MF)
+                mhip->ip_off |= IP_MF;
+            if (off + len >= (u_int16_t)ip->ip_len)
+                len = (u_int16_t)ip->ip_len - off;
+            else
+                mhip->ip_off |= IP_MF;
+            mhip->ip_len = htons((u_int16_t)(len + mhlen));
+
+            if (m_copy(m, m0, off, len) < 0)
+            {
+                error = -1;
+                goto sendorfree;
+            }
+
+            mhip->ip_off = htons((u_int16_t)mhip->ip_off);
+            mhip->ip_sum = 0;
+            mhip->ip_sum = cksum(m, mhlen);
+            *mnext = m;
+            mnext = &m->m_nextpkt;
+            ipstat.ips_ofragments++;
         }
         /*
@@ -180,23 +189,25 @@
         ip->ip_sum = 0;
         ip->ip_sum = cksum(m, hlen);
+
 sendorfree:
-        for (m = m0; m; m = m0) {
-                m0 = m->m_nextpkt;
-                m->m_nextpkt = 0;
-                if (error == 0)
-                        if_output(pData, so, m);
-                else
-                        m_freem(pData, m);
+        for (m = m0; m; m = m0)
+        {
+            m0 = m->m_nextpkt;
+            m->m_nextpkt = 0;
+            if (error == 0)
+                if_output(pData, so, m);
+            else
+                m_freem(pData, m);
         }
 
         if (error == 0)
-                ipstat.ips_fragmented++;
+            ipstat.ips_fragmented++;
     }
 
 done:
-        return (error);
+    return (error);
 
 bad:
-        m_freem(pData, m0);
-        goto done;
+    m_freem(pData, m0);
+    goto done;
 }
Index: trunk/src/VBox/Devices/Network/slirp/libslirp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/libslirp.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/libslirp.h	(revision 14964)
@@ -2,19 +2,19 @@
 #define _LIBSLIRP_H
 
-#ifdef _WIN32
-#include <winsock2.h>
-#ifdef __cplusplus
+#ifdef RT_OS_WINDOWS
+# include <winsock2.h>
+# ifdef __cplusplus
 extern "C" {
-#endif
+# endif
 int inet_aton(const char *cp, struct in_addr *ia);
-#ifdef __cplusplus
+# ifdef __cplusplus
 }
-#endif
+# endif
 #else
-#ifdef RT_OS_OS2 /* temporary workaround, see ticket #127 */
-# include <sys/time.h>
-#endif
-#include <sys/select.h>
-#include <arpa/inet.h>
+# ifdef RT_OS_OS2 /* temporary workaround, see ticket #127 */
+#  include <sys/time.h>
+# endif
+# include <sys/select.h>
+# include <arpa/inet.h>
 #endif
 
Index: trunk/src/VBox/Devices/Network/slirp/main.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/main.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/main.h	(revision 14964)
@@ -10,20 +10,3 @@
 #endif
 
-#define TOWRITEMAX 512
-
-
-/*
- * Get the difference in 2 times from updtim()
- * Allow for wraparound times, "just in case"
- * x is the greater of the 2 (current time) and y is
- * what it's being compared against.
- */
-#define TIME_DIFF(x,y) (x)-(y) < 0 ? ~0-(y)+(x) : (x)-(y)
-
-
-#define PROTO_SLIP 0x1
-#ifdef USE_PPP
-#define PROTO_PPP 0x2
-#endif
-
 void if_encap(PNATState pData, const uint8_t *ip_data, int ip_data_len);
Index: trunk/src/VBox/Devices/Network/slirp/mbuf.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/mbuf.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/mbuf.c	(revision 14964)
@@ -22,8 +22,8 @@
 m_init(PNATState pData)
 {
-        m_freelist.m_next = m_freelist.m_prev = &m_freelist;
-        m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
-        mbuf_alloced = 0;
-        msize_init(pData);
+    m_freelist.m_next = m_freelist.m_prev = &m_freelist;
+    m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
+    mbuf_alloced = 0;
+    msize_init(pData);
 }
 
@@ -31,10 +31,10 @@
 msize_init(PNATState pData)
 {
-        /*
-         * Find a nice value for msize
-         * XXX if_maxlinkhdr already in mtu
-         */
-        msize = (if_mtu>if_mru?if_mtu:if_mru) +
-                        if_maxlinkhdr + sizeof(struct m_hdr ) + 6;
+    /*
+     * Find a nice value for msize
+     * XXX if_maxlinkhdr already in mtu
+     */
+    msize = (if_mtu>if_mru ? if_mtu : if_mru) 
+          + if_maxlinkhdr + sizeof(struct m_hdr ) + 6;
 }
 
@@ -50,35 +50,40 @@
 m_get(PNATState pData)
 {
-        register struct mbuf *m;
-        int flags = 0;
-
-        DEBUG_CALL("m_get");
-
-        if (m_freelist.m_next == &m_freelist) {
-                m = (struct mbuf *)malloc(msize);
-                if (m == NULL) goto end_error;
-                mbuf_alloced++;
-                if (mbuf_alloced > mbuf_thresh)
-                        flags = M_DOFREE;
-                if (mbuf_alloced > mbuf_max)
-                        mbuf_max = mbuf_alloced;
-        } else {
-                m = m_freelist.m_next;
-                remque(pData, m);
-        }
-
-        /* Insert it in the used list */
-        insque(pData, m,&m_usedlist);
-        m->m_flags = (flags | M_USEDLIST);
-
-        /* Initialise it */
-        m->m_size = msize - sizeof(struct m_hdr);
-        m->m_data = m->m_dat;
-        m->m_len = 0;
-        m->m_nextpkt = 0;
-        m->m_prevpkt = 0;
+    register struct mbuf *m;
+    int flags = 0;
+
+    DEBUG_CALL("m_get");
+
+    if (m_freelist.m_next == &m_freelist)
+    {
+        m = (struct mbuf *)malloc(msize);
+        if (m == NULL) goto
+            end_error;
+        mbuf_alloced++;
+        if (mbuf_alloced > mbuf_thresh)
+            flags = M_DOFREE;
+        if (mbuf_alloced > mbuf_max)
+            mbuf_max = mbuf_alloced;
+    }
+    else
+    {
+        m = m_freelist.m_next;
+        remque(pData, m);
+    }
+
+    /* Insert it in the used list */
+    insque(pData, m, &m_usedlist);
+    m->m_flags = (flags | M_USEDLIST);
+
+    /* Initialise it */
+    m->m_size = msize - sizeof(struct m_hdr);
+    m->m_data = m->m_dat;
+    m->m_len = 0;
+    m->m_nextpkt = 0;
+    m->m_prevpkt = 0;
+
 end_error:
-        DEBUG_ARG("m = %lx", (long )m);
-        return m;
+    DEBUG_ARG("m = %lx", (long )m);
+    return m;
 }
 
@@ -87,28 +92,32 @@
 {
 
-  DEBUG_CALL("m_free");
-  DEBUG_ARG("m = %lx", (long )m);
-
-  if(m) {
+    DEBUG_CALL("m_free");
+    DEBUG_ARG("m = %lx", (long )m);
+
+    if(m)
+    {
         /* Remove from m_usedlist */
         if (m->m_flags & M_USEDLIST)
-           remque(pData, m);
+            remque(pData, m);
 
         /* If it's M_EXT, free() it */
         if (m->m_flags & M_EXT)
-           free(m->m_ext);
+            free(m->m_ext);
 
         /*
          * Either free() it or put it on the free list
          */
-        if (m->m_flags & M_DOFREE) {
-                u32ptr_done(pData, ptr_to_u32(pData, m), m);
-                free(m);
-                mbuf_alloced--;
-        } else if ((m->m_flags & M_FREELIST) == 0) {
-                insque(pData, m,&m_freelist);
-                m->m_flags = M_FREELIST; /* Clobber other flags */
-        }
-  } /* if(m) */
+        if (m->m_flags & M_DOFREE)
+        {
+            u32ptr_done(pData, ptr_to_u32(pData, m), m);
+            free(m);
+            mbuf_alloced--;
+        }
+        else if ((m->m_flags & M_FREELIST) == 0)
+        {
+            insque(pData, m,&m_freelist);
+            m->m_flags = M_FREELIST; /* Clobber other flags */
+        }
+    } /* if(m) */
 }
 
@@ -121,14 +130,14 @@
 m_cat(PNATState pData, register struct mbuf *m, register struct mbuf *n)
 {
-        /*
-         * If there's no room, realloc
-         */
-        if (M_FREEROOM(m) < n->m_len)
-                m_inc(m,m->m_size+MINCSIZE);
-
-        memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
-        m->m_len += n->m_len;
-
-        m_free(pData, n);
+    /*
+     * If there's no room, realloc
+     */
+    if (M_FREEROOM(m) < n->m_len)
+        m_inc(m,m->m_size+MINCSIZE);
+
+    memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
+    m->m_len += n->m_len;
+
+    m_free(pData, n);
 }
 
@@ -136,56 +145,59 @@
 /* make m size bytes large */
 void
-m_inc(m, size)
-        struct mbuf *m;
-        int size;
-{
-        int datasize;
-
-        /* some compiles throw up on gotos.  This one we can fake. */
-        if(m->m_size>size) return;
-
-        if (m->m_flags & M_EXT) {
-          datasize = m->m_data - m->m_ext;
-          m->m_ext = (char *)realloc(m->m_ext,size);
-/*              if (m->m_ext == NULL)
- *                      return (struct mbuf *)NULL;
- */
-          m->m_data = m->m_ext + datasize;
-        } else {
-          char *dat;
-          datasize = m->m_data - m->m_dat;
-          dat = (char *)malloc(size);
-/*              if (dat == NULL)
- *                      return (struct mbuf *)NULL;
- */
-          memcpy(dat, m->m_dat, m->m_size);
-
-          m->m_ext = dat;
-          m->m_data = m->m_ext + datasize;
-          m->m_flags |= M_EXT;
-        }
-
-        m->m_size = size;
-
-}
-
-
-
-void
-m_adj(m, len)
-        struct mbuf *m;
-        int len;
-{
-        if (m == NULL)
-                return;
-        if (len >= 0) {
-                /* Trim from head */
-                m->m_data += len;
-                m->m_len -= len;
-        } else {
-                /* Trim from tail */
-                len = -len;
-                m->m_len -= len;
-        }
+m_inc(struct mbuf *m, int size)
+{
+    int datasize;
+
+    /* some compiles throw up on gotos.  This one we can fake. */
+    if (m->m_size>size)
+        return;
+
+    if (m->m_flags & M_EXT)
+    {
+        datasize = m->m_data - m->m_ext;
+        m->m_ext = (char *)realloc(m->m_ext,size);
+#if 0
+        if (m->m_ext == NULL)
+            return (struct mbuf *)NULL;
+#endif
+        m->m_data = m->m_ext + datasize;
+    }
+    else
+    {
+        char *dat;
+        datasize = m->m_data - m->m_dat;
+        dat = (char *)malloc(size);
+#if 0
+        if (dat == NULL)
+            return (struct mbuf *)NULL;
+#endif
+        memcpy(dat, m->m_dat, m->m_size);
+
+        m->m_ext = dat;
+        m->m_data = m->m_ext + datasize;
+        m->m_flags |= M_EXT;
+    }
+
+    m->m_size = size;
+}
+
+
+void
+m_adj(struct mbuf *m, int len)
+{
+    if (m == NULL)
+        return;
+    if (len >= 0)
+    {
+        /* Trim from head */
+        m->m_data += len;
+        m->m_len -= len;
+    }
+    else
+    {
+        /* Trim from tail */
+        len = -len;
+        m->m_len -= len;
+    }
 }
 
@@ -195,14 +207,12 @@
  */
 int
-m_copy(n, m, off, len)
-        struct mbuf *n, *m;
-        int off, len;
-{
-        if (len > M_FREEROOM(n))
-                return -1;
-
-        memcpy((n->m_data + n->m_len), (m->m_data + off), len);
-        n->m_len += len;
-        return 0;
+m_copy(struct mbuf *n, struct mbuf *m, int off, int len)
+{
+    if (len > M_FREEROOM(n))
+        return -1;
+
+    memcpy((n->m_data + n->m_len), (m->m_data + off), len);
+    n->m_len += len;
+    return 0;
 }
 
@@ -216,23 +226,28 @@
 dtom(PNATState pData, void *dat)
 {
-        struct mbuf *m;
-
-        DEBUG_CALL("dtom");
-        DEBUG_ARG("dat = %lx", (long )dat);
-
-        /* bug corrected for M_EXT buffers */
-        for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next) {
-          if (m->m_flags & M_EXT) {
-            if( (char *)dat>=m->m_ext && (char *)dat<(m->m_ext + m->m_size) )
-              return m;
-          } else {
-            if( (char *)dat >= m->m_dat && (char *)dat<(m->m_dat + m->m_size) )
-              return m;
-          }
-        }
-
-        DEBUG_ERROR((dfd, "dtom failed"));
-
-        return (struct mbuf *)0;
-}
-
+    struct mbuf *m;
+
+    DEBUG_CALL("dtom");
+    DEBUG_ARG("dat = %lx", (long )dat);
+
+    /* bug corrected for M_EXT buffers */
+    for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
+    {
+        if (m->m_flags & M_EXT)
+        {
+            if (   (char *)dat >=  m->m_ext
+                && (char *)dat <  (m->m_ext + m->m_size))
+                return m;
+        }
+        else
+        {
+            if (   (char *)dat >=  m->m_dat 
+                && (char *)dat <  (m->m_dat + m->m_size))
+                return m;
+        }
+    }
+
+    DEBUG_ERROR((dfd, "dtom failed"));
+
+    return (struct mbuf *)0;
+}
Index: trunk/src/VBox/Devices/Network/slirp/mbuf.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/mbuf.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/mbuf.h	(revision 14964)
@@ -61,18 +61,19 @@
 /* XXX should union some of these! */
 /* header at beginning of each mbuf: */
-struct m_hdr {
-        struct  mbuf *mh_next;          /* Linked list of mbufs */
-        struct  mbuf *mh_prev;
-        struct  mbuf *mh_nextpkt;       /* Next packet in queue/record */
-        struct  mbuf *mh_prevpkt; /* Flags aren't used in the output queue */
-        int     mh_flags;         /* Misc flags */
+struct m_hdr
+{
+    struct  mbuf *mh_next;     /* Linked list of mbufs */
+    struct  mbuf *mh_prev;
+    struct  mbuf *mh_nextpkt;  /* Next packet in queue/record */
+    struct  mbuf *mh_prevpkt;  /* Flags aren't used in the output queue */
+    int     mh_flags;          /* Misc flags */
 
-        int     mh_size;                /* Size of data */
-        struct  socket *mh_so;
+    int     mh_size;           /* Size of data */
+    struct  socket *mh_so;
 
-        caddr_t mh_data;                /* Location of data */
-        int     mh_len;                 /* Amount of data in this mbuf */
+    caddr_t mh_data;           /* Location of data */
+    int     mh_len;            /* Amount of data in this mbuf */
 #ifdef VBOX_WITH_BSD_REASS
-        void *header;                   /*XXX: in real BSD sources this field lays in pkthdr structure*/
+    void *header;              /*XXX: in real BSD sources this field lays in pkthdr structure*/
 #endif
 };
@@ -92,10 +93,12 @@
 #define M_TRAILINGSPACE M_FREEROOM
 
-struct mbuf {
-        struct  m_hdr m_hdr;
-        union M_dat {
-                char    m_dat_[1]; /* ANSI don't like 0 sized arrays */
-                char    *m_ext_;
-        } M_dat;
+struct mbuf
+{
+    struct  m_hdr m_hdr;
+    union M_dat
+    {
+        char    m_dat_[1]; /* ANSI don't like 0 sized arrays */
+        char    *m_ext_;
+    } M_dat;
 };
 
@@ -129,14 +132,4 @@
 #endif /* VBOX_WITH_BSD_REASS */
 
-/*
- * Mbuf statistics. XXX
- */
-
-struct mbstat {
-        int mbs_alloced;                /* Number of mbufs allocated */
-
-};
-
-extern struct   mbstat mbstat;
 extern int mbuf_alloced;
 extern struct mbuf m_freelist, m_usedlist;
Index: trunk/src/VBox/Devices/Network/slirp/misc.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/misc.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/misc.c	(revision 14964)
@@ -11,13 +11,11 @@
 #ifndef HAVE_INET_ATON
 int
-inet_aton(cp, ia)
-        const char *cp;
-        struct in_addr *ia;
+inet_aton(const char *cp, struct in_addr *ia)
 {
-        u_int32_t addr = inet_addr(cp);
-        if (addr == 0xffffffff)
-                return 0;
-        ia->s_addr = addr;
-        return 1;
+    u_int32_t addr = inet_addr(cp);
+    if (addr == 0xffffffff)
+        return 0;
+    ia->s_addr = addr;
+    return 1;
 }
 #endif
@@ -29,12 +27,13 @@
 getouraddr(PNATState pData)
 {
-        our_addr.s_addr = loopback_addr.s_addr;
+    our_addr.s_addr = loopback_addr.s_addr;
 }
 
 #if SIZEOF_CHAR_P == 8 && !defined(VBOX_WITH_BSD_REASS)
 
-struct quehead_32 {
-        u_int32_t qh_link;
-        u_int32_t qh_rlink;
+struct quehead_32
+{
+    u_int32_t qh_link;
+    u_int32_t qh_rlink;
 };
 
@@ -42,12 +41,12 @@
 insque_32(PNATState pData, void *a, void *b)
 {
-        register struct quehead_32 *element = (struct quehead_32 *) a;
-        register struct quehead_32 *head = (struct quehead_32 *) b;
-        struct quehead_32 *link = u32_to_ptr(pData, head->qh_link, struct quehead_32 *);
+    register struct quehead_32 *element = (struct quehead_32 *) a;
+    register struct quehead_32 *head = (struct quehead_32 *) b;
+    struct quehead_32 *link = u32_to_ptr(pData, head->qh_link, struct quehead_32 *);
 
-        element->qh_link = head->qh_link;
-        element->qh_rlink = ptr_to_u32(pData, head);
-        Assert(link->qh_rlink == element->qh_rlink);
-        link->qh_rlink = head->qh_link = ptr_to_u32(pData, element);
+    element->qh_link = head->qh_link;
+    element->qh_rlink = ptr_to_u32(pData, head);
+    Assert(link->qh_rlink == element->qh_rlink);
+    link->qh_rlink = head->qh_link = ptr_to_u32(pData, element);
 }
 
@@ -55,19 +54,20 @@
 remque_32(PNATState pData, void *a)
 {
-        register struct quehead_32 *element = (struct quehead_32 *) a;
-        struct quehead_32 *link = u32_to_ptr(pData, element->qh_link, struct quehead_32 *);
-        struct quehead_32 *rlink = u32_to_ptr(pData, element->qh_rlink, struct quehead_32 *);
+    register struct quehead_32 *element = (struct quehead_32 *) a;
+    struct quehead_32 *link = u32_to_ptr(pData, element->qh_link, struct quehead_32 *);
+    struct quehead_32 *rlink = u32_to_ptr(pData, element->qh_rlink, struct quehead_32 *);
 
-        u32ptr_done(pData, link->qh_rlink, element);
-        link->qh_rlink = element->qh_rlink;
-        rlink->qh_link = element->qh_link;
-        element->qh_rlink = 0;
+    u32ptr_done(pData, link->qh_rlink, element);
+    link->qh_rlink = element->qh_rlink;
+    rlink->qh_link = element->qh_link;
+    element->qh_rlink = 0;
 }
 
 #endif /* SIZEOF_CHAR_P == 8 && !VBOX_WITH_BSD_REASS */
 
-struct quehead {
-        struct quehead *qh_link;
-        struct quehead *qh_rlink;
+struct quehead
+{
+    struct quehead *qh_link;
+    struct quehead *qh_rlink;
 };
 
@@ -75,11 +75,10 @@
 insque(PNATState pData, void *a, void *b)
 {
-        register struct quehead *element = (struct quehead *) a;
-        register struct quehead *head = (struct quehead *) b;
-        element->qh_link = head->qh_link;
-        head->qh_link = (struct quehead *)element;
-        element->qh_rlink = (struct quehead *)head;
-        ((struct quehead *)(element->qh_link))->qh_rlink
-        = (struct quehead *)element;
+    register struct quehead *element = (struct quehead *) a;
+    register struct quehead *head = (struct quehead *) b;
+    element->qh_link = head->qh_link;
+    head->qh_link = (struct quehead *)element;
+    element->qh_rlink = (struct quehead *)head;
+    ((struct quehead *)(element->qh_link))->qh_rlink = (struct quehead *)element;
 }
 
@@ -87,168 +86,66 @@
 remque(PNATState pData, void *a)
 {
-  register struct quehead *element = (struct quehead *) a;
-  ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
-  ((struct quehead *)(element->qh_rlink))->qh_link = element->qh_link;
-  element->qh_rlink = NULL;
-  /*  element->qh_link = NULL;  TCP FIN1 crashes if you do this.  Why ? */
-}
-
-/* #endif */
-
-
-int
-add_exec(ex_ptr, do_pty, exec, addr, port)
-        struct ex_list **ex_ptr;
-        int do_pty;
-        char *exec;
-        int addr;
-        int port;
-{
-        struct ex_list *tmp_ptr;
-
-        /* First, check if the port is "bound" */
-        for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) {
-                if (port == tmp_ptr->ex_fport && addr == tmp_ptr->ex_addr)
-                   return -1;
-        }
-
-        tmp_ptr = *ex_ptr;
-        *ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));
-        (*ex_ptr)->ex_fport = port;
-        (*ex_ptr)->ex_addr = addr;
-        (*ex_ptr)->ex_pty = do_pty;
-        (*ex_ptr)->ex_exec = strdup(exec);
-        (*ex_ptr)->ex_next = tmp_ptr;
-        return 0;
-}
-
-#ifndef HAVE_STRERROR
-
-/*
- * For systems with no strerror
- */
-
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-char *
-strerror(error)
-        int error;
-{
-        if (error < sys_nerr)
-           return sys_errlist[error];
-        else
-           return "Unknown error.";
-}
-
-#endif
-
-
-#ifndef HAVE_STRDUP
-char *
-strdup(str)
-        const char *str;
-{
-        char *bptr;
-
-        bptr = (char *)malloc(strlen(str)+1);
-        strcpy(bptr, str);
-
-        return bptr;
-}
-#endif
-
-#ifdef BAD_SPRINTF
-
-#undef vsprintf
-#undef sprintf
-
-/*
- * Some BSD-derived systems have a sprintf which returns char *
- */
-
-int
-vsprintf_len(string, format, args)
-        char *string;
-        const char *format;
-        va_list args;
-{
-        vsprintf(string, format, args);
-        return strlen(string);
+    register struct quehead *element = (struct quehead *) a;
+    ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
+    ((struct quehead *)(element->qh_rlink))->qh_link = element->qh_link;
+    element->qh_rlink = NULL;
+    /*  element->qh_link = NULL;  TCP FIN1 crashes if you do this.  Why ? */
 }
 
 int
-#ifdef __STDC__
-sprintf_len(char *string, const char *format, ...)
-#else
-sprintf_len(va_alist) va_dcl
-#endif
+add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, int addr, int port)
 {
-        va_list args;
-#ifdef __STDC__
-        va_start(args, format);
-#else
-        char *string;
-        char *format;
-        va_start(args);
-        string = va_arg(args, char *);
-        format = va_arg(args, char *);
-#endif
-        vsprintf(string, format, args);
-        return strlen(string);
+    struct ex_list *tmp_ptr;
+
+    /* First, check if the port is "bound" */
+    for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next)
+    {
+        if (port == tmp_ptr->ex_fport && addr == tmp_ptr->ex_addr)
+            return -1;
+    }
+
+    tmp_ptr = *ex_ptr;
+    *ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));
+    (*ex_ptr)->ex_fport = port;
+    (*ex_ptr)->ex_addr = addr;
+    (*ex_ptr)->ex_pty = do_pty;
+    (*ex_ptr)->ex_exec = strdup(exec);
+    (*ex_ptr)->ex_next = tmp_ptr;
+    return 0;
 }
 
-#endif
-
-void
-u_sleep(usec)
-        int usec;
-{
-        struct timeval t;
-        fd_set fdset;
-
-        FD_ZERO(&fdset);
-
-        t.tv_sec = 0;
-        t.tv_usec = usec * 1000;
-
-        select(0, &fdset, &fdset, &fdset, &t);
-}
 
 /*
  * Set fd blocking and non-blocking
  */
-
 void
-fd_nonblock(fd)
-        int fd;
+fd_nonblock(int fd)
 {
 #ifdef FIONBIO
-        int opt = 1;
+    int opt = 1;
 
-        ioctlsocket(fd, FIONBIO, &opt);
+    ioctlsocket(fd, FIONBIO, &opt);
 #else
-        int opt;
+    int opt;
 
-        opt = fcntl(fd, F_GETFL, 0);
-        opt |= O_NONBLOCK;
-        fcntl(fd, F_SETFL, opt);
+    opt = fcntl(fd, F_GETFL, 0);
+    opt |= O_NONBLOCK;
+    fcntl(fd, F_SETFL, opt);
 #endif
 }
 
 void
-fd_block(fd)
-        int fd;
+fd_block(int fd)
 {
 #ifdef FIONBIO
-        int opt = 0;
+    int opt = 0;
 
-        ioctlsocket(fd, FIONBIO, &opt);
+    ioctlsocket(fd, FIONBIO, &opt);
 #else
-        int opt;
+    int opt;
 
-        opt = fcntl(fd, F_GETFL, 0);
-        opt &= ~O_NONBLOCK;
-        fcntl(fd, F_SETFL, opt);
+    opt = fcntl(fd, F_GETFL, 0);
+    opt &= ~O_NONBLOCK;
+    fcntl(fd, F_SETFL, opt);
 #endif
 }
Index: trunk/src/VBox/Devices/Network/slirp/misc.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/misc.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/misc.h	(revision 14964)
@@ -9,52 +9,49 @@
 #define _MISC_H_
 
-struct ex_list {
-	int ex_pty;			/* Do we want a pty? */
-	int ex_addr;			/* The last byte of the address */
-	int ex_fport;                   /* Port to telnet to */
-	char *ex_exec;                  /* Command line of what to exec */
-	struct ex_list *ex_next;
+struct ex_list
+{
+    int ex_pty;	         /* Do we want a pty? */
+    int ex_addr;         /* The last byte of the address */
+    int ex_fport;        /* Port to telnet to */
+    char *ex_exec;       /* Command line of what to exec */
+    struct ex_list *ex_next;
 };
 
 extern struct ex_list *exec_list;
 
-#ifndef HAVE_STRDUP
-char *strdup _P((const char *));
-#endif
-
-void do_wait _P((int));
-
-#define EMU_NONE 0x0
+#define EMU_NONE      0x0
 
 /* TCP emulations */
-#define EMU_CTL 0x1
-#define EMU_FTP 0x2
-#define EMU_KSH 0x3
-#define EMU_IRC 0x4
+#define EMU_CTL       0x1
+#define EMU_FTP       0x2
+#define EMU_KSH       0x3
+#define EMU_IRC       0x4
 #define EMU_REALAUDIO 0x5
-#define EMU_RLOGIN 0x6
-#define EMU_IDENT 0x7
-#define EMU_RSH 0x8
+#define EMU_RLOGIN    0x6
+#define EMU_IDENT     0x7
+#define EMU_RSH       0x8
 
 #define EMU_NOCONNECT 0x10	/* Don't connect */
 
 /* UDP emulations */
-#define EMU_TALK	0x1
-#define EMU_NTALK	0x2
-#define EMU_CUSEEME	0x3
+#define EMU_TALK      0x1
+#define EMU_NTALK     0x2
+#define EMU_CUSEEME   0x3
 
-struct tos_t {
-	u_int16_t lport;
-	u_int16_t fport;
-	u_int8_t tos;
-	u_int8_t emu;
+struct tos_t
+{
+    u_int16_t lport;
+    u_int16_t fport;
+    u_int8_t tos;
+    u_int8_t emu;
 };
 
-struct emu_t {
-	u_int16_t lport;
-	u_int16_t fport;
-	u_int8_t tos;
-	u_int8_t emu;
-	struct emu_t *next;
+struct emu_t
+{
+    u_int16_t lport;
+    u_int16_t fport;
+    u_int8_t tos;
+    u_int8_t emu;
+    struct emu_t *next;
 };
 
@@ -75,8 +72,6 @@
 void relay _P((int));
 void add_emu _P((char *));
-void u_sleep _P((int));
 void fd_nonblock _P((int));
 void fd_block _P((int));
-int rsh_exec _P((struct socket *, struct socket *, char *, char *, char *));
 
 #endif
Index: trunk/src/VBox/Devices/Network/slirp/sbuf.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/sbuf.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/sbuf.c	(revision 14964)
@@ -17,51 +17,50 @@
 
 void
-sbfree(sb)
-        struct sbuf *sb;
-{
-        free(sb->sb_data);
-}
-
-void
-sbdrop(sb, num)
-        struct sbuf *sb;
-        int num;
-{
-        /*
-         * We can only drop how much we have
-         * This should never succeed
-         */
-        if(num > sb->sb_cc)
-                num = sb->sb_cc;
-        sb->sb_cc -= num;
-        sb->sb_rptr += num;
-        if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
-                sb->sb_rptr -= sb->sb_datalen;
-
-}
-
-void
-sbreserve(sb, size)
-        struct sbuf *sb;
-        int size;
-{
-        if (sb->sb_data) {
-                /* Already alloced, realloc if necessary */
-                if (sb->sb_datalen != size) {
-                        sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)realloc(sb->sb_data, size);
-                        sb->sb_cc = 0;
-                        if (sb->sb_wptr)
-                           sb->sb_datalen = size;
-                        else
-                           sb->sb_datalen = 0;
-                }
-        } else {
-                sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size);
-                sb->sb_cc = 0;
-                if (sb->sb_wptr)
-                   sb->sb_datalen = size;
-                else
-                   sb->sb_datalen = 0;
+sbfree(struct sbuf *sb)
+{
+    free(sb->sb_data);
+}
+
+void
+sbdrop(struct sbuf *sb, int num)
+{
+    /*
+     * We can only drop how much we have
+     * This should never succeed
+     */
+    if (num > sb->sb_cc)
+        num = sb->sb_cc;
+    sb->sb_cc -= num;
+    sb->sb_rptr += num;
+    if (sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
+        sb->sb_rptr -= sb->sb_datalen;
+
+}
+
+void
+sbreserve(struct sbuf *sb, int size)
+{
+    if (sb->sb_data)
+    {
+        /* Already alloced, realloc if necessary */
+        if (sb->sb_datalen != size)
+        {
+            sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)realloc(sb->sb_data, size);
+            sb->sb_cc = 0;
+            if (sb->sb_wptr)
+                sb->sb_datalen = size;
+            else
+                sb->sb_datalen = 0;
         }
+    }
+    else
+    {
+        sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size);
+        sb->sb_cc = 0;
+        if (sb->sb_wptr)
+            sb->sb_datalen = size;
+        else
+            sb->sb_datalen = 0;
+    }
 }
 
@@ -75,55 +74,60 @@
 sbappend(PNATState pData, struct socket *so, struct mbuf *m)
 {
-        int ret = 0;
-
-        DEBUG_CALL("sbappend");
-        DEBUG_ARG("so = %lx", (long)so);
-        DEBUG_ARG("m = %lx", (long)m);
-        DEBUG_ARG("m->m_len = %d", m->m_len);
-
-        /* Shouldn't happen, but...  e.g. foreign host closes connection */
-        if (m->m_len <= 0) {
-                m_free(pData, m);
-                return;
-        }
-
+    int ret = 0;
+
+    DEBUG_CALL("sbappend");
+    DEBUG_ARG("so = %lx", (long)so);
+    DEBUG_ARG("m = %lx", (long)m);
+    DEBUG_ARG("m->m_len = %d", m->m_len);
+
+    /* Shouldn't happen, but...  e.g. foreign host closes connection */
+    if (m->m_len <= 0)
+    {
+        m_free(pData, m);
+        return;
+    }
+
+    /*
+     * If there is urgent data, call sosendoob
+     * if not all was sent, sowrite will take care of the rest
+     * (The rest of this function is just an optimisation)
+     */
+    if (so->so_urgc)
+    {
+        sbappendsb(&so->so_rcv, m);
+        m_free(pData, m);
+        sosendoob(so);
+        return;
+    }
+
+    /*
+     * We only write if there's nothing in the buffer,
+     * ottherwise it'll arrive out of order, and hence corrupt
+     */
+    if (!so->so_rcv.sb_cc)
+        ret = send(so->s, m->m_data, m->m_len, 0);
+
+    if (ret <= 0)
+    {
         /*
-         * If there is urgent data, call sosendoob
-         * if not all was sent, sowrite will take care of the rest
-         * (The rest of this function is just an optimisation)
+         * Nothing was written
+         * It's possible that the socket has closed, but
+         * we don't need to check because if it has closed,
+         * it will be detected in the normal way by soread()
          */
-        if (so->so_urgc) {
-                sbappendsb(&so->so_rcv, m);
-                m_free(pData, m);
-                sosendoob(so);
-                return;
-        }
-
+        sbappendsb(&so->so_rcv, m);
+    }
+    else if (ret != m->m_len)
+    {
         /*
-         * We only write if there's nothing in the buffer,
-         * ottherwise it'll arrive out of order, and hence corrupt
+         * Something was written, but not everything..
+         * sbappendsb the rest
          */
-        if (!so->so_rcv.sb_cc)
-           ret = send(so->s, m->m_data, m->m_len, 0);
-
-        if (ret <= 0) {
-                /*
-                 * Nothing was written
-                 * It's possible that the socket has closed, but
-                 * we don't need to check because if it has closed,
-                 * it will be detected in the normal way by soread()
-                 */
-                sbappendsb(&so->so_rcv, m);
-        } else if (ret != m->m_len) {
-                /*
-                 * Something was written, but not everything..
-                 * sbappendsb the rest
-                 */
-                m->m_len -= ret;
-                m->m_data += ret;
-                sbappendsb(&so->so_rcv, m);
-        } /* else */
-        /* Whatever happened, we free the mbuf */
-        m_free(pData, m);
+        m->m_len -= ret;
+        m->m_data += ret;
+        sbappendsb(&so->so_rcv, m);
+    } /* else */
+    /* Whatever happened, we free the mbuf */
+    m_free(pData, m);
 }
 
@@ -133,35 +137,38 @@
  */
 void
-sbappendsb(sb, m)
-         struct sbuf *sb;
-         struct mbuf *m;
-{
-        int len, n,  nn;
-
-        len = m->m_len;
-
-        if (sb->sb_wptr < sb->sb_rptr) {
-                n = sb->sb_rptr - sb->sb_wptr;
-                if (n > len) n = len;
-                memcpy(sb->sb_wptr, m->m_data, n);
-        } else {
-                /* Do the right edge first */
-                n = sb->sb_data + sb->sb_datalen - sb->sb_wptr;
-                if (n > len) n = len;
-                memcpy(sb->sb_wptr, m->m_data, n);
-                len -= n;
-                if (len) {
-                        /* Now the left edge */
-                        nn = sb->sb_rptr - sb->sb_data;
-                        if (nn > len) nn = len;
-                        memcpy(sb->sb_data,m->m_data+n,nn);
-                        n += nn;
-                }
+sbappendsb(struct sbuf *sb, struct mbuf *m)
+{
+    int len, n,  nn;
+
+    len = m->m_len;
+
+    if (sb->sb_wptr < sb->sb_rptr)
+    {
+        n = sb->sb_rptr - sb->sb_wptr;
+        if (n > len) n = len;
+        memcpy(sb->sb_wptr, m->m_data, n);
+    }
+    else
+    {
+        /* Do the right edge first */
+        n = sb->sb_data + sb->sb_datalen - sb->sb_wptr;
+        if (n > len) n = len;
+        memcpy(sb->sb_wptr, m->m_data, n);
+        len -= n;
+        if (len)
+        {
+            /* Now the left edge */
+            nn = sb->sb_rptr - sb->sb_data;
+            if (nn > len)
+                nn = len;
+            memcpy(sb->sb_data,m->m_data+n,nn);
+            n += nn;
         }
-
-        sb->sb_cc += n;
-        sb->sb_wptr += n;
-        if (sb->sb_wptr >= sb->sb_data + sb->sb_datalen)
-                sb->sb_wptr -= sb->sb_datalen;
+    }
+
+    sb->sb_cc += n;
+    sb->sb_wptr += n;
+    if (sb->sb_wptr >= sb->sb_data + sb->sb_datalen)
+        sb->sb_wptr -= sb->sb_datalen;
 }
 
@@ -172,28 +179,27 @@
  */
 void
-sbcopy(sb, off, len, to)
-        struct sbuf *sb;
-        int off;
-        int len;
-        char *to;
-{
-        char *from;
-
-        from = sb->sb_rptr + off;
-        if (from >= sb->sb_data + sb->sb_datalen)
-                from -= sb->sb_datalen;
-
-        if (from < sb->sb_wptr) {
-                if (len > sb->sb_cc) len = sb->sb_cc;
-                memcpy(to,from,len);
-        } else {
-                /* re-use off */
-                off = (sb->sb_data + sb->sb_datalen) - from;
-                if (off > len) off = len;
-                memcpy(to,from,off);
-                len -= off;
-                if (len)
-                   memcpy(to+off,sb->sb_data,len);
-        }
-}
-
+sbcopy(struct sbuf *sb, int off, int len, char *to)
+{
+    char *from;
+
+    from = sb->sb_rptr + off;
+    if (from >= sb->sb_data + sb->sb_datalen)
+        from -= sb->sb_datalen;
+
+    if (from < sb->sb_wptr)
+    {
+        if (len > sb->sb_cc) len = sb->sb_cc;
+        memcpy(to,from,len);
+    }
+    else
+    {
+        /* re-use off */
+        off = (sb->sb_data + sb->sb_datalen) - from;
+        if (off > len) off = len;
+        memcpy(to,from,off);
+        len -= off;
+        if (len)
+            memcpy(to+off,sb->sb_data,len);
+    }
+}
+
Index: trunk/src/VBox/Devices/Network/slirp/sbuf.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/sbuf.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/sbuf.h	(revision 14964)
@@ -12,12 +12,13 @@
 #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
 
-struct sbuf {
-        u_int   sb_cc;          /* actual chars in buffer */
-        u_int   sb_datalen;     /* Length of data  */
-        char    *sb_wptr;       /* write pointer. points to where the next
-                                 * bytes should be written in the sbuf */
-        char    *sb_rptr;       /* read pointer. points to where the next
-                                 * byte should be read from the sbuf */
-        char    *sb_data;       /* Actual data */
+struct sbuf
+{
+    u_int   sb_cc;          /* actual chars in buffer */
+    u_int   sb_datalen;     /* Length of data  */
+    char    *sb_wptr;       /* write pointer. points to where the next
+                             * bytes should be written in the sbuf */
+    char    *sb_rptr;       /* read pointer. points to where the next
+                             * byte should be read from the sbuf */
+    char    *sb_data;       /* Actual data */
 };
 
Index: trunk/src/VBox/Devices/Network/slirp/slirp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/slirp.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/slirp.c	(revision 14964)
@@ -1055,5 +1055,5 @@
             return 2;
         if (do_slowtimo)
-            return 500;
+            return 500; /* see PR_SLOWHZ */
     }
     return 0;
Index: trunk/src/VBox/Devices/Network/slirp/slirp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/slirp.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/slirp.h	(revision 14964)
@@ -260,22 +260,4 @@
 void if_start _P((PNATState));
 
-#ifdef BAD_SPRINTF
-# define vsprintf vsprintf_len
-# define sprintf sprintf_len
- extern int vsprintf_len _P((char *, const char *, va_list));
- extern int sprintf_len _P((char *, const char *, ...));
-#endif
-
-#ifdef DECLARE_SPRINTF
-# ifndef BAD_SPRINTF
- extern int vsprintf _P((char *, const char *, va_list));
-# endif
- extern int vfprintf _P((FILE *, const char *, va_list));
-#endif
-
-#ifndef HAVE_STRERROR
- extern char *strerror _P((int error));
-#endif
-
 #ifndef HAVE_INDEX
  char *index _P((const char *, int));
Index: trunk/src/VBox/Devices/Network/slirp/slirp_config.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/slirp_config.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/slirp_config.h	(revision 14964)
@@ -77,10 +77,4 @@
 #endif
 
-/* Define if you have strerror */
-#define HAVE_STRERROR
-
-/* Define if you have strdup() */
-#define HAVE_STRDUP
-
 /* Define according to how time.h should be included */
 #define TIME_WITH_SYS_TIME 0
@@ -92,7 +86,4 @@
 /* Define if the machine is big endian */
 /*#undef WORDS_BIGENDIAN */
-
-/* Define if your sprintf returns char * instead of int */
-#undef BAD_SPRINTF
 
 /* Define if you have readv */
@@ -104,7 +95,4 @@
 # define DECLARE_IOVEC
 #endif
-
-/* Define if a declaration of sprintf/fprintf is needed */
-#undef DECLARE_SPRINTF
 
 /* Define if you have a POSIX.1 sys/wait.h */
Index: trunk/src/VBox/Devices/Network/slirp/socket.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 14964)
@@ -17,30 +17,23 @@
 so_init()
 {
-        /* Nothing yet */
 }
 
 
 struct socket *
-solookup(head, laddr, lport, faddr, fport)
-        struct socket *head;
-        struct in_addr laddr;
-        u_int lport;
-        struct in_addr faddr;
-        u_int fport;
-{
-        struct socket *so;
-
-        for (so = head->so_next; so != head; so = so->so_next) {
-                if (so->so_lport == lport &&
-                    so->so_laddr.s_addr == laddr.s_addr &&
-                    so->so_faddr.s_addr == faddr.s_addr &&
-                    so->so_fport == fport)
-                   break;
-        }
-
-        if (so == head)
-           return (struct socket *)NULL;
-        return so;
-
+solookup(struct socket *head, struct in_addr laddr,
+         u_int lport, struct in_addr faddr, u_int fport)
+{
+    struct socket *so;
+
+    for (so = head->so_next; so != head; so = so->so_next)
+    {
+        if (   so->so_lport        == lport
+            && so->so_laddr.s_addr == laddr.s_addr
+            && so->so_faddr.s_addr == faddr.s_addr
+            && so->so_fport        == fport)
+            return so;
+    }
+
+    return (struct socket *)NULL;
 }
 
@@ -53,13 +46,14 @@
 socreate()
 {
-  struct socket *so;
-
-  so = (struct socket *)malloc(sizeof(struct socket));
-  if(so) {
-    memset(so, 0, sizeof(struct socket));
-    so->so_state = SS_NOFDREF;
-    so->s = -1;
-  }
-  return(so);
+    struct socket *so;
+
+    so = (struct socket *)malloc(sizeof(struct socket));
+    if(so)
+    {
+        memset(so, 0, sizeof(struct socket));
+        so->so_state = SS_NOFDREF;
+        so->s = -1;
+    }
+    return so;
 }
 
@@ -70,20 +64,15 @@
 sofree(PNATState pData, struct socket *so)
 {
-  if (so->so_emu==EMU_RSH && so->extra) {
-        sofree(pData, so->extra);
-        so->extra=NULL;
-  }
-  if (so == tcp_last_so)
-    tcp_last_so = &tcb;
-  else if (so == udp_last_so)
-    udp_last_so = &udb;
-
-  m_free(pData, so->so_m);
-
-
-  if(so->so_next && so->so_prev)
-    remque(pData, so);  /* crashes if so is not in a queue */
-
-  free(so);
+    if (so == tcp_last_so)
+        tcp_last_so = &tcb;
+    else if (so == udp_last_so)
+        udp_last_so = &udb;
+
+    m_free(pData, so->so_m);
+
+    if(so->so_next && so->so_prev)
+        remque(pData, so);  /* crashes if so is not in a queue */
+
+    free(so);
 }
 
@@ -96,116 +85,131 @@
 soread(PNATState pData, struct socket *so)
 {
-        int n, nn, lss, total;
-        struct sbuf *sb = &so->so_snd;
-        int len = sb->sb_datalen - sb->sb_cc;
-        struct iovec iov[2];
-        int mss = so->so_tcpcb->t_maxseg;
-
-        DEBUG_CALL("soread");
-        DEBUG_ARG("so = %lx", (long )so);
-
+    int n, nn, lss, total;
+    struct sbuf *sb = &so->so_snd;
+    int len = sb->sb_datalen - sb->sb_cc;
+    struct iovec iov[2];
+    int mss = so->so_tcpcb->t_maxseg;
+
+    DEBUG_CALL("soread");
+    DEBUG_ARG("so = %lx", (long )so);
+
+    /*
+     * No need to check if there's enough room to read.
+     * soread wouldn't have been called if there weren't
+     */
+
+    len = sb->sb_datalen - sb->sb_cc;
+
+    iov[0].iov_base = sb->sb_wptr;
+    iov[1].iov_base = 0;
+    iov[1].iov_len  = 0;
+    if (sb->sb_wptr < sb->sb_rptr)
+    {
+        iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
+        /* Should never succeed, but... */
+        if (iov[0].iov_len > len)
+            iov[0].iov_len = len;
+        if (iov[0].iov_len > mss)
+            iov[0].iov_len -= iov[0].iov_len%mss;
+        n = 1;
+    }
+    else
+    {
+        iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr;
+        /* Should never succeed, but... */
+        if (iov[0].iov_len > len) iov[0].iov_len = len;
+        len -= iov[0].iov_len;
+        if (len)
+        {
+            iov[1].iov_base = sb->sb_data;
+            iov[1].iov_len = sb->sb_rptr - sb->sb_data;
+            if(iov[1].iov_len > len)
+                iov[1].iov_len = len;
+            total = iov[0].iov_len + iov[1].iov_len;
+            if (total > mss)
+            {
+                lss = total % mss;
+                if (iov[1].iov_len > lss)
+                {
+                    iov[1].iov_len -= lss;
+                    n = 2;
+                }
+                else
+                {
+                    lss -= iov[1].iov_len;
+                    iov[0].iov_len -= lss;
+                    n = 1;
+                }
+            }
+            else
+                n = 2;
+        }
+        else
+        {
+            if (iov[0].iov_len > mss)
+                iov[0].iov_len -= iov[0].iov_len%mss;
+            n = 1;
+        }
+    }
+
+#ifdef HAVE_READV
+    nn = readv(so->s, (struct iovec *)iov, n);
+    DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
+#else
+    nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
+#endif
+    if (nn <= 0)
+    {
+#if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
         /*
-         * No need to check if there's enough room to read.
-         * soread wouldn't have been called if there weren't
+         * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that
+         * _could_ mean that the connection is closed. But we will receive an
+         * FD_CLOSE event later if the connection was _really_ closed. With
+         * www.youtube.com I see this very often. Closing the socket too early
+         * would be dangerous.
          */
-
-        len = sb->sb_datalen - sb->sb_cc;
-
-        iov[0].iov_base = sb->sb_wptr;
-        iov[1].iov_base = 0;
-        iov[1].iov_len  = 0;
-        if (sb->sb_wptr < sb->sb_rptr) {
-                iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
-                /* Should never succeed, but... */
-                if (iov[0].iov_len > len)
-                   iov[0].iov_len = len;
-                if (iov[0].iov_len > mss)
-                   iov[0].iov_len -= iov[0].iov_len%mss;
-                n = 1;
-        } else {
-                iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr;
-                /* Should never succeed, but... */
-                if (iov[0].iov_len > len) iov[0].iov_len = len;
-                len -= iov[0].iov_len;
-                if (len) {
-                        iov[1].iov_base = sb->sb_data;
-                        iov[1].iov_len = sb->sb_rptr - sb->sb_data;
-                        if(iov[1].iov_len > len)
-                           iov[1].iov_len = len;
-                        total = iov[0].iov_len + iov[1].iov_len;
-                        if (total > mss) {
-                                lss = total%mss;
-                                if (iov[1].iov_len > lss) {
-                                        iov[1].iov_len -= lss;
-                                        n = 2;
-                                } else {
-                                        lss -= iov[1].iov_len;
-                                        iov[0].iov_len -= lss;
-                                        n = 1;
-                                }
-                        } else
-                                n = 2;
-                } else {
-                        if (iov[0].iov_len > mss)
-                           iov[0].iov_len -= iov[0].iov_len%mss;
-                        n = 1;
-                }
-        }
-
-#ifdef HAVE_READV
-        nn = readv(so->s, (struct iovec *)iov, n);
-        DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#else
-        nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
-#endif
-        if (nn <= 0) {
-#if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-            /*
-             * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that
-             * _could_ mean that the connection is closed. But we will receive an
-             * FD_CLOSE event later if the connection was _really_ closed. With
-             * www.youtube.com I see this very often. Closing the socket too early
-             * would be dangerous.
-             */
-                if (nn == 0)
-                        return 0;
-#endif
-                if (nn < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
-                        return 0;
-                else {
-                        /* nn == 0 means peer has performed an orderly shutdown */
-                        DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
-                        sofcantrcvmore(so);
-                        tcp_sockclosed(pData, sototcpcb(so));
-                        return -1;
-                }
-        }
+        if (nn == 0)
+            return 0;
+#endif
+        if (nn < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
+            return 0;
+        else
+        {
+            /* nn == 0 means peer has performed an orderly shutdown */
+            DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n",
+                        nn, errno,strerror(errno)));
+            sofcantrcvmore(so);
+            tcp_sockclosed(pData, sototcpcb(so));
+            return -1;
+        }
+    }
 
 #ifndef HAVE_READV
-        /*
-         * If there was no error, try and read the second time round
-         * We read again if n = 2 (ie, there's another part of the buffer)
-         * and we read as much as we could in the first read
-         * We don't test for <= 0 this time, because there legitimately
-         * might not be any more data (since the socket is non-blocking),
-         * a close will be detected on next iteration.
-         * A return of -1 wont (shouldn't) happen, since it didn't happen above
-         */
-        if (n == 2 && nn == iov[0].iov_len) {
-            int ret;
-            ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
-            if (ret > 0)
-                nn += ret;
-        }
-
-        DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#endif
-
-        /* Update fields */
-        sb->sb_cc += nn;
-        sb->sb_wptr += nn;
-        if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen))
-                sb->sb_wptr -= sb->sb_datalen;
-        return nn;
+    /*
+     * If there was no error, try and read the second time round
+     * We read again if n = 2 (ie, there's another part of the buffer)
+     * and we read as much as we could in the first read
+     * We don't test for <= 0 this time, because there legitimately
+     * might not be any more data (since the socket is non-blocking),
+     * a close will be detected on next iteration.
+     * A return of -1 wont (shouldn't) happen, since it didn't happen above
+     */
+    if (n == 2 && nn == iov[0].iov_len)
+    {
+        int ret;
+        ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
+        if (ret > 0)
+            nn += ret;
+    }
+
+    DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
+#endif
+
+    /* Update fields */
+    sb->sb_cc += nn;
+    sb->sb_wptr += nn;
+    if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen))
+        sb->sb_wptr -= sb->sb_datalen;
+    return nn;
 }
 
@@ -220,22 +224,22 @@
 sorecvoob(PNATState pData, struct socket *so)
 {
-        struct tcpcb *tp = sototcpcb(so);
-
-        DEBUG_CALL("sorecvoob");
-        DEBUG_ARG("so = %lx", (long)so);
-
-        /*
-         * We take a guess at how much urgent data has arrived.
-         * In most situations, when urgent data arrives, the next
-         * read() should get all the urgent data.  This guess will
-         * be wrong however if more data arrives just after the
-         * urgent data, or the read() doesn't return all the
-         * urgent data.
-         */
-        soread(pData, so);
-        tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
-        tp->t_force = 1;
-        tcp_output(pData, tp);
-        tp->t_force = 0;
+    struct tcpcb *tp = sototcpcb(so);
+
+    DEBUG_CALL("sorecvoob");
+    DEBUG_ARG("so = %lx", (long)so);
+
+    /*
+     * We take a guess at how much urgent data has arrived.
+     * In most situations, when urgent data arrives, the next
+     * read() should get all the urgent data.  This guess will
+     * be wrong however if more data arrives just after the
+     * urgent data, or the read() doesn't return all the
+     * urgent data.
+     */
+    soread(pData, so);
+    tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
+    tp->t_force = 1;
+    tcp_output(pData, tp);
+    tp->t_force = 0;
 }
 
@@ -245,56 +249,62 @@
  */
 int
-sosendoob(so)
-        struct socket *so;
-{
-        struct sbuf *sb = &so->so_rcv;
-        char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
-
-        int n, len;
-
-        DEBUG_CALL("sosendoob");
-        DEBUG_ARG("so = %lx", (long)so);
-        DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc);
-
-        if (so->so_urgc > 2048)
-           so->so_urgc = 2048; /* XXXX */
-
-        if (sb->sb_rptr < sb->sb_wptr) {
-                /* We can send it directly */
-                n = send(so->s, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
-                so->so_urgc -= n;
-
-                DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
-        } else {
-                /*
-                 * Since there's no sendv or sendtov like writev,
-                 * we must copy all data to a linear buffer then
-                 * send it all
-                 */
-                len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
-                if (len > so->so_urgc) len = so->so_urgc;
-                memcpy(buff, sb->sb_rptr, len);
-                so->so_urgc -= len;
-                if (so->so_urgc) {
-                        n = sb->sb_wptr - sb->sb_data;
-                        if (n > so->so_urgc) n = so->so_urgc;
-                        memcpy((buff + len), sb->sb_data, n);
-                        so->so_urgc -= n;
-                        len += n;
-                }
-                n = send(so->s, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
+sosendoob(struct socket *so)
+{
+    struct sbuf *sb = &so->so_rcv;
+    char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
+
+    int n, len;
+
+    DEBUG_CALL("sosendoob");
+    DEBUG_ARG("so = %lx", (long)so);
+    DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc);
+
+    if (so->so_urgc > sizeof(buff))
+        so->so_urgc = sizeof(buff); /* XXX */
+
+    if (sb->sb_rptr < sb->sb_wptr)
+    {
+        /* We can send it directly */
+        n = send(so->s, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
+        so->so_urgc -= n;
+
+        DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n",
+                    n, so->so_urgc));
+    }
+    else
+    {
+        /*
+         * Since there's no sendv or sendtov like writev,
+         * we must copy all data to a linear buffer then
+         * send it all
+         */
+        len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
+        if (len > so->so_urgc) len = so->so_urgc;
+        memcpy(buff, sb->sb_rptr, len);
+        so->so_urgc -= len;
+        if (so->so_urgc)
+        {
+            n = sb->sb_wptr - sb->sb_data;
+            if (n > so->so_urgc)
+                n = so->so_urgc;
+            memcpy(buff + len, sb->sb_data, n);
+            so->so_urgc -= n;
+            len += n;
+        }
+        n = send(so->s, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
 #ifdef DEBUG
-                if (n != len)
-                   DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
-#endif
-                DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
-        }
-
-        sb->sb_cc -= n;
-        sb->sb_rptr += n;
-        if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))
-                sb->sb_rptr -= sb->sb_datalen;
-
-        return n;
+        if (n != len)
+            DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
+#endif
+        DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n",
+                    n, so->so_urgc));
+    }
+
+    sb->sb_cc -= n;
+    sb->sb_rptr += n;
+    if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))
+        sb->sb_rptr -= sb->sb_datalen;
+
+    return n;
 }
 
@@ -306,90 +316,97 @@
 sowrite(PNATState pData, struct socket *so)
 {
-        int  n,nn;
-        struct sbuf *sb = &so->so_rcv;
-        int len = sb->sb_cc;
-        struct iovec iov[2];
-
-        DEBUG_CALL("sowrite");
-        DEBUG_ARG("so = %lx", (long)so);
-
-        if (so->so_urgc) {
-                sosendoob(so);
-                if (sb->sb_cc == 0)
-                        return 0;
-        }
-
-        /*
-         * No need to check if there's something to write,
-         * sowrite wouldn't have been called otherwise
-         */
-
-        len = sb->sb_cc;
-
-        iov[0].iov_base = sb->sb_rptr;
-        iov[1].iov_base = 0;
-        iov[1].iov_len  = 0;
-        if (sb->sb_rptr < sb->sb_wptr) {
-                iov[0].iov_len = sb->sb_wptr - sb->sb_rptr;
-                /* Should never succeed, but... */
-                if (iov[0].iov_len > len) iov[0].iov_len = len;
-                n = 1;
-        } else {
-                iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
-                if (iov[0].iov_len > len) iov[0].iov_len = len;
-                len -= iov[0].iov_len;
-                if (len) {
-                        iov[1].iov_base = sb->sb_data;
-                        iov[1].iov_len = sb->sb_wptr - sb->sb_data;
-                        if (iov[1].iov_len > len) iov[1].iov_len = len;
-                        n = 2;
-                } else
-                        n = 1;
-        }
-        /* Check if there's urgent data to send, and if so, send it */
-
+    int  n,nn;
+    struct sbuf *sb = &so->so_rcv;
+    int len = sb->sb_cc;
+    struct iovec iov[2];
+
+    DEBUG_CALL("sowrite");
+    DEBUG_ARG("so = %lx", (long)so);
+
+    if (so->so_urgc)
+    {
+        sosendoob(so);
+        if (sb->sb_cc == 0)
+            return 0;
+    }
+
+    /*
+     * No need to check if there's something to write,
+     * sowrite wouldn't have been called otherwise
+     */
+
+    len = sb->sb_cc;
+
+    iov[0].iov_base = sb->sb_rptr;
+    iov[1].iov_base = 0;
+    iov[1].iov_len  = 0;
+    if (sb->sb_rptr < sb->sb_wptr)
+    {
+        iov[0].iov_len = sb->sb_wptr - sb->sb_rptr;
+        /* Should never succeed, but... */
+        if (iov[0].iov_len > len) iov[0].iov_len = len;
+        n = 1;
+    }
+    else
+    {
+        iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
+        if (iov[0].iov_len > len) iov[0].iov_len = len;
+        len -= iov[0].iov_len;
+        if (len)
+        {
+            iov[1].iov_base = sb->sb_data;
+            iov[1].iov_len = sb->sb_wptr - sb->sb_data;
+            if (iov[1].iov_len > len)
+                iov[1].iov_len = len;
+            n = 2;
+        }
+        else
+            n = 1;
+    }
+    /* Check if there's urgent data to send, and if so, send it */
 #ifdef HAVE_READV
-        nn = writev(so->s, (const struct iovec *)iov, n);
-
-        DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
+    nn = writev(so->s, (const struct iovec *)iov, n);
+    DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
 #else
-        nn = send(so->s, iov[0].iov_base, iov[0].iov_len,0);
-#endif
-        /* This should never happen, but people tell me it does *shrug* */
-        if (nn < 0 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
-                return 0;
-
-        if (nn < 0 || (nn == 0 && iov[0].iov_len > 0)) {
-                DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
-                        so->so_state, errno));
-                sofcantsendmore(so);
-                tcp_sockclosed(pData, sototcpcb(so));
-                return -1;
-        }
+    nn = send(so->s, iov[0].iov_base, iov[0].iov_len, 0);
+#endif
+    /* This should never happen, but people tell me it does *shrug* */
+    if (nn < 0 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
+        return 0;
+
+    if (nn < 0 || (nn == 0 && iov[0].iov_len > 0))
+    {
+        DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
+                   so->so_state, errno));
+        sofcantsendmore(so);
+        tcp_sockclosed(pData, sototcpcb(so));
+        return -1;
+    }
 
 #ifndef HAVE_READV
-        if (n == 2 && nn == iov[0].iov_len) {
-            int ret;
-            ret = send(so->s, iov[1].iov_base, iov[1].iov_len,0);
-            if (ret > 0)
-                nn += ret;
-        }
-        DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
-#endif
-
-        /* Update sbuf */
-        sb->sb_cc -= nn;
-        sb->sb_rptr += nn;
-        if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))
-                sb->sb_rptr -= sb->sb_datalen;
-
-        /*
-         * If in DRAIN mode, and there's no more data, set
-         * it CANTSENDMORE
-         */
-        if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0)
-                sofcantsendmore(so);
-
-        return nn;
+    if (n == 2 && nn == iov[0].iov_len)
+    {
+        int ret;
+        ret = send(so->s, iov[1].iov_base, iov[1].iov_len,0);
+        if (ret > 0)
+            nn += ret;
+    }
+    DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
+#endif
+
+    /* Update sbuf */
+    sb->sb_cc -= nn;
+    sb->sb_rptr += nn;
+    if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))
+        sb->sb_rptr -= sb->sb_datalen;
+
+    /*
+     * If in DRAIN mode, and there's no more data, set
+     * it CANTSENDMORE
+     */
+    if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0)
+        sofcantsendmore(so);
+
+    return nn;
 }
 
@@ -400,28 +417,35 @@
 sorecvfrom(PNATState pData, struct socket *so)
 {
-        struct sockaddr_in addr;
-        socklen_t addrlen = sizeof(struct sockaddr_in);
-
-        DEBUG_CALL("sorecvfrom");
-        DEBUG_ARG("so = %lx", (long)so);
-
-        if (so->so_type == IPPROTO_ICMP) {   /* This is a "ping" reply */
-          char buff[256];
-          int len;
-
-          len = recvfrom(so->s, buff, 256, 0,
-                         (struct sockaddr *)&addr, &addrlen);
-          /* XXX Check if reply is "correct"? */
-
-          if(len == -1 || len == 0) {
-            u_char code=ICMP_UNREACH_PORT;
-
-            if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
-            else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
+    struct sockaddr_in addr;
+    socklen_t addrlen = sizeof(struct sockaddr_in);
+
+    DEBUG_CALL("sorecvfrom");
+    DEBUG_ARG("so = %lx", (long)so);
+
+    if (so->so_type == IPPROTO_ICMP)
+    {
+        /* This is a "ping" reply */
+        char buff[256];
+        int len;
+
+        len = recvfrom(so->s, buff, sizeof(buff), 0,
+                       (struct sockaddr *)&addr, &addrlen);
+        /* XXX Check if reply is "correct"? */
+
+        if(len == -1 || len == 0)
+        {
+            u_char code = ICMP_UNREACH_PORT;
+
+            if (errno == EHOSTUNREACH)
+                code=ICMP_UNREACH_HOST;
+            else if(errno == ENETUNREACH)
+                code=ICMP_UNREACH_NET;
 
             DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
                         errno,strerror(errno)));
             icmp_error(pData, so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
-          } else {
+        }
+        else
+        {
 #ifdef VBOX_WITH_SLIRP_ICMP
             struct ip *ip;
@@ -439,61 +463,75 @@
             icmp_reflect(pData, so->so_m);
             so->so_m = 0; /* Don't m_free() it again! */
-          }
-          /* No need for this socket anymore, udp_detach it */
-          udp_detach(pData, so);
-        } else {                                /* A "normal" UDP packet */
-          struct mbuf *m;
-          int len, n;
-
-          if (!(m = m_get(pData))) return;
-          m->m_data += if_maxlinkhdr;
-
-          /*
-           * XXX Shouldn't FIONREAD packets destined for port 53,
-           * but I don't know the max packet size for DNS lookups
-           */
-          len = M_FREEROOM(m);
-          /* if (so->so_fport != htons(53)) { */
-          ioctlsocket(so->s, FIONREAD, &n);
-
-          if (n > len) {
-            n = (m->m_data - m->m_dat) + m->m_len + n + 1;
-            m_inc(m, n);
-            len = M_FREEROOM(m);
-          }
-          /* } */
-
-          m->m_len = recvfrom(so->s, m->m_data, len, 0,
-                              (struct sockaddr *)&addr, &addrlen);
-          DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
-                      m->m_len, errno,strerror(errno)));
-          if(m->m_len<0) {
+        }
+        /* No need for this socket anymore, udp_detach it */
+        udp_detach(pData, so);
+    }
+    else
+    { 
+        /* A "normal" UDP packet */
+        struct mbuf *m;
+        int len, n;
+
+        if (!(m = m_get(pData)))
+            return;
+        m->m_data += if_maxlinkhdr;
+
+        /*
+         * XXX Shouldn't FIONREAD packets destined for port 53,
+         * but I don't know the max packet size for DNS lookups
+         */
+        len = M_FREEROOM(m);
+        /* if (so->so_fport != htons(53)) */
+        {
+            ioctlsocket(so->s, FIONREAD, &n);
+
+            if (n > len)
+            {
+                n = (m->m_data - m->m_dat) + m->m_len + n + 1;
+                m_inc(m, n);
+                len = M_FREEROOM(m);
+            }
+        }
+
+        m->m_len = recvfrom(so->s, m->m_data, len, 0,
+                            (struct sockaddr *)&addr, &addrlen);
+        DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
+                    m->m_len, errno,strerror(errno)));
+        if(m->m_len < 0)
+        {
             u_char code=ICMP_UNREACH_PORT;
 
-            if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
-            else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
+            if (errno == EHOSTUNREACH)
+                code=ICMP_UNREACH_HOST;
+            else if(errno == ENETUNREACH)
+                code=ICMP_UNREACH_NET;
 
             DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
             icmp_error(pData, so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
             m_free(pData, m);
-          } else {
-          /*
-           * Hack: domain name lookup will be used the most for UDP,
-           * and since they'll only be used once there's no need
-           * for the 4 minute (or whatever) timeout... So we time them
-           * out much quicker (10 seconds  for now...)
-           */
-            if (so->so_expire) {
-              if (so->so_fport == htons(53))
-                so->so_expire = curtime + SO_EXPIREFAST;
-              else
-                so->so_expire = curtime + SO_EXPIRE;
+        }
+        else
+        {
+            /*
+             * Hack: domain name lookup will be used the most for UDP,
+             * and since they'll only be used once there's no need
+             * for the 4 minute (or whatever) timeout... So we time them
+             * out much quicker (10 seconds  for now...)
+             */
+            if (so->so_expire)
+            {
+                if (so->so_fport == htons(53))
+                    so->so_expire = curtime + SO_EXPIREFAST;
+                else
+                    so->so_expire = curtime + SO_EXPIRE;
             }
 
-            /*          if (m->m_len == len) {
-             *                  m_inc(m, MINCSIZE);
-             *                  m->m_len = 0;
-             *          }
-             */
+#if 0
+            if (m->m_len == len)
+            {
+                m_inc(m, MINCSIZE);
+                m->m_len = 0;
+            }
+#endif            
 
             /*
@@ -502,6 +540,6 @@
              */
             udp_output(pData, so, m, &addr);
-          } /* rx error */
-        } /* if ping packet */
+        } /* rx error */
+    } /* if ping packet */
 }
 
@@ -512,71 +550,73 @@
 sosendto(PNATState pData, struct socket *so, struct mbuf *m)
 {
-        int ret;
-        struct sockaddr_in addr;
+    int ret;
+    struct sockaddr_in addr;
 #if 0
-        struct sockaddr_in host_addr;
-#endif
-
-        DEBUG_CALL("sosendto");
-        DEBUG_ARG("so = %lx", (long)so);
-        DEBUG_ARG("m = %lx", (long)m);
-
-        addr.sin_family = AF_INET;
-        if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) {
-          /* It's an alias */
-          uint32_t last_byte = ntohl(so->so_faddr.s_addr) & ~pData->netmask;
-          switch(last_byte) {
+    struct sockaddr_in host_addr;
+#endif
+
+    DEBUG_CALL("sosendto");
+    DEBUG_ARG("so = %lx", (long)so);
+    DEBUG_ARG("m = %lx", (long)m);
+
+    addr.sin_family = AF_INET;
+    if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr)
+    {
+        /* It's an alias */
+        uint32_t last_byte = ntohl(so->so_faddr.s_addr) & ~pData->netmask;
+        switch(last_byte)
+        {
 #if 0
-          /* handle this case at 'default:' */
-          case CTL_BROADCAST:
-            addr.sin_addr.s_addr = INADDR_BROADCAST;
-# if 0
-            /* Send the packet to host to fully emulate broadcast */
-            /** @todo r=klaus: on Linux host this causes the host to receive
-             * the packet twice for some reason. And I cannot find any place
-             * in the man pages which states that sending a broadcast does not
-             * reach the host itself. */
-            host_addr.sin_family = AF_INET;
-            host_addr.sin_port = so->so_fport;
-            host_addr.sin_addr = our_addr;
-            sendto(so->s, m->m_data, m->m_len, 0,
-                  (struct sockaddr *)&host_addr, sizeof (struct sockaddr));
-# endif
-            break;
-#endif
-          case CTL_DNS:
-            if (!get_dns_addr(pData, &dns_addr))
-                addr.sin_addr = dns_addr;
-            else
-                addr.sin_addr = loopback_addr;
-            break;
-          case CTL_ALIAS:
-          default:
-            if (last_byte == ~pData->netmask)
-              addr.sin_addr.s_addr = INADDR_BROADCAST;
-            else
-              addr.sin_addr = loopback_addr;
-            break;
-          }
-        } else
-          addr.sin_addr = so->so_faddr;
-        addr.sin_port = so->so_fport;
-
-        DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
-
-        /* Don't care what port we get */
-        ret = sendto(so->s, m->m_data, m->m_len, 0,
-                     (struct sockaddr *)&addr, sizeof (struct sockaddr));
-        if (ret < 0)
-                return -1;
-
-        /*
-         * Kill the socket if there's no reply in 4 minutes,
-         * but only if it's an expirable socket
-         */
-        if (so->so_expire)
-                so->so_expire = curtime + SO_EXPIRE;
-        so->so_state = SS_ISFCONNECTED; /* So that it gets select()ed */
-        return 0;
+            /* handle this case at 'default:' */
+            case CTL_BROADCAST:
+                addr.sin_addr.s_addr = INADDR_BROADCAST;
+                /* Send the packet to host to fully emulate broadcast */
+                /** @todo r=klaus: on Linux host this causes the host to receive
+                 * the packet twice for some reason. And I cannot find any place
+                 * in the man pages which states that sending a broadcast does not
+                 * reach the host itself. */
+                host_addr.sin_family = AF_INET;
+                host_addr.sin_port = so->so_fport;
+                host_addr.sin_addr = our_addr;
+                sendto(so->s, m->m_data, m->m_len, 0,
+                        (struct sockaddr *)&host_addr, sizeof (struct sockaddr));
+                break;
+#endif
+            case CTL_DNS:
+                if (!get_dns_addr(pData, &dns_addr))
+                    addr.sin_addr = dns_addr;
+                else
+                    addr.sin_addr = loopback_addr;
+                break;
+            case CTL_ALIAS:
+            default:
+                if (last_byte == ~pData->netmask)
+                    addr.sin_addr.s_addr = INADDR_BROADCAST;
+                else
+                    addr.sin_addr = loopback_addr;
+                break;
+        }
+    }
+    else
+        addr.sin_addr = so->so_faddr;
+    addr.sin_port = so->so_fport;
+
+    DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n",
+                ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
+
+    /* Don't care what port we get */
+    ret = sendto(so->s, m->m_data, m->m_len, 0,
+                 (struct sockaddr *)&addr, sizeof (struct sockaddr));
+    if (ret < 0)
+        return -1;
+
+    /*
+     * Kill the socket if there's no reply in 4 minutes,
+     * but only if it's an expirable socket
+     */
+    if (so->so_expire)
+        so->so_expire = curtime + SO_EXPIRE;
+    so->so_state = SS_ISFCONNECTED; /* So that it gets select()ed */
+    return 0;
 }
 
@@ -587,71 +627,74 @@
 solisten(PNATState pData, u_int port, u_int32_t laddr, u_int lport, int flags)
 {
-        struct sockaddr_in addr;
-        struct socket *so;
-        socklen_t addrlen = sizeof(addr);
-        int s, opt = 1;
-
-        DEBUG_CALL("solisten");
-        DEBUG_ARG("port = %d", port);
-        DEBUG_ARG("laddr = %x", laddr);
-        DEBUG_ARG("lport = %d", lport);
-        DEBUG_ARG("flags = %x", flags);
-
-        if ((so = socreate()) == NULL) {
-          /* free(so);      Not sofree() ??? free(NULL) == NOP */
-          return NULL;
-        }
-
-        /* Don't tcp_attach... we don't need so_snd nor so_rcv */
-        if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL) {
-                free(so);
-                return NULL;
-        }
-        insque(pData, so,&tcb);
-
-        /*
-         * SS_FACCEPTONCE sockets must time out.
-         */
-        if (flags & SS_FACCEPTONCE)
-           so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
-
-        so->so_state = (SS_FACCEPTCONN|flags);
-        so->so_lport = lport; /* Kept in network format */
-        so->so_laddr.s_addr = laddr; /* Ditto */
-
-        addr.sin_family = AF_INET;
-        addr.sin_addr.s_addr = INADDR_ANY;
-        addr.sin_port = port;
-
-        if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
-            (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
-            (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
-            (listen(s,1) < 0)) {
+    struct sockaddr_in addr;
+    struct socket *so;
+    socklen_t addrlen = sizeof(addr);
+    int s, opt = 1;
+
+    DEBUG_CALL("solisten");
+    DEBUG_ARG("port = %d", port);
+    DEBUG_ARG("laddr = %x", laddr);
+    DEBUG_ARG("lport = %d", lport);
+    DEBUG_ARG("flags = %x", flags);
+
+    if ((so = socreate()) == NULL)
+    {
+        /* free(so);      Not sofree() ??? free(NULL) == NOP */
+        return NULL;
+    }
+
+    /* Don't tcp_attach... we don't need so_snd nor so_rcv */
+    if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL)
+    {
+        free(so);
+        return NULL;
+    }
+    insque(pData, so,&tcb);
+
+    /*
+     * SS_FACCEPTONCE sockets must time out.
+     */
+    if (flags & SS_FACCEPTONCE)
+        so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
+
+    so->so_state = (SS_FACCEPTCONN|flags);
+    so->so_lport = lport; /* Kept in network format */
+    so->so_laddr.s_addr = laddr; /* Ditto */
+
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = INADDR_ANY;
+    addr.sin_port = port;
+
+    if (   ((s = socket(AF_INET,SOCK_STREAM,0)) < 0)
+        || (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0)
+        || (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0)
+        || (listen(s,1) < 0))
+    {
 #ifdef RT_OS_WINDOWS
-                int tmperrno = WSAGetLastError(); /* Don't clobber the real reason we failed */
-                closesocket(s);
-                sofree(pData, so);
-                /* Restore the real errno */
-                WSASetLastError(tmperrno);
+        int tmperrno = WSAGetLastError(); /* Don't clobber the real reason we failed */
+        closesocket(s);
+        sofree(pData, so);
+        /* Restore the real errno */
+        WSASetLastError(tmperrno);
 #else
-                int tmperrno = errno; /* Don't clobber the real reason we failed */
-                close(s);
-                sofree(pData, so);
-                /* Restore the real errno */
-                errno = tmperrno;
-#endif
-                return NULL;
-        }
-        setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
-
-        getsockname(s,(struct sockaddr *)&addr,&addrlen);
-        so->so_fport = addr.sin_port;
-        if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
-           so->so_faddr = alias_addr;
-        else
-           so->so_faddr = addr.sin_addr;
-
-        so->s = s;
-        return so;
+        int tmperrno = errno; /* Don't clobber the real reason we failed */
+        close(s);
+        sofree(pData, so);
+        /* Restore the real errno */
+        errno = tmperrno;
+#endif
+        return NULL;
+    }
+    setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
+
+    getsockname(s,(struct sockaddr *)&addr,&addrlen);
+    so->so_fport = addr.sin_port;
+    if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
+        so->so_faddr = alias_addr;
+    else
+        so->so_faddr = addr.sin_addr;
+
+    so->s = s;
+    return so;
 }
 
@@ -662,9 +705,10 @@
  */
 void
-sorwakeup(so)
-        struct socket *so;
-{
-/*      sowrite(so); */
-/*      FD_CLR(so->s,&writefds); */
+sorwakeup(struct socket *so)
+{
+#if 0
+    sowrite(so);
+    FD_CLR(so->s,&writefds);
+#endif
 }
 
@@ -675,8 +719,6 @@
  */
 void
-sowwakeup(so)
-        struct socket *so;
-{
-        /* Nothing, yet */
+sowwakeup(struct socket *so)
+{
 }
 
@@ -688,58 +730,57 @@
  */
 void
-soisfconnecting(so)
-        register struct socket *so;
-{
-        so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE|
-                          SS_FCANTSENDMORE|SS_FWDRAIN);
-        so->so_state |= SS_ISFCONNECTING; /* Clobber other states */
-}
-
-void
-soisfconnected(so)
-        register struct socket *so;
-{
-        so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF);
-        so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
-}
-
-void
-sofcantrcvmore(so)
-        struct  socket *so;
-{
-        if ((so->so_state & SS_NOFDREF) == 0) {
-                shutdown(so->s,0);
-        }
-        so->so_state &= ~(SS_ISFCONNECTING);
-        if (so->so_state & SS_FCANTSENDMORE)
-           so->so_state = SS_NOFDREF; /* Don't select it */ /* XXX close() here as well? */
-        else
-           so->so_state |= SS_FCANTRCVMORE;
-}
-
-void
-sofcantsendmore(so)
-        struct socket *so;
-{
-        if ((so->so_state & SS_NOFDREF) == 0) {
-            shutdown(so->s,1);           /* send FIN to fhost */
-        }
-        so->so_state &= ~(SS_ISFCONNECTING);
-        if (so->so_state & SS_FCANTRCVMORE)
-           so->so_state = SS_NOFDREF; /* as above */
-        else
-           so->so_state |= SS_FCANTSENDMORE;
-}
-
-void
-soisfdisconnected(so)
-        struct socket *so;
-{
-/*      so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
-/*      close(so->s); */
-/*      so->so_state = SS_ISFDISCONNECTED; */
-        /*
-         * XXX Do nothing ... ?
-         */
+soisfconnecting(struct socket *so)
+{
+    so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE|
+                      SS_FCANTSENDMORE|SS_FWDRAIN);
+    so->so_state |= SS_ISFCONNECTING; /* Clobber other states */
+}
+
+void
+soisfconnected(struct socket *so)
+{
+    so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF);
+    so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
+}
+
+void
+sofcantrcvmore(struct  socket *so)
+{
+    if ((so->so_state & SS_NOFDREF) == 0)
+    {
+        shutdown(so->s,0);
+    }
+    so->so_state &= ~(SS_ISFCONNECTING);
+    if (so->so_state & SS_FCANTSENDMORE)
+        so->so_state = SS_NOFDREF; /* Don't select it */ 
+                                   /* XXX close() here as well? */
+    else
+        so->so_state |= SS_FCANTRCVMORE;
+}
+
+void
+sofcantsendmore(struct socket *so)
+{
+    if ((so->so_state & SS_NOFDREF) == 0)
+        shutdown(so->s, 1);           /* send FIN to fhost */
+
+    so->so_state &= ~(SS_ISFCONNECTING);
+    if (so->so_state & SS_FCANTRCVMORE)
+        so->so_state = SS_NOFDREF; /* as above */
+    else
+        so->so_state |= SS_FCANTSENDMORE;
+}
+
+void
+soisfdisconnected(struct socket *so)
+{
+#if 0
+    so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED);
+    close(so->s);
+    so->so_state = SS_ISFDISCONNECTED;
+    /*
+     * XXX Do nothing ... ?
+     */
+#endif
 }
 
@@ -749,11 +790,9 @@
  */
 void
-sofwdrain(so)
-        struct socket *so;
-{
-        if (so->so_rcv.sb_cc)
-                so->so_state |= SS_FWDRAIN;
-        else
-                sofcantsendmore(so);
-}
-
+sofwdrain(struct socket *so)
+{
+    if (so->so_rcv.sb_cc)
+        so->so_state |= SS_FWDRAIN;
+    else
+        sofcantsendmore(so);
+}
Index: trunk/src/VBox/Devices/Network/slirp/socket.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/socket.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/socket.h	(revision 14964)
@@ -18,38 +18,39 @@
  */
 
-struct socket {
-  struct socket *so_next,*so_prev;      /* For a linked list of sockets */
+struct socket
+{
+    struct socket   *so_next;
+    struct socket   *so_prev;    /* For a linked list of sockets */
 
-  int s;                           /* The actual socket */
+    int s;                       /* The actual socket */
 
-                        /* XXX union these with not-yet-used sbuf params */
-  struct mbuf *so_m;               /* Pointer to the original SYN packet,
-                                    * for non-blocking connect()'s, and
-                                    * PING reply's */
-  struct tcpiphdr *so_ti;          /* Pointer to the original ti within
-                                    * so_mconn, for non-blocking connections */
-  int so_urgc;
-  struct in_addr so_faddr;         /* foreign host table entry */
-  struct in_addr so_laddr;         /* local host table entry */
-  u_int16_t so_fport;              /* foreign port */
-  u_int16_t so_lport;              /* local port */
+    /* XXX union these with not-yet-used sbuf params */
+    struct mbuf     *so_m;       /* Pointer to the original SYN packet,
+                                  * for non-blocking connect()'s, and
+                                  * PING reply's */
+    struct tcpiphdr *so_ti;      /* Pointer to the original ti within
+                                  * so_mconn, for non-blocking connections */
+    int             so_urgc;
+    struct in_addr  so_faddr;    /* foreign host table entry */
+    struct in_addr  so_laddr;    /* local host table entry */
+    u_int16_t       so_fport;    /* foreign port */
+    u_int16_t       so_lport;    /* local port */
 
-  u_int8_t      so_iptos;       /* Type of service */
-  u_int8_t      so_emu;         /* Is the socket emulated? */
+    u_int8_t        so_iptos;    /* Type of service */
+    u_int8_t        so_emu;      /* Is the socket emulated? */
 
-  u_char        so_type;                /* Type of socket, UDP or TCP */
-  int   so_state;               /* internal state flags SS_*, below */
+    u_char          so_type;     /* Type of socket, UDP or TCP */
+    int             so_state;    /* internal state flags SS_*, below */
 
-  struct        tcpcb *so_tcpcb;        /* pointer to TCP protocol control block */
-  u_int so_expire;              /* When the socket will expire */
+    struct tcpcb    *so_tcpcb;   /* pointer to TCP protocol control block */
+    u_int           so_expire;   /* When the socket will expire */
 
-  int   so_queued;              /* Number of packets queued from this socket */
-  int   so_nqueued;             /* Number of packets queued in a row
-                                 * Used to determine when to "downgrade" a session
-                                         * from fastq to batchq */
+    int             so_queued;   /* Number of packets queued from this socket */
+    int             so_nqueued;  /* Number of packets queued in a row
+                                  * Used to determine when to "downgrade" a session
+                                  * from fastq to batchq */
 
-  struct sbuf so_rcv;           /* Receive buffer */
-  struct sbuf so_snd;           /* Send buffer */
-  void * extra;                 /* Extra pointer */
+    struct sbuf     so_rcv;      /* Receive buffer */
+    struct sbuf     so_snd;      /* Send buffer */
 };
 
@@ -74,9 +75,9 @@
 extern struct socket tcb;
 
-
 #if defined(DECLARE_IOVEC) && !defined(HAVE_READV)
-struct iovec {
-        char *iov_base;
-        size_t iov_len;
+struct iovec
+{
+    char *iov_base;
+    size_t iov_len;
 };
 #endif
Index: trunk/src/VBox/Devices/Network/slirp/tcp_timer.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_timer.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_timer.c	(revision 14964)
@@ -44,19 +44,20 @@
 tcp_fasttimo(PNATState pData)
 {
-        register struct socket *so;
-        register struct tcpcb *tp;
-
-        DEBUG_CALL("tcp_fasttimo");
-
-        so = tcb.so_next;
-        if (so)
+    register struct socket *so;
+    register struct tcpcb *tp;
+
+    DEBUG_CALL("tcp_fasttimo");
+
+    so = tcb.so_next;
+    if (so)
         for (; so != &tcb; so = so->so_next)
-                if ((tp = (struct tcpcb *)so->so_tcpcb) &&
-                    (tp->t_flags & TF_DELACK)) {
-                        tp->t_flags &= ~TF_DELACK;
-                        tp->t_flags |= TF_ACKNOW;
-                        tcpstat.tcps_delack++;
-                        (void) tcp_output(pData, tp);
-                }
+            if (   (tp = (struct tcpcb *)so->so_tcpcb)
+                && (tp->t_flags & TF_DELACK))
+            {
+                tp->t_flags &= ~TF_DELACK;
+                tp->t_flags |= TF_ACKNOW;
+                tcpstat.tcps_delack++;
+                (void) tcp_output(pData, tp);
+            }
 }
 
@@ -69,40 +70,43 @@
 tcp_slowtimo(PNATState pData)
 {
-        register struct socket *ip, *ipnxt;
-        register struct tcpcb *tp;
-        register int i;
-
-        DEBUG_CALL("tcp_slowtimo");
-
-        /*
-         * Search through tcb's and update active timers.
-         */
-        ip = tcb.so_next;
-        if (ip == 0)
-           return;
-        for (; ip != &tcb; ip = ipnxt) {
-                ipnxt = ip->so_next;
-                tp = sototcpcb(ip);
-                if (tp == 0)
-                        continue;
-                for (i = 0; i < TCPT_NTIMERS; i++) {
-                        if (tp->t_timer[i] && --tp->t_timer[i] == 0) {
-                                tcp_timers(pData, tp,i);
-                                if (ipnxt->so_prev != ip)
-                                        goto tpgone;
-                        }
-                }
-                tp->t_idle++;
-                if (tp->t_rtt)
-                   tp->t_rtt++;
+    register struct socket *ip, *ipnxt;
+    register struct tcpcb *tp;
+    register int i;
+
+    DEBUG_CALL("tcp_slowtimo");
+
+    /*
+     * Search through tcb's and update active timers.
+     */
+    ip = tcb.so_next;
+    if (ip == 0)
+        return;
+    for (; ip != &tcb; ip = ipnxt)
+    {
+        ipnxt = ip->so_next;
+        tp = sototcpcb(ip);
+        if (tp == 0)
+            continue;
+        for (i = 0; i < TCPT_NTIMERS; i++)
+        {
+            if (tp->t_timer[i] && --tp->t_timer[i] == 0)
+            {
+                tcp_timers(pData, tp,i);
+                if (ipnxt->so_prev != ip)
+                    goto tpgone;
+            }
+        }
+        tp->t_idle++;
+        if (tp->t_rtt)
+            tp->t_rtt++;
 tpgone:
-                ;
-        }
-        tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
+        ;
+    }
+    tcp_iss += TCP_ISSINCR / PR_SLOWHZ;         /* increment iss */
 #ifdef TCP_COMPAT_42
-        if ((int)tcp_iss < 0)
-                tcp_iss = 0;                            /* XXX */
+    if ((int)tcp_iss < 0)
+        tcp_iss = 0;                            /* XXX */
 #endif
-        tcp_now++;                                      /* for timestamps */
+    tcp_now++;                                  /* for timestamps */
 }
 
@@ -111,15 +115,16 @@
  */
 void
-tcp_canceltimers(tp)
-        struct tcpcb *tp;
-{
-        register int i;
-
-        for (i = 0; i < TCPT_NTIMERS; i++)
-                tp->t_timer[i] = 0;
+tcp_canceltimers(struct tcpcb *tp)
+{
+    register int i;
+
+    for (i = 0; i < TCPT_NTIMERS; i++)
+        tp->t_timer[i] = 0;
 }
 
-const int       tcp_backoff[TCP_MAXRXTSHIFT + 1] =
-   { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
+const int  tcp_backoff[TCP_MAXRXTSHIFT + 1] =
+{
+    1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64
+};
 
 /*
@@ -129,10 +134,10 @@
 tcp_timers(PNATState pData, register struct tcpcb *tp, int timer)
 {
-        register int rexmt;
-
-        DEBUG_CALL("tcp_timers");
-
-        switch (timer) {
-
+    register int rexmt;
+
+    DEBUG_CALL("tcp_timers");
+
+    switch (timer)
+    {
         /*
          * 2 MSL timeout in shutdown went off.  If we're closed but
@@ -142,10 +147,10 @@
          */
         case TCPT_2MSL:
-                if (tp->t_state != TCPS_TIME_WAIT &&
+            if (tp->t_state != TCPS_TIME_WAIT &&
                     tp->t_idle <= tcp_maxidle)
-                        tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
-                else
-                        tp = tcp_close(pData, tp);
-                break;
+                tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
+            else
+                tp = tcp_close(pData, tp);
+            break;
 
         /*
@@ -155,101 +160,101 @@
          */
         case TCPT_REXMT:
-
+            /*
+             * XXX If a packet has timed out, then remove all the queued
+             * packets for that session.
+             */
+            if (++tp->t_rxtshift > TCP_MAXRXTSHIFT)
+            {
                 /*
-                 * XXXXX If a packet has timed out, then remove all the queued
-                 * packets for that session.
+                 * This is a hack to suit our terminal server here at the uni of canberra
+                 * since they have trouble with zeroes... It usually lets them through
+                 * unharmed, but under some conditions, it'll eat the zeros.  If we
+                 * keep retransmitting it, it'll keep eating the zeroes, so we keep
+                 * retransmitting, and eventually the connection dies...
+                 * (this only happens on incoming data)
+                 *
+                 * So, if we were gonna drop the connection from too many retransmits,
+                 * don't... instead halve the t_maxseg, which might break up the NULLs and
+                 * let them through
+                 *
+                 * *sigh*
                  */
-
-                if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) {
-                        /*
-                         * This is a hack to suit our terminal server here at the uni of canberra
-                         * since they have trouble with zeroes... It usually lets them through
-                         * unharmed, but under some conditions, it'll eat the zeros.  If we
-                         * keep retransmitting it, it'll keep eating the zeroes, so we keep
-                         * retransmitting, and eventually the connection dies...
-                         * (this only happens on incoming data)
-                         *
-                         * So, if we were gonna drop the connection from too many retransmits,
-                         * don't... instead halve the t_maxseg, which might break up the NULLs and
-                         * let them through
-                         *
-                         * *sigh*
-                         */
-
-                        tp->t_maxseg >>= 1;
-                        if (tp->t_maxseg < 32) {
-                                /*
-                                 * We tried our best, now the connection must die!
-                                 */
-                                tp->t_rxtshift = TCP_MAXRXTSHIFT;
-                                tcpstat.tcps_timeoutdrop++;
-                                tp = tcp_drop(pData, tp, tp->t_softerror);
-                                /* tp->t_softerror : ETIMEDOUT); */ /* XXX */
-                                return (tp); /* XXX */
-                        }
-
-                        /*
-                         * Set rxtshift to 6, which is still at the maximum
-                         * backoff time
-                         */
-                        tp->t_rxtshift = 6;
+                tp->t_maxseg >>= 1;
+                if (tp->t_maxseg < 32)
+                {
+                    /*
+                     * We tried our best, now the connection must die!
+                     */
+                    tp->t_rxtshift = TCP_MAXRXTSHIFT;
+                    tcpstat.tcps_timeoutdrop++;
+                    tp = tcp_drop(pData, tp, tp->t_softerror);
+                    /* tp->t_softerror : ETIMEDOUT); */ /* XXX */
+                    return (tp); /* XXX */
                 }
-                tcpstat.tcps_rexmttimeo++;
-                rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
-                TCPT_RANGESET(tp->t_rxtcur, rexmt,
+
+                /*
+                 * Set rxtshift to 6, which is still at the maximum
+                 * backoff time
+                 */
+                tp->t_rxtshift = 6;
+            }
+            tcpstat.tcps_rexmttimeo++;
+            rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
+            TCPT_RANGESET(tp->t_rxtcur, rexmt,
                     (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */
-                tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
-                /*
-                 * If losing, let the lower level know and try for
-                 * a better route.  Also, if we backed off this far,
-                 * our srtt estimate is probably bogus.  Clobber it
-                 * so we'll take the next rtt measurement as our srtt;
-                 * move the current srtt into rttvar to keep the current
-                 * retransmit times until then.
-                 */
-                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
-/*                      in_losing(tp->t_inpcb); */
-                        tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT);
-                        tp->t_srtt = 0;
-                }
-                tp->snd_nxt = tp->snd_una;
-                /*
-                 * If timing a segment in this window, stop the timer.
-                 */
-                tp->t_rtt = 0;
-                /*
-                 * Close the congestion window down to one segment
-                 * (we'll open it by one segment for each ack we get).
-                 * Since we probably have a window's worth of unacked
-                 * data accumulated, this "slow start" keeps us from
-                 * dumping all that data as back-to-back packets (which
-                 * might overwhelm an intermediate gateway).
-                 *
-                 * There are two phases to the opening: Initially we
-                 * open by one mss on each ack.  This makes the window
-                 * size increase exponentially with time.  If the
-                 * window is larger than the path can handle, this
-                 * exponential growth results in dropped packet(s)
-                 * almost immediately.  To get more time between
-                 * drops but still "push" the network to take advantage
-                 * of improving conditions, we switch from exponential
-                 * to linear window opening at some threshold size.
-                 * For a threshold, we use half the current window
-                 * size, truncated to a multiple of the mss.
-                 *
-                 * (the minimum cwnd that will give us exponential
-                 * growth is 2 mss.  We don't allow the threshold
-                 * to go below this.)
-                 */
-                {
+            tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+            /*
+             * If losing, let the lower level know and try for
+             * a better route.  Also, if we backed off this far,
+             * our srtt estimate is probably bogus.  Clobber it
+             * so we'll take the next rtt measurement as our srtt;
+             * move the current srtt into rttvar to keep the current
+             * retransmit times until then.
+             */
+            if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4)
+            {
+/*              in_losing(tp->t_inpcb); */
+                tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT);
+                tp->t_srtt = 0;
+            }
+            tp->snd_nxt = tp->snd_una;
+            /*
+             * If timing a segment in this window, stop the timer.
+             */
+            tp->t_rtt = 0;
+            /*
+             * Close the congestion window down to one segment
+             * (we'll open it by one segment for each ack we get).
+             * Since we probably have a window's worth of unacked
+             * data accumulated, this "slow start" keeps us from
+             * dumping all that data as back-to-back packets (which
+             * might overwhelm an intermediate gateway).
+             *
+             * There are two phases to the opening: Initially we
+             * open by one mss on each ack.  This makes the window
+             * size increase exponentially with time.  If the
+             * window is larger than the path can handle, this
+             * exponential growth results in dropped packet(s)
+             * almost immediately.  To get more time between
+             * drops but still "push" the network to take advantage
+             * of improving conditions, we switch from exponential
+             * to linear window opening at some threshold size.
+             * For a threshold, we use half the current window
+             * size, truncated to a multiple of the mss.
+             *
+             * (the minimum cwnd that will give us exponential
+             * growth is 2 mss.  We don't allow the threshold
+             * to go below this.)
+             */
+            {
                 u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
                 if (win < 2)
-                        win = 2;
+                    win = 2;
                 tp->snd_cwnd = tp->t_maxseg;
                 tp->snd_ssthresh = win * tp->t_maxseg;
                 tp->t_dupacks = 0;
-                }
-                (void) tcp_output(pData, tp);
-                break;
+            }
+            (void) tcp_output(pData, tp);
+            break;
 
         /*
@@ -258,10 +263,10 @@
          */
         case TCPT_PERSIST:
-                tcpstat.tcps_persisttimeo++;
-                tcp_setpersist(tp);
-                tp->t_force = 1;
-                (void) tcp_output(pData, tp);
-                tp->t_force = 0;
-                break;
+            tcpstat.tcps_persisttimeo++;
+            tcp_setpersist(tp);
+            tp->t_force = 1;
+            (void) tcp_output(pData, tp);
+            tp->t_force = 0;
+            break;
 
         /*
@@ -270,47 +275,47 @@
          */
         case TCPT_KEEP:
-                tcpstat.tcps_keeptimeo++;
-                if (tp->t_state < TCPS_ESTABLISHED)
-                        goto dropit;
-
-/*              if (tp->t_socket->so_options & SO_KEEPALIVE && */
-                if ((so_options) && tp->t_state <= TCPS_CLOSE_WAIT) {
-                        if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
-                                goto dropit;
-                        /*
-                         * Send a packet designed to force a response
-                         * if the peer is up and reachable:
-                         * either an ACK if the connection is still alive,
-                         * or an RST if the peer has closed the connection
-                         * due to timeout or reboot.
-                         * Using sequence number tp->snd_una-1
-                         * causes the transmitted zero-length segment
-                         * to lie outside the receive window;
-                         * by the protocol spec, this requires the
-                         * correspondent TCP to respond.
-                         */
-                        tcpstat.tcps_keepprobe++;
+            tcpstat.tcps_keeptimeo++;
+            if (tp->t_state < TCPS_ESTABLISHED)
+                goto dropit;
+/*          if (tp->t_socket->so_options & SO_KEEPALIVE && */
+            if ((so_options) && tp->t_state <= TCPS_CLOSE_WAIT) {
+                if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
+                    goto dropit;
+                /*
+                 * Send a packet designed to force a response
+                 * if the peer is up and reachable:
+                 * either an ACK if the connection is still alive,
+                 * or an RST if the peer has closed the connection
+                 * due to timeout or reboot.
+                 * Using sequence number tp->snd_una-1
+                 * causes the transmitted zero-length segment
+                 * to lie outside the receive window;
+                 * by the protocol spec, this requires the
+                 * correspondent TCP to respond.
+                 */
+                tcpstat.tcps_keepprobe++;
 #ifdef TCP_COMPAT_42
-                        /*
-                         * The keepalive packet must have nonzero length
-                         * to get a 4.2 host to respond.
-                         */
-                        tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
+                /*
+                 * The keepalive packet must have nonzero length
+                 * to get a 4.2 host to respond.
+                 */
+                tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
                             tp->rcv_nxt - 1, tp->snd_una - 1, 0);
 #else
-                        tcp_respond(pData, tp, &tp->t_template, (struct mbuf *)NULL,
-                            tp->rcv_nxt, tp->snd_una - 1, 0);
+                tcp_respond(pData, tp, &tp->t_template, (struct mbuf *)NULL,
+                        tp->rcv_nxt, tp->snd_una - 1, 0);
 #endif
-                        tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
-                } else
-                        tp->t_timer[TCPT_KEEP] = tcp_keepidle;
-                break;
+                tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
+            }
+            else
+                tp->t_timer[TCPT_KEEP] = tcp_keepidle;
+            break;
 
         dropit:
-                tcpstat.tcps_keepdrops++;
-                tp = tcp_drop(pData, tp, 0); /* ETIMEDOUT); */
-                break;
-        }
-
-        return (tp);
+            tcpstat.tcps_keepdrops++;
+            tp = tcp_drop(pData, tp, 0); /* ETIMEDOUT); */
+            break;
+    }
+
+    return tp;
 }
Index: trunk/src/VBox/Devices/Network/slirp/tcp_timer.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_timer.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_timer.h	(revision 14964)
@@ -103,5 +103,4 @@
 
 #define TCPTV_MIN       (  1*PR_SLOWHZ)         /* minimum allowable value */
-/* #define      TCPTV_REXMTMAX  ( 64*PR_SLOWHZ) */      /* max allowable REXMT value */
 #define TCPTV_REXMTMAX  ( 12*PR_SLOWHZ)         /* max allowable REXMT value */
 
Index: trunk/src/VBox/Devices/Network/slirp/tcpip.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcpip.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/tcpip.h	(revision 14964)
@@ -41,7 +41,8 @@
  * Tcp+ip header, after ip options removed.
  */
-struct tcpiphdr {
-	struct 	ipovly ti_i;		/* overlaid ip structure */
-	struct	tcphdr ti_t;		/* tcp header */
+struct tcpiphdr
+{
+    struct 	ipovly ti_i;		/* overlaid ip structure */
+    struct	tcphdr ti_t;		/* tcp header */
 };
 #define	ti_next		ti_i.ih_next
@@ -67,7 +68,8 @@
  * of the packet
  */
-struct tcpiphdr_2 {
-	struct tcpiphdr dummy;
-	char first_char;
+struct tcpiphdr_2
+{
+    struct tcpiphdr dummy;
+    char first_char;
 };
 
Index: trunk/src/VBox/Devices/Network/slirp/tftp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 14964)
@@ -34,53 +34,56 @@
 static void tftp_session_terminate(struct tftp_session *spt)
 {
-  spt->in_use = 0;
+    spt->in_use = 0;
 }
 
 static int tftp_session_allocate(PNATState pData, struct tftp_t *tp)
 {
-  struct tftp_session *spt;
-  int k;
-
-  for (k = 0; k < TFTP_SESSIONS_MAX; k++) {
-    spt = &tftp_sessions[k];
-
-    if (!spt->in_use)
-        goto found;
-
-    /* sessions time out after 5 inactive seconds */
-    if ((int)(curtime - spt->timestamp) > 5000)
-        goto found;
-  }
-
-  return -1;
+    struct tftp_session *spt;
+    int k;
+
+    for (k = 0; k < TFTP_SESSIONS_MAX; k++)
+    {
+        spt = &tftp_sessions[k];
+
+        if (!spt->in_use)
+            goto found;
+
+        /* sessions time out after 5 inactive seconds */
+        if ((int)(curtime - spt->timestamp) > 5000)
+            goto found;
+    }
+
+    return -1;
 
  found:
-  memset(spt, 0, sizeof(*spt));
-  memcpy(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip));
-  spt->client_port = tp->udp.uh_sport;
-
-  tftp_session_update(pData, spt);
-
-  return k;
+    memset(spt, 0, sizeof(*spt));
+    memcpy(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip));
+    spt->client_port = tp->udp.uh_sport;
+
+    tftp_session_update(pData, spt);
+
+    return k;
 }
 
 static int tftp_session_find(PNATState pData, struct tftp_t *tp)
 {
-  struct tftp_session *spt;
-  int k;
-
-  for (k = 0; k < TFTP_SESSIONS_MAX; k++) {
-    spt = &tftp_sessions[k];
-
-    if (spt->in_use) {
-      if (!memcmp(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip))) {
-        if (spt->client_port == tp->udp.uh_sport) {
-          return k;
+    struct tftp_session *spt;
+    int k;
+
+    for (k = 0; k < TFTP_SESSIONS_MAX; k++)
+    {
+        spt = &tftp_sessions[k];
+
+        if (spt->in_use)
+        {
+            if (!memcmp(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip)))
+            {
+                if (spt->client_port == tp->udp.uh_sport)
+                    return k;
+            }
         }
-      }
-    }
-  }
-
-  return -1;
+    }
+
+    return -1;
 }
 
@@ -88,29 +91,27 @@
                           u_int8_t *buf, int len)
 {
-  int fd;
-  int bytes_read = 0;
-  char buffer[1024];
-  int n;
-
-  n = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
-               tftp_prefix, spt->filename);
-  if (n >= sizeof(buffer))
-    return -1;
-
-  fd = open(buffer, O_RDONLY | O_BINARY);
-
-  if (fd < 0) {
-    return -1;
-  }
-
-  if (len) {
-    lseek(fd, block_nr * 512, SEEK_SET);
-
-    bytes_read = read(fd, buf, len);
-  }
-
-  close(fd);
-
-  return bytes_read;
+    int fd;
+    int bytes_read = 0;
+    char buffer[1024];
+    int n;
+
+    n = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
+                    tftp_prefix, spt->filename);
+    if (n >= sizeof(buffer))
+        return -1;
+
+    fd = open(buffer, O_RDONLY | O_BINARY);
+    if (fd < 0)
+        return -1;
+
+    if (len)
+    {
+        lseek(fd, block_nr * 512, SEEK_SET);
+        bytes_read = read(fd, buf, len);
+    }
+
+    close(fd);
+
+    return bytes_read;
 }
 
@@ -126,5 +127,4 @@
 
     m = m_get(pData);
-
     if (!m)
         return -1;
@@ -160,41 +160,43 @@
                            struct tftp_t *recv_tp)
 {
-  struct sockaddr_in saddr, daddr;
-  struct mbuf *m;
-  struct tftp_t *tp;
-  int nobytes;
-
-  m = m_get(pData);
-
-  if (!m) {
-    return -1;
-  }
-
-  memset(m->m_data, 0, m->m_size);
-
-  m->m_data += if_maxlinkhdr;
-  tp = (void *)m->m_data;
-  m->m_data += sizeof(struct udpiphdr);
-
-  tp->tp_op = htons(TFTP_ERROR);
-  tp->x.tp_error.tp_error_code = htons(errorcode);
-  strcpy((char *)tp->x.tp_error.tp_msg, msg);
-
-  saddr.sin_addr = recv_tp->ip.ip_dst;
-  saddr.sin_port = recv_tp->udp.uh_dport;
-
-  daddr.sin_addr = spt->client_ip;
-  daddr.sin_port = spt->client_port;
-
-  nobytes = 2;
-
-  m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) -
-        sizeof(struct ip) - sizeof(struct udphdr);
-
-  udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
-
-  tftp_session_terminate(spt);
-
-  return 0;
+    struct sockaddr_in saddr, daddr;
+    struct mbuf *m;
+    struct tftp_t *tp;
+    int nobytes;
+
+    m = m_get(pData);
+    if (!m)
+        return -1;
+
+    memset(m->m_data, 0, m->m_size);
+
+    m->m_data += if_maxlinkhdr;
+    tp = (void *)m->m_data;
+    m->m_data += sizeof(struct udpiphdr);
+
+    tp->tp_op = htons(TFTP_ERROR);
+    tp->x.tp_error.tp_error_code = htons(errorcode);
+    strcpy((char *)tp->x.tp_error.tp_msg, msg);
+
+    saddr.sin_addr = recv_tp->ip.ip_dst;
+    saddr.sin_port = recv_tp->udp.uh_dport;
+
+    daddr.sin_addr = spt->client_ip;
+    daddr.sin_port = spt->client_port;
+
+    nobytes = 2;
+
+    m->m_len = sizeof(struct tftp_t) 
+             - 514
+             + 3 
+             + strlen(msg)
+             - sizeof(struct ip) 
+             - sizeof(struct udphdr);
+
+    udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
+
+    tftp_session_terminate(spt);
+
+    return 0;
 }
 
@@ -204,209 +206,200 @@
                           struct tftp_t *recv_tp)
 {
-  struct sockaddr_in saddr, daddr;
-  struct mbuf *m;
-  struct tftp_t *tp;
-  int nobytes;
-
-  if (block_nr < 1) {
-    return -1;
-  }
-
-  m = m_get(pData);
-
-  if (!m) {
-    return -1;
-  }
-
-  memset(m->m_data, 0, m->m_size);
-
-  m->m_data += if_maxlinkhdr;
-  tp = (void *)m->m_data;
-  m->m_data += sizeof(struct udpiphdr);
-
-  tp->tp_op = htons(TFTP_DATA);
-  tp->x.tp_data.tp_block_nr = htons(block_nr);
-
-  saddr.sin_addr = recv_tp->ip.ip_dst;
-  saddr.sin_port = recv_tp->udp.uh_dport;
-
-  daddr.sin_addr = spt->client_ip;
-  daddr.sin_port = spt->client_port;
-
-  nobytes = tftp_read_data(pData, spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
-
-  if (nobytes < 0) {
-    m_free(pData, m);
-
-    /* send "file not found" error back */
-
-    tftp_send_error(pData, spt, 1, "File not found", tp);
-
-    return -1;
-  }
-
-  m->m_len = sizeof(struct tftp_t) - (512 - nobytes) -
-        sizeof(struct ip) - sizeof(struct udphdr);
-
-  udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
-
-  if (nobytes == 512) {
-    tftp_session_update(pData, spt);
-  }
-  else {
-    tftp_session_terminate(spt);
-  }
-
-  return 0;
+    struct sockaddr_in saddr, daddr;
+    struct mbuf *m;
+    struct tftp_t *tp;
+    int nobytes;
+
+    if (block_nr < 1)
+        return -1;
+
+    m = m_get(pData);
+    if (!m)
+        return -1;
+
+    memset(m->m_data, 0, m->m_size);
+
+    m->m_data += if_maxlinkhdr;
+    tp = (void *)m->m_data;
+    m->m_data += sizeof(struct udpiphdr);
+
+    tp->tp_op = htons(TFTP_DATA);
+    tp->x.tp_data.tp_block_nr = htons(block_nr);
+
+    saddr.sin_addr = recv_tp->ip.ip_dst;
+    saddr.sin_port = recv_tp->udp.uh_dport;
+
+    daddr.sin_addr = spt->client_ip;
+    daddr.sin_port = spt->client_port;
+
+    nobytes = tftp_read_data(pData, spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
+    if (nobytes < 0)
+    {
+        m_free(pData, m);
+        /* send "file not found" error back */
+        tftp_send_error(pData, spt, 1, "File not found", tp);
+        return -1;
+    }
+
+    m->m_len = sizeof(struct tftp_t) 
+             - (512 - nobytes) 
+             - sizeof(struct ip) 
+             - sizeof(struct udphdr);
+
+    udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
+
+    if (nobytes == 512)
+        tftp_session_update(pData, spt);
+    else
+        tftp_session_terminate(spt);
+
+    return 0;
 }
 
 static void tftp_handle_rrq(PNATState pData, struct tftp_t *tp, int pktlen)
 {
-  struct tftp_session *spt;
-  int s, k, n;
-  u_int8_t *src, *dst;
-
-  s = tftp_session_allocate(pData, tp);
-
-  if (s < 0) {
-    return;
-  }
-
-  spt = &tftp_sessions[s];
-
-  src = tp->x.tp_buf;
-  dst = spt->filename;
-  n = pktlen - ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp);
-
-  /* get name */
-
-  for (k = 0; k < n; k++) {
-    if (k < TFTP_FILENAME_MAX) {
-      dst[k] = src[k];
-    }
-    else {
-      return;
-    }
-
-    if (src[k] == '\0') {
-      break;
-    }
-  }
-
-  if (k >= n) {
-    return;
-  }
-
-  k++;
-
-  /* check mode */
-  if ((n - k) < 6) {
-    return;
-  }
-
-  if (memcmp(&src[k], "octet\0", 6) != 0) {
-      tftp_send_error(pData, spt, 4, "Unsupported transfer mode", tp);
-      return;
-  }
-
-  k += 6; /* skipping octet */
-
-  /* do sanity checks on the filename */
-
-  if (   !strncmp((const char*)spt->filename, "../", 3)
-      || (spt->filename[strlen((const char *)spt->filename) - 1] == '/')
-      ||  strstr((const char *)spt->filename, "/../")) {
-      tftp_send_error(pData, spt, 2, "Access violation", tp);
-      return;
-  }
-
-  /* only allow exported prefixes */
-
-  if (!tftp_prefix) {
-      tftp_send_error(pData, spt, 2, "Access violation", tp);
-      return;
-  }
-
-  /* check if the file exists */
-
-  if (tftp_read_data(pData, spt, 0, spt->filename, 0) < 0) {
-      tftp_send_error(pData, spt, 1, "File not found", tp);
-      return;
-  }
-
-  if (src[n - 1] != 0) {
-      tftp_send_error(pData, spt, 2, "Access violation", tp);
-      return;
-  }
-
-  while (k < n) {
-      const char *key, *value;
-
-      key = (const char *)src + k;
-      k += strlen(key) + 1;
-
-      if (k >= n) {
-          tftp_send_error(pData, spt, 2, "Access violation", tp);
-          return;
-      }
-
-      value = (const char *)src + k;
-      k += strlen(value) + 1;
-
-      if (strcmp(key, "tsize") == 0) {
-          int tsize = atoi(value);
-          struct stat stat_p;
-
-          if (tsize == 0 && tftp_prefix) {
-              char buffer[1024];
-              int len;
-
-              len = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
-                             tftp_prefix, spt->filename);
-
-              if (stat(buffer, &stat_p) == 0)
-                  tsize = stat_p.st_size;
-              else {
-                  tftp_send_error(pData, spt, 1, "File not found", tp);
-                  return;
-              }
-          }
-
-          tftp_send_oack(pData, spt, "tsize", tsize, tp);
-      }
-  }
-
-  tftp_send_data(pData, spt, 1, tp);
+    struct tftp_session *spt;
+    int s, k, n;
+    u_int8_t *src, *dst;
+
+    s = tftp_session_allocate(pData, tp);
+    if (s < 0)
+        return;
+
+    spt = &tftp_sessions[s];
+
+    src = tp->x.tp_buf;
+    dst = spt->filename;
+    n = pktlen - ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp);
+
+    /* get name */
+    for (k = 0; k < n; k++)
+    {
+        if (k < TFTP_FILENAME_MAX)
+            dst[k] = src[k];
+        else
+            return;
+
+        if (src[k] == '\0')
+            break;
+    }
+
+    if (k >= n)
+        return;
+
+    k++;
+
+    /* check mode */
+    if ((n - k) < 6)
+        return;
+
+    if (memcmp(&src[k], "octet\0", 6) != 0)
+    {
+        tftp_send_error(pData, spt, 4, "Unsupported transfer mode", tp);
+        return;
+    }
+
+    k += 6; /* skipping octet */
+
+    /* do sanity checks on the filename */
+    if (   !strncmp((const char*)spt->filename, "../", 3)
+        || (spt->filename[strlen((const char *)spt->filename) - 1] == '/')
+        ||  strstr((const char *)spt->filename, "/../")) {
+        tftp_send_error(pData, spt, 2, "Access violation", tp);
+        return;
+    }
+
+    /* only allow exported prefixes */
+    if (!tftp_prefix)
+    {
+        tftp_send_error(pData, spt, 2, "Access violation", tp);
+        return;
+    }
+
+    /* check if the file exists */
+    if (tftp_read_data(pData, spt, 0, spt->filename, 0) < 0)
+    {
+        tftp_send_error(pData, spt, 1, "File not found", tp);
+        return;
+    }
+
+    if (src[n - 1] != 0)
+    {
+        tftp_send_error(pData, spt, 2, "Access violation", tp);
+        return;
+    }
+
+    while (k < n)
+    {
+        const char *key, *value;
+
+        key = (const char *)src + k;
+        k += strlen(key) + 1;
+
+        if (k >= n)
+        {
+            tftp_send_error(pData, spt, 2, "Access violation", tp);
+            return;
+        }
+
+        value = (const char *)src + k;
+        k += strlen(value) + 1;
+
+        if (strcmp(key, "tsize") == 0)
+        {
+            int tsize = atoi(value);
+            struct stat stat_p;
+
+            if (tsize == 0 && tftp_prefix)
+            {
+                char buffer[1024];
+                int len;
+
+                len = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
+                                  tftp_prefix, spt->filename);
+                if (stat(buffer, &stat_p) == 0)
+                    tsize = stat_p.st_size;
+                else
+                {
+                    tftp_send_error(pData, spt, 1, "File not found", tp);
+                    return;
+                }
+            }
+
+            tftp_send_oack(pData, spt, "tsize", tsize, tp);
+        }
+    }
+
+    tftp_send_data(pData, spt, 1, tp);
 }
 
 static void tftp_handle_ack(PNATState pData, struct tftp_t *tp, int pktlen)
 {
-  int s;
-
-  s = tftp_session_find(pData, tp);
-
-  if (s < 0) {
-    return;
-  }
-
-  if (tftp_send_data(pData, &tftp_sessions[s],
-                     ntohs(tp->x.tp_data.tp_block_nr) + 1,
-                     tp) < 0) {
-    return;
-  }
+    int s;
+
+    s = tftp_session_find(pData, tp);
+    if (s < 0)
+        return;
+
+    if (tftp_send_data(pData, &tftp_sessions[s],
+                       ntohs(tp->x.tp_data.tp_block_nr) + 1, tp) < 0)
+    {
+        /* XXX */
+    }
 }
 
 void tftp_input(PNATState pData, struct mbuf *m)
 {
-  struct tftp_t *tp = (struct tftp_t *)m->m_data;
-
-  switch(ntohs(tp->tp_op)) {
-  case TFTP_RRQ:
-    tftp_handle_rrq(pData, tp, m->m_len);
-    break;
-
-  case TFTP_ACK:
-    tftp_handle_ack(pData, tp, m->m_len);
-    break;
-  }
-}
+    struct tftp_t *tp = (struct tftp_t *)m->m_data;
+
+    switch(ntohs(tp->tp_op))
+    {
+        case TFTP_RRQ:
+            tftp_handle_rrq(pData, tp, m->m_len);
+            break;
+
+        case TFTP_ACK:
+            tftp_handle_ack(pData, tp, m->m_len);
+            break;
+    }
+}
Index: trunk/src/VBox/Devices/Network/slirp/tftp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tftp.h	(revision 14951)
+++ trunk/src/VBox/Devices/Network/slirp/tftp.h	(revision 14964)
@@ -14,19 +14,23 @@
 #define TFTP_FILENAME_MAX 512
 
-struct tftp_t {
-  struct ip ip;
-  struct udphdr udp;
-  u_int16_t tp_op;
-  union {
-    struct {
-      u_int16_t tp_block_nr;
-      u_int8_t tp_buf[512];
-    } tp_data;
-    struct {
-      u_int16_t tp_error_code;
-      u_int8_t tp_msg[512];
-    } tp_error;
-    u_int8_t tp_buf[512 + 2];
-  } x;
+struct tftp_t
+{
+    struct ip ip;
+    struct udphdr udp;
+    u_int16_t tp_op;
+    union
+    {
+        struct
+        {
+            u_int16_t tp_block_nr;
+            u_int8_t  tp_buf[512];
+        } tp_data;
+        struct
+        {
+            u_int16_t tp_error_code;
+            u_int8_t  tp_msg[512];
+        } tp_error;
+        u_int8_t tp_buf[512 + 2];
+    } x;
 };
 
