diff options
author | Owen Mooney <mooneyow@tcd.ie> | 2018-08-01 20:42:28 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-01 20:42:28 +0100 |
commit | 40474d58d9e4302b97e535e199e79ad1c63ade06 (patch) | |
tree | 2dcdac1d0d50d3f1938d5707a6d161f48ec24b87 /dhcpv4/option_userclass.go | |
parent | 85e86a8adb8f51277e8e9ceb1d423270dd2fffac (diff) |
Parse non-RFC compliant user class (#114)
Diffstat (limited to 'dhcpv4/option_userclass.go')
-rw-r--r-- | dhcpv4/option_userclass.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/dhcpv4/option_userclass.go b/dhcpv4/option_userclass.go index 307a128..fc088fa 100644 --- a/dhcpv4/option_userclass.go +++ b/dhcpv4/option_userclass.go @@ -66,6 +66,23 @@ func ParseOptUserClass(data []byte) (*OptUserClass, error) { totalLength, len(data)) } + // Check if option is Microsoft style instead of RFC compliant, issue #113 + + // User-class options are, according to RFC3004, supposed to contain a set + // of strings each with length UC_Len_i. Here we check that this is so, + // by seeing if all the UC_Len_i lengths are consistent with the overall + // option length. If the lengths don't add up, we assume that the option + // is a single string and non RFC3004 compliant + var counting int + for counting < totalLength { + // UC_Len_i does not include itself so add 1 + counting += int(data[counting]) + 1 + } + if counting != totalLength { + opt.UserClasses = append(opt.UserClasses, data[:totalLength]) + return &opt, nil + } + for i := 0; i < totalLength; { ucLen := int(data[i]) if ucLen == 0 { |