#!perl

=head1 NAME

suricata_ping - sends a ping out over the interfaces configured in a Suricata config

=head1 SYNOPSIS

suricata_ping -f <suricata config> [B<-p> <pattern>] [B<-i> <ip>] [B<-c> <count>] [B<-s> <section>]

suricata_ping -h/--help

suricata_ping -v/--version

=head1 DESCRIPTION

The purpose of send a ping packet on each interface being monitorined by suricata.

This can then be checked for further down the processing pipe for alerts to ensure
that everything is being processed as expected.

=head1 FLAGS

=head2 -f <suricata config>

This is the suricata config to read. This will include the configs in
.include .

This is a required flag.

=head2 -p <pattern>

The pattern to use with the ping.

default: e034o31qwe9034oldlAd31qdgf3

=head2 -i <ip>

The IP to send the ping request to.

default: 8.8.8.8

=cut

use strict;
use warnings;
use Getopt::Long   qw(GetOptions);
use Pod::Usage     qw( pod2usage );
use Suricata::Ping ();

sub main::VERSION_MESSAGE {
	print 'suricata_ping v. ' . $Suricata::Ping::VERSION . "\n";
}

sub main::HELP_MESSAGE {
	pod2usage( -exitval => 255, -verbose => 2, -output => \*STDOUT, );
}

my $help;
my $version;
my $config_file;
my $pattern;
my $ip;
my $section;
my $count;
Getopt::Long::Configure('no_ignore_case');
Getopt::Long::Configure('bundling');
GetOptions(
	'version' => \$version,
	'v'       => \$version,
	'help'    => \$help,
	'h'       => \$help,
	'f=s'     => \$config_file,
	'p=s'     => \$pattern,
	'i=s'     => \$ip,
	's=s'     => \$section,
	'c=s'     => \$count,
);

if ($version) {
	&VERSION_MESSAGE;
	exit 255;
}

if ($help) {
	&HELP_MESSAGE;
	exit 255;
}

my $suricata_ping = Suricata::Ping->new(
	config_file => $config_file,
	pattern     => $pattern,
	ip          => $ip,
	section     => $section,
	count       => $count,
);

$suricata_ping->ping;

exit 0;
