aboutsummaryrefslogtreecommitdiffstats
path: root/syscall_linux_386.go
blob: 76d7c7e52b7a79cf977ed228a4ac121b9cd55834 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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,
	)
}