1Net::IP::CMatch(3)    User Contributed Perl Documentation   Net::IP::CMatch(3)
2
3
4

NAME

6       Net::IP::CMatch - Efficiently match IP addresses against IP ranges with
7       C.
8

SYNOPSIS

10         use Net::IP::CMatch;
11         my $match = match_ip( $ip_addr, $match_ip1, $match_ip2, ... );
12

DESCRIPTION

14       Net::IP::CMatch is based upon, and does the same thing as
15       Net::IP::Match.  The unconditionally exported subroutine 'match_ip'
16       determines if the ip to match ( first argument ) matches any of the
17       subsequent ip arguments.  Match arguments may be absolute quads, as
18       '127.0.0.1', or contain mask bits as '111.245.76.248/29'.  A true
19       return value indicates a match. It was written in C, rather than a
20       macro, preprocessed through Perl's source filter mechanism ( as is
21       Net::IP::Match ), so that the ip arguments could be traditional perl
22       scalars. The C code is lean and mean ( IMHO ).
23
24       Example in Apache/mod_perl
25
26       I use this module in my Apache server's mod_perl DB logging script to
27       determine if an incoming IP is 'remote' or 'local'. First, I set up
28       some variables in httpd.conf:
29
30         PerlSetvar DBILogger_local_ips '222.234.52.192/29'
31         PerlAddvar DBILogger_local_ips '111.245.76.248/29'
32         PerlAddvar DBILogger_local_ips '10.0.0.0/24'
33         PerlAddvar DBILogger_local_ips '172.16.0.0/12'
34         PerlAddvar DBILogger_local_ips '192.168.0.0/16'
35         PerlAddvar DBILogger_local_ips '127.0.0.1'
36
37       These are the ip addresses I want to be considered local. In the
38       mod_perl module:
39
40         my @local_ips = $r->dir_config( "DBILogger_local_ips" );
41         my $local = match_ip( $incoming_ip, @local_ips );
42
43       Now $local is just that, and I set the database key accordingly.
44
45       EXPORT
46
47       'match_ip', unconditionally.
48

SEE ALSO

50       Net::IP::Match by Marcel Gruenauer.
51

AUTHOR

53       Beau E. Cox, <beaucox@hawaii.rr.com>
54
56       Copyright (C) 2004 by Beau E. Cox
57
58       This library is free software; you can redistribute it and/or modify it
59       under the same terms as Perl itself, either Perl version 5.6.1 or, at
60       your option, any later version of Perl 5 you may have available.
61
62
63
64perl v5.8.8                       2004-12-21                Net::IP::CMatch(3)
Impressum