set the Long Header packet type based on the state of the handshake

This commit is contained in:
Marten Seemann
2017-10-27 08:39:06 +07:00
parent a65929f6cf
commit 3f62ea8673
14 changed files with 205 additions and 22 deletions

View File

@@ -24,7 +24,7 @@ type Header struct {
DiversificationNonce []byte
// only needed for the IETF Header
Type uint8
Type protocol.PacketType
IsLongHeader bool
KeyPhase int

View File

@@ -35,7 +35,7 @@ func parseLongHeader(b *bytes.Reader, packetSentBy protocol.Perspective, typeByt
return nil, err
}
h := &Header{
Type: typeByte & 0x7f,
Type: protocol.PacketType(typeByte & 0x7f),
IsLongHeader: true,
ConnectionID: protocol.ConnectionID(connID),
PacketNumber: protocol.PacketNumber(pn),

View File

@@ -32,7 +32,7 @@ var _ = Describe("IETF draft Header", func() {
b := bytes.NewReader(data)
h, err := parseHeader(b, protocol.PerspectiveClient)
Expect(err).ToNot(HaveOccurred())
Expect(h.Type).To(BeEquivalentTo(3))
Expect(h.Type).To(Equal(protocol.PacketType(3)))
Expect(h.IsLongHeader).To(BeTrue())
Expect(h.OmitConnectionID).To(BeFalse())
Expect(h.ConnectionID).To(Equal(protocol.ConnectionID(0xdeadbeefcafe1337)))
@@ -62,6 +62,7 @@ var _ = Describe("IETF draft Header", func() {
b := bytes.NewReader(data)
h, err := parseHeader(b, protocol.PerspectiveServer)
Expect(err).ToNot(HaveOccurred())
Expect(h.Type).To(Equal(protocol.PacketTypeVersionNegotiation))
Expect(h.SupportedVersions).To(Equal([]protocol.VersionNumber{
0x22334455,
0x33445566,