Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/awelzel/no-bytes-in-variab…
Browse files Browse the repository at this point in the history
…le-length-integer'

* origin/topic/awelzel/no-bytes-in-variable-length-integer:
  quic: Avoid bytes for VariableLengthInteger
  • Loading branch information
awelzel committed Oct 12, 2023
2 parents 6b9d97a + 2af9f65 commit a3ffed8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions analyzer/QUIC.spicy
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,13 @@ type VariableLengthInteger = unit {
#
# https://datatracker.ietf.org/doc/rfc9000/
# Section 16 and Appendix A
#
first_byte: bytes &size=1 {
local uint8_val = uint8($$.to_uint(spicy::ByteOrder::Big));
self.bytes_to_parse = 2**((0xC0 & uint8_val) >> 6);
# Re-pack without most significant two bits for later use.
self.first_byte = pack(0x3f & uint8_val, spicy::ByteOrder::Big);
: uint8 {
self.bytes_to_parse = 2**((0xC0 & $$) >> 6);
self.result = $$ & 0x3F;
}
remaining_bytes: bytes &size=self.bytes_to_parse - 1;

on %done {
self.result = (self.first_byte + self.remaining_bytes).to_uint(spicy::ByteOrder::Big);
: uint8[self.bytes_to_parse - 1] if (self.bytes_to_parse > 1) foreach {
self.result = (self.result << 8) | $$;
}
};

Expand Down

0 comments on commit a3ffed8

Please sign in to comment.