patch #8358: allow more combinations of listening PCB for IPv6

This commit is contained in:
sg 2016-04-05 22:04:19 +02:00
parent 16c70dd60e
commit 8c7f513f4d
2 changed files with 12 additions and 6 deletions

View File

@ -317,6 +317,9 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2016-04-05: Simon Goldschmidt (patch by Philip Gladstone)
* udp.c: patch #8358: allow more combinations of listening PCB for IPv6
2016-04-05: Simon Goldschmidt 2016-04-05: Simon Goldschmidt
* netconn/socket API: fixed bug# 43739 (Accept not reporting errors about * netconn/socket API: fixed bug# 43739 (Accept not reporting errors about
aborted connections): netconn_accept() returns ERR_ABRT (sockets: ECONNABORTED) aborted connections): netconn_accept() returns ERR_ABRT (sockets: ECONNABORTED)

View File

@ -274,8 +274,13 @@ udp_input(struct pbuf *p, struct netif *inp)
/* compare PCB local addr+port to UDP destination addr+port */ /* compare PCB local addr+port to UDP destination addr+port */
if ((pcb->local_port == dest) && if ((pcb->local_port == dest) &&
(udp_input_local_match(pcb, inp, broadcast) != 0)) { (udp_input_local_match(pcb, inp, broadcast) != 0)) {
if ((uncon_pcb == NULL) && if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { ((uncon_pcb == NULL)
#if SO_REUSE
/* prefer specific IPs over cath-all */
|| !ip_addr_isany(&pcb->local_ip)
#endif /* SO_REUSE */
)) {
/* the first unconnected matching PCB */ /* the first unconnected matching PCB */
uncon_pcb = pcb; uncon_pcb = pcb;
} }
@ -939,10 +944,8 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
{ {
/* port matches that of PCB in list and REUSEADDR not set -> reject */ /* port matches that of PCB in list and REUSEADDR not set -> reject */
if ((ipcb->local_port == port) && (IP_IS_V6(ipaddr) == IP_IS_V6_VAL(ipcb->local_ip)) && if ((ipcb->local_port == port) && (IP_IS_V6(ipaddr) == IP_IS_V6_VAL(ipcb->local_ip)) &&
/* IP address matches, or one is IP_ADDR_ANY? */ /* IP address matches? */
(ip_addr_isany(&ipcb->local_ip) || ip_addr_cmp(&ipcb->local_ip, ipaddr)) {
ip_addr_isany(ipaddr) ||
ip_addr_cmp(&ipcb->local_ip, ipaddr))) {
/* other PCB already binds to this local IP and port */ /* other PCB already binds to this local IP and port */
LWIP_DEBUGF(UDP_DEBUG, LWIP_DEBUGF(UDP_DEBUG,
("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); ("udp_bind: local port %"U16_F" already bound by another pcb\n", port));