line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
123156
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
3
|
2
|
|
|
2
|
|
8301
|
use utf8; |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::IANA::Services; |
6
|
|
|
|
|
|
|
$Net::IANA::Services::VERSION = '0.004000'; |
7
|
|
|
|
|
|
|
BEGIN { |
8
|
2
|
|
|
2
|
|
166
|
$Net::IANA::Services::AUTHORITY = 'cpan:LESPEA'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#ABSTRACT: Makes working with named ip services easier |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Import needed modules |
15
|
2
|
|
|
2
|
|
1480
|
use YAML::Any qw/ LoadFile /; |
|
2
|
|
|
|
|
2171
|
|
|
2
|
|
|
|
|
13
|
|
16
|
2
|
|
|
2
|
|
10094
|
use File::ShareDir qw/ dist_file /; |
|
2
|
|
|
|
|
13256
|
|
|
2
|
|
|
|
|
281
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Export our vars/subs |
20
|
|
|
|
|
|
|
use Exporter::Easy ( |
21
|
2
|
|
|
|
|
25
|
TAGS => [ |
22
|
|
|
|
|
|
|
hashes => [qw( |
23
|
|
|
|
|
|
|
$IANA_HASH_INFO_FOR_SERVICE |
24
|
|
|
|
|
|
|
$IANA_HASH_PORTS_FOR_SERVICE |
25
|
|
|
|
|
|
|
$IANA_HASH_SERVICES_FOR_PORT |
26
|
|
|
|
|
|
|
$IANA_HASH_SERVICES_FOR_PORT_PROTO |
27
|
|
|
|
|
|
|
)], |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
regexes => [qw( |
30
|
|
|
|
|
|
|
$IANA_REGEX_PORTS |
31
|
|
|
|
|
|
|
$IANA_REGEX_PORTS_DCCP |
32
|
|
|
|
|
|
|
$IANA_REGEX_PORTS_SCTP |
33
|
|
|
|
|
|
|
$IANA_REGEX_PORTS_TCP |
34
|
|
|
|
|
|
|
$IANA_REGEX_PORTS_UDP |
35
|
|
|
|
|
|
|
$IANA_REGEX_SERVICES |
36
|
|
|
|
|
|
|
$IANA_REGEX_SERVICES_DCCP |
37
|
|
|
|
|
|
|
$IANA_REGEX_SERVICES_SCTP |
38
|
|
|
|
|
|
|
$IANA_REGEX_SERVICES_TCP |
39
|
|
|
|
|
|
|
$IANA_REGEX_SERVICES_UDP |
40
|
|
|
|
|
|
|
)], |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
subs => [qw( |
43
|
|
|
|
|
|
|
iana_has_port |
44
|
|
|
|
|
|
|
iana_has_service |
45
|
|
|
|
|
|
|
iana_info_for_port |
46
|
|
|
|
|
|
|
iana_info_for_service |
47
|
|
|
|
|
|
|
)], |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
all => [qw/ :hashes :regexes :subs /], |
50
|
|
|
|
|
|
|
], |
51
|
|
|
|
|
|
|
VARS => 1, |
52
|
2
|
|
|
2
|
|
1871
|
); |
|
2
|
|
|
|
|
3151
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Constants |
56
|
|
|
|
|
|
|
my $_HASHES_REF = LoadFile dist_file q{Net-IANA-Services}, q{services_hashes_dump.yml}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
##################### |
64
|
|
|
|
|
|
|
# Regex constants # |
65
|
|
|
|
|
|
|
##################### |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
our $IANA_REGEX_PORTS = qr{\b(?
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
our $IANA_REGEX_SERVICES = qr{\b(?
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
our $IANA_REGEX_PORTS_DCCP = qr{\b(?
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
our $IANA_REGEX_PORTS_SCTP = qr{\b(?
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
our $IANA_REGEX_PORTS_TCP = qr{\b(?
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
our $IANA_REGEX_PORTS_UDP = qr{\b(?
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
our $IANA_REGEX_SERVICES_DCCP = qr{\b(?
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
our $IANA_REGEX_SERVICES_SCTP = qr{\b(?
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
our $IANA_REGEX_SERVICES_TCP = qr{\b(?
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
our $IANA_REGEX_SERVICES_UDP = qr{\b(?
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#################### |
111
|
|
|
|
|
|
|
# Hash constants # |
112
|
|
|
|
|
|
|
#################### |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
our $IANA_HASH_INFO_FOR_SERVICE = $_HASHES_REF->{ q{service_info} }; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
our $IANA_HASH_SERVICES_FOR_PORT = $_HASHES_REF->{ q{port} }; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
our $IANA_HASH_SERVICES_FOR_PORT_PROTO = $_HASHES_REF->{ q{port_proto} }; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
our $IANA_HASH_PORTS_FOR_SERVICE = $_HASHES_REF->{ q{service} }; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
################# |
137
|
|
|
|
|
|
|
# Subroutines # |
138
|
|
|
|
|
|
|
################# |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub iana_has_port { |
143
|
8
|
|
|
8
|
1
|
41588
|
my ($port, $protocol) = @_; |
144
|
8
|
100
|
|
|
|
29
|
if (defined $protocol) { |
145
|
4
|
|
|
|
|
16
|
my $port_ref = $IANA_HASH_SERVICES_FOR_PORT_PROTO->{ $port }; |
146
|
4
|
50
|
|
|
|
29
|
if (defined $port_ref) { |
147
|
4
|
100
|
|
|
|
39
|
return $port_ref->{ $protocol } ? 1 : 0; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
else { |
150
|
0
|
|
|
|
|
0
|
return 0; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
else { |
154
|
4
|
100
|
|
|
|
31
|
return $IANA_HASH_SERVICES_FOR_PORT->{ $port } ? 1 : 0; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub iana_has_service { |
162
|
8
|
|
|
8
|
1
|
5993
|
my ($service, $protocol) = @_; |
163
|
8
|
100
|
|
|
|
32
|
if (defined $protocol) { |
164
|
4
|
|
|
|
|
15
|
my $serv_ref = $IANA_HASH_INFO_FOR_SERVICE->{ $service }; |
165
|
4
|
50
|
|
|
|
12
|
if (defined $serv_ref) { |
166
|
4
|
100
|
|
|
|
30
|
return $serv_ref->{ $protocol } ? 1 : 0; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
else { |
169
|
0
|
|
|
|
|
0
|
return 0; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
else { |
173
|
4
|
100
|
|
|
|
56
|
return $IANA_HASH_PORTS_FOR_SERVICE->{ $service } ? 1 : 0; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub iana_info_for_port { |
181
|
8
|
|
|
8
|
1
|
25
|
my ($port, $protocol) = @_; |
182
|
8
|
|
|
|
|
15
|
my $ret; |
183
|
8
|
100
|
|
|
|
33
|
if (defined $protocol) { |
184
|
4
|
|
|
|
|
15
|
my $port_ref = $IANA_HASH_SERVICES_FOR_PORT_PROTO->{ $port }; |
185
|
4
|
50
|
|
|
|
18
|
if (defined $port_ref) { |
186
|
4
|
|
|
|
|
14
|
$ret = $port_ref->{ $protocol }; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
else { |
190
|
4
|
|
|
|
|
242
|
$ret = $IANA_HASH_SERVICES_FOR_PORT->{ $port }; |
191
|
|
|
|
|
|
|
} |
192
|
8
|
100
|
|
|
|
26
|
if (defined $ret) { |
193
|
6
|
50
|
|
|
|
54
|
return wantarray ? @$ret : $ret; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
2
|
|
|
|
|
11
|
return; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub iana_info_for_service { |
204
|
8
|
|
|
8
|
1
|
22
|
my ($service, $protocol) = @_; |
205
|
8
|
|
|
|
|
28
|
my $serv_ref = $IANA_HASH_INFO_FOR_SERVICE->{ $service }; |
206
|
8
|
|
|
|
|
11
|
my $ret; |
207
|
8
|
100
|
|
|
|
51
|
if (defined $serv_ref) { |
208
|
7
|
100
|
|
|
|
42
|
$ret = defined $protocol ? $serv_ref->{ $protocol } : $serv_ref; |
209
|
|
|
|
|
|
|
} |
210
|
8
|
100
|
|
|
|
26
|
if (defined $ret) { |
211
|
6
|
50
|
|
|
|
73
|
return wantarray ? %$ret : $ret; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
else { |
214
|
2
|
|
|
|
|
11
|
return; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Happy ending |
222
|
|
|
|
|
|
|
1; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__END__ |