Merge branch 'SimpleDMR' into AX25_FM

This commit is contained in:
Jonathan Naylor 2020-10-30 13:57:58 +00:00
commit 098cc74c9e
8 changed files with 39 additions and 12 deletions

View file

@ -124,6 +124,7 @@ m_dstarEnabled(false),
m_dstarModule("C"),
m_dstarSelfOnly(false),
m_dstarBlackList(),
m_dstarWhiteList(),
m_dstarAckReply(true),
m_dstarAckTime(750U),
m_dstarAckMessage(false),
@ -571,6 +572,18 @@ bool CConf::read()
}
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "WhiteList") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
if (::strlen(p) > 0U) {
for (unsigned int i = 0U; p[i] != 0; i++)
p[i] = ::toupper(p[i]);
std::string callsign = std::string(p);
callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' ');
m_dstarWhiteList.push_back(callsign);
}
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "AckReply") == 0)
m_dstarAckReply = ::atoi(value) == 1;
else if (::strcmp(key, "AckTime") == 0)
@ -1318,6 +1331,11 @@ std::vector<std::string> CConf::getDStarBlackList() const
return m_dstarBlackList;
}
std::vector<std::string> CConf::getDStarWhiteList() const
{
return m_dstarWhiteList;
}
bool CConf::getDStarAckReply() const
{
return m_dstarAckReply;

2
Conf.h
View file

@ -108,6 +108,7 @@ public:
std::string getDStarModule() const;
bool getDStarSelfOnly() const;
std::vector<std::string> getDStarBlackList() const;
std::vector<std::string> getDStarWhiteList() const;
bool getDStarAckReply() const;
unsigned int getDStarAckTime() const;
bool getDStarAckMessage() const;
@ -404,6 +405,7 @@ private:
std::string m_dstarModule;
bool m_dstarSelfOnly;
std::vector<std::string> m_dstarBlackList;
std::vector<std::string> m_dstarWhiteList;
bool m_dstarAckReply;
unsigned int m_dstarAckTime;
bool m_dstarAckMessage;

View file

@ -36,7 +36,7 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)
// #define DUMP_DSTAR
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL),
m_gateway(NULL),
m_selfOnly(selfOnly),
@ -45,6 +45,7 @@ m_ackMessage(ackMessage),
m_errorReply(errorReply),
m_remoteGateway(remoteGateway),
m_blackList(blackList),
m_whiteList(whiteList),
m_network(network),
m_display(display),
m_duplex(duplex),
@ -231,7 +232,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
return false;
}
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0) {
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) {
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
m_rfState = RS_RF_REJECTED;
return false;
@ -465,7 +466,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
return false;
}
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0) {
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) {
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
m_rfState = RS_RF_REJECTED;
delete header;

View file

@ -37,7 +37,7 @@
class CDStarControl {
public:
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
~CDStarControl();
bool writeModem(unsigned char* data, unsigned int len);
@ -59,6 +59,7 @@ private:
bool m_errorReply;
bool m_remoteGateway;
std::vector<std::string> m_blackList;
std::vector<std::string> m_whiteList;
CDStarNetwork* m_network;
CDisplay* m_display;
bool m_duplex;

View file

@ -89,6 +89,7 @@ AckMessage=0
ErrorReply=1
RemoteGateway=0
# ModeHang=10
WhiteList=
[DMR]
Enable=1

View file

@ -432,6 +432,7 @@ int CMMDVMHost::run()
std::string module = m_conf.getDStarModule();
bool selfOnly = m_conf.getDStarSelfOnly();
std::vector<std::string> blackList = m_conf.getDStarBlackList();
std::vector<std::string> whiteList = m_conf.getDStarWhiteList();
bool ackReply = m_conf.getDStarAckReply();
unsigned int ackTime = m_conf.getDStarAckTime();
bool ackMessage = m_conf.getDStarAckMessage();
@ -451,8 +452,10 @@ int CMMDVMHost::run()
if (blackList.size() > 0U)
LogInfo(" Black List: %u", blackList.size());
if (whiteList.size() > 0U)
LogInfo(" White List: %u", whiteList.size());
m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, whiteList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
}
DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;

View file

@ -26,13 +26,13 @@
#include <clocale>
#include <sys/types.h>
#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
#include <ifaddrs.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#if defined(__OpenBSD__) || defined(__NetBSD__)
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@ -66,7 +66,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
::strcpy((char*)info, "(address unknown)");
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
char* dflt = NULL;
#if defined(__linux__)
@ -91,7 +91,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
::fclose(fp);
#elif defined(__OpenBSD__) || defined(__NetBSD__)
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
const int mib[] = {
CTL_NET,
PF_ROUTE,
@ -99,7 +99,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
AF_INET, // IPv4 routing
NET_RT_DUMP,
0, // show all routes
#if defined(__OpenBSD__)
#if defined(__OpenBSD__) || defined(__FreeBSD__)
0, // table id
#endif
};
@ -126,7 +126,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
continue;
#if defined(__OpenBSD__)
struct sockaddr_in *sa = (struct sockaddr_in *)(p + rtm->rtm_hdrlen);
#elif defined(__NetBSD__)
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
struct sockaddr_in *sa = (struct sockaddr_in *)(rtm + 1);
#endif
if (sa->sin_addr.s_addr == INADDR_ANY) {

View file

@ -92,7 +92,8 @@ then
fi
# Generate new file
curl 'http://registry.dstar.su/dmr/DMRIds.php' 2>/dev/null | sed -e 's/[[:space:]]\+/ /g' > ${DMRIDFILE}
#curl 'http://registry.dstar.su/dmr/DMRIds.php' 2>/dev/null | sed -e 's/[[:space:]]\+/ /g' > ${DMRIDFILE}
curl 'http://registry.dstar.su/dmr/DMRIds2.php' 2>/dev/null | sed -e 's/[[:space:]]\+/ /g' > ${DMRIDFILE}
# Restart MMDVMHost
eval ${RESTARTCOMMAND}