1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_netdev: remove remaining files and references

Somehow, these files were forgotten in my big cleanup in #7925. This
fixes that.
This commit is contained in:
Martine Lenders 2017-11-29 18:09:36 +01:00
parent 1ca465b140
commit 5a0e9bcca4
17 changed files with 5 additions and 1419 deletions

View File

@ -494,10 +494,6 @@ ifneq (,$(filter gnrc_pktbuf_%, $(USEMODULE)))
USEMODULE += gnrc_pktbuf # make MODULE_GNRC_PKTBUF macro available for all implementations
endif
ifneq (,$(filter gnrc_netdev,$(USEMODULE)))
USEMODULE += netopt
endif
ifneq (,$(filter netstats_%, $(USEMODULE)))
USEMODULE += netstats
endif

View File

@ -61,9 +61,6 @@ endif
ifneq (,$(filter nhdp,$(USEMODULE)))
DIRS += net/routing/nhdp
endif
ifneq (,$(filter gnrc_netdev,$(USEMODULE)))
DIRS += net/gnrc/link_layer/netdev
endif
ifneq (,$(filter fib,$(USEMODULE)))
DIRS += net/network_layer/fib
endif

View File

@ -18,7 +18,7 @@
* =====
*
* This module is currently the default network stack for RIOT and includes
* many components ranging from a @ref net_gnrc_netdev through a fully-featured
* many components ranging from a @ref net_gnrc_netif through a fully-featured
* @ref net_gnrc_ipv6 implementation with @ref net_gnrc_sixlowpan "6LowPAN"
* extensions to an @ref net_gnrc_udp "UDP" implementation and
* @ref net_gnrc_rpl.
@ -31,7 +31,7 @@
*
* From the application layer the @ref net_gnrc can be accessed through the
* @ref net_sock, while the interface to the @ref drivers_netdev_api is
* defined by the @ref net_gnrc_netdev.
* defined by the @ref net_gnrc_netif.
*
* Architecture
* ============

View File

@ -1,253 +0,0 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_gnrc_netdev Adaption layer for GNRC on top of Netdev
* @ingroup net_gnrc
* @brief Provides the glue code for @ref net_gnrc on top of @ref drivers_netdev_api
* @{
*
* @file
* @brief netdev-GNRC glue code interface
*
* This interface is supposed to provide common adaption code between the
* low-level network device interface "netdev" and the GNRC network stack.
*
* GNRC sends around "gnrc_pktsnip_t" structures, but netdev can only handle
* "struct iovec" structures when sending, or a flat buffer when receiving.
*
* The purpose of gnrc_netdev is to bring these two interfaces together.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef NET_GNRC_NETDEV_H
#define NET_GNRC_NETDEV_H
#include <assert.h>
#include <stdint.h>
#include "kernel_types.h"
#include "net/netdev.h"
#include "net/gnrc.h"
#include "net/gnrc/mac/types.h"
#include "net/ieee802154.h"
#include "net/gnrc/mac/mac.h"
#ifdef MODULE_GNRC_MAC
#include "net/csma_sender.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Default priority for adaption layer's threads
*/
#ifndef GNRC_NETDEV_MAC_PRIO
#define GNRC_NETDEV_MAC_PRIO (THREAD_PRIORITY_MAIN - 5)
#endif
/**
* @brief Type for @ref msg_t if device fired an event
*/
#define NETDEV_MSG_TYPE_EVENT 0x1234
/**
* @brief Mask for @ref gnrc_mac_tx_feedback_t
*/
#define GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK (0x0003U)
/**
* @brief Flag to track if a transmission might have corrupted a received
* packet
*/
#define GNRC_NETDEV_MAC_INFO_RX_STARTED (0x0004U)
/**
* @brief Flag to track if a device has enabled CSMA for transmissions
*
* If `gnrc_mac` is used, the user should be noticed that the `send()`
* function of gnrc_netdev will be affected with the state of this flag, since
* `gnrc_mac` accordingly adapts the `send()` function. If the device doesn't
* support on-chip CSMA and this flag is set for requiring CSMA transmission,
* then, the device will run software CSMA using `csma_sender` APIs.
*/
#define GNRC_NETDEV_MAC_INFO_CSMA_ENABLED (0x0100U)
/**
* @brief Structure holding GNRC netdev adapter state
*
* This structure is supposed to hold any state parameters needed
* to use a netdev device from GNRC.
*
* It can be extended
*/
typedef struct gnrc_netdev {
/**
* @brief Send a pktsnip using this device
*
* This function should convert the pktsnip into a format
* the underlying device understands and send it.
*/
int (*send)(struct gnrc_netdev *dev, gnrc_pktsnip_t *snip);
/**
* @brief Receive a pktsnip from this device
*
* This function should receive a raw frame from the underlying
* device and convert it into a pktsnip while adding a netif header
* and possibly marking out higher-layer headers.
*/
gnrc_pktsnip_t * (*recv)(struct gnrc_netdev *dev);
/**
* @brief netdev handle this adapter is working with
*/
netdev_t *dev;
/**
* @brief PID of this adapter for netapi messages
*/
kernel_pid_t pid;
#ifdef MODULE_GNRC_MAC
/**
* @brief general information for the MAC protocol
*/
uint16_t mac_info;
/**
* @brief device's l2 address
*/
uint8_t l2_addr[IEEE802154_LONG_ADDRESS_LEN];
/**
* @brief device's l2 address length
*/
uint8_t l2_addr_len;
/**
* @brief device's software CSMA configuration
*/
csma_sender_conf_t csma_conf;
#if ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
/**
* @brief MAC internal object which stores reception parameters, queues, and
* state machines.
*/
gnrc_mac_rx_t rx;
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
/**
* @brief MAC internal object which stores transmission parameters, queues, and
* state machines.
*/
gnrc_mac_tx_t tx;
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN) */
#ifdef MODULE_GNRC_LWMAC
/**
* @brief LWMAC specific structure object for storing LWMAC internal states.
*/
gnrc_lwmac_t lwmac;
#endif
#endif /* MODULE_GNRC_MAC */
} gnrc_netdev_t;
#ifdef MODULE_GNRC_MAC
/**
* @brief get the 'rx_started' state of the device
*
* This function checks whether the device has started receiving a packet.
*
* @param[in] dev ptr to netdev device
*
* @return the rx_started state
*/
static inline bool gnrc_netdev_get_rx_started(gnrc_netdev_t *dev)
{
return (dev->mac_info & GNRC_NETDEV_MAC_INFO_RX_STARTED);
}
/**
* @brief set the rx_started state of the device
*
* This function is intended to be called only in netdev_t::event_callback().
*
* @param[in] dev ptr to netdev device
*
*/
static inline void gnrc_netdev_set_rx_started(gnrc_netdev_t *dev, bool rx_started)
{
if (rx_started) {
dev->mac_info |= GNRC_NETDEV_MAC_INFO_RX_STARTED;
}
else {
dev->mac_info &= ~GNRC_NETDEV_MAC_INFO_RX_STARTED;
}
}
/**
* @brief get the transmission feedback of the device
*
* @param[in] dev ptr to netdev device
*
* @return the transmission feedback
*/
static inline gnrc_mac_tx_feedback_t gnrc_netdev_get_tx_feedback(gnrc_netdev_t *dev)
{
return (gnrc_mac_tx_feedback_t)(dev->mac_info &
GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK);
}
/**
* @brief set the transmission feedback of the device
*
* This function is intended to be called only in netdev_t::event_callback().
*
* @param[in] dev ptr to netdev device
*
*/
static inline void gnrc_netdev_set_tx_feedback(gnrc_netdev_t *dev,
gnrc_mac_tx_feedback_t txf)
{
/* check if gnrc_mac_tx_feedback does not collide with
* GNRC_NETDEV_MAC_INFO_RX_STARTED */
assert(!(txf & GNRC_NETDEV_MAC_INFO_RX_STARTED));
/* unset previous value */
dev->mac_info &= ~GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK;
dev->mac_info |= (uint16_t)(txf & GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK);
}
#endif
/**
* @brief Initialize GNRC netdev handler thread
*
* @param[in] stack ptr to preallocated stack buffer
* @param[in] stacksize size of stack buffer
* @param[in] priority priority of thread
* @param[in] name name of thread
* @param[in] gnrc_netdev ptr to netdev device to handle in created thread
*
* @return pid of created thread
* @return KERNEL_PID_UNDEF on error
*/
kernel_pid_t gnrc_netdev_init(char *stack, int stacksize, char priority,
const char *name, gnrc_netdev_t *gnrc_netdev);
#ifdef __cplusplus
}
#endif
#endif /* NET_GNRC_NETDEV_H */
/** @} */

View File

@ -1,44 +0,0 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_netdev
* @{
*
* @file
* @brief netdev gnrc ethernet glue code interface
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef NET_GNRC_NETDEV_ETH_H
#define NET_GNRC_NETDEV_ETH_H
#include "net/gnrc/netdev.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize gnrc handler thread for netdev ethernet device
*
* @param[in] gnrc_netdev gnrc_netdev struct to initialize
* @param[in] dev netdev device to handle
*
* @return 1 on success
* @return <=0 on error
*/
int gnrc_netdev_eth_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* NET_GNRC_NETDEV_ETH_H */
/** @} */

View File

@ -1,46 +0,0 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_netdev
* @brief
* @{
*
* @file
* @brief netdev gnrc IEEE 802.15.4 glue code interface
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NET_GNRC_NETDEV_IEEE802154_H
#define NET_GNRC_NETDEV_IEEE802154_H
#include "net/netdev/ieee802154.h"
#include "net/gnrc/netdev.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize gnrc handler for netdev IEEE 802.15.4 device
*
* @param[in] gnrc_netdev gnrc_netdev struct to initialize
* @param[in] dev netdev device to handle
*
* @return 1 on success
* @return <=0 on error
*/
int gnrc_netdev_ieee802154_init(gnrc_netdev_t *gnrc_netdev,
netdev_ieee802154_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* NET_GNRC_NETDEV_IEEE802154_H */
/** @} */

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_netdev
* @{
*
* @file
* @brief netdev gnrc raw (i.e. pure L3) glue code interface
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NET_GNRC_NETDEV_RAW_H
#define NET_GNRC_NETDEV_RAW_H
#include "net/gnrc/netdev.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize gnrc handler for netdev raw L3 devices
*
* @param[in] gnrc_netdev gnrc_netdev struct to initialize
* @param[in] dev network device to handle
*
* @return 1 on success
* @return <=0 on error
*/
int gnrc_netdev_raw_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* NET_GNRC_NETDEV_RAW_H */
/** @} */

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_netdev
* @{
*
* @file
* @brief GNRC to XBee netdev glue code interface
*
* Although the XBee devices are IEEE802.15.4 transceivers, use their own
* proprietary format for communicating between the host CPU and the device over
* UART. The XBee device driver expects the data to send to be given in this
* format, hence we need to introduce an XBee specific adaption layer that
* translates between GNRC and the XBee proprietary header format.
*
* For this custom header format, we can not make use of the existing adaption
* layers for other IEEE802.15.4 devices.
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef NET_GNRC_NETDEV_XBEE_ADPT_H
#define NET_GNRC_NETDEV_XBEE_ADPT_H
#include "xbee.h"
#include "net/gnrc/netdev.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize GNRC handler for netdev XBee devices
*
* @param[out] gnrc_netdev gnrc_netdev struct to initialize
* @param[in] dev XBee device to handle
*/
void gnrc_netdev_xbee_init(gnrc_netdev_t *gnrc_netdev, xbee_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* NET_GNRC_NETDEV_XBEE_ADPT_H */
/** @} */

View File

@ -11,7 +11,7 @@
* @ingroup net_gnrc
* @brief Protocol type definitions and helper functions
*
* The protocol types are used with the @ref net_gnrc_netapi, the @ref net_gnrc_netdev,
* The protocol types are used with the @ref net_gnrc_netapi, the @ref net_gnrc_netif,
* the @ref net_gnrc_netreg, and the @ref net_gnrc_pkt to identify network protocols
* throughout the network stack.
*

View File

@ -11,7 +11,7 @@
* @defgroup net_netopt Configuration options for network APIs
* @ingroup net
* @brief List of available configuration options for the
* @ref net_gnrc_netdev and the @ref net_gnrc_netapi
* @ref drivers_netdev_api and the @ref net_gnrc_netapi
* @{
*
* @file

View File

@ -1,3 +0,0 @@
MODULE = gnrc_netdev
include $(RIOTBASE)/Makefile.base

View File

@ -1,201 +0,0 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
* @ingroup net
* @file
* @brief Glue for netdev devices to netapi
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @}
*/
#include <errno.h>
#include "msg.h"
#include "thread.h"
#include "net/gnrc.h"
#include "net/gnrc/nettype.h"
#include "net/netdev.h"
#include "net/gnrc/netdev.h"
#include "net/ethernet/hdr.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#if defined(MODULE_OD) && ENABLE_DEBUG
#include "od.h"
#endif
#define NETDEV_NETAPI_MSG_QUEUE_SIZE 8
static void _pass_on_packet(gnrc_pktsnip_t *pkt);
/**
* @brief Function called by the device driver on device events
*
* @param[in] event type of event
*/
static void _event_cb(netdev_t *dev, netdev_event_t event)
{
gnrc_netdev_t *gnrc_netdev = (gnrc_netdev_t*) dev->context;
if (event == NETDEV_EVENT_ISR) {
msg_t msg;
msg.type = NETDEV_MSG_TYPE_EVENT;
msg.content.ptr = gnrc_netdev;
if (msg_send(&msg, gnrc_netdev->pid) <= 0) {
puts("gnrc_netdev: possibly lost interrupt.");
}
}
else {
DEBUG("gnrc_netdev: event triggered -> %i\n", event);
switch(event) {
case NETDEV_EVENT_RX_COMPLETE:
{
gnrc_pktsnip_t *pkt = gnrc_netdev->recv(gnrc_netdev);
if (pkt) {
_pass_on_packet(pkt);
}
break;
}
#ifdef MODULE_NETSTATS_L2
case NETDEV_EVENT_TX_MEDIUM_BUSY:
dev->stats.tx_failed++;
break;
case NETDEV_EVENT_TX_COMPLETE:
dev->stats.tx_success++;
break;
#endif
default:
DEBUG("gnrc_netdev: warning: unhandled event %u.\n", event);
}
}
}
static void _pass_on_packet(gnrc_pktsnip_t *pkt)
{
/* throw away packet if no one is interested */
if (!gnrc_netapi_dispatch_receive(pkt->type, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
DEBUG("gnrc_netdev: unable to forward packet of type %i\n", pkt->type);
gnrc_pktbuf_release(pkt);
return;
}
}
/**
* @brief Startup code and event loop of the gnrc_netdev layer
*
* @param[in] args expects a pointer to the underlying netdev device
*
* @return never returns
*/
static void *_gnrc_netdev_thread(void *args)
{
DEBUG("gnrc_netdev: starting thread\n");
gnrc_netdev_t *gnrc_netdev = (gnrc_netdev_t*) args;
netdev_t *dev = gnrc_netdev->dev;
gnrc_netdev->pid = thread_getpid();
gnrc_netapi_opt_t *opt;
int res;
msg_t msg, reply, msg_queue[NETDEV_NETAPI_MSG_QUEUE_SIZE];
/* setup the MAC layers message queue */
msg_init_queue(msg_queue, NETDEV_NETAPI_MSG_QUEUE_SIZE);
/* register the event callback with the device driver */
dev->event_callback = _event_cb;
dev->context = (void*) gnrc_netdev;
/* register the device to the network stack*/
gnrc_netif_add(thread_getpid());
/* initialize low-level driver */
dev->driver->init(dev);
/* start the event loop */
while (1) {
DEBUG("gnrc_netdev: waiting for incoming messages\n");
msg_receive(&msg);
/* dispatch NETDEV and NETAPI messages */
switch (msg.type) {
case NETDEV_MSG_TYPE_EVENT:
DEBUG("gnrc_netdev: GNRC_NETDEV_MSG_TYPE_EVENT received\n");
dev->driver->isr(dev);
break;
case GNRC_NETAPI_MSG_TYPE_SND:
DEBUG("gnrc_netdev: GNRC_NETAPI_MSG_TYPE_SND received\n");
gnrc_pktsnip_t *pkt = msg.content.ptr;
gnrc_netdev->send(gnrc_netdev, pkt);
break;
case GNRC_NETAPI_MSG_TYPE_SET:
/* read incoming options */
opt = msg.content.ptr;
DEBUG("gnrc_netdev: GNRC_NETAPI_MSG_TYPE_SET received. opt=%s\n",
netopt2str(opt->opt));
/* set option for device driver */
res = dev->driver->set(dev, opt->opt, opt->data, opt->data_len);
DEBUG("gnrc_netdev: response of netdev->set: %i\n", res);
/* send reply to calling thread */
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
reply.content.value = (uint32_t)res;
msg_reply(&msg, &reply);
break;
case GNRC_NETAPI_MSG_TYPE_GET:
/* read incoming options */
opt = msg.content.ptr;
DEBUG("gnrc_netdev: GNRC_NETAPI_MSG_TYPE_GET received. opt=%s\n",
netopt2str(opt->opt));
/* get option from device driver */
res = dev->driver->get(dev, opt->opt, opt->data, opt->data_len);
DEBUG("gnrc_netdev: response of netdev->get: %i\n", res);
/* send reply to calling thread */
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
reply.content.value = (uint32_t)res;
msg_reply(&msg, &reply);
break;
default:
DEBUG("gnrc_netdev: Unknown command %" PRIu16 "\n", msg.type);
break;
}
}
/* never reached */
return NULL;
}
kernel_pid_t gnrc_netdev_init(char *stack, int stacksize, char priority,
const char *name, gnrc_netdev_t *gnrc_netdev)
{
kernel_pid_t res;
/* check if given netdev device is defined and the driver is set */
if (gnrc_netdev == NULL || gnrc_netdev->dev == NULL) {
return -ENODEV;
}
/* create new gnrc_netdev thread */
res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
_gnrc_netdev_thread, (void *)gnrc_netdev, name);
if (res <= 0) {
return -EINVAL;
}
return res;
}

View File

@ -1,241 +0,0 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
* @ingroup net
* @file
* @brief gnrc netdev ethernet glue code
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @}
*/
#include "net/gnrc.h"
#include "net/gnrc/netdev.h"
#include "net/ethernet/hdr.h"
#ifdef MODULE_GNRC_IPV6
#include "net/ipv6/hdr.h"
#endif
#include "od.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
{
netdev_t *dev = gnrc_netdev->dev;
int bytes_expected = dev->driver->recv(dev, NULL, 0, NULL);
gnrc_pktsnip_t *pkt = NULL;
if (bytes_expected > 0) {
pkt = gnrc_pktbuf_add(NULL, NULL,
bytes_expected,
GNRC_NETTYPE_UNDEF);
if(!pkt) {
DEBUG("_recv_ethernet_packet: cannot allocate pktsnip.\n");
/* drop the packet */
dev->driver->recv(dev, NULL, bytes_expected, NULL);
goto out;
}
int nread = dev->driver->recv(dev, pkt->data, bytes_expected, NULL);
if(nread <= 0) {
DEBUG("_recv_ethernet_packet: read error.\n");
goto safe_out;
}
if (nread < bytes_expected) {
/* we've got less then the expected packet size,
* so free the unused space.*/
DEBUG("_recv_ethernet_packet: reallocating.\n");
gnrc_pktbuf_realloc_data(pkt, nread);
}
/* mark ethernet header */
gnrc_pktsnip_t *eth_hdr = gnrc_pktbuf_mark(pkt, sizeof(ethernet_hdr_t), GNRC_NETTYPE_UNDEF);
if (!eth_hdr) {
DEBUG("gnrc_netdev_eth: no space left in packet buffer\n");
goto safe_out;
}
ethernet_hdr_t *hdr = (ethernet_hdr_t *)eth_hdr->data;
#ifdef MODULE_L2FILTER
if (!l2filter_pass(dev->filter, hdr->src, ETHERNET_ADDR_LEN)) {
DEBUG("gnrc_netdev_eth: incoming packet filtered by l2filter\n");
goto safe_out;
}
#endif
/* set payload type from ethertype */
pkt->type = gnrc_nettype_from_ethertype(byteorder_ntohs(hdr->type));
/* create netif header */
gnrc_pktsnip_t *netif_hdr;
netif_hdr = gnrc_pktbuf_add(NULL, NULL,
sizeof(gnrc_netif_hdr_t) + (2 * ETHERNET_ADDR_LEN),
GNRC_NETTYPE_NETIF);
if (netif_hdr == NULL) {
DEBUG("gnrc_netdev_eth: no space left in packet buffer\n");
pkt = eth_hdr;
goto safe_out;
}
gnrc_netif_hdr_init(netif_hdr->data, ETHERNET_ADDR_LEN, ETHERNET_ADDR_LEN);
gnrc_netif_hdr_set_src_addr(netif_hdr->data, hdr->src, ETHERNET_ADDR_LEN);
gnrc_netif_hdr_set_dst_addr(netif_hdr->data, hdr->dst, ETHERNET_ADDR_LEN);
((gnrc_netif_hdr_t *)netif_hdr->data)->if_pid = thread_getpid();
DEBUG("gnrc_netdev_eth: received packet from %02x:%02x:%02x:%02x:%02x:%02x "
"of length %d\n",
hdr->src[0], hdr->src[1], hdr->src[2], hdr->src[3], hdr->src[4],
hdr->src[5], nread);
#if defined(MODULE_OD) && ENABLE_DEBUG
od_hex_dump(hdr, nread, OD_WIDTH_DEFAULT);
#endif
gnrc_pktbuf_remove_snip(pkt, eth_hdr);
LL_APPEND(pkt, netif_hdr);
}
out:
return pkt;
safe_out:
gnrc_pktbuf_release(pkt);
return NULL;
}
static inline void _addr_set_broadcast(uint8_t *dst)
{
memset(dst, 0xff, ETHERNET_ADDR_LEN);
}
static inline void _addr_set_multicast(uint8_t *dst, gnrc_pktsnip_t *payload)
{
switch (payload->type) {
#ifdef MODULE_GNRC_IPV6
case GNRC_NETTYPE_IPV6:
/* https://tools.ietf.org/html/rfc2464#section-7 */
dst[0] = 0x33;
dst[1] = 0x33;
ipv6_hdr_t *ipv6 = payload->data;
memcpy(dst + 2, ipv6->dst.u8 + 12, 4);
break;
#endif
default:
_addr_set_broadcast(dst);
break;
}
}
static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
{
ethernet_hdr_t hdr;
gnrc_netif_hdr_t *netif_hdr;
gnrc_pktsnip_t *payload;
int res;
netdev_t *dev = gnrc_netdev->dev;
if (pkt == NULL) {
DEBUG("gnrc_netdev_eth: pkt was NULL\n");
return -EINVAL;
}
payload = pkt->next;
if (pkt->type != GNRC_NETTYPE_NETIF) {
DEBUG("gnrc_netdev_eth: First header was not generic netif header\n");
return -EBADMSG;
}
if (payload) {
hdr.type = byteorder_htons(gnrc_nettype_to_ethertype(payload->type));
}
else {
hdr.type = byteorder_htons(ETHERTYPE_UNKNOWN);
}
netif_hdr = pkt->data;
/* set ethernet header */
if (netif_hdr->src_l2addr_len == ETHERNET_ADDR_LEN) {
memcpy(hdr.dst, gnrc_netif_hdr_get_src_addr(netif_hdr),
netif_hdr->src_l2addr_len);
}
else {
dev->driver->get(dev, NETOPT_ADDRESS, hdr.src, ETHERNET_ADDR_LEN);
}
if (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) {
_addr_set_broadcast(hdr.dst);
}
else if (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST) {
if (payload == NULL) {
DEBUG("gnrc_netdev_eth: empty multicast packets over Ethernet "\
"are not yet supported\n");
return -ENOTSUP;
}
_addr_set_multicast(hdr.dst, payload);
}
else if (netif_hdr->dst_l2addr_len == ETHERNET_ADDR_LEN) {
memcpy(hdr.dst, gnrc_netif_hdr_get_dst_addr(netif_hdr),
ETHERNET_ADDR_LEN);
}
else {
DEBUG("gnrc_netdev_eth: destination address had unexpected format\n");
return -EBADMSG;
}
DEBUG("gnrc_netdev_eth: send to %02x:%02x:%02x:%02x:%02x:%02x\n",
hdr.dst[0], hdr.dst[1], hdr.dst[2],
hdr.dst[3], hdr.dst[4], hdr.dst[5]);
size_t n;
payload = gnrc_pktbuf_get_iovec(pkt, &n); /* use payload as temporary
* variable */
res = -ENOBUFS;
if (payload != NULL) {
pkt = payload; /* reassign for later release; vec_snip is prepended to pkt */
struct iovec *vector = (struct iovec *)pkt->data;
vector[0].iov_base = (char*)&hdr;
vector[0].iov_len = sizeof(ethernet_hdr_t);
#ifdef MODULE_NETSTATS_L2
if ((netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) ||
(netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
gnrc_netdev->dev->stats.tx_mcast_count++;
}
else {
gnrc_netdev->dev->stats.tx_unicast_count++;
}
#endif
res = dev->driver->send(dev, vector, n);
}
gnrc_pktbuf_release(pkt);
return res;
}
int gnrc_netdev_eth_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev)
{
gnrc_netdev->send = _send;
gnrc_netdev->recv = _recv;
gnrc_netdev->dev = dev;
return 0;
}

View File

@ -1,243 +0,0 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#include <stddef.h>
#include "od.h"
#include "net/l2filter.h"
#include "net/gnrc.h"
#include "net/ieee802154.h"
#include "net/gnrc/netdev/ieee802154.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev);
static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt);
int gnrc_netdev_ieee802154_init(gnrc_netdev_t *gnrc_netdev,
netdev_ieee802154_t *dev)
{
gnrc_netdev->send = _send;
gnrc_netdev->recv = _recv;
gnrc_netdev->dev = (netdev_t *)dev;
return 0;
}
static gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
{
gnrc_pktsnip_t *snip;
uint8_t src[IEEE802154_LONG_ADDRESS_LEN], dst[IEEE802154_LONG_ADDRESS_LEN];
int src_len, dst_len;
le_uint16_t _pan_tmp; /* TODO: hand-up PAN IDs to GNRC? */
dst_len = ieee802154_get_dst(mhr, dst, &_pan_tmp);
src_len = ieee802154_get_src(mhr, src, &_pan_tmp);
if ((dst_len < 0) || (src_len < 0)) {
DEBUG("_make_netif_hdr: unable to get addresses\n");
return NULL;
}
/* allocate space for header */
snip = gnrc_netif_hdr_build(src, (size_t)src_len, dst, (size_t)dst_len);
if (snip == NULL) {
DEBUG("_make_netif_hdr: no space left in packet buffer\n");
return NULL;
}
/* set broadcast flag for broadcast destination */
if ((dst_len == 2) && (dst[0] == 0xff) && (dst[1] == 0xff)) {
gnrc_netif_hdr_t *hdr = snip->data;
hdr->flags |= GNRC_NETIF_HDR_FLAGS_BROADCAST;
}
return snip;
}
static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
{
netdev_t *netdev = gnrc_netdev->dev;
netdev_ieee802154_rx_info_t rx_info;
netdev_ieee802154_t *state = (netdev_ieee802154_t *)gnrc_netdev->dev;
gnrc_pktsnip_t *pkt = NULL;
int bytes_expected = netdev->driver->recv(netdev, NULL, 0, NULL);
if (bytes_expected > 0) {
int nread;
pkt = gnrc_pktbuf_add(NULL, NULL, bytes_expected, GNRC_NETTYPE_UNDEF);
if (pkt == NULL) {
DEBUG("_recv_ieee802154: cannot allocate pktsnip.\n");
return NULL;
}
nread = netdev->driver->recv(netdev, pkt->data, bytes_expected, &rx_info);
if (nread <= 0) {
gnrc_pktbuf_release(pkt);
return NULL;
}
if (!(state->flags & NETDEV_IEEE802154_RAW)) {
gnrc_pktsnip_t *ieee802154_hdr, *netif_hdr;
gnrc_netif_hdr_t *hdr;
#if ENABLE_DEBUG
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
#endif
size_t mhr_len = ieee802154_get_frame_hdr_len(pkt->data);
if (mhr_len == 0) {
DEBUG("_recv_ieee802154: illegally formatted frame received\n");
gnrc_pktbuf_release(pkt);
return NULL;
}
nread -= mhr_len;
/* mark IEEE 802.15.4 header */
ieee802154_hdr = gnrc_pktbuf_mark(pkt, mhr_len, GNRC_NETTYPE_UNDEF);
if (ieee802154_hdr == NULL) {
DEBUG("_recv_ieee802154: no space left in packet buffer\n");
gnrc_pktbuf_release(pkt);
return NULL;
}
netif_hdr = _make_netif_hdr(ieee802154_hdr->data);
if (netif_hdr == NULL) {
DEBUG("_recv_ieee802154: no space left in packet buffer\n");
gnrc_pktbuf_release(pkt);
return NULL;
}
hdr = netif_hdr->data;
#ifdef MODULE_L2FILTER
if (!l2filter_pass(netdev->filter, gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len)) {
gnrc_pktbuf_release(pkt);
gnrc_pktbuf_release(netif_hdr);
DEBUG("_recv_ieee802154: packet dropped by l2filter\n");
return NULL;
}
#endif
hdr->lqi = rx_info.lqi;
hdr->rssi = rx_info.rssi;
hdr->if_pid = thread_getpid();
pkt->type = state->proto;
#if ENABLE_DEBUG
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
gnrc_netif_addr_to_str(src_str, sizeof(src_str),
gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len),
nread);
#if defined(MODULE_OD)
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
#endif
#endif
gnrc_pktbuf_remove_snip(pkt, ieee802154_hdr);
LL_APPEND(pkt, netif_hdr);
}
DEBUG("_recv_ieee802154: reallocating.\n");
gnrc_pktbuf_realloc_data(pkt, nread);
}
return pkt;
}
static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
{
netdev_t *netdev = gnrc_netdev->dev;
netdev_ieee802154_t *state = (netdev_ieee802154_t *)gnrc_netdev->dev;
gnrc_netif_hdr_t *netif_hdr;
gnrc_pktsnip_t *vec_snip;
const uint8_t *src, *dst = NULL;
int res = 0;
size_t n, src_len, dst_len;
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
uint8_t flags = (uint8_t)(state->flags & NETDEV_IEEE802154_SEND_MASK);
le_uint16_t dev_pan = byteorder_btols(byteorder_htons(state->pan));
flags |= IEEE802154_FCF_TYPE_DATA;
if (pkt == NULL) {
DEBUG("_send_ieee802154: pkt was NULL\n");
return -EINVAL;
}
if (pkt->type != GNRC_NETTYPE_NETIF) {
DEBUG("_send_ieee802154: first header is not generic netif header\n");
return -EBADMSG;
}
netif_hdr = pkt->data;
/* prepare destination address */
if (netif_hdr->flags & /* If any of these flags is set so this is correct */
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
dst = ieee802154_addr_bcast;
dst_len = IEEE802154_ADDR_BCAST_LEN;
}
else {
dst = gnrc_netif_hdr_get_dst_addr(netif_hdr);
dst_len = netif_hdr->dst_l2addr_len;
}
src_len = netif_hdr->src_l2addr_len;
if (src_len > 0) {
src = gnrc_netif_hdr_get_src_addr(netif_hdr);
}
else if (state->flags & NETDEV_IEEE802154_SRC_MODE_LONG) {
src_len = IEEE802154_LONG_ADDRESS_LEN;
src = state->long_addr;
}
else {
src_len = IEEE802154_SHORT_ADDRESS_LEN;
src = state->short_addr;
}
/* fill MAC header, seq should be set by device */
if ((res = ieee802154_set_frame_hdr(mhr, src, src_len,
dst, dst_len, dev_pan,
dev_pan, flags, state->seq++)) == 0) {
DEBUG("_send_ieee802154: Error preperaring frame\n");
return -EINVAL;
}
/* prepare packet for sending */
vec_snip = gnrc_pktbuf_get_iovec(pkt, &n);
if (vec_snip != NULL) {
struct iovec *vector;
pkt = vec_snip; /* reassign for later release; vec_snip is prepended to pkt */
vector = (struct iovec *)pkt->data;
vector[0].iov_base = mhr;
vector[0].iov_len = (size_t)res;
#ifdef MODULE_NETSTATS_L2
if (netif_hdr->flags &
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
gnrc_netdev->dev->stats.tx_mcast_count++;
}
else {
gnrc_netdev->dev->stats.tx_unicast_count++;
}
#endif
#ifdef MODULE_GNRC_MAC
if (gnrc_netdev->mac_info & GNRC_NETDEV_MAC_INFO_CSMA_ENABLED) {
res = csma_sender_csma_ca_send(netdev, vector, n, &gnrc_netdev->csma_conf);
}
else {
res = netdev->driver->send(netdev, vector, n);
}
#else
res = netdev->driver->send(netdev, vector, n);
#endif
}
else {
return -ENOBUFS;
}
/* release old data */
gnrc_pktbuf_release(pkt);
return res;
}
/** @} */

View File

@ -1,99 +0,0 @@
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#include "net/gnrc/netdev/raw.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#define IP_VERSION_MASK (0xf0)
#define IP_VERSION4 (0x40)
#define IP_VERSION6 (0x60)
static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
{
netdev_t *dev = gnrc_netdev->dev;
int bytes_expected = dev->driver->recv(dev, NULL, 0, NULL);
gnrc_pktsnip_t *pkt = NULL;
if (bytes_expected > 0) {
int nread;
pkt = gnrc_pktbuf_add(NULL, NULL, bytes_expected, GNRC_NETTYPE_UNDEF);
if (!pkt) {
DEBUG("gnrc_netdev_raw: cannot allocate pktsnip.\n");
/* drop packet */
dev->driver->recv(dev, NULL, bytes_expected, NULL);
return pkt;
}
nread = dev->driver->recv(dev, pkt->data, bytes_expected, NULL);
if (nread <= 0) {
DEBUG("gnrc_netdev_raw: read error.\n");
gnrc_pktbuf_release(pkt);
return NULL;
}
if (nread < bytes_expected) {
/* we've got less then the expected packet size,
* so free the unused space.*/
DEBUG("gnrc_netdev_raw: reallocating.\n");
gnrc_pktbuf_realloc_data(pkt, nread);
}
switch (((uint8_t *)pkt->data)[0] & IP_VERSION_MASK) {
#ifdef MODULE_GNRC_IPV6
case IP_VERSION6:
pkt->type = GNRC_NETTYPE_IPV6;
break;
#endif
default:
/* leave UNDEF */
break;
}
}
return pkt;
}
static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
{
gnrc_pktsnip_t *vector;
int res = -ENOBUFS;
size_t n;
if (pkt->type == GNRC_NETTYPE_NETIF) {
/* we don't need the netif snip: remove it */
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
}
vector = gnrc_pktbuf_get_iovec(pkt, &n);
if (vector != NULL) {
struct iovec *v = (struct iovec *)vector->data;
netdev_t *dev = gnrc_netdev->dev;
#ifdef MODULE_NETSTATS_L2
gnrc_netdev->dev->stats.tx_unicast_count++;
#endif
res = dev->driver->send(dev, v, n);
}
return res;
}
int gnrc_netdev_raw_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev)
{
gnrc_netdev->send = _send;
gnrc_netdev->recv = _recv;
gnrc_netdev->dev = dev;
return 0;
}
/** @} */

View File

@ -1,182 +0,0 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc
* @{
*
* @file
* @brief GNRC to netdev adapter for XBee devices
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "assert.h"
#include "xbee.h"
#include "net/gnrc.h"
#include "net/gnrc/netdev/xbee_adpt.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#define BCAST (GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)
static gnrc_pktsnip_t *xbee_adpt_recv(gnrc_netdev_t *gnrc_netdev)
{
netdev_t *dev = gnrc_netdev->dev;
int pktlen;
int xhdr_len;
gnrc_pktsnip_t *payload;
gnrc_pktsnip_t *netif_snip;
gnrc_pktsnip_t *xhdr_snip;
gnrc_netif_hdr_t *netif;
xbee_l2hdr_t l2hdr;
assert(dev);
/* see how much data there is to process */
pktlen = dev->driver->recv(dev, NULL, 0, NULL);
if (pktlen <= 0) {
DEBUG("[xbee-gnrc] recv: no data available to process\n");
return NULL;
}
/* allocate space for the packet in the pktbuf */
payload = gnrc_pktbuf_add(NULL, NULL, pktlen, XBEE_DEFAULT_PROTOCOL);
if (payload == NULL) {
DEBUG("[xbee-gnrc] recv: unable to allocate space in the pktbuf\n");
/* tell the driver to drop the packet */
dev->driver->recv(dev, NULL, 1, NULL);
return NULL;
}
/* copy the complete including the XBee header into the packet buffer */
dev->driver->recv(dev, payload->data, pktlen, NULL);
/* try to parse the L2 header data from the XBee header */
xhdr_len = xbee_parse_hdr((xbee_t *)dev, (uint8_t *)payload->data, &l2hdr);
if (xhdr_len < 0) {
DEBUG("[xbee-gnrc] recv: unable to parse XBee header\n");
gnrc_pktbuf_release(payload);
return NULL;
}
/* crop the XBee header from the payload */
xhdr_snip = gnrc_pktbuf_mark(payload, xhdr_len, GNRC_NETTYPE_UNDEF);
if (xhdr_snip == NULL) {
DEBUG("[xbee-gnrc] recv: unable to mark XBee header snip\n");
gnrc_pktbuf_release(payload);
return NULL;
}
gnrc_pktbuf_remove_snip(payload, xhdr_snip);
/* create a netif hdr from the obtained data */
netif_snip = gnrc_netif_hdr_build(l2hdr.src_addr, l2hdr.addr_len,
l2hdr.dst_addr, l2hdr.addr_len);
if (netif_snip == NULL) {
DEBUG("[xbee-gnrc] recv: unable to allocate netif header\n");
gnrc_pktbuf_release(payload);
return NULL;
}
netif = (gnrc_netif_hdr_t *)netif_snip->data;
netif->if_pid = gnrc_netdev->pid;
netif->rssi = l2hdr.rssi;
if (l2hdr.bcast) {
netif->flags = GNRC_NETIF_HDR_FLAGS_BROADCAST;
}
DEBUG("[xbee-gnrc] recv: successfully parsed packet\n");
/* and append the netif header */
LL_APPEND(payload, netif_snip);
return payload;
}
static int xbee_adpt_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
{
int res;
size_t size;
size_t count;
gnrc_pktsnip_t *vec;
gnrc_netif_hdr_t *hdr;
uint8_t xhdr[XBEE_MAX_TXHDR_LENGTH];
/* check device descriptor and packet */
assert(dev && pkt);
/* get the payload size and the dst address details */
size = gnrc_pkt_len(pkt->next);
DEBUG("[xbee-gnrc] send: payload of packet is %i\n", (int)size);
hdr = (gnrc_netif_hdr_t *)pkt->data;
if (hdr->flags & BCAST) {
uint16_t addr = 0xffff;
res = xbee_build_hdr((xbee_t *)dev, xhdr, size, &addr, 2);
DEBUG("[xbee-gnrc] send: preparing to send broadcast\n");
}
else {
uint8_t *addr = gnrc_netif_hdr_get_dst_addr(hdr);
res = xbee_build_hdr((xbee_t *)dev, xhdr, size, addr, hdr->dst_l2addr_len);
if (res < 0) {
if (res == -EOVERFLOW) {
DEBUG("[xbee-gnrc] send: payload length exceeds max limit\n");
}
else if (res == -ENOMSG) {
DEBUG("[xbee-gnrc] send: invalid destination l2 address\n");
}
return res;
}
if (hdr->dst_l2addr_len == IEEE802154_SHORT_ADDRESS_LEN) {
DEBUG("[xbee-gnrc] send: preparing to send unicast to %02x:%02x\n",
(int)addr[0], (int)addr[1]);
}
else {
DEBUG("[xbee-gnrc] send: preparing to send unicast to "
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
(int)addr[0], (int)addr[1], (int)addr[2], (int)addr[3],
(int)addr[4], (int)addr[5], (int)addr[6], (int)addr[7]);
}
}
/* now let's extract the iovector and send out the stuff */
vec = gnrc_pktbuf_get_iovec(pkt, &count);
if (vec != NULL) {
pkt = vec;
struct iovec *vector = (struct iovec *)pkt->data;
vector[0].iov_base = xhdr;
vector[0].iov_len = res;
#ifdef MODULE_NETSTATS_L2
if (hdr->flags & BCAST) {
dev->dev->stats.tx_mcast_count++;
}
else {
dev->dev->stats.tx_unicast_count++;
}
#endif
DEBUG("[xbee-gnrc] send: triggering the drivers send function\n");
res = dev->dev->driver->send(dev->dev, vector, count);
}
else {
DEBUG("[xbee-gnrc] send: unable to create iovec\n");
}
gnrc_pktbuf_release(pkt);
return res;
}
void gnrc_netdev_xbee_init(gnrc_netdev_t *gnrc_netdev, xbee_t *dev)
{
assert(gnrc_netdev && dev);
gnrc_netdev->send = xbee_adpt_send;
gnrc_netdev->recv = xbee_adpt_recv;
gnrc_netdev->dev = (netdev_t *)dev;
}

View File

@ -20,6 +20,7 @@
* @}
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -29,7 +30,6 @@
#include "shell.h"
#include "shell_commands.h"
#include "net/gnrc/netdev.h"
#include "net/netdev.h"
#include "net/lora.h"