2017-08-19 16:48:52 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/socket/ieee802154_recvfrom.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <arch/irq.h>
|
|
|
|
|
|
|
|
#include <nuttx/clock.h>
|
|
|
|
#include <nuttx/semaphore.h>
|
2017-08-26 18:00:47 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
2017-08-19 16:48:52 +02:00
|
|
|
#include <nuttx/net/net.h>
|
2017-08-20 15:10:48 +02:00
|
|
|
#include <nuttx/net/radiodev.h>
|
2017-08-19 16:48:52 +02:00
|
|
|
#include <netpacket/ieee802154.h>
|
|
|
|
|
|
|
|
#include "netdev/netdev.h"
|
|
|
|
#include "devif/devif.h"
|
|
|
|
#include "socket/socket.h"
|
|
|
|
#include "ieee802154/ieee802154.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IEEE802154
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct ieee802154_recvfrom_s
|
|
|
|
{
|
2017-08-20 02:50:50 +02:00
|
|
|
FAR struct socket *ir_sock; /* Points to the parent socket structure */
|
2017-08-19 16:48:52 +02:00
|
|
|
FAR struct devif_callback_s *ir_cb; /* Reference to callback instance */
|
2017-08-20 02:50:50 +02:00
|
|
|
FAR struct sockaddr *ir_from; /* Location to return the from address */
|
|
|
|
FAR uint8_t *ir_buffer; /* Pointer to receive buffer */
|
|
|
|
size_t ir_buflen; /* Length of receive buffer */
|
|
|
|
sem_t ir_sem; /* Semaphore signals recv completion */
|
|
|
|
ssize_t ir_result; /* Success:size, failure:negated errno */
|
2017-08-19 16:48:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-21 16:18:53 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: ieee802154_count_frames
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the number of frames in the RX queue.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-08-21 16:18:53 +02:00
|
|
|
* conn - The socket connection structure.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2017-08-21 16:18:53 +02:00
|
|
|
* The number of frames in the queue.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_DEBUG_ASSERTIONS) && CONFIG_NET_IEEE802154_BACKLOG > 0
|
|
|
|
static int ieee802154_count_frames(FAR struct ieee802154_conn_s *conn)
|
|
|
|
{
|
|
|
|
FAR struct ieee802154_container_s *container;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
for (count = 0, container = conn->rxhead;
|
|
|
|
container != NULL;
|
|
|
|
count++, container = container->ic_flink)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-08-19 16:48:52 +02:00
|
|
|
/****************************************************************************
|
2017-08-20 02:50:50 +02:00
|
|
|
* Name: ieee802154_recvfrom_sender
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2017-08-20 02:50:50 +02:00
|
|
|
* Perform the reception operation if there are any queued frames in the
|
|
|
|
* RX frame queue.
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2017-08-20 02:50:50 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is lockec
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
static ssize_t ieee802154_recvfrom_rxqueue(FAR struct radio_driver_s *radio,
|
|
|
|
FAR struct ieee802154_recvfrom_s *pstate)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
2017-08-20 02:50:50 +02:00
|
|
|
FAR struct ieee802154_container_s *container;
|
|
|
|
FAR struct sockaddr_ieee802154_s *iaddr;
|
|
|
|
FAR struct ieee802154_conn_s *conn;
|
|
|
|
FAR struct iob_s *iob;
|
|
|
|
size_t copylen;
|
|
|
|
int ret = -EAGAIN;
|
|
|
|
|
|
|
|
/* Check if there is anyting in in the RX input queue */
|
|
|
|
|
|
|
|
DEBUGASSERT(pstate != NULL && pstate->ir_sock != NULL);
|
|
|
|
conn = (FAR struct ieee802154_conn_s *)pstate->ir_sock->s_conn;
|
|
|
|
DEBUGASSERT(conn != NULL);
|
|
|
|
|
|
|
|
if (conn->rxhead != NULL)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Remove the container from the RX input queue. */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
container = conn->rxhead;
|
|
|
|
DEBUGASSERT(container != NULL);
|
|
|
|
conn->rxhead = container->ic_flink;
|
|
|
|
container->ic_flink = NULL;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Did the RX queue become empty? */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
if (conn->rxhead == NULL)
|
|
|
|
{
|
|
|
|
conn->rxtail = NULL;
|
|
|
|
}
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-21 15:52:43 +02:00
|
|
|
#if CONFIG_NET_IEEE802154_BACKLOG > 0
|
2019-07-03 02:02:23 +02:00
|
|
|
/* Decrement the count of frames in the queue. */
|
2017-08-21 15:52:43 +02:00
|
|
|
|
2019-07-03 02:02:23 +02:00
|
|
|
DEBUGASSERT(conn->backlog > 0);
|
|
|
|
conn->backlog--;
|
|
|
|
DEBUGASSERT((int)conn->backlog == ieee802154_count_frames(conn));
|
2017-08-21 15:52:43 +02:00
|
|
|
#endif
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Extract the IOB containing the frame from the container */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
iob = container->ic_iob;
|
|
|
|
container->ic_iob = NULL;
|
|
|
|
DEBUGASSERT(iob != NULL);
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Copy the new packet data into the user buffer */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
copylen = iob->io_len - iob->io_offset;
|
|
|
|
memcpy(pstate->ir_buffer, &iob->io_data[iob->io_offset], copylen);
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
ninfo("Received %d bytes\n", (int)copylen);
|
|
|
|
ret = copylen;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* If a 'from' address poiner was supplied, copy the source address
|
|
|
|
* in the container there.
|
|
|
|
*/
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
if (pstate->ir_from != NULL)
|
|
|
|
{
|
|
|
|
iaddr = (FAR struct sockaddr_ieee802154_s *)pstate->ir_from;
|
|
|
|
iaddr->sa_family = AF_IEEE802154;
|
2019-10-25 19:31:42 +02:00
|
|
|
memcpy(&iaddr->sa_addr, &container->ic_src,
|
|
|
|
sizeof(struct ieee802154_saddr_s));
|
2017-08-20 02:50:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free both the IOB and the container */
|
|
|
|
|
2019-08-17 00:42:25 +02:00
|
|
|
iob_free(iob, IOBUSER_NET_SOCK_IEEE802154);
|
2017-08-20 02:50:50 +02:00
|
|
|
ieee802154_container_free(container);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-08-29 22:08:04 +02:00
|
|
|
* Name: ieee802154_recvfrom_eventhandler
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-20 02:50:50 +02:00
|
|
|
* The network is locked.
|
2017-08-19 16:48:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-29 22:08:04 +02:00
|
|
|
static uint16_t ieee802154_recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
|
|
|
FAR void *pvconn,
|
|
|
|
FAR void *pvpriv,
|
|
|
|
uint16_t flags)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
|
|
|
FAR struct ieee802154_recvfrom_s *pstate;
|
|
|
|
FAR struct radio_driver_s *radio;
|
2017-08-20 02:50:50 +02:00
|
|
|
ssize_t ret;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
|
|
|
ninfo("flags: %04x\n", flags);
|
|
|
|
|
|
|
|
DEBUGASSERT(pvpriv != NULL && dev != NULL && pvconn != NULL);
|
|
|
|
|
|
|
|
/* Ignore polls from non IEEE 802.15.4 network drivers */
|
|
|
|
|
|
|
|
if (dev->d_lltype != NET_LL_IEEE802154)
|
|
|
|
{
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that this is the driver to which the socket is bound. */
|
2019-10-25 19:31:42 +02:00
|
|
|
|
2017-08-19 16:48:52 +02:00
|
|
|
#warning Missing logic
|
|
|
|
|
|
|
|
pstate = (FAR struct ieee802154_recvfrom_s *)pvpriv;
|
|
|
|
radio = (FAR struct radio_driver_s *)dev;
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* 'pstate' might be null in some race conditions (?) */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
if (pstate != NULL)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
|
|
|
/* If a new packet is available, then complete the read action. */
|
|
|
|
|
|
|
|
if ((flags & IEEE802154_NEWDATA) != 0)
|
|
|
|
{
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Attempt to receive the frame */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
ret = ieee802154_recvfrom_rxqueue(radio, pstate);
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
/* Don't allow any further call backs. */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
pstate->ir_cb->flags = 0;
|
|
|
|
pstate->ir_cb->priv = NULL;
|
|
|
|
pstate->ir_cb->event = NULL;
|
|
|
|
pstate->ir_result = ret;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* indicate that the data has been consumed */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
flags &= ~IEEE802154_NEWDATA;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Wake up the waiting thread, returning the number of bytes
|
|
|
|
* actually read.
|
|
|
|
*/
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-10-03 23:35:24 +02:00
|
|
|
nxsem_post(&pstate->ir_sem);
|
2017-08-20 02:50:50 +02:00
|
|
|
}
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ieee802154_recvfrom
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Implements the socket recvfrom interface for the case of the AF_INET
|
|
|
|
* and AF_INET6 address families. ieee802154_recvfrom() receives messages from
|
|
|
|
* a socket, and may be used to receive data on a socket whether or not it
|
|
|
|
* is connection-oriented.
|
|
|
|
*
|
|
|
|
* If 'from' is not NULL, and the underlying protocol provides the source
|
|
|
|
* address, this source address is filled in. The argument 'fromlen' is
|
|
|
|
* initialized to the size of the buffer associated with from, and
|
|
|
|
* modified on return to indicate the actual size of the address stored
|
|
|
|
* there.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-08-19 16:48:52 +02:00
|
|
|
* psock A pointer to a NuttX-specific, internal socket structure
|
|
|
|
* buf Buffer to receive data
|
|
|
|
* len Length of buffer
|
|
|
|
* flags Receive flags
|
|
|
|
* from Address of source (may be NULL)
|
|
|
|
* fromlen The length of the address structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, returns the number of characters received. If no data is
|
|
|
|
* available to be received and the peer has performed an orderly shutdown,
|
|
|
|
* recv() will return 0. Otherwise, on errors, a negated errno value is
|
|
|
|
* returned (see recvfrom() for the list of appropriate error values).
|
|
|
|
*
|
2017-08-20 02:50:50 +02:00
|
|
|
* Assumptions:
|
|
|
|
* The network is locked.
|
|
|
|
*
|
2017-08-19 16:48:52 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
ssize_t ieee802154_recvfrom(FAR struct socket *psock, FAR void *buf,
|
|
|
|
size_t len, int flags, FAR struct sockaddr *from,
|
|
|
|
FAR socklen_t *fromlen)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
|
|
|
FAR struct ieee802154_conn_s *conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
|
|
|
|
FAR struct radio_driver_s *radio;
|
|
|
|
struct ieee802154_recvfrom_s state;
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
/* If a 'from' address has been provided, verify that it is large
|
|
|
|
* enough to hold this address family.
|
|
|
|
*/
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
if (from != NULL && *fromlen < sizeof(struct sockaddr_ieee802154_s))
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (psock->s_type != SOCK_DGRAM)
|
|
|
|
{
|
|
|
|
nerr("ERROR: Unsupported socket type: %d\n", psock->s_type);
|
2017-08-20 02:50:50 +02:00
|
|
|
return -EPROTONOSUPPORT;
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform the packet recvfrom() operation */
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Initialize the state structure. This is done with the network
|
|
|
|
* locked because we don't want anything to happen until we are ready.
|
2017-08-19 16:48:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
net_lock();
|
2017-08-20 02:50:50 +02:00
|
|
|
memset(&state, 0, sizeof(struct ieee802154_recvfrom_s));
|
|
|
|
|
|
|
|
state.ir_buflen = len;
|
|
|
|
state.ir_buffer = buf;
|
|
|
|
state.ir_sock = psock;
|
|
|
|
state.ir_from = from;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
|
|
|
/* Get the device driver that will service this transfer */
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
radio = ieee802154_find_device(conn, &conn->laddr);
|
2017-08-19 16:48:52 +02:00
|
|
|
if (radio == NULL)
|
|
|
|
{
|
|
|
|
ret = -ENODEV;
|
2017-08-20 02:50:50 +02:00
|
|
|
goto errout_with_lock;
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Before we wait for data, let's check if there are already frame(s)
|
|
|
|
* waiting in the RX queue.
|
2017-08-19 16:48:52 +02:00
|
|
|
*/
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
ret = ieee802154_recvfrom_rxqueue(radio, &state);
|
|
|
|
if (ret > 0)
|
2017-08-19 16:48:52 +02:00
|
|
|
{
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Good newe! We have a frame and we are done. */
|
|
|
|
|
|
|
|
net_unlock();
|
|
|
|
return ret;
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
2017-08-20 02:50:50 +02:00
|
|
|
|
|
|
|
/* We will have to wait. This semaphore is used for signaling and,
|
|
|
|
* hence, should not have priority inheritance enabled.
|
|
|
|
*/
|
|
|
|
|
2017-10-03 20:51:15 +02:00
|
|
|
(void)nxsem_init(&state.ir_sem, 0, 0); /* Doesn't really fail */
|
2017-10-03 23:35:24 +02:00
|
|
|
(void)nxsem_setprotocol(&state.ir_sem, SEM_PRIO_NONE);
|
2017-08-19 16:48:52 +02:00
|
|
|
|
|
|
|
/* Set up the callback in the connection */
|
|
|
|
|
|
|
|
state.ir_cb = ieee802154_callback_alloc(&radio->r_dev, conn);
|
|
|
|
if (state.ir_cb)
|
|
|
|
{
|
|
|
|
state.ir_cb->flags = (IEEE802154_NEWDATA | IEEE802154_POLL);
|
|
|
|
state.ir_cb->priv = (FAR void *)&state;
|
2017-08-29 22:08:04 +02:00
|
|
|
state.ir_cb->event = ieee802154_recvfrom_eventhandler;
|
2017-08-19 16:48:52 +02:00
|
|
|
|
|
|
|
/* Wait for either the receive to complete or for an error/timeout to
|
|
|
|
* occur. NOTES: (1) net_lockedwait will also terminate if a signal
|
2017-08-20 02:50:50 +02:00
|
|
|
* is received, (2) the network is locked! It will be un-locked while
|
|
|
|
* the task sleeps and automatically re-locked when the task restarts.
|
2017-08-19 16:48:52 +02:00
|
|
|
*/
|
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
(void)net_lockedwait(&state.ir_sem);
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
/* Make sure that no further events are processed */
|
2017-08-19 16:48:52 +02:00
|
|
|
|
|
|
|
ieee802154_callback_free(&radio->r_dev, conn, state.ir_cb);
|
2017-08-20 02:50:50 +02:00
|
|
|
ret = state.ir_result;
|
2017-08-19 16:48:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = -EBUSY;
|
|
|
|
}
|
|
|
|
|
2017-10-03 23:35:24 +02:00
|
|
|
nxsem_destroy(&state.ir_sem);
|
2017-08-19 16:48:52 +02:00
|
|
|
|
2017-08-20 02:50:50 +02:00
|
|
|
errout_with_lock:
|
2017-08-19 16:48:52 +02:00
|
|
|
net_unlock();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_IEEE802154 */
|