mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2025-12-06 05:32:02 +01:00
Cherry picked changes/fixes from Shawnchain's OpenWrt changes.
This commit is contained in:
parent
ccd6352e72
commit
baeee75cfd
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2014 by Jonathan Naylor G4KLX
|
* Copyright (C) 2010-2014,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -216,7 +216,7 @@ bool CAPRSWriterThread::connect()
|
||||||
m_socket.close();
|
m_socket.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wxLogMessage(wxT("Received login banner : ") + serverResponse);
|
wxLogMessage(wxT("Received login banner : %s"), serverResponse.c_str());
|
||||||
|
|
||||||
wxString filter(m_filter);
|
wxString filter(m_filter);
|
||||||
if (filter.Length() > 0) filter.Prepend(wxT(" filter "));
|
if (filter.Length() > 0) filter.Prepend(wxT(" filter "));
|
||||||
|
|
@ -242,7 +242,7 @@ bool CAPRSWriterThread::connect()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogMessage(wxT("Response from APRS server: ") + serverResponse);
|
wxLogMessage(wxT("Response from APRS server: %s"), serverResponse.c_str());
|
||||||
|
|
||||||
wxLogMessage(wxT("Connected to the APRS server"));
|
wxLogMessage(wxT("Connected to the APRS server"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011,2012,2013 by Jonathan Naylor G4KLX
|
* Copyright (C) 2011,2012,2013,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -22,8 +22,7 @@
|
||||||
|
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if defined(__linux__)
|
||||||
// XXX Check these
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
@ -103,7 +102,7 @@ void CDDHandler::initialise(unsigned int maxRoutes, const wxString& name)
|
||||||
// Add a dummy entry for "DX-Cluster" multicast
|
// Add a dummy entry for "DX-Cluster" multicast
|
||||||
m_list[2] = new CEthernet(DX_MULTICAST_ADDRESS, wxT("CQCQCQ "));
|
m_list[2] = new CEthernet(DX_MULTICAST_ADDRESS, wxT("CQCQCQ "));
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if defined(__linux__)
|
||||||
m_fd = ::open("/dev/net/tun", O_RDWR);
|
m_fd = ::open("/dev/net/tun", O_RDWR);
|
||||||
if (m_fd < 0) {
|
if (m_fd < 0) {
|
||||||
wxLogError(wxT("Cannot open /dev/net/tun"));
|
wxLogError(wxT("Cannot open /dev/net/tun"));
|
||||||
|
|
@ -238,7 +237,7 @@ void CDDHandler::process(CDDData& data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if defined(__linux__)
|
||||||
unsigned int length = data.getEthernetFrame(m_buffer, BUFFER_LENGTH);
|
unsigned int length = data.getEthernetFrame(m_buffer, BUFFER_LENGTH);
|
||||||
|
|
||||||
ssize_t len = ::write(m_fd, (char*)m_buffer, length);
|
ssize_t len = ::write(m_fd, (char*)m_buffer, length);
|
||||||
|
|
@ -253,7 +252,7 @@ CDDData* CDDHandler::read()
|
||||||
if (m_maxRoutes == 0U)
|
if (m_maxRoutes == 0U)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if !defined(WIN32)
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
// Check that the read() won't block
|
// Check that the read() won't block
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2013,2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2010-2013,2015,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL)
|
wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL)
|
||||||
{
|
{
|
||||||
#ifdef XLX_USE_WGET
|
#ifdef XLX_USE_WGET
|
||||||
|
wxLogMessage(_T("Downloading XLX reflector list from %s"), xlxHostsFileURL.c_str());
|
||||||
|
|
||||||
wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"));
|
wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"));
|
||||||
wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL;
|
wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL;
|
||||||
bool execResult = wxShell(commandLine);
|
bool execResult = wxShell(commandLine);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ wxIMPLEMENT_APP(CIRCDDBGatewayApp);
|
||||||
|
|
||||||
const wxChar* NAME_PARAM = wxT("Gateway Name");
|
const wxChar* NAME_PARAM = wxT("Gateway Name");
|
||||||
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
|
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
|
||||||
|
const wxChar* DEBUG_SWITCH = wxT("debug");
|
||||||
const wxChar* GUI_SWITCH = wxT("gui");
|
const wxChar* GUI_SWITCH = wxT("gui");
|
||||||
const wxChar* LOGDIR_OPTION = wxT("logdir");
|
const wxChar* LOGDIR_OPTION = wxT("logdir");
|
||||||
const wxChar* CONFDIR_OPTION = wxT("confdir");
|
const wxChar* CONFDIR_OPTION = wxT("confdir");
|
||||||
|
|
@ -50,6 +51,7 @@ CIRCDDBGatewayApp::CIRCDDBGatewayApp() :
|
||||||
wxApp(),
|
wxApp(),
|
||||||
m_name(),
|
m_name(),
|
||||||
m_nolog(false),
|
m_nolog(false),
|
||||||
|
m_debug(false),
|
||||||
m_gui(false),
|
m_gui(false),
|
||||||
m_logDir(),
|
m_logDir(),
|
||||||
m_confDir(),
|
m_confDir(),
|
||||||
|
|
@ -89,6 +91,14 @@ bool CIRCDDBGatewayApp::OnInit()
|
||||||
|
|
||||||
wxLog* log = new CLogger(m_logDir, logBaseName);
|
wxLog* log = new CLogger(m_logDir, logBaseName);
|
||||||
wxLog::SetActiveTarget(log);
|
wxLog::SetActiveTarget(log);
|
||||||
|
|
||||||
|
if (m_debug) {
|
||||||
|
wxLog::SetVerbose(true);
|
||||||
|
wxLog::SetLogLevel(wxLOG_Debug);
|
||||||
|
} else {
|
||||||
|
wxLog::SetVerbose(false);
|
||||||
|
wxLog::SetLogLevel(wxLOG_Message);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new wxLogNull;
|
new wxLogNull;
|
||||||
}
|
}
|
||||||
|
|
@ -174,6 +184,7 @@ int CIRCDDBGatewayApp::OnExit()
|
||||||
void CIRCDDBGatewayApp::OnInitCmdLine(wxCmdLineParser& parser)
|
void CIRCDDBGatewayApp::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
{
|
{
|
||||||
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
|
parser.AddSwitch(DEBUG_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddSwitch(GUI_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddSwitch(GUI_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
|
|
@ -188,6 +199,7 @@ bool CIRCDDBGatewayApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_nolog = parser.Found(NOLOGGING_SWITCH);
|
m_nolog = parser.Found(NOLOGGING_SWITCH);
|
||||||
|
m_debug = parser.Found(DEBUG_SWITCH);
|
||||||
m_gui = parser.Found(GUI_SWITCH);
|
m_gui = parser.Found(GUI_SWITCH);
|
||||||
|
|
||||||
wxString logDir;
|
wxString logDir;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public:
|
||||||
private:
|
private:
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
bool m_nolog;
|
bool m_nolog;
|
||||||
|
bool m_debug;
|
||||||
bool m_gui;
|
bool m_gui;
|
||||||
wxString m_logDir;
|
wxString m_logDir;
|
||||||
wxString m_confDir;
|
wxString m_confDir;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
const wxChar* NAME_PARAM = wxT("Gateway Name");
|
const wxChar* NAME_PARAM = wxT("Gateway Name");
|
||||||
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
|
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
|
||||||
|
const wxChar* DEBUG_SWITCH = wxT("debug");
|
||||||
const wxChar* LOGDIR_OPTION = wxT("logdir");
|
const wxChar* LOGDIR_OPTION = wxT("logdir");
|
||||||
const wxChar* CONFDIR_OPTION = wxT("confdir");
|
const wxChar* CONFDIR_OPTION = wxT("confdir");
|
||||||
const wxChar* DAEMON_SWITCH = wxT("daemon");
|
const wxChar* DAEMON_SWITCH = wxT("daemon");
|
||||||
|
|
@ -67,6 +68,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
wxCmdLineParser parser(argc, argv);
|
wxCmdLineParser parser(argc, argv);
|
||||||
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
|
parser.AddSwitch(DEBUG_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddSwitch(DAEMON_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddSwitch(DAEMON_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||||
|
|
@ -79,6 +81,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nolog = parser.Found(NOLOGGING_SWITCH);
|
bool nolog = parser.Found(NOLOGGING_SWITCH);
|
||||||
|
bool debug = parser.Found(DEBUG_SWITCH);
|
||||||
bool daemon = parser.Found(DAEMON_SWITCH);
|
bool daemon = parser.Found(DAEMON_SWITCH);
|
||||||
|
|
||||||
wxString logDir;
|
wxString logDir;
|
||||||
|
|
@ -135,7 +138,7 @@ int main(int argc, char** argv)
|
||||||
::fclose(fp);
|
::fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gateway = new CIRCDDBGatewayAppD(nolog, logDir, confDir, name);
|
m_gateway = new CIRCDDBGatewayAppD(nolog, debug, logDir, confDir, name);
|
||||||
if (!m_gateway->init()) {
|
if (!m_gateway->init()) {
|
||||||
::wxUninitialize();
|
::wxUninitialize();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -154,9 +157,10 @@ int main(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CIRCDDBGatewayAppD::CIRCDDBGatewayAppD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name) :
|
CIRCDDBGatewayAppD::CIRCDDBGatewayAppD(bool nolog, bool debug, const wxString& logDir, const wxString& confDir, const wxString& name) :
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_nolog(nolog),
|
m_nolog(nolog),
|
||||||
|
m_debug(debug),
|
||||||
m_logDir(logDir),
|
m_logDir(logDir),
|
||||||
m_confDir(confDir),
|
m_confDir(confDir),
|
||||||
m_thread(NULL),
|
m_thread(NULL),
|
||||||
|
|
@ -182,7 +186,14 @@ bool CIRCDDBGatewayAppD::init()
|
||||||
|
|
||||||
wxLog* log = new CLogger(m_logDir, logBaseName);
|
wxLog* log = new CLogger(m_logDir, logBaseName);
|
||||||
wxLog::SetActiveTarget(log);
|
wxLog::SetActiveTarget(log);
|
||||||
wxLog::SetVerbose();
|
|
||||||
|
if (m_debug) {
|
||||||
|
wxLog::SetVerbose(true);
|
||||||
|
wxLog::SetLogLevel(wxLOG_Debug);
|
||||||
|
} else {
|
||||||
|
wxLog::SetVerbose(false);
|
||||||
|
wxLog::SetLogLevel(wxLOG_Message);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new wxLogNull;
|
new wxLogNull;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2013 by Jonathan Naylor G4KLX
|
* Copyright (C) 2010-2013,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
class CIRCDDBGatewayAppD {
|
class CIRCDDBGatewayAppD {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CIRCDDBGatewayAppD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name);
|
CIRCDDBGatewayAppD(bool nolog, bool debug, const wxString& logDir, const wxString& confDir, const wxString& name);
|
||||||
~CIRCDDBGatewayAppD();
|
~CIRCDDBGatewayAppD();
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
@ -40,6 +40,7 @@ public:
|
||||||
private:
|
private:
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
bool m_nolog;
|
bool m_nolog;
|
||||||
|
bool m_debug;
|
||||||
wxString m_logDir;
|
wxString m_logDir;
|
||||||
wxString m_confDir;
|
wxString m_confDir;
|
||||||
CIRCDDBGatewayThread* m_thread;
|
CIRCDDBGatewayThread* m_thread;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue