Bug:
4676254
Change-Id: Ifb0b573750504f5daeb8db038d13dddd553797de
extern "C" int ifc_init(void);
extern "C" int ifc_init(void);
+extern "C" int ifc_close(void);
extern "C" int ifc_get_hwaddr(const char *name, void *ptr);
extern "C" int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength, unsigned *flags);
extern "C" int ifc_get_hwaddr(const char *name, void *ptr);
extern "C" int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength, unsigned *flags);
+extern "C" int ifc_get_addr(const char *name, in_addr_t *addr);
extern "C" int ifc_set_addr(const char *name, in_addr_t addr);
extern "C" int ifc_set_prefixLength(const char *name, int prefixLength);
extern "C" int ifc_up(const char *name);
extern "C" int ifc_set_addr(const char *name, in_addr_t addr);
extern "C" int ifc_set_prefixLength(const char *name, int prefixLength);
extern "C" int ifc_up(const char *name);
if (ifc_get_info(argv[2], &addr.s_addr, &prefixLength, &flags)) {
cli->sendMsg(ResponseCode::OperationFailed, "Interface not found", true);
if (ifc_get_info(argv[2], &addr.s_addr, &prefixLength, &flags)) {
cli->sendMsg(ResponseCode::OperationFailed, "Interface not found", true);
free(addr_s);
free(flag_s);
free(msg);
free(addr_s);
free(flag_s);
free(msg);
return 0;
} else if (!strcmp(argv[1], "setcfg")) {
// arglist: iface addr prefixLength [flags]
return 0;
} else if (!strcmp(argv[1], "setcfg")) {
// arglist: iface addr prefixLength [flags]
ifc_init();
if (ifc_set_addr(argv[2], addr.s_addr)) {
cli->sendMsg(ResponseCode::OperationFailed, "Failed to set address", true);
ifc_init();
if (ifc_set_addr(argv[2], addr.s_addr)) {
cli->sendMsg(ResponseCode::OperationFailed, "Failed to set address", true);
return 0;
}
if (ifc_set_prefixLength(argv[2], atoi(argv[4]))) {
cli->sendMsg(ResponseCode::OperationFailed, "Failed to set prefixLength", true);
return 0;
}
if (ifc_set_prefixLength(argv[2], atoi(argv[4]))) {
cli->sendMsg(ResponseCode::OperationFailed, "Failed to set prefixLength", true);
if (ifc_up(argv[2])) {
LOGE("Error upping interface");
cli->sendMsg(ResponseCode::OperationFailed, "Failed to up interface", true);
if (ifc_up(argv[2])) {
LOGE("Error upping interface");
cli->sendMsg(ResponseCode::OperationFailed, "Failed to up interface", true);
return 0;
}
} else if (!strcmp(flag, "down")) {
return 0;
}
} else if (!strcmp(flag, "down")) {
if (ifc_down(argv[2])) {
LOGE("Error downing interface");
cli->sendMsg(ResponseCode::OperationFailed, "Failed to down interface", true);
if (ifc_down(argv[2])) {
LOGE("Error downing interface");
cli->sendMsg(ResponseCode::OperationFailed, "Failed to down interface", true);
return 0;
}
} else if (!strcmp(flag, "broadcast")) {
return 0;
}
} else if (!strcmp(flag, "broadcast")) {
LOGD("multicast flag ignored");
} else {
cli->sendMsg(ResponseCode::CommandParameterError, "Flag unsupported", false);
LOGD("multicast flag ignored");
} else {
cli->sendMsg(ResponseCode::CommandParameterError, "Flag unsupported", false);
cli->sendMsg(ResponseCode::CommandOkay, "Interface configuration set", false);
cli->sendMsg(ResponseCode::CommandOkay, "Interface configuration set", false);
+ ifc_close();
+ return 0;
+ } else if (!strcmp(argv[1], "clearaddrs")) {
+ // arglist: iface
+ unsigned count, addr;
+
+ //IPv4 only right now
+ LOGD("Clearing all IP addresses on %s", argv[2]);
+
+ ifc_init();
+ for (count=0, addr=1;((addr != 0) && (count < 255)); count++) {
+ if (ifc_get_addr(argv[2], &addr) < 0)
+ break;
+ if (addr)
+ ifc_set_addr(argv[2], 0);
+ }
+ ifc_close();
+ cli->sendMsg(ResponseCode::CommandOkay, "Interface IP addresses cleared", false);
return 0;
} else {
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown interface cmd", false);
return 0;
} else {
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown interface cmd", false);