mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Check state == CLOSED in tcp_bind and tcp_connect to prevent binding/connecting twice (using LWIP_ERROR: can be disabled)
This commit is contained in:
parent
4dcfdac2f5
commit
5743b11925
@ -256,6 +256,8 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
{
|
{
|
||||||
struct tcp_pcb *cpcb;
|
struct tcp_pcb *cpcb;
|
||||||
|
|
||||||
|
LWIP_ERROR("tcp_connect: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||||
|
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = tcp_new_port();
|
port = tcp_new_port();
|
||||||
}
|
}
|
||||||
@ -343,7 +345,7 @@ tcp_listen(struct tcp_pcb *pcb)
|
|||||||
{
|
{
|
||||||
struct tcp_pcb_listen *lpcb;
|
struct tcp_pcb_listen *lpcb;
|
||||||
|
|
||||||
LWIP_ERROR("pcb not already connected", pcb->state == CLOSED, return NULL);
|
LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL);
|
||||||
|
|
||||||
/* already listening? */
|
/* already listening? */
|
||||||
if (pcb->state == LISTEN) {
|
if (pcb->state == LISTEN) {
|
||||||
@ -474,6 +476,8 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
|||||||
err_t ret;
|
err_t ret;
|
||||||
u32_t iss;
|
u32_t iss;
|
||||||
|
|
||||||
|
LWIP_ERROR("tcp_connect: can only connected from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);
|
||||||
|
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
|
||||||
if (ipaddr != NULL) {
|
if (ipaddr != NULL) {
|
||||||
pcb->remote_ip = *ipaddr;
|
pcb->remote_ip = *ipaddr;
|
||||||
|
Loading…
Reference in New Issue
Block a user