Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,13 @@ void CConfig::Load (void)
m_bNetworkDHCP = m_Properties.GetNumber ("NetworkDHCP", 0) != 0;
m_NetworkType = m_Properties.GetString ("NetworkType", "wlan");
m_NetworkHostname = m_Properties.GetString ("NetworkHostname", "MiniDexed");
m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0;
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
if (const u8 *pIP = m_Properties.GetIPAddress("NetworkIPAddress")) m_INetworkIPAddress.Set (pIP);
if (const u8 *pIP = m_Properties.GetIPAddress("NetworkSubnetMask")) m_INetworkSubnetMask.Set (pIP);
if (const u8 *pIP = m_Properties.GetIPAddress("NetworkDefaultGateway")) m_INetworkDefaultGateway.Set (pIP);
m_bSyslogEnabled = m_Properties.GetNumber ("NetworkSyslogEnabled", 0) != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
if (const u8 *pIP = m_Properties.GetIPAddress("NetworkDNSServer")) m_INetworkDNSServer.Set (pIP);
m_bNetworkFTPEnabled = m_Properties.GetNumber("NetworkFTPEnabled", 0) != 0;

const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress");
if (pSyslogServerIP)
{
m_INetworkSyslogServerIPAddress.Set (pSyslogServerIP);
}
if (const u8 *pIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress")) m_INetworkSyslogServerIPAddress.Set (pIP);

m_nMasterVolume = m_Properties.GetNumber ("MasterVolume", 64);
}
Expand Down Expand Up @@ -764,22 +759,22 @@ const char *CConfig::GetNetworkHostname (void) const
return m_NetworkHostname.c_str();
}

CIPAddress CConfig::GetNetworkIPAddress (void) const
const CIPAddress& CConfig::GetNetworkIPAddress (void) const
{
return m_INetworkIPAddress;
}

CIPAddress CConfig::GetNetworkSubnetMask (void) const
const CIPAddress& CConfig::GetNetworkSubnetMask (void) const
{
return m_INetworkSubnetMask;
}

CIPAddress CConfig::GetNetworkDefaultGateway (void) const
const CIPAddress& CConfig::GetNetworkDefaultGateway (void) const
{
return m_INetworkDefaultGateway;
}

CIPAddress CConfig::GetNetworkDNSServer (void) const
const CIPAddress& CConfig::GetNetworkDNSServer (void) const
{
return m_INetworkDNSServer;
}
Expand All @@ -789,7 +784,7 @@ bool CConfig::GetSyslogEnabled (void) const
return m_bSyslogEnabled;
}

CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const
const CIPAddress& CConfig::GetNetworkSyslogServerIPAddress (void) const
{
return m_INetworkSyslogServerIPAddress;
}
Expand Down
10 changes: 5 additions & 5 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ class CConfig // Configuration for MiniDexed
bool GetNetworkDHCP (void) const;
const char *GetNetworkType (void) const;
const char *GetNetworkHostname (void) const;
CIPAddress GetNetworkIPAddress (void) const;
CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const;
const CIPAddress& GetNetworkIPAddress (void) const;
const CIPAddress& GetNetworkSubnetMask (void) const;
const CIPAddress& GetNetworkDefaultGateway (void) const;
const CIPAddress& GetNetworkDNSServer (void) const;
bool GetSyslogEnabled (void) const;
CIPAddress GetNetworkSyslogServerIPAddress (void) const;
const CIPAddress& GetNetworkSyslogServerIPAddress (void) const;
bool GetNetworkFTPEnabled (void) const;

private:
Expand Down
27 changes: 20 additions & 7 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ void CMiniDexed::UpdateNetwork()
if (m_pConfig->GetSyslogEnabled())
{
LOGNOTE ("Syslog server is enabled in configuration");
CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress();
const CIPAddress& ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress();
if (ServerIP.IsSet () && !ServerIP.IsNull ())
{
static const u16 usServerPort = 8514;
Expand Down Expand Up @@ -2416,18 +2416,31 @@ bool CMiniDexed::InitNetwork()

if (NetDeviceType != NetDeviceTypeUnknown)
{
LOGNOTE("CMiniDexed::InitNetwork: Creating CNetSubSystem");
if (m_pConfig->GetNetworkDHCP())
{
LOGNOTE("CMiniDexed::InitNetwork: Creating CNetSubSystem with DHCP (Hostname: %s)", m_pConfig->GetNetworkHostname());
m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType);
else
}
else if (m_pConfig->GetNetworkIPAddress().IsSet() && m_pConfig->GetNetworkSubnetMask().IsSet())
{
CString IPString, SubnetString;
m_pConfig->GetNetworkIPAddress().Format (&IPString);
m_pConfig->GetNetworkSubnetMask().Format (&SubnetString);
LOGNOTE("CMiniDexed::InitNetwork: Creating CNetSubSystem with IP: %s / %s", (const char*)IPString, (const char*)SubnetString);
m_pNet = new CNetSubSystem(
m_pConfig->GetNetworkIPAddress().Get(),
m_pConfig->GetNetworkSubnetMask().Get(),
m_pConfig->GetNetworkDefaultGateway().Get(),
m_pConfig->GetNetworkDNSServer().Get(),
m_pConfig->GetNetworkDefaultGateway().IsSet() ? m_pConfig->GetNetworkDefaultGateway().Get() : 0,
m_pConfig->GetNetworkDNSServer().IsSet() ? m_pConfig->GetNetworkDNSServer().Get() : 0,
m_pConfig->GetNetworkHostname(),
NetDeviceType
);
NetDeviceType);
}
else
{
LOGNOTE ("CMiniDexed::InitNetwork: Neither DHCP nor IP address/subnet mask is set, using DHCP (Hostname: %s)", m_pConfig->GetNetworkHostname());
m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType);
}

if (!m_pNet || !m_pNet->Initialize(false)) // Check if m_pNet allocation succeeded
{
LOGERR("CMiniDexed::InitNetwork: Failed to initialize network subsystem");
Expand Down
Loading