diff --git a/Makefile b/Makefile index edd12a62..d584a7d0 100644 --- a/Makefile +++ b/Makefile @@ -72,15 +72,7 @@ OBJECTS = \ Utils.o \ HostMain.o -BIN = ../bin - all: dvmhost - -cp -f dvmhost $(BIN) - if [ ! -e $(BIN)/config.yml ]; then cp -f config.yml $(BIN); fi - if [ ! -e $(BIN)/rid_acl.dat ]; then cp -f rid_acl.dat $(BIN); fi - if [ ! -e $(BIN)/tg_acl.dat ]; then cp -f tg_acl.dat $(BIN); fi - if [ ! -e $(BIN)/iden_table.dat ]; then cp -f iden_table.dat $(BIN); fi - if [ ! -e $(BIN)/RSSI.dat ]; then cp -f RSSI.dat $(BIN); fi dvmhost: $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost diff --git a/Makefile.arm b/Makefile.arm index 31a7e406..2970f99e 100644 --- a/Makefile.arm +++ b/Makefile.arm @@ -72,15 +72,7 @@ OBJECTS = \ Utils.o \ HostMain.o -BIN = ../bin - all: dvmhost - -cp -f dvmhost $(BIN) - if [ ! -e $(BIN)/config.yml ]; then cp -f config.yml $(BIN); fi - if [ ! -e $(BIN)/rid_acl.dat ]; then cp -f rid_acl.dat $(BIN); fi - if [ ! -e $(BIN)/tg_acl.dat ]; then cp -f tg_acl.dat $(BIN); fi - if [ ! -e $(BIN)/iden_table.dat ]; then cp -f iden_table.dat $(BIN); fi - if [ ! -e $(BIN)/RSSI.dat ]; then cp -f RSSI.dat $(BIN); fi dvmhost: $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost diff --git a/Makefile.rpi-arm b/Makefile.rpi-arm index 4a6a50eb..c34be7ed 100644 --- a/Makefile.rpi-arm +++ b/Makefile.rpi-arm @@ -72,15 +72,7 @@ OBJECTS = \ Utils.o \ HostMain.o -BIN = ../bin - all: dvmhost - -cp -f dvmhost $(BIN) - if [ ! -e $(BIN)/config.yml ]; then cp -f config.yml $(BIN); fi - if [ ! -e $(BIN)/rid_acl.dat ]; then cp -f rid_acl.dat $(BIN); fi - if [ ! -e $(BIN)/tg_acl.dat ]; then cp -f tg_acl.dat $(BIN); fi - if [ ! -e $(BIN)/iden_table.dat ]; then cp -f iden_table.dat $(BIN); fi - if [ ! -e $(BIN)/RSSI.dat ]; then cp -f RSSI.dat $(BIN); fi dvmhost: $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost diff --git a/config.yml b/config.yml index e88a081a..3518d802 100644 --- a/config.yml +++ b/config.yml @@ -10,8 +10,11 @@ network: id: 100000 address: 127.0.0.1 port: 62031 + rconEnable: false rconAddress: 127.0.0.1 rconPort: 9990 + rconPassword: "PASSWORD" + rconDebug: false jitter: 360 password: "PASSWORD" slot1: true diff --git a/host/Host.cpp b/host/Host.cpp index 4d0d6989..beb11ade 100644 --- a/host/Host.cpp +++ b/host/Host.cpp @@ -1277,8 +1277,11 @@ bool Host::createNetwork() std::string address = networkConf["address"].as(); uint32_t port = networkConf["port"].as(TRAFFIC_DEFAULT_PORT); uint32_t local = networkConf["local"].as(0U); + bool rconEnable = networkConf["rconEnable"].as(false); std::string rconAddress = networkConf["rconAddress"].as("127.0.0.1"); uint32_t rconPort = networkConf["rconPort"].as(RCON_DEFAULT_PORT); + std::string rconPassword = networkConf["rconPassword"].as(); + bool rconDebug = networkConf["rconDebug"].as(false); uint32_t id = networkConf["id"].as(0U); uint32_t jitter = networkConf["talkgroupHang"].as(360U); std::string password = networkConf["password"].as(); @@ -1299,14 +1302,21 @@ bool Host::createNetwork() LogInfo(" Local: %u", local); else LogInfo(" Local: random"); - LogInfo(" RCON Address: %s", rconAddress.c_str()); - LogInfo(" RCON Port: %u", rconPort); + LogInfo(" RCON Enabled: %s", rconEnable ? "yes" : "no"); + if (rconEnable) { + LogInfo(" RCON Address: %s", rconAddress.c_str()); + LogInfo(" RCON Port: %u", rconPort); + } + + if (rconDebug) { + LogInfo(" RCON Debug: yes"); + } LogInfo(" DMR Jitter: %ums", jitter); LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); - LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "enabled" : "disabled"); - LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "enabled" : "disabled"); - LogInfo(" Update Lookups: %s", updateLookup ? "enabled" : "disabled"); + LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no"); + LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no"); + LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no"); if (debug) { LogInfo(" Debug: yes"); @@ -1315,8 +1325,11 @@ bool Host::createNetwork() m_network = new Network(address, port, local, id, password, m_duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup); m_network->setLookups(m_ridLookup, m_tidLookup); - m_network->setConfig(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_power, - m_latitude, m_longitude, m_height, m_location); + m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo, + m_power, m_latitude, m_longitude, m_height, m_location); + if (rconEnable) { + m_network->setRconData(rconPassword, rconPort); + } bool ret = m_network->open(); if (!ret) { @@ -1330,14 +1343,19 @@ bool Host::createNetwork() ::LogSetNetwork(m_network); // initialize network remote command - m_remoteControl = new RemoteControl(rconAddress, rconPort); - m_remoteControl->setLookups(m_ridLookup, m_tidLookup); - ret = m_remoteControl->open(); - if (!ret) { - delete m_remoteControl; + if (rconEnable) { + m_remoteControl = new RemoteControl(rconAddress, rconPort, rconPassword, rconDebug); + m_remoteControl->setLookups(m_ridLookup, m_tidLookup); + ret = m_remoteControl->open(); + if (!ret) { + delete m_remoteControl; + m_remoteControl = NULL; + LogError(LOG_HOST, "failed to initialize remote command networking! remote command control will be unavailable!"); + // remote command control failing isn't fatal -- we'll allow this to return normally + } + } + else { m_remoteControl = NULL; - LogError(LOG_HOST, "failed to initialize remote command networking! remote command control will be unavailable!"); - // remote command control failing isn't fatal -- we'll allow this to return normally } return true; diff --git a/network/Network.cpp b/network/Network.cpp index 9bf916b6..0ebee0e6 100644 --- a/network/Network.cpp +++ b/network/Network.cpp @@ -67,16 +67,20 @@ Network::Network(const std::string& address, uint32_t port, uint32_t local, uint m_password(password), m_enabled(false), m_updateLookup(updateLookup), - m_callsign(), + m_identity(), m_rxFrequency(0U), m_txFrequency(0U), m_txOffsetMhz(0.0F), m_chBandwidthKhz(0.0F), + m_channelId(0U), + m_channelNo(0U), m_power(0U), m_latitude(0.0F), m_longitude(0.0F), m_height(0), - m_location() + m_location(), + m_rconPassword(), + m_rconPort(0) { assert(!address.empty()); assert(port > 0U); @@ -105,26 +109,32 @@ void Network::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupId } /// -/// Sets various configuration settings from the modem. +/// Sets metadata configuration settings from the modem. /// -/// +/// /// /// /// /// +/// +/// /// /// /// /// /// -void Network::setConfig(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, - float chBandwidthKhz, uint32_t power, float latitude, float longitude, int height, const std::string& location) +void Network::setMetadata(const std::string& identity, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, + uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location) { - m_callsign = callsign; + m_identity = identity; m_rxFrequency = rxFrequency; m_txFrequency = txFrequency; + m_txOffsetMhz = txOffsetMhz; m_chBandwidthKhz = chBandwidthKhz; + m_channelId = channelId; + m_channelNo = channelNo; + m_power = power; m_latitude = latitude; m_longitude = longitude; @@ -132,6 +142,17 @@ void Network::setConfig(const std::string& callsign, uint32_t rxFrequency, uint3 m_location = location; } +/// +/// Sets RCON configuration settings from the modem. +/// +/// +/// +void Network::setRconData(const std::string& password, uint16_t port) +{ + m_rconPassword = password; + m_rconPort = port; +} + /// /// Gets the current status of the network. /// @@ -465,53 +486,48 @@ bool Network::writeAuthorisation() bool Network::writeConfig() { const char* software = "DVM_DMR_P25"; - char slots = '0'; - if (m_duplex) { - if (m_slot1 && m_slot2) - slots = '3'; - else if (m_slot1 && !m_slot2) - slots = '1'; - else if (!m_slot1 && m_slot2) - slots = '2'; - } - else { - slots = '4'; - } - - char buffer[400U]; + char buffer[168U]; ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); __SET_UINT32(m_id, buffer, 4U); - char latitude[20U]; + char latitude[11U]; ::sprintf(latitude, "%08f", m_latitude); - char longitude[20U]; + char longitude[11U]; ::sprintf(longitude, "%09f", m_longitude); - char chBandwidthKhz[20U]; - ::sprintf(chBandwidthKhz, "%03f", m_chBandwidthKhz); + char chBandwidthKhz[6U]; + ::sprintf(chBandwidthKhz, "%02.02f", m_chBandwidthKhz); + + char txOffsetMhz[6U]; + ::sprintf(txOffsetMhz, "%02.02f", m_txOffsetMhz); + + char channelId[4U]; + ::sprintf(channelId, "%d", m_channelId); - char txOffsetMhz[20U]; - ::sprintf(txOffsetMhz, "%03f", m_txOffsetMhz); + char channelNo[5U]; + ::sprintf(channelNo, "%d", m_channelNo); - uint32_t power = m_power; - if (power > 99U) + int power = m_power; + if (m_power > 99U) power = 99U; int height = m_height; - if (height > 999) + if (m_height > 999) height = 999; - // CallsgRX TX TxOfChBndLatitLongiHghtLocationPowrReservedSlReserved SoftwarePackage - ::sprintf(buffer + 8U, "%-8.8s%09u%09u%2.1s%2.1s%8.8s%9.9s%03d%-20.20s%02u%-17.17s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), - m_rxFrequency, m_txFrequency, txOffsetMhz, chBandwidthKhz, latitude, longitude, height, m_location.c_str(), - power, "", slots, "", software, software); + // IdntRX TX RsrvLatLngHghtLoctnRsrvTxOfChBnChIdChNoPowrSftwrRsrvRcnPsRcPt + ::sprintf(buffer + 8U, "%-8s%09u%09u%10s%8s%9s%03d%-20s%10s%-5s%-5s%-3s%-4s%02d%-16s%10s%-20s%05d", + m_identity.c_str(), m_rxFrequency, m_txFrequency, + "", latitude, longitude, height, m_location.c_str(), + "", txOffsetMhz, chBandwidthKhz, channelId, channelNo, power, software, + "", m_rconPassword.c_str(), m_rconPort); if (m_debug) - Utils::dump(1U, "Network Transmitted, Configuration", (uint8_t*)buffer, 11U); + Utils::dump(1U, "Network Transmitted, Configuration", (uint8_t*)buffer, 168U); - return write((uint8_t*)buffer, 302U); + return write((uint8_t*)buffer, 168U); } /// diff --git a/network/Network.h b/network/Network.h index 33bcdf9e..ae243e76 100644 --- a/network/Network.h +++ b/network/Network.h @@ -56,9 +56,11 @@ namespace network /// Sets the instances of the Radio ID and Talkgroup ID lookup tables. void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupIdLookup* tidLookup); - /// Sets various configuration settings from the modem. - void setConfig(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, - float chBandwidthKhz, uint32_t power, float latitude, float longitude, int height, const std::string& location); + /// Sets metadata configuration settings from the modem. + void setMetadata(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, + uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location); + /// Sets RCON configuration settings from the modem. + void setRconData(const std::string& password, uint16_t port); /// Gets the current status of the network. uint8_t getStatus(); @@ -89,17 +91,24 @@ namespace network lookups::TalkgroupIdLookup* m_tidLookup; /** station metadata */ - std::string m_callsign; + std::string m_identity; uint32_t m_rxFrequency; uint32_t m_txFrequency; + float m_txOffsetMhz; float m_chBandwidthKhz; + uint8_t m_channelId; + uint32_t m_channelNo; + uint32_t m_power; float m_latitude; float m_longitude; int m_height; std::string m_location; + std::string m_rconPassword; + uint16_t m_rconPort; + /// Writes login request to the network. bool writeLogin(); /// Writes network authentication challenge. diff --git a/network/RemoteControl.cpp b/network/RemoteControl.cpp index 0a7fd1bc..2a828d7e 100644 --- a/network/RemoteControl.cpp +++ b/network/RemoteControl.cpp @@ -29,6 +29,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "Defines.h" +#include "edac/SHA256.h" #include "RemoteControl.h" #include "HostMain.h" #include "Log.h" @@ -85,7 +86,10 @@ using namespace modem; #define RCD_P25_RELEASE_GRANTS "p25-rel-grnts" #define RCD_P25_RELEASE_AFFS "p25-rel-affs" -const uint32_t RC_BUFFER_LENGTH = 100U; +const uint32_t START_OF_TEXT = 0x02; +const uint32_t REC_SEPARATOR = 0x1E; + +const uint32_t RC_BUFFER_LENGTH = 140U; // --------------------------------------------------------------------------- // Public Class Members @@ -95,12 +99,31 @@ const uint32_t RC_BUFFER_LENGTH = 100U; /// /// Network Hostname/IP address to connect to. /// Network port number. -RemoteControl::RemoteControl(const std::string& address, uint32_t port) : +/// Authentication password. +/// +RemoteControl::RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug) : m_socket(address, port), - m_p25MFId(p25::P25_MFG_STANDARD) + m_p25MFId(p25::P25_MFG_STANDARD), + m_password(password), + m_passwordHash(NULL), + m_debug(debug) { assert(!address.empty()); assert(port > 0U); + + if (!password.empty()) { + size_t size = password.size(); + + uint8_t* in = new uint8_t[size]; + for (size_t i = 0U; i < size; i++) + in[i] = password.at(i); + + m_passwordHash = new uint8_t[32U]; + ::memset(m_passwordHash, 0x00U, 32U); + + edac::SHA256 sha256; + sha256.buffer(in, (uint32_t)(size), m_passwordHash); + } } /// @@ -133,16 +156,51 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) std::vector args = std::vector(); args.clear(); - char buffer[RC_BUFFER_LENGTH]; + uint8_t buffer[RC_BUFFER_LENGTH]; in_addr address; uint32_t port; - int ret = m_socket.read((uint8_t*)buffer, RC_BUFFER_LENGTH, address, port); - if (ret > 0) { + uint32_t ret = m_socket.read((uint8_t*)buffer, RC_BUFFER_LENGTH, address, port); + if (ret > 0U) { buffer[ret] = '\0'; + if (m_debug) + Utils::dump(1U, "RCON Received", (uint8_t*)buffer, ret); + + // make sure this is an RCON command + if (buffer[0U] != START_OF_TEXT) { + LogWarning(LOG_RCON, BAD_CMD_STR); + return; + } + + // ensure we have at least 33 bytes + if (ret < 33U) { + LogWarning(LOG_RCON, BAD_CMD_STR); + return; + } + + if (m_passwordHash != NULL) { + uint8_t hash[32U]; + ::memset(hash, 0x00U, 32U); + if (::memcmp(m_passwordHash, buffer + 1U, 32U) != 0) { + LogError(LOG_RCON, CMD_FAILED_STR "Invalid authentication!"); + return; + } + } + + // make sure we have arguments after the hash + if ((buffer[33U] != REC_SEPARATOR) || (ret - 34U) <= 0U) { + LogWarning(LOG_RCON, BAD_CMD_STR); + return; + } + + uint32_t size = ret - 34U; + char argBuffer[RC_BUFFER_LENGTH]; + ::memset(argBuffer, 0x00U, RC_BUFFER_LENGTH); + ::memcpy(argBuffer, buffer + 34U, size); + // parse the original command into a vector of strings. - char* b = buffer; + char* b = argBuffer; char* p = NULL; while ((p = ::strtok(b, " ")) != NULL) { b = NULL; @@ -155,19 +213,21 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) } else { std::string rcom = args.at(0); + uint32_t argCnt = args.size() - 1; // process command - if (rcom == RCD_MODE_CMD && args.size() >= 1U) { + if (rcom == RCD_MODE_CMD && argCnt >= 1U) { + std::string mode = getArgString(args, 0U); // Command is in the form of: "mode " - if (args.at(1U) == RCD_MODE_OPT_IDLE) { + if (mode == RCD_MODE_OPT_IDLE) { host->m_fixedMode = false; host->setMode(STATE_IDLE); } - else if (args.at(1U) == RCD_MODE_OPT_LCKOUT) { + else if (mode == RCD_MODE_OPT_LCKOUT) { host->m_fixedMode = false; host->setMode(HOST_STATE_LOCKOUT); } - else if (args.at(1U) == RCD_MODE_OPT_FDMR) { + else if (mode == RCD_MODE_OPT_FDMR) { if (dmr != NULL) { host->m_fixedMode = true; host->setMode(STATE_DMR); @@ -176,7 +236,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (args.at(1U) == RCD_MODE_OPT_FP25) { + else if (mode == RCD_MODE_OPT_FP25) { if (p25 != NULL) { host->m_fixedMode = true; host->setMode(STATE_P25); @@ -191,7 +251,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) g_killed = true; host->setMode(HOST_STATE_QUIT); } - else if (rcom == RCD_RID_WLIST_CMD && args.size() >= 1U) { + else if (rcom == RCD_RID_WLIST_CMD && argCnt >= 1U) { // Command is in the form of: "rid-whitelist " uint32_t srcId = getArgUInt32(args, 0U); if (srcId != 0U) { @@ -201,7 +261,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, INVALID_OPT_STR "tried to whitelist RID 0!"); } } - else if (rcom == RCD_RID_BLIST_CMD && args.size() >= 1U) { + else if (rcom == RCD_RID_BLIST_CMD && argCnt >= 1U) { // Command is in the form of: "rid-blacklist " uint32_t srcId = getArgUInt32(args, 0U); if (srcId != 0U) { @@ -229,7 +289,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_DMRD_MDM_INJ_CMD && args.size() >= 1U) { + else if (rcom == RCD_DMRD_MDM_INJ_CMD && argCnt >= 1U) { // Command is in the form of: "dmrd-mdm-inj if (dmr != NULL) { uint8_t slot = getArgUInt32(args, 0U); @@ -293,7 +353,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (rcom == RCD_P25D_MDM_INJ_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25D_MDM_INJ_CMD && argCnt >= 1U) { // Command is in the form of: "p25d-mdm-inj if (p25 != NULL) { const char* fileName = getArgString(args, 0U).c_str(); @@ -348,7 +408,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_DMR_RID_PAGE_CMD && args.size() >= 2U) { + else if (rcom == RCD_DMR_RID_PAGE_CMD && argCnt >= 2U) { // Command is in the form of: "dmr-rid-page " if (dmr != NULL) { uint32_t slotNo = getArgUInt32(args, 0U); @@ -369,7 +429,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (rcom == RCD_DMR_RID_CHECK_CMD && args.size() >= 2U) { + else if (rcom == RCD_DMR_RID_CHECK_CMD && argCnt >= 2U) { // Command is in the form of: "dmr-rid-check " if (dmr != NULL) { uint32_t slotNo = getArgUInt32(args, 0U); @@ -390,7 +450,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (rcom == RCD_DMR_RID_INHIBIT_CMD && args.size() >= 2U) { + else if (rcom == RCD_DMR_RID_INHIBIT_CMD && argCnt >= 2U) { // Command is in the form of: "dmr-rid-inhibit " if (dmr != NULL) { uint32_t slotNo = getArgUInt32(args, 0U); @@ -411,7 +471,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (rcom == RCD_DMR_RID_UNINHIBIT_CMD && args.size() >= 2U) { + else if (rcom == RCD_DMR_RID_UNINHIBIT_CMD && argCnt >= 2U) { // Command is in the form of: "dmr-rid-uninhibit " if (dmr != NULL) { uint32_t slotNo = getArgUInt32(args, 0U); @@ -432,7 +492,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "DMR mode is not enabled!"); } } - else if (rcom == RCD_P25_SET_MFID_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_SET_MFID_CMD && argCnt >= 1U) { // Command is in the form of: "p25-set-mfid if (p25 != NULL) { uint8_t mfId = getArgUInt8(args, 0U); @@ -449,7 +509,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_PAGE_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_PAGE_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-page " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -465,7 +525,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_CHECK_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_CHECK_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-check " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -481,7 +541,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_INHIBIT_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_INHIBIT_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-inhibit " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -497,7 +557,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_UNINHIBIT_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_UNINHIBIT_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-uninhibit " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -513,7 +573,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_GAQ_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_GAQ_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-gaq " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -529,7 +589,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_RID_UREG_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_RID_UREG_CMD && argCnt >= 1U) { // Command is in the form of: "p25-rid-ureg " if (p25 != NULL) { uint32_t dstId = getArgUInt32(args, 0U); @@ -545,7 +605,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25) LogError(LOG_RCON, CMD_FAILED_STR "P25 mode is not enabled!"); } } - else if (rcom == RCD_P25_PATCH_CMD && args.size() >= 1U) { + else if (rcom == RCD_P25_PATCH_CMD && argCnt >= 1U) { // Command is in the form of: "p25-patch " if (p25 != NULL) { uint32_t group1 = getArgUInt32(args, 0U); diff --git a/network/RemoteControl.h b/network/RemoteControl.h index e72984bd..249f57de 100644 --- a/network/RemoteControl.h +++ b/network/RemoteControl.h @@ -57,7 +57,7 @@ namespace p25 { class HOST_SW_API Control; } class HOST_SW_API RemoteControl { public: /// Initializes a new instance of the RemoteControl class. - RemoteControl(const std::string& address, uint32_t port); + RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug); /// Finalizes a instance of the RemoteControl class. ~RemoteControl(); @@ -77,6 +77,10 @@ private: network::UDPSocket m_socket; uint8_t m_p25MFId; + std::string m_password; + uint8_t* m_passwordHash; + bool m_debug; + lookups::RadioIdLookup* m_ridLookup; lookups::TalkgroupIdLookup* m_tidLookup;