line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: RAW.pm,v 7609c9d085d3 2018/03/15 15:17:19 gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::RAW; |
5
|
2
|
|
|
2
|
|
5077
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
48
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
362
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
391
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
11
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
14
|
|
|
|
|
|
|
consts => [], |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
17
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
17
|
no strict 'vars'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
479
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub pack { |
23
|
1
|
|
|
1
|
1
|
222
|
my $self = shift; |
24
|
1
|
|
|
|
|
7
|
$self->[$__raw] = ''; |
25
|
1
|
|
|
|
|
2
|
$self->[$__raw]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub unpack { |
29
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
30
|
1
|
|
|
|
|
2
|
$self->[$__payload] = $self->[$__raw]; |
31
|
1
|
|
|
|
|
2
|
$self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub encapsulate { |
35
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
4
|
return $self->[$__nextLayer] if $self->[$__nextLayer]; |
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
4
|
return NF_LAYER_NONE if ! $self->[$__payload]; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# With RAW layer, we must guess which type is the first layer |
42
|
0
|
|
|
|
|
0
|
my $payload = CORE::unpack('H*', $self->[$__payload]); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# XXX: may not work on big-endian arch |
45
|
0
|
0
|
|
|
|
0
|
if ($payload =~ /^4/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
return 'IPv4'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
elsif ($payload =~ /^6/) { |
49
|
0
|
|
|
|
|
0
|
return 'IPv6'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ($payload =~ /^0001....06/) { |
52
|
0
|
|
|
|
|
0
|
return 'ARP'; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
return NF_LAYER_UNKNOWN; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub print { |
59
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
60
|
1
|
|
|
|
|
9
|
my $l = $self->layer; |
61
|
1
|
|
|
|
|
40
|
"$l: empty"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |