Skip to content

Commit

Permalink
Remove HostPortList associated with the Service Directory from WML ba…
Browse files Browse the repository at this point in the history
…seline. (#2289)
  • Loading branch information
yufengwangca authored Aug 22, 2020
1 parent 1cf3b1f commit ccf6f88
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 512 deletions.
2 changes: 0 additions & 2 deletions src/lib/message/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ static_library("message") {
"CHIPServerBase.cpp",
"CHIPServerBase.h",
"ExchangeContext.cpp",
"HostPortList.cpp",
"HostPortList.h",
]

public_deps = [
Expand Down
128 changes: 1 addition & 127 deletions src/lib/message/CHIPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,106 +424,6 @@ CHIP_ERROR ChipConnection::Connect(uint64_t peerNodeId, ChipAuthMode authMode, c
return err;
}

/**
* Connect to a CHIP node using a node identifier and/or a list of hostname and ports.
*
* @param[in] peerNodeId The node identifier of the peer.
*
* @param[in] authMode The authentication mode used for the connection.
*
* @param[in] hostPortList The list of hostnames and ports.
*
* @param[in] intf The optional interface to use to connect to the peer node,
* default to #INET_NULL_INTERFACEID.
*
* @retval #CHIP_NO_ERROR on successful initiation of the connection to the peer.
* @retval #CHIP_ERROR_INCORRECT_STATE if the ChipConnection state is incorrect.
*
* @retval #CHIP_ERROR_UNSUPPORTED_AUTH_MODE if the requested authentication mode is not supported.
*
* @retval #CHIP_ERROR_INVALID_ADDRESS if the destination address cannot be deduced from the node id.
*
* @retval other Inet layer errors generated by the TCPEndPoint connect operations.
*
*/
CHIP_ERROR ChipConnection::Connect(uint64_t peerNodeId, ChipAuthMode authMode, HostPortList hostPortList, InterfaceId intf)
{
#if CHIP_CONFIG_ENABLE_DNS_RESOLVER
const uint8_t dnsOptions = ::chip::Inet::kDNSOption_Default;
#else
const uint8_t dnsOptions = 0;
#endif
return Connect(peerNodeId, authMode, hostPortList, dnsOptions, intf);
}

/**
* Connect to a CHIP node using a node identifier and/or a list of hostname and ports.
*
* @param[in] peerNodeId The node identifier of the peer.
*
* @param[in] authMode The authentication mode used for the connection.
*
* @param[in] hostPortList The list of hostnames and ports.
*
* @param[in] dnsOptions An integer value controlling how host name resolution is performed.
* Value should be the OR of one or more values from from the
* #::chip::Inet::DNSOptions enumeration.
*
* @param[in] intf The optional interface to use to connect to the peer node,
* default to #INET_NULL_INTERFACEID.
*
* @retval #CHIP_NO_ERROR on successful initiation of the connection to the peer.
* @retval #CHIP_ERROR_INCORRECT_STATE if the ChipConnection state is incorrect.
*
* @retval #CHIP_ERROR_UNSUPPORTED_AUTH_MODE if the requested authentication mode is not supported.
*
* @retval #CHIP_ERROR_INVALID_ADDRESS if the destination address cannot be deduced from the node id.
*
* @retval other Inet layer errors generated by the TCPEndPoint connect operations.
*
*/
CHIP_ERROR ChipConnection::Connect(uint64_t peerNodeId, ChipAuthMode authMode, HostPortList hostPortList, uint8_t dnsOptions,
InterfaceId intf)
{
CHIP_ERROR err = CHIP_NO_ERROR;

VerifyOrExit(State == kState_ReadyToConnect, err = CHIP_ERROR_INCORRECT_STATE);

VerifyOrExit(authMode == kChipAuthMode_Unauthenticated || IsCASEAuthMode(authMode) || IsPASEAuthMode(authMode),
err = CHIP_ERROR_INVALID_ARGUMENT);

// Can't request authentication if the security manager is not initialized.
VerifyOrExit(authMode == kChipAuthMode_Unauthenticated || MessageLayer->SecurityMgr != NULL,
err = CHIP_ERROR_UNSUPPORTED_AUTH_MODE);

// Application has made this an IP-based ChipConnection.
NetworkType = kNetworkType_IP;

// Clear the list of resolved peer addresses in preparation for resolving the first host name.
memset(mPeerAddrs, 0, sizeof(mPeerAddrs));

PeerNodeId = peerNodeId;
AuthMode = authMode;
mPeerHostPortList = hostPortList;
mTargetInterface = intf;
#if CHIP_CONFIG_ENABLE_DNS_RESOLVER
mDNSOptions = dnsOptions;
#endif

// Bump the reference count when we start the connection process. The corresponding decrement happens when the
// DoClose() method is called. This ensures the object stays live while there's the possibility of a callback
// happening from an underlying layer (e.g. TCPEndPoint or DNS resolution).
mRefCount++;

ChipLogProgress(MessageLayer, "Con start %04X %016llX %04X", LogId(), peerNodeId, authMode);

err = TryNextPeerAddress(CHIP_ERROR_HOST_PORT_LIST_EMPTY);
SuccessOrExit(err);

exit:
return err;
}

/**
* @brief Set timeout for Connect to succeed or return an error.
*
Expand Down Expand Up @@ -1133,6 +1033,7 @@ CHIP_ERROR ChipConnection::TryNextPeerAddress(CHIP_ERROR lastErr)

// Search the list of peer addresses for one we haven't tried yet...
for (int i = 0; i < CHIP_CONFIG_CONNECT_IP_ADDRS; i++)
{
if (mPeerAddrs[i] != IPAddress::Any)
{
// Select the next address, removing it from the list so it won't get tried again.
Expand All @@ -1143,32 +1044,6 @@ CHIP_ERROR ChipConnection::TryNextPeerAddress(CHIP_ERROR lastErr)
err = StartConnect();
ExitNow();
}

// If Connect() was called with a host/port list and there are additional entries in the list, then...
if (!mPeerHostPortList.IsEmpty())
{
char hostName[256]; // Per spec, max DNS name length is 253.

// Pop the next host/port pair from the list.
err = mPeerHostPortList.Pop(hostName, sizeof(hostName), PeerPort);
SuccessOrExit(err);

#if CHIP_CONFIG_ENABLE_DNS_RESOLVER
// Initiate name resolution for the new host name.
//
// NOTE: there was a moment, maybe it's passed now, when the
// log statement below was very useful since in showed exactly
// which host we thought we were getting a particular service
// from. for now i'm leaving it in place, protected by an
// ifdef 0 at the top of the file.
//
ChipLogProgress(MessageLayer, "Con DNS start %04" PRIX16 " %s %02" PRIX8, LogId(), hostName, mDNSOptions);
State = kState_Resolving;
err = MessageLayer->Inet->ResolveHostAddress(hostName, strlen(hostName), mDNSOptions, CHIP_CONFIG_CONNECT_IP_ADDRS,
mPeerAddrs, HandleResolveComplete, this);
#else // !CHIP_CONFIG_ENABLE_DNS_RESOLVER
err = StartConnectToAddressLiteral(hostName, strlen(hostName));
#endif // !CHIP_CONFIG_ENABLE_DNS_RESOLVER
}

exit:
Expand Down Expand Up @@ -1579,7 +1454,6 @@ void ChipConnection::Init(ChipMessageLayer * msgLayer)
#if CONFIG_NETWORK_LAYER_BLE
mBleEndPoint = NULL;
#endif
mPeerHostPortList.Clear();
mTargetInterface = INET_NULL_INTERFACEID;
mRefCount = 1;
SendSourceNodeId = false;
Expand Down
6 changes: 0 additions & 6 deletions src/lib/message/CHIPMessageLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <string.h>

#include <message/CHIPFabricState.h>
#include <message/HostPortList.h>
#include <support/DLLUtil.h>
#include <system/SystemStats.h>

Expand Down Expand Up @@ -254,10 +253,6 @@ class ChipConnection
uint16_t defaultPort = 0);
CHIP_ERROR Connect(uint64_t peerNodeId, ChipAuthMode authMode, const char * peerAddr, uint16_t peerAddrLen, uint8_t dnsOptions,
uint16_t defaultPort);
CHIP_ERROR Connect(uint64_t peerNodeId, ChipAuthMode authMode, HostPortList hostPortList,
InterfaceId intf = INET_NULL_INTERFACEID);
CHIP_ERROR Connect(uint64_t peerNodeId, ChipAuthMode authMode, HostPortList hostPortList, uint8_t dnsOptions, InterfaceId intf);

CHIP_ERROR GetPeerAddressInfo(IPPacketInfo & addrInfo);

enum
Expand Down Expand Up @@ -355,7 +350,6 @@ class ChipConnection

IPAddress mPeerAddrs[CHIP_CONFIG_CONNECT_IP_ADDRS];
TCPEndPoint * mTcpEndPoint;
HostPortList mPeerHostPortList;
InterfaceId mTargetInterface;
uint32_t mConnectTimeout;
uint8_t mRefCount;
Expand Down
Loading

0 comments on commit ccf6f88

Please sign in to comment.