1 // Copyright 2011 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.
13 // Deprecated: Use golang.org/x/net/bpf instead.
14 func LsfStmt(code
, k
int) *SockFilter
{
15 return &SockFilter
{Code
: uint16(code
), K
: uint32(k
)}
18 // Deprecated: Use golang.org/x/net/bpf instead.
19 func LsfJump(code
, k
, jt
, jf
int) *SockFilter
{
20 return &SockFilter
{Code
: uint16(code
), Jt
: uint8(jt
), Jf
: uint8(jf
), K
: uint32(k
)}
23 // Deprecated: Use golang.org/x/net/bpf instead.
24 func LsfSocket(ifindex
, proto
int) (int, error
) {
25 var lsall SockaddrLinklayer
26 s
, e
:= Socket(AF_PACKET
, SOCK_RAW
, proto
)
30 p
:= (*[2]byte)(unsafe
.Pointer(&lsall
.Protocol
))
31 p
[0] = byte(proto
>> 8)
33 lsall
.Ifindex
= ifindex
47 // Deprecated: Use golang.org/x/net/bpf instead.
48 func SetLsfPromisc(name
string, m
bool) error
{
49 s
, e
:= Socket(AF_INET
, SOCK_DGRAM
, 0)
55 copy(ifl
.name
[:], []byte(name
))
56 _
, _
, ep
:= Syscall(SYS_IOCTL
, uintptr(s
), SIOCGIFFLAGS
, uintptr(unsafe
.Pointer(&ifl
)))
61 ifl
.flags |
= uint16(IFF_PROMISC
)
63 ifl
.flags
&^= uint16(IFF_PROMISC
)
65 _
, _
, ep
= Syscall(SYS_IOCTL
, uintptr(s
), SIOCSIFFLAGS
, uintptr(unsafe
.Pointer(&ifl
)))
72 // Deprecated: Use golang.org/x/net/bpf instead.
73 func AttachLsf(fd
int, i
[]SockFilter
) error
{
75 p
.Len
= uint16(len(i
))
76 p
.Filter
= (*SockFilter
)(unsafe
.Pointer(&i
[0]))
77 return setsockopt(fd
, SOL_SOCKET
, SO_ATTACH_FILTER
, unsafe
.Pointer(&p
), Socklen_t(unsafe
.Sizeof(p
)))
80 // Deprecated: Use golang.org/x/net/bpf instead.
81 func DetachLsf(fd
int) error
{
83 return setsockopt(fd
, SOL_SOCKET
, SO_DETACH_FILTER
, unsafe
.Pointer(&dummy
), Socklen_t(unsafe
.Sizeof(dummy
)))