• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

sshclient.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
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     // Read bytes from the already opened SSH connection
00059     int sshRead(amf::Buffer &buf);
00060     int sshRead(boost::uint8_t *buf, size_t length);
00061     int sshRead(std::string &buf);
00062 
00063     // Write bytes to the already opened SSH connection
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     // Shutdown the Context for this connection
00069     bool sshShutdown();
00070 
00071     // sshConnect() is how the client connects to the server 
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     // Channel operations
00098     ssh_channel openChannel();
00099     ssh_channel openChannel(ssh_session session);
00100 
00101     void closeChannel();
00102     void closeChannel(ssh_channel channel);
00103 
00104     // Accessors
00105     ssh_channel getChannel() { return _channel; };
00106     ssh_session getSession() { return _session; };
00107     boost::shared_ptr<amf::Buffer> &getBuffer()  { return _buffer; };
00108 
00109     // Dump internal data to the screen for debugging
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 } // end of gnash namespace
00133 
00134 // end of GNASH_SSH_CLIENT_H
00135 #endif 
00136 
00137 // local Variables:
00138 // mode: C++
00139 // indent-tabs-mode: t
00140 // End:

Generated on Thu Sep 2 2010 for Gnash by  doxygen 1.7.1