Merge pull request #522 from sp5lg/master
DStar SelfOnly with WhiteList
This commit is contained in:
commit
99cdcf1f50
18
Conf.cpp
18
Conf.cpp
|
@ -126,6 +126,7 @@ m_dstarEnabled(false),
|
||||||
m_dstarModule("C"),
|
m_dstarModule("C"),
|
||||||
m_dstarSelfOnly(false),
|
m_dstarSelfOnly(false),
|
||||||
m_dstarBlackList(),
|
m_dstarBlackList(),
|
||||||
|
m_dstarWhiteList(),
|
||||||
m_dstarAckReply(true),
|
m_dstarAckReply(true),
|
||||||
m_dstarAckTime(750U),
|
m_dstarAckTime(750U),
|
||||||
m_dstarAckMessage(false),
|
m_dstarAckMessage(false),
|
||||||
|
@ -567,6 +568,18 @@ bool CConf::read()
|
||||||
}
|
}
|
||||||
p = ::strtok(NULL, ",\r\n");
|
p = ::strtok(NULL, ",\r\n");
|
||||||
}
|
}
|
||||||
|
} else if (::strcmp(key, "WhiteList") == 0) {
|
||||||
|
char* p = ::strtok(value, ",\r\n");
|
||||||
|
while (p != NULL) {
|
||||||
|
if (::strlen(p) > 0U) {
|
||||||
|
for (unsigned int i = 0U; p[i] != 0; i++)
|
||||||
|
p[i] = ::toupper(p[i]);
|
||||||
|
std::string callsign = std::string(p);
|
||||||
|
callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' ');
|
||||||
|
m_dstarWhiteList.push_back(callsign);
|
||||||
|
}
|
||||||
|
p = ::strtok(NULL, ",\r\n");
|
||||||
|
}
|
||||||
} else if (::strcmp(key, "AckReply") == 0)
|
} else if (::strcmp(key, "AckReply") == 0)
|
||||||
m_dstarAckReply = ::atoi(value) == 1;
|
m_dstarAckReply = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "AckTime") == 0)
|
else if (::strcmp(key, "AckTime") == 0)
|
||||||
|
@ -1294,6 +1307,11 @@ std::vector<std::string> CConf::getDStarBlackList() const
|
||||||
return m_dstarBlackList;
|
return m_dstarBlackList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> CConf::getDStarWhiteList() const
|
||||||
|
{
|
||||||
|
return m_dstarWhiteList;
|
||||||
|
}
|
||||||
|
|
||||||
bool CConf::getDStarAckReply() const
|
bool CConf::getDStarAckReply() const
|
||||||
{
|
{
|
||||||
return m_dstarAckReply;
|
return m_dstarAckReply;
|
||||||
|
|
2
Conf.h
2
Conf.h
|
@ -112,6 +112,7 @@ public:
|
||||||
std::string getDStarModule() const;
|
std::string getDStarModule() const;
|
||||||
bool getDStarSelfOnly() const;
|
bool getDStarSelfOnly() const;
|
||||||
std::vector<std::string> getDStarBlackList() const;
|
std::vector<std::string> getDStarBlackList() const;
|
||||||
|
std::vector<std::string> getDStarWhiteList() const;
|
||||||
bool getDStarAckReply() const;
|
bool getDStarAckReply() const;
|
||||||
unsigned int getDStarAckTime() const;
|
unsigned int getDStarAckTime() const;
|
||||||
bool getDStarAckMessage() const;
|
bool getDStarAckMessage() const;
|
||||||
|
@ -388,6 +389,7 @@ private:
|
||||||
std::string m_dstarModule;
|
std::string m_dstarModule;
|
||||||
bool m_dstarSelfOnly;
|
bool m_dstarSelfOnly;
|
||||||
std::vector<std::string> m_dstarBlackList;
|
std::vector<std::string> m_dstarBlackList;
|
||||||
|
std::vector<std::string> m_dstarWhiteList;
|
||||||
bool m_dstarAckReply;
|
bool m_dstarAckReply;
|
||||||
unsigned int m_dstarAckTime;
|
unsigned int m_dstarAckTime;
|
||||||
bool m_dstarAckMessage;
|
bool m_dstarAckMessage;
|
||||||
|
|
|
@ -36,7 +36,7 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)
|
||||||
|
|
||||||
// #define DUMP_DSTAR
|
// #define DUMP_DSTAR
|
||||||
|
|
||||||
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
|
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
|
||||||
m_callsign(NULL),
|
m_callsign(NULL),
|
||||||
m_gateway(NULL),
|
m_gateway(NULL),
|
||||||
m_selfOnly(selfOnly),
|
m_selfOnly(selfOnly),
|
||||||
|
@ -45,6 +45,7 @@ m_ackMessage(ackMessage),
|
||||||
m_errorReply(errorReply),
|
m_errorReply(errorReply),
|
||||||
m_remoteGateway(remoteGateway),
|
m_remoteGateway(remoteGateway),
|
||||||
m_blackList(blackList),
|
m_blackList(blackList),
|
||||||
|
m_whiteList(whiteList),
|
||||||
m_network(network),
|
m_network(network),
|
||||||
m_display(display),
|
m_display(display),
|
||||||
m_duplex(duplex),
|
m_duplex(duplex),
|
||||||
|
@ -231,7 +232,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0) {
|
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) {
|
||||||
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
||||||
m_rfState = RS_RF_REJECTED;
|
m_rfState = RS_RF_REJECTED;
|
||||||
return false;
|
return false;
|
||||||
|
@ -465,7 +466,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0) {
|
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) {
|
||||||
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
||||||
m_rfState = RS_RF_REJECTED;
|
m_rfState = RS_RF_REJECTED;
|
||||||
delete header;
|
delete header;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
class CDStarControl {
|
class CDStarControl {
|
||||||
public:
|
public:
|
||||||
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
|
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
|
||||||
~CDStarControl();
|
~CDStarControl();
|
||||||
|
|
||||||
bool writeModem(unsigned char* data, unsigned int len);
|
bool writeModem(unsigned char* data, unsigned int len);
|
||||||
|
@ -59,6 +59,7 @@ private:
|
||||||
bool m_errorReply;
|
bool m_errorReply;
|
||||||
bool m_remoteGateway;
|
bool m_remoteGateway;
|
||||||
std::vector<std::string> m_blackList;
|
std::vector<std::string> m_blackList;
|
||||||
|
std::vector<std::string> m_whiteList;
|
||||||
CDStarNetwork* m_network;
|
CDStarNetwork* m_network;
|
||||||
CDisplay* m_display;
|
CDisplay* m_display;
|
||||||
bool m_duplex;
|
bool m_duplex;
|
||||||
|
|
|
@ -93,6 +93,7 @@ AckMessage=0
|
||||||
ErrorReply=1
|
ErrorReply=1
|
||||||
RemoteGateway=0
|
RemoteGateway=0
|
||||||
# ModeHang=10
|
# ModeHang=10
|
||||||
|
WhiteList=
|
||||||
|
|
||||||
[DMR]
|
[DMR]
|
||||||
Enable=1
|
Enable=1
|
||||||
|
|
|
@ -410,6 +410,7 @@ int CMMDVMHost::run()
|
||||||
std::string module = m_conf.getDStarModule();
|
std::string module = m_conf.getDStarModule();
|
||||||
bool selfOnly = m_conf.getDStarSelfOnly();
|
bool selfOnly = m_conf.getDStarSelfOnly();
|
||||||
std::vector<std::string> blackList = m_conf.getDStarBlackList();
|
std::vector<std::string> blackList = m_conf.getDStarBlackList();
|
||||||
|
std::vector<std::string> whiteList = m_conf.getDStarWhiteList();
|
||||||
bool ackReply = m_conf.getDStarAckReply();
|
bool ackReply = m_conf.getDStarAckReply();
|
||||||
unsigned int ackTime = m_conf.getDStarAckTime();
|
unsigned int ackTime = m_conf.getDStarAckTime();
|
||||||
bool ackMessage = m_conf.getDStarAckMessage();
|
bool ackMessage = m_conf.getDStarAckMessage();
|
||||||
|
@ -429,8 +430,10 @@ int CMMDVMHost::run()
|
||||||
|
|
||||||
if (blackList.size() > 0U)
|
if (blackList.size() > 0U)
|
||||||
LogInfo(" Black List: %u", blackList.size());
|
LogInfo(" Black List: %u", blackList.size());
|
||||||
|
if (whiteList.size() > 0U)
|
||||||
|
LogInfo(" White List: %u", whiteList.size());
|
||||||
|
|
||||||
m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
|
m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, whiteList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;
|
DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;
|
||||||
|
|
Loading…
Reference in a new issue