Просмотр исходного кода

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

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/162460043
Mikio Hara 11 лет назад
Родитель
Сommit
97775bb465
6 измененных файлов с 36 добавлено и 24 удалено
  1. 1 1
      ipv6/icmp.go
  2. 3 7
      ipv6/icmp_bsd.go
  3. 3 7
      ipv6/icmp_linux.go
  4. 20 0
      ipv6/icmp_solaris.go
  5. 5 5
      ipv6/icmp_stub.go
  6. 4 4
      ipv6/icmp_windows.go

+ 1 - 1
ipv6/icmp.go

@@ -21,7 +21,7 @@ func (typ ICMPType) String() string {
 // packets.
 type ICMPFilter struct {
 	mu sync.RWMutex
-	sysICMPFilter
+	sysICMPv6Filter
 }
 
 // Set sets the ICMP type and filter action to the filter.

+ 3 - 7
ipv6/icmp_bsd.go

@@ -6,11 +6,7 @@
 
 package ipv6
 
-type sysICMPFilter struct {
-	Filt [8]uint32
-}
-
-func (f *sysICMPFilter) set(typ ICMPType, block bool) {
+func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
 	if block {
 		f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31)
 	} else {
@@ -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 {
 		if block {
 			f.Filt[i] = 0
@@ -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
 }

+ 3 - 7
ipv6/icmp_linux.go

@@ -4,11 +4,7 @@
 
 package ipv6
 
-type sysICMPFilter struct {
-	Data [8]uint32
-}
-
-func (f *sysICMPFilter) set(typ ICMPType, block bool) {
+func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
 	if block {
 		f.Data[typ>>5] |= 1 << (uint32(typ) & 31)
 	} else {
@@ -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 {
 		if block {
 			f.Data[i] = 1<<32 - 1
@@ -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
 }

+ 20 - 0
ipv6/icmp_solaris.go

@@ -0,0 +1,20 @@
+// 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
+}

+ 5 - 5
ipv6/icmp_stub.go

@@ -2,23 +2,23 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build nacl plan9 solaris
+// +build nacl plan9
 
 package ipv6
 
-type sysICMPFilter struct {
+type sysICMPv6Filter struct {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) set(typ ICMPType, block bool) {
+func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) setAll(block bool) {
+func (f *sysICMPv6Filter) setAll(block bool) {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
+func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
 	// TODO(mikio): Implement this
 	return false
 }

+ 4 - 4
ipv6/icmp_windows.go

@@ -4,19 +4,19 @@
 
 package ipv6
 
-type sysICMPFilter struct {
+type sysICMPv6Filter struct {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) set(typ ICMPType, block bool) {
+func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) setAll(block bool) {
+func (f *sysICMPv6Filter) setAll(block bool) {
 	// TODO(mikio): Implement this
 }
 
-func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
+func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
 	// TODO(mikio): Implement this
 	return false
 }