void processWanLed(const char *state) { if (!cmsUtl_strcmp(state, "on")) { cmsLed_setWanConnected(); } else if (!cmsUtl_strcmp(state, "off")) { cmsLed_setWanDisconnected(); } else if (!cmsUtl_strcmp(state, "red")) { cmsLed_setWanFailed(); } else if(!cmsUtl_strcmp(state, "flashgreen")) { while (keepLooping) { cmsLed_setWanConnected(); usleep(250*1000); cmsLed_setWanDisconnected(); usleep(750*1000); } } else { usage(1); } }
int main(int argc, char *argv[]) { #if defined(AEI_VDSL_CUSTOMER_BELLALIANT) CmsRet ret; cmsLog_init(EID_LEDCTL); cmsLog_setLevel(DEFAULT_LOG_LEVEL); if ((ret = cmsMsg_init(EID_LEDCTL, &msgHandle)) != CMSRET_SUCCESS) { cmsLog_error("msg initialization failed, ret=%d", ret); cmsLog_cleanup(); return 0; } #endif if (argc != 3) { usage(1); } cmsLog_error("++++++++%s %s",argv[1],argv[2]); if (!cmsUtl_strcmp(argv[1], "WAN")) { processWanLed(argv[2]); } else { usage(1); } #if defined(AEI_VDSL_CUSTOMER_BELLALIANT) cmsMsg_cleanup(&msgHandle); cmsLog_cleanup(); #endif return 0; }
ConnectionModeType cmsUtl_connectionModeStrToNum(const char *connModeStr) { ConnectionModeType connMode = CMS_CONNECTION_MODE_DEFAULT; if (connModeStr == NULL) { cmsLog_error("connModeStr is NULL"); return connMode; } if (cmsUtl_strcmp(connModeStr, MDMVS_VLANMUXMODE) == 0) { connMode = CMS_CONNECTION_MODE_VLANMUX; } else if (cmsUtl_strcmp(connModeStr, MDMVS_MULTIPLESERVICEMODE) == 0) { connMode = CMS_CONNECTION_MODE_MSC; } return connMode; }
int oal_getPidByName(const char *name) { DIR *dir; FILE *fp; struct dirent *dent; UBOOL8 found=FALSE; int pid, rc, p, i; int rval = CMS_INVALID_PID; char filename[BUFLEN_256]; char processName[BUFLEN_256]; if (NULL == (dir = opendir("/proc"))) { cmsLog_error("could not open /proc"); return rval; } while (!found && (dent = readdir(dir)) != NULL) { /* * Each process has its own directory under /proc, the name of the * directory is the pid number. */ if ((dent->d_type == DT_DIR) && (CMSRET_SUCCESS == cmsUtl_strtol(dent->d_name, NULL, 10, &pid))) { snprintf(filename, sizeof(filename), "/proc/%d/stat", pid); if ((fp = fopen(filename, "r")) == NULL) { cmsLog_error("could not open %s", filename); } else { /* Get the process name, format: 913 (consoled) */ memset(processName, 0, sizeof(processName)); rc = fscanf(fp, "%d (%s", &p, processName); fclose(fp); if (rc >= 2) { i = strlen(processName); if (i > 0) { /* strip out the trailing ) character */ if (processName[i-1] == ')') processName[i-1] = 0; } } if (!cmsUtl_strcmp(processName, name)) { rval = pid; found = TRUE; } } } } closedir(dir); return rval; }