"Fossies" - the Fresh Open Source Software Archive

Member "whois/make_ip6_del.pl" (27 Jul 2017, 767 Bytes) of package /linux/privat/whois_5.5.9.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "make_ip6_del.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl
    2 
    3 use warnings;
    4 use strict;
    5 
    6 while (<>) {
    7     chomp;
    8     s/#.*$//;
    9     s/^\s+//; s/\s+$//;
   10     next if /^$/;
   11 
   12     die "format error:\n$_\n"
   13         if not m#^([\da-fA-F]{4}):([\da-fA-F]{1,4})::/(\d+)\s+([\w\.]+)$#;
   14     my $len = $3; my $s = $4;
   15     my $i1 = $1; my $i2 = $2;
   16     my $net = (hex($i1) << 16) + hex $i2;
   17 
   18     if (0) { # just some code to help me visually aggregate networks
   19         my $bs = unpack('B32', pack('N', $net));
   20         $bs =~ s/(.{8})/$1 /g;
   21         print "${i1}:${i2}::/$len\t$bs $s\n";
   22         next;
   23     }
   24 
   25     print qq|{ ${net}UL, $len, "|;
   26     if ($s =~ /\./) {
   27         print $s;
   28     } elsif ($s eq '6to4') {
   29         print "\\x0A";
   30     } elsif ($s eq 'teredo') {
   31         print "\\x0B";
   32     } elsif ($s eq 'UNALLOCATED') {
   33         print "\\006";
   34     } else {
   35         print $s =~ /\./ ? $s : "whois.$s.net";
   36     }
   37     print qq|" },\n|;
   38 }
   39