summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2020-02-17 23:59:45 +0900
committerMaciej Żenczykowski <maze@google.com>2020-02-17 19:46:57 +0000
commit52db3916eee87be7aae1038f5eaac13b03576d0b (patch)
tree2390175c0d8567fd5341726f7e1369fde9b6fa40 /server/TetherController.cpp
parent58efd78f173bac89cf4c7c9a0d51423033ebb776 (diff)
Add a dump method to TetherController
Test: manual Change-Id: I56834d4dd8afa49460e4e02e084b4f268a51d3fe
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index c987d634..b56480a9 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -42,6 +42,7 @@
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
#include <log/log.h>
+#include <netdutils/DumpWriter.h>
#include <netdutils/StatusOr.h>
#include "Controllers.h"
@@ -59,6 +60,8 @@ using android::base::Join;
using android::base::Pipe;
using android::base::StringPrintf;
using android::base::unique_fd;
+using android::netdutils::DumpWriter;
+using android::netdutils::ScopedIndent;
using android::netdutils::statusFromErrno;
using android::netdutils::StatusOr;
@@ -919,5 +922,34 @@ StatusOr<TetherController::TetherStatsList> TetherController::getTetherStats() {
return statsList;
}
+void TetherController::dumpIfaces(DumpWriter& dw) {
+ dw.println("Interface pairs:");
+
+ ScopedIndent ifaceIndent(dw);
+ for (const auto& it : mFwdIfaces) {
+ dw.println("%s -> %s %s", it.first.c_str(), it.second.iface.c_str(),
+ (it.second.active ? "ACTIVE" : "DISABLED"));
+ }
+}
+
+void TetherController::dump(DumpWriter& dw) {
+ std::lock_guard guard(lock);
+
+ ScopedIndent tetherControllerIndent(dw);
+ dw.println("TetherController");
+ dw.incIndent();
+
+ dw.println("Forwarding requests: " + Join(mForwardingRequests, ' '));
+ if (mDnsNetId != 0) {
+ dw.println(StringPrintf("DNS: netId %d servers [%s]", mDnsNetId,
+ Join(mDnsForwarders, ", ").c_str()));
+ }
+ if (mDaemonPid != 0) {
+ dw.println("dnsmasq PID: %d", mDaemonPid);
+ }
+
+ dumpIfaces(dw);
+}
+
} // namespace net
} // namespace android