From b78ee6572930131da6072b325f71266ea87bcc95 Mon Sep 17 00:00:00 2001 From: Pablo Mazzini Date: Tue, 26 Oct 2021 09:13:03 +0100 Subject: [ztpv4] typo and NITs --- dhcpv4/ztpv4/ztp.go | 7 ++++--- dhcpv4/ztpv4/ztp_test.go | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dhcpv4/ztpv4/ztp.go b/dhcpv4/ztpv4/ztp.go index c57d958..af7c8f7 100644 --- a/dhcpv4/ztpv4/ztp.go +++ b/dhcpv4/ztpv4/ztp.go @@ -49,7 +49,7 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) { return vd, nil // Juniper option 60 parsing is a bit more nuanced. The following are all - // "valid" identifying stings for Juniper: + // "valid" identifying strings for Juniper: // Juniper-ptx1000-DD576 --- (serial in hostname option) // Juniper-qfx10002-361-DN817 -- (model has a dash in it!) @@ -70,11 +70,11 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) { return vd, nil // For Ciena the class identifier (opt 60) is written in the following format: - // {vendor iana code}-{product}-{type} + // {vendor iana code}-{product}-{type} // For Ciena the iana code is 1271 // The product type is a number that maps to a Ciena product // The type is used to identified different subtype of the product. - // An example can be ‘1271-23422Z11-123’. + // An example can be ‘1271-23422Z11-123’. case strings.HasPrefix(vc, strconv.Itoa(int(iana.EntIDCienaCorporation))): v := strings.Split(vc, "-") if len(v) != 3 { @@ -99,6 +99,7 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) { } return vd, nil } + return nil, nil } diff --git a/dhcpv4/ztpv4/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go index bee2230..5fa3f40 100644 --- a/dhcpv4/ztpv4/ztp_test.go +++ b/dhcpv4/ztpv4/ztp_test.go @@ -46,13 +46,6 @@ func TestParseClassIdentifier(t *testing.T) { vc: "ZPESystems:NSC:001234567", want: &VendorData{VendorName: "ZPESystems", Model: "NSC", Serial: "001234567"}, }, - { - name: "cisco", - vc: "FPR4100", - ci: []byte("JMX2525X0BW"), - want: &VendorData{VendorName: "Cisco Systems", Model: "FPR4100", Serial: "JMX2525X0BW"}, - }, - {name: "ciscoNoSerial", vc: "FPR4100", fail: true}, { name: "ciena", vc: "1271-00011E00-032", @@ -61,6 +54,13 @@ func TestParseClassIdentifier(t *testing.T) { }, {name: "cienaInvalidVendorClass", vc: "127100011E00032", fail: true}, {name: "cienaNoSerial", vc: "1271-00011E00-032", fail: true}, + { + name: "cisco", + vc: "FPR4100", + ci: []byte("JMX2525X0BW"), + want: &VendorData{VendorName: "Cisco Systems", Model: "FPR4100", Serial: "JMX2525X0BW"}, + }, + {name: "ciscoNoSerial", vc: "FPR4100", fail: true}, } for _, tc := range tt { -- cgit v1.2.3