From a6c986d516b33d2adb64f608a08860fae6479860 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Sat, 26 Mar 2022 16:53:41 +0800 Subject: [PATCH] rpmsg_usrsock: Support the wireless ioctl which contain pointer 2/2 Signed-off-by: zhanghongyu --- netutils/usrsock_rpmsg/usrsock_rpmsg_server.c | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c index 18393d897..6019b507a 100644 --- a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c +++ b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c @@ -35,7 +35,9 @@ #include #include #include - +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL +# include +#endif #include "usrsock_rpmsg.h" struct usrsock_rpmsg_s @@ -712,6 +714,10 @@ static int usrsock_rpmsg_ioctl_handler(struct rpmsg_endpoint *ept, struct usrsock_request_ioctl_s *req = data; struct usrsock_message_datareq_ack_s *ack; struct usrsock_rpmsg_s *priv = priv_; +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL + struct iwreq *wlreq; + struct iwreq *wlack; +#endif int ret = -EBADF; uint32_t len; @@ -719,9 +725,30 @@ static int usrsock_rpmsg_ioctl_handler(struct rpmsg_endpoint *ept, if (req->usockid >= 0 && req->usockid < CONFIG_NETUTILS_USRSOCK_NSOCK_DESCRIPTORS) { - memcpy(ack + 1, req + 1, req->arglen); + memcpy(ack + 1, req + 1, len_ - sizeof(*req)); +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL + wlreq = (struct iwreq *)(req + 1); + wlack = (struct iwreq *)(ack + 1); + if (WL_IS80211POINTERCMD(req->cmd)) + { + wlack->u.data.pointer = wlack + 1; + } +#endif + ret = psock_ioctl(&priv->socks[req->usockid], req->cmd, (unsigned long)(ack + 1)); + +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL + if (WL_IS80211POINTERCMD(req->cmd)) + { + if (ret >= 0) + { + ret = wlreq->u.data.length; + } + + wlack->u.data.pointer = wlreq->u.data.pointer; + } +#endif } return usrsock_rpmsg_send_data_ack(ept,