1
0
Fork 0

Initial changes ready for FCS support.

ycs232-kbc
Jonathan Naylor 7 years ago
parent 42bb42380a
commit c84df3db5e

@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
LIBS = -lm -lpthread LIBS = -lm -lpthread
LDFLAGS = -g LDFLAGS = -g
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o
all: YSFGateway all: YSFGateway

@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
LIBS = -lm -lpthread -lsocket LIBS = -lm -lpthread -lsocket
LDFLAGS = -g LDFLAGS = -g
OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \
UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o
all: YSFGateway all: YSFGateway

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -42,7 +42,7 @@ const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U};
const unsigned char NET_HEADER[] = "YSFD ALL "; const unsigned char NET_HEADER[] = "YSFD ALL ";
CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime) : CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime) :
m_callsign(callsign), m_callsign(callsign),
m_node(), m_node(),
m_network(network), m_network(network),

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,8 +19,8 @@
#if !defined(WIRESX_H) #if !defined(WIRESX_H)
#define WIRESX_H #define WIRESX_H
#include "Reflectors.h" #include "YSFReflectors.h"
#include "Network.h" #include "YSFNetwork.h"
#include "Timer.h" #include "Timer.h"
#include <string> #include <string>
@ -42,7 +42,7 @@ enum WXSI_STATUS {
class CWiresX { class CWiresX {
public: public:
CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime); CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, const std::string& hostsFile, unsigned int reloadTime);
~CWiresX(); ~CWiresX();
void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency);
@ -64,8 +64,8 @@ public:
private: private:
std::string m_callsign; std::string m_callsign;
std::string m_node; std::string m_node;
CNetwork* m_network; CYSFNetwork* m_network;
CReflectors m_reflectors; CYSFReflectors m_reflectors;
CYSFReflector* m_reflector; CYSFReflector* m_reflector;
std::string m_id; std::string m_id;
std::string m_name; std::string m_name;

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
*/ */
#include "YSFGateway.h" #include "YSFGateway.h"
#include "Reflectors.h" #include "YSFReflectors.h"
#include "UDPSocket.h" #include "UDPSocket.h"
#include "StopWatch.h" #include "StopWatch.h"
#include "Version.h" #include "Version.h"
@ -81,7 +81,7 @@ m_conf(configFile),
m_gps(NULL), m_gps(NULL),
m_wiresX(NULL), m_wiresX(NULL),
m_dtmf(NULL), m_dtmf(NULL),
m_netNetwork(NULL), m_ysfNetwork(NULL),
m_linked(false), m_linked(false),
m_exclude(false) m_exclude(false)
{ {
@ -174,7 +174,7 @@ int CYSFGateway::run()
std::string myAddress = m_conf.getMyAddress(); std::string myAddress = m_conf.getMyAddress();
unsigned int myPort = m_conf.getMyPort(); unsigned int myPort = m_conf.getMyPort();
CNetwork rptNetwork(myAddress, myPort, m_callsign, debug); CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug);
rptNetwork.setDestination(rptAddress, rptPort); rptNetwork.setDestination(rptAddress, rptPort);
ret = rptNetwork.open(); ret = rptNetwork.open();
@ -186,10 +186,10 @@ int CYSFGateway::run()
unsigned int netPort = m_conf.getNetworkPort(); unsigned int netPort = m_conf.getNetworkPort();
m_netNetwork = new CNetwork(netPort, m_callsign, debug); m_ysfNetwork = new CYSFNetwork(netPort, m_callsign, debug);
ret = m_netNetwork->open(); ret = m_ysfNetwork->open();
if (!ret) { if (!ret) {
::LogError("Cannot open the reflector network port"); ::LogError("Cannot open the YSF reflector network port");
::LogFinalise(); ::LogFinalise();
return 1; return 1;
} }
@ -234,10 +234,10 @@ int CYSFGateway::run()
if (reflector != NULL) { if (reflector != NULL) {
LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
m_netNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
if (!revert) if (!revert)
inactivityTimer.start(); inactivityTimer.start();
@ -276,17 +276,17 @@ int CYSFGateway::run()
WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft);
switch (status) { switch (status) {
case WXS_CONNECT: { case WXS_CONNECT: {
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
CYSFReflector* reflector = m_wiresX->getReflector(); CYSFReflector* reflector = m_wiresX->getReflector();
LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U);
m_netNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
inactivityTimer.start(); inactivityTimer.start();
lostTimer.start(); lostTimer.start();
@ -298,10 +298,10 @@ int CYSFGateway::run()
case WXS_DISCONNECT: case WXS_DISCONNECT:
LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); LogMessage("Disconnect has been requested by %10.10s", buffer + 14U);
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->clearDestination(); m_ysfNetwork->clearDestination();
inactivityTimer.stop(); inactivityTimer.stop();
lostTimer.stop(); lostTimer.stop();
@ -330,17 +330,17 @@ int CYSFGateway::run()
m_wiresX->processConnect(reflector); m_wiresX->processConnect(reflector);
if (m_linked) { if (m_linked) {
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
} }
LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U);
m_netNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
inactivityTimer.start(); inactivityTimer.start();
lostTimer.start(); lostTimer.start();
@ -356,10 +356,10 @@ int CYSFGateway::run()
LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U);
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->clearDestination(); m_ysfNetwork->clearDestination();
inactivityTimer.stop(); inactivityTimer.stop();
lostTimer.stop(); lostTimer.stop();
@ -378,7 +378,7 @@ int CYSFGateway::run()
} }
if (networkEnabled && m_linked && !m_exclude) { if (networkEnabled && m_linked && !m_exclude) {
m_netNetwork->write(buffer); m_ysfNetwork->write(buffer);
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
inactivityTimer.start(); inactivityTimer.start();
} }
@ -392,7 +392,7 @@ int CYSFGateway::run()
} }
} }
while (m_netNetwork->read(buffer) > 0U) { while (m_ysfNetwork->read(buffer) > 0U) {
if (networkEnabled && m_linked) { if (networkEnabled && m_linked) {
// Only pass through YSF data packets // Only pass through YSF data packets
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) if (::memcmp(buffer + 0U, "YSFD", 4U) == 0)
@ -406,7 +406,7 @@ int CYSFGateway::run()
stopWatch.start(); stopWatch.start();
rptNetwork.clock(ms); rptNetwork.clock(ms);
m_netNetwork->clock(ms); m_ysfNetwork->clock(ms);
if (m_gps != NULL) if (m_gps != NULL)
m_gps->clock(ms); m_gps->clock(ms);
if (m_wiresX != NULL) if (m_wiresX != NULL)
@ -424,14 +424,14 @@ int CYSFGateway::run()
m_wiresX->processConnect(reflector); m_wiresX->processConnect(reflector);
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->setDestination(reflector->m_address, reflector->m_port); m_ysfNetwork->setDestination(reflector->m_address, reflector->m_port);
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
lostTimer.start(); lostTimer.start();
pollTimer.start(); pollTimer.start();
@ -441,10 +441,10 @@ int CYSFGateway::run()
if (m_wiresX != NULL) if (m_wiresX != NULL)
m_wiresX->processDisconnect(); m_wiresX->processDisconnect();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_netNetwork->clearDestination(); m_ysfNetwork->clearDestination();
lostTimer.stop(); lostTimer.stop();
pollTimer.stop(); pollTimer.stop();
@ -463,7 +463,7 @@ int CYSFGateway::run()
if (m_wiresX != NULL) if (m_wiresX != NULL)
m_wiresX->processDisconnect(); m_wiresX->processDisconnect();
m_netNetwork->clearDestination(); m_ysfNetwork->clearDestination();
inactivityTimer.stop(); inactivityTimer.stop();
lostTimer.stop(); lostTimer.stop();
@ -474,7 +474,7 @@ int CYSFGateway::run()
pollTimer.clock(ms); pollTimer.clock(ms);
if (pollTimer.isRunning() && pollTimer.hasExpired()) { if (pollTimer.isRunning() && pollTimer.hasExpired()) {
m_netNetwork->writePoll(); m_ysfNetwork->writePoll();
pollTimer.start(); pollTimer.start();
} }
@ -483,14 +483,14 @@ int CYSFGateway::run()
} }
rptNetwork.close(); rptNetwork.close();
m_netNetwork->close(); m_ysfNetwork->close();
if (m_gps != NULL) { if (m_gps != NULL) {
m_gps->close(); m_gps->close();
delete m_gps; delete m_gps;
} }
delete m_netNetwork; delete m_ysfNetwork;
delete m_wiresX; delete m_wiresX;
delete m_dtmf; delete m_dtmf;

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#if !defined(YSFGateway_H) #if !defined(YSFGateway_H)
#define YSFGateway_H #define YSFGateway_H
#include "Network.h" #include "YSFNetwork.h"
#include "WiresX.h" #include "WiresX.h"
#include "Conf.h" #include "Conf.h"
#include "DTMF.h" #include "DTMF.h"
@ -42,7 +42,7 @@ private:
CGPS* m_gps; CGPS* m_gps;
CWiresX* m_wiresX; CWiresX* m_wiresX;
CDTMF* m_dtmf; CDTMF* m_dtmf;
CNetwork* m_netNetwork; CYSFNetwork* m_ysfNetwork;
bool m_linked; bool m_linked;
bool m_exclude; bool m_exclude;

@ -154,8 +154,6 @@
<ClInclude Include="Golay24128.h" /> <ClInclude Include="Golay24128.h" />
<ClInclude Include="GPS.h" /> <ClInclude Include="GPS.h" />
<ClInclude Include="Log.h" /> <ClInclude Include="Log.h" />
<ClInclude Include="Network.h" />
<ClInclude Include="Reflectors.h" />
<ClInclude Include="RingBuffer.h" /> <ClInclude Include="RingBuffer.h" />
<ClInclude Include="StopWatch.h" /> <ClInclude Include="StopWatch.h" />
<ClInclude Include="Sync.h" /> <ClInclude Include="Sync.h" />
@ -170,7 +168,9 @@
<ClInclude Include="YSFDefines.h" /> <ClInclude Include="YSFDefines.h" />
<ClInclude Include="YSFFICH.h" /> <ClInclude Include="YSFFICH.h" />
<ClInclude Include="YSFGateway.h" /> <ClInclude Include="YSFGateway.h" />
<ClInclude Include="YSFNetwork.h" />
<ClInclude Include="YSFPayload.h" /> <ClInclude Include="YSFPayload.h" />
<ClInclude Include="YSFReflectors.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="APRSWriter.cpp" /> <ClCompile Include="APRSWriter.cpp" />
@ -181,8 +181,6 @@
<ClCompile Include="Golay24128.cpp" /> <ClCompile Include="Golay24128.cpp" />
<ClCompile Include="GPS.cpp" /> <ClCompile Include="GPS.cpp" />
<ClCompile Include="Log.cpp" /> <ClCompile Include="Log.cpp" />
<ClCompile Include="Network.cpp" />
<ClCompile Include="Reflectors.cpp" />
<ClCompile Include="StopWatch.cpp" /> <ClCompile Include="StopWatch.cpp" />
<ClCompile Include="Sync.cpp" /> <ClCompile Include="Sync.cpp" />
<ClCompile Include="TCPSocket.cpp" /> <ClCompile Include="TCPSocket.cpp" />
@ -194,7 +192,9 @@
<ClCompile Include="YSFConvolution.cpp" /> <ClCompile Include="YSFConvolution.cpp" />
<ClCompile Include="YSFFICH.cpp" /> <ClCompile Include="YSFFICH.cpp" />
<ClCompile Include="YSFGateway.cpp" /> <ClCompile Include="YSFGateway.cpp" />
<ClCompile Include="YSFNetwork.cpp" />
<ClCompile Include="YSFPayload.cpp" /> <ClCompile Include="YSFPayload.cpp" />
<ClCompile Include="YSFReflectors.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

@ -11,9 +11,6 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Network.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RingBuffer.h"> <ClInclude Include="RingBuffer.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -74,9 +71,6 @@
<ClInclude Include="Sync.h"> <ClInclude Include="Sync.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Reflectors.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Utils.h"> <ClInclude Include="Utils.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -86,11 +80,14 @@
<ClInclude Include="DTMF.h"> <ClInclude Include="DTMF.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="YSFNetwork.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="YSFReflectors.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Network.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StopWatch.cpp"> <ClCompile Include="StopWatch.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -142,9 +139,6 @@
<ClCompile Include="Sync.cpp"> <ClCompile Include="Sync.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Reflectors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Utils.cpp"> <ClCompile Include="Utils.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -154,5 +148,11 @@
<ClCompile Include="DTMF.cpp"> <ClCompile Include="DTMF.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="YSFNetwork.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="YSFReflectors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
*/ */
#include "YSFDefines.h" #include "YSFDefines.h"
#include "Network.h" #include "YSFNetwork.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h" #include "Log.h"
@ -27,7 +27,7 @@
const unsigned int BUFFER_LENGTH = 200U; const unsigned int BUFFER_LENGTH = 200U;
CNetwork::CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) :
m_socket(address, port), m_socket(address, port),
m_debug(debug), m_debug(debug),
m_address(), m_address(),
@ -51,7 +51,7 @@ m_buffer(1000U, "YSF Network Buffer")
} }
} }
CNetwork::CNetwork(unsigned int port, const std::string& callsign, bool debug) : CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, bool debug) :
m_socket(port), m_socket(port),
m_debug(debug), m_debug(debug),
m_address(), m_address(),
@ -75,31 +75,31 @@ m_buffer(1000U, "YSF Network Buffer")
} }
} }
CNetwork::~CNetwork() CYSFNetwork::~CYSFNetwork()
{ {
delete[] m_poll; delete[] m_poll;
} }
bool CNetwork::open() bool CYSFNetwork::open()
{ {
LogMessage("Opening YSF network connection"); LogMessage("Opening YSF network connection");
return m_socket.open(); return m_socket.open();
} }
void CNetwork::setDestination(const in_addr& address, unsigned int port) void CYSFNetwork::setDestination(const in_addr& address, unsigned int port)
{ {
m_address = address; m_address = address;
m_port = port; m_port = port;
} }
void CNetwork::clearDestination() void CYSFNetwork::clearDestination()
{ {
m_address.s_addr = INADDR_NONE; m_address.s_addr = INADDR_NONE;
m_port = 0U; m_port = 0U;
} }
bool CNetwork::write(const unsigned char* data) bool CYSFNetwork::write(const unsigned char* data)
{ {
assert(data != NULL); assert(data != NULL);
@ -112,7 +112,7 @@ bool CNetwork::write(const unsigned char* data)
return m_socket.write(data, 155U, m_address, m_port); return m_socket.write(data, 155U, m_address, m_port);
} }
bool CNetwork::writePoll() bool CYSFNetwork::writePoll()
{ {
if (m_port == 0U) if (m_port == 0U)
return true; return true;
@ -120,7 +120,7 @@ bool CNetwork::writePoll()
return m_socket.write(m_poll, 14U, m_address, m_port); return m_socket.write(m_poll, 14U, m_address, m_port);
} }
bool CNetwork::writeUnlink() bool CYSFNetwork::writeUnlink()
{ {
if (m_port == 0U) if (m_port == 0U)
return true; return true;
@ -128,7 +128,7 @@ bool CNetwork::writeUnlink()
return m_socket.write(m_unlink, 14U, m_address, m_port); return m_socket.write(m_unlink, 14U, m_address, m_port);
} }
void CNetwork::clock(unsigned int ms) void CYSFNetwork::clock(unsigned int ms)
{ {
if (m_port == 0U) if (m_port == 0U)
return; return;
@ -153,7 +153,7 @@ void CNetwork::clock(unsigned int ms)
m_buffer.addData(buffer, length); m_buffer.addData(buffer, length);
} }
unsigned int CNetwork::read(unsigned char* data) unsigned int CYSFNetwork::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != NULL);
@ -168,7 +168,7 @@ unsigned int CNetwork::read(unsigned char* data)
return len; return len;
} }
void CNetwork::close() void CYSFNetwork::close()
{ {
m_socket.close(); m_socket.close();

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef Network_H #ifndef YSFNetwork_H
#define Network_H #define YSFNetwork_H
#include "YSFDefines.h" #include "YSFDefines.h"
#include "UDPSocket.h" #include "UDPSocket.h"
@ -26,11 +26,11 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
class CNetwork { class CYSFNetwork {
public: public:
CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug);
CNetwork(unsigned int port, const std::string& callsign, bool debug); CYSFNetwork(unsigned int port, const std::string& callsign, bool debug);
~CNetwork(); ~CYSFNetwork();
bool open(); bool open();

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "Reflectors.h" #include "YSFReflectors.h"
#include "Log.h" #include "Log.h"
#include <algorithm> #include <algorithm>
@ -26,7 +26,7 @@
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
CReflectors::CReflectors(const std::string& hostsFile, unsigned int reloadTime) : CYSFReflectors::CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime) :
m_hostsFile(hostsFile), m_hostsFile(hostsFile),
m_parrotAddress(), m_parrotAddress(),
m_parrotPort(0U), m_parrotPort(0U),
@ -39,7 +39,7 @@ m_timer(1000U, reloadTime * 60U)
m_timer.start(); m_timer.start();
} }
CReflectors::~CReflectors() CYSFReflectors::~CYSFReflectors()
{ {
for (std::vector<CYSFReflector*>::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) for (std::vector<CYSFReflector*>::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it)
delete *it; delete *it;
@ -68,19 +68,19 @@ static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2)
return false; return false;
} }
void CReflectors::setParrot(const std::string& address, unsigned int port) void CYSFReflectors::setParrot(const std::string& address, unsigned int port)
{ {
m_parrotAddress = address; m_parrotAddress = address;
m_parrotPort = port; m_parrotPort = port;
} }
void CReflectors::setYSF2DMR(const std::string& address, unsigned int port) void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned int port)
{ {
m_YSF2DMRAddress = address; m_YSF2DMRAddress = address;
m_YSF2DMRPort = port; m_YSF2DMRPort = port;
} }
bool CReflectors::load() bool CYSFReflectors::load()
{ {
for (std::vector<CYSFReflector*>::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) for (std::vector<CYSFReflector*>::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it)
delete *it; delete *it;
@ -163,24 +163,24 @@ bool CReflectors::load()
return true; return true;
} }
CYSFReflector* CReflectors::find(const std::string& id) CYSFReflector* CYSFReflectors::find(const std::string& id)
{ {
for (std::vector<CYSFReflector*>::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) { for (std::vector<CYSFReflector*>::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) {
if (id == (*it)->m_id) if (id == (*it)->m_id)
return *it; return *it;
} }
LogMessage("Trying to find non existent reflector with an id of %s", id.c_str()); LogMessage("Trying to find non existent YSF reflector with an id of %s", id.c_str());
return NULL; return NULL;
} }
std::vector<CYSFReflector*>& CReflectors::current() std::vector<CYSFReflector*>& CYSFReflectors::current()
{ {
return m_currReflectors; return m_currReflectors;
} }
std::vector<CYSFReflector*>& CReflectors::search(const std::string& name) std::vector<CYSFReflector*>& CYSFReflectors::search(const std::string& name)
{ {
m_search.clear(); m_search.clear();
@ -204,7 +204,7 @@ std::vector<CYSFReflector*>& CReflectors::search(const std::string& name)
return m_search; return m_search;
} }
bool CReflectors::reload() bool CYSFReflectors::reload()
{ {
if (m_newReflectors.empty()) if (m_newReflectors.empty())
return false; return false;
@ -221,7 +221,7 @@ bool CReflectors::reload()
return true; return true;
} }
void CReflectors::clock(unsigned int ms) void CYSFReflectors::clock(unsigned int ms)
{ {
m_timer.clock(ms); m_timer.clock(ms);

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(Reflectors_H) #if !defined(YSFReflectors_H)
#define Reflectors_H #define YSFReflectors_H
#include "UDPSocket.h" #include "UDPSocket.h"
#include "Timer.h" #include "Timer.h"
@ -45,10 +45,10 @@ public:
unsigned int m_port; unsigned int m_port;
}; };
class CReflectors { class CYSFReflectors {
public: public:
CReflectors(const std::string& hostsFile, unsigned int reloadTime); CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime);
~CReflectors(); ~CYSFReflectors();
void setParrot(const std::string& address, unsigned int port); void setParrot(const std::string& address, unsigned int port);
void setYSF2DMR(const std::string& address, unsigned int port); void setYSF2DMR(const std::string& address, unsigned int port);
Loading…
Cancel
Save