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;
std::vector<::lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) {
::lookups::IdenTable entry = *it;
for (auto entry : entries) {
if (entry.channelId() == channelId) {
m_idenEntry = entry;
break;
}
}
std::vector<uint32_t> availCh = voiceChNo;
for (auto it = availCh.begin(); it != availCh.end(); ++it) {
m_affiliations->addRFCh(*it);
for (uint32_t chNo : voiceChNo) {
m_affiliations->addRFCh(chNo);
}
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);
std::vector<uint32_t> gntsToRel = std::vector<uint32_t>();
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) {
uint32_t dstId = it->first;
for (auto entry : m_grantChTable) {
uint32_t dstId = entry.first;
gntsToRel.push_back(dstId);
}
// release grants
for (auto it = gntsToRel.begin(); it != gntsToRel.end(); ++it) {
releaseGrant(*it, false);
for (uint32_t dstId : gntsToRel) {
releaseGrant(dstId, false);
}
return true;
@ -190,15 +190,15 @@ bool DMRAffiliationLookup::isChBusy(uint32_t chNo) const
}
// lookup dynamic channel grant table entry
for (auto it = m_grantChTable.begin(); it != m_grantChTable.end(); ++it) {
if (it->second == chNo) {
for (auto grantEntry : m_grantChTable) {
if (grantEntry.second == chNo) {
uint8_t slotCount = 0U;
if (chNo == m_tsccChNo) {
slotCount++; // one slot is *always* used for TSCC
}
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) {
uint32_t foundChNo = std::get<0>(it->second);
for (auto slotEntry : m_grantChSlotTable) {
uint32_t foundChNo = std::get<0>(slotEntry.second);
if (foundChNo == chNo)
slotCount++;
}
@ -226,9 +226,9 @@ uint8_t DMRAffiliationLookup::getGrantedSlot(uint32_t dstId) const
}
// lookup dynamic channel grant table entry
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) {
if (it->first == dstId) {
uint8_t slot = std::get<1>(it->second);
for (auto entry : m_grantChSlotTable) {
if (entry.first == dstId) {
uint8_t slot = std::get<1>(entry.second);
return slot;
}
}
@ -269,11 +269,11 @@ uint8_t DMRAffiliationLookup::getAvailableSlotForChannel(uint32_t chNo) const
// lookup dynamic channel slot grant table entry
bool grantedSlot = false;
int slotCount = 0U;
for (auto it = m_grantChSlotTable.begin(); it != m_grantChSlotTable.end(); ++it) {
uint32_t foundChNo = std::get<0>(it->second);
for (auto entry : m_grantChSlotTable) {
uint32_t foundChNo = std::get<0>(entry.second);
if (foundChNo == chNo)
{
uint8_t foundSlot = std::get<1>(it->second);
uint8_t foundSlot = std::get<1>(entry.second);
if (slot == foundSlot) {
switch (foundSlot) {
case 1U:

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

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

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

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

@ -1107,9 +1107,9 @@ std::string RemoteControl::rcdGetVoiceCh(Host* host, dmr::Control* dmr, p25::Con
std::string reply = "";
if (host->m_voiceChData.size() > 0) {
for (auto it = host->m_voiceChData.begin(); it != host->m_voiceChData.end(); ++it) {
uint32_t chNo = it->first;
lookups::VoiceChData data = it->second;
for (auto entry : host->m_voiceChData) {
uint32_t chNo = entry.first;
lookups::VoiceChData data = entry.second;
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.setCallsign(cwCallsign);
std::vector<uint32_t> availCh = voiceChNo;
for (auto it = availCh.begin(); it != availCh.end(); ++it) {
m_affiliations.addRFCh(*it);
for (uint32_t ch : voiceChNo) {
m_affiliations.addRFCh(ch);
}
m_affiliations.setRFChData(voiceChData);
@ -279,8 +278,7 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
lc::RCCH::setCallsign(cwCallsign);
std::vector<lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) {
lookups::IdenTable entry = *it;
for (auto entry : entries) {
if (entry.channelId() == channelId) {
m_idenEntry = entry;
break;

@ -304,19 +304,16 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
lc::TSBK::setSiteData(m_siteData);
std::vector<::lookups::IdenTable> entries = m_idenTable->list();
for (auto it = entries.begin(); it != entries.end(); ++it) {
::lookups::IdenTable entry = *it;
for (auto entry : entries) {
if (entry.channelId() == channelId) {
m_idenEntry = entry;
break;
}
}
std::vector<uint32_t> availCh = voiceChNo;
m_siteData.setChCnt((uint8_t)availCh.size());
for (auto it = availCh.begin(); it != availCh.end(); ++it) {
m_affiliations.addRFCh(*it);
m_siteData.setChCnt((uint8_t)voiceChNo.size());
for (uint32_t ch : voiceChNo) {
m_affiliations.addRFCh(ch);
}
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
// 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)
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);
if (srcToRel.size() > 0U) {
// release affiliations
for (auto it = srcToRel.begin(); it != srcToRel.end(); ++it) {
m_p25->m_trunk->writeRF_TSDU_U_Dereg_Ack(*it);
for (uint32_t srcId : srcToRel) {
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
std::vector<uint32_t> connToClear = std::vector<uint32_t>();
for (auto it = m_connQueueTable.begin(); it != m_connQueueTable.end(); ++it) {
uint32_t llId = it->first;
for (auto entry : m_connQueueTable) {
uint32_t llId = entry.first;
m_connTimerTable[llId].clock(ms);
if (m_connTimerTable[llId].isRunning() && m_connTimerTable[llId].hasExpired()) {
@ -567,8 +567,7 @@ void Data::clock(uint32_t ms)
}
// handle PDU connection registration
for (auto it = connToClear.begin(); it != connToClear.end(); ++it) {
uint32_t llId = *it;
for (uint32_t llId : connToClear) {
uint8_t mfId = std::get<0>(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);
if (m_adjSiteUpdateTimer.isRunning() && m_adjSiteUpdateTimer.hasExpired()) {
// update adjacent site data
for (auto it = m_adjSiteUpdateCnt.begin(); it != m_adjSiteUpdateCnt.end(); ++it) {
uint8_t siteId = it->first;
uint8_t updateCnt = it->second;
for (auto& entry : m_adjSiteUpdateCnt) {
uint8_t siteId = entry.first;
uint8_t updateCnt = entry.second;
if (updateCnt > 0U) {
updateCnt--;
}
@ -972,14 +971,13 @@ void Trunk::clock(uint32_t ms)
siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass());
}
m_adjSiteUpdateCnt[siteId] = updateCnt;
entry.second = updateCnt;
}
// update SCCB data
for (auto it = m_sccbUpdateCnt.begin(); it != m_sccbUpdateCnt.end(); ++it) {
uint8_t rfssId = it->first;
uint8_t updateCnt = it->second;
for (auto& entry : m_sccbUpdateCnt) {
uint8_t rfssId = entry.first;
uint8_t updateCnt = entry.second;
if (updateCnt > 0U) {
updateCnt--;
}
@ -990,7 +988,7 @@ void Trunk::clock(uint32_t ms)
siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass());
}
m_sccbUpdateCnt[rfssId] = updateCnt;
entry.second = updateCnt;
}
m_adjSiteUpdateTimer.setTimeout(m_adjSiteUpdateInterval);
@ -1858,15 +1856,15 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
bool noData = false;
uint8_t i = 0U;
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...
if (i != m_mbfGrpGrntCnt) {
i++;
continue;
}
else {
uint32_t dstId = it->first;
uint32_t chNo = it->second;
uint32_t dstId = entry.first;
uint32_t chNo = entry.second;
if (chNo == 0U) {
noData = true;
@ -1906,15 +1904,13 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
m_mbfIdenCnt = 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...
if (i != m_mbfIdenCnt) {
i++;
continue;
}
else {
::lookups::IdenTable entry = *it;
// LogDebug(LOG_P25, "baseFrequency = %uHz, txOffsetMhz = %fMHz, chBandwidthKhz = %fKHz, chSpaceKhz = %fKHz",
// 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);
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...
if (i != m_mbfAdjSSCnt) {
i++;
continue;
}
else {
SiteData site = it->second;
SiteData site = entry.second;
uint8_t cfva = P25_CFVA_NETWORK;
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);
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...
if (i != m_mbfSCCBCnt) {
i++;
continue;
}
else {
SiteData site = it->second;
SiteData site = entry.second;
// transmit SCCB broadcast
osp->setLCO(TSBK_OSP_SCCB_EXP);

Loading…
Cancel
Save

Powered by TurnKey Linux.