clean up makefiles; implement proper support for RCON passwording and enable/disable; implement new enhanced configuration to send to FNE;

pull/1/head
Bryan Biedenkapp 5 years ago
parent fd99530376
commit e2026f33c9

@ -72,15 +72,7 @@ OBJECTS = \
Utils.o \ Utils.o \
HostMain.o HostMain.o
BIN = ../bin
all: dvmhost 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) dvmhost: $(OBJECTS)
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost

@ -72,15 +72,7 @@ OBJECTS = \
Utils.o \ Utils.o \
HostMain.o HostMain.o
BIN = ../bin
all: dvmhost 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) dvmhost: $(OBJECTS)
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost

@ -72,15 +72,7 @@ OBJECTS = \
Utils.o \ Utils.o \
HostMain.o HostMain.o
BIN = ../bin
all: dvmhost 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) dvmhost: $(OBJECTS)
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o dvmhost

@ -10,8 +10,11 @@ network:
id: 100000 id: 100000
address: 127.0.0.1 address: 127.0.0.1
port: 62031 port: 62031
rconEnable: false
rconAddress: 127.0.0.1 rconAddress: 127.0.0.1
rconPort: 9990 rconPort: 9990
rconPassword: "PASSWORD"
rconDebug: false
jitter: 360 jitter: 360
password: "PASSWORD" password: "PASSWORD"
slot1: true slot1: true

@ -1277,8 +1277,11 @@ bool Host::createNetwork()
std::string address = networkConf["address"].as<std::string>(); std::string address = networkConf["address"].as<std::string>();
uint32_t port = networkConf["port"].as<uint32_t>(TRAFFIC_DEFAULT_PORT); uint32_t port = networkConf["port"].as<uint32_t>(TRAFFIC_DEFAULT_PORT);
uint32_t local = networkConf["local"].as<uint32_t>(0U); uint32_t local = networkConf["local"].as<uint32_t>(0U);
bool rconEnable = networkConf["rconEnable"].as<bool>(false);
std::string rconAddress = networkConf["rconAddress"].as<std::string>("127.0.0.1"); std::string rconAddress = networkConf["rconAddress"].as<std::string>("127.0.0.1");
uint32_t rconPort = networkConf["rconPort"].as<uint32_t>(RCON_DEFAULT_PORT); uint32_t rconPort = networkConf["rconPort"].as<uint32_t>(RCON_DEFAULT_PORT);
std::string rconPassword = networkConf["rconPassword"].as<std::string>();
bool rconDebug = networkConf["rconDebug"].as<bool>(false);
uint32_t id = networkConf["id"].as<uint32_t>(0U); uint32_t id = networkConf["id"].as<uint32_t>(0U);
uint32_t jitter = networkConf["talkgroupHang"].as<uint32_t>(360U); uint32_t jitter = networkConf["talkgroupHang"].as<uint32_t>(360U);
std::string password = networkConf["password"].as<std::string>(); std::string password = networkConf["password"].as<std::string>();
@ -1299,14 +1302,21 @@ bool Host::createNetwork()
LogInfo(" Local: %u", local); LogInfo(" Local: %u", local);
else else
LogInfo(" Local: random"); LogInfo(" Local: random");
LogInfo(" RCON Address: %s", rconAddress.c_str()); LogInfo(" RCON Enabled: %s", rconEnable ? "yes" : "no");
LogInfo(" RCON Port: %u", rconPort); 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(" DMR Jitter: %ums", jitter);
LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled");
LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled");
LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "enabled" : "disabled"); LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no");
LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "enabled" : "disabled"); LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no");
LogInfo(" Update Lookups: %s", updateLookup ? "enabled" : "disabled"); LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no");
if (debug) { if (debug) {
LogInfo(" Debug: yes"); 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 = new Network(address, port, local, id, password, m_duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup);
m_network->setLookups(m_ridLookup, m_tidLookup); m_network->setLookups(m_ridLookup, m_tidLookup);
m_network->setConfig(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_power, m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo,
m_latitude, m_longitude, m_height, m_location); m_power, m_latitude, m_longitude, m_height, m_location);
if (rconEnable) {
m_network->setRconData(rconPassword, rconPort);
}
bool ret = m_network->open(); bool ret = m_network->open();
if (!ret) { if (!ret) {
@ -1330,14 +1343,19 @@ bool Host::createNetwork()
::LogSetNetwork(m_network); ::LogSetNetwork(m_network);
// initialize network remote command // initialize network remote command
m_remoteControl = new RemoteControl(rconAddress, rconPort); if (rconEnable) {
m_remoteControl->setLookups(m_ridLookup, m_tidLookup); m_remoteControl = new RemoteControl(rconAddress, rconPort, rconPassword, rconDebug);
ret = m_remoteControl->open(); m_remoteControl->setLookups(m_ridLookup, m_tidLookup);
if (!ret) { ret = m_remoteControl->open();
delete m_remoteControl; 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; 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; return true;

@ -67,16 +67,20 @@ Network::Network(const std::string& address, uint32_t port, uint32_t local, uint
m_password(password), m_password(password),
m_enabled(false), m_enabled(false),
m_updateLookup(updateLookup), m_updateLookup(updateLookup),
m_callsign(), m_identity(),
m_rxFrequency(0U), m_rxFrequency(0U),
m_txFrequency(0U), m_txFrequency(0U),
m_txOffsetMhz(0.0F), m_txOffsetMhz(0.0F),
m_chBandwidthKhz(0.0F), m_chBandwidthKhz(0.0F),
m_channelId(0U),
m_channelNo(0U),
m_power(0U), m_power(0U),
m_latitude(0.0F), m_latitude(0.0F),
m_longitude(0.0F), m_longitude(0.0F),
m_height(0), m_height(0),
m_location() m_location(),
m_rconPassword(),
m_rconPort(0)
{ {
assert(!address.empty()); assert(!address.empty());
assert(port > 0U); assert(port > 0U);
@ -105,26 +109,32 @@ void Network::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupId
} }
/// <summary> /// <summary>
/// Sets various configuration settings from the modem. /// Sets metadata configuration settings from the modem.
/// </summary> /// </summary>
/// <param name="callsign"></param> /// <param name="identity"></param>
/// <param name="rxFrequency"></param> /// <param name="rxFrequency"></param>
/// <param name="txFrequency"></param> /// <param name="txFrequency"></param>
/// <param name="txOffsetMhz"></param> /// <param name="txOffsetMhz"></param>
/// <param name="chBandwidthKhz"></param> /// <param name="chBandwidthKhz"></param>
/// <param name="channelId"></param>
/// <param name="channelNo"></param>
/// <param name="power"></param> /// <param name="power"></param>
/// <param name="latitude"></param> /// <param name="latitude"></param>
/// <param name="longitude"></param> /// <param name="longitude"></param>
/// <param name="height"></param> /// <param name="height"></param>
/// <param name="location"></param> /// <param name="location"></param>
void Network::setConfig(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, void Network::setMetadata(const std::string& identity, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz,
float chBandwidthKhz, uint32_t power, float latitude, float longitude, int height, const std::string& location) 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_rxFrequency = rxFrequency;
m_txFrequency = txFrequency; m_txFrequency = txFrequency;
m_txOffsetMhz = txOffsetMhz; m_txOffsetMhz = txOffsetMhz;
m_chBandwidthKhz = chBandwidthKhz; m_chBandwidthKhz = chBandwidthKhz;
m_channelId = channelId;
m_channelNo = channelNo;
m_power = power; m_power = power;
m_latitude = latitude; m_latitude = latitude;
m_longitude = longitude; m_longitude = longitude;
@ -132,6 +142,17 @@ void Network::setConfig(const std::string& callsign, uint32_t rxFrequency, uint3
m_location = location; m_location = location;
} }
/// <summary>
/// Sets RCON configuration settings from the modem.
/// </summary>
/// <param name="password"></param>
/// <param name="port"></param>
void Network::setRconData(const std::string& password, uint16_t port)
{
m_rconPassword = password;
m_rconPort = port;
}
/// <summary> /// <summary>
/// Gets the current status of the network. /// Gets the current status of the network.
/// </summary> /// </summary>
@ -465,53 +486,48 @@ bool Network::writeAuthorisation()
bool Network::writeConfig() bool Network::writeConfig()
{ {
const char* software = "DVM_DMR_P25"; const char* software = "DVM_DMR_P25";
char slots = '0'; char buffer[168U];
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];
::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U);
__SET_UINT32(m_id, buffer, 4U); __SET_UINT32(m_id, buffer, 4U);
char latitude[20U]; char latitude[11U];
::sprintf(latitude, "%08f", m_latitude); ::sprintf(latitude, "%08f", m_latitude);
char longitude[20U]; char longitude[11U];
::sprintf(longitude, "%09f", m_longitude); ::sprintf(longitude, "%09f", m_longitude);
char chBandwidthKhz[20U]; char chBandwidthKhz[6U];
::sprintf(chBandwidthKhz, "%03f", m_chBandwidthKhz); ::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]; char channelNo[5U];
::sprintf(txOffsetMhz, "%03f", m_txOffsetMhz); ::sprintf(channelNo, "%d", m_channelNo);
uint32_t power = m_power; int power = m_power;
if (power > 99U) if (m_power > 99U)
power = 99U; power = 99U;
int height = m_height; int height = m_height;
if (height > 999) if (m_height > 999)
height = 999; height = 999;
// CallsgRX TX TxOfChBndLatitLongiHghtLocationPowrReservedSlReserved SoftwarePackage // IdntRX TX RsrvLatLngHghtLoctnRsrvTxOfChBnChIdChNoPowrSftwrRsrvRcnPsRcPt
::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(), ::sprintf(buffer + 8U, "%-8s%09u%09u%10s%8s%9s%03d%-20s%10s%-5s%-5s%-3s%-4s%02d%-16s%10s%-20s%05d",
m_rxFrequency, m_txFrequency, txOffsetMhz, chBandwidthKhz, latitude, longitude, height, m_location.c_str(), m_identity.c_str(), m_rxFrequency, m_txFrequency,
power, "", slots, "", software, software); "", latitude, longitude, height, m_location.c_str(),
"", txOffsetMhz, chBandwidthKhz, channelId, channelNo, power, software,
"", m_rconPassword.c_str(), m_rconPort);
if (m_debug) 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);
} }
/// <summary> /// <summary>

@ -56,9 +56,11 @@ namespace network
/// <summary>Sets the instances of the Radio ID and Talkgroup ID lookup tables.</summary> /// <summary>Sets the instances of the Radio ID and Talkgroup ID lookup tables.</summary>
void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupIdLookup* tidLookup); void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupIdLookup* tidLookup);
/// <summary>Sets various configuration settings from the modem.</summary> /// <summary>Sets metadata configuration settings from the modem.</summary>
void setConfig(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, void setMetadata(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz,
float chBandwidthKhz, uint32_t power, float latitude, float longitude, int height, const std::string& location); uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location);
/// <summary>Sets RCON configuration settings from the modem.</summary>
void setRconData(const std::string& password, uint16_t port);
/// <summary>Gets the current status of the network.</summary> /// <summary>Gets the current status of the network.</summary>
uint8_t getStatus(); uint8_t getStatus();
@ -89,17 +91,24 @@ namespace network
lookups::TalkgroupIdLookup* m_tidLookup; lookups::TalkgroupIdLookup* m_tidLookup;
/** station metadata */ /** station metadata */
std::string m_callsign; std::string m_identity;
uint32_t m_rxFrequency; uint32_t m_rxFrequency;
uint32_t m_txFrequency; uint32_t m_txFrequency;
float m_txOffsetMhz; float m_txOffsetMhz;
float m_chBandwidthKhz; float m_chBandwidthKhz;
uint8_t m_channelId;
uint32_t m_channelNo;
uint32_t m_power; uint32_t m_power;
float m_latitude; float m_latitude;
float m_longitude; float m_longitude;
int m_height; int m_height;
std::string m_location; std::string m_location;
std::string m_rconPassword;
uint16_t m_rconPort;
/// <summary>Writes login request to the network.</summary> /// <summary>Writes login request to the network.</summary>
bool writeLogin(); bool writeLogin();
/// <summary>Writes network authentication challenge.</summary> /// <summary>Writes network authentication challenge.</summary>

@ -29,6 +29,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "Defines.h" #include "Defines.h"
#include "edac/SHA256.h"
#include "RemoteControl.h" #include "RemoteControl.h"
#include "HostMain.h" #include "HostMain.h"
#include "Log.h" #include "Log.h"
@ -85,7 +86,10 @@ using namespace modem;
#define RCD_P25_RELEASE_GRANTS "p25-rel-grnts" #define RCD_P25_RELEASE_GRANTS "p25-rel-grnts"
#define RCD_P25_RELEASE_AFFS "p25-rel-affs" #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 // Public Class Members
@ -95,12 +99,31 @@ const uint32_t RC_BUFFER_LENGTH = 100U;
/// </summary> /// </summary>
/// <param name="address">Network Hostname/IP address to connect to.</param> /// <param name="address">Network Hostname/IP address to connect to.</param>
/// <param name="port">Network port number.</param> /// <param name="port">Network port number.</param>
RemoteControl::RemoteControl(const std::string& address, uint32_t port) : /// <param name="password">Authentication password.</param>
/// <param name="debug"></param>
RemoteControl::RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug) :
m_socket(address, port), 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(!address.empty());
assert(port > 0U); 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);
}
} }
/// <summary> /// <summary>
@ -133,16 +156,51 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25)
std::vector<std::string> args = std::vector<std::string>(); std::vector<std::string> args = std::vector<std::string>();
args.clear(); args.clear();
char buffer[RC_BUFFER_LENGTH]; uint8_t buffer[RC_BUFFER_LENGTH];
in_addr address; in_addr address;
uint32_t port; uint32_t port;
int ret = m_socket.read((uint8_t*)buffer, RC_BUFFER_LENGTH, address, port); uint32_t ret = m_socket.read((uint8_t*)buffer, RC_BUFFER_LENGTH, address, port);
if (ret > 0) { if (ret > 0U) {
buffer[ret] = '\0'; 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. // parse the original command into a vector of strings.
char* b = buffer; char* b = argBuffer;
char* p = NULL; char* p = NULL;
while ((p = ::strtok(b, " ")) != NULL) { while ((p = ::strtok(b, " ")) != NULL) {
b = NULL; b = NULL;
@ -155,19 +213,21 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25)
} }
else { else {
std::string rcom = args.at(0); std::string rcom = args.at(0);
uint32_t argCnt = args.size() - 1;
// process command // 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 <mode>" // Command is in the form of: "mode <mode>"
if (args.at(1U) == RCD_MODE_OPT_IDLE) { if (mode == RCD_MODE_OPT_IDLE) {
host->m_fixedMode = false; host->m_fixedMode = false;
host->setMode(STATE_IDLE); 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->m_fixedMode = false;
host->setMode(HOST_STATE_LOCKOUT); host->setMode(HOST_STATE_LOCKOUT);
} }
else if (args.at(1U) == RCD_MODE_OPT_FDMR) { else if (mode == RCD_MODE_OPT_FDMR) {
if (dmr != NULL) { if (dmr != NULL) {
host->m_fixedMode = true; host->m_fixedMode = true;
host->setMode(STATE_DMR); 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!"); 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) { if (p25 != NULL) {
host->m_fixedMode = true; host->m_fixedMode = true;
host->setMode(STATE_P25); host->setMode(STATE_P25);
@ -191,7 +251,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25)
g_killed = true; g_killed = true;
host->setMode(HOST_STATE_QUIT); 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 <RID>" // Command is in the form of: "rid-whitelist <RID>"
uint32_t srcId = getArgUInt32(args, 0U); uint32_t srcId = getArgUInt32(args, 0U);
if (srcId != 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!"); 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 <RID>" // Command is in the form of: "rid-blacklist <RID>"
uint32_t srcId = getArgUInt32(args, 0U); uint32_t srcId = getArgUInt32(args, 0U);
if (srcId != 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!"); 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 <slot> <bin file> // Command is in the form of: "dmrd-mdm-inj <slot> <bin file>
if (dmr != NULL) { if (dmr != NULL) {
uint8_t slot = getArgUInt32(args, 0U); 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!"); 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 <bin file> // Command is in the form of: "p25d-mdm-inj <bin file>
if (p25 != NULL) { if (p25 != NULL) {
const char* fileName = getArgString(args, 0U).c_str(); 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!"); 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 <slot> <RID>" // Command is in the form of: "dmr-rid-page <slot> <RID>"
if (dmr != NULL) { if (dmr != NULL) {
uint32_t slotNo = getArgUInt32(args, 0U); 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!"); 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 <slot> <RID>" // Command is in the form of: "dmr-rid-check <slot> <RID>"
if (dmr != NULL) { if (dmr != NULL) {
uint32_t slotNo = getArgUInt32(args, 0U); 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!"); 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 <slot> <RID>" // Command is in the form of: "dmr-rid-inhibit <slot> <RID>"
if (dmr != NULL) { if (dmr != NULL) {
uint32_t slotNo = getArgUInt32(args, 0U); 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!"); 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 <slot> <RID>" // Command is in the form of: "dmr-rid-uninhibit <slot> <RID>"
if (dmr != NULL) { if (dmr != NULL) {
uint32_t slotNo = getArgUInt32(args, 0U); 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!"); 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 <Mfg. ID> // Command is in the form of: "p25-set-mfid <Mfg. ID>
if (p25 != NULL) { if (p25 != NULL) {
uint8_t mfId = getArgUInt8(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-page <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-check <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-inhibit <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-uninhibit <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-gaq <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <RID>" // Command is in the form of: "p25-rid-ureg <RID>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t dstId = getArgUInt32(args, 0U); 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!"); 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 <group 1> <group 2> <group 3>" // Command is in the form of: "p25-patch <group 1> <group 2> <group 3>"
if (p25 != NULL) { if (p25 != NULL) {
uint32_t group1 = getArgUInt32(args, 0U); uint32_t group1 = getArgUInt32(args, 0U);

@ -57,7 +57,7 @@ namespace p25 { class HOST_SW_API Control; }
class HOST_SW_API RemoteControl { class HOST_SW_API RemoteControl {
public: public:
/// <summary>Initializes a new instance of the RemoteControl class.</summary> /// <summary>Initializes a new instance of the RemoteControl class.</summary>
RemoteControl(const std::string& address, uint32_t port); RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug);
/// <summary>Finalizes a instance of the RemoteControl class.</summary> /// <summary>Finalizes a instance of the RemoteControl class.</summary>
~RemoteControl(); ~RemoteControl();
@ -77,6 +77,10 @@ private:
network::UDPSocket m_socket; network::UDPSocket m_socket;
uint8_t m_p25MFId; uint8_t m_p25MFId;
std::string m_password;
uint8_t* m_passwordHash;
bool m_debug;
lookups::RadioIdLookup* m_ridLookup; lookups::RadioIdLookup* m_ridLookup;
lookups::TalkgroupIdLookup* m_tidLookup; lookups::TalkgroupIdLookup* m_tidLookup;

Loading…
Cancel
Save

Powered by TurnKey Linux.