mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
Don't allow multiple binds to the same UDP port/address pair.Closes bug #1896
This commit is contained in:
parent
39edc69514
commit
16434f0d01
@ -272,7 +272,7 @@ do_bind(struct api_msg_msg *msg)
|
|||||||
case NETCONN_UDPNOCHKSUM:
|
case NETCONN_UDPNOCHKSUM:
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case NETCONN_UDP:
|
case NETCONN_UDP:
|
||||||
udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
|
msg->conn->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_UDP */
|
#endif /* LWIP_UDP */
|
||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: udp.c,v 1.9 2003/01/17 15:16:33 likewise Exp $
|
* $Id: udp.c,v 1.10 2003/01/21 14:09:31 jani Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
@ -396,8 +396,6 @@ err_t
|
|||||||
udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
||||||
{
|
{
|
||||||
struct udp_pcb *ipcb;
|
struct udp_pcb *ipcb;
|
||||||
ip_addr_set(&pcb->local_ip, ipaddr);
|
|
||||||
pcb->local_port = port;
|
|
||||||
|
|
||||||
/* Insert UDP PCB into the list of active UDP PCBs. */
|
/* Insert UDP PCB into the list of active UDP PCBs. */
|
||||||
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
|
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
|
||||||
@ -405,7 +403,19 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
/* Already on the list, just return. */
|
/* Already on the list, just return. */
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
if (ipcb->local_port == port) {
|
||||||
|
if(ip_addr_isany(&(ipcb->local_ip)) ||
|
||||||
|
ip_addr_isany(ipaddr) ||
|
||||||
|
ip_addr_cmp(&(ipcb->local_ip), ipaddr)) {
|
||||||
|
/* Port/IP pair already bound */
|
||||||
|
return ERR_USE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip_addr_set(&pcb->local_ip, ipaddr);
|
||||||
|
pcb->local_port = port;
|
||||||
|
|
||||||
/* We need to place the PCB on the list. */
|
/* We need to place the PCB on the list. */
|
||||||
pcb->next = udp_pcbs;
|
pcb->next = udp_pcbs;
|
||||||
udp_pcbs = pcb;
|
udp_pcbs = pcb;
|
||||||
|
Loading…
Reference in New Issue
Block a user