ne7ssh_transport.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef NE7SSH_TRANSPORT_H
00018 #define NE7SSH_TRANSPORT_H
00019
00020 #include "crypt.h"
00021 #include "ne7ssh_types.h"
00022 #include "ne7ssh_string.h"
00023
00024 #if defined(WIN32) || defined(__MINGW32__)
00025 # include <winsock.h>
00026 #endif
00027 #include <sys/types.h>
00028
00029
00030 #define MAX_PACKET_LEN 34816
00031 #define MAX_SEQUENCE 4294967295U
00032
00033 #if !defined(WIN32) && !defined(__MINGW32__)
00034 # define SOCKET int
00035 #endif
00036
00037 class ne7ssh_session;
00038
00042 class ne7ssh_transport
00043 {
00044 private:
00045 uint32 seq, rSeq;
00046 const ne7ssh_session* session;
00047 SOCKET sock;
00048 Botan::SecureVector<Botan::byte> in;
00049 Botan::SecureVector<Botan::byte> inBuffer;
00050
00057 bool NoBlock (SOCKET socket, bool on);
00058
00066 bool wait (SOCKET socket, int rw, int timeout = -1);
00067
00068 public:
00074 ne7ssh_transport(ne7ssh_session* _session);
00075
00079 ~ne7ssh_transport();
00080
00088 SOCKET establish (const char *host, uint32 port, int timeout = 0);
00089
00096 bool receive (Botan::SecureVector<Botan::byte>& buffer, bool append = false);
00097
00103 bool send (Botan::SecureVector<Botan::byte>& buffer);
00104
00110 bool sendPacket (Botan::SecureVector<Botan::byte>& buffer);
00111
00120 short waitForPacket (Botan::byte cmd, bool bufferOnly = false);
00121
00127 uint32 getPacket (Botan::SecureVector<Botan::byte>& result);
00128
00133 bool haveData ();
00134 };
00135
00136 #endif