avoid pointer gymnastics
This commit is contained in:
parent
6e28978d84
commit
77f96119f9
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $ */
|
/* $NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1989, 1991, 1993
|
* Copyright (c) 1983, 1989, 1991, 1993
|
||||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1991, 1993\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $");
|
__RCSID("$NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -543,8 +543,10 @@ routename(const struct sockaddr *sa, struct sockaddr *nm, int flags)
|
|||||||
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
|
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
|
||||||
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
|
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
|
||||||
sin6.sin6_scope_id == 0) {
|
sin6.sin6_scope_id == 0) {
|
||||||
sin6.sin6_scope_id =
|
uint16_t scope;
|
||||||
ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);
|
memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
|
||||||
|
sizeof(scope));
|
||||||
|
sin6.sin6_scope_id = ntohs(scope);
|
||||||
sin6.sin6_addr.s6_addr[2] = 0;
|
sin6.sin6_addr.s6_addr[2] = 0;
|
||||||
sin6.sin6_addr.s6_addr[3] = 0;
|
sin6.sin6_addr.s6_addr[3] = 0;
|
||||||
}
|
}
|
||||||
@ -710,8 +712,10 @@ netname(const struct sockaddr *sa, struct sockaddr *nm)
|
|||||||
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
|
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
|
||||||
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
|
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
|
||||||
sin6.sin6_scope_id == 0) {
|
sin6.sin6_scope_id == 0) {
|
||||||
sin6.sin6_scope_id =
|
uint16_t scope;
|
||||||
ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);
|
memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
|
||||||
|
sizeof(scope));
|
||||||
|
sin6.sin6_scope_id = ntohs(scope);
|
||||||
sin6.sin6_addr.s6_addr[2] = 0;
|
sin6.sin6_addr.s6_addr[2] = 0;
|
||||||
sin6.sin6_addr.s6_addr[3] = 0;
|
sin6.sin6_addr.s6_addr[3] = 0;
|
||||||
}
|
}
|
||||||
@ -1259,8 +1263,10 @@ getaddr(int which, const char *s, struct hostent **hpp, struct sou *soup)
|
|||||||
if ((IN6_IS_ADDR_LINKLOCAL(&su->sin6.sin6_addr) ||
|
if ((IN6_IS_ADDR_LINKLOCAL(&su->sin6.sin6_addr) ||
|
||||||
IN6_IS_ADDR_MC_LINKLOCAL(&su->sin6.sin6_addr)) &&
|
IN6_IS_ADDR_MC_LINKLOCAL(&su->sin6.sin6_addr)) &&
|
||||||
su->sin6.sin6_scope_id) {
|
su->sin6.sin6_scope_id) {
|
||||||
*(u_int16_t *)&su->sin6.sin6_addr.s6_addr[2] =
|
uint16_t scope;
|
||||||
htons(su->sin6.sin6_scope_id);
|
scope = htons(su->sin6.sin6_scope_id);
|
||||||
|
memcpy(&su->sin6.sin6_addr.s6_addr[2], &scope,
|
||||||
|
sizeof(scope));
|
||||||
su->sin6.sin6_scope_id = 0;
|
su->sin6.sin6_scope_id = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user