forked from dotnet/runtime
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge updated msquic API with datagram support
- Loading branch information
Showing
25 changed files
with
1,309 additions
and
1,502 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
405 changes: 83 additions & 322 deletions
405
...ibraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
Large diffs are not rendered by default.
Oops, something went wrong.
119 changes: 37 additions & 82 deletions
119
...em.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/MsQuicParameterHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,81 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using static System.Net.Quic.Implementations.MsQuic.Internal.MsQuicNativeMethods; | ||
|
||
namespace System.Net.Quic.Implementations.MsQuic.Internal | ||
{ | ||
internal static class MsQuicParameterHelpers | ||
{ | ||
internal static unsafe SOCKADDR_INET GetINetParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param) | ||
internal static unsafe SOCKADDR_INET GetINetParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param) | ||
{ | ||
byte* ptr = stackalloc byte[sizeof(SOCKADDR_INET)]; | ||
QuicBuffer buffer = new QuicBuffer | ||
{ | ||
Length = (uint)sizeof(SOCKADDR_INET), | ||
Buffer = ptr | ||
}; | ||
SOCKADDR_INET value; | ||
uint valueLen = (uint)sizeof(SOCKADDR_INET); | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeGetParam(nativeObject, level, param, ref buffer), | ||
"Could not get SOCKADDR_INET."); | ||
uint status = api.GetParamDelegate(nativeObject, level, param, ref valueLen, (byte*)&value); | ||
QuicExceptionHelpers.ThrowIfFailed(status, "GetINETParam failed."); | ||
Debug.Assert(valueLen == sizeof(SOCKADDR_INET)); | ||
|
||
return *(SOCKADDR_INET*)ptr; | ||
return value; | ||
} | ||
|
||
internal static unsafe ushort GetUShortParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param) | ||
internal static unsafe ushort GetUShortParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param) | ||
{ | ||
byte* ptr = stackalloc byte[sizeof(ushort)]; | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(ushort), | ||
Buffer = ptr | ||
}; | ||
ushort value; | ||
uint valueLen = (uint)sizeof(ushort); | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeGetParam(nativeObject, level, param, ref buffer), | ||
"Could not get ushort."); | ||
uint status = api.GetParamDelegate(nativeObject, level, param, ref valueLen, (byte*)&value); | ||
QuicExceptionHelpers.ThrowIfFailed(status, "GetUShortParam failed."); | ||
Debug.Assert(valueLen == sizeof(ushort)); | ||
|
||
return *(ushort*)ptr; | ||
return value; | ||
} | ||
|
||
internal static unsafe void SetUshortParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param, ushort value) | ||
internal static unsafe void SetUshortParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param, ushort value) | ||
{ | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(ushort), | ||
Buffer = (byte*)&value | ||
}; | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeSetParam(nativeObject, level, param, buffer), | ||
api.SetParamDelegate(nativeObject, level, param, sizeof(ushort), (byte*)&value), | ||
"Could not set ushort."); | ||
} | ||
|
||
internal static unsafe ulong GetULongParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param) | ||
internal static unsafe ulong GetULongParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param) | ||
{ | ||
byte* ptr = stackalloc byte[sizeof(ulong)]; | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(ulong), | ||
Buffer = ptr | ||
}; | ||
ulong value; | ||
uint valueLen = (uint)sizeof(ulong); | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeGetParam(nativeObject, level, param, ref buffer), | ||
"Could not get ulong."); | ||
uint status = api.GetParamDelegate(nativeObject, level, param, ref valueLen, (byte*)&value); | ||
QuicExceptionHelpers.ThrowIfFailed(status, "GetULongParam failed."); | ||
Debug.Assert(valueLen == sizeof(ulong)); | ||
|
||
return *(ulong*)ptr; | ||
return value; | ||
} | ||
|
||
internal static unsafe void SetULongParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param, ulong value) | ||
internal static unsafe void SetULongParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param, ulong value) | ||
{ | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(ulong), | ||
Buffer = (byte*)&value | ||
}; | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeSetParam(nativeObject, level, param, buffer), | ||
api.SetParamDelegate(nativeObject, level, param, sizeof(ulong), (byte*)&value), | ||
"Could not set ulong."); | ||
} | ||
|
||
internal static unsafe byte GetByteParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param) | ||
internal static unsafe byte GetByteParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param) | ||
{ | ||
byte* ptr = stackalloc byte[sizeof(byte)]; | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(byte), | ||
Buffer = ptr | ||
}; | ||
byte value; | ||
uint valueLen = (uint)sizeof(byte); | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeGetParam(nativeObject, level, param, ref buffer), | ||
"Could not get byte."); | ||
uint status = api.GetParamDelegate(nativeObject, level, param, ref valueLen, &value); | ||
QuicExceptionHelpers.ThrowIfFailed(status, "GetByteParam failed."); | ||
Debug.Assert(valueLen == sizeof(byte)); | ||
|
||
return *ptr; | ||
return value; | ||
} | ||
|
||
internal static unsafe void SetByteParam(MsQuicApi api, IntPtr nativeObject, uint level, uint param, byte value) | ||
internal static unsafe void SetByteParam(MsQuicApi api, SafeHandle nativeObject, uint level, uint param, byte value) | ||
{ | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(byte), | ||
Buffer = &value | ||
}; | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeSetParam(nativeObject, level, param, buffer), | ||
"Could not set byte."); | ||
} | ||
|
||
internal static unsafe void SetSecurityConfig(MsQuicApi api, IntPtr nativeObject, uint level, uint param, IntPtr value) | ||
{ | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = (uint)sizeof(void*), | ||
Buffer = (byte*)&value | ||
}; | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeSetParam(nativeObject, level, param, buffer), | ||
"Could not set security configuration."); | ||
api.SetParamDelegate(nativeObject, level, param, sizeof(byte), &value), | ||
"Could not set ulong."); | ||
} | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
...stem.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/MsQuicSecurityConfig.cs
This file was deleted.
Oops, something went wrong.
175 changes: 0 additions & 175 deletions
175
...ries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/MsQuicSession.cs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.