diff options
author | Chris Gorham <gorhamc90@gmail.com> | 2018-11-07 23:35:11 +0000 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-11-07 23:35:11 +0000 |
commit | 7af404c171f0b1e63112b579e246dd3dc77e56ce (patch) | |
tree | 8ad3db2846e704ce37f77e0530aa822fc781deec /dhcpv6/options.go | |
parent | c572359d4d841c1b9d3eadd06c2b05e6085897b2 (diff) |
Adding module for DHCPv6 Vendor Options (Opt 17) (#130)
Diffstat (limited to 'dhcpv6/options.go')
-rw-r--r-- | dhcpv6/options.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/dhcpv6/options.go b/dhcpv6/options.go index 5c4f321..8508b08 100644 --- a/dhcpv6/options.go +++ b/dhcpv6/options.go @@ -88,6 +88,8 @@ func ParseOption(dataStart []byte) (Option, error) { opt, err = ParseOptUserClass(optData) case OptionVendorClass: opt, err = ParseOptVendorClass(optData) + case OptionVendorOpts: + opt, err = ParseOptVendorOpts(optData) case OptionInterfaceID: opt, err = ParseOptInterfaceId(optData) case OptionDNSRecursiveNameServer: @@ -120,6 +122,15 @@ func ParseOption(dataStart []byte) (Option, error) { } func OptionsFromBytes(data []byte) ([]Option, error) { + return OptionsFromBytesWithParser(data, ParseOption) +} + +// OptionParser is a function signature for option parsing +type OptionParser func(data []byte) (Option, error) + +// OptionsFromBytesWithParser parses Options from byte sequences using the +// parsing function that is passed in as a paremeter +func OptionsFromBytesWithParser(data []byte, parser OptionParser) ([]Option, error) { // Parse a sequence of bytes until the end and build a list of options from // it. Returns an error if any invalid option or length is found. options := make([]Option, 0, 10) @@ -140,7 +151,7 @@ func OptionsFromBytes(data []byte) ([]Option, error) { // this should never happen return nil, fmt.Errorf("Error: reading past the end of options") } - opt, err := ParseOption(data[idx:]) + opt, err := parser(data[idx:]) if err != nil { return nil, err } |