protocol is now a enum class

unstable
Tom Early 4 years ago
parent 63c3302681
commit 048bb6d9ba

@ -33,9 +33,9 @@ public:
virtual ~CBmClient() {}; virtual ~CBmClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_XLX; } EProtocol GetProtocol(void) const { return EProtocol::ulx; }
int GetProtocolRevision(void) const { return XLX_PROTOCOL_REVISION_2; } int GetProtocolRevision(void) const { return XLX_PROTOCOL_REVISION_2; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "ULX"; }
int GetCodec(void) const { return CODEC_AMBE2PLUS; } int GetCodec(void) const { return CODEC_AMBE2PLUS; }
bool IsPeer(void) const { return true; } bool IsPeer(void) const { return true; }

@ -40,7 +40,7 @@ public:
bool IsAlive(void) const; bool IsAlive(void) const;
// identity // identity
int GetProtocol(void) const { return PROTOCOL_XLX; } EProtocol GetProtocol(void) const { return EProtocol::ulx; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "XLX"; }
// revision helper // revision helper

@ -56,7 +56,7 @@ public:
void SetReflectorModule(char c) { m_ReflectorModule = c; } void SetReflectorModule(char c) { m_ReflectorModule = c; }
// identity // identity
virtual int GetProtocol(void) const { return PROTOCOL_NONE; } virtual EProtocol GetProtocol(void) const { return EProtocol::none; }
virtual int GetProtocolRevision(void) const { return 0; } virtual int GetProtocolRevision(void) const { return 0; }
virtual int GetCodec(void) const { return CODEC_NONE; } virtual int GetCodec(void) const { return CODEC_NONE; }
virtual const char *GetProtocolName(void) const { return "none"; } virtual const char *GetProtocolName(void) const { return "none"; }

@ -125,7 +125,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip)
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, int Protocol) std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, const EProtocol Protocol)
{ {
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
@ -140,7 +140,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, int Protocol)
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, int Protocol, char ReflectorModule) std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, const EProtocol Protocol, const char ReflectorModule)
{ {
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
@ -155,7 +155,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, int Protocol, char
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, const CIp &Ip, int Protocol) std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, const CIp &Ip, const EProtocol Protocol)
{ {
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
@ -169,7 +169,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, const C
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, char module, const CIp &Ip, int Protocol) std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, char module, const CIp &Ip, const EProtocol Protocol)
{ {
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
@ -183,7 +183,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, char mo
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, int Protocol) std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, const EProtocol Protocol)
{ {
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
@ -200,7 +200,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, int Pro
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// iterate on clients // iterate on clients
std::shared_ptr<CClient> CClients::FindNextClient(int Protocol, std::list<std::shared_ptr<CClient>>::iterator &it) std::shared_ptr<CClient> CClients::FindNextClient(const EProtocol Protocol, std::list<std::shared_ptr<CClient>>::iterator &it)
{ {
while ( it != end() ) while ( it != end() )
{ {
@ -213,7 +213,7 @@ std::shared_ptr<CClient> CClients::FindNextClient(int Protocol, std::list<std::s
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindNextClient(const CIp &Ip, int Protocol, std::list<std::shared_ptr<CClient>>::iterator &it) std::shared_ptr<CClient> CClients::FindNextClient(const CIp &Ip, const EProtocol Protocol, std::list<std::shared_ptr<CClient>>::iterator &it)
{ {
while ( it != end() ) while ( it != end() )
{ {
@ -226,7 +226,7 @@ std::shared_ptr<CClient> CClients::FindNextClient(const CIp &Ip, int Protocol, s
return nullptr; return nullptr;
} }
std::shared_ptr<CClient> CClients::FindNextClient(const CCallsign &Callsign, const CIp &Ip, int Protocol, std::list<std::shared_ptr<CClient>>::iterator &it) std::shared_ptr<CClient> CClients::FindNextClient(const CCallsign &Callsign, const CIp &Ip, const EProtocol Protocol, std::list<std::shared_ptr<CClient>>::iterator &it)
{ {
while ( it != end() ) while ( it != end() )
{ {

@ -55,16 +55,16 @@ public:
// find clients // find clients
std::shared_ptr<CClient> FindClient(const CIp &); std::shared_ptr<CClient> FindClient(const CIp &);
std::shared_ptr<CClient> FindClient(const CIp &, int); std::shared_ptr<CClient> FindClient(const CIp &, const EProtocol);
std::shared_ptr<CClient> FindClient(const CIp &, int, char); std::shared_ptr<CClient> FindClient(const CIp &, const EProtocol, const char);
std::shared_ptr<CClient> FindClient(const CCallsign &, const CIp &, int); std::shared_ptr<CClient> FindClient(const CCallsign &, const CIp &, const EProtocol);
std::shared_ptr<CClient> FindClient(const CCallsign &, char, const CIp &, int); std::shared_ptr<CClient> FindClient(const CCallsign &, char, const CIp &, const EProtocol);
std::shared_ptr<CClient> FindClient(const CCallsign &, int); std::shared_ptr<CClient> FindClient(const CCallsign &, const EProtocol);
// iterate on clients // iterate on clients
std::shared_ptr<CClient> FindNextClient(int, std::list<std::shared_ptr<CClient>>::iterator &); std::shared_ptr<CClient> FindNextClient(const EProtocol, std::list<std::shared_ptr<CClient>>::iterator &);
std::shared_ptr<CClient> FindNextClient(const CIp &, int, std::list<std::shared_ptr<CClient>>::iterator &); std::shared_ptr<CClient> FindNextClient(const CIp &, const EProtocol, std::list<std::shared_ptr<CClient>>::iterator &);
std::shared_ptr<CClient> FindNextClient(const CCallsign &, const CIp &, int, std::list<std::shared_ptr<CClient>>::iterator &); std::shared_ptr<CClient> FindNextClient(const CCallsign &, const CIp &, const EProtocol, std::list<std::shared_ptr<CClient>>::iterator &);
protected: protected:
// data // data

@ -83,14 +83,14 @@ bool CCodecStream::Init(uint16_t uiPort)
// create socket address, family based on transcoder listen address // create socket address, family based on transcoder listen address
#ifdef LISTEN_IPV4 #ifdef LISTEN_IPV4
#ifdef LISTEN_IPV6 #ifdef LISTEN_IPV6
const auto paddr = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY) : g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY); auto paddr = (AF_INET == m_Ip.GetFamily()) ? LISTEN_IPV4 : LISTEN_IPV6;
#else #else
const auto paddr = g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY); auto paddr = LISTEN_IPV4;
#endif #endif
#else #else
const auto paddr = g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY); auto paddr = LISTEN_IPV6;
#endif #endif
CIp ip(m_Ip.GetFamily(), m_uiPort, paddr.c_str()); CIp ip(m_Ip.GetFamily(), m_uiPort, paddr);
// create our socket // create our socket
if (ip.IsSet()) if (ip.IsSet())

@ -32,7 +32,7 @@ public:
virtual ~CDcsClient() {}; virtual ~CDcsClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DCS; } EProtocol GetProtocol(void) const { return EProtocol::dcs; }
const char *GetProtocolName(void) const { return "DCS"; } const char *GetProtocolName(void) const { return "DCS"; }
int GetCodec(void) const { return CODEC_AMBEPLUS; } int GetCodec(void) const { return CODEC_AMBEPLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -26,7 +26,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDcsProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CDcsProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -68,7 +68,7 @@ void CDcsProtocol::Task(void)
if ( IsValidDvPacket(Buffer, Header, Frame) ) if ( IsValidDvPacket(Buffer, Header, Frame) )
{ {
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DCS, Header->GetRpt2Module()) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dcs, Header->GetRpt2Module()) )
{ {
OnDvHeaderPacketIn(Header, Ip); OnDvHeaderPacketIn(Header, Ip);
@ -89,7 +89,7 @@ void CDcsProtocol::Task(void)
std::cout << "DCS connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; std::cout << "DCS connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DCS) && g_Reflector.IsValidModule(ToLinkModule) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dcs) && g_Reflector.IsValidModule(ToLinkModule) )
{ {
// valid module ? // valid module ?
if ( g_Reflector.IsValidModule(ToLinkModule) ) if ( g_Reflector.IsValidModule(ToLinkModule) )
@ -125,7 +125,7 @@ void CDcsProtocol::Task(void)
// find client // find client
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Ip, PROTOCOL_DCS); std::shared_ptr<CClient>client = clients->FindClient(Ip, EProtocol::dcs);
if ( client != nullptr ) if ( client != nullptr )
{ {
// remove it // remove it
@ -144,7 +144,7 @@ void CDcsProtocol::Task(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(Callsign, Ip, PROTOCOL_DCS, it)) != nullptr ) while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dcs, it)) != nullptr )
{ {
client->Alive(); client->Alive();
} }
@ -202,7 +202,7 @@ void CDcsProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DCS); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dcs);
if ( client ) if ( client )
{ {
// get client callsign // get client callsign
@ -273,7 +273,7 @@ void CDcsProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DCS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dcs, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -305,7 +305,7 @@ void CDcsProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DCS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dcs, it)) != nullptr )
{ {
// encode client's specific keepalive packet // encode client's specific keepalive packet
CBuffer keepalive2; CBuffer keepalive2;

@ -44,7 +44,7 @@ class CDcsProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -39,7 +39,7 @@ public:
virtual ~CDextraClient() {}; virtual ~CDextraClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DEXTRA; } EProtocol GetProtocol(void) const { return EProtocol::dextra; }
int GetProtocolRevision(void) const { return m_ProtRev; } int GetProtocolRevision(void) const { return m_ProtRev; }
const char *GetProtocolName(void) const { return "DExtra"; } const char *GetProtocolName(void) const { return "DExtra"; }
int GetCodec(void) const { return CODEC_AMBEPLUS; } int GetCodec(void) const { return CODEC_AMBEPLUS; }

@ -34,8 +34,8 @@ public:
bool IsAlive(void) const; bool IsAlive(void) const;
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DEXTRA; } EProtocol GetProtocol(void) const { return EProtocol::dextra; }
const char *GetProtocolName(void) const { return "DExtra"; } const char *GetProtocolName(void) const { return "DExtra"; }
// revision helper // revision helper
static int GetProtocolRevision(const CVersion &); static int GetProtocolRevision(const CVersion &);

@ -28,7 +28,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDextraProtocol::Initialize(const char *type, int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CDextraProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -75,7 +75,7 @@ void CDextraProtocol::Task(void)
else if ( IsValidDvHeaderPacket(Buffer, Header) ) else if ( IsValidDvHeaderPacket(Buffer, Header) )
{ {
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA, Header->GetRpt2Module()) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dextra, Header->GetRpt2Module()) )
{ {
OnDvHeaderPacketIn(Header, Ip); OnDvHeaderPacketIn(Header, Ip);
} }
@ -89,7 +89,7 @@ void CDextraProtocol::Task(void)
std::cout << "DExtra connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << " rev " << ProtRev << std::endl; std::cout << "DExtra connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << " rev " << ProtRev << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DEXTRA) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dextra) )
{ {
// valid module ? // valid module ?
if ( g_Reflector.IsValidModule(ToLinkModule) ) if ( g_Reflector.IsValidModule(ToLinkModule) )
@ -103,7 +103,7 @@ void CDextraProtocol::Task(void)
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
if ( peers->FindPeer(Callsign, Ip, PROTOCOL_DEXTRA) == nullptr ) if ( peers->FindPeer(Callsign, Ip, EProtocol::dextra) == nullptr )
{ {
// create the new peer // create the new peer
// this also create one client per module // this also create one client per module
@ -147,7 +147,7 @@ void CDextraProtocol::Task(void)
// find client & remove it // find client & remove it
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Ip, PROTOCOL_DEXTRA); std::shared_ptr<CClient>client = clients->FindClient(Ip, EProtocol::dextra);
if ( client != nullptr ) if ( client != nullptr )
{ {
// ack disconnect packet // ack disconnect packet
@ -173,7 +173,7 @@ void CDextraProtocol::Task(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(Callsign, Ip, PROTOCOL_DEXTRA, it)) != nullptr ) while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dextra, it)) != nullptr )
{ {
client->Alive(); client->Alive();
} }
@ -234,7 +234,7 @@ void CDextraProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DEXTRA, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dextra, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -268,7 +268,7 @@ void CDextraProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DEXTRA, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dextra, it)) != nullptr )
{ {
// send keepalive // send keepalive
Send(keepalive, client->GetIp()); Send(keepalive, client->GetIp());
@ -283,7 +283,7 @@ void CDextraProtocol::HandleKeepalives(void)
else if ( !client->IsAlive() ) else if ( !client->IsAlive() )
{ {
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(client->GetCallsign(), client->GetIp(), PROTOCOL_DEXTRA); std::shared_ptr<CPeer>peer = peers->FindPeer(client->GetCallsign(), client->GetIp(), EProtocol::dextra);
if ( peer != nullptr && peer->GetReflectorModules()[0] == client->GetReflectorModule() ) if ( peer != nullptr && peer->GetReflectorModules()[0] == client->GetReflectorModule() )
{ {
// no, but this is a peer client, so it will be handled below // no, but this is a peer client, so it will be handled below
@ -309,7 +309,7 @@ void CDextraProtocol::HandleKeepalives(void)
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(PROTOCOL_DEXTRA, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::dextra, pit)) != nullptr )
{ {
// keepalives are sent between clients // keepalives are sent between clients
@ -349,7 +349,7 @@ void CDextraProtocol::HandlePeerLinks(void)
// if not, disconnect // if not, disconnect
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(PROTOCOL_DEXTRA, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::dextra, pit)) != nullptr )
{ {
if ( list->FindListItem(peer->GetCallsign()) == nullptr ) if ( list->FindListItem(peer->GetCallsign()) == nullptr )
{ {
@ -370,7 +370,7 @@ void CDextraProtocol::HandlePeerLinks(void)
continue; continue;
if ( strlen((*it).GetModules()) != 2 ) if ( strlen((*it).GetModules()) != 2 )
continue; continue;
if ( peers->FindPeer((*it).GetCallsign(), PROTOCOL_DEXTRA) == nullptr ) if ( peers->FindPeer((*it).GetCallsign(), EProtocol::dextra) == nullptr )
{ {
// resolve again peer's IP in case it's a dynamic IP // resolve again peer's IP in case it's a dynamic IP
(*it).ResolveIp(); (*it).ResolveIp();
@ -407,7 +407,7 @@ void CDextraProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Heade
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DEXTRA); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dextra);
if ( client ) if ( client )
{ {
// get client callsign // get client callsign

@ -52,7 +52,7 @@ class CDextraProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -32,7 +32,7 @@ public:
virtual ~CDmrmmdvmClient() {}; virtual ~CDmrmmdvmClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DMRMMDVM; } EProtocol GetProtocol(void) const { return EProtocol::dmrmmdvm; }
const char *GetProtocolName(void) const { return "DMRMmdvm"; } const char *GetProtocolName(void) const { return "DMRMmdvm"; }
int GetCodec(void) const { return CODEC_AMBE2PLUS; } int GetCodec(void) const { return CODEC_AMBE2PLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -47,7 +47,7 @@ static uint8_t g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDmrmmdvmProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CDmrmmdvmProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -105,7 +105,7 @@ void CDmrmmdvmProtocol::Task(void)
else if ( IsValidDvHeaderPacket(Buffer, Header, &Cmd, &CallType) ) else if ( IsValidDvHeaderPacket(Buffer, Header, &Cmd, &CallType) )
{ {
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DMRMMDVM) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrmmdvm) )
{ {
// handle it // handle it
OnDvHeaderPacketIn(Header, Ip, Cmd, CallType); OnDvHeaderPacketIn(Header, Ip, Cmd, CallType);
@ -120,7 +120,7 @@ void CDmrmmdvmProtocol::Task(void)
std::cout << "DMRmmdvm connect packet from " << Callsign << " at " << Ip << std::endl; std::cout << "DMRmmdvm connect packet from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DMRMMDVM) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer, Callsign, m_uiAuthSeed); EncodeConnectAckPacket(&Buffer, Callsign, m_uiAuthSeed);
@ -139,7 +139,7 @@ void CDmrmmdvmProtocol::Task(void)
std::cout << "DMRmmdvm authentication packet from " << Callsign << " at " << Ip << std::endl; std::cout << "DMRmmdvm authentication packet from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DMRMMDVM) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) )
{ {
// acknowledge the request // acknowledge the request
EncodeAckPacket(&Buffer, Callsign); EncodeAckPacket(&Buffer, Callsign);
@ -147,7 +147,7 @@ void CDmrmmdvmProtocol::Task(void)
// add client if needed // add client if needed
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, PROTOCOL_DMRMMDVM); std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, EProtocol::dmrmmdvm);
// client already connected ? // client already connected ?
if ( client == nullptr ) if ( client == nullptr )
{ {
@ -177,7 +177,7 @@ void CDmrmmdvmProtocol::Task(void)
// find client & remove it // find client & remove it
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Ip, PROTOCOL_DMRMMDVM); std::shared_ptr<CClient>client = clients->FindClient(Ip, EProtocol::dmrmmdvm);
if ( client != nullptr ) if ( client != nullptr )
{ {
clients->RemoveClient(client); clients->RemoveClient(client);
@ -200,7 +200,7 @@ void CDmrmmdvmProtocol::Task(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(Callsign, Ip, PROTOCOL_DMRMMDVM, it)) != nullptr ) while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dmrmmdvm, it)) != nullptr )
{ {
// acknowledge // acknowledge
EncodeKeepAlivePacket(&Buffer, client); EncodeKeepAlivePacket(&Buffer, client);
@ -273,7 +273,7 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Hea
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one // no stream open yet, open a new one
// firstfind this client // firstfind this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DMRMMDVM); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dmrmmdvm);
if ( client ) if ( client )
{ {
// process cmd if any // process cmd if any
@ -413,7 +413,7 @@ void CDmrmmdvmProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DMRMMDVM, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dmrmmdvm, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -442,7 +442,7 @@ void CDmrmmdvmProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DMRMMDVM, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dmrmmdvm, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( client->IsAMaster() ) if ( client->IsAMaster() )

@ -60,7 +60,7 @@ class CDmrmmdvmProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -32,7 +32,7 @@ public:
virtual ~CDmrplusClient() {}; virtual ~CDmrplusClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DMRPLUS; } EProtocol GetProtocol(void) const { return EProtocol::dmrplus; }
const char *GetProtocolName(void) const { return "DMRplus"; } const char *GetProtocolName(void) const { return "DMRplus"; }
int GetCodec(void) const { return CODEC_AMBE2PLUS; } int GetCodec(void) const { return CODEC_AMBE2PLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -40,7 +40,7 @@ static uint8_t g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDmrplusProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CDmrplusProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -93,7 +93,7 @@ void CDmrplusProtocol::Task(void)
else if ( IsValidDvHeaderPacket(Ip, Buffer, Header) ) else if ( IsValidDvHeaderPacket(Ip, Buffer, Header) )
{ {
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DMRPLUS) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrplus) )
{ {
// handle it // handle it
OnDvHeaderPacketIn(Header, Ip); OnDvHeaderPacketIn(Header, Ip);
@ -104,7 +104,7 @@ void CDmrplusProtocol::Task(void)
//std::cout << "DMRplus keepalive/connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; //std::cout << "DMRplus keepalive/connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DMRPLUS) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrplus) )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer); EncodeConnectAckPacket(&Buffer);
@ -112,7 +112,7 @@ void CDmrplusProtocol::Task(void)
// add client if needed // add client if needed
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, PROTOCOL_DMRPLUS); std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, EProtocol::dmrplus);
// client already connected ? // client already connected ?
if ( client == nullptr ) if ( client == nullptr )
{ {
@ -142,7 +142,7 @@ void CDmrplusProtocol::Task(void)
// find client & remove it // find client & remove it
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Ip, PROTOCOL_DMRPLUS); std::shared_ptr<CClient>client = clients->FindClient(Ip, EProtocol::dmrplus);
if ( client != nullptr ) if ( client != nullptr )
{ {
clients->RemoveClient(client); clients->RemoveClient(client);
@ -196,7 +196,7 @@ void CDmrplusProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Head
// no stream open yet, open a new one // no stream open yet, open a new one
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DMRPLUS); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dmrplus);
if ( client ) if ( client )
{ {
// and try to open the stream // and try to open the stream
@ -278,7 +278,7 @@ void CDmrplusProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DMRPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -304,7 +304,7 @@ void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8_t module
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DMRPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == module) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == module) )
@ -334,7 +334,7 @@ void CDmrplusProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DMRPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( client->IsAMaster() ) if ( client->IsAMaster() )

@ -50,7 +50,7 @@ class CDmrplusProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int pytpe, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol pytpe, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -32,7 +32,7 @@ public:
virtual ~CDplusClient() {}; virtual ~CDplusClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_DPLUS; } EProtocol GetProtocol(void) const { return EProtocol::dplus; }
const char *GetProtocolName(void) const { return "DPlus"; } const char *GetProtocolName(void) const { return "DPlus"; }
int GetCodec(void) const { return CODEC_AMBEPLUS; } int GetCodec(void) const { return CODEC_AMBEPLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDplusProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CDplusProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -73,7 +73,7 @@ void CDplusProtocol::Task(void)
else if ( IsValidDvHeaderPacket(Buffer, Header) ) else if ( IsValidDvHeaderPacket(Buffer, Header) )
{ {
// is muted? // is muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DPLUS, Header->GetRpt2Module()) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dplus, Header->GetRpt2Module()) )
{ {
// handle it // handle it
OnDvHeaderPacketIn(Header, Ip); OnDvHeaderPacketIn(Header, Ip);
@ -95,7 +95,7 @@ void CDplusProtocol::Task(void)
std::cout << "DPlus login packet from " << Callsign << " at " << Ip << std::endl; std::cout << "DPlus login packet from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DPLUS) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dplus) )
{ {
// acknowledge the request // acknowledge the request
EncodeLoginAckPacket(&Buffer); EncodeLoginAckPacket(&Buffer);
@ -119,7 +119,7 @@ void CDplusProtocol::Task(void)
// find client // find client
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Ip, PROTOCOL_DPLUS); std::shared_ptr<CClient>client = clients->FindClient(Ip, EProtocol::dplus);
if ( client != nullptr ) if ( client != nullptr )
{ {
// remove it // remove it
@ -138,7 +138,7 @@ void CDplusProtocol::Task(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(Ip, PROTOCOL_DPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(Ip, EProtocol::dplus, it)) != nullptr )
{ {
client->Alive(); client->Alive();
} }
@ -193,7 +193,7 @@ void CDplusProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header
if ( g_Reflector.IsValidModule(rpt2.GetModule()) ) if ( g_Reflector.IsValidModule(rpt2.GetModule()) )
{ {
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DPLUS); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dplus);
if ( client ) if ( client )
{ {
// now we know if it's a dextra dongle or a genuine dplus node // now we know if it's a dextra dongle or a genuine dplus node
@ -262,7 +262,7 @@ void CDplusProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dplus, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() ) if ( !client->IsAMaster() )
@ -352,7 +352,7 @@ void CDplusProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_DPLUS, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::dplus, it)) != nullptr )
{ {
// send keepalive // send keepalive
//std::cout << "Sending DPlus packet @ " << client->GetIp() << std::endl; //std::cout << "Sending DPlus packet @ " << client->GetIp() << std::endl;

@ -39,7 +39,7 @@ class CDplusProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -32,7 +32,7 @@ public:
virtual ~CG3Client() {}; virtual ~CG3Client() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_G3; } EProtocol GetProtocol(void) const { return EProtocol::g3; }
const char *GetProtocolName(void) const { return "Terminal/AP"; } const char *GetProtocolName(void) const { return "Terminal/AP"; }
int GetCodec(void) const { return CODEC_AMBEPLUS; } int GetCodec(void) const { return CODEC_AMBEPLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -31,7 +31,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uint16_t /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/) bool CG3Protocol::Initialize(const char */*type*/, const EProtocol /*type*/, const uint16_t /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/)
// everything is hard coded until ICOM gets their act together and start supporting IPv6 // everything is hard coded until ICOM gets their act together and start supporting IPv6
{ {
ReadOptions(); ReadOptions();
@ -46,8 +46,7 @@ bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uin
//m_ReflectorCallsign.PatchCallsign(0, (const uint8_t *)"XLX", 3); //m_ReflectorCallsign.PatchCallsign(0, (const uint8_t *)"XLX", 3);
// create our sockets // create our sockets
auto s = g_Reflector.m_Address.GetV4Address(PROTOCOL_G3); CIp ip(AF_INET, G3_DV_PORT, LISTEN_IPV4);
CIp ip(AF_INET, G3_DV_PORT, s.c_str());
if ( ip.IsSet() ) if ( ip.IsSet() )
{ {
if (! m_Socket4.Open(ip)) if (! m_Socket4.Open(ip))
@ -181,7 +180,7 @@ void CG3Protocol::PresenceTask(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>extant = nullptr; std::shared_ptr<CClient>extant = nullptr;
while ( (extant = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (extant = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
CIp ClIp = extant->GetIp(); CIp ClIp = extant->GetIp();
if (ClIp.GetAddr() == Ip.GetAddr()) if (ClIp.GetAddr() == Ip.GetAddr())
@ -195,7 +194,7 @@ void CG3Protocol::PresenceTask(void)
it = clients->begin(); it = clients->begin();
// do we already have a client with the same call (IP changed)? // do we already have a client with the same call (IP changed)?
while ( (extant = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (extant = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
if (extant->GetCallsign().HasSameCallsign(Terminal)) if (extant->GetCallsign().HasSameCallsign(Terminal))
{ {
@ -347,7 +346,7 @@ void CG3Protocol::IcmpTask(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
CIp ClientIp = client->GetIp(); CIp ClientIp = client->GetIp();
if (ClientIp.GetAddr() == Ip.GetAddr()) if (ClientIp.GetAddr() == Ip.GetAddr())
@ -383,7 +382,7 @@ void CG3Protocol::Task(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
ClIp = client->GetIp(); ClIp = client->GetIp();
if (ClIp.GetAddr() == Ip.GetAddr()) if (ClIp.GetAddr() == Ip.GetAddr())
@ -408,7 +407,7 @@ void CG3Protocol::Task(void)
else if ( IsValidDvHeaderPacket(Buffer, Header) ) else if ( IsValidDvHeaderPacket(Buffer, Header) )
{ {
// callsign muted? // callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_G3, Header->GetRpt2Module()) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::g3, Header->GetRpt2Module()) )
{ {
// handle it // handle it
OnDvHeaderPacketIn(Header, *BaseIp); OnDvHeaderPacketIn(Header, *BaseIp);
@ -464,7 +463,7 @@ void CG3Protocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -497,7 +496,7 @@ void CG3Protocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
if (!client->IsAlive()) if (!client->IsAlive())
{ {
@ -537,7 +536,7 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, c
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
CIp ClIp = client->GetIp(); CIp ClIp = client->GetIp();
if (ClIp.GetAddr() == Ip.GetAddr()) if (ClIp.GetAddr() == Ip.GetAddr())
@ -705,7 +704,7 @@ void CG3Protocol::NeedReload(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_G3, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
{ {
char module = client->GetReflectorModule(); char module = client->GetReflectorModule();
if (!strchr(m_Modules.c_str(), module) && !strchr(m_Modules.c_str(), '*')) if (!strchr(m_Modules.c_str(), module) && !strchr(m_Modules.c_str(), '*'))

@ -60,7 +60,7 @@ public:
CG3Protocol() : m_GwAddress(0u), m_Modules("*"), m_LastModTime(0) {} CG3Protocol() : m_GwAddress(0u), m_Modules("*"), m_LastModTime(0) {}
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// close // close
void Close(void); void Close(void);

@ -75,21 +75,21 @@ void CGateKeeper::Close(void)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// authorisations // authorisations
bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, int protocol, char *modules) const bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, EProtocol protocol, char *modules) const
{ {
bool ok = true; bool ok = true;
switch (protocol) switch (protocol)
{ {
// repeaters // repeaters
case PROTOCOL_DEXTRA: case EProtocol::dextra:
case PROTOCOL_DPLUS: case EProtocol::dplus:
case PROTOCOL_DCS: case EProtocol::dcs:
case PROTOCOL_DMRPLUS: case EProtocol::dmrplus:
case PROTOCOL_DMRMMDVM: case EProtocol::dmrmmdvm:
case PROTOCOL_YSF: case EProtocol::ysf:
#ifndef NO_G3 #ifndef NO_G3
case PROTOCOL_G3: case EProtocol::g3:
#endif #endif
// first check is IP & callsigned listed OK // first check is IP & callsigned listed OK
ok &= IsNodeListedOk(callsign, ip); ok &= IsNodeListedOk(callsign, ip);
@ -97,12 +97,12 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, int protocol
break; break;
// XLX interlinks // XLX interlinks
case PROTOCOL_XLX: case EProtocol::ulx:
ok &= IsPeerListedOk(callsign, ip, modules); ok &= IsPeerListedOk(callsign, ip, modules);
break; break;
// unsupported // unsupported
case PROTOCOL_NONE: case EProtocol::none:
default: default:
ok = false; ok = false;
break; break;
@ -111,29 +111,29 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, int protocol
// report // report
if ( !ok ) if ( !ok )
{ {
std::cout << "Gatekeeper blocking linking of " << callsign << " @ " << ip << " using protocol " << protocol << std::endl; std::cout << "Gatekeeper blocking linking of " << callsign << " @ " << ip << " using protocol " << ProtocolName(protocol) << std::endl;
} }
// done // done
return ok; return ok;
} }
bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int protocol, char module) const bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, const EProtocol protocol, char module) const
{ {
bool ok = true; bool ok = true;
switch (protocol) switch (protocol)
{ {
// repeaters, protocol specific // repeaters, protocol specific
case PROTOCOL_ANY: case EProtocol::any:
case PROTOCOL_DEXTRA: case EProtocol::dextra:
case PROTOCOL_DPLUS: case EProtocol::dplus:
case PROTOCOL_DCS: case EProtocol::dcs:
case PROTOCOL_DMRPLUS: case EProtocol::dmrplus:
case PROTOCOL_DMRMMDVM: case EProtocol::dmrmmdvm:
case PROTOCOL_YSF: case EProtocol::ysf:
#ifndef NO_G3 #ifndef NO_G3
case PROTOCOL_G3: case EProtocol::g3:
#endif #endif
// first check is IP & callsigned listed OK // first check is IP & callsigned listed OK
ok = ok && IsNodeListedOk(callsign, ip, module); ok = ok && IsNodeListedOk(callsign, ip, module);
@ -141,12 +141,12 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int prot
break; break;
// XLX interlinks // XLX interlinks
case PROTOCOL_XLX: case EProtocol::ulx:
ok = ok && IsPeerListedOk(callsign, ip, module); ok = ok && IsPeerListedOk(callsign, ip, module);
break; break;
// unsupported // unsupported
case PROTOCOL_NONE: case EProtocol::none:
default: default:
ok = false; ok = false;
break; break;
@ -155,7 +155,7 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int prot
// report // report
if ( !ok ) if ( !ok )
{ {
std::cout << "Gatekeeper blocking transmitting of " << callsign << " @ " << ip << " using protocol " << protocol << std::endl; std::cout << "Gatekeeper blocking transmitting of " << callsign << " @ " << ip << " using protocol " << ProtocolName(protocol) << std::endl;
} }
// done // done
@ -264,3 +264,29 @@ bool CGateKeeper::IsPeerListedOk(const CCallsign &callsign, const CIp &ip, char
// done // done
return ok; return ok;
} }
const std::string CGateKeeper::ProtocolName(const EProtocol p) const
{
switch (p) {
case EProtocol::any:
return "ANY";
case EProtocol::dcs:
return "DCS";
case EProtocol::dextra:
return "DExtra";
case EProtocol::dmrmmdvm:
return "MMDVM DMR";
case EProtocol::dmrplus:
return "DMR+";
case EProtocol::ulx:
return "ULX";
case EProtocol::ysf:
return "YSF";
#ifndef NO_G3
case EProtocol::g3:
return "Icom G3";
#endif
default:
return "NONE";
}
}

@ -42,8 +42,8 @@ public:
void Close(void); void Close(void);
// authorizations // authorizations
bool MayLink(const CCallsign &, const CIp &, int, char * = nullptr) const; bool MayLink(const CCallsign &, const CIp &, const EProtocol, char * = nullptr) const;
bool MayTransmit(const CCallsign &, const CIp &, int = PROTOCOL_ANY, char = ' ') const; bool MayTransmit(const CCallsign &, const CIp &, EProtocol = EProtocol::any, char = ' ') const;
// peer list handeling // peer list handeling
CPeerCallsignList *GetPeerList(void) { m_PeerList.Lock(); return &m_PeerList; } CPeerCallsignList *GetPeerList(void) { m_PeerList.Lock(); return &m_PeerList; }
@ -57,6 +57,7 @@ protected:
bool IsNodeListedOk(const CCallsign &, const CIp &, char = ' ') const; bool IsNodeListedOk(const CCallsign &, const CIp &, char = ' ') const;
bool IsPeerListedOk(const CCallsign &, const CIp &, char) const; bool IsPeerListedOk(const CCallsign &, const CIp &, char) const;
bool IsPeerListedOk(const CCallsign &, const CIp &, char *) const; bool IsPeerListedOk(const CCallsign &, const CIp &, char *) const;
const std::string ProtocolName(EProtocol) const;
protected: protected:
// data // data

@ -71,17 +71,10 @@
// protocols --------------------------------------------------- // protocols ---------------------------------------------------
#define PROTOCOL_ANY -1
#define PROTOCOL_NONE 0
#define PROTOCOL_DEXTRA 1
#define PROTOCOL_DPLUS 2
#define PROTOCOL_DCS 3
#define PROTOCOL_XLX 4
#define PROTOCOL_DMRPLUS 5
#define PROTOCOL_DMRMMDVM 6
#define PROTOCOL_YSF 7
#ifndef NO_G3 #ifndef NO_G3
#define PROTOCOL_G3 8 enum class EProtocol { any, none, dextra, dplus, dcs, ulx, dmrplus, dmrmmdvm, ysf, g3 };
#else
enum class EProtocol { any, none, dextra, dplus, dcs, xlx, dmrplus, dmrmmdvm, ysf };
#endif #endif
// DExtra // DExtra

@ -36,18 +36,16 @@ endif
LDFLAGS=-pthread LDFLAGS=-pthread
XRFSRCS = Buffer.cpp Callsign.cpp CallsignList.cpp CallsignListItem.cpp Client.cpp Clients.cpp DCSClient.cpp DCSProtocol.cpp DExtraClient.cpp DExtraPeer.cpp DExtraProtocol.cpp DPlusClient.cpp DPlusProtocol.cpp DVFramePacket.cpp DVHeaderPacket.cpp DVLastFramePacket.cpp GateKeeper.cpp IP.cpp Notification.cpp Packet.cpp PacketStream.cpp PeerCallsignList.cpp Peer.cpp Peers.cpp ProtoAddress.cpp Protocol.cpp Protocols.cpp Reflector.cpp UDPSocket.cpp User.cpp Users.cpp Version.cpp Main.cpp XRFSRCS = Buffer.cpp Callsign.cpp CallsignList.cpp CallsignListItem.cpp Client.cpp Clients.cpp DCSClient.cpp DCSProtocol.cpp DExtraClient.cpp DExtraPeer.cpp DExtraProtocol.cpp DPlusClient.cpp DPlusProtocol.cpp DVFramePacket.cpp DVHeaderPacket.cpp DVLastFramePacket.cpp GateKeeper.cpp IP.cpp Notification.cpp Packet.cpp PacketStream.cpp PeerCallsignList.cpp Peer.cpp Peers.cpp Protocol.cpp Protocols.cpp Reflector.cpp UDPSocket.cpp User.cpp Users.cpp Version.cpp Main.cpp
XLXSRCS = BMClient.cpp BMPeer.cpp BPTC19696.cpp CRC.cpp DMRIdDir.cpp DMRIdDirFile.cpp DMRIdDirHttp.cpp DMRMMDVMClient.cpp DMRMMDVMProtocol.cpp DMRPlusClient.cpp DMRPlusProtocol.cpp Golay2087.cpp Golay24128.cpp Hamming.cpp QR1676.cpp RS129.cpp Semaphore.cpp Utils.cpp WiresXCmd.cpp WiresXCmdHandler.cpp WiresXInfo.cpp ULXClient.cpp ULXProtocol.cpp ULXPeer.cpp YSFClient.cpp YSFConvolution.cpp YSFFich.cpp YSFNode.cpp YSFNodeDir.cpp YSFNodeDirFile.cpp YSFNodeDirHttp.cpp YSFPayload.cpp YSFProtocol.cpp YSFUtils.cpp XLXSRCS = BMClient.cpp BMPeer.cpp BPTC19696.cpp CRC.cpp DMRIdDir.cpp DMRIdDirFile.cpp DMRIdDirHttp.cpp DMRMMDVMClient.cpp DMRMMDVMProtocol.cpp DMRPlusClient.cpp DMRPlusProtocol.cpp Golay2087.cpp Golay24128.cpp Hamming.cpp QR1676.cpp RS129.cpp Semaphore.cpp Utils.cpp WiresXCmd.cpp WiresXCmdHandler.cpp WiresXInfo.cpp ULXClient.cpp ULXProtocol.cpp ULXPeer.cpp YSFClient.cpp YSFConvolution.cpp YSFFich.cpp YSFNode.cpp YSFNodeDir.cpp YSFNodeDirFile.cpp YSFNodeDirHttp.cpp YSFPayload.cpp YSFProtocol.cpp YSFUtils.cpp
G3SRCS = G3Client.cpp G3Protocol.cpp RawSocket.cpp UDPMsgSocket.cpp G3SRCS = G3Client.cpp G3Protocol.cpp RawSocket.cpp UDPMsgSocket.cpp
SRCS = $(XRFSRCS) SRCS = $(XRFSRCS)
ifeq ($(is_xlx), true)
SRCS += $(XLXSRCS) SRCS += $(XLXSRCS)
ifeq ($(ysf_db), true) ifeq ($(ysf_db), true)
LDFLAGS += `mysql_config --libs` LDFLAGS += `mysql_config --libs`
endif endif
endif
ifdef tc_ip ifdef tc_ip
SRCS += Transcoder.cpp CodecStream.cpp SRCS += Transcoder.cpp CodecStream.cpp
@ -60,11 +58,7 @@ endif
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d) DEPS = $(SRCS:.cpp=.d)
ifeq ($(is_xlx), true)
EXE=ulxd EXE=ulxd
else
EXE=xrfd
endif
all : $(EXE) all : $(EXE)

@ -46,9 +46,9 @@ public:
// set // set
// identity // identity
virtual int GetProtocol(void) const { return PROTOCOL_NONE; } virtual EProtocol GetProtocol(void) const { return EProtocol::none; }
virtual int GetProtocolRevision(void) const { return 0; } virtual int GetProtocolRevision(void) const { return 0; }
virtual const char *GetProtocolName(void) const { return "none"; } virtual const char *GetProtocolName(void) const { return "NONE"; }
// status // status
virtual bool IsAMaster(void) const; virtual bool IsAMaster(void) const;

@ -107,7 +107,7 @@ void CPeers::RemovePeer(std::shared_ptr<CPeer> peer)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// find peers // find peers
std::shared_ptr<CPeer> CPeers::FindPeer(const CIp &Ip, int Protocol) std::shared_ptr<CPeer> CPeers::FindPeer(const CIp &Ip, const EProtocol Protocol)
{ {
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
@ -120,7 +120,7 @@ std::shared_ptr<CPeer> CPeers::FindPeer(const CIp &Ip, int Protocol)
return nullptr; return nullptr;
} }
std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, const CIp &Ip, int Protocol) std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, const CIp &Ip, const EProtocol Protocol)
{ {
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
@ -133,7 +133,7 @@ std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, const CIp &Ip
return nullptr; return nullptr;
} }
std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, int Protocol) std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, const EProtocol Protocol)
{ {
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
@ -150,7 +150,7 @@ std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, int Protocol)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// iterate on peers // iterate on peers
std::shared_ptr<CPeer> CPeers::FindNextPeer(int Protocol, std::list<std::shared_ptr<CPeer>>::iterator &it) std::shared_ptr<CPeer> CPeers::FindNextPeer(const EProtocol Protocol, std::list<std::shared_ptr<CPeer>>::iterator &it)
{ {
while ( it!=end() ) while ( it!=end() )
{ {

@ -45,12 +45,12 @@ public:
std::list<std::shared_ptr<CPeer>>::const_iterator cend() const { return m_Peers.cend(); } std::list<std::shared_ptr<CPeer>>::const_iterator cend() const { return m_Peers.cend(); }
// find peers // find peers
std::shared_ptr<CPeer> FindPeer(const CIp &, int); std::shared_ptr<CPeer> FindPeer(const CIp &, const EProtocol);
std::shared_ptr<CPeer> FindPeer(const CCallsign &, const CIp &, int); std::shared_ptr<CPeer> FindPeer(const CCallsign &, const CIp &, const EProtocol);
std::shared_ptr<CPeer> FindPeer(const CCallsign &, int); std::shared_ptr<CPeer> FindPeer(const CCallsign &, const EProtocol);
// iterate on peers // iterate on peers
std::shared_ptr<CPeer> FindNextPeer(int, std::list<std::shared_ptr<CPeer>>::iterator &); std::shared_ptr<CPeer> FindNextPeer(const EProtocol, std::list<std::shared_ptr<CPeer>>::iterator &);
protected: protected:
// data // data

@ -1,96 +0,0 @@
// ulxd -- 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 "ProtoAddress.h"
CProtoAddress::CProtoAddress()
{
#ifdef LISTEN_IPV4
v4address[PROTOCOL_ANY] = LISTEN_IPV4;
#endif
#ifdef LISTEN_V4_DPLUS
v4address[PROTOCOL_DPLUS] = LISTEN_V4_DPLUS;
#endif
#ifdef LISTEN_V4_DCS
v4address[PROTOCOL_DCS] = LISTEN_V4_DCS;
#endif
#ifdef LISTEN_V4_DEXTRA
v4address[PROTOCOL_DEXTRA] = LISTEN_V4_DEXTRA;
#endif
#ifdef LISTEN_V4_DMRMMDVM
v4address[PROTOCOL_DMRMMDVM] = LISTEN_V4_DMRMMDVM;
#endif
#ifdef LISTEN_V4_DMRPLUS
v4address[PROTOCOL_DMRPLUS] = LISTEN_V4_DMRPLUS;
#endif
#ifdef LISTEN_V4_YSF
v4address[PROTOCOL_YSF] = LISTEN_V4_YSF;
#endif
#ifdef LISTEN_V4_XLX
v4address[PROTOCOL_XLX] = LISTEN_V4_XLX;
#endif
#ifdef LISTEN_V4_G3
v4address[PROTOCOL_G3] = LISTEN_V4_G3;
#endif
#ifdef LISTEN_IPV6
v6address[PROTOCOL_ANY] = LISTEN_IPV6;
#endif
#ifdef LISTEN_V6_DPLUS
v6address[PROTOCOL_DPLUS] = LISTEN_V6_DPLUS;
#endif
#ifdef LISTEN_V6_DCS
v6address[PROTOCOL_DCS] = LISTEN_V6_DCS;
#endif
#ifdef LISTEN_V6_DEXTRA
v6address[PROTOCOL_DEXTRA] = LISTEN_V6_DEXTRA;
#endif
#ifdef LISTEN_V6_DMRMMDVM
v6address[PROTOCOL_DMRMMDVM] = LISTEN_V6_DMRMMDVM;
#endif
#ifdef LISTEN_V6_DMRPLUS
v6address[PROTOCOL_DMRPLUS] = LISTEN_V6_DMRPLUS;
#endif
#ifdef LISTEN_V6_YSF
v6address[PROTOCOL_YSF] = LISTEN_V6_YSF;
#endif
#ifdef LISTEN_V6_XLX
v6address[PROTOCOL_XLX] = LISTEN_V6_XLX;
#endif
#ifdef LISTEN_V6_G3
v6address[PROTOCOL_G3] = LISTEN_V6_G3;
#endif
}
#ifdef LISTEN_IPV4
std::string CProtoAddress::GetV4Address(int protocol)
{
if (v4address.end() == v4address.find(protocol))
return v4address[PROTOCOL_ANY];
else
return v4address[protocol];
}
#endif
#ifdef LISTEN_IPV6
std::string CProtoAddress::GetV6Address(int protocol)
{
if (v6address.end() == v6address.find(protocol))
return v6address[PROTOCOL_ANY];
else
return v6address[protocol];
}
#endif

@ -1,42 +0,0 @@
// ulxd -- 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/>.
#pragma once
#include <unordered_map>
#include <string>
#include "Main.h"
class CProtoAddress
{
public:
CProtoAddress();
#ifdef LISTEN_IPV4
std::string GetV4Address(int protocol);
#endif
#ifdef LISTEN_IPV6
std::string GetV6Address(int protocol);
#endif
private:
#ifdef LISTEN_IPV4
std::unordered_map<int, std::string> v4address;
#endif
#ifdef LISTEN_IPV6
std::unordered_map<int, std::string> v6address;
#endif
};

@ -49,7 +49,7 @@ CProtocol::~CProtocol()
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// initialization // initialization
bool CProtocol::Initialize(const char *type, int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// init reflector apparent callsign // init reflector apparent callsign
m_ReflectorCallsign = g_Reflector.GetCallsign(); m_ReflectorCallsign = g_Reflector.GetCallsign();
@ -65,8 +65,7 @@ bool CProtocol::Initialize(const char *type, int ptype, const uint16_t port, con
#ifdef LISTEN_IPV4 #ifdef LISTEN_IPV4
if (has_ipv4) if (has_ipv4)
{ {
const auto s = g_Reflector.m_Address.GetV4Address(ptype); CIp ip4(AF_INET, port, LISTEN_IPV4);
CIp ip4(AF_INET, port, s.c_str());
if ( ip4.IsSet() ) if ( ip4.IsSet() )
{ {
if (! m_Socket4.Open(ip4)) if (! m_Socket4.Open(ip4))
@ -79,7 +78,7 @@ bool CProtocol::Initialize(const char *type, int ptype, const uint16_t port, con
#ifdef LISTEN_IPV6 #ifdef LISTEN_IPV6
if (has_ipv6) if (has_ipv6)
{ {
CIp ip6(AF_INET6, port, g_Reflector.m_Address.GetV6Address(ptype).c_str()); CIp ip6(AF_INET6, port, LISTEN_IPV6);
if ( ip6.IsSet() ) if ( ip6.IsSet() )
{ {
if (! m_Socket6.Open(ip6)) if (! m_Socket6.Open(ip6))

@ -69,7 +69,7 @@ public:
virtual ~CProtocol(); virtual ~CProtocol();
// initialization // initialization
virtual bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); virtual bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
virtual void Close(void); virtual void Close(void);
// queue // queue

@ -45,36 +45,36 @@ bool CProtocols::Init(void)
m_Mutex.lock(); m_Mutex.lock();
{ {
m_Protocols.emplace_back(std::unique_ptr<CDextraProtocol>(new CDextraProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDextraProtocol>(new CDextraProtocol));
if (! m_Protocols.back()->Initialize("XRF", PROTOCOL_DEXTRA, DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6)) if (! m_Protocols.back()->Initialize("XRF", EProtocol::dextra, DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CDplusProtocol>(new CDplusProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDplusProtocol>(new CDplusProtocol));
if (! m_Protocols.back()->Initialize("REF", PROTOCOL_DPLUS, DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6)) if (! m_Protocols.back()->Initialize("REF", EProtocol::dplus, DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CDcsProtocol>(new CDcsProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDcsProtocol>(new CDcsProtocol));
if (! m_Protocols.back()->Initialize("DCS", PROTOCOL_DCS, DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) if (! m_Protocols.back()->Initialize("DCS", EProtocol::dcs, DCS_PORT, DSTAR_IPV4, DSTAR_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CDmrmmdvmProtocol>(new CDmrmmdvmProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDmrmmdvmProtocol>(new CDmrmmdvmProtocol));
if (! m_Protocols.back()->Initialize(nullptr, PROTOCOL_DMRMMDVM, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6)) if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrmmdvm, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CDmrplusProtocol>(new CDmrplusProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDmrplusProtocol>(new CDmrplusProtocol));
if (! m_Protocols.back()->Initialize(nullptr, PROTOCOL_DMRPLUS, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6)) if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrplus, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CYsfProtocol>(new CYsfProtocol)); m_Protocols.emplace_back(std::unique_ptr<CYsfProtocol>(new CYsfProtocol));
if (! m_Protocols.back()->Initialize("YSF", PROTOCOL_YSF, YSF_PORT, YSF_IPV4, YSF_IPV6)) if (! m_Protocols.back()->Initialize("YSF", EProtocol::ysf, YSF_PORT, YSF_IPV4, YSF_IPV6))
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CUlxProtocol>(new CUlxProtocol)); m_Protocols.emplace_back(std::unique_ptr<CUlxProtocol>(new CUlxProtocol));
if (! m_Protocols.back()->Initialize("XLX", PROTOCOL_XLX, XLX_PORT, DMR_IPV4, DMR_IPV6)) if (! m_Protocols.back()->Initialize("XLX", EProtocol::ulx, XLX_PORT, DMR_IPV4, DMR_IPV6))
return false; return false;
#ifndef NO_G3 #ifndef NO_G3
m_Protocols.emplace_back(std::unique_ptr<CG3Protocol>(new CG3Protocol)); m_Protocols.emplace_back(std::unique_ptr<CG3Protocol>(new CG3Protocol));
if (! m_Protocols.back()->Initialize("XLX", PROTOCOL_G3, G3_DV_PORT, DMR_IPV4, DMR_IPV6)) if (! m_Protocols.back()->Initialize("XLX", EProtocol::g3, G3_DV_PORT, DMR_IPV4, DMR_IPV6))
return false; return false;
#endif #endif

@ -18,7 +18,6 @@
#pragma once #pragma once
#include "ProtoAddress.h"
#include "Users.h" #include "Users.h"
#include "Clients.h" #include "Clients.h"
#include "Peers.h" #include "Peers.h"
@ -78,9 +77,6 @@ public:
CUsers *GetUsers(void) { m_Users.Lock(); return &m_Users; } CUsers *GetUsers(void) { m_Users.Lock(); return &m_Users; }
void ReleaseUsers(void) { m_Users.Unlock(); } void ReleaseUsers(void) { m_Users.Unlock(); }
// IP Addresses
CProtoAddress m_Address;
// get // get
bool IsValidModule(char c) const { return (GetModuleIndex(c) >= 0); } bool IsValidModule(char c) const { return (GetModuleIndex(c) >= 0); }
int GetModuleIndex(char) const; int GetModuleIndex(char) const;

@ -76,14 +76,14 @@ bool CTranscoder::Init(void)
// now open the transcoder port // now open the transcoder port
#ifdef LISTEN_IPV4 #ifdef LISTEN_IPV4
#ifdef LISTEN_IPV6 #ifdef LISTEN_IPV6
const auto paddr = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY) : g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY); auto paddr = (AF_INET == m_Ip.GetFamily()) ? LISTEN_IPV4 : LISTEN_IPV6;
#else #else
const auto paddr = g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY); auto paddr = LISTEN_IPV4;
#endif #endif
#else #else
const auto paddr = g_Reflector.m_address.GetV6Address(PROTOCOL_ANY); auto paddr = LISTEN_IPV6;
#endif #endif
CIp tc(m_Ip.GetFamily(), TRANSCODER_PORT, paddr.c_str()); CIp tc(m_Ip.GetFamily(), TRANSCODER_PORT, paddr);
// create our socket // create our socket
if (tc.IsSet()) if (tc.IsSet())

@ -36,7 +36,7 @@ public:
virtual ~CUlxClient() {}; virtual ~CUlxClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_XLX; } EProtocol GetProtocol(void) const { return EProtocol::ulx; }
int GetProtocolRevision(void) const { return m_ProtRev; } int GetProtocolRevision(void) const { return m_ProtRev; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "XLX"; }
int GetCodec(void) const; int GetCodec(void) const;

@ -33,8 +33,8 @@ public:
bool IsAlive(void) const; bool IsAlive(void) const;
// identity // identity
int GetProtocol(void) const { return PROTOCOL_XLX; } EProtocol GetProtocol(void) const { return EProtocol::ulx; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "ULX"; }
// revision helper // revision helper
static int GetProtocolRevision(const CVersion &); static int GetProtocolRevision(const CVersion &);

@ -28,7 +28,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CUlxProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CUlxProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
return false; return false;
@ -88,7 +88,7 @@ void CUlxProtocol::Task(void)
std::cout << "XLX (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; std::cout << "XLX (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_XLX, Modules) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::ulx, Modules) )
{ {
// acknowledge connecting request // acknowledge connecting request
// following is version dependent // following is version dependent
@ -98,7 +98,7 @@ void CUlxProtocol::Task(void)
{ {
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
if ( peers->FindPeer(Callsign, Ip, PROTOCOL_XLX) == nullptr ) if ( peers->FindPeer(Callsign, Ip, EProtocol::ulx) == nullptr )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules); EncodeConnectAckPacket(&Buffer, Modules);
@ -129,11 +129,11 @@ void CUlxProtocol::Task(void)
std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_XLX, Modules) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::ulx, Modules) )
{ {
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
if ( peers->FindPeer(Callsign, Ip, PROTOCOL_XLX) == nullptr ) if ( peers->FindPeer(Callsign, Ip, EProtocol::ulx) == nullptr )
{ {
// create the new peer // create the new peer
// this also create one client per module // this also create one client per module
@ -152,7 +152,7 @@ void CUlxProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, PROTOCOL_XLX); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::ulx);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// remove it from reflector peer list // remove it from reflector peer list
@ -172,7 +172,7 @@ void CUlxProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, PROTOCOL_XLX); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::ulx);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// keep it alive // keep it alive
@ -247,7 +247,7 @@ void CUlxProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_XLX, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::ulx, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -298,7 +298,7 @@ void CUlxProtocol::HandleKeepalives(void)
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(PROTOCOL_XLX, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::ulx, pit)) != nullptr )
{ {
// send keepalive // send keepalive
Send(keepalive, peer->GetIp()); Send(keepalive, peer->GetIp());
@ -340,7 +340,7 @@ void CUlxProtocol::HandlePeerLinks(void)
// if not, disconnect // if not, disconnect
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(PROTOCOL_XLX, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::ulx, pit)) != nullptr )
{ {
if ( list->FindListItem(peer->GetCallsign()) == nullptr ) if ( list->FindListItem(peer->GetCallsign()) == nullptr )
{ {
@ -359,7 +359,7 @@ void CUlxProtocol::HandlePeerLinks(void)
{ {
if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) ) if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) )
continue; continue;
if ( peers->FindPeer((*it).GetCallsign(), PROTOCOL_XLX) == nullptr ) if ( peers->FindPeer((*it).GetCallsign(), EProtocol::ulx) == nullptr )
{ {
// resolve again peer's IP in case it's a dynamic IP // resolve again peer's IP in case it's a dynamic IP
(*it).ResolveIp(); (*it).ResolveIp();
@ -404,7 +404,7 @@ void CUlxProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one // no stream open yet, open a new one
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_XLX, Header->GetRpt2Module()); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::ulx, Header->GetRpt2Module());
if ( client ) if ( client )
{ {
// and try to open the stream // and try to open the stream

@ -34,7 +34,7 @@ class CUlxProtocol : public CDextraProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);

@ -149,7 +149,7 @@ void CWiresxCmdHandler::Task(void)
// find our client and the module it's currentlink linked to // find our client and the module it's currentlink linked to
cModule = ' '; cModule = ' ';
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf);
if ( client ) if ( client )
{ {
cModule = client->GetReflectorModule(); cModule = client->GetReflectorModule();
@ -179,7 +179,7 @@ void CWiresxCmdHandler::Task(void)
ReplyToWiresxConnReqPacket(Cmd.GetIp(), Info, cModule); ReplyToWiresxConnReqPacket(Cmd.GetIp(), Info, cModule);
// change client's module // change client's module
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf);
if ( client ) if ( client )
{ {
client->SetReflectorModule(cModule); client->SetReflectorModule(cModule);
@ -198,7 +198,7 @@ void CWiresxCmdHandler::Task(void)
// change client's module // change client's module
{ {
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf);
if ( client != nullptr ) if ( client != nullptr )
{ {
client->SetReflectorModule(' '); client->SetReflectorModule(' ');

@ -31,7 +31,7 @@ public:
virtual ~CYsfClient() {}; virtual ~CYsfClient() {};
// identity // identity
int GetProtocol(void) const { return PROTOCOL_YSF; } EProtocol GetProtocol(void) const { return EProtocol::ysf; }
const char *GetProtocolName(void) const { return "YSF"; } const char *GetProtocolName(void) const { return "YSF"; }
int GetCodec(void) const { return CODEC_AMBE2PLUS; } int GetCodec(void) const { return CODEC_AMBE2PLUS; }
bool IsNode(void) const { return true; } bool IsNode(void) const { return true; }

@ -38,7 +38,7 @@ CYsfProtocol::CYsfProtocol()
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CYsfProtocol::Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) bool CYsfProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6)
{ {
// base class // base class
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -119,7 +119,7 @@ void CYsfProtocol::Task(void)
else if ( IsValidDvHeaderPacket(Ip, Fich, Buffer, Header, Frames) ) else if ( IsValidDvHeaderPacket(Ip, Fich, Buffer, Header, Frames) )
{ {
// node linked and callsign muted? // node linked and callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_YSF, Header->GetRpt2Module()) ) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::ysf, Header->GetRpt2Module()) )
{ {
// handle it // handle it
OnDvHeaderPacketIn(Header, Ip); OnDvHeaderPacketIn(Header, Ip);
@ -138,7 +138,7 @@ void CYsfProtocol::Task(void)
//std::cout << "YSF keepalive/connect packet from " << Callsign << " at " << Ip << std::endl; //std::cout << "YSF keepalive/connect packet from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_YSF) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::ysf) )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer); EncodeConnectAckPacket(&Buffer);
@ -146,7 +146,7 @@ void CYsfProtocol::Task(void)
// add client if needed // add client if needed
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, PROTOCOL_YSF); std::shared_ptr<CClient>client = clients->FindClient(Callsign, Ip, EProtocol::ysf);
// client already connected ? // client already connected ?
if ( client == nullptr ) if ( client == nullptr )
{ {
@ -240,7 +240,7 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_YSF); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::ysf);
if ( client ) if ( client )
{ {
// get client callsign // get client callsign
@ -328,7 +328,7 @@ void CYsfProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_YSF, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::ysf, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModuleId()) )
@ -357,7 +357,7 @@ void CYsfProtocol::HandleKeepalives(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(PROTOCOL_YSF, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::ysf, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( client->IsAMaster() ) if ( client->IsAMaster() )

@ -65,7 +65,7 @@ public:
CYsfProtocol(); CYsfProtocol();
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
void Close(void); void Close(void);
// task // task

Loading…
Cancel
Save

Powered by TurnKey Linux.