diff options
Diffstat (limited to 'dhcpv4/bsdp/client.go')
-rw-r--r-- | dhcpv4/bsdp/client.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/dhcpv4/bsdp/client.go b/dhcpv4/bsdp/client.go index 3d885aa..2683e2a 100644 --- a/dhcpv4/bsdp/client.go +++ b/dhcpv4/bsdp/client.go @@ -2,6 +2,8 @@ package bsdp import ( "errors" + "fmt" + "net" "github.com/insomniacslk/dhcp/dhcpv4" ) @@ -49,10 +51,24 @@ func (c *Client) Exchange(ifname string, informList *dhcpv4.DHCPv4) ([]dhcpv4.DH if err != nil { return conversation, err } + iface, err := net.InterfaceByName(ifname) + if err != nil { + return conversation, err + } + + // Get currently configured IP. + addrs, err := iface.Addrs() + if err != nil { + return conversation, err + } + localIPs, err := dhcpv4.GetExternalIPv4Addrs(addrs) + if err != nil { + return conversation, fmt.Errorf("could not get local IPv4 addr for %s: %v", iface.Name, err) + } // INFORM[LIST] if informList == nil { - informList, err = NewInformListForInterface(ifname, dhcpv4.ClientPort) + informList, err = NewInformList(iface.HardwareAddr, localIPs[0], dhcpv4.ClientPort) if err != nil { return conversation, err } |