1 // Copyright 2018 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.
5 // Berkeley packet filter for Darwin
13 // Deprecated: Use golang.org/x/net/bpf instead.
14 func BpfStmt(code
, k
int) *BpfInsn
{
15 return &BpfInsn
{Code
: uint16(code
), K
: uint32(k
)}
18 // Deprecated: Use golang.org/x/net/bpf instead.
19 func BpfJump(code
, k
, jt
, jf
int) *BpfInsn
{
20 return &BpfInsn
{Code
: uint16(code
), Jt
: uint8(jt
), Jf
: uint8(jf
), K
: uint32(k
)}
23 // Deprecated: Use golang.org/x/net/bpf instead.
24 func BpfBuflen(fd
int) (int, error
) {
26 err
:= ioctlPtr(fd
, BIOCGBLEN
, unsafe
.Pointer(&l
))
33 // Deprecated: Use golang.org/x/net/bpf instead.
34 func SetBpfBuflen(fd
, l
int) (int, error
) {
35 err
:= ioctlPtr(fd
, BIOCSBLEN
, unsafe
.Pointer(&l
))
42 // Deprecated: Use golang.org/x/net/bpf instead.
43 func BpfDatalink(fd
int) (int, error
) {
45 err
:= ioctlPtr(fd
, BIOCGDLT
, unsafe
.Pointer(&t
))
52 // Deprecated: Use golang.org/x/net/bpf instead.
53 func SetBpfDatalink(fd
, t
int) (int, error
) {
54 err
:= ioctlPtr(fd
, BIOCSDLT
, unsafe
.Pointer(&t
))
61 // Deprecated: Use golang.org/x/net/bpf instead.
62 func SetBpfPromisc(fd
, m
int) error
{
63 err
:= ioctlPtr(fd
, BIOCPROMISC
, unsafe
.Pointer(&m
))
70 // Deprecated: Use golang.org/x/net/bpf instead.
71 func FlushBpf(fd
int) error
{
72 err
:= ioctlPtr(fd
, BIOCFLUSH
, nil)
84 // Deprecated: Use golang.org/x/net/bpf instead.
85 func BpfInterface(fd
int, name
string) (string, error
) {
87 err
:= ioctlPtr(fd
, BIOCGETIF
, unsafe
.Pointer(&iv
))
94 // Deprecated: Use golang.org/x/net/bpf instead.
95 func SetBpfInterface(fd
int, name
string) error
{
97 copy(iv
.name
[:], []byte(name
))
98 err
:= ioctlPtr(fd
, BIOCSETIF
, unsafe
.Pointer(&iv
))
105 // Deprecated: Use golang.org/x/net/bpf instead.
106 func BpfTimeout(fd
int) (*Timeval
, error
) {
108 err
:= ioctlPtr(fd
, BIOCGRTIMEOUT
, unsafe
.Pointer(&tv
))
115 // Deprecated: Use golang.org/x/net/bpf instead.
116 func SetBpfTimeout(fd
int, tv
*Timeval
) error
{
117 err
:= ioctlPtr(fd
, BIOCSRTIMEOUT
, unsafe
.Pointer(tv
))
124 // Deprecated: Use golang.org/x/net/bpf instead.
125 func BpfStats(fd
int) (*BpfStat
, error
) {
127 err
:= ioctlPtr(fd
, BIOCGSTATS
, unsafe
.Pointer(&s
))
134 // Deprecated: Use golang.org/x/net/bpf instead.
135 func SetBpfImmediate(fd
, m
int) error
{
136 err
:= ioctlPtr(fd
, BIOCIMMEDIATE
, unsafe
.Pointer(&m
))
143 // Deprecated: Use golang.org/x/net/bpf instead.
144 func SetBpf(fd
int, i
[]BpfInsn
) error
{
146 p
.Len
= uint32(len(i
))
147 p
.Insns
= (*BpfInsn
)(unsafe
.Pointer(&i
[0]))
148 err
:= ioctlPtr(fd
, BIOCSETF
, unsafe
.Pointer(&p
))
155 // Deprecated: Use golang.org/x/net/bpf instead.
156 func CheckBpfVersion(fd
int) error
{
158 err
:= ioctlPtr(fd
, BIOCVERSION
, unsafe
.Pointer(&v
))
162 if v
.Major
!= BPF_MAJOR_VERSION || v
.Minor
!= BPF_MINOR_VERSION
{
168 // Deprecated: Use golang.org/x/net/bpf instead.
169 func BpfHeadercmpl(fd
int) (int, error
) {
171 err
:= ioctlPtr(fd
, BIOCGHDRCMPLT
, unsafe
.Pointer(&f
))
178 // Deprecated: Use golang.org/x/net/bpf instead.
179 func SetBpfHeadercmpl(fd
, f
int) error
{
180 err
:= ioctlPtr(fd
, BIOCSHDRCMPLT
, unsafe
.Pointer(&f
))