NAME
Net::BGPdump - Perl extension for libBGPdump
SYNOPSIS
use Net::BGPdump qw( :all );
my $io = Net::BGPdump->open($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 is a perl extension for libBGPdump, a C library designed to help with analyzing dump files produced by Zebra/Quagga or MRT.
The bgpdump library can be found here:
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 via the
:const
or:all
export tags, or individually.- type
- exclude_type
-
Include or exclude records of the following types:
BGPDUMP_TYPE_MRTD_BGP 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_BGP_NULL BGPDUMP_SUBTYPE_MRTD_BGP_UPDATE BGPDUMP_SUBTYPE_MRTD_BGP_PREFUPDATE BGPDUMP_SUBTYPE_MRTD_BGP_STATE_CHANGE BGPDUMP_SUBTYPE_MRTD_BGP_SYNC BGPDUMP_SUBTYPE_MRTD_BGP_OPEN BGPDUMP_SUBTYPE_MRTD_BGP_NOTIFICATION BGPDUMP_SUBTYPE_MRTD_BGP_KEEPALIVE BGPDUMP_SUBTYPE_MRTD_BGP_ROUT_REFRESH 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_TABLE_DUMP_V2_PEER_INDEX_TABLE BGPDUMP_SUBTYPE_TABLE_DUMP_V2_RIB_IPV4_UNICAST BGPDUMP_SUBTYPE_TABLE_DUMP_V2_RIB_IPV4_MULTICAST BGPDUMP_SUBTYPE_TABLE_DUMP_V2_RIB_IPV6_UNICAST BGPDUMP_SUBTYPE_TABLE_DUMP_V2_RIB_IPV6_MULTICAST BGPDUMP_SUBTYPE_TABLE_DUMP_V2_RIB_GENERIC BGPDUMP_PEERTYPE_TABLE_DUMP_V2_AFI_IP BGPDUMP_PEERTYPE_TABLE_DUMP_V2_AFI_IP6 BGPDUMP_PEERTYPE_TABLE_DUMP_V2_AS2 BGPDUMP_PEERTYPE_TABLE_DUMP_V2_AS4 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 BGP_MSG_ROUTE_REFRESH_01 BGP_MSG_ROUTE_REFRESH
- ipv6
-
Include or exclude records involving IPv6 using 1 or 0, respectively.
- close()
-
Close the
Net::BGPdump
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.
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.