예제 #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));
        }