1docs::api::APR::IpSubneUts(e3r)Contributed Perl Documentdaotciso:n:api::APR::IpSubnet(3)
2
3
4
6 APR::IpSubnet - Perl API for accessing APRs ip_subnet structures
7
9 use APR::IpSubnet ();
10
11 my $ipsub = APR::IpSubnet->new($pool, "127.0.0.1");
12 $ok = $ipsub->test($sock_addr);
13
15 "APR::IpSubnet" object represents a range of IP addresses (IPv4/IPv6).
16 A socket connection can be matched against this range to test whether
17 the IP it's coming from is inside or outside of this range.
18
20 "APR::IpSubnet" provides the following functions and/or methods:
21
22 "new"
23 Create an IP subnet represenation object
24
25 $ipsubnet = APR::IpSubnet->new($pool, $ip);
26 $ipsubnet = APR::IpSubnet->new($pool, $ip, $mask_or_numbits);
27
28 obj: "APR::IpSubnet" (class name)
29 arg1: $pool ( "APR::Pool object" )
30 arg2: $ip ( string )
31 IP address in one of the two formats: IPv4 (e.g. "127.0.0.1") or
32 IPv6 (e.g. "::1"). IPv6 addresses are accepted only if APR has the
33 IPv6 support enabled.
34
35 opt arg3: $mask_or_numbits ( string )
36 An optional IP mask (e.g. "255.0.0.0") or number of bits (e.g.
37 "15").
38
39 If none provided, the default is not to mask off.
40
41 ret: $ret ( "APR::IpSubnet object" )
42 The IP-subnet object
43
44 excpt: "APR::Error"
45 since: 2.0.00
46
47 "test"
48 Test the IP address in the socket address object against a pre-built
49 ip-subnet representation.
50
51 $ret = $ipsub->test($sockaddr);
52
53 obj: $ipsub ( "APR::IpSubnet object" )
54 The ip-subnet representation
55
56 arg1: $sockaddr ( "APR::SockAddr object" )
57 The socket address to test
58
59 ret: $ret ( boolean )
60 true if the socket address is within the subnet, false otherwise
61
62 since: 2.0.00
63
64 This method is used for testing whether or not an address is within a
65 subnet. It's used by module "mod_access" to check whether the client IP
66 fits into the IP range, supplied by "Allow"/"Deny" directives.
67
68 Example:
69
70 Allow accesses only from the localhost (IPv4):
71
72 use APR::IpSubnet ();
73 use Apache2::Connection ();
74 use Apache2::RequestRec ();
75 my $ipsub = APR::IpSubnet->new($r->pool, "127.0.0.1");
76 ok $ipsub->test($r->connection->remote_addr);
77
79 mod_perl 2.0 documentation.
80
82 mod_perl 2.0 and its core modules are copyrighted under The Apache
83 Software License, Version 2.0.
84
86 The mod_perl development team and numerous contributors.
87
88
89
90perl v5.10.1 2007-11-12 docs::api::APR::IpSubnet(3)