From e347cd12d2c39ee2a2fdd4df1f951ad78f39518c Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Thu, 1 Aug 2024 17:19:12 -0400 Subject: [PATCH] remove deprecated iab registry; properly handle registry prefix lengths. Closes #6 --- oui/collect_csv.go | 2 +- oui/registry.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/oui/collect_csv.go b/oui/collect_csv.go index ea31d14..ce249a0 100644 --- a/oui/collect_csv.go +++ b/oui/collect_csv.go @@ -75,7 +75,7 @@ func ReadCSV(registry *Registry, fileName string, logger LoggerType) (results [] } assignment := strings.TrimSpace(row[1]) if !strings.Contains(assignment, "/") { - assignment += "/24" + assignment += fmt.Sprintf("/%d", registry.DefaultPrefixLen) } organization := row[2] org := strings.TrimSpace(organization) diff --git a/oui/registry.go b/oui/registry.go index 43bbbb8..b032660 100644 --- a/oui/registry.go +++ b/oui/registry.go @@ -14,10 +14,11 @@ const ( ) type Registry struct { - Name string - BaseURL string - FilePrefix string - FileExtension string + Name string + BaseURL string + FilePrefix string + FileExtension string + DefaultPrefixLen uint8 } func (reg *Registry) URL() *url.URL { @@ -39,10 +40,9 @@ func (reg *Registry) TempFilePattern() string { func Registries() []*Registry { return []*Registry{ - {Name: REGISTRY_OUI, BaseURL: "https://standards-oui.ieee.org/oui", FilePrefix: "oui", FileExtension: "csv"}, - {Name: REGISTRY_CID, BaseURL: "https://standards-oui.ieee.org/cid", FilePrefix: "cid", FileExtension: "csv"}, - {Name: REGISTRY_IAB, BaseURL: "https://standards-oui.ieee.org/iab", FilePrefix: "iab", FileExtension: "csv"}, - {Name: REGISTRY_OUI28, BaseURL: "https://standards-oui.ieee.org/oui28", FilePrefix: "mam", FileExtension: "csv"}, - {Name: REGISTRY_OUI36, BaseURL: "https://standards-oui.ieee.org/oui36", FilePrefix: "oui36", FileExtension: "csv"}, + {Name: REGISTRY_OUI, BaseURL: "https://standards-oui.ieee.org/oui", FilePrefix: "oui", FileExtension: "csv", DefaultPrefixLen: 24}, + {Name: REGISTRY_CID, BaseURL: "https://standards-oui.ieee.org/cid", FilePrefix: "cid", FileExtension: "csv", DefaultPrefixLen: 24}, + {Name: REGISTRY_OUI28, BaseURL: "https://standards-oui.ieee.org/oui28", FilePrefix: "mam", FileExtension: "csv", DefaultPrefixLen: 28}, + {Name: REGISTRY_OUI36, BaseURL: "https://standards-oui.ieee.org/oui36", FilePrefix: "oui36", FileExtension: "csv", DefaultPrefixLen: 36}, } }