home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / IpSubnet.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  3.4 KB  |  175 lines

  1. # /*
  2. #  * *********** WARNING **************
  3. #  * This file generated by ModPerl::WrapXS/0.01
  4. #  * Any changes made here will be lost
  5. #  * ***********************************
  6. #  * 01: lib/ModPerl/Code.pm:701
  7. #  * 02: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:584
  8. #  * 03: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:1100
  9. #  * 04: Makefile.PL:335
  10. #  * 05: Makefile.PL:283
  11. #  * 06: Makefile.PL:51
  12. #  */
  13.  
  14.  
  15. package APR::IpSubnet;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20.  
  21. use APR ();
  22. use APR::XSLoader ();
  23. our $VERSION = '0.01';
  24. APR::XSLoader::load __PACKAGE__;
  25.  
  26.  
  27.  
  28. 1;
  29. __END__
  30.  
  31. =head1 NAME
  32.  
  33. APR::IpSubnet - Perl API for accessing APRs ip_subnet structures
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use APR::IpSubnet ();
  41.   
  42.   my $ipsub = APR::IpSubnet->new($pool, "127.0.0.1");
  43.   $ok = $ipsub->test($sock_addr);
  44.  
  45.  
  46.  
  47.  
  48.  
  49. =head1 Description
  50.  
  51. C<APR::IpSubnet> object represents a range of IP addresses
  52. (IPv4/IPv6). A socket connection can be matched against this range to
  53. test whether the IP it's coming from is inside or outside of this
  54. range.
  55.  
  56.  
  57.  
  58.  
  59. =head1 API
  60.  
  61. C<APR::IpSubnet> provides the following functions and/or methods:
  62.  
  63.  
  64.  
  65. =head2 C<new>
  66.  
  67. Create an IP subnet represenation object
  68.  
  69.   $ipsubnet = APR::IpSubnet->new($pool, $ip);
  70.   $ipsubnet = APR::IpSubnet->new($pool, $ip, $mask_or_numbits);
  71.  
  72. =over 4
  73.  
  74. =item obj: C<APR::IpSubnet> (class name)
  75.  
  76. =item arg1: C<$pool>
  77. ( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  78.  
  79. =item arg2: C<$ip> ( string )
  80.  
  81. IP address in one of the two formats: IPv4 (e.g. I<"127.0.0.1">) or
  82. IPv6 (e.g. I<"::1">). IPv6 addresses are accepted only if APR has the
  83. IPv6 support enabled.
  84.  
  85. =item opt arg3: C<$mask_or_numbits> ( string )
  86.  
  87. An optional IP mask (e.g. I<"255.0.0.0">) or number of bits
  88. (e.g. I<"15">).
  89.  
  90. If none provided, the default is not to mask off.
  91.  
  92. =item ret: C<$ret>
  93. ( C<L<APR::IpSubnet object|docs::2.0::api::APR::IpSubnet>> )
  94.  
  95. The IP-subnet object
  96.  
  97. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  98.  
  99. =item since: 1.99_15
  100.  
  101. =back
  102.  
  103.  
  104. =head2 C<test>
  105.  
  106. Test the IP address in the socket address object against a pre-built
  107. ip-subnet representation.
  108.  
  109.   $ret = $ipsub->test($sockaddr);
  110.  
  111. =over 4
  112.  
  113. =item obj: C<$ipsub>
  114. ( C<L<APR::IpSubnet object|docs::2.0::api::APR::IpSubnet>> )
  115.  
  116. The ip-subnet representation
  117.  
  118. =item arg1: C<$sockaddr>
  119. ( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )
  120.  
  121. The socket address to test
  122.  
  123. =item ret: C<$ret> ( boolean )
  124.  
  125. true if the socket address is within the subnet, false otherwise
  126.  
  127. =item since: 1.99_15
  128.  
  129. =back
  130.  
  131. This method is used for testing whether or not an address is within a
  132. subnet. It's used by module C<mod_access> to check whether the client
  133. IP fits into the IP range, supplied by C<Allow>/C<Deny> directives.
  134.  
  135. Example:
  136.  
  137. Allow accesses only from the localhost (IPv4):
  138.  
  139.   use APR::IpSubnet ();
  140.   use Apache::Connection ();
  141.   use Apache::RequestRec ();
  142.   my $ipsub = APR::IpSubnet->new($r->pool, "127.0.0.1");
  143.   ok $ipsub->test($r->connection->remote_addr);
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151. =head1 See Also
  152.  
  153. L<mod_perl 2.0 documentation|docs::2.0::index>.
  154.  
  155.  
  156.  
  157.  
  158. =head1 Copyright
  159.  
  160. mod_perl 2.0 and its core modules are copyrighted under
  161. The Apache Software License, Version 2.0.
  162.  
  163.  
  164.  
  165.  
  166. =head1 Authors
  167.  
  168. L<The mod_perl development team and numerous
  169. contributors|about::contributors::people>.
  170.  
  171. =cut
  172.  
  173.