-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ipv6: rpl: add source routing header for RPL #4774
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,17 @@ | |
|
||
#include "net/gnrc/ipv6/ext.h" | ||
|
||
#define ENABLE_DEBUG (0) | ||
#include "debug.h" | ||
|
||
bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, | ||
uint8_t nh) | ||
{ | ||
gnrc_pktsnip_t *ext_snip; | ||
gnrc_pktsnip_t *ext_snip, *tmp; | ||
ipv6_ext_t *ext; | ||
unsigned int offset = 0; | ||
ipv6_hdr_t *hdr; | ||
int res; | ||
|
||
ext = ((ipv6_ext_t *)(((uint8_t *)pkt->data) + sizeof(ipv6_hdr_t))); | ||
|
||
|
@@ -36,6 +41,35 @@ bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, | |
case PROTNUM_IPV6_EXT_HOPOPT: | ||
case PROTNUM_IPV6_EXT_DST: | ||
case PROTNUM_IPV6_EXT_RH: | ||
if ((tmp = gnrc_pktbuf_start_write(pkt)) == NULL) { | ||
DEBUG("ipv6: could not get a copy of pkt\n"); | ||
gnrc_pktbuf_release(pkt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
} | ||
pkt = tmp; | ||
hdr = pkt->data; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ext = (ipv6_ext_t *) (((uint8_t *) pkt->data) + sizeof(ipv6_hdr_t) + offset); | ||
res = ipv6_ext_rh_process(hdr, (ipv6_ext_rh_t *)ext); | ||
if (res == EXT_RH_CODE_ERROR) { | ||
/* TODO: send ICMPv6 error codes */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gnrc_pktbuf_release(pkt); |
||
gnrc_pktbuf_release(pkt); | ||
return false; | ||
} | ||
else if (res == EXT_RH_CODE_FORWARD) { | ||
/* forward packet */ | ||
if (!gnrc_netapi_dispatch_receive(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL, | ||
pkt)) { | ||
DEBUG("ipv6: could not dispatch packet to the ipv6 thread\n"); | ||
gnrc_pktbuf_release(pkt); | ||
} | ||
return false; | ||
} | ||
else if (res == EXT_RH_CODE_OK) { | ||
nh = ext->nh; | ||
offset += ((ext->len * IPV6_EXT_LEN_UNIT) + IPV6_EXT_LEN_UNIT); | ||
ext = ipv6_ext_get_next((ipv6_ext_t *)ext); | ||
} | ||
break; | ||
case PROTNUM_IPV6_EXT_FRAG: | ||
case PROTNUM_IPV6_EXT_AH: | ||
case PROTNUM_IPV6_EXT_ESP: | ||
|
@@ -57,6 +91,7 @@ bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, | |
ext_snip = gnrc_pktbuf_mark(pkt, offset, GNRC_NETTYPE_IPV6); | ||
|
||
if (ext_snip == NULL) { | ||
gnrc_pktbuf_release(pkt); | ||
return false; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = gnrc_rpl_srh | ||
|
||
include $(RIOTBASE)/Makefile.base |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = ipv6_ext | ||
|
||
include $(RIOTBASE)/Makefile.base |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBASE)/Makefile.base |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
USEMODULE += gnrc_ipv6 | ||
USEMODULE += ipv6_addr | ||
USEMODULE += gnrc_rpl_srh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext
is also updated byipv6_ext_rh_process
.Please insert
ext = ((ipv6_ext_t *)(((uint8_t *)pkt->data) + sizeof(ipv6_hdr_t) + offset));
before
res = ipv6_ext_rh_process(hdr, (ipv6_ext_rh_t *)ext);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we need to update
ext
before the call toipv6_ext_rh_process
?ext
will be updated for each header extension (that is not a routing header extension) that was encountered before. Once we reach the routing header extension,ext
should point to the right place? That's whynh
is updated before getting the nextext
in line ~79.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
pkt
is referred from multiple pointers,gnrc_pktbuf_start_write
duplicates the packet data:ext
must point to the new byte array.Note that the buffer referred from
ext
is updated by this line:https://github.com/RIOT-OS/RIOT/pull/4774/files#diff-6906777c73d641182b398573d3bdba0bR87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in cgundogan@4b18686