1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

hwdb: de-duplicate and sort OUI entries

Ignoring duplicate entry: 0001C8 = "THOMAS CONRAD CORP.", "CONRAD CORP."
Ignoring duplicate entry: 080030 = "NETWORK RESEARCH CORPORATION", "ROYAL MELBOURNE INST OF TECH"
Ignoring duplicate entry: 080030 = "NETWORK RESEARCH CORPORATION", "CERN"
→ we have two vendor prefixes with duplicate entries. For the first one,
there are two entries with what appear to be the same company. In the
second case, the same prefix is assigned to three different entities.
I arbitrarily chose to prefer the first entry.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-10-02 13:19:23 +02:00
parent 53d22844f0
commit e4804bdae6
2 changed files with 81851 additions and 81848 deletions

File diff suppressed because it is too large Load Diff

View File

@ -117,6 +117,12 @@ def header(file, *sources):
'\n# '.join(sources)),
file=file)
def add_item(items, key, value):
if key in items:
print(f'Ignoring duplicate entry: {key} = "{items[key]}", "{value}"')
else:
items[key] = value
def usb_vendor_model(p):
with open('20-usb-vendor-model.hwdb', 'wt') as out:
header(out, 'http://www.linux-usb.org/usb.ids')
@ -261,32 +267,38 @@ def sdio_classes(p):
# Medium MA-M 28/20 bit (OUI prefix owned by IEEE)
# Small MA-S 36/12 bit (OUI prefix owned by IEEE)
def oui(p1, p2, p3):
prefixes = set()
items = {}
for p, check in ((p1, False), (p2, False), (p3, True)):
for vendor_group in p.VENDORS:
prefix = vendor_group.prefix.upper()
if check:
if prefix in prefixes:
continue
else:
prefixes.add(prefix)
start = vendor_group.start.upper()
end = vendor_group.end.upper()
if end and start != end:
print(f'{prefix:} {start} != {end}', file=sys.stderr)
text = vendor_group.text.strip()
key = prefix + start if end else prefix
add_item(items, key, text)
with open('20-OUI.hwdb', 'wt') as out:
header(out,
'https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=txt',
'https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-M&format=txt',
'https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-S&format=txt')
prefixes = set()
for pattern in sorted(items):
print(f'',
f'OUI:{pattern}*',
f' ID_OUI_FROM_DATABASE={items[pattern]}', sep='\n', file=out)
for p, check in ((p1, False), (p2, False), (p3, True)):
for vendor_group in p.VENDORS:
prefix = vendor_group.prefix.upper()
if check:
if prefix in prefixes:
continue
else:
prefixes.add(prefix)
start = vendor_group.start.upper()
end = vendor_group.end.upper()
if end and start != end:
print(f'{prefix:} {start} != {end}', file=sys.stderr)
text = vendor_group.text.strip()
print(f'',
f'OUI:{prefix}{start if end else ""}*',
f' ID_OUI_FROM_DATABASE={text}', sep='\n', file=out)
print(f'Wrote {out.name}')
if __name__ == '__main__':