From e2e62596bedab97cb1249a83df316d5761b2bc4c Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Thu, 27 Feb 2014 00:49:03 +0100 Subject: [PATCH] Byte order and rpl problems --- sys/net/network_layer/sixlowpan/icmp.c | 4 ++-- sys/net/network_layer/sixlowpan/lowpan.c | 2 +- sys/net/routing/rpl/rpl.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/net/network_layer/sixlowpan/icmp.c b/sys/net/network_layer/sixlowpan/icmp.c index 5d93f56bbd..69005329fe 100644 --- a/sys/net/network_layer/sixlowpan/icmp.c +++ b/sys/net/network_layer/sixlowpan/icmp.c @@ -672,7 +672,7 @@ void recv_rtr_adv(void) ipv6_addr_t abro_addr; ipv6_buf = ipv6_get_buf(); - packet_length = IPV6_HDR_LEN + ipv6_buf->length; + packet_length = IPV6_HDR_LEN + NTOHS(ipv6_buf->length); icmpv6_opt_hdr_len = RTR_ADV_LEN; rtr_adv_buf = get_rtr_adv_buf(ipv6_ext_hdr_len); ipv6_addr_t newaddr; @@ -937,7 +937,7 @@ void recv_nbr_sol(void) uint8_t send_na = 0; uint8_t sllao_set = 0; uint8_t aro_state = NDP_OPT_ARO_STATE_SUCCESS; - uint16_t packet_length = IPV6_HDR_LEN + ipv6_buf->length; + uint16_t packet_length = IPV6_HDR_LEN + NTOHS(ipv6_buf->length); /* check whick options are set, we need that because an aro * option condition is that a sllao option is set. thus that we don't diff --git a/sys/net/network_layer/sixlowpan/lowpan.c b/sys/net/network_layer/sixlowpan/lowpan.c index 4a5ca8e321..a4f54979a6 100644 --- a/sys/net/network_layer/sixlowpan/lowpan.c +++ b/sys/net/network_layer/sixlowpan/lowpan.c @@ -1154,7 +1154,7 @@ uint8_t lowpan_iphc_encoding(int if_id, const uint8_t *dest, int dest_len, ptr = get_payload_buf(ipv6_ext_hdr_len); } */ - memcpy(&ipv6_hdr_fields[hdr_pos], &ptr[IPV6_HDR_LEN], ipv6_buf->length); + memcpy(&ipv6_hdr_fields[hdr_pos], &ptr[IPV6_HDR_LEN], NTOHS(ipv6_buf->length)); comp_len = 2 + hdr_pos + payload_length; diff --git a/sys/net/routing/rpl/rpl.c b/sys/net/routing/rpl/rpl.c index 013c7258a5..a9a7d6fa3c 100644 --- a/sys/net/routing/rpl/rpl.c +++ b/sys/net/routing/rpl/rpl.c @@ -490,7 +490,7 @@ void rpl_process(void) code = ((uint8_t *)m_recv.content.ptr); /* differentiate packet types */ ipv6_buf = ipv6_get_buf(); - memcpy(&rpl_buffer, ipv6_buf, ipv6_buf->length + IPV6_HDR_LEN); + memcpy(&rpl_buffer, ipv6_buf, NTOHS(ipv6_buf->length) + IPV6_HDR_LEN); switch (*code) { case (ICMP_CODE_DIS): { @@ -583,7 +583,7 @@ void recv_rpl_dio(void) * ipv6_buf->length contains the packet length minus ipv6 and * icmpv6 header, so only ICMPV6_HDR_LEN remains to be * subtracted. */ - while (len < (ipv6_buf->length - ICMPV6_HDR_LEN)) { + while (len < (NTOHS(ipv6_buf->length) - ICMPV6_HDR_LEN)) { DEBUG("parsing DIO options\n"); rpl_opt_buf = get_rpl_opt_buf(len); @@ -970,7 +970,7 @@ void rpl_send(ipv6_addr_t *destination, uint8_t *payload, uint16_t p_len, uint8_ } } - ipv6_send_packet(ipv6_buf); + ipv6_send_packet(ipv6_send_buf); } }