mirror of
https://github.com/ShaYmez/xlxd.git
synced 2024-12-23 10:05:48 -05:00
version 1.3.8
This commit is contained in:
parent
dfb46e1266
commit
4be0cb5fa4
@ -32,11 +32,13 @@
|
|||||||
CCallsignListItem::CCallsignListItem()
|
CCallsignListItem::CCallsignListItem()
|
||||||
{
|
{
|
||||||
::memset(m_Modules, 0, sizeof(m_Modules));
|
::memset(m_Modules, 0, sizeof(m_Modules));
|
||||||
|
::memset(m_szUrl, 0, sizeof(m_szUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, const char *modules)
|
CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, const char *modules)
|
||||||
{
|
{
|
||||||
m_Callsign = callsign;
|
m_Callsign = callsign;
|
||||||
|
::memset(m_szUrl, 0, sizeof(m_szUrl));
|
||||||
m_Ip = ip;
|
m_Ip = ip;
|
||||||
if ( modules != NULL )
|
if ( modules != NULL )
|
||||||
{
|
{
|
||||||
@ -45,9 +47,22 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const char *url, const char *modules)
|
||||||
|
{
|
||||||
|
m_Callsign = callsign;
|
||||||
|
::strncpy(m_szUrl, url, URL_MAXLEN);
|
||||||
|
m_Ip = CIp(m_szUrl);
|
||||||
|
if ( modules != NULL )
|
||||||
|
{
|
||||||
|
:: memset(m_Modules, 0, sizeof(m_Modules));
|
||||||
|
::memcpy(m_Modules, modules, MIN(strlen(modules), sizeof(m_Modules)-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CCallsignListItem::CCallsignListItem(const CCallsignListItem &item)
|
CCallsignListItem::CCallsignListItem(const CCallsignListItem &item)
|
||||||
{
|
{
|
||||||
m_Callsign = item.m_Callsign;
|
m_Callsign = item.m_Callsign;
|
||||||
|
::memcpy(m_szUrl, item.m_szUrl, sizeof(m_szUrl));
|
||||||
m_Ip = item.m_Ip;
|
m_Ip = item.m_Ip;
|
||||||
::memcpy(m_Modules, item.m_Modules, sizeof(m_Modules));
|
::memcpy(m_Modules, item.m_Modules, sizeof(m_Modules));
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
#include "ccallsign.h"
|
#include "ccallsign.h"
|
||||||
#include "cip.h"
|
#include "cip.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// define
|
||||||
|
|
||||||
|
#define URL_MAXLEN 256
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// class
|
// class
|
||||||
|
|
||||||
@ -38,6 +43,7 @@ public:
|
|||||||
// constructor
|
// constructor
|
||||||
CCallsignListItem();
|
CCallsignListItem();
|
||||||
CCallsignListItem(const CCallsign &, const CIp &, const char *);
|
CCallsignListItem(const CCallsign &, const CIp &, const char *);
|
||||||
|
CCallsignListItem(const CCallsign &, const char *, const char *);
|
||||||
CCallsignListItem(const CCallsignListItem &);
|
CCallsignListItem(const CCallsignListItem &);
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
@ -54,9 +60,13 @@ public:
|
|||||||
const CIp &GetIp(void) const { return m_Ip; }
|
const CIp &GetIp(void) const { return m_Ip; }
|
||||||
const char *GetModules(void) { return m_Modules; }
|
const char *GetModules(void) { return m_Modules; }
|
||||||
|
|
||||||
|
// update
|
||||||
|
void ResolveIp(void) { m_Ip = CIp(m_szUrl); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// data
|
// data
|
||||||
CCallsign m_Callsign;
|
CCallsign m_Callsign;
|
||||||
|
char m_szUrl[URL_MAXLEN+1];
|
||||||
CIp m_Ip;
|
CIp m_Ip;
|
||||||
char m_Modules[NB_MODULES_MAX+1];
|
char m_Modules[NB_MODULES_MAX+1];
|
||||||
};
|
};
|
||||||
|
@ -291,14 +291,14 @@ void CDcsProtocol::HandleQueue(void)
|
|||||||
{
|
{
|
||||||
// encode it
|
// encode it
|
||||||
CBuffer buffer;
|
CBuffer buffer;
|
||||||
if ( packet->IsDvFrame() )
|
if ( packet->IsLastPacket() )
|
||||||
{
|
|
||||||
EncodeDvPacket(m_DvHeadersCache[iModId], (const CDvFramePacket &)*packet, m_iSeqCounters[iModId]++, &buffer);
|
|
||||||
}
|
|
||||||
else if ( packet->IsLastPacket() )
|
|
||||||
{
|
{
|
||||||
EncodeDvLastPacket(m_DvHeadersCache[iModId], (const CDvFramePacket &)*packet, m_iSeqCounters[iModId]++, &buffer);
|
EncodeDvLastPacket(m_DvHeadersCache[iModId], (const CDvFramePacket &)*packet, m_iSeqCounters[iModId]++, &buffer);
|
||||||
}
|
}
|
||||||
|
else if ( packet->IsDvFrame() )
|
||||||
|
{
|
||||||
|
EncodeDvPacket(m_DvHeadersCache[iModId], (const CDvFramePacket &)*packet, m_iSeqCounters[iModId]++, &buffer);
|
||||||
|
}
|
||||||
|
|
||||||
// send it
|
// send it
|
||||||
if ( buffer.size() > 0 )
|
if ( buffer.size() > 0 )
|
||||||
|
@ -30,6 +30,17 @@
|
|||||||
#include "cgatekeeper.h"
|
#include "cgatekeeper.h"
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// constructor
|
||||||
|
|
||||||
|
CDplusProtocol::CDplusProtocol()
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_iSeqCounters.size(); i++ )
|
||||||
|
{
|
||||||
|
m_iSeqCounters[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// operation
|
// operation
|
||||||
|
|
||||||
@ -270,6 +281,17 @@ void CDplusProtocol::HandleQueue(void)
|
|||||||
CPacket *packet = m_Queue.front();
|
CPacket *packet = m_Queue.front();
|
||||||
m_Queue.pop();
|
m_Queue.pop();
|
||||||
|
|
||||||
|
// get our sender's id
|
||||||
|
int iModId = g_Reflector.GetModuleIndex(packet->GetModuleId());
|
||||||
|
|
||||||
|
// check if it's header and update cache
|
||||||
|
if ( packet->IsDvHeader() )
|
||||||
|
{
|
||||||
|
// this relies on queue feeder setting valid module id
|
||||||
|
m_DvHeadersCache[iModId] = CDvHeaderPacket((const CDvHeaderPacket &)*packet);
|
||||||
|
m_iSeqCounters[iModId] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// encode it
|
// encode it
|
||||||
CBuffer buffer;
|
CBuffer buffer;
|
||||||
if ( EncodeDvPacket(*packet, &buffer) )
|
if ( EncodeDvPacket(*packet, &buffer) )
|
||||||
@ -288,30 +310,28 @@ void CDplusProtocol::HandleQueue(void)
|
|||||||
// check if client is a dextra dongle
|
// check if client is a dextra dongle
|
||||||
// then replace RPT2 with XRF instead of REF
|
// then replace RPT2 with XRF instead of REF
|
||||||
// if the client type is not yet known, send bothheaders
|
// if the client type is not yet known, send bothheaders
|
||||||
if ( packet->IsDvHeader() && (client->IsDextraDongle() || !client->HasModule()) )
|
if ( packet->IsDvHeader() )
|
||||||
{
|
{
|
||||||
// clone the packet and patch it
|
// sending header in Dplus is client specific
|
||||||
CDvHeaderPacket packet2(*((CDvHeaderPacket *)packet));
|
SendDvHeader((CDvHeaderPacket *)packet, (CDplusClient *)client);
|
||||||
CCallsign rpt2 = packet2.GetRpt2Callsign();
|
|
||||||
rpt2.PatchCallsign(0, (const uint8 *)"XRF", 3);
|
|
||||||
packet2.SetRpt2Callsign(rpt2);
|
|
||||||
// encode it
|
|
||||||
CBuffer buffer2;
|
|
||||||
if ( EncodeDvPacket(packet2, &buffer2) )
|
|
||||||
{
|
|
||||||
// and send it
|
|
||||||
m_Socket.Send(buffer2, client->GetIp());
|
|
||||||
}
|
}
|
||||||
// client type known ?
|
else if ( packet->IsDvFrame() )
|
||||||
if ( !client->HasModule() )
|
|
||||||
{
|
{
|
||||||
// no, send also the genuine packet
|
// and send the DV frame
|
||||||
m_Socket.Send(buffer, client->GetIp());
|
m_Socket.Send(buffer, client->GetIp());
|
||||||
|
|
||||||
|
// is it time to insert a DVheader copy ?
|
||||||
|
if ( (m_iSeqCounters[iModId]++ % 21) == 20 )
|
||||||
|
{
|
||||||
|
// yes, clone it
|
||||||
|
CDvHeaderPacket packet2(m_DvHeadersCache[iModId]);
|
||||||
|
// and send it
|
||||||
|
SendDvHeader(&packet2, (CDplusClient *)client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no, send the original packet
|
// otherwise, send the original packet
|
||||||
m_Socket.Send(buffer, client->GetIp());
|
m_Socket.Send(buffer, client->GetIp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,6 +346,43 @@ void CDplusProtocol::HandleQueue(void)
|
|||||||
m_Queue.Unlock();
|
m_Queue.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDplusProtocol::SendDvHeader(CDvHeaderPacket *packet, CDplusClient *client)
|
||||||
|
{
|
||||||
|
// encode it
|
||||||
|
CBuffer buffer;
|
||||||
|
if ( EncodeDvPacket(*packet, &buffer) )
|
||||||
|
{
|
||||||
|
if ( (client->IsDextraDongle() || !client->HasModule()) )
|
||||||
|
{
|
||||||
|
// clone the packet and patch it
|
||||||
|
CDvHeaderPacket packet2(*((CDvHeaderPacket *)packet));
|
||||||
|
CCallsign rpt2 = packet2.GetRpt2Callsign();
|
||||||
|
rpt2.PatchCallsign(0, (const uint8 *)"XRF", 3);
|
||||||
|
packet2.SetRpt2Callsign(rpt2);
|
||||||
|
|
||||||
|
// encode it
|
||||||
|
CBuffer buffer2;
|
||||||
|
if ( EncodeDvPacket(packet2, &buffer2) )
|
||||||
|
{
|
||||||
|
// and send it
|
||||||
|
m_Socket.Send(buffer2, client->GetIp());
|
||||||
|
}
|
||||||
|
|
||||||
|
// client type known ?
|
||||||
|
if ( !client->HasModule() )
|
||||||
|
{
|
||||||
|
// no, send also the genuine packet
|
||||||
|
m_Socket.Send(buffer, client->GetIp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// otherwise, send the original packet
|
||||||
|
m_Socket.Send(buffer, client->GetIp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// keepalive helpers
|
// keepalive helpers
|
||||||
|
|
||||||
|
@ -37,11 +37,13 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// class
|
// class
|
||||||
|
|
||||||
|
class CDplusClient;
|
||||||
|
|
||||||
class CDplusProtocol : public CProtocol
|
class CDplusProtocol : public CProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
CDplusProtocol() {};
|
CDplusProtocol();
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~CDplusProtocol() {};
|
virtual ~CDplusProtocol() {};
|
||||||
@ -55,6 +57,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// queue helper
|
// queue helper
|
||||||
void HandleQueue(void);
|
void HandleQueue(void);
|
||||||
|
void SendDvHeader(CDvHeaderPacket *, CDplusClient *);
|
||||||
|
|
||||||
// keepalive helpers
|
// keepalive helpers
|
||||||
void HandleKeepalives(void);
|
void HandleKeepalives(void);
|
||||||
@ -84,6 +87,10 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
// for keep alive
|
// for keep alive
|
||||||
CTimePoint m_LastKeepaliveTime;
|
CTimePoint m_LastKeepaliveTime;
|
||||||
|
|
||||||
|
// for queue header caches
|
||||||
|
std::array<CDvHeaderPacket, NB_OF_MODULES> m_DvHeadersCache;
|
||||||
|
std::array<uint32, NB_OF_MODULES> m_iSeqCounters;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -57,14 +57,14 @@ bool CPeerCallsignList::LoadFromFile(const char *filename)
|
|||||||
{
|
{
|
||||||
CCallsign callsign(szt);
|
CCallsign callsign(szt);
|
||||||
// 2nd token is ip
|
// 2nd token is ip
|
||||||
if ( (szt = ::strtok(NULL, " ,\t")) != NULL )
|
char *szip;
|
||||||
|
if ( (szip = ::strtok(NULL, " ,\t")) != NULL )
|
||||||
{
|
{
|
||||||
CIp ip(szt);
|
|
||||||
// 3rd token is modules list
|
// 3rd token is modules list
|
||||||
if ( (szt = ::strtok(NULL, " ,\t")) != NULL )
|
if ( (szt = ::strtok(NULL, " ,\t")) != NULL )
|
||||||
{
|
{
|
||||||
// and load
|
// and load
|
||||||
push_back(CCallsignListItem(callsign, ip, szt));
|
push_back(CCallsignListItem(callsign, szip, szt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,8 @@ void CXlxProtocol::HandlePeerLinks(void)
|
|||||||
CCallsignListItem *item = &((list->data())[i]);
|
CCallsignListItem *item = &((list->data())[i]);
|
||||||
if ( clients->FindClient(item->GetCallsign(), PROTOCOL_XLX) == NULL )
|
if ( clients->FindClient(item->GetCallsign(), PROTOCOL_XLX) == NULL )
|
||||||
{
|
{
|
||||||
|
// resolve again peer's IP in case it's a dynamic IP
|
||||||
|
item->ResolveIp();
|
||||||
// send connect packet to re-initiate peer link
|
// send connect packet to re-initiate peer link
|
||||||
EncodeConnectPacket(&buffer, item->GetModules());
|
EncodeConnectPacket(&buffer, item->GetModules());
|
||||||
m_Socket.Send(buffer, item->GetIp(), XLX_PORT);
|
m_Socket.Send(buffer, item->GetIp(), XLX_PORT);
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_REVISION 7
|
#define VERSION_REVISION 8
|
||||||
|
|
||||||
// global ------------------------------------------------------
|
// global ------------------------------------------------------
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ LDFLAGS=-std=c++11 -pthread
|
|||||||
SOURCES=$(wildcard *.cpp)
|
SOURCES=$(wildcard *.cpp)
|
||||||
OBJECTS=$(SOURCES:.cpp=.o)
|
OBJECTS=$(SOURCES:.cpp=.o)
|
||||||
EXECUTABLE=xlxd
|
EXECUTABLE=xlxd
|
||||||
RM=rm -f
|
|
||||||
|
|
||||||
all: $(SOURCES) $(EXECUTABLE)
|
all: $(SOURCES) $(EXECUTABLE)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ $(EXECUTABLE): $(OBJECTS)
|
|||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) *.o
|
rm *.o
|
||||||
|
|
||||||
install:
|
install:
|
||||||
mkdir -p /xlxd
|
mkdir -p /xlxd
|
||||||
|
Loading…
Reference in New Issue
Block a user