Added NullNet, a network layer for non-IP-enabled cases
This commit is contained in:
parent
7d262d6d89
commit
d9f9138ed2
|
@ -121,6 +121,9 @@ ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
|||
CONTIKI_WITH_RPL ?= 1
|
||||
CONTIKI_WITH_RPL_LITE ?= 1
|
||||
MODULES += os/net/ipv6 os/net/ip
|
||||
else
|
||||
CFLAGS += -DNETSTACK_CONF_WITH_NULLNET=1
|
||||
MODULES += os/net/nullnet
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_NET),MAKE_NET_OTHER)
|
||||
|
|
|
@ -40,6 +40,39 @@ ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a
|
|||
JNILIB = $(OBJECTDIR)/$(LIBNAME).$(TARGET)
|
||||
CONTIKI_APP_OBJ = $(CONTIKI_APP).co
|
||||
|
||||
# Modules
|
||||
MODULES += os/net os/net/mac os/net/mac/framer os/net/ip64-addr
|
||||
|
||||
## Copied from Makefile.include, since Cooja overrides CFLAGS et al
|
||||
MAKE_NET_NULLNET = 0
|
||||
MAKE_NET_IPV6 = 1
|
||||
MAKE_NET_OTHER = 2
|
||||
|
||||
# Make IPv6 the default stack
|
||||
MAKE_NET ?= MAKE_NET_IPV6
|
||||
|
||||
ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
||||
CFLAGS += -DNETSTACK_CONF_WITH_IPV6=1
|
||||
CONTIKI_WITH_RPL ?= 1
|
||||
CONTIKI_WITH_RPL_LITE ?= 1
|
||||
MODULES += os/net/ipv6 os/net/ip
|
||||
COOJA_NET = uip-driver.c
|
||||
else
|
||||
COOJA_NET =
|
||||
endif
|
||||
|
||||
ifeq ($(CONTIKI_WITH_RPL),1)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
ifeq ($(CONTIKI_WITH_RPL_LITE),1)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1
|
||||
MODULES += os/net/rpl-lite
|
||||
else
|
||||
MODULES += os/net/rpl
|
||||
endif
|
||||
else
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=0
|
||||
endif
|
||||
|
||||
### COOJA platform sources
|
||||
COOJA = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
CONTIKI_TARGET_DIRS = . dev lib sys cfs net
|
||||
|
@ -56,8 +89,6 @@ COOJA_INTFS = beep.c button-sensor.c ip.c leds-arch.c moteid.c \
|
|||
|
||||
COOJA_CORE = random.c sensors.c leds.c
|
||||
|
||||
COOJA_NET = uip-driver.c
|
||||
|
||||
# (COOJA_SOURCEFILES contains additional sources set from simulator)
|
||||
CONTIKI_TARGET_SOURCEFILES = \
|
||||
$(COOJA_BASE) $(COOJA_INTFS) $(COOJA_CORE) $(COOJA_NET) $(COOJA_SOURCEFILES)
|
||||
|
@ -76,31 +107,3 @@ ifeq ($(WERROR),1)
|
|||
CFLAGSNO += -Werror
|
||||
endif
|
||||
CFLAGS += $(CFLAGSNO)
|
||||
|
||||
MODULES += os/net os/net/mac os/net/mac/framer os/net/ip64-addr
|
||||
|
||||
## Copied from Makefile.include, since Cooja overrides CFLAGS et al
|
||||
MAKE_NET_NULLNET = 0
|
||||
MAKE_NET_IPV6 = 1
|
||||
|
||||
# Make IPv6 the default stack
|
||||
MAKE_NET ?= MAKE_NET_IPV6
|
||||
|
||||
ifeq ($(MAKE_NET),MAKE_NET_IPV6)
|
||||
CFLAGS += -DNETSTACK_CONF_WITH_IPV6=1
|
||||
CONTIKI_WITH_RPL ?= 1
|
||||
CONTIKI_WITH_RPL_LITE ?= 1
|
||||
MODULES += os/net/ipv6 os/net/ip
|
||||
endif
|
||||
|
||||
ifeq ($(CONTIKI_WITH_RPL),1)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
ifeq ($(CONTIKI_WITH_RPL_LITE),1)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1
|
||||
MODULES += os/net/rpl-lite
|
||||
else
|
||||
MODULES += os/net/rpl
|
||||
endif
|
||||
else
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=0
|
||||
endif
|
||||
|
|
|
@ -57,8 +57,6 @@
|
|||
#else /* NETSTACK_CONF_H */
|
||||
|
||||
/* Default network config */
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
#define CSMA_CONF_SEND_SOFT_ACK 1
|
||||
#define CSMA_CONF_ACK_WAIT_TIME RTIMER_SECOND / 500
|
||||
#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME 0
|
||||
|
@ -66,8 +64,6 @@
|
|||
/* Radio setup */
|
||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#endif /* NETSTACK_CONF_H */
|
||||
|
||||
/* Default network config */
|
||||
|
|
|
@ -112,7 +112,7 @@ create_frame(int do_create)
|
|||
} else if(packetbuf_hdralloc(hdr_len)) {
|
||||
frame802154_create(¶ms, packetbuf_hdrptr());
|
||||
|
||||
LOG_INFO("15.4-OUT: %2X ", params.fcf.frame_type);
|
||||
LOG_INFO("Out: %2X ", params.fcf.frame_type);
|
||||
LOG_INFO_LLADDR((const linkaddr_t *)params.dest_addr);
|
||||
LOG_INFO_(" %d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#define NETSTACK_NETWORK sicslowpan_driver
|
||||
#elif NETSTACK_CONF_WITH_NULLNET
|
||||
#error Nullnet layer not implemented yet
|
||||
#define NETSTACK_NETWORK nullnet_driver
|
||||
#elif NETSTACK_CONF_WITH_OTHER
|
||||
#define NETSTACK_NETWORK NETSTACK_CONF_OTHER_NETWORK
|
||||
#else
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright (c) 2017, RISE SICS.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* NullNet, a minimal network layer.
|
||||
* \author
|
||||
* Simon Duquennoy <simon.duquennoy@ri.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup nullnet
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/nullnet/nullnet.h"
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "NullNet"
|
||||
#define LOG_LEVEL LOG_LEVEL_NULLNET
|
||||
|
||||
static nullnet_input_callback current_callback = NULL;
|
||||
/*--------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
LOG_INFO("init\n");
|
||||
current_callback = NULL;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static void
|
||||
input(void)
|
||||
{
|
||||
if(current_callback != NULL) {
|
||||
LOG_INFO("received %u bytes from ", packetbuf_datalen());
|
||||
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
LOG_INFO_("\n");
|
||||
current_callback(packetbuf_dataptr(), packetbuf_datalen(),
|
||||
packetbuf_addr(PACKETBUF_ADDR_SENDER), packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
void
|
||||
nullnet_set_input_callback(nullnet_input_callback callback)
|
||||
{
|
||||
current_callback = callback;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
void
|
||||
nullnet_output(const void *data, uint16_t len, const linkaddr_t *dest)
|
||||
{
|
||||
packetbuf_clear();
|
||||
packetbuf_copyfrom(data, len);
|
||||
if(dest != NULL) {
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, dest);
|
||||
} else {
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &linkaddr_null);
|
||||
}
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
LOG_INFO("sending %u bytes to ", packetbuf_datalen());
|
||||
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
LOG_INFO_("\n");
|
||||
NETSTACK_MAC.send(NULL, NULL);
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
const struct network_driver nullnet_driver = {
|
||||
"nullnet",
|
||||
init,
|
||||
input
|
||||
};
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2017, RISE SICS.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* NullNet, a minimal network layer.
|
||||
* \author
|
||||
* Simon Duquennoy <simon.duquennoy@ri.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup nullnet
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef NULLNET_H_
|
||||
#define NULLNET_H_
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
||||
typedef void (* nullnet_input_callback)(const void *data, uint16_t len,
|
||||
const linkaddr_t *src, const linkaddr_t *dest);
|
||||
|
||||
void nullnet_set_input_callback(nullnet_input_callback callback);
|
||||
void nullnet_output(const void *data, uint16_t len, const linkaddr_t *dest);
|
||||
|
||||
#endif /* NULLNET_H_ */
|
||||
/** @} */
|
|
@ -94,6 +94,10 @@
|
|||
#define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_6LOWPAN */
|
||||
|
||||
#ifndef LOG_CONF_LEVEL_NULLNET
|
||||
#define LOG_CONF_LEVEL_NULLNET LOG_LEVEL_INFO
|
||||
#endif /* LOG_CONF_LEVEL_NULLNET */
|
||||
|
||||
#ifndef LOG_CONF_LEVEL_MAC
|
||||
#define LOG_CONF_LEVEL_MAC LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_MAC */
|
||||
|
|
|
@ -51,12 +51,11 @@
|
|||
#include "sys/log.h"
|
||||
#include "net/ip/ip64-addr.h"
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
int curr_log_level_rpl = LOG_CONF_LEVEL_RPL;
|
||||
int curr_log_level_tcpip = LOG_CONF_LEVEL_TCPIP;
|
||||
int curr_log_level_ipv6 = LOG_CONF_LEVEL_IPV6;
|
||||
int curr_log_level_6lowpan = LOG_CONF_LEVEL_6LOWPAN;
|
||||
int curr_log_level_nullnet = LOG_CONF_LEVEL_NULLNET;
|
||||
int curr_log_level_mac = LOG_CONF_LEVEL_MAC;
|
||||
int curr_log_level_framer = LOG_CONF_LEVEL_FRAMER;
|
||||
int curr_log_level_6top = LOG_CONF_LEVEL_6TOP;
|
||||
|
@ -66,12 +65,15 @@ struct log_module all_modules[] = {
|
|||
{"tcpip", &curr_log_level_tcpip, LOG_CONF_LEVEL_TCPIP},
|
||||
{"ipv6", &curr_log_level_ipv6, LOG_CONF_LEVEL_IPV6},
|
||||
{"6lowpan", &curr_log_level_6lowpan, LOG_CONF_LEVEL_6LOWPAN},
|
||||
{"nullnet", &curr_log_level_nullnet, LOG_CONF_LEVEL_NULLNET},
|
||||
{"mac", &curr_log_level_mac, LOG_CONF_LEVEL_MAC},
|
||||
{"framer", &curr_log_level_framer, LOG_CONF_LEVEL_FRAMER},
|
||||
{"6top", &curr_log_level_6top, LOG_CONF_LEVEL_6TOP},
|
||||
{NULL, NULL, 0},
|
||||
};
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
log_6addr(const uip_ipaddr_t *ipaddr)
|
||||
|
|
|
@ -77,6 +77,7 @@ extern int curr_log_level_rpl;
|
|||
extern int curr_log_level_tcpip;
|
||||
extern int curr_log_level_ipv6;
|
||||
extern int curr_log_level_6lowpan;
|
||||
extern int curr_log_level_nullnet;
|
||||
extern int curr_log_level_mac;
|
||||
extern int curr_log_level_framer;
|
||||
extern int curr_log_level_6top;
|
||||
|
@ -87,6 +88,7 @@ extern struct log_module all_modules[];
|
|||
#define LOG_LEVEL_TCPIP MIN((LOG_CONF_LEVEL_TCPIP), curr_log_level_tcpip)
|
||||
#define LOG_LEVEL_IPV6 MIN((LOG_CONF_LEVEL_IPV6), curr_log_level_ipv6)
|
||||
#define LOG_LEVEL_6LOWPAN MIN((LOG_CONF_LEVEL_6LOWPAN), curr_log_level_6lowpan)
|
||||
#define LOG_LEVEL_NULLNET MIN((LOG_CONF_LEVEL_NULLNET), curr_log_level_nullnet)
|
||||
#define LOG_LEVEL_MAC MIN((LOG_CONF_LEVEL_MAC), curr_log_level_mac)
|
||||
#define LOG_LEVEL_FRAMER MIN((LOG_CONF_LEVEL_FRAMER), curr_log_level_framer)
|
||||
#define LOG_LEVEL_6TOP MIN((LOG_CONF_LEVEL_6TOP), curr_log_level_6top)
|
||||
|
|
Loading…
Reference in New Issue