use memcpy to avoid type punning.
This commit is contained in:
parent
0f2de03a73
commit
0d33c75c01
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.11 2011/06/22 02:49:45 mrg Exp $
|
||||
# $NetBSD: Makefile,v 1.12 2011/08/16 12:49:13 christos Exp $
|
||||
|
||||
LIBISPRIVATE= yes
|
||||
|
||||
|
@ -16,8 +16,3 @@ CPPFLAGS+= -DINET6
|
|||
.endif
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
||||
# XXX
|
||||
.if ${HAVE_GCC} == 45
|
||||
COPTS.parser.c+= -fno-strict-aliasing
|
||||
.endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_qop.h,v 1.5 2008/05/02 19:07:44 xtraeme Exp $ */
|
||||
/* $NetBSD: altq_qop.h,v 1.6 2011/08/16 12:49:13 christos Exp $ */
|
||||
/* $KAME: altq_qop.h,v 1.5 2002/02/12 10:14:01 kjc Exp $ */
|
||||
/*
|
||||
* Copyright (C) 1999-2000
|
||||
|
@ -246,8 +246,14 @@ extern int daemonize; /* log_write uses stderr if daemonize is 0 */
|
|||
#endif /* !RSVPD */
|
||||
|
||||
#ifdef INET6
|
||||
/* a macro to handle v6 address in 32-bit fields */
|
||||
#define IN6ADDR32(a, i) (*(u_int32_t *)(&(a)->s6_addr[(i)<<2]))
|
||||
static inline uint32_t IN6ADDR32_GET(const struct in6_addr *a, size_t i) {
|
||||
uint32_t ret;
|
||||
memcpy(&ret, &(a)->s6_addr[i << 2], sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
static inline void IN6ADDR32_SET(struct in6_addr *a, size_t i, uint32_t val) {
|
||||
memcpy(&(a)->s6_addr[i << 2], &val, sizeof(val));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ALTQ_QOP_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parser.c,v 1.10 2004/10/29 19:58:18 dsl Exp $ */
|
||||
/* $NetBSD: parser.c,v 1.11 2011/08/16 12:49:13 christos Exp $ */
|
||||
/* $KAME: parser.c,v 1.16 2002/02/20 10:40:39 kjc Exp $ */
|
||||
/*
|
||||
* Copyright (C) 1999-2002
|
||||
|
@ -843,10 +843,14 @@ get_ip6addr(char **cpp, struct in6_addr *addr, struct in6_addr *mask)
|
|||
if (len > 0)
|
||||
*cp = (0xff << (8 - len)) & 0xff;
|
||||
|
||||
IN6ADDR32(addr, 0) &= IN6ADDR32(mask, 0);
|
||||
IN6ADDR32(addr, 1) &= IN6ADDR32(mask, 1);
|
||||
IN6ADDR32(addr, 2) &= IN6ADDR32(mask, 2);
|
||||
IN6ADDR32(addr, 3) &= IN6ADDR32(mask, 3);
|
||||
IN6ADDR32_SET(addr, 0, IN6ADDR32_GET(mask, 0) &
|
||||
IN6ADDR32_GET(addr, 0));
|
||||
IN6ADDR32_SET(addr, 1, IN6ADDR32_GET(mask, 1) &
|
||||
IN6ADDR32_GET(addr, 1));
|
||||
IN6ADDR32_SET(addr, 2, IN6ADDR32_GET(mask, 2) &
|
||||
IN6ADDR32_GET(addr, 2));
|
||||
IN6ADDR32_SET(addr, 3, IN6ADDR32_GET(mask, 3) &
|
||||
IN6ADDR32_GET(addr, 3));
|
||||
} else
|
||||
/* full mask */
|
||||
memset(mask, 0xff, sizeof(struct in6_addr));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: qop.c,v 1.10 2011/01/04 09:14:42 wiz Exp $ */
|
||||
/* $NetBSD: qop.c,v 1.11 2011/08/16 12:49:13 christos Exp $ */
|
||||
/* $KAME: qop.c,v 1.11 2001/10/26 04:57:59 kjc Exp $ */
|
||||
/*
|
||||
* Copyright (C) 1999-2000
|
||||
|
@ -1196,20 +1196,20 @@ filt_disjoint(struct flow_filter *front, struct flow_filter *back)
|
|||
if (!IN6_IS_ADDR_UNSPECIFIED(&front6->ff_flow6.fi6_src) &&
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&back6->ff_flow6.fi6_src)) {
|
||||
for (i=0; i<4; i++) {
|
||||
mask = IN6ADDR32(&front6->ff_mask6.mask6_src, i)
|
||||
& IN6ADDR32(&back6->ff_mask6.mask6_src, i);
|
||||
if ((IN6ADDR32(&front6->ff_flow6.fi6_src, i) & mask) !=
|
||||
(IN6ADDR32(&back6->ff_flow6.fi6_src, i) & mask))
|
||||
mask = IN6ADDR32_GET(&front6->ff_mask6.mask6_src, i)
|
||||
& IN6ADDR32_GET(&back6->ff_mask6.mask6_src, i);
|
||||
if ((IN6ADDR32_GET(&front6->ff_flow6.fi6_src, i) & mask) !=
|
||||
(IN6ADDR32_GET(&back6->ff_flow6.fi6_src, i) & mask))
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&front6->ff_flow6.fi6_dst) &&
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&back6->ff_flow6.fi6_dst)) {
|
||||
for (i=0; i<4; i++) {
|
||||
mask = IN6ADDR32(&front6->ff_mask6.mask6_dst, i)
|
||||
& IN6ADDR32(&back6->ff_mask6.mask6_dst, i);
|
||||
if ((IN6ADDR32(&front6->ff_flow6.fi6_dst, i) & mask) !=
|
||||
(IN6ADDR32(&back6->ff_flow6.fi6_dst, i) & mask))
|
||||
mask = IN6ADDR32_GET(&front6->ff_mask6.mask6_dst, i)
|
||||
& IN6ADDR32_GET(&back6->ff_mask6.mask6_dst, i);
|
||||
if ((IN6ADDR32_GET(&front6->ff_flow6.fi6_dst, i) & mask) !=
|
||||
(IN6ADDR32_GET(&back6->ff_flow6.fi6_dst, i) & mask))
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
@ -1306,16 +1306,16 @@ filt_subset(struct flow_filter *front, struct flow_filter *back)
|
|||
return (0);
|
||||
} else if (!IN6_IS_ADDR_UNSPECIFIED(&back6->ff_flow6.fi6_src))
|
||||
for (i=0; i<4; i++)
|
||||
if (~IN6ADDR32(&front6->ff_mask6.mask6_src, i) &
|
||||
IN6ADDR32(&back6->ff_mask6.mask6_src, i))
|
||||
if (~IN6ADDR32_GET(&front6->ff_mask6.mask6_src, i) &
|
||||
IN6ADDR32_GET(&back6->ff_mask6.mask6_src, i))
|
||||
return (0);
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&front6->ff_flow6.fi6_dst)) {
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&back6->ff_flow6.fi6_dst))
|
||||
return (0);
|
||||
} else if (!IN6_IS_ADDR_UNSPECIFIED(&back6->ff_flow6.fi6_dst))
|
||||
for (i=0; i<4; i++)
|
||||
if (~IN6ADDR32(&front6->ff_mask6.mask6_dst, i) &
|
||||
IN6ADDR32(&back6->ff_mask6.mask6_dst, i))
|
||||
if (~IN6ADDR32_GET(&front6->ff_mask6.mask6_dst, i) &
|
||||
IN6ADDR32_GET(&back6->ff_mask6.mask6_dst, i))
|
||||
return (0);
|
||||
|
||||
if (~front6->ff_mask6.mask6_tclass &
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: qop_conf.c,v 1.3 2006/10/12 19:59:13 peter Exp $ */
|
||||
/* $NetBSD: qop_conf.c,v 1.4 2011/08/16 12:49:13 christos Exp $ */
|
||||
/* $KAME: qop_conf.c,v 1.3 2002/10/26 06:59:53 kjc Exp $ */
|
||||
/*
|
||||
* Copyright (C) 1999-2000
|
||||
|
@ -30,6 +30,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <altq/altq.h>
|
||||
#include "altq_qop.h"
|
||||
|
|
Loading…
Reference in New Issue