diff options
author | Andrea Barberio <insomniac@slackware.it> | 2018-02-02 11:17:24 +0000 |
---|---|---|
committer | Andrea Barberio <insomniac@slackware.it> | 2018-02-02 11:17:24 +0000 |
commit | 4c5035ac053ead7e58def7e6e5c67402eb910bca (patch) | |
tree | 785f3f3491554edb633dcf27528d7ddf0cc0fdaf /dhcpv4/dhcpv4.go | |
parent | a28d7b9f5dabbc4387ca744d54e2a57ef07a5bd6 (diff) |
Changed API from NewDiscovery to NewDiscoveryForInterface
Diffstat (limited to 'dhcpv4/dhcpv4.go')
-rw-r--r-- | dhcpv4/dhcpv4.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dhcpv4/dhcpv4.go b/dhcpv4/dhcpv4.go index 5f01952..0df8cc6 100644 --- a/dhcpv4/dhcpv4.go +++ b/dhcpv4/dhcpv4.go @@ -81,14 +81,20 @@ func New() (*DHCPv4, error) { // Will build a new DHCPv4 Discovery message, with a default Ethernet HW type // and a null hardware address. The caller needs to fill the remaining fields up -func NewDiscovery() (*DHCPv4, error) { +func NewDiscoveryForInterface(ifname string) (*DHCPv4, error) { d, err := New() if err != nil { return nil, err } + // get hw addr + iface, err := net.InterfaceByName(ifname) + if err != nil { + return nil, err + } d.SetOpcode(OpcodeBootRequest) d.SetHwType(iana.HwTypeEthernet) - d.SetHwAddrLen(6) + d.SetHwAddrLen(uint8(len(iface.HardwareAddr))) + d.SetClientHwAddr(iface.HardwareAddr) d.SetBroadcast() d.AddOption(Option{ Code: OptionDHCPMessageType, |