Cherry picked changes/fixes from Shawnchain's OpenWrt changes.

This commit is contained in:
Jonathan Naylor 2018-11-09 11:31:10 +00:00
parent ccd6352e72
commit baeee75cfd
7 changed files with 41 additions and 15 deletions

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -216,7 +216,7 @@ bool CAPRSWriterThread::connect()
m_socket.close();
return false;
}
wxLogMessage(wxT("Received login banner : ") + serverResponse);
wxLogMessage(wxT("Received login banner : %s"), serverResponse.c_str());
wxString filter(m_filter);
if (filter.Length() > 0) filter.Prepend(wxT(" filter "));
@ -242,7 +242,7 @@ bool CAPRSWriterThread::connect()
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"));

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -22,8 +22,7 @@
#include <wx/filename.h>
#if !defined(WIN32)
// XXX Check these
#if defined(__linux__)
#include <net/if.h>
#include <arpa/inet.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
m_list[2] = new CEthernet(DX_MULTICAST_ADDRESS, wxT("CQCQCQ "));
#if !defined(WIN32)
#if defined(__linux__)
m_fd = ::open("/dev/net/tun", O_RDWR);
if (m_fd < 0) {
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);
ssize_t len = ::write(m_fd, (char*)m_buffer, length);
@ -253,7 +252,7 @@ CDDData* CDDHandler::read()
if (m_maxRoutes == 0U)
return NULL;
#if defined(WIN32)
#if !defined(WIN32)
return NULL;
#else
// Check that the read() won't block

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -28,6 +28,8 @@
wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL)
{
#ifdef XLX_USE_WGET
wxLogMessage(_T("Downloading XLX reflector list from %s"), xlxHostsFileURL.c_str());
wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"));
wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL;
bool execResult = wxShell(commandLine);

View file

@ -40,6 +40,7 @@ wxIMPLEMENT_APP(CIRCDDBGatewayApp);
const wxChar* NAME_PARAM = wxT("Gateway Name");
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
const wxChar* DEBUG_SWITCH = wxT("debug");
const wxChar* GUI_SWITCH = wxT("gui");
const wxChar* LOGDIR_OPTION = wxT("logdir");
const wxChar* CONFDIR_OPTION = wxT("confdir");
@ -50,6 +51,7 @@ CIRCDDBGatewayApp::CIRCDDBGatewayApp() :
wxApp(),
m_name(),
m_nolog(false),
m_debug(false),
m_gui(false),
m_logDir(),
m_confDir(),
@ -89,6 +91,14 @@ bool CIRCDDBGatewayApp::OnInit()
wxLog* log = new CLogger(m_logDir, logBaseName);
wxLog::SetActiveTarget(log);
if (m_debug) {
wxLog::SetVerbose(true);
wxLog::SetLogLevel(wxLOG_Debug);
} else {
wxLog::SetVerbose(false);
wxLog::SetLogLevel(wxLOG_Message);
}
} else {
new wxLogNull;
}
@ -174,6 +184,7 @@ int CIRCDDBGatewayApp::OnExit()
void CIRCDDBGatewayApp::OnInitCmdLine(wxCmdLineParser& parser)
{
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.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);
@ -188,6 +199,7 @@ bool CIRCDDBGatewayApp::OnCmdLineParsed(wxCmdLineParser& parser)
return false;
m_nolog = parser.Found(NOLOGGING_SWITCH);
m_debug = parser.Found(DEBUG_SWITCH);
m_gui = parser.Found(GUI_SWITCH);
wxString logDir;

View file

@ -54,6 +54,7 @@ public:
private:
wxString m_name;
bool m_nolog;
bool m_debug;
bool m_gui;
wxString m_logDir;
wxString m_confDir;

View file

@ -44,6 +44,7 @@
const wxChar* NAME_PARAM = wxT("Gateway Name");
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
const wxChar* DEBUG_SWITCH = wxT("debug");
const wxChar* LOGDIR_OPTION = wxT("logdir");
const wxChar* CONFDIR_OPTION = wxT("confdir");
const wxChar* DAEMON_SWITCH = wxT("daemon");
@ -67,6 +68,7 @@ int main(int argc, char** argv)
wxCmdLineParser parser(argc, argv);
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.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);
@ -79,6 +81,7 @@ int main(int argc, char** argv)
}
bool nolog = parser.Found(NOLOGGING_SWITCH);
bool debug = parser.Found(DEBUG_SWITCH);
bool daemon = parser.Found(DAEMON_SWITCH);
wxString logDir;
@ -135,7 +138,7 @@ int main(int argc, char** argv)
::fclose(fp);
}
m_gateway = new CIRCDDBGatewayAppD(nolog, logDir, confDir, name);
m_gateway = new CIRCDDBGatewayAppD(nolog, debug, logDir, confDir, name);
if (!m_gateway->init()) {
::wxUninitialize();
return 1;
@ -154,9 +157,10 @@ int main(int argc, char** argv)
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_nolog(nolog),
m_debug(debug),
m_logDir(logDir),
m_confDir(confDir),
m_thread(NULL),
@ -182,7 +186,14 @@ bool CIRCDDBGatewayAppD::init()
wxLog* log = new CLogger(m_logDir, logBaseName);
wxLog::SetActiveTarget(log);
wxLog::SetVerbose();
if (m_debug) {
wxLog::SetVerbose(true);
wxLog::SetLogLevel(wxLOG_Debug);
} else {
wxLog::SetVerbose(false);
wxLog::SetLogLevel(wxLOG_Message);
}
} else {
new wxLogNull;
}

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@
class CIRCDDBGatewayAppD {
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();
bool init();
@ -40,6 +40,7 @@ public:
private:
wxString m_name;
bool m_nolog;
bool m_debug;
wxString m_logDir;
wxString m_confDir;
CIRCDDBGatewayThread* m_thread;