1
0
mirror of https://github.com/ShaYmez/xlxd.git synced 2025-09-02 21:27:49 -04:00

xlxd 1.3.1

Added support for multi-radio repeaters
This commit is contained in:
LX3JL 2016-02-21 09:17:51 +01:00
parent e809e8f2cb
commit eb5cee1993
8 changed files with 55 additions and 25 deletions

View File

@ -214,6 +214,25 @@ CClient *CClients::FindClient(const CCallsign &Callsign, char module, const CIp
return client; 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 // iterate on clients

View File

@ -60,6 +60,7 @@ public:
CClient *FindClient(const CIp &, int); CClient *FindClient(const CIp &, int);
CClient *FindClient(const CCallsign &, const CIp &, int); CClient *FindClient(const CCallsign &, const CIp &, int);
CClient *FindClient(const CCallsign &, char, const CIp &, int); CClient *FindClient(const CCallsign &, char, const CIp &, int);
CClient *FindClient(const CCallsign &, int);
// iterate on clients // iterate on clients
CClient *FindNextClient(int, int*); CClient *FindNextClient(int, int*);

View File

@ -147,7 +147,7 @@ void CDcsProtocol::Task(void)
} }
else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) 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 // find client & remove it
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
@ -201,13 +201,14 @@ void CDcsProtocol::Task(void)
bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
{ {
bool newstream = false; bool newstream = false;
CCallsign via(Header->GetRpt1Callsign());
// find the stream // find the stream
CPacketStream *stream = GetStream(Header->GetStreamId()); CPacketStream *stream = GetStream(Header->GetStreamId());
if ( stream == NULL ) if ( stream == NULL )
{ {
// no stream open yet, open a new one // no stream open yet, open a new one
CCallsign via(Header->GetRpt1Callsign());
// find this client // find this client
CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DCS); CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DCS);
if ( client != NULL ) if ( client != NULL )
@ -224,6 +225,10 @@ bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
} }
// release // release
g_Reflector.ReleaseClients(); g_Reflector.ReleaseClients();
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
} }
else else
{ {
@ -234,10 +239,6 @@ bool CDcsProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
delete Header; delete Header;
} }
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
// done // done
return newstream; return newstream;
} }

View File

@ -85,6 +85,7 @@ void CDextraProtocol::Task(void)
else if ( (Header = IsValidDvHeaderPacket(Buffer)) != NULL ) else if ( (Header = IsValidDvHeaderPacket(Buffer)) != NULL )
{ {
//std::cout << "DExtra DV header:" << std::endl << *Header << std::endl; //std::cout << "DExtra DV header:" << std::endl << *Header << std::endl;
//std::cout << "DExtra DV header:" << std::endl;
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA) )
@ -135,7 +136,7 @@ void CDextraProtocol::Task(void)
// find client & remove it // find client & remove it
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
CClient *client = clients->FindClient(Callsign, Ip, PROTOCOL_DEXTRA); CClient *client = clients->FindClient(Ip, PROTOCOL_DEXTRA);
if ( client != NULL ) if ( client != NULL )
{ {
// ack disconnect packet // ack disconnect packet
@ -212,8 +213,11 @@ void CDextraProtocol::HandleQueue(void)
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
{ {
// no, send the packet // 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(); g_Reflector.ReleaseClients();
@ -275,13 +279,14 @@ void CDextraProtocol::HandleKeepalives(void)
bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
{ {
bool newstream = false; bool newstream = false;
CCallsign via(Header->GetRpt1Callsign());
// find the stream // find the stream
CPacketStream *stream = GetStream(Header->GetStreamId()); CPacketStream *stream = GetStream(Header->GetStreamId());
if ( stream == NULL ) if ( stream == NULL )
{ {
// no stream open yet, open a new one // no stream open yet, open a new one
CCallsign via(Header->GetRpt1Callsign());
// find this client // find this client
CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DEXTRA); CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DEXTRA);
if ( client != NULL ) if ( client != NULL )
@ -298,18 +303,20 @@ bool CDextraProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
} }
// release // release
g_Reflector.ReleaseClients(); g_Reflector.ReleaseClients();
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
} }
else else
{ {
// stream already open // stream already open
// skip packet, but tickle the stream // skip packet, but tickle the stream
stream->Tickle(); stream->Tickle();
// and delete packet
delete Header;
} }
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
// done // done
return newstream; return newstream;
} }

View File

@ -194,14 +194,15 @@ void CDplusProtocol::Task(void)
bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
{ {
bool newstream = false; bool newstream = false;
CCallsign via(Header->GetRpt1Callsign());
// find the stream // find the stream
CPacketStream *stream = GetStream(Header->GetStreamId()); CPacketStream *stream = GetStream(Header->GetStreamId());
if ( stream == NULL ) if ( stream == NULL )
{ {
// no stream open yet, open a new one // 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); CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DPLUS);
if ( client != NULL ) if ( client != NULL )
{ {
@ -222,6 +223,10 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
} }
// release // release
g_Reflector.ReleaseClients(); g_Reflector.ReleaseClients();
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
} }
else else
{ {
@ -232,10 +237,6 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
delete Header; delete Header;
} }
// update last heard
g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via);
g_Reflector.ReleaseUsers();
// done // done
return newstream; return newstream;
} }

View File

@ -79,7 +79,8 @@ void CIp::SetSockAddr(struct sockaddr_in *sa)
bool CIp::operator ==(const CIp &ip) const bool CIp::operator ==(const CIp &ip) const
{ {
return ( (ip.m_Addr.sin_family == m_Addr.sin_family) && 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 CIp::operator const char *() const

View File

@ -306,7 +306,7 @@ void CXlxProtocol::HandlePeerLinks(void)
{ {
// send disconnect packet // send disconnect packet
EncodeDisconnectPacket(&buffer); 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; std::cout << "Sending disconnect packet to XLX peer " << client->GetCallsign() << std::endl;
// remove client // remove client
clients->RemoveClient(client); clients->RemoveClient(client);
@ -318,7 +318,7 @@ void CXlxProtocol::HandlePeerLinks(void)
for ( int i = 0; i < list->size(); i++ ) for ( int i = 0; i < list->size(); i++ )
{ {
CCallsignListItem *item = &((list->data())[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 // send connect packet to re-initiate peer link
EncodeConnectPacket(&buffer, item->GetModules()); EncodeConnectPacket(&buffer, item->GetModules());

View File

@ -47,8 +47,8 @@
// version ----------------------------------------------------- // version -----------------------------------------------------
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 3
#define VERSION_REVISION 6 #define VERSION_REVISION 1
// global ------------------------------------------------------ // global ------------------------------------------------------