Index: trunk/src/VBox/Devices/Network/slirp/cksum.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/cksum.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/cksum.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1988, 1992, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)in_cksum.c	8.1 (Berkeley) 6/10/93
+ *      @(#)in_cksum.c  8.1 (Berkeley) 6/10/93
  * in_cksum.c,v 1.2 1994/08/02 07:48:16 davidg Exp
  */
@@ -51,91 +51,91 @@
 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;
-	
-	if (m->m_len == 0)
-	   goto cont;
-	w = mtod(m, u_int16_t *);
-	
-	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 (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;
-	
+        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 *);
+        
+        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 (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;
+        
 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/debug.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/debug.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/debug.c	(revision 14470)
@@ -41,39 +41,39 @@
 void
 ttystats(ttyp)
-	struct ttys *ttyp;
-{
-	struct slirp_ifstats *is = &ttyp->ifstats;
-	char buff[512];
-
-	lprint(" \r\n");
-
-	if (if_comp & IF_COMPRESS)
-	   strcpy(buff, "on");
-	else if (if_comp & IF_NOCOMPRESS)
-	   strcpy(buff, "off");
-	else
-	   strcpy(buff, "off (for now)");
-	lprint("Unit %d:\r\n", ttyp->unit);
-	lprint("  using %s encapsulation (VJ compression is %s)\r\n", (
+        struct ttys *ttyp;
+{
+        struct slirp_ifstats *is = &ttyp->ifstats;
+        char buff[512];
+
+        lprint(" \r\n");
+
+        if (if_comp & IF_COMPRESS)
+           strcpy(buff, "on");
+        else if (if_comp & IF_NOCOMPRESS)
+           strcpy(buff, "off");
+        else
+           strcpy(buff, "off (for now)");
+        lprint("Unit %d:\r\n", ttyp->unit);
+        lprint("  using %s encapsulation (VJ compression is %s)\r\n", (
 #ifdef USE_PPP
-	       ttyp->proto==PROTO_PPP?"PPP":
-#endif
-	       "SLIP"), buff);
-	lprint("  %d baudrate\r\n", ttyp->baud);
-	lprint("  interface is %s\r\n", ttyp->up?"up":"down");
-	lprint("  using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
+               ttyp->proto==PROTO_PPP?"PPP":
+#endif
+               "SLIP"), buff);
+        lprint("  %d baudrate\r\n", ttyp->baud);
+        lprint("  interface is %s\r\n", ttyp->up?"up":"down");
+        lprint("  using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
 #ifndef FULL_BOLT
-	lprint("  towrite is %d bytes\r\n", ttyp->towrite);
-#endif
-	if (ttyp->zeros)
-	   lprint("  %d zeros have been typed\r\n", ttyp->zeros);
-	else if (ttyp->ones)
-	   lprint("  %d ones have been typed\r\n", ttyp->ones);
-	lprint("Interface stats:\r\n");
-	lprint("  %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
-	lprint("  %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
-	lprint("  %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
-	lprint("  %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
-	lprint("  %6d bad input packets\r\n", is->in_mbad);
+        lprint("  towrite is %d bytes\r\n", ttyp->towrite);
+#endif
+        if (ttyp->zeros)
+           lprint("  %d zeros have been typed\r\n", ttyp->zeros);
+        else if (ttyp->ones)
+           lprint("  %d ones have been typed\r\n", ttyp->ones);
+        lprint("Interface stats:\r\n");
+        lprint("  %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
+        lprint("  %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
+        lprint("  %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
+        lprint("  %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
+        lprint("  %6d bad input packets\r\n", is->in_mbad);
 }
 
@@ -81,8 +81,8 @@
 allttystats()
 {
-	struct ttys *ttyp;
-
-	for (ttyp = ttys; ttyp; ttyp = ttyp->next)
-	   ttystats(ttyp);
+        struct ttys *ttyp;
+
+        for (ttyp = ttys; ttyp; ttyp = ttyp->next)
+           ttystats(ttyp);
 }
 #endif
@@ -91,23 +91,23 @@
 ipstats(PNATState pData)
 {
-	lprint(" \r\n");
-
-	lprint("IP stats:\r\n");
-	lprint("  %6d total packets received (%d were unaligned)\r\n",
-			ipstat.ips_total, ipstat.ips_unaligned);
-	lprint("  %6d with incorrect version\r\n", ipstat.ips_badvers);
-	lprint("  %6d with bad header checksum\r\n", ipstat.ips_badsum);
-	lprint("  %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
-	lprint("  %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
-	lprint("  %6d with bad header length\r\n", ipstat.ips_badhlen);
-	lprint("  %6d with bad packet length\r\n", ipstat.ips_badlen);
-	lprint("  %6d fragments received\r\n", ipstat.ips_fragments);
-	lprint("  %6d fragments dropped\r\n", ipstat.ips_fragdropped);
-	lprint("  %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
-	lprint("  %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
-	lprint("  %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
-	lprint("  %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
-	lprint("  %6d with bad protocol field\r\n", ipstat.ips_noproto);
-	lprint("  %6d total packets delivered\r\n", ipstat.ips_delivered);
+        lprint(" \r\n");
+
+        lprint("IP stats:\r\n");
+        lprint("  %6d total packets received (%d were unaligned)\r\n",
+                        ipstat.ips_total, ipstat.ips_unaligned);
+        lprint("  %6d with incorrect version\r\n", ipstat.ips_badvers);
+        lprint("  %6d with bad header checksum\r\n", ipstat.ips_badsum);
+        lprint("  %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
+        lprint("  %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
+        lprint("  %6d with bad header length\r\n", ipstat.ips_badhlen);
+        lprint("  %6d with bad packet length\r\n", ipstat.ips_badlen);
+        lprint("  %6d fragments received\r\n", ipstat.ips_fragments);
+        lprint("  %6d fragments dropped\r\n", ipstat.ips_fragdropped);
+        lprint("  %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
+        lprint("  %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
+        lprint("  %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
+        lprint("  %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
+        lprint("  %6d with bad protocol field\r\n", ipstat.ips_noproto);
+        lprint("  %6d total packets delivered\r\n", ipstat.ips_delivered);
 }
 
@@ -116,16 +116,16 @@
 vjstats()
 {
-	lprint(" \r\n");
-
-	lprint("VJ compression stats:\r\n");
-
-	lprint("  %6d outbound packets (%d compressed)\r\n",
-	       comp_s.sls_packets, comp_s.sls_compressed);
-	lprint("  %6d searches for connection stats (%d misses)\r\n",
-	       comp_s.sls_searches, comp_s.sls_misses);
-	lprint("  %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
-	lprint("  %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
-	lprint("  %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
-	lprint("  %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
+        lprint(" \r\n");
+
+        lprint("VJ compression stats:\r\n");
+
+        lprint("  %6d outbound packets (%d compressed)\r\n",
+               comp_s.sls_packets, comp_s.sls_compressed);
+        lprint("  %6d searches for connection stats (%d misses)\r\n",
+               comp_s.sls_searches, comp_s.sls_misses);
+        lprint("  %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
+        lprint("  %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
+        lprint("  %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
+        lprint("  %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
 }
 #endif
@@ -134,66 +134,66 @@
 tcpstats(PNATState pData)
 {
-	lprint(" \r\n");
-
-	lprint("TCP stats:\r\n");
-
-	lprint("  %6d packets sent\r\n", tcpstat.tcps_sndtotal);
-	lprint("          %6d data packets (%d bytes)\r\n",
-			tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
-	lprint("          %6d data packets retransmitted (%d bytes)\r\n",
-			tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
-	lprint("          %6d ack-only packets (%d delayed)\r\n",
-			tcpstat.tcps_sndacks, tcpstat.tcps_delack);
-	lprint("          %6d URG only packets\r\n", tcpstat.tcps_sndurg);
-	lprint("          %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
-	lprint("          %6d window update packets\r\n", tcpstat.tcps_sndwinup);
-	lprint("          %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
-	lprint("          %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
-
-	lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);
-	lprint("          %6d acks (for %d bytes)\r\n",
-			tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
-	lprint("          %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
-	lprint("          %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
-	lprint("          %6d packets received in sequence (%d bytes)\r\n",
-			tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
+        lprint(" \r\n");
+
+        lprint("TCP stats:\r\n");
+
+        lprint("  %6d packets sent\r\n", tcpstat.tcps_sndtotal);
+        lprint("          %6d data packets (%d bytes)\r\n",
+                        tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
+        lprint("          %6d data packets retransmitted (%d bytes)\r\n",
+                        tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
+        lprint("          %6d ack-only packets (%d delayed)\r\n",
+                        tcpstat.tcps_sndacks, tcpstat.tcps_delack);
+        lprint("          %6d URG only packets\r\n", tcpstat.tcps_sndurg);
+        lprint("          %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
+        lprint("          %6d window update packets\r\n", tcpstat.tcps_sndwinup);
+        lprint("          %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
+        lprint("          %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
+
+        lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);
+        lprint("          %6d acks (for %d bytes)\r\n",
+                        tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
+        lprint("          %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
+        lprint("          %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
+        lprint("          %6d packets received in sequence (%d bytes)\r\n",
+                        tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
         lprint("          %6d completely duplicate packets (%d bytes)\r\n",
-			tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
-
-	lprint("          %6d packets with some duplicate data (%d bytes duped)\r\n",
-			tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
-	lprint("          %6d out-of-order packets (%d bytes)\r\n",
-			tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
-	lprint("          %6d packets of data after window (%d bytes)\r\n",
-			tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
-	lprint("          %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
-	lprint("          %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
-	lprint("          %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
-	lprint("          %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
-	lprint("          %6d discarded for bad header offset fields\r\n",
-			tcpstat.tcps_rcvbadoff);
-
-	lprint("  %6d connection requests\r\n", tcpstat.tcps_connattempt);
-	lprint("  %6d connection accepts\r\n", tcpstat.tcps_accepts);
-	lprint("  %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
-	lprint("  %6d connections closed (including %d drop)\r\n",
-			tcpstat.tcps_closed, tcpstat.tcps_drops);
-	lprint("  %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
-	lprint("  %6d segments we tried to get rtt (%d succeeded)\r\n",
-			tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
-	lprint("  %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
-	lprint("          %6d connections dropped by rxmt timeout\r\n",
-			tcpstat.tcps_timeoutdrop);
-	lprint("  %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
-	lprint("  %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
-	lprint("          %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
-	lprint("          %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
-	lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
-	lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
-	lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
-
-
-/*	lprint("    Packets received too short:		%d\r\n", tcpstat.tcps_rcvshort); */
-/*	lprint("    Segments dropped due to PAWS:	%d\r\n", tcpstat.tcps_pawsdrop); */
+                        tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
+
+        lprint("          %6d packets with some duplicate data (%d bytes duped)\r\n",
+                        tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
+        lprint("          %6d out-of-order packets (%d bytes)\r\n",
+                        tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
+        lprint("          %6d packets of data after window (%d bytes)\r\n",
+                        tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
+        lprint("          %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
+        lprint("          %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
+        lprint("          %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
+        lprint("          %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
+        lprint("          %6d discarded for bad header offset fields\r\n",
+                        tcpstat.tcps_rcvbadoff);
+
+        lprint("  %6d connection requests\r\n", tcpstat.tcps_connattempt);
+        lprint("  %6d connection accepts\r\n", tcpstat.tcps_accepts);
+        lprint("  %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
+        lprint("  %6d connections closed (including %d drop)\r\n",
+                        tcpstat.tcps_closed, tcpstat.tcps_drops);
+        lprint("  %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
+        lprint("  %6d segments we tried to get rtt (%d succeeded)\r\n",
+                        tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
+        lprint("  %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
+        lprint("          %6d connections dropped by rxmt timeout\r\n",
+                        tcpstat.tcps_timeoutdrop);
+        lprint("  %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
+        lprint("  %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
+        lprint("          %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
+        lprint("          %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
+        lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
+        lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
+        lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
+
+
+/*      lprint("    Packets received too short:         %d\r\n", tcpstat.tcps_rcvshort); */
+/*      lprint("    Segments dropped due to PAWS:       %d\r\n", tcpstat.tcps_pawsdrop); */
 
 }
@@ -204,11 +204,11 @@
         lprint(" \r\n");
 
-	lprint("UDP stats:\r\n");
-	lprint("  %6d datagrams received\r\n", udpstat.udps_ipackets);
-	lprint("  %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
-	lprint("  %6d with bad checksums\r\n", udpstat.udps_badsum);
-	lprint("  %6d with data length larger than packet\r\n", udpstat.udps_badlen);
-	lprint("  %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
-	lprint("  %6d datagrams sent\r\n", udpstat.udps_opackets);
+        lprint("UDP stats:\r\n");
+        lprint("  %6d datagrams received\r\n", udpstat.udps_ipackets);
+        lprint("  %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
+        lprint("  %6d with bad checksums\r\n", udpstat.udps_badsum);
+        lprint("  %6d with data length larger than packet\r\n", udpstat.udps_badlen);
+        lprint("  %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
+        lprint("  %6d datagrams sent\r\n", udpstat.udps_opackets);
 }
 
@@ -216,12 +216,12 @@
 icmpstats(PNATState pData)
 {
-	lprint(" \r\n");
-	lprint("ICMP stats:\r\n");
-	lprint("  %6d ICMP packets received\r\n", icmpstat.icps_received);
-	lprint("  %6d were too short\r\n", icmpstat.icps_tooshort);
-	lprint("  %6d with bad checksums\r\n", icmpstat.icps_checksum);
-	lprint("  %6d with type not supported\r\n", icmpstat.icps_notsupp);
-	lprint("  %6d with bad type feilds\r\n", icmpstat.icps_badtype);
-	lprint("  %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
+        lprint(" \r\n");
+        lprint("ICMP stats:\r\n");
+        lprint("  %6d ICMP packets received\r\n", icmpstat.icps_received);
+        lprint("  %6d were too short\r\n", icmpstat.icps_tooshort);
+        lprint("  %6d with bad checksums\r\n", icmpstat.icps_checksum);
+        lprint("  %6d with type not supported\r\n", icmpstat.icps_notsupp);
+        lprint("  %6d with bad type feilds\r\n", icmpstat.icps_badtype);
+        lprint("  %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
 }
 
@@ -229,22 +229,22 @@
 mbufstats(PNATState pData)
 {
-	struct mbuf *m;
-	int i;
-
-        lprint(" \r\n");
-
-	lprint("Mbuf stats:\r\n");
-
-	lprint("  %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
-
-	i = 0;
-	for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
-		i++;
-	lprint("  %6d mbufs on free list\r\n",  i);
-
-	i = 0;
-	for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
-		i++;
-	lprint("  %6d mbufs on used list\r\n",  i);
+        struct mbuf *m;
+        int i;
+
+        lprint(" \r\n");
+
+        lprint("Mbuf stats:\r\n");
+
+        lprint("  %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
+
+        i = 0;
+        for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
+                i++;
+        lprint("  %6d mbufs on free list\r\n",  i);
+
+        i = 0;
+        for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
+                i++;
+        lprint("  %6d mbufs on used list\r\n",  i);
         lprint("  %6d mbufs queued as packets\r\n\r\n", if_queued);
 }
@@ -253,40 +253,40 @@
 sockstats(PNATState pData)
 {
-	char buff[256];
-	int n;
-	struct socket *so;
-
-        lprint(" \r\n");
-
-	lprint(
-	   "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\r\n");
-
-	for (so = tcb.so_next; so != &tcb; so = so->so_next) {
-
-		n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
-		while (n < 17)
-		   buff[n++] = ' ';
-		buff[17] = 0;
-		lprint("%s %3d   %15s %5d ",
-				buff, so->s,
-				inet_ntoa(so->so_laddr), ntohs(so->so_lport));
-		lprint("%15s %5d %5d %5d\r\n",
-				inet_ntoa(so->so_faddr), ntohs(so->so_fport),
-				so->so_rcv.sb_cc, so->so_snd.sb_cc);
-	}
-
-	for (so = udb.so_next; so != &udb; so = so->so_next) {
-
-		n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
-		while (n < 17)
-		   buff[n++] = ' ';
-		buff[17] = 0;
-		lprint("%s %3d  %15s %5d  ",
-				buff, so->s,
-				inet_ntoa(so->so_laddr), ntohs(so->so_lport));
-		lprint("%15s %5d %5d %5d\r\n",
-				inet_ntoa(so->so_faddr), ntohs(so->so_fport),
-				so->so_rcv.sb_cc, so->so_snd.sb_cc);
-	}
-}
-
+        char buff[256];
+        int n;
+        struct socket *so;
+
+        lprint(" \r\n");
+
+        lprint(
+           "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\r\n");
+
+        for (so = tcb.so_next; so != &tcb; so = so->so_next) {
+
+                n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
+                while (n < 17)
+                   buff[n++] = ' ';
+                buff[17] = 0;
+                lprint("%s %3d   %15s %5d ",
+                                buff, so->s,
+                                inet_ntoa(so->so_laddr), ntohs(so->so_lport));
+                lprint("%15s %5d %5d %5d\r\n",
+                                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
+                                so->so_rcv.sb_cc, so->so_snd.sb_cc);
+        }
+
+        for (so = udb.so_next; so != &udb; so = so->so_next) {
+
+                n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
+                while (n < 17)
+                   buff[n++] = ' ';
+                buff[17] = 0;
+                lprint("%s %3d  %15s %5d  ",
+                                buff, so->s,
+                                inet_ntoa(so->so_laddr), ntohs(so->so_lport));
+                lprint("%15s %5d %5d %5d\r\n",
+                                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
+                                so->so_rcv.sb_cc, so->so_snd.sb_cc);
+        }
+}
+
Index: trunk/src/VBox/Devices/Network/slirp/debug.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/debug.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/debug.h	(revision 14470)
@@ -6,6 +6,6 @@
  */
 
-#define PRN_STDERR	1
-#define PRN_SPRINTF	2
+#define PRN_STDERR      1
+#define PRN_SPRINTF     2
 
 /* Unused anyway, using VBox Log facility. */
Index: trunk/src/VBox/Devices/Network/slirp/if.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/if.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/if.c	(revision 14470)
@@ -13,14 +13,14 @@
 static void ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead)
 {
-	ifm->ifs_next = ifmhead->ifs_next;
-	ifmhead->ifs_next = ifm;
-	ifm->ifs_prev = ifmhead;
-	ifm->ifs_next->ifs_prev = ifm;
+        ifm->ifs_next = ifmhead->ifs_next;
+        ifmhead->ifs_next = ifm;
+        ifm->ifs_prev = ifmhead;
+        ifm->ifs_next->ifs_prev = ifm;
 }
 
 static void ifs_remque(struct mbuf *ifm)
 {
-	ifm->ifs_prev->ifs_next = ifm->ifs_next;
-	ifm->ifs_next->ifs_prev = ifm->ifs_prev;
+        ifm->ifs_prev->ifs_next = ifm->ifs_next;
+        ifm->ifs_next->ifs_prev = ifm->ifs_prev;
 }
 
@@ -29,12 +29,12 @@
 {
 #if 0
-	/*
-	 * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
-	 * and 8 bytes for PPP, but need to have it on an 8byte boundary
-	 */
+        /*
+         * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
+         * and 8 bytes for PPP, but need to have it on an 8byte boundary
+         */
 #ifdef USE_PPP
-	if_maxlinkhdr = 48;
+        if_maxlinkhdr = 48;
 #else
-	if_maxlinkhdr = 40;
+        if_maxlinkhdr = 40;
 #endif
 #else
@@ -44,11 +44,11 @@
         if_queued = 0;
         if_thresh = 10;
-	if_mtu = 1500;
-	if_mru = 1500;
-	if_comp = IF_AUTOCOMP;
-	if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
-	if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
-        /*	sl_compress_init(&comp_s); */
-	next_m = &if_batchq;
+        if_mtu = 1500;
+        if_mru = 1500;
+        if_comp = IF_AUTOCOMP;
+        if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
+        if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
+        /*      sl_compress_init(&comp_s); */
+        next_m = &if_batchq;
 }
 
@@ -69,91 +69,91 @@
 if_output(PNATState pData, struct socket *so, struct mbuf *ifm)
 {
-	struct mbuf *ifq;
-	int on_fastq = 1;
-
-	DEBUG_CALL("if_output");
-	DEBUG_ARG("so = %lx", (long)so);
-	DEBUG_ARG("ifm = %lx", (long)ifm);
-
-	/*
-	 * First remove the mbuf from m_usedlist,
-	 * since we're gonna use m_next and m_prev ourselves
-	 * XXX Shouldn't need this, gotta change dtom() etc.
-	 */
-	if (ifm->m_flags & M_USEDLIST) {
-		remque(pData, ifm);
-		ifm->m_flags &= ~M_USEDLIST;
-	}
-
-	/*
-	 * See if there's already a batchq list for this session.
-	 * This can include an interactive session, which should go on fastq,
-	 * but gets too greedy... hence it'll be downgraded from fastq to batchq.
-	 * We mustn't put this packet back on the fastq (or we'll send it out of order)
-	 * XXX add cache here?
-	 */
-	for (ifq = if_batchq.ifq_prev; ifq != &if_batchq; ifq = ifq->ifq_prev) {
-		if (so == ifq->ifq_so) {
-			/* A match! */
-			ifm->ifq_so = so;
-			ifs_insque(ifm, ifq->ifs_prev);
-			goto diddit;
-		}
-	}
-
-	/* No match, check which queue to put it on */
-	if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
-		ifq = if_fastq.ifq_prev;
-		on_fastq = 1;
-		/*
-		 * Check if this packet is a part of the last
-		 * packet's session
-		 */
-		if (ifq->ifq_so == so) {
-			ifm->ifq_so = so;
-			ifs_insque(ifm, ifq->ifs_prev);
-			goto diddit;
-		}
-	} else
-		ifq = if_batchq.ifq_prev;
-
-	/* Create a new doubly linked list for this session */
-	ifm->ifq_so = so;
-	ifs_init(ifm);
-	insque(pData, ifm, ifq);
+        struct mbuf *ifq;
+        int on_fastq = 1;
+
+        DEBUG_CALL("if_output");
+        DEBUG_ARG("so = %lx", (long)so);
+        DEBUG_ARG("ifm = %lx", (long)ifm);
+
+        /*
+         * First remove the mbuf from m_usedlist,
+         * since we're gonna use m_next and m_prev ourselves
+         * XXX Shouldn't need this, gotta change dtom() etc.
+         */
+        if (ifm->m_flags & M_USEDLIST) {
+                remque(pData, ifm);
+                ifm->m_flags &= ~M_USEDLIST;
+        }
+
+        /*
+         * See if there's already a batchq list for this session.
+         * This can include an interactive session, which should go on fastq,
+         * but gets too greedy... hence it'll be downgraded from fastq to batchq.
+         * We mustn't put this packet back on the fastq (or we'll send it out of order)
+         * XXX add cache here?
+         */
+        for (ifq = if_batchq.ifq_prev; ifq != &if_batchq; ifq = ifq->ifq_prev) {
+                if (so == ifq->ifq_so) {
+                        /* A match! */
+                        ifm->ifq_so = so;
+                        ifs_insque(ifm, ifq->ifs_prev);
+                        goto diddit;
+                }
+        }
+
+        /* No match, check which queue to put it on */
+        if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
+                ifq = if_fastq.ifq_prev;
+                on_fastq = 1;
+                /*
+                 * Check if this packet is a part of the last
+                 * packet's session
+                 */
+                if (ifq->ifq_so == so) {
+                        ifm->ifq_so = so;
+                        ifs_insque(ifm, ifq->ifs_prev);
+                        goto diddit;
+                }
+        } else
+                ifq = if_batchq.ifq_prev;
+
+        /* Create a new doubly linked list for this session */
+        ifm->ifq_so = so;
+        ifs_init(ifm);
+        insque(pData, ifm, ifq);
 
 diddit:
-	++if_queued;
-
-	if (so) {
-		/* Update *_queued */
-		so->so_queued++;
-		so->so_nqueued++;
-		/*
-		 * Check if the interactive session should be downgraded to
-		 * the batchq.  A session is downgraded if it has queued 6
-		 * packets without pausing, and at least 3 of those packets
-		 * have been sent over the link
-		 * (XXX These are arbitrary numbers, probably not optimal..)
-		 */
-		if (on_fastq && ((so->so_nqueued >= 6) &&
-				 (so->so_nqueued - so->so_queued) >= 3)) {
-
-			/* Remove from current queue... */
-			remque(pData, ifm->ifs_next);
-
-			/* ...And insert in the new.  That'll teach ya! */
-			insque(pData, ifm->ifs_next, &if_batchq);
-		}
-	}
+        ++if_queued;
+
+        if (so) {
+                /* Update *_queued */
+                so->so_queued++;
+                so->so_nqueued++;
+                /*
+                 * Check if the interactive session should be downgraded to
+                 * the batchq.  A session is downgraded if it has queued 6
+                 * packets without pausing, and at least 3 of those packets
+                 * have been sent over the link
+                 * (XXX These are arbitrary numbers, probably not optimal..)
+                 */
+                if (on_fastq && ((so->so_nqueued >= 6) &&
+                                 (so->so_nqueued - so->so_queued) >= 3)) {
+
+                        /* Remove from current queue... */
+                        remque(pData, ifm->ifs_next);
+
+                        /* ...And insert in the new.  That'll teach ya! */
+                        insque(pData, ifm->ifs_next, &if_batchq);
+                }
+        }
 
 #ifndef FULL_BOLT
-	/*
-	 * This prevents us from malloc()ing too many mbufs
-	 */
-	if (link_up) {
-		/* if_start will check towrite */
-		if_start(pData);
-	}
+        /*
+         * This prevents us from malloc()ing too many mbufs
+         */
+        if (link_up) {
+                /* if_start will check towrite */
+                if_start(pData);
+        }
 #endif
 }
@@ -174,10 +174,10 @@
 if_start(PNATState pData)
 {
-	struct mbuf *ifm, *ifqt;
-
-	DEBUG_CALL("if_start");
-
-	if (if_queued == 0)
-	   return; /* Nothing to do */
+        struct mbuf *ifm, *ifqt;
+
+        DEBUG_CALL("if_start");
+
+        if (if_queued == 0)
+           return; /* Nothing to do */
 
  again:
@@ -186,44 +186,44 @@
             return;
 
-	/*
-	 * See which queue to get next packet from
-	 * If there's something in the fastq, select it immediately
-	 */
-	if (if_fastq.ifq_next != &if_fastq) {
-		ifm = if_fastq.ifq_next;
-	} else {
-		/* Nothing on fastq, see if next_m is valid */
-		if (next_m != &if_batchq)
-		   ifm = next_m;
-		else
-		   ifm = if_batchq.ifq_next;
-
-		/* Set which packet to send on next iteration */
-		next_m = ifm->ifq_next;
-	}
-	/* Remove it from the queue */
-	ifqt = ifm->ifq_prev;
-	remque(pData, ifm);
-	--if_queued;
-
-	/* If there are more packets for this session, re-queue them */
-	if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) {
-		insque(pData, ifm->ifs_next, ifqt);
-		ifs_remque(ifm);
-	}
-
-	/* Update so_queued */
-	if (ifm->ifq_so) {
-		if (--ifm->ifq_so->so_queued == 0)
-		   /* If there's no more queued, reset nqueued */
-		   ifm->ifq_so->so_nqueued = 0;
-	}
-
-	/* Encapsulate the packet for sending */
+        /*
+         * See which queue to get next packet from
+         * If there's something in the fastq, select it immediately
+         */
+        if (if_fastq.ifq_next != &if_fastq) {
+                ifm = if_fastq.ifq_next;
+        } else {
+                /* Nothing on fastq, see if next_m is valid */
+                if (next_m != &if_batchq)
+                   ifm = next_m;
+                else
+                   ifm = if_batchq.ifq_next;
+
+                /* Set which packet to send on next iteration */
+                next_m = ifm->ifq_next;
+        }
+        /* Remove it from the queue */
+        ifqt = ifm->ifq_prev;
+        remque(pData, ifm);
+        --if_queued;
+
+        /* If there are more packets for this session, re-queue them */
+        if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) {
+                insque(pData, ifm->ifs_next, ifqt);
+                ifs_remque(ifm);
+        }
+
+        /* Update so_queued */
+        if (ifm->ifq_so) {
+                if (--ifm->ifq_so->so_queued == 0)
+                   /* If there's no more queued, reset nqueued */
+                   ifm->ifq_so->so_nqueued = 0;
+        }
+
+        /* Encapsulate the packet for sending */
         if_encap(pData, (const uint8_t *)ifm->m_data, ifm->m_len);
 
         m_free(pData, ifm);
 
-	if (if_queued)
-	   goto again;
-}
+        if (if_queued)
+           goto again;
+}
Index: trunk/src/VBox/Devices/Network/slirp/if.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/if.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/if.h	(revision 14470)
@@ -9,22 +9,22 @@
 #define _IF_H_
 
-#define IF_COMPRESS	0x01	/* We want compression */
-#define IF_NOCOMPRESS	0x02	/* Do not do compression */
-#define IF_AUTOCOMP	0x04	/* Autodetect (default) */
-#define IF_NOCIDCOMP	0x08	/* CID compression */
+#define IF_COMPRESS     0x01    /* We want compression */
+#define IF_NOCOMPRESS   0x02    /* Do not do compression */
+#define IF_AUTOCOMP     0x04    /* Autodetect (default) */
+#define IF_NOCIDCOMP    0x08    /* CID compression */
 
 /* Needed for FreeBSD */
 #undef if_mtu
-extern int	if_mtu;
-extern int	if_mru;	/* MTU and MRU */
-extern int	if_comp;	/* Flags for compression */
-extern int	if_maxlinkhdr;
-extern int	if_queued;	/* Number of packets queued so far */
-extern int	if_thresh;	/* Number of packets queued before we start sending
-				 * (to prevent allocing too many mbufs) */
+extern int      if_mtu;
+extern int      if_mru; /* MTU and MRU */
+extern int      if_comp;        /* Flags for compression */
+extern int      if_maxlinkhdr;
+extern int      if_queued;      /* Number of packets queued so far */
+extern int      if_thresh;      /* Number of packets queued before we start sending
+                                 * (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 *next_m;
+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;
 
 #define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
@@ -32,18 +32,18 @@
 /* Interface statistics */
 struct slirp_ifstats {
-	u_int out_pkts;		/* Output packets */
-	u_int out_bytes;		/* Output bytes */
-	u_int out_errpkts;	/* Output Error Packets */
-	u_int out_errbytes;	/* Output Error Bytes */
-	u_int in_pkts;		/* Input packets */
-	u_int in_bytes;		/* Input bytes */
-	u_int in_errpkts;		/* Input Error Packets */
-	u_int in_errbytes;	/* Input Error Bytes */
-	
-	u_int bytes_saved;	/* Number of bytes that compression "saved" */
-				/* ie: number of bytes that didn't need to be sent over the link
-				 * because of compression */
-	
-	u_int in_mbad;		/* Bad incoming packets */
+        u_int out_pkts;         /* Output packets */
+        u_int out_bytes;                /* Output bytes */
+        u_int out_errpkts;      /* Output Error Packets */
+        u_int out_errbytes;     /* Output Error Bytes */
+        u_int in_pkts;          /* Input packets */
+        u_int in_bytes;         /* Input bytes */
+        u_int in_errpkts;               /* Input Error Packets */
+        u_int in_errbytes;      /* Input Error Bytes */
+        
+        u_int bytes_saved;      /* Number of bytes that compression "saved" */
+                                /* ie: number of bytes that didn't need to be sent over the link
+                                 * because of compression */
+        
+        u_int in_mbad;          /* Bad incoming packets */
 };
 
Index: trunk/src/VBox/Devices/Network/slirp/ip.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/ip.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)ip.h	8.1 (Berkeley) 6/10/93
+ *      @(#)ip.h        8.1 (Berkeley) 6/10/93
  * ip.h,v 1.3 1994/08/21 05:27:30 paul Exp
  */
@@ -76,5 +76,5 @@
  * Per RFC 791, September 1981.
  */
-#define	IPVERSION	4
+#define IPVERSION       4
 
 /*
@@ -86,119 +86,119 @@
  */
 #ifdef WORDS_BIGENDIAN
-	u_int ip_v:4,			/* version */
-		ip_hl:4;		/* header length */
+        u_int ip_v:4,                   /* version */
+                ip_hl:4;                /* header length */
 #else
 #ifdef _MSC_VER
-	u_int8_t ip_hl:4,		/* header length */
-#else
-	u_int ip_hl:4,		/* header length */
-#endif
-		ip_v:4;			/* version */
-#endif
-	u_int8_t ip_tos;			/* type of service */
-	u_int16_t	ip_len;			/* total length */
-	u_int16_t	ip_id;			/* identification */
-	u_int16_t	ip_off;			/* fragment offset field */
-#define	IP_DF 0x4000			/* don't fragment flag */
-#define	IP_MF 0x2000			/* more fragments flag */
-#define	IP_OFFMASK 0x1fff		/* mask for fragmenting bits */
-	u_int8_t ip_ttl;			/* time to live */
-	u_int8_t ip_p;			/* protocol */
-	u_int16_t	ip_sum;			/* checksum */
-	struct	in_addr ip_src,ip_dst;	/* source and dest address */
-};
-
-#define	IP_MAXPACKET	65535		/* maximum packet size */
+        u_int8_t ip_hl:4,               /* header length */
+#else
+        u_int ip_hl:4,          /* header length */
+#endif
+                ip_v:4;                 /* version */
+#endif
+        u_int8_t ip_tos;                        /* type of service */
+        u_int16_t       ip_len;                 /* total length */
+        u_int16_t       ip_id;                  /* identification */
+        u_int16_t       ip_off;                 /* fragment offset field */
+#define IP_DF 0x4000                    /* don't fragment flag */
+#define IP_MF 0x2000                    /* more fragments flag */
+#define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
+        u_int8_t ip_ttl;                        /* time to live */
+        u_int8_t ip_p;                  /* protocol */
+        u_int16_t       ip_sum;                 /* checksum */
+        struct  in_addr ip_src,ip_dst;  /* source and dest address */
+};
+
+#define IP_MAXPACKET    65535           /* maximum packet size */
 
 /*
  * Definitions for IP type of service (ip_tos)
  */
-#define	IPTOS_LOWDELAY		0x10
-#define	IPTOS_THROUGHPUT	0x08
-#define	IPTOS_RELIABILITY	0x04
+#define IPTOS_LOWDELAY          0x10
+#define IPTOS_THROUGHPUT        0x08
+#define IPTOS_RELIABILITY       0x04
 
 /*
  * Definitions for options.
  */
-#define	IPOPT_COPIED(o)		((o)&0x80)
-#define	IPOPT_CLASS(o)		((o)&0x60)
-#define	IPOPT_NUMBER(o)		((o)&0x1f)
-
-#define	IPOPT_CONTROL		0x00
-#define	IPOPT_RESERVED1		0x20
-#define	IPOPT_DEBMEAS		0x40
-#define	IPOPT_RESERVED2		0x60
-
-#define	IPOPT_EOL		0		/* end of option list */
-#define	IPOPT_NOP		1		/* no operation */
-
-#define	IPOPT_RR		7		/* record packet route */
-#define	IPOPT_TS		68		/* timestamp */
-#define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
-#define	IPOPT_LSRR		131		/* loose source route */
-#define	IPOPT_SATID		136		/* satnet id */
-#define	IPOPT_SSRR		137		/* strict source route */
+#define IPOPT_COPIED(o)         ((o)&0x80)
+#define IPOPT_CLASS(o)          ((o)&0x60)
+#define IPOPT_NUMBER(o)         ((o)&0x1f)
+
+#define IPOPT_CONTROL           0x00
+#define IPOPT_RESERVED1         0x20
+#define IPOPT_DEBMEAS           0x40
+#define IPOPT_RESERVED2         0x60
+
+#define IPOPT_EOL               0               /* end of option list */
+#define IPOPT_NOP               1               /* no operation */
+
+#define IPOPT_RR                7               /* record packet route */
+#define IPOPT_TS                68              /* timestamp */
+#define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
+#define IPOPT_LSRR              131             /* loose source route */
+#define IPOPT_SATID             136             /* satnet id */
+#define IPOPT_SSRR              137             /* strict source route */
 
 /*
  * Offsets to fields in options other than EOL and NOP.
  */
-#define	IPOPT_OPTVAL		0		/* option ID */
-#define	IPOPT_OLEN		1		/* option length */
-#define IPOPT_OFFSET		2		/* offset within option */
-#define	IPOPT_MINOFF		4		/* min value of above */
+#define IPOPT_OPTVAL            0               /* option ID */
+#define IPOPT_OLEN              1               /* option length */
+#define IPOPT_OFFSET            2               /* offset within option */
+#define IPOPT_MINOFF            4               /* min value of above */
 
 /*
  * Time stamp option structure.
  */
-struct	ip_timestamp {
-	u_int8_t	ipt_code;		/* IPOPT_TS */
-	u_int8_t	ipt_len;		/* size of structure (variable) */
-	u_int8_t	ipt_ptr;		/* index of current entry */
+struct  ip_timestamp {
+        u_int8_t        ipt_code;               /* IPOPT_TS */
+        u_int8_t        ipt_len;                /* size of structure (variable) */
+        u_int8_t        ipt_ptr;                /* index of current entry */
 /*
  * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
  */
 #ifdef WORDS_BIGENDIAN
-	u_int	ipt_oflw:4,		/* overflow counter */
-		ipt_flg:4;		/* flags, see below */
+        u_int   ipt_oflw:4,             /* overflow counter */
+                ipt_flg:4;              /* flags, see below */
 #else
 #ifdef _MSC_VER
-	u_int8_t ipt_flg:4,		/* flags, see below */
-#else
-	u_int	ipt_flg:4,		/* flags, see below */
-#endif
-		ipt_oflw:4;		/* overflow counter */
-#endif
-	union ipt_timestamp {
-		n_long	ipt_time[1];
-		struct	ipt_ta {
-			struct in_addr ipt_addr;
-			n_long ipt_time;
-		} ipt_ta[1];
-	} ipt_timestamp;
+        u_int8_t ipt_flg:4,             /* flags, see below */
+#else
+        u_int   ipt_flg:4,              /* flags, see below */
+#endif
+                ipt_oflw:4;             /* overflow counter */
+#endif
+        union ipt_timestamp {
+                n_long  ipt_time[1];
+                struct  ipt_ta {
+                        struct in_addr ipt_addr;
+                        n_long ipt_time;
+                } ipt_ta[1];
+        } ipt_timestamp;
 };
 
 /* flag bits for ipt_flg */
-#define	IPOPT_TS_TSONLY		0		/* timestamps only */
-#define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
-#define	IPOPT_TS_PRESPEC	3		/* specified modules only */
+#define IPOPT_TS_TSONLY         0               /* timestamps only */
+#define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC        3               /* specified modules only */
 
 /* bits for security (not byte swapped) */
-#define	IPOPT_SECUR_UNCLASS	0x0000
-#define	IPOPT_SECUR_CONFID	0xf135
-#define	IPOPT_SECUR_EFTO	0x789a
-#define	IPOPT_SECUR_MMMM	0xbc4d
-#define	IPOPT_SECUR_RESTR	0xaf13
-#define	IPOPT_SECUR_SECRET	0xd788
-#define	IPOPT_SECUR_TOPSECRET	0x6bc5
+#define IPOPT_SECUR_UNCLASS     0x0000
+#define IPOPT_SECUR_CONFID      0xf135
+#define IPOPT_SECUR_EFTO        0x789a
+#define IPOPT_SECUR_MMMM        0xbc4d
+#define IPOPT_SECUR_RESTR       0xaf13
+#define IPOPT_SECUR_SECRET      0xd788
+#define IPOPT_SECUR_TOPSECRET   0x6bc5
 
 /*
  * Internet implementation parameters.
  */
-#define	MAXTTL		255		/* maximum time to live (seconds) */
-#define	IPDEFTTL	64		/* default ttl, from RFC 1340 */
-#define	IPFRAGTTL	60		/* time to live for frags, slowhz */
-#define	IPTTLDEC	1		/* subtracted when forwarding */
-
-#define	IP_MSS		576		/* default maximum segment size */
+#define MAXTTL          255             /* maximum time to live (seconds) */
+#define IPDEFTTL        64              /* default ttl, from RFC 1340 */
+#define IPFRAGTTL       60              /* time to live for frags, slowhz */
+#define IPTTLDEC        1               /* subtracted when forwarding */
+
+#define IP_MSS          576             /* default maximum segment size */
 
 #ifdef HAVE_SYS_TYPES32_H  /* Overcome some Solaris 2.x junk */
@@ -224,10 +224,10 @@
  */
 struct ipovly {
-	caddr32_t	ih_next, ih_prev;	/* for protocol sequence q's */
-	u_int8_t	ih_x1;			/* (unused) */
-	u_int8_t	ih_pr;			/* protocol */
-	u_int16_t	ih_len;			/* protocol length */
-	struct	in_addr ih_src;		/* source internet address */
-	struct	in_addr ih_dst;		/* destination internet address */
+        caddr32_t       ih_next, ih_prev;       /* for protocol sequence q's */
+        u_int8_t        ih_x1;                  /* (unused) */
+        u_int8_t        ih_pr;                  /* protocol */
+        u_int16_t       ih_len;                 /* protocol length */
+        struct  in_addr ih_src;         /* source internet address */
+        struct  in_addr ih_dst;         /* destination internet address */
 };
 
@@ -241,13 +241,13 @@
 struct ipq_t {
 #ifndef VBOX_WITH_BSD_REASS
-	ipqp_32 next,prev;	/* to other reass headers */
+        ipqp_32 next,prev;      /* to other reass headers */
 #else  /* VBOX_WITH_BSD_REASS */
         TAILQ_ENTRY(ipq_t) ipq_list;
 #endif /* VBOX_WITH_BSD_REASS */
-	u_int8_t	ipq_ttl;		/* time for reass q to live */
-	u_int8_t	ipq_p;			/* protocol of this fragment */
-	u_int16_t	ipq_id;			/* sequence id for reassembly */
+        u_int8_t        ipq_ttl;                /* time for reass q to live */
+        u_int8_t        ipq_p;                  /* protocol of this fragment */
+        u_int16_t       ipq_id;                 /* sequence id for reassembly */
 #ifndef VBOX_WITH_BSD_REASS
-	ipasfragp_32 ipq_next,ipq_prev;         /* to ip headers of fragments */
+        ipasfragp_32 ipq_next,ipq_prev;         /* to ip headers of fragments */
 #else  /* VBOX_WITH_BSD_REASS */
         u_int8_t        ipq_nfrags;             /* # of fragments in this packet */
@@ -255,5 +255,5 @@
 #endif /* VBOX_WITH_BSD_REASS */
 
-	struct	in_addr ipq_src,ipq_dst;
+        struct  in_addr ipq_src,ipq_dst;
 };
 
@@ -275,30 +275,30 @@
  * Note: ipf_next must be at same offset as ipq_next above
  */
-struct	ipasfrag {
+struct  ipasfrag {
 #ifdef WORDS_BIGENDIAN
-	u_int	ip_v:4,
- 		ip_hl:4;
+        u_int   ip_v:4,
+                ip_hl:4;
 #else
 #ifdef _MSC_VER
-	u_int8_t	ip_hl:4,
-#else
-	u_int	ip_hl:4,
-#endif
-		ip_v:4;
+        u_int8_t        ip_hl:4,
+#else
+        u_int   ip_hl:4,
+#endif
+                ip_v:4;
 #endif
                                         /* BUG : u_int changed to u_int8_t.
                                          * sizeof(u_int)==4 on linux 2.0
-					 */
-        u_int8_t ipf_mff;		/* XXX overlays ip_tos: use low bit
-					 * to avoid destroying tos (PPPDTRuu);
-					 * copied from (ip_off&IP_MF) */
-	u_int16_t	ip_len;
-	u_int16_t	ip_id;
-	u_int16_t	ip_off;
-	u_int8_t	ip_ttl;
-	u_int8_t	ip_p;
-	u_int16_t	ip_sum;
-	ipasfragp_32 ipf_next;		/* next fragment */
-	ipasfragp_32 ipf_prev;		/* previous fragment */
+                                         */
+        u_int8_t ipf_mff;               /* XXX overlays ip_tos: use low bit
+                                         * to avoid destroying tos (PPPDTRuu);
+                                         * copied from (ip_off&IP_MF) */
+        u_int16_t       ip_len;
+        u_int16_t       ip_id;
+        u_int16_t       ip_off;
+        u_int8_t        ip_ttl;
+        u_int8_t        ip_p;
+        u_int16_t       ip_sum;
+        ipasfragp_32 ipf_next;          /* next fragment */
+        ipasfragp_32 ipf_prev;          /* previous fragment */
 };
 
@@ -309,9 +309,9 @@
  * is in m_len.
  */
-#define MAX_IPOPTLEN	40
+#define MAX_IPOPTLEN    40
 
 struct ipoption {
-	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
-	int8_t	ipopt_list[MAX_IPOPTLEN];	/* options proper */
+        struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
+        int8_t  ipopt_list[MAX_IPOPTLEN];       /* options proper */
 };
 
@@ -321,32 +321,32 @@
  */
 
-struct	ipstat_t {
-	u_long	ips_total;		/* total packets received */
-	u_long	ips_badsum;		/* checksum bad */
-	u_long	ips_tooshort;		/* packet too short */
-	u_long	ips_toosmall;		/* not enough data */
-	u_long	ips_badhlen;		/* ip header length < data size */
-	u_long	ips_badlen;		/* ip length < ip header length */
-	u_long	ips_fragments;		/* fragments received */
-	u_long	ips_fragdropped;	/* frags dropped (dups, out of space) */
-	u_long	ips_fragtimeout;	/* fragments timed out */
-	u_long	ips_forward;		/* packets forwarded */
-	u_long	ips_cantforward;	/* packets rcvd for unreachable dest */
-	u_long	ips_redirectsent;	/* packets forwarded on same net */
-	u_long	ips_noproto;		/* unknown or unsupported protocol */
-	u_long	ips_delivered;		/* datagrams delivered to upper level*/
-	u_long	ips_localout;		/* total ip packets generated here */
-	u_long	ips_odropped;		/* lost packets due to nobufs, etc. */
-	u_long	ips_reassembled;	/* total packets reassembled ok */
-	u_long	ips_fragmented;		/* datagrams successfully fragmented */
-	u_long	ips_ofragments;		/* output fragments created */
-	u_long	ips_cantfrag;		/* don't fragment flag was set, etc. */
-	u_long	ips_badoptions;		/* error in option processing */
-	u_long	ips_noroute;		/* packets discarded due to no route */
-	u_long	ips_badvers;		/* ip version != 4 */
-	u_long	ips_rawout;		/* total raw ip packets generated */
-	u_long	ips_unaligned;		/* times the ip packet was not aligned */
-};
-
-
-#endif
+struct  ipstat_t {
+        u_long  ips_total;              /* total packets received */
+        u_long  ips_badsum;             /* checksum bad */
+        u_long  ips_tooshort;           /* packet too short */
+        u_long  ips_toosmall;           /* not enough data */
+        u_long  ips_badhlen;            /* ip header length < data size */
+        u_long  ips_badlen;             /* ip length < ip header length */
+        u_long  ips_fragments;          /* fragments received */
+        u_long  ips_fragdropped;        /* frags dropped (dups, out of space) */
+        u_long  ips_fragtimeout;        /* fragments timed out */
+        u_long  ips_forward;            /* packets forwarded */
+        u_long  ips_cantforward;        /* packets rcvd for unreachable dest */
+        u_long  ips_redirectsent;       /* packets forwarded on same net */
+        u_long  ips_noproto;            /* unknown or unsupported protocol */
+        u_long  ips_delivered;          /* datagrams delivered to upper level*/
+        u_long  ips_localout;           /* total ip packets generated here */
+        u_long  ips_odropped;           /* lost packets due to nobufs, etc. */
+        u_long  ips_reassembled;        /* total packets reassembled ok */
+        u_long  ips_fragmented;         /* datagrams successfully fragmented */
+        u_long  ips_ofragments;         /* output fragments created */
+        u_long  ips_cantfrag;           /* don't fragment flag was set, etc. */
+        u_long  ips_badoptions;         /* error in option processing */
+        u_long  ips_noroute;            /* packets discarded due to no route */
+        u_long  ips_badvers;            /* ip version != 4 */
+        u_long  ips_rawout;             /* total raw ip packets generated */
+        u_long  ips_unaligned;          /* times the ip packet was not aligned */
+};
+
+
+#endif
Index: trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip_icmp.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/ip_icmp.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)ip_icmp.c	8.2 (Berkeley) 1/4/94
+ *      @(#)ip_icmp.c   8.2 (Berkeley) 1/4/94
  * ip_icmp.c,v 1.7 1995/05/30 08:09:42 rgrimes Exp
  */
@@ -46,11 +46,11 @@
 static const int icmp_flush[19] = {
 /*  ECHO REPLY (0)  */   0,
-		         1,
-		         1,
+                         1,
+                         1,
 /* DEST UNREACH (3) */   1,
 /* SOURCE QUENCH (4)*/   1,
 /* REDIRECT (5) */       1,
-		         1,
-		         1,
+                         1,
+                         1,
 /* ECHO (8) */           0,
 /* ROUTERADVERT (9) */   1,
@@ -104,5 +104,5 @@
   m->m_data -= hlen;
 
-  /*	icmpstat.icps_inhist[icp->icmp_type]++; */
+  /*    icmpstat.icps_inhist[icp->icmp_type]++; */
   /* code = icp->icmp_code; */
 
@@ -111,5 +111,5 @@
   case ICMP_ECHO:
     icp->icmp_type = ICMP_ECHOREPLY;
-    ip->ip_len += hlen;	             /* since ip_input subtracts this */
+    ip->ip_len += hlen;              /* since ip_input subtracts this */
     if (ip->ip_dst.s_addr == alias_addr.s_addr) {
       icmp_reflect(pData, m);
@@ -119,9 +119,9 @@
       if ((so = socreate()) == NULL) goto freeit;
       if(udp_attach(pData, so) == -1) {
-	DEBUG_MISC((dfd,"icmp_input udp_attach errno = %d-%s\n",
-		    errno,strerror(errno)));
-	sofree(pData, so);
-	m_free(pData, m);
-	goto end_error;
+        DEBUG_MISC((dfd,"icmp_input udp_attach errno = %d-%s\n",
+                    errno,strerror(errno)));
+        sofree(pData, so);
+        m_free(pData, m);
+        goto end_error;
       }
       so->so_m = m;
@@ -137,24 +137,24 @@
       addr.sin_family = AF_INET;
       if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) {
-	/* It's an alias */
-	switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) {
-	case CTL_DNS:
-	  addr.sin_addr = dns_addr;
-	  break;
-	case CTL_ALIAS:
-	default:
-	  addr.sin_addr = loopback_addr;
-	  break;
-	}
+        /* It's an alias */
+        switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) {
+        case CTL_DNS:
+          addr.sin_addr = dns_addr;
+          break;
+        case CTL_ALIAS:
+        default:
+          addr.sin_addr = loopback_addr;
+          break;
+        }
       } else {
-	addr.sin_addr = so->so_faddr;
+        addr.sin_addr = so->so_faddr;
       }
       addr.sin_port = so->so_fport;
       if(sendto(so->s, icmp_ping_msg, strlen(icmp_ping_msg), 0,
-		(struct sockaddr *)&addr, sizeof(addr)) == -1) {
-	DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
-		    errno,strerror(errno)));
-	icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
-	udp_detach(pData, so);
+                (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+        DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
+                    errno,strerror(errno)));
+        icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
+        udp_detach(pData, so);
       }
     } /* if ip->ip_dst.s_addr == alias_addr.s_addr */
@@ -184,11 +184,11 @@
 
 /*
- *	Send an ICMP message in response to a situation
+ *      Send an ICMP message in response to a situation
  *
- *	RFC 1122: 3.2.2	MUST send at least the IP header and 8 bytes of header. MAY send more (we do).
- *			MUST NOT change this header information.
- *			MUST NOT reply to a multicast/broadcast IP address.
- *			MUST NOT reply to a multicast/broadcast MAC address.
- *			MUST reply to only the first fragment.
+ *      RFC 1122: 3.2.2 MUST send at least the IP header and 8 bytes of header. MAY send more (we do).
+ *                      MUST NOT change this header information.
+ *                      MUST NOT reply to a multicast/broadcast IP address.
+ *                      MUST NOT reply to a multicast/broadcast MAC address.
+ *                      MUST reply to only the first fragment.
  */
 /*
@@ -232,6 +232,6 @@
     icp = (struct icmp *)((char *)ip + shlen);
     /*
-     *	Assume any unknown ICMP type is an error. This isn't
-     *	specified by the RFC, but think about it..
+     *  Assume any unknown ICMP type is an error. This isn't
+     *  specified by the RFC, but think about it..
      */
     if(icp->icmp_type>18 || icmp_flush[icp->icmp_type]) goto end_error;
@@ -345,5 +345,5 @@
      */
     memmove((caddr_t)(ip + 1), (caddr_t)ip + hlen,
-	    (unsigned )(m->m_len - hlen));
+            (unsigned )(m->m_len - hlen));
     hlen -= optlen;
     ip->ip_hl = hlen >> 2;
Index: trunk/src/VBox/Devices/Network/slirp/ip_input.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip_input.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/ip_input.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)ip_input.c	8.2 (Berkeley) 1/4/94
+ *      @(#)ip_input.c  8.2 (Berkeley) 1/4/94
  * ip_input.c,v 1.11 1994/11/16 10:17:08 jkh Exp
  */
@@ -55,5 +55,5 @@
 {
 #ifndef VBOX_WITH_BSD_REASS
-	ipq.next = ipq.prev = ptr_to_u32(pData, &ipq);
+        ipq.next = ipq.prev = ptr_to_u32(pData, &ipq);
 #else /* !VBOX_WITH_BSD_REASS */
         int i = 0;
@@ -64,7 +64,7 @@
         nipq = 0;
 #endif /* VBOX_WITH_BSD_REASS */
-	ip_currid = tt.tv_sec & 0xffff;
-	udp_init(pData);
-	tcp_init(pData);
+        ip_currid = tt.tv_sec & 0xffff;
+        udp_init(pData);
+        tcp_init(pData);
 }
 
@@ -76,138 +76,138 @@
 ip_input(PNATState pData, struct mbuf *m)
 {
-	register struct ip *ip;
-	int hlen;
-
-	DEBUG_CALL("ip_input");
-	DEBUG_ARG("m = %lx", (long)m);
-	DEBUG_ARG("m_len = %d", m->m_len);
-
-	ipstat.ips_total++;
-
-	if (m->m_len < sizeof (struct ip)) {
-		ipstat.ips_toosmall++;
-		return;
-	}
-
-	ip = mtod(m, struct ip *);
-
-	if (ip->ip_v != IPVERSION) {
-		ipstat.ips_badvers++;
-		goto bad;
-	}
-
-	hlen = ip->ip_hl << 2;
-	if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
-	  ipstat.ips_badhlen++;                     /* or packet too short */
-	  goto bad;
-	}
+        register struct ip *ip;
+        int hlen;
+
+        DEBUG_CALL("ip_input");
+        DEBUG_ARG("m = %lx", (long)m);
+        DEBUG_ARG("m_len = %d", m->m_len);
+
+        ipstat.ips_total++;
+
+        if (m->m_len < sizeof (struct ip)) {
+                ipstat.ips_toosmall++;
+                return;
+        }
+
+        ip = mtod(m, struct ip *);
+
+        if (ip->ip_v != IPVERSION) {
+                ipstat.ips_badvers++;
+                goto bad;
+        }
+
+        hlen = ip->ip_hl << 2;
+        if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
+          ipstat.ips_badhlen++;                     /* or packet too short */
+          goto bad;
+        }
 
         /* keep ip header intact for ICMP reply
-	 * ip->ip_sum = cksum(m, hlen);
-	 * if (ip->ip_sum) {
-	 */
-	if(cksum(m,hlen)) {
-	  ipstat.ips_badsum++;
-	  goto bad;
-	}
-
-	/*
-	 * Convert fields to host representation.
-	 */
-	NTOHS(ip->ip_len);
-	if (ip->ip_len < hlen) {
-		ipstat.ips_badlen++;
-		goto bad;
-	}
-	NTOHS(ip->ip_id);
-	NTOHS(ip->ip_off);
-
-	/*
-	 * Check that the amount of data in the buffers
-	 * is as at least much as the IP header would have us expect.
-	 * Trim mbufs if longer than we expect.
-	 * Drop packet if shorter than we expect.
-	 */
-	if (m->m_len < ip->ip_len) {
-		ipstat.ips_tooshort++;
-		goto bad;
-	}
-	/* Should drop packet if mbuf too long? hmmm... */
-	if (m->m_len > ip->ip_len)
-	   m_adj(m, ip->ip_len - m->m_len);
-
-	/* check ip_ttl for a correct ICMP reply */
-	if(ip->ip_ttl==0 || ip->ip_ttl==1) {
-	  icmp_error(pData, m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");
-	  goto bad;
-	}
-
-	/*
-	 * Process options and, if not destined for us,
-	 * ship it on.  ip_dooptions returns 1 when an
-	 * error was detected (causing an icmp message
-	 * to be sent and the original packet to be freed).
-	 */
+         * ip->ip_sum = cksum(m, hlen);
+         * if (ip->ip_sum) {
+         */
+        if(cksum(m,hlen)) {
+          ipstat.ips_badsum++;
+          goto bad;
+        }
+
+        /*
+         * Convert fields to host representation.
+         */
+        NTOHS(ip->ip_len);
+        if (ip->ip_len < hlen) {
+                ipstat.ips_badlen++;
+                goto bad;
+        }
+        NTOHS(ip->ip_id);
+        NTOHS(ip->ip_off);
+
+        /*
+         * Check that the amount of data in the buffers
+         * is as at least much as the IP header would have us expect.
+         * Trim mbufs if longer than we expect.
+         * Drop packet if shorter than we expect.
+         */
+        if (m->m_len < ip->ip_len) {
+                ipstat.ips_tooshort++;
+                goto bad;
+        }
+        /* Should drop packet if mbuf too long? hmmm... */
+        if (m->m_len > ip->ip_len)
+           m_adj(m, ip->ip_len - m->m_len);
+
+        /* check ip_ttl for a correct ICMP reply */
+        if(ip->ip_ttl==0 || ip->ip_ttl==1) {
+          icmp_error(pData, m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");
+          goto bad;
+        }
+
+        /*
+         * Process options and, if not destined for us,
+         * ship it on.  ip_dooptions returns 1 when an
+         * error was detected (causing an icmp message
+         * to be sent and the original packet to be freed).
+         */
 /* We do no IP options */
-/*	if (hlen > sizeof (struct ip) && ip_dooptions(m))
- *		goto next;
- */
-	/*
-	 * If offset or IP_MF are set, must reassemble.
-	 * Otherwise, nothing need be done.
-	 * (We could look in the reassembly queue to see
-	 * if the packet was previously fragmented,
-	 * but it's not worth the time; just let them time out.)
-	 *
-	 * XXX This should fail, don't fragment yet
-	 */
+/*      if (hlen > sizeof (struct ip) && ip_dooptions(m))
+ *              goto next;
+ */
+        /*
+         * If offset or IP_MF are set, must reassemble.
+         * Otherwise, nothing need be done.
+         * (We could look in the reassembly queue to see
+         * if the packet was previously fragmented,
+         * but it's not worth the time; just let them time out.)
+         *
+         * XXX This should fail, don't fragment yet
+         */
 #ifndef VBOX_WITH_BSD_REASS
-	if (ip->ip_off &~ IP_DF) {
-	  register struct ipq_t *fp;
-		/*
-		 * Look for queue of fragments
-		 * of this datagram.
-		 */
-		for (fp = u32_to_ptr(pData, ipq.next, struct ipq_t *); fp != &ipq;
-		     fp = u32_to_ptr(pData, fp->next, struct ipq_t *))
-		  if (ip->ip_id == fp->ipq_id &&
-		      ip->ip_src.s_addr == fp->ipq_src.s_addr &&
-		      ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
-		      ip->ip_p == fp->ipq_p)
-		    goto found;
-		fp = 0;
-	found:
-
-		/*
-		 * Adjust ip_len to not reflect header,
-		 * set ip_mff if more fragments are expected,
-		 * convert offset of this to bytes.
-		 */
-		ip->ip_len -= hlen;
-		if (ip->ip_off & IP_MF)
-		  ((struct ipasfrag *)ip)->ipf_mff |= 1;
-		else
-		  ((struct ipasfrag *)ip)->ipf_mff &= ~1;
-
-		ip->ip_off <<= 3;
-
-		/*
-		 * If datagram marked as having more fragments
-		 * or if this is not the first fragment,
-		 * attempt reassembly; if it succeeds, proceed.
-		 */
-		if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) {
-			ipstat.ips_fragments++;
-			ip = ip_reass(pData, (struct ipasfrag *)ip, fp);
-			if (ip == 0)
-				return;
-			ipstat.ips_reassembled++;
-			m = dtom(pData, ip);
-		} else
-			if (fp)
-		   	   ip_freef(pData, fp);
-
-	} else
-		ip->ip_len -= hlen;
+        if (ip->ip_off &~ IP_DF) {
+          register struct ipq_t *fp;
+                /*
+                 * Look for queue of fragments
+                 * of this datagram.
+                 */
+                for (fp = u32_to_ptr(pData, ipq.next, struct ipq_t *); fp != &ipq;
+                     fp = u32_to_ptr(pData, fp->next, struct ipq_t *))
+                  if (ip->ip_id == fp->ipq_id &&
+                      ip->ip_src.s_addr == fp->ipq_src.s_addr &&
+                      ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
+                      ip->ip_p == fp->ipq_p)
+                    goto found;
+                fp = 0;
+        found:
+
+                /*
+                 * Adjust ip_len to not reflect header,
+                 * set ip_mff if more fragments are expected,
+                 * convert offset of this to bytes.
+                 */
+                ip->ip_len -= hlen;
+                if (ip->ip_off & IP_MF)
+                  ((struct ipasfrag *)ip)->ipf_mff |= 1;
+                else
+                  ((struct ipasfrag *)ip)->ipf_mff &= ~1;
+
+                ip->ip_off <<= 3;
+
+                /*
+                 * If datagram marked as having more fragments
+                 * or if this is not the first fragment,
+                 * attempt reassembly; if it succeeds, proceed.
+                 */
+                if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) {
+                        ipstat.ips_fragments++;
+                        ip = ip_reass(pData, (struct ipasfrag *)ip, fp);
+                        if (ip == 0)
+                                return;
+                        ipstat.ips_reassembled++;
+                        m = dtom(pData, ip);
+                } else
+                        if (fp)
+                           ip_freef(pData, fp);
+
+        } else
+                ip->ip_len -= hlen;
 #else /* !VBOX_WITH_BSD_REASS */
         if (ip->ip_off & (IP_MF | IP_OFFMASK)) {
@@ -219,29 +219,29 @@
         }
         else
-		ip->ip_len -= hlen;
+                ip->ip_len -= hlen;
 #endif /* VBOX_WITH_BSD_REASS */
 
-	/*
-	 * Switch out to protocol's input routine.
-	 */
-	ipstat.ips_delivered++;
-	switch (ip->ip_p) {
-	 case IPPROTO_TCP:
-		tcp_input(pData, m, hlen, (struct socket *)NULL);
-		break;
-	 case IPPROTO_UDP:
-		udp_input(pData, m, hlen);
-		break;
-	 case IPPROTO_ICMP:
-		icmp_input(pData, m, hlen);
-		break;
-	 default:
-		ipstat.ips_noproto++;
-		m_free(pData, m);
-	}
-	return;
+        /*
+         * Switch out to protocol's input routine.
+         */
+        ipstat.ips_delivered++;
+        switch (ip->ip_p) {
+         case IPPROTO_TCP:
+                tcp_input(pData, m, hlen, (struct socket *)NULL);
+                break;
+         case IPPROTO_UDP:
+                udp_input(pData, m, hlen);
+                break;
+         case IPPROTO_ICMP:
+                icmp_input(pData, m, hlen);
+                break;
+         default:
+                ipstat.ips_noproto++;
+                m_free(pData, m);
+        }
+        return;
 bad:
-	m_freem(pData, m);
-	return;
+        m_freem(pData, m);
+        return;
 }
 
@@ -256,152 +256,152 @@
 ip_reass(PNATState pData, register struct ipasfrag *ip, register struct ipq_t *fp)
 {
-	register struct mbuf *m = dtom(pData, ip);
-	register struct ipasfrag *q;
-	int hlen = ip->ip_hl << 2;
-	int i, next;
-
-	DEBUG_CALL("ip_reass");
-	DEBUG_ARG("ip = %lx", (long)ip);
-	DEBUG_ARG("fp = %lx", (long)fp);
-	DEBUG_ARG("m = %lx", (long)m);
-
-	/*
-	 * Presence of header sizes in mbufs
-	 * would confuse code below.
+        register struct mbuf *m = dtom(pData, ip);
+        register struct ipasfrag *q;
+        int hlen = ip->ip_hl << 2;
+        int i, next;
+
+        DEBUG_CALL("ip_reass");
+        DEBUG_ARG("ip = %lx", (long)ip);
+        DEBUG_ARG("fp = %lx", (long)fp);
+        DEBUG_ARG("m = %lx", (long)m);
+
+        /*
+         * Presence of header sizes in mbufs
+         * would confuse code below.
          * Fragment m_data is concatenated.
-	 */
-	m->m_data += hlen;
-	m->m_len -= hlen;
-
-	/*
-	 * If first fragment to arrive, create a reassembly queue.
-	 */
-	if (fp == 0) {
-	  struct mbuf *t;
-	  if ((t = m_get(pData)) == NULL) goto dropfrag;
-	  fp = mtod(t, struct ipq_t *);
-	  insque_32(pData, fp, &ipq);
-	  fp->ipq_ttl = IPFRAGTTL;
-	  fp->ipq_p = ip->ip_p;
-	  fp->ipq_id = ip->ip_id;
-	  fp->ipq_next = fp->ipq_prev = ptr_to_u32(pData, (struct ipasfrag *)fp);
-	  fp->ipq_src = ((struct ip *)ip)->ip_src;
-	  fp->ipq_dst = ((struct ip *)ip)->ip_dst;
-	  q = (struct ipasfrag *)fp;
-	  goto insert;
-	}
-
-	/*
-	 * Find a segment which begins after this one does.
-	 */
-	for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
-	    q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *))
-		if (q->ip_off > ip->ip_off)
-			break;
-
-	/*
-	 * If there is a preceding segment, it may provide some of
-	 * our data already.  If so, drop the data from the incoming
-	 * segment.  If it provides all of our data, drop us.
-	 */
-	if (u32_to_ptr(pData, q->ipf_prev, struct ipq_t *) != fp) {
-		i = (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *))->ip_off +
-		  (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *))->ip_len - ip->ip_off;
-		if (i > 0) {
-			if (i >= ip->ip_len)
-				goto dropfrag;
-			m_adj(dtom(pData, ip), i);
-			ip->ip_off += i;
-			ip->ip_len -= i;
-		}
-	}
-
-	/*
-	 * While we overlap succeeding segments trim them or,
-	 * if they are completely covered, dequeue them.
-	 */
-	while (q != (struct ipasfrag *)fp && ip->ip_off + ip->ip_len > q->ip_off) {
-		i = (ip->ip_off + ip->ip_len) - q->ip_off;
-		if (i < q->ip_len) {
-			q->ip_len -= i;
-			q->ip_off += i;
-			m_adj(dtom(pData, q), i);
-			break;
-		}
-		q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
-		m_freem(pData, dtom(pData, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *)));
-		ip_deq(pData, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *));
-	}
+         */
+        m->m_data += hlen;
+        m->m_len -= hlen;
+
+        /*
+         * If first fragment to arrive, create a reassembly queue.
+         */
+        if (fp == 0) {
+          struct mbuf *t;
+          if ((t = m_get(pData)) == NULL) goto dropfrag;
+          fp = mtod(t, struct ipq_t *);
+          insque_32(pData, fp, &ipq);
+          fp->ipq_ttl = IPFRAGTTL;
+          fp->ipq_p = ip->ip_p;
+          fp->ipq_id = ip->ip_id;
+          fp->ipq_next = fp->ipq_prev = ptr_to_u32(pData, (struct ipasfrag *)fp);
+          fp->ipq_src = ((struct ip *)ip)->ip_src;
+          fp->ipq_dst = ((struct ip *)ip)->ip_dst;
+          q = (struct ipasfrag *)fp;
+          goto insert;
+        }
+
+        /*
+         * Find a segment which begins after this one does.
+         */
+        for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
+            q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *))
+                if (q->ip_off > ip->ip_off)
+                        break;
+
+        /*
+         * If there is a preceding segment, it may provide some of
+         * our data already.  If so, drop the data from the incoming
+         * segment.  If it provides all of our data, drop us.
+         */
+        if (u32_to_ptr(pData, q->ipf_prev, struct ipq_t *) != fp) {
+                i = (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *))->ip_off +
+                  (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *))->ip_len - ip->ip_off;
+                if (i > 0) {
+                        if (i >= ip->ip_len)
+                                goto dropfrag;
+                        m_adj(dtom(pData, ip), i);
+                        ip->ip_off += i;
+                        ip->ip_len -= i;
+                }
+        }
+
+        /*
+         * While we overlap succeeding segments trim them or,
+         * if they are completely covered, dequeue them.
+         */
+        while (q != (struct ipasfrag *)fp && ip->ip_off + ip->ip_len > q->ip_off) {
+                i = (ip->ip_off + ip->ip_len) - q->ip_off;
+                if (i < q->ip_len) {
+                        q->ip_len -= i;
+                        q->ip_off += i;
+                        m_adj(dtom(pData, q), i);
+                        break;
+                }
+                q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
+                m_freem(pData, dtom(pData, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *)));
+                ip_deq(pData, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *));
+        }
 
 insert:
-	/*
-	 * Stick new segment in its place;
-	 * check for complete reassembly.
-	 */
-	ip_enq(pData, ip, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *));
-	next = 0;
-	for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
-	     q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *)) {
-		if (q->ip_off != next)
-			return (0);
-		next += q->ip_len;
-	}
-	if (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *)->ipf_mff & 1)
-		return (0);
-
-	/*
-	 * Reassembly is complete; concatenate fragments.
-	 */
-	q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *);
-	m = dtom(pData, q);
-
-	q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
-	while (q != (struct ipasfrag *)fp) {
-	  struct mbuf *t;
-	  t = dtom(pData, q);
-	  q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
-	  m_cat(pData, m, t);
-	}
-
-	/*
-	 * Create header for new ip packet by
-	 * modifying header of first packet;
-	 * dequeue and discard fragment reassembly header.
-	 * Make header visible.
-	 */
-	ip = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *);
-
-	/*
-	 * If the fragments concatenated to an mbuf that's
-	 * bigger than the total size of the fragment, then and
-	 * m_ext buffer was alloced. But fp->ipq_next points to
-	 * the old buffer (in the mbuf), so we must point ip
-	 * into the new buffer.
-	 */
-	if (m->m_flags & M_EXT) {
-	  int delta;
-	  delta = (char *)ip - m->m_dat;
-	  ip = (struct ipasfrag *)(m->m_ext + delta);
-	}
-
-	/* DEBUG_ARG("ip = %lx", (long)ip);
-	 * ip=(struct ipasfrag *)m->m_data; */
-
-	ip->ip_len = next;
-	ip->ipf_mff &= ~1;
-	((struct ip *)ip)->ip_src = fp->ipq_src;
-	((struct ip *)ip)->ip_dst = fp->ipq_dst;
-	remque_32(pData, fp);
-	(void) m_free(pData, dtom(pData, fp));
-	m = dtom(pData, ip);
-	m->m_len += (ip->ip_hl << 2);
-	m->m_data -= (ip->ip_hl << 2);
-
-	return ((struct ip *)ip);
+        /*
+         * Stick new segment in its place;
+         * check for complete reassembly.
+         */
+        ip_enq(pData, ip, u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *));
+        next = 0;
+        for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
+             q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *)) {
+                if (q->ip_off != next)
+                        return (0);
+                next += q->ip_len;
+        }
+        if (u32_to_ptr(pData, q->ipf_prev, struct ipasfrag *)->ipf_mff & 1)
+                return (0);
+
+        /*
+         * Reassembly is complete; concatenate fragments.
+         */
+        q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *);
+        m = dtom(pData, q);
+
+        q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
+        while (q != (struct ipasfrag *)fp) {
+          struct mbuf *t;
+          t = dtom(pData, q);
+          q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
+          m_cat(pData, m, t);
+        }
+
+        /*
+         * Create header for new ip packet by
+         * modifying header of first packet;
+         * dequeue and discard fragment reassembly header.
+         * Make header visible.
+         */
+        ip = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *);
+
+        /*
+         * If the fragments concatenated to an mbuf that's
+         * bigger than the total size of the fragment, then and
+         * m_ext buffer was alloced. But fp->ipq_next points to
+         * the old buffer (in the mbuf), so we must point ip
+         * into the new buffer.
+         */
+        if (m->m_flags & M_EXT) {
+          int delta;
+          delta = (char *)ip - m->m_dat;
+          ip = (struct ipasfrag *)(m->m_ext + delta);
+        }
+
+        /* DEBUG_ARG("ip = %lx", (long)ip);
+         * ip=(struct ipasfrag *)m->m_data; */
+
+        ip->ip_len = next;
+        ip->ipf_mff &= ~1;
+        ((struct ip *)ip)->ip_src = fp->ipq_src;
+        ((struct ip *)ip)->ip_dst = fp->ipq_dst;
+        remque_32(pData, fp);
+        (void) m_free(pData, dtom(pData, fp));
+        m = dtom(pData, ip);
+        m->m_len += (ip->ip_hl << 2);
+        m->m_data -= (ip->ip_hl << 2);
+
+        return ((struct ip *)ip);
 
 dropfrag:
-	ipstat.ips_fragdropped++;
-	m_freem(pData, m);
-	return (0);
+        ipstat.ips_fragdropped++;
+        m_freem(pData, m);
+        return (0);
 }
 
@@ -413,14 +413,14 @@
 ip_freef(PNATState pData, struct ipq_t *fp)
 {
-	register struct ipasfrag *q, *p;
-
-	for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
-	    q = p) {
-		p = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
-		ip_deq(pData, q);
-		m_freem(pData, dtom(pData, q));
-	}
-	remque_32(pData, fp);
-	(void) m_free(pData, dtom(pData, fp));
+        register struct ipasfrag *q, *p;
+
+        for (q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *); q != (struct ipasfrag *)fp;
+            q = p) {
+                p = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
+                ip_deq(pData, q);
+                m_freem(pData, dtom(pData, q));
+        }
+        remque_32(pData, fp);
+        (void) m_free(pData, dtom(pData, fp));
 }
 #else /* !VBOX_WITH_BSD_REASS */
@@ -718,10 +718,10 @@
 ip_enq(PNATState pData, register struct ipasfrag *p, register struct ipasfrag *prev)
 {
-	DEBUG_CALL("ip_enq");
-	DEBUG_ARG("prev = %lx", (long)prev);
-	p->ipf_prev = ptr_to_u32(pData, prev);
-	p->ipf_next = prev->ipf_next;
-	u32_to_ptr(pData, prev->ipf_next, struct ipasfrag *)->ipf_prev = ptr_to_u32(pData, p);
-	prev->ipf_next = ptr_to_u32(pData, p);
+        DEBUG_CALL("ip_enq");
+        DEBUG_ARG("prev = %lx", (long)prev);
+        p->ipf_prev = ptr_to_u32(pData, prev);
+        p->ipf_next = prev->ipf_next;
+        u32_to_ptr(pData, prev->ipf_next, struct ipasfrag *)->ipf_prev = ptr_to_u32(pData, p);
+        prev->ipf_next = ptr_to_u32(pData, p);
 }
 
@@ -732,9 +732,9 @@
 ip_deq(PNATState pData, register struct ipasfrag *p)
 {
-	struct ipasfrag *prev = u32_to_ptr(pData, p->ipf_prev, struct ipasfrag *);
-	struct ipasfrag *next = u32_to_ptr(pData, p->ipf_next, struct ipasfrag *);
-	u32ptr_done(pData, prev->ipf_next, p);
-	prev->ipf_next = p->ipf_next;
-	next->ipf_prev = p->ipf_prev;
+        struct ipasfrag *prev = u32_to_ptr(pData, p->ipf_prev, struct ipasfrag *);
+        struct ipasfrag *next = u32_to_ptr(pData, p->ipf_next, struct ipasfrag *);
+        u32ptr_done(pData, prev->ipf_next, p);
+        prev->ipf_next = p->ipf_next;
+        next->ipf_prev = p->ipf_prev;
 }
 
@@ -747,21 +747,21 @@
 ip_slowtimo(PNATState pData)
 {
-	register struct ipq_t *fp;
+        register struct ipq_t *fp;
 
 #ifndef VBOX_WITH_BSD_REASS
-	DEBUG_CALL("ip_slowtimo");
-
-	fp = u32_to_ptr(pData, ipq.next, struct ipq_t *);
-	if (fp == 0)
-	   return;
-
-	while (fp != &ipq) {
-		--fp->ipq_ttl;
-		fp = u32_to_ptr(pData, fp->next, struct ipq_t *);
-		if (u32_to_ptr(pData, fp->prev, struct ipq_t *)->ipq_ttl == 0) {
-			ipstat.ips_fragtimeout++;
-			ip_freef(pData, u32_to_ptr(pData, fp->prev, struct ipq_t *));
-		}
-	}
+        DEBUG_CALL("ip_slowtimo");
+
+        fp = u32_to_ptr(pData, ipq.next, struct ipq_t *);
+        if (fp == 0)
+           return;
+
+        while (fp != &ipq) {
+                --fp->ipq_ttl;
+                fp = u32_to_ptr(pData, fp->next, struct ipq_t *);
+                if (u32_to_ptr(pData, fp->prev, struct ipq_t *)->ipq_ttl == 0) {
+                        ipstat.ips_fragtimeout++;
+                        ip_freef(pData, u32_to_ptr(pData, fp->prev, struct ipq_t *));
+                }
+        }
 #else /* !VBOX_WITH_BSD_REASS */
     /* XXX: the fragment expiration is the same but requier
@@ -811,195 +811,195 @@
 int
 ip_dooptions(m)
-	struct mbuf *m;
+        struct mbuf *m;
 {
-	register struct ip *ip = mtod(m, struct ip *);
-	register u_char *cp;
-	register struct ip_timestamp *ipt;
-	register struct in_ifaddr *ia;
-/*	int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; */
-	int opt, optlen, cnt, off, code, type, forward = 0;
-	struct in_addr *sin, dst;
+        register struct ip *ip = mtod(m, struct ip *);
+        register u_char *cp;
+        register struct ip_timestamp *ipt;
+        register struct in_ifaddr *ia;
+/*      int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; */
+        int opt, optlen, cnt, off, code, type, forward = 0;
+        struct in_addr *sin, dst;
 typedef u_int32_t n_time;
-	n_time ntime;
-
-	dst = ip->ip_dst;
-	cp = (u_char *)(ip + 1);
-	cnt = (ip->ip_hl << 2) - sizeof (struct ip);
-	for (; cnt > 0; cnt -= optlen, cp += optlen) {
-		opt = cp[IPOPT_OPTVAL];
-		if (opt == IPOPT_EOL)
-			break;
-		if (opt == IPOPT_NOP)
-			optlen = 1;
-		else {
-			optlen = cp[IPOPT_OLEN];
-			if (optlen <= 0 || optlen > cnt) {
-				code = &cp[IPOPT_OLEN] - (u_char *)ip;
-				goto bad;
-			}
-		}
-		switch (opt) {
-
-		default:
-			break;
-
-		/*
-		 * Source routing with record.
-		 * Find interface with current destination address.
-		 * If none on this machine then drop if strictly routed,
-		 * or do nothing if loosely routed.
-		 * Record interface address and bring up next address
-		 * component.  If strictly routed make sure next
-		 * address is on directly accessible net.
-		 */
-		case IPOPT_LSRR:
-		case IPOPT_SSRR:
-			if ((off = cp[IPOPT_OFFSET]) < IPOPT_MINOFF) {
-				code = &cp[IPOPT_OFFSET] - (u_char *)ip;
-				goto bad;
-			}
-			ipaddr.sin_addr = ip->ip_dst;
-			ia = (struct in_ifaddr *)
-				ifa_ifwithaddr((struct sockaddr *)&ipaddr);
-			if (ia == 0) {
-				if (opt == IPOPT_SSRR) {
-					type = ICMP_UNREACH;
-					code = ICMP_UNREACH_SRCFAIL;
-					goto bad;
-				}
-				/*
-				 * Loose routing, and not at next destination
-				 * yet; nothing to do except forward.
-				 */
-				break;
-			}
-			off--;			/ * 0 origin *  /
-			if (off > optlen - sizeof(struct in_addr)) {
-				/*
-				 * End of source route.  Should be for us.
-				 */
-				save_rte(cp, ip->ip_src);
-				break;
-			}
-			/*
-			 * locate outgoing interface
-			 */
-			bcopy((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr,
-			    sizeof(ipaddr.sin_addr));
-			if (opt == IPOPT_SSRR) {
-#define	INA	struct in_ifaddr *
-#define	SA	struct sockaddr *
- 			    if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == 0)
-				ia = (INA)ifa_ifwithnet((SA)&ipaddr);
-			} else
-				ia = ip_rtaddr(ipaddr.sin_addr);
-			if (ia == 0) {
-				type = ICMP_UNREACH;
-				code = ICMP_UNREACH_SRCFAIL;
-				goto bad;
-			}
-			ip->ip_dst = ipaddr.sin_addr;
-			bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
-			    (caddr_t)(cp + off), sizeof(struct in_addr));
-			cp[IPOPT_OFFSET] += sizeof(struct in_addr);
-			/*
-			 * Let ip_intr's mcast routing check handle mcast pkts
-			 */
-			forward = !IN_MULTICAST(ntohl(ip->ip_dst.s_addr));
-			break;
-
-		case IPOPT_RR:
-			if ((off = cp[IPOPT_OFFSET]) < IPOPT_MINOFF) {
-				code = &cp[IPOPT_OFFSET] - (u_char *)ip;
-				goto bad;
-			}
-			/*
-			 * If no space remains, ignore.
-			 */
-			off--;			 * 0 origin *
-			if (off > optlen - sizeof(struct in_addr))
-				break;
-			bcopy((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr,
-			    sizeof(ipaddr.sin_addr));
-			/*
-			 * locate outgoing interface; if we're the destination,
-			 * use the incoming interface (should be same).
-			 */
-			if ((ia = (INA)ifa_ifwithaddr((SA)&ipaddr)) == 0 &&
-			    (ia = ip_rtaddr(ipaddr.sin_addr)) == 0) {
-				type = ICMP_UNREACH;
-				code = ICMP_UNREACH_HOST;
-				goto bad;
-			}
-			bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
-			    (caddr_t)(cp + off), sizeof(struct in_addr));
-			cp[IPOPT_OFFSET] += sizeof(struct in_addr);
-			break;
-
-		case IPOPT_TS:
-			code = cp - (u_char *)ip;
-			ipt = (struct ip_timestamp *)cp;
-			if (ipt->ipt_len < 5)
-				goto bad;
-			if (ipt->ipt_ptr > ipt->ipt_len - sizeof (int32_t)) {
-				if (++ipt->ipt_oflw == 0)
-					goto bad;
-				break;
-			}
-			sin = (struct in_addr *)(cp + ipt->ipt_ptr - 1);
-			switch (ipt->ipt_flg) {
-
-			case IPOPT_TS_TSONLY:
-				break;
-
-			case IPOPT_TS_TSANDADDR:
-				if (ipt->ipt_ptr + sizeof(n_time) +
-				    sizeof(struct in_addr) > ipt->ipt_len)
-					goto bad;
-				ipaddr.sin_addr = dst;
-				ia = (INA)ifaof_ i f p foraddr((SA)&ipaddr,
-							    m->m_pkthdr.rcvif);
-				if (ia == 0)
-					continue;
-				bcopy((caddr_t)&IA_SIN(ia)->sin_addr,
-				    (caddr_t)sin, sizeof(struct in_addr));
-				ipt->ipt_ptr += sizeof(struct in_addr);
-				break;
-
-			case IPOPT_TS_PRESPEC:
-				if (ipt->ipt_ptr + sizeof(n_time) +
-				    sizeof(struct in_addr) > ipt->ipt_len)
-					goto bad;
-				bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr,
-				    sizeof(struct in_addr));
-				if (ifa_ifwithaddr((SA)&ipaddr) == 0)
-					continue;
-				ipt->ipt_ptr += sizeof(struct in_addr);
-				break;
-
-			default:
-				goto bad;
-			}
-			ntime = iptime();
-			bcopy((caddr_t)&ntime, (caddr_t)cp + ipt->ipt_ptr - 1,
-			    sizeof(n_time));
-			ipt->ipt_ptr += sizeof(n_time);
-		}
-	}
-	if (forward) {
-		ip_forward(m, 1);
-		return (1);
-	}
-		}
-	}
-	return (0);
+        n_time ntime;
+
+        dst = ip->ip_dst;
+        cp = (u_char *)(ip + 1);
+        cnt = (ip->ip_hl << 2) - sizeof (struct ip);
+        for (; cnt > 0; cnt -= optlen, cp += optlen) {
+                opt = cp[IPOPT_OPTVAL];
+                if (opt == IPOPT_EOL)
+                        break;
+                if (opt == IPOPT_NOP)
+                        optlen = 1;
+                else {
+                        optlen = cp[IPOPT_OLEN];
+                        if (optlen <= 0 || optlen > cnt) {
+                                code = &cp[IPOPT_OLEN] - (u_char *)ip;
+                                goto bad;
+                        }
+                }
+                switch (opt) {
+
+                default:
+                        break;
+
+                /*
+                 * Source routing with record.
+                 * Find interface with current destination address.
+                 * If none on this machine then drop if strictly routed,
+                 * or do nothing if loosely routed.
+                 * Record interface address and bring up next address
+                 * component.  If strictly routed make sure next
+                 * address is on directly accessible net.
+                 */
+                case IPOPT_LSRR:
+                case IPOPT_SSRR:
+                        if ((off = cp[IPOPT_OFFSET]) < IPOPT_MINOFF) {
+                                code = &cp[IPOPT_OFFSET] - (u_char *)ip;
+                                goto bad;
+                        }
+                        ipaddr.sin_addr = ip->ip_dst;
+                        ia = (struct in_ifaddr *)
+                                ifa_ifwithaddr((struct sockaddr *)&ipaddr);
+                        if (ia == 0) {
+                                if (opt == IPOPT_SSRR) {
+                                        type = ICMP_UNREACH;
+                                        code = ICMP_UNREACH_SRCFAIL;
+                                        goto bad;
+                                }
+                                /*
+                                 * Loose routing, and not at next destination
+                                 * yet; nothing to do except forward.
+                                 */
+                                break;
+                        }
+                        off--;                  / * 0 origin *  /
+                        if (off > optlen - sizeof(struct in_addr)) {
+                                /*
+                                 * End of source route.  Should be for us.
+                                 */
+                                save_rte(cp, ip->ip_src);
+                                break;
+                        }
+                        /*
+                         * locate outgoing interface
+                         */
+                        bcopy((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr,
+                            sizeof(ipaddr.sin_addr));
+                        if (opt == IPOPT_SSRR) {
+#define INA     struct in_ifaddr *
+#define SA      struct sockaddr *
+                            if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == 0)
+                                ia = (INA)ifa_ifwithnet((SA)&ipaddr);
+                        } else
+                                ia = ip_rtaddr(ipaddr.sin_addr);
+                        if (ia == 0) {
+                                type = ICMP_UNREACH;
+                                code = ICMP_UNREACH_SRCFAIL;
+                                goto bad;
+                        }
+                        ip->ip_dst = ipaddr.sin_addr;
+                        bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
+                            (caddr_t)(cp + off), sizeof(struct in_addr));
+                        cp[IPOPT_OFFSET] += sizeof(struct in_addr);
+                        /*
+                         * Let ip_intr's mcast routing check handle mcast pkts
+                         */
+                        forward = !IN_MULTICAST(ntohl(ip->ip_dst.s_addr));
+                        break;
+
+                case IPOPT_RR:
+                        if ((off = cp[IPOPT_OFFSET]) < IPOPT_MINOFF) {
+                                code = &cp[IPOPT_OFFSET] - (u_char *)ip;
+                                goto bad;
+                        }
+                        /*
+                         * If no space remains, ignore.
+                         */
+                        off--;                   * 0 origin *
+                        if (off > optlen - sizeof(struct in_addr))
+                                break;
+                        bcopy((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr,
+                            sizeof(ipaddr.sin_addr));
+                        /*
+                         * locate outgoing interface; if we're the destination,
+                         * use the incoming interface (should be same).
+                         */
+                        if ((ia = (INA)ifa_ifwithaddr((SA)&ipaddr)) == 0 &&
+                            (ia = ip_rtaddr(ipaddr.sin_addr)) == 0) {
+                                type = ICMP_UNREACH;
+                                code = ICMP_UNREACH_HOST;
+                                goto bad;
+                        }
+                        bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
+                            (caddr_t)(cp + off), sizeof(struct in_addr));
+                        cp[IPOPT_OFFSET] += sizeof(struct in_addr);
+                        break;
+
+                case IPOPT_TS:
+                        code = cp - (u_char *)ip;
+                        ipt = (struct ip_timestamp *)cp;
+                        if (ipt->ipt_len < 5)
+                                goto bad;
+                        if (ipt->ipt_ptr > ipt->ipt_len - sizeof (int32_t)) {
+                                if (++ipt->ipt_oflw == 0)
+                                        goto bad;
+                                break;
+                        }
+                        sin = (struct in_addr *)(cp + ipt->ipt_ptr - 1);
+                        switch (ipt->ipt_flg) {
+
+                        case IPOPT_TS_TSONLY:
+                                break;
+
+                        case IPOPT_TS_TSANDADDR:
+                                if (ipt->ipt_ptr + sizeof(n_time) +
+                                    sizeof(struct in_addr) > ipt->ipt_len)
+                                        goto bad;
+                                ipaddr.sin_addr = dst;
+                                ia = (INA)ifaof_ i f p foraddr((SA)&ipaddr,
+                                                            m->m_pkthdr.rcvif);
+                                if (ia == 0)
+                                        continue;
+                                bcopy((caddr_t)&IA_SIN(ia)->sin_addr,
+                                    (caddr_t)sin, sizeof(struct in_addr));
+                                ipt->ipt_ptr += sizeof(struct in_addr);
+                                break;
+
+                        case IPOPT_TS_PRESPEC:
+                                if (ipt->ipt_ptr + sizeof(n_time) +
+                                    sizeof(struct in_addr) > ipt->ipt_len)
+                                        goto bad;
+                                bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr,
+                                    sizeof(struct in_addr));
+                                if (ifa_ifwithaddr((SA)&ipaddr) == 0)
+                                        continue;
+                                ipt->ipt_ptr += sizeof(struct in_addr);
+                                break;
+
+                        default:
+                                goto bad;
+                        }
+                        ntime = iptime();
+                        bcopy((caddr_t)&ntime, (caddr_t)cp + ipt->ipt_ptr - 1,
+                            sizeof(n_time));
+                        ipt->ipt_ptr += sizeof(n_time);
+                }
+        }
+        if (forward) {
+                ip_forward(m, 1);
+                return (1);
+        }
+                }
+        }
+        return (0);
 bad:
-	/* ip->ip_len -= ip->ip_hl << 2;   XXX icmp_error adds in hdr length */
+        /* ip->ip_len -= ip->ip_hl << 2;   XXX icmp_error adds in hdr length */
 
 /* Not yet */
- 	icmp_error(m, type, code, 0, 0);
-
-	ipstat.ips_badoptions++;
-	return (1);
+        icmp_error(m, type, code, 0, 0);
+
+        ipstat.ips_badoptions++;
+        return (1);
 }
 
@@ -1015,18 +1015,18 @@
 void
 ip_stripoptions(m, mopt)
-	register struct mbuf *m;
-	struct mbuf *mopt;
+        register struct mbuf *m;
+        struct mbuf *mopt;
 {
-	register int i;
-	struct ip *ip = mtod(m, struct ip *);
-	register caddr_t opts;
-	int olen;
-
-	olen = (ip->ip_hl<<2) - sizeof (struct ip);
-	opts = (caddr_t)(ip + 1);
-	i = m->m_len - (sizeof (struct ip) + olen);
-	memcpy(opts, opts  + olen, (unsigned)i);
-	m->m_len -= olen;
-
-	ip->ip_hl = sizeof(struct ip) >> 2;
+        register int i;
+        struct ip *ip = mtod(m, struct ip *);
+        register caddr_t opts;
+        int olen;
+
+        olen = (ip->ip_hl<<2) - sizeof (struct ip);
+        opts = (caddr_t)(ip + 1);
+        i = m->m_len - (sizeof (struct ip) + olen);
+        memcpy(opts, opts  + olen, (unsigned)i);
+        m->m_len -= olen;
+
+        ip->ip_hl = sizeof(struct ip) >> 2;
 }
Index: trunk/src/VBox/Devices/Network/slirp/ip_output.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/ip_output.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)ip_output.c	8.3 (Berkeley) 1/21/94
+ *      @(#)ip_output.c 8.3 (Berkeley) 1/21/94
  * ip_output.c,v 1.9 1994/11/16 10:17:10 jkh Exp
  */
@@ -55,148 +55,148 @@
 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);
+
+        /* 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;
+        }
 
     {
-	int mhlen, firstlen = len;
-	struct mbuf **mnext = &m->m_nextpkt;
-
-	/*
-	 * Loop through length of segment after first fragment,
-	 * make new header and copy data of each part and link onto chain.
-	 */
-	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++;
-	}
-	/*
-	 * Update first fragment by trimming what's been copied out
-	 * and updating header, then send each fragment (in order).
-	 */
-	m = m0;
-	m_adj(m, hlen + firstlen - (u_int16_t)ip->ip_len);
-	ip->ip_len = htons((u_int16_t)m->m_len);
-	ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));
-	ip->ip_sum = 0;
-	ip->ip_sum = cksum(m, hlen);
+        int mhlen, firstlen = len;
+        struct mbuf **mnext = &m->m_nextpkt;
+
+        /*
+         * Loop through length of segment after first fragment,
+         * make new header and copy data of each part and link onto chain.
+         */
+        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++;
+        }
+        /*
+         * Update first fragment by trimming what's been copied out
+         * and updating header, then send each fragment (in order).
+         */
+        m = m0;
+        m_adj(m, hlen + firstlen - (u_int16_t)ip->ip_len);
+        ip->ip_len = htons((u_int16_t)m->m_len);
+        ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));
+        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);
-	}
-
-	if (error == 0)
-		ipstat.ips_fragmented++;
+        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++;
     }
 
 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/mbuf.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/mbuf.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/mbuf.c	(revision 14470)
@@ -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;
+        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);
+        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,35 @@
 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;
 }
 
@@ -91,23 +91,23 @@
 
   if(m) {
-	/* Remove from m_usedlist */
-	if (m->m_flags & M_USEDLIST)
-	   remque(pData, m);
-
-	/* If it's M_EXT, free() it */
-	if (m->m_flags & 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 */
-	}
+        /* Remove from m_usedlist */
+        if (m->m_flags & M_USEDLIST)
+           remque(pData, m);
+
+        /* If it's M_EXT, free() it */
+        if (m->m_flags & 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) */
 }
@@ -121,14 +121,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);
 }
 
@@ -140,28 +140,28 @@
         int size;
 {
-	int datasize;
-
-	/* some compiles throw up on gotos.  This one we can fake. */
+        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;
+          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;
+          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;
         }
 
@@ -174,18 +174,18 @@
 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;
-	}
+        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;
+        }
 }
 
@@ -196,13 +196,13 @@
 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;
+        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;
 }
 
@@ -216,23 +216,23 @@
 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 14466)
+++ trunk/src/VBox/Devices/Network/slirp/mbuf.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)mbuf.h	8.3 (Berkeley) 1/21/94
+ *      @(#)mbuf.h      8.3 (Berkeley) 1/21/94
  * mbuf.h,v 1.9 1994/11/14 13:54:20 bde Exp
  */
@@ -41,13 +41,13 @@
 
 
-#define MINCSIZE 4096	/* Amount to increase mbuf if too small */
+#define MINCSIZE 4096   /* Amount to increase mbuf if too small */
 
 /*
  * Macros for type conversion
- * mtod(m,t) -	convert mbuf pointer to data pointer of correct type
- * dtom(x) -	convert data pointer within mbuf to mbuf pointer (XXX)
+ * mtod(m,t) -  convert mbuf pointer to data pointer of correct type
+ * dtom(x) -    convert data pointer within mbuf to mbuf pointer (XXX)
  */
-#define mtod(m,t)	((t)(m)->m_data)
-/* #define	dtom(x)		((struct mbuf *)((int)(x) & ~(M_SIZE-1))) */
+#define mtod(m,t)       ((t)(m)->m_data)
+/* #define      dtom(x)         ((struct mbuf *)((int)(x) & ~(M_SIZE-1))) */
 
 /* XXX About mbufs for slirp:
@@ -62,15 +62,15 @@
 /* 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  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*/
@@ -82,7 +82,7 @@
  */
 #define M_ROOM(m) ((m->m_flags & M_EXT)? \
-			(((m)->m_ext + (m)->m_size) - (m)->m_data) \
-		   : \
-			(((m)->m_dat + (m)->m_size) - (m)->m_data))
+                        (((m)->m_ext + (m)->m_size) - (m)->m_data) \
+                   : \
+                        (((m)->m_dat + (m)->m_size) - (m)->m_data))
 
 /*
@@ -93,22 +93,22 @@
 
 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  m_hdr m_hdr;
+        union M_dat {
+                char    m_dat_[1]; /* ANSI don't like 0 sized arrays */
+                char    *m_ext_;
+        } M_dat;
 };
 
-#define m_next		m_hdr.mh_next
-#define m_prev		m_hdr.mh_prev
-#define m_nextpkt	m_hdr.mh_nextpkt
-#define m_prevpkt	m_hdr.mh_prevpkt
-#define m_flags		m_hdr.mh_flags
-#define	m_len		m_hdr.mh_len
-#define	m_data		m_hdr.mh_data
-#define m_size		m_hdr.mh_size
-#define m_dat		M_dat.m_dat_
-#define m_ext		M_dat.m_ext_
-#define m_so		m_hdr.mh_so
+#define m_next          m_hdr.mh_next
+#define m_prev          m_hdr.mh_prev
+#define m_nextpkt       m_hdr.mh_nextpkt
+#define m_prevpkt       m_hdr.mh_prevpkt
+#define m_flags         m_hdr.mh_flags
+#define m_len           m_hdr.mh_len
+#define m_data          m_hdr.mh_data
+#define m_size          m_hdr.mh_size
+#define m_dat           M_dat.m_dat_
+#define m_ext           M_dat.m_ext_
+#define m_so            m_hdr.mh_so
 
 #define ifq_prev m_prev
@@ -118,9 +118,9 @@
 #define ifq_so m_so
 
-#define M_EXT			0x01	/* m_ext points to more (malloced) data */
-#define M_FREELIST		0x02	/* mbuf is on free list */
-#define M_USEDLIST		0x04	/* XXX mbuf is on used list (for dtom()) */
-#define M_DOFREE		0x08	/* when m_free is called on the mbuf, free()
-					 * it rather than putting it on the free list */
+#define M_EXT                   0x01    /* m_ext points to more (malloced) data */
+#define M_FREELIST              0x02    /* mbuf is on free list */
+#define M_USEDLIST              0x04    /* XXX mbuf is on used list (for dtom()) */
+#define M_DOFREE                0x08    /* when m_free is called on the mbuf, free()
+                                         * it rather than putting it on the free list */
 #ifdef VBOX_WITH_BSD_REASS
 #define M_FRAG                  0x0800  /* packet is a fragment of a larger packet */
@@ -134,9 +134,9 @@
 
 struct mbstat {
-	int mbs_alloced;		/* Number of mbufs allocated */
+        int mbs_alloced;                /* Number of mbufs allocated */
 
 };
 
-extern struct	mbstat mbstat;
+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 14466)
+++ trunk/src/VBox/Devices/Network/slirp/misc.c	(revision 14470)
@@ -12,12 +12,12 @@
 int
 inet_aton(cp, ia)
-	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;
+        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;
 }
 #endif
@@ -29,8 +29,8 @@
 getouraddr(PNATState pData)
 {
-	char buff[256];
-	struct hostent *he = NULL;
-
-	if (gethostname(buff,256) == 0)
+        char buff[256];
+        struct hostent *he = NULL;
+
+        if (gethostname(buff,256) == 0)
         {
             he = gethostbyname(buff);
@@ -56,6 +56,6 @@
 
 struct quehead_32 {
-	u_int32_t qh_link;
-	u_int32_t qh_rlink;
+        u_int32_t qh_link;
+        u_int32_t qh_rlink;
 };
 
@@ -63,12 +63,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 *);
-
-	element->qh_link = head->qh_link;
-	element->qh_rlink = ptr_to_u32(pData, head);
+        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);
+        link->qh_rlink = head->qh_link = ptr_to_u32(pData, element);
 }
 
@@ -76,12 +76,12 @@
 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 *);
-
-	u32ptr_done(pData, link->qh_rlink, element);
-	link->qh_rlink = element->qh_rlink;
-	rlink->qh_link = element->qh_link;
-	element->qh_rlink = 0;
+        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;
 }
 
@@ -89,6 +89,6 @@
 
 struct quehead {
-	struct quehead *qh_link;
-	struct quehead *qh_rlink;
+        struct quehead *qh_link;
+        struct quehead *qh_rlink;
 };
 
@@ -96,11 +96,11 @@
 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;
 }
 
@@ -120,26 +120,26 @@
 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;
+        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;
 }
 
@@ -155,10 +155,10 @@
 char *
 strerror(error)
-	int error;
-{
-	if (error < sys_nerr)
-	   return sys_errlist[error];
-	else
-	   return "Unknown error.";
+        int error;
+{
+        if (error < sys_nerr)
+           return sys_errlist[error];
+        else
+           return "Unknown error.";
 }
 
@@ -169,12 +169,12 @@
 char *
 strdup(str)
-	const char *str;
-{
-	char *bptr;
-
-	bptr = (char *)malloc(strlen(str)+1);
-	strcpy(bptr, str);
-
-	return bptr;
+        const char *str;
+{
+        char *bptr;
+
+        bptr = (char *)malloc(strlen(str)+1);
+        strcpy(bptr, str);
+
+        return bptr;
 }
 #endif
@@ -191,10 +191,10 @@
 int
 vsprintf_len(string, format, args)
-	char *string;
-	const char *format;
-	va_list args;
-{
-	vsprintf(string, format, args);
-	return strlen(string);
+        char *string;
+        const char *format;
+        va_list args;
+{
+        vsprintf(string, format, args);
+        return strlen(string);
 }
 
@@ -206,16 +206,16 @@
 #endif
 {
-	va_list args;
+        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);
+        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);
 }
 
@@ -224,15 +224,15 @@
 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);
+        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);
 }
 
@@ -243,16 +243,16 @@
 void
 fd_nonblock(fd)
-	int fd;
+        int fd;
 {
 #ifdef FIONBIO
-	int opt = 1;
-
-	ioctlsocket(fd, FIONBIO, &opt);
-#else
-	int opt;
-
-	opt = fcntl(fd, F_GETFL, 0);
-	opt |= O_NONBLOCK;
-	fcntl(fd, F_SETFL, opt);
+        int opt = 1;
+
+        ioctlsocket(fd, FIONBIO, &opt);
+#else
+        int opt;
+
+        opt = fcntl(fd, F_GETFL, 0);
+        opt |= O_NONBLOCK;
+        fcntl(fd, F_SETFL, opt);
 #endif
 }
@@ -260,17 +260,17 @@
 void
 fd_block(fd)
-	int fd;
+        int fd;
 {
 #ifdef FIONBIO
-	int opt = 0;
-
-	ioctlsocket(fd, FIONBIO, &opt);
-#else
-	int opt;
-
-	opt = fcntl(fd, F_GETFL, 0);
-	opt &= ~O_NONBLOCK;
-	fcntl(fd, F_SETFL, opt);
-#endif
-}
-
+        int opt = 0;
+
+        ioctlsocket(fd, FIONBIO, &opt);
+#else
+        int opt;
+
+        opt = fcntl(fd, F_GETFL, 0);
+        opt &= ~O_NONBLOCK;
+        fcntl(fd, F_SETFL, opt);
+#endif
+}
+
Index: trunk/src/VBox/Devices/Network/slirp/queue.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/queue.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/queue.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*-
  * Copyright (c) 1991, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,10 +27,10 @@
  * SUCH DAMAGE.
  *
- *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ *      @(#)queue.h     8.5 (Berkeley) 8/20/94
  * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
  */
 
 #ifndef _SYS_QUEUE_H_
-#define	_SYS_QUEUE_H_
+#define _SYS_QUEUE_H_
 
 #include <iprt/cdefs.h>
@@ -84,25 +84,25 @@
  *
  *
- *				SLIST	LIST	STAILQ	TAILQ
- * _HEAD			+	+	+	+
- * _HEAD_INITIALIZER		+	+	+	+
- * _ENTRY			+	+	+	+
- * _INIT			+	+	+	+
- * _EMPTY			+	+	+	+
- * _FIRST			+	+	+	+
- * _NEXT			+	+	+	+
- * _PREV			-	-	-	+
- * _LAST			-	-	+	+
- * _FOREACH			+	+	+	+
- * _FOREACH_SAFE		+	+	+	+
- * _FOREACH_REVERSE		-	-	-	+
- * _FOREACH_REVERSE_SAFE	-	-	-	+
- * _INSERT_HEAD			+	+	+	+
- * _INSERT_BEFORE		-	+	-	+
- * _INSERT_AFTER		+	+	+	+
- * _INSERT_TAIL			-	-	+	+
- * _CONCAT			-	-	+	+
- * _REMOVE_HEAD			+	-	+	-
- * _REMOVE			+	+	+	+
+ *                              SLIST   LIST    STAILQ  TAILQ
+ * _HEAD                        +       +       +       +
+ * _HEAD_INITIALIZER            +       +       +       +
+ * _ENTRY                       +       +       +       +
+ * _INIT                        +       +       +       +
+ * _EMPTY                       +       +       +       +
+ * _FIRST                       +       +       +       +
+ * _NEXT                        +       +       +       +
+ * _PREV                        -       -       -       +
+ * _LAST                        -       -       +       +
+ * _FOREACH                     +       +       +       +
+ * _FOREACH_SAFE                +       +       +       +
+ * _FOREACH_REVERSE             -       -       -       +
+ * _FOREACH_REVERSE_SAFE        -       -       -       +
+ * _INSERT_HEAD                 +       +       +       +
+ * _INSERT_BEFORE               -       +       -       +
+ * _INSERT_AFTER                +       +       +       +
+ * _INSERT_TAIL                 -       -       +       +
+ * _CONCAT                      -       -       +       +
+ * _REMOVE_HEAD                 +       -       +       -
+ * _REMOVE                      +       +       +       +
  *
  */
@@ -110,48 +110,48 @@
 /* Store the last 2 places the queue element or head was altered */
 struct qm_trace {
-	char * lastfile;
-	int lastline;
-	char * prevfile;
-	int prevline;
+        char * lastfile;
+        int lastline;
+        char * prevfile;
+        int prevline;
 };
 
-#define	TRACEBUF	struct qm_trace trace;
-#define	TRASHIT(x)	do {(x) = (void *)-1;} while (0)
-
-#define	QMD_TRACE_HEAD(head) do {					\
-	(head)->trace.prevline = (head)->trace.lastline;		\
-	(head)->trace.prevfile = (head)->trace.lastfile;		\
-	(head)->trace.lastline = __LINE__;				\
-	(head)->trace.lastfile = __FILE__;				\
-} while (0)
-
-#define	QMD_TRACE_ELEM(elem) do {					\
-	(elem)->trace.prevline = (elem)->trace.lastline;		\
-	(elem)->trace.prevfile = (elem)->trace.lastfile;		\
-	(elem)->trace.lastline = __LINE__;				\
-	(elem)->trace.lastfile = __FILE__;				\
+#define TRACEBUF        struct qm_trace trace;
+#define TRASHIT(x)      do {(x) = (void *)-1;} while (0)
+
+#define QMD_TRACE_HEAD(head) do {                                       \
+        (head)->trace.prevline = (head)->trace.lastline;                \
+        (head)->trace.prevfile = (head)->trace.lastfile;                \
+        (head)->trace.lastline = __LINE__;                              \
+        (head)->trace.lastfile = __FILE__;                              \
+} while (0)
+
+#define QMD_TRACE_ELEM(elem) do {                                       \
+        (elem)->trace.prevline = (elem)->trace.lastline;                \
+        (elem)->trace.prevfile = (elem)->trace.lastfile;                \
+        (elem)->trace.lastline = __LINE__;                              \
+        (elem)->trace.lastfile = __FILE__;                              \
 } while (0)
 
 #else
-#define	QMD_TRACE_ELEM(elem)
-#define	QMD_TRACE_HEAD(head)
-#define	TRACEBUF
-#define	TRASHIT(x)
-#endif	/* QUEUE_MACRO_DEBUG */
+#define QMD_TRACE_ELEM(elem)
+#define QMD_TRACE_HEAD(head)
+#define TRACEBUF
+#define TRASHIT(x)
+#endif  /* QUEUE_MACRO_DEBUG */
 
 /*
  * Singly-linked List declarations.
  */
-#define	SLIST_HEAD(name, type)						\
-struct name {								\
-	struct type *slh_first;	/* first element */			\
-}
-
-#define	SLIST_HEAD_INITIALIZER(head)					\
-	{ NULL }
-
-#define	SLIST_ENTRY(type)						\
-struct {								\
-	struct type *sle_next;	/* next element */			\
+#define SLIST_HEAD(name, type)                                          \
+struct name {                                                           \
+        struct type *slh_first; /* first element */                     \
+}
+
+#define SLIST_HEAD_INITIALIZER(head)                                    \
+        { NULL }
+
+#define SLIST_ENTRY(type)                                               \
+struct {                                                                \
+        struct type *sle_next;  /* next element */                      \
 }
 
@@ -159,55 +159,55 @@
  * Singly-linked List functions.
  */
-#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
-
-#define	SLIST_FIRST(head)	((head)->slh_first)
-
-#define	SLIST_FOREACH(var, head, field)					\
-	for ((var) = SLIST_FIRST((head));				\
-	    (var);							\
-	    (var) = SLIST_NEXT((var), field))
-
-#define	SLIST_FOREACH_SAFE(var, head, field, tvar)			\
-	for ((var) = SLIST_FIRST((head));				\
-	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);		\
-	    (var) = (tvar))
-
-#define	SLIST_FOREACH_PREVPTR(var, varp, head, field)			\
-	for ((varp) = &SLIST_FIRST((head));				\
-	    ((var) = *(varp)) != NULL;					\
-	    (varp) = &SLIST_NEXT((var), field))
-
-#define	SLIST_INIT(head) do {						\
-	SLIST_FIRST((head)) = NULL;					\
-} while (0)
-
-#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
-	SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);	\
-	SLIST_NEXT((slistelm), field) = (elm);				\
-} while (0)
-
-#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
-	SLIST_NEXT((elm), field) = SLIST_FIRST((head));			\
-	SLIST_FIRST((head)) = (elm);					\
-} while (0)
-
-#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
-
-#define	SLIST_REMOVE(head, elm, type, field) do {			\
-	if (SLIST_FIRST((head)) == (elm)) {				\
-		SLIST_REMOVE_HEAD((head), field);			\
-	}								\
-	else {								\
-		struct type *curelm = SLIST_FIRST((head));		\
-		while (SLIST_NEXT(curelm, field) != (elm))		\
-			curelm = SLIST_NEXT(curelm, field);		\
-		SLIST_NEXT(curelm, field) =				\
-		    SLIST_NEXT(SLIST_NEXT(curelm, field), field);	\
-	}								\
-	TRASHIT((elm)->field.sle_next);					\
-} while (0)
-
-#define	SLIST_REMOVE_HEAD(head, field) do {				\
-	SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);	\
+#define SLIST_EMPTY(head)       ((head)->slh_first == NULL)
+
+#define SLIST_FIRST(head)       ((head)->slh_first)
+
+#define SLIST_FOREACH(var, head, field)                                 \
+        for ((var) = SLIST_FIRST((head));                               \
+            (var);                                                      \
+            (var) = SLIST_NEXT((var), field))
+
+#define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
+        for ((var) = SLIST_FIRST((head));                               \
+            (var) && ((tvar) = SLIST_NEXT((var), field), 1);            \
+            (var) = (tvar))
+
+#define SLIST_FOREACH_PREVPTR(var, varp, head, field)                   \
+        for ((varp) = &SLIST_FIRST((head));                             \
+            ((var) = *(varp)) != NULL;                                  \
+            (varp) = &SLIST_NEXT((var), field))
+
+#define SLIST_INIT(head) do {                                           \
+        SLIST_FIRST((head)) = NULL;                                     \
+} while (0)
+
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
+        SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);       \
+        SLIST_NEXT((slistelm), field) = (elm);                          \
+} while (0)
+
+#define SLIST_INSERT_HEAD(head, elm, field) do {                        \
+        SLIST_NEXT((elm), field) = SLIST_FIRST((head));                 \
+        SLIST_FIRST((head)) = (elm);                                    \
+} while (0)
+
+#define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
+
+#define SLIST_REMOVE(head, elm, type, field) do {                       \
+        if (SLIST_FIRST((head)) == (elm)) {                             \
+                SLIST_REMOVE_HEAD((head), field);                       \
+        }                                                               \
+        else {                                                          \
+                struct type *curelm = SLIST_FIRST((head));              \
+                while (SLIST_NEXT(curelm, field) != (elm))              \
+                        curelm = SLIST_NEXT(curelm, field);             \
+                SLIST_NEXT(curelm, field) =                             \
+                    SLIST_NEXT(SLIST_NEXT(curelm, field), field);       \
+        }                                                               \
+        TRASHIT((elm)->field.sle_next);                                 \
+} while (0)
+
+#define SLIST_REMOVE_HEAD(head, field) do {                             \
+        SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
 } while (0)
 
@@ -215,16 +215,16 @@
  * Singly-linked Tail queue declarations.
  */
-#define	STAILQ_HEAD(name, type)						\
-struct name {								\
-	struct type *stqh_first;/* first element */			\
-	struct type **stqh_last;/* addr of last next element */		\
-}
-
-#define	STAILQ_HEAD_INITIALIZER(head)					\
-	{ NULL, &(head).stqh_first }
-
-#define	STAILQ_ENTRY(type)						\
-struct {								\
-	struct type *stqe_next;	/* next element */			\
+#define STAILQ_HEAD(name, type)                                         \
+struct name {                                                           \
+        struct type *stqh_first;/* first element */                     \
+        struct type **stqh_last;/* addr of last next element */         \
+}
+
+#define STAILQ_HEAD_INITIALIZER(head)                                   \
+        { NULL, &(head).stqh_first }
+
+#define STAILQ_ENTRY(type)                                              \
+struct {                                                                \
+        struct type *stqe_next; /* next element */                      \
 }
 
@@ -232,77 +232,77 @@
  * Singly-linked Tail queue functions.
  */
-#define	STAILQ_CONCAT(head1, head2) do {				\
-	if (!STAILQ_EMPTY((head2))) {					\
-		*(head1)->stqh_last = (head2)->stqh_first;		\
-		(head1)->stqh_last = (head2)->stqh_last;		\
-		STAILQ_INIT((head2));					\
-	}								\
-} while (0)
-
-#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
-
-#define	STAILQ_FIRST(head)	((head)->stqh_first)
-
-#define	STAILQ_FOREACH(var, head, field)				\
-	for((var) = STAILQ_FIRST((head));				\
-	   (var);							\
-	   (var) = STAILQ_NEXT((var), field))
-
-
-#define	STAILQ_FOREACH_SAFE(var, head, field, tvar)			\
-	for ((var) = STAILQ_FIRST((head));				\
-	    (var) && ((tvar) = STAILQ_NEXT((var), field), 1);		\
-	    (var) = (tvar))
-
-#define	STAILQ_INIT(head) do {						\
-	STAILQ_FIRST((head)) = NULL;					\
-	(head)->stqh_last = &STAILQ_FIRST((head));			\
-} while (0)
-
-#define	STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {		\
-	if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
-		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
-	STAILQ_NEXT((tqelm), field) = (elm);				\
-} while (0)
-
-#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
-	if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL)	\
-		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
-	STAILQ_FIRST((head)) = (elm);					\
-} while (0)
-
-#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
-	STAILQ_NEXT((elm), field) = NULL;				\
-	*(head)->stqh_last = (elm);					\
-	(head)->stqh_last = &STAILQ_NEXT((elm), field);			\
-} while (0)
-
-#define	STAILQ_LAST(head, type, field)					\
-	(STAILQ_EMPTY((head)) ?						\
-		NULL :							\
-	        ((struct type *)(void *)				\
-		((char *)((head)->stqh_last) - __offsetof(struct type, field))))
-
-#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
-
-#define	STAILQ_REMOVE(head, elm, type, field) do {			\
-	if (STAILQ_FIRST((head)) == (elm)) {				\
-		STAILQ_REMOVE_HEAD((head), field);			\
-	}								\
-	else {								\
-		struct type *curelm = STAILQ_FIRST((head));		\
-		while (STAILQ_NEXT(curelm, field) != (elm))		\
-			curelm = STAILQ_NEXT(curelm, field);		\
-		if ((STAILQ_NEXT(curelm, field) =			\
-		     STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
-			(head)->stqh_last = &STAILQ_NEXT((curelm), field);\
-	}								\
-	TRASHIT((elm)->field.stqe_next);				\
-} while (0)
-
-#define	STAILQ_REMOVE_HEAD(head, field) do {				\
-	if ((STAILQ_FIRST((head)) =					\
-	     STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)		\
-		(head)->stqh_last = &STAILQ_FIRST((head));		\
+#define STAILQ_CONCAT(head1, head2) do {                                \
+        if (!STAILQ_EMPTY((head2))) {                                   \
+                *(head1)->stqh_last = (head2)->stqh_first;              \
+                (head1)->stqh_last = (head2)->stqh_last;                \
+                STAILQ_INIT((head2));                                   \
+        }                                                               \
+} while (0)
+
+#define STAILQ_EMPTY(head)      ((head)->stqh_first == NULL)
+
+#define STAILQ_FIRST(head)      ((head)->stqh_first)
+
+#define STAILQ_FOREACH(var, head, field)                                \
+        for((var) = STAILQ_FIRST((head));                               \
+           (var);                                                       \
+           (var) = STAILQ_NEXT((var), field))
+
+
+#define STAILQ_FOREACH_SAFE(var, head, field, tvar)                     \
+        for ((var) = STAILQ_FIRST((head));                              \
+            (var) && ((tvar) = STAILQ_NEXT((var), field), 1);           \
+            (var) = (tvar))
+
+#define STAILQ_INIT(head) do {                                          \
+        STAILQ_FIRST((head)) = NULL;                                    \
+        (head)->stqh_last = &STAILQ_FIRST((head));                      \
+} while (0)
+
+#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {               \
+        if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
+                (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
+        STAILQ_NEXT((tqelm), field) = (elm);                            \
+} while (0)
+
+#define STAILQ_INSERT_HEAD(head, elm, field) do {                       \
+        if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
+                (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
+        STAILQ_FIRST((head)) = (elm);                                   \
+} while (0)
+
+#define STAILQ_INSERT_TAIL(head, elm, field) do {                       \
+        STAILQ_NEXT((elm), field) = NULL;                               \
+        *(head)->stqh_last = (elm);                                     \
+        (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
+} while (0)
+
+#define STAILQ_LAST(head, type, field)                                  \
+        (STAILQ_EMPTY((head)) ?                                         \
+                NULL :                                                  \
+                ((struct type *)(void *)                                \
+                ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
+
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
+
+#define STAILQ_REMOVE(head, elm, type, field) do {                      \
+        if (STAILQ_FIRST((head)) == (elm)) {                            \
+                STAILQ_REMOVE_HEAD((head), field);                      \
+        }                                                               \
+        else {                                                          \
+                struct type *curelm = STAILQ_FIRST((head));             \
+                while (STAILQ_NEXT(curelm, field) != (elm))             \
+                        curelm = STAILQ_NEXT(curelm, field);            \
+                if ((STAILQ_NEXT(curelm, field) =                       \
+                     STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
+                        (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
+        }                                                               \
+        TRASHIT((elm)->field.stqe_next);                                \
+} while (0)
+
+#define STAILQ_REMOVE_HEAD(head, field) do {                            \
+        if ((STAILQ_FIRST((head)) =                                     \
+             STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)         \
+                (head)->stqh_last = &STAILQ_FIRST((head));              \
 } while (0)
 
@@ -310,16 +310,16 @@
  * List declarations.
  */
-#define	LIST_HEAD(name, type)						\
-struct name {								\
-	struct type *lh_first;	/* first element */			\
-}
-
-#define	LIST_HEAD_INITIALIZER(head)					\
-	{ NULL }
-
-#define	LIST_ENTRY(type)						\
-struct {								\
-	struct type *le_next;	/* next element */			\
-	struct type **le_prev;	/* address of previous next element */	\
+#define LIST_HEAD(name, type)                                           \
+struct name {                                                           \
+        struct type *lh_first;  /* first element */                     \
+}
+
+#define LIST_HEAD_INITIALIZER(head)                                     \
+        { NULL }
+
+#define LIST_ENTRY(type)                                                \
+struct {                                                                \
+        struct type *le_next;   /* next element */                      \
+        struct type **le_prev;  /* address of previous next element */  \
 }
 
@@ -329,82 +329,82 @@
 
 #if (defined(_KERNEL) && defined(INVARIANTS))
-#define	QMD_LIST_CHECK_HEAD(head, field) do {				\
-	if (LIST_FIRST((head)) != NULL &&				\
-	    LIST_FIRST((head))->field.le_prev !=			\
-	     &LIST_FIRST((head)))					\
-		panic("Bad list head %p first->prev != head", (head));	\
-} while (0)
-
-#define	QMD_LIST_CHECK_NEXT(elm, field) do {				\
-	if (LIST_NEXT((elm), field) != NULL &&				\
-	    LIST_NEXT((elm), field)->field.le_prev !=			\
-	     &((elm)->field.le_next))					\
-	     	panic("Bad link elm %p next->prev != elm", (elm));	\
-} while (0)
-
-#define	QMD_LIST_CHECK_PREV(elm, field) do {				\
-	if (*(elm)->field.le_prev != (elm))				\
-		panic("Bad link elm %p prev->next != elm", (elm));	\
+#define QMD_LIST_CHECK_HEAD(head, field) do {                           \
+        if (LIST_FIRST((head)) != NULL &&                               \
+            LIST_FIRST((head))->field.le_prev !=                        \
+             &LIST_FIRST((head)))                                       \
+                panic("Bad list head %p first->prev != head", (head));  \
+} while (0)
+
+#define QMD_LIST_CHECK_NEXT(elm, field) do {                            \
+        if (LIST_NEXT((elm), field) != NULL &&                          \
+            LIST_NEXT((elm), field)->field.le_prev !=                   \
+             &((elm)->field.le_next))                                   \
+                panic("Bad link elm %p next->prev != elm", (elm));      \
+} while (0)
+
+#define QMD_LIST_CHECK_PREV(elm, field) do {                            \
+        if (*(elm)->field.le_prev != (elm))                             \
+                panic("Bad link elm %p prev->next != elm", (elm));      \
 } while (0)
 #else
-#define	QMD_LIST_CHECK_HEAD(head, field)
-#define	QMD_LIST_CHECK_NEXT(elm, field)
-#define	QMD_LIST_CHECK_PREV(elm, field)
+#define QMD_LIST_CHECK_HEAD(head, field)
+#define QMD_LIST_CHECK_NEXT(elm, field)
+#define QMD_LIST_CHECK_PREV(elm, field)
 #endif /* (_KERNEL && INVARIANTS) */
 
-#define	LIST_EMPTY(head)	((head)->lh_first == NULL)
-
-#define	LIST_FIRST(head)	((head)->lh_first)
-
-#define	LIST_FOREACH(var, head, field)					\
-	for ((var) = LIST_FIRST((head));				\
-	    (var);							\
-	    (var) = LIST_NEXT((var), field))
-
-#define	LIST_FOREACH_SAFE(var, head, field, tvar)			\
-	for ((var) = LIST_FIRST((head));				\
-	    (var) && ((tvar) = LIST_NEXT((var), field), 1);		\
-	    (var) = (tvar))
-
-#define	LIST_INIT(head) do {						\
-	LIST_FIRST((head)) = NULL;					\
-} while (0)
-
-#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
-	QMD_LIST_CHECK_NEXT(listelm, field);				\
-	if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
-		LIST_NEXT((listelm), field)->field.le_prev =		\
-		    &LIST_NEXT((elm), field);				\
-	LIST_NEXT((listelm), field) = (elm);				\
-	(elm)->field.le_prev = &LIST_NEXT((listelm), field);		\
-} while (0)
-
-#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
-	QMD_LIST_CHECK_PREV(listelm, field);				\
-	(elm)->field.le_prev = (listelm)->field.le_prev;		\
-	LIST_NEXT((elm), field) = (listelm);				\
-	*(listelm)->field.le_prev = (elm);				\
-	(listelm)->field.le_prev = &LIST_NEXT((elm), field);		\
-} while (0)
-
-#define	LIST_INSERT_HEAD(head, elm, field) do {				\
-	QMD_LIST_CHECK_HEAD((head), field);				\
-	if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)	\
-		LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
-	LIST_FIRST((head)) = (elm);					\
-	(elm)->field.le_prev = &LIST_FIRST((head));			\
-} while (0)
-
-#define	LIST_NEXT(elm, field)	((elm)->field.le_next)
-
-#define	LIST_REMOVE(elm, field) do {					\
-	QMD_LIST_CHECK_NEXT(elm, field);				\
-	QMD_LIST_CHECK_PREV(elm, field);				\
-	if (LIST_NEXT((elm), field) != NULL)				\
-		LIST_NEXT((elm), field)->field.le_prev = 		\
-		    (elm)->field.le_prev;				\
-	*(elm)->field.le_prev = LIST_NEXT((elm), field);		\
-	TRASHIT((elm)->field.le_next);					\
-	TRASHIT((elm)->field.le_prev);					\
+#define LIST_EMPTY(head)        ((head)->lh_first == NULL)
+
+#define LIST_FIRST(head)        ((head)->lh_first)
+
+#define LIST_FOREACH(var, head, field)                                  \
+        for ((var) = LIST_FIRST((head));                                \
+            (var);                                                      \
+            (var) = LIST_NEXT((var), field))
+
+#define LIST_FOREACH_SAFE(var, head, field, tvar)                       \
+        for ((var) = LIST_FIRST((head));                                \
+            (var) && ((tvar) = LIST_NEXT((var), field), 1);             \
+            (var) = (tvar))
+
+#define LIST_INIT(head) do {                                            \
+        LIST_FIRST((head)) = NULL;                                      \
+} while (0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do {                     \
+        QMD_LIST_CHECK_NEXT(listelm, field);                            \
+        if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
+                LIST_NEXT((listelm), field)->field.le_prev =            \
+                    &LIST_NEXT((elm), field);                           \
+        LIST_NEXT((listelm), field) = (elm);                            \
+        (elm)->field.le_prev = &LIST_NEXT((listelm), field);            \
+} while (0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
+        QMD_LIST_CHECK_PREV(listelm, field);                            \
+        (elm)->field.le_prev = (listelm)->field.le_prev;                \
+        LIST_NEXT((elm), field) = (listelm);                            \
+        *(listelm)->field.le_prev = (elm);                              \
+        (listelm)->field.le_prev = &LIST_NEXT((elm), field);            \
+} while (0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do {                         \
+        QMD_LIST_CHECK_HEAD((head), field);                             \
+        if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)     \
+                LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
+        LIST_FIRST((head)) = (elm);                                     \
+        (elm)->field.le_prev = &LIST_FIRST((head));                     \
+} while (0)
+
+#define LIST_NEXT(elm, field)   ((elm)->field.le_next)
+
+#define LIST_REMOVE(elm, field) do {                                    \
+        QMD_LIST_CHECK_NEXT(elm, field);                                \
+        QMD_LIST_CHECK_PREV(elm, field);                                \
+        if (LIST_NEXT((elm), field) != NULL)                            \
+                LIST_NEXT((elm), field)->field.le_prev =                \
+                    (elm)->field.le_prev;                               \
+        *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
+        TRASHIT((elm)->field.le_next);                                  \
+        TRASHIT((elm)->field.le_prev);                                  \
 } while (0)
 
@@ -412,19 +412,19 @@
  * Tail queue declarations.
  */
-#define	TAILQ_HEAD(name, type)						\
-struct name {								\
-	struct type *tqh_first;	/* first element */			\
-	struct type **tqh_last;	/* addr of last next element */		\
-	TRACEBUF							\
-}
-
-#define	TAILQ_HEAD_INITIALIZER(head)					\
-	{ NULL, &(head).tqh_first }
-
-#define	TAILQ_ENTRY(type)						\
-struct {								\
-	struct type *tqe_next;	/* next element */			\
-	struct type **tqe_prev;	/* address of previous next element */	\
-	TRACEBUF							\
+#define TAILQ_HEAD(name, type)                                          \
+struct name {                                                           \
+        struct type *tqh_first; /* first element */                     \
+        struct type **tqh_last; /* addr of last next element */         \
+        TRACEBUF                                                        \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head)                                    \
+        { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type)                                               \
+struct {                                                                \
+        struct type *tqe_next;  /* next element */                      \
+        struct type **tqe_prev; /* address of previous next element */  \
+        TRACEBUF                                                        \
 }
 
@@ -433,145 +433,145 @@
  */
 #if (defined(_KERNEL) && defined(INVARIANTS))
-#define	QMD_TAILQ_CHECK_HEAD(head, field) do {				\
-	if (!TAILQ_EMPTY(head) &&					\
-	    TAILQ_FIRST((head))->field.tqe_prev !=			\
-	     &TAILQ_FIRST((head)))					\
-		panic("Bad tailq head %p first->prev != head", (head));	\
-} while (0)
-
-#define	QMD_TAILQ_CHECK_TAIL(head, field) do {				\
-	if (*(head)->tqh_last != NULL)					\
-	    	panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); 	\
-} while (0)
-
-#define	QMD_TAILQ_CHECK_NEXT(elm, field) do {				\
-	if (TAILQ_NEXT((elm), field) != NULL &&				\
-	    TAILQ_NEXT((elm), field)->field.tqe_prev !=			\
-	     &((elm)->field.tqe_next))					\
-		panic("Bad link elm %p next->prev != elm", (elm));	\
-} while (0)
-
-#define	QMD_TAILQ_CHECK_PREV(elm, field) do {				\
-	if (*(elm)->field.tqe_prev != (elm))				\
-		panic("Bad link elm %p prev->next != elm", (elm));	\
+#define QMD_TAILQ_CHECK_HEAD(head, field) do {                          \
+        if (!TAILQ_EMPTY(head) &&                                       \
+            TAILQ_FIRST((head))->field.tqe_prev !=                      \
+             &TAILQ_FIRST((head)))                                      \
+                panic("Bad tailq head %p first->prev != head", (head)); \
+} while (0)
+
+#define QMD_TAILQ_CHECK_TAIL(head, field) do {                          \
+        if (*(head)->tqh_last != NULL)                                  \
+                panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head));  \
+} while (0)
+
+#define QMD_TAILQ_CHECK_NEXT(elm, field) do {                           \
+        if (TAILQ_NEXT((elm), field) != NULL &&                         \
+            TAILQ_NEXT((elm), field)->field.tqe_prev !=                 \
+             &((elm)->field.tqe_next))                                  \
+                panic("Bad link elm %p next->prev != elm", (elm));      \
+} while (0)
+
+#define QMD_TAILQ_CHECK_PREV(elm, field) do {                           \
+        if (*(elm)->field.tqe_prev != (elm))                            \
+                panic("Bad link elm %p prev->next != elm", (elm));      \
 } while (0)
 #else
-#define	QMD_TAILQ_CHECK_HEAD(head, field)
-#define	QMD_TAILQ_CHECK_TAIL(head, headname)
-#define	QMD_TAILQ_CHECK_NEXT(elm, field)
-#define	QMD_TAILQ_CHECK_PREV(elm, field)
+#define QMD_TAILQ_CHECK_HEAD(head, field)
+#define QMD_TAILQ_CHECK_TAIL(head, headname)
+#define QMD_TAILQ_CHECK_NEXT(elm, field)
+#define QMD_TAILQ_CHECK_PREV(elm, field)
 #endif /* (_KERNEL && INVARIANTS) */
 
-#define	TAILQ_CONCAT(head1, head2, field) do {				\
-	if (!TAILQ_EMPTY(head2)) {					\
-		*(head1)->tqh_last = (head2)->tqh_first;		\
-		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
-		(head1)->tqh_last = (head2)->tqh_last;			\
-		TAILQ_INIT((head2));					\
-		QMD_TRACE_HEAD(head1);					\
-		QMD_TRACE_HEAD(head2);					\
-	}								\
-} while (0)
-
-#define	TAILQ_EMPTY(head)	((head)->tqh_first == NULL)
-
-#define	TAILQ_FIRST(head)	((head)->tqh_first)
-
-#define	TAILQ_FOREACH(var, head, field)					\
-	for ((var) = TAILQ_FIRST((head));				\
-	    (var);							\
-	    (var) = TAILQ_NEXT((var), field))
-
-#define	TAILQ_FOREACH_SAFE(var, head, field, tvar)			\
-	for ((var) = TAILQ_FIRST((head));				\
-	    (var) && ((tvar) = TAILQ_NEXT((var), field), 1);		\
-	    (var) = (tvar))
-
-#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
-	for ((var) = TAILQ_LAST((head), headname);			\
-	    (var);							\
-	    (var) = TAILQ_PREV((var), headname, field))
-
-#define	TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)	\
-	for ((var) = TAILQ_LAST((head), headname);			\
-	    (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);	\
-	    (var) = (tvar))
-
-#define	TAILQ_INIT(head) do {						\
-	TAILQ_FIRST((head)) = NULL;					\
-	(head)->tqh_last = &TAILQ_FIRST((head));			\
-	QMD_TRACE_HEAD(head);						\
-} while (0)
-
-#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
-	QMD_TAILQ_CHECK_NEXT(listelm, field);				\
-	if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
-		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
-		    &TAILQ_NEXT((elm), field);				\
-	else {								\
-		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
-		QMD_TRACE_HEAD(head);					\
-	}								\
-	TAILQ_NEXT((listelm), field) = (elm);				\
-	(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);		\
-	QMD_TRACE_ELEM(&(elm)->field);					\
-	QMD_TRACE_ELEM(&listelm->field);				\
-} while (0)
-
-#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
-	QMD_TAILQ_CHECK_PREV(listelm, field);				\
-	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
-	TAILQ_NEXT((elm), field) = (listelm);				\
-	*(listelm)->field.tqe_prev = (elm);				\
-	(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);		\
-	QMD_TRACE_ELEM(&(elm)->field);					\
-	QMD_TRACE_ELEM(&listelm->field);				\
-} while (0)
-
-#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
-	QMD_TAILQ_CHECK_HEAD(head, field);				\
-	if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)	\
-		TAILQ_FIRST((head))->field.tqe_prev =			\
-		    &TAILQ_NEXT((elm), field);				\
-	else								\
-		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
-	TAILQ_FIRST((head)) = (elm);					\
-	(elm)->field.tqe_prev = &TAILQ_FIRST((head));			\
-	QMD_TRACE_HEAD(head);						\
-	QMD_TRACE_ELEM(&(elm)->field);					\
-} while (0)
-
-#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
-	QMD_TAILQ_CHECK_TAIL(head, field);				\
-	TAILQ_NEXT((elm), field) = NULL;				\
-	(elm)->field.tqe_prev = (head)->tqh_last;			\
-	*(head)->tqh_last = (elm);					\
-	(head)->tqh_last = &TAILQ_NEXT((elm), field);			\
-	QMD_TRACE_HEAD(head);						\
-	QMD_TRACE_ELEM(&(elm)->field);					\
-} while (0)
-
-#define	TAILQ_LAST(head, headname)					\
-	(*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define	TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define	TAILQ_PREV(elm, headname, field)				\
-	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-#define	TAILQ_REMOVE(head, elm, field) do {				\
-	QMD_TAILQ_CHECK_NEXT(elm, field);				\
-	QMD_TAILQ_CHECK_PREV(elm, field);				\
-	if ((TAILQ_NEXT((elm), field)) != NULL)				\
-		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
-		    (elm)->field.tqe_prev;				\
-	else {								\
-		(head)->tqh_last = (elm)->field.tqe_prev;		\
-		QMD_TRACE_HEAD(head);					\
-	}								\
-	*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);		\
-	TRASHIT((elm)->field.tqe_next);					\
-	TRASHIT((elm)->field.tqe_prev);					\
-	QMD_TRACE_ELEM(&(elm)->field);					\
+#define TAILQ_CONCAT(head1, head2, field) do {                          \
+        if (!TAILQ_EMPTY(head2)) {                                      \
+                *(head1)->tqh_last = (head2)->tqh_first;                \
+                (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+                (head1)->tqh_last = (head2)->tqh_last;                  \
+                TAILQ_INIT((head2));                                    \
+                QMD_TRACE_HEAD(head1);                                  \
+                QMD_TRACE_HEAD(head2);                                  \
+        }                                                               \
+} while (0)
+
+#define TAILQ_EMPTY(head)       ((head)->tqh_first == NULL)
+
+#define TAILQ_FIRST(head)       ((head)->tqh_first)
+
+#define TAILQ_FOREACH(var, head, field)                                 \
+        for ((var) = TAILQ_FIRST((head));                               \
+            (var);                                                      \
+            (var) = TAILQ_NEXT((var), field))
+
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
+        for ((var) = TAILQ_FIRST((head));                               \
+            (var) && ((tvar) = TAILQ_NEXT((var), field), 1);            \
+            (var) = (tvar))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field)               \
+        for ((var) = TAILQ_LAST((head), headname);                      \
+            (var);                                                      \
+            (var) = TAILQ_PREV((var), headname, field))
+
+#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
+        for ((var) = TAILQ_LAST((head), headname);                      \
+            (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
+            (var) = (tvar))
+
+#define TAILQ_INIT(head) do {                                           \
+        TAILQ_FIRST((head)) = NULL;                                     \
+        (head)->tqh_last = &TAILQ_FIRST((head));                        \
+        QMD_TRACE_HEAD(head);                                           \
+} while (0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {              \
+        QMD_TAILQ_CHECK_NEXT(listelm, field);                           \
+        if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
+                TAILQ_NEXT((elm), field)->field.tqe_prev =              \
+                    &TAILQ_NEXT((elm), field);                          \
+        else {                                                          \
+                (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
+                QMD_TRACE_HEAD(head);                                   \
+        }                                                               \
+        TAILQ_NEXT((listelm), field) = (elm);                           \
+        (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);          \
+        QMD_TRACE_ELEM(&(elm)->field);                                  \
+        QMD_TRACE_ELEM(&listelm->field);                                \
+} while (0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \
+        QMD_TAILQ_CHECK_PREV(listelm, field);                           \
+        (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
+        TAILQ_NEXT((elm), field) = (listelm);                           \
+        *(listelm)->field.tqe_prev = (elm);                             \
+        (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);          \
+        QMD_TRACE_ELEM(&(elm)->field);                                  \
+        QMD_TRACE_ELEM(&listelm->field);                                \
+} while (0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do {                        \
+        QMD_TAILQ_CHECK_HEAD(head, field);                              \
+        if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
+                TAILQ_FIRST((head))->field.tqe_prev =                   \
+                    &TAILQ_NEXT((elm), field);                          \
+        else                                                            \
+                (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
+        TAILQ_FIRST((head)) = (elm);                                    \
+        (elm)->field.tqe_prev = &TAILQ_FIRST((head));                   \
+        QMD_TRACE_HEAD(head);                                           \
+        QMD_TRACE_ELEM(&(elm)->field);                                  \
+} while (0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do {                        \
+        QMD_TAILQ_CHECK_TAIL(head, field);                              \
+        TAILQ_NEXT((elm), field) = NULL;                                \
+        (elm)->field.tqe_prev = (head)->tqh_last;                       \
+        *(head)->tqh_last = (elm);                                      \
+        (head)->tqh_last = &TAILQ_NEXT((elm), field);                   \
+        QMD_TRACE_HEAD(head);                                           \
+        QMD_TRACE_ELEM(&(elm)->field);                                  \
+} while (0)
+
+#define TAILQ_LAST(head, headname)                                      \
+        (*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_PREV(elm, headname, field)                                \
+        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+#define TAILQ_REMOVE(head, elm, field) do {                             \
+        QMD_TAILQ_CHECK_NEXT(elm, field);                               \
+        QMD_TAILQ_CHECK_PREV(elm, field);                               \
+        if ((TAILQ_NEXT((elm), field)) != NULL)                         \
+                TAILQ_NEXT((elm), field)->field.tqe_prev =              \
+                    (elm)->field.tqe_prev;                              \
+        else {                                                          \
+                (head)->tqh_last = (elm)->field.tqe_prev;               \
+                QMD_TRACE_HEAD(head);                                   \
+        }                                                               \
+        *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);              \
+        TRASHIT((elm)->field.tqe_next);                                 \
+        TRASHIT((elm)->field.tqe_prev);                                 \
+        QMD_TRACE_ELEM(&(elm)->field);                                  \
 } while (0)
 
@@ -585,6 +585,6 @@
 
 struct quehead {
-	struct quehead *qh_link;
-	struct quehead *qh_rlink;
+        struct quehead *qh_link;
+        struct quehead *qh_rlink;
 };
 
@@ -594,11 +594,11 @@
 insque(void *a, void *b)
 {
-	struct quehead *element = (struct quehead *)a,
-		 *head = (struct quehead *)b;
-
-	element->qh_link = head->qh_link;
-	element->qh_rlink = head;
-	head->qh_link = element;
-	element->qh_link->qh_rlink = element;
+        struct quehead *element = (struct quehead *)a,
+                 *head = (struct quehead *)b;
+
+        element->qh_link = head->qh_link;
+        element->qh_rlink = head;
+        head->qh_link = element;
+        element->qh_link->qh_rlink = element;
 }
 
@@ -606,15 +606,15 @@
 remque(void *a)
 {
-	struct quehead *element = (struct quehead *)a;
-
-	element->qh_link->qh_rlink = element->qh_rlink;
-	element->qh_rlink->qh_link = element->qh_link;
-	element->qh_rlink = 0;
+        struct quehead *element = (struct quehead *)a;
+
+        element->qh_link->qh_rlink = element->qh_rlink;
+        element->qh_rlink->qh_link = element->qh_link;
+        element->qh_rlink = 0;
 }
 
 #else /* !__CC_SUPPORTS___INLINE */
 
-void	insque(void *a, void *b);
-void	remque(void *a);
+void    insque(void *a, void *b);
+void    remque(void *a);
 
 #endif /* __CC_SUPPORTS___INLINE */
Index: trunk/src/VBox/Devices/Network/slirp/sbuf.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/sbuf.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/sbuf.c	(revision 14470)
@@ -12,5 +12,5 @@
  * sbspace(struct sockbuff *sb)
  * {
- *	return SB_DATALEN - sb->sb_cc;
+ *      return SB_DATALEN - sb->sb_cc;
  * }
  */
@@ -18,24 +18,24 @@
 void
 sbfree(sb)
-	struct sbuf *sb;
+        struct sbuf *sb;
 {
-	free(sb->sb_data);
+        free(sb->sb_data);
 }
 
 void
 sbdrop(sb, num)
-	struct sbuf *sb;
-	int 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;
+        /*
+         * 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;
 
 }
@@ -43,25 +43,25 @@
 void
 sbreserve(sb, size)
-	struct sbuf *sb;
-	int 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;
-	}
+        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 +75,55 @@
 sbappend(PNATState pData, struct socket *so, struct mbuf *m)
 {
-	int ret = 0;
+        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);
+        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;
-	}
+        /* 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;
-	}
+        /*
+         * 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);
+        /*
+         * 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) {
-		/*
-		 * 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);
+        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);
 }
 
@@ -134,34 +134,34 @@
 void
 sbappendsb(sb, m)
-	 struct sbuf *sb;
-	 struct mbuf *m;
+         struct sbuf *sb;
+         struct mbuf *m;
 {
-	int len, n,  nn;
+        int len, n,  nn;
 
-	len = m->m_len;
+        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;
-		}
-	}
+        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;
 }
 
@@ -173,27 +173,27 @@
 void
 sbcopy(sb, off, len, to)
-	struct sbuf *sb;
-	int off;
-	int len;
-	char *to;
+        struct sbuf *sb;
+        int off;
+        int len;
+        char *to;
 {
-	char *from;
+        char *from;
 
-	from = sb->sb_rptr + off;
-	if (from >= sb->sb_data + sb->sb_datalen)
-		from -= sb->sb_datalen;
+        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);
-	}
+        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 14466)
+++ trunk/src/VBox/Devices/Network/slirp/sbuf.h	(revision 14470)
@@ -13,11 +13,11 @@
 
 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 */
+        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 14466)
+++ trunk/src/VBox/Devices/Network/slirp/slirp.c	(revision 14470)
@@ -227,5 +227,5 @@
     }
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-	pData->phEvents[VBOX_SOCKET_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL);
+        pData->phEvents[VBOX_SOCKET_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL);
 #endif
 #endif
@@ -365,11 +365,11 @@
 static void updtime(PNATState pData)
 {
-	gettimeofday(&tt, 0);
-
-	curtime = (u_int)tt.tv_sec * (u_int)1000;
-	curtime += (u_int)tt.tv_usec / (u_int)1000;
-
-	if ((tt.tv_usec % 1000) >= 500)
-	   curtime++;
+        gettimeofday(&tt, 0);
+
+        curtime = (u_int)tt.tv_sec * (u_int)1000;
+        curtime += (u_int)tt.tv_usec / (u_int)1000;
+
+        if ((tt.tv_usec % 1000) >= 500)
+           curtime++;
 }
 #endif
@@ -393,16 +393,16 @@
 
     nfds = *pnfds;
-	/*
-	 * First, TCP sockets
-	 */
-	do_slowtimo = 0;
-	if (link_up) {
-		/*
-		 * *_slowtimo needs calling if there are IP fragments
-		 * in the fragment queue, or there are TCP connections active
-		 */
+        /*
+         * First, TCP sockets
+         */
+        do_slowtimo = 0;
+        if (link_up) {
+                /*
+                 * *_slowtimo needs calling if there are IP fragments
+                 * in the fragment queue, or there are TCP connections active
+                 */
 #ifndef VBOX_WITH_BSD_REASS
-		do_slowtimo = ((tcb.so_next != &tcb) ||
-			       ((struct ipasfrag *)&ipq != u32_to_ptr(pData, ipq.next, struct ipasfrag *)));
+                do_slowtimo = ((tcb.so_next != &tcb) ||
+                               ((struct ipasfrag *)&ipq != u32_to_ptr(pData, ipq.next, struct ipasfrag *)));
 #else /* !VBOX_WITH_BSD_REASS */
     /* XXX: triggering of fragment expiration should be the same but use
@@ -421,32 +421,32 @@
                 STAM_REL_COUNTER_RESET(&pData->StatTCPHot);
 
-		for (so = tcb.so_next; so != &tcb; so = so_next) {
-			so_next = so->so_next;
+                for (so = tcb.so_next; so != &tcb; so = so_next) {
+                        so_next = so->so_next;
 
                         STAM_REL_COUNTER_INC(&pData->StatTCP);
 
-			/*
-			 * See if we need a tcp_fasttimo
-			 */
-			if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
-			   time_fasttimo = curtime; /* Flag when we want a fasttimo */
-
-			/*
-			 * NOFDREF can include still connecting to local-host,
-			 * newly socreated() sockets etc. Don't want to select these.
-	 		 */
-			if (so->so_state & SS_NOFDREF || so->s == -1)
-			   continue;
-
-			/*
-			 * Set for reading sockets which are accepting
-			 */
-			if (so->so_state & SS_FACCEPTCONN) {
+                        /*
+                         * See if we need a tcp_fasttimo
+                         */
+                        if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
+                           time_fasttimo = curtime; /* Flag when we want a fasttimo */
+
+                        /*
+                         * NOFDREF can include still connecting to local-host,
+                         * newly socreated() sockets etc. Don't want to select these.
+                         */
+                        if (so->so_state & SS_NOFDREF || so->s == -1)
+                           continue;
+
+                        /*
+                         * Set for reading sockets which are accepting
+                         */
+                        if (so->so_state & SS_FACCEPTCONN) {
                                 STAM_REL_COUNTER_INC(&pData->StatTCPHot);
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
                                 FD_SET(so->s, readfds);
-				UPD_NFDS(so->s);
-#else
-				rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
+                                UPD_NFDS(so->s);
+#else
+                                rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
                                 if (rc == SOCKET_ERROR)
                                 {
@@ -456,108 +456,108 @@
                                 }
 #endif
-				continue;
-			}
-
-			/*
-			 * Set for writing sockets which are connecting
-			 */
-			if (so->so_state & SS_ISFCONNECTING) {
+                                continue;
+                        }
+
+                        /*
+                         * Set for writing sockets which are connecting
+                         */
+                        if (so->so_state & SS_ISFCONNECTING) {
                                 STAM_REL_COUNTER_INC(&pData->StatTCPHot);
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-				FD_SET(so->s, writefds);
-				UPD_NFDS(so->s);
-#else
-				rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
+                                FD_SET(so->s, writefds);
+                                UPD_NFDS(so->s);
+#else
+                                rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
                                 if (rc == SOCKET_ERROR)
                                     goto socket_error;
 #endif
-				continue;
-			}
-
-			/*
-			 * Set for writing if we are connected, can send more, and
-			 * we have something to send
-			 */
-			if (CONN_CANFSEND(so) && so->so_rcv.sb_cc) {
+                                continue;
+                        }
+
+                        /*
+                         * Set for writing if we are connected, can send more, and
+                         * we have something to send
+                         */
+                        if (CONN_CANFSEND(so) && so->so_rcv.sb_cc) {
                                 STAM_REL_COUNTER_INC(&pData->StatTCPHot);
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-				FD_SET(so->s, writefds);
-				UPD_NFDS(so->s);
-#else
-				rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
+                                FD_SET(so->s, writefds);
+                                UPD_NFDS(so->s);
+#else
+                                rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);
                                 if (rc == SOCKET_ERROR)
                                     goto socket_error;
-				continue; /*XXX: we're using the widest mask for event*/
-#endif
-			}
-
-			/*
-			 * Set for reading (and urgent data) if we are connected, can
-			 * receive more, and we have room for it XXX /2 ?
-			 */
-			if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
+                                continue; /*XXX: we're using the widest mask for event*/
+#endif
+                        }
+
+                        /*
+                         * Set for reading (and urgent data) if we are connected, can
+                         * receive more, and we have room for it XXX /2 ?
+                         */
+                        if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
                                 STAM_REL_COUNTER_INC(&pData->StatTCPHot);
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-				FD_SET(so->s, readfds);
-				FD_SET(so->s, xfds);
-				UPD_NFDS(so->s);
-#else
-				rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_OOB|FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT);
+                                FD_SET(so->s, readfds);
+                                FD_SET(so->s, xfds);
+                                UPD_NFDS(so->s);
+#else
+                                rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_OOB|FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT);
                                 if (rc == SOCKET_ERROR)
                                     goto socket_error;
-				continue; /*XXX: we're using the widest mask for event*/
-#endif
-			}
+                                continue; /*XXX: we're using the widest mask for event*/
+#endif
+                        }
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-			rc = WSAEventSelect(so->s, NULL, 0);
+                        rc = WSAEventSelect(so->s, NULL, 0);
                         if (rc == SOCKET_ERROR)
                             goto socket_error;
 #endif
-		}
-
-		/*
-		 * UDP sockets
-		 */
+                }
+
+                /*
+                 * UDP sockets
+                 */
                 STAM_REL_COUNTER_RESET(&pData->StatUDP);
                 STAM_REL_COUNTER_RESET(&pData->StatUDPHot);
 
-		for (so = udb.so_next; so != &udb; so = so_next) {
-			so_next = so->so_next;
+                for (so = udb.so_next; so != &udb; so = so_next) {
+                        so_next = so->so_next;
 
                         STAM_REL_COUNTER_INC(&pData->StatUDP);
 
-			/*
-			 * See if it's timed out
-			 */
-			if (so->so_expire) {
-				if (so->so_expire <= curtime) {
-					udp_detach(pData, so);
-					continue;
-				} else
-					do_slowtimo = 1; /* Let socket expire */
-			}
-
-			/*
-			 * When UDP packets are received from over the
-			 * link, they're sendto()'d straight away, so
-			 * no need for setting for writing
-			 * Limit the number of packets queued by this session
-			 * to 4.  Note that even though we try and limit this
-			 * to 4 packets, the session could have more queued
-			 * if the packets needed to be fragmented
-			 * (XXX <= 4 ?)
-			 */
-			if ((so->so_state & SS_ISFCONNECTED) && so->so_queued <= 4) {
+                        /*
+                         * See if it's timed out
+                         */
+                        if (so->so_expire) {
+                                if (so->so_expire <= curtime) {
+                                        udp_detach(pData, so);
+                                        continue;
+                                } else
+                                        do_slowtimo = 1; /* Let socket expire */
+                        }
+
+                        /*
+                         * When UDP packets are received from over the
+                         * link, they're sendto()'d straight away, so
+                         * no need for setting for writing
+                         * Limit the number of packets queued by this session
+                         * to 4.  Note that even though we try and limit this
+                         * to 4 packets, the session could have more queued
+                         * if the packets needed to be fragmented
+                         * (XXX <= 4 ?)
+                         */
+                        if ((so->so_state & SS_ISFCONNECTED) && so->so_queued <= 4) {
                                 STAM_REL_COUNTER_INC(&pData->StatUDPHot);
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-				FD_SET(so->s, readfds);
-				UPD_NFDS(so->s);
-#else
-				rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT);
+                                FD_SET(so->s, readfds);
+                                UPD_NFDS(so->s);
+#else
+                                rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT);
                                 if (rc == SOCKET_ERROR)
                                     goto socket_error;
-				continue;
-#endif
-			}
+                                continue;
+#endif
+                        }
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
                         else
@@ -568,40 +568,40 @@
                         }
 #endif
-		}
-	}
-
-	/*
-	 * Setup timeout to use minimum CPU usage, especially when idle
-	 */
-
-	/*
-	 * First, see the timeout needed by *timo
-	 */
-	timeout.tv_sec = 0;
-	timeout.tv_usec = -1;
-	/*
-	 * If a slowtimo is needed, set timeout to 500ms from the last
-	 * slow timeout. If a fast timeout is needed, set timeout within
-	 * 200ms of when it was requested.
-	 */
-	if (do_slowtimo) {
-		/* XXX + 10000 because some select()'s aren't that accurate */
-		timeout.tv_usec = ((500 - (curtime - last_slowtimo)) * 1000) + 10000;
-		if (timeout.tv_usec < 0)
-		   timeout.tv_usec = 0;
-		else if (timeout.tv_usec > 510000)
-		   timeout.tv_usec = 510000;
-
-		/* Can only fasttimo if we also slowtimo */
-		if (time_fasttimo) {
-			tmp_time = (200 - (curtime - time_fasttimo)) * 1000;
-			if (tmp_time < 0)
-			   tmp_time = 0;
-
-			/* Choose the smallest of the 2 */
-			if (tmp_time < timeout.tv_usec)
-			   timeout.tv_usec = (u_int)tmp_time;
-		}
-	}
+                }
+        }
+
+        /*
+         * Setup timeout to use minimum CPU usage, especially when idle
+         */
+
+        /*
+         * First, see the timeout needed by *timo
+         */
+        timeout.tv_sec = 0;
+        timeout.tv_usec = -1;
+        /*
+         * If a slowtimo is needed, set timeout to 500ms from the last
+         * slow timeout. If a fast timeout is needed, set timeout within
+         * 200ms of when it was requested.
+         */
+        if (do_slowtimo) {
+                /* XXX + 10000 because some select()'s aren't that accurate */
+                timeout.tv_usec = ((500 - (curtime - last_slowtimo)) * 1000) + 10000;
+                if (timeout.tv_usec < 0)
+                   timeout.tv_usec = 0;
+                else if (timeout.tv_usec > 510000)
+                   timeout.tv_usec = 510000;
+
+                /* Can only fasttimo if we also slowtimo */
+                if (time_fasttimo) {
+                        tmp_time = (200 - (curtime - time_fasttimo)) * 1000;
+                        if (tmp_time < 0)
+                           tmp_time = 0;
+
+                        /* Choose the smallest of the 2 */
+                        if (tmp_time < timeout.tv_usec)
+                           timeout.tv_usec = (u_int)tmp_time;
+                }
+        }
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
         *pnfds = nfds;
@@ -618,54 +618,54 @@
     int ret;
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-	WSANETWORKEVENTS NetworkEvents;
-	int rc;
+        WSANETWORKEVENTS NetworkEvents;
+        int rc;
         int error;
-	int timer_update = (readfds == NULL && writefds == NULL && xfds == NULL);
+        int timer_update = (readfds == NULL && writefds == NULL && xfds == NULL);
 #endif
         STAM_REL_PROFILE_START(&pData->StatPoll, a);
 
-	/* Update time */
-	updtime(pData);
-
-	/*
-	 * See if anything has timed out
-	 */
-	if (link_up) {
-		if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {
+        /* Update time */
+        updtime(pData);
+
+        /*
+         * See if anything has timed out
+         */
+        if (link_up) {
+                if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {
                         STAM_REL_PROFILE_START(&pData->StatFastTimer, a);
-			tcp_fasttimo(pData);
-			time_fasttimo = 0;
+                        tcp_fasttimo(pData);
+                        time_fasttimo = 0;
                         STAM_REL_PROFILE_STOP(&pData->StatFastTimer, a);
-		}
-		if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {
+                }
+                if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {
                         STAM_REL_PROFILE_START(&pData->StatSlowTimer, a);
-			ip_slowtimo(pData);
-			tcp_slowtimo(pData);
-			last_slowtimo = curtime;
+                        ip_slowtimo(pData);
+                        tcp_slowtimo(pData);
+                        last_slowtimo = curtime;
                         STAM_REL_PROFILE_STOP(&pData->StatSlowTimer, a);
-		}
-	}
+                }
+        }
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-	if (timer_update) return;
-#endif
-
-	/*
-	 * Check sockets
-	 */
-	if (link_up) {
-		/*
-		 * Check TCP sockets
-		 */
-		for (so = tcb.so_next; so != &tcb; so = so_next) {
-			so_next = so->so_next;
-
-			/*
-			 * FD_ISSET is meaningless on these sockets
-			 * (and they can crash the program)
-			 */
-			if (so->so_state & SS_NOFDREF || so->s == -1)
-			   continue;
+        if (timer_update) return;
+#endif
+
+        /*
+         * Check sockets
+         */
+        if (link_up) {
+                /*
+                 * Check TCP sockets
+                 */
+                for (so = tcb.so_next; so != &tcb; so = so_next) {
+                        so_next = so->so_next;
+
+                        /*
+                         * FD_ISSET is meaningless on these sockets
+                         * (and they can crash the program)
+                         */
+                        if (so->so_state & SS_NOFDREF || so->s == -1)
+                           continue;
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-			rc = WSAEnumNetworkEvents(so->s, VBOX_SOCKET_EVENT, &NetworkEvents);
+                        rc = WSAEnumNetworkEvents(so->s, VBOX_SOCKET_EVENT, &NetworkEvents);
                         if (rc == SOCKET_ERROR)
                         {
@@ -676,52 +676,52 @@
 #endif
 
-			/*
-			 * Check for URG data
-			 * This will soread as well, so no need to
-			 * test for readfds below if this succeeds
-			 */
+                        /*
+                         * Check for URG data
+                         * This will soread as well, so no need to
+                         * test for readfds below if this succeeds
+                         */
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-			if (FD_ISSET(so->s, xfds))
+                        if (FD_ISSET(so->s, xfds))
 #else
                         /* out-of-band data */
-			if ((NetworkEvents.lNetworkEvents & FD_OOB) && NetworkEvents.iErrorCode[FD_OOB_BIT] == 0)
-#endif
-			   sorecvoob(pData, so);
-			/*
-			 * Check sockets for reading
-			 */
+                        if ((NetworkEvents.lNetworkEvents & FD_OOB) && NetworkEvents.iErrorCode[FD_OOB_BIT] == 0)
+#endif
+                           sorecvoob(pData, so);
+                        /*
+                         * Check sockets for reading
+                         */
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-			else if (FD_ISSET(so->s, readfds)) {
-#else
-			else if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)) {
-#endif
-				/*
-				 * Check for incoming connections
-				 */
-				if (so->so_state & SS_FACCEPTCONN) {
-					tcp_connect(pData, so);
-					continue;
-				} /* else */
-				ret = soread(pData, so);
-
-				/* Output it if we read something */
-				if (ret > 0)
-				   tcp_output(pData, sototcpcb(so));
-			}
-
-			/*
-			 * Check sockets for writing
-			 */
+                        else if (FD_ISSET(so->s, readfds)) {
+#else
+                        else if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)) {
+#endif
+                                /*
+                                 * Check for incoming connections
+                                 */
+                                if (so->so_state & SS_FACCEPTCONN) {
+                                        tcp_connect(pData, so);
+                                        continue;
+                                } /* else */
+                                ret = soread(pData, so);
+
+                                /* Output it if we read something */
+                                if (ret > 0)
+                                   tcp_output(pData, sototcpcb(so));
+                        }
+
+                        /*
+                         * Check sockets for writing
+                         */
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-			if (FD_ISSET(so->s, writefds)) {
-#else
-			if ((NetworkEvents.lNetworkEvents & FD_WRITE) && (NetworkEvents.iErrorCode[FD_WRITE_BIT] == 0)) {
-#endif
-			  /*
-			   * Check for non-blocking, still-connecting sockets
-			   */
-			  if (so->so_state & SS_ISFCONNECTING) {
-			    /* Connected */
-			    so->so_state &= ~SS_ISFCONNECTING;
+                        if (FD_ISSET(so->s, writefds)) {
+#else
+                        if ((NetworkEvents.lNetworkEvents & FD_WRITE) && (NetworkEvents.iErrorCode[FD_WRITE_BIT] == 0)) {
+#endif
+                          /*
+                           * Check for non-blocking, still-connecting sockets
+                           */
+                          if (so->so_state & SS_ISFCONNECTING) {
+                            /* Connected */
+                            so->so_state &= ~SS_ISFCONNECTING;
 
                 /*
@@ -732,81 +732,81 @@
                  */
 #ifndef RT_OS_OS2
-			    ret = send(so->s, (const char *)&ret, 0, 0);
-			    if (ret < 0) {
-			      /* XXXXX Must fix, zero bytes is a NOP */
-			      if (errno == EAGAIN || errno == EWOULDBLOCK ||
-				  errno == EINPROGRESS || errno == ENOTCONN) {
-				continue;
-			      }
-
-			      /* else failed */
-			      so->so_state = SS_NOFDREF;
-			    }
-			    /* else so->so_state &= ~SS_ISFCONNECTING; */
-#endif
-
-			    /*
-			     * Continue tcp_input
-			     */
-			    tcp_input(pData, (struct mbuf *)NULL, sizeof(struct ip), so);
-			    /* continue; */
-			  } else
-			    ret = sowrite(pData, so);
-			  /*
-			   * XXXXX If we wrote something (a lot), there
-			   * could be a need for a window update.
-			   * In the worst case, the remote will send
-			   * a window probe to get things going again
-			   */
-			}
-
-			/*
-			 * Probe a still-connecting, non-blocking socket
-			 * to check if it's still alive
-	 	 	 */
+                            ret = send(so->s, (const char *)&ret, 0, 0);
+                            if (ret < 0) {
+                              /* XXXXX Must fix, zero bytes is a NOP */
+                              if (errno == EAGAIN || errno == EWOULDBLOCK ||
+                                  errno == EINPROGRESS || errno == ENOTCONN) {
+                                continue;
+                              }
+
+                              /* else failed */
+                              so->so_state = SS_NOFDREF;
+                            }
+                            /* else so->so_state &= ~SS_ISFCONNECTING; */
+#endif
+
+                            /*
+                             * Continue tcp_input
+                             */
+                            tcp_input(pData, (struct mbuf *)NULL, sizeof(struct ip), so);
+                            /* continue; */
+                          } else
+                            ret = sowrite(pData, so);
+                          /*
+                           * XXXXX If we wrote something (a lot), there
+                           * could be a need for a window update.
+                           * In the worst case, the remote will send
+                           * a window probe to get things going again
+                           */
+                        }
+
+                        /*
+                         * Probe a still-connecting, non-blocking socket
+                         * to check if it's still alive
+                         */
 #ifdef PROBE_CONN
-			if (so->so_state & SS_ISFCONNECTING) {
-			  ret = recv(so->s, (char *)&ret, 0,0);
-
-			  if (ret < 0) {
-			    /* XXX */
-			    if (errno == EAGAIN || errno == EWOULDBLOCK ||
-				errno == EINPROGRESS || errno == ENOTCONN) {
-			      continue; /* Still connecting, continue */
-			    }
-
-			    /* else failed */
-			    so->so_state = SS_NOFDREF;
-
-			    /* tcp_input will take care of it */
-			  } else {
-			    ret = send(so->s, &ret, 0,0);
-			    if (ret < 0) {
-			      /* XXX */
-			      if (errno == EAGAIN || errno == EWOULDBLOCK ||
-				  errno == EINPROGRESS || errno == ENOTCONN) {
-				continue;
-				}
-			      /* else failed */
-			      so->so_state = SS_NOFDREF;
-			    } else
-			      so->so_state &= ~SS_ISFCONNECTING;
-
-			  }
-			  tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
-			} /* SS_ISFCONNECTING */
-#endif
-		}
-
-		/*
-		 * Now UDP sockets.
-		 * Incoming packets are sent straight away, they're not buffered.
-		 * Incoming UDP data isn't buffered either.
-		 */
-		for (so = udb.so_next; so != &udb; so = so_next) {
-			so_next = so->so_next;
+                        if (so->so_state & SS_ISFCONNECTING) {
+                          ret = recv(so->s, (char *)&ret, 0,0);
+
+                          if (ret < 0) {
+                            /* XXX */
+                            if (errno == EAGAIN || errno == EWOULDBLOCK ||
+                                errno == EINPROGRESS || errno == ENOTCONN) {
+                              continue; /* Still connecting, continue */
+                            }
+
+                            /* else failed */
+                            so->so_state = SS_NOFDREF;
+
+                            /* tcp_input will take care of it */
+                          } else {
+                            ret = send(so->s, &ret, 0,0);
+                            if (ret < 0) {
+                              /* XXX */
+                              if (errno == EAGAIN || errno == EWOULDBLOCK ||
+                                  errno == EINPROGRESS || errno == ENOTCONN) {
+                                continue;
+                                }
+                              /* else failed */
+                              so->so_state = SS_NOFDREF;
+                            } else
+                              so->so_state &= ~SS_ISFCONNECTING;
+
+                          }
+                          tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
+                        } /* SS_ISFCONNECTING */
+#endif
+                }
+
+                /*
+                 * Now UDP sockets.
+                 * Incoming packets are sent straight away, they're not buffered.
+                 * Incoming UDP data isn't buffered either.
+                 */
+                for (so = udb.so_next; so != &udb; so = so_next) {
+                        so_next = so->so_next;
 
 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
-			rc = WSAEnumNetworkEvents(so->s, VBOX_SOCKET_EVENT, &NetworkEvents);
+                        rc = WSAEnumNetworkEvents(so->s, VBOX_SOCKET_EVENT, &NetworkEvents);
                         if (rc == SOCKET_ERROR)
                         {
@@ -817,18 +817,18 @@
 #endif
 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
-			if (so->s != -1 && FD_ISSET(so->s, readfds)) {
-#else
-			if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)) {
+                        if (so->s != -1 && FD_ISSET(so->s, readfds)) {
+#else
+                        if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)) {
 #endif
                             sorecvfrom(pData, so);
                         }
-		}
-	}
-
-	/*
-	 * See if we can start outputting
-	 */
-	if (if_queued && link_up)
-	   if_start(pData);
+                }
+        }
+
+        /*
+         * See if we can start outputting
+         */
+        if (if_queued && link_up)
+           if_start(pData);
 
         STAM_REL_PROFILE_STOP(&pData->StatPoll, a);
@@ -838,32 +838,32 @@
 #define ETH_HLEN 14
 
-#define ETH_P_IP	0x0800		/* Internet Protocol packet	*/
-#define ETH_P_ARP	0x0806		/* Address Resolution packet	*/
-
-#define	ARPOP_REQUEST	1		/* ARP request			*/
-#define	ARPOP_REPLY	2		/* ARP reply			*/
+#define ETH_P_IP        0x0800          /* Internet Protocol packet     */
+#define ETH_P_ARP       0x0806          /* Address Resolution packet    */
+
+#define ARPOP_REQUEST   1               /* ARP request                  */
+#define ARPOP_REPLY     2               /* ARP reply                    */
 
 struct ethhdr
 {
-	unsigned char	h_dest[ETH_ALEN];	/* destination eth addr	*/
-	unsigned char	h_source[ETH_ALEN];	/* source ether addr	*/
-	unsigned short	h_proto;		/* packet type ID field	*/
+        unsigned char   h_dest[ETH_ALEN];       /* destination eth addr */
+        unsigned char   h_source[ETH_ALEN];     /* source ether addr    */
+        unsigned short  h_proto;                /* packet type ID field */
 };
 
 struct arphdr
 {
-	unsigned short	ar_hrd;		/* format of hardware address	*/
-	unsigned short	ar_pro;		/* format of protocol address	*/
-	unsigned char	ar_hln;		/* length of hardware address	*/
-	unsigned char	ar_pln;		/* length of protocol address	*/
-	unsigned short	ar_op;		/* ARP opcode (command)		*/
-
-	 /*
-	  *	 Ethernet looks like this : This bit is variable sized however...
-	  */
-	unsigned char		ar_sha[ETH_ALEN];	/* sender hardware address	*/
-	unsigned char		ar_sip[4];		/* sender IP address		*/
-	unsigned char		ar_tha[ETH_ALEN];	/* target hardware address	*/
-	unsigned char		ar_tip[4];		/* target IP address		*/
+        unsigned short  ar_hrd;         /* format of hardware address   */
+        unsigned short  ar_pro;         /* format of protocol address   */
+        unsigned char   ar_hln;         /* length of hardware address   */
+        unsigned char   ar_pln;         /* length of protocol address   */
+        unsigned short  ar_op;          /* ARP opcode (command)         */
+
+         /*
+          *      Ethernet looks like this : This bit is variable sized however...
+          */
+        unsigned char           ar_sha[ETH_ALEN];       /* sender hardware address      */
+        unsigned char           ar_sip[4];              /* sender IP address            */
+        unsigned char           ar_tha[ETH_ALEN];       /* target hardware address      */
+        unsigned char           ar_tip[4];              /* target IP address            */
 };
 
@@ -933,7 +933,7 @@
         break;
     case ETH_P_IP:
-	/* Update time. Important if the network is very quiet, as otherwise
+        /* Update time. Important if the network is very quiet, as otherwise
          * the first outgoing connection gets an incorrect timestamp. */
-	updtime(pData);
+        updtime(pData);
 
         m = m_get(pData);
@@ -1005,9 +1005,9 @@
 HANDLE *slirp_get_events(PNATState pData)
 {
-	return pData->phEvents;
+        return pData->phEvents;
 }
 void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index)
 {
-	pData->phEvents[index] = hEvent;
+        pData->phEvents[index] = hEvent;
 }
 #endif
Index: trunk/src/VBox/Devices/Network/slirp/socket.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 14470)
@@ -17,5 +17,5 @@
 so_init()
 {
-	/* Nothing yet */
+        /* Nothing yet */
 }
 
@@ -23,23 +23,23 @@
 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;
+        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;
 
 }
@@ -71,6 +71,6 @@
 {
   if (so->so_emu==EMU_RSH && so->extra) {
-	sofree(pData, so->extra);
-	so->extra=NULL;
+        sofree(pData, so->extra);
+        so->extra=NULL;
   }
   if (so == tcp_last_so)
@@ -96,89 +96,89 @@
 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);
-
-	/*
-	 * 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;
+        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;
-		}
-	}
+        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));
+        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 (nn < 0 && (errno == EINTR || errno == EAGAIN))
-			return 0;
-		else {
-			DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
-			sofcantrcvmore(so);
-			tcp_sockclosed(pData, sototcpcb(so));
-			return -1;
-		}
-	}
+        nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
+#endif
+        if (nn <= 0) {
+                if (nn < 0 && (errno == EINTR || errno == EAGAIN))
+                        return 0;
+                else {
+                        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) {
+        /*
+         * 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);
@@ -187,13 +187,13 @@
         }
 
-	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;
+        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;
 }
 
@@ -208,22 +208,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;
 }
 
@@ -234,55 +234,55 @@
 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)); */
+        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)); */
 #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;
 }
 
@@ -294,68 +294,68 @@
 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
-	 */
+        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[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 */
+        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))
-		return 0;
-
-	if (nn <= 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))
+                return 0;
+
+        if (nn <= 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) {
+        if (n == 2 && nn == iov[0].iov_len) {
             int ret;
             ret = send(so->s, iov[1].iov_base, iov[1].iov_len,0);
@@ -366,18 +366,18 @@
 #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;
+        /* 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;
 }
 
@@ -388,95 +388,95 @@
 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;
-
-	    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 {
-	    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) {
-	    u_char code=ICMP_UNREACH_PORT;
-
-	    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;
-	    }
-
-	    /*		if (m->m_len == len) {
-	     *			m_inc(m, MINCSIZE);
-	     *			m->m_len = 0;
-	     *		}
-	     */
-
-	    /*
-	     * If this packet was destined for CTL_ADDR,
-	     * make it look like that's where it came from, done by udp_output
-	     */
-	    udp_output(pData, so, m, &addr);
-	  } /* rx error */
-	} /* if ping packet */
+        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;
+
+            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 {
+            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) {
+            u_char code=ICMP_UNREACH_PORT;
+
+            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;
+            }
+
+            /*          if (m->m_len == len) {
+             *                  m_inc(m, MINCSIZE);
+             *                  m->m_len = 0;
+             *          }
+             */
+
+            /*
+             * If this packet was destined for CTL_ADDR,
+             * make it look like that's where it came from, done by udp_output
+             */
+            udp_output(pData, so, m, &addr);
+          } /* rx error */
+        } /* if ping packet */
 }
 
@@ -487,19 +487,19 @@
 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);
+        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 */
+        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) {
+          switch(last_byte) {
 #if 0
           /* handle this case at 'default:' */
@@ -520,38 +520,38 @@
             break;
 #endif
-	  case CTL_DNS:
+          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:
+            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;
+              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;
 }
 
@@ -562,71 +562,71 @@
 solisten(PNATState pData, u_int port, u_int32_t laddr, u_int lport, int flags)
 {
-	struct sockaddr_in addr;
-	struct socket *so;
+        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)) {
+        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;
+                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;
 }
 
@@ -638,8 +638,8 @@
 void
 sorwakeup(so)
-	struct socket *so;
-{
-/*	sowrite(so); */
-/*	FD_CLR(so->s,&writefds); */
+        struct socket *so;
+{
+/*      sowrite(so); */
+/*      FD_CLR(so->s,&writefds); */
 }
 
@@ -651,7 +651,7 @@
 void
 sowwakeup(so)
-	struct socket *so;
-{
-	/* Nothing, yet */
+        struct socket *so;
+{
+        /* Nothing, yet */
 }
 
@@ -664,9 +664,9 @@
 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 */
+        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 */
 }
 
@@ -675,46 +675,46 @@
         register struct socket *so;
 {
-	so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF);
-	so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
+        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;
+        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) {
+        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;
+        }
+        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 ... ?
-	 */
+        struct socket *so;
+{
+/*      so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
+/*      close(so->s); */
+/*      so->so_state = SS_ISFDISCONNECTED; */
+        /*
+         * XXX Do nothing ... ?
+         */
 }
 
@@ -725,10 +725,10 @@
 void
 sofwdrain(so)
-	struct socket *so;
-{
-	if (so->so_rcv.sb_cc)
-		so->so_state |= SS_FWDRAIN;
-	else
-		sofcantsendmore(so);
-}
-
+        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 14466)
+++ trunk/src/VBox/Devices/Network/slirp/socket.h	(revision 14470)
@@ -23,33 +23,33 @@
   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 */
+                        /* 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 */
+  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 */
+  void * extra;                 /* Extra pointer */
 };
 
@@ -59,16 +59,16 @@
  * local host means the host on the other end of the modem)
  */
-#define SS_NOFDREF		0x001	/* No fd reference */
+#define SS_NOFDREF              0x001   /* No fd reference */
 
-#define SS_ISFCONNECTING	0x002	/* Socket is connecting to peer (non-blocking connect()'s) */
-#define SS_ISFCONNECTED		0x004	/* Socket is connected to peer */
-#define SS_FCANTRCVMORE		0x008	/* Socket can't receive more from peer (for half-closes) */
-#define SS_FCANTSENDMORE	0x010	/* Socket can't send more to peer (for half-closes) */
-/* #define SS_ISFDISCONNECTED	0x020*/	/* Socket has disconnected from peer, in 2MSL state */
-#define SS_FWDRAIN		0x040	/* We received a FIN, drain data and set SS_FCANTSENDMORE */
+#define SS_ISFCONNECTING        0x002   /* Socket is connecting to peer (non-blocking connect()'s) */
+#define SS_ISFCONNECTED         0x004   /* Socket is connected to peer */
+#define SS_FCANTRCVMORE         0x008   /* Socket can't receive more from peer (for half-closes) */
+#define SS_FCANTSENDMORE        0x010   /* Socket can't send more to peer (for half-closes) */
+/* #define SS_ISFDISCONNECTED   0x020*/ /* Socket has disconnected from peer, in 2MSL state */
+#define SS_FWDRAIN              0x040   /* We received a FIN, drain data and set SS_FCANTSENDMORE */
 
-/* #define SS_CTL		0x080 */
-#define SS_FACCEPTCONN		0x100	/* Socket is accepting connections from a host on the internet */
-#define SS_FACCEPTONCE		0x200	/* If set, the SS_FACCEPTCONN socket will die after one accept */
+/* #define SS_CTL               0x080 */
+#define SS_FACCEPTCONN          0x100   /* Socket is accepting connections from a host on the internet */
+#define SS_FACCEPTONCE          0x200   /* If set, the SS_FACCEPTCONN socket will die after one accept */
 
 extern struct socket tcb;
@@ -77,6 +77,6 @@
 #if defined(DECLARE_IOVEC) && !defined(HAVE_READV)
 struct iovec {
-	char *iov_base;
-	size_t iov_len;
+        char *iov_base;
+        size_t iov_len;
 };
 #endif
Index: trunk/src/VBox/Devices/Network/slirp/tcp_input.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_input.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_input.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_input.c	8.5 (Berkeley) 4/10/94
+ *      @(#)tcp_input.c 8.5 (Berkeley) 4/10/94
  * tcp_input.c,v 1.10 1994/10/13 18:36:32 wollman Exp
  */
@@ -47,9 +47,9 @@
 
 
-#define TCP_PAWS_IDLE	(24 * 24 * 60 * 60 * PR_SLOWHZ)
+#define TCP_PAWS_IDLE   (24 * 24 * 60 * 60 * PR_SLOWHZ)
 
 /* for modulo comparisons of timestamps */
-#define TSTMP_LT(a,b)	((int)((a)-(b)) < 0)
-#define TSTMP_GEQ(a,b)	((int)((a)-(b)) >= 0)
+#define TSTMP_LT(a,b)   ((int)((a)-(b)) < 0)
+#define TSTMP_GEQ(a,b)  ((int)((a)-(b)) >= 0)
 
 #ifndef VBOX_WITH_BSD_TCP_REASS
@@ -78,9 +78,9 @@
                tcpstat.tcps_rcvbyte += (ti)->ti_len;\
                if (so->so_emu) { \
-		       if (tcp_emu((pData), (so),(m))) sbappend((pData), (so), (m)); \
-	       } else \
-	       	       sbappend((pData), (so), (m)); \
+                       if (tcp_emu((pData), (so),(m))) sbappend((pData), (so), (m)); \
+               } else \
+                       sbappend((pData), (so), (m)); \
 /*               sorwakeup(so); */ \
-	} else {\
+        } else {\
                (flags) = tcp_reass((pData), (tp), (ti), (m)); \
                tp->t_flags |= TF_ACKNOW; \
@@ -88,22 +88,22 @@
 }
 #else
-#define	TCP_REASS(pData, tp, ti, m, so, flags) { \
-	if ((ti)->ti_seq == (tp)->rcv_nxt && \
-	    u32_to_ptr((pData), (tp)->seg_next, struct tcpcb *) == (tp) && \
-	    (tp)->t_state == TCPS_ESTABLISHED) { \
-		tp->t_flags |= TF_DELACK; \
-		(tp)->rcv_nxt += (ti)->ti_len; \
-		flags = (ti)->ti_flags & TH_FIN; \
-		tcpstat.tcps_rcvpack++;\
-		tcpstat.tcps_rcvbyte += (ti)->ti_len;\
-		if (so->so_emu) { \
-			if (tcp_emu((pData), (so),(m))) sbappend((pData), (so), (m)); \
-		} else \
-			sbappend((pData), (so), (m)); \
-/*		sorwakeup(so); */ \
-	} else { \
-		(flags) = tcp_reass((pData), (tp), (ti), (m)); \
-		tp->t_flags |= TF_ACKNOW; \
-	} \
+#define TCP_REASS(pData, tp, ti, m, so, flags) { \
+        if ((ti)->ti_seq == (tp)->rcv_nxt && \
+            u32_to_ptr((pData), (tp)->seg_next, struct tcpcb *) == (tp) && \
+            (tp)->t_state == TCPS_ESTABLISHED) { \
+                tp->t_flags |= TF_DELACK; \
+                (tp)->rcv_nxt += (ti)->ti_len; \
+                flags = (ti)->ti_flags & TH_FIN; \
+                tcpstat.tcps_rcvpack++;\
+                tcpstat.tcps_rcvbyte += (ti)->ti_len;\
+                if (so->so_emu) { \
+                        if (tcp_emu((pData), (so),(m))) sbappend((pData), (so), (m)); \
+                } else \
+                        sbappend((pData), (so), (m)); \
+/*              sorwakeup(so); */ \
+        } else { \
+                (flags) = tcp_reass((pData), (tp), (ti), (m)); \
+                tp->t_flags |= TF_ACKNOW; \
+        } \
 }
 #endif
@@ -112,111 +112,111 @@
 tcp_reass(PNATState pData, register struct tcpcb *tp, register struct tcpiphdr *ti, struct mbuf *m)
 {
-	register struct tcpiphdr *q;
-	struct socket *so = tp->t_socket;
-	int flags;
-
-	/*
-	 * Call with ti==0 after become established to
-	 * force pre-ESTABLISHED data up to user socket.
-	 */
-	if (ti == 0)
-		goto present;
-
-	/*
-	 * Find a segment which begins after this one does.
-	 */
-	for (q = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *); q != (struct tcpiphdr *)tp;
-	    q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *))
-		if (SEQ_GT(q->ti_seq, ti->ti_seq))
-			break;
-
-	/*
-	 * If there is a preceding segment, it may provide some of
-	 * our data already.  If so, drop the data from the incoming
-	 * segment.  If it provides all of our data, drop us.
-	 */
-	if (u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *) != (struct tcpiphdr *)tp) {
-		register int i;
-		q = u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *);
-		/* conversion to int (in i) handles seq wraparound */
-		i = q->ti_seq + q->ti_len - ti->ti_seq;
-		if (i > 0) {
-			if (i >= ti->ti_len) {
-				tcpstat.tcps_rcvduppack++;
-				tcpstat.tcps_rcvdupbyte += ti->ti_len;
-				m_freem(pData, m);
-				/*
-				 * Try to present any queued data
-				 * at the left window edge to the user.
-				 * This is needed after the 3-WHS
-				 * completes.
-				 */
-				goto present;   /* ??? */
-			}
-			m_adj(m, i);
-			ti->ti_len -= i;
-			ti->ti_seq += i;
-		}
-		q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *);
-	}
-	tcpstat.tcps_rcvoopack++;
-	tcpstat.tcps_rcvoobyte += ti->ti_len;
-	REASS_MBUF_SET(ti, m); /* XXX */
-
-	/*
-	 * While we overlap succeeding segments trim them or,
-	 * if they are completely covered, dequeue them.
-	 */
-	while (q != (struct tcpiphdr *)tp) {
-		register int i = (ti->ti_seq + ti->ti_len) - q->ti_seq;
-		if (i <= 0)
-			break;
-		if (i < q->ti_len) {
-			q->ti_seq += i;
-			q->ti_len -= i;
-			m_adj(REASS_MBUF_GET(q), i);
-			break;
-		}
-		q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *);
-		m = REASS_MBUF_GET(u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
-		remque_32(pData, u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
-		m_freem(pData, m);
-	}
-
-	/*
-	 * Stick new segment in its place.
-	 */
-	insque_32(pData, ti, u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
+        register struct tcpiphdr *q;
+        struct socket *so = tp->t_socket;
+        int flags;
+
+        /*
+         * Call with ti==0 after become established to
+         * force pre-ESTABLISHED data up to user socket.
+         */
+        if (ti == 0)
+                goto present;
+
+        /*
+         * Find a segment which begins after this one does.
+         */
+        for (q = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *); q != (struct tcpiphdr *)tp;
+            q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *))
+                if (SEQ_GT(q->ti_seq, ti->ti_seq))
+                        break;
+
+        /*
+         * If there is a preceding segment, it may provide some of
+         * our data already.  If so, drop the data from the incoming
+         * segment.  If it provides all of our data, drop us.
+         */
+        if (u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *) != (struct tcpiphdr *)tp) {
+                register int i;
+                q = u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *);
+                /* conversion to int (in i) handles seq wraparound */
+                i = q->ti_seq + q->ti_len - ti->ti_seq;
+                if (i > 0) {
+                        if (i >= ti->ti_len) {
+                                tcpstat.tcps_rcvduppack++;
+                                tcpstat.tcps_rcvdupbyte += ti->ti_len;
+                                m_freem(pData, m);
+                                /*
+                                 * Try to present any queued data
+                                 * at the left window edge to the user.
+                                 * This is needed after the 3-WHS
+                                 * completes.
+                                 */
+                                goto present;   /* ??? */
+                        }
+                        m_adj(m, i);
+                        ti->ti_len -= i;
+                        ti->ti_seq += i;
+                }
+                q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *);
+        }
+        tcpstat.tcps_rcvoopack++;
+        tcpstat.tcps_rcvoobyte += ti->ti_len;
+        REASS_MBUF_SET(ti, m); /* XXX */
+
+        /*
+         * While we overlap succeeding segments trim them or,
+         * if they are completely covered, dequeue them.
+         */
+        while (q != (struct tcpiphdr *)tp) {
+                register int i = (ti->ti_seq + ti->ti_len) - q->ti_seq;
+                if (i <= 0)
+                        break;
+                if (i < q->ti_len) {
+                        q->ti_seq += i;
+                        q->ti_len -= i;
+                        m_adj(REASS_MBUF_GET(q), i);
+                        break;
+                }
+                q = u32_to_ptr(pData, q->ti_next, struct tcpiphdr *);
+                m = REASS_MBUF_GET(u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
+                remque_32(pData, u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
+                m_freem(pData, m);
+        }
+
+        /*
+         * Stick new segment in its place.
+         */
+        insque_32(pData, ti, u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
 
 present:
-	/*
-	 * Present data to user, advancing rcv_nxt through
-	 * completed sequence space.
-	 */
-	if (!TCPS_HAVEESTABLISHED(tp->t_state))
-		return (0);
-	ti = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *);
-	if (ti == (struct tcpiphdr *)tp || ti->ti_seq != tp->rcv_nxt)
-		return (0);
-	if (tp->t_state == TCPS_SYN_RECEIVED && ti->ti_len)
-		return (0);
-	do {
-		tp->rcv_nxt += ti->ti_len;
-		flags = ti->ti_flags & TH_FIN;
-		remque_32(pData, ti);
-		m = REASS_MBUF_GET(ti); /* XXX */
-		ti = u32_to_ptr(pData, ti->ti_next, struct tcpiphdr *);
-/*		if (so->so_state & SS_FCANTRCVMORE) */
-		if (so->so_state & SS_FCANTSENDMORE)
+        /*
+         * Present data to user, advancing rcv_nxt through
+         * completed sequence space.
+         */
+        if (!TCPS_HAVEESTABLISHED(tp->t_state))
+                return (0);
+        ti = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *);
+        if (ti == (struct tcpiphdr *)tp || ti->ti_seq != tp->rcv_nxt)
+                return (0);
+        if (tp->t_state == TCPS_SYN_RECEIVED && ti->ti_len)
+                return (0);
+        do {
+                tp->rcv_nxt += ti->ti_len;
+                flags = ti->ti_flags & TH_FIN;
+                remque_32(pData, ti);
+                m = REASS_MBUF_GET(ti); /* XXX */
+                ti = u32_to_ptr(pData, ti->ti_next, struct tcpiphdr *);
+/*              if (so->so_state & SS_FCANTRCVMORE) */
+                if (so->so_state & SS_FCANTSENDMORE)
                         m_freem(pData, m);
-		else {
-			if (so->so_emu) {
-				if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
-			} else
-				sbappend(pData, so, m);
-		}
-	} while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
-/*	sorwakeup(so); */
-	return (flags);
+                else {
+                        if (so->so_emu) {
+                                if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
+                        } else
+                                sbappend(pData, so, m);
+                }
+        } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
+/*      sorwakeup(so); */
+        return (flags);
 }
 
@@ -231,5 +231,5 @@
 #else /* !TCP_ACK_HACK */
 #define DELAY_ACK(tp, ign)                          \
-		tp->t_flags |= TF_DELACK;
+                tp->t_flags |= TF_DELACK;
 #endif /* TCP_ACK_HACK */
 
@@ -243,160 +243,160 @@
 tcp_reass(PNATState pData, struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
 {
-	struct tseg_qent *q;
-	struct tseg_qent *p = NULL;
-	struct tseg_qent *nq;
-	struct tseg_qent *te = NULL;
-	struct socket *so = tp->t_socket;
-	int flags;
-
-	/*
-	 * XXX: tcp_reass() is rather inefficient with its data structures
-	 * and should be rewritten (see NetBSD for optimizations).  While
-	 * doing that it should move to its own file tcp_reass.c.
-	 */
-
-	/*
-	 * Call with th==NULL after become established to
-	 * force pre-ESTABLISHED data up to user socket.
-	 */
-	if (th == NULL)
-		goto present;
-
-	/*
-	 * Limit the number of segments in the reassembly queue to prevent
-	 * holding on to too many segments (and thus running out of mbufs).
-	 * Make sure to let the missing segment through which caused this
-	 * queue.  Always keep one global queue entry spare to be able to
-	 * process the missing segment.
-	 */
-	if (th->th_seq != tp->rcv_nxt &&
-	    (tcp_reass_qsize + 1 >= tcp_reass_maxseg ||
-	     tp->t_segqlen >= tcp_reass_maxqlen)) {
-		tcp_reass_overflows++;
-		tcpstat.tcps_rcvmemdrop++;
-		m_freem(pData, m);
-		*tlenp = 0;
-		return (0);
-	}
-
-	/*
-	 * Allocate a new queue entry. If we can't, or hit the zone limit
-	 * just drop the pkt.
-	 */
-	te = malloc(sizeof(struct tseg_qent));
-	if (te == NULL) {
-		tcpstat.tcps_rcvmemdrop++;
-		m_freem(pData, m);
-		*tlenp = 0;
-		return (0);
-	}
-	tp->t_segqlen++;
-	tcp_reass_qsize++;
-
-	/*
-	 * Find a segment which begins after this one does.
-	 */
-	LIST_FOREACH(q, &tp->t_segq, tqe_q) {
-		if (SEQ_GT(q->tqe_th->th_seq, th->th_seq))
-			break;
-		p = q;
-	}
-
-	/*
-	 * If there is a preceding segment, it may provide some of
-	 * our data already.  If so, drop the data from the incoming
-	 * segment.  If it provides all of our data, drop us.
-	 */
-	if (p != NULL) {
-		int i;
-		/* conversion to int (in i) handles seq wraparound */
-		i = p->tqe_th->th_seq + p->tqe_len - th->th_seq;
-		if (i > 0) {
-			if (i >= *tlenp) {
-				tcpstat.tcps_rcvduppack++;
-				tcpstat.tcps_rcvdupbyte += *tlenp;
-				m_freem(pData, m);
-				free(te);
-				tp->t_segqlen--;
-				tcp_reass_qsize--;
-				/*
-				 * Try to present any queued data
-				 * at the left window edge to the user.
-				 * This is needed after the 3-WHS
-				 * completes.
-				 */
-				goto present;	/* ??? */
-			}
-			m_adj(m, i);
-			*tlenp -= i;
-			th->th_seq += i;
-		}
-	}
-	tcpstat.tcps_rcvoopack++;
-	tcpstat.tcps_rcvoobyte += *tlenp;
-
-	/*
-	 * While we overlap succeeding segments trim them or,
-	 * if they are completely covered, dequeue them.
-	 */
-	while (q) {
-		int i = (th->th_seq + *tlenp) - q->tqe_th->th_seq;
-		if (i <= 0)
-			break;
-		if (i < q->tqe_len) {
-			q->tqe_th->th_seq += i;
-			q->tqe_len -= i;
-			m_adj(q->tqe_m, i);
-			break;
-		}
-
-		nq = LIST_NEXT(q, tqe_q);
-		LIST_REMOVE(q, tqe_q);
-		m_freem(pData, q->tqe_m);
-		free(q);
-		tp->t_segqlen--;
-		tcp_reass_qsize--;
-		q = nq;
-	}
-
-	/* Insert the new segment queue entry into place. */
-	te->tqe_m = m;
-	te->tqe_th = th;
-	te->tqe_len = *tlenp;
-
-	if (p == NULL) {
-		LIST_INSERT_HEAD(&tp->t_segq, te, tqe_q);
-	} else {
-		LIST_INSERT_AFTER(p, te, tqe_q);
-	}
+        struct tseg_qent *q;
+        struct tseg_qent *p = NULL;
+        struct tseg_qent *nq;
+        struct tseg_qent *te = NULL;
+        struct socket *so = tp->t_socket;
+        int flags;
+
+        /*
+         * XXX: tcp_reass() is rather inefficient with its data structures
+         * and should be rewritten (see NetBSD for optimizations).  While
+         * doing that it should move to its own file tcp_reass.c.
+         */
+
+        /*
+         * Call with th==NULL after become established to
+         * force pre-ESTABLISHED data up to user socket.
+         */
+        if (th == NULL)
+                goto present;
+
+        /*
+         * Limit the number of segments in the reassembly queue to prevent
+         * holding on to too many segments (and thus running out of mbufs).
+         * Make sure to let the missing segment through which caused this
+         * queue.  Always keep one global queue entry spare to be able to
+         * process the missing segment.
+         */
+        if (th->th_seq != tp->rcv_nxt &&
+            (tcp_reass_qsize + 1 >= tcp_reass_maxseg ||
+             tp->t_segqlen >= tcp_reass_maxqlen)) {
+                tcp_reass_overflows++;
+                tcpstat.tcps_rcvmemdrop++;
+                m_freem(pData, m);
+                *tlenp = 0;
+                return (0);
+        }
+
+        /*
+         * Allocate a new queue entry. If we can't, or hit the zone limit
+         * just drop the pkt.
+         */
+        te = malloc(sizeof(struct tseg_qent));
+        if (te == NULL) {
+                tcpstat.tcps_rcvmemdrop++;
+                m_freem(pData, m);
+                *tlenp = 0;
+                return (0);
+        }
+        tp->t_segqlen++;
+        tcp_reass_qsize++;
+
+        /*
+         * Find a segment which begins after this one does.
+         */
+        LIST_FOREACH(q, &tp->t_segq, tqe_q) {
+                if (SEQ_GT(q->tqe_th->th_seq, th->th_seq))
+                        break;
+                p = q;
+        }
+
+        /*
+         * If there is a preceding segment, it may provide some of
+         * our data already.  If so, drop the data from the incoming
+         * segment.  If it provides all of our data, drop us.
+         */
+        if (p != NULL) {
+                int i;
+                /* conversion to int (in i) handles seq wraparound */
+                i = p->tqe_th->th_seq + p->tqe_len - th->th_seq;
+                if (i > 0) {
+                        if (i >= *tlenp) {
+                                tcpstat.tcps_rcvduppack++;
+                                tcpstat.tcps_rcvdupbyte += *tlenp;
+                                m_freem(pData, m);
+                                free(te);
+                                tp->t_segqlen--;
+                                tcp_reass_qsize--;
+                                /*
+                                 * Try to present any queued data
+                                 * at the left window edge to the user.
+                                 * This is needed after the 3-WHS
+                                 * completes.
+                                 */
+                                goto present;   /* ??? */
+                        }
+                        m_adj(m, i);
+                        *tlenp -= i;
+                        th->th_seq += i;
+                }
+        }
+        tcpstat.tcps_rcvoopack++;
+        tcpstat.tcps_rcvoobyte += *tlenp;
+
+        /*
+         * While we overlap succeeding segments trim them or,
+         * if they are completely covered, dequeue them.
+         */
+        while (q) {
+                int i = (th->th_seq + *tlenp) - q->tqe_th->th_seq;
+                if (i <= 0)
+                        break;
+                if (i < q->tqe_len) {
+                        q->tqe_th->th_seq += i;
+                        q->tqe_len -= i;
+                        m_adj(q->tqe_m, i);
+                        break;
+                }
+
+                nq = LIST_NEXT(q, tqe_q);
+                LIST_REMOVE(q, tqe_q);
+                m_freem(pData, q->tqe_m);
+                free(q);
+                tp->t_segqlen--;
+                tcp_reass_qsize--;
+                q = nq;
+        }
+
+        /* Insert the new segment queue entry into place. */
+        te->tqe_m = m;
+        te->tqe_th = th;
+        te->tqe_len = *tlenp;
+
+        if (p == NULL) {
+                LIST_INSERT_HEAD(&tp->t_segq, te, tqe_q);
+        } else {
+                LIST_INSERT_AFTER(p, te, tqe_q);
+        }
 
 present:
-	/*
-	 * Present data to user, advancing rcv_nxt through
-	 * completed sequence space.
-	 */
-	if (!TCPS_HAVEESTABLISHED(tp->t_state))
-		return (0);
-	q = LIST_FIRST(&tp->t_segq);
-	if (!q || q->tqe_th->th_seq != tp->rcv_nxt)
-		return (0);
-	do {
-		tp->rcv_nxt += q->tqe_len;
-		flags = q->tqe_th->th_flags & TH_FIN;
-		nq = LIST_NEXT(q, tqe_q);
-		LIST_REMOVE(q, tqe_q);
+        /*
+         * Present data to user, advancing rcv_nxt through
+         * completed sequence space.
+         */
+        if (!TCPS_HAVEESTABLISHED(tp->t_state))
+                return (0);
+        q = LIST_FIRST(&tp->t_segq);
+        if (!q || q->tqe_th->th_seq != tp->rcv_nxt)
+                return (0);
+        do {
+                tp->rcv_nxt += q->tqe_len;
+                flags = q->tqe_th->th_flags & TH_FIN;
+                nq = LIST_NEXT(q, tqe_q);
+                LIST_REMOVE(q, tqe_q);
                 /* XXX: This place should be checked for the same code in
                  * original BSD code for Slirp and current BSD used SS_FCANTRCVMORE
                  */
-		if (so->so_state & SS_FCANTSENDMORE)
-			m_freem(pData, q->tqe_m);
-		else
-			sbappend(pData, so, q->tqe_m);
-		free(q);
-		tp->t_segqlen--;
-		tcp_reass_qsize--;
-		q = nq;
-	} while (q && q->tqe_th->th_seq == tp->rcv_nxt);
-	return (flags);
+                if (so->so_state & SS_FCANTSENDMORE)
+                        m_freem(pData, q->tqe_m);
+                else
+                        sbappend(pData, so, q->tqe_m);
+                free(q);
+                tp->t_segqlen--;
+                tcp_reass_qsize--;
+                q = nq;
+        } while (q && q->tqe_th->th_seq == tp->rcv_nxt);
+        return (flags);
 }
 #endif /* VBOX_WITH_BSD_TCP_REASS */
@@ -409,1101 +409,1101 @@
 tcp_input(PNATState pData, register struct mbuf *m, int iphlen, struct socket *inso)
 {
-  	struct ip save_ip, *ip;
-	register struct tcpiphdr *ti;
-	caddr_t optp = NULL;
-	int optlen = 0;
-	int len, tlen, off;
-	register struct tcpcb *tp = 0;
-	register int tiflags;
-	struct socket *so = 0;
-	int todrop, acked, ourfinisacked, needoutput = 0;
-/*	int dropsocket = 0; */
-	int iss = 0;
-	u_long tiwin;
-	int ret;
-/*	int ts_present = 0; */
-	int mbuf_freed = 0;
-
-	DEBUG_CALL("tcp_input");
-	DEBUG_ARGS((dfd," m = %8lx  iphlen = %2d  inso = %lx\n",
-		    (long )m, iphlen, (long )inso ));
-
-	/*
-	 * If called with m == 0, then we're continuing the connect
-	 */
-	if (m == NULL) {
-		so = inso;
-
-		/* Re-set a few variables */
-		tp = sototcpcb(so);
-		m = so->so_m;
-		so->so_m = 0;
-		ti = so->so_ti;
-		tiwin = ti->ti_win;
-		tiflags = ti->ti_flags;
-
-		goto cont_conn;
-	}
-
-
-	tcpstat.tcps_rcvtotal++;
-	/*
-	 * Get IP and TCP header together in first mbuf.
-	 * Note: IP leaves IP header in first mbuf.
-	 */
-	ti = mtod(m, struct tcpiphdr *);
-	if (iphlen > sizeof(struct ip )) {
-	  ip_stripoptions(m, (struct mbuf *)0);
-	  iphlen=sizeof(struct ip );
-	}
-	/* XXX Check if too short */
-
-
-	/*
-	 * Save a copy of the IP header in case we want restore it
-	 * for sending an ICMP error message in response.
-	 */
-	ip=mtod(m, struct ip *);
-	save_ip = *ip;
-	save_ip.ip_len+= iphlen;
-
-	/*
-	 * Checksum extended TCP header and data.
-	 */
-	tlen = ((struct ip *)ti)->ip_len;
-	ti->ti_next = ti->ti_prev = 0;
-	ti->ti_x1 = 0;
-	ti->ti_len = htons((u_int16_t)tlen);
-	len = sizeof(struct ip ) + tlen;
-	/* keep checksum for ICMP reply
-	 * ti->ti_sum = cksum(m, len);
-	 * if (ti->ti_sum) { */
-	if(cksum(m, len)) {
-	  tcpstat.tcps_rcvbadsum++;
-	  goto drop;
-	}
-
-	/*
-	 * Check that TCP offset makes sense,
-	 * pull out TCP options and adjust length.		XXX
-	 */
-	off = ti->ti_off << 2;
-	if (off < sizeof (struct tcphdr) || off > tlen) {
-	  tcpstat.tcps_rcvbadoff++;
-	  goto drop;
-	}
-	tlen -= off;
-	ti->ti_len = tlen;
-	if (off > sizeof (struct tcphdr)) {
-	  optlen = off - sizeof (struct tcphdr);
-	  optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr);
-
-		/*
-		 * Do quick retrieval of timestamp options ("options
-		 * prediction?").  If timestamp is the only option and it's
-		 * formatted as recommended in RFC 1323 appendix A, we
-		 * quickly get the values now and not bother calling
-		 * tcp_dooptions(), etc.
-		 */
-/*		if ((optlen == TCPOLEN_TSTAMP_APPA ||
- *		     (optlen > TCPOLEN_TSTAMP_APPA &&
- *			optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) &&
- *		     *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&
- *		     (ti->ti_flags & TH_SYN) == 0) {
- *			ts_present = 1;
- *			ts_val = ntohl(*(u_int32_t *)(optp + 4));
- *			ts_ecr = ntohl(*(u_int32_t *)(optp + 8));
- *			optp = NULL;   / * we've parsed the options * /
- *		}
- */
-	}
-	tiflags = ti->ti_flags;
-
-	/*
-	 * Convert TCP protocol specific fields to host format.
-	 */
-	NTOHL(ti->ti_seq);
-	NTOHL(ti->ti_ack);
-	NTOHS(ti->ti_win);
-	NTOHS(ti->ti_urp);
-
-	/*
-	 * Drop TCP, IP headers and TCP options.
-	 */
-	m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-	m->m_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-
-	/*
-	 * Locate pcb for segment.
-	 */
+        struct ip save_ip, *ip;
+        register struct tcpiphdr *ti;
+        caddr_t optp = NULL;
+        int optlen = 0;
+        int len, tlen, off;
+        register struct tcpcb *tp = 0;
+        register int tiflags;
+        struct socket *so = 0;
+        int todrop, acked, ourfinisacked, needoutput = 0;
+/*      int dropsocket = 0; */
+        int iss = 0;
+        u_long tiwin;
+        int ret;
+/*      int ts_present = 0; */
+        int mbuf_freed = 0;
+
+        DEBUG_CALL("tcp_input");
+        DEBUG_ARGS((dfd," m = %8lx  iphlen = %2d  inso = %lx\n",
+                    (long )m, iphlen, (long )inso ));
+
+        /*
+         * If called with m == 0, then we're continuing the connect
+         */
+        if (m == NULL) {
+                so = inso;
+
+                /* Re-set a few variables */
+                tp = sototcpcb(so);
+                m = so->so_m;
+                so->so_m = 0;
+                ti = so->so_ti;
+                tiwin = ti->ti_win;
+                tiflags = ti->ti_flags;
+
+                goto cont_conn;
+        }
+
+
+        tcpstat.tcps_rcvtotal++;
+        /*
+         * Get IP and TCP header together in first mbuf.
+         * Note: IP leaves IP header in first mbuf.
+         */
+        ti = mtod(m, struct tcpiphdr *);
+        if (iphlen > sizeof(struct ip )) {
+          ip_stripoptions(m, (struct mbuf *)0);
+          iphlen=sizeof(struct ip );
+        }
+        /* XXX Check if too short */
+
+
+        /*
+         * Save a copy of the IP header in case we want restore it
+         * for sending an ICMP error message in response.
+         */
+        ip=mtod(m, struct ip *);
+        save_ip = *ip;
+        save_ip.ip_len+= iphlen;
+
+        /*
+         * Checksum extended TCP header and data.
+         */
+        tlen = ((struct ip *)ti)->ip_len;
+        ti->ti_next = ti->ti_prev = 0;
+        ti->ti_x1 = 0;
+        ti->ti_len = htons((u_int16_t)tlen);
+        len = sizeof(struct ip ) + tlen;
+        /* keep checksum for ICMP reply
+         * ti->ti_sum = cksum(m, len);
+         * if (ti->ti_sum) { */
+        if(cksum(m, len)) {
+          tcpstat.tcps_rcvbadsum++;
+          goto drop;
+        }
+
+        /*
+         * Check that TCP offset makes sense,
+         * pull out TCP options and adjust length.              XXX
+         */
+        off = ti->ti_off << 2;
+        if (off < sizeof (struct tcphdr) || off > tlen) {
+          tcpstat.tcps_rcvbadoff++;
+          goto drop;
+        }
+        tlen -= off;
+        ti->ti_len = tlen;
+        if (off > sizeof (struct tcphdr)) {
+          optlen = off - sizeof (struct tcphdr);
+          optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr);
+
+                /*
+                 * Do quick retrieval of timestamp options ("options
+                 * prediction?").  If timestamp is the only option and it's
+                 * formatted as recommended in RFC 1323 appendix A, we
+                 * quickly get the values now and not bother calling
+                 * tcp_dooptions(), etc.
+                 */
+/*              if ((optlen == TCPOLEN_TSTAMP_APPA ||
+ *                   (optlen > TCPOLEN_TSTAMP_APPA &&
+ *                      optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) &&
+ *                   *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&
+ *                   (ti->ti_flags & TH_SYN) == 0) {
+ *                      ts_present = 1;
+ *                      ts_val = ntohl(*(u_int32_t *)(optp + 4));
+ *                      ts_ecr = ntohl(*(u_int32_t *)(optp + 8));
+ *                      optp = NULL;   / * we've parsed the options * /
+ *              }
+ */
+        }
+        tiflags = ti->ti_flags;
+
+        /*
+         * Convert TCP protocol specific fields to host format.
+         */
+        NTOHL(ti->ti_seq);
+        NTOHL(ti->ti_ack);
+        NTOHS(ti->ti_win);
+        NTOHS(ti->ti_urp);
+
+        /*
+         * Drop TCP, IP headers and TCP options.
+         */
+        m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+        m->m_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+
+        /*
+         * Locate pcb for segment.
+         */
 findso:
-	so = tcp_last_so;
-	if (so->so_fport != ti->ti_dport ||
-	    so->so_lport != ti->ti_sport ||
-	    so->so_laddr.s_addr != ti->ti_src.s_addr ||
-	    so->so_faddr.s_addr != ti->ti_dst.s_addr) {
-		so = solookup(&tcb, ti->ti_src, ti->ti_sport,
-			       ti->ti_dst, ti->ti_dport);
-		if (so)
-			tcp_last_so = so;
-		++tcpstat.tcps_socachemiss;
-	}
-
-	/*
-	 * If the state is CLOSED (i.e., TCB does not exist) then
-	 * all data in the incoming segment is discarded.
-	 * If the TCB exists but is in CLOSED state, it is embryonic,
-	 * but should either do a listen or a connect soon.
-	 *
-	 * state == CLOSED means we've done socreate() but haven't
-	 * attached it to a protocol yet...
-	 *
-	 * XXX If a TCB does not exist, and the TH_SYN flag is
-	 * the only flag set, then create a session, mark it
-	 * as if it was LISTENING, and continue...
-	 */
-	if (so == 0) {
-	  if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)
-	    goto dropwithreset;
-
-	  if ((so = socreate()) == NULL)
-	    goto dropwithreset;
-	  if (tcp_attach(pData, so) < 0) {
-	    free(so); /* Not sofree (if it failed, it's not insqued) */
-	    goto dropwithreset;
-	  }
-
-	  sbreserve(&so->so_snd, tcp_sndspace);
-	  sbreserve(&so->so_rcv, tcp_rcvspace);
-
-	  /*		tcp_last_so = so; */  /* XXX ? */
-	  /*		tp = sototcpcb(so);    */
-
-	  so->so_laddr = ti->ti_src;
-	  so->so_lport = ti->ti_sport;
-	  so->so_faddr = ti->ti_dst;
-	  so->so_fport = ti->ti_dport;
-
-	  if ((so->so_iptos = tcp_tos(so)) == 0)
-	    so->so_iptos = ((struct ip *)ti)->ip_tos;
-
-	  tp = sototcpcb(so);
-	  tp->t_state = TCPS_LISTEN;
-	}
+        so = tcp_last_so;
+        if (so->so_fport != ti->ti_dport ||
+            so->so_lport != ti->ti_sport ||
+            so->so_laddr.s_addr != ti->ti_src.s_addr ||
+            so->so_faddr.s_addr != ti->ti_dst.s_addr) {
+                so = solookup(&tcb, ti->ti_src, ti->ti_sport,
+                               ti->ti_dst, ti->ti_dport);
+                if (so)
+                        tcp_last_so = so;
+                ++tcpstat.tcps_socachemiss;
+        }
+
+        /*
+         * If the state is CLOSED (i.e., TCB does not exist) then
+         * all data in the incoming segment is discarded.
+         * If the TCB exists but is in CLOSED state, it is embryonic,
+         * but should either do a listen or a connect soon.
+         *
+         * state == CLOSED means we've done socreate() but haven't
+         * attached it to a protocol yet...
+         *
+         * XXX If a TCB does not exist, and the TH_SYN flag is
+         * the only flag set, then create a session, mark it
+         * as if it was LISTENING, and continue...
+         */
+        if (so == 0) {
+          if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)
+            goto dropwithreset;
+
+          if ((so = socreate()) == NULL)
+            goto dropwithreset;
+          if (tcp_attach(pData, so) < 0) {
+            free(so); /* Not sofree (if it failed, it's not insqued) */
+            goto dropwithreset;
+          }
+
+          sbreserve(&so->so_snd, tcp_sndspace);
+          sbreserve(&so->so_rcv, tcp_rcvspace);
+
+          /*            tcp_last_so = so; */  /* XXX ? */
+          /*            tp = sototcpcb(so);    */
+
+          so->so_laddr = ti->ti_src;
+          so->so_lport = ti->ti_sport;
+          so->so_faddr = ti->ti_dst;
+          so->so_fport = ti->ti_dport;
+
+          if ((so->so_iptos = tcp_tos(so)) == 0)
+            so->so_iptos = ((struct ip *)ti)->ip_tos;
+
+          tp = sototcpcb(so);
+          tp->t_state = TCPS_LISTEN;
+        }
 
         /*
          * If this is a still-connecting socket, this probably
          * a retransmit of the SYN.  Whether it's a retransmit SYN
-	 * or something else, we nuke it.
+         * or something else, we nuke it.
          */
         if (so->so_state & SS_ISFCONNECTING)
                 goto drop;
 
-	tp = sototcpcb(so);
-
-	/* XXX Should never fail */
-	if (tp == 0)
-		goto dropwithreset;
-	if (tp->t_state == TCPS_CLOSED)
-		goto drop;
-
-	/* Unscale the window into a 32-bit value. */
-/*	if ((tiflags & TH_SYN) == 0)
- *		tiwin = ti->ti_win << tp->snd_scale;
- *	else
- */
-		tiwin = ti->ti_win;
-
-	/*
-	 * Segment received on connection.
-	 * Reset idle time and keep-alive timer.
-	 */
-	tp->t_idle = 0;
-	if (so_options)
-	   tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
-	else
-	   tp->t_timer[TCPT_KEEP] = tcp_keepidle;
-
-	/*
-	 * Process options if not in LISTEN state,
-	 * else do it below (after getting remote address).
-	 */
-	if (optp && tp->t_state != TCPS_LISTEN)
-		tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
+        tp = sototcpcb(so);
+
+        /* XXX Should never fail */
+        if (tp == 0)
+                goto dropwithreset;
+        if (tp->t_state == TCPS_CLOSED)
+                goto drop;
+
+        /* Unscale the window into a 32-bit value. */
+/*      if ((tiflags & TH_SYN) == 0)
+ *              tiwin = ti->ti_win << tp->snd_scale;
+ *      else
+ */
+                tiwin = ti->ti_win;
+
+        /*
+         * Segment received on connection.
+         * Reset idle time and keep-alive timer.
+         */
+        tp->t_idle = 0;
+        if (so_options)
+           tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
+        else
+           tp->t_timer[TCPT_KEEP] = tcp_keepidle;
+
+        /*
+         * Process options if not in LISTEN state,
+         * else do it below (after getting remote address).
+         */
+        if (optp && tp->t_state != TCPS_LISTEN)
+                tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
 /* , */
-/*			&ts_present, &ts_val, &ts_ecr); */
-
-	/*
-	 * Header prediction: check for the two common cases
-	 * of a uni-directional data xfer.  If the packet has
-	 * no control flags, is in-sequence, the window didn't
-	 * change and we're not retransmitting, it's a
-	 * candidate.  If the length is zero and the ack moved
-	 * forward, we're the sender side of the xfer.  Just
-	 * free the data acked & wake any higher level process
-	 * that was blocked waiting for space.  If the length
-	 * is non-zero and the ack didn't move, we're the
-	 * receiver side.  If we're getting packets in-order
-	 * (the reassembly queue is empty), add the data to
-	 * the socket buffer and note that we need a delayed ack.
-	 *
-	 * XXX Some of these tests are not needed
-	 * eg: the tiwin == tp->snd_wnd prevents many more
-	 * predictions.. with no *real* advantage..
-	 */
-	if (tp->t_state == TCPS_ESTABLISHED &&
-	    (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&
-/*	    (!ts_present || TSTMP_GEQ(ts_val, tp->ts_recent)) && */
-	    ti->ti_seq == tp->rcv_nxt &&
-	    tiwin && tiwin == tp->snd_wnd &&
-	    tp->snd_nxt == tp->snd_max) {
-		/*
-		 * If last ACK falls within this segment's sequence numbers,
-		 *  record the timestamp.
-		 */
-/*		if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
- *		   SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len)) {
- *			tp->ts_recent_age = tcp_now;
- *			tp->ts_recent = ts_val;
- *		}
- */
-		if (ti->ti_len == 0) {
-			if (SEQ_GT(ti->ti_ack, tp->snd_una) &&
-			    SEQ_LEQ(ti->ti_ack, tp->snd_max) &&
-			    tp->snd_cwnd >= tp->snd_wnd) {
-				/*
-				 * this is a pure ack for outstanding data.
-				 */
-				++tcpstat.tcps_predack;
-/*				if (ts_present)
- *					tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
- *				else
- */				     if (tp->t_rtt &&
-					    SEQ_GT(ti->ti_ack, tp->t_rtseq))
-					tcp_xmit_timer(pData, tp, tp->t_rtt);
-				acked = ti->ti_ack - tp->snd_una;
-				tcpstat.tcps_rcvackpack++;
-				tcpstat.tcps_rcvackbyte += acked;
-				sbdrop(&so->so_snd, acked);
-				tp->snd_una = ti->ti_ack;
-				m_freem(pData, m);
-
-				/*
-				 * If all outstanding data are acked, stop
-				 * retransmit timer, otherwise restart timer
-				 * using current (possibly backed-off) value.
-				 * If process is waiting for space,
-				 * wakeup/selwakeup/signal.  If data
-				 * are ready to send, let tcp_output
-				 * decide between more output or persist.
-				 */
-				if (tp->snd_una == tp->snd_max)
-					tp->t_timer[TCPT_REXMT] = 0;
-				else if (tp->t_timer[TCPT_PERSIST] == 0)
-					tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
-
-				/*
-				 * There's room in so_snd, sowwakup will read()
-				 * from the socket if we can
-				 */
-/*				if (so->so_snd.sb_flags & SB_NOTIFY)
- *					sowwakeup(so);
- */
-				/*
-				 * This is called because sowwakeup might have
-				 * put data into so_snd.  Since we don't so sowwakeup,
-				 * we don't need this.. XXX???
-				 */
-				if (so->so_snd.sb_cc)
-					(void) tcp_output(pData, tp);
-
-				return;
-			}
-		} else if (ti->ti_ack == tp->snd_una &&
+/*                      &ts_present, &ts_val, &ts_ecr); */
+
+        /*
+         * Header prediction: check for the two common cases
+         * of a uni-directional data xfer.  If the packet has
+         * no control flags, is in-sequence, the window didn't
+         * change and we're not retransmitting, it's a
+         * candidate.  If the length is zero and the ack moved
+         * forward, we're the sender side of the xfer.  Just
+         * free the data acked & wake any higher level process
+         * that was blocked waiting for space.  If the length
+         * is non-zero and the ack didn't move, we're the
+         * receiver side.  If we're getting packets in-order
+         * (the reassembly queue is empty), add the data to
+         * the socket buffer and note that we need a delayed ack.
+         *
+         * XXX Some of these tests are not needed
+         * eg: the tiwin == tp->snd_wnd prevents many more
+         * predictions.. with no *real* advantage..
+         */
+        if (tp->t_state == TCPS_ESTABLISHED &&
+            (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&
+/*          (!ts_present || TSTMP_GEQ(ts_val, tp->ts_recent)) && */
+            ti->ti_seq == tp->rcv_nxt &&
+            tiwin && tiwin == tp->snd_wnd &&
+            tp->snd_nxt == tp->snd_max) {
+                /*
+                 * If last ACK falls within this segment's sequence numbers,
+                 *  record the timestamp.
+                 */
+/*              if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
+ *                 SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len)) {
+ *                      tp->ts_recent_age = tcp_now;
+ *                      tp->ts_recent = ts_val;
+ *              }
+ */
+                if (ti->ti_len == 0) {
+                        if (SEQ_GT(ti->ti_ack, tp->snd_una) &&
+                            SEQ_LEQ(ti->ti_ack, tp->snd_max) &&
+                            tp->snd_cwnd >= tp->snd_wnd) {
+                                /*
+                                 * this is a pure ack for outstanding data.
+                                 */
+                                ++tcpstat.tcps_predack;
+/*                              if (ts_present)
+ *                                      tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
+ *                              else
+ */                                  if (tp->t_rtt &&
+                                            SEQ_GT(ti->ti_ack, tp->t_rtseq))
+                                        tcp_xmit_timer(pData, tp, tp->t_rtt);
+                                acked = ti->ti_ack - tp->snd_una;
+                                tcpstat.tcps_rcvackpack++;
+                                tcpstat.tcps_rcvackbyte += acked;
+                                sbdrop(&so->so_snd, acked);
+                                tp->snd_una = ti->ti_ack;
+                                m_freem(pData, m);
+
+                                /*
+                                 * If all outstanding data are acked, stop
+                                 * retransmit timer, otherwise restart timer
+                                 * using current (possibly backed-off) value.
+                                 * If process is waiting for space,
+                                 * wakeup/selwakeup/signal.  If data
+                                 * are ready to send, let tcp_output
+                                 * decide between more output or persist.
+                                 */
+                                if (tp->snd_una == tp->snd_max)
+                                        tp->t_timer[TCPT_REXMT] = 0;
+                                else if (tp->t_timer[TCPT_PERSIST] == 0)
+                                        tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+
+                                /*
+                                 * There's room in so_snd, sowwakup will read()
+                                 * from the socket if we can
+                                 */
+/*                              if (so->so_snd.sb_flags & SB_NOTIFY)
+ *                                      sowwakeup(so);
+ */
+                                /*
+                                 * This is called because sowwakeup might have
+                                 * put data into so_snd.  Since we don't so sowwakeup,
+                                 * we don't need this.. XXX???
+                                 */
+                                if (so->so_snd.sb_cc)
+                                        (void) tcp_output(pData, tp);
+
+                                return;
+                        }
+                } else if (ti->ti_ack == tp->snd_una &&
 #ifndef VBOX_WITH_BSD_TCP_REASS
-		    u32_to_ptr(pData, tp->seg_next, struct tcpcb *) == tp &&
+                    u32_to_ptr(pData, tp->seg_next, struct tcpcb *) == tp &&
 #else  /* VBOX_WITH_BSD_TCP_REASS */
                     LIST_FIRST(&tp->t_segq) &&
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-		    ti->ti_len <= sbspace(&so->so_rcv)) {
-			/*
-			 * this is a pure, in-sequence data packet
-			 * with nothing on the reassembly queue and
-			 * we have enough buffer space to take it.
-			 */
-			++tcpstat.tcps_preddat;
-			tp->rcv_nxt += ti->ti_len;
-			tcpstat.tcps_rcvpack++;
-			tcpstat.tcps_rcvbyte += ti->ti_len;
-			/*
-			 * Add data to socket buffer.
-			 */
-			if (so->so_emu) {
-				if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
-			} else
-				sbappend(pData, so, m);
-
-			/*
-			 * XXX This is called when data arrives.  Later, check
-			 * if we can actually write() to the socket
-			 * XXX Need to check? It's be NON_BLOCKING
-			 */
-/*			sorwakeup(so); */
-
-			/*
-			 * If this is a short packet, then ACK now - with Nagel
-			 *	congestion avoidance sender won't send more until
-			 *	he gets an ACK.
-			 *
-			 * It is better to not delay acks at all to maximize
-			 * TCP throughput.  See RFC 2581.
-			 */
-			tp->t_flags |= TF_ACKNOW;
-			tcp_output(pData, tp);
-			return;
-		}
-	} /* header prediction */
-	/*
-	 * Calculate amount of space in receive window,
-	 * and then do TCP input processing.
-	 * Receive window is amount of space in rcv queue,
-	 * but not less than advertised window.
-	 */
-	{ int win;
+                    ti->ti_len <= sbspace(&so->so_rcv)) {
+                        /*
+                         * this is a pure, in-sequence data packet
+                         * with nothing on the reassembly queue and
+                         * we have enough buffer space to take it.
+                         */
+                        ++tcpstat.tcps_preddat;
+                        tp->rcv_nxt += ti->ti_len;
+                        tcpstat.tcps_rcvpack++;
+                        tcpstat.tcps_rcvbyte += ti->ti_len;
+                        /*
+                         * Add data to socket buffer.
+                         */
+                        if (so->so_emu) {
+                                if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
+                        } else
+                                sbappend(pData, so, m);
+
+                        /*
+                         * XXX This is called when data arrives.  Later, check
+                         * if we can actually write() to the socket
+                         * XXX Need to check? It's be NON_BLOCKING
+                         */
+/*                      sorwakeup(so); */
+
+                        /*
+                         * If this is a short packet, then ACK now - with Nagel
+                         *      congestion avoidance sender won't send more until
+                         *      he gets an ACK.
+                         *
+                         * It is better to not delay acks at all to maximize
+                         * TCP throughput.  See RFC 2581.
+                         */
+                        tp->t_flags |= TF_ACKNOW;
+                        tcp_output(pData, tp);
+                        return;
+                }
+        } /* header prediction */
+        /*
+         * Calculate amount of space in receive window,
+         * and then do TCP input processing.
+         * Receive window is amount of space in rcv queue,
+         * but not less than advertised window.
+         */
+        { int win;
           win = sbspace(&so->so_rcv);
-	  if (win < 0)
-	    win = 0;
-	  tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt));
-	}
-
-	switch (tp->t_state) {
-
-	/*
-	 * If the state is LISTEN then ignore segment if it contains an RST.
-	 * If the segment contains an ACK then it is bad and send a RST.
-	 * If it does not contain a SYN then it is not interesting; drop it.
-	 * Don't bother responding if the destination was a broadcast.
-	 * Otherwise initialize tp->rcv_nxt, and tp->irs, select an initial
-	 * tp->iss, and send a segment:
-	 *     <SEQ=ISS><ACK=RCV_NXT><CTL=SYN,ACK>
-	 * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss.
-	 * Fill in remote peer address fields if not previously specified.
-	 * Enter SYN_RECEIVED state, and process any other fields of this
-	 * segment in this state.
-	 */
-	case TCPS_LISTEN: {
-
-	  if (tiflags & TH_RST)
-	    goto drop;
-	  if (tiflags & TH_ACK)
-	    goto dropwithreset;
-	  if ((tiflags & TH_SYN) == 0)
-	    goto drop;
-
-	  /*
-	   * This has way too many gotos...
-	   * But a bit of spaghetti code never hurt anybody :)
-	   */
-
-	  if (so->so_emu & EMU_NOCONNECT) {
-	    so->so_emu &= ~EMU_NOCONNECT;
-	    goto cont_input;
-	  }
-
-	  if((tcp_fconnect(pData, so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
-	    u_char code=ICMP_UNREACH_NET;
-	    DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n",
-			errno,strerror(errno)));
-	    if(errno == ECONNREFUSED) {
-	      /* ACK the SYN, send RST to refuse the connection */
-	      tcp_respond(pData, tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
-			  TH_RST|TH_ACK);
-	    } else {
-	      if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
-	      HTONL(ti->ti_seq);             /* restore tcp header */
-	      HTONL(ti->ti_ack);
-	      HTONS(ti->ti_win);
-	      HTONS(ti->ti_urp);
-	      m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-	      m->m_len  += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
-	      *ip=save_ip;
-	      icmp_error(pData, m, ICMP_UNREACH,code, 0,strerror(errno));
-	    }
-	    tp = tcp_close(pData, tp);
-	    m_free(pData, m);
-	  } else {
-	    /*
-	     * Haven't connected yet, save the current mbuf
-	     * and ti, and return
-	     * XXX Some OS's don't tell us whether the connect()
-	     * succeeded or not.  So we must time it out.
-	     */
-	    so->so_m = m;
-	    so->so_ti = ti;
-	    tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
-	    tp->t_state = TCPS_SYN_RECEIVED;
-	  }
-	  return;
-
-	cont_conn:
-	  /* m==NULL
-	   * Check if the connect succeeded
-	   */
-	  if (so->so_state & SS_NOFDREF) {
-	    tp = tcp_close(pData, tp);
-	    goto dropwithreset;
-	  }
-	cont_input:
-	  tcp_template(tp);
-
-	  if (optp)
-	    tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
-	  /* , */
-	  /*				&ts_present, &ts_val, &ts_ecr); */
-
-	  if (iss)
-	    tp->iss = iss;
-	  else
-	    tp->iss = tcp_iss;
-	  tcp_iss += TCP_ISSINCR/2;
-	  tp->irs = ti->ti_seq;
-	  tcp_sendseqinit(tp);
-	  tcp_rcvseqinit(tp);
-	  tp->t_flags |= TF_ACKNOW;
-	  tp->t_state = TCPS_SYN_RECEIVED;
-	  tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
-	  tcpstat.tcps_accepts++;
-	  goto trimthenstep6;
-	} /* case TCPS_LISTEN */
-
-	/*
-	 * If the state is SYN_SENT:
-	 *	if seg contains an ACK, but not for our SYN, drop the input.
-	 *	if seg contains a RST, then drop the connection.
-	 *	if seg does not contain SYN, then drop it.
-	 * Otherwise this is an acceptable SYN segment
-	 *	initialize tp->rcv_nxt and tp->irs
-	 *	if seg contains ack then advance tp->snd_una
-	 *	if SYN has been acked change to ESTABLISHED else SYN_RCVD state
-	 *	arrange for segment to be acked (eventually)
-	 *	continue processing rest of data/controls, beginning with URG
-	 */
-	case TCPS_SYN_SENT:
-		if ((tiflags & TH_ACK) &&
-		    (SEQ_LEQ(ti->ti_ack, tp->iss) ||
-		     SEQ_GT(ti->ti_ack, tp->snd_max)))
-			goto dropwithreset;
-
-		if (tiflags & TH_RST) {
-			if (tiflags & TH_ACK)
-				tp = tcp_drop(pData, tp,0); /* XXX Check t_softerror! */
-			goto drop;
-		}
-
-		if ((tiflags & TH_SYN) == 0)
-			goto drop;
-		if (tiflags & TH_ACK) {
-			tp->snd_una = ti->ti_ack;
-			if (SEQ_LT(tp->snd_nxt, tp->snd_una))
-				tp->snd_nxt = tp->snd_una;
-		}
-
-		tp->t_timer[TCPT_REXMT] = 0;
-		tp->irs = ti->ti_seq;
-		tcp_rcvseqinit(tp);
-		tp->t_flags |= TF_ACKNOW;
-		if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
-			tcpstat.tcps_connects++;
-			soisfconnected(so);
-			tp->t_state = TCPS_ESTABLISHED;
-
-			/* Do window scaling on this connection? */
-/*			if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- *				(TF_RCVD_SCALE|TF_REQ_SCALE)) {
- * 				tp->snd_scale = tp->requested_s_scale;
- *				tp->rcv_scale = tp->request_r_scale;
- *			}
+          if (win < 0)
+            win = 0;
+          tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt));
+        }
+
+        switch (tp->t_state) {
+
+        /*
+         * If the state is LISTEN then ignore segment if it contains an RST.
+         * If the segment contains an ACK then it is bad and send a RST.
+         * If it does not contain a SYN then it is not interesting; drop it.
+         * Don't bother responding if the destination was a broadcast.
+         * Otherwise initialize tp->rcv_nxt, and tp->irs, select an initial
+         * tp->iss, and send a segment:
+         *     <SEQ=ISS><ACK=RCV_NXT><CTL=SYN,ACK>
+         * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss.
+         * Fill in remote peer address fields if not previously specified.
+         * Enter SYN_RECEIVED state, and process any other fields of this
+         * segment in this state.
+         */
+        case TCPS_LISTEN: {
+
+          if (tiflags & TH_RST)
+            goto drop;
+          if (tiflags & TH_ACK)
+            goto dropwithreset;
+          if ((tiflags & TH_SYN) == 0)
+            goto drop;
+
+          /*
+           * This has way too many gotos...
+           * But a bit of spaghetti code never hurt anybody :)
+           */
+
+          if (so->so_emu & EMU_NOCONNECT) {
+            so->so_emu &= ~EMU_NOCONNECT;
+            goto cont_input;
+          }
+
+          if((tcp_fconnect(pData, so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
+            u_char code=ICMP_UNREACH_NET;
+            DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n",
+                        errno,strerror(errno)));
+            if(errno == ECONNREFUSED) {
+              /* ACK the SYN, send RST to refuse the connection */
+              tcp_respond(pData, tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
+                          TH_RST|TH_ACK);
+            } else {
+              if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
+              HTONL(ti->ti_seq);             /* restore tcp header */
+              HTONL(ti->ti_ack);
+              HTONS(ti->ti_win);
+              HTONS(ti->ti_urp);
+              m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+              m->m_len  += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
+              *ip=save_ip;
+              icmp_error(pData, m, ICMP_UNREACH,code, 0,strerror(errno));
+            }
+            tp = tcp_close(pData, tp);
+            m_free(pData, m);
+          } else {
+            /*
+             * Haven't connected yet, save the current mbuf
+             * and ti, and return
+             * XXX Some OS's don't tell us whether the connect()
+             * succeeded or not.  So we must time it out.
+             */
+            so->so_m = m;
+            so->so_ti = ti;
+            tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
+            tp->t_state = TCPS_SYN_RECEIVED;
+          }
+          return;
+
+        cont_conn:
+          /* m==NULL
+           * Check if the connect succeeded
+           */
+          if (so->so_state & SS_NOFDREF) {
+            tp = tcp_close(pData, tp);
+            goto dropwithreset;
+          }
+        cont_input:
+          tcp_template(tp);
+
+          if (optp)
+            tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
+          /* , */
+          /*                            &ts_present, &ts_val, &ts_ecr); */
+
+          if (iss)
+            tp->iss = iss;
+          else
+            tp->iss = tcp_iss;
+          tcp_iss += TCP_ISSINCR/2;
+          tp->irs = ti->ti_seq;
+          tcp_sendseqinit(tp);
+          tcp_rcvseqinit(tp);
+          tp->t_flags |= TF_ACKNOW;
+          tp->t_state = TCPS_SYN_RECEIVED;
+          tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
+          tcpstat.tcps_accepts++;
+          goto trimthenstep6;
+        } /* case TCPS_LISTEN */
+
+        /*
+         * If the state is SYN_SENT:
+         *      if seg contains an ACK, but not for our SYN, drop the input.
+         *      if seg contains a RST, then drop the connection.
+         *      if seg does not contain SYN, then drop it.
+         * Otherwise this is an acceptable SYN segment
+         *      initialize tp->rcv_nxt and tp->irs
+         *      if seg contains ack then advance tp->snd_una
+         *      if SYN has been acked change to ESTABLISHED else SYN_RCVD state
+         *      arrange for segment to be acked (eventually)
+         *      continue processing rest of data/controls, beginning with URG
+         */
+        case TCPS_SYN_SENT:
+                if ((tiflags & TH_ACK) &&
+                    (SEQ_LEQ(ti->ti_ack, tp->iss) ||
+                     SEQ_GT(ti->ti_ack, tp->snd_max)))
+                        goto dropwithreset;
+
+                if (tiflags & TH_RST) {
+                        if (tiflags & TH_ACK)
+                                tp = tcp_drop(pData, tp,0); /* XXX Check t_softerror! */
+                        goto drop;
+                }
+
+                if ((tiflags & TH_SYN) == 0)
+                        goto drop;
+                if (tiflags & TH_ACK) {
+                        tp->snd_una = ti->ti_ack;
+                        if (SEQ_LT(tp->snd_nxt, tp->snd_una))
+                                tp->snd_nxt = tp->snd_una;
+                }
+
+                tp->t_timer[TCPT_REXMT] = 0;
+                tp->irs = ti->ti_seq;
+                tcp_rcvseqinit(tp);
+                tp->t_flags |= TF_ACKNOW;
+                if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
+                        tcpstat.tcps_connects++;
+                        soisfconnected(so);
+                        tp->t_state = TCPS_ESTABLISHED;
+
+                        /* Do window scaling on this connection? */
+/*                      if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
+ *                              (TF_RCVD_SCALE|TF_REQ_SCALE)) {
+ *                              tp->snd_scale = tp->requested_s_scale;
+ *                              tp->rcv_scale = tp->request_r_scale;
+ *                      }
  */
 #ifndef VBOX_WITH_BSD_TCP_REASS
-			(void) tcp_reass(pData, tp, (struct tcpiphdr *)0,
-				(struct mbuf *)0);
+                        (void) tcp_reass(pData, tp, (struct tcpiphdr *)0,
+                                (struct mbuf *)0);
 #else  /* VBOX_WITH_BSD_TCP_REASS */
-			(void) tcp_reass(pData, tp, (struct tcphdr *)0, NULL, (struct mbuf *)0);
+                        (void) tcp_reass(pData, tp, (struct tcphdr *)0, NULL, (struct mbuf *)0);
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-			/*
-			 * if we didn't have to retransmit the SYN,
-			 * use its rtt as our initial srtt & rtt var.
-			 */
-			if (tp->t_rtt)
-				tcp_xmit_timer(pData, tp, tp->t_rtt);
-		} else
-			tp->t_state = TCPS_SYN_RECEIVED;
+                        /*
+                         * if we didn't have to retransmit the SYN,
+                         * use its rtt as our initial srtt & rtt var.
+                         */
+                        if (tp->t_rtt)
+                                tcp_xmit_timer(pData, tp, tp->t_rtt);
+                } else
+                        tp->t_state = TCPS_SYN_RECEIVED;
 
 trimthenstep6:
-		/*
-		 * Advance ti->ti_seq to correspond to first data byte.
-		 * If data, trim to stay within window,
-		 * dropping FIN if necessary.
-		 */
-		ti->ti_seq++;
-		if (ti->ti_len > tp->rcv_wnd) {
-			todrop = ti->ti_len - tp->rcv_wnd;
-			m_adj(m, -todrop);
-			ti->ti_len = tp->rcv_wnd;
-			tiflags &= ~TH_FIN;
-			tcpstat.tcps_rcvpackafterwin++;
-			tcpstat.tcps_rcvbyteafterwin += todrop;
-		}
-		tp->snd_wl1 = ti->ti_seq - 1;
-		tp->rcv_up = ti->ti_seq;
-		goto step6;
-	} /* switch tp->t_state */
-	/*
-	 * States other than LISTEN or SYN_SENT.
-	 * First check timestamp, if present.
-	 * Then check that at least some bytes of segment are within
-	 * receive window.  If segment begins before rcv_nxt,
-	 * drop leading data (and SYN); if nothing left, just ack.
-	 *
-	 * RFC 1323 PAWS: If we have a timestamp reply on this segment
-	 * and it's less than ts_recent, drop it.
-	 */
-/*	if (ts_present && (tiflags & TH_RST) == 0 && tp->ts_recent &&
- *	    TSTMP_LT(ts_val, tp->ts_recent)) {
+                /*
+                 * Advance ti->ti_seq to correspond to first data byte.
+                 * If data, trim to stay within window,
+                 * dropping FIN if necessary.
+                 */
+                ti->ti_seq++;
+                if (ti->ti_len > tp->rcv_wnd) {
+                        todrop = ti->ti_len - tp->rcv_wnd;
+                        m_adj(m, -todrop);
+                        ti->ti_len = tp->rcv_wnd;
+                        tiflags &= ~TH_FIN;
+                        tcpstat.tcps_rcvpackafterwin++;
+                        tcpstat.tcps_rcvbyteafterwin += todrop;
+                }
+                tp->snd_wl1 = ti->ti_seq - 1;
+                tp->rcv_up = ti->ti_seq;
+                goto step6;
+        } /* switch tp->t_state */
+        /*
+         * States other than LISTEN or SYN_SENT.
+         * First check timestamp, if present.
+         * Then check that at least some bytes of segment are within
+         * receive window.  If segment begins before rcv_nxt,
+         * drop leading data (and SYN); if nothing left, just ack.
+         *
+         * RFC 1323 PAWS: If we have a timestamp reply on this segment
+         * and it's less than ts_recent, drop it.
+         */
+/*      if (ts_present && (tiflags & TH_RST) == 0 && tp->ts_recent &&
+ *          TSTMP_LT(ts_val, tp->ts_recent)) {
  *
- */		/* Check to see if ts_recent is over 24 days old.  */
-/*		if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
- */			/*
- *			 * Invalidate ts_recent.  If this segment updates
- *			 * ts_recent, the age will be reset later and ts_recent
- *			 * will get a valid value.  If it does not, setting
- *			 * ts_recent to zero will at least satisfy the
- *			 * requirement that zero be placed in the timestamp
- *			 * echo reply when ts_recent isn't valid.  The
- *			 * age isn't reset until we get a valid ts_recent
- *			 * because we don't want out-of-order segments to be
- *			 * dropped when ts_recent is old.
- *			 */
-/*			tp->ts_recent = 0;
- *		} else {
- *			tcpstat.tcps_rcvduppack++;
- *			tcpstat.tcps_rcvdupbyte += ti->ti_len;
- *			tcpstat.tcps_pawsdrop++;
- *			goto dropafterack;
- *		}
- *	}
- */
-
-	todrop = tp->rcv_nxt - ti->ti_seq;
-	if (todrop > 0) {
-		if (tiflags & TH_SYN) {
-			tiflags &= ~TH_SYN;
-			ti->ti_seq++;
-			if (ti->ti_urp > 1)
-				ti->ti_urp--;
-			else
-				tiflags &= ~TH_URG;
-			todrop--;
-		}
-		/*
-		 * Following if statement from Stevens, vol. 2, p. 960.
-		 */
-		if (todrop > ti->ti_len
-		    || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) {
-			/*
-			 * Any valid FIN must be to the left of the window.
-			 * At this point the FIN must be a duplicate or out
-			 * of sequence; drop it.
-			 */
-			tiflags &= ~TH_FIN;
-
-			/*
-			 * Send an ACK to resynchronize and drop any data.
-			 * But keep on processing for RST or ACK.
-			 */
-			tp->t_flags |= TF_ACKNOW;
-			todrop = ti->ti_len;
-			tcpstat.tcps_rcvduppack++;
-			tcpstat.tcps_rcvdupbyte += todrop;
-		} else {
-			tcpstat.tcps_rcvpartduppack++;
-			tcpstat.tcps_rcvpartdupbyte += todrop;
-		}
-		m_adj(m, todrop);
-		ti->ti_seq += todrop;
-		ti->ti_len -= todrop;
-		if (ti->ti_urp > todrop)
-			ti->ti_urp -= todrop;
-		else {
-			tiflags &= ~TH_URG;
-			ti->ti_urp = 0;
-		}
-	}
-	/*
-	 * If new data are received on a connection after the
-	 * user processes are gone, then RST the other end.
-	 */
-	if ((so->so_state & SS_NOFDREF) &&
-	    tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) {
-		tp = tcp_close(pData, tp);
-		tcpstat.tcps_rcvafterclose++;
-		goto dropwithreset;
-	}
-
-	/*
-	 * If segment ends after window, drop trailing data
-	 * (and PUSH and FIN); if nothing left, just ACK.
-	 */
-	todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
-	if (todrop > 0) {
-		tcpstat.tcps_rcvpackafterwin++;
-		if (todrop >= ti->ti_len) {
-			tcpstat.tcps_rcvbyteafterwin += ti->ti_len;
-			/*
-			 * If a new connection request is received
-			 * while in TIME_WAIT, drop the old connection
-			 * and start over if the sequence numbers
-			 * are above the previous ones.
-			 */
-			if (tiflags & TH_SYN &&
-			    tp->t_state == TCPS_TIME_WAIT &&
-			    SEQ_GT(ti->ti_seq, tp->rcv_nxt)) {
-				iss = tp->rcv_nxt + TCP_ISSINCR;
-				tp = tcp_close(pData, tp);
-				goto findso;
-			}
-			/*
-			 * If window is closed can only take segments at
-			 * window edge, and have to drop data and PUSH from
-			 * incoming segments.  Continue processing, but
-			 * remember to ack.  Otherwise, drop segment
-			 * and ack.
-			 */
-			if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) {
-				tp->t_flags |= TF_ACKNOW;
-				tcpstat.tcps_rcvwinprobe++;
-			} else
-				goto dropafterack;
-		} else
-			tcpstat.tcps_rcvbyteafterwin += todrop;
-		m_adj(m, -todrop);
-		ti->ti_len -= todrop;
-		tiflags &= ~(TH_PUSH|TH_FIN);
-	}
-
-	/*
-	 * If last ACK falls within this segment's sequence numbers,
-	 * record its timestamp.
-	 */
-/*	if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
- *	    SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len +
- *		   ((tiflags & (TH_SYN|TH_FIN)) != 0))) {
- *		tp->ts_recent_age = tcp_now;
- *		tp->ts_recent = ts_val;
- *	}
- */
-
-	/*
-	 * If the RST bit is set examine the state:
-	 *    SYN_RECEIVED STATE:
-	 *	If passive open, return to LISTEN state.
-	 *	If active open, inform user that connection was refused.
-	 *    ESTABLISHED, FIN_WAIT_1, FIN_WAIT2, CLOSE_WAIT STATES:
-	 *	Inform user that connection was reset, and close tcb.
-	 *    CLOSING, LAST_ACK, TIME_WAIT STATES
-	 *	Close the tcb.
-	 */
-	if (tiflags&TH_RST) switch (tp->t_state) {
-
-	case TCPS_SYN_RECEIVED:
-/*		so->so_error = ECONNREFUSED; */
-		goto close;
-
-	case TCPS_ESTABLISHED:
-	case TCPS_FIN_WAIT_1:
-	case TCPS_FIN_WAIT_2:
-	case TCPS_CLOSE_WAIT:
-/*		so->so_error = ECONNRESET; */
-	close:
-		tp->t_state = TCPS_CLOSED;
-		tcpstat.tcps_drops++;
-		tp = tcp_close(pData, tp);
-		goto drop;
-
-	case TCPS_CLOSING:
-	case TCPS_LAST_ACK:
-	case TCPS_TIME_WAIT:
-		tp = tcp_close(pData, tp);
-		goto drop;
-	}
-
-	/*
-	 * If a SYN is in the window, then this is an
-	 * error and we send an RST and drop the connection.
-	 */
-	if (tiflags & TH_SYN) {
-		tp = tcp_drop(pData, tp,0);
-		goto dropwithreset;
-	}
-
-	/*
-	 * If the ACK bit is off we drop the segment and return.
-	 */
-	if ((tiflags & TH_ACK) == 0) goto drop;
-
-	/*
-	 * Ack processing.
-	 */
-	switch (tp->t_state) {
-	/*
-	 * In SYN_RECEIVED state if the ack ACKs our SYN then enter
-	 * ESTABLISHED state and continue processing, otherwise
-	 * send an RST.  una<=ack<=max
-	 */
-	case TCPS_SYN_RECEIVED:
-
-		if (SEQ_GT(tp->snd_una, ti->ti_ack) ||
-		    SEQ_GT(ti->ti_ack, tp->snd_max))
-			goto dropwithreset;
-		tcpstat.tcps_connects++;
-		tp->t_state = TCPS_ESTABLISHED;
-		/*
-		 * The sent SYN is ack'ed with our sequence number +1
-		 * The first data byte already in the buffer will get
-		 * lost if no correction is made.  This is only needed for
-		 * SS_CTL since the buffer is empty otherwise.
-		 * tp->snd_una++; or:
-		 */
-		tp->snd_una=ti->ti_ack;
+ */             /* Check to see if ts_recent is over 24 days old.  */
+/*              if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
+ */                     /*
+ *                       * Invalidate ts_recent.  If this segment updates
+ *                       * ts_recent, the age will be reset later and ts_recent
+ *                       * will get a valid value.  If it does not, setting
+ *                       * ts_recent to zero will at least satisfy the
+ *                       * requirement that zero be placed in the timestamp
+ *                       * echo reply when ts_recent isn't valid.  The
+ *                       * age isn't reset until we get a valid ts_recent
+ *                       * because we don't want out-of-order segments to be
+ *                       * dropped when ts_recent is old.
+ *                       */
+/*                      tp->ts_recent = 0;
+ *              } else {
+ *                      tcpstat.tcps_rcvduppack++;
+ *                      tcpstat.tcps_rcvdupbyte += ti->ti_len;
+ *                      tcpstat.tcps_pawsdrop++;
+ *                      goto dropafterack;
+ *              }
+ *      }
+ */
+
+        todrop = tp->rcv_nxt - ti->ti_seq;
+        if (todrop > 0) {
+                if (tiflags & TH_SYN) {
+                        tiflags &= ~TH_SYN;
+                        ti->ti_seq++;
+                        if (ti->ti_urp > 1)
+                                ti->ti_urp--;
+                        else
+                                tiflags &= ~TH_URG;
+                        todrop--;
+                }
+                /*
+                 * Following if statement from Stevens, vol. 2, p. 960.
+                 */
+                if (todrop > ti->ti_len
+                    || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) {
+                        /*
+                         * Any valid FIN must be to the left of the window.
+                         * At this point the FIN must be a duplicate or out
+                         * of sequence; drop it.
+                         */
+                        tiflags &= ~TH_FIN;
+
+                        /*
+                         * Send an ACK to resynchronize and drop any data.
+                         * But keep on processing for RST or ACK.
+                         */
+                        tp->t_flags |= TF_ACKNOW;
+                        todrop = ti->ti_len;
+                        tcpstat.tcps_rcvduppack++;
+                        tcpstat.tcps_rcvdupbyte += todrop;
+                } else {
+                        tcpstat.tcps_rcvpartduppack++;
+                        tcpstat.tcps_rcvpartdupbyte += todrop;
+                }
+                m_adj(m, todrop);
+                ti->ti_seq += todrop;
+                ti->ti_len -= todrop;
+                if (ti->ti_urp > todrop)
+                        ti->ti_urp -= todrop;
+                else {
+                        tiflags &= ~TH_URG;
+                        ti->ti_urp = 0;
+                }
+        }
+        /*
+         * If new data are received on a connection after the
+         * user processes are gone, then RST the other end.
+         */
+        if ((so->so_state & SS_NOFDREF) &&
+            tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) {
+                tp = tcp_close(pData, tp);
+                tcpstat.tcps_rcvafterclose++;
+                goto dropwithreset;
+        }
+
+        /*
+         * If segment ends after window, drop trailing data
+         * (and PUSH and FIN); if nothing left, just ACK.
+         */
+        todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
+        if (todrop > 0) {
+                tcpstat.tcps_rcvpackafterwin++;
+                if (todrop >= ti->ti_len) {
+                        tcpstat.tcps_rcvbyteafterwin += ti->ti_len;
+                        /*
+                         * If a new connection request is received
+                         * while in TIME_WAIT, drop the old connection
+                         * and start over if the sequence numbers
+                         * are above the previous ones.
+                         */
+                        if (tiflags & TH_SYN &&
+                            tp->t_state == TCPS_TIME_WAIT &&
+                            SEQ_GT(ti->ti_seq, tp->rcv_nxt)) {
+                                iss = tp->rcv_nxt + TCP_ISSINCR;
+                                tp = tcp_close(pData, tp);
+                                goto findso;
+                        }
+                        /*
+                         * If window is closed can only take segments at
+                         * window edge, and have to drop data and PUSH from
+                         * incoming segments.  Continue processing, but
+                         * remember to ack.  Otherwise, drop segment
+                         * and ack.
+                         */
+                        if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) {
+                                tp->t_flags |= TF_ACKNOW;
+                                tcpstat.tcps_rcvwinprobe++;
+                        } else
+                                goto dropafterack;
+                } else
+                        tcpstat.tcps_rcvbyteafterwin += todrop;
+                m_adj(m, -todrop);
+                ti->ti_len -= todrop;
+                tiflags &= ~(TH_PUSH|TH_FIN);
+        }
+
+        /*
+         * If last ACK falls within this segment's sequence numbers,
+         * record its timestamp.
+         */
+/*      if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
+ *          SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len +
+ *                 ((tiflags & (TH_SYN|TH_FIN)) != 0))) {
+ *              tp->ts_recent_age = tcp_now;
+ *              tp->ts_recent = ts_val;
+ *      }
+ */
+
+        /*
+         * If the RST bit is set examine the state:
+         *    SYN_RECEIVED STATE:
+         *      If passive open, return to LISTEN state.
+         *      If active open, inform user that connection was refused.
+         *    ESTABLISHED, FIN_WAIT_1, FIN_WAIT2, CLOSE_WAIT STATES:
+         *      Inform user that connection was reset, and close tcb.
+         *    CLOSING, LAST_ACK, TIME_WAIT STATES
+         *      Close the tcb.
+         */
+        if (tiflags&TH_RST) switch (tp->t_state) {
+
+        case TCPS_SYN_RECEIVED:
+/*              so->so_error = ECONNREFUSED; */
+                goto close;
+
+        case TCPS_ESTABLISHED:
+        case TCPS_FIN_WAIT_1:
+        case TCPS_FIN_WAIT_2:
+        case TCPS_CLOSE_WAIT:
+/*              so->so_error = ECONNRESET; */
+        close:
+                tp->t_state = TCPS_CLOSED;
+                tcpstat.tcps_drops++;
+                tp = tcp_close(pData, tp);
+                goto drop;
+
+        case TCPS_CLOSING:
+        case TCPS_LAST_ACK:
+        case TCPS_TIME_WAIT:
+                tp = tcp_close(pData, tp);
+                goto drop;
+        }
+
+        /*
+         * If a SYN is in the window, then this is an
+         * error and we send an RST and drop the connection.
+         */
+        if (tiflags & TH_SYN) {
+                tp = tcp_drop(pData, tp,0);
+                goto dropwithreset;
+        }
+
+        /*
+         * If the ACK bit is off we drop the segment and return.
+         */
+        if ((tiflags & TH_ACK) == 0) goto drop;
+
+        /*
+         * Ack processing.
+         */
+        switch (tp->t_state) {
+        /*
+         * In SYN_RECEIVED state if the ack ACKs our SYN then enter
+         * ESTABLISHED state and continue processing, otherwise
+         * send an RST.  una<=ack<=max
+         */
+        case TCPS_SYN_RECEIVED:
+
+                if (SEQ_GT(tp->snd_una, ti->ti_ack) ||
+                    SEQ_GT(ti->ti_ack, tp->snd_max))
+                        goto dropwithreset;
+                tcpstat.tcps_connects++;
+                tp->t_state = TCPS_ESTABLISHED;
+                /*
+                 * The sent SYN is ack'ed with our sequence number +1
+                 * The first data byte already in the buffer will get
+                 * lost if no correction is made.  This is only needed for
+                 * SS_CTL since the buffer is empty otherwise.
+                 * tp->snd_una++; or:
+                 */
+                tp->snd_una=ti->ti_ack;
                 soisfconnected(so);
 
-		/* Do window scaling? */
-/*		if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- *			(TF_RCVD_SCALE|TF_REQ_SCALE)) {
- *			tp->snd_scale = tp->requested_s_scale;
- *			tp->rcv_scale = tp->request_r_scale;
- *		}
+                /* Do window scaling? */
+/*              if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
+ *                      (TF_RCVD_SCALE|TF_REQ_SCALE)) {
+ *                      tp->snd_scale = tp->requested_s_scale;
+ *                      tp->rcv_scale = tp->request_r_scale;
+ *              }
  */
 #ifndef VBOX_WITH_BSD_TCP_REASS
-		(void) tcp_reass(pData, tp, (struct tcpiphdr *)0, (struct mbuf *)0);
+                (void) tcp_reass(pData, tp, (struct tcpiphdr *)0, (struct mbuf *)0);
 #else  /* VBOX_WITH_BSD_TCP_REASS */
-		(void) tcp_reass(pData, tp, (struct tcphdr *)0, (int *)0, (struct mbuf *)0);
+                (void) tcp_reass(pData, tp, (struct tcphdr *)0, (int *)0, (struct mbuf *)0);
 #endif /*VBOX_WITH_BSD_TCP_REASS*/
-		tp->snd_wl1 = ti->ti_seq - 1;
-		/* Avoid ack processing; snd_una==ti_ack  =>  dup ack */
-		goto synrx_to_est;
-		/* fall into ... */
-
-	/*
-	 * In ESTABLISHED state: drop duplicate ACKs; ACK out of range
-	 * ACKs.  If the ack is in the range
-	 *	tp->snd_una < ti->ti_ack <= tp->snd_max
-	 * then advance tp->snd_una to ti->ti_ack and drop
-	 * data from the retransmission queue.  If this ACK reflects
-	 * more up to date window information we update our window information.
-	 */
-	case TCPS_ESTABLISHED:
-	case TCPS_FIN_WAIT_1:
-	case TCPS_FIN_WAIT_2:
-	case TCPS_CLOSE_WAIT:
-	case TCPS_CLOSING:
-	case TCPS_LAST_ACK:
-	case TCPS_TIME_WAIT:
-
-		if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) {
-			if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {
-			  tcpstat.tcps_rcvdupack++;
-			  DEBUG_MISC((dfd," dup ack  m = %lx  so = %lx \n",
-				      (long )m, (long )so));
-				/*
-				 * If we have outstanding data (other than
-				 * a window probe), this is a completely
-				 * duplicate ack (ie, window info didn't
-				 * change), the ack is the biggest we've
-				 * seen and we've seen exactly our rexmt
-				 * threshold of them, assume a packet
-				 * has been dropped and retransmit it.
-				 * Kludge snd_nxt & the congestion
-				 * window so we send only this one
-				 * packet.
-				 *
-				 * We know we're losing at the current
-				 * window size so do congestion avoidance
-				 * (set ssthresh to half the current window
-				 * and pull our congestion window back to
-				 * the new ssthresh).
-				 *
-				 * Dup acks mean that packets have left the
-				 * network (they're now cached at the receiver)
-				 * so bump cwnd by the amount in the receiver
-				 * to keep a constant cwnd packets in the
-				 * network.
-				 */
-				if (tp->t_timer[TCPT_REXMT] == 0 ||
-				    ti->ti_ack != tp->snd_una)
-					tp->t_dupacks = 0;
-				else if (++tp->t_dupacks == tcprexmtthresh) {
-					tcp_seq onxt = tp->snd_nxt;
-					u_int win =
-					    min(tp->snd_wnd, tp->snd_cwnd) / 2 /
-						tp->t_maxseg;
-
-					if (win < 2)
-						win = 2;
-					tp->snd_ssthresh = win * tp->t_maxseg;
-					tp->t_timer[TCPT_REXMT] = 0;
-					tp->t_rtt = 0;
-					tp->snd_nxt = ti->ti_ack;
-					tp->snd_cwnd = tp->t_maxseg;
-					(void) tcp_output(pData, tp);
-					tp->snd_cwnd = tp->snd_ssthresh +
-					       tp->t_maxseg * tp->t_dupacks;
-					if (SEQ_GT(onxt, tp->snd_nxt))
-						tp->snd_nxt = onxt;
-					goto drop;
-				} else if (tp->t_dupacks > tcprexmtthresh) {
-					tp->snd_cwnd += tp->t_maxseg;
-					(void) tcp_output(pData, tp);
-					goto drop;
-				}
-			} else
-				tp->t_dupacks = 0;
-			break;
-		}
-	synrx_to_est:
-		/*
-		 * If the congestion window was inflated to account
-		 * for the other side's cached packets, retract it.
-		 */
-		if (tp->t_dupacks > tcprexmtthresh &&
-		    tp->snd_cwnd > tp->snd_ssthresh)
-			tp->snd_cwnd = tp->snd_ssthresh;
-		tp->t_dupacks = 0;
-		if (SEQ_GT(ti->ti_ack, tp->snd_max)) {
-			tcpstat.tcps_rcvacktoomuch++;
-			goto dropafterack;
-		}
-		acked = ti->ti_ack - tp->snd_una;
-		tcpstat.tcps_rcvackpack++;
-		tcpstat.tcps_rcvackbyte += acked;
-
-		/*
-		 * If we have a timestamp reply, update smoothed
-		 * round trip time.  If no timestamp is present but
-		 * transmit timer is running and timed sequence
-		 * number was acked, update smoothed round trip time.
-		 * Since we now have an rtt measurement, cancel the
-		 * timer backoff (cf., Phil Karn's retransmit alg.).
-		 * Recompute the initial retransmit timer.
-		 */
-/*		if (ts_present)
- *			tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
- *		else
- */
-		     if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
-			tcp_xmit_timer(pData, tp,tp->t_rtt);
-
-		/*
-		 * If all outstanding data is acked, stop retransmit
-		 * timer and remember to restart (more output or persist).
-		 * If there is more data to be acked, restart retransmit
-		 * timer, using current (possibly backed-off) value.
-		 */
-		if (ti->ti_ack == tp->snd_max) {
-			tp->t_timer[TCPT_REXMT] = 0;
-			needoutput = 1;
-		} else if (tp->t_timer[TCPT_PERSIST] == 0)
-			tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
-		/*
-		 * When new data is acked, open the congestion window.
-		 * If the window gives us less than ssthresh packets
-		 * in flight, open exponentially (maxseg per packet).
-		 * Otherwise open linearly: maxseg per window
-		 * (maxseg^2 / cwnd per packet).
-		 */
-		{
-		  register u_int cw = tp->snd_cwnd;
-		  register u_int incr = tp->t_maxseg;
-
-		  if (cw > tp->snd_ssthresh)
-		    incr = incr * incr / cw;
-		  tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale);
-		}
-		if (acked > so->so_snd.sb_cc) {
-			tp->snd_wnd -= so->so_snd.sb_cc;
-			sbdrop(&so->so_snd, (int )so->so_snd.sb_cc);
-			ourfinisacked = 1;
-		} else {
-			sbdrop(&so->so_snd, acked);
-			tp->snd_wnd -= acked;
-			ourfinisacked = 0;
-		}
-		/*
-		 * XXX sowwakup is called when data is acked and there's room for
-		 * for more data... it should read() the socket
-		 */
-/*		if (so->so_snd.sb_flags & SB_NOTIFY)
- *			sowwakeup(so);
- */
-		tp->snd_una = ti->ti_ack;
-		if (SEQ_LT(tp->snd_nxt, tp->snd_una))
-			tp->snd_nxt = tp->snd_una;
-
-		switch (tp->t_state) {
-
-		/*
-		 * In FIN_WAIT_1 STATE in addition to the processing
-		 * for the ESTABLISHED state if our FIN is now acknowledged
-		 * then enter FIN_WAIT_2.
-		 */
-		case TCPS_FIN_WAIT_1:
-			if (ourfinisacked) {
-				/*
-				 * If we can't receive any more
-				 * data, then closing user can proceed.
-				 * Starting the timer is contrary to the
-				 * specification, but if we don't get a FIN
-				 * we'll hang forever.
-				 */
-				if (so->so_state & SS_FCANTRCVMORE) {
-					soisfdisconnected(so);
-					tp->t_timer[TCPT_2MSL] = tcp_maxidle;
-				}
-				tp->t_state = TCPS_FIN_WAIT_2;
-			}
-			break;
-
-	 	/*
-		 * In CLOSING STATE in addition to the processing for
-		 * the ESTABLISHED state if the ACK acknowledges our FIN
-		 * then enter the TIME-WAIT state, otherwise ignore
-		 * the segment.
-		 */
-		case TCPS_CLOSING:
-			if (ourfinisacked) {
-				tp->t_state = TCPS_TIME_WAIT;
-				tcp_canceltimers(tp);
-				tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-				soisfdisconnected(so);
-			}
-			break;
-
-		/*
-		 * In LAST_ACK, we may still be waiting for data to drain
-		 * and/or to be acked, as well as for the ack of our FIN.
-		 * If our FIN is now acknowledged, delete the TCB,
-		 * enter the closed state and return.
-		 */
-		case TCPS_LAST_ACK:
-			if (ourfinisacked) {
-				tp = tcp_close(pData, tp);
-				goto drop;
-			}
-			break;
-
-		/*
-		 * In TIME_WAIT state the only thing that should arrive
-		 * is a retransmission of the remote FIN.  Acknowledge
-		 * it and restart the finack timer.
-		 */
-		case TCPS_TIME_WAIT:
-			tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-			goto dropafterack;
-		}
-	} /* switch(tp->t_state) */
+                tp->snd_wl1 = ti->ti_seq - 1;
+                /* Avoid ack processing; snd_una==ti_ack  =>  dup ack */
+                goto synrx_to_est;
+                /* fall into ... */
+
+        /*
+         * In ESTABLISHED state: drop duplicate ACKs; ACK out of range
+         * ACKs.  If the ack is in the range
+         *      tp->snd_una < ti->ti_ack <= tp->snd_max
+         * then advance tp->snd_una to ti->ti_ack and drop
+         * data from the retransmission queue.  If this ACK reflects
+         * more up to date window information we update our window information.
+         */
+        case TCPS_ESTABLISHED:
+        case TCPS_FIN_WAIT_1:
+        case TCPS_FIN_WAIT_2:
+        case TCPS_CLOSE_WAIT:
+        case TCPS_CLOSING:
+        case TCPS_LAST_ACK:
+        case TCPS_TIME_WAIT:
+
+                if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) {
+                        if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {
+                          tcpstat.tcps_rcvdupack++;
+                          DEBUG_MISC((dfd," dup ack  m = %lx  so = %lx \n",
+                                      (long )m, (long )so));
+                                /*
+                                 * If we have outstanding data (other than
+                                 * a window probe), this is a completely
+                                 * duplicate ack (ie, window info didn't
+                                 * change), the ack is the biggest we've
+                                 * seen and we've seen exactly our rexmt
+                                 * threshold of them, assume a packet
+                                 * has been dropped and retransmit it.
+                                 * Kludge snd_nxt & the congestion
+                                 * window so we send only this one
+                                 * packet.
+                                 *
+                                 * We know we're losing at the current
+                                 * window size so do congestion avoidance
+                                 * (set ssthresh to half the current window
+                                 * and pull our congestion window back to
+                                 * the new ssthresh).
+                                 *
+                                 * Dup acks mean that packets have left the
+                                 * network (they're now cached at the receiver)
+                                 * so bump cwnd by the amount in the receiver
+                                 * to keep a constant cwnd packets in the
+                                 * network.
+                                 */
+                                if (tp->t_timer[TCPT_REXMT] == 0 ||
+                                    ti->ti_ack != tp->snd_una)
+                                        tp->t_dupacks = 0;
+                                else if (++tp->t_dupacks == tcprexmtthresh) {
+                                        tcp_seq onxt = tp->snd_nxt;
+                                        u_int win =
+                                            min(tp->snd_wnd, tp->snd_cwnd) / 2 /
+                                                tp->t_maxseg;
+
+                                        if (win < 2)
+                                                win = 2;
+                                        tp->snd_ssthresh = win * tp->t_maxseg;
+                                        tp->t_timer[TCPT_REXMT] = 0;
+                                        tp->t_rtt = 0;
+                                        tp->snd_nxt = ti->ti_ack;
+                                        tp->snd_cwnd = tp->t_maxseg;
+                                        (void) tcp_output(pData, tp);
+                                        tp->snd_cwnd = tp->snd_ssthresh +
+                                               tp->t_maxseg * tp->t_dupacks;
+                                        if (SEQ_GT(onxt, tp->snd_nxt))
+                                                tp->snd_nxt = onxt;
+                                        goto drop;
+                                } else if (tp->t_dupacks > tcprexmtthresh) {
+                                        tp->snd_cwnd += tp->t_maxseg;
+                                        (void) tcp_output(pData, tp);
+                                        goto drop;
+                                }
+                        } else
+                                tp->t_dupacks = 0;
+                        break;
+                }
+        synrx_to_est:
+                /*
+                 * If the congestion window was inflated to account
+                 * for the other side's cached packets, retract it.
+                 */
+                if (tp->t_dupacks > tcprexmtthresh &&
+                    tp->snd_cwnd > tp->snd_ssthresh)
+                        tp->snd_cwnd = tp->snd_ssthresh;
+                tp->t_dupacks = 0;
+                if (SEQ_GT(ti->ti_ack, tp->snd_max)) {
+                        tcpstat.tcps_rcvacktoomuch++;
+                        goto dropafterack;
+                }
+                acked = ti->ti_ack - tp->snd_una;
+                tcpstat.tcps_rcvackpack++;
+                tcpstat.tcps_rcvackbyte += acked;
+
+                /*
+                 * If we have a timestamp reply, update smoothed
+                 * round trip time.  If no timestamp is present but
+                 * transmit timer is running and timed sequence
+                 * number was acked, update smoothed round trip time.
+                 * Since we now have an rtt measurement, cancel the
+                 * timer backoff (cf., Phil Karn's retransmit alg.).
+                 * Recompute the initial retransmit timer.
+                 */
+/*              if (ts_present)
+ *                      tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
+ *              else
+ */
+                     if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
+                        tcp_xmit_timer(pData, tp,tp->t_rtt);
+
+                /*
+                 * If all outstanding data is acked, stop retransmit
+                 * timer and remember to restart (more output or persist).
+                 * If there is more data to be acked, restart retransmit
+                 * timer, using current (possibly backed-off) value.
+                 */
+                if (ti->ti_ack == tp->snd_max) {
+                        tp->t_timer[TCPT_REXMT] = 0;
+                        needoutput = 1;
+                } else if (tp->t_timer[TCPT_PERSIST] == 0)
+                        tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+                /*
+                 * When new data is acked, open the congestion window.
+                 * If the window gives us less than ssthresh packets
+                 * in flight, open exponentially (maxseg per packet).
+                 * Otherwise open linearly: maxseg per window
+                 * (maxseg^2 / cwnd per packet).
+                 */
+                {
+                  register u_int cw = tp->snd_cwnd;
+                  register u_int incr = tp->t_maxseg;
+
+                  if (cw > tp->snd_ssthresh)
+                    incr = incr * incr / cw;
+                  tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale);
+                }
+                if (acked > so->so_snd.sb_cc) {
+                        tp->snd_wnd -= so->so_snd.sb_cc;
+                        sbdrop(&so->so_snd, (int )so->so_snd.sb_cc);
+                        ourfinisacked = 1;
+                } else {
+                        sbdrop(&so->so_snd, acked);
+                        tp->snd_wnd -= acked;
+                        ourfinisacked = 0;
+                }
+                /*
+                 * XXX sowwakup is called when data is acked and there's room for
+                 * for more data... it should read() the socket
+                 */
+/*              if (so->so_snd.sb_flags & SB_NOTIFY)
+ *                      sowwakeup(so);
+ */
+                tp->snd_una = ti->ti_ack;
+                if (SEQ_LT(tp->snd_nxt, tp->snd_una))
+                        tp->snd_nxt = tp->snd_una;
+
+                switch (tp->t_state) {
+
+                /*
+                 * In FIN_WAIT_1 STATE in addition to the processing
+                 * for the ESTABLISHED state if our FIN is now acknowledged
+                 * then enter FIN_WAIT_2.
+                 */
+                case TCPS_FIN_WAIT_1:
+                        if (ourfinisacked) {
+                                /*
+                                 * If we can't receive any more
+                                 * data, then closing user can proceed.
+                                 * Starting the timer is contrary to the
+                                 * specification, but if we don't get a FIN
+                                 * we'll hang forever.
+                                 */
+                                if (so->so_state & SS_FCANTRCVMORE) {
+                                        soisfdisconnected(so);
+                                        tp->t_timer[TCPT_2MSL] = tcp_maxidle;
+                                }
+                                tp->t_state = TCPS_FIN_WAIT_2;
+                        }
+                        break;
+
+                /*
+                 * In CLOSING STATE in addition to the processing for
+                 * the ESTABLISHED state if the ACK acknowledges our FIN
+                 * then enter the TIME-WAIT state, otherwise ignore
+                 * the segment.
+                 */
+                case TCPS_CLOSING:
+                        if (ourfinisacked) {
+                                tp->t_state = TCPS_TIME_WAIT;
+                                tcp_canceltimers(tp);
+                                tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
+                                soisfdisconnected(so);
+                        }
+                        break;
+
+                /*
+                 * In LAST_ACK, we may still be waiting for data to drain
+                 * and/or to be acked, as well as for the ack of our FIN.
+                 * If our FIN is now acknowledged, delete the TCB,
+                 * enter the closed state and return.
+                 */
+                case TCPS_LAST_ACK:
+                        if (ourfinisacked) {
+                                tp = tcp_close(pData, tp);
+                                goto drop;
+                        }
+                        break;
+
+                /*
+                 * In TIME_WAIT state the only thing that should arrive
+                 * is a retransmission of the remote FIN.  Acknowledge
+                 * it and restart the finack timer.
+                 */
+                case TCPS_TIME_WAIT:
+                        tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
+                        goto dropafterack;
+                }
+        } /* switch(tp->t_state) */
 
 step6:
-	/*
-	 * Update window information.
-	 * Don't look at window if no ACK: TAC's send garbage on first SYN.
-	 */
-	if ((tiflags & TH_ACK) &&
-	    (SEQ_LT(tp->snd_wl1, ti->ti_seq) ||
-	    (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) ||
-	    (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) {
-		/* keep track of pure window updates */
-		if (ti->ti_len == 0 &&
-		    tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)
-			tcpstat.tcps_rcvwinupd++;
-		tp->snd_wnd = tiwin;
-		tp->snd_wl1 = ti->ti_seq;
-		tp->snd_wl2 = ti->ti_ack;
-		if (tp->snd_wnd > tp->max_sndwnd)
-			tp->max_sndwnd = tp->snd_wnd;
-		needoutput = 1;
-	}
-
-	/*
-	 * Process segments with URG.
-	 */
-	if ((tiflags & TH_URG) && ti->ti_urp &&
-	    TCPS_HAVERCVDFIN(tp->t_state) == 0) {
-		/*
-		 * This is a kludge, but if we receive and accept
-		 * random urgent pointers, we'll crash in
-		 * soreceive.  It's hard to imagine someone
-		 * actually wanting to send this much urgent data.
-		 */
-		if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) {
-			ti->ti_urp = 0;
-			tiflags &= ~TH_URG;
-			goto dodata;
-		}
-		/*
-		 * If this segment advances the known urgent pointer,
-		 * then mark the data stream.  This should not happen
-		 * in CLOSE_WAIT, CLOSING, LAST_ACK or TIME_WAIT STATES since
-		 * a FIN has been received from the remote side.
-		 * In these states we ignore the URG.
-		 *
-		 * According to RFC961 (Assigned Protocols),
-		 * the urgent pointer points to the last octet
-		 * of urgent data.  We continue, however,
-		 * to consider it to indicate the first octet
-		 * of data past the urgent section as the original
-		 * spec states (in one of two places).
-		 */
-		if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) {
-			tp->rcv_up = ti->ti_seq + ti->ti_urp;
-			so->so_urgc =  so->so_rcv.sb_cc +
-				(tp->rcv_up - tp->rcv_nxt); /* -1; */
-			tp->rcv_up = ti->ti_seq + ti->ti_urp;
-
-		}
-	} else
-		/*
-		 * If no out of band data is expected,
-		 * pull receive urgent pointer along
-		 * with the receive window.
-		 */
-		if (SEQ_GT(tp->rcv_nxt, tp->rcv_up))
-			tp->rcv_up = tp->rcv_nxt;
+        /*
+         * Update window information.
+         * Don't look at window if no ACK: TAC's send garbage on first SYN.
+         */
+        if ((tiflags & TH_ACK) &&
+            (SEQ_LT(tp->snd_wl1, ti->ti_seq) ||
+            (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) ||
+            (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) {
+                /* keep track of pure window updates */
+                if (ti->ti_len == 0 &&
+                    tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)
+                        tcpstat.tcps_rcvwinupd++;
+                tp->snd_wnd = tiwin;
+                tp->snd_wl1 = ti->ti_seq;
+                tp->snd_wl2 = ti->ti_ack;
+                if (tp->snd_wnd > tp->max_sndwnd)
+                        tp->max_sndwnd = tp->snd_wnd;
+                needoutput = 1;
+        }
+
+        /*
+         * Process segments with URG.
+         */
+        if ((tiflags & TH_URG) && ti->ti_urp &&
+            TCPS_HAVERCVDFIN(tp->t_state) == 0) {
+                /*
+                 * This is a kludge, but if we receive and accept
+                 * random urgent pointers, we'll crash in
+                 * soreceive.  It's hard to imagine someone
+                 * actually wanting to send this much urgent data.
+                 */
+                if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) {
+                        ti->ti_urp = 0;
+                        tiflags &= ~TH_URG;
+                        goto dodata;
+                }
+                /*
+                 * If this segment advances the known urgent pointer,
+                 * then mark the data stream.  This should not happen
+                 * in CLOSE_WAIT, CLOSING, LAST_ACK or TIME_WAIT STATES since
+                 * a FIN has been received from the remote side.
+                 * In these states we ignore the URG.
+                 *
+                 * According to RFC961 (Assigned Protocols),
+                 * the urgent pointer points to the last octet
+                 * of urgent data.  We continue, however,
+                 * to consider it to indicate the first octet
+                 * of data past the urgent section as the original
+                 * spec states (in one of two places).
+                 */
+                if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) {
+                        tp->rcv_up = ti->ti_seq + ti->ti_urp;
+                        so->so_urgc =  so->so_rcv.sb_cc +
+                                (tp->rcv_up - tp->rcv_nxt); /* -1; */
+                        tp->rcv_up = ti->ti_seq + ti->ti_urp;
+
+                }
+        } else
+                /*
+                 * If no out of band data is expected,
+                 * pull receive urgent pointer along
+                 * with the receive window.
+                 */
+                if (SEQ_GT(tp->rcv_nxt, tp->rcv_up))
+                        tp->rcv_up = tp->rcv_nxt;
 dodata:
 
-	/*
-	 * Process the segment text, merging it into the TCP sequencing queue,
-	 * and arranging for acknowledgment of receipt if necessary.
-	 * This process logically involves adjusting tp->rcv_wnd as data
-	 * is presented to the user (this happens in tcp_usrreq.c,
-	 * case PRU_RCVD).  If a FIN has already been received on this
-	 * connection then we just ignore the text.
-	 */
-	if ((ti->ti_len || (tiflags&TH_FIN)) &&
-	    TCPS_HAVERCVDFIN(tp->t_state) == 0) {
+        /*
+         * Process the segment text, merging it into the TCP sequencing queue,
+         * and arranging for acknowledgment of receipt if necessary.
+         * This process logically involves adjusting tp->rcv_wnd as data
+         * is presented to the user (this happens in tcp_usrreq.c,
+         * case PRU_RCVD).  If a FIN has already been received on this
+         * connection then we just ignore the text.
+         */
+        if ((ti->ti_len || (tiflags&TH_FIN)) &&
+            TCPS_HAVERCVDFIN(tp->t_state) == 0) {
 #ifndef VBOX_WITH_BSD_TCP_REASS
-		TCP_REASS(pData, tp, ti, m, so, tiflags);
+                TCP_REASS(pData, tp, ti, m, so, tiflags);
 #else  /* VBOX_WITH_BSD_TCP_REASS */
                 if (ti->ti_seq == tp->rcv_nxt
                 && LIST_EMPTY(&tp->t_segq)
                 && tp->t_state == TCPS_ESTABLISHED) {
-		    DELAY_ACK(tp, ti); /* little bit different from BSD declaration see netinet/tcp_input.c */
-		    tp->rcv_nxt += tlen;
-		    tiflags = ti->ti_t.th_flags & TH_FIN;
-		    tcpstat.tcps_rcvpack++;
-		    tcpstat.tcps_rcvbyte += tlen;
-		    if (so->so_state & SS_FCANTRCVMORE)
-		    	m_freem(pData, m);
-		    else
-		    	sbappend(pData, so, m);
+                    DELAY_ACK(tp, ti); /* little bit different from BSD declaration see netinet/tcp_input.c */
+                    tp->rcv_nxt += tlen;
+                    tiflags = ti->ti_t.th_flags & TH_FIN;
+                    tcpstat.tcps_rcvpack++;
+                    tcpstat.tcps_rcvbyte += tlen;
+                    if (so->so_state & SS_FCANTRCVMORE)
+                        m_freem(pData, m);
+                    else
+                        sbappend(pData, so, m);
                 }
                 else {
@@ -1512,211 +1512,211 @@
                 }
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-		/*
-		 * Note the amount of data that peer has sent into
-		 * our window, in order to estimate the sender's
-		 * buffer size.
-		 */
-		len = so->so_rcv.sb_datalen - (tp->rcv_adv - tp->rcv_nxt);
-	} else {
-	        mbuf_freed = 1; /* The mbuf must be freed, but only when its content is not needed anymore. */
-		tiflags &= ~TH_FIN;
-	}
-
-	/*
-	 * If FIN is received ACK the FIN and let the user know
-	 * that the connection is closing.
-	 */
-	if (tiflags & TH_FIN) {
-		if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
-			/*
-			 * If we receive a FIN we can't send more data,
-			 * set it SS_FDRAIN
+                /*
+                 * Note the amount of data that peer has sent into
+                 * our window, in order to estimate the sender's
+                 * buffer size.
+                 */
+                len = so->so_rcv.sb_datalen - (tp->rcv_adv - tp->rcv_nxt);
+        } else {
+                mbuf_freed = 1; /* The mbuf must be freed, but only when its content is not needed anymore. */
+                tiflags &= ~TH_FIN;
+        }
+
+        /*
+         * If FIN is received ACK the FIN and let the user know
+         * that the connection is closing.
+         */
+        if (tiflags & TH_FIN) {
+                if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
+                        /*
+                         * If we receive a FIN we can't send more data,
+                         * set it SS_FDRAIN
                          * Shutdown the socket if there is no rx data in the
-			 * buffer.
-			 * soread() is called on completion of shutdown() and
-			 * will got to TCPS_LAST_ACK, and use tcp_output()
-			 * to send the FIN.
-			 */
-/*			sofcantrcvmore(so); */
-			sofwdrain(so);
-
-			tp->t_flags |= TF_ACKNOW;
-			tp->rcv_nxt++;
-		}
-		switch (tp->t_state) {
-
-	 	/*
-		 * In SYN_RECEIVED and ESTABLISHED STATES
-		 * enter the CLOSE_WAIT state.
-		 */
-		case TCPS_SYN_RECEIVED:
-		case TCPS_ESTABLISHED:
-		  if(so->so_emu == EMU_CTL)        /* no shutdown on socket */
-		    tp->t_state = TCPS_LAST_ACK;
-		  else
-		    tp->t_state = TCPS_CLOSE_WAIT;
-		  break;
-
-	 	/*
-		 * If still in FIN_WAIT_1 STATE FIN has not been acked so
-		 * enter the CLOSING state.
-		 */
-		case TCPS_FIN_WAIT_1:
-			tp->t_state = TCPS_CLOSING;
-			break;
-
-	 	/*
-		 * In FIN_WAIT_2 state enter the TIME_WAIT state,
-		 * starting the time-wait timer, turning off the other
-		 * standard timers.
-		 */
-		case TCPS_FIN_WAIT_2:
-			tp->t_state = TCPS_TIME_WAIT;
-			tcp_canceltimers(tp);
-			tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-			soisfdisconnected(so);
-			break;
-
-		/*
-		 * In TIME_WAIT state restart the 2 MSL time_wait timer.
-		 */
-		case TCPS_TIME_WAIT:
-			tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-			break;
-		}
-	}
-
-	/*
-	 * If this is a small packet, then ACK now - with Nagel
-	 *      congestion avoidance sender won't send more until
-	 *      he gets an ACK.
-	 *
-	 * See above.
-	 */
-/*	if (ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg) {
- */
-/*	if ((ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg &&
- *		(so->so_iptos & IPTOS_LOWDELAY) == 0) ||
- *	       ((so->so_iptos & IPTOS_LOWDELAY) &&
- *	       ((struct tcpiphdr_2 *)ti)->first_char == (char)27)) {
- */
-	if (ti->ti_len && (unsigned)ti->ti_len <= 5 &&
-	    ((struct tcpiphdr_2 *)ti)->first_char == (char)27) {
-		tp->t_flags |= TF_ACKNOW;
-	}
-
-	if (mbuf_freed) {
-		m_free(pData, m);
-	}
-	/*
-	 * Return any desired output.
-	 */
-	if (needoutput || (tp->t_flags & TF_ACKNOW)) {
-		(void) tcp_output(pData, tp);
-	}
-	return;
+                         * buffer.
+                         * soread() is called on completion of shutdown() and
+                         * will got to TCPS_LAST_ACK, and use tcp_output()
+                         * to send the FIN.
+                         */
+/*                      sofcantrcvmore(so); */
+                        sofwdrain(so);
+
+                        tp->t_flags |= TF_ACKNOW;
+                        tp->rcv_nxt++;
+                }
+                switch (tp->t_state) {
+
+                /*
+                 * In SYN_RECEIVED and ESTABLISHED STATES
+                 * enter the CLOSE_WAIT state.
+                 */
+                case TCPS_SYN_RECEIVED:
+                case TCPS_ESTABLISHED:
+                  if(so->so_emu == EMU_CTL)        /* no shutdown on socket */
+                    tp->t_state = TCPS_LAST_ACK;
+                  else
+                    tp->t_state = TCPS_CLOSE_WAIT;
+                  break;
+
+                /*
+                 * If still in FIN_WAIT_1 STATE FIN has not been acked so
+                 * enter the CLOSING state.
+                 */
+                case TCPS_FIN_WAIT_1:
+                        tp->t_state = TCPS_CLOSING;
+                        break;
+
+                /*
+                 * In FIN_WAIT_2 state enter the TIME_WAIT state,
+                 * starting the time-wait timer, turning off the other
+                 * standard timers.
+                 */
+                case TCPS_FIN_WAIT_2:
+                        tp->t_state = TCPS_TIME_WAIT;
+                        tcp_canceltimers(tp);
+                        tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
+                        soisfdisconnected(so);
+                        break;
+
+                /*
+                 * In TIME_WAIT state restart the 2 MSL time_wait timer.
+                 */
+                case TCPS_TIME_WAIT:
+                        tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
+                        break;
+                }
+        }
+
+        /*
+         * If this is a small packet, then ACK now - with Nagel
+         *      congestion avoidance sender won't send more until
+         *      he gets an ACK.
+         *
+         * See above.
+         */
+/*      if (ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg) {
+ */
+/*      if ((ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg &&
+ *              (so->so_iptos & IPTOS_LOWDELAY) == 0) ||
+ *             ((so->so_iptos & IPTOS_LOWDELAY) &&
+ *             ((struct tcpiphdr_2 *)ti)->first_char == (char)27)) {
+ */
+        if (ti->ti_len && (unsigned)ti->ti_len <= 5 &&
+            ((struct tcpiphdr_2 *)ti)->first_char == (char)27) {
+                tp->t_flags |= TF_ACKNOW;
+        }
+
+        if (mbuf_freed) {
+                m_free(pData, m);
+        }
+        /*
+         * Return any desired output.
+         */
+        if (needoutput || (tp->t_flags & TF_ACKNOW)) {
+                (void) tcp_output(pData, tp);
+        }
+        return;
 
 dropafterack:
-	/*
-	 * Generate an ACK dropping incoming segment if it occupies
-	 * sequence space, where the ACK reflects our state.
-	 */
-	if (tiflags & TH_RST)
-		goto drop;
-	m_freem(pData, m);
-	tp->t_flags |= TF_ACKNOW;
-	(void) tcp_output(pData, tp);
-	return;
+        /*
+         * Generate an ACK dropping incoming segment if it occupies
+         * sequence space, where the ACK reflects our state.
+         */
+        if (tiflags & TH_RST)
+                goto drop;
+        m_freem(pData, m);
+        tp->t_flags |= TF_ACKNOW;
+        (void) tcp_output(pData, tp);
+        return;
 
 dropwithreset:
-	/* reuses m if m!=NULL, m_free() unnecessary */
-	if (tiflags & TH_ACK)
-		tcp_respond(pData, tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST);
-	else {
-		if (tiflags & TH_SYN) ti->ti_len++;
-		tcp_respond(pData, tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0,
-		    TH_RST|TH_ACK);
-	}
-
-	return;
+        /* reuses m if m!=NULL, m_free() unnecessary */
+        if (tiflags & TH_ACK)
+                tcp_respond(pData, tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST);
+        else {
+                if (tiflags & TH_SYN) ti->ti_len++;
+                tcp_respond(pData, tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0,
+                    TH_RST|TH_ACK);
+        }
+
+        return;
 
 drop:
-	/*
-	 * Drop space held by incoming segment and return.
-	 */
-	m_free(pData, m);
-
-	return;
+        /*
+         * Drop space held by incoming segment and return.
+         */
+        m_free(pData, m);
+
+        return;
 }
 
  /* , ts_present, ts_val, ts_ecr) */
-/*	int *ts_present;
- *	u_int32_t *ts_val, *ts_ecr;
+/*      int *ts_present;
+ *      u_int32_t *ts_val, *ts_ecr;
  */
 void
 tcp_dooptions(PNATState pData, struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
 {
-	u_int16_t mss;
-	int opt, optlen;
-
-	DEBUG_CALL("tcp_dooptions");
-	DEBUG_ARGS((dfd," tp = %lx  cnt=%i \n", (long )tp, cnt));
-
-	for (; cnt > 0; cnt -= optlen, cp += optlen) {
-		opt = cp[0];
-		if (opt == TCPOPT_EOL)
-			break;
-		if (opt == TCPOPT_NOP)
-			optlen = 1;
-		else {
-			optlen = cp[1];
-			if (optlen <= 0)
-				break;
-		}
-		switch (opt) {
-
-		default:
-			continue;
-
-		case TCPOPT_MAXSEG:
-			if (optlen != TCPOLEN_MAXSEG)
-				continue;
-			if (!(ti->ti_flags & TH_SYN))
-				continue;
-			memcpy((char *) &mss, (char *) cp + 2, sizeof(mss));
-			NTOHS(mss);
-			(void) tcp_mss(pData, tp, mss);	/* sets t_maxseg */
-			break;
-
-/*		case TCPOPT_WINDOW:
- *			if (optlen != TCPOLEN_WINDOW)
- *				continue;
- *			if (!(ti->ti_flags & TH_SYN))
- *				continue;
- *			tp->t_flags |= TF_RCVD_SCALE;
- *			tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
- *			break;
- */
-/*		case TCPOPT_TIMESTAMP:
- *			if (optlen != TCPOLEN_TIMESTAMP)
- *				continue;
- *			*ts_present = 1;
- *			memcpy((char *) ts_val, (char *)cp + 2, sizeof(*ts_val));
- *			NTOHL(*ts_val);
- *			memcpy((char *) ts_ecr, (char *)cp + 6, sizeof(*ts_ecr));
- *			NTOHL(*ts_ecr);
+        u_int16_t mss;
+        int opt, optlen;
+
+        DEBUG_CALL("tcp_dooptions");
+        DEBUG_ARGS((dfd," tp = %lx  cnt=%i \n", (long )tp, cnt));
+
+        for (; cnt > 0; cnt -= optlen, cp += optlen) {
+                opt = cp[0];
+                if (opt == TCPOPT_EOL)
+                        break;
+                if (opt == TCPOPT_NOP)
+                        optlen = 1;
+                else {
+                        optlen = cp[1];
+                        if (optlen <= 0)
+                                break;
+                }
+                switch (opt) {
+
+                default:
+                        continue;
+
+                case TCPOPT_MAXSEG:
+                        if (optlen != TCPOLEN_MAXSEG)
+                                continue;
+                        if (!(ti->ti_flags & TH_SYN))
+                                continue;
+                        memcpy((char *) &mss, (char *) cp + 2, sizeof(mss));
+                        NTOHS(mss);
+                        (void) tcp_mss(pData, tp, mss); /* sets t_maxseg */
+                        break;
+
+/*              case TCPOPT_WINDOW:
+ *                      if (optlen != TCPOLEN_WINDOW)
+ *                              continue;
+ *                      if (!(ti->ti_flags & TH_SYN))
+ *                              continue;
+ *                      tp->t_flags |= TF_RCVD_SCALE;
+ *                      tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
+ *                      break;
+ */
+/*              case TCPOPT_TIMESTAMP:
+ *                      if (optlen != TCPOLEN_TIMESTAMP)
+ *                              continue;
+ *                      *ts_present = 1;
+ *                      memcpy((char *) ts_val, (char *)cp + 2, sizeof(*ts_val));
+ *                      NTOHL(*ts_val);
+ *                      memcpy((char *) ts_ecr, (char *)cp + 6, sizeof(*ts_ecr));
+ *                      NTOHL(*ts_ecr);
  *
- */			/*
- *			 * A timestamp received in a SYN makes
- *			 * it ok to send timestamp requests and replies.
- *			 */
-/*			if (ti->ti_flags & TH_SYN) {
- *				tp->t_flags |= TF_RCVD_TSTMP;
- *				tp->ts_recent = *ts_val;
- *				tp->ts_recent_age = tcp_now;
- *			}
- */			break;
-		}
-	}
+ */                     /*
+ *                       * A timestamp received in a SYN makes
+ *                       * it ok to send timestamp requests and replies.
+ *                       */
+/*                      if (ti->ti_flags & TH_SYN) {
+ *                              tp->t_flags |= TF_RCVD_TSTMP;
+ *                              tp->ts_recent = *ts_val;
+ *                              tp->ts_recent_age = tcp_now;
+ *                      }
+ */                     break;
+                }
+        }
 }
 
@@ -1733,27 +1733,27 @@
 void
 tcp_pulloutofband(so, ti, m)
-	struct socket *so;
-	struct tcpiphdr *ti;
-	register struct mbuf *m;
+        struct socket *so;
+        struct tcpiphdr *ti;
+        register struct mbuf *m;
 {
-	int cnt = ti->ti_urp - 1;
-
-	while (cnt >= 0) {
-		if (m->m_len > cnt) {
-			char *cp = mtod(m, caddr_t) + cnt;
-			struct tcpcb *tp = sototcpcb(so);
-
-			tp->t_iobc = *cp;
-			tp->t_oobflags |= TCPOOB_HAVEDATA;
-			memcpy(sp, cp+1, (unsigned)(m->m_len - cnt - 1));
-			m->m_len--;
-			return;
-		}
-		cnt -= m->m_len;
-		m = m->m_next; /* XXX WRONG! Fix it! */
-		if (m == 0)
-			break;
-	}
-	panic("tcp_pulloutofband");
+        int cnt = ti->ti_urp - 1;
+
+        while (cnt >= 0) {
+                if (m->m_len > cnt) {
+                        char *cp = mtod(m, caddr_t) + cnt;
+                        struct tcpcb *tp = sototcpcb(so);
+
+                        tp->t_iobc = *cp;
+                        tp->t_oobflags |= TCPOOB_HAVEDATA;
+                        memcpy(sp, cp+1, (unsigned)(m->m_len - cnt - 1));
+                        m->m_len--;
+                        return;
+                }
+                cnt -= m->m_len;
+                m = m->m_next; /* XXX WRONG! Fix it! */
+                if (m == 0)
+                        break;
+        }
+        panic("tcp_pulloutofband");
 }
 
@@ -1768,71 +1768,71 @@
 tcp_xmit_timer(PNATState pData, register struct tcpcb *tp, int rtt)
 {
-	register short delta;
-
-	DEBUG_CALL("tcp_xmit_timer");
-	DEBUG_ARG("tp = %lx", (long)tp);
-	DEBUG_ARG("rtt = %d", rtt);
-
-	tcpstat.tcps_rttupdated++;
-	if (tp->t_srtt != 0) {
-		/*
-		 * srtt is stored as fixed point with 3 bits after the
-		 * binary point (i.e., scaled by 8).  The following magic
-		 * is equivalent to the smoothing algorithm in rfc793 with
-		 * an alpha of .875 (srtt = rtt/8 + srtt*7/8 in fixed
-		 * point).  Adjust rtt to origin 0.
-		 */
-		delta = rtt - 1 - (tp->t_srtt >> TCP_RTT_SHIFT);
-		if ((tp->t_srtt += delta) <= 0)
-			tp->t_srtt = 1;
-		/*
-		 * We accumulate a smoothed rtt variance (actually, a
-		 * smoothed mean difference), then set the retransmit
-		 * timer to smoothed rtt + 4 times the smoothed variance.
-		 * rttvar is stored as fixed point with 2 bits after the
-		 * binary point (scaled by 4).  The following is
-		 * equivalent to rfc793 smoothing with an alpha of .75
-		 * (rttvar = rttvar*3/4 + |delta| / 4).  This replaces
-		 * rfc793's wired-in beta.
-		 */
-		if (delta < 0)
-			delta = -delta;
-		delta -= (tp->t_rttvar >> TCP_RTTVAR_SHIFT);
-		if ((tp->t_rttvar += delta) <= 0)
-			tp->t_rttvar = 1;
-	} else {
-		/*
-		 * No rtt measurement yet - use the unsmoothed rtt.
-		 * Set the variance to half the rtt (so our first
-		 * retransmit happens at 3*rtt).
-		 */
-		tp->t_srtt = rtt << TCP_RTT_SHIFT;
-		tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
-	}
-	tp->t_rtt = 0;
-	tp->t_rxtshift = 0;
-
-	/*
-	 * the retransmit should happen at rtt + 4 * rttvar.
-	 * Because of the way we do the smoothing, srtt and rttvar
-	 * will each average +1/2 tick of bias.  When we compute
-	 * the retransmit timer, we want 1/2 tick of rounding and
-	 * 1 extra tick because of +-1/2 tick uncertainty in the
-	 * firing of the timer.  The bias will give us exactly the
-	 * 1.5 tick we need.  But, because the bias is
-	 * statistical, we have to test that we don't drop below
-	 * the minimum feasible timer (which is 2 ticks).
-	 */
-	TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
-	    (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */
-
-	/*
-	 * We received an ack for a packet that wasn't retransmitted;
-	 * it is probably safe to discard any error indications we've
-	 * received recently.  This isn't quite right, but close enough
-	 * for now (a route might have failed after we sent a segment,
-	 * and the return path might not be symmetrical).
-	 */
-	tp->t_softerror = 0;
+        register short delta;
+
+        DEBUG_CALL("tcp_xmit_timer");
+        DEBUG_ARG("tp = %lx", (long)tp);
+        DEBUG_ARG("rtt = %d", rtt);
+
+        tcpstat.tcps_rttupdated++;
+        if (tp->t_srtt != 0) {
+                /*
+                 * srtt is stored as fixed point with 3 bits after the
+                 * binary point (i.e., scaled by 8).  The following magic
+                 * is equivalent to the smoothing algorithm in rfc793 with
+                 * an alpha of .875 (srtt = rtt/8 + srtt*7/8 in fixed
+                 * point).  Adjust rtt to origin 0.
+                 */
+                delta = rtt - 1 - (tp->t_srtt >> TCP_RTT_SHIFT);
+                if ((tp->t_srtt += delta) <= 0)
+                        tp->t_srtt = 1;
+                /*
+                 * We accumulate a smoothed rtt variance (actually, a
+                 * smoothed mean difference), then set the retransmit
+                 * timer to smoothed rtt + 4 times the smoothed variance.
+                 * rttvar is stored as fixed point with 2 bits after the
+                 * binary point (scaled by 4).  The following is
+                 * equivalent to rfc793 smoothing with an alpha of .75
+                 * (rttvar = rttvar*3/4 + |delta| / 4).  This replaces
+                 * rfc793's wired-in beta.
+                 */
+                if (delta < 0)
+                        delta = -delta;
+                delta -= (tp->t_rttvar >> TCP_RTTVAR_SHIFT);
+                if ((tp->t_rttvar += delta) <= 0)
+                        tp->t_rttvar = 1;
+        } else {
+                /*
+                 * No rtt measurement yet - use the unsmoothed rtt.
+                 * Set the variance to half the rtt (so our first
+                 * retransmit happens at 3*rtt).
+                 */
+                tp->t_srtt = rtt << TCP_RTT_SHIFT;
+                tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
+        }
+        tp->t_rtt = 0;
+        tp->t_rxtshift = 0;
+
+        /*
+         * the retransmit should happen at rtt + 4 * rttvar.
+         * Because of the way we do the smoothing, srtt and rttvar
+         * will each average +1/2 tick of bias.  When we compute
+         * the retransmit timer, we want 1/2 tick of rounding and
+         * 1 extra tick because of +-1/2 tick uncertainty in the
+         * firing of the timer.  The bias will give us exactly the
+         * 1.5 tick we need.  But, because the bias is
+         * statistical, we have to test that we don't drop below
+         * the minimum feasible timer (which is 2 ticks).
+         */
+        TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
+            (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */
+
+        /*
+         * We received an ack for a packet that wasn't retransmitted;
+         * it is probably safe to discard any error indications we've
+         * received recently.  This isn't quite right, but close enough
+         * for now (a route might have failed after we sent a segment,
+         * and the return path might not be symmetrical).
+         */
+        tp->t_softerror = 0;
 }
 
@@ -1856,25 +1856,25 @@
 tcp_mss(PNATState pData, register struct tcpcb *tp, u_int offer)
 {
-	struct socket *so = tp->t_socket;
-	int mss;
-
-	DEBUG_CALL("tcp_mss");
-	DEBUG_ARG("tp = %lx", (long)tp);
-	DEBUG_ARG("offer = %d", offer);
-
-	mss = min(if_mtu, if_mru) - sizeof(struct tcpiphdr);
-	if (offer)
-		mss = min(mss, offer);
-	mss = max(mss, 32);
-	if (mss < tp->t_maxseg || offer != 0)
-	   tp->t_maxseg = mss;
-
-	tp->snd_cwnd = mss;
-
-	sbreserve(&so->so_snd, tcp_sndspace+((tcp_sndspace%mss)?(mss-(tcp_sndspace%mss)):0));
-	sbreserve(&so->so_rcv, tcp_rcvspace+((tcp_rcvspace%mss)?(mss-(tcp_rcvspace%mss)):0));
-
-	DEBUG_MISC((dfd, " returning mss = %d\n", mss));
-
-	return mss;
+        struct socket *so = tp->t_socket;
+        int mss;
+
+        DEBUG_CALL("tcp_mss");
+        DEBUG_ARG("tp = %lx", (long)tp);
+        DEBUG_ARG("offer = %d", offer);
+
+        mss = min(if_mtu, if_mru) - sizeof(struct tcpiphdr);
+        if (offer)
+                mss = min(mss, offer);
+        mss = max(mss, 32);
+        if (mss < tp->t_maxseg || offer != 0)
+           tp->t_maxseg = mss;
+
+        tp->snd_cwnd = mss;
+
+        sbreserve(&so->so_snd, tcp_sndspace+((tcp_sndspace%mss)?(mss-(tcp_sndspace%mss)):0));
+        sbreserve(&so->so_rcv, tcp_rcvspace+((tcp_rcvspace%mss)?(mss-(tcp_rcvspace%mss)):0));
+
+        DEBUG_MISC((dfd, " returning mss = %d\n", mss));
+
+        return mss;
 }
Index: trunk/src/VBox/Devices/Network/slirp/tcp_output.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_output.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_output.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_output.c	8.3 (Berkeley) 12/30/93
+ *      @(#)tcp_output.c        8.3 (Berkeley) 12/30/93
  * tcp_output.c,v 1.3 1994/09/15 10:36:55 davidg Exp
  */
@@ -50,18 +50,18 @@
  */
 const char * const tcpstates[] = {
-/*	"CLOSED",       "LISTEN",       "SYN_SENT",     "SYN_RCVD", */
-	"REDIRECT",	"LISTEN",	"SYN_SENT",     "SYN_RCVD",
-	"ESTABLISHED",  "CLOSE_WAIT",   "FIN_WAIT_1",   "CLOSING",
-	"LAST_ACK",     "FIN_WAIT_2",   "TIME_WAIT",
+/*      "CLOSED",       "LISTEN",       "SYN_SENT",     "SYN_RCVD", */
+        "REDIRECT",     "LISTEN",       "SYN_SENT",     "SYN_RCVD",
+        "ESTABLISHED",  "CLOSE_WAIT",   "FIN_WAIT_1",   "CLOSING",
+        "LAST_ACK",     "FIN_WAIT_2",   "TIME_WAIT",
 };
 
 static const u_char  tcp_outflags[TCP_NSTATES] = {
-	TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
-	TH_ACK,        TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
-	TH_FIN|TH_ACK, TH_ACK, TH_ACK,
+        TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
+        TH_ACK,        TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
+        TH_FIN|TH_ACK, TH_ACK, TH_ACK,
 };
 
 
-#define MAX_TCPOPTLEN	32	/* max # bytes that go in options */
+#define MAX_TCPOPTLEN   32      /* max # bytes that go in options */
 
 /*
@@ -71,534 +71,534 @@
 tcp_output(PNATState pData, register struct tcpcb *tp)
 {
-	register struct socket *so = tp->t_socket;
-	register long len, win;
-	int off, flags, error;
-	register struct mbuf *m;
-	register struct tcpiphdr *ti;
-	u_char opt[MAX_TCPOPTLEN];
-	unsigned optlen, hdrlen;
-	int idle, sendalot;
-
-	DEBUG_CALL("tcp_output");
-	DEBUG_ARG("tp = %lx", (long )tp);
-
-	/*
-	 * Determine length of data that should be transmitted,
-	 * and flags that will be used.
-	 * If there is some data or critical controls (SYN, RST)
-	 * to send, then transmit; otherwise, investigate further.
-	 */
-	idle = (tp->snd_max == tp->snd_una);
-	if (idle && tp->t_idle >= tp->t_rxtcur)
-		/*
-		 * We have been idle for "a while" and no acks are
-		 * expected to clock out any data we send --
-		 * slow start to get ack "clock" running again.
-		 */
-		tp->snd_cwnd = tp->t_maxseg;
+        register struct socket *so = tp->t_socket;
+        register long len, win;
+        int off, flags, error;
+        register struct mbuf *m;
+        register struct tcpiphdr *ti;
+        u_char opt[MAX_TCPOPTLEN];
+        unsigned optlen, hdrlen;
+        int idle, sendalot;
+
+        DEBUG_CALL("tcp_output");
+        DEBUG_ARG("tp = %lx", (long )tp);
+
+        /*
+         * Determine length of data that should be transmitted,
+         * and flags that will be used.
+         * If there is some data or critical controls (SYN, RST)
+         * to send, then transmit; otherwise, investigate further.
+         */
+        idle = (tp->snd_max == tp->snd_una);
+        if (idle && tp->t_idle >= tp->t_rxtcur)
+                /*
+                 * We have been idle for "a while" and no acks are
+                 * expected to clock out any data we send --
+                 * slow start to get ack "clock" running again.
+                 */
+                tp->snd_cwnd = tp->t_maxseg;
 again:
-	sendalot = 0;
-	off = tp->snd_nxt - tp->snd_una;
-	win = min(tp->snd_wnd, tp->snd_cwnd);
-
-	flags = tcp_outflags[tp->t_state];
-
-	DEBUG_MISC((dfd, " --- tcp_output flags = 0x%x\n",flags));
-
-	/*
-	 * If in persist timeout with window of 0, send 1 byte.
-	 * Otherwise, if window is small but nonzero
-	 * and timer expired, we will send what we can
-	 * and go to transmit state.
-	 */
-	if (tp->t_force) {
-		if (win == 0) {
-			/*
-			 * If we still have some data to send, then
-			 * clear the FIN bit.  Usually this would
-			 * happen below when it realizes that we
-			 * aren't sending all the data.  However,
-			 * if we have exactly 1 byte of unset data,
-			 * then it won't clear the FIN bit below,
-			 * and if we are in persist state, we wind
-			 * up sending the packet without recording
-			 * that we sent the FIN bit.
-			 *
-			 * We can't just blindly clear the FIN bit,
-			 * because if we don't have any more data
-			 * to send then the probe will be the FIN
-			 * itself.
-			 */
-			if (off < so->so_snd.sb_cc)
-				flags &= ~TH_FIN;
-			win = 1;
-		} else {
-			tp->t_timer[TCPT_PERSIST] = 0;
-			tp->t_rxtshift = 0;
-		}
-	}
-
-	len = min(so->so_snd.sb_cc, win) - off;
-
-	if (len < 0) {
-		/*
-		 * If FIN has been sent but not acked,
-		 * but we haven't been called to retransmit,
-		 * len will be -1.  Otherwise, window shrank
-		 * after we sent into it.  If window shrank to 0,
-		 * cancel pending retransmit and pull snd_nxt
-		 * back to (closed) window.  We will enter persist
-		 * state below.  If the window didn't close completely,
-		 * just wait for an ACK.
-		 */
-		len = 0;
-		if (win == 0) {
-			tp->t_timer[TCPT_REXMT] = 0;
-			tp->snd_nxt = tp->snd_una;
-		}
-	}
-
-	if (len > tp->t_maxseg) {
-		len = tp->t_maxseg;
-		sendalot = 1;
-	}
-	if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + so->so_snd.sb_cc))
-		flags &= ~TH_FIN;
-
-	win = sbspace(&so->so_rcv);
-
-	/*
-	 * Sender silly window avoidance.  If connection is idle
-	 * and can send all data, a maximum segment,
-	 * at least a maximum default-size segment do it,
-	 * or are forced, do it; otherwise don't bother.
-	 * If peer's buffer is tiny, then send
-	 * when window is at least half open.
-	 * If retransmitting (possibly after persist timer forced us
-	 * to send into a small window), then must resend.
-	 */
-	if (len) {
-		if (len == tp->t_maxseg)
-			goto send;
-		if ((1 || idle || tp->t_flags & TF_NODELAY) &&
-		    len + off >= so->so_snd.sb_cc)
-			goto send;
-		if (tp->t_force)
-			goto send;
-		if (len >= tp->max_sndwnd / 2 && tp->max_sndwnd > 0)
-			goto send;
-		if (SEQ_LT(tp->snd_nxt, tp->snd_max))
-			goto send;
-	}
-
-	/*
-	 * Compare available window to amount of window
-	 * known to peer (as advertised window less
-	 * next expected input).  If the difference is at least two
-	 * max size segments, or at least 50% of the maximum possible
-	 * window, then want to send a window update to peer.
-	 */
-	if (win > 0) {
-		/*
-		 * "adv" is the amount we can increase the window,
-		 * taking into account that we are limited by
-		 * TCP_MAXWIN << tp->rcv_scale.
-		 */
-		long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) -
-			(tp->rcv_adv - tp->rcv_nxt);
-
-		if (adv >= (long) (2 * tp->t_maxseg))
-			goto send;
-		if (2 * adv >= (long) so->so_rcv.sb_datalen)
-			goto send;
-	}
-
-	/*
-	 * Send if we owe peer an ACK.
-	 */
-	if (tp->t_flags & TF_ACKNOW)
-		goto send;
-	if (flags & (TH_SYN|TH_RST))
-		goto send;
-	if (SEQ_GT(tp->snd_up, tp->snd_una))
-		goto send;
-	/*
-	 * If our state indicates that FIN should be sent
-	 * and we have not yet done so, or we're retransmitting the FIN,
-	 * then we need to send.
-	 */
-	if (flags & TH_FIN &&
-	    ((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
-		goto send;
-
-	/*
-	 * TCP window updates are not reliable, rather a polling protocol
-	 * using ``persist'' packets is used to insure receipt of window
-	 * updates.  The three ``states'' for the output side are:
-	 *	idle			not doing retransmits or persists
-	 *	persisting		to move a small or zero window
-	 *	(re)transmitting	and thereby not persisting
-	 *
-	 * tp->t_timer[TCPT_PERSIST]
-	 *	is set when we are in persist state.
-	 * tp->t_force
-	 *	is set when we are called to send a persist packet.
-	 * tp->t_timer[TCPT_REXMT]
-	 *	is set when we are retransmitting
-	 * The output side is idle when both timers are zero.
-	 *
-	 * If send window is too small, there is data to transmit, and no
-	 * retransmit or persist is pending, then go to persist state.
-	 * If nothing happens soon, send when timer expires:
-	 * if window is nonzero, transmit what we can,
-	 * otherwise force out a byte.
-	 */
-	if (so->so_snd.sb_cc && tp->t_timer[TCPT_REXMT] == 0 &&
-	    tp->t_timer[TCPT_PERSIST] == 0) {
-		tp->t_rxtshift = 0;
-		tcp_setpersist(tp);
-	}
-
-	/*
-	 * No reason to send a segment, just return.
-	 */
-	tcpstat.tcps_didnuttin++;
-
-	return (0);
+        sendalot = 0;
+        off = tp->snd_nxt - tp->snd_una;
+        win = min(tp->snd_wnd, tp->snd_cwnd);
+
+        flags = tcp_outflags[tp->t_state];
+
+        DEBUG_MISC((dfd, " --- tcp_output flags = 0x%x\n",flags));
+
+        /*
+         * If in persist timeout with window of 0, send 1 byte.
+         * Otherwise, if window is small but nonzero
+         * and timer expired, we will send what we can
+         * and go to transmit state.
+         */
+        if (tp->t_force) {
+                if (win == 0) {
+                        /*
+                         * If we still have some data to send, then
+                         * clear the FIN bit.  Usually this would
+                         * happen below when it realizes that we
+                         * aren't sending all the data.  However,
+                         * if we have exactly 1 byte of unset data,
+                         * then it won't clear the FIN bit below,
+                         * and if we are in persist state, we wind
+                         * up sending the packet without recording
+                         * that we sent the FIN bit.
+                         *
+                         * We can't just blindly clear the FIN bit,
+                         * because if we don't have any more data
+                         * to send then the probe will be the FIN
+                         * itself.
+                         */
+                        if (off < so->so_snd.sb_cc)
+                                flags &= ~TH_FIN;
+                        win = 1;
+                } else {
+                        tp->t_timer[TCPT_PERSIST] = 0;
+                        tp->t_rxtshift = 0;
+                }
+        }
+
+        len = min(so->so_snd.sb_cc, win) - off;
+
+        if (len < 0) {
+                /*
+                 * If FIN has been sent but not acked,
+                 * but we haven't been called to retransmit,
+                 * len will be -1.  Otherwise, window shrank
+                 * after we sent into it.  If window shrank to 0,
+                 * cancel pending retransmit and pull snd_nxt
+                 * back to (closed) window.  We will enter persist
+                 * state below.  If the window didn't close completely,
+                 * just wait for an ACK.
+                 */
+                len = 0;
+                if (win == 0) {
+                        tp->t_timer[TCPT_REXMT] = 0;
+                        tp->snd_nxt = tp->snd_una;
+                }
+        }
+
+        if (len > tp->t_maxseg) {
+                len = tp->t_maxseg;
+                sendalot = 1;
+        }
+        if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + so->so_snd.sb_cc))
+                flags &= ~TH_FIN;
+
+        win = sbspace(&so->so_rcv);
+
+        /*
+         * Sender silly window avoidance.  If connection is idle
+         * and can send all data, a maximum segment,
+         * at least a maximum default-size segment do it,
+         * or are forced, do it; otherwise don't bother.
+         * If peer's buffer is tiny, then send
+         * when window is at least half open.
+         * If retransmitting (possibly after persist timer forced us
+         * to send into a small window), then must resend.
+         */
+        if (len) {
+                if (len == tp->t_maxseg)
+                        goto send;
+                if ((1 || idle || tp->t_flags & TF_NODELAY) &&
+                    len + off >= so->so_snd.sb_cc)
+                        goto send;
+                if (tp->t_force)
+                        goto send;
+                if (len >= tp->max_sndwnd / 2 && tp->max_sndwnd > 0)
+                        goto send;
+                if (SEQ_LT(tp->snd_nxt, tp->snd_max))
+                        goto send;
+        }
+
+        /*
+         * Compare available window to amount of window
+         * known to peer (as advertised window less
+         * next expected input).  If the difference is at least two
+         * max size segments, or at least 50% of the maximum possible
+         * window, then want to send a window update to peer.
+         */
+        if (win > 0) {
+                /*
+                 * "adv" is the amount we can increase the window,
+                 * taking into account that we are limited by
+                 * TCP_MAXWIN << tp->rcv_scale.
+                 */
+                long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) -
+                        (tp->rcv_adv - tp->rcv_nxt);
+
+                if (adv >= (long) (2 * tp->t_maxseg))
+                        goto send;
+                if (2 * adv >= (long) so->so_rcv.sb_datalen)
+                        goto send;
+        }
+
+        /*
+         * Send if we owe peer an ACK.
+         */
+        if (tp->t_flags & TF_ACKNOW)
+                goto send;
+        if (flags & (TH_SYN|TH_RST))
+                goto send;
+        if (SEQ_GT(tp->snd_up, tp->snd_una))
+                goto send;
+        /*
+         * If our state indicates that FIN should be sent
+         * and we have not yet done so, or we're retransmitting the FIN,
+         * then we need to send.
+         */
+        if (flags & TH_FIN &&
+            ((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
+                goto send;
+
+        /*
+         * TCP window updates are not reliable, rather a polling protocol
+         * using ``persist'' packets is used to insure receipt of window
+         * updates.  The three ``states'' for the output side are:
+         *      idle                    not doing retransmits or persists
+         *      persisting              to move a small or zero window
+         *      (re)transmitting        and thereby not persisting
+         *
+         * tp->t_timer[TCPT_PERSIST]
+         *      is set when we are in persist state.
+         * tp->t_force
+         *      is set when we are called to send a persist packet.
+         * tp->t_timer[TCPT_REXMT]
+         *      is set when we are retransmitting
+         * The output side is idle when both timers are zero.
+         *
+         * If send window is too small, there is data to transmit, and no
+         * retransmit or persist is pending, then go to persist state.
+         * If nothing happens soon, send when timer expires:
+         * if window is nonzero, transmit what we can,
+         * otherwise force out a byte.
+         */
+        if (so->so_snd.sb_cc && tp->t_timer[TCPT_REXMT] == 0 &&
+            tp->t_timer[TCPT_PERSIST] == 0) {
+                tp->t_rxtshift = 0;
+                tcp_setpersist(tp);
+        }
+
+        /*
+         * No reason to send a segment, just return.
+         */
+        tcpstat.tcps_didnuttin++;
+
+        return (0);
 
 send:
-	/*
-	 * Before ESTABLISHED, force sending of initial options
-	 * unless TCP set not to do any options.
-	 * NOTE: we assume that the IP/TCP header plus TCP options
-	 * always fit in a single mbuf, leaving room for a maximum
-	 * link header, i.e.
-	 *	max_linkhdr + sizeof (struct tcpiphdr) + optlen <= MHLEN
-	 */
-	optlen = 0;
-	hdrlen = sizeof (struct tcpiphdr);
-	if (flags & TH_SYN) {
-		tp->snd_nxt = tp->iss;
-		if ((tp->t_flags & TF_NOOPT) == 0) {
-			u_int16_t mss;
-
-			opt[0] = TCPOPT_MAXSEG;
-			opt[1] = 4;
-			mss = htons((u_int16_t) tcp_mss(pData, tp, 0));
-			memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
-			optlen = 4;
-
-/*			if ((tp->t_flags & TF_REQ_SCALE) &&
- *			    ((flags & TH_ACK) == 0 ||
- *			    (tp->t_flags & TF_RCVD_SCALE))) {
- *				*((u_int32_t *) (opt + optlen)) = htonl(
- *					TCPOPT_NOP << 24 |
- *					TCPOPT_WINDOW << 16 |
- *					TCPOLEN_WINDOW << 8 |
- *					tp->request_r_scale);
- *				optlen += 4;
- *			}
- */
-		}
- 	}
-
- 	/*
-	 * Send a timestamp and echo-reply if this is a SYN and our side
-	 * wants to use timestamps (TF_REQ_TSTMP is set) or both our side
-	 * and our peer have sent timestamps in our SYN's.
- 	 */
-/* 	if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
- *	     (flags & TH_RST) == 0 &&
- *	    ((flags & (TH_SYN|TH_ACK)) == TH_SYN ||
- *	     (tp->t_flags & TF_RCVD_TSTMP))) {
- *		u_int32_t *lp = (u_int32_t *)(opt + optlen);
+        /*
+         * Before ESTABLISHED, force sending of initial options
+         * unless TCP set not to do any options.
+         * NOTE: we assume that the IP/TCP header plus TCP options
+         * always fit in a single mbuf, leaving room for a maximum
+         * link header, i.e.
+         *      max_linkhdr + sizeof (struct tcpiphdr) + optlen <= MHLEN
+         */
+        optlen = 0;
+        hdrlen = sizeof (struct tcpiphdr);
+        if (flags & TH_SYN) {
+                tp->snd_nxt = tp->iss;
+                if ((tp->t_flags & TF_NOOPT) == 0) {
+                        u_int16_t mss;
+
+                        opt[0] = TCPOPT_MAXSEG;
+                        opt[1] = 4;
+                        mss = htons((u_int16_t) tcp_mss(pData, tp, 0));
+                        memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
+                        optlen = 4;
+
+/*                      if ((tp->t_flags & TF_REQ_SCALE) &&
+ *                          ((flags & TH_ACK) == 0 ||
+ *                          (tp->t_flags & TF_RCVD_SCALE))) {
+ *                              *((u_int32_t *) (opt + optlen)) = htonl(
+ *                                      TCPOPT_NOP << 24 |
+ *                                      TCPOPT_WINDOW << 16 |
+ *                                      TCPOLEN_WINDOW << 8 |
+ *                                      tp->request_r_scale);
+ *                              optlen += 4;
+ *                      }
+ */
+                }
+        }
+
+        /*
+         * Send a timestamp and echo-reply if this is a SYN and our side
+         * wants to use timestamps (TF_REQ_TSTMP is set) or both our side
+         * and our peer have sent timestamps in our SYN's.
+         */
+/*      if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
+ *           (flags & TH_RST) == 0 &&
+ *          ((flags & (TH_SYN|TH_ACK)) == TH_SYN ||
+ *           (tp->t_flags & TF_RCVD_TSTMP))) {
+ *              u_int32_t *lp = (u_int32_t *)(opt + optlen);
  *
- *		/ * Form timestamp option as shown in appendix A of RFC 1323. *  /
- *		*lp++ = htonl(TCPOPT_TSTAMP_HDR);
- *		*lp++ = htonl(tcp_now);
- *		*lp   = htonl(tp->ts_recent);
- *		optlen += TCPOLEN_TSTAMP_APPA;
- *	}
- */
- 	hdrlen += optlen;
-
-	/*
-	 * Adjust data length if insertion of options will
-	 * bump the packet length beyond the t_maxseg length.
-	 */
-	 if (len > tp->t_maxseg - optlen) {
-		len = tp->t_maxseg - optlen;
-		sendalot = 1;
-	 }
-
-	/*
-	 * Grab a header mbuf, attaching a copy of data to
-	 * be transmitted, and initialize the header from
-	 * the template for sends on this connection.
-	 */
-	if (len) {
-		if (tp->t_force && len == 1)
-			tcpstat.tcps_sndprobe++;
-		else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
-			tcpstat.tcps_sndrexmitpack++;
-			tcpstat.tcps_sndrexmitbyte += len;
-		} else {
-			tcpstat.tcps_sndpack++;
-			tcpstat.tcps_sndbyte += len;
-		}
-
-		m = m_get(pData);
-		if (m == NULL) {
-/*			error = ENOBUFS; */
-			error = 1;
-			goto out;
-		}
-		m->m_data += if_maxlinkhdr;
-		m->m_len = hdrlen;
-
-		/*
-		 * This will always succeed, since we make sure our mbufs
-		 * are big enough to hold one MSS packet + header + ... etc.
-		 */
-/*		if (len <= MHLEN - hdrlen - max_linkhdr) { */
-
-			sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
-			m->m_len += len;
-
-/*		} else {
- *			m->m_next = m_copy(so->so_snd.sb_mb, off, (int) len);
- *			if (m->m_next == 0)
- *				len = 0;
- *		}
- */
-		/*
-		 * If we're sending everything we've got, set PUSH.
-		 * (This will keep happy those implementations which only
-		 * give data to the user when a buffer fills or
-		 * a PUSH comes in.)
-		 */
-		if (off + len == so->so_snd.sb_cc)
-			flags |= TH_PUSH;
-	} else {
-		if (tp->t_flags & TF_ACKNOW)
-			tcpstat.tcps_sndacks++;
-		else if (flags & (TH_SYN|TH_FIN|TH_RST))
-			tcpstat.tcps_sndctrl++;
-		else if (SEQ_GT(tp->snd_up, tp->snd_una))
-			tcpstat.tcps_sndurg++;
-		else
-			tcpstat.tcps_sndwinup++;
-
-		m = m_get(pData);
-		if (m == NULL) {
-/*			error = ENOBUFS; */
-			error = 1;
-			goto out;
-		}
-		m->m_data += if_maxlinkhdr;
-		m->m_len = hdrlen;
-	}
-
-	ti = mtod(m, struct tcpiphdr *);
-
-	memcpy((caddr_t)ti, &tp->t_template, sizeof (struct tcpiphdr));
-
-	/*
-	 * Fill in fields, remembering maximum advertised
-	 * window for use in delaying messages about window sizes.
-	 * If resending a FIN, be sure not to use a new sequence number.
-	 */
-	if (flags & TH_FIN && tp->t_flags & TF_SENTFIN &&
-	    tp->snd_nxt == tp->snd_max)
-		tp->snd_nxt--;
-	/*
-	 * If we are doing retransmissions, then snd_nxt will
-	 * not reflect the first unsent octet.  For ACK only
-	 * packets, we do not want the sequence number of the
-	 * retransmitted packet, we want the sequence number
-	 * of the next unsent octet.  So, if there is no data
-	 * (and no SYN or FIN), use snd_max instead of snd_nxt
-	 * when filling in ti_seq.  But if we are in persist
-	 * state, snd_max might reflect one byte beyond the
-	 * right edge of the window, so use snd_nxt in that
-	 * case, since we know we aren't doing a retransmission.
-	 * (retransmit and persist are mutually exclusive...)
-	 */
-	if (len || (flags & (TH_SYN|TH_FIN)) || tp->t_timer[TCPT_PERSIST])
-		ti->ti_seq = htonl(tp->snd_nxt);
-	else
-		ti->ti_seq = htonl(tp->snd_max);
-	ti->ti_ack = htonl(tp->rcv_nxt);
-	if (optlen) {
-		memcpy((caddr_t)(ti + 1), (caddr_t)opt, optlen);
-		ti->ti_off = (sizeof (struct tcphdr) + optlen) >> 2;
-	}
-	ti->ti_flags = flags;
-	/*
-	 * Calculate receive window.  Don't shrink window,
-	 * but avoid silly window syndrome.
-	 */
-	if (win < (long)(so->so_rcv.sb_datalen / 4) && win < (long)tp->t_maxseg)
-		win = 0;
-	if (win > (long)TCP_MAXWIN << tp->rcv_scale)
-		win = (long)TCP_MAXWIN << tp->rcv_scale;
-	if (win < (long)(tp->rcv_adv - tp->rcv_nxt))
-		win = (long)(tp->rcv_adv - tp->rcv_nxt);
-	ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));
-
-	if (SEQ_GT(tp->snd_up, tp->snd_una)) {
-		ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
+ *              / * Form timestamp option as shown in appendix A of RFC 1323. *  /
+ *              *lp++ = htonl(TCPOPT_TSTAMP_HDR);
+ *              *lp++ = htonl(tcp_now);
+ *              *lp   = htonl(tp->ts_recent);
+ *              optlen += TCPOLEN_TSTAMP_APPA;
+ *      }
+ */
+        hdrlen += optlen;
+
+        /*
+         * Adjust data length if insertion of options will
+         * bump the packet length beyond the t_maxseg length.
+         */
+         if (len > tp->t_maxseg - optlen) {
+                len = tp->t_maxseg - optlen;
+                sendalot = 1;
+         }
+
+        /*
+         * Grab a header mbuf, attaching a copy of data to
+         * be transmitted, and initialize the header from
+         * the template for sends on this connection.
+         */
+        if (len) {
+                if (tp->t_force && len == 1)
+                        tcpstat.tcps_sndprobe++;
+                else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
+                        tcpstat.tcps_sndrexmitpack++;
+                        tcpstat.tcps_sndrexmitbyte += len;
+                } else {
+                        tcpstat.tcps_sndpack++;
+                        tcpstat.tcps_sndbyte += len;
+                }
+
+                m = m_get(pData);
+                if (m == NULL) {
+/*                      error = ENOBUFS; */
+                        error = 1;
+                        goto out;
+                }
+                m->m_data += if_maxlinkhdr;
+                m->m_len = hdrlen;
+
+                /*
+                 * This will always succeed, since we make sure our mbufs
+                 * are big enough to hold one MSS packet + header + ... etc.
+                 */
+/*              if (len <= MHLEN - hdrlen - max_linkhdr) { */
+
+                        sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
+                        m->m_len += len;
+
+/*              } else {
+ *                      m->m_next = m_copy(so->so_snd.sb_mb, off, (int) len);
+ *                      if (m->m_next == 0)
+ *                              len = 0;
+ *              }
+ */
+                /*
+                 * If we're sending everything we've got, set PUSH.
+                 * (This will keep happy those implementations which only
+                 * give data to the user when a buffer fills or
+                 * a PUSH comes in.)
+                 */
+                if (off + len == so->so_snd.sb_cc)
+                        flags |= TH_PUSH;
+        } else {
+                if (tp->t_flags & TF_ACKNOW)
+                        tcpstat.tcps_sndacks++;
+                else if (flags & (TH_SYN|TH_FIN|TH_RST))
+                        tcpstat.tcps_sndctrl++;
+                else if (SEQ_GT(tp->snd_up, tp->snd_una))
+                        tcpstat.tcps_sndurg++;
+                else
+                        tcpstat.tcps_sndwinup++;
+
+                m = m_get(pData);
+                if (m == NULL) {
+/*                      error = ENOBUFS; */
+                        error = 1;
+                        goto out;
+                }
+                m->m_data += if_maxlinkhdr;
+                m->m_len = hdrlen;
+        }
+
+        ti = mtod(m, struct tcpiphdr *);
+
+        memcpy((caddr_t)ti, &tp->t_template, sizeof (struct tcpiphdr));
+
+        /*
+         * Fill in fields, remembering maximum advertised
+         * window for use in delaying messages about window sizes.
+         * If resending a FIN, be sure not to use a new sequence number.
+         */
+        if (flags & TH_FIN && tp->t_flags & TF_SENTFIN &&
+            tp->snd_nxt == tp->snd_max)
+                tp->snd_nxt--;
+        /*
+         * If we are doing retransmissions, then snd_nxt will
+         * not reflect the first unsent octet.  For ACK only
+         * packets, we do not want the sequence number of the
+         * retransmitted packet, we want the sequence number
+         * of the next unsent octet.  So, if there is no data
+         * (and no SYN or FIN), use snd_max instead of snd_nxt
+         * when filling in ti_seq.  But if we are in persist
+         * state, snd_max might reflect one byte beyond the
+         * right edge of the window, so use snd_nxt in that
+         * case, since we know we aren't doing a retransmission.
+         * (retransmit and persist are mutually exclusive...)
+         */
+        if (len || (flags & (TH_SYN|TH_FIN)) || tp->t_timer[TCPT_PERSIST])
+                ti->ti_seq = htonl(tp->snd_nxt);
+        else
+                ti->ti_seq = htonl(tp->snd_max);
+        ti->ti_ack = htonl(tp->rcv_nxt);
+        if (optlen) {
+                memcpy((caddr_t)(ti + 1), (caddr_t)opt, optlen);
+                ti->ti_off = (sizeof (struct tcphdr) + optlen) >> 2;
+        }
+        ti->ti_flags = flags;
+        /*
+         * Calculate receive window.  Don't shrink window,
+         * but avoid silly window syndrome.
+         */
+        if (win < (long)(so->so_rcv.sb_datalen / 4) && win < (long)tp->t_maxseg)
+                win = 0;
+        if (win > (long)TCP_MAXWIN << tp->rcv_scale)
+                win = (long)TCP_MAXWIN << tp->rcv_scale;
+        if (win < (long)(tp->rcv_adv - tp->rcv_nxt))
+                win = (long)(tp->rcv_adv - tp->rcv_nxt);
+        ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));
+
+        if (SEQ_GT(tp->snd_up, tp->snd_una)) {
+                ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
 #ifdef notdef
-	if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
-		ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));
+        if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
+                ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));
 #endif
-		ti->ti_flags |= TH_URG;
-	} else
-		/*
-		 * If no urgent pointer to send, then we pull
-		 * the urgent pointer to the left edge of the send window
-		 * so that it doesn't drift into the send window on sequence
-		 * number wraparound.
-		 */
-		tp->snd_up = tp->snd_una;		/* drag it along */
-
-	/*
-	 * Put TCP length in extended header, and then
-	 * checksum extended header and data.
-	 */
-	if (len + optlen)
-		ti->ti_len = htons((u_int16_t)(sizeof (struct tcphdr) +
-		    optlen + len));
-	ti->ti_sum = cksum(m, (int)(hdrlen + len));
-
-	/*
-	 * In transmit state, time the transmission and arrange for
-	 * the retransmit.  In persist state, just set snd_max.
-	 */
-	if (tp->t_force == 0 || tp->t_timer[TCPT_PERSIST] == 0) {
-		tcp_seq startseq = tp->snd_nxt;
-
-		/*
-		 * Advance snd_nxt over sequence space of this segment.
-		 */
-		if (flags & (TH_SYN|TH_FIN)) {
-			if (flags & TH_SYN)
-				tp->snd_nxt++;
-			if (flags & TH_FIN) {
-				tp->snd_nxt++;
-				tp->t_flags |= TF_SENTFIN;
-			}
-		}
-		tp->snd_nxt += len;
-		if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
-			tp->snd_max = tp->snd_nxt;
-			/*
-			 * Time this transmission if not a retransmission and
-			 * not currently timing anything.
-			 */
-			if (tp->t_rtt == 0) {
-				tp->t_rtt = 1;
-				tp->t_rtseq = startseq;
-				tcpstat.tcps_segstimed++;
-			}
-		}
-
-		/*
-		 * Set retransmit timer if not currently set,
-		 * and not doing an ack or a keep-alive probe.
-		 * Initial value for retransmit timer is smoothed
-		 * round-trip time + 2 * round-trip time variance.
-		 * Initialize shift counter which is used for backoff
-		 * of retransmit time.
-		 */
-		if (tp->t_timer[TCPT_REXMT] == 0 &&
-		    tp->snd_nxt != tp->snd_una) {
-			tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
-			if (tp->t_timer[TCPT_PERSIST]) {
-				tp->t_timer[TCPT_PERSIST] = 0;
-				tp->t_rxtshift = 0;
-			}
-		}
-	} else
-		if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
-			tp->snd_max = tp->snd_nxt + len;
-
-	/*
-	 * Fill in IP length and desired time to live and
-	 * send to IP level.  There should be a better way
-	 * to handle ttl and tos; we could keep them in
-	 * the template, but need a way to checksum without them.
-	 */
-	m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */
+                ti->ti_flags |= TH_URG;
+        } else
+                /*
+                 * If no urgent pointer to send, then we pull
+                 * the urgent pointer to the left edge of the send window
+                 * so that it doesn't drift into the send window on sequence
+                 * number wraparound.
+                 */
+                tp->snd_up = tp->snd_una;               /* drag it along */
+
+        /*
+         * Put TCP length in extended header, and then
+         * checksum extended header and data.
+         */
+        if (len + optlen)
+                ti->ti_len = htons((u_int16_t)(sizeof (struct tcphdr) +
+                    optlen + len));
+        ti->ti_sum = cksum(m, (int)(hdrlen + len));
+
+        /*
+         * In transmit state, time the transmission and arrange for
+         * the retransmit.  In persist state, just set snd_max.
+         */
+        if (tp->t_force == 0 || tp->t_timer[TCPT_PERSIST] == 0) {
+                tcp_seq startseq = tp->snd_nxt;
+
+                /*
+                 * Advance snd_nxt over sequence space of this segment.
+                 */
+                if (flags & (TH_SYN|TH_FIN)) {
+                        if (flags & TH_SYN)
+                                tp->snd_nxt++;
+                        if (flags & TH_FIN) {
+                                tp->snd_nxt++;
+                                tp->t_flags |= TF_SENTFIN;
+                        }
+                }
+                tp->snd_nxt += len;
+                if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
+                        tp->snd_max = tp->snd_nxt;
+                        /*
+                         * Time this transmission if not a retransmission and
+                         * not currently timing anything.
+                         */
+                        if (tp->t_rtt == 0) {
+                                tp->t_rtt = 1;
+                                tp->t_rtseq = startseq;
+                                tcpstat.tcps_segstimed++;
+                        }
+                }
+
+                /*
+                 * Set retransmit timer if not currently set,
+                 * and not doing an ack or a keep-alive probe.
+                 * Initial value for retransmit timer is smoothed
+                 * round-trip time + 2 * round-trip time variance.
+                 * Initialize shift counter which is used for backoff
+                 * of retransmit time.
+                 */
+                if (tp->t_timer[TCPT_REXMT] == 0 &&
+                    tp->snd_nxt != tp->snd_una) {
+                        tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+                        if (tp->t_timer[TCPT_PERSIST]) {
+                                tp->t_timer[TCPT_PERSIST] = 0;
+                                tp->t_rxtshift = 0;
+                        }
+                }
+        } else
+                if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
+                        tp->snd_max = tp->snd_nxt + len;
+
+        /*
+         * Fill in IP length and desired time to live and
+         * send to IP level.  There should be a better way
+         * to handle ttl and tos; we could keep them in
+         * the template, but need a way to checksum without them.
+         */
+        m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */
 
     {
 
-	((struct ip *)ti)->ip_len = m->m_len;
-
-	((struct ip *)ti)->ip_ttl = ip_defttl;
-	((struct ip *)ti)->ip_tos = so->so_iptos;
+        ((struct ip *)ti)->ip_len = m->m_len;
+
+        ((struct ip *)ti)->ip_ttl = ip_defttl;
+        ((struct ip *)ti)->ip_tos = so->so_iptos;
 
 /* #if BSD >= 43 */
-	/* Don't do IP options... */
-/*	error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
- *	    so->so_options & SO_DONTROUTE, 0);
- */
-	error = ip_output(pData, so, m);
+        /* Don't do IP options... */
+/*      error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
+ *          so->so_options & SO_DONTROUTE, 0);
+ */
+        error = ip_output(pData, so, m);
 
 /* #else
- *	error = ip_output(m, (struct mbuf *)0, &tp->t_inpcb->inp_route,
- *	    so->so_options & SO_DONTROUTE);
+ *      error = ip_output(m, (struct mbuf *)0, &tp->t_inpcb->inp_route,
+ *          so->so_options & SO_DONTROUTE);
  * #endif
  */
     }
-	if (error) {
+        if (error) {
 out:
-/*		if (error == ENOBUFS) {
- *			tcp_quench(tp->t_inpcb, 0);
- *			return (0);
- *		}
- */
-/*		if ((error == EHOSTUNREACH || error == ENETDOWN)
- *		    && TCPS_HAVERCVDSYN(tp->t_state)) {
- *			tp->t_softerror = error;
- *			return (0);
- *		}
- */
-		return (error);
-	}
-	tcpstat.tcps_sndtotal++;
-
-	/*
-	 * Data sent (as far as we can tell).
-	 * If this advertises a larger window than any other segment,
-	 * then remember the size of the advertised window.
-	 * Any pending ACK has now been sent.
-	 */
-	if (win > 0 && SEQ_GT(tp->rcv_nxt+win, tp->rcv_adv))
-		tp->rcv_adv = tp->rcv_nxt + win;
-	tp->last_ack_sent = tp->rcv_nxt;
-	tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
-	if (sendalot)
-		goto again;
-
-	return (0);
+/*              if (error == ENOBUFS) {
+ *                      tcp_quench(tp->t_inpcb, 0);
+ *                      return (0);
+ *              }
+ */
+/*              if ((error == EHOSTUNREACH || error == ENETDOWN)
+ *                  && TCPS_HAVERCVDSYN(tp->t_state)) {
+ *                      tp->t_softerror = error;
+ *                      return (0);
+ *              }
+ */
+                return (error);
+        }
+        tcpstat.tcps_sndtotal++;
+
+        /*
+         * Data sent (as far as we can tell).
+         * If this advertises a larger window than any other segment,
+         * then remember the size of the advertised window.
+         * Any pending ACK has now been sent.
+         */
+        if (win > 0 && SEQ_GT(tp->rcv_nxt+win, tp->rcv_adv))
+                tp->rcv_adv = tp->rcv_nxt + win;
+        tp->last_ack_sent = tp->rcv_nxt;
+        tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
+        if (sendalot)
+                goto again;
+
+        return (0);
 }
 
 void
 tcp_setpersist(tp)
-	register struct tcpcb *tp;
+        register struct tcpcb *tp;
 {
     int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
 
-/*	if (tp->t_timer[TCPT_REXMT])
- *		panic("tcp_output REXMT");
- */
-	/*
-	 * Start/restart persistence timer.
-	 */
-	TCPT_RANGESET(tp->t_timer[TCPT_PERSIST],
-	    t * tcp_backoff[tp->t_rxtshift],
-	    TCPTV_PERSMIN, TCPTV_PERSMAX);
-	if (tp->t_rxtshift < TCP_MAXRXTSHIFT)
-		tp->t_rxtshift++;
+/*      if (tp->t_timer[TCPT_REXMT])
+ *              panic("tcp_output REXMT");
+ */
+        /*
+         * Start/restart persistence timer.
+         */
+        TCPT_RANGESET(tp->t_timer[TCPT_PERSIST],
+            t * tcp_backoff[tp->t_rxtshift],
+            TCPTV_PERSMIN, TCPTV_PERSMAX);
+        if (tp->t_rxtshift < TCP_MAXRXTSHIFT)
+                tp->t_rxtshift++;
 }
Index: trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_subr.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_subr.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_subr.c	8.1 (Berkeley) 6/10/93
+ *      @(#)tcp_subr.c  8.1 (Berkeley) 6/10/93
  * tcp_subr.c,v 1.5 1994/10/08 22:39:58 phk Exp
  */
@@ -53,6 +53,6 @@
 tcp_init(PNATState pData)
 {
-	tcp_iss = 1;		/* wrong */
-	tcb.so_next = tcb.so_prev = &tcb;
+        tcp_iss = 1;            /* wrong */
+        tcb.so_next = tcb.so_prev = &tcb;
         tcp_last_so = &tcb;
 #ifdef VBOX_WITH_BSD_TCP_REASS
@@ -71,26 +71,26 @@
 void
 tcp_template(tp)
-	struct tcpcb *tp;
-{
-	struct socket *so = tp->t_socket;
-	register struct tcpiphdr *n = &tp->t_template;
-
-	n->ti_next = n->ti_prev = 0;
-	n->ti_x1 = 0;
-	n->ti_pr = IPPROTO_TCP;
-	n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
-	n->ti_src = so->so_faddr;
-	n->ti_dst = so->so_laddr;
-	n->ti_sport = so->so_fport;
-	n->ti_dport = so->so_lport;
-
-	n->ti_seq = 0;
-	n->ti_ack = 0;
-	n->ti_x2 = 0;
-	n->ti_off = 5;
-	n->ti_flags = 0;
-	n->ti_win = 0;
-	n->ti_sum = 0;
-	n->ti_urp = 0;
+        struct tcpcb *tp;
+{
+        struct socket *so = tp->t_socket;
+        register struct tcpiphdr *n = &tp->t_template;
+
+        n->ti_next = n->ti_prev = 0;
+        n->ti_x1 = 0;
+        n->ti_pr = IPPROTO_TCP;
+        n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
+        n->ti_src = so->so_faddr;
+        n->ti_dst = so->so_laddr;
+        n->ti_sport = so->so_fport;
+        n->ti_dport = so->so_lport;
+
+        n->ti_seq = 0;
+        n->ti_ack = 0;
+        n->ti_x2 = 0;
+        n->ti_off = 5;
+        n->ti_flags = 0;
+        n->ti_win = 0;
+        n->ti_sum = 0;
+        n->ti_urp = 0;
 }
 
@@ -111,69 +111,69 @@
 tcp_respond(PNATState pData, struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, tcp_seq ack, tcp_seq seq, int flags)
 {
-	register int tlen;
-	int win = 0;
-
-	DEBUG_CALL("tcp_respond");
-	DEBUG_ARG("tp = %lx", (long)tp);
-	DEBUG_ARG("ti = %lx", (long)ti);
-	DEBUG_ARG("m = %lx", (long)m);
-	DEBUG_ARG("ack = %u", ack);
-	DEBUG_ARG("seq = %u", seq);
-	DEBUG_ARG("flags = %x", flags);
-
-	if (tp)
-		win = sbspace(&tp->t_socket->so_rcv);
-	if (m == 0) {
-		if ((m = m_get(pData)) == NULL)
-			return;
+        register int tlen;
+        int win = 0;
+
+        DEBUG_CALL("tcp_respond");
+        DEBUG_ARG("tp = %lx", (long)tp);
+        DEBUG_ARG("ti = %lx", (long)ti);
+        DEBUG_ARG("m = %lx", (long)m);
+        DEBUG_ARG("ack = %u", ack);
+        DEBUG_ARG("seq = %u", seq);
+        DEBUG_ARG("flags = %x", flags);
+
+        if (tp)
+                win = sbspace(&tp->t_socket->so_rcv);
+        if (m == 0) {
+                if ((m = m_get(pData)) == NULL)
+                        return;
 #ifdef TCP_COMPAT_42
-		tlen = 1;
+                tlen = 1;
 #else
-		tlen = 0;
+                tlen = 0;
 #endif
-		m->m_data += if_maxlinkhdr;
-		*mtod(m, struct tcpiphdr *) = *ti;
-		ti = mtod(m, struct tcpiphdr *);
-		flags = TH_ACK;
-	} else {
-		/*
-		 * ti points into m so the next line is just making
-		 * the mbuf point to ti
-		 */
-		m->m_data = (caddr_t)ti;
-
-		m->m_len = sizeof (struct tcpiphdr);
-		tlen = 0;
+                m->m_data += if_maxlinkhdr;
+                *mtod(m, struct tcpiphdr *) = *ti;
+                ti = mtod(m, struct tcpiphdr *);
+                flags = TH_ACK;
+        } else {
+                /*
+                 * ti points into m so the next line is just making
+                 * the mbuf point to ti
+                 */
+                m->m_data = (caddr_t)ti;
+
+                m->m_len = sizeof (struct tcpiphdr);
+                tlen = 0;
 #define xchg(a,b,type) { type t; t=a; a=b; b=t; }
-		xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_int32_t);
-		xchg(ti->ti_dport, ti->ti_sport, u_int16_t);
+                xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_int32_t);
+                xchg(ti->ti_dport, ti->ti_sport, u_int16_t);
 #undef xchg
-	}
-	ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
-	tlen += sizeof (struct tcpiphdr);
-	m->m_len = tlen;
-
-	ti->ti_next = ti->ti_prev = 0;
-	ti->ti_x1 = 0;
-	ti->ti_seq = htonl(seq);
-	ti->ti_ack = htonl(ack);
-	ti->ti_x2 = 0;
-	ti->ti_off = sizeof (struct tcphdr) >> 2;
-	ti->ti_flags = flags;
-	if (tp)
-		ti->ti_win = htons((u_int16_t) (win >> tp->rcv_scale));
-	else
-		ti->ti_win = htons((u_int16_t)win);
-	ti->ti_urp = 0;
-	ti->ti_sum = 0;
-	ti->ti_sum = cksum(m, tlen);
-	((struct ip *)ti)->ip_len = tlen;
-
-	if(flags & TH_RST)
-	  ((struct ip *)ti)->ip_ttl = MAXTTL;
-	else
-	  ((struct ip *)ti)->ip_ttl = ip_defttl;
-
-	(void) ip_output(pData, (struct socket *)0, m);
+        }
+        ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
+        tlen += sizeof (struct tcpiphdr);
+        m->m_len = tlen;
+
+        ti->ti_next = ti->ti_prev = 0;
+        ti->ti_x1 = 0;
+        ti->ti_seq = htonl(seq);
+        ti->ti_ack = htonl(ack);
+        ti->ti_x2 = 0;
+        ti->ti_off = sizeof (struct tcphdr) >> 2;
+        ti->ti_flags = flags;
+        if (tp)
+                ti->ti_win = htons((u_int16_t) (win >> tp->rcv_scale));
+        else
+                ti->ti_win = htons((u_int16_t)win);
+        ti->ti_urp = 0;
+        ti->ti_sum = 0;
+        ti->ti_sum = cksum(m, tlen);
+        ((struct ip *)ti)->ip_len = tlen;
+
+        if(flags & TH_RST)
+          ((struct ip *)ti)->ip_ttl = MAXTTL;
+        else
+          ((struct ip *)ti)->ip_ttl = ip_defttl;
+
+        (void) ip_output(pData, (struct socket *)0, m);
 }
 
@@ -186,41 +186,41 @@
 tcp_newtcpcb(PNATState pData, struct socket *so)
 {
-	register struct tcpcb *tp;
-
-	tp = (struct tcpcb *)malloc(sizeof(*tp));
-	if (tp == NULL)
-		return ((struct tcpcb *)0);
-
-	memset((char *) tp, 0, sizeof(struct tcpcb));
+        register struct tcpcb *tp;
+
+        tp = (struct tcpcb *)malloc(sizeof(*tp));
+        if (tp == NULL)
+                return ((struct tcpcb *)0);
+
+        memset((char *) tp, 0, sizeof(struct tcpcb));
 #ifndef VBOX_WITH_BSD_TCP_REASS
-	tp->seg_next = tp->seg_prev = ptr_to_u32(pData, (struct tcpiphdr *)tp);
+        tp->seg_next = tp->seg_prev = ptr_to_u32(pData, (struct tcpiphdr *)tp);
 #else  /* VBOX_WITH_BSD_TCP_REASS */
         LIST_INSERT_HEAD(&pData->tcpcbhead, tp, t_list);
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-	tp->t_maxseg = tcp_mssdflt;
-
-	tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
-	tp->t_socket = so;
-
-	/*
-	 * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no
-	 * rtt estimate.  Set rttvar so that srtt + 2 * rttvar gives
-	 * reasonable initial retransmit time.
-	 */
-	tp->t_srtt = TCPTV_SRTTBASE;
-	tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << 2;
-	tp->t_rttmin = TCPTV_MIN;
-
-	TCPT_RANGESET(tp->t_rxtcur,
-	    ((TCPTV_SRTTBASE >> 2) + (TCPTV_SRTTDFLT << 2)) >> 1,
-	    TCPTV_MIN, TCPTV_REXMTMAX);
-
-	tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
-	tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
-	tp->t_state = TCPS_CLOSED;
-
-	so->so_tcpcb = tp;
-
-	return (tp);
+        tp->t_maxseg = tcp_mssdflt;
+
+        tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
+        tp->t_socket = so;
+
+        /*
+         * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no
+         * rtt estimate.  Set rttvar so that srtt + 2 * rttvar gives
+         * reasonable initial retransmit time.
+         */
+        tp->t_srtt = TCPTV_SRTTBASE;
+        tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << 2;
+        tp->t_rttmin = TCPTV_MIN;
+
+        TCPT_RANGESET(tp->t_rxtcur,
+            ((TCPTV_SRTTBASE >> 2) + (TCPTV_SRTTDFLT << 2)) >> 1,
+            TCPTV_MIN, TCPTV_REXMTMAX);
+
+        tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
+        tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
+        tp->t_state = TCPS_CLOSED;
+
+        so->so_tcpcb = tp;
+
+        return (tp);
 }
 
@@ -233,61 +233,61 @@
 {
 /* tcp_drop(tp, errno)
-	register struct tcpcb *tp;
-	int errno;
+        register struct tcpcb *tp;
+        int errno;
 {
 */
 
-	DEBUG_CALL("tcp_drop");
-	DEBUG_ARG("tp = %lx", (long)tp);
-	DEBUG_ARG("errno = %d", errno);
-
-	if (TCPS_HAVERCVDSYN(tp->t_state)) {
-		tp->t_state = TCPS_CLOSED;
-		(void) tcp_output(pData, tp);
-		tcpstat.tcps_drops++;
-	} else
-		tcpstat.tcps_conndrops++;
-/*	if (errno == ETIMEDOUT && tp->t_softerror)
- *		errno = tp->t_softerror;
- */
-/*	so->so_error = errno; */
-	return (tcp_close(pData, tp));
+        DEBUG_CALL("tcp_drop");
+        DEBUG_ARG("tp = %lx", (long)tp);
+        DEBUG_ARG("errno = %d", errno);
+
+        if (TCPS_HAVERCVDSYN(tp->t_state)) {
+                tp->t_state = TCPS_CLOSED;
+                (void) tcp_output(pData, tp);
+                tcpstat.tcps_drops++;
+        } else
+                tcpstat.tcps_conndrops++;
+/*      if (errno == ETIMEDOUT && tp->t_softerror)
+ *              errno = tp->t_softerror;
+ */
+/*      so->so_error = errno; */
+        return (tcp_close(pData, tp));
 }
 
 /*
  * Close a TCP control block:
- *	discard all space held by the tcp
- *	discard internet protocol block
- *	wake up any sleepers
+ *      discard all space held by the tcp
+ *      discard internet protocol block
+ *      wake up any sleepers
  */
 struct tcpcb *
 tcp_close(PNATState pData, register struct tcpcb *tp)
 {
-	register struct tcpiphdr *t;
-	struct socket *so = tp->t_socket;
-	register struct mbuf *m;
+        register struct tcpiphdr *t;
+        struct socket *so = tp->t_socket;
+        register struct mbuf *m;
 
 #ifndef VBOX_WITH_BSD_TCP_REASS
-	DEBUG_CALL("tcp_close");
-	DEBUG_ARG("tp = %lx", (long )tp);
-
-	/* free the reassembly queue, if any */
-	t = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *);
-	while (t != (struct tcpiphdr *)tp) {
-		t = u32_to_ptr(pData, t->ti_next, struct tcpiphdr *);
-		m = REASS_MBUF_GET(u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
-		remque_32(pData, u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
-		m_freem(pData, m);
-	}
-	/* It's static */
-/*	if (tp->t_template)
- *		(void) m_free(dtom(tp->t_template));
- */
-/*	free(tp, M_PCB);  */
-	u32ptr_done(pData, ptr_to_u32(pData, tp), tp);
+        DEBUG_CALL("tcp_close");
+        DEBUG_ARG("tp = %lx", (long )tp);
+
+        /* free the reassembly queue, if any */
+        t = u32_to_ptr(pData, tp->seg_next, struct tcpiphdr *);
+        while (t != (struct tcpiphdr *)tp) {
+                t = u32_to_ptr(pData, t->ti_next, struct tcpiphdr *);
+                m = REASS_MBUF_GET(u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
+                remque_32(pData, u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
+                m_freem(pData, m);
+        }
+        /* It's static */
+/*      if (tp->t_template)
+ *              (void) m_free(dtom(tp->t_template));
+ */
+/*      free(tp, M_PCB);  */
+        u32ptr_done(pData, ptr_to_u32(pData, tp), tp);
 #else  /* VBOX_WITH_BSD_TCP_REASS */
         struct tseg_qent *te;
-	DEBUG_CALL("tcp_close");
-	DEBUG_ARG("tp = %lx", (long )tp);
+        DEBUG_CALL("tcp_close");
+        DEBUG_ARG("tp = %lx", (long )tp);
         /*XXX: freeing the reassembly queue */
         LIST_FOREACH(te, &tp->t_segq, tqe_q) {
@@ -298,16 +298,16 @@
         }
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-	free(tp);
-	so->so_tcpcb = 0;
-	soisfdisconnected(so);
-	/* clobber input socket cache if we're closing the cached connection */
-	if (so == tcp_last_so)
-		tcp_last_so = &tcb;
-	closesocket(so->s);
-	sbfree(&so->so_rcv);
-	sbfree(&so->so_snd);
-	sofree(pData, so);
-	tcpstat.tcps_closed++;
-	return ((struct tcpcb *)0);
+        free(tp);
+        so->so_tcpcb = 0;
+        soisfdisconnected(so);
+        /* clobber input socket cache if we're closing the cached connection */
+        if (so == tcp_last_so)
+                tcp_last_so = &tcb;
+        closesocket(so->s);
+        sbfree(&so->so_rcv);
+        sbfree(&so->so_snd);
+        sofree(pData, so);
+        tcpstat.tcps_closed++;
+        return ((struct tcpcb *)0);
 }
 
@@ -315,5 +315,5 @@
 tcp_drain()
 {
-	/* XXX */
+        /* XXX */
 }
 
@@ -328,10 +328,10 @@
 tcp_quench(i, errno)
 
-	int errno;
-{
-	struct tcpcb *tp = intotcpcb(inp);
-
-	if (tp)
-		tp->snd_cwnd = tp->t_maxseg;
+        int errno;
+{
+        struct tcpcb *tp = intotcpcb(inp);
+
+        if (tp)
+                tp->snd_cwnd = tp->t_maxseg;
 }
 
@@ -356,30 +356,30 @@
 {
 
-	DEBUG_CALL("tcp_sockclosed");
-	DEBUG_ARG("tp = %lx", (long)tp);
-
-	switch (tp->t_state) {
-
-	case TCPS_CLOSED:
-	case TCPS_LISTEN:
-	case TCPS_SYN_SENT:
-		tp->t_state = TCPS_CLOSED;
-		tp = tcp_close(pData, tp);
-		break;
-
-	case TCPS_SYN_RECEIVED:
-	case TCPS_ESTABLISHED:
-		tp->t_state = TCPS_FIN_WAIT_1;
-		break;
-
-	case TCPS_CLOSE_WAIT:
-		tp->t_state = TCPS_LAST_ACK;
-		break;
-	}
-/*	soisfdisconnecting(tp->t_socket); */
-	if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
-		soisfdisconnected(tp->t_socket);
-	if (tp)
-		tcp_output(pData, tp);
+        DEBUG_CALL("tcp_sockclosed");
+        DEBUG_ARG("tp = %lx", (long)tp);
+
+        switch (tp->t_state) {
+
+        case TCPS_CLOSED:
+        case TCPS_LISTEN:
+        case TCPS_SYN_SENT:
+                tp->t_state = TCPS_CLOSED;
+                tp = tcp_close(pData, tp);
+                break;
+
+        case TCPS_SYN_RECEIVED:
+        case TCPS_ESTABLISHED:
+                tp->t_state = TCPS_FIN_WAIT_1;
+                break;
+
+        case TCPS_CLOSE_WAIT:
+                tp->t_state = TCPS_LAST_ACK;
+                break;
+        }
+/*      soisfdisconnecting(tp->t_socket); */
+        if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
+                soisfdisconnected(tp->t_socket);
+        if (tp)
+                tcp_output(pData, tp);
 }
 
@@ -417,12 +417,12 @@
       case CTL_DNS:
         if (!get_dns_addr(pData, &dns_addr))
-	    addr.sin_addr = dns_addr;
+            addr.sin_addr = dns_addr;
         else
             addr.sin_addr = loopback_addr;
-	break;
+        break;
       case CTL_ALIAS:
       default:
-	addr.sin_addr = loopback_addr;
-	break;
+        addr.sin_addr = loopback_addr;
+        break;
       }
     } else
@@ -431,6 +431,6 @@
 
     DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
-		"addr.sin_addr.s_addr=%.16s\n",
-		ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
+                "addr.sin_addr.s_addr=%.16s\n",
+                ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
     /* We don't care what port we get */
     ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
@@ -461,82 +461,82 @@
 tcp_connect(PNATState pData, struct socket *inso)
 {
-	struct socket *so;
-	struct sockaddr_in addr;
-	socklen_t addrlen = sizeof(struct sockaddr_in);
-	struct tcpcb *tp;
-	int s, opt;
-
-	DEBUG_CALL("tcp_connect");
-	DEBUG_ARG("inso = %lx", (long)inso);
-
-	/*
-	 * If it's an SS_ACCEPTONCE socket, no need to socreate()
-	 * another socket, just use the accept() socket.
-	 */
-	if (inso->so_state & SS_FACCEPTONCE) {
-		/* FACCEPTONCE already have a tcpcb */
-		so = inso;
-	} else {
-		if ((so = socreate()) == NULL) {
-			/* If it failed, get rid of the pending connection */
-			closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen));
-			return;
-		}
-		if (tcp_attach(pData, so) < 0) {
-			free(so); /* NOT sofree */
-			return;
-		}
-		so->so_laddr = inso->so_laddr;
-		so->so_lport = inso->so_lport;
-	}
-
-	(void) tcp_mss(pData, sototcpcb(so), 0);
-
-	if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
-		tcp_close(pData, sototcpcb(so)); /* This will sofree() as well */
-		return;
-	}
-	fd_nonblock(s);
-	opt = 1;
-	setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
-	opt = 1;
-	setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
+        struct socket *so;
+        struct sockaddr_in addr;
+        socklen_t addrlen = sizeof(struct sockaddr_in);
+        struct tcpcb *tp;
+        int s, opt;
+
+        DEBUG_CALL("tcp_connect");
+        DEBUG_ARG("inso = %lx", (long)inso);
+
+        /*
+         * If it's an SS_ACCEPTONCE socket, no need to socreate()
+         * another socket, just use the accept() socket.
+         */
+        if (inso->so_state & SS_FACCEPTONCE) {
+                /* FACCEPTONCE already have a tcpcb */
+                so = inso;
+        } else {
+                if ((so = socreate()) == NULL) {
+                        /* If it failed, get rid of the pending connection */
+                        closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen));
+                        return;
+                }
+                if (tcp_attach(pData, so) < 0) {
+                        free(so); /* NOT sofree */
+                        return;
+                }
+                so->so_laddr = inso->so_laddr;
+                so->so_lport = inso->so_lport;
+        }
+
+        (void) tcp_mss(pData, sototcpcb(so), 0);
+
+        if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
+                tcp_close(pData, sototcpcb(so)); /* This will sofree() as well */
+                return;
+        }
+        fd_nonblock(s);
+        opt = 1;
+        setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
+        opt = 1;
+        setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
         opt = 1;
         setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));
 
-	so->so_fport = addr.sin_port;
-	so->so_faddr = addr.sin_addr;
-	/* Translate connections from localhost to the real hostname */
-	if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
-	   so->so_faddr = alias_addr;
-
-	/* Close the accept() socket, set right state */
-	if (inso->so_state & SS_FACCEPTONCE) {
-		closesocket(so->s); /* If we only accept once, close the accept() socket */
-		so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */
-					   /* if it's not FACCEPTONCE, it's already NOFDREF */
-	}
-	so->s = s;
-
-	so->so_iptos = tcp_tos(so);
-	tp = sototcpcb(so);
-
-	tcp_template(tp);
-
-	/* Compute window scaling to request.  */
-/*	while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
- *		(TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
- *		tp->request_r_scale++;
- */
-
-/*	soisconnecting(so); */ /* NOFDREF used instead */
-	tcpstat.tcps_connattempt++;
-
-	tp->t_state = TCPS_SYN_SENT;
-	tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
-	tp->iss = tcp_iss;
-	tcp_iss += TCP_ISSINCR/2;
-	tcp_sendseqinit(tp);
-	tcp_output(pData, tp);
+        so->so_fport = addr.sin_port;
+        so->so_faddr = addr.sin_addr;
+        /* Translate connections from localhost to the real hostname */
+        if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
+           so->so_faddr = alias_addr;
+
+        /* Close the accept() socket, set right state */
+        if (inso->so_state & SS_FACCEPTONCE) {
+                closesocket(so->s); /* If we only accept once, close the accept() socket */
+                so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */
+                                           /* if it's not FACCEPTONCE, it's already NOFDREF */
+        }
+        so->s = s;
+
+        so->so_iptos = tcp_tos(so);
+        tp = sototcpcb(so);
+
+        tcp_template(tp);
+
+        /* Compute window scaling to request.  */
+/*      while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
+ *              (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
+ *              tp->request_r_scale++;
+ */
+
+/*      soisconnecting(so); */ /* NOFDREF used instead */
+        tcpstat.tcps_connattempt++;
+
+        tp->t_state = TCPS_SYN_SENT;
+        tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
+        tp->iss = tcp_iss;
+        tcp_iss += TCP_ISSINCR/2;
+        tcp_sendseqinit(tp);
+        tcp_output(pData, tp);
 }
 
@@ -547,10 +547,10 @@
 tcp_attach(PNATState pData, struct socket *so)
 {
-	if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL)
-	   return -1;
-
-	insque(pData, so, &tcb);
-
-	return 0;
+        if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL)
+           return -1;
+
+        insque(pData, so, &tcb);
+
+        return 0;
 }
 
@@ -559,17 +559,17 @@
  */
 static const struct tos_t tcptos[] = {
-	  {0, 20, IPTOS_THROUGHPUT, 0},	/* ftp data */
-	  {21, 21, IPTOS_LOWDELAY,  EMU_FTP},	/* ftp control */
-	  {0, 23, IPTOS_LOWDELAY, 0},	/* telnet */
-	  {0, 80, IPTOS_THROUGHPUT, 0},	/* WWW */
-	  {0, 513, IPTOS_LOWDELAY, EMU_RLOGIN|EMU_NOCONNECT},	/* rlogin */
-	  {0, 514, IPTOS_LOWDELAY, EMU_RSH|EMU_NOCONNECT},	/* shell */
-	  {0, 544, IPTOS_LOWDELAY, EMU_KSH},		/* kshell */
-	  {0, 543, IPTOS_LOWDELAY, 0},	/* klogin */
-	  {0, 6667, IPTOS_THROUGHPUT, EMU_IRC},	/* IRC */
-	  {0, 6668, IPTOS_THROUGHPUT, EMU_IRC},	/* IRC undernet */
-	  {0, 7070, IPTOS_LOWDELAY, EMU_REALAUDIO }, /* RealAudio control */
-	  {0, 113, IPTOS_LOWDELAY, EMU_IDENT }, /* identd protocol */
-	  {0, 0, 0, 0}
+          {0, 20, IPTOS_THROUGHPUT, 0}, /* ftp data */
+          {21, 21, IPTOS_LOWDELAY,  EMU_FTP},   /* ftp control */
+          {0, 23, IPTOS_LOWDELAY, 0},   /* telnet */
+          {0, 80, IPTOS_THROUGHPUT, 0}, /* WWW */
+          {0, 513, IPTOS_LOWDELAY, EMU_RLOGIN|EMU_NOCONNECT},   /* rlogin */
+          {0, 514, IPTOS_LOWDELAY, EMU_RSH|EMU_NOCONNECT},      /* shell */
+          {0, 544, IPTOS_LOWDELAY, EMU_KSH},            /* kshell */
+          {0, 543, IPTOS_LOWDELAY, 0},  /* klogin */
+          {0, 6667, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC */
+          {0, 6668, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC undernet */
+          {0, 7070, IPTOS_LOWDELAY, EMU_REALAUDIO }, /* RealAudio control */
+          {0, 113, IPTOS_LOWDELAY, EMU_IDENT }, /* identd protocol */
+          {0, 0, 0, 0}
 };
 
@@ -579,18 +579,18 @@
 u_int8_t
 tcp_tos(so)
-	struct socket *so;
-{
-	int i = 0;
-
-	while(tcptos[i].tos) {
-		if ((tcptos[i].fport && (ntohs(so->so_fport) == tcptos[i].fport)) ||
-		    (tcptos[i].lport && (ntohs(so->so_lport) == tcptos[i].lport))) {
-			so->so_emu = tcptos[i].emu;
-			return tcptos[i].tos;
-		}
-		i++;
-	}
-
-	return 0;
+        struct socket *so;
+{
+        int i = 0;
+
+        while(tcptos[i].tos) {
+                if ((tcptos[i].fport && (ntohs(so->so_fport) == tcptos[i].fport)) ||
+                    (tcptos[i].lport && (ntohs(so->so_lport) == tcptos[i].lport))) {
+                        so->so_emu = tcptos[i].emu;
+                        return tcptos[i].tos;
+                }
+                i++;
+        }
+
+        return 0;
 }
 
@@ -622,180 +622,180 @@
 tcp_emu(PNATState pData, struct socket *so, struct mbuf *m)
 {
-	u_int n1, n2, n3, n4, n5, n6;
-	char buff[256];
-	u_int32_t laddr;
-	u_int lport;
-	char *bptr;
-
-	DEBUG_CALL("tcp_emu");
-	DEBUG_ARG("so = %lx", (long)so);
-	DEBUG_ARG("m = %lx", (long)m);
-
-	switch(so->so_emu) {
-		int x, i;
-
-	 case EMU_IDENT:
-		/*
-		 * Identification protocol as per rfc-1413
-		 */
-
-		{
-			struct socket *tmpso;
-			struct sockaddr_in addr;
-			socklen_t addrlen = sizeof(struct sockaddr_in);
-			struct sbuf *so_rcv = &so->so_rcv;
-
-			memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
-			so_rcv->sb_wptr += m->m_len;
-			so_rcv->sb_rptr += m->m_len;
-			m->m_data[m->m_len] = 0; /* NULL terminate */
-			if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
-				if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
-					HTONS(n1);
-					HTONS(n2);
-					/* n2 is the one on our host */
-					for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) {
-						if (tmpso->so_laddr.s_addr == so->so_laddr.s_addr &&
-						    tmpso->so_lport == n2 &&
-						    tmpso->so_faddr.s_addr == so->so_faddr.s_addr &&
-						    tmpso->so_fport == n1) {
-							if (getsockname(tmpso->s,
-								(struct sockaddr *)&addr, &addrlen) == 0)
-							   n2 = ntohs(addr.sin_port);
-							break;
-						}
-					}
-				}
-				so_rcv->sb_cc = sprintf(so_rcv->sb_data, "%d,%d\r\n", n1, n2);
-				so_rcv->sb_rptr = so_rcv->sb_data;
-				so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc;
-			}
-			m_free(pData, m);
-			return 0;
-		}
+        u_int n1, n2, n3, n4, n5, n6;
+        char buff[256];
+        u_int32_t laddr;
+        u_int lport;
+        char *bptr;
+
+        DEBUG_CALL("tcp_emu");
+        DEBUG_ARG("so = %lx", (long)so);
+        DEBUG_ARG("m = %lx", (long)m);
+
+        switch(so->so_emu) {
+                int x, i;
+
+         case EMU_IDENT:
+                /*
+                 * Identification protocol as per rfc-1413
+                 */
+
+                {
+                        struct socket *tmpso;
+                        struct sockaddr_in addr;
+                        socklen_t addrlen = sizeof(struct sockaddr_in);
+                        struct sbuf *so_rcv = &so->so_rcv;
+
+                        memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
+                        so_rcv->sb_wptr += m->m_len;
+                        so_rcv->sb_rptr += m->m_len;
+                        m->m_data[m->m_len] = 0; /* NULL terminate */
+                        if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
+                                if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
+                                        HTONS(n1);
+                                        HTONS(n2);
+                                        /* n2 is the one on our host */
+                                        for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) {
+                                                if (tmpso->so_laddr.s_addr == so->so_laddr.s_addr &&
+                                                    tmpso->so_lport == n2 &&
+                                                    tmpso->so_faddr.s_addr == so->so_faddr.s_addr &&
+                                                    tmpso->so_fport == n1) {
+                                                        if (getsockname(tmpso->s,
+                                                                (struct sockaddr *)&addr, &addrlen) == 0)
+                                                           n2 = ntohs(addr.sin_port);
+                                                        break;
+                                                }
+                                        }
+                                }
+                                so_rcv->sb_cc = sprintf(so_rcv->sb_data, "%d,%d\r\n", n1, n2);
+                                so_rcv->sb_rptr = so_rcv->sb_data;
+                                so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc;
+                        }
+                        m_free(pData, m);
+                        return 0;
+                }
 
         case EMU_FTP: /* ftp */
-		*(m->m_data+m->m_len) = 0; /* NULL terminate for strstr */
-		if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
-			/*
-			 * Need to emulate the PORT command
-			 */
-			x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]",
-				   &n1, &n2, &n3, &n4, &n5, &n6, buff);
-			if (x < 6)
-			   return 1;
-
-			laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
-			lport = htons((n5 << 8) | (n6));
-
-			if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
-			   return 1;
-
-			n6 = ntohs(so->so_fport);
-
-			n5 = (n6 >> 8) & 0xff;
-			n6 &= 0xff;
-
-			laddr = ntohl(so->so_faddr.s_addr);
-
-			n1 = ((laddr >> 24) & 0xff);
-			n2 = ((laddr >> 16) & 0xff);
-			n3 = ((laddr >> 8)  & 0xff);
-			n4 =  (laddr & 0xff);
-
-			m->m_len = bptr - m->m_data; /* Adjust length */
-			m->m_len += sprintf(bptr,"ORT %d,%d,%d,%d,%d,%d\r\n%s",
-					    n1, n2, n3, n4, n5, n6, x==7?buff:"");
-			return 1;
-		} else if ((bptr = (char *)strstr(m->m_data, "27 Entering")) != NULL) {
-			/*
-			 * Need to emulate the PASV response
-			 */
-			x = sscanf(bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]",
-				   &n1, &n2, &n3, &n4, &n5, &n6, buff);
-			if (x < 6)
-			   return 1;
-
-			laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
-			lport = htons((n5 << 8) | (n6));
-
-			if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
-			   return 1;
-
-			n6 = ntohs(so->so_fport);
-
-			n5 = (n6 >> 8) & 0xff;
-			n6 &= 0xff;
-
-			laddr = ntohl(so->so_faddr.s_addr);
-
-			n1 = ((laddr >> 24) & 0xff);
-			n2 = ((laddr >> 16) & 0xff);
-			n3 = ((laddr >> 8)  & 0xff);
-			n4 =  (laddr & 0xff);
-
-			m->m_len = bptr - m->m_data; /* Adjust length */
-			m->m_len += sprintf(bptr,"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s",
-					    n1, n2, n3, n4, n5, n6, x==7?buff:"");
-
-			return 1;
-		}
-
-		return 1;
-
-	 case EMU_KSH:
-		/*
-		 * The kshell (Kerberos rsh) and shell services both pass
-		 * a local port port number to carry signals to the server
-		 * and stderr to the client.  It is passed at the beginning
-		 * of the connection as a NUL-terminated decimal ASCII string.
-		 */
-		so->so_emu = 0;
-		for (lport = 0, i = 0; i < m->m_len-1; ++i) {
-			if (m->m_data[i] < '0' || m->m_data[i] > '9')
-				return 1;       /* invalid number */
-			lport *= 10;
-			lport += m->m_data[i] - '0';
-		}
-		if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
-		    (so = solisten(pData, 0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL)
-			m->m_len = sprintf(m->m_data, "%d", ntohs(so->so_fport))+1;
-		return 1;
-
-	 case EMU_IRC:
-		/*
-		 * Need to emulate DCC CHAT, DCC SEND and DCC MOVE
-		 */
-		*(m->m_data+m->m_len) = 0; /* NULL terminate the string for strstr */
-		if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
-			 return 1;
-
-		/* The %256s is for the broken mIRC */
-		if (sscanf(bptr, "DCC CHAT %256s %u %u", buff, &laddr, &lport) == 3) {
-			if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
-				return 1;
-
-			m->m_len = bptr - m->m_data; /* Adjust length */
-			m->m_len += sprintf(bptr, "DCC CHAT chat %lu %u%c\n",
-			     (unsigned long)ntohl(so->so_faddr.s_addr),
-			     ntohs(so->so_fport), 1);
-		} else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
-			if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
-				return 1;
-
-			m->m_len = bptr - m->m_data; /* Adjust length */
-			m->m_len += sprintf(bptr, "DCC SEND %s %lu %u %u%c\n",
-			      buff, (unsigned long)ntohl(so->so_faddr.s_addr),
-			      ntohs(so->so_fport), n1, 1);
-		} else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
-			if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
-				return 1;
-
-			m->m_len = bptr - m->m_data; /* Adjust length */
-			m->m_len += sprintf(bptr, "DCC MOVE %s %lu %u %u%c\n",
-			      buff, (unsigned long)ntohl(so->so_faddr.s_addr),
-			      ntohs(so->so_fport), n1, 1);
-		}
-		return 1;
+                *(m->m_data+m->m_len) = 0; /* NULL terminate for strstr */
+                if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
+                        /*
+                         * Need to emulate the PORT command
+                         */
+                        x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]",
+                                   &n1, &n2, &n3, &n4, &n5, &n6, buff);
+                        if (x < 6)
+                           return 1;
+
+                        laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
+                        lport = htons((n5 << 8) | (n6));
+
+                        if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
+                           return 1;
+
+                        n6 = ntohs(so->so_fport);
+
+                        n5 = (n6 >> 8) & 0xff;
+                        n6 &= 0xff;
+
+                        laddr = ntohl(so->so_faddr.s_addr);
+
+                        n1 = ((laddr >> 24) & 0xff);
+                        n2 = ((laddr >> 16) & 0xff);
+                        n3 = ((laddr >> 8)  & 0xff);
+                        n4 =  (laddr & 0xff);
+
+                        m->m_len = bptr - m->m_data; /* Adjust length */
+                        m->m_len += sprintf(bptr,"ORT %d,%d,%d,%d,%d,%d\r\n%s",
+                                            n1, n2, n3, n4, n5, n6, x==7?buff:"");
+                        return 1;
+                } else if ((bptr = (char *)strstr(m->m_data, "27 Entering")) != NULL) {
+                        /*
+                         * Need to emulate the PASV response
+                         */
+                        x = sscanf(bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]",
+                                   &n1, &n2, &n3, &n4, &n5, &n6, buff);
+                        if (x < 6)
+                           return 1;
+
+                        laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
+                        lport = htons((n5 << 8) | (n6));
+
+                        if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
+                           return 1;
+
+                        n6 = ntohs(so->so_fport);
+
+                        n5 = (n6 >> 8) & 0xff;
+                        n6 &= 0xff;
+
+                        laddr = ntohl(so->so_faddr.s_addr);
+
+                        n1 = ((laddr >> 24) & 0xff);
+                        n2 = ((laddr >> 16) & 0xff);
+                        n3 = ((laddr >> 8)  & 0xff);
+                        n4 =  (laddr & 0xff);
+
+                        m->m_len = bptr - m->m_data; /* Adjust length */
+                        m->m_len += sprintf(bptr,"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s",
+                                            n1, n2, n3, n4, n5, n6, x==7?buff:"");
+
+                        return 1;
+                }
+
+                return 1;
+
+         case EMU_KSH:
+                /*
+                 * The kshell (Kerberos rsh) and shell services both pass
+                 * a local port port number to carry signals to the server
+                 * and stderr to the client.  It is passed at the beginning
+                 * of the connection as a NUL-terminated decimal ASCII string.
+                 */
+                so->so_emu = 0;
+                for (lport = 0, i = 0; i < m->m_len-1; ++i) {
+                        if (m->m_data[i] < '0' || m->m_data[i] > '9')
+                                return 1;       /* invalid number */
+                        lport *= 10;
+                        lport += m->m_data[i] - '0';
+                }
+                if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
+                    (so = solisten(pData, 0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL)
+                        m->m_len = sprintf(m->m_data, "%d", ntohs(so->so_fport))+1;
+                return 1;
+
+         case EMU_IRC:
+                /*
+                 * Need to emulate DCC CHAT, DCC SEND and DCC MOVE
+                 */
+                *(m->m_data+m->m_len) = 0; /* NULL terminate the string for strstr */
+                if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
+                         return 1;
+
+                /* The %256s is for the broken mIRC */
+                if (sscanf(bptr, "DCC CHAT %256s %u %u", buff, &laddr, &lport) == 3) {
+                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
+                                return 1;
+
+                        m->m_len = bptr - m->m_data; /* Adjust length */
+                        m->m_len += sprintf(bptr, "DCC CHAT chat %lu %u%c\n",
+                             (unsigned long)ntohl(so->so_faddr.s_addr),
+                             ntohs(so->so_fport), 1);
+                } else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
+                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
+                                return 1;
+
+                        m->m_len = bptr - m->m_data; /* Adjust length */
+                        m->m_len += sprintf(bptr, "DCC SEND %s %lu %u %u%c\n",
+                              buff, (unsigned long)ntohl(so->so_faddr.s_addr),
+                              ntohs(so->so_fport), n1, 1);
+                } else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
+                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
+                                return 1;
+
+                        m->m_len = bptr - m->m_data; /* Adjust length */
+                        m->m_len += sprintf(bptr, "DCC MOVE %s %lu %u %u%c\n",
+                              buff, (unsigned long)ntohl(so->so_faddr.s_addr),
+                              ntohs(so->so_fport), n1, 1);
+                }
+                return 1;
 
 #ifdef VBOX
@@ -803,136 +803,136 @@
           * This is not legal when more than one slirp instance is active. */
 #else /* !VBOX */
-	 case EMU_REALAUDIO:
+         case EMU_REALAUDIO:
                 /*
-		 * RealAudio emulation - JP. We must try to parse the incoming
-		 * data and try to find the two characters that contain the
-		 * port number. Then we redirect an udp port and replace the
-		 * number with the real port we got.
-		 *
-		 * The 1.0 beta versions of the player are not supported
-		 * any more.
-		 *
-		 * A typical packet for player version 1.0 (release version):
-		 *
-		 * 0000:50 4E 41 00 05
-		 * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 .....×..gælÜc..P
-		 * 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH
-		 * 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles/v
-		 * 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa/english_.rayB
-		 *
-		 * Now the port number 0x1BD7 is found at offset 0x04 of the
-		 * Now the port number 0x1BD7 is found at offset 0x04 of the
-		 * second packet. This time we received five bytes first and
-		 * then the rest. You never know how many bytes you get.
-		 *
-		 * A typical packet for player version 2.0 (beta):
-		 *
-		 * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA...........Á.
-		 * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .guxõc..Win2.0.0
-		 * 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles/
-		 * 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website/20releas
-		 * 0040:65 2E 72 61 79 53 00 00 06 36 42                e.rayS...6B
-		 *
-		 * Port number 0x1BC1 is found at offset 0x0d.
-		 *
-		 * This is just a horrible switch statement. Variable ra tells
-		 * us where we're going.
-		 */
-
-		bptr = m->m_data;
-		while (bptr < m->m_data + m->m_len) {
-			u_short p;
-			static int ra = 0;
-			char ra_tbl[4];
-
-			ra_tbl[0] = 0x50;
-			ra_tbl[1] = 0x4e;
-			ra_tbl[2] = 0x41;
-			ra_tbl[3] = 0;
-
-			switch (ra) {
-			 case 0:
-			 case 2:
-			 case 3:
-				if (*bptr++ != ra_tbl[ra]) {
-					ra = 0;
-					continue;
-				}
-				break;
-
-			 case 1:
-				/*
-				 * We may get 0x50 several times, ignore them
-				 */
-				if (*bptr == 0x50) {
-					ra = 1;
-					bptr++;
-					continue;
-				} else if (*bptr++ != ra_tbl[ra]) {
-					ra = 0;
-					continue;
-				}
-				break;
-
-			 case 4:
-				/*
-				 * skip version number
-				 */
-				bptr++;
-				break;
-
-			 case 5:
-				/*
-				 * The difference between versions 1.0 and
-				 * 2.0 is here. For future versions of
-				 * the player this may need to be modified.
-				 */
-				if (*(bptr + 1) == 0x02)
-				   bptr += 8;
-				else
-				   bptr += 4;
-				break;
-
-			 case 6:
-				/* This is the field containing the port
-				 * number that RA-player is listening to.
-				 */
-				lport = (((u_char*)bptr)[0] << 8)
-				+ ((u_char *)bptr)[1];
-				if (lport < 6970)
-				   lport += 256;   /* don't know why */
-				if (lport < 6970 || lport > 7170)
-				   return 1;       /* failed */
-
-				/* try to get udp port between 6970 - 7170 */
-				for (p = 6970; p < 7071; p++) {
-					if (udp_listen( htons(p),
-						       so->so_laddr.s_addr,
-						       htons(lport),
-						       SS_FACCEPTONCE)) {
-						break;
-					}
-				}
-				if (p == 7071)
-				   p = 0;
-				*(u_char *)bptr++ = (p >> 8) & 0xff;
-				*(u_char *)bptr++ = p & 0xff;
-				ra = 0;
-				return 1;   /* port redirected, we're done */
-				break;
-
-			 default:
-				ra = 0;
-			}
-			ra++;
-		}
-		return 1;
+                 * RealAudio emulation - JP. We must try to parse the incoming
+                 * data and try to find the two characters that contain the
+                 * port number. Then we redirect an udp port and replace the
+                 * number with the real port we got.
+                 *
+                 * The 1.0 beta versions of the player are not supported
+                 * any more.
+                 *
+                 * A typical packet for player version 1.0 (release version):
+                 *
+                 * 0000:50 4E 41 00 05
+                 * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 .....×..gælÜc..P
+                 * 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH
+                 * 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles/v
+                 * 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa/english_.rayB
+                 *
+                 * Now the port number 0x1BD7 is found at offset 0x04 of the
+                 * Now the port number 0x1BD7 is found at offset 0x04 of the
+                 * second packet. This time we received five bytes first and
+                 * then the rest. You never know how many bytes you get.
+                 *
+                 * A typical packet for player version 2.0 (beta):
+                 *
+                 * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA...........Á.
+                 * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .guxõc..Win2.0.0
+                 * 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles/
+                 * 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website/20releas
+                 * 0040:65 2E 72 61 79 53 00 00 06 36 42                e.rayS...6B
+                 *
+                 * Port number 0x1BC1 is found at offset 0x0d.
+                 *
+                 * This is just a horrible switch statement. Variable ra tells
+                 * us where we're going.
+                 */
+
+                bptr = m->m_data;
+                while (bptr < m->m_data + m->m_len) {
+                        u_short p;
+                        static int ra = 0;
+                        char ra_tbl[4];
+
+                        ra_tbl[0] = 0x50;
+                        ra_tbl[1] = 0x4e;
+                        ra_tbl[2] = 0x41;
+                        ra_tbl[3] = 0;
+
+                        switch (ra) {
+                         case 0:
+                         case 2:
+                         case 3:
+                                if (*bptr++ != ra_tbl[ra]) {
+                                        ra = 0;
+                                        continue;
+                                }
+                                break;
+
+                         case 1:
+                                /*
+                                 * We may get 0x50 several times, ignore them
+                                 */
+                                if (*bptr == 0x50) {
+                                        ra = 1;
+                                        bptr++;
+                                        continue;
+                                } else if (*bptr++ != ra_tbl[ra]) {
+                                        ra = 0;
+                                        continue;
+                                }
+                                break;
+
+                         case 4:
+                                /*
+                                 * skip version number
+                                 */
+                                bptr++;
+                                break;
+
+                         case 5:
+                                /*
+                                 * The difference between versions 1.0 and
+                                 * 2.0 is here. For future versions of
+                                 * the player this may need to be modified.
+                                 */
+                                if (*(bptr + 1) == 0x02)
+                                   bptr += 8;
+                                else
+                                   bptr += 4;
+                                break;
+
+                         case 6:
+                                /* This is the field containing the port
+                                 * number that RA-player is listening to.
+                                 */
+                                lport = (((u_char*)bptr)[0] << 8)
+                                + ((u_char *)bptr)[1];
+                                if (lport < 6970)
+                                   lport += 256;   /* don't know why */
+                                if (lport < 6970 || lport > 7170)
+                                   return 1;       /* failed */
+
+                                /* try to get udp port between 6970 - 7170 */
+                                for (p = 6970; p < 7071; p++) {
+                                        if (udp_listen( htons(p),
+                                                       so->so_laddr.s_addr,
+                                                       htons(lport),
+                                                       SS_FACCEPTONCE)) {
+                                                break;
+                                        }
+                                }
+                                if (p == 7071)
+                                   p = 0;
+                                *(u_char *)bptr++ = (p >> 8) & 0xff;
+                                *(u_char *)bptr++ = p & 0xff;
+                                ra = 0;
+                                return 1;   /* port redirected, we're done */
+                                break;
+
+                         default:
+                                ra = 0;
+                        }
+                        ra++;
+                }
+                return 1;
 #endif /* !VBOX */
 
-	 default:
-		/* Ooops, not emulated, won't call tcp_emu again */
-		so->so_emu = 0;
-		return 1;
-	}
+         default:
+                /* Ooops, not emulated, won't call tcp_emu again */
+                so->so_emu = 0;
+                return 1;
+        }
 }
 
Index: trunk/src/VBox/Devices/Network/slirp/tcp_timer.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_timer.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_timer.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_timer.c	8.1 (Berkeley) 6/10/93
+ *      @(#)tcp_timer.c 8.1 (Berkeley) 6/10/93
  * tcp_timer.c,v 1.2 1994/08/02 07:49:10 davidg Exp
  */
@@ -44,19 +44,19 @@
 tcp_fasttimo(PNATState pData)
 {
-	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);
-		}
+        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);
+                }
 }
 
@@ -69,40 +69,40 @@
 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 */
 }
 
@@ -112,13 +112,13 @@
 void
 tcp_canceltimers(tp)
-	struct tcpcb *tp;
+        struct tcpcb *tp;
 {
-	register int i;
-
-	for (i = 0; i < TCPT_NTIMERS; i++)
-		tp->t_timer[i] = 0;
+        register int i;
+
+        for (i = 0; i < TCPT_NTIMERS; i++)
+                tp->t_timer[i] = 0;
 }
 
-const int	tcp_backoff[TCP_MAXRXTSHIFT + 1] =
+const int       tcp_backoff[TCP_MAXRXTSHIFT + 1] =
    { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
 
@@ -129,188 +129,188 @@
 tcp_timers(PNATState pData, register struct tcpcb *tp, int timer)
 {
-	register int rexmt;
-
-	DEBUG_CALL("tcp_timers");
-
-	switch (timer) {
-
-	/*
-	 * 2 MSL timeout in shutdown went off.  If we're closed but
-	 * still waiting for peer to close and connection has been idle
-	 * too long, or if 2MSL time is up from TIME_WAIT, delete connection
-	 * control block.  Otherwise, check again in a bit.
-	 */
-	case TCPT_2MSL:
-		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;
-
-	/*
-	 * Retransmission timer went off.  Message has not
-	 * been acked within retransmit interval.  Back off
-	 * to a longer retransmit interval and retransmit one segment.
-	 */
-	case TCPT_REXMT:
-
-		/*
-		 * XXXXX If a packet has timed out, then remove all the queued
-		 * packets for that session.
-		 */
-
-		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;
-		}
-		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.)
-		 */
-		{
-		u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
-		if (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;
-
-	/*
-	 * Persistence timer into zero window.
-	 * Force a byte to be output, if possible.
-	 */
-	case TCPT_PERSIST:
-		tcpstat.tcps_persisttimeo++;
-		tcp_setpersist(tp);
-		tp->t_force = 1;
-		(void) tcp_output(pData, tp);
-		tp->t_force = 0;
-		break;
-
-	/*
-	 * Keep-alive timer went off; send something
-	 * or drop connection if idle for too long.
-	 */
-	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++;
+        register int rexmt;
+
+        DEBUG_CALL("tcp_timers");
+
+        switch (timer) {
+
+        /*
+         * 2 MSL timeout in shutdown went off.  If we're closed but
+         * still waiting for peer to close and connection has been idle
+         * too long, or if 2MSL time is up from TIME_WAIT, delete connection
+         * control block.  Otherwise, check again in a bit.
+         */
+        case TCPT_2MSL:
+                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;
+
+        /*
+         * Retransmission timer went off.  Message has not
+         * been acked within retransmit interval.  Back off
+         * to a longer retransmit interval and retransmit one segment.
+         */
+        case TCPT_REXMT:
+
+                /*
+                 * XXXXX If a packet has timed out, then remove all the queued
+                 * packets for that session.
+                 */
+
+                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;
+                }
+                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.)
+                 */
+                {
+                u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
+                if (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;
+
+        /*
+         * Persistence timer into zero window.
+         * Force a byte to be output, if possible.
+         */
+        case TCPT_PERSIST:
+                tcpstat.tcps_persisttimeo++;
+                tcp_setpersist(tp);
+                tp->t_force = 1;
+                (void) tcp_output(pData, tp);
+                tp->t_force = 0;
+                break;
+
+        /*
+         * Keep-alive timer went off; send something
+         * or drop connection if idle for too long.
+         */
+        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++;
 #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,
-			    tp->rcv_nxt - 1, tp->snd_una - 1, 0);
+                        /*
+                         * 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;
-
-	dropit:
-		tcpstat.tcps_keepdrops++;
-		tp = tcp_drop(pData, tp, 0); /* ETIMEDOUT); */
-		break;
-	}
-
-	return (tp);
+                        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);
 }
Index: trunk/src/VBox/Devices/Network/slirp/tcp_timer.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_timer.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_timer.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_timer.h	8.1 (Berkeley) 6/10/93
+ *      @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
  * tcp_timer.h,v 1.4 1994/08/21 05:27:38 paul Exp
  */
@@ -42,10 +42,10 @@
  * down PR_SLOWHZ times a second.
  */
-#define	TCPT_NTIMERS	4
+#define TCPT_NTIMERS    4
 
-#define	TCPT_REXMT	0		/* retransmit */
-#define	TCPT_PERSIST	1		/* retransmit persistence */
-#define	TCPT_KEEP	2		/* keep alive */
-#define	TCPT_2MSL	3		/* 2*msl quiet time timer */
+#define TCPT_REXMT      0               /* retransmit */
+#define TCPT_PERSIST    1               /* retransmit persistence */
+#define TCPT_KEEP       2               /* keep alive */
+#define TCPT_2MSL       3               /* 2*msl quiet time timer */
 
 /*
@@ -78,5 +78,5 @@
  * (and keepalives have been enabled on the socket), we begin to probe
  * the connection.  We force the peer to send us a segment by sending:
- *	<SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
+ *      <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
  * This segment is (deliberately) outside the window, and should elicit
  * an ack segment in response from the peer.  If, despite the TCPT_KEEP
@@ -90,26 +90,26 @@
 #define TCPTV_MSL       ( 5*PR_SLOWHZ)          /* max seg lifetime (hah!) */
 
-#define	TCPTV_SRTTBASE	0			/* base roundtrip time;
-						   if 0, no idea yet */
-#define	TCPTV_SRTTDFLT	(  3*PR_SLOWHZ)		/* assumed RTT if no info */
+#define TCPTV_SRTTBASE  0                       /* base roundtrip time;
+                                                   if 0, no idea yet */
+#define TCPTV_SRTTDFLT  (  3*PR_SLOWHZ)         /* assumed RTT if no info */
 
-#define	TCPTV_PERSMIN	(  5*PR_SLOWHZ)		/* retransmit persistence */
-#define	TCPTV_PERSMAX	( 60*PR_SLOWHZ)		/* maximum persist interval */
+#define TCPTV_PERSMIN   (  5*PR_SLOWHZ)         /* retransmit persistence */
+#define TCPTV_PERSMAX   ( 60*PR_SLOWHZ)         /* maximum persist interval */
 
-#define	TCPTV_KEEP_INIT	( 75*PR_SLOWHZ)		/* initial connect keep alive */
-#define	TCPTV_KEEP_IDLE	(120*60*PR_SLOWHZ)	/* dflt time before probing */
-#define	TCPTV_KEEPINTVL	( 75*PR_SLOWHZ)		/* default probe interval */
-#define	TCPTV_KEEPCNT	8			/* max probes before drop */
+#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ)         /* initial connect keep alive */
+#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ)      /* dflt time before probing */
+#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ)         /* default probe interval */
+#define TCPTV_KEEPCNT   8                       /* max probes before drop */
 
-#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 */
+#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 */
 
-#define	TCP_LINGERTIME	120			/* linger at most 2 minutes */
+#define TCP_LINGERTIME  120                     /* linger at most 2 minutes */
 
 #define TCP_MAXRXTSHIFT 12                      /* maximum retransmits */
 
 
-#ifdef	TCPTIMERS
+#ifdef  TCPTIMERS
 char *tcptimers[] =
     { "REXMT", "PERSIST", "KEEP", "2MSL" };
@@ -119,10 +119,10 @@
  * Force a time value to be in a certain range.
  */
-#define	TCPT_RANGESET(tv, value, tvmin, tvmax) { \
-	(tv) = (value); \
-	if ((tv) < (tvmin)) \
-		(tv) = (tvmin); \
-	else if ((tv) > (tvmax)) \
-		(tv) = (tvmax); \
+#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
+        (tv) = (value); \
+        if ((tv) < (tvmin)) \
+                (tv) = (tvmin); \
+        else if ((tv) > (tvmax)) \
+                (tv) = (tvmax); \
 }
 
Index: trunk/src/VBox/Devices/Network/slirp/tcp_var.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_var.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_var.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)tcp_var.h	8.3 (Berkeley) 4/10/94
+ *      @(#)tcp_var.h   8.3 (Berkeley) 4/10/94
  * tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp
  */
@@ -70,8 +70,8 @@
 /* TCP segment queue entry */
 struct tseg_qent {
-	LIST_ENTRY(tseg_qent) tqe_q;
-	int	tqe_len;		/* TCP segment data length */
-	struct	tcphdr *tqe_th;		/* a pointer to tcp header */
-	struct	mbuf	*tqe_m;		/* mbuf contains packet */
+        LIST_ENTRY(tseg_qent) tqe_q;
+        int     tqe_len;                /* TCP segment data length */
+        struct  tcphdr *tqe_th;         /* a pointer to tcp header */
+        struct  mbuf    *tqe_m;         /* mbuf contains packet */
 };
 LIST_HEAD(tsegqe_head, tseg_qent);
@@ -83,35 +83,35 @@
 struct tcpcb {
 #ifndef VBOX_WITH_BSD_TCP_REASS
-	tcpiphdrp_32 seg_next;	/* sequencing queue */
-	tcpiphdrp_32 seg_prev;
+        tcpiphdrp_32 seg_next;  /* sequencing queue */
+        tcpiphdrp_32 seg_prev;
 #else  /* VBOX_WITH_BSD_TCP_REASS */
-	LIST_ENTRY(tcpcb) t_list;
-	struct	tsegqe_head t_segq;	/* segment reassembly queue */
-	int	t_segqlen;		/* segment reassembly queue length */
+        LIST_ENTRY(tcpcb) t_list;
+        struct  tsegqe_head t_segq;     /* segment reassembly queue */
+        int     t_segqlen;              /* segment reassembly queue length */
 #endif /* VBOX_WITH_BSD_TCP_REASS */
-	short	t_state;		/* state of this connection */
-	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
-	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
-	short	t_rxtcur;		/* current retransmit value */
-	short	t_dupacks;		/* consecutive dup acks recd */
-	u_short	t_maxseg;		/* maximum segment size */
-	char	t_force;		/* 1 if forcing out a byte */
-	u_short	t_flags;
-#define	TF_ACKNOW	0x0001		/* ack peer immediately */
-#define	TF_DELACK	0x0002		/* ack, but try to delay it */
-#define	TF_NODELAY	0x0004		/* don't delay packets to coalesce */
-#define	TF_NOOPT	0x0008		/* don't use tcp options */
-#define	TF_SENTFIN	0x0010		/* have sent FIN */
-#define	TF_REQ_SCALE	0x0020		/* have/will request window scaling */
-#define	TF_RCVD_SCALE	0x0040		/* other side has requested scaling */
-#define	TF_REQ_TSTMP	0x0080		/* have/will request timestamps */
-#define	TF_RCVD_TSTMP	0x0100		/* a timestamp was received in SYN */
-#define	TF_SACK_PERMIT	0x0200		/* other side said I could SACK */
-
-	/* Make it static  for now */
-/*	struct	tcpiphdr *t_template;	/ * skeletal packet for transmit */
-	struct	tcpiphdr t_template;
-
-	struct	socket *t_socket;		/* back pointer to socket */
+        short   t_state;                /* state of this connection */
+        short   t_timer[TCPT_NTIMERS];  /* tcp timers */
+        short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
+        short   t_rxtcur;               /* current retransmit value */
+        short   t_dupacks;              /* consecutive dup acks recd */
+        u_short t_maxseg;               /* maximum segment size */
+        char    t_force;                /* 1 if forcing out a byte */
+        u_short t_flags;
+#define TF_ACKNOW       0x0001          /* ack peer immediately */
+#define TF_DELACK       0x0002          /* ack, but try to delay it */
+#define TF_NODELAY      0x0004          /* don't delay packets to coalesce */
+#define TF_NOOPT        0x0008          /* don't use tcp options */
+#define TF_SENTFIN      0x0010          /* have sent FIN */
+#define TF_REQ_SCALE    0x0020          /* have/will request window scaling */
+#define TF_RCVD_SCALE   0x0040          /* other side has requested scaling */
+#define TF_REQ_TSTMP    0x0080          /* have/will request timestamps */
+#define TF_RCVD_TSTMP   0x0100          /* a timestamp was received in SYN */
+#define TF_SACK_PERMIT  0x0200          /* other side said I could SACK */
+
+        /* Make it static  for now */
+/*      struct  tcpiphdr *t_template;   / * skeletal packet for transmit */
+        struct  tcpiphdr t_template;
+
+        struct  socket *t_socket;               /* back pointer to socket */
 /*
  * The following fields are used as in the protocol specification.
@@ -119,58 +119,58 @@
  */
 /* send sequence variables */
-	tcp_seq	snd_una;		/* send unacknowledged */
-	tcp_seq	snd_nxt;		/* send next */
-	tcp_seq	snd_up;			/* send urgent pointer */
-	tcp_seq	snd_wl1;		/* window update seg seq number */
-	tcp_seq	snd_wl2;		/* window update seg ack number */
-	tcp_seq	iss;			/* initial send sequence number */
-	u_int32_t snd_wnd;		/* send window */
+        tcp_seq snd_una;                /* send unacknowledged */
+        tcp_seq snd_nxt;                /* send next */
+        tcp_seq snd_up;                 /* send urgent pointer */
+        tcp_seq snd_wl1;                /* window update seg seq number */
+        tcp_seq snd_wl2;                /* window update seg ack number */
+        tcp_seq iss;                    /* initial send sequence number */
+        u_int32_t snd_wnd;              /* send window */
 /* receive sequence variables */
-	u_int32_t rcv_wnd;		/* receive window */
-	tcp_seq	rcv_nxt;		/* receive next */
-	tcp_seq	rcv_up;			/* receive urgent pointer */
-	tcp_seq	irs;			/* initial receive sequence number */
+        u_int32_t rcv_wnd;              /* receive window */
+        tcp_seq rcv_nxt;                /* receive next */
+        tcp_seq rcv_up;                 /* receive urgent pointer */
+        tcp_seq irs;                    /* initial receive sequence number */
 /*
  * Additional variables for this implementation.
  */
 /* receive variables */
-	tcp_seq	rcv_adv;		/* advertised window */
+        tcp_seq rcv_adv;                /* advertised window */
 /* retransmit variables */
-	tcp_seq	snd_max;		/* highest sequence number sent;
-					 * used to recognize retransmits
-					 */
+        tcp_seq snd_max;                /* highest sequence number sent;
+                                         * used to recognize retransmits
+                                         */
 /* congestion control (for slow start, source quench, retransmit after loss) */
-	u_int32_t snd_cwnd;		/* congestion-controlled window */
-	u_int32_t snd_ssthresh;		/* snd_cwnd size threshold for
-					 * for slow start exponential to
-					 * linear switch
-					 */
+        u_int32_t snd_cwnd;             /* congestion-controlled window */
+        u_int32_t snd_ssthresh;         /* snd_cwnd size threshold for
+                                         * for slow start exponential to
+                                         * linear switch
+                                         */
 /*
  * transmit timing stuff.  See below for scale of srtt and rttvar.
  * "Variance" is actually smoothed difference.
  */
-	short	t_idle;			/* inactivity time */
-	short	t_rtt;			/* round trip time */
-	tcp_seq	t_rtseq;		/* sequence number being timed */
-	short	t_srtt;			/* smoothed round-trip time */
-	short	t_rttvar;		/* variance in round-trip time */
-	u_short	t_rttmin;		/* minimum rtt allowed */
-	u_int32_t max_sndwnd;		/* largest window peer has offered */
+        short   t_idle;                 /* inactivity time */
+        short   t_rtt;                  /* round trip time */
+        tcp_seq t_rtseq;                /* sequence number being timed */
+        short   t_srtt;                 /* smoothed round-trip time */
+        short   t_rttvar;               /* variance in round-trip time */
+        u_short t_rttmin;               /* minimum rtt allowed */
+        u_int32_t max_sndwnd;           /* largest window peer has offered */
 
 /* out-of-band data */
-	char	t_oobflags;		/* have some */
-	char	t_iobc;			/* input character */
-#define	TCPOOB_HAVEDATA	0x01
-#define	TCPOOB_HADDATA	0x02
-	short	t_softerror;		/* possible error not yet reported */
+        char    t_oobflags;             /* have some */
+        char    t_iobc;                 /* input character */
+#define TCPOOB_HAVEDATA 0x01
+#define TCPOOB_HADDATA  0x02
+        short   t_softerror;            /* possible error not yet reported */
 
 /* RFC 1323 variables */
-	u_char	snd_scale;		/* window scaling for send window */
-	u_char	rcv_scale;		/* window scaling for recv window */
-	u_char	request_r_scale;	/* pending window scaling */
-	u_char	requested_s_scale;
-	u_int32_t	ts_recent;		/* timestamp echo data */
-	u_int32_t	ts_recent_age;		/* when last updated */
-	tcp_seq	last_ack_sent;
+        u_char  snd_scale;              /* window scaling for send window */
+        u_char  rcv_scale;              /* window scaling for recv window */
+        u_char  request_r_scale;        /* pending window scaling */
+        u_char  requested_s_scale;
+        u_int32_t       ts_recent;              /* timestamp echo data */
+        u_int32_t       ts_recent_age;          /* when last updated */
+        tcp_seq last_ack_sent;
 
 };
@@ -180,5 +180,5 @@
 #endif /*VBOX_WITH_BSD_TCP_REASS*/
 
-#define	sototcpcb(so)	((so)->so_tcpcb)
+#define sototcpcb(so)   ((so)->so_tcpcb)
 
 /*
@@ -191,8 +191,8 @@
  * binary point, and is smoothed with an ALPHA of 0.75.
  */
-#define	TCP_RTT_SCALE		8	/* multiplier for srtt; 3 bits frac. */
-#define	TCP_RTT_SHIFT		3	/* shift for srtt; 3 bits frac. */
-#define	TCP_RTTVAR_SCALE	4	/* multiplier for rttvar; 2 bits */
-#define	TCP_RTTVAR_SHIFT	2	/* multiplier for rttvar; 2 bits */
+#define TCP_RTT_SCALE           8       /* multiplier for srtt; 3 bits frac. */
+#define TCP_RTT_SHIFT           3       /* shift for srtt; 3 bits frac. */
+#define TCP_RTTVAR_SCALE        4       /* multiplier for rttvar; 2 bits */
+#define TCP_RTTVAR_SHIFT        2       /* multiplier for rttvar; 2 bits */
 
 /*
@@ -209,6 +209,6 @@
  * is the same as the multiplier for rttvar.
  */
-#define	TCP_REXMTVAL(tp) \
-	(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
+#define TCP_REXMTVAL(tp) \
+        (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
 
 /* XXX
@@ -239,57 +239,57 @@
  */
 struct tcpstat_t {
-	u_long	tcps_connattempt;	/* connections initiated */
-	u_long	tcps_accepts;		/* connections accepted */
-	u_long	tcps_connects;		/* connections established */
-	u_long	tcps_drops;		/* connections dropped */
-	u_long	tcps_conndrops;		/* embryonic connections dropped */
-	u_long	tcps_closed;		/* conn. closed (includes drops) */
-	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
-	u_long	tcps_rttupdated;	/* times we succeeded */
-	u_long	tcps_delack;		/* delayed acks sent */
-	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
-	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
-	u_long	tcps_persisttimeo;	/* persist timeouts */
-	u_long	tcps_keeptimeo;		/* keepalive timeouts */
-	u_long	tcps_keepprobe;		/* keepalive probes sent */
-	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
-
-	u_long	tcps_sndtotal;		/* total packets sent */
-	u_long	tcps_sndpack;		/* data packets sent */
-	u_long	tcps_sndbyte;		/* data bytes sent */
-	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
-	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
-	u_long	tcps_sndacks;		/* ack-only packets sent */
-	u_long	tcps_sndprobe;		/* window probes sent */
-	u_long	tcps_sndurg;		/* packets sent with URG only */
-	u_long	tcps_sndwinup;		/* window update-only packets sent */
-	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
-
-	u_long	tcps_rcvtotal;		/* total packets received */
-	u_long	tcps_rcvpack;		/* packets received in sequence */
-	u_long	tcps_rcvbyte;		/* bytes received in sequence */
-	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
-	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
-/*	u_long	tcps_rcvshort;	*/	/* packets received too short */
-	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
-	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
-	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
-	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
-	u_long	tcps_rcvoopack;		/* out-of-order packets received */
-	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
-	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
-	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
-	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
-	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
-	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
-	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
-	u_long	tcps_rcvackpack;	/* rcvd ack packets */
-	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
-	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
-/*	u_long	tcps_pawsdrop;	*/	/* segments dropped due to PAWS */
-	u_long	tcps_predack;		/* times hdr predict ok for acks */
-	u_long	tcps_preddat;		/* times hdr predict ok for data pkts */
-	u_long	tcps_socachemiss;	/* tcp_last_so misses */
-	u_long	tcps_didnuttin;		/* Times tcp_output didn't do anything XXX */
+        u_long  tcps_connattempt;       /* connections initiated */
+        u_long  tcps_accepts;           /* connections accepted */
+        u_long  tcps_connects;          /* connections established */
+        u_long  tcps_drops;             /* connections dropped */
+        u_long  tcps_conndrops;         /* embryonic connections dropped */
+        u_long  tcps_closed;            /* conn. closed (includes drops) */
+        u_long  tcps_segstimed;         /* segs where we tried to get rtt */
+        u_long  tcps_rttupdated;        /* times we succeeded */
+        u_long  tcps_delack;            /* delayed acks sent */
+        u_long  tcps_timeoutdrop;       /* conn. dropped in rxmt timeout */
+        u_long  tcps_rexmttimeo;        /* retransmit timeouts */
+        u_long  tcps_persisttimeo;      /* persist timeouts */
+        u_long  tcps_keeptimeo;         /* keepalive timeouts */
+        u_long  tcps_keepprobe;         /* keepalive probes sent */
+        u_long  tcps_keepdrops;         /* connections dropped in keepalive */
+
+        u_long  tcps_sndtotal;          /* total packets sent */
+        u_long  tcps_sndpack;           /* data packets sent */
+        u_long  tcps_sndbyte;           /* data bytes sent */
+        u_long  tcps_sndrexmitpack;     /* data packets retransmitted */
+        u_long  tcps_sndrexmitbyte;     /* data bytes retransmitted */
+        u_long  tcps_sndacks;           /* ack-only packets sent */
+        u_long  tcps_sndprobe;          /* window probes sent */
+        u_long  tcps_sndurg;            /* packets sent with URG only */
+        u_long  tcps_sndwinup;          /* window update-only packets sent */
+        u_long  tcps_sndctrl;           /* control (SYN|FIN|RST) packets sent */
+
+        u_long  tcps_rcvtotal;          /* total packets received */
+        u_long  tcps_rcvpack;           /* packets received in sequence */
+        u_long  tcps_rcvbyte;           /* bytes received in sequence */
+        u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
+        u_long  tcps_rcvbadoff;         /* packets received with bad offset */
+/*      u_long  tcps_rcvshort;  */      /* packets received too short */
+        u_long  tcps_rcvduppack;        /* duplicate-only packets received */
+        u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
+        u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
+        u_long  tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
+        u_long  tcps_rcvoopack;         /* out-of-order packets received */
+        u_long  tcps_rcvoobyte;         /* out-of-order bytes received */
+        u_long  tcps_rcvpackafterwin;   /* packets with data after window */
+        u_long  tcps_rcvbyteafterwin;   /* bytes rcvd after window */
+        u_long  tcps_rcvafterclose;     /* packets rcvd after "close" */
+        u_long  tcps_rcvwinprobe;       /* rcvd window probe packets */
+        u_long  tcps_rcvdupack;         /* rcvd duplicate acks */
+        u_long  tcps_rcvacktoomuch;     /* rcvd acks for unsent data */
+        u_long  tcps_rcvackpack;        /* rcvd ack packets */
+        u_long  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
+        u_long  tcps_rcvwinupd;         /* rcvd window update packets */
+/*      u_long  tcps_pawsdrop;  */      /* segments dropped due to PAWS */
+        u_long  tcps_predack;           /* times hdr predict ok for acks */
+        u_long  tcps_preddat;           /* times hdr predict ok for data pkts */
+        u_long  tcps_socachemiss;       /* tcp_last_so misses */
+        u_long  tcps_didnuttin;         /* Times tcp_output didn't do anything XXX */
 #ifdef VBOX_WITH_BSD_TCP_REASS
         u_long tcps_rcvmemdrop;
Index: trunk/src/VBox/Devices/Network/slirp/tftp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 14470)
@@ -75,7 +75,7 @@
     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;
-	}
+        if (spt->client_port == tp->udp.uh_sport) {
+          return k;
+        }
       }
     }
@@ -86,5 +86,5 @@
 
 static int tftp_read_data(PNATState pData, struct tftp_session *spt, u_int16_t block_nr,
-			  u_int8_t *buf, int len)
+                          u_int8_t *buf, int len)
 {
   int fd;
@@ -94,5 +94,5 @@
 
   n = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
-	       tftp_prefix, spt->filename);
+               tftp_prefix, spt->filename);
   if (n >= sizeof(buffer))
     return -1;
@@ -128,5 +128,5 @@
 
     if (!m)
-	return -1;
+        return -1;
 
     memset(m->m_data, 0, m->m_size);
@@ -157,6 +157,6 @@
 static int tftp_send_error(PNATState pData,
                            struct tftp_session *spt,
-			   u_int16_t errorcode, const char *msg,
-			   struct tftp_t *recv_tp)
+                           u_int16_t errorcode, const char *msg,
+                           struct tftp_t *recv_tp)
 {
   struct sockaddr_in saddr, daddr;
@@ -201,6 +201,6 @@
 static int tftp_send_data(PNATState pData,
                           struct tftp_session *spt,
-			  u_int16_t block_nr,
-			  struct tftp_t *recv_tp)
+                          u_int16_t block_nr,
+                          struct tftp_t *recv_tp)
 {
   struct sockaddr_in saddr, daddr;
@@ -347,6 +347,6 @@
 
       if (k >= n) {
-	  tftp_send_error(pData, spt, 2, "Access violation", tp);
-	  return;
+          tftp_send_error(pData, spt, 2, "Access violation", tp);
+          return;
       }
 
@@ -355,23 +355,23 @@
 
       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);
+          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);
       }
   }
@@ -391,6 +391,6 @@
 
   if (tftp_send_data(pData, &tftp_sessions[s],
-		     ntohs(tp->x.tp_data.tp_block_nr) + 1,
-		     tp) < 0) {
+                     ntohs(tp->x.tp_data.tp_block_nr) + 1,
+                     tp) < 0) {
     return;
   }
Index: trunk/src/VBox/Devices/Network/slirp/tftp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tftp.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/tftp.h	(revision 14470)
@@ -3,5 +3,5 @@
 #define TFTP_SESSIONS_MAX 3
 
-#define TFTP_SERVER	69
+#define TFTP_SERVER     69
 
 #define TFTP_RRQ    1
Index: trunk/src/VBox/Devices/Network/slirp/udp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/udp.c	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/udp.c	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)udp_usrreq.c	8.4 (Berkeley) 1/21/94
+ *      @(#)udp_usrreq.c        8.4 (Berkeley) 1/21/94
  * udp_usrreq.c,v 1.4 1994/10/02 17:48:45 phk Exp
  */
@@ -57,5 +57,5 @@
 {
         udp_last_so = &udb;
-	udb.so_next = udb.so_prev = &udb;
+        udb.so_next = udb.so_prev = &udb;
 }
 
@@ -67,73 +67,73 @@
 udp_input(PNATState pData, register struct mbuf *m, int iphlen)
 {
-	register struct ip *ip;
-	register struct udphdr *uh;
-/*	struct mbuf *opts = 0;*/
-	int len;
-	struct ip save_ip;
-	struct socket *so;
-
-	DEBUG_CALL("udp_input");
-	DEBUG_ARG("m = %lx", (long)m);
-	DEBUG_ARG("iphlen = %d", iphlen);
-
-	udpstat.udps_ipackets++;
-
-	/*
-	 * Strip IP options, if any; should skip this,
-	 * make available to user, and use on returned packets,
-	 * but we don't yet have a way to check the checksum
-	 * with options still present.
-	 */
-	if(iphlen > sizeof(struct ip)) {
-		ip_stripoptions(m, (struct mbuf *)0);
-		iphlen = sizeof(struct ip);
-	}
-
-	/*
-	 * Get IP and UDP header together in first mbuf.
-	 */
-	ip = mtod(m, struct ip *);
-	uh = (struct udphdr *)((caddr_t)ip + iphlen);
-
-	/*
-	 * Make mbuf data length reflect UDP length.
-	 * If not enough data to reflect UDP length, drop.
-	 */
-	len = ntohs((u_int16_t)uh->uh_ulen);
-
-	if (ip->ip_len != len) {
-		if (len > ip->ip_len) {
-			udpstat.udps_badlen++;
-			goto bad;
-		}
-		m_adj(m, len - ip->ip_len);
-		ip->ip_len = len;
-	}
-
-	/*
-	 * Save a copy of the IP header in case we want restore it
-	 * for sending an ICMP error message in response.
-	 */
-	save_ip = *ip;
-	save_ip.ip_len+= iphlen;         /* tcp_input subtracts this */
-
-	/*
-	 * Checksum extended UDP header and data.
-	 */
-	if (udpcksum && uh->uh_sum) {
-	  ((struct ipovly *)ip)->ih_next = 0;
-	  ((struct ipovly *)ip)->ih_prev = 0;
-	  ((struct ipovly *)ip)->ih_x1 = 0;
-	  ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
-	  /* keep uh_sum for ICMP reply
-	   * uh->uh_sum = cksum(m, len + sizeof (struct ip));
-	   * if (uh->uh_sum) {
-	   */
-	  if(cksum(m, len + sizeof(struct ip))) {
-	    udpstat.udps_badsum++;
-	    goto bad;
-	  }
-	}
+        register struct ip *ip;
+        register struct udphdr *uh;
+/*      struct mbuf *opts = 0;*/
+        int len;
+        struct ip save_ip;
+        struct socket *so;
+
+        DEBUG_CALL("udp_input");
+        DEBUG_ARG("m = %lx", (long)m);
+        DEBUG_ARG("iphlen = %d", iphlen);
+
+        udpstat.udps_ipackets++;
+
+        /*
+         * Strip IP options, if any; should skip this,
+         * make available to user, and use on returned packets,
+         * but we don't yet have a way to check the checksum
+         * with options still present.
+         */
+        if(iphlen > sizeof(struct ip)) {
+                ip_stripoptions(m, (struct mbuf *)0);
+                iphlen = sizeof(struct ip);
+        }
+
+        /*
+         * Get IP and UDP header together in first mbuf.
+         */
+        ip = mtod(m, struct ip *);
+        uh = (struct udphdr *)((caddr_t)ip + iphlen);
+
+        /*
+         * Make mbuf data length reflect UDP length.
+         * If not enough data to reflect UDP length, drop.
+         */
+        len = ntohs((u_int16_t)uh->uh_ulen);
+
+        if (ip->ip_len != len) {
+                if (len > ip->ip_len) {
+                        udpstat.udps_badlen++;
+                        goto bad;
+                }
+                m_adj(m, len - ip->ip_len);
+                ip->ip_len = len;
+        }
+
+        /*
+         * Save a copy of the IP header in case we want restore it
+         * for sending an ICMP error message in response.
+         */
+        save_ip = *ip;
+        save_ip.ip_len+= iphlen;         /* tcp_input subtracts this */
+
+        /*
+         * Checksum extended UDP header and data.
+         */
+        if (udpcksum && uh->uh_sum) {
+          ((struct ipovly *)ip)->ih_next = 0;
+          ((struct ipovly *)ip)->ih_prev = 0;
+          ((struct ipovly *)ip)->ih_x1 = 0;
+          ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
+          /* keep uh_sum for ICMP reply
+           * uh->uh_sum = cksum(m, len + sizeof (struct ip));
+           * if (uh->uh_sum) {
+           */
+          if(cksum(m, len + sizeof(struct ip))) {
+            udpstat.udps_badsum++;
+            goto bad;
+          }
+        }
 
         /*
@@ -153,90 +153,90 @@
         }
 
-	/*
-	 * Locate pcb for datagram.
-	 */
-	so = udp_last_so;
-	if (so->so_lport != uh->uh_sport ||
-	    so->so_laddr.s_addr != ip->ip_src.s_addr) {
-		struct socket *tmp;
-
-		for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) {
-			if (tmp->so_lport == uh->uh_sport &&
-			    tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
-				so = tmp;
-				break;
-			}
-		}
-		if (tmp == &udb) {
-		  so = NULL;
-		} else {
-		  udpstat.udpps_pcbcachemiss++;
-		  udp_last_so = so;
-		}
-	}
-
-	if (so == NULL) {
-	  /*
-	   * If there's no socket for this packet,
-	   * create one
-	   */
-	  if ((so = socreate()) == NULL) goto bad;
-	  if(udp_attach(pData, so) == -1) {
-	    DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
-			errno,strerror(errno)));
+        /*
+         * Locate pcb for datagram.
+         */
+        so = udp_last_so;
+        if (so->so_lport != uh->uh_sport ||
+            so->so_laddr.s_addr != ip->ip_src.s_addr) {
+                struct socket *tmp;
+
+                for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) {
+                        if (tmp->so_lport == uh->uh_sport &&
+                            tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
+                                so = tmp;
+                                break;
+                        }
+                }
+                if (tmp == &udb) {
+                  so = NULL;
+                } else {
+                  udpstat.udpps_pcbcachemiss++;
+                  udp_last_so = so;
+                }
+        }
+
+        if (so == NULL) {
+          /*
+           * If there's no socket for this packet,
+           * create one
+           */
+          if ((so = socreate()) == NULL) goto bad;
+          if(udp_attach(pData, so) == -1) {
+            DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
+                        errno,strerror(errno)));
             sofree(pData, so);
-	    goto bad;
-	  }
-
-	  /*
-	   * Setup fields
-	   */
-	  /* udp_last_so = so; */
-	  so->so_laddr = ip->ip_src;
-	  so->so_lport = uh->uh_sport;
-
-	  if ((so->so_iptos = udp_tos(so)) == 0)
-	    so->so_iptos = ip->ip_tos;
-
-	  /*
-	   * XXXXX Here, check if it's in udpexec_list,
-	   * and if it is, do the fork_exec() etc.
-	   */
-	}
+            goto bad;
+          }
+
+          /*
+           * Setup fields
+           */
+          /* udp_last_so = so; */
+          so->so_laddr = ip->ip_src;
+          so->so_lport = uh->uh_sport;
+
+          if ((so->so_iptos = udp_tos(so)) == 0)
+            so->so_iptos = ip->ip_tos;
+
+          /*
+           * XXXXX Here, check if it's in udpexec_list,
+           * and if it is, do the fork_exec() etc.
+           */
+        }
 
         so->so_faddr = ip->ip_dst; /* XXX */
         so->so_fport = uh->uh_dport; /* XXX */
 
-	iphlen += sizeof(struct udphdr);
-	m->m_len -= iphlen;
-	m->m_data += iphlen;
-
-	/*
-	 * Now we sendto() the packet.
-	 */
-	if (so->so_emu)
-	   udp_emu(pData, so, m);
-
-	if(sosendto(pData, so,m) == -1) {
-	  m->m_len += iphlen;
-	  m->m_data -= iphlen;
-	  *ip=save_ip;
-	  DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
-	  icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
-	}
-
-	m_free(pData, so->so_m);   /* used for ICMP if error on sorecvfrom */
-
-	/* restore the orig mbuf packet */
-	m->m_len += iphlen;
-	m->m_data -= iphlen;
-	*ip=save_ip;
-	so->so_m=m;         /* ICMP backup */
-
-	return;
+        iphlen += sizeof(struct udphdr);
+        m->m_len -= iphlen;
+        m->m_data += iphlen;
+
+        /*
+         * Now we sendto() the packet.
+         */
+        if (so->so_emu)
+           udp_emu(pData, so, m);
+
+        if(sosendto(pData, so,m) == -1) {
+          m->m_len += iphlen;
+          m->m_data -= iphlen;
+          *ip=save_ip;
+          DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
+          icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
+        }
+
+        m_free(pData, so->so_m);   /* used for ICMP if error on sorecvfrom */
+
+        /* restore the orig mbuf packet */
+        m->m_len += iphlen;
+        m->m_data -= iphlen;
+        *ip=save_ip;
+        so->so_m=m;         /* ICMP backup */
+
+        return;
 bad:
-	m_freem(pData, m);
-	/* if (opts) m_freem(opts); */
-	return;
+        m_freem(pData, m);
+        /* if (opts) m_freem(opts); */
+        return;
 }
 
@@ -245,53 +245,53 @@
                 int iptos)
 {
-	register struct udpiphdr *ui;
-	int error = 0;
-
-	DEBUG_CALL("udp_output");
-	DEBUG_ARG("so = %lx", (long)so);
-	DEBUG_ARG("m = %lx", (long)m);
-	DEBUG_ARG("saddr = %lx", (long)saddr->sin_addr.s_addr);
-	DEBUG_ARG("daddr = %lx", (long)daddr->sin_addr.s_addr);
-
-	/*
-	 * Adjust for header
-	 */
-	m->m_data -= sizeof(struct udpiphdr);
-	m->m_len += sizeof(struct udpiphdr);
-
-	/*
-	 * Fill in mbuf with extended UDP header
-	 * and addresses and length put into network format.
-	 */
-	ui = mtod(m, struct udpiphdr *);
-	ui->ui_next = ui->ui_prev = 0;
-	ui->ui_x1 = 0;
-	ui->ui_pr = IPPROTO_UDP;
-	ui->ui_len = htons(m->m_len - sizeof(struct ip)); /* + sizeof (struct udphdr)); */
-	/* XXXXX Check for from-one-location sockets, or from-any-location sockets */
+        register struct udpiphdr *ui;
+        int error = 0;
+
+        DEBUG_CALL("udp_output");
+        DEBUG_ARG("so = %lx", (long)so);
+        DEBUG_ARG("m = %lx", (long)m);
+        DEBUG_ARG("saddr = %lx", (long)saddr->sin_addr.s_addr);
+        DEBUG_ARG("daddr = %lx", (long)daddr->sin_addr.s_addr);
+
+        /*
+         * Adjust for header
+         */
+        m->m_data -= sizeof(struct udpiphdr);
+        m->m_len += sizeof(struct udpiphdr);
+
+        /*
+         * Fill in mbuf with extended UDP header
+         * and addresses and length put into network format.
+         */
+        ui = mtod(m, struct udpiphdr *);
+        ui->ui_next = ui->ui_prev = 0;
+        ui->ui_x1 = 0;
+        ui->ui_pr = IPPROTO_UDP;
+        ui->ui_len = htons(m->m_len - sizeof(struct ip)); /* + sizeof (struct udphdr)); */
+        /* XXXXX Check for from-one-location sockets, or from-any-location sockets */
         ui->ui_src = saddr->sin_addr;
-	ui->ui_dst = daddr->sin_addr;
-	ui->ui_sport = saddr->sin_port;
-	ui->ui_dport = daddr->sin_port;
-	ui->ui_ulen = ui->ui_len;
-
-	/*
-	 * Stuff checksum and output datagram.
-	 */
-	ui->ui_sum = 0;
-	if (udpcksum) {
-	    if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
-		ui->ui_sum = 0xffff;
-	}
-	((struct ip *)ui)->ip_len = m->m_len;
-
-	((struct ip *)ui)->ip_ttl = ip_defttl;
-	((struct ip *)ui)->ip_tos = iptos;
-
-	udpstat.udps_opackets++;
-
-	error = ip_output(pData, so, m);
-
-	return (error);
+        ui->ui_dst = daddr->sin_addr;
+        ui->ui_sport = saddr->sin_port;
+        ui->ui_dport = daddr->sin_port;
+        ui->ui_ulen = ui->ui_len;
+
+        /*
+         * Stuff checksum and output datagram.
+         */
+        ui->ui_sum = 0;
+        if (udpcksum) {
+            if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
+                ui->ui_sum = 0xffff;
+        }
+        ((struct ip *)ui)->ip_len = m->m_len;
+
+        ((struct ip *)ui)->ip_ttl = ip_defttl;
+        ((struct ip *)ui)->ip_tos = iptos;
+
+        udpstat.udps_opackets++;
+
+        error = ip_output(pData, so, m);
+
+        return (error);
 }
 
@@ -357,36 +357,36 @@
 udp_detach(PNATState pData, struct socket *so)
 {
-	/* Correctly update list if detaching last socket in list. */
-	if (so == udp_last_so) udp_last_so = &udb;
-	closesocket(so->s);
-	/* if (so->so_m) m_free(so->so_m);    done by sofree */
-
-	sofree(pData, so);
+        /* Correctly update list if detaching last socket in list. */
+        if (so == udp_last_so) udp_last_so = &udb;
+        closesocket(so->s);
+        /* if (so->so_m) m_free(so->so_m);    done by sofree */
+
+        sofree(pData, so);
 }
 
 static const struct tos_t udptos[] = {
-	{0, 53, IPTOS_LOWDELAY, 0},			/* DNS */
-	{517, 517, IPTOS_LOWDELAY, EMU_TALK},	/* talk */
-	{518, 518, IPTOS_LOWDELAY, EMU_NTALK},	/* ntalk */
-	{0, 7648, IPTOS_LOWDELAY, EMU_CUSEEME},	/* Cu-Seeme */
-	{0, 0, 0, 0}
+        {0, 53, IPTOS_LOWDELAY, 0},                     /* DNS */
+        {517, 517, IPTOS_LOWDELAY, EMU_TALK},   /* talk */
+        {518, 518, IPTOS_LOWDELAY, EMU_NTALK},  /* ntalk */
+        {0, 7648, IPTOS_LOWDELAY, EMU_CUSEEME}, /* Cu-Seeme */
+        {0, 0, 0, 0}
 };
 
 u_int8_t
 udp_tos(so)
-	struct socket *so;
-{
-	int i = 0;
-
-	while(udptos[i].tos) {
-		if ((udptos[i].fport && ntohs(so->so_fport) == udptos[i].fport) ||
-		    (udptos[i].lport && ntohs(so->so_lport) == udptos[i].lport)) {
-		    	so->so_emu = udptos[i].emu;
-			return udptos[i].tos;
-		}
-		i++;
-	}
-
-	return 0;
+        struct socket *so;
+{
+        int i = 0;
+
+        while(udptos[i].tos) {
+                if ((udptos[i].fport && ntohs(so->so_fport) == udptos[i].fport) ||
+                    (udptos[i].lport && ntohs(so->so_lport) == udptos[i].lport)) {
+                        so->so_emu = udptos[i].emu;
+                        return udptos[i].tos;
+                }
+                i++;
+        }
+
+        return 0;
 }
 
@@ -401,59 +401,59 @@
 udp_emu(PNATState pData, struct socket *so, struct mbuf *m)
 {
-	struct sockaddr_in addr;
+        struct sockaddr_in addr;
         socklen_t addrlen = sizeof(addr);
 #ifdef EMULATE_TALK
-	CTL_MSG_OLD *omsg;
-	CTL_MSG *nmsg;
-	char buff[sizeof(CTL_MSG)];
-	u_char type;
+        CTL_MSG_OLD *omsg;
+        CTL_MSG *nmsg;
+        char buff[sizeof(CTL_MSG)];
+        u_char type;
 
 struct talk_request {
-	struct talk_request *next;
-	struct socket *udp_so;
-	struct socket *tcp_so;
+        struct talk_request *next;
+        struct socket *udp_so;
+        struct socket *tcp_so;
 } *req;
 
-	static struct talk_request *req_tbl = 0;
+        static struct talk_request *req_tbl = 0;
 
 #endif
 
 struct cu_header {
-	uint16_t	d_family;		/* destination family */
-	uint16_t	d_port;			/* destination port */
-	uint32_t	d_addr;			/* destination address */
-	uint16_t	s_family;		/* source family */
-	uint16_t	s_port;			/* source port */
-	uint32_t	so_addr;		/* source address */
-	uint32_t	seqn;			/* sequence number */
-	uint16_t	message;		/* message */
-	uint16_t	data_type;		/* data type */
-	uint16_t	pkt_len;		/* packet length */
+        uint16_t        d_family;               /* destination family */
+        uint16_t        d_port;                 /* destination port */
+        uint32_t        d_addr;                 /* destination address */
+        uint16_t        s_family;               /* source family */
+        uint16_t        s_port;                 /* source port */
+        uint32_t        so_addr;                /* source address */
+        uint32_t        seqn;                   /* sequence number */
+        uint16_t        message;                /* message */
+        uint16_t        data_type;              /* data type */
+        uint16_t        pkt_len;                /* packet length */
 } *cu_head;
 
-	switch(so->so_emu) {
+        switch(so->so_emu) {
 
 #ifdef EMULATE_TALK
-	 case EMU_TALK:
-	 case EMU_NTALK:
-		/*
-		 * Talk emulation. We always change the ctl_addr to get
-		 * some answers from the daemon. When an ANNOUNCE comes,
-		 * we send LEAVE_INVITE to the local daemons. Also when a
-		 * DELETE comes, we send copies to the local daemons.
-		 */
-		if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
-			return;
-
-#define	IS_OLD	(so->so_emu == EMU_TALK)
+         case EMU_TALK:
+         case EMU_NTALK:
+                /*
+                 * Talk emulation. We always change the ctl_addr to get
+                 * some answers from the daemon. When an ANNOUNCE comes,
+                 * we send LEAVE_INVITE to the local daemons. Also when a
+                 * DELETE comes, we send copies to the local daemons.
+                 */
+                if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
+                        return;
+
+#define IS_OLD  (so->so_emu == EMU_TALK)
 
 #define COPY_MSG(dest, src) { dest->type = src->type; \
-			      dest->id_num = src->id_num; \
-			      dest->pid = src->pid; \
-			      dest->addr = src->addr; \
-			      dest->ctl_addr = src->ctl_addr; \
-			      memcpy(&dest->l_name, &src->l_name, NAME_SIZE_OLD); \
-			      memcpy(&dest->r_name, &src->r_name, NAME_SIZE_OLD); \
-	         	      memcpy(&dest->r_tty, &src->r_tty, TTY_SIZE); }
+                              dest->id_num = src->id_num; \
+                              dest->pid = src->pid; \
+                              dest->addr = src->addr; \
+                              dest->ctl_addr = src->ctl_addr; \
+                              memcpy(&dest->l_name, &src->l_name, NAME_SIZE_OLD); \
+                              memcpy(&dest->r_name, &src->r_name, NAME_SIZE_OLD); \
+                              memcpy(&dest->r_tty, &src->r_tty, TTY_SIZE); }
 
 #define OTOSIN(ptr, field) ((struct sockaddr_in *)&ptr->field)
@@ -461,165 +461,165 @@
 
 
-		if (IS_OLD) {  		/* old talk */
-			omsg = mtod(m, CTL_MSG_OLD*);
-			nmsg = (CTL_MSG *) buff;
-			type = omsg->type;
-			OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
-			OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
-			strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD);
-		} else {		/* new talk */
-			omsg = (CTL_MSG_OLD *) buff;
-			nmsg = mtod(m, CTL_MSG *);
-			type = nmsg->type;
-			OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
-			OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
-			strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
-		}
-
-		if (type == LOOK_UP)
-			return;		/* for LOOK_UP this is enough */
-
-		if (IS_OLD) {		/* make a copy of the message */
-			COPY_MSG(nmsg, omsg);
-			nmsg->vers = 1;
-			nmsg->answer = 0;
-		} else
-			COPY_MSG(omsg, nmsg);
-
-		/*
-		 * If if is an ANNOUNCE message, we go through the
-		 * request table to see if a tcp port has already
-		 * been redirected for this socket. If not, we solisten()
-		 * a new socket and add this entry to the table.
-		 * The port number of the tcp socket and our IP
-		 * are put to the addr field of the message structures.
-		 * Then a LEAVE_INVITE is sent to both local daemon
-		 * ports, 517 and 518. This is why we have two copies
-		 * of the message, one in old talk and one in new talk
-		 * format.
-		 */
-
-		if (type == ANNOUNCE) {
-			int s;
-			u_short temp_port;
-
-			for(req = req_tbl; req; req = req->next)
-				if (so == req->udp_so)
-					break;  	/* found it */
-
-			if (!req) {	/* no entry for so, create new */
-				req = (struct talk_request *)
-					malloc(sizeof(struct talk_request));
-				req->udp_so = so;
-				req->tcp_so = solisten(0,
-					OTOSIN(omsg, addr)->sin_addr.s_addr,
-					OTOSIN(omsg, addr)->sin_port,
-					SS_FACCEPTONCE);
-				req->next = req_tbl;
-				req_tbl = req;
-			}
-
-			/* replace port number in addr field */
-			addrlen = sizeof(addr);
-			getsockname(req->tcp_so->s,
-					(struct sockaddr *) &addr,
-					&addrlen);
-			OTOSIN(omsg, addr)->sin_port = addr.sin_port;
-			OTOSIN(omsg, addr)->sin_addr = our_addr;
-			OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
-			OTOSIN(nmsg, addr)->sin_addr = our_addr;
-
-			/* send LEAVE_INVITEs */
-			temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
-			OTOSIN(omsg, ctl_addr)->sin_port = 0;
-			OTOSIN(nmsg, ctl_addr)->sin_port = 0;
-			omsg->type = nmsg->type = LEAVE_INVITE;
-
-			s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
-			addr.sin_addr = our_addr;
-			addr.sin_family = AF_INET;
-			addr.sin_port = htons(517);
-			sendto(s, (char *)omsg, sizeof(*omsg), 0,
-				(struct sockaddr *)&addr, sizeof(addr));
-			addr.sin_port = htons(518);
-			sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
-				(struct sockaddr *) &addr, sizeof(addr));
-			closesocket(s) ;
-
-			omsg->type = nmsg->type = ANNOUNCE;
-			OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
-			OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
-		}
-
-		/*
-		 * If it is a DELETE message, we send a copy to the
-		 * local daemons. Then we delete the entry corresponding
-		 * to our socket from the request table.
-		 */
-
-		if (type == DELETE) {
-			struct talk_request *temp_req, *req_next;
-			int s;
-			u_short temp_port;
-
-			temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
-			OTOSIN(omsg, ctl_addr)->sin_port = 0;
-			OTOSIN(nmsg, ctl_addr)->sin_port = 0;
-
-			s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
-			addr.sin_addr = our_addr;
-			addr.sin_family = AF_INET;
-			addr.sin_port = htons(517);
-			sendto(s, (char *)omsg, sizeof(*omsg), 0,
-				(struct sockaddr *)&addr, sizeof(addr));
-			addr.sin_port = htons(518);
-			sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
-				(struct sockaddr *)&addr, sizeof(addr));
-			closesocket(s);
-
-			OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
-			OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
-
-			/* delete table entry */
-			if (so == req_tbl->udp_so) {
-				temp_req = req_tbl;
-				req_tbl = req_tbl->next;
-				free(temp_req);
-			} else {
-				temp_req = req_tbl;
-				for(req = req_tbl->next; req; req = req_next) {
-					req_next = req->next;
-					if (so == req->udp_so) {
-						temp_req->next = req_next;
-						free(req);
-						break;
-					} else {
-						temp_req = req;
-					}
-				}
-			}
-		}
-
-		return;
+                if (IS_OLD) {           /* old talk */
+                        omsg = mtod(m, CTL_MSG_OLD*);
+                        nmsg = (CTL_MSG *) buff;
+                        type = omsg->type;
+                        OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
+                        OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
+                        strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD);
+                } else {                /* new talk */
+                        omsg = (CTL_MSG_OLD *) buff;
+                        nmsg = mtod(m, CTL_MSG *);
+                        type = nmsg->type;
+                        OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
+                        OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
+                        strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
+                }
+
+                if (type == LOOK_UP)
+                        return;         /* for LOOK_UP this is enough */
+
+                if (IS_OLD) {           /* make a copy of the message */
+                        COPY_MSG(nmsg, omsg);
+                        nmsg->vers = 1;
+                        nmsg->answer = 0;
+                } else
+                        COPY_MSG(omsg, nmsg);
+
+                /*
+                 * If if is an ANNOUNCE message, we go through the
+                 * request table to see if a tcp port has already
+                 * been redirected for this socket. If not, we solisten()
+                 * a new socket and add this entry to the table.
+                 * The port number of the tcp socket and our IP
+                 * are put to the addr field of the message structures.
+                 * Then a LEAVE_INVITE is sent to both local daemon
+                 * ports, 517 and 518. This is why we have two copies
+                 * of the message, one in old talk and one in new talk
+                 * format.
+                 */
+
+                if (type == ANNOUNCE) {
+                        int s;
+                        u_short temp_port;
+
+                        for(req = req_tbl; req; req = req->next)
+                                if (so == req->udp_so)
+                                        break;          /* found it */
+
+                        if (!req) {     /* no entry for so, create new */
+                                req = (struct talk_request *)
+                                        malloc(sizeof(struct talk_request));
+                                req->udp_so = so;
+                                req->tcp_so = solisten(0,
+                                        OTOSIN(omsg, addr)->sin_addr.s_addr,
+                                        OTOSIN(omsg, addr)->sin_port,
+                                        SS_FACCEPTONCE);
+                                req->next = req_tbl;
+                                req_tbl = req;
+                        }
+
+                        /* replace port number in addr field */
+                        addrlen = sizeof(addr);
+                        getsockname(req->tcp_so->s,
+                                        (struct sockaddr *) &addr,
+                                        &addrlen);
+                        OTOSIN(omsg, addr)->sin_port = addr.sin_port;
+                        OTOSIN(omsg, addr)->sin_addr = our_addr;
+                        OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
+                        OTOSIN(nmsg, addr)->sin_addr = our_addr;
+
+                        /* send LEAVE_INVITEs */
+                        temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
+                        OTOSIN(omsg, ctl_addr)->sin_port = 0;
+                        OTOSIN(nmsg, ctl_addr)->sin_port = 0;
+                        omsg->type = nmsg->type = LEAVE_INVITE;
+
+                        s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+                        addr.sin_addr = our_addr;
+                        addr.sin_family = AF_INET;
+                        addr.sin_port = htons(517);
+                        sendto(s, (char *)omsg, sizeof(*omsg), 0,
+                                (struct sockaddr *)&addr, sizeof(addr));
+                        addr.sin_port = htons(518);
+                        sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
+                                (struct sockaddr *) &addr, sizeof(addr));
+                        closesocket(s) ;
+
+                        omsg->type = nmsg->type = ANNOUNCE;
+                        OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
+                        OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
+                }
+
+                /*
+                 * If it is a DELETE message, we send a copy to the
+                 * local daemons. Then we delete the entry corresponding
+                 * to our socket from the request table.
+                 */
+
+                if (type == DELETE) {
+                        struct talk_request *temp_req, *req_next;
+                        int s;
+                        u_short temp_port;
+
+                        temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
+                        OTOSIN(omsg, ctl_addr)->sin_port = 0;
+                        OTOSIN(nmsg, ctl_addr)->sin_port = 0;
+
+                        s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+                        addr.sin_addr = our_addr;
+                        addr.sin_family = AF_INET;
+                        addr.sin_port = htons(517);
+                        sendto(s, (char *)omsg, sizeof(*omsg), 0,
+                                (struct sockaddr *)&addr, sizeof(addr));
+                        addr.sin_port = htons(518);
+                        sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
+                                (struct sockaddr *)&addr, sizeof(addr));
+                        closesocket(s);
+
+                        OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
+                        OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
+
+                        /* delete table entry */
+                        if (so == req_tbl->udp_so) {
+                                temp_req = req_tbl;
+                                req_tbl = req_tbl->next;
+                                free(temp_req);
+                        } else {
+                                temp_req = req_tbl;
+                                for(req = req_tbl->next; req; req = req_next) {
+                                        req_next = req->next;
+                                        if (so == req->udp_so) {
+                                                temp_req->next = req_next;
+                                                free(req);
+                                                break;
+                                        } else {
+                                                temp_req = req;
+                                        }
+                                }
+                        }
+                }
+
+                return;
 #endif
 
-	case EMU_CUSEEME:
-
-		/*
-		 * Cu-SeeMe emulation.
-		 * Hopefully the packet is more that 16 bytes long. We don't
-		 * do any other tests, just replace the address and port
-		 * fields.
-		 */
-		if (m->m_len >= sizeof (*cu_head)) {
-			if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
-				return;
-			cu_head = mtod(m, struct cu_header *);
-			cu_head->s_port = addr.sin_port;
-			cu_head->so_addr = our_addr.s_addr;
-		}
-
-		return;
-	}
+        case EMU_CUSEEME:
+
+                /*
+                 * Cu-SeeMe emulation.
+                 * Hopefully the packet is more that 16 bytes long. We don't
+                 * do any other tests, just replace the address and port
+                 * fields.
+                 */
+                if (m->m_len >= sizeof (*cu_head)) {
+                        if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
+                                return;
+                        cu_head = mtod(m, struct cu_header *);
+                        cu_head->s_port = addr.sin_port;
+                        cu_head->so_addr = our_addr.s_addr;
+                }
+
+                return;
+        }
 }
 
@@ -627,45 +627,45 @@
 udp_listen(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(struct sockaddr_in);
+        struct sockaddr_in addr;
+        struct socket *so;
+        socklen_t addrlen = sizeof(struct sockaddr_in);
         int opt = 1;
 
-	if ((so = socreate()) == NULL) {
-		free(so);
-		return NULL;
-	}
-	so->s = socket(AF_INET,SOCK_DGRAM,0);
-	so->so_expire = curtime + SO_EXPIRE;
-	insque(pData, so,&udb);
-
-	addr.sin_family = AF_INET;
-	addr.sin_addr.s_addr = INADDR_ANY;
-	addr.sin_port = port;
-
-	if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {
-		udp_detach(pData, so);
-		return NULL;
-	}
-	setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
-/*	setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); */
-
-	getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
-	so->so_fport = addr.sin_port;
+        if ((so = socreate()) == NULL) {
+                free(so);
+                return NULL;
+        }
+        so->s = socket(AF_INET,SOCK_DGRAM,0);
+        so->so_expire = curtime + SO_EXPIRE;
+        insque(pData, so,&udb);
+
+        addr.sin_family = AF_INET;
+        addr.sin_addr.s_addr = INADDR_ANY;
+        addr.sin_port = port;
+
+        if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {
+                udp_detach(pData, so);
+                return NULL;
+        }
+        setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
+/*      setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); */
+
+        getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
+        so->so_fport = addr.sin_port;
         /* The original check was completely broken, as the commented out
          * if statement was always true (INADDR_ANY=0). */
-	/* if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr) */
+        /* if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr) */
         if (1 == 0)                 /* always use the else part */
-	   so->so_faddr = alias_addr;
-	else
-	   so->so_faddr = addr.sin_addr;
-
-	so->so_lport = lport;
-	so->so_laddr.s_addr = laddr;
-	if (flags != SS_FACCEPTONCE)
-	   so->so_expire = 0;
-
-	so->so_state = SS_ISFCONNECTED;
-
-	return so;
-}
+           so->so_faddr = alias_addr;
+        else
+           so->so_faddr = addr.sin_addr;
+
+        so->so_lport = lport;
+        so->so_laddr.s_addr = laddr;
+        if (flags != SS_FACCEPTONCE)
+           so->so_expire = 0;
+
+        so->so_state = SS_ISFCONNECTED;
+
+        return so;
+}
Index: trunk/src/VBox/Devices/Network/slirp/udp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/udp.h	(revision 14466)
+++ trunk/src/VBox/Devices/Network/slirp/udp.h	(revision 14470)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,6 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -31,5 +31,5 @@
  * SUCH DAMAGE.
  *
- *	@(#)udp.h	8.1 (Berkeley) 6/10/93
+ *      @(#)udp.h       8.1 (Berkeley) 6/10/93
  * udp.h,v 1.3 1994/08/21 05:27:41 paul Exp
  */
@@ -48,8 +48,8 @@
  */
 struct udphdr {
-	u_int16_t	uh_sport;		/* source port */
-	u_int16_t	uh_dport;		/* destination port */
-	int16_t	uh_ulen;		/* udp length */
-	u_int16_t	uh_sum;			/* udp checksum */
+        u_int16_t       uh_sport;               /* source port */
+        u_int16_t       uh_dport;               /* destination port */
+        int16_t uh_ulen;                /* udp length */
+        u_int16_t       uh_sum;                 /* udp checksum */
 };
 
@@ -58,6 +58,6 @@
  */
 struct udpiphdr {
-	        struct  ipovly ui_i;            /* overlaid ip structure */
-	        struct  udphdr ui_u;            /* udp header */
+                struct  ipovly ui_i;            /* overlaid ip structure */
+                struct  udphdr ui_u;            /* udp header */
 };
 #define ui_next         ui_i.ih_next
@@ -74,15 +74,15 @@
 
 struct udpstat_t {
-	                                /* input statistics: */
-	        u_long  udps_ipackets;          /* total input packets */
-	        u_long  udps_hdrops;            /* packet shorter than header */
-	        u_long  udps_badsum;            /* checksum error */
-	        u_long  udps_badlen;            /* data length larger than packet */
-	        u_long  udps_noport;            /* no socket on port */
-	        u_long  udps_noportbcast;       /* of above, arrived as broadcast */
-	        u_long  udps_fullsock;          /* not delivered, input socket full */
-	        u_long  udpps_pcbcachemiss;     /* input packets missing pcb cache */
-	                                /* output statistics: */
-	        u_long  udps_opackets;          /* total output packets */
+                                        /* input statistics: */
+                u_long  udps_ipackets;          /* total input packets */
+                u_long  udps_hdrops;            /* packet shorter than header */
+                u_long  udps_badsum;            /* checksum error */
+                u_long  udps_badlen;            /* data length larger than packet */
+                u_long  udps_noport;            /* no socket on port */
+                u_long  udps_noportbcast;       /* of above, arrived as broadcast */
+                u_long  udps_fullsock;          /* not delivered, input socket full */
+                u_long  udpps_pcbcachemiss;     /* input packets missing pcb cache */
+                                        /* output statistics: */
+                u_long  udps_opackets;          /* total output packets */
 };
 
