internal delegate void KeyboardInteractiveCallback()

in sources/Google.Solutions.Ssh/Native/NativeMethods.cs [357:680]


        internal delegate void KeyboardInteractiveCallback(
            IntPtr namePtr,
            int nameLength,
            IntPtr instructionPtr,
            int instructionLength,
            int numPrompts,
            IntPtr prompts,
            IntPtr responses,
            IntPtr context);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern int libssh2_userauth_keyboard_interactive_ex(
            Libssh2SessionHandle session,
            [MarshalAs(UnmanagedType.LPStr)] string username,
            int usernameLength,
            KeyboardInteractiveCallback callback,
            IntPtr context);

        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        internal delegate int PasswordChangeCallback(
            IntPtr session,
            IntPtr newPasswordPtr,
            IntPtr newPasswordLengthPtr,
            IntPtr context);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern int libssh2_userauth_password_ex(
            Libssh2SessionHandle session,
            [MarshalAs(UnmanagedType.LPStr)] string username,
            int usernameLength,
            [MarshalAs(UnmanagedType.LPStr)] string password,
            int passwordLength,
            PasswordChangeCallback passwordChangeCallback);

        //---------------------------------------------------------------------
        // Channel.
        //---------------------------------------------------------------------

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_close(
            Libssh2ChannelHandle channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_free(
            IntPtr channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern Libssh2ChannelHandle libssh2_channel_open_ex(
            Libssh2SessionHandle session,
            [MarshalAs(UnmanagedType.LPStr)] string channelType,
            uint channelTypeLength,
            uint windowSize,
            uint packetSize,
            [MarshalAs(UnmanagedType.LPStr)] string? message,
            uint messageLength);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern int libssh2_channel_setenv_ex(
            Libssh2ChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string variableName,
            uint variableNameLength,
            [MarshalAs(UnmanagedType.LPStr)] string variableValue,
            uint variableValueLength);


        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern int libssh2_channel_process_startup(
            Libssh2ChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string request,
            uint requestLength,
            [MarshalAs(UnmanagedType.LPStr)] string? message,
            uint messageLength);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_read_ex(
            Libssh2ChannelHandle channel,
            int streamId,
            byte[] buffer,
            IntPtr bufferSize);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_write_ex(
            Libssh2ChannelHandle channel,
            int streamId,
            byte[] buffer,
            IntPtr bufferSize);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_wait_closed(
            Libssh2ChannelHandle channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_wait_eof(
            Libssh2ChannelHandle channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_get_exit_status(
            Libssh2ChannelHandle channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_get_exit_signal(
            Libssh2ChannelHandle channel,
            out IntPtr exitsignal,
            out IntPtr exitsignalLength,
            out IntPtr errmsg,
            out IntPtr errmsgLength,
            out IntPtr langTag,
            out IntPtr langTagLength);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_handle_extended_data2(
            Libssh2ChannelHandle channel,
            LIBSSH2_CHANNEL_EXTENDED_DATA mode);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_eof(
            Libssh2ChannelHandle channel);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        internal static extern int libssh2_channel_request_pty_ex(
            Libssh2ChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string term,
            uint termLength,
            byte[]? modes,
            uint modesLength,
            int width,
            int height,
            int widthPx,
            int heightPx);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_channel_request_pty_size_ex(
            Libssh2ChannelHandle channel,
            int width,
            int height,
            int widthPx,
            int heightPx);

        //---------------------------------------------------------------------
        // SFTP.
        //---------------------------------------------------------------------

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern Libssh2SftpChannelHandle libssh2_sftp_init(
            Libssh2SessionHandle session);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_shutdown(
            IntPtr sftp);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_last_error(
            Libssh2SftpChannelHandle sftp);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_close_handle(
            IntPtr sftp);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern Libssh2SftpFileHandle libssh2_sftp_open_ex(
            Libssh2SftpChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string path,
            uint pathLength,
            LIBSSH2_FXF_FLAGS flags,
            FilePermissions mode,
            LIBSSH2_OPENTYPE openType);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_readdir_ex(
            Libssh2SftpFileHandle handle,
            IntPtr buffer,
            IntPtr bufferSize,
            IntPtr longEntry,
            IntPtr longEntrySize,
            out LIBSSH2_SFTP_ATTRIBUTES attrs);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_mkdir_ex(
            Libssh2SftpChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string path,
            uint pathLength,
            FilePermissions mode);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_rmdir_ex(
            Libssh2SftpChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string path,
            uint pathLength);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_unlink_ex(
            Libssh2SftpChannelHandle channel,
            [MarshalAs(UnmanagedType.LPStr)] string path,
            uint pathLength);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_read(
            Libssh2SftpFileHandle channel,
            byte[] buffer,
            IntPtr bufferSize);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_write(
            Libssh2SftpFileHandle channel,
            IntPtr buffer,
            IntPtr bufferSize);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_sftp_fstat_ex(
            Libssh2SftpFileHandle channel,
            out LIBSSH2_SFTP_ATTRIBUTES attrs,
            int setstat);

        //---------------------------------------------------------------------
        // Keepalive.
        //---------------------------------------------------------------------

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void libssh2_keepalive_config(
            Libssh2SessionHandle session,
            int wantReply,
            uint interval);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_keepalive_send(
            Libssh2SessionHandle session,
            out int secondsToNext);

        //---------------------------------------------------------------------
        // Error functions.
        //---------------------------------------------------------------------

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_session_last_errno(
            Libssh2SessionHandle session);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int libssh2_session_last_error(
            Libssh2SessionHandle session,
            out IntPtr errorMessage,
            out int errorMessageLength,
            int allocateBuffer);

        //---------------------------------------------------------------------
        // Tracing functions.
        //---------------------------------------------------------------------

        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        internal delegate void TraceHandler(
            IntPtr sessionHandle,
            IntPtr context,
            IntPtr data,
            IntPtr length);

        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void libssh2_trace(
            Libssh2SessionHandle session,
            LIBSSH2_TRACE bitmask);


        [DllImport(Libssh2, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void libssh2_trace_sethandler(
            Libssh2SessionHandle session,
            IntPtr context,
            TraceHandler? callback);

        //---------------------------------------------------------------------
        // Winsock.
        //---------------------------------------------------------------------

        internal const uint WSA_WAIT_FAILED = 0xFFFFFFFF;
        internal const uint WSA_WAIT_EVENT_0 = 0;
        internal const uint WSA_WAIT_TIMEOUT = 0x102;
        internal const uint FD_READ = 1;
        internal const uint FD_WRITE = 2;
        internal const uint FD_OOB = 4;
        internal const uint FD_ACCEPT = 8;
        internal const uint FD_CONNECT = 16;
        internal const uint FD_CLOSE = 32;

        [DllImport("Ws2_32.dll")]
        internal static extern WsaEventHandle WSACreateEvent();

        [DllImport("Ws2_32.dll")]
        internal static extern int WSAEventSelect(
            IntPtr socket,
            WsaEventHandle hande,
            uint eventMask);

        [DllImport("Ws2_32.dll")]
        internal static extern bool WSASetEvent(WsaEventHandle hande);

        [DllImport("Ws2_32.dll")]
        internal static extern bool WSAResetEvent(WsaEventHandle hande);

        [DllImport("Ws2_32.dll")]
        internal static extern bool WSACloseEvent(IntPtr hande);

        [DllImport("Ws2_32.dll")]
        internal static extern uint WSAWaitForMultipleEvents(
            uint cEvents,
            IntPtr[] pEvents,
            bool fWaitAll,
            uint timeout,
            bool fAlterable);

        [DllImport("Ws2_32.dll")]
        internal static extern int WSAEnumNetworkEvents(
            IntPtr socket,
            WsaEventHandle eventHandle,
            ref WSANETWORKEVENTS eventInfo);

        [DllImport("Ws2_32.dll")]
        internal static extern int WSAGetLastError();


        [StructLayout(LayoutKind.Sequential)]
        internal struct WSANETWORKEVENTS
        {
            internal int lNetworkEvents;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
            internal int[] iErrorCode;
        }