mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 15:09:23 +08:00
Merge branch 'SimpleDMR' into M17
This commit is contained in:
18
Conf.cpp
18
Conf.cpp
@@ -122,6 +122,7 @@ m_dstarEnabled(false),
|
|||||||
m_dstarModule("C"),
|
m_dstarModule("C"),
|
||||||
m_dstarSelfOnly(false),
|
m_dstarSelfOnly(false),
|
||||||
m_dstarBlackList(),
|
m_dstarBlackList(),
|
||||||
|
m_dstarWhiteList(),
|
||||||
m_dstarAckReply(true),
|
m_dstarAckReply(true),
|
||||||
m_dstarAckTime(750U),
|
m_dstarAckTime(750U),
|
||||||
m_dstarAckMessage(false),
|
m_dstarAckMessage(false),
|
||||||
@@ -564,6 +565,18 @@ bool CConf::read()
|
|||||||
}
|
}
|
||||||
p = ::strtok(NULL, ",\r\n");
|
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)
|
} else if (::strcmp(key, "AckReply") == 0)
|
||||||
m_dstarAckReply = ::atoi(value) == 1;
|
m_dstarAckReply = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "AckTime") == 0)
|
else if (::strcmp(key, "AckTime") == 0)
|
||||||
@@ -1284,6 +1297,11 @@ std::vector<std::string> CConf::getDStarBlackList() const
|
|||||||
return m_dstarBlackList;
|
return m_dstarBlackList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> CConf::getDStarWhiteList() const
|
||||||
|
{
|
||||||
|
return m_dstarWhiteList;
|
||||||
|
}
|
||||||
|
|
||||||
bool CConf::getDStarAckReply() const
|
bool CConf::getDStarAckReply() const
|
||||||
{
|
{
|
||||||
return m_dstarAckReply;
|
return m_dstarAckReply;
|
||||||
|
|||||||
2
Conf.h
2
Conf.h
@@ -107,6 +107,7 @@ public:
|
|||||||
std::string getDStarModule() const;
|
std::string getDStarModule() const;
|
||||||
bool getDStarSelfOnly() const;
|
bool getDStarSelfOnly() const;
|
||||||
std::vector<std::string> getDStarBlackList() const;
|
std::vector<std::string> getDStarBlackList() const;
|
||||||
|
std::vector<std::string> getDStarWhiteList() const;
|
||||||
bool getDStarAckReply() const;
|
bool getDStarAckReply() const;
|
||||||
unsigned int getDStarAckTime() const;
|
unsigned int getDStarAckTime() const;
|
||||||
bool getDStarAckMessage() const;
|
bool getDStarAckMessage() const;
|
||||||
@@ -389,6 +390,7 @@ private:
|
|||||||
std::string m_dstarModule;
|
std::string m_dstarModule;
|
||||||
bool m_dstarSelfOnly;
|
bool m_dstarSelfOnly;
|
||||||
std::vector<std::string> m_dstarBlackList;
|
std::vector<std::string> m_dstarBlackList;
|
||||||
|
std::vector<std::string> m_dstarWhiteList;
|
||||||
bool m_dstarAckReply;
|
bool m_dstarAckReply;
|
||||||
unsigned int m_dstarAckTime;
|
unsigned int m_dstarAckTime;
|
||||||
bool m_dstarAckMessage;
|
bool m_dstarAckMessage;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)
|
|||||||
|
|
||||||
// #define DUMP_DSTAR
|
// #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_callsign(NULL),
|
||||||
m_gateway(NULL),
|
m_gateway(NULL),
|
||||||
m_selfOnly(selfOnly),
|
m_selfOnly(selfOnly),
|
||||||
@@ -45,6 +45,7 @@ m_ackMessage(ackMessage),
|
|||||||
m_errorReply(errorReply),
|
m_errorReply(errorReply),
|
||||||
m_remoteGateway(remoteGateway),
|
m_remoteGateway(remoteGateway),
|
||||||
m_blackList(blackList),
|
m_blackList(blackList),
|
||||||
|
m_whiteList(whiteList),
|
||||||
m_network(network),
|
m_network(network),
|
||||||
m_display(display),
|
m_display(display),
|
||||||
m_duplex(duplex),
|
m_duplex(duplex),
|
||||||
@@ -231,7 +232,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||||||
return false;
|
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);
|
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
||||||
m_rfState = RS_RF_REJECTED;
|
m_rfState = RS_RF_REJECTED;
|
||||||
return false;
|
return false;
|
||||||
@@ -465,7 +466,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||||||
return false;
|
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);
|
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
|
||||||
m_rfState = RS_RF_REJECTED;
|
m_rfState = RS_RF_REJECTED;
|
||||||
delete header;
|
delete header;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
class CDStarControl {
|
class CDStarControl {
|
||||||
public:
|
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();
|
~CDStarControl();
|
||||||
|
|
||||||
bool writeModem(unsigned char* data, unsigned int len);
|
bool writeModem(unsigned char* data, unsigned int len);
|
||||||
@@ -59,6 +59,7 @@ private:
|
|||||||
bool m_errorReply;
|
bool m_errorReply;
|
||||||
bool m_remoteGateway;
|
bool m_remoteGateway;
|
||||||
std::vector<std::string> m_blackList;
|
std::vector<std::string> m_blackList;
|
||||||
|
std::vector<std::string> m_whiteList;
|
||||||
CDStarNetwork* m_network;
|
CDStarNetwork* m_network;
|
||||||
CDisplay* m_display;
|
CDisplay* m_display;
|
||||||
bool m_duplex;
|
bool m_duplex;
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ AckMessage=0
|
|||||||
ErrorReply=1
|
ErrorReply=1
|
||||||
RemoteGateway=0
|
RemoteGateway=0
|
||||||
# ModeHang=10
|
# ModeHang=10
|
||||||
|
WhiteList=
|
||||||
|
|
||||||
[DMR]
|
[DMR]
|
||||||
Enable=1
|
Enable=1
|
||||||
|
|||||||
@@ -422,6 +422,7 @@ int CMMDVMHost::run()
|
|||||||
std::string module = m_conf.getDStarModule();
|
std::string module = m_conf.getDStarModule();
|
||||||
bool selfOnly = m_conf.getDStarSelfOnly();
|
bool selfOnly = m_conf.getDStarSelfOnly();
|
||||||
std::vector<std::string> blackList = m_conf.getDStarBlackList();
|
std::vector<std::string> blackList = m_conf.getDStarBlackList();
|
||||||
|
std::vector<std::string> whiteList = m_conf.getDStarWhiteList();
|
||||||
bool ackReply = m_conf.getDStarAckReply();
|
bool ackReply = m_conf.getDStarAckReply();
|
||||||
unsigned int ackTime = m_conf.getDStarAckTime();
|
unsigned int ackTime = m_conf.getDStarAckTime();
|
||||||
bool ackMessage = m_conf.getDStarAckMessage();
|
bool ackMessage = m_conf.getDStarAckMessage();
|
||||||
@@ -441,8 +442,10 @@ int CMMDVMHost::run()
|
|||||||
|
|
||||||
if (blackList.size() > 0U)
|
if (blackList.size() > 0U)
|
||||||
LogInfo(" Black List: %u", blackList.size());
|
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;
|
DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;
|
||||||
|
|||||||
@@ -26,13 +26,13 @@
|
|||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#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 <ifaddrs.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#if defined(__OpenBSD__) || defined(__NetBSD__)
|
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
@@ -66,7 +66,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
|||||||
|
|
||||||
::strcpy((char*)info, "(address unknown)");
|
::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;
|
char* dflt = NULL;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@@ -91,7 +91,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
|||||||
|
|
||||||
::fclose(fp);
|
::fclose(fp);
|
||||||
|
|
||||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||||
const int mib[] = {
|
const int mib[] = {
|
||||||
CTL_NET,
|
CTL_NET,
|
||||||
PF_ROUTE,
|
PF_ROUTE,
|
||||||
@@ -99,7 +99,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
|||||||
AF_INET, // IPv4 routing
|
AF_INET, // IPv4 routing
|
||||||
NET_RT_DUMP,
|
NET_RT_DUMP,
|
||||||
0, // show all routes
|
0, // show all routes
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||||
0, // table id
|
0, // table id
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -126,7 +126,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
|||||||
continue;
|
continue;
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__OpenBSD__)
|
||||||
struct sockaddr_in *sa = (struct sockaddr_in *)(p + rtm->rtm_hdrlen);
|
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);
|
struct sockaddr_in *sa = (struct sockaddr_in *)(rtm + 1);
|
||||||
#endif
|
#endif
|
||||||
if (sa->sin_addr.s_addr == INADDR_ANY) {
|
if (sa->sin_addr.s_addr == INADDR_ANY) {
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate new file
|
# 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
|
# Restart MMDVMHost
|
||||||
eval ${RESTARTCOMMAND}
|
eval ${RESTARTCOMMAND}
|
||||||
|
|||||||
Reference in New Issue
Block a user