set IFF_PROMISC
This commit is contained in:
parent
1f294666f3
commit
48486cc205
@ -37,7 +37,7 @@ type iflags struct {
|
||||
flags uint16
|
||||
}
|
||||
|
||||
func setAllMulti(fd int, iface string, enable bool) {
|
||||
func setPromisc(fd int, iface string, enable bool) {
|
||||
var ifl iflags
|
||||
copy(ifl.name[:], []byte(iface))
|
||||
_, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.SIOCGIFFLAGS, uintptr(unsafe.Pointer(&ifl)))
|
||||
@ -46,9 +46,9 @@ func setAllMulti(fd int, iface string, enable bool) {
|
||||
}
|
||||
|
||||
if enable {
|
||||
ifl.flags |= uint16(syscall.IFF_ALLMULTI)
|
||||
ifl.flags |= uint16(syscall.IFF_PROMISC)
|
||||
} else {
|
||||
ifl.flags &^= uint16(syscall.IFF_ALLMULTI)
|
||||
ifl.flags &^= uint16(syscall.IFF_PROMISC)
|
||||
}
|
||||
|
||||
_, _, ep = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifl)))
|
||||
|
@ -34,7 +34,7 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
|
||||
}
|
||||
go func() {
|
||||
<-stopChan
|
||||
setAllMulti(fd, iface, false)
|
||||
setPromisc(fd, iface, false)
|
||||
_ = syscall.Close(fd)
|
||||
stopWG.Done() // syscall.read does not release when the file descriptor is closed
|
||||
}()
|
||||
@ -51,7 +51,7 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
setAllMulti(fd, iface, true)
|
||||
setPromisc(fd, iface, true)
|
||||
|
||||
var protocolNo uint32
|
||||
if requestType == ndp_SOL {
|
||||
|
Loading…
x
Reference in New Issue
Block a user