diff --git a/src/arch/unix/netif/tapif.c b/src/arch/unix/netif/tapif.c index 00062af5..525f39dd 100644 --- a/src/arch/unix/netif/tapif.c +++ b/src/arch/unix/netif/tapif.c @@ -149,7 +149,12 @@ low_level_output(struct netif *netif, struct pbuf *p) 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 @@ low_level_input(struct tapif *tapif) /* 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 9d412eac..ff67cdaf 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -307,6 +307,7 @@ tcp_listen(struct tcp_pcb *pcb) } 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 @@ tcp_slowtmr(void) 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 ea1a265b..b47e6f18 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -202,6 +202,7 @@ struct tcp_pcb { 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 @@ struct tcp_pcb { 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 @@ struct tcp_pcb_listen { 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. */