The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

BGPmon::Translator::XFB2PerlHash::Simple - a clean interface to extract commonly-used information from XFB messages.

SYNOPSIS

use BGPmon::Translator::XFB2PerlHash::Simple;

print get_error_msg('init') if !init('/XML/MESSAGE/TO/PARSE');

my $scalar_result = get_timestamp();

print $scalar_result;

my @array_result = get_nlri();

do_something() foreach my $nlri (@array_result)...

my $hash_ref_result = get_peering();

print $hash_ref_result-{'element'}-{'subelement'}-{'attribute'};

EXPORT

init get_timestamp get_dateTime get_nlri get_mp_nlri get_withdrawn get_mp_withdrawn get_peering get_origin get_as_path get_as4_path get_next_hop get_mp_next_hop get_xml_string get_error_code get_error_message get_error_msg get_xml_message_type get_status

SUBROUTINES/METHODS

init

This function takes an XML message to be translated and internally converts it to an appropriate data structure for querying.

   Input:      The message to be translated

   Output:     1 on success, 0 on failure

get_error_code

Get the error code

Input : the name of the function whose error code we should report

Output: the function's error code or NO_FUNCTION_SPECIFIED if the user did not supply a function or INVALID_FUNCTION_SPECIFIED if the user provided an invalid function

get_error_message

Get the error message

Input : the name of the function whose error message we should report

Output: the function's error message or NO_FUNCTION_SPECIFIED if the user did not supply a function or INVALID_FUNCTION_SPECIFIED if the user provided an invalid function

get_error_msg

Get the error message

This function is identical to get_error_message

get_timestamp

Returns the UNIX timestamp from an XFB message as a scalar.

get_dateTime

Returns the human-readable timestamp from an XFB message as a scalar.

get_xml_message_type

Returns the type of message we're seeing - if it's from a live stream or if it's from a RIB dump from a BGPmon source.

get_origin

Returns the stringified origin of the BGP message. Defined values are given in the XFB specification.

get_next_hop

Returns a scalar IPv4 address in dotted-decimal notation as given in the next hop attribute.

get_xml_string

Returns the raw XML string passed into init

get_status

Returns the status message in the XML if it exists

get_mp_next_hop

Returns an array of hashes with the next hop(s) from the MP_REACH attribute.

Ex: my @ret = get_mp_next_hop(); print my $addr-{'ADDRESS'}-{'content'} foreach $addr (@ret);

get_nlri

Returns an array of hashes. Each of these hashes are structured like so:

{ 'SAFI' = { 'value' = '1', 'content' = 'UNICAST' }, 'AFI' = { 'value' = '1', 'content' = 'IPV4' }, 'ADDRESS' = { 'content' = '192.168.0.0/16' }

}

get_withdrawn

Returns an array of hashes which contain an AFI,SAFI,and withdrawn IPv4 prefix. These hashes are structured just like the ones described in the documentation for get_nlri().

get_as_path

Returns an array of hashes that contains the AS path attribute of the message. Each hash represents a single AS Segment, which can be either an AS_SEQUENCE or AS_SET. Each AS_SEG has an AS subarray that contains the ASNs for that segment.

get_as4_path

Returns an array of hashes that contains the AS4_PATH attribute of the message. Each hash represents a single AS Segment, which can be either an AS_SEQUENCE or AS_SET. Each AS_SEG has an AS subarray that contains the ASNs for that segment.

get_mp_nlri

Returns an array of hashes which contain an AFI,SAFI,and announced prefix. These hashes are structured just like the ones described in the documentation for get_nlri().

get_mp_withdrawn

Returns an array of hashes which contain an AFI,SAFI,and withdrawn prefix. These hashes are structured just like the ones described in the documentation for get_nlri().

get_peering

Returns a hash reference that contains information about the BGP peering session that the message was received from. To see its contents, check the XFB specification or use Data::Dumper.

BUGS

Please report any bugs or feature requests to bgpmon at netsec.colostate.edu, or through the web interface at http://bgpmon.netsec.colostate.edu.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc BGPmon::Translator::XFB2PerlHash::Simple

LICENSE AND COPYRIGHT

Copyright (c) 2012 Colorado State University

    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use,
    copy, modify, merge, publish, distribute, sublicense, and/or
    sell copies of the Software, and to permit persons to whom
    the Software is furnished to do so, subject to the following
    conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.\

    File: Simple.pm

    Authors: M. Lawrence Weikum, Jason Bartlett
    Date: 13 October 2013