M. Lawrence Weikum > BGPmon-core-1 > BGPmon::Translator::XFB2PerlHash::Simple

Download:
BGPmon-core-1-092.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 1.092   Source  

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_xml_message_type

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_timestamp

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

get_dateTime

Returns a human-readable, scalar version of the timestamp of an XFB message.

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_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_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_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.

get_origin

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

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 the 4-byte AS path, if present.

get_next_hop

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

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_xml_string

Returns the raw XML string passed into init

get_xml_message_type

Returns a string that contains the type of the BGP_MESSAGE.

Ex: my $type = get_xml_message_type();

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

AUTHOR ^

Jason Bartlett, <bartletj at cs.colostate.edu>

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: Jason Bartlett
    Date: 17 July 2012
syntax highlighting: