line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Works::Types; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
13
|
use strict; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
92
|
|
4
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
138
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
13
|
use Carp qw( confess ); |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
136
|
|
9
|
4
|
|
|
4
|
|
13
|
use Exporter qw( import ); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
85
|
|
10
|
4
|
|
|
4
|
|
15
|
use Scalar::Util (); |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
97
|
|
11
|
4
|
|
|
4
|
|
1697
|
use Sub::Quote qw( quote_sub ); |
|
4
|
|
|
|
|
36356
|
|
|
4
|
|
|
|
|
963
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
Int |
15
|
|
|
|
|
|
|
IPInt |
16
|
|
|
|
|
|
|
IPVersion |
17
|
|
|
|
|
|
|
PrefixLength |
18
|
|
|
|
|
|
|
NetWorksAddress |
19
|
|
|
|
|
|
|
PackedBinary |
20
|
|
|
|
|
|
|
Str |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
## no critic (ValuesAndExpressions::ProhibitImplicitNewlines, NamingConventions::Capitalization) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
my $t = quote_sub( |
26
|
|
|
|
|
|
|
q{ |
27
|
|
|
|
|
|
|
( defined $_[0] && !ref $_[0] && $_[0] =~ /^[0-9]+\z/ ) |
28
|
|
|
|
|
|
|
or Net::Works::Types::_confess( |
29
|
|
|
|
|
|
|
'%s is not a valid integer for an IP address', |
30
|
|
|
|
|
|
|
$_[0] |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
4
|
0
|
27
|
sub Int () { $t } |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
my $t = quote_sub( |
40
|
|
|
|
|
|
|
q{ |
41
|
|
|
|
|
|
|
( |
42
|
|
|
|
|
|
|
defined $_[0] && ( ( !ref $_[0] && $_[0] =~ /^[0-9]+\z/ ) |
43
|
|
|
|
|
|
|
|| ( Scalar::Util::blessed( $_[0] ) |
44
|
|
|
|
|
|
|
&& ( $_[0]->isa('Math::UInt128') || $_[0]->isa('Math::BigInt') ) ) |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
) |
47
|
|
|
|
|
|
|
or Net::Works::Types::_confess( |
48
|
|
|
|
|
|
|
'%s is not a valid integer for an IP address', |
49
|
|
|
|
|
|
|
defined $_[0] ? $_[0] : 'undef' |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
7
|
|
|
7
|
0
|
24
|
sub IPInt () { $t } |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
my $t = quote_sub( |
59
|
|
|
|
|
|
|
q{ |
60
|
|
|
|
|
|
|
( defined $_[0] && !ref $_[0] && ( $_[0] == 4 || $_[0] == 6 ) ) |
61
|
|
|
|
|
|
|
or Net::Works::Types::_confess( |
62
|
|
|
|
|
|
|
'%s is not a valid IP version (4 or 6)', |
63
|
|
|
|
|
|
|
defined $_[0] ? $_[0] : 'undef' |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
4
|
|
|
4
|
0
|
13
|
sub IPVersion () { $t } |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
my $t = quote_sub( |
73
|
|
|
|
|
|
|
q{ |
74
|
|
|
|
|
|
|
( !ref $_[0] && defined $_[0] && $_[0] =~ /^[0-9]+\z/ && $_[0] <= 128 ) |
75
|
|
|
|
|
|
|
or Net::Works::Types::_confess( |
76
|
|
|
|
|
|
|
'%s is not a valid IP network prefix length (0-128)', |
77
|
|
|
|
|
|
|
defined $_[0] ? $_[0] : 'undef' |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
3
|
0
|
7
|
sub PrefixLength () { $t } |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
my $t = quote_sub( |
87
|
|
|
|
|
|
|
q{ |
88
|
|
|
|
|
|
|
( Scalar::Util::blessed( $_[0] ) && $_[0]->isa('Net::Works::Address') ) |
89
|
|
|
|
|
|
|
or Net::Works::Types::_confess( |
90
|
|
|
|
|
|
|
'%s is not a Net::Works::Address object', |
91
|
|
|
|
|
|
|
$_[0] |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
6
|
|
|
6
|
0
|
17
|
sub NetWorksAddress () { $t } |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
{ |
100
|
|
|
|
|
|
|
my $t = quote_sub( |
101
|
|
|
|
|
|
|
q{ |
102
|
|
|
|
|
|
|
( defined $_[0] && !ref $_[0] ) |
103
|
|
|
|
|
|
|
or Net::Works::Types::_confess( '%s is not binary data', $_[0] ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
4
|
|
|
4
|
0
|
15
|
sub PackedBinary () { $t } |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
my $t = quote_sub( |
112
|
|
|
|
|
|
|
q{ |
113
|
|
|
|
|
|
|
( defined $_[0] && !ref $_[0] ) |
114
|
|
|
|
|
|
|
or Net::Works::Types::_confess( '%s is not a string', $_[0] ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
7
|
|
|
7
|
0
|
34
|
sub Str () { $t } |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
## use critic |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines, Variables::ProhibitPackageVars) |
123
|
|
|
|
|
|
|
sub _confess { |
124
|
32
|
|
|
32
|
|
735
|
local $Carp::Internal{__PACKAGE__} = 1; |
125
|
|
|
|
|
|
|
|
126
|
32
|
50
|
|
|
|
6369
|
confess sprintf( |
127
|
|
|
|
|
|
|
$_[0], |
128
|
|
|
|
|
|
|
defined $_[1] ? $_[1] : 'undef' |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
## use critic |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |