_private.h File Reference

Prototypes for public functions only of internal interest,. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int aco_init (void)
void ast_autoservice_init (void)
int ast_bridging_init (void)
 Initialize the bridging system.
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_endpoint_init (void)
 Endpoint support initialization.
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_local_init (void)
 Initialize the local proxy channel.
int ast_msg_init (void)
void ast_msg_shutdown (void)
int ast_parking_stasis_init (void)
 initializes the rtp engine arrays
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_rtp_engine_init (void)
 initializes the rtp engine arrays
int ast_sounds_index_init (void)
 initialize the sounds index
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 clean_time_zones (void)
void close_logger (void)
int dnsmgr_init (void)
int dnsmgr_reload (void)
void dnsmgr_start_refresh (void)
int init_logger (void)
int load_modules (unsigned int)
int load_pbx (void)
void logger_queue_start (void)
 Start the ast_queue_log() logger.
void threadstorage_init (void)


Detailed Description

Prototypes for public functions only of internal interest,.

Definition in file _private.h.


Function Documentation

int aco_init ( void   ) 

Provided by config_options.c

Definition at line 1281 of file config_options.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_log, ast_register_cleanup(), and LOG_ERROR.

Referenced by main().

01282 {
01283 #ifdef AST_XML_DOCS
01284    ast_register_cleanup(aco_deinit);
01285    if (!(xmldocs = ast_xmldoc_build_documentation("configInfo"))) {
01286       ast_log(LOG_ERROR, "Couldn't build config documentation\n");
01287       return -1;
01288    }
01289    ast_cli_register_multiple(cli_aco, ARRAY_LEN(cli_aco));
01290 #endif /* AST_XML_DOCS */
01291    return 0;
01292 }

void ast_autoservice_init ( void   ) 

Provided by autoservice.c

Definition at line 356 of file autoservice.c.

References as_cond, ast_cond_init, ast_register_cleanup(), autoservice_shutdown(), and NULL.

Referenced by main().

int ast_bridging_init ( void   ) 

Initialize the bridging system.

Since:
12.0.0
Return values:
0 on success.
-1 on error.

Definition at line 5271 of file bridge.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_container_alloc_rbtree, ao2_container_register(), ARRAY_LEN, ast_bridging_init_basic(), ast_cli_register_multiple(), ast_manager_register_xml_core, ast_register_cleanup(), ast_stasis_bridging_init(), bridge_cleanup(), bridge_manager, bridge_manager_create(), bridge_prnt_obj(), bridge_sort_cmp(), manager_bridge_tech_list(), manager_bridge_tech_suspend(), manager_bridge_tech_unsuspend(), and NULL.

Referenced by main().

05272 {
05273    ast_register_cleanup(bridge_cleanup);
05274 
05275    if (ast_stasis_bridging_init()) {
05276       return -1;
05277    }
05278 
05279    bridge_manager = bridge_manager_create();
05280    if (!bridge_manager) {
05281       return -1;
05282    }
05283 
05284    bridges = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_MUTEX,
05285       AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, bridge_sort_cmp, NULL);
05286    if (!bridges) {
05287       return -1;
05288    }
05289    ao2_container_register("bridges", bridges, bridge_prnt_obj);
05290 
05291    ast_bridging_init_basic();
05292 
05293    ast_cli_register_multiple(bridge_cli, ARRAY_LEN(bridge_cli));
05294 
05295    ast_manager_register_xml_core("BridgeTechnologyList", 0, manager_bridge_tech_list);
05296    ast_manager_register_xml_core("BridgeTechnologySuspend", 0, manager_bridge_tech_suspend);
05297    ast_manager_register_xml_core("BridgeTechnologyUnsuspend", 0, manager_bridge_tech_unsuspend);
05298 
05299    return 0;
05300 }

void ast_builtins_init ( void   ) 

initialize the _full_cmd string in * each of the builtins.

Provided by cli.c

Definition at line 2026 of file main/cli.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_register_cleanup(), and cli_shutdown().

Referenced by main().

int ast_cel_engine_init ( void   ) 

Provided by cel.c

Definition at line 1696 of file cel.c.

References ACO_EXACT, aco_info_init(), aco_option_register, aco_option_register_custom, aco_process_config(), aco_set_defaults(), ao2_cleanup, ao2_container_alloc, ao2_global_obj_replace_unref, ao2_ref, apps_handler(), ast_cel_check_enabled(), ast_cli_register(), ast_log, ast_register_cleanup(), BACKEND_BUCKETS, cel_backend_cmp(), cel_backend_hash(), cel_config_alloc(), cel_engine_cleanup(), cel_generic_type(), container, create_routes(), create_subscriptions(), date_format, dialstatus_cmp(), dialstatus_hash(), events_handler(), FLDSET, cel_config::general, lid_cmp(), lid_hash(), LOG_NOTICE, NUM_APP_BUCKETS, NUM_DIALSTATUS_BUCKETS, OPT_BOOL_T, OPT_STRINGFIELD_T, STASIS_MESSAGE_TYPE_INIT, and STRFLDSET.

Referenced by main().

01697 {
01698    struct ao2_container *container;
01699 
01700    container = ao2_container_alloc(NUM_APP_BUCKETS, lid_hash, lid_cmp);
01701    ao2_global_obj_replace_unref(cel_linkedids, container);
01702    ao2_cleanup(container);
01703    if (!container) {
01704       cel_engine_cleanup();
01705       return -1;
01706    }
01707 
01708    container = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS,
01709       dialstatus_hash, dialstatus_cmp);
01710    ao2_global_obj_replace_unref(cel_dialstatus_store, container);
01711    ao2_cleanup(container);
01712    if (!container) {
01713       cel_engine_cleanup();
01714       return -1;
01715    }
01716 
01717    if (STASIS_MESSAGE_TYPE_INIT(cel_generic_type)) {
01718       cel_engine_cleanup();
01719       return -1;
01720    }
01721 
01722    if (ast_cli_register(&cli_status)) {
01723       cel_engine_cleanup();
01724       return -1;
01725    }
01726 
01727    container = ao2_container_alloc(BACKEND_BUCKETS, cel_backend_hash, cel_backend_cmp);
01728    ao2_global_obj_replace_unref(cel_backends, container);
01729    ao2_cleanup(container);
01730    if (!container) {
01731       cel_engine_cleanup();
01732       return -1;
01733    }
01734 
01735    if (aco_info_init(&cel_cfg_info)) {
01736       cel_engine_cleanup();
01737       return -1;
01738    }
01739 
01740    aco_option_register(&cel_cfg_info, "enable", ACO_EXACT, general_options, "no", OPT_BOOL_T, 1, FLDSET(struct ast_cel_general_config, enable));
01741    aco_option_register(&cel_cfg_info, "dateformat", ACO_EXACT, general_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_cel_general_config, date_format));
01742    aco_option_register_custom(&cel_cfg_info, "apps", ACO_EXACT, general_options, "", apps_handler, 0);
01743    aco_option_register_custom(&cel_cfg_info, "events", ACO_EXACT, general_options, "", events_handler, 0);
01744 
01745    if (aco_process_config(&cel_cfg_info, 0)) {
01746       struct cel_config *cel_cfg = cel_config_alloc();
01747 
01748       if (!cel_cfg) {
01749          cel_engine_cleanup();
01750          return -1;
01751       }
01752 
01753       /* We couldn't process the configuration so create a default config. */
01754       if (!aco_set_defaults(&general_option, "general", cel_cfg->general)) {
01755          ast_log(LOG_NOTICE, "Failed to process CEL configuration; using defaults\n");
01756          ao2_global_obj_replace_unref(cel_configs, cel_cfg);
01757       }
01758       ao2_ref(cel_cfg, -1);
01759    }
01760 
01761    if (create_subscriptions()) {
01762       cel_engine_cleanup();
01763       return -1;
01764    }
01765 
01766    if (ast_cel_check_enabled() && create_routes()) {
01767       cel_engine_cleanup();
01768       return -1;
01769    }
01770 
01771    ast_register_cleanup(cel_engine_cleanup);
01772    return 0;
01773 }

int ast_cel_engine_reload ( void   ) 

Provided by cel.c

Definition at line 1775 of file cel.c.

References aco_process_config(), ACO_PROCESS_ERROR, ast_cel_check_enabled(), ast_verb, create_routes(), destroy_routes(), and is_enabled().

01776 {
01777    unsigned int was_enabled = ast_cel_check_enabled();
01778    unsigned int is_enabled;
01779 
01780    if (aco_process_config(&cel_cfg_info, 1) == ACO_PROCESS_ERROR) {
01781       return -1;
01782    }
01783 
01784    is_enabled = ast_cel_check_enabled();
01785 
01786    if (!was_enabled && is_enabled) {
01787       if (create_routes()) {
01788          return -1;
01789       }
01790    } else if (was_enabled && !is_enabled) {
01791       destroy_routes();
01792    }
01793 
01794    ast_verb(3, "CEL logging %sabled.\n", is_enabled ? "en" : "dis");
01795 
01796    return 0;
01797 }

void ast_channels_init ( void   ) 

int ast_cli_perms_init ( int  reload  ) 

Provided by cli.c

Definition at line 1898 of file main/cli.c.

References ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_free, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log, ast_mutex_trylock, ast_mutex_unlock, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strlen_zero, ast_variable_browse(), cli_perm::command, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEUNCHANGED, destroy_user_perms(), usergroup_cli_perm::gid, LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, cli_perm::permit, usergroup_cli_perm::perms, perms_config, usergroup_cli_perm::uid, and ast_variable::value.

Referenced by handle_cli_reload_permissions(), and main().

01899 {
01900    struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
01901    struct ast_config *cfg;
01902    char *cat = NULL;
01903    struct ast_variable *v;
01904    struct usergroup_cli_perm *user_group, *cp_entry;
01905    struct cli_perm *perm = NULL;
01906    struct passwd *pw;
01907    struct group *gr;
01908 
01909    if (ast_mutex_trylock(&permsconfiglock)) {
01910       ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n");
01911       return 1;
01912    }
01913 
01914    cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags);
01915    if (!cfg) {
01916       ast_mutex_unlock(&permsconfiglock);
01917       return 1;
01918    } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
01919       ast_mutex_unlock(&permsconfiglock);
01920       return 0;
01921    }
01922 
01923    /* free current structures. */
01924    destroy_user_perms();
01925 
01926    while ((cat = ast_category_browse(cfg, cat))) {
01927       if (!strcasecmp(cat, "general")) {
01928          /* General options */
01929          for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
01930             if (!strcasecmp(v->name, "default_perm")) {
01931                cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0;
01932             }
01933          }
01934          continue;
01935       }
01936 
01937       /* users or groups */
01938       gr = NULL, pw = NULL;
01939       if (cat[0] == '@') {
01940          /* This is a group */
01941          gr = getgrnam(&cat[1]);
01942          if (!gr) {
01943             ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]);
01944             continue;
01945          }
01946       } else {
01947          /* This is a user */
01948          pw = getpwnam(cat);
01949          if (!pw) {
01950             ast_log (LOG_WARNING, "Unknown user '%s'\n", cat);
01951             continue;
01952          }
01953       }
01954       user_group = NULL;
01955       /* Check for duplicates */
01956       AST_RWLIST_WRLOCK(&cli_perms);
01957       AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) {
01958          if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) {
01959             /* if it is duplicated, just added this new settings, to
01960             the current list. */
01961             user_group = cp_entry;
01962             break;
01963          }
01964       }
01965       AST_RWLIST_UNLOCK(&cli_perms);
01966 
01967       if (!user_group) {
01968          /* alloc space for the new user config. */
01969          user_group = ast_calloc(1, sizeof(*user_group));
01970          if (!user_group) {
01971             continue;
01972          }
01973          user_group->uid = (pw ? pw->pw_uid : -1);
01974          user_group->gid = (gr ? gr->gr_gid : -1);
01975          user_group->perms = ast_calloc(1, sizeof(*user_group->perms));
01976          if (!user_group->perms) {
01977             ast_free(user_group);
01978             continue;
01979          }
01980       }
01981       for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
01982          if (ast_strlen_zero(v->value)) {
01983             /* we need to check this condition cause it could break security. */
01984             ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat);
01985             continue;
01986          }
01987          if (!strcasecmp(v->name, "permit")) {
01988             perm = ast_calloc(1, sizeof(*perm));
01989             if (perm) {
01990                perm->permit = 1;
01991                perm->command = ast_strdup(v->value);
01992             }
01993          } else if (!strcasecmp(v->name, "deny")) {
01994             perm = ast_calloc(1, sizeof(*perm));
01995             if (perm) {
01996                perm->permit = 0;
01997                perm->command = ast_strdup(v->value);
01998             }
01999          } else {
02000             /* up to now, only 'permit' and 'deny' are possible values. */
02001             ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name);
02002             continue;
02003          }
02004          if (perm) {
02005             /* Added the permission to the user's list. */
02006             AST_LIST_INSERT_TAIL(user_group->perms, perm, list);
02007             perm = NULL;
02008          }
02009       }
02010       AST_RWLIST_WRLOCK(&cli_perms);
02011       AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list);
02012       AST_RWLIST_UNLOCK(&cli_perms);
02013    }
02014 
02015    ast_config_destroy(cfg);
02016    ast_mutex_unlock(&permsconfiglock);
02017    return 0;
02018 }

int ast_data_init ( void   ) 

Provided by data.c

Definition at line 3328 of file data.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_manager_register_xml_core, ast_register_cleanup(), ast_rwlock_init, AST_TEST_REGISTER, cli_data, data_provider_cmp(), data_provider_hash(), data_shutdown(), manager_data_get(), NUM_DATA_NODE_BUCKETS, and root_data.

Referenced by main().

03329 {
03330    int res = 0;
03331 
03332    ast_rwlock_init(&root_data.lock);
03333 
03334    if (!(root_data.container = ao2_container_alloc(NUM_DATA_NODE_BUCKETS,
03335       data_provider_hash, data_provider_cmp))) {
03336       return -1;
03337    }
03338 
03339    res |= ast_cli_register_multiple(cli_data, ARRAY_LEN(cli_data));
03340 
03341    res |= ast_manager_register_xml_core("DataGet", 0, manager_data_get);
03342 
03343    AST_TEST_REGISTER(test_data_get);
03344 
03345    ast_register_cleanup(data_shutdown);
03346 
03347    return res;
03348 }

int ast_device_state_engine_init ( void   ) 

Initialize the device state engine in separate thread.

Provided by devicestate.c

Definition at line 621 of file devicestate.c.

References ast_cond_init, ast_log, ast_pthread_create_background, change_pending, change_thread, do_devstate_changes(), LOG_ERROR, and NULL.

Referenced by main().

00622 {
00623    ast_cond_init(&change_pending, NULL);
00624    if (ast_pthread_create_background(&change_thread, NULL, do_devstate_changes, NULL) < 0) {
00625       ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
00626       return -1;
00627    }
00628 
00629    return 0;
00630 }

int ast_endpoint_init ( void   ) 

Endpoint support initialization.

Returns:
0 on success.

Non-zero on error.

Definition at line 508 of file endpoints.c.

References ao2_container_alloc, ast_register_cleanup(), ENDPOINT_BUCKETS, endpoint_cleanup(), endpoint_cmp(), endpoint_hash(), and TECH_ENDPOINT_BUCKETS.

Referenced by main().

00509 {
00510    ast_register_cleanup(endpoint_cleanup);
00511 
00512    endpoints = ao2_container_alloc(ENDPOINT_BUCKETS, endpoint_hash,
00513       endpoint_cmp);
00514    if (!endpoints) {
00515       return -1;
00516    }
00517 
00518    tech_endpoints = ao2_container_alloc(TECH_ENDPOINT_BUCKETS, endpoint_hash,
00519       endpoint_cmp);
00520    if (!tech_endpoints) {
00521       return -1;
00522    }
00523 
00524    return 0;
00525 }

int ast_features_init ( void   ) 

Provided by features.c

Definition at line 1168 of file features.c.

References action_bridge(), ast_features_config_init(), ast_manager_register_xml_core, ast_register_application2(), ast_register_cleanup(), bridge_exec(), EVENT_FLAG_CALL, features_shutdown(), and NULL.

Referenced by main().

01169 {
01170    int res;
01171 
01172    res = ast_features_config_init();
01173    if (res) {
01174       return res;
01175    }
01176    res |= ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL);
01177    res |= ast_manager_register_xml_core("Bridge", EVENT_FLAG_CALL, action_bridge);
01178 
01179    if (res) {
01180       features_shutdown();
01181    } else {
01182       ast_register_cleanup(features_shutdown);
01183    }
01184 
01185    return res;
01186 }

int ast_file_init ( void   ) 

Provided by file.c

Definition at line 1778 of file file.c.

Referenced by main().

int ast_http_init ( void   ) 

int ast_http_reload ( void   ) 

Provided by http.c

Definition at line 2304 of file http.c.

References __ast_http_load().

02305 {
02306    return __ast_http_load(1);
02307 }

int ast_indications_init ( void   ) 

Load indications module.

Provided by indications.c

Definition at line 1174 of file indications.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_register_cleanup(), ast_tone_zone_cmp(), ast_tone_zone_hash(), indications_shutdown(), load_indications(), and NUM_TONE_ZONE_BUCKETS.

Referenced by main().

01175 {
01176    if (!(ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS,
01177          ast_tone_zone_hash, ast_tone_zone_cmp))) {
01178       return -1;
01179    }
01180 
01181    if (load_indications(0)) {
01182       indications_shutdown();
01183       return -1;
01184    }
01185 
01186    ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications));
01187 
01188    ast_register_cleanup(indications_shutdown);
01189    return 0;
01190 }

int ast_indications_reload ( void   ) 

Reload indications module.

Provided by indications.c

Definition at line 1193 of file indications.c.

References load_indications().

01194 {
01195    return load_indications(1);
01196 }

int ast_local_init ( void   ) 

Initialize the local proxy channel.

Since:
12.0.0
Return values:
0 on success.
-1 on error.

Definition at line 1017 of file core_local.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_cleanup, ao2_container_alloc_list, ao2_ref, ARRAY_LEN, ast_channel_register(), ast_cli_register_multiple(), ast_format_cap_alloc, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_log, ast_manager_register_xml_core, AST_MEDIA_TYPE_UNKNOWN, ast_register_cleanup(), ast_channel_tech::capabilities, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, local_shutdown(), locals_cmp_cb(), LOG_ERROR, manager_optimize_away(), NULL, and STASIS_MESSAGE_TYPE_INIT.

Referenced by main().

01018 {
01019 
01020    if (STASIS_MESSAGE_TYPE_INIT(ast_local_optimization_begin_type)) {
01021       return -1;
01022    }
01023 
01024    if (STASIS_MESSAGE_TYPE_INIT(ast_local_optimization_end_type)) {
01025       return -1;
01026    }
01027 
01028    if (STASIS_MESSAGE_TYPE_INIT(ast_local_bridge_type)) {
01029       return -1;
01030    }
01031 
01032    if (!(local_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
01033       return -1;
01034    }
01035    ast_format_cap_append_by_type(local_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
01036 
01037    locals = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, locals_cmp_cb);
01038    if (!locals) {
01039       ao2_cleanup(local_tech.capabilities);
01040       local_tech.capabilities = NULL;
01041       return -1;
01042    }
01043 
01044    /* Make sure we can register our channel type */
01045    if (ast_channel_register(&local_tech)) {
01046       ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
01047       ao2_ref(locals, -1);
01048       ao2_cleanup(local_tech.capabilities);
01049       local_tech.capabilities = NULL;
01050       return -1;
01051    }
01052    ast_cli_register_multiple(cli_local, ARRAY_LEN(cli_local));
01053    ast_manager_register_xml_core("LocalOptimizeAway", EVENT_FLAG_SYSTEM|EVENT_FLAG_CALL, manager_optimize_away);
01054 
01055    ast_register_cleanup(local_shutdown);
01056    return 0;
01057 }

int ast_msg_init ( void   ) 

Provided by message.c

Definition at line 1493 of file message.c.

References __ast_custom_function_register(), action_messagesend(), ast_manager_register_xml_core, ast_msg_handler_register(), ast_register_application2(), ast_register_cleanup(), ast_rwlock_init, ast_taskprocessor_get(), AST_VECTOR_INIT, EVENT_FLAG_MESSAGE, message_shutdown(), msg_send_exec(), NULL, and TPS_REF_DEFAULT.

Referenced by main().

01494 {
01495    int res;
01496 
01497    msg_q_tp = ast_taskprocessor_get("ast_msg_queue", TPS_REF_DEFAULT);
01498    if (!msg_q_tp) {
01499       return -1;
01500    }
01501 
01502    ast_rwlock_init(&msg_techs_lock);
01503    if (AST_VECTOR_INIT(&msg_techs, 8)) {
01504       return -1;
01505    }
01506 
01507    ast_rwlock_init(&msg_handlers_lock);
01508    if (AST_VECTOR_INIT(&msg_handlers, 4)) {
01509       return -1;
01510    }
01511 
01512    res = ast_msg_handler_register(&dialplan_msg_handler);
01513 
01514    res |= __ast_custom_function_register(&msg_function, NULL);
01515    res |= __ast_custom_function_register(&msg_data_function, NULL);
01516    res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL);
01517    res |= ast_manager_register_xml_core("MessageSend", EVENT_FLAG_MESSAGE, action_messagesend);
01518 
01519    ast_register_cleanup(message_shutdown);
01520 
01521    return res;
01522 }

void ast_msg_shutdown ( void   ) 

Provided by message.c

Definition at line 1452 of file message.c.

References ast_taskprocessor_unreference().

Referenced by can_safely_quit().

01453 {
01454    if (msg_q_tp) {
01455       msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
01456    }
01457 }

int ast_parking_stasis_init ( void   ) 

initializes the rtp engine arrays

Since:
12.0.0

Definition at line 55 of file parking.c.

References ast_parked_call_type(), ast_register_cleanup(), parking_stasis_cleanup(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by main().

00056 {
00057    if (STASIS_MESSAGE_TYPE_INIT(ast_parked_call_type)) {
00058       return -1;
00059    }
00060 
00061    parking_topic = stasis_topic_create("ast_parking");
00062    if (!parking_topic) {
00063       return -1;
00064    }
00065    ast_register_cleanup(parking_stasis_cleanup);
00066    return 0;
00067 }

int ast_plc_reload ( void   ) 

Reload genericplc configuration value from codecs.conf.

Implementation is in main/channel.c

Definition at line 7436 of file channel.c.

References ast_config_destroy(), ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_variable::value, and var.

Referenced by ast_channels_init().

07437 {
07438    struct ast_variable *var;
07439    struct ast_flags config_flags = { 0 };
07440    struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
07441    if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
07442       return 0;
07443    for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
07444       if (!strcasecmp(var->name, "genericplc")) {
07445          ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
07446       }
07447    }
07448    ast_config_destroy(cfg);
07449    return 0;
07450 }

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.

Note:
This function will do nothing if the server has not completely started up. Once called, the reload queue is emptied, and further invocations will have no affect.

Definition at line 771 of file loader.c.

References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log, ast_module_reload(), do_full_reload, item, LOG_NOTICE, reload_queue_item::module, modules_loaded, and NULL.

Referenced by main().

00772 {
00773    struct reload_queue_item *item;
00774 
00775    modules_loaded = 1;
00776 
00777    AST_LIST_LOCK(&reload_queue);
00778 
00779    if (do_full_reload) {
00780       do_full_reload = 0;
00781       AST_LIST_UNLOCK(&reload_queue);
00782       ast_log(LOG_NOTICE, "Executing deferred reload request.\n");
00783       ast_module_reload(NULL);
00784       return;
00785    }
00786 
00787    while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) {
00788       ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module);
00789       ast_module_reload(item->module);
00790       ast_free(item);
00791    }
00792 
00793    AST_LIST_UNLOCK(&reload_queue);
00794 }

int ast_rtp_engine_init ( void   ) 

initializes the rtp engine arrays

Definition at line 2084 of file rtp_engine.c.

References add_static_payload(), ast_format_adpcm, ast_format_alaw, ast_format_g719, ast_format_g722, ast_format_g723, ast_format_g726, ast_format_g726_aal2, ast_format_g729, ast_format_gsm, ast_format_h261, ast_format_h263, ast_format_h263p, ast_format_h264, ast_format_ilbc, ast_format_jpeg, ast_format_lpc10, ast_format_mp4, ast_format_opus, ast_format_png, ast_format_siren14, ast_format_siren7, ast_format_slin, ast_format_slin12, ast_format_slin16, ast_format_slin192, ast_format_slin24, ast_format_slin32, ast_format_slin44, ast_format_slin48, ast_format_slin96, ast_format_speex, ast_format_speex16, ast_format_speex32, ast_format_t140, ast_format_t140_red, ast_format_ulaw, ast_format_vp8, ast_register_cleanup(), AST_RTP_CISCO_DTMF, AST_RTP_CN, AST_RTP_DTMF, ast_rtp_rtcp_received_type(), ast_rtp_rtcp_sent_type(), ast_rwlock_init, NULL, rtp_engine_shutdown(), set_next_mime_type(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by main().

02085 {
02086    ast_rwlock_init(&mime_types_lock);
02087    ast_rwlock_init(&static_RTP_PT_lock);
02088 
02089    rtp_topic = stasis_topic_create("rtp_topic");
02090    if (!rtp_topic) {
02091       return -1;
02092    }
02093    STASIS_MESSAGE_TYPE_INIT(ast_rtp_rtcp_sent_type);
02094    STASIS_MESSAGE_TYPE_INIT(ast_rtp_rtcp_received_type);
02095    ast_register_cleanup(rtp_engine_shutdown);
02096 
02097    /* Define all the RTP mime types available */
02098    set_next_mime_type(ast_format_g723, 0, "audio", "G723", 8000);
02099    set_next_mime_type(ast_format_gsm, 0, "audio", "GSM", 8000);
02100    set_next_mime_type(ast_format_ulaw, 0, "audio", "PCMU", 8000);
02101    set_next_mime_type(ast_format_ulaw, 0, "audio", "G711U", 8000);
02102    set_next_mime_type(ast_format_alaw, 0, "audio", "PCMA", 8000);
02103    set_next_mime_type(ast_format_alaw, 0, "audio", "G711A", 8000);
02104    set_next_mime_type(ast_format_g726, 0, "audio", "G726-32", 8000);
02105    set_next_mime_type(ast_format_adpcm, 0, "audio", "DVI4", 8000);
02106    set_next_mime_type(ast_format_slin, 0, "audio", "L16", 8000);
02107    set_next_mime_type(ast_format_slin16, 0, "audio", "L16", 16000);
02108    set_next_mime_type(ast_format_slin16, 0, "audio", "L16-256", 16000);
02109    set_next_mime_type(ast_format_slin12, 0, "audio", "L16", 12000);
02110    set_next_mime_type(ast_format_slin24, 0, "audio", "L16", 24000);
02111    set_next_mime_type(ast_format_slin32, 0, "audio", "L16", 32000);
02112    set_next_mime_type(ast_format_slin44, 0, "audio", "L16", 44000);
02113    set_next_mime_type(ast_format_slin48, 0, "audio", "L16", 48000);
02114    set_next_mime_type(ast_format_slin96, 0, "audio", "L16", 96000);
02115    set_next_mime_type(ast_format_slin192, 0, "audio", "L16", 192000);
02116    set_next_mime_type(ast_format_lpc10, 0, "audio", "LPC", 8000);
02117    set_next_mime_type(ast_format_g729, 0, "audio", "G729", 8000);
02118    set_next_mime_type(ast_format_g729, 0, "audio", "G729A", 8000);
02119    set_next_mime_type(ast_format_g729, 0, "audio", "G.729", 8000);
02120    set_next_mime_type(ast_format_speex, 0, "audio", "speex", 8000);
02121    set_next_mime_type(ast_format_speex16, 0,  "audio", "speex", 16000);
02122    set_next_mime_type(ast_format_speex32, 0,  "audio", "speex", 32000);
02123    set_next_mime_type(ast_format_ilbc, 0, "audio", "iLBC", 8000);
02124    /* this is the sample rate listed in the RTP profile for the G.722 codec, *NOT* the actual sample rate of the media stream */
02125    set_next_mime_type(ast_format_g722, 0, "audio", "G722", 8000);
02126    set_next_mime_type(ast_format_g726_aal2, 0, "audio", "AAL2-G726-32", 8000);
02127    set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 8000);
02128    set_next_mime_type(NULL, AST_RTP_CISCO_DTMF, "audio", "cisco-telephone-event", 8000);
02129    set_next_mime_type(NULL, AST_RTP_CN, "audio", "CN", 8000);
02130    set_next_mime_type(ast_format_jpeg, 0, "video", "JPEG", 90000);
02131    set_next_mime_type(ast_format_png, 0, "video", "PNG", 90000);
02132    set_next_mime_type(ast_format_h261, 0, "video", "H261", 90000);
02133    set_next_mime_type(ast_format_h263, 0, "video", "H263", 90000);
02134    set_next_mime_type(ast_format_h263p, 0, "video", "h263-1998", 90000);
02135    set_next_mime_type(ast_format_h264, 0, "video", "H264", 90000);
02136    set_next_mime_type(ast_format_mp4, 0, "video", "MP4V-ES", 90000);
02137    set_next_mime_type(ast_format_t140_red, 0, "text", "RED", 1000);
02138    set_next_mime_type(ast_format_t140, 0, "text", "T140", 1000);
02139    set_next_mime_type(ast_format_siren7, 0, "audio", "G7221", 16000);
02140    set_next_mime_type(ast_format_siren14, 0, "audio", "G7221", 32000);
02141    set_next_mime_type(ast_format_g719, 0, "audio", "G719", 48000);
02142    /* Opus and VP8 */
02143    set_next_mime_type(ast_format_opus, 0,  "audio", "opus", 48000);
02144    set_next_mime_type(ast_format_vp8, 0,  "video", "VP8", 90000);
02145 
02146    /* Define the static rtp payload mappings */
02147    add_static_payload(0, ast_format_ulaw, 0);
02148    #ifdef USE_DEPRECATED_G726
02149    add_static_payload(2, ast_format_g726, 0);/* Technically this is G.721, but if Cisco can do it, so can we... */
02150    #endif
02151    add_static_payload(3, ast_format_gsm, 0);
02152    add_static_payload(4, ast_format_g723, 0);
02153    add_static_payload(5, ast_format_adpcm, 0);/* 8 kHz */
02154    add_static_payload(6, ast_format_adpcm, 0); /* 16 kHz */
02155    add_static_payload(7, ast_format_lpc10, 0);
02156    add_static_payload(8, ast_format_alaw, 0);
02157    add_static_payload(9, ast_format_g722, 0);
02158    add_static_payload(10, ast_format_slin, 0); /* 2 channels */
02159    add_static_payload(11, ast_format_slin, 0); /* 1 channel */
02160    add_static_payload(13, NULL, AST_RTP_CN);
02161    add_static_payload(16, ast_format_adpcm, 0); /* 11.025 kHz */
02162    add_static_payload(17, ast_format_adpcm, 0); /* 22.050 kHz */
02163    add_static_payload(18, ast_format_g729, 0);
02164    add_static_payload(19, NULL, AST_RTP_CN);         /* Also used for CN */
02165    add_static_payload(26, ast_format_jpeg, 0);
02166    add_static_payload(31, ast_format_h261, 0);
02167    add_static_payload(34, ast_format_h263, 0);
02168    add_static_payload(97, ast_format_ilbc, 0);
02169    add_static_payload(98, ast_format_h263p, 0);
02170    add_static_payload(99, ast_format_h264, 0);
02171    add_static_payload(101, NULL, AST_RTP_DTMF);
02172    add_static_payload(102, ast_format_siren7, 0);
02173    add_static_payload(103, ast_format_h263p, 0);
02174    add_static_payload(104, ast_format_mp4, 0);
02175    add_static_payload(105, ast_format_t140_red, 0);   /* Real time text chat (with redundancy encoding) */
02176    add_static_payload(106, ast_format_t140, 0);     /* Real time text chat */
02177    add_static_payload(110, ast_format_speex, 0);
02178    add_static_payload(111, ast_format_g726, 0);
02179    add_static_payload(112, ast_format_g726_aal2, 0);
02180    add_static_payload(115, ast_format_siren14, 0);
02181    add_static_payload(116, ast_format_g719, 0);
02182    add_static_payload(117, ast_format_speex16, 0);
02183    add_static_payload(118, ast_format_slin16, 0); /* 16 Khz signed linear */
02184    add_static_payload(119, ast_format_speex32, 0);
02185    add_static_payload(121, NULL, AST_RTP_CISCO_DTMF);   /* Must be type 121 */
02186    add_static_payload(122, ast_format_slin12, 0);
02187    add_static_payload(123, ast_format_slin24, 0);
02188    add_static_payload(124, ast_format_slin32, 0);
02189    add_static_payload(125, ast_format_slin44, 0);
02190    add_static_payload(126, ast_format_slin48, 0);
02191    add_static_payload(127, ast_format_slin96, 0);
02192    /* payload types above 127 are not valid */
02193    add_static_payload(96, ast_format_slin192, 0);
02194    /* Opus and VP8 */
02195    add_static_payload(100, ast_format_vp8, 0);
02196    add_static_payload(107, ast_format_opus, 0);
02197 
02198    return 0;
02199 }

int ast_sounds_index_init ( void   ) 

initialize the sounds index

Definition at line 291 of file sounds_index.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_format_register_type(), ast_format_unregister_type(), ast_register_cleanup(), ast_sounds_reindex(), ast_system_topic(), format_update_cb(), NULL, sounds_cleanup(), stasis_message_router_add(), and stasis_message_router_create().

Referenced by main().

00292 {
00293    int res = 0;
00294    sounds_index = NULL;
00295    if (ast_sounds_reindex()) {
00296       return -1;
00297    }
00298    res |= ast_cli_register_multiple(cli_sounds, ARRAY_LEN(cli_sounds));
00299 
00300    sounds_system_router = stasis_message_router_create(ast_system_topic());
00301    if (!sounds_system_router) {
00302       return -1;
00303    }
00304 
00305    if (ast_format_register_type()) {
00306       res |= stasis_message_router_add(
00307          sounds_system_router,
00308          ast_format_register_type(),
00309          format_update_cb,
00310          NULL);
00311    }
00312 
00313    if (ast_format_unregister_type()) {
00314       res |= stasis_message_router_add(
00315          sounds_system_router,
00316          ast_format_unregister_type(),
00317          format_update_cb,
00318          NULL);
00319    }
00320 
00321    if (res) {
00322       return -1;
00323    }
00324 
00325    ast_register_cleanup(sounds_cleanup);
00326    return 0;
00327 }

int ast_ssl_init ( void   ) 

Provided by ssl.c

Definition at line 152 of file libasteriskssl.c.

References ast_calloc, ast_debug, ast_mutex_init, and NULL.

Referenced by main().

00153 {
00154 #ifdef HAVE_OPENSSL
00155    unsigned int i;
00156    int (*real_SSL_library_init)(void);
00157    void (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
00158    void (*real_CRYPTO_set_locking_callback)(void (*)(int, int, const char *, int));
00159    void (*real_SSL_load_error_strings)(void);
00160    void (*real_ERR_load_SSL_strings)(void);
00161    void (*real_ERR_load_BIO_strings)(void);
00162    const char *errstr;
00163 
00164    /* clear any previous dynamic linker errors */
00165    dlerror();
00166    get_OpenSSL_function(SSL_library_init);
00167    if ((errstr = dlerror()) != NULL) {
00168       ast_debug(1, "unable to get real address of SSL_library_init: %s\n", errstr);
00169       /* there is no way to continue in this situation... SSL will
00170        * likely be broken in this process
00171        */
00172       return -1;
00173    } else {
00174       real_SSL_library_init();
00175    }
00176 
00177    /* Make OpenSSL usage thread-safe. */
00178 
00179    dlerror();
00180    get_OpenSSL_function(CRYPTO_set_id_callback);
00181    if ((errstr = dlerror()) != NULL) {
00182       ast_debug(1, "unable to get real address of CRYPTO_set_id_callback: %s\n", errstr);
00183       /* there is no way to continue in this situation... SSL will
00184        * likely be broken in this process
00185        */
00186       return -1;
00187    } else {
00188       real_CRYPTO_set_id_callback(ssl_threadid);
00189    }
00190 
00191    dlerror();
00192    get_OpenSSL_function(CRYPTO_set_locking_callback);
00193    if ((errstr = dlerror()) != NULL) {
00194       ast_debug(1, "unable to get real address of CRYPTO_set_locking_callback: %s\n", errstr);
00195       /* there is no way to continue in this situation... SSL will
00196        * likely be broken in this process
00197        */
00198       return -1;
00199    } else {
00200       ssl_num_locks = CRYPTO_num_locks();
00201       if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) {
00202          return -1;
00203       }
00204       for (i = 0; i < ssl_num_locks; i++) {
00205          ast_mutex_init(&ssl_locks[i]);
00206       }
00207       real_CRYPTO_set_locking_callback(ssl_lock);
00208    }
00209 
00210    /* after this point, we don't check for errors from the dlsym() calls,
00211     * under the assumption that if the ones above were successful, all
00212     * the rest will be too. this assumption holds as long as OpenSSL still
00213     * provides all of these functions.
00214     */
00215 
00216    get_OpenSSL_function(SSL_load_error_strings);
00217    real_SSL_load_error_strings();
00218 
00219    get_OpenSSL_function(ERR_load_SSL_strings);
00220    real_ERR_load_SSL_strings();
00221 
00222    get_OpenSSL_function(ERR_load_BIO_strings);
00223    real_ERR_load_BIO_strings();
00224 
00225    startup_complete = 1;
00226 
00227 #endif /* HAVE_OPENSSL */
00228    return 0;
00229 }

void ast_stun_init ( void   ) 

Initialize the STUN system in Asterisk.

Provided by stun.c

Definition at line 516 of file stun.c.

References ast_cli_register_multiple(), ast_register_cleanup(), and stun_shutdown().

Referenced by main().

00517 {
00518    ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
00519    ast_register_cleanup(stun_shutdown);
00520 }

int ast_term_init ( void   ) 

Provided by term.c

Definition at line 95 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(), end, ESC, and NULL.

Referenced by main().

00096 {
00097    char *term = getenv("TERM");
00098    char termfile[256] = "";
00099    char buffer[512] = "";
00100    int termfd = -1, parseokay = 0, i;
00101 
00102    if (ast_opt_no_color) {
00103       return 0;
00104    }
00105 
00106    if (!ast_opt_console) {
00107       /* If any remote console is not compatible, we'll strip the color codes at that point */
00108       vt100compat = 1;
00109       goto end;
00110    }
00111 
00112    if (!term) {
00113       return 0;
00114    }
00115 
00116    for (i = 0;; i++) {
00117       if (termpath[i] == NULL) {
00118          break;
00119       }
00120       snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term);
00121       termfd = open(termfile, O_RDONLY);
00122       if (termfd > -1) {
00123          break;
00124       }
00125    }
00126    if (termfd > -1) {
00127       int actsize = read(termfd, buffer, sizeof(buffer) - 1);
00128       short sz_names = convshort(buffer + 2);
00129       short sz_bools = convshort(buffer + 4);
00130       short n_nums   = convshort(buffer + 6);
00131 
00132       /* if ((sz_names + sz_bools) & 1)
00133          sz_bools++; */
00134 
00135       if (sz_names + sz_bools + n_nums < actsize) {
00136          /* Offset 13 is defined in /usr/include/term.h, though we do not
00137           * include it here, as it conflicts with include/asterisk/term.h */
00138          short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2);
00139          if (max_colors > 0) {
00140             vt100compat = 1;
00141          }
00142          parseokay = 1;
00143       }
00144       close(termfd);
00145    }
00146 
00147    if (!parseokay) {
00148       /* These comparisons should not be substrings nor case-insensitive, as
00149        * terminal types are very particular about how they treat suffixes and
00150        * capitalization.  For example, terminal type 'linux-m' does NOT
00151        * support color, while 'linux' does.  Not even all vt100* terminals
00152        * support color, either (e.g. 'vt100+fnkeys'). */
00153       if (!strcmp(term, "linux")) {
00154          vt100compat = 1;
00155       } else if (!strcmp(term, "xterm")) {
00156          vt100compat = 1;
00157       } else if (!strcmp(term, "xterm-color")) {
00158          vt100compat = 1;
00159       } else if (!strcmp(term, "xterm-256color")) {
00160          vt100compat = 1;
00161       } else if (!strncmp(term, "Eterm", 5)) {
00162          /* Both entries which start with Eterm support color */
00163          vt100compat = 1;
00164       } else if (!strcmp(term, "vt100")) {
00165          vt100compat = 1;
00166       } else if (!strncmp(term, "crt", 3)) {
00167          /* Both crt terminals support color */
00168          vt100compat = 1;
00169       }
00170    }
00171 
00172 end:
00173    if (vt100compat) {
00174       /* Make commands show up in nice colors */
00175       if (ast_opt_light_background) {
00176          snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN);
00177          snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
00178          snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
00179       } else if (ast_opt_force_black_background) {
00180          snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10);
00181          snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
00182          snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
00183       } else {
00184          snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN);
00185          snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE);
00186          snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
00187       }
00188    }
00189    return 0;
00190 }

int ast_test_init ( void   ) 

Provided by test.c

Definition at line 1112 of file test.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_register_cleanup(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by main().

01113 {
01114 #ifdef TEST_FRAMEWORK
01115    ast_register_cleanup(test_cleanup);
01116 
01117    /* Create stasis topic */
01118    test_suite_topic = stasis_topic_create("test_suite_topic");
01119    if (!test_suite_topic) {
01120       return -1;
01121    }
01122 
01123    if (STASIS_MESSAGE_TYPE_INIT(ast_test_suite_message_type) != 0) {
01124       return -1;
01125    }
01126 
01127    /* Register cli commands */
01128    ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
01129 #endif
01130 
01131    return 0;
01132 }

int ast_timing_init ( void   ) 

Provided by timing.c

Definition at line 286 of file timing.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_heap_create(), ast_register_cleanup(), timing_holder_cmp(), and timing_shutdown().

Referenced by main().

00287 {
00288    if (!(timing_interfaces = ast_heap_create(2, timing_holder_cmp, 0))) {
00289       return -1;
00290    }
00291 
00292    ast_register_cleanup(timing_shutdown);
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 270 of file taskprocessor.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_log, ast_register_cleanup(), cli_ping_cond, LOG_ERROR, NULL, taskprocessor_clis, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, tps_shutdown(), and tps_singletons.

Referenced by main().

00271 {
00272    if (!(tps_singletons = ao2_container_alloc(TPS_MAX_BUCKETS, tps_hash_cb, tps_cmp_cb))) {
00273       ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
00274       return -1;
00275    }
00276 
00277    ast_cond_init(&cli_ping_cond, NULL);
00278 
00279    ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
00280 
00281    ast_register_cleanup(tps_shutdown);
00282 
00283    return 0;
00284 }

int ast_xmldoc_load_documentation ( void   ) 

Load XML documentation. Provided by xmldoc.c.

Return values:
1 on error.
0 on success.

Referenced by main().

int astdb_init ( void   ) 

int astobj2_init ( void   ) 

Provided by astobj2.c

Definition at line 898 of file astobj2.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_config_AST_LOG_DIR, ast_log, ast_register_cleanup(), astobj2_cleanup(), container_init(), and LOG_ERROR.

Referenced by main().

00899 {
00900 #ifdef REF_DEBUG
00901    char ref_filename[1024];
00902 #endif
00903 
00904    if (container_init() != 0) {
00905       return -1;
00906    }
00907 
00908 #ifdef REF_DEBUG
00909    snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
00910    ref_log = fopen(ref_filename, "w");
00911    if (!ref_log) {
00912       ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
00913    }
00914 #endif
00915 
00916 #if defined(AO2_DEBUG)
00917    ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
00918 #endif   /* defined(AO2_DEBUG) */
00919 
00920    ast_register_cleanup(astobj2_cleanup);
00921 
00922    return 0;
00923 }

void clean_time_zones ( void   ) 

Provided by localtime.c

Definition at line 1623 of file localtime.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and sstate_free().

Referenced by really_quit().

01624 {
01625    struct state *sp;
01626 
01627    AST_LIST_LOCK(&zonelist);
01628    while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
01629       sstate_free(sp);
01630    }
01631    AST_LIST_UNLOCK(&zonelist);
01632 }

void close_logger ( void   ) 

Provided by logger.c

Definition at line 1448 of file logger.c.

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_cond_signal, ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, cli_logger, close_logger_thread, f, logchannel::fileptr, logchannel::list, logcond, logthread, NULL, and qlog.

Referenced by really_quit().

01449 {
01450    struct logchannel *f = NULL;
01451    struct verb *cur = NULL;
01452 
01453    ast_cli_unregister_multiple(cli_logger, ARRAY_LEN(cli_logger));
01454 
01455    logger_initialized = 0;
01456 
01457    /* Stop logger thread */
01458    AST_LIST_LOCK(&logmsgs);
01459    close_logger_thread = 1;
01460    ast_cond_signal(&logcond);
01461    AST_LIST_UNLOCK(&logmsgs);
01462 
01463    if (logthread != AST_PTHREADT_NULL)
01464       pthread_join(logthread, NULL);
01465 
01466    AST_RWLIST_WRLOCK(&verbosers);
01467    while ((cur = AST_LIST_REMOVE_HEAD(&verbosers, list))) {
01468       ast_free(cur);
01469    }
01470    AST_RWLIST_UNLOCK(&verbosers);
01471 
01472    AST_RWLIST_WRLOCK(&logchannels);
01473 
01474    if (qlog) {
01475       fclose(qlog);
01476       qlog = NULL;
01477    }
01478 
01479    while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) {
01480       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
01481          fclose(f->fileptr);
01482          f->fileptr = NULL;
01483       }
01484       ast_free(f);
01485    }
01486 
01487    closelog(); /* syslog */
01488 
01489    AST_RWLIST_UNLOCK(&logchannels);
01490 }

int dnsmgr_init ( void   ) 

Provided by dnsmgr.c

Definition at line 431 of file dnsmgr.c.

References ast_cli_register(), ast_log, ast_register_cleanup(), ast_sched_context_create(), cli_refresh, cli_reload, cli_status, dnsmgr_shutdown(), do_reload(), and LOG_ERROR.

Referenced by main().

00432 {
00433    if (!(sched = ast_sched_context_create())) {
00434       ast_log(LOG_ERROR, "Unable to create schedule context.\n");
00435       return -1;
00436    }
00437    ast_cli_register(&cli_reload);
00438    ast_cli_register(&cli_status);
00439    ast_cli_register(&cli_refresh);
00440 
00441    ast_register_cleanup(dnsmgr_shutdown);
00442 
00443    return do_reload(1);
00444 }

int dnsmgr_reload ( void   ) 

Provided by dnsmgr.c

Definition at line 446 of file dnsmgr.c.

References do_reload().

00447 {
00448    return do_reload(0);
00449 }

void dnsmgr_start_refresh ( void   ) 

Provided by dnsmgr.c

Definition at line 303 of file dnsmgr.c.

References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, and refresh_list().

Referenced by main().

00304 {
00305    if (refresh_sched > -1) {
00306       AST_SCHED_DEL(sched, refresh_sched);
00307       refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1);
00308    }
00309 }

int init_logger ( void   ) 

Provided by logger.c

Definition at line 1410 of file logger.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_destroy, ast_cond_init, ast_config_AST_LOG_DIR, ast_log, ast_mkdir(), ast_mutex_destroy, ast_mutex_init, ast_pthread_create, ast_verb_update(), cli_logger, handle_SIGXFSZ, init_logger_chain(), LOG_ERROR, logcond, logger_thread(), logthread, and NULL.

Referenced by main().

01411 {
01412    int res;
01413    /* auto rotate if sig SIGXFSZ comes a-knockin */
01414    sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
01415 
01416    /* Re-initialize the logmsgs mutex.  The recursive mutex can be accessed prior
01417     * to Asterisk being forked into the background, which can cause the thread
01418     * ID tracked by the underlying pthread mutex to be different than the ID of
01419     * the thread that unlocks the mutex.  Since init_logger is called after the
01420     * fork, it is safe to initialize the mutex here for future accesses.
01421     */
01422    ast_mutex_destroy(&logmsgs.lock);
01423    ast_mutex_init(&logmsgs.lock);
01424    ast_cond_init(&logcond, NULL);
01425 
01426    /* start logger thread */
01427    if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
01428       ast_cond_destroy(&logcond);
01429       return -1;
01430    }
01431 
01432    /* register the logger cli commands */
01433    ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger));
01434 
01435    ast_mkdir(ast_config_AST_LOG_DIR, 0777);
01436 
01437    /* create log channels */
01438    res = init_logger_chain(0 /* locked */, NULL);
01439    ast_verb_update();
01440    logger_initialized = 1;
01441    if (res) {
01442       ast_log(LOG_ERROR, "Errors detected in logger.conf.  Default console logging is being used.\n");
01443    }
01444 
01445    return 0;
01446 }

int load_modules ( unsigned  int  ) 

Provided by loader.c

Definition at line 1242 of file loader.c.

References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load2(), ast_debug, AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MODULE_CONFIG, ast_opt_quiet, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verb, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, embedded_module_list, embedding, find_resource(), module_list::first, ast_module::flags, module_list::last, ast_module::last, ast_module::lib, load_resource_list(), LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, order, load_order_entry::resource, ast_module::resource, resource_name_match(), ast_module::running, and ast_variable::value.

Referenced by main().

01243 {
01244    struct ast_config *cfg;
01245    struct ast_module *mod;
01246    struct load_order_entry *order;
01247    struct ast_variable *v;
01248    unsigned int load_count;
01249    struct load_order load_order;
01250    int res = 0;
01251    struct ast_flags config_flags = { 0 };
01252    int modulecount = 0;
01253 
01254 #ifdef LOADABLE_MODULES
01255    struct dirent *dirent;
01256    DIR *dir;
01257 #endif
01258 
01259    /* all embedded modules have registered themselves by now */
01260    embedding = 0;
01261 
01262    ast_verb(1, "Asterisk Dynamic Loader Starting:\n");
01263 
01264    AST_LIST_HEAD_INIT_NOLOCK(&load_order);
01265 
01266    AST_DLLIST_LOCK(&module_list);
01267 
01268    if (embedded_module_list.first) {
01269       module_list.first = embedded_module_list.first;
01270       module_list.last = embedded_module_list.last;
01271       embedded_module_list.first = NULL;
01272    }
01273 
01274    cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags);
01275    if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
01276       ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG);
01277       goto done;
01278    }
01279 
01280    /* first, find all the modules we have been explicitly requested to load */
01281    for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
01282       if (!strcasecmp(v->name, preload_only ? "preload" : "load")) {
01283          add_to_load_order(v->value, &load_order, 0);
01284       }
01285       if (!strcasecmp(v->name, preload_only ? "preload-require" : "require")) {
01286          /* Add the module to the list and make sure it's required */
01287          add_to_load_order(v->value, &load_order, 1);
01288          ast_debug(2, "Adding module to required list: %s (%s)\n", v->value, v->name);
01289       }
01290 
01291    }
01292 
01293    /* check if 'autoload' is on */
01294    if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) {
01295       /* if so, first add all the embedded modules that are not already running to the load order */
01296       AST_DLLIST_TRAVERSE(&module_list, mod, entry) {
01297          /* if it's not embedded, skip it */
01298          if (mod->lib)
01299             continue;
01300 
01301          if (mod->flags.running)
01302             continue;
01303 
01304          add_to_load_order(mod->resource, &load_order, 0);
01305       }
01306 
01307 #ifdef LOADABLE_MODULES
01308       /* if we are allowed to load dynamic modules, scan the directory for
01309          for all available modules and add them as well */
01310       if ((dir = opendir(ast_config_AST_MODULE_DIR))) {
01311          while ((dirent = readdir(dir))) {
01312             int ld = strlen(dirent->d_name);
01313 
01314             /* Must end in .so to load it.  */
01315 
01316             if (ld < 4)
01317                continue;
01318 
01319             if (strcasecmp(dirent->d_name + ld - 3, ".so"))
01320                continue;
01321 
01322             /* if there is already a module by this name in the module_list,
01323                skip this file */
01324             if (find_resource(dirent->d_name, 0))
01325                continue;
01326 
01327             add_to_load_order(dirent->d_name, &load_order, 0);
01328          }
01329 
01330          closedir(dir);
01331       } else {
01332          if (!ast_opt_quiet)
01333             ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n",
01334                ast_config_AST_MODULE_DIR);
01335       }
01336 #endif
01337    }
01338 
01339    /* now scan the config for any modules we are prohibited from loading and
01340       remove them from the load order */
01341    for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
01342       if (strcasecmp(v->name, "noload"))
01343          continue;
01344 
01345       AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
01346          if (!resource_name_match(order->resource, v->value)) {
01347             AST_LIST_REMOVE_CURRENT(entry);
01348             ast_free(order->resource);
01349             ast_free(order);
01350          }
01351       }
01352       AST_LIST_TRAVERSE_SAFE_END;
01353    }
01354 
01355    /* we are done with the config now, all the information we need is in the
01356       load_order list */
01357    ast_config_destroy(cfg);
01358 
01359    load_count = 0;
01360    AST_LIST_TRAVERSE(&load_order, order, entry)
01361       load_count++;
01362 
01363    if (load_count)
01364       ast_log(LOG_NOTICE, "%u modules will be loaded.\n", load_count);
01365 
01366    /* first, load only modules that provide global symbols */
01367    if ((res = load_resource_list(&load_order, 1, &modulecount)) < 0) {
01368       goto done;
01369    }
01370 
01371    /* now load everything else */
01372    if ((res = load_resource_list(&load_order, 0, &modulecount)) < 0) {
01373       goto done;
01374    }
01375 
01376 done:
01377    while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
01378       ast_free(order->resource);
01379       ast_free(order);
01380    }
01381 
01382    AST_DLLIST_UNLOCK(&module_list);
01383    return res;
01384 }

int load_pbx ( void   ) 

Provided by pbx.c

Definition at line 12100 of file pbx.c.

References __ast_custom_function_register(), action_extensionstatelist(), ARRAY_LEN, ast_cli_register_multiple(), ast_data_register_multiple_core, ast_device_state_topic_all(), ast_log, ast_manager_register_xml_core, ast_presence_state_topic_all(), ast_register_application2(), ast_register_cleanup(), ast_verb, builtins, device_state_cb(), EVENT_FLAG_CALL, EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, exception_function, LOG_ERROR, manager_show_dialplan(), NULL, pbx_cli, pbx_data_providers, presence_state_cb(), stasis_subscribe(), testtime_function, and unload_pbx().

Referenced by main().

12101 {
12102    int res = 0;
12103    int x;
12104 
12105    ast_register_cleanup(unload_pbx);
12106 
12107    /* Initialize the PBX */
12108    ast_verb(1, "Asterisk PBX Core Initializing\n");
12109 
12110    ast_verb(2, "Registering builtin applications and functions:\n");
12111    ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli));
12112    ast_data_register_multiple_core(pbx_data_providers, ARRAY_LEN(pbx_data_providers));
12113    __ast_custom_function_register(&exception_function, NULL);
12114    __ast_custom_function_register(&testtime_function, NULL);
12115 
12116    /* Register builtin applications */
12117    for (x = 0; x < ARRAY_LEN(builtins); x++) {
12118       if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) {
12119          ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
12120          return -1;
12121       }
12122    }
12123 
12124    /* Register manager application */
12125    res |= ast_manager_register_xml_core("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan);
12126    res |= ast_manager_register_xml_core("ExtensionStateList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstatelist);
12127 
12128    if (res) {
12129       return -1;
12130    }
12131 
12132    if (!(device_state_sub = stasis_subscribe(ast_device_state_topic_all(), device_state_cb, NULL))) {
12133       return -1;
12134    }
12135 
12136    if (!(presence_state_sub = stasis_subscribe(ast_presence_state_topic_all(), presence_state_cb, NULL))) {
12137       return -1;
12138    }
12139 
12140    return 0;
12141 }

void logger_queue_start ( void   ) 

Start the ast_queue_log() logger.

Provided by logger.c

Note:
Called when the system is fully booted after startup so preloaded realtime modules can get up.
Returns:
Nothing

Definition at line 1394 of file logger.c.

References ast_assert, ast_queue_log(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and logger_queue_init().

Referenced by ast_queue_log(), and main().

01395 {
01396    /* Must not be called before the logger is initialized. */
01397    ast_assert(logger_initialized);
01398 
01399    AST_RWLIST_WRLOCK(&logchannels);
01400    if (!queuelog_init) {
01401       logger_queue_init();
01402       queuelog_init = 1;
01403       AST_RWLIST_UNLOCK(&logchannels);
01404       ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
01405    } else {
01406       AST_RWLIST_UNLOCK(&logchannels);
01407    }
01408 }

void threadstorage_init ( void   ) 

Provided by threadstorage.c

Definition at line 35 of file threadstorage.c.

Referenced by main().

00036 {
00037 }


Generated on Thu Apr 16 06:28:06 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6