Lines Matching refs:cli

53 #define PARSE_INT_RETURN_IF_FAIL(cli, label, intLabel, errMsg, addErrno)         \  argument
57 (cli)->sendMsg(ResponseCode::OperationFailed, (errMsg), (addErrno)); \
62 #define PARSE_UINT_RETURN_IF_FAIL(cli, label, intLabel, errMsg, addErrno) \ argument
66 (cli)->sendMsg(ResponseCode::OperationFailed, (errMsg), (addErrno)); \
167 int NdcDispatcher::InterfaceCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
169 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
179 cli->sendMsg(ResponseCode::OperationFailed, "Failed to get interface list", true); in runCommand()
183 cli->sendMsg(ResponseCode::InterfaceListResult, iface.c_str(), false); in runCommand()
186 cli->sendMsg(ResponseCode::CommandOkay, "Interface list completed", false); in runCommand()
193 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
203 cli->sendMsg(ResponseCode::OperationFailed, "Interface not found", true); in runCommand()
213 cli->sendMsg(ResponseCode::InterfaceGetCfgResult, msg.c_str(), false); in runCommand()
219 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
238 PARSE_INT_RETURN_IF_FAIL(cli, argv[4], interfaceCfg.prefixLength, in runCommand()
243 cli->sendMsg(ResponseCode::OperationFailed, "Failed to set address", true); in runCommand()
259 cli->sendMsg(ResponseCode::OperationFailed, "Failed to up interface", true); in runCommand()
270 cli->sendMsg(ResponseCode::OperationFailed, "Failed to down interface", in runCommand()
279 cli->sendMsg(ResponseCode::CommandParameterError, "Flag unsupported", false); in runCommand()
284 cli->sendMsg(ResponseCode::CommandOkay, "Interface configuration set", false); in runCommand()
292 cli->sendMsg(ResponseCode::CommandOkay, "Interface IP addresses cleared", false); in runCommand()
296 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
304 cli->sendMsg(ResponseCode::CommandOkay, "IPv6 privacy extensions changed", false); in runCommand()
307 cli->sendMsg(ResponseCode::OperationFailed, "Failed to set ipv6 privacy extensions", in runCommand()
313 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
321 cli->sendMsg(ResponseCode::CommandOkay, "IPv6 state changed", false); in runCommand()
324 cli->sendMsg(ResponseCode::OperationFailed, "Failed to change IPv6 state", true); in runCommand()
329 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
335 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], mtuValue, "Failed to set MTU", true); in runCommand()
338 cli->sendMsg(ResponseCode::CommandOkay, "MTU changed", false); in runCommand()
341 cli->sendMsg(ResponseCode::OperationFailed, "Failed to set MTU", true); in runCommand()
345 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown interface cmd", false); in runCommand()
354 int NdcDispatcher::IpFwdCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
365 cli->sendMsg(ResponseCode::IpFwdStatusResult, msg.c_str(), false); in runCommand()
393 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown ipfwd cmd", false); in runCommand()
398 cli->sendMsg(ResponseCode::CommandOkay, "ipfwd operation succeeded", false); in runCommand()
401 cli->sendMsg(ResponseCode::OperationFailed, "ipfwd operation failed", true); in runCommand()
408 int NdcDispatcher::TetherCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
412 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
423 cli->sendMsg(ResponseCode::TetherStatusResult, msg.c_str(), false); in runCommand()
430 cli->sendMsg(ResponseCode::TetherInterfaceListResult, ifname.c_str(), false); in runCommand()
435 cli->sendMsg(ResponseCode::CommandSyntaxError, "Bad number of arguments", false); in runCommand()
451 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
462 cli->sendMsg(ResponseCode::CommandParameterError, in runCommand()
469 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
480 cli->sendMsg(ResponseCode::CommandParameterError, in runCommand()
485 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown tether cmd", false); in runCommand()
491 cli->sendMsg(ResponseCode::CommandOkay, "Tether operation succeeded", false); in runCommand()
494 cli->sendMsg(ResponseCode::OperationFailed, "Tether operation failed", true); in runCommand()
502 int NdcDispatcher::NatCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
506 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
518 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown nat cmd", false); in runCommand()
523 cli->sendMsg(ResponseCode::CommandOkay, "Nat operation succeeded", false); in runCommand()
526 cli->sendMsg(ResponseCode::OperationFailed, "Nat operation failed", true); in runCommand()
534 void NdcDispatcher::BandwidthControlCmd::sendGenericSyntaxError(NdcClient* cli, in sendGenericSyntaxError() argument
538 cli->sendMsg(ResponseCode::CommandSyntaxError, msg, false); in sendGenericSyntaxError()
542 void NdcDispatcher::BandwidthControlCmd::sendGenericOkFail(NdcClient* cli, int cond) const { in sendGenericOkFail() argument
544 cli->sendMsg(ResponseCode::CommandOkay, "Bandwidth command succeeeded", false); in sendGenericOkFail()
546 cli->sendMsg(ResponseCode::OperationFailed, "Bandwidth command failed", false); in sendGenericOkFail()
550 void NdcDispatcher::BandwidthControlCmd::sendGenericOpFailed(NdcClient* cli, in sendGenericOpFailed() argument
552 cli->sendMsg(ResponseCode::OperationFailed, errMsg, false); in sendGenericOpFailed()
555 int NdcDispatcher::BandwidthControlCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
557 sendGenericSyntaxError(cli, "<cmds> <args...>"); in runCommand()
565 sendGenericSyntaxError(cli, "removeiquota <interface>"); in runCommand()
569 sendGenericOkFail(cli, rc); in runCommand()
574 sendGenericSyntaxError(cli, "setiquota <interface> <bytes>"); in runCommand()
578 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], bytes, "Bandwidth command failed", false); in runCommand()
580 sendGenericOkFail(cli, rc); in runCommand()
585 sendGenericSyntaxError(cli, "addnaughtyapps <appUid> ..."); in runCommand()
591 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
595 sendGenericOkFail(cli, rc); in runCommand()
600 sendGenericSyntaxError(cli, "removenaughtyapps <appUid> ..."); in runCommand()
606 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
610 sendGenericOkFail(cli, rc); in runCommand()
615 sendGenericSyntaxError(cli, "addniceapps <appUid> ..."); in runCommand()
621 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
625 sendGenericOkFail(cli, rc); in runCommand()
630 sendGenericSyntaxError(cli, "removeniceapps <appUid> ..."); in runCommand()
636 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
640 sendGenericOkFail(cli, rc); in runCommand()
645 sendGenericSyntaxError(cli, "setglobalalert <bytes>"); in runCommand()
649 PARSE_INT_RETURN_IF_FAIL(cli, argv[2], bytes, "Bandwidth command failed", false); in runCommand()
651 sendGenericOkFail(cli, rc); in runCommand()
656 sendGenericSyntaxError(cli, "setinterfacealert <interface> <bytes>"); in runCommand()
660 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], bytes, "Bandwidth command failed", false); in runCommand()
662 sendGenericOkFail(cli, rc); in runCommand()
667 sendGenericSyntaxError(cli, "removeinterfacealert <interface>"); in runCommand()
671 sendGenericOkFail(cli, rc); in runCommand()
675 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown bandwidth cmd", false); in runCommand()
681 int NdcDispatcher::IdletimerControlCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
684 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
693 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
698 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], timeout, "Failed to add interface", false); in runCommand()
701 cli->sendMsg(ResponseCode::OperationFailed, "Failed to add interface", false); in runCommand()
703 cli->sendMsg(ResponseCode::CommandOkay, "Add success", false); in runCommand()
709 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
713 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], timeout, "Failed to remove interface", false); in runCommand()
716 cli->sendMsg(ResponseCode::OperationFailed, "Failed to remove interface", false); in runCommand()
718 cli->sendMsg(ResponseCode::CommandOkay, "Remove success", false); in runCommand()
723 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown idletimer cmd", false); in runCommand()
729 int NdcDispatcher::FirewallCmd::sendGenericOkFail(NdcClient* cli, int cond) const { in sendGenericOkFail() argument
731 cli->sendMsg(ResponseCode::CommandOkay, "Firewall command succeeded", false); in sendGenericOkFail()
733 cli->sendMsg(ResponseCode::OperationFailed, "Firewall command failed", false); in sendGenericOkFail()
777 int NdcDispatcher::FirewallCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
779 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing command", false); in runCommand()
785 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
790 return sendGenericOkFail(cli, res); in runCommand()
795 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
800 return sendGenericOkFail(cli, res); in runCommand()
805 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
813 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
818 PARSE_UINT_RETURN_IF_FAIL(cli, argv[3], uid, "Firewall command failed", false); in runCommand()
820 return sendGenericOkFail(cli, res); in runCommand()
825 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
830 return sendGenericOkFail(cli, res); in runCommand()
835 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
840 return sendGenericOkFail(cli, res); in runCommand()
843 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown command", false); in runCommand()
849 int NdcDispatcher::ClatdCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
852 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
862 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing argument", false); in runCommand()
867 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown clatd cmd", false); in runCommand()
872 cli->sendMsg(ResponseCode::CommandOkay, in runCommand()
875 cli->sendMsg(ResponseCode::OperationFailed, "Clatd operation failed", false); in runCommand()
883 int NdcDispatcher::StrictCmd::sendGenericOkFail(NdcClient* cli, int cond) const { in sendGenericOkFail() argument
885 cli->sendMsg(ResponseCode::CommandOkay, "Strict command succeeded", false); in sendGenericOkFail()
887 cli->sendMsg(ResponseCode::OperationFailed, "Strict command failed", false); in sendGenericOkFail()
904 int NdcDispatcher::StrictCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
906 cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing command", false); in runCommand()
912 cli->sendMsg(ResponseCode::CommandSyntaxError, in runCommand()
919 PARSE_UINT_RETURN_IF_FAIL(cli, argv[2], uid, "Invalid UID", false); in runCommand()
921 cli->sendMsg(ResponseCode::CommandSyntaxError, "Invalid UID", false); in runCommand()
927 cli->sendMsg(ResponseCode::CommandSyntaxError, "Invalid penalty argument", false); in runCommand()
932 return sendGenericOkFail(cli, res); in runCommand()
935 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown command", false); in runCommand()
941 int NdcDispatcher::NetworkCommand::syntaxError(NdcClient* cli, const char* message) const { in syntaxError() argument
942 cli->sendMsg(ResponseCode::CommandSyntaxError, message, false); in syntaxError()
946 int NdcDispatcher::NetworkCommand::operationError(NdcClient* cli, const char* message, in operationError() argument
949 cli->sendMsg(ResponseCode::OperationFailed, message, true); in operationError()
953 int NdcDispatcher::NetworkCommand::success(NdcClient* cli) const { in success()
954 cli->sendMsg(ResponseCode::CommandOkay, "success", false); in success()
958 int NdcDispatcher::NetworkCommand::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand() argument
960 return syntaxError(cli, "Missing argument"); in runCommand()
970 return syntaxError(cli, "Incorrect number of arguments"); in runCommand()
979 PARSE_UINT_RETURN_IF_FAIL(cli, argv[nextArg++], uid, "Unknown argument", false); in runCommand()
986 return syntaxError(cli, "Unknown argument"); in runCommand()
991 return syntaxError(cli, "Incorrect number of arguments"); in runCommand()
1011 return operationError(cli, add ? "addRoute() failed" : "removeRoute() failed", in runCommand()
1015 return success(cli); in runCommand()
1023 return syntaxError(cli, "Missing argument"); in runCommand()
1028 return operationError(cli, "addInterfaceToNetwork() failed", in runCommand()
1033 return operationError(cli, "removeInterfaceFromNetwork() failed", in runCommand()
1037 return syntaxError(cli, "Unknown argument"); in runCommand()
1039 return success(cli); in runCommand()
1049 return syntaxError(cli, "Missing argument"); in runCommand()
1058 return operationError(cli, "createVirtualNetwork() failed", in runCommand()
1062 return syntaxError(cli, "Unknown trailing argument(s)"); in runCommand()
1068 return syntaxError(cli, "Unknown permission"); in runCommand()
1075 return operationError(cli, "createPhysicalNetwork() failed", in runCommand()
1079 return success(cli); in runCommand()
1086 return syntaxError(cli, "Incorrect number of arguments"); in runCommand()
1091 return operationError(cli, "destroyNetwork() failed", in runCommand()
1095 return success(cli); in runCommand()
1103 return syntaxError(cli, "Missing argument"); in runCommand()
1108 return syntaxError(cli, "Missing netId"); in runCommand()
1112 return syntaxError(cli, "Unknown argument"); in runCommand()
1115 return operationError(cli, "setDefaultNetwork() failed", in runCommand()
1118 return success(cli); in runCommand()
1128 return syntaxError(cli, "Missing argument"); in runCommand()
1135 return syntaxError(cli, "Unknown permission"); in runCommand()
1139 return syntaxError(cli, "Unknown argument"); in runCommand()
1142 return syntaxError(cli, "Missing id"); in runCommand()
1148 return syntaxError(cli, "Unknown argument"); in runCommand()
1157 return syntaxError(cli, "Invalid id"); in runCommand()
1172 return operationError(cli, "setPermissionForNetworks() failed", in runCommand()
1177 return success(cli); in runCommand()
1185 return syntaxError(cli, "Missing argument"); in runCommand()
1190 return syntaxError(cli, "Invalid UIDs"); in runCommand()
1195 return operationError(cli, "addUsersToNetwork() failed", in runCommand()
1201 return operationError(cli, "removeUsersFromNetwork() failed", in runCommand()
1205 return syntaxError(cli, "Unknown argument"); in runCommand()
1207 return success(cli); in runCommand()
1215 return syntaxError(cli, "Missing argument"); in runCommand()
1220 PARSE_UINT_RETURN_IF_FAIL(cli, argv[i], uid, "Unknown argument", false); in runCommand()
1232 return syntaxError(cli, "Unknown argument"); in runCommand()
1234 return success(cli); in runCommand()
1237 return syntaxError(cli, "Unknown argument"); in runCommand()