-
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.
Inet: Split InetLayer class (#12291)
#### Problem This is a step toward #7715 _Virtualize System and Inet interfaces_ for mockability, building on recent virtualization of Inet endpoints and changes to object allocation pools. The `InetLayer` class acts as a factory for `UDPEndPoint` and `TCPEndPoint`. Merely making its methods virtual would result in an unacceptable code size increase for applications that do not use TCP on platforms that offer it, since the vtable would introduce a dependency that normal linking doesn't remove. #### Change overview - Split the `EndPoint` factory/iteration code into its own class, `EndPointManager`. `InetLayer` remains as a stub wrapper for the pair of Managers. - Move the code for TCP idle timeout from `InetLayer` to `TCPEndPoint`. - Move `IPPacketInfo` from `InetLayer.h` to its own files. **NOTE** that applications that use CHIP TCP must now explicitly initialize it via `InetLayer::InitTCP()`. #### Testing CI; no changes to external functionality. Tests revised where necessary to initialize TCP.
- Loading branch information
1 parent
e68f644
commit 1053736
Showing
38 changed files
with
486 additions
and
631 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 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
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
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
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,34 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2013-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. | ||
*/ | ||
|
||
#include "IPPacketInfo.h" | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
void IPPacketInfo::Clear() | ||
{ | ||
SrcAddress = IPAddress::Any; | ||
DestAddress = IPAddress::Any; | ||
Interface = InterfaceId::Null(); | ||
SrcPort = 0; | ||
DestPort = 0; | ||
} | ||
|
||
} // 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,50 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2021 Project CHIP Authors | ||
* Copyright (c) 2013-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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <inet/IPAddress.h> | ||
#include <inet/InetInterface.h> | ||
|
||
namespace chip { | ||
namespace Inet { | ||
|
||
/** | ||
* Information about an incoming/outgoing message/connection. | ||
* | ||
* @warning | ||
* Do not alter the contents of this class without first reading and understanding | ||
* the code/comments in UDPEndPoint::GetPacketInfo(). | ||
*/ | ||
class IPPacketInfo | ||
{ | ||
public: | ||
IPAddress SrcAddress; /**< The source IPAddress in the packet. */ | ||
IPAddress DestAddress; /**< The destination IPAddress in the packet. */ | ||
InterfaceId Interface; /**< The interface identifier for the connection. */ | ||
uint16_t SrcPort; /**< The source port in the packet. */ | ||
uint16_t DestPort; /**< The destination port in the packet. */ | ||
|
||
/** | ||
* Reset the members of the IPPacketInfo object. | ||
*/ | ||
void Clear(); | ||
}; | ||
|
||
} // 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
Oops, something went wrong.