Пример #1
0
void CHeaderLogger::write(const wxChar* type, const CDDData& data)
{
	wxASSERT(type != NULL);

	time_t timeNow = ::time(NULL);
	struct tm* tm = ::gmtime(&timeNow);

	wxString text;
	text.Printf(wxT("%04d-%02d-%02d %02d:%02d:%02d: %s header - My: %s/%s  Your: %s  Rpt1: %s  Rpt2: %s  Flags: %02X %02X %02X\n"),
		tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, type,
		data.getMyCall1().c_str(), data.getMyCall2().c_str(), data.getYourCall().c_str(),
		data.getRptCall1().c_str(), data.getRptCall2().c_str(), data.getFlag1(), data.getFlag2(),
		data.getFlag3());

	m_file.Write(text);
	m_file.Flush();
}
Пример #2
0
void CDDHandler::process(CDDData& data)
{
	// If we're not initialised, return immediately
	if (m_maxRoutes == 0U)
		return;

	unsigned char flag1 = data.getFlag1();
	unsigned char flag2 = data.getFlag2();
	unsigned char flag3 = data.getFlag3();
	wxString myCall1    = data.getMyCall1();
	wxString myCall2    = data.getMyCall2();
	wxString yourCall   = data.getYourCall();
	wxString rptCall1   = data.getRptCall1();
	wxString rptCall2   = data.getRptCall2();

	if (!m_timer.isRunning() || m_timer.hasExpired()) {
		// Write to Header.log if it's enabled
		if (m_headerLogger != NULL)
			m_headerLogger->write(wxT("Repeater"), data);

		m_irc->sendHeardWithTXMsg(myCall1, myCall2, yourCall, rptCall1, rptCall2, flag1, flag2, flag3, wxEmptyString, wxT("Digital Data        "));
		m_irc->sendHeardWithTXStats(myCall1, myCall2, yourCall, rptCall1, rptCall2, flag1, flag2, flag3, 1, 0, -1);
		m_timer.start();
	}

	// Can we continue?
	if (m_fd < 0)
		return;

	unsigned char* address = data.getSourceAddress();

	bool found = false;
	for (unsigned int i = 0U; i < m_maxRoutes; i++) {
		if (m_list[i] != NULL) {
			unsigned char* addr = m_list[i]->getAddress();

			if (::memcmp(addr, address, ETHERNET_ADDRESS_LENGTH) == 0) {
				found = true;
				break;
			}
		}
	}

	if (!found) {
		wxLogMessage(wxT("Adding DD user %s with ethernet address %02X:%02X:%02X:%02X:%02X:%02X"), myCall1.c_str(),
			address[0], address[1], address[2], address[3], address[4], address[5]);

		CEthernet* ethernet = new CEthernet(address, myCall1);

		bool found = false;
		for (unsigned int i = 0U; i < m_maxRoutes; i++) {
			if (m_list[i] == NULL) {
				m_list[i] = ethernet;
				found = true;
				break;
			}
		}

		if (!found) {
			wxLogError(wxT("No space to add new DD ethernet address"));
			delete ethernet;
			return;
		}
	}

	unsigned int length = data.getEthernetFrame(m_buffer, BUFFER_LENGTH);

#if !defined(WIN32)
	ssize_t len = ::write(m_fd, (char*)m_buffer, length);
	if (len != ssize_t(length))
		wxLogError(wxT("Error returned from write()"));
#endif
}