rename and resolve

unstable
Tom Early 4 years ago
parent b296c10ac5
commit f58c6599b4

@ -1,26 +1,20 @@
//
// cbmclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 20/01/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"

@ -1,6 +1,6 @@
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The ultimate Reflector // ulxd -- The universal Reflector
// Copyright © 2021 Thomas A. Early N7TAE // Copyright © 2021 Thomas A. Early N7TAE
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -21,13 +21,6 @@
#include "Client.h" #include "Client.h"
#include "ULXClient.h" #include "ULXClient.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CBmClient : public CClient class CBmClient : public CClient
{ {
public: public:

@ -1,26 +1,21 @@
//
// cbmpeer.cpp
// xlxd
// Created by Jean-Luc Deltombe (LX3JL) on 10/12/2016.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>

@ -1,30 +1,22 @@
//
// BMPeer.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 20/01/2017.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cbmpeer_h
#define cbmpeer_h
#pragma once
#include "Peer.h" #include "Peer.h"
#include "BMClient.h" #include "BMClient.h"
@ -54,6 +46,3 @@ public:
// revision helper // revision helper
static int GetProtocolRevision(const CVersion &); static int GetProtocolRevision(const CVersion &);
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cbmpeer_h */

@ -1,26 +1,20 @@
//
// cbuffer.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 02/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Buffer.h" #include "Buffer.h"

@ -1,30 +1,22 @@
//
// Buffer.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 02/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cbuffer_h #pragma once
#define cbuffer_h
#include <vector> #include <vector>
#include <fstream> #include <fstream>
@ -80,6 +72,3 @@ public:
protected: protected:
std::vector<uint8_t> m_data; std::vector<uint8_t> m_data;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cbuffer_h */

@ -1,31 +1,31 @@
/* // Copyright (C) 2012 by Ian Wraith
* Copyright (C) 2012 by Ian Wraith // Copyright (C) 2015 by Jonathan Naylor G4KLX
* Copyright (C) 2015 by Jonathan Naylor G4KLX
* // ulxd -- The universal reflector
* This program is free software; you can redistribute it and/or modify // Copyright © 2021 Thomas A. Early N7TAE
* it under the terms of the GNU General Public License as published by //
* the Free Software Foundation; either version 2 of the License, or // This program is free software: you can redistribute it and/or modify
* (at your option) any later version. // it under the terms of the GNU General Public License as published by
* // the Free Software Foundation, either version 3 of the License, or
* This program is distributed in the hope that it will be useful, // (at your option) any later version.
* but WITHOUT ANY WARRANTY; without even the implied warranty of //
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // This program is distributed in the hope that it will be useful,
* GNU General Public License for more details. // but WITHOUT ANY WARRANTY; without even the implied warranty of
* // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* You should have received a copy of the GNU General Public License // GNU General Public License for more details.
* along with this program; if not, write to the Free Software //
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // 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 "CBPT19696.h"
#include "Hamming.h"
#include "Utils.h"
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include "CBPTC19696.h"
#include "Hamming.h"
#include "Utils.h"
CBPTC19696::CBPTC19696() CBPTC19696::CBPTC19696()
{ {
} }

@ -1,23 +1,22 @@
/* // Copyright (C) 2015 by Jonathan Naylor G4KLX
* Copyright (C) 2015 by Jonathan Naylor G4KLX
* // ulxd -- The universal reflector
* This program is free software; you can redistribute it and/or modify // Copyright © 2021 Thomas A. Early N7TAE
* it under the terms of the GNU General Public License as published by //
* the Free Software Foundation; either version 2 of the License, or // This program is free software: you can redistribute it and/or modify
* (at your option) any later version. // it under the terms of the GNU General Public License as published by
* // the Free Software Foundation, either version 3 of the License, or
* This program is distributed in the hope that it will be useful, // (at your option) any later version.
* but WITHOUT ANY WARRANTY; without even the implied warranty of //
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // This program is distributed in the hope that it will be useful,
* GNU General Public License for more details. // but WITHOUT ANY WARRANTY; without even the implied warranty of
* // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* You should have received a copy of the GNU General Public License // GNU General Public License for more details.
* along with this program; if not, write to the Free Software //
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // You should have received a copy of the GNU General Public License
*/ // along with this program. If not, see <https://www.gnu.org/licenses/>.
#if !defined(BPTC19696_H) #pragma once
#define BPTC19696_H
class CBPTC19696 class CBPTC19696
{ {
@ -43,5 +42,3 @@ private:
void encodeErrorCheck(); void encodeErrorCheck();
void encodeExtractBinary(unsigned char* data); void encodeExtractBinary(unsigned char* data);
}; };
#endif

@ -1,32 +1,22 @@
//
// NotificationQueue.h
// xlxd
//
// Created by Jean-Luc on 05/12/2015.
// Copyright © 2015 Jean-Luc. All rights reserved. // Copyright © 2015 Jean-Luc. All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#pragma once
#ifndef cnotificationqueue_h
#define cnotificationqueue_h
#include <queue> #include <queue>
#include <mutex> #include <mutex>
@ -63,6 +53,3 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
std::queue<CNotification> queue; std::queue<CNotification> queue;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cnotificationqueue_h */

@ -1,20 +1,20 @@
/* // Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* // ulxd -- The universal reflector
* This program is free software; you can redistribute it and/or modify // Copyright © 2021 Thomas A. Early N7TAE
* it under the terms of the GNU General Public License as published by //
* the Free Software Foundation; either version 2 of the License, or // This program is free software: you can redistribute it and/or modify
* (at your option) any later version. // it under the terms of the GNU General Public License as published by
* // the Free Software Foundation, either version 3 of the License, or
* This program is distributed in the hope that it will be useful, // (at your option) any later version.
* but WITHOUT ANY WARRANTY; without even the implied warranty of //
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // This program is distributed in the hope that it will be useful,
* GNU General Public License for more details. // but WITHOUT ANY WARRANTY; without even the implied warranty of
* // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* You should have received a copy of the GNU General Public License // GNU General Public License for more details.
* along with this program; if not, write to the Free Software //
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // 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 "CRC.h" #include "CRC.h"

@ -1,23 +1,22 @@
/* // Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(CRC_H) // ulxd -- The universal reflector
#define CRC_H // 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
class CCRC class CCRC
{ {
@ -35,5 +34,3 @@ public:
static unsigned char addCRC(const unsigned char* in, unsigned int length); static unsigned char addCRC(const unsigned char* in, unsigned int length);
}; };
#endif

@ -1,31 +1,25 @@
//
// ccallsign.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
#include <cctype> #include <cctype>
#include "cdmriddirfile.h" #include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h" #include "DMRIdDirHttp.h"
#include "Callsign.h" #include "Callsign.h"
@ -43,7 +37,7 @@ CCallsign::CCallsign()
#endif #endif
} }
CCallsign::CCallsign(const char *sz, uint32 dmrid) CCallsign::CCallsign(const char *sz, uint32_t dmrid)
{ {
// blank all // blank all
::memset(m_Callsign, ' ', sizeof(m_Callsign)); ::memset(m_Callsign, ' ', sizeof(m_Callsign));
@ -168,7 +162,7 @@ void CCallsign::SetCallsign(const char *sz, bool UpdateDmrid)
#endif #endif
} }
void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid) void CCallsign::SetCallsign(const uint8_t *buffer, int len, bool UpdateDmrid)
{ {
// set callsign // set callsign
::memset(m_Callsign, ' ', sizeof(m_Callsign)); ::memset(m_Callsign, ' ', sizeof(m_Callsign));
@ -198,7 +192,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
} }
#ifndef NO_XLX #ifndef NO_XLX
void CCallsign::SetDmrid(uint32 dmrid, bool UpdateCallsign) void CCallsign::SetDmrid(uint32_t dmrid, bool UpdateCallsign)
{ {
m_uiDmrid = dmrid; m_uiDmrid = dmrid;
if ( UpdateCallsign ) if ( UpdateCallsign )
@ -215,12 +209,12 @@ void CCallsign::SetDmrid(uint32 dmrid, bool UpdateCallsign)
} }
} }
void CCallsign::SetDmrid(const uint8 *buffer, bool UpdateCallsign) void CCallsign::SetDmrid(const uint8_t *buffer, bool UpdateCallsign)
{ {
char sz[9]; char sz[9];
::memcpy(sz, buffer, 8); ::memcpy(sz, buffer, 8);
sz[8] = 0; sz[8] = 0;
SetDmrid((uint32)::strtol(sz, nullptr, 16), UpdateCallsign); SetDmrid((uint32_t)::strtol(sz, nullptr, 16), UpdateCallsign);
} }
#endif #endif
@ -236,7 +230,7 @@ void CCallsign::SetSuffix(const char *sz)
::memcpy(m_Suffix, sz, MIN(strlen(sz), sizeof(m_Suffix))); ::memcpy(m_Suffix, sz, MIN(strlen(sz), sizeof(m_Suffix)));
} }
void CCallsign::SetSuffix(const uint8 *buffer, int len) void CCallsign::SetSuffix(const uint8_t *buffer, int len)
{ {
len = MIN(len, (int)sizeof(m_Suffix)); len = MIN(len, (int)sizeof(m_Suffix));
::memset(m_Suffix, ' ', sizeof(m_Suffix)); ::memset(m_Suffix, ' ', sizeof(m_Suffix));
@ -246,7 +240,7 @@ void CCallsign::SetSuffix(const uint8 *buffer, int len)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// modify // modify
void CCallsign::PatchCallsign(int off, const uint8 *patch, int len) void CCallsign::PatchCallsign(int off, const uint8_t *patch, int len)
{ {
if ( off < CALLSIGN_LEN ) if ( off < CALLSIGN_LEN )
{ {
@ -258,7 +252,7 @@ void CCallsign::PatchCallsign(int off, const uint8 *patch, int len)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// get // get
void CCallsign::GetCallsign(uint8 *buffer) const void CCallsign::GetCallsign(uint8_t *buffer) const
{ {
::memcpy(buffer, m_Callsign, sizeof(m_Callsign)); ::memcpy(buffer, m_Callsign, sizeof(m_Callsign));
if ( HasModule() ) if ( HasModule() )
@ -277,7 +271,7 @@ void CCallsign::GetCallsignString(char *sz) const
sz[i] = 0; sz[i] = 0;
} }
void CCallsign::GetSuffix(uint8 *buffer) const void CCallsign::GetSuffix(uint8_t *buffer) const
{ {
::memcpy(buffer, m_Suffix, sizeof(m_Suffix)); ::memcpy(buffer, m_Suffix, sizeof(m_Suffix));
} }

@ -1,29 +1,22 @@
/// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// Callsign.h // This program is free software: you can redistribute it and/or modify
// xlxd // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015. // (at your option) any later version.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
//
// xlxd is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef ccallsign_h #pragma once
#define ccallsign_h
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// define // define
@ -40,7 +33,7 @@ class CCallsign
public: public:
// contructors // contructors
CCallsign(); CCallsign();
CCallsign(const char *, uint32 = 0); CCallsign(const char *, uint32_t = 0);
// status // status
bool IsValid(void) const; bool IsValid(void) const;
@ -49,25 +42,25 @@ public:
// set // set
void SetCallsign(const char *, bool = true); void SetCallsign(const char *, bool = true);
void SetCallsign(const uint8 *, int, bool = true); void SetCallsign(const uint8_t *, int, bool = true);
#ifndef NO_XLX #ifndef NO_XLX
void SetDmrid(uint32, bool = true); void SetDmrid(uint32_t, bool = true);
void SetDmrid(const uint8 *, bool = true); void SetDmrid(const uint8_t *, bool = true);
#endif #endif
void SetModule(char); void SetModule(char);
void SetSuffix(const char *); void SetSuffix(const char *);
void SetSuffix(const uint8 *, int); void SetSuffix(const uint8_t *, int);
// modify // modify
void PatchCallsign(int, const uint8 *, int); void PatchCallsign(int, const uint8_t *, int);
// get // get
void GetCallsign(uint8 *) const; void GetCallsign(uint8_t *) const;
void GetCallsignString(char *) const; void GetCallsignString(char *) const;
#ifndef NO_XLX #ifndef NO_XLX
uint32 GetDmrid(void) const { return m_uiDmrid; } uint32_t GetDmrid(void) const { return m_uiDmrid; }
#endif #endif
void GetSuffix(uint8 *) const; void GetSuffix(uint8_t *) const;
char GetModule(void) const { return m_Module; } char GetModule(void) const { return m_Module; }
// compare // compare
@ -93,9 +86,6 @@ protected:
char m_Module; char m_Module;
mutable char m_sz[CALLSIGN_LEN+CALLSUFFIX_LEN+5]; mutable char m_sz[CALLSIGN_LEN+CALLSUFFIX_LEN+5];
#ifndef NO_XLX #ifndef NO_XLX
uint32 m_uiDmrid; uint32_t m_uiDmrid;
#endif #endif
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* ccallsign_h */

@ -1,27 +1,20 @@
//
// ccallsignlist.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 30/12/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>

@ -1,32 +1,22 @@
//
// CallsignList.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 30/12/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef ccallsignlist_h
#define ccallsignlist_h
#pragma once
#include "Main.h" #include "Main.h"
#include "CallsignListItem.h" #include "CallsignListItem.h"
@ -75,7 +65,3 @@ protected:
time_t m_LastModTime; time_t m_LastModTime;
std::list<CCallsignListItem> m_Callsigns; std::list<CCallsignListItem> m_Callsigns;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* ccallsignlist_h */

@ -1,26 +1,20 @@
//
// ccallsignlistitem.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"

@ -1,29 +1,22 @@
//
// CallsignListItem.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef ccallsignlistitem_h #pragma once
#define ccallsignlistitem_h
#include "Main.h" #include "Main.h"
#include "Callsign.h" #include "Callsign.h"
@ -70,8 +63,3 @@ protected:
CIp m_Ip; CIp m_Ip;
char m_Modules[27]; char m_Modules[27];
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* ccallsignlistitem_h */

@ -1,26 +1,20 @@
//
// cclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -34,7 +28,7 @@ CClient::CClient()
{ {
m_ReflectorModule = ' '; m_ReflectorModule = ' ';
m_ModuleMastered = ' '; m_ModuleMastered = ' ';
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
m_ConnectTime = std::time(nullptr); m_ConnectTime = std::time(nullptr);
m_LastHeardTime = std::time(nullptr); m_LastHeardTime = std::time(nullptr);
} }
@ -45,7 +39,7 @@ CClient::CClient(const CCallsign &callsign, const CIp &ip, char reflectorModule)
m_Callsign = callsign; m_Callsign = callsign;
m_Ip = ip; m_Ip = ip;
m_ModuleMastered = ' '; m_ModuleMastered = ' ';
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
m_ConnectTime = std::time(nullptr); m_ConnectTime = std::time(nullptr);
m_LastHeardTime = std::time(nullptr); m_LastHeardTime = std::time(nullptr);
} }
@ -66,7 +60,7 @@ CClient::CClient(const CClient &client)
void CClient::Alive(void) void CClient::Alive(void)
{ {
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.time();
} }

@ -1,29 +1,22 @@
//
// Client.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cclient_h #pragma once
#define cclient_h
#include "Timer.h" #include "Timer.h"
#include "IP.h" #include "IP.h"
@ -94,10 +87,7 @@ protected:
// status // status
char m_ModuleMastered; char m_ModuleMastered;
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
std::time_t m_ConnectTime; std::time_t m_ConnectTime;
std::time_t m_LastHeardTime; std::time_t m_LastHeardTime;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cclient_h */

@ -1,27 +1,20 @@
//
// cclients.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Reflector.h" #include "Reflector.h"

@ -1,30 +1,22 @@
//
// Clients.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cclients_h #pragma once
#define cclients_h
#include "Client.h" #include "Client.h"
@ -79,7 +71,3 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
std::list<std::shared_ptr<CClient>> m_Clients; std::list<std::shared_ptr<CClient>> m_Clients;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cclients_h */

@ -1,26 +1,20 @@
//
// ccodecstream.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 13/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -36,7 +30,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// constructor // constructor
CCodecStream::CCodecStream(CPacketStream *PacketStream, uint16 uiId, uint8 uiCodecIn, uint8 uiCodecOut) CCodecStream::CCodecStream(CPacketStream *PacketStream, uint16_t uiId, uint8_t uiCodecIn, uint8_t uiCodecOut)
{ {
keep_running = true; keep_running = true;
m_uiStreamId = uiId; m_uiStreamId = uiId;
@ -72,7 +66,7 @@ CCodecStream::~CCodecStream()
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// initialization // initialization
bool CCodecStream::Init(uint16 uiPort) bool CCodecStream::Init(uint16_t uiPort)
{ {
m_bConnected = keep_running = false; // prepare for the worst m_bConnected = keep_running = false; // prepare for the worst
@ -155,8 +149,8 @@ void CCodecStream::Task(void)
{ {
CBuffer Buffer; CBuffer Buffer;
CIp Ip; CIp Ip;
uint8 Ambe[AMBE_SIZE]; uint8_t Ambe[AMBE_SIZE];
uint8 DStarSync[] = { 0x55,0x2D,0x16 }; uint8_t DStarSync[] = { 0x55,0x2D,0x16 };
// any packet from transcoder // any packet from transcoder
if ( m_Socket.Receive(Buffer, Ip, 5) ) if ( m_Socket.Receive(Buffer, Ip, 5) )
@ -165,10 +159,10 @@ void CCodecStream::Task(void)
if ( IsValidAmbePacket(Buffer, Ambe) ) if ( IsValidAmbePacket(Buffer, Ambe) )
{ {
// tickle // tickle
m_TimeoutTimer.Now(); m_TimeoutTimer.start();
// update statistics // update statistics
double ping = m_StatsTimer.DurationSinceNow(); double ping = m_StatsTimer.time();
if ( m_fPingMin == -1 ) if ( m_fPingMin == -1 )
{ {
m_fPingMin = ping; m_fPingMin = ping;
@ -222,7 +216,7 @@ void CCodecStream::Task(void)
// this assume that thread pushing the Packet // this assume that thread pushing the Packet
// have verified that the CodecStream is connected // have verified that the CodecStream is connected
// and that the packet needs transcoding // and that the packet needs transcoding
m_StatsTimer.Now(); m_StatsTimer.start();
m_uiTotalPackets++; m_uiTotalPackets++;
EncodeAmbePacket(&Buffer, Frame->GetAmbe(m_uiCodecIn)); EncodeAmbePacket(&Buffer, Frame->GetAmbe(m_uiCodecIn));
m_Socket.Send(Buffer, m_Ip, m_uiPort); m_Socket.Send(Buffer, m_Ip, m_uiPort);
@ -232,7 +226,7 @@ void CCodecStream::Task(void)
} }
// handle timeout // handle timeout
if ( !m_LocalQueue.empty() && (m_TimeoutTimer.DurationSinceNow() >= (TRANSCODER_AMBEPACKET_TIMEOUT/1000.0f)) ) if ( !m_LocalQueue.empty() && (m_TimeoutTimer.time() >= (TRANSCODER_AMBEPACKET_TIMEOUT/1000.0f)) )
{ {
//std::cout << "ambed packet timeout" << std::endl; //std::cout << "ambed packet timeout" << std::endl;
m_uiTimeoutPackets++; m_uiTimeoutPackets++;
@ -242,7 +236,7 @@ void CCodecStream::Task(void)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
/// packet decoding helpers /// packet decoding helpers
bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8 *Ambe) bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8_t *Ambe)
{ {
bool valid = false; bool valid = false;
@ -257,10 +251,10 @@ bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8 *Ambe)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
/// packet encoding helpers /// packet encoding helpers
void CCodecStream::EncodeAmbePacket(CBuffer *Buffer, const uint8 *Ambe) void CCodecStream::EncodeAmbePacket(CBuffer *Buffer, const uint8_t *Ambe)
{ {
Buffer->clear(); Buffer->clear();
Buffer->Append(m_uiCodecIn); Buffer->Append(m_uiCodecIn);
Buffer->Append(m_uiPid); Buffer->Append(m_uiPid);
Buffer->Append((uint8 *)Ambe, 9); Buffer->Append((uint8_t *)Ambe, 9);
} }

@ -1,29 +1,22 @@
//
// CodecStream.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 13/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef ccodecstream_h #pragma once
#define ccodecstream_h
#include "Semaphore.h" #include "Semaphore.h"
#include "UDPSocket.h" #include "UDPSocket.h"
@ -47,23 +40,23 @@ class CCodecStream : public CPacketQueue
{ {
public: public:
// constructor // constructor
CCodecStream(CPacketStream *, uint16, uint8, uint8); CCodecStream(CPacketStream *, uint16_t, uint8_t, uint8_t);
// destructor // destructor
virtual ~CCodecStream(); virtual ~CCodecStream();
// initialization // initialization
bool Init(uint16); bool Init(uint16_t);
void Close(void); void Close(void);
// get // get
bool IsConnected(void) const { return m_bConnected; } bool IsConnected(void) const { return m_bConnected; }
uint16 GetStreamId(void) const { return m_uiStreamId; } uint16_t GetStreamId(void) const { return m_uiStreamId; }
double GetPingMin(void) const { return m_fPingMin; } double GetPingMin(void) const { return m_fPingMin; }
double GetPingMax(void) const { return m_fPingMax; } double GetPingMax(void) const { return m_fPingMax; }
double GetPingAve(void) const { return (m_fPingCount != 0) ? m_fPingSum/m_fPingCount : 0; } double GetPingAve(void) const { return (m_fPingCount != 0) ? m_fPingSum/m_fPingCount : 0; }
uint32 GetTotalPackets(void) const { return m_uiTotalPackets; } uint32_t GetTotalPackets(void) const { return m_uiTotalPackets; }
uint32 GetTimeoutPackets(void) const { return m_uiTimeoutPackets; } uint32_t GetTimeoutPackets(void) const { return m_uiTimeoutPackets; }
bool IsEmpty(void) const; bool IsEmpty(void) const;
// task // task
@ -73,19 +66,19 @@ public:
protected: protected:
// packet decoding helpers // packet decoding helpers
bool IsValidAmbePacket(const CBuffer &, uint8 *); bool IsValidAmbePacket(const CBuffer &, uint8_t *);
// packet encoding helpers // packet encoding helpers
void EncodeAmbePacket(CBuffer *, const uint8 *); void EncodeAmbePacket(CBuffer *, const uint8_t *);
protected: protected:
// data // data
uint16 m_uiStreamId; uint16_t m_uiStreamId;
uint16 m_uiPort; uint16_t m_uiPort;
uint8 m_uiPid; uint8_t m_uiPid;
uint8 m_uiCodecIn; uint8_t m_uiCodecIn;
uint8 m_uiCodecOut; uint8_t m_uiCodecOut;
// socket // socket
CIp m_Ip; CIp m_Ip;
@ -93,24 +86,20 @@ protected:
bool m_bConnected; bool m_bConnected;
// associated packet stream // associated packet stream
CPacketStream *m_PacketStream; CPacketStream *m_PacketStream;
CPacketQueue m_LocalQueue; CPacketQueue m_LocalQueue;
// thread // thread
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
std::future<void> m_Future; std::future<void> m_Future;
CTimePoint m_TimeoutTimer; CTimer m_TimeoutTimer;
CTimePoint m_StatsTimer; CTimer m_StatsTimer;
// statistics // statistics
double m_fPingMin; double m_fPingMin;
double m_fPingMax; double m_fPingMax;
double m_fPingSum; double m_fPingSum;
double m_fPingCount; double m_fPingCount;
uint32 m_uiTotalPackets; uint32_t m_uiTotalPackets;
uint32 m_uiTimeoutPackets; uint32_t m_uiTimeoutPackets;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* ccodecstream_h */

@ -1,26 +1,20 @@
//
// cdcsclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DCSClient.h" #include "DCSClient.h"
@ -48,5 +42,5 @@ CDcsClient::CDcsClient(const CDcsClient &client)
bool CDcsClient::IsAlive(void) const bool CDcsClient::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < DCS_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < DCS_KEEPALIVE_TIMEOUT);
} }

@ -1,39 +1,25 @@
//
// DCSClient.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdcsclient_h #pragma once
#define cdcsclient_h
#include "Client.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDcsClient : public CClient class CDcsClient : public CClient
{ {
public: public:
@ -54,7 +40,3 @@ public:
// status // status
bool IsAlive(void) const; bool IsAlive(void) const;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdcsclient_h */

@ -1,46 +1,39 @@
//
// cdcsprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
#include "DCSClient.h" #include "DCSClient.h"
#include "cdcsprotocol.h" #include "DCSProtocol.h"
#include "Reflector.h" #include "Reflector.h"
#include "GateKeeper.h" #include "GateKeeper.h"
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDcsProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) bool CDcsProtocol::Initialize(const char *type, const int 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))
return false; return false;
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
// done // done
return true; return true;
@ -178,13 +171,13 @@ void CDcsProtocol::Task(void)
HandleQueue(); HandleQueue();
// keep client alive // keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > DCS_KEEPALIVE_PERIOD ) if ( m_LastKeepaliveTime.time() > DCS_KEEPALIVE_PERIOD )
{ {
// //
HandleKeepalives(); HandleKeepalives();
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
} }
} }
@ -392,23 +385,23 @@ bool CDcsProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *call
bool CDcsProtocol::IsValidDvPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header, std::unique_ptr<CDvFramePacket> &frame) bool CDcsProtocol::IsValidDvPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header, std::unique_ptr<CDvFramePacket> &frame)
{ {
uint8 tag[] = { '0','0','0','1' }; uint8_t tag[] = { '0','0','0','1' };
if ( (Buffer.size() >= 100) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() >= 100) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
// get the header // get the header
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[4]), *((uint16 *)&(Buffer.data()[43])), 0x80)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[4]), *((uint16_t *)&(Buffer.data()[43])), 0x80));
// get the frame // get the frame
if ( Buffer.data()[45] & 0x40U ) if ( Buffer.data()[45] & 0x40U )
{ {
// it's the last frame // it's the last frame
frame = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[46]), *((uint16 *)&(Buffer.data()[43])), Buffer.data()[45])); frame = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[46]), *((uint16_t *)&(Buffer.data()[43])), Buffer.data()[45]));
} }
else else
{ {
// it's a regular DV frame // it's a regular DV frame
frame = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[46]), *((uint16 *)&(Buffer.data()[43])), Buffer.data()[45])); frame = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[46]), *((uint16_t *)&(Buffer.data()[43])), Buffer.data()[45]));
} }
// check validity of packets // check validity of packets
@ -420,7 +413,7 @@ bool CDcsProtocol::IsValidDvPacket(const CBuffer &Buffer, std::unique_ptr<CDvHea
bool CDcsProtocol::IsIgnorePacket(const CBuffer &Buffer) bool CDcsProtocol::IsIgnorePacket(const CBuffer &Buffer)
{ {
uint8 tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; uint8_t tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, };
if ( Buffer.size() == 15 && Buffer.Compare(tag, sizeof(tag)) == 0 ) if ( Buffer.size() == 15 && Buffer.Compare(tag, sizeof(tag)) == 0 )
return true; return true;
@ -438,75 +431,75 @@ void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client) void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{ {
uint8 tag[] = { 0x0A,0x00,0x20,0x20 }; uint8_t tag[] = { 0x0A,0x00,0x20,0x20 };
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1); Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)Client->GetReflectorModule()); Buffer->Append((uint8_t)Client->GetReflectorModule());
Buffer->Append((uint8)' '); Buffer->Append((uint8_t)' ');
Buffer->Append((uint8 *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1); Buffer->Append((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)Client->GetModule()); Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append((uint8)Client->GetModule()); Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
void CDcsProtocol::EncodeConnectAckPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer) void CDcsProtocol::EncodeConnectAckPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer)
{ {
uint8 tag[] = { 'A','C','K',0x00 }; uint8_t tag[] = { 'A','C','K',0x00 };
uint8 cs[CALLSIGN_LEN]; uint8_t cs[CALLSIGN_LEN];
Callsign.GetCallsign(cs); Callsign.GetCallsign(cs);
Buffer->Set(cs, CALLSIGN_LEN-1); Buffer->Set(cs, CALLSIGN_LEN-1);
Buffer->Append((uint8)' '); Buffer->Append((uint8_t)' ');
Buffer->Append((uint8)Callsign.GetModule()); Buffer->Append((uint8_t)Callsign.GetModule());
Buffer->Append((uint8)ReflectorModule); Buffer->Append((uint8_t)ReflectorModule);
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
void CDcsProtocol::EncodeConnectNackPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer) void CDcsProtocol::EncodeConnectNackPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer)
{ {
uint8 tag[] = { 'N','A','K',0x00 }; uint8_t tag[] = { 'N','A','K',0x00 };
uint8 cs[CALLSIGN_LEN]; uint8_t cs[CALLSIGN_LEN];
Callsign.GetCallsign(cs); Callsign.GetCallsign(cs);
Buffer->Set(cs, CALLSIGN_LEN-1); Buffer->Set(cs, CALLSIGN_LEN-1);
Buffer->Append((uint8)' '); Buffer->Append((uint8_t)' ');
Buffer->Append((uint8)Callsign.GetModule()); Buffer->Append((uint8_t)Callsign.GetModule());
Buffer->Append((uint8)ReflectorModule); Buffer->Append((uint8_t)ReflectorModule);
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
void CDcsProtocol::EncodeDisconnectPacket(CBuffer *Buffer, std::shared_ptr<CClient>Client) void CDcsProtocol::EncodeDisconnectPacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{ {
Buffer->Set((uint8 *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1); Buffer->Set((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)' '); Buffer->Append((uint8_t)' ');
Buffer->Append((uint8)Client->GetModule()); Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append((uint8)0x00); Buffer->Append((uint8_t)0x00);
Buffer->Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1); Buffer->Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)' '); Buffer->Append((uint8_t)' ');
Buffer->Append((uint8)0x00); Buffer->Append((uint8_t)0x00);
} }
void CDcsProtocol::EncodeDvPacket(const CDvHeaderPacket &Header, const CDvFramePacket &DvFrame, uint32 iSeq, CBuffer *Buffer) const void CDcsProtocol::EncodeDvPacket(const CDvHeaderPacket &Header, const CDvFramePacket &DvFrame, uint32_t iSeq, CBuffer *Buffer) const
{ {
uint8 tag[] = { '0','0','0','1' }; uint8_t tag[] = { '0','0','0','1' };
struct dstar_header DstarHeader; struct dstar_header DstarHeader;
Header.ConvertToDstarStruct(&DstarHeader); Header.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header) - sizeof(uint16)); Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header) - sizeof(uint16_t));
Buffer->Append(DvFrame.GetStreamId()); Buffer->Append(DvFrame.GetStreamId());
Buffer->Append((uint8)(DvFrame.GetPacketId() % 21)); Buffer->Append((uint8_t)(DvFrame.GetPacketId() % 21));
Buffer->Append((uint8 *)DvFrame.GetAmbe(), AMBE_SIZE); Buffer->Append((uint8_t *)DvFrame.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)DvFrame.GetDvData(), DVDATA_SIZE); Buffer->Append((uint8_t *)DvFrame.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8)((iSeq >> 0) & 0xFF)); Buffer->Append((uint8_t)((iSeq >> 0) & 0xFF));
Buffer->Append((uint8)((iSeq >> 8) & 0xFF)); Buffer->Append((uint8_t)((iSeq >> 8) & 0xFF));
Buffer->Append((uint8)((iSeq >> 16) & 0xFF)); Buffer->Append((uint8_t)((iSeq >> 16) & 0xFF));
Buffer->Append((uint8)0x01); Buffer->Append((uint8_t)0x01);
Buffer->Append((uint8)0x00, 38); Buffer->Append((uint8_t)0x00, 38);
} }
void CDcsProtocol::EncodeDvLastPacket(const CDvHeaderPacket &Header, const CDvFramePacket &DvFrame, uint32 iSeq, CBuffer *Buffer) const void CDcsProtocol::EncodeDvLastPacket(const CDvHeaderPacket &Header, const CDvFramePacket &DvFrame, uint32_t iSeq, CBuffer *Buffer) const
{ {
EncodeDvPacket(Header, DvFrame, iSeq, Buffer); EncodeDvPacket(Header, DvFrame, iSeq, Buffer);
(Buffer->data())[45] |= 0x40; (Buffer->data())[45] |= 0x40;

@ -1,32 +1,25 @@
//
// cdcsprotocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdcsprotocol_h #pragma once
#define cdcsprotocol_h
#include "Timer.h" #include "Timer.h"
#include "DCSProtocol.h" #include "Protocol.h"
#include "DVHeaderPacket.h" #include "DVHeaderPacket.h"
#include "DVFramePacket.h" #include "DVFramePacket.h"
#include "DVLastFramePacket.h" #include "DVLastFramePacket.h"
@ -44,14 +37,14 @@ public:
~CDcsStreamCacheItem() {} ~CDcsStreamCacheItem() {}
CDvHeaderPacket m_dvHeader; CDvHeaderPacket m_dvHeader;
uint32 m_iSeqCounter; uint32_t m_iSeqCounter;
}; };
class CDcsProtocol : public CProtocol class CDcsProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);
@ -79,16 +72,13 @@ protected:
void EncodeConnectAckPacket(const CCallsign &, char, CBuffer *); void EncodeConnectAckPacket(const CCallsign &, char, CBuffer *);
void EncodeConnectNackPacket(const CCallsign &, char, CBuffer *); void EncodeConnectNackPacket(const CCallsign &, char, CBuffer *);
void EncodeDisconnectPacket(CBuffer *, std::shared_ptr<CClient>); void EncodeDisconnectPacket(CBuffer *, std::shared_ptr<CClient>);
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32, CBuffer *) const; void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32_t, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32, CBuffer *) const; void EncodeDvLastPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32_t, CBuffer *) const;
protected: protected:
// for keep alive // for keep alive
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
// for queue header caches // for queue header caches
std::array<CDcsStreamCacheItem, NB_OF_MODULES> m_StreamsCache; std::array<CDcsStreamCacheItem, NB_OF_MODULES> m_StreamsCache;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdcsprotocol_h */

@ -1,26 +1,20 @@
//
// cdextraclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DExtraClient.h" #include "DExtraClient.h"
@ -51,5 +45,5 @@ CDextraClient::CDextraClient(const CDextraClient &client)
bool CDextraClient::IsAlive(void) const bool CDextraClient::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < DEXTRA_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < DEXTRA_KEEPALIVE_TIMEOUT);
} }

@ -1,29 +1,22 @@
//
// DExtraClient.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdextraclient_h #pragma once
#define cdextraclient_h
#include "Client.h" #include "Client.h"
@ -59,6 +52,3 @@ protected:
// data // data
int m_ProtRev; int m_ProtRev;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdextraclient_h */

@ -1,27 +1,21 @@
//
// cdextrapeer.cpp
// xlxd
//
// Created by Antony Chazapis (SV9OAN) on 25/2/2018. // Created by Antony Chazapis (SV9OAN) on 25/2/2018.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>

@ -1,40 +1,27 @@
//
// DExtraPeer.h
// xlxd
//
// Created by Antony Chazapis (SV9OAN) on 25/2/2018. // Created by Antony Chazapis (SV9OAN) on 25/2/2018.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdextrapeer_h #pragma once
#define cdextrapeer_h
#include "Peer.h" #include "Peer.h"
#include "DExtraClient.h" #include "DExtraClient.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDextraPeer : public CPeer class CDextraPeer : public CPeer
{ {
public: public:
@ -53,6 +40,3 @@ public:
// revision helper // revision helper
static int GetProtocolRevision(const CVersion &); static int GetProtocolRevision(const CVersion &);
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdextrapeer_h */

@ -1,27 +1,20 @@
//
// cdextraprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -35,7 +28,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDextraProtocol::Initialize(const char *type, int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) bool CDextraProtocol::Initialize(const char *type, int 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))
@ -499,10 +492,10 @@ bool CDextraProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *c
bool CDextraProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header) bool CDextraProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header)
{ {
if ( 56==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x10U==Buffer.data()[4] && 0x20U==Buffer.data()[8] ) if ( 56==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x10U==Buffer.data()[4] && 0x20U==Buffer.data()[8] )
{ {
// create packet // create packet
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), 0x80)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), 0x80));
// check validity of packet // check validity of packet
if ( header && header->IsValid() ) if ( header && header->IsValid() )
return true; return true;
@ -512,10 +505,10 @@ bool CDextraProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_p
bool CDextraProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe) bool CDextraProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
{ {
if ( 27==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && 0U==(Buffer.data()[14] & 0x40U) ) if ( 27==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && 0U==(Buffer.data()[14] & 0x40U) )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), Buffer.data()[14])); dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), Buffer.data()[14]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -525,10 +518,10 @@ bool CDextraProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_pt
bool CDextraProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe) bool CDextraProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe)
{ {
if ( 27==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && (Buffer.data()[14] & 0x40) ) if ( 27==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && (Buffer.data()[14] & 0x40) )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), Buffer.data()[14])); dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), Buffer.data()[14]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -546,12 +539,12 @@ void CDextraProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
void CDextraProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules) void CDextraProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules)
{ {
uint8 lm = (uint8)Modules[0]; uint8_t lm = (uint8_t)Modules[0];
uint8 rm = (uint8)Modules[1]; uint8_t rm = (uint8_t)Modules[1];
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN); Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append(lm); Buffer->Append(lm);
Buffer->Append(rm); Buffer->Append(rm);
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
} }
void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev) void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
@ -560,18 +553,18 @@ void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
if ( ProtRev == 2 ) if ( ProtRev == 2 )
{ {
// XRFxxx // XRFxxx
uint8 rm = (Buffer->data())[8]; uint8_t rm = (Buffer->data())[8];
uint8 lm = (Buffer->data())[9]; uint8_t lm = (Buffer->data())[9];
Buffer->clear(); Buffer->clear();
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN); Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append(lm); Buffer->Append(lm);
Buffer->Append(rm); Buffer->Append(rm);
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
} }
else else
{ {
// regular repeater // regular repeater
uint8 tag[] = { 'A','C','K',0 }; uint8_t tag[] = { 'A','C','K',0 };
Buffer->resize(Buffer->size()-1); Buffer->resize(Buffer->size()-1);
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
@ -579,49 +572,49 @@ void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
void CDextraProtocol::EncodeConnectNackPacket(CBuffer *Buffer) void CDextraProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 'N','A','K',0 }; uint8_t tag[] = { 'N','A','K',0 };
Buffer->resize(Buffer->size()-1); Buffer->resize(Buffer->size()-1);
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
void CDextraProtocol::EncodeDisconnectPacket(CBuffer *Buffer, char Module) void CDextraProtocol::EncodeDisconnectPacket(CBuffer *Buffer, char Module)
{ {
uint8 tag[] = { ' ',0 }; uint8_t tag[] = { ' ',0 };
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN); Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8)Module); Buffer->Append((uint8_t)Module);
Buffer->Append(tag, sizeof(tag)); Buffer->Append(tag, sizeof(tag));
} }
void CDextraProtocol::EncodeDisconnectedPacket(CBuffer *Buffer) void CDextraProtocol::EncodeDisconnectedPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 'D','I','S','C','O','N','N','E','C','T','E','D' }; uint8_t tag[] = { 'D','I','S','C','O','N','N','E','C','T','E','D' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
bool CDextraProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const bool CDextraProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','S','V','T',0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 'D','S','V','T',0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
struct dstar_header DstarHeader; struct dstar_header DstarHeader;
Packet.ConvertToDstarStruct(&DstarHeader); Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80); Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header)); Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true; return true;
} }
bool CDextraProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const bool CDextraProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21)); Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE); Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE); Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true; return true;
@ -629,12 +622,12 @@ bool CDextraProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer
bool CDextraProtocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const bool CDextraProtocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
uint8 tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 }; uint8_t tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1)); Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40)); Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2)); Buffer->Append(tag2, sizeof(tag2));
return true; return true;

@ -1,29 +1,22 @@
//
// DExtraProtocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdextraprotocol_h #pragma once
#define cdextraprotocol_h
#include "Timer.h" #include "Timer.h"
#include "DCSProtocol.h" #include "DCSProtocol.h"
@ -59,7 +52,7 @@ class CDextraProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);
@ -99,6 +92,3 @@ protected:
CTimePoint m_LastKeepaliveTime; CTimePoint m_LastKeepaliveTime;
CTimePoint m_LastPeersLinkTime; CTimePoint m_LastPeersLinkTime;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdextraprotocol_h */

@ -1,32 +1,26 @@
//
// cdmriddir.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 08/10/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"
#include "Reflector.h" #include "Reflector.h"
#include "DMRIdDir.h" #include "DMRIdDir.h"
#include "cdmriddirfile.h" #include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h" #include "DMRIdDirHttp.h"
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -78,7 +72,7 @@ void CDmridDir::Thread()
{ {
// Wait DMRIDDB_REFRESH_RATE minutes // Wait DMRIDDB_REFRESH_RATE minutes
for (int i=0; i<30*DMRIDDB_REFRESH_RATE && keep_running; i++) for (int i=0; i<30*DMRIDDB_REFRESH_RATE && keep_running; i++)
CTimePoint::TaskSleepFor(2000); std::this_thread::sleep_for(std::chrono::milliseconds(2000));
// have lists files changed ? // have lists files changed ?
if ( NeedReload() ) if ( NeedReload() )
@ -111,7 +105,7 @@ bool CDmridDir::Reload(void)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// find // find
const CCallsign *CDmridDir::FindCallsign(uint32 dmrid) const CCallsign *CDmridDir::FindCallsign(uint32_t dmrid)
{ {
auto found = m_CallsignMap.find(dmrid); auto found = m_CallsignMap.find(dmrid);
if ( found != m_CallsignMap.end() ) if ( found != m_CallsignMap.end() )
@ -121,7 +115,7 @@ const CCallsign *CDmridDir::FindCallsign(uint32 dmrid)
return nullptr; return nullptr;
} }
uint32 CDmridDir::FindDmrid(const CCallsign &callsign) uint32_t CDmridDir::FindDmrid(const CCallsign &callsign)
{ {
auto found = m_DmridMap.find(callsign); auto found = m_DmridMap.find(callsign);
if ( found != m_DmridMap.end() ) if ( found != m_DmridMap.end() )

@ -1,29 +1,22 @@
//
// DMRIdDir.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 08/10/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmriddir_h #pragma once
#define cdmriddir_h
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -65,8 +58,8 @@ public:
virtual bool RefreshContent(const CBuffer &) { return false; } virtual bool RefreshContent(const CBuffer &) { return false; }
// find // find
const CCallsign *FindCallsign(uint32); const CCallsign *FindCallsign(uint32_t);
uint32 FindDmrid(const CCallsign &); uint32_t FindDmrid(const CCallsign &);
protected: protected:
// thread // thread
@ -79,17 +72,14 @@ protected:
protected: protected:
// data // data
std::map <uint32, CCallsign> m_CallsignMap; std::map <uint32_t, CCallsign> m_CallsignMap;
std::map <CCallsign, uint32, CDmridDirCallsignCompare> m_DmridMap; std::map <CCallsign, uint32_t, CDmridDirCallsignCompare> m_DmridMap;
// Lock() // Lock()
std::mutex m_Mutex; std::mutex m_Mutex;
// thread // thread
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
std::future<void> m_Future; std::future<void> m_Future;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmriddir_h */

@ -0,0 +1,159 @@
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// 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 <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "Main.h"
#include "DMRIdDirFile.h"
#if (DMRIDDB_USE_RLX_SERVER == 0)
CDmridDirFile g_DmridDir;
#endif
////////////////////////////////////////////////////////////////////////////////////////
// constructor & destructor
CDmridDirFile::CDmridDirFile()
{
::memset(&m_LastModTime, 0, sizeof(time_t));
}
////////////////////////////////////////////////////////////////////////////////////////
// init & close
bool CDmridDirFile::Init(void)
{
return CDmridDir::Init();
}
////////////////////////////////////////////////////////////////////////////////////////
// refresh
bool CDmridDirFile::NeedReload(void)
{
bool needReload = false;
time_t time;
if ( GetLastModTime(&time) )
{
needReload = time != m_LastModTime;
}
return needReload;
}
bool CDmridDirFile::LoadContent(CBuffer *buffer)
{
bool ok = false;
std::ifstream file;
std::streampos size;
// open file
file.open(DMRIDDB_PATH, std::ios::in | std::ios::binary | std::ios::ate);
if ( file.is_open() )
{
// read file
size = file.tellg();
if ( size > 0 )
{
// read file into buffer
buffer->resize((int)size+1);
file.seekg (0, std::ios::beg);
file.read((char *)buffer->data(), (int)size);
// close file
file.close();
// update time
GetLastModTime(&m_LastModTime);
// done
ok = true;
}
}
// done
return ok;
}
bool CDmridDirFile::RefreshContent(const CBuffer &buffer)
{
bool ok = false;
// clear directory
m_CallsignMap.clear();
m_DmridMap.clear();
// scan buffer
if ( buffer.size() > 0 )
{
// crack it
char *ptr1 = (char *)buffer.data();
char *ptr2;
// get next line
while ( (ptr2 = ::strchr(ptr1, '\n')) != nullptr )
{
*ptr2 = 0;
// get items
char *dmrid;
char *callsign;
if ( ((dmrid = ::strtok(ptr1, ";")) != nullptr) && IsValidDmrid(dmrid) )
{
if ( ((callsign = ::strtok(nullptr, ";")) != nullptr) )
{
// new entry
uint32_t ui = atoi(dmrid);
CCallsign cs(callsign, ui);
if ( cs.IsValid() )
{
m_CallsignMap.insert(std::pair<uint32_t,CCallsign>(ui, cs));
m_DmridMap.insert(std::pair<CCallsign,uint32_t>(cs,ui));
}
}
}
// next line
ptr1 = ptr2+1;
}
// done
ok = true;
}
// report
std::cout << "Read " << m_DmridMap.size() << " DMR ids from file " << DMRIDDB_PATH << std::endl;
// done
return ok;
}
bool CDmridDirFile::GetLastModTime(time_t *time)
{
bool ok = false;
struct stat fileStat;
if( ::stat(DMRIDDB_PATH, &fileStat) != -1 )
{
*time = fileStat.st_mtime;
ok = true;
}
return ok;
}

@ -0,0 +1,47 @@
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// 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 "DMRIdDir.h"
class CDmridDirFile : public CDmridDir
{
public:
// constructor
CDmridDirFile();
// destructor
~CDmridDirFile() {}
// init & close
bool Init(void);
// refresh
bool LoadContent(CBuffer *);
bool RefreshContent(const CBuffer &);
protected:
// reload helpers
bool NeedReload(void);
bool GetLastModTime(time_t *);
protected:
// data
time_t m_LastModTime;
};

@ -1,26 +1,20 @@
//
// cdmriddirhttp.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 29/12/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"
@ -68,12 +62,12 @@ bool CDmridDirHttp::RefreshContent(const CBuffer &buffer)
if ( ((callsign = ::strtok(nullptr, ";")) != nullptr) ) if ( ((callsign = ::strtok(nullptr, ";")) != nullptr) )
{ {
// new entry // new entry
uint32 ui = atoi(dmrid); uint32_t ui = atoi(dmrid);
CCallsign cs(callsign, ui); CCallsign cs(callsign, ui);
if ( cs.IsValid() ) if ( cs.IsValid() )
{ {
m_CallsignMap.insert(std::pair<uint32,CCallsign>(ui, cs)); m_CallsignMap.insert(std::pair<uint32_t,CCallsign>(ui, cs));
m_DmridMap.insert(std::pair<CCallsign,uint32>(cs,ui)); m_DmridMap.insert(std::pair<CCallsign,uint32_t>(cs,ui));
} }
} }
} }
@ -148,7 +142,7 @@ bool CDmridDirHttp::HttpGet(const char *hostname, const char *filename, int port
len = read(sock_id, buf, 1440); len = read(sock_id, buf, 1440);
if ( len > 0 ) if ( len > 0 )
{ {
buffer->Append((uint8 *)buf, (int)len); buffer->Append((uint8_t *)buf, (int)len);
ok = true; ok = true;
} }
//} //}
@ -156,7 +150,7 @@ bool CDmridDirHttp::HttpGet(const char *hostname, const char *filename, int port
} }
while (!done); while (!done);
buffer->Append((uint8)0); buffer->Append((uint8_t)0);
// and disconnect // and disconnect
close(sock_id); close(sock_id);

@ -1,34 +1,25 @@
//
// DMRIdDirHttp.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 29/12/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmriddirhttp_h #pragma once
#define cdmriddirhttp_h
#include "DMRIdDir.h" #include "DMRIdDir.h"
////////////////////////////////////////////////////////////////////////////////////////
class CDmridDirHttp : public CDmridDir class CDmridDirHttp : public CDmridDir
{ {
public: public:
@ -47,6 +38,3 @@ protected:
bool NeedReload(void) { return true; } bool NeedReload(void) { return true; }
bool HttpGet(const char *, const char *, int, CBuffer *); bool HttpGet(const char *, const char *, int, CBuffer *);
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmriddirhttp_h */

@ -1,29 +1,23 @@
//
// cdmrmmdvmclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 04/03/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DMMMDVMClient.h" #include "DMRMMDVMClient.h"
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -48,5 +42,5 @@ CDmrmmdvmClient::CDmrmmdvmClient(const CDmrmmdvmClient &client)
bool CDmrmmdvmClient::IsAlive(void) const bool CDmrmmdvmClient::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < DMRMMDVM_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < DMRMMDVM_KEEPALIVE_TIMEOUT);
} }

@ -1,39 +1,25 @@
//
// DMMMDVMClient.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 04/03/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmrmmdvmclient_h #pragma once
#define cdmrmmdvmclient_h
#include "Client.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDmrmmdvmClient : public CClient class CDmrmmdvmClient : public CClient
{ {
public: public:
@ -54,7 +40,3 @@ public:
// status // status
bool IsAlive(void) const; bool IsAlive(void) const;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmrmmdvmclient_h */

@ -1,35 +1,28 @@
//
// cdmrmmdvmprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 104/03/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
#include "DMMMDVMClient.h" #include "DMRMMDVMClient.h"
#include "DMMMDVMProtocol.h" #include "DMRMMDVMProtocol.h"
#include "Reflector.h" #include "Reflector.h"
#include "GateKeeper.h" #include "GateKeeper.h"
#include "CBPT19696.h" #include "CBPTC19696.h"
#include "RS129.h" #include "RS129.h"
#include "Golay2087.h" #include "Golay2087.h"
#include "QR1676.h" #include "QR1676.h"
@ -45,16 +38,16 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// constants // constants
static uint8 g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 }; static uint8_t g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8 g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 }; static uint8_t g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8 g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 }; static uint8_t g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; 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 port, const bool has_ipv4, const bool has_ipv6) bool CDmrmmdvmProtocol::Initialize(const char *type, const int 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))
@ -66,7 +59,7 @@ bool CDmrmmdvmProtocol::Initialize(const char *type, const int ptype, const uint
// random number generator // random number generator
time_t t; time_t t;
::srand((unsigned) time(&t)); ::srand((unsigned) time(&t));
m_uiAuthSeed = (uint32)rand(); m_uiAuthSeed = (uint32_t)rand();
// done // done
return true; return true;
@ -83,8 +76,8 @@ void CDmrmmdvmProtocol::Task(void)
CIp Ip; CIp Ip;
CCallsign Callsign; CCallsign Callsign;
int iRssi; int iRssi;
uint8 Cmd; uint8_t Cmd;
uint8 CallType; uint8_t CallType;
std::unique_ptr<CDvHeaderPacket> Header; std::unique_ptr<CDvHeaderPacket> Header;
std::unique_ptr<CDvLastFramePacket> LastFrame; std::unique_ptr<CDvLastFramePacket> LastFrame;
std::array<std::unique_ptr<CDvFramePacket>, 3> Frames; std::array<std::unique_ptr<CDvFramePacket>, 3> Frames;
@ -261,7 +254,7 @@ void CDmrmmdvmProtocol::Task(void)
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// streams helpers // streams helpers
void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, const CIp &Ip, uint8 cmd, uint8 CallType) void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, const CIp &Ip, uint8_t cmd, uint8_t CallType)
{ {
bool lastheard = false; bool lastheard = false;
@ -478,12 +471,12 @@ void CDmrmmdvmProtocol::HandleKeepalives(void)
bool CDmrmmdvmProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *callsign) bool CDmrmmdvmProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign *callsign)
{ {
uint8 tag[] = { 'R','P','T','P','I','N','G' }; uint8_t tag[] = { 'R','P','T','P','I','N','G' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 11) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 11) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],Buffer.data()[7])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],Buffer.data()[7]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -493,12 +486,12 @@ bool CDmrmmdvmProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign
bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip)
{ {
uint8 tag[] = { 'R','P','T','L' }; uint8_t tag[] = { 'R','P','T','L' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 8) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 8) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -512,12 +505,12 @@ bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *c
bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip)
{ {
uint8 tag[] = { 'R','P','T','K' }; uint8_t tag[] = { 'R','P','T','K' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 40) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 40) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -532,12 +525,12 @@ bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCall
bool CDmrmmdvmProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *callsign) bool CDmrmmdvmProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *callsign)
{ {
uint8 tag[] = { 'R','P','T','C','L' }; uint8_t tag[] = { 'R','P','T','C','L' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 13) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 13) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -547,12 +540,12 @@ bool CDmrmmdvmProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip) bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *callsign, const CIp &Ip)
{ {
uint8 tag[] = { 'R','P','T','C' }; uint8_t tag[] = { 'R','P','T','C' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 302) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 302) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -567,12 +560,12 @@ bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *ca
bool CDmrmmdvmProtocol::IsValidOptionPacket(const CBuffer &Buffer, CCallsign *callsign) bool CDmrmmdvmProtocol::IsValidOptionPacket(const CBuffer &Buffer, CCallsign *callsign)
{ {
uint8 tag[] = { 'R','P','T','O' }; uint8_t tag[] = { 'R','P','T','O' };
bool valid = false; bool valid = false;
if ( (Buffer.size() >= 8) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() >= 8) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
callsign->SetDmrid(uiRptrId, true); callsign->SetDmrid(uiRptrId, true);
callsign->SetModule(MMDVM_MODULE_ID); callsign->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid(); valid = callsign->IsValid();
@ -582,7 +575,7 @@ bool CDmrmmdvmProtocol::IsValidOptionPacket(const CBuffer &Buffer, CCallsign *ca
bool CDmrmmdvmProtocol::IsValidRssiPacket(const CBuffer &Buffer, CCallsign *callsign, int *rssi) bool CDmrmmdvmProtocol::IsValidRssiPacket(const CBuffer &Buffer, CCallsign *callsign, int *rssi)
{ {
uint8 tag[] = { 'R','P','T','I','N','T','R' }; uint8_t tag[] = { 'R','P','T','I','N','T','R' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 17) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 17) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
@ -595,26 +588,26 @@ bool CDmrmmdvmProtocol::IsValidRssiPacket(const CBuffer &Buffer, CCallsign *call
return valid; return valid;
} }
bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header, uint8 *cmd, uint8 *CallType) bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header, uint8_t *cmd, uint8_t *CallType)
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
*cmd = CMD_NONE; *cmd = CMD_NONE;
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
// frame details // frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4; uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1; uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL; uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8 uiSlotType = Buffer.data()[15] & 0x0F; uint8_t uiSlotType = Buffer.data()[15] & 0x0F;
//std::cout << (int)uiSlot << std::endl; //std::cout << (int)uiSlot << std::endl;
if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) && if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) && (uiSlot == DMRMMDVM_REFLECTOR_SLOT) &&
(uiSlotType == MMDVM_SLOTTYPE_HEADER) ) (uiSlotType == MMDVM_SLOTTYPE_HEADER) )
{ {
// extract sync // extract sync
uint8 dmrsync[7]; uint8_t dmrsync[7];
dmrsync[0] = Buffer.data()[33] & 0x0F; dmrsync[0] = Buffer.data()[33] & 0x0F;
::memcpy(&dmrsync[1], &Buffer.data()[34], 5); ::memcpy(&dmrsync[1], &Buffer.data()[34], 5);
dmrsync[6] = Buffer.data()[39] & 0xF0; dmrsync[6] = Buffer.data()[39] & 0xF0;
@ -624,16 +617,16 @@ bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique
{ {
// get payload // get payload
//CBPTC19696 bptc; //CBPTC19696 bptc;
//uint8 lcdata[12]; //uint8_t lcdata[12];
//bptc.decode(&(Buffer.data()[20]), lcdata); //bptc.decode(&(Buffer.data()[20]), lcdata);
// crack DMR header // crack DMR header
//uint8 uiSeqId = Buffer.data()[4]; //uint8_t uiSeqId = Buffer.data()[4];
uint32 uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0)); uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
uint32 uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0)); uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11])); uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F); //uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]); uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// call type // call type
*CallType = uiCallType; *CallType = uiCallType;
@ -671,30 +664,30 @@ bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique
bool CDmrmmdvmProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::array<std::unique_ptr<CDvFramePacket>, 3> &frames) bool CDmrmmdvmProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::array<std::unique_ptr<CDvFramePacket>, 3> &frames)
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
// frame details // frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4; uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1; uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL; uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
if ( ((uiFrameType == DMRMMDVM_FRAMETYPE_VOICE) || (uiFrameType == DMRMMDVM_FRAMETYPE_VOICESYNC)) && if ( ((uiFrameType == DMRMMDVM_FRAMETYPE_VOICE) || (uiFrameType == DMRMMDVM_FRAMETYPE_VOICESYNC)) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) ) (uiSlot == DMRMMDVM_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) )
{ {
// crack DMR header // crack DMR header
//uint8 uiSeqId = Buffer.data()[4]; //uint8_t uiSeqId = Buffer.data()[4];
//uint32 uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0)); //uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
//uint32 uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0)); //uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
//uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11])); //uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F); uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]); uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// crack payload // crack payload
uint8 dmrframe[33]; uint8_t dmrframe[33];
uint8 dmr3ambe[27]; uint8_t dmr3ambe[27];
uint8 dmrambe[9]; uint8_t dmrambe[9];
uint8 dmrsync[7]; uint8_t dmrsync[7];
// get the 33 bytes ambe // get the 33 bytes ambe
memcpy(dmrframe, &(Buffer.data()[20]), 33); memcpy(dmrframe, &(Buffer.data()[20]), 33);
// extract the 3 ambe frames // extract the 3 ambe frames
@ -735,22 +728,22 @@ bool CDmrmmdvmProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::array<s
bool CDmrmmdvmProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &frame) bool CDmrmmdvmProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &frame)
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
// frame details // frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4; uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1; uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
//uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL; //uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8 uiSlotType = Buffer.data()[15] & 0x0F; uint8_t uiSlotType = Buffer.data()[15] & 0x0F;
//std::cout << (int)uiSlot << std::endl; //std::cout << (int)uiSlot << std::endl;
if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) && if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) && (uiSlot == DMRMMDVM_REFLECTOR_SLOT) &&
(uiSlotType == MMDVM_SLOTTYPE_TERMINATOR) ) (uiSlotType == MMDVM_SLOTTYPE_TERMINATOR) )
{ {
// extract sync // extract sync
uint8 dmrsync[7]; uint8_t dmrsync[7];
dmrsync[0] = Buffer.data()[33] & 0x0F; dmrsync[0] = Buffer.data()[33] & 0x0F;
::memcpy(&dmrsync[1], &Buffer.data()[34], 5); ::memcpy(&dmrsync[1], &Buffer.data()[34], 5);
dmrsync[6] = Buffer.data()[39] & 0xF0; dmrsync[6] = Buffer.data()[39] & 0xF0;
@ -760,19 +753,19 @@ bool CDmrmmdvmProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::uni
{ {
// get payload // get payload
//CBPTC19696 bptc; //CBPTC19696 bptc;
//uint8 lcdata[12]; //uint8_t lcdata[12];
//bptc.decode(&(Buffer.data()[20]), lcdata); //bptc.decode(&(Buffer.data()[20]), lcdata);
// crack DMR header // crack DMR header
//uint8 uiSeqId = Buffer.data()[4]; //uint8_t uiSeqId = Buffer.data()[4];
//uint32 uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0)); //uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
//uint32 uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0)); //uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
//uint32 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11])); //uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F); //uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]); uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// dummy ambe // dummy ambe
uint8 ambe[9]; uint8_t ambe[9];
::memset(ambe, 0, sizeof(ambe)); ::memset(ambe, 0, sizeof(ambe));
@ -791,23 +784,23 @@ bool CDmrmmdvmProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::uni
void CDmrmmdvmProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client) void CDmrmmdvmProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{ {
uint8 tag[] = { 'M','S','T','P','O','N','G' }; uint8_t tag[] = { 'M','S','T','P','O','N','G' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
uint32 uiDmrId = Client->GetCallsign().GetDmrid(); uint32_t uiDmrId = Client->GetCallsign().GetDmrid();
Buffer->Append((uint8 *)&uiDmrId, 4); Buffer->Append((uint8_t *)&uiDmrId, 4);
} }
void CDmrmmdvmProtocol::EncodeAckPacket(CBuffer *Buffer, const CCallsign &Callsign) void CDmrmmdvmProtocol::EncodeAckPacket(CBuffer *Buffer, const CCallsign &Callsign)
{ {
uint8 tag[] = { 'R','P','T','A','C','K' }; uint8_t tag[] = { 'R','P','T','A','C','K' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDmrmmdvmProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const CCallsign &Callsign, uint32 AuthSeed) void CDmrmmdvmProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const CCallsign &Callsign, uint32_t AuthSeed)
{ {
uint8 tag[] = { 'R','P','T','A','C','K' }; uint8_t tag[] = { 'R','P','T','A','C','K' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(AuthSeed); Buffer->Append(AuthSeed);
@ -815,55 +808,55 @@ void CDmrmmdvmProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const CCallsign
void CDmrmmdvmProtocol::EncodeNackPacket(CBuffer *Buffer, const CCallsign &Callsign) void CDmrmmdvmProtocol::EncodeNackPacket(CBuffer *Buffer, const CCallsign &Callsign)
{ {
uint8 tag[] = { 'M','S','T','N','A','K' }; uint8_t tag[] = { 'M','S','T','N','A','K' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDmrmmdvmProtocol::EncodeClosePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client) void CDmrmmdvmProtocol::EncodeClosePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{ {
uint8 tag[] = { 'M','S','T','C','L' }; uint8_t tag[] = { 'M','S','T','C','L' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
bool CDmrmmdvmProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, uint8 seqid, CBuffer *Buffer) const bool CDmrmmdvmProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, uint8_t seqid, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
// DMR header // DMR header
// uiSeqId // uiSeqId
Buffer->Append((uint8)seqid); Buffer->Append((uint8_t)seqid);
// uiSrcId // uiSrcId
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid(); uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId); AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId = TG9 // uiDstId = TG9
uint32 uiDstId = 9; // ModuleToDmrDestId(Packet.GetRpt2Module()); uint32_t uiDstId = 9; // ModuleToDmrDestId(Packet.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId); AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId // uiRptrId
uint32 uiRptrId = Packet.GetRpt1Callsign().GetDmrid(); uint32_t uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId); AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField // uiBitField
uint8 uiBitField = uint8_t uiBitField =
(DMRMMDVM_FRAMETYPE_DATASYNC << 4) | (DMRMMDVM_FRAMETYPE_DATASYNC << 4) |
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) | ((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) |
MMDVM_SLOTTYPE_HEADER; MMDVM_SLOTTYPE_HEADER;
Buffer->Append((uint8)uiBitField); Buffer->Append((uint8_t)uiBitField);
// uiStreamId // uiStreamId
uint32 uiStreamId = Packet.GetStreamId(); uint32_t uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32)uiStreamId); Buffer->Append((uint32_t)uiStreamId);
// Payload // Payload
AppendVoiceLCToBuffer(Buffer, uiSrcId); AppendVoiceLCToBuffer(Buffer, uiSrcId);
// BER // BER
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
// RSSI // RSSI
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
// done // done
return true; return true;
@ -872,25 +865,25 @@ bool CDmrmmdvmProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, uint
void CDmrmmdvmProtocol::EncodeDvPacket( void CDmrmmdvmProtocol::EncodeDvPacket(
const CDvHeaderPacket &Header, const CDvHeaderPacket &Header,
const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2, const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2,
uint8 seqid, CBuffer *Buffer) const uint8_t seqid, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
// DMR header // DMR header
// uiSeqId // uiSeqId
Buffer->Append((uint8)seqid); Buffer->Append((uint8_t)seqid);
// uiSrcId // uiSrcId
uint32 uiSrcId = Header.GetMyCallsign().GetDmrid(); uint32_t uiSrcId = Header.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId); AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId = TG9 // uiDstId = TG9
uint32 uiDstId = 9; // ModuleToDmrDestId(Header.GetRpt2Module()); uint32_t uiDstId = 9; // ModuleToDmrDestId(Header.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId); AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId // uiRptrId
uint32 uiRptrId = Header.GetRpt1Callsign().GetDmrid(); uint32_t uiRptrId = Header.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId); AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField // uiBitField
uint8 uiBitField = uint8_t uiBitField =
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00); ((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00);
if ( DvFrame0.GetDmrPacketId() == 0 ) if ( DvFrame0.GetDmrPacketId() == 0 )
{ {
@ -901,21 +894,21 @@ void CDmrmmdvmProtocol::EncodeDvPacket(
uiBitField |= (DMRMMDVM_FRAMETYPE_VOICE << 4); uiBitField |= (DMRMMDVM_FRAMETYPE_VOICE << 4);
} }
uiBitField |= (DvFrame0.GetDmrPacketId() & 0x0F); uiBitField |= (DvFrame0.GetDmrPacketId() & 0x0F);
Buffer->Append((uint8)uiBitField); Buffer->Append((uint8_t)uiBitField);
// uiStreamId // uiStreamId
uint32 uiStreamId = Header.GetStreamId(); uint32_t uiStreamId = Header.GetStreamId();
Buffer->Append((uint32)uiStreamId); Buffer->Append((uint32_t)uiStreamId);
// Payload // Payload
// frame0 // frame0
Buffer->ReplaceAt(20, DvFrame0.GetAmbePlus(), 9); Buffer->ReplaceAt(20, DvFrame0.GetAmbePlus(), 9);
// 1/2 frame1 // 1/2 frame1
Buffer->ReplaceAt(29, DvFrame1.GetAmbePlus(), 5); Buffer->ReplaceAt(29, DvFrame1.GetAmbePlus(), 5);
Buffer->ReplaceAt(33, (uint8)(Buffer->at(33) & 0xF0)); Buffer->ReplaceAt(33, (uint8_t)(Buffer->at(33) & 0xF0));
// 1/2 frame1 // 1/2 frame1
Buffer->ReplaceAt(39, DvFrame1.GetAmbePlus()+4, 5); Buffer->ReplaceAt(39, DvFrame1.GetAmbePlus()+4, 5);
Buffer->ReplaceAt(39, (uint8)(Buffer->at(39) & 0x0F)); Buffer->ReplaceAt(39, (uint8_t)(Buffer->at(39) & 0x0F));
// frame2 // frame2
Buffer->ReplaceAt(44, DvFrame2.GetAmbePlus(), 9); Buffer->ReplaceAt(44, DvFrame2.GetAmbePlus(), 9);
@ -928,56 +921,56 @@ void CDmrmmdvmProtocol::EncodeDvPacket(
//dump.DebugDump(g_Reflector.m_DebugFile); //dump.DebugDump(g_Reflector.m_DebugFile);
// BER // BER
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
// RSSI // RSSI
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
} }
void CDmrmmdvmProtocol::EncodeDvLastPacket(const CDvHeaderPacket &Packet, uint8 seqid, CBuffer *Buffer) const void CDmrmmdvmProtocol::EncodeDvLastPacket(const CDvHeaderPacket &Packet, uint8_t seqid, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','M','R','D' }; uint8_t tag[] = { 'D','M','R','D' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
// DMR header // DMR header
// uiSeqId // uiSeqId
Buffer->Append((uint8)seqid); Buffer->Append((uint8_t)seqid);
// uiSrcId // uiSrcId
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid(); uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId); AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId // uiDstId
uint32 uiDstId = 9; //ModuleToDmrDestId(Packet.GetRpt2Module()); uint32_t uiDstId = 9; //ModuleToDmrDestId(Packet.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId); AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId // uiRptrId
uint32 uiRptrId = Packet.GetRpt1Callsign().GetDmrid(); uint32_t uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId); AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField // uiBitField
uint8 uiBitField = uint8_t uiBitField =
(DMRMMDVM_FRAMETYPE_DATASYNC << 4) | (DMRMMDVM_FRAMETYPE_DATASYNC << 4) |
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) | ((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) |
MMDVM_SLOTTYPE_TERMINATOR; MMDVM_SLOTTYPE_TERMINATOR;
Buffer->Append((uint8)uiBitField); Buffer->Append((uint8_t)uiBitField);
// uiStreamId // uiStreamId
uint32 uiStreamId = Packet.GetStreamId(); uint32_t uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32)uiStreamId); Buffer->Append((uint32_t)uiStreamId);
// Payload // Payload
AppendTerminatorLCToBuffer(Buffer, uiSrcId); AppendTerminatorLCToBuffer(Buffer, uiSrcId);
// BER // BER
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
// RSSI // RSSI
Buffer->Append((uint8)0); Buffer->Append((uint8_t)0);
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper // DestId to Module helper
char CDmrmmdvmProtocol::DmrDstIdToModule(uint32 tg) const char CDmrmmdvmProtocol::DmrDstIdToModule(uint32_t tg) const
{ {
// is it a 4xxx ? // is it a 4xxx ?
if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) ) if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) )
@ -987,33 +980,33 @@ char CDmrmmdvmProtocol::DmrDstIdToModule(uint32 tg) const
return ' '; return ' ';
} }
uint32 CDmrmmdvmProtocol::ModuleToDmrDestId(char m) const uint32_t CDmrmmdvmProtocol::ModuleToDmrDestId(char m) const
{ {
return (uint32)(m - 'A')+4001; return (uint32_t)(m - 'A')+4001;
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// Buffer & LC helpers // Buffer & LC helpers
void CDmrmmdvmProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) const void CDmrmmdvmProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32_t uiSrcId) const
{ {
uint8 payload[33]; uint8_t payload[33];
// fill payload // fill payload
CBPTC19696 bptc; CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload)); ::memset(payload, 0, sizeof(payload));
// LC data // LC data
uint8 lc[12]; uint8_t lc[12];
{ {
::memset(lc, 0, sizeof(lc)); ::memset(lc, 0, sizeof(lc));
// uiDstId = TG9 // uiDstId = TG9
lc[5] = 9; lc[5] = 9;
// uiSrcId // uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId)); lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId)); lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId)); lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity // parity
uint8 parity[4]; uint8_t parity[4];
CRS129::encode(lc, 9, parity); CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ DMR_VOICE_LC_HEADER_CRC_MASK; lc[9] = parity[2] ^ DMR_VOICE_LC_HEADER_CRC_MASK;
lc[10] = parity[1] ^ DMR_VOICE_LC_HEADER_CRC_MASK; lc[10] = parity[1] ^ DMR_VOICE_LC_HEADER_CRC_MASK;
@ -1024,7 +1017,7 @@ void CDmrmmdvmProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) c
// slot type // slot type
{ {
// slot type // slot type
uint8 slottype[3]; uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype)); ::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
slottype[0] |= (DMR_DT_VOICE_LC_HEADER << 0) & 0x0FU; slottype[0] |= (DMR_DT_VOICE_LC_HEADER << 0) & 0x0FU;
@ -1042,25 +1035,25 @@ void CDmrmmdvmProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) c
buffer->Append(payload, sizeof(payload)); buffer->Append(payload, sizeof(payload));
} }
void CDmrmmdvmProtocol::AppendTerminatorLCToBuffer(CBuffer *buffer, uint32 uiSrcId) const void CDmrmmdvmProtocol::AppendTerminatorLCToBuffer(CBuffer *buffer, uint32_t uiSrcId) const
{ {
uint8 payload[33]; uint8_t payload[33];
// fill payload // fill payload
CBPTC19696 bptc; CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload)); ::memset(payload, 0, sizeof(payload));
// LC data // LC data
uint8 lc[12]; uint8_t lc[12];
{ {
::memset(lc, 0, sizeof(lc)); ::memset(lc, 0, sizeof(lc));
// uiDstId = TG9 // uiDstId = TG9
lc[5] = 9; lc[5] = 9;
// uiSrcId // uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId)); lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId)); lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId)); lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity // parity
uint8 parity[4]; uint8_t parity[4];
CRS129::encode(lc, 9, parity); CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ DMR_TERMINATOR_WITH_LC_CRC_MASK; lc[9] = parity[2] ^ DMR_TERMINATOR_WITH_LC_CRC_MASK;
lc[10] = parity[1] ^ DMR_TERMINATOR_WITH_LC_CRC_MASK; lc[10] = parity[1] ^ DMR_TERMINATOR_WITH_LC_CRC_MASK;
@ -1071,7 +1064,7 @@ void CDmrmmdvmProtocol::AppendTerminatorLCToBuffer(CBuffer *buffer, uint32 uiSrc
// slot type // slot type
{ {
// slot type // slot type
uint8 slottype[3]; uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype)); ::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
slottype[0] |= (DMR_DT_TERMINATOR_WITH_LC << 0) & 0x0FU; slottype[0] |= (DMR_DT_TERMINATOR_WITH_LC << 0) & 0x0FU;
@ -1088,21 +1081,21 @@ void CDmrmmdvmProtocol::AppendTerminatorLCToBuffer(CBuffer *buffer, uint32 uiSrc
buffer->Append(payload, sizeof(payload)); buffer->Append(payload, sizeof(payload));
} }
void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId) const void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8_t uiDmrPacketId) const
{ {
// voice packet A ? // voice packet A ?
if ( uiDmrPacketId == 0 ) if ( uiDmrPacketId == 0 )
{ {
// sync // sync
buffer->ReplaceAt(33, (uint8)(buffer->at(33) | (g_DmrSyncBSVoice[0] & 0x0F))); buffer->ReplaceAt(33, (uint8_t)(buffer->at(33) | (g_DmrSyncBSVoice[0] & 0x0F)));
buffer->ReplaceAt(34, g_DmrSyncBSVoice+1, 5); buffer->ReplaceAt(34, g_DmrSyncBSVoice+1, 5);
buffer->ReplaceAt(39, (uint8)(buffer->at(39) | (g_DmrSyncBSVoice[6] & 0xF0))); buffer->ReplaceAt(39, (uint8_t)(buffer->at(39) | (g_DmrSyncBSVoice[6] & 0xF0)));
} }
// voice packet B,C,D,E ? // voice packet B,C,D,E ?
else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) ) else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) )
{ {
// EMB LC // EMB LC
uint8 emb[2]; uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00; //emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06; //emb[0] |= (LCSS << 1) & 0x06;
@ -1110,21 +1103,21 @@ void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode // encode
CQR1676::encode(emb); CQR1676::encode(emb);
// and append // and append
buffer->ReplaceAt(33, (uint8)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F))); buffer->ReplaceAt(33, (uint8_t)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0))); buffer->ReplaceAt(34, (uint8_t)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8)(buffer->at(34) & 0xF0)); buffer->ReplaceAt(34, (uint8_t)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8)0); buffer->ReplaceAt(35, (uint8_t)0);
buffer->ReplaceAt(36, (uint8)0); buffer->ReplaceAt(36, (uint8_t)0);
buffer->ReplaceAt(37, (uint8)0); buffer->ReplaceAt(37, (uint8_t)0);
buffer->ReplaceAt(38, (uint8)(buffer->at(38) & 0x0F)); buffer->ReplaceAt(38, (uint8_t)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F))); buffer->ReplaceAt(38, (uint8_t)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0))); buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
} }
// voice packet F // voice packet F
else else
{ {
// nullptr // nullptr
uint8 emb[2]; uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00; //emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06; //emb[0] |= (LCSS << 1) & 0x06;
@ -1132,29 +1125,29 @@ void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode // encode
CQR1676::encode(emb); CQR1676::encode(emb);
// and append // and append
buffer->ReplaceAt(33, (uint8)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F))); buffer->ReplaceAt(33, (uint8_t)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0))); buffer->ReplaceAt(34, (uint8_t)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8)(buffer->at(34) & 0xF0)); buffer->ReplaceAt(34, (uint8_t)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8)0); buffer->ReplaceAt(35, (uint8_t)0);
buffer->ReplaceAt(36, (uint8)0); buffer->ReplaceAt(36, (uint8_t)0);
buffer->ReplaceAt(37, (uint8)0); buffer->ReplaceAt(37, (uint8_t)0);
buffer->ReplaceAt(38, (uint8)(buffer->at(38) & 0x0F)); buffer->ReplaceAt(38, (uint8_t)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F))); buffer->ReplaceAt(38, (uint8_t)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0))); buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
} }
} }
void CDmrmmdvmProtocol::AppendDmrIdToBuffer(CBuffer *buffer, uint32 id) const void CDmrmmdvmProtocol::AppendDmrIdToBuffer(CBuffer *buffer, uint32_t id) const
{ {
buffer->Append((uint8)LOBYTE(HIWORD(id))); buffer->Append((uint8_t)LOBYTE(HIWORD(id)));
buffer->Append((uint8)HIBYTE(LOWORD(id))); buffer->Append((uint8_t)HIBYTE(LOWORD(id)));
buffer->Append((uint8)LOBYTE(LOWORD(id))); buffer->Append((uint8_t)LOBYTE(LOWORD(id)));
} }
void CDmrmmdvmProtocol::AppendDmrRptrIdToBuffer(CBuffer *buffer, uint32 id) const void CDmrmmdvmProtocol::AppendDmrRptrIdToBuffer(CBuffer *buffer, uint32_t id) const
{ {
buffer->Append((uint8)HIBYTE(HIWORD(id))); buffer->Append((uint8_t)HIBYTE(HIWORD(id)));
buffer->Append((uint8)LOBYTE(HIWORD(id))); buffer->Append((uint8_t)LOBYTE(HIWORD(id)));
buffer->Append((uint8)HIBYTE(LOWORD(id))); buffer->Append((uint8_t)HIBYTE(LOWORD(id)));
buffer->Append((uint8)LOBYTE(LOWORD(id))); buffer->Append((uint8_t)LOBYTE(LOWORD(id)));
} }

@ -1,30 +1,22 @@
//
// DMMMDVMProtocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 04/03/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmrmmdvmprotocol_h #pragma once
#define cdmrmmdvmprotocol_h
#include "Timer.h" #include "Timer.h"
#include "DCSProtocol.h" #include "DCSProtocol.h"
@ -60,7 +52,7 @@ public:
CDvFramePacket m_dvFrame0; CDvFramePacket m_dvFrame0;
CDvFramePacket m_dvFrame1; CDvFramePacket m_dvFrame1;
uint8 m_uiSeqId; uint8_t m_uiSeqId;
}; };
@ -68,7 +60,7 @@ class CDmrmmdvmProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);
@ -81,7 +73,7 @@ protected:
void HandleKeepalives(void); void HandleKeepalives(void);
// stream helpers // stream helpers
void OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &, const CIp &, uint8, uint8); void OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &, const CIp &, uint8_t, uint8_t);
// packet decoding helpers // packet decoding helpers
bool IsValidConnectPacket(const CBuffer &, CCallsign *, const CIp &); bool IsValidConnectPacket(const CBuffer &, CCallsign *, const CIp &);
@ -91,30 +83,30 @@ protected:
bool IsValidOptionPacket(const CBuffer &, CCallsign *); bool IsValidOptionPacket(const CBuffer &, CCallsign *);
bool IsValidKeepAlivePacket(const CBuffer &, CCallsign *); bool IsValidKeepAlivePacket(const CBuffer &, CCallsign *);
bool IsValidRssiPacket(const CBuffer &, CCallsign *, int *); bool IsValidRssiPacket(const CBuffer &, CCallsign *, int *);
bool IsValidDvHeaderPacket(const CBuffer &, std::unique_ptr<CDvHeaderPacket> &, uint8 *, uint8 *); bool IsValidDvHeaderPacket(const CBuffer &, std::unique_ptr<CDvHeaderPacket> &, uint8_t *, uint8_t *);
bool IsValidDvFramePacket(const CBuffer &, std::array<std::unique_ptr<CDvFramePacket>, 3> &); bool IsValidDvFramePacket(const CBuffer &, std::array<std::unique_ptr<CDvFramePacket>, 3> &);
bool IsValidDvLastFramePacket(const CBuffer &, std::unique_ptr<CDvLastFramePacket> &); bool IsValidDvLastFramePacket(const CBuffer &, std::unique_ptr<CDvLastFramePacket> &);
// packet encoding helpers // packet encoding helpers
void EncodeKeepAlivePacket(CBuffer *, std::shared_ptr<CClient>); void EncodeKeepAlivePacket(CBuffer *, std::shared_ptr<CClient>);
void EncodeAckPacket(CBuffer *, const CCallsign &); void EncodeAckPacket(CBuffer *, const CCallsign &);
void EncodeConnectAckPacket(CBuffer *, const CCallsign &, uint32); void EncodeConnectAckPacket(CBuffer *, const CCallsign &, uint32_t);
void EncodeNackPacket(CBuffer *, const CCallsign &); void EncodeNackPacket(CBuffer *, const CCallsign &);
void EncodeClosePacket(CBuffer *, std::shared_ptr<CClient>); void EncodeClosePacket(CBuffer *, std::shared_ptr<CClient>);
bool EncodeDvHeaderPacket(const CDvHeaderPacket &, uint8, CBuffer *) const; bool EncodeDvHeaderPacket(const CDvHeaderPacket &, uint8_t, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8, CBuffer *) const; void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8_t, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, uint8, CBuffer *) const; void EncodeDvLastPacket(const CDvHeaderPacket &, uint8_t, CBuffer *) const;
// dmr DstId to Module helper // dmr DstId to Module helper
char DmrDstIdToModule(uint32) const; char DmrDstIdToModule(uint32_t) const;
uint32 ModuleToDmrDestId(char) const; uint32_t ModuleToDmrDestId(char) const;
// Buffer & LC helpers // Buffer & LC helpers
void AppendVoiceLCToBuffer(CBuffer *, uint32) const; void AppendVoiceLCToBuffer(CBuffer *, uint32_t) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32) const; void AppendTerminatorLCToBuffer(CBuffer *, uint32_t) const;
void ReplaceEMBInBuffer(CBuffer *, uint8) const; void ReplaceEMBInBuffer(CBuffer *, uint8_t) const;
void AppendDmrIdToBuffer(CBuffer *, uint32) const; void AppendDmrIdToBuffer(CBuffer *, uint32_t) const;
void AppendDmrRptrIdToBuffer(CBuffer *, uint32) const; void AppendDmrRptrIdToBuffer(CBuffer *, uint32_t) const;
protected: protected:
@ -122,15 +114,11 @@ protected:
CTimePoint m_LastKeepaliveTime; CTimePoint m_LastKeepaliveTime;
// for stream id // for stream id
uint16 m_uiStreamId; uint16_t m_uiStreamId;
// for queue header caches // for queue header caches
std::array<CDmrmmdvmStreamCacheItem, NB_OF_MODULES> m_StreamsCache; std::array<CDmrmmdvmStreamCacheItem, NB_OF_MODULES> m_StreamsCache;
// for authentication // for authentication
uint32 m_uiAuthSeed; uint32_t m_uiAuthSeed;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmrmmdvmprotocol_h */

@ -1,29 +1,23 @@
//
// cdmrplusclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL on 10/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "cdmrplusclient.h" #include "DMRPlusClient.h"
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -48,5 +42,5 @@ CDmrplusClient::CDmrplusClient(const CDmrplusClient &client)
bool CDmrplusClient::IsAlive(void) const bool CDmrplusClient::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < DMRPLUS_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < DMRPLUS_KEEPALIVE_TIMEOUT);
} }

@ -1,39 +1,25 @@
//
// cdmrplusclient.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmrplusclient_h #pragma once
#define cdmrplusclient_h
#include "Client.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDmrplusClient : public CClient class CDmrplusClient : public CClient
{ {
public: public:
@ -54,6 +40,3 @@ public:
// status // status
bool IsAlive(void) const; bool IsAlive(void) const;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmrplusclient_h */

@ -1,36 +1,29 @@
//
// cdmrplusprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
#include "cdmrplusclient.h" #include "DMRPlusClient.h"
#include "DMRPlusProtocol.h" #include "DMRPlusProtocol.h"
#include "Reflector.h" #include "Reflector.h"
#include "GateKeeper.h" #include "GateKeeper.h"
#include "DMRIdDir.h" #include "DMRIdDir.h"
#include "CBPT19696.h" #include "CBPTC19696.h"
#include "RS129.h" #include "RS129.h"
#include "Golay2087.h" #include "Golay2087.h"
#include "QR1676.h" #include "QR1676.h"
@ -38,16 +31,16 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// constants // constants
static uint8 g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 }; static uint8_t g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8 g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 }; static uint8_t g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8 g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 }; static uint8_t g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; 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 port, const bool has_ipv4, const bool has_ipv6) bool CDmrplusProtocol::Initialize(const char *type, const int 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))
@ -303,7 +296,7 @@ void CDmrplusProtocol::HandleQueue(void)
m_Queue.Unlock(); m_Queue.Unlock();
} }
void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8 module) void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8_t module)
{ {
if ( buffer.size() > 0 ) if ( buffer.size() > 0 )
{ {
@ -377,7 +370,7 @@ bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *ca
char sz[9]; char sz[9];
::memcpy(sz, Buffer.data(), 8); ::memcpy(sz, Buffer.data(), 8);
sz[8] = 0; sz[8] = 0;
uint32 dmrid = atoi(sz); uint32_t dmrid = atoi(sz);
callsign->SetDmrid(dmrid, true); callsign->SetDmrid(dmrid, true);
callsign->SetModule(DMRPLUS_MODULE_ID); callsign->SetModule(DMRPLUS_MODULE_ID);
::memcpy(sz, &Buffer.data()[8], 4); ::memcpy(sz, &Buffer.data()[8], 4);
@ -400,7 +393,7 @@ bool CDmrplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
char sz[9]; char sz[9];
::memcpy(sz, Buffer.data(), 8); ::memcpy(sz, Buffer.data(), 8);
sz[8] = 0; sz[8] = 0;
uint32 dmrid = atoi(sz); uint32_t dmrid = atoi(sz);
callsign->SetDmrid(dmrid, true); callsign->SetDmrid(dmrid, true);
callsign->SetModule(DMRPLUS_MODULE_ID); callsign->SetModule(DMRPLUS_MODULE_ID);
*reflectormodule = Buffer.data()[11] - '0' + 'A'; *reflectormodule = Buffer.data()[11] - '0' + 'A';
@ -411,20 +404,20 @@ bool CDmrplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &Header) bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &Header)
{ {
uint8 uiPacketType = Buffer.data()[8]; uint8_t uiPacketType = Buffer.data()[8];
if ( (Buffer.size() == 72) && ( uiPacketType == 2 ) ) if ( (Buffer.size() == 72) && ( uiPacketType == 2 ) )
{ {
// frame details // frame details
uint8 uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1; uint8_t uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL; uint8_t uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8 uiColourCode = Buffer.data()[20] & 0x0F; uint8_t uiColourCode = Buffer.data()[20] & 0x0F;
if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) ) if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) )
{ {
// more frames details // more frames details
//uint8 uiSeqId = Buffer.data()[4]; //uint8_t uiSeqId = Buffer.data()[4];
//uint8 uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type //uint8_t uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
uint32 uiDstId = *(uint32 *)(&Buffer.data()[64]) & 0x00FFFFFF; uint32_t uiDstId = *(uint32_t *)(&Buffer.data()[64]) & 0x00FFFFFF;
uint32 uiSrcId = *(uint32 *)(&Buffer.data()[68]) & 0x00FFFFFF; uint32_t uiSrcId = *(uint32_t *)(&Buffer.data()[68]) & 0x00FFFFFF;
// build DVHeader // build DVHeader
CCallsign csMY = CCallsign("", uiSrcId); CCallsign csMY = CCallsign("", uiSrcId);
@ -432,7 +425,7 @@ bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffe
rpt1.SetModule(DMRPLUS_MODULE_ID); rpt1.SetModule(DMRPLUS_MODULE_ID);
CCallsign rpt2 = m_ReflectorCallsign; CCallsign rpt2 = m_ReflectorCallsign;
rpt2.SetModule(DmrDstIdToModule(uiDstId)); rpt2.SetModule(DmrDstIdToModule(uiDstId));
uint32 uiStreamId = IpToStreamId(Ip); uint32_t uiStreamId = IpToStreamId(Ip);
// and packet // and packet
Header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(uiSrcId, CCallsign("CQCQCQ"), rpt1, rpt2, uiStreamId, 0, 0)); Header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(uiSrcId, CCallsign("CQCQCQ"), rpt1, rpt2, uiStreamId, 0, 0));
@ -445,26 +438,26 @@ bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffe
bool CDmrplusProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer, std::array<std::unique_ptr<CDvFramePacket>, 3> &frames) bool CDmrplusProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer, std::array<std::unique_ptr<CDvFramePacket>, 3> &frames)
{ {
uint8 uiPacketType = Buffer.data()[8]; uint8_t uiPacketType = Buffer.data()[8];
if ( (Buffer.size() == 72) && ((uiPacketType == 1) || (uiPacketType == 3)) ) if ( (Buffer.size() == 72) && ((uiPacketType == 1) || (uiPacketType == 3)) )
{ {
// frame details // frame details
uint8 uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1; uint8_t uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL; uint8_t uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8 uiColourCode = Buffer.data()[20] & 0x0F; uint8_t uiColourCode = Buffer.data()[20] & 0x0F;
if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) ) if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) )
{ {
// more frames details // more frames details
//uint8 uiSeqId = Buffer.data()[4]; //uint8_t uiSeqId = Buffer.data()[4];
uint8 uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type uint8_t uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
//uint32 uiDstId = *(uint32 *)(&Buffer.data()[64]) & 0x00FFFFFF; //uint32_t uiDstId = *(uint32_t *)(&Buffer.data()[64]) & 0x00FFFFFF;
//uint32 uiSrcId = *(uint32 *)(&Buffer.data()[68]) & 0x00FFFFFF; //uint32_t uiSrcId = *(uint32_t *)(&Buffer.data()[68]) & 0x00FFFFFF;
// crack payload // crack payload
uint8 dmrframe[33]; uint8_t dmrframe[33];
uint8 dmr3ambe[27]; uint8_t dmr3ambe[27];
uint8 dmrambe[9]; uint8_t dmrambe[9];
uint8 dmrsync[7]; uint8_t dmrsync[7];
// get the 33 bytes ambe // get the 33 bytes ambe
memcpy(dmrframe, &(Buffer.data()[26]), 33); memcpy(dmrframe, &(Buffer.data()[26]), 33);
// handle endianess // handle endianess
@ -480,7 +473,7 @@ bool CDmrplusProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer
dmrsync[6] = dmrframe[19] & 0xF0; dmrsync[6] = dmrframe[19] & 0xF0;
// and create 3 dv frames // and create 3 dv frames
uint32 uiStreamId = IpToStreamId(Ip); uint32_t uiStreamId = IpToStreamId(Ip);
// frame1 // frame1
memcpy(dmrambe, &dmr3ambe[0], 9); memcpy(dmrambe, &dmr3ambe[0], 9);
frames[0] = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(dmrambe, dmrsync, uiStreamId, uiVoiceSeq, 1)); frames[0] = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(dmrambe, dmrsync, uiStreamId, uiVoiceSeq, 1));
@ -514,19 +507,19 @@ bool CDmrplusProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer
void CDmrplusProtocol::EncodeConnectAckPacket(CBuffer *Buffer) void CDmrplusProtocol::EncodeConnectAckPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 'A','C','K',' ','O','K',0x0A,0x00 }; uint8_t tag[] = { 'A','C','K',' ','O','K',0x0A,0x00 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDmrplusProtocol::EncodeConnectNackPacket(CBuffer *Buffer) void CDmrplusProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 'N','A','K',' ','O','K',0x0A,0x00 }; uint8_t tag[] = { 'N','A','K',' ','O','K',0x0A,0x00 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02, uint8_t tag[] = { 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,
0x00,0x05,0x01,0x02,0x00,0x00,0x00 0x00,0x05,0x01,0x02,0x00,0x00,0x00
} ; } ;
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
@ -536,32 +529,32 @@ bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuff
// uiPktType // uiPktType
//Buffer->ReplaceAt(8, 2); //Buffer->ReplaceAt(8, 2);
// uiSlot // uiSlot
Buffer->Append((uint16)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222)); Buffer->Append((uint16_t)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
// uiSlotType // uiSlotType
Buffer->Append((uint16)0xEEEE); Buffer->Append((uint16_t)0xEEEE);
// uiColourCode // uiColourCode
uint8 uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4); uint8_t uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8)uiColourCode); Buffer->Append((uint8_t)uiColourCode);
Buffer->Append((uint8)uiColourCode); Buffer->Append((uint8_t)uiColourCode);
// uiFrameType // uiFrameType
Buffer->Append((uint16)0x1111); Buffer->Append((uint16_t)0x1111);
// reserved // reserved
Buffer->Append((uint16)0x0000); Buffer->Append((uint16_t)0x0000);
// payload // payload
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid() & 0x00FFFFFF; uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32 uiDstId = ModuleToDmrDestId(Packet.GetRpt2Module()) & 0x00FFFFFF; uint32_t uiDstId = ModuleToDmrDestId(Packet.GetRpt2Module()) & 0x00FFFFFF;
Buffer->Append((uint8)0x00, 34); Buffer->Append((uint8_t)0x00, 34);
Buffer->ReplaceAt(36, HIBYTE(HIWORD(uiSrcId))); Buffer->ReplaceAt(36, HIBYTE(HIWORD(uiSrcId)));
Buffer->ReplaceAt(38, LOBYTE(HIWORD(uiSrcId))); Buffer->ReplaceAt(38, LOBYTE(HIWORD(uiSrcId)));
Buffer->ReplaceAt(40, HIBYTE(LOWORD(uiSrcId))); Buffer->ReplaceAt(40, HIBYTE(LOWORD(uiSrcId)));
Buffer->ReplaceAt(42, LOBYTE(LOWORD(uiSrcId))); Buffer->ReplaceAt(42, LOBYTE(LOWORD(uiSrcId)));
// reserved // reserved
Buffer->Append((uint16)0x0000); Buffer->Append((uint16_t)0x0000);
// uiCallType // uiCallType
Buffer->Append((uint8)0x01); Buffer->Append((uint8_t)0x01);
// reserved // reserved
Buffer->Append((uint8)0x00); Buffer->Append((uint8_t)0x00);
// uiDstId // uiDstId
Buffer->Append(uiDstId); Buffer->Append(uiDstId);
// uiSrcId // uiSrcId
@ -574,10 +567,10 @@ bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuff
void CDmrplusProtocol::EncodeDvPacket void CDmrplusProtocol::EncodeDvPacket
(const CDvHeaderPacket &Header, (const CDvHeaderPacket &Header,
const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2, const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2,
uint8 seqid, CBuffer *Buffer) const uint8_t seqid, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, uint8_t tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x05,0x01,0x02,0x00,0x00,0x00 0x00,0x05,0x01,0x02,0x00,0x00,0x00
} ; } ;
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
@ -587,31 +580,31 @@ void CDmrplusProtocol::EncodeDvPacket
// uiPktType // uiPktType
//Buffer->ReplaceAt(8, 1); //Buffer->ReplaceAt(8, 1);
// uiSlot // uiSlot
Buffer->Append((uint16)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222)); Buffer->Append((uint16_t)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
// uiVoiceSeq // uiVoiceSeq
uint8 uiVoiceSeq = (DvFrame0.GetDmrPacketId() + 7) | ((DvFrame0.GetDmrPacketId() + 7) << 4); uint8_t uiVoiceSeq = (DvFrame0.GetDmrPacketId() + 7) | ((DvFrame0.GetDmrPacketId() + 7) << 4);
Buffer->Append((uint8)uiVoiceSeq); Buffer->Append((uint8_t)uiVoiceSeq);
Buffer->Append((uint8)uiVoiceSeq); Buffer->Append((uint8_t)uiVoiceSeq);
// uiColourCode // uiColourCode
uint8 uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4); uint8_t uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8)uiColourCode); Buffer->Append((uint8_t)uiColourCode);
Buffer->Append((uint8)uiColourCode); Buffer->Append((uint8_t)uiColourCode);
// uiFrameType // uiFrameType
Buffer->Append((uint16)0x1111); Buffer->Append((uint16_t)0x1111);
// reserved // reserved
Buffer->Append((uint16)0x0000); Buffer->Append((uint16_t)0x0000);
// payload // payload
uint32 uiSrcId = Header.GetMyCallsign().GetDmrid() & 0x00FFFFFF; uint32_t uiSrcId = Header.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32 uiDstId = ModuleToDmrDestId(Header.GetRpt2Module()) & 0x00FFFFFF; uint32_t uiDstId = ModuleToDmrDestId(Header.GetRpt2Module()) & 0x00FFFFFF;
// frame0 // frame0
Buffer->ReplaceAt(26, DvFrame0.GetAmbePlus(), 9); Buffer->ReplaceAt(26, DvFrame0.GetAmbePlus(), 9);
// 1/2 frame1 // 1/2 frame1
Buffer->ReplaceAt(35, DvFrame1.GetAmbePlus(), 5); Buffer->ReplaceAt(35, DvFrame1.GetAmbePlus(), 5);
Buffer->ReplaceAt(39, (uint8)(Buffer->at(39) & 0xF0)); Buffer->ReplaceAt(39, (uint8_t)(Buffer->at(39) & 0xF0));
// 1/2 frame1 // 1/2 frame1
Buffer->ReplaceAt(45, DvFrame1.GetAmbePlus()+4, 5); Buffer->ReplaceAt(45, DvFrame1.GetAmbePlus()+4, 5);
Buffer->ReplaceAt(45, (uint8)(Buffer->at(45) & 0x0F)); Buffer->ReplaceAt(45, (uint8_t)(Buffer->at(45) & 0x0F));
// frame2 // frame2
Buffer->ReplaceAt(50, DvFrame2.GetAmbePlus(), 9); Buffer->ReplaceAt(50, DvFrame2.GetAmbePlus(), 9);
@ -619,12 +612,12 @@ void CDmrplusProtocol::EncodeDvPacket
ReplaceEMBInBuffer(Buffer, DvFrame0.GetDmrPacketId()); ReplaceEMBInBuffer(Buffer, DvFrame0.GetDmrPacketId());
// reserved // reserved
Buffer->Append((uint16)0x0000); Buffer->Append((uint16_t)0x0000);
Buffer->Append((uint8)0x00); Buffer->Append((uint8_t)0x00);
// uiCallType // uiCallType
Buffer->Append((uint8)0x01); Buffer->Append((uint8_t)0x01);
// reserved // reserved
Buffer->Append((uint8)0x00); Buffer->Append((uint8_t)0x00);
// uiDstId // uiDstId
Buffer->Append(uiDstId); Buffer->Append(uiDstId);
// uiSrcId // uiSrcId
@ -634,11 +627,11 @@ void CDmrplusProtocol::EncodeDvPacket
SwapEndianess(&(Buffer->data()[26]), 34); SwapEndianess(&(Buffer->data()[26]), 34);
} }
void CDmrplusProtocol::SwapEndianess(uint8 *buffer, int len) const void CDmrplusProtocol::SwapEndianess(uint8_t *buffer, int len) const
{ {
for ( int i = 0; i < len; i += 2 ) for ( int i = 0; i < len; i += 2 )
{ {
uint8 t = buffer[i]; uint8_t t = buffer[i];
buffer[i] = buffer[i+1]; buffer[i] = buffer[i+1];
buffer[i+1] = t; buffer[i+1] = t;
} }
@ -648,7 +641,7 @@ void CDmrplusProtocol::SwapEndianess(uint8 *buffer, int len) const
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// SeqId helper // SeqId helper
uint8 CDmrplusProtocol::GetNextSeqId(uint8 uiSeqId) const uint8_t CDmrplusProtocol::GetNextSeqId(uint8_t uiSeqId) const
{ {
return (uiSeqId + 1) & 0xFF; return (uiSeqId + 1) & 0xFF;
} }
@ -656,7 +649,7 @@ uint8 CDmrplusProtocol::GetNextSeqId(uint8 uiSeqId) const
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper // DestId to Module helper
char CDmrplusProtocol::DmrDstIdToModule(uint32 tg) const char CDmrplusProtocol::DmrDstIdToModule(uint32_t tg) const
{ {
// is it a 4xxx ? // is it a 4xxx ?
if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) ) if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) )
@ -666,33 +659,33 @@ char CDmrplusProtocol::DmrDstIdToModule(uint32 tg) const
return ' '; return ' ';
} }
uint32 CDmrplusProtocol::ModuleToDmrDestId(char m) const uint32_t CDmrplusProtocol::ModuleToDmrDestId(char m) const
{ {
return (uint32)(m - 'A')+4001; return (uint32_t)(m - 'A')+4001;
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// Buffer & LC helpers // Buffer & LC helpers
void CDmrplusProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) const void CDmrplusProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32_t uiSrcId) const
{ {
uint8 payload[34]; uint8_t payload[34];
// fill payload // fill payload
CBPTC19696 bptc; CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload)); ::memset(payload, 0, sizeof(payload));
// LC data // LC data
uint8 lc[12]; uint8_t lc[12];
{ {
::memset(lc, 0, sizeof(lc)); ::memset(lc, 0, sizeof(lc));
// uiDstId = TG9 // uiDstId = TG9
lc[5] = 9; lc[5] = 9;
// uiSrcId // uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId)); lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId)); lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId)); lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity // parity
uint8 parity[4]; uint8_t parity[4];
CRS129::encode(lc, 9, parity); CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ DMR_VOICE_LC_HEADER_CRC_MASK; lc[9] = parity[2] ^ DMR_VOICE_LC_HEADER_CRC_MASK;
lc[10] = parity[1] ^ DMR_VOICE_LC_HEADER_CRC_MASK; lc[10] = parity[1] ^ DMR_VOICE_LC_HEADER_CRC_MASK;
@ -703,7 +696,7 @@ void CDmrplusProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) co
// slot type // slot type
{ {
// slot type // slot type
uint8 slottype[3]; uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype)); ::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRPLUS_REFLECTOR_COLOUR << 4) & 0xF0; slottype[0] = (DMRPLUS_REFLECTOR_COLOUR << 4) & 0xF0;
slottype[0] |= (DMR_DT_VOICE_LC_HEADER << 0) & 0x0FU; slottype[0] |= (DMR_DT_VOICE_LC_HEADER << 0) & 0x0FU;
@ -721,21 +714,21 @@ void CDmrplusProtocol::AppendVoiceLCToBuffer(CBuffer *buffer, uint32 uiSrcId) co
buffer->Append(payload, sizeof(payload)); buffer->Append(payload, sizeof(payload));
} }
void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId) const void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8_t uiDmrPacketId) const
{ {
// voice packet A ? // voice packet A ?
if ( uiDmrPacketId == 0 ) if ( uiDmrPacketId == 0 )
{ {
// sync // sync
buffer->ReplaceAt(39, (uint8)(buffer->at(39) | (g_DmrSyncBSVoice[0] & 0x0F))); buffer->ReplaceAt(39, (uint8_t)(buffer->at(39) | (g_DmrSyncBSVoice[0] & 0x0F)));
buffer->ReplaceAt(40, g_DmrSyncBSVoice+1, 5); buffer->ReplaceAt(40, g_DmrSyncBSVoice+1, 5);
buffer->ReplaceAt(45, (uint8)(buffer->at(45) | (g_DmrSyncBSVoice[6] & 0xF0))); buffer->ReplaceAt(45, (uint8_t)(buffer->at(45) | (g_DmrSyncBSVoice[6] & 0xF0)));
} }
// voice packet B,C,D,E ? // voice packet B,C,D,E ?
else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) ) else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) )
{ {
// EMB LC // EMB LC
uint8 emb[2]; uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00; //emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06; //emb[0] |= (LCSS << 1) & 0x06;
@ -743,21 +736,21 @@ void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode // encode
CQR1676::encode(emb); CQR1676::encode(emb);
// and append // and append
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F))); buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0))); buffer->ReplaceAt(40, (uint8_t)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8)(buffer->at(40) & 0xF0)); buffer->ReplaceAt(40, (uint8_t)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8)0); buffer->ReplaceAt(41, (uint8_t)0);
buffer->ReplaceAt(42, (uint8)0); buffer->ReplaceAt(42, (uint8_t)0);
buffer->ReplaceAt(43, (uint8)0); buffer->ReplaceAt(43, (uint8_t)0);
buffer->ReplaceAt(44, (uint8)(buffer->at(44) & 0x0F)); buffer->ReplaceAt(44, (uint8_t)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F))); buffer->ReplaceAt(44, (uint8_t)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(45, (uint8)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0))); buffer->ReplaceAt(45, (uint8_t)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
} }
// voice packet F // voice packet F
else else
{ {
// nullptr // nullptr
uint8 emb[2]; uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0; emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00; //emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06; //emb[0] |= (LCSS << 1) & 0x06;
@ -765,15 +758,15 @@ void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode // encode
CQR1676::encode(emb); CQR1676::encode(emb);
// and append // and append
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F))); buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0))); buffer->ReplaceAt(40, (uint8_t)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8)(buffer->at(40) & 0xF0)); buffer->ReplaceAt(40, (uint8_t)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8)0); buffer->ReplaceAt(41, (uint8_t)0);
buffer->ReplaceAt(42, (uint8)0); buffer->ReplaceAt(42, (uint8_t)0);
buffer->ReplaceAt(43, (uint8)0); buffer->ReplaceAt(43, (uint8_t)0);
buffer->ReplaceAt(44, (uint8)(buffer->at(44) & 0x0F)); buffer->ReplaceAt(44, (uint8_t)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F))); buffer->ReplaceAt(44, (uint8_t)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(45, (uint8)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0))); buffer->ReplaceAt(45, (uint8_t)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
} }
} }
@ -782,7 +775,7 @@ void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// uiStreamId helpers // uiStreamId helpers
uint32 CDmrplusProtocol::IpToStreamId(const CIp &ip) const uint32_t CDmrplusProtocol::IpToStreamId(const CIp &ip) const
{ {
return ip.GetAddr() ^ (uint32)(MAKEDWORD(ip.GetPort(), ip.GetPort())); return ip.GetAddr() ^ (uint32_t)(MAKEDWORD(ip.GetPort(), ip.GetPort()));
} }

@ -1,29 +1,22 @@
//
// DMRPlusProtocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdmrplusprotocol_h #pragma once
#define cdmrplusprotocol_h
#include "Timer.h" #include "Timer.h"
#include "DCSProtocol.h" #include "DCSProtocol.h"
@ -49,7 +42,7 @@ public:
CDvFramePacket m_dvFrame0; CDvFramePacket m_dvFrame0;
CDvFramePacket m_dvFrame1; CDvFramePacket m_dvFrame1;
uint8 m_uiSeqId; uint8_t m_uiSeqId;
}; };
@ -57,7 +50,7 @@ class CDmrplusProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int pytpe, const uint16 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int pytpe, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);
@ -65,7 +58,7 @@ public:
protected: protected:
// queue helper // queue helper
void HandleQueue(void); void HandleQueue(void);
void SendBufferToClients(const CBuffer &, uint8); void SendBufferToClients(const CBuffer &, uint8_t);
// keepalive helpers // keepalive helpers
void HandleKeepalives(void); void HandleKeepalives(void);
@ -83,23 +76,23 @@ protected:
void EncodeConnectAckPacket(CBuffer *); void EncodeConnectAckPacket(CBuffer *);
void EncodeConnectNackPacket(CBuffer *); void EncodeConnectNackPacket(CBuffer *);
bool EncodeDvHeaderPacket(const CDvHeaderPacket &, CBuffer *) const; bool EncodeDvHeaderPacket(const CDvHeaderPacket &, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8, CBuffer *) const; void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8_t, CBuffer *) const;
void SwapEndianess(uint8 *, int) const; void SwapEndianess(uint8_t *, int) const;
// dmr SeqId helper // dmr SeqId helper
uint8 GetNextSeqId(uint8) const; uint8_t GetNextSeqId(uint8_t) const;
// dmr DstId to Module helper // dmr DstId to Module helper
char DmrDstIdToModule(uint32) const; char DmrDstIdToModule(uint32_t) const;
uint32 ModuleToDmrDestId(char) const; uint32_t ModuleToDmrDestId(char) const;
// uiStreamId helpers // uiStreamId helpers
uint32 IpToStreamId(const CIp &) const; uint32_t IpToStreamId(const CIp &) const;
// Buffer & LC helpers // Buffer & LC helpers
void AppendVoiceLCToBuffer(CBuffer *, uint32) const; void AppendVoiceLCToBuffer(CBuffer *, uint32_t) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32) const; void AppendTerminatorLCToBuffer(CBuffer *, uint32_t) const;
void ReplaceEMBInBuffer(CBuffer *, uint8) const; void ReplaceEMBInBuffer(CBuffer *, uint8_t) const;
protected: protected:
@ -109,8 +102,3 @@ protected:
// for queue header caches // for queue header caches
std::array<CDmrplusStreamCacheItem, NB_OF_MODULES> m_StreamsCache; std::array<CDmrplusStreamCacheItem, NB_OF_MODULES> m_StreamsCache;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmrplusprotocol_h */

@ -1,26 +1,20 @@
//
// cdplusclient.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DPlusClient.h" #include "DPlusClient.h"
@ -51,7 +45,7 @@ CDplusClient::CDplusClient(const CDplusClient &client)
bool CDplusClient::IsAlive(void) const bool CDplusClient::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < DPLUS_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < DPLUS_KEEPALIVE_TIMEOUT);
} }
void CDplusClient::SetMasterOfModule(char c) void CDplusClient::SetMasterOfModule(char c)

@ -1,38 +1,24 @@
//
// DPlusClient.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdplusclient_h #pragma once
#define cdplusclient_h
#include "cclient.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDplusClient : public CClient class CDplusClient : public CClient
{ {
@ -61,6 +47,3 @@ protected:
// data // data
bool m_bDextraDongle; bool m_bDextraDongle;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdplusclient_h */

@ -1,27 +1,20 @@
//
// cdplusprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -34,14 +27,14 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CDplusProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) bool CDplusProtocol::Initialize(const char *type, const int 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))
return false; return false;
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
// done // done
return true; return true;
@ -166,13 +159,13 @@ void CDplusProtocol::Task(void)
HandleQueue(); HandleQueue();
// keep client alive // keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > DPLUS_KEEPALIVE_PERIOD ) if ( m_LastKeepaliveTime.time() > DPLUS_KEEPALIVE_PERIOD )
{ {
// //
HandleKeepalives(); HandleKeepalives();
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
} }
} }
@ -320,7 +313,7 @@ void CDplusProtocol::SendDvHeader(CDvHeaderPacket *packet, CDplusClient *client)
// clone the packet and patch it // clone the packet and patch it
CDvHeaderPacket packet2(*((CDvHeaderPacket *)packet)); CDvHeaderPacket packet2(*((CDvHeaderPacket *)packet));
CCallsign rpt2 = packet2.GetRpt2Callsign(); CCallsign rpt2 = packet2.GetRpt2Callsign();
rpt2.PatchCallsign(0, (const uint8 *)"XRF", 3); rpt2.PatchCallsign(0, (const uint8_t *)"XRF", 3);
packet2.SetRpt2Callsign(rpt2); packet2.SetRpt2Callsign(rpt2);
// encode it // encode it
@ -392,13 +385,13 @@ void CDplusProtocol::HandleKeepalives(void)
bool CDplusProtocol::IsValidConnectPacket(const CBuffer &Buffer) bool CDplusProtocol::IsValidConnectPacket(const CBuffer &Buffer)
{ {
uint8 tag[] = { 0x05,0x00,0x18,0x00,0x01 }; uint8_t tag[] = { 0x05,0x00,0x18,0x00,0x01 };
return (Buffer == CBuffer(tag, sizeof(tag))); return (Buffer == CBuffer(tag, sizeof(tag)));
} }
bool CDplusProtocol::IsValidLoginPacket(const CBuffer &Buffer, CCallsign *Callsign) bool CDplusProtocol::IsValidLoginPacket(const CBuffer &Buffer, CCallsign *Callsign)
{ {
uint8 Tag[] = { 0x1C,0xC0,0x04,0x00 }; uint8_t Tag[] = { 0x1C,0xC0,0x04,0x00 };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 28) &&(::memcmp(Buffer.data(), Tag, sizeof(Tag)) == 0) ) if ( (Buffer.size() == 28) &&(::memcmp(Buffer.data(), Tag, sizeof(Tag)) == 0) )
@ -411,22 +404,22 @@ bool CDplusProtocol::IsValidLoginPacket(const CBuffer &Buffer, CCallsign *Callsi
bool CDplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer) bool CDplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer)
{ {
uint8 tag[] = { 0x05,0x00,0x18,0x00,0x00 }; uint8_t tag[] = { 0x05,0x00,0x18,0x00,0x00 };
return (Buffer == CBuffer(tag, sizeof(tag))); return (Buffer == CBuffer(tag, sizeof(tag)));
} }
bool CDplusProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer) bool CDplusProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer)
{ {
uint8 tag[] = { 0x03,0x60,0x00 }; uint8_t tag[] = { 0x03,0x60,0x00 };
return (Buffer == CBuffer(tag, sizeof(tag))); return (Buffer == CBuffer(tag, sizeof(tag)));
} }
bool CDplusProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header) bool CDplusProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header)
{ {
if ( 58==Buffer.size() && 0x3AU==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0==Buffer.Compare((uint8 *)"DSVT", 2, 4) && 0x10U==Buffer.data()[6] && 0x20U==Buffer.data()[10] ) if ( 58==Buffer.size() && 0x3AU==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0==Buffer.Compare((uint8_t *)"DSVT", 2, 4) && 0x10U==Buffer.data()[6] && 0x20U==Buffer.data()[10] )
{ {
// create packet // create packet
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[17]), *((uint16 *)&(Buffer.data()[14])), 0x80)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[17]), *((uint16_t *)&(Buffer.data()[14])), 0x80));
// check validity of packet // check validity of packet
if ( header && header->IsValid() ) if ( header && header->IsValid() )
return true; return true;
@ -436,10 +429,10 @@ bool CDplusProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_pt
bool CDplusProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe) bool CDplusProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
{ {
if ( 29==Buffer.size() && 0x1DU==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0==Buffer.Compare((uint8 *)"DSVT", 2, 4) && 0x20U==Buffer.data()[6] && 0x20U==Buffer.data()[10] ) if ( 29==Buffer.size() && 0x1DU==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0==Buffer.Compare((uint8_t *)"DSVT", 2, 4) && 0x20U==Buffer.data()[6] && 0x20U==Buffer.data()[10] )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[17]), *((uint16 *)&(Buffer.data()[14])), Buffer.data()[16])); dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[17]), *((uint16_t *)&(Buffer.data()[14])), Buffer.data()[16]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -449,10 +442,10 @@ bool CDplusProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr
bool CDplusProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe) bool CDplusProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe)
{ {
if ( 32==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 2, 4) && 0x20U==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0x20U==Buffer.data()[6] && 0x20U==Buffer.data()[10] ) if ( 32==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 2, 4) && 0x20U==Buffer.data()[0] && 0x80U==Buffer.data()[1] && 0x20U==Buffer.data()[6] && 0x20U==Buffer.data()[10] )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[17]), *((uint16 *)&(Buffer.data()[14])), Buffer.data()[16])); dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[17]), *((uint16_t *)&(Buffer.data()[14])), Buffer.data()[16]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -466,53 +459,53 @@ bool CDplusProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique
void CDplusProtocol::EncodeKeepAlivePacket(CBuffer *Buffer) void CDplusProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 0x03,0x60,0x00 }; uint8_t tag[] = { 0x03,0x60,0x00 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDplusProtocol::EncodeLoginAckPacket(CBuffer *Buffer) void CDplusProtocol::EncodeLoginAckPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 0x08,0xC0,0x04,0x00,'O','K','R','W' }; uint8_t tag[] = { 0x08,0xC0,0x04,0x00,'O','K','R','W' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDplusProtocol::EncodeLoginNackPacket(CBuffer *Buffer) void CDplusProtocol::EncodeLoginNackPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 0x08,0xC0,0x04,0x00,'B','U','S','Y' }; uint8_t tag[] = { 0x08,0xC0,0x04,0x00,'B','U','S','Y' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
void CDplusProtocol::EncodeDisconnectPacket(CBuffer *Buffer) void CDplusProtocol::EncodeDisconnectPacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 0x05,0x00,0x18,0x00,0x00 }; uint8_t tag[] = { 0x05,0x00,0x18,0x00,0x00 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
} }
bool CDplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const bool CDplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x3A,0x80,0x44,0x53,0x56,0x54,0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 0x3A,0x80,0x44,0x53,0x56,0x54,0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
struct dstar_header DstarHeader; struct dstar_header DstarHeader;
Packet.ConvertToDstarStruct(&DstarHeader); Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80); Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header)); Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true; return true;
} }
bool CDplusProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const bool CDplusProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x1D,0x80,0x44,0x53,0x56,0x54,0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 0x1D,0x80,0x44,0x53,0x56,0x54,0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21)); Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE); Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE); Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true; return true;
@ -520,12 +513,12 @@ bool CDplusProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *
bool CDplusProtocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const bool CDplusProtocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag1[] = { 0x20,0x80,0x44,0x53,0x56,0x54,0x20,0x00,0x81,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag1[] = { 0x20,0x80,0x44,0x53,0x56,0x54,0x20,0x00,0x81,0x00,0x20,0x00,0x01,0x02 };
uint8 tag2[] = { 0x55,0xC8,0x7A,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x25,0x1A,0xC6 }; uint8_t tag2[] = { 0x55,0xC8,0x7A,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1)); Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40)); Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2)); Buffer->Append(tag2, sizeof(tag2));
return true; return true;

@ -1,29 +1,22 @@
//
// DPlusProtocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdplusprotocol_h #pragma once
#define cdplusprotocol_h
#include "Timer.h" #include "Timer.h"
#include "Protocol.h" #include "Protocol.h"
@ -31,12 +24,6 @@
#include "DVFramePacket.h" #include "DVFramePacket.h"
#include "DVLastFramePacket.h" #include "DVLastFramePacket.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDplusClient; class CDplusClient;
class CDPlusStreamCacheItem class CDPlusStreamCacheItem
@ -45,14 +32,14 @@ public:
CDPlusStreamCacheItem() { m_iSeqCounter = 0; } CDPlusStreamCacheItem() { m_iSeqCounter = 0; }
CDvHeaderPacket m_dvHeader; CDvHeaderPacket m_dvHeader;
uint8 m_iSeqCounter; uint8_t m_iSeqCounter;
}; };
class CDplusProtocol : public CProtocol class CDplusProtocol : public CProtocol
{ {
public: public:
// initialization // initialization
bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// task // task
void Task(void); void Task(void);
@ -89,11 +76,8 @@ protected:
protected: protected:
// for keep alive // for keep alive
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
// for queue header caches // for queue header caches
std::array<CDPlusStreamCacheItem, NB_OF_MODULES> m_StreamsCache; std::array<CDPlusStreamCacheItem, NB_OF_MODULES> m_StreamsCache;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdplusprotocol_h */

@ -1,30 +1,23 @@
//
// cdvframepacket.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h"
#include <string.h> #include <string.h>
#include "Main.h"
#include "DVFramePacket.h" #include "DVFramePacket.h"
@ -43,7 +36,7 @@ CDvFramePacket::CDvFramePacket()
// dstar constructor // dstar constructor
CDvFramePacket::CDvFramePacket(const struct dstar_dvframe *dvframe, uint16 sid, uint8 pid) CDvFramePacket::CDvFramePacket(const struct dstar_dvframe *dvframe, uint16_t sid, uint8_t pid)
: CPacket(sid, pid) : CPacket(sid, pid)
{ {
::memcpy(m_uiAmbe, dvframe->AMBE, sizeof(m_uiAmbe)); ::memcpy(m_uiAmbe, dvframe->AMBE, sizeof(m_uiAmbe));
@ -57,7 +50,7 @@ CDvFramePacket::CDvFramePacket(const struct dstar_dvframe *dvframe, uint16 sid,
#ifndef NO_XLX #ifndef NO_XLX
// dmr constructor // dmr constructor
CDvFramePacket::CDvFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid, uint8 pid, uint8 spid) CDvFramePacket::CDvFramePacket(const uint8_t *ambe, const uint8_t *sync, uint16_t sid, uint8_t pid, uint8_t spid)
: CPacket(sid, pid, spid) : CPacket(sid, pid, spid)
{ {
::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus)); ::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus));
@ -68,7 +61,7 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid,
// ysf constructor // ysf constructor
CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 spid, uint8 fid) CDvFramePacket::CDvFramePacket(const uint8_t *ambe, uint16_t sid, uint8_t pid, uint8_t spid, uint8_t fid)
: CPacket(sid, pid, spid, fid) : CPacket(sid, pid, spid, fid)
{ {
::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus)); ::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus));
@ -80,9 +73,9 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 s
// xlx constructor // xlx constructor
CDvFramePacket::CDvFramePacket CDvFramePacket::CDvFramePacket
(uint16 sid, (uint16_t sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata, uint8_t dstarpid, const uint8_t *dstarambe, const uint8_t *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync) uint8_t dmrpid, uint8_t dprspid, const uint8_t *dmrambe, const uint8_t *dmrsync)
: CPacket(sid, dstarpid, dmrpid, dprspid, 0xFF, 0xFF, 0xFF) : CPacket(sid, dstarpid, dmrpid, dprspid, 0xFF, 0xFF, 0xFF)
{ {
::memcpy(m_uiAmbe, dstarambe, sizeof(m_uiAmbe)); ::memcpy(m_uiAmbe, dstarambe, sizeof(m_uiAmbe));
@ -103,7 +96,7 @@ std::unique_ptr<CPacket> CDvFramePacket::Duplicate(void) const
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// get // get
const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const const uint8_t *CDvFramePacket::GetAmbe(uint8_t uiCodec) const
{ {
switch (uiCodec) switch (uiCodec)
{ {
@ -121,12 +114,12 @@ const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// set // set
void CDvFramePacket::SetDvData(uint8 *DvData) void CDvFramePacket::SetDvData(uint8_t *DvData)
{ {
::memcpy(m_uiDvData, DvData, sizeof(m_uiDvData)); ::memcpy(m_uiDvData, DvData, sizeof(m_uiDvData));
} }
void CDvFramePacket::SetAmbe(uint8 uiCodec, uint8 *Ambe) void CDvFramePacket::SetAmbe(uint8_t uiCodec, uint8_t *Ambe)
{ {
switch (uiCodec) switch (uiCodec)
{ {

@ -1,29 +1,22 @@
//
// DVFramePacket.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdvframepacket_h #pragma once
#define cdvframepacket_h
#include "Packet.h" #include "Packet.h"
@ -40,8 +33,8 @@
struct __attribute__ ((__packed__))dstar_dvframe struct __attribute__ ((__packed__))dstar_dvframe
{ {
uint8 AMBE[AMBE_SIZE]; uint8_t AMBE[AMBE_SIZE];
uint8 DVDATA[DVDATA_SIZE]; uint8_t DVDATA[DVDATA_SIZE];
}; };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -53,11 +46,11 @@ class CDvFramePacket : public CPacket
public: public:
// constructor // constructor
CDvFramePacket(); CDvFramePacket();
CDvFramePacket(const struct dstar_dvframe *, uint16, uint8); CDvFramePacket(const struct dstar_dvframe *, uint16_t, uint8_t);
#ifndef NO_XLX #ifndef NO_XLX
CDvFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8); CDvFramePacket(const uint8_t *, const uint8_t *, uint16_t, uint8_t, uint8_t);
CDvFramePacket(const uint8 *, uint16, uint8, uint8, uint8); CDvFramePacket(const uint8_t *, uint16_t, uint8_t, uint8_t, uint8_t);
CDvFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *); CDvFramePacket(uint16_t, uint8_t, const uint8_t *, const uint8_t *, uint8_t, uint8_t, const uint8_t *, const uint8_t *);
#endif #endif
// virtual duplication // virtual duplication
@ -70,39 +63,35 @@ public:
#endif #endif
// get // get
const uint8 *GetAmbe(uint8) const; const uint8_t *GetAmbe(uint8_t) const;
const uint8 *GetAmbe(void) const { return m_uiAmbe; } const uint8_t *GetAmbe(void) const { return m_uiAmbe; }
#ifndef NO_XLX #ifndef NO_XLX
const uint8 *GetAmbePlus(void) const { return m_uiAmbePlus; } const uint8_t *GetAmbePlus(void) const { return m_uiAmbePlus; }
const uint8 *GetDvSync(void) const { return m_uiDvSync; } const uint8_t *GetDvSync(void) const { return m_uiDvSync; }
#endif #endif
const uint8 *GetDvData(void) const { return m_uiDvData; } const uint8_t *GetDvData(void) const { return m_uiDvData; }
// set // set
void SetDvData(uint8 *); void SetDvData(uint8_t *);
void SetAmbe(uint8, uint8 *); void SetAmbe(uint8_t, uint8_t *);
// operators // operators
bool operator ==(const CDvFramePacket &) const; bool operator ==(const CDvFramePacket &) const;
protected: protected:
// get // get
uint8 *GetAmbeData(void) { return m_uiAmbe; } uint8_t *GetAmbeData(void) { return m_uiAmbe; }
#ifndef NO_XLX #ifndef NO_XLX
uint8 *GetAmbePlusData(void) { return m_uiAmbePlus; } uint8_t *GetAmbePlusData(void) { return m_uiAmbePlus; }
#endif #endif
protected: protected:
// data (dstar) // data (dstar)
uint8 m_uiAmbe[AMBE_SIZE]; uint8_t m_uiAmbe[AMBE_SIZE];
uint8 m_uiDvData[DVDATA_SIZE]; uint8_t m_uiDvData[DVDATA_SIZE];
#ifndef NO_XLX #ifndef NO_XLX
// data (dmr) // data (dmr)
uint8 m_uiAmbePlus[AMBEPLUS_SIZE]; uint8_t m_uiAmbePlus[AMBEPLUS_SIZE];
uint8 m_uiDvSync[DVSYNC_SIZE]; uint8_t m_uiDvSync[DVSYNC_SIZE];
#endif #endif
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdvframepacket_h */

@ -1,26 +1,20 @@
//
// cdvheaderpacket.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -41,7 +35,7 @@ CDvHeaderPacket::CDvHeaderPacket()
// dstar constructor // dstar constructor
CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16 sid, uint8 pid) CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16_t sid, uint8_t pid)
: CPacket(sid, pid) : CPacket(sid, pid)
{ {
m_uiFlag1 = buffer->Flag1; m_uiFlag1 = buffer->Flag1;
@ -58,7 +52,7 @@ CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16 sid,
#ifndef NO_XLX #ifndef NO_XLX
// dmr constructor // dmr constructor
CDvHeaderPacket::CDvHeaderPacket(uint32 my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16 sid, uint8 pid, uint8 spid) CDvHeaderPacket::CDvHeaderPacket(uint32_t my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16_t sid, uint8_t pid, uint8_t spid)
: CPacket(sid, pid, spid) : CPacket(sid, pid, spid)
{ {
m_uiFlag1 = 0; m_uiFlag1 = 0;
@ -73,7 +67,7 @@ CDvHeaderPacket::CDvHeaderPacket(uint32 my, const CCallsign &ur, const CCallsign
// YSF constructor // YSF constructor
CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16 sid, uint8 pid) CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16_t sid, uint8_t pid)
: CPacket(sid, pid, 0, 0) : CPacket(sid, pid, 0, 0)
{ {
m_uiFlag1 = 0; m_uiFlag1 = 0;

@ -1,29 +1,22 @@
//
// DVHeaderPacket.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdvheaderpacket_h #pragma once
#define cdvheaderpacket_h
#include "Callsign.h" #include "Callsign.h"
#include "Packet.h" #include "Packet.h"
@ -39,17 +32,17 @@
struct __attribute__ ((__packed__))dstar_header struct __attribute__ ((__packed__))dstar_header
{ {
// flags // flags
uint8 Flag1; uint8_t Flag1;
uint8 Flag2; uint8_t Flag2;
uint8 Flag3; uint8_t Flag3;
// callsigns // callsigns
uint8 RPT2[CALLSIGN_LEN]; uint8_t RPT2[CALLSIGN_LEN];
uint8 RPT1[CALLSIGN_LEN]; uint8_t RPT1[CALLSIGN_LEN];
uint8 UR[CALLSIGN_LEN]; uint8_t UR[CALLSIGN_LEN];
uint8 MY[CALLSIGN_LEN]; uint8_t MY[CALLSIGN_LEN];
uint8 SUFFIX[CALLSUFFIX_LEN]; uint8_t SUFFIX[CALLSUFFIX_LEN];
// crc // crc
uint16 Crc; uint16_t Crc;
}; };
@ -61,10 +54,10 @@ class CDvHeaderPacket : public CPacket
public: public:
// constructor // constructor
CDvHeaderPacket(); CDvHeaderPacket();
CDvHeaderPacket(const struct dstar_header *, uint16, uint8); CDvHeaderPacket(const struct dstar_header *, uint16_t, uint8_t);
#ifndef NO_XLX #ifndef NO_XLX
CDvHeaderPacket(uint32, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8, uint8); CDvHeaderPacket(uint32_t, const CCallsign &, const CCallsign &, const CCallsign &, uint16_t, uint8_t, uint8_t);
CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8); CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16_t, uint8_t);
#endif #endif
// virtual duplication // virtual duplication
@ -103,19 +96,16 @@ public:
protected: protected:
// data // data
uint8 m_uiFlag1; uint8_t m_uiFlag1;
uint8 m_uiFlag2; uint8_t m_uiFlag2;
uint8 m_uiFlag3; uint8_t m_uiFlag3;
CCallsign m_csUR; CCallsign m_csUR;
CCallsign m_csRPT1; CCallsign m_csRPT1;
CCallsign m_csRPT2; CCallsign m_csRPT2;
CCallsign m_csMY; CCallsign m_csMY;
uint16 m_uiCrc; uint16_t m_uiCrc;
#ifdef IMPLEMENT_CDVHEADERPACKET_CONST_CHAR_OPERATOR #ifdef IMPLEMENT_CDVHEADERPACKET_CONST_CHAR_OPERATOR
// buffer // buffer
char m_sz[256]; char m_sz[256];
#endif #endif
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdvheaderpacket_h */

@ -1,26 +1,20 @@
//
// cdvlastframepacket.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 03/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DVLastFramePacket.h" #include "DVLastFramePacket.h"
@ -35,7 +29,7 @@ CDvLastFramePacket::CDvLastFramePacket()
// dstar constructor // dstar constructor
CDvLastFramePacket::CDvLastFramePacket(const struct dstar_dvframe *DvFrame, uint16 sid, uint8 pid) CDvLastFramePacket::CDvLastFramePacket(const struct dstar_dvframe *DvFrame, uint16_t sid, uint8_t pid)
: CDvFramePacket(DvFrame, sid, pid) : CDvFramePacket(DvFrame, sid, pid)
{ {
} }
@ -43,7 +37,7 @@ CDvLastFramePacket::CDvLastFramePacket(const struct dstar_dvframe *DvFrame, uint
#ifndef NO_XLX #ifndef NO_XLX
// dmr constructor // dmr constructor
CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid, uint8 pid, uint8 spid) CDvLastFramePacket::CDvLastFramePacket(const uint8_t *ambe, const uint8_t *sync, uint16_t sid, uint8_t pid, uint8_t spid)
: CDvFramePacket(ambe, sync, sid, pid, spid) : CDvFramePacket(ambe, sync, sid, pid, spid)
{ {
} }
@ -51,16 +45,16 @@ CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uin
// dstar + dmr constructor // dstar + dmr constructor
CDvLastFramePacket::CDvLastFramePacket CDvLastFramePacket::CDvLastFramePacket
(uint16 sid, (uint16_t sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata, uint8_t dstarpid, const uint8_t *dstarambe, const uint8_t *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync) uint8_t dmrpid, uint8_t dprspid, const uint8_t *dmrambe, const uint8_t *dmrsync)
: CDvFramePacket(sid, dstarpid, dstarambe, dstardvdata, dmrpid, dprspid, dmrambe, dmrsync) : CDvFramePacket(sid, dstarpid, dstarambe, dstardvdata, dmrpid, dprspid, dmrambe, dmrsync)
{ {
} }
// ysf constructor // ysf constructor
CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 spid, uint8 fid) CDvLastFramePacket::CDvLastFramePacket(const uint8_t *ambe, uint16_t sid, uint8_t pid, uint8_t spid, uint8_t fid)
: CDvFramePacket(ambe, sid, pid, spid, fid) : CDvFramePacket(ambe, sid, pid, spid, fid)
{ {
} }

@ -1,50 +1,35 @@
//
// DVLastFramePacket.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 03/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdvlastframepacket_h
#define cdvlastframepacket_h
#pragma once
#include "DVFramePacket.h" #include "DVFramePacket.h"
////////////////////////////////////////////////////////////////////////////////////////
// defines
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDvLastFramePacket : public CDvFramePacket class CDvLastFramePacket : public CDvFramePacket
{ {
public: public:
// constructor // constructor
CDvLastFramePacket(); CDvLastFramePacket();
CDvLastFramePacket(const struct dstar_dvframe *, uint16, uint8); CDvLastFramePacket(const struct dstar_dvframe *, uint16_t, uint8_t);
#ifndef NO_XLX #ifndef NO_XLX
CDvLastFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8); CDvLastFramePacket(const uint8_t *, const uint8_t *, uint16_t, uint8_t, uint8_t);
CDvLastFramePacket(const uint8 *, uint16, uint8, uint8, uint8); CDvLastFramePacket(const uint8_t *, uint16_t, uint8_t, uint8_t, uint8_t);
CDvLastFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *); CDvLastFramePacket(uint16_t, uint8_t, const uint8_t *, const uint8_t *, uint8_t, uint8_t, const uint8_t *, const uint8_t *);
#endif #endif
CDvLastFramePacket(const CDvLastFramePacket &); CDvLastFramePacket(const CDvLastFramePacket &);
@ -55,7 +40,3 @@ public:
bool IsLastPacket(void) const { return true; } bool IsLastPacket(void) const { return true; }
bool HasTranscodableAmbe(void) const { return false; } bool HasTranscodableAmbe(void) const { return false; }
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdvlastframepacket_h */

@ -1,26 +1,20 @@
//
// cg3client.cpp
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 03/06/2019.
// Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "G3Client.h" #include "G3Client.h"
@ -49,5 +43,5 @@ CG3Client::CG3Client(const CG3Client &client)
bool CG3Client::IsAlive(void) const bool CG3Client::IsAlive(void) const
{ {
return (m_LastKeepaliveTime.DurationSinceNow() < G3_KEEPALIVE_TIMEOUT); return (m_LastKeepaliveTime.time() < G3_KEEPALIVE_TIMEOUT);
} }

@ -1,39 +1,25 @@
//
// G3Client.h
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 03/06/2019.
// Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cg3client_h #pragma once
#define cg3client_h
#include "Client.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CG3Client : public CClient class CG3Client : public CClient
{ {
public: public:
@ -57,6 +43,3 @@ public:
protected: protected:
// data // data
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cg3client_h */

@ -1,27 +1,20 @@
//
// cg3protocol.cpp
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 03/06/2019.
// Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -38,7 +31,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// operation // operation
bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uint16 /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/) bool CG3Protocol::Initialize(const char */*type*/, const int /*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();
@ -50,7 +43,7 @@ bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uin
keep_running = true; keep_running = true;
// update the reflector callsign // update the reflector callsign
//m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)"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); auto s = g_Reflector.m_Address.GetV4Address(PROTOCOL_G3);
@ -93,7 +86,7 @@ bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uin
m_IcmpFuture = std::async(std::launch::async, &CG3Protocol::IcmpThread, this); m_IcmpFuture = std::async(std::launch::async, &CG3Protocol::IcmpThread, this);
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
std::cout << "Initialized G3 Protocol, all threads started" << std::endl; std::cout << "Initialized G3 Protocol, all threads started" << std::endl;
return true; return true;
@ -178,7 +171,7 @@ void CG3Protocol::PresenceTask(void)
if (m_GwAddress == 0) if (m_GwAddress == 0)
{ {
Buffer.Append(*(uint32 *)m_ConfigSocket.GetLocalAddr()); Buffer.Append(*(uint32_t *)m_ConfigSocket.GetLocalAddr());
} }
else else
{ {
@ -295,24 +288,24 @@ void CG3Protocol::ConfigTask(void)
// UR // UR
Buffer.resize(8); Buffer.resize(8);
Buffer.Append((uint8 *)(const char *)Call, CALLSIGN_LEN - 1); Buffer.Append((uint8_t *)(const char *)Call, CALLSIGN_LEN - 1);
Buffer.Append((uint8)module); Buffer.Append((uint8_t)module);
// RPT1 // RPT1
Buffer.Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1); Buffer.Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
Buffer.Append((uint8)'G'); Buffer.Append((uint8_t)'G');
// RPT2 // RPT2
Buffer.Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1); Buffer.Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
if (isRepeaterCall) if (isRepeaterCall)
{ {
Buffer.Append((uint8)Call.GetModule()); Buffer.Append((uint8_t)Call.GetModule());
} }
else else
{ {
// routed - no module for now // routed - no module for now
Buffer.Append((uint8)' '); Buffer.Append((uint8_t)' ');
} }
if (Buffer.data()[3] == 0x00) if (Buffer.data()[3] == 0x00)
@ -321,7 +314,7 @@ void CG3Protocol::ConfigTask(void)
if (m_GwAddress == 0) if (m_GwAddress == 0)
{ {
Buffer.Append(*(uint32 *)m_ConfigSocket.GetLocalAddr()); Buffer.Append(*(uint32_t *)m_ConfigSocket.GetLocalAddr());
} }
else else
{ {
@ -399,7 +392,7 @@ void CG3Protocol::Task(void)
client->Alive(); client->Alive();
// supress host checks - no ping needed to trigger potential ICMPs // supress host checks - no ping needed to trigger potential ICMPs
// the regular data flow will do it // the regular data flow will do it
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
break; break;
} }
} }
@ -435,13 +428,13 @@ void CG3Protocol::Task(void)
HandleQueue(); HandleQueue();
// keep alive during idle if needed // keep alive during idle if needed
if ( m_LastKeepaliveTime.DurationSinceNow() > G3_KEEPALIVE_PERIOD ) if ( m_LastKeepaliveTime.time() > G3_KEEPALIVE_PERIOD )
{ {
// handle keep alives // handle keep alives
HandleKeepalives(); HandleKeepalives();
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
// reload option if needed - called once every G3_KEEPALIVE_PERIOD // reload option if needed - called once every G3_KEEPALIVE_PERIOD
NeedReload(); NeedReload();
@ -457,7 +450,7 @@ void CG3Protocol::HandleQueue(void)
while ( !m_Queue.empty() ) while ( !m_Queue.empty() )
{ {
// supress host checks // supress host checks
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
// get the packet // get the packet
auto packet = m_Queue.front(); auto packet = m_Queue.front();
@ -498,7 +491,7 @@ void CG3Protocol::HandleKeepalives(void)
// G3 Terminal mode does not support keepalive // G3 Terminal mode does not support keepalive
// We will send some short packed and expect // We will send some short packed and expect
// A ICMP unreachable on failure // A ICMP unreachable on failure
CBuffer keepalive((uint8 *)"PING", 4); CBuffer keepalive((uint8_t *)"PING", 4);
// iterate on clients // iterate on clients
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
@ -599,10 +592,10 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, c
bool CG3Protocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header) bool CG3Protocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<CDvHeaderPacket> &header)
{ {
if ( 56==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x10U==Buffer.data()[4] && 0x20U==Buffer.data()[8] ) if ( 56==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x10U==Buffer.data()[4] && 0x20U==Buffer.data()[8] )
{ {
// create packet // create packet
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), 0x80)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket((struct dstar_header *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), 0x80));
// check validity of packet // check validity of packet
if ( header && header->IsValid() ) if ( header && header->IsValid() )
return true; return true;
@ -612,10 +605,10 @@ bool CG3Protocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique_ptr<C
bool CG3Protocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe) bool CG3Protocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvFramePacket> &dvframe)
{ {
if ( 27==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && 0U==(Buffer.data()[14] & 0x40U) ) if ( 27==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && 0U==(Buffer.data()[14] & 0x40U) )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), Buffer.data()[14])); dvframe = std::unique_ptr<CDvFramePacket>(new CDvFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), Buffer.data()[14]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -625,10 +618,10 @@ bool CG3Protocol::IsValidDvFramePacket(const CBuffer &Buffer, std::unique_ptr<CD
bool CG3Protocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe) bool CG3Protocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_ptr<CDvLastFramePacket> &dvframe)
{ {
if ( 27==Buffer.size() && 0==Buffer.Compare((uint8 *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && (Buffer.data()[14] & 0x40U) ) if ( 27==Buffer.size() && 0==Buffer.Compare((uint8_t *)"DSVT", 4) && 0x20U==Buffer.data()[4] && 0x20U==Buffer.data()[8] && (Buffer.data()[14] & 0x40U) )
{ {
// create packet // create packet
dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16 *)&(Buffer.data()[12])), Buffer.data()[14])); dvframe = std::unique_ptr<CDvLastFramePacket>(new CDvLastFramePacket((struct dstar_dvframe *)&(Buffer.data()[15]), *((uint16_t *)&(Buffer.data()[12])), Buffer.data()[14]));
// check validity of packet // check validity of packet
if ( dvframe && dvframe->IsValid() ) if ( dvframe && dvframe->IsValid() )
return true; return true;
@ -641,28 +634,28 @@ bool CG3Protocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_pt
bool CG3Protocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const bool CG3Protocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','S','V','T',0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 'D','S','V','T',0x10,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
struct dstar_header DstarHeader; struct dstar_header DstarHeader;
Packet.ConvertToDstarStruct(&DstarHeader); Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80); Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header)); Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true; return true;
} }
bool CG3Protocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const bool CG3Protocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21)); Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE); Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE); Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true; return true;
@ -670,12 +663,12 @@ bool CG3Protocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buf
bool CG3Protocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const bool CG3Protocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 }; uint8_t tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
uint8 tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 }; uint8_t tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1)); Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId()); Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40)); Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2)); Buffer->Append(tag2, sizeof(tag2));
return true; return true;

@ -1,29 +1,22 @@
//
// G3Protocol.h
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 03/06/2019.
// Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2019 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cg3protocol_h #pragma once
#define cg3protocol_h
#include <string> #include <string>
#include "Timer.h" #include "Timer.h"
@ -67,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 port, const bool has_ipv4, const bool has_ipv6); bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
// close // close
void Close(void); void Close(void);
@ -116,7 +109,7 @@ protected:
std::future<void> m_PresenceFuture, m_ConfigFuture, m_IcmpFuture; std::future<void> m_PresenceFuture, m_ConfigFuture, m_IcmpFuture;
// time // time
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
// sockets // sockets
CUdpSocket m_PresenceSocket; CUdpSocket m_PresenceSocket;
@ -124,10 +117,7 @@ protected:
CRawSocket m_IcmpRawSocket; CRawSocket m_IcmpRawSocket;
// optional params // optional params
uint32 m_GwAddress; uint32_t m_GwAddress;
std::string m_Modules; std::string m_Modules;
time_t m_LastModTime; time_t m_LastModTime;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cg3protocol_h */

@ -1,26 +1,20 @@
// // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// cgatekeeper.cpp
// xlxd // ulxd -- The universal reflector
// // Copyright © 2021 Thomas A. Early N7TAE
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Timer.h" #include "Timer.h"
@ -185,7 +179,7 @@ void CGateKeeper::Thread()
{ {
// Wait 30 seconds // Wait 30 seconds
for (int i=0; i<15 && keep_running; i++) for (int i=0; i<15 && keep_running; i++)
CTimePoint::TaskSleepFor(2000); std::this_thread::sleep_for(std::chrono::milliseconds(2000));
// have lists files changed ? // have lists files changed ?
if ( m_NodeWhiteList.NeedReload() ) if ( m_NodeWhiteList.NeedReload() )

@ -1,29 +1,23 @@
//
// GateKeeper.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 07/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cgatekeeper_h
#define cgatekeeper_h #pragma once
#include "Main.h" #include "Main.h"
#include "Callsign.h" #include "Callsign.h"
@ -74,7 +68,3 @@ protected:
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
std::future<void> m_Future; std::future<void> m_Future;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cgatekeeper_h */

@ -1,26 +1,25 @@
/*
* Copyright (C) 2020 by Thomas Early N7TAE // 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 // This program is free software: you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or // it under the terms of the GNU General Public License as published by
* (at your option) any later version. // 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 // This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. // 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, write to the Free Software // You should have received a copy of the GNU General Public License
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <cstdint> #include <cstdint>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include "cip.h" #include "IP.h"
CIp::CIp() : is_set(false) CIp::CIp() : is_set(false)
{ {

@ -1,22 +1,21 @@
#pragma once #pragma once
/*
* Copyright (C) 2020 by Thomas Early N7TAE // 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 // This program is free software: you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or // it under the terms of the GNU General Public License as published by
* (at your option) any later version. // 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 // This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. // 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, write to the Free Software // You should have received a copy of the GNU General Public License
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>

@ -1,26 +1,20 @@
//
// main.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Reflector.h" #include "Reflector.h"

@ -1,30 +1,22 @@
//
// Main.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Eary, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef main_h #pragma once
#define main_h
#include <atomic> #include <atomic>
#include <vector> #include <vector>
@ -209,26 +201,18 @@
#define PIDFILE_PATH "/var/run/xlxd.pid" #define PIDFILE_PATH "/var/run/xlxd.pid"
#endif #endif
////////////////////////////////////////////////////////////////////////////////////////
// typedefs
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned int uint;
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
#define MIN(a,b) ((a)<(b))?(a):(b) #define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) ((a)>(b))?(a):(b) #define MAX(a,b) ((a)>(b))?(a):(b)
#define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEWORD(low, high) ((uint16_t)(((uint8_t)(low)) | (((uint16_t)((uint8_t)(high))) << 8)))
#define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define MAKEDWORD(low, high) ((uint32_t)(((uint16_t)(low)) | (((uint32_t)((uint16_t)(high))) << 16)))
#define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) #define LOBYTE(w) ((uint8_t)(uint16_t)(w & 0x00FF))
#define HIBYTE(w) ((uint8)((((uint16)(w)) >> 8) & 0xFF)) #define HIBYTE(w) ((uint8_t)((((uint16_t)(w)) >> 8) & 0xFF))
#define LOWORD(dw) ((uint16)(uint32)(dw & 0x0000FFFF)) #define LOWORD(dw) ((uint16_t)(uint32_t)(dw & 0x0000FFFF))
#define HIWORD(dw) ((uint16)((((uint32)(dw)) >> 16) & 0xFFFF)) #define HIWORD(dw) ((uint16_t)((((uint32_t)(dw)) >> 16) & 0xFFFF))
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// global objects // global objects
@ -259,7 +243,3 @@ extern CYsfNodeDirFile g_YsfNodeDir;
class CTranscoder; class CTranscoder;
extern CTranscoder g_Transcoder; extern CTranscoder g_Transcoder;
#endif #endif
////////////////////////////////////////////////////////////////////////////////////////
#endif /* main_h */

@ -1,32 +1,23 @@
//
// cnotification.cpp
// xlxd
//
// Created by Jean-Luc on 05/12/2015.
// Copyright © 2015 Jean-Luc. All rights reserved. // Copyright © 2015 Jean-Luc. All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "cnotification.h" #include "Notification.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
CNotification::CNotification() CNotification::CNotification()
{ {

@ -1,30 +1,22 @@
//
// cnotification.h
// xlxd
//
// Created by Jean-Luc on 05/12/2015.
// Copyright © 2015 Jean-Luc. All rights reserved. // Copyright © 2015 Jean-Luc. All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#pragma once
#ifndef cnotification_h
#define cnotification_h
#include "Callsign.h" #include "Callsign.h"
@ -59,6 +51,3 @@ protected:
CCallsign m_Callsign; CCallsign m_Callsign;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cnotification_h */

@ -0,0 +1,55 @@
// Copyright © 2015 Jean-Luc. All rights reserved.
// 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 <queue>
#include <mutex>
#include "Notification.h"
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// class
class CNotificationQueue
{
public:
// constructor
CNotificationQueue() {}
// destructor
~CNotificationQueue() {}
// lock
void Lock() { m_Mutex.lock(); }
void Unlock() { m_Mutex.unlock(); }
// pass thru
CNotification front() { return queue.front(); }
void pop() { queue.pop(); }
void push(CNotification note) { queue.push(note); }
bool empty() const { return queue.empty(); }
protected:
// data
std::mutex m_Mutex;
std::queue<CNotification> queue;
};

@ -1,35 +1,24 @@
//
// cpacket.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 04/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Packet.h" #include "Packet.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
CPacket::CPacket() CPacket::CPacket()
{ {
m_uiStreamId = 0; m_uiStreamId = 0;
@ -45,7 +34,7 @@ CPacket::CPacket()
// dstar contrsuctor // dstar contrsuctor
CPacket::CPacket(uint16 sid, uint8 dstarpid) CPacket::CPacket(uint16_t sid, uint8_t dstarpid)
{ {
m_uiStreamId = sid; m_uiStreamId = sid;
m_uiDstarPacketId = dstarpid; m_uiDstarPacketId = dstarpid;
@ -60,7 +49,7 @@ CPacket::CPacket(uint16 sid, uint8 dstarpid)
// dmr constructor // dmr constructor
CPacket::CPacket(uint16 sid, uint8 dmrpid, uint8 dmrspid) CPacket::CPacket(uint16_t sid, uint8_t dmrpid, uint8_t dmrspid)
{ {
m_uiStreamId = sid; m_uiStreamId = sid;
m_uiDmrPacketId = dmrpid; m_uiDmrPacketId = dmrpid;
@ -75,7 +64,7 @@ CPacket::CPacket(uint16 sid, uint8 dmrpid, uint8 dmrspid)
// ysf constructor // ysf constructor
CPacket::CPacket(uint16 sid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysffrid) CPacket::CPacket(uint16_t sid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysffrid)
{ {
m_uiStreamId = sid; m_uiStreamId = sid;
m_uiYsfPacketId = ysfpid; m_uiYsfPacketId = ysfpid;
@ -90,7 +79,7 @@ CPacket::CPacket(uint16 sid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysffrid)
// xlx constructor // xlx constructor
CPacket::CPacket(uint16 sid, uint8 dstarpid, uint8 dmrpid, uint8 dmrsubpid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysffrid) CPacket::CPacket(uint16_t sid, uint8_t dstarpid, uint8_t dmrpid, uint8_t dmrsubpid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysffrid)
{ {
m_uiStreamId = sid; m_uiStreamId = sid;
m_uiDstarPacketId = dstarpid; m_uiDstarPacketId = dstarpid;
@ -106,7 +95,7 @@ CPacket::CPacket(uint16 sid, uint8 dstarpid, uint8 dmrpid, uint8 dmrsubpid, uint
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// pid conversion // pid conversion
void CPacket::UpdatePids(uint32 pid) void CPacket::UpdatePids(uint32_t pid)
{ {
// called while phusing this packet in a stream queue // called while phusing this packet in a stream queue
// so now packet sequence number is known and undefined pids can be updated // so now packet sequence number is known and undefined pids can be updated

@ -1,29 +1,22 @@
//
// Packet.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpacket_h #pragma once
#define cpacket_h
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -40,10 +33,10 @@ class CPacket
public: public:
// constructor // constructor
CPacket(); CPacket();
CPacket(uint16 sid, uint8 dstarpid); CPacket(uint16_t sid, uint8_t dstarpid);
CPacket(uint16 sid, uint8 dmrpid, uint8 dmrsubpid); CPacket(uint16_t sid, uint8_t dmrpid, uint8_t dmrsubpid);
CPacket(uint16 sid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysfsubpidmax); CPacket(uint16_t sid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysfsubpidmax);
CPacket(uint16 sid, uint8 dstarpid, uint8 dmrpid, uint8 dmrsubpid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysfsubpidmax); CPacket(uint16_t sid, uint8_t dstarpid, uint8_t dmrpid, uint8_t dmrsubpid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysfsubpidmax);
// destructor // destructor
virtual ~CPacket() {} virtual ~CPacket() {}
@ -59,37 +52,32 @@ public:
// get // get
virtual bool IsValid(void) const { return true; } virtual bool IsValid(void) const { return true; }
uint16 GetStreamId(void) const { return m_uiStreamId; } uint16_t GetStreamId(void) const { return m_uiStreamId; }
uint8 GetPacketId(void) const { return m_uiDstarPacketId; } uint8_t GetPacketId(void) const { return m_uiDstarPacketId; }
uint8 GetDstarPacketId(void) const { return m_uiDstarPacketId; } uint8_t GetDstarPacketId(void) const { return m_uiDstarPacketId; }
uint8 GetDmrPacketId(void) const { return m_uiDmrPacketId; } uint8_t GetDmrPacketId(void) const { return m_uiDmrPacketId; }
uint8 GetDmrPacketSubid(void) const { return m_uiDmrPacketSubid; } uint8_t GetDmrPacketSubid(void) const { return m_uiDmrPacketSubid; }
uint8 GetYsfPacketId(void) const { return m_uiYsfPacketId; } uint8_t GetYsfPacketId(void) const { return m_uiYsfPacketId; }
uint8 GetYsfPacketSubId(void) const { return m_uiYsfPacketSubId; } uint8_t GetYsfPacketSubId(void) const { return m_uiYsfPacketSubId; }
uint8 GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; } uint8_t GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; }
uint8 GetModuleId(void) const { return m_uiModuleId; } uint8_t GetModuleId(void) const { return m_uiModuleId; }
bool IsLocalOrigin(void) const { return (m_uiOriginId == ORIGIN_LOCAL); } bool IsLocalOrigin(void) const { return (m_uiOriginId == ORIGIN_LOCAL); }
// set // set
void UpdatePids(uint32); void UpdatePids(uint32_t);
void SetModuleId(uint8 uiId) { m_uiModuleId = uiId; } void SetModuleId(uint8_t uiId) { m_uiModuleId = uiId; }
void SetLocalOrigin(void) { m_uiOriginId = ORIGIN_LOCAL; } void SetLocalOrigin(void) { m_uiOriginId = ORIGIN_LOCAL; }
void SetRemotePeerOrigin(void) { m_uiOriginId = ORIGIN_PEER; } void SetRemotePeerOrigin(void) { m_uiOriginId = ORIGIN_PEER; }
protected: protected:
// data // data
uint16 m_uiStreamId; uint16_t m_uiStreamId;
uint8 m_uiDstarPacketId; uint8_t m_uiDstarPacketId;
uint8 m_uiDmrPacketId; uint8_t m_uiDmrPacketId;
uint8 m_uiDmrPacketSubid; uint8_t m_uiDmrPacketSubid;
uint8 m_uiYsfPacketId; uint8_t m_uiYsfPacketId;
uint8 m_uiYsfPacketSubId; uint8_t m_uiYsfPacketSubId;
uint8 m_uiYsfPacketFrameId; uint8_t m_uiYsfPacketFrameId;
uint8 m_uiModuleId; uint8_t m_uiModuleId;
uint8 m_uiOriginId; uint8_t m_uiOriginId;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpacket_h */

@ -1,30 +1,22 @@
//
// PacketQueue.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 02/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpacketqueue_h #pragma once
#define cpacketqueue_h
#include "Packet.h" #include "Packet.h"
#include "Client.h" #include "Client.h"
@ -55,13 +47,10 @@ public:
protected: protected:
// status // status
bool m_bOpen; bool m_bOpen;
uint16 m_uiStreamId; uint16_t m_uiStreamId;
std::mutex m_Mutex; std::mutex m_Mutex;
// owner // owner
CClient *m_Client; CClient *m_Client;
std::queue<std::unique_ptr<CPacket>> queue; std::queue<std::unique_ptr<CPacket>> queue;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpacketqueue_h */

@ -1,26 +1,20 @@
//
// cpacketstream.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 06/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "PacketStream.h" #include "PacketStream.h"
@ -55,7 +49,7 @@ bool CPacketStream::OpenPacketStream(const CDvHeaderPacket &DvHeader, std::share
m_uiPacketCntr = 0; m_uiPacketCntr = 0;
m_DvHeader = DvHeader; m_DvHeader = DvHeader;
m_OwnerClient = client; m_OwnerClient = client;
m_LastPacketTime.Now(); m_LastPacketTime.start();
#ifdef TRANSCODER_IP #ifdef TRANSCODER_IP
if (std::string::npos != std::string(TRANSCODED_MODULES).find(DvHeader.GetRpt2Module())) if (std::string::npos != std::string(TRANSCODED_MODULES).find(DvHeader.GetRpt2Module()))
m_CodecStream = g_Transcoder.GetCodecStream(this, client->GetCodec()); m_CodecStream = g_Transcoder.GetCodecStream(this, client->GetCodec());
@ -85,7 +79,7 @@ void CPacketStream::ClosePacketStream(void)
void CPacketStream::Push(std::unique_ptr<CPacket> Packet) void CPacketStream::Push(std::unique_ptr<CPacket> Packet)
{ {
// update stream dependent packet data // update stream dependent packet data
m_LastPacketTime.Now(); m_LastPacketTime.start();
Packet->UpdatePids(m_uiPacketCntr++); Packet->UpdatePids(m_uiPacketCntr++);
// transcoder avaliable ? // transcoder avaliable ?
#ifdef TRANSCODER_IP #ifdef TRANSCODER_IP

@ -1,29 +1,22 @@
//
// PacketStream.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 06/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpacketstream_h #pragma once
#define cpacketstream_h
#include "PacketQueue.h" #include "PacketQueue.h"
#include "Timer.h" #include "Timer.h"
@ -50,29 +43,26 @@ public:
// push & pop // push & pop
void Push(std::unique_ptr<CPacket> packet); void Push(std::unique_ptr<CPacket> packet);
void Tickle(void) { m_LastPacketTime.Now(); } void Tickle(void) { m_LastPacketTime.start(); }
bool IsEmpty(void) const; bool IsEmpty(void) const;
// get // get
std::shared_ptr<CClient> GetOwnerClient(void) { return m_OwnerClient; } std::shared_ptr<CClient> GetOwnerClient(void) { return m_OwnerClient; }
const CIp *GetOwnerIp(void); const CIp *GetOwnerIp(void);
bool IsExpired(void) const { return (m_LastPacketTime.DurationSinceNow() > STREAM_TIMEOUT); } bool IsExpired(void) const { return (m_LastPacketTime.time() > STREAM_TIMEOUT); }
bool IsOpen(void) const { return m_bOpen; } bool IsOpen(void) const { return m_bOpen; }
uint16 GetStreamId(void) const { return m_uiStreamId; } uint16_t GetStreamId(void) const { return m_uiStreamId; }
const CCallsign &GetUserCallsign(void) const { return m_DvHeader.GetMyCallsign(); } const CCallsign &GetUserCallsign(void) const { return m_DvHeader.GetMyCallsign(); }
protected: protected:
// data // data
bool m_bOpen; bool m_bOpen;
uint16 m_uiStreamId; uint16_t m_uiStreamId;
uint32 m_uiPacketCntr; uint32_t m_uiPacketCntr;
CTimePoint m_LastPacketTime; CTimer m_LastPacketTime;
CDvHeaderPacket m_DvHeader; CDvHeaderPacket m_DvHeader;
std::shared_ptr<CClient> m_OwnerClient; std::shared_ptr<CClient> m_OwnerClient;
#ifdef TRANSCODER_IP #ifdef TRANSCODER_IP
std::shared_ptr<CCodecStream> m_CodecStream; std::shared_ptr<CCodecStream> m_CodecStream;
#endif #endif
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpacketstream_h */

@ -1,27 +1,20 @@
//
// cpeer.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/12/2016.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -47,7 +40,7 @@ CPeer::CPeer(const CCallsign &callsign, const CIp &ip, const char *modules, cons
::memset(m_ReflectorModules, 0, sizeof(m_ReflectorModules)); ::memset(m_ReflectorModules, 0, sizeof(m_ReflectorModules));
::strncpy(m_ReflectorModules, modules, sizeof(m_ReflectorModules)-1); ::strncpy(m_ReflectorModules, modules, sizeof(m_ReflectorModules)-1);
m_Version = version; m_Version = version;
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
m_ConnectTime = std::time(nullptr); m_ConnectTime = std::time(nullptr);
m_LastHeardTime = std::time(nullptr); m_LastHeardTime = std::time(nullptr);
} }
@ -103,7 +96,7 @@ bool CPeer::IsAMaster(void) const
void CPeer::Alive(void) void CPeer::Alive(void)
{ {
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
(*it)->Alive(); (*it)->Alive();

@ -1,30 +1,22 @@
//
// Peer.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/12/2016.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpeer_h #pragma once
#define cpeer_h
#include "Version.h" #include "Version.h"
#include "Timer.h" #include "Timer.h"
@ -32,12 +24,6 @@
#include "Callsign.h" #include "Callsign.h"
#include "Client.h" #include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPeer class CPeer
{ {
public: public:
@ -93,10 +79,7 @@ protected:
std::list<std::shared_ptr<CClient>> m_Clients; std::list<std::shared_ptr<CClient>> m_Clients;
// status // status
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
std::time_t m_ConnectTime; std::time_t m_ConnectTime;
std::time_t m_LastHeardTime; std::time_t m_LastHeardTime;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpeer_h */

@ -1,35 +1,25 @@
//
// cxlxcallsignlist.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"
#include "PeerCallsignList.h" #include "PeerCallsignList.h"
////////////////////////////////////////////////////////////////////////////////////////
// file io
bool CPeerCallsignList::LoadFromFile(const char *filename) bool CPeerCallsignList::LoadFromFile(const char *filename)
{ {
bool ok = false; bool ok = false;

@ -1,31 +1,22 @@
//
// PeerCallsignList.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpeercallsignlist_h
#define cpeercallsignlist_h
#pragma once
#include "Main.h" #include "Main.h"
#include "CallsignList.h" #include "CallsignList.h"
@ -45,7 +36,3 @@ public:
// file io // file io
bool LoadFromFile(const char *); bool LoadFromFile(const char *);
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpeercallsignlist_h */

@ -1,27 +1,20 @@
//
// cpeers.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/12/2016.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Reflector.h" #include "Reflector.h"

@ -1,41 +1,25 @@
//
// Peers.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 10/12/2016.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpeers_h #pragma once
#define cpeers_h
#include "Peer.h" #include "Peer.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPeers class CPeers
{ {
public: public:
@ -73,7 +57,3 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
std::list<std::shared_ptr<CPeer>> m_Peers; std::list<std::shared_ptr<CPeer>> m_Peers;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cpeers_h */

@ -1,22 +1,18 @@
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// Copyright © 2020 Thomas A. Eary, 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,
// This file is part of xlxd. // 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.
// //
// xlxd is free software: you can redistribute it and/or modify // You should have received a copy of the GNU General Public License
// it under the terms of the GNU General Public License as published by // along with this program. If not, see <https://www.gnu.org/licenses/>.
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "ProtoAddress.h" #include "ProtoAddress.h"

@ -1,24 +1,20 @@
#pragma once // ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// Copyright © 2020 Thomas A. Eary, N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is free software: you can redistribute it and/or modify // This program is distributed in the hope that it will be useful,
// it under the terms of the GNU General Public License as published by // but WITHOUT ANY WARRANTY; without even the implied warranty of
// the Free Software Foundation, either version 3 of the License, or // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// (at your option) any later version. // GNU General Public License for more details.
// //
// xlxd is distributed in the hope that it will be useful, // You should have received a copy of the GNU General Public License
// but WITHOUT ANY WARRANTY; without even the implied warranty of // along with this program. If not, see <https://www.gnu.org/licenses/>.
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. #pragma once
//
// You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>

@ -1,27 +1,20 @@
//
// cprotocol.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DCSProtocol.h" #include "DCSProtocol.h"
@ -56,7 +49,7 @@ CProtocol::~CProtocol()
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// initialization // initialization
bool CProtocol::Initialize(const char *type, int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) bool CProtocol::Initialize(const char *type, int 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();
@ -66,7 +59,7 @@ bool CProtocol::Initialize(const char *type, int ptype, const uint16 port, const
// update the reflector callsign // update the reflector callsign
if (type) if (type)
m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)type, 3); m_ReflectorCallsign.PatchCallsign(0, (const uint8_t *)type, 3);
// create our sockets // create our sockets
#ifdef LISTEN_IPV4 #ifdef LISTEN_IPV4
@ -199,7 +192,7 @@ void CProtocol::OnDvLastFramePacketIn(std::unique_ptr<CDvLastFramePacket> &Frame
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// stream handle helpers // stream handle helpers
CPacketStream *CProtocol::GetStream(uint16 uiStreamId, const CIp *Ip) CPacketStream *CProtocol::GetStream(uint16_t uiStreamId, const CIp *Ip)
{ {
for ( auto it=m_Streams.begin(); it!=m_Streams.end(); it++ ) for ( auto it=m_Streams.begin(); it!=m_Streams.end(); it++ )
{ {
@ -261,14 +254,14 @@ bool CProtocol::IsSpace(char c) const
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper // DestId to Module helper
char CProtocol::DmrDstIdToModule(uint32 tg) const char CProtocol::DmrDstIdToModule(uint32_t tg) const
{ {
return ((char)((tg % 26)-1) + 'A'); return ((char)((tg % 26)-1) + 'A');
} }
uint32 CProtocol::ModuleToDmrDestId(char m) const uint32_t CProtocol::ModuleToDmrDestId(char m) const
{ {
return (uint32)(m - 'A')+1; return (uint32_t)(m - 'A')+1;
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////

@ -1,30 +1,22 @@
//
// DCSProtocol.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cprotocol_h #pragma once
#define cprotocol_h
#include "UDPSocket.h" #include "UDPSocket.h"
#include "PacketStream.h" #include "PacketStream.h"
@ -77,7 +69,7 @@ public:
virtual ~CProtocol(); virtual ~CProtocol();
// initialization // initialization
virtual bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); virtual bool Initialize(const char *type, const int ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6);
virtual void Close(void); virtual void Close(void);
// queue // queue
@ -104,7 +96,7 @@ protected:
virtual void OnDvLastFramePacketIn(std::unique_ptr<CDvLastFramePacket> &, const CIp * = nullptr); virtual void OnDvLastFramePacketIn(std::unique_ptr<CDvLastFramePacket> &, const CIp * = nullptr);
// stream handle helpers // stream handle helpers
CPacketStream *GetStream(uint16, const CIp * = nullptr); CPacketStream *GetStream(uint16_t, const CIp * = nullptr);
void CheckStreamsTimeout(void); void CheckStreamsTimeout(void);
// queue helper // queue helper
@ -119,8 +111,8 @@ protected:
bool IsSpace(char) const; bool IsSpace(char) const;
// dmr DstId to Module helper // dmr DstId to Module helper
virtual char DmrDstIdToModule(uint32) const; virtual char DmrDstIdToModule(uint32_t) const;
virtual uint32 ModuleToDmrDestId(char) const; virtual uint32_t ModuleToDmrDestId(char) const;
bool Receive6(CBuffer &buf, CIp &Ip, int time_ms); bool Receive6(CBuffer &buf, CIp &Ip, int time_ms);
bool Receive4(CBuffer &buf, CIp &Ip, int time_ms); bool Receive4(CBuffer &buf, CIp &Ip, int time_ms);
@ -128,8 +120,8 @@ protected:
void Send(const CBuffer &buf, const CIp &Ip) const; void Send(const CBuffer &buf, const CIp &Ip) const;
void Send(const char *buf, const CIp &Ip) const; void Send(const char *buf, const CIp &Ip) const;
void Send(const CBuffer &buf, const CIp &Ip, uint16 port) const; void Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const;
void Send(const char *buf, const CIp &Ip, uint16 port) const; void Send(const char *buf, const CIp &Ip, uint16_t port) const;
// socket // socket
CUdpSocket m_Socket4; CUdpSocket m_Socket4;
@ -149,8 +141,5 @@ protected:
CCallsign m_ReflectorCallsign; CCallsign m_ReflectorCallsign;
// debug // debug
CTimePoint m_DebugTimer; CTimer m_DebugTimer;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cprotocol_h */

@ -1,36 +1,29 @@
// // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// cprotocols.cpp
// xlxd // ulxd -- The universal reflector
// // Copyright © 2021 Thomas A. Early N7TAE
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "DExtraProtocol.h" #include "DExtraProtocol.h"
#include "DPlusProtocol.h" #include "DPlusProtocol.h"
#include "cdcsprotocol.h" #include "DCSProtocol.h"
#ifndef NO_XLX #ifndef NO_XLX
#include "ULXProtocol.h" #include "ULXProtocol.h"
#include "DMRPlusProtocol.h" #include "DMRPlusProtocol.h"
#include "DMMMDVMProtocol.h" #include "DMRMMDVMProtocol.h"
#include "YSFProtocol.h" #include "YSFProtocol.h"
#endif #endif
#ifndef NO_G3 #ifndef NO_G3

@ -1,40 +1,25 @@
//
// Protocols.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cprotocols_h #pragma once
#define cprotocols_h
#include "DCSProtocol.h" #include "DCSProtocol.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CProtocols class CProtocols
{ {
public: public:
@ -56,8 +41,3 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
std::list<std::unique_ptr<CProtocol>> m_Protocols; std::list<std::unique_ptr<CProtocol>> m_Protocols;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cprotocols_h */

@ -1,26 +1,20 @@
//
// crawsocket.cpp
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 22/02/2020.
// Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
@ -50,7 +44,7 @@ CRawSocket::~CRawSocket()
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// open & close // open & close
bool CRawSocket::Open(uint16 uiProto) bool CRawSocket::Open(uint16_t uiProto)
{ {
bool open = false; bool open = false;
int on = 1; int on = 1;

@ -1,33 +1,22 @@
//
// RawSocket.h
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 22/02/2020.
// Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// Description: #pragma once
// Raw socket access class with protocol specific
#ifndef crawsocket_h
#define crawsocket_h
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -60,7 +49,7 @@ public:
~CRawSocket(); ~CRawSocket();
// open & close // open & close
bool Open(uint16); bool Open(uint16_t);
void Close(void); void Close(void);
int GetSocket(void) { return m_Socket; } int GetSocket(void) { return m_Socket; }
@ -96,6 +85,3 @@ protected:
int m_Proto; int m_Proto;
struct sockaddr_in m_SocketAddr; struct sockaddr_in m_SocketAddr;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* crawsocket_h */

@ -1,37 +1,30 @@
//
// creflector.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>
#include "Reflector.h" #include "Reflector.h"
#include "GateKeeper.h" #include "GateKeeper.h"
#include "cdmriddirfile.h" #include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h" #include "DMRIdDirHttp.h"
#include "Transcoder.h" #include "Transcoder.h"
#include "YSFNodeDirFile.h" #include "YSFNodeDirFile.h"
#include "YSFNodeDirhttp.h" #include "YSFNodeDirHttp.h"
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// constructor // constructor
@ -243,7 +236,7 @@ void CReflector::CloseStream(CPacketStream *stream)
bEmpty = stream->empty(); bEmpty = stream->empty();
stream->Unlock(); stream->Unlock();
if ( !bEmpty ) if ( !bEmpty )
CTimePoint::TaskSleepFor(10); std::this_thread::sleep_for(std::chrono::milliseconds(10));
} }
while (!bEmpty); while (!bEmpty);
@ -282,7 +275,7 @@ void CReflector::CloseStream(CPacketStream *stream)
void CReflector::RouterThread(CPacketStream *streamIn) void CReflector::RouterThread(CPacketStream *streamIn)
{ {
// get our module // get our module
uint8 uiModuleId = GetStreamModule(streamIn); uint8_t uiModuleId = GetStreamModule(streamIn);
// get on input queue // get on input queue
std::unique_ptr<CPacket> packet; std::unique_ptr<CPacket> packet;
@ -334,7 +327,7 @@ void CReflector::RouterThread(CPacketStream *streamIn)
} }
else else
{ {
CTimePoint::TaskSleepFor(10); std::this_thread::sleep_for(std::chrono::milliseconds(10));
} }
} }
} }
@ -366,7 +359,7 @@ void CReflector::XmlReportThread()
// and wait a bit // and wait a bit
for (int i=0; i< XML_UPDATE_PERIOD && keep_running; i++) for (int i=0; i< XML_UPDATE_PERIOD && keep_running; i++)
CTimePoint::TaskSleepFor(1000); std::this_thread::sleep_for(std::chrono::milliseconds(1000));
} }
} }
@ -391,7 +384,7 @@ void CReflector::JsonReportThread()
if ( Socket.Receive(Buffer, Ip, 50) ) if ( Socket.Receive(Buffer, Ip, 50) )
{ {
// check verb // check verb
if ( Buffer.Compare((uint8 *)"hello", 5) == 0 ) if ( Buffer.Compare((uint8_t *)"hello", 5) == 0 )
{ {
std::cout << "Monitor socket connected with " << Ip << std::endl; std::cout << "Monitor socket connected with " << Ip << std::endl;
@ -405,7 +398,7 @@ void CReflector::JsonReportThread()
SendJsonNodesObject(Socket, Ip); SendJsonNodesObject(Socket, Ip);
SendJsonStationsObject(Socket, Ip); SendJsonStationsObject(Socket, Ip);
} }
else if ( Buffer.Compare((uint8 *)"bye", 3) == 0 ) else if ( Buffer.Compare((uint8_t *)"bye", 3) == 0 )
{ {
std::cout << "Monitor socket disconnected" << std::endl; std::cout << "Monitor socket disconnected" << std::endl;
@ -451,7 +444,7 @@ void CReflector::JsonReportThread()
case NOTIFICATION_NONE: case NOTIFICATION_NONE:
default: default:
// nothing to do, just sleep a bit // nothing to do, just sleep a bit
CTimePoint::TaskSleepFor(250); std::this_thread::sleep_for(std::chrono::milliseconds(250);
break; break;
} }
} }
@ -623,7 +616,7 @@ void CReflector::SendJsonReflectorObject(CUdpSocket &Socket, CIp &Ip)
char mod[8] = "\"A\""; char mod[8] = "\"A\"";
// get reflector callsign // get reflector callsign
m_Callsign.GetCallsign((uint8 *)cs); m_Callsign.GetCallsign((uint8_t *)cs);
cs[CALLSIGN_LEN] = 0; cs[CALLSIGN_LEN] = 0;
// build string // build string

@ -1,30 +1,22 @@
//
// Reflector.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef creflector_h #pragma once
#define creflector_h
#include "ProtoAddress.h" #include "ProtoAddress.h"
#include "Users.h" #include "Users.h"
@ -155,6 +147,3 @@ public:
std::ofstream m_DebugFile; std::ofstream m_DebugFile;
#endif #endif
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* creflector_h */

@ -1,26 +1,20 @@
//
// csemaphore.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 16/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Semaphore.h" #include "Semaphore.h"
@ -57,7 +51,7 @@ void CSemaphore::Wait(void)
m_Count--; m_Count--;
} }
bool CSemaphore::WaitFor(uint ms) bool CSemaphore::WaitFor(unsigned ms)
{ {
std::chrono::milliseconds timespan(ms); std::chrono::milliseconds timespan(ms);
std::unique_lock<decltype(m_Mutex)> lock(m_Mutex); std::unique_lock<decltype(m_Mutex)> lock(m_Mutex);

@ -1,33 +1,24 @@
//
// Semaphore.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 16/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef csemaphore_h
#define csemaphore_h
#pragma once
//////////////////////////////////////////////////////////////////////////////////////// #include "Main.h"
// class
class CSemaphore class CSemaphore
{ {
@ -42,7 +33,7 @@ public:
void Reset(void); void Reset(void);
void Notify(void); void Notify(void);
void Wait(void); void Wait(void);
bool WaitFor(uint); bool WaitFor(unsigned);
protected: protected:
// data // data
@ -51,6 +42,3 @@ protected:
size_t m_Count; size_t m_Count;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* csemaphore_h */

@ -1,16 +1,16 @@
// hyvoc - a hybrid vocoder using DVSI hardware and Codec2 software // ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE // Copyright © 2021 Thomas A. Early N7TAE
//
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.

@ -1,26 +1,20 @@
//
// ctranscoder.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 13/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include "Reflector.h" #include "Reflector.h"
@ -48,8 +42,8 @@ CTranscoder::CTranscoder()
{ {
keep_running = true; keep_running = true;
m_bConnected = false; m_bConnected = false;
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
m_LastActivityTime.Now(); m_LastActivityTime.start();
m_bStreamOpened = false; m_bStreamOpened = false;
m_StreamidOpenStream = 0; m_StreamidOpenStream = 0;
m_PortOpenStream = 0; m_PortOpenStream = 0;
@ -147,14 +141,14 @@ void CTranscoder::Task(void)
{ {
CBuffer Buffer; CBuffer Buffer;
CIp Ip; CIp Ip;
uint16 StreamId; uint16_t StreamId;
uint16 Port; uint16_t Port;
// anything coming in from codec server ? // anything coming in from codec server ?
//if ( (m_Socket.Receive(&Buffer, &Ip, 20) != -1) && (Ip == m_Ip) ) //if ( (m_Socket.Receive(&Buffer, &Ip, 20) != -1) && (Ip == m_Ip) )
if ( m_Socket.Receive(Buffer, Ip, 20) ) if ( m_Socket.Receive(Buffer, Ip, 20) )
{ {
m_LastActivityTime.Now(); m_LastActivityTime.start();
// crack packet // crack packet
if ( IsValidStreamDescrPacket(Buffer, &StreamId, &Port) ) if ( IsValidStreamDescrPacket(Buffer, &StreamId, &Port) )
@ -182,20 +176,20 @@ void CTranscoder::Task(void)
} }
// keep client alive // keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > TRANSCODER_KEEPALIVE_PERIOD ) if ( m_LastKeepaliveTime.time() > TRANSCODER_KEEPALIVE_PERIOD )
{ {
// //
HandleKeepalives(); HandleKeepalives();
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.start();
} }
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// manage streams // manage streams
std::shared_ptr<CCodecStream> CTranscoder::GetCodecStream(CPacketStream *PacketStream, uint8 uiCodecIn) std::shared_ptr<CCodecStream> CTranscoder::GetCodecStream(CPacketStream *PacketStream, uint8_t uiCodecIn)
{ {
CBuffer Buffer; CBuffer Buffer;
@ -315,7 +309,7 @@ void CTranscoder::HandleKeepalives(void)
m_Socket.Send(keepalive, m_Ip, TRANSCODER_PORT); m_Socket.Send(keepalive, m_Ip, TRANSCODER_PORT);
// check if still with us // check if still with us
if ( m_bConnected && (m_LastActivityTime.DurationSinceNow() >= TRANSCODER_KEEPALIVE_TIMEOUT) ) if ( m_bConnected && (m_LastActivityTime.time() >= TRANSCODER_KEEPALIVE_TIMEOUT) )
{ {
// no, disconnect // no, disconnect
m_bConnected = false; m_bConnected = false;
@ -328,7 +322,7 @@ void CTranscoder::HandleKeepalives(void)
bool CTranscoder::IsValidKeepAlivePacket(const CBuffer &Buffer) bool CTranscoder::IsValidKeepAlivePacket(const CBuffer &Buffer)
{ {
uint8 tag[] = { 'A','M','B','E','D','P','O','N','G' }; uint8_t tag[] = { 'A','M','B','E','D','P','O','N','G' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 9) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 9) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
@ -338,17 +332,17 @@ bool CTranscoder::IsValidKeepAlivePacket(const CBuffer &Buffer)
return valid; return valid;
} }
bool CTranscoder::IsValidStreamDescrPacket(const CBuffer &Buffer, uint16 *Id, uint16 *Port) bool CTranscoder::IsValidStreamDescrPacket(const CBuffer &Buffer, uint16_t *Id, uint16_t *Port)
{ {
uint8 tag[] = { 'A','M','B','E','D','S','T','D' }; uint8_t tag[] = { 'A','M','B','E','D','S','T','D' };
bool valid = false; bool valid = false;
if ( (Buffer.size() == 14) && (Buffer.Compare(tag, sizeof(tag)) == 0) ) if ( (Buffer.size() == 14) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{ {
*Id = *(uint16 *)(&Buffer.data()[8]); *Id = *(uint16_t *)(&Buffer.data()[8]);
*Port = *(uint16 *)(&Buffer.data()[10]); *Port = *(uint16_t *)(&Buffer.data()[10]);
// uint8 CodecIn = Buffer.data()[12]; // uint8_t CodecIn = Buffer.data()[12];
// uint8 CodecOut = Buffer.data()[13]; // uint8_t CodecOut = Buffer.data()[13];
valid = true; valid = true;
} }
return valid; return valid;
@ -356,7 +350,7 @@ bool CTranscoder::IsValidStreamDescrPacket(const CBuffer &Buffer, uint16 *Id, ui
bool CTranscoder::IsValidNoStreamAvailablePacket(const CBuffer&Buffer) bool CTranscoder::IsValidNoStreamAvailablePacket(const CBuffer&Buffer)
{ {
uint8 tag[] = { 'A','M','B','E','D','B','U','S','Y' }; uint8_t tag[] = { 'A','M','B','E','D','B','U','S','Y' };
return ( (Buffer.size() == 9) && (Buffer.Compare(tag, sizeof(tag)) == 0) ); return ( (Buffer.size() == 9) && (Buffer.Compare(tag, sizeof(tag)) == 0) );
} }
@ -367,26 +361,26 @@ bool CTranscoder::IsValidNoStreamAvailablePacket(const CBuffer&Buffer)
void CTranscoder::EncodeKeepAlivePacket(CBuffer *Buffer) void CTranscoder::EncodeKeepAlivePacket(CBuffer *Buffer)
{ {
uint8 tag[] = { 'A','M','B','E','D','P','I','N','G' }; uint8_t tag[] = { 'A','M','B','E','D','P','I','N','G' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append((uint8 *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN); Buffer->Append((uint8_t *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN);
} }
void CTranscoder::EncodeOpenstreamPacket(CBuffer *Buffer, uint8 uiCodecIn, uint8 uiCodecOut) void CTranscoder::EncodeOpenstreamPacket(CBuffer *Buffer, uint8_t uiCodecIn, uint8_t uiCodecOut)
{ {
uint8 tag[] = { 'A','M','B','E','D','O','S' }; uint8_t tag[] = { 'A','M','B','E','D','O','S' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append((uint8 *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN); Buffer->Append((uint8_t *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8)uiCodecIn); Buffer->Append((uint8_t)uiCodecIn);
Buffer->Append((uint8)uiCodecOut); Buffer->Append((uint8_t)uiCodecOut);
} }
void CTranscoder::EncodeClosestreamPacket(CBuffer *Buffer, uint16 uiStreamId) void CTranscoder::EncodeClosestreamPacket(CBuffer *Buffer, uint16_t uiStreamId)
{ {
uint8 tag[] = { 'A','M','B','E','D','C','S' }; uint8_t tag[] = { 'A','M','B','E','D','C','S' };
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append((uint16)uiStreamId); Buffer->Append((uint16_t)uiStreamId);
} }

@ -1,42 +1,27 @@
//
// Transcoder.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 13/04/2017.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef ctranscoder_h #pragma once
#define ctranscoder_h
#include "Semaphore.h" #include "Semaphore.h"
#include "CodecStream.h" #include "CodecStream.h"
#include "UDPSocket.h" #include "UDPSocket.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPacketStream; class CPacketStream;
class CTranscoder class CTranscoder
@ -60,7 +45,7 @@ public:
bool IsConnected(void) const { return m_bConnected; } bool IsConnected(void) const { return m_bConnected; }
// manage streams // manage streams
std::shared_ptr<CCodecStream> GetCodecStream(CPacketStream *, uint8); std::shared_ptr<CCodecStream> GetCodecStream(CPacketStream *, uint8_t);
void ReleaseStream(std::shared_ptr<CCodecStream>); void ReleaseStream(std::shared_ptr<CCodecStream>);
// task // task
@ -73,13 +58,13 @@ protected:
// packet decoding helpers // packet decoding helpers
bool IsValidKeepAlivePacket(const CBuffer &); bool IsValidKeepAlivePacket(const CBuffer &);
bool IsValidStreamDescrPacket(const CBuffer &, uint16 *, uint16 *); bool IsValidStreamDescrPacket(const CBuffer &, uint16_t *, uint16_t *);
bool IsValidNoStreamAvailablePacket(const CBuffer&); bool IsValidNoStreamAvailablePacket(const CBuffer&);
// packet encoding helpers // packet encoding helpers
void EncodeKeepAlivePacket(CBuffer *); void EncodeKeepAlivePacket(CBuffer *);
void EncodeOpenstreamPacket(CBuffer *, uint8, uint8); void EncodeOpenstreamPacket(CBuffer *, uint8_t, uint8_t);
void EncodeClosestreamPacket(CBuffer *, uint16); void EncodeClosestreamPacket(CBuffer *, uint16_t);
protected: protected:
// streams // streams
@ -89,8 +74,8 @@ protected:
// sync objects for Openstream // sync objects for Openstream
CSemaphore m_SemaphoreOpenStream; CSemaphore m_SemaphoreOpenStream;
bool m_bStreamOpened; bool m_bStreamOpened;
uint16 m_StreamidOpenStream; uint16_t m_StreamidOpenStream;
uint16 m_PortOpenStream; uint16_t m_PortOpenStream;
// thread // thread
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
@ -102,10 +87,6 @@ protected:
bool m_bConnected; bool m_bConnected;
// time // time
CTimePoint m_LastKeepaliveTime; CTimer m_LastKeepaliveTime;
CTimePoint m_LastActivityTime; CTimer m_LastActivityTime;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* ctranscoder_h */

@ -1,26 +1,20 @@
//
// cudpmsgsocket.cpp
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 22/02/2020.
// Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "Main.h" #include "Main.h"
#include <string.h> #include <string.h>

@ -1,41 +1,31 @@
//
// UDPMsgSocket.h
// xlxd
//
// Created by Marius Petrescu (YO2LOJ) on 22/02/2020.
// Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved. // Copyright © 2020 Marius Petrescu (YO2LOJ). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
// //
// ---------------------------------------------------------------------------- // This program is free software: you can redistribute it and/or modify
// This file is part of xlxd. // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// xlxd is free software: you can redistribute it and/or modify // (at your option) any later version.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// Description: // Description:
// Extension of the CUdpSocket class to allow retrieving // Extension of the CUdpSocket class to allow retrieving
// the local target IP for a G3 Terminal mode config request // the local target IP for a G3 Terminal mode config request
#ifndef cudpmsgsocket_h #pragma once
#define cudpmsgsocket_h
#include "UDPSocket.h" #include "UDPSocket.h"
#define UDP_MSG_BUFFER_LENMAX 1024 #define UDP_MSG_BUFFER_LENMAX 1024
////////////////////////////////////////////////////////////////////////////////////////
// class
class CUdpMsgSocket : public CUdpSocket class CUdpMsgSocket : public CUdpSocket
{ {
public: public:
@ -51,6 +41,3 @@ protected:
// data // data
struct in_addr m_LocalAddr; struct in_addr m_LocalAddr;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cudpmsgsocket_h */

@ -1,27 +1,20 @@
//
// cudpsocket.cpp
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <string.h> #include <string.h>
#include "Main.h" #include "Main.h"

@ -1,30 +1,22 @@
//
// UDPSocket.h
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/2015.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved. // Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
// // ulxd -- The universal reflector
// ---------------------------------------------------------------------------- // Copyright © 2021 Thomas A. Early N7TAE
// This file is part of xlxd.
// //
// xlxd is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// xlxd is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // 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 this program. If not, see <https://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cudpsocket_h #pragma once
#define cudpsocket_h
#include <cstdint> #include <cstdint>
#include <sys/types.h> #include <sys/types.h>
@ -37,15 +29,8 @@
#include "IP.h" #include "IP.h"
#include "Buffer.h" #include "Buffer.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
#define UDP_BUFFER_LENMAX 1024 #define UDP_BUFFER_LENMAX 1024
////////////////////////////////////////////////////////////////////////////////////////
// class
class CUdpSocket class CUdpSocket
{ {
public: public:
@ -78,6 +63,3 @@ protected:
int m_fd; int m_fd;
CIp m_addr; CIp m_addr;
}; };
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cudpsocket_h */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.