struct tcp_pcb_listen { /* Common members of all PCB types */ IP_PCB; /* Protocol specific PCB members */ TCP_PCB_COMMON(struct tcp_pcb_listen); #if LWIP_CALLBACK_API /* Function to call when a listener has been connected. * @param arg user-supplied argument (tcp_pcb.callback_arg) * @param pcb a new tcp_pcb that now is connected * @param err an error argument (TODO: that is current always ERR_OK?) * @return ERR_OK: accept the new connection, * any other err_t abortsthe new connection */ err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err); #endif /* LWIP_CALLBACK_API */ #if LWIP_LISTEN_BACKLOG u8_t backlog; u8_t to_accept; #endif /* LWIP_LISTEN_BACKLOG */ }; void do_recv(struct api_msg_msg *msg) { #if LWIP_TCP if (!ERR_IS_FATAL(msg->conn->err)) { if (msg->conn->pcb.tcp != NULL) { if (msg->conn->type == NETCONN_TCP) { if (conn->pcb.tcp->state == LISTEN) { #if LWIP_LISTEN_BACKLOG tcp_accepted((struct tcp_pcb_listen *)(msg->conn->pcb.tcp)); <<<<<<<< NEW #endif /* LWIP_LISTEN_BACKLOG */ } else { tcp_recved(msg->conn->pcb.tcp, msg->msg.r.len); } } } } #endif /* LWIP_TCP */ TCPIP_APIMSG_ACK(msg); } #if LWIP_LISTEN_BACKLOG void tcp_accepted(struct tcp_pcb_listen *pcb) { pcb->to_accept--; } #endif /* LWIP_LISTEN_BACKLOG */ static err_t tcp_listen_input(struct tcp_pcb_listen *pcb) { ... } 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 (pcb->to_accept>=pcb->backlog) { return ERR_ABRT; } #endif /* LWIP_LISTEN_BACKLOG */ ... }