summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4.go
diff options
context:
space:
mode:
authorHu Jun <hujun.work@gmail.com>2020-07-18 10:57:57 -0700
committerHu Jun <hujun.work@gmail.com>2020-07-18 10:57:57 -0700
commit78b117a1466dc17b81361199c79d620e083c04d4 (patch)
tree0c93d93b28f7c4d778d745b071a412677405cee1 /dhcpv4/dhcpv4.go
parent72bd5d4387dff6845f6182af2e797cdd557d8e2f (diff)
move NewReleaseFromAck to where all NewXXFromYY are
Signed-off-by: Hu Jun <hujun.work@gmail.com>
Diffstat (limited to 'dhcpv4/dhcpv4.go')
-rw-r--r--dhcpv4/dhcpv4.go34
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())),
- )...)
-}