blob: 12657a8859a05d61abafc24ce2e85ed41cebbc25 [file] [log] [blame]
Elly Jones73161782012-08-14 17:37:05 -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
5#include "icmp_tool.h"
6
7#include <stdlib.h>
8#include <base/stringprintf.h>
9
10#include "process_with_output.h"
11
12namespace debugd {
13
14ICMPTool::ICMPTool() { }
15ICMPTool::~ICMPTool() { }
16
17std::string ICMPTool::TestICMP(const std::string& host, DBus::Error* error) {
18 char *envvar = getenv("DEBUGD_HELPERS");
19 std::string path = StringPrintf("%s/icmp", envvar ? envvar
20 : "/usr/libexec/debugd/helpers");
21 if (path.length() > PATH_MAX)
22 return "<path too long>";
23 ProcessWithOutput p;
24 if (!p.Init())
25 return "<can't create process>";
26 p.AddArg(path);
27 p.AddArg(host);
28 p.Run();
29 std::string out;
30 p.GetOutput(&out);
31 return out;
32}
33
34}; // namespace debugd