ne7ssh_transport.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
00003  *   Author: Andrew Useckas                                                *
00004  *   Email: andrew@netsieben.com                                           *
00005  *                                                                         *
00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
00007  *                                                                         *
00008  *   This program may be distributed under the terms of the Q Public       *
00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
00010  *   file LICENSE.QPL included in the packaging of this file.              *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
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 //#define MAX_PACKET_LEN 35000
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

Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  doxygen 1.5.9