Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: webrtc/rtc_base/network_unittest.cc

Issue 2985133002: If adapter type is unknown and interface name is "ipsec", treat as VPN. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/network.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 835
836 // Test that the network type can be determined based on name matching in 836 // Test that the network type can be determined based on name matching in
837 // a few cases. Note that UNKNOWN type for non-matching strings has been tested 837 // a few cases. Note that UNKNOWN type for non-matching strings has been tested
838 // in the above test. 838 // in the above test.
839 TEST_F(NetworkTest, TestGetAdapterTypeFromNameMatching) { 839 TEST_F(NetworkTest, TestGetAdapterTypeFromNameMatching) {
840 std::string ipv6_address1 = "1000:2000:3000:4000:0:0:0:1"; 840 std::string ipv6_address1 = "1000:2000:3000:4000:0:0:0:1";
841 std::string ipv6_address2 = "1000:2000:3000:8000:0:0:0:1"; 841 std::string ipv6_address2 = "1000:2000:3000:8000:0:0:0:1";
842 std::string ipv6_mask = "FFFF:FFFF:FFFF:FFFF::"; 842 std::string ipv6_mask = "FFFF:FFFF:FFFF:FFFF::";
843 BasicNetworkManager manager; 843 BasicNetworkManager manager;
844 844
845 #if defined(WEBRTC_IOS) 845 // IPSec interface; name is in form "ipsec<index>".
846 char if_name[20] = "pdp_ip0"; 846 char if_name[20] = "ipsec11";
847 ifaddrs* addr_list = 847 ifaddrs* addr_list =
848 InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); 848 InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
849 EXPECT_EQ(ADAPTER_TYPE_VPN, GetAdapterType(manager));
850 ClearNetworks(manager);
851 ReleaseIfAddrs(addr_list);
849 852
853 #if defined(WEBRTC_IOS)
854 strcpy(if_name, "pdp_ip0");
855 addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
850 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager)); 856 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager));
851 ClearNetworks(manager); 857 ClearNetworks(manager);
852 ReleaseIfAddrs(addr_list); 858 ReleaseIfAddrs(addr_list);
853 859
854 strcpy(if_name, "en0"); 860 strcpy(if_name, "en0");
855 addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); 861 addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
856 EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager)); 862 EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager));
857 ClearNetworks(manager); 863 ClearNetworks(manager);
858 ReleaseIfAddrs(addr_list); 864 ReleaseIfAddrs(addr_list);
859 865
860 #elif defined(WEBRTC_ANDROID) 866 #elif defined(WEBRTC_ANDROID)
861 char if_name[20] = "rmnet0"; 867 strcpy(if_name, "rmnet0");
862 ifaddrs* addr_list = 868 addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
863 InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
864
865 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager)); 869 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager));
866 ClearNetworks(manager); 870 ClearNetworks(manager);
867 ReleaseIfAddrs(addr_list); 871 ReleaseIfAddrs(addr_list);
868 872
869 strcpy(if_name, "wlan1"); 873 strcpy(if_name, "wlan1");
870 addr_list = InstallIpv6Network(if_name, ipv6_address2, ipv6_mask, manager); 874 addr_list = InstallIpv6Network(if_name, ipv6_address2, ipv6_mask, manager);
871 EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager)); 875 EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager));
872 ClearNetworks(manager); 876 ClearNetworks(manager);
873 ReleaseIfAddrs(addr_list); 877 ReleaseIfAddrs(addr_list);
874 878
875 strcpy(if_name, "v4-rmnet_data0"); 879 strcpy(if_name, "v4-rmnet_data0");
876 addr_list = InstallIpv6Network(if_name, ipv6_address2, ipv6_mask, manager); 880 addr_list = InstallIpv6Network(if_name, ipv6_address2, ipv6_mask, manager);
877 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager)); 881 EXPECT_EQ(ADAPTER_TYPE_CELLULAR, GetAdapterType(manager));
878 ClearNetworks(manager); 882 ClearNetworks(manager);
879 ReleaseIfAddrs(addr_list); 883 ReleaseIfAddrs(addr_list);
880 #else 884 #else
881 char if_name[20] = "wlan0"; 885 // TODO(deadbeef): If not iOS or Android, "wlan0" should be treated as
882 ifaddrs* addr_list = 886 // "unknown"? Why? This should be fixed if there's no good reason.
883 InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); 887 strcpy(if_name, "wlan0");
888 addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
884 889
885 EXPECT_EQ(ADAPTER_TYPE_UNKNOWN, GetAdapterType(manager)); 890 EXPECT_EQ(ADAPTER_TYPE_UNKNOWN, GetAdapterType(manager));
886 ClearNetworks(manager); 891 ClearNetworks(manager);
887 ReleaseIfAddrs(addr_list); 892 ReleaseIfAddrs(addr_list);
888 #endif 893 #endif
889 } 894 }
890 #endif // defined(WEBRTC_POSIX) 895 #endif // defined(WEBRTC_POSIX)
891 896
892 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) 897 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
893 // If you want to test non-default routes, you can do the following on a linux 898 // If you want to test non-default routes, you can do the following on a linux
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 // If the set default address is in a network, GetDefaultLocalAddress will 1150 // If the set default address is in a network, GetDefaultLocalAddress will
1146 // return the best IP in that network. 1151 // return the best IP in that network.
1147 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2); 1152 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2);
1148 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); 1153 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
1149 EXPECT_EQ(static_cast<IPAddress>(ip1), ip); 1154 EXPECT_EQ(static_cast<IPAddress>(ip1), ip);
1150 1155
1151 manager.StopUpdating(); 1156 manager.StopUpdating();
1152 } 1157 }
1153 1158
1154 } // namespace rtc 1159 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/rtc_base/network.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698