package Net::IP::Match::XS;

use 5.006001;
use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);

our @EXPORT = qw(

our $VERSION = '0.03';

require XSLoader;
XSLoader::load('Net::IP::Match::XS', $VERSION);



=head1 NAME

Net::IP::Match::XS - Efficiently match IP addresses against IP ranges with C.


  use Net::IP::Match::XS;
  my $match = match_ip( $ip_addr, $match_ip1, $match_ip2, ... );


Net::IP::Match::XS is based upon, and does the same thing as Net::IP::Match.
The unconditionally exported subroutine 'match_ip' determines if the
ip to match ( first argument ) matches any of the subsequent ip arguments.
Match arguments may be absolute quads, as '', or contain
mask bits as ''.
A true return value indicates a match. It was written in C, rather than
a macro, preprocessed
through Perl's source filter mechanism ( as is Net::IP::Match ), so that
the ip arguments could be traditional perl scalars. The C code is
lean and mean ( IMHO ).

=head2 Example in Apache/mod_perl

I use this module in my Apache server's mod_perl DB logging script to
determine if an incoming IP is 'remote' or 'local'. First, I set up
some variables in httpd.conf:

  PerlSetvar DBILogger_local_ips ''
  PerlAddvar DBILogger_local_ips ''
  PerlAddvar DBILogger_local_ips ''
  PerlAddvar DBILogger_local_ips ''
  PerlAddvar DBILogger_local_ips ''
  PerlAddvar DBILogger_local_ips ''

These are the ip addresses I want to be considered local. In the
mod_perl module:

  my @local_ips = $r->dir_config( "DBILogger_local_ips" );
  my $local = match_ip( $incoming_ip, @local_ips );

Now $local is just that, and I set the database key accordingly.

=head2 EXPORT

'match_ip', unconditionally.

=head1 SEE ALSO

L<Net::IP::Match> by Marcel GrE<uuml>nauer.

=head1 AUTHOR

Beau E. Cox, E<lt>beaucox@hawaii.rr.comE<gt>


Copyright (C) 2004 by Beau E. Cox

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.6.1 or,
at your option, any later version of Perl 5 you may have available.