Skip to content

Commit ddd8a41

Browse files
authored
Merge pull request #540 from hrvach/master
Add ZTPv6 NVOS Support
2 parents bf3278a + 2f4c47f commit ddd8a41

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

dhcpv6/ztpv6/parse_vendor_options.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ func ParseVendorData(packet dhcpv6.DHCPv6) (*VendorData, error) {
7777
vd.Model = p[1]
7878
vd.Serial = p[2]
7979
return &vd, nil
80+
81+
// NVOS##MMM1234##MM1234X56ABC
82+
case strings.HasPrefix(d, "NVOS##"):
83+
p := strings.Split(d, "##")
84+
if len(p) < 3 {
85+
return nil, errVendorOptionMalformed
86+
}
87+
88+
vd.VendorName = p[0]
89+
vd.Model = p[1]
90+
vd.Serial = p[2]
91+
return &vd, nil
8092

8193
// For Ciena the class identifier (opt 60) is written in the following format:
8294
// {vendor iana code}-{product}-{type}

dhcpv6/ztpv6/parse_vendor_options_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
7272
{name: "unknownVendor", vc: "VendorX;BFR10K;XX12345", fail: true, want: nil},
7373
{name: "truncatedArista", vc: "Arista;1234", fail: true, want: nil},
7474
{name: "truncatedZPE", vc: "ZPESystems:1234", fail: true, want: nil},
75+
{name: "truncatedNVOS", vc: "NVOS##MMM1234", fail: true, want: nil},
7576
{
7677
name: "arista",
7778
vc: "Arista;DCS-7050S-64;01.23;JPE12345678",
@@ -80,8 +81,11 @@ func TestParseVendorDataWithVendorClass(t *testing.T) {
8081
name: "zpe",
8182
vc: "ZPESystems:NSC:001234567",
8283
want: &VendorData{VendorName: "ZPESystems", Model: "NSC", Serial: "001234567"},
83-
},
84-
{
84+
}, {
85+
name: "nvos",
86+
vc: "NVOS##MMM1234##MM1234X123456",
87+
want: &VendorData{VendorName: "NVOS", Model: "MMM1234", Serial: "MM1234X123456"},
88+
}, {
8589
name: "Ciena",
8690
vc: "1271-23422Z11-123",
8791
clientId: &dhcpv6.DUIDEN{

0 commit comments

Comments
 (0)