-
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
Netif fix byteorder #1948
Netif fix byteorder #1948
Conversation
I choose solution number three: use the types in byteorder.h. |
Maybe I'm too tired, but I don't understand how I can swap the byte order by using a union. |
@@ -378,7 +379,8 @@ int net_if_send_packet_long(int if_id, net_if_eui64_t *target, | |||
p.frame.fcf.frame_type = 1; | |||
p.frame.fcf.frame_pend = 0; | |||
p.frame.dest_pan_id = net_if_get_pan_id(if_id); | |||
memcpy(p.frame.dest_addr, target, 8); | |||
uint64_t target_h = NTOHLL(target->uint64); |
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.
for consistency you could use uint64_t target_h = byteorder_ntohll((network_uint64_t)target->uint64);
here too.
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, I will do this.
Don't know if my comment above matches @Kijewski's proposal but might be worth considering. Anyway I'd take the second solution due to compactness. |
Is the EUI-64 really in host byte-order on all boards? Because I remember that this was not the case on all boards (including the old iot-lab_M3 from thirdparty_boards) I tested back then. |
I think it would be best if |
@authmillenon, I checked for at86rf231 and cc2420. For mc1322x I don't know, but should behave the same way. |
@Kijewski, I agree, but this would require a somewhat bigger change and I don't dare to introduce this now - one day before the IoT-Lab tutorial. Would you agree to merge the (cleaned up) second solution for now and prepare a new PR for replacing the right data types in the network stack later on? (Maybe even after the refactoring?) |
@@ -335,7 +335,8 @@ int net_if_send_packet(int if_id, uint16_t target, const void *payload, | |||
p.frame.fcf.frame_pend = 0; | |||
|
|||
p.frame.dest_pan_id = net_if_get_pan_id(if_id); | |||
memcpy(p.frame.dest_addr, &target, 2); | |||
uint16_t target_h = byteorder_ntohs((network_uint16_t) target); | |||
memcpy(p.frame.dest_addr, &target_h, 2); |
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 is a memcpy needed here?
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.
Because dest_addr
is an array.
I've chosen to use |
Travis is fine. Who else (after squashing)? |
ACK, merge at will. |
1acb6e6
to
ac3519d
Compare
Squashed - @Kijewski, can you live with this solution for now? |
yes |
This PR proposes two possible solutions. Please choose one.