-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Inet::EndPoint into per-implemention files (#11539)
#### Problem This is a step toward #7715 _Virtualize System and Inet interfaces_. #### Change overview Move each `Inet::EndPointBasis` implementation into its own file. Each inherits from `Inet::EndPointBase`, but transitionally each implementation is statically named `EndPointBasis`, and initialization continues to be done in `InitEndPointBasis()` rather than a constructor. #### Testing CI; no changes to functionality.
- Loading branch information
1 parent
9855f3b
commit a6a5d2a
Showing
7 changed files
with
182 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2015-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. | ||
*/ | ||
|
||
/** | ||
* LwIP implementation of EndPointBase. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inet/EndPointBasis.h> | ||
|
||
#include <inet/IPAddress.h> | ||
|
||
struct udp_pcb; | ||
struct tcp_pcb; | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
class DLL_EXPORT EndPointImplLwIP : public EndPointBase | ||
{ | ||
protected: | ||
// EndPointBase overrides | ||
void InitEndPointBasisImpl() override { mLwIPEndPointType = LwIPEndPointType::Unknown; } | ||
|
||
/** Encapsulated LwIP protocol control block */ | ||
union | ||
{ | ||
const void * mVoid; /**< An untyped protocol control buffer reference */ | ||
#if INET_CONFIG_ENABLE_UDP_ENDPOINT | ||
udp_pcb * mUDP; /**< User datagram protocol (UDP) control */ | ||
#endif // INET_CONFIG_ENABLE_UDP_ENDPOINT | ||
#if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
tcp_pcb * mTCP; /**< Transmission control protocol (TCP) control */ | ||
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
}; | ||
|
||
enum class LwIPEndPointType : uint8_t | ||
{ | ||
Unknown = 0, | ||
UDP = 1, | ||
TCP = 2 | ||
} mLwIPEndPointType; | ||
}; | ||
|
||
using EndPointBasis = EndPointImplLwIP; | ||
|
||
} // namespace Inet | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2015-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. | ||
*/ | ||
|
||
/** | ||
* Network Framework implementation of EndPointBase. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inet/EndPointBasis.h> | ||
|
||
#include <inet/IPAddress.h> | ||
|
||
#include <Network/Network.h> | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
class DLL_EXPORT EndPointImplNetworkFramework : public EndPointBase | ||
{ | ||
protected: | ||
void InitEndPointBasisImpl() override {} | ||
|
||
nw_parameters_t mParameters; | ||
IPAddressType mAddrType; /**< Protocol family, i.e. IPv4 or IPv6. */ | ||
}; | ||
|
||
using EndPointBasis = EndPointImplNetworkFramework; | ||
|
||
} // namespace Inet | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2015-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. | ||
*/ | ||
|
||
/** | ||
* Sockets implementation of EndPointBase. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inet/EndPointBasis.h> | ||
|
||
#include <inet/IPAddress.h> | ||
#include <system/SocketEvents.h> | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
class DLL_EXPORT EndPointImplSockets : public EndPointBase | ||
{ | ||
protected: | ||
void InitEndPointBasisImpl() override { mSocket = kInvalidSocketFd; } | ||
|
||
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 */ | ||
}; | ||
|
||
using EndPointBasis = EndPointImplSockets; | ||
|
||
} // namespace Inet | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters