Update to IPv6.

This commit is contained in:
Jonathan Naylor 2020-11-16 15:42:37 +00:00
parent 086e665af8
commit d617161772
8 changed files with 77 additions and 68 deletions

View file

@ -1,4 +1,4 @@
ircDDB Gateway - 20180627
ircDDB Gateway - 20201116
=========================
20101010
@ -1488,3 +1488,8 @@ Support the GPS data from the Kenwood TH-D74.
Add support for external GPS input for mobile systems.
Add audio bypass processing for fast data mode.
20201116
--------
Add support for IPv6.

View file

@ -24,9 +24,9 @@
const wxString VENDOR_NAME = wxT("G4KLX");
#if defined(__WXDEBUG__)
const wxString VERSION = wxT("20200621 - DEBUG");
const wxString VERSION = wxT("20201116 - DEBUG");
#else
const wxString VERSION = wxT("20190621");
const wxString VERSION = wxT("20201116");
#endif
#endif

View file

@ -16,10 +16,11 @@ This is the ircDDB Gateway. It allows a D-Star Repeater to interface into callsi
* Remote control interface.
* StarNet server.
* Ability to set policies for reflector usage.
* IPv6 support.
There are many external programs that allow for inserting voice or text messages, as well as remote control operation.
They all build on 32-bit and 64-bit Linux as well as on Windows using Visual Studio 2017 on x86 and x64.
They all build on 32-bit and 64-bit Linux as well as on Windows using Visual Studio 2019 on x86 and x64.
This software is licenced under the GPL v2.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2011,2013 by Jonathan Naylor G4KLX
* Copyright (C) 2011,2013,2020 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
@ -25,8 +25,8 @@ const unsigned int MAX_RETRIES = 3U;
CRemoteControlRemoteControlHandler::CRemoteControlRemoteControlHandler(const wxString& address, unsigned int port) :
m_socket(wxEmptyString, 0U),
m_address(),
m_port(port),
m_addr(),
m_addrLen(0U),
m_loggedIn(false),
m_retryCount(0U),
m_type(RCT_NONE),
@ -38,7 +38,7 @@ m_outLength(0U)
wxASSERT(!address.IsEmpty());
wxASSERT(port > 0U);
m_address = CUDPReaderWriter::lookup(address);
CUDPReaderWriter::lookup(address, port, m_addr, m_addrLen);
m_inBuffer = new unsigned char[BUFFER_LENGTH];
m_outBuffer = new unsigned char[BUFFER_LENGTH];
@ -59,10 +59,10 @@ RC_TYPE CRemoteControlRemoteControlHandler::readType()
{
m_type = RCT_NONE;
in_addr address;
unsigned int port;
sockaddr_storage addr;
unsigned int addrLen;
int length = m_socket.read(m_inBuffer, BUFFER_LENGTH, address, port);
int length = m_socket.read(m_inBuffer, BUFFER_LENGTH, addr, addrLen);
if (length <= 0)
return m_type;
@ -258,13 +258,13 @@ bool CRemoteControlRemoteControlHandler::login()
if (m_loggedIn)
return false;
if (m_address.s_addr == INADDR_NONE)
if (m_addrLen == 0U)
return false;
::memcpy(m_outBuffer, "LIN", 3U);
m_outLength = 3U;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -287,7 +287,7 @@ bool CRemoteControlRemoteControlHandler::getCallsigns()
::memcpy(m_outBuffer, "GCS", 3U);
m_outLength = 3U;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -316,7 +316,7 @@ bool CRemoteControlRemoteControlHandler::sendHash(const unsigned char* hash, uns
m_outLength += length;
p += length;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -347,7 +347,7 @@ bool CRemoteControlRemoteControlHandler::getRepeater(const wxString& callsign)
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -378,7 +378,7 @@ bool CRemoteControlRemoteControlHandler::getStarNet(const wxString& callsign)
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -422,7 +422,7 @@ bool CRemoteControlRemoteControlHandler::link(const wxString& callsign, RECONNEC
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -466,7 +466,7 @@ bool CRemoteControlRemoteControlHandler::unlink(const wxString& callsign, PROTOC
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -505,7 +505,7 @@ bool CRemoteControlRemoteControlHandler::logoff(const wxString& callsign, const
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -524,7 +524,7 @@ bool CRemoteControlRemoteControlHandler::logout()
m_outLength = 3U;
for (unsigned int i = 0U; i < 5U; i++) {
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -545,7 +545,7 @@ bool CRemoteControlRemoteControlHandler::retry()
return false;
}
m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
}
return true;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
* Copyright (C) 2014,2020 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
@ -112,12 +112,14 @@ CTextTransmit::~CTextTransmit()
bool CTextTransmit::run()
{
bool opened = m_socket.open();
sockaddr_storage addr;
unsigned int addrLen;
CUDPReaderWriter::lookup(wxT("127.0.0.1"), G2_DV_PORT, addr, addrLen);
bool opened = m_socket.open(addr);
if (!opened)
return false;
in_addr address = CUDPReaderWriter::lookup(wxT("127.0.0.1"));
unsigned int id = CHeaderData::createId();
wxString callsignG = m_callsign.Left(LONG_CALLSIGN_LENGTH - 1U);
@ -130,7 +132,7 @@ bool CTextTransmit::run()
header.setRptCall1(callsignG);
header.setRptCall2(m_callsign);
header.setYourCall(wxT("CQCQCQ "));
header.setDestination(address, G2_DV_PORT);
header.setDestination(addr, addrLen);
sendHeader(header);
@ -139,7 +141,7 @@ bool CTextTransmit::run()
encoder.setTextData(m_text);
CAMBEData data;
data.setDestination(address, G2_DV_PORT);
data.setDestination(addr, addrLen);
data.setId(id);
wxStopWatch timer;
@ -192,7 +194,7 @@ bool CTextTransmit::sendHeader(const CHeaderData& header)
unsigned int length = header.getG2Data(buffer, 60U, true);
for (unsigned int i = 0U; i < 2U; i++) {
bool res = m_socket.write(buffer, length, header.getYourAddress(), header.getYourPort());
bool res = m_socket.write(buffer, length, header.getYourAddr(), header.getYourAddrLen());
if (!res)
return false;
}
@ -205,5 +207,5 @@ bool CTextTransmit::sendData(const CAMBEData& data)
unsigned char buffer[40U];
unsigned int length = data.getG2Data(buffer, 40U);
return m_socket.write(buffer, length, data.getYourAddress(), data.getYourPort());
return m_socket.write(buffer, length, data.getYourAddr(), data.getYourAddrLen());
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012,2013 by Jonathan Naylor G4KLX
* Copyright (C) 2012,2013,2020 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
@ -43,7 +43,8 @@ m_callsignC(),
m_callsignD(),
m_callsignE(),
m_callsignG(),
m_address(),
m_addr(),
m_addrLen(0U),
m_language(LANG_ENGLISH_UK_1),
m_format(FORMAT_VOICE_TIME),
m_interval(INTERVAL_15MINS),
@ -56,8 +57,6 @@ m_encoder(),
m_data(NULL),
m_killed(false)
{
m_address.s_addr = INADDR_NONE;
m_data = new CAMBEData*[MAX_FRAMES];
for (unsigned int i = 0U; i < MAX_FRAMES; i++)
@ -76,7 +75,7 @@ CTimeServerThread::~CTimeServerThread()
void CTimeServerThread::run()
{
// Wait here until we have the essentials to run
while (!m_killed && m_address.s_addr == INADDR_NONE && m_callsignA.IsEmpty() && m_callsignB.IsEmpty() && m_callsignC.IsEmpty() && m_callsignD.IsEmpty() && m_callsignE.IsEmpty())
while (!m_killed && m_addrLen == 0U && m_callsignA.IsEmpty() && m_callsignB.IsEmpty() && m_callsignC.IsEmpty() && m_callsignD.IsEmpty() && m_callsignE.IsEmpty())
::wxMilliSleep(500UL); // 1/2 sec
if (m_killed)
@ -162,9 +161,9 @@ bool CTimeServerThread::setGateway(const wxString& callsign, bool sendA, bool se
m_callsign.Append(wxT(" "));
m_address = CUDPReaderWriter::lookup(address);
CUDPReaderWriter::lookup(address, G2_DV_PORT, m_addr, m_addrLen);
bool ret = m_socket.open();
bool ret = m_socket.open(m_addr);
if (!ret)
return false;
@ -1158,7 +1157,7 @@ bool CTimeServerThread::lookup(const wxString &id)
unsigned char* dataIn = m_ambe + (start + i) * VOICE_FRAME_LENGTH_BYTES;
CAMBEData* dataOut = new CAMBEData;
dataOut->setDestination(m_address, G2_DV_PORT);
dataOut->setDestination(m_addr, m_addrLen);
dataOut->setSeq(m_seqNo);
unsigned char buffer[DV_FRAME_LENGTH_BYTES];
@ -1205,7 +1204,7 @@ void CTimeServerThread::end()
{
CAMBEData* dataOut = new CAMBEData;
dataOut->setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
dataOut->setDestination(m_address, G2_DV_PORT);
dataOut->setDestination(m_addr, m_addrLen);
dataOut->setSeq(m_seqNo);
dataOut->setEnd(true);
@ -1226,7 +1225,7 @@ bool CTimeServerThread::send(const wxArrayString &words, unsigned int hour, unsi
header.setRptCall1(m_callsignG);
header.setRptCall2(m_callsign); // Just for the slow data header
header.setYourCall(wxT("CQCQCQ "));
header.setDestination(m_address, G2_DV_PORT);
header.setDestination(m_addr, m_addrLen);
wxString slowData;
switch (m_language) {
@ -1320,7 +1319,7 @@ bool CTimeServerThread::send(const wxArrayString &words, unsigned int hour, unsi
for (unsigned int i = 0U; i < 21U; i++) {
CAMBEData* dataOut = new CAMBEData;
dataOut->setDestination(m_address, G2_DV_PORT);
dataOut->setDestination(m_addr, m_addrLen);
dataOut->setSeq(i);
unsigned char buffer[DV_FRAME_LENGTH_BYTES];
@ -1342,7 +1341,7 @@ bool CTimeServerThread::send(const wxArrayString &words, unsigned int hour, unsi
CAMBEData* dataOut = new CAMBEData;
dataOut->setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
dataOut->setDestination(m_address, G2_DV_PORT);
dataOut->setDestination(m_addr, m_addrLen);
dataOut->setSeq(0U);
dataOut->setEnd(true);
@ -1443,7 +1442,7 @@ bool CTimeServerThread::sendHeader(const CHeaderData &header)
return true;
#else
for (unsigned int i = 0U; i < 5U; i++) {
bool res = m_socket.write(buffer, length, header.getYourAddress(), header.getYourPort());
bool res = m_socket.write(buffer, length, header.getYourAddr(), header.getYourAddrLen());
if (!res)
return false;
}
@ -1461,6 +1460,6 @@ bool CTimeServerThread::sendData(const CAMBEData& data)
CUtils::dump(wxT("Sending Data"), buffer, length);
return true;
#else
return m_socket.write(buffer, length, data.getYourAddress(), data.getYourPort());
return m_socket.write(buffer, length, data.getYourAddr(), data.getYourAddrLen());
#endif
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2011,2013 by Jonathan Naylor G4KLX
* Copyright (C) 2011,2013,2020 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
@ -25,8 +25,8 @@ const unsigned int MAX_RETRIES = 3U;
CTimerControlRemoteControlHandler::CTimerControlRemoteControlHandler(const wxString& address, unsigned int port) :
m_socket(wxEmptyString, 0U),
m_address(),
m_port(port),
m_addr(),
m_addrLen(0U),
m_loggedIn(false),
m_retryCount(0U),
m_type(TCT_NONE),
@ -38,7 +38,7 @@ m_outLength(0U)
wxASSERT(!address.IsEmpty());
wxASSERT(port > 0U);
m_address = CUDPReaderWriter::lookup(address);
CUDPReaderWriter::lookup(address, port, m_addr, m_addrLen);
m_inBuffer = new unsigned char[BUFFER_LENGTH];
m_outBuffer = new unsigned char[BUFFER_LENGTH];
@ -52,17 +52,17 @@ CTimerControlRemoteControlHandler::~CTimerControlRemoteControlHandler()
bool CTimerControlRemoteControlHandler::open()
{
return m_socket.open();
return m_socket.open(m_addr);
}
TC_TYPE CTimerControlRemoteControlHandler::readType()
{
m_type = TCT_NONE;
in_addr address;
unsigned int port;
sockaddr_storage addr;
unsigned int addrLen;
int length = m_socket.read(m_inBuffer, BUFFER_LENGTH, address, port);
int length = m_socket.read(m_inBuffer, BUFFER_LENGTH, addr, addrLen);
if (length <= 0)
return m_type;
@ -141,13 +141,13 @@ bool CTimerControlRemoteControlHandler::login()
if (m_loggedIn)
return false;
if (m_address.s_addr == INADDR_NONE)
if (m_addrLen == 0U)
return false;
::memcpy(m_outBuffer, "LIN", 3U);
m_outLength = 3U;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -170,7 +170,7 @@ bool CTimerControlRemoteControlHandler::getCallsigns()
::memcpy(m_outBuffer, "GCS", 3U);
m_outLength = 3U;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -199,7 +199,7 @@ bool CTimerControlRemoteControlHandler::sendHash(const unsigned char* hash, unsi
m_outLength += length;
p += length;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -243,7 +243,7 @@ bool CTimerControlRemoteControlHandler::link(const wxString& callsign, RECONNECT
m_outLength += LONG_CALLSIGN_LENGTH;
p += LONG_CALLSIGN_LENGTH;
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -262,7 +262,7 @@ bool CTimerControlRemoteControlHandler::logout()
m_outLength = 3U;
for (unsigned int i = 0U; i < 5U; i++) {
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
bool ret = m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
if (!ret) {
m_retryCount = 0U;
return false;
@ -283,7 +283,7 @@ bool CTimerControlRemoteControlHandler::retry()
return false;
}
m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
m_socket.write(m_outBuffer, m_outLength, m_addr, m_addrLen);
}
return true;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
* Copyright (C) 2014,2020 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
@ -74,12 +74,14 @@ CVoiceTransmit::~CVoiceTransmit()
bool CVoiceTransmit::run()
{
bool opened = m_socket.open();
sockaddr_storage addr;
unsigned int addrLen;
CUDPReaderWriter::lookup(wxT("127.0.0.1"), G2_DV_PORT, addr, addrLen);
bool opened = m_socket.open(addr);
if (!opened)
return false;
in_addr address = CUDPReaderWriter::lookup(wxT("127.0.0.1"));
unsigned int id = CHeaderData::createId();
wxString callsignG = m_callsign.Left(LONG_CALLSIGN_LENGTH - 1U);
@ -94,7 +96,7 @@ bool CVoiceTransmit::run()
header->setId(id);
header->setRptCall1(callsignG);
header->setRptCall2(m_callsign);
header->setDestination(address, G2_DV_PORT);
header->setDestination(addr, addrLen);
sendHeader(header);
@ -119,7 +121,7 @@ bool CVoiceTransmit::run()
CAMBEData data;
data.setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
data.setDestination(address, G2_DV_PORT);
data.setDestination(addr, addrLen);
data.setId(id);
data.setSeq(seqNo);
data.setEnd(true);
@ -133,7 +135,7 @@ bool CVoiceTransmit::run()
seqNo = ambe->getSeq();
ambe->setDestination(address, G2_DV_PORT);
ambe->setDestination(addr, addrLen);
ambe->setEnd(false);
ambe->setId(id);
@ -156,7 +158,7 @@ bool CVoiceTransmit::sendHeader(CHeaderData* header)
unsigned int length = header->getG2Data(buffer, 60U, true);
for (unsigned int i = 0U; i < 2U; i++) {
bool res = m_socket.write(buffer, length, header->getYourAddress(), header->getYourPort());
bool res = m_socket.write(buffer, length, header->getYourAddr(), header->getYourAddrLen());
if (!res)
return false;
}
@ -171,5 +173,5 @@ bool CVoiceTransmit::sendData(CAMBEData* data)
unsigned char buffer[40U];
unsigned int length = data->getG2Data(buffer, 40U);
return m_socket.write(buffer, length, data->getYourAddress(), data->getYourPort());
return m_socket.write(buffer, length, data->getYourAddr(), data->getYourAddrLen());
}