Пример #1
0
        public unsafe IntPtr SessionOpen(byte[] alpn)
        {
            IntPtr sessionPtr = IntPtr.Zero;
            uint   status;

            fixed(byte *pAlpn = alpn)
            {
                var alpnBuffer = new MsQuicNativeMethods.QuicBuffer
                {
                    Length = (uint)alpn.Length,
                    Buffer = pAlpn
                };

                status = SessionOpenDelegate(
                    _registrationContext,
                    &alpnBuffer,
                    1,
                    IntPtr.Zero,
                    ref sessionPtr);
            }

            QuicExceptionHelpers.ThrowIfFailed(status, "Could not open session.");

            return(sessionPtr);
        }
Пример #2
0
        private unsafe void SetUshortParameter(QUIC_PARAM_SESSION param, ushort count)
        {
            var buffer = new MsQuicNativeMethods.QuicBuffer()
            {
                Length = sizeof(ushort),
                Buffer = (byte *)&count
            };

            SetParam(param, buffer);
        }
Пример #3
0
 private void SetParam(
     QUIC_PARAM_SESSION param,
     MsQuicNativeMethods.QuicBuffer buf)
 {
     QuicExceptionHelpers.ThrowIfFailed(MsQuicApi.Api.UnsafeSetParam(
                                            _nativeObjPtr,
                                            (uint)QUIC_PARAM_LEVEL.SESSION,
                                            (uint)param,
                                            buf),
                                        "Could not set parameter on session.");
 }
Пример #4
0
 internal unsafe uint UnsafeSetParam(
     IntPtr Handle,
     uint Level,
     uint Param,
     MsQuicNativeMethods.QuicBuffer Buffer)
 {
     return(SetParamDelegate(
                Handle,
                Level,
                Param,
                Buffer.Length,
                Buffer.Buffer));
 }
Пример #5
0
        private unsafe IntPtr SessionOpen(SslApplicationProtocol alpnProtocol)
        {
            ReadOnlyMemory <byte> memory = alpnProtocol.Protocol;

            using MemoryHandle h = memory.Pin();

            var quicBuffer = new MsQuicNativeMethods.QuicBuffer()
            {
                Buffer = (byte *)h.Pointer,
                Length = (uint)memory.Length
            };

            return(SessionOpen(&quicBuffer, 1));
        }
Пример #6
0
        internal unsafe uint UnsafeGetParam(
            IntPtr Handle,
            uint Level,
            uint Param,
            ref MsQuicNativeMethods.QuicBuffer Buffer)
        {
            uint  bufferLength = Buffer.Length;
            byte *buf          = Buffer.Buffer;

            return(GetParamDelegate(
                       Handle,
                       Level,
                       Param,
                       &bufferLength,
                       buf));
        }