|
| 1 | +From 5b5e383674e78115107c7a95eb563902cd6b6014 Mon Sep 17 00:00:00 2001 |
| 2 | +Message-ID: <5b5e383674e78115107c7a95eb563902cd6b6014.1704821887.git.stefan@agner.ch> |
| 3 | +From: Stefan Agner <stefan@agner.ch> |
| 4 | +Date: Tue, 9 Jan 2024 18:35:50 +0100 |
| 5 | +Subject: [PATCH] [Python] Parse Interface ID from IP address string as well |
| 6 | + |
| 7 | +Currently, when passing a link-local address with an interface specified |
| 8 | +using the %<interface> notation leads to "CHIP Error 0x0000002F: Invalid |
| 9 | +argument". |
| 10 | + |
| 11 | +Correctly parse the interface ID as well and pass it to the PeerAddress |
| 12 | +object. |
| 13 | +--- |
| 14 | + .../python/ChipDeviceController-ScriptBinding.cpp | 10 ++++++---- |
| 15 | + 1 file changed, 6 insertions(+), 4 deletions(-) |
| 16 | + |
| 17 | +diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp |
| 18 | +index a7732a4836..e3e4de8d88 100644 |
| 19 | +--- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp |
| 20 | ++++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp |
| 21 | +@@ -383,13 +383,14 @@ PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommission |
| 22 | + uint32_t setupPINCode, chip::NodeId nodeid) |
| 23 | + { |
| 24 | + chip::Inet::IPAddress peerAddr; |
| 25 | ++ chip::Inet::InterfaceId ifaceOutput; |
| 26 | + chip::Transport::PeerAddress addr; |
| 27 | + chip::RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode); |
| 28 | + |
| 29 | +- VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); |
| 30 | ++ VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr, ifaceOutput), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); |
| 31 | + |
| 32 | + // TODO: IP rendezvous should use TCP connection. |
| 33 | +- addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr); |
| 34 | ++ addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr).SetInterface(ifaceOutput); |
| 35 | + params.SetPeerAddress(addr).SetDiscriminator(0); |
| 36 | + |
| 37 | + sPairingDelegate.SetExpectingPairingComplete(true); |
| 38 | +@@ -577,10 +578,11 @@ PyChipError pychip_DeviceController_EstablishPASESessionIP(chip::Controller::Dev |
| 39 | + uint32_t setupPINCode, chip::NodeId nodeid, uint16_t port) |
| 40 | + { |
| 41 | + chip::Inet::IPAddress peerAddr; |
| 42 | ++ chip::Inet::InterfaceId ifaceOutput; |
| 43 | + chip::Transport::PeerAddress addr; |
| 44 | + RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode); |
| 45 | +- VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); |
| 46 | +- addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr); |
| 47 | ++ VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr, ifaceOutput), ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); |
| 48 | ++ addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr).SetInterface(ifaceOutput); |
| 49 | + if (port != 0) |
| 50 | + { |
| 51 | + addr.SetPort(port); |
| 52 | +-- |
| 53 | +2.43.0 |
| 54 | + |
0 commit comments