コード例 #1
0
        internal static unsafe ulong GetULongParam(MsQuicApi api, SafeHandle nativeObject, uint param)
        {
            ulong value;
            uint  valueLen = (uint)sizeof(ulong);

            uint status = api.GetParamDelegate(nativeObject, param, ref valueLen, (byte *)&value);

            QuicExceptionHelpers.ThrowIfFailed(status, "GetULongParam failed.");
            Debug.Assert(valueLen == sizeof(ulong));

            return(value);
        }
コード例 #2
0
        internal static unsafe ushort GetUShortParam(MsQuicApi api, SafeHandle nativeObject, QUIC_PARAM_LEVEL level, uint param)
        {
            ushort value;
            uint   valueLen = (uint)sizeof(ushort);

            uint status = api.GetParamDelegate(nativeObject, level, param, ref valueLen, (byte *)&value);

            QuicExceptionHelpers.ThrowIfFailed(status, "GetUShortParam failed.");
            Debug.Assert(valueLen == sizeof(ushort));

            return(value);
        }
コード例 #3
0
        internal static unsafe IPEndPoint GetIPEndPointParam(MsQuicApi api, SafeHandle nativeObject, uint param)
        {
            // MsQuic always uses storage size as if IPv6 was used
            uint        valueLen = (uint)Internals.SocketAddress.IPv6AddressSize;
            Span <byte> address  = stackalloc byte[Internals.SocketAddress.IPv6AddressSize];

            fixed(byte *paddress = &MemoryMarshal.GetReference(address))
            {
                uint status = api.GetParamDelegate(nativeObject, param, ref valueLen, paddress);

                QuicExceptionHelpers.ThrowIfFailed(status, "GetIPEndPointParam failed.");
            }

            address = address.Slice(0, (int)valueLen);

            return(new Internals.SocketAddress(SocketAddressPal.GetAddressFamily(address), address)
                   .GetIPEndPoint());
        }