line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Extract::Net::MAC48; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
941
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
17
|
use re 'eval'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
555
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $charset = '0-9A-Fa-f'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $c = '['. $charset .']'; #character |
13
|
|
|
|
|
|
|
our $cc = $c.$c; #just shorthand |
14
|
|
|
|
|
|
|
our $cccc = $cc.$cc; #again shorthand |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#---------- Constructor ----------# |
17
|
|
|
|
|
|
|
sub new |
18
|
|
|
|
|
|
|
{ |
19
|
1
|
|
|
1
|
0
|
562
|
my ($pkgname) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
3
|
my ($instance) = {}; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
bless($instance, "Parse::Extract::Net::MAC48"); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
4
|
return $instance; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub extract |
29
|
|
|
|
|
|
|
{ |
30
|
12
|
|
|
12
|
0
|
2364
|
my $instance = shift; |
31
|
|
|
|
|
|
|
|
32
|
12
|
|
|
|
|
55
|
local($/); |
33
|
12
|
|
|
|
|
16
|
my $data = @_; |
34
|
|
|
|
|
|
|
|
35
|
12
|
|
|
|
|
14
|
my (@results); |
36
|
|
|
|
|
|
|
|
37
|
12
|
50
|
|
|
|
143
|
if( my @match = ( |
38
|
|
|
|
|
|
|
$data =~ / |
39
|
|
|
|
|
|
|
(?
|
40
|
|
|
|
|
|
|
(?: |
41
|
|
|
|
|
|
|
(?:($cc([:-]) $cc (?:\2$cc){4}){1}) | |
42
|
|
|
|
|
|
|
(?:($cccc(\.)$cccc\.$cccc){1}) |
43
|
|
|
|
|
|
|
) |
44
|
0
|
0
|
|
|
|
0
|
(??{ ($4 eq '.') ? '(?
|
45
|
0
|
0
|
|
|
|
0
|
(?!(??{ ($4 eq '.') ? '\.' : $2 })|$c) #collapse this to 1 eval |
46
|
|
|
|
|
|
|
/gcxo |
47
|
|
|
|
|
|
|
) ) |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
|
|
0
|
my $MAC = ''; |
50
|
0
|
|
|
|
|
0
|
my $delim = ''; |
51
|
0
|
|
|
|
|
0
|
while( scalar(@match) > 0 ) |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
0
|
|
|
|
0
|
if( defined($match[0]) ) |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
0
|
my $MAC = shift(@match); |
56
|
0
|
|
|
|
|
0
|
my $delim = shift(@match); |
57
|
0
|
|
|
|
|
0
|
splice(@match, 0, 2); |
58
|
0
|
0
|
|
|
|
0
|
if( $MAC =~ /[a-f]/ ) #to be configurable |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
|
|
0
|
$MAC = uc($MAC); #might be faster with a tr instead of m+uc? |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
0
|
|
|
0
|
if( defined $delim && $delim eq '-' ) #to be configurable |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
0
|
$MAC =~ tr/-/:/; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
0
|
push(@results, $MAC); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
|
|
0
|
splice(@match, 0, 2); |
72
|
0
|
|
|
|
|
0
|
my $MAC = shift(@match); |
73
|
0
|
|
|
|
|
0
|
my $delim = '.'; #shift(@match); |
74
|
0
|
|
|
|
|
0
|
shift(@match); |
75
|
0
|
|
|
|
|
0
|
push(@results, $MAC); |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
0
|
$MAC = ''; |
78
|
0
|
|
|
|
|
0
|
$delim = ''; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
12
|
|
|
|
|
51
|
return(@results); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |