drivers: wifi: eswifi: Fully populate sockaddr_in on async msg

Updating the eswifi driver to provide port information (along with
IP / net context) whenever an async message is received. This is
needed to fully populate the "remote" info in "net_context"
required whenever net_context_send is called.

Also adding code to populate "remote" info in "net_context"..

Tested with STM32 disco IOT kit. Fixes #25621

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
This commit is contained in:
Bilal Wasim 2020-05-12 17:35:39 +05:00 committed by Carles Cufí
commit 64d5192f60

View file

@ -484,11 +484,19 @@ void eswifi_offload_async_msg(struct eswifi_dev *eswifi, char *msg, size_t len)
return; return;
} }
sin_addr = &net_sin(&socket->peer_addr)->sin_addr; struct sockaddr_in *peer = net_sin(&socket->peer_addr);
sin_addr = &peer->sin_addr;
memcpy(&sin_addr->s4_addr, ip, 4); memcpy(&sin_addr->s4_addr, ip, 4);
peer->sin_port = htons(port);
socket->state = ESWIFI_SOCKET_STATE_CONNECTED; socket->state = ESWIFI_SOCKET_STATE_CONNECTED;
socket->usage++; socket->usage++;
/* Save information about remote. */
socket->context->flags |= NET_CONTEXT_REMOTE_ADDR_SET;
memcpy(&socket->context->remote, &socket->peer_addr,
sizeof(struct sockaddr));
LOG_DBG("%u.%u.%u.%u connected to port %u", LOG_DBG("%u.%u.%u.%u connected to port %u",
ip[0], ip[1], ip[2], ip[3], port); ip[0], ip[1], ip[2], ip[3], port);