NAME

Net::BGPdump::IO - IO object for reading bgpdump files

SYNOPSIS

use Net::BGPdump qw( :const );
use Net::BGPdump::IO;

my $io = Net::BGPdump::IO->new($file, msgtype => BGP_MSG_UPDATE);

while (<$io>) {
  print "TIME: $_->{time}\n";
  print "TYPE: $_->{type}\n";
  printf("FROM: %s AS%d\n", $_->{from_addr}, $_->{from_as});
  printf("TO: %s AS%d\n", $_->{to_addr}, $_->{to_as});
  print "ORIGIN: $_->{origin}\n";
  print "ASPATH: $_->{as_path}\n";
  print "NEXT_HOP: $_->{next_hop}\n";
  if ($_->{announce}) {
    print "ANNOUNCE\n";
    for my $cidr (@{$_->{announce}}) {
      print "  $cidr\n";
    }
  }
  if ($_->{withdraw}) {
    print "WITHDRAW\n";
    for my $cidr (@{$_->{withdraw}}) {
      print "  $cidr\n";
    }
  }
}

DESCRIPTION

Net::PGPDump::IO is the interface for reading bgpdump files.

METHODS

The following methods are available to IO objects:

open($filename, %opts)

Opens a bgpdump file produced by Zebra/Quagga or MRT and returns a Net::BGPdump::IO object. Files can be uncompressed, gzip or bzip2. Use a filename of '-' for reading STDIN.

The following keyword filtering options are accepted. The constants used for these options are exported by Net::BGPdump.

type
exclude_type

Include or exclude records of the following types:

BGPDUMP_TYPE_MRTD_TABLE_DUMP
BGPDUMP_TYPE_TABLE_DUMP_V2
BGPDUMP_TYPE_ZEBRA_BGP
subtype
exclude_subtype

Include or exclude records of the following subtypes:

BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP6
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP6_32BIT_AS
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP_32BIT_AS
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP6
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP6_32BIT_AS
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP
BGPDUMP_SUBTYPE_MRTD_TABLE_DUMP_AFI_IP_32BIT_AS

BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE
BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_AS4
BGPDUMP_SUBTYPE_ZEBRA_BGP_STATE_CHANGE
BGPDUMP_SUBTYPE_ZEBRA_BGP_STATE_CHANGE_AS4
msgtype
exclude_msgtype

Include or exclude messages of the following types:

BGP_MSG_UPDATE
BGP_MSG_OPEN
BGP_MSG_NOTIFY
BGP_MSG_KEEPALIVE
ipv6

Include or exclude records involving IPv6 using 1 or 0, respectively.

close()

Close the IO object.

read()

Return the next record as a hash reference. Records are possibly subject to filtering as specified in the open() constructor.

closed()

Return whether or not the file has been closed.

eof()

Return whether or not the end of the file has been reached.

filename()

Return the filename this IO object is reading.

file_type()

Return the type of file this IO object has opened: 'uncompressed', 'bzip2', or 'gzip'.

records()

Return the total number of records read so far from the file.

parsed_fail()

Return the number of records that have failed to parse so far.

parsed_ok()

Return the number of records successfully poarsed so far.

OPERATORS

IO objects can be used as filehandles, so <$io> works as expected.

SEE ALSO

Net::BGPdump

COPYRIGHT & LICENSE

Copyright (C) 2015 by Carnegie Mellon University

Use of the Net-BGPdump library and related source code is subject to the terms of the following licenses:

GNU Public License (GPL) Rights pursuant to Version 2, June 1991 Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013

NO WARRANTY

See GPL.txt and LICENSE.txt for more details.