Fix IPv6 filtering definitions in netinet/icmp6.h.

Linux and *BSD kernels use opposite values to indicate pass/block
in ICMPv6 filters, and assign a different value to the
ICMP6_FILTER sockopt.

Bug: 9671560
Bug: 9469682
Change-Id: Ic0f1fcd48891add992acf97632f60aebd172c1d7
This commit is contained in:
Lorenzo Colitti 2013-07-03 15:42:06 +09:00 committed by Elliott Hughes
parent e63ea6aca7
commit bfc6a59556

View File

@ -533,18 +533,28 @@ struct icmp6_filter {
u_int32_t icmp6_filt[8]; u_int32_t icmp6_filt[8];
}; };
/*
* BEGIN android-changed
* Linux and *BSD kernels use opposite values to indicate pass/block in ICMPv6
* filters, and assign a different value to the ICMP6_FILTER sockopt.
*/
#define ICMP6_FILTER 1
#define ICMP6_FILTER_SETPASSALL(filterp) \ #define ICMP6_FILTER_SETPASSALL(filterp) \
(void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
#define ICMP6_FILTER_SETBLOCKALL(filterp) \
(void)memset(filterp, 0x00, sizeof(struct icmp6_filter)) (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
#define ICMP6_FILTER_SETBLOCKALL(filterp) \
(void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
#define ICMP6_FILTER_SETPASS(type, filterp) \ #define ICMP6_FILTER_SETPASS(type, filterp) \
(((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
(((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
(((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
#define ICMP6_FILTER_WILLPASS(type, filterp) \ #define ICMP6_FILTER_WILLPASS(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
/*
* END android-changed
*/
/* /*
* Variables related to this implementation * Variables related to this implementation