Skip to content

Commit

Permalink
Merge pull request #90 from hacknix/master
Browse files Browse the repository at this point in the history
Access Control for DMR
  • Loading branch information
g4klx authored Jun 11, 2016
2 parents c9f9d16 + 05c1b52 commit 0be7f59
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 21 deletions.
52 changes: 51 additions & 1 deletion Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ m_dmrColorCode(2U),
m_dmrSelfOnly(false),
m_dmrPrefixes(),
m_dmrBlackList(),
m_dmrDstIdBlacklistSlot1(),
m_dmrDstIdBlacklistSlot2(),
m_dmrDstIdWhitelistSlot1(),
m_dmrDstIdWhitelistSlot2(),
m_dmrLookupFile(),
m_dmrTXHang(4U),
m_fusionEnabled(true),
Expand Down Expand Up @@ -314,6 +318,38 @@ bool CConf::read()
m_dmrBlackList.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "DstIdBlackListSlot1") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrDstIdBlacklistSlot1.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "DstIdBlackListSlot2") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrDstIdBlacklistSlot2.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "DstIdWhiteListSlot1") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrDstIdWhitelistSlot1.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "DstIdWhiteListSlot2") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrDstIdWhitelistSlot2.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "LookupFile") == 0)
m_dmrLookupFile = value;
else if (::strcmp(key, "TXHang") == 0)
Expand Down Expand Up @@ -626,7 +662,21 @@ std::vector<unsigned int> CConf::getDMRBlackList() const
{
return m_dmrBlackList;
}

std::vector<unsigned int> CConf::getDMRDstIdBlacklistSlot1() const
{
return m_dmrDstIdBlacklistSlot1;
}
std::vector<unsigned int> CConf::getDMRDstIdBlacklistSlot2() const
{
return m_dmrDstIdBlacklistSlot2;
}
std::vector<unsigned int> CConf::getDMRDstIdWhitelistSlot1() const
{
return m_dmrDstIdWhitelistSlot1;
}std::vector<unsigned int> CConf::getDMRDstIdWhitelistSlot2() const
{
return m_dmrDstIdWhitelistSlot2;
}
std::string CConf::getDMRLookupFile() const
{
return m_dmrLookupFile;
Expand Down
8 changes: 8 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class CConf
bool getDMRSelfOnly() const;
std::vector<unsigned int> getDMRPrefixes() const;
std::vector<unsigned int> getDMRBlackList() const;
std::vector<unsigned int> getDMRDstIdBlacklistSlot1() const;
std::vector<unsigned int> getDMRDstIdBlacklistSlot2() const;
std::vector<unsigned int> getDMRDstIdWhitelistSlot1() const;
std::vector<unsigned int> getDMRDstIdWhitelistSlot2() const;
std::string getDMRLookupFile() const;
unsigned int getDMRTXHang() const;

Expand Down Expand Up @@ -192,6 +196,10 @@ class CConf
bool m_dmrSelfOnly;
std::vector<unsigned int> m_dmrPrefixes;
std::vector<unsigned int> m_dmrBlackList;
std::vector<unsigned int> m_dmrDstIdBlacklistSlot1;
std::vector<unsigned int> m_dmrDstIdBlacklistSlot2;
std::vector<unsigned int> m_dmrDstIdWhitelistSlot1;
std::vector<unsigned int> m_dmrDstIdWhitelistSlot2;
std::string m_dmrLookupFile;
unsigned int m_dmrTXHang;

Expand Down
4 changes: 2 additions & 2 deletions DMRControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <cassert>
#include <algorithm>

CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile) :
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, const std::vector<unsigned int>& DstIdBlacklistSlot1, const std::vector<unsigned int>& DstIdWhitelistSlot1, const std::vector<unsigned int>& DstIdBlacklistSlot2, const std::vector<unsigned int>& DstIdWhitelistSlot2, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile) :
m_id(id),
m_colorCode(colorCode),
m_selfOnly(selfOnly),
Expand All @@ -38,7 +38,7 @@ m_lookup(NULL)
m_lookup = new CDMRLookup(lookupFile);
m_lookup->read();

CDMRSlot::init(id, colorCode, selfOnly, prefixes, blackList, modem, network, display, duplex, m_lookup);
CDMRSlot::init(id, colorCode, selfOnly, prefixes, blackList, DstIdBlacklistSlot1, DstIdWhitelistSlot1, DstIdBlacklistSlot2, DstIdWhitelistSlot2, modem, network, display, duplex, m_lookup);
}

CDMRControl::~CDMRControl()
Expand Down
2 changes: 1 addition & 1 deletion DMRControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class CDMRControl {
public:
CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile);
CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, const std::vector<unsigned int>& DstIdBlacklistSlot1, const std::vector<unsigned int>& DstIdWhitelistSlot1, const std::vector<unsigned int>& DstIdBlacklistSlot2, const std::vector<unsigned int>& DstIdWhitelistSlot2, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile);
~CDMRControl();

bool processWakeup(const unsigned char* data);
Expand Down
Loading

0 comments on commit 0be7f59

Please sign in to comment.