line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ipv4_networks; |
2
|
1
|
|
|
1
|
|
4640
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1548
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
7
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('all' => [ qw(new class_a class_b class_c)]); |
8
|
|
|
|
|
|
|
our @EXPORT_OK = (@{$EXPORT_TAGS{'all'}}); |
9
|
|
|
|
|
|
|
our @EXPORT = qw(); |
10
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
11
|
|
|
|
|
|
|
##################################################### |
12
|
|
|
|
|
|
|
my @network = qw - 128 192 224 240 248 252 254 255 -; |
13
|
|
|
|
|
|
|
my ($class, $this, @class_a, @class_b, @class_c); |
14
|
|
|
|
|
|
|
##################################################### |
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
0
|
|
0
|
0
|
|
$class = shift or die $!; |
17
|
0
|
|
|
|
|
|
$this = {}; |
18
|
0
|
|
|
|
|
|
bless $this, $class; |
19
|
0
|
|
|
|
|
|
return $this; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
##################################################### |
22
|
|
|
|
|
|
|
#Public |
23
|
|
|
|
|
|
|
sub class_a{ |
24
|
0
|
0
|
|
0
|
0
|
|
$this = shift or die $!; |
25
|
0
|
0
|
|
|
|
|
$this->{ip} = shift or die $!; |
26
|
0
|
|
|
|
|
|
foreach (@network){ |
27
|
0
|
|
|
|
|
|
secondo($_); |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
foreach (@network){ |
30
|
0
|
|
|
|
|
|
for (my$i=0; $i<256;$i++){ |
31
|
0
|
|
|
|
|
|
secondo_terzo($i,$_); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
foreach (@network){ |
35
|
0
|
|
|
|
|
|
for (my$i=0; $i<256;$i++){ |
36
|
0
|
|
|
|
|
|
for (my$i2=0; $i2<256;$i2++){ |
37
|
0
|
|
|
|
|
|
secondo_terzo_quarto($i,$i2,$_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
#no push and return, or memory problems. |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
#Public |
44
|
|
|
|
|
|
|
sub class_b{ |
45
|
0
|
|
|
0
|
0
|
|
$this = shift; |
46
|
0
|
0
|
|
|
|
|
$this->{ip} = shift or die $!; |
47
|
0
|
|
|
|
|
|
foreach (@network){ |
48
|
0
|
|
|
|
|
|
terzo($_); |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
foreach (@network){ |
51
|
0
|
|
|
|
|
|
for (my$i = 0; $i <256; $i++){ |
52
|
0
|
|
|
|
|
|
terzo_quarto($i,$_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return @class_b; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
#Public |
58
|
|
|
|
|
|
|
sub class_c{ |
59
|
0
|
|
|
0
|
0
|
|
$this = shift; |
60
|
0
|
0
|
|
|
|
|
$this->{ip} = shift or die $!; |
61
|
0
|
|
|
|
|
|
foreach (@network){ |
62
|
0
|
|
|
|
|
|
quarto($_); |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
return @class_c; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
################################################################################################## |
67
|
|
|
|
|
|
|
#Private |
68
|
|
|
|
|
|
|
sub secondo{ |
69
|
0
|
|
|
0
|
0
|
|
my$n = shift; |
70
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
71
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'secondo'); |
72
|
0
|
|
|
|
|
|
my$magic = 256; |
73
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
74
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
75
|
0
|
|
|
|
|
|
my$salto = 0; |
76
|
0
|
|
|
|
|
|
my$a = "$split[0]."; my$b = "$salto.0.0/$terminale"; |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
push @class_a, $a.$b; |
78
|
0
|
|
|
|
|
|
print $a.$b."\n"; |
79
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
80
|
0
|
|
|
|
|
|
my$c = "$split[0]."; my$d = $salto+=$blocchida; my$e = ".0.0/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
print $c.$d.$e."\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
#Private |
85
|
|
|
|
|
|
|
sub secondo_terzo{ |
86
|
0
|
|
|
0
|
0
|
|
my$first = shift; |
87
|
0
|
|
|
|
|
|
my$n = shift; |
88
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
89
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'terzo'); |
90
|
0
|
|
|
|
|
|
my$magic = 256; |
91
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
92
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
93
|
0
|
|
|
|
|
|
my$salto = 0; |
94
|
0
|
|
|
|
|
|
$a = "$split[0].$first.$salto.0/$terminale"; |
95
|
0
|
|
|
|
|
|
print $a."\n"; |
96
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
97
|
0
|
|
|
|
|
|
my$b = "$split[0]."; my$c = "$first."; my$d = $salto+=$blocchida; my$e = ".0/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
print $b.$c.$d.$e."\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
#Private |
103
|
|
|
|
|
|
|
sub secondo_terzo_quarto{ |
104
|
0
|
|
|
0
|
0
|
|
my$first = shift; |
105
|
0
|
|
|
|
|
|
my$second = shift; |
106
|
0
|
|
|
|
|
|
my$n = shift; |
107
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
108
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'quarto'); |
109
|
0
|
|
|
|
|
|
my$magic = 256; |
110
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
111
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
112
|
0
|
|
|
|
|
|
my$salto = 0; |
113
|
0
|
|
|
|
|
|
my$a = "$split[0].$first.$second.$salto/$terminale"; |
114
|
0
|
|
|
|
|
|
print $a."\n"; |
115
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
116
|
0
|
|
|
|
|
|
my$b = "$split[0]."; my$c = "$first.$second."; my$d = $salto+=$blocchida; my$e = "/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
print $b.$c.$d.$e."\n"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
#Private |
121
|
|
|
|
|
|
|
sub terzo{ |
122
|
0
|
|
|
0
|
0
|
|
my$n = shift; |
123
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
124
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'terzo'); |
125
|
0
|
|
|
|
|
|
my$magic = 256; |
126
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
127
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
128
|
0
|
|
|
|
|
|
my$salto = 0; |
129
|
0
|
|
|
|
|
|
my$a = "$split[0].$split[1]."; my$b = "$salto.0/$terminale"; |
|
0
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
push @class_b, $a.$b; |
131
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
132
|
0
|
|
|
|
|
|
my$c = "$split[0].$split[1]."; my$d = $salto+=$blocchida; my$e = ".0/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
push @class_b, $c.$d.$e; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
#Private |
137
|
|
|
|
|
|
|
sub terzo_quarto{ |
138
|
0
|
|
|
0
|
0
|
|
my$first = shift; |
139
|
0
|
|
|
|
|
|
my$n = shift; |
140
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
141
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'quarto'); |
142
|
0
|
|
|
|
|
|
my$magic = 256; |
143
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
144
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
145
|
0
|
|
|
|
|
|
my$salto = 0; |
146
|
0
|
|
|
|
|
|
my$a = "$split[0].$split[1].$first.$salto/$terminale"; |
147
|
0
|
|
|
|
|
|
push @class_b, $a; |
148
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
149
|
0
|
|
|
|
|
|
my$b = "$split[0].$split[1]."; my$c = "$first."; my$d = $salto+=$blocchida; my$e = "/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
push @class_b, $b.$c.$d.$e; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
#Private |
154
|
|
|
|
|
|
|
sub quarto { |
155
|
0
|
|
|
0
|
0
|
|
my$n = shift; |
156
|
0
|
|
|
|
|
|
my@split = split /\./, $this->{ip}; |
157
|
0
|
|
|
|
|
|
my$terminale = trasforma($n, 'quarto'); |
158
|
0
|
|
|
|
|
|
my$magic = 256; |
159
|
0
|
|
|
|
|
|
my$blocchida = $magic-$n; |
160
|
0
|
|
|
|
|
|
my$numeroblocchi = $magic/$blocchida; |
161
|
0
|
|
|
|
|
|
my$salto = 0; |
162
|
0
|
|
|
|
|
|
my$a = "$split[0].$split[1]."; $b = "$split[2].0/$terminale"; |
|
0
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
push @class_c, $a.$b; |
164
|
0
|
|
|
|
|
|
for (my$x = 1; $x<$numeroblocchi; $x++){ |
165
|
0
|
|
|
|
|
|
my$c = "$split[0].$split[1].$split[2]."; my$d = $salto+=$blocchida; my$e = "/$terminale"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
push @class_c, $c.$d.$e; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
#Private |
170
|
|
|
|
|
|
|
sub trasforma{ |
171
|
0
|
|
|
0
|
0
|
|
my$n = shift; |
172
|
0
|
|
|
|
|
|
my$metodo = shift; |
173
|
0
|
|
|
|
|
|
my $terminale; |
174
|
0
|
0
|
0
|
|
|
|
$terminale = 9 if $n == 128 and $metodo eq 'secondo'; |
175
|
0
|
0
|
0
|
|
|
|
$terminale = 10 if $n == 192 and $metodo eq 'secondo'; |
176
|
0
|
0
|
0
|
|
|
|
$terminale = 11 if $n == 224 and $metodo eq 'secondo'; |
177
|
0
|
0
|
0
|
|
|
|
$terminale = 12 if $n == 240 and $metodo eq 'secondo'; |
178
|
0
|
0
|
0
|
|
|
|
$terminale = 13 if $n == 248 and $metodo eq 'secondo'; |
179
|
0
|
0
|
0
|
|
|
|
$terminale = 14 if $n == 252 and $metodo eq 'secondo'; |
180
|
0
|
0
|
0
|
|
|
|
$terminale = 15 if $n == 254 and $metodo eq 'secondo'; |
181
|
0
|
0
|
0
|
|
|
|
$terminale = 16 if $n == 255 and $metodo eq 'secondo'; |
182
|
0
|
0
|
0
|
|
|
|
$terminale = 17 if $n == 128 and $metodo eq 'terzo'; |
183
|
0
|
0
|
0
|
|
|
|
$terminale = 18 if $n == 192 and $metodo eq 'terzo'; |
184
|
0
|
0
|
0
|
|
|
|
$terminale = 19 if $n == 224 and $metodo eq 'terzo'; |
185
|
0
|
0
|
0
|
|
|
|
$terminale = 20 if $n == 240 and $metodo eq 'terzo'; |
186
|
0
|
0
|
0
|
|
|
|
$terminale = 21 if $n == 248 and $metodo eq 'terzo'; |
187
|
0
|
0
|
0
|
|
|
|
$terminale = 22 if $n == 252 and $metodo eq 'terzo'; |
188
|
0
|
0
|
0
|
|
|
|
$terminale = 23 if $n == 254 and $metodo eq 'terzo'; |
189
|
0
|
0
|
0
|
|
|
|
$terminale = 24 if $n == 255 and $metodo eq 'terzo'; |
190
|
0
|
0
|
0
|
|
|
|
$terminale = 25 if $n == 128 and $metodo eq 'quarto'; |
191
|
0
|
0
|
0
|
|
|
|
$terminale = 26 if $n == 192 and $metodo eq 'quarto'; |
192
|
0
|
0
|
0
|
|
|
|
$terminale = 27 if $n == 224 and $metodo eq 'quarto'; |
193
|
0
|
0
|
0
|
|
|
|
$terminale = 28 if $n == 240 and $metodo eq 'quarto'; |
194
|
0
|
0
|
0
|
|
|
|
$terminale = 29 if $n == 248 and $metodo eq 'quarto'; |
195
|
0
|
0
|
0
|
|
|
|
$terminale = 30 if $n == 252 and $metodo eq 'quarto'; |
196
|
0
|
0
|
0
|
|
|
|
$terminale = 31 if $n == 254 and $metodo eq 'quarto'; |
197
|
0
|
0
|
0
|
|
|
|
$terminale = 32 if $n == 255 and $metodo eq 'quarto'; |
198
|
0
|
|
|
|
|
|
return $terminale; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
return 1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__ |