blob: d708b37e9722b6c7ee2d1929911005f8ed84cb69 [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
Hardik Goyalb09d6b02019-08-13 16:15:50 -07007#include "debugd/src/helper_utils.h"
Alex Vakulenko262be3f2014-07-30 15:25:50 -07008#include "debugd/src/process_with_output.h"
Elly Jonesad1e9d92012-07-20 15:39:23 -04009
Elly Jonesad1e9d92012-07-20 15:39:23 -040010namespace debugd {
11
Eric Carusoc93a15c2017-04-24 16:15:12 -070012std::string NetifTool::GetInterfaces() {
Ben Chan297c3c22013-07-17 17:34:12 -070013 std::string path;
Hardik Goyalb09d6b02019-08-13 16:15:50 -070014 if (!GetHelperPath("netif", &path))
Elly Jonesad1e9d92012-07-20 15:39:23 -040015 return "<path too long>";
Ben Chan297c3c22013-07-17 17:34:12 -070016
Elly Jonesad1e9d92012-07-20 15:39:23 -040017 ProcessWithOutput p;
18 if (!p.Init())
19 return "<can't create process>";
20 p.AddArg(path);
21 p.Run();
22 std::string out;
23 p.GetOutput(&out);
24 return out;
25}
26
27} // namespace debugd