Skip to content

Commit 1670252

Browse files
andy31415pull[bot]
authored andcommitted
Revert "Add multi-address support for PeerAddress" (#15082)
* Revert "Add ability to keep several IP addresses per PeerAddress (#14968)" This reverts commit 14eb3f5. * Add back unit tests for peer address to string formatting. More tests are good * Maintain the cleanup of ToPeerAddress from the previous patch - that was good * Restyle
1 parent 4883d37 commit 1670252

File tree

7 files changed

+88
-315
lines changed

7 files changed

+88
-315
lines changed

src/app/OperationalDeviceProxy.h

+10-22
Original file line numberDiff line numberDiff line change
@@ -178,31 +178,19 @@ class DLL_EXPORT OperationalDeviceProxy : public DeviceProxy, SessionReleaseDele
178178

179179
static Transport::PeerAddress ToPeerAddress(const Dnssd::ResolvedNodeData & nodeData)
180180
{
181-
Transport::PeerAddress address = Transport::PeerAddress(Transport::Type::kUdp);
182-
address.SetPort(nodeData.mPort);
183-
184-
for (unsigned i = 0; i < nodeData.mNumIPs; i++)
181+
Inet::InterfaceId interfaceId = Inet::InterfaceId::Null();
182+
183+
// TODO - Revisit usage of InterfaceID only for addresses that are IPv6 LLA
184+
// Only use the DNS-SD resolution's InterfaceID for addresses that are IPv6 LLA.
185+
// For all other addresses, we should rely on the device's routing table to route messages sent.
186+
// Forcing messages down an InterfaceId might fail. For example, in bridged networks like Thread,
187+
// mDNS advertisements are not usually received on the same interface the peer is reachable on.
188+
if (nodeData.mAddress[0].IsIPv6LinkLocal())
185189
{
186-
const auto addr = nodeData.mAddress[i];
187-
// Only use the mDNS resolution's InterfaceID for addresses that are IPv6 LLA.
188-
// For all other addresses, we should rely on the device's routing table to route messages sent.
189-
// Forcing messages down an InterfaceId might fail. For example, in bridged networks like Thread,
190-
// mDNS advertisements are not usually received on the same interface the peer is reachable on.
191-
// TODO: Right now, just use addr0, but we should really push all the addresses and interfaces to
192-
// the device and allow it to make a proper decision about which addresses are preferred and reachable.
193-
CHIP_ERROR err = address.AppendDestination(nodeData.mAddress[i],
194-
addr.IsIPv6LinkLocal() ? nodeData.mInterfaceId : Inet::InterfaceId::Null());
195-
196-
if (err != CHIP_NO_ERROR)
197-
{
198-
char addr_str[Inet::IPAddress::kMaxStringLength];
199-
addr.ToString(addr_str);
200-
201-
ChipLogError(Controller, "Could not append IP address %s: %s", addr_str, err.AsString());
202-
}
190+
interfaceId = nodeData.mInterfaceId;
203191
}
204192

205-
return address;
193+
return Transport::PeerAddress::UDP(nodeData.mAddress[0], nodeData.mPort, interfaceId);
206194
}
207195

208196
private:

src/controller/CommissioneeDeviceProxy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat
214214

215215
Messaging::ExchangeManager * GetExchangeManager() const override { return mExchangeMgr; }
216216

217-
void SetAddress(const Inet::IPAddress & deviceAddr) { mDeviceAddress.SetSingleIPAddress(deviceAddr); }
217+
void SetAddress(const Inet::IPAddress & deviceAddr) { mDeviceAddress.SetIPAddress(deviceAddr); }
218218

219219
PASESession & GetPairing() { return mPairing; }
220220

src/controller/python/ChipDeviceController-ScriptBinding.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ChipError::StorageType pychip_DeviceController_ConnectIP(chip::Controller::Devic
324324
VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), CHIP_ERROR_INVALID_ARGUMENT.AsInteger());
325325

326326
// TODO: IP rendezvous should use TCP connection.
327-
addr.SetTransportType(chip::Transport::Type::kUdp).SetSingleIPAddress(peerAddr);
327+
addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr);
328328
params.SetPeerAddress(addr).SetDiscriminator(0);
329329

330330
devCtrl->ReleaseOperationalDevice(nodeid);
@@ -380,7 +380,7 @@ ChipError::StorageType pychip_DeviceController_EstablishPASESessionIP(chip::Cont
380380
chip::Transport::PeerAddress addr;
381381
RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode);
382382
VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), CHIP_ERROR_INVALID_ARGUMENT.AsInteger());
383-
addr.SetTransportType(chip::Transport::Type::kUdp).SetSingleIPAddress(peerAddr);
383+
addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr);
384384
params.SetPeerAddress(addr).SetDiscriminator(0);
385385
return devCtrl->EstablishPASEConnection(nodeid, params).AsInteger();
386386
}

src/transport/raw/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ static_library("raw") {
2222
"Base.h",
2323
"MessageHeader.cpp",
2424
"MessageHeader.h",
25-
"PeerAddress.cpp",
2625
"PeerAddress.h",
2726
"TCP.cpp",
2827
"TCP.h",

src/transport/raw/PeerAddress.cpp

-124
This file was deleted.

0 commit comments

Comments
 (0)