[riot-notifications] [RIOT-OS/RIOT] gnrc_ipv6_nib/arsm: ensure proper int width in backoff calculation (#10369)

Martine Lenders notifications at github.com
Tue Jan 29 14:53:46 CET 2019


miri64 commented on this pull request.



> + * @pre (NDP_MIN_RANDOM_FACTOR <= factor < NDP_MAX_RANDOM_FACTOR)
+ * @pre (ns_sent <= NDP_MAX_NS_NUMOF)
+ *
+ * @return  exponential back-off of the retransmission timer
+ */
+static inline uint32_t _exp_backoff_retrans_timer_factor(uint8_t ns_sent,
+                                                         uint32_t retrans_timer,
+                                                         uint32_t factor)
+{
+    assert(NDP_MIN_RANDOM_FACTOR <= factor);
+    assert(factor < NDP_MAX_RANDOM_FACTOR);
+    assert(ns_sent <= NDP_MAX_NS_NUMOF);
+    /* backoff according to  https://tools.ietf.org/html/rfc7048 with
+     * BACKOFF_MULTIPLE == 2 */
+    uint32_t res = (uint32_t)(((uint64_t)(((uint32_t) 1) << ns_sent) *
+                               retrans_timer * factor) / US_PER_MS);

+ again: this was just moved from `_nib-arsm.c` which I only did because @cladmi wanted a unittest case.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10369#discussion_r251840958
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190129/30b763c3/attachment-0001.html>


More information about the notifications mailing list