Skip to content

Commit

Permalink
Revert "Add multi-address support for PeerAddress" (#15082)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andy31415 authored and pull[bot] committed Jul 19, 2023
1 parent 9ed26e0 commit 4628817
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 315 deletions.
32 changes: 10 additions & 22 deletions src/app/OperationalDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,31 +178,19 @@ class DLL_EXPORT OperationalDeviceProxy : public DeviceProxy, SessionReleaseDele

static Transport::PeerAddress ToPeerAddress(const Dnssd::ResolvedNodeData & nodeData)
{
Transport::PeerAddress address = Transport::PeerAddress(Transport::Type::kUdp);
address.SetPort(nodeData.mPort);

for (unsigned i = 0; i < nodeData.mNumIPs; i++)
Inet::InterfaceId interfaceId = Inet::InterfaceId::Null();

// TODO - Revisit usage of InterfaceID only for addresses that are IPv6 LLA
// Only use the DNS-SD resolution's InterfaceID for addresses that are IPv6 LLA.
// For all other addresses, we should rely on the device's routing table to route messages sent.
// Forcing messages down an InterfaceId might fail. For example, in bridged networks like Thread,
// mDNS advertisements are not usually received on the same interface the peer is reachable on.
if (nodeData.mAddress[0].IsIPv6LinkLocal())
{
const auto addr = nodeData.mAddress[i];
// Only use the mDNS resolution's InterfaceID for addresses that are IPv6 LLA.
// For all other addresses, we should rely on the device's routing table to route messages sent.
// Forcing messages down an InterfaceId might fail. For example, in bridged networks like Thread,
// mDNS advertisements are not usually received on the same interface the peer is reachable on.
// TODO: Right now, just use addr0, but we should really push all the addresses and interfaces to
// the device and allow it to make a proper decision about which addresses are preferred and reachable.
CHIP_ERROR err = address.AppendDestination(nodeData.mAddress[i],
addr.IsIPv6LinkLocal() ? nodeData.mInterfaceId : Inet::InterfaceId::Null());

if (err != CHIP_NO_ERROR)
{
char addr_str[Inet::IPAddress::kMaxStringLength];
addr.ToString(addr_str);

ChipLogError(Controller, "Could not append IP address %s: %s", addr_str, err.AsString());
}
interfaceId = nodeData.mInterfaceId;
}

return address;
return Transport::PeerAddress::UDP(nodeData.mAddress[0], nodeData.mPort, interfaceId);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CommissioneeDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat

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

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

PASESession & GetPairing() { return mPairing; }

Expand Down
4 changes: 2 additions & 2 deletions src/controller/python/ChipDeviceController-ScriptBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ ChipError::StorageType pychip_DeviceController_ConnectIP(chip::Controller::Devic
VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), CHIP_ERROR_INVALID_ARGUMENT.AsInteger());

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

devCtrl->ReleaseOperationalDevice(nodeid);
Expand Down Expand Up @@ -380,7 +380,7 @@ ChipError::StorageType pychip_DeviceController_EstablishPASESessionIP(chip::Cont
chip::Transport::PeerAddress addr;
RendezvousParameters params = chip::RendezvousParameters().SetSetupPINCode(setupPINCode);
VerifyOrReturnError(chip::Inet::IPAddress::FromString(peerAddrStr, peerAddr), CHIP_ERROR_INVALID_ARGUMENT.AsInteger());
addr.SetTransportType(chip::Transport::Type::kUdp).SetSingleIPAddress(peerAddr);
addr.SetTransportType(chip::Transport::Type::kUdp).SetIPAddress(peerAddr);
params.SetPeerAddress(addr).SetDiscriminator(0);
return devCtrl->EstablishPASEConnection(nodeid, params).AsInteger();
}
Expand Down
1 change: 0 additions & 1 deletion src/transport/raw/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static_library("raw") {
"Base.h",
"MessageHeader.cpp",
"MessageHeader.h",
"PeerAddress.cpp",
"PeerAddress.h",
"TCP.cpp",
"TCP.h",
Expand Down
124 changes: 0 additions & 124 deletions src/transport/raw/PeerAddress.cpp

This file was deleted.

Loading

0 comments on commit 4628817

Please sign in to comment.