Skip to content

Commit

Permalink
add support to grant demand to support denying a grant and supporting…
Browse files Browse the repository at this point in the history
… unit to unit; better support LOC_REG_RSP being sent over the network;
  • Loading branch information
gatekeep committed Sep 1, 2023
1 parent a09338f commit 5c371c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/p25/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,8 @@ void Control::processNetwork()
}

bool grantDemand = (buffer[14U] & 0x80U) == 0x80U;
bool grantDenial = (buffer[14U] & 0x40U) == 0x40U;
bool unitToUnit = (buffer[14U] & 0x01U) == 0x01U;

// process network message header
uint8_t duid = buffer[22U];
Expand Down Expand Up @@ -1283,7 +1285,15 @@ void Control::processNetwork()
LogMessage(LOG_NET, P25_TSDU_STR " remote grant demand, srcId = %u, dstId = %u", srcId, dstId);
}

if (!m_control->writeRF_TSDU_Grant(srcId, dstId, serviceOptions, true, true)) {
// are we denying the grant?
if (grantDenial) {
m_control->writeRF_TSDU_Deny(srcId, dstId, P25_DENY_RSN_PTT_COLLIDE, (!unitToUnit) ? TSBK_IOSP_GRP_VCH : TSBK_IOSP_UU_VCH);
return;
}

// perform grant response logic
if (!m_control->writeRF_TSDU_Grant(srcId, dstId, serviceOptions, unitToUnit, true))
{
LogError(LOG_NET, P25_TSDU_STR " call failure, network call not granted, dstId = %u", dstId);
return;
}
Expand Down
6 changes: 5 additions & 1 deletion src/p25/packet/ControlSignaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2726,11 +2726,14 @@ bool ControlSignaling::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId,
osp->setDstId(dstId);
osp->setSrcId(srcId);

bool noNet = false;

// validate the source RID
if (!acl::AccessControl::validateSrcId(srcId)) {
LogWarning(LOG_RF, P25_TSDU_STR ", %s denial, RID rejection, srcId = %u", osp->toString().c_str(), srcId);
::ActivityLog("P25", true, "location registration request from %u denied", srcId);
osp->setResponse(P25_RSP_REFUSED);
noNet = true;
}

// validate the source RID is registered
Expand All @@ -2751,6 +2754,7 @@ bool ControlSignaling::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId,
LogWarning(LOG_RF, P25_TSDU_STR ", %s denial, TGID rejection, dstId = %u", osp->toString().c_str(), dstId);
::ActivityLog("P25", true, "location registration request from %u to %s %u denied", srcId, "TG ", dstId);
osp->setResponse(P25_RSP_DENY);
noNet = true;
}
}
}
Expand All @@ -2764,7 +2768,7 @@ bool ControlSignaling::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId,
ret = true;
}

writeRF_TSDU_SBF_Imm(osp.get(), false);
writeRF_TSDU_SBF_Imm(osp.get(), noNet);
return ret;
}

Expand Down

0 comments on commit 5c371c9

Please sign in to comment.