added new CPacket member bool IsSecond

unstable
Tom Early 4 years ago
parent ed87b9e7f6
commit 436e0b00d9

@ -19,7 +19,6 @@
#pragma once
#include "Client.h"
#include "XLXClient.h"
class CBmClient : public CClient
{

@ -19,9 +19,8 @@
#include <string.h>
#include "Main.h"
#include "XLXPeer.h"
#include "BMPeer.h"
#include "XLXProtocol.h"
#include "BMProtocol.h"
#include "Reflector.h"
#include "GateKeeper.h"
@ -29,7 +28,7 @@
////////////////////////////////////////////////////////////////////////////////////////
// operation
bool CXlxProtocol::Initialize(const char *type, EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
bool CBMProtocol::Initialize(const char *type, EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
return false;
@ -45,7 +44,7 @@ bool CXlxProtocol::Initialize(const char *type, EProtocol ptype, const uint16_t
////////////////////////////////////////////////////////////////////////////////////////
// task
void CXlxProtocol::Task(void)
void CBMProtocol::Task(void)
{
CBuffer Buffer;
CIp Ip;
@ -79,10 +78,6 @@ void CXlxProtocol::Task(void)
OnDvHeaderPacketIn(Header, Ip);
}
}
else if ( IsValidDvLastFramePacket(Buffer, Frame) )
{
OnDvLastFramePacketIn(Frame, &Ip);
}
else if ( IsValidConnectPacket(Buffer, &Callsign, Modules, &Version) )
{
std::cout << "XLX (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
@ -90,32 +85,9 @@ void CXlxProtocol::Task(void)
// callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) )
{
// acknowledge connecting request
// following is version dependent
switch ( GetConnectingPeerProtocolRevision(Callsign, Version) )
{
case EProtoRev::original:
{
// already connected ?
CPeers *peers = g_Reflector.GetPeers();
if ( peers->FindPeer(Callsign, Ip, EProtocol::xlx) == nullptr )
{
// acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules);
Send(Buffer, Ip);
}
g_Reflector.ReleasePeers();
}
break;
case EProtoRev::revised:
case EProtoRev::ambe:
default:
// acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules);
Send(Buffer, Ip);
break;
}
// acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules);
Send(Buffer, Ip);
}
else
{
@ -137,7 +109,7 @@ void CXlxProtocol::Task(void)
{
// create the new peer
// this also create one client per module
std::shared_ptr<CPeer>peer = CreateNewPeer(Callsign, Ip, Modules, Version);
std::shared_ptr<CPeer>peer = std::make_shared<CBmPeer>(Callsign, Ip, Modules, Version);
// append the peer to reflector peer list
// this also add all new clients to reflector client list
@ -218,7 +190,7 @@ void CXlxProtocol::Task(void)
////////////////////////////////////////////////////////////////////////////////////////
// queue helper
void CXlxProtocol::HandleQueue(void)
void CBMProtocol::HandleQueue(void)
{
m_Queue.Lock();
while ( !m_Queue.empty() )
@ -285,7 +257,7 @@ void CXlxProtocol::HandleQueue(void)
////////////////////////////////////////////////////////////////////////////////////////
// keepalive helpers
void CXlxProtocol::HandleKeepalives(void)
void CBMProtocol::HandleKeepalives(void)
{
// DExtra protocol sends and monitors keepalives packets
// event if the client is currently streaming
@ -327,7 +299,7 @@ void CXlxProtocol::HandleKeepalives(void)
////////////////////////////////////////////////////////////////////////////////////////
// Peers helpers
void CXlxProtocol::HandlePeerLinks(void)
void CBMProtocol::HandlePeerLinks(void)
{
CBuffer buffer;
@ -378,7 +350,7 @@ void CXlxProtocol::HandlePeerLinks(void)
////////////////////////////////////////////////////////////////////////////////////////
// streams helpers
void CXlxProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, const CIp &Ip)
void CBMProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, const CIp &Ip)
{
CCallsign peer;
@ -423,29 +395,32 @@ void CXlxProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
}
}
void CXlxProtocol::OnDvFramePacketIn(std::unique_ptr<CDvFramePacket> &DvFrame, const CIp *Ip)
{
// tag packet as remote peer origin
DvFrame->SetRemotePeerOrigin();
// anc call base class
CDextraProtocol::OnDvFramePacketIn(DvFrame, Ip);
}
void CXlxProtocol::OnDvLastFramePacketIn(std::unique_ptr<CDvFramePacket> &DvFrame, const CIp *Ip)
void CBMProtocol::OnDvFramePacketIn(std::unique_ptr<CDvFramePacket> &DvFrame, const CIp *Ip)
{
// tag packet as remote peer origin
DvFrame->SetRemotePeerOrigin();
// anc call base class
CDextraProtocol::OnDvFramePacketIn(DvFrame, Ip);
CProtocol::OnDvFramePacketIn(DvFrame, Ip);
}
////////////////////////////////////////////////////////////////////////////////////////
// packet decoding helpers
bool CXlxProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *callsign)
bool CBMProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header)
{
if ( 56==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x10U==Buffer.data()[4] && 0x20U==Buffer.data()[8] )
{
// create packet
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), 0x80));
// check validity of packet
if ( header && header->IsValid() )
return true;
}
return false;
}
bool CBMProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *callsign)
{
bool valid = false;
if (Buffer.size() == 9)
@ -457,7 +432,7 @@ bool CXlxProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *call
}
bool CXlxProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, char *modules, CVersion *version)
bool CBMProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, char *modules, CVersion *version)
{
bool valid = false;
if ((Buffer.size() == 39) && (Buffer.data()[0] == 'L') && (Buffer.data()[38] == 0))
@ -474,7 +449,7 @@ bool CXlxProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsi
return valid;
}
bool CXlxProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *callsign)
bool CBMProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *callsign)
{
bool valid = false;
if ((Buffer.size() == 10) && (Buffer.data()[0] == 'U') && (Buffer.data()[9] == 0))
@ -485,7 +460,7 @@ bool CXlxProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *cal
return valid;
}
bool CXlxProtocol::IsValidAckPacket(const CBuffer &Buffer, CCallsign *callsign, char *modules, CVersion *version)
bool CBMProtocol::IsValidAckPacket(const CBuffer &Buffer, CCallsign *callsign, char *modules, CVersion *version)
{
bool valid = false;
if ((Buffer.size() == 39) && (Buffer.data()[0] == 'A') && (Buffer.data()[38] == 0))
@ -502,7 +477,7 @@ bool CXlxProtocol::IsValidAckPacket(const CBuffer &Buffer, CCallsign *callsign,
return valid;
}
bool CXlxProtocol::IsValidNackPacket(const CBuffer &Buffer, CCallsign *callsign)
bool CBMProtocol::IsValidNackPacket(const CBuffer &Buffer, CCallsign *callsign)
{
bool valid = false;
if ((Buffer.size() == 10) && (Buffer.data()[0] == 'N') && (Buffer.data()[9] == 0))
@ -513,40 +488,9 @@ bool CXlxProtocol::IsValidNackPacket(const CBuffer &Buffer, CCallsign *callsign)
return valid;
}
bool CXlxProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
{
// base class first (protocol revision 1 and lower)
if (CDextraProtocol::IsValidDvFramePacket(Buffer, dvframe))
return true;
// otherwise try protocol revision 2
if ( 45==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && 0==(Buffer.data()[14] & 0x40) )
{
// create packet
dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(
// sid
*((uint16_t *)&(Buffer.data()[12])),
// dstar
Buffer.data()[14], &(Buffer.data()[15]), &(Buffer.data()[24]),
// dmr
Buffer.data()[27], Buffer.data()[28], &(Buffer.data()[29]), &(Buffer.data()[38]),
ECodecType::dmr, false));
// check validity of packet
if ( dvframe && dvframe->IsValid() )
return true;
}
return false;
}
bool CXlxProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
bool CBMProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
{
// base class first (protocol revision 1 and lower)
if (CDextraProtocol::IsValidDvFramePacket(Buffer, dvframe))
return true;
// otherwise try protocol revision 2
if ( 45==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && (Buffer.data()[14] & 0x40U) )
if ( 45==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] )
{
// create packet
dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(
@ -556,7 +500,7 @@ bool CXlxProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_p
Buffer.data()[14], &(Buffer.data()[15]), &(Buffer.data()[24]),
// dmr
Buffer.data()[27], Buffer.data()[28], &(Buffer.data()[29]), &(Buffer.data()[38]),
ECodecType::dmr, true));
ECodecType::dmr, 0x40U==(Buffer.data()[14] & 0x40U)));
// check validity of packet
if ( dvframe && dvframe->IsValid() )
@ -568,12 +512,12 @@ bool CXlxProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_p
////////////////////////////////////////////////////////////////////////////////////////
// packet encoding helpers
void CXlxProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
void CBMProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
{
Buffer->Set(GetReflectorCallsign());
}
void CXlxProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules)
void CBMProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules)
{
uint8_t tag[] = { 'L' };
@ -591,7 +535,7 @@ void CXlxProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules)
Buffer->resize(39);
}
void CXlxProtocol::EncodeDisconnectPacket(CBuffer *Buffer)
void CBMProtocol::EncodeDisconnectPacket(CBuffer *Buffer)
{
uint8_t tag[] = { 'U' };
@ -603,7 +547,7 @@ void CXlxProtocol::EncodeDisconnectPacket(CBuffer *Buffer)
Buffer->Append((uint8_t)0);
}
void CXlxProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const char *Modules)
void CBMProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const char *Modules)
{
uint8_t tag[] = { 'A' };
@ -621,7 +565,7 @@ void CXlxProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const char *Modules)
Buffer->resize(39);
}
void CXlxProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
void CBMProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
{
uint8_t tag[] = { 'N' };
@ -633,7 +577,7 @@ void CXlxProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
Buffer->Append((uint8_t)0);
}
bool CXlxProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
bool CBMProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
{
uint8_t tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
@ -652,7 +596,7 @@ bool CXlxProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Bu
}
bool CXlxProtocol::EncodeDvLastFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
bool CBMProtocol::EncodeDvLastFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
{
uint8_t tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
uint8_t dstarambe[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00 };
@ -672,38 +616,3 @@ bool CXlxProtocol::EncodeDvLastFramePacket(const CDvFramePacket &Packet, CBuffer
return true;
}
////////////////////////////////////////////////////////////////////////////////////////
// protocol revision helper
EProtoRev CXlxProtocol::GetConnectingPeerProtocolRevision(const CCallsign &Callsign, const CVersion &Version)
{
EProtoRev protrev;
// BM ?
if ( Callsign.HasSameCallsignWithWildcard(CCallsign("BM*")) )
{
protrev = CBmPeer::GetProtocolRevision(Version);
}
// otherwise, assume native xlx
else
{
protrev = CXlxPeer::GetProtocolRevision(Version);
}
// done
return protrev;
}
std::shared_ptr<CPeer> CXlxProtocol::CreateNewPeer(const CCallsign &Callsign, const CIp &Ip, char *Modules, const CVersion &Version)
{
// BM ?
if ( Callsign.HasSameCallsignWithWildcard(CCallsign("BM*")) )
{
return std::make_shared<CBmPeer>(Callsign, Ip, Modules, Version);
}
else
{
return std::make_shared<CXlxPeer>(Callsign, Ip, Modules, Version);
}
}

@ -20,7 +20,7 @@
#include "Version.h"
#include "Timer.h"
#include "DExtraProtocol.h"
#include "Protocol.h"
#include "Clients.h"
////////////////////////////////////////////////////////////////////////////////////////
@ -30,7 +30,7 @@ class CPeer;
////////////////////////////////////////////////////////////////////////////////////////
// class
class CXlxProtocol : public CDextraProtocol
class CBMProtocol : public CProtocol
{
public:
// initialization
@ -50,16 +50,15 @@ protected:
// stream helpers
void OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &, const CIp &);
void OnDvFramePacketIn(std::unique_ptr<CDvFramePacket> &, const CIp * = nullptr);
void OnDvLastFramePacketIn(std::unique_ptr<CDvFramePacket> &, const CIp * = nullptr);
// packet decoding helpers
bool IsValidDvHeaderPacket(const CBuffer &, std::unique_ptr<CDvHeaderPacket> &);
bool IsValidKeepAlivePacket(const CBuffer &, CCallsign *);
bool IsValidConnectPacket(const CBuffer &, CCallsign *, char *, CVersion *);
bool IsValidDisconnectPacket(const CBuffer &, CCallsign *);
bool IsValidAckPacket(const CBuffer &, CCallsign *, char *, CVersion *);
bool IsValidNackPacket(const CBuffer &, CCallsign *);
bool IsValidDvFramePacket(const CBuffer &, std::unique_ptr<CDvFramePacket> &);
bool IsValidDvLastFramePacket(const CBuffer &, std::unique_ptr<CDvFramePacket> &);
// packet encoding helpers
void EncodeKeepAlivePacket(CBuffer *);
@ -70,10 +69,6 @@ protected:
bool EncodeDvFramePacket(const CDvFramePacket &, CBuffer *) const;
bool EncodeDvLastFramePacket(const CDvFramePacket &, CBuffer *) const;
// protocol revision helper
EProtoRev GetConnectingPeerProtocolRevision(const CCallsign &, const CVersion &);
std::shared_ptr<CPeer>CreateNewPeer(const CCallsign &, const CIp &, char *, const CVersion &);
protected:
// time
CTimer m_LastKeepaliveTime;

@ -23,7 +23,6 @@ enum class ECodecType { none, dstar, dmr, c2_1600, c2_3200 };
using STCPacket = struct tcpacket_tag {
char module;
bool is_last_packet;
bool has_valid_m17;
uint16_t streamid;
ECodecType codec_in;
uint8_t dstar[9];

@ -73,7 +73,8 @@ void CM17Protocol::Task(void)
{
OnDvHeaderPacketIn(Header, Ip);
OnDvFramePacketIn((std::unique_ptr<CDvFramePacket> &)Frame, &Ip);
OnDvFramePacketIn(Frame, &Ip);
OnDvFramePacketIn(Frame, &Ip); // push two packet because we need a packet every 20 ms
}
}
else if ( IsValidConnectPacket(Buffer, Callsign, ToLinkModule) )
@ -232,7 +233,7 @@ void CM17Protocol::HandleQueue(void)
m_StreamsCache[module].m_dvHeader = CDvHeaderPacket((const CDvHeaderPacket &)*packet.get());
m_StreamsCache[module].m_iSeqCounter = 0;
}
else
else if (packet->IsSecond() || packet->IsLastPacket())
{
// encode it
SM17Frame frame;

@ -162,4 +162,7 @@ void CPacket::UpdatePids(const uint32_t pid)
// frames are every 20 milliseconds, so the m17 data will come every 40 milliseconds
m_uiM17FrameNumber = (pid % 2) % 0x7FFFU;
}
// set the Is Second member used for M17 clients
m_bIsSecond = (1 == pid % 2);
}

@ -62,6 +62,7 @@ public:
uint8_t GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; }
char GetModule(void) const { return m_cModule; }
bool IsLocalOrigin(void) const { return (m_uiOriginId == ORIGIN_LOCAL); }
bool IsSecond(void) const { return m_bIsSecond; }
ECodecType GetCodecIn(void) const { return m_eCodecIn; }
// set
@ -74,6 +75,7 @@ protected:
// data
ECodecType m_eCodecIn;
bool m_bLastPacket;
bool m_bIsSecond;
char m_cModule;
uint16_t m_uiStreamId;
uint16_t m_uiM17FrameNumber;

@ -25,6 +25,7 @@
#include "DMRMMDVMProtocol.h"
#include "YSFProtocol.h"
#include "M17Protocol.h"
#include "BMProtocol.h"
#ifndef NO_G3
#include "G3Protocol.h"
#endif
@ -61,6 +62,10 @@ bool CProtocols::Init(void)
if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrmmdvm, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6))
return false;
m_Protocols.emplace_back(std::unique_ptr<CBMProtocol>(new CBMProtocol));
if (! m_Protocols.back()->Initialize(nullptr, EProtocol::xlx, XLX_PORT, DMR_IPV4, DMR_IPV6))
return false;
m_Protocols.emplace_back(std::unique_ptr<CDmrplusProtocol>(new CDmrplusProtocol));
if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrplus, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6))
return false;
@ -69,14 +74,14 @@ bool CProtocols::Init(void)
if (! m_Protocols.back()->Initialize("YSF", EProtocol::ysf, YSF_PORT, YSF_IPV4, YSF_IPV6))
return false;
m_Protocols.emplace_back(std::unique_ptr<CURFProtocol>(new CURFProtocol));
if (! m_Protocols.back()->Initialize("URF", EProtocol::urf, URF_PORT, URF_IPV4, URF_IPV6))
return false;
m_Protocols.emplace_back(std::unique_ptr<CM17Protocol>(new CM17Protocol));
if (! m_Protocols.back()->Initialize("URF", EProtocol::m17, M17_PORT, M17_IPV4, M17_IPV6))
return false;
m_Protocols.emplace_back(std::unique_ptr<CURFProtocol>(new CURFProtocol));
if (! m_Protocols.back()->Initialize("URF", EProtocol::urf, URF_PORT, URF_IPV4, URF_IPV6))
return false;
#ifndef NO_G3
m_Protocols.emplace_back(std::unique_ptr<CG3Protocol>(new CG3Protocol));
if (! m_Protocols.back()->Initialize("XLX", EProtocol::g3, G3_DV_PORT, DMR_IPV4, DMR_IPV6))

@ -182,7 +182,7 @@ std::shared_ptr<CPacketStream> CReflector::OpenStream(std::unique_ptr<CDvHeaderP
}
// get the module's queue
char module = DvHeader->GetRpt2Module();
char module = DvHeader->GetModule();
auto stream = GetStream(module);
if ( stream == nullptr )
return nullptr;

@ -25,7 +25,7 @@
#include "PacketStream.h"
#include "NotificationQueue.h"
#ifdef TRANSCODED_MODULES
#include "UnixDgramSocket.h"
//#include "UnixDgramSocket.h"
#endif

@ -1,77 +0,0 @@
//
// cxlxclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 28/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
//
// xlxd is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h>
#include "Main.h"
#include "XLXClient.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructors
CXlxClient::CXlxClient()
{
m_ProtRev = EProtoRev::original;
}
CXlxClient::CXlxClient(const CCallsign &callsign, const CIp &ip, char reflectorModule, EProtoRev protRev)
: CClient(callsign, ip, reflectorModule)
{
m_ProtRev = protRev;
}
CXlxClient::CXlxClient(const CXlxClient &client)
: CClient(client)
{
m_ProtRev = client.m_ProtRev;
}
////////////////////////////////////////////////////////////////////////////////////////
// identity
ECodecType CXlxClient::GetCodec(void) const
{
ECodecType codec;
switch ( GetProtocolRevision() )
{
case EProtoRev::original:
case EProtoRev::revised:
default:
codec = ECodecType::dstar;
break;
case EProtoRev::ambe:
codec = ECodecType::none;
break;
}
return codec;
}
////////////////////////////////////////////////////////////////////////////////////////
// status
bool CXlxClient::IsAlive(void) const
{
return (m_LastKeepaliveTime.time() < XLX_KEEPALIVE_TIMEOUT);
}

@ -1,50 +0,0 @@
#pragma once
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// urfd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Client.h"
class CXlxClient : public CClient
{
public:
// constructors
CXlxClient();
CXlxClient(const CCallsign &, const CIp &, char = ' ', EProtoRev = EProtoRev::ambe);
CXlxClient(const CXlxClient &);
// destructor
virtual ~CXlxClient() {};
// identity
EProtocol GetProtocol(void) const { return EProtocol::xlx; }
EProtoRev GetProtocolRevision(void) const { return m_ProtRev; }
const char *GetProtocolName(void) const { return "XLX"; }
ECodecType GetCodec(void) const;
bool IsPeer(void) const { return true; }
// status
bool IsAlive(void) const;
// reporting
void WriteXml(std::ofstream &) {}
protected:
// data
EProtoRev m_ProtRev;
};

@ -1,64 +0,0 @@
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// urfd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include "Main.h"
#include "Reflector.h"
#include "XLXPeer.h"
#include "XLXClient.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
CXlxPeer::CXlxPeer()
{
}
CXlxPeer::CXlxPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version)
: CPeer(callsign, ip, modules, version)
{
// get protocol revision
EProtoRev protrev = GetProtocolRevision(version);
//std::cout << "Adding XLX peer with protocol revision " << protrev << std::endl;
// and construct all xlx clients
for ( unsigned i = 0; i < ::strlen(modules); i++ )
{
// create and append to vector
m_Clients.push_back(std::make_shared<CXlxClient>(callsign, ip, modules[i], protrev));
}
}
////////////////////////////////////////////////////////////////////////////////////////
// status
bool CXlxPeer::IsAlive(void) const
{
return (m_LastKeepaliveTime.time() < XLX_KEEPALIVE_TIMEOUT);
}
////////////////////////////////////////////////////////////////////////////////////////
// revision helper
EProtoRev CXlxPeer::GetProtocolRevision(const CVersion &version)
{
return EProtoRev::ambe;
}

@ -1,41 +0,0 @@
#pragma once
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// urfd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Peer.h"
#include "XLXClient.h"
class CXlxPeer : public CPeer
{
public:
// constructors
CXlxPeer();
CXlxPeer(const CCallsign &, const CIp &, const char *, const CVersion &);
CXlxPeer(const CXlxPeer &) = delete;
// status
bool IsAlive(void) const;
// identity
EProtocol GetProtocol(void) const { return EProtocol::xlx; }
const char *GetProtocolName(void) const { return "XLX"; }
// revision helper
static EProtoRev GetProtocolRevision(const CVersion &);
};
Loading…
Cancel
Save

Powered by TurnKey Linux.