/* * Load from console.conf XML file the section: * <keybindings> * <key name="1" value="show calls"/> * </keybindings> */ static switch_status_t console_xml_config(void) { char *cf = "switch.conf"; switch_xml_t cfg, xml, settings, param; /* clear the keybind array */ int i; for (i = 0; i < 12; i++) { console_fnkeys[i] = NULL; } if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "cli-keybindings"))) { for (param = switch_xml_child(settings, "key"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); i = atoi(var); if ((i < 1) || (i > 12)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Keybind %s is invalid, range is from 1 to 12\n", var); } else { /* Add the command to the fnkey array */ console_fnkeys[i - 1] = switch_core_permanent_strdup(val); } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
static switch_status_t do_config(void) { char *cf = "python.conf"; switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "xml-handler-script")) { globals.xml_handler = switch_core_strdup(globals.pool, val); } else if (!strcmp(var, "xml-handler-bindings")) { if (!zstr(globals.xml_handler)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "binding '%s' to '%s'\n", globals.xml_handler, val); switch_xml_bind_search_function(python_fetch, switch_xml_parse_section_string(val), NULL); } } else if (!strcmp(var, "startup-script")) { if (val) { py_thread(val); } } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
static int load_tts_commandline_config(void) { char *cf = "tts_commandline.conf"; switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); } else { if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "command")) { set_global_command(val); } } } switch_xml_free(xml); } if (zstr(globals.command)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No command set, please edit %s\n", cf); } return SWITCH_STATUS_SUCCESS; }
static void load_config(void) { char *cf = "dialplan_directory.conf"; switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "directory-name") && val) { set_global_directory_name(val); } else if (!strcmp(var, "host") && val) { set_global_host(val); } else if (!strcmp(var, "dn") && val) { set_global_dn(val); } else if (!strcmp(var, "pass") && val) { set_global_pass(val); } else if (!strcmp(var, "base") && val) { set_global_base(val); } } } switch_xml_free(xml); }
static int load_config(void) { switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(OREKA_XML_CONFIG, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open XML configuration '%s'\n", OREKA_XML_CONFIG); return -1; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found parameter %s=%s\n", var, val); if (!strcasecmp(var, "sip-server-addr")) { snprintf(globals.sip_server_addr_str, sizeof(globals.sip_server_addr_str), "%s", val); } else if (!strcasecmp(var, "sip-server-port")) { globals.sip_server_port = atoi(val); } else if (!strcasecmp(var, "mux-all-streams")) { globals.mux_streams = 1; } } } switch_xml_free(xml); return 0; }
static switch_status_t load_config(switch_bool_t reload) { switch_xml_t cfg, xml = NULL, settings, param, x_profiles, x_profile; if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); return SWITCH_STATUS_TERM; } switch_mutex_lock(globals.mutex); if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "debug")) { globals.debug = atoi(val); } } } if ((x_profiles = switch_xml_child(cfg, "profiles"))) { for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { load_profile(switch_xml_attr_soft(x_profile, "name")); } } switch_mutex_unlock(globals.mutex); switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
static switch_status_t load_config(switch_bool_t reload) { switch_status_t status = SWITCH_STATUS_SUCCESS; switch_xml_t cfg, xml = NULL, settings, param, x_profiles, x_profile; switch_cache_db_handle_t *dbh = NULL; if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); return SWITCH_STATUS_TERM; } switch_mutex_lock(globals.mutex); if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { if (switch_odbc_available()) { switch_set_string(globals.odbc_dsn, val); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); } } else if (!strcasecmp(var, "dbname") && !zstr(val)) { globals.dbname = switch_core_strdup(globals.pool, val); } if (!strcasecmp(var, "debug")) { globals.debug = atoi(val); } } } if ((x_profiles = switch_xml_child(cfg, "profiles"))) { for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { load_profile(switch_xml_attr_soft(x_profile, "name")); } } if (zstr(globals.odbc_dsn) && zstr(globals.dbname)) { globals.dbname = switch_core_sprintf(globals.pool, "directory"); } dbh = directory_get_db_handle(); if (dbh) { if (!reload) { switch_cache_db_test_reactive(dbh, "delete from directory_search where uuid != '' and name_visible != '' ", "drop table directory_search", dir_sql); } switch_cache_db_release_db_handle(&dbh); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!2\n"); status = SWITCH_STATUS_TERM; goto end; } end: switch_mutex_unlock(globals.mutex); switch_xml_free(xml); return status; }
static switch_status_t load_config(void) { char *cf = "shout.conf"; switch_xml_t cfg, xml, settings, param; memset(&globals, 0, sizeof(globals)); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "decoder")) { switch_set_string(globals.decoder, val); } else if (!strcmp(var, "volume")) { globals.vol = (float) atof(val); } else if (!strcmp(var, "outscale")) { int tmp = atoi(val); if (tmp > 0) { globals.outscale = tmp; } } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
switch_status_t mod_amqp_do_config(switch_bool_t reload) { switch_xml_t cfg = NULL, xml = NULL, profiles = NULL, profile = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, reload ? "Reloading Config\n" : "Loading Config\n"); if (!(xml = switch_xml_open_cfg("amqp.conf", &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of amqp.conf.xml failed\n"); return SWITCH_STATUS_FALSE; } if ((profiles = switch_xml_child(cfg, "producers"))) { if ((profile = switch_xml_child(profiles, "profile"))) { for (; profile; profile = profile->next) { char *name = (char *) switch_xml_attr_soft(profile, "name"); if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load mod_amqp profile. Check configs missing name attr\n"); continue; } if ( mod_amqp_producer_create(name, profile) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load mod_amqp profile [%s]. Check configs\n", name); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loaded mod_amqp profile [%s] successfully\n", name); } } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unable to locate a profile for mod_amqp\n" ); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unable to locate producers section for mod_amqp\n" ); } if ((profiles = switch_xml_child(cfg, "commands"))) { if ((profile = switch_xml_child(profiles, "profile"))) { for (; profile; profile = profile->next) { char *name = (char *) switch_xml_attr_soft(profile, "name"); if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load mod_amqp profile. Check configs missing name attr\n"); continue; } name = switch_core_strdup(globals.pool, name); if ( mod_amqp_command_create(name, profile) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load mod_amqp profile [%s]. Check configs\n", name); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loaded mod_amqp profile [%s] successfully\n", name); } } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unable to locate a profile for mod_amqp\n" ); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unable to locate commands section for mod_amqp\n" ); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t load_config(void) { switch_xml_t cfg, xml, settings, param; int num_servers = 0; int i = 0; my_timeout = "5"; my_retries = "3"; my_deadtime = "0"; strncpy(my_seqfile, "/var/run/radius.seq", PATH_MAX - 1); strncpy(my_dictionary, "/usr/local/freeswitch/conf/radius/dictionary", PATH_MAX - 1); for (i = 0; i < SERVER_MAX; i++) { my_servers[i][0] = '\0'; } if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "acctserver")) { if (num_servers < SERVER_MAX) { strncpy(my_servers[num_servers], val, 255 - 1); num_servers++; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "you can only specify %d radius servers, ignoring excess server entry\n", SERVER_MAX); } } else if (!strcmp(var, "dictionary")) { strncpy(my_dictionary, val, PATH_MAX - 1); } else if (!strcmp(var, "seqfile")) { strncpy(my_seqfile, val, PATH_MAX - 1); } else if (!strcmp(var, "radius_timeout")) { my_timeout = strdup(val); } else if (!strcmp(var, "radius_retries")) { my_retries = strdup(val); } else if (!strcmp(var, "radius_deadtime")) { my_deadtime = strdup(val); } } } switch_xml_free(xml); if (num_servers < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "you must specify at least 1 radius server\n"); return SWITCH_STATUS_TERM; } /* If we made it this far, we succeeded */ return SWITCH_STATUS_SUCCESS; }
static switch_status_t load_config(void) { char *cf = "translate.conf"; switch_xml_t cfg, xml, rule, profile, profiles; switch_status_t status = SWITCH_STATUS_SUCCESS; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); status = SWITCH_STATUS_FALSE; goto done; } if ((profiles = switch_xml_child(cfg, "profiles"))) { for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) { translate_rule_t *rules_list = NULL; char *name = (char *) switch_xml_attr_soft(profile, "name"); if (!name) { continue; } for (rule = switch_xml_child(profile, "rule"); rule; rule = rule->next) { char *regex = (char *) switch_xml_attr_soft(rule, "regex"); char *replace = (char *) switch_xml_attr_soft(rule, "replace"); if (regex && replace) { translate_rule_t *this_rule = NULL, *rl = NULL; this_rule = switch_core_alloc(globals.pool, sizeof(translate_rule_t)); this_rule->regex = switch_core_strdup(globals.pool, regex); this_rule->replace = switch_core_strdup(globals.pool, replace); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Replace number matching [%s] with [%s]\n", regex, replace); if (rules_list == NULL) { rules_list = switch_core_alloc(globals.pool, sizeof(translate_rule_t)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "starting with an empty list\n"); rules_list = this_rule; } else { for (rl = rules_list; rl && rl->next; rl = rl->next); rl->next = this_rule; } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Translation!\n"); } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding rules to profile [%s]\n", name); switch_core_hash_insert_wrlock(globals.translate_profiles, name, rules_list, globals.profile_hash_rwlock); } } done: if (xml) { switch_xml_free(xml); } return status; }
switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){ VALUE_PAIR *send = NULL; uint32_t service = PW_STATUS_STOP; rc_handle *new_handle = NULL; switch_xml_t fields = NULL, conditions = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); if (GLOBAL_DEBUG ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting stop\n"); switch_core_session_execute_application(session, "info", NULL); } /* If there are conditions defined, and none of them pass, then skip this accounting */ if ((conditions = switch_xml_child(globals.acct_start_configs, "conditions")) != NULL && mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) { goto end; } if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_end handle for call: %s\n", switch_channel_get_variable(channel, "uuid")); goto end; } if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); goto end; } if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); goto end; } if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); goto end; } if (rc_acct(new_handle, 0, send) == OK_RC) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Stop success\n"); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Accounting Stop failed\n"); } end: if ( send ) { rc_avpair_free(send); send = NULL; } if ( new_handle) { rc_destroy(new_handle); new_handle = NULL; } return SWITCH_STATUS_SUCCESS; }
static switch_status_t config_logger(void) { char *cf = "console.conf"; switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if (log_hash) { switch_core_hash_destroy(&log_hash); } switch_core_hash_init(&log_hash, module_pool); if ((settings = switch_xml_child(cfg, "mappings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(var, val, 1); } for (param = switch_xml_child(settings, "map"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(var, val, 0); } } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "colorize") && switch_true(val)) { #ifdef WIN32 hStdout = GetStdHandle(STD_OUTPUT_HANDLE); if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) { wOldColorAttrs = csbiInfo.wAttributes; COLORIZE = 1; } #else COLORIZE = 1; #endif } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { hard_log_level = switch_log_str2level(val); } else if (!strcasecmp(var, "uuid") && switch_true(val)) { log_uuid = SWITCH_TRUE; } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
static switch_status_t do_config(void) { char *cf = "xml_rpc.conf"; switch_xml_t cfg, xml, settings, param; char *realm, *user, *pass, *default_domain; default_domain = realm = user = pass = NULL; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } globals.virtual_host = SWITCH_TRUE; if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!zstr(var) && !zstr(val)) { if (!strcasecmp(var, "auth-realm")) { realm = val; } else if (!strcasecmp(var, "auth-user")) { user = val; } else if (!strcasecmp(var, "auth-pass")) { pass = val; } else if (!strcasecmp(var, "http-port")) { globals.port = (uint16_t) atoi(val); } else if (!strcasecmp(var, "default-domain")) { default_domain = val; } else if (!strcasecmp(var, "virtual-host")) { globals.virtual_host = switch_true(val); } else if (!strcasecmp(var, "enable-websocket")) { globals.enable_websocket = switch_true(val); } } } } if (!globals.port) { globals.port = 8080; } if (realm) { set_global_realm(realm); if (user && pass) { set_global_user(user); set_global_pass(pass); } } if (default_domain) { set_global_default_domain(default_domain); } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switch_xml_t conditions) { switch_xml_t condition, param; char *channel_var = NULL; const char *channel_val = NULL; char *regex = NULL; char *anti = NULL; int all_matched = 1; int result = 0; if ( (condition = switch_xml_child(conditions, "condition")) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a condition under the conditions section\n"); return SWITCH_STATUS_FALSE; } for (; condition; condition = condition->next) { if ( (param = switch_xml_child(condition, "param")) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under this condition\n"); return SWITCH_STATUS_FALSE; } all_matched = 1; for (; param && all_matched; param = param->next) { channel_var = (char *) switch_xml_attr(param, "var"); regex = (char *) switch_xml_attr(param, "regex"); anti = (char *) switch_xml_attr(param, "anti"); if ( channel_var == NULL || regex == NULL ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition: %s %s\n", channel_var, regex); continue; } if ( ( channel_val = switch_channel_get_variable(channel, channel_var) ) == NULL ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition, no such channel variable: %s %s\n", channel_var, regex); continue; } result = ( switch_regex_match( channel_val, regex) != SWITCH_STATUS_SUCCESS); if (( anti == NULL && result ) || ( anti != NULL && !result ) ){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex); all_matched = 0; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n", anti, switch_channel_get_variable(channel, channel_var), regex); } } if ( all_matched ) { return SWITCH_STATUS_SUCCESS; } } return SWITCH_STATUS_FALSE; }
static switch_status_t load_config(void) { char *cf = "rednibblebill.conf"; switch_xml_t cfg, xml = NULL, param, settings; switch_status_t status = SWITCH_STATUS_SUCCESS; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); status = SWITCH_STATUS_SUCCESS; /* We don't fail because we can still write to a text file or buffer */ } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "redis_host")) { set_global_redis_host(val); } else if (!strcasecmp(var, "redis_port")) { globals.redis_port = atoi(val); } else if (!strcasecmp(var, "redis_timeout")) { globals.redis_timeout = atoi(val); } else if (!strcasecmp(var, "percall_action")) { set_global_percall_action(val); } else if (!strcasecmp(var, "percall_max_amt")) { globals.percall_max_amt = atof(val); } else if (!strcasecmp(var, "lowbal_action")) { set_global_lowbal_action(val); } else if (!strcasecmp(var, "lowbal_amt")) { globals.lowbal_amt = atof(val); } else if (!strcasecmp(var, "nobal_action")) { set_global_nobal_action(val); } else if (!strcasecmp(var, "nobal_amt")) { globals.nobal_amt = atof(val); } else if (!strcasecmp(var, "global_heartbeat")) { globals.global_heartbeat = atoi(val); } } } if (zstr(globals.percall_action)) { set_global_percall_action("hangup"); } if (zstr(globals.lowbal_action)) { set_global_lowbal_action("play ding"); } if (zstr(globals.nobal_action)) { set_global_nobal_action("hangup"); } if (xml) { switch_xml_free(xml); } return status; }
static switch_status_t load_profile(switch_xml_t xml) { switch_xml_t param, settings; char *name = (char *) switch_xml_attr_soft(xml, "name"); logfile_profile_t *new_profile; new_profile = switch_core_alloc(module_pool, sizeof(*new_profile)); memset(new_profile, 0, sizeof(*new_profile)); switch_core_hash_init(&(new_profile->log_hash)); new_profile->name = switch_core_strdup(module_pool, switch_str_nil(name)); new_profile->suffix = 1; new_profile->log_uuid = SWITCH_TRUE; if ((settings = switch_xml_child(xml, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "logfile")) { new_profile->logfile = strdup(val); } else if (!strcmp(var, "rollover")) { new_profile->roll_size = switch_atoui(val); } else if (!strcmp(var, "maximum-rotate")) { new_profile->max_rot = switch_atoui(val); if (new_profile->max_rot == 0) { new_profile->max_rot = MAX_ROT; } } else if (!strcmp(var, "uuid")) { new_profile->log_uuid = switch_true(val); } } } if ((settings = switch_xml_child(xml, "mappings"))) { for (param = switch_xml_child(settings, "map"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(new_profile, var, val); } } if (zstr(new_profile->logfile)) { char logfile[512]; switch_snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, "freeswitch.log"); new_profile->logfile = strdup(logfile); } if (mod_logfile_openlogfile(new_profile, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_GENERR; } switch_core_hash_insert_destructor(profile_hash, new_profile->name, (void *) new_profile, cleanup_profile); return SWITCH_STATUS_SUCCESS; }
static dir_profile_t *load_profile(const char *profile_name) { dir_profile_t *profile = NULL; switch_xml_t x_profiles, x_profile, cfg, xml = NULL; switch_event_t *event = NULL; if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); return profile; } if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { goto end; } if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) { switch_memory_pool_t *pool; int count; if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); goto end; } if (!(profile = switch_core_alloc(pool, sizeof(dir_profile_t)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); switch_core_destroy_memory_pool(&pool); goto end; } profile->pool = pool; profile_set_config(profile); /* Add the params to the event structure */ count = (int)switch_event_import_xml(switch_xml_child(x_profile, "param"), "name", "value", &event); if (switch_xml_config_parse_event(event, count, SWITCH_FALSE, profile->config) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to process configuration\n"); switch_core_destroy_memory_pool(&pool); goto end; } switch_thread_rwlock_create(&profile->rwlock, pool); profile->name = switch_core_strdup(pool, profile_name); switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); switch_core_hash_insert(globals.profile_hash, profile->name, profile); } end: switch_xml_free(xml); return profile; }
static switch_status_t config(void) { const char *cf = "mongo.conf"; switch_xml_t cfg, xml, settings, param; switch_status_t status = SWITCH_STATUS_SUCCESS; const char *conn_str = "127.0.0.1"; switch_size_t min_connections = 1, max_connections = 1; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_GENERR; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); int tmp; if (!strcmp(var, "host")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "'host' is deprecated. use 'connection-string'\n"); conn_str = val; } else if (!strcmp(var, "connection-string")) { conn_str = val; } else if (!strcmp(var, "min-connections")) { if ((tmp = atoi(val)) > 0) { min_connections = tmp; } } else if (!strcmp(var, "max-connections")) { if ((tmp = atoi(val)) > 0) { max_connections = tmp; } } else if (!strcmp(var, "map")) { globals.map = strdup(val); } else if (!strcmp(var, "reduce")) { globals.reduce = strdup(val); } else if (!strcmp(var, "finalize")) { globals.finalize = strdup(val); } } } if (mongo_connection_pool_create(&globals.conn_pool, min_connections, max_connections, conn_str) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Can't create connection pool\n"); status = SWITCH_STATUS_GENERR; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mongo connection pool created [%s %d/%d]\n", conn_str, (int)min_connections, (int)max_connections); } switch_xml_free(xml); return status; }
static switch_status_t load_config(void) { char *cf = "reference.conf"; switch_xml_t cfg, xml, settings, param; memset(&globals, 0, sizeof(globals)); switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "debug")) { globals.debug = atoi(val); } else if (!strcmp(var, "port")) { globals.port = atoi(val); } else if (!strcmp(var, "ip")) { set_global_ip(val); } else if (!strcmp(var, "codec-master")) { if (!strcasecmp(val, "us")) { switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS); } } else if (!strcmp(var, "dialplan")) { set_global_dialplan(val); } else if (!strcmp(var, "codec-prefs")) { set_global_codec_string(val); globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS); } else if (!strcmp(var, "codec-rates")) { set_global_codec_rates_string(val); globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS); } } } if (!globals.dialplan) { set_global_dialplan("default"); } if (!globals.port) { globals.port = 4569; } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; }
void populate_profile_menu_event(vmivr_profile_t *profile, vmivr_menu_profile_t *menu) { switch_xml_t cfg, xml, x_profiles, x_profile, x_keys, x_phrases, x_menus, x_menu; free_profile_menu_event(menu); if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); goto end; } if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { goto end; } if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile->name))) { if ((x_menus = switch_xml_child(x_profile, "menus"))) { if ((x_menu = switch_xml_find_child(x_menus, "menu", "name", menu->name))) { if ((x_keys = switch_xml_child(x_menu, "keys"))) { switch_event_import_xml(switch_xml_child(x_keys, "key"), "dtmf", "action", &menu->event_keys_dtmf); switch_event_import_xml(switch_xml_child(x_keys, "key"), "action", "dtmf", &menu->event_keys_action); switch_event_import_xml(switch_xml_child(x_keys, "key"), "action", "variable", &menu->event_keys_varname); } if ((x_phrases = switch_xml_child(x_menu, "phrases"))) { switch_event_import_xml(switch_xml_child(x_phrases, "phrase"), "name", "value", &menu->event_phrases); } } } } end: if (xml) switch_xml_free(xml); return; }
switch_status_t mod_xml_radius_new_handle(rc_handle **new_handle, switch_xml_t xml) { switch_xml_t server, param; *new_handle = rc_new(); if ( *new_handle == NULL ) { goto err; } *new_handle = rc_config_init(*new_handle); if ( *new_handle == NULL ) { goto err; } if (rc_add_config(*new_handle, "auth_order", "radius", "mod_radius_cdr.c", 0) != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n"); goto err; } if ((server = switch_xml_child(xml, "connection")) == NULL ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n"); goto err; } for (param = switch_xml_child(server, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if ( GLOBAL_DEBUG ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Attempting to add param '%s' with value '%s' \n", var, val); } if (strncmp(var, "dictionary", 10) == 0) { rc_read_dictionary(*new_handle, val); } else if (rc_add_config(*new_handle, var, val, "mod_xml_radius", 0) != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val); goto err; } } return SWITCH_STATUS_SUCCESS; err: if ( *new_handle ) { rc_destroy( *new_handle ); *new_handle = NULL; } return SWITCH_STATUS_GENERR; }
static switch_status_t do_config(switch_bool_t reload) { /* Load up blacklists */ switch_xml_t xml, cfg, lists, list; switch_hash_index_t *hi = NULL; if (!(xml = switch_xml_open_cfg("mod_blacklist.conf", &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load configuration section\n"); return SWITCH_STATUS_FALSE; } switch_mutex_lock(globals.lists_mutex); /* Destroy any active lists */ while ((hi = switch_core_hash_first_iter( globals.lists, hi))) { const void *key; void *val; switch_core_hash_this(hi, &key, NULL, &val); blacklist_free((blacklist_t*)val); switch_core_hash_delete(globals.lists, (const char*)key); } if ((lists = switch_xml_child(cfg, "lists"))) { for (list = switch_xml_child(lists, "list"); list; list = list->next) { const char *name = switch_xml_attr_soft(list, "name"); const char *filename = switch_xml_attr_soft(list, "filename"); if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "list has no name\n"); continue; } if (zstr(filename)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "list [%s] has no filename\n", name); continue; } load_list(name, filename); } } switch_mutex_unlock(globals.lists_mutex); if (xml) { switch_xml_free(xml); xml = NULL; } return SWITCH_STATUS_SUCCESS; }
static int launch_streams(const char *name) { switch_xml_t cfg, xml, directory; int x = 0; if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); return 0; } if (zstr(name)) { for (directory = switch_xml_child(cfg, "directory"); directory; directory = directory->next) { char *name = (char *) switch_xml_attr(directory, "name"); char *path = (char *) switch_xml_attr(directory, "path"); launch_thread(name, path, directory); x++; } } else if ((directory = switch_xml_find_child(cfg, "directory", "name", name))) { char *path = (char *) switch_xml_attr(directory, "path"); launch_thread(name, path, directory); x++; } switch_xml_free(xml); return x; }
static switch_status_t load_config(void) { char *cf = "syslog.conf"; switch_xml_t cfg, xml, settings, param; /* default log level */ log_level = SWITCH_LOG_WARNING; /* default facility */ globals.facility = DEFAULT_FACILITY; globals.log_uuid = SWITCH_TRUE; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); } else { if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "ident")) { set_global_ident(val); } else if (!strcmp(var, "format")) { set_global_format(val); } else if (!strcmp(var, "facility")) { set_global_facility(val); } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { log_level = switch_log_str2level(val); if (log_level == SWITCH_LOG_INVALID) { log_level = SWITCH_LOG_WARNING; } } else if (!strcasecmp(var, "uuid")) { globals.log_uuid = switch_true(val); } } } switch_xml_free(xml); } if (zstr(globals.ident)) { set_global_ident(DEFAULT_IDENT); } if (zstr(globals.format)) { set_global_format(DEFAULT_FORMAT); } return 0; }
SWITCH_DECLARE(void) switch_nat_republish(void) { switch_xml_t natxml = NULL; switch_xml_t row = NULL; switch_xml_t child = NULL; switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Refreshing nat maps\n"); switch_api_execute("show", "nat_map as xml", NULL, &stream); if (!(natxml = switch_xml_parse_str_dup(stream.data))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", (char *) stream.data); switch_safe_free(stream.data); return; } /* iterate the xml and publish the mappings */ row = switch_xml_find_child(natxml, "row", "row_id", "1"); while (row != NULL) { char *sport = NULL; char *sproto = NULL; switch_port_t port; switch_nat_ip_proto_t proto; if ((child = switch_xml_child(row, "port"))) { sport = child->txt; } if ((child = switch_xml_child(row, "proto_num"))) { sproto = child->txt; } if (sport && sproto) { port = (switch_port_t) (atoi(sport)); proto = (switch_nat_ip_proto_t) (atoi(sproto)); switch_nat_add_mapping_internal(port, proto, NULL, SWITCH_FALSE, SWITCH_FALSE); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse port/proto info: XML: %s\n", (char *) stream.data); } row = switch_xml_next(row); } switch_safe_free(stream.data); switch_xml_free(natxml); }
static void do_config(switch_bool_t reload) { switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL; if ((xml = switch_xml_open_cfg("hash.conf", &cfg, NULL))) { if ((x_lists = switch_xml_child(cfg, "remotes"))) { for (x_list = switch_xml_child(x_lists, "remote"); x_list; x_list = x_list->next) { const char *name = switch_xml_attr(x_list, "name"); const char *host = switch_xml_attr(x_list, "host"); const char *szport = switch_xml_attr(x_list, "port"); const char *username = switch_xml_attr(x_list, "username"); const char *password = switch_xml_attr(x_list, "password"); const char *szinterval = switch_xml_attr(x_list, "interval"); uint16_t port = 0; int interval = 0; limit_remote_t *remote; switch_threadattr_t *thd_attr = NULL; if (reload) { switch_thread_rwlock_rdlock(globals.remote_hash_rwlock); if (switch_core_hash_find(globals.remote_hash, name)) { switch_thread_rwlock_unlock(globals.remote_hash_rwlock); continue; } switch_thread_rwlock_unlock(globals.remote_hash_rwlock); } if (!zstr(szport)) { port = (uint16_t)atoi(szport); } if (!zstr(szinterval)) { interval = atoi(szinterval); } remote = limit_remote_create(name, host, port, username, password, interval); remote->state = REMOTE_DOWN; switch_threadattr_create(&thd_attr, remote->pool); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&remote->thread, thd_attr, limit_remote_thread, remote, remote->pool); } } switch_xml_free(xml); } }
SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_module_settings(const char *file, switch_bool_t reload, switch_xml_config_item_t *instructions) { switch_xml_t cfg, xml, settings; switch_status_t status = SWITCH_STATUS_SUCCESS; if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file); return SWITCH_STATUS_FALSE; } if ((settings = switch_xml_child(cfg, "settings"))) { status = switch_xml_config_parse(switch_xml_child(settings, "param"), reload, instructions); } switch_xml_free(xml); return status; }
void switch_load_timezones(switch_bool_t reload) { switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL; unsigned total = 0; if (TIMEZONES_LIST.hash) { switch_core_hash_destroy(&TIMEZONES_LIST.hash); } if (TIMEZONES_LIST.pool) { switch_core_destroy_memory_pool(&TIMEZONES_LIST.pool); } memset(&TIMEZONES_LIST, 0, sizeof(TIMEZONES_LIST)); switch_core_new_memory_pool(&TIMEZONES_LIST.pool); switch_core_hash_init(&TIMEZONES_LIST.hash, TIMEZONES_LIST.pool); if ((xml = switch_xml_open_cfg("timezones.conf", &cfg, NULL))) { if ((x_lists = switch_xml_child(cfg, "timezones"))) { for (x_list = switch_xml_child(x_lists, "zone"); x_list; x_list = x_list->next) { const char *name = switch_xml_attr(x_list, "name"); const char *value = switch_xml_attr(x_list, "value"); if (zstr(name)) { continue; } if (zstr(value)) { continue; } switch_core_hash_insert(TIMEZONES_LIST.hash, name, switch_core_strdup(TIMEZONES_LIST.pool, value)); total++; } } switch_xml_free(xml); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Timezone %sloaded %d definitions\n", reload ? "re" : "", total); }
static switch_status_t opus_load_config(switch_bool_t reload) { char *cf = "opus.conf"; switch_xml_t cfg, xml = NULL, param, settings; switch_status_t status = SWITCH_STATUS_SUCCESS; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf); return status; } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *key = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(key, "use-vbr") && !zstr(val)) { opus_prefs.use_vbr = atoi(val); } else if (!strcasecmp(key, "complexity")) { opus_prefs.complexity = atoi(val); } else if (!strcasecmp(key, "maxaveragebitrate")) { opus_prefs.maxaveragebitrate = atoi(val); if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) { opus_prefs.maxaveragebitrate = 0; /* values outside the range between 6000 and 510000 SHOULD be ignored */ } } else if (!strcasecmp(key, "maxplaybackrate")) { opus_prefs.maxplaybackrate = atoi(val); if ( opus_prefs.maxplaybackrate != 8000 && opus_prefs.maxplaybackrate != 12000 && opus_prefs.maxplaybackrate != 16000 && opus_prefs.maxplaybackrate != 24000 && opus_prefs.maxplaybackrate != 48000) { opus_prefs.maxplaybackrate = 0; /* value not supported */ } } } } if (xml) { switch_xml_free(xml); } return status; }