<commit_before>/*
 * Copyright (C) 2017 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
 * directory for more details.
 */

/**
 * @{
 *
 * @file
 * @author  <NAME> <<EMAIL>>
 */

#include <stdio.h>

#include "net/gnrc/ipv6/nib/abr.h"

#include "_nib-6ln.h"
#include "_nib-internal.h"

#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
#if GNRC_IPV6_NIB_CONF_6LBR
int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr)
{
    _nib_abr_entry_t *abr;
    _nib_offl_entry_t *offl = NULL;

    _nib_acquire();
    if ((abr = _nib_abr_add(addr)) == NULL) {
        _nib_release();
        return -ENOMEM;
    }
    abr->valid_until = 0U;
    while ((offl = _nib_offl_iter(offl))) {
        if (offl->mode & _PL) {
            _nib_abr_add_pfx(abr, offl);
        }
    }
#ifdef MODULE_GNRC_SIXLOWPAN_CTX    /* included optionally for NIB testing */
    for (uint8_t id = 0; id < GNRC_SIXLOWPAN_CTX_SIZE; id++) {
        if (gnrc_sixlowpan_ctx_lookup_id(id) != NULL) {
            bf_set(abr->ctxs, id);
        }
    }
#endif  /* MODULE_GNRC_SIXLOWPAN_CTX */
    _nib_release();
    return 0;
}

void gnrc_ipv6_nib_abr_del(const ipv6_addr_t *addr)
{
    _nib_acquire();
    _nib_abr_remove(addr);
    _nib_release();
}
#endif  /* GNRC_IPV6_NIB_CONF_6LBR */
<commit_msg>gnrc_ipv6_nib: only add prefix of same interface to ABR<commit_after>/*
 * Copyright (C) 2017 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
 * directory for more details.
 */

/**
 * @{
 *
 * @file
 * @author  <NAME> <<EMAIL>>
 */

#include <stdio.h>

#include "net/gnrc/ipv6/nib/abr.h"
#include "net/gnrc/netif.h"

#include "_nib-6ln.h"
#include "_nib-internal.h"

#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
#if GNRC_IPV6_NIB_CONF_6LBR
int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr)
{
    _nib_abr_entry_t *abr;
    _nib_offl_entry_t *offl = NULL;
    gnrc_netif_t *netif = gnrc_netif_get_by_ipv6_addr(addr);

    assert(netif != NULL);
    _nib_acquire();
    if ((abr = _nib_abr_add(addr)) == NULL) {
        _nib_release();
        return -ENOMEM;
    }
    abr->valid_until = 0U;
    /* Associate all existing prefixes in the prefix list of the border router's
     * downstream interface to the authoritative border router so they are
     * advertised in a Router Advertisement with the Authoritative Border Router
     * Option (ABRO) in a respective Prefix Information Option (PIO)
     * (see https://tools.ietf.org/html/rfc6775#section-8.1.1). */
    while ((offl = _nib_offl_iter(offl))) {
        if ((offl->mode & _PL) &&
            (_nib_onl_get_if(offl->next_hop) == (unsigned)netif->pid)) {
            _nib_abr_add_pfx(abr, offl);
        }
    }
#ifdef MODULE_GNRC_SIXLOWPAN_CTX    /* included optionally for NIB testing */
    for (uint8_t id = 0; id < GNRC_SIXLOWPAN_CTX_SIZE; id++) {
        if (gnrc_sixlowpan_ctx_lookup_id(id) != NULL) {
            bf_set(abr->ctxs, id);
        }
    }
#endif  /* MODULE_GNRC_SIXLOWPAN_CTX */
    _nib_release();
    return 0;
}

void gnrc_ipv6_nib_abr_del(const ipv6_addr_t *addr)
{
    _nib_acquire();
    _nib_abr_remove(addr);
    _nib_release();
}
#endif  /* GNRC_IPV6_NIB_CONF_6LBR */

{'fraction_non_alphanumeric': 0.11990407673860912, 'fraction_numerical': 0.015887290167865706, 'mean_word_length': 3.140198511166253, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3622507', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1382, 'n_words': 284}