From 18dae087d822c843c2a2252f915f45577ba21df8 Mon Sep 17 00:00:00 2001 From: insomniac Date: Wed, 2 May 2018 00:35:41 +0200 Subject: NewMessage now accepts modifiers (#54) --- dhcpv6/dhcpv6.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go index 329d8b2..7a53b90 100644 --- a/dhcpv6/dhcpv6.go +++ b/dhcpv6/dhcpv6.go @@ -79,16 +79,21 @@ func FromBytes(data []byte) (DHCPv6, error) { } // NewMessage creates a new DHCPv6 message with default options -func NewMessage() (DHCPv6, error) { +func NewMessage(modifiers ...Modifier) (DHCPv6, error) { tid, err := GenerateTransactionID() if err != nil { return nil, err } - d := DHCPv6Message{ + msg := DHCPv6Message{ messageType: SOLICIT, transactionID: *tid, } - return &d, nil + // apply modifiers + d := DHCPv6(&msg) + for _, mod := range modifiers { + d = mod(d) + } + return d, nil } func getOptions(options []Option, code OptionCode, onlyFirst bool) []Option { -- cgit v1.2.3