mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-05 16:47:02 +08:00
Use socketcall on x86
This commit is contained in:
53
syscall_linux_386.go
Normal file
53
syscall_linux_386.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// +build linux,386
|
||||
|
||||
/* Copyright 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
_SENDMSG = 16
|
||||
_RECVMSG = 17
|
||||
)
|
||||
|
||||
func sendmsg(fd int, msghdr *unix.Msghdr, flags int) (uintptr, uintptr, syscall.Errno) {
|
||||
args := struct {
|
||||
fd uintptr
|
||||
msghdr uintptr
|
||||
flags uintptr
|
||||
}{
|
||||
uintptr(fd),
|
||||
uintptr(unsafe.Pointer(msghdr)),
|
||||
uintptr(flags),
|
||||
}
|
||||
return unix.Syscall(
|
||||
unix.SYS_SOCKETCALL,
|
||||
_SENDMSG,
|
||||
uintptr(unsafe.Pointer(&args)),
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
func recvmsg(fd int, msghdr *unix.Msghdr, flags int) (uintptr, uintptr, syscall.Errno) {
|
||||
args := struct {
|
||||
fd uintptr
|
||||
msghdr uintptr
|
||||
flags uintptr
|
||||
}{
|
||||
uintptr(fd),
|
||||
uintptr(unsafe.Pointer(msghdr)),
|
||||
uintptr(flags),
|
||||
}
|
||||
return unix.Syscall(
|
||||
unix.SYS_SOCKETCALL,
|
||||
_RECVMSG,
|
||||
uintptr(unsafe.Pointer(&args)),
|
||||
0,
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user