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/Controllers.cpp b/server/Controllers.cpp
index 4231a53..8b02f60 100644
--- a/server/Controllers.cpp
+++ b/server/Controllers.cpp
@@ -188,13 +188,18 @@
Controllers::Controllers()
: clatdCtrl(&netCtrl),
wakeupCtrl(
- [this](const std::string& prefix, uid_t uid, gid_t gid, uint64_t timestampNs) {
+ [this](const WakeupController::ReportArgs& args) {
const auto listener = eventReporter.getNetdEventListener();
if (listener == nullptr) {
ALOGE("getNetdEventListener() returned nullptr. dropping wakeup event");
return;
}
- listener->onWakeupEvent(String16(prefix.c_str()), uid, gid, timestampNs);
+ String16 prefix = String16(args.prefix.c_str());
+ String16 srcIp = String16(args.srcIp.c_str());
+ String16 dstIp = String16(args.dstIp.c_str());
+ listener->onWakeupEvent(prefix, args.uid, args.ethertype, args.ipNextHeader,
+ args.dstHw, srcIp, dstIp, args.srcPort, args.dstPort,
+ args.timestampNs);
},
&iptablesRestoreCtrl) {
InterfaceController::initializeAll();