diff --git a/src/cdextraprotocol.cpp b/src/cdextraprotocol.cpp index d191e23..4708603 100644 --- a/src/cdextraprotocol.cpp +++ b/src/cdextraprotocol.cpp @@ -107,13 +107,13 @@ void CDextraProtocol::Task(void) } else if ( IsValidConnectPacket(Buffer, &Callsign, &ToLinkModule, &ProtRev) ) { - std::cout << "DExtra connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; + std::cout << "DExtra connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << " rev " << ProtRev << std::endl; // callsign authorized? if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DEXTRA) ) { // acknowledge the request - EncodeConnectAckPacket(&Buffer); + EncodeConnectAckPacket(&Buffer, ProtRev); m_Socket.Send(Buffer, Ip); // create the client @@ -293,6 +293,13 @@ bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) { // get client callsign via = client->GetCallsign(); + // apply protocol revision details + if ( client->GetProtocolRevision() == 2 ) + { + // update Header RPT2 module letter with + // the module the client is linked to + Header->SetRpt2Module(client->GetReflectorModule()); + } // and try to open the stream if ( (stream = g_Reflector.OpenStream(Header, client)) != NULL ) { @@ -334,6 +341,19 @@ bool CDextraProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *cal *reflectormodule = Buffer.data()[9]; *revision = (Buffer.data()[10] == 11) ? 1 : 0; valid = (callsign->IsValid() && IsLetter(*reflectormodule)); + // detect revision + if ( (Buffer.data()[10] == 11) ) + { + *revision = 1; + } + else if ( callsign->HasSameCallsignWithWidlcard(CCallsign("XRF*")) ) + { + *revision = 2; + } + else + { + *revision = 0; + } } return valid; } @@ -431,12 +451,10 @@ void CDextraProtocol::EncodeKeepAlivePacket(CBuffer *Buffer) Buffer->Set(GetReflectorCallsign()); } -void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer) +void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev) { - uint8 xrf[] = { 'X','R','F' }; - // is it for a XRF or repeater - if ( Buffer->Compare(xrf, sizeof(xrf)) == 0 ) + if ( ProtRev == 2 ) { // XRFxxx uint8 rm = (Buffer->data())[8]; diff --git a/src/cdextraprotocol.h b/src/cdextraprotocol.h index b73257f..3c623fc 100644 --- a/src/cdextraprotocol.h +++ b/src/cdextraprotocol.h @@ -33,6 +33,24 @@ //////////////////////////////////////////////////////////////////////////////////////// +// note on protocol revisions: +// +// rev 0: +// this is standard protocol implementation +// +// rev 1: +// this is specific UP4DAR umplementation +// the protocol is detected using byte(10) of connect packet (value is 11) +// the protocol require a specific non-standard disconnect acqknowleding packet +// +// rev 2: +// this is specific to KI4KLF dxrfd reflector +// the protocol is detected by looking at "XRF" in connect packet callsign +// the protocol require a specific connect ack packet +// the protocol also implement a workaround for detecting stream's module +// as dxrfd soes not set DV header RPT2 properly. +// the protocol assumes that a dxrfd can only be linked to one module at a time + //////////////////////////////////////////////////////////////////////////////////////// // class @@ -72,7 +90,7 @@ protected: // packet encoding helpers void EncodeKeepAlivePacket(CBuffer *); - void EncodeConnectAckPacket(CBuffer *); + void EncodeConnectAckPacket(CBuffer *, int); void EncodeConnectNackPacket(CBuffer *); void EncodeDisconnectPacket(CBuffer *); void EncodeDisconnectedPacket(CBuffer *); diff --git a/src/cdvheaderpacket.h b/src/cdvheaderpacket.h index 6c80c80..26f0d17 100644 --- a/src/cdvheaderpacket.h +++ b/src/cdvheaderpacket.h @@ -93,6 +93,7 @@ public: // set callsigns void SetRpt2Callsign(const CCallsign &cs) { m_csRPT2 = cs; } + void SetRpt2Module(char c) { m_csRPT2.SetModule(c); } // operators bool operator ==(const CDvHeaderPacket &) const; diff --git a/src/main.h b/src/main.h index be097f2..ab40281 100644 --- a/src/main.h +++ b/src/main.h @@ -48,7 +48,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 -#define VERSION_REVISION 4 +#define VERSION_REVISION 5 // global ------------------------------------------------------