Modify the P25 UID check slightly.

This commit is contained in:
Jonathan Naylor 2017-03-29 20:46:27 +01:00
parent 37bde2df6c
commit c0571edb0b
8 changed files with 16 additions and 15 deletions

View File

@ -439,6 +439,8 @@ bool CConf::read()
m_p25Enabled = ::atoi(value) == 1;
else if (::strcmp(key, "NAC") == 0)
m_p25NAC = (unsigned int)::strtoul(value, NULL, 16);
else if (::strcmp(key, "OverrideUIDCheck") == 0)
m_p25OverrideUID = ::atoi(value) == 1;
} else if (section == SECTION_DSTAR_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_dstarNetworkEnabled = ::atoi(value) == 1;
@ -495,8 +497,6 @@ bool CConf::read()
m_p25LocalPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_p25NetworkDebug = ::atoi(value) == 1;
else if (::strcmp(key, "OverrideUIDCheck") == 0)
m_p25OverrideUID = ::atoi(value) == 1;
} else if (section == SECTION_TFTSERIAL) {
if (::strcmp(key, "Port") == 0)
m_tftSerialPort = value;

View File

@ -86,6 +86,7 @@ RemoteGateway=0
[P25]
Enable=1
NAC=293
OverrideUIDCheck=0
[D-Star Network]
Enable=1
@ -120,7 +121,6 @@ GatewayAddress=127.0.0.1
GatewayPort=42020
LocalPort=32010
Debug=0
OverrideUIDCheck=0
[TFT Serial]
# Port=modem

View File

@ -407,12 +407,14 @@ int CMMDVMHost::run()
CP25Control* p25 = NULL;
if (m_p25Enabled) {
unsigned int nac = m_conf.getP25NAC();
unsigned int nac = m_conf.getP25NAC();
bool uidOverride = m_conf.getP25OverrideUID();
LogInfo("P25 Parameters");
LogInfo(" NAC: $%03X", nac);
LogInfo(" UID Override: %s", uidOverride ? "yes" : "no");
p25 = new CP25Control(nac, m_conf.getP25OverrideUID(), m_p25Network, m_display, m_timeout, m_duplex, m_lookup, rssi);
p25 = new CP25Control(nac, uidOverride, m_p25Network, m_display, m_timeout, m_duplex, m_lookup, rssi);
}
setMode(MODE_IDLE);

View File

@ -35,9 +35,9 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
#define WRITE_BIT(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
#define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CP25Control::CP25Control(unsigned int nac, bool uidoverride, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper) :
CP25Control::CP25Control(unsigned int nac, bool uidOverride, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper) :
m_nac(nac),
m_uidoverride(uidoverride),
m_uidOverride(uidOverride),
m_network(network),
m_display(display),
m_duplex(duplex),
@ -177,7 +177,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
if (duid == P25_DUID_LDU1) {
if (m_rfState == RS_RF_LISTENING) {
m_rfData.reset();
bool ret = m_rfData.decodeLDU1(data + 2U, m_network, m_uidoverride);
bool ret = m_rfData.decodeLDU1(data + 2U, m_network, m_uidOverride);
if (!ret) {
m_lastDUID = duid;
return false;

View File

@ -36,7 +36,7 @@
class CP25Control {
public:
CP25Control(unsigned int nac, bool uidoverride, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper);
CP25Control(unsigned int nac, bool uidOverride, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper);
~CP25Control();
bool writeModem(unsigned char* data, unsigned int len);
@ -47,7 +47,7 @@ public:
private:
unsigned int m_nac;
bool m_uidoverride;
bool m_uidOverride;
CP25Network* m_network;
CDisplay* m_display;
bool m_duplex;

View File

@ -71,7 +71,7 @@ void CP25Data::encodeHeader(unsigned char* data)
CP25Utils::encode(DUMMY_HEADER, data, 114U, 780U);
}
bool CP25Data::decodeLDU1(const unsigned char* data, bool m_network, bool m_uidoverride)
bool CP25Data::decodeLDU1(const unsigned char* data, bool m_network, bool m_uidOverride)
{
assert(data != NULL);
@ -107,10 +107,11 @@ bool CP25Data::decodeLDU1(const unsigned char* data, bool m_network, bool m_uido
// Simple validation of the source id - does not check if no network
unsigned int srcId = (rs[6U] << 16) + (rs[7U] << 8) + rs[8U];
if(m_network || (!m_network && !m_uidoverride)) {
if (m_network || (!m_network && !m_uidOverride)) {
if (srcId < 1000000U)
return false;
}
switch (rs[0U]) {
case P25_LCF_GROUP:
m_emergency = (rs[2U] & 0x80U) == 0x80U;

View File

@ -28,7 +28,7 @@ public:
void encodeHeader(unsigned char* data);
bool decodeLDU1(const unsigned char* data, bool m_network, bool m_overrideuid);
bool decodeLDU1(const unsigned char* data, bool m_network, bool m_uidOverride);
void encodeLDU1(unsigned char* data);
void encodeLDU2(unsigned char* data);

View File

@ -433,5 +433,3 @@ void CP25Network::enable(bool enabled)
{
m_enabled = enabled;
}