@ -1072,7 +1072,7 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const
skipRidCheck = true ;
}
LogDebug ( LOG_NET , " P25, duid = $%02X, mfId = $%02X, lco = $%02X, srcId = %u, dstId = %u " , duid , control . getMFId ( ) , control . getLCO ( ) , control . getSrcId ( ) , control . getDstId ( ) ) ;
//LogDebug(LOG_NET, " P25, duid = $%02X, mfId = $%02X, lco = $%02X, srcId = %u, dstId = %u", duid, control.getMFId(), control.getLCO(), control.getSrcId(), control.getDstId());
// is the source ID a blacklisted ID?
if ( ! skipRidCheck ) {
@ -1249,6 +1249,16 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const
return false ;
}
// peer always send list takes priority over any following affiliation rules
bool isAlwaysPeer = false ;
std : : vector < uint32_t > alwaysSend = tg . config ( ) . alwaysSend ( ) ;
if ( alwaysSend . size ( ) > 0 ) {
auto it = std : : find ( alwaysSend . begin ( ) , alwaysSend . end ( ) , peerId ) ;
if ( it ! = alwaysSend . end ( ) ) {
isAlwaysPeer = true ; // skip any following checks and always send traffic
}
}
// is the TGID active?
if ( ! tg . config ( ) . active ( ) ) {
// report error event to InfluxDB
@ -1269,34 +1279,36 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const
return false ;
}
// does the TGID have a permitted RID list?
if ( tg . config ( ) . permittedRIDs ( ) . size ( ) > 0 ) {
// does the transmitting RID have permission?
std : : vector < uint32_t > permittedRIDs = tg . config ( ) . permittedRIDs ( ) ;
if ( std : : find ( permittedRIDs . begin ( ) , permittedRIDs . end ( ) , control . getSrcId ( ) ) = = permittedRIDs . end ( ) ) {
// report error event to InfluxDB
if ( m_network - > m_enableInfluxDB ) {
influxdb : : QueryBuilder ( )
. meas ( " call_error_event " )
. tag ( " peerId " , std : : to_string ( peerId ) )
. tag ( " streamId " , std : : to_string ( streamId ) )
. tag ( " srcId " , std : : to_string ( control . getSrcId ( ) ) )
. tag ( " dstId " , std : : to_string ( control . getDstId ( ) ) )
. field ( " message " , INFLUXDB_ERRSTR_RID_NOT_PERMITTED )
. timestamp ( std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( std : : chrono : : system_clock : : now ( ) . time_since_epoch ( ) ) . count ( ) )
. request ( m_network - > m_influxServer ) ;
}
// always peers can violate the rules...hurray
if ( ! isAlwaysPeer ) {
// does the TGID have a permitted RID list?
if ( tg . config ( ) . permittedRIDs ( ) . size ( ) > 0 ) {
// does the transmitting RID have permission?
std : : vector < uint32_t > permittedRIDs = tg . config ( ) . permittedRIDs ( ) ;
if ( std : : find ( permittedRIDs . begin ( ) , permittedRIDs . end ( ) , control . getSrcId ( ) ) = = permittedRIDs . end ( ) ) {
// report error event to InfluxDB
if ( m_network - > m_enableInfluxDB ) {
influxdb : : QueryBuilder ( )
. meas ( " call_error_event " )
. tag ( " peerId " , std : : to_string ( peerId ) )
. tag ( " streamId " , std : : to_string ( streamId ) )
. tag ( " srcId " , std : : to_string ( control . getSrcId ( ) ) )
. tag ( " dstId " , std : : to_string ( control . getDstId ( ) ) )
. field ( " message " , INFLUXDB_ERRSTR_RID_NOT_PERMITTED )
. timestamp ( std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( std : : chrono : : system_clock : : now ( ) . time_since_epoch ( ) ) . count ( ) )
. request ( m_network - > m_influxServer ) ;
}
// report In-Call Control to the peer sending traffic
m_network - > writePeerICC ( peerId , streamId , NET_SUBFUNC : : PROTOCOL_SUBFUNC_P25 , NET_ICC : : REJECT_TRAFFIC , control . getDstId ( ) ) ;
return false ;
// report In-Call Control to the peer sending traffic
m_network - > writePeerICC ( peerId , streamId , NET_SUBFUNC : : PROTOCOL_SUBFUNC_P25 , NET_ICC : : REJECT_TRAFFIC , control . getDstId ( ) ) ;
return false ;
}
}
}
return true ;
}
/* Helper to write a grant packet. */
bool TagP25Data : : write_TSDU_Grant ( uint32_t peerId , uint32_t srcId , uint32_t dstId , uint8_t serviceOptions , bool grp )