net: zperf: Add support for bind to host option for tcp/udp download
The current zperf tcp/udp download command doesn't provide the option to bind the server to a specific host address. If there is more than one interface, it will not be possible to test each interface with zperf tcp/udp download command without building the Zpehyr. This patch will add support for zperf tcp/udp download command to bind server to host interface address. Signed-off-by: Rahul Singh <rahul.singh@arm.com>
This commit is contained in:
parent
c8a79e1fc1
commit
6ef75a26ea
4 changed files with 84 additions and 20 deletions
|
@ -48,6 +48,7 @@ static void *udp_user_data;
|
|||
static bool udp_server_running;
|
||||
static bool udp_server_stop;
|
||||
static uint16_t udp_server_port;
|
||||
static struct sockaddr udp_server_addr;
|
||||
static K_SEM_DEFINE(udp_server_run, 0, 1);
|
||||
|
||||
static inline void build_reply(struct zperf_udp_datagram *hdr,
|
||||
|
@ -251,7 +252,12 @@ static void udp_server_session(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (MY_IP4ADDR && strlen(MY_IP4ADDR)) {
|
||||
in4_addr = &net_sin(&udp_server_addr)->sin_addr;
|
||||
|
||||
if (!net_ipv4_is_addr_unspecified(in4_addr)) {
|
||||
memcpy(&in4_addr_my->sin_addr, in4_addr,
|
||||
sizeof(struct in_addr));
|
||||
} else if (MY_IP4ADDR && strlen(MY_IP4ADDR)) {
|
||||
/* Use setting IP */
|
||||
ret = zperf_get_ipv4_addr(MY_IP4ADDR,
|
||||
&in4_addr_my->sin_addr);
|
||||
|
@ -301,7 +307,12 @@ static void udp_server_session(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (MY_IP6ADDR && strlen(MY_IP6ADDR)) {
|
||||
in6_addr = &net_sin6(&udp_server_addr)->sin6_addr;
|
||||
|
||||
if (!net_ipv6_is_addr_unspecified(in6_addr)) {
|
||||
memcpy(&in6_addr_my->sin6_addr, in6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
} else if (MY_IP6ADDR && strlen(MY_IP6ADDR)) {
|
||||
/* Use setting IP */
|
||||
ret = zperf_get_ipv6_addr(MY_IP6ADDR,
|
||||
MY_PREFIX_LEN_STR,
|
||||
|
@ -441,6 +452,7 @@ int zperf_udp_download(const struct zperf_download_params *param,
|
|||
udp_server_port = param->port;
|
||||
udp_server_running = true;
|
||||
udp_server_stop = false;
|
||||
memcpy(&udp_server_addr, ¶m->addr, sizeof(struct sockaddr));
|
||||
|
||||
k_sem_give(&udp_server_run);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue