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.

67 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "mojoRemoteClient.h"
  2. #include "mojoKernel.h"
  3. #define LOG( X ) m_pLog->Log( "RPC", this, X )
  4. #ifdef DEBUG
  5. #define LOG_ERROR( X ) {\
  6. char _tBfrErrMSG234[256];\
  7. sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  8. m_pLog->Log( "RPC", this, _LOG_ERROR, _tBfrErrMSG234 );\
  9. }
  10. #else
  11. #define LOG_ERROR( X ) m_pLog->Log( "RPC", this, _LOG_ERROR, X );
  12. #endif
  13. mojoRemoteClient::mojoRemoteClient( mojoKernel * ptr ):protocolParser(){
  14. m_pLog = basicLogCollection::getInstance();
  15. m_pPort = NULL;
  16. m_pMaster = ptr;
  17. };
  18. mojoRemoteClient::~mojoRemoteClient(){
  19. if ( m_pPort ) delete( m_pPort );
  20. };
  21. bool mojoRemoteClient::create(){
  22. if ( m_pMaster == NULL ) return false;
  23. #ifdef DEBUG
  24. char tB[128];
  25. sprintf(tB,"Creating Remote connection to [%s:%d]", m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
  26. LOG( tB );
  27. #endif
  28. if ( m_pMaster->m_sSiteData.remote_port ) {
  29. m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
  30. if( m_pPort ) {
  31. if ( m_pPort->create() ) {
  32. LOG( "Port Created Sucessfully!" );
  33. return setTransport( m_pPort );
  34. } else {
  35. delete( m_pPort );
  36. m_pPort = NULL;
  37. };
  38. };
  39. };
  40. return false;
  41. };
  42. int mojoRemoteClient::packetChecker(U8 *Buffer, size_t BufferSize){
  43. if ( Buffer[0] == ARGUS_START_SERVER_FLAG ) {
  44. ARGUS_DATA_HEADER *ptr = (ARGUS_DATA_HEADER*) Buffer;
  45. if ( ( ptr->SIZE + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE ) <= BufferSize ) {
  46. uint16_t tCRC = checksum16( Buffer, ptr->SIZE + ARGUS_HEADER_SIZE );
  47. uint16_t *cCRC = (uint16_t*)( Buffer + ptr->SIZE + ARGUS_HEADER_SIZE );
  48. if ( tCRC == *cCRC ) return 0;
  49. } else return 1;
  50. };
  51. return -1;
  52. };
  53. protocolPackage *mojoRemoteClient::packetExtractor(U8 *Buffer, size_t BufferSize){
  54. };
  55. bool mojoRemoteClient::packetHandler( protocolPackage *Package ){
  56. };
  57. #undef LOG
  58. #undef LOG_ERROR