gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/net/internal/socket/sys_windows.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package socket
     6  
     7  import (
     8  	"syscall"
     9  	"unsafe"
    10  
    11  	"golang.org/x/sys/windows"
    12  )
    13  
    14  func probeProtocolStack() int {
    15  	var p uintptr
    16  	return int(unsafe.Sizeof(p))
    17  }
    18  
    19  const (
    20  	sysAF_UNSPEC = windows.AF_UNSPEC
    21  	sysAF_INET   = windows.AF_INET
    22  	sysAF_INET6  = windows.AF_INET6
    23  
    24  	sysSOCK_RAW = windows.SOCK_RAW
    25  
    26  	sizeofSockaddrInet4 = 0x10
    27  	sizeofSockaddrInet6 = 0x1c
    28  )
    29  
    30  func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
    31  	l := uint32(len(b))
    32  	err := syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), (*int32)(unsafe.Pointer(&l)))
    33  	return int(l), err
    34  }
    35  
    36  func setsockopt(s uintptr, level, name int, b []byte) error {
    37  	return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), int32(len(b)))
    38  }
    39  
    40  func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
    41  	return 0, errNotImplemented
    42  }
    43  
    44  func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
    45  	return 0, errNotImplemented
    46  }
    47  
    48  func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
    49  	return 0, errNotImplemented
    50  }
    51  
    52  func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
    53  	return 0, errNotImplemented
    54  }