refactor a lot of iterator based C++ for loops into C++ range for loops; correct bad opcode value (this was getting truncated to $3F anyway so no big deal but in code it should be proper);

3.0-rcon_maint
Bryan Biedenkapp 3 years ago
parent e6a399d4fb
commit 7d1ae452dc

@ -674,17 +674,15 @@ void Slot::setSiteData(const std::vector<uint32_t> voiceChNo, const std::unorder
m_channelNo = channelNo; m_channelNo = channelNo;
std::vector<::lookups::IdenTable> entries = m_idenTable->list(); std::vector<::lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) { for (auto entry : entries) {
::lookups::IdenTable entry = *it;
if (entry.channelId() == channelId) { if (entry.channelId() == channelId) {
m_idenEntry = entry; m_idenEntry = entry;
break; break;
} }
} }
std::vector<uint32_t> availCh = voiceChNo; for (uint32_t chNo : voiceChNo) {
for (auto it = availCh.begin(); it != availCh.end(); ++it) { m_affiliations->addRFCh(chNo);
m_affiliations->addRFCh(*it);
} }
m_affiliations->setRFChData(voiceChData); m_affiliations->setRFChData(voiceChData);

@ -133,14 +133,14 @@ bool DMRAffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
LogWarning(LOG_HOST, "%s, force releasing all channel grants", m_name); LogWarning(LOG_HOST, "%s, force releasing all channel grants", m_name);
std::vector<uint32_t> gntsToRel = std::vector<uint32_t>(); std::vector<uint32_t> gntsToRel = std::vector<uint32_t>();
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) { for (auto entry : m_grantChTable) {
uint32_t dstId = it->first; uint32_t dstId = entry.first;
gntsToRel.push_back(dstId); gntsToRel.push_back(dstId);
} }
// release grants // release grants
for (auto it = gntsToRel.begin(); it != gntsToRel.end(); ++it) { for (uint32_t dstId : gntsToRel) {
releaseGrant(*it, false); releaseGrant(dstId, false);
} }
return true; return true;
@ -190,15 +190,15 @@ bool DMRAffiliationLookup::isChBusy(uint32_t chNo) const
} }
// lookup dynamic channel grant table entry // lookup dynamic channel grant table entry
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) { for (auto grantEntry : m_grantChTable) {
if (it->second == chNo) { if (grantEntry.second == chNo) {
uint8_t slotCount = 0U; uint8_t slotCount = 0U;
if (chNo == m_tsccChNo) { if (chNo == m_tsccChNo) {
slotCount++; // one slot is *always* used for TSCC slotCount++; // one slot is *always* used for TSCC
} }
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) { for (auto slotEntry : m_grantChSlotTable) {
uint32_t foundChNo = std::get<0>(it->second); uint32_t foundChNo = std::get<0>(slotEntry.second);
if (foundChNo == chNo) if (foundChNo == chNo)
slotCount++; slotCount++;
} }
@ -226,9 +226,9 @@ uint8_t DMRAffiliationLookup::getGrantedSlot(uint32_t dstId) const
} }
// lookup dynamic channel grant table entry // lookup dynamic channel grant table entry
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) { for (auto entry : m_grantChSlotTable) {
if (it->first == dstId) { if (entry.first == dstId) {
uint8_t slot = std::get<1>(it->second); uint8_t slot = std::get<1>(entry.second);
return slot; return slot;
} }
} }
@ -269,11 +269,11 @@ uint8_t DMRAffiliationLookup::getAvailableSlotForChannel(uint32_t chNo) const
// lookup dynamic channel slot grant table entry // lookup dynamic channel slot grant table entry
bool grantedSlot = false; bool grantedSlot = false;
int slotCount = 0U; int slotCount = 0U;
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) { for (auto entry : m_grantChSlotTable) {
uint32_t foundChNo = std::get<0>(it->second); uint32_t foundChNo = std::get<0>(entry.second);
if (foundChNo == chNo) if (foundChNo == chNo)
{ {
uint8_t foundSlot = std::get<1>(it->second); uint8_t foundSlot = std::get<1>(entry.second);
if (slot == foundSlot) { if (slot == foundSlot) {
switch (foundSlot) { switch (foundSlot) {
case 1U: case 1U:

@ -215,16 +215,16 @@ std::vector<uint32_t> AffiliationLookup::clearGroupAff(uint32_t dstId, bool rele
if (dstId == 0U && releaseAll) { if (dstId == 0U && releaseAll) {
LogWarning(LOG_HOST, "%s, releasing all group affiliations", m_name); LogWarning(LOG_HOST, "%s, releasing all group affiliations", m_name);
for (auto it = m_grpAffTable.begin(); it != m_grpAffTable.end(); ++it) { for (auto entry : m_grpAffTable) {
uint32_t srcId = it->first; uint32_t srcId = entry.first;
srcToRel.push_back(srcId); srcToRel.push_back(srcId);
} }
} }
else { else {
LogWarning(LOG_HOST, "%s, releasing group affiliations, dstId = %u", m_name, dstId); LogWarning(LOG_HOST, "%s, releasing group affiliations, dstId = %u", m_name, dstId);
for (auto it = m_grpAffTable.begin(); it != m_grpAffTable.end(); ++it) { for (auto entry : m_grpAffTable) {
uint32_t srcId = it->first; uint32_t srcId = entry.first;
uint32_t grpId = it->second; uint32_t grpId = entry.second;
if (grpId == dstId) { if (grpId == dstId) {
srcToRel.push_back(srcId); srcToRel.push_back(srcId);
} }
@ -300,14 +300,14 @@ bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
LogWarning(LOG_HOST, "%s, force releasing all channel grants", m_name); LogWarning(LOG_HOST, "%s, force releasing all channel grants", m_name);
std::vector<uint32_t> gntsToRel = std::vector<uint32_t>(); std::vector<uint32_t> gntsToRel = std::vector<uint32_t>();
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) { for (auto entry : m_grantChTable) {
uint32_t dstId = it->first; uint32_t dstId = entry.first;
gntsToRel.push_back(dstId); gntsToRel.push_back(dstId);
} }
// release grants // release grants
for (auto it = gntsToRel.begin(); it != gntsToRel.end(); ++it) { for (uint32_t dstId : gntsToRel) {
releaseGrant(*it, false); releaseGrant(dstId, false);
} }
return true; return true;
@ -350,8 +350,8 @@ bool AffiliationLookup::isChBusy(uint32_t chNo) const
} }
// lookup dynamic channel grant table entry // lookup dynamic channel grant table entry
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) { for (auto entry : m_grantChTable) {
if (it->second == chNo) { if (entry.second == chNo) {
return true; return true;
} }
} }
@ -431,8 +431,8 @@ void AffiliationLookup::clock(uint32_t ms)
{ {
// clock all the grant timers // clock all the grant timers
std::vector<uint32_t> gntsToRel = std::vector<uint32_t>(); std::vector<uint32_t> gntsToRel = std::vector<uint32_t>();
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) { for (auto entry : m_grantChTable) {
uint32_t dstId = it->first; uint32_t dstId = entry.first;
m_grantTimers[dstId].clock(ms); m_grantTimers[dstId].clock(ms);
if (m_grantTimers[dstId].isRunning() && m_grantTimers[dstId].hasExpired()) { if (m_grantTimers[dstId].isRunning() && m_grantTimers[dstId].hasExpired()) {
@ -441,7 +441,7 @@ void AffiliationLookup::clock(uint32_t ms)
} }
// release grants that have timed out // release grants that have timed out
for (auto it = gntsToRel.begin(); it != gntsToRel.end(); ++it) { for (uint32_t dstId : gntsToRel) {
releaseGrant(*it, false); releaseGrant(dstId, false);
} }
} }

@ -98,9 +98,8 @@ std::vector<IdenTable> IdenTableLookup::list()
{ {
std::vector<IdenTable> list = std::vector<IdenTable>(); std::vector<IdenTable> list = std::vector<IdenTable>();
if (m_table.size() > 0) { if (m_table.size() > 0) {
for (auto it = m_table.begin(); it != m_table.end(); ++it) { for (auto entry : m_table) {
IdenTable entry = it->second; list.push_back(entry.second);
list.push_back(entry);
} }
} }

@ -198,15 +198,15 @@ bool RadioIdLookup::load()
std::vector<std::string> parsed; std::vector<std::string> parsed;
char delim = ','; char delim = ',';
for (auto it = line.begin(); it != line.end(); it++) { for (char c : line) {
if (*it == delim) { if (c == delim) {
if (!next.empty()) { if (!next.empty()) {
parsed.push_back(next); parsed.push_back(next);
next.clear(); next.clear();
} }
} }
else else
next += *it; next += c;
} }
if (!next.empty()) if (!next.empty())
parsed.push_back(next); parsed.push_back(next);

@ -161,15 +161,15 @@ bool TalkgroupIdLookup::load()
std::vector<std::string> parsed; std::vector<std::string> parsed;
char delim = ','; char delim = ',';
for (auto it = line.begin(); it != line.end(); it++) { for (char c : line) {
if (*it == delim) { if (c == delim) {
if (!next.empty()) { if (!next.empty()) {
parsed.push_back(next); parsed.push_back(next);
next.clear(); next.clear();
} }
} }
else else
next += *it; next += c;
} }
if (!next.empty()) if (!next.empty())
parsed.push_back(next); parsed.push_back(next);

@ -1107,9 +1107,9 @@ std::string RemoteControl::rcdGetVoiceCh(Host* host, dmr::Control* dmr, p25::Con
std::string reply = ""; std::string reply = "";
if (host->m_voiceChData.size() > 0) { if (host->m_voiceChData.size() > 0) {
for (auto it = host->m_voiceChData.begin(); it != host->m_voiceChData.end(); ++it) { for (auto entry : host->m_voiceChData) {
uint32_t chNo = it->first; uint32_t chNo = entry.first;
lookups::VoiceChData data = it->second; lookups::VoiceChData data = entry.second;
reply += string_format("\r\n%u, %s:%u", chNo, data.address().c_str(), data.port()); reply += string_format("\r\n%u, %s:%u", chNo, data.address().c_str(), data.port());
} }

@ -268,9 +268,8 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
m_siteData = SiteData(locId, channelId, channelNo, serviceClass, false); m_siteData = SiteData(locId, channelId, channelNo, serviceClass, false);
m_siteData.setCallsign(cwCallsign); m_siteData.setCallsign(cwCallsign);
std::vector<uint32_t> availCh = voiceChNo; for (uint32_t ch : voiceChNo) {
for (auto it = availCh.begin(); it != availCh.end(); ++it) { m_affiliations.addRFCh(ch);
m_affiliations.addRFCh(*it);
} }
m_affiliations.setRFChData(voiceChData); m_affiliations.setRFChData(voiceChData);
@ -279,8 +278,7 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
lc::RCCH::setCallsign(cwCallsign); lc::RCCH::setCallsign(cwCallsign);
std::vector<lookups::IdenTable> entries = m_idenTable->list(); std::vector<lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) { for (auto entry : entries) {
lookups::IdenTable entry = *it;
if (entry.channelId() == channelId) { if (entry.channelId() == channelId) {
m_idenEntry = entry; m_idenEntry = entry;
break; break;

@ -304,19 +304,16 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
lc::TSBK::setSiteData(m_siteData); lc::TSBK::setSiteData(m_siteData);
std::vector<::lookups::IdenTable> entries = m_idenTable->list(); std::vector<::lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) { for (auto entry : entries) {
::lookups::IdenTable entry = *it;
if (entry.channelId() == channelId) { if (entry.channelId() == channelId) {
m_idenEntry = entry; m_idenEntry = entry;
break; break;
} }
} }
std::vector<uint32_t> availCh = voiceChNo; m_siteData.setChCnt((uint8_t)voiceChNo.size());
m_siteData.setChCnt((uint8_t)availCh.size()); for (uint32_t ch : voiceChNo) {
m_affiliations.addRFCh(ch);
for (auto it = availCh.begin(); it != availCh.end(); ++it) {
m_affiliations.addRFCh(*it);
} }
m_affiliations.setRFChData(voiceChData); m_affiliations.setRFChData(voiceChData);

@ -354,7 +354,7 @@ namespace p25
const uint8_t TSBK_OSP_MOT_PSH_CCH = 0x0EU; // MOT PSH CCH - Motorola / Planned Control Channel Shutdown const uint8_t TSBK_OSP_MOT_PSH_CCH = 0x0EU; // MOT PSH CCH - Motorola / Planned Control Channel Shutdown
// TSBK Motorola Outbound Signalling Packet (OSP) Opcode(s) // TSBK Motorola Outbound Signalling Packet (OSP) Opcode(s)
const uint8_t TSBK_OSP_DVM_GIT_HASH = 0x7BU; // const uint8_t TSBK_OSP_DVM_GIT_HASH = 0x3FU; //
// Data Unit ID(s) // Data Unit ID(s)
const uint8_t P25_DUID_HDU = 0x00U; // Header Data Unit const uint8_t P25_DUID_HDU = 0x00U; // Header Data Unit

@ -88,8 +88,8 @@ std::vector<uint32_t> P25AffiliationLookup::clearGroupAff(uint32_t dstId, bool r
std::vector<uint32_t> srcToRel = ::lookups::AffiliationLookup::clearGroupAff(dstId, releaseAll); std::vector<uint32_t> srcToRel = ::lookups::AffiliationLookup::clearGroupAff(dstId, releaseAll);
if (srcToRel.size() > 0U) { if (srcToRel.size() > 0U) {
// release affiliations // release affiliations
for (auto it = srcToRel.begin(); it != srcToRel.end(); ++it) { for (uint32_t srcId : srcToRel) {
m_p25->m_trunk->writeRF_TSDU_U_Dereg_Ack(*it); m_p25->m_trunk->writeRF_TSDU_U_Dereg_Ack(srcId);
} }
} }

@ -557,8 +557,8 @@ void Data::clock(uint32_t ms)
{ {
// clock all the connect timers // clock all the connect timers
std::vector<uint32_t> connToClear = std::vector<uint32_t>(); std::vector<uint32_t> connToClear = std::vector<uint32_t>();
for (auto it = m_connQueueTable.begin(); it != m_connQueueTable.end(); ++it) { for (auto entry : m_connQueueTable) {
uint32_t llId = it->first; uint32_t llId = entry.first;
m_connTimerTable[llId].clock(ms); m_connTimerTable[llId].clock(ms);
if (m_connTimerTable[llId].isRunning() && m_connTimerTable[llId].hasExpired()) { if (m_connTimerTable[llId].isRunning() && m_connTimerTable[llId].hasExpired()) {
@ -567,8 +567,7 @@ void Data::clock(uint32_t ms)
} }
// handle PDU connection registration // handle PDU connection registration
for (auto it = connToClear.begin(); it != connToClear.end(); ++it) { for (uint32_t llId : connToClear) {
uint32_t llId = *it;
uint8_t mfId = std::get<0>(m_connQueueTable[llId]); uint8_t mfId = std::get<0>(m_connQueueTable[llId]);
uint64_t ipAddr = std::get<1>(m_connQueueTable[llId]); uint64_t ipAddr = std::get<1>(m_connQueueTable[llId]);

@ -958,10 +958,9 @@ void Trunk::clock(uint32_t ms)
m_adjSiteUpdateTimer.clock(ms); m_adjSiteUpdateTimer.clock(ms);
if (m_adjSiteUpdateTimer.isRunning() && m_adjSiteUpdateTimer.hasExpired()) { if (m_adjSiteUpdateTimer.isRunning() && m_adjSiteUpdateTimer.hasExpired()) {
// update adjacent site data // update adjacent site data
for (auto it = m_adjSiteUpdateCnt.begin(); it != m_adjSiteUpdateCnt.end(); ++it) { for (auto& entry : m_adjSiteUpdateCnt) {
uint8_t siteId = it->first; uint8_t siteId = entry.first;
uint8_t updateCnt = entry.second;
uint8_t updateCnt = it->second;
if (updateCnt > 0U) { if (updateCnt > 0U) {
updateCnt--; updateCnt--;
} }
@ -972,14 +971,13 @@ void Trunk::clock(uint32_t ms)
siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass()); siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass());
} }
m_adjSiteUpdateCnt[siteId] = updateCnt; entry.second = updateCnt;
} }
// update SCCB data // update SCCB data
for (auto it = m_sccbUpdateCnt.begin(); it != m_sccbUpdateCnt.end(); ++it) { for (auto& entry : m_sccbUpdateCnt) {
uint8_t rfssId = it->first; uint8_t rfssId = entry.first;
uint8_t updateCnt = entry.second;
uint8_t updateCnt = it->second;
if (updateCnt > 0U) { if (updateCnt > 0U) {
updateCnt--; updateCnt--;
} }
@ -990,7 +988,7 @@ void Trunk::clock(uint32_t ms)
siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass()); siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass());
} }
m_sccbUpdateCnt[rfssId] = updateCnt; entry.second = updateCnt;
} }
m_adjSiteUpdateTimer.setTimeout(m_adjSiteUpdateInterval); m_adjSiteUpdateTimer.setTimeout(m_adjSiteUpdateInterval);
@ -1858,15 +1856,15 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
bool noData = false; bool noData = false;
uint8_t i = 0U; uint8_t i = 0U;
std::unordered_map<uint32_t, uint32_t> grantTable = m_p25->m_affiliations.grantTable(); std::unordered_map<uint32_t, uint32_t> grantTable = m_p25->m_affiliations.grantTable();
for (auto it = grantTable.begin(); it != grantTable.end(); ++it) { for (auto entry : grantTable) {
// no good very bad way of skipping entries... // no good very bad way of skipping entries...
if (i != m_mbfGrpGrntCnt) { if (i != m_mbfGrpGrntCnt) {
i++; i++;
continue; continue;
} }
else { else {
uint32_t dstId = it->first; uint32_t dstId = entry.first;
uint32_t chNo = it->second; uint32_t chNo = entry.second;
if (chNo == 0U) { if (chNo == 0U) {
noData = true; noData = true;
@ -1906,15 +1904,13 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
m_mbfIdenCnt = 0U; m_mbfIdenCnt = 0U;
uint8_t i = 0U; uint8_t i = 0U;
for (auto it = entries.begin(); it != entries.end(); ++it) { for (auto entry : entries) {
// no good very bad way of skipping entries... // no good very bad way of skipping entries...
if (i != m_mbfIdenCnt) { if (i != m_mbfIdenCnt) {
i++; i++;
continue; continue;
} }
else { else {
::lookups::IdenTable entry = *it;
// LogDebug(LOG_P25, "baseFrequency = %uHz, txOffsetMhz = %fMHz, chBandwidthKhz = %fKHz, chSpaceKhz = %fKHz", // LogDebug(LOG_P25, "baseFrequency = %uHz, txOffsetMhz = %fMHz, chBandwidthKhz = %fKHz, chSpaceKhz = %fKHz",
// entry.baseFrequency(), entry.txOffsetMhz(), entry.chBandwidthKhz(), entry.chSpaceKhz()); // entry.baseFrequency(), entry.txOffsetMhz(), entry.chBandwidthKhz(), entry.chSpaceKhz());
@ -1969,14 +1965,14 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
std::unique_ptr<OSP_ADJ_STS_BCAST> osp = new_unique(OSP_ADJ_STS_BCAST); std::unique_ptr<OSP_ADJ_STS_BCAST> osp = new_unique(OSP_ADJ_STS_BCAST);
uint8_t i = 0U; uint8_t i = 0U;
for (auto it = m_adjSiteTable.begin(); it != m_adjSiteTable.end(); ++it) { for (auto entry : m_adjSiteTable) {
// no good very bad way of skipping entries... // no good very bad way of skipping entries...
if (i != m_mbfAdjSSCnt) { if (i != m_mbfAdjSSCnt) {
i++; i++;
continue; continue;
} }
else { else {
SiteData site = it->second; SiteData site = entry.second;
uint8_t cfva = P25_CFVA_NETWORK; uint8_t cfva = P25_CFVA_NETWORK;
if (m_adjSiteUpdateCnt[site.siteId()] == 0U) { if (m_adjSiteUpdateCnt[site.siteId()] == 0U) {
@ -2018,14 +2014,14 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
std::unique_ptr<OSP_SCCB_EXP> osp = new_unique(OSP_SCCB_EXP); std::unique_ptr<OSP_SCCB_EXP> osp = new_unique(OSP_SCCB_EXP);
uint8_t i = 0U; uint8_t i = 0U;
for (auto it = m_sccbTable.begin(); it != m_sccbTable.end(); ++it) { for (auto entry : m_sccbTable) {
// no good very bad way of skipping entries... // no good very bad way of skipping entries...
if (i != m_mbfSCCBCnt) { if (i != m_mbfSCCBCnt) {
i++; i++;
continue; continue;
} }
else { else {
SiteData site = it->second; SiteData site = entry.second;
// transmit SCCB broadcast // transmit SCCB broadcast
osp->setLCO(TSBK_OSP_SCCB_EXP); osp->setLCO(TSBK_OSP_SCCB_EXP);

Loading…
Cancel
Save

Powered by TurnKey Linux.