blob: 00fc0f16de4db45fbfa222936c76882f3618f7e3 [file] [log] [blame]
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "debugd/src/route_tool.h"
#include <base/files/file_util.h>
#include <chromeos/process.h>
#include "debugd/src/process_with_output.h"
namespace debugd {
const char* kIpTool = "/bin/ip";
std::vector<std::string> RouteTool::GetRoutes(
const std::map<std::string, DBus::Variant>& options, DBus::Error* error) {
std::vector<std::string> result;
ProcessWithOutput p;
if (!p.Init())
return result;
p.AddArg(kIpTool);
auto option_iter = options.find("v6");
if (option_iter != options.end() && option_iter->second.reader().get_bool())
p.AddArg("-6");
p.AddArg("r"); // route
p.AddArg("s"); // show
if (p.Run())
return result;
p.GetOutputLines(&result);
return result;
}
} // namespace debugd