summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bindtodevice_darwin.go
blob: e9580ce7486dcb4d47b702378885c4787fae227d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
}