From dd1586d478b2679abe76b0dac3e3ba552b56f1fd Mon Sep 17 00:00:00 2001 From: Doug McLain Date: Fri, 18 Mar 2022 15:24:24 -0400 Subject: [PATCH 1/2] Add handlers for YSFI and YSFV packets, so that they dont clutter the lof=g with unkown packet entries --- reflector/YSFProtocol.cpp | 26 ++++++++++++++++++++++++++ reflector/YSFProtocol.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index eb261aa..ffaca56 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -186,6 +186,14 @@ void CYsfProtocol::Task(void) EncodeServerStatusPacket(&Buffer); Send(Buffer, Ip); } + else if ( IsValidInfoPacket(Buffer) ) + { + // Do nothing + } + else if ( IsValidAckPacket(Buffer) ) + { + std::cout << "YSF valid/ack packet received from " << Ip << std::endl; + } else { #ifdef DEBUG @@ -882,6 +890,24 @@ bool CYsfProtocol::IsValidServerStatusPacket(const CBuffer &Buffer) const return ( (Buffer.size() >= 4) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); } +// Info packet sent by some clients -- currently ignored by YSFReflector + +bool CYsfProtocol::IsValidInfoPacket(const CBuffer &Buffer) const +{ + uint8_t tag[] = { 'Y','S','F','I' }; + + return ( (Buffer.size() >= 4) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); +} + +// Valid packet sent by registry as an ACK response to a server status reply from reflector + +bool CYsfProtocol::IsValidAckPacket(const CBuffer &Buffer) const +{ + uint8_t tag[] = { 'Y','S','F','V' }; + + return ( (Buffer.size() >= 4) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); +} + // server status packet encoding helpers bool CYsfProtocol::EncodeServerStatusPacket(CBuffer *Buffer) const diff --git a/reflector/YSFProtocol.h b/reflector/YSFProtocol.h index 5a90628..2cb1b8f 100644 --- a/reflector/YSFProtocol.h +++ b/reflector/YSFProtocol.h @@ -101,6 +101,8 @@ protected: // server status packet decoding helpers bool IsValidServerStatusPacket(const CBuffer &) const; + bool IsValidInfoPacket(const CBuffer &) const; + bool IsValidAckPacket(const CBuffer &) const; uint32_t CalcHash(const uint8_t *, int) const; // server status packet encoding helpers From f3008f402a582bba2dd6c2f16a0d8319bcabe3d4 Mon Sep 17 00:00:00 2001 From: Doug McLain Date: Fri, 18 Mar 2022 18:22:53 -0400 Subject: [PATCH 2/2] Add handler for YSFO too --- reflector/YSFProtocol.cpp | 13 ++++++++++++- reflector/YSFProtocol.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index ffaca56..f67fd1f 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -192,7 +192,11 @@ void CYsfProtocol::Task(void) } else if ( IsValidAckPacket(Buffer) ) { - std::cout << "YSF valid/ack packet received from " << Ip << std::endl; + // Do nothing + } + else if ( IsValidOptionsPacket(Buffer) ) + { + // Do nothing } else { @@ -908,6 +912,13 @@ bool CYsfProtocol::IsValidAckPacket(const CBuffer &Buffer) const return ( (Buffer.size() >= 4) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); } +bool CYsfProtocol::IsValidOptionsPacket(const CBuffer &Buffer) const +{ + uint8_t tag[] = { 'Y','S','F','O' }; + + return ( (Buffer.size() >= 4) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); +} + // server status packet encoding helpers bool CYsfProtocol::EncodeServerStatusPacket(CBuffer *Buffer) const diff --git a/reflector/YSFProtocol.h b/reflector/YSFProtocol.h index 2cb1b8f..666ef40 100644 --- a/reflector/YSFProtocol.h +++ b/reflector/YSFProtocol.h @@ -103,6 +103,7 @@ protected: bool IsValidServerStatusPacket(const CBuffer &) const; bool IsValidInfoPacket(const CBuffer &) const; bool IsValidAckPacket(const CBuffer &) const; + bool IsValidOptionsPacket(const CBuffer &) const; uint32_t CalcHash(const uint8_t *, int) const; // server status packet encoding helpers