-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go.net/ipv4: add support for dragonfly, enable IP_PKTINFO on darwin
This CL adds support for dragonfly and IP_PKTINFO support for darwin with less dependency on syscall package. Update golang/go#7175 Fixes golang/go#7172. LGTM=iant R=golang-codereviews, gobot, iant CC=golang-codereviews https://golang.org/cl/97800043
- Loading branch information
Showing
32 changed files
with
640 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2014 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build !darwin,!linux | ||
|
||
package ipv4 | ||
|
||
func (cm *ControlMessage) marshalPacketInfo() (oob []byte) { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2014 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build darwin linux | ||
|
||
package ipv4 | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func (cm *ControlMessage) marshalPacketInfo() (oob []byte) { | ||
if l := cm.oobLen(); l > 0 { | ||
oob = make([]byte, l) | ||
m := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0])) | ||
m.Level = ianaProtocolIP | ||
m.Type = sysSockoptPacketInfo | ||
m.SetLen(syscall.CmsgLen(sysSizeofPacketInfo)) | ||
pi := (*sysPacketInfo)(unsafe.Pointer(&oob[syscall.CmsgLen(0)])) | ||
if ip := cm.Src.To4(); ip != nil { | ||
copy(pi.IP[:], ip) | ||
} | ||
if cm.IfIndex != 0 { | ||
pi.IfIndex = int32(cm.IfIndex) | ||
} | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.