.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "docs::api::APR::IpSubnet 3pm" .TH docs::api::APR::IpSubnet 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME APR::IpSubnet \- Perl API for accessing APRs ip_subnet structures .SH Synopsis .IX Header "Synopsis" .Vb 1 \& use APR::IpSubnet (); \& \& my $ipsub = APR::IpSubnet\->new($pool, "127.0.0.1"); \& $ok = $ipsub\->test($sock_addr); .Ve .SH Description .IX Header "Description" \&\f(CW\*(C`APR::IpSubnet\*(C'\fR object represents a range of IP addresses (IPv4/IPv6). A socket connection can be matched against this range to test whether the IP it's coming from is inside or outside of this range. .SH API .IX Header "API" \&\f(CW\*(C`APR::IpSubnet\*(C'\fR provides the following functions and/or methods: .ie n .SS """new""" .el .SS \f(CWnew\fP .IX Subsection "new" Create an IP subnet represenation object .PP .Vb 2 \& $ipsubnet = APR::IpSubnet\->new($pool, $ip); \& $ipsubnet = APR::IpSubnet\->new($pool, $ip, $mask_or_numbits); .Ve .ie n .IP "obj: ""APR::IpSubnet"" (class name)" 4 .el .IP "obj: \f(CWAPR::IpSubnet\fR (class name)" 4 .IX Item "obj: APR::IpSubnet (class name)" .PD 0 .ie n .IP "arg1: $pool ( ""APR::Pool object"" )" 4 .el .IP "arg1: \f(CW$pool\fR ( \f(CWAPR::Pool object\fR )" 4 .IX Item "arg1: $pool ( APR::Pool object )" .ie n .IP "arg2: $ip ( string )" 4 .el .IP "arg2: \f(CW$ip\fR ( string )" 4 .IX Item "arg2: $ip ( string )" .PD IP address in one of the two formats: IPv4 (e.g. \fI"127.0.0.1"\fR) or IPv6 (e.g. \fI"::1"\fR). IPv6 addresses are accepted only if APR has the IPv6 support enabled. .ie n .IP "opt arg3: $mask_or_numbits ( string )" 4 .el .IP "opt arg3: \f(CW$mask_or_numbits\fR ( string )" 4 .IX Item "opt arg3: $mask_or_numbits ( string )" An optional IP mask (e.g. \fI"255.0.0.0"\fR) or number of bits (e.g. \fI"15"\fR). .Sp If none provided, the default is not to mask off. .ie n .IP "ret: $ret ( ""APR::IpSubnet object"" )" 4 .el .IP "ret: \f(CW$ret\fR ( \f(CWAPR::IpSubnet object\fR )" 4 .IX Item "ret: $ret ( APR::IpSubnet object )" The IP-subnet object .ie n .IP "excpt: ""APR::Error""" 4 .el .IP "excpt: \f(CWAPR::Error\fR" 4 .IX Item "excpt: APR::Error" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """test""" .el .SS \f(CWtest\fP .IX Subsection "test" Test the IP address in the socket address object against a pre-built ip-subnet representation. .PP .Vb 1 \& $ret = $ipsub\->test($sockaddr); .Ve .ie n .IP "obj: $ipsub ( ""APR::IpSubnet object"" )" 4 .el .IP "obj: \f(CW$ipsub\fR ( \f(CWAPR::IpSubnet object\fR )" 4 .IX Item "obj: $ipsub ( APR::IpSubnet object )" The ip-subnet representation .ie n .IP "arg1: $sockaddr ( ""APR::SockAddr object"" )" 4 .el .IP "arg1: \f(CW$sockaddr\fR ( \f(CWAPR::SockAddr object\fR )" 4 .IX Item "arg1: $sockaddr ( APR::SockAddr object )" The socket address to test .ie n .IP "ret: $ret ( boolean )" 4 .el .IP "ret: \f(CW$ret\fR ( boolean )" 4 .IX Item "ret: $ret ( boolean )" true if the socket address is within the subnet, false otherwise .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP This method is used for testing whether or not an address is within a subnet. It's used by module \f(CW\*(C`mod_access\*(C'\fR to check whether the client IP fits into the IP range, supplied by \f(CW\*(C`Allow\*(C'\fR/\f(CW\*(C`Deny\*(C'\fR directives. .PP Example: .PP Allow accesses only from the localhost (IPv4): .PP .Vb 5 \& use APR::IpSubnet (); \& use Apache2::Connection (); \& use Apache2::RequestRec (); \& my $ipsub = APR::IpSubnet\->new($r\->pool, "127.0.0.1"); \& ok $ipsub\->test($r\->connection\->remote_addr); .Ve .SH "See Also" .IX Header "See Also" mod_perl 2.0 documentation. .SH Copyright .IX Header "Copyright" mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. .SH Authors .IX Header "Authors" The mod_perl development team and numerous contributors.