Merge branch 'master' into IPv6
This commit is contained in:
commit
bbe1a50745
4 changed files with 27 additions and 12 deletions
|
@ -34,6 +34,7 @@ m_addr(),
|
|||
m_addrLen(0U),
|
||||
m_poll(NULL),
|
||||
m_options(NULL),
|
||||
m_opt(),
|
||||
m_unlink(NULL),
|
||||
m_buffer(1000U, "YSF Network Buffer"),
|
||||
m_pollTimer(1000U, 5U),
|
||||
|
@ -66,6 +67,7 @@ m_addr(),
|
|||
m_addrLen(0U),
|
||||
m_poll(NULL),
|
||||
m_options(NULL),
|
||||
m_opt(),
|
||||
m_unlink(NULL),
|
||||
m_buffer(1000U, "YSF Network Buffer"),
|
||||
m_pollTimer(1000U, 5U),
|
||||
|
@ -94,6 +96,8 @@ m_linked(false)
|
|||
CYSFNetwork::~CYSFNetwork()
|
||||
{
|
||||
delete[] m_poll;
|
||||
delete[] m_unlink;
|
||||
delete[] m_options;
|
||||
}
|
||||
|
||||
bool CYSFNetwork::open()
|
||||
|
@ -147,21 +151,23 @@ void CYSFNetwork::writePoll(unsigned int count)
|
|||
for (unsigned int i = 0U; i < count; i++)
|
||||
m_socket.write(m_poll, 14U, m_addr, m_addrLen);
|
||||
|
||||
if (m_options != NULL)
|
||||
if (!m_opt.empty())
|
||||
m_socket.write(m_options, 50U, m_addr, m_addrLen);
|
||||
}
|
||||
|
||||
void CYSFNetwork::setOptions(const std::string& options)
|
||||
{
|
||||
std::string opt = options;
|
||||
|
||||
if (opt.size() < 1)
|
||||
if (options.empty()) {
|
||||
m_opt.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
opt.resize(50, ' ');
|
||||
m_opt = options;
|
||||
|
||||
for (unsigned int i = 0U; i < (50 - 4 - YSF_CALLSIGN_LENGTH); i++)
|
||||
m_options[i + 4U + YSF_CALLSIGN_LENGTH] = opt.at(i);
|
||||
m_opt.resize(50, ' ');
|
||||
|
||||
for (unsigned int i = 0U; i < (50U - 4U - YSF_CALLSIGN_LENGTH); i++)
|
||||
m_options[i + 4U + YSF_CALLSIGN_LENGTH] = m_opt.at(i);
|
||||
}
|
||||
|
||||
void CYSFNetwork::writeUnlink(unsigned int count)
|
||||
|
@ -204,7 +210,7 @@ void CYSFNetwork::clock(unsigned int ms)
|
|||
|
||||
m_linked = true;
|
||||
|
||||
if (m_options != NULL)
|
||||
if (!m_opt.empty())
|
||||
m_socket.write(m_options, 50U, m_addr, m_addrLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void write(const unsigned char* data);
|
||||
|
||||
void writePoll(unsigned int count = 1U);
|
||||
void setOptions(const std::string& options = NULL);
|
||||
void setOptions(const std::string& options = "");
|
||||
void writeUnlink(unsigned int count = 1U);
|
||||
|
||||
unsigned int read(unsigned char* data);
|
||||
|
@ -57,6 +57,7 @@ private:
|
|||
unsigned int m_addrLen;
|
||||
unsigned char* m_poll;
|
||||
unsigned char* m_options;
|
||||
std::string m_opt;
|
||||
unsigned char* m_unlink;
|
||||
CRingBuffer<unsigned char> m_buffer;
|
||||
CTimer m_pollTimer;
|
||||
|
|
|
@ -89,6 +89,10 @@ unsigned int CNetwork::read(unsigned char* data)
|
|||
return 0U;
|
||||
}
|
||||
|
||||
// Throw away incoming options messages
|
||||
if (::memcmp(data, "YSFO", 4U) == 0)
|
||||
return 0U;
|
||||
|
||||
// Handle incoming unlinks
|
||||
if (::memcmp(data, "YSFU", 4U) == 0)
|
||||
return 0U;
|
||||
|
|
|
@ -104,15 +104,19 @@ unsigned int CNetwork::readData(unsigned char* data, unsigned int length, sockad
|
|||
if (len <= 0)
|
||||
return 0U;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "YSF Network Data Received", data, len);
|
||||
|
||||
// Throw away any options messages
|
||||
if (::memcmp(data, "YSFO", 4U) == 0)
|
||||
return 0U;
|
||||
|
||||
// Handle incoming status requests
|
||||
if (::memcmp(data, "YSFS", 4U) == 0) {
|
||||
m_socket.write(m_status, 42U, addr, addrLen);
|
||||
return 0U;
|
||||
}
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "YSF Network Data Received", data, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue