diff --git a/Conf.cpp b/Conf.cpp index d7fb925..a861360 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -65,6 +65,8 @@ m_dmrNetwork1TGRewrites(), m_dmrNetwork1PCRewrites(), m_dmrNetwork1TypeRewrites(), m_dmrNetwork1SrcRewrites(), +m_dmrNetwork1PassAllPC(), +m_dmrNetwork1PassAllTG(), m_dmrNetwork2Enabled(false), m_dmrNetwork2Id(0U), m_dmrNetwork2Address(), @@ -77,6 +79,8 @@ m_dmrNetwork2TGRewrites(), m_dmrNetwork2PCRewrites(), m_dmrNetwork2TypeRewrites(), m_dmrNetwork2SrcRewrites(), +m_dmrNetwork2PassAllPC(), +m_dmrNetwork2PassAllTG(), m_xlxNetwork1Enabled(false), m_xlxNetwork1Id(0U), m_xlxNetwork1Address(), @@ -302,6 +306,12 @@ bool CConf::read() rewrite.m_range = ::atoi(p5); m_dmrNetwork1SrcRewrites.push_back(rewrite); } + } else if (::strcmp(key, "PassAllPC") == 0) { + unsigned int slotNo = (unsigned int)::atoi(value); + m_dmrNetwork1PassAllPC.push_back(slotNo); + } else if (::strcmp(key, "PassAllTG") == 0) { + unsigned int slotNo = (unsigned int)::atoi(value); + m_dmrNetwork1PassAllTG.push_back(slotNo); } } else if (section == SECTION_DMR_NETWORK_2) { if (::strcmp(key, "Enabled") == 0) @@ -378,6 +388,12 @@ bool CConf::read() rewrite.m_range = ::atoi(p5); m_dmrNetwork2SrcRewrites.push_back(rewrite); } + } else if (::strcmp(key, "PassAllPC") == 0) { + unsigned int slotNo = (unsigned int)::atoi(value); + m_dmrNetwork2PassAllPC.push_back(slotNo); + } else if (::strcmp(key, "PassAllTG") == 0) { + unsigned int slotNo = (unsigned int)::atoi(value); + m_dmrNetwork2PassAllTG.push_back(slotNo); } } } @@ -627,6 +643,16 @@ std::vector CConf::getDMRNetwork1SrcRewrites() const return m_dmrNetwork1SrcRewrites; } +std::vector CConf::getDMRNetwork1PassAllPC() const +{ + return m_dmrNetwork1PassAllPC; +} + +std::vector CConf::getDMRNetwork1PassAllTG() const +{ + return m_dmrNetwork1PassAllTG; +} + bool CConf::getDMRNetwork2Enabled() const { return m_dmrNetwork2Enabled; @@ -686,3 +712,13 @@ std::vector CConf::getDMRNetwork2SrcRewrites() const { return m_dmrNetwork2SrcRewrites; } + +std::vector CConf::getDMRNetwork2PassAllPC() const +{ + return m_dmrNetwork2PassAllPC; +} + +std::vector CConf::getDMRNetwork2PassAllTG() const +{ + return m_dmrNetwork2PassAllTG; +} diff --git a/Conf.h b/Conf.h index 160a6ae..2834d3c 100644 --- a/Conf.h +++ b/Conf.h @@ -94,6 +94,8 @@ public: std::vector getDMRNetwork1PCRewrites() const; std::vector getDMRNetwork1TypeRewrites() const; std::vector getDMRNetwork1SrcRewrites() const; + std::vector getDMRNetwork1PassAllPC() const; + std::vector getDMRNetwork1PassAllTG() const; // The DMR Network 2 section bool getDMRNetwork2Enabled() const; @@ -108,6 +110,8 @@ public: std::vector getDMRNetwork2PCRewrites() const; std::vector getDMRNetwork2TypeRewrites() const; std::vector getDMRNetwork2SrcRewrites() const; + std::vector getDMRNetwork2PassAllPC() const; + std::vector getDMRNetwork2PassAllTG() const; // The XLX Network 1 section bool getXLXNetwork1Enabled() const; @@ -166,6 +170,8 @@ private: std::vector m_dmrNetwork1PCRewrites; std::vector m_dmrNetwork1TypeRewrites; std::vector m_dmrNetwork1SrcRewrites; + std::vector m_dmrNetwork1PassAllPC; + std::vector m_dmrNetwork1PassAllTG; bool m_dmrNetwork2Enabled; unsigned int m_dmrNetwork2Id; @@ -179,6 +185,8 @@ private: std::vector m_dmrNetwork2PCRewrites; std::vector m_dmrNetwork2TypeRewrites; std::vector m_dmrNetwork2SrcRewrites; + std::vector m_dmrNetwork2PassAllPC; + std::vector m_dmrNetwork2PassAllTG; bool m_xlxNetwork1Enabled; unsigned int m_xlxNetwork1Id; diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 9cfc328..055b390 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -21,6 +21,8 @@ #include "DMRGateway.h" #include "StopWatch.h" #include "RewritePC.h" +#include "PassAllPC.h" +#include "PassAllTG.h" #include "Version.h" #include "Thread.h" #include "Voice.h" @@ -778,6 +780,28 @@ bool CDMRGateway::createDMRNetwork1() m_dmr1NetRewrites.push_back(rewrite); } + std::vector tgPassAll = m_conf.getDMRNetwork2PassAllTG(); + for (std::vector::const_iterator it = tgPassAll.begin(); it != tgPassAll.end(); ++it) { + LogInfo(" Pass All TG: %u", *it); + + CPassAllTG* rfPassAllTG = new CPassAllTG("DMR-1", *it); + CPassAllTG* netPassAllTG = new CPassAllTG("DMR-1", *it); + + m_dmr1RFRewrites.push_back(rfPassAllTG); + m_dmr1NetRewrites.push_back(netPassAllTG); + } + + std::vector pcPassAll = m_conf.getDMRNetwork2PassAllPC(); + for (std::vector::const_iterator it = pcPassAll.begin(); it != pcPassAll.end(); ++it) { + LogInfo(" Pass All PC: %u", *it); + + CPassAllPC* rfPassAllPC = new CPassAllPC("DMR-1", *it); + CPassAllPC* netPassAllPC = new CPassAllPC("DMR-1", *it); + + m_dmr1RFRewrites.push_back(rfPassAllPC); + m_dmr1NetRewrites.push_back(netPassAllPC); + } + return true; } @@ -864,6 +888,28 @@ bool CDMRGateway::createDMRNetwork2() m_dmr2NetRewrites.push_back(rewrite); } + std::vector tgPassAll = m_conf.getDMRNetwork2PassAllTG(); + for (std::vector::const_iterator it = tgPassAll.begin(); it != tgPassAll.end(); ++it) { + LogInfo(" Pass All TG: %u", *it); + + CPassAllTG* rfPassAllTG = new CPassAllTG("DMR-2", *it); + CPassAllTG* netPassAllTG = new CPassAllTG("DMR-2", *it); + + m_dmr2RFRewrites.push_back(rfPassAllTG); + m_dmr2NetRewrites.push_back(netPassAllTG); + } + + std::vector pcPassAll = m_conf.getDMRNetwork2PassAllPC(); + for (std::vector::const_iterator it = pcPassAll.begin(); it != pcPassAll.end(); ++it) { + LogInfo(" Pass All PC: %u", *it); + + CPassAllPC* rfPassAllPC = new CPassAllPC("DMR-2", *it); + CPassAllPC* netPassAllPC = new CPassAllPC("DMR-2", *it); + + m_dmr2RFRewrites.push_back(rfPassAllPC); + m_dmr2NetRewrites.push_back(netPassAllPC); + } + return true; } diff --git a/DMRGateway.ini b/DMRGateway.ini index ee515b5..6ed3d9c 100644 --- a/DMRGateway.ini +++ b/DMRGateway.ini @@ -60,6 +60,9 @@ TypeRewrite=1,9990,1,9990 SrcRewrite=1,9990,1,9990,1 # Reflector status returns SrcRewrite=2,4000,2,9,1001 +# Pass all of the other private traffic on slot 1 and slot 2 +PassAllPC=1 +PassAllPC=2 Password=PASSWORD Debug=0 @@ -75,5 +78,8 @@ TGRewrite=2,8,2,9,1 TGRewrite=2,9990,2,9990,1 # Reflector control command slot 2 84000->4000 to 85000->5000 PCRewrite=2,84000,2,4000,1001 +# Pass all of the other talk group traffic on slot 1 and slot 2 +PassAllTG=1 +PassAllTG=2 Password=PASSWORD Debug=0 diff --git a/DMRGateway.vcxproj b/DMRGateway.vcxproj index 1b02149..4c5f463 100644 --- a/DMRGateway.vcxproj +++ b/DMRGateway.vcxproj @@ -168,6 +168,8 @@ + + @@ -203,6 +205,8 @@ + + @@ -223,4 +227,4 @@ - + \ No newline at end of file diff --git a/DMRGateway.vcxproj.filters b/DMRGateway.vcxproj.filters index 05fbb47..d6fcb34 100644 --- a/DMRGateway.vcxproj.filters +++ b/DMRGateway.vcxproj.filters @@ -113,6 +113,12 @@ Header Files + + Header Files + + + Header Files + @@ -208,5 +214,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/Makefile b/Makefile index 0b98223..1635dd3 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ LIBS = -lpthread LDFLAGS = -g OBJECTS = BPTC19696.o Conf.o CRC.o DMRData.o DMREmbeddedData.o DMREMB.o DMRFullLC.o DMRGateway.o DMRLC.o DMRNetwork.o DMRSlotType.o Golay2087.o Hamming.o Log.o \ - MMDVMNetwork.o QR1676.o RepeaterProtocol.o Rewrite.o RewritePC.o RewriteSrc.o RewriteTG.o RewriteType.o RS129.o SHA256.o StopWatch.o Sync.o \ - Thread.o Timer.o UDPSocket.o Utils.o Voice.o + MMDVMNetwork.o PassAllPC.o PassAllTG.o QR1676.o RepeaterProtocol.o Rewrite.o RewritePC.o RewriteSrc.o RewriteTG.o RewriteType.o RS129.o SHA256.o StopWatch.o \ + Sync.o Thread.o Timer.o UDPSocket.o Utils.o Voice.o all: DMRGateway diff --git a/PassAllPC.cpp b/PassAllPC.cpp new file mode 100644 index 0000000..13614d4 --- /dev/null +++ b/PassAllPC.cpp @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2017 by Jonathan Naylor G4KLX +* +* 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 +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "PassAllPC.h" + +#include "DMRDefines.h" + +#include +#include + +CPassAllPC::CPassAllPC(const char* name, unsigned int slot) : +m_name(name), +m_slot(slot) +{ + assert(slot == 1U || slot == 2U); +} + +CPassAllPC::~CPassAllPC() +{ +} + +bool CPassAllPC::processRF(CDMRData& data) +{ + return process(data); +} + +bool CPassAllPC::processNet(CDMRData& data) +{ + return process(data); +} + +bool CPassAllPC::process(CDMRData& data) +{ + FLCO flco = data.getFLCO(); + unsigned int slotNo = data.getSlotNo(); + + return flco == FLCO_USER_USER || slotNo == m_slot; +} diff --git a/PassAllPC.h b/PassAllPC.h new file mode 100644 index 0000000..cfb3afb --- /dev/null +++ b/PassAllPC.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2017 by Jonathan Naylor G4KLX +* +* 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 +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#if !defined(PASSALLPC_H) +#define PASSALLPC_H + +#include "Rewrite.h" +#include "DMRData.h" + +class CPassAllPC : public IRewrite { +public: + CPassAllPC(const char* name, unsigned int slot); + virtual ~CPassAllPC(); + + virtual bool processRF(CDMRData& data); + virtual bool processNet(CDMRData& data); + +private: + const char* m_name; + unsigned int m_slot; + + bool process(CDMRData& data); +}; + + +#endif diff --git a/PassAllTG.cpp b/PassAllTG.cpp new file mode 100644 index 0000000..3f9d628 --- /dev/null +++ b/PassAllTG.cpp @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2017 by Jonathan Naylor G4KLX +* +* 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 +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "PassAllTG.h" + +#include "DMRDefines.h" + +#include +#include + +CPassAllTG::CPassAllTG(const char* name, unsigned int slot) : +m_name(name), +m_slot(slot) +{ + assert(slot == 1U || slot == 2U); +} + +CPassAllTG::~CPassAllTG() +{ +} + +bool CPassAllTG::processRF(CDMRData& data) +{ + return process(data); +} + +bool CPassAllTG::processNet(CDMRData& data) +{ + return process(data); +} + +bool CPassAllTG::process(CDMRData& data) +{ + FLCO flco = data.getFLCO(); + unsigned int slotNo = data.getSlotNo(); + + return flco == FLCO_GROUP || slotNo == m_slot; +} diff --git a/PassAllTG.h b/PassAllTG.h new file mode 100644 index 0000000..e17d7b6 --- /dev/null +++ b/PassAllTG.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2017 by Jonathan Naylor G4KLX +* +* 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 +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#if !defined(PASSALLTG_H) +#define PASSALLTG_H + +#include "Rewrite.h" +#include "DMRData.h" + +class CPassAllTG : public IRewrite { +public: + CPassAllTG(const char* name, unsigned int slot); + virtual ~CPassAllTG(); + + virtual bool processRF(CDMRData& data); + virtual bool processNet(CDMRData& data); + +private: + const char* m_name; + unsigned int m_slot; + + bool process(CDMRData& data); +}; + + +#endif