added preprocssing directives for xrfd

pull/1/head
Tom Early 6 years ago
parent 24656209f7
commit f9710a6e3b

@ -6,7 +6,7 @@ The XLX Multiprotocol Gateway Reflector Server is part of the software system fo
This will build **either** a new kind of XLX reflector **or** a tri-mode XRF reflector. This build support *dual-stack* operation, so the server on which it's running, must have both an IPv4 and IPv6 routable address if you are going to configure a dual-stack reflector. This XLX is different from the original because it can support out-going DExtra links, by adding a new DExtra Peer type *and* it has many changes designed to increase reliability and stability. The XRF reflector built from this source supports inbound DExtra, DPlus **and DCS connections**. Like XLX, XRF also supports out-going DExtra linking. Please note that for now, only one DExtra peer link per node is supported.
This is an improved version of the multi-protocol Reflector. Nearly all std::vector containers have been replaced with std::list containers. This is a far better choice for any collection where it is common to delete elements that are not at the end of the collection. Also in this package, no classes are derived from any standard containers. Because standard containers don't have a virtual destructor, derriving from them is highly ill-advised and while the origin XLX server worked using such derivations, it represents a possible serious problem when considering future development. Also, the clean-up routines designed to be executed when shutting down were unreachable as designed and this has been fixed. In addtion, long sleep times in certain threads were preventing a polite systemd shutdown and this has been fixed. Please note that it can still take several seconds to complete the shutdown while some execution threads complete their i/o cycle. Concurancy has been moved from std::thread to std::future. This is a superior way to manage threads. The original code created several threads that contained empty bodies and they have been eliminated. The C++ warning flag, -W has been turned on and a significant number of warning have been fixed.
This is an improved version of the multi-protocol Reflector. Nearly all std::vector containers have been replaced with std::list containers. This is a far better choice for any collection where it is common to delete elements that are not at the end of the collection. Also in this package, no classes are derived from any standard containers. Because standard containers don't have a virtual destructor, derriving from them is highly ill-advised and while the origin XLX server worked using such derivations, it represents a possible serious problem when considering future development. Also, the clean-up routines designed to be executed when shutting down were unreachable as designed and this has been fixed. In addtion, long sleep times in certain threads were preventing a polite systemd shutdown and this has been fixed. Please note that it can still take several seconds to complete the shutdown while some execution threads complete their i/o cycle. The C++ warning flag, -W has been turned on and a significant number of warning have been fixed.
The Makefiles have been improved to provide automatically generated dependencies. This significantly speeds up updating time and eliminates build errors. Be sure to do a `make clean` before you switch your build type between XLX and XRF. There are several switches in the Makefile for controlling what is to be made. By default, "make" will build an XLXD system with support for G3. The first switch will add gdb debugging support. The second switch will make a DStar-only xrfd reflector. The third switch will drop support for G3. This switch should be turned on if you are planning to have a DStar routing application also run on the server. If you want to turn on any of these switches, you should copy `Makefile` to `makefile` and then modify the `makefile`.

@ -38,7 +38,9 @@ CCallsign::CCallsign()
::memset(m_Callsign, ' ', sizeof(m_Callsign));
::memset(m_Suffix, ' ', sizeof(m_Suffix));
m_Module = ' ';
#ifndef NO_XLX
m_uiDmrid = 0;
#endif
}
CCallsign::CCallsign(const char *sz, uint32 dmrid)
@ -47,7 +49,9 @@ CCallsign::CCallsign(const char *sz, uint32 dmrid)
::memset(m_Callsign, ' ', sizeof(m_Callsign));
::memset(m_Suffix, ' ', sizeof(m_Suffix));
m_Module = ' ';
#ifndef NO_XLX
m_uiDmrid = dmrid;
#endif
// and populate
if ( ::strlen(sz) > 0 )
@ -58,6 +62,7 @@ CCallsign::CCallsign(const char *sz, uint32 dmrid)
{
m_Module = sz[sizeof(m_Callsign)-1];
}
#ifndef NO_XLX
// dmrid ok ?
if ( m_uiDmrid == 0 )
{
@ -79,6 +84,7 @@ CCallsign::CCallsign(const char *sz, uint32 dmrid)
}
}
g_DmridDir.Unlock();
#endif
}
}
@ -149,6 +155,7 @@ void CCallsign::SetCallsign(const char *sz, bool UpdateDmrid)
{
m_Module = sz[sizeof(m_Callsign)-1];
}
#ifndef NO_XLX
// and update dmrid
if ( UpdateDmrid )
{
@ -158,6 +165,7 @@ void CCallsign::SetCallsign(const char *sz, bool UpdateDmrid)
}
g_DmridDir.Unlock();
}
#endif
}
void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
@ -177,6 +185,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
{
m_Module = (char)buffer[sizeof(m_Callsign)-1];
}
#ifndef NO_XLX
if ( UpdateDmrid )
{
g_DmridDir.Lock();
@ -185,8 +194,10 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
}
g_DmridDir.Unlock();
}
#endif
}
#ifndef NO_XLX
void CCallsign::SetDmrid(uint32 dmrid, bool UpdateCallsign)
{
m_uiDmrid = dmrid;
@ -211,6 +222,7 @@ void CCallsign::SetDmrid(const uint8 *buffer, bool UpdateCallsign)
sz[8] = 0;
SetDmrid((uint32)::strtol(sz, NULL, 16), UpdateCallsign);
}
#endif
void CCallsign::SetModule(char c)
{
@ -309,10 +321,12 @@ bool CCallsign::HasSameModule(const CCallsign &Callsign) const
bool CCallsign::operator ==(const CCallsign &callsign) const
{
return ((::memcmp(callsign.m_Callsign, m_Callsign, sizeof(m_Callsign)) == 0) &&
(m_Module == callsign.m_Module) &&
(::memcmp(callsign.m_Suffix, m_Suffix, sizeof(m_Suffix)) == 0) &&
(m_uiDmrid == callsign.m_uiDmrid) );
return ((::memcmp(callsign.m_Callsign, m_Callsign, sizeof(m_Callsign)) == 0) && (m_Module == callsign.m_Module)
&& (::memcmp(callsign.m_Suffix, m_Suffix, sizeof(m_Suffix)) == 0)
#ifndef NO_XLX
&& (m_uiDmrid == callsign.m_uiDmrid)
#endif
);
}
CCallsign::operator const char *() const

@ -50,8 +50,10 @@ public:
// set
void SetCallsign(const char *, bool = true);
void SetCallsign(const uint8 *, int, bool = true);
#ifndef NO_XLX
void SetDmrid(uint32, bool = true);
void SetDmrid(const uint8 *, bool = true);
#endif
void SetModule(char);
void SetSuffix(const char *);
void SetSuffix(const uint8 *, int);
@ -62,7 +64,9 @@ public:
// get
void GetCallsign(uint8 *) const;
void GetCallsignString(char *) const;
#ifndef NO_XLX
uint32 GetDmrid(void) const { return m_uiDmrid; }
#endif
void GetSuffix(uint8 *) const;
char GetModule(void) const { return m_Module; }
@ -88,7 +92,9 @@ protected:
char m_Suffix[CALLSUFFIX_LEN];
char m_Module;
char m_sz[CALLSIGN_LEN+CALLSUFFIX_LEN+5];
#ifndef NO_XLX
uint32 m_uiDmrid;
#endif
};
////////////////////////////////////////////////////////////////////////////////////////

@ -35,8 +35,10 @@ CDvFramePacket::CDvFramePacket()
{
::memset(m_uiAmbe, 0, sizeof(m_uiAmbe));
::memset(m_uiDvData, 0, sizeof(m_uiDvData));
#ifndef NO_XLX
::memset(m_uiAmbePlus, 0, sizeof(m_uiAmbePlus));
::memset(m_uiDvSync, 0, sizeof(m_uiDvSync));
#endif
};
// dstar constructor
@ -46,10 +48,13 @@ CDvFramePacket::CDvFramePacket(const struct dstar_dvframe *dvframe, uint16 sid,
{
::memcpy(m_uiAmbe, dvframe->AMBE, sizeof(m_uiAmbe));
::memcpy(m_uiDvData, dvframe->DVDATA, sizeof(m_uiDvData));
#ifndef NO_XLX
::memset(m_uiAmbePlus, 0, sizeof(m_uiAmbePlus));
::memset(m_uiDvSync, 0, sizeof(m_uiDvSync));
#endif
}
#ifndef NO_XLX
// dmr constructor
CDvFramePacket::CDvFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid, uint8 pid, uint8 spid)
@ -85,6 +90,7 @@ CDvFramePacket::CDvFramePacket
::memcpy(m_uiAmbePlus, dmrambe, sizeof(m_uiAmbePlus));
::memcpy(m_uiDvSync, dmrsync, sizeof(m_uiDvSync));
}
#endif
////////////////////////////////////////////////////////////////////////////////////////
// virtual duplication
@ -102,7 +108,9 @@ const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const
switch (uiCodec)
{
case CODEC_AMBEPLUS: return m_uiAmbe;
#ifndef NO_XLX
case CODEC_AMBE2PLUS: return m_uiAmbePlus;
#endif
default: return NULL;
}
}
@ -122,9 +130,11 @@ void CDvFramePacket::SetAmbe(uint8 uiCodec, uint8 *Ambe)
case CODEC_AMBEPLUS:
::memcpy(m_uiAmbe, Ambe, sizeof(m_uiAmbe));
break;
#ifndef NO_XLX
case CODEC_AMBE2PLUS:
::memcpy(m_uiAmbePlus, Ambe, sizeof(m_uiAmbe));
break;
#endif
}
}
@ -134,8 +144,11 @@ void CDvFramePacket::SetAmbe(uint8 uiCodec, uint8 *Ambe)
bool CDvFramePacket::operator ==(const CDvFramePacket &DvFrame) const
{
return ( (::memcmp(m_uiAmbe, DvFrame.m_uiAmbe, sizeof(m_uiAmbe)) == 0) &&
(::memcmp(m_uiDvData, DvFrame.m_uiDvData, sizeof(m_uiDvData)) == 0) &&
(::memcmp(m_uiAmbePlus, DvFrame.m_uiAmbePlus, sizeof(m_uiAmbePlus)) == 0) &&
(::memcmp(m_uiDvSync, DvFrame.m_uiDvSync, sizeof(m_uiDvSync)) == 0) );
return ( (::memcmp(m_uiAmbe, DvFrame.m_uiAmbe, sizeof(m_uiAmbe)) == 0)
&& (::memcmp(m_uiDvData, DvFrame.m_uiDvData, sizeof(m_uiDvData)) == 0)
#ifndef NO_XLX
&& (::memcmp(m_uiAmbePlus, DvFrame.m_uiAmbePlus, sizeof(m_uiAmbePlus)) == 0)
&& (::memcmp(m_uiDvSync, DvFrame.m_uiDvSync, sizeof(m_uiDvSync)) == 0)
#endif
);
}

@ -54,23 +54,29 @@ public:
// constructor
CDvFramePacket();
CDvFramePacket(const struct dstar_dvframe *, uint16, uint8);
#ifndef NO_XLX
CDvFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8);
CDvFramePacket(const uint8 *, uint16, uint8, uint8, uint8);
CDvFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *);
#endif
// virtual duplication
CPacket *Duplicate(void) const;
// identity
bool IsDvFrame(void) const { return true; }
#ifndef NO_XLX
bool HaveTranscodableAmbe(void) const { return true; }
#endif
// get
const uint8 *GetAmbe(uint8) const;
const uint8 *GetAmbe(void) const { return m_uiAmbe; }
#ifndef NO_XLX
const uint8 *GetAmbePlus(void) const { return m_uiAmbePlus; }
const uint8 *GetDvData(void) const { return m_uiDvData; }
const uint8 *GetDvSync(void) const { return m_uiDvSync; }
#endif
const uint8 *GetDvData(void) const { return m_uiDvData; }
// set
void SetDvData(uint8 *);
@ -82,15 +88,19 @@ public:
protected:
// get
uint8 *GetAmbeData(void) { return m_uiAmbe; }
#ifndef NO_XLX
uint8 *GetAmbePlusData(void) { return m_uiAmbePlus; }
#endif
protected:
// data (dstar)
uint8 m_uiAmbe[AMBE_SIZE];
uint8 m_uiDvData[DVDATA_SIZE];
#ifndef NO_XLX
// data (dmr)
uint8 m_uiAmbePlus[AMBEPLUS_SIZE];
uint8 m_uiDvSync[DVSYNC_SIZE];
#endif
};

@ -55,6 +55,7 @@ CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16 sid,
m_uiCrc = buffer->Crc;
}
#ifndef NO_XLX
// dmr constructor
CDvHeaderPacket::CDvHeaderPacket(uint32 my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16 sid, uint8 pid, uint8 spid)
@ -84,6 +85,7 @@ CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const
m_csRPT2 = rpt2;
m_csMY = my;
}
#endif
////////////////////////////////////////////////////////////////////////////////////////
// virtual duplication

@ -62,8 +62,10 @@ public:
// constructor
CDvHeaderPacket();
CDvHeaderPacket(const struct dstar_header *, uint16, uint8);
#ifndef NO_XLX
CDvHeaderPacket(uint32, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8, uint8);
CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8);
#endif
// virtual duplication
CPacket *Duplicate(void) const;

@ -19,7 +19,7 @@
// 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/>.
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "main.h"
@ -40,6 +40,7 @@ CDvLastFramePacket::CDvLastFramePacket(const struct dstar_dvframe *DvFrame, uint
{
}
#ifndef NO_XLX
// dmr constructor
CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid, uint8 pid, uint8 spid)
@ -63,10 +64,11 @@ CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, uint16 sid, uint8 pid,
: CDvFramePacket(ambe, sid, pid, spid, fid)
{
}
#endif
// copy constructor
CDvLastFramePacket::CDvLastFramePacket(const CDvLastFramePacket &DvFrame)
: CDvFramePacket(DvFrame)
{
@ -79,4 +81,3 @@ CPacket *CDvLastFramePacket::Duplicate(void) const
{
return new CDvLastFramePacket(*this);
}

@ -19,7 +19,7 @@
// 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/>.
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdvlastframepacket_h
@ -41,17 +41,16 @@ public:
// constructor
CDvLastFramePacket();
CDvLastFramePacket(const struct dstar_dvframe *, uint16, uint8);
#ifndef NO_XLX
CDvLastFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8);
CDvLastFramePacket(const uint8 *, uint16, uint8, uint8, uint8);
CDvLastFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *);
#endif
CDvLastFramePacket(const CDvLastFramePacket &);
// destructor
virtual ~CDvLastFramePacket() {};
// virtual duplication
CPacket *Duplicate(void) const;
// identity
bool IsLastPacket(void) const { return true; }
bool HaveTranscodableAmbe(void) const { return false; }

@ -100,19 +100,25 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, int protocol
case PROTOCOL_DEXTRA:
case PROTOCOL_DPLUS:
case PROTOCOL_DCS:
#ifndef NO_XLX
case PROTOCOL_DMRPLUS:
case PROTOCOL_DMRMMDVM:
case PROTOCOL_YSF:
#endif
#ifndef NO_G3
case PROTOCOL_G3:
#endif
// first check is IP & callsigned listed OK
ok &= IsNodeListedOk(callsign, ip);
// todo: then apply any protocol specific authorisation for the operation
break;
#ifndef NO_XLX
// XLX interlinks
case PROTOCOL_XLX:
ok &= IsPeerListedOk(callsign, ip, modules);
break;
#endif
// unsupported
case PROTOCOL_NONE:
@ -142,19 +148,25 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int prot
case PROTOCOL_DEXTRA:
case PROTOCOL_DPLUS:
case PROTOCOL_DCS:
#ifndef NO_XLX
case PROTOCOL_DMRPLUS:
case PROTOCOL_DMRMMDVM:
case PROTOCOL_YSF:
#endif
#ifndef NO_G3
case PROTOCOL_G3:
#endif
// first check is IP & callsigned listed OK
ok &= IsNodeListedOk(callsign, ip, module);
// todo: then apply any protocol specific authorisation for the operation
break;
#ifndef NO_XLX
// XLX interlinks
case PROTOCOL_XLX:
ok &= IsPeerListedOk(callsign, ip, module);
break;
#endif
// unsupported
case PROTOCOL_NONE:

@ -19,7 +19,7 @@
// 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/>.
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "main.h"
@ -43,7 +43,7 @@ CPacketStream::CPacketStream()
bool CPacketStream::Open(const CDvHeaderPacket &DvHeader, CClient *client)
{
bool ok = false;
// not already open?
if ( !m_bOpen )
{
@ -54,7 +54,9 @@ bool CPacketStream::Open(const CDvHeaderPacket &DvHeader, CClient *client)
m_DvHeader = DvHeader;
m_OwnerClient = client;
m_LastPacketTime.Now();
#ifndef NO_XLX
m_CodecStream = g_Transcoder.GetStream(this, client->GetCodec());
#endif
ok = true;
}
return ok;
@ -66,7 +68,9 @@ void CPacketStream::Close(void)
m_bOpen = false;
m_uiStreamId = 0;
m_OwnerClient = NULL;
#ifndef NO_XLX
g_Transcoder.ReleaseStream(m_CodecStream);
#endif
m_CodecStream = NULL;
}
@ -109,16 +113,19 @@ void CPacketStream::Push(CPacket *Packet)
bool CPacketStream::IsEmpty(void) const
{
#ifndef NO_XLX
bool bEmpty = empty();
// also check no packets still in Codec stream's queue
if ( bEmpty && (m_CodecStream != NULL) )
{
bEmpty &= m_CodecStream->IsEmpty();
bEmpty = m_CodecStream->IsEmpty();
}
// done
return bEmpty;
#else
return empty();
#endif
}
////////////////////////////////////////////////////////////////////////////////////////
@ -132,4 +139,3 @@ const CIp *CPacketStream::GetOwnerIp(void)
}
return NULL;
}

@ -19,7 +19,7 @@
// 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/>.
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpacketstream_h
@ -43,19 +43,19 @@ class CPacketStream : public CPacketQueue
public:
// constructor
CPacketStream();
// destructor
virtual ~CPacketStream() {};
virtual ~CPacketStream() {}
// open / close
bool Open(const CDvHeaderPacket &, CClient *);
void Close(void);
// push & pop
void Push(CPacket *);
void Tickle(void) { m_LastPacketTime.Now(); }
bool IsEmpty(void) const;
// get
CClient *GetOwnerClient(void) { return m_OwnerClient; }
const CIp *GetOwnerIp(void);

@ -88,6 +88,7 @@ bool CProtocols::Init(void)
return false;
}
#ifndef NO_XLX
// create and initialize XLX - interlink
auto xlx = new CXlxProtocol;
if (xlx->Init())
@ -127,7 +128,9 @@ bool CProtocols::Init(void)
delete ysf;
return false;
}
#endif
#ifndef NO_G3
// create and initialize G3
auto g3 = new CG3Protocol;
if (g3->Init())
@ -137,6 +140,7 @@ bool CProtocols::Init(void)
delete g3;
return true;
}
#endif
}
m_Mutex.unlock();

@ -103,6 +103,7 @@ bool CReflector::Start(void)
// init gate keeper. It can only return true!
g_GateKeeper.Init();
#ifndef NO_XLX
// init dmrid directory. No need to check the return value.
g_DmridDir.Init();
@ -112,6 +113,7 @@ bool CReflector::Start(void)
// init the transcoder
if (! g_Transcoder.Init())
return false;
#endif
// create protocols
if (! m_Protocols.Init())
@ -168,16 +170,17 @@ void CReflector::Stop(void)
// close protocols
m_Protocols.Close();
// close transcoder
g_Transcoder.Close();
// close gatekeeper
g_GateKeeper.Close();
#ifndef NO_XLX
// close transcoder
g_Transcoder.Close();
// close databases
g_DmridDir.Close();
g_YsfNodeDir.Close();
#endif
}
////////////////////////////////////////////////////////////////////////////////////////

@ -42,12 +42,21 @@ int main(int argc, const char * argv[])
{
// check arguments
#ifndef NO_XLX
if ( argc != 5 )
{
std::cout << "Usage: " << argv[0] << " callsign ipv4 ipv6 ambedip" << std::endl;
std::cout << "example: " << argv[0] << " XLX999 192.168.178.212 2001:400:534::675b 127.0.0.1" << std::endl;
return EXIT_FAILURE;
}
#else
if ( argc != 4 )
{
std::cout << "Usage: " << argv[0] << " callsign ipv4 ipv6" << std::endl;
std::cout << "example: " << argv[0] << " XLX999 192.168.178.212 2001:400:534::675b" << std::endl;
return EXIT_FAILURE;
}
#endif
bool is4none = 0 == strncasecmp(argv[2], "none", 4);
bool is6none = 0 == strncasecmp(argv[3], "none", 4);
@ -63,7 +72,9 @@ int main(int argc, const char * argv[])
g_Reflector.SetCallsign(argv[1]);
g_Reflector.SetListenIPv4(argv[2], INET_ADDRSTRLEN);
g_Reflector.SetListenIPv6(argv[3], INET6_ADDRSTRLEN);
#ifndef NO_XLX
g_Reflector.SetTranscoderIp(argv[4], INET6_ADDRSTRLEN);
#endif
// and let it run
@ -76,15 +87,15 @@ int main(int argc, const char * argv[])
std::cout << "Reflector " << g_Reflector.GetCallsign() << "started and listening on ";
if (! is4none)
{
std::cout << g_Reflector.GetListenIPv4();
std::cout << g_Reflector.GetListenIPv4() << " for IPv4";
if (! is6none)
{
std::cout << " and " << g_Reflector.GetListenIPv6() << std::endl;
std::cout << " and " << g_Reflector.GetListenIPv6() << " for IPv6" << std::endl;
}
}
else
{
std::cout << g_Reflector.GetListenIPv6() << std::endl;
std::cout << g_Reflector.GetListenIPv6() << " for IPv6" << std::endl;
}
pause(); // wait for any signal

@ -80,11 +80,15 @@
#define PROTOCOL_DEXTRA 1
#define PROTOCOL_DPLUS 2
#define PROTOCOL_DCS 3
#ifndef NO_XLX
#define PROTOCOL_XLX 4
#define PROTOCOL_DMRPLUS 5
#define PROTOCOL_DMRMMDVM 6
#define PROTOCOL_YSF 7
#endif
#ifndef NO_G3
#define PROTOCOL_G3 8
#endif
// DExtra
#define DEXTRA_PORT 30001 // UDP port
@ -102,6 +106,7 @@
#define DCS_KEEPALIVE_PERIOD 1 // in seconds
#define DCS_KEEPALIVE_TIMEOUT (DCS_KEEPALIVE_PERIOD*30) // in seconds
#ifndef NO_XLX
// XLX
#define XLX_PORT 10002 // UDP port
#define XLX_KEEPALIVE_PERIOD 1 // in seconds
@ -130,26 +135,31 @@
#define YSF_DEFAULT_NODE_RX_FREQ 437000000 // in Hz
#define YSF_AUTOLINK_ENABLE 0 // 1 = enable, 0 = disable auto-link
#define YSF_AUTOLINK_MODULE 'B' // module for client to auto-link to
#endif
#ifndef NO_G3
// G3 Terminal
#define G3_PRESENCE_PORT 12346 // UDP port
#define G3_CONFIG_PORT 12345 // UDP port
#define G3_DV_PORT 40000 // UDP port
#define G3_KEEPALIVE_PERIOD 10 // in seconds
#define G3_KEEPALIVE_TIMEOUT 3600 // in seconds, 1 hour
#endif
#ifndef NO_XLX
// Transcoder server --------------------------------------------
#define TRANSCODER_PORT 10100 // UDP port
#define TRANSCODER_KEEPALIVE_PERIOD 5 // in seconds
#define TRANSCODER_KEEPALIVE_TIMEOUT 30 // in seconds
#define TRANSCODER_AMBEPACKET_TIMEOUT 400 // in ms
#endif
// codec --------------------------------------------------------
#define CODEC_NONE 0
#define CODEC_AMBEPLUS 1 // DStar
#ifndef NO_XLX
#define CODEC_AMBE2PLUS 2 // DMR
@ -164,6 +174,7 @@
#define YSFNODEDB_USE_RLX_SERVER 1 // 1 = use http, 0 = use local file
#define YSFNODEDB_PATH "/usr/local/etc/ysfnode.dat" // local file path
#define YSFNODEDB_REFRESH_RATE 180 // in minutes
#endif
// xml & json reporting -----------------------------------------
@ -211,6 +222,7 @@ extern CReflector g_Reflector;
class CGateKeeper;
extern CGateKeeper g_GateKeeper;
#ifndef NO_XLX
#if (DMRIDDB_USE_RLX_SERVER == 1)
class CDmridDirHttp;
extern CDmridDirHttp g_DmridDir;
@ -229,6 +241,7 @@ extern CGateKeeper g_GateKeeper;
class CTranscoder;
extern CTranscoder g_Transcoder;
#endif
////////////////////////////////////////////////////////////////////////////////////////

@ -1,96 +0,0 @@
/*************************************************************************
** Copyright (C) 2014 Jan Pedersen <jp@jp-embedded.com>
**
** 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 <http://www.gnu.org/licenses/>.
*************************************************************************/
#ifndef __syslog
#define __syslog
#include <iostream>
#include <streambuf>
#include <string>
namespace csyslog {
#include <syslog.h>
}
namespace syslog
{
struct level {
enum pri {
emerg = LOG_EMERG, // A panic condition
alert = LOG_ALERT, // A condition that should be corrected
critical= LOG_CRIT, // Critical condition, e.g, hard device error
error = LOG_ERR, // Errors
warning = LOG_WARNING, // Warning messages
notice = LOG_NOTICE, // Possibly be handled specially
info = LOG_INFO, // Informational
debug = LOG_DEBUG // For debugging program
};
};
class streambuf : public std::streambuf
{
std::string _buf;
int _level;
public:
streambuf() : _level(level::debug) { }
void level(int level) { _level = level; }
protected:
int sync()
{
if (_buf.size()) {
csyslog::syslog(_level, "%s", _buf.c_str());
_buf.erase();
}
return 0;
}
int_type overflow(int_type c)
{
if(c == traits_type::eof()) sync();
else _buf += static_cast<char>(c);
return c;
}
};
class ostream : public std::ostream
{
streambuf _logbuf;
public:
ostream() : std::ostream(&_logbuf) {}
ostream& operator<<(const level::pri lev) { _logbuf.level(lev); return *this; }
};
class redirect
{
ostream dst;
std::ostream &src;
std::streambuf * const sbuf;
public:
redirect(std::ostream & src) : src(src), sbuf(src.rdbuf(dst.rdbuf())) { dst << (&src == &std::cout ? level::info : level::error); }
~redirect() { src.rdbuf(sbuf); }
};
}
#endif
Loading…
Cancel
Save

Powered by TurnKey Linux.