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.
8
"code.google.com/p/go.net/ipv6"
17
var icmpStringTests = []struct {
21
{ipv6.ICMPTypeDestinationUnreachable, "destination unreachable"},
26
func TestICMPString(t *testing.T) {
27
for _, tt := range icmpStringTests {
30
t.Errorf("got %s; expected %s", s, tt.out)
35
func TestICMPFilter(t *testing.T) {
37
case "dragonfly", "plan9", "solaris", "windows":
38
t.Skipf("not supported on %q", runtime.GOOS)
42
for _, toggle := range []bool{false, true} {
45
for _, typ := range []ipv6.ICMPType{
46
ipv6.ICMPTypeDestinationUnreachable,
47
ipv6.ICMPTypeEchoReply,
48
ipv6.ICMPTypeNeighborSolicitation,
49
ipv6.ICMPTypeDuplicateAddressConfirmation,
52
go func(typ ipv6.ICMPType) {
56
t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ)
59
if !f.WillBlock(typ) {
60
t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ)
68
func TestSetICMPFilter(t *testing.T) {
70
case "dragonfly", "plan9", "solaris", "windows":
71
t.Skipf("not supported on %q", runtime.GOOS)
74
t.Skip("ipv6 is not supported")
77
t.Skip("must be root")
80
c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
82
t.Fatalf("net.ListenPacket failed: %v", err)
86
p := ipv6.NewPacketConn(c)
90
f.Set(ipv6.ICMPTypeEchoRequest, false)
91
f.Set(ipv6.ICMPTypeEchoReply, false)
92
if err := p.SetICMPFilter(&f); err != nil {
93
t.Fatalf("ipv6.PacketConn.SetICMPFilter failed: %v", err)
95
kf, err := p.ICMPFilter()
97
t.Fatalf("ipv6.PacketConn.ICMPFilter failed: %v", err)
99
if !reflect.DeepEqual(kf, &f) {
100
t.Fatalf("got unexpected filter %#v; expected %#v", kf, f)