Remove some dead Inet code (#10211)
#### Problem
`src/inet` has some unused code inherited from Weave, which complicates
maintenance. (Specifically, this is on the path to #7715 _Virtualize
System and Inet interfaces_.)
#### Change overview
- Remove some unused code from `Inet::EndPointBasis`
- Remove some unused `#include`s
- Remove unused `INET_CONFIG_WILL_OVERRIDE_PLATFORM_XTOR_FUNCS`
- Remove `src/inet/InetUtils.cpp`
- Remove `src/system/SystemLayerPrivate.h`
- Convert LwIPEndPointType to `enum class`
#### Testing
CI; no functional changes.
diff --git a/src/inet/EndPointBasis.h b/src/inet/EndPointBasis.h
index 31ed82c..f34db99 100644
--- a/src/inet/EndPointBasis.h
+++ b/src/inet/EndPointBasis.h
@@ -26,11 +26,8 @@
#include <inet/InetConfig.h>
-#include "inet/IANAConstants.h"
-#include "inet/InetLayerBasis.h"
-#include <inet/InetError.h>
-#include <inet/InetInterface.h>
-#include <inet/InetLayerEvents.h>
+#include <inet/IPAddress.h>
+#include <inet/InetLayerBasis.h>
#include <lib/support/DLLUtil.h>
@@ -42,58 +39,29 @@
#include <Network/Network.h>
#endif // CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-//--- Declaration of LWIP protocol control buffer structure names
#if CHIP_SYSTEM_CONFIG_USE_LWIP
-#if INET_CONFIG_ENABLE_UDP_ENDPOINT
struct udp_pcb;
-#endif // INET_CONFIG_ENABLE_UDP_ENDPOINT
-#if INET_CONFIG_ENABLE_TCP_ENDPOINT
struct tcp_pcb;
-#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
namespace chip {
namespace Inet {
/**
- * @class EndPointBasis
- *
- * @brief Basis of internet transport endpoint classes
+ * Basis of internet transport endpoint classes.
*/
class DLL_EXPORT EndPointBasis : public InetLayerBasis
{
-public:
- /** Common state codes */
- enum
- {
- kBasisState_Closed = 0 /**< Encapsulated descriptor is not valid. */
- };
-
-#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
- /** Test whether endpoint is a Network.framework endpoint */
- bool IsNetworkFrameworkEndPoint(void) const;
-#endif
-
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
- /** Test whether endpoint is a POSIX socket */
- bool IsSocketsEndPoint() const;
-#endif
-
-#if CHIP_SYSTEM_CONFIG_USE_LWIP
- /** Test whether endpoint is a LwIP protocol control buffer */
- bool IsLWIPEndPoint(void) const;
-#endif
-
- /** Test whether endpoint has a valid descriptor. */
- bool IsOpenEndPoint() const;
-
protected:
+ void InitEndPointBasis(InetLayer & aInetLayer, void * aAppState = nullptr);
+
#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
nw_parameters_t mParameters;
IPAddressType mAddrType; /**< Protocol family, i.e. IPv4 or IPv6. */
#endif
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
+ static constexpr int kInvalidSocketFd = -1;
int mSocket; /**< Encapsulated socket descriptor. */
IPAddressType mAddrType; /**< Protocol family, i.e. IPv4 or IPv6. */
System::SocketWatchToken mWatch; /**< Socket event watcher */
@@ -112,63 +80,18 @@
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
};
- enum
+ enum class LwIPEndPointType : uint8_t
{
- kLwIPEndPointType_Unknown = 0,
+ Unknown = 0,
+ Raw = 1,
+ UDP = 2,
+ UCP = 3,
+ TCP = 4
+ } mLwIPEndPointType;
- kLwIPEndPointType_Raw = 1,
- kLwIPEndPointType_UDP = 2,
- kLwIPEndPointType_UCP = 3,
- kLwIPEndPointType_TCP = 4
- };
-
- uint8_t mLwIPEndPointType;
-
- void DeferredFree(chip::System::Object::ReleaseDeferralErrorTactic aTactic);
+ void DeferredFree(System::Object::ReleaseDeferralErrorTactic aTactic);
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
-
- void InitEndPointBasis(InetLayer & aInetLayer, void * aAppState = nullptr);
};
-#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-inline bool EndPointBasis::IsNetworkFrameworkEndPoint(void) const
-{
- return mParameters != NULL;
-}
-#endif // CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
-inline bool EndPointBasis::IsSocketsEndPoint() const
-{
- return mSocket != INET_INVALID_SOCKET_FD;
-}
-#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
-
-#if CHIP_SYSTEM_CONFIG_USE_LWIP
-inline bool EndPointBasis::IsLWIPEndPoint(void) const
-{
- return mVoid != NULL;
-}
-#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
-
-inline bool EndPointBasis::IsOpenEndPoint() const
-{
- bool lResult = false;
-
-#if CHIP_SYSTEM_CONFIG_USE_LWIP
- lResult = (lResult || IsLWIPEndPoint());
-#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
-
-#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
- lResult = (lResult || IsSocketsEndPoint());
-#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
-
-#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
- lResult = (lResult || IsNetworkFrameworkEndPoint());
-#endif // CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-
- return lResult;
-}
-
} // namespace Inet
} // namespace chip