diff --git a/doc/rawapi.txt b/doc/rawapi.txt index 61a5edb9..2c88ca28 100644 --- a/doc/rawapi.txt +++ b/doc/rawapi.txt @@ -272,6 +272,11 @@ level of complexity of UDP, the interface is significantly simpler. Sets the remote end of the pcb. This function does not generate any network traffic, but only set the remote address of the pcb. +- err_t udp_disconnect(struct udp_pcb *pcb) + + Remove the remote end of the pcb. This function does not generate + any network traffic, but only removes the remote address of the pcb. + - err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) Sends the pbuf p. The pbuf is not deallocated. diff --git a/src/core/udp.c b/src/core/udp.c index b352669c..4f318133 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -703,6 +703,10 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) void udp_disconnect(struct udp_pcb *pcb) { + /* reset remote address association */ + ip_addr_set(&pcb->remote_ip, IP_ADDR_ANY); + pcb->remote_port = 0; + /* mark PCB as unconnected */ pcb->flags &= ~UDP_FLAGS_CONNECTED; } diff --git a/src/include/lwip/err.h b/src/include/lwip/err.h index b7a4ea0e..c92cb26d 100644 --- a/src/include/lwip/err.h +++ b/src/include/lwip/err.h @@ -59,6 +59,7 @@ typedef s8_t err_t; #define ERR_USE -10 /* Address in use. */ #define ERR_IF -11 /* Low-level netif error */ +#define ERR_ISCONN -12 /* Already connected. */ #ifdef LWIP_DEBUG