limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t port, const char *username, const char *password, int interval) { limit_remote_t *r; switch_memory_pool_t *pool; switch_thread_rwlock_rdlock(globals.remote_hash_rwlock); if (switch_core_hash_find(globals.remote_hash, name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Already have a remote instance named %s\n", name); switch_thread_rwlock_unlock(globals.remote_hash_rwlock); return NULL; } switch_thread_rwlock_unlock(globals.remote_hash_rwlock); if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { return NULL; } r = switch_core_alloc(pool, sizeof(limit_remote_t)); r->pool = pool; r->name = switch_core_strdup(r->pool, name); r->host = switch_core_strdup(r->pool, host); r->port = port; r->username = switch_core_strdup(r->pool, username); r->password = switch_core_strdup(r->pool, password); r->interval = interval; switch_thread_rwlock_create(&r->rwlock, pool); switch_core_hash_init(&r->index, pool); switch_thread_rwlock_rdlock(globals.remote_hash_rwlock); switch_core_hash_insert(globals.remote_hash, name, r); switch_thread_rwlock_unlock(globals.remote_hash_rwlock); return r; }
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 void do_load(void) { switch_mutex_lock(MUTEX); switch_core_hash_init(&globals.translate_profiles); switch_thread_rwlock_create(&globals.profile_hash_rwlock, globals.pool); load_config(); switch_mutex_unlock(MUTEX); }
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; }
/** * Load input CPA * @param module_interface * @param pool memory pool * @param config_file * @return SWITCH_STATUS_SUCCESS if successfully loaded */ switch_status_t rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "cpa", "set:"RAYO_EXT_NS":stop", stop_cpa_component); switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CUSTOM, "rayo::cpa", on_rayo_cpa_detector_event, NULL); switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE, NULL, on_channel_hangup_complete_event, NULL); globals.pool = pool; switch_core_hash_init(&globals.subscribers); switch_mutex_init(&globals.subscribers_mutex, SWITCH_MUTEX_NESTED, pool); return rayo_cpa_detector_load(module_interface, pool, config_file); }
static valet_lot_t *valet_find_lot(const char *name) { valet_lot_t *lot; switch_mutex_lock(globals.mutex); if (!(lot = switch_core_hash_find(globals.hash, name))) { switch_zmalloc(lot, sizeof(*lot)); switch_mutex_init(&lot->mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_core_hash_init(&lot->hash, NULL); switch_core_hash_insert(globals.hash, name, lot); } switch_mutex_unlock(globals.mutex); return lot; }
/** * Initialize output component * @param module_interface * @param pool memory pool to allocate from * @param config_file to use * @return SWITCH_STATUS_SUCCESS if successful */ switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) { switch_api_interface_t *api_interface; switch_file_interface_t *file_interface; rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_OUTPUT_NS":output", start_call_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_EXT_NS":stop", stop_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":pause", pause_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":resume", resume_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":speed-up", speed_up_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":speed-down", speed_down_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":volume-up", volume_up_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":volume-down", volume_down_output_component); rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":seek", seek_output_component); rayo_actor_command_handler_add(RAT_MIXER, "", "set:"RAYO_OUTPUT_NS":output", start_mixer_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_EXT_NS":stop", stop_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":pause", pause_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":resume", resume_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":speed-up", speed_up_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":speed-down", speed_down_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":volume-up", volume_up_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":volume-down", volume_down_output_component); rayo_actor_command_handler_add(RAT_MIXER_COMPONENT, "output", "set:"RAYO_OUTPUT_NS":seek", seek_output_component); file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); file_interface->interface_name = "mod_rayo"; file_interface->extens = rayo_supported_formats; file_interface->file_open = rayo_file_open; file_interface->file_close = rayo_file_close; file_interface->file_read = rayo_file_read; file_interface->file_seek = rayo_file_seek; switch_mutex_init(&fileman_globals.mutex, SWITCH_MUTEX_NESTED, pool); switch_core_hash_init(&fileman_globals.hash); file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); file_interface->interface_name = "mod_rayo"; file_interface->extens = fileman_supported_formats; file_interface->file_open = fileman_file_open; file_interface->file_close = fileman_file_close; file_interface->file_write = fileman_file_write; file_interface->file_read = fileman_file_read; file_interface->file_seek = fileman_file_seek; SWITCH_ADD_API(api_interface, "fileman", "Manage file audio", fileman_api, FILEMAN_SYNTAX); return SWITCH_STATUS_SUCCESS; }
blacklist_t *blacklist_create(const char *name) { switch_memory_pool_t *pool = NULL; blacklist_t *bl = NULL; switch_core_new_memory_pool(&pool); bl = switch_core_alloc(pool, sizeof(*bl)); switch_assert(bl); bl->pool = pool; switch_core_hash_init(&bl->list); switch_mutex_init(&bl->list_mutex, SWITCH_MUTEX_NESTED, pool); return bl; }
/** * Request signals */ static void subscribe(const char *uuid, const char *signal_type, const char *jid) { char *key = switch_mprintf("%s:%s", uuid, signal_type); switch_mutex_lock(globals.subscribers_mutex); { switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Subscribe %s => %s\n", signal_type, jid); if (!signal_subscribers) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Create %s subscriber hash\n", signal_type); switch_core_hash_init(&signal_subscribers); switch_core_hash_insert(globals.subscribers, key, signal_subscribers); } switch_core_hash_insert(signal_subscribers, jid, "1"); } switch_mutex_unlock(globals.subscribers_mutex); switch_safe_free(key); }
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); }
/** * Add a definition for a tag * @param tag the name * @param attribs_fn the function to handle the tag attributes * @param cdata_fn the function to handler the tag CDATA * @param children_tags comma-separated list of valid child tag names * @return the definition */ static struct tag_def *add_tag_def(const char *tag, tag_attribs_fn attribs_fn, tag_cdata_fn cdata_fn, const char *children_tags) { struct tag_def *def = switch_core_alloc(globals.pool, sizeof(*def)); switch_core_hash_init(&def->children_tags, globals.pool); if (!zstr(children_tags)) { char *children_tags_dup = switch_core_strdup(globals.pool, children_tags); char *tags[32] = { 0 }; int tag_count = switch_separate_string(children_tags_dup, ',', tags, sizeof(tags) / sizeof(tags[0])); if (tag_count) { int i; for (i = 0; i < tag_count; i++) { switch_core_hash_insert(def->children_tags, tags[i], tags[i]); } } } def->attribs_fn = attribs_fn; def->cdata_fn = cdata_fn; def->is_root = SWITCH_FALSE; switch_core_hash_insert(globals.tag_defs, tag, def); return def; }
/** * Initialize NLSML parser. This function is not thread safe. */ int nlsml_init(void) { if (globals.init) { return 1; } globals.init = SWITCH_TRUE; switch_core_new_memory_pool(&globals.pool); switch_core_hash_init(&globals.tag_defs, globals.pool); add_root_tag_def("result", process_attribs_ignore, process_cdata_ignore, "interpretation"); add_tag_def("interpretation", process_attribs_ignore, process_cdata_ignore, "input,model,xf:model,instance,xf:instance"); add_tag_def("input", process_attribs_ignore, process_cdata_match, "input,nomatch,noinput"); add_tag_def("noinput", process_noinput, process_cdata_bad, ""); add_tag_def("nomatch", process_nomatch, process_cdata_ignore, ""); add_tag_def("model", process_attribs_ignore, process_cdata_ignore, "ANY"); add_tag_def("xf:model", process_attribs_ignore, process_cdata_ignore, "ANY"); add_tag_def("instance", process_attribs_ignore, process_cdata_ignore, "ANY"); add_tag_def("xf:instance", process_attribs_ignore, process_cdata_ignore, "ANY"); add_tag_def("ANY", process_attribs_ignore, process_cdata_ignore, "ANY"); return 1; }
static switch_status_t load_config(switch_memory_pool_t *pool) { char *cf = "cdr_sqlite.conf"; switch_xml_t cfg, xml, settings, param; switch_cache_db_handle_t *dbh = NULL; char *select_sql = NULL, *create_sql = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.template_hash, pool); globals.pool = pool; switch_core_hash_insert(globals.template_hash, "default", default_template); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n"); globals.legs = CDR_LEG_A; if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { 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 = switch_true(val); } else if (!strcasecmp(var, "db-name")) { globals.db_name = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "db-table")) { globals.db_table = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "legs")) { globals.legs = 0; if (strchr(val, 'a')) { globals.legs |= CDR_LEG_A; } if (strchr(val, 'b')) { globals.legs |= CDR_LEG_B; } } else if (!strcasecmp(var, "default-template")) { globals.default_template = switch_core_strdup(pool, val); } } } if ((settings = switch_xml_child(cfg, "templates"))) { for (param = switch_xml_child(settings, "template"); param; param = param->next) { char *var = (char *) switch_xml_attr(param, "name"); if (var) { char *tpl; tpl = switch_core_strdup(pool, param->txt); switch_core_hash_insert(globals.template_hash, var, tpl); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s.\n", var); } } } switch_xml_free(xml); } if (zstr(globals.db_name)) { globals.db_name = switch_core_strdup(pool, "cdr"); } if (zstr(globals.db_table)) { globals.db_table = switch_core_strdup(pool, "cdr"); } if (zstr(globals.default_template)) { globals.default_template = switch_core_strdup(pool, "default"); } dbh = cdr_get_db_handle(); if (dbh) { select_sql = switch_mprintf("SELECT * FROM %s LIMIT 1", globals.db_table); assert(select_sql); create_sql = switch_mprintf(default_create_sql, globals.db_table); assert(create_sql); /* Check if table exists (try SELECT FROM ...) and create table if query fails */ switch_cache_db_test_reactive(dbh, select_sql, NULL, create_sql); switch_safe_free(select_sql); switch_safe_free(create_sql); switch_cache_db_release_db_handle(&dbh); } return status; }
static void event_handler(switch_event_t *event) { uint8_t send = 0; if (globals.running != 1) { return; } if (event->subclass_name && (!strcmp(event->subclass_name, MULTICAST_EVENT) || !strcmp(event->subclass_name, MULTICAST_PEERUP) || !strcmp(event->subclass_name, MULTICAST_PEERDOWN))) { char *event_name, *sender; if ((event_name = switch_event_get_header(event, "orig-event-name")) && !strcasecmp(event_name, "HEARTBEAT") && (sender = switch_event_get_header(event, "orig-multicast-sender"))) { struct peer_status *p; time_t now = switch_epoch_time_now(NULL); if (!(p = switch_core_hash_find(globals.peer_hash, sender))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Host %s not already in hash\n", sender); p = switch_core_alloc(module_pool, sizeof(struct peer_status)); p->active = SWITCH_FALSE; p->lastseen = 0; /*} else { */ /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Host %s last seen %d seconds ago\n", sender, now - p->lastseen); */ } if (!p->active) { switch_event_t *local_event; if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_PEERUP) == SWITCH_STATUS_SUCCESS) { char lastseen[21]; switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Peer", sender); if (p->lastseen) { switch_snprintf(lastseen, sizeof(lastseen), "%d", (int) p->lastseen); } else { switch_snprintf(lastseen, sizeof(lastseen), "%s", "Never"); } switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Lastseen", lastseen); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Peer %s has come up; last seen: %s\n", sender, lastseen); switch_event_fire(&local_event); } } p->active = SWITCH_TRUE; p->lastseen = now; switch_core_hash_insert(globals.peer_hash, sender, p); } /* ignore our own events to avoid ping pong */ return; } if (event->event_id == SWITCH_EVENT_RELOADXML) { switch_mutex_lock(globals.mutex); switch_core_hash_destroy(&globals.event_hash); globals.event_hash = NULL; if (globals.psk) { switch_safe_free(globals.psk); globals.psk = NULL; } switch_core_hash_init(&globals.event_hash, module_pool); memset(globals.event_list, 0, SWITCH_EVENT_ALL + 1); if (load_config() != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to reload config file\n"); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Event Multicast Reloaded\n"); } switch_mutex_unlock(globals.mutex); } if (event->event_id == SWITCH_EVENT_HEARTBEAT) { switch_hash_index_t *cur; switch_ssize_t keylen; const void *key; void *value; time_t now = switch_epoch_time_now(NULL); struct peer_status *last; char *host; for (cur = switch_hash_first(NULL, globals.peer_hash); cur; cur = switch_hash_next(cur)) { switch_hash_this(cur, &key, &keylen, &value); host = (char *) key; last = (struct peer_status *) value; if (last->active && (now - (last->lastseen)) > 60) { switch_event_t *local_event; last->active = SWITCH_FALSE; if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_PEERDOWN) == SWITCH_STATUS_SUCCESS) { char lastseen[21]; switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Peer", host); switch_snprintf(lastseen, sizeof(lastseen), "%d", (int) last->lastseen); switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Lastseen", lastseen); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Peer %s has gone down; last seen: %s\n", host, lastseen); switch_event_fire(&local_event); } } } } switch_mutex_lock(globals.mutex); if (globals.event_list[(uint8_t) SWITCH_EVENT_ALL]) { send = 1; } else if ((globals.event_list[(uint8_t) event->event_id])) { if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass_name && switch_core_hash_find(globals.event_hash, event->subclass_name))) { send = 1; } } switch_mutex_unlock(globals.mutex); if (send) { char *packet; switch (event->event_id) { case SWITCH_EVENT_LOG: return; default: switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", switch_core_get_switchname()); if (switch_event_serialize(event, &packet, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { size_t len; char *buf; #ifdef HAVE_OPENSSL int outlen, tmplen; EVP_CIPHER_CTX ctx; char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; switch_uuid_t uuid; switch_uuid_get(&uuid); switch_uuid_format(uuid_str, &uuid); len = strlen(packet) + SWITCH_UUID_FORMATTED_LENGTH + EVP_MAX_IV_LENGTH + strlen((char *) MAGIC); #else len = strlen(packet) + strlen((char *) MAGIC); #endif buf = malloc(len + 1); memset(buf, 0, len + 1); switch_assert(buf); #ifdef HAVE_OPENSSL if (globals.psk) { switch_copy_string(buf, uuid_str, SWITCH_UUID_FORMATTED_LENGTH); EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit(&ctx, EVP_bf_cbc(), NULL, NULL); EVP_CIPHER_CTX_set_key_length(&ctx, strlen(globals.psk)); EVP_EncryptInit(&ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str); EVP_EncryptUpdate(&ctx, (unsigned char *) buf + SWITCH_UUID_FORMATTED_LENGTH, &outlen, (unsigned char *) packet, (int) strlen(packet)); EVP_EncryptUpdate(&ctx, (unsigned char *) buf + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen, (unsigned char *) MAGIC, (int) strlen((char *) MAGIC)); outlen += tmplen; EVP_EncryptFinal(&ctx, (unsigned char *) buf + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen); outlen += tmplen; len = (size_t) outlen + SWITCH_UUID_FORMATTED_LENGTH; *(buf + SWITCH_UUID_FORMATTED_LENGTH + outlen) = '\0'; } else { #endif switch_copy_string(buf, packet, len); switch_copy_string(buf + strlen(packet), (char *) MAGIC, strlen((char *) MAGIC) + 1); #ifdef HAVE_OPENSSL } #endif switch_socket_sendto(globals.udp_socket, globals.addr, 0, buf, &len); switch_safe_free(packet); switch_safe_free(buf); } break; } } return; }
static switch_status_t config(void) { char *cf = "kazoo.conf"; switch_xml_t cfg, xml, child, param; globals.send_all_headers = globals.send_all_private_headers = 0; globals.connection_timeout = 500; globals.receive_timeout = 200; globals.receive_msg_preallocate = 2000; globals.event_stream_preallocate = 4000; globals.send_msg_batch = 10; globals.event_stream_framing = 2; globals.port = 0; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open configuration file %s\n", cf); return SWITCH_STATUS_FALSE; } else { if ((child = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(child, "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, "listen-ip")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set bind ip address: %s\n", val); set_pref_ip(val); } else if (!strcmp(var, "listen-port")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set bind port: %s\n", val); globals.port = atoi(val); } else if (!strcmp(var, "cookie")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set cookie: %s\n", val); set_pref_ei_cookie(val); } else if (!strcmp(var, "cookie-file")) { if (read_cookie_from_file(val) == 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to read cookie from %s\n", val); } } else if (!strcmp(var, "nodename")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set node name: %s\n", val); set_pref_ei_nodename(val); } else if (!strcmp(var, "shortname")) { globals.ei_shortname = switch_true(val); } else if (!strcmp(var, "kazoo-var-prefix")) { set_pref_kazoo_var_prefix(val); } else if (!strcmp(var, "compat-rel")) { if (atoi(val) >= 7) globals.ei_compat_rel = atoi(val); else switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid compatibility release '%s' specified\n", val); } else if (!strcmp(var, "nat-map")) { globals.nat_map = switch_true(val); } else if (!strcmp(var, "send-all-headers")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-all-headers: %s\n", val); globals.send_all_headers = switch_true(val); } else if (!strcmp(var, "send-all-private-headers")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-all-private-headers: %s\n", val); globals.send_all_private_headers = switch_true(val); } else if (!strcmp(var, "connection-timeout")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set connection-timeout: %s\n", val); globals.connection_timeout = atoi(val); } else if (!strcmp(var, "receive-timeout")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set receive-timeout: %s\n", val); globals.receive_timeout = atoi(val); } else if (!strcmp(var, "receive-msg-preallocate")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set receive-msg-preallocate: %s\n", val); globals.receive_msg_preallocate = atoi(val); } else if (!strcmp(var, "event-stream-preallocate")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set event-stream-preallocate: %s\n", val); globals.event_stream_preallocate = atoi(val); } else if (!strcmp(var, "send-msg-batch-size")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-msg-batch-size: %s\n", val); globals.send_msg_batch = atoi(val); } else if (!strcmp(var, "event-stream-framing")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set event-stream-framing: %s\n", val); globals.event_stream_framing = atoi(val); } } } if ((child = switch_xml_child(cfg, "event-filter"))) { switch_hash_t *filter; switch_core_hash_init(&filter); for (param = switch_xml_child(child, "header"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); switch_core_hash_insert(filter, var, "1"); } globals.event_filter = filter; } switch_xml_free(xml); } if (globals.receive_msg_preallocate < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid receive message preallocate value, disabled\n"); globals.receive_msg_preallocate = 0; } if (globals.event_stream_preallocate < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid event stream preallocate value, disabled\n"); globals.event_stream_preallocate = 0; } if (globals.send_msg_batch < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid send message batch size, reverting to default\n"); globals.send_msg_batch = 10; } if (!globals.event_filter) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Event filter not found in configuration, using default\n"); globals.event_filter = create_default_filter(); } if (globals.event_stream_framing < 1 || globals.event_stream_framing > 4) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid event stream framing value, using default\n"); globals.event_stream_framing = 2; } if (zstr(globals.kazoo_var_prefix)) { set_pref_kazoo_var_prefix("variable_ecallmgr*"); globals.var_prefix_length = 17; //ignore the * } else { /* we could use the global pool but then we would have to conditionally * free the pointer if it was not drawn from the XML */ char *buf; int size = switch_snprintf(NULL, 0, "variable_%s*", globals.kazoo_var_prefix) + 1; switch_malloc(buf, size); switch_snprintf(buf, size, "variable_%s*", globals.kazoo_var_prefix); switch_safe_free(globals.kazoo_var_prefix); globals.kazoo_var_prefix = buf; globals.var_prefix_length = size - 2; //ignore the * } if (!globals.num_worker_threads) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Number of worker threads not found in configuration, using default\n"); globals.num_worker_threads = 10; } if (zstr(globals.ip)) { set_pref_ip("0.0.0.0"); } if (zstr(globals.ei_cookie)) { int res; char *home_dir = getenv("HOME"); char path_buf[1024]; if (!zstr(home_dir)) { /* $HOME/.erlang.cookie */ switch_snprintf(path_buf, sizeof (path_buf), "%s%s%s", home_dir, SWITCH_PATH_SEPARATOR, ".erlang.cookie"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for cookie at path: %s\n", path_buf); res = read_cookie_from_file(path_buf); if (res) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No cookie or valid cookie file specified, using default cookie\n"); set_pref_ei_cookie("ClueCon"); } } } if (!globals.ei_nodename) { set_pref_ei_nodename("freeswitch"); } if (!globals.nat_map) { globals.nat_map = 0; } return SWITCH_STATUS_SUCCESS; }
static switch_status_t do_config(void) { char *cf = "xml_scgi.conf"; switch_xml_t cfg, xml, bindings_tag, binding_tag, param; xml_binding_t *binding = NULL; int x = 0; int need_vars_map = 0; switch_hash_t *vars_map = 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 (!(bindings_tag = switch_xml_child(cfg, "bindings"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!\n"); goto done; } for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) { char *bname = (char *) switch_xml_attr_soft(binding_tag, "name"); char *host = "127.0.0.1"; char *port = "8080"; char *bind_mask = NULL; int timeout = 0; char *server = NULL; hash_node_t *hash_node; need_vars_map = 0; vars_map = NULL; for (param = switch_xml_child(binding_tag, "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, "host")) { bind_mask = (char *) switch_xml_attr_soft(param, "bindings"); if (val) { host = val; } } else if (!strcasecmp(var, "port")) { port = val; } else if (!strcasecmp(var, "timeout")) { int tmp = atoi(val); if (tmp >= 0) { timeout = tmp; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!\n"); } } else if (!strcasecmp(var, "enable-post-var")) { if (!vars_map && need_vars_map == 0) { if (switch_core_hash_init(&vars_map, globals.pool) != SWITCH_STATUS_SUCCESS) { need_vars_map = -1; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't init params hash!\n"); continue; } need_vars_map = 1; } if (vars_map && val) { if (switch_core_hash_insert(vars_map, val, ENABLE_PARAM_VALUE) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't add %s to params hash!\n", val); } } } else if (!strcasecmp(var, "server")) { server = val; } } if (!host) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Binding has no host!\n"); if (vars_map) { switch_core_hash_destroy(&vars_map); } continue; } if (!(binding = switch_core_alloc(globals.pool, sizeof(*binding)))) { if (vars_map) { switch_core_hash_destroy(&vars_map); } goto done; } memset(binding, 0, sizeof(*binding)); binding->timeout = timeout; binding->host = switch_core_strdup(globals.pool, host); binding->port = atoi(port); binding->vars_map = vars_map; binding->uri = switch_mprintf("/%s", bname); binding->url = switch_mprintf("scgi://%s:%s/%s", host, port, bname); if (server) { binding->server = switch_core_strdup(globals.pool, server); } if (bind_mask) { binding->bindings = switch_core_strdup(globals.pool, bind_mask); } if (vars_map) { switch_zmalloc(hash_node, sizeof(hash_node_t)); hash_node->hash = vars_map; hash_node->next = NULL; if (!globals.hash_root) { globals.hash_root = hash_node; globals.hash_tail = globals.hash_root; } else { globals.hash_tail->next = hash_node; globals.hash_tail = globals.hash_tail->next; } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n", zstr(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all"); switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding); if (binding->server) { launch_monitor_thread(binding); } binding->next = globals.bindings; globals.bindings = binding; x++; binding = NULL; } done: switch_xml_free(xml); return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; }
static switch_status_t load_config(switch_memory_pool_t *pool) { char *cf = "cdr_csv.conf"; switch_xml_t cfg, xml, settings, param; switch_status_t status = SWITCH_STATUS_SUCCESS; memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.fd_hash, pool); switch_core_hash_init(&globals.template_hash, pool); globals.pool = pool; switch_core_hash_insert(globals.template_hash, "default", default_template); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n"); globals.legs = CDR_LEG_A; if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { 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 = switch_true(val); } else if (!strcasecmp(var, "legs")) { globals.legs = 0; if (strchr(val, 'a')) { globals.legs |= CDR_LEG_A; } if (strchr(val, 'b')) { globals.legs |= CDR_LEG_B; } } else if (!strcasecmp(var, "log-base")) { globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", val, SWITCH_PATH_SEPARATOR); } else if (!strcasecmp(var, "rotate-on-hup")) { globals.rotate = switch_true(val); } else if (!strcasecmp(var, "default-template")) { globals.default_template = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "master-file-only")) { globals.masterfileonly = switch_true(val); } } } if ((settings = switch_xml_child(cfg, "templates"))) { for (param = switch_xml_child(settings, "template"); param; param = param->next) { char *var = (char *) switch_xml_attr(param, "name"); if (var) { char *tpl; size_t len = strlen(param->txt) + 2; if (end_of(param->txt) != '\n') { tpl = switch_core_alloc(pool, len); switch_snprintf(tpl, len, "%s\n", param->txt); } else { tpl = switch_core_strdup(pool, param->txt); } switch_core_hash_insert(globals.template_hash, var, tpl); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s.\n", var); } } } switch_xml_free(xml); } if (zstr(globals.default_template)) { globals.default_template = switch_core_strdup(pool, "default"); } if (!globals.log_dir) { globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR); } return status; }
static switch_status_t load_config(switch_memory_pool_t *pool) { switch_status_t status = SWITCH_STATUS_SUCCESS; char *cf = "cdr_pg_csv.conf", *ptr; switch_xml_t cfg, xml, schema, field; const char *attr; int num_fields = 0; switch_size_t len = 0; cdr_field_t *cdr_field; if (globals.db_online) { PQfinish(globals.db_connection); switch_mutex_destroy(globals.db_mutex); globals.db_online = 0; } memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.fd_hash, pool); switch_mutex_init(&globals.db_mutex, SWITCH_MUTEX_NESTED, pool); globals.pool = pool; if (switch_xml_config_parse_module_settings(cf, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; } if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { if ((schema = switch_xml_child(cfg, "schema"))) { /* Count fields in schema so we can calculate required buffer size */ for (field = switch_xml_child(schema, "field"); field; field = field->next) { if (switch_xml_attr(field, "var")) { num_fields++; } } globals.db_schema = switch_core_alloc(pool, (num_fields + 1) * sizeof(cdr_field_t)); cdr_field = globals.db_schema->fields; for (field = switch_xml_child(schema, "field"); field; field = field->next) { if ((attr = switch_xml_attr(field, "var"))) { cdr_field->var_name = switch_core_strdup(pool, attr); /* Assume SQL column name is the same as FreeSWITCH channel var name, unless specified otherwise */ if ((attr = switch_xml_attr(field, "column"))) { cdr_field->col_name = switch_core_strdup(pool, attr); } else { cdr_field->col_name = switch_core_strdup(pool, cdr_field->var_name); } /* Assume all fields should be quoted (treated as strings), unless specified otherwise */ if ((attr = switch_xml_attr(field, "quote")) && !strncmp(attr, "false", 5)) { cdr_field->quote = SWITCH_FALSE; } else { cdr_field->quote = SWITCH_TRUE; } /* Assume all fields allow SQL nulls, unless specified otherwise */ if ((attr = switch_xml_attr(field, "not-null")) && !strncmp(attr, "true", 4)) { cdr_field->not_null = SWITCH_TRUE; } else { cdr_field->not_null = SWITCH_FALSE; } len += strlen(cdr_field->col_name) + 1; cdr_field++; } } cdr_field->var_name = 0; globals.db_schema->columns = switch_core_alloc(pool, len); ptr = globals.db_schema->columns; for (cdr_field = globals.db_schema->fields; cdr_field->col_name; cdr_field++) { len = strlen(cdr_field->col_name); memcpy(ptr, cdr_field->col_name, len); ptr += len; *ptr = ','; ptr++; } *--ptr = '\0'; } switch_xml_free(xml); } return status; }
static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf) { char atom[MAXATOMLEN]; switch_status_t ret = SWITCH_STATUS_SUCCESS; if (ei_decode_atom(buf->buff, &buf->index, atom)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); } else if (!strncmp(atom, "nolog", MAXATOMLEN)) { if (switch_test_flag(listener, LFLAG_LOG)) { void *pop; /*purge the log queue */ while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS); switch_clear_flag_locked(listener, LFLAG_LOG); } ei_x_encode_atom(rbuf, "ok"); } else if (!strncmp(atom, "register_log_handler", MAXATOMLEN)) { ei_link(listener, ei_self(listener->ec), &msg->from); listener->log_process.type = ERLANG_PID; memcpy(&listener->log_process.pid, &msg->from, sizeof(erlang_pid)); listener->level = SWITCH_LOG_DEBUG; switch_set_flag(listener, LFLAG_LOG); ei_x_encode_atom(rbuf, "ok"); } else if (!strncmp(atom, "register_event_handler", MAXATOMLEN)) { ei_link(listener, ei_self(listener->ec), &msg->from); listener->event_process.type = ERLANG_PID; memcpy(&listener->event_process.pid, &msg->from, sizeof(erlang_pid)); if (!switch_test_flag(listener, LFLAG_EVENTS)) { switch_set_flag_locked(listener, LFLAG_EVENTS); } ei_x_encode_atom(rbuf, "ok"); } else if (!strncmp(atom, "noevents", MAXATOMLEN)) { void *pop; /*purge the event queue */ while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS); if (switch_test_flag(listener, LFLAG_EVENTS)) { uint8_t x = 0; switch_clear_flag_locked(listener, LFLAG_EVENTS); for (x = 0; x <= SWITCH_EVENT_ALL; x++) { listener->event_list[x] = 0; } /* wipe the hash */ switch_core_hash_destroy(&listener->event_hash); switch_core_hash_init(&listener->event_hash, listener->pool); ei_x_encode_atom(rbuf, "ok"); } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "notlistening"); } } else if (!strncmp(atom, "session_noevents", MAXATOMLEN)) { session_elem_t *session; if ((session = find_session_elem_by_pid(listener, &msg->from))) { void *pop; uint8_t x = 0; /*purge the event queue */ while (switch_queue_trypop(session->event_queue, &pop) == SWITCH_STATUS_SUCCESS); for (x = 0; x <= SWITCH_EVENT_ALL; x++) { session->event_list[x] = 0; } /* wipe the hash */ switch_core_hash_destroy(&session->event_hash); switch_core_hash_init(&session->event_hash, session->pool); ei_x_encode_atom(rbuf, "ok"); } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "notlistening"); } } else if (!strncmp(atom, "exit", MAXATOMLEN)) { ei_x_encode_atom(rbuf, "ok"); ret = SWITCH_STATUS_TERM; } else if (!strncmp(atom, "getpid", MAXATOMLEN)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "ok"); ei_x_encode_pid(rbuf, ei_self(listener->ec)); } else if (!strncmp(atom, "link", MAXATOMLEN)) { /* debugging */ ei_link(listener, ei_self(listener->ec), &msg->from); ret = SWITCH_STATUS_FALSE; } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "undef"); } return ret; }
static switch_status_t handle_msg_session_setevent(listener_t *listener, erlang_msg *msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf) { char atom[MAXATOMLEN]; if (arity == 1){ ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); } else { session_elem_t *session; if ((session = find_session_elem_by_pid(listener, &msg->from))) { uint8_t event_list[SWITCH_EVENT_ALL + 1]; switch_hash_t *event_hash; int custom = 0; int i = 0; switch_event_types_t type; uint32_t x = 0; /* clear any previous event registrations */ for (x = 0; x <= SWITCH_EVENT_ALL; x++){ event_list[x] = 0; } /* create new hash */ switch_core_hash_init(&event_hash, session->pool); for (i = 1; i < arity; i++){ if (!ei_decode_atom(buf->buff, &buf->index, atom)) { if (custom) { switch_core_hash_insert(event_hash, atom, MARKER); } else if (switch_name_event(atom, &type) == SWITCH_STATUS_SUCCESS) { if (type == SWITCH_EVENT_ALL) { ei_x_encode_tuple_header(rbuf, 1); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); break; } if (type <= SWITCH_EVENT_ALL) { event_list[type] = 1; } if (type == SWITCH_EVENT_CUSTOM) { custom++; } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "enable event %s for session %s\n", atom, session->uuid_str); } } /* update the event subscriptions with the new ones */ switch_thread_rwlock_wrlock(session->event_rwlock); memcpy(session->event_list, event_list, sizeof(uint8_t) * (SWITCH_EVENT_ALL + 1)); /* wipe the old hash, and point the pointer at the new one */ switch_core_hash_destroy(&session->event_hash); session->event_hash = event_hash; switch_thread_rwlock_unlock(session->event_rwlock); /* TODO - we should flush any non-matching events from the queue */ ei_x_encode_atom(rbuf, "ok"); } else { /* no session for this pid */ ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "notlistening"); } } return SWITCH_STATUS_SUCCESS; }
/** * Start CPA */ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data) { iks *iq = msg->payload; switch_core_session_t *session = (switch_core_session_t *)session_data; iks *input = iks_find(iq, "input"); switch_memory_pool_t *pool = NULL; struct cpa_component *component = NULL; int have_grammar = 0; iks *grammar = NULL; /* create CPA component */ switch_core_new_memory_pool(&pool); component = switch_core_alloc(pool, sizeof(*component)); component = CPA_COMPONENT(rayo_component_init((struct rayo_component *)component, pool, RAT_CALL_COMPONENT, "cpa", NULL, call, iks_find_attrib(iq, "from"))); if (!component) { switch_core_destroy_memory_pool(&pool); return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create CPA entity"); } switch_core_hash_init(&component->signals); /* start CPA detectors */ for (grammar = iks_find(input, "grammar"); grammar; grammar = iks_next_tag(grammar)) { if (!strcmp("grammar", iks_name(grammar))) { const char *error_str = ""; const char *url = iks_find_attrib_soft(grammar, "url"); char *url_dup; char *url_params; if (zstr(url)) { stop_cpa_detectors(component); RAYO_UNLOCK(component); RAYO_DESTROY(component); return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing grammar URL"); } have_grammar = 1; url_dup = strdup(url); if ((url_params = strchr(url_dup, '?'))) { *url_params = '\0'; url_params++; } if (switch_core_hash_find(component->signals, url)) { free(url_dup); stop_cpa_detectors(component); RAYO_UNLOCK(component); RAYO_DESTROY(component); return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Duplicate URL"); } /* start detector */ /* TODO return better reasons... */ if (rayo_cpa_detector_start(switch_core_session_get_uuid(session), url_dup, &error_str)) { struct cpa_signal *cpa_signal = switch_core_alloc(pool, sizeof(*cpa_signal)); cpa_signal->terminate = !zstr(url_params) && strstr(url_params, "terminate=true"); cpa_signal->name = switch_core_strdup(pool, url_dup); switch_core_hash_insert(component->signals, cpa_signal->name, cpa_signal); subscribe(switch_core_session_get_uuid(session), cpa_signal->name, RAYO_JID(component)); } else { free(url_dup); stop_cpa_detectors(component); RAYO_UNLOCK(component); RAYO_DESTROY(component); return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, error_str); } free(url_dup); } } if (!have_grammar) { stop_cpa_detectors(component); RAYO_UNLOCK(component); RAYO_DESTROY(component); return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "No grammar defined"); } /* acknowledge command */ rayo_component_send_start(RAYO_COMPONENT(component), iq); /* TODO hangup race condition */ subscribe(switch_core_session_get_uuid(session), "hangup", RAYO_JID(component)); /* ready to forward detector events */ component->ready = 1; return NULL; }
static switch_status_t do_config(void) { char *cf = "xml_curl.conf"; switch_xml_t cfg, xml, bindings_tag, binding_tag, param; xml_binding_t *binding = NULL; int x = 0; int need_vars_map = 0; switch_hash_t *vars_map = 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 (!(bindings_tag = switch_xml_child(cfg, "bindings"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!\n"); goto done; } for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) { char *bname = (char *) switch_xml_attr_soft(binding_tag, "name"); char *url = NULL; char *bind_cred = NULL; char *bind_mask = NULL; char *method = NULL; int disable100continue = 1; int use_dynamic_url = 0, timeout = 0; uint32_t enable_cacert_check = 0; char *ssl_cert_file = NULL; char *ssl_key_file = NULL; char *ssl_key_password = NULL; char *ssl_version = NULL; char *ssl_cacert_file = NULL; uint32_t enable_ssl_verifyhost = 0; char *cookie_file = NULL; hash_node_t *hash_node; int auth_scheme = CURLAUTH_BASIC; need_vars_map = 0; vars_map = NULL; for (param = switch_xml_child(binding_tag, "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, "gateway-url")) { bind_mask = (char *) switch_xml_attr_soft(param, "bindings"); if (val) { url = val; } } else if (!strcasecmp(var, "gateway-credentials")) { bind_cred = val; } else if (!strcasecmp(var, "auth-scheme")) { if (*val == '=') { auth_scheme = 0; val++; } if (!strcasecmp(val, "basic")) { auth_scheme |= CURLAUTH_BASIC; } else if (!strcasecmp(val, "digest")) { auth_scheme |= CURLAUTH_DIGEST; } else if (!strcasecmp(val, "NTLM")) { auth_scheme |= CURLAUTH_NTLM; } else if (!strcasecmp(val, "GSS-NEGOTIATE")) { auth_scheme |= CURLAUTH_GSSNEGOTIATE; } else if (!strcasecmp(val, "any")) { auth_scheme = CURLAUTH_ANY; } } else if (!strcasecmp(var, "disable-100-continue") && !switch_true(val)) { disable100continue = 0; } else if (!strcasecmp(var, "method")) { method = val; } else if (!strcasecmp(var, "timeout")) { int tmp = atoi(val); if (tmp >= 0) { timeout = tmp; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!\n"); } } else if (!strcasecmp(var, "enable-cacert-check") && switch_true(val)) { enable_cacert_check = 1; } else if (!strcasecmp(var, "ssl-cert-path")) { ssl_cert_file = val; } else if (!strcasecmp(var, "ssl-key-path")) { ssl_key_file = val; } else if (!strcasecmp(var, "ssl-key-password")) { ssl_key_password = val; } else if (!strcasecmp(var, "ssl-version")) { ssl_version = val; } else if (!strcasecmp(var, "ssl-cacert-file")) { ssl_cacert_file = val; } else if (!strcasecmp(var, "enable-ssl-verifyhost") && switch_true(val)) { enable_ssl_verifyhost = 1; } else if (!strcasecmp(var, "cookie-file")) { cookie_file = val; } else if (!strcasecmp(var, "use-dynamic-url") && switch_true(val)) { use_dynamic_url = 1; } else if (!strcasecmp(var, "enable-post-var")) { if (!vars_map && need_vars_map == 0) { if (switch_core_hash_init(&vars_map, globals.pool) != SWITCH_STATUS_SUCCESS) { need_vars_map = -1; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't init params hash!\n"); continue; } need_vars_map = 1; } if (vars_map && val) if (switch_core_hash_insert(vars_map, val, ENABLE_PARAM_VALUE) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't add %s to params hash!\n", val); } } } if (!url) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Binding has no url!\n"); if (vars_map) switch_core_hash_destroy(&vars_map); continue; } if (!(binding = malloc(sizeof(*binding)))) { if (vars_map) switch_core_hash_destroy(&vars_map); goto done; } memset(binding, 0, sizeof(*binding)); binding->auth_scheme = auth_scheme; binding->timeout = timeout; binding->url = strdup(url); switch_assert(binding->url); if (method != NULL) { binding->method = strdup(method); } else { binding->method = NULL; } if (bind_mask) { binding->bindings = strdup(bind_mask); } if (bind_cred) { binding->cred = strdup(bind_cred); } binding->disable100continue = disable100continue; binding->use_get_style = method != NULL && strcasecmp(method, "post") != 0; binding->use_dynamic_url = use_dynamic_url; binding->enable_cacert_check = enable_cacert_check; if (ssl_cert_file) { binding->ssl_cert_file = strdup(ssl_cert_file); } if (ssl_key_file) { binding->ssl_key_file = strdup(ssl_key_file); } if (ssl_key_password) { binding->ssl_key_password = strdup(ssl_key_password); } if (ssl_version) { binding->ssl_version = strdup(ssl_version); } if (ssl_cacert_file) { binding->ssl_cacert_file = strdup(ssl_cacert_file); } binding->enable_ssl_verifyhost = enable_ssl_verifyhost; if (cookie_file) { binding->cookie_file = strdup(cookie_file); } binding->vars_map = vars_map; if (vars_map) { switch_zmalloc(hash_node, sizeof(hash_node_t)); hash_node->hash = vars_map; hash_node->next = NULL; if (!globals.hash_root) { globals.hash_root = hash_node; globals.hash_tail = globals.hash_root; } else { globals.hash_tail->next = hash_node; globals.hash_tail = globals.hash_tail->next; } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n", zstr(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all"); switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding); x++; binding = NULL; } done: switch_xml_free(xml); return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; }
switch_hash_t *create_default_filter() { switch_hash_t *filter; switch_core_hash_init(&filter); switch_core_hash_insert(filter, "Acquired-UUID", "1"); switch_core_hash_insert(filter, "action", "1"); switch_core_hash_insert(filter, "Action", "1"); switch_core_hash_insert(filter, "alt_event_type", "1"); switch_core_hash_insert(filter, "Answer-State", "1"); switch_core_hash_insert(filter, "Application", "1"); switch_core_hash_insert(filter, "Application-Data", "1"); switch_core_hash_insert(filter, "Application-Name", "1"); switch_core_hash_insert(filter, "Application-Response", "1"); switch_core_hash_insert(filter, "att_xfer_replaced_by", "1"); switch_core_hash_insert(filter, "Auth-Method", "1"); switch_core_hash_insert(filter, "Auth-Realm", "1"); switch_core_hash_insert(filter, "Auth-User", "1"); switch_core_hash_insert(filter, "Bridge-A-Unique-ID", "1"); switch_core_hash_insert(filter, "Bridge-B-Unique-ID", "1"); switch_core_hash_insert(filter, "Call-Direction", "1"); switch_core_hash_insert(filter, "Caller-Callee-ID-Name", "1"); switch_core_hash_insert(filter, "Caller-Callee-ID-Number", "1"); switch_core_hash_insert(filter, "Caller-Caller-ID-Name", "1"); switch_core_hash_insert(filter, "Caller-Caller-ID-Number", "1"); switch_core_hash_insert(filter, "Caller-Context", "1"); switch_core_hash_insert(filter, "Caller-Controls", "1"); switch_core_hash_insert(filter, "Caller-Destination-Number", "1"); switch_core_hash_insert(filter, "Caller-Dialplan", "1"); switch_core_hash_insert(filter, "Caller-Network-Addr", "1"); switch_core_hash_insert(filter, "Caller-Unique-ID", "1"); switch_core_hash_insert(filter, "Call-ID", "1"); switch_core_hash_insert(filter, "Channel-Call-State", "1"); switch_core_hash_insert(filter, "Channel-Call-UUID", "1"); switch_core_hash_insert(filter, "Channel-Presence-ID", "1"); switch_core_hash_insert(filter, "Channel-State", "1"); switch_core_hash_insert(filter, "Chat-Permissions", "1"); switch_core_hash_insert(filter, "Conference-Name", "1"); switch_core_hash_insert(filter, "Conference-Profile-Name", "1"); switch_core_hash_insert(filter, "Conference-Unique-ID", "1"); switch_core_hash_insert(filter, "contact", "1"); switch_core_hash_insert(filter, "Detected-Tone", "1"); switch_core_hash_insert(filter, "dialog_state", "1"); switch_core_hash_insert(filter, "direction", "1"); switch_core_hash_insert(filter, "Distributed-From", "1"); switch_core_hash_insert(filter, "DTMF-Digit", "1"); switch_core_hash_insert(filter, "DTMF-Duration", "1"); switch_core_hash_insert(filter, "Event-Date-Timestamp", "1"); switch_core_hash_insert(filter, "Event-Name", "1"); switch_core_hash_insert(filter, "Event-Subclass", "1"); switch_core_hash_insert(filter, "expires", "1"); switch_core_hash_insert(filter, "Expires", "1"); switch_core_hash_insert(filter, "Ext-SIP-IP", "1"); switch_core_hash_insert(filter, "File", "1"); switch_core_hash_insert(filter, "FreeSWITCH-Hostname", "1"); switch_core_hash_insert(filter, "from", "1"); switch_core_hash_insert(filter, "Hunt-Destination-Number", "1"); switch_core_hash_insert(filter, "ip", "1"); switch_core_hash_insert(filter, "Message-Account", "1"); switch_core_hash_insert(filter, "metadata", "1"); switch_core_hash_insert(filter, "old_node_channel_uuid", "1"); switch_core_hash_insert(filter, "Other-Leg-Callee-ID-Name", "1"); switch_core_hash_insert(filter, "Other-Leg-Callee-ID-Number", "1"); switch_core_hash_insert(filter, "Other-Leg-Caller-ID-Name", "1"); switch_core_hash_insert(filter, "Other-Leg-Caller-ID-Number", "1"); switch_core_hash_insert(filter, "Other-Leg-Destination-Number", "1"); switch_core_hash_insert(filter, "Other-Leg-Direction", "1"); switch_core_hash_insert(filter, "Other-Leg-Unique-ID", "1"); switch_core_hash_insert(filter, "Other-Leg-Channel-Name", "1"); switch_core_hash_insert(filter, "Participant-Type", "1"); switch_core_hash_insert(filter, "Path", "1"); switch_core_hash_insert(filter, "profile_name", "1"); switch_core_hash_insert(filter, "Profiles", "1"); switch_core_hash_insert(filter, "proto-specific-event-name", "1"); switch_core_hash_insert(filter, "Raw-Application-Data", "1"); switch_core_hash_insert(filter, "realm", "1"); switch_core_hash_insert(filter, "Resigning-UUID", "1"); switch_core_hash_insert(filter, "set", "1"); switch_core_hash_insert(filter, "sip_auto_answer", "1"); switch_core_hash_insert(filter, "sip_auth_method", "1"); switch_core_hash_insert(filter, "sip_from_host", "1"); switch_core_hash_insert(filter, "sip_from_user", "1"); switch_core_hash_insert(filter, "sip_to_host", "1"); switch_core_hash_insert(filter, "sip_to_user", "1"); switch_core_hash_insert(filter, "sub-call-id", "1"); switch_core_hash_insert(filter, "technology", "1"); switch_core_hash_insert(filter, "to", "1"); switch_core_hash_insert(filter, "Unique-ID", "1"); switch_core_hash_insert(filter, "URL", "1"); switch_core_hash_insert(filter, "username", "1"); switch_core_hash_insert(filter, "variable_channel_is_moving", "1"); switch_core_hash_insert(filter, "variable_collected_digits", "1"); switch_core_hash_insert(filter, "variable_current_application", "1"); switch_core_hash_insert(filter, "variable_current_application_data", "1"); switch_core_hash_insert(filter, "variable_domain_name", "1"); switch_core_hash_insert(filter, "variable_effective_caller_id_name", "1"); switch_core_hash_insert(filter, "variable_effective_caller_id_number", "1"); switch_core_hash_insert(filter, "variable_holding_uuid", "1"); switch_core_hash_insert(filter, "variable_hold_music", "1"); switch_core_hash_insert(filter, "variable_media_group_id", "1"); switch_core_hash_insert(filter, "variable_originate_disposition", "1"); switch_core_hash_insert(filter, "variable_origination_uuid", "1"); switch_core_hash_insert(filter, "variable_playback_terminator_used", "1"); switch_core_hash_insert(filter, "variable_presence_id", "1"); switch_core_hash_insert(filter, "variable_record_ms", "1"); switch_core_hash_insert(filter, "variable_recovered", "1"); switch_core_hash_insert(filter, "variable_silence_hits_exhausted", "1"); switch_core_hash_insert(filter, "variable_sip_auth_realm", "1"); switch_core_hash_insert(filter, "variable_sip_from_host", "1"); switch_core_hash_insert(filter, "variable_sip_from_user", "1"); switch_core_hash_insert(filter, "variable_sip_from_tag", "1"); switch_core_hash_insert(filter, "variable_sip_h_X-AUTH-IP", "1"); switch_core_hash_insert(filter, "variable_sip_received_ip", "1"); switch_core_hash_insert(filter, "variable_sip_to_host", "1"); switch_core_hash_insert(filter, "variable_sip_to_user", "1"); switch_core_hash_insert(filter, "variable_sip_to_tag", "1"); switch_core_hash_insert(filter, "variable_sofia_profile_name", "1"); switch_core_hash_insert(filter, "variable_transfer_history", "1"); switch_core_hash_insert(filter, "variable_user_name", "1"); switch_core_hash_insert(filter, "variable_endpoint_disposition", "1"); switch_core_hash_insert(filter, "variable_originate_disposition", "1"); switch_core_hash_insert(filter, "variable_bridge_hangup_cause", "1"); switch_core_hash_insert(filter, "variable_hangup_cause", "1"); switch_core_hash_insert(filter, "variable_last_bridge_proto_specific_hangup_cause", "1"); switch_core_hash_insert(filter, "variable_proto_specific_hangup_cause", "1"); switch_core_hash_insert(filter, "VM-Call-ID", "1"); switch_core_hash_insert(filter, "VM-sub-call-id", "1"); switch_core_hash_insert(filter, "whistle_application_name", "1"); switch_core_hash_insert(filter, "whistle_application_response", "1"); switch_core_hash_insert(filter, "whistle_event_name", "1"); switch_core_hash_insert(filter, "sip_auto_answer_notify", "1"); switch_core_hash_insert(filter, "eavesdrop_group", "1"); switch_core_hash_insert(filter, "origination_caller_id_name", "1"); switch_core_hash_insert(filter, "origination_caller_id_number", "1"); switch_core_hash_insert(filter, "origination_callee_id_name", "1"); switch_core_hash_insert(filter, "origination_callee_id_number", "1"); switch_core_hash_insert(filter, "sip_auth_username", "1"); switch_core_hash_insert(filter, "sip_auth_password", "1"); switch_core_hash_insert(filter, "effective_caller_id_name", "1"); switch_core_hash_insert(filter, "effective_caller_id_number", "1"); switch_core_hash_insert(filter, "effective_callee_id_name", "1"); switch_core_hash_insert(filter, "effective_callee_id_number", "1"); /* Registration headers */ switch_core_hash_insert(filter, "call-id", "1"); switch_core_hash_insert(filter, "profile-name", "1"); switch_core_hash_insert(filter, "from-user", "1"); switch_core_hash_insert(filter, "from-host", "1"); switch_core_hash_insert(filter, "presence-hosts", "1"); switch_core_hash_insert(filter, "contact", "1"); switch_core_hash_insert(filter, "rpid", "1"); switch_core_hash_insert(filter, "status", "1"); switch_core_hash_insert(filter, "expires", "1"); switch_core_hash_insert(filter, "to-user", "1"); switch_core_hash_insert(filter, "to-host", "1"); switch_core_hash_insert(filter, "network-ip", "1"); switch_core_hash_insert(filter, "network-port", "1"); switch_core_hash_insert(filter, "username", "1"); switch_core_hash_insert(filter, "realm", "1"); switch_core_hash_insert(filter, "user-agent", "1"); switch_core_hash_insert(filter, "Hangup-Cause", "1"); switch_core_hash_insert(filter, "Unique-ID", "1"); switch_core_hash_insert(filter, "variable_switch_r_sdp", "1"); switch_core_hash_insert(filter, "variable_rtp_local_sdp_str", "1"); switch_core_hash_insert(filter, "variable_sip_to_uri", "1"); switch_core_hash_insert(filter, "variable_sip_from_uri", "1"); switch_core_hash_insert(filter, "variable_sip_user_agent", "1"); switch_core_hash_insert(filter, "variable_duration", "1"); switch_core_hash_insert(filter, "variable_billsec", "1"); switch_core_hash_insert(filter, "variable_progresssec", "1"); switch_core_hash_insert(filter, "variable_progress_uepoch", "1"); switch_core_hash_insert(filter, "variable_progress_media_uepoch", "1"); switch_core_hash_insert(filter, "variable_start_uepoch", "1"); switch_core_hash_insert(filter, "variable_digits_dialed", "1"); switch_core_hash_insert(filter, "Member-ID", "1"); switch_core_hash_insert(filter, "Floor", "1"); switch_core_hash_insert(filter, "Video", "1"); switch_core_hash_insert(filter, "Hear", "1"); switch_core_hash_insert(filter, "Speak", "1"); switch_core_hash_insert(filter, "Talking", "1"); switch_core_hash_insert(filter, "Current-Energy", "1"); switch_core_hash_insert(filter, "Energy-Level", "1"); switch_core_hash_insert(filter, "Mute-Detect", "1"); /* RTMP headers */ switch_core_hash_insert(filter, "RTMP-Session-ID", "1"); switch_core_hash_insert(filter, "RTMP-Profile", "1"); switch_core_hash_insert(filter, "RTMP-Flash-Version", "1"); switch_core_hash_insert(filter, "RTMP-SWF-URL", "1"); switch_core_hash_insert(filter, "RTMP-TC-URL", "1"); switch_core_hash_insert(filter, "RTMP-Page-URL", "1"); switch_core_hash_insert(filter, "User", "1"); switch_core_hash_insert(filter, "Domain", "1"); /* Fax headers */ switch_core_hash_insert(filter, "variable_fax_bad_rows", "1"); switch_core_hash_insert(filter, "variable_fax_document_total_pages", "1"); switch_core_hash_insert(filter, "variable_fax_document_transferred_pages", "1"); switch_core_hash_insert(filter, "variable_fax_ecm_used", "1"); switch_core_hash_insert(filter, "variable_fax_result_code", "1"); switch_core_hash_insert(filter, "variable_fax_result_text", "1"); switch_core_hash_insert(filter, "variable_fax_success", "1"); switch_core_hash_insert(filter, "variable_fax_transfer_rate", "1"); switch_core_hash_insert(filter, "variable_fax_local_station_id", "1"); switch_core_hash_insert(filter, "variable_fax_remote_station_id", "1"); switch_core_hash_insert(filter, "variable_fax_remote_country", "1"); switch_core_hash_insert(filter, "variable_fax_remote_vendor", "1"); switch_core_hash_insert(filter, "variable_fax_remote_model", "1"); switch_core_hash_insert(filter, "variable_fax_image_resolution", "1"); switch_core_hash_insert(filter, "variable_fax_file_image_resolution", "1"); switch_core_hash_insert(filter, "variable_fax_image_size", "1"); switch_core_hash_insert(filter, "variable_fax_image_pixel_size", "1"); switch_core_hash_insert(filter, "variable_fax_file_image_pixel_size", "1"); switch_core_hash_insert(filter, "variable_fax_longest_bad_row_run", "1"); switch_core_hash_insert(filter, "variable_fax_encoding", "1"); switch_core_hash_insert(filter, "variable_fax_encoding_name", "1"); switch_core_hash_insert(filter, "variable_fax_header", "1"); switch_core_hash_insert(filter, "variable_fax_ident", "1"); switch_core_hash_insert(filter, "variable_fax_timezone", "1"); switch_core_hash_insert(filter, "variable_fax_doc_id", "1"); switch_core_hash_insert(filter, "variable_fax_doc_database", "1"); /* Secure headers */ /* switch_core_hash_insert(filter, "variable_sdp_secure_savp_only", "1"); switch_core_hash_insert(filter, "variable_rtp_has_crypto", "1"); switch_core_hash_insert(filter, "variable_rtp_secure_media", "1"); switch_core_hash_insert(filter, "variable_rtp_secure_media_confirmed", "1"); switch_core_hash_insert(filter, "variable_rtp_secure_media_confirmed_audio", "1"); switch_core_hash_insert(filter, "variable_rtp_secure_media_confirmed_video", "1"); switch_core_hash_insert(filter, "variable_zrtp_secure_media", "1"); switch_core_hash_insert(filter, "variable_zrtp_secure_media_confirmed", "1"); switch_core_hash_insert(filter, "variable_zrtp_secure_media_confirmed_audio", "1"); switch_core_hash_insert(filter, "variable_zrtp_secure_media_confirmed_video", "1"); switch_core_hash_insert(filter, "sdp_secure_savp_only", "1"); switch_core_hash_insert(filter, "rtp_has_crypto", "1"); switch_core_hash_insert(filter, "rtp_secure_media", "1"); switch_core_hash_insert(filter, "rtp_secure_media_confirmed", "1"); switch_core_hash_insert(filter, "rtp_secure_media_confirmed_audio", "1"); switch_core_hash_insert(filter, "rtp_secure_media_confirmed_video", "1"); switch_core_hash_insert(filter, "zrtp_secure_media", "1"); switch_core_hash_insert(filter, "zrtp_secure_media_confirmed", "1"); switch_core_hash_insert(filter, "zrtp_secure_media_confirmed_audio", "1"); switch_core_hash_insert(filter, "zrtp_secure_media_confirmed_video", "1"); */ /* Device Redirect headers */ /* switch_core_hash_insert(filter, "variable_last_bridge_hangup_cause", "1"); switch_core_hash_insert(filter, "variable_sip_redirected_by", "1"); */ switch_core_hash_insert(filter, "intercepted_by", "1"); // SMS switch_core_hash_insert(filter, "Message-ID", "1"); switch_core_hash_insert(filter, "Delivery-Failure", "1"); switch_core_hash_insert(filter, "Delivery-Result-Code", "1"); return filter; }