1
/***************************************************************************
2
* fqterm, a terminal emulator for both BBS and *nix. *
3
* Copyright (C) 2008 fqterm development group. *
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 2 of the License, or *
8
* (at your option) any later version. *
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. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
19
***************************************************************************/
21
#ifndef FQTERM_SSH_CHANNEL_H
22
#define FQTERM_SSH_CHANNEL_H
24
#include "fqterm_ssh_types.h"
30
class FQTermSSHPacketReceiver;
31
class FQTermSSHPacketSender;
33
class FQTermSSHChannel: public QObject {
38
FQTermSSHPacketReceiver *packet_receiver_;
39
FQTermSSHPacketSender *packet_sender_;
43
virtual ~FQTermSSHChannel(){}
44
virtual void initChannel(FQTermSSHPacketReceiver *packet,
45
FQTermSSHPacketSender *output) = 0;
46
virtual void closeConnection(char *reason) = 0;
48
// TODO: it seems this function isn't used.
49
virtual void changeTermSize(int col, int row) = 0;
51
virtual void sendData(const char *data, int len) = 0;
54
virtual void handlePacket(int type) = 0;
57
void channelReadyRead(const char *data, int len);
58
void channelError(const char *reason);
61
class FQTermSSH1Channel: public FQTermSSHChannel {
64
enum FQTermSSH1ChannelState {
65
BEGIN_SERVICE, REQPTY_SENT,
72
virtual void initChannel(FQTermSSHPacketReceiver *packet, FQTermSSHPacketSender *output);
73
virtual void closeConnection(char *reason);
74
virtual void changeTermSize(int col, int row);
75
virtual void sendData(const char *data, int len);
78
virtual void handlePacket(int type);
80
void channelReadyRead(const char *data, int len);
84
class FQTermSSH2Channel: public FQTermSSHChannel {
87
static u_int32_t generateChannelID();
90
enum FQTermSSH2ChannelState {
91
BEGIN_CHANNEL, REQUEST_PTY_SENT, REQUEST_SHELL_SENT, CHANNEL_OK
94
u_int32_t channel_id_;
96
enum {MAX_LOCAL_WINDOW_SIZE = 0x100000, MAX_LOCAL_PACKET_SIZE = 0x4000};
98
u_int32_t local_window_size_;
100
u_int32_t server_channel_id_;
101
u_int32_t server_window_size_; // connection packet window size;
102
u_int32_t server_max_packet_size_; // max size of each packet sent to server.
106
void processChannelPacket();
107
void checkLocalWindowSize();
111
virtual void initChannel(FQTermSSHPacketReceiver *packet, FQTermSSHPacketSender *output);
112
virtual void closeConnection(char *reason);
113
virtual void changeTermSize(int col, int row);
114
virtual void sendData(const char *data, int len);
117
virtual void handlePacket(int type);
119
void channelReadyRead(const char *data, int len);
122
} // namespace FQTerm
124
#endif // FQTERM_SSH_CHANNEL_H