9 open(IN, "<", "usb.ids");
10 open(OUT, ">", "20-usb-vendor-model.hwdb");
11 print(OUT "# This file is part of systemd.\n" .
13 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
15 while (my $line = <IN>) {
17 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
22 print(OUT "usb:v" . $vendor . "*\n");
23 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
27 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
32 print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
33 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
46 open(IN, "<", "usb.ids");
47 open(OUT, ">", "20-usb-classes.hwdb");
48 print(OUT "# This file is part of systemd.\n" .
50 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
52 while (my $line = <IN>) {
55 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
58 if ($class =~ m/^00$/) {
63 print(OUT "usb:v*p*d*dc" . $class . "*\n");
64 print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
68 if (not defined $class) {
70 } elsif ($line =~ m/^$/) {
74 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
77 if ($subclass =~ m/^00$/) {
81 if ($text =~ m/^(\?|None|Unused)$/) {
85 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
86 print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
90 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
94 if ($text =~ m/^(\?|None|Unused)$/) {
98 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
99 print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
111 open(IN, "<", "pci.ids");
112 open(OUT, ">", "20-pci-vendor-model.hwdb");
113 print(OUT "# This file is part of systemd.\n" .
115 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
117 while (my $line = <IN>) {
119 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
125 print(OUT "pci:v0000" . $vendor . "*\n");
126 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
130 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
135 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
136 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
140 $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
142 my $sub_vendor = uc $1;
143 my $sub_device = uc $2;
146 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
147 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
160 open(IN, "<", "pci.ids");
161 open(OUT, ">", "20-pci-classes.hwdb");
162 print(OUT "# This file is part of systemd.\n" .
164 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
166 while (my $line = <IN>) {
169 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
174 print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
175 print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
179 if (not defined $class) {
181 } elsif ($line =~ m/^$/) {
185 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
190 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
191 print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
195 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
200 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
201 print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
211 my %iab_prefixes = ();
213 open(OUT, ">", "20-OUI.hwdb");
214 print(OUT "# This file is part of systemd.\n" .
216 "# Data imported from:\n" .
217 "# http://standards.ieee.org/develop/regauth/oui/oui.txt\n" .
218 "# http://standards.ieee.org/develop/regauth/iab/iab.txt\n");
220 open(IN, "<", "iab.txt");
221 while (my $line = <IN>) {
224 $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
226 $iab_prefix = $1 . $2 . $3;
227 $iab_prefixes{ $iab_prefix } = 1;
231 $line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
237 print(OUT "OUI:" . $iab_prefix . $vendor . "*\n");
238 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
243 open(IN, "<", "oui.txt");
244 while (my $line = <IN>) {
247 $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
252 # skip the IAB prefixes
253 if (! exists $iab_prefixes{ $vendor }) {
255 print(OUT "OUI:" . $vendor . "*\n");
256 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");