diff options
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", |