Lines Matching refs:argv
148 int NdcDispatcher::dispatchCommand(int argc, char** argv) { in dispatchCommand() argument
154 if (c->getCommand() == argv[0]) { in dispatchCommand()
155 if (c->runCommand(&mNdc, argc, argv)) { in dispatchCommand()
167 int NdcDispatcher::InterfaceCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
173 if (!strcmp(argv[1], "list")) { in runCommand()
197 if (!strcmp(argv[1], "getcfg")) { in runCommand()
199 Status status = mNetd->interfaceGetCfg(std::string(argv[2]), &interfaceCfgResult); in runCommand()
216 } else if (!strcmp(argv[1], "setcfg")) { in runCommand()
227 interfaceCfg.ifName = argv[2]; in runCommand()
230 if (!inet_aton(argv[3], &addr)) { in runCommand()
237 interfaceCfg.ipv4Addr = argv[3]; in runCommand()
238 PARSE_INT_RETURN_IF_FAIL(cli, argv[4], interfaceCfg.prefixLength, in runCommand()
251 char* flag = argv[i]; in runCommand()
253 LOG(LOGLEVEL) << "Trying to bring up " << argv[2]; in runCommand()
264 LOG(LOGLEVEL) << "Trying to bring down " << argv[2]; in runCommand()
286 } else if (!strcmp(argv[1], "clearaddrs")) { in runCommand()
288 LOG(LOGLEVEL) << "Clearing all IP addresses on " << argv[2]; in runCommand()
290 mNetd->interfaceClearAddrs(std::string(argv[2])); in runCommand()
294 } else if (!strcmp(argv[1], "ipv6privacyextensions")) { in runCommand()
301 int enable = !strcmp(argv[3], "enable"); in runCommand()
302 Status status = mNetd->interfaceSetIPv6PrivacyExtensions(std::string(argv[2]), enable); in runCommand()
311 } else if (!strcmp(argv[1], "ipv6")) { in runCommand()
318 int enable = !strcmp(argv[3], "enable"); in runCommand()
319 Status status = mNetd->interfaceSetEnableIPv6(std::string(argv[2]), enable); in runCommand()
327 } else if (!strcmp(argv[1], "setmtu")) { in runCommand()
335 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], mtuValue, "Failed to set MTU", true); in runCommand()
336 Status status = mNetd->interfaceSetMtu(std::string(argv[2]), mtuValue); in runCommand()
354 int NdcDispatcher::IpFwdCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
361 if (!strcmp(argv[1], "status")) { in runCommand()
372 if (!strcmp(argv[1], "enable")) { in runCommand()
374 status = mNetd->ipfwdEnableForwarding(argv[2]); in runCommand()
375 } else if (!strcmp(argv[1], "disable")) { in runCommand()
377 status = mNetd->ipfwdDisableForwarding(argv[2]); in runCommand()
383 if (!strcmp(argv[1], "add")) { in runCommand()
385 status = mNetd->ipfwdAddInterfaceForward(argv[2], argv[3]); in runCommand()
386 } else if (!strcmp(argv[1], "remove")) { in runCommand()
388 status = mNetd->ipfwdRemoveInterfaceForward(argv[2], argv[3]); in runCommand()
408 int NdcDispatcher::TetherCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
416 if (!strcmp(argv[1], "stop")) { in runCommand()
418 } else if (!strcmp(argv[1], "status")) { in runCommand()
426 if (!strcmp(argv[1], "interface") && !strcmp(argv[2], "list")) { in runCommand()
433 } else if (!strcmp(argv[1], "start")) { in runCommand()
442 dhcpRanges.push_back(argv[arg_index]); in runCommand()
455 if (!strcmp(argv[1], "interface")) { in runCommand()
456 if (!strcmp(argv[2], "add")) { in runCommand()
457 status = mNetd->tetherInterfaceAdd(argv[3]); in runCommand()
458 } else if (!strcmp(argv[2], "remove")) { in runCommand()
459 status = mNetd->tetherInterfaceRemove(argv[3]); in runCommand()
466 } else if (!strcmp(argv[1], "dns")) { in runCommand()
467 if (!strcmp(argv[2], "set")) { in runCommand()
473 unsigned netId = stringToNetId(argv[3]); in runCommand()
475 tetherDnsAddrs.push_back(argv[arg_index]); in runCommand()
502 int NdcDispatcher::NatCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
513 if (!strcmp(argv[1], "enable") && argc >= 4) { in runCommand()
514 status = mNetd->tetherAddForward(argv[2], argv[3]); in runCommand()
515 } else if (!strcmp(argv[1], "disable") && argc >= 4) { in runCommand()
516 status = mNetd->tetherRemoveForward(argv[2], argv[3]); in runCommand()
555 int NdcDispatcher::BandwidthControlCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
561 LOG(LOGLEVEL) << StringPrintf("bwctrlcmd: argc=%d %s %s ...", argc, argv[0], argv[1]).c_str(); in runCommand()
563 if (!strcmp(argv[1], "removeiquota") || !strcmp(argv[1], "riq")) { in runCommand()
568 int rc = !mNetd->bandwidthRemoveInterfaceQuota(argv[2]).isOk(); in runCommand()
572 if (!strcmp(argv[1], "setiquota") || !strcmp(argv[1], "siq")) { in runCommand()
578 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], bytes, "Bandwidth command failed", false); in runCommand()
579 int rc = !mNetd->bandwidthSetInterfaceQuota(argv[2], bytes).isOk(); in runCommand()
583 if (!strcmp(argv[1], "addnaughtyapps") || !strcmp(argv[1], "ana")) { in runCommand()
591 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
598 if (!strcmp(argv[1], "removenaughtyapps") || !strcmp(argv[1], "rna")) { in runCommand()
606 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
613 if (!strcmp(argv[1], "addniceapps") || !strcmp(argv[1], "aha")) { in runCommand()
621 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
628 if (!strcmp(argv[1], "removeniceapps") || !strcmp(argv[1], "rha")) { in runCommand()
636 PARSE_UINT_RETURN_IF_FAIL(cli, argv[arg_index], uid, "Bandwidth command failed", false); in runCommand()
643 if (!strcmp(argv[1], "setglobalalert") || !strcmp(argv[1], "sga")) { in runCommand()
649 PARSE_INT_RETURN_IF_FAIL(cli, argv[2], bytes, "Bandwidth command failed", false); in runCommand()
654 if (!strcmp(argv[1], "setinterfacealert") || !strcmp(argv[1], "sia")) { in runCommand()
660 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], bytes, "Bandwidth command failed", false); in runCommand()
661 int rc = !mNetd->bandwidthSetInterfaceAlert(argv[2], bytes).isOk(); in runCommand()
665 if (!strcmp(argv[1], "removeinterfacealert") || !strcmp(argv[1], "ria")) { in runCommand()
670 int rc = !mNetd->bandwidthRemoveInterfaceAlert(argv[2]).isOk(); in runCommand()
681 int NdcDispatcher::IdletimerControlCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
689 << StringPrintf("idletimerctrlcmd: argc=%d %s %s ...", argc, argv[0], argv[1]).c_str(); in runCommand()
691 if (!strcmp(argv[1], "add")) { in runCommand()
698 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], timeout, "Failed to add interface", false); in runCommand()
699 Status status = mNetd->idletimerAddInterface(argv[2], timeout, argv[4]); in runCommand()
707 if (!strcmp(argv[1], "remove")) { in runCommand()
713 PARSE_INT_RETURN_IF_FAIL(cli, argv[3], timeout, "Failed to remove interface", false); in runCommand()
714 Status status = mNetd->idletimerRemoveInterface(argv[2], timeout, argv[4]); in runCommand()
775 int NdcDispatcher::FirewallCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
781 if (!strcmp(argv[1], "enable")) { in runCommand()
787 int res = !mNetd->firewallSetFirewallType(parseFirewallType(argv[2])).isOk(); in runCommand()
791 if (!strcmp(argv[1], "set_interface_rule")) { in runCommand()
797 int res = !mNetd->firewallSetInterfaceRule(argv[2], parseRule(argv[3])).isOk(); in runCommand()
801 if (!strcmp(argv[1], "set_uid_rule")) { in runCommand()
809 int childChain = parseChildChain(argv[2]); in runCommand()
816 PARSE_UINT_RETURN_IF_FAIL(cli, argv[3], uid, "Firewall command failed", false); in runCommand()
817 int res = !mNetd->firewallSetUidRule(childChain, uid, parseRule(argv[4])).isOk(); in runCommand()
821 if (!strcmp(argv[1], "enable_chain")) { in runCommand()
827 int res = !mNetd->firewallEnableChildChain(parseChildChain(argv[2]), true).isOk(); in runCommand()
831 if (!strcmp(argv[1], "disable_chain")) { in runCommand()
837 int res = !mNetd->firewallEnableChildChain(parseChildChain(argv[2]), false).isOk(); in runCommand()
847 int NdcDispatcher::ClatdCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
856 if (!strcmp(argv[1], "stop")) { in runCommand()
857 rc = !mNetd->clatdStop(argv[2]).isOk(); in runCommand()
858 } else if (!strcmp(argv[1], "start")) { in runCommand()
863 rc = !mNetd->clatdStart(argv[2], argv[3], &v6Addr).isOk(); in runCommand()
902 int NdcDispatcher::StrictCmd::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
908 if (!strcmp(argv[1], "set_uid_cleartext_policy")) { in runCommand()
917 PARSE_UINT_RETURN_IF_FAIL(cli, argv[2], uid, "Invalid UID", false); in runCommand()
923 int penalty = parsePenalty(argv[3]); in runCommand()
956 int NdcDispatcher::NetworkCommand::runCommand(NdcClient* cli, int argc, char** argv) const { in runCommand()
966 if (!strcmp(argv[1], "route")) { in runCommand()
974 if (!strcmp(argv[nextArg], "legacy")) { in runCommand()
977 PARSE_UINT_RETURN_IF_FAIL(cli, argv[nextArg++], uid, "Unknown argument", false); in runCommand()
981 if (!strcmp(argv[nextArg], "add")) { in runCommand()
983 } else if (strcmp(argv[nextArg], "remove") != 0) { in runCommand()
992 unsigned netId = stringToNetId(argv[nextArg++]); in runCommand()
993 const char* interface = argv[nextArg++]; in runCommand()
994 const char* destination = argv[nextArg++]; in runCommand()
995 const char* nexthop = argc > nextArg ? argv[nextArg] : ""; in runCommand()
1019 if (!strcmp(argv[1], "interface")) { in runCommand()
1023 unsigned netId = stringToNetId(argv[3]); in runCommand()
1024 if (!strcmp(argv[2], "add")) { in runCommand()
1025 if (Status status = mNetd->networkAddInterface(netId, argv[4]); !status.isOk()) { in runCommand()
1029 } else if (!strcmp(argv[2], "remove")) { in runCommand()
1030 if (Status status = mNetd->networkRemoveInterface(netId, argv[4]); !status.isOk()) { in runCommand()
1045 if (!strcmp(argv[1], "create")) { in runCommand()
1049 unsigned netId = stringToNetId(argv[2]); in runCommand()
1050 if (argc == 6 && !strcmp(argv[3], "vpn")) { in runCommand()
1051 bool secure = strtol(argv[4], nullptr, 2); in runCommand()
1061 permission = stringToINetdPermission(argv[3]); in runCommand()
1076 if (!strcmp(argv[1], "destroy")) { in runCommand()
1080 unsigned netId = stringToNetId(argv[2]); in runCommand()
1093 if (!strcmp(argv[1], "default")) { in runCommand()
1098 if (!strcmp(argv[2], "set")) { in runCommand()
1102 netId = stringToNetId(argv[3]); in runCommand()
1103 } else if (strcmp(argv[2], "clear") != 0) { in runCommand()
1118 if (!strcmp(argv[1], "permission")) { in runCommand()
1124 if (!strcmp(argv[3], "set")) { in runCommand()
1125 permission = stringToINetdPermission(argv[4]); in runCommand()
1130 } else if (strcmp(argv[3], "clear") != 0) { in runCommand()
1137 bool userPermissions = !strcmp(argv[2], "user"); in runCommand()
1138 bool networkPermissions = !strcmp(argv[2], "network"); in runCommand()
1147 unsigned id = strtoul(argv[nextArg], &endPtr, 0); in runCommand()
1148 if (!*argv[nextArg] || *endPtr) { in runCommand()
1154 ids.push_back(stringToNetId(argv[nextArg])); in runCommand()
1175 if (!strcmp(argv[1], "users")) { in runCommand()
1179 unsigned netId = stringToNetId(argv[3]); in runCommand()
1181 if (!uidRanges.parseFrom(argc - 4, argv + 4)) { in runCommand()
1184 if (!strcmp(argv[2], "add")) { in runCommand()
1190 } else if (!strcmp(argv[2], "remove")) { in runCommand()
1205 if (!strcmp(argv[1], "protect")) { in runCommand()
1212 PARSE_UINT_RETURN_IF_FAIL(cli, argv[i], uid, "Unknown argument", false); in runCommand()
1215 if (!strcmp(argv[2], "allow")) { in runCommand()
1219 } else if (!strcmp(argv[2], "deny")) { in runCommand()