mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc: make all gnrc modules sub-modules of gnrc
This commit is contained in:
parent
6b22e15a54
commit
58ff31bfe9
183
Makefile.dep
183
Makefile.dep
@ -2,16 +2,8 @@ ifneq (,$(filter gnrc_%,$(filter-out gnrc_netapi gnrc_netreg gnrc_netif% gnrc_pk
|
||||
USEMODULE += gnrc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
USEMODULE += ng_netif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_netif,$(USEMODULE)))
|
||||
USEMODULE += gnrc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_nomac,$(USEMODULE)))
|
||||
USEMODULE += gnrc
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += gnrc_netif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter at86rf2%,$(USEMODULE)))
|
||||
@ -27,100 +19,97 @@ ifneq (,$(filter xbee,$(USEMODULE)))
|
||||
USEMODULE += ieee802154
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_zep,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_zep,$(USEMODULE)))
|
||||
USEMODULE += hashes
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += ng_udp
|
||||
USEMODULE += gnrc_udp
|
||||
USEMODULE += random
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_rpl,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_rpl,$(USEMODULE)))
|
||||
USEMODULE += fib
|
||||
USEMODULE += gnrc
|
||||
USEMODULE += ng_ipv6_router_default
|
||||
USEMODULE += gnrc_ipv6_router_default
|
||||
USEMODULE += trickle
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ieee802154,$(USEMODULE)))
|
||||
ifneq (,$(filter ng_ipv6, $(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan
|
||||
ifneq (,$(filter gnrc_ipv6, $(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_router, $(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan # TODO: replace with ng_sixlowpan_router
|
||||
ifneq (,$(filter gnrc_ipv6_router, $(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan # TODO: replace with gnrc_sixlowpan_router
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_default, $(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan_default
|
||||
ifneq (,$(filter gnrc_ipv6_default, $(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan_default
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_router_default, $(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan_default # TODO: replace with ng_sixlowpan_router_default
|
||||
ifneq (,$(filter gnrc_ipv6_router_default, $(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan_default # TODO: replace with gnrc_sixlowpan_router_default
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan_default,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6_default
|
||||
USEMODULE += ng_sixlowpan
|
||||
USEMODULE += ng_sixlowpan_frag
|
||||
USEMODULE += ng_sixlowpan_iphc
|
||||
ifneq (,$(filter gnrc_sixlowpan_default,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
USEMODULE += gnrc_sixlowpan
|
||||
USEMODULE += gnrc_sixlowpan_frag
|
||||
USEMODULE += gnrc_sixlowpan_iphc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan_frag,$(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan
|
||||
ifneq (,$(filter gnrc_sixlowpan_frag,$(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan_iphc,$(USEMODULE)))
|
||||
USEMODULE += ng_sixlowpan
|
||||
USEMODULE += ng_sixlowpan_ctx
|
||||
ifneq (,$(filter gnrc_sixlowpan_iphc,$(USEMODULE)))
|
||||
USEMODULE += gnrc_sixlowpan
|
||||
USEMODULE += gnrc_sixlowpan_ctx
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6
|
||||
USEMODULE += ng_sixlowpan_netif
|
||||
USEMODULE += gnrc
|
||||
ifneq (,$(filter gnrc_sixlowpan,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_sixlowpan_netif
|
||||
USEMODULE += sixlowpan
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan_ctx,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_sixlowpan_ctx,$(USEMODULE)))
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_default,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6
|
||||
USEMODULE += ng_icmpv6
|
||||
USEMODULE += ng_ndp
|
||||
USEMODULE += ng_ndp_internal
|
||||
USEMODULE += ng_ndp_node
|
||||
ifneq (,$(filter gnrc_ipv6_default,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_icmpv6
|
||||
USEMODULE += gnrc_ndp
|
||||
USEMODULE += gnrc_ndp_internal
|
||||
USEMODULE += gnrc_ndp_node
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_router_default,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6_router
|
||||
USEMODULE += ng_icmpv6
|
||||
USEMODULE += ng_ndp
|
||||
USEMODULE += ng_ndp_internal
|
||||
USEMODULE += ng_ndp_node
|
||||
ifneq (,$(filter gnrc_ipv6_router_default,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6_router
|
||||
USEMODULE += gnrc_icmpv6
|
||||
USEMODULE += gnrc_ndp
|
||||
USEMODULE += gnrc_ndp_internal
|
||||
USEMODULE += gnrc_ndp_node
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ndp,$(USEMODULE)))
|
||||
USEMODULE += ng_icmpv6
|
||||
ifneq (,$(filter gnrc_ndp,$(USEMODULE)))
|
||||
USEMODULE += gnrc_icmpv6
|
||||
USEMODULE += random
|
||||
USEMODULE += timex
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_icmpv6_echo,$(USEMODULE)))
|
||||
USEMODULE += ng_icmpv6
|
||||
USEMODULE += gnrc
|
||||
ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
|
||||
USEMODULE += gnrc_icmpv6
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_icmpv6,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_icmpv6,$(USEMODULE)))
|
||||
USEMODULE += inet_csum
|
||||
USEMODULE += ng_ipv6
|
||||
USEMODULE += gnrc_ipv6
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_rpl_srh,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_rpl_srh,$(USEMODULE)))
|
||||
USEMODULE += ipv6_ext_rh
|
||||
endif
|
||||
|
||||
@ -128,27 +117,26 @@ ifneq (,$(filter ipv6_ext_rh,$(USEMODULE)))
|
||||
USEMODULE += ipv6_ext
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_ext,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_ipv6_ext,$(USEMODULE)))
|
||||
USEMODULE += ipv6_ext
|
||||
USEMODULE += ng_ipv6
|
||||
USEMODULE += gnrc_ipv6
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_router,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6
|
||||
ifneq (,$(filter gnrc_ipv6_router,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
|
||||
USEMODULE += inet_csum
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += ng_ipv6_hdr
|
||||
USEMODULE += ng_ipv6_nc
|
||||
USEMODULE += ng_ipv6_netif
|
||||
USEMODULE += gnrc
|
||||
USEMODULE += gnrc_ipv6_hdr
|
||||
USEMODULE += gnrc_ipv6_nc
|
||||
USEMODULE += gnrc_ipv6_netif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_hdr,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_ipv6_hdr,$(USEMODULE)))
|
||||
USEMODULE += ipv6_hdr
|
||||
USEMODULE += ng_pktbuf
|
||||
USEMODULE += gnrc_pktbuf
|
||||
endif
|
||||
|
||||
ifneq (,$(filter sixlowpan,$(USEMODULE)))
|
||||
@ -159,55 +147,42 @@ ifneq (,$(filter ipv6_hdr,$(USEMODULE)))
|
||||
USEMODULE += inet_csum
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_nc,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_ipv6_nc,$(USEMODULE)))
|
||||
USEMODULE += ipv6_addr
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_netif,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE)))
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += ng_netif
|
||||
USEMODULE += gnrc_netif
|
||||
USEMODULE += bitfield
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_udp,$(USEMODULE)))
|
||||
USEMODULE += gnrc
|
||||
ifneq (,$(filter gnrc_udp,$(USEMODULE)))
|
||||
USEMODULE += inet_csum
|
||||
USEMODULE += udp
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_nettest,$(USEMODULE)))
|
||||
USEMODULE += ng_netapi
|
||||
USEMODULE += ng_netreg
|
||||
USEMODULE += ng_netif
|
||||
USEMODULE += ng_pktbuf
|
||||
ifneq (,$(filter gnrc_nettest,$(USEMODULE)))
|
||||
USEMODULE += gnrc_netapi
|
||||
USEMODULE += gnrc_netreg
|
||||
USEMODULE += gnrc_netif
|
||||
USEMODULE += gnrc_pktbuf
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gnrc,$(USEMODULE)))
|
||||
USEMODULE += ng_netapi
|
||||
USEMODULE += ng_netreg
|
||||
USEMODULE += ng_netif
|
||||
USEMODULE += ng_netif_hdr
|
||||
USEMODULE += ng_pktbuf
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_pktdump,$(USEMODULE)))
|
||||
USEMODULE += ng_pktbuf
|
||||
ifneq (,$(filter gnrc_pktdump,$(USEMODULE)))
|
||||
USEMODULE += gnrc_pktbuf
|
||||
USEMODULE += od
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_pktbuf, $(USEMODULE)))
|
||||
ifeq (,$(filter ng_pktbuf_%, $(USEMODULE)))
|
||||
USEMODULE += ng_pktbuf_static
|
||||
ifneq (,$(filter gnrc_pktbuf, $(USEMODULE)))
|
||||
ifeq (,$(filter gnrc_pktbuf_%, $(USEMODULE)))
|
||||
USEMODULE += gnrc_pktbuf_static
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_pktbuf_%, $(USEMODULE)))
|
||||
USEMODULE += ng_pktbuf # make MODULE_NG_PKTBUF macro available for all implementations
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_slip,$(USEMODULE)))
|
||||
USEMODULE += gnrc
|
||||
ifneq (,$(filter gnrc_pktbuf_%, $(USEMODULE)))
|
||||
USEMODULE += gnrc_pktbuf # make MODULE_GNRC_PKTBUF macro available for all implementations
|
||||
endif
|
||||
|
||||
ifneq (,$(filter uart0,$(USEMODULE)))
|
||||
@ -268,8 +243,16 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
||||
USEMODULE += uart_stdio
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_netdev_eth,$(USEMODULE)))
|
||||
USEMODULE += ng_pktbuf
|
||||
ifneq (,$(filter gnrc_netdev_eth,$(USEMODULE)))
|
||||
USEMODULE += gnrc_pktbuf
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gnrc,$(USEMODULE)))
|
||||
USEMODULE += gnrc_netapi
|
||||
USEMODULE += gnrc_netreg
|
||||
USEMODULE += gnrc_netif
|
||||
USEMODULE += gnrc_netif_hdr
|
||||
USEMODULE += gnrc_pktbuf
|
||||
endif
|
||||
|
||||
ifneq (,$(filter hih6130,$(USEMODULE)))
|
||||
|
@ -134,10 +134,10 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
||||
include $(RIOTCPU)/$(CPU)/Makefile.include
|
||||
|
||||
# get number of interfaces straight before resolving dependencies
|
||||
NG_NETIF_NUMOF ?= 1
|
||||
GNRC_NETIF_NUMOF ?= 1
|
||||
|
||||
ifneq ($(NG_NETIF_NUMOF),1)
|
||||
CFLAGS += -DNG_NETIF_NUMOF=$(NG_NETIF_NUMOF)
|
||||
ifneq ($(GNRC_NETIF_NUMOF),1)
|
||||
CFLAGS += -DGNRC_NETIF_NUMOF=$(GNRC_NETIF_NUMOF)
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.dep
|
||||
|
@ -1,14 +1,14 @@
|
||||
PSEUDOMODULES += ng_netif_default
|
||||
PSEUDOMODULES += gnrc_netif_default
|
||||
PSEUDOMODULES += gnrc_ipv6_default
|
||||
PSEUDOMODULES += gnrc_ipv6_router
|
||||
PSEUDOMODULES += gnrc_ipv6_router_default
|
||||
PSEUDOMODULES += gnrc_sixlowpan_default
|
||||
PSEUDOMODULES += gnrc_pktbuf
|
||||
PSEUDOMODULES += ieee802154
|
||||
PSEUDOMODULES += ng_ipv6_default
|
||||
PSEUDOMODULES += ng_ipv6_router
|
||||
PSEUDOMODULES += ng_ipv6_router_default
|
||||
PSEUDOMODULES += pktqueue
|
||||
PSEUDOMODULES += ng_pktbuf
|
||||
PSEUDOMODULES += newlib
|
||||
PSEUDOMODULES += ng_sixlowpan_default
|
||||
PSEUDOMODULES += log
|
||||
PSEUDOMODULES += log_printfnoformat
|
||||
PSEUDOMODULES += newlib
|
||||
PSEUDOMODULES += pktqueue
|
||||
|
||||
# include variants of the AT86RF2xx drivers as pseudo modules
|
||||
PSEUDOMODULES += at86rf23%
|
||||
|
@ -1,4 +1,4 @@
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += at86rf231
|
||||
USEMODULE += ng_nomac
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += at86rf212b
|
||||
USEMODULE += ng_nomac
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
|
||||
# The RTT clock drives the core clock in the default configuration
|
||||
|
@ -1,5 +1,5 @@
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += dev_eth_tap
|
||||
USEMODULE += ng_netdev_eth
|
||||
USEMODULE += ng_nomac
|
||||
USEMODULE += gnrc_netdev_eth
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += kw2xrf
|
||||
USEMODULE += ng_nomac
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
ifneq (,$(filter ng_netif_default,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += at86rf233
|
||||
USEMODULE += ng_nomac
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
|
@ -31,8 +31,8 @@ extern "C" {
|
||||
#define UART0_BUFSIZE (32)
|
||||
#endif
|
||||
|
||||
#ifndef NG_PKTBUF_SIZE
|
||||
#define NG_PKTBUF_SIZE (2560) /* TODO: Make this value
|
||||
#ifndef GNRC_PKTBUF_SIZE
|
||||
#define GNRC_PKTBUF_SIZE (2560) /* TODO: Make this value
|
||||
* overall MTU dependent */
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -109,14 +109,14 @@ static int _recv(dev_eth_t *dev_eth, char *buf, int len) {
|
||||
dev_eth_tap_t *dev = (dev_eth_tap_t*)dev_eth;
|
||||
|
||||
int nread = real_read(dev->tap_fd, buf, len);
|
||||
DEBUG("ng_tapnet: read %d bytes\n", nread);
|
||||
DEBUG("gnrc_tapnet: read %d bytes\n", nread);
|
||||
|
||||
if (nread > 0) {
|
||||
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
|
||||
if (!(dev->promiscous) && !_is_addr_multicast(hdr->dst) &&
|
||||
!_is_addr_broadcast(hdr->dst) &&
|
||||
(memcmp(hdr->dst, dev->addr, ETHERNET_ADDR_LEN) != 0)) {
|
||||
DEBUG("ng_eth_dev: received for %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||
DEBUG("gnrc_eth_dev: received for %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||
"That's not me => Dropped\n",
|
||||
hdr->dst[0], hdr->dst[1], hdr->dst[2],
|
||||
hdr->dst[3], hdr->dst[4], hdr->dst[5]);
|
||||
@ -255,7 +255,7 @@ static int _init(dev_eth_t *ethdev)
|
||||
/* change mac addr so it differs from what the host is using */
|
||||
dev->addr[5]++;
|
||||
#endif
|
||||
DEBUG("ng_tapnet_init(): dev->addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
DEBUG("gnrc_tapnet_init(): dev->addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
dev->addr[0], dev->addr[1], dev->addr[2],
|
||||
dev->addr[3], dev->addr[4], dev->addr[5]);
|
||||
/* configure signal handler for fds */
|
||||
@ -267,14 +267,14 @@ static int _init(dev_eth_t *ethdev)
|
||||
#else
|
||||
/* configure fds to send signals on io */
|
||||
if (fcntl(dev->tap_fd, F_SETOWN, _native_pid) == -1) {
|
||||
err(EXIT_FAILURE, "ng_tapnet_init(): fcntl(F_SETOWN)");
|
||||
err(EXIT_FAILURE, "gnrc_tapnet_init(): fcntl(F_SETOWN)");
|
||||
}
|
||||
/* set file access mode to non-blocking */
|
||||
if (fcntl(dev->tap_fd, F_SETFL, O_NONBLOCK | O_ASYNC) == -1) {
|
||||
err(EXIT_FAILURE, "ng_tabnet_init(): fcntl(F_SETFL)");
|
||||
err(EXIT_FAILURE, "gnrc_tabnet_init(): fcntl(F_SETFL)");
|
||||
}
|
||||
#endif /* not OSX */
|
||||
DEBUG("ng_tapnet: initialized.\n");
|
||||
DEBUG("gnrc_tapnet: initialized.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ static void _cleanup(dev_eth_t *ethdev)
|
||||
}
|
||||
|
||||
#ifdef __MACH__
|
||||
static void _sigio_child(ng_tapnet_t *dev)
|
||||
static void _sigio_child(gnrc_tapnet_t *dev)
|
||||
{
|
||||
pid_t parent = _native_pid;
|
||||
if ((_sigio_child_pid = real_fork()) == -1) {
|
||||
|
@ -55,7 +55,7 @@
|
||||
#ifndef NRFMIN_H_
|
||||
#define NRFMIN_H_
|
||||
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -79,7 +79,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Reference to the netdev driver interface
|
||||
*/
|
||||
extern const ng_netdev_driver_t nrfmin_driver;
|
||||
extern const gnrc_netdev_driver_t nrfmin_driver;
|
||||
|
||||
/**
|
||||
* @brief Initialize the NRF51822 radio
|
||||
@ -91,7 +91,7 @@ extern const ng_netdev_driver_t nrfmin_driver;
|
||||
* @return 0 on success
|
||||
* @return -ENODEV if @p dev is invalid
|
||||
*/
|
||||
int nrfmin_init(ng_netdev_t *dev);
|
||||
int nrfmin_init(gnrc_netdev_t *dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ typedef struct __attribute__((packed)) {
|
||||
/**
|
||||
* @brief Pointer to the MAC layer event callback
|
||||
*/
|
||||
static ng_netdev_t *_netdev = NULL;
|
||||
static gnrc_netdev_t *_netdev = NULL;
|
||||
|
||||
/**
|
||||
* @brief Current state of the device
|
||||
@ -142,39 +142,39 @@ static volatile int _rx_next = 0;
|
||||
/*
|
||||
* Create an internal mapping between NETTYPE and NRFTYPE
|
||||
*/
|
||||
static inline ng_nettype_t _nrftype_to_nettype(uint8_t nrftype)
|
||||
static inline gnrc_nettype_t _nrftype_to_nettype(uint8_t nrftype)
|
||||
{
|
||||
switch (nrftype) {
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
case NRFTYPE_SIXLOWPAN:
|
||||
return NG_NETTYPE_SIXLOWPAN;
|
||||
return GNRC_NETTYPE_SIXLOWPAN;
|
||||
#endif
|
||||
#ifdef MODULE_NG_IPV6
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case NRFTYPE_IPV6:
|
||||
return NG_NETTYPE_IPV6;
|
||||
return GNRC_NETTYPE_IPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
case NRFTYPE_ICMPV6:
|
||||
return NG_NETTYPE_ICMPV6;
|
||||
return GNRC_NETTYPE_ICMPV6;
|
||||
#endif
|
||||
default:
|
||||
return NG_NETTYPE_UNDEF;
|
||||
return GNRC_NETTYPE_UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint8_t _nettype_to_nrftype(ng_nettype_t nettype)
|
||||
static inline uint8_t _nettype_to_nrftype(gnrc_nettype_t nettype)
|
||||
{
|
||||
switch (nettype) {
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
case NG_NETTYPE_SIXLOWPAN:
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
case GNRC_NETTYPE_SIXLOWPAN:
|
||||
return NRFTYPE_SIXLOWPAN;
|
||||
#endif
|
||||
#ifdef MODULE_NG_IPV6
|
||||
case NG_NETTYPE_IPV6:
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
return NRFTYPE_IPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
case NG_NETTYPE_ICMPV6:
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
case GNRC_NETTYPE_ICMPV6:
|
||||
return NRFTYPE_ICMPV6;
|
||||
#endif
|
||||
default:
|
||||
@ -437,7 +437,7 @@ void isr_radio(void)
|
||||
if (NRF_RADIO->CRCSTATUS != 1) {
|
||||
return;
|
||||
}
|
||||
msg.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.content.value = ISR_EVENT_RX_DONE;
|
||||
msg_send_int(&msg, _netdev->mac_pid);
|
||||
/* switch buffer */
|
||||
@ -466,10 +466,10 @@ void isr_radio(void)
|
||||
static void _receive_data(void)
|
||||
{
|
||||
packet_t *data;
|
||||
ng_pktsnip_t *pkt_head;
|
||||
ng_pktsnip_t *pkt;
|
||||
ng_netif_hdr_t *hdr;
|
||||
ng_nettype_t nettype;
|
||||
gnrc_pktsnip_t *pkt_head;
|
||||
gnrc_pktsnip_t *pkt;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
gnrc_nettype_t nettype;
|
||||
|
||||
/* only read data if we have somewhere to send it to */
|
||||
if (_netdev->event_cb == NULL) {
|
||||
@ -480,24 +480,24 @@ static void _receive_data(void)
|
||||
data = &(_rx_buf[_rx_next ^ 1]);
|
||||
|
||||
/* allocate and fill netif header */
|
||||
pkt_head = ng_pktbuf_add(NULL, NULL, sizeof(ng_netif_hdr_t) + 4,
|
||||
NG_NETTYPE_UNDEF);
|
||||
pkt_head = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_netif_hdr_t) + 4,
|
||||
GNRC_NETTYPE_UNDEF);
|
||||
if (pkt_head == NULL) {
|
||||
DEBUG("nrfmin: Error allocating netif header on RX\n");
|
||||
return;
|
||||
}
|
||||
hdr = (ng_netif_hdr_t *)pkt_head->data;
|
||||
ng_netif_hdr_init(hdr, 2, 2);
|
||||
hdr = (gnrc_netif_hdr_t *)pkt_head->data;
|
||||
gnrc_netif_hdr_init(hdr, 2, 2);
|
||||
hdr->if_pid = _netdev->mac_pid;
|
||||
ng_netif_hdr_set_src_addr(hdr, data->src_addr, 2);
|
||||
ng_netif_hdr_set_dst_addr(hdr, data->dst_addr, 2);
|
||||
gnrc_netif_hdr_set_src_addr(hdr, data->src_addr, 2);
|
||||
gnrc_netif_hdr_set_dst_addr(hdr, data->dst_addr, 2);
|
||||
|
||||
/* allocate and fill payload */
|
||||
nettype = _nrftype_to_nettype(data->proto);
|
||||
pkt = ng_pktbuf_add(pkt_head, data->payload, data->length - 6, nettype);
|
||||
pkt = gnrc_pktbuf_add(pkt_head, data->payload, data->length - 6, nettype);
|
||||
if (pkt == NULL) {
|
||||
DEBUG("nrfmin: Error allocating packet payload on RX\n");
|
||||
ng_pktbuf_release(pkt_head);
|
||||
gnrc_pktbuf_release(pkt_head);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -508,7 +508,7 @@ static void _receive_data(void)
|
||||
/*
|
||||
* Public interface functions
|
||||
*/
|
||||
int nrfmin_init(ng_netdev_t *dev)
|
||||
int nrfmin_init(gnrc_netdev_t *dev)
|
||||
{
|
||||
uint8_t cpuid[CPUID_ID_LEN];
|
||||
uint8_t tmp;
|
||||
@ -576,14 +576,14 @@ int nrfmin_init(ng_netdev_t *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _send(ng_netdev_t *dev, ng_pktsnip_t *pkt)
|
||||
int _send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
(void)dev;
|
||||
size_t size;
|
||||
size_t pos = 0;
|
||||
uint8_t *dst_addr;
|
||||
ng_netif_hdr_t *hdr;
|
||||
ng_pktsnip_t *payload;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *payload;
|
||||
|
||||
/* check packet */
|
||||
if (pkt == NULL || pkt->next == NULL) {
|
||||
@ -592,20 +592,20 @@ int _send(ng_netdev_t *dev, ng_pktsnip_t *pkt)
|
||||
}
|
||||
|
||||
/* check if payload is withing length bounds */
|
||||
size = ng_pkt_len(pkt->next);
|
||||
size = gnrc_pkt_len(pkt->next);
|
||||
if (size > CONF_PAYLOAD_LEN) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
DEBUG("nrfmin: Error sending packet: payload to large\n");
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
/* get netif header and check address length */
|
||||
hdr = (ng_netif_hdr_t *)pkt->data;
|
||||
hdr = (gnrc_netif_hdr_t *)pkt->data;
|
||||
if (hdr->dst_l2addr_len != 2) {
|
||||
DEBUG("nrfmin: Error sending packet: dest address has invalid size\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOMSG;
|
||||
}
|
||||
dst_addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
dst_addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
|
||||
DEBUG("nrfmin: Sending packet to %02x:%02x - size %u\n",
|
||||
dst_addr[0], dst_addr[1], size);
|
||||
@ -640,11 +640,11 @@ int _send(ng_netdev_t *dev, ng_pktsnip_t *pkt)
|
||||
NRF_RADIO->TASKS_TXEN = 1;
|
||||
|
||||
/* release packet */
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
int _add_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
int _add_event_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev->event_cb != NULL) {
|
||||
return -ENOBUFS;
|
||||
@ -653,7 +653,7 @@ int _add_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _rem_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
int _rem_event_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev->event_cb == cb) {
|
||||
dev->event_cb = NULL;
|
||||
@ -662,7 +662,7 @@ int _rem_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
int _get(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
{
|
||||
(void)dev;
|
||||
|
||||
@ -682,7 +682,7 @@ int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
}
|
||||
}
|
||||
|
||||
int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
int _set(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
{
|
||||
(void)dev;
|
||||
|
||||
@ -702,7 +702,7 @@ int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
}
|
||||
}
|
||||
|
||||
void _isr_event(ng_netdev_t *dev, uint32_t event_type)
|
||||
void _isr_event(gnrc_netdev_t *dev, uint32_t event_type)
|
||||
{
|
||||
switch (event_type) {
|
||||
case ISR_EVENT_RX_DONE:
|
||||
@ -717,7 +717,7 @@ void _isr_event(ng_netdev_t *dev, uint32_t event_type)
|
||||
/*
|
||||
* Mapping of netdev interface
|
||||
*/
|
||||
const ng_netdev_driver_t nrfmin_driver = {
|
||||
const gnrc_netdev_driver_t nrfmin_driver = {
|
||||
.send_data = _send,
|
||||
.add_event_callback = _add_event_cb,
|
||||
.rem_event_callback = _rem_event_cb,
|
||||
|
2
dist/tools/sniffer/README.md
vendored
2
dist/tools/sniffer/README.md
vendored
@ -8,7 +8,7 @@ nodes. It is primarily designed for sniffing wireless data traffic, but can also
|
||||
well be used for wired network traffic, as long as the used network devices
|
||||
support promiscuous mode and output of raw data.
|
||||
|
||||
The sniffer is based on a RIOT node running the [sniffer application](https://github.com/RIOT-OS/applications/tree/master/ng_sniffer) application located in [RIOTs application repository](https://github.com/RIOT-OS/applications).
|
||||
The sniffer is based on a RIOT node running the [sniffer application](https://github.com/RIOT-OS/applications/tree/master/sniffer) application located in [RIOTs application repository](https://github.com/RIOT-OS/applications).
|
||||
This node outputs received network traffic via a serial port in the Wireshark
|
||||
pcap format. This output is then parsed by the `sniffer.py` script included
|
||||
in this folder run on a host computer.
|
||||
|
2
dist/tools/tunslip/README.md
vendored
2
dist/tools/tunslip/README.md
vendored
@ -1,7 +1,7 @@
|
||||
Creating a SLIP network interface
|
||||
=================================
|
||||
|
||||
The module `ng_slip` (Serial line IP) enables the RIOT network stack to
|
||||
The module `gnrc_slip` (Serial line IP) enables the RIOT network stack to
|
||||
communicate IP packets over the serial interface. This collection of tools
|
||||
originally from Contiki [1] enables Linux to interpret this data. Though there
|
||||
is a tool for such operations on Linux (`slattach`) it is only able to handle
|
||||
|
@ -45,7 +45,7 @@ static void _irq_handler(void *arg)
|
||||
at86rf2xx_t *dev = (at86rf2xx_t *) arg;
|
||||
|
||||
/* tell driver thread about the interrupt */
|
||||
msg.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
msg_send(&msg, dev->mac_pid);
|
||||
}
|
||||
|
||||
@ -143,10 +143,10 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_RX_START, false);
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_RX_END, true);
|
||||
/* set default protocol */
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
dev->proto = NG_NETTYPE_SIXLOWPAN;
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
dev->proto = GNRC_NETTYPE_SIXLOWPAN;
|
||||
#else
|
||||
dev->proto = NG_NETTYPE_UNDEF;
|
||||
dev->proto = GNRC_NETTYPE_UNDEF;
|
||||
#endif
|
||||
/* enable safe mode (protect RX FIFO until reading data starts) */
|
||||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_CTRL_2,
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
/* TODO: generalize and move to (gnrc_)ieee802154 */
|
||||
static size_t _make_data_frame_hdr(at86rf2xx_t *dev, uint8_t *buf,
|
||||
ng_netif_hdr_t *hdr)
|
||||
gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
@ -43,8 +43,8 @@ static size_t _make_data_frame_hdr(at86rf2xx_t *dev, uint8_t *buf,
|
||||
buf[1] = IEEE802154_FCF_VERS_V1;
|
||||
|
||||
/* if AUTOACK is enabled, then we also expect ACKs for this packet */
|
||||
if (!(hdr->flags & NG_NETIF_HDR_FLAGS_BROADCAST) &&
|
||||
!(hdr->flags & NG_NETIF_HDR_FLAGS_MULTICAST) &&
|
||||
if (!(hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) &&
|
||||
!(hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST) &&
|
||||
(dev->options & AT86RF2XX_OPT_AUTOACK)) {
|
||||
buf[0] |= IEEE802154_FCF_ACK_REQ;
|
||||
}
|
||||
@ -56,20 +56,20 @@ static size_t _make_data_frame_hdr(at86rf2xx_t *dev, uint8_t *buf,
|
||||
|
||||
/* fill in destination address */
|
||||
if (hdr->flags &
|
||||
(NG_NETIF_HDR_FLAGS_BROADCAST | NG_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_SHORT;
|
||||
buf[pos++] = 0xff;
|
||||
buf[pos++] = 0xff;
|
||||
}
|
||||
else if (hdr->dst_l2addr_len == 2) {
|
||||
uint8_t *dst_addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
uint8_t *dst_addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_SHORT;
|
||||
buf[pos++] = dst_addr[1];
|
||||
buf[pos++] = dst_addr[0];
|
||||
}
|
||||
else if (hdr->dst_l2addr_len == 8) {
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_LONG;
|
||||
uint8_t *dst_addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
uint8_t *dst_addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
buf[pos++] = dst_addr[i];
|
||||
}
|
||||
@ -142,13 +142,13 @@ static size_t _get_frame_hdr_len(uint8_t *mhr)
|
||||
}
|
||||
|
||||
/* TODO: generalize and move to (gnrc_)ieee802154 */
|
||||
static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
static gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint8_t *addr;
|
||||
uint8_t src_len, dst_len;
|
||||
ng_pktsnip_t *snip;
|
||||
ng_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *snip;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
|
||||
/* figure out address sizes */
|
||||
tmp = mhr[1] & IEEE802154_FCF_SRC_ADDR_MASK;
|
||||
@ -178,17 +178,17 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
return NULL;
|
||||
}
|
||||
/* allocate space for header */
|
||||
snip = ng_pktbuf_add(NULL, NULL, sizeof(ng_netif_hdr_t) + src_len + dst_len,
|
||||
NG_NETTYPE_NETIF);
|
||||
snip = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_netif_hdr_t) + src_len + dst_len,
|
||||
GNRC_NETTYPE_NETIF);
|
||||
if (snip == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
/* fill header */
|
||||
hdr = (ng_netif_hdr_t *)snip->data;
|
||||
ng_netif_hdr_init(hdr, src_len, dst_len);
|
||||
hdr = (gnrc_netif_hdr_t *)snip->data;
|
||||
gnrc_netif_hdr_init(hdr, src_len, dst_len);
|
||||
if (dst_len > 0) {
|
||||
tmp = 5 + dst_len;
|
||||
addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
for (int i = 0; i < dst_len; i++) {
|
||||
addr[i] = mhr[5 + (dst_len - i) - 1];
|
||||
}
|
||||
@ -200,7 +200,7 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
tmp += 2;
|
||||
}
|
||||
if (src_len > 0) {
|
||||
addr = ng_netif_hdr_get_src_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_src_addr(hdr);
|
||||
for (int i = 0; i < src_len; i++) {
|
||||
addr[i] = mhr[tmp + (src_len - i) - 1];
|
||||
}
|
||||
@ -209,10 +209,10 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
}
|
||||
|
||||
|
||||
static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
static int _send(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
|
||||
ng_pktsnip_t *snip;
|
||||
gnrc_pktsnip_t *snip;
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
|
||||
size_t len;
|
||||
|
||||
@ -220,23 +220,23 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
return -ENOMSG;
|
||||
}
|
||||
if (dev == NULL) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* create 802.15.4 header */
|
||||
len = _make_data_frame_hdr(dev, mhr, (ng_netif_hdr_t *)pkt->data);
|
||||
len = _make_data_frame_hdr(dev, mhr, (gnrc_netif_hdr_t *)pkt->data);
|
||||
if (len == 0) {
|
||||
DEBUG("[at86rf2xx] error: unable to create 802.15.4 header\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOMSG;
|
||||
}
|
||||
/* check if packet (header + payload + FCS) fits into FIFO */
|
||||
snip = pkt->next;
|
||||
if ((ng_pkt_len(snip) + len + 2) > AT86RF2XX_MAX_PKT_LENGTH) {
|
||||
if ((gnrc_pkt_len(snip) + len + 2) > AT86RF2XX_MAX_PKT_LENGTH) {
|
||||
printf("[at86rf2xx] error: packet too large (%u byte) to be send\n",
|
||||
ng_pkt_len(snip) + len + 2);
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pkt_len(snip) + len + 2);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
at86rf2xx_tx_exec(dev);
|
||||
}
|
||||
/* release packet */
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
/* return the number of bytes that were actually send out */
|
||||
return (int)len;
|
||||
}
|
||||
@ -262,8 +262,8 @@ static void _receive_data(at86rf2xx_t *dev)
|
||||
{
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
|
||||
size_t pkt_len, hdr_len;
|
||||
ng_pktsnip_t *hdr, *payload = NULL;
|
||||
ng_netif_hdr_t *netif;
|
||||
gnrc_pktsnip_t *hdr, *payload = NULL;
|
||||
gnrc_netif_hdr_t *netif;
|
||||
|
||||
/* get the size of the received packet (unlocks frame buffer protection) */
|
||||
pkt_len = at86rf2xx_rx_len(dev);
|
||||
@ -275,7 +275,7 @@ static void _receive_data(at86rf2xx_t *dev)
|
||||
|
||||
/* in raw mode, just read the binary dump into the packet buffer */
|
||||
if (dev->options & AT86RF2XX_OPT_RAWDUMP) {
|
||||
payload = ng_pktbuf_add(NULL, NULL, pkt_len, NG_NETTYPE_UNDEF);
|
||||
payload = gnrc_pktbuf_add(NULL, NULL, pkt_len, GNRC_NETTYPE_UNDEF);
|
||||
if (payload == NULL ) {
|
||||
DEBUG("[at86rf2xx] error: unable to allocate RAW data\n");
|
||||
return;
|
||||
@ -300,16 +300,16 @@ static void _receive_data(at86rf2xx_t *dev)
|
||||
return;
|
||||
}
|
||||
/* fill missing fields in netif header */
|
||||
netif = (ng_netif_hdr_t *)hdr->data;
|
||||
netif = (gnrc_netif_hdr_t *)hdr->data;
|
||||
netif->if_pid = dev->mac_pid;
|
||||
at86rf2xx_rx_read(dev, &(netif->lqi), 1, pkt_len);
|
||||
netif->rssi = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_ED_LEVEL);
|
||||
|
||||
/* allocate payload */
|
||||
payload = ng_pktbuf_add(hdr, NULL, (pkt_len - hdr_len), dev->proto);
|
||||
payload = gnrc_pktbuf_add(hdr, NULL, (pkt_len - hdr_len), dev->proto);
|
||||
if (payload == NULL) {
|
||||
DEBUG("[at86rf2xx] error: unable to allocate incoming payload\n");
|
||||
ng_pktbuf_release(hdr);
|
||||
gnrc_pktbuf_release(hdr);
|
||||
return;
|
||||
}
|
||||
/* copy payload */
|
||||
@ -357,7 +357,7 @@ netopt_state_t _get_state(at86rf2xx_t *dev)
|
||||
}
|
||||
}
|
||||
|
||||
static int _get(ng_netdev_t *device, netopt_t opt, void *val, size_t max_len)
|
||||
static int _get(gnrc_netdev_t *device, netopt_t opt, void *val, size_t max_len)
|
||||
{
|
||||
if (device == NULL) {
|
||||
return -ENODEV;
|
||||
@ -421,11 +421,11 @@ static int _get(ng_netdev_t *device, netopt_t opt, void *val, size_t max_len)
|
||||
return sizeof(eui64_t);
|
||||
|
||||
case NETOPT_PROTO:
|
||||
if (max_len < sizeof(ng_nettype_t)) {
|
||||
if (max_len < sizeof(gnrc_nettype_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
*((ng_nettype_t *)val) = dev->proto;
|
||||
return sizeof(ng_nettype_t);
|
||||
*((gnrc_nettype_t *)val) = dev->proto;
|
||||
return sizeof(gnrc_nettype_t);
|
||||
|
||||
case NETOPT_CHANNEL:
|
||||
if (max_len < sizeof(uint16_t)) {
|
||||
@ -535,7 +535,7 @@ static int _get(ng_netdev_t *device, netopt_t opt, void *val, size_t max_len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set(ng_netdev_t *device, netopt_t opt, void *val, size_t len)
|
||||
static int _set(gnrc_netdev_t *device, netopt_t opt, void *val, size_t len)
|
||||
{
|
||||
at86rf2xx_t *dev = (at86rf2xx_t *) device;
|
||||
|
||||
@ -661,7 +661,7 @@ static int _set(ng_netdev_t *device, netopt_t opt, void *val, size_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _add_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _add_event_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -674,7 +674,7 @@ static int _add_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _rem_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _rem_event_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -687,7 +687,7 @@ static int _rem_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _isr_event(ng_netdev_t *device, uint32_t event_type)
|
||||
static void _isr_event(gnrc_netdev_t *device, uint32_t event_type)
|
||||
{
|
||||
at86rf2xx_t *dev = (at86rf2xx_t *) device;
|
||||
uint8_t irq_mask;
|
||||
@ -720,7 +720,7 @@ static void _isr_event(ng_netdev_t *device, uint32_t event_type)
|
||||
}
|
||||
}
|
||||
|
||||
const ng_netdev_driver_t at86rf2xx_driver = {
|
||||
const gnrc_netdev_driver_t at86rf2xx_driver = {
|
||||
.send_data = _send,
|
||||
.add_event_callback = _add_event_cb,
|
||||
.rem_event_callback = _rem_event_cb,
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef AT86RF2XX_NETDEV_H_
|
||||
#define AT86RF2XX_NETDEV_H_
|
||||
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -28,7 +28,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Reference to the netdev device driver struct
|
||||
*/
|
||||
extern const ng_netdev_driver_t at86rf2xx_driver;
|
||||
extern const gnrc_netdev_driver_t at86rf2xx_driver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "board.h"
|
||||
#include "periph/spi.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "at86rf2xx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -133,8 +133,8 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
/* netdev fields */
|
||||
const ng_netdev_driver_t *driver; /**< pointer to the devices interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
const gnrc_netdev_driver_t *driver; /**< pointer to the devices interface */
|
||||
gnrc_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< the driver's thread's PID */
|
||||
/* device specific fields */
|
||||
spi_t spi; /**< used SPI device */
|
||||
@ -142,7 +142,7 @@ typedef struct {
|
||||
gpio_t sleep_pin; /**< sleep pin */
|
||||
gpio_t reset_pin; /**< reset pin */
|
||||
gpio_t int_pin; /**< external interrupt pin */
|
||||
ng_nettype_t proto; /**< protocol the radio expects */
|
||||
gnrc_nettype_t proto; /**< protocol the radio expects */
|
||||
uint8_t state; /**< current state of the radio */
|
||||
uint8_t seq_nr; /**< sequence number to use next */
|
||||
uint8_t frame_len; /**< length of the current TX frame */
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "board.h"
|
||||
#include "periph/spi.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -41,10 +41,10 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default protocol for data that is coming in
|
||||
*/
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
#define KW2XRF_DEFAULT_PROTOCOL NG_NETTYPE_SIXLOWPAN
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
#define KW2XRF_DEFAULT_PROTOCOL GNRC_NETTYPE_SIXLOWPAN
|
||||
#else
|
||||
#define KW2XRF_DEFAULT_PROTOCOL NG_NETTYPE_UNDEF
|
||||
#define KW2XRF_DEFAULT_PROTOCOL GNRC_NETTYPE_UNDEF
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -104,8 +104,8 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
/* netdev fields */
|
||||
ng_netdev_driver_t const *driver; /**< Pointer to the devices interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< Netdev event callback */
|
||||
gnrc_netdev_driver_t const *driver; /**< Pointer to the devices interface */
|
||||
gnrc_netdev_event_cb_t event_cb; /**< Netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< The driver's thread's PID */
|
||||
/* driver specific fields */
|
||||
uint8_t buf[KW2XRF_MAX_PKT_LENGTH]; /**< Buffer for incoming or outgoing packets */
|
||||
@ -117,7 +117,7 @@ typedef struct {
|
||||
uint8_t addr_long[8]; /**< The long address the radio device is using */
|
||||
uint16_t option; /**< Bit field to save enable/disable options */
|
||||
int8_t tx_power; /**< The current tx-power setting of the device */
|
||||
ng_nettype_t proto; /**< Protocol the interface speaks */
|
||||
gnrc_nettype_t proto; /**< Protocol the interface speaks */
|
||||
} kw2xrf_t;
|
||||
|
||||
/**
|
||||
@ -147,7 +147,7 @@ typedef struct kw2xrf_params {
|
||||
/**
|
||||
* @brief Reference to the KW2XRF driver interface
|
||||
*/
|
||||
extern const ng_netdev_driver_t kw2xrf_driver;
|
||||
extern const gnrc_netdev_driver_t kw2xrf_driver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default protocol for data that is coming in
|
||||
*/
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
#define XBEE_DEFAULT_PROTOCOL (NG_NETTYPE_SIXLOWPAN)
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
#define XBEE_DEFAULT_PROTOCOL (GNRC_NETTYPE_SIXLOWPAN)
|
||||
#else
|
||||
#define XBEE_DEFAULT_PROTOCOL (NG_NETTYPE_UNDEF)
|
||||
#define XBEE_DEFAULT_PROTOCOL (GNRC_NETTYPE_UNDEF)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -108,14 +108,14 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
/* netdev fields */
|
||||
ng_netdev_driver_t const *driver; /**< pointer to the devices interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
gnrc_netdev_driver_t const *driver; /**< pointer to the devices interface */
|
||||
gnrc_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< the driver's thread's PID */
|
||||
/* device driver specific fields */
|
||||
uart_t uart; /**< UART interfaced used */
|
||||
gpio_t reset_pin; /**< GPIO pin connected to RESET */
|
||||
gpio_t sleep_pin; /**< GPIO pin connected to SLEEP */
|
||||
ng_nettype_t proto; /**< protocol the interface speaks */
|
||||
gnrc_nettype_t proto; /**< protocol the interface speaks */
|
||||
uint8_t options; /**< options field */
|
||||
uint8_t addr_flags; /**< address flags as defined above */
|
||||
uint8_t addr_short[2]; /**< onw 802.15.4 short address */
|
||||
@ -145,7 +145,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Reference to the XBee driver interface
|
||||
*/
|
||||
extern const ng_netdev_driver_t xbee_driver;
|
||||
extern const gnrc_netdev_driver_t xbee_driver;
|
||||
|
||||
/**
|
||||
* @brief Initialize the given Xbee device
|
||||
|
@ -278,7 +278,7 @@ void kw2xrf_irq_handler(void *args)
|
||||
kw2xrf_t *dev = (kw2xrf_t *)args;
|
||||
|
||||
/* notify driver thread about the interrupt */
|
||||
msg.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
msg_send_int(&msg, dev->mac_pid);
|
||||
}
|
||||
|
||||
@ -315,22 +315,22 @@ int kw2xrf_set_pan(kw2xrf_t *dev, uint16_t pan)
|
||||
|
||||
int kw2xrf_get_proto(kw2xrf_t *dev, uint8_t *val, size_t max)
|
||||
{
|
||||
if (max < sizeof(ng_nettype_t)) {
|
||||
if (max < sizeof(gnrc_nettype_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
memcpy(val, &(dev->proto), sizeof(ng_nettype_t));
|
||||
return sizeof(ng_nettype_t);
|
||||
memcpy(val, &(dev->proto), sizeof(gnrc_nettype_t));
|
||||
return sizeof(gnrc_nettype_t);
|
||||
}
|
||||
|
||||
int kw2xrf_set_proto(kw2xrf_t *dev, uint8_t *val, size_t len)
|
||||
{
|
||||
if (len != sizeof(ng_nettype_t)) {
|
||||
if (len != sizeof(gnrc_nettype_t)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(&(dev->proto), val, sizeof(ng_nettype_t));
|
||||
return sizeof(ng_nettype_t);
|
||||
memcpy(&(dev->proto), val, sizeof(gnrc_nettype_t));
|
||||
return sizeof(gnrc_nettype_t);
|
||||
}
|
||||
|
||||
int kw2xrf_on(kw2xrf_t *dev)
|
||||
@ -468,7 +468,7 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kw2xrf_add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
int kw2xrf_add_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -482,7 +482,7 @@ int kw2xrf_add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kw2xrf_rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
int kw2xrf_rem_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -508,7 +508,7 @@ uint64_t kw2xrf_get_addr_long(kw2xrf_t *dev)
|
||||
return addr;
|
||||
}
|
||||
|
||||
int kw2xrf_get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
int kw2xrf_get(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
{
|
||||
kw2xrf_t *dev = (kw2xrf_t *)netdev;
|
||||
|
||||
@ -696,7 +696,7 @@ void kw2xrf_set_option(kw2xrf_t *dev, uint16_t option, bool state)
|
||||
}
|
||||
}
|
||||
|
||||
int kw2xrf_set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
int kw2xrf_set(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
{
|
||||
kw2xrf_t *dev = (kw2xrf_t *)netdev;
|
||||
|
||||
@ -849,13 +849,13 @@ static size_t _get_frame_hdr_len(uint8_t *mhr)
|
||||
}
|
||||
|
||||
/* TODO: generalize and move to (gnrc_)ieee802154 */
|
||||
static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
static gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint8_t *addr;
|
||||
uint8_t src_len, dst_len;
|
||||
ng_pktsnip_t *snip;
|
||||
ng_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *snip;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
|
||||
/* figure out address sizes */
|
||||
tmp = mhr[1] & IEEE802154_FCF_SRC_ADDR_MASK;
|
||||
@ -889,20 +889,20 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
}
|
||||
|
||||
/* allocate space for header */
|
||||
snip = ng_pktbuf_add(NULL, NULL, sizeof(ng_netif_hdr_t) + src_len + dst_len,
|
||||
NG_NETTYPE_NETIF);
|
||||
snip = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_netif_hdr_t) + src_len + dst_len,
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (snip == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill header */
|
||||
hdr = (ng_netif_hdr_t *)snip->data;
|
||||
ng_netif_hdr_init(hdr, src_len, dst_len);
|
||||
hdr = (gnrc_netif_hdr_t *)snip->data;
|
||||
gnrc_netif_hdr_init(hdr, src_len, dst_len);
|
||||
|
||||
if (dst_len > 0) {
|
||||
tmp = 5 + dst_len;
|
||||
addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
|
||||
for (int i = 0; i < dst_len; i++) {
|
||||
addr[i] = mhr[5 + (dst_len - i) - 1];
|
||||
@ -917,7 +917,7 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
}
|
||||
|
||||
if (src_len > 0) {
|
||||
addr = ng_netif_hdr_get_src_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_src_addr(hdr);
|
||||
|
||||
for (int i = 0; i < src_len; i++) {
|
||||
addr[i] = mhr[tmp + (src_len - i) - 1];
|
||||
@ -930,8 +930,8 @@ static ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
void _receive_data(kw2xrf_t *dev)
|
||||
{
|
||||
size_t pkt_len, hdr_len;
|
||||
ng_pktsnip_t *hdr, *payload = NULL;
|
||||
ng_netif_hdr_t *netif;
|
||||
gnrc_pktsnip_t *hdr, *payload = NULL;
|
||||
gnrc_netif_hdr_t *netif;
|
||||
|
||||
/* get size of the received packet */
|
||||
pkt_len = kw2xrf_read_dreg(MKW2XDM_RX_FRM_LEN);
|
||||
@ -946,7 +946,7 @@ void _receive_data(kw2xrf_t *dev)
|
||||
|
||||
/* If RAW-mode is selected direclty forward pkt, MAC does the rest */
|
||||
if (dev->option & KW2XRF_OPT_RAWDUMP) {
|
||||
payload = ng_pktbuf_add(NULL, NULL, pkt_len, NG_NETTYPE_UNDEF);
|
||||
payload = gnrc_pktbuf_add(NULL, NULL, pkt_len, GNRC_NETTYPE_UNDEF);
|
||||
|
||||
if (payload == NULL) {
|
||||
DEBUG("kw2xf: error: unable to allocate RAW data\n");
|
||||
@ -975,7 +975,7 @@ void _receive_data(kw2xrf_t *dev)
|
||||
}
|
||||
|
||||
/* fill missing fields in netif header */
|
||||
netif = (ng_netif_hdr_t *)hdr->data;
|
||||
netif = (gnrc_netif_hdr_t *)hdr->data;
|
||||
netif->if_pid = thread_getpid();
|
||||
netif->lqi = dev->buf[pkt_len];
|
||||
/* lqi and rssi are directly related to each other in the kw2x-device.
|
||||
@ -984,19 +984,19 @@ void _receive_data(kw2xrf_t *dev)
|
||||
*/
|
||||
netif->rssi = -((netif->lqi) - 286.6) / 2.69333;
|
||||
|
||||
payload = ng_pktbuf_add(hdr, (void *) & (dev->buf[hdr_len]),
|
||||
pkt_len - hdr_len - 2, dev->proto);
|
||||
payload = gnrc_pktbuf_add(hdr, (void *) & (dev->buf[hdr_len]),
|
||||
pkt_len - hdr_len - 2, dev->proto);
|
||||
|
||||
if (payload == NULL) {
|
||||
DEBUG("kw2xrf: ERROR allocating payload in packet buffer on RX\n");
|
||||
ng_pktbuf_release(hdr);
|
||||
gnrc_pktbuf_release(hdr);
|
||||
return;
|
||||
}
|
||||
|
||||
dev->event_cb(NETDEV_EVENT_RX_COMPLETE, payload);
|
||||
}
|
||||
|
||||
void kw2xrf_isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
void kw2xrf_isr_event(gnrc_netdev_t *netdev, uint32_t event_type)
|
||||
{
|
||||
kw2xrf_t *dev = (kw2xrf_t *)netdev;
|
||||
uint8_t irqst1 = kw2xrf_read_dreg(MKW2XDM_IRQSTS1);
|
||||
@ -1040,20 +1040,20 @@ void kw2xrf_isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Move to ng_ieee802.15.4 as soon as ready */
|
||||
int _assemble_tx_buf(kw2xrf_t *dev, ng_pktsnip_t *pkt)
|
||||
/* TODO: Move to gnrc_ieee802.15.4 as soon as ready */
|
||||
int _assemble_tx_buf(kw2xrf_t *dev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
ng_netif_hdr_t *hdr;
|
||||
hdr = (ng_netif_hdr_t *)pkt->data;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
hdr = (gnrc_netif_hdr_t *)pkt->data;
|
||||
int index = 0;
|
||||
|
||||
if (dev == NULL) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* get netif header check address length */
|
||||
hdr = (ng_netif_hdr_t *)pkt->data;
|
||||
hdr = (gnrc_netif_hdr_t *)pkt->data;
|
||||
|
||||
/* FCF, set up data frame, request for ack, panid_compression */
|
||||
/* TODO: Currently we don´t request for Ack in this device.
|
||||
@ -1079,7 +1079,7 @@ int _assemble_tx_buf(kw2xrf_t *dev, ng_pktsnip_t *pkt)
|
||||
|
||||
/* fill in destination address */
|
||||
if (hdr->flags &
|
||||
(NG_NETIF_HDR_FLAGS_BROADCAST | NG_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
dev->buf[2] = 0x88;
|
||||
dev->buf[index++] = 0xff;
|
||||
dev->buf[index++] = 0xff;
|
||||
@ -1091,8 +1091,8 @@ int _assemble_tx_buf(kw2xrf_t *dev, ng_pktsnip_t *pkt)
|
||||
/* set to short addressing mode */
|
||||
dev->buf[2] = 0x88;
|
||||
/* set destination address, byte order is inverted */
|
||||
dev->buf[index++] = (ng_netif_hdr_get_dst_addr(hdr))[1];
|
||||
dev->buf[index++] = (ng_netif_hdr_get_dst_addr(hdr))[0];
|
||||
dev->buf[index++] = (gnrc_netif_hdr_get_dst_addr(hdr))[1];
|
||||
dev->buf[index++] = (gnrc_netif_hdr_get_dst_addr(hdr))[0];
|
||||
/* set source pan_id */
|
||||
//dev->buf[index++] = (uint8_t)((dev->radio_pan) >> 8);
|
||||
//dev->buf[index++] = (uint8_t)((dev->radio_pan) & 0xff);
|
||||
@ -1103,8 +1103,8 @@ int _assemble_tx_buf(kw2xrf_t *dev, ng_pktsnip_t *pkt)
|
||||
else if (hdr->dst_l2addr_len == 8) {
|
||||
/* default to use long address mode for src and dst */
|
||||
dev->buf[2] |= 0xcc;
|
||||
/* set destination address located directly after ng_ifhrd_t in memory */
|
||||
memcpy(&(dev->buf)[index], ng_netif_hdr_get_dst_addr(hdr), 8);
|
||||
/* set destination address located directly after gnrc_ifhrd_t in memory */
|
||||
memcpy(&(dev->buf)[index], gnrc_netif_hdr_get_dst_addr(hdr), 8);
|
||||
index += 8;
|
||||
/* set source pan_id, wireshark expects it there */
|
||||
//dev->buf[index++] = (uint8_t)((dev->radio_pan) >> 8);
|
||||
@ -1115,14 +1115,14 @@ int _assemble_tx_buf(kw2xrf_t *dev, ng_pktsnip_t *pkt)
|
||||
index += 8;
|
||||
}
|
||||
else {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
int kw2xrf_send(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
int index = 0;
|
||||
kw2xrf_t *dev = (kw2xrf_t *) netdev;
|
||||
@ -1131,22 +1131,22 @@ int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
ng_pktsnip_t *payload = pkt->next;
|
||||
gnrc_pktsnip_t *payload = pkt->next;
|
||||
|
||||
if (netdev == NULL) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (pkt->type == NG_NETTYPE_NETIF) {
|
||||
if (pkt->type == GNRC_NETTYPE_NETIF) {
|
||||
/* Build header and fills this already into the tx-buf */
|
||||
index = _assemble_tx_buf(dev, pkt);
|
||||
DEBUG("Assembled header for NG_NETTYPE_UNDEF to tx-buf, index: %i\n", index);
|
||||
DEBUG("Assembled header for GNRC_NETTYPE_UNDEF to tx-buf, index: %i\n", index);
|
||||
}
|
||||
else if (pkt->type == NG_NETTYPE_UNDEF) {
|
||||
else if (pkt->type == GNRC_NETTYPE_UNDEF) {
|
||||
/* IEEE packet is already included in the header,
|
||||
* no need to build the header manually */
|
||||
DEBUG("Incoming packet of type NG_NETTYPE_802154: %i\n", index);
|
||||
DEBUG("Incoming packet of type GNRC_NETTYPE_802154: %i\n", index);
|
||||
DEBUG("size of pktsnip: %i\n", pkt->size);
|
||||
|
||||
for (int i = 0; i < pkt->size; i++) {
|
||||
@ -1165,7 +1165,7 @@ int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
while (payload) {
|
||||
/* check we don't exceed FIFO size */
|
||||
if (index + 2 + payload->size > KW2XRF_MAX_PKT_LENGTH) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
DEBUG("Packet exceeded FIFO size.\n");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
@ -1184,7 +1184,7 @@ int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
|
||||
dev->buf[0] = index + 1; /* set packet size */
|
||||
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
DEBUG("kw2xrf: packet with size %i loaded to tx_buf\n", dev->buf[0]);
|
||||
kw2xrf_write_fifo(dev->buf, dev->buf[0]);
|
||||
|
||||
@ -1197,7 +1197,7 @@ int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
}
|
||||
|
||||
/* implementation of the netdev interface */
|
||||
const ng_netdev_driver_t kw2xrf_driver = {
|
||||
const gnrc_netdev_driver_t kw2xrf_driver = {
|
||||
.send_data = kw2xrf_send,
|
||||
.add_event_callback = kw2xrf_add_cb,
|
||||
.rem_event_callback = kw2xrf_rem_cb,
|
||||
|
@ -205,7 +205,7 @@ static void _rx_cb(void *arg, char c)
|
||||
dev->rx_buf[dev->rx_count++] = (uint8_t)c;
|
||||
if (dev->rx_count == dev->rx_limit) {
|
||||
/* packet is complete */
|
||||
msg.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.content.value = ISR_EVENT_RX_DONE;
|
||||
msg_send_int(&msg, dev->mac_pid);
|
||||
dev->int_state = XBEE_INT_STATE_IDLE;
|
||||
@ -387,20 +387,20 @@ static int _set_panid(xbee_t *dev, uint8_t *val, size_t len)
|
||||
|
||||
static int _get_proto(xbee_t *dev, uint8_t *val, size_t max)
|
||||
{
|
||||
if (max < sizeof(ng_nettype_t)) {
|
||||
if (max < sizeof(gnrc_nettype_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
memcpy(val, &(dev->proto), sizeof(ng_nettype_t));
|
||||
return sizeof(ng_nettype_t);
|
||||
memcpy(val, &(dev->proto), sizeof(gnrc_nettype_t));
|
||||
return sizeof(gnrc_nettype_t);
|
||||
}
|
||||
|
||||
static int _set_proto(xbee_t *dev, uint8_t *val, size_t len)
|
||||
{
|
||||
if (len != sizeof(ng_nettype_t)) {
|
||||
if (len != sizeof(gnrc_nettype_t)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
memcpy(&(dev->proto), val, sizeof(ng_nettype_t));
|
||||
return sizeof(ng_nettype_t);
|
||||
memcpy(&(dev->proto), val, sizeof(gnrc_nettype_t));
|
||||
return sizeof(gnrc_nettype_t);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -487,42 +487,42 @@ int xbee_init(xbee_t *dev, uart_t uart, uint32_t baudrate,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool _is_broadcast(ng_netif_hdr_t *hdr)
|
||||
static inline bool _is_broadcast(gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
/* IEEE 802.15.4 does not support multicast so we need to check both flags */
|
||||
return (bool)(hdr->flags & (NG_NETIF_HDR_FLAGS_BROADCAST |
|
||||
NG_NETIF_HDR_FLAGS_MULTICAST));
|
||||
return (bool)(hdr->flags & (GNRC_NETIF_HDR_FLAGS_BROADCAST |
|
||||
GNRC_NETIF_HDR_FLAGS_MULTICAST));
|
||||
}
|
||||
|
||||
static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
static int _send(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
xbee_t *dev = (xbee_t *)netdev;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
ng_netif_hdr_t *hdr;
|
||||
ng_pktsnip_t *payload;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *payload;
|
||||
|
||||
/* check device descriptor and packet */
|
||||
if (pkt == NULL) {
|
||||
return -ENOMSG;
|
||||
}
|
||||
if (dev == NULL) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* figure out the size of the payload to send */
|
||||
size = ng_pkt_len(pkt->next);
|
||||
size = gnrc_pkt_len(pkt->next);
|
||||
if (size > XBEE_MAX_PAYLOAD_LENGTH) {
|
||||
DEBUG("xbee: Error sending data, payload length exceeds limit\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
/* get netif header check address length and flags */
|
||||
hdr = (ng_netif_hdr_t *)pkt->data;
|
||||
hdr = (gnrc_netif_hdr_t *)pkt->data;
|
||||
if (!((hdr->dst_l2addr_len == 2) || (hdr->dst_l2addr_len == 8) ||
|
||||
_is_broadcast(hdr))) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
@ -543,14 +543,14 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
dev->tx_buf[1] = (uint8_t)((size + 5) >> 8);
|
||||
dev->tx_buf[2] = (uint8_t)(size + 5);
|
||||
dev->tx_buf[3] = API_ID_TX_SHORT_ADDR;
|
||||
memcpy(dev->tx_buf + 5, ng_netif_hdr_get_dst_addr(hdr), 2);
|
||||
memcpy(dev->tx_buf + 5, gnrc_netif_hdr_get_dst_addr(hdr), 2);
|
||||
pos = 7;
|
||||
}
|
||||
else {
|
||||
dev->tx_buf[1] = (uint8_t)((size + 11) >> 8);
|
||||
dev->tx_buf[2] = (uint8_t)(size + 11);
|
||||
dev->tx_buf[3] = API_ID_TX_LONG_ADDR;
|
||||
memcpy(dev->tx_buf + 5, ng_netif_hdr_get_dst_addr(hdr), 8);
|
||||
memcpy(dev->tx_buf + 5, gnrc_netif_hdr_get_dst_addr(hdr), 8);
|
||||
pos = 13;
|
||||
}
|
||||
/* set options */
|
||||
@ -570,12 +570,12 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
/* start transmission */
|
||||
uart_tx_begin(dev->uart);
|
||||
/* release data */
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
/* return number of payload byte */
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _add_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -587,7 +587,7 @@ static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _rem_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -599,7 +599,7 @@ static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
static int _get(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
{
|
||||
xbee_t *dev = (xbee_t *)netdev;
|
||||
if (dev == NULL) {
|
||||
@ -652,7 +652,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
}
|
||||
}
|
||||
|
||||
static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
static int _set(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
{
|
||||
xbee_t *dev = (xbee_t *)netdev;
|
||||
if (dev == NULL) {
|
||||
@ -676,12 +676,12 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
}
|
||||
}
|
||||
|
||||
static void _isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
static void _isr_event(gnrc_netdev_t *netdev, uint32_t event_type)
|
||||
{
|
||||
xbee_t *dev = (xbee_t *)netdev;
|
||||
ng_pktsnip_t *pkt_head;
|
||||
ng_pktsnip_t *pkt;
|
||||
ng_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *pkt_head;
|
||||
gnrc_pktsnip_t *pkt;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
size_t pos;
|
||||
size_t addr_len;
|
||||
uint8_t cksum = 0;
|
||||
@ -715,34 +715,34 @@ static void _isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
}
|
||||
|
||||
/* allocate and fill interface header */
|
||||
pkt_head = ng_pktbuf_add(NULL, NULL,
|
||||
sizeof(ng_netif_hdr_t) + (2 * addr_len),
|
||||
NG_NETTYPE_NETIF);
|
||||
pkt_head = gnrc_pktbuf_add(NULL, NULL,
|
||||
sizeof(gnrc_netif_hdr_t) + (2 * addr_len),
|
||||
GNRC_NETTYPE_NETIF);
|
||||
if (pkt_head == NULL) {
|
||||
DEBUG("xbee: Error allocating netif header in packet buffer on RX\n");
|
||||
dev->rx_count = 0;
|
||||
return;
|
||||
}
|
||||
hdr = (ng_netif_hdr_t *)pkt_head->data;
|
||||
hdr = (gnrc_netif_hdr_t *)pkt_head->data;
|
||||
hdr->src_l2addr_len = (uint8_t)addr_len;
|
||||
hdr->dst_l2addr_len = (uint8_t)addr_len;
|
||||
hdr->if_pid = dev->mac_pid;
|
||||
hdr->rssi = dev->rx_buf[2 + addr_len];
|
||||
hdr->lqi = 0;
|
||||
ng_netif_hdr_set_src_addr(hdr, &(dev->rx_buf[1]), addr_len);
|
||||
gnrc_netif_hdr_set_src_addr(hdr, &(dev->rx_buf[1]), addr_len);
|
||||
if (addr_len == 2) {
|
||||
ng_netif_hdr_set_dst_addr(hdr, dev->addr_short, 2);
|
||||
gnrc_netif_hdr_set_dst_addr(hdr, dev->addr_short, 2);
|
||||
}
|
||||
else {
|
||||
ng_netif_hdr_set_dst_addr(hdr, dev->addr_long.uint8, 8);
|
||||
gnrc_netif_hdr_set_dst_addr(hdr, dev->addr_long.uint8, 8);
|
||||
}
|
||||
pos = 3 + addr_len;
|
||||
/* allocate and copy payload */
|
||||
pkt = ng_pktbuf_add(pkt_head, &(dev->rx_buf[pos]), dev->rx_limit - pos - 1,
|
||||
dev->proto);
|
||||
pkt = gnrc_pktbuf_add(pkt_head, &(dev->rx_buf[pos]), dev->rx_limit - pos - 1,
|
||||
dev->proto);
|
||||
if (pkt == NULL) {
|
||||
DEBUG("xbee: Error allocating payload in packet buffer on RX\n");
|
||||
ng_pktbuf_release(pkt_head);
|
||||
gnrc_pktbuf_release(pkt_head);
|
||||
dev->rx_count = 0;
|
||||
return;
|
||||
}
|
||||
@ -756,7 +756,7 @@ static void _isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
/*
|
||||
* The drivers netdev interface
|
||||
*/
|
||||
const ng_netdev_driver_t xbee_driver = {
|
||||
const gnrc_netdev_driver_t xbee_driver = {
|
||||
.send_data = _send,
|
||||
.add_event_callback = _add_cb,
|
||||
.rem_event_callback = _rem_cb,
|
||||
|
@ -17,17 +17,17 @@ BOARD_BLACKLIST := arduino-mega2560 spark-core
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
|
||||
USEMODULE += ng_netif_default
|
||||
USEMODULE += gnrc_netif_default
|
||||
USEMODULE += auto_init_ng_netif
|
||||
# Specify the mandatory networking modules for IPv6 and UDP
|
||||
USEMODULE += ng_ipv6_router_default
|
||||
USEMODULE += ng_udp
|
||||
USEMODULE += gnrc_ipv6_router_default
|
||||
USEMODULE += gnrc_udp
|
||||
# Add a routing protocol
|
||||
USEMODULE += ng_rpl
|
||||
USEMODULE += gnrc_rpl
|
||||
# This application dumps received packets to STDIO using the pktdump module
|
||||
USEMODULE += ng_pktdump
|
||||
USEMODULE += gnrc_pktdump
|
||||
# Additional networking modules that can be dropped if not needed
|
||||
USEMODULE += ng_icmpv6_echo
|
||||
USEMODULE += gnrc_icmpv6_echo
|
||||
# Add also the shell, some shell commands (which are based on uart0 in this app)
|
||||
USEMODULE += uart0
|
||||
USEMODULE += shell
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
#include "kernel.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ng_udp.h"
|
||||
#include "net/ng_pktdump.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "net/gnrc/pktdump.h"
|
||||
|
||||
static ng_netreg_entry_t server = {NULL, NG_NETREG_DEMUX_CTX_ALL,
|
||||
static gnrc_netreg_entry_t server = {NULL, GNRC_NETREG_DEMUX_CTX_ALL,
|
||||
KERNEL_PID_UNDEF};
|
||||
|
||||
|
||||
@ -35,9 +35,9 @@ static void send(char *addr_str, char *port_str, char *data)
|
||||
{
|
||||
uint8_t port[2];
|
||||
uint16_t tmp;
|
||||
ng_pktsnip_t *payload, *udp, *ip;
|
||||
gnrc_pktsnip_t *payload, *udp, *ip;
|
||||
ipv6_addr_t addr;
|
||||
ng_netreg_entry_t *sendto;
|
||||
gnrc_netreg_entry_t *sendto;
|
||||
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
@ -54,37 +54,37 @@ static void send(char *addr_str, char *port_str, char *data)
|
||||
port[1] = tmp >> 8;
|
||||
|
||||
/* allocate payload */
|
||||
payload = ng_pktbuf_add(NULL, data, strlen(data), NG_NETTYPE_UNDEF);
|
||||
payload = gnrc_pktbuf_add(NULL, data, strlen(data), GNRC_NETTYPE_UNDEF);
|
||||
if (payload == NULL) {
|
||||
puts("Error: unable to copy data to packet buffer");
|
||||
return;
|
||||
}
|
||||
/* allocate UDP header, set source port := destination port */
|
||||
udp = ng_udp_hdr_build(payload, port, 2, port, 2);
|
||||
udp = gnrc_udp_hdr_build(payload, port, 2, port, 2);
|
||||
if (udp == NULL) {
|
||||
puts("Error: unable to allocate UDP header");
|
||||
ng_pktbuf_release(payload);
|
||||
gnrc_pktbuf_release(payload);
|
||||
return;
|
||||
}
|
||||
/* allocate IPv6 header */
|
||||
ip = ng_ipv6_hdr_build(udp, NULL, 0, (uint8_t *)&addr, sizeof(addr));
|
||||
ip = gnrc_ipv6_hdr_build(udp, NULL, 0, (uint8_t *)&addr, sizeof(addr));
|
||||
if (ip == NULL) {
|
||||
puts("Error: unable to allocate IPv6 header");
|
||||
ng_pktbuf_release(udp);
|
||||
gnrc_pktbuf_release(udp);
|
||||
return;
|
||||
}
|
||||
/* send packet */
|
||||
sendto = ng_netreg_lookup(NG_NETTYPE_UDP, NG_NETREG_DEMUX_CTX_ALL);
|
||||
sendto = gnrc_netreg_lookup(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL);
|
||||
if (sendto == NULL) {
|
||||
puts("Error: unable to locate UDP thread");
|
||||
ng_pktbuf_release(ip);
|
||||
gnrc_pktbuf_release(ip);
|
||||
return;
|
||||
}
|
||||
ng_pktbuf_hold(ip, ng_netreg_num(NG_NETTYPE_UDP,
|
||||
NG_NETREG_DEMUX_CTX_ALL) - 1);
|
||||
gnrc_pktbuf_hold(ip, gnrc_netreg_num(GNRC_NETTYPE_UDP,
|
||||
GNRC_NETREG_DEMUX_CTX_ALL) - 1);
|
||||
while (sendto != NULL) {
|
||||
ng_netapi_send(sendto->pid, ip);
|
||||
sendto = ng_netreg_getnext(sendto);
|
||||
gnrc_netapi_send(sendto->pid, ip);
|
||||
sendto = gnrc_netreg_getnext(sendto);
|
||||
}
|
||||
printf("Success: send %i byte to %s:%u\n", payload->size, addr_str, tmp);
|
||||
}
|
||||
@ -106,9 +106,9 @@ static void start_server(char *port_str)
|
||||
return;
|
||||
}
|
||||
/* start server (which means registering pktdump for the chosen port) */
|
||||
server.pid = ng_pktdump_getpid();
|
||||
server.pid = gnrc_pktdump_getpid();
|
||||
server.demux_ctx = (uint32_t)port;
|
||||
ng_netreg_register(NG_NETTYPE_UDP, &server);
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
|
||||
printf("Success: started UDP server on port %" PRIu16 "\n", port);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ static void stop_server(void)
|
||||
return;
|
||||
}
|
||||
/* stop server */
|
||||
ng_netreg_unregister(NG_NETTYPE_UDP, &server);
|
||||
gnrc_netreg_unregister(GNRC_NETTYPE_UDP, &server);
|
||||
server.pid = KERNEL_PID_UNDEF;
|
||||
puts("Success: stopped UDP server");
|
||||
}
|
||||
|
87
sys/Makefile
87
sys/Makefile
@ -31,102 +31,18 @@ endif
|
||||
ifneq (,$(filter gnrc gnrc_%,$(USEMODULE)))
|
||||
DIRS += net/gnrc
|
||||
endif
|
||||
ifneq (,$(filter ng_icmpv6,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_icmpv6
|
||||
endif
|
||||
ifneq (,$(filter ng_icmpv6_echo,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_icmpv6/echo
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_ext,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6/ext
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_hdr,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6/hdr
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_nc,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6/nc
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_netif,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6/netif
|
||||
endif
|
||||
ifneq (,$(filter inet_csum,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/inet_csum
|
||||
endif
|
||||
ifneq (,$(filter ng_ndp,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ndp
|
||||
endif
|
||||
ifneq (,$(filter ng_ndp_internal,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ndp/internal
|
||||
endif
|
||||
ifneq (,$(filter ng_ndp_node,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ndp/node
|
||||
endif
|
||||
ifneq (,$(filter ng_netapi,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_netapi
|
||||
endif
|
||||
ifneq (,$(filter ng_netif,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_netif
|
||||
endif
|
||||
ifneq (,$(filter ng_netif_hdr,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_netif/hdr
|
||||
endif
|
||||
ifneq (,$(filter ng_netreg,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_netreg
|
||||
endif
|
||||
ifneq (,$(filter ng_nettest,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_nettest
|
||||
endif
|
||||
ifneq (,$(filter ng_nomac,$(USEMODULE)))
|
||||
DIRS += net/link_layer/ng_nomac
|
||||
endif
|
||||
ifneq (,$(filter cipher_modes,$(USEMODULE)))
|
||||
DIRS += crypto/modes
|
||||
endif
|
||||
ifneq (,$(filter ng_pktbuf_static,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_pktbuf_static
|
||||
endif
|
||||
ifneq (,$(filter ng_zep,$(USEMODULE)))
|
||||
DIRS += net/application_layer/ng_zep
|
||||
endif
|
||||
ifneq (,$(filter ng_rpl,$(USEMODULE)))
|
||||
DIRS += net/routing/ng_rpl
|
||||
endif
|
||||
ifneq (,$(filter ng_rpl_srh,$(USEMODULE)))
|
||||
DIRS += net/routing/ng_rpl/srh
|
||||
endif
|
||||
ifneq (,$(filter ng_sixlowpan,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_sixlowpan
|
||||
endif
|
||||
ifneq (,$(filter ng_sixlowpan_ctx,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_sixlowpan/ctx
|
||||
endif
|
||||
ifneq (,$(filter ng_sixlowpan_frag,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_sixlowpan/frag
|
||||
endif
|
||||
ifneq (,$(filter ng_sixlowpan_iphc,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_sixlowpan/iphc
|
||||
endif
|
||||
ifneq (,$(filter ng_sixlowpan_netif,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_sixlowpan/netif
|
||||
endif
|
||||
ifneq (,$(filter ng_slip,$(USEMODULE)))
|
||||
DIRS += net/link_layer/ng_slip
|
||||
endif
|
||||
ifneq (,$(filter nhdp,$(USEMODULE)))
|
||||
DIRS += net/routing/nhdp
|
||||
endif
|
||||
ifneq (,$(filter ng_pktdump,$(USEMODULE)))
|
||||
DIRS += net/crosslayer/ng_pktdump
|
||||
endif
|
||||
ifneq (,$(filter fib,$(USEMODULE)))
|
||||
DIRS += net/network_layer/fib
|
||||
endif
|
||||
ifneq (,$(filter ng_udp,$(USEMODULE)))
|
||||
DIRS += net/transport_layer/ng_udp
|
||||
endif
|
||||
ifneq (,$(filter sixlowpan,$(USEMODULE)))
|
||||
DIRS += net/network_layer/sixlowpan
|
||||
endif
|
||||
@ -139,9 +55,6 @@ endif
|
||||
ifneq (,$(filter cpp11-compat,$(USEMODULE)))
|
||||
DIRS += cpp11-compat
|
||||
endif
|
||||
ifneq (,$(filter ng_netdev_eth,$(USEMODULE)))
|
||||
DIRS += net/link_layer/ng_netdev_eth
|
||||
endif
|
||||
ifneq (,$(filter udp,$(USEMODULE)))
|
||||
DIRS += net/transport_layer/udp
|
||||
endif
|
||||
|
@ -28,7 +28,7 @@ ifneq (,$(filter cpp11-compat,$(USEMODULE)))
|
||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/cpp11-compat/include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_slip,$(USEMODULE)))
|
||||
ifneq (,$(filter gnrc_slip,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
endif
|
||||
|
||||
|
@ -52,32 +52,32 @@
|
||||
#include "periph/rtc.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
#include "net/ng_sixlowpan.h"
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
#include "net/gnrc/sixlowpan.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_IPV6
|
||||
#include "net/ng_ipv6.h"
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#ifdef MODULE_GNRC_IPV6_NETIF
|
||||
#include "net/gnrc/ipv6/netif.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_L2_PING
|
||||
#include "l2_ping.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_PKTBUF
|
||||
#include "net/ng_pktbuf.h"
|
||||
#ifdef MODULE_GNRC_PKTBUF
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_PKTDUMP
|
||||
#include "net/ng_pktdump.h"
|
||||
#ifdef MODULE_GNRC_PKTDUMP
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_UDP
|
||||
#include "net/ng_udp.h"
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
#include "net/gnrc/udp.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_DEV_ETH_AUTOINIT
|
||||
@ -133,25 +133,25 @@ void auto_init(void)
|
||||
extern void profiling_init(void);
|
||||
profiling_init();
|
||||
#endif
|
||||
#ifdef MODULE_NG_PKTBUF
|
||||
DEBUG("Auto init ng_pktbuf module\n");
|
||||
ng_pktbuf_init();
|
||||
#ifdef MODULE_GNRC_PKTBUF
|
||||
DEBUG("Auto init gnrc_pktbuf module\n");
|
||||
gnrc_pktbuf_init();
|
||||
#endif
|
||||
#ifdef MODULE_NG_PKTDUMP
|
||||
DEBUG("Auto init ng_pktdump module.\n");
|
||||
ng_pktdump_init();
|
||||
#ifdef MODULE_GNRC_PKTDUMP
|
||||
DEBUG("Auto init gnrc_pktdump module.\n");
|
||||
gnrc_pktdump_init();
|
||||
#endif
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
DEBUG("Auto init ng_sixlowpan module.\n");
|
||||
ng_sixlowpan_init();
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
DEBUG("Auto init gnrc_sixlowpan module.\n");
|
||||
gnrc_sixlowpan_init();
|
||||
#endif
|
||||
#ifdef MODULE_NG_IPV6
|
||||
DEBUG("Auto init ng_ipv6 module.\n");
|
||||
ng_ipv6_init();
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
DEBUG("Auto init gnrc_ipv6 module.\n");
|
||||
gnrc_ipv6_init();
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
DEBUG("Auto init UDP module.\n");
|
||||
ng_udp_init();
|
||||
gnrc_udp_init();
|
||||
#endif
|
||||
#ifdef MODULE_FIB
|
||||
DEBUG("Auto init FIB module.\n");
|
||||
@ -177,14 +177,14 @@ void auto_init(void)
|
||||
auto_init_kw2xrf();
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_NETDEV_ETH
|
||||
#ifdef MODULE_GNRC_NETDEV_ETH
|
||||
extern void auto_init_ng_netdev_eth(void);
|
||||
auto_init_ng_netdev_eth();
|
||||
#endif
|
||||
|
||||
#endif /* MODULE_AUTO_INIT_NG_NETIF */
|
||||
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
ng_ipv6_netif_init_by_dev();
|
||||
#ifdef MODULE_GNRC_IPV6_NETIF
|
||||
gnrc_ipv6_netif_init_by_dev();
|
||||
#endif
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifdef MODULE_AT86RF2XX
|
||||
|
||||
#include "board.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "at86rf2xx.h"
|
||||
@ -58,9 +58,9 @@ void auto_init_at86rf2xx(void)
|
||||
DEBUG("Error initializing AT86RF2xx radio device!");
|
||||
}
|
||||
else {
|
||||
ng_nomac_init(_nomac_stacks[i],
|
||||
AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_PRIO,
|
||||
"at86rfxx", (ng_netdev_t *)&at86rf2xx_devs[i]);
|
||||
gnrc_nomac_init(_nomac_stacks[i],
|
||||
AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_PRIO,
|
||||
"at86rfxx", (gnrc_netdev_t *)&at86rf2xx_devs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifdef MODULE_KW2XRF
|
||||
|
||||
#include "board.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "kw2xrf.h"
|
||||
@ -59,14 +59,14 @@ void auto_init_kw2xrf(void)
|
||||
DEBUG("Error initializing KW2xrf radio device!");
|
||||
}
|
||||
else {
|
||||
ng_nomac_init(_nomac_stacks[i],
|
||||
KW2XRF_MAC_STACKSIZE, KW2XRF_MAC_PRIO,
|
||||
"kw2xrf", (ng_netdev_t *)&kw2xrf_devs[i]);
|
||||
gnrc_nomac_init(_nomac_stacks[i],
|
||||
KW2XRF_MAC_STACKSIZE, KW2XRF_MAC_PRIO,
|
||||
"kw2xrf", (gnrc_netdev_t *)&kw2xrf_devs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
typedef int dont_be_pedantic;
|
||||
#endif /* MODULE_NG_KW2XRF */
|
||||
#endif /* MODULE_GNRC_KW2XRF */
|
||||
|
||||
/** @} */
|
||||
|
@ -18,13 +18,13 @@
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*/
|
||||
|
||||
#ifdef MODULE_NG_NETDEV_ETH
|
||||
#ifdef MODULE_GNRC_NETDEV_ETH
|
||||
|
||||
#include "board.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "net/ng_netdev_eth.h"
|
||||
#include "net/gnrc/netdev_eth.h"
|
||||
#include "net/dev_eth.h"
|
||||
#include "dev_eth_tap.h"
|
||||
|
||||
@ -43,18 +43,18 @@ static char _nomac_stack[NETDEV_ETH_MAC_STACKSIZE];
|
||||
void auto_init_ng_netdev_eth(void)
|
||||
{
|
||||
DEBUG("Initializing NETDEV_ETH device\n");
|
||||
int res = ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);
|
||||
int res = gnrc_netdev_eth_init(&gnrc_netdev_eth, (dev_eth_t*)&dev_eth_tap);
|
||||
|
||||
if (res < 0) {
|
||||
DEBUG("Error initializing NETDEV_ETH device!");
|
||||
}
|
||||
else {
|
||||
ng_nomac_init(_nomac_stack, NETDEV_ETH_MAC_STACKSIZE, NETDEV_ETH_MAC_PRIO,
|
||||
"tapnet", (ng_netdev_t *)&ng_netdev_eth);
|
||||
gnrc_nomac_init(_nomac_stack, NETDEV_ETH_MAC_STACKSIZE, NETDEV_ETH_MAC_PRIO,
|
||||
"tapnet", (gnrc_netdev_t *)&gnrc_netdev_eth);
|
||||
}
|
||||
}
|
||||
#else
|
||||
typedef int dont_be_pedantic;
|
||||
#endif /* MODULE_NG_NETDEV_ETH */
|
||||
#endif /* MODULE_GNRC_NETDEV_ETH */
|
||||
|
||||
/** @} */
|
||||
|
@ -17,10 +17,10 @@
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifdef MODULE_NG_SLIP
|
||||
#ifdef MODULE_GNRC_SLIP
|
||||
|
||||
#include "board.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "slip.h"
|
||||
@ -29,9 +29,9 @@
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
#define SLIP_NUM (sizeof(ng_slip_params)/sizeof(ng_slip_params_t))
|
||||
#define SLIP_NUM (sizeof(gnrc_slip_params)/sizeof(gnrc_slip_params_t))
|
||||
|
||||
static ng_slip_dev_t slip_devs[SLIP_NUM];
|
||||
static gnrc_slip_dev_t slip_devs[SLIP_NUM];
|
||||
|
||||
/**
|
||||
* @brief Define stack parameters for the MAC layer thread
|
||||
@ -48,11 +48,11 @@ static char _slip_stacks[SLIP_STACKSIZE][SLIP_NUM];
|
||||
void auto_init_slip(void)
|
||||
{
|
||||
for (int i = 0; i < SLIP_NUM; i++) {
|
||||
const ng_slip_params_t *p = &ng_slip_params[i];
|
||||
const gnrc_slip_params_t *p = &gnrc_slip_params[i];
|
||||
DEBUG("Initializing SLIP radio at UART_%d\n", p->uart);
|
||||
kernel_pid_t res = ng_slip_init(&slip_devs[i], p->uart, p->baudrate,
|
||||
_slip_stacks[i], SLIP_STACKSIZE,
|
||||
SLIP_PRIO);
|
||||
kernel_pid_t res = gnrc_slip_init(&slip_devs[i], p->uart, p->baudrate,
|
||||
_slip_stacks[i], SLIP_STACKSIZE,
|
||||
SLIP_PRIO);
|
||||
|
||||
if (res <= KERNEL_PID_UNDEF) {
|
||||
DEBUG("Error initializing XBee radio device!");
|
||||
@ -62,5 +62,5 @@ void auto_init_slip(void)
|
||||
|
||||
#else
|
||||
typedef int dont_be_pedantic;
|
||||
#endif /* MODULE_NG_SLIP */
|
||||
#endif /* MODULE_GNRC_SLIP */
|
||||
/** @} */
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifdef MODULE_XBEE
|
||||
|
||||
#include "board.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "xbee.h"
|
||||
@ -60,9 +60,9 @@ void auto_init_xbee(void)
|
||||
DEBUG("Error initializing XBee radio device!");
|
||||
}
|
||||
else {
|
||||
ng_nomac_init(_nomac_stacks[i],
|
||||
XBEE_MAC_STACKSIZE, XBEE_MAC_PRIO, "xbee",
|
||||
(ng_netdev_t *)&xbee_devs[i]);
|
||||
gnrc_nomac_init(_nomac_stacks[i],
|
||||
XBEE_MAC_STACKSIZE, XBEE_MAC_PRIO, "xbee",
|
||||
(gnrc_netdev_t *)&xbee_devs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,18 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NETBASE_H_
|
||||
#define NG_NETBASE_H_
|
||||
#ifndef GNRC_NETBASE_H_
|
||||
#define GNRC_NETBASE_H_
|
||||
|
||||
#include "net/netopt.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/ng_netapi.h"
|
||||
#include "net/ng_netreg.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/ng_netif/hdr.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
#include "net/gnrc/netreg.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -41,5 +41,5 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETBASE_H_ */
|
||||
#endif /* GNRC_NETBASE_H_ */
|
||||
/** @} */
|
||||
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_icmpv6 Internet Control Message Protocol for IPv6
|
||||
* @ingroup net_ng_ipv6
|
||||
* @defgroup net_gnrc__icmpv6 Internet Control Message Protocol for IPv6
|
||||
* @ingroup net_gnrc__ipv6
|
||||
* @brief Basic implementation of ICMPv6
|
||||
*
|
||||
* @see <a href="https://tools.ietf.org/html/rfc4443">
|
||||
@ -24,15 +24,15 @@
|
||||
* @todo build error messages
|
||||
*/
|
||||
|
||||
#ifndef NG_ICMPV6_H_
|
||||
#define NG_ICMPV6_H_
|
||||
#ifndef GNRC_ICMPV6_H_
|
||||
#define GNRC_ICMPV6_H_
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/icmpv6.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#include "net/ng_icmpv6/echo.h"
|
||||
#include "net/ng_icmpv6/error.h"
|
||||
#include "net/gnrc/icmpv6/echo.h"
|
||||
#include "net/gnrc/icmpv6/error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -44,7 +44,7 @@ extern "C" {
|
||||
* @param[in] iface The receiving interface
|
||||
* @param[in] pkt The packet to demultiplex.
|
||||
*/
|
||||
void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt);
|
||||
void gnrc_icmpv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Builds an ICMPv6 message for sending.
|
||||
@ -58,7 +58,7 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt);
|
||||
* @return The ICMPv6 message on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ng_pktsnip_t *ng_icmpv6_build(ng_pktsnip_t *next, uint8_t type, uint8_t code, size_t size);
|
||||
gnrc_pktsnip_t *gnrc_icmpv6_build(gnrc_pktsnip_t *next, uint8_t type, uint8_t code, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Calculates the checksum for an ICMPv6 packet.
|
||||
@ -69,17 +69,17 @@ ng_pktsnip_t *ng_icmpv6_build(ng_pktsnip_t *next, uint8_t type, uint8_t code, si
|
||||
* from. NULL if none is needed.
|
||||
*
|
||||
* @return 0, on success.
|
||||
* @return -EINVAL, if ng_pktsnip_t::type of @p pkt was not NG_NETTYPE_ICMPV6
|
||||
* @return -ENOENT, if ng_pktsnip_t::type of @p pseudo_hdr was not
|
||||
* NG_NETTYPE_IPV6
|
||||
* @return -EINVAL, if gnrc_pktsnip_t::type of @p pkt was not GNRC_NETTYPE_ICMPV6
|
||||
* @return -ENOENT, if gnrc_pktsnip_t::type of @p pseudo_hdr was not
|
||||
* GNRC_NETTYPE_IPV6
|
||||
*/
|
||||
int ng_icmpv6_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr);
|
||||
int gnrc_icmpv6_calc_csum(gnrc_pktsnip_t *hdr, gnrc_pktsnip_t *pseudo_hdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_ICMPV6_H_ */
|
||||
#endif /* GNRC_ICMPV6_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_icmpv6_echo ICMPv6 echo messages
|
||||
* @ingroup net_ng_icmpv6
|
||||
* @defgroup net_gnrc_icmpv6_echo ICMPv6 echo messages
|
||||
* @ingroup net_gnrc_icmpv6
|
||||
* @brief ICMPv6 echo request and reply
|
||||
* @{
|
||||
*
|
||||
@ -17,8 +17,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_ICMPV6_ECHO_H_
|
||||
#define NG_ICMPV6_ECHO_H_
|
||||
#ifndef GNRC_ICMPV6_ECHO_H_
|
||||
#define GNRC_ICMPV6_ECHO_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -43,8 +43,8 @@ extern "C" {
|
||||
* @return The echo message on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ng_pktsnip_t *ng_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq,
|
||||
uint8_t *data, size_t data_len);
|
||||
gnrc_pktsnip_t *gnrc_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq,
|
||||
uint8_t *data, size_t data_len);
|
||||
|
||||
/**
|
||||
* @brief Builds an ICMPv6 echo request for sending.
|
||||
@ -61,10 +61,10 @@ ng_pktsnip_t *ng_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq,
|
||||
* @return The echo request message on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
static inline ng_pktsnip_t *ng_icmpv6_echo_req_build(uint16_t id, uint16_t seq,
|
||||
static inline gnrc_pktsnip_t *gnrc_icmpv6_echo_req_build(uint16_t id, uint16_t seq,
|
||||
uint8_t *data, size_t data_len)
|
||||
{
|
||||
return ng_icmpv6_echo_build(ICMPV6_ECHO_REQ, id, seq, data, data_len);
|
||||
return gnrc_icmpv6_echo_build(ICMPV6_ECHO_REQ, id, seq, data, data_len);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,10 +82,10 @@ static inline ng_pktsnip_t *ng_icmpv6_echo_req_build(uint16_t id, uint16_t seq,
|
||||
* @return The echo reply message on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
static inline ng_pktsnip_t *ng_icmpv6_echo_rep_build(uint16_t id, uint16_t seq,
|
||||
static inline gnrc_pktsnip_t *gnrc_icmpv6_echo_rep_build(uint16_t id, uint16_t seq,
|
||||
uint8_t *data, size_t data_len)
|
||||
{
|
||||
return ng_icmpv6_echo_build(ICMPV6_ECHO_REP, id, seq, data, data_len);
|
||||
return gnrc_icmpv6_echo_build(ICMPV6_ECHO_REP, id, seq, data, data_len);
|
||||
}
|
||||
|
||||
|
||||
@ -98,12 +98,12 @@ static inline ng_pktsnip_t *ng_icmpv6_echo_rep_build(uint16_t id, uint16_t seq,
|
||||
* @param[in] len Length of the echo request message (ipv6_hdr_t::len
|
||||
* of @p ipv6_hdr minus length of extension headers).
|
||||
*/
|
||||
void ng_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr,
|
||||
icmpv6_echo_t *echo, uint16_t len);
|
||||
void gnrc_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr,
|
||||
icmpv6_echo_t *echo, uint16_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_ICMPV6_ECHO_H_ */
|
||||
#endif /* GNRC_ICMPV6_ECHO_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_icmpv6_error ICMPv6 error messages
|
||||
* @ingroup net_ng_icmpv6
|
||||
* @defgroup net_gnrc_icmpv6_error ICMPv6 error messages
|
||||
* @ingroup net_gnrc_icmpv6
|
||||
* @brief ICMPv6 error message handling and creation
|
||||
* @{
|
||||
*
|
||||
@ -19,8 +19,8 @@
|
||||
*
|
||||
* @todo implement build and handle functions
|
||||
*/
|
||||
#ifndef NG_ICMPV6_ERROR_H_
|
||||
#define NG_ICMPV6_ERROR_H_
|
||||
#ifndef GNRC_ICMPV6_ERROR_H_
|
||||
#define GNRC_ICMPV6_ERROR_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -30,5 +30,5 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_ICMPV6_ERROR_H_ */
|
||||
#endif /* GNRC_ICMPV6_ERROR_H_ */
|
||||
/** @} */
|
@ -7,14 +7,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6 IPv6
|
||||
* @defgroup net_gnrc_ipv6 IPv6
|
||||
* @ingroup net
|
||||
* @brief New IPv6 implementation
|
||||
*
|
||||
* The IPv6 control thread understands messages of type
|
||||
*
|
||||
* * @ref NG_NETAPI_MSG_TYPE_RCV, and
|
||||
* * @ref NG_NETAPI_MSG_TYPE_SND,
|
||||
* * @ref GNRC_NETAPI_MSG_TYPE_RCV, and
|
||||
* * @ref GNRC_NETAPI_MSG_TYPE_SND,
|
||||
*
|
||||
* @{
|
||||
*
|
||||
@ -25,18 +25,18 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NG_IPV6_H_
|
||||
#define NG_IPV6_H_
|
||||
#ifndef GNRC_IPV6_H_
|
||||
#define GNRC_IPV6_H_
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "net/ipv6.h"
|
||||
#include "net/ng_ipv6/ext.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#include "net/gnrc/ipv6/ext.h"
|
||||
#include "net/gnrc/ipv6/hdr.h"
|
||||
#include "net/gnrc/ipv6/nc.h"
|
||||
#include "net/gnrc/ipv6/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -45,33 +45,33 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default stack size to use for the IPv6 thread
|
||||
*/
|
||||
#ifndef NG_IPV6_STACK_SIZE
|
||||
#define NG_IPV6_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_IPV6_STACK_SIZE
|
||||
#define GNRC_IPV6_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default priority for the IPv6 thread
|
||||
*/
|
||||
#ifndef NG_IPV6_PRIO
|
||||
#define NG_IPV6_PRIO (THREAD_PRIORITY_MAIN - 3)
|
||||
#ifndef GNRC_IPV6_PRIO
|
||||
#define GNRC_IPV6_PRIO (THREAD_PRIORITY_MAIN - 3)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default message queue size to use for the IPv6 thread.
|
||||
*/
|
||||
#ifndef NG_IPV6_MSG_QUEUE_SIZE
|
||||
#define NG_IPV6_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_IPV6_MSG_QUEUE_SIZE
|
||||
#define GNRC_IPV6_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The PID to the IPv6 thread.
|
||||
*
|
||||
* @note Use @ref ng_ipv6_init() to initialize. **Do not set by hand**.
|
||||
* @note Use @ref gnrc_ipv6_init() to initialize. **Do not set by hand**.
|
||||
*
|
||||
* @details This variable is preferred for IPv6 internal communication *only*.
|
||||
* Please use @ref net_ng_netreg for external communication.
|
||||
* Please use @ref net_gnrc_netreg for external communication.
|
||||
*/
|
||||
extern kernel_pid_t ng_ipv6_pid;
|
||||
extern kernel_pid_t gnrc_ipv6_pid;
|
||||
|
||||
/**
|
||||
* @brief Initialization of the IPv6 thread.
|
||||
@ -81,7 +81,7 @@ extern kernel_pid_t ng_ipv6_pid;
|
||||
* @return -EOVERFLOW, if there are too many threads running already
|
||||
* @return -EEXIST, if IPv6 was already initialized.
|
||||
*/
|
||||
kernel_pid_t ng_ipv6_init(void);
|
||||
kernel_pid_t gnrc_ipv6_init(void);
|
||||
|
||||
/**
|
||||
* @brief Demultiplexes a packet according to @p nh.
|
||||
@ -95,13 +95,13 @@ kernel_pid_t ng_ipv6_init(void);
|
||||
* @param[in] pkt A packet.
|
||||
* @param[in] nh A protocol number (see @ref net_protnum).
|
||||
*/
|
||||
void ng_ipv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt, uint8_t nh);
|
||||
void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, uint8_t nh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_IPV6_H_ */
|
||||
#endif /* GNRC_IPV6_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6_ext IPv6 extension headers.
|
||||
* @ingroup net_ng_ipv6
|
||||
* @defgroup net_gnrc_ipv6_ext IPv6 extension headers.
|
||||
* @ingroup net_gnrc_ipv6
|
||||
* @brief Implementation of IPv6 extension headers
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2460#section-4">
|
||||
* RFC 2460, section 4
|
||||
@ -22,15 +22,15 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NG_IPV6_EXT_H_
|
||||
#define NG_IPV6_EXT_H_
|
||||
#ifndef GNRC_IPV6_EXT_H_
|
||||
#define GNRC_IPV6_EXT_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/ipv6/ext.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -49,8 +49,8 @@ extern "C" {
|
||||
* @return true, on success.
|
||||
* @return false, on failure.
|
||||
*/
|
||||
bool ng_ipv6_ext_demux(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
uint8_t nh);
|
||||
bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
||||
uint8_t nh);
|
||||
|
||||
/**
|
||||
* @brief Builds an extension header for sending.
|
||||
@ -64,14 +64,14 @@ bool ng_ipv6_ext_demux(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
* @return The extension header on success.
|
||||
* @return NULL, on error.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ipv6_ext_build(ng_pktsnip_t *ipv6, ng_pktsnip_t *next,
|
||||
uint8_t nh, size_t size);
|
||||
gnrc_pktsnip_t *gnrc_ipv6_ext_build(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *next,
|
||||
uint8_t nh, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_IPV6_EXT_H_ */
|
||||
#endif /* GNRC_IPV6_EXT_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6_hdr IPv6 header defintions
|
||||
* @ingroup net_ng_ipv6
|
||||
* @defgroup net_gnrc_ipv6_hdr IPv6 header defintions
|
||||
* @ingroup net_gnrc_ipv6
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -16,13 +16,13 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_IPV6_HDR_H_
|
||||
#define NG_IPV6_HDR_H_
|
||||
#ifndef GNRC_IPV6_HDR_H_
|
||||
#define GNRC_IPV6_HDR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "net/ipv6/hdr.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -47,13 +47,13 @@ extern "C" {
|
||||
* @return The an IPv6 header in packet buffer on success.
|
||||
* @return NULL on error.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ipv6_hdr_build(ng_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len);
|
||||
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_IPV6_HDR_H_ */
|
||||
#endif /* GNRC_IPV6_HDR_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6_nc IPv6 neighbor cache
|
||||
* @ingroup net_ng_ipv6
|
||||
* @defgroup net_gnrc_ipv6_nc IPv6 neighbor cache
|
||||
* @ingroup net_gnrc_ipv6
|
||||
* @brief Translates IPv6 addresses to link layer addresses.
|
||||
* @{
|
||||
*
|
||||
@ -18,39 +18,39 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_IPV6_NC_H_
|
||||
#define NG_IPV6_NC_H_
|
||||
#ifndef GNRC_IPV6_NC_H_
|
||||
#define GNRC_IPV6_NC_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/ng_pktqueue.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/pktqueue.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NG_IPV6_NC_SIZE
|
||||
#ifndef GNRC_IPV6_NC_SIZE
|
||||
/**
|
||||
* @brief The size of the neighbor cache
|
||||
*/
|
||||
#define NG_IPV6_NC_SIZE (NG_NETIF_NUMOF * 8)
|
||||
#define GNRC_IPV6_NC_SIZE (GNRC_NETIF_NUMOF * 8)
|
||||
#endif
|
||||
|
||||
#ifndef NG_IPV6_NC_L2_ADDR_MAX
|
||||
#ifndef GNRC_IPV6_NC_L2_ADDR_MAX
|
||||
/**
|
||||
* @brief The maximum size of a link layer address
|
||||
*/
|
||||
#define NG_IPV6_NC_L2_ADDR_MAX (8)
|
||||
#define GNRC_IPV6_NC_L2_ADDR_MAX (8)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Flag definitions for ng_ipv6_nc_t
|
||||
* @name Flag definitions for gnrc_ipv6_nc_t
|
||||
*/
|
||||
/**
|
||||
* @{
|
||||
@ -60,10 +60,10 @@ extern "C" {
|
||||
* RFC 4861, section 7.3.2
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NC_STATE_MASK (0x07) /**< Mask for neighbor cache state */
|
||||
#define NG_IPV6_NC_STATE_POS (0) /**< Shift of neighbor cache state */
|
||||
#define GNRC_IPV6_NC_STATE_MASK (0x07) /**< Mask for neighbor cache state */
|
||||
#define GNRC_IPV6_NC_STATE_POS (0) /**< Shift of neighbor cache state */
|
||||
|
||||
#define NG_IPV6_NC_STATE_UNMANAGED (0x00) /**< The entry is not manage by NDP */
|
||||
#define GNRC_IPV6_NC_STATE_UNMANAGED (0x00) /**< The entry is not manage by NDP */
|
||||
|
||||
/**
|
||||
* @brief The entry is unreachable
|
||||
@ -72,20 +72,20 @@ extern "C" {
|
||||
* RFC 7048, section 3
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NC_STATE_UNREACHABLE (0x01)
|
||||
#define NG_IPV6_NC_STATE_INCOMPLETE (0x02) /**< Address resolution is performed */
|
||||
#define NG_IPV6_NC_STATE_STALE (0x03) /**< The entry is stale */
|
||||
#define NG_IPV6_NC_STATE_DELAY (0x04) /**< The entry was stale but packet was sent out */
|
||||
#define NG_IPV6_NC_STATE_PROBE (0x05) /**< Periodic reachabality confirmation */
|
||||
#define NG_IPV6_NC_STATE_REACHABLE (0x07) /**< The entry is reachable */
|
||||
#define GNRC_IPV6_NC_STATE_UNREACHABLE (0x01)
|
||||
#define GNRC_IPV6_NC_STATE_INCOMPLETE (0x02) /**< Address resolution is performed */
|
||||
#define GNRC_IPV6_NC_STATE_STALE (0x03) /**< The entry is stale */
|
||||
#define GNRC_IPV6_NC_STATE_DELAY (0x04) /**< The entry was stale but packet was sent out */
|
||||
#define GNRC_IPV6_NC_STATE_PROBE (0x05) /**< Periodic reachabality confirmation */
|
||||
#define GNRC_IPV6_NC_STATE_REACHABLE (0x07) /**< The entry is reachable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define NG_IPV6_NC_IS_ROUTER (0x08) /**< The neighbor is a router */
|
||||
#define GNRC_IPV6_NC_IS_ROUTER (0x08) /**< The neighbor is a router */
|
||||
|
||||
#define NG_IPV6_NC_TYPE_MASK (0x30) /**< Mask for neighbor cache state */
|
||||
#define NG_IPV6_NC_TYPE_POS (4) /**< Shift of neighbor cache state */
|
||||
#define GNRC_IPV6_NC_TYPE_MASK (0x30) /**< Mask for neighbor cache state */
|
||||
#define GNRC_IPV6_NC_TYPE_POS (4) /**< Shift of neighbor cache state */
|
||||
|
||||
/**
|
||||
* @{
|
||||
@ -100,10 +100,10 @@ extern "C" {
|
||||
*
|
||||
* @details The node sents multicast Neighbor Solicitations for hosts.
|
||||
*/
|
||||
#define NG_IPV6_NC_TYPE_NONE (0x00)
|
||||
#define NG_IPV6_NC_TYPE_GC (0x10) /**< The entry is marked for removal */
|
||||
#define NG_IPV6_NC_TYPE_TENTATIVE (0x20) /**< The entry is temporary */
|
||||
#define NG_IPV6_NC_TYPE_REGISTERED (0x30) /**< The entry is registered */
|
||||
#define GNRC_IPV6_NC_TYPE_NONE (0x00)
|
||||
#define GNRC_IPV6_NC_TYPE_GC (0x10) /**< The entry is marked for removal */
|
||||
#define GNRC_IPV6_NC_TYPE_TENTATIVE (0x20) /**< The entry is temporary */
|
||||
#define GNRC_IPV6_NC_TYPE_REGISTERED (0x30) /**< The entry is registered */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -118,13 +118,13 @@ extern "C" {
|
||||
* </a>.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_pktqueue_t *pkts; /**< Packets waiting for address resolution */
|
||||
ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
|
||||
uint8_t l2_addr[NG_IPV6_NC_L2_ADDR_MAX];/**< Link layer address of the neighbor */
|
||||
uint8_t l2_addr_len; /**< Length of ng_ipv6_nc_t::l2_addr */
|
||||
uint8_t flags; /**< Flags as defined above */
|
||||
kernel_pid_t iface; /**< PID to the interface where the neighbor is */
|
||||
vtimer_t rtr_timeout; /**< timeout timer for router flag */
|
||||
gnrc_pktqueue_t *pkts; /**< Packets waiting for address resolution */
|
||||
ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
|
||||
uint8_t l2_addr[GNRC_IPV6_NC_L2_ADDR_MAX]; /**< Link layer address of the neighbor */
|
||||
uint8_t l2_addr_len; /**< Length of gnrc_ipv6_nc_t::l2_addr */
|
||||
uint8_t flags; /**< Flags as defined above */
|
||||
kernel_pid_t iface; /**< PID to the interface where the neighbor is */
|
||||
vtimer_t rtr_timeout; /**< timeout timer for router flag */
|
||||
|
||||
/**
|
||||
* @brief (Re)Transmission timer for neighbor solicitations of this entry and
|
||||
@ -147,12 +147,12 @@ typedef struct {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
} ng_ipv6_nc_t;
|
||||
} gnrc_ipv6_nc_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes neighbor cache
|
||||
*/
|
||||
void ng_ipv6_nc_init(void);
|
||||
void gnrc_ipv6_nc_init(void);
|
||||
|
||||
/**
|
||||
* @brief Adds a neighbor to the neighbor cache
|
||||
@ -161,14 +161,14 @@ void ng_ipv6_nc_init(void);
|
||||
* @param[in] ipv6_addr IPv6 address of the neighbor. Must not be NULL.
|
||||
* @param[in] l2_addr Link layer address of the neighbor. NULL if unknown.
|
||||
* @param[in] l2_addr_len Length of @p l2_addr, must be lesser than or equal
|
||||
* to NG_IPV6_L2_ADDR_MAX. 0 if unknown.
|
||||
* to GNRC_IPV6_L2_ADDR_MAX. 0 if unknown.
|
||||
* @param[in] flags Flags for the entry
|
||||
*
|
||||
* @return Pointer to new neighbor cache entry on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr,
|
||||
const void *l2_addr, size_t l2_addr_len, uint8_t flags);
|
||||
gnrc_ipv6_nc_t *gnrc_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr,
|
||||
const void *l2_addr, size_t l2_addr_len, uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Removes a neighbor from the neighbor cache
|
||||
@ -178,7 +178,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr,
|
||||
* interfaces.
|
||||
* @param[in] ipv6_addr IPv6 address of the neighbor
|
||||
*/
|
||||
void ng_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
void gnrc_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for any neighbor cache entry fitting the @p ipv6_addr.
|
||||
@ -191,7 +191,7 @@ void ng_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
* @return The neighbor cache entry, if one is found.
|
||||
* @return NULL, if none is found.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
gnrc_ipv6_nc_t *gnrc_ipv6_nc_get(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
/**
|
||||
* @brief Gets next entry in neighbor cache after @p prev.
|
||||
@ -200,7 +200,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
*
|
||||
* @return The next entry in neighbor cache.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get_next(ng_ipv6_nc_t *prev);
|
||||
gnrc_ipv6_nc_t *gnrc_ipv6_nc_get_next(gnrc_ipv6_nc_t *prev);
|
||||
|
||||
/**
|
||||
* @brief Gets next reachable router entry in neighbor cache after @p prev.
|
||||
@ -209,7 +209,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_next(ng_ipv6_nc_t *prev);
|
||||
*
|
||||
* @return The next reachable router entry in neighbor cache.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get_next_router(ng_ipv6_nc_t *prev);
|
||||
gnrc_ipv6_nc_t *gnrc_ipv6_nc_get_next_router(gnrc_ipv6_nc_t *prev);
|
||||
|
||||
/**
|
||||
* @brief Returns the state of a neigbor cache entry.
|
||||
@ -218,9 +218,9 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_next_router(ng_ipv6_nc_t *prev);
|
||||
*
|
||||
* @return The state of the neighbor cache entry as defined by its flags.
|
||||
*/
|
||||
static inline uint8_t ng_ipv6_nc_get_state(const ng_ipv6_nc_t *entry)
|
||||
static inline uint8_t gnrc_ipv6_nc_get_state(const gnrc_ipv6_nc_t *entry)
|
||||
{
|
||||
return (entry->flags & NG_IPV6_NC_STATE_MASK);
|
||||
return (entry->flags & GNRC_IPV6_NC_STATE_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,25 +230,25 @@ static inline uint8_t ng_ipv6_nc_get_state(const ng_ipv6_nc_t *entry)
|
||||
*
|
||||
* @return The type of the neighbor cache entry as defined by its flags.
|
||||
*/
|
||||
static inline uint8_t ng_ipv6_nc_get_type(const ng_ipv6_nc_t *entry)
|
||||
static inline uint8_t gnrc_ipv6_nc_get_type(const gnrc_ipv6_nc_t *entry)
|
||||
{
|
||||
return (entry->flags & NG_IPV6_NC_TYPE_MASK);
|
||||
return (entry->flags & GNRC_IPV6_NC_TYPE_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if an entry is reachable (do not confuse with
|
||||
* @ref NG_IPV6_NC_STATE_REACHABLE).
|
||||
* @ref GNRC_IPV6_NC_STATE_REACHABLE).
|
||||
*
|
||||
* @param[in] entry A neighbor cache entry
|
||||
*
|
||||
* @return true, if you can send packets to @p entry
|
||||
* @return false, if you can't send packets to @p entry
|
||||
*/
|
||||
static inline bool ng_ipv6_nc_is_reachable(const ng_ipv6_nc_t *entry)
|
||||
static inline bool gnrc_ipv6_nc_is_reachable(const gnrc_ipv6_nc_t *entry)
|
||||
{
|
||||
switch (ng_ipv6_nc_get_state(entry)) {
|
||||
case NG_IPV6_NC_STATE_UNREACHABLE:
|
||||
case NG_IPV6_NC_STATE_INCOMPLETE:
|
||||
switch (gnrc_ipv6_nc_get_state(entry)) {
|
||||
case GNRC_IPV6_NC_STATE_UNREACHABLE:
|
||||
case GNRC_IPV6_NC_STATE_INCOMPLETE:
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -273,13 +273,13 @@ static inline bool ng_ipv6_nc_is_reachable(const ng_ipv6_nc_t *entry)
|
||||
* @return The neighbor cache entry, if one is found.
|
||||
* @return NULL, if none is found.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr);
|
||||
gnrc_ipv6_nc_t *gnrc_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_IPV6_NC_H_ */
|
||||
#endif /* GNRC_IPV6_NC_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6_netif IPv6 network interfaces
|
||||
* @ingroup net_ng_ipv6
|
||||
* @brief IPv6 specific information on @ref net_ng_netif.
|
||||
* @defgroup net_gnrc_ipv6_netif IPv6 network interfaces
|
||||
* @ingroup net_gnrc_ipv6
|
||||
* @brief IPv6 specific information on @ref net_gnrc_netif.
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -18,8 +18,8 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_IPV6_NETIF_H_
|
||||
#define NG_IPV6_NETIF_H_
|
||||
#ifndef GNRC_IPV6_NETIF_H_
|
||||
#define GNRC_IPV6_NETIF_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -36,15 +36,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def NG_IPV6_NETIF_ADDR_NUMOF
|
||||
* @def GNRC_IPV6_NETIF_ADDR_NUMOF
|
||||
*
|
||||
* @brief Number of IPv6 addresses per interface.
|
||||
*/
|
||||
#ifndef NG_IPV6_NETIF_ADDR_NUMOF
|
||||
#ifdef MODULE_NG_IPV6_ROUTER
|
||||
#define NG_IPV6_NETIF_ADDR_NUMOF (8) /* router needs all-routers multicast address */
|
||||
#ifndef GNRC_IPV6_NETIF_ADDR_NUMOF
|
||||
#ifdef MODULE_GNRC_IPV6_ROUTER
|
||||
#define GNRC_IPV6_NETIF_ADDR_NUMOF (7) /* router needs all-routers multicast address */
|
||||
#else
|
||||
#define NG_IPV6_NETIF_ADDR_NUMOF (7)
|
||||
#define GNRC_IPV6_NETIF_ADDR_NUMOF (6)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -55,7 +55,7 @@ extern "C" {
|
||||
* RFC 2460, section 5
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NETIF_DEFAULT_MTU (1280)
|
||||
#define GNRC_IPV6_NETIF_DEFAULT_MTU (1280)
|
||||
|
||||
/**
|
||||
* @brief Default hop limit
|
||||
@ -67,7 +67,7 @@ extern "C" {
|
||||
* IANA, IP TIME TO LIVE PARAMETER
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NETIF_DEFAULT_HL (64)
|
||||
#define GNRC_IPV6_NETIF_DEFAULT_HL (64)
|
||||
|
||||
/**
|
||||
* @{
|
||||
@ -78,8 +78,8 @@ extern "C" {
|
||||
* RFC 4291, section 2.6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NETIF_ADDR_FLAGS_UNICAST (0x00) /**< unicast address */
|
||||
#define NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST (0x01) /**< non-unicast address */
|
||||
#define GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST (0x00) /**< unicast address */
|
||||
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST (0x01) /**< non-unicast address */
|
||||
|
||||
/**
|
||||
* @brief A prefix information option that propagates the prefix of this
|
||||
@ -88,7 +88,7 @@ extern "C" {
|
||||
* RFC 4861, section 6.2.1
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO (0x40)
|
||||
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO (0x40)
|
||||
|
||||
/**
|
||||
* @brief A prefix information option that propagates the prefix of this
|
||||
@ -97,7 +97,7 @@ extern "C" {
|
||||
* RFC 4861, section 6.2.1
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK (0x80)
|
||||
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK (0x80)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -109,42 +109,42 @@ extern "C" {
|
||||
/**
|
||||
* @brief Interface is 6LoWPAN interface.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_SIXLOWPAN (0x0001)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN (0x0001)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that routing is enabled on the interface.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_ROUTER (0x0002)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_ROUTER (0x0002)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that the interface sends periodic router
|
||||
* advertisements and in response to router solicitations.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_RTR_ADV (0x0004)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV (0x0004)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that ng_ipv6_netif_t::mtu shall be propagated
|
||||
* @brief Flag to indicate that gnrc_ipv6_netif_t::mtu shall be propagated
|
||||
* with the MTU options in router advertisements.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_ADV_MTU (0x0008)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_ADV_MTU (0x0008)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that ng_ipv6_netif_t::cur_hl shall be propagated
|
||||
* @brief Flag to indicate that gnrc_ipv6_netif_t::cur_hl shall be propagated
|
||||
* in router advertisements.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_ADV_CUR_HL (0x0010)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_ADV_CUR_HL (0x0010)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that the interface has other address
|
||||
* configuration.
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_OTHER_CONF (0x4000)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_OTHER_CONF (0x4000)
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate that the interface has managed address
|
||||
* configuration (e.g. via DHCPv6).
|
||||
*/
|
||||
#define NG_IPV6_NETIF_FLAGS_MANAGED (0x8000)
|
||||
#define GNRC_IPV6_NETIF_FLAGS_MANAGED (0x8000)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -172,7 +172,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief The length of time that this address remains preferred.
|
||||
* If it is UINT32_MAX the lifetime is infinite.
|
||||
* It **must** be < ng_ipv6_netif_addr_t::valid.
|
||||
* It **must** be < gnrc_ipv6_netif_addr_t::valid.
|
||||
*/
|
||||
uint32_t preferred;
|
||||
/**
|
||||
@ -182,14 +182,16 @@ typedef struct {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
} ng_ipv6_netif_addr_t;
|
||||
} gnrc_ipv6_netif_addr_t;
|
||||
|
||||
/**
|
||||
* @brief Definition of IPv6 interface type.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_ipv6_netif_addr_t addrs[NG_IPV6_NETIF_ADDR_NUMOF]; /**< addresses registered
|
||||
* to the interface */
|
||||
/**
|
||||
* @brief addresses registered to the interface
|
||||
*/
|
||||
gnrc_ipv6_netif_addr_t addrs[GNRC_IPV6_NETIF_ADDR_NUMOF];
|
||||
mutex_t mutex; /**< mutex for the interface */
|
||||
kernel_pid_t pid; /**< PID of the interface */
|
||||
uint16_t mtu; /**< Maximum Transmission Unit (MTU) of the interface */
|
||||
@ -197,17 +199,17 @@ typedef struct {
|
||||
uint16_t flags; /**< flags for 6LoWPAN and Neighbor Discovery */
|
||||
/**
|
||||
* @brief Base value in microseconds for computing random
|
||||
* ng_ipv6_netif_t::reach_time.
|
||||
* The default value is @ref NG_NDP_REACH_TIME.
|
||||
* gnrc_ipv6_netif_t::reach_time.
|
||||
* The default value is @ref GNRC_NDP_REACH_TIME.
|
||||
*/
|
||||
uint32_t reach_time_base;
|
||||
|
||||
/**
|
||||
* @brief The time a neighbor is considered reachable after receiving
|
||||
* a reachability confirmation.
|
||||
* Should be uniformly distributed between @ref NG_NDP_MIN_RAND
|
||||
* and NG_NDP_MAX_RAND multiplied with
|
||||
* ng_ipv6_netif_t::reach_time_base microseconds devided by 10.
|
||||
* Should be uniformly distributed between @ref GNRC_NDP_MIN_RAND
|
||||
* and GNRC_NDP_MAX_RAND multiplied with
|
||||
* gnrc_ipv6_netif_t::reach_time_base microseconds devided by 10.
|
||||
* Can't be greater than 1 hour.
|
||||
*/
|
||||
timex_t reach_time;
|
||||
@ -215,33 +217,33 @@ typedef struct {
|
||||
/**
|
||||
* @brief Time between retransmissions of neighbor solicitations to a
|
||||
* neighbor.
|
||||
* The default value is @ref NG_NDP_RETRANS_TIMER.
|
||||
* The default value is @ref GNRC_NDP_RETRANS_TIMER.
|
||||
*/
|
||||
timex_t retrans_timer;
|
||||
} ng_ipv6_netif_t;
|
||||
} gnrc_ipv6_netif_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes the module.
|
||||
*/
|
||||
void ng_ipv6_netif_init(void);
|
||||
void gnrc_ipv6_netif_init(void);
|
||||
|
||||
/**
|
||||
* @brief Add interface to IPv6.
|
||||
*
|
||||
* @details This function will be called by @ref ng_netif_add().
|
||||
* @details This function will be called by @ref gnrc_netif_add().
|
||||
*
|
||||
* @param[in] pid The PID to the interface.
|
||||
*/
|
||||
void ng_ipv6_netif_add(kernel_pid_t pid);
|
||||
void gnrc_ipv6_netif_add(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Remove interface from IPv6.
|
||||
*
|
||||
* @details This function will be called by @ref ng_netif_remove().
|
||||
* @details This function will be called by @ref gnrc_netif_remove().
|
||||
*
|
||||
* @param[in] pid The PID to the interface.
|
||||
*/
|
||||
void ng_ipv6_netif_remove(kernel_pid_t pid);
|
||||
void gnrc_ipv6_netif_remove(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Get interface.
|
||||
@ -251,18 +253,18 @@ void ng_ipv6_netif_remove(kernel_pid_t pid);
|
||||
* @return The interface describing structure, on success.
|
||||
* @return NULL, if there is no interface with PID @p pid.
|
||||
*/
|
||||
ng_ipv6_netif_t *ng_ipv6_netif_get(kernel_pid_t pid);
|
||||
gnrc_ipv6_netif_t *gnrc_ipv6_netif_get(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Set interface to router mode.
|
||||
*
|
||||
* @details This sets/unsets the NG_IPV6_NETIF_FLAGS_ROUTER and initializes
|
||||
* @details This sets/unsets the GNRC_IPV6_NETIF_FLAGS_ROUTER and initializes
|
||||
* or ceases router behavior for neighbor discovery.
|
||||
*
|
||||
* @param[in] netif The interface.
|
||||
* @param[in] enable Status for the NG_IPV6_NETIF_FLAGS_ROUTER flag.
|
||||
* @param[in] enable Status for the GNRC_IPV6_NETIF_FLAGS_ROUTER flag.
|
||||
*/
|
||||
static inline void ng_ipv6_netif_set_rtr(ng_ipv6_netif_t *netif, bool enable)
|
||||
static inline void gnrc_ipv6_netif_set_rtr(gnrc_ipv6_netif_t *netif, bool enable)
|
||||
{
|
||||
(void)netif; /* Don't do anything for non-routers */
|
||||
(void)enable;
|
||||
@ -271,14 +273,14 @@ static inline void ng_ipv6_netif_set_rtr(ng_ipv6_netif_t *netif, bool enable)
|
||||
/**
|
||||
* @brief Set interface to router advertisement mode.
|
||||
*
|
||||
* @details If NG_IPV6_NETIF_FLAGS_ROUTER is set this sets/unsets the
|
||||
* NG_IPV6_NETIF_FLAGS_RTR_ADV and initializes or ceases router
|
||||
* @details If GNRC_IPV6_NETIF_FLAGS_ROUTER is set this sets/unsets the
|
||||
* GNRC_IPV6_NETIF_FLAGS_RTR_ADV and initializes or ceases router
|
||||
* advertising behavior for neighbor discovery.
|
||||
*
|
||||
* @param[in] netif The interface.
|
||||
* @param[in] enable Status for the NG_IPV6_NETIF_FLAGS_RTR flag.
|
||||
* @param[in] enable Status for the GNRC_IPV6_NETIF_FLAGS_RTR flag.
|
||||
*/
|
||||
static inline void ng_ipv6_netif_set_rtr_adv(ng_ipv6_netif_t *netif, bool enable)
|
||||
static inline void gnrc_ipv6_netif_set_rtr_adv(gnrc_ipv6_netif_t *netif, bool enable)
|
||||
{
|
||||
(void)netif; /* Don't do anything for non-routers */
|
||||
(void)enable;
|
||||
@ -292,7 +294,7 @@ static inline void ng_ipv6_netif_set_rtr_adv(ng_ipv6_netif_t *netif, bool enable
|
||||
* @param[in] dst The address of the neighboring router.
|
||||
* May be NULL for @ref IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL.
|
||||
*/
|
||||
static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif, ipv6_addr_t *dst)
|
||||
static inline void gnrc_ipv6_netif_sol_router(gnrc_ipv6_netif_t *netif, ipv6_addr_t *dst)
|
||||
{
|
||||
(void)netif; /* TODO */
|
||||
(void)dst;
|
||||
@ -307,10 +309,10 @@ static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif, ipv6_addr_t
|
||||
* Must be between 1 and 128.
|
||||
* @param[in] flags Flags for the address entry
|
||||
* If @p addr should be an anycast address, @p flags
|
||||
* must have @ref NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST
|
||||
* must have @ref GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST
|
||||
* set. Otherwise leave it unset.
|
||||
* If @p addr is a multicast address, the status of
|
||||
* @ref NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST will be
|
||||
* @ref GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST will be
|
||||
* ignored and set in either case.
|
||||
*
|
||||
* @see <a href="https://tools.ietf.org/html/rfc4291#section-2.6">
|
||||
@ -320,8 +322,8 @@ static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif, ipv6_addr_t
|
||||
* @return The address on the interface, on success.
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr, uint8_t prefix_len,
|
||||
uint8_t flags);
|
||||
ipv6_addr_t *gnrc_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr, uint8_t prefix_len,
|
||||
uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Remove an address from the interface.
|
||||
@ -330,14 +332,14 @@ ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr, u
|
||||
* it will be removed from all interfaces.
|
||||
* @param[in] addr An address you want to remove from interface.
|
||||
*/
|
||||
void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ipv6_addr_t *addr);
|
||||
void gnrc_ipv6_netif_remove_addr(kernel_pid_t pid, ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Removes all addresses from the interface.
|
||||
*
|
||||
* @param[in] pid The PID to the interface.
|
||||
*/
|
||||
void ng_ipv6_netif_reset_addr(kernel_pid_t pid);
|
||||
void gnrc_ipv6_netif_reset_addr(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Searches for an address on all interfaces.
|
||||
@ -348,7 +350,7 @@ void ng_ipv6_netif_reset_addr(kernel_pid_t pid);
|
||||
* @return The PID to the interface the address is registered to.
|
||||
* @return KERNEL_PID_UNDEF, if the address can not be found on any interface.
|
||||
*/
|
||||
kernel_pid_t ng_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *addr);
|
||||
kernel_pid_t gnrc_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for an address on an interface.
|
||||
@ -360,7 +362,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *ad
|
||||
* @return NULL, if the address can not be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr);
|
||||
ipv6_addr_t *gnrc_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for the first address matching a prefix best on all
|
||||
@ -373,7 +375,7 @@ ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr);
|
||||
* @return KERNEL_PID_UNDEF, if no matching address can not be found on any
|
||||
* interface.
|
||||
*/
|
||||
kernel_pid_t ng_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *prefix);
|
||||
kernel_pid_t gnrc_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *prefix);
|
||||
|
||||
/**
|
||||
* @brief Searches for the first address matching a prefix best on an
|
||||
@ -386,7 +388,7 @@ kernel_pid_t ng_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *
|
||||
* @return NULL, if no matching address can be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *prefix);
|
||||
ipv6_addr_t *gnrc_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *prefix);
|
||||
|
||||
/**
|
||||
* @brief Searches for the best address on an interface usable as a
|
||||
@ -409,7 +411,7 @@ ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *pre
|
||||
* @return NULL, if no matching address can be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dest);
|
||||
ipv6_addr_t *gnrc_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dest);
|
||||
|
||||
/**
|
||||
* @brief Get interface specific meta-information on an address
|
||||
@ -417,12 +419,12 @@ ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_
|
||||
* @details This only works with addresses you retrieved via the following
|
||||
* functions:
|
||||
*
|
||||
* * ng_ipv6_netif_add_addr()
|
||||
* * ng_ipv6_find_addr()
|
||||
* * ng_ipv6_find_addr_local()
|
||||
* * ng_ipv6_find_prefix_match()
|
||||
* * ng_ipv6_find_prefix_match_local()
|
||||
* * ng_ipv6_find_best_src_address()
|
||||
* * gnrc_ipv6_netif_add_addr()
|
||||
* * gnrc_ipv6_find_addr()
|
||||
* * gnrc_ipv6_find_addr_local()
|
||||
* * gnrc_ipv6_find_prefix_match()
|
||||
* * gnrc_ipv6_find_prefix_match_local()
|
||||
* * gnrc_ipv6_find_best_src_address()
|
||||
*
|
||||
* The behaviour for other addresses is undefined.
|
||||
*
|
||||
@ -430,9 +432,9 @@ ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_
|
||||
*
|
||||
* @return Interface specific meta-information on @p addr
|
||||
*/
|
||||
static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ipv6_addr_t *addr)
|
||||
static inline gnrc_ipv6_netif_addr_t *gnrc_ipv6_netif_addr_get(const ipv6_addr_t *addr)
|
||||
{
|
||||
return container_of(addr, ng_ipv6_netif_addr_t, addr);
|
||||
return container_of(addr, gnrc_ipv6_netif_addr_t, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,12 +443,12 @@ static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ipv6_addr_t *ad
|
||||
* @details This only works with addresses you retrieved via the following
|
||||
* functions:
|
||||
*
|
||||
* * ng_ipv6_netif_add_addr()
|
||||
* * ng_ipv6_find_addr()
|
||||
* * ng_ipv6_find_addr_local()
|
||||
* * ng_ipv6_find_prefix_match()
|
||||
* * ng_ipv6_find_prefix_match_local()
|
||||
* * ng_ipv6_find_best_src_address()
|
||||
* * gnrc_ipv6_netif_add_addr()
|
||||
* * gnrc_ipv6_find_addr()
|
||||
* * gnrc_ipv6_find_addr_local()
|
||||
* * gnrc_ipv6_find_prefix_match()
|
||||
* * gnrc_ipv6_find_prefix_match_local()
|
||||
* * gnrc_ipv6_find_best_src_address()
|
||||
*
|
||||
* The behaviour for other addresses is undefined.
|
||||
*
|
||||
@ -455,10 +457,10 @@ static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ipv6_addr_t *ad
|
||||
* @return true, if address is anycast or multicast.
|
||||
* @return false, if address is unicast.
|
||||
*/
|
||||
static inline bool ng_ipv6_netif_addr_is_non_unicast(const ipv6_addr_t *addr)
|
||||
static inline bool gnrc_ipv6_netif_addr_is_non_unicast(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (bool)(container_of(addr, ng_ipv6_netif_addr_t, addr)->flags &
|
||||
NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST);
|
||||
return (bool)(container_of(addr, gnrc_ipv6_netif_addr_t, addr)->flags &
|
||||
GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST);
|
||||
|
||||
}
|
||||
|
||||
@ -468,7 +470,7 @@ static inline bool ng_ipv6_netif_addr_is_non_unicast(const ipv6_addr_t *addr)
|
||||
* @note Must be called after all interfaces were initialized and must not
|
||||
* be called in an interface's thread (will otherwise hang up).
|
||||
*/
|
||||
void ng_ipv6_netif_init_by_dev(void);
|
||||
void gnrc_ipv6_netif_init_by_dev(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ndp IPv6 Neighbor discovery
|
||||
* @ingroup net_ng_icmpv6
|
||||
* @defgroup net_gnrc_ndp IPv6 Neighbor discovery
|
||||
* @ingroup net_gnrc_icmpv6
|
||||
* @brief IPv6 Neighbor Discovery Implementation
|
||||
* @{
|
||||
*
|
||||
@ -18,30 +18,30 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NDP_H_
|
||||
#define NG_NDP_H_
|
||||
#ifndef GNRC_NDP_H_
|
||||
#define GNRC_NDP_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "net/ndp.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_icmpv6.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/icmpv6.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#include "net/gnrc/ipv6/nc.h"
|
||||
#include "net/gnrc/ipv6/netif.h"
|
||||
|
||||
#include "net/ng_ndp/node.h"
|
||||
#include "net/gnrc/ndp/node.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NG_NDP_MSG_RTR_TIMEOUT (0x0211) /**< Message type for router timeouts */
|
||||
#define NG_NDP_MSG_ADDR_TIMEOUT (0x0212) /**< Message type for address timeouts */
|
||||
#define NG_NDP_MSG_NBR_SOL_RETRANS (0x0213) /**< Message type for multicast
|
||||
* neighbor solicitation retransmissions */
|
||||
#define NG_NDP_MSG_NC_STATE_TIMEOUT (0x0214) /**< Message type for neighbor cache state timeouts */
|
||||
#define GNRC_NDP_MSG_RTR_TIMEOUT (0x0211) /**< Message type for router timeouts */
|
||||
#define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0212) /**< Message type for address timeouts */
|
||||
#define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0213) /**< Message type for multicast
|
||||
* neighbor solicitation retransmissions */
|
||||
#define GNRC_NDP_MSG_NC_STATE_TIMEOUT (0x0214) /**< Message type for neighbor cache state timeouts */
|
||||
|
||||
/**
|
||||
* @{
|
||||
@ -54,54 +54,54 @@ extern "C" {
|
||||
* @brief Maximum number of unanswered multicast neighbor solicitations
|
||||
* before address resolution is considered failed.
|
||||
*/
|
||||
#define NG_NDP_MAX_MC_NBR_SOL_NUMOF (3U)
|
||||
#define GNRC_NDP_MAX_MC_NBR_SOL_NUMOF (3U)
|
||||
|
||||
/**
|
||||
* @brief Maximum number of unanswered unicast neighbor solicitations before
|
||||
* an address is considered unreachable.
|
||||
*/
|
||||
#define NG_NDP_MAX_UC_NBR_SOL_NUMOF (3U)
|
||||
#define GNRC_NDP_MAX_UC_NBR_SOL_NUMOF (3U)
|
||||
|
||||
/**
|
||||
* @brief Upper bound of randomized delay in seconds for a solicited
|
||||
* neighbor advertisement transmission for an anycast target.
|
||||
*/
|
||||
#define NG_NDP_MAX_AC_TGT_DELAY (1U)
|
||||
#define GNRC_NDP_MAX_AC_TGT_DELAY (1U)
|
||||
|
||||
/**
|
||||
* @brief Maximum number of unsolicited neighbor advertisements before on
|
||||
* link-layer address change.
|
||||
*/
|
||||
#define NG_NDP_MAX_NBR_ADV_NUMOF (3U)
|
||||
#define GNRC_NDP_MAX_NBR_ADV_NUMOF (3U)
|
||||
|
||||
/**
|
||||
* @brief Base value in mircoseconds for computing randomised
|
||||
* reachable time.
|
||||
*/
|
||||
#define NG_NDP_REACH_TIME (30U * SEC_IN_USEC)
|
||||
#define GNRC_NDP_REACH_TIME (30U * SEC_IN_USEC)
|
||||
|
||||
/**
|
||||
* @brief Time in mircoseconds between retransmissions of neighbor
|
||||
* solicitations to a neighbor.
|
||||
*/
|
||||
#define NG_NDP_RETRANS_TIMER (1U * SEC_IN_USEC)
|
||||
#define GNRC_NDP_RETRANS_TIMER (1U * SEC_IN_USEC)
|
||||
|
||||
/**
|
||||
* @brief Delay in seconds for neighbor cache entry between entering
|
||||
* DELAY state and entering PROBE state if no reachability
|
||||
* confirmation has been received.
|
||||
*/
|
||||
#define NG_NDP_FIRST_PROBE_DELAY (5U)
|
||||
#define GNRC_NDP_FIRST_PROBE_DELAY (5U)
|
||||
|
||||
/**
|
||||
* @brief Lower bound for randomised reachable time calculation.
|
||||
*/
|
||||
#define NG_NDP_MIN_RAND (5U)
|
||||
#define GNRC_NDP_MIN_RAND (5U)
|
||||
|
||||
/**
|
||||
* @brief Upper bound for randomised reachable time calculation.
|
||||
*/
|
||||
#define NG_NDP_MAX_RAND (15U)
|
||||
#define GNRC_NDP_MAX_RAND (15U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -115,9 +115,9 @@ extern "C" {
|
||||
* @param[in] nbr_sol The neighbor solicitation in @p pkt.
|
||||
* @param[in] icmpv6_size The overall size of the neighbor solicitation.
|
||||
*/
|
||||
void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol,
|
||||
size_t icmpv6_size);
|
||||
void gnrc_ndp_nbr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol,
|
||||
size_t icmpv6_size);
|
||||
|
||||
/**
|
||||
* @brief Handles received neighbor advertisements.
|
||||
@ -128,9 +128,9 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
* @param[in] nbr_adv The neighbor advertisement in @p pkt.
|
||||
* @param[in] icmpv6_size The overall size of the neighbor advertisement.
|
||||
*/
|
||||
void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv,
|
||||
size_t icmpv6_size);
|
||||
void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv,
|
||||
size_t icmpv6_size);
|
||||
|
||||
/**
|
||||
* @brief Retransmits a multicast neighbor solicitation for an incomplete or
|
||||
@ -142,31 +142,31 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
* neighbor cache.
|
||||
*
|
||||
* @param[in] nc_entry A neighbor cache entry. Will be ignored if its state
|
||||
* is not @ref NG_IPV6_NC_STATE_INCOMPLETE or
|
||||
* @ref NG_IPV6_NC_STATE_PROBE.
|
||||
* is not @ref GNRC_IPV6_NC_STATE_INCOMPLETE or
|
||||
* @ref GNRC_IPV6_NC_STATE_PROBE.
|
||||
*/
|
||||
void ng_ndp_retrans_nbr_sol(ng_ipv6_nc_t *nc_entry);
|
||||
void gnrc_ndp_retrans_nbr_sol(gnrc_ipv6_nc_t *nc_entry);
|
||||
|
||||
/**
|
||||
* @brief Event handler for a neighbor cache state timeout.
|
||||
*
|
||||
* @param[in] nc_entry A neighbor cache entry.
|
||||
*/
|
||||
void ng_ndp_state_timeout(ng_ipv6_nc_t *nc_entry);
|
||||
void gnrc_ndp_state_timeout(gnrc_ipv6_nc_t *nc_entry);
|
||||
|
||||
/**
|
||||
* @brief NDP interface initialization.
|
||||
*
|
||||
* @param[in] iface An IPv6 interface descriptor. Must not be NULL.
|
||||
*/
|
||||
void ng_ndp_netif_add(ng_ipv6_netif_t *iface);
|
||||
void gnrc_ndp_netif_add(gnrc_ipv6_netif_t *iface);
|
||||
|
||||
/**
|
||||
* @brief NDP interface removal.
|
||||
*
|
||||
* @param[in] iface An IPv6 interface descriptor. Must not be NULL.
|
||||
*/
|
||||
void ng_ndp_netif_remove(ng_ipv6_netif_t *iface);
|
||||
void gnrc_ndp_netif_remove(gnrc_ipv6_netif_t *iface);
|
||||
|
||||
/**
|
||||
* @brief Get link-layer address and interface for next hop to destination
|
||||
@ -185,9 +185,9 @@ void ng_ndp_netif_remove(ng_ipv6_netif_t *iface);
|
||||
* @return -ENOBUFS, if @p l2addr_len was smaller than the resulting @p l2addr
|
||||
* would be long.
|
||||
*/
|
||||
kernel_pid_t ng_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
ng_pktsnip_t *pkt);
|
||||
kernel_pid_t gnrc_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Builds a neighbor solicitation message for sending.
|
||||
@ -202,7 +202,7 @@ kernel_pid_t ng_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
* @return The resulting ICMPv6 packet on success.
|
||||
* @return NULL, on failure.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options);
|
||||
gnrc_pktsnip_t *gnrc_ndp_nbr_sol_build(ipv6_addr_t *tgt, gnrc_pktsnip_t *options);
|
||||
|
||||
/**
|
||||
* @brief Builds a neighbor advertisement message for sending.
|
||||
@ -230,8 +230,8 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options);
|
||||
* @return The resulting ICMPv6 packet on success.
|
||||
* @return NULL, on failure.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
|
||||
ng_pktsnip_t *options);
|
||||
gnrc_pktsnip_t *gnrc_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
|
||||
gnrc_pktsnip_t *options);
|
||||
|
||||
/**
|
||||
* @brief Builds a generic NDP option.
|
||||
@ -244,7 +244,7 @@ ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
|
||||
* @return The packet snip list of options, on success
|
||||
* @return NULL, if packet buffer is full
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_opt_build(uint8_t type, size_t size, ng_pktsnip_t *next);
|
||||
gnrc_pktsnip_t *gnrc_ndp_opt_build(uint8_t type, size_t size, gnrc_pktsnip_t *next);
|
||||
|
||||
/**
|
||||
* @brief Builds the source link-layer address option.
|
||||
@ -264,8 +264,8 @@ ng_pktsnip_t *ng_ndp_opt_build(uint8_t type, size_t size, ng_pktsnip_t *next);
|
||||
* @return The packet snip list of options, on success
|
||||
* @return NULL, if packet buffer is full
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
|
||||
ng_pktsnip_t *next);
|
||||
gnrc_pktsnip_t *gnrc_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
|
||||
gnrc_pktsnip_t *next);
|
||||
|
||||
/**
|
||||
* @brief Builds the target link-layer address option.
|
||||
@ -285,14 +285,14 @@ ng_pktsnip_t *ng_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
|
||||
* @return The pkt snip list of options, on success
|
||||
* @return NULL, if packet buffer is full
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
|
||||
ng_pktsnip_t *next);
|
||||
gnrc_pktsnip_t *gnrc_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
|
||||
gnrc_pktsnip_t *next);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NDP_H_ */
|
||||
#endif /* GNRC_NDP_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ndp_internal Internal functions for neighbor discovery.
|
||||
* @ingroup net_ng_ndp
|
||||
* @defgroup net_gnrc_ndp_internal Internal functions for neighbor discovery.
|
||||
* @ingroup net_gnrc_ndp
|
||||
* @brief Internal functions for neighbor discovery.
|
||||
* @internal
|
||||
* @note Only for use with a neighbor discovery implementations.
|
||||
@ -42,7 +42,7 @@ extern "C" {
|
||||
* @return Address to a default router.
|
||||
* @return NULL, if the default router list is empty.
|
||||
*/
|
||||
ipv6_addr_t *ng_ndp_internal_default_router(void);
|
||||
ipv6_addr_t *gnrc_ndp_internal_default_router(void);
|
||||
|
||||
/**
|
||||
* @brief Sets state of a neighbor cache entry and triggers required actions.
|
||||
@ -52,7 +52,7 @@ ipv6_addr_t *ng_ndp_internal_default_router(void);
|
||||
* @param[in] nc_entry A neighbor cache entry.
|
||||
* @param[in] state The new state for the neighbor cache entry.
|
||||
*/
|
||||
void ng_ndp_internal_set_state(ng_ipv6_nc_t *nc_entry, uint8_t state);
|
||||
void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state);
|
||||
|
||||
/**
|
||||
* @brief Send precompiled neighbor solicitation.
|
||||
@ -65,8 +65,8 @@ void ng_ndp_internal_set_state(ng_ipv6_nc_t *nc_entry, uint8_t state);
|
||||
* @param[in] dst Destination address for neighbor solicitation. May not be
|
||||
* NULL.
|
||||
*/
|
||||
void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst);
|
||||
void gnrc_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst);
|
||||
|
||||
/**
|
||||
* @brief Send precompiled neighbor advertisement.
|
||||
@ -81,8 +81,8 @@ void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
* @param[in] supply_tl2a Add target link-layer address option to neighbor
|
||||
* advertisement if link-layer has addresses.
|
||||
*/
|
||||
void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst, bool supply_tl2a);
|
||||
void gnrc_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst, bool supply_tl2a);
|
||||
|
||||
/**
|
||||
* @brief Handles a SL2A option.
|
||||
@ -96,9 +96,9 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
* @return true, on success.
|
||||
* @return false, if SL2A was not valid.
|
||||
*/
|
||||
bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, uint8_t icmpv6_type,
|
||||
ndp_opt_t *sl2a_opt);
|
||||
bool gnrc_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
||||
ipv6_hdr_t *ipv6, uint8_t icmpv6_type,
|
||||
ndp_opt_t *sl2a_opt);
|
||||
|
||||
/**
|
||||
* @brief Handles a TL2A option.
|
||||
@ -113,9 +113,9 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
* @return length of the L2 address, on success.
|
||||
* @return -EINVAL, if TL2A was not valid.
|
||||
*/
|
||||
int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
|
||||
uint8_t icmpv6_type, ndp_opt_t *tl2a_opt,
|
||||
uint8_t *l2addr);
|
||||
int gnrc_ndp_internal_tl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
|
||||
uint8_t icmpv6_type, ndp_opt_t *tl2a_opt,
|
||||
uint8_t *l2addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ndp_node Neighbor discovery for pure IPv6 nodes
|
||||
* @ingroup net_ng_ndp
|
||||
* @defgroup net_gnrc_ndp_node Neighbor discovery for pure IPv6 nodes
|
||||
* @ingroup net_gnrc_ndp
|
||||
* @brief Used for pure IPv6 nodes (without 6LoWPAN).
|
||||
* @{
|
||||
*
|
||||
@ -17,8 +17,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_NDP_NODE_H_
|
||||
#define NG_NDP_NODE_H_
|
||||
#ifndef GNRC_NDP_NODE_H_
|
||||
#define GNRC_NDP_NODE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -41,13 +41,13 @@ extern "C" {
|
||||
* @return -ENOBUFS, if @p l2addr_len was smaller than the resulting @p l2addr
|
||||
* would be long.
|
||||
*/
|
||||
kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
ng_pktsnip_t *pkt);
|
||||
kernel_pid_t gnrc_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
gnrc_pktsnip_t *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NDP_NODE_H_ */
|
||||
#endif /* GNRC_NDP_NODE_H_ */
|
||||
/** @} */
|
@ -7,14 +7,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_netapi Generic network module interface
|
||||
* @defgroup net_gnrc_netapi Generic network module interface
|
||||
* @ingroup net
|
||||
* @brief Generic interface for IPC communication between network modules
|
||||
*
|
||||
* @details The idea of this interface is that it provides every network
|
||||
* module with a basic set of commands to communicate with its
|
||||
* neighboring modules. In this model every module runs in its own
|
||||
* thread and communication is done using the @ref net_ng_netapi.
|
||||
* thread and communication is done using the @ref net_gnrc_netapi.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
@ -25,57 +25,57 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NETAPI_H_
|
||||
#define NG_NETAPI_H_
|
||||
#ifndef GNRC_NETAPI_H_
|
||||
#define GNRC_NETAPI_H_
|
||||
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "net/netopt.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief @ref core_msg type for passing a @ref net_ng_pkt up the network stack
|
||||
* @brief @ref core_msg type for passing a @ref net_gnrc_pkt up the network stack
|
||||
*/
|
||||
#define NG_NETAPI_MSG_TYPE_RCV (0x0201)
|
||||
#define GNRC_NETAPI_MSG_TYPE_RCV (0x0201)
|
||||
|
||||
/**
|
||||
* @brief @ref core_msg type for passing a @ref net_ng_pkt down the network stack
|
||||
* @brief @ref core_msg type for passing a @ref net_gnrc_pkt down the network stack
|
||||
*/
|
||||
#define NG_NETAPI_MSG_TYPE_SND (0x0202)
|
||||
#define GNRC_NETAPI_MSG_TYPE_SND (0x0202)
|
||||
|
||||
/**
|
||||
* @brief @ref core_msg type for setting options of network modules
|
||||
*/
|
||||
#define NG_NETAPI_MSG_TYPE_SET (0x0203)
|
||||
#define GNRC_NETAPI_MSG_TYPE_SET (0x0203)
|
||||
|
||||
/**
|
||||
* @brief @ref core_msg type for getting options from network modules
|
||||
*/
|
||||
#define NG_NETAPI_MSG_TYPE_GET (0x0204)
|
||||
#define GNRC_NETAPI_MSG_TYPE_GET (0x0204)
|
||||
|
||||
/**
|
||||
* @brief @ref core_msg type for replying to get and set option messages
|
||||
*/
|
||||
#define NG_NETAPI_MSG_TYPE_ACK (0x0205)
|
||||
#define GNRC_NETAPI_MSG_TYPE_ACK (0x0205)
|
||||
|
||||
/**
|
||||
* @brief Data structure to be send for setting (@ref NG_NETAPI_MSG_TYPE_SET)
|
||||
* and getting (@ref NG_NETAPI_MSG_TYPE_GET) options
|
||||
* @brief Data structure to be send for setting (@ref GNRC_NETAPI_MSG_TYPE_SET)
|
||||
* and getting (@ref GNRC_NETAPI_MSG_TYPE_GET) options
|
||||
*/
|
||||
typedef struct {
|
||||
netopt_t opt; /**< the option to get/set */
|
||||
uint16_t context; /**< (optional) context for that option */
|
||||
void *data; /**< data to set or buffer to read into */
|
||||
uint16_t data_len; /**< size of the data / the buffer */
|
||||
} ng_netapi_opt_t;
|
||||
} gnrc_netapi_opt_t;
|
||||
|
||||
/**
|
||||
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_SND messages
|
||||
* @brief Shortcut function for sending @ref GNRC_NETAPI_MSG_TYPE_SND messages
|
||||
*
|
||||
* @param[in] pid PID of the targeted network module
|
||||
* @param[in] pkt pointer into the packet buffer holding the data to send
|
||||
@ -83,10 +83,10 @@ typedef struct {
|
||||
* @return 1 if packet was successfully delivered
|
||||
* @return -1 on error (invalid PID or no space in queue)
|
||||
*/
|
||||
int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt);
|
||||
int gnrc_netapi_send(kernel_pid_t pid, gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Sends a @ref NG_NETAPI_MSG_TYPE_SND command to all subscribers to
|
||||
* @brief Sends a @ref GNRC_NETAPI_MSG_TYPE_SND command to all subscribers to
|
||||
* (@p type, @p demux_ctx).
|
||||
*
|
||||
* @param[in] type type of the targeted network module.
|
||||
@ -95,11 +95,11 @@ int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt);
|
||||
*
|
||||
* @return Number of subscribers to (@p type, @p demux_ctx).
|
||||
*/
|
||||
int ng_netapi_dispatch_send(ng_nettype_t type, uint32_t demux_ctx,
|
||||
ng_pktsnip_t *pkt);
|
||||
int gnrc_netapi_dispatch_send(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_RCV messages
|
||||
* @brief Shortcut function for sending @ref GNRC_NETAPI_MSG_TYPE_RCV messages
|
||||
*
|
||||
* @param[in] pid PID of the targeted network module
|
||||
* @param[in] pkt pointer into the packet buffer holding the received data
|
||||
@ -107,10 +107,10 @@ int ng_netapi_dispatch_send(ng_nettype_t type, uint32_t demux_ctx,
|
||||
* @return 1 if packet was successfully delivered
|
||||
* @return -1 on error (invalid PID or no space in queue)
|
||||
*/
|
||||
int ng_netapi_receive(kernel_pid_t pid, ng_pktsnip_t *pkt);
|
||||
int gnrc_netapi_receive(kernel_pid_t pid, gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Sends a @ref NG_NETAPI_MSG_TYPE_RCV command to all subscribers to
|
||||
* @brief Sends a @ref GNRC_NETAPI_MSG_TYPE_RCV command to all subscribers to
|
||||
* (@p type, @p demux_ctx).
|
||||
*
|
||||
* @param[in] type type of the targeted network module.
|
||||
@ -119,12 +119,12 @@ int ng_netapi_receive(kernel_pid_t pid, ng_pktsnip_t *pkt);
|
||||
*
|
||||
* @return Number of subscribers to (@p type, @p demux_ctx).
|
||||
*/
|
||||
int ng_netapi_dispatch_receive(ng_nettype_t type, uint32_t demux_ctx,
|
||||
ng_pktsnip_t *pkt);
|
||||
int gnrc_netapi_dispatch_receive(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_GET messages and
|
||||
* parsing the returned @ref NG_NETAPI_MSG_TYPE_ACK message
|
||||
* @brief Shortcut function for sending @ref GNRC_NETAPI_MSG_TYPE_GET messages and
|
||||
* parsing the returned @ref GNRC_NETAPI_MSG_TYPE_ACK message
|
||||
*
|
||||
* @param[in] pid PID of the targeted network module
|
||||
* @param[in] opt option to get
|
||||
@ -132,14 +132,14 @@ int ng_netapi_dispatch_receive(ng_nettype_t type, uint32_t demux_ctx,
|
||||
* @param[in] data pointer to buffer for reading the option's value
|
||||
* @param[in] max_len maximum number of bytes that fit into @p data
|
||||
*
|
||||
* @return value returned by the @ref NG_NETAPI_MSG_TYPE_ACK message
|
||||
* @return value returned by the @ref GNRC_NETAPI_MSG_TYPE_ACK message
|
||||
*/
|
||||
int ng_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t max_len);
|
||||
int gnrc_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t max_len);
|
||||
|
||||
/**
|
||||
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_SET messages and
|
||||
* parsing the returned @ref NG_NETAPI_MSG_TYPE_ACK message
|
||||
* @brief Shortcut function for sending @ref GNRC_NETAPI_MSG_TYPE_SET messages and
|
||||
* parsing the returned @ref GNRC_NETAPI_MSG_TYPE_ACK message
|
||||
*
|
||||
* @param[in] pid PID of the targeted network module
|
||||
* @param[in] opt option to set
|
||||
@ -147,16 +147,16 @@ int ng_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
* @param[in] data data to set the given option to
|
||||
* @param[in] data_len size of @p data
|
||||
*
|
||||
* @return value returned by the @ref NG_NETAPI_MSG_TYPE_ACK message
|
||||
* @return value returned by the @ref GNRC_NETAPI_MSG_TYPE_ACK message
|
||||
*/
|
||||
int ng_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len);
|
||||
int gnrc_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETAPI_H_ */
|
||||
#endif /* GNRC_NETAPI_H_ */
|
||||
/**
|
||||
* @}^
|
||||
*/
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_netdev Network device driver interface
|
||||
* @defgroup net_gnrc_netdev Network device driver interface
|
||||
* @ingroup net
|
||||
* @{
|
||||
*
|
||||
@ -19,15 +19,15 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NETDEV_H_
|
||||
#define NG_NETDEV_H_
|
||||
#ifndef GNRC_NETDEV_H_
|
||||
#define GNRC_NETDEV_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/netopt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -37,7 +37,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Type for @ref msg_t if device fired an event
|
||||
*/
|
||||
#define NG_NETDEV_MSG_TYPE_EVENT (0x0100)
|
||||
#define GNRC_NETDEV_MSG_TYPE_EVENT (0x0100)
|
||||
|
||||
/**
|
||||
* @brief Possible event types that are send from the device driver to the
|
||||
@ -49,7 +49,7 @@ typedef enum {
|
||||
NETDEV_EVENT_TX_STARTED = 0x0004, /**< started to transfer a packet */
|
||||
NETDEV_EVENT_TX_COMPLETE = 0x0008, /**< finished transferring packet */
|
||||
/* expand this list if needed */
|
||||
} ng_netdev_event_t;
|
||||
} gnrc_netdev_event_t;
|
||||
|
||||
/**
|
||||
* @brief Event callback for signaling event to a MAC layer
|
||||
@ -57,15 +57,15 @@ typedef enum {
|
||||
* @param[in] type type of the event
|
||||
* @param[in] arg event argument, can e.g. contain a pktsnip_t pointer
|
||||
*/
|
||||
typedef void (*ng_netdev_event_cb_t)(ng_netdev_event_t type, void *arg);
|
||||
typedef void (*gnrc_netdev_event_cb_t)(gnrc_netdev_event_t type, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Forward declaration of ng_netdev_t due to cyclic dependency to
|
||||
* @ref ng_netdev_driver_t.
|
||||
* @brief Forward declaration of gnrc_netdev_t due to cyclic dependency to
|
||||
* @ref gnrc_netdev_driver_t.
|
||||
*
|
||||
* @see ng_netdev
|
||||
* @see gnrc_netdev
|
||||
*/
|
||||
typedef struct ng_netdev ng_netdev_t;
|
||||
typedef struct gnrc_netdev gnrc_netdev_t;
|
||||
|
||||
/**
|
||||
* @brief Network device API definition.
|
||||
@ -86,7 +86,7 @@ typedef struct {
|
||||
* @return -EOVERFLOW if the payload size of @p pkt exceeds the
|
||||
* payload size that can be handled by the device
|
||||
*/
|
||||
int (*send_data)(ng_netdev_t *dev, ng_pktsnip_t *pkt);
|
||||
int (*send_data)(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Registers an event callback to a given network device
|
||||
@ -98,7 +98,7 @@ typedef struct {
|
||||
* @return -ENODEV if @p dev is invalid
|
||||
* @return -ENOBUFS if maximum number of callbacks is exceeded
|
||||
*/
|
||||
int (*add_event_callback)(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
int (*add_event_callback)(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregisters an event callback from a given network device
|
||||
@ -110,7 +110,7 @@ typedef struct {
|
||||
* @return -ENODEV if @p dev is invalid
|
||||
* @return -ENOENT if callback was not registered
|
||||
*/
|
||||
int (*rem_event_callback)(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
int (*rem_event_callback)(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Get an option value from a given network device
|
||||
@ -127,7 +127,7 @@ typedef struct {
|
||||
* @p max_len is too small to store the option value
|
||||
* @return -ECANCELED if internal driver error occurred
|
||||
*/
|
||||
int (*get)(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
int (*get)(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
|
||||
/**
|
||||
* @brief Set an option value for a given network device
|
||||
@ -143,18 +143,18 @@ typedef struct {
|
||||
* @return -EINVAL if @p value is invalid
|
||||
* @return -ECANCELED if internal driver error occurred
|
||||
*/
|
||||
int (*set)(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
int (*set)(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
|
||||
/**
|
||||
* @brief This function is called by a MAC layer when a message of type
|
||||
* @ref NG_NETDEV_MSG_TYPE_EVENT was received
|
||||
* @ref GNRC_NETDEV_MSG_TYPE_EVENT was received
|
||||
*
|
||||
* @param[in] dev network device descriptor
|
||||
* @param[in] event_type event type, given by msg_t::content::value
|
||||
* in the received message
|
||||
*/
|
||||
void (*isr_event)(ng_netdev_t *dev, uint32_t event_type);
|
||||
} ng_netdev_driver_t;
|
||||
void (*isr_event)(gnrc_netdev_t *dev, uint32_t event_type);
|
||||
} gnrc_netdev_driver_t;
|
||||
|
||||
/**
|
||||
* @brief The netdev data-structure holds the minimum information needed for
|
||||
@ -163,11 +163,11 @@ typedef struct {
|
||||
*
|
||||
* The netdev structure is the parent for all network device driver descriptors.
|
||||
*
|
||||
* @see ng_netdev_t
|
||||
* @see gnrc_netdev_t
|
||||
*/
|
||||
struct ng_netdev {
|
||||
ng_netdev_driver_t const *driver; /**< pointer to the devices interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
struct gnrc_netdev {
|
||||
gnrc_netdev_driver_t const *driver; /**< pointer to the devices interface */
|
||||
gnrc_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< the driver's thread's PID */
|
||||
};
|
||||
|
||||
@ -175,5 +175,5 @@ struct ng_netdev {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETDEV_H_ */
|
||||
#endif /* GNRC_NETDEV_H_ */
|
||||
/** @} */
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ng_netdev_eth dev_eth ethernet interface as netdev device.
|
||||
* @defgroup gnrc_netdev_eth dev_eth ethernet interface as netdev device.
|
||||
* @ingroup net
|
||||
*
|
||||
* @brief Allows for usage of dev_eth ethernet interfaces as ethernet netdev
|
||||
@ -18,19 +18,19 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definitions for @ref ng_netdev_eth
|
||||
* @brief Definitions for @ref gnrc_netdev_eth
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NETDEV_ETH_H_
|
||||
#define NG_NETDEV_ETH_H_
|
||||
#ifndef GNRC_NETDEV_ETH_H_
|
||||
#define GNRC_NETDEV_ETH_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "net/ethernet/hdr.h"
|
||||
#include "net/dev_eth.h"
|
||||
|
||||
@ -40,26 +40,28 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Definition of the netdev_eth device
|
||||
* @extends ng_netdev_t
|
||||
* @extends gnrc_netdev_t
|
||||
* @internal
|
||||
*/
|
||||
typedef struct {
|
||||
ng_netdev_driver_t *driver; /**< pointer to the devices interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
gnrc_netdev_driver_t *driver; /**< pointer to the devices interface */
|
||||
gnrc_netdev_event_cb_t event_cb;/**< netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< the driver's thread's PID */
|
||||
dev_eth_t *ethdev; /**< ptr to low-level device handle */
|
||||
} ng_netdev_eth_t;
|
||||
} gnrc_netdev_eth_t;
|
||||
|
||||
/**
|
||||
* @brief Reference to the netdev_eth driver interface
|
||||
*/
|
||||
extern const ng_netdev_driver_t ng_netdev_eth_driver;
|
||||
extern const gnrc_netdev_driver_t gnrc_netdev_eth_driver;
|
||||
|
||||
/**
|
||||
* @brief Reference to the netdev_eth device
|
||||
*/
|
||||
extern ng_netdev_eth_t ng_netdev_eth; /* XXX: this is only here since I do not know how
|
||||
* to get the device in the interrupt handler */
|
||||
extern gnrc_netdev_eth_t gnrc_netdev_eth;
|
||||
/* XXX: this is only here since I do not know how to get the device in the
|
||||
* interrupt handler */
|
||||
|
||||
/**
|
||||
* @brief Initialize a given netdev_eth device
|
||||
*
|
||||
@ -71,11 +73,11 @@ extern ng_netdev_eth_t ng_netdev_eth; /* XXX: this is only here since I do not k
|
||||
* @return 0 on success
|
||||
* @return -ENODEV on invalid device descriptor
|
||||
*/
|
||||
int ng_netdev_eth_init(ng_netdev_eth_t *netdev, dev_eth_t *ethdev);
|
||||
int gnrc_netdev_eth_init(gnrc_netdev_eth_t *netdev, dev_eth_t *ethdev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* NG_NETDEV_ETH_H_ */
|
||||
#endif /* GNRC_NETDEV_ETH_H_ */
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_netif Network interfaces
|
||||
* @defgroup net_gnrc_netif Network interfaces
|
||||
* @ingroup net
|
||||
* @brief Abstraction layer for network interfaces
|
||||
*
|
||||
@ -21,8 +21,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_NETIF_H_
|
||||
#define NG_NETIF_H_
|
||||
#ifndef GNRC_NETIF_H_
|
||||
#define GNRC_NETIF_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "kernel_types.h"
|
||||
@ -34,8 +34,8 @@ extern "C" {
|
||||
/**
|
||||
* @brief Maximum number of network interfaces
|
||||
*/
|
||||
#ifndef NG_NETIF_NUMOF
|
||||
#define NG_NETIF_NUMOF (1)
|
||||
#ifndef GNRC_NETIF_NUMOF
|
||||
#define GNRC_NETIF_NUMOF (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -44,24 +44,24 @@ extern "C" {
|
||||
*
|
||||
* @param[in] pid The PID to the new interface.
|
||||
*/
|
||||
typedef void (*ng_netif_op_t)(kernel_pid_t pid);
|
||||
typedef void (*gnrc_netif_op_t)(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief The add and remove handlers to set network layer protocol
|
||||
* specific options for an interface.
|
||||
*
|
||||
* @details If you implement a pair, please add it to the list in ng_netif.c
|
||||
* @details If you implement a pair, please add it to the list in gnrc_netif.c
|
||||
* statically.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_netif_op_t add; /**< The add operation */
|
||||
ng_netif_op_t remove; /**< The remove operation */
|
||||
} ng_netif_handler_t;
|
||||
gnrc_netif_op_t add; /**< The add operation */
|
||||
gnrc_netif_op_t remove; /**< The remove operation */
|
||||
} gnrc_netif_handler_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes module.
|
||||
*/
|
||||
void ng_netif_init(void);
|
||||
void gnrc_netif_init(void);
|
||||
|
||||
/**
|
||||
* @brief Adds a thread as interface.
|
||||
@ -71,24 +71,24 @@ void ng_netif_init(void);
|
||||
* @return 0, on success,
|
||||
* @return -ENOMEM, if maximum number of interfaces has been exceeded.
|
||||
*/
|
||||
int ng_netif_add(kernel_pid_t pid);
|
||||
int gnrc_netif_add(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Removes a thread as interface.
|
||||
*
|
||||
* @param[in] pid PID of the removed thread.
|
||||
*/
|
||||
void ng_netif_remove(kernel_pid_t pid);
|
||||
void gnrc_netif_remove(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Get all active interfaces.
|
||||
*
|
||||
* @param[out] netifs List of all active interfaces. There is no order ensured.
|
||||
* It must at least fit @ref NG_NETIF_NUMOF elements.
|
||||
* It must at least fit @ref GNRC_NETIF_NUMOF elements.
|
||||
*
|
||||
* @return The number of active interfaces.
|
||||
*/
|
||||
size_t ng_netif_get(kernel_pid_t *netifs);
|
||||
size_t gnrc_netif_get(kernel_pid_t *netifs);
|
||||
|
||||
/**
|
||||
* @brief Converts a hardware address to a human readable string.
|
||||
@ -107,8 +107,8 @@ size_t ng_netif_get(kernel_pid_t *netifs);
|
||||
* @return Copy of @p out on success.
|
||||
* @return NULL, if @p out_len < 3 * @p addr_len.
|
||||
*/
|
||||
char *ng_netif_addr_to_str(char *out, size_t out_len, const uint8_t *addr,
|
||||
size_t addr_len);
|
||||
char *gnrc_netif_addr_to_str(char *out, size_t out_len, const uint8_t *addr,
|
||||
size_t addr_len);
|
||||
|
||||
/**
|
||||
* @brief Parses a string of colon-separated hexadecimals to a hardware
|
||||
@ -124,11 +124,11 @@ char *ng_netif_addr_to_str(char *out, size_t out_len, const uint8_t *addr,
|
||||
* @return Actual length of @p out on success.
|
||||
* @return 0, on failure.
|
||||
*/
|
||||
size_t ng_netif_addr_from_str(uint8_t *out, size_t out_len, const char *str);
|
||||
size_t gnrc_netif_addr_from_str(uint8_t *out, size_t out_len, const char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETIF_H_ */
|
||||
#endif /* GNRC_NETIF_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_netif_hdr Generic network interface header
|
||||
* @ingroup net_ng_netif
|
||||
* @defgroup net_gnrc_netif_hdr Generic network interface header
|
||||
* @ingroup net_gnrc_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -25,8 +25,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -36,35 +36,35 @@ extern "C" {
|
||||
* @brief Maximum length of the l2 addresses of the generic interface header
|
||||
* in bytes.
|
||||
*/
|
||||
#define NG_NETIF_HDR_L2ADDR_MAX_LEN (8)
|
||||
#define GNRC_NETIF_HDR_L2ADDR_MAX_LEN (8)
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Flags for the ng_netif_hdr_t
|
||||
* @name Flags for the gnrc_netif_hdr_t
|
||||
*/
|
||||
/**
|
||||
* @brief Send packet broadcast.
|
||||
*
|
||||
* @details Packets with this flag set must be send broadcast.
|
||||
* ng_netif_hdr_t::dst_l2addr_len and any appended destination
|
||||
* gnrc_netif_hdr_t::dst_l2addr_len and any appended destination
|
||||
* address must be ignored.
|
||||
* If the link layer does not support broadcast the packet must be
|
||||
* dropped silently.
|
||||
*/
|
||||
#define NG_NETIF_HDR_FLAGS_BROADCAST (0x80)
|
||||
#define GNRC_NETIF_HDR_FLAGS_BROADCAST (0x80)
|
||||
|
||||
/**
|
||||
* @brief Send packet multicast.
|
||||
*
|
||||
* @details Packets with this flag set must be send multicast.
|
||||
* ng_netif_hdr_t::dst_l2addr_len and any appended destination
|
||||
* gnrc_netif_hdr_t::dst_l2addr_len and any appended destination
|
||||
* address must be ignored.
|
||||
* The context for the multicast address must be derived from the
|
||||
* network layer destination address.
|
||||
* If the link layer does not support multicast it should interpret
|
||||
* this flag the same way it does @ref NG_NETIF_HDR_FLAGS_BROADCAST.
|
||||
* this flag the same way it does @ref GNRC_NETIF_HDR_FLAGS_BROADCAST.
|
||||
*/
|
||||
#define NG_NETIF_HDR_FLAGS_MULTICAST (0x40)
|
||||
#define GNRC_NETIF_HDR_FLAGS_MULTICAST (0x40)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -82,7 +82,7 @@ typedef struct {
|
||||
uint8_t flags; /**< flags as defined above */
|
||||
uint8_t rssi; /**< rssi of received packet (optional) */
|
||||
uint8_t lqi; /**< lqi of received packet (optional) */
|
||||
} ng_netif_hdr_t;
|
||||
} gnrc_netif_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the given generic network interface header
|
||||
@ -91,8 +91,8 @@ typedef struct {
|
||||
* @param[in] src_l2addr_len link layer source address length
|
||||
* @param[in] dst_l2addr_len link layer destination address length
|
||||
*/
|
||||
static inline void ng_netif_hdr_init(ng_netif_hdr_t *hdr, uint8_t src_l2addr_len,
|
||||
uint8_t dst_l2addr_len)
|
||||
static inline void gnrc_netif_hdr_init(gnrc_netif_hdr_t *hdr, uint8_t src_l2addr_len,
|
||||
uint8_t dst_l2addr_len)
|
||||
{
|
||||
hdr->src_l2addr_len = src_l2addr_len;
|
||||
hdr->dst_l2addr_len = dst_l2addr_len;
|
||||
@ -110,9 +110,9 @@ static inline void ng_netif_hdr_init(ng_netif_hdr_t *hdr, uint8_t src_l2addr_len
|
||||
* @return the size of the given header, including link layer
|
||||
* addresses
|
||||
*/
|
||||
static inline size_t ng_netif_hdr_sizeof(ng_netif_hdr_t *hdr)
|
||||
static inline size_t gnrc_netif_hdr_sizeof(gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
return sizeof(ng_netif_hdr_t) + hdr->src_l2addr_len + hdr->dst_l2addr_len;
|
||||
return sizeof(gnrc_netif_hdr_t) + hdr->src_l2addr_len + hdr->dst_l2addr_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +123,7 @@ static inline size_t ng_netif_hdr_sizeof(ng_netif_hdr_t *hdr)
|
||||
* @return pointer to source address on success
|
||||
* @return NULL on error
|
||||
*/
|
||||
static inline uint8_t *ng_netif_hdr_get_src_addr(ng_netif_hdr_t *hdr)
|
||||
static inline uint8_t *gnrc_netif_hdr_get_src_addr(gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
return ((uint8_t *)(hdr + 1));
|
||||
}
|
||||
@ -135,7 +135,7 @@ static inline uint8_t *ng_netif_hdr_get_src_addr(ng_netif_hdr_t *hdr)
|
||||
* @param[in] addr new source address
|
||||
* @param[in] addr_len *addr* length
|
||||
*/
|
||||
static inline void ng_netif_hdr_set_src_addr(ng_netif_hdr_t *hdr, uint8_t *addr,
|
||||
static inline void gnrc_netif_hdr_set_src_addr(gnrc_netif_hdr_t *hdr, uint8_t *addr,
|
||||
uint8_t addr_len)
|
||||
{
|
||||
if (addr_len != hdr->src_l2addr_len) {
|
||||
@ -154,7 +154,7 @@ static inline void ng_netif_hdr_set_src_addr(ng_netif_hdr_t *hdr, uint8_t *addr,
|
||||
* @return pointer to destination address on success
|
||||
* @return NULL on error
|
||||
*/
|
||||
static inline uint8_t *ng_netif_hdr_get_dst_addr(ng_netif_hdr_t *hdr)
|
||||
static inline uint8_t *gnrc_netif_hdr_get_dst_addr(gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
return (((uint8_t *)(hdr + 1)) + hdr->src_l2addr_len);
|
||||
}
|
||||
@ -166,7 +166,7 @@ static inline uint8_t *ng_netif_hdr_get_dst_addr(ng_netif_hdr_t *hdr)
|
||||
* @param[in] addr new destination address
|
||||
* @param[in] addr_len *addr* length
|
||||
*/
|
||||
static inline void ng_netif_hdr_set_dst_addr(ng_netif_hdr_t *hdr, uint8_t *addr,
|
||||
static inline void gnrc_netif_hdr_set_dst_addr(gnrc_netif_hdr_t *hdr, uint8_t *addr,
|
||||
uint8_t addr_len)
|
||||
{
|
||||
if (addr_len != hdr->dst_l2addr_len) {
|
||||
@ -190,25 +190,25 @@ static inline void ng_netif_hdr_set_dst_addr(ng_netif_hdr_t *hdr, uint8_t *addr,
|
||||
* @return The generic network layer header on success.
|
||||
* @return NULL on error.
|
||||
*/
|
||||
static inline ng_pktsnip_t *ng_netif_hdr_build(uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len)
|
||||
static inline gnrc_pktsnip_t *gnrc_netif_hdr_build(uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len)
|
||||
{
|
||||
ng_pktsnip_t *pkt = ng_pktbuf_add(NULL, NULL,
|
||||
sizeof(ng_netif_hdr_t) + src_len + dst_len,
|
||||
NG_NETTYPE_NETIF);
|
||||
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, NULL,
|
||||
sizeof(gnrc_netif_hdr_t) + src_len + dst_len,
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (pkt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_netif_hdr_init(pkt->data, src_len, dst_len);
|
||||
gnrc_netif_hdr_init(pkt->data, src_len, dst_len);
|
||||
|
||||
if (src != NULL && src_len > 0) {
|
||||
ng_netif_hdr_set_src_addr(pkt->data, src, src_len);
|
||||
gnrc_netif_hdr_set_src_addr(pkt->data, src, src_len);
|
||||
}
|
||||
|
||||
if (dst != NULL && dst_len > 0) {
|
||||
ng_netif_hdr_set_dst_addr(pkt->data, dst, dst_len);
|
||||
gnrc_netif_hdr_set_dst_addr(pkt->data, dst, dst_len);
|
||||
}
|
||||
|
||||
return pkt;
|
||||
@ -219,7 +219,7 @@ static inline ng_pktsnip_t *ng_netif_hdr_build(uint8_t *src, uint8_t src_len,
|
||||
*
|
||||
* @param[in] hdr A generic interface header.
|
||||
*/
|
||||
void ng_netif_hdr_print(ng_netif_hdr_t *hdr);
|
||||
void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -7,13 +7,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_netreg Network protocol registry
|
||||
* @defgroup net_gnrc_netreg Network protocol registry
|
||||
* @ingroup net
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definitions to register network protocol PIDs to use with
|
||||
* @ref net_ng_netapi.
|
||||
* @ref net_gnrc_netapi.
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
@ -23,8 +23,8 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -33,20 +33,20 @@ extern "C" {
|
||||
/**
|
||||
* @brief Demux context value to get all packets of a certain type.
|
||||
*
|
||||
* @see ng_netreg_entry_t::demux_ctx
|
||||
* @see gnrc_netreg_entry_t::demux_ctx
|
||||
*/
|
||||
#define NG_NETREG_DEMUX_CTX_ALL (0xffff0000)
|
||||
#define GNRC_NETREG_DEMUX_CTX_ALL (0xffff0000)
|
||||
|
||||
/**
|
||||
* @brief Entry to the @ref net_ng_netreg
|
||||
* @brief Entry to the @ref net_gnrc_netreg
|
||||
*/
|
||||
typedef struct ng_netreg_entry {
|
||||
typedef struct gnrc_netreg_entry {
|
||||
/**
|
||||
* @brief next element in list
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
struct ng_netreg_entry *next;
|
||||
struct gnrc_netreg_entry *next;
|
||||
|
||||
/**
|
||||
* @brief The demultiplexing context for the registering thread.
|
||||
@ -57,31 +57,31 @@ typedef struct ng_netreg_entry {
|
||||
*/
|
||||
uint32_t demux_ctx;
|
||||
kernel_pid_t pid; /**< The PID of the registering thread */
|
||||
} ng_netreg_entry_t;
|
||||
} gnrc_netreg_entry_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes module.
|
||||
*/
|
||||
void ng_netreg_init(void);
|
||||
void gnrc_netreg_init(void);
|
||||
|
||||
/**
|
||||
* @brief Registers a thread to the registry.
|
||||
*
|
||||
* @details The semantics are: Thread ng_netreg_entry_t::pid is interested in
|
||||
* packets of protocol @p type with context ng_netreg_entry_t::demux_ctx.
|
||||
* @details The semantics are: Thread gnrc_netreg_entry_t::pid is interested in
|
||||
* packets of protocol @p type with context gnrc_netreg_entry_t::demux_ctx.
|
||||
*
|
||||
* @param[in] type Type of the protocol. Must not be < NG_NETTYPE_UNDEF or
|
||||
* >= NG_NETTYPE_NUMOF.
|
||||
* @param[in] type Type of the protocol. Must not be < GNRC_NETTYPE_UNDEF or
|
||||
* >= GNRC_NETTYPE_NUMOF.
|
||||
* @param[in] entry An entry you want to add to the registry with
|
||||
* ng_netreg_entry_t::pid and ng_netreg_entry_t::demux_ctx set.
|
||||
* gnrc_netreg_entry_t::pid and gnrc_netreg_entry_t::demux_ctx set.
|
||||
*
|
||||
* @warning Call ng_netreg_unregister() *before* you leave the context you
|
||||
* @warning Call gnrc_netreg_unregister() *before* you leave the context you
|
||||
* allocated @p entry in. Otherwise it might get overwritten.
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -EINVAL if @p type was < NG_NETTYPE_UNDEF or >= NG_NETTYPE_NUMOF
|
||||
* @return -EINVAL if @p type was < GNRC_NETTYPE_UNDEF or >= GNRC_NETTYPE_NUMOF
|
||||
*/
|
||||
int ng_netreg_register(ng_nettype_t type, ng_netreg_entry_t *entry);
|
||||
int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry);
|
||||
|
||||
/**
|
||||
* @brief Removes a thread from the registry.
|
||||
@ -89,7 +89,7 @@ int ng_netreg_register(ng_nettype_t type, ng_netreg_entry_t *entry);
|
||||
* @param[in] type Type of the protocol.
|
||||
* @param[in] entry An entry you want to remove from the registry.
|
||||
*/
|
||||
void ng_netreg_unregister(ng_nettype_t type, ng_netreg_entry_t *entry);
|
||||
void gnrc_netreg_unregister(gnrc_nettype_t type, gnrc_netreg_entry_t *entry);
|
||||
|
||||
/**
|
||||
* @brief Searches for entries with given parameters in the registry and
|
||||
@ -97,38 +97,38 @@ void ng_netreg_unregister(ng_nettype_t type, ng_netreg_entry_t *entry);
|
||||
*
|
||||
* @param[in] type Type of the protocol.
|
||||
* @param[in] demux_ctx The demultiplexing context for the registered thread.
|
||||
* See ng_netreg_entry_t::demux_ctx.
|
||||
* See gnrc_netreg_entry_t::demux_ctx.
|
||||
*
|
||||
* @return The first entry fitting the given parameters on success
|
||||
* @return NULL if no entry can be found.
|
||||
*/
|
||||
ng_netreg_entry_t *ng_netreg_lookup(ng_nettype_t type, uint32_t demux_ctx);
|
||||
gnrc_netreg_entry_t *gnrc_netreg_lookup(gnrc_nettype_t type, uint32_t demux_ctx);
|
||||
|
||||
/**
|
||||
* @brief Returns number of entries with the same ng_netreg_entry_t::type and
|
||||
* ng_netreg_entry_t::demux_ctx.
|
||||
* @brief Returns number of entries with the same gnrc_netreg_entry_t::type and
|
||||
* gnrc_netreg_entry_t::demux_ctx.
|
||||
*
|
||||
* @param[in] type Type of the protocol.
|
||||
* @param[in] demux_ctx The demultiplexing context for the registered thread.
|
||||
* See ng_netreg_entry_t::demux_ctx.
|
||||
* See gnrc_netreg_entry_t::demux_ctx.
|
||||
*
|
||||
* @return Number of entries with the same ng_netreg_entry_t::type and
|
||||
* ng_netreg_entry_t::demux_ctx as the given parameters.
|
||||
* @return Number of entries with the same gnrc_netreg_entry_t::type and
|
||||
* gnrc_netreg_entry_t::demux_ctx as the given parameters.
|
||||
*/
|
||||
int ng_netreg_num(ng_nettype_t type, uint32_t demux_ctx);
|
||||
int gnrc_netreg_num(gnrc_nettype_t type, uint32_t demux_ctx);
|
||||
|
||||
/**
|
||||
* @brief Returns the next entry after @p entry with the same
|
||||
* ng_netreg_entry_t::type and ng_netreg_entry_t::demux_ctx as the
|
||||
* gnrc_netreg_entry_t::type and gnrc_netreg_entry_t::demux_ctx as the
|
||||
* given entry.
|
||||
*
|
||||
* @param[in] entry A registry entry retrieved by ng_netreg_lookup() or
|
||||
* ng_netreg_getnext(). Must not be NULL.
|
||||
* @param[in] entry A registry entry retrieved by gnrc_netreg_lookup() or
|
||||
* gnrc_netreg_getnext(). Must not be NULL.
|
||||
*
|
||||
* @return The next entry after @p entry fitting the given parameters on success
|
||||
* @return NULL if no entry new entry can be found.
|
||||
*/
|
||||
ng_netreg_entry_t *ng_netreg_getnext(ng_netreg_entry_t *entry);
|
||||
gnrc_netreg_entry_t *gnrc_netreg_getnext(gnrc_netreg_entry_t *entry);
|
||||
|
||||
/**
|
||||
* @brief Calculates the checksum for a header.
|
||||
@ -140,11 +140,11 @@ ng_netreg_entry_t *ng_netreg_getnext(ng_netreg_entry_t *entry);
|
||||
*
|
||||
* @return 0, on success.
|
||||
* @return -EINVAL, if @p pseudo_hdr is NULL but a pseudo header was required.
|
||||
* @return -ENOENT, if @ref net_netreg does not know how to calculate checksum
|
||||
* for ng_pktsnip_t::type of @p hdr.
|
||||
* @return -ENOENT, if @ref net_gnrc_netreg does not know how to calculate checksum
|
||||
* for gnrc_pktsnip_t::type of @p hdr.
|
||||
*/
|
||||
|
||||
int ng_netreg_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr);
|
||||
int gnrc_netreg_calc_csum(gnrc_pktsnip_t *hdr, gnrc_pktsnip_t *pseudo_hdr);
|
||||
|
||||
/**
|
||||
* @brief Builds a header for sending and adds it to the packet buffer.
|
||||
@ -161,9 +161,9 @@ int ng_netreg_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr);
|
||||
* @return The header for the protocol on success.
|
||||
* @return NULL on error.
|
||||
*/
|
||||
ng_pktsnip_t *ng_netreg_hdr_build(ng_nettype_t type, ng_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len);
|
||||
gnrc_pktsnip_t *gnrc_netreg_hdr_build(gnrc_nettype_t type, gnrc_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -7,28 +7,28 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_nettest NETAPI test framework
|
||||
* @ingroup net_ng_netapi
|
||||
* @brief This provides a framework to test the @ref net_ng_netapi IPC
|
||||
* @defgroup net_gnrc_nettest NETAPI test framework
|
||||
* @ingroup net_gnrc_netapi
|
||||
* @brief This provides a framework to test the @ref net_gnrc_netapi IPC
|
||||
* calls.
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definitions for the @ref net_ng_netapi test framework
|
||||
* @brief Definitions for the @ref net_gnrc_netapi test framework
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_NETTEST_H_
|
||||
#define NG_NETTEST_H_
|
||||
#ifndef GNRC_NETTEST_H_
|
||||
#define GNRC_NETTEST_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_netapi.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
#include "net/netopt.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -38,29 +38,29 @@ extern "C" {
|
||||
/**
|
||||
* @brief Timeout for tests in microseconds
|
||||
*/
|
||||
#ifndef NG_NETTEST_TIMEOUT
|
||||
#define NG_NETTEST_TIMEOUT (1000)
|
||||
#ifndef GNRC_NETTEST_TIMEOUT
|
||||
#define GNRC_NETTEST_TIMEOUT (1000)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default stack size to use for the nettest thread
|
||||
*/
|
||||
#ifndef NG_NETTEST_STACK_SIZE
|
||||
#define NG_NETTEST_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_NETTEST_STACK_SIZE
|
||||
#define GNRC_NETTEST_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default priority for the nettest thread
|
||||
*/
|
||||
#ifndef NG_NETTEST_PRIO
|
||||
#define NG_NETTEST_PRIO (THREAD_PRIORITY_MAIN)
|
||||
#ifndef GNRC_NETTEST_PRIO
|
||||
#define GNRC_NETTEST_PRIO (THREAD_PRIORITY_MAIN)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default message queue size to use for the nettest thread.
|
||||
*/
|
||||
#ifndef NG_NETTEST_MSG_QUEUE_SIZE
|
||||
#define NG_NETTEST_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_NETTEST_MSG_QUEUE_SIZE
|
||||
#define GNRC_NETTEST_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,34 +68,34 @@ extern "C" {
|
||||
* @brief Type for get/set callbacks.
|
||||
*
|
||||
* @param[in] context (Optional) context for the option.
|
||||
* Compare ng_netapi_opt_t::context.
|
||||
* Compare gnrc_netapi_opt_t::context.
|
||||
* @param[in,out] data Data to set or buffer to read into.
|
||||
* Compare ng_netapi_opt_t::data.
|
||||
* Compare gnrc_netapi_opt_t::data.
|
||||
* @param[in] data_len Size of the data / the buffer.
|
||||
* Compare ng_netapi_opt_t::data_len
|
||||
* Compare gnrc_netapi_opt_t::data_len
|
||||
*
|
||||
* @return The value for the @ref NG_NETAPI_MSG_TYPE_ACK message.
|
||||
* @return The value for the @ref GNRC_NETAPI_MSG_TYPE_ACK message.
|
||||
*/
|
||||
typedef int (*ng_nettest_opt_cb_t)(uint16_t context, void *data, uint16_t data_len);
|
||||
typedef int (*gnrc_nettest_opt_cb_t)(uint16_t context, void *data, uint16_t data_len);
|
||||
|
||||
/**
|
||||
* @brief Option callback list element.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_nettest_opt_cb_t get; /**< getter for an option */
|
||||
ng_nettest_opt_cb_t set; /**< setter for an option */
|
||||
} ng_nettest_opt_cbs_t;
|
||||
gnrc_nettest_opt_cb_t get; /**< getter for an option */
|
||||
gnrc_nettest_opt_cb_t set; /**< setter for an option */
|
||||
} gnrc_nettest_opt_cbs_t;
|
||||
|
||||
/**
|
||||
* @brief Result type for tests.
|
||||
*/
|
||||
typedef enum {
|
||||
NG_NETTEST_SUCCESS = 0, /**< test was successful */
|
||||
NG_NETTEST_FAIL, /**< test failed */
|
||||
NG_NETTEST_TIMED_OUT, /**< test timed out */
|
||||
NG_NETTEST_WRONG_MSG, /**< wrong message type received */
|
||||
NG_NETTEST_WRONG_SENDER, /**< wrong message type received */
|
||||
} ng_nettest_res_t;
|
||||
GNRC_NETTEST_SUCCESS = 0, /**< test was successful */
|
||||
GNRC_NETTEST_FAIL, /**< test failed */
|
||||
GNRC_NETTEST_TIMED_OUT, /**< test timed out */
|
||||
GNRC_NETTEST_WRONG_MSG, /**< wrong message type received */
|
||||
GNRC_NETTEST_WRONG_SENDER, /**< wrong message type received */
|
||||
} gnrc_nettest_res_t;
|
||||
|
||||
/**
|
||||
* @brief Registers a getter for an option.
|
||||
@ -105,7 +105,7 @@ typedef enum {
|
||||
* @param[in] opt The option to register the getter for.
|
||||
* @param[in] cb An option getter. NULL to delete.
|
||||
*/
|
||||
void ng_nettest_register_get(netopt_t opt, ng_nettest_opt_cb_t cb);
|
||||
void gnrc_nettest_register_get(netopt_t opt, gnrc_nettest_opt_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Registers a setter for an option.
|
||||
@ -115,20 +115,20 @@ void ng_nettest_register_get(netopt_t opt, ng_nettest_opt_cb_t cb);
|
||||
* @param[in] opt The option to register the setter for.
|
||||
* @param[in] cb An option setter. NULL to delete.
|
||||
*/
|
||||
void ng_nettest_register_set(netopt_t opt, ng_nettest_opt_cb_t cb);
|
||||
void gnrc_nettest_register_set(netopt_t opt, gnrc_nettest_opt_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Test @ref NG_NETAPI_MSG_TYPE_SND command to @p pid.
|
||||
* @brief Test @ref GNRC_NETAPI_MSG_TYPE_SND command to @p pid.
|
||||
*
|
||||
* @details This registered the nettest thread to (@p exp_type, @p exp_demux_ctx)
|
||||
* and checks if @p exp_pkts of @p exp_out were received from @p exp_senders.
|
||||
* If no message was received after @ref NG_NETTEST_TIMEOUT microseconds, while
|
||||
* there are still packets expected, the function will return NG_NETTEST_TIMED_OUT.
|
||||
* If no message was received after @ref GNRC_NETTEST_TIMEOUT microseconds, while
|
||||
* there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.
|
||||
*
|
||||
* In case of success it releases all packets send by the tested module.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command for.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SND command for.
|
||||
* @param[in] in The packet you want to send through @p pid.
|
||||
* @param[in] exp_pkts The number of packets expected to be received.
|
||||
* @param[in] exp_senders The PID the resulting packet should be coming from.
|
||||
@ -136,31 +136,31 @@ void ng_nettest_register_set(netopt_t opt, ng_nettest_opt_cb_t cb);
|
||||
* @param[in] exp_out The expected packet from @p exp_sender.
|
||||
* Must be of dimension @p exp_pkts.
|
||||
* @param[in] exp_type The expected receiver type for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SND command.
|
||||
* @param[in] exp_demux_ctx The expected receiver demux type for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SND command.
|
||||
*
|
||||
* @return @see ng_nettest_res_t
|
||||
* @return @see gnrc_nettest_res_t
|
||||
*/
|
||||
ng_nettest_res_t ng_nettest_send(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out,
|
||||
ng_nettype_t exp_type, uint32_t exp_demux_ctx);
|
||||
gnrc_nettest_res_t gnrc_nettest_send(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out,
|
||||
gnrc_nettype_t exp_type, uint32_t exp_demux_ctx);
|
||||
|
||||
/**
|
||||
* @brief Test @ref NG_NETAPI_MSG_TYPE_SND command to @p pid with the receiving
|
||||
* @brief Test @ref GNRC_NETAPI_MSG_TYPE_SND command to @p pid with the receiving
|
||||
* thread being an interface.
|
||||
*
|
||||
* @details This registered the nettest thread as an interface and checks ifx
|
||||
* @p exp_pkts of @p exp_out were received from @p exp_senders. If no message
|
||||
* was received after @ref NG_NETTEST_TIMEOUT microseconds, while there are
|
||||
* still packets expected, the function will return NG_NETTEST_TIMED_OUT.
|
||||
* was received after @ref GNRC_NETTEST_TIMEOUT microseconds, while there are
|
||||
* still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.
|
||||
*
|
||||
* In case of success it releases all packets received from the tested module.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SND command for.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SND command for.
|
||||
* @param[in] in The packet you want to send through @p pid.
|
||||
* @param[in] exp_pkts The number of packets expected to be received.
|
||||
* @param[in] exp_senders The PID the resulting packet should be coming from.
|
||||
@ -170,23 +170,23 @@ ng_nettest_res_t ng_nettest_send(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
* Must be of dimension @p exp_pkts. May be NULL if
|
||||
* @p exp_pkts == 0.
|
||||
*
|
||||
* @return @see ng_nettest_res_t
|
||||
* @return @see gnrc_nettest_res_t
|
||||
*/
|
||||
ng_nettest_res_t ng_nettest_send_iface(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out);
|
||||
gnrc_nettest_res_t gnrc_nettest_send_iface(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out);
|
||||
|
||||
/**
|
||||
* @brief Test @ref NG_NETAPI_MSG_TYPE_RCV command to @p pid.
|
||||
* @brief Test @ref GNRC_NETAPI_MSG_TYPE_RCV command to @p pid.
|
||||
*
|
||||
* @details This registered the nettest thread to (@p exp_type, @p exp_demux_ctx)
|
||||
* and checks if @p exp_pkts of @p exp_out were received from @p exp_senders.
|
||||
* If no message was received after @ref NG_NETTEST_TIMEOUT microseconds, while
|
||||
* there are still packets expected, the function will return NG_NETTEST_TIMED_OUT.
|
||||
* If no message was received after @ref GNRC_NETTEST_TIMEOUT microseconds, while
|
||||
* there are still packets expected, the function will return GNRC_NETTEST_TIMED_OUT.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_RCV command for.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_RCV command for.
|
||||
* @param[in] in The packet you want to send through @p pid.
|
||||
* @param[in] exp_pkts The number of packets expected to be received.
|
||||
* @param[in] exp_senders The PID the resulting packet should be coming from.
|
||||
@ -194,75 +194,75 @@ ng_nettest_res_t ng_nettest_send_iface(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
* @param[in] exp_out The expected packet from @p exp_sender.
|
||||
* Must be of dimension @p exp_pkts.
|
||||
* @param[in] exp_type The expected receiver type for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_RCV command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_RCV command.
|
||||
* @param[in] exp_demux_ctx The expected receiver demux type for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_RCV command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_RCV command.
|
||||
*
|
||||
* @return @see ng_nettest_res_t
|
||||
* @return @see gnrc_nettest_res_t
|
||||
*/
|
||||
ng_nettest_res_t ng_nettest_receive(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out,
|
||||
ng_nettype_t exp_type, uint32_t exp_demux_ctx);
|
||||
gnrc_nettest_res_t gnrc_nettest_receive(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out,
|
||||
gnrc_nettype_t exp_type, uint32_t exp_demux_ctx);
|
||||
|
||||
/**
|
||||
* @brief Test @ref NG_NETAPI_MSG_TYPE_GET command to @p pid.
|
||||
* @brief Test @ref GNRC_NETAPI_MSG_TYPE_GET command to @p pid.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_GET command for.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_GET command for.
|
||||
* @param[in] opt The option you want to test.
|
||||
* @param[in] context The context for the option.
|
||||
* @param[in] data The data pointer for the @ref NG_NETAPI_MSG_TYPE_GET
|
||||
* @param[in] data The data pointer for the @ref GNRC_NETAPI_MSG_TYPE_GET
|
||||
* command.
|
||||
* @param[in] data_len The maximum length for @p data.
|
||||
* @param[in] exp_data The expected value for the returned data. May be
|
||||
* NULL if @p exp_res < 0
|
||||
* @param[in] exp_res The expected return value for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_GET command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_GET command.
|
||||
*
|
||||
* @return @see ng_nettest_res_t
|
||||
* @return @see gnrc_nettest_res_t
|
||||
*/
|
||||
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
void *exp_data, int exp_res);
|
||||
gnrc_nettest_res_t gnrc_nettest_get(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
void *exp_data, int exp_res);
|
||||
|
||||
/**
|
||||
* @brief Test @ref NG_NETAPI_MSG_TYPE_SET command to @p pid.
|
||||
* @brief Test @ref GNRC_NETAPI_MSG_TYPE_SET command to @p pid.
|
||||
*
|
||||
* @param[in] pid The thread you want to test the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SET command for.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SET command for.
|
||||
* @param[in] opt The option you want to test.
|
||||
* @param[in] context The context for the option.
|
||||
* @param[in] data The data pointer for the @ref NG_NETAPI_MSG_TYPE_SET
|
||||
* @param[in] data The data pointer for the @ref GNRC_NETAPI_MSG_TYPE_SET
|
||||
* command.
|
||||
* @param[in] data_len The maximum length for @p data.
|
||||
* @param[in] exp_res The expected return value for the
|
||||
* @ref NG_NETAPI_MSG_TYPE_SET command.
|
||||
* @ref GNRC_NETAPI_MSG_TYPE_SET command.
|
||||
*
|
||||
* @return @see ng_nettest_res_t
|
||||
* @return @see gnrc_nettest_res_t
|
||||
*/
|
||||
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
int exp_res);
|
||||
gnrc_nettest_res_t gnrc_nettest_set(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
int exp_res);
|
||||
|
||||
/**
|
||||
* @brief Initializes the @ref net_ng_nettest module.
|
||||
* @brief Initializes the @ref net_gnrc_nettest module.
|
||||
*
|
||||
* @return The PID to the nettest thread, on success.
|
||||
* @return a negative errno on error.
|
||||
* @return -EOVERFLOW, if there are too many threads running already
|
||||
*/
|
||||
int ng_nettest_init(void);
|
||||
int gnrc_nettest_init(void);
|
||||
|
||||
/**
|
||||
* @brief Resets ng_nettest_opt_cbs_t list.
|
||||
* @brief Resets gnrc_nettest_opt_cbs_t list.
|
||||
*/
|
||||
void ng_nettest_reset(void);
|
||||
void gnrc_nettest_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETTEST_H_ */
|
||||
#endif /* GNRC_NETTEST_H_ */
|
||||
/** @} */
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_nettype Protocol type
|
||||
* @defgroup net_gnrc_nettype Protocol type
|
||||
* @ingroup net
|
||||
* @brief Protocol type definitions to be used with the @ref net_ng_netapi,
|
||||
* the @ref net_ng_netdev, the @ref net_ng_netreg, and
|
||||
* the @ref net_ng_pkt
|
||||
* @brief Protocol type definitions to be used with the @ref net_gnrc_netapi,
|
||||
* the @ref net_gnrc_netdev, the @ref net_gnrc_netreg, and
|
||||
* the @ref net_gnrc_pkt
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -19,8 +19,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_NETTYPE_H_
|
||||
#define NG_NETTYPE_H_
|
||||
#ifndef GNRC_NETTYPE_H_
|
||||
#define GNRC_NETTYPE_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -41,27 +41,27 @@ typedef enum {
|
||||
* @brief Not so much protocol but data type that is passed to network
|
||||
* devices using the netdev interface
|
||||
*/
|
||||
NG_NETTYPE_IOVEC = -2,
|
||||
GNRC_NETTYPE_IOVEC = -2,
|
||||
/**
|
||||
* @brief Protocol is as defined in @ref ng_netif_hdr_t. Not usable with
|
||||
* @ref net_ng_netreg
|
||||
* @brief Protocol is as defined in @ref gnrc_netif_hdr_t. Not usable with
|
||||
* @ref net_gnrc_netreg
|
||||
*/
|
||||
NG_NETTYPE_NETIF = -1,
|
||||
NG_NETTYPE_UNDEF = 0, /**< Protocol is undefined */
|
||||
GNRC_NETTYPE_NETIF = -1,
|
||||
GNRC_NETTYPE_UNDEF = 0, /**< Protocol is undefined */
|
||||
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
NG_NETTYPE_SIXLOWPAN, /**< Protocol is 6LoWPAN */
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
GNRC_NETTYPE_SIXLOWPAN, /**< Protocol is 6LoWPAN */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Network layer
|
||||
*/
|
||||
#ifdef MODULE_NG_IPV6
|
||||
NG_NETTYPE_IPV6, /**< Protocol is IPv6 */
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
GNRC_NETTYPE_IPV6, /**< Protocol is IPv6 */
|
||||
#endif
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
NG_NETTYPE_ICMPV6, /**< Protocol is ICMPv6 */
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
GNRC_NETTYPE_ICMPV6, /**< Protocol is ICMPv6 */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
@ -71,11 +71,11 @@ typedef enum {
|
||||
* @{
|
||||
* @name Transport layer
|
||||
*/
|
||||
#ifdef MODULE_NG_TCP
|
||||
NG_NETTYPE_TCP, /**< Protocol is TCP */
|
||||
#ifdef MODULE_GNRC_TCP
|
||||
GNRC_NETTYPE_TCP, /**< Protocol is TCP */
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
NG_NETTYPE_UDP, /**< Protocol is UDP */
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
GNRC_NETTYPE_UDP, /**< Protocol is UDP */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
@ -87,37 +87,37 @@ typedef enum {
|
||||
* @name Testing
|
||||
*/
|
||||
#ifdef TEST_SUITES
|
||||
NG_NETTYPE_TEST,
|
||||
GNRC_NETTYPE_TEST,
|
||||
#endif
|
||||
|
||||
NG_NETTYPE_NUMOF, /**< maximum number of available protocols */
|
||||
} ng_nettype_t;
|
||||
GNRC_NETTYPE_NUMOF, /**< maximum number of available protocols */
|
||||
} gnrc_nettype_t;
|
||||
|
||||
/**
|
||||
* @brief Translates an Ether Type number to @ref net_ng_nettype
|
||||
* @brief Translates an Ether Type number to @ref net_gnrc_nettype
|
||||
* @see <a href="http://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1">
|
||||
* IANA, ETHER TYPES
|
||||
* </a>
|
||||
*
|
||||
* @param[in] type An Ether Type number
|
||||
*
|
||||
* @return The corresponding @ref net_ng_nettype to @p type.
|
||||
* @return @ref NG_NETTYPE_UNDEF if @p type not translatable.
|
||||
* @return The corresponding @ref net_gnrc_nettype to @p type.
|
||||
* @return @ref GNRC_NETTYPE_UNDEF if @p type not translatable.
|
||||
*/
|
||||
static inline ng_nettype_t ng_nettype_from_ethertype(uint16_t type)
|
||||
static inline gnrc_nettype_t gnrc_nettype_from_ethertype(uint16_t type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef MODULE_NG_IPV6
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case ETHERTYPE_IPV6:
|
||||
return NG_NETTYPE_IPV6;
|
||||
return GNRC_NETTYPE_IPV6;
|
||||
#endif
|
||||
default:
|
||||
return NG_NETTYPE_UNDEF;
|
||||
return GNRC_NETTYPE_UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Translates @ref net_ng_nettype to an Ether Type number
|
||||
* @brief Translates @ref net_gnrc_nettype to an Ether Type number
|
||||
* @see <a href="http://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1">
|
||||
* IANA, ETHER TYPES
|
||||
* </a>
|
||||
@ -127,11 +127,11 @@ static inline ng_nettype_t ng_nettype_from_ethertype(uint16_t type)
|
||||
* @return The corresponding Ether Type number to @p type.
|
||||
* @return @ref ETHERTYPE_RESERVED if @p type not translatable.
|
||||
*/
|
||||
static inline uint16_t ng_nettype_to_ethertype(ng_nettype_t type)
|
||||
static inline uint16_t gnrc_nettype_to_ethertype(gnrc_nettype_t type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef MODULE_NG_IPV6
|
||||
case NG_NETTYPE_IPV6:
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
return ETHERTYPE_IPV6;
|
||||
#endif
|
||||
default:
|
||||
@ -140,42 +140,42 @@ static inline uint16_t ng_nettype_to_ethertype(ng_nettype_t type)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Translates a Protocol Number to @ref net_ng_nettype
|
||||
* @brief Translates a Protocol Number to @ref net_gnrc_nettype
|
||||
* @see <a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml">
|
||||
* IANA, Assigned Internet Protocol Numbers
|
||||
* </a>
|
||||
*
|
||||
* @param[in] num A Protocol Number
|
||||
*
|
||||
* @return The corresponding @ref net_ng_nettype to @p num.
|
||||
* @return @ref NG_NETTYPE_UNDEF if @p num not translatable.
|
||||
* @return The corresponding @ref net_gnrc_nettype to @p num.
|
||||
* @return @ref GNRC_NETTYPE_UNDEF if @p num not translatable.
|
||||
*/
|
||||
static inline ng_nettype_t ng_nettype_from_protnum(uint8_t num)
|
||||
static inline gnrc_nettype_t gnrc_nettype_from_protnum(uint8_t num)
|
||||
{
|
||||
switch (num) {
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
case PROTNUM_ICMPV6:
|
||||
return NG_NETTYPE_ICMPV6;
|
||||
return GNRC_NETTYPE_ICMPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_IPV6
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case PROTNUM_IPV6:
|
||||
return NG_NETTYPE_IPV6;
|
||||
return GNRC_NETTYPE_IPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_TCP
|
||||
#ifdef MODULE_GNRC_TCP
|
||||
case PROTNUM_TCP:
|
||||
return NG_NETTYPE_TCP;
|
||||
return GNRC_NETTYPE_TCP;
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
case PROTNUM_UDP:
|
||||
return NG_NETTYPE_UDP;
|
||||
return GNRC_NETTYPE_UDP;
|
||||
#endif
|
||||
default:
|
||||
return NG_NETTYPE_UNDEF;
|
||||
return GNRC_NETTYPE_UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Translates @ref net_ng_nettype to a Protocol Number
|
||||
* @brief Translates @ref net_gnrc_nettype to a Protocol Number
|
||||
* @see <a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml">
|
||||
* IANA, Assigned Internet Protocol Numbers
|
||||
* </a>
|
||||
@ -185,23 +185,23 @@ static inline ng_nettype_t ng_nettype_from_protnum(uint8_t num)
|
||||
* @return The corresponding Protocol Number to @p type.
|
||||
* @return @ref PROTNUM_RESERVED if @p type not translatable.
|
||||
*/
|
||||
static inline uint8_t ng_nettype_to_protnum(ng_nettype_t type)
|
||||
static inline uint8_t gnrc_nettype_to_protnum(gnrc_nettype_t type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
case NG_NETTYPE_ICMPV6:
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
case GNRC_NETTYPE_ICMPV6:
|
||||
return PROTNUM_ICMPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_IPV6
|
||||
case NG_NETTYPE_IPV6:
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
return PROTNUM_IPV6;
|
||||
#endif
|
||||
#ifdef MODULE_NG_TCP
|
||||
case NG_NETTYPE_TCP:
|
||||
#ifdef MODULE_GNRC_TCP
|
||||
case GNRC_NETTYPE_TCP:
|
||||
return PROTNUM_TCP;
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
case NG_NETTYPE_UDP:
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
case GNRC_NETTYPE_UDP:
|
||||
return PROTNUM_UDP;
|
||||
#endif
|
||||
default:
|
||||
@ -213,5 +213,5 @@ static inline uint8_t ng_nettype_to_protnum(ng_nettype_t type)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_NETTYPE_H_ */
|
||||
#endif /* GNRC_NETTYPE_H_ */
|
||||
/** @} */
|
@ -19,11 +19,11 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_NOMAC_H_
|
||||
#define NG_NOMAC_H_
|
||||
#ifndef GNRC_NOMAC_H_
|
||||
#define GNRC_NOMAC_H_
|
||||
|
||||
#include "kernel.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -32,8 +32,8 @@ extern "C" {
|
||||
/**
|
||||
* @brief Set the default message queue size for NOMAC layers
|
||||
*/
|
||||
#ifndef NG_NOMAC_MSG_QUEUE_SIZE
|
||||
#define NG_NOMAC_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_NOMAC_MSG_QUEUE_SIZE
|
||||
#define GNRC_NOMAC_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -52,8 +52,8 @@ extern "C" {
|
||||
* @return -EINVAL if creation of thread fails
|
||||
* @return -ENODEV if *dev* is invalid
|
||||
*/
|
||||
kernel_pid_t ng_nomac_init(char *stack, int stacksize, char priority,
|
||||
const char *name, ng_netdev_t *dev);
|
||||
kernel_pid_t gnrc_nomac_init(char *stack, int stacksize, char priority,
|
||||
const char *name, gnrc_netdev_t *dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_pkt Packet
|
||||
* @defgroup net_gnrc_pkt Packet
|
||||
* @brief Network packet abstraction types
|
||||
* @ingroup net
|
||||
* @{
|
||||
@ -19,13 +19,13 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_PKT_H_
|
||||
#define NG_PKT_H_
|
||||
#ifndef GNRC_PKT_H_
|
||||
#define GNRC_PKT_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -95,22 +95,22 @@ extern "C" {
|
||||
* | * L2 header 3
|
||||
* * L2 header 4
|
||||
*
|
||||
* @note This type has no initializer on purpose. Please use @ref net_ng_pktbuf
|
||||
* @note This type has no initializer on purpose. Please use @ref net_gnrc_pktbuf
|
||||
* as factory.
|
||||
*/
|
||||
/* packed to be aligned correctly in the static packet buffer */
|
||||
typedef struct ng_pktsnip {
|
||||
typedef struct gnrc_pktsnip {
|
||||
/**
|
||||
* @brief Counter of threads currently having control over this packet.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
unsigned int users;
|
||||
struct ng_pktsnip *next; /**< next snip in the packet */
|
||||
struct gnrc_pktsnip *next; /**< next snip in the packet */
|
||||
void *data; /**< pointer to the data of the snip */
|
||||
size_t size; /**< the length of the snip in byte */
|
||||
ng_nettype_t type; /**< protocol of the packet snip */
|
||||
} ng_pktsnip_t;
|
||||
gnrc_nettype_t type; /**< protocol of the packet snip */
|
||||
} gnrc_pktsnip_t;
|
||||
|
||||
/**
|
||||
* @brief Calculates length of a packet in byte.
|
||||
@ -119,7 +119,7 @@ typedef struct ng_pktsnip {
|
||||
*
|
||||
* @return length of the list of headers.
|
||||
*/
|
||||
static inline size_t ng_pkt_len(ng_pktsnip_t *pkt)
|
||||
static inline size_t gnrc_pkt_len(gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
@ -138,7 +138,7 @@ static inline size_t ng_pkt_len(ng_pktsnip_t *pkt)
|
||||
*
|
||||
* @return number of snips in the given packet
|
||||
*/
|
||||
static inline size_t ng_pkt_count(const ng_pktsnip_t *pkt)
|
||||
static inline size_t gnrc_pkt_count(const gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
@ -154,5 +154,5 @@ static inline size_t ng_pkt_count(const ng_pktsnip_t *pkt)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_PKT_H_ */
|
||||
#endif /* GNRC_PKT_H_ */
|
||||
/** @} */
|
@ -8,13 +8,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_pktbuf Packet buffer
|
||||
* @defgroup net_gnrc_pktbuf Packet buffer
|
||||
* @ingroup net
|
||||
* @brief A global network packet buffer.
|
||||
*
|
||||
* @note **WARNING!!** Do not store data structures that are not packed
|
||||
* (defined with `__attribute__((packed))`) or enforce alignment in
|
||||
* in any way in here if @ref NG_PKTBUF_SIZE > 0. On some RISC architectures
|
||||
* in any way in here if @ref GNRC_PKTBUF_SIZE > 0. On some RISC architectures
|
||||
* this *will* lead to alignment problems and can potentially result
|
||||
* in segmentation/hard faults and other unexpected behaviour.
|
||||
*
|
||||
@ -27,8 +27,8 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_PKTBUF_H_
|
||||
#define NG_PKTBUF_H_
|
||||
#ifndef GNRC_PKTBUF_H_
|
||||
#define GNRC_PKTBUF_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -36,8 +36,8 @@
|
||||
|
||||
#include "atomic.h"
|
||||
#include "cpu_conf.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "utlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -45,44 +45,44 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def NG_PKTBUF_SIZE
|
||||
* @def GNRC_PKTBUF_SIZE
|
||||
* @brief Maximum size of the static packet buffer.
|
||||
*
|
||||
* @details The rational here is to have at least space for 4 full-MTU IPv6
|
||||
* packages (2 incoming, 2 outgoing; 2 * 2 * 1280 B = 5 KiB) +
|
||||
* Meta-Data (roughly estimated to 1 KiB; might be smaller). If
|
||||
* @ref NG_PKTBUF_SIZE is 0 the packet buffer will use dynamic memory
|
||||
* @ref GNRC_PKTBUF_SIZE is 0 the packet buffer will use dynamic memory
|
||||
* management to allocate packets.
|
||||
*/
|
||||
#ifndef NG_PKTBUF_SIZE
|
||||
#define NG_PKTBUF_SIZE (6144)
|
||||
#endif /* NG_PKTBUF_SIZE */
|
||||
#ifndef GNRC_PKTBUF_SIZE
|
||||
#define GNRC_PKTBUF_SIZE (6144)
|
||||
#endif /* GNRC_PKTBUF_SIZE */
|
||||
|
||||
/**
|
||||
* @brief Initializes packet buffer module.
|
||||
*/
|
||||
void ng_pktbuf_init(void);
|
||||
void gnrc_pktbuf_init(void);
|
||||
|
||||
/**
|
||||
* @brief Adds a new ng_pktsnip_t and its packet to the packet buffer.
|
||||
* @brief Adds a new gnrc_pktsnip_t and its packet to the packet buffer.
|
||||
*
|
||||
* @warning **Do not** change the fields of the ng_pktsnip_t created by this
|
||||
* @warning **Do not** change the fields of the gnrc_pktsnip_t created by this
|
||||
* function externally. This will most likely create memory leaks or
|
||||
* not allowed memory access.
|
||||
*
|
||||
* @param[in] next Next ng_pktsnip_t in the packet. Leave NULL if you
|
||||
* @param[in] next Next gnrc_pktsnip_t in the packet. Leave NULL if you
|
||||
* want to create a new packet.
|
||||
* @param[in] data Data of the new ng_pktsnip_t. If @p data is NULL no data
|
||||
* @param[in] data Data of the new gnrc_pktsnip_t. If @p data is NULL no data
|
||||
* will be inserted into `result`.
|
||||
* @param[in] size Length of @p data. May not be 0.
|
||||
* @param[in] type Protocol type of the ng_pktsnip_t.
|
||||
* @param[in] type Protocol type of the gnrc_pktsnip_t.
|
||||
*
|
||||
* @return Pointer to the packet part that represents the new ng_pktsnip_t.
|
||||
* @return Pointer to the packet part that represents the new gnrc_pktsnip_t.
|
||||
* @return NULL, if no space is left in the packet buffer.
|
||||
* @return NULL, if @p size == 0.
|
||||
*/
|
||||
ng_pktsnip_t *ng_pktbuf_add(ng_pktsnip_t *next, void *data, size_t size,
|
||||
ng_nettype_t type);
|
||||
gnrc_pktsnip_t *gnrc_pktbuf_add(gnrc_pktsnip_t *next, void *data, size_t size,
|
||||
gnrc_nettype_t type);
|
||||
|
||||
/**
|
||||
* @brief Marks the first @p size bytes in a received packet with a new
|
||||
@ -110,16 +110,16 @@ ng_pktsnip_t *ng_pktbuf_add(ng_pktsnip_t *next, void *data, size_t size,
|
||||
* @return NULL, if pkt == NULL or size == 0 or size > pkt->size or pkt->data == NULL.
|
||||
* @return NULL, if no space is left in the packet buffer.
|
||||
*/
|
||||
ng_pktsnip_t *ng_pktbuf_mark(ng_pktsnip_t *pkt, size_t size, ng_nettype_t type);
|
||||
gnrc_pktsnip_t *gnrc_pktbuf_mark(gnrc_pktsnip_t *pkt, size_t size, gnrc_nettype_t type);
|
||||
|
||||
/**
|
||||
* @brief Reallocates ng_pktsnip_t::data of @p pkt in the packet buffer, without
|
||||
* @brief Reallocates gnrc_pktsnip_t::data of @p pkt in the packet buffer, without
|
||||
* changing the content.
|
||||
*
|
||||
* @pre ng_pktsnip_t::data of @p pkt is in the packet buffer.
|
||||
* @pre gnrc_pktsnip_t::data of @p pkt is in the packet buffer.
|
||||
*
|
||||
* @details If enough memory is available behind it or @p size is smaller than
|
||||
* the original size of the packet then ng_pktsnip_t::data of @p pkt will
|
||||
* the original size of the packet then gnrc_pktsnip_t::data of @p pkt will
|
||||
* not be moved. Otherwise, it will be moved. If no space is available
|
||||
* nothing happens.
|
||||
*
|
||||
@ -129,41 +129,41 @@ ng_pktsnip_t *ng_pktbuf_mark(ng_pktsnip_t *pkt, size_t size, ng_nettype_t type);
|
||||
* @return 0, on success
|
||||
* @return ENOMEM, if no space is left in the packet buffer or size was 0.
|
||||
*/
|
||||
int ng_pktbuf_realloc_data(ng_pktsnip_t *pkt, size_t size);
|
||||
int gnrc_pktbuf_realloc_data(gnrc_pktsnip_t *pkt, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Increases ng_pktsnip_t::users of @p pkt atomically.
|
||||
* @brief Increases gnrc_pktsnip_t::users of @p pkt atomically.
|
||||
*
|
||||
* @param[in] pkt A packet.
|
||||
* @param[in] num Number you want to increment ng_pktsnip_t::users of @p pkt by.
|
||||
* @param[in] num Number you want to increment gnrc_pktsnip_t::users of @p pkt by.
|
||||
*/
|
||||
void ng_pktbuf_hold(ng_pktsnip_t *pkt, unsigned int num);
|
||||
void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num);
|
||||
|
||||
/**
|
||||
* @brief Decreases ng_pktsnip_t::users of @p pkt atomically and removes it if it
|
||||
* @brief Decreases gnrc_pktsnip_t::users of @p pkt atomically and removes it if it
|
||||
* reaches 0.
|
||||
*
|
||||
* @pre All snips of @p pkt must be in the packet buffer.
|
||||
*
|
||||
* @param[in] pkt A packet.
|
||||
*/
|
||||
void ng_pktbuf_release(ng_pktsnip_t *pkt);
|
||||
void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Must be called once before there is a write operation in a thread.
|
||||
*
|
||||
* @details This function duplicates a packet in the packet buffer if
|
||||
* ng_pktsnip_t::users of @p pkt > 1.
|
||||
* gnrc_pktsnip_t::users of @p pkt > 1.
|
||||
*
|
||||
* @note Do *not* call this function in a thread twice on the same packet.
|
||||
*
|
||||
* @param[in] pkt The packet you want to write into.
|
||||
*
|
||||
* @return The (new) pointer to the pkt.
|
||||
* @return NULL, if ng_pktsnip_t::users of @p pkt > 1 and if there is not
|
||||
* @return NULL, if gnrc_pktsnip_t::users of @p pkt > 1 and if there is not
|
||||
* enough space in the packet buffer.
|
||||
*/
|
||||
ng_pktsnip_t *ng_pktbuf_start_write(ng_pktsnip_t *pkt);
|
||||
gnrc_pktsnip_t *gnrc_pktbuf_start_write(gnrc_pktsnip_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Create a IOVEC representation of the packet pointed to by *pkt*
|
||||
@ -178,7 +178,7 @@ ng_pktsnip_t *ng_pktbuf_start_write(ng_pktsnip_t *pkt);
|
||||
* @return Pointer to the 'IOVEC packet snip'
|
||||
* @return NULL, if packet is empty of the packet buffer is full
|
||||
*/
|
||||
ng_pktsnip_t *ng_pktbuf_get_iovec(ng_pktsnip_t *pkt, size_t *len);
|
||||
gnrc_pktsnip_t *gnrc_pktbuf_get_iovec(gnrc_pktsnip_t *pkt, size_t *len);
|
||||
|
||||
/**
|
||||
* @brief Deletes a snip from a packet and the packet buffer.
|
||||
@ -188,12 +188,12 @@ ng_pktsnip_t *ng_pktbuf_get_iovec(ng_pktsnip_t *pkt, size_t *len);
|
||||
*
|
||||
* @return The new reference to @p pkt.
|
||||
*/
|
||||
static inline ng_pktsnip_t *ng_pktbuf_remove_snip(ng_pktsnip_t *pkt,
|
||||
ng_pktsnip_t *snip)
|
||||
static inline gnrc_pktsnip_t *gnrc_pktbuf_remove_snip(gnrc_pktsnip_t *pkt,
|
||||
gnrc_pktsnip_t *snip)
|
||||
{
|
||||
LL_DELETE(pkt, snip);
|
||||
snip->next = NULL;
|
||||
ng_pktbuf_release(snip);
|
||||
gnrc_pktbuf_release(snip);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
@ -206,7 +206,7 @@ static inline ng_pktsnip_t *ng_pktbuf_remove_snip(ng_pktsnip_t *pkt,
|
||||
*
|
||||
* @details Statistics include maximum number of reserved bytes.
|
||||
*/
|
||||
void ng_pktbuf_stats(void);
|
||||
void gnrc_pktbuf_stats(void);
|
||||
#endif
|
||||
|
||||
/* for testing */
|
||||
@ -217,7 +217,7 @@ void ng_pktbuf_stats(void);
|
||||
* @return true, if packet buffer is empty
|
||||
* @return false, if packet buffer is not empty
|
||||
*/
|
||||
bool ng_pktbuf_is_empty(void);
|
||||
bool gnrc_pktbuf_is_empty(void);
|
||||
|
||||
/**
|
||||
* @brief Checks if the implementation's internal invariants still uphold
|
||||
@ -225,12 +225,12 @@ bool ng_pktbuf_is_empty(void);
|
||||
* @return true, the packet buffer is sane.
|
||||
* @return false, the packet buffer is insane.
|
||||
*/
|
||||
bool ng_pktbuf_is_sane(void);
|
||||
bool gnrc_pktbuf_is_sane(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_PKTBUF_H_ */
|
||||
#endif /* GNRC_PKTBUF_H_ */
|
||||
/** @} */
|
@ -19,8 +19,8 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_PKTDUMP_H_
|
||||
#define NG_PKTDUMP_H_
|
||||
#ifndef GNRC_PKTDUMP_H_
|
||||
#define GNRC_PKTDUMP_H_
|
||||
|
||||
#include "kernel.h"
|
||||
|
||||
@ -31,22 +31,22 @@ extern "C" {
|
||||
/**
|
||||
* @brief Message queue size for the pktdump thread
|
||||
*/
|
||||
#ifndef NG_PKTDUMP_MSG_QUEUE_SIZE
|
||||
#define NG_PKTDUMP_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_PKTDUMP_MSG_QUEUE_SIZE
|
||||
#define GNRC_PKTDUMP_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Priority of the pktdump thread
|
||||
*/
|
||||
#ifndef NG_PKTDUMP_PRIO
|
||||
#define NG_PKTDUMP_PRIO (THREAD_PRIORITY_MAIN - 1)
|
||||
#ifndef GNRC_PKTDUMP_PRIO
|
||||
#define GNRC_PKTDUMP_PRIO (THREAD_PRIORITY_MAIN - 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Stack size used for the pktdump thread
|
||||
*/
|
||||
#ifndef NG_PKTDUMP_STACKSIZE
|
||||
#define NG_PKTDUMP_STACKSIZE (THREAD_STACKSIZE_MAIN)
|
||||
#ifndef GNRC_PKTDUMP_STACKSIZE
|
||||
#define GNRC_PKTDUMP_STACKSIZE (THREAD_STACKSIZE_MAIN)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ extern "C" {
|
||||
* @return PID of the pktdump thread
|
||||
* @return @ref KERNEL_PID_UNDEF if not initialized
|
||||
*/
|
||||
kernel_pid_t ng_pktdump_getpid(void);
|
||||
kernel_pid_t gnrc_pktdump_getpid(void);
|
||||
|
||||
/**
|
||||
* @brief Start the packet dump thread and listening for incoming packets
|
||||
@ -63,11 +63,11 @@ kernel_pid_t ng_pktdump_getpid(void);
|
||||
* @return PID of the pktdump thread
|
||||
* @return negative value on error
|
||||
*/
|
||||
kernel_pid_t ng_pktdump_init(void);
|
||||
kernel_pid_t gnrc_pktdump_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_PKTDUMP_H_ */
|
||||
#endif /* GNRC_PKTDUMP_H_ */
|
||||
/** @} */
|
@ -7,24 +7,24 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_pktqueue Packet Queue
|
||||
* @defgroup net_gnrc_pktqueue Packet Queue
|
||||
* @brief Packet wrapper for the Priority Queue
|
||||
* @ingroup net
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief ng_pktsnip_t-centric wrapper for @ref priority_queue_t
|
||||
* @brief gnrc_pktsnip_t-centric wrapper for @ref priority_queue_t
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_PKTQUEUE_H_
|
||||
#define NG_PKTQUEUE_H_
|
||||
#ifndef GNRC_PKTQUEUE_H_
|
||||
#define GNRC_PKTQUEUE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "utlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -36,10 +36,10 @@ extern "C" {
|
||||
*
|
||||
* @extends priority_queue_node_t
|
||||
*/
|
||||
typedef struct ng_pktqueue {
|
||||
struct ng_pktqueue *next; /**< next node in queue */
|
||||
ng_pktsnip_t *pkt; /**< pointer to the packet */
|
||||
} ng_pktqueue_t;
|
||||
typedef struct gnrc_pktqueue {
|
||||
struct gnrc_pktqueue *next; /**< next node in queue */
|
||||
gnrc_pktsnip_t *pkt; /**< pointer to the packet */
|
||||
} gnrc_pktqueue_t;
|
||||
|
||||
/**
|
||||
* @brief add @p node into @p queue based on its priority
|
||||
@ -50,7 +50,7 @@ typedef struct ng_pktqueue {
|
||||
* @param[in,out] queue the queue, may not be NULL
|
||||
* @param[in] node the node to add.
|
||||
*/
|
||||
static inline void ng_pktqueue_add(ng_pktqueue_t **queue, ng_pktqueue_t *node)
|
||||
static inline void gnrc_pktqueue_add(gnrc_pktqueue_t **queue, gnrc_pktqueue_t *node)
|
||||
{
|
||||
LL_APPEND(*queue, node);
|
||||
}
|
||||
@ -63,7 +63,7 @@ static inline void ng_pktqueue_add(ng_pktqueue_t **queue, ng_pktqueue_t *node)
|
||||
*
|
||||
* @return @p node.
|
||||
*/
|
||||
static inline ng_pktqueue_t *ng_pktqueue_remove(ng_pktqueue_t **queue, ng_pktqueue_t *node)
|
||||
static inline gnrc_pktqueue_t *gnrc_pktqueue_remove(gnrc_pktqueue_t **queue, gnrc_pktqueue_t *node)
|
||||
{
|
||||
if (node) {
|
||||
LL_DELETE(*queue, node);
|
||||
@ -80,16 +80,16 @@ static inline ng_pktqueue_t *ng_pktqueue_remove(ng_pktqueue_t **queue, ng_pktque
|
||||
*
|
||||
* @return the old head
|
||||
*/
|
||||
static inline ng_pktqueue_t *ng_pktqueue_remove_head(ng_pktqueue_t **queue)
|
||||
static inline gnrc_pktqueue_t *gnrc_pktqueue_remove_head(gnrc_pktqueue_t **queue)
|
||||
{
|
||||
return ng_pktqueue_remove(queue, *queue);
|
||||
return gnrc_pktqueue_remove(queue, *queue);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_PKTQUEUE_H_ */
|
||||
#endif /* GNRC_PKTQUEUE_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_rpl RPL
|
||||
* @defgroup net_gnrc_rpl New RPL
|
||||
* @ingroup net
|
||||
* @{
|
||||
*
|
||||
@ -25,16 +25,16 @@
|
||||
* @author Cenk Gündoğan <cnkgndgn@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef NG_RPL_H_
|
||||
#define NG_RPL_H_
|
||||
#ifndef GNRC_RPL_H_
|
||||
#define GNRC_RPL_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_rpl/structs.h"
|
||||
#include "net/ng_rpl/dodag.h"
|
||||
#include "net/ng_rpl/of_manager.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/rpl/structs.h"
|
||||
#include "net/gnrc/rpl/dodag.h"
|
||||
#include "net/gnrc/rpl/of_manager.h"
|
||||
#include "net/fib.h"
|
||||
#include "vtimer.h"
|
||||
#include "trickle.h"
|
||||
@ -46,22 +46,22 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default stack size to use for the IPv6 thread
|
||||
*/
|
||||
#ifndef NG_RPL_STACK_SIZE
|
||||
#define NG_RPL_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_RPL_STACK_SIZE
|
||||
#define GNRC_RPL_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default priority for the RPL thread
|
||||
*/
|
||||
#ifndef NG_RPL_PRIO
|
||||
#define NG_RPL_PRIO (THREAD_PRIORITY_MAIN - 4)
|
||||
#ifndef GNRC_RPL_PRIO
|
||||
#define GNRC_RPL_PRIO (THREAD_PRIORITY_MAIN - 4)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default message queue size to use for the RPL thread.
|
||||
*/
|
||||
#ifndef NG_RPL_MSG_QUEUE_SIZE
|
||||
#define NG_RPL_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_RPL_MSG_QUEUE_SIZE
|
||||
#define GNRC_RPL_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -72,32 +72,32 @@ extern "C" {
|
||||
* RFC 6550, section 6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_RPL_NODES {{ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a }}
|
||||
#define GNRC_RPL_ALL_NODES_ADDR {{ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a }}
|
||||
|
||||
/**
|
||||
* @brief Message type for lifetime updates
|
||||
*/
|
||||
#define NG_RPL_MSG_TYPE_LIFETIME_UPDATE (0x0900)
|
||||
#define GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE (0x0900)
|
||||
|
||||
/**
|
||||
* @brief Message type for trickle intervals
|
||||
*/
|
||||
#define NG_RPL_MSG_TYPE_TRICKLE_INTERVAL (0x0901)
|
||||
#define GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL (0x0901)
|
||||
|
||||
/**
|
||||
* @brief Message type for trickle callbacks
|
||||
*/
|
||||
#define NG_RPL_MSG_TYPE_TRICKLE_CALLBACK (0x0902)
|
||||
#define GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK (0x0902)
|
||||
|
||||
/**
|
||||
* @brief Message type for handling DAO sending
|
||||
*/
|
||||
#define NG_RPL_MSG_TYPE_DAO_HANDLE (0x0903)
|
||||
#define GNRC_RPL_MSG_TYPE_DAO_HANDLE (0x0903)
|
||||
|
||||
/**
|
||||
* @brief Message type for handling DODAG cleanup
|
||||
*/
|
||||
#define NG_RPL_MSG_TYPE_CLEANUP_HANDLE (0x0904)
|
||||
#define GNRC_RPL_MSG_TYPE_CLEANUP_HANDLE (0x0904)
|
||||
|
||||
/**
|
||||
* @brief Infinite rank
|
||||
@ -105,7 +105,7 @@ extern "C" {
|
||||
* RFC 6550, section 17
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_INFINITE_RANK (0xFFFF)
|
||||
#define GNRC_RPL_INFINITE_RANK (0xFFFF)
|
||||
|
||||
/**
|
||||
* @brief Default minimum hop rank increase
|
||||
@ -113,34 +113,34 @@ extern "C" {
|
||||
* RFC 6550, section 17
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_MIN_HOP_RANK_INCREASE (256)
|
||||
#define GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE (256)
|
||||
|
||||
/**
|
||||
* @brief Maximum rank increase
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_MAX_RANK_INCREASE (0)
|
||||
#define GNRC_RPL_DEFAULT_MAX_RANK_INCREASE (0)
|
||||
|
||||
/**
|
||||
* @brief Number of implemented Objective Functions
|
||||
*/
|
||||
#define NG_RPL_IMPLEMENTED_OFS_NUMOF (1)
|
||||
#define GNRC_RPL_IMPLEMENTED_OFS_NUMOF (1)
|
||||
|
||||
/**
|
||||
* @brief Default Objective Code Point (OF0)
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_OCP (0)
|
||||
#define GNRC_RPL_DEFAULT_OCP (0)
|
||||
|
||||
/**
|
||||
* @name RPL Mode of Operations
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_MOP_NO_DOWNWARD_ROUTES (0x00)
|
||||
#define NG_RPL_MOP_NON_STORING_MODE (0x01)
|
||||
#define NG_RPL_MOP_STORING_MODE_NO_MC (0x02)
|
||||
#define NG_RPL_MOP_STORING_MODE_MC (0x03)
|
||||
#define GNRC_RPL_MOP_NO_DOWNWARD_ROUTES (0x00)
|
||||
#define GNRC_RPL_MOP_NON_STORING_MODE (0x01)
|
||||
#define GNRC_RPL_MOP_STORING_MODE_NO_MC (0x02)
|
||||
#define GNRC_RPL_MOP_STORING_MODE_MC (0x03)
|
||||
/** default MOP set on compile time */
|
||||
#ifndef NG_RPL_DEFAULT_MOP
|
||||
# define NG_RPL_DEFAULT_MOP NG_RPL_MOP_STORING_MODE_NO_MC
|
||||
#ifndef GNRC_RPL_DEFAULT_MOP
|
||||
# define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_STORING_MODE_NO_MC
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
@ -151,34 +151,34 @@ extern "C" {
|
||||
* </a>
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_COUNTER_MAX (255)
|
||||
#define NG_RPL_COUNTER_LOWER_REGION (127)
|
||||
#define NG_RPL_COUNTER_SEQ_WINDOW (16)
|
||||
#define NG_RPL_COUNTER_INIT (NG_RPL_COUNTER_MAX - NG_RPL_COUNTER_SEQ_WINDOW + 1)
|
||||
#define GNRC_RPL_COUNTER_MAX (255)
|
||||
#define GNRC_RPL_COUNTER_LOWER_REGION (127)
|
||||
#define GNRC_RPL_COUNTER_SEQ_WINDOW (16)
|
||||
#define GNRC_RPL_COUNTER_INIT (GNRC_RPL_COUNTER_MAX - GNRC_RPL_COUNTER_SEQ_WINDOW + 1)
|
||||
|
||||
static inline uint8_t NG_RPL_COUNTER_INCREMENT(uint8_t counter)
|
||||
static inline uint8_t GNRC_RPL_COUNTER_INCREMENT(uint8_t counter)
|
||||
{
|
||||
return ((counter > NG_RPL_COUNTER_LOWER_REGION) ?
|
||||
((counter == NG_RPL_COUNTER_MAX) ? counter = 0 : ++counter) :
|
||||
((counter == NG_RPL_COUNTER_LOWER_REGION) ? counter = 0 : ++counter));
|
||||
return ((counter > GNRC_RPL_COUNTER_LOWER_REGION) ?
|
||||
((counter == GNRC_RPL_COUNTER_MAX) ? counter = 0 : ++counter) :
|
||||
((counter == GNRC_RPL_COUNTER_LOWER_REGION) ? counter = 0 : ++counter));
|
||||
}
|
||||
|
||||
static inline bool NG_RPL_COUNTER_IS_INIT(uint8_t counter)
|
||||
static inline bool GNRC_RPL_COUNTER_IS_INIT(uint8_t counter)
|
||||
{
|
||||
return (counter > NG_RPL_COUNTER_LOWER_REGION);
|
||||
return (counter > GNRC_RPL_COUNTER_LOWER_REGION);
|
||||
}
|
||||
|
||||
static inline bool NG_RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A, uint8_t B)
|
||||
static inline bool GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A, uint8_t B)
|
||||
{
|
||||
return (((A < B) && (NG_RPL_COUNTER_LOWER_REGION + 1 - B + A < NG_RPL_COUNTER_SEQ_WINDOW))
|
||||
|| ((A > B) && (A - B < NG_RPL_COUNTER_SEQ_WINDOW)));
|
||||
return (((A < B) && (GNRC_RPL_COUNTER_LOWER_REGION + 1 - B + A < GNRC_RPL_COUNTER_SEQ_WINDOW))
|
||||
|| ((A > B) && (A - B < GNRC_RPL_COUNTER_SEQ_WINDOW)));
|
||||
}
|
||||
|
||||
static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
{
|
||||
return ((A > NG_RPL_COUNTER_LOWER_REGION) ? ((B > NG_RPL_COUNTER_LOWER_REGION) ?
|
||||
NG_RPL_COUNTER_GREATER_THAN_LOCAL(A, B) : 0) :
|
||||
((B > NG_RPL_COUNTER_LOWER_REGION) ? 1 : NG_RPL_COUNTER_GREATER_THAN_LOCAL(A, B)));
|
||||
return ((A > GNRC_RPL_COUNTER_LOWER_REGION) ? ((B > GNRC_RPL_COUNTER_LOWER_REGION) ?
|
||||
GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(A, B) : 0) :
|
||||
((B > GNRC_RPL_COUNTER_LOWER_REGION) ? 1 : GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(A, B)));
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@ -189,9 +189,9 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* </a>
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS (20)
|
||||
#define NG_RPL_DEFAULT_DIO_INTERVAL_MIN (3)
|
||||
#define NG_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT (10)
|
||||
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS (20)
|
||||
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN (3)
|
||||
#define GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT (10)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@ -199,24 +199,24 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* default lifetime will be multiplied by the lifetime unit to obtain the resulting lifetime
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_LIFETIME (60)
|
||||
#define NG_RPL_LIFETIME_UNIT (2)
|
||||
#define GNRC_RPL_DEFAULT_LIFETIME (60)
|
||||
#define GNRC_RPL_LIFETIME_UNIT (2)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Interval of the void _update_lifetime() function
|
||||
*/
|
||||
#define NG_RPL_LIFETIME_STEP (2)
|
||||
#define GNRC_RPL_LIFETIME_STEP (2)
|
||||
|
||||
/**
|
||||
* @brief Default prefix length for the DODAG id
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_PREFIX_LEN (64)
|
||||
#define GNRC_RPL_DEFAULT_PREFIX_LEN (64)
|
||||
|
||||
/**
|
||||
* @brief Default prefix valid and preferred time for the DODAG id
|
||||
*/
|
||||
#define NG_RPL_DEFAULT_PREFIX_LIFETIME (0xFFFFFFFF)
|
||||
#define GNRC_RPL_DEFAULT_PREFIX_LIFETIME (0xFFFFFFFF)
|
||||
|
||||
/**
|
||||
* @brief A DODAG can be grounded or floating
|
||||
@ -224,30 +224,30 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* Grounded and Floating DODAGs
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_GROUNDED (1)
|
||||
#define GNRC_RPL_GROUNDED (1)
|
||||
|
||||
/**
|
||||
* @name Parameters used for DAO handling
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_DAO_SEND_RETRIES (4)
|
||||
#define NG_RPL_DEFAULT_WAIT_FOR_DAO_ACK (3)
|
||||
#define NG_RPL_REGULAR_DAO_INTERVAL (60)
|
||||
#define NG_RPL_DEFAULT_DAO_DELAY (5)
|
||||
#define GNRC_RPL_DAO_SEND_RETRIES (4)
|
||||
#define GNRC_RPL_DEFAULT_WAIT_FOR_DAO_ACK (3)
|
||||
#define GNRC_RPL_REGULAR_DAO_INTERVAL (60)
|
||||
#define GNRC_RPL_DEFAULT_DAO_DELAY (5)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Cleanup timeout in seconds
|
||||
*/
|
||||
#define NG_RPL_CLEANUP_TIME (30)
|
||||
#define GNRC_RPL_CLEANUP_TIME (30)
|
||||
|
||||
/**
|
||||
* @name Node Status
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_NORMAL_NODE (0)
|
||||
#define NG_RPL_ROOT_NODE (1)
|
||||
#define NG_RPL_LEAF_NODE (2)
|
||||
#define GNRC_RPL_NORMAL_NODE (0)
|
||||
#define GNRC_RPL_ROOT_NODE (1)
|
||||
#define GNRC_RPL_LEAF_NODE (2)
|
||||
/** @} */
|
||||
|
||||
|
||||
@ -258,22 +258,22 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* </a>
|
||||
* @{
|
||||
*/
|
||||
#define NG_RPL_OPT_PAD1 (0)
|
||||
#define NG_RPL_OPT_PADN (1)
|
||||
#define NG_RPL_OPT_DAG_METRIC_CONTAINER (2)
|
||||
#define NG_RPL_OPT_ROUTE_INFO (3)
|
||||
#define NG_RPL_OPT_DODAG_CONF (4)
|
||||
#define NG_RPL_OPT_TARGET (5)
|
||||
#define NG_RPL_OPT_TRANSIT (6)
|
||||
#define NG_RPL_OPT_SOLICITED_INFO (7)
|
||||
#define NG_RPL_OPT_PREFIX_INFO (8)
|
||||
#define NG_RPL_OPT_TARGET_DESC (9)
|
||||
#define GNRC_RPL_OPT_PAD1 (0)
|
||||
#define GNRC_RPL_OPT_PADN (1)
|
||||
#define GNRC_RPL_OPT_DAG_METRIC_CONTAINER (2)
|
||||
#define GNRC_RPL_OPT_ROUTE_INFO (3)
|
||||
#define GNRC_RPL_OPT_DODAG_CONF (4)
|
||||
#define GNRC_RPL_OPT_TARGET (5)
|
||||
#define GNRC_RPL_OPT_TRANSIT (6)
|
||||
#define GNRC_RPL_OPT_SOLICITED_INFO (7)
|
||||
#define GNRC_RPL_OPT_PREFIX_INFO (8)
|
||||
#define GNRC_RPL_OPT_TARGET_DESC (9)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Rank of the root node
|
||||
*/
|
||||
#define NG_RPL_ROOT_RANK (256)
|
||||
#define GNRC_RPL_ROOT_RANK (256)
|
||||
|
||||
/**
|
||||
* @brief DIS ICMPv6 code
|
||||
@ -281,7 +281,7 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* RFC 6550, section 6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_ICMPV6_CODE_DIS (0x00)
|
||||
#define GNRC_RPL_ICMPV6_CODE_DIS (0x00)
|
||||
|
||||
/**
|
||||
* @brief DIO ICMPv6 code
|
||||
@ -289,7 +289,7 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* RFC 6550, section 6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_ICMPV6_CODE_DIO (0x01)
|
||||
#define GNRC_RPL_ICMPV6_CODE_DIO (0x01)
|
||||
|
||||
/**
|
||||
* @brief DAO ICMPv6 code
|
||||
@ -297,7 +297,7 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* RFC 6550, section 6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_ICMPV6_CODE_DAO (0x02)
|
||||
#define GNRC_RPL_ICMPV6_CODE_DAO (0x02)
|
||||
|
||||
/**
|
||||
* @brief DAO ACK ICMPv6 code
|
||||
@ -305,17 +305,17 @@ static inline bool NG_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
||||
* RFC 6550, section 6
|
||||
* </a>
|
||||
*/
|
||||
#define NG_RPL_ICMPV6_CODE_DAO_ACK (0x03)
|
||||
#define GNRC_RPL_ICMPV6_CODE_DAO_ACK (0x03)
|
||||
|
||||
/**
|
||||
* @brief Update interval of the lifetime update function
|
||||
*/
|
||||
#define NG_RPL_LIFETIME_UPDATE_STEP (2)
|
||||
#define GNRC_RPL_LIFETIME_UPDATE_STEP (2)
|
||||
|
||||
/**
|
||||
* @brief PID of the RPL thread.
|
||||
*/
|
||||
extern kernel_pid_t ng_rpl_pid;
|
||||
extern kernel_pid_t gnrc_rpl_pid;
|
||||
|
||||
/**
|
||||
* @brief Initialization of the RPL thread.
|
||||
@ -325,7 +325,7 @@ extern kernel_pid_t ng_rpl_pid;
|
||||
* @return The PID of the RPL thread, on success.
|
||||
* @return a negative errno on error.
|
||||
*/
|
||||
kernel_pid_t ng_rpl_init(kernel_pid_t if_pid);
|
||||
kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid);
|
||||
|
||||
/**
|
||||
* @brief Initialization of a RPL DODAG as root node. Creates a new instance if necessary.
|
||||
@ -336,7 +336,7 @@ kernel_pid_t ng_rpl_init(kernel_pid_t if_pid);
|
||||
* @return Pointer to the new DODAG, on success.
|
||||
* @return NULL, otherwise.
|
||||
*/
|
||||
ng_rpl_dodag_t *ng_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id);
|
||||
gnrc_rpl_dodag_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id);
|
||||
|
||||
/**
|
||||
* @brief Send a DIO of the @p dodag to the @p destination.
|
||||
@ -344,7 +344,7 @@ ng_rpl_dodag_t *ng_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id);
|
||||
* @param[in] dodag Pointer to the DODAG.
|
||||
* @param[in] destination IPv6 addres of the destination.
|
||||
*/
|
||||
void ng_rpl_send_DIO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
void gnrc_rpl_send_DIO(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
|
||||
/**
|
||||
* @brief Send a DIS of the @p dodag to the @p destination.
|
||||
@ -352,7 +352,7 @@ void ng_rpl_send_DIO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
* @param[in] dodag Pointer to the DODAG, optional.
|
||||
* @param[in] destination IPv6 addres of the destination.
|
||||
*/
|
||||
void ng_rpl_send_DIS(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
void gnrc_rpl_send_DIS(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
|
||||
/**
|
||||
* @brief Send a DAO of the @p dodag to the @p destination.
|
||||
@ -361,7 +361,7 @@ void ng_rpl_send_DIS(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination);
|
||||
* @param[in] destination IPv6 addres of the destination.
|
||||
* @param[in] lifetime Lifetime of the route to announce.
|
||||
*/
|
||||
void ng_rpl_send_DAO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t lifetime);
|
||||
void gnrc_rpl_send_DAO(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t lifetime);
|
||||
|
||||
/**
|
||||
* @brief Send a DAO-ACK of the @p dodag to the @p destination.
|
||||
@ -370,7 +370,7 @@ void ng_rpl_send_DAO(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t li
|
||||
* @param[in] destination IPv6 addres of the destination.
|
||||
* @param[in] seq Sequence number to be acknowledged.
|
||||
*/
|
||||
void ng_rpl_send_DAO_ACK(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t seq);
|
||||
void gnrc_rpl_send_DAO_ACK(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_t seq);
|
||||
|
||||
/**
|
||||
* @brief Parse a DIS.
|
||||
@ -380,7 +380,7 @@ void ng_rpl_send_DAO_ACK(ng_rpl_dodag_t *dodag, ipv6_addr_t *destination, uint8_
|
||||
* @param[in] dst Pointer to the destination address of the IPv6 packet.
|
||||
* @param[in] len Length of the IPv6 packet.
|
||||
*/
|
||||
void ng_rpl_recv_DIS(ng_rpl_dis_t *dis, ipv6_addr_t *src, ipv6_addr_t *dst, uint16_t len);
|
||||
void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, ipv6_addr_t *src, ipv6_addr_t *dst, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Parse a DIO.
|
||||
@ -389,7 +389,7 @@ void ng_rpl_recv_DIS(ng_rpl_dis_t *dis, ipv6_addr_t *src, ipv6_addr_t *dst, uint
|
||||
* @param[in] src Pointer to the source address of the IPv6 packet.
|
||||
* @param[in] len Length of the IPv6 packet.
|
||||
*/
|
||||
void ng_rpl_recv_DIO(ng_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len);
|
||||
void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Parse a DAO.
|
||||
@ -398,33 +398,31 @@ void ng_rpl_recv_DIO(ng_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len);
|
||||
* @param[in] src Pointer to the source address of the IPv6 packet.
|
||||
* @param[in] len Length of the IPv6 packet.
|
||||
*/
|
||||
void ng_rpl_recv_DAO(ng_rpl_dao_t *dao, ipv6_addr_t *src, uint16_t len);
|
||||
void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, ipv6_addr_t *src, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Parse a DAO-ACK.
|
||||
*
|
||||
* @param[in] dao_ack Pointer to the DAO-ACK message.
|
||||
*/
|
||||
void ng_rpl_recv_DAO_ACK(ng_rpl_dao_ack_t *dao_ack);
|
||||
void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack);
|
||||
|
||||
/**
|
||||
* @brief Delay the DAO sending interval
|
||||
*
|
||||
* @param[in] dodag The DODAG of the DAO
|
||||
*/
|
||||
void ng_rpl_delay_dao(ng_rpl_dodag_t *dodag);
|
||||
void gnrc_rpl_delay_dao(gnrc_rpl_dodag_t *dodag);
|
||||
|
||||
/**
|
||||
* @brief Long delay the DAO sending interval
|
||||
*
|
||||
* @param[in] dodag The DODAG of the DAO
|
||||
*/
|
||||
void ng_rpl_long_delay_dao(ng_rpl_dodag_t *dodag);
|
||||
void gnrc_rpl_long_delay_dao(gnrc_rpl_dodag_t *dodag);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_RPL_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* GNRC_RPL_H_ */
|
||||
/** @} */
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_ng_rpl
|
||||
* @ingroup net_gnrc_rpl
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -20,53 +20,53 @@
|
||||
* @author Cenk Gündoğan <cnkgndgn@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef NG_RPL_DODAG_H_
|
||||
#define NG_RPL_DODAG_H_
|
||||
#ifndef GNRC_RPL_DODAG_H_
|
||||
#define GNRC_RPL_DODAG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "trickle.h"
|
||||
#include "net/ng_rpl.h"
|
||||
#include "net/ng_rpl/structs.h"
|
||||
#include "net/gnrc/rpl.h"
|
||||
#include "net/gnrc/rpl/structs.h"
|
||||
|
||||
/**
|
||||
* @brief Number of RPL instances
|
||||
*/
|
||||
#ifndef NG_RPL_INSTANCES_NUMOF
|
||||
#define NG_RPL_INSTANCES_NUMOF (2)
|
||||
#ifndef GNRC_RPL_INSTANCES_NUMOF
|
||||
#define GNRC_RPL_INSTANCES_NUMOF (2)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of RPL dodags
|
||||
*/
|
||||
#ifndef NG_RPL_DODAGS_NUMOF
|
||||
#define NG_RPL_DODAGS_NUMOF (4)
|
||||
#ifndef GNRC_RPL_DODAGS_NUMOF
|
||||
#define GNRC_RPL_DODAGS_NUMOF (4)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of RPL parents
|
||||
*/
|
||||
#ifndef NG_RPL_PARENTS_NUMOF
|
||||
#define NG_RPL_PARENTS_NUMOF (6)
|
||||
#ifndef GNRC_RPL_PARENTS_NUMOF
|
||||
#define GNRC_RPL_PARENTS_NUMOF (6)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief RPL instance table
|
||||
*/
|
||||
extern ng_rpl_instance_t ng_rpl_instances[NG_RPL_INSTANCES_NUMOF];
|
||||
extern gnrc_rpl_instance_t gnrc_rpl_instances[GNRC_RPL_INSTANCES_NUMOF];
|
||||
|
||||
/**
|
||||
* @brief RPL DODAG table
|
||||
*/
|
||||
extern ng_rpl_dodag_t ng_rpl_dodags[NG_RPL_DODAGS_NUMOF];
|
||||
extern gnrc_rpl_dodag_t gnrc_rpl_dodags[GNRC_RPL_DODAGS_NUMOF];
|
||||
|
||||
/**
|
||||
* @brief RPL parent table
|
||||
*/
|
||||
extern ng_rpl_parent_t ng_rpl_parents[NG_RPL_PARENTS_NUMOF];
|
||||
extern gnrc_rpl_parent_t gnrc_rpl_parents[GNRC_RPL_PARENTS_NUMOF];
|
||||
|
||||
/**
|
||||
* @brief Add a new RPL instance with the id @p instance_id.
|
||||
@ -77,7 +77,7 @@ extern ng_rpl_parent_t ng_rpl_parents[NG_RPL_PARENTS_NUMOF];
|
||||
* @return true, if instance could be created.
|
||||
* @return false, if instance could not be created or exists already.
|
||||
*/
|
||||
bool ng_rpl_instance_add(uint8_t instance_id, ng_rpl_instance_t **inst);
|
||||
bool gnrc_rpl_instance_add(uint8_t instance_id, gnrc_rpl_instance_t **inst);
|
||||
|
||||
/**
|
||||
* @brief Remove a RPL instance with the id @p instance_id.
|
||||
@ -87,7 +87,7 @@ bool ng_rpl_instance_add(uint8_t instance_id, ng_rpl_instance_t **inst);
|
||||
* @return true, on success.
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
bool ng_rpl_instance_remove_by_id(uint8_t instance_id);
|
||||
bool gnrc_rpl_instance_remove_by_id(uint8_t instance_id);
|
||||
|
||||
/**
|
||||
* @brief Remove a RPL instance with the pointer @p inst.
|
||||
@ -97,7 +97,7 @@ bool ng_rpl_instance_remove_by_id(uint8_t instance_id);
|
||||
* @return true, on success.
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
bool ng_rpl_instance_remove(ng_rpl_instance_t *inst);
|
||||
bool gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst);
|
||||
|
||||
/**
|
||||
* @brief Get the RPL instance with the id @p instance_id.
|
||||
@ -107,7 +107,7 @@ bool ng_rpl_instance_remove(ng_rpl_instance_t *inst);
|
||||
* @return Pointer to the RPL instance, on success.
|
||||
* @return NULL, otherwise.
|
||||
*/
|
||||
ng_rpl_instance_t *ng_rpl_instance_get(uint8_t instance_id);
|
||||
gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id);
|
||||
|
||||
/**
|
||||
* @brief Add a new RPL DODAG with the id @p dodag_id to the instance @p instance.
|
||||
@ -119,7 +119,8 @@ ng_rpl_instance_t *ng_rpl_instance_get(uint8_t instance_id);
|
||||
* @return true, if DODAG could be created.
|
||||
* @return false, if DODAG could not be created or exists already.
|
||||
*/
|
||||
bool ng_rpl_dodag_add(ng_rpl_instance_t *instance, ipv6_addr_t *dodag_id, ng_rpl_dodag_t **dodag);
|
||||
bool gnrc_rpl_dodag_add(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id,
|
||||
gnrc_rpl_dodag_t **dodag);
|
||||
|
||||
/**
|
||||
* @brief Remove the RPL DODAG @p dodag.
|
||||
@ -129,14 +130,14 @@ bool ng_rpl_dodag_add(ng_rpl_instance_t *instance, ipv6_addr_t *dodag_id, ng_rpl
|
||||
* @return true, on success.
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
bool ng_rpl_dodag_remove(ng_rpl_dodag_t *dodag);
|
||||
bool gnrc_rpl_dodag_remove(gnrc_rpl_dodag_t *dodag);
|
||||
|
||||
/**
|
||||
* @brief Remove all parents from the @p dodag.
|
||||
*
|
||||
* @param[in] dodag Pointer to the dodag.
|
||||
*/
|
||||
void ng_rpl_dodag_remove_all_parents(ng_rpl_dodag_t *dodag);
|
||||
void gnrc_rpl_dodag_remove_all_parents(gnrc_rpl_dodag_t *dodag);
|
||||
|
||||
/**
|
||||
* @brief Get the RPL DODAG with the id @p dodag_id to the instance @p instance.
|
||||
@ -147,7 +148,7 @@ void ng_rpl_dodag_remove_all_parents(ng_rpl_dodag_t *dodag);
|
||||
* @return Pointer to the existing RPL DODAG, on success.
|
||||
* @return NULL, otherwise.
|
||||
*/
|
||||
ng_rpl_dodag_t *ng_rpl_dodag_get(ng_rpl_instance_t *instance, ipv6_addr_t *dodag_id);
|
||||
gnrc_rpl_dodag_t *gnrc_rpl_dodag_get(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id);
|
||||
|
||||
/**
|
||||
* @brief Add a new parent with the IPv6 address @p addr to the @p dodag.
|
||||
@ -159,7 +160,8 @@ ng_rpl_dodag_t *ng_rpl_dodag_get(ng_rpl_instance_t *instance, ipv6_addr_t *dodag
|
||||
* @return true. if parent could be created.
|
||||
* @return false, if parent could not be created or exists already.
|
||||
*/
|
||||
bool ng_rpl_parent_add_by_addr(ng_rpl_dodag_t *dodag, ipv6_addr_t *addr, ng_rpl_parent_t **parent);
|
||||
bool gnrc_rpl_parent_add_by_addr(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *addr,
|
||||
gnrc_rpl_parent_t **parent);
|
||||
|
||||
/**
|
||||
* @brief Remove the @p parent from its DODAG.
|
||||
@ -169,7 +171,7 @@ bool ng_rpl_parent_add_by_addr(ng_rpl_dodag_t *dodag, ipv6_addr_t *addr, ng_rpl_
|
||||
* @return true, on success.
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
bool ng_rpl_parent_remove(ng_rpl_parent_t *parent);
|
||||
bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent);
|
||||
|
||||
/**
|
||||
* @brief Get a parent with the IPv6 addr @p addr of the DODAG @p dodag.
|
||||
@ -180,7 +182,7 @@ bool ng_rpl_parent_remove(ng_rpl_parent_t *parent);
|
||||
* @return Pointer to the existing parent, on success.
|
||||
* @return NULL, otherwise.
|
||||
*/
|
||||
ng_rpl_parent_t *ng_rpl_parent_get(ng_rpl_dodag_t *dodag, ipv6_addr_t *addr);
|
||||
gnrc_rpl_parent_t *gnrc_rpl_parent_get(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Update a @p parent of the @p dodag.
|
||||
@ -188,7 +190,7 @@ ng_rpl_parent_t *ng_rpl_parent_get(ng_rpl_dodag_t *dodag, ipv6_addr_t *addr);
|
||||
* @param[in] dodag Pointer to the DODAG
|
||||
* @param[in] parent Pointer to the parent
|
||||
*/
|
||||
void ng_rpl_parent_update(ng_rpl_dodag_t *dodag, ng_rpl_parent_t *parent);
|
||||
void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent);
|
||||
|
||||
/**
|
||||
* @brief Find the parent with the lowest rank and update the DODAG's preferred parent
|
||||
@ -198,19 +200,19 @@ void ng_rpl_parent_update(ng_rpl_dodag_t *dodag, ng_rpl_parent_t *parent);
|
||||
* @return Pointer to the preferred parent, on success.
|
||||
* @return NULL, otherwise.
|
||||
*/
|
||||
ng_rpl_parent_t *ng_rpl_find_preferred_parent(ng_rpl_dodag_t *dodag);
|
||||
gnrc_rpl_parent_t *gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *dodag);
|
||||
|
||||
/**
|
||||
* @brief Start a local repair.
|
||||
*
|
||||
* @param[in] dodag Pointer to the DODAG
|
||||
*/
|
||||
void ng_rpl_local_repair(ng_rpl_dodag_t *dodag);
|
||||
void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_RPL_DODAG_H_ */
|
||||
#endif /* GNRC_RPL_DODAG_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_ng_rpl
|
||||
* @ingroup net_gnrc_rpl
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -20,7 +20,6 @@
|
||||
#define RPL_OFM_H
|
||||
|
||||
#include "structs.h"
|
||||
#include "net/ng_ipv6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -29,14 +28,14 @@ extern "C" {
|
||||
/**
|
||||
* @brief Initialization of Manager and of-functions.
|
||||
*/
|
||||
void ng_rpl_of_manager_init(void);
|
||||
void gnrc_rpl_of_manager_init(void);
|
||||
|
||||
/**
|
||||
* @brief Returns objective function with a given cope point
|
||||
* @param[in] ocp Objective code point of objective function
|
||||
* @return Pointer of corresponding objective function implementation
|
||||
*/
|
||||
ng_rpl_of_t *ng_rpl_get_of_for_ocp(uint16_t ocp);
|
||||
gnrc_rpl_of_t *gnrc_rpl_get_of_for_ocp(uint16_t ocp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
/**
|
||||
* @defgroup net_rpl_srh RPL source routing header extension
|
||||
* @ingroup net_ng_rpl
|
||||
* @ingroup net_gnrc_rpl
|
||||
* @brief Implementation of RPL source routing extension headers
|
||||
* @see <a href="https://tools.ietf.org/html/rfc6554">
|
||||
* RFC 6554
|
||||
@ -20,8 +20,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_RPL_SRH_H_
|
||||
#define NG_RPL_SRH_H_
|
||||
#ifndef GNRC_RPL_SRH_H_
|
||||
#define GNRC_RPL_SRH_H_
|
||||
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
@ -32,7 +32,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Type for source routing header.
|
||||
*/
|
||||
#define NG_RPL_SRH_TYPE (3U)
|
||||
#define GNRC_RPL_SRH_TYPE (3U)
|
||||
|
||||
/**
|
||||
* @brief The RPL Source routing header.
|
||||
@ -48,7 +48,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t len; /**< length in 8 octets without first octet */
|
||||
uint8_t type; /**< identifier of a particular routing header type */
|
||||
uint8_t seg_left; /**< number of route segments remaining */
|
||||
} ng_rpl_srh_t;
|
||||
} gnrc_rpl_srh_t;
|
||||
|
||||
/**
|
||||
* @brief Extract next hop from the RPL source routing header.
|
||||
@ -58,11 +58,11 @@ typedef struct __attribute__((packed)) {
|
||||
* @return next hop, on success
|
||||
* @return NULL, if not found.
|
||||
*/
|
||||
ipv6_addr_t *ng_rpl_srh_next_hop(ng_rpl_srh_t *rh);
|
||||
ipv6_addr_t *gnrc_rpl_srh_next_hop(gnrc_rpl_srh_t *rh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_RPL_SRH_H_ */
|
||||
#endif /* GNRC_RPL_SRH_H_ */
|
||||
/** @} */
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_ng_rpl
|
||||
* @ingroup net_gnrc_rpl
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -20,14 +20,14 @@
|
||||
* @author Cenk Gündoğan <cnkgndgn@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef NG_RPL_STRUCTS_H_
|
||||
#define NG_RPL_STRUCTS_H_
|
||||
#ifndef GNRC_RPL_STRUCTS_H_
|
||||
#define GNRC_RPL_STRUCTS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "trickle.h"
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ extern "C" {
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type; /**< Option Type */
|
||||
uint8_t length; /**< Option Length, does not include the first two byte */
|
||||
} ng_rpl_opt_t;
|
||||
} gnrc_rpl_opt_t;
|
||||
|
||||
/**
|
||||
* @brief DIO Base Object
|
||||
@ -56,7 +56,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t flags; /**< unused */
|
||||
uint8_t reserved; /**< reserved */
|
||||
ipv6_addr_t dodag_id; /**< id of the dodag */
|
||||
} ng_rpl_dio_t;
|
||||
} gnrc_rpl_dio_t;
|
||||
|
||||
/**
|
||||
* @brief DODAG Configuration Option
|
||||
@ -77,7 +77,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t reserved; /**< reserved */
|
||||
uint8_t default_lifetime; /**< lifetime of RPL routes (lifetime * lifetime_unit) */
|
||||
network_uint16_t lifetime_unit; /**< unit in seconds */
|
||||
} ng_rpl_opt_dodag_conf_t;
|
||||
} gnrc_rpl_opt_dodag_conf_t;
|
||||
|
||||
/**
|
||||
* @brief DODAG Information Solicitation
|
||||
@ -88,7 +88,7 @@ typedef struct __attribute__((packed)) {
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t flags; /**< unused */
|
||||
uint8_t reserved; /**< reserved */
|
||||
} ng_rpl_dis_t;
|
||||
} gnrc_rpl_dis_t;
|
||||
|
||||
/**
|
||||
* @brief Destination Advertisement Object
|
||||
@ -102,7 +102,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t reserved; /**< reserved */
|
||||
uint8_t dao_sequence; /**< sequence of the DAO, needs to be used for DAO-ACK */
|
||||
ipv6_addr_t dodag_id; /**< id of the DODAG */
|
||||
} ng_rpl_dao_t;
|
||||
} gnrc_rpl_dao_t;
|
||||
|
||||
/**
|
||||
* @brief Destination Advertisement Object Acknowledgement
|
||||
@ -116,7 +116,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t dao_sequence; /**< sequence must be equal to the sequence from the DAO object */
|
||||
uint8_t status; /**< indicates completion */
|
||||
ipv6_addr_t dodag_id; /**< id of the DODAG */
|
||||
} ng_rpl_dao_ack_t;
|
||||
} gnrc_rpl_dao_ack_t;
|
||||
|
||||
/**
|
||||
* @brief Target Option
|
||||
@ -130,7 +130,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t flags; /**< unused */
|
||||
uint8_t prefix_length; /**< number of valid leading bits in the IPv6 prefix */
|
||||
ipv6_addr_t target; /**< IPv6 prefix, address or multicast group */
|
||||
} ng_rpl_opt_target_t;
|
||||
} gnrc_rpl_opt_target_t;
|
||||
|
||||
/**
|
||||
* @brief Transit Option
|
||||
@ -145,7 +145,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t path_control; /**< limits the number of DAO parents */
|
||||
uint8_t path_sequence; /**< increased value for route updates */
|
||||
uint8_t path_lifetime; /**< lifetime of routes */
|
||||
} ng_rpl_opt_transit_t;
|
||||
} gnrc_rpl_opt_transit_t;
|
||||
|
||||
/**
|
||||
* @brief Prefix Information Option
|
||||
@ -162,21 +162,21 @@ typedef struct __attribute__((packed)) {
|
||||
uint32_t pref_lifetime; /**< preferred lifetime */
|
||||
uint32_t reserved; /**< reserved */
|
||||
ipv6_addr_t prefix; /**< prefix used for Stateless Address Autoconfiguration */
|
||||
} ng_rpl_opt_prefix_info_t;
|
||||
} gnrc_rpl_opt_prefix_info_t;
|
||||
|
||||
typedef struct ng_rpl_dodag ng_rpl_dodag_t;
|
||||
typedef struct ng_rpl_parent ng_rpl_parent_t;
|
||||
typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
|
||||
typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
|
||||
|
||||
/**
|
||||
* @brief Parent representation
|
||||
*/
|
||||
struct ng_rpl_parent {
|
||||
ng_rpl_parent_t *next; /**< pointer to the next parent */
|
||||
struct gnrc_rpl_parent {
|
||||
gnrc_rpl_parent_t *next; /**< pointer to the next parent */
|
||||
uint8_t state; /**< 0 for unsued, 1 for used */
|
||||
ipv6_addr_t addr; /**< link-local IPv6 address of this parent */
|
||||
uint16_t rank; /**< rank of the parent */
|
||||
uint8_t dtsn; /**< last seen dtsn of this parent */
|
||||
ng_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */
|
||||
gnrc_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */
|
||||
timex_t lifetime; /**< lifetime of this parent */
|
||||
double link_metric; /**< metric of the link */
|
||||
uint8_t link_metric_type; /**< type of the metric */
|
||||
@ -187,14 +187,14 @@ struct ng_rpl_parent {
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t ocp; /**< objective code point */
|
||||
uint16_t (*calc_rank)(ng_rpl_parent_t *parent, uint16_t base_rank); /**< calculate the rank */
|
||||
ng_rpl_parent_t *(*which_parent)(ng_rpl_parent_t *, ng_rpl_parent_t *); /**< compare for parents */
|
||||
ng_rpl_dodag_t *(*which_dodag)(ng_rpl_dodag_t *, ng_rpl_dodag_t *); /**< compare for dodags */
|
||||
void (*reset)(ng_rpl_dodag_t *); /**< resets the OF */
|
||||
void (*parent_state_callback)(ng_rpl_parent_t *, int, int); /**< retrieves the state of a parent*/
|
||||
uint16_t (*calc_rank)(gnrc_rpl_parent_t *parent, uint16_t base_rank); /**< calculate the rank */
|
||||
gnrc_rpl_parent_t *(*which_parent)(gnrc_rpl_parent_t *, gnrc_rpl_parent_t *); /**< compare for parents */
|
||||
gnrc_rpl_dodag_t *(*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *); /**< compare for dodags */
|
||||
void (*reset)(gnrc_rpl_dodag_t *); /**< resets the OF */
|
||||
void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int); /**< retrieves the state of a parent*/
|
||||
void (*init)(void); /**< OF specific init function */
|
||||
void (*process_dio)(void); /**< DIO processing callback (acc. to OF0 spec, chpt 5) */
|
||||
} ng_rpl_of_t;
|
||||
} gnrc_rpl_of_t;
|
||||
|
||||
|
||||
/**
|
||||
@ -203,20 +203,20 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint8_t id; /**< id of the instance */
|
||||
uint8_t state; /**< 0 for unused, 1 for used */
|
||||
ng_rpl_dodag_t *dodags; /**< pointer to the DODAG list of this instance */
|
||||
gnrc_rpl_dodag_t *dodags; /**< pointer to the DODAG list of this instance */
|
||||
uint8_t mop; /**< configured Mode of Operation */
|
||||
ng_rpl_of_t *of; /**< configured Objective Function */
|
||||
gnrc_rpl_of_t *of; /**< configured Objective Function */
|
||||
uint16_t min_hop_rank_inc; /**< minimum hop rank increase */
|
||||
uint16_t max_rank_inc; /**< max increase in the rank */
|
||||
} ng_rpl_instance_t;
|
||||
} gnrc_rpl_instance_t;
|
||||
|
||||
/**
|
||||
* @brief DODAG representation
|
||||
*/
|
||||
struct ng_rpl_dodag {
|
||||
ng_rpl_instance_t *instance; /**< id of the instance */
|
||||
ng_rpl_dodag_t *next; /**< pointer to the next dodag */
|
||||
ng_rpl_parent_t *parents; /**< pointer to the parents list of this DODAG */
|
||||
struct gnrc_rpl_dodag {
|
||||
gnrc_rpl_instance_t *instance; /**< id of the instance */
|
||||
gnrc_rpl_dodag_t *next; /**< pointer to the next dodag */
|
||||
gnrc_rpl_parent_t *parents; /**< pointer to the parents list of this DODAG */
|
||||
ipv6_addr_t dodag_id; /**< id of the DODAG */
|
||||
uint8_t prefix_len; /**< length of the prefix for the DODAG id */
|
||||
uint32_t addr_preferred; /**< time in seconds the DODAG id is preferred */
|
||||
@ -248,7 +248,7 @@ struct ng_rpl_dodag {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_RPL_STRUCTS_H_ */
|
||||
#endif /* GNRC_RPL_STRUCTS_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_sixlowpan 6LoWPAN
|
||||
* @defgroup net_gnrc_sixlowpan 6LoWPAN
|
||||
* @ingroup net
|
||||
* @brief 6LoWPAN implementation
|
||||
* @{
|
||||
@ -17,15 +17,15 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_H_
|
||||
#define NG_SIXLOWPAN_H_
|
||||
#ifndef GNRC_SIXLOWPAN_H_
|
||||
#define GNRC_SIXLOWPAN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
|
||||
#include "net/ng_sixlowpan/frag.h"
|
||||
#include "net/ng_sixlowpan/iphc.h"
|
||||
#include "net/gnrc/sixlowpan/frag.h"
|
||||
#include "net/gnrc/sixlowpan/iphc.h"
|
||||
#include "net/sixlowpan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -35,22 +35,22 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default stack size to use for the 6LoWPAN thread.
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_STACK_SIZE
|
||||
#define NG_SIXLOWPAN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_SIXLOWPAN_STACK_SIZE
|
||||
#define GNRC_SIXLOWPAN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default priority for the 6LoWPAN thread.
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_PRIO
|
||||
#define NG_SIXLOWPAN_PRIO (THREAD_PRIORITY_MAIN - 4)
|
||||
#ifndef GNRC_SIXLOWPAN_PRIO
|
||||
#define GNRC_SIXLOWPAN_PRIO (THREAD_PRIORITY_MAIN - 4)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default message queue size to use for the 6LoWPAN thread.
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_MSG_QUEUE_SIZE
|
||||
#define NG_SIXLOWPAN_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_SIXLOWPAN_MSG_QUEUE_SIZE
|
||||
#define GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -60,15 +60,15 @@ extern "C" {
|
||||
* the 6LoWPAN thread.
|
||||
*
|
||||
* @return The PID to the 6LoWPAN thread, on success.
|
||||
* @return -EINVAL, if @ref NG_SIXLOWPAN_PRIO was greater than or equal to
|
||||
* @return -EINVAL, if @ref GNRC_SIXLOWPAN_PRIO was greater than or equal to
|
||||
* @ref SCHED_PRIO_LEVELS
|
||||
* @return -EOVERFLOW, if there are too many threads running already in general
|
||||
*/
|
||||
kernel_pid_t ng_sixlowpan_init(void);
|
||||
kernel_pid_t gnrc_sixlowpan_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_SIXLOWPAN_H_ */
|
||||
#endif /* GNRC_SIXLOWPAN_H_ */
|
||||
/** @} */
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_sixlowpan 6LoWPAN
|
||||
* @defgroup net_gnrc_sixlowpan 6LoWPAN
|
||||
* @ingroup net
|
||||
*
|
||||
* @defgroup net_ng_sixlowpan_ctx Contexts for 6LoWPAN address compression
|
||||
* @ingroup net_ng_sixlowpan
|
||||
* @defgroup net_gnrc_sixlowpan_ctx Contexts for 6LoWPAN address compression
|
||||
* @ingroup net_gnrc_sixlowpan
|
||||
* @brief Context buffer for stateful 6LoWPAN address compression
|
||||
* @see <a href="https://tools.ietf.org/html/rfc6282#section-3.1.2">
|
||||
* RFC 6282, section 3.1.2
|
||||
@ -26,8 +26,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_CTX_H_
|
||||
#define NG_SIXLOWPAN_CTX_H_
|
||||
#ifndef GNRC_SIXLOWPAN_CTX_H_
|
||||
#define GNRC_SIXLOWPAN_CTX_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
@ -38,16 +38,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NG_SIXLOWPAN_CTX_SIZE (16) /**< maximum number of entries in
|
||||
#define GNRC_SIXLOWPAN_CTX_SIZE (16) /**< maximum number of entries in
|
||||
* context buffer */
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @name Context flags.
|
||||
* @brief Flags to set in ng_sixlowpan_ctx_t::flags_id.
|
||||
* @brief Flags to set in gnrc_sixlowpan_ctx_t::flags_id.
|
||||
*/
|
||||
#define NG_SIXLOWPAN_CTX_FLAGS_CID_MASK (0x0f) /**< mask for the Context ID. */
|
||||
#define NG_SIXLOWPAN_CTX_FLAGS_COMP (0x10) /**< Use context for compression */
|
||||
#define GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK (0x0f) /**< mask for the Context ID. */
|
||||
#define GNRC_SIXLOWPAN_CTX_FLAGS_COMP (0x10) /**< Use context for compression */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -57,7 +57,7 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
ipv6_addr_t prefix; /**< The prefix associated to this context. */
|
||||
uint8_t prefix_len; /**< Length of ng_sixlowpan_ctx_t::prefix in bit. */
|
||||
uint8_t prefix_len; /**< Length of gnrc_sixlowpan_ctx_t::prefix in bit. */
|
||||
/**
|
||||
* @brief 4-bit flags, 4-bit Context ID.
|
||||
*
|
||||
@ -75,7 +75,7 @@ typedef struct {
|
||||
* </a>
|
||||
*/
|
||||
uint16_t ltime;
|
||||
} ng_sixlowpan_ctx_t;
|
||||
} gnrc_sixlowpan_ctx_t;
|
||||
|
||||
/**
|
||||
* @brief Gets a context matching the given IPv6 address best with its prefix.
|
||||
@ -85,7 +85,7 @@ typedef struct {
|
||||
* @return The context associated with the best prefix for @p addr.
|
||||
* @return NULL if there is no such context.
|
||||
*/
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr);
|
||||
gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Gets context by ID.
|
||||
@ -95,13 +95,13 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr);
|
||||
* @return The context associated with @p id.
|
||||
* @return NULL if there is no such context.
|
||||
*/
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_id(uint8_t id);
|
||||
gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_lookup_id(uint8_t id);
|
||||
|
||||
/**
|
||||
* @brief Updates (or adds if currently not registered) a context
|
||||
*
|
||||
* @param[in] id The ID for the context.
|
||||
* Must be < @ref NG_SIXLOWPAN_CTX_SIZE.
|
||||
* Must be < @ref GNRC_SIXLOWPAN_CTX_SIZE.
|
||||
* @param[in] prefix The prefix for the context.
|
||||
* @param[in] prefix_len Length of @p prefix in bits. Must be > 0.
|
||||
* @param[in] ltime New lifetime of the context. @p comp will be
|
||||
@ -112,30 +112,30 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_id(uint8_t id);
|
||||
* @return The new context on success.
|
||||
* @return NULL, on error or on removal.
|
||||
*/
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *prefix,
|
||||
uint8_t prefix_len, uint16_t ltime,
|
||||
bool comp);
|
||||
gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *prefix,
|
||||
uint8_t prefix_len, uint16_t ltime,
|
||||
bool comp);
|
||||
|
||||
/**
|
||||
* @brief Removes context.
|
||||
*
|
||||
* @param[in] id A context ID.
|
||||
*/
|
||||
static inline void ng_sixlowpan_ctx_remove(uint8_t id)
|
||||
static inline void gnrc_sixlowpan_ctx_remove(uint8_t id)
|
||||
{
|
||||
ng_sixlowpan_ctx_lookup_id(id)->prefix_len = 0;
|
||||
gnrc_sixlowpan_ctx_lookup_id(id)->prefix_len = 0;
|
||||
}
|
||||
|
||||
#ifdef TEST_SUITES
|
||||
/**
|
||||
* @brief Resets the whole context buffer.
|
||||
*/
|
||||
void ng_sixlowpan_ctx_reset(void);
|
||||
void gnrc_sixlowpan_ctx_reset(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_SIXLOWPAN_CTX_H_ */
|
||||
#endif /* GNRC_SIXLOWPAN_CTX_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_sixlowpan_frag 6LoWPAN Fragmentation
|
||||
* @ingroup net_ng_sixlowpan
|
||||
* @defgroup net_gnrc_sixlowpan_frag 6LoWPAN Fragmentation
|
||||
* @ingroup net_gnrc_sixlowpan
|
||||
* @brief 6LoWPAN Fragmentation headers and functionality
|
||||
* @see <a href="https://tools.ietf.org/html/rfc4944#section-5.3">
|
||||
* RFC 4944, section 5.3
|
||||
@ -20,15 +20,15 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_FRAG_H_
|
||||
#define NG_SIXLOWPAN_FRAG_H_
|
||||
#ifndef GNRC_SIXLOWPAN_FRAG_H_
|
||||
#define GNRC_SIXLOWPAN_FRAG_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/sixlowpan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -41,22 +41,22 @@ extern "C" {
|
||||
* @param[in] pid The interface to send the packet over.
|
||||
* @param[in] pkt The packet to send.
|
||||
* @param[in] datagram_size The length of just the IPv6 packet. It is the value
|
||||
* that the ng_sixlowpan_frag_t::disp_size field will be
|
||||
* that the gnrc_sixlowpan_frag_t::disp_size field will be
|
||||
* set to.
|
||||
*/
|
||||
void ng_sixlowpan_frag_send(kernel_pid_t pid, ng_pktsnip_t *pkt,
|
||||
size_t datagram_size);
|
||||
void gnrc_sixlowpan_frag_send(kernel_pid_t pid, gnrc_pktsnip_t *pkt,
|
||||
size_t datagram_size);
|
||||
|
||||
/**
|
||||
* @brief Handles a packet containing a fragment header.
|
||||
*
|
||||
* @param[in] pkt The packet to handle.
|
||||
*/
|
||||
void ng_sixlowpan_frag_handle_pkt(ng_pktsnip_t *pkt);
|
||||
void gnrc_sixlowpan_frag_handle_pkt(gnrc_pktsnip_t *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_SIXLOWPAN_FRAG_H_ */
|
||||
#endif /* GNRC_SIXLOWPAN_FRAG_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_sixlowpan_iphc IPv6 header compression (IPHC)
|
||||
* @ingroup net_ng_sixlowpan
|
||||
* @defgroup net_gnrc_sixlowpan_iphc IPv6 header compression (IPHC)
|
||||
* @ingroup net_gnrc_sixlowpan
|
||||
* @brief IPv6 header compression for 6LoWPAN.
|
||||
* @{
|
||||
*
|
||||
@ -17,12 +17,12 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_IPHC_H_
|
||||
#define NG_SIXLOWPAN_IPHC_H_
|
||||
#ifndef GNRC_SIXLOWPAN_IPHC_H_
|
||||
#define GNRC_SIXLOWPAN_IPHC_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/sixlowpan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -32,18 +32,18 @@ extern "C" {
|
||||
/**
|
||||
* @brief Decompresses a received 6LoWPAN IPHC frame.
|
||||
*
|
||||
* @pre (ipv6 != NULL) && (ipv6->size >= sizeof(ng_ipv6_hdr_t))
|
||||
* @pre (ipv6 != NULL) && (ipv6->size >= sizeof(gnrc_ipv6_hdr_t))
|
||||
*
|
||||
* @param[out] ipv6 A pre-allocated IPv6 header. Will not be inserted into
|
||||
* @p pkt
|
||||
* @param[in,out] pkt A received 6LoWPAN IPHC frame. IPHC dispatch will not
|
||||
* be marked.
|
||||
* @param[in] size Offset of the IPHC dispatch in 6LoWPaN frame.
|
||||
* @param[in] offset Offset of the IPHC dispatch in 6LoWPaN frame.
|
||||
*
|
||||
* @return length of the HC dispatches + inline values on success.
|
||||
* @return 0 on error.
|
||||
*/
|
||||
size_t ng_sixlowpan_iphc_decode(ng_pktsnip_t *ipv6, ng_pktsnip_t *pkt, size_t offset);
|
||||
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t offset);
|
||||
|
||||
/**
|
||||
* @brief Compresses a 6LoWPAN for IPHC.
|
||||
@ -54,11 +54,11 @@ size_t ng_sixlowpan_iphc_decode(ng_pktsnip_t *ipv6, ng_pktsnip_t *pkt, size_t of
|
||||
* @return true, on success
|
||||
* @return false, on error.
|
||||
*/
|
||||
bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt);
|
||||
bool gnrc_sixlowpan_iphc_encode(gnrc_pktsnip_t *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_SIXLOWPAN_IPHC_H_ */
|
||||
#endif /* GNRC_SIXLOWPAN_IPHC_H_ */
|
||||
/** @} */
|
@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_sixlowpan_netif 6LoWPAN network interfaces
|
||||
* @ingroup net_ng_sixlowpan
|
||||
* @brief 6LoWPAN specific information on @ref net_ng_netif
|
||||
* @defgroup net_gnrc_sixlowpan_netif 6LoWPAN network interfaces
|
||||
* @ingroup net_gnrc_sixlowpan
|
||||
* @brief 6LoWPAN specific information on @ref net_gnrc_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -17,8 +17,8 @@
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef NG_SIXLOWPAN_NETIF_H_
|
||||
#define NG_SIXLOWPAN_NETIF_H_
|
||||
#ifndef GNRC_SIXLOWPAN_NETIF_H_
|
||||
#define GNRC_SIXLOWPAN_NETIF_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -34,15 +34,15 @@ extern "C" {
|
||||
typedef struct {
|
||||
kernel_pid_t pid; /**< PID of the interface */
|
||||
uint16_t max_frag_size; /**< Maximum fragment size for this interface */
|
||||
#ifdef MODULE_NG_SIXLOWPAN_IPHC
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||
bool iphc_enabled; /**< enable or disable IPHC */
|
||||
#endif
|
||||
} ng_sixlowpan_netif_t;
|
||||
} gnrc_sixlowpan_netif_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes the module
|
||||
*/
|
||||
void ng_sixlowpan_netif_init(void);
|
||||
void gnrc_sixlowpan_netif_init(void);
|
||||
|
||||
/**
|
||||
* @brief Add interface to 6LoWPAN.
|
||||
@ -50,14 +50,14 @@ void ng_sixlowpan_netif_init(void);
|
||||
* @param[in] pid The PID to the interface.
|
||||
* @param[in] max_frag_size The maximum fragment size for this interface.
|
||||
*/
|
||||
void ng_sixlowpan_netif_add(kernel_pid_t pid, uint16_t max_frag_size);
|
||||
void gnrc_sixlowpan_netif_add(kernel_pid_t pid, uint16_t max_frag_size);
|
||||
|
||||
/**
|
||||
* @brief Remove interface from 6LoWPAN.
|
||||
*
|
||||
* @param[in] pid The PID to the interface.
|
||||
*/
|
||||
void ng_sixlowpan_netif_remove(kernel_pid_t pid);
|
||||
void gnrc_sixlowpan_netif_remove(kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Get interface.
|
||||
@ -67,11 +67,11 @@ void ng_sixlowpan_netif_remove(kernel_pid_t pid);
|
||||
* @return The interface describing structure, on success.
|
||||
* @return NULL, if there is no interface with PID @p pid.
|
||||
*/
|
||||
ng_sixlowpan_netif_t *ng_sixlowpan_netif_get(kernel_pid_t pid);
|
||||
gnrc_sixlowpan_netif_t *gnrc_sixlowpan_netif_get(kernel_pid_t pid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_SIXLOWPAN_NETIF_H_ */
|
||||
#endif /* GNRC_SIXLOWPAN_NETIF_H_ */
|
||||
/** @} */
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_slip SLIP
|
||||
* @defgroup net_gnrc_slip SLIP
|
||||
* @ingroup net
|
||||
* @brief Provides a SLIP interface over UART utilizing
|
||||
* @ref driver_periph_uart.
|
||||
@ -21,8 +21,8 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_SLIP_H_
|
||||
#define NG_SLIP_H_
|
||||
#ifndef GNRC_SLIP_H_
|
||||
#define GNRC_SLIP_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -40,8 +40,8 @@ extern "C" {
|
||||
* Reduce this value if your expected traffic does not include full IPv6 MTU
|
||||
* sized packets
|
||||
*/
|
||||
#ifndef NG_SLIP_BUFSIZE
|
||||
#define NG_SLIP_BUFSIZE (1500U)
|
||||
#ifndef GNRC_SLIP_BUFSIZE
|
||||
#define GNRC_SLIP_BUFSIZE (1500U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -51,13 +51,13 @@ typedef struct {
|
||||
uart_t uart; /**< the UART interface */
|
||||
ringbuffer_t *in_buf; /**< RX buffer */
|
||||
ringbuffer_t *out_buf; /**< TX buffer */
|
||||
char rx_mem[NG_SLIP_BUFSIZE]; /**< memory used by RX buffer */
|
||||
char tx_mem[NG_SLIP_BUFSIZE]; /**< memory used by TX buffer */
|
||||
char rx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by RX buffer */
|
||||
char tx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by TX buffer */
|
||||
uint32_t in_bytes; /**< the number of bytes received of a
|
||||
* currently incoming packet */
|
||||
uint16_t in_esc; /**< receiver is in escape mode */
|
||||
kernel_pid_t slip_pid; /**< PID of the device thread */
|
||||
} ng_slip_dev_t;
|
||||
} gnrc_slip_dev_t;
|
||||
|
||||
/**
|
||||
* @brief auto_init struct holding SLIP initalization params
|
||||
@ -65,10 +65,10 @@ typedef struct {
|
||||
typedef struct xbee_params {
|
||||
uart_t uart; /**< UART interfaced the device is connected to */
|
||||
uint32_t baudrate; /**< baudrate to use */
|
||||
} ng_slip_params_t;
|
||||
} gnrc_slip_params_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes a new @ref net_ng_slip control thread for UART device
|
||||
* @brief Initializes a new @ref net_gnrc_slip control thread for UART device
|
||||
* @p uart
|
||||
*
|
||||
* @param[in] dev un-initialized SLIP device descriptor
|
||||
@ -80,10 +80,10 @@ typedef struct xbee_params {
|
||||
*
|
||||
* @return PID of SLIP thread on success
|
||||
* @return -EFAULT, if slip thread could not be created
|
||||
* @return -ENODEV, if ng_slip_dev_t::uart of @p dev was no valid UART
|
||||
* @return -ENODEV, if gnrc_slip_dev_t::uart of @p dev was no valid UART
|
||||
*/
|
||||
kernel_pid_t ng_slip_init(ng_slip_dev_t *dev, uart_t uart, uint32_t baudrate,
|
||||
char *stack, size_t stack_size, char priority);
|
||||
kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate,
|
||||
char *stack, size_t stack_size, char priority);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -19,8 +19,8 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NG_UDP_H_
|
||||
#define NG_UDP_H_
|
||||
#ifndef GNRC_UDP_H_
|
||||
#define GNRC_UDP_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -35,22 +35,22 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default message queue size for the UDP thread
|
||||
*/
|
||||
#ifndef NG_UDP_MSG_QUEUE_SIZE
|
||||
#define NG_UDP_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_UDP_MSG_QUEUE_SIZE
|
||||
#define GNRC_UDP_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Priority of the pktdump thread
|
||||
*/
|
||||
#ifndef NG_UDP_PRIO
|
||||
#define NG_UDP_PRIO (THREAD_PRIORITY_MAIN - 2)
|
||||
#ifndef GNRC_UDP_PRIO
|
||||
#define GNRC_UDP_PRIO (THREAD_PRIORITY_MAIN - 2)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default stack size to use for the UDP thread
|
||||
*/
|
||||
#ifndef NG_UDP_STACK_SIZE
|
||||
#define NG_UDP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_UDP_STACK_SIZE
|
||||
#define GNRC_UDP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -60,11 +60,11 @@ extern "C" {
|
||||
* @param[in] pseudo_hdr Pointer to the network layer header
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -EBADMSG if @p hdr is not of type NG_NETTYPE_UDP
|
||||
* @return -EBADMSG if @p hdr is not of type GNRC_NETTYPE_UDP
|
||||
* @return -EFAULT if @p hdr or @p pseudo_hdr is NULL
|
||||
* @return -ENOENT if ng_pktsnip_t::type of @p pseudo_hdr is not known
|
||||
* @return -ENOENT if gnrc_pktsnip_t::type of @p pseudo_hdr is not known
|
||||
*/
|
||||
int ng_udp_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr);
|
||||
int gnrc_udp_calc_csum(gnrc_pktsnip_t *hdr, gnrc_pktsnip_t *pseudo_hdr);
|
||||
|
||||
/**
|
||||
* @brief Allocate and initialize a fresh UDP header in the packet buffer
|
||||
@ -79,9 +79,9 @@ int ng_udp_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr);
|
||||
* @return NULL on `src == NULL`, `dst == NULL`, `src_len != 2`, `dst_len != 2`
|
||||
* or on allocation error
|
||||
*/
|
||||
ng_pktsnip_t *ng_udp_hdr_build(ng_pktsnip_t *payload,
|
||||
uint8_t *src, size_t src_len,
|
||||
uint8_t *dst, size_t dst_len);
|
||||
gnrc_pktsnip_t *gnrc_udp_hdr_build(gnrc_pktsnip_t *payload,
|
||||
uint8_t *src, size_t src_len,
|
||||
uint8_t *dst, size_t dst_len);
|
||||
|
||||
/**
|
||||
* @brief Initialize and start UDP
|
||||
@ -89,11 +89,11 @@ ng_pktsnip_t *ng_udp_hdr_build(ng_pktsnip_t *payload,
|
||||
* @return PID of the UDP thread
|
||||
* @return negative value on error
|
||||
*/
|
||||
int ng_udp_init(void);
|
||||
int gnrc_udp_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_UDP_H_ */
|
||||
#endif /* GNRC_UDP_H_ */
|
||||
/** @} */
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_zep Zigbee Encapsulation Protocol
|
||||
* @defgroup net_gnrc_zep Zigbee Encapsulation Protocol
|
||||
* @ingroup net
|
||||
* @brief Transports IEEE 802.15.4 frames over UDP (can be parsed by
|
||||
* Wireshark)
|
||||
@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NG_ZEP_H_
|
||||
#define NG_ZEP_H_
|
||||
#ifndef GNRC_ZEP_H_
|
||||
#define GNRC_ZEP_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "kernel_types.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -45,35 +45,35 @@ extern "C" {
|
||||
/**
|
||||
* @brief Maximum possible packet size in byte
|
||||
*/
|
||||
#define NG_ZEP_MAX_PKT_LENGTH (116)
|
||||
#define GNRC_ZEP_MAX_PKT_LENGTH (116)
|
||||
|
||||
/**
|
||||
* @brief Default stack size to use for the ZEP thread
|
||||
*/
|
||||
#ifndef NG_ZEP_STACK_SIZE
|
||||
#define NG_ZEP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#ifndef GNRC_ZEP_STACK_SIZE
|
||||
#define GNRC_ZEP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default priority for the ZEP thread
|
||||
*/
|
||||
#ifndef NG_ZEP_PRIO
|
||||
#define NG_ZEP_PRIO (THREAD_PRIORITY_MAIN - 5)
|
||||
#ifndef GNRC_ZEP_PRIO
|
||||
#define GNRC_ZEP_PRIO (THREAD_PRIORITY_MAIN - 5)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default message queue size to use for the ZEP thread.
|
||||
*/
|
||||
#ifndef NG_ZEP_MSG_QUEUE_SIZE
|
||||
#define NG_ZEP_MSG_QUEUE_SIZE (8U)
|
||||
#ifndef GNRC_ZEP_MSG_QUEUE_SIZE
|
||||
#define GNRC_ZEP_MSG_QUEUE_SIZE (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default addresses if the CPUID module is not present
|
||||
* @{
|
||||
*/
|
||||
#define NG_ZEP_DEFAULT_ADDR_SHORT (0x98b0)
|
||||
#define NG_ZEP_DEFAULT_ADDR_LONG (0x4a8a6377552b4249)
|
||||
#define GNRC_ZEP_DEFAULT_ADDR_SHORT (0x98b0)
|
||||
#define GNRC_ZEP_DEFAULT_ADDR_LONG (0x4a8a6377552b4249)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -82,9 +82,9 @@ extern "C" {
|
||||
* @brief Channel configuration
|
||||
* @{
|
||||
*/
|
||||
#define NG_ZEP_MIN_CHANNEL (11U)
|
||||
#define NG_ZEP_MAX_CHANNEL (26U)
|
||||
#define NG_ZEP_DEFAULT_CHANNEL (26U)
|
||||
#define GNRC_ZEP_MIN_CHANNEL (11U)
|
||||
#define GNRC_ZEP_MAX_CHANNEL (26U)
|
||||
#define GNRC_ZEP_DEFAULT_CHANNEL (26U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -94,16 +94,16 @@ extern "C" {
|
||||
*
|
||||
* @todo Read some global network stack specific configuration value
|
||||
*/
|
||||
#define NG_ZEP_DEFAULT_PANID (0x0023)
|
||||
#define GNRC_ZEP_DEFAULT_PANID (0x0023)
|
||||
|
||||
/**
|
||||
* @brief Option flags for the ZEP device
|
||||
* @{
|
||||
*/
|
||||
#define NG_ZEP_FLAGS_AUTOACK (0x0001) /**< auto ACKS active */
|
||||
#define NG_ZEP_FLAGS_SRC_ADDR_LONG (0x0002) /**< send data using long source address */
|
||||
#define NG_ZEP_FLAGS_DST_ADDR_LONG (0x0004) /**< send data using long destination address */
|
||||
#define NG_ZEP_FLAGS_USE_SRC_PAN (0x0008) /**< do not compress source PAN ID */
|
||||
#define GNRC_ZEP_FLAGS_AUTOACK (0x0001) /**< auto ACKS active */
|
||||
#define GNRC_ZEP_FLAGS_SRC_ADDR_LONG (0x0002) /**< send data using long source address */
|
||||
#define GNRC_ZEP_FLAGS_DST_ADDR_LONG (0x0004) /**< send data using long destination address */
|
||||
#define GNRC_ZEP_FLAGS_USE_SRC_PAN (0x0008) /**< do not compress source PAN ID */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -111,17 +111,17 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default UDP port for ZEP
|
||||
*/
|
||||
#define NG_ZEP_DEFAULT_PORT (17754)
|
||||
#define GNRC_ZEP_DEFAULT_PORT (17754)
|
||||
|
||||
/**
|
||||
* @brief Type == Data for ZEPv2 header
|
||||
*/
|
||||
#define NG_ZEP_V2_TYPE_DATA (1)
|
||||
#define GNRC_ZEP_V2_TYPE_DATA (1)
|
||||
|
||||
/**
|
||||
* @brief Type == Ack for ZEPv2 header
|
||||
*/
|
||||
#define NG_ZEP_V2_TYPE_ACK (2)
|
||||
#define GNRC_ZEP_V2_TYPE_ACK (2)
|
||||
|
||||
/**
|
||||
* @brief Mask for length field
|
||||
@ -134,11 +134,11 @@ extern "C" {
|
||||
typedef struct __attribute__((packed)) {
|
||||
char preamble[2]; /**< Preamble code (must be "EX") */
|
||||
uint8_t version; /**< Protocol Version (must be 1 or 2) */
|
||||
} ng_zep_hdr_t;
|
||||
} gnrc_zep_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief ZEPv1 header definition
|
||||
* @extends ng_zep_hdr_t
|
||||
* @extends gnrc_zep_hdr_t
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
char preamble[2]; /**< preamble code (must be "EX") */
|
||||
@ -149,11 +149,11 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t lqi_val; /**< LQI value */
|
||||
uint8_t resv[7]; /**< reserved field, must always be 0 */
|
||||
uint8_t length; /**< length of the frame */
|
||||
} ng_zep_v1_hdr_t;
|
||||
} gnrc_zep_v1_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief ZEPv2 header definition (type == Data)
|
||||
* @extends ng_zep_hdr_t
|
||||
* @extends gnrc_zep_hdr_t
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
char preamble[2]; /**< preamble code (must be "EX") */
|
||||
@ -167,30 +167,30 @@ typedef struct __attribute__((packed)) {
|
||||
network_uint32_t seq; /**< Sequence number */
|
||||
uint8_t resv[10]; /**< reserved field, must always be 0 */
|
||||
uint8_t length; /**< length of the frame */
|
||||
} ng_zep_v2_data_hdr_t;
|
||||
} gnrc_zep_v2_data_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief ZEPv2 header definition (type == Ack)
|
||||
* @extends ng_zep_hdr_t
|
||||
* @extends gnrc_zep_hdr_t
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
char preamble[2]; /**< preamble code (must be "EX") */
|
||||
uint8_t version; /**< protocol Version (must be 2) */
|
||||
uint8_t type; /**< type (must be 2/Ack) */
|
||||
network_uint32_t seq; /**< Sequence number */
|
||||
} ng_zep_v2_ack_hdr_t;
|
||||
} gnrc_zep_v2_ack_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief ZEP device descriptor.
|
||||
*
|
||||
* @extends ng_netdev_t
|
||||
* @extends gnrc_netdev_t
|
||||
*/
|
||||
typedef struct {
|
||||
ng_netdev_driver_t *driver; /**< pointer to the device's interface */
|
||||
ng_netdev_event_cb_t event_cb; /**< netdev event callback */
|
||||
gnrc_netdev_driver_t *driver; /**< pointer to the device's interface */
|
||||
gnrc_netdev_event_cb_t event_cb;/**< netdev event callback */
|
||||
kernel_pid_t mac_pid; /**< the driver's thread's PID */
|
||||
/**
|
||||
* @brief @ref ng_zep_t specific members
|
||||
* @brief @ref gnrc_zep_t specific members
|
||||
* @{
|
||||
*/
|
||||
le_uint16_t addr; /**< the device's short address */
|
||||
@ -201,42 +201,42 @@ typedef struct {
|
||||
ipv6_addr_t dst; /**< destination IPv6 address */
|
||||
uint16_t src_port; /**< source UDP port */
|
||||
uint16_t dst_port; /**< destination UDP port */
|
||||
ng_nettype_t proto; /**< the target protocol for received packets */
|
||||
gnrc_nettype_t proto; /**< the target protocol for received packets */
|
||||
uint8_t chan; /**< the device's channel */
|
||||
uint8_t version; /**< ZEP version to use (default 2) */
|
||||
uint8_t lqi_mode; /**< LQI mode for send packets (default 1) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
} ng_zep_t;
|
||||
} gnrc_zep_t;
|
||||
|
||||
/**
|
||||
* @brief Initializion of the ZEP thread and device.
|
||||
*
|
||||
* @param[in] dev Network device, will be initialized.
|
||||
* @param[in] src_port Source port to use in UDP datagrams. Also the port
|
||||
* @ref net_ng_zep registers to in @ref net_ng_netreg.
|
||||
* @ref net_gnrc_zep registers to in @ref net_gnrc_netreg.
|
||||
* @param[in] dst Destination address to use in IPv6 packets.
|
||||
* @param[in] dst_port Destination port to use in UDP datagrams.
|
||||
*
|
||||
* @return PID of the ZEP thread on success.
|
||||
* @return -EADDRINUSE, if @p src_port is already ready registered to
|
||||
* @ref net_ng_netreg.
|
||||
* @ref net_gnrc_netreg.
|
||||
* @return -EEXIST, if ZEP thread was already created.
|
||||
* @return -EINVAL, if @ref NG_ZEP_PRIO is greater than or equal to
|
||||
* @return -EINVAL, if @ref GNRC_ZEP_PRIO is greater than or equal to
|
||||
* @ref SCHED_PRIO_LEVELS
|
||||
* @return -ENODEV, if @p dev is NULL.
|
||||
* @return -ENOTSUP, if @p dst is NULL or unspecified address (::).
|
||||
* @return -EOVERFLOW, if there are too many threads running already
|
||||
*/
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port);
|
||||
kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_ZEP_H_ */
|
||||
#endif /* GNRC_ZEP_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -176,7 +176,7 @@ static inline void ipv6_hdr_set_tc_ecn(ipv6_hdr_t *hdr, uint8_t ecn)
|
||||
* </a>
|
||||
*
|
||||
* @param[out] hdr Pointer to an IPv6 header.
|
||||
* @param[in] dscp The new value for the 6-bit DSCP ng_part of the traffic class
|
||||
* @param[in] dscp The new value for the 6-bit DSCP part of the traffic class
|
||||
* field.
|
||||
*/
|
||||
static inline void ipv6_hdr_set_tc_dscp(ipv6_hdr_t *hdr, uint8_t dscp)
|
||||
|
@ -10,7 +10,7 @@
|
||||
* @defgroup net_netopt Configuration options for network APIs
|
||||
* @ingroup net
|
||||
* @brief List of available configuration options for the
|
||||
* @ref net_ng_netdev and the @ref net_ng_netapi
|
||||
* @ref net_gnrc_netdev and the @ref net_gnrc_netapi
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -80,7 +80,7 @@ typedef enum {
|
||||
/**
|
||||
* @brief en/disable preloading or read the current state.
|
||||
*
|
||||
* Preload using ng_netdev_driver_t::send_data() or ng_netapi_send()
|
||||
* Preload using gnrc_netdev_driver_t::send_data() or gnrc_netapi_send()
|
||||
* respectively, send setting state to @ref NETOPT_STATE_TX
|
||||
*/
|
||||
NETOPT_PRELOADING,
|
||||
@ -91,12 +91,12 @@ typedef enum {
|
||||
NETOPT_RETRANS, /**< get/set the maximum number of
|
||||
* retransmissions. */
|
||||
NETOPT_PROTO, /**< get/set the protocol for the layer
|
||||
* as type ng_nettype_t. */
|
||||
* as type gnrc_nettype_t. */
|
||||
NETOPT_STATE, /**< get/set the state of network devices as
|
||||
* type netopt_state_t */
|
||||
NETOPT_RAWMODE, /**< en/disable the pre-processing of data
|
||||
* in a network device driver as type
|
||||
* ng_nettype_t */
|
||||
* gnrc_nettype_t */
|
||||
/**
|
||||
* @brief en/disable the interrupt at reception start.
|
||||
*
|
||||
|
@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "clist.h"
|
||||
#include "utlist.h"
|
||||
#include "net/ng_netreg.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_icmpv6.h"
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ng_udp.h"
|
||||
|
||||
#define _INVALID_TYPE(type) (((type) < NG_NETTYPE_UNDEF) || ((type) >= NG_NETTYPE_NUMOF))
|
||||
|
||||
/* The registry as lookup table by ng_nettype_t */
|
||||
static ng_netreg_entry_t *netreg[NG_NETTYPE_NUMOF];
|
||||
|
||||
void ng_netreg_init(void)
|
||||
{
|
||||
/* set all pointers in registry to NULL */
|
||||
memset(netreg, 0, NG_NETTYPE_NUMOF * sizeof(ng_netreg_entry_t *));
|
||||
}
|
||||
|
||||
int ng_netreg_register(ng_nettype_t type, ng_netreg_entry_t *entry)
|
||||
{
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
LL_PREPEND(netreg[type], entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ng_netreg_unregister(ng_nettype_t type, ng_netreg_entry_t *entry)
|
||||
{
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LL_DELETE(netreg[type], entry);
|
||||
}
|
||||
|
||||
ng_netreg_entry_t *ng_netreg_lookup(ng_nettype_t type, uint32_t demux_ctx)
|
||||
{
|
||||
ng_netreg_entry_t *res;
|
||||
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LL_SEARCH_SCALAR(netreg[type], res, demux_ctx, demux_ctx);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ng_netreg_num(ng_nettype_t type, uint32_t demux_ctx)
|
||||
{
|
||||
int num = 0;
|
||||
ng_netreg_entry_t *entry;
|
||||
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry = netreg[type];
|
||||
|
||||
while (entry != NULL) {
|
||||
if (entry->demux_ctx == demux_ctx) {
|
||||
num++;
|
||||
}
|
||||
|
||||
entry = entry->next;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
ng_netreg_entry_t *ng_netreg_getnext(ng_netreg_entry_t *entry)
|
||||
{
|
||||
uint32_t demux_ctx;
|
||||
|
||||
if (entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
demux_ctx = entry->demux_ctx;
|
||||
|
||||
LL_SEARCH_SCALAR(entry->next, entry, demux_ctx, demux_ctx);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
int ng_netreg_calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr)
|
||||
{
|
||||
if (pseudo_hdr == NULL) {
|
||||
/* XXX: Might be allowed for future checksums.
|
||||
* If this is the case: move this to the branches were it
|
||||
* is needed. */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (hdr->type) {
|
||||
#ifdef MODULE_NG_ICMPV6
|
||||
case NG_NETTYPE_ICMPV6:
|
||||
return ng_icmpv6_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
#ifdef MODULE_NG_TCP
|
||||
case NG_NETTYPE_TCP:
|
||||
return ng_tcp_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
case NG_NETTYPE_UDP:
|
||||
return ng_udp_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
ng_pktsnip_t *ng_netreg_hdr_build(ng_nettype_t type, ng_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef MODULE_NG_IPV6
|
||||
|
||||
case NG_NETTYPE_IPV6:
|
||||
return ng_ipv6_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
#ifdef MODULE_NG_TCP
|
||||
|
||||
case NG_NETTYPE_TCP:
|
||||
return ng_tcp_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
#ifdef MODULE_NG_UDP
|
||||
|
||||
case NG_NETTYPE_UDP:
|
||||
return ng_udp_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
|
||||
default:
|
||||
(void)payload;
|
||||
(void)src;
|
||||
(void)src_len;
|
||||
(void)dst;
|
||||
(void)dst_len;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
@ -1 +0,0 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1,259 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "msg.h"
|
||||
#include "mutex.h"
|
||||
#include "net/ng_netapi.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/netopt.h"
|
||||
#include "net/ng_netreg.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "timex.h"
|
||||
#include "thread.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#include "net/ng_nettest.h"
|
||||
|
||||
static ng_nettest_opt_cbs_t _opt_cbs[NETOPT_NUMOF];
|
||||
static mutex_t _mutex = MUTEX_INIT;
|
||||
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
|
||||
static char _stack[NG_NETTEST_STACK_SIZE];
|
||||
|
||||
static void *_event_loop(void *arg);
|
||||
|
||||
void ng_nettest_register_get(netopt_t opt, ng_nettest_opt_cb_t cb)
|
||||
{
|
||||
mutex_lock(&_mutex);
|
||||
_opt_cbs[opt].get = cb;
|
||||
mutex_unlock(&_mutex);
|
||||
}
|
||||
|
||||
void ng_nettest_register_set(netopt_t opt, ng_nettest_opt_cb_t cb)
|
||||
{
|
||||
mutex_lock(&_mutex);
|
||||
_opt_cbs[opt].set = cb;
|
||||
mutex_unlock(&_mutex);
|
||||
}
|
||||
|
||||
static ng_nettest_res_t _pkt_test(uint16_t cmd_type, kernel_pid_t pid,
|
||||
ng_pktsnip_t *in, unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out)
|
||||
{
|
||||
msg_t msg;
|
||||
timex_t t = { 0, NG_NETTEST_TIMEOUT };
|
||||
ng_nettest_res_t res = NG_NETTEST_SUCCESS;
|
||||
|
||||
msg.type = cmd_type;
|
||||
msg.content.ptr = (char *)in;
|
||||
|
||||
msg_send(&msg, pid);
|
||||
timex_normalize(&t);
|
||||
|
||||
if (exp_pkts == 0) {
|
||||
thread_yield();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < exp_pkts; i++) {
|
||||
ng_pktsnip_t *out;
|
||||
const ng_pktsnip_t *exp = exp_out[i];
|
||||
|
||||
if (vtimer_msg_receive_timeout(&msg, t) < 0) {
|
||||
return NG_NETTEST_TIMED_OUT;
|
||||
}
|
||||
|
||||
if (msg.type != cmd_type) {
|
||||
return NG_NETTEST_WRONG_MSG;
|
||||
}
|
||||
|
||||
if (msg.sender_pid != exp_senders[i]) {
|
||||
return NG_NETTEST_WRONG_SENDER;
|
||||
}
|
||||
|
||||
out = (ng_pktsnip_t *)msg.content.ptr;
|
||||
|
||||
if (out == NULL) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
while (out && exp) {
|
||||
if ((out->users != exp->users) ||
|
||||
(out->size != exp->size) ||
|
||||
(out->type != exp->type) ||
|
||||
(memcmp(out->data, exp->data, out->size) != 0)) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
out = out->next;
|
||||
exp = exp->next;
|
||||
}
|
||||
|
||||
ng_pktbuf_release((ng_pktsnip_t *)msg.content.ptr);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ng_nettest_res_t ng_nettest_send(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out,
|
||||
ng_nettype_t exp_type, uint32_t exp_demux_ctx)
|
||||
{
|
||||
ng_netreg_entry_t reg_entry = { NULL, exp_demux_ctx, thread_getpid() };
|
||||
ng_nettest_res_t res;
|
||||
|
||||
ng_netreg_register(exp_type, ®_entry);
|
||||
|
||||
res = _pkt_test(NG_NETAPI_MSG_TYPE_SND, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
ng_netreg_unregister(exp_type, ®_entry);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ng_nettest_res_t ng_nettest_send_iface(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out)
|
||||
{
|
||||
ng_nettest_res_t res;
|
||||
|
||||
ng_netif_add(thread_getpid());
|
||||
|
||||
res = _pkt_test(NG_NETAPI_MSG_TYPE_SND, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
ng_netif_remove(thread_getpid());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ng_nettest_res_t ng_nettest_receive(kernel_pid_t pid, ng_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const ng_pktsnip_t **exp_out,
|
||||
ng_nettype_t exp_type, uint32_t exp_demux_ctx)
|
||||
{
|
||||
ng_netreg_entry_t reg_entry = { NULL, exp_demux_ctx, thread_getpid() };
|
||||
ng_nettest_res_t res;
|
||||
|
||||
ng_netreg_register(exp_type, ®_entry);
|
||||
|
||||
res = _pkt_test(NG_NETAPI_MSG_TYPE_RCV, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
ng_netreg_unregister(exp_type, ®_entry);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
void *exp_data, int exp_res)
|
||||
{
|
||||
if ((exp_res != ng_netapi_get(pid, opt, context, data, data_len)) ||
|
||||
((exp_res > 0) && (memcpy(exp_data, data, exp_res)))) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
return NG_NETTEST_SUCCESS;
|
||||
}
|
||||
|
||||
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
int exp_res)
|
||||
{
|
||||
if (exp_res != ng_netapi_get(pid, opt, context, data, data_len)) {
|
||||
return NG_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
return NG_NETTEST_SUCCESS;
|
||||
}
|
||||
|
||||
int ng_nettest_init(void)
|
||||
{
|
||||
if (_pid <= KERNEL_PID_UNDEF) {
|
||||
_pid = thread_create(_stack, sizeof(_stack), NG_NETTEST_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, NULL, "nettest");
|
||||
}
|
||||
|
||||
return _pid;
|
||||
}
|
||||
|
||||
void ng_nettest_reset(void)
|
||||
{
|
||||
for (int i = 0; i < NETOPT_NUMOF; i++) {
|
||||
_opt_cbs[i].get = NULL;
|
||||
_opt_cbs[i].set = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t _get_set_opt(ng_nettest_opt_cb_t cb, uint16_t context,
|
||||
void *data, uint16_t data_len)
|
||||
{
|
||||
int res;
|
||||
|
||||
mutex_lock(&_mutex);
|
||||
if (cb != NULL) {
|
||||
res = cb(context, data, data_len);
|
||||
}
|
||||
else {
|
||||
res = -ENOTSUP;
|
||||
}
|
||||
mutex_unlock(&_mutex);
|
||||
return (uint32_t)res;
|
||||
}
|
||||
|
||||
static void *_event_loop(void *arg)
|
||||
{
|
||||
msg_t reply, msg_queue[NG_NETTEST_MSG_QUEUE_SIZE];
|
||||
|
||||
(void)arg;
|
||||
msg_init_queue(msg_queue, NG_NETTEST_MSG_QUEUE_SIZE);
|
||||
reply.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
|
||||
while (1) {
|
||||
msg_t msg;
|
||||
ng_netapi_opt_t *opt;
|
||||
|
||||
msg_receive(&msg);
|
||||
|
||||
switch (msg.type) {
|
||||
case NG_NETAPI_MSG_TYPE_GET:
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
reply.content.value = _get_set_opt(_opt_cbs[opt->opt].get,
|
||||
opt->context, opt->data,
|
||||
opt->data_len);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_SET:
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
reply.content.value = _get_set_opt(_opt_cbs[opt->opt].set,
|
||||
opt->context, opt->data,
|
||||
opt->data_len);
|
||||
break;
|
||||
}
|
||||
|
||||
msg_reply(&msg, &reply);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** @} */
|
@ -1 +0,0 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1 +0,0 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1 +1,89 @@
|
||||
ifneq (,$(filter gnrc_icmpv6,$(USEMODULE)))
|
||||
DIRS += network_layer/icmpv6
|
||||
endif
|
||||
ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
|
||||
DIRS += network_layer/icmpv6/echo
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_ext,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6/ext
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_hdr,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6/hdr
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_nc,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6/nc
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6/netif
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ndp,$(USEMODULE)))
|
||||
DIRS += network_layer/ndp
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ndp_internal,$(USEMODULE)))
|
||||
DIRS += network_layer/ndp/internal
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ndp_node,$(USEMODULE)))
|
||||
DIRS += network_layer/ndp/node
|
||||
endif
|
||||
ifneq (,$(filter gnrc_netapi,$(USEMODULE)))
|
||||
DIRS += netapi
|
||||
endif
|
||||
ifneq (,$(filter gnrc_netdev_eth,$(USEMODULE)))
|
||||
DIRS += link_layer/netdev_eth
|
||||
endif
|
||||
ifneq (,$(filter gnrc_netif,$(USEMODULE)))
|
||||
DIRS += netif
|
||||
endif
|
||||
ifneq (,$(filter gnrc_netif_hdr,$(USEMODULE)))
|
||||
DIRS += netif/hdr
|
||||
endif
|
||||
ifneq (,$(filter gnrc_netreg,$(USEMODULE)))
|
||||
DIRS += netreg
|
||||
endif
|
||||
ifneq (,$(filter gnrc_nettest,$(USEMODULE)))
|
||||
DIRS += nettest
|
||||
endif
|
||||
ifneq (,$(filter gnrc_nomac,$(USEMODULE)))
|
||||
DIRS += link_layer/nomac
|
||||
endif
|
||||
ifneq (,$(filter gnrc_pktbuf_static,$(USEMODULE)))
|
||||
DIRS += pktbuf_static
|
||||
endif
|
||||
ifneq (,$(filter gnrc_pktdump,$(USEMODULE)))
|
||||
DIRS += pktdump
|
||||
endif
|
||||
ifneq (,$(filter gnrc_rpl,$(USEMODULE)))
|
||||
DIRS += routing/rpl
|
||||
endif
|
||||
ifneq (,$(filter gnrc_rpl_srh,$(USEMODULE)))
|
||||
DIRS += routing/rpl/srh
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan,$(USEMODULE)))
|
||||
DIRS += network_layer/sixlowpan
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan_ctx,$(USEMODULE)))
|
||||
DIRS += network_layer/sixlowpan/ctx
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan_frag,$(USEMODULE)))
|
||||
DIRS += network_layer/sixlowpan/frag
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan_iphc,$(USEMODULE)))
|
||||
DIRS += network_layer/sixlowpan/iphc
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan_netif,$(USEMODULE)))
|
||||
DIRS += network_layer/sixlowpan/netif
|
||||
endif
|
||||
ifneq (,$(filter gnrc_slip,$(USEMODULE)))
|
||||
DIRS += link_layer/slip
|
||||
endif
|
||||
ifneq (,$(filter gnrc_udp,$(USEMODULE)))
|
||||
DIRS += transport_layer/udp
|
||||
endif
|
||||
ifneq (,$(filter gnrc_zep,$(USEMODULE)))
|
||||
DIRS += application_layer/zep
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1 +1,3 @@
|
||||
MODULE = gnrc_zep
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_ng_zep
|
||||
* @ingroup net_gnrc_zep
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -25,14 +25,14 @@
|
||||
#include "msg.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/gnrc/ipv6/hdr.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "net/ng_udp.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "periph/cpuid.h"
|
||||
#include "random.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#include "net/ng_zep.h"
|
||||
#include "net/gnrc/zep.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
@ -44,23 +44,23 @@
|
||||
|
||||
#define _EVENT_RX_STARTED (1)
|
||||
#define _EVENT_RX_COMPLETE (2)
|
||||
#define _RX_BUF_SIZE (16U * sizeof(ng_pktsnip_t *))
|
||||
#define _RX_BUF_SIZE (16U * sizeof(gnrc_pktsnip_t *))
|
||||
#define IEEE_802154_FCS_POLY (0x8408) /* x^16 + x^12 + x^5 + 1 for LSB first */
|
||||
|
||||
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
|
||||
static char _rx_stack[NG_ZEP_STACK_SIZE];
|
||||
static char _rx_stack[GNRC_ZEP_STACK_SIZE];
|
||||
static char _rx_buf_array[_RX_BUF_SIZE];
|
||||
static ringbuffer_t _rx_buf = RINGBUFFER_INIT(_rx_buf_array);
|
||||
|
||||
/* ng_netdev driver definitions */
|
||||
static int _send(ng_netdev_t *dev, ng_pktsnip_t *pkt);
|
||||
static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
static void _isr_event(ng_netdev_t *dev, uint32_t event_type);
|
||||
/* gnrc_netdev driver definitions */
|
||||
static int _send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt);
|
||||
static int _add_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
static int _rem_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
static int _get(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
static int _set(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
static void _isr_event(gnrc_netdev_t *dev, uint32_t event_type);
|
||||
|
||||
static const ng_netdev_driver_t _zep_driver = {
|
||||
static const gnrc_netdev_driver_t _zep_driver = {
|
||||
_send,
|
||||
_add_cb,
|
||||
_rem_cb,
|
||||
@ -73,24 +73,24 @@ static const ng_netdev_driver_t _zep_driver = {
|
||||
void *_event_loop(void *args);
|
||||
|
||||
/* Builds (uninitialized) ZEP packet according to configured version */
|
||||
static ng_pktsnip_t *_zep_hdr_build(ng_zep_t *dev, size_t size, bool ack);
|
||||
static gnrc_pktsnip_t *_zep_hdr_build(gnrc_zep_t *dev, size_t size, bool ack);
|
||||
|
||||
/* Fills ZEP header according to ng_zep_t configuration */
|
||||
static size_t _zep_hdr_fill(ng_zep_t *dev, ng_zep_hdr_t *hdr,
|
||||
/* Fills ZEP header according to gnrc_zep_t configuration */
|
||||
static size_t _zep_hdr_fill(gnrc_zep_t *dev, gnrc_zep_hdr_t *hdr,
|
||||
size_t payload_len);
|
||||
|
||||
/* Event handlers for ISR events */
|
||||
static void _rx_started_event(ng_zep_t *dev);
|
||||
static void _rx_started_event(gnrc_zep_t *dev);
|
||||
|
||||
/* IEEE 802.15.4 helper functions: TODO: generalize add to (gnrc_)ieee802154 */
|
||||
static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
ng_netif_hdr_t *hdr);
|
||||
static size_t _make_data_frame_hdr(gnrc_zep_t *dev, uint8_t *buf,
|
||||
gnrc_netif_hdr_t *hdr);
|
||||
static size_t _get_frame_hdr_len(uint8_t *mhr);
|
||||
ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr);
|
||||
gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr);
|
||||
static uint16_t _calc_fcs(uint16_t fcs, const uint8_t *frame, uint8_t frame_len);
|
||||
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port)
|
||||
kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port)
|
||||
{
|
||||
#if CPUID_ID_LEN
|
||||
uint8_t cpuid[CPUID_ID_LEN];
|
||||
@ -112,15 +112,15 @@ kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (ng_netreg_lookup(NG_NETTYPE_UDP, src_port)) {
|
||||
if (gnrc_netreg_lookup(GNRC_NETTYPE_UDP, src_port)) {
|
||||
DEBUG("zep: port (%" PRIu16 ") already registered\n", src_port);
|
||||
return -EADDRINUSE;
|
||||
}
|
||||
|
||||
dev->driver = (ng_netdev_driver_t *)&_zep_driver;
|
||||
dev->chan = NG_ZEP_DEFAULT_CHANNEL;
|
||||
dev->pan = byteorder_btols(byteorder_htons(NG_ZEP_DEFAULT_PANID));
|
||||
dev->flags = NG_ZEP_FLAGS_USE_SRC_PAN;
|
||||
dev->driver = (gnrc_netdev_driver_t *)&_zep_driver;
|
||||
dev->chan = GNRC_ZEP_DEFAULT_CHANNEL;
|
||||
dev->pan = byteorder_btols(byteorder_htons(GNRC_ZEP_DEFAULT_PANID));
|
||||
dev->flags = GNRC_ZEP_FLAGS_USE_SRC_PAN;
|
||||
#if CPUID_ID_LEN
|
||||
/* initialize dev->addr and dev->eui64 from cpuid if available */
|
||||
cpuid_get(cpuid);
|
||||
@ -141,18 +141,18 @@ kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
dev->eui64.u8[7] &= 0xfe; /* set to unicast */
|
||||
dev->eui64.u8[7] |= 0x02; /* set to locally administered */
|
||||
#else
|
||||
dev->addr = NG_ZEP_DEFAULT_ADDR_SHORT;
|
||||
dev->eui64 = NG_ZEP_DEFAULT_ADDR_LONG;
|
||||
dev->addr = GNRC_ZEP_DEFAULT_ADDR_SHORT;
|
||||
dev->eui64 = GNRC_ZEP_DEFAULT_ADDR_LONG;
|
||||
#endif
|
||||
DEBUG("zep: initialized radio parameters: chan: %" PRIu8 ", pan: 0x%04" PRIx16
|
||||
"addr: 0x%04" PRIx16 ", eui64: %016" PRIx64 "\n", dev->chan,
|
||||
dev->pan, byteorder_ltobs(dev->addr).u16,
|
||||
byteorder_ltobll(dev->eui64).u64);
|
||||
|
||||
#ifdef MODULE_NG_SIXLOWPAN
|
||||
dev->proto = NG_NETTYPE_SIXLOWPAN;
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN
|
||||
dev->proto = GNRC_NETTYPE_SIXLOWPAN;
|
||||
#else
|
||||
dev->proto = NG_NETTYPE_UNDEF;
|
||||
dev->proto = GNRC_NETTYPE_UNDEF;
|
||||
#endif
|
||||
|
||||
dev->seq = genrand_uint32();
|
||||
@ -163,7 +163,7 @@ kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
dev->version = 2;
|
||||
dev->lqi_mode = 1;
|
||||
|
||||
_pid = thread_create(_rx_stack, NG_ZEP_STACK_SIZE, NG_ZEP_PRIO,
|
||||
_pid = thread_create(_rx_stack, GNRC_ZEP_STACK_SIZE, GNRC_ZEP_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, dev, "zep_app");
|
||||
|
||||
DEBUG("zep: started thread with PID %" PRIkernel_pid "\n", _pid);
|
||||
@ -203,27 +203,27 @@ static inline uint64_t *_get_uint64_ptr(void *ptr)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
static int _send(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
ng_zep_t *dev = (ng_zep_t *)netdev;
|
||||
ng_pktsnip_t *ptr, *new_pkt, *hdr;
|
||||
ng_zep_hdr_t *zep;
|
||||
size_t payload_len = ng_pkt_len(pkt->next), hdr_len, mhr_offset;
|
||||
gnrc_zep_t *dev = (gnrc_zep_t *)netdev;
|
||||
gnrc_pktsnip_t *ptr, *new_pkt, *hdr;
|
||||
gnrc_zep_hdr_t *zep;
|
||||
size_t payload_len = gnrc_pkt_len(pkt->next), hdr_len, mhr_offset;
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN], *data;
|
||||
uint16_t fcs = 0;
|
||||
|
||||
if ((netdev == NULL) || (netdev->driver != &_zep_driver)) {
|
||||
DEBUG("zep: wrong device on sending\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* create 802.15.4 header */
|
||||
hdr_len = _make_data_frame_hdr(dev, mhr, (ng_netif_hdr_t *)pkt->data);
|
||||
hdr_len = _make_data_frame_hdr(dev, mhr, (gnrc_netif_hdr_t *)pkt->data);
|
||||
|
||||
if (hdr_len == 0) {
|
||||
DEBUG("zep: error on frame creation\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
@ -231,31 +231,31 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
|
||||
if (new_pkt == NULL) {
|
||||
DEBUG("zep: could not allocate ZEP header in pktbuf\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
zep = new_pkt->data;
|
||||
|
||||
hdr = ng_udp_hdr_build(new_pkt, (uint8_t *)(&(dev->src_port)), sizeof(uint16_t),
|
||||
(uint8_t *)(&(dev->dst_port)), sizeof(uint16_t));
|
||||
hdr = gnrc_udp_hdr_build(new_pkt, (uint8_t *)(&(dev->src_port)), sizeof(uint16_t),
|
||||
(uint8_t *)(&(dev->dst_port)), sizeof(uint16_t));
|
||||
|
||||
if (hdr == NULL) {
|
||||
DEBUG("zep: could not allocate UDP header in pktbuf\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
ng_pktbuf_release(new_pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(new_pkt);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
new_pkt = hdr;
|
||||
|
||||
hdr = ng_ipv6_hdr_build(new_pkt, NULL, 0, (uint8_t *) &(dev->dst),
|
||||
sizeof(ipv6_addr_t));
|
||||
hdr = gnrc_ipv6_hdr_build(new_pkt, NULL, 0, (uint8_t *) &(dev->dst),
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
if (hdr == NULL) {
|
||||
DEBUG("zep: could not allocate IPv6 header in pktbuf\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
ng_pktbuf_release(new_pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(new_pkt);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
@ -265,8 +265,8 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
|
||||
if (mhr_offset == 0) {
|
||||
DEBUG("zep: error filling ZEP header\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
ng_pktbuf_release(new_pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(new_pkt);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -283,21 +283,21 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
|
||||
DEBUG("zep: set frame FCS to 0x%04 " PRIx16 "\n", fcs);
|
||||
_set_uint16_ptr((uint16_t *)data, byteorder_btols(byteorder_htons(fcs)).u16);
|
||||
|
||||
if (!ng_netapi_dispatch_send(NG_NETTYPE_UDP, NG_NETREG_DEMUX_CTX_ALL, new_pkt)) {
|
||||
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL, new_pkt)) {
|
||||
DEBUG("zep: no UDP handler found: dropping packet\n");
|
||||
ng_pktbuf_release(new_pkt);
|
||||
gnrc_pktbuf_release(new_pkt);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return payload_len + hdr_len + IEEE802154_FCS_LEN;
|
||||
}
|
||||
|
||||
static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _add_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if ((dev == NULL) || (dev->driver != &_zep_driver)) {
|
||||
return -ENODEV;
|
||||
@ -312,7 +312,7 @@ static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _rem_cb(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
if ((dev == NULL) || (dev->driver != &_zep_driver)) {
|
||||
return -ENODEV;
|
||||
@ -327,9 +327,9 @@ static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
static int _get(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
{
|
||||
ng_zep_t *dev = (ng_zep_t *)netdev;
|
||||
gnrc_zep_t *dev = (gnrc_zep_t *)netdev;
|
||||
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -365,7 +365,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
if (dev->flags & NG_ZEP_FLAGS_DST_ADDR_LONG) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_DST_ADDR_LONG) {
|
||||
_set_uint16_ptr(value, 8);
|
||||
}
|
||||
else {
|
||||
@ -379,7 +379,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
if (dev->flags & NG_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
_set_uint16_ptr(value, 8);
|
||||
}
|
||||
else {
|
||||
@ -389,12 +389,12 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
return sizeof(uint16_t);
|
||||
|
||||
case NETOPT_PROTO:
|
||||
if (max_len < sizeof(ng_nettype_t)) {
|
||||
if (max_len < sizeof(gnrc_nettype_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
*((ng_nettype_t *)value) = dev->proto;
|
||||
return sizeof(ng_nettype_t);
|
||||
*((gnrc_nettype_t *)value) = dev->proto;
|
||||
return sizeof(gnrc_nettype_t);
|
||||
|
||||
case NETOPT_NID:
|
||||
if (max_len < sizeof(uint16_t)) {
|
||||
@ -408,7 +408,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
if (max_len < sizeof(eui64_t)) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
if (dev->flags & NG_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
uint64_t addr = byteorder_ltobll(dev->eui64).u64;
|
||||
ieee802154_get_iid(value, (uint8_t *)&addr, 8);
|
||||
}
|
||||
@ -423,7 +423,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
_set_uint16_ptr(value, NG_ZEP_MAX_PKT_LENGTH);
|
||||
_set_uint16_ptr(value, GNRC_ZEP_MAX_PKT_LENGTH);
|
||||
return sizeof(uint16_t);
|
||||
|
||||
case NETOPT_AUTOACK:
|
||||
@ -431,7 +431,7 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
_set_flag_ptr(value, dev->flags, NG_ZEP_FLAGS_AUTOACK);
|
||||
_set_flag_ptr(value, dev->flags, GNRC_ZEP_FLAGS_AUTOACK);
|
||||
return sizeof(uint16_t);
|
||||
|
||||
default:
|
||||
@ -439,9 +439,9 @@ static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
}
|
||||
}
|
||||
|
||||
static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
static int _set(gnrc_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
|
||||
{
|
||||
ng_zep_t *dev = (ng_zep_t *)netdev;
|
||||
gnrc_zep_t *dev = (gnrc_zep_t *)netdev;
|
||||
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
@ -453,8 +453,8 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
if ((*_get_uint16_ptr(value) < NG_ZEP_MIN_CHANNEL) ||
|
||||
(*_get_uint16_ptr(value)) > NG_ZEP_MAX_CHANNEL) {
|
||||
if ((*_get_uint16_ptr(value) < GNRC_ZEP_MIN_CHANNEL) ||
|
||||
(*_get_uint16_ptr(value)) > GNRC_ZEP_MAX_CHANNEL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
@ -490,11 +490,11 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
|
||||
switch (*_get_uint16_ptr(value)) {
|
||||
case 2:
|
||||
dev->flags &= ~NG_ZEP_FLAGS_DST_ADDR_LONG;
|
||||
dev->flags &= ~GNRC_ZEP_FLAGS_DST_ADDR_LONG;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
dev->flags |= NG_ZEP_FLAGS_DST_ADDR_LONG;
|
||||
dev->flags |= GNRC_ZEP_FLAGS_DST_ADDR_LONG;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -510,11 +510,11 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
|
||||
switch (*_get_uint16_ptr(value)) {
|
||||
case 2:
|
||||
dev->flags &= ~NG_ZEP_FLAGS_SRC_ADDR_LONG;
|
||||
dev->flags &= ~GNRC_ZEP_FLAGS_SRC_ADDR_LONG;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
dev->flags |= NG_ZEP_FLAGS_SRC_ADDR_LONG;
|
||||
dev->flags |= GNRC_ZEP_FLAGS_SRC_ADDR_LONG;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -539,7 +539,7 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
_set_flag_ptr(value, dev->flags, NG_ZEP_FLAGS_AUTOACK);
|
||||
_set_flag_ptr(value, dev->flags, GNRC_ZEP_FLAGS_AUTOACK);
|
||||
return sizeof(uint16_t);
|
||||
|
||||
default:
|
||||
@ -547,12 +547,12 @@ static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len
|
||||
}
|
||||
}
|
||||
|
||||
static void _isr_event(ng_netdev_t *dev, uint32_t event_type)
|
||||
static void _isr_event(gnrc_netdev_t *dev, uint32_t event_type)
|
||||
{
|
||||
switch (event_type) {
|
||||
case _EVENT_RX_STARTED:
|
||||
DEBUG("zep: ISR event: RX started\n");
|
||||
_rx_started_event((ng_zep_t *)dev);
|
||||
_rx_started_event((gnrc_zep_t *)dev);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -563,51 +563,51 @@ static void _isr_event(ng_netdev_t *dev, uint32_t event_type)
|
||||
|
||||
void *_event_loop(void *args)
|
||||
{
|
||||
msg_t msg, ack, msg_q[NG_ZEP_MSG_QUEUE_SIZE];
|
||||
ng_netdev_t *dev = (ng_netdev_t *)args;
|
||||
ng_netapi_opt_t *opt;
|
||||
ng_netreg_entry_t my_reg = { NULL, ((ng_zep_t *)args)->src_port,
|
||||
KERNEL_PID_UNDEF
|
||||
};
|
||||
msg_t msg, ack, msg_q[GNRC_ZEP_MSG_QUEUE_SIZE];
|
||||
gnrc_netdev_t *dev = (gnrc_netdev_t *)args;
|
||||
gnrc_netapi_opt_t *opt;
|
||||
gnrc_netreg_entry_t my_reg = { NULL, ((gnrc_zep_t *)args)->src_port,
|
||||
KERNEL_PID_UNDEF
|
||||
};
|
||||
|
||||
if (msg_init_queue(msg_q, NG_ZEP_MSG_QUEUE_SIZE)) {
|
||||
if (msg_init_queue(msg_q, GNRC_ZEP_MSG_QUEUE_SIZE)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
my_reg.pid = thread_getpid();
|
||||
|
||||
ng_netreg_register(NG_NETTYPE_UDP, &my_reg);
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UDP, &my_reg);
|
||||
|
||||
while (1) {
|
||||
msg_receive(&msg);
|
||||
|
||||
switch (msg.type) {
|
||||
case NG_NETAPI_MSG_TYPE_RCV:
|
||||
DEBUG("zep: NG_NETAPI_MSG_TYPE_RCV\n");
|
||||
case GNRC_NETAPI_MSG_TYPE_RCV:
|
||||
DEBUG("zep: GNRC_NETAPI_MSG_TYPE_RCV\n");
|
||||
ringbuffer_add(&_rx_buf, (char *)(&msg.content.ptr),
|
||||
sizeof(ng_pktsnip_t *));
|
||||
ack.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
sizeof(gnrc_pktsnip_t *));
|
||||
ack.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
ack.content.value = _EVENT_RX_STARTED;
|
||||
msg_send_int(&ack, dev->mac_pid);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("zep: NG_NETAPI_MSG_TYPE_SND\n");
|
||||
_send(dev, (ng_pktsnip_t *)msg.content.ptr);
|
||||
case GNRC_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("zep: GNRC_NETAPI_MSG_TYPE_SND\n");
|
||||
_send(dev, (gnrc_pktsnip_t *)msg.content.ptr);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_GET:
|
||||
DEBUG("zep: NG_NETAPI_MSG_TYPE_GET\n");
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
ack.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
case GNRC_NETAPI_MSG_TYPE_GET:
|
||||
DEBUG("zep: GNRC_NETAPI_MSG_TYPE_GET\n");
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
ack.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
ack.content.value = _get(dev, opt->opt, opt->data, opt->data_len);
|
||||
msg_reply(&msg, &ack);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_SET:
|
||||
DEBUG("zep: NG_NETAPI_MSG_TYPE_SET\n");
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
ack.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||
DEBUG("zep: GNRC_NETAPI_MSG_TYPE_SET\n");
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
ack.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
ack.content.value = _set(dev, opt->opt, opt->data, opt->data_len);
|
||||
msg_reply(&msg, &ack);
|
||||
break;
|
||||
@ -622,27 +622,27 @@ void *_event_loop(void *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ng_pktsnip_t *_zep_hdr_build(ng_zep_t *dev, size_t size, bool ack)
|
||||
static gnrc_pktsnip_t *_zep_hdr_build(gnrc_zep_t *dev, size_t size, bool ack)
|
||||
{
|
||||
ng_pktsnip_t *zep;
|
||||
gnrc_pktsnip_t *zep;
|
||||
|
||||
switch (dev->version) {
|
||||
case 1:
|
||||
DEBUG("zep: Build ZEPv1 data header in pktbuf\n");
|
||||
zep = ng_pktbuf_add(NULL, NULL, sizeof(ng_zep_v1_hdr_t) + size,
|
||||
NG_NETTYPE_UNDEF);
|
||||
zep = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_zep_v1_hdr_t) + size,
|
||||
GNRC_NETTYPE_UNDEF);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (ack) {
|
||||
DEBUG("zep: Build ZEPv2 ACK header in pktbuf\n");
|
||||
zep = ng_pktbuf_add(NULL, NULL, sizeof(ng_zep_v2_ack_hdr_t) + size,
|
||||
NG_NETTYPE_UNDEF);
|
||||
zep = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_zep_v2_ack_hdr_t) + size,
|
||||
GNRC_NETTYPE_UNDEF);
|
||||
}
|
||||
else {
|
||||
DEBUG("zep: Build ZEPv2 data header in pktbuf\n");
|
||||
zep = ng_pktbuf_add(NULL, NULL, sizeof(ng_zep_v2_data_hdr_t) + size,
|
||||
NG_NETTYPE_UNDEF);
|
||||
zep = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_zep_v2_data_hdr_t) + size,
|
||||
GNRC_NETTYPE_UNDEF);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -655,21 +655,21 @@ static ng_pktsnip_t *_zep_hdr_build(ng_zep_t *dev, size_t size, bool ack)
|
||||
return zep;
|
||||
}
|
||||
|
||||
static inline size_t _zep_hdr_fill_v1(ng_zep_t *dev, ng_zep_v1_hdr_t *hdr,
|
||||
static inline size_t _zep_hdr_fill_v1(gnrc_zep_t *dev, gnrc_zep_v1_hdr_t *hdr,
|
||||
size_t payload_len)
|
||||
{
|
||||
hdr->version = 1;
|
||||
hdr->chan = dev->chan - NG_ZEP_MIN_CHANNEL;
|
||||
hdr->chan = dev->chan - GNRC_ZEP_MIN_CHANNEL;
|
||||
hdr->dev = byteorder_htons(1);
|
||||
hdr->lqi_mode = dev->lqi_mode;
|
||||
hdr->lqi_val = 0xff; /* TODO: set */
|
||||
memset(hdr->resv, 0, sizeof(hdr->resv));
|
||||
hdr->length = payload_len;
|
||||
|
||||
return sizeof(ng_zep_v1_hdr_t);
|
||||
return sizeof(gnrc_zep_v1_hdr_t);
|
||||
}
|
||||
|
||||
static size_t _zep_hdr_fill_v2_data(ng_zep_t *dev, ng_zep_v2_data_hdr_t *hdr,
|
||||
static size_t _zep_hdr_fill_v2_data(gnrc_zep_t *dev, gnrc_zep_v2_data_hdr_t *hdr,
|
||||
size_t payload_len)
|
||||
{
|
||||
uint32_t epoch_sec;
|
||||
@ -677,8 +677,8 @@ static size_t _zep_hdr_fill_v2_data(ng_zep_t *dev, ng_zep_v2_data_hdr_t *hdr,
|
||||
epoch_sec = (uint32_t)time(NULL);
|
||||
|
||||
hdr->version = 2;
|
||||
hdr->type = NG_ZEP_V2_TYPE_DATA;
|
||||
hdr->chan = dev->chan - NG_ZEP_MIN_CHANNEL;
|
||||
hdr->type = GNRC_ZEP_V2_TYPE_DATA;
|
||||
hdr->chan = dev->chan - GNRC_ZEP_MIN_CHANNEL;
|
||||
hdr->dev = byteorder_htons(1);
|
||||
hdr->lqi_mode = dev->lqi_mode;
|
||||
hdr->lqi_val = 0xff; /* TODO: set */
|
||||
@ -688,10 +688,10 @@ static size_t _zep_hdr_fill_v2_data(ng_zep_t *dev, ng_zep_v2_data_hdr_t *hdr,
|
||||
memset(hdr->resv, 0, sizeof(hdr->resv));
|
||||
hdr->length = payload_len;
|
||||
|
||||
return sizeof(ng_zep_v2_data_hdr_t);
|
||||
return sizeof(gnrc_zep_v2_data_hdr_t);
|
||||
}
|
||||
|
||||
static size_t _zep_hdr_fill(ng_zep_t *dev, ng_zep_hdr_t *hdr,
|
||||
static size_t _zep_hdr_fill(gnrc_zep_t *dev, gnrc_zep_hdr_t *hdr,
|
||||
size_t payload_len)
|
||||
{
|
||||
hdr->preamble[0] = 'E';
|
||||
@ -699,10 +699,10 @@ static size_t _zep_hdr_fill(ng_zep_t *dev, ng_zep_hdr_t *hdr,
|
||||
|
||||
switch (dev->version) {
|
||||
case 1:
|
||||
return _zep_hdr_fill_v1(dev, (ng_zep_v1_hdr_t *)hdr, payload_len);
|
||||
return _zep_hdr_fill_v1(dev, (gnrc_zep_v1_hdr_t *)hdr, payload_len);
|
||||
|
||||
case 2:
|
||||
return _zep_hdr_fill_v2_data(dev, (ng_zep_v2_data_hdr_t *)hdr,
|
||||
return _zep_hdr_fill_v2_data(dev, (gnrc_zep_v2_data_hdr_t *)hdr,
|
||||
payload_len);
|
||||
break;
|
||||
|
||||
@ -711,11 +711,11 @@ static size_t _zep_hdr_fill(ng_zep_t *dev, ng_zep_hdr_t *hdr,
|
||||
}
|
||||
}
|
||||
|
||||
static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
|
||||
uint8_t lqi, uint8_t frame_len,
|
||||
uint8_t version)
|
||||
static gnrc_pktsnip_t *_create_received(gnrc_zep_t *dev, gnrc_pktsnip_t *pkt,
|
||||
uint8_t lqi, uint8_t frame_len,
|
||||
uint8_t version)
|
||||
{
|
||||
ng_pktsnip_t *payload, *mhr, *netif;
|
||||
gnrc_pktsnip_t *payload, *mhr, *netif;
|
||||
size_t mhr_len;
|
||||
|
||||
(void)version;
|
||||
@ -724,13 +724,13 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
payload = ng_pktbuf_mark(pkt, pkt->size - 2, dev->proto);
|
||||
payload = gnrc_pktbuf_mark(pkt, pkt->size - 2, dev->proto);
|
||||
|
||||
if (payload == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pkt = ng_pktbuf_remove_snip(pkt, pkt); /* remove FCS */
|
||||
pkt = gnrc_pktbuf_remove_snip(pkt, pkt); /* remove FCS */
|
||||
|
||||
mhr_len = _get_frame_hdr_len(pkt->data);
|
||||
|
||||
@ -738,78 +738,78 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mhr = ng_pktbuf_mark(pkt, mhr_len, NG_NETTYPE_UNDEF);
|
||||
mhr = gnrc_pktbuf_mark(pkt, mhr_len, GNRC_NETTYPE_UNDEF);
|
||||
|
||||
/* TODO: send ACK */
|
||||
|
||||
netif = _make_netif_hdr(mhr->data);
|
||||
|
||||
pkt = ng_pktbuf_remove_snip(pkt, mhr);
|
||||
pkt = gnrc_pktbuf_remove_snip(pkt, mhr);
|
||||
|
||||
((ng_netif_hdr_t *)netif->data)->if_pid = dev->mac_pid;
|
||||
((ng_netif_hdr_t *)netif->data)->lqi = lqi;
|
||||
((ng_netif_hdr_t *)netif->data)->rssi = 0;
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = dev->mac_pid;
|
||||
((gnrc_netif_hdr_t *)netif->data)->lqi = lqi;
|
||||
((gnrc_netif_hdr_t *)netif->data)->rssi = 0;
|
||||
|
||||
LL_APPEND(pkt, netif);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
static ng_pktsnip_t *_recv_v1(ng_zep_t *dev, ng_pktsnip_t *pkt)
|
||||
static gnrc_pktsnip_t *_recv_v1(gnrc_zep_t *dev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
ng_pktsnip_t *zep;
|
||||
ng_zep_v1_hdr_t *hdr = pkt->data;
|
||||
gnrc_pktsnip_t *zep;
|
||||
gnrc_zep_v1_hdr_t *hdr = pkt->data;
|
||||
uint8_t lqi, frame_len;
|
||||
|
||||
if (pkt->size < sizeof(ng_zep_v1_hdr_t)) {
|
||||
if (pkt->size < sizeof(gnrc_zep_v1_hdr_t)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lqi = hdr->lqi_val;
|
||||
frame_len = hdr->length;
|
||||
|
||||
if ((hdr->chan + NG_ZEP_MIN_CHANNEL) != dev->chan) {
|
||||
if ((hdr->chan + GNRC_ZEP_MIN_CHANNEL) != dev->chan) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v1_hdr_t), NG_NETTYPE_UNDEF);
|
||||
zep = gnrc_pktbuf_mark(pkt, sizeof(gnrc_zep_v1_hdr_t), GNRC_NETTYPE_UNDEF);
|
||||
|
||||
if (zep == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pkt = ng_pktbuf_remove_snip(pkt, zep);
|
||||
pkt = gnrc_pktbuf_remove_snip(pkt, zep);
|
||||
|
||||
return _create_received(dev, pkt, lqi, frame_len, 2);
|
||||
}
|
||||
|
||||
static ng_pktsnip_t *_recv_v2(ng_zep_t *dev, ng_pktsnip_t *pkt)
|
||||
static gnrc_pktsnip_t *_recv_v2(gnrc_zep_t *dev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
ng_zep_v2_data_hdr_t *hdr = pkt->data;
|
||||
gnrc_zep_v2_data_hdr_t *hdr = pkt->data;
|
||||
|
||||
if (pkt->size < sizeof(ng_zep_v2_ack_hdr_t)) {
|
||||
if (pkt->size < sizeof(gnrc_zep_v2_ack_hdr_t)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (hdr->type == NG_ZEP_V2_TYPE_ACK) {
|
||||
if (hdr->type == GNRC_ZEP_V2_TYPE_ACK) {
|
||||
/* TODO handle correctly */
|
||||
}
|
||||
else if ((hdr->type == NG_ZEP_V2_TYPE_DATA) &&
|
||||
(pkt->size >= sizeof(ng_zep_v2_data_hdr_t))) {
|
||||
ng_pktsnip_t *zep;
|
||||
else if ((hdr->type == GNRC_ZEP_V2_TYPE_DATA) &&
|
||||
(pkt->size >= sizeof(gnrc_zep_v2_data_hdr_t))) {
|
||||
gnrc_pktsnip_t *zep;
|
||||
uint8_t lqi = hdr->lqi_val, frame_len = hdr->length;
|
||||
|
||||
if ((hdr->chan + NG_ZEP_MIN_CHANNEL) != dev->chan) {
|
||||
if ((hdr->chan + GNRC_ZEP_MIN_CHANNEL) != dev->chan) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v2_data_hdr_t), NG_NETTYPE_UNDEF);
|
||||
zep = gnrc_pktbuf_mark(pkt, sizeof(gnrc_zep_v2_data_hdr_t), GNRC_NETTYPE_UNDEF);
|
||||
|
||||
if (zep == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pkt = ng_pktbuf_remove_snip(pkt, zep);
|
||||
pkt = gnrc_pktbuf_remove_snip(pkt, zep);
|
||||
|
||||
return _create_received(dev, pkt, lqi, frame_len, 2);
|
||||
}
|
||||
@ -817,21 +817,21 @@ static ng_pktsnip_t *_recv_v2(ng_zep_t *dev, ng_pktsnip_t *pkt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void _rx_started_event(ng_zep_t *dev)
|
||||
static void _rx_started_event(gnrc_zep_t *dev)
|
||||
{
|
||||
ng_pktsnip_t *tmp, *pkt;
|
||||
ng_zep_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *tmp, *pkt;
|
||||
gnrc_zep_hdr_t *hdr;
|
||||
|
||||
if (ringbuffer_get(&_rx_buf, (char *)(&pkt),
|
||||
sizeof(ng_pktsnip_t *)) != sizeof(ng_pktsnip_t *)) {
|
||||
sizeof(gnrc_pktsnip_t *)) != sizeof(gnrc_pktsnip_t *)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = ng_pktbuf_start_write(pkt);
|
||||
tmp = gnrc_pktbuf_start_write(pkt);
|
||||
|
||||
if (tmp == NULL) {
|
||||
DEBUG("zep: Could not get write access to received packet\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -839,14 +839,14 @@ static void _rx_started_event(ng_zep_t *dev)
|
||||
|
||||
while (pkt->next) {
|
||||
/* remove everything below UDP */
|
||||
ng_pktbuf_remove_snip(pkt, pkt->next);
|
||||
gnrc_pktbuf_remove_snip(pkt, pkt->next);
|
||||
}
|
||||
|
||||
hdr = pkt->data;
|
||||
|
||||
if ((pkt->size < 2) || (hdr->preamble[0] != 'E') ||
|
||||
(hdr->preamble[1] != 'X')) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ static void _rx_started_event(ng_zep_t *dev)
|
||||
break;
|
||||
|
||||
default:
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -868,13 +868,13 @@ static void _rx_started_event(ng_zep_t *dev)
|
||||
dev->event_cb(NETDEV_EVENT_RX_COMPLETE, pkt);
|
||||
}
|
||||
else if (pkt != NULL) {
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Generalize and move all below to ieee802154 */
|
||||
static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
ng_netif_hdr_t *hdr)
|
||||
static size_t _make_data_frame_hdr(gnrc_zep_t *dev, uint8_t *buf,
|
||||
gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
@ -883,7 +883,7 @@ static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
buf[1] = 0x88; /* use short src and dst addresses as starting point */
|
||||
|
||||
/* if AUTOACK is enabled, then we also expect ACKs for this packet */
|
||||
if (dev->flags & NG_ZEP_FLAGS_AUTOACK) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_AUTOACK) {
|
||||
buf[0] |= IEEE802154_FCF_ACK_REQ;
|
||||
}
|
||||
|
||||
@ -894,18 +894,18 @@ static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
|
||||
/* fill in destination address */
|
||||
if (hdr->flags &
|
||||
(NG_NETIF_HDR_FLAGS_BROADCAST | NG_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
buf[pos++] = 0xff;
|
||||
buf[pos++] = 0xff;
|
||||
}
|
||||
else if (hdr->dst_l2addr_len == 2) {
|
||||
uint8_t *dst_addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
uint8_t *dst_addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
buf[pos++] = dst_addr[1];
|
||||
buf[pos++] = dst_addr[0];
|
||||
}
|
||||
else if (hdr->dst_l2addr_len == 8) {
|
||||
buf[1] |= 0x04;
|
||||
uint8_t *dst_addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
uint8_t *dst_addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
buf[pos++] = dst_addr[i];
|
||||
@ -917,7 +917,7 @@ static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
}
|
||||
|
||||
/* fill in source PAN ID (if applicable) */
|
||||
if (dev->flags & NG_ZEP_FLAGS_USE_SRC_PAN) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_USE_SRC_PAN) {
|
||||
buf[pos++] = dev->pan.u8[0];
|
||||
buf[pos++] = dev->pan.u8[1];
|
||||
}
|
||||
@ -926,7 +926,7 @@ static size_t _make_data_frame_hdr(ng_zep_t *dev, uint8_t *buf,
|
||||
}
|
||||
|
||||
/* fill in source address */
|
||||
if (dev->flags & NG_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
if (dev->flags & GNRC_ZEP_FLAGS_SRC_ADDR_LONG) {
|
||||
buf[1] |= 0x40;
|
||||
memcpy(&(buf[pos]), &dev->eui64, 8);
|
||||
pos += 8;
|
||||
@ -981,13 +981,13 @@ static size_t _get_frame_hdr_len(uint8_t *mhr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
{
|
||||
uint8_t tmp;
|
||||
uint8_t *addr;
|
||||
uint8_t src_len, dst_len;
|
||||
ng_pktsnip_t *snip;
|
||||
ng_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *snip;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
|
||||
/* figure out address sizes */
|
||||
tmp = mhr[1] & IEEE802154_FCF_SRC_ADDR_MASK;
|
||||
@ -1021,20 +1021,20 @@ ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
}
|
||||
|
||||
/* allocate space for header */
|
||||
snip = ng_pktbuf_add(NULL, NULL, sizeof(ng_netif_hdr_t) + src_len + dst_len,
|
||||
NG_NETTYPE_NETIF);
|
||||
snip = gnrc_pktbuf_add(NULL, NULL, sizeof(gnrc_netif_hdr_t) + src_len + dst_len,
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (snip == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill header */
|
||||
hdr = (ng_netif_hdr_t *)snip->data;
|
||||
ng_netif_hdr_init(hdr, src_len, dst_len);
|
||||
hdr = (gnrc_netif_hdr_t *)snip->data;
|
||||
gnrc_netif_hdr_init(hdr, src_len, dst_len);
|
||||
|
||||
if (dst_len > 0) {
|
||||
tmp = 5 + dst_len;
|
||||
addr = ng_netif_hdr_get_dst_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_dst_addr(hdr);
|
||||
|
||||
for (int i = 0; i < dst_len; i++) {
|
||||
addr[i] = mhr[5 + (dst_len - i) - 1];
|
||||
@ -1049,7 +1049,7 @@ ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
|
||||
}
|
||||
|
||||
if (src_len > 0) {
|
||||
addr = ng_netif_hdr_get_src_addr(hdr);
|
||||
addr = gnrc_netif_hdr_get_src_addr(hdr);
|
||||
|
||||
for (int i = 0; i < src_len; i++) {
|
||||
addr[i] = mhr[tmp + (src_len - i) - 1];
|
3
sys/net/gnrc/link_layer/netdev_eth/Makefile
Normal file
3
sys/net/gnrc/link_layer/netdev_eth/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = gnrc_netdev_eth
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -33,11 +33,11 @@
|
||||
#include "net/ethernet.h"
|
||||
#include "net/ethertype.h"
|
||||
#include "net/ipv6/hdr.h"
|
||||
#include "net/ng_netdev.h"
|
||||
#include "net/ng_netif/hdr.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "net/ng_netdev_eth.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/netdev_eth.h"
|
||||
#include "net/dev_eth.h"
|
||||
#include "od.h"
|
||||
#include "thread.h"
|
||||
@ -46,7 +46,7 @@
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
ng_netdev_eth_t ng_netdev_eth;
|
||||
gnrc_netdev_eth_t gnrc_netdev_eth;
|
||||
|
||||
static uint8_t send_buffer[ETHERNET_MAX_LEN];
|
||||
static uint8_t recv_buffer[ETHERNET_MAX_LEN];
|
||||
@ -54,15 +54,15 @@ static uint8_t recv_buffer[ETHERNET_MAX_LEN];
|
||||
#define _ISR_EVENT_RX (1U)
|
||||
|
||||
/* driver function definitions */
|
||||
static int _send_data(ng_netdev_t *netdev, ng_pktsnip_t *pkt);
|
||||
static int _add_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
static int _rem_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
|
||||
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
static void _isr_event(ng_netdev_t *dev, uint32_t event_type);
|
||||
static int _send_data(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt);
|
||||
static int _add_event_callback(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
static int _rem_event_callback(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb);
|
||||
static int _get(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
|
||||
static int _set(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
|
||||
static void _isr_event(gnrc_netdev_t *dev, uint32_t event_type);
|
||||
|
||||
/* netdev driver struct */
|
||||
const ng_netdev_driver_t ng_netdev_eth_driver = {
|
||||
const gnrc_netdev_driver_t gnrc_netdev_eth_driver = {
|
||||
_send_data,
|
||||
_add_event_callback,
|
||||
_rem_event_callback,
|
||||
@ -88,32 +88,32 @@ static inline bool _is_addr_multicast(uint8_t *addr)
|
||||
#endif
|
||||
|
||||
/* build Ethernet packet from pkt */
|
||||
static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_t *pkt);
|
||||
static int _marshall_ethernet(gnrc_netdev_eth_t *dev, uint8_t *buffer, gnrc_pktsnip_t *pkt);
|
||||
|
||||
/* build ISR handler for ISR events */
|
||||
void _trigger_isr_event(void);
|
||||
|
||||
static int _send_data(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
static int _send_data(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
int nsent, to_send;
|
||||
ng_netdev_eth_t *dev = (ng_netdev_eth_t *)netdev;
|
||||
gnrc_netdev_eth_t *dev = (gnrc_netdev_eth_t *)netdev;
|
||||
|
||||
DEBUG("ng_netdev_eth: send data ");
|
||||
DEBUG("gnrc_netdev_eth: send data ");
|
||||
|
||||
if (pkt == NULL) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if ((dev == NULL) || (netdev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (netdev->driver != &gnrc_netdev_eth_driver)) {
|
||||
DEBUG("[wrong device descriptor]\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
DEBUG("\n");
|
||||
|
||||
to_send = _marshall_ethernet(dev, send_buffer, pkt);
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
|
||||
if (to_send < 0) {
|
||||
errno = -to_send;
|
||||
@ -121,7 +121,7 @@ static int _send_data(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
return to_send;
|
||||
}
|
||||
|
||||
DEBUG("ng_netdev_eth: send %d bytes\n", to_send);
|
||||
DEBUG("gnrc_netdev_eth: send %d bytes\n", to_send);
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
od_hex_dump(send_buffer, to_send, OD_WIDTH_DEFAULT);
|
||||
#endif
|
||||
@ -135,11 +135,11 @@ static int _send_data(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
return nsent;
|
||||
}
|
||||
|
||||
static int _add_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _add_event_callback(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
DEBUG("ng_netdev_eth: add event callback");
|
||||
DEBUG("gnrc_netdev_eth: add event callback");
|
||||
|
||||
if ((dev == NULL) || (dev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (dev->driver != &gnrc_netdev_eth_driver)) {
|
||||
DEBUG(" [wrong device descriptor]\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -155,11 +155,11 @@ static int _add_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _rem_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
static int _rem_event_callback(gnrc_netdev_t *dev, gnrc_netdev_event_cb_t cb)
|
||||
{
|
||||
DEBUG("ng_netdev_eth: remove event callback");
|
||||
DEBUG("gnrc_netdev_eth: remove event callback");
|
||||
|
||||
if ((dev == NULL) || (dev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (dev->driver != &gnrc_netdev_eth_driver)) {
|
||||
DEBUG(" [wrong device descriptor]\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -176,7 +176,7 @@ static int _rem_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
|
||||
}
|
||||
|
||||
/* individual option getters to be called by _get() */
|
||||
static inline int _get_addr(ng_netdev_eth_t *netdev, uint8_t *value, size_t max_len)
|
||||
static inline int _get_addr(gnrc_netdev_eth_t *netdev, uint8_t *value, size_t max_len)
|
||||
{
|
||||
if (max_len < ETHERNET_ADDR_LEN) {
|
||||
/* value buffer not big enough */
|
||||
@ -201,7 +201,7 @@ static inline int _get_addr_len(uint16_t *value, size_t max_len)
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
static inline int _get_iid(ng_netdev_eth_t *netdev, eui64_t *value, size_t max_len)
|
||||
static inline int _get_iid(gnrc_netdev_eth_t *netdev, eui64_t *value, size_t max_len)
|
||||
{
|
||||
if (max_len < sizeof(eui64_t)) {
|
||||
/* value buffer not big enough */
|
||||
@ -228,7 +228,7 @@ static inline int _get_max_pkt_sz(uint16_t *value, size_t max_len)
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
static inline int _get_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *value,
|
||||
static inline int _get_promiscousmode(gnrc_netdev_eth_t *netdev, netopt_enable_t *value,
|
||||
size_t max_len)
|
||||
{
|
||||
if (max_len != sizeof(netopt_enable_t)) {
|
||||
@ -243,11 +243,11 @@ static inline int _get_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *
|
||||
return sizeof(netopt_enable_t);
|
||||
}
|
||||
|
||||
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
static int _get(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
{
|
||||
DEBUG("ng_netdev_eth: get ");
|
||||
DEBUG("gnrc_netdev_eth: get ");
|
||||
|
||||
if ((dev == NULL) || (dev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (dev->driver != &gnrc_netdev_eth_driver)) {
|
||||
DEBUG("[wrong device descriptor]\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -255,7 +255,7 @@ static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
switch (opt) {
|
||||
case NETOPT_ADDRESS:
|
||||
DEBUG("address\n");
|
||||
return _get_addr((ng_netdev_eth_t *)dev, value, max_len);
|
||||
return _get_addr((gnrc_netdev_eth_t *)dev, value, max_len);
|
||||
|
||||
case NETOPT_ADDR_LEN:
|
||||
DEBUG("address length\n");
|
||||
@ -263,7 +263,7 @@ static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
|
||||
case NETOPT_IPV6_IID:
|
||||
DEBUG("IPv6 IID\n");
|
||||
return _get_iid((ng_netdev_eth_t *)dev, value, max_len);
|
||||
return _get_iid((gnrc_netdev_eth_t *)dev, value, max_len);
|
||||
|
||||
case NETOPT_MAX_PACKET_SIZE:
|
||||
DEBUG("maximum packet size\n");
|
||||
@ -271,7 +271,7 @@ static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
|
||||
case NETOPT_PROMISCUOUSMODE:
|
||||
DEBUG("promiscous mode\n");
|
||||
return _get_promiscousmode((ng_netdev_eth_t *)dev, value, max_len);
|
||||
return _get_promiscousmode((gnrc_netdev_eth_t *)dev, value, max_len);
|
||||
|
||||
default:
|
||||
DEBUG("[not supported: %d]\n", opt);
|
||||
@ -280,7 +280,7 @@ static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
|
||||
}
|
||||
|
||||
/* individual option getters to be called by _get() */
|
||||
static inline int _set_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *value,
|
||||
static inline int _set_promiscousmode(gnrc_netdev_eth_t *netdev, netopt_enable_t *value,
|
||||
size_t value_len)
|
||||
{
|
||||
if (value_len != sizeof(netopt_enable_t)) {
|
||||
@ -295,11 +295,11 @@ static inline int _set_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *
|
||||
return sizeof(netopt_enable_t);
|
||||
}
|
||||
|
||||
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
static int _set(gnrc_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
{
|
||||
DEBUG("ng_netdev_eth: set ");
|
||||
DEBUG("gnrc_netdev_eth: set ");
|
||||
|
||||
if ((dev == NULL) || (dev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (dev->driver != &gnrc_netdev_eth_driver)) {
|
||||
DEBUG("[wrong device descriptor]\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -307,7 +307,7 @@ static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
switch (opt) {
|
||||
case NETOPT_PROMISCUOUSMODE:
|
||||
DEBUG("promiscous mode\n");
|
||||
return _set_promiscousmode((ng_netdev_eth_t *)dev, value, value_len);
|
||||
return _set_promiscousmode((gnrc_netdev_eth_t *)dev, value, value_len);
|
||||
|
||||
default:
|
||||
DEBUG("[not supported: %d]\n", opt);
|
||||
@ -316,17 +316,17 @@ static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
|
||||
}
|
||||
|
||||
/* individual event handlers called by _isr_event() */
|
||||
static void _rx_event(ng_netdev_eth_t *dev);
|
||||
static void _rx_event(gnrc_netdev_eth_t *dev);
|
||||
|
||||
static void _isr_event(ng_netdev_t *dev, uint32_t event_type)
|
||||
static void _isr_event(gnrc_netdev_t *dev, uint32_t event_type)
|
||||
{
|
||||
DEBUG("ng_netdev_eth: ISR event ");
|
||||
DEBUG("gnrc_netdev_eth: ISR event ");
|
||||
|
||||
if ((dev == NULL) || (dev->driver != &ng_netdev_eth_driver)) {
|
||||
if ((dev == NULL) || (dev->driver != &gnrc_netdev_eth_driver)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ng_netdev_eth_t *netdev = (ng_netdev_eth_t*)dev;
|
||||
gnrc_netdev_eth_t *netdev = (gnrc_netdev_eth_t*)dev;
|
||||
|
||||
switch (event_type) {
|
||||
case _ISR_EVENT_RX:
|
||||
@ -355,11 +355,11 @@ static inline void _addr_set_broadcast(uint8_t *dst)
|
||||
memset(dst, 0xff, ETHERNET_ADDR_LEN);
|
||||
}
|
||||
|
||||
static inline void _addr_set_multicast(uint8_t *dst, ng_pktsnip_t *payload)
|
||||
static inline void _addr_set_multicast(uint8_t *dst, gnrc_pktsnip_t *payload)
|
||||
{
|
||||
switch (payload->type) {
|
||||
#ifdef MODULE_NG_IPV6
|
||||
case NG_NETTYPE_IPV6:
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
dst[0] = 0x33;
|
||||
dst[1] = 0x33;
|
||||
if (payload->data != NULL) {
|
||||
@ -376,27 +376,27 @@ static inline void _addr_set_multicast(uint8_t *dst, ng_pktsnip_t *payload)
|
||||
}
|
||||
}
|
||||
|
||||
static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_t *pkt)
|
||||
static int _marshall_ethernet(gnrc_netdev_eth_t *dev, uint8_t *buffer, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
int data_len = 0;
|
||||
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buffer;
|
||||
ng_netif_hdr_t *netif_hdr;
|
||||
ng_pktsnip_t *payload;
|
||||
gnrc_netif_hdr_t *netif_hdr;
|
||||
gnrc_pktsnip_t *payload;
|
||||
|
||||
if (pkt == NULL) {
|
||||
DEBUG("ng_netdev_eth: pkt was NULL");
|
||||
DEBUG("gnrc_netdev_eth: pkt was NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = pkt->next;
|
||||
|
||||
if (pkt->type != NG_NETTYPE_NETIF) {
|
||||
DEBUG("ng_netdev_eth: First header was not generic netif header\n");
|
||||
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(ng_nettype_to_ethertype(payload->type));
|
||||
hdr->type = byteorder_htons(gnrc_nettype_to_ethertype(payload->type));
|
||||
}
|
||||
else {
|
||||
hdr->type = byteorder_htons(ETHERTYPE_UNKNOWN);
|
||||
@ -406,7 +406,7 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_
|
||||
|
||||
/* set ethernet header */
|
||||
if (netif_hdr->src_l2addr_len == ETHERNET_ADDR_LEN) {
|
||||
memcpy(hdr->dst, ng_netif_hdr_get_src_addr(netif_hdr),
|
||||
memcpy(hdr->dst, gnrc_netif_hdr_get_src_addr(netif_hdr),
|
||||
netif_hdr->src_l2addr_len);
|
||||
}
|
||||
else {
|
||||
@ -414,12 +414,12 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_
|
||||
ethdev->driver->get_mac_addr(ethdev, hdr->src);
|
||||
}
|
||||
|
||||
if (netif_hdr->flags & NG_NETIF_HDR_FLAGS_BROADCAST) {
|
||||
if (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) {
|
||||
_addr_set_broadcast(hdr->dst);
|
||||
}
|
||||
else if (netif_hdr->flags & NG_NETIF_HDR_FLAGS_MULTICAST) {
|
||||
else if (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST) {
|
||||
if (payload == NULL) {
|
||||
DEBUG("ng_netdev_eth: empty multicast packets over Ethernet are "\
|
||||
DEBUG("gnrc_netdev_eth: empty multicast packets over Ethernet are "\
|
||||
"not yet supported\n");
|
||||
return -ENOTSUP;
|
||||
|
||||
@ -427,15 +427,15 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_
|
||||
_addr_set_multicast(hdr->dst, payload);
|
||||
}
|
||||
else if (netif_hdr->dst_l2addr_len == ETHERNET_ADDR_LEN) {
|
||||
memcpy(hdr->dst, ng_netif_hdr_get_dst_addr(netif_hdr),
|
||||
memcpy(hdr->dst, gnrc_netif_hdr_get_dst_addr(netif_hdr),
|
||||
ETHERNET_ADDR_LEN);
|
||||
}
|
||||
else {
|
||||
DEBUG("ng_netdev_eth: destination address had unexpected format\n");
|
||||
DEBUG("gnrc_netdev_eth: destination address had unexpected format\n");
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
DEBUG("ng_netdev_eth: send to %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
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]);
|
||||
|
||||
@ -443,7 +443,7 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_
|
||||
|
||||
while (payload != NULL) {
|
||||
if ((data_len + payload->size) > ETHERNET_MAX_LEN) {
|
||||
DEBUG("ng_netdev_eth: Packet too big for ethernet frame\n");
|
||||
DEBUG("gnrc_netdev_eth: Packet too big for ethernet frame\n");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_
|
||||
* Linux does this on its own, but it doesn't hurt to do it here.
|
||||
* As of now only tuntaposx needs this. */
|
||||
if (data_len < (ETHERNET_MIN_LEN)) {
|
||||
DEBUG("ng_netdev_eth: padding data! (%d -> ", data_len);
|
||||
DEBUG("gnrc_netdev_eth: padding data! (%d -> ", data_len);
|
||||
memset(send_buffer + data_len, 0, ETHERNET_MIN_LEN - data_len);
|
||||
data_len = ETHERNET_MIN_LEN;
|
||||
DEBUG("%d)\n", data_len);
|
||||
@ -471,62 +471,62 @@ void dev_eth_isr(dev_eth_t* dev)
|
||||
(void)dev;
|
||||
msg_t msg;
|
||||
|
||||
DEBUG("ng_netdev_eth: Trigger ISR event\n");
|
||||
DEBUG("gnrc_netdev_eth: Trigger ISR event\n");
|
||||
|
||||
/* TODO: check whether this is an input or an output event
|
||||
TODO: refactor this into general io-signal multiplexer */
|
||||
|
||||
msg.type = NG_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.type = GNRC_NETDEV_MSG_TYPE_EVENT;
|
||||
msg.content.value = _ISR_EVENT_RX;
|
||||
|
||||
if (msg_send(&msg, ng_netdev_eth.mac_pid) <= 0) {
|
||||
if (msg_send(&msg, gnrc_netdev_eth.mac_pid) <= 0) {
|
||||
puts("dev_eth_isr: possibly lost interrupt.");
|
||||
}
|
||||
}
|
||||
|
||||
void dev_eth_rx_handler(dev_eth_t* dev) {
|
||||
(void)dev;
|
||||
_rx_event(&ng_netdev_eth);
|
||||
_rx_event(&gnrc_netdev_eth);
|
||||
}
|
||||
|
||||
void dev_eth_linkstate_handler(dev_eth_t *dev, int newstate)
|
||||
{
|
||||
DEBUG("ng_dev_eth: dev=0x%08x link %s\n", (unsigned)dev, newstate ? "UP" : "DOWN");
|
||||
DEBUG("gnrc_dev_eth: dev=0x%08x link %s\n", (unsigned)dev, newstate ? "UP" : "DOWN");
|
||||
(void)dev; (void)newstate;
|
||||
}
|
||||
|
||||
static void _rx_event(ng_netdev_eth_t *netdev)
|
||||
static void _rx_event(gnrc_netdev_eth_t *netdev)
|
||||
{
|
||||
dev_eth_t *dev = netdev->ethdev;
|
||||
int nread = dev->driver->recv(dev, (char*)recv_buffer, ETHERNET_MAX_LEN);
|
||||
|
||||
DEBUG("ng_netdev_eth: read %d bytes\n", nread);
|
||||
DEBUG("gnrc_netdev_eth: read %d bytes\n", nread);
|
||||
|
||||
if (nread > 0) {
|
||||
ethernet_hdr_t *hdr = (ethernet_hdr_t *)recv_buffer;
|
||||
ng_pktsnip_t *netif_hdr, *pkt;
|
||||
ng_nettype_t receive_type = NG_NETTYPE_UNDEF;
|
||||
gnrc_pktsnip_t *netif_hdr, *pkt;
|
||||
gnrc_nettype_t receive_type = GNRC_NETTYPE_UNDEF;
|
||||
size_t data_len = (nread - sizeof(ethernet_hdr_t));
|
||||
|
||||
/* TODO: implement multicast groups? */
|
||||
|
||||
netif_hdr = ng_pktbuf_add(NULL, NULL,
|
||||
sizeof(ng_netif_hdr_t) + (2 * ETHERNET_ADDR_LEN),
|
||||
NG_NETTYPE_NETIF);
|
||||
netif_hdr = gnrc_pktbuf_add(NULL, NULL,
|
||||
sizeof(gnrc_netif_hdr_t) + (2 * ETHERNET_ADDR_LEN),
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (netif_hdr == NULL) {
|
||||
DEBUG("ng_netdev_eth: no space left in packet buffer\n");
|
||||
DEBUG("gnrc_netdev_eth: no space left in packet buffer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ng_netif_hdr_init(netif_hdr->data, ETHERNET_ADDR_LEN, ETHERNET_ADDR_LEN);
|
||||
ng_netif_hdr_set_src_addr(netif_hdr->data, hdr->src, ETHERNET_ADDR_LEN);
|
||||
ng_netif_hdr_set_dst_addr(netif_hdr->data, hdr->dst, ETHERNET_ADDR_LEN);
|
||||
((ng_netif_hdr_t *)netif_hdr->data)->if_pid = thread_getpid();
|
||||
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();
|
||||
|
||||
receive_type = ng_nettype_from_ethertype(byteorder_ntohs(hdr->type));
|
||||
receive_type = gnrc_nettype_from_ethertype(byteorder_ntohs(hdr->type));
|
||||
|
||||
DEBUG("ng_netdev_eth: received packet from %02x:%02x:%02x:%02x:%02x:%02x "
|
||||
DEBUG("gnrc_netdev_eth: received packet from %02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"of length %zu\n",
|
||||
hdr->src[0], hdr->src[1], hdr->src[2], hdr->src[3], hdr->src[4],
|
||||
hdr->src[5], data_len);
|
||||
@ -535,10 +535,10 @@ static void _rx_event(ng_netdev_eth_t *netdev)
|
||||
#endif
|
||||
|
||||
/* Mark netif header and payload for next layer */
|
||||
if ((pkt = ng_pktbuf_add(netif_hdr, recv_buffer + sizeof(ethernet_hdr_t),
|
||||
data_len, receive_type)) == NULL) {
|
||||
ng_pktbuf_release(netif_hdr);
|
||||
DEBUG("ng_netdev_eth: no space left in packet buffer\n");
|
||||
if ((pkt = gnrc_pktbuf_add(netif_hdr, recv_buffer + sizeof(ethernet_hdr_t),
|
||||
data_len, receive_type)) == NULL) {
|
||||
gnrc_pktbuf_release(netif_hdr);
|
||||
DEBUG("gnrc_netdev_eth: no space left in packet buffer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -546,16 +546,17 @@ static void _rx_event(ng_netdev_eth_t *netdev)
|
||||
netdev->event_cb(NETDEV_EVENT_RX_COMPLETE, pkt);
|
||||
}
|
||||
else {
|
||||
ng_pktbuf_release(pkt); /* netif_hdr is released automatically too */
|
||||
gnrc_pktbuf_release(pkt); /* netif_hdr is released automatically too */
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG("ng_netdev_eth: spurious _rx_event: %d\n", nread);
|
||||
DEBUG("gnrc_netdev_eth: spurious _rx_event: %d\n", nread);
|
||||
}
|
||||
}
|
||||
|
||||
int ng_netdev_eth_init(ng_netdev_eth_t *netdev, dev_eth_t *ethdev) {
|
||||
if ((netdev == NULL) || (ethdev == NULL) || (netdev != &ng_netdev_eth)) {
|
||||
int gnrc_netdev_eth_init(gnrc_netdev_eth_t *netdev, dev_eth_t *ethdev)
|
||||
{
|
||||
if ((netdev == NULL) || (ethdev == NULL) || (netdev != &gnrc_netdev_eth)) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@ -563,10 +564,10 @@ int ng_netdev_eth_init(ng_netdev_eth_t *netdev, dev_eth_t *ethdev) {
|
||||
dev_eth_init(ethdev);
|
||||
|
||||
/* initialize device descriptor */
|
||||
netdev->driver = (ng_netdev_driver_t *)(&ng_netdev_eth_driver);
|
||||
netdev->driver = (gnrc_netdev_driver_t *)(&gnrc_netdev_eth_driver);
|
||||
netdev->ethdev = ethdev;
|
||||
|
||||
DEBUG("ng_netdev_eth: initialized.\n");
|
||||
DEBUG("gnrc_netdev_eth: initialized.\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_ipv6_nc
|
||||
MODULE = gnrc_nomac
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -21,7 +21,7 @@
|
||||
#include "kernel.h"
|
||||
#include "msg.h"
|
||||
#include "thread.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/gnrc/nomac.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
@ -38,19 +38,19 @@
|
||||
* @param[in] event type of event
|
||||
* @param[in] data optional parameter
|
||||
*/
|
||||
static void _event_cb(ng_netdev_event_t event, void *data)
|
||||
static void _event_cb(gnrc_netdev_event_t event, void *data)
|
||||
{
|
||||
DEBUG("nomac: event triggered -> %i\n", event);
|
||||
/* NOMAC only understands the RX_COMPLETE event... */
|
||||
if (event == NETDEV_EVENT_RX_COMPLETE) {
|
||||
ng_pktsnip_t *pkt;
|
||||
gnrc_pktsnip_t *pkt;
|
||||
|
||||
/* get pointer to the received packet */
|
||||
pkt = (ng_pktsnip_t *)data;
|
||||
pkt = (gnrc_pktsnip_t *)data;
|
||||
/* send the packet to everyone interested in it's type */
|
||||
if (!ng_netapi_dispatch_receive(pkt->type, NG_NETREG_DEMUX_CTX_ALL, pkt)) {
|
||||
if (!gnrc_netapi_dispatch_receive(pkt->type, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
|
||||
DEBUG("nomac: unable to forward packet of type %i\n", pkt->type);
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,16 +64,16 @@ static void _event_cb(ng_netdev_event_t event, void *data)
|
||||
*/
|
||||
static void *_nomac_thread(void *args)
|
||||
{
|
||||
ng_netdev_t *dev = (ng_netdev_t *)args;
|
||||
ng_netapi_opt_t *opt;
|
||||
gnrc_netdev_t *dev = (gnrc_netdev_t *)args;
|
||||
gnrc_netapi_opt_t *opt;
|
||||
int res;
|
||||
msg_t msg, reply, msg_queue[NG_NOMAC_MSG_QUEUE_SIZE];
|
||||
msg_t msg, reply, msg_queue[GNRC_NOMAC_MSG_QUEUE_SIZE];
|
||||
|
||||
/* setup the MAC layers message queue */
|
||||
msg_init_queue(msg_queue, NG_NOMAC_MSG_QUEUE_SIZE);
|
||||
msg_init_queue(msg_queue, GNRC_NOMAC_MSG_QUEUE_SIZE);
|
||||
/* save the PID to the device descriptor and register the device */
|
||||
dev->mac_pid = thread_getpid();
|
||||
ng_netif_add(dev->mac_pid);
|
||||
gnrc_netif_add(dev->mac_pid);
|
||||
/* register the event callback with the device driver */
|
||||
dev->driver->add_event_callback(dev, _event_cb);
|
||||
|
||||
@ -83,39 +83,39 @@ static void *_nomac_thread(void *args)
|
||||
msg_receive(&msg);
|
||||
/* dispatch NETDEV and NETAPI messages */
|
||||
switch (msg.type) {
|
||||
case NG_NETDEV_MSG_TYPE_EVENT:
|
||||
DEBUG("nomac: NG_NETDEV_MSG_TYPE_EVENT received\n");
|
||||
case GNRC_NETDEV_MSG_TYPE_EVENT:
|
||||
DEBUG("nomac: GNRC_NETDEV_MSG_TYPE_EVENT received\n");
|
||||
dev->driver->isr_event(dev, msg.content.value);
|
||||
break;
|
||||
case NG_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("nomac: NG_NETAPI_MSG_TYPE_SND received\n");
|
||||
dev->driver->send_data(dev, (ng_pktsnip_t *)msg.content.ptr);
|
||||
case GNRC_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("nomac: GNRC_NETAPI_MSG_TYPE_SND received\n");
|
||||
dev->driver->send_data(dev, (gnrc_pktsnip_t *)msg.content.ptr);
|
||||
break;
|
||||
case NG_NETAPI_MSG_TYPE_SET:
|
||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||
/* TODO: filter out MAC layer options -> for now forward
|
||||
everything to the device driver */
|
||||
DEBUG("nomac: NG_NETAPI_MSG_TYPE_SET received\n");
|
||||
DEBUG("nomac: GNRC_NETAPI_MSG_TYPE_SET received\n");
|
||||
/* read incoming options */
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
/* set option for device driver */
|
||||
res = dev->driver->set(dev, opt->opt, opt->data, opt->data_len);
|
||||
DEBUG("nomac: response of netdev->set: %i\n", res);
|
||||
/* send reply to calling thread */
|
||||
reply.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
reply.content.value = (uint32_t)res;
|
||||
msg_reply(&msg, &reply);
|
||||
break;
|
||||
case NG_NETAPI_MSG_TYPE_GET:
|
||||
case GNRC_NETAPI_MSG_TYPE_GET:
|
||||
/* TODO: filter out MAC layer options -> for now forward
|
||||
everything to the device driver */
|
||||
DEBUG("nomac: NG_NETAPI_MSG_TYPE_GET received\n");
|
||||
DEBUG("nomac: GNRC_NETAPI_MSG_TYPE_GET received\n");
|
||||
/* read incoming options */
|
||||
opt = (ng_netapi_opt_t *)msg.content.ptr;
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
/* get option from device driver */
|
||||
res = dev->driver->get(dev, opt->opt, opt->data, opt->data_len);
|
||||
DEBUG("nomac: response of netdev->get: %i\n", res);
|
||||
/* send reply to calling thread */
|
||||
reply.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
reply.content.value = (uint32_t)res;
|
||||
msg_reply(&msg, &reply);
|
||||
break;
|
||||
@ -128,8 +128,8 @@ static void *_nomac_thread(void *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
kernel_pid_t ng_nomac_init(char *stack, int stacksize, char priority,
|
||||
const char *name, ng_netdev_t *dev)
|
||||
kernel_pid_t gnrc_nomac_init(char *stack, int stacksize, char priority,
|
||||
const char *name, gnrc_netdev_t *dev)
|
||||
{
|
||||
kernel_pid_t res;
|
||||
|
3
sys/net/gnrc/link_layer/slip/Makefile
Normal file
3
sys/net/gnrc/link_layer/slip/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = gnrc_slip
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_ng_slip
|
||||
* @ingroup net_gnrc_slip
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -33,7 +33,7 @@
|
||||
#include "thread.h"
|
||||
#include "net/ipv6/hdr.h"
|
||||
|
||||
#include "net/ng_slip.h"
|
||||
#include "net/gnrc/slip.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
@ -47,7 +47,7 @@
|
||||
#define _SLIP_NAME "SLIP"
|
||||
#define _SLIP_MSG_QUEUE_SIZE (8U)
|
||||
|
||||
#define _SLIP_DEV(arg) ((ng_slip_dev_t *)arg)
|
||||
#define _SLIP_DEV(arg) ((gnrc_slip_dev_t *)arg)
|
||||
|
||||
/* UART callbacks */
|
||||
static void _slip_rx_cb(void *arg, char data)
|
||||
@ -107,72 +107,72 @@ int _slip_tx_cb(void *arg)
|
||||
}
|
||||
|
||||
/* SLIP receive handler */
|
||||
static void _slip_receive(ng_slip_dev_t *dev, size_t bytes)
|
||||
static void _slip_receive(gnrc_slip_dev_t *dev, size_t bytes)
|
||||
{
|
||||
ng_netif_hdr_t *hdr;
|
||||
ng_netreg_entry_t *sendto;
|
||||
ng_pktsnip_t *pkt, *netif_hdr;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
gnrc_netreg_entry_t *sendto;
|
||||
gnrc_pktsnip_t *pkt, *netif_hdr;
|
||||
|
||||
pkt = ng_pktbuf_add(NULL, NULL, bytes, NG_NETTYPE_UNDEF);
|
||||
pkt = gnrc_pktbuf_add(NULL, NULL, bytes, GNRC_NETTYPE_UNDEF);
|
||||
|
||||
if (pkt == NULL) {
|
||||
DEBUG("slip: no space left in packet buffer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
netif_hdr = ng_pktbuf_add(pkt, NULL, sizeof(ng_netif_hdr_t),
|
||||
NG_NETTYPE_NETIF);
|
||||
netif_hdr = gnrc_pktbuf_add(pkt, NULL, sizeof(gnrc_netif_hdr_t),
|
||||
GNRC_NETTYPE_NETIF);
|
||||
|
||||
if (netif_hdr == NULL) {
|
||||
DEBUG("slip: no space left in packet buffer\n");
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
hdr = netif_hdr->data;
|
||||
ng_netif_hdr_init(hdr, 0, 0);
|
||||
gnrc_netif_hdr_init(hdr, 0, 0);
|
||||
hdr->if_pid = thread_getpid();
|
||||
|
||||
if (ringbuffer_get(dev->in_buf, pkt->data, bytes) != bytes) {
|
||||
DEBUG("slip: could not read %zu bytes from ringbuffer\n", bytes);
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MODULE_NG_IPV6
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
if ((pkt->size >= sizeof(ipv6_hdr_t)) && ipv6_hdr_is(pkt->data)) {
|
||||
pkt->type = NG_NETTYPE_IPV6;
|
||||
pkt->type = GNRC_NETTYPE_IPV6;
|
||||
}
|
||||
#endif
|
||||
|
||||
sendto = ng_netreg_lookup(pkt->type, NG_NETREG_DEMUX_CTX_ALL);
|
||||
sendto = gnrc_netreg_lookup(pkt->type, GNRC_NETREG_DEMUX_CTX_ALL);
|
||||
|
||||
if (sendto == NULL) {
|
||||
DEBUG("slip: unable to forward packet of type %i\n", pkt->type);
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
|
||||
ng_pktbuf_hold(pkt, ng_netreg_num(pkt->type, NG_NETREG_DEMUX_CTX_ALL) - 1);
|
||||
gnrc_pktbuf_hold(pkt, gnrc_netreg_num(pkt->type, GNRC_NETREG_DEMUX_CTX_ALL) - 1);
|
||||
|
||||
while (sendto != NULL) {
|
||||
DEBUG("slip: sending pkt %p to PID %u\n", pkt, sendto->pid);
|
||||
ng_netapi_receive(sendto->pid, pkt);
|
||||
sendto = ng_netreg_getnext(sendto);
|
||||
gnrc_netapi_receive(sendto->pid, pkt);
|
||||
sendto = gnrc_netreg_getnext(sendto);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _slip_send_char(ng_slip_dev_t *dev, char c)
|
||||
static inline void _slip_send_char(gnrc_slip_dev_t *dev, char c)
|
||||
{
|
||||
ringbuffer_add_one(dev->out_buf, c);
|
||||
uart_tx_begin(dev->uart);
|
||||
}
|
||||
|
||||
/* SLIP send handler */
|
||||
static void _slip_send(ng_slip_dev_t *dev, ng_pktsnip_t *pkt)
|
||||
static void _slip_send(gnrc_slip_dev_t *dev, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
ng_pktsnip_t *ptr;
|
||||
gnrc_pktsnip_t *ptr;
|
||||
|
||||
ptr = pkt->next; /* ignore ng_netif_hdr_t, we don't need it */
|
||||
ptr = pkt->next; /* ignore gnrc_netif_hdr_t, we don't need it */
|
||||
|
||||
while (ptr != NULL) {
|
||||
DEBUG("slip: send pktsnip of length %zu over UART_%d\n", ptr->size, uart);
|
||||
@ -204,17 +204,17 @@ static void _slip_send(ng_slip_dev_t *dev, ng_pktsnip_t *pkt)
|
||||
|
||||
_slip_send_char(dev, _SLIP_END);
|
||||
|
||||
ng_pktbuf_release(pkt);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
|
||||
static void *_slip(void *args)
|
||||
{
|
||||
ng_slip_dev_t *dev = _SLIP_DEV(args);
|
||||
gnrc_slip_dev_t *dev = _SLIP_DEV(args);
|
||||
msg_t msg, reply, msg_q[_SLIP_MSG_QUEUE_SIZE];
|
||||
|
||||
msg_init_queue(msg_q, _SLIP_MSG_QUEUE_SIZE);
|
||||
dev->slip_pid = thread_getpid();
|
||||
ng_netif_add(dev->slip_pid);
|
||||
gnrc_netif_add(dev->slip_pid);
|
||||
|
||||
DEBUG("slip: SLIP runs on UART_%d\n", uart);
|
||||
|
||||
@ -228,15 +228,15 @@ static void *_slip(void *args)
|
||||
_slip_receive(dev, (size_t)msg.content.value);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("slip: NG_NETAPI_MSG_TYPE_SND received\n");
|
||||
_slip_send(dev, (ng_pktsnip_t *)msg.content.ptr);
|
||||
case GNRC_NETAPI_MSG_TYPE_SND:
|
||||
DEBUG("slip: GNRC_NETAPI_MSG_TYPE_SND received\n");
|
||||
_slip_send(dev, (gnrc_pktsnip_t *)msg.content.ptr);
|
||||
break;
|
||||
|
||||
case NG_NETAPI_MSG_TYPE_GET:
|
||||
case NG_NETAPI_MSG_TYPE_SET:
|
||||
DEBUG("slip: NG_NETAPI_MSG_TYPE_GET or NG_NETAPI_MSG_TYPE_SET received\n");
|
||||
reply.type = NG_NETAPI_MSG_TYPE_ACK;
|
||||
case GNRC_NETAPI_MSG_TYPE_GET:
|
||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||
DEBUG("slip: GNRC_NETAPI_MSG_TYPE_GET or GNRC_NETAPI_MSG_TYPE_SET received\n");
|
||||
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
reply.content.value = (uint32_t)(-ENOTSUP);
|
||||
DEBUG("slip: I don't support these but have to reply.\n");
|
||||
msg_reply(&msg, &reply);
|
||||
@ -248,8 +248,8 @@ static void *_slip(void *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
kernel_pid_t ng_slip_init(ng_slip_dev_t *dev, uart_t uart, uint32_t baudrate,
|
||||
char *stack, size_t stack_size, char priority)
|
||||
kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate,
|
||||
char *stack, size_t stack_size, char priority)
|
||||
{
|
||||
int res;
|
||||
kernel_pid_t pid;
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_ipv6_ext
|
||||
MODULE = gnrc_netapi
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -8,7 +8,7 @@
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @ingroup net_ng_netapi
|
||||
* @ingroup net_gnrc_netapi
|
||||
* @file
|
||||
* @brief This file contains a number of helper functions that provide
|
||||
* some shortcuts for some always repeating code snippets when
|
||||
@ -20,9 +20,9 @@
|
||||
|
||||
#include "kernel.h"
|
||||
#include "msg.h"
|
||||
#include "net/ng_netreg.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "net/ng_netapi.h"
|
||||
#include "net/gnrc/netreg.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
|
||||
/**
|
||||
* @brief Unified function for getting and setting netapi options
|
||||
@ -41,7 +41,7 @@ static inline int _get_set(kernel_pid_t pid, uint16_t type,
|
||||
{
|
||||
msg_t cmd;
|
||||
msg_t ack;
|
||||
ng_netapi_opt_t o;
|
||||
gnrc_netapi_opt_t o;
|
||||
/* set ńetapi's option struct */
|
||||
o.opt = opt;
|
||||
o.context = context;
|
||||
@ -56,7 +56,7 @@ static inline int _get_set(kernel_pid_t pid, uint16_t type,
|
||||
return (int)ack.content.value;
|
||||
}
|
||||
|
||||
static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, ng_pktsnip_t *pkt)
|
||||
static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
msg_t msg;
|
||||
/* set the outgoing message's fields */
|
||||
@ -66,56 +66,56 @@ static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, ng_pktsnip_t *pkt)
|
||||
return msg_send(&msg, pid);
|
||||
}
|
||||
|
||||
static inline int _snd_rcv_dispatch(ng_nettype_t type, uint32_t demux_ctx,
|
||||
uint16_t cmd, ng_pktsnip_t *pkt)
|
||||
static inline int _snd_rcv_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
uint16_t cmd, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
int numof = ng_netreg_num(type, demux_ctx);
|
||||
int numof = gnrc_netreg_num(type, demux_ctx);
|
||||
|
||||
if (numof != 0) {
|
||||
ng_netreg_entry_t *sendto = ng_netreg_lookup(type, demux_ctx);
|
||||
gnrc_netreg_entry_t *sendto = gnrc_netreg_lookup(type, demux_ctx);
|
||||
|
||||
ng_pktbuf_hold(pkt, numof - 1);
|
||||
gnrc_pktbuf_hold(pkt, numof - 1);
|
||||
|
||||
while (sendto) {
|
||||
_snd_rcv(sendto->pid, cmd, pkt);
|
||||
sendto = ng_netreg_getnext(sendto);
|
||||
sendto = gnrc_netreg_getnext(sendto);
|
||||
}
|
||||
}
|
||||
|
||||
return numof;
|
||||
}
|
||||
int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt)
|
||||
int gnrc_netapi_send(kernel_pid_t pid, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
return _snd_rcv(pid, NG_NETAPI_MSG_TYPE_SND, pkt);
|
||||
return _snd_rcv(pid, GNRC_NETAPI_MSG_TYPE_SND, pkt);
|
||||
}
|
||||
|
||||
int ng_netapi_dispatch_send(ng_nettype_t type, uint32_t demux_ctx,
|
||||
ng_pktsnip_t *pkt)
|
||||
int gnrc_netapi_dispatch_send(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
return _snd_rcv_dispatch(type, demux_ctx, NG_NETAPI_MSG_TYPE_SND, pkt);
|
||||
return _snd_rcv_dispatch(type, demux_ctx, GNRC_NETAPI_MSG_TYPE_SND, pkt);
|
||||
}
|
||||
|
||||
int ng_netapi_receive(kernel_pid_t pid, ng_pktsnip_t *pkt)
|
||||
int gnrc_netapi_receive(kernel_pid_t pid, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
return _snd_rcv(pid, NG_NETAPI_MSG_TYPE_RCV, pkt);
|
||||
return _snd_rcv(pid, GNRC_NETAPI_MSG_TYPE_RCV, pkt);
|
||||
}
|
||||
|
||||
int ng_netapi_dispatch_receive(ng_nettype_t type, uint32_t demux_ctx,
|
||||
ng_pktsnip_t *pkt)
|
||||
int gnrc_netapi_dispatch_receive(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
return _snd_rcv_dispatch(type, demux_ctx, NG_NETAPI_MSG_TYPE_RCV, pkt);
|
||||
return _snd_rcv_dispatch(type, demux_ctx, GNRC_NETAPI_MSG_TYPE_RCV, pkt);
|
||||
}
|
||||
|
||||
int ng_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len)
|
||||
int gnrc_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len)
|
||||
{
|
||||
return _get_set(pid, NG_NETAPI_MSG_TYPE_GET, opt, context,
|
||||
return _get_set(pid, GNRC_NETAPI_MSG_TYPE_GET, opt, context,
|
||||
data, data_len);
|
||||
}
|
||||
|
||||
int ng_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len)
|
||||
int gnrc_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
|
||||
void *data, size_t data_len)
|
||||
{
|
||||
return _get_set(pid, NG_NETAPI_MSG_TYPE_SET, opt, context,
|
||||
return _get_set(pid, GNRC_NETAPI_MSG_TYPE_SET, opt, context,
|
||||
data, data_len);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_ipv6_hdr
|
||||
MODULE = gnrc_netif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -16,37 +16,37 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#ifdef MODULE_GNRC_IPV6_NETIF
|
||||
#include "net/gnrc/ipv6/netif.h"
|
||||
#endif
|
||||
|
||||
static ng_netif_handler_t if_handler[] = {
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
{ ng_ipv6_netif_add, ng_ipv6_netif_remove },
|
||||
static gnrc_netif_handler_t if_handler[] = {
|
||||
#ifdef MODULE_GNRC_IPV6_NETIF
|
||||
{ gnrc_ipv6_netif_add, gnrc_ipv6_netif_remove },
|
||||
#endif
|
||||
/* #ifdef MODULE_NG_IPV4_NETIF
|
||||
/* #ifdef MODULE_GNRC_IPV4_NETIF
|
||||
* { ipv4_netif_add, ipv4_netif_remove },
|
||||
* #endif ... you get the idea
|
||||
*/
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static kernel_pid_t ifs[NG_NETIF_NUMOF];
|
||||
static kernel_pid_t ifs[GNRC_NETIF_NUMOF];
|
||||
|
||||
void ng_netif_init(void)
|
||||
void gnrc_netif_init(void)
|
||||
{
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
for (int i = 0; i < GNRC_NETIF_NUMOF; i++) {
|
||||
ifs[i] = KERNEL_PID_UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
int ng_netif_add(kernel_pid_t pid)
|
||||
int gnrc_netif_add(kernel_pid_t pid)
|
||||
{
|
||||
kernel_pid_t *free_entry = NULL;
|
||||
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
for (int i = 0; i < GNRC_NETIF_NUMOF; i++) {
|
||||
if (ifs[i] == pid) {
|
||||
return 0;
|
||||
}
|
||||
@ -68,11 +68,11 @@ int ng_netif_add(kernel_pid_t pid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ng_netif_remove(kernel_pid_t pid)
|
||||
void gnrc_netif_remove(kernel_pid_t pid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
for (i = 0; i < GNRC_NETIF_NUMOF; i++) {
|
||||
if (ifs[i] == pid) {
|
||||
ifs[i] = KERNEL_PID_UNDEF;
|
||||
|
||||
@ -85,11 +85,11 @@ void ng_netif_remove(kernel_pid_t pid)
|
||||
}
|
||||
}
|
||||
|
||||
size_t ng_netif_get(kernel_pid_t *netifs)
|
||||
size_t gnrc_netif_get(kernel_pid_t *netifs)
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
for (int i = 0; i < GNRC_NETIF_NUMOF; i++) {
|
||||
if (ifs[i] != KERNEL_PID_UNDEF) {
|
||||
netifs[size++] = ifs[i];
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
|
||||
static inline int _dehex(char c, int default_)
|
||||
{
|
||||
@ -31,7 +31,7 @@ static inline int _dehex(char c, int default_)
|
||||
}
|
||||
}
|
||||
|
||||
size_t ng_netif_addr_from_str(uint8_t *out, size_t out_len, const char *str)
|
||||
size_t gnrc_netif_addr_from_str(uint8_t *out, size_t out_len, const char *str)
|
||||
{
|
||||
/* Walk over str from the end. */
|
||||
/* Take two chars a time as one hex value (%hhx). */
|
@ -12,15 +12,15 @@
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
|
||||
static inline char _half_byte_to_char(uint8_t half_byte)
|
||||
{
|
||||
return (half_byte < 10) ? ('0' + half_byte) : ('a' + (half_byte - 10));
|
||||
}
|
||||
|
||||
char *ng_netif_addr_to_str(char *out, size_t out_len, const uint8_t *addr,
|
||||
size_t addr_len)
|
||||
char *gnrc_netif_addr_to_str(char *out, size_t out_len, const uint8_t *addr,
|
||||
size_t addr_len)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_icmpv6_echo
|
||||
MODULE = gnrc_netif_hdr
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -15,12 +15,12 @@
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/ng_netif/hdr.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
|
||||
void ng_netif_hdr_print(ng_netif_hdr_t *hdr)
|
||||
void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
char addr_str[NG_NETIF_HDR_L2ADDR_MAX_LEN * 3];
|
||||
char addr_str[GNRC_NETIF_HDR_L2ADDR_MAX_LEN * 3];
|
||||
|
||||
printf("if_pid: %" PRIkernel_pid " ", hdr->if_pid);
|
||||
printf("rssi: %" PRIu8 " ", hdr->rssi);
|
||||
@ -28,9 +28,9 @@ void ng_netif_hdr_print(ng_netif_hdr_t *hdr)
|
||||
|
||||
if (hdr->src_l2addr_len > 0) {
|
||||
printf("src_l2addr: %s\n",
|
||||
ng_netif_addr_to_str(addr_str, sizeof(addr_str),
|
||||
ng_netif_hdr_get_src_addr(hdr),
|
||||
(size_t)hdr->src_l2addr_len));
|
||||
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str),
|
||||
gnrc_netif_hdr_get_src_addr(hdr),
|
||||
(size_t)hdr->src_l2addr_len));
|
||||
}
|
||||
else {
|
||||
puts("src_l2addr: (nil)");
|
||||
@ -38,9 +38,9 @@ void ng_netif_hdr_print(ng_netif_hdr_t *hdr)
|
||||
|
||||
if (hdr->dst_l2addr_len > 0) {
|
||||
printf("dst_l2addr: %s\n",
|
||||
ng_netif_addr_to_str(addr_str, sizeof(addr_str),
|
||||
ng_netif_hdr_get_dst_addr(hdr),
|
||||
(size_t)hdr->dst_l2addr_len));
|
||||
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str),
|
||||
gnrc_netif_hdr_get_dst_addr(hdr),
|
||||
(size_t)hdr->dst_l2addr_len));
|
||||
}
|
||||
else {
|
||||
puts("dst_l2addr: (nil)");
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_ndp_node
|
||||
MODULE = gnrc_netreg
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
166
sys/net/gnrc/netreg/gnrc_netreg.c
Normal file
166
sys/net/gnrc/netreg/gnrc_netreg.c
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "clist.h"
|
||||
#include "utlist.h"
|
||||
#include "net/gnrc/netreg.h"
|
||||
#include "net/gnrc/nettype.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/icmpv6.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
|
||||
#define _INVALID_TYPE(type) (((type) < GNRC_NETTYPE_UNDEF) || ((type) >= GNRC_NETTYPE_NUMOF))
|
||||
|
||||
/* The registry as lookup table by gnrc_nettype_t */
|
||||
static gnrc_netreg_entry_t *netreg[GNRC_NETTYPE_NUMOF];
|
||||
|
||||
void gnrc_netreg_init(void)
|
||||
{
|
||||
/* set all pointers in registry to NULL */
|
||||
memset(netreg, 0, GNRC_NETTYPE_NUMOF * sizeof(gnrc_netreg_entry_t *));
|
||||
}
|
||||
|
||||
int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
|
||||
{
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
LL_PREPEND(netreg[type], entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gnrc_netreg_unregister(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
|
||||
{
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LL_DELETE(netreg[type], entry);
|
||||
}
|
||||
|
||||
gnrc_netreg_entry_t *gnrc_netreg_lookup(gnrc_nettype_t type, uint32_t demux_ctx)
|
||||
{
|
||||
gnrc_netreg_entry_t *res;
|
||||
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LL_SEARCH_SCALAR(netreg[type], res, demux_ctx, demux_ctx);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int gnrc_netreg_num(gnrc_nettype_t type, uint32_t demux_ctx)
|
||||
{
|
||||
int num = 0;
|
||||
gnrc_netreg_entry_t *entry;
|
||||
|
||||
if (_INVALID_TYPE(type)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry = netreg[type];
|
||||
|
||||
while (entry != NULL) {
|
||||
if (entry->demux_ctx == demux_ctx) {
|
||||
num++;
|
||||
}
|
||||
|
||||
entry = entry->next;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
gnrc_netreg_entry_t *gnrc_netreg_getnext(gnrc_netreg_entry_t *entry)
|
||||
{
|
||||
uint32_t demux_ctx;
|
||||
|
||||
if (entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
demux_ctx = entry->demux_ctx;
|
||||
|
||||
LL_SEARCH_SCALAR(entry->next, entry, demux_ctx, demux_ctx);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
int gnrc_netreg_calc_csum(gnrc_pktsnip_t *hdr, gnrc_pktsnip_t *pseudo_hdr)
|
||||
{
|
||||
if (pseudo_hdr == NULL) {
|
||||
/* XXX: Might be allowed for future checksums.
|
||||
* If this is the case: move this to the branches were it
|
||||
* is needed. */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (hdr->type) {
|
||||
#ifdef MODULE_GNRC_ICMPV6
|
||||
case GNRC_NETTYPE_ICMPV6:
|
||||
return gnrc_icmpv6_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_TCP
|
||||
case GNRC_NETTYPE_TCP:
|
||||
return gnrc_tcp_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
case GNRC_NETTYPE_UDP:
|
||||
return gnrc_udp_calc_csum(hdr, pseudo_hdr);
|
||||
#endif
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
gnrc_pktsnip_t *gnrc_netreg_hdr_build(gnrc_nettype_t type, gnrc_pktsnip_t *payload,
|
||||
uint8_t *src, uint8_t src_len,
|
||||
uint8_t *dst, uint8_t dst_len)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
return gnrc_ipv6_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_TCP
|
||||
|
||||
case GNRC_NETTYPE_TCP:
|
||||
return gnrc_tcp_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_UDP
|
||||
|
||||
case GNRC_NETTYPE_UDP:
|
||||
return gnrc_udp_hdr_build(payload, src, src_len, dst, dst_len);
|
||||
#endif
|
||||
|
||||
default:
|
||||
(void)payload;
|
||||
(void)src;
|
||||
(void)src_len;
|
||||
(void)dst;
|
||||
(void)dst_len;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_netif_hdr
|
||||
MODULE = gnrc_nettest
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
259
sys/net/gnrc/nettest/gnrc_nettest.c
Normal file
259
sys/net/gnrc/nettest/gnrc_nettest.c
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "msg.h"
|
||||
#include "mutex.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/netopt.h"
|
||||
#include "net/gnrc/netreg.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "timex.h"
|
||||
#include "thread.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#include "net/gnrc/nettest.h"
|
||||
|
||||
static gnrc_nettest_opt_cbs_t _opt_cbs[NETOPT_NUMOF];
|
||||
static mutex_t _mutex = MUTEX_INIT;
|
||||
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
|
||||
static char _stack[GNRC_NETTEST_STACK_SIZE];
|
||||
|
||||
static void *_event_loop(void *arg);
|
||||
|
||||
void gnrc_nettest_register_get(netopt_t opt, gnrc_nettest_opt_cb_t cb)
|
||||
{
|
||||
mutex_lock(&_mutex);
|
||||
_opt_cbs[opt].get = cb;
|
||||
mutex_unlock(&_mutex);
|
||||
}
|
||||
|
||||
void gnrc_nettest_register_set(netopt_t opt, gnrc_nettest_opt_cb_t cb)
|
||||
{
|
||||
mutex_lock(&_mutex);
|
||||
_opt_cbs[opt].set = cb;
|
||||
mutex_unlock(&_mutex);
|
||||
}
|
||||
|
||||
static gnrc_nettest_res_t _pkt_test(uint16_t cmd_type, kernel_pid_t pid,
|
||||
gnrc_pktsnip_t *in, unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out)
|
||||
{
|
||||
msg_t msg;
|
||||
timex_t t = { 0, GNRC_NETTEST_TIMEOUT };
|
||||
gnrc_nettest_res_t res = GNRC_NETTEST_SUCCESS;
|
||||
|
||||
msg.type = cmd_type;
|
||||
msg.content.ptr = (char *)in;
|
||||
|
||||
msg_send(&msg, pid);
|
||||
timex_normalize(&t);
|
||||
|
||||
if (exp_pkts == 0) {
|
||||
thread_yield();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < exp_pkts; i++) {
|
||||
gnrc_pktsnip_t *out;
|
||||
const gnrc_pktsnip_t *exp = exp_out[i];
|
||||
|
||||
if (vtimer_msg_receive_timeout(&msg, t) < 0) {
|
||||
return GNRC_NETTEST_TIMED_OUT;
|
||||
}
|
||||
|
||||
if (msg.type != cmd_type) {
|
||||
return GNRC_NETTEST_WRONG_MSG;
|
||||
}
|
||||
|
||||
if (msg.sender_pid != exp_senders[i]) {
|
||||
return GNRC_NETTEST_WRONG_SENDER;
|
||||
}
|
||||
|
||||
out = (gnrc_pktsnip_t *)msg.content.ptr;
|
||||
|
||||
if (out == NULL) {
|
||||
return GNRC_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
while (out && exp) {
|
||||
if ((out->users != exp->users) ||
|
||||
(out->size != exp->size) ||
|
||||
(out->type != exp->type) ||
|
||||
(memcmp(out->data, exp->data, out->size) != 0)) {
|
||||
return GNRC_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
out = out->next;
|
||||
exp = exp->next;
|
||||
}
|
||||
|
||||
gnrc_pktbuf_release((gnrc_pktsnip_t *)msg.content.ptr);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gnrc_nettest_res_t gnrc_nettest_send(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out,
|
||||
gnrc_nettype_t exp_type, uint32_t exp_demux_ctx)
|
||||
{
|
||||
gnrc_netreg_entry_t reg_entry = { NULL, exp_demux_ctx, thread_getpid() };
|
||||
gnrc_nettest_res_t res;
|
||||
|
||||
gnrc_netreg_register(exp_type, ®_entry);
|
||||
|
||||
res = _pkt_test(GNRC_NETAPI_MSG_TYPE_SND, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
gnrc_netreg_unregister(exp_type, ®_entry);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gnrc_nettest_res_t gnrc_nettest_send_iface(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out)
|
||||
{
|
||||
gnrc_nettest_res_t res;
|
||||
|
||||
gnrc_netif_add(thread_getpid());
|
||||
|
||||
res = _pkt_test(GNRC_NETAPI_MSG_TYPE_SND, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
gnrc_netif_remove(thread_getpid());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gnrc_nettest_res_t gnrc_nettest_receive(kernel_pid_t pid, gnrc_pktsnip_t *in,
|
||||
unsigned int exp_pkts,
|
||||
const kernel_pid_t *exp_senders,
|
||||
const gnrc_pktsnip_t **exp_out,
|
||||
gnrc_nettype_t exp_type, uint32_t exp_demux_ctx)
|
||||
{
|
||||
gnrc_netreg_entry_t reg_entry = { NULL, exp_demux_ctx, thread_getpid() };
|
||||
gnrc_nettest_res_t res;
|
||||
|
||||
gnrc_netreg_register(exp_type, ®_entry);
|
||||
|
||||
res = _pkt_test(GNRC_NETAPI_MSG_TYPE_RCV, pid, in, exp_pkts, exp_senders,
|
||||
exp_out);
|
||||
|
||||
gnrc_netreg_unregister(exp_type, ®_entry);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gnrc_nettest_res_t gnrc_nettest_get(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
void *exp_data, int exp_res)
|
||||
{
|
||||
if ((exp_res != gnrc_netapi_get(pid, opt, context, data, data_len)) ||
|
||||
((exp_res > 0) && (memcpy(exp_data, data, exp_res)))) {
|
||||
return GNRC_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
return GNRC_NETTEST_SUCCESS;
|
||||
}
|
||||
|
||||
gnrc_nettest_res_t gnrc_nettest_set(kernel_pid_t pid, netopt_t opt,
|
||||
uint16_t context, void *data, size_t data_len,
|
||||
int exp_res)
|
||||
{
|
||||
if (exp_res != gnrc_netapi_get(pid, opt, context, data, data_len)) {
|
||||
return GNRC_NETTEST_FAIL;
|
||||
}
|
||||
|
||||
return GNRC_NETTEST_SUCCESS;
|
||||
}
|
||||
|
||||
int gnrc_nettest_init(void)
|
||||
{
|
||||
if (_pid <= KERNEL_PID_UNDEF) {
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_NETTEST_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, NULL, "nettest");
|
||||
}
|
||||
|
||||
return _pid;
|
||||
}
|
||||
|
||||
void gnrc_nettest_reset(void)
|
||||
{
|
||||
for (int i = 0; i < NETOPT_NUMOF; i++) {
|
||||
_opt_cbs[i].get = NULL;
|
||||
_opt_cbs[i].set = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t _get_set_opt(gnrc_nettest_opt_cb_t cb, uint16_t context,
|
||||
void *data, uint16_t data_len)
|
||||
{
|
||||
int res;
|
||||
|
||||
mutex_lock(&_mutex);
|
||||
if (cb != NULL) {
|
||||
res = cb(context, data, data_len);
|
||||
}
|
||||
else {
|
||||
res = -ENOTSUP;
|
||||
}
|
||||
mutex_unlock(&_mutex);
|
||||
return (uint32_t)res;
|
||||
}
|
||||
|
||||
static void *_event_loop(void *arg)
|
||||
{
|
||||
msg_t reply, msg_queue[GNRC_NETTEST_MSG_QUEUE_SIZE];
|
||||
|
||||
(void)arg;
|
||||
msg_init_queue(msg_queue, GNRC_NETTEST_MSG_QUEUE_SIZE);
|
||||
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
|
||||
|
||||
while (1) {
|
||||
msg_t msg;
|
||||
gnrc_netapi_opt_t *opt;
|
||||
|
||||
msg_receive(&msg);
|
||||
|
||||
switch (msg.type) {
|
||||
case GNRC_NETAPI_MSG_TYPE_GET:
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
reply.content.value = _get_set_opt(_opt_cbs[opt->opt].get,
|
||||
opt->context, opt->data,
|
||||
opt->data_len);
|
||||
break;
|
||||
|
||||
case GNRC_NETAPI_MSG_TYPE_SET:
|
||||
opt = (gnrc_netapi_opt_t *)msg.content.ptr;
|
||||
reply.content.value = _get_set_opt(_opt_cbs[opt->opt].set,
|
||||
opt->context, opt->data,
|
||||
opt->data_len);
|
||||
break;
|
||||
}
|
||||
|
||||
msg_reply(&msg, &reply);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** @} */
|
3
sys/net/gnrc/network_layer/icmpv6/Makefile
Normal file
3
sys/net/gnrc/network_layer/icmpv6/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = gnrc_icmpv6
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
3
sys/net/gnrc/network_layer/icmpv6/echo/Makefile
Normal file
3
sys/net/gnrc/network_layer/icmpv6/echo/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = gnrc_icmpv6_echo
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user