summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorinsomniac <insomniacslk@users.noreply.github.com>2018-05-02 00:35:41 +0200
committerGitHub <noreply@github.com>2018-05-02 00:35:41 +0200
commit18dae087d822c843c2a2252f915f45577ba21df8 (patch)
tree84a73b81863f8c5c6786d9e075a9d8b7187d010f
parent73ca529d3079e0704e2d3901d4ead1591f6ccf72 (diff)
NewMessage now accepts modifiers (#54)
-rw-r--r--dhcpv6/dhcpv6.go11
1 files 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 {