BGPmon::Validate
This module provides a way to validate XML messages from a BGPmon source against the published XSD.
use BGPmon::Validate;
if(BGPmon::Validate::init()){
my $err_code = BGPmon::Validate::get_error_code('init'); my $err_msg = BGPmon::Validate::get_error_msg('init'); print "$err_code : $err_msg\n"; exit 1; }
my $xml_msg; #put your own xml message here
if(BGPmon::Validate::validate($xml_msg)){
my $err_code = BGPmon::Validate::get_error_code('validate'); my $err_msg = BGPmon::Validate::get_error_msg('validate'); print "$err_code : $err_msg\n"; exit 1; } else{ print "Message validated.\n";
}
init validate get_error_msg get_error_code
Loads the default or desired XSD for the module to use for validation. If a different XSD is to be used a later time, simply run init again to load the other XSD.
Input: The desired XSD (optional)
Output: 1 if there was an error loading the XSD 0 if there were no errors
Will check the XML message against the XSD loaded using BGPmon::Validate::init
Input: A BGPmon message in XML format
Output: 0 if the message validated 1 if an error has occured
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.
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.
Will return the schema validation error if one occurred.
Input:
Output: The error code form schema validation or undef is there was no error.
The following error codes and messages are defined: 0: There isn't an error. 'No Error. Relax with some tea.'; 690: The message given to validate was invalid. 'Invalid XML message was given.' 691: The XML message given to validate did not validate against the XSD. 'XML message did not validate.' 692: Either the XSD file did not exist or there was a problem loading the XSD. The error message will be dynamic. 693: The message passed to validate was not a proper XML message and could not be parsed. The error message will be dynamic.
M. Lawrence Weikum <mweikum at rams.colostate.edu>
<mweikum at rams.colostate.edu>
Please report any bugs or feature requeues to bgpmon at netsec.colostate.edu or through the web interface at http://bgpmon.netsec.colostate.edu.
bgpmon at netsec.colostate.edu
You can find documentation on this module with the perldoc command.
perldoc BGPmon::Validate
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: Validate.pm
Authors: M. Lawrence Weikum
Date: 13 August 2013
To install BGPmon::Validate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BGPmon::Validate
CPAN shell
perl -MCPAN -e shell install BGPmon::Validate
For more information on module installation, please visit the detailed CPAN module installation guide.