Subversion Repositories Kolibri OS

Rev

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

  1. ;    sshlib_channel.inc - SSH channel
  2. ;
  3. ;    Copyright (C) 2016-2024 Jeffrey Amelynck
  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 <http://www.gnu.org/licenses/>.
  17.  
  18.  
  19. proc sshlib_chan_open con_ptr; Channel struct ptr?!
  20.  
  21. ; >> Open channel
  22.  
  23.         DEBUGF  2, "SSH: Opening channel\n"
  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.  
  41.         DEBUGF  2, "SSH: Channel opened successfully\n"
  42.  
  43. ; >> Channel request: pty
  44.  
  45.         DEBUGF  2, "SSH: Requesting PTY\n"
  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.  
  61.         DEBUGF  2, "SSH: PTY opened successfully\n"
  62.  
  63. ; >> Channel request: shell
  64.  
  65.         DEBUGF  2, "SSH: Requesting shell\n"
  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.  
  83.         DEBUGF  2, "SSH: Shell opened successfully\n"
  84.  
  85.         xor     eax, eax
  86.   .err:
  87.         ret
  88.  
  89.   .err_proto:
  90.         mov     eax, SSHLIB_ERR_PROTOCOL
  91.         ret
  92.  
  93. endp
  94.