make Win32 compiles work again; correct incorrect behavior handling try_lock_for;

pull/85/head
Bryan Biedenkapp 10 months ago
parent 4fc8990d16
commit fb0e51f36a

@ -15,7 +15,7 @@
#include "common/Log.h"
#include "common/Thread.h"
#include "common/Utils.h"
#include "network/RPC.h"
#include "network/NetRPC.h"
using namespace network;
using namespace network::frame;
@ -34,9 +34,9 @@ using namespace network::frame;
// Public Class Members
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RPC class. */
/* Initializes a new instance of the NetRPC class. */
RPC::RPC(const std::string& address, uint16_t port, uint16_t localPort, const std::string& password, bool debug) :
NetRPC::NetRPC(const std::string& address, uint16_t port, uint16_t localPort, const std::string& password, bool debug) :
m_address(address),
m_port(port),
m_debug(debug),
@ -54,9 +54,9 @@ RPC::RPC(const std::string& address, uint16_t port, uint16_t localPort, const st
m_frameQueue = new RawFrameQueue(m_socket, debug);
}
/* Finalizes a instance of the RPC class. */
/* Finalizes a instance of the NetRPC class. */
RPC::~RPC()
NetRPC::~NetRPC()
{
if (m_frameQueue != nullptr) {
delete m_frameQueue;
@ -69,7 +69,7 @@ RPC::~RPC()
/* Updates the timer by the passed number of milliseconds. */
void RPC::clock(uint32_t ms)
void NetRPC::clock(uint32_t ms)
{
sockaddr_storage address;
uint32_t addrLen;
@ -82,19 +82,19 @@ void RPC::clock(uint32_t ms)
uint8_t* raw = buffer.get();
if (length > 0) {
if (length < RPC_HEADER_LENGTH_BYTES) {
LogError(LOG_NET, "RPC::clock(), message received from network is malformed! %u bytes != %u bytes",
LogError(LOG_NET, "NetRPC::clock(), message received from network is malformed! %u bytes != %u bytes",
RPC_HEADER_LENGTH_BYTES, length);
return;
}
// decode RTP header
if (!rpcHeader.decode(buffer.get())) {
LogError(LOG_NET, "RPC::clock(), invalid RPC packet received from network");
LogError(LOG_NET, "NetRPC::clock(), invalid RPC packet received from network");
return;
}
if (m_debug) {
LogDebugEx(LOG_NET, "RPC::clock()", "received RPC, %s:%u, func = $%04X, messageLength = %u",
LogDebugEx(LOG_NET, "NetRPC::clock()", "received RPC, %s:%u, func = $%04X, messageLength = %u",
udp::Socket::address(address).c_str(), udp::Socket::port(address), rpcHeader.getFunction(), rpcHeader.getMessageLength());
}
@ -105,11 +105,11 @@ void RPC::clock(uint32_t ms)
uint16_t calc = edac::CRC::createCRC16(message.get(), messageLength * 8U);
if (m_debug) {
LogDebugEx(LOG_NET, "RPC::clock()", "RPC, calc = $%04X, crc = $%04X", calc, rpcHeader.getCRC());
LogDebugEx(LOG_NET, "NetRPC::clock()", "RPC, calc = $%04X, crc = $%04X", calc, rpcHeader.getCRC());
}
if (calc != rpcHeader.getCRC()) {
LogError(LOG_NET, "RPC::clock(), failed CRC CCITT-162 check");
LogError(LOG_NET, "NetRPC::clock(), failed CRC CCITT-162 check");
return;
}
@ -119,13 +119,13 @@ void RPC::clock(uint32_t ms)
json::value v;
std::string err = json::parse(v, content);
if (!err.empty()) {
LogError(LOG_NET, "RPC::clock(), invalid RPC JSON payload, %s", err.c_str());
LogError(LOG_NET, "NetRPC::clock(), invalid RPC JSON payload, %s", err.c_str());
return;
}
// ensure parsed JSON is an object
if (!v.is<json::object>()) {
LogError(LOG_NET, "RPC::clock(), invalid RPC JSON payload, request was not a JSON object");
LogError(LOG_NET, "NetRPC::clock(), invalid RPC JSON payload, request was not a JSON object");
return;
}
@ -158,7 +158,7 @@ void RPC::clock(uint32_t ms)
}
int status = request["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (request["message"].is<std::string>()) {
std::string retMsg = request["message"].get<std::string>();
::LogError(LOG_NET, "RPC %s:%u failed, %s", udp::Socket::address(address).c_str(), udp::Socket::port(address), retMsg.c_str());
@ -166,14 +166,14 @@ void RPC::clock(uint32_t ms)
}
}
else
LogWarning(LOG_NET, "RPC::clock(), ignoring unhandled function, func = $%04X, reply = %u", rpcHeader.getFunction() & 0x3FFFU, isReply);
LogWarning(LOG_NET, "NetRPC::clock(), ignoring unhandled function, func = $%04X, reply = %u", rpcHeader.getFunction() & 0x3FFFU, isReply);
}
}
}
/* Writes an RPC request to the network. */
bool RPC::req(uint16_t func, const json::object& request, RPCType reply, std::string address, uint16_t port,
bool NetRPC::req(uint16_t func, const json::object& request, RPCType reply, std::string address, uint16_t port,
bool blocking)
{
sockaddr_storage addr;
@ -187,14 +187,14 @@ bool RPC::req(uint16_t func, const json::object& request, RPCType reply, std::st
/* Writes an RPC request to the network. */
bool RPC::req(uint16_t func, const json::object& request, RPCType reply, sockaddr_storage& address, uint32_t addrLen,
bool NetRPC::req(uint16_t func, const json::object& request, RPCType reply, sockaddr_storage& address, uint32_t addrLen,
bool blocking)
{
json::value v = json::value(request);
std::string json = v.serialize();
if (m_debug) {
LogDebugEx(LOG_NET, "RPC::req()", "sending RPC, %s:%u, func = $%04X, messageLength = %u",
LogDebugEx(LOG_NET, "NetRPC::req()", "sending RPC, %s:%u, func = $%04X, messageLength = %u",
udp::Socket::address(address).c_str(), udp::Socket::port(address), func, json.length() + 1U);
}
@ -217,7 +217,7 @@ bool RPC::req(uint16_t func, const json::object& request, RPCType reply, sockadd
uint16_t crc = edac::CRC::createCRC16((uint8_t*)message, (json.length() + 1U) * 8U);
if (m_debug) {
LogDebugEx(LOG_NET, "RPC::req()", "RPC, crc = $%04X", crc);
LogDebugEx(LOG_NET, "NetRPC::req()", "RPC, crc = $%04X", crc);
}
header.setCRC(crc);
@ -252,7 +252,7 @@ bool RPC::req(uint16_t func, const json::object& request, RPCType reply, sockadd
}
if (m_debug)
LogDebugEx(LOG_HOST, "RPC::req()", "blocking = %u, to = %d", blocking, timeout);
LogDebugEx(LOG_HOST, "NetRPC::req()", "blocking = %u, to = %d", blocking, timeout);
timeout--;
Thread::sleep(1);
@ -274,7 +274,7 @@ bool RPC::req(uint16_t func, const json::object& request, RPCType reply, sockadd
/* Helper to generate a default response error payload. */
void RPC::defaultResponse(json::object& reply, std::string message, StatusType status)
void NetRPC::defaultResponse(json::object& reply, std::string message, StatusType status)
{
reply = json::object();
@ -285,7 +285,7 @@ void RPC::defaultResponse(json::object& reply, std::string message, StatusType s
/* Opens connection to the network. */
bool RPC::open()
bool NetRPC::open()
{
if (m_debug)
LogMessage(LOG_NET, "Opening RPC network");
@ -312,7 +312,7 @@ bool RPC::open()
/* Closes connection to the network. */
void RPC::close()
void NetRPC::close()
{
if (m_debug)
LogMessage(LOG_NET, "Closing RPC network");
@ -327,7 +327,7 @@ void RPC::close()
/* Writes an RPC reply to the network. */
bool RPC::reply(uint16_t func, json::object& reply, sockaddr_storage& address, uint32_t addrLen)
bool NetRPC::reply(uint16_t func, json::object& reply, sockaddr_storage& address, uint32_t addrLen)
{
json::value v = json::value(reply);
std::string json = v.serialize();
@ -358,7 +358,7 @@ bool RPC::reply(uint16_t func, json::object& reply, sockaddr_storage& address, u
/* Default status response handler. */
void RPC::defaultHandler(json::object& request, json::object& reply)
void NetRPC::defaultHandler(json::object& request, json::object& reply)
{
reply = json::object();

@ -8,18 +8,22 @@
*
*/
/**
* @file RPC.h
* @file NetRPC.h
* @ingroup network_core
* @file RPC.cpp
* @file NetRPC.cpp
* @ingroup network_core
*/
#if !defined(__RPC_H__)
#define __RPC_H__
#if !defined(__NET_RPC_H__)
#define __NET_RPC_H__
#if defined(_WIN32)
#include <Winsock2.h>
#endif // defined(_WIN32)
#include "common/Defines.h"
#include "common/network/udp/Socket.h"
#include "common/network/RawFrameQueue.h"
#include "common/network/json/json.h"
#include "common/network/udp/Socket.h"
#include <string>
#include <cstdint>
@ -28,6 +32,15 @@
namespace network
{
namespace udp
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Socket;
}
// ---------------------------------------------------------------------------
// Macros
// ---------------------------------------------------------------------------
@ -42,7 +55,7 @@ namespace network
* @brief Implements the Remote Procedure Call networking logic.
* @ingroup network_core
*/
class HOST_SW_API RPC {
class HOST_SW_API NetRPC {
public:
typedef std::function<void(json::object& request, json::object& reply)> RPCType;
@ -58,7 +71,7 @@ namespace network
} status;
/**
* @brief Initializes a new instance of the RPC class.
* @brief Initializes a new instance of the NetRPC class.
* @param address Network Hostname/IP address to connect to.
* @param port Network port number.
* @param localPort
@ -66,11 +79,11 @@ namespace network
* @param password Network authentication password.
* @param debug Flag indicating whether network debug is enabled.
*/
RPC(const std::string& address, uint16_t port, uint16_t localPort, const std::string& password, bool debug);
NetRPC(const std::string& address, uint16_t port, uint16_t localPort, const std::string& password, bool debug);
/**
* @brief Finalizes a instance of the RPC class.
* @brief Finalizes a instance of the NetRPC class.
*/
~RPC();
~NetRPC();
/**
* @brief Updates the timer by the passed number of milliseconds.
@ -164,4 +177,4 @@ namespace network
};
} // namespace network
#endif // __RPC_H__
#endif // __NET_RPC_H__

@ -1205,9 +1205,11 @@ void* FNENetwork::threadedNetworkRx(void* arg)
LogMessage(LOG_NET, "PEER %u (%s) no local key or container, requesting key from upstream master, algId = $%02X, kID = $%04X", peerId, connection->identity().c_str(),
modifyKey->getAlgId(), modifyKey->getKId());
network->m_keyQueueMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = network->m_keyQueueMutex.try_lock_for(std::chrono::milliseconds(60));
network->m_peerLinkKeyQueue[peerId] = modifyKey->getKId();
network->m_keyQueueMutex.unlock();
if (locked)
network->m_keyQueueMutex.unlock();
peer.second->writeMaster({ NET_FUNC::KEY_REQ, NET_SUBFUNC::NOP },
req->buffer, req->length, RTP_END_OF_CALL_SEQ, 0U, false, false);

@ -175,7 +175,7 @@ namespace network
bool hasStreamPktSeq(uint64_t streamId)
{
bool ret = false;
m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
// determine if the stream has a current sequence no and return
{
@ -188,7 +188,8 @@ namespace network
}
}
m_streamSeqMutex.unlock();
if (locked)
m_streamSeqMutex.unlock();
return ret;
}
@ -200,7 +201,7 @@ namespace network
*/
uint16_t getStreamPktSeq(uint64_t streamId)
{
m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
// find the current sequence no and return
uint32_t pktSeq = 0U;
@ -213,7 +214,8 @@ namespace network
}
}
m_streamSeqMutex.unlock();
if (locked)
m_streamSeqMutex.unlock();
return pktSeq;
}
@ -226,7 +228,7 @@ namespace network
*/
uint16_t incStreamPktSeq(uint64_t streamId, uint16_t initialSeq)
{
m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
// find the current sequence no, increment and return
uint32_t pktSeq = 0U;
@ -246,7 +248,8 @@ namespace network
}
}
m_streamSeqMutex.unlock();
if (locked)
m_streamSeqMutex.unlock();
return pktSeq;
}
@ -257,7 +260,7 @@ namespace network
*/
void eraseStreamPktSeq(uint64_t streamId)
{
m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = m_streamSeqMutex.try_lock_for(std::chrono::milliseconds(60));
// find the sequence no and erase
{
@ -267,7 +270,8 @@ namespace network
}
}
m_streamSeqMutex.unlock();
if (locked)
m_streamSeqMutex.unlock();
}
public:

@ -389,9 +389,12 @@ void P25PacketData::clock(uint32_t ms)
// transmit queued data frames
bool processed = false;
m_vtunMutex.try_lock_for(std::chrono::milliseconds(60));
bool locked = m_vtunMutex.try_lock_for(std::chrono::milliseconds(60));
auto& dataFrame = m_dataFrames[0];
m_vtunMutex.unlock();
if (locked)
m_vtunMutex.unlock();
if (dataFrame != nullptr) {
if (now > dataFrame->timestamp + 500U) {
@ -456,7 +459,7 @@ void P25PacketData::clock(uint32_t ms)
}
pkt_clock_abort:
m_vtunMutex.try_lock_for(std::chrono::milliseconds(60));
locked = m_vtunMutex.try_lock_for(std::chrono::milliseconds(60));
m_dataFrames.pop_front();
if (processed) {
if (dataFrame->buffer != nullptr)
@ -466,7 +469,9 @@ pkt_clock_abort:
// requeue packet
m_dataFrames.push_back(dataFrame);
}
m_vtunMutex.unlock();
if (locked)
m_vtunMutex.unlock();
}
// ---------------------------------------------------------------------------

@ -10,6 +10,11 @@
#include "fne/Defines.h"
#include "fne/network/influxdb/InfluxDB.h"
#if defined(_WIN32)
#include <ws2tcpip.h>
#include <Winsock2.h>
#endif
using namespace network::influxdb;
// ---------------------------------------------------------------------------

@ -32,6 +32,8 @@
#ifdef _WIN32
#define NOMINMAX
#include <ws2tcpip.h>
#include <Winsock2.h>
#include <windows.h>
#include <algorithm>
@ -636,7 +638,11 @@ namespace network
{
TSCallerRequest* req = (TSCallerRequest*)arg;
if (req != nullptr) {
#if defined(_WIN32)
::CloseHandle(req->thread);
#else
::pthread_detach(req->thread);
#endif // defined(_WIN32)
#ifdef _GNU_SOURCE
::pthread_setname_np(req->thread, "fluxql:request");

@ -757,7 +757,7 @@ bool Host::createNetwork()
// initialize RPC
m_rpcAddress = rpcAddress;
m_rpcPort = rpcPort;
g_RPC = new RPC(rpcAddress, rpcPort, 0U, rpcPassword, rpcDebug);
g_RPC = new NetRPC(rpcAddress, rpcPort, 0U, rpcPassword, rpcDebug);
bool ret = g_RPC->open();
if (!ret) {
delete g_RPC;

@ -38,7 +38,7 @@ using namespace lookups;
// Global Variables
// ---------------------------------------------------------------------------
network::RPC* g_RPC = nullptr;
network::NetRPC* g_RPC = nullptr;
// ---------------------------------------------------------------------------
// Static Class Members
@ -2156,7 +2156,7 @@ void* Host::threadPresence(void* arg)
// register VC -> CC notification RPC handler
g_RPC->registerHandler(RPC_REGISTER_CC_VC, [=](json::object &req, json::object &reply) {
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
if (!host->m_dmrTSCCData && !host->m_p25CCData && !host->m_nxdnCCData) {
g_RPC->defaultResponse(reply, "Host is not a control channel, cannot register voice channel");
@ -2165,7 +2165,7 @@ void* Host::threadPresence(void* arg)
// validate channelNo is a string within the JSON blob
if (!req["channelNo"].is<int>()) {
g_RPC->defaultResponse(reply, "channelNo was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "channelNo was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -2173,7 +2173,7 @@ void* Host::threadPresence(void* arg)
// validate peerId is a string within the JSON blob
if (!req["peerId"].is<int>()) {
g_RPC->defaultResponse(reply, "peerId was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "peerId was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -2183,12 +2183,12 @@ void* Host::threadPresence(void* arg)
// validate restAddress is a string within the JSON blob
if (!req["rpcAddress"].is<std::string>()) {
g_RPC->defaultResponse(reply, "rpcAddress was not a valid string", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "rpcAddress was not a valid string", network::NetRPC::INVALID_ARGS);
return;
}
if (!req["rpcPort"].is<int>()) {
g_RPC->defaultResponse(reply, "rpcPort was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "rpcPort was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -2216,7 +2216,7 @@ void* Host::threadPresence(void* arg)
g_fireCCVCNotification = true; // announce this registration immediately to the FNE
} else {
LogMessage(LOG_REST, "VC, registration rejected, peerId = %u, chNo = %u, VC wasn't a defined member of the CC voice channel list", peerId, channelNo);
g_RPC->defaultResponse(reply, "registration rejected", network::RPC::BAD_REQUEST);
g_RPC->defaultResponse(reply, "registration rejected", network::NetRPC::BAD_REQUEST);
}
});
@ -2262,7 +2262,7 @@ void* Host::threadPresence(void* arg)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_HOST, "failed to notify the CC %s:%u of VC registration", host->m_controlChData.address().c_str(), host->m_controlChData.port());
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();

@ -34,7 +34,7 @@
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/network/json/json.h"
#include "common/network/Network.h"
#include "common/network/RPC.h"
#include "common/network/NetRPC.h"
#include "common/yaml/Yaml.h"
#include "dmr/Control.h"
#include "p25/Control.h"
@ -61,7 +61,7 @@
// ---------------------------------------------------------------------------
/** @brief */
extern network::RPC* g_RPC;
extern network::NetRPC* g_RPC;
// ---------------------------------------------------------------------------
// Class Prototypes

@ -792,11 +792,11 @@ void Control::processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId,
void Control::RPC_permittedTG(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -804,7 +804,7 @@ void Control::RPC_permittedTG(json::object& req, json::object& reply)
// validate slot is a integer within the JSON blob
if (!req["slot"].is<int>()) {
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -824,11 +824,11 @@ void Control::RPC_permittedTG(json::object& req, json::object& reply)
void Control::RPC_releaseGrantTG(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -841,7 +841,7 @@ void Control::RPC_releaseGrantTG(json::object& req, json::object& reply)
// validate slot is a integer within the JSON blob
if (!req["slot"].is<int>()) {
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -871,11 +871,11 @@ void Control::RPC_releaseGrantTG(json::object& req, json::object& reply)
void Control::RPC_touchGrantTG(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -888,7 +888,7 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply)
// validate slot is a integer within the JSON blob
if (!req["slot"].is<int>()) {
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "slot was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -918,17 +918,17 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply)
void Control::RPC_tsccPayloadActivate(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["slot"].is<uint8_t>()) {
g_RPC->defaultResponse(reply, "slot was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "slot was not valid", network::NetRPC::INVALID_ARGS);
return;
}
// validate clear flag is a boolean within the JSON blob
if (!req["clear"].is<bool>()) {
g_RPC->defaultResponse(reply, "clear flag was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "clear flag was not valid", network::NetRPC::INVALID_ARGS);
return;
}
@ -946,25 +946,25 @@ void Control::RPC_tsccPayloadActivate(json::object& req, json::object& reply)
else {
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<uint32_t>()) {
g_RPC->defaultResponse(reply, "destination ID was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not valid", network::NetRPC::INVALID_ARGS);
return;
}
// validate destination ID is a integer within the JSON blob
if (!req["srcId"].is<uint32_t>()) {
g_RPC->defaultResponse(reply, "source ID was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "source ID was not valid", network::NetRPC::INVALID_ARGS);
return;
}
// validate group flag is a boolean within the JSON blob
if (!req["group"].is<bool>()) {
g_RPC->defaultResponse(reply, "group flag was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "group flag was not valid", network::NetRPC::INVALID_ARGS);
return;
}
// validate voice flag is a boolean within the JSON blob
if (!req["voice"].is<bool>()) {
g_RPC->defaultResponse(reply, "voice flag was not valid", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "voice flag was not valid", network::NetRPC::INVALID_ARGS);
return;
}

@ -31,7 +31,7 @@
#include "common/lookups/IdenTableLookup.h"
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/network/RPC.h"
#include "common/network/NetRPC.h"
#include "common/network/RTPFNEHeader.h"
#include "common/network/Network.h"
#include "common/yaml/Yaml.h"

@ -1269,7 +1269,7 @@ void Slot::notifyCC_ReleaseGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_DMR, "DMR Slot %u, failed to notify the CC %s:%u of the release of, dstId = %u", m_slotNo, m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
@ -1316,7 +1316,7 @@ void Slot::notifyCC_TouchGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_DMR, "DMR Slot %u, failed to notify the CC %s:%u of the touch of, dstId = %u", m_slotNo, m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();

@ -966,7 +966,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError((net) ? LOG_NET : LOG_RF, "DMR Slot %u, RPC failed, %s", tscc->m_slotNo, retMsg.c_str());
@ -1059,7 +1059,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError((net) ? LOG_NET : LOG_RF, "DMR Slot %u, RPC failed, %s", tscc->m_slotNo, retMsg.c_str());

@ -1080,7 +1080,7 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_NXDN, "failed to notify the CC %s:%u of the release of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
@ -1124,7 +1124,7 @@ void Control::notifyCC_TouchGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_NXDN, "failed to notify the CC %s:%u of the touch of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
@ -1140,11 +1140,11 @@ void Control::notifyCC_TouchGrant(uint32_t dstId)
void Control::RPC_permittedTG(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -1160,15 +1160,15 @@ void Control::RPC_permittedTG(json::object& req, json::object& reply)
void Control::RPC_releaseGrantTG(json::object& req, json::object& reply)
{
if (!m_enableControl) {
g_RPC->defaultResponse(reply, "not NXDN control channel", network::RPC::BAD_REQUEST);
g_RPC->defaultResponse(reply, "not NXDN control channel", network::NetRPC::BAD_REQUEST);
return;
}
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -1207,11 +1207,11 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply)
return;
}
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}

@ -31,7 +31,7 @@
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/lookups/AffiliationLookup.h"
#include "common/network/RPC.h"
#include "common/network/NetRPC.h"
#include "common/network/RTPFNEHeader.h"
#include "common/network/Network.h"
#include "common/RingBuffer.h"

@ -581,7 +581,7 @@ bool ControlSignaling::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uin
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError((net) ? LOG_NET : LOG_RF, "NXDN, RPC failed, %s", retMsg.c_str());

@ -1600,7 +1600,7 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_P25, "failed to notify the CC %s:%u of the release of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
@ -1644,7 +1644,7 @@ void Control::notifyCC_TouchGrant(uint32_t dstId)
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
::LogError(LOG_P25, "failed to notify the CC %s:%u of the touch of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId);
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
@ -1800,11 +1800,11 @@ void Control::writeRF_TDU(bool noNetwork, bool imm)
void Control::RPC_permittedTG(json::object& req, json::object& reply)
{
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -1826,15 +1826,15 @@ void Control::RPC_permittedTG(json::object& req, json::object& reply)
void Control::RPC_releaseGrantTG(json::object& req, json::object& reply)
{
if (!m_enableControl) {
g_RPC->defaultResponse(reply, "not P25 control channel", network::RPC::BAD_REQUEST);
g_RPC->defaultResponse(reply, "not P25 control channel", network::NetRPC::BAD_REQUEST);
return;
}
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}
@ -1873,11 +1873,11 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply)
return;
}
g_RPC->defaultResponse(reply, "OK", network::RPC::OK);
g_RPC->defaultResponse(reply, "OK", network::NetRPC::OK);
// validate destination ID is a integer within the JSON blob
if (!req["dstId"].is<int>()) {
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::RPC::INVALID_ARGS);
g_RPC->defaultResponse(reply, "destination ID was not a valid integer", network::NetRPC::INVALID_ARGS);
return;
}

@ -31,7 +31,7 @@
#include "common/lookups/IdenTableLookup.h"
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/network/RPC.h"
#include "common/network/NetRPC.h"
#include "common/network/RTPFNEHeader.h"
#include "common/network/Network.h"
#include "common/p25/SiteData.h"

@ -2308,7 +2308,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError((net) ? LOG_NET : LOG_RF, "P25, RPC failed, %s", retMsg.c_str());
@ -2378,7 +2378,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError((net) ? LOG_NET : LOG_RF, "P25, RPC failed, %s", retMsg.c_str());
@ -2596,7 +2596,7 @@ bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip, uint3
}
int status = req["status"].get<int>();
if (status != network::RPC::OK) {
if (status != network::NetRPC::OK) {
if (req["message"].is<std::string>()) {
std::string retMsg = req["message"].get<std::string>();
::LogError(LOG_RF, "P25, RPC failed, %s", retMsg.c_str());

Loading…
Cancel
Save

Powered by TurnKey Linux.