diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index edde3a9..6a91b1c 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -429,11 +429,15 @@ void CWiresX::clock(unsigned int ms) } } -void CWiresX::createReply(const unsigned char* data, unsigned int length) +void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network) { assert(data != NULL); assert(length > 0U); + // If we don't explicitly pass a network, use the default one. + if (network == NULL) + network = m_network; + unsigned char bt = 0U; if (length > 260U) { @@ -475,7 +479,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo; seqNo += 2U; - m_network->write(buffer); + network->write(buffer); fich.setFI(YSF_FI_COMMUNICATIONS); @@ -522,7 +526,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo; seqNo += 2U; - m_network->write(buffer); + network->write(buffer); fn++; if (fn >= 8U) { @@ -542,7 +546,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo | 0x01U; - m_network->write(buffer); + network->write(buffer); } unsigned char CWiresX::calculateFT(unsigned int length, unsigned int offset) const @@ -637,6 +641,27 @@ void CWiresX::sendDXReply() m_seqNo++; } +void CWiresX::sendConnect(CYSFNetwork* network) +{ + unsigned char data[20U]; + ::memset(data, 0x00U, 20U); + ::memset(data, ' ', 16U); + + data[0U] = m_seqNo; + + for (unsigned int i = 0U; i < 3U; i++) + data[i + 1U] = DX_REQ[i]; + + data[15U] = 0x03U; // End of data marker + data[16U] = CCRC::addCRC(data, 16U); + + CUtils::dump(1U, "CONNECT", data, 20U); + + createReply(data, 20U, network); + + m_seqNo++; +} + void CWiresX::sendConnectReply() { assert(m_reflector != NULL); diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index ca490e5..201b197 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -64,6 +64,8 @@ public: void processConnect(CYSFReflector* reflector); void processDisconnect(const unsigned char* source = NULL); + void sendConnect(CYSFNetwork* network); + void clock(unsigned int ms); private: @@ -102,7 +104,7 @@ private: void sendSearchNotFoundReply(); void sendCategoryReply(); - void createReply(const unsigned char* data, unsigned int length); + void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = NULL); unsigned char calculateFT(unsigned int length, unsigned int offset) const; };