mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Blacklist and whitelist traffic from network
This commit is contained in:
153
DMRSlot.cpp
153
DMRSlot.cpp
@@ -149,14 +149,14 @@ void CDMRSlot::writeModem(unsigned char *data)
|
|||||||
// - G7RZU
|
// - G7RZU
|
||||||
did = lc->getDstId();
|
did = lc->getDstId();
|
||||||
if (DstIdBlacklist(did,m_slotNo)) {
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to %u (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;
|
||||||
}
|
}
|
||||||
did = lc->getDstId();
|
did = lc->getDstId();
|
||||||
// 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 (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
LogMessage("DMR Slot %u, invalid access attempt to %u (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;
|
||||||
}
|
}
|
||||||
@@ -275,6 +275,18 @@ void CDMRSlot::writeModem(unsigned char *data)
|
|||||||
LogMessage("DMR Slot %u, invalid access attempt from %u", m_slotNo, srcId);
|
LogMessage("DMR Slot %u, invalid access attempt from %u", m_slotNo, srcId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
if (DstIdBlacklist(dstId,m_slotNo)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(dstId,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_rfFrames = dataHeader.getBlocks();
|
m_rfFrames = dataHeader.getBlocks();
|
||||||
|
|
||||||
@@ -333,6 +345,18 @@ void CDMRSlot::writeModem(unsigned char *data)
|
|||||||
LogMessage("DMR Slot %u, invalid access attempt from %u", m_slotNo, srcId);
|
LogMessage("DMR Slot %u, invalid access attempt from %u", m_slotNo, srcId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
if (DstIdBlacklist(dstId,m_slotNo)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, dstId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(dstId,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, dstId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Regenerate the CSBK data
|
// Regenerate the CSBK data
|
||||||
csbk.get(data + 2U);
|
csbk.get(data + 2U);
|
||||||
@@ -482,6 +506,23 @@ void CDMRSlot::writeModem(unsigned char *data)
|
|||||||
delete lc;
|
delete lc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = lc->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
delete lc;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
did = lc->getDstId();
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Slot %u, invalid access attempt to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
delete lc;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_rfLC = lc;
|
m_rfLC = lc;
|
||||||
|
|
||||||
@@ -725,7 +766,7 @@ void CDMRSlot::writeEndNet(bool writeEnd)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
void CDMRSlot::writeNetwork (const CDMRData& dmrData)
|
||||||
{
|
{
|
||||||
if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE)
|
if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE)
|
||||||
return;
|
return;
|
||||||
@@ -748,12 +789,28 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Store the LC for the embedded LC
|
// Store the LC for the embedded LC
|
||||||
m_netEmbeddedLC.setData(*m_netLC);
|
m_netEmbeddedLC.setData(*m_netLC);
|
||||||
|
|
||||||
// Regenerate the LC data
|
// Regenerate the LC data
|
||||||
fullLC.encode(*m_netLC, data + 2U, DT_VOICE_LC_HEADER);
|
fullLC.encode(*m_netLC, data + 2U, DT_VOICE_LC_HEADER);
|
||||||
|
|
||||||
|
|
||||||
// Regenerate the Slot Type
|
// Regenerate the Slot Type
|
||||||
CDMRSlotType slotType;
|
CDMRSlotType slotType;
|
||||||
slotType.setColorCode(m_colorCode);
|
slotType.setColorCode(m_colorCode);
|
||||||
@@ -774,6 +831,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
m_netBits = 1U;
|
m_netBits = 1U;
|
||||||
m_netErrs = 0U;
|
m_netErrs = 0U;
|
||||||
|
|
||||||
|
|
||||||
writeQueueNet(m_idle);
|
writeQueueNet(m_idle);
|
||||||
writeQueueNet(m_idle);
|
writeQueueNet(m_idle);
|
||||||
writeQueueNet(m_idle);
|
writeQueueNet(m_idle);
|
||||||
@@ -819,6 +877,21 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
data[0U] = TAG_DATA;
|
data[0U] = TAG_DATA;
|
||||||
data[1U] = 0x00U;
|
data[1U] = 0x00U;
|
||||||
|
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
writeQueueNet(data);
|
writeQueueNet(data);
|
||||||
|
|
||||||
#if defined(DUMP_DMR)
|
#if defined(DUMP_DMR)
|
||||||
@@ -831,7 +904,20 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
// Regenerate the LC data
|
// Regenerate the LC data
|
||||||
CDMRFullLC fullLC;
|
CDMRFullLC fullLC;
|
||||||
fullLC.encode(*m_netLC, data + 2U, DT_TERMINATOR_WITH_LC);
|
fullLC.encode(*m_netLC, data + 2U, DT_TERMINATOR_WITH_LC);
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Regenerate the Slot Type
|
// Regenerate the Slot Type
|
||||||
CDMRSlotType slotType;
|
CDMRSlotType slotType;
|
||||||
slotType.setColorCode(m_colorCode);
|
slotType.setColorCode(m_colorCode);
|
||||||
@@ -878,7 +964,20 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
unsigned int dstId = dataHeader.getDstId();
|
unsigned int dstId = dataHeader.getDstId();
|
||||||
|
|
||||||
m_netLC = new CDMRLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId);
|
m_netLC = new CDMRLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId);
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Regenerate the data header
|
// Regenerate the data header
|
||||||
dataHeader.get(data + 2U);
|
dataHeader.get(data + 2U);
|
||||||
|
|
||||||
@@ -916,6 +1015,20 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
} else if (dataType == DT_VOICE_SYNC) {
|
} else if (dataType == DT_VOICE_SYNC) {
|
||||||
if (m_netState == RS_NET_IDLE) {
|
if (m_netState == RS_NET_IDLE) {
|
||||||
m_netLC = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId());
|
m_netLC = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId());
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_netTimeoutTimer.start();
|
m_netTimeoutTimer.start();
|
||||||
|
|
||||||
@@ -1004,7 +1117,20 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
} else if (dataType == DT_VOICE) {
|
} else if (dataType == DT_VOICE) {
|
||||||
if (m_netState != RS_NET_AUDIO)
|
if (m_netState != RS_NET_AUDIO)
|
||||||
return;
|
return;
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = m_netLC->getDstId();
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
unsigned char fid = m_netLC->getFID();
|
unsigned char fid = m_netLC->getFID();
|
||||||
if (fid == FID_ETSI || fid == FID_DMRA)
|
if (fid == FID_ETSI || fid == FID_DMRA)
|
||||||
m_netErrs += m_fec.regenerateDMR(data + 2U);
|
m_netErrs += m_fec.regenerateDMR(data + 2U);
|
||||||
@@ -1061,7 +1187,20 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||||||
bool gi = csbk.getGI();
|
bool gi = csbk.getGI();
|
||||||
unsigned int srcId = csbk.getSrcId();
|
unsigned int srcId = csbk.getSrcId();
|
||||||
unsigned int dstId = csbk.getDstId();
|
unsigned int dstId = csbk.getDstId();
|
||||||
|
// add check for valid dst id (e.g. TG)
|
||||||
|
//AKA - the BlockTheNet modification ;-)
|
||||||
|
// - G7RZU
|
||||||
|
unsigned int did;
|
||||||
|
did = dstId;
|
||||||
|
if (DstIdBlacklist(did,m_slotNo)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG blacklisted)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// true sets allow greater than 4k. Need to add boolean in conf for this later.
|
||||||
|
if (!DstIdWhitelist(did,m_slotNo,true)) {
|
||||||
|
LogMessage("DMR Network Slot %u, invalid traffic to TG %u (TG not in whitelist)", m_slotNo, did);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Regenerate the CSBK data
|
// Regenerate the CSBK data
|
||||||
csbk.get(data + 2U);
|
csbk.get(data + 2U);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user