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

Side by Side Diff: ipv4/control_linux.go

Issue 9727045: code review 9727045: go.net/ipv4: Expose SpecDst in ControlMessage and set i...
Patch Set: diff -r 89dbba2db2d4 https://code.google.com/p/go.net Created 10 years, 1 month 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:
View unified diff | Download patch
« no previous file with comments | « ipv4/control.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5 package ipv4
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 "syscall" 9 "syscall"
10 "unsafe" 10 "unsafe"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 for _, m := range cmsgs { 82 for _, m := range cmsgs {
83 if m.Header.Level != ianaProtocolIP { 83 if m.Header.Level != ianaProtocolIP {
84 continue 84 continue
85 } 85 }
86 switch m.Header.Type { 86 switch m.Header.Type {
87 case syscall.IP_TTL: 87 case syscall.IP_TTL:
88 cm.TTL = int(*(*byte)(unsafe.Pointer(&m.Data[:1][0]))) 88 cm.TTL = int(*(*byte)(unsafe.Pointer(&m.Data[:1][0])))
89 case syscall.IP_PKTINFO: 89 case syscall.IP_PKTINFO:
90 pi := (*syscall.Inet4Pktinfo)(unsafe.Pointer(&m.Data[0]) ) 90 pi := (*syscall.Inet4Pktinfo)(unsafe.Pointer(&m.Data[0]) )
91 cm.IfIndex = int(pi.Ifindex) 91 cm.IfIndex = int(pi.Ifindex)
92 cm.SpecDst = pi.Spec_dst[:]
92 cm.Dst = pi.Addr[:] 93 cm.Dst = pi.Addr[:]
93 } 94 }
94 } 95 }
95 return cm, nil 96 return cm, nil
96 } 97 }
97 98
98 func marshalControlMessage(cm *ControlMessage) (oob []byte) { 99 func marshalControlMessage(cm *ControlMessage) (oob []byte) {
99 if cm == nil { 100 if cm == nil {
100 return 101 return
101 } 102 }
(...skipping 15 matching lines...) Expand all
117 copy(pi.Addr[:], ip) 118 copy(pi.Addr[:], ip)
118 } 119 }
119 if cm.IfIndex != 0 { 120 if cm.IfIndex != 0 {
120 pi.Ifindex = int32(cm.IfIndex) 121 pi.Ifindex = int32(cm.IfIndex)
121 } 122 }
122 off += syscall.CmsgSpace(syscall.SizeofInet4Pktinfo) 123 off += syscall.CmsgSpace(syscall.SizeofInet4Pktinfo)
123 } 124 }
124 } 125 }
125 return 126 return
126 } 127 }
OLDNEW
« no previous file with comments | « ipv4/control.go ('k') | no next file » | no next file with comments »

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