diff options
-rw-r--r-- | dhcpv4/dhcpv4.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/dhcpv4/dhcpv4.go b/dhcpv4/dhcpv4.go index 14b0d9f..344e889 100644 --- a/dhcpv4/dhcpv4.go +++ b/dhcpv4/dhcpv4.go @@ -271,6 +271,23 @@ func NewReplyFromRequest(request *DHCPv4, modifiers ...Modifier) (*DHCPv4, error )...) } +// NewReleaseFromACK creates a DHCPv4 Release message from ACK. +// default Release message without any Modifer is created as following: +// - option Message Type is Release +// - ClientIP is set to ack.YourIPAddr +// - ClientHWAddr is set to ack.ClientHWAddr +// - Unicast +// - option Server Identifier is set to ack's ServerIdentifier +func NewReleaseFromACK(ack *DHCPv4, modifiers ...Modifier) (*DHCPv4, error) { + return New(PrependModifiers(modifiers, + WithMessageType(MessageTypeRelease), + WithClientIP(ack.YourIPAddr), + WithHwAddr(ack.ClientHWAddr), + WithBroadcast(false), + WithOption(OptServerIdentifier(ack.ServerIdentifier())), + )...) +} + // FromBytes encodes the DHCPv4 packet into a sequence of bytes, and returns an // error if the packet is not valid. func FromBytes(q []byte) (*DHCPv4, error) { @@ -790,20 +807,3 @@ func (d *DHCPv4) VIVC() VIVCIdentifiers { } return ids } - -// NewReleaseFromACK creates a DHCPv4 Release message from ACK. -// default Release message without any Modifer is created as following: -// - option Message Type is Release -// - ClientIP is set to ack.YourIPAddr -// - ClientHWAddr is set to ack.ClientHWAddr -// - Unicast -// - option Server Identifier is set to ack's ServerIdentifier -func NewReleaseFromACK(ack *DHCPv4, modifiers ...Modifier) (*DHCPv4, error) { - return New(PrependModifiers(modifiers, - WithMessageType(MessageTypeRelease), - WithClientIP(ack.YourIPAddr), - WithHwAddr(ack.ClientHWAddr), - WithBroadcast(false), - WithOption(OptServerIdentifier(ack.ServerIdentifier())), - )...) -} |