You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2023/01/11 03:43:28 UTC

[GitHub] [nuttx] ethanlcz commented on a diff in pull request #8022: switch usrsock server's defconfig to upgraded version

ethanlcz commented on code in PR #8022:
URL: https://github.com/apache/nuttx/pull/8022#discussion_r1066546725


##########
drivers/usrsock/usrsock_rpmsg_server.c:
##########
@@ -0,0 +1,1135 @@
+/****************************************************************************
+ * drivers/usrsock/usrsock_rpmsg_server.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <poll.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+
+#include <nuttx/mutex.h>
+#include <nuttx/net/dns.h>
+#include <nuttx/net/net.h>
+#include <nuttx/rptun/openamp.h>
+#include <nuttx/usrsock/usrsock_rpmsg.h>
+#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
+#include <nuttx/wireless/wireless.h>
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct usrsock_rpmsg_s
+{
+  rmutex_t                  mutex;
+  struct iovec              iov[CONFIG_NET_USRSOCK_RPMSG_SERVER_NIOVEC];
+  struct socket             socks[CONFIG_NET_USRSOCK_RPMSG_SERVER_NSOCKS];
+  FAR struct rpmsg_endpoint *epts[CONFIG_NET_USRSOCK_RPMSG_SERVER_NSOCKS];
+  struct pollfd             pfds[CONFIG_NET_USRSOCK_RPMSG_SERVER_NSOCKS];
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static bool usrsock_rpmsg_available(FAR struct socket *psock, int cmd);
+
+static int usrsock_rpmsg_send_ack(FAR struct rpmsg_endpoint *ept,
+                                  uint16_t events,
+                                  uint32_t xid, int32_t result);
+static int usrsock_rpmsg_send_data_ack(FAR struct rpmsg_endpoint *ept,
+                              FAR struct usrsock_message_datareq_ack_s *ack,
+                              uint16_t events,
+                              uint32_t xid, int32_t result,
+                              uint16_t valuelen,
+                              uint16_t valuelen_nontrunc,
+                              int32_t datalen);
+static int usrsock_rpmsg_send_event(FAR struct rpmsg_endpoint *ept,
+                                    int16_t usockid, uint16_t events);
+
+static int usrsock_rpmsg_socket_handler(FAR struct rpmsg_endpoint *ept,
+                                        FAR void *data, size_t len,
+                                        uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_close_handler(FAR struct rpmsg_endpoint *ept,
+                                       FAR void *data, size_t len,
+                                       uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_connect_handler(FAR struct rpmsg_endpoint *ept,
+                                         FAR void *data, size_t len,
+                                         uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_sendto_handler(FAR struct rpmsg_endpoint *ept,
+                                        FAR void *data, size_t len,
+                                        uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_recvfrom_handler(FAR struct rpmsg_endpoint *ept,
+                                          FAR void *data, size_t len,
+                                          uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_setsockopt_handler(FAR struct rpmsg_endpoint *ept,
+                                            FAR void *data, size_t len,
+                                            uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_getsockopt_handler(FAR struct rpmsg_endpoint *ept,
+                                            FAR void *data, size_t len,
+                                            uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_getsockname_handler(FAR struct rpmsg_endpoint *ept,
+                                             FAR void *data, size_t len,
+                                             uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_getpeername_handler(FAR struct rpmsg_endpoint *ept,
+                                             FAR void *data, size_t len,
+                                             uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_bind_handler(FAR struct rpmsg_endpoint *ept,
+                                      FAR void *data, size_t len,
+                                      uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_listen_handler(FAR struct rpmsg_endpoint *ept,
+                                        FAR void *data, size_t len,
+                                        uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_accept_handler(FAR struct rpmsg_endpoint *ept,
+                                        FAR void *data, size_t len,
+                                        uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_ioctl_handler(FAR struct rpmsg_endpoint *ept,
+                                       FAR void *data, size_t len,
+                                       uint32_t src, FAR void *priv_);
+static int usrsock_rpmsg_dns_handler(FAR struct rpmsg_endpoint *ept,
+                                     FAR void *data, size_t len,
+                                     uint32_t src, FAR void *priv_);
+
+static bool usrsock_rpmsg_ns_match(FAR struct rpmsg_device *rdev,
+                                   FAR void *priv_, FAR const char *name,
+                                   uint32_t dest);
+static void usrsock_rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
+                                  FAR void *priv_, FAR const char *name,
+                                  uint32_t dest);
+static void usrsock_rpmsg_ns_unbind(FAR struct rpmsg_endpoint *ept);
+static int usrsock_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept,
+                                FAR void *data, size_t len, uint32_t src,
+                                FAR void *priv);
+
+static void usrsock_rpmsg_poll_cb(FAR struct pollfd *pfds);
+static int usrsock_rpmsg_poll_setup(FAR struct pollfd *pfds,
+                                    pollevent_t events);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const rpmsg_ept_cb g_usrsock_rpmsg_handler[] =
+{
+  [USRSOCK_REQUEST_SOCKET]      = usrsock_rpmsg_socket_handler,

Review Comment:
   > C89 incompatible
   
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org