mirror of
https://github.com/ShaYmez/xlxd.git
synced 2024-12-23 01:55:49 -05:00
xlxd 1.3.1
Added support for multi-radio repeaters
This commit is contained in:
parent
e809e8f2cb
commit
eb5cee1993
@ -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
|
||||
|
||||
|
@ -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*);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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 ------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user