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

Delta Between Two Patch Sets: ipv4/header_test.go

Issue 6482044: code review 6482044: go.net/ipv4: new package (Closed)
Left Patch Set: diff -r 2513e9008213 https://code.google.com/p/go.net Created 11 years, 6 months ago
Right Patch Set: diff -r 2513e9008213 https://code.google.com/p/go.net Created 11 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/header.go ('k') | ipv4/helper.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 package ipv4_test 5 package ipv4_test
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "code.google.com/p/go.net/ipv4" 9 "code.google.com/p/go.net/ipv4"
10 "net" 10 "net"
11 "reflect" 11 "reflect"
12 "runtime" 12 "runtime"
13 "testing" 13 "testing"
14 ) 14 )
15 15
16 var ( 16 var (
17 wireHeaderFromKernel = [ipv4.HeaderLen]byte{ 17 wireHeaderFromKernel = [ipv4.HeaderLen]byte{
18 » » 0x45, 0x01, 0xbe, 0xef, 0xca, 0xfe, 0x05, 0xdc, 18 » » 0x45, 0x01, 0xbe, 0xef,
19 » » 0xff, 0x01, 0xde, 0xad, 172, 16, 254, 254, 19 » » 0xca, 0xfe, 0x05, 0xdc,
20 » » 0xff, 0x01, 0xde, 0xad,
21 » » 172, 16, 254, 254,
20 192, 168, 0, 1, 22 192, 168, 0, 1,
21 } 23 }
22 wireHeaderToKernel = [ipv4.HeaderLen]byte{ 24 wireHeaderToKernel = [ipv4.HeaderLen]byte{
23 » » 0x45, 0x01, 0xbe, 0xef, 0xca, 0xfe, 0x05, 0xdc, 25 » » 0x45, 0x01, 0xbe, 0xef,
24 » » 0xff, 0x01, 0xde, 0xad, 172, 16, 254, 254, 26 » » 0xca, 0xfe, 0x05, 0xdc,
27 » » 0xff, 0x01, 0xde, 0xad,
28 » » 172, 16, 254, 254,
25 192, 168, 0, 1, 29 192, 168, 0, 1,
26 } 30 }
27 wireHeaderFromTradBSDKernel = [ipv4.HeaderLen]byte{ 31 wireHeaderFromTradBSDKernel = [ipv4.HeaderLen]byte{
28 » » 0x45, 0x01, 0xdb, 0xbe, 0xca, 0xfe, 0xdc, 0x05, 32 » » 0x45, 0x01, 0xdb, 0xbe,
29 » » 0xff, 0x01, 0xde, 0xad, 172, 16, 254, 254, 33 » » 0xca, 0xfe, 0xdc, 0x05,
34 » » 0xff, 0x01, 0xde, 0xad,
35 » » 172, 16, 254, 254,
30 192, 168, 0, 1, 36 192, 168, 0, 1,
31 } 37 }
32 wireHeaderToTradBSDKernel = [ipv4.HeaderLen]byte{ 38 wireHeaderToTradBSDKernel = [ipv4.HeaderLen]byte{
33 » » 0x45, 0x01, 0xef, 0xbe, 0xca, 0xfe, 0xdc, 0x05, 39 » » 0x45, 0x01, 0xef, 0xbe,
34 » » 0xff, 0x01, 0xde, 0xad, 172, 16, 254, 254, 40 » » 0xca, 0xfe, 0xdc, 0x05,
41 » » 0xff, 0x01, 0xde, 0xad,
42 » » 172, 16, 254, 254,
35 192, 168, 0, 1, 43 192, 168, 0, 1,
36 } 44 }
37 » // TODO(mikio): Add platform dependent wire header format when 45 » // TODO(mikio): Add platform dependent wire header formats when
38 » // we support new platform. 46 » // we support new platforms.
39 ) 47 )
40 48
41 func testHeader() *ipv4.Header { 49 func testHeader() *ipv4.Header {
42 h := &ipv4.Header{} 50 h := &ipv4.Header{}
43 h.Version = ipv4.Version 51 h.Version = ipv4.Version
44 h.Len = ipv4.HeaderLen 52 h.Len = ipv4.HeaderLen
45 h.TOS = 1 53 h.TOS = 1
46 h.TotalLen = 0xbeef 54 h.TotalLen = 0xbeef
47 h.ID = 0xcafe 55 h.ID = 0xcafe
48 h.FragOff = 1500 56 h.FragOff = 1500
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 90 }
83 h, err := ipv4.ParseHeader(wh) 91 h, err := ipv4.ParseHeader(wh)
84 if err != nil { 92 if err != nil {
85 t.Fatalf("ipv4.ParseHeader failed: %v", err) 93 t.Fatalf("ipv4.ParseHeader failed: %v", err)
86 } 94 }
87 th := testHeader() 95 th := testHeader()
88 if !reflect.DeepEqual(h, th) { 96 if !reflect.DeepEqual(h, th) {
89 t.Fatalf("ipv4.ParseHeader failed: %#v not equal %#v", h, th) 97 t.Fatalf("ipv4.ParseHeader failed: %#v not equal %#v", h, th)
90 } 98 }
91 } 99 }
LEFTRIGHT

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