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

NAME

BGPmon::Translator::XFB2PerlHash::Simpler - a cleaner interface to extract commonly-used information from XFB messages that, unline XFB2PerlHash::Simple, will ignore xml attributes.

SYNOPSIS

  use BGPmon::Translator::XFB2PerlHash::Simpler;

  my $xml_message = "...

  if(BGPmon::Translator::XFB2PerlHash::Simpler::parse_xml_msg($xml_message)){

    print BGPmon::Translator::SFB2PerlHash::get_error_msg('parse_xml_msg')."\n";

    exit 1;

  }

  my @withdrawn_prefixes = BGPmon::Translator::XFB2PerlHash::get_withdraw();

  foreach(@withdrawn_prefixes){

    ...

  }

  my $peer_address = BGPmon::Translator::XFB2PerlHash::extract_sender_addr();

  print "Seen at peer $peer_address\n";

EXPORT

get_error_msg get_error_code parse_xml_msg extract_sender_addr extract_sender_port extract_sender_asn extract_withdraw extract_nlri extract_mpreach_nlri extract_mpunreach_nlri extract_aspath extract_as4path extract_origin

SUBROUTINES/METHODS

get_error_msg

Will return the error message of the given function name.

Input: A string that contains the function name where an error occured.

Output: The message which represents the error stored from that function.

get_error_code

Will return the error code of the given function name.

Input: A string that represents the function name where an error occured.

Output: The code which represents the error stored from that function.

parse_xml_msg

Will translate an XML message from a string to a perl hash

Input: An XML string from a BGPmon source

Output: 0 if parsing completed successfully

extract_sender_addr

Will extract a sender's IP address from the parsed XML mesage.

Input: None

Output: IPv4/6 Address if successful; undef if not.

extract_sender_port

Will extract a sender's port number from the parsed XML mesage.

Input: None

Output: Port number if successful; undef if not.

extract_sender_asn

Will extract a sender's ASN number from the parsed XML mesage.

Input: None

Output: ASN number if successful; undef if not.

extract_withdraw

Will extract all the withdrawn prefixes from the parsed XML mesage.

Input: None

Output: Array of IPv4/6 prefixes that were seen to have been withdrawn.

extract_nlri

Will extract all the prefixes in NLRI areas from the parsed XML mesage.

Input: None

Output: Array of IPv4 prefixes that were seen in NLRIs.

extract_mpreach_nlri

Will extract all the IPv4/6 prefixes announced in MP_REACH_NLRI's from the parsed XML mesage. This will exclude the MP_REACH NEXT_HOP.

Input: None

Output: Array of IPv4/6 prefixes that were seen in MP_REACH_NLRI's

extract_mpunreach_nlri

Will extract all the IPv4/6 prefixes withdrawn in MP_UNREACH_NLRI's from the parsed XML mesage.

Input: None

Output: Array of IPv4/6 prefixes that were seen in MP_UNREACH_NLRI's

extract_aspath

Will extract all the ASNs found in either AS_PATH/AS_SET or AS_PATH/AS_SEQUENCE from the parsed XML mesage.

Input: None

Output: Array of ASNs found in the AS_PATH path attribute.

extract_as4path

Will extract all the ASNs found in either AS4_PATH/AS_SET or AS4_PATH/AS_SEQUENCE from the parsed XML mesage.

Input: None

Output: Array of ASNs found in the AS4_PATH path attribute.

extract_origin

Will extract the ASN where the message was announced from within the parsed XML mesage.

Input: None

Output: The ASN of the origin AS; undef if there is none.

ERROR CODES AND MESSAGES

The following error codes and messages are defined:

0: There isn't an error. 'No Error. Relax with some tea.'

200: Run parse_xml_message first. "There was no XML message given."

201: Invalid xml message given "The XML message given was blank."

AUTHOR

M. Lawrence Weikum <mweikum at rams.colostate.edu>

BUGS

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

SUPPORT

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

perldoc BGPmon::Filter

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: Simpler.pm
  Authors: M. Lawrence Weikum
  Date: 13 October 2013