diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-12-22 11:34:37 +0000 |
---|---|---|
committer | Pablo Mazzini <pmazzini@gmail.com> | 2018-12-22 11:34:37 +0000 |
commit | 8c76c175ee8c3e2de4de54c461abccc04c2b7167 (patch) | |
tree | c1ea47916a4ae45c4f884f8865a4add932bccf5b /dhcpv4 | |
parent | 2b569280e441c779406c8b2aaa1283ca5ce0f15b (diff) |
[ztpv4] make it consistent with ztpv6
Diffstat (limited to 'dhcpv4')
-rw-r--r-- | dhcpv4/ztpv4/ztp.go (renamed from dhcpv4/ztp/ztp.go) | 8 | ||||
-rw-r--r-- | dhcpv4/ztpv4/ztp_test.go (renamed from dhcpv4/ztp/ztp_test.go) | 4 |
2 files changed, 5 insertions, 7 deletions
diff --git a/dhcpv4/ztp/ztp.go b/dhcpv4/ztpv4/ztp.go index b899425..d8c507a 100644 --- a/dhcpv4/ztp/ztp.go +++ b/dhcpv4/ztpv4/ztp.go @@ -10,9 +10,7 @@ import ( // VendorData is optional data a particular vendor may or may not include // in the Vendor Class options. type VendorData struct { - VendorName string - Model string - Serial string + VendorName, Model, Serial string } var errVendorOptionMalformed = errors.New("malformed vendor option") @@ -22,7 +20,7 @@ var errVendorOptionMalformed = errors.New("malformed vendor option") func ParseVendorData(packet *dhcpv4.DHCPv4) (*VendorData, error) { opt := packet.GetOneOption(dhcpv4.OptionClassIdentifier) if opt == nil { - return nil, nil + return nil, errors.New("vendor options not found") } vc := opt.(*dhcpv4.OptClassIdentifier).Identifier vd := &VendorData{} @@ -76,5 +74,5 @@ func ParseVendorData(packet *dhcpv4.DHCPv4) (*VendorData, error) { } // We didn't match anything. - return nil, nil + return nil, errors.New("failed to parse vendor option data") } diff --git a/dhcpv4/ztp/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go index 15a9d26..c9c8d86 100644 --- a/dhcpv4/ztp/ztp_test.go +++ b/dhcpv4/ztpv4/ztp_test.go @@ -14,8 +14,8 @@ func TestParseV4VendorClass(t *testing.T) { want *VendorData fail bool }{ - {name: "empty"}, - {name: "unknownVendor", vc: "VendorX;BFR10K;XX12345"}, + {name: "empty", fail: true}, + {name: "unknownVendor", vc: "VendorX;BFR10K;XX12345", fail: true}, {name: "truncatedVendor", vc: "Arista;1234", fail: true}, { name: "arista", |