static uint8_t _get_scope(const ipv6_addr_t *addr) { if (ipv6_addr_is_link_local(addr)) { return IPV6_ADDR_MCAST_SCP_LINK_LOCAL; } else if (ipv6_addr_is_site_local(addr)) { return IPV6_ADDR_MCAST_SCP_SITE_LOCAL; } else { return IPV6_ADDR_MCAST_SCP_GLOBAL; } }
/** * @brief Determines the scope of the given address. * * @param[in] addr The IPv6 address to check. * @param[in] maybe_multicast False if @p addr is definitely no multicast * address, true otherwise. * * @return The scope of the address. * * @pre address is not loopback or unspecified. * see http://tools.ietf.org/html/rfc6724#section-4 */ static uint8_t _get_scope(const ipv6_addr_t *addr, const bool maybe_multicast) { if (maybe_multicast && ipv6_addr_is_multicast(addr)) { return (addr->u8[1] & 0x0f); } else if (ipv6_addr_is_link_local(addr)) { return IPV6_ADDR_MCAST_SCP_LINK_LOCAL; } else if (ipv6_addr_is_site_local(addr)) { return IPV6_ADDR_MCAST_SCP_SITE_LOCAL; } else { return IPV6_ADDR_MCAST_SCP_GLOBAL; } }