Skip to content

Commit

Permalink
Merge branch 'master' into SimpleDMR
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Oct 30, 2020
2 parents 62c0165 + 99cdcf1 commit bbe44df
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 12 deletions.
18 changes: 18 additions & 0 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ m_dstarEnabled(false),
m_dstarModule("C"),
m_dstarSelfOnly(false),
m_dstarBlackList(),
m_dstarWhiteList(),
m_dstarAckReply(true),
m_dstarAckTime(750U),
m_dstarAckMessage(false),
Expand Down Expand Up @@ -544,6 +545,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)
Expand Down Expand Up @@ -1236,6 +1249,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;
Expand Down
2 changes: 2 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class CConf
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;
Expand Down Expand Up @@ -372,6 +373,7 @@ class CConf
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;
Expand Down
7 changes: 4 additions & 3 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion DStarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -59,6 +59,7 @@ class CDStarControl {
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;
Expand Down
1 change: 1 addition & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ AckMessage=0
ErrorReply=1
RemoteGateway=0
# ModeHang=10
WhiteList=

[DMR]
Enable=1
Expand Down
5 changes: 4 additions & 1 deletion MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,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();
Expand All @@ -430,8 +431,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;
Expand Down
12 changes: 6 additions & 6 deletions NetworkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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__)
Expand All @@ -91,15 +91,15 @@ 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,
0, // protocol
AF_INET, // IPv4 routing
NET_RT_DUMP,
0, // show all routes
#if defined(__OpenBSD__)
#if defined(__OpenBSD__) || defined(__FreeBSD__)
0, // table id
#endif
};
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion linux/DMRIDUpdateBM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit bbe44df

Please sign in to comment.