Skip to content

Commit 97775bb

Browse files
committed
go.net/ipv6: refit icmp filter for new platform-dependent code
LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/162460043
1 parent 48871f0 commit 97775bb

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

ipv6/icmp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (typ ICMPType) String() string {
2121
// packets.
2222
type ICMPFilter struct {
2323
mu sync.RWMutex
24-
sysICMPFilter
24+
sysICMPv6Filter
2525
}
2626

2727
// Set sets the ICMP type and filter action to the filter.

ipv6/icmp_bsd.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66

77
package ipv6
88

9-
type sysICMPFilter struct {
10-
Filt [8]uint32
11-
}
12-
13-
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
9+
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
1410
if block {
1511
f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31)
1612
} else {
1713
f.Filt[typ>>5] |= 1 << (uint32(typ) & 31)
1814
}
1915
}
2016

21-
func (f *sysICMPFilter) setAll(block bool) {
17+
func (f *sysICMPv6Filter) setAll(block bool) {
2218
for i := range f.Filt {
2319
if block {
2420
f.Filt[i] = 0
@@ -28,6 +24,6 @@ func (f *sysICMPFilter) setAll(block bool) {
2824
}
2925
}
3026

31-
func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
27+
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
3228
return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0
3329
}

ipv6/icmp_linux.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44

55
package ipv6
66

7-
type sysICMPFilter struct {
8-
Data [8]uint32
9-
}
10-
11-
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
7+
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
128
if block {
139
f.Data[typ>>5] |= 1 << (uint32(typ) & 31)
1410
} else {
1511
f.Data[typ>>5] &^= 1 << (uint32(typ) & 31)
1612
}
1713
}
1814

19-
func (f *sysICMPFilter) setAll(block bool) {
15+
func (f *sysICMPv6Filter) setAll(block bool) {
2016
for i := range f.Data {
2117
if block {
2218
f.Data[i] = 1<<32 - 1
@@ -26,6 +22,6 @@ func (f *sysICMPFilter) setAll(block bool) {
2622
}
2723
}
2824

29-
func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
25+
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
3026
return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0
3127
}

ipv6/icmp_solaris.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build solaris
6+
7+
package ipv6
8+
9+
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
10+
// TODO(mikio): Implement this
11+
}
12+
13+
func (f *sysICMPv6Filter) setAll(block bool) {
14+
// TODO(mikio): Implement this
15+
}
16+
17+
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
18+
// TODO(mikio): Implement this
19+
return false
20+
}

ipv6/icmp_stub.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build nacl plan9 solaris
5+
// +build nacl plan9
66

77
package ipv6
88

9-
type sysICMPFilter struct {
9+
type sysICMPv6Filter struct {
1010
// TODO(mikio): Implement this
1111
}
1212

13-
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
13+
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
1414
// TODO(mikio): Implement this
1515
}
1616

17-
func (f *sysICMPFilter) setAll(block bool) {
17+
func (f *sysICMPv6Filter) setAll(block bool) {
1818
// TODO(mikio): Implement this
1919
}
2020

21-
func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
21+
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
2222
// TODO(mikio): Implement this
2323
return false
2424
}

ipv6/icmp_windows.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
package ipv6
66

7-
type sysICMPFilter struct {
7+
type sysICMPv6Filter struct {
88
// TODO(mikio): Implement this
99
}
1010

11-
func (f *sysICMPFilter) set(typ ICMPType, block bool) {
11+
func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
1212
// TODO(mikio): Implement this
1313
}
1414

15-
func (f *sysICMPFilter) setAll(block bool) {
15+
func (f *sysICMPv6Filter) setAll(block bool) {
1616
// TODO(mikio): Implement this
1717
}
1818

19-
func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
19+
func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
2020
// TODO(mikio): Implement this
2121
return false
2222
}

0 commit comments

Comments
 (0)