From a13ef93d6e7298b1b4558d4d3b351b6b6674a0b6 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 21 Jan 2020 12:50:49 +0100 Subject: [PATCH] Allow special callsigns to connect via DMR protocol This allows for connection of IPSC2 masters using callsigns like IPSC_EU2. In order to not cause issues with the existing code this has been enclosed into an ifdef. It has to be activated ex- plicitely though. --- src/ccallsign.cpp | 23 +++++++++++++++++++++-- src/ccallsign.h | 3 +++ src/main.h | 5 +++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ccallsign.cpp b/src/ccallsign.cpp index 23cdb3e..75f6d5d 100644 --- a/src/ccallsign.cpp +++ b/src/ccallsign.cpp @@ -110,22 +110,34 @@ bool CCallsign::IsValid(void) const } } valid &= (iNum < 3); - // all remaining char are letter, number or space + // all remaining char are letter, number or space (or underscore in extended checks) for ( ; i < CALLSIGN_LEN; i++) { +#ifdef EXTENDED_DMRID_CHECKS + valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]) || IsUnderscore(m_Callsign[i]); +#else valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]); +#endif } // prefix - // all chars are number, uppercase or space + // all chars are number, uppercase or space (or underscore in extend checks) for ( i = 0; i < CALLSUFFIX_LEN; i++ ) { +#ifdef EXTENDED_DMRID_CHECKS + valid &= IsLetter(m_Suffix[i]) || IsNumber(m_Suffix[i]) || IsSpace(m_Suffix[i]) || IsUnderscore(m_Suffix[i]); +#else valid &= IsLetter(m_Suffix[i]) || IsNumber(m_Suffix[i]) || IsSpace(m_Suffix[i]); +#endif } // module // is an letter or space +#ifdef EXTENDED_DMRID_CHECKS + valid &= IsLetter(m_Module) || IsSpace(m_Module) || IsNumber(m_Module); +#else valid &= IsLetter(m_Module) || IsSpace(m_Module); +#endif // dmrid is not tested, as it can be NULL // if station does is not dmr registered @@ -361,6 +373,13 @@ bool CCallsign::IsLetter(char c) const return ((c >= 'A') && (c <= 'Z')); } +#ifdef EXTENDED_DMRID_CHECKS +bool CCallsign::IsUnderscore(char c) const +{ + return (c == '_'); +} +#endif + bool CCallsign::IsSpace(char c) const { return (c == ' '); diff --git a/src/ccallsign.h b/src/ccallsign.h index bd5f118..c0436e3 100644 --- a/src/ccallsign.h +++ b/src/ccallsign.h @@ -85,6 +85,9 @@ protected: bool IsNumber(char) const; bool IsLetter(char) const; bool IsSpace(char) const; +#ifdef EXTENDED_DMRID_CHECKS + bool IsUnderscore(char) const; +#endif protected: // data diff --git a/src/main.h b/src/main.h index b07c48e..7fc0a74 100644 --- a/src/main.h +++ b/src/main.h @@ -144,6 +144,11 @@ #define DMRIDDB_PATH "/xlxd/dmrid.dat" // local file path #define DMRIDDB_REFRESH_RATE 180 // in minutes +// Extended DMR ID checks --------------------------------------- + +//#define EXTENDED_DMRID_CHECKS // Also allow extended "callsigns" like "IPSC_EU2" + // used for incoming DMR-DL master connections + // Wires-X node database ---------------------------------------- #define YSFNODEDB_USE_RLX_SERVER 1 // 1 = use http, 0 = use local file