A number of major and minor fixes.
This commit is contained in:
parent
7a36995e81
commit
7f0b9aae89
|
@ -150,7 +150,7 @@ bool CConf::read()
|
||||||
else if (::strcmp(key, "ParrotPort") == 0)
|
else if (::strcmp(key, "ParrotPort") == 0)
|
||||||
m_networkParrotPort = (unsigned int)::atoi(value);
|
m_networkParrotPort = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Startup") == 0)
|
else if (::strcmp(key, "Startup") == 0)
|
||||||
m_networkStartup = (unsigned int)::atoi(value);
|
m_networkStartup = (unsigned short)::atoi(value);
|
||||||
else if (::strcmp(key, "InactivityTimeout") == 0)
|
else if (::strcmp(key, "InactivityTimeout") == 0)
|
||||||
m_networkInactivityTimeout = (unsigned int)::atoi(value);
|
m_networkInactivityTimeout = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Debug") == 0)
|
else if (::strcmp(key, "Debug") == 0)
|
||||||
|
@ -258,7 +258,7 @@ unsigned int CConf::getNetworkParrotPort() const
|
||||||
return m_networkParrotPort;
|
return m_networkParrotPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CConf::getNetworkStartup() const
|
unsigned short CConf::getNetworkStartup() const
|
||||||
{
|
{
|
||||||
return m_networkStartup;
|
return m_networkStartup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,15 @@ public:
|
||||||
std::string getLogFileRoot() const;
|
std::string getLogFileRoot() const;
|
||||||
|
|
||||||
// The Network section
|
// The Network section
|
||||||
unsigned int getNetworkPort() const;
|
unsigned int getNetworkPort() const;
|
||||||
std::string getNetworkHosts1() const;
|
std::string getNetworkHosts1() const;
|
||||||
std::string getNetworkHosts2() const;
|
std::string getNetworkHosts2() const;
|
||||||
unsigned int getNetworkReloadTime() const;
|
unsigned int getNetworkReloadTime() const;
|
||||||
std::string getNetworkParrotAddress() const;
|
std::string getNetworkParrotAddress() const;
|
||||||
unsigned int getNetworkParrotPort() const;
|
unsigned int getNetworkParrotPort() const;
|
||||||
unsigned int getNetworkStartup() const;
|
unsigned short getNetworkStartup() const;
|
||||||
unsigned int getNetworkInactivityTimeout() const;
|
unsigned int getNetworkInactivityTimeout() const;
|
||||||
bool getNetworkDebug() const;
|
bool getNetworkDebug() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_file;
|
std::string m_file;
|
||||||
|
@ -81,15 +81,15 @@ private:
|
||||||
std::string m_logFilePath;
|
std::string m_logFilePath;
|
||||||
std::string m_logFileRoot;
|
std::string m_logFileRoot;
|
||||||
|
|
||||||
unsigned int m_networkPort;
|
unsigned int m_networkPort;
|
||||||
std::string m_networkHosts1;
|
std::string m_networkHosts1;
|
||||||
std::string m_networkHosts2;
|
std::string m_networkHosts2;
|
||||||
unsigned int m_networkReloadTime;
|
unsigned int m_networkReloadTime;
|
||||||
std::string m_networkParrotAddress;
|
std::string m_networkParrotAddress;
|
||||||
unsigned int m_networkParrotPort;
|
unsigned int m_networkParrotPort;
|
||||||
unsigned int m_networkStartup;
|
unsigned short m_networkStartup;
|
||||||
unsigned int m_networkInactivityTimeout;
|
unsigned int m_networkInactivityTimeout;
|
||||||
bool m_networkDebug;
|
bool m_networkDebug;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -212,11 +212,11 @@ void CNXDNGateway::run()
|
||||||
unsigned short dstId = 0U;
|
unsigned short dstId = 0U;
|
||||||
bool grp = false;
|
bool grp = false;
|
||||||
|
|
||||||
unsigned int currentId = 9999U;
|
unsigned short currentId = 9999U;
|
||||||
in_addr currentAddr;
|
in_addr currentAddr;
|
||||||
unsigned int currentPort = 0U;
|
unsigned int currentPort = 0U;
|
||||||
|
|
||||||
unsigned int id = m_conf.getNetworkStartup();
|
unsigned short id = m_conf.getNetworkStartup();
|
||||||
if (id != 9999U) {
|
if (id != 9999U) {
|
||||||
CNXDNReflector* reflector = reflectors.find(id);
|
CNXDNReflector* reflector = reflectors.find(id);
|
||||||
if (reflector != NULL) {
|
if (reflector != NULL) {
|
||||||
|
@ -228,9 +228,9 @@ void CNXDNGateway::run()
|
||||||
pollTimer.start();
|
pollTimer.start();
|
||||||
lostTimer.start();
|
lostTimer.start();
|
||||||
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
LogMessage("Linked at startup to reflector %u", currentId);
|
LogMessage("Linked at startup to reflector %u", currentId);
|
||||||
}
|
}
|
||||||
|
@ -290,9 +290,9 @@ void CNXDNGateway::run()
|
||||||
if (voice != NULL && dstId == 9999U)
|
if (voice != NULL && dstId == 9999U)
|
||||||
voice->unlinked();
|
voice->unlinked();
|
||||||
|
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
inactivityTimer.stop();
|
inactivityTimer.stop();
|
||||||
pollTimer.stop();
|
pollTimer.stop();
|
||||||
|
@ -314,9 +314,9 @@ void CNXDNGateway::run()
|
||||||
if (voice != NULL)
|
if (voice != NULL)
|
||||||
voice->linkedTo(currentId);
|
voice->linkedTo(currentId);
|
||||||
|
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
inactivityTimer.start();
|
inactivityTimer.start();
|
||||||
pollTimer.start();
|
pollTimer.start();
|
||||||
|
@ -357,9 +357,9 @@ void CNXDNGateway::run()
|
||||||
if (currentId != 9999U) {
|
if (currentId != 9999U) {
|
||||||
LogMessage("Unlinking from %u due to inactivity", currentId);
|
LogMessage("Unlinking from %u due to inactivity", currentId);
|
||||||
|
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
remoteNetwork.writeUnlink(currentAddr, currentPort);
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
if (voice != NULL)
|
if (voice != NULL)
|
||||||
voice->unlinked();
|
voice->unlinked();
|
||||||
|
@ -375,7 +375,7 @@ void CNXDNGateway::run()
|
||||||
pollTimer.clock(ms);
|
pollTimer.clock(ms);
|
||||||
if (pollTimer.isRunning() && pollTimer.hasExpired()) {
|
if (pollTimer.isRunning() && pollTimer.hasExpired()) {
|
||||||
if (currentId != 9999U)
|
if (currentId != 9999U)
|
||||||
remoteNetwork.writePoll(currentAddr, currentPort);
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
pollTimer.start();
|
pollTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ bool CNXDNNetwork::writeData(const unsigned char* data, unsigned int length, uns
|
||||||
return m_socket.write(buffer, 43U, address, port);
|
return m_socket.write(buffer, 43U, address, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNXDNNetwork::writePoll(const in_addr& address, unsigned int port)
|
bool CNXDNNetwork::writePoll(const in_addr& address, unsigned int port, unsigned short tg)
|
||||||
{
|
{
|
||||||
assert(port > 0U);
|
assert(port > 0U);
|
||||||
|
|
||||||
|
@ -94,13 +94,16 @@ bool CNXDNNetwork::writePoll(const in_addr& address, unsigned int port)
|
||||||
for (unsigned int i = 0U; i < 10U; i++)
|
for (unsigned int i = 0U; i < 10U; i++)
|
||||||
data[i + 5U] = m_callsign.at(i);
|
data[i + 5U] = m_callsign.at(i);
|
||||||
|
|
||||||
if (m_debug)
|
data[15U] = (tg >> 8) & 0xFFU;
|
||||||
CUtils::dump(1U, "NXDN Network Poll Sent", data, 15U);
|
data[16U] = (tg >> 0) & 0xFFU;
|
||||||
|
|
||||||
return m_socket.write(data, 15U, address, port);
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "NXDN Network Poll Sent", data, 17U);
|
||||||
|
|
||||||
|
return m_socket.write(data, 17U, address, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNXDNNetwork::writeUnlink(const in_addr& address, unsigned int port)
|
bool CNXDNNetwork::writeUnlink(const in_addr& address, unsigned int port, unsigned short tg)
|
||||||
{
|
{
|
||||||
assert(port > 0U);
|
assert(port > 0U);
|
||||||
|
|
||||||
|
@ -115,10 +118,13 @@ bool CNXDNNetwork::writeUnlink(const in_addr& address, unsigned int port)
|
||||||
for (unsigned int i = 0U; i < 10U; i++)
|
for (unsigned int i = 0U; i < 10U; i++)
|
||||||
data[i + 5U] = m_callsign.at(i);
|
data[i + 5U] = m_callsign.at(i);
|
||||||
|
|
||||||
if (m_debug)
|
data[15U] = (tg >> 8) & 0xFFU;
|
||||||
CUtils::dump(1U, "NXDN Network Unlink Sent", data, 15U);
|
data[16U] = (tg >> 0) & 0xFFU;
|
||||||
|
|
||||||
return m_socket.write(data, 15U, address, port);
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "NXDN Network Unlink Sent", data, 17U);
|
||||||
|
|
||||||
|
return m_socket.write(data, 17U, address, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CNXDNNetwork::readData(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port)
|
unsigned int CNXDNNetwork::readData(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port)
|
||||||
|
@ -130,7 +136,7 @@ unsigned int CNXDNNetwork::readData(unsigned char* data, unsigned int length, in
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
if ((::memcmp(data, "NXDNP", 5U) == 0 && len == 15) || (::memcmp(data, "NXDND", 5U) == 0 && len == 43)) {
|
if ((::memcmp(data, "NXDNP", 5U) == 0 && len == 17) || (::memcmp(data, "NXDND", 5U) == 0 && len == 43)) {
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
CUtils::dump(1U, "NXDN Network Data Received", data, len);
|
CUtils::dump(1U, "NXDN Network Data Received", data, len);
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ public:
|
||||||
|
|
||||||
bool writeData(const unsigned char* data, unsigned int length, unsigned short srcId, unsigned short dstId, bool grp, const in_addr& address, unsigned int port);
|
bool writeData(const unsigned char* data, unsigned int length, unsigned short srcId, unsigned short dstId, bool grp, const in_addr& address, unsigned int port);
|
||||||
|
|
||||||
bool writePoll(const in_addr& address, unsigned int port);
|
bool writePoll(const in_addr& address, unsigned int port, unsigned short tg);
|
||||||
|
|
||||||
bool writeUnlink(const in_addr& address, unsigned int port);
|
bool writeUnlink(const in_addr& address, unsigned int port, unsigned short tg);
|
||||||
|
|
||||||
unsigned int readData(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port);
|
unsigned int readData(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ bool CReflectors::load()
|
||||||
in_addr address = CUDPSocket::lookup(host);
|
in_addr address = CUDPSocket::lookup(host);
|
||||||
if (address.s_addr != INADDR_NONE) {
|
if (address.s_addr != INADDR_NONE) {
|
||||||
CNXDNReflector* refl = new CNXDNReflector;
|
CNXDNReflector* refl = new CNXDNReflector;
|
||||||
refl->m_id = (unsigned int)::atoi(p1);
|
refl->m_id = (unsigned short)::atoi(p1);
|
||||||
refl->m_address = address;
|
refl->m_address = address;
|
||||||
refl->m_port = (unsigned int)::atoi(p3);
|
refl->m_port = (unsigned int)::atoi(p3);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ bool CReflectors::load()
|
||||||
in_addr address = CUDPSocket::lookup(host);
|
in_addr address = CUDPSocket::lookup(host);
|
||||||
if (address.s_addr != INADDR_NONE) {
|
if (address.s_addr != INADDR_NONE) {
|
||||||
CNXDNReflector* refl = new CNXDNReflector;
|
CNXDNReflector* refl = new CNXDNReflector;
|
||||||
refl->m_id = (unsigned int)::atoi(p1);
|
refl->m_id = (unsigned short)::atoi(p1);
|
||||||
refl->m_address = address;
|
refl->m_address = address;
|
||||||
refl->m_port = (unsigned int)::atoi(p3);
|
refl->m_port = (unsigned int)::atoi(p3);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ bool CReflectors::load()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CNXDNReflector* CReflectors::find(unsigned int id)
|
CNXDNReflector* CReflectors::find(unsigned short id)
|
||||||
{
|
{
|
||||||
for (std::vector<CNXDNReflector*>::iterator it = m_reflectors.begin(); it != m_reflectors.end(); ++it) {
|
for (std::vector<CNXDNReflector*>::iterator it = m_reflectors.begin(); it != m_reflectors.end(); ++it) {
|
||||||
if (id == (*it)->m_id)
|
if (id == (*it)->m_id)
|
||||||
|
|
|
@ -28,15 +28,15 @@
|
||||||
class CNXDNReflector {
|
class CNXDNReflector {
|
||||||
public:
|
public:
|
||||||
CNXDNReflector() :
|
CNXDNReflector() :
|
||||||
m_id(),
|
m_id(0U),
|
||||||
m_address(),
|
m_address(),
|
||||||
m_port(0U)
|
m_port(0U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int m_id;
|
unsigned short m_id;
|
||||||
in_addr m_address;
|
in_addr m_address;
|
||||||
unsigned int m_port;
|
unsigned int m_port;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CReflectors {
|
class CReflectors {
|
||||||
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
|
|
||||||
CNXDNReflector* find(unsigned int id);
|
CNXDNReflector* find(unsigned short id);
|
||||||
|
|
||||||
void clock(unsigned int ms);
|
void clock(unsigned int ms);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
||||||
LIBS = -lpthread
|
LIBS = -lpthread
|
||||||
LDFLAGS = -g
|
LDFLAGS = -g
|
||||||
|
|
||||||
OBJECTS = Network.o NXDNParrot.o Parrot.o StopWatch.o Thread.o Timer.o UDPSocket.o
|
OBJECTS = NXDNNetwork.o NXDNParrot.o Parrot.o StopWatch.o Thread.o Timer.o UDPSocket.o
|
||||||
|
|
||||||
all: NXDNParrot
|
all: NXDNParrot
|
||||||
|
|
||||||
|
|
|
@ -16,31 +16,31 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Network.h"
|
#include "NXDNNetwork.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
CNetwork::CNetwork(unsigned int port) :
|
CNXDNNetwork::CNXDNNetwork(unsigned int port) :
|
||||||
m_socket(port),
|
m_socket(port),
|
||||||
m_address(),
|
m_address(),
|
||||||
m_port(0U)
|
m_port(0U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CNetwork::~CNetwork()
|
CNXDNNetwork::~CNXDNNetwork()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetwork::open()
|
bool CNXDNNetwork::open()
|
||||||
{
|
{
|
||||||
::fprintf(stdout, "Opening NXDN network connection\n");
|
::fprintf(stdout, "Opening NXDN network connection\n");
|
||||||
|
|
||||||
return m_socket.open();
|
return m_socket.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetwork::write(const unsigned char* data, unsigned int length)
|
bool CNXDNNetwork::write(const unsigned char* data, unsigned int length)
|
||||||
{
|
{
|
||||||
if (m_port == 0U)
|
if (m_port == 0U)
|
||||||
return true;
|
return true;
|
||||||
|
@ -50,7 +50,7 @@ bool CNetwork::write(const unsigned char* data, unsigned int length)
|
||||||
return m_socket.write(data, length, m_address, m_port);
|
return m_socket.write(data, length, m_address, m_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CNetwork::read(unsigned char* data, unsigned int len)
|
unsigned int CNXDNNetwork::read(unsigned char* data, unsigned int len)
|
||||||
{
|
{
|
||||||
in_addr address;
|
in_addr address;
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
|
@ -61,7 +61,7 @@ unsigned int CNetwork::read(unsigned char* data, unsigned int len)
|
||||||
m_address.s_addr = address.s_addr;
|
m_address.s_addr = address.s_addr;
|
||||||
m_port = port;
|
m_port = port;
|
||||||
|
|
||||||
if (::memcmp(data, "NXDNP", 5U) == 0 && length == 15) { // A poll
|
if (::memcmp(data, "NXDNP", 5U) == 0 && length == 17) { // A poll
|
||||||
write(data, length);
|
write(data, length);
|
||||||
return 0U;
|
return 0U;
|
||||||
} else if (::memcmp(data, "NXDND", 5U) == 0 && length == 43) {
|
} else if (::memcmp(data, "NXDND", 5U) == 0 && length == 43) {
|
||||||
|
@ -71,12 +71,12 @@ unsigned int CNetwork::read(unsigned char* data, unsigned int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetwork::end()
|
void CNXDNNetwork::end()
|
||||||
{
|
{
|
||||||
m_port = 0U;
|
m_port = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetwork::close()
|
void CNXDNNetwork::close()
|
||||||
{
|
{
|
||||||
m_socket.close();
|
m_socket.close();
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef Network_H
|
#ifndef NXDNNetwork_H
|
||||||
#define Network_H
|
#define NXDNNetwork_H
|
||||||
|
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CNetwork {
|
class CNXDNNetwork {
|
||||||
public:
|
public:
|
||||||
CNetwork(unsigned int port);
|
CNXDNNetwork(unsigned int port);
|
||||||
~CNetwork();
|
~CNXDNNetwork();
|
||||||
|
|
||||||
bool open();
|
bool open();
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StopWatch.h"
|
#include "NXDNNetwork.h"
|
||||||
#include "NXDNParrot.h"
|
#include "NXDNParrot.h"
|
||||||
#include "Parrot.h"
|
#include "StopWatch.h"
|
||||||
#include "Network.h"
|
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
#include "Parrot.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ CNXDNParrot::~CNXDNParrot()
|
||||||
void CNXDNParrot::run()
|
void CNXDNParrot::run()
|
||||||
{
|
{
|
||||||
CParrot parrot(180U);
|
CParrot parrot(180U);
|
||||||
CNetwork network(m_port);
|
CNXDNNetwork network(m_port);
|
||||||
|
|
||||||
bool ret = network.open();
|
bool ret = network.open();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Network.h" />
|
<ClInclude Include="NXDNNetwork.h" />
|
||||||
<ClInclude Include="NXDNParrot.h" />
|
<ClInclude Include="NXDNParrot.h" />
|
||||||
<ClInclude Include="Parrot.h" />
|
<ClInclude Include="Parrot.h" />
|
||||||
<ClInclude Include="StopWatch.h" />
|
<ClInclude Include="StopWatch.h" />
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
<ClInclude Include="Version.h" />
|
<ClInclude Include="Version.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Network.cpp" />
|
<ClCompile Include="NXDNNetwork.cpp" />
|
||||||
<ClCompile Include="NXDNParrot.cpp" />
|
<ClCompile Include="NXDNParrot.cpp" />
|
||||||
<ClCompile Include="Parrot.cpp" />
|
<ClCompile Include="Parrot.cpp" />
|
||||||
<ClCompile Include="StopWatch.cpp" />
|
<ClCompile Include="StopWatch.cpp" />
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Network.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="NXDNParrot.h">
|
<ClInclude Include="NXDNParrot.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -35,11 +32,11 @@
|
||||||
<ClInclude Include="Thread.h">
|
<ClInclude Include="Thread.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="NXDNNetwork.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Network.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="NXDNParrot.cpp">
|
<ClCompile Include="NXDNParrot.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -58,5 +55,8 @@
|
||||||
<ClCompile Include="Thread.cpp">
|
<ClCompile Include="Thread.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="NXDNNetwork.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -102,7 +102,7 @@ unsigned int CNXDNNetwork::read(unsigned char* data, unsigned int length, in_add
|
||||||
if (::memcmp(data, "NXDN", 4U) != 0)
|
if (::memcmp(data, "NXDN", 4U) != 0)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
if (len != 15 && len != 43)
|
if (len != 17 && len != 43)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
|
|
|
@ -214,35 +214,41 @@ void CNXDNReflector::run()
|
||||||
if (len > 0U) {
|
if (len > 0U) {
|
||||||
CNXDNRepeater* rpt = findRepeater(address, port);
|
CNXDNRepeater* rpt = findRepeater(address, port);
|
||||||
|
|
||||||
if (::memcmp(buffer, "NXDNP", 5U) == 0 && len == 15U) {
|
if (::memcmp(buffer, "NXDNP", 5U) == 0 && len == 17U) {
|
||||||
if (rpt == NULL) {
|
unsigned short id = (buffer[15U] << 8) | buffer[16U];
|
||||||
rpt = new CNXDNRepeater;
|
if (id == tg) {
|
||||||
rpt->m_timer.start();
|
if (rpt == NULL) {
|
||||||
rpt->m_address = address;
|
rpt = new CNXDNRepeater;
|
||||||
rpt->m_port = port;
|
rpt->m_timer.start();
|
||||||
rpt->m_callsign = std::string((char*)(buffer + 5U), 10U);
|
rpt->m_address = address;
|
||||||
m_repeaters.push_back(rpt);
|
rpt->m_port = port;
|
||||||
|
rpt->m_callsign = std::string((char*)(buffer + 5U), 10U);
|
||||||
|
m_repeaters.push_back(rpt);
|
||||||
|
|
||||||
LogMessage("Adding %s (%s:%u)", rpt->m_callsign.c_str(), ::inet_ntoa(address), port);
|
LogMessage("Adding %s (%s:%u)", rpt->m_callsign.c_str(), ::inet_ntoa(address), port);
|
||||||
} else {
|
} else {
|
||||||
rpt->m_timer.start();
|
rpt->m_timer.start();
|
||||||
}
|
|
||||||
|
|
||||||
// Return the poll
|
|
||||||
nxdnNetwork.write(buffer, len, address, port);
|
|
||||||
} else if (::memcmp(buffer, "NXDNU", 5U) == 0 && len == 15U) {
|
|
||||||
if (rpt != NULL) {
|
|
||||||
std::string callsign = std::string((char*)(buffer + 5U), 10U);
|
|
||||||
LogMessage("Removing %s (%s:%u)", callsign.c_str(), ::inet_ntoa(address), port);
|
|
||||||
|
|
||||||
for (std::vector<CNXDNRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
||||||
if (*it == rpt) {
|
|
||||||
m_repeaters.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete rpt;
|
// Return the poll
|
||||||
|
nxdnNetwork.write(buffer, len, address, port);
|
||||||
|
}
|
||||||
|
} else if (::memcmp(buffer, "NXDNU", 5U) == 0 && len == 17U) {
|
||||||
|
unsigned short id = (buffer[15U] << 8) | buffer[16U];
|
||||||
|
if (id == tg) {
|
||||||
|
if (rpt != NULL) {
|
||||||
|
std::string callsign = std::string((char*)(buffer + 5U), 10U);
|
||||||
|
LogMessage("Removing %s (%s:%u)", callsign.c_str(), ::inet_ntoa(address), port);
|
||||||
|
|
||||||
|
for (std::vector<CNXDNRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||||
|
if (*it == rpt) {
|
||||||
|
m_repeaters.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete rpt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (::memcmp(buffer, "NXDND", 5U) == 0 && len == 43U) {
|
} else if (::memcmp(buffer, "NXDND", 5U) == 0 && len == 43U) {
|
||||||
if (rpt != NULL) {
|
if (rpt != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue