From a3fe5c3e5d5ec382767965eedf60cb38b79ae108 Mon Sep 17 00:00:00 2001 From: Hariharakumar Narasimhakumar Date: Thu, 26 Aug 2021 15:02:46 -0700 Subject: Adding support to parse vendor data for cisco firepower (#443) * Adding support to parse vendor data for cisco firepower --- dhcpv4/ztpv4/ztp.go | 9 +++++++++ dhcpv4/ztpv4/ztp_test.go | 10 ++++++++++ 2 files changed, 19 insertions(+) (limited to 'dhcpv4') diff --git a/dhcpv4/ztpv4/ztp.go b/dhcpv4/ztpv4/ztp.go index 43bc0e6..09ec790 100644 --- a/dhcpv4/ztpv4/ztp.go +++ b/dhcpv4/ztpv4/ztp.go @@ -65,6 +65,15 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) { vd.VendorName = p[0] return vd, nil + + // Cisco Firepower FPR4100/9300 models use Opt 60 for model info + // and Opt 61 contains the serial number + case vc == "FPR4100" || vc == "FPR9300": + vd.VendorName = iana.EntIDCiscoSystems.String() + vd.Model = vc + vd.Serial = dhcpv4.GetString(dhcpv4.OptionClientIdentifier, packet.Options) + return vd, nil + } return nil, nil diff --git a/dhcpv4/ztpv4/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go index d0b002f..a6781a1 100644 --- a/dhcpv4/ztpv4/ztp_test.go +++ b/dhcpv4/ztpv4/ztp_test.go @@ -12,6 +12,7 @@ func TestParseClassIdentifier(t *testing.T) { tt := []struct { name string vc, hostname string + ci []byte // Client Identifier want *VendorData fail bool }{ @@ -45,6 +46,12 @@ 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"}, + }, } for _, tc := range tt { @@ -60,6 +67,9 @@ func TestParseClassIdentifier(t *testing.T) { if tc.hostname != "" { packet.UpdateOption(dhcpv4.OptHostName(tc.hostname)) } + if tc.ci != nil { + packet.UpdateOption(dhcpv4.OptClientIdentifier(tc.ci)) + } vd, err := ParseVendorData(packet) if tc.fail { -- cgit v1.2.3