blob: f19e08ac46f0e73f83983a5c7b2b086088ce495f [file] [log] [blame]
Elly Jonesad1e9d92012-07-20 15:39:23 -04001// Copyright (c) 2012 The Chromium OS 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
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#include "debugd/src/netif_tool.h"
Elly Jonesad1e9d92012-07-20 15:39:23 -04006
7#include <string>
8
9#include <dbus-c++/dbus.h>
10
Alex Vakulenko262be3f2014-07-30 15:25:50 -070011#include "debugd/src/process_with_output.h"
Elly Jonesad1e9d92012-07-20 15:39:23 -040012
Ben Chan55903dd2014-04-24 00:29:04 -070013using base::StringPrintf;
14
Elly Jonesad1e9d92012-07-20 15:39:23 -040015namespace debugd {
16
17NetifTool::NetifTool() { }
18
19NetifTool::~NetifTool() { }
20
21std::string NetifTool::GetInterfaces(DBus::Error* error) {
Ben Chan297c3c22013-07-17 17:34:12 -070022 std::string path;
23 if (!SandboxedProcess::GetHelperPath("netif", &path))
Elly Jonesad1e9d92012-07-20 15:39:23 -040024 return "<path too long>";
Ben Chan297c3c22013-07-17 17:34:12 -070025
Elly Jonesad1e9d92012-07-20 15:39:23 -040026 ProcessWithOutput p;
27 if (!p.Init())
28 return "<can't create process>";
29 p.AddArg(path);
30 p.Run();
31 std::string out;
32 p.GetOutput(&out);
33 return out;
34}
35
36} // namespace debugd