mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2024-11-26 09:08:47 -05:00
Use proper random numbers for the SSRC in the Kenwood network protocol.
This commit is contained in:
parent
f16a7be674
commit
822883f40f
@ -55,7 +55,8 @@ m_rtcpTimer(1000U, 0U, 200U),
|
||||
m_hangTimer(1000U, 5U),
|
||||
m_hangType(0U),
|
||||
m_hangSrc(0U),
|
||||
m_hangDst(0U)
|
||||
m_hangDst(0U),
|
||||
m_random()
|
||||
{
|
||||
assert(localPort > 0U);
|
||||
assert(!rptAddress.empty());
|
||||
@ -64,6 +65,10 @@ m_hangDst(0U)
|
||||
m_sacch = new unsigned char[10U];
|
||||
|
||||
m_address = CUDPSocket::lookup(rptAddress);
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 mt(rd());
|
||||
m_random = mt;
|
||||
}
|
||||
|
||||
CKenwoodNetwork::~CKenwoodNetwork()
|
||||
@ -86,7 +91,8 @@ bool CKenwoodNetwork::open()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ssrc = m_rtpSocket.getLocalAddress();
|
||||
std::uniform_int_distribution<unsigned int> dist(0x00000001, 0xfffffffe);
|
||||
m_ssrc = dist(m_random);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <random>
|
||||
|
||||
class CKenwoodNetwork : public IRptNetwork {
|
||||
public:
|
||||
@ -64,6 +65,7 @@ private:
|
||||
unsigned char m_hangType;
|
||||
unsigned short m_hangSrc;
|
||||
unsigned short m_hangDst;
|
||||
std::mt19937 m_random;
|
||||
|
||||
bool processIcomVoiceHeader(const unsigned char* data);
|
||||
bool processIcomVoiceData(const unsigned char* data);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2016,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2006-2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -261,31 +261,3 @@ void CUDPSocket::close()
|
||||
::close(m_fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long CUDPSocket::getLocalAddress() const
|
||||
{
|
||||
unsigned long address = 0UL;
|
||||
|
||||
char hostname[80U];
|
||||
int ret = ::gethostname(hostname, 80);
|
||||
if (ret == -1)
|
||||
return 0UL;
|
||||
|
||||
struct hostent* phe = ::gethostbyname(hostname);
|
||||
if (phe == NULL)
|
||||
return 0UL;
|
||||
|
||||
if (phe->h_addrtype != AF_INET)
|
||||
return 0UL;
|
||||
|
||||
for (unsigned int i = 0U; phe->h_addr_list[i] != NULL; i++) {
|
||||
struct in_addr addr;
|
||||
::memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr));
|
||||
if (addr.s_addr != INADDR_LOOPBACK) {
|
||||
address = addr.s_addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011,2013,2015,2016,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2011,2013,2015,2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -47,8 +47,6 @@ public:
|
||||
|
||||
void close();
|
||||
|
||||
unsigned long getLocalAddress() const;
|
||||
|
||||
static in_addr lookup(const std::string& hostName);
|
||||
|
||||
private:
|
||||
|
@ -19,6 +19,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20200621";
|
||||
const char* VERSION = "20200701";
|
||||
|
||||
#endif
|
||||
|
@ -56,13 +56,18 @@ m_rtcpTimer(1000U, 0U, 200U),
|
||||
m_hangTimer(1000U, 5U),
|
||||
m_hangType(0U),
|
||||
m_hangSrc(0U),
|
||||
m_hangDst(0U)
|
||||
m_hangDst(0U),
|
||||
m_random()
|
||||
{
|
||||
assert(!address.empty());
|
||||
|
||||
m_sacch = new unsigned char[10U];
|
||||
|
||||
m_address = CUDPSocket::lookup(address);
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 mt(rd());
|
||||
m_random = mt;
|
||||
}
|
||||
|
||||
CKenwoodNetwork::~CKenwoodNetwork()
|
||||
@ -85,7 +90,8 @@ bool CKenwoodNetwork::open()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ssrc = m_rtpSocket.getLocalAddress();
|
||||
std::uniform_int_distribution<unsigned int> dist(0x00000001, 0xfffffffe);
|
||||
m_ssrc = dist(m_random);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <random>
|
||||
|
||||
class CKenwoodNetwork : public ICoreNetwork {
|
||||
public:
|
||||
@ -62,6 +63,7 @@ private:
|
||||
unsigned char m_hangType;
|
||||
unsigned short m_hangSrc;
|
||||
unsigned short m_hangDst;
|
||||
std::mt19937 m_random;
|
||||
|
||||
bool processIcomVoiceHeader(const unsigned char* data);
|
||||
bool processIcomVoiceData(const unsigned char* data);
|
||||
|
@ -260,31 +260,3 @@ void CUDPSocket::close()
|
||||
::close(m_fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long CUDPSocket::getLocalAddress() const
|
||||
{
|
||||
unsigned long address = 0UL;
|
||||
|
||||
char hostname[80U];
|
||||
int ret = ::gethostname(hostname, 80);
|
||||
if (ret == -1)
|
||||
return 0UL;
|
||||
|
||||
struct hostent* phe = ::gethostbyname(hostname);
|
||||
if (phe == NULL)
|
||||
return 0UL;
|
||||
|
||||
if (phe->h_addrtype != AF_INET)
|
||||
return 0UL;
|
||||
|
||||
for (unsigned int i = 0U; phe->h_addr_list[i] != NULL; i++) {
|
||||
struct in_addr addr;
|
||||
::memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr));
|
||||
if (addr.s_addr != INADDR_LOOPBACK) {
|
||||
address = addr.s_addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011,2013,2015,2016,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2011,2013,2015,2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -47,8 +47,6 @@ public:
|
||||
|
||||
void close();
|
||||
|
||||
unsigned long getLocalAddress() const;
|
||||
|
||||
static in_addr lookup(const std::string& hostName);
|
||||
|
||||
private:
|
||||
|
@ -19,6 +19,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20200427";
|
||||
const char* VERSION = "20200701";
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user