summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
authorHariharakumar Narasimhakumar <hana8349@colorado.edu>2021-08-27 10:34:40 -0700
committerGitHub <noreply@github.com>2021-08-27 18:34:40 +0100
commitb95caade3eac806fa0f09a38d2ca991cf449b7b3 (patch)
tree815ea6a9a44b53531f5b67cf5c849da74c36a622 /dhcpv4
parent9bb7354278c1ab7d4ec1addf82ddb236a8857798 (diff)
[ztpv4][cisco firepower] Check to ensure serial number in Opt 61 is not empty (#444)
* Adding check for empty serial number in opt 61
Diffstat (limited to 'dhcpv4')
-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 {