Skip to content

Commit

Permalink
Merge branch 'master' into fix_return_err_shadowing_by_nil
Browse files Browse the repository at this point in the history
  • Loading branch information
youngifif authored Jul 12, 2024
2 parents 02c4c2c + ddd8a41 commit 6f6f92a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions dhcpv6/ztpv6/parse_vendor_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ func ParseVendorData(packet dhcpv6.DHCPv6) (*VendorData, error) {
vd.Model = p[1]
vd.Serial = p[2]
return &vd, nil

// NVOS##MMM1234##MM1234X56ABC
case strings.HasPrefix(d, "NVOS##"):
p := strings.Split(d, "##")
if len(p) < 3 {
return nil, errVendorOptionMalformed
}

vd.VendorName = p[0]
vd.Model = p[1]
vd.Serial = p[2]
return &vd, nil

// For Ciena the class identifier (opt 60) is written in the following format:
// {vendor iana code}-{product}-{type}
Expand Down
8 changes: 6 additions & 2 deletions dhcpv6/ztpv6/parse_vendor_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
{name: "unknownVendor", vc: "VendorX;BFR10K;XX12345", fail: true, want: nil},
{name: "truncatedArista", vc: "Arista;1234", fail: true, want: nil},
{name: "truncatedZPE", vc: "ZPESystems:1234", fail: true, want: nil},
{name: "truncatedNVOS", vc: "NVOS##MMM1234", fail: true, want: nil},
{
name: "arista",
vc: "Arista;DCS-7050S-64;01.23;JPE12345678",
Expand All @@ -80,8 +81,11 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
name: "zpe",
vc: "ZPESystems:NSC:001234567",
want: &VendorData{VendorName: "ZPESystems", Model: "NSC", Serial: "001234567"},
},
{
}, {
name: "nvos",
vc: "NVOS##MMM1234##MM1234X123456",
want: &VendorData{VendorName: "NVOS", Model: "MMM1234", Serial: "MM1234X123456"},
}, {
name: "Ciena",
vc: "1271-23422Z11-123",
clientId: &dhcpv6.DUIDEN{
Expand Down

0 comments on commit 6f6f92a

Please sign in to comment.