Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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.");
 }
Ejemplo n.º 4
0
 internal unsafe uint UnsafeSetParam(
     IntPtr Handle,
     uint Level,
     uint Param,
     MsQuicNativeMethods.QuicBuffer Buffer)
 {
     return(SetParamDelegate(
                Handle,
                Level,
                Param,
                Buffer.Length,
                Buffer.Buffer));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }