mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
net/: Versions of psock_send() and pock_sendto() should not set errno. That is taken care of at a higher level in the send()/sendto() implementation as appropriate.
This commit is contained in:
@@ -395,8 +395,8 @@ void ieee802154_poll(FAR struct net_driver_s *dev,
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On error,
|
||||||
* -1 is returned, and errno is set appropriately. See sendto()
|
* a negated errno value is retruend. See sendto() for the complete list
|
||||||
* for the complete list of return values.
|
* of return values.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -427,8 +427,8 @@ errout:
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On error,
|
||||||
* -1 is returned, and errno is set appropriately. See sendto()
|
* a negated errno value is retruend. See sendto() for the complete list
|
||||||
* for the complete list of return values.
|
* of return values.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -440,15 +440,13 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
FAR struct radio_driver_s *radio;
|
FAR struct radio_driver_s *radio;
|
||||||
FAR struct ieee802154_conn_s *conn;
|
FAR struct ieee802154_conn_s *conn;
|
||||||
struct ieee802154_sendto_s state;
|
struct ieee802154_sendto_s state;
|
||||||
int errcode;
|
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
if (psock == NULL || psock->s_crefs <= 0)
|
if (psock == NULL || psock->s_crefs <= 0)
|
||||||
{
|
{
|
||||||
errcode = EBADF;
|
return -EBADF;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
|
conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
|
||||||
@@ -460,8 +458,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
if (tolen < sizeof(struct ieee802154_saddr_s))
|
if (tolen < sizeof(struct ieee802154_saddr_s))
|
||||||
{
|
{
|
||||||
errcode = EDESTADDRREQ;
|
return -EDESTADDRREQ;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the device driver that will service this transfer */
|
/* Get the device driver that will service this transfer */
|
||||||
@@ -469,8 +466,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
radio = ieee802154_find_device(conn, &conn->laddr);
|
radio = ieee802154_find_device(conn, &conn->laddr);
|
||||||
if (radio == NULL)
|
if (radio == NULL)
|
||||||
{
|
{
|
||||||
errcode = ENODEV;
|
return -ENODEV;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the socket state to sending */
|
/* Set the socket state to sending */
|
||||||
@@ -548,8 +544,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
if (state.is_sent < 0)
|
if (state.is_sent < 0)
|
||||||
{
|
{
|
||||||
errcode = state.is_sent;
|
return state.is_sent;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
||||||
@@ -558,17 +553,12 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = -ret;
|
return ret;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of bytes actually sent */
|
/* Return the number of bytes actually sent */
|
||||||
|
|
||||||
return state.is_sent;
|
return state.is_sent;
|
||||||
|
|
||||||
errout:
|
|
||||||
set_errno(errcode);
|
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IEEE802154 */
|
#endif /* CONFIG_NET_IEEE802154 */
|
||||||
|
|||||||
+2
-40
@@ -292,46 +292,8 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn);
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On error,
|
||||||
* -1 is returned, and errno is set appropriately:
|
* a negated errno value is retruend. See send() for the complete list
|
||||||
*
|
* of return values.
|
||||||
* EAGAIN or EWOULDBLOCK
|
|
||||||
* The socket is marked non-blocking and the requested operation
|
|
||||||
* would block.
|
|
||||||
* EBADF
|
|
||||||
* An invalid descriptor was specified.
|
|
||||||
* ECONNRESET
|
|
||||||
* Connection reset by peer.
|
|
||||||
* EDESTADDRREQ
|
|
||||||
* The socket is not connection-mode, and no peer address is set.
|
|
||||||
* EFAULT
|
|
||||||
* An invalid user space address was specified for a parameter.
|
|
||||||
* EINTR
|
|
||||||
* A signal occurred before any data was transmitted.
|
|
||||||
* EINVAL
|
|
||||||
* Invalid argument passed.
|
|
||||||
* EISCONN
|
|
||||||
* The connection-mode socket was connected already but a recipient
|
|
||||||
* was specified. (Now either this error is returned, or the recipient
|
|
||||||
* specification is ignored.)
|
|
||||||
* EMSGSIZE
|
|
||||||
* The socket type requires that message be sent atomically, and the
|
|
||||||
* size of the message to be sent made this impossible.
|
|
||||||
* ENOBUFS
|
|
||||||
* The output queue for a network interface was full. This generally
|
|
||||||
* indicates that the interface has stopped sending, but may be
|
|
||||||
* caused by transient congestion.
|
|
||||||
* ENOMEM
|
|
||||||
* No memory available.
|
|
||||||
* ENOTCONN
|
|
||||||
* The socket is not connected, and no target has been given.
|
|
||||||
* ENOTSOCK
|
|
||||||
* The argument s is not a socket.
|
|
||||||
* EPIPE
|
|
||||||
* The local end has been shut down on a connection oriented socket.
|
|
||||||
* In this case the process will also receive a SIGPIPE unless
|
|
||||||
* MSG_NOSIGNAL is set.
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
+7
-55
@@ -1,8 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/pkt/pkt_send.c
|
* net/pkt/pkt_send.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -165,46 +164,8 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On error,
|
||||||
* -1 is returned, and errno is set appropriately:
|
* a negated errno value is retruend. See send() for the complete list
|
||||||
*
|
* of return values.
|
||||||
* EAGAIN or EWOULDBLOCK
|
|
||||||
* The socket is marked non-blocking and the requested operation
|
|
||||||
* would block.
|
|
||||||
* EBADF
|
|
||||||
* An invalid descriptor was specified.
|
|
||||||
* ECONNRESET
|
|
||||||
* Connection reset by peer.
|
|
||||||
* EDESTADDRREQ
|
|
||||||
* The socket is not connection-mode, and no peer address is set.
|
|
||||||
* EFAULT
|
|
||||||
* An invalid user space address was specified for a parameter.
|
|
||||||
* EINTR
|
|
||||||
* A signal occurred before any data was transmitted.
|
|
||||||
* EINVAL
|
|
||||||
* Invalid argument passed.
|
|
||||||
* EISCONN
|
|
||||||
* The connection-mode socket was connected already but a recipient
|
|
||||||
* was specified. (Now either this error is returned, or the recipient
|
|
||||||
* specification is ignored.)
|
|
||||||
* EMSGSIZE
|
|
||||||
* The socket type requires that message be sent atomically, and the
|
|
||||||
* size of the message to be sent made this impossible.
|
|
||||||
* ENOBUFS
|
|
||||||
* The output queue for a network interface was full. This generally
|
|
||||||
* indicates that the interface has stopped sending, but may be
|
|
||||||
* caused by transient congestion.
|
|
||||||
* ENOMEM
|
|
||||||
* No memory available.
|
|
||||||
* ENOTCONN
|
|
||||||
* The socket is not connected, and no target has been given.
|
|
||||||
* ENOTSOCK
|
|
||||||
* The argument s is not a socket.
|
|
||||||
* EPIPE
|
|
||||||
* The local end has been shut down on a connection oriented socket.
|
|
||||||
* In this case the process will also receive a SIGPIPE unless
|
|
||||||
* MSG_NOSIGNAL is set.
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -213,15 +174,13 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
struct send_s state;
|
struct send_s state;
|
||||||
int errcode;
|
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
if (!psock || psock->s_crefs <= 0)
|
if (!psock || psock->s_crefs <= 0)
|
||||||
{
|
{
|
||||||
errcode = EBADF;
|
return -EBADF;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the device driver that will service this transfer */
|
/* Get the device driver that will service this transfer */
|
||||||
@@ -229,8 +188,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
dev = pkt_find_device((FAR struct pkt_conn_s *)psock->s_conn);
|
dev = pkt_find_device((FAR struct pkt_conn_s *)psock->s_conn);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
errcode = ENODEV;
|
return -ENODEV;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the socket state to sending */
|
/* Set the socket state to sending */
|
||||||
@@ -304,8 +262,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
if (state.snd_sent < 0)
|
if (state.snd_sent < 0)
|
||||||
{
|
{
|
||||||
errcode = state.snd_sent;
|
return state.snd_sent;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
||||||
@@ -314,17 +271,12 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = -ret;
|
return ret;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of bytes actually sent */
|
/* Return the number of bytes actually sent */
|
||||||
|
|
||||||
return state.snd_sent;
|
return state.snd_sent;
|
||||||
|
|
||||||
errout:
|
|
||||||
set_errno(errcode);
|
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NET_PKT */
|
#endif /* CONFIG_NET && CONFIG_NET_PKT */
|
||||||
|
|||||||
Reference in New Issue
Block a user