Separate DMR Access control into new class: DMRAccessControl::
This commit is contained in:
parent
cd50cbcb44
commit
66415e004e
5 changed files with 158 additions and 84 deletions
86
DMRAccessControl.cpp
Normal file
86
DMRAccessControl.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DMRAccessControl.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<unsigned int> DMRAccessControl::m_dstBlackListSlot1;
|
||||||
|
std::vector<unsigned int> DMRAccessControl::m_dstBlackListSlot2;
|
||||||
|
std::vector<unsigned int> DMRAccessControl::m_dstWhiteListSlot1;
|
||||||
|
std::vector<unsigned int> DMRAccessControl::m_dstWhiteListSlot2;
|
||||||
|
|
||||||
|
void DMRAccessControl::init(const std::vector<unsigned int>& DstIdBlacklistSlot1, const std::vector<unsigned int>& DstIdWhitelistSlot1, const std::vector<unsigned int>& DstIdBlacklistSlot2, const std::vector<unsigned int>& DstIdWhitelistSlot2)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_dstBlackListSlot1 = DstIdBlacklistSlot1;
|
||||||
|
m_dstWhiteListSlot1 = DstIdWhitelistSlot1;
|
||||||
|
m_dstBlackListSlot2 = DstIdBlacklistSlot2;
|
||||||
|
m_dstWhiteListSlot2 = DstIdWhitelistSlot2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMRAccessControl::DstIdBlacklist(unsigned int did, unsigned int slot)
|
||||||
|
{
|
||||||
|
if (slot == 1U) {
|
||||||
|
if (std::find(m_dstBlackListSlot1.begin(), m_dstBlackListSlot1.end(), did) != m_dstBlackListSlot1.end())
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (std::find(m_dstBlackListSlot2.begin(), m_dstBlackListSlot2.end(), did) != m_dstBlackListSlot2.end())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMRAccessControl::DstIdWhitelist(unsigned int did, unsigned int slot, bool gt4k)
|
||||||
|
{
|
||||||
|
if (slot == 1U) {
|
||||||
|
if (m_dstWhiteListSlot1.size() == 0U)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// No reflectors on slot1, so we only allow all IDs over 99999 unless specifically whitelisted.
|
||||||
|
//Allow traffic to TG0 as I think this is a special case - need to confirm
|
||||||
|
if (gt4k) {
|
||||||
|
if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did >= 99999U || did == 0)
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_dstWhiteListSlot2.size() == 0U)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//On slot2 we allow reflector control IDs, but not secondary TG IDs unless specifically listed. Also allow echo.
|
||||||
|
if (gt4k) {
|
||||||
|
if (std::find(m_dstWhiteListSlot2.begin(), m_dstWhiteListSlot2.end(), did) != m_dstWhiteListSlot2.end() || did == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//if dstId in secondary TG range or whitelist
|
||||||
|
else if (did >= 4000) {
|
||||||
|
if (did > 5000U && did < 10000U)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (std::find(m_dstWhiteListSlot2.begin(), m_dstWhiteListSlot2.end(), did) != m_dstWhiteListSlot2.end())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
39
DMRAccessControl.h
Normal file
39
DMRAccessControl.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
*/
|
||||||
|
#if !defined(DMRAccessControl_H)
|
||||||
|
#define DMRAccessControl_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class DMRAccessControl {
|
||||||
|
public:
|
||||||
|
static bool DstIdBlacklist(unsigned int did,unsigned int slot);
|
||||||
|
static bool DstIdWhitelist(unsigned int did,unsigned int slot,bool gt4k);
|
||||||
|
|
||||||
|
static void init(const std::vector<unsigned int>& DstIdBlacklistSlot1, const std::vector<unsigned int>& DstIdWhitelistSlot1, const std::vector<unsigned int>& DstIdBlacklistSlot2, const std::vector<unsigned int>& DstIdWhitelistSlot2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::vector<unsigned int> m_dstBlackListSlot1;
|
||||||
|
static std::vector<unsigned int> m_dstBlackListSlot2;
|
||||||
|
static std::vector<unsigned int> m_dstWhiteListSlot1;
|
||||||
|
static std::vector<unsigned int> m_dstWhiteListSlot2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
109
DMRSlot.cpp
109
DMRSlot.cpp
|
@ -22,6 +22,7 @@
|
||||||
#include "Sync.h"
|
#include "Sync.h"
|
||||||
#include "CRC.h"
|
#include "CRC.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "DMRAccessControl.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -32,11 +33,11 @@ unsigned int CDMRSlot::m_colorCode = 0U;
|
||||||
bool CDMRSlot::m_selfOnly = false;
|
bool CDMRSlot::m_selfOnly = false;
|
||||||
std::vector<unsigned int> CDMRSlot::m_prefixes;
|
std::vector<unsigned int> CDMRSlot::m_prefixes;
|
||||||
std::vector<unsigned int> CDMRSlot::m_blackList;
|
std::vector<unsigned int> CDMRSlot::m_blackList;
|
||||||
std::vector<unsigned int> CDMRSlot::m_dstBlackListSlot1;
|
/*std::vector<unsigned int> CDMRSlot::m_dstBlackListSlot1;
|
||||||
std::vector<unsigned int> CDMRSlot::m_dstWhiteListSlot1;
|
std::vector<unsigned int> CDMRSlot::m_dstWhiteListSlot1;
|
||||||
std::vector<unsigned int> CDMRSlot::m_dstBlackListSlot2;
|
std::vector<unsigned int> CDMRSlot::m_dstBlackListSlot2;
|
||||||
std::vector<unsigned int> CDMRSlot::m_dstWhiteListSlot2;
|
std::vector<unsigned int> CDMRSlot::m_dstWhiteListSlot2;
|
||||||
|
*/
|
||||||
CModem* CDMRSlot::m_modem = NULL;
|
CModem* CDMRSlot::m_modem = NULL;
|
||||||
CDMRIPSC* CDMRSlot::m_network = NULL;
|
CDMRIPSC* CDMRSlot::m_network = NULL;
|
||||||
CDisplay* CDMRSlot::m_display = NULL;
|
CDisplay* CDMRSlot::m_display = NULL;
|
||||||
|
@ -148,14 +149,14 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = lc->getDstId();
|
unsigned int did = lc->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
delete lc;
|
delete lc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
delete lc;
|
delete lc;
|
||||||
return;
|
return;
|
||||||
|
@ -279,13 +280,13 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
if (DstIdBlacklist(dstId, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(dstId, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(dstId, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(dstId, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -350,13 +351,13 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
if (DstIdBlacklist(dstId, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(dstId, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(dstId, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(dstId, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -519,14 +520,14 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = lc->getDstId();
|
unsigned int did = lc->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
delete lc;
|
delete lc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid access attempt to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
delete lc;
|
delete lc;
|
||||||
return;
|
return;
|
||||||
|
@ -807,13 +808,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = m_netLC->getDstId();
|
unsigned int did = m_netLC->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -879,13 +880,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = m_netLC->getDstId();
|
unsigned int did = m_netLC->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -920,14 +921,14 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = m_netLC->getDstId();
|
unsigned int did = m_netLC->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
writeEndNet();
|
writeEndNet();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
writeEndNet();
|
writeEndNet();
|
||||||
return;
|
return;
|
||||||
|
@ -989,13 +990,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = dataHeader.getDstId();
|
unsigned int did = dataHeader.getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1043,13 +1044,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = dmrData.getDstId();
|
unsigned int did = dmrData.getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1150,13 +1151,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = m_netLC->getDstId();
|
unsigned int did = m_netLC->getDstId();
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1221,13 +1222,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||||
// add check for valid dst id (e.g. TG)
|
// add check for valid dst id (e.g. TG)
|
||||||
// - G7RZU
|
// - G7RZU
|
||||||
unsigned int did = dstId;
|
unsigned int did = dstId;
|
||||||
if (DstIdBlacklist(did, m_slotNo)) {
|
if (DMRAccessControl::DstIdBlacklist(did, m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
if (!DstIdWhitelist(did, m_slotNo, true)) {
|
if (!DMRAccessControl::DstIdWhitelist(did, m_slotNo, true)) {
|
||||||
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1467,10 +1468,6 @@ void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHa
|
||||||
m_selfOnly = selfOnly;
|
m_selfOnly = selfOnly;
|
||||||
m_prefixes = prefixes;
|
m_prefixes = prefixes;
|
||||||
m_blackList = blackList;
|
m_blackList = blackList;
|
||||||
m_dstBlackListSlot1 = DstIdBlacklistSlot1;
|
|
||||||
m_dstWhiteListSlot1 = DstIdWhitelistSlot1;
|
|
||||||
m_dstBlackListSlot2 = DstIdBlacklistSlot2;
|
|
||||||
m_dstWhiteListSlot2 = DstIdWhitelistSlot2;
|
|
||||||
m_modem = modem;
|
m_modem = modem;
|
||||||
m_network = network;
|
m_network = network;
|
||||||
m_display = display;
|
m_display = display;
|
||||||
|
@ -1487,6 +1484,9 @@ void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHa
|
||||||
slotType.setColorCode(colorCode);
|
slotType.setColorCode(colorCode);
|
||||||
slotType.setDataType(DT_IDLE);
|
slotType.setDataType(DT_IDLE);
|
||||||
slotType.getData(m_idle + 2U);
|
slotType.getData(m_idle + 2U);
|
||||||
|
|
||||||
|
//Load black and white lists to DMRAccessControl
|
||||||
|
DMRAccessControl::init(DstIdBlacklistSlot1, DstIdWhitelistSlot1, DstIdBlacklistSlot2, DstIdWhitelistSlot2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDMRSlot::validateId(unsigned int id)
|
bool CDMRSlot::validateId(unsigned int id)
|
||||||
|
@ -1508,59 +1508,6 @@ bool CDMRSlot::validateId(unsigned int id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//is dst id blacklisted?
|
|
||||||
bool CDMRSlot::DstIdBlacklist(unsigned int did, unsigned int slot)
|
|
||||||
{
|
|
||||||
if (slot == 1U) {
|
|
||||||
if (std::find(m_dstBlackListSlot1.begin(), m_dstBlackListSlot1.end(), did) != m_dstBlackListSlot1.end())
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (std::find(m_dstBlackListSlot2.begin(), m_dstBlackListSlot2.end(), did) != m_dstBlackListSlot2.end())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CDMRSlot::DstIdWhitelist(unsigned int did, unsigned int slot, bool gt4k)
|
|
||||||
{
|
|
||||||
if (slot == 1U) {
|
|
||||||
if (m_dstWhiteListSlot1.size() == 0U)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// No reflectors on slot1, so we only allow all IDs over 99999 unless specifically whitelisted.
|
|
||||||
//Allow traffic to TG0 as I think this is a special case - need to confirm
|
|
||||||
if (gt4k) {
|
|
||||||
if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did >= 99999U || did == 0)
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_dstWhiteListSlot2.size() == 0U)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//On slot2 we allow reflector control IDs, but not secondary TG IDs unless specifically listed. Also allow echo.
|
|
||||||
if (gt4k) {
|
|
||||||
if (std::find(m_dstWhiteListSlot2.begin(), m_dstWhiteListSlot2.end(), did) != m_dstWhiteListSlot2.end() || did == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//if dstId in secondary TG range or whitelist
|
|
||||||
else if (did >= 4000) {
|
|
||||||
if (did > 5000U && did < 10000U)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (std::find(m_dstWhiteListSlot2.begin(), m_dstWhiteListSlot2.end(), did) != m_dstWhiteListSlot2.end())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, bool voice)
|
void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, bool voice)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,11 +90,12 @@ private:
|
||||||
static bool m_selfOnly;
|
static bool m_selfOnly;
|
||||||
static std::vector<unsigned int> m_prefixes;
|
static std::vector<unsigned int> m_prefixes;
|
||||||
static std::vector<unsigned int> m_blackList;
|
static std::vector<unsigned int> m_blackList;
|
||||||
|
/*
|
||||||
static std::vector<unsigned int> m_dstBlackListSlot1;
|
static std::vector<unsigned int> m_dstBlackListSlot1;
|
||||||
static std::vector<unsigned int> m_dstBlackListSlot2;
|
static std::vector<unsigned int> m_dstBlackListSlot2;
|
||||||
static std::vector<unsigned int> m_dstWhiteListSlot1;
|
static std::vector<unsigned int> m_dstWhiteListSlot1;
|
||||||
static std::vector<unsigned int> m_dstWhiteListSlot2;
|
static std::vector<unsigned int> m_dstWhiteListSlot2;
|
||||||
|
*/
|
||||||
static CModem* m_modem;
|
static CModem* m_modem;
|
||||||
static CDMRIPSC* m_network;
|
static CDMRIPSC* m_network;
|
||||||
static CDisplay* m_display;
|
static CDisplay* m_display;
|
||||||
|
@ -133,6 +134,7 @@ private:
|
||||||
static bool validateId(unsigned int id);
|
static bool validateId(unsigned int id);
|
||||||
static bool DstIdBlacklist(unsigned int did,unsigned int slot);
|
static bool DstIdBlacklist(unsigned int did,unsigned int slot);
|
||||||
static bool DstIdWhitelist(unsigned int did,unsigned int slot,bool gt4k);
|
static bool DstIdWhitelist(unsigned int did,unsigned int slot,bool gt4k);
|
||||||
|
static char DMRAC;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -8,7 +8,7 @@ LDFLAGS = -g
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
|
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
|
||||||
DMRShortLC.o DMRSlot.o DMRSlotType.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o Log.o MMDVMHost.o \
|
DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o Log.o MMDVMHost.o \
|
||||||
Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o Utils.o YSFControl.o \
|
||||||
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||||
|
|
||||||
|
@ -22,4 +22,4 @@ MMDVMHost: $(OBJECTS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) MMDVMHost *.o *.d *.bak *~
|
$(RM) MMDVMHost *.o *.d *.bak *~
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue