line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: PPPoES.pm 4 2010-06-03 13:02:31Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::PPPoES; |
5
|
2
|
|
|
2
|
|
26764
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
89
|
|
6
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
116
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
2408
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
214191
|
|
|
2
|
|
|
|
|
658
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
consts => [qw( |
16
|
|
|
|
|
|
|
NF_PPPoE_HDR_LEN |
17
|
|
|
|
|
|
|
NF_PPPoE_PPP_PROTOCOL_IPv4 |
18
|
|
|
|
|
|
|
NF_PPPoE_PPP_PROTOCOL_PPPLCP |
19
|
|
|
|
|
|
|
)], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
22
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
36
|
use constant NF_PPPoE_HDR_LEN => 8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
114
|
|
26
|
2
|
|
|
2
|
|
10
|
use constant NF_PPPoE_PPP_PROTOCOL_IPv4 => 0x0021; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
27
|
2
|
|
|
2
|
|
10
|
use constant NF_PPPoE_PPP_PROTOCOL_PPPLCP => 0xc021; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1470
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @AS = qw( |
30
|
|
|
|
|
|
|
version |
31
|
|
|
|
|
|
|
type |
32
|
|
|
|
|
|
|
code |
33
|
|
|
|
|
|
|
sessionId |
34
|
|
|
|
|
|
|
payloadLength |
35
|
|
|
|
|
|
|
pppProtocol |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
38
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
require Bit::Vector; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
|
|
|
|
|
|
shift->SUPER::new( |
44
|
1
|
|
|
1
|
1
|
26
|
version => 1, |
45
|
|
|
|
|
|
|
type => 1, |
46
|
|
|
|
|
|
|
code => 0, |
47
|
|
|
|
|
|
|
sessionId => 1, |
48
|
|
|
|
|
|
|
payloadLength => 0, |
49
|
|
|
|
|
|
|
pppProtocol => NF_PPPoE_PPP_PROTOCOL_IPv4, |
50
|
|
|
|
|
|
|
@_, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
1
|
0
|
sub getLength { NF_PPPoE_HDR_LEN } |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
0
|
sub getPayloadLength { shift->payloadLength } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub pack { |
59
|
1
|
|
|
1
|
1
|
323
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
my $version = Bit::Vector->new_Dec(4, $self->version); |
62
|
1
|
|
|
|
|
58
|
my $type = Bit::Vector->new_Dec(4, $self->type); |
63
|
1
|
|
|
|
|
22
|
my $v8 = $version->Concat_List($type); |
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
14
|
$self->raw($self->SUPER::pack('CCnnn', |
66
|
|
|
|
|
|
|
$v8->to_Dec, |
67
|
|
|
|
|
|
|
$self->code, |
68
|
|
|
|
|
|
|
$self->sessionId, |
69
|
|
|
|
|
|
|
$self->payloadLength, |
70
|
|
|
|
|
|
|
$self->pppProtocol, |
71
|
|
|
|
|
|
|
)) or return undef; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
68
|
$self->raw; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub unpack { |
77
|
1
|
|
|
1
|
1
|
118
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
5
|
my ($versionType, $code, $sessionId, $payloadLength, $pppProtocol, $payload) |
80
|
|
|
|
|
|
|
= $self->SUPER::unpack('CCnnn a*', $self->raw) |
81
|
|
|
|
|
|
|
or return undef; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
43
|
my $v8 = Bit::Vector->new_Dec(8, $versionType); |
84
|
1
|
|
|
|
|
14
|
$self->version($v8->Chunk_Read(4, 0)); |
85
|
1
|
|
|
|
|
15
|
$self->type($v8->Chunk_Read(4, 4)); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
10
|
$self->code($code); |
88
|
1
|
|
|
|
|
10
|
$self->sessionId($sessionId); |
89
|
1
|
|
|
|
|
11
|
$self->payloadLength($payloadLength); |
90
|
1
|
|
|
|
|
10
|
$self->pppProtocol($pppProtocol); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
13
|
$self->payload($payload); |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
11
|
$self; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub encapsulate { |
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
return $self->nextLayer if $self->nextLayer; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $types = { |
103
|
|
|
|
|
|
|
NF_PPPoE_PPP_PROTOCOL_IPv4() => 'IPv4', |
104
|
|
|
|
|
|
|
NF_PPPoE_PPP_PROTOCOL_PPPLCP() => 'PPPLCP', |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
$types->{$self->pppProtocol} || NF_LAYER_UNKNOWN; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub print { |
111
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $l = $self->layer; |
114
|
0
|
|
|
|
|
|
sprintf "$l: version:%d type:%d code:0x%02x sessionId:0x%04x\n". |
115
|
|
|
|
|
|
|
"$l: payloadLength:%d pppProtocol:0x%04x", |
116
|
|
|
|
|
|
|
$self->version, |
117
|
|
|
|
|
|
|
$self->type, |
118
|
|
|
|
|
|
|
$self->code, |
119
|
|
|
|
|
|
|
$self->sessionId, |
120
|
|
|
|
|
|
|
$self->payloadLength, |
121
|
|
|
|
|
|
|
$self->pppProtocol, |
122
|
|
|
|
|
|
|
; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |