line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::SPDY::Frame::Control; |
2
|
|
|
|
|
|
|
$Protocol::SPDY::Frame::Control::VERSION = '1.001'; |
3
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
98
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
87
|
|
5
|
3
|
|
|
3
|
|
18
|
use parent qw(Protocol::SPDY::Frame); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Protocol::SPDY::Frame::Control - control frame subclass for the SPDY protocol |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
version 1.001 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Support for control frames. Typically you'd interact with these through the top-level |
18
|
|
|
|
|
|
|
L object. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Subclass of L. See also L. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 TYPES |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The following control frame types are known: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * L |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item * L |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item * L |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * L |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * L |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * L |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * L |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=back |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
3
|
|
185
|
use Protocol::SPDY::Constants ':all'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1616
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 is_control |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This is a control frame, so it will return true. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
27
|
|
|
27
|
1
|
153
|
sub is_control { 1 } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 is_data |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This is not a data frame, so it returns false. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
16
|
|
|
16
|
1
|
61
|
sub is_data { 0 } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 version |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The version for this frame - probably 3. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub version { |
77
|
33
|
50
|
|
33
|
1
|
108
|
die "no version for $_[0]" unless $_[0]->{version}; |
78
|
33
|
|
|
|
|
140
|
shift->{version} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 type |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The numerical type for this frame. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
31
|
|
|
31
|
1
|
109
|
sub type { FRAME_TYPE_BY_NAME->{ shift->type_name } } |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 uni |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Unidirectional flag (if set, we expect no response from the other side). |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
25
|
|
|
25
|
1
|
117
|
sub uni { shift->{uni} } |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 compress |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The compression flag. Used on some frames. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
21
|
|
|
21
|
1
|
116
|
sub compress { shift->{compress} } |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 as_packet |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the byte representation for this frame. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub as_packet { |
112
|
21
|
|
|
21
|
1
|
28
|
my $self = shift; |
113
|
21
|
|
|
|
|
60
|
my %args = @_; |
114
|
21
|
|
|
|
|
42
|
my $len = length($args{payload}); |
115
|
21
|
50
|
|
|
|
69
|
my $pkt = pack 'n1n1C1n1C1', |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
116
|
|
|
|
|
|
|
($self->is_control ? 0x8000 : 0x0000) | ($self->version & 0x7FFF), |
117
|
|
|
|
|
|
|
$self->type, |
118
|
|
|
|
|
|
|
($self->fin ? FLAG_FIN : 0) | ($self->uni ? FLAG_UNI : 0) | ($self->compress ? FLAG_COMPRESS : 0), |
119
|
|
|
|
|
|
|
$len >> 8, |
120
|
|
|
|
|
|
|
$len & 0xFF; |
121
|
21
|
|
|
|
|
57
|
$pkt .= $args{payload}; |
122
|
21
|
|
|
|
|
139
|
return $pkt; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 pairs_to_nv_header |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns a name-value pair header block. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub pairs_to_nv_header { |
132
|
18
|
|
|
18
|
1
|
22
|
shift; |
133
|
18
|
|
|
|
|
34
|
my @hdr = @_; |
134
|
18
|
|
|
|
|
54
|
my $data = pack 'N1', @hdr / 2; |
135
|
18
|
|
|
|
|
235
|
$data .= pack '(N/A*)*', @hdr; |
136
|
18
|
|
|
|
|
56
|
return $data; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 find_class_for_type |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns the class appropriate for the given type (can be numerical |
142
|
|
|
|
|
|
|
or string representation). |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub find_class_for_type { |
147
|
34
|
|
|
34
|
1
|
35
|
shift; |
148
|
34
|
|
|
|
|
37
|
my $type = shift; |
149
|
34
|
100
|
|
|
|
198
|
my $name = exists FRAME_TYPE_BY_NAME->{$type} ? $type : FRAME_TYPE_BY_ID->{$type} or die "No class for $type"; |
|
|
50
|
|
|
|
|
|
150
|
34
|
|
|
|
|
121
|
return 'Protocol::SPDY::Frame::Control::' . $name; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 from_data |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Instantiates a frame from the given bytes. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub from_data { |
160
|
24
|
|
|
24
|
1
|
33
|
my $class = shift; |
161
|
24
|
|
|
|
|
129
|
my %args = @_; |
162
|
24
|
|
|
|
|
38
|
my $type = $args{type}; |
163
|
24
|
|
|
|
|
60
|
my $target_class = $class->find_class_for_type($type); |
164
|
24
|
|
|
|
|
150
|
return $target_class->from_data(%args); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 to_string |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
String representation for debugging. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub to_string { |
174
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
175
|
2
|
|
|
|
|
11
|
$self->SUPER::to_string . ', control'; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |