summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv4/ztpv4/ztp.go3
-rw-r--r--dhcpv4/ztpv4/ztp_test.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/dhcpv4/ztpv4/ztp.go b/dhcpv4/ztpv4/ztp.go
index 09ec790..ef8e13d 100644
--- a/dhcpv4/ztpv4/ztp.go
+++ b/dhcpv4/ztpv4/ztp.go
@@ -72,6 +72,9 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) {
vd.VendorName = iana.EntIDCiscoSystems.String()
vd.Model = vc
vd.Serial = dhcpv4.GetString(dhcpv4.OptionClientIdentifier, packet.Options)
+ if len(vd.Serial) == 0 {
+ return nil, errors.New("client identifier option is missing")
+ }
return vd, nil
}
diff --git a/dhcpv4/ztpv4/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go
index a6781a1..189ed3b 100644
--- a/dhcpv4/ztpv4/ztp_test.go
+++ b/dhcpv4/ztpv4/ztp_test.go
@@ -52,6 +52,7 @@ func TestParseClassIdentifier(t *testing.T) {
ci: []byte("JMX2525X0BW"),
want: &VendorData{VendorName: "Cisco Systems", Model: "FPR4100", Serial: "JMX2525X0BW"},
},
+ {name: "ciscoNoSerial", vc: "FPR4100", fail: true},
}
for _, tc := range tt {