2 # create the services file from
3 # http://www.iana.org/assignments/enterprise-numbers
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 2004 Gerald Combs
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 my $svc_file = "services";
29 my $min_size = 800000; # Size was 833397 on 2010-10-04
30 my @exclude_pats = qw(
36 $in = "http://www.iana.org/assignments/port-numbers" unless(defined $in);
40 if($in =~ m/^http:/i) {
41 eval "require LWP::UserAgent;";
42 die "LWP isn't installed. It is part of the standard Perl module libwww." if $@;
44 my $agent = LWP::UserAgent->new;
46 warn "starting to fetch $in ...\n";
48 my $request = HTTP::Request->new(GET => $in);
53 (undef,undef,undef,undef,undef,undef,undef,$min_size,undef,$mtime,undef,undef,undef) = stat($svc_file);
54 $request->if_modified_since( $mtime );
57 my $result = $agent->request($request);
59 if ($result->code eq 200) {
60 warn "done fetching $in\n";
61 my @in_lines = split /\n/, $result->content;
66 foreach $line (@in_lines) {
69 foreach $pat (@exclude_pats) {
77 $body .= "# Excluded by $PROGRAM_NAME\n";
84 $body .= $prefix . $line . "\n";
86 } elsif ($result->code eq 304) {
87 warn "$svc_file was up-to-date\n";
90 die "request for $in failed with result code:" . $result->code;
99 if (length($body) < $min_size * 0.9) {
100 die "$in doesn't have enough data\n";
103 open OUT, "> $svc_file";
105 print OUT <<"_SMINMPEC";
106 # This is a local copy of the IANA port-numbers file.
110 # Wireshark uses it to resolve port numbers into human readable
111 # service names, e.g. TCP port 80 -> http.
113 # It is subject to copyright and being used with IANA's permission:
114 # http://www.wireshark.org/lists/wireshark-dev/200708/msg00160.html
116 # The original file can be found at:
117 # http://www.iana.org/assignments/port-numbers