summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2018-09-17 15:13:14 +0100
committerGitHub <noreply@github.com>2018-09-17 15:13:14 +0100
commit37d7fb8c0ea2aad32543403bbb57d1206062bc20 (patch)
tree3c2bbf58bb2dd7621e0d0c8c9dc6061d676bc4c0
parenta1d809f9af5f6e4d5aae6522b5dc9d9a16812465 (diff)
parent49117fb0f83872ea94c8f5c778f48dc15fb56d4b (diff)
Merge pull request #154 from pmazzini/infrequest
NewReplyFromDHCPv6Message: reply to information request
-rw-r--r--dhcpv6/dhcpv6_test.go6
-rw-r--r--dhcpv6/dhcpv6message.go5
2 files changed, 9 insertions, 2 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go
index 6840252..0b7c895 100644
--- a/dhcpv6/dhcpv6_test.go
+++ b/dhcpv6/dhcpv6_test.go
@@ -174,6 +174,12 @@ func TestNewReplyFromDHCPv6Message(t *testing.T) {
require.Equal(t, rep.(*DHCPv6Message).TransactionID(), msg.TransactionID())
require.Equal(t, rep.Type(), MessageTypeReply)
+ msg.SetMessage(MessageTypeInformationRequest)
+ rep, err = NewReplyFromDHCPv6Message(&msg, WithServerID(duid))
+ require.NoError(t, err)
+ require.Equal(t, rep.(*DHCPv6Message).TransactionID(), msg.TransactionID())
+ require.Equal(t, rep.Type(), MessageTypeReply)
+
msg.SetMessage(MessageTypeSolicit)
rep, err = NewReplyFromDHCPv6Message(&msg)
require.Error(t, err)
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index 48b82e9..cb17624 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -201,13 +201,14 @@ func NewRequestFromAdvertise(advertise DHCPv6, modifiers ...Modifier) (DHCPv6, e
// NewReplyFromDHCPv6Message creates a new REPLY packet based on a
// DHCPv6Message. The function is to be used when generating a reply to
-// REQUEST, CONFIRM, RENEW, REBIND and RELEASE packets.
+// REQUEST, CONFIRM, RENEW, REBIND, RELEASE and INFORMATION-REQUEST packets.
func NewReplyFromDHCPv6Message(message DHCPv6, modifiers ...Modifier) (DHCPv6, error) {
if message == nil {
return nil, errors.New("DHCPv6Message cannot be nil")
}
switch message.Type() {
- case MessageTypeRequest, MessageTypeConfirm, MessageTypeRenew, MessageTypeRebind, MessageTypeRelease:
+ case MessageTypeRequest, MessageTypeConfirm, MessageTypeRenew,
+ MessageTypeRebind, MessageTypeRelease, MessageTypeInformationRequest:
default:
return nil, errors.New("Cannot create REPLY from the passed message type set")
}