mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Misc changes
This commit is contained in:
parent
b96c08f35c
commit
0405ba1ccf
Binary file not shown.
@ -10,9 +10,9 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -21,21 +21,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
@ -72,17 +72,17 @@
|
||||
#endif /* LWIP_TCP_KEEPALIVE */
|
||||
|
||||
const char * const tcp_state_str[] = {
|
||||
"CLOSED",
|
||||
"LISTEN",
|
||||
"SYN_SENT",
|
||||
"SYN_RCVD",
|
||||
"ESTABLISHED",
|
||||
"FIN_WAIT_1",
|
||||
"FIN_WAIT_2",
|
||||
"CLOSE_WAIT",
|
||||
"CLOSING",
|
||||
"LAST_ACK",
|
||||
"TIME_WAIT"
|
||||
"CLOSED",
|
||||
"LISTEN",
|
||||
"SYN_SENT",
|
||||
"SYN_RCVD",
|
||||
"ESTABLISHED",
|
||||
"FIN_WAIT_1",
|
||||
"FIN_WAIT_2",
|
||||
"CLOSE_WAIT",
|
||||
"CLOSING",
|
||||
"LAST_ACK",
|
||||
"TIME_WAIT"
|
||||
};
|
||||
|
||||
/* last local TCP port */
|
||||
@ -118,7 +118,7 @@ struct tcp_pcb *tcp_tmp_pcb;
|
||||
|
||||
u8_t tcp_active_pcbs_changed;
|
||||
|
||||
/** Timer counter to handle calling slow-timer from tcp_tmr() */
|
||||
/** Timer counter to handle calling slow-timer from tcp_tmr() */
|
||||
static u8_t tcp_timer;
|
||||
static u8_t tcp_timer_ctr;
|
||||
static u16_t tcp_new_port(void);
|
||||
@ -202,7 +202,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
|
||||
* however, it is in this state once allocated and as yet unused
|
||||
* and the user needs some way to free it should the need arise.
|
||||
* Calling tcp_close() with a pcb that has already been closed, (i.e. twice)
|
||||
* or for a pcb that has been used and then entered the CLOSED state
|
||||
* or for a pcb that has been used and then entered the CLOSED state
|
||||
* is erroneous, but this should never happen as the pcb has in those cases
|
||||
* been freed, and so any remaining handles are bogus. */
|
||||
err = ERR_OK;
|
||||
@ -357,7 +357,7 @@ void
|
||||
tcp_abandon(struct tcp_pcb *pcb, int reset)
|
||||
{
|
||||
u32_t seqno, ackno;
|
||||
#if LWIP_CALLBACK_API
|
||||
#if LWIP_CALLBACK_API
|
||||
tcp_err_fn errf;
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
void *errf_arg;
|
||||
@ -385,7 +385,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
|
||||
if (pcb->unsent != NULL) {
|
||||
tcp_segs_free(pcb->unsent);
|
||||
}
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
if (pcb->ooseq != NULL) {
|
||||
tcp_segs_free(pcb->ooseq);
|
||||
}
|
||||
@ -570,7 +570,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
||||
return (struct tcp_pcb *)lpcb;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Update the state that tracks the available window space to advertise.
|
||||
*
|
||||
* Returns how much extra window would be advertised if we sent an
|
||||
@ -649,7 +649,7 @@ tcp_new_port(void)
|
||||
u8_t i;
|
||||
u16_t n = 0;
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
|
||||
again:
|
||||
if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) {
|
||||
tcp_port = TCP_LOCAL_PORT_RANGE_START;
|
||||
@ -757,7 +757,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
|
||||
pcb->ssthresh = pcb->mss * 10;
|
||||
#if LWIP_CALLBACK_API
|
||||
pcb->connected = connected;
|
||||
#else /* LWIP_CALLBACK_API */
|
||||
#else /* LWIP_CALLBACK_API */
|
||||
LWIP_UNUSED_ARG(connected);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
@ -870,7 +870,7 @@ tcp_slowtmr_start:
|
||||
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F
|
||||
" ssthresh %"U16_F"\n",
|
||||
pcb->cwnd, pcb->ssthresh));
|
||||
|
||||
|
||||
/* The following needs to be called AFTER cwnd is set to one
|
||||
mss - STJ */
|
||||
tcp_rexmit_rto(pcb);
|
||||
@ -901,11 +901,11 @@ tcp_slowtmr_start:
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n",
|
||||
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
|
||||
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
|
||||
|
||||
|
||||
++pcb_remove;
|
||||
++pcb_reset;
|
||||
}
|
||||
else if((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
else if((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
|
||||
/ TCP_SLOW_INTERVAL)
|
||||
{
|
||||
@ -998,7 +998,7 @@ tcp_slowtmr_start:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Steps through all of the TIME-WAIT PCBs. */
|
||||
prev = NULL;
|
||||
pcb = tcp_tw_pcbs;
|
||||
@ -1010,7 +1010,7 @@ tcp_slowtmr_start:
|
||||
if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) {
|
||||
++pcb_remove;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* If the PCB should be removed, do it. */
|
||||
@ -1172,7 +1172,7 @@ tcp_setprio(struct tcp_pcb *pcb, u8_t prio)
|
||||
*
|
||||
* @param seg the old tcp_seg
|
||||
* @return a copy of seg
|
||||
*/
|
||||
*/
|
||||
struct tcp_seg *
|
||||
tcp_seg_copy(struct tcp_seg *seg)
|
||||
{
|
||||
@ -1182,7 +1182,7 @@ tcp_seg_copy(struct tcp_seg *seg)
|
||||
if (cseg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg));
|
||||
SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg));
|
||||
pbuf_ref(cseg->p);
|
||||
return cseg;
|
||||
}
|
||||
@ -1222,7 +1222,7 @@ tcp_kill_prio(u8_t prio)
|
||||
|
||||
|
||||
mprio = TCP_PRIO_MAX;
|
||||
|
||||
|
||||
/* We kill the oldest active connection that has lower priority than prio. */
|
||||
inactivity = 0;
|
||||
inactive = NULL;
|
||||
@ -1279,7 +1279,7 @@ tcp_alloc(u8_t prio)
|
||||
{
|
||||
struct tcp_pcb *pcb;
|
||||
u32_t iss;
|
||||
|
||||
|
||||
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
||||
if (pcb == NULL) {
|
||||
/* Try killing oldest connection in TIME-WAIT. */
|
||||
@ -1324,7 +1324,7 @@ tcp_alloc(u8_t prio)
|
||||
pcb->snd_wl2 = iss;
|
||||
pcb->snd_nxt = iss;
|
||||
pcb->lastack = iss;
|
||||
pcb->snd_lbb = iss;
|
||||
pcb->snd_lbb = iss;
|
||||
pcb->tmr = tcp_ticks;
|
||||
pcb->last_timer = tcp_timer_ctr;
|
||||
|
||||
@ -1332,11 +1332,11 @@ tcp_alloc(u8_t prio)
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
pcb->recv = tcp_recv_null;
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
/* Init KEEPALIVE timer */
|
||||
pcb->keep_idle = TCP_KEEPIDLE_DEFAULT;
|
||||
|
||||
|
||||
#if LWIP_TCP_KEEPALIVE
|
||||
pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT;
|
||||
pcb->keep_cnt = TCP_KEEPCNT_DEFAULT;
|
||||
@ -1371,7 +1371,7 @@ tcp_new(void)
|
||||
*
|
||||
* @param pcb tcp_pcb to set the callback argument
|
||||
* @param arg void pointer argument to pass to callback functions
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_arg(struct tcp_pcb *pcb, void *arg)
|
||||
{
|
||||
@ -1387,7 +1387,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg)
|
||||
*
|
||||
* @param pcb tcp_pcb to set the recv callback
|
||||
* @param recv callback function to call for this pcb when data is received
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
|
||||
{
|
||||
@ -1401,7 +1401,7 @@ tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
|
||||
*
|
||||
* @param pcb tcp_pcb to set the sent callback
|
||||
* @param sent callback function to call for this pcb when data is successfully sent
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
|
||||
{
|
||||
@ -1416,7 +1416,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
|
||||
* @param pcb tcp_pcb to set the err callback
|
||||
* @param err callback function to call for this pcb when a fatal error
|
||||
* has occured on the connection
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
|
||||
{
|
||||
@ -1431,7 +1431,7 @@ tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
|
||||
* @param pcb tcp_pcb to set the accept callback
|
||||
* @param accept callback function to call for this pcb when LISTENing
|
||||
* connection has been connected to another host
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
|
||||
{
|
||||
@ -1447,16 +1447,16 @@ tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
|
||||
* from TCP. The interval is specified in terms of the TCP coarse
|
||||
* timer interval, which is called twice a second.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
void
|
||||
tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)
|
||||
{
|
||||
LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN);
|
||||
#if LWIP_CALLBACK_API
|
||||
pcb->poll = poll;
|
||||
#else /* LWIP_CALLBACK_API */
|
||||
#else /* LWIP_CALLBACK_API */
|
||||
LWIP_UNUSED_ARG(poll);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
pcb->pollinterval = interval;
|
||||
}
|
||||
|
||||
@ -1540,7 +1540,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
|
||||
TCP_RMV(pcblist, pcb);
|
||||
|
||||
tcp_pcb_purge(pcb);
|
||||
|
||||
|
||||
/* if there is an outstanding delayed ACKs, send it */
|
||||
if (pcb->state != TIME_WAIT &&
|
||||
pcb->state != LISTEN &&
|
||||
@ -1571,7 +1571,7 @@ u32_t
|
||||
tcp_next_iss(void)
|
||||
{
|
||||
static u32_t iss = 6510;
|
||||
|
||||
|
||||
iss += tcp_ticks; /* XXX */
|
||||
return iss;
|
||||
}
|
||||
@ -1703,21 +1703,21 @@ tcp_debug_print_pcbs(void)
|
||||
pcb->local_port, pcb->remote_port,
|
||||
pcb->snd_nxt, pcb->rcv_nxt));
|
||||
tcp_debug_print_state(pcb->state);
|
||||
}
|
||||
}
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n"));
|
||||
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ",
|
||||
pcb->local_port, pcb->remote_port,
|
||||
pcb->snd_nxt, pcb->rcv_nxt));
|
||||
tcp_debug_print_state(pcb->state);
|
||||
}
|
||||
}
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n"));
|
||||
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ",
|
||||
pcb->local_port, pcb->remote_port,
|
||||
pcb->snd_nxt, pcb->rcv_nxt));
|
||||
tcp_debug_print_state(pcb->state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* These functions are generally called in the order (ip_input() ->)
|
||||
* tcp_input() -> * tcp_process() -> tcp_receive() (-> application).
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -166,7 +166,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
for an active connection. */
|
||||
prev = NULL;
|
||||
|
||||
|
||||
|
||||
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED);
|
||||
LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
|
||||
@ -253,7 +253,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
/* put this listening pcb at the head of the listening list */
|
||||
tcp_listen_pcbs.listen_pcbs = lpcb;
|
||||
}
|
||||
|
||||
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));
|
||||
tcp_listen_input(lpcb);
|
||||
pbuf_free(p);
|
||||
@ -588,7 +588,7 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
acceptable = 1;
|
||||
}
|
||||
} else {
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
|
||||
pcb->rcv_nxt+pcb->rcv_wnd)) {
|
||||
acceptable = 1;
|
||||
}
|
||||
@ -609,12 +609,12 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) {
|
||||
if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) {
|
||||
/* Cope with new connection attempt after remote end crashed */
|
||||
tcp_ack_now(pcb);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
if ((pcb->flags & TF_RXCLOSED) == 0) {
|
||||
/* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */
|
||||
pcb->tmr = tcp_ticks;
|
||||
@ -892,7 +892,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
#if TCP_WND_DEBUG
|
||||
} else {
|
||||
if (pcb->snd_wnd != tcphdr->wnd) {
|
||||
LWIP_DEBUGF(TCP_WND_DEBUG,
|
||||
LWIP_DEBUGF(TCP_WND_DEBUG,
|
||||
("tcp_receive: no window update lastack %"U32_F" ackno %"
|
||||
U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n",
|
||||
pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2));
|
||||
@ -902,17 +902,17 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
|
||||
/* (From Stevens TCP/IP Illustrated Vol II, p970.) Its only a
|
||||
* duplicate ack if:
|
||||
* 1) It doesn't ACK new data
|
||||
* 2) length of received packet is zero (i.e. no payload)
|
||||
* 3) the advertised window hasn't changed
|
||||
* 1) It doesn't ACK new data
|
||||
* 2) length of received packet is zero (i.e. no payload)
|
||||
* 3) the advertised window hasn't changed
|
||||
* 4) There is outstanding unacknowledged data (retransmission timer running)
|
||||
* 5) The ACK is == biggest ACK sequence number so far seen (snd_una)
|
||||
*
|
||||
* If it passes all five, should process as a dupack:
|
||||
* a) dupacks < 3: do nothing
|
||||
* b) dupacks == 3: fast retransmit
|
||||
* c) dupacks > 3: increase cwnd
|
||||
*
|
||||
*
|
||||
* If it passes all five, should process as a dupack:
|
||||
* a) dupacks < 3: do nothing
|
||||
* b) dupacks == 3: fast retransmit
|
||||
* c) dupacks > 3: increase cwnd
|
||||
*
|
||||
* If it only passes 1-3, should reset dupack counter (and add to
|
||||
* stats, which we don't do in lwIP)
|
||||
*
|
||||
@ -1053,7 +1053,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
->unsent list after a retransmission, so these segments may
|
||||
in fact have been sent once. */
|
||||
while (pcb->unsent != NULL &&
|
||||
TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) +
|
||||
TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) +
|
||||
TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n",
|
||||
ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) +
|
||||
@ -1065,7 +1065,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
if (pcb->unsent == NULL) {
|
||||
pcb->unsent_oversize = 0;
|
||||
}
|
||||
#endif /* TCP_OVERSIZE */
|
||||
#endif /* TCP_OVERSIZE */
|
||||
LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen));
|
||||
LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p)));
|
||||
/* Prevent ACK for FIN to generate a sent event */
|
||||
@ -1211,7 +1211,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
/* The sequence number must be within the window (above rcv_nxt
|
||||
and below rcv_nxt + rcv_wnd) in order to be further
|
||||
processed. */
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
|
||||
pcb->rcv_nxt + pcb->rcv_wnd - 1)){
|
||||
if (pcb->rcv_nxt == seqno) {
|
||||
/* The incoming segment is the next in sequence. We check if
|
||||
@ -1220,12 +1220,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
tcplen = TCP_TCPLEN(&inseg);
|
||||
|
||||
if (tcplen > pcb->rcv_wnd) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
("tcp_receive: other end overran receive window"
|
||||
"seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n",
|
||||
seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd));
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
|
||||
/* Must remove the FIN from the header as we're trimming
|
||||
/* Must remove the FIN from the header as we're trimming
|
||||
* that byte of sequence-space from the packet */
|
||||
TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN);
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
- inseq overlaps with ooseq */
|
||||
if (pcb->ooseq != NULL) {
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
("tcp_receive: received in-order FIN, binning ooseq queue\n"));
|
||||
/* Received in-order FIN means anything that was received
|
||||
* out of order must now have been received in-order, so
|
||||
@ -1352,7 +1352,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
recv_flags |= TF_GOT_FIN;
|
||||
if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */
|
||||
pcb->state = CLOSE_WAIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pcb->ooseq = cseg->next;
|
||||
@ -1465,12 +1465,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
}
|
||||
/* check if the remote side overruns our receive window */
|
||||
if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
("tcp_receive: other end overran receive window"
|
||||
"seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n",
|
||||
seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd));
|
||||
if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) {
|
||||
/* Must remove the FIN from the header as we're trimming
|
||||
/* Must remove the FIN from the header as we're trimming
|
||||
* that byte of sequence-space from the packet */
|
||||
TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN);
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the options contained in the incoming segment.
|
||||
* Parses the options contained in the incoming segment.
|
||||
*
|
||||
* Called from tcp_listen_input() and tcp_process().
|
||||
* Currently, only the MSS option is supported!
|
||||
@ -1588,7 +1588,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
|
||||
return;
|
||||
}
|
||||
/* TCP timestamp option with valid length */
|
||||
tsval = (opts[c+2]) | (opts[c+3] << 8) |
|
||||
tsval = (opts[c+2]) | (opts[c+3] << 8) |
|
||||
(opts[c+4] << 16) | (opts[c+5] << 24);
|
||||
if (flags & TCP_SYN) {
|
||||
pcb->ts_recent = ntohl(tsval);
|
||||
|
@ -197,7 +197,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
|
||||
/* wnd and chksum are set in tcp_output */
|
||||
seg->tcphdr->urgp = 0;
|
||||
return seg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a PBUF_RAM pbuf, perhaps with extra space at the end.
|
||||
@ -212,7 +212,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
|
||||
* @param pcb The TCP connection that willo enqueue the pbuf.
|
||||
* @param apiflags API flags given to tcp_write.
|
||||
* @param first_seg true when this pbuf will be used in the first enqueued segment.
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
#if TCP_OVERSIZE
|
||||
static struct pbuf *
|
||||
@ -379,7 +379,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n",
|
||||
(void *)pcb, arg, len, (u16_t)apiflags));
|
||||
LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)",
|
||||
LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)",
|
||||
arg != NULL, return ERR_ARG;);
|
||||
|
||||
err = tcp_write_checks(pcb, len);
|
||||
@ -857,7 +857,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
|
||||
return ERR_BUF;
|
||||
}
|
||||
tcphdr = (struct tcp_hdr *)p->payload;
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG,
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG,
|
||||
("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt));
|
||||
/* remove ACK flags from the PCB, as we send an empty ACK now */
|
||||
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
|
||||
@ -869,7 +869,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
|
||||
if (pcb->flags & TF_TIMESTAMP) {
|
||||
tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CHECKSUM_GEN_TCP
|
||||
tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
|
||||
@ -950,7 +950,7 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
", seg == NULL, ack %"U32_F"\n",
|
||||
pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack));
|
||||
} else {
|
||||
LWIP_DEBUGF(TCP_CWND_DEBUG,
|
||||
LWIP_DEBUGF(TCP_CWND_DEBUG,
|
||||
("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F
|
||||
", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n",
|
||||
pcb->snd_wnd, pcb->cwnd, wnd,
|
||||
@ -961,7 +961,7 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
/* data available and window allows it to be sent? */
|
||||
while (seg != NULL &&
|
||||
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) {
|
||||
LWIP_ASSERT("RST not expected here!",
|
||||
LWIP_ASSERT("RST not expected here!",
|
||||
(TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0);
|
||||
/* Stop sending if the nagle algorithm would prevent it
|
||||
* Don't stop:
|
||||
@ -1086,7 +1086,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set retransmission timer running if it is not currently enabled
|
||||
/* Set retransmission timer running if it is not currently enabled
|
||||
This must be set before checking the route. */
|
||||
if (pcb->rtime == -1) {
|
||||
pcb->rtime = 0;
|
||||
@ -1317,12 +1317,12 @@ tcp_rexmit(struct tcp_pcb *pcb)
|
||||
*
|
||||
* @param pcb the tcp_pcb for which to retransmit the first unacked segment
|
||||
*/
|
||||
void
|
||||
void
|
||||
tcp_rexmit_fast(struct tcp_pcb *pcb)
|
||||
{
|
||||
if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) {
|
||||
/* This is fast retransmit. Retransmit the first unacked segment. */
|
||||
LWIP_DEBUGF(TCP_FR_DEBUG,
|
||||
LWIP_DEBUGF(TCP_FR_DEBUG,
|
||||
("tcp_receive: dupacks %"U16_F" (%"U32_F
|
||||
"), fast retransmit %"U32_F"\n",
|
||||
(u16_t)pcb->dupacks, pcb->lastack,
|
||||
@ -1336,19 +1336,19 @@ tcp_rexmit_fast(struct tcp_pcb *pcb)
|
||||
} else {
|
||||
pcb->ssthresh = pcb->cwnd / 2;
|
||||
}
|
||||
|
||||
|
||||
/* The minimum value for ssthresh should be 2 MSS */
|
||||
if (pcb->ssthresh < 2*pcb->mss) {
|
||||
LWIP_DEBUGF(TCP_FR_DEBUG,
|
||||
LWIP_DEBUGF(TCP_FR_DEBUG,
|
||||
("tcp_receive: The minimum value for ssthresh %"U16_F
|
||||
" should be min 2 mss %"U16_F"...\n",
|
||||
pcb->ssthresh, 2*pcb->mss));
|
||||
pcb->ssthresh = 2*pcb->mss;
|
||||
}
|
||||
|
||||
|
||||
pcb->cwnd = pcb->ssthresh + 3 * pcb->mss;
|
||||
pcb->flags |= TF_INFR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1370,12 +1370,12 @@ tcp_keepalive(struct tcp_pcb *pcb)
|
||||
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
|
||||
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
|
||||
tcp_ticks, pcb->tmr, pcb->keep_cnt_sent));
|
||||
|
||||
|
||||
p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1));
|
||||
if(p == NULL) {
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
("tcp_keepalive: could not allocate memory for pbuf\n"));
|
||||
return;
|
||||
}
|
||||
@ -1419,15 +1419,15 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
|
||||
u16_t len;
|
||||
u8_t is_fin;
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
("tcp_zero_window_probe: sending ZERO WINDOW probe to %"
|
||||
U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip),
|
||||
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip)));
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
("tcp_zero_window_probe: tcp_ticks %"U32_F
|
||||
" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
|
||||
" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n",
|
||||
tcp_ticks, pcb->tmr, pcb->keep_cnt_sent));
|
||||
|
||||
seg = pcb->unacked;
|
||||
|
@ -116,7 +116,7 @@
|
||||
#define MEM_SIZE 1024 * 1024 * 64
|
||||
#define TCP_SND_BUF 1024 * 63
|
||||
|
||||
|
||||
#define TCP_SND_QUEUELEN 1024
|
||||
/*------------------------------------------------------------------------------
|
||||
-------------------------- Internal Memory Pool Sizes --------------------------
|
||||
------------------------------------------------------------------------------*/
|
||||
@ -157,7 +157,7 @@
|
||||
* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_SEG 128
|
||||
#define MEMP_NUM_TCP_SEG 1024
|
||||
|
||||
/**
|
||||
* MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
|
||||
|
@ -494,6 +494,13 @@ int connect(CONNECT_SIG)
|
||||
return err;
|
||||
}
|
||||
|
||||
//int flags = fcntl(__fd, F_GETFD);
|
||||
//dwr("connect(): socket flags = %d\n", flags);
|
||||
|
||||
if(sock_type && O_NONBLOCK) {
|
||||
dwr("connect(): O_NONBLOCK\n");
|
||||
}
|
||||
|
||||
/* assemble and route command */
|
||||
int err;
|
||||
char cmd[BUF_SZ];
|
||||
@ -507,6 +514,10 @@ int connect(CONNECT_SIG)
|
||||
memcpy(&cmd[1], &rpc_st, sizeof(struct connect_st));
|
||||
pthread_mutex_lock(&lock);
|
||||
send_command(fdret_sock, cmd);
|
||||
if(sock_type && O_NONBLOCK) {
|
||||
//pthread_mutex_unlock(&lock);
|
||||
//return EINPROGRESS;
|
||||
}
|
||||
err = get_retval();
|
||||
pthread_mutex_unlock(&lock);
|
||||
return err;
|
||||
|
@ -318,6 +318,8 @@ void NetconEthernetTap::threadMain()
|
||||
fprintf(stderr, "_threadMain()\n");
|
||||
uint64_t prev_tcp_time = 0;
|
||||
uint64_t prev_etharp_time = 0;
|
||||
fprintf(stderr, "- TCP_SND_QUEUELEN = %d\n", TCP_SND_QUEUELEN);
|
||||
fprintf(stderr, "- TCP_MAXRTX = %d\n", TCP_MAXRTX);
|
||||
|
||||
/*
|
||||
fprintf(stderr, "- MEM_SIZE = %dM\n", MEM_SIZE / (1024*1024));
|
||||
@ -327,7 +329,7 @@ void NetconEthernetTap::threadMain()
|
||||
fprintf(stderr, "- MEMP_NUM_TCP_PCB_LISTEN = %d\n", MEMP_NUM_TCP_PCB_LISTEN);
|
||||
fprintf(stderr, "- MEMP_NUM_TCP_SEG = %d\n", MEMP_NUM_TCP_SEG);
|
||||
fprintf(stderr, "- PBUF_POOL_SIZE = %d\n", PBUF_POOL_SIZE);
|
||||
fprintf(stderr, "- TCP_SND_QUEUELEN = %d\n", TCP_SND_QUEUELEN);
|
||||
|
||||
fprintf(stderr, "- IP_REASSEMBLY = %d\n", IP_REASSEMBLY);
|
||||
fprintf(stderr, "- TCP_WND = %d\n", TCP_WND);
|
||||
fprintf(stderr, "- TCP_MSS = %d\n", TCP_MSS);
|
||||
@ -376,9 +378,13 @@ void NetconEthernetTap::phyOnFileDescriptorActivity(PhySocket *sock,void **uptr,
|
||||
{
|
||||
if(readable) {
|
||||
TcpConnection *conn = (TcpConnection*)*uptr;
|
||||
Mutex::Lock _l(lwipstack->_lock);
|
||||
if(conn->dataSock) // Sometimes a connection may be closed via nc_recved, check first
|
||||
{
|
||||
//Mutex::Lock _l(lwipstack->_lock);
|
||||
//lwipstack->_lock.lock();
|
||||
handle_write(conn);
|
||||
//lwipstack->_lock.unlock();
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "phyOnFileDescriptorActivity(): PhySocket not readable\n");
|
||||
@ -1144,8 +1150,9 @@ void NetconEthernetTap::handle_write(TcpConnection *conn)
|
||||
// NOTE: this assumes that lwipstack->_lock is locked, either
|
||||
// because we are in a callback or have locked it manually.
|
||||
int err = lwipstack->_tcp_write(conn->pcb, &conn->buf, r, TCP_WRITE_FLAG_COPY);
|
||||
lwipstack->_tcp_output(conn->pcb);
|
||||
if(err != ERR_OK) {
|
||||
fprintf(stderr, "handle_write(): error while writing to PCB\n");
|
||||
fprintf(stderr, "handle_write(): error while writing to PCB, (err = %d)\n", err);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
Binary file not shown.
BIN
netcon/liblwip.so
Executable file
BIN
netcon/liblwip.so
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user