PCB_ISIPV6() macro is well defined for all cases (LWIP_IPV4 && LWIP_IPV6,
LWIP_IPV4 only and LWIP_IPV6 only), thus remove the unnecessary #if guard
around PCB_ISIPV6() calls.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This makes the code simpler with better readability.
Also make memp_names static because it's only referenced by stats.c.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
We don't really care the order of overflow/underflow checking because if
any checking fails we got assertion.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This fixes a bug in close when LWIP_SO_SNDTIMEO is enabled, but
the option is not in use on the socket
A simple mis-typed comparison against zero would cause the close_timeout
to get set to zero if conn->send_timeout was 0
The intended check was to over-ride the default close timeout if a
send timeout had been specified via SO_SNDTIMEO
+ Minor compile fix from me
Patch makes the code a tiny bit less lightweight (add a parameter in dns_gethostbyname which is then not used in dns_gethostbyname_addrtype) but it makes the code more readable.
No port specified means to use a random port.
udp_new_port() returns a new (free) local UDP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, udp_new_port() alreay ensures the port is not used.
Move the code checking for double bind and rebind of the same pcb earlier,
as this checking is necessary in all cases.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
The code for #if SO_REUSE case does not match the comment.
By default, we don't allow to bind to a port that any other udp
PCB is already bound to, unless *all* PCBs with that port have tha
REUSEADDR flag set.
Which means we want to omit checking for the same port if both pcbs
have REUSEADDR set. Fix the logic accordingly.
Fixes: d0348e0c60 ("task #6995: Implement SO_REUSEADDR (correctly)")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
No port specified means to use a random port.
tcp_new_port() returns a new (free) local TCP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, tcp_new_port() alreay ensures the port is not used.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Current code does not correctly detect port conflict if no port specified
because it checks ipcb->local_port == port before udp_new_port().
Fix it by allocating a random port earlier.
Signed-off-by: Axel Lin <axel.lin@ingics.com>