From 681e9b9356de763ebee086f3f6ea633a2f189541 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 10 Feb 2022 21:16:35 -0800 Subject: [PATCH] =?UTF-8?q?Set=20OffPremiseServicesReachableIPv4=20and=20O?= =?UTF-8?q?ffPremiseServicesReachableIP=E2=80=A6=20(#15008)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Set OffPremiseServicesReachableIPv4 and OffPremiseServicesReachableIPv6 to null if the reachable status is unknown * Address review comments --- .../Ameba/DiagnosticDataProviderImpl.cpp | 4 ++-- .../EFR32/DiagnosticDataProviderImpl.cpp | 4 ++-- .../ESP32/DiagnosticDataProviderImpl.cpp | 4 ++-- .../Linux/DiagnosticDataProviderImpl.cpp | 4 ++-- src/platform/P6/DiagnosticDataProviderImpl.cpp | 16 ++++++++-------- src/platform/P6/DiagnosticDataProviderImpl.h | 4 ++-- .../Zephyr/DiagnosticDataProviderImpl.cpp | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp index 9b1f4e68a95101..23a1d5280132d7 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp @@ -143,8 +143,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->type = EMBER_ZCL_INTERFACE_TYPE_ETHERNET; else ifp->type = EMBER_ZCL_INTERFACE_TYPE_WI_FI; - ifp->offPremiseServicesReachableIPv4.SetNonNull(false); - ifp->offPremiseServicesReachableIPv6.SetNonNull(false); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); memcpy(ifp->MacAddress, ifa->hwaddr, sizeof(ifa->hwaddr)); diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index 973f2d4a9eee6c..564ad3bacf166c 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -185,8 +185,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); ifp->name = Span(threadNetworkName, strlen(threadNetworkName)); ifp->fabricConnected = true; - ifp->offPremiseServicesReachableIPv4.SetNonNull(false); - ifp->offPremiseServicesReachableIPv6.SetNonNull(false); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); ifp->type = InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD; #else /* TODO */ diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index dac196d1061c2e..38d2ca41affa08 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -212,8 +212,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->name = CharSpan::fromCharString(ifp->Name); ifp->fabricConnected = true; ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); - ifp->offPremiseServicesReachableIPv4.SetNonNull(false); - ifp->offPremiseServicesReachableIPv6.SetNonNull(false); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK) { ChipLogError(DeviceLayer, "Failed to get network hardware address"); diff --git a/src/platform/Linux/DiagnosticDataProviderImpl.cpp b/src/platform/Linux/DiagnosticDataProviderImpl.cpp index d8bf743a0949ce..02c9a0328b4fa6 100644 --- a/src/platform/Linux/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Linux/DiagnosticDataProviderImpl.cpp @@ -447,8 +447,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->name = CharSpan::fromCharString(ifp->Name); ifp->fabricConnected = ifa->ifa_flags & IFF_RUNNING; ifp->type = ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name); - ifp->offPremiseServicesReachableIPv4.SetNonNull(false); - ifp->offPremiseServicesReachableIPv6.SetNonNull(false); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); if (ConnectivityUtils::GetInterfaceHardwareAddrs(ifa->ifa_name, ifp->MacAddress, kMaxHardwareAddrSize) != CHIP_NO_ERROR) diff --git a/src/platform/P6/DiagnosticDataProviderImpl.cpp b/src/platform/P6/DiagnosticDataProviderImpl.cpp index d17af3c5f94629..37984a7763aceb 100644 --- a/src/platform/P6/DiagnosticDataProviderImpl.cpp +++ b/src/platform/P6/DiagnosticDataProviderImpl.cpp @@ -143,10 +143,10 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(uint8_t & bootReason) void DiagnosticDataProviderImpl::UpdateoffPremiseService(bool ipv4service, bool ipv6service) { /* Enable/Disable IPv4 Off Premise Services */ - mipv4_offpremise = ipv4service; + mipv4_offpremise.SetNonNull(ipv4service); /* Enable/Disable IPv6 Off Premise Services */ - mipv6_offpremise = ipv6service; + mipv6_offpremise.SetNonNull(ipv6service); } CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) @@ -158,12 +158,12 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** if (net_interface) { /* Update Network Interface list */ - ifp->name = CharSpan::fromCharString(net_interface->name); - ifp->fabricConnected = net_interface->flags & NETIF_FLAG_LINK_UP; - ifp->type = EMBER_ZCL_INTERFACE_TYPE_WI_FI; - ifp->offPremiseServicesReachableIPv4.SetNonNull(mipv4_offpremise); - ifp->offPremiseServicesReachableIPv6.SetNonNull(mipv6_offpremise); - ifp->hardwareAddress = ByteSpan(net_interface->hwaddr, net_interface->hwaddr_len); + ifp->name = CharSpan::fromCharString(net_interface->name); + ifp->fabricConnected = net_interface->flags & NETIF_FLAG_LINK_UP; + ifp->type = EMBER_ZCL_INTERFACE_TYPE_WI_FI; + ifp->offPremiseServicesReachableIPv4 = mipv4_offpremise; + ifp->offPremiseServicesReachableIPv6 = mipv6_offpremise; + ifp->hardwareAddress = ByteSpan(net_interface->hwaddr, net_interface->hwaddr_len); } *netifpp = ifp; diff --git a/src/platform/P6/DiagnosticDataProviderImpl.h b/src/platform/P6/DiagnosticDataProviderImpl.h index b15456ebc8351b..aa0af35c04ce94 100644 --- a/src/platform/P6/DiagnosticDataProviderImpl.h +++ b/src/platform/P6/DiagnosticDataProviderImpl.h @@ -109,8 +109,8 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider uint32_t mPacketUnicastTxCount = 0; uint64_t mOverrunCount = 0; uint8_t mWiFiMacAddress[CY_WCM_MAC_ADDR_LEN]; - bool mipv4_offpremise = false; - bool mipv6_offpremise = false; + app::DataModel::Nullable mipv4_offpremise; + app::DataModel::Nullable mipv6_offpremise; }; } // namespace DeviceLayer diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 96f5074427a722..bef1eb0579a677 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -199,8 +199,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ChipLogError(DeviceLayer, "Failed to get interface type"); } - ifp->offPremiseServicesReachableIPv4.SetNonNull(false); - ifp->offPremiseServicesReachableIPv6.SetNonNull(false); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); uint8_t addressSize; if (interfaceIterator.GetHardwareAddress(ifp->MacAddress, addressSize, sizeof(ifp->MacAddress)) != CHIP_NO_ERROR)