[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Moss-devel] CVS: moss/rmc/include/Transport Makefile.am,NONE,1.1 SSLExc
From: |
Alexander Feder <address@hidden> |
Subject: |
[Moss-devel] CVS: moss/rmc/include/Transport Makefile.am,NONE,1.1 SSLExceptions.h,NONE,1.1 SSLSocket.h,NONE,1.1 SSLSocketNamed.h,NONE,1.1 SSLSocketUnNamed.h,NONE,1.1 Socket.h,NONE,1.1 SocketNamed.h,NONE,1.1 SocketUnNamed.h,NONE,1.1 TransportBufferInterface.h,NONE,1.1 TransportClient.h,NONE,1.1 TransportClientHandler.h,NONE,1.1 TransportClientInterface.h,NONE,1.1 TransportClientSSLSocket.h,NONE,1.1 TransportClientSocket.h,NONE,1.1 TransportServer.h,NONE,1.1 TransportServerSSLSocket.h,NONE,1.1 TransportServerSocket.h,NONE,1.1 |
Date: |
Sun, 23 Jun 2002 09:27:51 -0400 |
Update of /cvsroot/moss/moss/rmc/include/Transport
In directory subversions:/tmp/cvs-serv2212/include/Transport
Added Files:
Makefile.am SSLExceptions.h SSLSocket.h SSLSocketNamed.h
SSLSocketUnNamed.h Socket.h SocketNamed.h SocketUnNamed.h
TransportBufferInterface.h TransportClient.h
TransportClientHandler.h TransportClientInterface.h
TransportClientSSLSocket.h TransportClientSocket.h
TransportServer.h TransportServerSSLSocket.h
TransportServerSocket.h
Log Message:
added rmc
--- NEW FILE ---
EXTRA_DIST = TransportClient.h TransportClientInterface.h
TransportClientSocket.h TransportServer TransportServerSocket.h
TransportClientHandler.h TransportBufferInterface.h
install-data-local:
$(mkinstalldirs) $(prefix)/include/RMC/Transport
$(INSTALL_DATA) TransportClientInterface.h
$(prefix)/include/RMC/Transport/TransportClientInterface.h
$(INSTALL_DATA) TransportClient.h
$(prefix)/include/RMC/Transport/TransportClient.h
$(INSTALL_DATA) TransportClientSocket.h
$(prefix)/include/RMC/Transport/TransportClientSocket.h
$(INSTALL_DATA) TransportServer.h
$(prefix)/include/RMC/Transport/TransportServer.h
$(INSTALL_DATA) TransportServerSocket.h
$(prefix)/include/RMC/Transport/TransportServerSocket.h
$(INSTALL_DATA) TransportClientHandler.h
$(prefix)/include/RMC/Transport/TransportClientHandler.h
$(INSTALL_DATA) TransportBufferInterface.h
$(prefix)/include/RMC/Transport/TransportBufferInterface.h
--- NEW FILE ---
/***************************************************************************
SSLExceptions.h - description
-------------------
begin : Fri October 5 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
class ESSLWrongPassword
{
ESSLWrongPassword();
};
class ESSLNoValidKeyfile
{
ESSLNoValidKeyfile();
};
class ESSLNoValidCA_LIST
{
ESSLNoValidCA_LIST();
};
class ESSLClientCertificateException
{
ESSLClientCertificateException();
};
/*
// FATAL Exceptions
class ESSLContextFailed
{
ESSLContextFailed();
};
*/
--- NEW FILE ---
/***************************************************************************
SSLSocket.h - description
-------------------
begin : Thu June 07 2001
copyright : (C) 2001 Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __SSL_SOCKET_H
#define __SSL_SOCKET_H
#if _MSC_VER > 1000
#pragma ones
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "Socket.h"
#include <openssl/ssl.h>
extern "C"
{
void SSLInit();
}
namespace family
{
// the CSSLSocket is a kind of Socket
class CSSLSocket : public CSocket
{
// Extra for SSL Housekeeping
private:
static string skeyFile;
static string spassword;
static void certificateLoad();
protected:
static SSL_CTX *context;
SSL *ssl;
BIO *sbio;
protected:
void Initialize ( );
//- virtual LONG MyWrite ( const void*, LONG );
virtual LONG MyRead ( void*, LONG );
public:
static void ctxInit(); // should be friend or so
CSSLSocket ( int nSocket, sockaddr_in& st_SocketAddress );
CSSLSocket ( );
virtual ~CSSLSocket();
}; // class CSSLSocket
int pem_passwd_cb(char *buf, int size, int rwflag, void *password);
}; // namespace family
#endif // #ifndef __SSL_SOCKET_H
--- NEW FILE ---
/***************************************************************************
SSLSocketNamed.h - description
-------------------
begin : Thu June 21 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __SSL_SOCKET_NAMED_H
#define __SSL_SOCKET_NAMED_H
#if _MSC_VER > 1000
#pragma ones
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "SSLSocket.h"
#include "SSLSocketUnNamed.h"
namespace family
{
class CSSLSocketNamed : public CSSLSocket
{
private:
fd_set m_stFdCheckIt;
public:
CSSLSocketNamed ();
virtual ~CSSLSocketNamed ();
private:
virtual CSSLSocketUnNamed* Accept ();
public:
virtual int Bind ( int nPort );
virtual int Listen (int nbOfClients = 32);
virtual CSSLSocketUnNamed* WaitForClient ();
}; // class CSSLSocketNamed
}; // namespace family
#endif // __SSL_SOCKET_NAMED_H
--- NEW FILE ---
/***************************************************************************
SSLSocketUnNamed.h - description
-------------------
begin : Thu June 21 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __SSL_SOCKET_UNNAMED_H
#define __SSL_SOCKET_UNNAMED_H
#if _MSC_VER > 1000
#pragma ones
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "SSLSocket.h"
namespace family
{
class CSSLSocketUnNamed : public CSSLSocket
{
public:
CSSLSocketUnNamed ( int nSocket, sockaddr_in& st_SocketAddress );
CSSLSocketUnNamed ( );
virtual ~CSSLSocketUnNamed ( );
int Connect( string sAddress, int nPort );
}; // class CSSLSocketUnNamed
}; // namespace family
#endif // __SSL_SOCKET_UNNAMED_H
--- NEW FILE ---
/***************************************************************************
Socket.h
-------------------
begin : Thu June 07 2001
copyright : (C) 2001 Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************
2001-12-18 Manfred Morgner
* changed to "all inline" - no cxx file anymore
! If you wish to use this class under any win32-derivate, please insert
the following 3 lines into you main code file:
#ifdef WIN32
bool CSocket::s_bWinSocketOk = CSocket::WinSocketInitialize();
#endif // WIN32
***************************************************************************/
#ifndef __SOCKET_H
#define __SOCKET_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#define CONNECTION_TIMEOUT 50
//- #include "rmc.h"
//#include "Transport/TransportBufferInterface.h"
#include "TransportBufferInterface.h"
#include <stdio.h>
#include <list>
#ifdef WIN32
# include <io.h>
#else // WIN32
# include <unistd.h>
# include <arpa/inet.h>
# include <sys/time.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
# include <sys/ioctl.h>
#endif // else WIN32
#include <sys/types.h>
namespace family
{
//- typedef std::list<void*> CListPtrPv;
//- typedef std::list<LONG> CListLong;
typedef std::pair<LONG, void*> CPairEntry;
typedef std::list<CPairEntry*> CListEntries;
// the CSocket is a kind of transport buffer
class CSocket : public rmc::CTransportBufferInterface
{
#ifdef WIN32
private:
static bool s_bWinSocketOk;
static bool WinSocketInitialize()
{
WSADATA wsaData;
//+ KM: here should go some checks into the methode
if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) != 0 )
{
return false;
}
return true;
} // static bool WinSocketInitialize()
#endif // WIN32
protected:
sockaddr_in m_stSocketAddress; // structure containing socket address info
int m_nSocket; // file descriptor of this socket
//- CListPtrPv m_lnPvOut;
//- CListLong m_lnLOut;
CListEntries m_lpEntries;
LONG m_nInSize;
LONG m_nInPos;
UCHAR *m_pucIn;
public:
CSocket( )
{
Initialize ();
m_nSocket = socket(AF_INET, SOCK_STREAM, 0);
}
CSocket(int nSocket, sockaddr_in& rstSocketAddress)
{
Initialize ();
m_nSocket = nSocket;
m_stSocketAddress = rstSocketAddress;
}
virtual ~CSocket()
{
TRACE("CSocket Destructor\n")
if ( m_pucIn != 0 )
{
delete m_pucIn;
// TRACE(", deleted m_pucIn")
}
if (m_nSocket)
{
close(m_nSocket);
}
TRACE("CSocket Destructor End\n")
} // CSocket::~CSocket ( )
int FdGet()
{
return m_nSocket;
} // int FdGet()
virtual bool IdentSet(const std::string& sText)
{
if (sText.length() != 4)
{
TRACE("BUG! Check where the ident was set wrong..")
// exit(1);
}
return Push ( (UCHAR*) sText.c_str(), 4 );
} // bool IdentSet(const std::string& sText)
virtual std::string IdentGet()
{
UCHAR* pcTemp = 0;
Pop ( pcTemp, 4 );
char* pcTempNew = new char[5];
memcpy ( pcTempNew, pcTemp, 4 );
pcTempNew[4] = '\0';
return pcTempNew;
} // string CSocket::GetIdent ( )
virtual rmc::CTransportBufferInterface& operator << (LONG nValue)
{
Push(nValue);
return *this;
} // rmc::CTransportBufferInterface& operator << (LONG nValue)
virtual bool Push(LONG nValue)
{
return Push((void*) &nValue, sizeof(nValue));
} // bool Push(LONG nValue)
//- virtual bool Push ( UCHAR*, const LONG& );
virtual bool Push(const void* pData, const LONG nSize)
{
void *p = new char[nSize];
memcpy(p, pData, nSize);
m_lpEntries.push_back(new CPairEntry(nSize, p));
return true;
} // bool Push(const void* pData, const LONG nSize)
virtual rmc::CTransportBufferInterface& operator >> (LONG& rnValue)
{
Pop(rnValue);
return *this;
} // rmc::CTransportBufferInterface& operator >> (LONG& rnValue)
virtual rmc::CTransportBufferInterface& operator >> (UCHAR*& rpucData)
{
Pop(rpucData);
return *this;
} // rmc::CTransportBufferInterface& operator >> (UCHAR*& rpucBuffer)
virtual bool Pop(LONG& rnLong)
{
memcpy (&rnLong, &m_pucIn[m_nInPos], sizeof(rnLong));
m_nInPos += sizeof (rnLong);
return true;
} // bool Pop(LONG& rnLong)
virtual bool Pop(UCHAR*& rpucChar, const LONG nSize)
{
rpucChar = new UCHAR[nSize];
if ( ( m_nInPos + nSize ) <= m_nInSize )
{
memcpy ( rpucChar, m_pucIn + m_nInPos, nSize );
m_nInPos += nSize;
return true;
} // if ( ( m_nInPos + nSize ) <= m_nInSize )
return false;
} // bool Pop(UCHAR*& rpucBuffer, const LONG nSize)
virtual bool Pop(UCHAR*& rpucChar)
{
if (m_nInPos <= m_nInSize)
{
rpucChar = new UCHAR[m_nInSize - m_nInPos ];
memcpy (rpucChar, m_pucIn + m_nInPos, m_nInSize-m_nInPos);
return true;
}
return false;
} // bool Pop(UCHAR*& rpucBuffer)
virtual bool Send()
{
LONG nSize = 0;
CListEntries::iterator it;
for ( it = m_lpEntries.begin(); it != m_lpEntries.end(); ++it )
{
nSize += (*it)->first;
} // for ( it = m_lnLOut.begin(); it != m_lnLOut.end(); ++it )
UCHAR* pucOut = new UCHAR[nSize];
it = m_lpEntries.begin();
//- LONG nSizeTemp = 0;
for (LONG nPos = 0; it != m_lpEntries.end(); ++it)
{
memcpy ( &pucOut[nPos], (*it)->second, (*it)->first );
delete (*it)->second;
(*it)->second = 0;
nPos += (*it)->first;
} // for ( lPv::iterator lpIt = m_lnPvOut.begin(); lpIt !=
m_lnPvOut.end(); ++lpIt)
m_lpEntries.clear();
// at first, we send the size of the coming buffer
LONG nNetSize = htonl ( nSize ); //convert to network byteorder
LONG nResult = Write( (UCHAR*)&nNetSize, sizeof (nNetSize) );
if (nResult == 0)
{
return Write(pucOut, nSize) == 0;
}
return false;
} // bool Send ( )
virtual LONG Recv()
{
if (m_pucIn != 0)
{
delete m_pucIn;
m_pucIn = 0;
}
LONG nResult = Read((void*&)m_pucIn, m_nInSize);
m_nInPos = 0;
return (nResult == 0) ? m_nInSize : -1 ;
} // LONG CSocket::Recv ( )
protected:
void Initialize()
{
m_stSocketAddress.sin_family = AF_INET;
m_stSocketAddress.sin_addr.s_addr = htonl(INADDR_ANY);
m_nSocket = 0;
m_pucIn = 0;
m_nInSize = 0;
m_nInPos = 0;
} // void Initialize ( )
//- virtual LONG MyWrite ( const void* pData, LONG nSize);
virtual LONG MyRead(void* pBuffer, LONG nSize)
{
for ( int nPos = 0, nRcvd = 0, nTimeout = 0; nPos < nSize; nPos +=
nRcvd)
{
nTimeout++;
if ( nTimeout > CONNECTION_TIMEOUT )
{
return -1;
} // if ( nTimeout > CONNECTION_TIMEOUT )
#ifdef WIN32
nRcvd = recv(m_nSocket, ((char*)pBuffer) + nPos , nSize -
nPos, 0);
#else // WIN32
nRcvd = read(m_nSocket, (void*)(((char*)pBuffer) + nPos), nSize -
nPos);
#endif // else WIN32
if ( nRcvd < 0 )
{
perror ("read: ");
return nRcvd;
} // if ( nRcvd < 0 )
} // for ( int nPos = 0, nRcvd = 0, nTimeout = 0; nPos < nCount; nPos
+= nRcvd)
return 0; // success
}; // LONG CSocket::MyRead(void* pBuffer, LONG nSize)
LONG Write(const void* pData, LONG nSize)
{
for ( int nPos = 0, nSent = 0, nTimeout = 0; nPos < nSize; nPos +=
nSent)
{
nTimeout++;
if ( nTimeout > CONNECTION_TIMEOUT )
{
return -1;
} // if ( nTimeout > CONNECTION_TIMEOUT )
#ifdef WIN32
nSent = send (m_nSocket, ((char*)pData) + nPos , nSize -
nPos, 0);
#else // WIN32
nSent = write(m_nSocket, (void*)(((char*)pData) + nPos), nSize -
nPos);
#endif // else WIN32
if ( nSent < 0 )
{
perror ("write: ");
return nSent;
} // if ( nSent < 0 )
} // for ( int i = 0, nSent = 0; i < nCount; i += nSent)
return 0; // success
}; // LONG CSocket::MyWrite ( const void *cvBuf, LONG nCount )
LONG Read(void*& rpBuffer, LONG &rnSize)
{
rnSize = 0;
if ( MyRead ( (unsigned char*) &rnSize, sizeof ( rnSize ) ) < 0 )
{
return -1;
}
rnSize = ntohl ( rnSize ); //convert to host-byteorder
rpBuffer = new UCHAR[rnSize];
// we have to return the count for the realy reed bytes
return MyRead ( rpBuffer, rnSize );
} // LONG CSocket::Read (void*& rpBuffer, LONG &rnSize)
}; // class CSocket
}; // namespace family
#endif // #ifndef __SOCKET_H
--- NEW FILE ---
/***************************************************************************
SocketNamed.h
-------------------
begin : Thu June 21 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************
2001-12-18 Manfred Morgner
* changed to "all inline" - no cxx file anymore
***************************************************************************/
#ifndef __SOCKET_NAMED_H
#define __SOCKET_NAMED_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "Socket.h"
#include "SocketUnNamed.h"
namespace family
{
class CSocketNamed : public CSocket
{
private:
fd_set m_stFdCheckIt;
public:
// SERVERSIDE
CSocketNamed()
: CSocket()
{
TRACE("CSocketNamed Construktor\n")
} // CSocketNamed ()
virtual ~CSocketNamed()
{
TRACE("CSocketNamed Destruktor\n")
} // ~CSocketNamed()
private:
CSocketUnNamed* Accept()
{
sockaddr_in stClientAddress;
#ifdef WIN32
int nSize = sizeof(stClientAddress);
#else // WIN32
size_t nSize = sizeof(stClientAddress);
#endif // else WIN32
int nSocket = accept( m_nSocket, (struct sockaddr *)&stClientAddress,
&nSize);
return new CSocketUnNamed(nSocket, stClientAddress);
} // CSocketUnNamed* Accept()
public:
// SERVERSIDE
int Bind(int nPort)
{
m_stSocketAddress.sin_port = htons(nPort);
if (bind (m_nSocket, (struct sockaddr*)&m_stSocketAddress, sizeof
(m_stSocketAddress)))
{
TRACE("Can't bind socket!\n")
perror("bind: ");
return -5;
} // if (bind (nServerSocket, (struct sockaddr*)&stServerAddress,
sizeof (stServerAddress)))
return m_nSocket;
} // int Bind(int nPort)
// Manfred Morgner: 15.11.2001
// new behavior of tcp in kernel after 2.2 changes the
// meaning of the parameter from "count of uncomplete
// simulatniouse connections" to "size of queue"
// that's why I changed the default for the parameter
// from 32 to SOMAXCONN, defined in socket.h
int Listen (int nbOfClients = SOMAXCONN)
{
TRACE("[Listening for connections...\n")
#ifdef _DEBUG
std::cout << "\tSocket: " << m_nSocket << std::endl;
std::cout << "\tCCount: " << nbOfClients << std::endl;
#endif // _DEBUG
// Manfred Morgner, 15.11.2001:
// I think it's best to do explicite comparation to
// express what the if-statemant has to compare
// - ok, this is simple for programmers,
// but some times, even programmers are wrong during
// loocking to foreign code (as I)
if (listen (m_nSocket, nbOfClients) != 0)
{
TRACE("Can't listen on socket!\n")
// Manfred Morgner, 15.11.2001:
//+ is anyone able to return a "speaking value" here?
//+ like E_CANT_LISTEN ?
return -4;
} // if (m_nSocket, nbOfClients)
TRACE("\tSocket: ok\n")
return m_nSocket;
} // int CSocketNamed::Listen(int nbOfClients=32)
CSocketUnNamed* WaitForClient()
{
FD_ZERO(&m_stFdCheckIt);
FD_SET (m_nSocket, &m_stFdCheckIt);
TRACE("Waiting for client..\n")
int nFdMax = m_nSocket + 1;
#ifdef WIN32
// in Win32. the first parameter is ignored
if (select (0, &m_stFdCheckIt, 0, 0, 0) < 0)
#else // WIN32
if (select (nFdMax, &m_stFdCheckIt, 0, 0, 0) < 0)
#endif // else WIN32
{
TRACE("Error in Network::waitForConnection: select!\n")
return 0;
} // if (select (m_nSocket, &m_stFdCheckIt,(fd_set*)0, (fd_set*)0,
(struct timeval *)0) < 0)
TRACE("CLIENT?\n")
if ( FD_ISSET(m_nSocket, &m_stFdCheckIt) ) // Is fd in our set ?
{
CSocketUnNamed* poSocketClient = Accept(); //gets the effective
UnNamed Socket
#ifdef _DEBUG
std::cout << "Added client on socket [" << poSocketClient->FdGet() <<
"]" << std::endl;
#endif // _DEBUG
return poSocketClient;
}
else
{
return 0;
//huh?
}
return 0;
} // CSocketUnNamed* WaitForClient ()
}; // class CSocketNamed
}; // namespace family
#endif // __SOCKET_NAMED_H
--- NEW FILE ---
/***************************************************************************
SocketUnNamed.h
-------------------
begin : Thu June 21 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************
2001-12-18 Manfred Morgner
* changed to "all inline" - no cxx file anymore
***************************************************************************/
#ifndef __SOCKET_UNNAMED_H
#define __SOCKET_UNNAMED_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "Socket.h"
#include <string>
namespace family
{
class CSocketUnNamed : public CSocket
{
public:
CSocketUnNamed()
: CSocket ()
{
TRACE("CSocketUnNamed Constructor()\n");
}
CSocketUnNamed(int nSocket, sockaddr_in& st_SocketAddress )
: CSocket ( nSocket, st_SocketAddress )
{
TRACE("CSocketUnNamed Constructor(...)\n");
}
virtual ~CSocketUnNamed()
{
TRACE("CSocketUnNamed Destructor\n");
}
int Connect(std::string sAddress, int nPort)
{
TRACE("Resolving [") TRACE(sAddress) TRACE("]\n")
// memory leak ?? no delete for this needed ?
hostent* pstHost = gethostbyname ( sAddress.c_str() );
#ifdef _DEBUG
std::cout << "Connecting to [" << pstHost->h_name << "] [" << inet_ntoa
( * ( (in_addr*) pstHost->h_addr ) ) << "]" << std::endl;
#endif // _DEBUG
m_stSocketAddress.sin_family = AF_INET;
m_stSocketAddress.sin_addr.s_addr = inet_addr( inet_ntoa(
*((in_addr*)pstHost->h_addr) ) );
m_stSocketAddress.sin_port = htons(nPort);
// bzero ( & ( m_stSocketAddress.sin_zero ), 8 );
memset( &(m_stSocketAddress.sin_zero),0, 8 );
if ( connect ( m_nSocket, (sockaddr *) &m_stSocketAddress, sizeof (
m_stSocketAddress ) ) )
{
return -5; // CANT CONNECT
} // if ( connect ( m_nS..
return m_nSocket;
} // CSocketUnNamed::Connect (std::string sAddress, int nPort)
}; // class CSocketUnNamed
}; // namespace family
#endif // __SOCKET_UNNAMED_H
--- NEW FILE ---
/***************************************************************************
TransportBufferInterface.h
-------------------
begin : Thu June 07 2001
copyright : (C) 2001 Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_BUFFER_INTERFACE_H
#define __TRANSPORT_BUFFER_INTERFACE_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include <string>
//+
// because of "LONG" - this has to go in an other header
// the transport does not depend on rmc but vice versa!
// #include "rmc.h"
namespace rmc
{
// typedef unsigned char uchar; // maybe better in rmc.h
class CTransportBufferInterface
{
public:
virtual bool IdentSet( const std::string& sText ) = 0;
// ?? virtual const string& GetIdent() = 0;
virtual std::string IdentGet( ) = 0;
virtual CTransportBufferInterface& operator << ( LONG nValue ) = 0;
virtual bool Push ( LONG nValue ) = 0;
//- virtual bool Push ( UCHAR*, const LONG& ) = 0;
virtual bool Push ( const void* pData, const LONG nSize ) = 0;
virtual CTransportBufferInterface& operator >> ( LONG& rnValue ) = 0;
virtual CTransportBufferInterface& operator >> ( UCHAR*& rpucBuffer ) = 0;
virtual bool Pop ( LONG& rnValue) = 0;
virtual bool Pop ( UCHAR*& rpucBuffer, const LONG nSize ) = 0;
virtual bool Pop ( UCHAR*& rpucBuffer) = 0;
//virtual bool operator >> ( long& ) = 0;
//virtual bool operator >> ( UCHAR* ) = 0;
virtual bool Send ( ) = 0;
virtual LONG Recv ( ) = 0;
}; // class CTransportBufferInterface
}; // namespace rmc
#endif // #ifndef __CTRANSPORT_BUFFER_INTERFACE_H
--- NEW FILE ---
/***************************************************************************
TransportClient.h
-------------------
begin : Thu June 07 2001
copyright : (C) 2001 by Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_SOCKET_H
#define __TRANSPORT_SOCKET_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
#include <stdio.h>
#include "Transport/TransportClientInterface.h"
#include "Transport/TransportBufferInterface.h"
using namespace std;
namespace rmc
{
//class CTransportClient;
//extern CTransportClient g_oSocketClient;
class CTransportClient : public CTransportClientInterface
{
protected:
CTransportBufferInterface* m_poTransportBufferClient;
string m_sLoginName;
string m_sPassword;
long m_nLastRmcResult;
public:
CTransportClient ( );
virtual ~CTransportClient ( );
virtual LONG RemoteSystemConfig ( const string& sComputer,
const string& sLogin = "",
const string& sPasswd = "");
virtual TTransResult RmcConnect ( TRmcClass nClass,
TRmcObject &rnObject,
TRmcVisum &rnVisum );
virtual TTransResult RmcCall ( TRmcObject nObject,
TRmcVisum &rnVisum,
TRmcMethode nMethode,
TRmcSize &rnSize,
TRmcData *&rpcData,
TRmcResult &rnResult );
virtual TTransResult RmcRelease ( TRmcObject nObject,
TRmcVisum nVisum );
protected:
void Initialize ( );
virtual LONG Connect ( )=0;
LONG Authenticate ( );
//LONG Write ( unsigned char* pucData, LONG nSize );
//LONG Read ( unsigned char** ppucData );
}; // class CTransportClient
}; // namespace rmc
#endif // #ifndef __SOCKET_CLIENT_H
--- NEW FILE ---
/***************************************************************************
TransportClientHandler.h
-------------------
begin : Fri June 29 2001
copyright : (C) 2001 Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_CLIENT_HANDLER_H
#define __TRANSPORT_CLIENT_HANDLER_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include <family/Threaded.h>
#include "rmc.h"
#include "RmcServer.h"
#include "Transport/TransportBufferInterface.h"
namespace rmc
{
class CTransportClientHandler : public family::CThreaded
{
protected:
CRmcServer **m_ppoRmcServer;
CTransportBufferInterface* m_poSocketClient;
void HandleRmcConnect ();
void HandleRmcCall ();
void HandleRmcRelease ();
long Step ();
public:
CTransportClientHandler(CTransportBufferInterface*
poClientSocket, CRmcServer *&m_rpoRmcServer );
virtual ~CTransportClientHandler();
void Initialize ();
}; // class CTransportSocketClientHandler
}; // namespace rmc
#endif // #ifndef __CLIENTHANDLER_H
--- NEW FILE ---
/***************************************************************************
TransportClientInterface.h
-------------------
begin : Thu June 19 2001
copyright : (C) 2001 by Manfred Morgner
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_CLIENT_H
#define __TRANSPORT_CLIENT_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
namespace rmc
{
class CTransportClientInterface;
enum
{
RMC_TRANS_CONN = 0,
RMC_TRANS_CALL = 1,
RMC_TRANS_RELE = 2
};
extern "C"
{
// import for/from client transport library
typedef CTransportClientInterface* (*pfnGetTransport)();
}; // extern "C"
class CTransportClientInterface
{
public:
virtual ~CTransportClientInterface ( ) { /* nothings */ };
virtual LONG RemoteSystemConfig ( const std::string& sComputer,
const std::string& sLogin = "",
const std::string& sPasswd = "") = 0;
virtual TTransResult RmcConnect ( TRmcClass nClass,
TRmcObject &rnObject,
TRmcVisum &rnVisum ) = 0;
virtual TTransResult RmcCall ( TRmcObject nObject,
TRmcVisum &rnVisum,
TRmcMethode nMethode,
TRmcSize &rnSize,
TRmcData *&rpcData,
TRmcResult &rnResult ) = 0;
virtual TTransResult RmcRelease ( TRmcObject nObject,
TRmcVisum nVisum ) = 0;
}; // class CTransportClientInterface
}; // namespace rmc
#endif // #ifndef __TRANSPORT_CLIENT_H
--- NEW FILE ---
/***************************************************************************
TransportClientSSLSocket.h - description
-------------------
begin : Fri October 5 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_CLIENT_SSL_SOCKET_H
#define __TRANSPORT_CLIENT_SSL_SOCKET_H
#if _MSC_VER > 1000
#pragma ones
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
#include <stdio.h>
#include <unistd.h>
#include "Transport/TransportClientSocket.h"
//#include "family/SSLSocketUnNamed.h"
#include "RmcClient.h"
namespace rmc
{
class CTransportClientSSLSocket : public CTransportClientSocket
{
private:
public:
CTransportClientSSLSocket ( );
virtual ~CTransportClientSSLSocket ( );
protected:
// Overridden, we use an SSLSocket now
virtual LONG Connect ( );
};
}
#endif
--- NEW FILE ---
/***************************************************************************
TransportClientSocket.h
-------------------
begin : Thu June 07 2001
copyright : (C) 2001 by Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_CLIENT_SOCKET_H
#define __TRANSPORT_CLIENT_SOCKET_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
#include <stdio.h>
#include "TransportClient.h"
using namespace std;
namespace rmc
{
//- class CTransportClientSocket;
//- extern CTransportClientSocket g_oSocketClient;
class CTransportClientSocket : public CTransportClient
{
public:
static CTransportClientSocket s_oSocketClient;
protected:
string m_sAddress;
int m_nPort; // Port we want to connect to
public:
CTransportClientSocket ( );
virtual ~CTransportClientSocket ( );
virtual LONG RemoteSystemConfig ( const string& sComputer,
const string& sLogin = "",
const string& sPasswd = "");
protected:
void Initialize ( );
virtual LONG Connect ( );
}; // class CTransportClientSocket
}; // namespace rmc
#endif // #ifndef __TRANSPORT_CLIENT_SOCKET_H
--- NEW FILE ---
/***************************************************************************
TransportServer.h
-------------------
begin : Thu June 7 2001
copyright : (C) 2001 by Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __SOCKET_SERVER_H
#define __SOCKET_SERVER_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
#include "RmcServer.h"
#include <stdio.h>
#ifdef WIN32
// currently nothings
#else
# include <unistd.h>
#endif // WIN32
#include <map>
#include "Transport/TransportBufferInterface.h"
#include "Transport/TransportClientHandler.h"
namespace rmc
{
typedef CTransportClientHandler CClientHandler;
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//typedef map<int,CClientHandler*> CMapSocket2Client;
class CTransportServer
{
protected:
CRmcServer *m_poRmcServer;
CTransportBufferInterface *m_poSocketServer; // Our own Socket
public:
CTransportServer ( );
virtual ~CTransportServer ( );
virtual int WaitForClient( ) = 0;
void RegisterRmcServer (CRmcServer *poRmcServer);
protected:
void Initialize ( );
protected:
virtual void RemoveClient(int fd) = 0;
#ifdef WIN32
// the code does not compile with vc6 if the
// methode is abstract. don't know what this means
// 2001.11.29 - morgner
virtual void RemoveAllClients( ) {};
#else
virtual void RemoveAllClients( ) = 0;
#endif // else WIN32
}; // class CTransportServer
}; // namespace rmc
#endif // #ifndef __SOCKET_CLIENT_H
--- NEW FILE ---
/***************************************************************************
TransportServerSSLSocket.h - description
-------------------
begin : Fri October 5 2001
copyright : (C) 2001 Peter Soetens
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_SERVER_SSL_SOCKET_H
#define __TRANSPORT_SERVER_SSL_SOCKET_H
#if _MSC_VER > 1000
#pragma ones
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
#include "rmc.h"
#include <stdio.h>
#include <unistd.h>
#include <map>
//#include "family/SSLSocketNamed.h"
#include "Transport/TransportServerSocket.h"
#include "Transport/TransportClientHandler.h"
#include "RmcServer.h"
namespace rmc
{
class CTransportServerSSLSocket : public CTransportServerSocket
{
public:
CTransportServerSSLSocket ( int nPort = 6666 );
virtual ~CTransportServerSSLSocket ( );
virtual int WaitForClient ( void );
protected:
virtual void RemoveAllClients ( );
virtual void RemoveClient ( int fd );
}; // class CTransportServerSSLSocket
}; // namespace rmc
#endif // #ifndef __TRANSPORT_SERVER_SSL_SOCKET_H
--- NEW FILE ---
/***************************************************************************
TransportServerSocket.h
-------------------
begin : Thu June 7 2001
copyright : (C) 2001 by Alexander Feder
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************/
#ifndef __TRANSPORT_SERVER_SOCKET_H
#define __TRANSPORT_SERVER_SOCKET_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if __GNU__ >= 2
# pragma interface
#endif // __GNU__ >= 2
/*
#include "rmc.h"
#include <stdio.h>
#ifdef WIN32
#else
# include <unistd.h>
#endif // WIN32
#include <map>
//#include "family/SocketNamed.h"
#include "Transport/TransportServer.h"
#include "Transport/TransportClientHandler.h"
#include "RmcServer.h"
*/
#include "Transport/TransportServer.h"
namespace rmc
{
typedef std::map<int,CTransportClientHandler*> CMapSocket2Client;
class CTransportServerSocket : public CTransportServer
{
public:
static CTransportServer *s_poTransport;
protected:
std::string m_sAddress;
CMapSocket2Client m_moSocket2Client;
public:
CTransportServerSocket ( int nPort = 6666 );
virtual ~CTransportServerSocket ( );
virtual int WaitForClient ( void );
protected:
virtual void RemoveAllClients ( );
virtual void RemoveClient ( int fd );
}; // class CTransportServerSocket
}; // namespace rmc
#endif // #ifndef __TRANSPORT_SERVER_SOCKET_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Moss-devel] CVS: moss/rmc/include/Transport Makefile.am,NONE,1.1 SSLExceptions.h,NONE,1.1 SSLSocket.h,NONE,1.1 SSLSocketNamed.h,NONE,1.1 SSLSocketUnNamed.h,NONE,1.1 Socket.h,NONE,1.1 SocketNamed.h,NONE,1.1 SocketUnNamed.h,NONE,1.1 TransportBufferInterface.h,NONE,1.1 TransportClient.h,NONE,1.1 TransportClientHandler.h,NONE,1.1 TransportClientInterface.h,NONE,1.1 TransportClientSSLSocket.h,NONE,1.1 TransportClientSocket.h,NONE,1.1 TransportServer.h,NONE,1.1 TransportServerSSLSocket.h,NONE,1.1 TransportServerSocket.h,NONE,1.1,
Alexander Feder <address@hidden> <=