put a state field in listen PCBs to since they are often treated as normal pcbs. patch #922, bug #2114
diff --git a/src/arch/unix/netif/tapif.c b/src/arch/unix/netif/tapif.c
index 00062af..525f39d 100644
--- a/src/arch/unix/netif/tapif.c
+++ b/src/arch/unix/netif/tapif.c
@@ -149,7 +149,12 @@
   struct tapif *tapif;
 
   tapif = netif->state;
-  
+#if 0  
+    if(((double)rand()/(double)RAND_MAX) < 0.2) {
+    printf("drop output\n");
+    return ERR_OK;
+    }
+#endif 
   /* initiate transfer(); */
   
   bufptr = &buf[0];
@@ -189,12 +194,12 @@
   /* Obtain the size of the packet and put it into the "len"
      variable. */
   len = read(tapif->fd, buf, sizeof(buf));
-
-  /*  if(((double)rand()/(double)RAND_MAX) < 0.1) {
+#if 0
+    if(((double)rand()/(double)RAND_MAX) < 0.2) {
     printf("drop\n");
     return NULL;
-    }*/
-
+    }
+#endif
   
   /* We allocate a pbuf chain of pbufs from the pool. */
   p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
diff --git a/src/core/tcp.c b/src/core/tcp.c
index 9d412ea..ff67cda 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -307,6 +307,7 @@
   }
   lpcb->callback_arg = pcb->callback_arg;
   lpcb->local_port = pcb->local_port;
+  lpcb->state = LISTEN;
   ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
   memp_free(MEMP_TCP_PCB, pcb);
 #if LWIP_CALLBACK_API
@@ -475,7 +476,7 @@
       if(pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
 
 	/* Time for a retransmission. */
-        DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %ld pcb->rto %d\n",
+        DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %d pcb->rto %d\n",
                                pcb->rtime, pcb->rto));
 
 	/* Double retransmission time-out unless we are trying to
diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
index ea1a265..b47e6f1 100644
--- a/src/include/lwip/tcp.h
+++ b/src/include/lwip/tcp.h
@@ -202,6 +202,7 @@
 
   struct ip_addr local_ip;
   u16_t local_port;
+  enum tcp_state state;   /* TCP state */
   
   struct ip_addr remote_ip;
   u16_t remote_port;
@@ -210,7 +211,6 @@
   u32_t rcv_nxt;   /* next seqno expected */
   u16_t rcv_wnd;   /* receiver window */
 
-  enum tcp_state state;   /* TCP state */
   
   /* Timers */
   u32_t tmr;
@@ -293,7 +293,12 @@
   void *callback_arg;
   
   struct ip_addr local_ip;
-  u16_t local_port;  
+  u16_t local_port; 
+  /* Even if state is obviously LISTEN this is here for
+   * field compatibility with tpc_pcb to which it is cast sometimes
+   * Until a cleaner solution emerges this is here.FIXME
+   */ 
+  enum tcp_state state;   /* TCP state */
 
 #if LWIP_CALLBACK_API
   /* Function to call when a listener has been connected. */