aboutsummaryrefslogtreecommitdiffstats
path: root/syscall_linux_386.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-18 07:54:39 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-18 10:17:04 +0200
commit0b940a756838efcb90363ad99cb085d077b78e96 (patch)
tree7438647654e830a76da66758606d03c7826ab5c8 /syscall_linux_386.go
parentUse simple 16-bit integer for persistent keepalive (diff)
downloadwireguard-go-0b940a756838efcb90363ad99cb085d077b78e96.tar.xz
wireguard-go-0b940a756838efcb90363ad99cb085d077b78e96.zip
Use socketcall on x86
Diffstat (limited to '')
-rw-r--r--syscall_linux_386.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/syscall_linux_386.go b/syscall_linux_386.go
new file mode 100644
index 0000000..76d7c7e
--- /dev/null
+++ b/syscall_linux_386.go
@@ -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,
+ )
+}