Skip to content

Commit

Permalink
TinyDTLS: integration into RIOT (without sockets)
Browse files Browse the repository at this point in the history
Support for TinyDTLS (0.8.6) is added together an example at 'examples/dtls-echo'.
  • Loading branch information
rfuentess committed Oct 30, 2016
1 parent ac94d38 commit cf64aba
Show file tree
Hide file tree
Showing 7 changed files with 1,203 additions and 0 deletions.
73 changes: 73 additions & 0 deletions examples/dtls-echo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# name of your application
APPLICATION = dtls_echo

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

BOARD_BLACKLIST := z1 wsn430-v1_4 wsn430-v1_3b waspmote-pro arduino-mega2560 \
msb-430h msb-430 chronos telosb msbiot cc2538dk \
saml21-xpro samr21-xpro arduino-duemilanove arduino-uno

BOARD_INSUFFICIENT_MEMORY := airfy-beacon chronos msb-430 msb-430h nrf51dongle \
nrf6310 nucleo-f103 nucleo-f334 pca10000 pca10005 spark-core \
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \
yunjia-nrf51822 z1 nucleo-f072 cc2650stk nucleo-f030\
nucleo-f070

# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules for IPv6 and sUDP
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_udp
# Add a routing protocol
USEMODULE += gnrc_rpl
# This application dumps received packets to STDIO using the pktdump module
USEMODULE += gnrc_pktdump
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
# Add also the shell, some shell commands
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps

#TinyDTLs (crypto.c) made use of pthread
ifneq ($(BOARD),native)
USEMODULE += pthread
endif

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -DDEVELHELP

# NOTE: Add the package for TinyDTLS
USEPKG += tinydtls

# NOTE: Those are taken from TinyDTLS. As the original Makefiles are
# overwitten is a good idea to preserve them here.
CFLAGS += -DDTLSv12 -DWITH_SHA256

# NOTE: This adds support for TLS_PSK_WITH_AES_128_CCM_8
CFLAGS += -DDTLS_PSK

# NOTE: This adds support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
CFLAGS += -DDTLS_ECC

# NOTE: If enabled TinyDTLS' log are disabled (if memory is a issue).
# WARNING: Sometimes the log leads to Stack pointer corrupted.
# The reason is not identified yet.
# If said issue appears, enable this line.
#CFLAGS += -DNDEBUG

# NOTE: The configuration for socket or non-socket communication in TinyDTLS.
CFLAGS += -DWITH_RIOT_GNRC

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
77 changes: 77 additions & 0 deletions examples/dtls-echo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# dtls_echo

This example shows you how to use TinyDTLS with the non-socket approach.

This code is based on ../gnrc_networking and ../gnrc_tftp.
Is a good idea to read their README.md's for any doubt of how making the
testings.

## SOCKET vs. Non-socket (GNRC)

This example is configured to use the GNRC instead of sockets (over GNRC).
At the moment, the configuration must be done manually in the Makefile of
this project.

## Fast configuration (Between RIOT instances):

Preparing the logical interfaces:

./../../dist/tools/tapsetup/tapsetup --create 2

For the server instance:

make all; PORT=tap1 make term
dtlss start
ifconfig

Do not forget to copy the IPv6 addresses!

For the client:

PORT=tap0 make term
dtlsc <IPv6's server address> "DATA TO DATA TO DATA!"

# Testings
## Boards

Those boards that do not support the `../gnrc_networking` example are included
in the `BOARD_INSUFFICIENT_MEMORY`, plus the board `cc2650stk`.

There are certain boards that are having issues with `crypto.c` and
`dtls_time.h` Which for now are in the the `BOARD_BLACKLIST`.

The boards that requires `periph_conf.h` are not tested.

Boards with problem type 1 (`crypto.c`):
z1
wsn430-v1_4
wsn430-v1_3b
waspmote-pro
msb-430h
msb-430
chronos
arduino-mega2560

Boards with problem type 2 (`dtls_time.h`):
cc2538dk
msbiot
telosb

Boards with problem type 3 (Redifinition):
saml21-xpro
samr21-xpro
arduino-uno
arduino-duemilanove

NOTE: Those on type 1 can be benefit of the following PR:
https://github.com/RIOT-OS/RIOT/issues/2360
However, there are still issues to fix.

NOTE: Those on type 2 can be fixed with the patch at
https://github.com/RIOT-OS/RIOT/pull/5974

## FIT-LAB

The code has been tested in the FIT-LAB with M3 motes.
However, erros can occurrs. Enabling the line `CFLAGS += -DNDEBUG` in
the `Makefile` reduces the risk.
Loading

0 comments on commit cf64aba

Please sign in to comment.