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 2021/03/03 04:21:19 UTC

[GitHub] [incubator-nuttx] PeterBee97 opened a new pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

PeterBee97 opened a new pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959


   ## Summary
   Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
   the other way round. 
   Multi-iov cases has been handled in Unix domain sockets and inet sockets.
   
   
   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959#discussion_r587505029



##########
File path: net/usrsock/usrsock_sendmsg.c
##########
@@ -191,32 +191,32 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: usrsock_sendto
+ * Name: usrsock_sendmsg
  *
  * Description:
- *   If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
- *   socket, the parameters to and 'tolen' are ignored (and the error EISCONN
- *   may be returned when they are not NULL and 0), and the error ENOTCONN is
- *   returned when the socket was not actually connected.
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
  *
  * Input Parameters:
  *   psock    A reference to the socket structure of the socket
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags (ignored)
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
  *   On success, returns the number of characters sent.  On any failure, a
  *   negated errno value is returned.
  *
  ****************************************************************************/
 
-ssize_t usrsock_sendto(FAR struct socket *psock, FAR const void *buf,
-                       size_t len, int flags, FAR const struct sockaddr *to,
-                       socklen_t tolen)
+ssize_t usrsock_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                       int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;
+  socklen_t tolen = msg->msg_namelen;
+  FAR struct iovec *iov;

Review comment:
       ```suggestion
     FAR const struct iovec *iov;
   ```

##########
File path: net/icmpv6/icmpv6_sendmsg.c
##########
@@ -249,40 +249,58 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: icmpv6_sendto
+ * Name: icmpv6_sendmsg
  *
  * Description:
- *   Implements the sendto() operation for the case of the IPPROTO_ICMP6
+ *   Implements the sendmsg() operation for the case of the IPPROTO_ICMP6
  *   socket.  The 'buf' parameter points to a block of memory that includes
  *   an ICMPv6 request header, followed by any payload that accompanies the
  *   request.  The 'len' parameter includes both the size of the ICMPv6
  *   header and the following payload.
  *
  * Input Parameters:
  *   psock    A pointer to a NuttX-specific, internal socket structure
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
- *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send_to() for the list of appropriate error
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
  ****************************************************************************/
 
-ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf,
-                      size_t len, int flags, FAR const struct sockaddr *to,
-                      socklen_t tolen)
+ssize_t icmpv6_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                       int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/usrsock/usrsock_sendmsg.c
##########
@@ -191,32 +191,32 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: usrsock_sendto
+ * Name: usrsock_sendmsg
  *
  * Description:
- *   If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
- *   socket, the parameters to and 'tolen' are ignored (and the error EISCONN
- *   may be returned when they are not NULL and 0), and the error ENOTCONN is
- *   returned when the socket was not actually connected.
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
  *
  * Input Parameters:
  *   psock    A reference to the socket structure of the socket
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags (ignored)
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
  *   On success, returns the number of characters sent.  On any failure, a
  *   negated errno value is returned.
  *
  ****************************************************************************/
 
-ssize_t usrsock_sendto(FAR struct socket *psock, FAR const void *buf,
-                       size_t len, int flags, FAR const struct sockaddr *to,
-                       socklen_t tolen)
+ssize_t usrsock_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                       int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/local/local_sendpacket.c
##########
@@ -125,9 +125,11 @@ static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf,
  *
  ****************************************************************************/
 
-int local_send_packet(FAR struct file *filep, FAR const uint8_t *buf,
+int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf,
                       size_t len)
 {
+  FAR struct iovec *iov;

Review comment:
       ```suggestion
     FAR const struct iovec *iov;
   ```

##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;
+  socklen_t tolen = msg->msg_namelen;
+  FAR struct iovec *iov;
+  FAR struct iovec *end;

Review comment:
       ```suggestion
     FAR const struct iovec *end;
   ```

##########
File path: net/netlink/netlink_sockif.c
##########
@@ -659,87 +647,68 @@ static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds,
 }
 
 /****************************************************************************
- * Name: netlink_send
+ * Name: netlink_sendmsg
  *
  * Description:
- *   The netlink_send() call may be used only when the socket is in
- *   a connected state  (so that the intended recipient is known).
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
  *
  * Input Parameters:
- *   psock - An instance of the internal socket structure.
- *   buf   - Data to send
- *   len   - Length of data to send
- *   flags - Send flags (ignored)
+ *   psock    A reference to the structure of the socket to be connected
+ *   msg      msg to send
+ *   flags    Send flags (ignored)
  *
  * Returned Value:
  *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send() for the list of appropriate error
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
+ * Assumptions:
+ *
  ****************************************************************************/
 
-static ssize_t netlink_send(FAR struct socket *psock, FAR const void *buf,
-                            size_t len, int flags)
+static ssize_t netlink_sendmsg(FAR struct socket *psock,
+                               FAR struct msghdr *msg, int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/pkt/pkt_sendmsg.c
##########
@@ -135,38 +135,66 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: psock_pkt_send
+ * Name: pkt_sendmsg
  *
  * Description:
- *   The psock_pkt_send() call may be used only when the packet socket is in
+ *   The pkt_sendmsg() call may be used only when the packet socket is in
  *   a connected state (so that the intended recipient is known).
  *
  * Input Parameters:
  *   psock    An instance of the internal socket structure.
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
+ *   flags    Send flags
  *
  * Returned Value:
- *   On success, returns the number of characters sent.  On  error,
- *   a negated errno value is returned.  See send() for the complete list
- *   of return values.
+ *   On success, returns the number of characters sent. On error, a negated
+ *   errno value is returned (see sendmsg() for the complete list of return
+ *   values.
  *
  ****************************************************************************/
 
-ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
-                       size_t len)
+ssize_t pkt_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                    int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/local/local_sendpacket.c
##########
@@ -125,9 +125,11 @@ static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf,
  *
  ****************************************************************************/
 
-int local_send_packet(FAR struct file *filep, FAR const uint8_t *buf,
+int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf,
                       size_t len)
 {
+  FAR struct iovec *iov;
+  FAR struct iovec *end;

Review comment:
       ```suggestion
     FAR const struct iovec *end;
   ```

##########
File path: net/local/local_sendmsg.c
##########
@@ -162,7 +270,46 @@ ssize_t psock_local_sendto(FAR struct socket *psock,
   /* Release our reference to the half duplex FIFO */
 
   local_release_halfduplex(conn);
+
+#else
+  nsent = -EISCONN;
+#endif /* CONFIG_NET_LOCAL_DGRAM */
+
   return nsent;
 }
 
-#endif /* CONFIG_NET && CONFIG_NET_LOCAL_DGRAM */
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: local_sendmsg
+ *
+ * Description:
+ *   Implements the sendmsg() operation for the case of the local Unix socket
+ *
+ * Input Parameters:
+ *   psock    A pointer to a NuttX-specific, internal socket structure
+ *   msg      msg to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                      int flags)
+{
+  FAR void *buf = msg->msg_iov;

Review comment:
       ```suggestion
     FAR const struct iovec *buf = msg->msg_iov;
   ```

##########
File path: net/icmpv6/icmpv6_sendmsg.c
##########
@@ -249,40 +249,58 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: icmpv6_sendto
+ * Name: icmpv6_sendmsg
  *
  * Description:
- *   Implements the sendto() operation for the case of the IPPROTO_ICMP6
+ *   Implements the sendmsg() operation for the case of the IPPROTO_ICMP6
  *   socket.  The 'buf' parameter points to a block of memory that includes
  *   an ICMPv6 request header, followed by any payload that accompanies the
  *   request.  The 'len' parameter includes both the size of the ICMPv6
  *   header and the following payload.
  *
  * Input Parameters:
  *   psock    A pointer to a NuttX-specific, internal socket structure
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
- *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send_to() for the list of appropriate error
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
  ****************************************************************************/
 
-ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf,
-                      size_t len, int flags, FAR const struct sockaddr *to,
-                      socklen_t tolen)
+ssize_t icmpv6_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                       int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/netlink/netlink_sockif.c
##########
@@ -659,87 +647,68 @@ static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds,
 }
 
 /****************************************************************************
- * Name: netlink_send
+ * Name: netlink_sendmsg
  *
  * Description:
- *   The netlink_send() call may be used only when the socket is in
- *   a connected state  (so that the intended recipient is known).
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
  *
  * Input Parameters:
- *   psock - An instance of the internal socket structure.
- *   buf   - Data to send
- *   len   - Length of data to send
- *   flags - Send flags (ignored)
+ *   psock    A reference to the structure of the socket to be connected
+ *   msg      msg to send
+ *   flags    Send flags (ignored)
  *
  * Returned Value:
  *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send() for the list of appropriate error
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
+ * Assumptions:
+ *
  ****************************************************************************/
 
-static ssize_t netlink_send(FAR struct socket *psock, FAR const void *buf,
-                            size_t len, int flags)
+static ssize_t netlink_sendmsg(FAR struct socket *psock,
+                               FAR struct msghdr *msg, int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/pkt/pkt_sockif.c
##########
@@ -341,7 +328,7 @@ static int pkt_bind(FAR struct socket *psock,
 
   if (addr->sa_family != AF_PACKET || addrlen < sizeof(struct sockaddr_ll))
     {
-      nerr("ERROR: Invalid address length: %d < %d\n",
+      nerr("ERROR: Invalid address length: %d < %u\n",

Review comment:
       ```suggestion
         nerr("ERROR: Invalid address length: %d < %z\n",
   ```

##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/icmp/icmp_sendmsg.c
##########
@@ -259,40 +259,58 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: icmp_sendto
+ * Name: icmp_sendmsg
  *
  * Description:
- *   Implements the sendto() operation for the case of the IPPROTO_ICMP
+ *   Implements the sendmsg() operation for the case of the IPPROTO_ICMP
  *   socket.  The 'buf' parameter points to a block of memory that includes
  *   an ICMP request header, followed by any payload that accompanies the
  *   request.  The 'len' parameter includes both the size of the ICMP header
  *   and the following payload.
  *
  * Input Parameters:
  *   psock    A pointer to a NuttX-specific, internal socket structure
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
- *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send_to() for the list of appropriate error
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
  ****************************************************************************/
 
-ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf,
-                    size_t len, int flags, FAR const struct sockaddr *to,
-                    socklen_t tolen)
+ssize_t icmp_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                     int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/ieee802154/ieee802154_sendmsg.c
##########
@@ -538,4 +546,111 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock,
   return state.is_sent;
 }
 
+/****************************************************************************
+ * Name: ieee802154_send
+ *
+ * Description:
+ *   Socket send() method for the PF_IEEE802154 socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
+                               size_t len, int flags)
+{
+  struct sockaddr_ieee802154_s to;
+  FAR struct ieee802154_conn_s *conn;
+  ssize_t ret;
+
+  DEBUGASSERT(psock != NULL || buf != NULL);
+  conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
+  DEBUGASSERT(conn != NULL);
+
+  /* Only SOCK_DGRAM is supported (because the MAC header is stripped) */
+
+  if (psock->s_type == SOCK_DGRAM)
+    {
+      /* send() may be used only if the socket has been connected. */
+
+      if (!_SS_ISCONNECTED(psock->s_flags) ||
+          conn->raddr.s_mode == IEEE802154_ADDRMODE_NONE)
+        {
+          ret = -ENOTCONN;
+        }
+      else
+        {
+          to.sa_family = AF_IEEE802154;
+          memcpy(&to.sa_addr, &conn->raddr,
+                 sizeof(struct ieee802154_saddr_s));
+
+          /* Then perform the send() as sendto() */
+
+          ret = ieee802154_sendto(psock, buf, len, flags,
+                                  (FAR const struct sockaddr *)&to,
+                                  sizeof(struct sockaddr_ieee802154_s));
+        }
+    }
+  else
+    {
+      /* EDESTADDRREQ.  Signifies that the socket is not connection-mode and
+       * no peer address is set.
+       */
+
+      ret = -EDESTADDRREQ;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: ieee802154_sendmsg
+ *
+ * Description:
+ *   Socket sendmsg() method for the PF_IEEE802154 socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+ssize_t ieee802154_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                           int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/ieee802154/ieee802154_sendmsg.c
##########
@@ -538,4 +546,111 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock,
   return state.is_sent;
 }
 
+/****************************************************************************
+ * Name: ieee802154_send
+ *
+ * Description:
+ *   Socket send() method for the PF_IEEE802154 socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
+                               size_t len, int flags)
+{
+  struct sockaddr_ieee802154_s to;
+  FAR struct ieee802154_conn_s *conn;
+  ssize_t ret;
+
+  DEBUGASSERT(psock != NULL || buf != NULL);
+  conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
+  DEBUGASSERT(conn != NULL);
+
+  /* Only SOCK_DGRAM is supported (because the MAC header is stripped) */
+
+  if (psock->s_type == SOCK_DGRAM)
+    {
+      /* send() may be used only if the socket has been connected. */
+
+      if (!_SS_ISCONNECTED(psock->s_flags) ||
+          conn->raddr.s_mode == IEEE802154_ADDRMODE_NONE)
+        {
+          ret = -ENOTCONN;
+        }
+      else
+        {
+          to.sa_family = AF_IEEE802154;
+          memcpy(&to.sa_addr, &conn->raddr,
+                 sizeof(struct ieee802154_saddr_s));
+
+          /* Then perform the send() as sendto() */
+
+          ret = ieee802154_sendto(psock, buf, len, flags,
+                                  (FAR const struct sockaddr *)&to,
+                                  sizeof(struct sockaddr_ieee802154_s));
+        }
+    }
+  else
+    {
+      /* EDESTADDRREQ.  Signifies that the socket is not connection-mode and
+       * no peer address is set.
+       */
+
+      ret = -EDESTADDRREQ;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: ieee802154_sendmsg
+ *
+ * Description:
+ *   Socket sendmsg() method for the PF_IEEE802154 socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+ssize_t ieee802154_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                           int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/local/local_sendmsg.c
##########
@@ -162,7 +270,46 @@ ssize_t psock_local_sendto(FAR struct socket *psock,
   /* Release our reference to the half duplex FIFO */
 
   local_release_halfduplex(conn);
+
+#else
+  nsent = -EISCONN;
+#endif /* CONFIG_NET_LOCAL_DGRAM */
+
   return nsent;
 }
 
-#endif /* CONFIG_NET && CONFIG_NET_LOCAL_DGRAM */
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: local_sendmsg
+ *
+ * Description:
+ *   Implements the sendmsg() operation for the case of the local Unix socket
+ *
+ * Input Parameters:
+ *   psock    A pointer to a NuttX-specific, internal socket structure
+ *   msg      msg to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                      int flags)
+{
+  FAR void *buf = msg->msg_iov;
+  size_t len = msg->msg_iovlen;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/local/local_sendmsg.c
##########
@@ -66,16 +154,36 @@
  *
  ****************************************************************************/
 
-ssize_t psock_local_sendto(FAR struct socket *psock,
-                           FAR const void *buf,
-                           size_t len, int flags,
-                           FAR const struct sockaddr *to,
-                           socklen_t tolen)
+static ssize_t local_sendto(FAR struct socket *psock, FAR const void *buf,

Review comment:
       ```suggestion
   static ssize_t local_sendto(FAR struct socket *psock, FAR const  struct iovec *buf,
   ```

##########
File path: net/local/local_sendmsg.c
##########
@@ -38,11 +38,99 @@
 #include "local/local.h"
 
 /****************************************************************************
- * Public Functions
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: local_send
+ *
+ * Description:
+ *   Send a local packet as a stream.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags (ignored for now)
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error,
+ *   -1 is returned, and errno is set appropriately (see send() for the
+ *   list of errno numbers).
+ *
  ****************************************************************************/
 
+static ssize_t local_send(FAR struct socket *psock, FAR const void *buf,

Review comment:
       ```suggestion
   static ssize_t local_send(FAR struct socket *psock, FAR const  struct iovec *buf,
   ```

##########
File path: net/local/local_sendmsg.c
##########
@@ -162,7 +270,46 @@ ssize_t psock_local_sendto(FAR struct socket *psock,
   /* Release our reference to the half duplex FIFO */
 
   local_release_halfduplex(conn);
+
+#else
+  nsent = -EISCONN;

Review comment:
       ```suggestion
     return -EISCONN;
   ```

##########
File path: net/can/can_sendmsg.c
##########
@@ -60,16 +58,15 @@
 
 struct send_s
 {
-  FAR struct socket      *snd_sock;    /* Points to the parent socket structure */
-  FAR struct devif_callback_s *snd_cb; /* Reference to callback instance */
-  sem_t                   snd_sem;     /* Used to wake up the waiting thread */
-  FAR const uint8_t      *snd_buffer;  /* Points to the buffer of data to send */
-  size_t                  snd_buflen;  /* Number of bytes in the buffer to send */
-#ifdef CONFIG_NET_CMSG
-  size_t                  pr_msglen;   /* Length of msg buffer */
-  FAR uint8_t            *pr_msgbuf;   /* Pointer to msg buffer */
-#endif
-  ssize_t                 snd_sent;    /* The number of bytes sent */
+  FAR struct socket *snd_sock;    /* Points to the parent socket structure */

Review comment:
       why change?

##########
File path: net/local/local_sendpacket.c
##########
@@ -125,9 +125,11 @@ static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf,
  *
  ****************************************************************************/
 
-int local_send_packet(FAR struct file *filep, FAR const uint8_t *buf,
+int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf,
                       size_t len)
 {
+  FAR struct iovec *iov;
+  FAR struct iovec *end;

Review comment:
       and remove the cast at line 143, 144, 155

##########
File path: net/bluetooth/bluetooth_sendmsg.c
##########
@@ -389,4 +396,182 @@ ssize_t psock_bluetooth_sendto(FAR struct socket *psock, FAR const void *buf,
   return ret;
 }
 
+/****************************************************************************
+ * Name: bluetooth_l2cap_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket over BTPROTO_L2CAP.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_l2cap_send(FAR struct socket *psock,
+                                    FAR const void *buf,
+                                    size_t len, int flags)
+{
+  struct sockaddr_l2 to;
+  FAR struct bluetooth_conn_s *conn;
+  ssize_t ret;
+
+  conn = (FAR struct bluetooth_conn_s *)psock->s_conn;
+  DEBUGASSERT(conn != NULL);
+
+  if (!_SS_ISCONNECTED(psock->s_flags))
+    {
+      ret = -ENOTCONN;
+    }
+  else
+    {
+      to.l2_family = AF_BLUETOOTH;
+      memcpy(&to.l2_bdaddr, &conn->bc_raddr, sizeof(bt_addr_t));
+      to.l2_cid = conn->bc_channel;
+
+      /* Then perform the send() as sendto() */
+
+      ret = bluetooth_sendto(psock, buf, len, flags,
+                             (FAR const struct sockaddr *)&to,
+                             sizeof(struct sockaddr_l2));
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: bluetooth_hci_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket over BTPROTO_HCI.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_hci_send(FAR struct socket *psock,
+                                  FAR const void *buf,
+                                  size_t len, int flags)
+{
+  /* We only support sendto() for HCI sockets */
+
+  return -EPFNOSUPPORT;
+}
+
+/****************************************************************************
+ * Name: bluetooth_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_send(FAR struct socket *psock, FAR const void *buf,
+                              size_t len, int flags)
+{
+  ssize_t ret;
+
+  DEBUGASSERT(psock != NULL || buf != NULL);
+
+  /* Only SOCK_RAW is supported */
+
+  if (psock->s_type == SOCK_RAW)
+    {
+      switch (psock->s_proto)
+        {
+          case BTPROTO_L2CAP:
+            {
+              ret = bluetooth_l2cap_send(psock, buf, len, flags);
+              break;
+            }
+
+          case BTPROTO_HCI:
+            {
+              ret = bluetooth_hci_send(psock, buf, len, flags);
+              break;
+            }
+
+          default:
+            ret = -EPFNOSUPPORT;
+        }
+    }
+  else
+    {
+      ret = -EINVAL;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: bluetooth_sendmsg
+ *
+ * Description:
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
+ *
+ * Input Parameters:
+ *   psock    A pointer to a NuttX-specific, internal socket structure
+ *   msg      data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On error,
+ *   a negated errno value is returned.  See sendmsg() for the complete list
+ *   of return values.
+ *
+ ****************************************************************************/
+
+ssize_t bluetooth_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                          int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;
+  size_t len = msg->msg_iov->iov_len;
+  FAR struct sockaddr *to = msg->msg_name;

Review comment:
       ```suggestion
     FAR const struct sockaddr *to = msg->msg_name;
   ```

##########
File path: net/bluetooth/bluetooth_sendmsg.c
##########
@@ -389,4 +396,182 @@ ssize_t psock_bluetooth_sendto(FAR struct socket *psock, FAR const void *buf,
   return ret;
 }
 
+/****************************************************************************
+ * Name: bluetooth_l2cap_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket over BTPROTO_L2CAP.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_l2cap_send(FAR struct socket *psock,
+                                    FAR const void *buf,
+                                    size_t len, int flags)
+{
+  struct sockaddr_l2 to;
+  FAR struct bluetooth_conn_s *conn;
+  ssize_t ret;
+
+  conn = (FAR struct bluetooth_conn_s *)psock->s_conn;
+  DEBUGASSERT(conn != NULL);
+
+  if (!_SS_ISCONNECTED(psock->s_flags))
+    {
+      ret = -ENOTCONN;
+    }
+  else
+    {
+      to.l2_family = AF_BLUETOOTH;
+      memcpy(&to.l2_bdaddr, &conn->bc_raddr, sizeof(bt_addr_t));
+      to.l2_cid = conn->bc_channel;
+
+      /* Then perform the send() as sendto() */
+
+      ret = bluetooth_sendto(psock, buf, len, flags,
+                             (FAR const struct sockaddr *)&to,
+                             sizeof(struct sockaddr_l2));
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: bluetooth_hci_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket over BTPROTO_HCI.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_hci_send(FAR struct socket *psock,
+                                  FAR const void *buf,
+                                  size_t len, int flags)
+{
+  /* We only support sendto() for HCI sockets */
+
+  return -EPFNOSUPPORT;
+}
+
+/****************************************************************************
+ * Name: bluetooth_send
+ *
+ * Description:
+ *   Socket send() method for the PF_BLUETOOTH socket.
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   buf      Data to send
+ *   len      Length of data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see send() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t bluetooth_send(FAR struct socket *psock, FAR const void *buf,
+                              size_t len, int flags)
+{
+  ssize_t ret;
+
+  DEBUGASSERT(psock != NULL || buf != NULL);
+
+  /* Only SOCK_RAW is supported */
+
+  if (psock->s_type == SOCK_RAW)
+    {
+      switch (psock->s_proto)
+        {
+          case BTPROTO_L2CAP:
+            {
+              ret = bluetooth_l2cap_send(psock, buf, len, flags);
+              break;
+            }
+
+          case BTPROTO_HCI:
+            {
+              ret = bluetooth_hci_send(psock, buf, len, flags);
+              break;
+            }
+
+          default:
+            ret = -EPFNOSUPPORT;
+        }
+    }
+  else
+    {
+      ret = -EINVAL;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: bluetooth_sendmsg
+ *
+ * Description:
+ *   If sendmsg() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
+ *   socket, the parameters 'msg_name' and 'msg_namelen' are ignored (and the
+ *   error EISCONN may be returned when they are not NULL and 0), and the
+ *   error ENOTCONN is returned when the socket was not actually connected.
+ *
+ * Input Parameters:
+ *   psock    A pointer to a NuttX-specific, internal socket structure
+ *   msg      data to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On error,
+ *   a negated errno value is returned.  See sendmsg() for the complete list
+ *   of return values.
+ *
+ ****************************************************************************/
+
+ssize_t bluetooth_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                          int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```

##########
File path: net/icmp/icmp_sendmsg.c
##########
@@ -259,40 +259,58 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: icmp_sendto
+ * Name: icmp_sendmsg
  *
  * Description:
- *   Implements the sendto() operation for the case of the IPPROTO_ICMP
+ *   Implements the sendmsg() operation for the case of the IPPROTO_ICMP
  *   socket.  The 'buf' parameter points to a block of memory that includes
  *   an ICMP request header, followed by any payload that accompanies the
  *   request.  The 'len' parameter includes both the size of the ICMP header
  *   and the following payload.
  *
  * Input Parameters:
  *   psock    A pointer to a NuttX-specific, internal socket structure
- *   buf      Data to send
- *   len      Length of data to send
+ *   msg      Message to send
  *   flags    Send flags
- *   to       Address of recipient
- *   tolen    The length of the address structure
  *
  * Returned Value:
- *   On success, returns the number of characters sent.  On  error, a negated
- *   errno value is returned (see send_to() for the list of appropriate error
+ *   On success, returns the number of characters sent.  On error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
  *   values.
  *
  ****************************************************************************/
 
-ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf,
-                    size_t len, int flags, FAR const struct sockaddr *to,
-                    socklen_t tolen)
+ssize_t icmp_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
+                     int flags)
 {
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       ```suggestion
     FAR const void *buf = msg->msg_iov->iov_base;
   ```




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959#discussion_r588172189



##########
File path: net/pkt/pkt_sockif.c
##########
@@ -341,7 +328,7 @@ static int pkt_bind(FAR struct socket *psock,
 
   if (addr->sa_family != AF_PACKET || addrlen < sizeof(struct sockaddr_ll))
     {
-      nerr("ERROR: Invalid address length: %d < %d\n",
+      nerr("ERROR: Invalid address length: %d < %u\n",

Review comment:
       Yes, you are right.




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] PeterBee97 commented on a change in pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
PeterBee97 commented on a change in pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959#discussion_r588174617



##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       The buf pointer is reused in the temporary support for multi-iov memcpy below, should we use another pointer or keep it as-is for now?




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] PeterBee97 commented on a change in pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
PeterBee97 commented on a change in pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959#discussion_r588166980



##########
File path: net/pkt/pkt_sockif.c
##########
@@ -341,7 +328,7 @@ static int pkt_bind(FAR struct socket *psock,
 
   if (addr->sa_family != AF_PACKET || addrlen < sizeof(struct sockaddr_ll))
     {
-      nerr("ERROR: Invalid address length: %d < %d\n",
+      nerr("ERROR: Invalid address length: %d < %u\n",

Review comment:
       zu?




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2959: net/socket: move si_send/recv into sendmsg/recvmsg

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2959:
URL: https://github.com/apache/incubator-nuttx/pull/2959#discussion_r588256892



##########
File path: net/inet/inet_sockif.c
##########
@@ -1224,6 +1222,68 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
   return nsent;
 }
 
+/****************************************************************************
+ * Name: inet_sendmsg
+ *
+ * Description:
+ *   The inet_send() call may be used only when the socket is in a connected
+ *   state  (so that the intended recipient is known).
+ *
+ * Input Parameters:
+ *   psock    An instance of the internal socket structure.
+ *   msg      Message to send
+ *   flags    Send flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters sent.  On  error, a negated
+ *   errno value is returned (see sendmsg() for the list of appropriate error
+ *   values.
+ *
+ ****************************************************************************/
+
+static ssize_t inet_sendmsg(FAR struct socket *psock,
+                            FAR struct msghdr *msg, int flags)
+{
+  FAR void *buf = msg->msg_iov->iov_base;

Review comment:
       Ok, let's keep it as before.




----------------------------------------------------------------
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.

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