diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs index 2a6ceac8cacf11..e2866454356dd2 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs @@ -17,7 +17,7 @@ internal sealed unsafe class MsQuicApi { private static readonly Version MinWindowsVersion = new Version(10, 0, 20145, 1000); - private static readonly Version MsQuicVersion = new Version(2, 0); + private static readonly Version MsQuicVersion = new Version(2, 1); public MsQuicSafeHandle Registration { get; } diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs index 1a83c7205202f9..738c2365f604f7 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.cs @@ -76,6 +76,7 @@ internal enum QUIC_CREDENTIAL_FLAGS USE_SYSTEM_MAPPER = 0x00010000, CACHE_ONLY_URL_RETRIEVAL = 0x00020000, REVOCATION_CHECK_CACHE_ONLY = 0x00040000, + INPROC_PEER_CERTIFICATE = 0x00080000, } [System.Flags] @@ -424,6 +425,7 @@ internal enum QUIC_CIPHER_SUITE internal enum QUIC_CONGESTION_CONTROL_ALGORITHM { CUBIC, + BBR, MAX, } @@ -2481,6 +2483,9 @@ internal byte RESERVED [NativeTypeName("QUIC_UINT62")] internal ulong ConnectionErrorCode; + + [NativeTypeName("HRESULT")] + internal int ConnectionCloseStatus; } internal partial struct _IDEAL_SEND_BUFFER_SIZE_e__Struct @@ -2782,6 +2787,9 @@ internal static unsafe partial class MsQuic [NativeTypeName("#define QUIC_PARAM_STREAM_PRIORITY 0x08000003")] internal const uint QUIC_PARAM_STREAM_PRIORITY = 0x08000003; + [NativeTypeName("#define QUIC_PARAM_STREAM_STATISTICS 0X08000004")] + internal const uint QUIC_PARAM_STREAM_STATISTICS = 0X08000004; + [NativeTypeName("#define QUIC_API_VERSION_2 2")] internal const uint QUIC_API_VERSION_2 = 2; } diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs index 217e53f3be103a..28a292d031af19 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs @@ -543,12 +543,14 @@ private unsafe int HandleEventShutdownComplete(ref SHUTDOWN_COMPLETE data) (shutdownByApp: true, closedRemotely: true) => ThrowHelper.GetConnectionAbortedException((long)data.ConnectionErrorCode), // It's local shutdown by app, this side called QuicConnection.CloseAsync, throw QuicError.OperationAborted. (shutdownByApp: true, closedRemotely: false) => ThrowHelper.GetOperationAbortedException(), - // It's remote shutdown by transport, (TODO: we should propagate transport error code), throw QuicError.InternalError. + // It's remote shutdown by transport, we received a CONNECTION_CLOSE frame with a QUIC transport error code + // TODO: we should propagate the transport error code // https://github.com/dotnet/runtime/issues/72666 - (shutdownByApp: false, closedRemotely: true) => ThrowHelper.GetExceptionForMsQuicStatus(QUIC_STATUS_INTERNAL_ERROR, $"Shutdown by transport {data.ConnectionErrorCode}"), - // It's local shutdown by transport, assuming idle connection (TODO: we should get Connection.CloseStatus), throw QuicError.ConnectionIdle. + (shutdownByApp: false, closedRemotely: true) => ThrowHelper.GetExceptionForMsQuicStatus(data.ConnectionCloseStatus, $"Shutdown by transport {data.ConnectionErrorCode}"), + // It's local shutdown by transport, due to some timeout + // TODO: we should propagate transport error code // https://github.com/dotnet/runtime/issues/72666 - (shutdownByApp: false, closedRemotely: false) => ThrowHelper.GetExceptionForMsQuicStatus(QUIC_STATUS_CONNECTION_IDLE), + (shutdownByApp: false, closedRemotely: false) => ThrowHelper.GetExceptionForMsQuicStatus(data.ConnectionCloseStatus), }; _startedTcs.TrySetException(exception); _receiveTcs.TrySetException(exception, final: true);