Skip to content

Commit

Permalink
drivers: wifi: eswifi: Fully populate sockaddr_in on async msg
Browse files Browse the repository at this point in the history
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 zephyrproject-rtos#25621

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
  • Loading branch information
bwasim committed May 26, 2020
1 parent 97326c0 commit d0d8162
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/wifi/eswifi/eswifi_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,19 @@ void eswifi_offload_async_msg(struct eswifi_dev *eswifi, char *msg, size_t len)
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);
peer->sin_port = htons(port);
socket->state = ESWIFI_SOCKET_STATE_CONNECTED;
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",
ip[0], ip[1], ip[2], ip[3], port);

Expand Down

0 comments on commit d0d8162

Please sign in to comment.