SecBSD's official ports repository
This commit is contained in:
commit
2c0afcbbf3
64331 changed files with 5339189 additions and 0 deletions
18
sysutils/beats/packetbeat/files/bindtodevice_bsd.go
Normal file
18
sysutils/beats/packetbeat/files/bindtodevice_bsd.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
// +build openbsd
|
||||
|
||||
package dhcpv4
|
||||
|
||||
import (
|
||||
"net"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// BindToInterface emulates linux's SO_BINDTODEVICE option for a socket by using
|
||||
// IP_RECVIF.
|
||||
func BindToInterface(fd int, ifname string) error {
|
||||
iface, err := net.InterfaceByName(ifname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return syscall.SetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_RECVIF, iface.Index)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue