mirror of https://github.com/vacp2p/nim-quic.git
Write reserved bits for short header
This commit is contained in:
parent
77e3a39e2f
commit
1d250c9715
|
@ -42,6 +42,7 @@ proc write*(datagram: var Datagram, packet: Packet) =
|
|||
case packet.form
|
||||
of formShort:
|
||||
writer.writeSpinBit(datagram)
|
||||
writer.writeReservedBits(datagram)
|
||||
of formLong:
|
||||
writer.writeKind(datagram)
|
||||
writer.writeVersion(datagram)
|
||||
|
|
|
@ -82,3 +82,7 @@ proc writePayload*(writer: var PacketWriter, datagram: var Datagram) =
|
|||
|
||||
proc writeSpinBit*(writer: var PacketWriter, datagram: var Datagram) =
|
||||
datagram[writer.next].bits[2] = Bit(writer.packet.spinBit)
|
||||
|
||||
proc writeReservedBits*(writer: var PacketWriter, datagram: var Datagram) =
|
||||
datagram[writer.next].bits[3] = 0
|
||||
datagram[writer.next].bits[4] = 0
|
||||
|
|
|
@ -133,6 +133,13 @@ suite "packet writing":
|
|||
datagram.write(Packet(form: formShort, spinBit: true))
|
||||
check datagram[0].bits[2] == 1
|
||||
|
||||
test "writes reserved bits for short packet":
|
||||
datagram[0].bits[3] = 1
|
||||
datagram[0].bits[4] = 1
|
||||
datagram.write(Packet(form: formShort))
|
||||
check datagram[0].bits[3] == 0
|
||||
check datagram[0].bits[4] == 0
|
||||
|
||||
suite "packet reading":
|
||||
|
||||
var datagram: seq[byte]
|
||||
|
|
Loading…
Reference in New Issue