net: zperf: By default bind to any IP address
Default behaviour should only bind to port independent of IP, this allows even multicast/broadcast L4 traffic to be received. User can always specify a specific address to bind using shell or Kconfig or API. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
parent
dee1f2deaa
commit
a1024f6aeb
4 changed files with 15 additions and 64 deletions
|
@ -263,18 +263,11 @@ static void udp_server_session(void)
|
|||
&in4_addr_my->sin_addr);
|
||||
if (ret < 0) {
|
||||
NET_WARN("Unable to set IPv4");
|
||||
goto use_existing_ipv4;
|
||||
goto use_any_ipv4;
|
||||
}
|
||||
} else {
|
||||
use_existing_ipv4:
|
||||
/* Use existing IP */
|
||||
in4_addr = zperf_get_default_if_in4_addr();
|
||||
if (!in4_addr) {
|
||||
NET_ERR("Unable to get IPv4 by default");
|
||||
goto error;
|
||||
}
|
||||
memcpy(&in4_addr_my->sin_addr, in4_addr,
|
||||
sizeof(struct in_addr));
|
||||
use_any_ipv4:
|
||||
in4_addr_my->sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
NET_INFO("Binding to %s",
|
||||
|
@ -319,18 +312,13 @@ static void udp_server_session(void)
|
|||
&in6_addr_my->sin6_addr);
|
||||
if (ret < 0) {
|
||||
NET_WARN("Unable to set IPv6");
|
||||
goto use_existing_ipv6;
|
||||
goto use_any_ipv6;
|
||||
}
|
||||
} else {
|
||||
use_existing_ipv6:
|
||||
/* Use existing IP */
|
||||
in6_addr = zperf_get_default_if_in6_addr();
|
||||
if (!in6_addr) {
|
||||
NET_ERR("Unable to get IPv4 by default");
|
||||
goto error;
|
||||
}
|
||||
memcpy(&in6_addr_my->sin6_addr, in6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
use_any_ipv6:
|
||||
memcpy(&in6_addr_my->sin6_addr,
|
||||
net_ipv6_unspecified_address(),
|
||||
sizeof(struct in6_addr));
|
||||
}
|
||||
|
||||
NET_INFO("Binding to %s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue