8c3eb424d4c05e1d91a689ed6bd46774483be9da
[govpp.git] / vendor / github.com / google / gopacket / afpacket / sockopt_linux_386.go
1 // Copyright 2012 Google, Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree.
6
7 // +build linux,386
8
9 package afpacket
10
11 import (
12         "unsafe"
13
14         "golang.org/x/sys/unix"
15 )
16
17 const (
18         sysSETSOCKOPT = 0xe
19         sysGETSOCKOPT = 0xf
20 )
21
22 func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, unix.Errno)
23
24 // setsockopt provides access to the setsockopt syscall.
25 func setsockopt(fd, level, name int, v unsafe.Pointer, l uintptr) error {
26         _, errno := socketcall(
27                 sysSETSOCKOPT,
28                 uintptr(fd),
29                 uintptr(level),
30                 uintptr(name),
31                 uintptr(v),
32                 l,
33                 0,
34         )
35         if errno != 0 {
36                 return error(errno)
37         }
38
39         return nil
40 }
41
42 func getsockopt(fd, level, name int, v unsafe.Pointer, l uintptr) error {
43         _, errno := socketcall(
44                 sysGETSOCKOPT,
45                 uintptr(fd),
46                 uintptr(level),
47                 uintptr(name),
48                 uintptr(v),
49                 l,
50                 0,
51         )
52         if errno != 0 {
53                 return error(errno)
54         }
55
56         return nil
57 }