Add a class lable parameter to idletimer.
Now the idletimer should be setup by this command:
ndc idletimer add <interface> <timeout> <class label>
Class label can be a number or string to identify device type, such as
mobile or wifi. Idletimer will send label in the netd message instead
of the actual interface name.
Change-Id: Ic8b69dc5e38a4436c74723697905643a1214aa2a
diff --git a/IdletimerController.cpp b/IdletimerController.cpp
index efe4f09..2bcb9b7 100644
--- a/IdletimerController.cpp
+++ b/IdletimerController.cpp
@@ -51,8 +51,8 @@
* ndc command sequence
* ------------------
* ndc idletimer enable
- * ndc idletimer add <iface> <timeout>
- * ndc idletimer remove <iface> <timeout>
+ * ndc idletimer add <iface> <timeout> <class label>
+ * ndc idletimer remove <iface> <timeout> <class label>
*
* Monitor effect on the iptables chains after each step using:
* iptables -nxvL -t nat
@@ -148,28 +148,33 @@
}
int IdletimerController::modifyInterfaceIdletimer(IptOp op, const char *iface,
- uint32_t timeout) {
+ uint32_t timeout,
+ const char *classLabel) {
int res;
char *buffer;
asprintf(&buffer, "-t nat -%c idletimer_nat_PREROUTING -i %s -j IDLETIMER"
" --timeout %u --label %s --send_nl_msg 1",
- (op == IptOpAdd) ? 'A' : 'D', iface, timeout, iface);
+ (op == IptOpAdd) ? 'A' : 'D', iface, timeout, classLabel);
res = runIpxtablesCmd(buffer);
free(buffer);
asprintf(&buffer, "-t nat -%c idletimer_nat_POSTROUTING -o %s -j IDLETIMER"
" --timeout %u --label %s --send_nl_msg 1",
- (op == IptOpAdd) ? 'A' : 'D', iface, timeout, iface);
+ (op == IptOpAdd) ? 'A' : 'D', iface, timeout, classLabel);
res |= runIpxtablesCmd(buffer);
free(buffer);
return res;
}
-int IdletimerController::addInterfaceIdletimer(const char *iface, uint32_t timeout) {
- return modifyInterfaceIdletimer(IptOpAdd, iface, timeout);
+int IdletimerController::addInterfaceIdletimer(const char *iface,
+ uint32_t timeout,
+ const char *classLabel) {
+ return modifyInterfaceIdletimer(IptOpAdd, iface, timeout, classLabel);
}
-int IdletimerController::removeInterfaceIdletimer(const char *iface, uint32_t timeout) {
- return modifyInterfaceIdletimer(IptOpDelete, iface, timeout);
+int IdletimerController::removeInterfaceIdletimer(const char *iface,
+ uint32_t timeout,
+ const char *classLabel) {
+ return modifyInterfaceIdletimer(IptOpDelete, iface, timeout, classLabel);
}