From 61b829b656a6bb9f89f90dd3dea997aa09dc87e6 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 23 Oct 2018 14:21:18 +0200 Subject: [PATCH] gnrc_rpl_srh: reorder variables for better memory usage --- sys/net/gnrc/routing/rpl/srh/gnrc_rpl_srh.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/net/gnrc/routing/rpl/srh/gnrc_rpl_srh.c b/sys/net/gnrc/routing/rpl/srh/gnrc_rpl_srh.c index 753d5bf65e..163efd0d23 100644 --- a/sys/net/gnrc/routing/rpl/srh/gnrc_rpl_srh.c +++ b/sys/net/gnrc/routing/rpl/srh/gnrc_rpl_srh.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2015 Martine Lenders + * Copyright (C) 2015 Cenk Gündoğan + * Copyright (C) 2018 Freie Universität Berlin * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -10,6 +11,8 @@ * @{ * * @file + * @author Cenk Gündoğan + * @author Martine Lenders */ #include @@ -28,17 +31,19 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN]; int gnrc_rpl_srh_process(ipv6_hdr_t *ipv6, gnrc_rpl_srh_t *rh) { + ipv6_addr_t addr = ipv6->dst, tmp; + uint8_t *addr_vec = (uint8_t *) (rh + 1); + bool found = false; + uint8_t n; + uint8_t i, pref_elided, tmp_pref_elided, addr_len, compri_addr_len, tmp_addr_len, found_pos = 0; + if (rh->seg_left == 0) { return GNRC_IPV6_EXT_RH_AT_DST; } - uint8_t n = (((rh->len * 8) - GNRC_RPL_SRH_PADDING(rh->pad_resv) - - (16 - GNRC_RPL_SRH_COMPRE(rh->compr))) / - (16 - GNRC_RPL_SRH_COMPRI(rh->compr))) + 1; - ipv6_addr_t addr = ipv6->dst, tmp; - uint8_t i, pref_elided, tmp_pref_elided, addr_len, compri_addr_len, tmp_addr_len, found_pos = 0; - uint8_t *addr_vec = (uint8_t *) (rh + 1); - bool found = false; + n = (((rh->len * 8) - GNRC_RPL_SRH_PADDING(rh->pad_resv) - + (16 - GNRC_RPL_SRH_COMPRE(rh->compr))) / + (16 - GNRC_RPL_SRH_COMPRI(rh->compr))) + 1; DEBUG("RPL SRH: %u addresses in the routing header\n", (unsigned) n);