From 36971a687bf3a6edc2bf5af8a8b2a3176e7d4691 Mon Sep 17 00:00:00 2001 From: JP Abgrall Date: Mon, 18 Mar 2013 13:04:17 -0700 Subject: [PATCH] TetherController: fix "tether blabla list" commands handling And "interface list" doesn't accept the extra args anymore. Bug: 5327568 Change-Id: I3d2cb5d790b74a013edfc10dfe7a544e9e39f0ff --- CommandListener.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/CommandListener.cpp b/CommandListener.cpp index 496d446..8de0c68 100644 --- a/CommandListener.cpp +++ b/CommandListener.cpp @@ -555,11 +555,20 @@ int CommandListener::TetherCmd::runCommand(SocketClient *cli, 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 @@ int CommandListener::TetherCmd::runCommand(SocketClient *cli, } 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); -- 2.11.0