ne7ssh_connection.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef NE7SSH_CONNECTION_H
00018 #define NE7SSH_CONNECTION_H
00019
00020 #include "ne7ssh_transport.h"
00021 #include "ne7ssh_session.h"
00022 #include "ne7ssh_channel.h"
00023 #include "ne7ssh_keys.h"
00024 #include "crypt.h"
00025 #include "ne7ssh_types.h"
00026 #include "ne7ssh_string.h"
00027 #include "ne7ssh_sftp.h"
00028
00029
00033 class ne7ssh_connection
00034 {
00035 private:
00036 SOCKET sock;
00037 int thisChannel;
00038 ne7ssh_crypt *crypto;
00039 ne7ssh_transport *transport;
00040 ne7ssh_session *session;
00041 ne7ssh_channel *channel;
00042 Ne7sshSftp* sftp;
00043
00044 Ne7ssh_Mutex mut;
00045 bool connected;
00046 bool cmdRunning;
00047 bool cmdClosed;
00048
00049
00054 bool checkRemoteVersion ();
00055
00060 bool sendLocalVersion ();
00061
00067 bool requestService (const char* service);
00068
00075 bool authWithPassword (const char* username, const char* password);
00076
00085 bool authWithKey (const char* username, const char* privKeyFileName);
00086
00087 public:
00091 ne7ssh_connection();
00092
00096 ~ne7ssh_connection();
00097
00109 int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell = true, int timeout = 0);
00110
00122 int connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell = true, int timeout = 0);
00123
00128 SOCKET getSocket () { return sock; }
00129
00133 void handleData ();
00134
00139 void sendData (const char* data);
00140
00144 void setChannelNo (int channelID) { thisChannel = channelID; }
00145
00150 int getChannelNo () { return thisChannel; }
00151
00156 bool data2Send () { return channel->data2Send(); }
00157
00162 void sendData () { channel->sendAll (); }
00163
00169 bool sendCmd (const char* cmd);
00170
00176 bool sendClose ();
00177
00182 bool isOpen () { return channel->isOpen(); }
00183
00188 bool isConnected () { return connected; }
00189
00194 Botan::SecureVector<Botan::byte>& getReceived () { return channel->getReceived(); }
00195
00200 bool getCmdComplete() { return channel->getCmdComplete(); }
00201
00206 bool isCmdClosed() { return cmdClosed; }
00207
00212 bool isRemoteShell () { return channel->isRemoteShell(); }
00213
00218 bool isCmdRunning () { return cmdRunning; }
00219
00224 Ne7sshSftp* startSftp ();
00225
00230 bool isSftpActive ();
00231 };
00232
00233 #endif