From 8ada09c4e1b0e89ccccc24178ac663311aa61cd8 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 5 Mar 2024 09:20:36 +0100 Subject: [PATCH 1/2] Update to master branch --- ...kit-requirement-to-fix-ptpython-vers.patch | 27 --- ...3-Linux-Increase-number-of-endpoints.patch | 0 ...ommissioning-with-code-on-network-on.patch | 90 --------- ...erface-ID-from-IP-address-string-as-.patch | 54 ----- ...w-early-logging-initialization-31945.patch | 51 ----- ...-Make-Logging-Filtering-global-31944.patch | 186 ------------------ ...ip-interfaces-without-IPv4-addresses.patch | 96 --------- connectedhomeip | 2 +- 8 files changed, 1 insertion(+), 505 deletions(-) delete mode 100644 0003-Bump-prompt-toolkit-requirement-to-fix-ptpython-vers.patch rename 0009-Linux-Increase-number-of-endpoints.patch => 0003-Linux-Increase-number-of-endpoints.patch (100%) delete mode 100644 0004-Python-Support-commissioning-with-code-on-network-on.patch delete mode 100644 0005-Python-Parse-Interface-ID-from-IP-address-string-as-.patch delete mode 100644 0006-Python-Allow-early-logging-initialization-31945.patch delete mode 100644 0007-Python-Make-Logging-Filtering-global-31944.patch delete mode 100644 0008-MinMDNS-skip-interfaces-without-IPv4-addresses.patch diff --git a/0003-Bump-prompt-toolkit-requirement-to-fix-ptpython-vers.patch b/0003-Bump-prompt-toolkit-requirement-to-fix-ptpython-vers.patch deleted file mode 100644 index 27c20c0..0000000 --- a/0003-Bump-prompt-toolkit-requirement-to-fix-ptpython-vers.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 1536ca20c5917578ca40ce509400e97b52751788 Mon Sep 17 00:00:00 2001 -Message-ID: <1536ca20c5917578ca40ce509400e97b52751788.1703082429.git.stefan@agner.ch> -From: Andrei Litvin -Date: Wed, 13 Dec 2023 13:27:16 -0500 -Subject: [PATCH] Bump prompt-toolkit requirement to fix ptpython version - update (#30987) - ---- - scripts/setup/constraints.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/scripts/setup/constraints.txt b/scripts/setup/constraints.txt -index b0e9aed4ae..ad80df20c4 100644 ---- a/scripts/setup/constraints.txt -+++ b/scripts/setup/constraints.txt -@@ -163,7 +163,7 @@ portpicker==1.5.2 - # via - # -r requirements.all.txt - # mobly --prompt-toolkit==3.0.38 -+prompt-toolkit==3.0.43 - # via ipython - protobuf==4.24.4 - # via --- -2.43.0 - diff --git a/0009-Linux-Increase-number-of-endpoints.patch b/0003-Linux-Increase-number-of-endpoints.patch similarity index 100% rename from 0009-Linux-Increase-number-of-endpoints.patch rename to 0003-Linux-Increase-number-of-endpoints.patch diff --git a/0004-Python-Support-commissioning-with-code-on-network-on.patch b/0004-Python-Support-commissioning-with-code-on-network-on.patch deleted file mode 100644 index ba5a222..0000000 --- a/0004-Python-Support-commissioning-with-code-on-network-on.patch +++ /dev/null @@ -1,90 +0,0 @@ -From e34fbf7b58908fa777335cbc4da4a0d6b26fe6d7 Mon Sep 17 00:00:00 2001 -Message-ID: -From: Stefan Agner -Date: Thu, 14 Dec 2023 13:33:05 +0100 -Subject: [PATCH] [Python] Support commissioning with code on network only - (#31000) - -* [Python] Support commissioning with code on network only - -Add an additional parameter to support commissioning on network only. -This is useful when a manual pairing code is given and we know the -device is on the network already. - -* Use consistent casing for newly added parameter ---- - .../python/ChipDeviceController-ScriptBinding.cpp | 10 +++++++--- - src/controller/python/chip/ChipDeviceCtrl.py | 6 +++--- - 2 files changed, 10 insertions(+), 6 deletions(-) - -diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -index a7732a4836..c4b12570fd 100644 ---- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp -+++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -@@ -50,6 +50,7 @@ - #include - #include - #include -+#include - - #include - #include -@@ -135,7 +136,7 @@ PyChipError pychip_DeviceController_ConnectBLE(chip::Controller::DeviceCommissio - PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommissioner * devCtrl, const char * peerAddrStr, - uint32_t setupPINCode, chip::NodeId nodeid); - PyChipError pychip_DeviceController_ConnectWithCode(chip::Controller::DeviceCommissioner * devCtrl, const char * onboardingPayload, -- chip::NodeId nodeid); -+ chip::NodeId nodeid, bool networkOnly); - PyChipError pychip_DeviceController_UnpairDevice(chip::Controller::DeviceCommissioner * devCtrl, chip::NodeId remoteDeviceId, - DeviceUnpairingCompleteFunct callback); - PyChipError pychip_DeviceController_SetThreadOperationalDataset(const char * threadOperationalDataset, uint32_t size); -@@ -397,10 +398,13 @@ PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommission - } - - PyChipError pychip_DeviceController_ConnectWithCode(chip::Controller::DeviceCommissioner * devCtrl, const char * onboardingPayload, -- chip::NodeId nodeid) -+ chip::NodeId nodeid, bool networkOnly) - { -+ chip::Controller::DiscoveryType discoveryType = chip::Controller::DiscoveryType::kAll; - sPairingDelegate.SetExpectingPairingComplete(true); -- return ToPyChipError(devCtrl->PairDevice(nodeid, onboardingPayload, sCommissioningParameters)); -+ if (networkOnly) -+ discoveryType = chip::Controller::DiscoveryType::kDiscoveryNetworkOnly; -+ return ToPyChipError(devCtrl->PairDevice(nodeid, onboardingPayload, sCommissioningParameters, discoveryType)); - } - - namespace { -diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py -index 22ae11cda6..de6f1fff03 100644 ---- a/src/controller/python/chip/ChipDeviceCtrl.py -+++ b/src/controller/python/chip/ChipDeviceCtrl.py -@@ -1422,7 +1422,7 @@ class ChipDeviceControllerBase(): - self._dmLib.pychip_DeviceController_ConnectIP.restype = PyChipError - - self._dmLib.pychip_DeviceController_ConnectWithCode.argtypes = [ -- c_void_p, c_char_p, c_uint64] -+ c_void_p, c_char_p, c_uint64, c_bool] - self._dmLib.pychip_DeviceController_ConnectWithCode.restype = PyChipError - - self._dmLib.pychip_DeviceController_UnpairDevice.argtypes = [ -@@ -1726,7 +1726,7 @@ class ChipDeviceController(ChipDeviceControllerBase): - return PyChipError(CHIP_ERROR_TIMEOUT) - return self._ChipStack.commissioningEventRes - -- def CommissionWithCode(self, setupPayload: str, nodeid: int) -> PyChipError: -+ def CommissionWithCode(self, setupPayload: str, nodeid: int, networkOnly: bool = False) -> PyChipError: - self.CheckIsActive() - - setupPayload = setupPayload.encode() + b'\0' -@@ -1739,7 +1739,7 @@ class ChipDeviceController(ChipDeviceControllerBase): - - self._ChipStack.CallAsync( - lambda: self._dmLib.pychip_DeviceController_ConnectWithCode( -- self.devCtrl, setupPayload, nodeid) -+ self.devCtrl, setupPayload, nodeid, networkOnly) - ) - if not self._ChipStack.commissioningCompleteEvent.isSet(): - # Error 50 is a timeout --- -2.43.0 - diff --git a/0005-Python-Parse-Interface-ID-from-IP-address-string-as-.patch b/0005-Python-Parse-Interface-ID-from-IP-address-string-as-.patch deleted file mode 100644 index f42625c..0000000 --- a/0005-Python-Parse-Interface-ID-from-IP-address-string-as-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 5b5e383674e78115107c7a95eb563902cd6b6014 Mon Sep 17 00:00:00 2001 -Message-ID: <5b5e383674e78115107c7a95eb563902cd6b6014.1704821887.git.stefan@agner.ch> -From: Stefan Agner -Date: Tue, 9 Jan 2024 18:35:50 +0100 -Subject: [PATCH] [Python] Parse Interface ID from IP address string as well - -Currently, when passing a link-local address with an interface specified -using the % notation leads to "CHIP Error 0x0000002F: Invalid -argument". - -Correctly parse the interface ID as well and pass it to the PeerAddress -object. ---- - .../python/ChipDeviceController-ScriptBinding.cpp | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -index a7732a4836..e3e4de8d88 100644 ---- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp -+++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -@@ -383,13 +383,14 @@ PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommission - uint32_t setupPINCode, chip::NodeId nodeid) - { - chip::Inet::IPAddress peerAddr; -+ chip::Inet::InterfaceId ifaceOutput; - chip::Transport::PeerAddress addr; - chip::RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode); - -- VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); -+ VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr, ifaceOutput), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); - - // TODO: IP rendezvous should use TCP connection. -- addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr); -+ addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr).SetInterface(ifaceOutput); - params.SetPeerAddress(addr).SetDiscriminator(0); - - sPairingDelegate.SetExpectingPairingComplete(true); -@@ -577,10 +578,11 @@ PyChipError pychip_DeviceController_EstablishPASESessionIP(chip::Controller::Dev - uint32_t setupPINCode, chip::NodeId nodeid, uint16_t port) - { - chip::Inet::IPAddress peerAddr; -+ chip::Inet::InterfaceId ifaceOutput; - chip::Transport::PeerAddress addr; - RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode); -- VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); -- addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr); -+ VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr, ifaceOutput), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); -+ addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr).SetInterface(ifaceOutput); - if (port != 0) - { - addr.SetPort(port); --- -2.43.0 - diff --git a/0006-Python-Allow-early-logging-initialization-31945.patch b/0006-Python-Allow-early-logging-initialization-31945.patch deleted file mode 100644 index 57dbbff..0000000 --- a/0006-Python-Allow-early-logging-initialization-31945.patch +++ /dev/null @@ -1,51 +0,0 @@ -From e4d6e50d1485110068e85ec28836b37d386fbd47 Mon Sep 17 00:00:00 2001 -From: Stefan Agner -Date: Tue, 13 Feb 2024 22:38:46 +0100 -Subject: [PATCH] [Python] Allow early logging initialization (#31945) - -* [Python] Allow early logging initialization - -Allow to initialize logging before initializing the stack. Similar to -tracing, logging doesn't need the stack to be setup. This allows to -redirect logging to Python as early as possible. - -* Log using chip.native module for clarity - -Use chip.native module for all redirected logs. This separates it from -logs written by the Python bindings themselfs. ---- - src/controller/python/chip/logging/__init__.py | 2 +- - src/controller/python/chip/logging/library_handle.py | 4 +++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/src/controller/python/chip/logging/__init__.py b/src/controller/python/chip/logging/__init__.py -index 980c33ac92..6916c8b272 100644 ---- a/src/controller/python/chip/logging/__init__.py -+++ b/src/controller/python/chip/logging/__init__.py -@@ -32,7 +32,7 @@ def _RedirectToPythonLogging(category, module, message): - module = module.decode('utf-8') - message = message.decode('utf-8') - -- logger = logging.getLogger('chip.%s' % module) -+ logger = logging.getLogger('chip.native.%s' % module) - - if category == ERROR_CATEGORY_ERROR: - logger.error("%s", message) -diff --git a/src/controller/python/chip/logging/library_handle.py b/src/controller/python/chip/logging/library_handle.py -index ae34f502fd..f74a810b46 100644 ---- a/src/controller/python/chip/logging/library_handle.py -+++ b/src/controller/python/chip/logging/library_handle.py -@@ -27,7 +27,9 @@ def _GetLoggingLibraryHandle() -> ctypes.CDLL: - native methods. - """ - -- handle = chip.native.GetLibraryHandle() -+ # Getting a handle without requiring init, as logging methods -+ # do not require chip stack startup -+ handle = chip.native.GetLibraryHandle(chip.native.HandleFlags(0)) - - # Uses one of the type decorators as an indicator for everything being - # initialized. --- -2.43.0 - diff --git a/0007-Python-Make-Logging-Filtering-global-31944.patch b/0007-Python-Make-Logging-Filtering-global-31944.patch deleted file mode 100644 index 5242566..0000000 --- a/0007-Python-Make-Logging-Filtering-global-31944.patch +++ /dev/null @@ -1,186 +0,0 @@ -From bf8ce26830a60e0d247f37f3b26d2f2244cb986d Mon Sep 17 00:00:00 2001 -From: Stefan Agner -Date: Wed, 14 Feb 2024 15:11:44 +0100 -Subject: [PATCH] [Python] Make Logging Filtering global (#31944) - -Log filtering is a global affair, so move the filtering functions to a -global context too. This allows to setup logging before creating any -device controller. It aligns with how the SDK treats logging. - -Also enable log filtering for the Linux platform to make the -functionality useful on Linux. ---- - src/controller/python/BUILD.gn | 1 + - .../ChipDeviceController-ScriptBinding.cpp | 20 ---------- - src/controller/python/chip/ChipDeviceCtrl.py | 17 --------- - .../python/chip/logging/LoggingFilter.cpp | 37 +++++++++++++++++++ - .../python/chip/logging/__init__.py | 13 +++++++ - src/platform/Linux/CHIPPlatformConfig.h | 2 +- - 6 files changed, 52 insertions(+), 38 deletions(-) - create mode 100644 src/controller/python/chip/logging/LoggingFilter.cpp - -diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn -index 140ef1e08d..5fc2212098 100644 ---- a/src/controller/python/BUILD.gn -+++ b/src/controller/python/BUILD.gn -@@ -81,6 +81,7 @@ shared_library("ChipDeviceCtrl") { - "chip/internal/ChipThreadWork.cpp", - "chip/internal/ChipThreadWork.h", - "chip/internal/CommissionerImpl.cpp", -+ "chip/logging/LoggingFilter.cpp", - "chip/logging/LoggingRedirect.cpp", - "chip/native/ChipMainLoopWork.h", - "chip/native/PyChipError.cpp", -diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -index 2576a36030..b4f2edb295 100644 ---- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp -+++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp -@@ -71,7 +71,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -200,9 +199,6 @@ PyChipError pychip_ScriptDevicePairingDelegate_SetOpenWindowCompleteCallback( - // BLE - PyChipError pychip_DeviceCommissioner_CloseBleConnection(chip::Controller::DeviceCommissioner * devCtrl); - --uint8_t pychip_DeviceController_GetLogFilter(); --void pychip_DeviceController_SetLogFilter(uint8_t category); -- - const char * pychip_Stack_ErrorToString(ChipError::StorageType err); - const char * pychip_Stack_StatusReportToString(uint32_t profileId, uint16_t statusCode); - void pychip_Stack_SetLogFunct(LogMessageFunct logFunct); -@@ -353,22 +349,6 @@ const char * pychip_DeviceController_StatusReportToString(uint32_t profileId, ui - return nullptr; - } - --uint8_t pychip_DeviceController_GetLogFilter() --{ --#if _CHIP_USE_LOGGING -- return chip::Logging::GetLogFilter(); --#else -- return chip::Logging::kLogCategory_None; --#endif --} -- --void pychip_DeviceController_SetLogFilter(uint8_t category) --{ --#if _CHIP_USE_LOGGING -- chip::Logging::SetLogFilter(category); --#endif --} -- - PyChipError pychip_DeviceController_ConnectBLE(chip::Controller::DeviceCommissioner * devCtrl, uint16_t discriminator, - uint32_t setupPINCode, chip::NodeId nodeid) - { -diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py -index 2297dfff30..2400d543f6 100644 ---- a/src/controller/python/chip/ChipDeviceCtrl.py -+++ b/src/controller/python/chip/ChipDeviceCtrl.py -@@ -1480,23 +1480,6 @@ class ChipDeviceControllerBase(): - - return self._Cluster.ListClusterAttributes() - -- def SetLogFilter(self, category): -- self.CheckIsActive() -- -- if category < 0 or category > pow(2, 8): -- raise ValueError("category must be an unsigned 8-bit integer") -- -- self._ChipStack.Call( -- lambda: self._dmLib.pychip_DeviceController_SetLogFilter(category) -- ) -- -- def GetLogFilter(self): -- self.CheckIsActive() -- -- self._ChipStack.Call( -- lambda: self._dmLib.pychip_DeviceController_GetLogFilter() -- ) -- - def SetBlockingCB(self, blockingCB): - self.CheckIsActive() - -diff --git a/src/controller/python/chip/logging/LoggingFilter.cpp b/src/controller/python/chip/logging/LoggingFilter.cpp -new file mode 100644 -index 0000000000..52271dc3ae ---- /dev/null -+++ b/src/controller/python/chip/logging/LoggingFilter.cpp -@@ -0,0 +1,37 @@ -+/* -+ * -+ * Copyright (c) 2024 Project CHIP Authors -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#include -+ -+extern "C" { -+ -+uint8_t pychip_logging_GetLogFilter() -+{ -+#if _CHIP_USE_LOGGING -+ return chip::Logging::GetLogFilter(); -+#else -+ return chip::Logging::kLogCategory_None; -+#endif -+} -+ -+void pychip_logging_SetLogFilter(uint8_t category) -+{ -+#if _CHIP_USE_LOGGING -+ chip::Logging::SetLogFilter(category); -+#endif -+} -+} -diff --git a/src/controller/python/chip/logging/__init__.py b/src/controller/python/chip/logging/__init__.py -index 6916c8b272..047d3f4f8e 100644 ---- a/src/controller/python/chip/logging/__init__.py -+++ b/src/controller/python/chip/logging/__init__.py -@@ -51,3 +51,16 @@ def RedirectToPythonLogging(): - - handle = _GetLoggingLibraryHandle() - handle.pychip_logging_set_callback(_RedirectToPythonLogging) -+ -+ -+def SetLogFilter(category): -+ if category < 0 or category > pow(2, 8): -+ raise ValueError("category must be an unsigned 8-bit integer") -+ -+ handle = _GetLoggingLibraryHandle() -+ handle.pychip_logging_SetLogFilter(category) -+ -+ -+def GetLogFilter(): -+ handle = _GetLoggingLibraryHandle() -+ return handle.pychip_logging_GetLogFilter() -diff --git a/src/platform/Linux/CHIPPlatformConfig.h b/src/platform/Linux/CHIPPlatformConfig.h -index 788fe9b80c..9e2832307f 100644 ---- a/src/platform/Linux/CHIPPlatformConfig.h -+++ b/src/platform/Linux/CHIPPlatformConfig.h -@@ -57,7 +57,7 @@ using CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE = const char *; - #endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS - - #ifndef CHIP_LOG_FILTERING --#define CHIP_LOG_FILTERING 0 -+#define CHIP_LOG_FILTERING 1 - #endif // CHIP_LOG_FILTERING - - #ifndef CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS --- -2.43.0 - diff --git a/0008-MinMDNS-skip-interfaces-without-IPv4-addresses.patch b/0008-MinMDNS-skip-interfaces-without-IPv4-addresses.patch deleted file mode 100644 index 0e6a8b2..0000000 --- a/0008-MinMDNS-skip-interfaces-without-IPv4-addresses.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 72e9a1c20118b6c41c750a8bcaca578ff85488e2 Mon Sep 17 00:00:00 2001 -From: Stefan Agner -Date: Wed, 28 Feb 2024 10:38:37 +0100 -Subject: [PATCH] MinMDNS skip interfaces without IPv4 addresses - -IPv4 multicast require an IPv4 address to be present on a particular -interface. Skip interfaces without IPv4 addresses in the default -address policy. This avoids errors when trying to join the multicast -group later on: -MDNS failed to join multicast group on veth3cdf62f for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:777: Inet Error 0x00000110: Address not found ---- - .../minimal_mdns/AddressPolicy_LibNlImpl.cpp | 42 +++++++++++++++++-- - 1 file changed, 38 insertions(+), 4 deletions(-) - -diff --git a/src/lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.cpp b/src/lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.cpp -index e73627f423..b1802c8d25 100644 ---- a/src/lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.cpp -+++ b/src/lib/dnssd/minimal_mdns/AddressPolicy_LibNlImpl.cpp -@@ -48,6 +48,7 @@ private: - - nl_sock * mNlSocket = nullptr; - nl_cache * mNlCache = nullptr; -+ nl_cache * mNlAddrCache = nullptr; - nl_object * mCurrentLink = nullptr; - IPAddressType mCurrentLinkType = IPAddressType::kUnknown; - -@@ -94,6 +95,12 @@ AllListenIterator::~AllListenIterator() - mNlCache = nullptr; - } - -+ if (mNlAddrCache != nullptr) -+ { -+ nl_cache_free(mNlAddrCache); -+ mNlAddrCache = nullptr; -+ } -+ - if (mNlSocket != nullptr) - { - nl_socket_free(mNlSocket); -@@ -151,7 +158,6 @@ bool AllListenIterator::Next(InterfaceId * id, IPAddressType * type) - while (true) - { - #if INET_CONFIG_ENABLE_IPV4 -- // FOR IPv4, report all interfaces as 'try IPv4 here as well' - if (mCurrentLinkType == IPAddressType::kIPv6) - { - mCurrentLinkType = IPAddressType::kIPv4; -@@ -176,14 +182,42 @@ bool AllListenIterator::Next(InterfaceId * id, IPAddressType * type) - continue; - } - -- int idx = rtnl_link_get_ifindex(CurrentLink()); -- if (idx == 0) -+ int ifindex = rtnl_link_get_ifindex(CurrentLink()); -+ if (ifindex == 0) - { - // Invalid index, move to the next interface - continue; - } - -- *id = InterfaceId(idx); -+ // For IPv4, report only interfaces which have an IPv4 address -+ if (mCurrentLinkType == IPAddressType::kIPv4) -+ { -+ if (mNlAddrCache == nullptr) -+ { -+ int result = rtnl_addr_alloc_cache(mNlSocket, &mNlAddrCache); -+ if (result != 0) -+ { -+ ChipLogError(Inet, "Failed to cache addresses"); -+ return false; -+ } -+ } -+ -+ // Find IPv4 address for this interface -+ struct rtnl_addr * filter = rtnl_addr_alloc(); -+ rtnl_addr_set_family(filter, AF_INET); -+ rtnl_addr_set_ifindex(filter, ifindex); -+ -+ struct nl_object * addr = nl_cache_find(mNlAddrCache, OBJ_CAST(filter)); -+ nl_object_put(OBJ_CAST(filter)); -+ -+ // No IPv4 address, skip this interface for IPv4. -+ if (addr == nullptr) -+ continue; -+ -+ nl_object_put(addr); -+ } -+ -+ *id = InterfaceId(ifindex); - *type = mCurrentLinkType; // advancing should have set this - return true; - } --- -2.44.0 - diff --git a/connectedhomeip b/connectedhomeip index 181b0cb..3d47e35 160000 --- a/connectedhomeip +++ b/connectedhomeip @@ -1 +1 @@ -Subproject commit 181b0cb14ff007ec912f2ba6627e05dfb066c008 +Subproject commit 3d47e357d7626103c97d8a9abc3a64ea1f88276a From 3554056a4859ea182e348e40f77b18b4499e4316 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 5 Mar 2024 11:25:53 +0100 Subject: [PATCH 2/2] Adjust configuration for depandabot --- .github/dependabot.yml | 1 + .gitmodules | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9d26334..dcc2e6b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,6 +6,7 @@ updates: - dependency-name: "connectedhomeip" schedule: interval: "daily" + target-branch: main - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.gitmodules b/.gitmodules index 682e0dc..9edf119 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "connectedhomeip"] path = connectedhomeip url = https://github.com/project-chip/connectedhomeip.git + branch = master