native: provide socket-based ZEP device#6121
Conversation
|
(Just in case you are wondering why the EUI-64 is gradually growing with the nodes: it's generated from the sockets sockaddr. I took great care that the local port part is in the region were the last two bytes of the EUI-64 are and also used those two bytes for the short address). |
|
I implemented this primarily to test my new NDP implementation I'm going to finally start in a few days. |
cpu/native/Makefile
Outdated
|
|
||
| ifneq (,$(filter netdev2_tap,$(USEMODULE))) | ||
| DIRS += netdev2_tap | ||
| DIRS += netdev2_tap |
There was a problem hiding this comment.
there seem to spaces instead of tabs now ..
There was a problem hiding this comment.
Yes, this is the quasi convention for a while now. Since I touched this file anyway I allowed myself to change that ;-).
| */ | ||
| void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params); | ||
|
|
||
| void socket_zep_cleanup(socket_zep_t *dev); |
cpu/native/socket_zep/socket_zep.c
Outdated
| { | ||
| struct timeval tv; | ||
|
|
||
| gettimeofday(&tv, NULL); |
There was a problem hiding this comment.
I have the feeling gettimeofday should be added to syscalls...
cpu/native/socket_zep/socket_zep.c
Outdated
| return (memcmp(dst_addr, ieee802154_addr_bcast, dst_len) != 0) && | ||
| (memcmp(dst_addr, dev->netdev.short_addr, dst_len) != 0); | ||
| default: | ||
| return false; /* better save than sorry ;-) */ |
| if (max_len != sizeof(uint16_t)) { | ||
| return -EOVERFLOW; | ||
| } | ||
| *v = SOCKET_ZEP_FRAME_PAYLOAD_LEN; |
There was a problem hiding this comment.
you might want to check for v != NULL before...
There was a problem hiding this comment.
I think we don't do that anywhere else, but will do.
There was a problem hiding this comment.
|
Addressed comments |
|
I found the following patch useful for testing BTW ;-) diff --git a/boards/native/Makefile.dep b/boards/native/Makefile.dep
index 88151e9..0991015 100644
--- a/boards/native/Makefile.dep
+++ b/boards/native/Makefile.dep
@@ -1,5 +1,5 @@
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
- USEMODULE += netdev2_tap
+ USEMODULE += socket_zep
endif
ifneq (,$(filter socket_zep,$(USEMODULE)))
diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include
index 01fc119..232dc26 100644
--- a/boards/native/Makefile.include
+++ b/boards/native/Makefile.include
@@ -88,11 +88,11 @@ endif
export LINKFLAGS += -ffunction-sections
# set the tap interface for term/valgrind
-ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
- export PORT ?= tap0
-else
- export PORT =
-endif
+# ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
+# export PORT ?= tap0
+# else
+# export PORT =
+# endif
export TERMFLAGS := $(PORT) $(TERMFLAGS)
(will provide a proper test application ASAP) |
|
Very nice! I won't find time to test, though... |
cpu/native/socket_zep/socket_zep.c
Outdated
|
|
||
| if (getpeername(dev->sock_fd, (struct sockaddr *)&ss_array, &ss_len) < 0) { | ||
| perror("ZEP: Unable to retrieve remote address"); | ||
| return; |
There was a problem hiding this comment.
Here and below: the socket is connected at this point, should it be closed?
There was a problem hiding this comment.
I think that's a remnant from when I played around with unbound/unconnected sockets. Will do.
|
Provided tests. |
When working on RIOT-OS#6121 I noticed that the documentation of the `netdev2` driver part is not really precise. This fixes that.
|
this looks like a neat feature. Will try to find time on the weekend to give it a shot |
ec2f8fb to
3af0d87
Compare
|
Rebased to current master, since #6112 got merged => Removed Waiting for other PR label. Also removed WIP label. Those missing features can well be done in a follow-up. |
|
@miri64 can you give a hint about how to use this, e.g. with It would be great to have this for the release! |
|
Have you cleaned between builds? |
|
Sorry, my bad. I didn't apply your patch but just added |
|
murdock isn't all that happy, can you have look? |
|
@smlng Murdock should now be happy. |
|
That's a new one :D |
ca1a23f to
4704c81
Compare
|
Rebased (to include |
|
@smlng now finally both Travis and Murdock are happy (except for squashing notice). Do you think we can include this into the release? Would be awesome for testing and debugging to have IEEE 802.15.4 for BTW, @aabadie @kaspar030 @smlng Murdock doesn't seem to have |
yep, workers need an update but not before release testing is done. Otherwise, yes this should go into the release. |
smlng
left a comment
There was a problem hiding this comment.
some minor comments on documentation (non blocking). But I also tried the test app which failed with an assertion as follows:
Socket ZEP device driver test
Initializing socket ZEP with (local: [::]:17754, remote: [::1]:17754)
(Hwaddrs: 455b, 005a45501c1e455b)
Send zero-length packet
Send 'Hello\0World\0'
Waiting for an incoming message (use `make test`)
tests/socket_zep/main.c:126 => 0x4d5c
*** RIOT kernel panic:
FAILED ASSERTION.
*** halted.
native: exiting
| * @{ | ||
| * | ||
| * @file | ||
| * @brief Configuration parameters for the @ref netdev_socket_zep driver |
cpu/native/include/socket_zep.h
Outdated
| /** | ||
| * @defgroup netdev_socket_zep ZEP-based IEEE 802.15.4 device for native | ||
| * @ingroup netdev | ||
| * @brief |
There was a problem hiding this comment.
mhm, a bit sad this is empty 😢 Maybe put the (rather long) defgroup title here, and shorten the above?
| #include "debug.h" | ||
|
|
||
| /** | ||
| * @brief Define stack parameters for the MAC layer thread |
There was a problem hiding this comment.
Isn't generated anyways and the other devices use the same notation (also the brace doesn't seem to be closed... I just remove the brace, because this just refers to the stack, not the prio.
sys/include/net/zep.h
Outdated
| /** | ||
| * @defgroup net_zep ZEP header definitions | ||
| * @ingroup net | ||
| * @brief |
|
while the error above was with |
|
Did you used the most current version? I literally just fixed that in the latest batch and at least on my machine it was working with that. |
okay, I'll quickly test again |
|
I'll verified and I'm on the latest commit, but still get the errors as reported above. Though, I've to admit I test on macOS ... |
|
retested on linux: works! So issues reported are likely macOS specific, still would be great to have it compatible in the future, if possible. |
|
please squash in a timely manner, the feature freeze is approaching slowly 😉 |
db4ac82 to
585e9a2
Compare
|
ACK and GO! |
|
Awesome! 🎉 |
This is aiming to replace GNRC ZEP and allow platform independent IEEE 802.15.4 traffic on native (as opposed to #5582).
I tested it already with zep_mesh, a very simple network simulator I specifically wrote for ZEP (and RIOT, though I tried to keep it generalized):
This is more or less done, but there are still some minor stuff I might add/change on a later point:
Depends on
#6112(merged).