Commit 97775bb4 authored by Mikio Hara's avatar Mikio Hara

go.net/ipv6: refit icmp filter for new platform-dependent code

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/162460043
parent 48871f00
...@@ -21,7 +21,7 @@ func (typ ICMPType) String() string { ...@@ -21,7 +21,7 @@ func (typ ICMPType) String() string {
// packets. // packets.
type ICMPFilter struct { type ICMPFilter struct {
mu sync.RWMutex mu sync.RWMutex
sysICMPFilter sysICMPv6Filter
} }
// Set sets the ICMP type and filter action to the filter. // Set sets the ICMP type and filter action to the filter.
......
...@@ -6,11 +6,7 @@ ...@@ -6,11 +6,7 @@
package ipv6 package ipv6
type sysICMPFilter struct { func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
Filt [8]uint32
}
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
if block { if block {
f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31)
} else { } else {
...@@ -18,7 +14,7 @@ func (f *sysICMPFilter) set(typ ICMPType, block bool) { ...@@ -18,7 +14,7 @@ func (f *sysICMPFilter) set(typ ICMPType, block bool) {
} }
} }
func (f *sysICMPFilter) setAll(block bool) { func (f *sysICMPv6Filter) setAll(block bool) {
for i := range f.Filt { for i := range f.Filt {
if block { if block {
f.Filt[i] = 0 f.Filt[i] = 0
...@@ -28,6 +24,6 @@ func (f *sysICMPFilter) setAll(block bool) { ...@@ -28,6 +24,6 @@ func (f *sysICMPFilter) setAll(block bool) {
} }
} }
func (f *sysICMPFilter) willBlock(typ ICMPType) bool { func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0
} }
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
package ipv6 package ipv6
type sysICMPFilter struct { func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
Data [8]uint32
}
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
if block { if block {
f.Data[typ>>5] |= 1 << (uint32(typ) & 31) f.Data[typ>>5] |= 1 << (uint32(typ) & 31)
} else { } else {
...@@ -16,7 +12,7 @@ func (f *sysICMPFilter) set(typ ICMPType, block bool) { ...@@ -16,7 +12,7 @@ func (f *sysICMPFilter) set(typ ICMPType, block bool) {
} }
} }
func (f *sysICMPFilter) setAll(block bool) { func (f *sysICMPv6Filter) setAll(block bool) {
for i := range f.Data { for i := range f.Data {
if block { if block {
f.Data[i] = 1<<32 - 1 f.Data[i] = 1<<32 - 1
...@@ -26,6 +22,6 @@ func (f *sysICMPFilter) setAll(block bool) { ...@@ -26,6 +22,6 @@ func (f *sysICMPFilter) setAll(block bool) {
} }
} }
func (f *sysICMPFilter) willBlock(typ ICMPType) bool { func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0 return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0
} }
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build solaris
package ipv6
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
// TODO(mikio): Implement this
}
func (f *sysICMPv6Filter) setAll(block bool) {
// TODO(mikio): Implement this
}
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
// TODO(mikio): Implement this
return false
}
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build nacl plan9 solaris // +build nacl plan9
package ipv6 package ipv6
type sysICMPFilter struct { type sysICMPv6Filter struct {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) set(typ ICMPType, block bool) { func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) setAll(block bool) { func (f *sysICMPv6Filter) setAll(block bool) {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) willBlock(typ ICMPType) bool { func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
// TODO(mikio): Implement this // TODO(mikio): Implement this
return false return false
} }
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
package ipv6 package ipv6
type sysICMPFilter struct { type sysICMPv6Filter struct {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) set(typ ICMPType, block bool) { func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) setAll(block bool) { func (f *sysICMPv6Filter) setAll(block bool) {
// TODO(mikio): Implement this // TODO(mikio): Implement this
} }
func (f *sysICMPFilter) willBlock(typ ICMPType) bool { func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
// TODO(mikio): Implement this // TODO(mikio): Implement this
return false return false
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment