void CXReflectorDPlusHandler::process(CConnectData& connect) { CD_TYPE type = connect.getType(); in_addr address = connect.getYourAddress(); for (unsigned int i = 0U; i < m_maxReflectors; i++) { CXReflectorDPlusHandler* reflector = m_reflectors[i]; if (reflector != NULL) { if (reflector->m_address.s_addr == address.s_addr) { bool res = m_reflectors[i]->processInt(connect, type); if (res) { delete m_reflectors[i]; m_reflectors[i] = NULL; } } } } unsigned int port = connect.getYourPort(); // Check that it isn't a duplicate 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) return; } } if (type == CT_UNLINK) return; if (type != CT_LINK1) { wxLogMessage(wxT("Incoming D-Plus message from unknown source")); return; } CXReflectorDPlusHandler* dplus = new CXReflectorDPlusHandler(address, port); bool found = false; for (unsigned int i = 0U; i < m_maxReflectors; i++) { if (m_reflectors[i] == NULL) { m_reflectors[i] = dplus; found = true; break; } } if (found) { CConnectData connect(CT_LINK1, address, port, 0U); m_handler->writeConnect(connect); } else { wxLogError(wxT("No space to add new D-Plus dongle, ignoring")); delete dplus; } }
void CCCSHandler::process(CConnectData& connect) { CD_TYPE type = connect.getType(); if (type == CT_ACK && m_state == CS_CONNECTING) { wxLogMessage(wxT("CCS: %s connected to server %s"), m_callsign.c_str(), m_ccsHost.c_str()); m_announceTimer.start(); m_pollInactivityTimer.start(); m_pollTimer.start(); m_tryTimer.stop(); m_state = CS_CONNECTED; return; } if (type == CT_NAK && m_state == CS_CONNECTING) { wxLogMessage(wxT("CCS: Connection refused for %s"), m_callsign.c_str()); m_tryTimer.stop(); m_state = CS_DISABLED; return; } }
void CDExtraHandler::process(CConnectData& connect) { CD_TYPE type = connect.getType(); if (type == CT_ACK || type == CT_NAK || type == CT_UNLINK) { for (unsigned int i = 0U; i < m_maxReflectors; i++) { if (m_reflectors[i] != NULL) { bool res = m_reflectors[i]->processInt(connect, type); if (res) { delete m_reflectors[i]; m_reflectors[i] = NULL; } } } return; } // else if type == CT_LINK1 or type == CT_LINK2 in_addr address = connect.getAddress(); unsigned int port = connect.getPort(); wxString repeaterCallsign = connect.getRepeater(); wxChar band = connect.getReflector().GetChar(LONG_CALLSIGN_LENGTH - 1U); wxString reflectorCallsign = m_callsign; reflectorCallsign.SetChar(LONG_CALLSIGN_LENGTH - 1U, band); // Check that it isn't a duplicate for (unsigned int i = 0U; i < m_maxReflectors; i++) { if (m_reflectors[i] != NULL) { if (m_reflectors[i]->m_direction == DIR_INCOMING && m_reflectors[i]->m_address.s_addr == address.s_addr && m_reflectors[i]->m_port == port && m_reflectors[i]->m_repeater.IsSameAs(reflectorCallsign) && m_reflectors[i]->m_reflector.IsSameAs(repeaterCallsign)) return; } } // Check the validity of our repeater callsign IReflectorCallback* handler = CRepeaterHandler::findDVRepeater(reflectorCallsign); if (handler == NULL) { wxLogMessage(wxT("DExtra connect to unknown reflector %s from %s"), reflectorCallsign.c_str(), repeaterCallsign.c_str()); CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, connect.getAddress(), connect.getPort()); m_handler->writeConnect(reply); return; } // A new connect packet indicates the need for a new entry wxLogMessage(wxT("New incoming DExtra link to %s from %s"), reflectorCallsign.c_str(), repeaterCallsign.c_str()); CDExtraHandler* dextra = new CDExtraHandler(handler, repeaterCallsign, reflectorCallsign, address, port, DIR_INCOMING); bool found = false; for (unsigned int i = 0U; i < m_maxReflectors; i++) { if (m_reflectors[i] == NULL) { m_reflectors[i] = dextra; found = true; break; } } if (found) { CConnectData reply(repeaterCallsign, reflectorCallsign, CT_ACK, address, port); m_handler->writeConnect(reply); wxString callsign = repeaterCallsign; callsign.SetChar(LONG_CALLSIGN_LENGTH - 1U, wxT(' ')); CPollData poll(callsign, wxEmptyString, address, port); m_handler->writePoll(poll); } else { CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, address, port); m_handler->writeConnect(reply); wxLogError(wxT("No space to add new DExtra repeater, ignoring")); delete dextra; } }
void CDPlusHandler::process(CConnectData& connect) { CD_TYPE type = connect.getType(); in_addr yourAddress = connect.getYourAddress(); unsigned int yourPort = connect.getYourPort(); unsigned int myPort = connect.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) { bool res = m_reflectors[i]->processInt(connect, type); if (res) { delete m_reflectors[i]; m_reflectors[i] = NULL; } } } } // Check that it isn't a duplicate 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) return; } } if (type == CT_UNLINK) return; if (type != CT_LINK1) { wxLogMessage(wxT("Incoming D-Plus message from unknown source")); 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) count++; } if (count >= m_maxDongles) return; CDPlusHandler* dplus = new CDPlusHandler(m_incoming, yourAddress, yourPort); bool found = false; for (unsigned int i = 0U; i < m_maxReflectors; i++) { if (m_reflectors[i] == NULL) { m_reflectors[i] = dplus; found = true; break; } } if (found) { CConnectData connect(CT_LINK1, yourAddress, yourPort); m_incoming->writeConnect(connect); } else { wxLogError(wxT("No space to add new D-Plus dongle, ignoring")); delete dplus; } }