=pod

=head1 NAME

B<ipmatch> - a tool for checking if IP address belongs to a subnet

=head1 DESCRIPTION

This program checks if given IP address belongs to a particular subnet,
or if it is the nework, broadcast or host address. It's default
behavior is to output nothing and to set proper return value.

=head1 RETURN VALUES

=begin man

0 - IP was checked as being in range
.br
1 - syntax or usage error
.br
2 - IP was checked as being out of range

=end man

=head1 SYNOPSIS

B<ipmatch> [-r|-n|-h|-b] B<ip> B<network/netmask>

=head1 OPTIONS

  -r, --range          Check if IP address is in given range (default)
  -n, --network        Check if IP address is network address
  -h, --host           Check if IP address is a host address
  -b, --broadcast      Check if IP address is broadcast address

  -t, --text           Print text output (IN/OUT) - default: no output
      --help, --usage  Print this help

  network and netmask can be specified in one of these formats:
    a.b.c.d/prefix   (mask is not specified)
    a.b.c.d prefix
    a.b.c.d/e.f.g.h  (a.b.c.d is IP address, e.f.g.h is netmask)
    a.b.c.d e.f.g.h
    a.b.c.d          (netmask will be determined automatically)

=head1 OUTPUT

The program gives no output by default. Only in case I<-t> is given
as a paremeter, a simple string B<IN> or B<OUT> is being written.

In case of syntax or usage error, all output is written to I<stdout>.

=head1 EXAMPLES

B<$ ipmatch -t 192.168.1.1 192.168.1.0/24>

=begin man

.br
IN

=end man

B<$ ipmatch -t -n 192.168.1.1 192.168.1.0 255.255.255.0>

=begin man

.br
OUT

=end man

B<$ ipmatch -t -b 192.168.1.15 192.168.1.0/28>

=begin man

.br
IN

=end man

B<$ ipmatch -h 192.168.1.0 192.168.1.0/30 || echo "Not a host address">

=begin man

.br
Not a host address

=end man

B<$ ipmatch -n 192.168.0.0 192.168.0.0 && echo "A network address">

=begin man

.br
A network address

=end man

B<$ ipmatch -b 10.255.255.255 10.0.0.0; echo $?>

=begin man

.br
0

=end man

B<$ ipmatch -b 10.255.255.255 10.0.0.0/24; echo $?>

=begin man

.br
2

=end man

=head1 AUTHOR

=begin man

Written by C. McCohy <mccohy@kyberdigi.cz>
.br
See http://www.kyberdigi.cz/projects/ipinfo/ for more information.

=end man

=cut

