Subversion Repositories Kolibri OS

Rev

Rev 9106 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9106 hidnplayr 1
;    sshlib_channel.inc - SSH channel
2
;
9987 hidnplayr 3
;    Copyright (C) 2016-2024 Jeffrey Amelynck
9106 hidnplayr 4
;
5
;    This program is free software: you can redistribute it and/or modify
6
;    it under the terms of the GNU General Public License as published by
7
;    the Free Software Foundation, either version 3 of the License, or
8
;    (at your option) any later version.
9
;
10
;    This program is distributed in the hope that it will be useful,
11
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
;    GNU General Public License for more details.
14
;
15
;    You should have received a copy of the GNU General Public License
16
;    along with this program.  If not, see .
17
 
18
 
19
proc sshlib_chan_open con_ptr; Channel struct ptr?!
20
 
21
; >> Open channel
22
 
9987 hidnplayr 23
        DEBUGF  2, "SSH: Opening channel\n"
9106 hidnplayr 24
 
25
        mov     [ssh_chan.rcv_wnd], BUFFERSIZE
26
        mov     [ssh_chan.snd_wnd], 0
27
        stdcall sshlib_send_packet, [con_ptr], ssh_msg_channel_open, ssh_msg_channel_open.length, 0
28
        cmp     eax, 0
29
        jl      .err
30
 
31
; << Check for channel open confirmation
32
 
33
        stdcall sshlib_msg_handler, [con_ptr], 0
34
        cmp     eax, 0
35
        jl      .err
36
 
37
        mov     esi, [con_ptr]
38
        cmp     [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_OPEN_CONFIRMATION
39
        jne     .err_proto
40
 
9987 hidnplayr 41
        DEBUGF  2, "SSH: Channel opened successfully\n"
42
 
9106 hidnplayr 43
; >> Channel request: pty
44
 
9987 hidnplayr 45
        DEBUGF  2, "SSH: Requesting PTY\n"
9106 hidnplayr 46
 
47
        stdcall sshlib_send_packet, [con_ptr], ssh_msg_channel_request, ssh_msg_channel_request.length, 0
48
        cmp     eax, 0
49
        jl      .err
50
 
51
; << Check for channel request confirmation
52
 
53
        stdcall sshlib_msg_handler, [con_ptr], 0
54
        cmp     eax, 0
55
        jl      .err
56
 
57
        mov     esi, [con_ptr]
58
        cmp     [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
59
        jne     .err_proto
60
 
9987 hidnplayr 61
        DEBUGF  2, "SSH: PTY opened successfully\n"
62
 
9106 hidnplayr 63
; >> Channel request: shell
64
 
9987 hidnplayr 65
        DEBUGF  2, "SSH: Requesting shell\n"
9106 hidnplayr 66
 
67
        stdcall sshlib_send_packet, [con_ptr], ssh_msg_shell_request, ssh_msg_shell_request.length, 0
68
        cmp     eax, 0
69
        jl      .err
70
 
71
; << Check for channel request confirmation
72
 
73
; TODO: timeout
74
  .wait_success:
75
        stdcall sshlib_msg_handler, [con_ptr], 0
76
        cmp     eax, 0
77
        jl      .err
78
 
79
        mov     esi, [con_ptr]
80
        cmp     [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
81
        jne     .wait_success
82
 
9987 hidnplayr 83
        DEBUGF  2, "SSH: Shell opened successfully\n"
84
 
9106 hidnplayr 85
        xor     eax, eax
86
  .err:
87
        ret
88
 
89
  .err_proto:
90
        mov     eax, SSHLIB_ERR_PROTOCOL
91
        ret
92
 
9987 hidnplayr 93
endp