Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;    sshlib_channel.inc - SSH channel
  2. ;
  3. ;    Copyright (C) 2016-2021 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: Open 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. ; >> Channel request: pty
  42.  
  43.         DEBUGF  2, "SSH: Request pty\n"
  44.  
  45.         stdcall sshlib_send_packet, [con_ptr], ssh_msg_channel_request, ssh_msg_channel_request.length, 0
  46.         cmp     eax, 0
  47.         jl      .err
  48.  
  49. ; << Check for channel request confirmation
  50.  
  51.         stdcall sshlib_msg_handler, [con_ptr], 0
  52.         cmp     eax, 0
  53.         jl      .err
  54.  
  55.         mov     esi, [con_ptr]
  56.         cmp     [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
  57.         jne     .err_proto
  58.  
  59. ; >> Channel request: shell
  60.  
  61.         DEBUGF  2, "SSH: Request shell\n"
  62.  
  63.         stdcall sshlib_send_packet, [con_ptr], ssh_msg_shell_request, ssh_msg_shell_request.length, 0
  64.         cmp     eax, 0
  65.         jl      .err
  66.  
  67. ; << Check for channel request confirmation
  68.  
  69. ; TODO: timeout
  70.   .wait_success:
  71.         stdcall sshlib_msg_handler, [con_ptr], 0
  72.         cmp     eax, 0
  73.         jl      .err
  74.  
  75.         mov     esi, [con_ptr]
  76.         cmp     [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
  77.         jne     .wait_success
  78.  
  79.         xor     eax, eax
  80.   .err:
  81.         ret
  82.  
  83.   .err_proto:
  84.         mov     eax, SSHLIB_ERR_PROTOCOL
  85.         ret
  86.  
  87. endp