-
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
gnrc_sixlowpan_iphc.c: add nhc udp encoding and decoding #4189
Conversation
Interesting. Have you found a way to reproduce this isolated (with the unittests e.g.) Would be gread if we could find the reason for that ;). |
alternative: (what I did for IPHC) just create a new header for UDP and replace it with the UDP NHC header, when you're done. |
@@ -368,7 +369,74 @@ size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, siz | |||
|
|||
} | |||
|
|||
/* TODO: add next header decoding */ | |||
/* next header decoding */ |
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'd prefer to have this whole chunk of code in a seperate module gnrc_sixlowpan_nhc
, so one can turn it of.
Unfortunately not, if I have time I try to investigate.
That was my first idea, but then I need a pointer to pointer to pkt inside gnrc_sixlowpan_iphc_decode ? |
|
||
/* make place for udp length */ | ||
if(gnrc_pktbuf_realloc_data(pkt, pkt->size + 2)) { | ||
printf("realloc failed\n"); |
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 assume this is just for debugging purpose while implementing. But should be replaced with DEBUG
and a proper cleanup pktbuf_free(pkt); return 0;
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 am not so sure about pktbuf_free
anymore in this context, because it is never used in the above code (@authmillenon?)
@authmillenon @cgundogan I have rebuilt it, |
rebased on master, still WIP decoding is working and can be tested from linux host with something like:
|
@authmillenon ping |
Why is it a pseudo-module? The way you set it up now |
Other then that, the code looks great. |
From the code structure, I find it more readable if it stays in gnrc_sixlowpan_iphc.c.
Yes it would be good, I have to read how I can test it. |
My first initial test found it working. Will test at the ETSI plugtest tomorrow. |
uint8_t *udp_data = udp->data; | ||
size_t nhc_len = 0; | ||
|
||
/* TODO: Add support for elided checksum when it is available in the linux kernel. */ |
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.
We will need also something like IPsec for that.
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.
elided checksum?
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.
Yes. RFC6282 requires authorization of an upper lay in case that e.g. tunneling or a message integrity check is in place by something like IPsec.
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.
Authorization to be allowed eliding the checksum, right?
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.
Yes, exactly.
The problem is: how to implement/test it with extension header (https://tools.ietf.org/html/rfc6282#section-4.2). 🌴 |
Luckily this is out of scope for the plugtest. ;) |
Needs #4235 and jfischer-phytec-iot/RIOT#17 to build for applications without UDP (e.g. gnrc_border_router). |
|
||
/* TODO: Add support for elided checksum when it is available in the linux kernel. */ | ||
|
||
/* Compressing UDP ports, follow the same sequence as the linux kernel (nhc_udp module). */ |
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.
might be nit-picking, but I would be more happy with a reference to the RFC instead of a mentioning a module from the linux kernel.
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.
Can you "fix" this?
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.
It is expressed a little wrong. It means that if first 8 bits of Destination Port are 0xf0 and first 8 bits of Source Port are 0xf0
then dst will be elided. (L504).
Should I remove the comment?
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 I look at the code it seems rather that if the first 12 bits of destination and source port are 0xf0b then only four bits are carried inline
which is exactly what the RFC says. Or am I mistaken?
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.
no, I mean: if first 8 bits of Destination Port are 0xf0 and first 8 bits of Source Port are 0xf0
there are IMHO two capabilities (RFC leaves free to choose):
- dst will be elided
- src will be elided
Nothing special, the comment is just confusing.
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.
Okay, whatever. I don't quite agree to your comment, but I agree with your code. ;-) And this is obviously more important. As for the comment: I think it's actually okay to leave as is.
Can you rebase, please? |
@OlegHahm rebased on master, untested |
Can you also squash my commits? |
@OlegHahm ok? |
If you can also replace the |
@jfischer-phytec-iot, please address @cgundogan's comment and squash immediately. I tested for RIOT-to-RIOT and RIOT-to-Linux with and without elided ports. Everything works. ACK! |
Ok, please squash your commits and we're ready to go, I think. |
Please apply: diff --git a/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c b/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c
index 6dea595..267f0da 100644
--- a/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c
+++ b/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c
@@ -111,6 +111,7 @@ static inline bool _context_overlaps_iid(gnrc_sixlowpan_ctx_t *ctx,
(iid->uint8[(ctx->prefix_len / 8) - 8] & byte_mask[ctx->prefix_len % 8])));
}
+#ifdef MODULE_GNRC_UDP
inline static size_t iphc_nhc_udp_decode(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *ipv6, size_t offset)
{
uint8_t *payload = pkt->data;
@@ -181,6 +182,7 @@ inline static size_t iphc_nhc_udp_decode(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *ip
return offset;
}
+#endif
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t datagram_size,
size_t offset) and squash immediately. |
It's probably easiest if you just do it. I'm without access to a real computer currently anyway . On 8 December 2015 13:46:49 CET, Johann Fischer notifications@github.com wrote:
Join the RIOT |
This patch adds UDP Header Compression and Decompression as specified in https://tools.ietf.org/html/rfc6282#section-4.3 UDP NHC module will be included only if UDP is used.
gnrc_sixlowpan_iphc.c: add nhc udp encoding and decoding
ipv6_hdr->nh = PROTNUM_UDP; | ||
ipv6_hdr->len = udp_hdr->length; | ||
|
||
ipv6->next = udp; |
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.
This is the cause for #4397: Decoding happens on receive, this means the udp snip must come before the IPv6 snip. But since the IPv6 snip is only inserted after decoding, this is not easy to fix. Will try anyway :-)
This PR adds NHC UDP decoding and encoding.
@cgundogan @authmillenon @OlegHahm ~~~I need your support to get it pretty.
For first, my mayor problem is that gnrc_pktbuf_realloc_data fails after a few calls.
What would be the alternative?~~~
References:
https://tools.ietf.org/html/rfc6282#section-4.3
https://github.com/torvalds/linux/blob/master/net/6lowpan/nhc_udp.c