Advertisement
ajcorrea

flow-asn.pl

Jul 30th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.59 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use Net::Patricia;
  4. my $pt = new Net::Patricia;
  5.  
  6. # Origin prefixes by ASNs
  7.  
  8. print STDERR "Loading prefix file into memory... ";
  9. open (fil, "/netflow/tools/originas.txt");
  10. @db = <fil>;
  11. close(fil);
  12. print STDERR "done.\n";
  13.  
  14.  
  15. print STDERR "Creating data structure... ";
  16. foreach $rrow(@db) {
  17.     my ($rAS,$rnet, $rmask) = split(/\s+/, $rrow);
  18.     $pt->add_string("$rnet/$rmask", $rAS);
  19. }
  20.  
  21. print STDERR "done.\n";
  22.  
  23. while (<STDIN>) {
  24.   @row=split(",");
  25.  
  26.  
  27.   $row[22]=$pt->match_string($row[10]);
  28.   $row[23]=$pt->match_string($row[11]);
  29.     print join(",", @row) . "\n"
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement