<p></p>
<p><b>@miri64</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/16672#discussion_r678986399">sys/net/gnrc/netif/gnrc_netif.c</a>:</p>
<pre style='color:#555'>> +#if IS_USED(MODULE_GNRC_SIXLOWPAN_CTX)
+static bool _ctx_match(const gnrc_sixlowpan_ctx_t *ctx,
+                       const ipv6_addr_t *prefix, uint8_t prefix_len)
+{
+    return (ctx != NULL) &&
+           (ctx->prefix_len == prefix_len) &&
+           (ipv6_addr_match_prefix(&ctx->prefix, prefix) >= prefix_len);
+}
+
+/* configure 6LoWPAN compression context */
+static void _update_6ctx(const ipv6_addr_t *prefix, uint8_t prefix_len,
+                         uint32_t valid)
+{
+    gnrc_sixlowpan_ctx_t *ctx = gnrc_sixlowpan_ctx_lookup_addr(prefix);
+    uint8_t cid = 0;
+
+    if (!_ctx_match(ctx, prefix, prefix_len)) {
+        /* While the context is a prefix match, the defined prefix within the
+         * context does not match => use new context */
+        ctx = NULL;
+    }
+    else {
+        cid = ctx->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK;
+    }
+    /* find first free context ID */
+    if (ctx == NULL) {
+        while (((ctx = gnrc_sixlowpan_ctx_lookup_id(cid)) != NULL) &&
+               !_ctx_match(ctx, prefix, prefix_len)) {
+            cid++;
+        }
+    }
+    if (cid < GNRC_SIXLOWPAN_CTX_SIZE) {
+        DEBUG("GNRC util: add compression context %u for prefix %s/%u\n", cid,
+              ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)),
+              prefix_len);
+        gnrc_sixlowpan_ctx_update(cid, (ipv6_addr_t *)prefix, prefix_len,
+                                  valid / (60 * MS_PER_SEC),
+                                  true);
+    }
+}
+#else
+static void _update_6ctx(const ipv6_addr_t *prefix, uint8_t prefix_len,
+                         uint32_t valid)
+{
+    (void)prefix;
+    (void)prefix_len;
+    (void)valid;
+}
+#endif
</pre>
<p>Last thought (and I am aware that this is more or less asking you to clean up my mess <g-emoji class="g-emoji" alias="sweat_smile" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f605.png">😅</g-emoji>): Would it make sense to move these as convenience functions to <code>net/gnrc/sixlowpan/ctx.h</code>?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/16672#pullrequestreview-717876161">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABE7WYAPS6UEJ7RTSPPFI33T2ENV5ANCNFSM5A2EDGWQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABE7WYETABFD2YXOC3UQDLDT2ENV5A5CNFSM5A2EDGW2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOFLE6XQI.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/16672#pullrequestreview-717876161",
"url": "https://github.com/RIOT-OS/RIOT/pull/16672#pullrequestreview-717876161",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>