Define TcpSocketMonitor with a single dump method
This patch adds a TcpSocketMonitor registered in Controllers and
implementing a single dump method for pretty printing socket info
dumped with SockDiag for all sockets on the system.
The dump method can be called with
$ adb shell dumpsys netd tcp_socket_info
Example of output is:
TcpSocketMonitor
uid=1021 saddr=192.168.2.29 daddr=192.168.2.228 sport=49766 dport=80 state=ESTABLISHED(1) rqueue=0 wqueue=339 rtt=0ms var_rtt=67373.1ms rcv_rtt=1.11372e+06ms unacked=1792 snd_cwnd=0
uid=0 saddr=192.168.2.29 daddr=8.8.4.4 sport=37050 dport=853 state=SYN-SENT(2) rqueue=0 wqueue=1 rtt=0ms var_rtt=134744ms rcv_rtt=1.11372e+06ms unacked=2816 snd_cwnd=0
uid=0 saddr=192.168.2.29 daddr=8.8.8.8 sport=38674 dport=853 state=SYN-SENT(2) rqueue=0 wqueue=1 rtt=1.9084e+06ms var_rtt=0.121ms rcv_rtt=1.90841e+06ms unacked=2816 snd_cwnd=0
uid=0 saddr=2001::0db8:4:fd00:51eb:5323:2a88:7e5a daddr=2001::0db8:4860::8844 sport=42521 dport=853 state=SYN-SENT(2) rqueue=0 wqueue=1 rtt=1.51824e+06ms var_rtt=1.61533e+06ms rcv_rtt=1.34365e+06ms unacked=2816 snd_cwnd=0
uid=0 saddr=2001::0db8:4:fd00:51eb:5323:2a88:7e5a daddr=2001::0db8:4860::8888 sport=44725 dport=853 state=SYN-SENT(2) rqueue=0 wqueue=1 rtt=0ms var_rtt=134744ms rcv_rtt=1.11372e+06ms unacked=2816 snd_cwnd=0
Bug: 64147860
Test: manual tests with newly introduced commands
Change-Id: Iad68cc141bc517f38c2c0ec3937269cb11fa8aa4
diff --git a/server/TcpSocketMonitor.h b/server/TcpSocketMonitor.h
new file mode 100644
index 0000000..7f1501a
--- /dev/null
+++ b/server/TcpSocketMonitor.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TCP_SOCKET_MONITOR_H
+#define TCP_SOCKET_MONITOR_H
+
+#include "utils/String16.h"
+
+namespace android {
+namespace net {
+
+class DumpWriter;
+
+class TcpSocketMonitor {
+ public:
+ static const String16 DUMP_KEYWORD;
+
+ TcpSocketMonitor() = default;
+ ~TcpSocketMonitor() = default;
+
+ void dump(DumpWriter& dw);
+
+ private:
+};
+
+} // namespace net
+} // namespace android
+
+#endif /* TCP_SOCKET_MONITOR_H */