diff options
author | Sean Karlage <skarlage@fb.com> | 2018-07-26 22:51:50 -0500 |
---|---|---|
committer | Sean Karlage <skarlage@fb.com> | 2018-07-29 10:22:52 -0700 |
commit | 76761c89adf7dfd77abc1b601f3a6bac56724686 (patch) | |
tree | d3fb832af0ca4487acb244d111797b61fa96bf7e /dhcpv4/bsdp/bsdp.go | |
parent | b30145cf5536cc1a134ad83cfce21f0b7249cf84 (diff) |
DHCPv4: Refactor methods for easier testing
This refactors the input parameters for construction DISCOVER/INFORM*
packets so that it's easier to write unit tests for DHCPv4 and BSDP
methods. It also adds a bunch of unit tests for both packages and rounds out
their test coverage.
Diffstat (limited to 'dhcpv4/bsdp/bsdp.go')
-rw-r--r-- | dhcpv4/bsdp/bsdp.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/dhcpv4/bsdp/bsdp.go b/dhcpv4/bsdp/bsdp.go index 27de68e..22360ef 100644 --- a/dhcpv4/bsdp/bsdp.go +++ b/dhcpv4/bsdp/bsdp.go @@ -37,10 +37,10 @@ func needsReplyPort(replyPort uint16) bool { return replyPort != 0 && replyPort != dhcpv4.ClientPort } -// NewInformListForInterface creates a new INFORM packet for interface ifname -// with configuration options specified by config. -func NewInformListForInterface(iface string, replyPort uint16) (*dhcpv4.DHCPv4, error) { - d, err := dhcpv4.NewInformForInterface(iface /* needsBroadcast = */, false) +// NewInformList creates a new INFORM packet for interface with hardware address +// `hwaddr` and IP `localIP`. Packet will be sent out on port `replyPort`. +func NewInformList(hwaddr net.HardwareAddr, localIP net.IP, replyPort uint16) (*dhcpv4.DHCPv4, error) { + d, err := dhcpv4.NewInform(hwaddr, localIP) if err != nil { return nil, err } @@ -77,7 +77,7 @@ func NewInformListForInterface(iface string, replyPort uint16) (*dhcpv4.DHCPv4, } // InformSelectForAck constructs an INFORM[SELECT] packet given an ACK to the -// previously-sent INFORM[LIST] with Config config. +// previously-sent INFORM[LIST]. func InformSelectForAck(ack dhcpv4.DHCPv4, replyPort uint16, selectedImage BootImage) (*dhcpv4.DHCPv4, error) { d, err := dhcpv4.New() if err != nil { |