From 8923fc3186a092035d1c62267a3e44fdb4dcc123 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Sun, 22 May 2022 19:58:04 +0200 Subject: [PATCH] wifi: eswifi: Implement listen helper The listen helper will be used by eswifi socket offload layer. Signed-off-by: Loic Poulain --- drivers/wifi/eswifi/eswifi.h | 1 + drivers/wifi/eswifi/eswifi_socket.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/wifi/eswifi/eswifi.h b/drivers/wifi/eswifi/eswifi.h index b982cc39c64..c9ad9e278c5 100644 --- a/drivers/wifi/eswifi/eswifi.h +++ b/drivers/wifi/eswifi/eswifi.h @@ -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); diff --git a/drivers/wifi/eswifi/eswifi_socket.c b/drivers/wifi/eswifi/eswifi_socket.c index fb142066a7d..97767171adf 100644 --- a/drivers/wifi/eswifi/eswifi_socket.c +++ b/drivers/wifi/eswifi/eswifi_socket.c @@ -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";