/*-------------------------------------------------------------------------------------- * Purpose: Read the queue settings from the config file. * Input: none * Output: returns 0 on success, 1 on failure * Dan Massey @ July 22, 2008 * -------------------------------------------------------------------------------------*/ int readQueueSettings() { int err = 0; int result; float fnum; int num; // get the pacing on threshold result = getConfigValueAsFloat(&fnum, XML_QUEUE_PACING_ON_PATH, 0, 1); if (result == CONFIG_VALID_ENTRY) QueueConfig.pacingOnThresh = fnum; else if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue pacing on threshold."); } else log_msg("No configuration of queue pacing on threshold, using default."); #ifdef DEBUG debug( __FUNCTION__, "queue's pacingOnThresh %f.", QueueConfig.pacingOnThresh ); #endif // get pacing off threshold result = getConfigValueAsFloat(&fnum, XML_QUEUE_PACING_OFF_PATH, 0, 1); if (result == CONFIG_VALID_ENTRY) QueueConfig.pacingOffThresh = fnum; else if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue pacing off threshold."); } else log_msg("No configuration of queue pacing off threshold, using default."); #ifdef DEBUG debug( __FUNCTION__, "queue's pacingOffThresh %f.", QueueConfig.pacingOffThresh ); #endif // get alpha result = getConfigValueAsFloat(&fnum, XML_QUEUE_ALPHA_PATH, 0, 1); if (result == CONFIG_VALID_ENTRY) QueueConfig.alpha = fnum; else if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue alpha value."); } else log_msg("No configuration of queue alpha value, using default."); #ifdef DEBUG debug( __FUNCTION__, "queue's alpha %f.", QueueConfig.alpha); #endif // get min writes limit result = getConfigValueAsInt(&num, XML_QUEUE_MIN_WRITES_LIMIT_PATH, 0, 65536); if (result == CONFIG_VALID_ENTRY) QueueConfig.minWritesPerInterval= num; else{ if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue min writes per interval."); } else log_msg("No configuration of queue min writes per interval, using default."); } #ifdef DEBUG debug( __FUNCTION__, "queue's min writes limit per interval %d.", QueueConfig.minWritesPerInterval); #endif // get pacing Interval result = getConfigValueAsInt(&num, XML_QUEUE_PACING_INTERVAL_PATH, 0, 65536); if (result == CONFIG_VALID_ENTRY) QueueConfig.pacingInterval = num; else{ if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue pacing interval."); } else log_msg("No configuration of queue pacing interval, using default."); } #ifdef DEBUG debug( __FUNCTION__, "queue's pacing interval %d.", QueueConfig.pacingInterval); #endif // get log Interval result = getConfigValueAsInt(&num, XML_QUEUE_LOG_INTERVAL_PATH, 0, 65536); if (result == CONFIG_VALID_ENTRY) QueueConfig.logInterval = num; else{ if (result == CONFIG_INVALID_ENTRY) { err = 1; log_warning("Invalid configuration of queue log interval."); } else log_msg("No configuration of queue log interval, using default."); } #ifdef DEBUG debug( __FUNCTION__, "queue's log interval %d.", QueueConfig.logInterval); #endif return err; };
/*-------------------------------------------------------------------------------------- * Purpose: Read the login control settings from the config file. * Input: none * Output: returns 0 on success, 1 on failure * Kevin Burnett @ November 18, 2008 * -------------------------------------------------------------------------------------*/ int readLoginControlSettings() { int err = 0; int result = 0; int num = 0; char * addr = NULL; char * temp = NULL; // get listen addr and port only if we are not in recovery mode if(!LoginSettings.recoveryMode){ result = getConfigValueAsAddr(&addr, XML_LOGIN_ADDRESS_PATH, ADDR_PASSIVE); if (result == CONFIG_VALID_ENTRY){ result = checkAddress(addr, ADDR_PASSIVE); if(result != ADDR_VALID){ err = 1; log_warning("Invalid configuration of login listen address."); } else { strncpy(LoginSettings.listenAddr, addr, ADDR_MAX_CHARS); } free(addr); }else if ( result == CONFIG_INVALID_ENTRY ){ err = 1; log_warning("Invalid configuration of login listen address."); }else{ log_msg("No configuration of login listen address, using default."); } #ifdef DEBUG debug(__FUNCTION__, "Login Control Addr:%s", LoginSettings.listenAddr); #endif // get listen port result = getConfigValueAsInt(&num, XML_LOGIN_PORT_PATH, 1, 65536); if (result == CONFIG_VALID_ENTRY) { LoginSettings.listenPort = num; }else if( result == CONFIG_INVALID_ENTRY ){ err = 1; log_warning("Invalid configuration of login listen port."); } else{ log_msg("No configuration of login listen port, using default."); } #ifdef DEBUG debug(__FUNCTION__, "Login listen port set to %d", LoginSettings.listenPort); #endif } // get ACCESS_PASSWORD value if(getConfigValueAsString(&temp, XML_LOGIN_ACCESS_PASSWORD_PATH, PASSWORD_MAX_CHARS )) { log_warning("Invalid configuration of Login access password, default value used."); } else { memcpy(LoginSettings.accessPassword, temp, strlen(temp) + 1); free(temp); } // get ENABLE_PASSWORD value if(getConfigValueAsString(&temp, XML_LOGIN_ENABLE_PASSWORD_PATH, PASSWORD_MAX_CHARS)) { log_warning("Invalid configuration of Login enable password, default value used."); } else { memcpy(LoginSettings.enablePassword, temp, strlen(temp) + 1); free(temp); } // get the cli ACL AccessControlList * acl = NULL; #ifdef DEBUG char * aclName = NULL; #endif result = getConfigValueAsString(&temp, XML_LOGIN_CLI_ACL_PATH, PASSWORD_MAX_CHARS); if(result==0) { acl = getACL(temp); if(acl!=NULL) { LoginSettings.cliAcl = acl; #ifdef DEBUG aclName = acl->name; #endif } free(temp); } #ifdef DEBUG debug(__FUNCTION__, "Command Line Interface Access Control List set to [%s]", aclName); #endif // get the client update ACL acl = NULL; #ifdef DEBUG aclName = NULL; #endif result = getConfigValueAsString(&temp, XML_LOGIN_CLIENT_UPDATE_ACL_PATH, PASSWORD_MAX_CHARS); if(result==0) { acl = getACL(temp); if(acl!=NULL) { LoginSettings.clientUpdateAcl = acl; #ifdef DEBUG aclName = acl->name; #endif } free(temp); } #ifdef DEBUG debug(__FUNCTION__, "Client Update's Access Control List set to [%s]", aclName); #endif // get the client rib ACL acl = NULL; #ifdef DEBUG aclName = NULL; #endif result = getConfigValueAsString(&temp, XML_LOGIN_CLIENT_RIB_ACL_PATH, PASSWORD_MAX_CHARS); if(result==0) { acl = getACL(temp); if(acl!=NULL) { LoginSettings.clientRIBAcl = acl; #ifdef DEBUG aclName = acl->name; #endif } free(temp); } #ifdef DEBUG debug(__FUNCTION__, "Client RIB's Access Control List set to [%s]", aclName); #endif // get the mrt ACL acl = NULL; #ifdef DEBUG aclName = NULL; #endif result = getConfigValueAsString(&temp, XML_LOGIN_MRT_ACL_PATH, PASSWORD_MAX_CHARS); if(result==0) { acl = getACL(temp); if(acl!=NULL) { LoginSettings.mrtAcl = acl; #ifdef DEBUG aclName = acl->name; #endif } free(temp); } #ifdef DEBUG debug(__FUNCTION__, "Mrt's Access Control List set to [%s]", aclName); #endif return err; }