Device-Network-ConfigParser

 view release on metacpan or  search on metacpan

lib/Device/Network/ConfigParser/CheckPoint/Gaia.pm  view on Meta::CPAN

package Device::Network::ConfigParser::CheckPoint::Gaia;
# ABSTRACT: Parse CheckPoint Configuration
our $VERSION = '0.006'; # VERSION

use 5.006;
use strict;
use warnings;
use Modern::Perl;
use Parse::RecDescent;
use Data::Dumper;
use JSON;

use Exporter qw{import};

our @EXPORT_OK = qw{get_parser get_output_drivers parse_config post_process};

=head1 NAME

Device::Network::ConfigParser::CheckPoint::Gaia - parse CheckPoint Gaia configuration.

=head1 VERSION

version 0.006

=head1 SYNOPSIS

This module is intended to be used in conjunction with L<Device::Network::ConfigParser>, however there's nothing stopping it being used on its own.

The module provides subroutines to parse & post-process CheckPoint Gaia configuration, and output the structured data in a number of formats.

=head1 SUBROUTINES

=head2 get_parser

For more information on the subroutine, see L<Device::Network::ConfigParser/"get_parser">.

This module currently parses the following sections of Gaia config:

=over 4

=item * Static routes

=item * Interface configuration

=back

Any other lines within the file are classified as 'unrecognised'.

=cut

sub get_parser {
    return new Parse::RecDescent(q{
        <autoaction: { [@item] }>
        startrule: config_line(s) { $item[1] }
        config_line:
            interface { $item[1] } |
            static_route { $item[1] } |
            unrecognised { $item[1] }

        static_route: 'set static-route' destination (nexthop | comment) { { type => $item[0], config => { @{ $item[2] }, @{ $item[3]->[1] } } } }
            destination: m{((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{2})|default)} { [$item[0], $item[1]] }
            nexthop: 'nexthop' (nexthop_blackhole | nexthop_reject | nexthop_address | nexthop_interface) { [@{$item[2]->[1]}] }
            nexthop_blackhole: 'blackhole' { ['nexthop_type', $item[1]] }
            nexthop_reject: 'reject' { ['nexthop_type', $item[1]] }
            nexthop_address: 'gateway address' ipv4 m{on|off} { [nexthop_type => 'address', nexthop => $item[2]->[1], status => $item[3]] }
            nexthop_interface: 'gateway logical' interface_name m{on|off} { [nexthop_type => 'interface', nexthop => $item[2]->[1], status => $item[3]] }
            comment: 'comment' m{"[\w\s]+"} { [$item[0], $item[2]] }

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.504 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )