From c53a96baab415b8428154ca8555540ef96a85096 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 11 Sep 2016 12:15:03 +0100 Subject: [PATCH 01/16] Added TG rewrite code --- DMRAccessControl.cpp | 35 +++++++++++++++++++++++++++++++++++ DMRAccessControl.h | 9 +++++++++ DMRSlot.cpp | 16 +++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index a881ab2..48927aa 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -18,6 +18,7 @@ #include #include +#include std::vector DMRAccessControl::m_dstBlackListSlot1RF; std::vector DMRAccessControl::m_dstBlackListSlot2RF; @@ -37,6 +38,10 @@ bool DMRAccessControl::m_selfOnly = false; unsigned int DMRAccessControl::m_id = 0U; +unsigned int DMRAccessControl::m_dstRewriteID = 0U; + +std::time_t DMRAccessControl::m_time; + void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id) { m_dstBlackListSlot1RF = DstIdBlacklistSlot1RF; @@ -180,3 +185,33 @@ bool DMRAccessControl::validateAccess (unsigned int src_id, unsigned int dst_id, return true; } } + +unsigned int DMRAccessControl::DstIdRewrite (unsigned int id, bool network) +{ + // record current time + std::time_t currenttime = std::time(nullptr); + + // if the traffic is from the network + if (network) { + m_dstRewriteID = id; + // record current time + m_time = std::time(nullptr); + // if the ID is a talkgroup, log and rewrite to TG9 + if (id < 4000 && id != 0) { + LogMessage("Rewrite DST ID (TG) of of inbound network traffic from %u to 9", id); + return 9; + } else { + return 0; + } + } else { + // if less than 30 seconds has passed since we last saw traffic + if (m_dstRewriteID == id && (m_time + 30) > currenttime && m_time) { + LogMessage("Inbound DST ID (TG) rewrite seen in last 30 seconds"); + LogMessage("Rewrite DST ID (TG) of outbound network traffic from 9 to %u", id); + return(id); + } else { + return(0); + } + } + +} diff --git a/DMRAccessControl.h b/DMRAccessControl.h index 78be7ba..5e4f989 100644 --- a/DMRAccessControl.h +++ b/DMRAccessControl.h @@ -16,12 +16,15 @@ #define DMRAccessControl_H #include +#include class DMRAccessControl { public: static bool validateAccess (unsigned int src_id, unsigned int dst_id, unsigned int slot, bool network); static void init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id); + + static unsigned int DstIdRewrite(unsigned int id, bool network); private: static std::vector m_dstBlackListSlot1RF; @@ -45,6 +48,12 @@ private: static bool DstIdWhitelist(unsigned int did,unsigned int slot,bool gt4k, bool network); static bool validateSrcId(unsigned int id); + + static std::time_t m_time; + + static unsigned int m_dstRewriteID; + + }; #endif diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 9cea73a..620a423 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -157,7 +157,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!DMRAccessControl::validateAccess(id, did, m_slotNo, false)) { delete lc; return; - } + } m_rfLC = lc; @@ -762,6 +762,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) unsigned int id = m_netLC->getSrcId(); if (!DMRAccessControl::validateAccess(id, did, m_slotNo, true)) return; + + // Test dst rewrite + unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, true); + if (rw_id) { + LogMessage("Rewrite ID: %u", rw_id); + m_netLC->setDstId(rw_id); + } // Store the LC for the embedded LC m_netEmbeddedLC.setData(*m_netLC); @@ -825,6 +832,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) unsigned int id = m_netLC->getSrcId(); if (!DMRAccessControl::validateAccess(id, did, m_slotNo, true)) return; + + // Test dst rewrite + unsigned int rw_id = DMRAccessControl::DstIdRewrite(id,true); + if (rw_id) { + LogMessage("Rewrite ID: %u", rw_id); + m_netLC->setDstId(rw_id); + } // Regenerate the Slot Type CDMRSlotType slotType; From 809153e0f254bb486cee17ee37c9e8e3a893af7c Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 11 Sep 2016 13:01:05 +0100 Subject: [PATCH 02/16] Add TG rewrite code call to DMRSlot.cpp --- DMRSlot.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 620a423..67d415d 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -157,7 +157,14 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!DMRAccessControl::validateAccess(id, did, m_slotNo, false)) { delete lc; return; - } + } + + // Test dst rewrite + unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, false); + if (rw_id) { + LogMessage("Rewrite ID: %u", rw_id); + lc->setDstId(rw_id); + } m_rfLC = lc; @@ -271,6 +278,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!DMRAccessControl::validateAccess(srcId, dstId, m_slotNo, false)) return; + m_rfFrames = dataHeader.getBlocks(); m_rfDataHeader = dataHeader; @@ -325,7 +333,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) unsigned int dstId = csbk.getDstId(); if (!DMRAccessControl::validateAccess(srcId, dstId, m_slotNo, false)) return; - + // Regenerate the CSBK data csbk.get(data + 2U); @@ -484,6 +492,12 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) delete lc; return; } + // Test dst rewrite + unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, false); + if (rw_id) { + LogMessage("Rewrite ID: %u", rw_id); + lc->setDstId(rw_id); + } m_rfLC = lc; From a275e7790201af7cfda2dabdfd877f4d03afa402 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 11 Sep 2016 18:26:27 +0100 Subject: [PATCH 03/16] fixed id/did logic --- DMRSlot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 67d415d..9b7910c 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -160,7 +160,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) } // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, false); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, false); if (rw_id) { LogMessage("Rewrite ID: %u", rw_id); lc->setDstId(rw_id); @@ -493,7 +493,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) return; } // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, false); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, false); if (rw_id) { LogMessage("Rewrite ID: %u", rw_id); lc->setDstId(rw_id); From 105d18594a827654cc605bcba7b58a1aea1ba080 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 10:08:13 +0100 Subject: [PATCH 04/16] more tg-rewrite work --- DMRAccessControl.cpp | 7 ++++--- DMRSlot.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 48927aa..4bc4f4b 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -197,17 +197,18 @@ unsigned int DMRAccessControl::DstIdRewrite (unsigned int id, bool network) // record current time m_time = std::time(nullptr); // if the ID is a talkgroup, log and rewrite to TG9 - if (id < 4000 && id != 0) { + if (id < 4000 && id > 0) { LogMessage("Rewrite DST ID (TG) of of inbound network traffic from %u to 9", id); return 9; } else { return 0; } } else { - // if less than 30 seconds has passed since we last saw traffic - if (m_dstRewriteID == id && (m_time + 30) > currenttime && m_time) { + // if less than 30 seconds has passed since we last saw traffic from network + if (m_dstRewriteID == id && (m_time + 30) > currenttime) { LogMessage("Inbound DST ID (TG) rewrite seen in last 30 seconds"); LogMessage("Rewrite DST ID (TG) of outbound network traffic from 9 to %u", id); + m_time = std::time(nullptr); return(id); } else { return(0); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 9b7910c..2f29850 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -774,11 +774,11 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) unsigned int did = m_netLC->getDstId(); unsigned int id = m_netLC->getSrcId(); - if (!DMRAccessControl::validateAccess(id, did, m_slotNo, true)) + if (!DMRAccessControl::validateAccess(did, did, m_slotNo, true)) return; // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(id, true); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, true); if (rw_id) { LogMessage("Rewrite ID: %u", rw_id); m_netLC->setDstId(rw_id); From 21691b046b96b1b0cd3697aa0f0440ed8517f5b7 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 14:19:00 +0100 Subject: [PATCH 05/16] Talkgroup rewrite now working --- DMRAccessControl.cpp | 36 +++++++++++++++++++----------------- DMRAccessControl.h | 8 ++++++-- DMRSlot.cpp | 38 +++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 4bc4f4b..ee3c000 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -39,10 +39,13 @@ bool DMRAccessControl::m_selfOnly = false; unsigned int DMRAccessControl::m_id = 0U; unsigned int DMRAccessControl::m_dstRewriteID = 0U; +unsigned int DMRAccessControl::m_SrcID = 0U; std::time_t DMRAccessControl::m_time; -void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id) +unsigned int DMRAccessControl::m_callHang; + +void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang) { m_dstBlackListSlot1RF = DstIdBlacklistSlot1RF; m_dstWhiteListSlot1RF = DstIdWhitelistSlot1RF; @@ -52,6 +55,7 @@ void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1 m_dstWhiteListSlot1NET = DstIdWhitelistSlot1NET; m_dstBlackListSlot2NET = DstIdBlacklistSlot2NET; m_dstWhiteListSlot2NET = DstIdWhitelistSlot2NET; + m_callHang = callHang; } bool DMRAccessControl::DstIdBlacklist(unsigned int did, unsigned int slot, bool network) @@ -186,33 +190,31 @@ bool DMRAccessControl::validateAccess (unsigned int src_id, unsigned int dst_id, } } -unsigned int DMRAccessControl::DstIdRewrite (unsigned int id, bool network) +unsigned int DMRAccessControl::DstIdRewrite (unsigned int did, unsigned int sid, unsigned int slot, bool network) { - // record current time std::time_t currenttime = std::time(nullptr); - // if the traffic is from the network if (network) { - m_dstRewriteID = id; - // record current time - m_time = std::time(nullptr); - // if the ID is a talkgroup, log and rewrite to TG9 - if (id < 4000 && id > 0) { - LogMessage("Rewrite DST ID (TG) of of inbound network traffic from %u to 9", id); + m_dstRewriteID = did; + m_SrcID = sid; + if (did < 4000 && did > 0 && did != 9) { + LogMessage("DMR Slot %u, Rewrite DST ID (TG) of of inbound network traffic from %u to 9",slot,did); return 9; } else { return 0; } } else { - // if less than 30 seconds has passed since we last saw traffic from network - if (m_dstRewriteID == id && (m_time + 30) > currenttime) { - LogMessage("Inbound DST ID (TG) rewrite seen in last 30 seconds"); - LogMessage("Rewrite DST ID (TG) of outbound network traffic from 9 to %u", id); - m_time = std::time(nullptr); - return(id); + if (m_SrcID == sid && (m_time + m_callHang) > currenttime) { + LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from 9 to %u (return traffic during CallHang)",slot,m_dstRewriteID); + return(m_dstRewriteID); } else { return(0); } } -} +} + +void DMRAccessControl::setOverEndTime() +{ + m_time = std::time(nullptr); +} diff --git a/DMRAccessControl.h b/DMRAccessControl.h index 5e4f989..cc788d1 100644 --- a/DMRAccessControl.h +++ b/DMRAccessControl.h @@ -22,9 +22,10 @@ class DMRAccessControl { public: static bool validateAccess (unsigned int src_id, unsigned int dst_id, unsigned int slot, bool network); - static void init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id); + static void init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang); - static unsigned int DstIdRewrite(unsigned int id, bool network); + static unsigned int DstIdRewrite(unsigned int id, unsigned int sid,unsigned int slot, bool network); + static void setOverEndTime(); private: static std::vector m_dstBlackListSlot1RF; @@ -40,6 +41,8 @@ private: static std::vector m_SrcIdBlacklist; static std::vector m_prefixes; + + static unsigned int m_callHang; static bool m_selfOnly; static unsigned int m_id; @@ -52,6 +55,7 @@ private: static std::time_t m_time; static unsigned int m_dstRewriteID; + static unsigned int m_SrcID; }; diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 2f29850..735a55d 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -152,17 +152,16 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (lc == NULL) return; - unsigned int id = lc->getSrcId(); + unsigned int sid = lc->getSrcId(); unsigned int did = lc->getDstId(); - if (!DMRAccessControl::validateAccess(id, did, m_slotNo, false)) { + if (!DMRAccessControl::validateAccess(sid, did, m_slotNo, false)) { delete lc; return; } - // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, false); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did,sid,m_slotNo,false); if (rw_id) { - LogMessage("Rewrite ID: %u", rw_id); + lc->setDstId(rw_id); } @@ -203,7 +202,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfState = RS_RF_AUDIO; - std::string src = m_lookup->find(id); + std::string src = m_lookup->find(sid); std::string dst = m_lookup->find(m_rfLC->getDstId()); if (m_netState == RS_NET_IDLE) { @@ -486,16 +485,16 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) CDMRLC* lc = m_rfEmbeddedLC.addData(data + 2U, emb.getLCSS()); if (lc != NULL) { - unsigned int id = lc->getSrcId(); + unsigned int sid = lc->getSrcId(); unsigned int did = lc->getDstId(); - if (!DMRAccessControl::validateAccess(id,did,m_slotNo,false)) { + if (!DMRAccessControl::validateAccess(sid,did,m_slotNo,false)) { delete lc; return; } // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, false); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did,sid,m_slotNo,false); if (rw_id) { - LogMessage("Rewrite ID: %u", rw_id); + lc->setDstId(rw_id); } @@ -773,14 +772,14 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } unsigned int did = m_netLC->getDstId(); - unsigned int id = m_netLC->getSrcId(); - if (!DMRAccessControl::validateAccess(did, did, m_slotNo, true)) + unsigned int sid = m_netLC->getSrcId(); + if (!DMRAccessControl::validateAccess(sid, did, m_slotNo, true)) return; // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, true); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did, sid,m_slotNo, true); if (rw_id) { - LogMessage("Rewrite ID: %u", rw_id); + m_netLC->setDstId(rw_id); } @@ -843,14 +842,14 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) return; unsigned int did = m_netLC->getDstId(); - unsigned int id = m_netLC->getSrcId(); - if (!DMRAccessControl::validateAccess(id, did, m_slotNo, true)) + unsigned int sid = m_netLC->getSrcId(); + if (!DMRAccessControl::validateAccess(sid, did, m_slotNo, true)) return; // Test dst rewrite - unsigned int rw_id = DMRAccessControl::DstIdRewrite(id,true); + unsigned int rw_id = DMRAccessControl::DstIdRewrite(did,sid,m_slotNo,true); if (rw_id) { - LogMessage("Rewrite ID: %u", rw_id); + m_netLC->setDstId(rw_id); } @@ -919,6 +918,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) LogMessage("DMR Slot %u, received network end of voice transmission, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeEndNet(); + DMRAccessControl::setOverEndTime(); } else if (dataType == DT_DATA_HEADER) { if (m_netState == RS_NET_DATA) return; @@ -1396,7 +1396,7 @@ void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHa slotType.getData(m_idle + 2U); //Load black and white lists to DMRAccessControl - DMRAccessControl::init(DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, SrcIdBlacklist, m_selfOnly, m_prefixes, m_id); + DMRAccessControl::init(DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, SrcIdBlacklist, m_selfOnly, m_prefixes, m_id,callHang); } From b6f4842b7f3626f7dc658200e2613b58884bc580 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 20:41:14 +0100 Subject: [PATCH 06/16] Completed TG Rewrite, added config options. --- Conf.cpp | 16 ++++++++++++++++ Conf.h | 4 ++++ DMRAccessControl.cpp | 19 ++++++++++++++++--- DMRAccessControl.h | 6 +++++- DMRControl.cpp | 4 ++-- DMRControl.h | 2 +- DMRSlot.cpp | 4 ++-- DMRSlot.h | 2 +- MMDVMHost.cpp | 11 ++++++++++- 9 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 4c099bc..b87724e 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -93,6 +93,8 @@ m_dmrBeacons(false), m_dmrId(0U), m_dmrColorCode(2U), m_dmrSelfOnly(false), +m_TGRewriteSlot1(false), +m_TGRewriteSlot2(false), m_dmrPrefixes(), m_dmrBlackList(), m_dmrDstIdBlacklistSlot1RF(), @@ -330,6 +332,10 @@ bool CConf::read() m_dmrColorCode = (unsigned int)::atoi(value); else if (::strcmp(key, "SelfOnly") == 0) m_dmrSelfOnly = ::atoi(value) == 1; + else if (::strcmp(key, "TGRewriteSlot1") == 0) + m_TGRewriteSlot1 = ::atoi(value) == 1; + else if (::strcmp(key, "TGRewriteSlot2") == 0) + m_TGRewriteSlot2 = ::atoi(value) == 1; else if (::strcmp(key, "Prefixes") == 0) { char* p = ::strtok(value, ",\r\n"); while (p != NULL) { @@ -748,6 +754,16 @@ bool CConf::getDMRSelfOnly() const return m_dmrSelfOnly; } +bool CConf::getDMRTGRewriteSlot1() const +{ + return m_TGRewriteSlot1; +} + +bool CConf::getDMRTGRewriteSlot2() const +{ + return m_TGRewriteSlot2; +} + std::vector CConf::getDMRPrefixes() const { return m_dmrPrefixes; diff --git a/Conf.h b/Conf.h index 7c203a2..39f9b48 100644 --- a/Conf.h +++ b/Conf.h @@ -88,6 +88,8 @@ public: unsigned int getDMRId() const; unsigned int getDMRColorCode() const; bool getDMRSelfOnly() const; + bool getDMRTGRewriteSlot1() const; + bool getDMRTGRewriteSlot2() const; std::vector getDMRPrefixes() const; std::vector getDMRBlackList() const; std::vector getDMRDstIdBlacklistSlot1RF() const; @@ -213,6 +215,8 @@ private: unsigned int m_dmrId; unsigned int m_dmrColorCode; bool m_dmrSelfOnly; + bool m_TGRewriteSlot1; + bool m_TGRewriteSlot2; std::vector m_dmrPrefixes; std::vector m_dmrBlackList; std::vector m_dmrDstIdBlacklistSlot1RF; diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index ee3c000..637a6ef 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -45,7 +45,11 @@ std::time_t DMRAccessControl::m_time; unsigned int DMRAccessControl::m_callHang; -void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang) +bool DMRAccessControl::m_TGRewriteSlot1; +bool DMRAccessControl::m_TGRewriteSlot2; + + +void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang,bool TGRewriteSlot1, bool TGRewriteSlot2) { m_dstBlackListSlot1RF = DstIdBlacklistSlot1RF; m_dstWhiteListSlot1RF = DstIdWhitelistSlot1RF; @@ -56,6 +60,8 @@ void DMRAccessControl::init(const std::vector& DstIdBlacklistSlot1 m_dstBlackListSlot2NET = DstIdBlacklistSlot2NET; m_dstWhiteListSlot2NET = DstIdWhitelistSlot2NET; m_callHang = callHang; + m_TGRewriteSlot1 = TGRewriteSlot1; + m_TGRewriteSlot2 = TGRewriteSlot2; } bool DMRAccessControl::DstIdBlacklist(unsigned int did, unsigned int slot, bool network) @@ -192,6 +198,13 @@ bool DMRAccessControl::validateAccess (unsigned int src_id, unsigned int dst_id, unsigned int DMRAccessControl::DstIdRewrite (unsigned int did, unsigned int sid, unsigned int slot, bool network) { + + if (slot == 1 && m_TGRewriteSlot1 == false) + return 0; + + if (slot == 2 && m_TGRewriteSlot2 == false) + return 0; + std::time_t currenttime = std::time(nullptr); if (network) { @@ -204,8 +217,8 @@ unsigned int DMRAccessControl::DstIdRewrite (unsigned int did, unsigned int sid, return 0; } } else { - if (m_SrcID == sid && (m_time + m_callHang) > currenttime) { - LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from 9 to %u (return traffic during CallHang)",slot,m_dstRewriteID); + if (did == 9 && (m_time + m_callHang) > currenttime) { + LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from %u to %u (return traffic during CallHang)",slot,sid,m_dstRewriteID); return(m_dstRewriteID); } else { return(0); diff --git a/DMRAccessControl.h b/DMRAccessControl.h index cc788d1..ec36497 100644 --- a/DMRAccessControl.h +++ b/DMRAccessControl.h @@ -22,7 +22,7 @@ class DMRAccessControl { public: static bool validateAccess (unsigned int src_id, unsigned int dst_id, unsigned int slot, bool network); - static void init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang); + static void init(const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, const std::vector& SrcIdBlacklist, bool selfOnly, const std::vector& prefixes,unsigned int id,unsigned int callHang, bool TGRewrteSlot1, bool TGRewrteSlot2); static unsigned int DstIdRewrite(unsigned int id, unsigned int sid,unsigned int slot, bool network); static void setOverEndTime(); @@ -57,6 +57,10 @@ private: static unsigned int m_dstRewriteID; static unsigned int m_SrcID; + static bool m_TGRewriteSlot1; + static bool m_TGRewriteSlot2; + + }; diff --git a/DMRControl.cpp b/DMRControl.cpp index 3ba58ee..df42a15 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -20,7 +20,7 @@ #include #include -CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile, int rssiMultiplier, int rssiOffset, unsigned int jitter) : +CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile, int rssiMultiplier, int rssiOffset, unsigned int jitter, bool TGRewriteSlot1, bool TGRewriteSlot2) : m_id(id), m_colorCode(colorCode), m_selfOnly(selfOnly), @@ -38,7 +38,7 @@ m_lookup(NULL) m_lookup = new CDMRLookup(lookupFile); m_lookup->read(); - CDMRSlot::init(id, colorCode, callHang, selfOnly, prefixes, blackList, DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, modem, network, display, duplex, m_lookup, rssiMultiplier, rssiOffset, jitter); + CDMRSlot::init(id, colorCode, callHang, selfOnly, prefixes, blackList, DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, modem, network, display, duplex, m_lookup, rssiMultiplier, rssiOffset, jitter, TGRewriteSlot1, TGRewriteSlot2); } CDMRControl::~CDMRControl() diff --git a/DMRControl.h b/DMRControl.h index 3187828..81649d1 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -30,7 +30,7 @@ class CDMRControl { public: - CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF,const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile, int rssiMultiplier, int rssiOffset, unsigned int jitter); + CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& blackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF,const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile, int rssiMultiplier, int rssiOffset, unsigned int jitter, bool TGRewriteSlot1, bool TGRewriteSlot2); ~CDMRControl(); bool processWakeup(const unsigned char* data); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 735a55d..b7265f6 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -1361,7 +1361,7 @@ void CDMRSlot::writeQueueNet(const unsigned char *data) m_queue.addData(data, len); } -void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& SrcIdBlacklist, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup, int rssiMultiplier, int rssiOffset, unsigned int jitter) +void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& SrcIdBlacklist, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup, int rssiMultiplier, int rssiOffset, unsigned int jitter, bool TGRewriteSlot1, bool TGRewriteSlot2) { assert(id != 0U); assert(modem != NULL); @@ -1396,7 +1396,7 @@ void CDMRSlot::init(unsigned int id, unsigned int colorCode, unsigned int callHa slotType.getData(m_idle + 2U); //Load black and white lists to DMRAccessControl - DMRAccessControl::init(DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, SrcIdBlacklist, m_selfOnly, m_prefixes, m_id,callHang); + DMRAccessControl::init(DstIdBlacklistSlot1RF, DstIdWhitelistSlot1RF, DstIdBlacklistSlot2RF, DstIdWhitelistSlot2RF, DstIdBlacklistSlot1NET, DstIdWhitelistSlot1NET, DstIdBlacklistSlot2NET, DstIdWhitelistSlot2NET, SrcIdBlacklist, m_selfOnly, m_prefixes, m_id,callHang, TGRewriteSlot1, TGRewriteSlot2); } diff --git a/DMRSlot.h b/DMRSlot.h index d678a42..d9a758a 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -50,7 +50,7 @@ public: void clock(); - static void init(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& SrcIdBlackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup, int rssiMultiplier, int rssiOffset, unsigned int jitter); + static void init(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector& prefixes, const std::vector& SrcIdBlackList, const std::vector& DstIdBlacklistSlot1RF, const std::vector& DstIdWhitelistSlot1RF, const std::vector& DstIdBlacklistSlot2RF, const std::vector& DstIdWhitelistSlot2RF, const std::vector& DstIdBlacklistSlot1NET, const std::vector& DstIdWhitelistSlot1NET, const std::vector& DstIdBlacklistSlot2NET, const std::vector& DstIdWhitelistSlot2NET, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup, int rssiMultiplier, int rssiOffset, unsigned int jitter, bool TGRewriteSlot1, bool TGRewriteSlot2); private: unsigned int m_slotNo; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b3bef3b..bc26dce 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -296,6 +296,8 @@ int CMMDVMHost::run() unsigned int id = m_conf.getDMRId(); unsigned int colorCode = m_conf.getDMRColorCode(); bool selfOnly = m_conf.getDMRSelfOnly(); + bool TGRewriteSlot1 = m_conf.getDMRTGRewriteSlot1(); + bool TGRewriteSlot2 = m_conf.getDMRTGRewriteSlot2(); std::vector prefixes = m_conf.getDMRPrefixes(); std::vector blackList = m_conf.getDMRBlackList(); std::vector dstIDBlackListSlot1RF = m_conf.getDMRDstIdBlacklistSlot1RF(); @@ -354,8 +356,15 @@ int CMMDVMHost::run() LogInfo(" RSSI Multiplier: %d", rssiMultiplier); LogInfo(" RSSI Offset: %d", rssiOffset); } + + if (TGRewriteSlot1) + LogInfo(" TG Rewrite Slot 1 enabled"); + + if (TGRewriteSlot2) + LogInfo(" TG Rewrite Slot 2 enabled"); + - dmr = new CDMRControl(id, colorCode, callHang, selfOnly, prefixes, blackList,dstIDBlackListSlot1RF,dstIDWhiteListSlot1RF, dstIDBlackListSlot2RF, dstIDWhiteListSlot2RF, dstIDBlackListSlot1NET,dstIDWhiteListSlot1NET, dstIDBlackListSlot2NET, dstIDWhiteListSlot2NET, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, lookupFile, rssiMultiplier, rssiOffset, jitter); + dmr = new CDMRControl(id, colorCode, callHang, selfOnly, prefixes, blackList,dstIDBlackListSlot1RF,dstIDWhiteListSlot1RF, dstIDBlackListSlot2RF, dstIDWhiteListSlot2RF, dstIDBlackListSlot1NET,dstIDWhiteListSlot1NET, dstIDBlackListSlot2NET, dstIDWhiteListSlot2NET, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, lookupFile, rssiMultiplier, rssiOffset, jitter, TGRewriteSlot1, TGRewriteSlot2); m_dmrTXTimer.setTimeout(txHang); } From 57cf9492044eaa9d7a7e3c5ddcd8debfd2bc7024 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 20:59:25 +0100 Subject: [PATCH 07/16] Add readme for TG Rewrite --- README.TGRewrite | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 README.TGRewrite diff --git a/README.TGRewrite b/README.TGRewrite new file mode 100644 index 0000000..b4b368c --- /dev/null +++ b/README.TGRewrite @@ -0,0 +1,31 @@ +Talk-Group Rewrite was conceived as a way of making talk-groups behave more +like the reflector system and of attempting to solve the problem of "slot +contention",where the user may be locked out of a slot by traffic on a +talk-group they know nothing about, without knowing why. This is frustrating to +users, both those new to DMR and seasoned DMR users. + +TG Rewrite, when enabled for a slot, rewrites the DST ID of incoming talkgroup +traffic to TG9, alowing audio to be heard by any user monitoring TG9 on that +slot. If the user then replies on TG9, as long as they key-up during the +CallHang period, the DST ID (TG) is again rewritten on the outbound traffic, +which transparently maps back to the originating talkgroup. + +To use a User Activated talk-group, briefly key-up on that talk-group to +activate it, then switch back to TG9 and talk as normal. If the CallHang period +expires, you may need to activate the talk-group again by keying up on that +talkgroup briefly, as before. + +It is useful to set the CallHang parameter to a generous amount. I am currently +using seven seconds. + +Two configuration options control the TG Rewrite feature: + +TGRewriteSlot1= +TGRewriteSlot2= + +ACL's are applied before the rewrite, so still apply to rewritten traffic on source talk-group. + +73 + +Simon (G7RZU) + From 36508d730519e815c63e5640ebf7303479c3d7a8 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 21:01:03 +0100 Subject: [PATCH 08/16] Slight edit --- README.TGRewrite | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.TGRewrite b/README.TGRewrite index b4b368c..064c0d1 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -18,10 +18,10 @@ talkgroup briefly, as before. It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds. -Two configuration options control the TG Rewrite feature: +Two boolean configuration options control the TG Rewrite feature: -TGRewriteSlot1= -TGRewriteSlot2= +TGRewriteSlot1=[0|1] +TGRewriteSlot2=[0|1] ACL's are applied before the rewrite, so still apply to rewritten traffic on source talk-group. From ade1ddb2b91a490f18db3d3f54596e0bdc23c84a Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 21:18:57 +0100 Subject: [PATCH 09/16] Tidy up readme --- README.TGRewrite | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.TGRewrite b/README.TGRewrite index 064c0d1..b610735 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -18,12 +18,19 @@ talkgroup briefly, as before. It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds. +If you don't like having to switch back to TG9. You can programme a channel for +your target TG but add an RX list which also includes TG 9 to your channel +definition. Just switch to that chanel and QSO as normal. You'll still hear the +return traffic, but so will everyone else monitoring TG 9, they can even join +in, even if they don't have the target TG programmed in their codeplug. + Two boolean configuration options control the TG Rewrite feature: TGRewriteSlot1=[0|1] TGRewriteSlot2=[0|1] -ACL's are applied before the rewrite, so still apply to rewritten traffic on source talk-group. +ACL's are applied before the rewrite, so still apply to rewritten traffic on +original (non-rewritten) talk-group. 73 From 27c42ff422a25634eee2b1f7330d1b2acb3e1931 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 21:25:17 +0100 Subject: [PATCH 10/16] remove ya --- README.TGRewrite | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.TGRewrite b/README.TGRewrite index b610735..5593ad8 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -18,11 +18,6 @@ talkgroup briefly, as before. It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds. -If you don't like having to switch back to TG9. You can programme a channel for -your target TG but add an RX list which also includes TG 9 to your channel -definition. Just switch to that chanel and QSO as normal. You'll still hear the -return traffic, but so will everyone else monitoring TG 9, they can even join -in, even if they don't have the target TG programmed in their codeplug. Two boolean configuration options control the TG Rewrite feature: From 9a90852566f0349a757ae3cd114f5b6e408353da Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Sep 2016 22:03:43 +0100 Subject: [PATCH 11/16] Track over end time on RF --- DMRSlot.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index b7265f6..3cdde6d 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -262,6 +262,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len) LogMessage("DMR Slot %u, received RF end of voice transmission, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); writeEndRF(); + DMRAccessControl::setOverEndTime(); } else if (dataType == DT_DATA_HEADER) { if (m_rfState == RS_RF_DATA) return; From ce74a799c15aa7f007eb3f0599e92b0a61b32688 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Sep 2016 10:49:12 +0100 Subject: [PATCH 12/16] Fix TG9 handling on rewrite --- DMRAccessControl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 637a6ef..d560380 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -217,8 +217,8 @@ unsigned int DMRAccessControl::DstIdRewrite (unsigned int did, unsigned int sid, return 0; } } else { - if (did == 9 && (m_time + m_callHang) > currenttime) { - LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from %u to %u (return traffic during CallHang)",slot,sid,m_dstRewriteID); + if (did == 9 && m_dstRewriteID != 9 && (m_time + m_callHang) > currenttime) { + LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from %u to %u (return traffic during CallHang)",slot,did,m_dstRewriteID); return(m_dstRewriteID); } else { return(0); From ff04fea52fc68e5f5f6ff95a151f83bdaf351d21 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Sep 2016 13:51:24 +0100 Subject: [PATCH 13/16] Further refinement of TGRewrite logic --- DMRAccessControl.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index d560380..e2a9808 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -216,17 +216,16 @@ unsigned int DMRAccessControl::DstIdRewrite (unsigned int did, unsigned int sid, } else { return 0; } - } else { - if (did == 9 && m_dstRewriteID != 9 && (m_time + m_callHang) > currenttime) { + } else if (did == 9 && m_dstRewriteID != 9 && m_dstRewriteID != 0 && (m_time + m_callHang) > currenttime) { LogMessage("DMR Slot %u, Rewrite DST ID (TG) of outbound network traffic from %u to %u (return traffic during CallHang)",slot,did,m_dstRewriteID); return(m_dstRewriteID); - } else { - return(0); - } - } - + } else if (did < 4000 && did > 0 && did !=9) { + m_dstRewriteID = did; + } + return 0; } + void DMRAccessControl::setOverEndTime() { m_time = std::time(nullptr); From 11c869d1775bf1d2ee71380e773348550006f1cc Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Sep 2016 13:57:32 +0100 Subject: [PATCH 14/16] Update TGRewrite readme --- README.TGRewrite | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.TGRewrite b/README.TGRewrite index 5593ad8..9c19c36 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -8,13 +8,21 @@ TG Rewrite, when enabled for a slot, rewrites the DST ID of incoming talkgroup traffic to TG9, alowing audio to be heard by any user monitoring TG9 on that slot. If the user then replies on TG9, as long as they key-up during the CallHang period, the DST ID (TG) is again rewritten on the outbound traffic, -which transparently maps back to the originating talkgroup. +which transparently maps back to the originating talkgroup. Rewrite is also +enabled if an outbound call is made to a talkgroup and then TG9 is activated +during the callhang period. To use a User Activated talk-group, briefly key-up on that talk-group to activate it, then switch back to TG9 and talk as normal. If the CallHang period expires, you may need to activate the talk-group again by keying up on that talkgroup briefly, as before. +Note, proper ettiquette dictates that the user confirms the repeater is free +before activiating this feature. It is best to ensure the slot is keyed from +"cold" when activating a talkgroup for rewrite. Although not strictly neccesary, +it may be advantageous to also disconnect the repeater from the reflector system +first, if using slot 2. + It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds. From 0a3acc50d00af33a639983b934b5c39f64e893ab Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Sep 2016 13:59:15 +0100 Subject: [PATCH 15/16] More readme updates --- README.TGRewrite | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.TGRewrite b/README.TGRewrite index 9c19c36..5d92fee 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -10,18 +10,19 @@ slot. If the user then replies on TG9, as long as they key-up during the CallHang period, the DST ID (TG) is again rewritten on the outbound traffic, which transparently maps back to the originating talkgroup. Rewrite is also enabled if an outbound call is made to a talkgroup and then TG9 is activated -during the callhang period. +during the CallHang period. To use a User Activated talk-group, briefly key-up on that talk-group to activate it, then switch back to TG9 and talk as normal. If the CallHang period expires, you may need to activate the talk-group again by keying up on that -talkgroup briefly, as before. +talkgroup briefly, as before. Alternatively, you can wait for inbound audio to +re-activate the rewrite, then respond during the CallHang period. Note, proper ettiquette dictates that the user confirms the repeater is free before activiating this feature. It is best to ensure the slot is keyed from -"cold" when activating a talkgroup for rewrite. Although not strictly neccesary, -it may be advantageous to also disconnect the repeater from the reflector system -first, if using slot 2. +"cold" when activating a talkgroup for rewrite. Although not strictly +neccesary, it may be advantageous to also disconnect the repeater from the +reflector system first, if using slot 2. It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds. From a9a8506778385b22cf14e2e88bf4f3ac9c974451 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Sep 2016 14:01:12 +0100 Subject: [PATCH 16/16] Readme additions --- README.TGRewrite | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.TGRewrite b/README.TGRewrite index 5d92fee..8b6480c 100644 --- a/README.TGRewrite +++ b/README.TGRewrite @@ -24,6 +24,9 @@ before activiating this feature. It is best to ensure the slot is keyed from neccesary, it may be advantageous to also disconnect the repeater from the reflector system first, if using slot 2. +Talk-group rewrite was originally intended to work with User-Activated talk +groups, although it will function with permanent talk-groups too. + It is useful to set the CallHang parameter to a generous amount. I am currently using seven seconds.