-
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: simplify hdr_build functions #5118
gnrc: simplify hdr_build functions #5118
Conversation
Wow, someone was planning ahead! ;) +1 |
Just wondering, and maybe unrelated to this PR: do we want to support 8-bit port numbers in the future? |
Would gladly appreciate if this would be done for |
{ | ||
uint16_t src_port = *((uint16_t *)src); | ||
uint16_t dst_port = *((uint16_t *)dst); | ||
return gnrc_udp_hdr_build(payload, src_port, dst_port); |
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.
Error check from https://github.com/RIOT-OS/RIOT/pull/5118/files#diff-a743a0dcf90d0eb32c837f1a047918c1L283 needs to be moved here now.
What do you mean by 8-bit port numbers? |
Will do. |
updated |
uint8_t *src, uint8_t src_len, | ||
uint8_t *dst, uint8_t dst_len); | ||
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload, uint8_t *src, | ||
uint8_t *dst); |
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.
Why not use ipv6_addr_t
pointers?
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.
true, will update
I mean that 16-bit port numbers may be too much for certain IoT use cases. Do we plan to make that configurable (by compile time e.g.) to reduce that to 8-bit instead somewhen in the future? |
I don't think we should make that part of the protocol compile-time configurable... |
NHC allows to compress a certain range of UDP ports. Compressing them internally seems to be overkill to me. |
IPv6 UDP NHC can compress the ports to 4-bits each if they are in the range of |
I don't think it makes sense to use compressed representation in the API. |
@cgundogan that's out-of-scope for IPv6 and purely a 6LoWPAN thing. I would keep it there and not put 6LoWPAN specific stuff in our UDP implementation |
Addressed @authmillenon's comment. |
Thanks for the review - I think this PR now simplifies the code a bit. |
Please squash (and change title of PR appropriately ;-)) |
72c7833
to
c4131f0
Compare
done |
@@ -143,17 +144,31 @@ gnrc_pktsnip_t *gnrc_netreg_hdr_build(gnrc_nettype_t type, gnrc_pktsnip_t *paylo | |||
#ifdef MODULE_GNRC_IPV6 | |||
|
|||
case GNRC_NETTYPE_IPV6: | |||
return gnrc_ipv6_hdr_build(payload, src, src_len, dst, dst_len); | |||
assert(src_len == sizeof(ipv6_addr_t)); | |||
assert(dst_len == sizeof(ipv6_addr_t)); |
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.
Please document these preconditions in the doxygen.
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.
Hm, wondering about how to document this, I begin to wonder if we need this function at all. What is the purpose of this function?
One (nitpicky) remark. Otherwise I give my ACK when Murdock is happy. |
(you may squash the doc fix immediately). |
CI was failing because of missing const specifiers. Unsure if I should squash this last commit. |
I couldn't think of a reason where this generic header build function would be needed, hence I removed it. |
I think the original idea was to be layer agnostic, but that proved to be impossible at least for TCP/IP. Any objections @haukepetersen? |
Please rebase. |
0dbb94c
to
1a9a8e3
Compare
rebased to master |
ACK and go. |
(when Murdock is happy). |
1a9a8e3
to
a137b99
Compare
Fixed a typo in zep that Murdock reported and squashed immediately. |
Directly using 16 bit port numbers instead of casting uint8_t pointers.
a137b99
to
cba3ba7
Compare
args, fixed the wrong parameter - another try. |
Directly using 16 bit port numbers instead of casting uint8_t pointers.