summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bindtodevice_darwin.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4/bindtodevice_darwin.go')
-rw-r--r--dhcpv4/bindtodevice_darwin.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/dhcpv4/bindtodevice_darwin.go b/dhcpv4/bindtodevice_darwin.go
new file mode 100644
index 0000000..e9580ce
--- /dev/null
+++ b/dhcpv4/bindtodevice_darwin.go
@@ -0,0 +1,16 @@
+// +build darwin
+
+package dhcpv4
+
+import (
+ "net"
+ "syscall"
+)
+
+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_BOUND_IF, iface.Index)
+}