2 # create the enterprises file from
3 # http://www.iana.org/assignments/enterprise-numbers
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 2004 Gerald Combs
9 # SPDX-License-Identifier: GPL-2.0-or-later
14 my ($vol, $script_dir) = File::Spec->splitpath( __FILE__ );
15 my $root_dir = File::Spec->catpath($vol, $script_dir, "..");
16 chdir($root_dir) || die("Can't find $root_dir");
20 $in = "http://www.iana.org/assignments/enterprise-numbers" unless(defined $in);
23 my $revision = '2014-04-27';
25 my $min_entries = 100;
28 if($in =~ m/^http:/i) {
29 eval "require LWP::UserAgent;";
30 die "LWP isn't installed. It is part of the standard Perl module libwww." if $@;
32 my $agent = LWP::UserAgent->new;
34 $agent->agent("Wireshark make-sminmpec.pl/$revision");
36 warn "starting to fetch $in ...\n";
38 my $request = HTTP::Request->new(GET => $in);
40 my $result = $agent->request($request);
42 if ($result->code eq 200) {
43 warn "done fetching $in\n";
44 @in_lines = split /\n/, $result->content;
46 die "request for $in failed with result code:" . $result->code;
57 my $last_updated = "(last updated ???)";
58 my $end_of_document = 0;
64 $code = sprintf("%d", $1);
65 } elsif (/^ ?(\S.*)/ ) { # up to three spaces because of formatting errors in the source
67 next if (/^\s*\(?\s*unassigned/i);
69 $name =~ s/ \((formerly .*)\)/\t# $1/;
70 $body .= "\n$code\t$name";
71 } elsif (/\(last updated/i) {
73 } elsif (/^ *End of Document/) {
78 die "\"End of Document\" not found. Truncated source file?" unless ($end_of_document);
80 open OUT, "> enterprises.tsv";
82 print OUT <<"_SMINMPEC";
84 # generated from http://www.iana.org/assignments/enterprise-numbers
85 # run "tools/make-sminmpec.pl [infile]" to regenerate
87 # The format used here is: <NUMERICAL_ID><SPACE><NAME>
88 # Where SPACE can be any sequence of spaces and tabs.