astyle -A1 -T -O

pull/1/head
Tom Early 5 years ago
parent 2af8c7225a
commit a0e615c459

@ -36,11 +36,14 @@ typedef void VOID;
typedef USHORT *PUSHORT; typedef USHORT *PUSHORT;
typedef unsigned long long int ULONGLONG; typedef unsigned long long int ULONGLONG;
typedef struct _OVERLAPPED { typedef struct _OVERLAPPED
{
DWORD Internal; DWORD Internal;
DWORD InternalHigh; DWORD InternalHigh;
union { union
struct{ {
struct
{
DWORD Offset; DWORD Offset;
DWORD OffsetHigh; DWORD OffsetHigh;
}; };
@ -49,11 +52,12 @@ typedef struct _OVERLAPPED {
HANDLE hEvent; HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED; } OVERLAPPED, *LPOVERLAPPED;
typedef struct _SECURITY_ATTRIBUTES { typedef struct _SECURITY_ATTRIBUTES
{
DWORD nLength; DWORD nLength;
LPVOID lpSecurityDescriptor; LPVOID lpSecurityDescriptor;
BOOL bInheritHandle; BOOL bInheritHandle;
} SECURITY_ATTRIBUTES , *LPSECURITY_ATTRIBUTES; } SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
#include <pthread.h> #include <pthread.h>
// Substitute for HANDLE returned by Windows CreateEvent API. // Substitute for HANDLE returned by Windows CreateEvent API.

@ -77,7 +77,8 @@ bool CController::Init(void)
// create our socket // create our socket
CIp ip(strchr(m_addr, ':') ? AF_INET6 : AF_INET, TRANSCODER_PORT, m_addr); CIp ip(strchr(m_addr, ':') ? AF_INET6 : AF_INET, TRANSCODER_PORT, m_addr);
if (! ip.IsSet()) { if (! ip.IsSet())
{
std::cerr << "IP initialization failed for " << m_addr << std::endl; std::cerr << "IP initialization failed for " << m_addr << std::endl;
return false; return false;
} }

@ -38,7 +38,7 @@
// constructor // constructor
CUsb3000Interface::CUsb3000Interface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial) CUsb3000Interface::CUsb3000Interface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial)
: CUsb3xxxInterface(uiVid, uiPid, szDeviceName, szDeviceSerial) : CUsb3xxxInterface(uiVid, uiPid, szDeviceName, szDeviceSerial)
{ {
m_uiChCodec = CODEC_NONE; m_uiChCodec = CODEC_NONE;
} }

@ -35,7 +35,7 @@
// constructor // constructor
CUsb3003DF2ETInterface::CUsb3003DF2ETInterface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial) CUsb3003DF2ETInterface::CUsb3003DF2ETInterface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial)
: CUsb3003Interface(uiVid, uiPid, szDeviceName, szDeviceSerial) : CUsb3003Interface(uiVid, uiPid, szDeviceName, szDeviceSerial)
{ {
} }
@ -115,7 +115,8 @@ bool CUsb3003DF2ETInterface::ResetDevice(void)
} }
n -= b; n -= b;
p += b; p += b;
} while (n > 0); }
while (n > 0);
} }
p = &reset_packet[0]; p = &reset_packet[0];
@ -129,7 +130,8 @@ bool CUsb3003DF2ETInterface::ResetDevice(void)
} }
n -= b; n -= b;
p += b; p += b;
} while (n > 0); }
while (n > 0);
len = FTDI_read_packet( m_FtdiHandle, rxpacket, sizeof(rxpacket) ); len = FTDI_read_packet( m_FtdiHandle, rxpacket, sizeof(rxpacket) );
ok = ((len == 7) && (rxpacket[4] == PKT_READY)); ok = ((len == 7) && (rxpacket[4] == PKT_READY));

@ -32,7 +32,7 @@
// constructor // constructor
CUsb3003HRInterface::CUsb3003HRInterface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial) CUsb3003HRInterface::CUsb3003HRInterface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial)
: CUsb3003Interface(uiVid, uiPid, szDeviceName, szDeviceSerial) : CUsb3003Interface(uiVid, uiPid, szDeviceName, szDeviceSerial)
{ {
} }

@ -40,7 +40,7 @@
// constructor // constructor
CUsb3003Interface::CUsb3003Interface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial) CUsb3003Interface::CUsb3003Interface(uint32 uiVid, uint32 uiPid, const char *szDeviceName, const char *szDeviceSerial)
: CUsb3xxxInterface(uiVid, uiPid, szDeviceName, szDeviceSerial) : CUsb3xxxInterface(uiVid, uiPid, szDeviceName, szDeviceSerial)
{ {
m_uiChCodecs[0]= CODEC_AMBEPLUS; m_uiChCodecs[0]= CODEC_AMBEPLUS;
m_uiChCodecs[1]= CODEC_AMBE2PLUS; m_uiChCodecs[1]= CODEC_AMBE2PLUS;

@ -231,7 +231,8 @@ void CUsb3xxxInterface::Task(void)
Channel->ReleasePacketQueueIn(); Channel->ReleasePacketQueueIn();
} }
} }
} while (!done); }
while (!done);
// process device incoming queues (aka to device) // process device incoming queues (aka to device)
// interlace speech and channels packets // interlace speech and channels packets
@ -265,7 +266,8 @@ void CUsb3xxxInterface::Task(void)
} }
} }
} while (!done); }
while (!done);
// process device queue to feed hardware // process device queue to feed hardware
// make sure that device fifo is fed all the time // make sure that device fifo is fed all the time
@ -297,7 +299,8 @@ void CUsb3xxxInterface::Task(void)
// next // next
done = false; done = false;
#ifdef DEBUG_DUMPFILE #ifdef DEBUG_DUMPFILE
g_AmbeServer.m_DebugFile << m_szDeviceName << "\t" << "Sp" << Packet->GetChannel() << "->" << std::endl; std::cout.flush(); g_AmbeServer.m_DebugFile << m_szDeviceName << "\t" << "Sp" << Packet->GetChannel() << "->" << std::endl;
std::cout.flush();
#endif #endif
} }
else if ( Packet->IsAmbe() && (m_iChannelFifolLevel < fifoSize) ) else if ( Packet->IsAmbe() && (m_iChannelFifolLevel < fifoSize) )
@ -314,13 +317,15 @@ void CUsb3xxxInterface::Task(void)
// next // next
done = false; done = false;
#ifdef DEBUG_DUMPFILE #ifdef DEBUG_DUMPFILE
g_AmbeServer.m_DebugFile << m_szDeviceName << "\t" << "Ch" << Packet->GetChannel() << "->" << std::endl; std::cout.flush(); g_AmbeServer.m_DebugFile << m_szDeviceName << "\t" << "Ch" << Packet->GetChannel() << "->" << std::endl;
std::cout.flush();
#endif #endif
} }
} }
} }
} while (!done); }
while (!done);
// and wait a bit // and wait a bit
CTimePoint::TaskSleepFor(2); CTimePoint::TaskSleepFor(2);

File diff suppressed because it is too large Load Diff

@ -127,10 +127,12 @@ grid
#if USE_BANDPASSFILTER == 1 #if USE_BANDPASSFILTER == 1
const float FILTER_TAPS[] { const float FILTER_TAPS[]
-0.05063341f, -0.00060337f, -0.08892498f, -0.02026701f, -0.05940750f, -0.10977641f, 0.03244024f, -0.22304499f, {
0.11452865f, 0.72500000f, 0.11452865f, -0.22304499f, 0.03244024f, -0.10977641f, -0.05940750f, -0.02026701f, -0.05063341f, -0.00060337f, -0.08892498f, -0.02026701f, -0.05940750f, -0.10977641f, 0.03244024f, -0.22304499f,
-0.08892498f, -0.00060337f, -0.05063341f }; 0.11452865f, 0.72500000f, 0.11452865f, -0.22304499f, 0.03244024f, -0.10977641f, -0.05940750f, -0.02026701f,
-0.08892498f, -0.00060337f, -0.05063341f
};
#define FILTER_TAPS_LENGTH 19 #define FILTER_TAPS_LENGTH 19
#endif #endif

@ -38,7 +38,7 @@ CBmPeer::CBmPeer()
} }
CBmPeer::CBmPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version) CBmPeer::CBmPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version)
: CPeer(callsign, ip, modules, version) : CPeer(callsign, ip, modules, version)
{ {
std::cout << "Adding BM peer" << std::endl; std::cout << "Adding BM peer" << std::endl;

@ -117,7 +117,8 @@ void CBPTC19696::decodeDeInterleave()
m_deInterData[i] = false; m_deInterData[i] = false;
// The first bit is R(3) which is not used so can be ignored // The first bit is R(3) which is not used so can be ignored
for (unsigned int a = 0U; a < 196U; a++) { for (unsigned int a = 0U; a < 196U; a++)
{
// Calculate the interleave sequence // Calculate the interleave sequence
unsigned int interleaveSequence = (a * 181U) % 196U; unsigned int interleaveSequence = (a * 181U) % 196U;
// Shuffle the data // Shuffle the data
@ -130,21 +131,26 @@ void CBPTC19696::decodeErrorCheck()
{ {
bool fixing; bool fixing;
unsigned int count = 0U; unsigned int count = 0U;
do { do
{
fixing = false; fixing = false;
// Run through each of the 15 columns // Run through each of the 15 columns
bool col[13U]; bool col[13U];
for (unsigned int c = 0U; c < 15U; c++) { for (unsigned int c = 0U; c < 15U; c++)
{
unsigned int pos = c + 1U; unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) { for (unsigned int a = 0U; a < 13U; a++)
{
col[a] = m_deInterData[pos]; col[a] = m_deInterData[pos];
pos = pos + 15U; pos = pos + 15U;
} }
if (CHamming::decode1393(col)) { if (CHamming::decode1393(col))
{
unsigned int pos = c + 1U; unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) { for (unsigned int a = 0U; a < 13U; a++)
{
m_deInterData[pos] = col[a]; m_deInterData[pos] = col[a];
pos = pos + 15U; pos = pos + 15U;
} }
@ -154,14 +160,16 @@ void CBPTC19696::decodeErrorCheck()
} }
// Run through each of the 9 rows containing data // Run through each of the 9 rows containing data
for (unsigned int r = 0U; r < 9U; r++) { for (unsigned int r = 0U; r < 9U; r++)
{
unsigned int pos = (r * 15U) + 1U; unsigned int pos = (r * 15U) + 1U;
if (CHamming::decode15113_2(m_deInterData + pos)) if (CHamming::decode15113_2(m_deInterData + pos))
fixing = true; fixing = true;
} }
count++; count++;
} while (fixing && count < 5U); }
while (fixing && count < 5U);
} }
// Extract the 96 bits of payload // Extract the 96 bits of payload
@ -264,16 +272,19 @@ void CBPTC19696::encodeErrorCheck()
{ {
// Run through each of the 9 rows containing data // Run through each of the 9 rows containing data
for (unsigned int r = 0U; r < 9U; r++) { for (unsigned int r = 0U; r < 9U; r++)
{
unsigned int pos = (r * 15U) + 1U; unsigned int pos = (r * 15U) + 1U;
CHamming::encode15113_2(m_deInterData + pos); CHamming::encode15113_2(m_deInterData + pos);
} }
// Run through each of the 15 columns // Run through each of the 15 columns
bool col[13U]; bool col[13U];
for (unsigned int c = 0U; c < 15U; c++) { for (unsigned int c = 0U; c < 15U; c++)
{
unsigned int pos = c + 1U; unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) { for (unsigned int a = 0U; a < 13U; a++)
{
col[a] = m_deInterData[pos]; col[a] = m_deInterData[pos];
pos = pos + 15U; pos = pos + 15U;
} }
@ -281,7 +292,8 @@ void CBPTC19696::encodeErrorCheck()
CHamming::encode1393(col); CHamming::encode1393(col);
pos = c + 1U; pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) { for (unsigned int a = 0U; a < 13U; a++)
{
m_deInterData[pos] = col[a]; m_deInterData[pos] = col[a];
pos = pos + 15U; pos = pos + 15U;
} }
@ -295,7 +307,8 @@ void CBPTC19696::encodeInterleave()
m_rawData[i] = false; m_rawData[i] = false;
// The first bit is R(3) which is not used so can be ignored // The first bit is R(3) which is not used so can be ignored
for (unsigned int a = 0U; a < 196U; a++) { for (unsigned int a = 0U; a < 196U; a++)
{
// Calculate the interleave sequence // Calculate the interleave sequence
unsigned int interleaveSequence = (a * 181U) % 196U; unsigned int interleaveSequence = (a * 181U) % 196U;
// Unshuffle the data // Unshuffle the data

@ -92,7 +92,8 @@ void CBuffer::Append(const char *sz)
void CBuffer::ReplaceAt(int i, uint8_t ui) void CBuffer::ReplaceAt(int i, uint8_t ui)
{ {
if ( m_data.size() < (i+sizeof(uint8_t)) ) { if ( m_data.size() < (i+sizeof(uint8_t)) )
{
m_data.resize(i+sizeof(uint8_t)); m_data.resize(i+sizeof(uint8_t));
} }
*(uint8_t *)(&(m_data.data()[i])) = ui; *(uint8_t *)(&(m_data.data()[i])) = ui;
@ -100,7 +101,8 @@ void CBuffer::ReplaceAt(int i, uint8_t ui)
void CBuffer::ReplaceAt(int i, uint16_t ui) void CBuffer::ReplaceAt(int i, uint16_t ui)
{ {
if ( m_data.size() < (i+sizeof(uint16_t)) ) { if ( m_data.size() < (i+sizeof(uint16_t)) )
{
m_data.resize(i+sizeof(uint16_t)); m_data.resize(i+sizeof(uint16_t));
} }
*(uint16_t *)(&(m_data.data()[i])) = ui; *(uint16_t *)(&(m_data.data()[i])) = ui;
@ -108,7 +110,8 @@ void CBuffer::ReplaceAt(int i, uint16_t ui)
void CBuffer::ReplaceAt(int i, uint32_t ui) void CBuffer::ReplaceAt(int i, uint32_t ui)
{ {
if ( m_data.size() < (i+sizeof(uint32_t)) ) { if ( m_data.size() < (i+sizeof(uint32_t)) )
{
m_data.resize(i+sizeof(uint32_t)); m_data.resize(i+sizeof(uint32_t));
} }
*(uint32_t *)(&(m_data.data()[i])) = ui; *(uint32_t *)(&(m_data.data()[i])) = ui;
@ -116,7 +119,8 @@ void CBuffer::ReplaceAt(int i, uint32_t ui)
void CBuffer::ReplaceAt(int i, const uint8_t *ptr, int len) void CBuffer::ReplaceAt(int i, const uint8_t *ptr, int len)
{ {
if ( m_data.size() < unsigned(i+len) ) { if ( m_data.size() < unsigned(i+len) )
{
m_data.resize(i+len); m_data.resize(i+len);
} }
::memcpy(&(m_data.data()[i]), ptr, len); ::memcpy(&(m_data.data()[i]), ptr, len);
@ -128,7 +132,8 @@ void CBuffer::ReplaceAt(int i, const uint8_t *ptr, int len)
int CBuffer::Compare(uint8_t *buffer, int len) const int CBuffer::Compare(uint8_t *buffer, int len) const
{ {
int result = -1; int result = -1;
if ( m_data.size() >= unsigned(len) ) { if ( m_data.size() >= unsigned(len) )
{
result = ::memcmp(m_data.data(), buffer, len); result = ::memcmp(m_data.data(), buffer, len);
} }
return result; return result;
@ -137,7 +142,8 @@ int CBuffer::Compare(uint8_t *buffer, int len) const
int CBuffer::Compare(uint8_t *buffer, int off, int len) const int CBuffer::Compare(uint8_t *buffer, int off, int len) const
{ {
int result = -1; int result = -1;
if ( m_data.size() >= unsigned(off+len) ) { if ( m_data.size() >= unsigned(off+len) )
{
result = ::memcmp(&(m_data.data()[off]), buffer, len); result = ::memcmp(&(m_data.data()[off]), buffer, len);
} }
return result; return result;
@ -149,7 +155,8 @@ int CBuffer::Compare(uint8_t *buffer, int off, int len) const
bool CBuffer::operator ==(const CBuffer &Buffer) const bool CBuffer::operator ==(const CBuffer &Buffer) const
{ {
if ( m_data.size() == Buffer.m_data.size() ) { if ( m_data.size() == Buffer.m_data.size() )
{
return (::memcmp((const char *)m_data.data(), (const char *)Buffer.m_data.data(), m_data.size()) == 0); return (::memcmp((const char *)m_data.data(), (const char *)Buffer.m_data.data(), m_data.size()) == 0);
} }
return false; return false;
@ -157,7 +164,8 @@ bool CBuffer::operator ==(const CBuffer &Buffer) const
bool CBuffer::operator ==(const char *sz) const bool CBuffer::operator ==(const char *sz) const
{ {
if ( m_data.size() == ::strlen(sz) ) { if ( m_data.size() == ::strlen(sz) )
{
return (::memcmp((const char *)m_data.data(), sz, m_data.size()) == 0); return (::memcmp((const char *)m_data.data(), sz, m_data.size()) == 0);
} }
return false; return false;
@ -174,14 +182,18 @@ CBuffer::operator const char *() const
void CBuffer::DebugDump(std::ofstream &debugout) const void CBuffer::DebugDump(std::ofstream &debugout) const
{ {
// dump an hex line // dump an hex line
for ( unsigned int i = 0; i < m_data.size(); i++ ) { for ( unsigned int i = 0; i < m_data.size(); i++ )
{
char sz[16]; char sz[16];
//sprintf(sz, "%02X", m_data.data()[i]); //sprintf(sz, "%02X", m_data.data()[i]);
sprintf(sz, "0x%02X", m_data.data()[i]); sprintf(sz, "0x%02X", m_data.data()[i]);
debugout << sz; debugout << sz;
if ( i == m_data.size()-1 ) { if ( i == m_data.size()-1 )
{
debugout << std::endl; debugout << std::endl;
} else { }
else
{
debugout << ','; debugout << ',';
} }
} }
@ -190,14 +202,19 @@ void CBuffer::DebugDump(std::ofstream &debugout) const
void CBuffer::DebugDumpAscii(std::ofstream &debugout) const void CBuffer::DebugDumpAscii(std::ofstream &debugout) const
{ {
// dump an ascii line // dump an ascii line
for ( unsigned int i = 0; i < m_data.size(); i++ ) { for ( unsigned int i = 0; i < m_data.size(); i++ )
{
char c = m_data.data()[i]; char c = m_data.data()[i];
if ( isascii(c) ) { if ( isascii(c) )
{
debugout << c; debugout << c;
} else { }
else
{
debugout << '.'; debugout << '.';
} }
if ( i == m_data.size()-1 ) { if ( i == m_data.size()-1 )
{
debugout << std::endl; debugout << std::endl;
} }
} }

@ -66,7 +66,7 @@ CClient::CClient(const CClient &client)
void CClient::Alive(void) void CClient::Alive(void)
{ {
m_LastKeepaliveTime.Now();; m_LastKeepaliveTime.Now();
} }

@ -66,8 +66,7 @@ void CClients::AddClient(std::shared_ptr<CClient> client)
// and append // and append
m_Clients.push_back(client); m_Clients.push_back(client);
std::cout << "New client " << client->GetCallsign() << " at " << client->GetIp() std::cout << "New client " << client->GetCallsign() << " at " << client->GetIp() << " added with protocol " << client->GetProtocolName();
<< " added with protocol " << client->GetProtocolName();
if ( client->GetReflectorModule() != ' ' ) if ( client->GetReflectorModule() != ' ' )
{ {
std::cout << " on module " << client->GetReflectorModule(); std::cout << " on module " << client->GetReflectorModule();
@ -153,9 +152,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CIp &Ip, int Protocol, char
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( ((*it)->GetIp() == Ip) && if ( ((*it)->GetIp() == Ip) && ((*it)->GetReflectorModule() == ReflectorModule) && ((*it)->GetProtocol() == Protocol) )
((*it)->GetReflectorModule() == ReflectorModule) &&
((*it)->GetProtocol() == Protocol) )
{ {
return *it; return *it;
} }
@ -170,9 +167,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, const C
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && ((*it)->GetIp() == Ip) && ((*it)->GetProtocol() == Protocol) )
((*it)->GetIp() == Ip) &&
((*it)->GetProtocol() == Protocol) )
{ {
return *it; return *it;
} }
@ -186,10 +181,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, char mo
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && ((*it)->GetModule() == module) && ((*it)->GetIp() == Ip) && ((*it)->GetProtocol() == Protocol) )
((*it)->GetModule() == module) &&
((*it)->GetIp() == Ip) &&
((*it)->GetProtocol() == Protocol) )
{ {
return *it; return *it;
} }
@ -203,8 +195,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, int Pro
// find client // find client
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( ((*it)->GetProtocol() == Protocol) && if ( ((*it)->GetProtocol() == Protocol) && (*it)->GetCallsign().HasSameCallsign(Callsign) )
(*it)->GetCallsign().HasSameCallsign(Callsign) )
{ {
return *it; return *it;
} }
@ -233,8 +224,7 @@ std::shared_ptr<CClient> CClients::FindNextClient(const CIp &Ip, int Protocol, s
{ {
while ( it != end() ) while ( it != end() )
{ {
if ( ((*it)->GetProtocol() == Protocol) && if ( ((*it)->GetProtocol() == Protocol) && ((*it)->GetIp() == Ip) )
((*it)->GetIp() == Ip) )
{ {
return *it++; return *it++;
} }
@ -247,9 +237,7 @@ std::shared_ptr<CClient> CClients::FindNextClient(const CCallsign &Callsign, con
{ {
while ( it != end() ) while ( it != end() )
{ {
if ( ((*it)->GetProtocol() == Protocol) && if ( ((*it)->GetProtocol() == Protocol) && ((*it)->GetIp() == Ip) && (*it)->GetCallsign().HasSameCallsign(Callsign) )
((*it)->GetIp() == Ip) &&
(*it)->GetCallsign().HasSameCallsign(Callsign) )
{ {
return *it++; return *it++;
} }

@ -117,7 +117,8 @@ bool CCodecStream::Init(uint16 uiPort)
// create our socket // create our socket
if (ip.IsSet()) if (ip.IsSet())
{ {
if (! m_Socket.Open(ip)) { if (! m_Socket.Open(ip))
{
std::cerr << "Error opening socket on IP address " << m_Ip << std::endl; std::cerr << "Error opening socket on IP address " << m_Ip << std::endl;
return false; return false;
} }

@ -25,7 +25,8 @@
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
const uint8_t CRC8_TABLE[] = { const uint8_t CRC8_TABLE[] =
{
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31,
0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9,
@ -47,9 +48,11 @@ const uint8_t CRC8_TABLE[] = {
0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7,
0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF,
0xFA, 0xFD, 0xF4, 0xF3, 0x01 }; 0xFA, 0xFD, 0xF4, 0xF3, 0x01
};
const uint16_t CCITT16_TABLE1[] = { const uint16_t CCITT16_TABLE1[] =
{
0x0000U, 0x1189U, 0x2312U, 0x329bU, 0x4624U, 0x57adU, 0x6536U, 0x74bfU, 0x0000U, 0x1189U, 0x2312U, 0x329bU, 0x4624U, 0x57adU, 0x6536U, 0x74bfU,
0x8c48U, 0x9dc1U, 0xaf5aU, 0xbed3U, 0xca6cU, 0xdbe5U, 0xe97eU, 0xf8f7U, 0x8c48U, 0x9dc1U, 0xaf5aU, 0xbed3U, 0xca6cU, 0xdbe5U, 0xe97eU, 0xf8f7U,
0x1081U, 0x0108U, 0x3393U, 0x221aU, 0x56a5U, 0x472cU, 0x75b7U, 0x643eU, 0x1081U, 0x0108U, 0x3393U, 0x221aU, 0x56a5U, 0x472cU, 0x75b7U, 0x643eU,
@ -81,9 +84,11 @@ const uint16_t CCITT16_TABLE1[] = {
0xe70eU, 0xf687U, 0xc41cU, 0xd595U, 0xa12aU, 0xb0a3U, 0x8238U, 0x93b1U, 0xe70eU, 0xf687U, 0xc41cU, 0xd595U, 0xa12aU, 0xb0a3U, 0x8238U, 0x93b1U,
0x6b46U, 0x7acfU, 0x4854U, 0x59ddU, 0x2d62U, 0x3cebU, 0x0e70U, 0x1ff9U, 0x6b46U, 0x7acfU, 0x4854U, 0x59ddU, 0x2d62U, 0x3cebU, 0x0e70U, 0x1ff9U,
0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U, 0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U,
0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U }; 0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U
};
const uint16_t CCITT16_TABLE2[] = { const uint16_t CCITT16_TABLE2[] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
@ -115,7 +120,8 @@ const uint16_t CCITT16_TABLE2[] = {
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 }; 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
bool CCRC::checkFiveBit(bool* in, unsigned int tcrc) bool CCRC::checkFiveBit(bool* in, unsigned int tcrc)
@ -133,7 +139,8 @@ void CCRC::encodeFiveBit(const bool* in, unsigned int& tcrc)
assert(in != nullptr); assert(in != nullptr);
unsigned short total = 0U; unsigned short total = 0U;
for (unsigned int i = 0U; i < 72U; i += 8U) { for (unsigned int i = 0U; i < 72U; i += 8U)
{
unsigned char c; unsigned char c;
CUtils::bitsToByteBE(in + i, c); CUtils::bitsToByteBE(in + i, c);
total += c; total += c;
@ -149,7 +156,8 @@ void CCRC::addCCITT162(unsigned char *in, unsigned int length)
assert(in != nullptr); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union
{
uint16_t crc16; uint16_t crc16;
uint8_t crc8[2U]; uint8_t crc8[2U];
}; };
@ -170,7 +178,8 @@ bool CCRC::checkCCITT162(const unsigned char *in, unsigned int length)
assert(in != nullptr); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union
{
uint16_t crc16; uint16_t crc16;
uint8_t crc8[2U]; uint8_t crc8[2U];
}; };
@ -190,7 +199,8 @@ void CCRC::addCCITT161(unsigned char *in, unsigned int length)
assert(in != nullptr); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union
{
uint16_t crc16; uint16_t crc16;
uint8_t crc8[2U]; uint8_t crc8[2U];
}; };
@ -211,7 +221,8 @@ bool CCRC::checkCCITT161(const unsigned char *in, unsigned int length)
assert(in != nullptr); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union
{
uint16_t crc16; uint16_t crc16;
uint8_t crc8[2U]; uint8_t crc8[2U];
}; };

@ -34,12 +34,12 @@ CDcsClient::CDcsClient()
} }
CDcsClient::CDcsClient(const CCallsign &callsign, const CIp &ip, char reflectorModule) CDcsClient::CDcsClient(const CCallsign &callsign, const CIp &ip, char reflectorModule)
: CClient(callsign, ip, reflectorModule) : CClient(callsign, ip, reflectorModule)
{ {
} }
CDcsClient::CDcsClient(const CDcsClient &client) CDcsClient::CDcsClient(const CDcsClient &client)
: CClient(client) : CClient(client)
{ {
} }

@ -39,7 +39,7 @@ CDextraPeer::CDextraPeer()
} }
CDextraPeer::CDextraPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version) CDextraPeer::CDextraPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version)
: CPeer(callsign, ip, modules, version) : CPeer(callsign, ip, modules, version)
{ {
std::cout << "Adding DExtra peer" << std::endl; std::cout << "Adding DExtra peer" << std::endl;

@ -53,7 +53,7 @@ protected:
protected: protected:
// data // data
time_t m_LastModTime; time_t m_LastModTime;
}; };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#endif /* cdmrididirfile_h */ #endif /* cdmrididirfile_h */

@ -154,7 +154,8 @@ bool CDmridDirHttp::HttpGet(const char *hostname, const char *filename, int port
//} //}
done = (len <= 0); done = (len <= 0);
} while (!done); }
while (!done);
buffer->Append((uint8)0); buffer->Append((uint8)0);
// and disconnect // and disconnect

@ -34,12 +34,12 @@ CDmrmmdvmClient::CDmrmmdvmClient()
} }
CDmrmmdvmClient::CDmrmmdvmClient(const CCallsign &callsign, const CIp &ip, char reflectorModule) CDmrmmdvmClient::CDmrmmdvmClient(const CCallsign &callsign, const CIp &ip, char reflectorModule)
: CClient(callsign, ip, reflectorModule) : CClient(callsign, ip, reflectorModule)
{ {
} }
CDmrmmdvmClient::CDmrmmdvmClient(const CDmrmmdvmClient &client) CDmrmmdvmClient::CDmrmmdvmClient(const CDmrmmdvmClient &client)
: CClient(client) : CClient(client)
{ {
} }

@ -34,12 +34,12 @@ CDmrplusClient::CDmrplusClient()
} }
CDmrplusClient::CDmrplusClient(const CCallsign &callsign, const CIp &ip, char reflectorModule) CDmrplusClient::CDmrplusClient(const CCallsign &callsign, const CIp &ip, char reflectorModule)
: CClient(callsign, ip, reflectorModule) : CClient(callsign, ip, reflectorModule)
{ {
} }
CDmrplusClient::CDmrplusClient(const CDmrplusClient &client) CDmrplusClient::CDmrplusClient(const CDmrplusClient &client)
: CClient(client) : CClient(client)
{ {
} }

@ -575,7 +575,8 @@ void CDmrplusProtocol::EncodeConnectNackPacket(CBuffer *Buffer)
bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02, uint8 tag[] = { 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,
0x00,0x05,0x01,0x02,0x00,0x00,0x00 } ; 0x00,0x05,0x01,0x02,0x00,0x00,0x00
} ;
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
// uiSeqId // uiSeqId
@ -619,13 +620,14 @@ bool CDmrplusProtocol::EncodeDvHeaderPacket(const CDvHeaderPacket &Packet, CBuff
} }
void CDmrplusProtocol::EncodeDvPacket void CDmrplusProtocol::EncodeDvPacket
(const CDvHeaderPacket &Header, (const CDvHeaderPacket &Header,
const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2, const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2,
uint8 seqid, CBuffer *Buffer) const uint8 seqid, CBuffer *Buffer) const
{ {
uint8 tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, uint8 tag[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x05,0x01,0x02,0x00,0x00,0x00 } ; 0x00,0x05,0x01,0x02,0x00,0x00,0x00
} ;
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
// uiSeqId // uiSeqId
@ -682,14 +684,14 @@ void CDmrplusProtocol::EncodeDvPacket
void CDmrplusProtocol::EncodeDvLastPacket void CDmrplusProtocol::EncodeDvLastPacket
(const CDvHeaderPacket &Header, (const CDvHeaderPacket &Header,
const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2, const CDvFramePacket &DvFrame0, const CDvFramePacket &DvFrame1, const CDvFramePacket &DvFrame2,
uint8 seqid, CBuffer *Buffer) const uint8 seqid, CBuffer *Buffer) const
{ {
EncodeDvPacket(Header, DvFrame0, DvFrame1, DvFrame2, seqid, Buffer); EncodeDvPacket(Header, DvFrame0, DvFrame1, DvFrame2, seqid, Buffer);
Buffer->ReplaceAt(8, (uint8)3); Buffer->ReplaceAt(8, (uint8)3);
Buffer->ReplaceAt(18, (uint16)0x2222); Buffer->ReplaceAt(18, (uint16)0x2222);
} }
void CDmrplusProtocol::SwapEndianess(uint8 *buffer, int len) const void CDmrplusProtocol::SwapEndianess(uint8 *buffer, int len) const
{ {

@ -184,7 +184,7 @@ void CDplusProtocol::Task(void)
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.Now();
} }
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// streams helpers // streams helpers

@ -69,7 +69,7 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, const uint8 *sync, uint16 sid,
// ysf constructor // ysf constructor
CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 spid, uint8 fid) CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 spid, uint8 fid)
: CPacket(sid, pid, spid, fid) : CPacket(sid, pid, spid, fid)
{ {
::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus)); ::memcpy(m_uiAmbePlus, ambe, sizeof(m_uiAmbePlus));
::memset(m_uiDvSync, 0, sizeof(m_uiDvSync)); ::memset(m_uiDvSync, 0, sizeof(m_uiDvSync));
@ -80,10 +80,10 @@ CDvFramePacket::CDvFramePacket(const uint8 *ambe, uint16 sid, uint8 pid, uint8 s
// xlx constructor // xlx constructor
CDvFramePacket::CDvFramePacket CDvFramePacket::CDvFramePacket
(uint16 sid, (uint16 sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata, uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync) uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync)
: CPacket(sid, dstarpid, dmrpid, dprspid, 0xFF, 0xFF, 0xFF) : CPacket(sid, dstarpid, dmrpid, dprspid, 0xFF, 0xFF, 0xFF)
{ {
::memcpy(m_uiAmbe, dstarambe, sizeof(m_uiAmbe)); ::memcpy(m_uiAmbe, dstarambe, sizeof(m_uiAmbe));
::memcpy(m_uiDvData, dstardvdata, sizeof(m_uiDvData)); ::memcpy(m_uiDvData, dstardvdata, sizeof(m_uiDvData));
@ -107,11 +107,14 @@ const uint8 *CDvFramePacket::GetAmbe(uint8 uiCodec) const
{ {
switch (uiCodec) switch (uiCodec)
{ {
case CODEC_AMBEPLUS: return m_uiAmbe; case CODEC_AMBEPLUS:
return m_uiAmbe;
#ifndef NO_XLX #ifndef NO_XLX
case CODEC_AMBE2PLUS: return m_uiAmbePlus; case CODEC_AMBE2PLUS:
return m_uiAmbePlus;
#endif #endif
default: return nullptr; default:
return nullptr;
} }
} }

@ -49,7 +49,7 @@ struct __attribute__ ((__packed__))dstar_dvframe
class CDvFramePacket : public CPacket class CDvFramePacket : public CPacket
{ {
friend class CCodecStream; friend class CCodecStream;
public: public:
// constructor // constructor
CDvFramePacket(); CDvFramePacket();

@ -74,7 +74,7 @@ CDvHeaderPacket::CDvHeaderPacket(uint32 my, const CCallsign &ur, const CCallsign
// YSF constructor // YSF constructor
CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16 sid, uint8 pid) CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const CCallsign &rpt1, const CCallsign &rpt2, uint16 sid, uint8 pid)
: CPacket(sid, pid, 0, 0) : CPacket(sid, pid, 0, 0)
{ {
m_uiFlag1 = 0; m_uiFlag1 = 0;
m_uiFlag2 = 0; m_uiFlag2 = 0;

@ -51,7 +51,7 @@ CDvLastFramePacket::CDvLastFramePacket(const uint8 *ambe, const uint8 *sync, uin
// dstar + dmr constructor // dstar + dmr constructor
CDvLastFramePacket::CDvLastFramePacket CDvLastFramePacket::CDvLastFramePacket
(uint16 sid, (uint16 sid,
uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata, uint8 dstarpid, const uint8 *dstarambe, const uint8 *dstardvdata,
uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync) uint8 dmrpid, uint8 dprspid, const uint8 *dmrambe, const uint8 *dmrsync)
: CDvFramePacket(sid, dstarpid, dstarambe, dstardvdata, dmrpid, dprspid, dmrambe, dmrsync) : CDvFramePacket(sid, dstarpid, dstarambe, dstardvdata, dmrpid, dprspid, dmrambe, dmrsync)

@ -63,7 +63,8 @@ bool CG3Protocol::Initalize(const char */*type*/, const uint16 /*port*/, const b
//create helper socket //create helper socket
ip.SetPort(G3_PRESENCE_PORT); ip.SetPort(G3_PRESENCE_PORT);
if (! m_PresenceSocket.Open(ip)) { if (! m_PresenceSocket.Open(ip))
{
std::cout << "Error opening socket on port UDP" << G3_PRESENCE_PORT << " on ip " << ip << std::endl; std::cout << "Error opening socket on port UDP" << G3_PRESENCE_PORT << " on ip " << ip << std::endl;
return false; return false;
} }

@ -100,14 +100,14 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, int protocol
case PROTOCOL_DEXTRA: case PROTOCOL_DEXTRA:
case PROTOCOL_DPLUS: case PROTOCOL_DPLUS:
case PROTOCOL_DCS: case PROTOCOL_DCS:
#ifndef NO_XLX #ifndef NO_XLX
case PROTOCOL_DMRPLUS: case PROTOCOL_DMRPLUS:
case PROTOCOL_DMRMMDVM: case PROTOCOL_DMRMMDVM:
case PROTOCOL_YSF: case PROTOCOL_YSF:
#endif #endif
#ifndef NO_G3 #ifndef NO_G3
case PROTOCOL_G3: case PROTOCOL_G3:
#endif #endif
// first check is IP & callsigned listed OK // first check is IP & callsigned listed OK
ok &= IsNodeListedOk(callsign, ip); ok &= IsNodeListedOk(callsign, ip);
// todo: then apply any protocol specific authorisation for the operation // todo: then apply any protocol specific authorisation for the operation

@ -22,7 +22,8 @@
#include <cassert> #include <cassert>
const unsigned int ENCODING_TABLE_2087[] = const unsigned int ENCODING_TABLE_2087[] =
{0x0000U, 0xB08EU, 0xE093U, 0x501DU, 0x70A9U, 0xC027U, 0x903AU, 0x20B4U, 0x60DCU, 0xD052U, 0x804FU, 0x30C1U, {
0x0000U, 0xB08EU, 0xE093U, 0x501DU, 0x70A9U, 0xC027U, 0x903AU, 0x20B4U, 0x60DCU, 0xD052U, 0x804FU, 0x30C1U,
0x1075U, 0xA0FBU, 0xF0E6U, 0x4068U, 0x7036U, 0xC0B8U, 0x90A5U, 0x202BU, 0x009FU, 0xB011U, 0xE00CU, 0x5082U, 0x1075U, 0xA0FBU, 0xF0E6U, 0x4068U, 0x7036U, 0xC0B8U, 0x90A5U, 0x202BU, 0x009FU, 0xB011U, 0xE00CU, 0x5082U,
0x10EAU, 0xA064U, 0xF079U, 0x40F7U, 0x6043U, 0xD0CDU, 0x80D0U, 0x305EU, 0xD06CU, 0x60E2U, 0x30FFU, 0x8071U, 0x10EAU, 0xA064U, 0xF079U, 0x40F7U, 0x6043U, 0xD0CDU, 0x80D0U, 0x305EU, 0xD06CU, 0x60E2U, 0x30FFU, 0x8071U,
0xA0C5U, 0x104BU, 0x4056U, 0xF0D8U, 0xB0B0U, 0x003EU, 0x5023U, 0xE0ADU, 0xC019U, 0x7097U, 0x208AU, 0x9004U, 0xA0C5U, 0x104BU, 0x4056U, 0xF0D8U, 0xB0B0U, 0x003EU, 0x5023U, 0xE0ADU, 0xC019U, 0x7097U, 0x208AU, 0x9004U,
@ -43,10 +44,12 @@ const unsigned int ENCODING_TABLE_2087[] =
0x200EU, 0x9080U, 0xC09DU, 0x7013U, 0x50A7U, 0xE029U, 0xB034U, 0x00BAU, 0xE088U, 0x5006U, 0x001BU, 0xB095U, 0x200EU, 0x9080U, 0xC09DU, 0x7013U, 0x50A7U, 0xE029U, 0xB034U, 0x00BAU, 0xE088U, 0x5006U, 0x001BU, 0xB095U,
0x9021U, 0x20AFU, 0x70B2U, 0xC03CU, 0x8054U, 0x30DAU, 0x60C7U, 0xD049U, 0xF0FDU, 0x4073U, 0x106EU, 0xA0E0U, 0x9021U, 0x20AFU, 0x70B2U, 0xC03CU, 0x8054U, 0x30DAU, 0x60C7U, 0xD049U, 0xF0FDU, 0x4073U, 0x106EU, 0xA0E0U,
0x90BEU, 0x2030U, 0x702DU, 0xC0A3U, 0xE017U, 0x5099U, 0x0084U, 0xB00AU, 0xF062U, 0x40ECU, 0x10F1U, 0xA07FU, 0x90BEU, 0x2030U, 0x702DU, 0xC0A3U, 0xE017U, 0x5099U, 0x0084U, 0xB00AU, 0xF062U, 0x40ECU, 0x10F1U, 0xA07FU,
0x80CBU, 0x3045U, 0x6058U, 0xD0D6U}; 0x80CBU, 0x3045U, 0x6058U, 0xD0D6U
};
const unsigned int DECODING_TABLE_1987[] = const unsigned int DECODING_TABLE_1987[] =
{0x00000U, 0x00001U, 0x00002U, 0x00003U, 0x00004U, 0x00005U, 0x00006U, 0x00007U, 0x00008U, 0x00009U, 0x0000AU, 0x0000BU, 0x0000CU, {
0x00000U, 0x00001U, 0x00002U, 0x00003U, 0x00004U, 0x00005U, 0x00006U, 0x00007U, 0x00008U, 0x00009U, 0x0000AU, 0x0000BU, 0x0000CU,
0x0000DU, 0x0000EU, 0x24020U, 0x00010U, 0x00011U, 0x00012U, 0x00013U, 0x00014U, 0x00015U, 0x00016U, 0x00017U, 0x00018U, 0x00019U, 0x0000DU, 0x0000EU, 0x24020U, 0x00010U, 0x00011U, 0x00012U, 0x00013U, 0x00014U, 0x00015U, 0x00016U, 0x00017U, 0x00018U, 0x00019U,
0x0001AU, 0x0001BU, 0x0001CU, 0x0001DU, 0x48040U, 0x01480U, 0x00020U, 0x00021U, 0x00022U, 0x00023U, 0x00024U, 0x00025U, 0x00026U, 0x0001AU, 0x0001BU, 0x0001CU, 0x0001DU, 0x48040U, 0x01480U, 0x00020U, 0x00021U, 0x00022U, 0x00023U, 0x00024U, 0x00025U, 0x00026U,
0x24008U, 0x00028U, 0x00029U, 0x0002AU, 0x24004U, 0x0002CU, 0x24002U, 0x24001U, 0x24000U, 0x00030U, 0x00031U, 0x00032U, 0x08180U, 0x24008U, 0x00028U, 0x00029U, 0x0002AU, 0x24004U, 0x0002CU, 0x24002U, 0x24001U, 0x24000U, 0x00030U, 0x00031U, 0x00032U, 0x08180U,
@ -203,7 +206,8 @@ const unsigned int DECODING_TABLE_1987[] =
0x0C082U, 0x04130U, 0x0C084U, 0x06808U, 0x08A10U, 0x08A11U, 0x11021U, 0x11020U, 0x11023U, 0x11022U, 0x20110U, 0x06800U, 0x20112U, 0x0C082U, 0x04130U, 0x0C084U, 0x06808U, 0x08A10U, 0x08A11U, 0x11021U, 0x11020U, 0x11023U, 0x11022U, 0x20110U, 0x06800U, 0x20112U,
0x06802U, 0x04103U, 0x04102U, 0x04101U, 0x04100U, 0x10482U, 0x04106U, 0x10480U, 0x04104U, 0x11011U, 0x11010U, 0x04109U, 0x04108U, 0x06802U, 0x04103U, 0x04102U, 0x04101U, 0x04100U, 0x10482U, 0x04106U, 0x10480U, 0x04104U, 0x11011U, 0x11010U, 0x04109U, 0x04108U,
0x20120U, 0x40600U, 0x20122U, 0x40602U, 0x11009U, 0x11008U, 0x22800U, 0x04110U, 0x1100DU, 0x1100CU, 0x22804U, 0x04114U, 0x11001U, 0x20120U, 0x40600U, 0x20122U, 0x40602U, 0x11009U, 0x11008U, 0x22800U, 0x04110U, 0x1100DU, 0x1100CU, 0x22804U, 0x04114U, 0x11001U,
0x11000U, 0x11003U, 0x11002U, 0x11005U, 0x11004U, 0x28081U, 0x28080U}; 0x11000U, 0x11003U, 0x11002U, 0x11005U, 0x11004U, 0x28081U, 0x28080U
};
#define X18 0x00040000 /* vector representation of X^{18} */ #define X18 0x00040000 /* vector representation of X^{18} */
#define X11 0x00000800 /* vector representation of X^{11} */ #define X11 0x00000800 /* vector representation of X^{11} */
@ -223,8 +227,10 @@ unsigned int CGolay2087::getSyndrome1987(unsigned int pattern)
{ {
unsigned int aux = X18; unsigned int aux = X18;
if (pattern >= X11) { if (pattern >= X11)
while (pattern & MASK8) { {
while (pattern & MASK8)
{
while (!(aux & pattern)) while (!(aux & pattern))
aux = aux >> 1; aux = aux >> 1;

@ -19,7 +19,8 @@
#ifndef Golay2087_H #ifndef Golay2087_H
#define Golay2087_H #define Golay2087_H
class CGolay2087 { class CGolay2087
{
public: public:
static void encode(unsigned char* data); static void encode(unsigned char* data);

@ -8,7 +8,8 @@
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
const unsigned int ENCODING_TABLE_23127[] = { const unsigned int ENCODING_TABLE_23127[] =
{
0x000000U, 0x0018EAU, 0x00293EU, 0x0031D4U, 0x004A96U, 0x00527CU, 0x0063A8U, 0x007B42U, 0x008DC6U, 0x00952CU, 0x000000U, 0x0018EAU, 0x00293EU, 0x0031D4U, 0x004A96U, 0x00527CU, 0x0063A8U, 0x007B42U, 0x008DC6U, 0x00952CU,
0x00A4F8U, 0x00BC12U, 0x00C750U, 0x00DFBAU, 0x00EE6EU, 0x00F684U, 0x010366U, 0x011B8CU, 0x012A58U, 0x0132B2U, 0x00A4F8U, 0x00BC12U, 0x00C750U, 0x00DFBAU, 0x00EE6EU, 0x00F684U, 0x010366U, 0x011B8CU, 0x012A58U, 0x0132B2U,
0x0149F0U, 0x01511AU, 0x0160CEU, 0x017824U, 0x018EA0U, 0x01964AU, 0x01A79EU, 0x01BF74U, 0x01C436U, 0x01DCDCU, 0x0149F0U, 0x01511AU, 0x0160CEU, 0x017824U, 0x018EA0U, 0x01964AU, 0x01A79EU, 0x01BF74U, 0x01C436U, 0x01DCDCU,
@ -418,9 +419,11 @@ const unsigned int ENCODING_TABLE_23127[] = {
0xFDC8E6U, 0xFDD00CU, 0xFDE1D8U, 0xFDF932U, 0xFE0A1CU, 0xFE12F6U, 0xFE2322U, 0xFE3BC8U, 0xFE408AU, 0xFE5860U, 0xFDC8E6U, 0xFDD00CU, 0xFDE1D8U, 0xFDF932U, 0xFE0A1CU, 0xFE12F6U, 0xFE2322U, 0xFE3BC8U, 0xFE408AU, 0xFE5860U,
0xFE69B4U, 0xFE715EU, 0xFE87DAU, 0xFE9F30U, 0xFEAEE4U, 0xFEB60EU, 0xFECD4CU, 0xFED5A6U, 0xFEE472U, 0xFEFC98U, 0xFE69B4U, 0xFE715EU, 0xFE87DAU, 0xFE9F30U, 0xFEAEE4U, 0xFEB60EU, 0xFECD4CU, 0xFED5A6U, 0xFEE472U, 0xFEFC98U,
0xFF097AU, 0xFF1190U, 0xFF2044U, 0xFF38AEU, 0xFF43ECU, 0xFF5B06U, 0xFF6AD2U, 0xFF7238U, 0xFF84BCU, 0xFF9C56U, 0xFF097AU, 0xFF1190U, 0xFF2044U, 0xFF38AEU, 0xFF43ECU, 0xFF5B06U, 0xFF6AD2U, 0xFF7238U, 0xFF84BCU, 0xFF9C56U,
0xFFAD82U, 0xFFB568U, 0xFFCE2AU, 0xFFD6C0U, 0xFFE714U, 0xFFFFFEU}; 0xFFAD82U, 0xFFB568U, 0xFFCE2AU, 0xFFD6C0U, 0xFFE714U, 0xFFFFFEU
};
static const unsigned int ENCODING_TABLE_24128[] = { static const unsigned int ENCODING_TABLE_24128[] =
{
0x000000U, 0x0018EBU, 0x00293EU, 0x0031D5U, 0x004A97U, 0x00527CU, 0x0063A9U, 0x007B42U, 0x008DC6U, 0x00952DU, 0x000000U, 0x0018EBU, 0x00293EU, 0x0031D5U, 0x004A97U, 0x00527CU, 0x0063A9U, 0x007B42U, 0x008DC6U, 0x00952DU,
0x00A4F8U, 0x00BC13U, 0x00C751U, 0x00DFBAU, 0x00EE6FU, 0x00F684U, 0x010367U, 0x011B8CU, 0x012A59U, 0x0132B2U, 0x00A4F8U, 0x00BC13U, 0x00C751U, 0x00DFBAU, 0x00EE6FU, 0x00F684U, 0x010367U, 0x011B8CU, 0x012A59U, 0x0132B2U,
0x0149F0U, 0x01511BU, 0x0160CEU, 0x017825U, 0x018EA1U, 0x01964AU, 0x01A79FU, 0x01BF74U, 0x01C436U, 0x01DCDDU, 0x0149F0U, 0x01511BU, 0x0160CEU, 0x017825U, 0x018EA1U, 0x01964AU, 0x01A79FU, 0x01BF74U, 0x01C436U, 0x01DCDDU,
@ -830,9 +833,11 @@ static const unsigned int ENCODING_TABLE_24128[] = {
0xFDC8E7U, 0xFDD00CU, 0xFDE1D9U, 0xFDF932U, 0xFE0A1CU, 0xFE12F7U, 0xFE2322U, 0xFE3BC9U, 0xFE408BU, 0xFE5860U, 0xFDC8E7U, 0xFDD00CU, 0xFDE1D9U, 0xFDF932U, 0xFE0A1CU, 0xFE12F7U, 0xFE2322U, 0xFE3BC9U, 0xFE408BU, 0xFE5860U,
0xFE69B5U, 0xFE715EU, 0xFE87DAU, 0xFE9F31U, 0xFEAEE4U, 0xFEB60FU, 0xFECD4DU, 0xFED5A6U, 0xFEE473U, 0xFEFC98U, 0xFE69B5U, 0xFE715EU, 0xFE87DAU, 0xFE9F31U, 0xFEAEE4U, 0xFEB60FU, 0xFECD4DU, 0xFED5A6U, 0xFEE473U, 0xFEFC98U,
0xFF097BU, 0xFF1190U, 0xFF2045U, 0xFF38AEU, 0xFF43ECU, 0xFF5B07U, 0xFF6AD2U, 0xFF7239U, 0xFF84BDU, 0xFF9C56U, 0xFF097BU, 0xFF1190U, 0xFF2045U, 0xFF38AEU, 0xFF43ECU, 0xFF5B07U, 0xFF6AD2U, 0xFF7239U, 0xFF84BDU, 0xFF9C56U,
0xFFAD83U, 0xFFB568U, 0xFFCE2AU, 0xFFD6C1U, 0xFFE714U, 0xFFFFFFU}; 0xFFAD83U, 0xFFB568U, 0xFFCE2AU, 0xFFD6C1U, 0xFFE714U, 0xFFFFFFU
};
static const unsigned int DECODING_TABLE_23127[] = { static const unsigned int DECODING_TABLE_23127[] =
{
0x000000U, 0x000001U, 0x000002U, 0x000003U, 0x000004U, 0x000005U, 0x000006U, 0x000007U, 0x000008U, 0x000009U, 0x000000U, 0x000001U, 0x000002U, 0x000003U, 0x000004U, 0x000005U, 0x000006U, 0x000007U, 0x000008U, 0x000009U,
0x00000AU, 0x00000BU, 0x00000CU, 0x00000DU, 0x00000EU, 0x024020U, 0x000010U, 0x000011U, 0x000012U, 0x000013U, 0x00000AU, 0x00000BU, 0x00000CU, 0x00000DU, 0x00000EU, 0x024020U, 0x000010U, 0x000011U, 0x000012U, 0x000013U,
0x000014U, 0x000015U, 0x000016U, 0x412000U, 0x000018U, 0x000019U, 0x00001AU, 0x180800U, 0x00001CU, 0x200300U, 0x000014U, 0x000015U, 0x000016U, 0x412000U, 0x000018U, 0x000019U, 0x00001AU, 0x180800U, 0x00001CU, 0x200300U,
@ -1037,7 +1042,8 @@ static const unsigned int DECODING_TABLE_23127[] = {
0x080400U, 0x080401U, 0x020110U, 0x006800U, 0x080404U, 0x440008U, 0x480200U, 0x004102U, 0x004101U, 0x004100U, 0x080400U, 0x080401U, 0x020110U, 0x006800U, 0x080404U, 0x440008U, 0x480200U, 0x004102U, 0x004101U, 0x004100U,
0x100050U, 0x20A000U, 0x010480U, 0x004104U, 0x200880U, 0x011010U, 0x148000U, 0x004108U, 0x020120U, 0x040600U, 0x100050U, 0x20A000U, 0x010480U, 0x004104U, 0x200880U, 0x011010U, 0x148000U, 0x004108U, 0x020120U, 0x040600U,
0x403000U, 0x080840U, 0x100044U, 0x011008U, 0x022800U, 0x004110U, 0x100040U, 0x100041U, 0x100042U, 0x440020U, 0x403000U, 0x080840U, 0x100044U, 0x011008U, 0x022800U, 0x004110U, 0x100040U, 0x100041U, 0x100042U, 0x440020U,
0x011001U, 0x011000U, 0x080420U, 0x011002U, 0x100048U, 0x011004U, 0x204200U, 0x028080U}; 0x011001U, 0x011000U, 0x080420U, 0x011002U, 0x100048U, 0x011004U, 0x204200U, 0x028080U
};
#define X22 0x00400000 /* vector representation of X^{22} */ #define X22 0x00400000 /* vector representation of X^{22} */
#define X11 0x00000800 /* vector representation of X^{11} */ #define X11 0x00000800 /* vector representation of X^{11} */
@ -1057,8 +1063,10 @@ static unsigned int get_syndrome_23127(unsigned int pattern)
{ {
unsigned int aux = X22; unsigned int aux = X22;
if (pattern >= X11) { if (pattern >= X11)
while (pattern & MASK12) { {
while (pattern & MASK12)
{
while (!(aux & pattern)) while (!(aux & pattern))
aux = aux >> 1; aux = aux >> 1;

@ -19,7 +19,8 @@
#ifndef Golay24128_H #ifndef Golay24128_H
#define Golay24128_H #define Golay24128_H
class CGolay24128 { class CGolay24128
{
public: public:
static unsigned int encode23127(unsigned int data); static unsigned int encode23127(unsigned int data);
static unsigned int encode24128(unsigned int data); static unsigned int encode24128(unsigned int data);

@ -41,26 +41,57 @@ bool CHamming::decode15113_1(bool* d)
switch (n) switch (n)
{ {
// Parity bit errors // Parity bit errors
case 0x01U: d[11] = !d[11]; return true; case 0x01U:
case 0x02U: d[12] = !d[12]; return true; d[11] = !d[11];
case 0x04U: d[13] = !d[13]; return true; return true;
case 0x08U: d[14] = !d[14]; return true; case 0x02U:
d[12] = !d[12];
return true;
case 0x04U:
d[13] = !d[13];
return true;
case 0x08U:
d[14] = !d[14];
return true;
// Data bit errors // Data bit errors
case 0x0FU: d[0] = !d[0]; return true; case 0x0FU:
case 0x07U: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x0BU: d[2] = !d[2]; return true; return true;
case 0x03U: d[3] = !d[3]; return true; case 0x07U:
case 0x0DU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x05U: d[5] = !d[5]; return true; return true;
case 0x09U: d[6] = !d[6]; return true; case 0x0BU:
case 0x0EU: d[7] = !d[7]; return true; d[2] = !d[2];
case 0x06U: d[8] = !d[8]; return true; return true;
case 0x0AU: d[9] = !d[9]; return true; case 0x03U:
case 0x0CU: d[10] = !d[10]; return true; d[3] = !d[3];
return true;
case 0x0DU:
d[4] = !d[4];
return true;
case 0x05U:
d[5] = !d[5];
return true;
case 0x09U:
d[6] = !d[6];
return true;
case 0x0EU:
d[7] = !d[7];
return true;
case 0x06U:
d[8] = !d[8];
return true;
case 0x0AU:
d[9] = !d[9];
return true;
case 0x0CU:
d[10] = !d[10];
return true;
// No bit errors // No bit errors
default: return false; default:
return false;
} }
} }
@ -92,28 +123,60 @@ bool CHamming::decode15113_2(bool* d)
n |= (c2 != d[13]) ? 0x04U : 0x00U; n |= (c2 != d[13]) ? 0x04U : 0x00U;
n |= (c3 != d[14]) ? 0x08U : 0x00U; n |= (c3 != d[14]) ? 0x08U : 0x00U;
switch (n) { switch (n)
{
// Parity bit errors // Parity bit errors
case 0x01U: d[11] = !d[11]; return true; case 0x01U:
case 0x02U: d[12] = !d[12]; return true; d[11] = !d[11];
case 0x04U: d[13] = !d[13]; return true; return true;
case 0x08U: d[14] = !d[14]; return true; case 0x02U:
d[12] = !d[12];
return true;
case 0x04U:
d[13] = !d[13];
return true;
case 0x08U:
d[14] = !d[14];
return true;
// Data bit errors // Data bit errors
case 0x09U: d[0] = !d[0]; return true; case 0x09U:
case 0x0BU: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x0FU: d[2] = !d[2]; return true; return true;
case 0x07U: d[3] = !d[3]; return true; case 0x0BU:
case 0x0EU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x05U: d[5] = !d[5]; return true; return true;
case 0x0AU: d[6] = !d[6]; return true; case 0x0FU:
case 0x0DU: d[7] = !d[7]; return true; d[2] = !d[2];
case 0x03U: d[8] = !d[8]; return true; return true;
case 0x06U: d[9] = !d[9]; return true; case 0x07U:
case 0x0CU: d[10] = !d[10]; return true; d[3] = !d[3];
return true;
case 0x0EU:
d[4] = !d[4];
return true;
case 0x05U:
d[5] = !d[5];
return true;
case 0x0AU:
d[6] = !d[6];
return true;
case 0x0DU:
d[7] = !d[7];
return true;
case 0x03U:
d[8] = !d[8];
return true;
case 0x06U:
d[9] = !d[9];
return true;
case 0x0CU:
d[10] = !d[10];
return true;
// No bit errors // No bit errors
default: return false; default:
return false;
} }
} }
@ -145,26 +208,54 @@ bool CHamming::decode1393(bool* d)
n |= (c2 != d[11]) ? 0x04U : 0x00U; n |= (c2 != d[11]) ? 0x04U : 0x00U;
n |= (c3 != d[12]) ? 0x08U : 0x00U; n |= (c3 != d[12]) ? 0x08U : 0x00U;
switch (n) { switch (n)
{
// Parity bit errors // Parity bit errors
case 0x01U: d[9] = !d[9]; return true; case 0x01U:
case 0x02U: d[10] = !d[10]; return true; d[9] = !d[9];
case 0x04U: d[11] = !d[11]; return true; return true;
case 0x08U: d[12] = !d[12]; return true; case 0x02U:
d[10] = !d[10];
return true;
case 0x04U:
d[11] = !d[11];
return true;
case 0x08U:
d[12] = !d[12];
return true;
// Data bit erros // Data bit erros
case 0x0FU: d[0] = !d[0]; return true; case 0x0FU:
case 0x07U: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x0EU: d[2] = !d[2]; return true; return true;
case 0x05U: d[3] = !d[3]; return true; case 0x07U:
case 0x0AU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x0DU: d[5] = !d[5]; return true; return true;
case 0x03U: d[6] = !d[6]; return true; case 0x0EU:
case 0x06U: d[7] = !d[7]; return true; d[2] = !d[2];
case 0x0CU: d[8] = !d[8]; return true; return true;
case 0x05U:
d[3] = !d[3];
return true;
case 0x0AU:
d[4] = !d[4];
return true;
case 0x0DU:
d[5] = !d[5];
return true;
case 0x03U:
d[6] = !d[6];
return true;
case 0x06U:
d[7] = !d[7];
return true;
case 0x0CU:
d[8] = !d[8];
return true;
// No bit errors // No bit errors
default: return false; default:
return false;
} }
} }
@ -196,23 +287,45 @@ bool CHamming::decode1063(bool* d)
n |= (c2 != d[8]) ? 0x04U : 0x00U; n |= (c2 != d[8]) ? 0x04U : 0x00U;
n |= (c3 != d[9]) ? 0x08U : 0x00U; n |= (c3 != d[9]) ? 0x08U : 0x00U;
switch (n) { switch (n)
{
// Parity bit errors // Parity bit errors
case 0x01U: d[6] = !d[6]; return true; case 0x01U:
case 0x02U: d[7] = !d[7]; return true; d[6] = !d[6];
case 0x04U: d[8] = !d[8]; return true; return true;
case 0x08U: d[9] = !d[9]; return true; case 0x02U:
d[7] = !d[7];
return true;
case 0x04U:
d[8] = !d[8];
return true;
case 0x08U:
d[9] = !d[9];
return true;
// Data bit erros // Data bit erros
case 0x07U: d[0] = !d[0]; return true; case 0x07U:
case 0x0BU: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x0DU: d[2] = !d[2]; return true; return true;
case 0x0EU: d[3] = !d[3]; return true; case 0x0BU:
case 0x0CU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x03U: d[5] = !d[5]; return true; return true;
case 0x0DU:
d[2] = !d[2];
return true;
case 0x0EU:
d[3] = !d[3];
return true;
case 0x0CU:
d[4] = !d[4];
return true;
case 0x03U:
d[5] = !d[5];
return true;
// No bit errors // No bit errors
default: return false; default:
return false;
} }
} }
@ -247,32 +360,67 @@ bool CHamming::decode16114(bool* d)
n |= (c3 != d[14]) ? 0x08U : 0x00U; n |= (c3 != d[14]) ? 0x08U : 0x00U;
n |= (c4 != d[15]) ? 0x10U : 0x00U; n |= (c4 != d[15]) ? 0x10U : 0x00U;
switch (n) { switch (n)
{
// Parity bit errors // Parity bit errors
case 0x01U: d[11] = !d[11]; return true; case 0x01U:
case 0x02U: d[12] = !d[12]; return true; d[11] = !d[11];
case 0x04U: d[13] = !d[13]; return true; return true;
case 0x08U: d[14] = !d[14]; return true; case 0x02U:
case 0x10U: d[15] = !d[15]; return true; d[12] = !d[12];
return true;
case 0x04U:
d[13] = !d[13];
return true;
case 0x08U:
d[14] = !d[14];
return true;
case 0x10U:
d[15] = !d[15];
return true;
// Data bit errors // Data bit errors
case 0x19U: d[0] = !d[0]; return true; case 0x19U:
case 0x0BU: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x1FU: d[2] = !d[2]; return true; return true;
case 0x07U: d[3] = !d[3]; return true; case 0x0BU:
case 0x0EU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x15U: d[5] = !d[5]; return true; return true;
case 0x1AU: d[6] = !d[6]; return true; case 0x1FU:
case 0x0DU: d[7] = !d[7]; return true; d[2] = !d[2];
case 0x13U: d[8] = !d[8]; return true; return true;
case 0x16U: d[9] = !d[9]; return true; case 0x07U:
case 0x1CU: d[10] = !d[10]; return true; d[3] = !d[3];
return true;
case 0x0EU:
d[4] = !d[4];
return true;
case 0x15U:
d[5] = !d[5];
return true;
case 0x1AU:
d[6] = !d[6];
return true;
case 0x0DU:
d[7] = !d[7];
return true;
case 0x13U:
d[8] = !d[8];
return true;
case 0x16U:
d[9] = !d[9];
return true;
case 0x1CU:
d[10] = !d[10];
return true;
// No bit errors // No bit errors
case 0x00U: return true; case 0x00U:
return true;
// Unrecoverable errors // Unrecoverable errors
default: return false; default:
return false;
} }
} }
@ -307,33 +455,70 @@ bool CHamming::decode17123(bool* d)
n |= (c3 != d[15]) ? 0x08U : 0x00U; n |= (c3 != d[15]) ? 0x08U : 0x00U;
n |= (c4 != d[16]) ? 0x10U : 0x00U; n |= (c4 != d[16]) ? 0x10U : 0x00U;
switch (n) { switch (n)
{
// Parity bit errors // Parity bit errors
case 0x01U: d[12] = !d[12]; return true; case 0x01U:
case 0x02U: d[13] = !d[13]; return true; d[12] = !d[12];
case 0x04U: d[14] = !d[14]; return true; return true;
case 0x08U: d[15] = !d[15]; return true; case 0x02U:
case 0x10U: d[16] = !d[16]; return true; d[13] = !d[13];
return true;
case 0x04U:
d[14] = !d[14];
return true;
case 0x08U:
d[15] = !d[15];
return true;
case 0x10U:
d[16] = !d[16];
return true;
// Data bit errors // Data bit errors
case 0x1BU: d[0] = !d[0]; return true; case 0x1BU:
case 0x1FU: d[1] = !d[1]; return true; d[0] = !d[0];
case 0x17U: d[2] = !d[2]; return true; return true;
case 0x07U: d[3] = !d[3]; return true; case 0x1FU:
case 0x0EU: d[4] = !d[4]; return true; d[1] = !d[1];
case 0x1CU: d[5] = !d[5]; return true; return true;
case 0x11U: d[6] = !d[6]; return true; case 0x17U:
case 0x0BU: d[7] = !d[7]; return true; d[2] = !d[2];
case 0x16U: d[8] = !d[8]; return true; return true;
case 0x05U: d[9] = !d[9]; return true; case 0x07U:
case 0x0AU: d[10] = !d[10]; return true; d[3] = !d[3];
case 0x14U: d[11] = !d[11]; return true; return true;
case 0x0EU:
d[4] = !d[4];
return true;
case 0x1CU:
d[5] = !d[5];
return true;
case 0x11U:
d[6] = !d[6];
return true;
case 0x0BU:
d[7] = !d[7];
return true;
case 0x16U:
d[8] = !d[8];
return true;
case 0x05U:
d[9] = !d[9];
return true;
case 0x0AU:
d[10] = !d[10];
return true;
case 0x14U:
d[11] = !d[11];
return true;
// No bit errors // No bit errors
case 0x00U: return true; case 0x00U:
return true;
// Unrecoverable errors // Unrecoverable errors
default: return false; default:
return false;
} }
} }

@ -19,7 +19,8 @@
#ifndef Hamming_H #ifndef Hamming_H
#define Hamming_H #define Hamming_H
class CHamming { class CHamming
{
public: public:
static void encode15113_1(bool* d); static void encode15113_1(bool* d);
static bool decode15113_1(bool* d); static bool decode15113_1(bool* d);

@ -39,7 +39,8 @@ CIp::CIp(const char *address, int family, int type, uint16_t port) : is_set(true
bzero(&hints, sizeof(struct addrinfo)); bzero(&hints, sizeof(struct addrinfo));
hints.ai_family = family; hints.ai_family = family;
hints.ai_socktype = type; hints.ai_socktype = type;
if (0 == getaddrinfo(address, (port ? std::to_string(port).c_str() : nullptr), &hints, &result)) { if (0 == getaddrinfo(address, (port ? std::to_string(port).c_str() : nullptr), &hints, &result))
{
memcpy(&addr, result->ai_addr, result->ai_addrlen); memcpy(&addr, result->ai_addr, result->ai_addrlen);
addr.ss_family = result->ai_family; addr.ss_family = result->ai_family;
freeaddrinfo(result); freeaddrinfo(result);
@ -248,7 +249,8 @@ uint16_t CIp::GetPort() const
{ {
auto addr6 = (struct sockaddr_in6 *)&addr; auto addr6 = (struct sockaddr_in6 *)&addr;
return ntohs(addr6->sin6_port); return ntohs(addr6->sin6_port);
} else }
else
return 0; return 0;
} }

@ -103,7 +103,7 @@ bool CPeer::IsAMaster(void) const
void CPeer::Alive(void) void CPeer::Alive(void)
{ {
m_LastKeepaliveTime.Now();; m_LastKeepaliveTime.Now();
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
(*it)->Alive(); (*it)->Alive();

@ -64,8 +64,7 @@ void CPeers::AddPeer(std::shared_ptr<CPeer> peer)
// if not, append to the vector // if not, append to the vector
m_Peers.push_back(peer); m_Peers.push_back(peer);
std::cout << "New peer " << peer->GetCallsign() << " at " << peer->GetIp() std::cout << "New peer " << peer->GetCallsign() << " at " << peer->GetIp() << " added with protocol " << peer->GetProtocolName() << std::endl;
<< " added with protocol " << peer->GetProtocolName() << std::endl;
// and append all peer's client to reflector client list // and append all peer's client to reflector client list
// it is double lock safe to lock Clients list after Peers list // it is double lock safe to lock Clients list after Peers list
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
@ -132,9 +131,7 @@ std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, const CIp &Ip
{ {
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && ((*it)->GetIp() == Ip) && ((*it)->GetProtocol() == Protocol) )
((*it)->GetIp() == Ip) &&
((*it)->GetProtocol() == Protocol) )
{ {
return *it; return *it;
} }
@ -147,8 +144,7 @@ std::shared_ptr<CPeer> CPeers::FindPeer(const CCallsign &Callsign, int Protocol)
{ {
for ( auto it=begin(); it!=end(); it++ ) for ( auto it=begin(); it!=end(); it++ )
{ {
if ( ((*it)->GetProtocol() == Protocol) && if ( ((*it)->GetProtocol() == Protocol) && (*it)->GetCallsign().HasSameCallsign(Callsign) )
(*it)->GetCallsign().HasSameCallsign(Callsign) )
{ {
return *it; return *it;
} }

@ -357,7 +357,8 @@ bool CProtocol::ReceiveDS(CBuffer &buf, CIp &ip, int time_ms)
void CProtocol::Send(const CBuffer &buf, const CIp &Ip) const void CProtocol::Send(const CBuffer &buf, const CIp &Ip) const
{ {
switch (Ip.GetFamily()) { switch (Ip.GetFamily())
{
case AF_INET: case AF_INET:
m_Socket4.Send(buf, Ip); m_Socket4.Send(buf, Ip);
break; break;
@ -372,7 +373,8 @@ void CProtocol::Send(const CBuffer &buf, const CIp &Ip) const
void CProtocol::Send(const char *buf, const CIp &Ip) const void CProtocol::Send(const char *buf, const CIp &Ip) const
{ {
switch (Ip.GetFamily()) { switch (Ip.GetFamily())
{
case AF_INET: case AF_INET:
m_Socket4.Send(buf, Ip); m_Socket4.Send(buf, Ip);
break; break;
@ -387,7 +389,8 @@ void CProtocol::Send(const char *buf, const CIp &Ip) const
void CProtocol::Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const void CProtocol::Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const
{ {
switch (Ip.GetFamily()) { switch (Ip.GetFamily())
{
case AF_INET: case AF_INET:
m_Socket4.Send(buf, Ip, port); m_Socket4.Send(buf, Ip, port);
break; break;
@ -402,7 +405,8 @@ void CProtocol::Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const
void CProtocol::Send(const char *buf, const CIp &Ip, uint16_t port) const void CProtocol::Send(const char *buf, const CIp &Ip, uint16_t port) const
{ {
switch (Ip.GetFamily()) { switch (Ip.GetFamily())
{
case AF_INET: case AF_INET:
m_Socket4.Send(buf, Ip, port); m_Socket4.Send(buf, Ip, port);
break; break;

@ -22,7 +22,8 @@
#include <cassert> #include <cassert>
const unsigned int ENCODING_TABLE_1676[] = const unsigned int ENCODING_TABLE_1676[] =
{0x0000U, 0x0273U, 0x04E5U, 0x0696U, 0x09C9U, 0x0BBAU, 0x0D2CU, 0x0F5FU, 0x11E2U, 0x1391U, 0x1507U, 0x1774U, {
0x0000U, 0x0273U, 0x04E5U, 0x0696U, 0x09C9U, 0x0BBAU, 0x0D2CU, 0x0F5FU, 0x11E2U, 0x1391U, 0x1507U, 0x1774U,
0x182BU, 0x1A58U, 0x1CCEU, 0x1EBDU, 0x21B7U, 0x23C4U, 0x2552U, 0x2721U, 0x287EU, 0x2A0DU, 0x2C9BU, 0x2EE8U, 0x182BU, 0x1A58U, 0x1CCEU, 0x1EBDU, 0x21B7U, 0x23C4U, 0x2552U, 0x2721U, 0x287EU, 0x2A0DU, 0x2C9BU, 0x2EE8U,
0x3055U, 0x3226U, 0x34B0U, 0x36C3U, 0x399CU, 0x3BEFU, 0x3D79U, 0x3F0AU, 0x411EU, 0x436DU, 0x45FBU, 0x4788U, 0x3055U, 0x3226U, 0x34B0U, 0x36C3U, 0x399CU, 0x3BEFU, 0x3D79U, 0x3F0AU, 0x411EU, 0x436DU, 0x45FBU, 0x4788U,
0x48D7U, 0x4AA4U, 0x4C32U, 0x4E41U, 0x50FCU, 0x528FU, 0x5419U, 0x566AU, 0x5935U, 0x5B46U, 0x5DD0U, 0x5FA3U, 0x48D7U, 0x4AA4U, 0x4C32U, 0x4E41U, 0x50FCU, 0x528FU, 0x5419U, 0x566AU, 0x5935U, 0x5B46U, 0x5DD0U, 0x5FA3U,
@ -32,10 +33,12 @@ const unsigned int ENCODING_TABLE_1676[] =
0xA831U, 0xAA42U, 0xACD4U, 0xAEA7U, 0xB01AU, 0xB269U, 0xB4FFU, 0xB68CU, 0xB9D3U, 0xBBA0U, 0xBD36U, 0xBF45U, 0xA831U, 0xAA42U, 0xACD4U, 0xAEA7U, 0xB01AU, 0xB269U, 0xB4FFU, 0xB68CU, 0xB9D3U, 0xBBA0U, 0xBD36U, 0xBF45U,
0xC151U, 0xC322U, 0xC5B4U, 0xC7C7U, 0xC898U, 0xCAEBU, 0xCC7DU, 0xCE0EU, 0xD0B3U, 0xD2C0U, 0xD456U, 0xD625U, 0xC151U, 0xC322U, 0xC5B4U, 0xC7C7U, 0xC898U, 0xCAEBU, 0xCC7DU, 0xCE0EU, 0xD0B3U, 0xD2C0U, 0xD456U, 0xD625U,
0xD97AU, 0xDB09U, 0xDD9FU, 0xDFECU, 0xE0E6U, 0xE295U, 0xE403U, 0xE670U, 0xE92FU, 0xEB5CU, 0xEDCAU, 0xEFB9U, 0xD97AU, 0xDB09U, 0xDD9FU, 0xDFECU, 0xE0E6U, 0xE295U, 0xE403U, 0xE670U, 0xE92FU, 0xEB5CU, 0xEDCAU, 0xEFB9U,
0xF104U, 0xF377U, 0xF5E1U, 0xF792U, 0xF8CDU, 0xFABEU, 0xFC28U, 0xFE5BU}; 0xF104U, 0xF377U, 0xF5E1U, 0xF792U, 0xF8CDU, 0xFABEU, 0xFC28U, 0xFE5BU
};
const unsigned int DECODING_TABLE_1576[] = const unsigned int DECODING_TABLE_1576[] =
{0x0000U, 0x0001U, 0x0002U, 0x0003U, 0x0004U, 0x0005U, 0x0006U, 0x4020U, 0x0008U, 0x0009U, 0x000AU, 0x000BU, {
0x0000U, 0x0001U, 0x0002U, 0x0003U, 0x0004U, 0x0005U, 0x0006U, 0x4020U, 0x0008U, 0x0009U, 0x000AU, 0x000BU,
0x000CU, 0x000DU, 0x2081U, 0x2080U, 0x0010U, 0x0011U, 0x0012U, 0x0013U, 0x0014U, 0x0C00U, 0x0016U, 0x0C02U, 0x000CU, 0x000DU, 0x2081U, 0x2080U, 0x0010U, 0x0011U, 0x0012U, 0x0013U, 0x0014U, 0x0C00U, 0x0016U, 0x0C02U,
0x0018U, 0x0120U, 0x001AU, 0x0122U, 0x4102U, 0x0124U, 0x4100U, 0x4101U, 0x0020U, 0x0021U, 0x0022U, 0x4004U, 0x0018U, 0x0120U, 0x001AU, 0x0122U, 0x4102U, 0x0124U, 0x4100U, 0x4101U, 0x0020U, 0x0021U, 0x0022U, 0x4004U,
0x0024U, 0x4002U, 0x4001U, 0x4000U, 0x0028U, 0x0110U, 0x1800U, 0x1801U, 0x002CU, 0x400AU, 0x4009U, 0x4008U, 0x0024U, 0x4002U, 0x4001U, 0x4000U, 0x0028U, 0x0110U, 0x1800U, 0x1801U, 0x002CU, 0x400AU, 0x4009U, 0x4008U,
@ -56,7 +59,8 @@ const unsigned int DECODING_TABLE_1576[] =
0x1003U, 0x1002U, 0x1001U, 0x1000U, 0x0501U, 0x0500U, 0x1005U, 0x1004U, 0x0404U, 0x0810U, 0x1100U, 0x1101U, 0x1003U, 0x1002U, 0x1001U, 0x1000U, 0x0501U, 0x0500U, 0x1005U, 0x1004U, 0x0404U, 0x0810U, 0x1100U, 0x1101U,
0x0400U, 0x0401U, 0x0402U, 0x0403U, 0x040CU, 0x0818U, 0x1108U, 0x1030U, 0x0408U, 0x0409U, 0x040AU, 0x2060U, 0x0400U, 0x0401U, 0x0402U, 0x0403U, 0x040CU, 0x0818U, 0x1108U, 0x1030U, 0x0408U, 0x0409U, 0x040AU, 0x2060U,
0x0801U, 0x0800U, 0x0280U, 0x0802U, 0x0410U, 0x0804U, 0x0412U, 0x0806U, 0x0809U, 0x0808U, 0x1021U, 0x1020U, 0x0801U, 0x0800U, 0x0280U, 0x0802U, 0x0410U, 0x0804U, 0x0412U, 0x0806U, 0x0809U, 0x0808U, 0x1021U, 0x1020U,
0x5000U, 0x2200U, 0x5002U, 0x2202U}; 0x5000U, 0x2200U, 0x5002U, 0x2202U
};
#define X14 0x00004000 /* vector representation of X^{14} */ #define X14 0x00004000 /* vector representation of X^{14} */
#define X8 0x00000100 /* vector representation of X^{8} */ #define X8 0x00000100 /* vector representation of X^{8} */
@ -76,8 +80,10 @@ unsigned int CQR1676::getSyndrome1576(unsigned int pattern)
{ {
unsigned int aux = X14; unsigned int aux = X14;
if (pattern >= X8) { if (pattern >= X8)
while (pattern & MASK7) { {
while (pattern & MASK7)
{
while (!(aux & pattern)) while (!(aux & pattern))
aux = aux >> 1; aux = aux >> 1;

@ -19,7 +19,8 @@
#ifndef QR1676_H #ifndef QR1676_H
#define QR1676_H #define QR1676_H
class CQR1676 { class CQR1676
{
public: public:
static void encode(unsigned char* data); static void encode(unsigned char* data);

@ -277,7 +277,8 @@ void CReflector::CloseStream(CPacketStream *stream)
// wait a bit // wait a bit
CTimePoint::TaskSleepFor(10); CTimePoint::TaskSleepFor(10);
} }
} while (!bEmpty); }
while (!bEmpty);
// lock clients // lock clients
GetClients(); GetClients();

@ -30,7 +30,8 @@ const unsigned int NPAR = 3U;
/* Generator Polynomial */ /* Generator Polynomial */
const unsigned char POLY[] = {64U, 56U, 14U, 1U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U}; const unsigned char POLY[] = {64U, 56U, 14U, 1U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U};
const unsigned char EXP_TABLE[] = { const unsigned char EXP_TABLE[] =
{
0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x20U, 0x40U, 0x80U, 0x1DU, 0x3AU, 0x74U, 0xE8U, 0xCDU, 0x87U, 0x13U, 0x26U, 0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x20U, 0x40U, 0x80U, 0x1DU, 0x3AU, 0x74U, 0xE8U, 0xCDU, 0x87U, 0x13U, 0x26U,
0x4CU, 0x98U, 0x2DU, 0x5AU, 0xB4U, 0x75U, 0xEAU, 0xC9U, 0x8FU, 0x03U, 0x06U, 0x0CU, 0x18U, 0x30U, 0x60U, 0xC0U, 0x4CU, 0x98U, 0x2DU, 0x5AU, 0xB4U, 0x75U, 0xEAU, 0xC9U, 0x8FU, 0x03U, 0x06U, 0x0CU, 0x18U, 0x30U, 0x60U, 0xC0U,
0x9DU, 0x27U, 0x4EU, 0x9CU, 0x25U, 0x4AU, 0x94U, 0x35U, 0x6AU, 0xD4U, 0xB5U, 0x77U, 0xEEU, 0xC1U, 0x9FU, 0x23U, 0x9DU, 0x27U, 0x4EU, 0x9CU, 0x25U, 0x4AU, 0x94U, 0x35U, 0x6AU, 0xD4U, 0xB5U, 0x77U, 0xEEU, 0xC1U, 0x9FU, 0x23U,
@ -62,9 +63,11 @@ const unsigned char EXP_TABLE[] = {
0x19U, 0x32U, 0x64U, 0xC8U, 0x8DU, 0x07U, 0x0EU, 0x1CU, 0x38U, 0x70U, 0xE0U, 0xDDU, 0xA7U, 0x53U, 0xA6U, 0x51U, 0x19U, 0x32U, 0x64U, 0xC8U, 0x8DU, 0x07U, 0x0EU, 0x1CU, 0x38U, 0x70U, 0xE0U, 0xDDU, 0xA7U, 0x53U, 0xA6U, 0x51U,
0xA2U, 0x59U, 0xB2U, 0x79U, 0xF2U, 0xF9U, 0xEFU, 0xC3U, 0x9BU, 0x2BU, 0x56U, 0xACU, 0x45U, 0x8AU, 0x09U, 0x12U, 0xA2U, 0x59U, 0xB2U, 0x79U, 0xF2U, 0xF9U, 0xEFU, 0xC3U, 0x9BU, 0x2BU, 0x56U, 0xACU, 0x45U, 0x8AU, 0x09U, 0x12U,
0x24U, 0x48U, 0x90U, 0x3DU, 0x7AU, 0xF4U, 0xF5U, 0xF7U, 0xF3U, 0xFBU, 0xEBU, 0xCBU, 0x8BU, 0x0BU, 0x16U, 0x2CU, 0x24U, 0x48U, 0x90U, 0x3DU, 0x7AU, 0xF4U, 0xF5U, 0xF7U, 0xF3U, 0xFBU, 0xEBU, 0xCBU, 0x8BU, 0x0BU, 0x16U, 0x2CU,
0x58U, 0xB0U, 0x7DU, 0xFAU, 0xE9U, 0xCFU, 0x83U, 0x1BU, 0x36U, 0x6CU, 0xD8U, 0xADU, 0x47U, 0x8EU, 0x01U, 0x00U}; 0x58U, 0xB0U, 0x7DU, 0xFAU, 0xE9U, 0xCFU, 0x83U, 0x1BU, 0x36U, 0x6CU, 0xD8U, 0xADU, 0x47U, 0x8EU, 0x01U, 0x00U
};
const unsigned char LOG_TABLE[] = { const unsigned char LOG_TABLE[] =
{
0x00U, 0x00U, 0x01U, 0x19U, 0x02U, 0x32U, 0x1AU, 0xC6U, 0x03U, 0xDFU, 0x33U, 0xEEU, 0x1BU, 0x68U, 0xC7U, 0x4BU, 0x00U, 0x00U, 0x01U, 0x19U, 0x02U, 0x32U, 0x1AU, 0xC6U, 0x03U, 0xDFU, 0x33U, 0xEEU, 0x1BU, 0x68U, 0xC7U, 0x4BU,
0x04U, 0x64U, 0xE0U, 0x0EU, 0x34U, 0x8DU, 0xEFU, 0x81U, 0x1CU, 0xC1U, 0x69U, 0xF8U, 0xC8U, 0x08U, 0x4CU, 0x71U, 0x04U, 0x64U, 0xE0U, 0x0EU, 0x34U, 0x8DU, 0xEFU, 0x81U, 0x1CU, 0xC1U, 0x69U, 0xF8U, 0xC8U, 0x08U, 0x4CU, 0x71U,
0x05U, 0x8AU, 0x65U, 0x2FU, 0xE1U, 0x24U, 0x0FU, 0x21U, 0x35U, 0x93U, 0x8EU, 0xDAU, 0xF0U, 0x12U, 0x82U, 0x45U, 0x05U, 0x8AU, 0x65U, 0x2FU, 0xE1U, 0x24U, 0x0FU, 0x21U, 0x35U, 0x93U, 0x8EU, 0xDAU, 0xF0U, 0x12U, 0x82U, 0x45U,
@ -80,7 +83,8 @@ const unsigned char LOG_TABLE[] = {
0x1FU, 0x2DU, 0x43U, 0xD8U, 0xB7U, 0x7BU, 0xA4U, 0x76U, 0xC4U, 0x17U, 0x49U, 0xECU, 0x7FU, 0x0CU, 0x6FU, 0xF6U, 0x1FU, 0x2DU, 0x43U, 0xD8U, 0xB7U, 0x7BU, 0xA4U, 0x76U, 0xC4U, 0x17U, 0x49U, 0xECU, 0x7FU, 0x0CU, 0x6FU, 0xF6U,
0x6CU, 0xA1U, 0x3BU, 0x52U, 0x29U, 0x9DU, 0x55U, 0xAAU, 0xFBU, 0x60U, 0x86U, 0xB1U, 0xBBU, 0xCCU, 0x3EU, 0x5AU, 0x6CU, 0xA1U, 0x3BU, 0x52U, 0x29U, 0x9DU, 0x55U, 0xAAU, 0xFBU, 0x60U, 0x86U, 0xB1U, 0xBBU, 0xCCU, 0x3EU, 0x5AU,
0xCBU, 0x59U, 0x5FU, 0xB0U, 0x9CU, 0xA9U, 0xA0U, 0x51U, 0x0BU, 0xF5U, 0x16U, 0xEBU, 0x7AU, 0x75U, 0x2CU, 0xD7U, 0xCBU, 0x59U, 0x5FU, 0xB0U, 0x9CU, 0xA9U, 0xA0U, 0x51U, 0x0BU, 0xF5U, 0x16U, 0xEBU, 0x7AU, 0x75U, 0x2CU, 0xD7U,
0x4FU, 0xAEU, 0xD5U, 0xE9U, 0xE6U, 0xE7U, 0xADU, 0xE8U, 0x74U, 0xD6U, 0xF4U, 0xEAU, 0xA8U, 0x50U, 0x58U, 0xAFU}; 0x4FU, 0xAEU, 0xD5U, 0xE9U, 0xE6U, 0xE7U, 0xADU, 0xE8U, 0x74U, 0xD6U, 0xF4U, 0xEAU, 0xA8U, 0x50U, 0x58U, 0xAFU
};
/* multiplication using logarithms */ /* multiplication using logarithms */
static unsigned char gmult(unsigned char a, unsigned char b) static unsigned char gmult(unsigned char a, unsigned char b)
@ -107,7 +111,8 @@ void CRS129::encode(const unsigned char* msg, unsigned int nbytes, unsigned char
for (unsigned int i = 0U; i < NPAR + 1U; i++) for (unsigned int i = 0U; i < NPAR + 1U; i++)
parity[i] = 0x00U; parity[i] = 0x00U;
for (unsigned int i = 0U; i < nbytes; i++) { for (unsigned int i = 0U; i < nbytes; i++)
{
unsigned char dbyte = msg[i] ^ parity[NPAR - 1U]; unsigned char dbyte = msg[i] ^ parity[NPAR - 1U];
for (int j = NPAR - 1; j > 0; j--) for (int j = NPAR - 1; j > 0; j--)

@ -53,7 +53,7 @@ void CSemaphore::Notify(void)
void CSemaphore::Wait(void) void CSemaphore::Wait(void)
{ {
std::unique_lock<std::mutex> lock(m_Mutex); std::unique_lock<std::mutex> lock(m_Mutex);
m_Condition.wait(lock, [&]{ return m_Count > 0; }); m_Condition.wait(lock, [&] { return m_Count > 0; });
m_Count--; m_Count--;
} }
@ -61,7 +61,7 @@ bool CSemaphore::WaitFor(uint ms)
{ {
std::chrono::milliseconds timespan(ms); std::chrono::milliseconds timespan(ms);
std::unique_lock<decltype(m_Mutex)> lock(m_Mutex); std::unique_lock<decltype(m_Mutex)> lock(m_Mutex);
auto ok = m_Condition.wait_for(lock, timespan, [&]{ return m_Count > 0; }); auto ok = m_Condition.wait_for(lock, timespan, [&] { return m_Count > 0; });
if ( ok ) if ( ok )
{ {
m_Count--; m_Count--;

@ -95,7 +95,8 @@ bool CTranscoder::Init(void)
// create our socket // create our socket
if (tc.IsSet()) if (tc.IsSet())
{ {
if (! m_Socket.Open(tc)) { if (! m_Socket.Open(tc))
{
std::cerr << "Error opening socket on port UDP" << TRANSCODER_PORT << " on ip " << m_Ip << std::endl; std::cerr << "Error opening socket on port UDP" << TRANSCODER_PORT << " on ip " << m_Ip << std::endl;
return false; return false;
} }
@ -199,7 +200,7 @@ void CTranscoder::Task(void)
// update time // update time
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.Now();
} }
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// manage streams // manage streams

@ -54,7 +54,8 @@ int CUdpMsgSocket::Receive(CBuffer *Buffer, CIp *Ip, int timeout)
struct msghdr Msg; struct msghdr Msg;
struct iovec Iov[1]; struct iovec Iov[1];
union { union
{
struct cmsghdr cm; struct cmsghdr cm;
unsigned char pktinfo_sizer[sizeof(struct cmsghdr) + sizeof(struct in_pktinfo)]; unsigned char pktinfo_sizer[sizeof(struct cmsghdr) + sizeof(struct in_pktinfo)];
} Control; } Control;

@ -83,7 +83,8 @@ bool CUdpSocket::Open(const CIp &Ip)
return false; return false;
} }
if (0 == m_addr.GetPort()) { // get the assigned port for an ephemeral port request if (0 == m_addr.GetPort()) // get the assigned port for an ephemeral port request
{
CIp a; CIp a;
socklen_t len = sizeof(struct sockaddr_storage); socklen_t len = sizeof(struct sockaddr_storage);
if (getsockname(m_fd, a.GetPointer(), &len)) if (getsockname(m_fd, a.GetPointer(), &len))

@ -16,7 +16,8 @@
#include <string> #include <string>
class CUtils { class CUtils
{
public: public:
static void byteToBitsBE(unsigned char byte, bool* bits); static void byteToBitsBE(unsigned char byte, bool* bits);
static void byteToBitsLE(unsigned char byte, bool* bits); static void byteToBitsLE(unsigned char byte, bool* bits);

@ -36,13 +36,13 @@ CXlxClient::CXlxClient()
} }
CXlxClient::CXlxClient(const CCallsign &callsign, const CIp &ip, char reflectorModule, int protRev) CXlxClient::CXlxClient(const CCallsign &callsign, const CIp &ip, char reflectorModule, int protRev)
: CClient(callsign, ip, reflectorModule) : CClient(callsign, ip, reflectorModule)
{ {
m_ProtRev = protRev; m_ProtRev = protRev;
} }
CXlxClient::CXlxClient(const CXlxClient &client) CXlxClient::CXlxClient(const CXlxClient &client)
: CClient(client) : CClient(client)
{ {
m_ProtRev = client.m_ProtRev; m_ProtRev = client.m_ProtRev;
} }

@ -39,7 +39,7 @@ CXlxPeer::CXlxPeer()
} }
CXlxPeer::CXlxPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version) CXlxPeer::CXlxPeer(const CCallsign &callsign, const CIp &ip, const char *modules, const CVersion &version)
: CPeer(callsign, ip, modules, version) : CPeer(callsign, ip, modules, version)
{ {
// get protocol revision // get protocol revision
int protrev = GetProtocolRevision(version); int protrev = GetProtocolRevision(version);

@ -36,12 +36,12 @@ const uint32_t M = 2U;
const unsigned int K = 5U; const unsigned int K = 5U;
CYSFConvolution::CYSFConvolution() : CYSFConvolution::CYSFConvolution() :
m_metrics1(nullptr), m_metrics1(nullptr),
m_metrics2(nullptr), m_metrics2(nullptr),
m_oldMetrics(nullptr), m_oldMetrics(nullptr),
m_newMetrics(nullptr), m_newMetrics(nullptr),
m_decisions(nullptr), m_decisions(nullptr),
m_dp(nullptr) m_dp(nullptr)
{ {
m_metrics1 = new uint16_t[16U]; m_metrics1 = new uint16_t[16U];
m_metrics2 = new uint16_t[16U]; m_metrics2 = new uint16_t[16U];
@ -69,7 +69,8 @@ void CYSFConvolution::decode(uint8_t s0, uint8_t s1)
{ {
*m_dp = 0U; *m_dp = 0U;
for (uint8_t i = 0U; i < NUM_OF_STATES_D2; i++) { for (uint8_t i = 0U; i < NUM_OF_STATES_D2; i++)
{
uint8_t j = i * 2U; uint8_t j = i * 2U;
uint16_t metric = (BRANCH_TABLE1[i] ^ s0) + (BRANCH_TABLE2[i] ^ s1); uint16_t metric = (BRANCH_TABLE1[i] ^ s0) + (BRANCH_TABLE2[i] ^ s1);
@ -102,7 +103,8 @@ void CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
uint32_t state = 0U; uint32_t state = 0U;
while (nBits-- > 0) { while (nBits-- > 0)
{
--m_dp; --m_dp;
uint32_t i = state >> (9 - K); uint32_t i = state >> (9 - K);
@ -121,7 +123,8 @@ void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsign
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U; uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;
uint32_t k = 0U; uint32_t k = 0U;
for (unsigned int i = 0U; i < nBits; i++) { for (unsigned int i = 0U; i < nBits; i++)
{
uint8_t d = READ_BIT1(in, i) ? 1U : 0U; uint8_t d = READ_BIT1(in, i) ? 1U : 0U;
uint8_t g1 = (d + d3 + d4) & 1; uint8_t g1 = (d + d3 + d4) & 1;

@ -23,7 +23,8 @@
#include <cstdint> #include <cstdint>
class CYSFConvolution { class CYSFConvolution
{
public: public:
CYSFConvolution(); CYSFConvolution();
~CYSFConvolution(); ~CYSFConvolution();

@ -33,7 +33,8 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
#define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7]) #define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
const unsigned int INTERLEAVE_TABLE[] = { const unsigned int INTERLEAVE_TABLE[] =
{
0U, 40U, 80U, 120U, 160U, 0U, 40U, 80U, 120U, 160U,
2U, 42U, 82U, 122U, 162U, 2U, 42U, 82U, 122U, 162U,
4U, 44U, 84U, 124U, 164U, 4U, 44U, 84U, 124U, 164U,
@ -53,10 +54,11 @@ const unsigned int INTERLEAVE_TABLE[] = {
32U, 72U, 112U, 152U, 192U, 32U, 72U, 112U, 152U, 192U,
34U, 74U, 114U, 154U, 194U, 34U, 74U, 114U, 154U, 194U,
36U, 76U, 116U, 156U, 196U, 36U, 76U, 116U, 156U, 196U,
38U, 78U, 118U, 158U, 198U}; 38U, 78U, 118U, 158U, 198U
};
CYSFFICH::CYSFFICH() : CYSFFICH::CYSFFICH() :
m_fich(nullptr) m_fich(nullptr)
{ {
m_fich = new unsigned char[6U]; m_fich = new unsigned char[6U];
::memset(m_fich, 0U, 6U); ::memset(m_fich, 0U, 6U);
@ -75,7 +77,8 @@ bool CYSFFICH::decode(const unsigned char* bytes)
viterbi.start(); viterbi.start();
// Deinterleave the FICH and send bits to the Viterbi decoder // Deinterleave the FICH and send bits to the Viterbi decoder
for (unsigned int i = 0U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++)
{
unsigned int n = INTERLEAVE_TABLE[i]; unsigned int n = INTERLEAVE_TABLE[i];
uint8_t s0 = READ_BIT1(bytes, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(bytes, n) ? 1U : 0U;
@ -139,7 +142,8 @@ void CYSFFICH::encode(unsigned char* bytes)
convolution.encode(conv, convolved, 100U); convolution.encode(conv, convolved, 100U);
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++)
{
unsigned int n = INTERLEAVE_TABLE[i]; unsigned int n = INTERLEAVE_TABLE[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;

@ -20,7 +20,8 @@
#if !defined(YSFFICH_H) #if !defined(YSFFICH_H)
#define YSFFICH_H #define YSFFICH_H
class CYSFFICH { class CYSFFICH
{
public: public:
CYSFFICH(); CYSFFICH();
~CYSFFICH(); ~CYSFFICH();

@ -53,7 +53,7 @@ protected:
protected: protected:
// data // data
time_t m_LastModTime; time_t m_LastModTime;
}; };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#endif /* cysfnodedirfile_h */ #endif /* cysfnodedirfile_h */

@ -157,7 +157,8 @@ bool CYsfNodeDirHttp::HttpGet(const char *hostname, const char *filename, int po
//} //}
done = (len <= 0); done = (len <= 0);
} while (!done); }
while (!done);
buffer->Append((uint8)0); buffer->Append((uint8)0);
// and disconnect // and disconnect

@ -24,7 +24,8 @@
#include <cstring> #include <cstring>
#include <cstdint> #include <cstdint>
const unsigned int INTERLEAVE_TABLE_9_20[] = { const unsigned int INTERLEAVE_TABLE_9_20[] =
{
0U, 40U, 80U, 120U, 160U, 200U, 240U, 280U, 320U, 0U, 40U, 80U, 120U, 160U, 200U, 240U, 280U, 320U,
2U, 42U, 82U, 122U, 162U, 202U, 242U, 282U, 322U, 2U, 42U, 82U, 122U, 162U, 202U, 242U, 282U, 322U,
4U, 44U, 84U, 124U, 164U, 204U, 244U, 284U, 324U, 4U, 44U, 84U, 124U, 164U, 204U, 244U, 284U, 324U,
@ -44,9 +45,11 @@ const unsigned int INTERLEAVE_TABLE_9_20[] = {
32U, 72U, 112U, 152U, 192U, 232U, 272U, 312U, 352U, 32U, 72U, 112U, 152U, 192U, 232U, 272U, 312U, 352U,
34U, 74U, 114U, 154U, 194U, 234U, 274U, 314U, 354U, 34U, 74U, 114U, 154U, 194U, 234U, 274U, 314U, 354U,
36U, 76U, 116U, 156U, 196U, 236U, 276U, 316U, 356U, 36U, 76U, 116U, 156U, 196U, 236U, 276U, 316U, 356U,
38U, 78U, 118U, 158U, 198U, 238U, 278U, 318U, 358U}; 38U, 78U, 118U, 158U, 198U, 238U, 278U, 318U, 358U
};
const unsigned int INTERLEAVE_TABLE_5_20[] = { const unsigned int INTERLEAVE_TABLE_5_20[] =
{
0U, 40U, 80U, 120U, 160U, 0U, 40U, 80U, 120U, 160U,
2U, 42U, 82U, 122U, 162U, 2U, 42U, 82U, 122U, 162U,
4U, 44U, 84U, 124U, 164U, 4U, 44U, 84U, 124U, 164U,
@ -66,11 +69,13 @@ const unsigned int INTERLEAVE_TABLE_5_20[] = {
32U, 72U, 112U, 152U, 192U, 32U, 72U, 112U, 152U, 192U,
34U, 74U, 114U, 154U, 194U, 34U, 74U, 114U, 154U, 194U,
36U, 76U, 116U, 156U, 196U, 36U, 76U, 116U, 156U, 196U,
38U, 78U, 118U, 158U, 198U}; 38U, 78U, 118U, 158U, 198U
};
// This one differs from the others in that it interleaves bits and not dibits // This one differs from the others in that it interleaves bits and not dibits
const unsigned char WHITENING_DATA[] = {0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU, const unsigned char WHITENING_DATA[] = {0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU,
0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U}; 0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U
};
const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U}; const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
@ -78,10 +83,10 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CYSFPayload::CYSFPayload() : CYSFPayload::CYSFPayload() :
m_uplink(nullptr), m_uplink(nullptr),
m_downlink(nullptr), m_downlink(nullptr),
m_source(nullptr), m_source(nullptr),
m_dest(nullptr) m_dest(nullptr)
{ {
} }
@ -103,15 +108,18 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
unsigned char* p1 = data; unsigned char* p1 = data;
unsigned char* p2 = dch; unsigned char* p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 9U); ::memcpy(p2, p1, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
CYSFConvolution conv; CYSFConvolution conv;
conv.start(); conv.start();
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -125,16 +133,19 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
conv.chainback(output, 176U); conv.chainback(output, 176U);
bool valid1 = CCRC::checkCCITT162(output, 22U); bool valid1 = CCRC::checkCCITT162(output, 22U);
if (valid1) { if (valid1)
{
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
if (m_dest == nullptr) { if (m_dest == nullptr)
{
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH]; m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH); ::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH);
} }
if (m_source == nullptr) { if (m_source == nullptr)
{
m_source = new unsigned char[YSF_CALLSIGN_LENGTH]; m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH); ::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
} }
@ -150,7 +161,8 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
unsigned char bytes[45U]; unsigned char bytes[45U];
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;
@ -167,22 +179,27 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
p1 = data; p1 = data;
p2 = bytes; p2 = bytes;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p1, p2, 9U); ::memcpy(p1, p2, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
} }
p1 = data + 9U; p1 = data + 9U;
p2 = dch; p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 9U); ::memcpy(p2, p1, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
conv.start(); conv.start();
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -195,7 +212,8 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
conv.chainback(output, 176U); conv.chainback(output, 176U);
bool valid2 = CCRC::checkCCITT162(output, 22U); bool valid2 = CCRC::checkCCITT162(output, 22U);
if (valid2) { if (valid2)
{
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
@ -216,7 +234,8 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
unsigned char bytes[45U]; unsigned char bytes[45U];
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;
@ -233,9 +252,11 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
p1 = data + 9U; p1 = data + 9U;
p2 = bytes; p2 = bytes;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p1, p2, 9U); ::memcpy(p1, p2, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
} }
@ -255,15 +276,18 @@ bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char*
const unsigned char* p1 = data; const unsigned char* p1 = data;
unsigned char* p2 = dch; unsigned char* p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 9U); ::memcpy(p2, p1, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
CYSFConvolution conv; CYSFConvolution conv;
conv.start(); conv.start();
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -277,7 +301,8 @@ bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char*
conv.chainback(output, 176U); conv.chainback(output, 176U);
bool ret = CCRC::checkCCITT162(output, 22U); bool ret = CCRC::checkCCITT162(output, 22U);
if (ret) { if (ret)
{
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
@ -302,15 +327,18 @@ bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char*
const unsigned char* p1 = data + 9U; const unsigned char* p1 = data + 9U;
unsigned char* p2 = dch; unsigned char* p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 9U); ::memcpy(p2, p1, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
CYSFConvolution conv; CYSFConvolution conv;
conv.start(); conv.start();
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -324,7 +352,8 @@ bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char*
conv.chainback(output, 176U); conv.chainback(output, 176U);
bool ret = CCRC::checkCCITT162(output, 22U); bool ret = CCRC::checkCCITT162(output, 22U);
if (ret) { if (ret)
{
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
@ -356,7 +385,8 @@ void CYSFPayload::writeVDMode2Data(unsigned char* data, const unsigned char* dt)
unsigned char bytes[25U]; unsigned char bytes[25U];
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++)
{
unsigned int n = INTERLEAVE_TABLE_5_20[i]; unsigned int n = INTERLEAVE_TABLE_5_20[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;
@ -373,9 +403,11 @@ void CYSFPayload::writeVDMode2Data(unsigned char* data, const unsigned char* dt)
unsigned char* p1 = data; unsigned char* p1 = data;
unsigned char* p2 = bytes; unsigned char* p2 = bytes;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p1, p2, 5U); ::memcpy(p1, p2, 5U);
p1 += 18U; p2 += 5U; p1 += 18U;
p2 += 5U;
} }
} }
@ -391,15 +423,18 @@ bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
const unsigned char* p1 = data; const unsigned char* p1 = data;
unsigned char* p2 = dch; unsigned char* p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 9U); ::memcpy(p2, p1, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
CYSFConvolution conv; CYSFConvolution conv;
conv.start(); conv.start();
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -413,7 +448,8 @@ bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
conv.chainback(output, 176U); conv.chainback(output, 176U);
bool ret = CCRC::checkCCITT162(output, 22U); bool ret = CCRC::checkCCITT162(output, 22U);
if (ret) { if (ret)
{
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
@ -437,15 +473,18 @@ bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
const unsigned char* p1 = data; const unsigned char* p1 = data;
unsigned char* p2 = dch; unsigned char* p2 = dch;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p2, p1, 5U); ::memcpy(p2, p1, 5U);
p1 += 18U; p2 += 5U; p1 += 18U;
p2 += 5U;
} }
CYSFConvolution conv; CYSFConvolution conv;
conv.start(); conv.start();
for (unsigned int i = 0U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++)
{
unsigned int n = INTERLEAVE_TABLE_5_20[i]; unsigned int n = INTERLEAVE_TABLE_5_20[i];
uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U; uint8_t s0 = READ_BIT1(dch, n) ? 1U : 0U;
@ -459,7 +498,8 @@ bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
conv.chainback(output, 96U); conv.chainback(output, 96U);
bool ret = CCRC::checkCCITT162(output, 12U); bool ret = CCRC::checkCCITT162(output, 12U);
if (ret) { if (ret)
{
for (unsigned int i = 0U; i < 10U; i++) for (unsigned int i = 0U; i < 10U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
@ -503,7 +543,8 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
unsigned char bytes[45U]; unsigned char bytes[45U];
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;
@ -520,9 +561,11 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
unsigned char* p1 = data; unsigned char* p1 = data;
unsigned char* p2 = bytes; unsigned char* p2 = bytes;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p1, p2, 9U); ::memcpy(p1, p2, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
} }
@ -547,7 +590,8 @@ void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* d
unsigned char bytes[45U]; unsigned char bytes[45U];
unsigned int j = 0U; unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) { for (unsigned int i = 0U; i < 180U; i++)
{
unsigned int n = INTERLEAVE_TABLE_9_20[i]; unsigned int n = INTERLEAVE_TABLE_9_20[i];
bool s0 = READ_BIT1(convolved, j) != 0U; bool s0 = READ_BIT1(convolved, j) != 0U;
@ -564,9 +608,11 @@ void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* d
unsigned char* p1 = data + 9U; unsigned char* p1 = data + 9U;
unsigned char* p2 = bytes; unsigned char* p2 = bytes;
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++)
{
::memcpy(p1, p2, 9U); ::memcpy(p1, p2, 9U);
p1 += 18U; p2 += 9U; p1 += 18U;
p2 += 9U;
} }
} }

@ -21,7 +21,8 @@
#include <string> #include <string>
class CYSFPayload { class CYSFPayload
{
public: public:
CYSFPayload(); CYSFPayload();
~CYSFPayload(); ~CYSFPayload();

@ -176,9 +176,9 @@ void CYsfProtocol::Task(void)
auto newclient = std::make_shared<CYsfClient>(Callsign, Ip); auto newclient = std::make_shared<CYsfClient>(Callsign, Ip);
// aautolink, if enabled // aautolink, if enabled
#if YSF_AUTOLINK_ENABLE #if YSF_AUTOLINK_ENABLE
newclient->SetReflectorModule(YSF_AUTOLINK_MODULE); newclient->SetReflectorModule(YSF_AUTOLINK_MODULE);
#endif #endif
// and append // and append
clients->AddClient(newclient); clients->AddClient(newclient);

@ -34,7 +34,8 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// constants & defines // constants & defines
const unsigned int PRNG_TABLE[] = { const unsigned int PRNG_TABLE[] =
{
0x42CC47U, 0x19D6FEU, 0x304729U, 0x6B2CD0U, 0x60BF47U, 0x39650EU, 0x7354F1U, 0xEACF60U, 0x819C9FU, 0xDE25CEU, 0x42CC47U, 0x19D6FEU, 0x304729U, 0x6B2CD0U, 0x60BF47U, 0x39650EU, 0x7354F1U, 0xEACF60U, 0x819C9FU, 0xDE25CEU,
0xD7B745U, 0x8CC8B8U, 0x8D592BU, 0xF71257U, 0xBCA084U, 0xA5B329U, 0xEE6AFAU, 0xF7D9A7U, 0xBCC21CU, 0x4712D9U, 0xD7B745U, 0x8CC8B8U, 0x8D592BU, 0xF71257U, 0xBCA084U, 0xA5B329U, 0xEE6AFAU, 0xF7D9A7U, 0xBCC21CU, 0x4712D9U,
0x4F2922U, 0x14FA37U, 0x5D43ECU, 0x564115U, 0x299A92U, 0x20A9EBU, 0x7B707DU, 0x3BE3A4U, 0x20D95BU, 0x6B085AU, 0x4F2922U, 0x14FA37U, 0x5D43ECU, 0x564115U, 0x299A92U, 0x20A9EBU, 0x7B707DU, 0x3BE3A4U, 0x20D95BU, 0x6B085AU,
@ -444,26 +445,33 @@ const unsigned int PRNG_TABLE[] = {
0xC9D7C8U, 0x98661FU, 0x93BDC6U, 0xC88EE5U, 0xC15438U, 0xBA45C3U, 0xF2FE56U, 0xE9290DU, 0x2230E8U, 0x3B9273U, 0xC9D7C8U, 0x98661FU, 0x93BDC6U, 0xC88EE5U, 0xC15438U, 0xBA45C3U, 0xF2FE56U, 0xE9290DU, 0x2230E8U, 0x3B9273U,
0x70C98FU, 0x0958DCU, 0x02A343U, 0x58B0A2U, 0x150A7DU, 0x0E5BC4U, 0x6FC897U, 0x74F33AU, 0x3F23E9U, 0x66A834U, 0x70C98FU, 0x0958DCU, 0x02A343U, 0x58B0A2U, 0x150A7DU, 0x0E5BC4U, 0x6FC897U, 0x74F33AU, 0x3F23E9U, 0x66A834U,
0xECDB0FU, 0xB542DAU, 0x9E5131U, 0xC7ABA5U, 0x8C38FEU, 0x97010BU, 0xDED290U, 0xA4CC7DU, 0xAD3D2EU, 0xF6B6B3U, 0xECDB0FU, 0xB542DAU, 0x9E5131U, 0xC7ABA5U, 0x8C38FEU, 0x97010BU, 0xDED290U, 0xA4CC7DU, 0xAD3D2EU, 0xF6B6B3U,
0xF9A540U, 0x205ED9U, 0x634EB6U, 0x5A9567U, 0x11A6D8U, 0x0B3F09U}; 0xF9A540U, 0x205ED9U, 0x634EB6U, 0x5A9567U, 0x11A6D8U, 0x0B3F09U
};
const unsigned int DMR_A_TABLE[] = {0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U, const unsigned int DMR_A_TABLE[] = {0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U,
48U, 52U, 56U, 60U, 64U, 68U, 1U, 5U, 9U, 13U, 17U, 21U}; 48U, 52U, 56U, 60U, 64U, 68U, 1U, 5U, 9U, 13U, 17U, 21U
};
const unsigned int DMR_B_TABLE[] = {25U, 29U, 33U, 37U, 41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, const unsigned int DMR_B_TABLE[] = {25U, 29U, 33U, 37U, 41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U,
2U, 6U, 10U, 14U, 18U, 22U, 26U, 30U, 34U, 38U, 42U}; 2U, 6U, 10U, 14U, 18U, 22U, 26U, 30U, 34U, 38U, 42U
};
const unsigned int DMR_C_TABLE[] = {46U, 50U, 54U, 58U, 62U, 66U, 70U, 3U, 7U, 11U, 15U, 19U, 23U, const unsigned int DMR_C_TABLE[] = {46U, 50U, 54U, 58U, 62U, 66U, 70U, 3U, 7U, 11U, 15U, 19U, 23U,
27U, 31U, 35U, 39U, 43U, 47U, 51U, 55U, 59U, 63U, 67U, 71U}; 27U, 31U, 35U, 39U, 43U, 47U, 51U, 55U, 59U, 63U, 67U, 71U
};
const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U}; const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
const unsigned int INTERLEAVE_TABLE_26_4[] = { const unsigned int INTERLEAVE_TABLE_26_4[] =
{
0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U, 48U, 52U, 56U, 60U, 64U, 68U, 72U, 76U, 80U, 84U, 88U, 92U, 96U, 100U, 0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U, 48U, 52U, 56U, 60U, 64U, 68U, 72U, 76U, 80U, 84U, 88U, 92U, 96U, 100U,
1U, 5U, 9U, 13U, 17U, 21U, 25U, 29U, 33U, 37U, 41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, 73U, 77U, 81U, 85U, 89U, 93U, 97U, 101U, 1U, 5U, 9U, 13U, 17U, 21U, 25U, 29U, 33U, 37U, 41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, 73U, 77U, 81U, 85U, 89U, 93U, 97U, 101U,
2U, 6U, 10U, 14U, 18U, 22U, 26U, 30U, 34U, 38U, 42U, 46U, 50U, 54U, 58U, 62U, 66U, 70U, 74U, 78U, 82U, 86U, 90U, 94U, 98U, 102U, 2U, 6U, 10U, 14U, 18U, 22U, 26U, 30U, 34U, 38U, 42U, 46U, 50U, 54U, 58U, 62U, 66U, 70U, 74U, 78U, 82U, 86U, 90U, 94U, 98U, 102U,
3U, 7U, 11U, 15U, 19U, 23U, 27U, 31U, 35U, 39U, 43U, 47U, 51U, 55U, 59U, 63U, 67U, 71U, 75U, 79U, 83U, 87U, 91U, 95U, 99U, 103U}; 3U, 7U, 11U, 15U, 19U, 23U, 27U, 31U, 35U, 39U, 43U, 47U, 51U, 55U, 59U, 63U, 67U, 71U, 75U, 79U, 83U, 87U, 91U, 95U, 99U, 103U
};
const unsigned char WHITENING_DATA[] = {0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU, const unsigned char WHITENING_DATA[] = {0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU,
0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U}; 0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U
};
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
@ -483,7 +491,8 @@ void CYsfUtils::DecodeVD2Vchs(uint8 *data, uint8 **ambe)
unsigned int offset = 40U; // DCH(0) unsigned int offset = 40U; // DCH(0)
// We have a total of 5 VCH sections, iterate through each // We have a total of 5 VCH sections, iterate through each
for (unsigned int j = 0U; j < 5U; j++, offset += 144U) { for (unsigned int j = 0U; j < 5U; j++, offset += 144U)
{
unsigned char vch[13U]; unsigned char vch[13U];
unsigned int dat_a = 0U; unsigned int dat_a = 0U;
@ -491,7 +500,8 @@ void CYsfUtils::DecodeVD2Vchs(uint8 *data, uint8 **ambe)
unsigned int dat_c = 0U; unsigned int dat_c = 0U;
// Deinterleave // Deinterleave
for (unsigned int i = 0U; i < 104U; i++) { for (unsigned int i = 0U; i < 104U; i++)
{
unsigned int n = INTERLEAVE_TABLE_26_4[i]; unsigned int n = INTERLEAVE_TABLE_26_4[i];
bool s = READ_BIT(data, offset + n); bool s = READ_BIT(data, offset + n);
WRITE_BIT(vch, i, s); WRITE_BIT(vch, i, s);
@ -501,28 +511,32 @@ void CYsfUtils::DecodeVD2Vchs(uint8 *data, uint8 **ambe)
for (unsigned int i = 0U; i < 13U; i++) for (unsigned int i = 0U; i < 13U; i++)
vch[i] ^= WHITENING_DATA[i]; vch[i] ^= WHITENING_DATA[i];
for (unsigned int i = 0U; i < 12U; i++) { for (unsigned int i = 0U; i < 12U; i++)
{
dat_a <<= 1U; dat_a <<= 1U;
if (READ_BIT(vch, 3U*i + 1U)) if (READ_BIT(vch, 3U*i + 1U))
dat_a |= 0x01U;; dat_a |= 0x01U;
} }
for (unsigned int i = 0U; i < 12U; i++) { for (unsigned int i = 0U; i < 12U; i++)
{
dat_b <<= 1U; dat_b <<= 1U;
if (READ_BIT(vch, 3U*(i + 12U) + 1U)) if (READ_BIT(vch, 3U*(i + 12U) + 1U))
dat_b |= 0x01U;; dat_b |= 0x01U;
} }
for (unsigned int i = 0U; i < 3U; i++) { for (unsigned int i = 0U; i < 3U; i++)
{
dat_c <<= 1U; dat_c <<= 1U;
if (READ_BIT(vch, 3U*(i + 24U) + 1U)) if (READ_BIT(vch, 3U*(i + 24U) + 1U))
dat_c |= 0x01U;; dat_c |= 0x01U;
} }
for (unsigned int i = 0U; i < 22U; i++) { for (unsigned int i = 0U; i < 22U; i++)
{
dat_c <<= 1U; dat_c <<= 1U;
if (READ_BIT(vch, i + 81U)) if (READ_BIT(vch, i + 81U))
dat_c |= 0x01U;; dat_c |= 0x01U;
} }
// convert to ambe2plus // convert to ambe2plus
@ -534,19 +548,22 @@ void CYsfUtils::DecodeVD2Vchs(uint8 *data, uint8 **ambe)
b ^= p; b ^= p;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;
for (unsigned int i = 0U; i < 24U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 24U; i++, MASK >>= 1)
{
unsigned int aPos = DMR_A_TABLE[i]; unsigned int aPos = DMR_A_TABLE[i];
WRITE_BIT(v_dmr, aPos, a & MASK); WRITE_BIT(v_dmr, aPos, a & MASK);
} }
MASK = 0x400000U; MASK = 0x400000U;
for (unsigned int i = 0U; i < 23U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 23U; i++, MASK >>= 1)
{
unsigned int bPos = DMR_B_TABLE[i]; unsigned int bPos = DMR_B_TABLE[i];
WRITE_BIT(v_dmr, bPos, b & MASK); WRITE_BIT(v_dmr, bPos, b & MASK);
} }
MASK = 0x1000000U; MASK = 0x1000000U;
for (unsigned int i = 0U; i < 25U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 25U; i++, MASK >>= 1)
{
unsigned int cPos = DMR_C_TABLE[i]; unsigned int cPos = DMR_C_TABLE[i];
WRITE_BIT(v_dmr, cPos, dat_c & MASK); WRITE_BIT(v_dmr, cPos, dat_c & MASK);
} }
@ -560,7 +577,8 @@ void CYsfUtils::EncodeVD2Vch(uint8 *ambe, uint8 *data)
// convert from ambe2plus // convert from ambe2plus
unsigned int a = 0U; unsigned int a = 0U;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;
for (unsigned int i = 0U; i < 24U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 24U; i++, MASK >>= 1)
{
unsigned int aPos = DMR_A_TABLE[i]; unsigned int aPos = DMR_A_TABLE[i];
if (READ_BIT(ambe, aPos)) if (READ_BIT(ambe, aPos))
@ -569,7 +587,8 @@ void CYsfUtils::EncodeVD2Vch(uint8 *ambe, uint8 *data)
unsigned int b = 0U; unsigned int b = 0U;
MASK = 0x400000U; MASK = 0x400000U;
for (unsigned int i = 0U; i < 23U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 23U; i++, MASK >>= 1)
{
unsigned int bPos = DMR_B_TABLE[i]; unsigned int bPos = DMR_B_TABLE[i];
if (READ_BIT(ambe, bPos)) if (READ_BIT(ambe, bPos))
@ -578,7 +597,8 @@ void CYsfUtils::EncodeVD2Vch(uint8 *ambe, uint8 *data)
unsigned int dat_c = 0U; unsigned int dat_c = 0U;
MASK = 0x1000000U; MASK = 0x1000000U;
for (unsigned int i = 0U; i < 25U; i++, MASK >>= 1) { for (unsigned int i = 0U; i < 25U; i++, MASK >>= 1)
{
unsigned int cPos = DMR_C_TABLE[i]; unsigned int cPos = DMR_C_TABLE[i];
if (READ_BIT(ambe, cPos)) if (READ_BIT(ambe, cPos))
@ -598,28 +618,32 @@ void CYsfUtils::EncodeVD2Vch(uint8 *ambe, uint8 *data)
unsigned int dat_b = b >> 11; unsigned int dat_b = b >> 11;
for (unsigned int i = 0U; i < 12U; i++) { for (unsigned int i = 0U; i < 12U; i++)
{
bool s = (dat_a << (20U + i)) & 0x80000000U; bool s = (dat_a << (20U + i)) & 0x80000000U;
WRITE_BIT(vch, 3*i + 0U, s); WRITE_BIT(vch, 3*i + 0U, s);
WRITE_BIT(vch, 3*i + 1U, s); WRITE_BIT(vch, 3*i + 1U, s);
WRITE_BIT(vch, 3*i + 2U, s); WRITE_BIT(vch, 3*i + 2U, s);
} }
for (unsigned int i = 0U; i < 12U; i++) { for (unsigned int i = 0U; i < 12U; i++)
{
bool s = (dat_b << (20U + i)) & 0x80000000U; bool s = (dat_b << (20U + i)) & 0x80000000U;
WRITE_BIT(vch, 3*(i + 12U) + 0U, s); WRITE_BIT(vch, 3*(i + 12U) + 0U, s);
WRITE_BIT(vch, 3*(i + 12U) + 1U, s); WRITE_BIT(vch, 3*(i + 12U) + 1U, s);
WRITE_BIT(vch, 3*(i + 12U) + 2U, s); WRITE_BIT(vch, 3*(i + 12U) + 2U, s);
} }
for (unsigned int i = 0U; i < 3U; i++) { for (unsigned int i = 0U; i < 3U; i++)
{
bool s = (dat_c << (7U + i)) & 0x80000000U; bool s = (dat_c << (7U + i)) & 0x80000000U;
WRITE_BIT(vch, 3*(i + 24U) + 0U, s); WRITE_BIT(vch, 3*(i + 24U) + 0U, s);
WRITE_BIT(vch, 3*(i + 24U) + 1U, s); WRITE_BIT(vch, 3*(i + 24U) + 1U, s);
WRITE_BIT(vch, 3*(i + 24U) + 2U, s); WRITE_BIT(vch, 3*(i + 24U) + 2U, s);
} }
for (unsigned int i = 0U; i < 22U; i++) { for (unsigned int i = 0U; i < 22U; i++)
{
bool s = (dat_c << (10U + i)) & 0x80000000U; bool s = (dat_c << (10U + i)) & 0x80000000U;
WRITE_BIT(vch, i + 81U, s); WRITE_BIT(vch, i + 81U, s);
} }
@ -631,11 +655,12 @@ void CYsfUtils::EncodeVD2Vch(uint8 *ambe, uint8 *data)
vch[i] ^= WHITENING_DATA[i]; vch[i] ^= WHITENING_DATA[i];
// Interleave // Interleave
for (unsigned int i = 0U; i < 104U; i++) { for (unsigned int i = 0U; i < 104U; i++)
{
unsigned int n = INTERLEAVE_TABLE_26_4[i]; unsigned int n = INTERLEAVE_TABLE_26_4[i];
bool s = READ_BIT(vch, i); bool s = READ_BIT(vch, i);
WRITE_BIT(ysfFrame, n, s); WRITE_BIT(ysfFrame, n, s);
} }
::memcpy(data, ysfFrame, 13U); ::memcpy(data, ysfFrame, 13U);
} }

@ -243,19 +243,19 @@ extern CGateKeeper g_GateKeeper;
#ifndef NO_XLX #ifndef NO_XLX
#if (DMRIDDB_USE_RLX_SERVER == 1) #if (DMRIDDB_USE_RLX_SERVER == 1)
class CDmridDirHttp; class CDmridDirHttp;
extern CDmridDirHttp g_DmridDir; extern CDmridDirHttp g_DmridDir;
#else #else
class CDmridDirFile; class CDmridDirFile;
extern CDmridDirFile g_DmridDir; extern CDmridDirFile g_DmridDir;
#endif #endif
#if (YSFNODEDB_USE_RLX_SERVER == 1) #if (YSFNODEDB_USE_RLX_SERVER == 1)
class CYsfNodeDirHttp; class CYsfNodeDirHttp;
extern CYsfNodeDirHttp g_YsfNodeDir; extern CYsfNodeDirHttp g_YsfNodeDir;
#else #else
class CYsfNodeDirFile; class CYsfNodeDirFile;
extern CYsfNodeDirFile g_YsfNodeDir; extern CYsfNodeDirFile g_YsfNodeDir;
#endif #endif
class CTranscoder; class CTranscoder;

Loading…
Cancel
Save

Powered by TurnKey Linux.