Add a binder RPC for tethering stats.
Bug: 32163131
Bug: 64995262
Test: netd_{unit,integration}_test pass
Change-Id: I9c7dfdaf6b823840b1691761930b53c30a4dcbc3
diff --git a/server/TetherController.h b/server/TetherController.h
index e202f2b..e715a41 100644
--- a/server/TetherController.h
+++ b/server/TetherController.h
@@ -21,6 +21,7 @@
#include <set>
#include <string>
+#include <netdutils/StatusOr.h>
#include <sysutils/SocketClient.h>
#include "NetdConstants.h"
@@ -28,6 +29,8 @@
namespace android {
namespace net {
+using android::netdutils::StatusOr;
+
class TetherController {
private:
std::list<std::string> mInterfaces;
@@ -103,19 +106,17 @@
}
};
+ typedef std::vector<TetherStats> TetherStatsList;
+
+ StatusOr<TetherStatsList> getTetherStats(std::string &extraProcessingInfo);
+
/*
* Sends out to the cli a list of stats TetheringStatsListResult+CommandOkay).
* Error is to be handled on the outside.
*/
int getTetherStats(SocketClient *cli, std::string &extraProcessingInfo);
- int getTetherStats(SocketClient *cli, TetherStats &stats, std::string &extraProcessingInfo);
-
- typedef std::vector<TetherStats> TetherStatsList;
-
- static void addStats(TetherStatsList& statsList, const TetherStats& stats);
/*
- * output should be a file to the apropriate FORWARD chain of iptables rules.
* extraProcessingInfo: contains raw parsed data, and error info.
* This strongly requires that setup of the rules is in a specific order:
* in:intIface out:extIface
@@ -125,25 +126,14 @@
static int addForwardChainStats(TetherStatsList& statsList, const std::string& iptOutput,
std::string &extraProcessingInfo);
- /*
- * stats should never have only intIface initialized. Other 3 combos are ok.
- * fp should be a file to the apropriate FORWARD chain of iptables rules.
- * extraProcessingInfo: contains raw parsed data, and error info.
- * This strongly requires that setup of the rules is in a specific order:
- * in:intIface out:extIface
- * in:extIface out:intIface
- * and the rules are grouped in pairs when more that one tethering was setup.
- */
- static int addForwardChainStats(const TetherStats& filter,
- TetherStatsList& statsList, const std::string& iptOutput,
- std::string &extraProcessingInfo);
-
static constexpr const char* LOCAL_FORWARD = "tetherctrl_FORWARD";
static constexpr const char* LOCAL_MANGLE_FORWARD = "tetherctrl_mangle_FORWARD";
static constexpr const char* LOCAL_NAT_POSTROUTING = "tetherctrl_nat_POSTROUTING";
static constexpr const char* LOCAL_RAW_PREROUTING = "tetherctrl_raw_PREROUTING";
static constexpr const char* LOCAL_TETHER_COUNTERS_CHAIN = "tetherctrl_counters";
+ android::RWLock lock;
+
private:
bool setIpFwdEnabled();
@@ -156,6 +146,8 @@
int setForwardRules(bool set, const char *intIface, const char *extIface);
int setTetherCountingRules(bool add, const char *intIface, const char *extIface);
+ static void addStats(TetherStatsList& statsList, const TetherStats& stats);
+
// For testing.
friend class TetherControllerTest;
static int (*iptablesRestoreFunction)(IptablesTarget, const std::string&, std::string *);