wifi: eswifi: Implement listen helper

The listen helper will be used by eswifi socket offload layer.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
This commit is contained in:
Loic Poulain 2022-05-22 19:58:04 +02:00 committed by Carles Cufí
parent 2bcd469ca2
commit 8923fc3186
2 changed files with 20 additions and 0 deletions

View File

@ -140,6 +140,7 @@ int __eswifi_socket_new(struct eswifi_dev *eswifi, int family, int type,
int proto, void *context);
int __eswifi_off_start_client(struct eswifi_dev *eswifi,
struct eswifi_off_socket *socket);
int __eswifi_listen(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket, int backlog);
int __eswifi_accept(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket);
int __eswifi_bind(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket,
const struct sockaddr *addr, socklen_t addrlen);

View File

@ -227,6 +227,25 @@ int __eswifi_off_start_client(struct eswifi_dev *eswifi,
return 0;
}
int __eswifi_listen(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket, int backlog)
{
int err;
__select_socket(eswifi, socket->index);
/* Set backlog */
snprintk(eswifi->buf, sizeof(eswifi->buf), "P8=%d\r", backlog);
err = eswifi_at_cmd(eswifi, eswifi->buf);
if (err < 0) {
LOG_ERR("Unable to start set listen backlog");
err = -EIO;
}
socket->is_server = true;
return 0;
}
int __eswifi_accept(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket)
{
char cmd[] = "P5=1\r";