forked from jow-/oui-database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.pl
53 lines (42 loc) · 987 Bytes
/
update.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl
use strict;
use JSON;
if (open DB, "wget -O- 'https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf' |")
{
my @output;
while (defined(my $line = readline DB)) {
chomp $line;
next if ($line =~ m!\[TR\?\]! || $line =~ m!Please see MAM public listing for more information!);
if ($line =~ m!
^
([0-9A-F]{2}(?:[:-][0-9A-F]{2}){2,5})
(?:/([0-9]{1,2}))?
\t (\S+)
(?:
\s+ (.+?)
(?: \# .+ )?
)?
$
!x) {
my ($prefix, $mask, $company, $comment) = ($1, $2, $3, $4);
$prefix =~ s/[:-]//g;
$mask = defined($mask) ? int($mask) : length($prefix) * 4;
$prefix .= ('0' x (12 - length($prefix)));
$prefix =~ s/^0+([0-9A-F])/$1/g;
my $name = $comment || $company;
$name =~ s/\s+/ /g;
$name =~ s/^ //;
$name =~ s/ $//;
push @output,
$prefix,
$mask,
$name;
}
}
close DB;
if (open JSON, "> oui.json")
{
print JSON encode_json(\@output);
close JSON;
}
}