forked from golang/net
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipv4: implement control messages on windows
Fixes golang/go#7175 Change-Id: I583c5713bedf073cf5abe25976275fc6b9193379
- Loading branch information
Showing
16 changed files
with
185 additions
and
21 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,20 @@ | ||
// Copyright 2017 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. | ||
|
||
package socket | ||
|
||
// WSACMSGHDR | ||
type cmsghdr struct { | ||
Len uintptr | ||
Level int32 | ||
Type int32 | ||
} | ||
|
||
const sizeofCmsghdr = 0xc | ||
|
||
func (h *cmsghdr) set(l, lvl, typ int) { | ||
h.Len = uintptr(l) | ||
h.Level = int32(lvl) | ||
h.Type = int32(typ) | ||
} |
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,21 @@ | ||
// Copyright 2017 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. | ||
|
||
package socket | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
type iovec syscall.WSABuf | ||
|
||
func (v *iovec) set(b []byte) { | ||
l := len(b) | ||
if l == 0 { | ||
return | ||
} | ||
v.Buf = (*byte)(unsafe.Pointer(&b[0])) | ||
v.Len = uint32(l) | ||
} |
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,51 @@ | ||
// Copyright 2017 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. | ||
|
||
package socket | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
type msghdr syscall.WSAMsg | ||
|
||
func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { | ||
for i := range vs { | ||
vs[i].set(bs[i]) | ||
} | ||
h.setIov(vs) | ||
if len(oob) > 0 { | ||
h.Control.Buf = (*byte)(unsafe.Pointer(&oob[0])) | ||
h.Control.Len = uint32(len(oob)) | ||
} | ||
if sa != nil { | ||
h.Name = uintptr(unsafe.Pointer(&sa[0])) | ||
h.Namelen = int32(len(sa)) | ||
} | ||
} | ||
|
||
func (h *msghdr) name() []byte { | ||
if h.Name != 0 && h.Namelen > 0 { | ||
return (*[sizeofSockaddrInet6]byte)(unsafe.Pointer(h.Name))[:h.Namelen] | ||
} | ||
return nil | ||
} | ||
|
||
func (h *msghdr) controllen() int { | ||
return int(h.Control.Len) | ||
} | ||
|
||
func (h *msghdr) flags() int { | ||
return int(h.Flags) | ||
} | ||
|
||
func (h *msghdr) setIov(vs []iovec) { | ||
l := len(vs) | ||
if l == 0 { | ||
return | ||
} | ||
h.Buffers = (*syscall.WSABuf)(unsafe.Pointer(&vs[0])) | ||
h.Bufferslen = uint32(l) | ||
} |
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
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
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