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
* 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");
return m_socket.open();
return m_socket.open(addr);
}
void CFCSNetwork::clearDestination()
@ -128,7 +128,7 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
LogWarning("Unknown FCS reflector - %s", name.c_str());
return false;
}
} else {
} else {
std::pair<sockaddr_storage, unsigned int> entry = m_addresses[name];
m_addr = entry.first;
m_addrLen = entry.second;

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

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

@ -112,12 +112,14 @@ bool CYSFNetwork::open()
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_addr = addr;
m_addrLen = addrLen;
m_linked = false;
return open();
}
void CYSFNetwork::clearDestination()
@ -126,6 +128,8 @@ void CYSFNetwork::clearDestination()
m_linked = false;
m_pollTimer.stop();
close();
}
void CYSFNetwork::write(const unsigned char* data)

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

Loading…
Cancel
Save