net_util_cast.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "chromecast/net/net_util_cast.h"
  5. #include "base/command_line.h"
  6. #include "base/strings/string_split.h"
  7. #include "chromecast/base/cast_sys_info_util.h"
  8. #include "chromecast/net/net_switches.h"
  9. #include "chromecast/public/cast_sys_info.h"
  10. namespace chromecast {
  11. std::unordered_set<std::string> GetIgnoredInterfaces() {
  12. std::unordered_set<std::string> ignored_interfaces;
  13. std::unique_ptr<CastSysInfo> sys_info = CreateSysInfo();
  14. if (!sys_info->GetApInterface().empty())
  15. ignored_interfaces.insert(sys_info->GetApInterface());
  16. // Add interfaces from "netif-to-ignore" switch.
  17. base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  18. base::CommandLine::StringType netifs_to_ignore_str =
  19. command_line->GetSwitchValueNative(switches::kNetifsToIgnore);
  20. for (const std::string& netif : base::SplitString(
  21. netifs_to_ignore_str, ",", base::TRIM_WHITESPACE,
  22. base::SPLIT_WANT_ALL))
  23. ignored_interfaces.insert(netif);
  24. return ignored_interfaces;
  25. }
  26. } // namespace chromecast