mirror of
https://github.com/g4klx/DAPNETGateway.git
synced 2026-08-26 12:32:45 -04:00
Add an optional white list of RICs to transmit.
This commit is contained in:
parent
5d8ce8f8f5
commit
acc20ec8e7
4 changed files with 33 additions and 4 deletions
16
Conf.cpp
16
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<uint32_t> CConf::getWhiteList() const
|
||||
{
|
||||
return m_whiteList;
|
||||
}
|
||||
|
||||
std::string CConf::getRptAddress() const
|
||||
{
|
||||
return m_rptAddress;
|
||||
|
|
|
|||
4
Conf.h
4
Conf.h
|
|
@ -20,6 +20,7 @@
|
|||
#define CONF_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CConf
|
||||
{
|
||||
|
|
@ -31,6 +32,7 @@ public:
|
|||
|
||||
// The General section
|
||||
std::string getCallsign() const;
|
||||
std::vector<unsigned int> 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<unsigned int> m_whiteList;
|
||||
std::string m_rptAddress;
|
||||
unsigned int m_rptPort;
|
||||
std::string m_myAddress;
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ int CDAPNETGateway::run()
|
|||
|
||||
::LogMessage("Logged into the DAPNET network");
|
||||
|
||||
std::vector<unsigned int> 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;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
[General]
|
||||
Callsign=G9BF
|
||||
Callsign=g9bf
|
||||
# WhiteList=12345,78901
|
||||
RptAddress=127.0.0.1
|
||||
RptPort=3800
|
||||
LocalAddress=127.0.0.1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue