1
0
Fork 0

Fix networking issues.

ycs232-kbc
Jonathan Naylor 4 years ago
parent 2201b07a38
commit e7503907df

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2014,2016,2017,2018 by Jonathan Naylor G4KLX * Copyright (C) 2009-2014,2016,2017,2018,2020 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
@ -85,7 +85,7 @@ bool CFCSNetwork::open()
LogMessage("Opening FCS network connection"); LogMessage("Opening FCS network connection");
return m_socket.open(); return m_socket.open(addr);
} }
void CFCSNetwork::clearDestination() void CFCSNetwork::clearDestination()
@ -128,7 +128,7 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
LogWarning("Unknown FCS reflector - %s", name.c_str()); LogWarning("Unknown FCS reflector - %s", name.c_str());
return false; return false;
} }
} else { } else {
std::pair<sockaddr_storage, unsigned int> entry = m_addresses[name]; std::pair<sockaddr_storage, unsigned int> entry = m_addresses[name];
m_addr = entry.first; m_addr = entry.first;
m_addrLen = entry.second; m_addrLen = entry.second;

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20201101"; const char* VERSION = "20201104";
#endif #endif

@ -203,9 +203,7 @@ int CYSFGateway::run()
unsigned int myPort = m_conf.getMyPort(); unsigned int myPort = m_conf.getMyPort();
CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug);
rptNetwork.setDestination("MMDVM", rptAddr, rptAddrLen); ret = rptNetwork.setDestination("MMDVM", rptAddr, rptAddrLen);
ret = rptNetwork.open();
if (!ret) { if (!ret) {
::LogError("Cannot open the repeater network port"); ::LogError("Cannot open the repeater network port");
::LogFinalise(); ::LogFinalise();
@ -215,14 +213,7 @@ int CYSFGateway::run()
bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled();
if (ysfNetworkEnabled) { if (ysfNetworkEnabled) {
unsigned int ysfPort = m_conf.getYSFNetworkPort(); unsigned int ysfPort = m_conf.getYSFNetworkPort();
m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug);
ret = m_ysfNetwork->open();
if (!ret) {
::LogError("Cannot open the YSF reflector network port");
::LogFinalise();
return 1;
}
} }
m_fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); m_fcsNetworkEnabled = m_conf.getFCSNetworkEnabled();
@ -431,7 +422,7 @@ int CYSFGateway::run()
CThread::sleep(5U); CThread::sleep(5U);
} }
rptNetwork.close(); rptNetwork.clearDestination();
if (m_gps != NULL) { if (m_gps != NULL) {
m_writer->close(); m_writer->close();
@ -440,7 +431,7 @@ int CYSFGateway::run()
} }
if (m_ysfNetwork != NULL) { if (m_ysfNetwork != NULL) {
m_ysfNetwork->close(); m_ysfNetwork->clearDestination();
delete m_ysfNetwork; delete m_ysfNetwork;
} }

@ -112,12 +112,14 @@ bool CYSFNetwork::open()
return m_socket.open(m_addr); return m_socket.open(m_addr);
} }
void CYSFNetwork::setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen) bool CYSFNetwork::setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen)
{ {
m_name = name; m_name = name;
m_addr = addr; m_addr = addr;
m_addrLen = addrLen; m_addrLen = addrLen;
m_linked = false; m_linked = false;
return open();
} }
void CYSFNetwork::clearDestination() void CYSFNetwork::clearDestination()
@ -126,6 +128,8 @@ void CYSFNetwork::clearDestination()
m_linked = false; m_linked = false;
m_pollTimer.stop(); m_pollTimer.stop();
close();
} }
void CYSFNetwork::write(const unsigned char* data) void CYSFNetwork::write(const unsigned char* data)

@ -33,9 +33,7 @@ public:
CYSFNetwork(unsigned int port, const std::string& callsign, bool debug); CYSFNetwork(unsigned int port, const std::string& callsign, bool debug);
~CYSFNetwork(); ~CYSFNetwork();
bool open(); bool setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen);
void setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen);
void clearDestination(); void clearDestination();
void write(const unsigned char* data); void write(const unsigned char* data);
@ -48,8 +46,6 @@ public:
void clock(unsigned int ms); void clock(unsigned int ms);
void close();
private: private:
CUDPSocket m_socket; CUDPSocket m_socket;
bool m_debug; bool m_debug;
@ -63,6 +59,9 @@ private:
CTimer m_pollTimer; CTimer m_pollTimer;
std::string m_name; std::string m_name;
bool m_linked; bool m_linked;
bool open();
void close();
}; };
#endif #endif

Loading…
Cancel
Save