예제 #1
0
void CG2Handler::process(CAMBEData& data)
{
	// Check to see if this is for StarNet
	CStarNetHandler* handler = CStarNetHandler::findStarNet(data);
	if (handler != NULL) {
		handler->process(data);
		return;
	}

	// No need to go any further
	if (m_maxRoutes == 0U)
		return;

	unsigned int id = data.getId();

	for (unsigned int i = 0U; i < m_maxRoutes; i++) {
		CG2Handler* route = m_routes[i];
		if (route != NULL) {
			if (route->m_id == id) {
				route->m_inactivityTimer.reset();
				route->m_repeater->process(data, DIR_INCOMING, AS_G2);

				if (data.isEnd()) {
					delete route;
					m_routes[i] = NULL;
				}

				return;
			}
		}
	}	
}
예제 #2
0
void CDExtraHandler::processInt(CAMBEData& data)
{
	if (m_linkState != DEXTRA_LINKED)
		return;

	if (m_dExtraId != data.getId())
		return;

	m_inactivityTimer.reset();

	m_dExtraSeq = data.getSeq();

	// Send the header every 21 frames
	if (m_dExtraSeq == 0U)
		m_destination->process(*m_header, AS_DUP);

	// Copy the data to ensure it remains unchanged
	CAMBEData temp(data);

	m_destination->process(temp, AS_DEXTRA);

	if (temp.isEnd()) {
		delete m_header;
		m_header = NULL;

		m_dExtraId  = 0x00U;
		m_dExtraSeq = 0x00U;

		m_inactivityTimer.stop();
	}
}
예제 #3
0
void CDPlusHandler::writeAMBEInt(CAMBEData& data, DIRECTION direction)
{
	if (m_linkState != DPLUS_LINKED)
		return;

	if (direction != m_direction)
		return;

	// Already in use?
	if (m_dPlusId != 0x00U)
		return;

	switch (m_direction) {
		case DIR_OUTGOING:
			if (data.getId() == m_rptrId) {
				data.setDestination(m_yourAddress, m_yourPort);
				m_handler->writeAMBE(data);

				if (data.isEnd())
					m_rptrId = 0x00U;
			}
			break;

		case DIR_INCOMING:
			data.setDestination(m_yourAddress, m_yourPort);
			m_handler->writeAMBE(data);
			break;
	}
}
예제 #4
0
void CDPlusHandler::processInt(CAMBEData& data)
{
	unsigned int id = data.getId();

	if (m_dPlusId != id)
		return;

	m_dPlusSeq = data.getSeq();

	// Send the header every 21 frames
	if (m_dPlusSeq == 0U)
		m_destination->process(*m_header, AS_DUP);

	m_inactivityTimer.reset();
	m_pollInactivityTimer.reset();

	m_destination->process(data, AS_DPLUS);

	if (data.isEnd()) {
		m_dPlusId  = 0x00U;
		m_dPlusSeq = 0x00U;

		delete m_header;
		m_header = NULL;

		m_inactivityTimer.stop();
	}
}
예제 #5
0
void CXReflectorDPlusHandler::processInt(CAMBEData& data)
{
    unsigned int id = data.getId();

    if (m_dPlusId == id) {
        m_inactivityTimer.reset();
        m_pollInactivityTimer.reset();
        m_destination->process(m_dPlusId, data);

        if (data.isEnd()) {
            m_dPlusId = 0x00;
            m_inactivityTimer.stop();
        }
    }
}
예제 #6
0
void CCCSHandler::process(CAMBEData& data)
{
	CHeaderData& header = data.getHeader();
	unsigned int seqNo = data.getSeq();
	unsigned int id = data.getId();

	if (m_state != CS_CONNECTED && m_state != CS_ACTIVE)
		return;

	// This is a new incoming CCS call
	if (m_state == CS_CONNECTED) {
		m_yourCall    = header.getMyCall1();
		m_local       = header.getYourCall();
		m_direction   = DIR_INCOMING;
		m_time        = ::time(NULL);
		m_state       = CS_ACTIVE;
		m_stateChange = true;
		m_inactivityTimer.start();

		m_handler->ccsLinkMade(m_yourCall);

		wxLogMessage(wxT("CCS: New incoming link to %s from %s"), m_local.c_str(), m_yourCall.c_str());
	}

	m_pollInactivityTimer.reset();
	m_inactivityTimer.reset();

	if (m_id != id) {
		// Write to Header.log if it's enabled
		if (m_headerLogger != NULL)
			m_headerLogger->write(wxT("CCS"), header);

		header.setCQCQCQ();
		m_handler->process(header, DIR_INCOMING, AS_CCS);

		m_id = id;
	} else if (seqNo == 0U) {
		header.setCQCQCQ();
		m_handler->process(header, DIR_INCOMING, AS_DUP);
	}

	m_handler->process(data, DIR_INCOMING, AS_CCS);
}
bool CStarNetHandler::process(CAMBEData &data, AUDIO_SOURCE source)
{
	unsigned int id = data.getId();
	if (id != m_id)
		return false;

	m_linkTimer.reset();

	sendToRepeaters(data);

	if (data.isEnd()) {
		m_linkTimer.stop();
		m_id = 0x00U;

		// Clear the repeater list
		for (CStarNetRepeatersHashMap::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it)
			delete it->second;
		m_repeaters.clear();
	}

	return true;
}
예제 #8
0
void CDExtraHandler::writeAMBEInt(CAMBEData& data, DIRECTION direction)
{
	if (m_linkState != DEXTRA_LINKED)
		return;

	// Is it link in the right direction
	if (m_direction != direction)
		return;

	// If the ids don't match, reject
	if (data.getId() != m_rptrId)
		return;

	// Already in use?
	if (m_dExtraId != 0x00)
		return;

	data.setDestination(m_address, m_port);
	m_handler->writeAMBE(data);

	if (data.isEnd())
		m_rptrId = 0x00;
}
void CStarNetHandler::process(CAMBEData &data)
{
	unsigned int id = data.getId();

	CStarNetId* tx = m_ids[id];
	if (tx == NULL)
		return;

	tx->reset();

	CStarNetUser* user = tx->getUser();
	user->reset();

	m_groupTimer.reset();

	// If we've just logged in, the LOGOFF and INFO commands are disabled
	if (!tx->isLogin()) {
		// If we've already found some slow data, then don't look again
		if (!tx->isLogoff() && !tx->isInfo()) {
			tx->getTextCollector().writeData(data);
			bool hasText = tx->getTextCollector().hasData();
			if (hasText) {
				wxString text = tx->getTextCollector().getData();

				if (text.Left(6U).IsSameAs(wxT("LOGOFF"), false)) {
					if (m_logFile != NULL) {
						time_t timeNow = ::time(NULL);
						struct tm* tm = ::gmtime(&timeNow);

						wxString text;
						text.Printf(wxT("%04d-%02d-%02d %02d:%02d:%02d: Removing %s from StarNet group %s, logged off\n"),
							tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
							user->getCallsign().c_str(), m_groupCallsign.c_str());

						m_logFile->Write(text);
						m_logFile->Flush();
					}

					tx->setLogoff();

					// Ensure that this user is in the cache in time for the logoff ack
					CUserData* cacheUser = m_cache->findUser(user->getCallsign());
					if (cacheUser == NULL)
						m_irc->findUser(user->getCallsign());

					delete cacheUser;
					cacheUser = NULL;
				}

				if (text.Left(4U).IsSameAs(wxT("INFO"), false)) {
					tx->setInfo();

					// Ensure that this user is in the cache in time for the info text
					CUserData* cacheUser = m_cache->findUser(user->getCallsign());
					if (cacheUser == NULL)
						m_irc->findUser(user->getCallsign());

					delete cacheUser;
					cacheUser = NULL;
				}
			}
		}
	}

	if (id == m_id) {
#if defined(DEXTRA_LINK)
		CDExtraHandler::writeAMBE(this, data, DIR_OUTGOING);
#endif
#if defined(DCS_LINK)
		CDCSHandler::writeAMBE(this, data, DIR_OUTGOING);
#endif
		sendToRepeaters(data);
	}

	if (data.isEnd()) {
		if (id == m_id) {
			// Clear the repeater list if we're the relayed id
			for (CStarNetRepeatersHashMap::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it)
				delete it->second;
			m_repeaters.clear();
			m_id = 0x00U;
		}

		if (tx->isLogin()) {
			tx->reset();
			tx->setEnd();
		} else if (tx->isLogoff()) {
			m_users.erase(user->getCallsign());
			tx->reset();
			tx->setEnd();
		} else if (tx->isInfo()) {
			tx->reset();
			tx->setEnd();
		} else {
			m_ids.erase(tx->getId());
			delete tx;
		}
	}
}