Ejemplo n.º 1
0
bool CCCSProtocolHandler::writePoll(const CPollData& poll)
{
	unsigned char buffer[30U];
	unsigned int length = poll.getCCSData(buffer, 30U);

#if defined(DUMP_TX)
	CUtils::dump(wxT("Sending Poll"), buffer, length);
#endif

	return m_socket.write(buffer, length, poll.getYourAddress(), poll.getYourPort());
}
Ejemplo n.º 2
0
CPollData* CCCSProtocolHandler::readPoll()
{
	if (m_type != CT_POLL)
		return NULL;

	CPollData* poll = new CPollData;

	bool res = poll->setCCSData(m_buffer, m_length, m_yourAddress, m_yourPort, m_myPort);
	if (!res) {
		delete poll;
		return NULL;
	}

	return poll;
}
Ejemplo n.º 3
0
void CDPlusHandler::process(const CPollData& poll)
{
	in_addr   yourAddress = poll.getYourAddress();
	unsigned int yourPort = poll.getYourPort();
	unsigned int   myPort = poll.getMyPort();

	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		CDPlusHandler* reflector = m_reflectors[i];

		if (reflector != NULL) {
			if (reflector->m_yourAddress.s_addr == yourAddress.s_addr &&
				reflector->m_yourPort           == yourPort &&
				reflector->m_myPort             == myPort) {
				reflector->m_pollInactivityTimer.reset();
				return;
			}
		}
	}	

	// If we cannot find an existing link, we ignore the poll
	wxLogMessage(wxT("Incoming poll from unknown D-Plus dongle"));
}
Ejemplo n.º 4
0
void CDPlusHandler::process(const CPollData& poll)
{
    in_addr address = poll.getAddress();

    for (unsigned int i = 0U; i < m_maxReflectors; i++) {
        if (m_reflectors[i] != NULL) {
            if (m_reflectors[i]->m_address.s_addr == address.s_addr) {
                m_reflectors[i]->m_pollInactivityTimer.reset();
                return;
            }
        }
    }

    // If we cannot find an existing link, we ignore the poll
    wxLogMessage(wxT("Incoming poll from unknown D-Plus dongle"));
}
Ejemplo n.º 5
0
void CDExtraHandler::process(const CPollData& poll)
{
	bool found = false;

	wxString reflector = poll.getData1();
	in_addr  address   = poll.getAddress();
	unsigned int port  = poll.getPort();

	// Check to see if we already have a link
	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		if (m_reflectors[i] != NULL) {
			if (m_reflectors[i]->m_reflector.Left(LONG_CALLSIGN_LENGTH - 1U).IsSameAs(reflector.Left(LONG_CALLSIGN_LENGTH - 1U)) &&
				m_reflectors[i]->m_address.s_addr == address.s_addr && m_reflectors[i]->m_port == port && m_reflectors[i]->m_linkState == DEXTRA_LINKED) {
				m_reflectors[i]->m_pollInactivityTimer.reset();
				found = true;
			}
		}
	}	

	if (found)
		return;

	// A repeater poll arriving here is an error
	if (!poll.isDongle())
		return;

	// Check to see if we are allowed to accept it
	unsigned int count = 0U;
	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		if (m_reflectors[i] != NULL &&
			m_reflectors[i]->m_direction == DIR_INCOMING &&
			m_reflectors[i]->m_repeater.IsEmpty())
			count++;
	}

	if (count >= m_maxDongles)
		return;

	// An unmatched poll indicates the need for a new entry
	wxLogMessage(wxT("New incoming DExtra Dongle from %s"), reflector.c_str());

	CDExtraHandler* handler = new CDExtraHandler(reflector, address, port, DIR_INCOMING);

	found = false;

	for (unsigned int i = 0U; i < m_maxReflectors; i++) {
		if (m_reflectors[i] == NULL) {
			m_reflectors[i] = handler;
			found = true;
			break;
		}
	}

	if (found) {
		// Return the poll
		CPollData poll(m_callsign, wxEmptyString, address, port);
		m_handler->writePoll(poll);
	} else {
		wxLogError(wxT("No space to add new DExtra Dongle, ignoring"));
		delete handler;
	}
}