diff --git a/pndp/interface.go b/pndp/interface.go index f0a2391..46b9bb4 100644 --- a/pndp/interface.go +++ b/pndp/interface.go @@ -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))) diff --git a/pndp/listener.go b/pndp/listener.go index d664ac7..1dfbfee 100644 --- a/pndp/listener.go +++ b/pndp/listener.go @@ -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 {