Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 1 | // 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 Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #include "debugd/src/netif_tool.h" |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 6 | |
Hardik Goyal | b09d6b0 | 2019-08-13 16:15:50 -0700 | [diff] [blame] | 7 | #include "debugd/src/helper_utils.h" |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 8 | #include "debugd/src/process_with_output.h" |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 9 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 10 | namespace debugd { |
| 11 | |
Eric Caruso | c93a15c | 2017-04-24 16:15:12 -0700 | [diff] [blame] | 12 | std::string NetifTool::GetInterfaces() { |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 13 | std::string path; |
Hardik Goyal | b09d6b0 | 2019-08-13 16:15:50 -0700 | [diff] [blame] | 14 | if (!GetHelperPath("netif", &path)) |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 15 | return "<path too long>"; |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 16 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 17 | 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 |