2005-12-09 15:46:09 +00:00
|
|
|
#!/usr/bin/perl -w
|
2017-06-24 13:25:41 +00:00
|
|
|
# create the enterprises file from
|
2005-07-24 03:36:21 +00:00
|
|
|
# http://www.iana.org/assignments/enterprise-numbers
|
|
|
|
#
|
2006-05-21 05:12:17 +00:00
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
2005-07-24 03:36:21 +00:00
|
|
|
# Copyright 2004 Gerald Combs
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2014-05-05 18:50:24 +00:00
|
|
|
|
2005-07-24 03:36:21 +00:00
|
|
|
use strict;
|
2014-04-27 20:26:17 +00:00
|
|
|
use File::Spec;
|
|
|
|
|
2017-06-24 13:25:41 +00:00
|
|
|
my ($vol, $script_dir) = File::Spec->splitpath( __FILE__ );
|
|
|
|
my $root_dir = File::Spec->catpath($vol, $script_dir, "..");
|
|
|
|
chdir($root_dir) || die("Can't find $root_dir");
|
2005-07-24 03:36:21 +00:00
|
|
|
|
|
|
|
my $in = shift;
|
|
|
|
|
2014-04-27 20:26:17 +00:00
|
|
|
$in = "http://www.iana.org/assignments/enterprise-numbers" unless(defined $in);
|
2006-09-07 16:16:51 +00:00
|
|
|
|
|
|
|
my @in_lines;
|
2014-04-27 20:26:17 +00:00
|
|
|
my $revision = '2014-04-27';
|
|
|
|
|
|
|
|
my $min_entries = 100;
|
|
|
|
my $smi_total = 0;
|
2006-09-07 16:16:51 +00:00
|
|
|
|
|
|
|
if($in =~ m/^http:/i) {
|
2006-09-07 22:38:16 +00:00
|
|
|
eval "require LWP::UserAgent;";
|
|
|
|
die "LWP isn't installed. It is part of the standard Perl module libwww." if $@;
|
2010-02-24 12:28:04 +00:00
|
|
|
|
2006-09-07 22:38:16 +00:00
|
|
|
my $agent = LWP::UserAgent->new;
|
2011-09-02 16:07:36 +00:00
|
|
|
$agent->env_proxy;
|
2014-04-27 20:26:17 +00:00
|
|
|
$agent->agent("Wireshark make-sminmpec.pl/$revision");
|
2006-09-07 22:38:16 +00:00
|
|
|
|
|
|
|
warn "starting to fetch $in ...\n";
|
2006-09-07 16:16:51 +00:00
|
|
|
|
2006-09-07 22:38:16 +00:00
|
|
|
my $request = HTTP::Request->new(GET => $in);
|
2006-09-07 16:16:51 +00:00
|
|
|
|
2006-09-07 22:38:16 +00:00
|
|
|
my $result = $agent->request($request);
|
|
|
|
|
|
|
|
if ($result->code eq 200) {
|
|
|
|
warn "done fetching $in\n";
|
|
|
|
@in_lines = split /\n/, $result->content;
|
|
|
|
} else {
|
|
|
|
die "request for $in failed with result code:" . $result->code;
|
|
|
|
}
|
2006-09-07 16:16:51 +00:00
|
|
|
} else {
|
|
|
|
open IN, "< $in";
|
|
|
|
@in_lines = <IN>;
|
|
|
|
close IN;
|
|
|
|
}
|
|
|
|
|
2005-07-24 03:36:21 +00:00
|
|
|
my $body = '';
|
|
|
|
my $code;
|
2017-06-24 13:25:41 +00:00
|
|
|
my $name;
|
|
|
|
my $last_updated = "(last updated ???)";
|
|
|
|
my $end_of_document = 0;
|
2010-09-23 18:48:19 +00:00
|
|
|
|
2006-09-07 16:16:51 +00:00
|
|
|
for(@in_lines) {
|
2017-06-24 13:25:41 +00:00
|
|
|
chomp;
|
2010-02-24 12:28:04 +00:00
|
|
|
|
2005-07-24 03:36:21 +00:00
|
|
|
if (/^(\d+)/) {
|
2017-06-24 13:25:41 +00:00
|
|
|
$code = sprintf("%d", $1);
|
|
|
|
} elsif (/^ ?(\S.*)/ ) { # up to three spaces because of formatting errors in the source
|
|
|
|
$name = $1;
|
|
|
|
next if (/^\s*\(?\s*unassigned/i);
|
|
|
|
$name =~ s/\s+$//;
|
|
|
|
$name =~ s/ \((formerly .*)\)/\t# $1/;
|
|
|
|
$body .= "\n$code\t$name";
|
|
|
|
} elsif (/\(last updated/i) {
|
|
|
|
$last_updated = $_;
|
|
|
|
} elsif (/^ *End of Document/) {
|
|
|
|
$end_of_document = 1;
|
2005-07-24 03:36:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-24 13:25:41 +00:00
|
|
|
die "\"End of Document\" not found. Truncated source file?" unless ($end_of_document);
|
2014-04-27 20:26:17 +00:00
|
|
|
|
2017-07-13 20:03:13 +00:00
|
|
|
open OUT, "> enterprises.tsv";
|
2014-04-27 20:26:17 +00:00
|
|
|
|
2005-07-24 03:36:21 +00:00
|
|
|
print OUT <<"_SMINMPEC";
|
2017-06-24 13:25:41 +00:00
|
|
|
#
|
|
|
|
# generated from http://www.iana.org/assignments/enterprise-numbers
|
|
|
|
# run "tools/make-sminmpec.pl [infile]" to regenerate
|
|
|
|
#
|
|
|
|
# $last_updated
|
|
|
|
$body
|
2005-07-24 03:36:21 +00:00
|
|
|
_SMINMPEC
|
|
|
|
|
|
|
|
close OUT;
|