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

Delta Between Two Patch Sets: ipv6/control_rfc3542_unix.go

Issue 174720043: code review 174720043: go.net/ipv6: update TODOs (Closed)
Left Patch Set: diff -r 34976018d4f0cf09061e2ab776fe46f2f3249a12 https://code.google.com/p/go.net Created 10 years, 4 months ago
Right Patch Set: diff -r 69996db1c92211d9aea524512fe7feda6555200e https://code.google.com/p/go.net Created 10 years, 4 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 | « ipv6/control_rfc2292_unix.go ('k') | ipv6/control_stub.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 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 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 dragonfly freebsd linux netbsd openbsd 5 // +build darwin dragonfly freebsd linux netbsd openbsd
6 6
7 package ipv6 7 package ipv6
8 8
9 import ( 9 import (
10 "syscall" 10 "syscall"
11 "unsafe" 11 "unsafe"
12 12
13 » "code.google.com/p/go.net/internal/iana" 13 » "golang.org/x/net/internal/iana"
14 ) 14 )
15 15
16 func marshalTrafficClass(b []byte, cm *ControlMessage) []byte { 16 func marshalTrafficClass(b []byte, cm *ControlMessage) []byte {
17 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 17 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
18 m.Level = iana.ProtocolIPv6 18 m.Level = iana.ProtocolIPv6
19 m.Type = sysIPV6_TCLASS 19 m.Type = sysIPV6_TCLASS
20 m.SetLen(syscall.CmsgLen(4)) 20 m.SetLen(syscall.CmsgLen(4))
21 if cm != nil { 21 if cm != nil {
22 data := b[syscall.CmsgLen(0):] 22 data := b[syscall.CmsgLen(0):]
23 » » // TODO(mikio): fix spurious word boundary access 23 » » // TODO(mikio): fix potential misaligned memory access
24 *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.TrafficClass) 24 *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.TrafficClass)
25 } 25 }
26 return b[syscall.CmsgSpace(4):] 26 return b[syscall.CmsgSpace(4):]
27 } 27 }
28 28
29 func parseTrafficClass(cm *ControlMessage, b []byte) { 29 func parseTrafficClass(cm *ControlMessage, b []byte) {
30 » // TODO(mikio): fix spurious word boundary access 30 » // TODO(mikio): fix potential misaligned memory access
31 cm.TrafficClass = int(*(*int32)(unsafe.Pointer(&b[:4][0]))) 31 cm.TrafficClass = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
32 } 32 }
33 33
34 func marshalHopLimit(b []byte, cm *ControlMessage) []byte { 34 func marshalHopLimit(b []byte, cm *ControlMessage) []byte {
35 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 35 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
36 m.Level = iana.ProtocolIPv6 36 m.Level = iana.ProtocolIPv6
37 m.Type = sysIPV6_HOPLIMIT 37 m.Type = sysIPV6_HOPLIMIT
38 m.SetLen(syscall.CmsgLen(4)) 38 m.SetLen(syscall.CmsgLen(4))
39 if cm != nil { 39 if cm != nil {
40 data := b[syscall.CmsgLen(0):] 40 data := b[syscall.CmsgLen(0):]
41 » » // TODO(mikio): fix spurious word boundary access 41 » » // TODO(mikio): fix potential misaligned memory access
42 *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.HopLimit) 42 *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.HopLimit)
43 } 43 }
44 return b[syscall.CmsgSpace(4):] 44 return b[syscall.CmsgSpace(4):]
45 } 45 }
46 46
47 func parseHopLimit(cm *ControlMessage, b []byte) { 47 func parseHopLimit(cm *ControlMessage, b []byte) {
48 » // TODO(mikio): fix spurious word boundary access 48 » // TODO(mikio): fix potential misaligned memory access
49 cm.HopLimit = int(*(*int32)(unsafe.Pointer(&b[:4][0]))) 49 cm.HopLimit = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
50 } 50 }
51 51
52 func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { 52 func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
53 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 53 m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
54 m.Level = iana.ProtocolIPv6 54 m.Level = iana.ProtocolIPv6
55 m.Type = sysIPV6_PKTINFO 55 m.Type = sysIPV6_PKTINFO
56 m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo)) 56 m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo))
57 if cm != nil { 57 if cm != nil {
58 pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) 58 pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 m.SetLen(syscall.CmsgLen(sysSizeofIPv6Mtuinfo)) 94 m.SetLen(syscall.CmsgLen(sysSizeofIPv6Mtuinfo))
95 return b[syscall.CmsgSpace(sysSizeofIPv6Mtuinfo):] 95 return b[syscall.CmsgSpace(sysSizeofIPv6Mtuinfo):]
96 } 96 }
97 97
98 func parsePathMTU(cm *ControlMessage, b []byte) { 98 func parsePathMTU(cm *ControlMessage, b []byte) {
99 mi := (*sysIPv6Mtuinfo)(unsafe.Pointer(&b[0])) 99 mi := (*sysIPv6Mtuinfo)(unsafe.Pointer(&b[0]))
100 cm.Dst = mi.Addr.Addr[:] 100 cm.Dst = mi.Addr.Addr[:]
101 cm.IfIndex = int(mi.Addr.Scope_id) 101 cm.IfIndex = int(mi.Addr.Scope_id)
102 cm.MTU = int(mi.Mtu) 102 cm.MTU = int(mi.Mtu)
103 } 103 }
LEFTRIGHT

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