diff --git a/Conf.cpp b/Conf.cpp index 9f5f8c9..f574713 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -36,6 +36,7 @@ enum SECTION { CConf::CConf(const std::string& file) : m_file(file), m_callsign(), +m_whiteList(), m_rptAddress(), m_rptPort(0U), m_myAddress(), @@ -92,7 +93,15 @@ bool CConf::read() if (section == SECTION_GENERAL) { if (::strcmp(key, "Callsign") == 0) m_callsign = value; - else if (::strcmp(key, "RptAddress") == 0) + else if (::strcmp(key, "WhiteList") == 0) { + char* p = ::strtok(value, ",\r\n"); + while (p != NULL) { + unsigned int ric = (unsigned int)::atoi(p); + if (ric > 0U) + m_whiteList.push_back(ric); + p = ::strtok(NULL, ",\r\n"); + } + } else if (::strcmp(key, "RptAddress") == 0) m_rptAddress = value; else if (::strcmp(key, "RptPort") == 0) m_rptPort = (unsigned int)::atoi(value); @@ -133,6 +142,11 @@ std::string CConf::getCallsign() const return m_callsign; } +std::vector CConf::getWhiteList() const +{ + return m_whiteList; +} + std::string CConf::getRptAddress() const { return m_rptAddress; diff --git a/Conf.h b/Conf.h index 47344b2..4a8378a 100644 --- a/Conf.h +++ b/Conf.h @@ -20,6 +20,7 @@ #define CONF_H #include +#include class CConf { @@ -31,6 +32,7 @@ public: // The General section std::string getCallsign() const; + std::vector getWhiteList() const; std::string getRptAddress() const; unsigned int getRptPort() const; std::string getMyAddress() const; @@ -51,7 +53,9 @@ public: private: std::string m_file; + std::string m_callsign; + std::vector m_whiteList; std::string m_rptAddress; unsigned int m_rptPort; std::string m_myAddress; diff --git a/DAPNETGateway.cpp b/DAPNETGateway.cpp index 9596c10..89839ed 100644 --- a/DAPNETGateway.cpp +++ b/DAPNETGateway.cpp @@ -241,6 +241,8 @@ int CDAPNETGateway::run() ::LogMessage("Logged into the DAPNET network"); + std::vector whiteList = m_conf.getWhiteList(); + LogMessage("Starting DAPNETGateway-%s", VERSION); for (;;) { @@ -274,8 +276,16 @@ int CDAPNETGateway::run() CPOCSAGMessage* message = m_dapnetNetwork->readMessage(); if (message != NULL) { - LogDebug("Queueing message to %07u, type %u, func %s: \"%.*s\"", message->m_ric, message->m_type, message->m_functional == FUNCTIONAL_NUMERIC ? "Numeric" : "Alphanumeric", message->m_length, message->m_message); - m_queue.push_front(message); + bool found = false; + + // If we have a white list of RICs, use it. + if (!whiteList.empty()) + found = std::find(whiteList.begin(), whiteList.end(), message->m_ric) != whiteList.end(); + + if (!found) { + LogDebug("Queueing message to %07u, type %u, func %s: \"%.*s\"", message->m_ric, message->m_type, message->m_functional == FUNCTIONAL_NUMERIC ? "Numeric" : "Alphanumeric", message->m_length, message->m_message); + m_queue.push_front(message); + } } unsigned int t = (m_slotTimer.time() / 100ULL) % 1024ULL; diff --git a/DAPNETGateway.ini b/DAPNETGateway.ini index cd9fdb7..104fddf 100644 --- a/DAPNETGateway.ini +++ b/DAPNETGateway.ini @@ -1,5 +1,6 @@ [General] -Callsign=G9BF +Callsign=g9bf +# WhiteList=12345,78901 RptAddress=127.0.0.1 RptPort=3800 LocalAddress=127.0.0.1