Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1100)

Delta Between Two Patch Sets: ipv4/multicast_test.go

Issue 6482044: code review 6482044: go.net/ipv4: new package (Closed)
Left Patch Set: diff -r 147c4a6dca9b https://code.google.com/p/go.net Created 12 years, 6 months ago
Right Patch Set: diff -r 2513e9008213 https://code.google.com/p/go.net Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ipv4/mocktransponder_test.go ('k') | ipv4/multicastlistener_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux openbsd 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 package ipv4_test 7 package ipv4_test
8 8
9 import ( 9 import (
10 "code.google.com/p/go.net/ipv4" 10 "code.google.com/p/go.net/ipv4"
11 "net" 11 "net"
12 "os" 12 "os"
13 "testing" 13 "testing"
14 ) 14 )
15 15
16 func TestReadWriteMulticastUDPoIPPayload(t *testing.T) { 16 func TestReadWriteMulticastIPPayloadUDP(t *testing.T) {
dave_cheney.net 2012/09/05 06:27:16 toIPPayload ?
mikio 2012/09/06 10:43:48 changed to IPPayloadUDP.
mikio 2012/09/06 10:43:48 Done.
17 if testing.Short() || !*testExternal { 17 if testing.Short() || !*testExternal {
18 t.Logf("skipping test to avoid external network") 18 t.Logf("skipping test to avoid external network")
19 return 19 return
20 } 20 }
21 21
22 » c, err := net.ListenPacket("udp4", "224.0.0.0"+":"+"1024") // see RFC 47 27 22 » c, err := net.ListenPacket("udp4", "224.0.0.0:1024") // see RFC 4727
dave_cheney.net 2012/09/05 06:27:16 Can't this just be "224.0.0.0:1024" ?
mikio 2012/09/06 10:43:48 Done.
23 if err != nil { 23 if err != nil {
24 t.Fatalf("net.ListenPacket failed: %v", err) 24 t.Fatalf("net.ListenPacket failed: %v", err)
25 } 25 }
26 defer c.Close() 26 defer c.Close()
27 27
28 ifi := loopbackInterface() 28 ifi := loopbackInterface()
29 if ifi == nil { 29 if ifi == nil {
30 t.Logf("skipping test; an appropriate interface not found") 30 t.Logf("skipping test; an appropriate interface not found")
31 return 31 return
32 } 32 }
33 » dst, err := net.ResolveUDPAddr("udp4", "224.0.0.254"+":"+"1024") // see RFC 4727 33 » dst, err := net.ResolveUDPAddr("udp4", "224.0.0.254:1024") // see RFC 47 27
dave_cheney.net 2012/09/05 06:27:16 ditto
mikio 2012/09/06 10:43:48 Done.
34 if err != nil { 34 if err != nil {
35 t.Fatalf("net.ResolveUDPAddr failed: %v", err) 35 t.Fatalf("net.ResolveUDPAddr failed: %v", err)
36 } 36 }
37 37
38 p := ipv4.NewPacketConn(c) 38 p := ipv4.NewPacketConn(c)
39 if err := p.JoinGroup(ifi, dst); err != nil { 39 if err := p.JoinGroup(ifi, dst); err != nil {
40 t.Fatalf("ipv4.PacketConn.JoinGroup on %v failed: %v", ifi, err) 40 t.Fatalf("ipv4.PacketConn.JoinGroup on %v failed: %v", ifi, err)
41 } 41 }
42 if err := p.SetMulticastInterface(ifi); err != nil { 42 if err := p.SetMulticastInterface(ifi); err != nil {
43 t.Fatalf("ipv4.PacketConn.SetMulticastInterface failed: %v", err ) 43 t.Fatalf("ipv4.PacketConn.SetMulticastInterface failed: %v", err )
44 } 44 }
45 if err := p.SetMulticastLoopback(true); err != nil { 45 if err := p.SetMulticastLoopback(true); err != nil {
46 t.Fatalf("ipv4.PacketConn.SetMulticastLoopback failed: %v", err) 46 t.Fatalf("ipv4.PacketConn.SetMulticastLoopback failed: %v", err)
47 } 47 }
48 runPayloadTransponder(t, p, []byte("HELLO-R-U-THERE"), dst) 48 runPayloadTransponder(t, p, []byte("HELLO-R-U-THERE"), dst)
49 } 49 }
50 50
51 func TestReadWriteMulticastICMPoIPPayload(t *testing.T) { 51 func TestReadWriteMulticastIPPayloadICMP(t *testing.T) {
52 if testing.Short() || !*testExternal { 52 if testing.Short() || !*testExternal {
53 t.Logf("skipping test to avoid external network") 53 t.Logf("skipping test to avoid external network")
54 return 54 return
55 } 55 }
56 if os.Getuid() != 0 { 56 if os.Getuid() != 0 {
57 t.Logf("skipping test; must be root") 57 t.Logf("skipping test; must be root")
58 return 58 return
59 } 59 }
60 60
61 c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") 61 c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if err := r.JoinGroup(ifi, dst); err != nil { 119 if err := r.JoinGroup(ifi, dst); err != nil {
120 t.Fatalf("ipv4.RawConn.JoinGroup on %v failed: %v", ifi, err) 120 t.Fatalf("ipv4.RawConn.JoinGroup on %v failed: %v", ifi, err)
121 } 121 }
122 if err := r.SetMulticastInterface(ifi); err != nil { 122 if err := r.SetMulticastInterface(ifi); err != nil {
123 t.Fatalf("ipv4.PacketConn.SetMulticastInterface failed: %v", err ) 123 t.Fatalf("ipv4.PacketConn.SetMulticastInterface failed: %v", err )
124 } 124 }
125 id := os.Getpid() & 0xffff 125 id := os.Getpid() & 0xffff
126 pld := newICMPEchoRequest(id, 1, 128, []byte("HELLO-R-U-THERE")) 126 pld := newICMPEchoRequest(id, 1, 128, []byte("HELLO-R-U-THERE"))
127 runDatagramTransponder(t, r, pld, nil, dst) 127 runDatagramTransponder(t, r, pld, nil, dst)
128 } 128 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b