line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: RAW.pm,v ce68fbcc7f6d 2019/05/23 05:58:40 gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::RAW; |
5
|
2
|
|
|
2
|
|
4569
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
48
|
|
6
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
334
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
360
|
|
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
|
|
14
|
no strict 'vars'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
476
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub pack { |
23
|
1
|
|
|
1
|
1
|
194
|
my $self = shift; |
24
|
1
|
|
|
|
|
6
|
$self->[$__raw] = ''; |
25
|
1
|
|
|
|
|
3
|
$self->[$__raw]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub unpack { |
29
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
30
|
1
|
|
|
|
|
3
|
$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
|
|
|
|
5
|
return $self->[$__nextLayer] if $self->[$__nextLayer]; |
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
5
|
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
|
5
|
my $self = shift; |
60
|
1
|
|
|
|
|
10
|
my $l = $self->layer; |
61
|
1
|
|
|
|
|
42
|
"$l: empty"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |