You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
2.2 KiB

#include "mojoRemoteClient.h"
#include "mojoKernel.h"
#define LOG( X ) m_pLog->Log( "RPC", this, X )
#ifdef DEBUG
#define LOG_ERROR( X ) {\
char _tBfrErrMSG234[256];\
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
m_pLog->Log( "RPC", this, _LOG_ERROR, _tBfrErrMSG234 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "RPC", this, _LOG_ERROR, X );
#endif
mojoRemoteClient::mojoRemoteClient( mojoKernel * ptr ):protocolParser(){
m_pLog = basicLogCollection::getInstance();
m_pPort = NULL;
m_pMaster = ptr;
};
mojoRemoteClient::~mojoRemoteClient(){
if ( m_pPort ) delete( m_pPort );
};
bool mojoRemoteClient::create(){
if ( m_pMaster == NULL ) return false;
#ifdef DEBUG
char tB[128];
sprintf(tB,"Creating Remote connection to [%s:%d]", m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
LOG( tB );
#endif
if ( m_pMaster->m_sSiteData.remote_port ) {
m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
if( m_pPort ) {
if ( m_pPort->create() ) {
LOG( "Port Created Sucessfully!" );
return setTransport( m_pPort );
} else {
delete( m_pPort );
m_pPort = NULL;
};
};
};
return false;
};
int mojoRemoteClient::packetChecker(U8 *Buffer, size_t BufferSize){
if ( Buffer[0] == ARGUS_START_SERVER_FLAG ) {
ARGUS_DATA_HEADER *ptr = (ARGUS_DATA_HEADER*) Buffer;
if ( ( ptr->SIZE + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE ) <= BufferSize ) {
uint16_t tCRC = checksum16( Buffer, ptr->SIZE + ARGUS_HEADER_SIZE );
uint16_t *cCRC = (uint16_t*)( Buffer + ptr->SIZE + ARGUS_HEADER_SIZE );
if ( tCRC == *cCRC ) return 0;
} else return 1;
};
return -1;
};
protocolPackage *mojoRemoteClient::packetExtractor(U8 *Buffer, size_t BufferSize){
};
bool mojoRemoteClient::packetHandler( protocolPackage *Package ){
};
#undef LOG
#undef LOG_ERROR