diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 8bbbea0d69526a..77eb03ad819fe2 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -84,7 +84,6 @@ static_library("inet") { "InetInterface.h", "InetLayer.cpp", "InetLayer.h", - "InetLayerBasis.h", "InetLayerEvents.h", "arpa-inet-compatibility.h", ] diff --git a/src/inet/EndPointBasis.cpp b/src/inet/EndPointBasis.cpp index a3e5d54486bc7f..0dc43cf79e5ff2 100644 --- a/src/inet/EndPointBasis.cpp +++ b/src/inet/EndPointBasis.cpp @@ -34,7 +34,8 @@ namespace Inet { void EndPointBasis::InitEndPointBasis(InetLayer & aInetLayer, void * aAppState) { - InitInetLayerBasis(aInetLayer, aAppState); + AppState = aAppState; + mInetLayer = &aInetLayer; mLwIPEndPointType = LwIPEndPointType::Unknown; } @@ -56,8 +57,9 @@ void EndPointBasis::DeferredFree(System::Object::ReleaseDeferralErrorTactic aTac void EndPointBasis::InitEndPointBasis(InetLayer & aInetLayer, void * aAppState) { - InitInetLayerBasis(aInetLayer, aAppState); - mSocket = kInvalidSocketFd; + AppState = aAppState; + mInetLayer = &aInetLayer; + mSocket = kInvalidSocketFd; } void EndPointBasis::DeferredFree(System::Object::ReleaseDeferralErrorTactic aTactic) @@ -71,7 +73,8 @@ void EndPointBasis::DeferredFree(System::Object::ReleaseDeferralErrorTactic aTac void EndPointBasis::InitEndPointBasis(InetLayer & aInetLayer, void * aAppState) { - InitInetLayerBasis(aInetLayer, aAppState); + AppState = aAppState; + mInetLayer = &aInetLayer; } void EndPointBasis::DeferredFree(System::Object::ReleaseDeferralErrorTactic aTactic) diff --git a/src/inet/EndPointBasis.h b/src/inet/EndPointBasis.h index 154d32aa132447..a03fd4c377b4bf 100644 --- a/src/inet/EndPointBasis.h +++ b/src/inet/EndPointBasis.h @@ -27,9 +27,8 @@ #include #include -#include - #include +#include #if CHIP_SYSTEM_CONFIG_USE_SOCKETS #include @@ -47,11 +46,28 @@ struct tcp_pcb; namespace chip { namespace Inet { +class InetLayer; + /** * Basis of internet transport endpoint classes. */ -class DLL_EXPORT EndPointBasis : public InetLayerBasis +class DLL_EXPORT EndPointBasis : public System::Object { +public: + /** + * Returns a reference to the Inet layer object that owns this basis object. + */ + InetLayer & Layer() const { return *mInetLayer; } + + /** + * Returns \c true if the basis object was obtained by the specified Inet layer instance. + * + * @note + * Does not check whether the object is actually obtained by the system layer instance associated with the Inet layer + * instance. It merely tests whether \c aInetLayer is the Inet layer instance that was provided to \c InitInetLayerBasis. + */ + bool IsCreatedByInetLayer(const InetLayer & aInetLayer) const { return mInetLayer == &aInetLayer; } + protected: void InitEndPointBasis(InetLayer & aInetLayer, void * aAppState = nullptr); void DeferredFree(System::Object::ReleaseDeferralErrorTactic aTactic); @@ -90,6 +106,9 @@ class DLL_EXPORT EndPointBasis : public InetLayerBasis TCP = 4 } mLwIPEndPointType; #endif // CHIP_SYSTEM_CONFIG_USE_LWIP + +private: + InetLayer * mInetLayer; /**< Pointer to the InetLayer object that owns this object. */ }; } // namespace Inet diff --git a/src/inet/InetLayer.cpp b/src/inet/InetLayer.cpp index 9cb196b9123668..18bf4329b1692f 100644 --- a/src/inet/InetLayer.cpp +++ b/src/inet/InetLayer.cpp @@ -656,7 +656,7 @@ CHIP_ERROR InetLayer::HandleInetLayerEvent(chip::System::Object & aTarget, chip: // If the event was droppable, record the fact that it has been dequeued. if (IsDroppableEvent(aEventType)) { - InetLayerBasis & lBasis = static_cast(aTarget); + EndPointBasis & lBasis = static_cast(aTarget); InetLayer & lInetLayer = lBasis.Layer(); lInetLayer.DroppableEventDequeued(); diff --git a/src/inet/InetLayer.h b/src/inet/InetLayer.h index d87917bd9efa0a..e30a3233183c22 100644 --- a/src/inet/InetLayer.h +++ b/src/inet/InetLayer.h @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #if INET_CONFIG_ENABLE_TCP_ENDPOINT diff --git a/src/inet/InetLayerBasis.h b/src/inet/InetLayerBasis.h deleted file mode 100644 index 4645a8a118e67a..00000000000000 --- a/src/inet/InetLayerBasis.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * Copyright (c) 2014-2017 Nest Labs, Inc. - * - * 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. - */ - -/** - * This file contains the basis class for reference counting objects by the Inet layer. - */ - -#pragma once - -#include - -namespace chip { -namespace Inet { - -class InetLayer; - -/** - * This is the basis class of reference-counted objects managed by an InetLayer object. - */ -class InetLayerBasis : public chip::System::Object -{ -public: - /** - * Returns a reference to the Inet layer object that owns this basis object. - */ - InetLayer & Layer() const { return *mInetLayer; } - - /** - * Returns \c true if the basis object was obtained by the specified Inet layer instance. - * - * @note - * Does not check whether the object is actually obtained by the system layer instance associated with the Inet layer - * instance. It merely tests whether \c aInetLayer is the Inet layer instance that was provided to \c InitInetLayerBasis. - */ - bool IsCreatedByInetLayer(const InetLayer & aInetLayer) const { return mInetLayer == &aInetLayer; } - -protected: - void InitInetLayerBasis(InetLayer & aInetLayer, void * aAppState = nullptr) - { - AppState = aAppState; - mInetLayer = &aInetLayer; - } - -private: - InetLayer * mInetLayer; /**< Pointer to the InetLayer object that owns this object. */ -}; - -} // namespace Inet -} // namespace chip diff --git a/src/inet/UDPEndPoint.h b/src/inet/UDPEndPoint.h index 50057ad93e6f4a..eadb2d935e3858 100644 --- a/src/inet/UDPEndPoint.h +++ b/src/inet/UDPEndPoint.h @@ -242,7 +242,7 @@ class DLL_EXPORT UDPEndPoint : public EndPointBasis /** * Close the endpoint and recycle its memory. * - * Invokes the \c Close method, then invokes the InetLayerBasis::Release method to return the object to its + * Invokes the \c Close method, then invokes the EndPointBasis::Release method to return the object to its * memory pool. * * On LwIP systems, this method must not be called with the LwIP stack lock already acquired.