/src/PcapPlusPlus/Packet++/src/QuicLayer.cpp
Line | Count | Source |
1 | | #include "QuicLayer.h" |
2 | | #include "PayloadLayer.h" |
3 | | #include "GeneralUtils.h" |
4 | | #include "SystemUtils.h" |
5 | | #include <algorithm> |
6 | | #include <cstring> |
7 | | |
8 | | namespace pcpp |
9 | | { |
10 | | QuicV1Layer* QuicV1Layer::parseQuicLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) |
11 | 0 | { |
12 | 0 | if (data == nullptr || dataLen <= sizeof(quic_common_header)) |
13 | 0 | { |
14 | 0 | return nullptr; |
15 | 0 | } |
16 | | |
17 | 0 | auto headerForm = static_cast<QuicHeaderForm>(reinterpret_cast<quic_common_header*>(data)->headerForm); |
18 | |
|
19 | 0 | if (headerForm == QuicHeaderForm::ShortHeader && QuicV1OneRttLayer::isDataValid(data, dataLen)) |
20 | 0 | { |
21 | 0 | return new QuicV1OneRttLayer(data, dataLen, prevLayer, packet); |
22 | 0 | } |
23 | | |
24 | 0 | if (headerForm == QuicHeaderForm::LongHeader && QuicV1LongHeaderLayer::isDataValid(data, dataLen)) |
25 | 0 | { |
26 | 0 | auto header = reinterpret_cast<quic_long_header*>(data); |
27 | 0 | if (header->version == 0x00000000) |
28 | 0 | { |
29 | 0 | return new QuicV1VersionNegotiationLayer(data, dataLen, prevLayer, packet); |
30 | 0 | } |
31 | 0 | if (netToHost32(header->version) != 0x00000001) |
32 | 0 | { |
33 | 0 | return nullptr; |
34 | 0 | } |
35 | | |
36 | 0 | switch (header->longPacketType) |
37 | 0 | { |
38 | 0 | case static_cast<uint8_t>(QuicPacketType::Initial): |
39 | 0 | { |
40 | 0 | return new QuicV1InitialLayer(data, dataLen, prevLayer, packet); |
41 | 0 | } |
42 | 0 | case static_cast<uint8_t>(QuicPacketType::Handshake): |
43 | 0 | { |
44 | 0 | return new QuicV1HandshakeLayer(data, dataLen, prevLayer, packet); |
45 | 0 | } |
46 | 0 | case static_cast<uint8_t>(QuicPacketType::ZeroRTT): |
47 | 0 | { |
48 | 0 | return new QuicV1ZeroRttLayer(data, dataLen, prevLayer, packet); |
49 | 0 | } |
50 | 0 | default: // QuicPacketType::Retry |
51 | 0 | { |
52 | 0 | return new QuicV1RetryLayer(data, dataLen, prevLayer, packet); |
53 | 0 | } |
54 | 0 | } |
55 | 0 | } |
56 | | |
57 | 0 | return nullptr; |
58 | 0 | } |
59 | | |
60 | | void QuicV1Layer::parseNextLayer() |
61 | 0 | { |
62 | 0 | auto headerLen = getHeaderLen(); |
63 | |
|
64 | 0 | if (headerLen < m_DataLen) |
65 | 0 | { |
66 | 0 | tryConstructNextLayerFromFactoryWithFallback<PayloadLayer>(parseQuicLayer, m_Data + headerLen, |
67 | 0 | m_DataLen - headerLen); |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | | QuicV1Layer::QuicHeaderForm QuicV1Layer::getHeaderForm() const |
72 | 0 | { |
73 | 0 | return static_cast<QuicHeaderForm>(getCommonHeader()->headerForm); |
74 | 0 | } |
75 | | |
76 | | uint8_t QuicV1Layer::getFixedBit() const |
77 | 0 | { |
78 | 0 | return getCommonHeader()->fixedBit; |
79 | 0 | } |
80 | | |
81 | | static constexpr const char* quicPacketTypeToString(QuicV1Layer::QuicPacketType packetType) |
82 | 0 | { |
83 | 0 | switch (packetType) |
84 | 0 | { |
85 | 0 | case QuicV1Layer::QuicPacketType::Initial: |
86 | 0 | return "Initial"; |
87 | 0 | case QuicV1Layer::QuicPacketType::Handshake: |
88 | 0 | return "Handshake"; |
89 | 0 | case QuicV1Layer::QuicPacketType::ZeroRTT: |
90 | 0 | return "0-RTT"; |
91 | 0 | case QuicV1Layer::QuicPacketType::Retry: |
92 | 0 | return "Retry"; |
93 | 0 | case QuicV1Layer::QuicPacketType::OneRtt: |
94 | 0 | return "1-RTT"; |
95 | 0 | default: // QuicPacketType::VersionNegotiation |
96 | 0 | return "Version Negotiation"; |
97 | 0 | } |
98 | 0 | } |
99 | | |
100 | | std::string QuicV1Layer::toString() const |
101 | 0 | { |
102 | 0 | return std::string("QUIC v1 Layer, ") + quicPacketTypeToString(getPacketType()) + " message"; |
103 | 0 | } |
104 | | |
105 | | const FieldDescriptor QuicV1Layer::SerializedFields::PacketType{ Layer::SerializedFields::MaxID + 1, "packetType" }; |
106 | | const FieldDescriptor QuicV1Layer::SerializedFields::HeaderForm{ Layer::SerializedFields::MaxID + 2, "headerForm" }; |
107 | | const FieldDescriptor QuicV1Layer::SerializedFields::FixedBit{ Layer::SerializedFields::MaxID + 3, "fixedBit" }; |
108 | | |
109 | | void QuicV1Layer::serializeLayer(ObjectScope& serializer) const |
110 | 0 | { |
111 | 0 | serializer.writeField(SerializedFields::PacketType, quicPacketTypeToString(getPacketType())); |
112 | 0 | serializer.writeField(SerializedFields::HeaderForm, |
113 | 0 | getHeaderForm() == QuicHeaderForm::LongHeader ? "Long" : "Short"); |
114 | 0 | serializer.writeField(SerializedFields::FixedBit, getFixedBit() != 0); |
115 | 0 | } |
116 | | |
117 | | bool QuicV1LongHeaderLayer::isDataValid(const uint8_t* data, size_t dataLen) |
118 | 0 | { |
119 | 0 | return data != nullptr && dataLen >= sizeof(quic_long_header); |
120 | 0 | } |
121 | | |
122 | | QuicV1Layer::QuicPacketType QuicV1LongHeaderLayer::getPacketType() const |
123 | 0 | { |
124 | 0 | return static_cast<QuicPacketType>(getLongHeader()->longPacketType); |
125 | 0 | } |
126 | | |
127 | | uint32_t QuicV1LongHeaderLayer::getVersion() const |
128 | 0 | { |
129 | 0 | return netToHost32(getLongHeader()->version); |
130 | 0 | } |
131 | | |
132 | | constexpr int QuicV1LongHeaderLayer::destinationConnectionIdOffset; |
133 | | |
134 | | QuicV1LongHeaderLayer::OffsetAndLength QuicV1LongHeaderLayer::getDestConIdOffsetAndLength() const |
135 | 0 | { |
136 | 0 | if (m_DataLen <= destinationConnectionIdOffset) |
137 | 0 | { |
138 | 0 | throw std::out_of_range("Not enough data to read destination connection ID length"); |
139 | 0 | } |
140 | | |
141 | 0 | auto length = static_cast<size_t>(getLongHeader()->destinationConnectionIdLength); |
142 | 0 | if (destinationConnectionIdOffset + length > m_DataLen) |
143 | 0 | { |
144 | 0 | throw std::out_of_range("Not enough data to read destination connection ID"); |
145 | 0 | } |
146 | | |
147 | 0 | return { length, destinationConnectionIdOffset }; |
148 | 0 | } |
149 | | |
150 | | std::vector<uint8_t> QuicV1LongHeaderLayer::getDestinationConnectionId() const |
151 | 0 | { |
152 | 0 | try |
153 | 0 | { |
154 | 0 | auto offsetAndLength = getDestConIdOffsetAndLength(); |
155 | 0 | return { m_Data + offsetAndLength.offset, m_Data + offsetAndLength.offset + offsetAndLength.length }; |
156 | 0 | } |
157 | 0 | catch (std::out_of_range&) |
158 | 0 | { |
159 | 0 | return {}; |
160 | 0 | } |
161 | 0 | } |
162 | | |
163 | | std::string QuicV1LongHeaderLayer::getDestinationConnectionIdAsString() const |
164 | 0 | { |
165 | 0 | auto connectionId = getDestinationConnectionId(); |
166 | 0 | return byteArrayToHexString(connectionId.data(), connectionId.size()); |
167 | 0 | } |
168 | | |
169 | | QuicV1LongHeaderLayer::OffsetAndLength QuicV1LongHeaderLayer::getSrcConIdOffsetAndLength() const |
170 | 0 | { |
171 | 0 | auto destOffsetAndLength = getDestConIdOffsetAndLength(); |
172 | 0 | auto sourceConnectionIdLengthOffset = destOffsetAndLength.offset + destOffsetAndLength.length; |
173 | 0 | if (m_DataLen <= sourceConnectionIdLengthOffset + sizeof(uint8_t)) |
174 | 0 | { |
175 | 0 | throw std::out_of_range("Not enough data to read source connection ID length"); |
176 | 0 | } |
177 | | |
178 | 0 | auto offset = sourceConnectionIdLengthOffset + sizeof(uint8_t); |
179 | 0 | auto length = static_cast<size_t>(m_Data[sourceConnectionIdLengthOffset]); |
180 | 0 | if (offset + length > m_DataLen) |
181 | 0 | { |
182 | 0 | throw std::out_of_range("Not enough data to read source connection ID"); |
183 | 0 | } |
184 | | |
185 | 0 | return { length, offset }; |
186 | 0 | } |
187 | | |
188 | | std::vector<uint8_t> QuicV1LongHeaderLayer::getSourceConnectionId() const |
189 | 0 | { |
190 | 0 | try |
191 | 0 | { |
192 | 0 | auto offsetAndLength = getSrcConIdOffsetAndLength(); |
193 | 0 | return { m_Data + offsetAndLength.offset, m_Data + offsetAndLength.offset + offsetAndLength.length }; |
194 | 0 | } |
195 | 0 | catch (std::out_of_range&) |
196 | 0 | { |
197 | 0 | return {}; |
198 | 0 | } |
199 | 0 | } |
200 | | |
201 | | std::string QuicV1LongHeaderLayer::getSourceConnectionIdAsString() const |
202 | 0 | { |
203 | 0 | auto connectionId = getSourceConnectionId(); |
204 | 0 | return byteArrayToHexString(connectionId.data(), connectionId.size()); |
205 | 0 | } |
206 | | |
207 | | const FieldDescriptor QuicV1LongHeaderLayer::SerializedFields::Version{ QuicV1Layer::SerializedFields::MaxID + 1, |
208 | | "version" }; |
209 | | const FieldDescriptor QuicV1LongHeaderLayer::SerializedFields::DestinationConnectionId{ |
210 | | QuicV1Layer::SerializedFields::MaxID + 2, "destinationConnectionId" |
211 | | }; |
212 | | const FieldDescriptor QuicV1LongHeaderLayer::SerializedFields::SourceConnectionId{ |
213 | | QuicV1Layer::SerializedFields::MaxID + 3, "sourceConnectionId" |
214 | | }; |
215 | | |
216 | | void QuicV1LongHeaderLayer::serializeLayer(ObjectScope& serializer) const |
217 | 0 | { |
218 | 0 | QuicV1Layer::serializeLayer(serializer); |
219 | 0 | serializer.writeField(SerializedFields::Version, getVersion()); |
220 | 0 | serializer.writeField(SerializedFields::DestinationConnectionId, getDestinationConnectionIdAsString()); |
221 | 0 | serializer.writeField(SerializedFields::SourceConnectionId, getSourceConnectionIdAsString()); |
222 | 0 | } |
223 | | |
224 | | size_t QuicV1EstablishmentLayer::getLengthOffset() const |
225 | 0 | { |
226 | 0 | auto srcConOffsetAndLength = getSrcConIdOffsetAndLength(); |
227 | 0 | if (srcConOffsetAndLength.offset + srcConOffsetAndLength.length + sizeof(uint8_t) > m_DataLen) |
228 | 0 | { |
229 | 0 | throw std::out_of_range("Not enough data to read length offset"); |
230 | 0 | } |
231 | | |
232 | 0 | return srcConOffsetAndLength.offset + srcConOffsetAndLength.length; |
233 | 0 | } |
234 | | |
235 | | QuicV1EstablishmentLayer::VarintValueAndSize QuicV1EstablishmentLayer::getVarintValueAndSize(size_t offset) const |
236 | 0 | { |
237 | 0 | uint8_t prefix = (m_Data[offset] & 0xc0) >> 6; |
238 | 0 | auto size = static_cast<size_t>(1) << prefix; |
239 | |
|
240 | 0 | if (offset + size > m_DataLen) |
241 | 0 | { |
242 | 0 | throw std::out_of_range("Not enough data to read varint value"); |
243 | 0 | } |
244 | | |
245 | 0 | uint64_t value = m_Data[offset] & 0x3f; |
246 | 0 | for (size_t i = 1; i < size; i++) |
247 | 0 | { |
248 | 0 | value = (value << 8) | m_Data[offset + i]; |
249 | 0 | } |
250 | |
|
251 | 0 | return { value, size }; |
252 | 0 | } |
253 | | |
254 | | uint64_t QuicV1EstablishmentLayer::getLength() const |
255 | 0 | { |
256 | 0 | try |
257 | 0 | { |
258 | 0 | auto offset = getLengthOffset(); |
259 | 0 | auto valueAndSize = getVarintValueAndSize(offset); |
260 | 0 | return valueAndSize.value; |
261 | 0 | } |
262 | 0 | catch (std::out_of_range&) |
263 | 0 | { |
264 | 0 | return 0; |
265 | 0 | } |
266 | 0 | } |
267 | | |
268 | | size_t QuicV1EstablishmentLayer::getHeaderLen() const |
269 | 0 | { |
270 | 0 | try |
271 | 0 | { |
272 | 0 | auto offset = getLengthOffset(); |
273 | 0 | auto lengthValueAndSize = getVarintValueAndSize(offset); |
274 | 0 | return (std::min)(static_cast<size_t>(offset + lengthValueAndSize.size + lengthValueAndSize.value), |
275 | 0 | m_DataLen); |
276 | 0 | } |
277 | 0 | catch (std::out_of_range&) |
278 | 0 | { |
279 | 0 | return m_DataLen; |
280 | 0 | } |
281 | 0 | } |
282 | | |
283 | | QuicV1EstablishmentLayer::ProtectedPayload QuicV1EstablishmentLayer::getProtectedPayload() const |
284 | 0 | { |
285 | 0 | try |
286 | 0 | { |
287 | 0 | auto lengthOffset = getLengthOffset(); |
288 | 0 | auto lengthValueAndSize = getVarintValueAndSize(lengthOffset); |
289 | |
|
290 | 0 | auto payloadOffset = lengthOffset + lengthValueAndSize.size; |
291 | 0 | auto payloadLength = static_cast<size_t>(lengthValueAndSize.value); |
292 | |
|
293 | 0 | payloadLength = (std::min)(payloadLength, m_DataLen - payloadOffset); |
294 | |
|
295 | 0 | return { m_Data + payloadOffset, payloadLength }; |
296 | 0 | } |
297 | 0 | catch (std::out_of_range&) |
298 | 0 | { |
299 | 0 | return { nullptr, 0 }; |
300 | 0 | } |
301 | 0 | } |
302 | | |
303 | | const FieldDescriptor QuicV1EstablishmentLayer::SerializedFields::PayloadLength{ |
304 | | QuicV1LongHeaderLayer::SerializedFields::MaxID + 1, "payloadLength" |
305 | | }; |
306 | | |
307 | | void QuicV1EstablishmentLayer::serializeLayer(ObjectScope& serializer) const |
308 | 0 | { |
309 | 0 | QuicV1LongHeaderLayer::serializeLayer(serializer); |
310 | 0 | serializer.writeField(SerializedFields::PayloadLength, getLength()); |
311 | 0 | } |
312 | | |
313 | | std::vector<uint8_t> QuicV1InitialLayer::getToken() const |
314 | 0 | { |
315 | 0 | try |
316 | 0 | { |
317 | 0 | auto tokenLengthOffset = getTokenLengthOffset(); |
318 | 0 | auto tokenLengthValueAndSize = getVarintValueAndSize(tokenLengthOffset); |
319 | 0 | if (tokenLengthValueAndSize.value == 0 || |
320 | 0 | tokenLengthOffset + tokenLengthValueAndSize.size + tokenLengthValueAndSize.value > m_DataLen) |
321 | 0 | { |
322 | 0 | return {}; |
323 | 0 | } |
324 | 0 | auto tokenOffset = m_Data + tokenLengthOffset + tokenLengthValueAndSize.size; |
325 | 0 | return { tokenOffset, tokenOffset + tokenLengthValueAndSize.value }; |
326 | 0 | } |
327 | 0 | catch (std::out_of_range&) |
328 | 0 | { |
329 | 0 | return {}; |
330 | 0 | } |
331 | 0 | } |
332 | | |
333 | | std::string QuicV1InitialLayer::getTokenAsString() const |
334 | 0 | { |
335 | 0 | auto token = getToken(); |
336 | 0 | return byteArrayToHexString(token.data(), token.size()); |
337 | 0 | } |
338 | | |
339 | | const FieldDescriptor QuicV1InitialLayer::SerializedFields::Token{ |
340 | | QuicV1EstablishmentLayer::SerializedFields::MaxID + 1, "token" |
341 | | }; |
342 | | |
343 | | void QuicV1InitialLayer::serializeLayer(ObjectScope& serializer) const |
344 | 0 | { |
345 | 0 | QuicV1EstablishmentLayer::serializeLayer(serializer); |
346 | 0 | serializer.writeField(SerializedFields::Token, getTokenAsString()); |
347 | 0 | } |
348 | | |
349 | | size_t QuicV1InitialLayer::getLengthOffset() const |
350 | 0 | { |
351 | 0 | auto tokenLengthOffset = getTokenLengthOffset(); |
352 | 0 | auto tokenLengthValueAndSize = getVarintValueAndSize(tokenLengthOffset); |
353 | 0 | if (tokenLengthOffset + tokenLengthValueAndSize.size + tokenLengthValueAndSize.value + sizeof(uint8_t) > |
354 | 0 | m_DataLen) |
355 | 0 | { |
356 | 0 | throw std::out_of_range("Not enough data to read length offset"); |
357 | 0 | } |
358 | 0 | return tokenLengthOffset + tokenLengthValueAndSize.size + tokenLengthValueAndSize.value; |
359 | 0 | } |
360 | | |
361 | | size_t QuicV1InitialLayer::getTokenLengthOffset() const |
362 | 0 | { |
363 | 0 | auto srcConOffsetAndLength = getSrcConIdOffsetAndLength(); |
364 | 0 | if (srcConOffsetAndLength.offset + srcConOffsetAndLength.length + sizeof(uint8_t) > m_DataLen) |
365 | 0 | { |
366 | 0 | throw std::out_of_range("Not enough data to read token length offset"); |
367 | 0 | } |
368 | 0 | return srcConOffsetAndLength.offset + srcConOffsetAndLength.length; |
369 | 0 | } |
370 | | |
371 | | size_t QuicV1RetryLayer::getRetryTokenOffset() const |
372 | 0 | { |
373 | 0 | try |
374 | 0 | { |
375 | 0 | auto offsetAndLength = getSrcConIdOffsetAndLength(); |
376 | 0 | return offsetAndLength.offset + offsetAndLength.length; |
377 | 0 | } |
378 | 0 | catch (std::out_of_range&) |
379 | 0 | { |
380 | 0 | return m_DataLen; |
381 | 0 | } |
382 | 0 | } |
383 | | |
384 | | std::vector<uint8_t> QuicV1RetryLayer::getRetryToken() const |
385 | 0 | { |
386 | 0 | auto retryTokenOffset = getRetryTokenOffset(); |
387 | 0 | if (m_DataLen - retryTokenOffset < retryIntegritySize) |
388 | 0 | { |
389 | 0 | return {}; |
390 | 0 | } |
391 | | |
392 | 0 | return { m_Data + retryTokenOffset, m_Data + m_DataLen - retryIntegritySize }; |
393 | 0 | } |
394 | | |
395 | | std::string QuicV1RetryLayer::getRetryTokenAsString() const |
396 | 0 | { |
397 | 0 | auto retryToken = getRetryToken(); |
398 | 0 | return byteArrayToHexString(retryToken.data(), retryToken.size()); |
399 | 0 | } |
400 | | |
401 | | std::vector<uint8_t> QuicV1RetryLayer::getRetryIntegrityTag() const |
402 | 0 | { |
403 | 0 | auto retryTokenOffset = getRetryTokenOffset(); |
404 | 0 | if (m_DataLen - retryTokenOffset < retryIntegritySize) |
405 | 0 | { |
406 | 0 | return {}; |
407 | 0 | } |
408 | | |
409 | 0 | return { m_Data + m_DataLen - retryIntegritySize, m_Data + m_DataLen }; |
410 | 0 | } |
411 | | |
412 | | std::string QuicV1RetryLayer::getRetryIntegrityTagAsString() const |
413 | 0 | { |
414 | 0 | auto retryIntegrityTag = getRetryIntegrityTag(); |
415 | 0 | return byteArrayToHexString(retryIntegrityTag.data(), retryIntegrityTag.size()); |
416 | 0 | } |
417 | | |
418 | | const FieldDescriptor QuicV1RetryLayer::SerializedFields::RetryToken{ |
419 | | QuicV1LongHeaderLayer::SerializedFields::MaxID + 1, "retryToken" |
420 | | }; |
421 | | const FieldDescriptor QuicV1RetryLayer::SerializedFields::RetryIntegrityTag{ |
422 | | QuicV1LongHeaderLayer::SerializedFields::MaxID + 2, "retryIntegrityTag" |
423 | | }; |
424 | | |
425 | | void QuicV1RetryLayer::serializeLayer(ObjectScope& serializer) const |
426 | 0 | { |
427 | 0 | QuicV1LongHeaderLayer::serializeLayer(serializer); |
428 | 0 | serializer.writeField(SerializedFields::RetryToken, getRetryTokenAsString()); |
429 | 0 | serializer.writeField(SerializedFields::RetryIntegrityTag, getRetryIntegrityTagAsString()); |
430 | 0 | } |
431 | | |
432 | | std::vector<uint32_t> QuicV1VersionNegotiationLayer::getSupportedVersions() const |
433 | 0 | { |
434 | 0 | try |
435 | 0 | { |
436 | 0 | auto offsetAndLength = getSrcConIdOffsetAndLength(); |
437 | 0 | auto supportedVersionsOffset = offsetAndLength.offset + offsetAndLength.length; |
438 | 0 | std::vector<uint32_t> supportedVersions; |
439 | 0 | while (supportedVersionsOffset < m_DataLen) |
440 | 0 | { |
441 | 0 | if (m_DataLen - supportedVersionsOffset < sizeof(uint32_t)) |
442 | 0 | { |
443 | 0 | break; |
444 | 0 | } |
445 | 0 | uint32_t version; |
446 | 0 | std::memcpy(&version, m_Data + supportedVersionsOffset, sizeof(uint32_t)); |
447 | 0 | supportedVersions.push_back(netToHost32(version)); |
448 | 0 | supportedVersionsOffset += sizeof(uint32_t); |
449 | 0 | } |
450 | 0 | return supportedVersions; |
451 | 0 | } |
452 | 0 | catch (std::out_of_range&) |
453 | 0 | { |
454 | 0 | return {}; |
455 | 0 | } |
456 | 0 | } |
457 | | |
458 | | const FieldDescriptor QuicV1VersionNegotiationLayer::SerializedFields::SupportedVersions{ |
459 | | QuicV1LongHeaderLayer::SerializedFields::MaxID + 1, "supportedVersions" |
460 | | }; |
461 | | const FieldDescriptor QuicV1VersionNegotiationLayer::SerializedFields::SupportedVersion{ 0, "supportedVersion" }; |
462 | | |
463 | | void QuicV1VersionNegotiationLayer::serializeLayer(ObjectScope& serializer) const |
464 | 0 | { |
465 | 0 | QuicV1LongHeaderLayer::serializeLayer(serializer); |
466 | 0 | auto versions = serializer.writeArray(SerializedFields::SupportedVersions); |
467 | 0 | for (auto version : getSupportedVersions()) |
468 | 0 | { |
469 | 0 | versions.writeField(SerializedFields::SupportedVersion, version); |
470 | 0 | } |
471 | 0 | } |
472 | | |
473 | | QuicV1Layer::ProtectedPayload QuicV1OneRttLayer::getProtectedPayload() const |
474 | 0 | { |
475 | 0 | return { m_Data + sizeof(quic_short_header), m_DataLen - sizeof(quic_short_header) }; |
476 | 0 | } |
477 | | |
478 | | bool QuicV1OneRttLayer::isDataValid(const uint8_t* data, size_t dataLen) |
479 | 0 | { |
480 | 0 | return data != nullptr && dataLen >= sizeof(quic_short_header); |
481 | 0 | } |
482 | | |
483 | | const FieldDescriptor QuicV1OneRttLayer::SerializedFields::SpinBit{ QuicV1Layer::SerializedFields::MaxID + 1, |
484 | | "spinBit" }; |
485 | | const FieldDescriptor QuicV1OneRttLayer::SerializedFields::KeyPhaseBit{ QuicV1Layer::SerializedFields::MaxID + 2, |
486 | | "keyPhaseBit" }; |
487 | | |
488 | | void QuicV1OneRttLayer::serializeLayer(ObjectScope& serializer) const |
489 | 0 | { |
490 | 0 | QuicV1Layer::serializeLayer(serializer); |
491 | 0 | serializer.writeField(SerializedFields::SpinBit, getSpinBit()); |
492 | 0 | serializer.writeField(SerializedFields::KeyPhaseBit, getKeyPhaseBit()); |
493 | 0 | } |
494 | | } // namespace pcpp |