|
|
@ -34,6 +34,7 @@ m_socket(port),
|
|
|
|
m_debug(debug),
|
|
|
|
m_debug(debug),
|
|
|
|
m_address(),
|
|
|
|
m_address(),
|
|
|
|
m_ping(NULL),
|
|
|
|
m_ping(NULL),
|
|
|
|
|
|
|
|
m_options(NULL),
|
|
|
|
m_info(NULL),
|
|
|
|
m_info(NULL),
|
|
|
|
m_reflector(),
|
|
|
|
m_reflector(),
|
|
|
|
m_print(),
|
|
|
|
m_print(),
|
|
|
@ -52,18 +53,25 @@ m_state(FCS_UNLINKED)
|
|
|
|
::memset(m_ping + 4U, ' ', 6U);
|
|
|
|
::memset(m_ping + 4U, ' ', 6U);
|
|
|
|
::memcpy(m_ping + 4U, callsign.c_str(), callsign.size());
|
|
|
|
::memcpy(m_ping + 4U, callsign.c_str(), callsign.size());
|
|
|
|
::memset(m_ping + 10U, 0x00U, 15U);
|
|
|
|
::memset(m_ping + 10U, 0x00U, 15U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_options = new unsigned char[50U];
|
|
|
|
|
|
|
|
::memcpy(m_options + 0U, "FCSO", 4U);
|
|
|
|
|
|
|
|
::memset(m_options + 4U, ' ', 46U);
|
|
|
|
|
|
|
|
::memcpy(m_options + 4U, callsign.c_str(), callsign.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CFCSNetwork::~CFCSNetwork()
|
|
|
|
CFCSNetwork::~CFCSNetwork()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete[] m_info;
|
|
|
|
delete[] m_info;
|
|
|
|
delete[] m_ping;
|
|
|
|
delete[] m_ping;
|
|
|
|
|
|
|
|
delete[] m_options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CFCSNetwork::open()
|
|
|
|
bool CFCSNetwork::open()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LogMessage("Resolving FCS00x addresses");
|
|
|
|
LogMessage("Resolving FCS00x addresses");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* OE1KBC not needed see ::writeLink
|
|
|
|
m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net");
|
|
|
|
m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net");
|
|
|
|
m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net");
|
|
|
|
m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net");
|
|
|
|
m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net");
|
|
|
|
m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net");
|
|
|
@ -74,7 +82,9 @@ bool CFCSNetwork::open()
|
|
|
|
m_addresses["FCS232"] = CUDPSocket::lookup("fcs232.xreflector.net");
|
|
|
|
m_addresses["FCS232"] = CUDPSocket::lookup("fcs232.xreflector.net");
|
|
|
|
m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net");
|
|
|
|
m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net");
|
|
|
|
m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net");
|
|
|
|
m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net");
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// OE1KBC 2020-09-04
|
|
|
|
|
|
|
|
m_addresses["FCS999"] = CUDPSocket::lookup("fcs999.xreflector.net");
|
|
|
|
|
|
|
|
|
|
|
|
LogMessage("Opening FCS network connection");
|
|
|
|
LogMessage("Opening FCS network connection");
|
|
|
|
|
|
|
|
|
|
|
@ -111,12 +121,28 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_state != FCS_LINKED) {
|
|
|
|
if (m_state != FCS_LINKED) {
|
|
|
|
std::string name = reflector.substr(0U, 6U);
|
|
|
|
std::string name = reflector.substr(0U, 6U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// OE1KBC 2020-09-04
|
|
|
|
if (m_addresses.count(name) == 0U) {
|
|
|
|
if (m_addresses.count(name) == 0U) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char fcs_url[30U];
|
|
|
|
|
|
|
|
::sprintf(fcs_url, "%s.xreflector.net", name.c_str());
|
|
|
|
|
|
|
|
m_address = CUDPSocket::lookup(fcs_url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(m_address.s_addr == INADDR_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
LogError("Unknown FCS reflector - %s", name.c_str());
|
|
|
|
LogError("Unknown FCS reflector - %s", name.c_str());
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
m_address = m_addresses[name];
|
|
|
|
m_address = m_addresses[name];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_address.s_addr == INADDR_NONE) {
|
|
|
|
if (m_address.s_addr == INADDR_NONE) {
|
|
|
|
LogError("FCS reflector %s has no address", name.c_str());
|
|
|
|
LogError("FCS reflector %s has no address", name.c_str());
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -137,6 +163,11 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CFCSNetwork::setOptions(const std::string& options)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_opt = options;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CFCSNetwork::writeUnlink(unsigned int count)
|
|
|
|
void CFCSNetwork::writeUnlink(unsigned int count)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_state != FCS_LINKED)
|
|
|
|
if (m_state != FCS_LINKED)
|
|
|
@ -182,12 +213,14 @@ void CFCSNetwork::clock(unsigned int ms)
|
|
|
|
LogMessage("Linked to %s", m_print.c_str());
|
|
|
|
LogMessage("Linked to %s", m_print.c_str());
|
|
|
|
m_state = FCS_LINKED;
|
|
|
|
m_state = FCS_LINKED;
|
|
|
|
writeInfo();
|
|
|
|
writeInfo();
|
|
|
|
|
|
|
|
writeOptions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (length == 10 && m_state == FCS_LINKING) {
|
|
|
|
if (length == 10 && m_state == FCS_LINKING) {
|
|
|
|
LogMessage("Linked to %s", m_print.c_str());
|
|
|
|
LogMessage("Linked to %s", m_print.c_str());
|
|
|
|
m_state = FCS_LINKED;
|
|
|
|
m_state = FCS_LINKED;
|
|
|
|
writeInfo();
|
|
|
|
writeInfo();
|
|
|
|
|
|
|
|
writeOptions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (length == 7 || length == 10 || length == 130) {
|
|
|
|
if (length == 7 || length == 10 || length == 130) {
|
|
|
@ -264,3 +297,20 @@ void CFCSNetwork::writePing()
|
|
|
|
|
|
|
|
|
|
|
|
m_socket.write(m_ping, 25U, m_address, FCS_PORT);
|
|
|
|
m_socket.write(m_ping, 25U, m_address, FCS_PORT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CFCSNetwork::writeOptions()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_state != FCS_LINKED)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_opt.size() < 1)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::memset(m_options + 14U, 0x20U, 36U);
|
|
|
|
|
|
|
|
::memcpy(m_options + 14U, m_opt.c_str(), m_opt.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_debug)
|
|
|
|
|
|
|
|
CUtils::dump(1U, "FCS Network Options Sent", m_options, 50U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_socket.write(m_options, 50U, m_address, FCS_PORT);
|
|
|
|
|
|
|
|
}
|
|
|
|