.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "Net::Subnets 3pm" .TH Net::Subnets 3pm "2022-10-15" "perl v5.34.0" "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" Net::Subnets \- Computing Subnets In Large Scale Networks .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 8 \& use Net::Subnets; \& my $sn = Net::Subnets\->new; \& $sn\->subnets(\e@subnets); \& if (my $subnetref = $sn\->check(\e$address)) { \& ... \& } \& my ($lowipref, highipref) = $sn\->range(\e$subnet); \& my $listref = $sn\->list(\e($lowipref, $highipref)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Very fast matches large lists of \s-1IP\s0 addresses against many \s-1CIDR\s0 subnets and calculates \s-1IP\s0 address ranges. .PP This is a simple and efficient example for subnet matching: .PP .Vb 1 \& use Net::Subnets; \& \& my @subnets = qw(10.0.0.0/24 10.0.1.0/24); \& my @addresses = qw/10.0.0.1 10.0.1.2 10.0.3.1/; \& \& my $sn = Net::Subnets\->new; \& $sn\->subnets(\e@subnets); \& my $results; \& foreach my $address (@addresses) { \& if (my $subnetref = $sn\->check(\e$address)) { \& $results .= "$address: $$subnetref\en"; \& } \& else { \& $results .= "$address: not found\en"; \& } \& } \& print($results); .Ve .PP This is a simple example for range calculation: .PP .Vb 1 \& use Net::Subnets; \& \& my @subnets = qw(10.0.0.0/24 10.0.1.0/24); \& \& my $sn = Net::Subnets\->new; \& my $results; \& foreach my $subnet (@subnets) { \& my ($lowipref, $highipref) = $sn\->range(\e$subnet); \& $results .= "$subnet: $$lowipref \- $$highipref\en"; \& } \& print( $results ); .Ve .PP This is a simple example for list generation: .PP .Vb 1 \& use Net::Subnets; \& \& my $lowip = \*(Aq192.168.0.1\*(Aq; \& my $highip = \*(Aq192.168.0.100\*(Aq; \& \& my $sn = Net::Subnets\->new; \& my $listref = $sn\->list(\e($lowip, $highip)); \& foreach my $address (@$listref) { \& # do something cool \& } .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS """new""" .el .SS "\f(CWnew\fP" .IX Subsection "new" .Vb 1 \& my $subnets = Net::Subnets\->new; \& \& Creates an "Net::Subnets" object. .Ve .ie n .SS """subnets""" .el .SS "\f(CWsubnets\fP" .IX Subsection "subnets" .Vb 1 \& $subnets\->subnets([qw(10.0.0.0/24 10.0.1.0/24)]); \& \& The C method lets you prepare a list of CIDR subnets. .Ve .ie n .SS """check""" .el .SS "\f(CWcheck\fP" .IX Subsection "check" .Vb 1 \& my $match = $subnets\->check(\e$address); \& \& The C method lets you check an IP address against the previously \& prepared subnets. .Ve .ie n .SS """range""" .el .SS "\f(CWrange\fP" .IX Subsection "range" .Vb 1 \& my ($lowest, $highest) = $subnets\->range(\e$subnet) \& \& The C method lets you calculate the IP address range of a subnet. .Ve .ie n .SS """list""" .el .SS "\f(CWlist\fP" .IX Subsection "list" .Vb 1 \& my $list = $subnets\->list(\e$lowest, $highest); \& \& The C method lets you calculate a list containing all IP addresses \& in a given range. .Ve .SH "AUTHOR" .IX Header "AUTHOR" Sebastian Riedel (sri@cpan.org), Juergen Peters (juergen.peters@taulmarill.de) .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2003\-2010, Sebastian Riedel. .PP This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.