Merge pull request #2 from g4klx/master

Merge from upstream.
This commit is contained in:
Inga Muste 2022-02-09 15:38:54 +02:00 committed by GitHub
commit 5fe32de534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 8 deletions

View File

@ -36,6 +36,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
@ -155,7 +156,7 @@ void CP25Gateway::run()
return;
}
// Double check it worked (AKA Paranoia)
// Double check it worked (AKA Paranoia)
if (setuid(0) != -1) {
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
return;
@ -301,8 +302,18 @@ void CP25Gateway::run()
hangTimer.start();
}
} else if (currentTG == 0U) {
bool poll = false;
unsigned char pollReply[11U] = { 0xF0U };
std::string callsign = m_conf.getCallsign();
callsign.resize(10U, ' ');
// Build poll reply data
for (unsigned int i = 0U; i < 10U; i++)
pollReply[i + 1U] = callsign.at(i);
// Don't pass reflector control data through to the MMDVM
if (buffer[0U] != 0xF0U && buffer[0U] != 0xF1U) {
if ((buffer[0U] != 0xF0U && buffer[0U] != 0xF1U) || (poll = (::memcmp(buffer, pollReply, std::min(11U, len)) == 0))) {
// Find the static TG that this audio data belongs to
for (std::vector<CStaticTG>::const_iterator it = staticTGs.cbegin(); it != staticTGs.cend(); ++it) {
if (CUDPSocket::match(addr, (*it).m_addr)) {
@ -325,7 +336,8 @@ void CP25Gateway::run()
buffer[3U] = (currentTG >> 0) & 0xFFU;
}
localNetwork.write(buffer, len);
if (!poll)
localNetwork.write(buffer, len);
LogMessage("Switched to reflector %u due to network activity", currentTG);
@ -347,7 +359,7 @@ void CP25Gateway::run()
srcId = (buffer[1U] << 16) & 0xFF0000U;
srcId |= (buffer[2U] << 8) & 0x00FF00U;
srcId |= (buffer[3U] << 0) & 0x0000FFU;
if (dstTG != currentTG) {
if (currentAddrLen > 0U) {
std::string callsign = lookup->find(srcId);
@ -449,7 +461,7 @@ void CP25Gateway::run()
if (res > 0) {
buffer[res] = '\0';
if (::memcmp(buffer + 0U, "TalkGroup", 9U) == 0) {
unsigned int tg = (unsigned int)::atoi((char*)(buffer + 9U));
unsigned int tg = ((strlen((char*)buffer + 0U) > 10) ? (unsigned int)::atoi((char*)(buffer + 10U)) : 9999);
if (tg != currentTG) {
if (currentAddrLen > 0U) {
@ -514,6 +526,21 @@ void CP25Gateway::run()
voice->linkedTo(currentTG);
}
}
} else if (::memcmp(buffer + 0U, "status", 6U) == 0) {
std::string state = std::string("p25:") + ((currentAddrLen > 0) ? "conn" : "disc");
remoteSocket->write((unsigned char*)state.c_str(), (unsigned int)state.length(), addr, addrLen);
} else if (::memcmp(buffer + 0U, "host", 4U) == 0) {
std::string ref;
if (currentAddrLen > 0) {
char buffer[INET6_ADDRSTRLEN];
if (getnameinfo((struct sockaddr*)&currentAddr, currentAddrLen, buffer, sizeof(buffer), 0, 0, NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
ref = std::string(buffer);
}
}
std::string host = std::string("p25:\"") + ((ref.length() == 0) ? "NONE" : ref) + "\"";
remoteSocket->write((unsigned char*)host.c_str(), (unsigned int)host.length(), addr, addrLen);
} else {
CUtils::dump("Invalid remote command received", buffer, res);
}

View File

@ -12,7 +12,7 @@
# 138 P25 PKT THAILAND
138 p25138.freeddns.org 41001
# 149 Thailand P25 Link XLX149 Modules C
# 149 Thailand P25 Link XLX149 Modules D
149 p25.pwk.ac.th 41000
# 202 HELLAS Zone P25
@ -73,7 +73,7 @@
994 misc.openreflector.com 41000
# 1007 The Harley-Hangout "TGIF TG-1007 Multi-Function Bridge"
1007 43773.kb5rir.com 41000
1007 43773.kb5rir.com 41003
# 1701 Sector 001
1701 hamsomniac.mooo.com 41001
@ -186,6 +186,9 @@
# 10260 Poland
10260 80.211.249.221 41000
# 10294 SkyHub https://skyhublink.com/connections
10294 hub.skyhublink.com 41000
# 10300 Europe https://p25-eu.n18.de/
10300 176.9.1.168 41000
@ -255,6 +258,9 @@
# 10473 LinAn, China, Fireside Chat Reflector
10473 p25.hamdao.com 41000
# 10666 F5KFF P25 Net in Paris
10666 f5kff.hd.free.fr 41000
# 10700 Australia NSW Bridge to AU NSW YSF
10700 p25nsw.gustotech.net 41000
@ -291,6 +297,9 @@
# 23426 FreeSTAR UK
23426 p25.freestar.network 41000
#23456 SHARC Multi Mode System Sherman, ME
23456 kc1noc.duckdns.org 41000
# 23551 P25 Scotland
23551 p25scotland.ddns.net 41000
@ -310,7 +319,7 @@
26538 116.203.223.233 41000
# 28299 America-Ragchew
28299 65.101.7.51 41000
28299 arcp25.duckdns.org 41000
# 29252 Oklahoma Hamsomniacs
29252 hamsomniac.mooo.com 41000
@ -468,6 +477,9 @@
# 50536 FreeSTAR VK
50536 p25tg50536.vkradio.com 41001
# 51502 DX1ACE
51502 p25-dx1ace.hopto.org 41000
# 51503 US Philippines P25 network
51503 45.79.76.10 41000
@ -483,12 +495,18 @@
# 51575 PH-Dumaguete Link (Multimode)
51575 140.82.14.24 41000
# 52032 P25 Link XLX149 Modules C
52032 p52032.pwk.ac.th 41009
# 52072 Phuket
52072 xlx727phuketdstar.ddns.net 41000
# 52138 P25 Link Thailand
52138 p2552138.freeddns.org 41000
# 52910 XLX Nexus
52910 p25x.mywire.org 41000
# 53099 New Zealand bridge to D-Star, DMR and NXDN
53099 203.86.206.49 41000