Add more packet info to nflog packet wakeup events
This patch completes the onWakeupEvent() binder interface of
INetdEventListener with some L2, L3, L4 packet information:
- ethertype
- destination hardware address
- destination ip address if any
- ip protocol if any
- src and dst ports if any
Also for consistency applying globally the transformation:
be16toh -> ntohs
be32toh -> ntohl
htobe16toh -> htons
htobe32toh -> htonl
Bug: 66869042
Test: runtest -x system/netd/server/netd_unit_test.cpp
+ manual testing by monitoring $ dumpsys connmetrics list
Change-Id: I33ef54d5af2e5e667006d853f56f3fe2e82b6a0b
diff --git a/server/WakeupController.h b/server/WakeupController.h
index e147f3e..841051b 100644
--- a/server/WakeupController.h
+++ b/server/WakeupController.h
@@ -29,11 +29,30 @@
class WakeupController {
public:
- using ReportFn = std::function<void(const std::string&, uid_t, gid_t, uint64_t)>;
+
+ // Simple data struct for passing back packet wakeup event information to the ReportFn callback.
+ struct ReportArgs {
+ std::string prefix;
+ uint64_t timestampNs;
+ int uid;
+ int gid;
+ int ethertype;
+ int ipNextHeader;
+ std::vector<uint8_t> dstHw;
+ std::string srcIp;
+ std::string dstIp;
+ int srcPort;
+ int dstPort;
+ };
+
+ // Callback that is triggered for every wakeup event.
+ using ReportFn = std::function<void(const struct ReportArgs&)>;
// iptables chain where wakeup packets are matched
static const char LOCAL_MANGLE_INPUT[];
+ static const uint32_t kDefaultPacketCopyRange;
+
WakeupController(ReportFn report, IptablesRestoreInterface* iptables)
: mReport(report), mIptables(iptables) {}