-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUIC] API Update #49823
[QUIC] API Update #49823
Changes from 10 commits
6bf36e4
e96522e
b92bd1d
7aa745c
6a132c5
1d0d98c
68a5c48
851dc1b
78e3981
7ad5163
f67ed0d
204f4fa
72ea176
5d3884f
c0f896f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,9 @@ internal override bool Connected | |
} | ||
|
||
// TODO: Should clone the endpoint since it is mutable | ||
internal override IPEndPoint LocalEndPoint => _localEndPoint; | ||
// TODO: could this be made back to non-nullable? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we get rid of instance method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider the TODO as work that needs to be done/resolved. But I don't want to hold the PR on those issues. The work will be done in follow up PRs. |
||
// For inbound we have it immediately, for outbound after connect. | ||
internal override IPEndPoint? LocalEndPoint => _localEndPoint; | ||
|
||
// TODO: Should clone the endpoint since it is mutable | ||
internal override EndPoint RemoteEndPoint => _remoteEndPoint!; | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,62 @@ | ||
// 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, QUIC_PARAM_LEVEL 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, QUIC_PARAM_LEVEL 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, QUIC_PARAM_LEVEL 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, QUIC_PARAM_LEVEL 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, QUIC_PARAM_LEVEL level, uint param, ulong value) | ||
{ | ||
QuicBuffer buffer = new QuicBuffer() | ||
{ | ||
Length = sizeof(ulong), | ||
Buffer = (byte*)&value | ||
}; | ||
|
||
QuicExceptionHelpers.ThrowIfFailed( | ||
api.UnsafeGetParam(nativeObject, level, param, ref buffer), | ||
api.SetParamDelegate(nativeObject, level, param, sizeof(ulong), (byte*)&value), | ||
"Could not set ulong."); | ||
} | ||
|
||
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."); | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scalablecory could we reference the System.Net.Experimental.Quic here instead now? https://github.com/dotnet/runtimelab/tree/feature/System.Net.Experimental.MsQuic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You won't need that package for .NET 6.