Rename EndpointConfig into EmulatedEndpointConfig

Also fix minor issues in this class.

Bug: webrtc:10138
Change-Id: Icb3ec7f6296c34da260e701ec51d7b87ce62a4d7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127281
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27073}
This commit is contained in:
Artem Titov 2019-03-12 13:37:28 +01:00 committed by Commit Bot
parent 30e60d6fd9
commit a268b69037
5 changed files with 34 additions and 30 deletions

View File

@ -81,9 +81,9 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
EmulatedNetworkNode* bob_node = network_emulation_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
EmulatedEndpoint* alice_endpoint =
network_emulation_manager.CreateEndpoint(EndpointConfig());
network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig());
EmulatedEndpoint* bob_endpoint =
network_emulation_manager.CreateEndpoint(EndpointConfig());
network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig());
network_emulation_manager.CreateRoute(alice_endpoint, {alice_node},
bob_endpoint);
network_emulation_manager.CreateRoute(bob_endpoint, {bob_node},

View File

@ -29,12 +29,16 @@ constexpr uint32_t kMaxIPv4Address = 0xC0A8FFFF;
} // namespace
EndpointConfig::EndpointConfig() = default;
EndpointConfig::~EndpointConfig() = default;
EndpointConfig::EndpointConfig(EndpointConfig&) = default;
EndpointConfig& EndpointConfig::operator=(EndpointConfig&) = default;
EndpointConfig::EndpointConfig(EndpointConfig&&) = default;
EndpointConfig& EndpointConfig::operator=(EndpointConfig&&) = default;
EmulatedEndpointConfig::EmulatedEndpointConfig() = default;
EmulatedEndpointConfig::~EmulatedEndpointConfig() = default;
EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&) =
default;
EmulatedEndpointConfig& EmulatedEndpointConfig::operator=(
EmulatedEndpointConfig&) = default;
EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&&) =
default;
EmulatedEndpointConfig& EmulatedEndpointConfig::operator=(
EmulatedEndpointConfig&&) = default;
NetworkEmulationManager::NetworkEmulationManager()
: clock_(Clock::GetRealTimeClock()),
@ -68,15 +72,15 @@ EmulatedNetworkNode* NetworkEmulationManager::CreateEmulatedNode(
}
EmulatedEndpoint* NetworkEmulationManager::CreateEndpoint(
EndpointConfig config) {
EmulatedEndpointConfig config) {
absl::optional<rtc::IPAddress> ip = config.ip;
if (!ip) {
switch (config.generated_ip_family) {
case EndpointConfig::IpAddressFamily::kIpv4:
case EmulatedEndpointConfig::IpAddressFamily::kIpv4:
ip = GetNextIPv4Address();
RTC_CHECK(ip) << "All auto generated IPv4 addresses exhausted";
break;
case EndpointConfig::IpAddressFamily::kIpv6:
case EmulatedEndpointConfig::IpAddressFamily::kIpv6:
ip = GetNextIPv4Address();
RTC_CHECK(ip) << "All auto generated IPv6 addresses exhausted";
ip = ip->AsIPv6Address();
@ -128,7 +132,7 @@ void NetworkEmulationManager::ClearRoute(
TrafficRoute* NetworkEmulationManager::CreateTrafficRoute(
std::vector<EmulatedNetworkNode*> via_nodes) {
RTC_CHECK(!via_nodes.empty());
EmulatedEndpoint* endpoint = CreateEndpoint(EndpointConfig());
EmulatedEndpoint* endpoint = CreateEndpoint(EmulatedEndpointConfig());
// Setup a route via specified nodes.
EmulatedNetworkNode* cur_node = via_nodes[0];

View File

@ -31,18 +31,18 @@
namespace webrtc {
namespace test {
struct EndpointConfig {
enum IpAddressFamily { kIpv4, kIpv6 };
struct EmulatedEndpointConfig {
enum class IpAddressFamily { kIpv4, kIpv6 };
EndpointConfig();
~EndpointConfig();
EndpointConfig(EndpointConfig&);
EndpointConfig& operator=(EndpointConfig&);
EndpointConfig(EndpointConfig&&);
EndpointConfig& operator=(EndpointConfig&&);
EmulatedEndpointConfig();
~EmulatedEndpointConfig();
EmulatedEndpointConfig(EmulatedEndpointConfig&);
EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&);
EmulatedEndpointConfig(EmulatedEndpointConfig&&);
EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&&);
IpAddressFamily generated_ip_family = IpAddressFamily::kIpv4;
// If specified will be used as IP address for endpoint node. Should be unique
// If specified will be used as IP address for endpoint node. Must be unique
// among all created nodes.
absl::optional<rtc::IPAddress> ip;
};
@ -55,7 +55,7 @@ class NetworkEmulationManager {
EmulatedNetworkNode* CreateEmulatedNode(
std::unique_ptr<NetworkBehaviorInterface> network_behavior);
EmulatedEndpoint* CreateEndpoint(EndpointConfig config);
EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config);
void CreateRoute(EmulatedEndpoint* from,
std::vector<EmulatedNetworkNode*> via_nodes,

View File

@ -109,9 +109,9 @@ TEST(NetworkEmulationManagerPCTest, Run) {
EmulatedNetworkNode* bob_node = network_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
EmulatedEndpoint* alice_endpoint =
network_manager.CreateEndpoint(EndpointConfig());
network_manager.CreateEndpoint(EmulatedEndpointConfig());
EmulatedEndpoint* bob_endpoint =
network_manager.CreateEndpoint(EndpointConfig());
network_manager.CreateEndpoint(EmulatedEndpointConfig());
network_manager.CreateRoute(alice_endpoint, {alice_node}, bob_endpoint);
network_manager.CreateRoute(bob_endpoint, {bob_node}, alice_endpoint);

View File

@ -60,8 +60,8 @@ class SocketReader : public sigslot::has_slots<> {
TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
NetworkEmulationManager network_manager;
std::set<rtc::IPAddress> ips;
EndpointConfig config;
config.generated_ip_family = EndpointConfig::IpAddressFamily::kIpv4;
EmulatedEndpointConfig config;
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv4;
for (int i = 0; i < 1000; i++) {
EmulatedEndpoint* endpoint = network_manager.CreateEndpoint(config);
ASSERT_EQ(endpoint->GetPeerLocalAddress().family(), AF_INET);
@ -73,8 +73,8 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) {
NetworkEmulationManager network_manager;
std::set<rtc::IPAddress> ips;
EndpointConfig config;
config.generated_ip_family = EndpointConfig::IpAddressFamily::kIpv6;
EmulatedEndpointConfig config;
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv6;
for (int i = 0; i < 1000; i++) {
EmulatedEndpoint* endpoint = network_manager.CreateEndpoint(config);
ASSERT_EQ(endpoint->GetPeerLocalAddress().family(), AF_INET6);
@ -91,9 +91,9 @@ TEST(NetworkEmulationManagerTest, Run) {
EmulatedNetworkNode* bob_node = network_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
EmulatedEndpoint* alice_endpoint =
network_manager.CreateEndpoint(EndpointConfig());
network_manager.CreateEndpoint(EmulatedEndpointConfig());
EmulatedEndpoint* bob_endpoint =
network_manager.CreateEndpoint(EndpointConfig());
network_manager.CreateEndpoint(EmulatedEndpointConfig());
network_manager.CreateRoute(alice_endpoint, {alice_node}, bob_endpoint);
network_manager.CreateRoute(bob_endpoint, {bob_node}, alice_endpoint);