Add support for GRP UNAFFIL opcode. (#65)

* Add support for GRP UNAFFIL opcode

* Fix line spacing
pull/66/head
firealarmss 2 years ago committed by GitHub
parent 95ea46d7d5
commit e031b2bb8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,6 +6,7 @@
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL
* Copyright (C) 2024 Caleb, KO4UYJ
*
*/
#include "Defines.h"
@ -187,6 +188,20 @@ bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId)
return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_GRP_AFFIL }, buffer, MSG_ANNC_GRP_AFFIL, RTP_END_OF_CALL_SEQ, 0U);
}
/* Writes a group affiliation removal to the network. */
bool BaseNetwork::announceGroupAffiliationRemoval(uint32_t srcId)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
return false;
uint8_t buffer[DATA_PACKET_LENGTH];
__SET_UINT16(srcId, buffer, 0U);
return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_GRP_UNAFFIL }, buffer, MSG_ANNC_GRP_UNAFFIL, RTP_END_OF_CALL_SEQ, 0U);
}
/* Writes a unit registration to the network. */
bool BaseNetwork::announceUnitRegistration(uint32_t srcId)

@ -77,6 +77,7 @@ namespace network
const uint32_t MSG_HDR_SIZE = 24U;
const uint32_t MSG_ANNC_GRP_AFFIL = 6U;
const uint32_t MSG_ANNC_GRP_UNAFFIL = 3U;
const uint32_t MSG_ANNC_UNIT_REG = 3U;
const uint32_t DMR_PACKET_LENGTH = 55U; // 20 byte header + DMR_FRAME_LENGTH_BYTES + 2 byte trailer
const uint32_t P25_LDU1_PACKET_LENGTH = 193U; // 24 byte header + DFSI data + 1 byte frame type + 12 byte enc sync
@ -209,6 +210,13 @@ namespace network
* @returns bool True, if group affiliation announcement was sent, otherwise false.
*/
virtual bool announceGroupAffiliation(uint32_t srcId, uint32_t dstId);
/**
* @brief Writes a group affiliation removal to the network.
* @param srcId Source Radio ID.
* @returns bool True, if group affiliation announcement was sent, otherwise false.
*/
virtual bool announceGroupAffiliationRemoval(uint32_t srcId);
/**
* @brief Writes a unit registration to the network.
* \code{.unparsed}
@ -231,12 +239,14 @@ namespace network
* @returns bool True, if unit deregistration announcement was sent, otherwise false.
*/
virtual bool announceUnitDeregistration(uint32_t srcId);
/**
* @brief Writes a complete update of the peer affiliation list to the network.
* @param affs Complete map of peer unit affiliations.
* @returns bool True, if affiliation update announcement was sent, otherwise false.
*/
virtual bool announceAffiliationUpdate(const std::unordered_map<uint32_t, uint32_t> affs);
/**
* @brief Writes a complete update of the peer's voice channel list to the network.
* @param peers List of voice channel peers.

@ -95,6 +95,7 @@ namespace network
ANNC_SUBFUNC_GRP_AFFIL = 0x00U, //! Announce Group Affiliation
ANNC_SUBFUNC_UNIT_REG = 0x01U, //! Announce Unit Registration
ANNC_SUBFUNC_UNIT_DEREG = 0x02U, //! Announce Unit Deregistration
ANNC_SUBFUNC_GRP_UNAFFIL = 0x03U, //! Announce Group Affiliation Removal
ANNC_SUBFUNC_AFFILS = 0x90U, //! Update All Affiliations
ANNC_SUBFUNC_SITE_VC = 0x9AU //! Announce Site VCs
};

@ -1107,6 +1107,27 @@ void* FNENetwork::threadedNetworkRx(void* arg)
}
}
}
else if (req->fneHeader.getSubFunction() == NET_SUBFUNC::ANNC_SUBFUNC_GRP_UNAFFIL) { // Announce Group Affiliation Removal
if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) {
FNEPeerConnection* connection = network->m_peers[peerId];
if (connection != nullptr) {
std::string ip = udp::Socket::address(req->address);
lookups::AffiliationLookup* aff = network->m_peerAffiliations[peerId];
if (aff == nullptr) {
LogError(LOG_NET, "PEER %u (%s) has an invalid affiliations lookup? This shouldn't happen BUGBUG.", peerId, connection->identity().c_str());
}
// validate peer (simple validation really)
if (connection->connected() && connection->address() == ip && aff != nullptr) {
uint32_t srcId = __GET_UINT16(req->buffer, 0U); // Source Address
aff->groupUnaff(srcId);
}
else {
network->writePeerNAK(peerId, TAG_ANNOUNCE, NET_CONN_NAK_FNE_UNAUTHORIZED);
}
}
}
}
else if (req->fneHeader.getSubFunction() == NET_SUBFUNC::ANNC_SUBFUNC_AFFILS) { // Announce Update All Affiliations
if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) {
FNEPeerConnection* connection = network->m_peers[peerId];

Loading…
Cancel
Save

Powered by TurnKey Linux.