net: contiki: Traverse UDP connection list properly
We have an array of UDP connections so just go through the list in a most simple way. Set only the UDP connection pointer if we found something and clear it otherwise. This helps to avoid weird errors where multiple UDP connections were added but only the first one was found during list traversal. Change-Id: Iae90ee6803eee1d06e7a49211d77692b0cf5ca50 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
6f059122f7
commit
857017a9e3
1 changed files with 9 additions and 9 deletions
|
@ -1522,9 +1522,7 @@ uip_process(struct net_buf *buf, uint8_t flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Demultiplex this UDP packet between the UDP "connections". */
|
/* Demultiplex this UDP packet between the UDP "connections". */
|
||||||
for(i = 0, uip_set_udp_conn(buf) = &uip_udp_conns[0];
|
for(i = 0; i < UIP_UDP_CONNS; i++) {
|
||||||
i < UIP_UDP_CONNS && uip_udp_conn(buf) < &uip_udp_conns[UIP_UDP_CONNS];
|
|
||||||
i++, ++uip_set_udp_conn(buf)) {
|
|
||||||
/* If the local UDP port is non-zero, the connection is considered
|
/* If the local UDP port is non-zero, the connection is considered
|
||||||
to be used. If so, the local port number is checked against the
|
to be used. If so, the local port number is checked against the
|
||||||
destination port number in the received packet. If the two port
|
destination port number in the received packet. If the two port
|
||||||
|
@ -1532,15 +1530,17 @@ uip_process(struct net_buf *buf, uint8_t flag)
|
||||||
connection is bound to a remote port. Finally, if the
|
connection is bound to a remote port. Finally, if the
|
||||||
connection is bound to a remote IP address, the source IP
|
connection is bound to a remote IP address, the source IP
|
||||||
address of the packet is checked. */
|
address of the packet is checked. */
|
||||||
if(uip_udp_conn(buf)->lport != 0 &&
|
if(uip_udp_conns[i].lport != 0 &&
|
||||||
UIP_UDP_BUF(buf)->destport == uip_udp_conn(buf)->lport &&
|
UIP_UDP_BUF(buf)->destport == uip_udp_conns[i].lport &&
|
||||||
(uip_udp_conn(buf)->rport == 0 ||
|
(uip_udp_conns[i].rport == 0 ||
|
||||||
UIP_UDP_BUF(buf)->srcport == uip_udp_conn(buf)->rport) &&
|
UIP_UDP_BUF(buf)->srcport == uip_udp_conns[i].rport) &&
|
||||||
(uip_is_addr_unspecified(&uip_udp_conn(buf)->ripaddr) ||
|
(uip_is_addr_unspecified(&uip_udp_conns[i].ripaddr) ||
|
||||||
uip_ipaddr_cmp(&UIP_IP_BUF(buf)->srcipaddr, &uip_udp_conn(buf)->ripaddr))) {
|
uip_ipaddr_cmp(&UIP_IP_BUF(buf)->srcipaddr, &uip_udp_conns[i].ripaddr))) {
|
||||||
|
uip_set_udp_conn(buf) = &uip_udp_conns[i];
|
||||||
goto udp_found;
|
goto udp_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uip_set_udp_conn(buf) = NULL;
|
||||||
PRINTF("udp: no matching connection found\n");
|
PRINTF("udp: no matching connection found\n");
|
||||||
UIP_STAT(++uip_stat.udp.drop);
|
UIP_STAT(++uip_stat.udp.drop);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue