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