summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4')
-rw-r--r--dhcpv4/bindtodevice_bsd.go18
-rw-r--r--dhcpv4/bindtodevice_darwin.go19
-rw-r--r--dhcpv4/bindtodevice_linux.go9
-rw-r--r--dhcpv4/bindtointerface.go10
4 files changed, 10 insertions, 46 deletions
diff --git a/dhcpv4/bindtodevice_bsd.go b/dhcpv4/bindtodevice_bsd.go
deleted file mode 100644
index 0f1b581..0000000
--- a/dhcpv4/bindtodevice_bsd.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// +build freebsd openbsd netbsd
-
-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)
-}
diff --git a/dhcpv4/bindtodevice_darwin.go b/dhcpv4/bindtodevice_darwin.go
deleted file mode 100644
index 3a1406b..0000000
--- a/dhcpv4/bindtodevice_darwin.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// +build darwin
-
-package dhcpv4
-
-import (
- "net"
-
- "golang.org/x/sys/unix"
-)
-
-// BindToInterface emulates linux's SO_BINDTODEVICE option for a socket by using
-// SO_IP_BOUND_IF.
-func BindToInterface(fd int, ifname string) error {
- iface, err := net.InterfaceByName(ifname)
- if err != nil {
- return err
- }
- return unix.SetsockoptInt(fd, unix.IPPROTO_IP, unix.IP_BOUND_IF, iface.Index)
-}
diff --git a/dhcpv4/bindtodevice_linux.go b/dhcpv4/bindtodevice_linux.go
deleted file mode 100644
index c1ae025..0000000
--- a/dhcpv4/bindtodevice_linux.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// +build linux
-
-package dhcpv4
-
-import "golang.org/x/sys/unix"
-
-func BindToInterface(fd int, ifname string) error {
- return unix.BindToDevice(fd, ifname)
-}
diff --git a/dhcpv4/bindtointerface.go b/dhcpv4/bindtointerface.go
new file mode 100644
index 0000000..dbe8fbc
--- /dev/null
+++ b/dhcpv4/bindtointerface.go
@@ -0,0 +1,10 @@
+package dhcpv4
+
+import (
+ "github.com/insomniacslk/dhcp/interfaces"
+)
+
+// BindToInterface (deprecated) redirects to interfaces.BindToInterface
+func BindToInterface(fd int, ifname string) error {
+ return interfaces.BindToInterface(fd, ifname)
+}