1docs::api::APR::IpSubneUts(e3r)Contributed Perl Documentdaotciso:n:api::APR::IpSubnet(3)
2
3
4

NAME

6       APR::IpSubnet - Perl API for accessing APRs ip_subnet structures
7

Synopsis

9         use APR::IpSubnet ();
10
11         my $ipsub = APR::IpSubnet->new($pool, "127.0.0.1");
12         $ok = $ipsub->test($sock_addr);
13

Description

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

API

20       "APR::IpSubnet" provides the following functions and/or methods:
21
22       "new"
23
24       Create an IP subnet represenation object
25
26         $ipsubnet = APR::IpSubnet->new($pool, $ip);
27         $ipsubnet = APR::IpSubnet->new($pool, $ip, $mask_or_numbits);
28
29       obj: "APR::IpSubnet" (class name)
30       arg1: $pool ( "APR::Pool object" )
31       arg2: $ip ( string )
32           IP address in one of the two formats: IPv4 (e.g. "127.0.0.1") or
33           IPv6 (e.g. "::1"). IPv6 addresses are accepted only if APR has the
34           IPv6 support enabled.
35
36       opt arg3: $mask_or_numbits ( string )
37           An optional IP mask (e.g. "255.0.0.0") or number of bits (e.g.
38           "15").
39
40           If none provided, the default is not to mask off.
41
42       ret: $ret ( "APR::IpSubnet object" )
43           The IP-subnet object
44
45       excpt: "APR::Error"
46       since: 2.0.00
47
48       "test"
49
50       Test the IP address in the socket address object against a pre-built
51       ip-subnet representation.
52
53         $ret = $ipsub->test($sockaddr);
54
55       obj: $ipsub ( "APR::IpSubnet object" )
56           The ip-subnet representation
57
58       arg1: $sockaddr ( "APR::SockAddr object" )
59           The socket address to test
60
61       ret: $ret ( boolean )
62           true if the socket address is within the subnet, false otherwise
63
64       since: 2.0.00
65
66       This method is used for testing whether or not an address is within a
67       subnet. It's used by module "mod_access" to check whether the client IP
68       fits into the IP range, supplied by "Allow"/"Deny" directives.
69
70       Example:
71
72       Allow accesses only from the localhost (IPv4):
73
74         use APR::IpSubnet ();
75         use Apache2::Connection ();
76         use Apache2::RequestRec ();
77         my $ipsub = APR::IpSubnet->new($r->pool, "127.0.0.1");
78         ok $ipsub->test($r->connection->remote_addr);
79

See Also

81       mod_perl 2.0 documentation.
82
84       mod_perl 2.0 and its core modules are copyrighted under The Apache
85       Software License, Version 2.0.
86

Authors

88       The mod_perl development team and numerous contributors.
89
90
91
92perl v5.8.8                       2006-11-19       docs::api::APR::IpSubnet(3)
Impressum