parse IETF headers independent of the sender's perspective

The IETF header format allows parsing of the header without knowing
which peer sent the packet.
This commit is contained in:
Marten Seemann
2018-05-05 17:59:54 +09:00
parent 70f6e3651e
commit 8f2fed1b10
9 changed files with 74 additions and 74 deletions

View File

@@ -314,18 +314,25 @@ func (s *server) handlePacket(remoteAddr net.Addr, packet []byte) error {
func (s *server) handleIETFQUICPacket(hdr *wire.Header, packetData []byte, remoteAddr net.Addr, rcvTime time.Time) error {
if hdr.IsLongHeader {
if !s.supportsTLS {
return errors.New("Received an IETF QUIC Long Header")
}
if protocol.ByteCount(len(packetData)) < hdr.PayloadLen {
return fmt.Errorf("packet payload (%d bytes) is smaller than the expected payload length (%d bytes)", len(packetData), hdr.PayloadLen)
}
packetData = packetData[:int(hdr.PayloadLen)]
// TODO(#1312): implement parsing of compound packets
}
if hdr.Type == protocol.PacketTypeInitial {
if s.supportsTLS {
switch hdr.Type {
case protocol.PacketTypeInitial:
go s.serverTLS.HandleInitial(remoteAddr, hdr, packetData)
return nil
case protocol.PacketTypeHandshake:
// nothing to do here. Packet will be passed to the session.
default:
// Note that this also drops 0-RTT packets.
return fmt.Errorf("Received unsupported packet type: %s", hdr.Type)
}
return nil
}
s.sessionsMutex.RLock()