Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GNASH_SSH_CLIENT_H
00020 #define GNASH_SSH_CLIENT_H
00021
00022 #include <string>
00023 #include <boost/array.hpp>
00024 #include <boost/shared_ptr.hpp>
00025 #include <boost/shared_array.hpp>
00026 #include <boost/scoped_array.hpp>
00027 #include <boost/cstdint.hpp>
00028 #include <sstream>
00029
00030 extern "C" {
00031 #include <libssh/libssh.h>
00032 #include <libssh/sftp.h>
00033 }
00034
00035 #include "cque.h"
00036 #include "network.h"
00037 #include "buffer.h"
00038
00039 namespace gnash
00040 {
00041
00042 extern const char *ROOTPATH;
00043 extern const char *HOST;
00044 extern const char *CA_LIST;
00045 extern const char *RANDOM;
00046 extern const char *KEYFILE;
00047 extern const size_t SSH_PASSWD_SIZE;
00048
00049 class DSOEXPORT SSHClient
00050 {
00051 public:
00052 typedef enum {NO_AUTHTYPE, DSS, RSA} authtype_t;
00053 typedef enum {NO_TRANSPORT, RAW, SFTP} transport_type_t;
00054
00055 SSHClient();
00056 ~SSHClient();
00057
00058
00059 int sshRead(amf::Buffer &buf);
00060 int sshRead(boost::uint8_t *buf, size_t length);
00061 int sshRead(std::string &buf);
00062
00063
00064 int sshWrite(amf::Buffer &buf);
00065 int sshWrite(const boost::uint8_t *buf, size_t length);
00066 int sshWrite(std::string &buf);
00067
00068
00069 bool sshShutdown();
00070
00071
00072 bool sshConnect(int fd);
00073 bool sshConnect(int fd, std::string &hostname);
00074
00075 void setUser();
00076 void setUser(std::string name) { _user = name; };
00077 std::string &getUser() { return _user; };
00078
00079 void setPassword(std::string pw) { _password = pw; };
00080 std::string &getPassword() { return _password; };
00081
00082 void setHostname(std::string name) { _hostname = name; };
00083 std::string &getHostname() { return _hostname; };
00084
00085 void setServerAuth(bool flag) { _need_server_auth = flag; };
00086 bool getServerAuth() { return _need_server_auth; };
00087
00088 void setAuthType(authtype_t type) { _authtype = type; };
00089 authtype_t getAuthType() { return _authtype; };
00090
00091 void setTransportType(transport_type_t type) { _transporttype = type; };
00092 transport_type_t getTransportType() { return _transporttype; };
00093
00094 int authKbdint();
00095 int authKbdint(ssh_session);
00096
00097
00098 ssh_channel openChannel();
00099 ssh_channel openChannel(ssh_session session);
00100
00101 void closeChannel();
00102 void closeChannel(ssh_channel channel);
00103
00104
00105 ssh_channel getChannel() { return _channel; };
00106 ssh_session getSession() { return _session; };
00107 boost::shared_ptr<amf::Buffer> &getBuffer() { return _buffer; };
00108
00109
00110 void dump();
00111 protected:
00112 int readChannel (ssh_channel channel, amf::Buffer &buf);
00113 int writeChannel(ssh_channel channel, amf::Buffer &buf);
00114
00115 std::string _hostname;
00116 std::string _user;
00117 std::string _password;
00118 bool _need_server_auth;
00119 authtype_t _authtype;
00120 transport_type_t _transporttype;
00121 int _state;
00122 #if 0
00123 boost::shared_ptr<ssh_session> _session;
00124 boost::shared_ptr<SSH_OPTIONS> _options;
00125 #else
00126 ssh_session _session;
00127 ssh_channel _channel;
00128 #endif
00129 boost::shared_ptr<amf::Buffer> _buffer;
00130 };
00131
00132 }
00133
00134
00135 #endif
00136
00137
00138
00139
00140