PF_IEEE802154: With this commit PF_IEEE802154 address family is basically functional. More testing is needed, of course.

This commit is contained in:
Gregory Nutt
2017-08-19 18:50:50 -06:00
parent d00a37ee5a
commit b52034ffd2
15 changed files with 670 additions and 344 deletions
+1 -1
View File
@@ -1304,7 +1304,7 @@ Configuration sub-directories
Then, on subsequent testing, it "magically" started behaving
properaly and seems quite stable now.. although I did nothing to
the the problem. Perhaps the radio was in a bad state for awhile;
solve the problem. Perhaps the radio was in a bad state for awhile;
perhaps something I did masked the problem. However, all is well
for the time being.
+5
View File
@@ -836,6 +836,11 @@ pf_ieee802154
the IEEE 802.15.4 loopback network driver and the test at
apps/examples/pf_ieee802154.
Basic usage example:
nsh> pfserver ab:cd &
nsh> pfclient ab:cd
pktradio
This configuration is identical to the 'sixlowpan configuration
+2 -2
View File
@@ -87,7 +87,7 @@ struct ieee802154_data_ind_s; /* Forward reference */
struct iob_s; /* Forward reference */
int ieee802154_input(FAR struct radio_driver_s *radio,
FAR struct iob_s *framelist,
FAR const struct ieee802154_data_ind_s *meta);
FAR struct iob_s *framelist,
FAR struct ieee802154_data_ind_s *meta);
#endif /* __INCLUDE_NUTTX_NET_IEEE802154_H */
+1 -1
View File
@@ -259,7 +259,7 @@ static int devif_poll_ieee802154_connections(FAR struct net_driver_s *dev,
/* Traverse all of the allocated packet connections and perform the poll action */
while (!bstop && (ieee802154_conn = ieee802154_nextconn(ieee802154_conn)))
while (!bstop && (ieee802154_conn = ieee802154_conn_next(ieee802154_conn)))
{
/* Perform the packet TX poll */
+8 -1
View File
@@ -24,7 +24,14 @@ if NET_IEEE802154
config NET_IEEE802154_NCONNS
int "Max IEEE 802.15.4 sockets"
default 1
default 4
config NET_IEEE802154_NCONTAINERS
int "Number of pre-allocated frame containers"
default 20
---help---
This specifies the total number of preallocated frame containers.
One must be allocated with each incoming frame.
endif # NET_IEEE802154
endmenu # IEEE 802.15.4 Socket Support
+11 -6
View File
@@ -37,19 +37,24 @@
ifeq ($(CONFIG_NET_IEEE802154),y)
# Initialization / resource managment
NET_CSRCS += ieee802154_initialize.c
NET_CSRCS += ieee802154_conn.c
NET_CSRCS += ieee802154_container.c
# Socket layer
SOCK_CSRCS += ieee802154_sockif.c
SOCK_CSRCS += ieee802154_sendto.c
SOCK_CSRCS += ieee802154_recvfrom.c
# Transport layer
# Device interface
NET_CSRCS += ieee802154_conn.c
NET_CSRCS += ieee802154_input.c
NET_CSRCS += ieee802154_callback.c
NET_CSRCS += ieee802154_poll.c
NET_CSRCS += ieee802154_finddev.c
NET_CSRCS += ieee802154_input.c
NET_CSRCS += ieee802154_callback.c
NET_CSRCS += ieee802154_poll.c
NET_CSRCS += ieee802154_finddev.c
# Include packet socket build support
+125 -15
View File
@@ -59,20 +59,44 @@
#define ieee802154_callback_free(dev,conn,cb) \
devif_conn_callback_free(dev, cb, &conn->list)
/* Memory Pools */
#define IEEE802154_POOL_PREALLOCATED 0
#define IEEE802154_POOL_DYNAMIC 1
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* Used for containing and queuing IOBs along with information about the
* source of the frame.
*/
struct iob_s; /* Forward reference */
struct ieee802154_container_s
{
FAR struct ieee802154_container_s *ic_flink; /* Supports a singly linked list */
struct ieee802154_saddr_s ic_src; /* Source of the packet */
FAR struct iob_s *ic_iob; /* Contained IOB */
uint8_t ic_pool; /* See IEEE802154_POOL_* definitions */
};
/* Representation of a IEEE 802.15.4 socket connection */
struct devif_callback_s; /* Forward reference */
struct devif_callback_s; /* Forward reference */
struct ieee802154_conn_s
{
dq_entry_t node; /* Supports a double linked list */
struct ieee802154_saddr_s laddr; /* Locally bound / source address */
struct ieee802154_saddr_s raddr; /* Connected remote address */
uint8_t crefs; /* Reference counts on this instance */
dq_entry_t node; /* Supports a double linked list */
struct ieee802154_saddr_s laddr; /* Locally bound / source address */
struct ieee802154_saddr_s raddr; /* Connected remote address */
uint8_t crefs; /* Reference counts on this instance */
/* List of incoming packets */
FAR struct ieee802154_container_s *rxhead;
FAR struct ieee802154_container_s *rxtail;
/* This is a list of IEEE 802.15.4 callbacks. Each callback represents
* a thread that is stalled, waiting for a device-specific event.
@@ -112,15 +136,32 @@ struct sockaddr; /* Forward reference */
* Name: ieee802154_initialize()
*
* Description:
* Initialize the IEEE 802.15.4 socket connection structures. Called
* once and only from the network initialization logic.
* Initialize the IEEE 802.15.4 socket support. Called once and only
* from the network initialization logic.
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_initialize(void);
/****************************************************************************
* Name: ieee802154_alloc()
* Name: ieee802154_conn_initialize
*
* Description:
* Initialize the IEEE 802.15.5 connection structure allocator. Called
* once and only from ieee802154_initialize().
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_conn_initialize(void);
/****************************************************************************
* Name: ieee802154_conn_alloc()
*
* Description:
* Allocate a new, uninitialized IEEE 802.15.4 socket connection
@@ -129,10 +170,10 @@ void ieee802154_initialize(void);
*
****************************************************************************/
FAR struct ieee802154_conn_s *ieee802154_alloc(void);
FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void);
/****************************************************************************
* Name: ieee802154_free()
* Name: ieee802154_conn_free()
*
* Description:
* Free a IEEE 802.15.4 socket connection structure that is no longer in
@@ -140,10 +181,10 @@ FAR struct ieee802154_conn_s *ieee802154_alloc(void);
*
****************************************************************************/
void ieee802154_free(FAR struct ieee802154_conn_s *conn);
void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn);
/****************************************************************************
* Name: ieee802154_active()
* Name: ieee802154_conn_active()
*
* Description:
* Find a connection structure that is the appropriate
@@ -155,10 +196,10 @@ void ieee802154_free(FAR struct ieee802154_conn_s *conn);
****************************************************************************/
FAR struct ieee802154_conn_s *
ieee802154_active(FAR const struct ieee802154_data_ind_s *meta);
ieee802154_conn_active(FAR const struct ieee802154_data_ind_s *meta);
/****************************************************************************
* Name: ieee802154_nextconn()
* Name: ieee802154_conn_next()
*
* Description:
* Traverse the list of allocated IEEE 802.15.4 connections
@@ -169,7 +210,7 @@ FAR struct ieee802154_conn_s *
****************************************************************************/
FAR struct ieee802154_conn_s *
ieee802154_nextconn(FAR struct ieee802154_conn_s *conn);
ieee802154_conn_next(FAR struct ieee802154_conn_s *conn);
/****************************************************************************
* Name: ieee802154_input
@@ -339,6 +380,75 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock,
size_t len, int flags,
FAR const struct sockaddr *to, socklen_t tolen);
/****************************************************************************
* Name: ieee802154_container_initialize
*
* Description:
* This function initializes the container allocator. This function must
* be called early in the initialization sequence before any socket
* activity.
*
* Inputs:
* None
*
* Return Value:
* None
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_container_initialize(void);
/****************************************************************************
* Name: ieee802154_container_allocate
*
* Description:
* The ieee802154_container_allocate function will get a free continer
* for use by the recvfrom() logic.
*
* This function will first attempt to allocate from the g_free_container
* list. If that the list is empty, then the meta-data structure will be
* allocated from the dynamic memory pool.
*
* Inputs:
* None
*
* Return Value:
* A reference to the allocated container structure. All user fields in this
* structure have been zeroed. On a failure to allocate, NULL is
* returned.
*
* Assumptions:
* The caller has locked the network.
*
****************************************************************************/
FAR struct ieee802154_container_s *ieee802154_container_allocate(void);
/****************************************************************************
* Name: ieee802154_container_free
*
* Description:
* The ieee802154_container_free function will return a container structure
* to the free list of containers if it was a pre-allocated container
* structure. If the container structure was allocated dynamically it will
* be deallocated.
*
* Inputs:
* container - container structure to free
*
* Return Value:
* None
*
* Assumptions:
* The caller has locked the network.
*
****************************************************************************/
void ieee802154_container_free(FAR struct ieee802154_container_s *container);
#undef EXTERN
#ifdef __cplusplus
}
+22 -48
View File
@@ -58,7 +58,9 @@
* Private Data
****************************************************************************/
/* The array containing all packet socket connections */
/* The array containing all packet socket connections. Protected via the
* network lock.
*/
static struct ieee802154_conn_s
g_ieee802154_connections[CONFIG_NET_IEEE802154_NCONNS];
@@ -66,54 +68,28 @@ static struct ieee802154_conn_s
/* A list of all free packet socket connections */
static dq_queue_t g_free_ieee802154_connections;
static sem_t g_free_sem;
/* A list of all allocated packet socket connections */
static dq_queue_t g_active_ieee802154_connections;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: _ieee802154_semtake() and _ieee802154_semgive()
*
* Description:
* Take/give semaphore
*
****************************************************************************/
static inline void _ieee802154_semtake(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
while (net_lockedwait(sem) != 0)
{
/* The only case that an error should occur here is if
* the wait was awakened by a signal.
*/
DEBUGASSERT(get_errno() == EINTR);
}
}
#define _ieee802154_semgive(sem) sem_post(sem)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: ieee802154_initialize()
* Name: ieee802154_conn_initialize
*
* Description:
* Initialize the packet socket connection structures. Called once and
* only from the network logic early in initialization.
* Initialize the IEEE 802.15.5 connection structure allocator. Called
* once and only from ieee802154_initialize().
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_initialize(void)
void ieee802154_conn_initialize(void)
{
int i;
@@ -121,7 +97,6 @@ void ieee802154_initialize(void)
dq_init(&g_free_ieee802154_connections);
dq_init(&g_active_ieee802154_connections);
sem_init(&g_free_sem, 0, 1);
for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
{
@@ -133,7 +108,7 @@ void ieee802154_initialize(void)
}
/****************************************************************************
* Name: ieee802154_alloc()
* Name: ieee802154_conn_alloc()
*
* Description:
* Allocate a new, uninitialized packet socket connection structure. This
@@ -141,7 +116,7 @@ void ieee802154_initialize(void)
*
****************************************************************************/
FAR struct ieee802154_conn_s *ieee802154_alloc(void)
FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
{
FAR struct ieee802154_conn_s *conn;
@@ -149,7 +124,7 @@ FAR struct ieee802154_conn_s *ieee802154_alloc(void)
* is protected by a semaphore (that behaves like a mutex).
*/
_ieee802154_semtake(&g_free_sem);
net_lock();
conn = (FAR struct ieee802154_conn_s *)
dq_remfirst(&g_free_ieee802154_connections);
@@ -160,12 +135,12 @@ FAR struct ieee802154_conn_s *ieee802154_alloc(void)
dq_addlast(&conn->node, &g_active_ieee802154_connections);
}
_ieee802154_semgive(&g_free_sem);
net_unlock();
return conn;
}
/****************************************************************************
* Name: ieee802154_free()
* Name: ieee802154_conn_free()
*
* Description:
* Free a packet socket connection structure that is no longer in use.
@@ -173,7 +148,7 @@ FAR struct ieee802154_conn_s *ieee802154_alloc(void)
*
****************************************************************************/
void ieee802154_free(FAR struct ieee802154_conn_s *conn)
void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
{
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
@@ -181,20 +156,19 @@ void ieee802154_free(FAR struct ieee802154_conn_s *conn)
DEBUGASSERT(conn->crefs == 0);
_ieee802154_semtake(&g_free_sem);
/* Remove the connection from the active list */
net_lock();
dq_rem(&conn->node, &g_active_ieee802154_connections);
/* Free the connection */
dq_addlast(&conn->node, &g_free_ieee802154_connections);
_ieee802154_semgive(&g_free_sem);
net_unlock();
}
/****************************************************************************
* Name: ieee802154_active()
* Name: ieee802154_conn_active()
*
* Description:
* Find a connection structure that is the appropriate
@@ -206,7 +180,7 @@ void ieee802154_free(FAR struct ieee802154_conn_s *conn)
****************************************************************************/
FAR struct ieee802154_conn_s *
ieee802154_active(FAR const struct ieee802154_data_ind_s *meta)
ieee802154_conn_active(FAR const struct ieee802154_data_ind_s *meta)
{
FAR struct ieee802154_conn_s *conn;
@@ -271,7 +245,7 @@ FAR struct ieee802154_conn_s *
}
/****************************************************************************
* Name: ieee802154_nextconn()
* Name: ieee802154_conn_next()
*
* Description:
* Traverse the list of allocated packet connections
@@ -282,7 +256,7 @@ FAR struct ieee802154_conn_s *
****************************************************************************/
FAR struct ieee802154_conn_s *
ieee802154_nextconn(FAR struct ieee802154_conn_s *conn)
ieee802154_conn_next(FAR struct ieee802154_conn_s *conn)
{
if (!conn)
{
+221
View File
@@ -0,0 +1,221 @@
/****************************************************************************
* wireless/pktradio/ieee802154_container.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 <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <semaphore.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mm/iob.h>
#include "ieee802154/ieee802154.h"
/****************************************************************************
* Private Data
****************************************************************************/
/* The g_free_container is a list of IOB container structures that are
* available for general use. The number of messages in this list is a
* system configuration item.
*
* Mutually exclusive access to this list is managed via the network lock:
* i.e., the network must be locked beffore accessing this free list.
*/
static FAR struct ieee802154_container_s *g_free_container;
/* Pool of pre-allocated meta-data stuctures */
static struct ieee802154_container_s
g_container_pool[CONFIG_NET_IEEE802154_NCONTAINERS];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: ieee802154_container_initialize
*
* Description:
* This function initializes the container allocator. This function must
* be called early in the initialization sequence before any socket
* activity.
*
* Inputs:
* None
*
* Return Value:
* None
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_container_initialize(void)
{
FAR struct ieee802154_container_s *container;
int i;
/* Initialize g_free_container, the list of meta-data structures that
* are available for allocation.
*/
g_free_container = NULL;
for (i = 0, container = g_container_pool;
i < CONFIG_NET_IEEE802154_NCONTAINERS;
i++, container++)
{
/* Add the next meta data structure from the pool to the list of
* general structures.
*/
container->ic_flink = g_free_container;
g_free_container = container;
}
}
/****************************************************************************
* Name: ieee802154_container_allocate
*
* Description:
* The ieee802154_container_allocate function will get a free continer
* for use by the recvfrom() logic.
*
* This function will first attempt to allocate from the g_free_container
* list. If that the list is empty, then the meta-data structure will be
* allocated from the dynamic memory pool.
*
* Inputs:
* None
*
* Return Value:
* A reference to the allocated container structure. All user fields in this
* structure have been zeroed. On a failure to allocate, NULL is
* returned.
*
* Assumptions:
* The caller has locked the network.
*
****************************************************************************/
FAR struct ieee802154_container_s *ieee802154_container_allocate(void)
{
FAR struct ieee802154_container_s *container;
uint8_t pool;
/* Try the free list first */
net_lock();
if (g_free_container != NULL)
{
container = g_free_container;
g_free_container = container->ic_flink;
pool = IEEE802154_POOL_PREALLOCATED;
net_unlock();
}
else
{
net_unlock();
container = (FAR struct ieee802154_container_s *)
kmm_malloc((sizeof (struct ieee802154_container_s)));
pool = IEEE802154_POOL_DYNAMIC;
}
/* We have successfully allocated memory from some source? */
if (container != NULL)
{
/* Zero and tag the allocated meta-data structure. */
memset(container, 0, sizeof(struct ieee802154_container_s));
container->ic_pool = pool;
}
return container;
}
/****************************************************************************
* Name: ieee802154_container_free
*
* Description:
* The ieee802154_container_free function will return a container structure
* to the free list of containers if it was a pre-allocated container
* structure. If the container structure was allocated dynamically it will
* be deallocated.
*
* Inputs:
* container - container structure to free
*
* Return Value:
* None
*
* Assumptions:
* The caller has locked the network.
*
****************************************************************************/
void ieee802154_container_free(FAR struct ieee802154_container_s *container)
{
/* If this is a pre-allocated meta-data structure, then just put it back
* in the free list.
*/
net_lock();
if (container->ic_pool == IEEE802154_POOL_PREALLOCATED)
{
container->ic_flink = g_free_container;
g_free_container = container;
net_unlock();
}
else
{
DEBUGASSERT(container->ic_pool == IEEE802154_POOL_DYNAMIC);
/* Otherwise, deallocate it. */
net_unlock();
sched_kfree(container);
}
}
+71
View File
@@ -0,0 +1,71 @@
/****************************************************************************
* net/ieee802154/ieee802154_initialize.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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 "ieee802154/ieee802154.h"
#ifdef CONFIG_NET_IEEE802154
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: ieee802154_initialize()
*
* Description:
* Initialize the IEEE 802.15.4 socket support. Called once and only
* from the network initialization logic.
*
* Assumptions:
* Called early in the initialization sequence
*
****************************************************************************/
void ieee802154_initialize(void)
{
/* Initialize connection structions */
ieee802154_conn_initialize();
/* Initialize the container allocator */
ieee802154_container_initialize();
}
#endif /* CONFIG_NET_IEEE802154 */
+54 -10
View File
@@ -38,6 +38,8 @@
#include <nuttx/config.h>
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/mm/iob.h>
@@ -97,15 +99,16 @@
int ieee802154_input(FAR struct radio_driver_s *radio,
FAR struct iob_s *framelist,
FAR const struct ieee802154_data_ind_s *meta)
FAR struct ieee802154_data_ind_s *meta)
{
FAR struct ieee802154_container_s *container;
FAR struct ieee802154_conn_s *conn;
int ret = OK;
/* Check if there is a connection that will accept this packet */
conn = ieee802154_active(meta);
if (conn)
conn = ieee802154_conn_active(meta);
if (conn != NULL)
{
uint16_t flags;
@@ -117,25 +120,66 @@ int ieee802154_input(FAR struct radio_driver_s *radio,
radio->r_dev.d_len = 0;
radio->r_dev.d_sndlen = 0;
/* Allocate a container for the IOB */
container = ieee802154_container_allocate();
if (container == NULL)
{
nerr("ERROR: Failed to allocate a container\n");
return -ENOMEM;
}
/* Initialize the container */
memset(&container->ic_src, 0, sizeof(struct ieee802154_saddr_s));
DEBUGASSERT(meta->src.mode != IEEE802154_ADDRMODE_NONE);
container->ic_src.s_mode = meta->src.mode;
IEEE802154_PANIDCOPY(container->ic_src.s_panid, meta->src.panid);
if (meta->src.mode == IEEE802154_ADDRMODE_SHORT)
{
IEEE802154_SADDRCOPY(container->ic_src.s_saddr, meta->src.saddr);
}
else if (meta->src.mode == IEEE802154_ADDRMODE_EXTENDED)
{
IEEE802154_EADDRCOPY(container->ic_src.s_eaddr, meta->src.eaddr);
}
DEBUGASSERT(framelist != NULL);
container->ic_iob = framelist;
/* Add the container to the tail of the list of incoming frames */
container->ic_flink = NULL;
if (conn->rxtail == NULL)
{
conn->rxhead = container;
}
else
{
conn->rxtail->ic_flink = container;
}
conn->rxtail = container;
/* Perform the application callback */
/* REVISIT: Need to pass the meta data and the IOB through the callback */
#warning Missing logic
flags = ieee802154_callback(radio, conn, IEEE802154_NEWDATA);
/* If the operation was successful, the PKT_NEWDATA flag is removed
* and thus the packet can be deleted (OK will be returned).
/* If the operation was successful, the IEEE802154_NEWDATA flag is
* removed and thus the frame can be deleted (OK will be returned).
*/
if ((flags & PKT_NEWDATA) != 0)
if ((flags & IEEE802154_NEWDATA) != 0)
{
/* No.. the packet was not processed now. Return ERROR so
/* No.. the frame was not processed now. Return ERROR so
* that the driver may retry again later. We still need to
* set d_len to zero so that the driver is aware that there
* is nothing to be sent.
*/
nwarn("WARNING: Packet not processed\n");
nwarn("WARNING: Frame not processed\n");
ret = ERROR;
}
}
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -119,6 +119,9 @@ const struct sock_intf_s g_ieee802154_sockif =
* Description:
* Allocate and attach a PF_IEEE802154 connection structure.
*
* Assumptions:
* The network is locked
*
****************************************************************************/
static int ieee802154_sockif_alloc(FAR struct socket *psock)
@@ -127,7 +130,7 @@ static int ieee802154_sockif_alloc(FAR struct socket *psock)
* socket instance.
*/
FAR struct ieee802154_conn_s *conn = ieee802154_alloc();
FAR struct ieee802154_conn_s *conn = ieee802154_conn_alloc();
if (conn == NULL)
{
/* Failed to reserve a connection structure */
@@ -681,7 +684,7 @@ static int ieee802154_close(FAR struct socket *psock)
/* Yes... free the connection structure */
conn->crefs = 0; /* No more references on the connection */
ieee802154_free(psock->s_conn); /* Free network resources */
ieee802154_conn_free(psock->s_conn); /* Free network resources */
}
else
{
+10 -11
View File
@@ -117,7 +117,7 @@ static inline void pkt_add_recvlen(FAR struct pkt_recvfrom_s *pstate,
* Copy the read data from the packet
*
* Parameters:
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that caused the event.
* pstate recvfrom state structure
*
* Returned Value:
@@ -212,11 +212,11 @@ static uint16_t pkt_recvfrom_interrupt(FAR struct net_driver_s *dev,
pstate->pr_cb->flags = 0;
pstate->pr_cb->priv = NULL;
pstate->pr_cb->event = NULL;
#if 0
/* Save the sender's address in the caller's 'from' location */
pkt_recvfrom_sender(dev, pstate);
#endif
/* indicate that the data has been consumed */
flags &= ~PKT_NEWDATA;
@@ -406,9 +406,8 @@ ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
/* Perform the packet recvfrom() operation */
/* Initialize the state structure. This is done with interrupts
* disabled because we don't want anything to happen until we
* are ready.
/* Initialize the state structure. This is done with the network
* locked because we don't want anything to happen until we are ready.
*/
net_lock();
@@ -454,15 +453,15 @@ ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
pkt_recvfrom_rxnotify(conn);
#endif
/* Wait for either the receive to complete or for an error/timeout to occur.
* NOTES: (1) net_lockedwait will also terminate if a signal is received, (2)
* interrupts are disabled! They will be re-enabled while the task sleeps
* and automatically re-enabled when the task restarts.
/* Wait for either the receive to complete or for an error/timeout to
* occur. NOTES: (1) net_lockedwait will also terminate if a signal
* is received, (2) the network is locked! It will be un-locked while
* the task sleeps and automatically re-locked when the task restarts.
*/
ret = net_lockedwait(&state.pr_sem);
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
pkt_callback_free(dev, conn, state.pr_cb);
ret = pkt_recvfrom_result(ret, &state);
+2 -2
View File
@@ -60,7 +60,7 @@
* item.
*/
static struct pktradio_metadata_s *g_free_metadata;
static FAR struct pktradio_metadata_s *g_free_metadata;
/* Supports mutually exclusive access to the free list */
@@ -188,7 +188,7 @@ FAR struct pktradio_metadata_s *pktradio_metadata_allocate(void)
if (metadata != NULL)
{
/* Zero and tag the alloated meta-data structure. */
/* Zero and tag the allocated meta-data structure. */
memset(metadata, 0, sizeof(struct pktradio_metadata_s));
metadata->pm_pool = pool;