Go to the source code of this file.
Functions | |
void | ast_autoservice_init (void) |
void | ast_builtins_init (void) |
initialize the _full_cmd string in * each of the builtins. | |
int | ast_cel_engine_init (void) |
int | ast_cel_engine_reload (void) |
void | ast_channels_init (void) |
int | ast_cli_perms_init (int reload) |
int | ast_data_init (void) |
int | ast_device_state_engine_init (void) |
Initialize the device state engine in separate thread. | |
int | ast_event_init (void) |
int | ast_features_init (void) |
int | ast_file_init (void) |
int | ast_http_init (void) |
int | ast_http_reload (void) |
int | ast_indications_init (void) |
Load indications module. | |
int | ast_indications_reload (void) |
Reload indications module. | |
int | ast_module_reload (const char *name) |
Reload asterisk modules. | |
int | ast_plc_reload (void) |
Reload genericplc configuration value from codecs.conf. | |
void | ast_process_pending_reloads (void) |
Process reload requests received during startup. | |
int | ast_ssl_init (void) |
void | ast_stun_init (void) |
Initialize the STUN system in Asterisk. | |
int | ast_term_init (void) |
int | ast_test_init (void) |
int | ast_timing_init (void) |
int | ast_tps_init (void) |
int | ast_xmldoc_load_documentation (void) |
Load XML documentation. Provided by xmldoc.c. | |
int | astdb_init (void) |
int | astobj2_init (void) |
void | close_logger (void) |
int | dnsmgr_init (void) |
int | dnsmgr_reload (void) |
void | dnsmgr_start_refresh (void) |
int | init_framer (void) |
int | init_logger (void) |
int | load_modules (unsigned int) |
int | load_pbx (void) |
void | threadstorage_init (void) |
Definition in file _private.h.
void ast_autoservice_init | ( | void | ) |
Provided by autoservice.c
Definition at line 319 of file autoservice.c.
References as_cond, and ast_cond_init.
Referenced by main().
00320 { 00321 ast_cond_init(&as_cond, NULL); 00322 }
void ast_builtins_init | ( | void | ) |
initialize the _full_cmd string in * each of the builtins.
Provided by cli.c
Definition at line 1853 of file cli.c.
References ARRAY_LEN, ast_cli_register_multiple(), and cli_cli.
Referenced by main().
01854 { 01855 ast_cli_register_multiple(cli_cli, ARRAY_LEN(cli_cli)); 01856 }
int ast_cel_engine_init | ( | void | ) |
Provided by cel.c
Definition at line 647 of file cel.c.
References ao2_container_alloc, ao2_ref, app_cmp(), app_hash(), appset, ast_cel_engine_term(), ast_cli_register(), ast_register_atexit(), cli_status, and do_reload().
Referenced by main().
00648 { 00649 if (!(appset = ao2_container_alloc(NUM_APP_BUCKETS, app_hash, app_cmp))) { 00650 return -1; 00651 } 00652 00653 if (do_reload()) { 00654 ao2_ref(appset, -1); 00655 appset = NULL; 00656 return -1; 00657 } 00658 00659 if (ast_cli_register(&cli_status)) { 00660 ao2_ref(appset, -1); 00661 appset = NULL; 00662 return -1; 00663 } 00664 00665 ast_register_atexit(ast_cel_engine_term); 00666 00667 return 0; 00668 }
int ast_cel_engine_reload | ( | void | ) |
Provided by cel.c
Definition at line 670 of file cel.c.
References do_reload().
00671 { 00672 return do_reload(); 00673 }
void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 7688 of file channel.c.
References ao2_container_alloc, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_cli_register_multiple(), ast_data_register_multiple_core, ast_plc_reload(), channel_providers, channels, cli_channel, and NUM_CHANNEL_BUCKETS.
Referenced by main().
07689 { 07690 channels = ao2_container_alloc(NUM_CHANNEL_BUCKETS, 07691 ast_channel_hash_cb, ast_channel_cmp_cb); 07692 07693 ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel)); 07694 07695 ast_data_register_multiple_core(channel_providers, ARRAY_LEN(channel_providers)); 07696 07697 ast_plc_reload(); 07698 }
int ast_cli_perms_init | ( | int | reload | ) |
Provided by cli.c
Definition at line 1730 of file cli.c.
References ast_calloc, ast_category_browse(), ast_config_load2(), ast_free, AST_LIST_TRAVERSE, ast_log(), ast_mutex_trylock, ast_mutex_unlock, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strlen_zero(), ast_variable_browse(), CONFIG_FLAG_FILEUNCHANGED, config_flags, CONFIG_STATUS_FILEUNCHANGED, destroy_user_perms(), usergroup_cli_perm::gid, cli_perm::list, LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, perms_config, usergroup_cli_perm::uid, and ast_variable::value.
Referenced by handle_cli_reload_permissions(), and main().
01731 { 01732 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 01733 struct ast_config *cfg; 01734 char *cat = NULL; 01735 struct ast_variable *v; 01736 struct usergroup_cli_perm *user_group, *cp_entry; 01737 struct cli_perm *perm = NULL; 01738 struct passwd *pw; 01739 struct group *gr; 01740 01741 if (ast_mutex_trylock(&permsconfiglock)) { 01742 ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n"); 01743 return 1; 01744 } 01745 01746 cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags); 01747 if (!cfg) { 01748 ast_mutex_unlock(&permsconfiglock); 01749 return 1; 01750 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { 01751 ast_mutex_unlock(&permsconfiglock); 01752 return 0; 01753 } 01754 01755 /* free current structures. */ 01756 destroy_user_perms(); 01757 01758 while ((cat = ast_category_browse(cfg, cat))) { 01759 if (!strcasecmp(cat, "general")) { 01760 /* General options */ 01761 for (v = ast_variable_browse(cfg, cat); v; v = v->next) { 01762 if (!strcasecmp(v->name, "default_perm")) { 01763 cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0; 01764 } 01765 } 01766 continue; 01767 } 01768 01769 /* users or groups */ 01770 gr = NULL, pw = NULL; 01771 if (cat[0] == '@') { 01772 /* This is a group */ 01773 gr = getgrnam(&cat[1]); 01774 if (!gr) { 01775 ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]); 01776 continue; 01777 } 01778 } else { 01779 /* This is a user */ 01780 pw = getpwnam(cat); 01781 if (!pw) { 01782 ast_log (LOG_WARNING, "Unknown user '%s'\n", cat); 01783 continue; 01784 } 01785 } 01786 user_group = NULL; 01787 /* Check for duplicates */ 01788 AST_RWLIST_WRLOCK(&cli_perms); 01789 AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) { 01790 if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) { 01791 /* if it is duplicated, just added this new settings, to 01792 the current list. */ 01793 user_group = cp_entry; 01794 break; 01795 } 01796 } 01797 AST_RWLIST_UNLOCK(&cli_perms); 01798 01799 if (!user_group) { 01800 /* alloc space for the new user config. */ 01801 user_group = ast_calloc(1, sizeof(*user_group)); 01802 if (!user_group) { 01803 continue; 01804 } 01805 user_group->uid = (pw ? pw->pw_uid : -1); 01806 user_group->gid = (gr ? gr->gr_gid : -1); 01807 user_group->perms = ast_calloc(1, sizeof(*user_group->perms)); 01808 if (!user_group->perms) { 01809 ast_free(user_group); 01810 continue; 01811 } 01812 } 01813 for (v = ast_variable_browse(cfg, cat); v; v = v->next) { 01814 if (ast_strlen_zero(v->value)) { 01815 /* we need to check this condition cause it could break security. */ 01816 ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat); 01817 continue; 01818 } 01819 if (!strcasecmp(v->name, "permit")) { 01820 perm = ast_calloc(1, sizeof(*perm)); 01821 if (perm) { 01822 perm->permit = 1; 01823 perm->command = ast_strdup(v->value); 01824 } 01825 } else if (!strcasecmp(v->name, "deny")) { 01826 perm = ast_calloc(1, sizeof(*perm)); 01827 if (perm) { 01828 perm->permit = 0; 01829 perm->command = ast_strdup(v->value); 01830 } 01831 } else { 01832 /* up to now, only 'permit' and 'deny' are possible values. */ 01833 ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name); 01834 continue; 01835 } 01836 if (perm) { 01837 /* Added the permission to the user's list. */ 01838 AST_LIST_INSERT_TAIL(user_group->perms, perm, list); 01839 perm = NULL; 01840 } 01841 } 01842 AST_RWLIST_WRLOCK(&cli_perms); 01843 AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list); 01844 AST_RWLIST_UNLOCK(&cli_perms); 01845 } 01846 01847 ast_config_destroy(cfg); 01848 ast_mutex_unlock(&permsconfiglock); 01849 return 0; 01850 }
int ast_data_init | ( | void | ) |
Provided by data.c
Definition at line 3277 of file data.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_manager_register_xml, ast_rwlock_init, AST_TEST_REGISTER, cli_data, data_provider_cmp(), data_provider_hash(), manager_data_get(), NUM_DATA_NODE_BUCKETS, and root_data.
Referenced by main().
03278 { 03279 int res = 0; 03280 03281 ast_rwlock_init(&root_data.lock); 03282 03283 if (!(root_data.container = ao2_container_alloc(NUM_DATA_NODE_BUCKETS, 03284 data_provider_hash, data_provider_cmp))) { 03285 return -1; 03286 } 03287 03288 res |= ast_cli_register_multiple(cli_data, ARRAY_LEN(cli_data)); 03289 03290 res |= ast_manager_register_xml("DataGet", 0, manager_data_get); 03291 03292 #ifdef TEST_FRAMEWORK 03293 AST_TEST_REGISTER(test_data_get); 03294 #endif 03295 03296 return res; 03297 }
int ast_device_state_engine_init | ( | void | ) |
Initialize the device state engine in separate thread.
Provided by devicestate.c
Definition at line 721 of file devicestate.c.
References ast_cond_init, ast_log(), ast_pthread_create_background, change_thread, do_devstate_changes(), and LOG_ERROR.
Referenced by main().
00722 { 00723 ast_cond_init(&change_pending, NULL); 00724 if (ast_pthread_create_background(&change_thread, NULL, do_devstate_changes, NULL) < 0) { 00725 ast_log(LOG_ERROR, "Unable to start device state change thread.\n"); 00726 return -1; 00727 } 00728 00729 return 0; 00730 }
int ast_event_init | ( | void | ) |
Provided by event.c
Definition at line 1687 of file event.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_event_cache, ast_event_cmp(), ast_event_hash(), ast_event_subs, AST_RWDLLIST_HEAD_INIT, ast_taskprocessor_get(), container, event_cli, event_dispatcher, hash_fn, and NUM_CACHE_BUCKETS.
Referenced by main().
01688 { 01689 int i; 01690 01691 for (i = 0; i < AST_EVENT_TOTAL; i++) { 01692 AST_RWDLLIST_HEAD_INIT(&ast_event_subs[i]); 01693 } 01694 01695 for (i = 0; i < AST_EVENT_TOTAL; i++) { 01696 if (!ast_event_cache[i].hash_fn) { 01697 /* This event type is not cached. */ 01698 continue; 01699 } 01700 01701 if (!(ast_event_cache[i].container = ao2_container_alloc(NUM_CACHE_BUCKETS, 01702 ast_event_hash, ast_event_cmp))) { 01703 return -1; 01704 } 01705 } 01706 01707 if (!(event_dispatcher = ast_taskprocessor_get("core_event_dispatcher", 0))) { 01708 return -1; 01709 } 01710 01711 ast_cli_register_multiple(event_cli, ARRAY_LEN(event_cli)); 01712 01713 return 0; 01714 }
int ast_features_init | ( | void | ) |
Provided by features.c
Definition at line 5955 of file features.c.
References action_bridge(), ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_devstate_prov_add(), ast_manager_register_xml, ast_pthread_create, ast_register_application2(), AST_TEST_REGISTER, bridge_exec(), cli_features, do_parking_thread(), EVENT_FLAG_CALL, load_config(), manager_park(), manager_parking_status(), metermaidstate(), park_call_exec(), park_exec(), parkcall, parkedcall, parking_thread, parkinglot_cmp_cb(), parkinglot_hash_cb(), and parkinglots.
Referenced by main().
05956 { 05957 int res; 05958 05959 ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL); 05960 05961 parkinglots = ao2_container_alloc(7, parkinglot_hash_cb, parkinglot_cmp_cb); 05962 05963 if ((res = load_config())) 05964 return res; 05965 ast_cli_register_multiple(cli_features, ARRAY_LEN(cli_features)); 05966 ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL); 05967 res = ast_register_application2(parkedcall, park_exec, NULL, NULL, NULL); 05968 if (!res) 05969 res = ast_register_application2(parkcall, park_call_exec, NULL, NULL, NULL); 05970 if (!res) { 05971 ast_manager_register_xml("ParkedCalls", 0, manager_parking_status); 05972 ast_manager_register_xml("Park", EVENT_FLAG_CALL, manager_park); 05973 ast_manager_register_xml("Bridge", EVENT_FLAG_CALL, action_bridge); 05974 } 05975 05976 res |= ast_devstate_prov_add("Park", metermaidstate); 05977 #ifdef TEST_FRAMEWORK 05978 res |= AST_TEST_REGISTER(features_test); 05979 #endif 05980 05981 return res; 05982 }
int ast_file_init | ( | void | ) |
int ast_http_init | ( | void | ) |
Provided by http.c
Definition at line 1163 of file http.c.
References __ast_http_load(), ARRAY_LEN, ast_cli_register_multiple(), ast_http_uri_link(), cli_http, staticuri, and statusuri.
Referenced by main().
01164 { 01165 ast_http_uri_link(&statusuri); 01166 ast_http_uri_link(&staticuri); 01167 ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http)); 01168 01169 return __ast_http_load(0); 01170 }
int ast_http_reload | ( | void | ) |
Provided by http.c
Definition at line 1154 of file http.c.
References __ast_http_load().
01155 { 01156 return __ast_http_load(1); 01157 }
int ast_indications_init | ( | void | ) |
Load indications module.
Provided by indications.c
Definition at line 1147 of file indications.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_tone_zone_cmp(), ast_tone_zone_hash(), ast_tone_zones, cli_indications, load_indications(), and NUM_TONE_ZONE_BUCKETS.
Referenced by main().
01148 { 01149 if (!(ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS, 01150 ast_tone_zone_hash, ast_tone_zone_cmp))) { 01151 return -1; 01152 } 01153 01154 if (load_indications(0)) { 01155 return -1; 01156 } 01157 01158 ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications)); 01159 01160 return 0; 01161 }
int ast_indications_reload | ( | void | ) |
Reload indications module.
Provided by indications.c
Definition at line 1164 of file indications.c.
References load_indications().
01165 { 01166 return load_indications(1); 01167 }
int ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
name | the name of the module to reload |
1 | if the module was found but cannot be reloaded. | |
-1 | if a reload operation is already in progress. | |
2 | if the specfied module was found and reloaded. |
Definition at line 660 of file loader.c.
References ast_config_AST_CONFIG_DIR, ast_fully_booted, ast_lastreloadtime, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_lock_path(), AST_LOCK_SUCCESS, AST_LOCK_TIMEOUT, ast_log(), ast_mutex_trylock, ast_mutex_unlock, ast_opt_lock_confdir, ast_tvnow(), ast_unlock_path(), ast_verb, ast_verbose, ast_module::declined, ast_module_info::description, ast_module_user::entry, ast_module::flags, ast_module::info, LOG_NOTICE, LOG_WARNING, queue_reload_request(), ast_module_info::reload, ast_module::resource, resource_name_match(), and ast_module::running.
Referenced by action_reload(), action_updateconfig(), ast_process_pending_reloads(), handle_core_reload(), handle_reload(), manager_moduleload(), and monitor_sig_flags().
00661 { 00662 struct ast_module *cur; 00663 int res = 0; /* return value. 0 = not found, others, see below */ 00664 int i; 00665 00666 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00667 up to run once we are booted up. */ 00668 if (!ast_fully_booted) { 00669 queue_reload_request(name); 00670 return 0; 00671 } 00672 00673 if (ast_mutex_trylock(&reloadlock)) { 00674 ast_verbose("The previous reload command didn't finish yet\n"); 00675 return -1; /* reload already in progress */ 00676 } 00677 ast_lastreloadtime = ast_tvnow(); 00678 00679 if (ast_opt_lock_confdir) { 00680 int try; 00681 int res; 00682 for (try = 1, res = AST_LOCK_TIMEOUT; try < 6 && (res == AST_LOCK_TIMEOUT); try++) { 00683 res = ast_lock_path(ast_config_AST_CONFIG_DIR); 00684 if (res == AST_LOCK_TIMEOUT) { 00685 ast_log(LOG_WARNING, "Failed to grab lock on %s, try %d\n", ast_config_AST_CONFIG_DIR, try); 00686 } 00687 } 00688 if (res != AST_LOCK_SUCCESS) { 00689 ast_verbose("Cannot grab lock on %s\n", ast_config_AST_CONFIG_DIR); 00690 ast_mutex_unlock(&reloadlock); 00691 return -1; 00692 } 00693 } 00694 00695 /* Call "predefined" reload here first */ 00696 for (i = 0; reload_classes[i].name; i++) { 00697 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00698 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00699 res = 2; /* found and reloaded */ 00700 } 00701 } 00702 00703 if (name && res) { 00704 if (ast_opt_lock_confdir) { 00705 ast_unlock_path(ast_config_AST_CONFIG_DIR); 00706 } 00707 ast_mutex_unlock(&reloadlock); 00708 return res; 00709 } 00710 00711 AST_LIST_LOCK(&module_list); 00712 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00713 const struct ast_module_info *info = cur->info; 00714 00715 if (name && resource_name_match(name, cur->resource)) 00716 continue; 00717 00718 if (!cur->flags.running || cur->flags.declined) { 00719 if (!name) 00720 continue; 00721 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00722 "Before reloading the module, you must run \"module load %s\" " 00723 "and fix whatever is preventing the module from being initialized.\n", 00724 name, name); 00725 res = 2; /* Don't report that the module was not found */ 00726 break; 00727 } 00728 00729 if (!info->reload) { /* cannot be reloaded */ 00730 if (res < 1) /* store result if possible */ 00731 res = 1; /* 1 = no reload() method */ 00732 continue; 00733 } 00734 00735 res = 2; 00736 ast_verb(3, "Reloading module '%s' (%s)\n", cur->resource, info->description); 00737 info->reload(); 00738 } 00739 AST_LIST_UNLOCK(&module_list); 00740 00741 if (ast_opt_lock_confdir) { 00742 ast_unlock_path(ast_config_AST_CONFIG_DIR); 00743 } 00744 ast_mutex_unlock(&reloadlock); 00745 00746 return res; 00747 }
int ast_plc_reload | ( | void | ) |
Reload genericplc configuration value from codecs.conf.
Implementation is in main/channel.c
Definition at line 7553 of file channel.c.
References ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), config_flags, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, and var.
Referenced by ast_channels_init().
07554 { 07555 struct ast_variable *var; 07556 struct ast_flags config_flags = { 0 }; 07557 struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); 07558 if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) 07559 return 0; 07560 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 07561 if (!strcasecmp(var->name, "genericplc")) { 07562 ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC); 07563 } 07564 } 07565 ast_config_destroy(cfg); 07566 return 0; 07567 }
void ast_process_pending_reloads | ( | void | ) |
Process reload requests received during startup.
This function requests that the loader execute the pending reload requests that were queued during server startup.
Definition at line 595 of file loader.c.
References ast_free, ast_fully_booted, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_module_reload(), do_full_reload, ast_module_user::entry, LOG_NOTICE, and reload_queue_item::module.
Referenced by main().
00596 { 00597 struct reload_queue_item *item; 00598 00599 if (!ast_fully_booted) { 00600 return; 00601 } 00602 00603 AST_LIST_LOCK(&reload_queue); 00604 00605 if (do_full_reload) { 00606 do_full_reload = 0; 00607 AST_LIST_UNLOCK(&reload_queue); 00608 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00609 ast_module_reload(NULL); 00610 return; 00611 } 00612 00613 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00614 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00615 ast_module_reload(item->module); 00616 ast_free(item); 00617 } 00618 00619 AST_LIST_UNLOCK(&reload_queue); 00620 }
int ast_ssl_init | ( | void | ) |
Provided by ssl.c
Definition at line 73 of file ssl.c.
References ast_calloc, ast_mutex_init, ssl_lock(), ssl_locks, and ssl_threadid().
Referenced by main().
00074 { 00075 #ifdef HAVE_OPENSSL 00076 unsigned int i; 00077 00078 SSL_library_init(); 00079 SSL_load_error_strings(); 00080 ERR_load_crypto_strings(); 00081 ERR_load_BIO_strings(); 00082 OpenSSL_add_all_algorithms(); 00083 00084 /* Make OpenSSL thread-safe. */ 00085 00086 CRYPTO_set_id_callback(ssl_threadid); 00087 00088 ssl_num_locks = CRYPTO_num_locks(); 00089 if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) { 00090 return -1; 00091 } 00092 for (i = 0; i < ssl_num_locks; i++) { 00093 ast_mutex_init(&ssl_locks[i]); 00094 } 00095 CRYPTO_set_locking_callback(ssl_lock); 00096 00097 #endif /* HAVE_OPENSSL */ 00098 return 0; 00099 }
void ast_stun_init | ( | void | ) |
Initialize the STUN system in Asterisk.
Provided by stun.c
Definition at line 469 of file stun.c.
References ast_cli_register_multiple(), and cli_stun.
Referenced by main().
00470 { 00471 ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry)); 00472 }
int ast_term_init | ( | void | ) |
Provided by term.c
Definition at line 83 of file term.c.
References ast_opt_console, ast_opt_force_black_background, ast_opt_light_background, ast_opt_no_color, ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), and ESC.
Referenced by main().
00084 { 00085 char *term = getenv("TERM"); 00086 char termfile[256] = ""; 00087 char buffer[512] = ""; 00088 int termfd = -1, parseokay = 0, i; 00089 00090 if (ast_opt_no_color) { 00091 return 0; 00092 } 00093 00094 if (!ast_opt_console) { 00095 /* If any remote console is not compatible, we'll strip the color codes at that point */ 00096 vt100compat = 1; 00097 goto end; 00098 } 00099 00100 if (!term) { 00101 return 0; 00102 } 00103 00104 for (i = 0;; i++) { 00105 if (termpath[i] == NULL) { 00106 break; 00107 } 00108 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term); 00109 termfd = open(termfile, O_RDONLY); 00110 if (termfd > -1) { 00111 break; 00112 } 00113 } 00114 if (termfd > -1) { 00115 int actsize = read(termfd, buffer, sizeof(buffer) - 1); 00116 short sz_names = convshort(buffer + 2); 00117 short sz_bools = convshort(buffer + 4); 00118 short n_nums = convshort(buffer + 6); 00119 00120 /* if ((sz_names + sz_bools) & 1) 00121 sz_bools++; */ 00122 00123 if (sz_names + sz_bools + n_nums < actsize) { 00124 /* Offset 13 is defined in /usr/include/term.h, though we do not 00125 * include it here, as it conflicts with include/asterisk/term.h */ 00126 short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2); 00127 if (max_colors > 0) { 00128 vt100compat = 1; 00129 } 00130 parseokay = 1; 00131 } 00132 close(termfd); 00133 } 00134 00135 if (!parseokay) { 00136 /* These comparisons should not be substrings nor case-insensitive, as 00137 * terminal types are very particular about how they treat suffixes and 00138 * capitalization. For example, terminal type 'linux-m' does NOT 00139 * support color, while 'linux' does. Not even all vt100* terminals 00140 * support color, either (e.g. 'vt100+fnkeys'). */ 00141 if (!strcmp(term, "linux")) { 00142 vt100compat = 1; 00143 } else if (!strcmp(term, "xterm")) { 00144 vt100compat = 1; 00145 } else if (!strcmp(term, "xterm-color")) { 00146 vt100compat = 1; 00147 } else if (!strncmp(term, "Eterm", 5)) { 00148 /* Both entries which start with Eterm support color */ 00149 vt100compat = 1; 00150 } else if (!strcmp(term, "vt100")) { 00151 vt100compat = 1; 00152 } else if (!strncmp(term, "crt", 3)) { 00153 /* Both crt terminals support color */ 00154 vt100compat = 1; 00155 } 00156 } 00157 00158 end: 00159 if (vt100compat) { 00160 /* Make commands show up in nice colors */ 00161 if (ast_opt_light_background) { 00162 snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN); 00163 snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK); 00164 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00165 } else if (ast_opt_force_black_background) { 00166 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00167 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00168 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00169 } else { 00170 snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN); 00171 snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE); 00172 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00173 } 00174 } 00175 return 0; 00176 }
int ast_test_init | ( | void | ) |
Provided by test.c
Definition at line 889 of file test.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00890 { 00891 #ifdef TEST_FRAMEWORK 00892 /* Register cli commands */ 00893 ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli)); 00894 #endif 00895 00896 return 0; 00897 }
int ast_timing_init | ( | void | ) |
Provided by timing.c
Definition at line 288 of file timing.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_heap_create(), cli_timing, timing_holder_cmp(), and timing_interfaces.
Referenced by main().
00289 { 00290 if (!(timing_interfaces = ast_heap_create(2, timing_holder_cmp, 0))) { 00291 return -1; 00292 } 00293 00294 return ast_cli_register_multiple(cli_timing, ARRAY_LEN(cli_timing)); 00295 }
int ast_tps_init | ( | void | ) |
Provided by taskprocessor.c
Definition at line 122 of file taskprocessor.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_log(), cli_ping_cond, LOG_ERROR, taskprocessor_clis, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, and tps_singletons.
Referenced by main().
00123 { 00124 if (!(tps_singletons = ao2_container_alloc(TPS_MAX_BUCKETS, tps_hash_cb, tps_cmp_cb))) { 00125 ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n"); 00126 return -1; 00127 } 00128 00129 ast_cond_init(&cli_ping_cond, NULL); 00130 00131 ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis)); 00132 return 0; 00133 }
int ast_xmldoc_load_documentation | ( | void | ) |
int astdb_init | ( | void | ) |
Provided by db.c
Definition at line 759 of file db.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_manager_register_xml, ast_pthread_create_background, cli_database, db_sync_thread(), dbinit(), EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput().
Referenced by main().
00760 { 00761 pthread_t dont_care; 00762 00763 ast_cond_init(&dbcond, NULL); 00764 if (ast_pthread_create_background(&dont_care, NULL, db_sync_thread, NULL)) { 00765 return -1; 00766 } 00767 00768 dbinit(); 00769 ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database)); 00770 ast_manager_register_xml("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget); 00771 ast_manager_register_xml("DBPut", EVENT_FLAG_SYSTEM, manager_dbput); 00772 ast_manager_register_xml("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel); 00773 ast_manager_register_xml("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree); 00774 return 0; 00775 }
int astobj2_init | ( | void | ) |
Provided by astobj2.c
Definition at line 1117 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
01118 { 01119 #ifdef AO2_DEBUG 01120 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 01121 #endif 01122 01123 return 0; 01124 }
void close_logger | ( | void | ) |
Provided by logger.c
Definition at line 1065 of file logger.c.
References ast_cond_signal, AST_LIST_LOCK, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, close_logger_thread, f, logchannel::list, logcond, logthread, and qlog.
Referenced by quit_handler().
01066 { 01067 struct logchannel *f = NULL; 01068 01069 /* Stop logger thread */ 01070 AST_LIST_LOCK(&logmsgs); 01071 close_logger_thread = 1; 01072 ast_cond_signal(&logcond); 01073 AST_LIST_UNLOCK(&logmsgs); 01074 01075 if (logthread != AST_PTHREADT_NULL) 01076 pthread_join(logthread, NULL); 01077 01078 AST_RWLIST_WRLOCK(&logchannels); 01079 01080 if (qlog) { 01081 fclose(qlog); 01082 qlog = NULL; 01083 } 01084 01085 AST_RWLIST_TRAVERSE(&logchannels, f, list) { 01086 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 01087 fclose(f->fileptr); 01088 f->fileptr = NULL; 01089 } 01090 } 01091 01092 closelog(); /* syslog */ 01093 01094 AST_RWLIST_UNLOCK(&logchannels); 01095 01096 return; 01097 }
int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 352 of file dnsmgr.c.
References ast_cli_register(), ast_log(), cli_refresh, cli_reload, cli_status, do_reload(), LOG_ERROR, sched, and sched_context_create().
Referenced by main().
00353 { 00354 if (!(sched = sched_context_create())) { 00355 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00356 return -1; 00357 } 00358 ast_cli_register(&cli_reload); 00359 ast_cli_register(&cli_status); 00360 ast_cli_register(&cli_refresh); 00361 return do_reload(1); 00362 }
int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 364 of file dnsmgr.c.
References do_reload().
00365 { 00366 return do_reload(0); 00367 }
void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 246 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, refresh_list(), and sched.
Referenced by main().
00247 { 00248 if (refresh_sched > -1) { 00249 AST_SCHED_DEL(sched, refresh_sched); 00250 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00251 } 00252 }
int init_framer | ( | void | ) |
Provided by frame.c
Definition at line 981 of file frame.c.
References ARRAY_LEN, ast_cli_register_multiple(), and my_clis.
Referenced by main().
00982 { 00983 ast_cli_register_multiple(my_clis, ARRAY_LEN(my_clis)); 00984 return 0; 00985 }
int init_logger | ( | void | ) |
Provided by logger.c
Definition at line 1042 of file logger.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_destroy, ast_cond_init, ast_config_AST_LOG_DIR, ast_mkdir(), ast_pthread_create, cli_logger, init_logger_chain(), logcond, logger_thread(), and logthread.
Referenced by main().
01043 { 01044 /* auto rotate if sig SIGXFSZ comes a-knockin */ 01045 sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL); 01046 01047 /* start logger thread */ 01048 ast_cond_init(&logcond, NULL); 01049 if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) { 01050 ast_cond_destroy(&logcond); 01051 return -1; 01052 } 01053 01054 /* register the logger cli commands */ 01055 ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger)); 01056 01057 ast_mkdir(ast_config_AST_LOG_DIR, 0777); 01058 01059 /* create log channels */ 01060 init_logger_chain(0 /* locked */); 01061 01062 return 0; 01063 }
int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 996 of file loader.c.
References add_to_load_order(), ast_config_load2(), ast_debug, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, ast_log(), AST_MODULE_CONFIG, ast_variable_browse(), ast_verb, config_flags, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, embedding, LOG_WARNING, ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by main().
00997 { 00998 struct ast_config *cfg; 00999 struct ast_module *mod; 01000 struct load_order_entry *order; 01001 struct ast_variable *v; 01002 unsigned int load_count; 01003 struct load_order load_order; 01004 int res = 0; 01005 struct ast_flags config_flags = { 0 }; 01006 int modulecount = 0; 01007 01008 #ifdef LOADABLE_MODULES 01009 struct dirent *dirent; 01010 DIR *dir; 01011 #endif 01012 01013 /* all embedded modules have registered themselves by now */ 01014 embedding = 0; 01015 01016 ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); 01017 01018 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 01019 01020 AST_LIST_LOCK(&module_list); 01021 01022 if (embedded_module_list.first) { 01023 module_list.first = embedded_module_list.first; 01024 module_list.last = embedded_module_list.last; 01025 embedded_module_list.first = NULL; 01026 } 01027 01028 cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); 01029 if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { 01030 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 01031 goto done; 01032 } 01033 01034 /* first, find all the modules we have been explicitly requested to load */ 01035 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 01036 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 01037 add_to_load_order(v->value, &load_order, 0); 01038 } 01039 if (!strcasecmp(v->name, preload_only ? "preload-require" : "require")) { 01040 /* Add the module to the list and make sure it's required */ 01041 add_to_load_order(v->value, &load_order, 1); 01042 ast_debug(2, "Adding module to required list: %s (%s)\n", v->value, v->name); 01043 } 01044 01045 } 01046 01047 /* check if 'autoload' is on */ 01048 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 01049 /* if so, first add all the embedded modules that are not already running to the load order */ 01050 AST_LIST_TRAVERSE(&module_list, mod, entry) { 01051 /* if it's not embedded, skip it */ 01052 if (mod->lib) 01053 continue; 01054 01055 if (mod->flags.running) 01056 continue; 01057 01058 order = add_to_load_order(mod->resource, &load_order, 0); 01059 } 01060 01061 #ifdef LOADABLE_MODULES 01062 /* if we are allowed to load dynamic modules, scan the directory for 01063 for all available modules and add them as well */ 01064 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 01065 while ((dirent = readdir(dir))) { 01066 int ld = strlen(dirent->d_name); 01067 01068 /* Must end in .so to load it. */ 01069 01070 if (ld < 4) 01071 continue; 01072 01073 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 01074 continue; 01075 01076 /* if there is already a module by this name in the module_list, 01077 skip this file */ 01078 if (find_resource(dirent->d_name, 0)) 01079 continue; 01080 01081 add_to_load_order(dirent->d_name, &load_order, 0); 01082 } 01083 01084 closedir(dir); 01085 } else { 01086 if (!ast_opt_quiet) 01087 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 01088 ast_config_AST_MODULE_DIR); 01089 } 01090 #endif 01091 } 01092 01093 /* now scan the config for any modules we are prohibited from loading and 01094 remove them from the load order */ 01095 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 01096 if (strcasecmp(v->name, "noload")) 01097 continue; 01098 01099 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 01100 if (!resource_name_match(order->resource, v->value)) { 01101 AST_LIST_REMOVE_CURRENT(entry); 01102 ast_free(order->resource); 01103 ast_free(order); 01104 } 01105 } 01106 AST_LIST_TRAVERSE_SAFE_END; 01107 } 01108 01109 /* we are done with the config now, all the information we need is in the 01110 load_order list */ 01111 ast_config_destroy(cfg); 01112 01113 load_count = 0; 01114 AST_LIST_TRAVERSE(&load_order, order, entry) 01115 load_count++; 01116 01117 if (load_count) 01118 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 01119 01120 /* first, load only modules that provide global symbols */ 01121 if ((res = load_resource_list(&load_order, 1, &modulecount)) < 0) { 01122 goto done; 01123 } 01124 01125 /* now load everything else */ 01126 if ((res = load_resource_list(&load_order, 0, &modulecount)) < 0) { 01127 goto done; 01128 } 01129 01130 done: 01131 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 01132 ast_free(order->resource); 01133 ast_free(order); 01134 } 01135 01136 AST_LIST_UNLOCK(&module_list); 01137 01138 /* Tell manager clients that are aggressive at logging in that we're done 01139 loading modules. If there's a DNS problem in chan_sip, we might not 01140 even reach this */ 01141 manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount); 01142 01143 return res; 01144 }
int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 9865 of file pbx.c.
References __ast_custom_function_register(), ARRAY_LEN, ast_cli_register_multiple(), ast_data_register_multiple_core, AST_EVENT_DEVICE_STATE, AST_EVENT_IE_END, ast_event_subscribe(), ast_log(), ast_manager_register_xml, ast_register_application2(), ast_taskprocessor_get(), ast_verb, builtins, device_state_cb(), device_state_sub, device_state_tps, EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, exception_function, LOG_ERROR, LOG_WARNING, manager_show_dialplan(), pbx_cli, pbx_data_providers, and testtime_function.
Referenced by main().
09866 { 09867 int x; 09868 09869 /* Initialize the PBX */ 09870 ast_verb(1, "Asterisk PBX Core Initializing\n"); 09871 if (!(device_state_tps = ast_taskprocessor_get("pbx-core", 0))) { 09872 ast_log(LOG_WARNING, "failed to create pbx-core taskprocessor\n"); 09873 } 09874 09875 ast_verb(1, "Registering builtin applications:\n"); 09876 ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli)); 09877 ast_data_register_multiple_core(pbx_data_providers, ARRAY_LEN(pbx_data_providers)); 09878 __ast_custom_function_register(&exception_function, NULL); 09879 __ast_custom_function_register(&testtime_function, NULL); 09880 09881 /* Register builtin applications */ 09882 for (x = 0; x < ARRAY_LEN(builtins); x++) { 09883 ast_verb(1, "[%s]\n", builtins[x].name); 09884 if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) { 09885 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 09886 return -1; 09887 } 09888 } 09889 09890 /* Register manager application */ 09891 ast_manager_register_xml("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan); 09892 09893 if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, "pbx Device State Change", NULL, 09894 AST_EVENT_IE_END))) { 09895 return -1; 09896 } 09897 09898 return 0; 09899 }
void threadstorage_init | ( | void | ) |