mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-08 08:33:39 +08:00
rawapi.txt, api.h, api_lib.c, api_msg.h, api_msg.c, sockets.c, tcp.h, tcp.c, tcp_in.c, init.c, opt.h: rename backlog options with TCP_ prefix, limit the "backlog" parameter in an u8_t, 0 is interpreted as "smallest queue", add documentation in the rawapi.txt file.
This commit is contained in:
@@ -103,6 +103,9 @@
|
||||
#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
|
||||
#error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 255))
|
||||
#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
|
||||
#endif
|
||||
#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
|
||||
#error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
|
||||
#endif
|
||||
@@ -152,9 +155,6 @@
|
||||
#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
|
||||
#error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_DEFAULT_LISTEN_BACKLOG < 0) || (LWIP_DEFAULT_LISTEN_BACKLOG > 255)
|
||||
#error "LWIP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
|
||||
#endif
|
||||
|
||||
|
||||
/* Compile-time checks for deprecated options.
|
||||
|
||||
@@ -343,7 +343,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
* tpcb = tcp_listen(tpcb);
|
||||
*/
|
||||
struct tcp_pcb *
|
||||
tcp_listen(struct tcp_pcb *pcb)
|
||||
tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
||||
{
|
||||
struct tcp_pcb_listen *lpcb;
|
||||
|
||||
@@ -370,10 +370,10 @@ tcp_listen(struct tcp_pcb *pcb)
|
||||
#if LWIP_CALLBACK_API
|
||||
lpcb->accept = tcp_accept_null;
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
#if LWIP_LISTEN_BACKLOG
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
lpcb->accepts_pending = 0;
|
||||
lpcb->backlog = LWIP_DEFAULT_LISTEN_BACKLOG;
|
||||
#endif /* LWIP_LISTEN_BACKLOG */
|
||||
lpcb->backlog = (backlog ? backlog : 1);
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
TCP_REG(&tcp_listen_pcbs.listen_pcbs, lpcb);
|
||||
return (struct tcp_pcb *)lpcb;
|
||||
}
|
||||
|
||||
@@ -381,11 +381,11 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
tcphdr->dest, tcphdr->src);
|
||||
} else if (flags & TCP_SYN) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest));
|
||||
#if LWIP_LISTEN_BACKLOG
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
if (pcb->accepts_pending >= pcb->backlog) {
|
||||
return ERR_ABRT;
|
||||
}
|
||||
#endif /* LWIP_LISTEN_BACKLOG */
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
npcb = tcp_alloc(pcb->prio);
|
||||
/* If a new PCB could not be created (probably due to lack of memory),
|
||||
we don't do anything, but rely on the sender will retransmit the
|
||||
@@ -395,9 +395,9 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
TCP_STATS_INC(tcp.memerr);
|
||||
return ERR_MEM;
|
||||
}
|
||||
#if LWIP_LISTEN_BACKLOG
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
pcb->accepts_pending++;
|
||||
#endif /* LWIP_LISTEN_BACKLOG */
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
/* Set up the new PCB. */
|
||||
ip_addr_set(&(npcb->local_ip), &(iphdr->dest));
|
||||
npcb->local_port = pcb->local_port;
|
||||
|
||||
Reference in New Issue
Block a user