#!/usr/bin/perl # # make /etc/protocols file from IANA web site. # © TiChou use strict; my $url = "http://www.iana.org/assignments/protocol-numbers"; my $ver = "1.1"; my $date = "2003/03/06"; use POSIX qw(strftime); open(IANA,"lynx -dump -dont_wrap_pre $url|") || die "Can't connect to www.iana.org : $!\n"; print "# /etc/protocols, version $ver $date TiChou # # See \"man 5 protocols\" for more information. # # The Internet protocol numbers definition file (updated ".(strftime "%Y/%m/%d", localtime).") # # This file is describes the various DARPA internet protocols that are available # from the TCP/IP subsystem. It should be consulted instead of using the numbers # in the ARPA include files, or, even worse, just guessing them. These numbers # will occur in the protocol field of any ip header. # # The latest IANA protocol numbers assignments can be found on : # # $url # # protocol number aliases comments "; my ($num,$num2,$proto,$comment,$ref); while () { if (/^\s+(\d+)(-\d+)?\s+(any .+|Unassigned|Reserved|\S+)\s+(.*\S)?\s*\[([^\[]+)\]\s*$/) { ($num,$num2,$proto,$comment,$ref) = ($1,$2,$3,$4,$5); if ($ref eq "IANA" && ($num2 || $proto =~ /^(any .+|Unassigned|Reserved)$/)) { print "#\t\t"; print " "x(3-length($num)); print "$num$num2\t\t\t# $proto\n"; } else { print "\L$proto\E"; print "\t"x(2-int(length($proto)/8)); print " "x(3-length($num)); print "$num\t$proto"; print "\t"x(2-int(length($proto)/8)); print "# $comment"; print "\n"; } } } print "# End of /etc/protocols.\n"; close(IANA);