netif.h 20 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
/*
 * Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
 *
 * 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.
 */

/**
 * @defgroup    net_gnrc_ipv6_netif IPv6 network interfaces
 * @ingroup     net_gnrc_ipv6
 * @brief       IPv6 specific information on @ref net_gnrc_netif.
 * @{
 *
 * @file
 * @brief       Definitions for IPv6 specific information of network interfaces.
 *
 * @author      Martine Lenders <mlenders@inf.fu-berlin.de>
 */

#ifndef NET_GNRC_IPV6_NETIF_H
#define NET_GNRC_IPV6_NETIF_H

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#include "kernel_defines.h"
#include "kernel_types.h"
#include "mutex.h"
#include "net/ipv6.h"
#include "net/ipv6/addr.h"
#include "xtimer.h"

#ifdef MODULE_NETSTATS_IPV6
#include "net/netstats.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @cond INTERNAL
 */
#ifdef MODULE_GNRC_RPL
/* RPL needs all-RPL-nodes multicast address */
#   define  GNRC_IPV6_NETIF_RPL_ADDR    (1)
#else
#   define  GNRC_IPV6_NETIF_RPL_ADDR    (0)
#endif
#ifdef MODULE_GNRC_IPV6_ROUTER
/* routers need all-routers multicast address */
#   define GNRC_IPV6_NETIF_RTR_ADDR     (1)
#else
#   define GNRC_IPV6_NETIF_RTR_ADDR     (0)
#endif
/**
 * @endcond
 */
/**
 * @brief   Number of IPv6 addresses per interface.
 */
#ifndef GNRC_IPV6_NETIF_ADDR_NUMOF
#define GNRC_IPV6_NETIF_ADDR_NUMOF  (6 + GNRC_IPV6_NETIF_RPL_ADDR + GNRC_IPV6_NETIF_RTR_ADDR)
#endif

/**
 * @brief   Default MTU
 *
 * An interface will choose this MTU if the link-layer's maximum packet size
 * (see @ref NETOPT_MAX_PACKET_SIZE) is lesser than the @ref IPV6_MIN_MTU or if it just not
 * provide it. For RFC-compatible communication it must be at least @ref IPV6_MIN_MTU.
 *
 * @note    If the scenario the node is used in allows for it and the packet size is predictable,
 *          a user might choose to set @ref GNRC_IPV6_NETIF_DEFAULT_MTU to a lesser value than
 *          @ref IPV6_MIN_MTU to optimize for code size (e.g. because it is then possible to omit
 *          @ref net_gnrc_sixlowpan_frag) and memory usage (e.g. because @ref GNRC_PKTBUF_SIZE
 *          can be much smaller).
 */
#ifndef GNRC_IPV6_NETIF_DEFAULT_MTU
#define GNRC_IPV6_NETIF_DEFAULT_MTU             (IPV6_MIN_MTU)
#endif

/**
 * @brief   Default hop limit
 *
 * @see <a href="https://tools.ietf.org/html/rfc4861#section-6.3.2">
 *          RFC 4861, section 6.3.2
 *      </a>
 * @see <a href="http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-2">
 *          IANA, IP TIME TO LIVE PARAMETER
 *      </a>
 */
#define GNRC_IPV6_NETIF_DEFAULT_HL              (64)

/**
 * @name    Default values for router configuration
 * @{
 * @see <a href="https://tools.ietf.org/html/rfc4861#section-6.2.1">
 *          RFC 4861, section 6.2.1
 *      </a>
 */
/**
 * @brief   Maximum time in seconds between sending unsolicited multicast router advertisements.
 */
#define GNRC_IPV6_NETIF_DEFAULT_MAX_ADV_INT     (600U)

/**
 * @brief   Minimum time in seconds between sending unsolicited multicast router advertisements.
 */
#define GNRC_IPV6_NETIF_DEFAULT_MIN_ADV_INT     (200U)

/**
 * @brief   The router lifetime to propagate in router advertisements.
 */
#define GNRC_IPV6_NETIF_DEFAULT_ROUTER_LTIME    (1800U)
/** @} */

/**
 * @{
 * @name Flags for a registered IPv6 address.
 * @brief   Needed primarily to identify addresses as either anycast or unicast.
 *
 * @see <a href="https://tools.ietf.org/html/rfc4291#section-2.6">
 *          RFC 4291, section 2.6
 *      </a>
 */
#define GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST      (0x00)  /**< unicast address */
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST  (0x01)  /**< non-unicast address */

/**
 * @brief   A prefix information option that propagates the prefix of this
 *          address should set the autonomous flag.
 * @see     <a href="https://tools.ietf.org/html/rfc4861#section-6.2.1">
 *              RFC 4861, section 6.2.1
 *          </a>
 */
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO     (0x40)

/**
 * @brief   A prefix information option that propagates the prefix of this
 *          address should set the on-link flag.
 * @see     <a href="https://tools.ietf.org/html/rfc4861#section-6.2.1">
 *              RFC 4861, section 6.2.1
 *          </a>
 */
#define GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK  (0x80)
/**
 * @}
 */

/**
 * @{
 * @name Flags for the interfaces
 *
 * @note The most-significant byte of these flags is identical to the flags in
 *       IPv6 router advertisements. See <a
 *       href="https://tools.ietf.org/html/rfc4861#section-4.2">RFC4861,
 *       section 4.2</a>, <a
 *       href="https://tools.ietf.org/html/rfc6275#section-7.1">RFC6275,
 *       section 7.1</a>, <a
 *       href="https://tools.ietf.org/html/rfc4191#section-2.2">RFC4191,
 *       section 2.2</a>, and <a
 *       href="https://tools.ietf.org/html/rfc4389#section-4.1.3.3">RFC4389,
 *       section 4.1.3.3</a>.
 */
/**
 * @brief   Interface is 6LoWPAN interface.
 */
#define GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN         (0x0001)

/**
 * @brief   Flag to indicate that routing is enabled on the interface.
 */
#define GNRC_IPV6_NETIF_FLAGS_ROUTER            (0x0002)

/**
 * @brief   Flag to indicate that the interface sends periodic router
 *          advertisements and in response to router solicitations.
 */
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV           (0x0004)

/**
 * @brief   Flag to indicate that gnrc_ipv6_netif_t::mtu shall be propagated
 *          with the MTU options in router advertisements.
 */
#define GNRC_IPV6_NETIF_FLAGS_ADV_MTU           (0x0008)

/**
 * @brief   Flag to indicate that gnrc_ipv6_netif_t::cur_hl shall be propagated
 *          in router advertisements.
 */
#define GNRC_IPV6_NETIF_FLAGS_ADV_CUR_HL        (0x0010)

/**
 * @brief   Flag to indicate that gnrc_ipv6_netif_t::reach_time shall be propagated
 *          in router advertisements.
 */
#define GNRC_IPV6_NETIF_FLAGS_ADV_REACH_TIME    (0x0020)

/**
 * @brief   Flag to indicate that gnrc_ipv6_netif_t::retrans_timer shall be propagated
 *          in router advertisements.
 */
#define GNRC_IPV6_NETIF_FLAGS_ADV_RETRANS_TIMER (0x0040)

/**
 * @brief   Flag to indicate if the interface is operating over a wired link
 */
#define GNRC_IPV6_NETIF_FLAGS_IS_WIRED          (0x0080)

/**
 * @brief   Offset of the router advertisement flags compared to the position in router
 *          advertisements.
 */
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV_POS       (8U)

/**
 * @brief   Mask for flags intended for router advertisements.
 * @note    Please expand if more router advertisement flags are introduced.
 */
#define GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK      (0xc000)

/**
 * @brief   Flag to indicate that the interface has other address
 *          configuration.
 */
#define GNRC_IPV6_NETIF_FLAGS_OTHER_CONF        (0x4000)

/**
 * @brief   Flag to indicate that the interface has managed address
 *          configuration (e.g. via DHCPv6).
 */
#define GNRC_IPV6_NETIF_FLAGS_MANAGED           (0x8000)
/**
 * @}
 */

/**
 * @brief   Type to represent an IPv6 address registered to an interface.
 */
typedef struct {
    ipv6_addr_t addr;       /**< The address data */
    uint8_t flags;          /**< flags */
    uint8_t prefix_len;     /**< length of the prefix of the address */
    /**
     * @{
     * @name    Neigbour discovery variables for prefixes
     * @see     <a href="https://tools.ietf.org/html/rfc4861#section-6.2.1">
     *              RFC 4861, section 6.2.1
     *          </a>
     */
    /**
     * @brief   The time in seconds this address is valid. If it is UINT32_MAX
     *          the lifetime is infinite.
     */
    uint32_t valid;

    /**
     * @brief   The length of time that this address remains preferred.
     *          If it is UINT32_MAX the lifetime is infinite.
     *          It **must** be < gnrc_ipv6_netif_addr_t::valid.
     */
    uint32_t preferred;
    /**
     * @brief   Validity timeout timer.
     */
    xtimer_t valid_timeout;
    msg_t valid_timeout_msg;    /**< msg_t for gnrc_ipv6_netif_addr_t::valid_timeout */
    /**
     * @}
     */
} gnrc_ipv6_netif_addr_t;

/**
 * @brief   Definition of IPv6 interface type.
 */
typedef struct {
    /**
     * @brief addresses registered to the interface
     */
    gnrc_ipv6_netif_addr_t addrs[GNRC_IPV6_NETIF_ADDR_NUMOF];
    mutex_t mutex;          /**< mutex for the interface */
    kernel_pid_t pid;       /**< PID of the interface */
    uint16_t flags;         /**< flags for 6LoWPAN and Neighbor Discovery */
    uint16_t mtu;           /**< Maximum Transmission Unit (MTU) of the interface */
    uint8_t cur_hl;         /**< current hop limit for the interface */
#if defined(MODULE_GNRC_NDP_HOST) || defined(MODULE_GNRC_SIXLOWPAN_ND)
    /**
     * @brief   Counter for send router solicitations.
     */
    uint8_t rtr_sol_count;
#endif
#ifdef MODULE_GNRC_NDP_ROUTER
    /**
     * @brief   Counter for initial router advertisements.
     */
    uint8_t rtr_adv_count;

    /**
     * @brief   Maximum time in seconds between sending unsolicited multicast
     *          router advertisements. Must be between 4 and 1800 seconds.
     *          The default value is @ref GNRC_IPV6_NETIF_DEFAULT_MAX_ADV_INT.
     */
    uint16_t max_adv_int;

    /**
     * @brief   Minimum time in seconds between sending unsolicited multicast
     *          router advertisements. Must be between 3 and
     *          3/4 * gnrc_ipv6_netif_t::max_adv_int seconds.
     *          The default value is @ref GNRC_IPV6_NETIF_DEFAULT_MIN_ADV_INT.
     */
    uint16_t min_adv_int;

#endif
#if defined (MODULE_GNRC_NDP_ROUTER) || defined (MODULE_GNRC_SIXLOWPAN_ND_ROUTER)
    /**
     * @brief   The router lifetime to propagate in router advertisements.
     *          Must be either 0 or between gnrc_ipv6_netif_t::max_adv_int and
     *          9000 seconds. 0 means this router is not to be used as a default
     *          router. The default value is @ref GNRC_IPV6_NETIF_DEFAULT_ROUTER_LTIME.
     */
    uint16_t adv_ltime;
#endif
    /**
     * @brief   Base value in microseconds for computing random
     *          gnrc_ipv6_netif_t::reach_time.
     *          The default value is @ref GNRC_NDP_REACH_TIME.
     */
    uint32_t reach_time_base;

    /**
     * @brief   The time a neighbor is considered reachable after receiving
     *          a reachability confirmation.
     *          Should be uniformly distributed between @ref GNRC_NDP_MIN_RAND
     *          and GNRC_NDP_MAX_RAND multiplied with
     *          gnrc_ipv6_netif_t::reach_time_base microseconds devided by 10.
     *          Can't be greater than 1 hour.
     */
    uint32_t reach_time;

    /**
     * @brief   Time between retransmissions of neighbor solicitations to a
     *          neighbor.
     *          The default value is @ref GNRC_NDP_RETRANS_TIMER.
     */
    uint32_t retrans_timer;
    xtimer_t rtr_sol_timer; /**< Timer for periodic router solicitations */
    msg_t rtr_sol_msg;      /**< msg_t for gnrc_ipv6_netif_t::rtr_sol_timer */
#if defined (MODULE_GNRC_NDP_ROUTER) || defined (MODULE_GNRC_SIXLOWPAN_ND_ROUTER)
    xtimer_t rtr_adv_timer; /**< Timer for periodic router advertisements */
    msg_t rtr_adv_msg;      /**< msg_t for gnrc_ipv6_netif_t::rtr_adv_timer */
#endif
#ifdef MODULE_NETSTATS_IPV6
    netstats_t stats;                       /**< transceiver's statistics */
#endif
} gnrc_ipv6_netif_t;

/**
 * @brief Initializes the module.
 */
void gnrc_ipv6_netif_init(void);

/**
 * @brief   Add interface to IPv6.
 *
 * @details This function will be called by @ref gnrc_netif_add().
 *
 * @param[in] pid   The PID to the interface.
 */
void gnrc_ipv6_netif_add(kernel_pid_t pid);

/**
 * @brief   Remove interface from IPv6.
 *
 * @details This function will be called by @ref gnrc_netif_remove().
 *
 * @param[in] pid   The PID to the interface.
 */
void gnrc_ipv6_netif_remove(kernel_pid_t pid);

/**
 * @brief   Get interface.
 *
 * @param[in] pid   The PID to the interface.
 *
 * @return  The interface describing structure, on success.
 * @return  NULL, if there is no interface with PID @p pid.
 */
gnrc_ipv6_netif_t *gnrc_ipv6_netif_get(kernel_pid_t pid);

#if (defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER))
/**
 * @brief   Set interface to router mode.
 *
 * @details This sets/unsets the GNRC_IPV6_NETIF_FLAGS_ROUTER and initializes
 *          or ceases router behavior for neighbor discovery.
 *
 * @param[in] netif     The interface.
 * @param[in] enable    Status for the GNRC_IPV6_NETIF_FLAGS_ROUTER flag.
 */
void gnrc_ipv6_netif_set_router(gnrc_ipv6_netif_t *netif, bool enable);

/**
 * @brief   Set interface to router advertisement mode.
 *
 * @details If GNRC_IPV6_NETIF_FLAGS_ROUTER is set this sets/unsets the
 *          GNRC_IPV6_NETIF_FLAGS_RTR_ADV and initializes or ceases router
 *          advertising behavior for neighbor discovery.
 *
 * @param[in] netif     The interface.
 * @param[in] enable    Status for the GNRC_IPV6_NETIF_FLAGS_RTR flag.
 */
void gnrc_ipv6_netif_set_rtr_adv(gnrc_ipv6_netif_t *netif, bool enable);
#else
/* dummy macros to be able to "call" these functions when none of the relevant modules
 * is implemented */
#define gnrc_ipv6_netif_set_router(netif, enable)
#define gnrc_ipv6_netif_set_rtr_adv(netif, enable)
#endif

/**
 * @brief   Adds an address to an interface.
 *
 * @param[in] pid           The PID to the interface.
 * @param[in] addr          An address you want to add to the interface.
 * @param[in] prefix_len    Length of the prefix of the address.
 *                          Must be between 1 and 128.
 * @param[in] flags         Flags for the address entry
 *                          If @p addr should be an anycast address, @p flags
 *                          must have @ref GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST
 *                          set. Otherwise leave it unset.
 *                          If @p addr is a multicast address, the status of
 *                          @ref GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST will be
 *                          ignored and set in either case.
 *
 * @see <a href="https://tools.ietf.org/html/rfc4291#section-2.6">
 *          RFC 4291, section 2.6
 *      </a>
 *
 * @return  The address on the interface, on success.
 * @return  NULL, on failure
 */
ipv6_addr_t *gnrc_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr, uint8_t prefix_len,
                                      uint8_t flags);

/**
 * @brief   Remove an address from the interface.
 *
 * @param[in] pid       The PID to the interface. If @p pid is KERNEL_PID_UNDEF
 *                      it will be removed from all interfaces.
 * @param[in] addr      An address you want to remove from interface.
 */
void gnrc_ipv6_netif_remove_addr(kernel_pid_t pid, ipv6_addr_t *addr);

/**
 * @brief   Removes all addresses from the interface.
 *
 * @param[in] pid       The PID to the interface.
 */
void gnrc_ipv6_netif_reset_addr(kernel_pid_t pid);

/**
 * @brief   Searches for an address on all interfaces.
 *
 * @param[out] out  The reference to the address on the interface.
 * @param[in] addr  The address you want to search for.
 *
 * @return  The PID to the interface the address is registered to.
 * @return  KERNEL_PID_UNDEF, if the address can not be found on any interface.
 */
kernel_pid_t gnrc_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *addr);

/**
 * @brief   Searches for an address on an interface.
 *
 * @param[in] pid   The PID to the interface.
 * @param[in] addr  The address you want to search for.
 *
 * @return  The reference to the address on the interface.
 * @return  NULL, if the address can not be found on the interface.
 * @return  NULL, if @p pid is no interface.
 */
ipv6_addr_t *gnrc_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr);

/**
 * @brief   Searches for the first address matching a prefix best on all
 *          interfaces.
 *
 * @param[out] out      The reference to the found address on the interface.
 *                      Must be a pointer to NULL on calling and may stay
 *                      unchanged if no match can be found.
 *
 * @param[in] prefix    The prefix you want to search for.
 *
 * @pre     @p out must not be NULL.
 *
 * @return  The PID to the interface the address is registered to.
 * @return  KERNEL_PID_UNDEF, if no matching address can not be found on any
 *          interface.
 */
kernel_pid_t gnrc_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *prefix);

/**
 * @brief   Searches for the first address matching a prefix best on an
 *          interface.
 *
 * @param[in] pid       The PID to the interface.
 * @param[in] prefix    The prefix you want to search for.
 *
 * @return  The reference to the found address on the interface.
 * @return  NULL, if no matching address can be found on the interface.
 * @return  NULL, if @p pid is no interface.
 */
ipv6_addr_t *gnrc_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *prefix);

/**
 * @brief   Searches for the best address on an interface usable as a
 *          source address for a given destination address.
 *
 * @param[in] pid     The PID to the interface.
 * @param[in] dest    The destination address you want to find a destination
 *                    address for.
 * @param[in] ll_only If only link local addresses qualify
 *
 * @todo Rule 4 from RFC 6724 is currently not implemented. Has to updated as
 *       soon as gnrc supports Mobile IP.
 *
 * @todo Rule 6 from RFC 6724 is currently not implemented. Has to updated as
 *       soon as gnrc supports flow labels.
 *
 * @todo Rule 7 from RFC 6724 is currently not implemented. Has to updated as
 *       soon as gnrc supports temporary addresses.
 *
 * @return  The reference to the found address on the interface.
 * @return  NULL, if no matching address can be found on the interface.
 * @return  NULL, if @p pid is no interface.
 */
ipv6_addr_t *gnrc_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dest, bool ll_only);

/**
 * @brief   Get interface specific meta-information on an address
 *
 * @details This only works with addresses you retrieved via the following
 *          functions:
 *
 * * gnrc_ipv6_netif_add_addr()
 * * gnrc_ipv6_find_addr()
 * * gnrc_ipv6_find_addr_local()
 * * gnrc_ipv6_find_prefix_match()
 * * gnrc_ipv6_find_prefix_match_local()
 * * gnrc_ipv6_find_best_src_address()
 *
 * The behaviour for other addresses is undefined.
 *
 * @param[in] addr  The address you want to get the meta-information for.
 *
 * @return  Interface specific meta-information on @p addr
 */
static inline gnrc_ipv6_netif_addr_t *gnrc_ipv6_netif_addr_get(const ipv6_addr_t *addr)
{
    return container_of(addr, gnrc_ipv6_netif_addr_t, addr);
}

/**
 * @brief   Checks if an address is non-unicast.
 *
 * @details This only works with addresses you retrieved via the following
 *          functions:
 *
 * * gnrc_ipv6_netif_add_addr()
 * * gnrc_ipv6_find_addr()
 * * gnrc_ipv6_find_addr_local()
 * * gnrc_ipv6_find_prefix_match()
 * * gnrc_ipv6_find_prefix_match_local()
 * * gnrc_ipv6_find_best_src_address()
 *
 * The behaviour for other addresses is undefined.
 *
 * @param[in] addr  The address you want to check.
 *
 * @return true, if address is anycast or multicast.
 * @return false, if address is unicast.
 */
static inline bool gnrc_ipv6_netif_addr_is_non_unicast(const ipv6_addr_t *addr)
{
    return (bool)(container_of(addr, gnrc_ipv6_netif_addr_t, addr)->flags &
                  GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST);

}

/**
 * @brief   Initializes an interface with device-dependent values.
 *
 * @note    Must be called after all interfaces were initialized and must not
 *          be called in an interface's thread (will otherwise hang up).
 */
void gnrc_ipv6_netif_init_by_dev(void);

/**
 * @brief   Get sent and received statistics about IPv6 traffic on this interface.
 *
 * @note    This function is only available if compiled with module `netstats_ipv6`.
 *
 * @param[in] pid   The PID to the interface.
 *
 * @return  A @ref netstats_t pointer to the statistics.
 * @return  NULL if no statistics are available.
 */
#if defined(MODULE_NETSTATS_IPV6) || DOXYGEN
netstats_t *gnrc_ipv6_netif_get_stats(kernel_pid_t pid);
#endif

#ifdef __cplusplus
}
#endif

#endif /* NET_GNRC_IPV6_NETIF_H */
/**
 * @}
 */