use new constants

This commit is contained in:
christos 2013-10-19 15:47:02 +00:00
parent c7c7d1300b
commit 1f484a2734

View File

@ -34,7 +34,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: inet6_scopeid.c,v 1.1 2013/10/19 00:08:34 christos Exp $");
__RCSID("$NetBSD: inet6_scopeid.c,v 1.2 2013/10/19 15:47:02 christos Exp $");
#include <sys/endian.h>
#include <string.h>
@ -47,8 +47,12 @@ void
inet6_getscopeid(struct sockaddr_in6 *sin6, int flags)
{
#if defined(__KAME__)
if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && (flags & 1)) ||
(IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) && (flags & 2))) {
if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_LINKLOCAL)) ||
(IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_MC_LINKLOCAL)) ||
(IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_SITELOCAL))) {
uint16_t scope;
memcpy(&scope, &sin6->sin6_addr.s6_addr[2], sizeof(scope));
sin6->sin6_scope_id = ntohs(scope);
@ -61,8 +65,12 @@ void
inet6_putscopeid(struct sockaddr_in6 *sin6, int flags)
{
#if defined(__KAME__)
if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && (flags & 1)) ||
(IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) && (flags & 2))) {
if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_LINKLOCAL)) ||
(IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_MC_LINKLOCAL)) ||
(IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) &&
(flags & INET6_IS_ADDR_SITELOCAL))) {
uint16_t scope = htons(sin6->sin6_scope_id);
memcpy(&sin6->sin6_addr.s6_addr[2], &scope, sizeof(scope));
sin6->sin6_scope_id = 0;