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

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

@ -1,31 +1,31 @@
/*
* Copyright (C) 2012 by Ian Wraith
* Copyright (C) 2015 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.
*/
#include "CBPT19696.h"
#include "Hamming.h"
#include "Utils.h"
// Copyright (C) 2012 by Ian Wraith
// Copyright (C) 2015 by Jonathan Naylor G4KLX
// 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 <cstdio>
#include <cassert>
#include <cstring>
#include "CBPTC19696.h"
#include "Hamming.h"
#include "Utils.h"
CBPTC19696::CBPTC19696()
{
}

@ -1,23 +1,22 @@
/*
* Copyright (C) 2015 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(BPTC19696_H)
#define BPTC19696_H
// Copyright (C) 2015 by Jonathan Naylor G4KLX
// 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
class CBPTC19696
{
@ -43,5 +42,3 @@ private:
void encodeErrorCheck();
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cnotificationqueue_h
#define cnotificationqueue_h
#pragma once
#include <queue>
#include <mutex>
@ -63,6 +53,3 @@ protected:
std::mutex m_Mutex;
std::queue<CNotification> queue;
};
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cnotificationqueue_h */

@ -1,20 +1,20 @@
/*
* 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.
*/
// Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
// 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 "CRC.h"

@ -1,23 +1,22 @@
/*
* 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.
*/
// Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
#if !defined(CRC_H)
#define CRC_H
// 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
class CCRC
{
@ -35,5 +34,3 @@ public:
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include <cctype>
#include "cdmriddirfile.h"
#include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h"
#include "Callsign.h"
@ -43,7 +37,7 @@ CCallsign::CCallsign()
#endif
}
CCallsign::CCallsign(const char *sz, uint32 dmrid)
CCallsign::CCallsign(const char *sz, uint32_t dmrid)
{
// blank all
::memset(m_Callsign, ' ', sizeof(m_Callsign));
@ -168,7 +162,7 @@ void CCallsign::SetCallsign(const char *sz, bool UpdateDmrid)
#endif
}
void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
void CCallsign::SetCallsign(const uint8_t *buffer, int len, bool UpdateDmrid)
{
// set callsign
::memset(m_Callsign, ' ', sizeof(m_Callsign));
@ -198,7 +192,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
}
#ifndef NO_XLX
void CCallsign::SetDmrid(uint32 dmrid, bool UpdateCallsign)
void CCallsign::SetDmrid(uint32_t dmrid, bool UpdateCallsign)
{
m_uiDmrid = dmrid;
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];
::memcpy(sz, buffer, 8);
sz[8] = 0;
SetDmrid((uint32)::strtol(sz, nullptr, 16), UpdateCallsign);
SetDmrid((uint32_t)::strtol(sz, nullptr, 16), UpdateCallsign);
}
#endif
@ -236,7 +230,7 @@ void CCallsign::SetSuffix(const char *sz)
::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));
::memset(m_Suffix, ' ', sizeof(m_Suffix));
@ -246,7 +240,7 @@ void CCallsign::SetSuffix(const uint8 *buffer, int len)
////////////////////////////////////////////////////////////////////////////////////////
// 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 )
{
@ -258,7 +252,7 @@ void CCallsign::PatchCallsign(int off, const uint8 *patch, int len)
////////////////////////////////////////////////////////////////////////////////////////
// get
void CCallsign::GetCallsign(uint8 *buffer) const
void CCallsign::GetCallsign(uint8_t *buffer) const
{
::memcpy(buffer, m_Callsign, sizeof(m_Callsign));
if ( HasModule() )
@ -277,7 +271,7 @@ void CCallsign::GetCallsignString(char *sz) const
sz[i] = 0;
}
void CCallsign::GetSuffix(uint8 *buffer) const
void CCallsign::GetSuffix(uint8_t *buffer) const
{
::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
// xlxd
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/10/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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ccallsign_h
#define ccallsign_h
#pragma once
////////////////////////////////////////////////////////////////////////////////////////
// define
@ -40,7 +33,7 @@ class CCallsign
public:
// contructors
CCallsign();
CCallsign(const char *, uint32 = 0);
CCallsign(const char *, uint32_t = 0);
// status
bool IsValid(void) const;
@ -49,25 +42,25 @@ public:
// set
void SetCallsign(const char *, bool = true);
void SetCallsign(const uint8 *, int, bool = true);
void SetCallsign(const uint8_t *, int, bool = true);
#ifndef NO_XLX
void SetDmrid(uint32, bool = true);
void SetDmrid(const uint8 *, bool = true);
void SetDmrid(uint32_t, bool = true);
void SetDmrid(const uint8_t *, bool = true);
#endif
void SetModule(char);
void SetSuffix(const char *);
void SetSuffix(const uint8 *, int);
void SetSuffix(const uint8_t *, int);
// modify
void PatchCallsign(int, const uint8 *, int);
void PatchCallsign(int, const uint8_t *, int);
// get
void GetCallsign(uint8 *) const;
void GetCallsign(uint8_t *) const;
void GetCallsignString(char *) const;
#ifndef NO_XLX
uint32 GetDmrid(void) const { return m_uiDmrid; }
uint32_t GetDmrid(void) const { return m_uiDmrid; }
#endif
void GetSuffix(uint8 *) const;
void GetSuffix(uint8_t *) const;
char GetModule(void) const { return m_Module; }
// compare
@ -93,9 +86,6 @@ protected:
char m_Module;
mutable char m_sz[CALLSIGN_LEN+CALLSUFFIX_LEN+5];
#ifndef NO_XLX
uint32 m_uiDmrid;
uint32_t m_uiDmrid;
#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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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>

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

@ -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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ccallsignlistitem_h
#define ccallsignlistitem_h
#pragma once
#include "Main.h"
#include "Callsign.h"
@ -70,8 +63,3 @@ protected:
CIp m_Ip;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -34,7 +28,7 @@ CClient::CClient()
{
m_ReflectorModule = ' ';
m_ModuleMastered = ' ';
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
m_ConnectTime = 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_Ip = ip;
m_ModuleMastered = ' ';
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
m_ConnectTime = std::time(nullptr);
m_LastHeardTime = std::time(nullptr);
}
@ -66,7 +60,7 @@ CClient::CClient(const CClient &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cclient_h
#define cclient_h
#pragma once
#include "Timer.h"
#include "IP.h"
@ -94,10 +87,7 @@ protected:
// status
char m_ModuleMastered;
CTimePoint m_LastKeepaliveTime;
CTimer m_LastKeepaliveTime;
std::time_t m_ConnectTime;
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cclients_h
#define cclients_h
#pragma once
#include "Client.h"
@ -79,7 +71,3 @@ protected:
std::mutex m_Mutex;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -36,7 +30,7 @@
////////////////////////////////////////////////////////////////////////////////////////
// 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;
m_uiStreamId = uiId;
@ -72,7 +66,7 @@ CCodecStream::~CCodecStream()
////////////////////////////////////////////////////////////////////////////////////////
// initialization
bool CCodecStream::Init(uint16 uiPort)
bool CCodecStream::Init(uint16_t uiPort)
{
m_bConnected = keep_running = false; // prepare for the worst
@ -155,8 +149,8 @@ void CCodecStream::Task(void)
{
CBuffer Buffer;
CIp Ip;
uint8 Ambe[AMBE_SIZE];
uint8 DStarSync[] = { 0x55,0x2D,0x16 };
uint8_t Ambe[AMBE_SIZE];
uint8_t DStarSync[] = { 0x55,0x2D,0x16 };
// any packet from transcoder
if ( m_Socket.Receive(Buffer, Ip, 5) )
@ -165,10 +159,10 @@ void CCodecStream::Task(void)
if ( IsValidAmbePacket(Buffer, Ambe) )
{
// tickle
m_TimeoutTimer.Now();
m_TimeoutTimer.start();
// update statistics
double ping = m_StatsTimer.DurationSinceNow();
double ping = m_StatsTimer.time();
if ( m_fPingMin == -1 )
{
m_fPingMin = ping;
@ -222,7 +216,7 @@ void CCodecStream::Task(void)
// this assume that thread pushing the Packet
// have verified that the CodecStream is connected
// and that the packet needs transcoding
m_StatsTimer.Now();
m_StatsTimer.start();
m_uiTotalPackets++;
EncodeAmbePacket(&Buffer, Frame->GetAmbe(m_uiCodecIn));
m_Socket.Send(Buffer, m_Ip, m_uiPort);
@ -232,7 +226,7 @@ void CCodecStream::Task(void)
}
// 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;
m_uiTimeoutPackets++;
@ -242,7 +236,7 @@ void CCodecStream::Task(void)
////////////////////////////////////////////////////////////////////////////////////////
/// packet decoding helpers
bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8 *Ambe)
bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8_t *Ambe)
{
bool valid = false;
@ -257,10 +251,10 @@ bool CCodecStream::IsValidAmbePacket(const CBuffer &Buffer, uint8 *Ambe)
////////////////////////////////////////////////////////////////////////////////////////
/// packet encoding helpers
void CCodecStream::EncodeAmbePacket(CBuffer *Buffer, const uint8 *Ambe)
void CCodecStream::EncodeAmbePacket(CBuffer *Buffer, const uint8_t *Ambe)
{
Buffer->clear();
Buffer->Append(m_uiCodecIn);
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ccodecstream_h
#define ccodecstream_h
#pragma once
#include "Semaphore.h"
#include "UDPSocket.h"
@ -47,23 +40,23 @@ class CCodecStream : public CPacketQueue
{
public:
// constructor
CCodecStream(CPacketStream *, uint16, uint8, uint8);
CCodecStream(CPacketStream *, uint16_t, uint8_t, uint8_t);
// destructor
virtual ~CCodecStream();
// initialization
bool Init(uint16);
bool Init(uint16_t);
void Close(void);
// get
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 GetPingMax(void) const { return m_fPingMax; }
double GetPingAve(void) const { return (m_fPingCount != 0) ? m_fPingSum/m_fPingCount : 0; }
uint32 GetTotalPackets(void) const { return m_uiTotalPackets; }
uint32 GetTimeoutPackets(void) const { return m_uiTimeoutPackets; }
uint32_t GetTotalPackets(void) const { return m_uiTotalPackets; }
uint32_t GetTimeoutPackets(void) const { return m_uiTimeoutPackets; }
bool IsEmpty(void) const;
// task
@ -73,19 +66,19 @@ public:
protected:
// packet decoding helpers
bool IsValidAmbePacket(const CBuffer &, uint8 *);
bool IsValidAmbePacket(const CBuffer &, uint8_t *);
// packet encoding helpers
void EncodeAmbePacket(CBuffer *, const uint8 *);
void EncodeAmbePacket(CBuffer *, const uint8_t *);
protected:
// data
uint16 m_uiStreamId;
uint16 m_uiPort;
uint8 m_uiPid;
uint8 m_uiCodecIn;
uint8 m_uiCodecOut;
uint16_t m_uiStreamId;
uint16_t m_uiPort;
uint8_t m_uiPid;
uint8_t m_uiCodecIn;
uint8_t m_uiCodecOut;
// socket
CIp m_Ip;
@ -93,24 +86,20 @@ protected:
bool m_bConnected;
// associated packet stream
CPacketStream *m_PacketStream;
CPacketStream *m_PacketStream;
CPacketQueue m_LocalQueue;
// thread
std::atomic<bool> keep_running;
std::future<void> m_Future;
CTimePoint m_TimeoutTimer;
CTimePoint m_StatsTimer;
CTimer m_TimeoutTimer;
CTimer m_StatsTimer;
// statistics
double m_fPingMin;
double m_fPingMax;
double m_fPingSum;
double m_fPingCount;
uint32 m_uiTotalPackets;
uint32 m_uiTimeoutPackets;
uint32_t m_uiTotalPackets;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DCSClient.h"
@ -48,5 +42,5 @@ CDcsClient::CDcsClient(const CDcsClient &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdcsclient_h
#define cdcsclient_h
#pragma once
#include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDcsClient : public CClient
{
public:
@ -54,7 +40,3 @@ public:
// status
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include "DCSClient.h"
#include "cdcsprotocol.h"
#include "DCSProtocol.h"
#include "Reflector.h"
#include "GateKeeper.h"
////////////////////////////////////////////////////////////////////////////////////////
// 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
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
return false;
// update time
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
// done
return true;
@ -178,13 +171,13 @@ void CDcsProtocol::Task(void)
HandleQueue();
// keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > DCS_KEEPALIVE_PERIOD )
if ( m_LastKeepaliveTime.time() > DCS_KEEPALIVE_PERIOD )
{
//
HandleKeepalives();
// 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)
{
uint8 tag[] = { '0','0','0','1' };
uint8_t tag[] = { '0','0','0','1' };
if ( (Buffer.size() >= 100) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{
// 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
if ( Buffer.data()[45] & 0x40U )
{
// 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
{
// 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
@ -420,7 +413,7 @@ bool CDcsProtocol::IsValidDvPacket(const CBuffer &Buffer, std::unique_ptr<CDvHea
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 )
return true;
@ -438,75 +431,75 @@ void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{
uint8 tag[] = { 0x0A,0x00,0x20,0x20 };
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)Client->GetReflectorModule());
Buffer->Append((uint8)' ');
Buffer->Append((uint8 *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)Client->GetModule());
Buffer->Append((uint8)Client->GetModule());
uint8_t tag[] = { 0x0A,0x00,0x20,0x20 };
Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8_t)Client->GetReflectorModule());
Buffer->Append((uint8_t)' ');
Buffer->Append((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append(tag, sizeof(tag));
}
void CDcsProtocol::EncodeConnectAckPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer)
{
uint8 tag[] = { 'A','C','K',0x00 };
uint8 cs[CALLSIGN_LEN];
uint8_t tag[] = { 'A','C','K',0x00 };
uint8_t cs[CALLSIGN_LEN];
Callsign.GetCallsign(cs);
Buffer->Set(cs, CALLSIGN_LEN-1);
Buffer->Append((uint8)' ');
Buffer->Append((uint8)Callsign.GetModule());
Buffer->Append((uint8)ReflectorModule);
Buffer->Append((uint8_t)' ');
Buffer->Append((uint8_t)Callsign.GetModule());
Buffer->Append((uint8_t)ReflectorModule);
Buffer->Append(tag, sizeof(tag));
}
void CDcsProtocol::EncodeConnectNackPacket(const CCallsign &Callsign, char ReflectorModule, CBuffer *Buffer)
{
uint8 tag[] = { 'N','A','K',0x00 };
uint8 cs[CALLSIGN_LEN];
uint8_t tag[] = { 'N','A','K',0x00 };
uint8_t cs[CALLSIGN_LEN];
Callsign.GetCallsign(cs);
Buffer->Set(cs, CALLSIGN_LEN-1);
Buffer->Append((uint8)' ');
Buffer->Append((uint8)Callsign.GetModule());
Buffer->Append((uint8)ReflectorModule);
Buffer->Append((uint8_t)' ');
Buffer->Append((uint8_t)Callsign.GetModule());
Buffer->Append((uint8_t)ReflectorModule);
Buffer->Append(tag, sizeof(tag));
}
void CDcsProtocol::EncodeDisconnectPacket(CBuffer *Buffer, std::shared_ptr<CClient>Client)
{
Buffer->Set((uint8 *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)' ');
Buffer->Append((uint8)Client->GetModule());
Buffer->Append((uint8)0x00);
Buffer->Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8)' ');
Buffer->Append((uint8)0x00);
Buffer->Set((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8_t)' ');
Buffer->Append((uint8_t)Client->GetModule());
Buffer->Append((uint8_t)0x00);
Buffer->Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
Buffer->Append((uint8_t)' ');
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;
Header.ConvertToDstarStruct(&DstarHeader);
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((uint8)(DvFrame.GetPacketId() % 21));
Buffer->Append((uint8 *)DvFrame.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)DvFrame.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8)((iSeq >> 0) & 0xFF));
Buffer->Append((uint8)((iSeq >> 8) & 0xFF));
Buffer->Append((uint8)((iSeq >> 16) & 0xFF));
Buffer->Append((uint8)0x01);
Buffer->Append((uint8)0x00, 38);
Buffer->Append((uint8_t)(DvFrame.GetPacketId() % 21));
Buffer->Append((uint8_t *)DvFrame.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8_t *)DvFrame.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8_t)((iSeq >> 0) & 0xFF));
Buffer->Append((uint8_t)((iSeq >> 8) & 0xFF));
Buffer->Append((uint8_t)((iSeq >> 16) & 0xFF));
Buffer->Append((uint8_t)0x01);
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);
(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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdcsprotocol_h
#define cdcsprotocol_h
#pragma once
#include "Timer.h"
#include "DCSProtocol.h"
#include "Protocol.h"
#include "DVHeaderPacket.h"
#include "DVFramePacket.h"
#include "DVLastFramePacket.h"
@ -44,14 +37,14 @@ public:
~CDcsStreamCacheItem() {}
CDvHeaderPacket m_dvHeader;
uint32 m_iSeqCounter;
uint32_t m_iSeqCounter;
};
class CDcsProtocol : public CProtocol
{
public:
// 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
void Task(void);
@ -79,16 +72,13 @@ protected:
void EncodeConnectAckPacket(const CCallsign &, char, CBuffer *);
void EncodeConnectNackPacket(const CCallsign &, char, CBuffer *);
void EncodeDisconnectPacket(CBuffer *, std::shared_ptr<CClient>);
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32_t, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, const CDvFramePacket &, uint32_t, CBuffer *) const;
protected:
// for keep alive
CTimePoint m_LastKeepaliveTime;
CTimer m_LastKeepaliveTime;
// for queue header caches
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DExtraClient.h"
@ -51,5 +45,5 @@ CDextraClient::CDextraClient(const CDextraClient &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdextraclient_h
#define cdextraclient_h
#pragma once
#include "Client.h"
@ -59,6 +52,3 @@ protected:
// data
int m_ProtRev;
};
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdextraclient_h */

@ -1,27 +1,21 @@
//
// cdextrapeer.cpp
// xlxd
//
// Created by Antony Chazapis (SV9OAN) on 25/2/2018.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>

@ -1,40 +1,27 @@
//
// DExtraPeer.h
// xlxd
//
// Created by Antony Chazapis (SV9OAN) on 25/2/2018.
// Copyright © 2016 Jean-Luc Deltombe (LX3JL). All rights reserved.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdextrapeer_h
#define cdextrapeer_h
#pragma once
#include "Peer.h"
#include "DExtraClient.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDextraPeer : public CPeer
{
public:
@ -53,6 +40,3 @@ public:
// revision helper
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -35,7 +28,7 @@
////////////////////////////////////////////////////////////////////////////////////////
// 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
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)
{
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
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
if ( header && header->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
return true;
@ -546,12 +539,12 @@ void CDextraProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
void CDextraProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules)
{
uint8 lm = (uint8)Modules[0];
uint8 rm = (uint8)Modules[1];
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
uint8_t lm = (uint8_t)Modules[0];
uint8_t rm = (uint8_t)Modules[1];
Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append(lm);
Buffer->Append(rm);
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
}
void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
@ -560,18 +553,18 @@ void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
if ( ProtRev == 2 )
{
// XRFxxx
uint8 rm = (Buffer->data())[8];
uint8 lm = (Buffer->data())[9];
uint8_t rm = (Buffer->data())[8];
uint8_t lm = (Buffer->data())[9];
Buffer->clear();
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append(lm);
Buffer->Append(rm);
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
}
else
{
// regular repeater
uint8 tag[] = { 'A','C','K',0 };
uint8_t tag[] = { 'A','C','K',0 };
Buffer->resize(Buffer->size()-1);
Buffer->Append(tag, sizeof(tag));
}
@ -579,49 +572,49 @@ void CDextraProtocol::EncodeConnectAckPacket(CBuffer *Buffer, int ProtRev)
void CDextraProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
{
uint8 tag[] = { 'N','A','K',0 };
uint8_t tag[] = { 'N','A','K',0 };
Buffer->resize(Buffer->size()-1);
Buffer->Append(tag, sizeof(tag));
}
void CDextraProtocol::EncodeDisconnectPacket(CBuffer *Buffer, char Module)
{
uint8 tag[] = { ' ',0 };
Buffer->Set((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8)Module);
uint8_t tag[] = { ' ',0 };
Buffer->Set((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8_t)Module);
Buffer->Append(tag, sizeof(tag));
}
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));
}
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;
Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header));
Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true;
}
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->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true;
@ -629,12 +622,12 @@ bool CDextraProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer
bool CDextraProtocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const
{
uint8 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 tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
uint8_t tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2));
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdextraprotocol_h
#define cdextraprotocol_h
#pragma once
#include "Timer.h"
#include "DCSProtocol.h"
@ -59,7 +52,7 @@ class CDextraProtocol : public CProtocol
{
public:
// 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
void Task(void);
@ -99,6 +92,3 @@ protected:
CTimePoint m_LastKeepaliveTime;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include "Main.h"
#include "Reflector.h"
#include "DMRIdDir.h"
#include "cdmriddirfile.h"
#include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h"
////////////////////////////////////////////////////////////////////////////////////////
@ -78,7 +72,7 @@ void CDmridDir::Thread()
{
// Wait DMRIDDB_REFRESH_RATE minutes
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 ?
if ( NeedReload() )
@ -111,7 +105,7 @@ bool CDmridDir::Reload(void)
////////////////////////////////////////////////////////////////////////////////////////
// find
const CCallsign *CDmridDir::FindCallsign(uint32 dmrid)
const CCallsign *CDmridDir::FindCallsign(uint32_t dmrid)
{
auto found = m_CallsignMap.find(dmrid);
if ( found != m_CallsignMap.end() )
@ -121,7 +115,7 @@ const CCallsign *CDmridDir::FindCallsign(uint32 dmrid)
return nullptr;
}
uint32 CDmridDir::FindDmrid(const CCallsign &callsign)
uint32_t CDmridDir::FindDmrid(const CCallsign &callsign)
{
auto found = m_DmridMap.find(callsign);
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmriddir_h
#define cdmriddir_h
#pragma once
#include <sys/types.h>
#include <sys/socket.h>
@ -65,8 +58,8 @@ public:
virtual bool RefreshContent(const CBuffer &) { return false; }
// find
const CCallsign *FindCallsign(uint32);
uint32 FindDmrid(const CCallsign &);
const CCallsign *FindCallsign(uint32_t);
uint32_t FindDmrid(const CCallsign &);
protected:
// thread
@ -79,17 +72,14 @@ protected:
protected:
// data
std::map <uint32, CCallsign> m_CallsignMap;
std::map <CCallsign, uint32, CDmridDirCallsignCompare> m_DmridMap;
std::map <uint32_t, CCallsign> m_CallsignMap;
std::map <CCallsign, uint32_t, CDmridDirCallsignCompare> m_DmridMap;
// Lock()
std::mutex m_Mutex;
std::mutex m_Mutex;
// thread
std::atomic<bool> keep_running;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include "Main.h"
@ -68,12 +62,12 @@ bool CDmridDirHttp::RefreshContent(const CBuffer &buffer)
if ( ((callsign = ::strtok(nullptr, ";")) != nullptr) )
{
// new entry
uint32 ui = atoi(dmrid);
uint32_t ui = atoi(dmrid);
CCallsign cs(callsign, ui);
if ( cs.IsValid() )
{
m_CallsignMap.insert(std::pair<uint32,CCallsign>(ui, cs));
m_DmridMap.insert(std::pair<CCallsign,uint32>(cs,ui));
m_CallsignMap.insert(std::pair<uint32_t,CCallsign>(ui, cs));
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);
if ( len > 0 )
{
buffer->Append((uint8 *)buf, (int)len);
buffer->Append((uint8_t *)buf, (int)len);
ok = true;
}
//}
@ -156,7 +150,7 @@ bool CDmridDirHttp::HttpGet(const char *hostname, const char *filename, int port
}
while (!done);
buffer->Append((uint8)0);
buffer->Append((uint8_t)0);
// and disconnect
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmriddirhttp_h
#define cdmriddirhttp_h
#pragma once
#include "DMRIdDir.h"
////////////////////////////////////////////////////////////////////////////////////////
class CDmridDirHttp : public CDmridDir
{
public:
@ -47,6 +38,3 @@ protected:
bool NeedReload(void) { return true; }
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DMMMDVMClient.h"
#include "DMRMMDVMClient.h"
////////////////////////////////////////////////////////////////////////////////////////
@ -48,5 +42,5 @@ CDmrmmdvmClient::CDmrmmdvmClient(const CDmrmmdvmClient &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmrmmdvmclient_h
#define cdmrmmdvmclient_h
#pragma once
#include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDmrmmdvmClient : public CClient
{
public:
@ -54,7 +40,3 @@ public:
// status
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include "DMMMDVMClient.h"
#include "DMMMDVMProtocol.h"
#include "DMRMMDVMClient.h"
#include "DMRMMDVMProtocol.h"
#include "Reflector.h"
#include "GateKeeper.h"
#include "CBPT19696.h"
#include "CBPTC19696.h"
#include "RS129.h"
#include "Golay2087.h"
#include "QR1676.h"
@ -45,16 +38,16 @@
////////////////////////////////////////////////////////////////////////////////////////
// constants
static uint8 g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8 g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8 g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
static uint8_t g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8_t g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8_t g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8_t g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
////////////////////////////////////////////////////////////////////////////////////////
// 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
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
time_t t;
::srand((unsigned) time(&t));
m_uiAuthSeed = (uint32)rand();
m_uiAuthSeed = (uint32_t)rand();
// done
return true;
@ -83,8 +76,8 @@ void CDmrmmdvmProtocol::Task(void)
CIp Ip;
CCallsign Callsign;
int iRssi;
uint8 Cmd;
uint8 CallType;
uint8_t Cmd;
uint8_t CallType;
std::unique_ptr<CDvHeaderPacket> Header;
std::unique_ptr<CDvLastFramePacket> LastFrame;
std::array<std::unique_ptr<CDvFramePacket>, 3> Frames;
@ -261,7 +254,7 @@ void CDmrmmdvmProtocol::Task(void)
////////////////////////////////////////////////////////////////////////////////////////
// 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;
@ -478,12 +471,12 @@ void CDmrmmdvmProtocol::HandleKeepalives(void)
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;
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->SetModule(MMDVM_MODULE_ID);
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)
{
uint8 tag[] = { 'R','P','T','L' };
uint8_t tag[] = { 'R','P','T','L' };
bool valid = false;
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->SetModule(MMDVM_MODULE_ID);
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)
{
uint8 tag[] = { 'R','P','T','K' };
uint8_t tag[] = { 'R','P','T','K' };
bool valid = false;
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->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid();
@ -532,12 +525,12 @@ bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCall
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;
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->SetModule(MMDVM_MODULE_ID);
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)
{
uint8 tag[] = { 'R','P','T','C' };
uint8_t tag[] = { 'R','P','T','C' };
bool valid = false;
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->SetModule(MMDVM_MODULE_ID);
valid = callsign->IsValid();
@ -567,12 +560,12 @@ bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *ca
bool CDmrmmdvmProtocol::IsValidOptionPacket(const CBuffer &Buffer, CCallsign *callsign)
{
uint8 tag[] = { 'R','P','T','O' };
uint8_t tag[] = { 'R','P','T','O' };
bool valid = false;
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->SetModule(MMDVM_MODULE_ID);
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)
{
uint8 tag[] = { 'R','P','T','I','N','T','R' };
uint8_t tag[] = { 'R','P','T','I','N','T','R' };
bool valid = false;
if ( (Buffer.size() == 17) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
@ -595,26 +588,26 @@ bool CDmrmmdvmProtocol::IsValidRssiPacket(const CBuffer &Buffer, CCallsign *call
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;
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{
// frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8 uiSlotType = Buffer.data()[15] & 0x0F;
uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8_t uiSlotType = Buffer.data()[15] & 0x0F;
//std::cout << (int)uiSlot << std::endl;
if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) &&
(uiSlotType == MMDVM_SLOTTYPE_HEADER) )
{
// extract sync
uint8 dmrsync[7];
uint8_t dmrsync[7];
dmrsync[0] = Buffer.data()[33] & 0x0F;
::memcpy(&dmrsync[1], &Buffer.data()[34], 5);
dmrsync[6] = Buffer.data()[39] & 0xF0;
@ -624,16 +617,16 @@ bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique
{
// get payload
//CBPTC19696 bptc;
//uint8 lcdata[12];
//uint8_t lcdata[12];
//bptc.decode(&(Buffer.data()[20]), lcdata);
// crack DMR header
//uint8 uiSeqId = Buffer.data()[4];
uint32 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 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]);
//uint8_t uiSeqId = Buffer.data()[4];
uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// call type
*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)
{
uint8 tag[] = { 'D','M','R','D' };
uint8_t tag[] = { 'D','M','R','D' };
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{
// frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
if ( ((uiFrameType == DMRMMDVM_FRAMETYPE_VOICE) || (uiFrameType == DMRMMDVM_FRAMETYPE_VOICESYNC)) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) )
{
// crack DMR header
//uint8 uiSeqId = Buffer.data()[4];
//uint32 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 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]);
//uint8_t uiSeqId = Buffer.data()[4];
//uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
//uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
//uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// crack payload
uint8 dmrframe[33];
uint8 dmr3ambe[27];
uint8 dmrambe[9];
uint8 dmrsync[7];
uint8_t dmrframe[33];
uint8_t dmr3ambe[27];
uint8_t dmrambe[9];
uint8_t dmrsync[7];
// get the 33 bytes ambe
memcpy(dmrframe, &(Buffer.data()[20]), 33);
// 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)
{
uint8 tag[] = { 'D','M','R','D' };
uint8_t tag[] = { 'D','M','R','D' };
if ( (Buffer.size() == 55) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{
// frame details
uint8 uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8 uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
//uint8 uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8 uiSlotType = Buffer.data()[15] & 0x0F;
uint8_t uiFrameType = (Buffer.data()[15] & 0x30) >> 4;
uint8_t uiSlot = (Buffer.data()[15] & 0x80) ? DMR_SLOT2 : DMR_SLOT1;
//uint8_t uiCallType = (Buffer.data()[15] & 0x40) ? DMR_PRIVATE_CALL : DMR_GROUP_CALL;
uint8_t uiSlotType = Buffer.data()[15] & 0x0F;
//std::cout << (int)uiSlot << std::endl;
if ( (uiFrameType == DMRMMDVM_FRAMETYPE_DATASYNC) &&
(uiSlot == DMRMMDVM_REFLECTOR_SLOT) &&
(uiSlotType == MMDVM_SLOTTYPE_TERMINATOR) )
{
// extract sync
uint8 dmrsync[7];
uint8_t dmrsync[7];
dmrsync[0] = Buffer.data()[33] & 0x0F;
::memcpy(&dmrsync[1], &Buffer.data()[34], 5);
dmrsync[6] = Buffer.data()[39] & 0xF0;
@ -760,19 +753,19 @@ bool CDmrmmdvmProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::uni
{
// get payload
//CBPTC19696 bptc;
//uint8 lcdata[12];
//uint8_t lcdata[12];
//bptc.decode(&(Buffer.data()[20]), lcdata);
// crack DMR header
//uint8 uiSeqId = Buffer.data()[4];
//uint32 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 uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8 uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32 uiStreamId = *(uint32 *)(&Buffer.data()[16]);
//uint8_t uiSeqId = Buffer.data()[4];
//uint32_t uiSrcId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],0));
//uint32_t uiDstId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],0));
//uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[14],Buffer.data()[13]),MAKEWORD(Buffer.data()[12],Buffer.data()[11]));
//uint8_t uiVoiceSeq = (Buffer.data()[15] & 0x0F);
uint32_t uiStreamId = *(uint32_t *)(&Buffer.data()[16]);
// dummy ambe
uint8 ambe[9];
uint8_t ambe[9];
::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)
{
uint8 tag[] = { 'M','S','T','P','O','N','G' };
uint8_t tag[] = { 'M','S','T','P','O','N','G' };
Buffer->Set(tag, sizeof(tag));
uint32 uiDmrId = Client->GetCallsign().GetDmrid();
Buffer->Append((uint8 *)&uiDmrId, 4);
uint32_t uiDmrId = Client->GetCallsign().GetDmrid();
Buffer->Append((uint8_t *)&uiDmrId, 4);
}
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));
}
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->Append(AuthSeed);
@ -815,55 +808,55 @@ void CDmrmmdvmProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const CCallsign
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));
}
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));
}
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));
// DMR header
// uiSeqId
Buffer->Append((uint8)seqid);
Buffer->Append((uint8_t)seqid);
// uiSrcId
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid();
uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId = TG9
uint32 uiDstId = 9; // ModuleToDmrDestId(Packet.GetRpt2Module());
uint32_t uiDstId = 9; // ModuleToDmrDestId(Packet.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId
uint32 uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
uint32_t uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField
uint8 uiBitField =
uint8_t uiBitField =
(DMRMMDVM_FRAMETYPE_DATASYNC << 4) |
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) |
MMDVM_SLOTTYPE_HEADER;
Buffer->Append((uint8)uiBitField);
Buffer->Append((uint8_t)uiBitField);
// uiStreamId
uint32 uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32)uiStreamId);
uint32_t uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32_t)uiStreamId);
// Payload
AppendVoiceLCToBuffer(Buffer, uiSrcId);
// BER
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
// RSSI
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
// done
return true;
@ -872,25 +865,25 @@ bool CDmrmmdvmProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, uint
void CDmrmmdvmProtocol::EncodeDvPacket(
const CDvHeaderPacket &Header,
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));
// DMR header
// uiSeqId
Buffer->Append((uint8)seqid);
Buffer->Append((uint8_t)seqid);
// uiSrcId
uint32 uiSrcId = Header.GetMyCallsign().GetDmrid();
uint32_t uiSrcId = Header.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId = TG9
uint32 uiDstId = 9; // ModuleToDmrDestId(Header.GetRpt2Module());
uint32_t uiDstId = 9; // ModuleToDmrDestId(Header.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId
uint32 uiRptrId = Header.GetRpt1Callsign().GetDmrid();
uint32_t uiRptrId = Header.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField
uint8 uiBitField =
uint8_t uiBitField =
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00);
if ( DvFrame0.GetDmrPacketId() == 0 )
{
@ -901,21 +894,21 @@ void CDmrmmdvmProtocol::EncodeDvPacket(
uiBitField |= (DMRMMDVM_FRAMETYPE_VOICE << 4);
}
uiBitField |= (DvFrame0.GetDmrPacketId() & 0x0F);
Buffer->Append((uint8)uiBitField);
Buffer->Append((uint8_t)uiBitField);
// uiStreamId
uint32 uiStreamId = Header.GetStreamId();
Buffer->Append((uint32)uiStreamId);
uint32_t uiStreamId = Header.GetStreamId();
Buffer->Append((uint32_t)uiStreamId);
// Payload
// frame0
Buffer->ReplaceAt(20, DvFrame0.GetAmbePlus(), 9);
// 1/2 frame1
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
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
Buffer->ReplaceAt(44, DvFrame2.GetAmbePlus(), 9);
@ -928,56 +921,56 @@ void CDmrmmdvmProtocol::EncodeDvPacket(
//dump.DebugDump(g_Reflector.m_DebugFile);
// BER
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
// 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));
// DMR header
// uiSeqId
Buffer->Append((uint8)seqid);
Buffer->Append((uint8_t)seqid);
// uiSrcId
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid();
uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid();
AppendDmrIdToBuffer(Buffer, uiSrcId);
// uiDstId
uint32 uiDstId = 9; //ModuleToDmrDestId(Packet.GetRpt2Module());
uint32_t uiDstId = 9; //ModuleToDmrDestId(Packet.GetRpt2Module());
AppendDmrIdToBuffer(Buffer, uiDstId);
// uiRptrId
uint32 uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
uint32_t uiRptrId = Packet.GetRpt1Callsign().GetDmrid();
AppendDmrRptrIdToBuffer(Buffer, uiRptrId);
// uiBitField
uint8 uiBitField =
uint8_t uiBitField =
(DMRMMDVM_FRAMETYPE_DATASYNC << 4) |
((DMRMMDVM_REFLECTOR_SLOT == DMR_SLOT2) ? 0x80 : 0x00) |
MMDVM_SLOTTYPE_TERMINATOR;
Buffer->Append((uint8)uiBitField);
Buffer->Append((uint8_t)uiBitField);
// uiStreamId
uint32 uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32)uiStreamId);
uint32_t uiStreamId = Packet.GetStreamId();
Buffer->Append((uint32_t)uiStreamId);
// Payload
AppendTerminatorLCToBuffer(Buffer, uiSrcId);
// BER
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
// RSSI
Buffer->Append((uint8)0);
Buffer->Append((uint8_t)0);
}
////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper
char CDmrmmdvmProtocol::DmrDstIdToModule(uint32 tg) const
char CDmrmmdvmProtocol::DmrDstIdToModule(uint32_t tg) const
{
// is it a 4xxx ?
if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) )
@ -987,33 +980,33 @@ char CDmrmmdvmProtocol::DmrDstIdToModule(uint32 tg) const
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
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
CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload));
// LC data
uint8 lc[12];
uint8_t lc[12];
{
::memset(lc, 0, sizeof(lc));
// uiDstId = TG9
lc[5] = 9;
// uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId));
lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity
uint8 parity[4];
uint8_t parity[4];
CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ 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
uint8 slottype[3];
uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
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));
}
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
CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload));
// LC data
uint8 lc[12];
uint8_t lc[12];
{
::memset(lc, 0, sizeof(lc));
// uiDstId = TG9
lc[5] = 9;
// uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId));
lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity
uint8 parity[4];
uint8_t parity[4];
CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ 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
uint8 slottype[3];
uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
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));
}
void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId) const
void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8_t uiDmrPacketId) const
{
// voice packet A ?
if ( uiDmrPacketId == 0 )
{
// 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(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 ?
else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) )
{
// EMB LC
uint8 emb[2];
uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06;
@ -1110,21 +1103,21 @@ void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode
CQR1676::encode(emb);
// and append
buffer->ReplaceAt(33, (uint8)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8)0);
buffer->ReplaceAt(36, (uint8)0);
buffer->ReplaceAt(37, (uint8)0);
buffer->ReplaceAt(38, (uint8)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
buffer->ReplaceAt(33, (uint8_t)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8_t)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8_t)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8_t)0);
buffer->ReplaceAt(36, (uint8_t)0);
buffer->ReplaceAt(37, (uint8_t)0);
buffer->ReplaceAt(38, (uint8_t)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8_t)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
}
// voice packet F
else
{
// nullptr
uint8 emb[2];
uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06;
@ -1132,29 +1125,29 @@ void CDmrmmdvmProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode
CQR1676::encode(emb);
// and append
buffer->ReplaceAt(33, (uint8)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8)0);
buffer->ReplaceAt(36, (uint8)0);
buffer->ReplaceAt(37, (uint8)0);
buffer->ReplaceAt(38, (uint8)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
buffer->ReplaceAt(33, (uint8_t)((buffer->at(33) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(34, (uint8_t)((buffer->at(34) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(34, (uint8_t)(buffer->at(34) & 0xF0));
buffer->ReplaceAt(35, (uint8_t)0);
buffer->ReplaceAt(36, (uint8_t)0);
buffer->ReplaceAt(37, (uint8_t)0);
buffer->ReplaceAt(38, (uint8_t)(buffer->at(38) & 0x0F));
buffer->ReplaceAt(38, (uint8_t)((buffer->at(38) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
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)HIBYTE(LOWORD(id)));
buffer->Append((uint8)LOBYTE(LOWORD(id)));
buffer->Append((uint8_t)LOBYTE(HIWORD(id)));
buffer->Append((uint8_t)HIBYTE(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)LOBYTE(HIWORD(id)));
buffer->Append((uint8)HIBYTE(LOWORD(id)));
buffer->Append((uint8)LOBYTE(LOWORD(id)));
buffer->Append((uint8_t)HIBYTE(HIWORD(id)));
buffer->Append((uint8_t)LOBYTE(HIWORD(id)));
buffer->Append((uint8_t)HIBYTE(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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmrmmdvmprotocol_h
#define cdmrmmdvmprotocol_h
#pragma once
#include "Timer.h"
#include "DCSProtocol.h"
@ -60,7 +52,7 @@ public:
CDvFramePacket m_dvFrame0;
CDvFramePacket m_dvFrame1;
uint8 m_uiSeqId;
uint8_t m_uiSeqId;
};
@ -68,7 +60,7 @@ class CDmrmmdvmProtocol : public CProtocol
{
public:
// 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
void Task(void);
@ -81,7 +73,7 @@ protected:
void HandleKeepalives(void);
// 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
bool IsValidConnectPacket(const CBuffer &, CCallsign *, const CIp &);
@ -91,30 +83,30 @@ protected:
bool IsValidOptionPacket(const CBuffer &, CCallsign *);
bool IsValidKeepAlivePacket(const CBuffer &, CCallsign *);
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 IsValidDvLastFramePacket(const CBuffer &, std::unique_ptr<CDvLastFramePacket> &);
// packet encoding helpers
void EncodeKeepAlivePacket(CBuffer *, std::shared_ptr<CClient>);
void EncodeAckPacket(CBuffer *, const CCallsign &);
void EncodeConnectAckPacket(CBuffer *, const CCallsign &, uint32);
void EncodeConnectAckPacket(CBuffer *, const CCallsign &, uint32_t);
void EncodeNackPacket(CBuffer *, const CCallsign &);
void EncodeClosePacket(CBuffer *, std::shared_ptr<CClient>);
bool EncodeDvHeaderPacket(const CDvHeaderPacket &, uint8, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, uint8, CBuffer *) const;
bool EncodeDvHeaderPacket(const CDvHeaderPacket &, uint8_t, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8_t, CBuffer *) const;
void EncodeDvLastPacket(const CDvHeaderPacket &, uint8_t, CBuffer *) const;
// dmr DstId to Module helper
char DmrDstIdToModule(uint32) const;
uint32 ModuleToDmrDestId(char) const;
char DmrDstIdToModule(uint32_t) const;
uint32_t ModuleToDmrDestId(char) const;
// Buffer & LC helpers
void AppendVoiceLCToBuffer(CBuffer *, uint32) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32) const;
void ReplaceEMBInBuffer(CBuffer *, uint8) const;
void AppendDmrIdToBuffer(CBuffer *, uint32) const;
void AppendDmrRptrIdToBuffer(CBuffer *, uint32) const;
void AppendVoiceLCToBuffer(CBuffer *, uint32_t) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32_t) const;
void ReplaceEMBInBuffer(CBuffer *, uint8_t) const;
void AppendDmrIdToBuffer(CBuffer *, uint32_t) const;
void AppendDmrRptrIdToBuffer(CBuffer *, uint32_t) const;
protected:
@ -122,15 +114,11 @@ protected:
CTimePoint m_LastKeepaliveTime;
// for stream id
uint16 m_uiStreamId;
uint16_t m_uiStreamId;
// for queue header caches
std::array<CDmrmmdvmStreamCacheItem, NB_OF_MODULES> m_StreamsCache;
// 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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "cdmrplusclient.h"
#include "DMRPlusClient.h"
////////////////////////////////////////////////////////////////////////////////////////
@ -48,5 +42,5 @@ CDmrplusClient::CDmrplusClient(const CDmrplusClient &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmrplusclient_h
#define cdmrplusclient_h
#pragma once
#include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDmrplusClient : public CClient
{
public:
@ -54,6 +40,3 @@ public:
// status
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include "cdmrplusclient.h"
#include "DMRPlusClient.h"
#include "DMRPlusProtocol.h"
#include "Reflector.h"
#include "GateKeeper.h"
#include "DMRIdDir.h"
#include "CBPT19696.h"
#include "CBPTC19696.h"
#include "RS129.h"
#include "Golay2087.h"
#include "QR1676.h"
@ -38,16 +31,16 @@
////////////////////////////////////////////////////////////////////////////////////////
// constants
static uint8 g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8 g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8 g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
static uint8_t g_DmrSyncBSVoice[] = { 0x07,0x55,0xFD,0x7D,0xF7,0x5F,0x70 };
static uint8_t g_DmrSyncBSData[] = { 0x0D,0xFF,0x57,0xD7,0x5D,0xF5,0xD0 };
static uint8_t g_DmrSyncMSVoice[] = { 0x07,0xF7,0xD5,0xDD,0x57,0xDF,0xD0 };
static uint8_t g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 };
////////////////////////////////////////////////////////////////////////////////////////
// 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
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
@ -303,7 +296,7 @@ void CDmrplusProtocol::HandleQueue(void)
m_Queue.Unlock();
}
void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8 module)
void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8_t module)
{
if ( buffer.size() > 0 )
{
@ -377,7 +370,7 @@ bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *ca
char sz[9];
::memcpy(sz, Buffer.data(), 8);
sz[8] = 0;
uint32 dmrid = atoi(sz);
uint32_t dmrid = atoi(sz);
callsign->SetDmrid(dmrid, true);
callsign->SetModule(DMRPLUS_MODULE_ID);
::memcpy(sz, &Buffer.data()[8], 4);
@ -400,7 +393,7 @@ bool CDmrplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
char sz[9];
::memcpy(sz, Buffer.data(), 8);
sz[8] = 0;
uint32 dmrid = atoi(sz);
uint32_t dmrid = atoi(sz);
callsign->SetDmrid(dmrid, true);
callsign->SetModule(DMRPLUS_MODULE_ID);
*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)
{
uint8 uiPacketType = Buffer.data()[8];
uint8_t uiPacketType = Buffer.data()[8];
if ( (Buffer.size() == 72) && ( uiPacketType == 2 ) )
{
// frame details
uint8 uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8 uiColourCode = Buffer.data()[20] & 0x0F;
uint8_t uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8_t uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8_t uiColourCode = Buffer.data()[20] & 0x0F;
if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) )
{
// more frames details
//uint8 uiSeqId = Buffer.data()[4];
//uint8 uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
uint32 uiDstId = *(uint32 *)(&Buffer.data()[64]) & 0x00FFFFFF;
uint32 uiSrcId = *(uint32 *)(&Buffer.data()[68]) & 0x00FFFFFF;
//uint8_t uiSeqId = Buffer.data()[4];
//uint8_t uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
uint32_t uiDstId = *(uint32_t *)(&Buffer.data()[64]) & 0x00FFFFFF;
uint32_t uiSrcId = *(uint32_t *)(&Buffer.data()[68]) & 0x00FFFFFF;
// build DVHeader
CCallsign csMY = CCallsign("", uiSrcId);
@ -432,7 +425,7 @@ bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffe
rpt1.SetModule(DMRPLUS_MODULE_ID);
CCallsign rpt2 = m_ReflectorCallsign;
rpt2.SetModule(DmrDstIdToModule(uiDstId));
uint32 uiStreamId = IpToStreamId(Ip);
uint32_t uiStreamId = IpToStreamId(Ip);
// and packet
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)
{
uint8 uiPacketType = Buffer.data()[8];
uint8_t uiPacketType = Buffer.data()[8];
if ( (Buffer.size() == 72) && ((uiPacketType == 1) || (uiPacketType == 3)) )
{
// frame details
uint8 uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8 uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8 uiColourCode = Buffer.data()[20] & 0x0F;
uint8_t uiSlot = (Buffer.data()[16] == 0x22) ? DMR_SLOT2 : DMR_SLOT1;
uint8_t uiCallType = (Buffer.data()[62] == 1) ? DMR_GROUP_CALL : DMR_PRIVATE_CALL;
uint8_t uiColourCode = Buffer.data()[20] & 0x0F;
if ( (uiSlot == DMRPLUS_REFLECTOR_SLOT) && (uiCallType == DMR_GROUP_CALL) && (uiColourCode == DMRPLUS_REFLECTOR_COLOUR) )
{
// more frames details
//uint8 uiSeqId = Buffer.data()[4];
uint8 uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
//uint32 uiDstId = *(uint32 *)(&Buffer.data()[64]) & 0x00FFFFFF;
//uint32 uiSrcId = *(uint32 *)(&Buffer.data()[68]) & 0x00FFFFFF;
//uint8_t uiSeqId = Buffer.data()[4];
uint8_t uiVoiceSeq = (Buffer.data()[18] & 0x0F) - 7; // aka slot type
//uint32_t uiDstId = *(uint32_t *)(&Buffer.data()[64]) & 0x00FFFFFF;
//uint32_t uiSrcId = *(uint32_t *)(&Buffer.data()[68]) & 0x00FFFFFF;
// crack payload
uint8 dmrframe[33];
uint8 dmr3ambe[27];
uint8 dmrambe[9];
uint8 dmrsync[7];
uint8_t dmrframe[33];
uint8_t dmr3ambe[27];
uint8_t dmrambe[9];
uint8_t dmrsync[7];
// get the 33 bytes ambe
memcpy(dmrframe, &(Buffer.data()[26]), 33);
// handle endianess
@ -480,7 +473,7 @@ bool CDmrplusProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer
dmrsync[6] = dmrframe[19] & 0xF0;
// and create 3 dv frames
uint32 uiStreamId = IpToStreamId(Ip);
uint32_t uiStreamId = IpToStreamId(Ip);
// frame1
memcpy(dmrambe, &dmr3ambe[0], 9);
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)
{
uint8 tag[] = { 'A','C','K',' ','O','K',0x0A,0x00 };
uint8_t tag[] = { 'A','C','K',' ','O','K',0x0A,0x00 };
Buffer->Set(tag, sizeof(tag));
}
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));
}
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
} ;
Buffer->Set(tag, sizeof(tag));
@ -536,32 +529,32 @@ bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuff
// uiPktType
//Buffer->ReplaceAt(8, 2);
// uiSlot
Buffer->Append((uint16)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
Buffer->Append((uint16_t)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
// uiSlotType
Buffer->Append((uint16)0xEEEE);
Buffer->Append((uint16_t)0xEEEE);
// uiColourCode
uint8 uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8)uiColourCode);
Buffer->Append((uint8)uiColourCode);
uint8_t uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8_t)uiColourCode);
Buffer->Append((uint8_t)uiColourCode);
// uiFrameType
Buffer->Append((uint16)0x1111);
Buffer->Append((uint16_t)0x1111);
// reserved
Buffer->Append((uint16)0x0000);
Buffer->Append((uint16_t)0x0000);
// payload
uint32 uiSrcId = Packet.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32 uiDstId = ModuleToDmrDestId(Packet.GetRpt2Module()) & 0x00FFFFFF;
Buffer->Append((uint8)0x00, 34);
uint32_t uiSrcId = Packet.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32_t uiDstId = ModuleToDmrDestId(Packet.GetRpt2Module()) & 0x00FFFFFF;
Buffer->Append((uint8_t)0x00, 34);
Buffer->ReplaceAt(36, HIBYTE(HIWORD(uiSrcId)));
Buffer->ReplaceAt(38, LOBYTE(HIWORD(uiSrcId)));
Buffer->ReplaceAt(40, HIBYTE(LOWORD(uiSrcId)));
Buffer->ReplaceAt(42, LOBYTE(LOWORD(uiSrcId)));
// reserved
Buffer->Append((uint16)0x0000);
Buffer->Append((uint16_t)0x0000);
// uiCallType
Buffer->Append((uint8)0x01);
Buffer->Append((uint8_t)0x01);
// reserved
Buffer->Append((uint8)0x00);
Buffer->Append((uint8_t)0x00);
// uiDstId
Buffer->Append(uiDstId);
// uiSrcId
@ -574,10 +567,10 @@ bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuff
void CDmrplusProtocol::EncodeDvPacket
(const CDvHeaderPacket &Header,
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
} ;
Buffer->Set(tag, sizeof(tag));
@ -587,31 +580,31 @@ void CDmrplusProtocol::EncodeDvPacket
// uiPktType
//Buffer->ReplaceAt(8, 1);
// uiSlot
Buffer->Append((uint16)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
Buffer->Append((uint16_t)((DMRPLUS_REFLECTOR_SLOT == DMR_SLOT1) ? 0x1111 : 0x2222));
// uiVoiceSeq
uint8 uiVoiceSeq = (DvFrame0.GetDmrPacketId() + 7) | ((DvFrame0.GetDmrPacketId() + 7) << 4);
Buffer->Append((uint8)uiVoiceSeq);
Buffer->Append((uint8)uiVoiceSeq);
uint8_t uiVoiceSeq = (DvFrame0.GetDmrPacketId() + 7) | ((DvFrame0.GetDmrPacketId() + 7) << 4);
Buffer->Append((uint8_t)uiVoiceSeq);
Buffer->Append((uint8_t)uiVoiceSeq);
// uiColourCode
uint8 uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8)uiColourCode);
Buffer->Append((uint8)uiColourCode);
uint8_t uiColourCode = DMRPLUS_REFLECTOR_COLOUR | (DMRPLUS_REFLECTOR_COLOUR << 4);
Buffer->Append((uint8_t)uiColourCode);
Buffer->Append((uint8_t)uiColourCode);
// uiFrameType
Buffer->Append((uint16)0x1111);
Buffer->Append((uint16_t)0x1111);
// reserved
Buffer->Append((uint16)0x0000);
Buffer->Append((uint16_t)0x0000);
// payload
uint32 uiSrcId = Header.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32 uiDstId = ModuleToDmrDestId(Header.GetRpt2Module()) & 0x00FFFFFF;
uint32_t uiSrcId = Header.GetMyCallsign().GetDmrid() & 0x00FFFFFF;
uint32_t uiDstId = ModuleToDmrDestId(Header.GetRpt2Module()) & 0x00FFFFFF;
// frame0
Buffer->ReplaceAt(26, DvFrame0.GetAmbePlus(), 9);
// 1/2 frame1
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
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
Buffer->ReplaceAt(50, DvFrame2.GetAmbePlus(), 9);
@ -619,12 +612,12 @@ void CDmrplusProtocol::EncodeDvPacket
ReplaceEMBInBuffer(Buffer, DvFrame0.GetDmrPacketId());
// reserved
Buffer->Append((uint16)0x0000);
Buffer->Append((uint8)0x00);
Buffer->Append((uint16_t)0x0000);
Buffer->Append((uint8_t)0x00);
// uiCallType
Buffer->Append((uint8)0x01);
Buffer->Append((uint8_t)0x01);
// reserved
Buffer->Append((uint8)0x00);
Buffer->Append((uint8_t)0x00);
// uiDstId
Buffer->Append(uiDstId);
// uiSrcId
@ -634,11 +627,11 @@ void CDmrplusProtocol::EncodeDvPacket
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 )
{
uint8 t = buffer[i];
uint8_t t = buffer[i];
buffer[i] = buffer[i+1];
buffer[i+1] = t;
}
@ -648,7 +641,7 @@ void CDmrplusProtocol::SwapEndianess(uint8 *buffer, int len) const
////////////////////////////////////////////////////////////////////////////////////////
// SeqId helper
uint8 CDmrplusProtocol::GetNextSeqId(uint8 uiSeqId) const
uint8_t CDmrplusProtocol::GetNextSeqId(uint8_t uiSeqId) const
{
return (uiSeqId + 1) & 0xFF;
}
@ -656,7 +649,7 @@ uint8 CDmrplusProtocol::GetNextSeqId(uint8 uiSeqId) const
////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper
char CDmrplusProtocol::DmrDstIdToModule(uint32 tg) const
char CDmrplusProtocol::DmrDstIdToModule(uint32_t tg) const
{
// is it a 4xxx ?
if ( (tg >= 4001) && (tg <= (4000 + NB_OF_MODULES)) )
@ -666,33 +659,33 @@ char CDmrplusProtocol::DmrDstIdToModule(uint32 tg) const
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
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
CBPTC19696 bptc;
::memset(payload, 0, sizeof(payload));
// LC data
uint8 lc[12];
uint8_t lc[12];
{
::memset(lc, 0, sizeof(lc));
// uiDstId = TG9
lc[5] = 9;
// uiSrcId
lc[6] = (uint8)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8)LOBYTE(LOWORD(uiSrcId));
lc[6] = (uint8_t)LOBYTE(HIWORD(uiSrcId));
lc[7] = (uint8_t)HIBYTE(LOWORD(uiSrcId));
lc[8] = (uint8_t)LOBYTE(LOWORD(uiSrcId));
// parity
uint8 parity[4];
uint8_t parity[4];
CRS129::encode(lc, 9, parity);
lc[9] = parity[2] ^ 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
uint8 slottype[3];
uint8_t slottype[3];
::memset(slottype, 0, sizeof(slottype));
slottype[0] = (DMRPLUS_REFLECTOR_COLOUR << 4) & 0xF0;
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));
}
void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId) const
void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8_t uiDmrPacketId) const
{
// voice packet A ?
if ( uiDmrPacketId == 0 )
{
// 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(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 ?
else if ( (uiDmrPacketId >= 1) && (uiDmrPacketId <= 4 ) )
{
// EMB LC
uint8 emb[2];
uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06;
@ -743,21 +736,21 @@ void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode
CQR1676::encode(emb);
// and append
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8)0);
buffer->ReplaceAt(42, (uint8)0);
buffer->ReplaceAt(43, (uint8)0);
buffer->ReplaceAt(44, (uint8)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(45, (uint8)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8_t)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8_t)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8_t)0);
buffer->ReplaceAt(42, (uint8_t)0);
buffer->ReplaceAt(43, (uint8_t)0);
buffer->ReplaceAt(44, (uint8_t)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8_t)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(45, (uint8_t)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
}
// voice packet F
else
{
// nullptr
uint8 emb[2];
uint8_t emb[2];
emb[0] = (DMRMMDVM_REFLECTOR_COLOUR << 4) & 0xF0;
//emb[0] |= PI ? 0x08U : 0x00;
//emb[0] |= (LCSS << 1) & 0x06;
@ -765,15 +758,15 @@ void CDmrplusProtocol::ReplaceEMBInBuffer(CBuffer *buffer, uint8 uiDmrPacketId)
// encode
CQR1676::encode(emb);
// and append
buffer->ReplaceAt(39, (uint8)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8)0);
buffer->ReplaceAt(42, (uint8)0);
buffer->ReplaceAt(43, (uint8)0);
buffer->ReplaceAt(44, (uint8)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
buffer->ReplaceAt(45, (uint8)((buffer->at(45) & 0x0F) | ((emb[1U] << 4) & 0xF0)));
buffer->ReplaceAt(39, (uint8_t)((buffer->at(39) & 0xF0) | ((emb[0U] >> 4) & 0x0F)));
buffer->ReplaceAt(40, (uint8_t)((buffer->at(40) & 0x0F) | ((emb[0U] << 4) & 0xF0)));
buffer->ReplaceAt(40, (uint8_t)(buffer->at(40) & 0xF0));
buffer->ReplaceAt(41, (uint8_t)0);
buffer->ReplaceAt(42, (uint8_t)0);
buffer->ReplaceAt(43, (uint8_t)0);
buffer->ReplaceAt(44, (uint8_t)(buffer->at(44) & 0x0F));
buffer->ReplaceAt(44, (uint8_t)((buffer->at(44) & 0xF0) | ((emb[1U] >> 4) & 0x0F)));
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
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdmrplusprotocol_h
#define cdmrplusprotocol_h
#pragma once
#include "Timer.h"
#include "DCSProtocol.h"
@ -49,7 +42,7 @@ public:
CDvFramePacket m_dvFrame0;
CDvFramePacket m_dvFrame1;
uint8 m_uiSeqId;
uint8_t m_uiSeqId;
};
@ -57,7 +50,7 @@ class CDmrplusProtocol : public CProtocol
{
public:
// 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
void Task(void);
@ -65,7 +58,7 @@ public:
protected:
// queue helper
void HandleQueue(void);
void SendBufferToClients(const CBuffer &, uint8);
void SendBufferToClients(const CBuffer &, uint8_t);
// keepalive helpers
void HandleKeepalives(void);
@ -83,23 +76,23 @@ protected:
void EncodeConnectAckPacket(CBuffer *);
void EncodeConnectNackPacket(CBuffer *);
bool EncodeDvHeaderPacket(const CDvHeaderPacket &, CBuffer *) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8, CBuffer *) const;
void SwapEndianess(uint8 *, int) const;
void EncodeDvPacket(const CDvHeaderPacket &, const CDvFramePacket &, const CDvFramePacket &, const CDvFramePacket &, uint8_t, CBuffer *) const;
void SwapEndianess(uint8_t *, int) const;
// dmr SeqId helper
uint8 GetNextSeqId(uint8) const;
uint8_t GetNextSeqId(uint8_t) const;
// dmr DstId to Module helper
char DmrDstIdToModule(uint32) const;
uint32 ModuleToDmrDestId(char) const;
char DmrDstIdToModule(uint32_t) const;
uint32_t ModuleToDmrDestId(char) const;
// uiStreamId helpers
uint32 IpToStreamId(const CIp &) const;
uint32_t IpToStreamId(const CIp &) const;
// Buffer & LC helpers
void AppendVoiceLCToBuffer(CBuffer *, uint32) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32) const;
void ReplaceEMBInBuffer(CBuffer *, uint8) const;
void AppendVoiceLCToBuffer(CBuffer *, uint32_t) const;
void AppendTerminatorLCToBuffer(CBuffer *, uint32_t) const;
void ReplaceEMBInBuffer(CBuffer *, uint8_t) const;
protected:
@ -109,8 +102,3 @@ protected:
// for queue header caches
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DPlusClient.h"
@ -51,7 +45,7 @@ CDplusClient::CDplusClient(const CDplusClient &client)
bool CDplusClient::IsAlive(void) const
{
return (m_LastKeepaliveTime.DurationSinceNow() < DPLUS_KEEPALIVE_TIMEOUT);
return (m_LastKeepaliveTime.time() < DPLUS_KEEPALIVE_TIMEOUT);
}
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdplusclient_h
#define cdplusclient_h
#pragma once
#include "cclient.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
#include "Client.h"
class CDplusClient : public CClient
{
@ -61,6 +47,3 @@ protected:
// data
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -34,14 +27,14 @@
////////////////////////////////////////////////////////////////////////////////////////
// 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
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
return false;
// update time
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
// done
return true;
@ -166,13 +159,13 @@ void CDplusProtocol::Task(void)
HandleQueue();
// keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > DPLUS_KEEPALIVE_PERIOD )
if ( m_LastKeepaliveTime.time() > DPLUS_KEEPALIVE_PERIOD )
{
//
HandleKeepalives();
// 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
CDvHeaderPacket packet2(*((CDvHeaderPacket *)packet));
CCallsign rpt2 = packet2.GetRpt2Callsign();
rpt2.PatchCallsign(0, (const uint8 *)"XRF", 3);
rpt2.PatchCallsign(0, (const uint8_t *)"XRF", 3);
packet2.SetRpt2Callsign(rpt2);
// encode it
@ -392,13 +385,13 @@ void CDplusProtocol::HandleKeepalives(void)
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)));
}
bool CDplusProtocol::IsValidLoginPacket(const CBuffer &Buffer, CCallsign *Callsign)
{
uint8 Tag[] = { 0x1C,0xC0,0x04,0x00 };
uint8_t Tag[] = { 0x1C,0xC0,0x04,0x00 };
bool valid = false;
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)
{
uint8 tag[] = { 0x05,0x00,0x18,0x00,0x00 };
uint8_t tag[] = { 0x05,0x00,0x18,0x00,0x00 };
return (Buffer == CBuffer(tag, sizeof(tag)));
}
bool CDplusProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer)
{
uint8 tag[] = { 0x03,0x60,0x00 };
uint8_t tag[] = { 0x03,0x60,0x00 };
return (Buffer == CBuffer(tag, sizeof(tag)));
}
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
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
if ( header && header->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
return true;
@ -466,53 +459,53 @@ bool CDplusProtocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique
void CDplusProtocol::EncodeKeepAlivePacket(CBuffer *Buffer)
{
uint8 tag[] = { 0x03,0x60,0x00 };
uint8_t tag[] = { 0x03,0x60,0x00 };
Buffer->Set(tag, sizeof(tag));
}
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));
}
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));
}
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));
}
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;
Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header));
Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true;
}
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->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true;
@ -520,12 +513,12 @@ bool CDplusProtocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *
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 tag2[] = { 0x55,0xC8,0x7A,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x25,0x1A,0xC6 };
uint8_t tag1[] = { 0x20,0x80,0x44,0x53,0x56,0x54,0x20,0x00,0x81,0x00,0x20,0x00,0x01,0x02 };
uint8_t tag2[] = { 0x55,0xC8,0x7A,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2));
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdplusprotocol_h
#define cdplusprotocol_h
#pragma once
#include "Timer.h"
#include "Protocol.h"
@ -31,12 +24,6 @@
#include "DVFramePacket.h"
#include "DVLastFramePacket.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDplusClient;
class CDPlusStreamCacheItem
@ -45,14 +32,14 @@ public:
CDPlusStreamCacheItem() { m_iSeqCounter = 0; }
CDvHeaderPacket m_dvHeader;
uint8 m_iSeqCounter;
uint8_t m_iSeqCounter;
};
class CDplusProtocol : public CProtocol
{
public:
// 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
void Task(void);
@ -89,11 +76,8 @@ protected:
protected:
// for keep alive
CTimePoint m_LastKeepaliveTime;
CTimer m_LastKeepaliveTime;
// for queue header caches
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include "Main.h"
#include "DVFramePacket.h"
@ -43,7 +36,7 @@ CDvFramePacket::CDvFramePacket()
// 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)
{
::memcpy(m_uiAmbe, dvframe->AMBE, sizeof(m_uiAmbe));
@ -57,7 +50,7 @@ CDvFramePacket::CDvFramePacket(const struct dstar_dvframe *dvframe, uint16 sid,
#ifndef NO_XLX
// 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)
{
::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus));
@ -68,7 +61,7 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid,
// 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)
{
::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus));
@ -80,9 +73,9 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 s
// xlx constructor
CDvFramePacket::CDvFramePacket
(uint16 sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync)
(uint16_t sid,
uint8_t dstarpid, const uint8_t *dstarambe, const uint8_t *dstardvdata,
uint8_t dmrpid, uint8_t dprspid, const uint8_t *dmrambe, const uint8_t *dmrsync)
: CPacket(sid, dstarpid, dmrpid, dprspid, 0xFF, 0xFF, 0xFF)
{
::memcpy(m_uiAmbe, dstarambe, sizeof(m_uiAmbe));
@ -103,7 +96,7 @@ std::unique_ptr<CPacket> CDvFramePacket::Duplicate(void) const
////////////////////////////////////////////////////////////////////////////////////////
// get
const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const
const uint8_t *CDvFramePacket::GetAmbe(uint8_t uiCodec) const
{
switch (uiCodec)
{
@ -121,12 +114,12 @@ const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const
////////////////////////////////////////////////////////////////////////////////////////
// set
void CDvFramePacket::SetDvData(uint8 *DvData)
void CDvFramePacket::SetDvData(uint8_t *DvData)
{
::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)
{

@ -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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdvframepacket_h
#define cdvframepacket_h
#pragma once
#include "Packet.h"
@ -40,8 +33,8 @@
struct __attribute__ ((__packed__))dstar_dvframe
{
uint8 AMBE[AMBE_SIZE];
uint8 DVDATA[DVDATA_SIZE];
uint8_t AMBE[AMBE_SIZE];
uint8_t DVDATA[DVDATA_SIZE];
};
////////////////////////////////////////////////////////////////////////////////////////
@ -53,11 +46,11 @@ class CDvFramePacket : public CPacket
public:
// constructor
CDvFramePacket();
CDvFramePacket(const struct dstar_dvframe *, uint16, uint8);
CDvFramePacket(const struct dstar_dvframe *, uint16_t, uint8_t);
#ifndef NO_XLX
CDvFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8);
CDvFramePacket(const uint8 *, uint16, uint8, uint8, uint8);
CDvFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *);
CDvFramePacket(const uint8_t *, const uint8_t *, uint16_t, uint8_t, uint8_t);
CDvFramePacket(const uint8_t *, uint16_t, uint8_t, uint8_t, uint8_t);
CDvFramePacket(uint16_t, uint8_t, const uint8_t *, const uint8_t *, uint8_t, uint8_t, const uint8_t *, const uint8_t *);
#endif
// virtual duplication
@ -70,39 +63,35 @@ public:
#endif
// get
const uint8 *GetAmbe(uint8) const;
const uint8 *GetAmbe(void) const { return m_uiAmbe; }
const uint8_t *GetAmbe(uint8_t) const;
const uint8_t *GetAmbe(void) const { return m_uiAmbe; }
#ifndef NO_XLX
const uint8 *GetAmbePlus(void) const { return m_uiAmbePlus; }
const uint8 *GetDvSync(void) const { return m_uiDvSync; }
const uint8_t *GetAmbePlus(void) const { return m_uiAmbePlus; }
const uint8_t *GetDvSync(void) const { return m_uiDvSync; }
#endif
const uint8 *GetDvData(void) const { return m_uiDvData; }
const uint8_t *GetDvData(void) const { return m_uiDvData; }
// set
void SetDvData(uint8 *);
void SetAmbe(uint8, uint8 *);
void SetDvData(uint8_t *);
void SetAmbe(uint8_t, uint8_t *);
// operators
bool operator ==(const CDvFramePacket &) const;
protected:
// get
uint8 *GetAmbeData(void) { return m_uiAmbe; }
uint8_t *GetAmbeData(void) { return m_uiAmbe; }
#ifndef NO_XLX
uint8 *GetAmbePlusData(void) { return m_uiAmbePlus; }
uint8_t *GetAmbePlusData(void) { return m_uiAmbePlus; }
#endif
protected:
// data (dstar)
uint8 m_uiAmbe[AMBE_SIZE];
uint8 m_uiDvData[DVDATA_SIZE];
uint8_t m_uiAmbe[AMBE_SIZE];
uint8_t m_uiDvData[DVDATA_SIZE];
#ifndef NO_XLX
// data (dmr)
uint8 m_uiAmbePlus[AMBEPLUS_SIZE];
uint8 m_uiDvSync[DVSYNC_SIZE];
uint8_t m_uiAmbePlus[AMBEPLUS_SIZE];
uint8_t m_uiDvSync[DVSYNC_SIZE];
#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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -41,7 +35,7 @@ CDvHeaderPacket::CDvHeaderPacket()
// 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)
{
m_uiFlag1 = buffer->Flag1;
@ -58,7 +52,7 @@ CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16 sid,
#ifndef NO_XLX
// 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)
{
m_uiFlag1 = 0;
@ -73,7 +67,7 @@ CDvHeaderPacket::CDvHeaderPacket(uint32 my, const CCallsign &ur, const CCallsign
// 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)
{
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cdvheaderpacket_h
#define cdvheaderpacket_h
#pragma once
#include "Callsign.h"
#include "Packet.h"
@ -39,17 +32,17 @@
struct __attribute__ ((__packed__))dstar_header
{
// flags
uint8 Flag1;
uint8 Flag2;
uint8 Flag3;
uint8_t Flag1;
uint8_t Flag2;
uint8_t Flag3;
// callsigns
uint8 RPT2[CALLSIGN_LEN];
uint8 RPT1[CALLSIGN_LEN];
uint8 UR[CALLSIGN_LEN];
uint8 MY[CALLSIGN_LEN];
uint8 SUFFIX[CALLSUFFIX_LEN];
uint8_t RPT2[CALLSIGN_LEN];
uint8_t RPT1[CALLSIGN_LEN];
uint8_t UR[CALLSIGN_LEN];
uint8_t MY[CALLSIGN_LEN];
uint8_t SUFFIX[CALLSUFFIX_LEN];
// crc
uint16 Crc;
uint16_t Crc;
};
@ -61,10 +54,10 @@ class CDvHeaderPacket : public CPacket
public:
// constructor
CDvHeaderPacket();
CDvHeaderPacket(const struct dstar_header *, uint16, uint8);
CDvHeaderPacket(const struct dstar_header *, uint16_t, uint8_t);
#ifndef NO_XLX
CDvHeaderPacket(uint32, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8, uint8);
CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8);
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_t, uint8_t);
#endif
// virtual duplication
@ -103,19 +96,16 @@ public:
protected:
// data
uint8 m_uiFlag1;
uint8 m_uiFlag2;
uint8 m_uiFlag3;
uint8_t m_uiFlag1;
uint8_t m_uiFlag2;
uint8_t m_uiFlag3;
CCallsign m_csUR;
CCallsign m_csRPT1;
CCallsign m_csRPT2;
CCallsign m_csMY;
uint16 m_uiCrc;
uint16_t m_uiCrc;
#ifdef IMPLEMENT_CDVHEADERPACKET_CONST_CHAR_OPERATOR
// buffer
char m_sz[256];
#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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DVLastFramePacket.h"
@ -35,7 +29,7 @@ CDvLastFramePacket::CDvLastFramePacket()
// 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)
{
}
@ -43,7 +37,7 @@ CDvLastFramePacket::CDvLastFramePacket(const struct dstar_dvframe *DvFrame, uint
#ifndef NO_XLX
// dmr constructor
CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid, uint8 pid, uint8 spid)
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)
{
}
@ -51,16 +45,16 @@ CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uin
// dstar + dmr constructor
CDvLastFramePacket::CDvLastFramePacket
(uint16 sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync)
(uint16_t sid,
uint8_t dstarpid, const uint8_t *dstarambe, const uint8_t *dstardvdata,
uint8_t dmrpid, uint8_t dprspid, const uint8_t *dmrambe, const uint8_t *dmrsync)
: CDvFramePacket(sid, dstarpid, dstarambe, dstardvdata, dmrpid, dprspid, dmrambe, dmrsync)
{
}
// 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)
{
}

@ -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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cdvlastframepacket_h
#define cdvlastframepacket_h
// 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 "DVFramePacket.h"
////////////////////////////////////////////////////////////////////////////////////////
// defines
////////////////////////////////////////////////////////////////////////////////////////
// class
class CDvLastFramePacket : public CDvFramePacket
{
public:
// constructor
CDvLastFramePacket();
CDvLastFramePacket(const struct dstar_dvframe *, uint16, uint8);
CDvLastFramePacket(const struct dstar_dvframe *, uint16_t, uint8_t);
#ifndef NO_XLX
CDvLastFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8);
CDvLastFramePacket(const uint8 *, uint16, uint8, uint8, uint8);
CDvLastFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *);
CDvLastFramePacket(const uint8_t *, const uint8_t *, uint16_t, uint8_t, uint8_t);
CDvLastFramePacket(const uint8_t *, uint16_t, uint8_t, uint8_t, uint8_t);
CDvLastFramePacket(uint16_t, uint8_t, const uint8_t *, const uint8_t *, uint8_t, uint8_t, const uint8_t *, const uint8_t *);
#endif
CDvLastFramePacket(const CDvLastFramePacket &);
@ -55,7 +40,3 @@ public:
bool IsLastPacket(void) const { return true; }
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "G3Client.h"
@ -49,5 +43,5 @@ CG3Client::CG3Client(const CG3Client &client)
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cg3client_h
#define cg3client_h
#pragma once
#include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CG3Client : public CClient
{
public:
@ -57,6 +43,3 @@ public:
protected:
// 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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -38,7 +31,7 @@
////////////////////////////////////////////////////////////////////////////////////////
// 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
{
ReadOptions();
@ -50,7 +43,7 @@ bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uin
keep_running = true;
// update the reflector callsign
//m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)"XLX", 3);
//m_ReflectorCallsign.PatchCallsign(0, (const uint8_t *)"XLX", 3);
// create our sockets
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);
// update time
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
std::cout << "Initialized G3 Protocol, all threads started" << std::endl;
return true;
@ -178,7 +171,7 @@ void CG3Protocol::PresenceTask(void)
if (m_GwAddress == 0)
{
Buffer.Append(*(uint32 *)m_ConfigSocket.GetLocalAddr());
Buffer.Append(*(uint32_t *)m_ConfigSocket.GetLocalAddr());
}
else
{
@ -295,24 +288,24 @@ void CG3Protocol::ConfigTask(void)
// UR
Buffer.resize(8);
Buffer.Append((uint8 *)(const char *)Call, CALLSIGN_LEN - 1);
Buffer.Append((uint8)module);
Buffer.Append((uint8_t *)(const char *)Call, CALLSIGN_LEN - 1);
Buffer.Append((uint8_t)module);
// RPT1
Buffer.Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
Buffer.Append((uint8)'G');
Buffer.Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
Buffer.Append((uint8_t)'G');
// RPT2
Buffer.Append((uint8 *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
Buffer.Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN - 1);
if (isRepeaterCall)
{
Buffer.Append((uint8)Call.GetModule());
Buffer.Append((uint8_t)Call.GetModule());
}
else
{
// routed - no module for now
Buffer.Append((uint8)' ');
Buffer.Append((uint8_t)' ');
}
if (Buffer.data()[3] == 0x00)
@ -321,7 +314,7 @@ void CG3Protocol::ConfigTask(void)
if (m_GwAddress == 0)
{
Buffer.Append(*(uint32 *)m_ConfigSocket.GetLocalAddr());
Buffer.Append(*(uint32_t *)m_ConfigSocket.GetLocalAddr());
}
else
{
@ -399,7 +392,7 @@ void CG3Protocol::Task(void)
client->Alive();
// supress host checks - no ping needed to trigger potential ICMPs
// the regular data flow will do it
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
break;
}
}
@ -435,13 +428,13 @@ void CG3Protocol::Task(void)
HandleQueue();
// keep alive during idle if needed
if ( m_LastKeepaliveTime.DurationSinceNow() > G3_KEEPALIVE_PERIOD )
if ( m_LastKeepaliveTime.time() > G3_KEEPALIVE_PERIOD )
{
// handle keep alives
HandleKeepalives();
// update time
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
// reload option if needed - called once every G3_KEEPALIVE_PERIOD
NeedReload();
@ -457,7 +450,7 @@ void CG3Protocol::HandleQueue(void)
while ( !m_Queue.empty() )
{
// supress host checks
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
// get the packet
auto packet = m_Queue.front();
@ -498,7 +491,7 @@ void CG3Protocol::HandleKeepalives(void)
// G3 Terminal mode does not support keepalive
// We will send some short packed and expect
// A ICMP unreachable on failure
CBuffer keepalive((uint8 *)"PING", 4);
CBuffer keepalive((uint8_t *)"PING", 4);
// iterate on clients
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)
{
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
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
if ( header && header->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
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)
{
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
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
if ( dvframe && dvframe->IsValid() )
return true;
@ -641,28 +634,28 @@ bool CG3Protocol::IsValidDvLastFramePacket(const CBuffer &Buffer, std::unique_pt
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;
Packet.ConvertToDstarStruct(&DstarHeader);
Buffer->Set(tag, sizeof(tag));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)0x80);
Buffer->Append((uint8 *)&DstarHeader, sizeof(struct dstar_header));
Buffer->Append((uint8_t)0x80);
Buffer->Append((uint8_t *)&DstarHeader, sizeof(struct dstar_header));
return true;
}
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->Append(Packet.GetStreamId());
Buffer->Append((uint8)(Packet.GetPacketId() % 21));
Buffer->Append((uint8 *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8 *)Packet.GetDvData(), DVDATA_SIZE);
Buffer->Append((uint8_t)(Packet.GetPacketId() % 21));
Buffer->Append((uint8_t *)Packet.GetAmbe(), AMBE_SIZE);
Buffer->Append((uint8_t *)Packet.GetDvData(), DVDATA_SIZE);
return true;
@ -670,12 +663,12 @@ bool CG3Protocol::EncodeDvFramePacket(const CDvFramePacket &Packet, CBuffer *Buf
bool CG3Protocol::EncodeDvLastFramePacket(const CDvLastFramePacket &Packet, CBuffer *Buffer) const
{
uint8 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 tag1[] = { 'D','S','V','T',0x20,0x00,0x00,0x00,0x20,0x00,0x01,0x02 };
uint8_t tag2[] = { 0x55,0xC8,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x1A,0xC6 };
Buffer->Set(tag1, sizeof(tag1));
Buffer->Append(Packet.GetStreamId());
Buffer->Append((uint8)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append((uint8_t)((Packet.GetPacketId() % 21) | 0x40));
Buffer->Append(tag2, sizeof(tag2));
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cg3protocol_h
#define cg3protocol_h
#pragma once
#include <string>
#include "Timer.h"
@ -67,7 +60,7 @@ public:
CG3Protocol() : m_GwAddress(0u), m_Modules("*"), m_LastModTime(0) {}
// 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
void Close(void);
@ -116,7 +109,7 @@ protected:
std::future<void> m_PresenceFuture, m_ConfigFuture, m_IcmpFuture;
// time
CTimePoint m_LastKeepaliveTime;
CTimer m_LastKeepaliveTime;
// sockets
CUdpSocket m_PresenceSocket;
@ -124,10 +117,7 @@ protected:
CRawSocket m_IcmpRawSocket;
// optional params
uint32 m_GwAddress;
uint32_t m_GwAddress;
std::string m_Modules;
time_t m_LastModTime;
};
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cg3protocol_h */

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

@ -1,26 +1,25 @@
/*
* Copyright (C) 2020 by Thomas 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 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.
*/
// 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 <cstdint>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include "cip.h"
#include "IP.h"
CIp::CIp() : is_set(false)
{

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

@ -1,30 +1,22 @@
//
// cnotification.h
// xlxd
//
// Created by Jean-Luc on 05/12/2015.
// Copyright © 2015 Jean-Luc. All rights reserved.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cnotification_h
#define cnotification_h
#pragma once
#include "Callsign.h"
@ -59,6 +51,3 @@ protected:
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "Packet.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
CPacket::CPacket()
{
m_uiStreamId = 0;
@ -45,7 +34,7 @@ CPacket::CPacket()
// dstar contrsuctor
CPacket::CPacket(uint16 sid, uint8 dstarpid)
CPacket::CPacket(uint16_t sid, uint8_t dstarpid)
{
m_uiStreamId = sid;
m_uiDstarPacketId = dstarpid;
@ -60,7 +49,7 @@ CPacket::CPacket(uint16 sid, uint8 dstarpid)
// 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_uiDmrPacketId = dmrpid;
@ -75,7 +64,7 @@ CPacket::CPacket(uint16 sid, uint8 dmrpid, uint8 dmrspid)
// 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_uiYsfPacketId = ysfpid;
@ -90,7 +79,7 @@ CPacket::CPacket(uint16 sid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysffrid)
// 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_uiDstarPacketId = dstarpid;
@ -106,7 +95,7 @@ CPacket::CPacket(uint16 sid, uint8 dstarpid, uint8 dmrpid, uint8 dmrsubpid, uint
////////////////////////////////////////////////////////////////////////////////////////
// pid conversion
void CPacket::UpdatePids(uint32 pid)
void CPacket::UpdatePids(uint32_t pid)
{
// called while phusing this packet in a stream queue
// 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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cpacket_h
#define cpacket_h
#pragma once
////////////////////////////////////////////////////////////////////////////////////////
@ -40,10 +33,10 @@ class CPacket
public:
// constructor
CPacket();
CPacket(uint16 sid, uint8 dstarpid);
CPacket(uint16 sid, uint8 dmrpid, uint8 dmrsubpid);
CPacket(uint16 sid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysfsubpidmax);
CPacket(uint16 sid, uint8 dstarpid, uint8 dmrpid, uint8 dmrsubpid, uint8 ysfpid, uint8 ysfsubpid, uint8 ysfsubpidmax);
CPacket(uint16_t sid, uint8_t dstarpid);
CPacket(uint16_t sid, uint8_t dmrpid, uint8_t dmrsubpid);
CPacket(uint16_t sid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysfsubpidmax);
CPacket(uint16_t sid, uint8_t dstarpid, uint8_t dmrpid, uint8_t dmrsubpid, uint8_t ysfpid, uint8_t ysfsubpid, uint8_t ysfsubpidmax);
// destructor
virtual ~CPacket() {}
@ -59,37 +52,32 @@ public:
// get
virtual bool IsValid(void) const { return true; }
uint16 GetStreamId(void) const { return m_uiStreamId; }
uint8 GetPacketId(void) const { return m_uiDstarPacketId; }
uint8 GetDstarPacketId(void) const { return m_uiDstarPacketId; }
uint8 GetDmrPacketId(void) const { return m_uiDmrPacketId; }
uint8 GetDmrPacketSubid(void) const { return m_uiDmrPacketSubid; }
uint8 GetYsfPacketId(void) const { return m_uiYsfPacketId; }
uint8 GetYsfPacketSubId(void) const { return m_uiYsfPacketSubId; }
uint8 GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; }
uint8 GetModuleId(void) const { return m_uiModuleId; }
uint16_t GetStreamId(void) const { return m_uiStreamId; }
uint8_t GetPacketId(void) const { return m_uiDstarPacketId; }
uint8_t GetDstarPacketId(void) const { return m_uiDstarPacketId; }
uint8_t GetDmrPacketId(void) const { return m_uiDmrPacketId; }
uint8_t GetDmrPacketSubid(void) const { return m_uiDmrPacketSubid; }
uint8_t GetYsfPacketId(void) const { return m_uiYsfPacketId; }
uint8_t GetYsfPacketSubId(void) const { return m_uiYsfPacketSubId; }
uint8_t GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; }
uint8_t GetModuleId(void) const { return m_uiModuleId; }
bool IsLocalOrigin(void) const { return (m_uiOriginId == ORIGIN_LOCAL); }
// set
void UpdatePids(uint32);
void SetModuleId(uint8 uiId) { m_uiModuleId = uiId; }
void UpdatePids(uint32_t);
void SetModuleId(uint8_t uiId) { m_uiModuleId = uiId; }
void SetLocalOrigin(void) { m_uiOriginId = ORIGIN_LOCAL; }
void SetRemotePeerOrigin(void) { m_uiOriginId = ORIGIN_PEER; }
protected:
// data
uint16 m_uiStreamId;
uint8 m_uiDstarPacketId;
uint8 m_uiDmrPacketId;
uint8 m_uiDmrPacketSubid;
uint8 m_uiYsfPacketId;
uint8 m_uiYsfPacketSubId;
uint8 m_uiYsfPacketFrameId;
uint8 m_uiModuleId;
uint8 m_uiOriginId;
uint16_t m_uiStreamId;
uint8_t m_uiDstarPacketId;
uint8_t m_uiDmrPacketId;
uint8_t m_uiDmrPacketSubid;
uint8_t m_uiYsfPacketId;
uint8_t m_uiYsfPacketSubId;
uint8_t m_uiYsfPacketFrameId;
uint8_t m_uiModuleId;
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cpacketqueue_h
#define cpacketqueue_h
#pragma once
#include "Packet.h"
#include "Client.h"
@ -55,13 +47,10 @@ public:
protected:
// status
bool m_bOpen;
uint16 m_uiStreamId;
uint16_t m_uiStreamId;
std::mutex m_Mutex;
// owner
CClient *m_Client;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "PacketStream.h"
@ -55,7 +49,7 @@ bool CPacketStream::OpenPacketStream(const CDvHeaderPacket &DvHeader, std::share
m_uiPacketCntr = 0;
m_DvHeader = DvHeader;
m_OwnerClient = client;
m_LastPacketTime.Now();
m_LastPacketTime.start();
#ifdef TRANSCODER_IP
if (std::string::npos != std::string(TRANSCODED_MODULES).find(DvHeader.GetRpt2Module()))
m_CodecStream = g_Transcoder.GetCodecStream(this, client->GetCodec());
@ -85,7 +79,7 @@ void CPacketStream::ClosePacketStream(void)
void CPacketStream::Push(std::unique_ptr<CPacket> Packet)
{
// update stream dependent packet data
m_LastPacketTime.Now();
m_LastPacketTime.start();
Packet->UpdatePids(m_uiPacketCntr++);
// transcoder avaliable ?
#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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cpacketstream_h
#define cpacketstream_h
#pragma once
#include "PacketQueue.h"
#include "Timer.h"
@ -50,29 +43,26 @@ public:
// push & pop
void Push(std::unique_ptr<CPacket> packet);
void Tickle(void) { m_LastPacketTime.Now(); }
void Tickle(void) { m_LastPacketTime.start(); }
bool IsEmpty(void) const;
// get
std::shared_ptr<CClient> GetOwnerClient(void) { return m_OwnerClient; }
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; }
uint16 GetStreamId(void) const { return m_uiStreamId; }
uint16_t GetStreamId(void) const { return m_uiStreamId; }
const CCallsign &GetUserCallsign(void) const { return m_DvHeader.GetMyCallsign(); }
protected:
// data
bool m_bOpen;
uint16 m_uiStreamId;
uint32 m_uiPacketCntr;
CTimePoint m_LastPacketTime;
uint16_t m_uiStreamId;
uint32_t m_uiPacketCntr;
CTimer m_LastPacketTime;
CDvHeaderPacket m_DvHeader;
std::shared_ptr<CClient> m_OwnerClient;
#ifdef TRANSCODER_IP
std::shared_ptr<CCodecStream> m_CodecStream;
#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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.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));
::strncpy(m_ReflectorModules, modules, sizeof(m_ReflectorModules)-1);
m_Version = version;
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
m_ConnectTime = std::time(nullptr);
m_LastHeardTime = std::time(nullptr);
}
@ -103,7 +96,7 @@ bool CPeer::IsAMaster(void) const
void CPeer::Alive(void)
{
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
for ( auto it=begin(); it!=end(); it++ )
{
(*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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cpeer_h
#define cpeer_h
#pragma once
#include "Version.h"
#include "Timer.h"
@ -32,12 +24,6 @@
#include "Callsign.h"
#include "Client.h"
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPeer
{
public:
@ -93,10 +79,7 @@ protected:
std::list<std::shared_ptr<CClient>> m_Clients;
// status
CTimePoint m_LastKeepaliveTime;
CTimer m_LastKeepaliveTime;
std::time_t m_ConnectTime;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include "Main.h"
#include "PeerCallsignList.h"
////////////////////////////////////////////////////////////////////////////////////////
// file io
bool CPeerCallsignList::LoadFromFile(const char *filename)
{
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef cpeercallsignlist_h
#define cpeercallsignlist_h
// 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 "Main.h"
#include "CallsignList.h"
@ -45,7 +36,3 @@ public:
// file io
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cpeers_h
#define cpeers_h
#pragma once
#include "Peer.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPeers
{
public:
@ -73,7 +57,3 @@ protected:
std::mutex m_Mutex;
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 file is part of xlxd.
// 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.
//
// xlxd is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "ProtoAddress.h"

@ -1,24 +1,20 @@
#pragma once
//
// Copyright © 2020 Thomas A. Eary, N7TAE
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// 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.
//
// 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.
// 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.
//
// 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/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <unordered_map>
#include <string>

@ -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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DCSProtocol.h"
@ -56,7 +49,7 @@ CProtocol::~CProtocol()
////////////////////////////////////////////////////////////////////////////////////////
// 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
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
if (type)
m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)type, 3);
m_ReflectorCallsign.PatchCallsign(0, (const uint8_t *)type, 3);
// create our sockets
#ifdef LISTEN_IPV4
@ -199,7 +192,7 @@ void CProtocol::OnDvLastFramePacketIn(std::unique_ptr<CDvLastFramePacket> &Frame
////////////////////////////////////////////////////////////////////////////////////////
// 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++ )
{
@ -261,14 +254,14 @@ bool CProtocol::IsSpace(char c) const
////////////////////////////////////////////////////////////////////////////////////////
// DestId to Module helper
char CProtocol::DmrDstIdToModule(uint32 tg) const
char CProtocol::DmrDstIdToModule(uint32_t tg) const
{
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cprotocol_h
#define cprotocol_h
#pragma once
#include "UDPSocket.h"
#include "PacketStream.h"
@ -77,7 +69,7 @@ public:
virtual ~CProtocol();
// 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);
// queue
@ -104,7 +96,7 @@ protected:
virtual void OnDvLastFramePacketIn(std::unique_ptr<CDvLastFramePacket> &, const CIp * = nullptr);
// stream handle helpers
CPacketStream *GetStream(uint16, const CIp * = nullptr);
CPacketStream *GetStream(uint16_t, const CIp * = nullptr);
void CheckStreamsTimeout(void);
// queue helper
@ -119,8 +111,8 @@ protected:
bool IsSpace(char) const;
// dmr DstId to Module helper
virtual char DmrDstIdToModule(uint32) const;
virtual uint32 ModuleToDmrDestId(char) const;
virtual char DmrDstIdToModule(uint32_t) const;
virtual uint32_t ModuleToDmrDestId(char) const;
bool Receive6(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 char *buf, const CIp &Ip) const;
void Send(const CBuffer &buf, const CIp &Ip, uint16 port) const;
void Send(const char *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_t port) const;
// socket
CUdpSocket m_Socket4;
@ -149,8 +141,5 @@ protected:
CCallsign m_ReflectorCallsign;
// debug
CTimePoint m_DebugTimer;
CTimer m_DebugTimer;
};
////////////////////////////////////////////////////////////////////////////////////////
#endif /* cprotocol_h */

@ -1,36 +1,29 @@
//
// cprotocols.cpp
// xlxd
//
// 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.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "DExtraProtocol.h"
#include "DPlusProtocol.h"
#include "cdcsprotocol.h"
#include "DCSProtocol.h"
#ifndef NO_XLX
#include "ULXProtocol.h"
#include "DMRPlusProtocol.h"
#include "DMMMDVMProtocol.h"
#include "DMRMMDVMProtocol.h"
#include "YSFProtocol.h"
#endif
#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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cprotocols_h
#define cprotocols_h
#pragma once
#include "DCSProtocol.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CProtocols
{
public:
@ -56,8 +41,3 @@ protected:
std::mutex m_Mutex;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
@ -50,7 +44,7 @@ CRawSocket::~CRawSocket()
////////////////////////////////////////////////////////////////////////////////////////
// open & close
bool CRawSocket::Open(uint16 uiProto)
bool CRawSocket::Open(uint16_t uiProto)
{
bool open = false;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Description:
// Raw socket access class with protocol specific
#ifndef crawsocket_h
#define crawsocket_h
#pragma once
#include <sys/types.h>
#include <unistd.h>
@ -60,7 +49,7 @@ public:
~CRawSocket();
// open & close
bool Open(uint16);
bool Open(uint16_t);
void Close(void);
int GetSocket(void) { return m_Socket; }
@ -96,6 +85,3 @@ protected:
int m_Proto;
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include <string.h>
#include "Reflector.h"
#include "GateKeeper.h"
#include "cdmriddirfile.h"
#include "DMRIdDirFile.h"
#include "DMRIdDirHttp.h"
#include "Transcoder.h"
#include "YSFNodeDirFile.h"
#include "YSFNodeDirhttp.h"
#include "YSFNodeDirHttp.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
@ -243,7 +236,7 @@ void CReflector::CloseStream(CPacketStream *stream)
bEmpty = stream->empty();
stream->Unlock();
if ( !bEmpty )
CTimePoint::TaskSleepFor(10);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
while (!bEmpty);
@ -282,7 +275,7 @@ void CReflector::CloseStream(CPacketStream *stream)
void CReflector::RouterThread(CPacketStream *streamIn)
{
// get our module
uint8 uiModuleId = GetStreamModule(streamIn);
uint8_t uiModuleId = GetStreamModule(streamIn);
// get on input queue
std::unique_ptr<CPacket> packet;
@ -334,7 +327,7 @@ void CReflector::RouterThread(CPacketStream *streamIn)
}
else
{
CTimePoint::TaskSleepFor(10);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
}
@ -366,7 +359,7 @@ void CReflector::XmlReportThread()
// and wait a bit
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) )
{
// 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;
@ -405,7 +398,7 @@ void CReflector::JsonReportThread()
SendJsonNodesObject(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;
@ -451,7 +444,7 @@ void CReflector::JsonReportThread()
case NOTIFICATION_NONE:
default:
// nothing to do, just sleep a bit
CTimePoint::TaskSleepFor(250);
std::this_thread::sleep_for(std::chrono::milliseconds(250);
break;
}
}
@ -623,7 +616,7 @@ void CReflector::SendJsonReflectorObject(CUdpSocket &Socket, CIp &Ip)
char mod[8] = "\"A\"";
// get reflector callsign
m_Callsign.GetCallsign((uint8 *)cs);
m_Callsign.GetCallsign((uint8_t *)cs);
cs[CALLSIGN_LEN] = 0;
// 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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef creflector_h
#define creflector_h
#pragma once
#include "ProtoAddress.h"
#include "Users.h"
@ -155,6 +147,3 @@ public:
std::ofstream m_DebugFile;
#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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "Semaphore.h"
@ -57,7 +51,7 @@ void CSemaphore::Wait(void)
m_Count--;
}
bool CSemaphore::WaitFor(uint ms)
bool CSemaphore::WaitFor(unsigned ms)
{
std::chrono::milliseconds timespan(ms);
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#ifndef csemaphore_h
#define csemaphore_h
// 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
#include "Main.h"
class CSemaphore
{
@ -42,7 +33,7 @@ public:
void Reset(void);
void Notify(void);
void Wait(void);
bool WaitFor(uint);
bool WaitFor(unsigned);
protected:
// data
@ -51,6 +42,3 @@ protected:
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
//
// 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/>.

@ -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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.h"
#include "Reflector.h"
@ -48,8 +42,8 @@ CTranscoder::CTranscoder()
{
keep_running = true;
m_bConnected = false;
m_LastKeepaliveTime.Now();
m_LastActivityTime.Now();
m_LastKeepaliveTime.start();
m_LastActivityTime.start();
m_bStreamOpened = false;
m_StreamidOpenStream = 0;
m_PortOpenStream = 0;
@ -147,14 +141,14 @@ void CTranscoder::Task(void)
{
CBuffer Buffer;
CIp Ip;
uint16 StreamId;
uint16 Port;
uint16_t StreamId;
uint16_t Port;
// anything coming in from codec server ?
//if ( (m_Socket.Receive(&Buffer, &Ip, 20) != -1) && (Ip == m_Ip) )
if ( m_Socket.Receive(Buffer, Ip, 20) )
{
m_LastActivityTime.Now();
m_LastActivityTime.start();
// crack packet
if ( IsValidStreamDescrPacket(Buffer, &StreamId, &Port) )
@ -182,20 +176,20 @@ void CTranscoder::Task(void)
}
// keep client alive
if ( m_LastKeepaliveTime.DurationSinceNow() > TRANSCODER_KEEPALIVE_PERIOD )
if ( m_LastKeepaliveTime.time() > TRANSCODER_KEEPALIVE_PERIOD )
{
//
HandleKeepalives();
// update time
m_LastKeepaliveTime.Now();
m_LastKeepaliveTime.start();
}
}
////////////////////////////////////////////////////////////////////////////////////////
// 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;
@ -315,7 +309,7 @@ void CTranscoder::HandleKeepalives(void)
m_Socket.Send(keepalive, m_Ip, TRANSCODER_PORT);
// 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
m_bConnected = false;
@ -328,7 +322,7 @@ void CTranscoder::HandleKeepalives(void)
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;
if ( (Buffer.size() == 9) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
@ -338,17 +332,17 @@ bool CTranscoder::IsValidKeepAlivePacket(const CBuffer &Buffer)
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;
if ( (Buffer.size() == 14) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
{
*Id = *(uint16 *)(&Buffer.data()[8]);
*Port = *(uint16 *)(&Buffer.data()[10]);
// uint8 CodecIn = Buffer.data()[12];
// uint8 CodecOut = Buffer.data()[13];
*Id = *(uint16_t *)(&Buffer.data()[8]);
*Port = *(uint16_t *)(&Buffer.data()[10]);
// uint8_t CodecIn = Buffer.data()[12];
// uint8_t CodecOut = Buffer.data()[13];
valid = true;
}
return valid;
@ -356,7 +350,7 @@ bool CTranscoder::IsValidStreamDescrPacket(const CBuffer &Buffer, uint16 *Id, ui
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) );
}
@ -367,26 +361,26 @@ bool CTranscoder::IsValidNoStreamAvailablePacket(const 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->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->Append((uint8 *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8)uiCodecIn);
Buffer->Append((uint8)uiCodecOut);
Buffer->Append((uint8_t *)(const char *)g_Reflector.GetCallsign(), CALLSIGN_LEN);
Buffer->Append((uint8_t)uiCodecIn);
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->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 © 2020 Thomas A. Early N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ctranscoder_h
#define ctranscoder_h
#pragma once
#include "Semaphore.h"
#include "CodecStream.h"
#include "UDPSocket.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
////////////////////////////////////////////////////////////////////////////////////////
// class
class CPacketStream;
class CTranscoder
@ -60,7 +45,7 @@ public:
bool IsConnected(void) const { return m_bConnected; }
// manage streams
std::shared_ptr<CCodecStream> GetCodecStream(CPacketStream *, uint8);
std::shared_ptr<CCodecStream> GetCodecStream(CPacketStream *, uint8_t);
void ReleaseStream(std::shared_ptr<CCodecStream>);
// task
@ -73,13 +58,13 @@ protected:
// packet decoding helpers
bool IsValidKeepAlivePacket(const CBuffer &);
bool IsValidStreamDescrPacket(const CBuffer &, uint16 *, uint16 *);
bool IsValidStreamDescrPacket(const CBuffer &, uint16_t *, uint16_t *);
bool IsValidNoStreamAvailablePacket(const CBuffer&);
// packet encoding helpers
void EncodeKeepAlivePacket(CBuffer *);
void EncodeOpenstreamPacket(CBuffer *, uint8, uint8);
void EncodeClosestreamPacket(CBuffer *, uint16);
void EncodeOpenstreamPacket(CBuffer *, uint8_t, uint8_t);
void EncodeClosestreamPacket(CBuffer *, uint16_t);
protected:
// streams
@ -89,8 +74,8 @@ protected:
// sync objects for Openstream
CSemaphore m_SemaphoreOpenStream;
bool m_bStreamOpened;
uint16 m_StreamidOpenStream;
uint16 m_PortOpenStream;
uint16_t m_StreamidOpenStream;
uint16_t m_PortOpenStream;
// thread
std::atomic<bool> keep_running;
@ -102,10 +87,6 @@ protected:
bool m_bConnected;
// time
CTimePoint m_LastKeepaliveTime;
CTimePoint m_LastActivityTime;
CTimer m_LastKeepaliveTime;
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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// 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 "Main.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.
// 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
// 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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// xlxd is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Description:
// Extension of the CUdpSocket class to allow retrieving
// the local target IP for a G3 Terminal mode config request
#ifndef cudpmsgsocket_h
#define cudpmsgsocket_h
#pragma once
#include "UDPSocket.h"
#define UDP_MSG_BUFFER_LENMAX 1024
////////////////////////////////////////////////////////////////////////////////////////
// class
class CUdpMsgSocket : public CUdpSocket
{
public:
@ -51,6 +41,3 @@ protected:
// data
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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string.h>
#include "Main.h"

@ -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 © 2020 Thomas A. Early, N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of xlxd.
// ulxd -- The universal reflector
// Copyright © 2021 Thomas A. Early N7TAE
//
// 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.
// 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.
//
// 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.
// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef cudpsocket_h
#define cudpsocket_h
#pragma once
#include <cstdint>
#include <sys/types.h>
@ -37,15 +29,8 @@
#include "IP.h"
#include "Buffer.h"
////////////////////////////////////////////////////////////////////////////////////////
// define
#define UDP_BUFFER_LENMAX 1024
////////////////////////////////////////////////////////////////////////////////////////
// class
class CUdpSocket
{
public:
@ -78,6 +63,3 @@ protected:
int m_fd;
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.