• Home
  • Raw
  • Download

Lines Matching full:network

11 #include "rtc_base/network.h"
122 bool SameNameAndPrefix(const rtc::Network& a, const rtc::Network& b) { in SameNameAndPrefix()
134 std::vector<const Network*> CopyNetworkPointers( in CopyNetworkPointers()
135 const std::vector<std::unique_ptr<Network>>& owning_list) { in CopyNetworkPointers()
136 std::vector<const Network*> ptr_list; in CopyNetworkPointers()
138 for (const auto& network : owning_list) { in CopyNetworkPointers() local
139 ptr_list.push_back(network.get()); in CopyNetworkPointers()
154 std::vector<std::unique_ptr<Network>> list, in MergeNetworkList()
162 const Network& network) { in IsIgnoredNetwork() argument
164 return network_manager.IsIgnoredNetwork(network); in IsIgnoredNetwork()
173 std::vector<std::unique_ptr<Network>> GetNetworks( in GetNetworks()
177 std::vector<std::unique_ptr<Network>> list; in GetNetworks()
193 std::vector<const Network*> list = network_manager.GetNetworks(); in GetAdapterType()
204 std::vector<std::unique_ptr<Network>>* networks) { in CallConvertIfAddrs()
249 std::vector<std::unique_ptr<Network>> result; in InstallIpv6Network()
291 std::vector<std::unique_ptr<Network>> result; in InstallIpv4Network()
329 // Test that the Network ctor works properly.
331 Network ipv4_network1("test_eth0", "Test Network Adapter 1", in TEST_F()
334 EXPECT_EQ("Test Network Adapter 1", ipv4_network1.description()); in TEST_F()
342 Network ipv4_network1("test_eth0", "Test Network Adapter 1", in TEST_F()
345 Network ipv4_network2("test_eth1", "Test Network Adapter 2", in TEST_F()
357 Network ignore_me("ignore_me", "Ignore me please!", IPAddress(0x12345600U), in TEST_F()
359 Network include_me("include_me", "Include me please!", IPAddress(0x12345600U), in TEST_F()
380 std::vector<std::unique_ptr<Network>> result = GetNetworks(manager, true); in TEST_F()
423 // is called, after network update signal is already sent. in TEST_F()
444 // Verify that MergeNetworkList() merges network lists properly.
446 Network ipv4_network1("test_eth0", "Test Network Adapter 1", in TEST_F()
448 Network ipv4_network2("test_eth1", "Test Network Adapter 2", in TEST_F()
456 std::vector<std::unique_ptr<Network>> list; in TEST_F()
457 list.push_back(std::make_unique<Network>(ipv4_network1)); in TEST_F()
466 std::vector<const rtc::Network*> current = manager.GetNetworks(); in TEST_F()
469 const Network* net1 = current[0]; in TEST_F()
474 list.push_back(std::make_unique<Network>(ipv4_network2)); in TEST_F()
484 const Network* net2 = current[0]; in TEST_F()
486 // Network id will increase. in TEST_F()
490 list.push_back(std::make_unique<Network>(ipv4_network1)); in TEST_F()
491 list.push_back(std::make_unique<Network>(ipv4_network2)); in TEST_F()
498 // Verify that we get previous instances of Network objects. in TEST_F()
508 list.push_back(std::make_unique<Network>(ipv4_network2)); in TEST_F()
509 list.push_back(std::make_unique<Network>(ipv4_network1)); in TEST_F()
516 // Verify that we get previous instances of Network objects. in TEST_F()
527 void SetupNetworks(std::vector<std::unique_ptr<Network>>* list) { in SetupNetworks()
533 Network ipv6_eth0_linklocalnetwork("test_eth0", "Test NetworkAdapter 1", in SetupNetworks()
537 Network ipv6_eth1_linklocalnetwork("test_eth1", "Test NetworkAdapter 2", in SetupNetworks()
543 Network ipv6_eth0_publicnetwork1_ip1("test_eth0", "Test NetworkAdapter 1", in SetupNetworks()
548 Network ipv6_eth1_publicnetwork1_ip1("test_eth1", "Test NetworkAdapter 1", in SetupNetworks()
551 list->push_back(std::make_unique<Network>(ipv6_eth0_linklocalnetwork)); in SetupNetworks()
552 list->push_back(std::make_unique<Network>(ipv6_eth1_linklocalnetwork)); in SetupNetworks()
553 list->push_back(std::make_unique<Network>(ipv6_eth0_publicnetwork1_ip1)); in SetupNetworks()
554 list->push_back(std::make_unique<Network>(ipv6_eth1_publicnetwork1_ip1)); in SetupNetworks()
557 // Test that the basic network merging case works.
563 std::vector<std::unique_ptr<Network>> networks; in TEST_F()
565 std::vector<const Network*> original_list = CopyNetworkPointers(networks); in TEST_F()
572 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
577 // Tests that when two network lists that describe the same set of networks are
585 std::vector<std::unique_ptr<Network>> networks; in TEST_F()
587 std::vector<const Network*> original_list = CopyNetworkPointers(networks); in TEST_F()
592 std::vector<std::unique_ptr<Network>> second_networks; in TEST_F()
594 std::vector<const Network*> second_list = in TEST_F()
599 std::vector<const Network*> resulting_list = manager.GetNetworks(); in TEST_F()
603 for (const Network* network : second_list) { in TEST_F() local
604 EXPECT_THAT(resulting_list, Not(Contains(network))); in TEST_F()
608 // Test that we can merge a network that is the same as another network but with
609 // a different IP. The original network should remain in the list, but have its
616 std::vector<std::unique_ptr<Network>> original_list; in TEST_F()
618 // Make a network that we're going to change. in TEST_F()
622 std::unique_ptr<Network> network_to_change = std::make_unique<Network>( in TEST_F()
623 "test_eth0", "Test Network Adapter 1", prefix, 64); in TEST_F()
624 std::unique_ptr<Network> changed_network = in TEST_F()
625 std::make_unique<Network>(*network_to_change); in TEST_F()
630 const Network* const network_to_change_ptr = network_to_change.get(); in TEST_F()
635 std::vector<std::unique_ptr<Network>> second_list; in TEST_F()
641 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
643 // Make sure the original network is still in the merged list. in TEST_F()
653 std::vector<std::unique_ptr<Network>> original_list; in TEST_F()
655 const Network* const network_ptr = original_list[2].get(); in TEST_F()
662 // Add a second IP to the public network on eth0 (2401:fa00:4:1000/64). in TEST_F()
665 Network ipv6_eth0_publicnetwork1_ip2("test_eth0", "Test NetworkAdapter 1", in TEST_F()
667 // This is the IP that already existed in the public network on eth0. in TEST_F()
671 std::vector<std::unique_ptr<Network>> second_list; in TEST_F()
674 std::make_unique<Network>(ipv6_eth0_publicnetwork1_ip2)); in TEST_F()
676 const auto network_copy = std::make_unique<Network>(*second_list[2]); in TEST_F()
680 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
684 for (const Network* network : list) { in TEST_F() local
685 if (SameNameAndPrefix(*network, *network_copy)) { in TEST_F()
688 // This should be the same network object as before. in TEST_F()
689 EXPECT_EQ(network, network_ptr); in TEST_F()
691 EXPECT_THAT(network->GetIPs(), in TEST_F()
696 EXPECT_THAT(network->GetIPs(), Not(Contains(InterfaceAddress(ip)))); in TEST_F()
707 std::vector<std::unique_ptr<Network>> original_list; in TEST_F()
714 // A second network for eth0. in TEST_F()
717 Network ipv6_eth0_publicnetwork2_ip1("test_eth0", "Test NetworkAdapter 1", in TEST_F()
720 std::vector<std::unique_ptr<Network>> second_list; in TEST_F()
723 std::make_unique<Network>(ipv6_eth0_publicnetwork2_ip1)); in TEST_F()
728 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
731 for (const Network* network : list) { in TEST_F() local
732 if (network->prefix() == ipv6_eth0_publicnetwork2_ip1.prefix() && in TEST_F()
733 network->name() == ipv6_eth0_publicnetwork2_ip1.name()) { in TEST_F()
734 // Check the new network has 1 IP and that it's the correct one. in TEST_F()
735 EXPECT_EQ(1U, network->GetIPs().size()); in TEST_F()
736 EXPECT_EQ(ip, network->GetIPs().at(0)); in TEST_F()
739 EXPECT_THAT(network->GetIPs(), Not(Contains(InterfaceAddress(ip)))); in TEST_F()
749 std::vector<std::unique_ptr<Network>> list = GetNetworks(manager, true); in TEST_F()
760 for (const auto& network : GetNetworks(manager, true)) { in TEST_F() local
761 if (network->prefix().family() == AF_INET6) { in TEST_F()
769 // Test that when network interfaces are sorted and given preference values,
774 Network ipv4_network1("test_eth0", "Test Network Adapter 1", in TEST_F()
782 Network ipv6_eth1_publicnetwork1_ip1("test_eth1", "Test NetworkAdapter 2", in TEST_F()
786 std::vector<std::unique_ptr<Network>> list; in TEST_F()
787 list.push_back(std::make_unique<Network>(ipv4_network1)); in TEST_F()
788 list.push_back(std::make_unique<Network>(ipv6_eth1_publicnetwork1_ip1)); in TEST_F()
789 const Network* net1 = list[0].get(); in TEST_F()
790 const Network* net2 = list[1].get(); in TEST_F()
795 // After sorting IPv6 network should be higher order than IPv4 networks. in TEST_F()
804 auto eth0 = std::make_unique<Network>("test_eth0", "Test Network Adapter 1", in TEST_F()
807 auto eth1 = std::make_unique<Network>("test_eth1", "Test Network Adapter 2", in TEST_F()
810 std::vector<std::unique_ptr<Network>> list; in TEST_F()
811 const Network* eth0_ptr = eth0.get(); in TEST_F()
812 const Network* eth1_ptr = eth1.get(); in TEST_F()
826 Network wifi("wlan0", "Wireless Adapter", IPAddress(0x12345600U), 24, in TEST_F()
829 Network ethernet("eth0", "Ethernet", IPAddress(0x12345600U), 24, in TEST_F()
832 Network cellular("test_cell", "Cellular Adapter", IPAddress(0x12345600U), 24, in TEST_F()
835 Network vpn("bridge_test", "VPN Adapter", IPAddress(0x12345600U), 24, in TEST_F()
838 Network unknown("test", "Test Adapter", IPAddress(0x12345600U), 24, in TEST_F()
850 std::vector<std::unique_ptr<Network>> result; in TEST_F()
858 // Verify that if there are two addresses on one interface, only one network
867 std::vector<std::unique_ptr<Network>> result; in TEST_F()
888 std::vector<std::unique_ptr<Network>> result; in TEST_F()
896 // Tests that the network type can be determined from the network monitor when
906 // A network created without a network monitor will get UNKNOWN type. in TEST_F()
912 // With the fake network monitor the type should be correctly determined. in TEST_F()
917 // Add the same ipv6 address as before but it has the right network type in TEST_F()
918 // detected by the network monitor now. in TEST_F()
925 // Test that the network type can be determined based on name matching in
998 // Test that an adapter won't be included in the network list if there's a
999 // network monitor that says it's unavailable.
1008 std::vector<std::unique_ptr<Network>> result; in TEST_F()
1036 // prefix/length into a single Network.
1040 std::vector<std::unique_ptr<Network>> list; in TEST_F()
1048 auto net1 = std::make_unique<Network>("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1049 auto net2 = std::make_unique<Network>("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1061 std::vector<const Network*> list2 = manager.GetNetworks(); in TEST_F()
1072 // a network becomes inactive and then active again.
1076 Network network1("test_wifi", "Test Network Adapter 1", in TEST_F()
1078 Network network2("test_eth0", "Test Network Adapter 2", in TEST_F()
1082 std::vector<std::unique_ptr<Network>> list; in TEST_F()
1083 auto net1 = std::make_unique<Network>(network1); in TEST_F()
1084 const Network* const net1_ptr = net1.get(); in TEST_F()
1091 std::vector<const Network*> current = manager.GetNetworks(); in TEST_F()
1096 auto net2 = std::make_unique<Network>(network2); in TEST_F()
1097 const Network* const net2_ptr = net2.get(); in TEST_F()
1108 list.push_back(std::make_unique<Network>(network1)); in TEST_F()
1118 // Test that the filtering logic follows the defined ruleset in network.h.
1126 // Create a network with this prefix. in TEST_F()
1127 Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), in TEST_F()
1160 // Test that the filtering logic follows the defined ruleset in network.h.
1171 // Create a network with this prefix. in TEST_F()
1172 Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), in TEST_F()
1236 // Clear the networks so that there will be network changes below. in TEST_F()
1238 // Network manager is started, so the callback is called when the network in TEST_F()
1239 // monitor fires the network-change event. in TEST_F()
1243 // Network manager is stopped. in TEST_F()
1266 std::vector<const Network*> networks = manager.GetNetworks(); in TEST_F()
1268 for (const Network* network : networks) { in TEST_F() local
1269 if (network->GetBestIP().family() == AF_INET) { in TEST_F()
1271 } else if (network->GetBestIP().family() == AF_INET6 && in TEST_F()
1272 !IPIsLoopback(network->GetBestIP())) { in TEST_F()
1273 // Existence of an IPv6 loopback address doesn't mean it has IPv6 network in TEST_F()
1288 // default address may be different from the best IP address of any network. in TEST_F()
1292 // Create a network with a prefix of ip1. in TEST_F()
1293 Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip1, 64), in TEST_F()
1299 std::vector<std::unique_ptr<Network>> list; in TEST_F()
1300 list.push_back(std::make_unique<Network>(ipv6_network)); in TEST_F()
1303 // If the set default address is not in any network, GetDefaultLocalAddress in TEST_F()
1310 // If the set default address is in a network, GetDefaultLocalAddress will in TEST_F()
1311 // return the best IP in that network. in TEST_F()
1327 auto net1 = std::make_unique<Network>("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1330 std::vector<std::unique_ptr<Network>> list; in TEST_F()
1337 std::vector<const Network*> list2 = manager.GetNetworks(); in TEST_F()
1345 std::make_unique<Network>("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1356 std::vector<const Network*> list2 = manager.GetNetworks(); in TEST_F()
1364 std::make_unique<Network>("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1374 std::vector<const Network*> list2 = manager.GetNetworks(); in TEST_F()
1393 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
1412 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
1426 std::vector<std::unique_ptr<Network>> result; in TEST_F()
1448 // The network monitor only knwos about the ipv6 address, interface. in TEST_F()
1465 Network* net1 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1469 Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1484 Network* net1 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1488 Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1507 Network net1("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1510 Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials)); in TEST_F()
1523 Network net1("em1", "em1", TruncateIP(ip1, 64), 64); in TEST_F()
1527 Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials)); in TEST_F()
1572 std::vector<const Network*> list = manager.GetNetworks(); in TEST_F()
1598 auto network = std::make_unique<Network>( in TEST() local
1599 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1600 EXPECT_FALSE(webrtc_network_internal::CompareNetworks(network, network)); in TEST()
1605 auto network_a = std::make_unique<Network>( in TEST()
1606 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1607 auto network_b = std::make_unique<Network>( in TEST()
1608 "test_eth1", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1612 auto network_c = std::make_unique<Network>( in TEST()
1613 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345500U), 24); in TEST()
1614 auto network_d = std::make_unique<Network>( in TEST()
1615 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1622 auto network_a = std::make_unique<Network>( in TEST()
1623 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1624 auto network_b = std::make_unique<Network>( in TEST()
1625 "test_eth1", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1626 auto network_c = std::make_unique<Network>( in TEST()
1627 "test_eth2", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1631 auto network_d = std::make_unique<Network>( in TEST()
1632 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1633 auto network_e = std::make_unique<Network>( in TEST()
1634 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345700U), 24); in TEST()
1635 auto network_f = std::make_unique<Network>( in TEST()
1636 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345800U), 24); in TEST()
1646 auto network_a = std::make_unique<Network>( in TEST()
1647 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 23); in TEST()
1648 auto network_b = std::make_unique<Network>( in TEST()
1649 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1650 auto network_c = std::make_unique<Network>( in TEST()
1651 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345700U), 24); in TEST()
1665 auto network_d = std::make_unique<Network>( in TEST()
1666 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1667 auto network_e = std::make_unique<Network>( in TEST()
1668 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()
1669 auto network_f = std::make_unique<Network>( in TEST()
1670 "test_eth0", "Test Network Adapter 1", IPAddress(0x12345600U), 24); in TEST()