redfish: ensure protocol state always returned

The code logic currently calls the systemd 'ListUnits' interface and
then compares the returned services and sockets with a predefined map
that associates the systemd units with specific protocols. The
appropriate 'Port' and 'ProtocolEnabled' properties are then filled into
the Redfish response to a redfish/v1/Managers/bmc/NetworkProtocol query.

The issue is that when certain services like IPMI or SSH are disabled,
the systemd unit will no longer be returned by the 'ListUnits' d-bus
interface. This results in the IPMI and SSH protocols not showing up in
the Redfish query. This commit ensures if a feature like IPMI or SSH is
disabled, the user will still see it in the Redfish query and it will
shows false for 'ProtocolEnabled'.

Looked into calling 'ListUnitFiles' which sounds like it returns all
possible units in the system, but that consistently timed out when
calling in a witherspoon qemu session (vs. the instant response to
`ListUnits` in the same session).

Prior to commit 5c3e927 the code operated differently and would look up
each individual protocol. If it didn't find it, then it would fill in
defaults. The change caused us to no longer put a default in for the
protocols when they are disabled.

Tested:
- Confirmed when IPMI was disabled that a query to NetworkProtocol
  returned with IPMI in its response and 'ProtocolEnabled' was false
- Basic testing to ensure IPMI could be enabled/disabled and Redfish
  responses were as expected
- Ran redfish validator when NetworkProtocol was returning IPMI disabled

Change-Id: I476361413fdb508c93aea88ca6142bc649562c56
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index d06e21a..e4a4b56 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -175,6 +175,17 @@
     asyncResp->res.jsonValue["HTTP"]["Port"] = nullptr;
     asyncResp->res.jsonValue["HTTP"]["ProtocolEnabled"] = false;
 
+    // The ProtocolEnabled of the following protocols is determined by
+    // inspecting the state of associated systemd sockets. If these protocols
+    // have been disabled, then the systemd socket unit files will not be found
+    // and the protocols will not be returned in this Redfish query. Set some
+    // defaults to ensure something is always returned.
+    for (const auto& nwkProtocol : networkProtocolToDbus)
+    {
+        asyncResp->res.jsonValue[nwkProtocol.first]["Port"] = nullptr;
+        asyncResp->res.jsonValue[nwkProtocol.first]["ProtocolEnabled"] = false;
+    }
+
     std::string hostName = getHostName();
 
     asyncResp->res.jsonValue["HostName"] = hostName;