Increase verbosity

network
probonopd 3 days ago
parent 14653d6142
commit cc424e4424
  1. 115
      src/minidexed.cpp

@ -2295,65 +2295,108 @@ void CMiniDexed::UpdateNetwork()
bool CMiniDexed::InitNetwork() bool CMiniDexed::InitNetwork()
{ {
LOGNOTE("InitNetwork: Starting network initialization");
assert(m_pNet == nullptr); assert(m_pNet == nullptr);
TNetDeviceType NetDeviceType = NetDeviceTypeUnknown; TNetDeviceType NetDeviceType = NetDeviceTypeUnknown;
LOGNOTE("InitNetwork: NetworkEnabled=%d, NetworkType=%s", m_pConfig->GetNetworkEnabled(), m_pConfig->GetNetworkType());
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0))
{ {
LOGNOTE("Initializing WLAN"); LOGNOTE("InitNetwork: Initializing WLAN");
if (m_WLAN.Initialize())
{
LOGNOTE("InitNetwork: WLAN initialized");
}
else
{
LOGERR("InitNetwork: Failed to initialize WLAN");
}
if (m_WPASupplicant.Initialize())
{
LOGNOTE("InitNetwork: WPASupplicant initialized");
}
else
{
LOGERR("InitNetwork: Failed to initialize WPASupplicant");
}
if (m_WLAN.Initialize() && m_WPASupplicant.Initialize()) if (m_WLAN.Initialize() && m_WPASupplicant.Initialize())
{ {
LOGNOTE("wlan and wpasupplicant initialized"); LOGNOTE("InitNetwork: WLAN and WPASupplicant initialized");
NetDeviceType = NetDeviceTypeWLAN; NetDeviceType = NetDeviceTypeWLAN;
} }
else else
LOGERR("Failed to initialize WLAN"); {
LOGERR("InitNetwork: Failed to initialize WLAN or WPASupplicant");
}
} }
else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0))
{ {
LOGNOTE("Initializing Ethernet"); LOGNOTE("InitNetwork: Initializing Ethernet");
NetDeviceType = NetDeviceTypeEthernet; NetDeviceType = NetDeviceTypeEthernet;
} }
if (NetDeviceType != NetDeviceTypeUnknown) if (NetDeviceType != NetDeviceTypeUnknown)
{
LOGNOTE("InitNetwork: NetDeviceType set, proceeding to create CNetSubSystem");
if (m_pConfig->GetNetworkDHCP())
{ {
if (m_pConfig->GetNetworkDHCP()) LOGNOTE("InitNetwork: Using DHCP");
m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType); m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType);
else }
m_pNet = new CNetSubSystem( else
m_pConfig->GetNetworkIPAddress().Get(), {
m_pConfig->GetNetworkSubnetMask().Get(), LOGNOTE("InitNetwork: Using static IP");
m_pConfig->GetNetworkDefaultGateway().Get(), LOGNOTE("InitNetwork: IP=%u, Mask=%u, GW=%u, DNS=%u, Hostname=%s",
m_pConfig->GetNetworkDNSServer().Get(), (unsigned)m_pConfig->GetNetworkIPAddress().Get(),
m_pConfig->GetNetworkHostname(), (unsigned)m_pConfig->GetNetworkSubnetMask().Get(),
NetDeviceType (unsigned)m_pConfig->GetNetworkDefaultGateway().Get(),
); (unsigned)m_pConfig->GetNetworkDNSServer().Get(),
m_pConfig->GetNetworkHostname());
if (!m_pNet->Initialize()) m_pNet = new CNetSubSystem(
{ m_pConfig->GetNetworkIPAddress().Get(),
LOGERR("Failed to initialize network subsystem"); m_pConfig->GetNetworkSubnetMask().Get(),
delete m_pNet; m_pConfig->GetNetworkDefaultGateway().Get(),
m_pNet = nullptr; m_pConfig->GetNetworkDNSServer().Get(),
} m_pConfig->GetNetworkHostname(),
NetDeviceType
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); );
}
// Syslog configuration if (!m_pNet->Initialize())
CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress(); {
if (ServerIP.IsSet () && !ServerIP.IsNull ()) LOGERR("InitNetwork: Failed to initialize network subsystem");
{ delete m_pNet;
static const u16 usServerPort = 8514; // standard port is 514 m_pNet = nullptr;
CString IPString; }
ServerIP.Format (&IPString); else
LOGNOTE ("Sending log messages to syslog server %s:%u", {
(const char *) IPString, (unsigned) usServerPort); LOGNOTE("InitNetwork: Network subsystem initialized");
}
new CSysLogDaemon (m_pNet, ServerIP, usServerPort); m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
} LOGNOTE("InitNetwork: Got NetDevice, type=%d", (int)NetDeviceType);
// syslog configuration
CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress();
if (ServerIP.IsSet () && !ServerIP.IsNull ())
{
static const u16 usServerPort = 8514; // standard port is 514
CString IPString;
ServerIP.Format (&IPString);
LOGNOTE ("InitNetwork: Sending log messages to syslog server %s:%u",
(const char *) IPString, (unsigned) usServerPort);
new CSysLogDaemon (m_pNet, ServerIP, usServerPort);
} }
}
else
{
LOGERR("InitNetwork: NetDeviceType is unknown, network not initialized");
}
LOGNOTE("InitNetwork: Done, m_pNet %s", m_pNet ? "set" : "nullptr");
return m_pNet != nullptr; return m_pNet != nullptr;
} }

Loading…
Cancel
Save