diff --git a/sys/net/destiny/socket.c b/sys/net/destiny/socket.c index 6d99fa6aba..7c810e1e78 100644 --- a/sys/net/destiny/socket.c +++ b/sys/net/destiny/socket.c @@ -1010,7 +1010,7 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags, current_udp_packet->checksum = 0; memcpy(payload, buf, len); - current_udp_packet->length = UDP_HDR_LEN + len; + current_udp_packet->length = HTONS(UDP_HDR_LEN + len); temp_ipv6_header->length = UDP_HDR_LEN + len; current_udp_packet->checksum = ~udp_csum(temp_ipv6_header, @@ -1018,7 +1018,7 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags, ipv6_sendto(&to->sin6_addr, IPPROTO_UDP, (uint8_t *)(current_udp_packet), - current_udp_packet->length); + NTOHS(current_udp_packet->length)); return current_udp_packet->length; } else { diff --git a/sys/net/ieee802154/ieee802154_frame.c b/sys/net/ieee802154/ieee802154_frame.c index 7d72ed3c8d..5e4b3500d4 100644 --- a/sys/net/ieee802154/ieee802154_frame.c +++ b/sys/net/ieee802154/ieee802154_frame.c @@ -27,12 +27,7 @@ uint8_t ieee802154_frame_init(ieee802154_frame_t *frame, uint8_t *buf) { /* Frame Control Field - 802.15.4 - 2006 - 7.2.1.1 */ uint8_t index = 0; - - buf[index] = ((frame->fcf.dest_addr_m << 2) | - (frame->fcf.frame_ver << 4) | - (frame->fcf.src_addr_m << 6)); - index++; buf[index] = ((frame->fcf.frame_type) | (frame->fcf.sec_enb << 3) | (frame->fcf.frame_pend << 4) | @@ -40,14 +35,20 @@ uint8_t ieee802154_frame_init(ieee802154_frame_t *frame, uint8_t *buf) (frame->fcf.panid_comp << 6)); index++; + buf[index] = ((frame->fcf.dest_addr_m << 2) | + (frame->fcf.frame_ver << 4) | + (frame->fcf.src_addr_m << 6)); + + index++; + /* Sequence Number - 802.15.4 - 2006 - 7.2.1.2 */ buf[index] = frame->seq_nr; index++; /* Destination PAN Identifier - 802.15.4 - 2006 - 7.2.1.3 */ if (frame->fcf.dest_addr_m == 0x02 || frame->fcf.dest_addr_m == 0x03) { - buf[index] = ((frame->dest_pan_id >> 8) & 0xff); - buf[index + 1] = (frame->dest_pan_id & 0xff); + buf[index + 1] = ((frame->dest_pan_id >> 8) & 0xff); + buf[index] = (frame->dest_pan_id & 0xff); } index += 2; diff --git a/sys/net/sixlowpan/lowpan.c b/sys/net/sixlowpan/lowpan.c index 3d5b0a7891..13aa962dae 100644 --- a/sys/net/sixlowpan/lowpan.c +++ b/sys/net/sixlowpan/lowpan.c @@ -174,6 +174,7 @@ void sixlowpan_lowpan_sendto(const ieee_802154_long_t *dest, packet_length = comp_len; } else { + ipv6_buf->length = HTONS(ipv6_buf->length); lowpan_ipv6_set_dispatch(data); }