mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
put a state field in listen PCBs to since they are often treated as normal pcbs. patch #922, bug #2114
This commit is contained in:
parent
07af438a38
commit
42309b5d6f
@ -149,7 +149,12 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
|||||||
struct tapif *tapif;
|
struct tapif *tapif;
|
||||||
|
|
||||||
tapif = netif->state;
|
tapif = netif->state;
|
||||||
|
#if 0
|
||||||
|
if(((double)rand()/(double)RAND_MAX) < 0.2) {
|
||||||
|
printf("drop output\n");
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* initiate transfer(); */
|
/* initiate transfer(); */
|
||||||
|
|
||||||
bufptr = &buf[0];
|
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"
|
/* Obtain the size of the packet and put it into the "len"
|
||||||
variable. */
|
variable. */
|
||||||
len = read(tapif->fd, buf, sizeof(buf));
|
len = read(tapif->fd, buf, sizeof(buf));
|
||||||
|
#if 0
|
||||||
/* if(((double)rand()/(double)RAND_MAX) < 0.1) {
|
if(((double)rand()/(double)RAND_MAX) < 0.2) {
|
||||||
printf("drop\n");
|
printf("drop\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}*/
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
|
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
|
||||||
|
@ -307,6 +307,7 @@ tcp_listen(struct tcp_pcb *pcb)
|
|||||||
}
|
}
|
||||||
lpcb->callback_arg = pcb->callback_arg;
|
lpcb->callback_arg = pcb->callback_arg;
|
||||||
lpcb->local_port = pcb->local_port;
|
lpcb->local_port = pcb->local_port;
|
||||||
|
lpcb->state = LISTEN;
|
||||||
ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
|
ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
|
||||||
memp_free(MEMP_TCP_PCB, pcb);
|
memp_free(MEMP_TCP_PCB, pcb);
|
||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
@ -475,7 +476,7 @@ tcp_slowtmr(void)
|
|||||||
if(pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
|
if(pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
|
||||||
|
|
||||||
/* Time for a retransmission. */
|
/* 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));
|
pcb->rtime, pcb->rto));
|
||||||
|
|
||||||
/* Double retransmission time-out unless we are trying to
|
/* Double retransmission time-out unless we are trying to
|
||||||
|
@ -202,6 +202,7 @@ struct tcp_pcb {
|
|||||||
|
|
||||||
struct ip_addr local_ip;
|
struct ip_addr local_ip;
|
||||||
u16_t local_port;
|
u16_t local_port;
|
||||||
|
enum tcp_state state; /* TCP state */
|
||||||
|
|
||||||
struct ip_addr remote_ip;
|
struct ip_addr remote_ip;
|
||||||
u16_t remote_port;
|
u16_t remote_port;
|
||||||
@ -210,7 +211,6 @@ struct tcp_pcb {
|
|||||||
u32_t rcv_nxt; /* next seqno expected */
|
u32_t rcv_nxt; /* next seqno expected */
|
||||||
u16_t rcv_wnd; /* receiver window */
|
u16_t rcv_wnd; /* receiver window */
|
||||||
|
|
||||||
enum tcp_state state; /* TCP state */
|
|
||||||
|
|
||||||
/* Timers */
|
/* Timers */
|
||||||
u32_t tmr;
|
u32_t tmr;
|
||||||
@ -293,7 +293,12 @@ struct tcp_pcb_listen {
|
|||||||
void *callback_arg;
|
void *callback_arg;
|
||||||
|
|
||||||
struct ip_addr local_ip;
|
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
|
#if LWIP_CALLBACK_API
|
||||||
/* Function to call when a listener has been connected. */
|
/* Function to call when a listener has been connected. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user