Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyDTLS integrated to RIOT (without sockets) #5395

Merged
merged 1 commit into from
Oct 30, 2016

Conversation

rfuentess
Copy link
Contributor

@rfuentess rfuentess commented Apr 25, 2016

This is a tested example using RIOT and TinyDTLS ( V. 0.8.2 from Eclipse instead of sourceforge).

The TinyDTLS's code had been modified to support the GNRC architecture. This is why the clone of the pkg/tinydtls is with my fork of TinyDTLS.

There is too support for simple sockets, yet the examples are not finished, and are not included in this PR.

@OlegHahm OlegHahm added this to the Release 2016.07 milestone Apr 26, 2016
@OlegHahm OlegHahm added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Apr 26, 2016
@OlegHahm
Copy link
Member

Awesome! 👍

@PeterKietzmann
Copy link
Member

I just felt like referencing this PR #4308 here

@rfuentess
Copy link
Contributor Author

Hi @PeterKietzmann, I used that PR as a reference for the structure of the examples, about all the Makefile's. That is why I preserved the list of authors.

I was unable to run the examples from that PR, plus that in January, the TinyDTLS code suffered changes, after emigrating from Sourceforge to Eclipse.

@miri64
Copy link
Member

miri64 commented Apr 27, 2016

~~Wouldn't it make more sense to

a) still have it as a package, so changes from upstream can be pulled in easier (especially for security-related libs I would argue this still makes a lot of sense)?
b) implement it with conn so other stacks than GNRC could benefit from your work?~~

Sorry, I somehow misstook your examples as lib code...

@@ -0,0 +1 @@
Subproject commit 6c479ef140b09e83b79b7e26fad8d36c7bebe442
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file, it isn't needed

@rfuentess
Copy link
Contributor Author

Hi, @authmillenon Thanks by noticing that my pkg/tinydtls/Makefile was obsolete (and was a good reminder that I need to update my fork).

b) implement it with conn so other stacks than GNRC could benefit from your work?~~

Could be, though to be honest, I selected the GNRC because was the one in the examples, additionally to the sockets. I'm not sure, which one is intended to be THE main stack in RIOT.

@rfuentess
Copy link
Contributor Author

Hi @authmillenon This is rookie question with Git. I already find my error trying to link to a branch instead to a specific commit in the new Makefile. However, I want to concentrated all my work with TinyDTLS/RIOT in one specific branch from my fork (mostly because I need to work with Linux and contiki versions as well).

Is possible to indicated to the new makefile to check a specifically branch ? ( I was experimenting to squash all my commits in one single one in the same branch, but not success)

@miri64
Copy link
Member

miri64 commented Apr 27, 2016

Could be, though to be honest, I selected the GNRC because was the one in the examples, additionally to the sockets. I'm not sure, which one is intended to be THE main stack in RIOT.

GNRC is intended to be the main stack, but we don't want to bind users to that (conn isn't a stack though, it's just a lightweight application API to a stack [which is actually used to implement sockets]). But anyways, I think for now GNRC-only should suffice for the examples.

Hi @authmillenon This is rookie question with Git. I already find my error trying to link to a branch instead to a specific commit in the new Makefile. However, I want to concentrated all my work with TinyDTLS/RIOT in one specific branch from my fork (mostly because I need to work with Linux and contiki versions as well).

Is possible to indicated to the new makefile to check a specifically branch ? ( I was experimenting to squash all my commits in one single one in the same branch, but not success)

This should be possible, just give the branch name for the PKG_VERSION macro in the makefile (which you already do, as far as I can see, so I'm not sure I understood your problem)

all: git-download
$(MAKE) -C $(PKG_BUILDDIR)

include $(RIOTBASE)/pkg/pkg.mk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the superfluous newline

@rfuentess
Copy link
Contributor Author

after updating my fork with fetch up I got the following problem.


ruentess@ ~/Projects/RIOT/examples/dtls-echo $ make all 
+ local REMOTE=git://github.com/rfuentess/TinyDTLS.git
+ local SHA1=RIOT-OS
+ basename git://github.com/rfuentess/TinyDTLS.git
+ local REMOTE_NAME=TinyDTLS.git
+ local TARGET_PATH=~/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
+ _check_commit RIOT-OS
+ git clone git://github.com/rfuentess/TinyDTLS.git ~/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
Cloning into '~/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls'...
remote: Counting objects: 279, done.
remote: Total 279 (delta 0), reused 0 (delta 0), pack-reused 278
Receiving objects: 100% (279/279), 260.88 KiB | 133.00 KiB/s, done.
Resolving deltas: 100% (121/121), done.
Checking connectivity... done.
+ git -C ~/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls checkout RIOT-OS
Switched to a new branch 'RIOT-OS'
+ set +ex
~/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls/sha2/sha2.c:35:22: fatal error: tinydtls.h: No such file or directory
 #include "tinydtls.h"

The line + _check_commit RIOT-OS made me think that is not trying to download a branch but instead a specific commit

@miri64
Copy link
Member

miri64 commented Apr 27, 2016

The line + _check_commit RIOT-OS made me think that is not trying to download a branch but instead a specific commit

of course it checks out a specific commit. A branch is just a reference (in git internal terms: a file named after the branch, containing the object identity (sha-1 sum) of the most recent commit in the branch), so when you checkout a branch you checkout the most recent commit in that branch. What are you trying to do? Regarding your error: You need to adapt your include paths, since the checked out package no resides in another directory:

diff --git a/pkg/tinydtls/Makefile.include b/pkg/tinydtls/Makefile.include
index eb1f442..f56e059 100644
--- a/pkg/tinydtls/Makefile.include
+++ b/pkg/tinydtls/Makefile.include
@@ -1 +1 @@
-INCLUDES += -I$(RIOTBASE)/pkg/tinydtls -I$(RIOTBASE)/pkg/tinydtls/tinydtls
+INCLUDES += -I$(BINDIRBASE)/pkg/$(BOARD)/tinydtls

Also: please rebase if you use the new package scheme (but I guess you already did that just not pushed ;-))

@miri64
Copy link
Member

miri64 commented Apr 27, 2016

You will realize that a lot of the GNRC API changed ;-)

@rfuentess
Copy link
Contributor Author

rfuentess commented Apr 28, 2016

Hi @authmillenon,

I upgrade my lines with the new GNRC's API (is more friendly!) but when I'm trying to compile fore testing I got the following:

user@Machine ~/Projects/RIOT/examples/dtls-echo $ make all
Building application "dtls_echo" for "native" with MCU "native".

"make" -C /home/user/Projects/RIOT/pkg/tinydtls
rm -Rf /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
mkdir -p /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
/home/user/Projects/RIOT/dist/tools/git/git-cache clone "git://github.com/user/TinyDTLS.git" "RIOT-OS" "/home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls"
+ local REMOTE=git://github.com/user/TinyDTLS.git
+ local SHA1=RIOT-OS
+ basename git://github.com/user/TinyDTLS.git
+ local REMOTE_NAME=TinyDTLS.git
+ local TARGET_PATH=/home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
+ _check_commit RIOT-OS
+ git_cache cat-file -e RIOT-OS^{commit}
+ git -C /home/user/.gitcache cat-file -e RIOT-OS^{commit}
fatal: Cannot change to '/home/user/.gitcache': No such file or directory
+ git clone git://github.com/user/TinyDTLS.git /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
Cloning into '/home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls'...
remote: Counting objects: 279, done.
remote: Total 279 (delta 0), reused 0 (delta 0), pack-reused 278
Receiving objects: 100% (279/279), 260.88 KiB | 98.00 KiB/s, done.
Resolving deltas: 100% (121/121), done.
Checking connectivity... done.
+ git -C /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls checkout RIOT-OS
Branch RIOT-OS set up to track remote branch RIOT-OS from origin.
Switched to a new branch 'RIOT-OS'
+ set +ex
if test -d "/home/user/Projects/RIOT/pkg/tinydtls"/patches; then git -C "/home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls" am --ignore-whitespace "/home/user/Projects/RIOT/pkg/tinydtls"/patches/*.patch; fi
touch /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls/.git-downloaded
make -C /home/user/Projects/RIOT/examples/dtls-echo/bin/pkg/native/tinydtls
..
...

gcc: error: /home/user/Projects/RIOT/examples/dtls-echo/bin/native/gnrc_netif_default.a: No such file or directory
make: *** [all] Error 1

I tried adding the include "net/gnrc/netif.h" to the client and server but I still got that error. Plus, I'm seeing there are many netif in that compilation. Any suggestion to where to look for the problem?

@miri64
Copy link
Member

miri64 commented Apr 28, 2016

Including a header does not do much to include a module ;-). You have to add it to the USEMODULE list in your application's Makefile, but the module does not exist anymore: it was renamed to gnrc_netdev_default. Since your branch seems to be based on an older version, I think its best if you compare your Makefiles to the Makefile of the gnrc_networking application in current master.

@rfuentess rfuentess force-pushed the TinyDTLS-GNRC branch 2 times, most recently from b73a90c to b739d21 Compare April 29, 2016 17:52
@rfuentess
Copy link
Contributor Author

Many thanks @authmillenon, I just forget the Makefile and didn't expected that after 3 months some packages could not be the same anymore.

Ok, let see if I didn't screwed anything after the rebase.

@OlegHahm OlegHahm added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 29, 2016
@OlegHahm
Copy link
Member

Setting the CI label to have Travis and Murdock have a look.

@rfuentess rfuentess force-pushed the TinyDTLS-GNRC branch 2 times, most recently from 589b969 to 34329dd Compare May 3, 2016 12:18
@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 24, 2016
@biboc
Copy link
Member

biboc commented Oct 24, 2016

Most of the board are black listed, shouldn't we fix bugs for boards before merging it?

@miri64
Copy link
Member

miri64 commented Oct 24, 2016

Most of the board are black listed, shouldn't we fix bugs for boards before merging it?

👍

@rfuentess
Copy link
Contributor Author

Most of the board are black listed, shouldn't we fix bugs for boards before merging it?

For me is OK as that is a wise action for RIOT. Though, I'll be unable to work closely on them until finishing the thesis and the defense (March next year).

If this is action is preferred, then maybe is a good idea to close this PR and open a new one when those bugs are fixed.

@kYc0o kYc0o removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 26, 2016
@miri64
Copy link
Member

miri64 commented Oct 27, 2016

For now we need a rebase. Also: now that sock is in, consider porting to that (you will find it is a lot more comfortable than conn, also see #6005).

@rfuentess
Copy link
Contributor Author

Sorry by the delay. I hope I had fixed correctly the chaos.

For now we need a rebase. Also: now that sock is in, consider porting to that (you will find it is a lot more comfortable than conn, also see #6005 ).

I was planning to do it after my thesis. But, I had though that conn was intended to be used instead of socket. Oh well, minor thing.

@miri64
Copy link
Member

miri64 commented Oct 27, 2016

@rfuentess (POSIX) sockets and sock are a different thing. sock is the new application layer API that is about to replace conn and is a lot more comfortable to implement/use.

@miri64
Copy link
Member

miri64 commented Oct 27, 2016

Here's some reference ;-).

@miri64
Copy link
Member

miri64 commented Oct 27, 2016

Sorry about the noise :( I now realize that the occurances of conn were only because of the missing rebase in the code :/

@miri64
Copy link
Member

miri64 commented Oct 27, 2016

@rfuentess Please consider rfuentess#2 to address my comments from April. Other than that I say we can merge.

@rfuentess
Copy link
Contributor Author

rfuentess commented Oct 29, 2016

@miri64 merged and rebase.

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK & go when travis (murdock, I'm tired, okay?) is happy.

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 29, 2016
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some adaptations to current master

PKG_NAME=tinydtls
PKG_URL=git://github.com/rfuentess/TinyDTLS.git
# PKG_VERSION=RIOT-OS
PKG_VERSION=f824b5553a865c186a9b41236be03358f0c8feaf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace (as reported by Murdock)

(void) _dtls_kernel_pid;

/* Only one instance of the server */
if (server.pid != KERNEL_PID_UNDEF) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #5526 was merged this needs to be server.target.pid (and this PR needs a rebase to current master)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this PR needs a rebase to current master

Just to avoid the conflicts from the previous week. This means to fetch my local repository with the changes from RIOT-OS and then rebase my branch with those changes, right ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but just to avoid any confusion here is what you should do

git remote add riot git://github.com/RIOT-OS/RIOT  # you might already have done this
git fetch riot
git rebase -i riot/upstream # here remove any commits that do NOT belong to this PR
git push -f

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you don't have any conflicts in here this should run rather smoothly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, It was riot/master, right ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ähh yes. Sorry.

dtls_init();

/* We genarte */
server.pid = thread_create(_server_stack, sizeof(_server_stack),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use gnrc_netreg_entry_init_pid() to initialize server, please.

static void stop_server(void)
{
/* check if server is running at all */
if (server.pid == KERNEL_PID_UNDEF) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server.target.pid


/* stop server */
gnrc_netreg_unregister(GNRC_NETTYPE_UDP, &server);
server.pid = KERNEL_PID_UNDEF;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server.target.pid

@rfuentess
Copy link
Contributor Author

rfuentess commented Oct 30, 2016

Ok, fetched riot, rebase with riot/master, added the changes requested, upgraded the client, tested correctly the client and server in native. BUT now the FIT IoT-LAB (greenoble and paris sites) are returning an empty list when ifconfig is used.

Not sure if it is just bad timing with the testbed or something we are forgetting to upgrade on the Makefile.


Edit: Seems is just bad timing with FIT IoT-Lab.

@miri64
Copy link
Member

miri64 commented Oct 30, 2016

Ok, fetched riot, rebase with riot/master, added the changes requested, upgraded the client, tested correctly the client and server in native. BUT now the FIT IoT-LAB (greenoble and paris sites) are returning an empty list when ifconfig is used.

Not sure if it is just bad timing with the testbed or something we are forgetting to upgrade on the Makefile.

Edit: Seems is just bad timing with FIT IoT-Lab.

Nothing to do with FIT IoT-Lab, nor timings, nor this PR. #5891 just messed up the dependencies for iotlab-m3 a little so the driver for the network device was not in included. Find fix at #6023.

@rfuentess
Copy link
Contributor Author

rfuentess commented Oct 30, 2016

Tested with available hardware. Already pushed.


Edit: Push again, after the rebase boards nucleo-f070 and nucleo-f030 do not have enough memory.

Support for TinyDTLS (0.8.6) is added together an example at 'examples/dtls-echo'.
@miri64
Copy link
Member

miri64 commented Oct 30, 2016

Confirmed it to be working. ACK and go as soon as Murdock agrees.

@miri64 miri64 merged commit 1de2175 into RIOT-OS:master Oct 30, 2016
@OlegHahm
Copy link
Member

Wow! Pretty cool! Nice job, @rfuentess!

@kYc0o
Copy link
Contributor

kYc0o commented Oct 31, 2016

Excellent! Congrats!

@rfuentess rfuentess deleted the TinyDTLS-GNRC branch May 19, 2017 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants