TetherController: fix "tether blabla list" commands handling
And "interface list" doesn't accept the extra args anymore.
Bug: 5327568
Change-Id: I3d2cb5d790b74a013edfc10dfe7a544e9e39f0ff
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 496d446..8de0c68 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -555,11 +555,20 @@
cli->sendMsg(ResponseCode::TetherStatusResult, tmp, false);
free(tmp);
return 0;
- } else if (argc >= 3 && !strcmp(argv[1], "interface") && !strcmp(argv[2], "list")) {
- InterfaceCollection *ilist = sTetherCtrl->getTetheredInterfaceList();
- InterfaceCollection::iterator it;
- for (it = ilist->begin(); it != ilist->end(); ++it) {
- cli->sendMsg(ResponseCode::TetherInterfaceListResult, *it, false);
+ } else if (argc == 3) {
+ if (!strcmp(argv[1], "interface") && !strcmp(argv[2], "list")) {
+ InterfaceCollection *ilist = sTetherCtrl->getTetheredInterfaceList();
+ InterfaceCollection::iterator it;
+ for (it = ilist->begin(); it != ilist->end(); ++it) {
+ cli->sendMsg(ResponseCode::TetherInterfaceListResult, *it, false);
+ }
+ } else if (!strcmp(argv[1], "dns") && !strcmp(argv[2], "list")) {
+ NetAddressCollection *dlist = sTetherCtrl->getDnsForwarders();
+ NetAddressCollection::iterator it;
+
+ for (it = dlist->begin(); it != dlist->end(); ++it) {
+ cli->sendMsg(ResponseCode::TetherDnsFwdTgtListResult, inet_ntoa(*it), false);
+ }
}
} else {
/*
@@ -603,13 +612,7 @@
} else if (!strcmp(argv[1], "dns")) {
if (!strcmp(argv[2], "set")) {
rc = sTetherCtrl->setDnsForwarders(&argv[3], argc - 3);
- } else if (!strcmp(argv[2], "list")) {
- NetAddressCollection *dlist = sTetherCtrl->getDnsForwarders();
- NetAddressCollection::iterator it;
-
- for (it = dlist->begin(); it != dlist->end(); ++it) {
- cli->sendMsg(ResponseCode::TetherDnsFwdTgtListResult, inet_ntoa(*it), false);
- }
+ /* else if (!strcmp(argv[2], "list")) handled above */
} else {
cli->sendMsg(ResponseCode::CommandParameterError,
"Unknown tether interface operation", false);