diff --git a/src/cclients.cpp b/src/cclients.cpp index efb029a..484100f 100644 --- a/src/cclients.cpp +++ b/src/cclients.cpp @@ -214,6 +214,25 @@ CClient *CClients::FindClient(const CCallsign &Callsign, char module, const CIp return client; } +CClient *CClients::FindClient(const CCallsign &Callsign, int Protocol) +{ + CClient *client = NULL; + + // find client + for ( int i = 0; (i < m_Clients.size()) && (client == NULL); i++ ) + { + if ( (m_Clients[i]->GetProtocol() == Protocol) && + m_Clients[i]->GetCallsign().HasSameCallsign(Callsign) ) + { + client = m_Clients[i]; + } + } + + // done + return client; +} + + //////////////////////////////////////////////////////////////////////////////////////// // iterate on clients diff --git a/src/cclients.h b/src/cclients.h index 66e6158..34cb42d 100644 --- a/src/cclients.h +++ b/src/cclients.h @@ -60,6 +60,7 @@ public: CClient *FindClient(const CIp &, int); CClient *FindClient(const CCallsign &, const CIp &, int); CClient *FindClient(const CCallsign &, char, const CIp &, int); + CClient *FindClient(const CCallsign &, int); // iterate on clients CClient *FindNextClient(int, int*); diff --git a/src/cdcsprotocol.cpp b/src/cdcsprotocol.cpp index c642e64..3c27def 100644 --- a/src/cdcsprotocol.cpp +++ b/src/cdcsprotocol.cpp @@ -147,7 +147,7 @@ void CDcsProtocol::Task(void) } else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) { - std::cout << "DCS disconnect packet from " << Ip << std::endl; + std::cout << "DCS disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client & remove it CClients *clients = g_Reflector.GetClients(); @@ -201,13 +201,14 @@ void CDcsProtocol::Task(void) bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) { bool newstream = false; - CCallsign via(Header->GetRpt1Callsign()); // find the stream CPacketStream *stream = GetStream(Header->GetStreamId()); if ( stream == NULL ) { // no stream open yet, open a new one + CCallsign via(Header->GetRpt1Callsign()); + // find this client CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DCS); if ( client != NULL ) @@ -224,6 +225,10 @@ bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) } // release g_Reflector.ReleaseClients(); + + // update last heard + g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); + g_Reflector.ReleaseUsers(); } else { @@ -234,10 +239,6 @@ bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) delete Header; } - // update last heard - g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); - g_Reflector.ReleaseUsers(); - // done return newstream; } diff --git a/src/cdextraprotocol.cpp b/src/cdextraprotocol.cpp index 6dbc074..d191e23 100644 --- a/src/cdextraprotocol.cpp +++ b/src/cdextraprotocol.cpp @@ -85,6 +85,7 @@ void CDextraProtocol::Task(void) else if ( (Header = IsValidDvHeaderPacket(Buffer)) != NULL ) { //std::cout << "DExtra DV header:" << std::endl << *Header << std::endl; + //std::cout << "DExtra DV header:" << std::endl; // callsign muted? if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA) ) @@ -135,7 +136,7 @@ void CDextraProtocol::Task(void) // find client & remove it CClients *clients = g_Reflector.GetClients(); - CClient *client = clients->FindClient(Callsign, Ip, PROTOCOL_DEXTRA); + CClient *client = clients->FindClient(Ip, PROTOCOL_DEXTRA); if ( client != NULL ) { // ack disconnect packet @@ -212,8 +213,11 @@ void CDextraProtocol::HandleQueue(void) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) { // no, send the packet - m_Socket.Send(buffer, client->GetIp()); - + int n = packet->IsDvHeader() ? 5 : 1; + for ( int i = 0; i < n; i++ ) + { + m_Socket.Send(buffer, client->GetIp()); + } } } g_Reflector.ReleaseClients(); @@ -275,13 +279,14 @@ void CDextraProtocol::HandleKeepalives(void) bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) { bool newstream = false; - CCallsign via(Header->GetRpt1Callsign()); // find the stream CPacketStream *stream = GetStream(Header->GetStreamId()); if ( stream == NULL ) { // no stream open yet, open a new one + CCallsign via(Header->GetRpt1Callsign()); + // find this client CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DEXTRA); if ( client != NULL ) @@ -298,18 +303,20 @@ bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) } // release g_Reflector.ReleaseClients(); + + // update last heard + g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); + g_Reflector.ReleaseUsers(); } else { // stream already open // skip packet, but tickle the stream stream->Tickle(); + // and delete packet + delete Header; } - // update last heard - g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); - g_Reflector.ReleaseUsers(); - // done return newstream; } diff --git a/src/cdplusprotocol.cpp b/src/cdplusprotocol.cpp index 3003f7b..869e284 100644 --- a/src/cdplusprotocol.cpp +++ b/src/cdplusprotocol.cpp @@ -194,14 +194,15 @@ void CDplusProtocol::Task(void) bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) { bool newstream = false; - CCallsign via(Header->GetRpt1Callsign()); // find the stream CPacketStream *stream = GetStream(Header->GetStreamId()); if ( stream == NULL ) { // no stream open yet, open a new one - // find this client + CCallsign via(Header->GetRpt1Callsign()); + + // find this client CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DPLUS); if ( client != NULL ) { @@ -222,6 +223,10 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) } // release g_Reflector.ReleaseClients(); + + // update last heard + g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); + g_Reflector.ReleaseUsers(); } else { @@ -232,10 +237,6 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) delete Header; } - // update last heard - g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); - g_Reflector.ReleaseUsers(); - // done return newstream; } diff --git a/src/cip.cpp b/src/cip.cpp index 10ac1ca..5cec9b5 100644 --- a/src/cip.cpp +++ b/src/cip.cpp @@ -79,7 +79,8 @@ void CIp::SetSockAddr(struct sockaddr_in *sa) bool CIp::operator ==(const CIp &ip) const { return ( (ip.m_Addr.sin_family == m_Addr.sin_family) && - (ip.m_Addr.sin_addr.s_addr == m_Addr.sin_addr.s_addr)) ; + (ip.m_Addr.sin_addr.s_addr == m_Addr.sin_addr.s_addr) && + (ip.m_Addr.sin_port == m_Addr.sin_port)) ; } CIp::operator const char *() const diff --git a/src/cxlxprotocol.cpp b/src/cxlxprotocol.cpp index 442907d..9643bdb 100644 --- a/src/cxlxprotocol.cpp +++ b/src/cxlxprotocol.cpp @@ -306,7 +306,7 @@ void CXlxProtocol::HandlePeerLinks(void) { // send disconnect packet EncodeDisconnectPacket(&buffer); - m_Socket.Send(buffer, client->GetIp(), XLX_PORT); + m_Socket.Send(buffer, client->GetIp()); std::cout << "Sending disconnect packet to XLX peer " << client->GetCallsign() << std::endl; // remove client clients->RemoveClient(client); @@ -318,7 +318,7 @@ void CXlxProtocol::HandlePeerLinks(void) for ( int i = 0; i < list->size(); i++ ) { CCallsignListItem *item = &((list->data())[i]); - if ( clients->FindClient(item->GetCallsign(), item->GetIp(), PROTOCOL_XLX) == NULL ) + if ( clients->FindClient(item->GetCallsign(), PROTOCOL_XLX) == NULL ) { // send connect packet to re-initiate peer link EncodeConnectPacket(&buffer, item->GetModules()); diff --git a/src/main.h b/src/main.h index c1b0e94..3682f28 100644 --- a/src/main.h +++ b/src/main.h @@ -47,8 +47,8 @@ // version ----------------------------------------------------- #define VERSION_MAJOR 1 -#define VERSION_MINOR 2 -#define VERSION_REVISION 6 +#define VERSION_MINOR 3 +#define VERSION_REVISION 1 // global ------------------------------------------------------