Asterisk - The Open Source Telephony Project GIT-master-9647a4f
Loading...
Searching...
No Matches
Functions
_private.h File Reference

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

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_channels_init (void)
 
void ast_cli_channels_init (void)
 
int ast_cli_perms_init (int reload)
 
int ast_device_state_engine_init (void)
 Initialize the device state engine in separate thread.
 
int ast_dns_system_resolver_init (void)
 Initializes the resolver.
 
int ast_endpoint_init (void)
 Endpoint support initialization.
 
int ast_file_init (void)
 
int ast_local_init (void)
 Initialize the local proxy channel.
 
int ast_msg_init (void)
 
void ast_msg_shutdown (void)
 
int ast_named_locks_init (void)
 
int ast_parking_stasis_init (void)
 initializes the rtp engine arrays
 
int ast_pj_init (void)
 
void ast_process_pending_reloads (void)
 Process reload requests received during startup.
 
int ast_refer_init (void)
 
int ast_rtp_engine_init (void)
 initializes the rtp engine arrays
 
int ast_ssl_init (void)
 
void ast_stun_init (void)
 Initialize the STUN system in Asterisk.
 
int ast_taskpool_init (void)
 
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 dns_core_init (void)
 
void dnsmgr_start_refresh (void)
 
int init_logger (void)
 
void load_asterisk_conf (void)
 
void load_astmm_phase_1 (void)
 Initialize malloc debug phase 1.
 
void load_astmm_phase_2 (void)
 Initialize malloc debug phase 2.
 
int load_modules (void)
 
int load_pbx (void)
 
int load_pbx_app (void)
 
int load_pbx_builtins (void)
 
int load_pbx_functions_cli (void)
 
int load_pbx_hangup_handler (void)
 
int load_pbx_switch (void)
 
int load_pbx_variables (void)
 
void logger_queue_start (void)
 Start the ast_queue_log() logger.
 
int modules_shutdown (void)
 
void set_asterisk_conf_path (const char *path)
 
void set_socket_path (const char *path)
 
void threadstorage_init (void)
 

Detailed Description

Prototypes for public functions only of internal interest,.

Definition in file _private.h.

Function Documentation

◆ aco_init()

int aco_init ( void  )

Provided by config_options.c

Definition at line 1490 of file config_options.c.

1491{
1492#ifdef AST_XML_DOCS
1494 if (!(xmldocs = ast_xmldoc_build_documentation("configInfo"))) {
1495 ast_log(LOG_ERROR, "Couldn't build config documentation\n");
1496 return -1;
1497 }
1499#endif /* AST_XML_DOCS */
1500 return 0;
1501}
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition clicompat.c:19
#define ast_log
Definition astobj2.c:42
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition cli.h:265
static struct ao2_container * xmldocs
static struct ast_cli_entry cli_aco[]
static void aco_deinit(void)
#define LOG_ERROR
#define ARRAY_LEN(a)
Definition utils.h:706
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
Definition xmldoc.c:2783

References aco_deinit(), ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_register_cleanup(), ast_xmldoc_build_documentation(), cli_aco, LOG_ERROR, and xmldocs.

Referenced by asterisk_daemon().

◆ ast_autoservice_init()

void ast_autoservice_init ( void  )

Provided by autoservice.c

Definition at line 387 of file autoservice.c.

388{
391}
static ast_cond_t as_cond
Definition autoservice.c:71
static void autoservice_shutdown(void)
#define ast_cond_init(cond, attr)
Definition lock.h:208
#define NULL
Definition resample.c:96

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

Referenced by asterisk_daemon().

◆ ast_bridging_init()

int ast_bridging_init ( void  )

Initialize the bridging system.

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

Definition at line 5623 of file bridge.c.

5624{
5626
5628 return -1;
5629 }
5630
5632 if (!bridge_manager) {
5633 return -1;
5634 }
5635
5638 if (!bridges) {
5639 return -1;
5640 }
5642
5644
5646
5647 ast_manager_register_xml_core("BridgeTechnologyList", 0, manager_bridge_tech_list);
5648 ast_manager_register_xml_core("BridgeTechnologySuspend", 0, manager_bridge_tech_suspend);
5649 ast_manager_register_xml_core("BridgeTechnologyUnsuspend", 0, manager_bridge_tech_unsuspend);
5650
5651 return 0;
5652}
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition astobj2.h:363
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree container.
Definition astobj2.h:1349
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE
Replace objects with duplicate keys in container.
Definition astobj2.h:1211
static struct bridge_manager_controller * bridge_manager
Definition bridge.c:183
static int manager_bridge_tech_list(struct mansession *s, const struct message *m)
Definition bridge.c:5540
static int manager_bridge_tech_suspend(struct mansession *s, const struct message *m)
Definition bridge.c:5530
static int manager_bridge_tech_unsuspend(struct mansession *s, const struct message *m)
Definition bridge.c:5535
static struct ast_cli_entry bridge_cli[]
Definition bridge.c:5484
static int bridge_sort_cmp(const void *obj_left, const void *obj_right, int flags)
Definition bridge.c:5069
static void bridge_prnt_obj(void *v_obj, void *where, ao2_prnt_fn *prnt)
Definition bridge.c:5593
static struct ao2_container * bridges
Definition bridge.c:132
static void bridge_cleanup(void)
Definition bridge.c:5609
static struct bridge_manager_controller * bridge_manager_create(void)
Definition bridge.c:5030
void ast_bridging_init_basic(void)
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition manager.h:203
int ast_stasis_bridging_init(void)

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_cli, bridge_manager, bridge_manager_create(), bridge_prnt_obj(), bridge_sort_cmp(), bridges, manager_bridge_tech_list(), manager_bridge_tech_suspend(), manager_bridge_tech_unsuspend(), and NULL.

Referenced by asterisk_daemon().

◆ ast_builtins_init()

void ast_builtins_init ( void  )

initialize the _full_cmd string in * each of the builtins.

Provided by cli.c

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

2215{
2219}
static void cli_shutdown(void)
Definition main/cli.c:2203
static struct ast_cli_entry cli_cli[]
Definition main/cli.c:1996
static struct @355 shutdown_commands
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition vector.h:124

References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), AST_VECTOR_INIT, cli_cli, cli_shutdown(), and shutdown_commands.

Referenced by asterisk_daemon().

◆ ast_channels_init()

int ast_channels_init ( void  )

Provided by channel.c

Definition at line 8045 of file channel.c.

8046{
8047
8048 if (ast_channelstorage_init() != 0) {
8049 return -1;
8050 }
8051
8052 /*
8053 * channel_storage_type is a global variable set by options.c
8054 * from the "channel_storage_backend" option in asterisk.conf.
8055 */
8056 if (ast_channel_open_storage() != 0) {
8057 return -1;
8058 }
8059
8061
8063
8065
8067
8070
8071 return 0;
8072}
static void channels_shutdown(void)
Definition channel.c:7983
static struct external_vars ari_vars
Definition channel.c:7817
static struct external_vars ami_vars
Definition channel.c:7816
int ast_channel_open_storage()
Definition channel.c:7996
int ast_channel_register(const struct ast_channel_tech *tech)
Register a new telephony channel in Asterisk.
Definition channel.c:539
static const struct ast_channel_tech surrogate_tech
Channel technology used to extract a channel from a running application. The channel created with thi...
Definition channel.c:696
static struct ast_cli_entry cli_channel[]
Definition channel.c:390
int ast_channelstorage_init(void)
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
int ast_stasis_channels_init(void)
Initialize the stasis channel topic and message types.

References ami_vars, ari_vars, ARRAY_LEN, ast_channel_open_storage(), ast_channel_register(), ast_channelstorage_init(), ast_cli_register_multiple, ast_register_cleanup(), AST_RWLIST_HEAD_INIT, ast_stasis_channels_init(), channels_shutdown(), cli_channel, and surrogate_tech.

Referenced by asterisk_daemon().

◆ ast_cli_channels_init()

void ast_cli_channels_init ( void  )

Provided by cli.c

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

2222{
2225}
static void cli_channels_shutdown(void)
Definition main/cli.c:2208
static struct ast_cli_entry cli_channels_cli[]
Definition main/cli.c:2028

References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), cli_channels_cli, and cli_channels_shutdown().

Referenced by asterisk_daemon().

◆ ast_cli_perms_init()

int ast_cli_perms_init ( int  reload)

Provided by cli.c

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

2082{
2083 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
2084 struct ast_config *cfg;
2085 char *cat = NULL;
2086 struct ast_variable *v;
2087 struct usergroup_cli_perm *user_group, *cp_entry;
2088 struct cli_perm *perm = NULL;
2089 struct passwd *pw;
2090 struct group *gr;
2091
2093 ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n");
2094 return 1;
2095 }
2096
2097 cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags);
2098 if (!cfg) {
2100 return 1;
2101 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
2103 return 0;
2104 }
2105
2106 /* free current structures. */
2108
2109 while ((cat = ast_category_browse(cfg, cat))) {
2110 if (!strcasecmp(cat, "general")) {
2111 /* General options */
2112 for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
2113 if (!strcasecmp(v->name, "default_perm")) {
2114 cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0;
2115 }
2116 }
2117 continue;
2118 }
2119
2120 /* users or groups */
2121 gr = NULL, pw = NULL;
2122 if (cat[0] == '@') {
2123 /* This is a group */
2124 gr = getgrnam(&cat[1]);
2125 if (!gr) {
2126 ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]);
2127 continue;
2128 }
2129 } else {
2130 /* This is a user */
2131 pw = getpwnam(cat);
2132 if (!pw) {
2133 ast_log (LOG_WARNING, "Unknown user '%s'\n", cat);
2134 continue;
2135 }
2136 }
2137 user_group = NULL;
2138 /* Check for duplicates */
2140 AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) {
2141 if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) {
2142 /* if it is duplicated, just added this new settings, to
2143 the current list. */
2144 user_group = cp_entry;
2145 break;
2146 }
2147 }
2149
2150 if (!user_group) {
2151 /* alloc space for the new user config. */
2152 user_group = ast_calloc(1, sizeof(*user_group));
2153 if (!user_group) {
2154 continue;
2155 }
2156 user_group->uid = (pw ? pw->pw_uid : -1);
2157 user_group->gid = (gr ? gr->gr_gid : -1);
2158 user_group->perms = ast_calloc(1, sizeof(*user_group->perms));
2159 if (!user_group->perms) {
2160 ast_free(user_group);
2161 continue;
2162 }
2163 }
2164 for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
2165 if (ast_strlen_zero(v->value)) {
2166 /* we need to check this condition cause it could break security. */
2167 ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat);
2168 continue;
2169 }
2170 if (!strcasecmp(v->name, "permit")) {
2171 perm = ast_calloc(1, sizeof(*perm));
2172 if (perm) {
2173 perm->permit = 1;
2174 perm->command = ast_strdup(v->value);
2175 }
2176 } else if (!strcasecmp(v->name, "deny")) {
2177 perm = ast_calloc(1, sizeof(*perm));
2178 if (perm) {
2179 perm->permit = 0;
2180 perm->command = ast_strdup(v->value);
2181 }
2182 } else {
2183 /* up to now, only 'permit' and 'deny' are possible values. */
2184 ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name);
2185 continue;
2186 }
2187 if (perm) {
2188 /* Added the permission to the user's list. */
2189 AST_LIST_INSERT_TAIL(user_group->perms, perm, list);
2190 perm = NULL;
2191 }
2192 }
2194 AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list);
2196 }
2197
2198 ast_config_destroy(cfg);
2200 return 0;
2201}
#define ast_free(a)
Definition astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition extconf.c:3324
#define CONFIG_STATUS_FILEUNCHANGED
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition extconf.c:1287
@ CONFIG_FLAG_FILEUNCHANGED
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition extconf.c:1213
#define LOG_NOTICE
#define LOG_WARNING
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_RWLIST_INSERT_TAIL
#define ast_mutex_unlock(a)
Definition lock.h:197
#define ast_mutex_trylock(a)
Definition lock.h:198
static ast_mutex_t permsconfiglock
mutex used to prevent a user from running the 'cli reload permissions' command while it is already ru...
Definition main/cli.c:91
static int cli_default_perm
Default permissions value 1=Permit 0=Deny.
Definition main/cli.c:87
static void destroy_user_perms(void)
cleanup (free) cli_perms linkedlist.
Definition main/cli.c:2065
static const char perms_config[]
CLI permissions config file.
Definition main/cli.c:85
static int reload(void)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Structure used to handle boolean flags.
Definition utils.h:220
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
List of restrictions per user.
Definition main/cli.c:69
unsigned int permit
Definition main/cli.c:70
char * command
Definition main/cli.c:71
List of users and permissions.
Definition main/cli.c:93
list of users to apply restrictions.
Definition main/cli.c:78
struct cli_perm_head * perms
Definition main/cli.c:81

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_default_perm, 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, permsconfiglock, reload(), usergroup_cli_perm::uid, and ast_variable::value.

Referenced by asterisk_daemon(), and handle_cli_reload_permissions().

◆ ast_device_state_engine_init()

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.

622{
625 ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
626 return -1;
627 }
629
630 return 0;
631}
static void device_state_engine_cleanup(void)
static pthread_t change_thread
The device state change notification thread.
static void * do_devstate_changes(void *data)
Go through the dev state change queue and update changes in the dev state thread.
static ast_cond_t change_pending
Flag for the queue.
#define ast_pthread_create_background(a, b, c, d)
Definition utils.h:632

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

Referenced by asterisk_daemon().

◆ ast_dns_system_resolver_init()

int ast_dns_system_resolver_init ( void  )

Initializes the resolver.

Provided by dns_system_resolver.c

Return values
0on success
-1on failure

Definition at line 244 of file dns_system_resolver.c.

245{
246 /* Register the base resolver */
248
249 if (res) {
251 }
252
253 /* Instantiate the task processor */
254 dns_system_resolver_tp = ast_taskprocessor_get("dns_system_resolver_tp",
256
257 /* Return error if the task processor failed to instantiate */
260 }
261
262 /* Register the cleanup function */
264
266}
int ast_dns_resolver_register(struct ast_dns_resolver *resolver)
Register a DNS resolver.
Definition dns_core.c:632
static struct ast_taskprocessor * dns_system_resolver_tp
The task processor to use for making DNS searches asynchronous.
#define DNS_SYSTEM_RESOLVER_FAILURE
Resolver return code upon failure.
static void dns_system_resolver_destroy(void)
Destructor.
#define DNS_SYSTEM_RESOLVER_SUCCESS
Resolver return code upon success.
struct ast_dns_resolver dns_system_resolver_base
The base definition for the dns_system_resolver.
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary.
@ TPS_REF_DEFAULT
return a reference to a taskprocessor, create one if it does not exist

References ast_dns_resolver_register(), ast_register_cleanup(), ast_taskprocessor_get(), dns_system_resolver_base, dns_system_resolver_destroy(), DNS_SYSTEM_RESOLVER_FAILURE, DNS_SYSTEM_RESOLVER_SUCCESS, dns_system_resolver_tp, and TPS_REF_DEFAULT.

Referenced by asterisk_daemon().

◆ ast_endpoint_init()

int ast_endpoint_init ( void  )

Endpoint support initialization.

Returns
0 on success.
Non-zero on error.

Definition at line 453 of file main/endpoints.c.

454{
456
458 ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
459 if (!endpoints) {
460 return -1;
461 }
462
464 TECH_ENDPOINT_BUCKETS, ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
465 if (!tech_endpoints) {
466 return -1;
467 }
468
469 return 0;
470}
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition astobj2.h:1303
static struct ao2_container * tech_endpoints
static struct ao2_container * endpoints
#define ENDPOINT_BUCKETS
static void endpoint_cleanup(void)
#define TECH_ENDPOINT_BUCKETS

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_register_cleanup(), ENDPOINT_BUCKETS, endpoint_cleanup(), endpoints, NULL, TECH_ENDPOINT_BUCKETS, and tech_endpoints.

Referenced by asterisk_daemon().

◆ ast_file_init()

int ast_file_init ( void  )

Provided by file.c

Definition at line 2085 of file file.c.

2086{
2091 return 0;
2092}
static void file_shutdown(void)
Definition file.c:2078
static struct ast_cli_entry cli_file[]
Definition file.c:2074
struct stasis_message_type * ast_format_unregister_type(void)
Get the message type used for signaling a format unregistration.
struct stasis_message_type * ast_format_register_type(void)
Get the message type used for signaling a format registration.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition stasis.h:1493

References ARRAY_LEN, ast_cli_register_multiple, ast_format_register_type(), ast_format_unregister_type(), ast_register_cleanup(), cli_file, file_shutdown(), and STASIS_MESSAGE_TYPE_INIT.

Referenced by asterisk_daemon().

◆ ast_local_init()

int ast_local_init ( void  )

Initialize the local proxy channel.

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

Definition at line 1153 of file core_local.c.

1154{
1156 return -1;
1157 }
1158
1160 return -1;
1161 }
1162
1164 return -1;
1165 }
1166
1168 return -1;
1169 }
1171
1173 if (!locals) {
1174 return -1;
1175 }
1176
1177 /* Make sure we can register our channel type */
1179 ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
1180
1181 return -1;
1182 }
1185
1187 return 0;
1188}
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition astobj2.h:1327
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition channel.c:539
@ AST_MEDIA_TYPE_UNKNOWN
Definition codec.h:31
static int manager_optimize_away(struct mansession *s, const struct message *m)
static int locals_cmp_cb(void *obj, void *arg, int flags)
static struct ast_channel_tech local_tech
Definition core_local.c:185
static struct ast_cli_entry cli_local[]
static void local_shutdown(void)
static struct ao2_container * locals
Definition core_local.c:150
struct stasis_message_type * ast_local_bridge_type(void)
Message type for when two local channel halves are bridged together.
struct stasis_message_type * ast_local_optimization_end_type(void)
Message type for when a local channel optimization completes.
struct stasis_message_type * ast_local_optimization_begin_type(void)
Message type for when a local channel optimization begins.
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition format_cap.c:216
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition format_cap.h:38
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition format_cap.h:49
#define EVENT_FLAG_SYSTEM
Definition manager.h:75
#define EVENT_FLAG_CALL
Definition manager.h:76
struct ast_format_cap * capabilities
Definition channel.h:652

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, 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, cli_local, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, local_shutdown(), local_tech, locals, locals_cmp_cb(), LOG_ERROR, manager_optimize_away(), NULL, and STASIS_MESSAGE_TYPE_INIT.

Referenced by asterisk_daemon().

◆ ast_msg_init()

int ast_msg_init ( void  )

Provided by message.c

Definition at line 1770 of file main/message.c.

1771{
1772 int res;
1773
1775 if (!msg_q_tp) {
1776 return -1;
1777 }
1778
1780 if (AST_VECTOR_INIT(&msg_techs, 8)) {
1781 return -1;
1782 }
1783
1785 if (AST_VECTOR_INIT(&msg_handlers, 4)) {
1786 return -1;
1787 }
1788
1790
1795
1797
1798 return res;
1799}
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition lock.h:231
static const char app_msg_send[]
static ast_rwlock_t msg_techs_lock
Lock for msg_techs vector.
static struct ast_msg_handler dialplan_msg_handler
static struct ast_custom_function msg_function
static struct ast_taskprocessor * msg_q_tp
struct @403 msg_techs
Vector of message technologies.
static void message_shutdown(void)
int ast_msg_handler_register(const struct ast_msg_handler *handler)
Register a ast_msg_handler.
static int msg_send_exec(struct ast_channel *chan, const char *data)
static ast_rwlock_t msg_handlers_lock
Lock for msg_handlers vector.
static int action_messagesend(struct mansession *s, const struct message *m)
static struct ast_custom_function msg_data_function
struct @404 msg_handlers
Vector of received message handlers.
#define EVENT_FLAG_MESSAGE
Definition manager.h:95
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Definition pbx_app.c:104
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.

References __ast_custom_function_register(), action_messagesend(), app_msg_send, ast_manager_register_xml_core, ast_msg_handler_register(), ast_register_application2(), ast_register_cleanup(), ast_rwlock_init, ast_taskprocessor_get(), AST_VECTOR_INIT, dialplan_msg_handler, EVENT_FLAG_MESSAGE, message_shutdown(), msg_data_function, msg_function, msg_handlers, msg_handlers_lock, msg_q_tp, msg_send_exec(), msg_techs, msg_techs_lock, NULL, and TPS_REF_DEFAULT.

Referenced by asterisk_daemon().

◆ ast_msg_shutdown()

void ast_msg_shutdown ( void  )

Provided by message.c

Definition at line 1729 of file main/message.c.

1730{
1731 if (msg_q_tp) {
1733 }
1734}
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.

References ast_taskprocessor_unreference(), and msg_q_tp.

Referenced by can_safely_quit().

◆ ast_named_locks_init()

int ast_named_locks_init ( void  )

Provided by named_locks.c

Definition at line 52 of file named_locks.c.

53{
55 NAMED_LOCKS_BUCKETS, named_lock_proxy_hash_fn, NULL, named_lock_proxy_cmp_fn);
56 if (!named_locks) {
57 return -1;
58 }
59
61
62 return 0;
63}
#define NAMED_LOCKS_BUCKETS
Definition named_locks.c:34
static void named_locks_shutdown(void)
Definition named_locks.c:47
struct ao2_container * named_locks
Definition named_locks.c:33

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_register_cleanup(), named_locks, NAMED_LOCKS_BUCKETS, named_locks_shutdown(), and NULL.

Referenced by asterisk_daemon().

◆ ast_parking_stasis_init()

int ast_parking_stasis_init ( void  )

initializes the rtp engine arrays

Since
12.0.0

Definition at line 53 of file parking.c.

54{
56 return -1;
57 }
58
59 parking_topic = stasis_topic_create("parking:all");
60 if (!parking_topic) {
61 return -1;
62 }
64 return 0;
65}
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
static struct stasis_topic * parking_topic
Topic for parking lots.
Definition parking.c:41
static void parking_stasis_cleanup(void)
Definition parking.c:46
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition stasis.c:684

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

Referenced by asterisk_daemon().

◆ ast_pj_init()

int ast_pj_init ( void  )

Provided by libasteriskpj.c

Definition at line 45 of file libasteriskpj.c.

46{
47#ifdef HAVE_PJPROJECT_BUNDLED
49 pj_init();
50#endif
51 return 0;
52}
#define AST_PJPROJECT_INIT_LOG_LEVEL()
Get maximum log level pjproject was compiled with.
Definition options.h:177

References AST_PJPROJECT_INIT_LOG_LEVEL.

Referenced by asterisk_daemon().

◆ ast_process_pending_reloads()

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 1575 of file loader.c.

1576{
1577 struct reload_queue_item *item;
1578
1579 modules_loaded = 1;
1580
1582
1583 if (do_full_reload) {
1584 do_full_reload = 0;
1586 ast_log(LOG_NOTICE, "Executing deferred reload request.\n");
1588 return;
1589 }
1590
1592 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module);
1593 ast_module_reload(item->module);
1594 ast_free(item);
1595 }
1596
1598}
#define AST_LIST_LOCK(head)
Locks a list.
Definition linkedlists.h:40
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
static int modules_loaded
Internal flag to indicate all modules have been initially loaded.
Definition loader.c:300
static int do_full_reload
Definition loader.c:647
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
Definition loader.c:1730
struct reload_queue_item::@392 entry
static struct aco_type item

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

Referenced by asterisk_daemon().

◆ ast_refer_init()

int ast_refer_init ( void  )

Provided by refer.c

Definition at line 531 of file refer.c.

532{
534 if (AST_VECTOR_INIT(&refer_techs, 8)) {
535 return -1;
536 }
538 return 0;
539}
static void refer_shutdown(void)
Definition refer.c:515
struct @414 refer_techs
Vector of refer technologies.
static ast_rwlock_t refer_techs_lock
Lock for refer_techs vector.
Definition refer.c:79

References ast_register_cleanup(), ast_rwlock_init, AST_VECTOR_INIT, refer_shutdown(), refer_techs, and refer_techs_lock.

Referenced by asterisk_daemon().

◆ ast_rtp_engine_init()

int ast_rtp_engine_init ( void  )

initializes the rtp engine arrays

Definition at line 3856 of file rtp_engine.c.

3857{
3860
3861 rtp_topic = stasis_topic_create("rtp:all");
3862 if (!rtp_topic) {
3863 return -1;
3864 }
3868
3869 /* Define all the RTP mime types available */
3870 set_next_mime_type(ast_format_g723, 0, "audio", "G723", 8000);
3871 set_next_mime_type(ast_format_gsm, 0, "audio", "GSM", 8000);
3872 set_next_mime_type(ast_format_ulaw, 0, "audio", "PCMU", 8000);
3873 set_next_mime_type(ast_format_ulaw, 0, "audio", "G711U", 8000);
3874 set_next_mime_type(ast_format_alaw, 0, "audio", "PCMA", 8000);
3875 set_next_mime_type(ast_format_alaw, 0, "audio", "G711A", 8000);
3876 set_next_mime_type(ast_format_g726, 0, "audio", "G726-32", 8000);
3877 set_next_mime_type(ast_format_adpcm, 0, "audio", "DVI4", 8000);
3878 set_next_mime_type(ast_format_slin, 0, "audio", "L16", 8000);
3879 set_next_mime_type(ast_format_slin16, 0, "audio", "L16", 16000);
3880 set_next_mime_type(ast_format_slin16, 0, "audio", "L16-256", 16000);
3881 set_next_mime_type(ast_format_slin12, 0, "audio", "L16", 12000);
3882 set_next_mime_type(ast_format_slin24, 0, "audio", "L16", 24000);
3883 set_next_mime_type(ast_format_slin32, 0, "audio", "L16", 32000);
3884 set_next_mime_type(ast_format_slin44, 0, "audio", "L16", 44100);
3885 set_next_mime_type(ast_format_slin48, 0, "audio", "L16", 48000);
3886 set_next_mime_type(ast_format_slin96, 0, "audio", "L16", 96000);
3887 set_next_mime_type(ast_format_slin192, 0, "audio", "L16", 192000);
3888 set_next_mime_type(ast_format_lpc10, 0, "audio", "LPC", 8000);
3889 set_next_mime_type(ast_format_g729, 0, "audio", "G729", 8000);
3890 set_next_mime_type(ast_format_g729, 0, "audio", "G729A", 8000);
3891 set_next_mime_type(ast_format_g729, 0, "audio", "G.729", 8000);
3892 set_next_mime_type(ast_format_speex, 0, "audio", "speex", 8000);
3893 set_next_mime_type(ast_format_speex16, 0, "audio", "speex", 16000);
3894 set_next_mime_type(ast_format_speex32, 0, "audio", "speex", 32000);
3895 set_next_mime_type(ast_format_ilbc, 0, "audio", "iLBC", 8000);
3896 /* this is the sample rate listed in the RTP profile for the G.722 codec, *NOT* the actual sample rate of the media stream */
3897 set_next_mime_type(ast_format_g722, 0, "audio", "G722", 8000);
3898 set_next_mime_type(ast_format_g726_aal2, 0, "audio", "AAL2-G726-32", 8000);
3899 /* we need all possible dtmf/bitrate combinations or ast_rtp_codecs_payloads_set_rtpmap_type_rate will not examine it */
3900 set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 8000);
3901 set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 16000);
3902 set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 24000);
3903 set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 32000);
3904 set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 48000);
3905 set_next_mime_type(NULL, AST_RTP_CISCO_DTMF, "audio", "cisco-telephone-event", 8000);
3906 set_next_mime_type(NULL, AST_RTP_CN, "audio", "CN", 8000);
3907 set_next_mime_type(ast_format_jpeg, 0, "video", "JPEG", 90000);
3908 set_next_mime_type(ast_format_png, 0, "video", "PNG", 90000);
3909 set_next_mime_type(ast_format_h261, 0, "video", "H261", 90000);
3910 set_next_mime_type(ast_format_h263, 0, "video", "H263", 90000);
3911 set_next_mime_type(ast_format_h263p, 0, "video", "h263-1998", 90000);
3912 set_next_mime_type(ast_format_h264, 0, "video", "H264", 90000);
3913 set_next_mime_type(ast_format_h265, 0, "video", "H265", 90000);
3914 set_next_mime_type(ast_format_mp4, 0, "video", "MP4V-ES", 90000);
3915 set_next_mime_type(ast_format_t140_red, 0, "text", "RED", 1000);
3916 set_next_mime_type(ast_format_t140, 0, "text", "T140", 1000);
3917 set_next_mime_type(ast_format_siren7, 0, "audio", "G7221", 16000);
3918 set_next_mime_type(ast_format_siren14, 0, "audio", "G7221", 32000);
3919 set_next_mime_type(ast_format_g719, 0, "audio", "G719", 48000);
3920 /* Opus, VP8, and VP9 */
3921 set_next_mime_type(ast_format_opus, 0, "audio", "opus", 48000);
3922 set_next_mime_type(ast_format_vp8, 0, "video", "VP8", 90000);
3923 set_next_mime_type(ast_format_vp9, 0, "video", "VP9", 90000);
3924
3925 /* Define the static rtp payload mappings */
3927 #ifdef USE_DEPRECATED_G726
3928 add_static_payload(2, ast_format_g726, 0);/* Technically this is G.721, but if Cisco can do it, so can we... */
3929 #endif
3932 add_static_payload(5, ast_format_adpcm, 0);/* 8 kHz */
3933 add_static_payload(6, ast_format_adpcm, 0); /* 16 kHz */
3937 add_static_payload(10, ast_format_slin, 0); /* 2 channels */
3938 add_static_payload(11, ast_format_slin, 0); /* 1 channel */
3940 add_static_payload(16, ast_format_adpcm, 0); /* 11.025 kHz */
3941 add_static_payload(17, ast_format_adpcm, 0); /* 22.050 kHz */
3943 add_static_payload(19, NULL, AST_RTP_CN); /* Also used for CN */
3947
3948 /*
3949 * Dynamic payload types - Even when dynamically assigning them we'll fall
3950 * back to using the statically declared values as the default number.
3951 */
3954
3961 add_static_payload(105, ast_format_t140_red, 0); /* Real time text chat (with redundancy encoding) */
3962 add_static_payload(106, ast_format_t140, 0); /* Real time text chat */
3966
3970
3974 add_static_payload(118, ast_format_slin16, 0); /* 16 Khz signed linear */
3976
3977 add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */
3984 /* payload types above 127 are not valid */
3985
3993
3994 /*
3995 * Normnally a core module should call ast_register_cleanup,
3996 * which doesn't run if any module fails to unload. This
3997 * prevents resources being pulled out from under a running
3998 * module and possibly causing a segfault. In this case however,
3999 * the only thing we're cleaning up are the registrations of the
4000 * debug categories.
4001 */
4003
4004 return 0;
4005}
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition clicompat.c:13
struct ast_format * ast_format_speex16
Built-in cached speex at 16kHz format.
struct ast_format * ast_format_h264
Built-in cached h264 format.
struct ast_format * ast_format_slin44
Built-in cached signed linear 44kHz format.
struct ast_format * ast_format_adpcm
Built-in cached adpcm format.
struct ast_format * ast_format_slin24
Built-in cached signed linear 24kHz format.
struct ast_format * ast_format_opus
Built-in cached opus format.
struct ast_format * ast_format_h265
Built-in cached h265 format.
struct ast_format * ast_format_gsm
Built-in cached gsm format.
struct ast_format * ast_format_slin32
Built-in cached signed linear 32kHz format.
struct ast_format * ast_format_siren14
Built-in cached siren14 format.
struct ast_format * ast_format_speex
Built-in cached speex format.
struct ast_format * ast_format_h263
Built-in cached h263 format.
struct ast_format * ast_format_mp4
Built-in cached mp4 format.
struct ast_format * ast_format_slin192
Built-in cached signed linear 192kHz format.
struct ast_format * ast_format_ilbc
Built-in cached ilbc format.
struct ast_format * ast_format_g726
Built-in cached g726 format.
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
struct ast_format * ast_format_lpc10
Built-in cached ilbc format.
struct ast_format * ast_format_slin16
Built-in cached signed linear 16kHz format.
struct ast_format * ast_format_slin96
Built-in cached signed linear 96kHz format.
struct ast_format * ast_format_slin48
Built-in cached signed linear 48kHz format.
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
struct ast_format * ast_format_siren7
Built-in cached siren7 format.
struct ast_format * ast_format_alaw
Built-in cached alaw format.
struct ast_format * ast_format_speex32
Built-in cached speex at 32kHz format.
struct ast_format * ast_format_h261
Built-in cached h261 format.
struct ast_format * ast_format_vp9
Built-in cached vp9 format.
struct ast_format * ast_format_t140_red
Built-in cached t140 red format.
struct ast_format * ast_format_slin12
Built-in cached signed linear 12kHz format.
struct ast_format * ast_format_h263p
Built-in cached h263 plus format.
struct ast_format * ast_format_png
Built-in cached png format.
struct ast_format * ast_format_g722
Built-in cached g722 format.
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
struct ast_format * ast_format_t140
Built-in cached t140 format.
struct ast_format * ast_format_g729
Built-in cached g729 format.
struct ast_format * ast_format_jpeg
Built-in cached jpeg format.
struct ast_format * ast_format_vp8
Built-in cached vp8 format.
struct ast_format * ast_format_g719
Built-in cached g719 format.
struct stasis_message_type * ast_rtp_rtcp_sent_type(void)
Message type for an RTCP message sent from this Asterisk instance.
struct stasis_message_type * ast_rtp_rtcp_received_type(void)
Message type for an RTCP message received from some external source.
uintmax_t ast_debug_category_register(const char *name)
Register a debug level logger category.
static uintmax_t debug_category_dtls_packet_id
static uintmax_t debug_category_rtcp_id
static struct stasis_topic * rtp_topic
Stasis Message Bus API topic for RTP related messages
Definition rtp_engine.c:283
static void rtp_engine_shutdown(void)
static void add_static_payload(int payload, struct ast_format *format, int rtp_code)
static ast_rwlock_t static_RTP_PT_lock
Definition rtp_engine.c:280
static uintmax_t debug_category_rtcp_packet_id
static uintmax_t debug_category_ice_id
static void rtp_engine_atexit(void)
static uintmax_t debug_category_rtp_id
static uintmax_t debug_category_rtp_packet_id
static uintmax_t debug_category_dtls_id
static void set_next_mime_type(struct ast_format *format, int rtp_code, const char *type, const char *subtype, unsigned int sample_rate)
static ast_rwlock_t mime_types_lock
Definition rtp_engine.c:266
#define AST_LOG_CATEGORY_ICE
#define AST_RTP_DTMF
Definition rtp_engine.h:294
#define AST_LOG_CATEGORY_RTCP_PACKET
#define AST_LOG_CATEGORY_DTLS
#define AST_LOG_CATEGORY_RTCP
#define AST_LOG_CATEGORY_RTP
#define AST_LOG_CATEGORY_RTP_PACKET
#define AST_LOG_CATEGORY_DTLS_PACKET
#define AST_RTP_CN
Definition rtp_engine.h:296
#define AST_RTP_CISCO_DTMF
Definition rtp_engine.h:298

References add_static_payload(), ast_debug_category_register(), 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_h265, 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_format_vp9, AST_LOG_CATEGORY_DTLS, AST_LOG_CATEGORY_DTLS_PACKET, AST_LOG_CATEGORY_ICE, AST_LOG_CATEGORY_RTCP, AST_LOG_CATEGORY_RTCP_PACKET, AST_LOG_CATEGORY_RTP, AST_LOG_CATEGORY_RTP_PACKET, ast_register_atexit(), 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, debug_category_dtls_id, debug_category_dtls_packet_id, debug_category_ice_id, debug_category_rtcp_id, debug_category_rtcp_packet_id, debug_category_rtp_id, debug_category_rtp_packet_id, mime_types_lock, NULL, rtp_engine_atexit(), rtp_engine_shutdown(), rtp_topic, set_next_mime_type(), STASIS_MESSAGE_TYPE_INIT, stasis_topic_create(), and static_RTP_PT_lock.

Referenced by asterisk_daemon().

◆ ast_ssl_init()

int ast_ssl_init ( void  )

Provided by ssl.c

Definition at line 205 of file libasteriskssl.c.

206{
207 return 0;
208}

Referenced by asterisk_daemon().

◆ ast_stun_init()

void ast_stun_init ( void  )

Initialize the STUN system in Asterisk.

Provided by stun.c

Definition at line 576 of file stun.c.

577{
578 ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
581
582 /*
583 * Normnally a core module should call ast_register_cleanup
584 * which doesn't run if any module fails to unload. This
585 * prevents resources being pulled out from under a running
586 * module and ppossibly causing a segfault. In this case however,
587 * the only thing we're cleaning up is the cli command and
588 * the registers of the debug categories.
589 */
591
592}
descriptor for a cli entry.
Definition cli.h:171
static void stun_shutdown(void)
Definition stun.c:567
static uintmax_t debug_category_stun_id
Definition stun.c:553
static uintmax_t debug_category_stun_packet_id
Definition stun.c:560
static struct ast_cli_entry cli_stun[]
Definition stun.c:549
#define AST_LOG_CATEGORY_STUN_PACKET
Definition stun.h:40
#define AST_LOG_CATEGORY_STUN
Definition stun.h:38

References ast_cli_register_multiple, ast_debug_category_register(), AST_LOG_CATEGORY_STUN, AST_LOG_CATEGORY_STUN_PACKET, ast_register_atexit(), cli_stun, debug_category_stun_id, debug_category_stun_packet_id, and stun_shutdown().

Referenced by asterisk_daemon().

◆ ast_taskpool_init()

int ast_taskpool_init ( void  )

Provided by taskpool.c

Definition at line 931 of file taskpool.c.

932{
934 if (!sched) {
935 return -1;
936 }
937
939 return -1;
940 }
941
943
944 return 0;
945}
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition sched.c:197
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition sched.c:238
Definition sched.c:76
static void taskpool_shutdown(void)
Definition taskpool.c:923

References ast_register_cleanup(), ast_sched_context_create(), ast_sched_start_thread(), and taskpool_shutdown().

Referenced by asterisk_daemon().

◆ ast_term_init()

int ast_term_init ( void  )

Provided by term.c

Definition at line 165 of file term.c.

166{
167 char *term = getenv("TERM");
168 char termfile[256] = "";
169 int termfd = -1, parseokay = 0, i;
170
171 if (ast_opt_no_color) {
172 return 0;
173 }
174
175 if (!ast_opt_console) {
176 /* If any remote console is not compatible, we'll strip the color codes at that point */
177 vt100compat = 1;
178 goto end;
179 }
180
181 if (!term) {
182 return 0;
183 }
184
185 for (i = 0; !parseokay && termpath[i]; i++) {
186 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term);
187
188 termfd = open(termfile, O_RDONLY);
189 if (termfd > -1) {
190 parseokay = parse_terminfo_file(termfd);
191 close(termfd);
192 }
193 }
194
195 if (!parseokay) {
196 /* These comparisons should not be substrings nor case-insensitive, as
197 * terminal types are very particular about how they treat suffixes and
198 * capitalization. For example, terminal type 'linux-m' does NOT
199 * support color, while 'linux' does. Not even all vt100* terminals
200 * support color, either (e.g. 'vt100+fnkeys'). */
201 if (!strcmp(term, "linux")) {
202 vt100compat = 1;
203 } else if (!strcmp(term, "xterm")) {
204 vt100compat = 1;
205 } else if (!strcmp(term, "xterm-color")) {
206 vt100compat = 1;
207 } else if (!strcmp(term, "xterm-256color")) {
208 vt100compat = 1;
209 } else if (!strncmp(term, "Eterm", 5)) {
210 /* Both entries which start with Eterm support color */
211 vt100compat = 1;
212 } else if (!strcmp(term, "vt100")) {
213 vt100compat = 1;
214 } else if (!strncmp(term, "crt", 3)) {
215 /* Both crt terminals support color */
216 vt100compat = 1;
217 }
218 }
219
220end:
221 if (vt100compat) {
222 /* Make commands show up in nice colors */
224 snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
226 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
227 } else {
228 snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, ATTR_RESET);
229 }
230 snprintf(quitdata, sizeof(quitdata), "%c[%dm", ESC, ATTR_RESET);
231 }
232 return 0;
233}
char * end
Definition eagi_proxy.c:73
#define ast_opt_console
Definition options.h:121
#define ast_opt_no_color
Definition options.h:126
#define ast_opt_force_black_background
Definition options.h:141
#define ast_opt_light_background
Definition options.h:140
static int vt100compat
Definition term.c:43
static char enddata[80]
Definition term.c:45
static int parse_terminfo_file(int fd)
Definition term.c:106
static char quitdata[80]
Definition term.c:46
static const char *const termpath[]
Definition term.c:48
#define ESC
Definition term.h:30
#define COLOR_WHITE
Definition term.h:64
#define COLOR_BLACK
Definition term.h:50
#define ATTR_RESET
Definition term.h:36

References ast_opt_console, ast_opt_force_black_background, ast_opt_light_background, ast_opt_no_color, ATTR_RESET, COLOR_BLACK, COLOR_WHITE, end, enddata, ESC, parse_terminfo_file(), quitdata, termpath, and vt100compat.

Referenced by ast_remotecontrol(), asterisk_daemon(), and main().

◆ ast_test_init()

int ast_test_init ( void  )

Provided by test.c

Definition at line 1505 of file test.c.

1506{
1507#ifdef TEST_FRAMEWORK
1508 ast_register_cleanup(test_cleanup);
1509
1510 /* Create stasis topic */
1511 test_suite_topic = stasis_topic_create("testsuite:all");
1512 if (!test_suite_topic) {
1513 return -1;
1514 }
1515
1516 if (STASIS_MESSAGE_TYPE_INIT(ast_test_suite_message_type) != 0) {
1517 return -1;
1518 }
1519
1520 AST_TEST_REGISTER(test_registrations);
1521
1522 /* Register cli commands */
1523 ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
1524#endif
1525
1526 return 0;
1527}
#define AST_TEST_REGISTER(cb)
Definition test.h:127

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

Referenced by asterisk_daemon().

◆ ast_timing_init()

int ast_timing_init ( void  )

Provided by timing.c

Definition at line 289 of file timing.c.

290{
292 return -1;
293 }
294
296
298}
#define ast_heap_create(init_height, cmp_fn, index_offset)
Create a max heap.
Definition heap.h:100
static void timing_shutdown(void)
Definition timing.c:281
static struct ast_heap * timing_interfaces
Definition timing.c:52
static struct ast_cli_entry cli_timing[]
Definition timing.c:277
static int timing_holder_cmp(void *_h1, void *_h2)
Definition timing.c:59

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

Referenced by asterisk_daemon().

◆ ast_tps_init()

int ast_tps_init ( void  )

Provided by taskprocessor.c

Definition at line 368 of file taskprocessor.c.

369{
372 if (!tps_singletons) {
373 ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
374 return -1;
375 }
376
377 if (AST_VECTOR_RW_INIT(&overloaded_subsystems, 10)) {
378 ao2_ref(tps_singletons, -1);
379 ast_log(LOG_ERROR, "taskprocessor subsystems vector failed to initialize!\n");
380 return -1;
381 }
382
383 ast_cond_init(&cli_ping_cond, NULL);
384
385 ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
386
388
389 return 0;
390}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
static void tps_shutdown(void)
#define TPS_MAX_BUCKETS
static int tps_cmp_cb(void *obj, void *arg, int flags)
static int tps_hash_cb(const void *obj, const int flags)
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.
Definition vector.h:169

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ARRAY_LEN, ast_cli_register_multiple, ast_cond_init, ast_log, ast_register_cleanup(), AST_VECTOR_RW_INIT, LOG_ERROR, NULL, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, and tps_shutdown().

Referenced by asterisk_daemon().

◆ ast_xmldoc_load_documentation()

int ast_xmldoc_load_documentation ( void  )

Load XML documentation. Provided by xmldoc.c.

Return values
1on error.
0on success.

Definition at line 3146 of file xmldoc.c.

3147{
3148 return xmldoc_load_documentation(1);
3149}
static int xmldoc_load_documentation(int first_time)
Definition xmldoc.c:3019

References xmldoc_load_documentation().

Referenced by asterisk_daemon().

◆ astdb_init()

int astdb_init ( void  )

Provided by db.c

Definition at line 1250 of file db.c.

1251{
1253
1254 if (db_init()) {
1255 return -1;
1256 }
1257
1259 return -1;
1260 }
1261
1269 return 0;
1270}
static int manager_dbdel(struct mansession *s, const struct message *m)
Definition db.c:1117
static int manager_db_tree_get(struct mansession *s, const struct message *m)
Definition db.c:1051
static int manager_dbdeltree(struct mansession *s, const struct message *m)
Definition db.c:1142
static struct ast_cli_entry cli_database[]
Definition db.c:974
static int manager_dbget(struct mansession *s, const struct message *m)
Definition db.c:1009
static int db_init(void)
Definition db.c:290
static int manager_dbput(struct mansession *s, const struct message *m)
Definition db.c:984
static void * db_sync_thread(void *data)
Definition db.c:1192
static ast_cond_t dbcond
Definition db.c:137
static pthread_t syncthread
Definition db.c:139
static void astdb_atexit(void)
Definition db.c:1225
#define EVENT_FLAG_REPORTING
Definition manager.h:84

References ARRAY_LEN, ast_cli_register_multiple, ast_cond_init, ast_manager_register_xml_core, ast_pthread_create_background, ast_register_atexit(), astdb_atexit(), cli_database, db_init(), db_sync_thread(), dbcond, EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, manager_db_tree_get(), manager_dbdel(), manager_dbdeltree(), manager_dbget(), manager_dbput(), NULL, and syncthread.

Referenced by asterisk_daemon().

◆ astobj2_init()

int astobj2_init ( void  )

Provided by astobj2.c

Definition at line 1169 of file astobj2.c.

1170{
1171 char ref_filename[1024];
1172
1173 if (ast_opt_ref_debug) {
1174 snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
1175 ref_log = fopen(ref_filename, "w");
1176 if (!ref_log) {
1177 ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
1178 }
1179 }
1180
1182
1183 if (container_init() != 0) {
1184 fclose(ref_log);
1185 ref_log = NULL;
1186 return -1;
1187 }
1188
1189#if defined(AO2_DEBUG)
1190 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
1191#endif /* defined(AO2_DEBUG) */
1192
1193 return 0;
1194}
static void astobj2_cleanup(void)
Definition astobj2.c:1157
static FILE * ref_log
Definition astobj2.c:44
int container_init(void)
#define ast_opt_ref_debug
Definition options.h:145
const char * ast_config_AST_LOG_DIR
Definition options.c:160

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

Referenced by asterisk_daemon().

◆ clean_time_zones()

void clean_time_zones ( void  )

Provided by localtime.c

Definition at line 1590 of file localtime.c.

1591{
1592 struct state *sp;
1593
1595 while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
1596 sstate_free(sp);
1597 }
1599}
static void sstate_free(struct state *p)
Definition localtime.c:789
struct state::@433 list

References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, state::list, and sstate_free().

Referenced by really_quit().

◆ close_logger()

void close_logger ( void  )

Provided by logger.c

Definition at line 2215 of file logger.c.

2216{
2217 struct logchannel *f = NULL;
2218
2220
2223
2225
2226 /* Stop logger thread */
2231
2233 pthread_join(logthread, NULL);
2234 }
2235
2237
2238 if (qlog) {
2239 fclose(qlog);
2240 qlog = NULL;
2241 }
2242
2243 while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) {
2244 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
2245 fclose(f->fileptr);
2246 f->fileptr = NULL;
2247 }
2248 ast_free(f);
2249 }
2250
2252
2253 closelog(); /* syslog */
2254
2256}
void ast_cli_unregister_multiple(void)
Definition ael_main.c:408
#define AST_PTHREADT_NULL
Definition lock.h:73
#define ast_cond_signal(cond)
Definition lock.h:210
static int callid_group_remove_filters(void)
Definition logger.c:1694
static struct ast_custom_function log_group_function
Definition logger.c:1781
static int close_logger_thread
Definition logger.c:196
static FILE * qlog
Definition logger.c:198
static int logger_initialized
Definition logger.c:86
static pthread_t logthread
Definition logger.c:194
static ast_cond_t logcond
Definition logger.c:195
static struct ast_cli_entry cli_logger[]
Definition logger.c:1871
int ast_logger_category_unload(void)
Unload system wide logger category functionality.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
struct logchannel::@395 list
FILE * fileptr
Definition logger.c:149

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

Referenced by really_quit().

◆ dns_core_init()

int dns_core_init ( void  )

Provided by dns_core.c

Definition at line 616 of file dns_core.c.

617{
619 if (!sched) {
620 return -1;
621 }
622
624 return -1;
625 }
626
628
629 return 0;
630}
static void dns_shutdown(void)
Definition dns_core.c:608

References ast_register_cleanup(), ast_sched_context_create(), ast_sched_start_thread(), and dns_shutdown().

Referenced by asterisk_daemon().

◆ dnsmgr_start_refresh()

void dnsmgr_start_refresh ( void  )

Provided by dnsmgr.c

Definition at line 302 of file dnsmgr.c.

303{
304 if (refresh_sched > -1) {
307 }
308}
static int refresh_list(const void *data)
Definition dnsmgr.c:272
static struct refresh_info master_refresh_info
Definition dnsmgr.c:101
static int refresh_sched
Definition dnsmgr.c:63
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
Definition sched.h:46
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
Definition sched.c:526

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

Referenced by asterisk_daemon().

◆ init_logger()

int init_logger ( void  )

Provided by logger.c

Definition at line 2172 of file logger.c.

2173{
2174 int res;
2175 /* auto rotate if sig SIGXFSZ comes a-knockin */
2176 sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
2177
2178 /* Re-initialize the logmsgs mutex. The recursive mutex can be accessed prior
2179 * to Asterisk being forked into the background, which can cause the thread
2180 * ID tracked by the underlying pthread mutex to be different than the ID of
2181 * the thread that unlocks the mutex. Since init_logger is called after the
2182 * fork, it is safe to initialize the mutex here for future accesses.
2183 */
2187
2188 /* start logger thread */
2191 return -1;
2192 }
2193
2194 /* register the logger cli commands */
2197
2199
2200 /* create log channels */
2202 res = init_logger_chain(NULL);
2206 if (res) {
2207 ast_log(LOG_ERROR, "Errors detected in logger.conf. Default console logging is being used.\n");
2208 }
2209
2211
2212 return 0;
2213}
#define ast_cond_destroy(cond)
Definition lock.h:209
#define ast_mutex_init(pmutex)
Definition lock.h:193
#define ast_mutex_destroy(a)
Definition lock.h:195
static int init_logger_chain(const char *altconf)
Read config, setup channels.
Definition logger.c:756
static struct sigaction handle_SIGXFSZ
Definition logger.c:1890
static void * logger_thread(void *data)
Actual logging thread.
Definition logger.c:2067
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition logger.c:2554
int ast_logger_category_load(void)
Load/Initialize system wide logger category functionality.
#define ast_custom_function_register(acf)
Register a custom function.
Definition pbx.h:1562
ast_mutex_t lock
Definition logger.c:193
#define ast_pthread_create(a, b, c, d)
Definition utils.h:624
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition utils.c:2515

References ARRAY_LEN, ast_cli_register_multiple, ast_cond_destroy, ast_cond_init, ast_config_AST_LOG_DIR, ast_custom_function_register, ast_log, ast_logger_category_load(), ast_mkdir(), ast_mutex_destroy, ast_mutex_init, ast_pthread_create, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb_update(), cli_logger, handle_SIGXFSZ, init_logger_chain(), logmsgs::lock, LOG_ERROR, log_group_function, logcond, logger_initialized, logger_thread(), logthread, and NULL.

Referenced by asterisk_daemon().

◆ load_asterisk_conf()

void load_asterisk_conf ( void  )

Definition at line 211 of file options.c.

212{
213 struct ast_config *cfg;
214 struct ast_variable *v;
215 char hostname[MAXHOSTNAMELEN] = "";
216 struct ast_flags config_flags = { CONFIG_FLAG_NOREALTIME };
217 struct {
218 unsigned int dbdir:1;
219 unsigned int keydir:1;
220 } found = { 0, 0 };
221 /* Default to false for security */
222 int live_dangerously = 0;
223 int option_debug_new = 0;
224 int option_trace_new = 0;
225 int option_verbose_new = 0;
226
227
228 /* init with buildtime config */
229#ifdef REF_DEBUG
230 /* The REF_DEBUG compiler flag is now only used to enable refdebug by default.
231 * Support for debugging reference counts is always compiled in. */
233#endif
234
236
237 cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
238
239 /* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.
240 * Using #exec from other configs requires that it be enabled from asterisk.conf. */
242
243 /* no asterisk.conf? no problem, use buildtime config! */
245 fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
246 return;
247 }
248
249 for (v = ast_variable_browse(cfg, "files"); v; v = v->next) {
250 if (!strcasecmp(v->name, "astctlpermissions")) {
252 } else if (!strcasecmp(v->name, "astctlowner")) {
254 } else if (!strcasecmp(v->name, "astctlgroup")) {
256 } else if (!strcasecmp(v->name, "astctl")) {
258 }
259 }
260
261 for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {
262 if (!strcasecmp(v->name, "astcachedir")) {
264 } else if (!strcasecmp(v->name, "astetcdir")) {
266 } else if (!strcasecmp(v->name, "astspooldir")) {
268 snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", v->value);
269 snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", v->value);
270 } else if (!strcasecmp(v->name, "astvarlibdir")) {
272 if (!found.dbdir) {
273 snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);
274 }
275 } else if (!strcasecmp(v->name, "astdbdir")) {
276 snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);
277 found.dbdir = 1;
278 } else if (!strcasecmp(v->name, "astdatadir")) {
280 if (!found.keydir) {
281 snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);
282 }
283 } else if (!strcasecmp(v->name, "astkeydir")) {
284 snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);
285 found.keydir = 1;
286 } else if (!strcasecmp(v->name, "astlogdir")) {
288 } else if (!strcasecmp(v->name, "astagidir")) {
290 } else if (!strcasecmp(v->name, "astrundir")) {
291 snprintf(cfg_paths.pid_path, sizeof(cfg_paths.pid_path), "%s/%s", v->value, "asterisk.pid");
293 } else if (!strcasecmp(v->name, "astmoddir")) {
295 } else if (!strcasecmp(v->name, "astsbindir")) {
297 }
298 }
299
300 /* Combine astrundir and astctl settings. */
301 snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s",
303
304 for (v = ast_variable_browse(cfg, "options"); v; v = v->next) {
305 /* verbose level (-v at startup) */
306 if (!strcasecmp(v->name, "verbose")) {
307 option_verbose_new = atoi(v->value);
308 /* whether or not to force timestamping in CLI verbose output. (-T at startup) */
309 } else if (!strcasecmp(v->name, "timestamp")) {
311 /* whether or not to support #exec in config files */
312 } else if (!strcasecmp(v->name, "execincludes")) {
314 /* debug level (-d at startup) */
315 } else if (!strcasecmp(v->name, "debug")) {
316 option_debug_new = 0;
317 if (sscanf(v->value, "%30d", &option_debug_new) != 1) {
318 option_debug_new = ast_true(v->value) ? 1 : 0;
319 }
320 } else if (!strcasecmp(v->name, "trace")) {
321 option_trace_new = 0;
322 if (sscanf(v->value, "%30d", &option_trace_new) != 1) {
323 option_trace_new = ast_true(v->value) ? 1 : 0;
324 }
325 } else if (!strcasecmp(v->name, "refdebug")) {
327#if HAVE_WORKING_FORK
328 /* Disable forking (-f at startup) */
329 } else if (!strcasecmp(v->name, "nofork")) {
331 /* Always fork, even if verbose or debug are enabled (-F at startup) */
332 } else if (!strcasecmp(v->name, "alwaysfork")) {
334#endif
335 /* Run quietly (-q at startup ) */
336 } else if (!strcasecmp(v->name, "quiet")) {
338 /* Run as console (-c at startup, implies nofork) */
339 } else if (!strcasecmp(v->name, "console")) {
340 if (!ast_opt_remote) {
342 }
343 /* Run with high priority if the O/S permits (-p at startup) */
344 } else if (!strcasecmp(v->name, "highpriority")) {
346 /* Initialize RSA auth keys (IAX2) (-i at startup) */
347 } else if (!strcasecmp(v->name, "initcrypto")) {
349 /* Disable ANSI colors for console (-c at startup) */
350 } else if (!strcasecmp(v->name, "nocolor")) {
352 /* Disable some usage warnings for picky people :p */
353 } else if (!strcasecmp(v->name, "dontwarn")) {
355 /* Dump core in case of crash (-g) */
356 } else if (!strcasecmp(v->name, "dumpcore")) {
358 /* Cache recorded sound files to another directory during recording */
359 } else if (!strcasecmp(v->name, "cache_record_files")) {
361#if !defined(LOW_MEMORY)
362 /* Cache media frames for performance */
363 } else if (!strcasecmp(v->name, "cache_media_frames")) {
365#endif
366 /* Specify cache directory */
367 } else if (!strcasecmp(v->name, "record_cache_dir")) {
369 /* Build transcode paths via SLINEAR, instead of directly */
370 } else if (!strcasecmp(v->name, "transcode_via_sln")) {
372 /* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */
373 } else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) {
375 } else if (!strcasecmp(v->name, "mindtmfduration")) {
376 if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) {
378 }
379 } else if (!strcasecmp(v->name, "rtp_use_dynamic")) {
381 /* http://www.iana.org/assignments/rtp-parameters
382 * RTP dynamic payload types start at 96 normally; extend down to 0 */
383 } else if (!strcasecmp(v->name, "rtp_pt_dynamic")) {
386 } else if (!strcasecmp(v->name, "maxcalls")) {
387 if ((sscanf(v->value, "%30d", &ast_option_maxcalls) != 1) || (ast_option_maxcalls < 0)) {
389 }
390 } else if (!strcasecmp(v->name, "maxload")) {
391 double test[1];
392
393 if (getloadavg(test, 1) == -1) {
394 ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n");
395 ast_option_maxload = 0.0;
396 } else if ((sscanf(v->value, "%30lf", &ast_option_maxload) != 1) || (ast_option_maxload < 0.0)) {
397 ast_option_maxload = 0.0;
398 }
399 /* Set the maximum amount of open files */
400 } else if (!strcasecmp(v->name, "maxfiles")) {
401 ast_option_maxfiles = atoi(v->value);
402 if (!ast_opt_remote) {
404 }
405 /* What user to run as */
406 } else if (!strcasecmp(v->name, "runuser")) {
408 /* What group to run as */
409 } else if (!strcasecmp(v->name, "rungroup")) {
411 } else if (!strcasecmp(v->name, "systemname")) {
413 } else if (!strcasecmp(v->name, "autosystemname")) {
414 if (ast_true(v->value)) {
415 if (!gethostname(hostname, sizeof(hostname) - 1)) {
417 } else {
420 }
421 ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using '%s' instead.\n", ast_config_AST_SYSTEM_NAME);
422 }
423 }
424 } else if (!strcasecmp(v->name, "languageprefix")) {
426 } else if (!strcasecmp(v->name, "defaultlanguage")) {
428 } else if (!strcasecmp(v->name, "lockmode")) {
429 if (!strcasecmp(v->value, "lockfile")) {
431 } else if (!strcasecmp(v->value, "flock")) {
433 } else {
434 ast_log(LOG_WARNING, "'%s' is not a valid setting for the lockmode option, "
435 "defaulting to 'lockfile'\n", v->value);
437 }
438#if defined(HAVE_SYSINFO)
439 } else if (!strcasecmp(v->name, "minmemfree")) {
440 /* specify the minimum amount of free memory to retain. Asterisk should stop accepting new calls
441 * if the amount of free memory falls below this watermark */
442 if ((sscanf(v->value, "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) {
444 }
445#endif
446 } else if (!strcasecmp(v->name, "entityid")) {
447 struct ast_eid tmp_eid;
448 if (!ast_str_to_eid(&tmp_eid, v->value)) {
449 ast_eid_default = tmp_eid;
450 } else {
451 ast_log(LOG_WARNING, "Invalid Entity ID '%s' provided\n", v->value);
452 }
453 } else if (!strcasecmp(v->name, "lightbackground")) {
455 } else if (!strcasecmp(v->name, "forceblackbackground")) {
457 } else if (!strcasecmp(v->name, "hideconnect")) {
459 } else if (!strcasecmp(v->name, "lockconfdir")) {
461 } else if (!strcasecmp(v->name, "stdexten")) {
462 /* Choose how to invoke the extensions.conf stdexten */
463 if (!strcasecmp(v->value, "gosub")) {
465 } else if (!strcasecmp(v->value, "macro")) {
467 } else {
469 "'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n",
470 v->value);
472 }
473 } else if (!strcasecmp(v->name, "live_dangerously")) {
475 } else if (!strcasecmp(v->name, "hide_messaging_ami_events")) {
477 } else if (!strcasecmp(v->name, "sounds_search_custom_dir")) {
479 } else if (!strcasecmp(v->name, "channel_storage_backend")) {
481 } else if (!strcasecmp(v->name, "disable_remote_console_shell")) {
483 }
484 }
485 if (!ast_opt_remote) {
488 }
489
490 option_debug += option_debug_new;
491 option_trace += option_trace_new;
492 option_verbose += option_verbose_new;
493
495}
int getloadavg(double *list, int nelem)
int internal_channel_set_current_storage_driver(const char *driver_name)
Definition channel.c:8023
#define MAX_LANGUAGE
Definition channel.h:174
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous AMI actions to run.
Definition manager.c:196
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
Definition manager.c:2443
int ast_option_rtpusedynamic
Definition options.c:89
int ast_option_maxfiles
Definition options.c:82
int option_debug
Definition options.c:70
int ast_option_maxcalls
Definition options.c:80
int ast_option_disable_remote_console_shell
Definition options.c:91
struct ast_flags64 ast_options
Definition options.c:62
double ast_option_maxload
Definition options.c:78
unsigned int ast_option_rtpptdynamic
Definition options.c:90
int option_verbose
Definition options.c:68
unsigned int option_dtmfminduration
Definition options.c:84
long option_minmemfree
Definition options.c:87
int option_trace
Definition options.c:72
@ AST_OPT_FLAG_HIGH_PRIORITY
Definition options.h:49
@ AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS
Definition options.h:93
@ AST_OPT_FLAG_TRANSCODE_VIA_SLIN
Definition options.h:61
@ AST_OPT_FLAG_HIDE_CONSOLE_CONNECT
Definition options.h:97
@ AST_OPT_FLAG_EXEC_INCLUDES
Definition options.h:41
@ AST_OPT_FLAG_NO_COLOR
Definition options.h:57
@ AST_OPT_FLAG_NO_FORK
Definition options.h:43
@ AST_OPT_FLAG_REF_DEBUG
Definition options.h:81
@ AST_OPT_FLAG_TRANSMIT_SILENCE
Definition options.h:75
@ AST_OPT_FLAG_ALWAYS_FORK
Definition options.h:83
@ AST_OPT_FLAG_QUIET
Definition options.h:45
@ AST_OPT_FLAG_STDEXTEN_MACRO
Definition options.h:63
@ AST_OPT_FLAG_CACHE_MEDIA_FRAMES
Definition options.h:71
@ AST_OPT_FLAG_TIMESTAMP
Definition options.h:69
@ AST_OPT_FLAG_LOCK_CONFIG_DIR
Definition options.h:99
@ AST_OPT_FLAG_CACHE_RECORD_FILES
Definition options.h:67
@ AST_OPT_FLAG_INIT_KEYS
Definition options.h:51
@ AST_OPT_FLAG_CONSOLE
Definition options.h:47
@ AST_OPT_FLAG_DONT_WARN
Definition options.h:77
@ AST_OPT_FLAG_FORCE_BLACK_BACKGROUND
Definition options.h:95
@ AST_OPT_FLAG_LIGHT_BACKGROUND
Definition options.h:91
@ AST_OPT_FLAG_DUMP_CORE
Definition options.h:65
@ AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM
Definition options.h:79
@ AST_LOCK_TYPE_LOCKFILE
@ AST_LOCK_TYPE_FLOCK
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
Definition main/app.c:2609
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEINVALID
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
@ CONFIG_FLAG_NOREALTIME
static char hostname[MAXHOSTNAMELEN]
Definition logger.c:116
#define MAXHOSTNAMELEN
Definition network.h:69
static struct _cfg_paths cfg_paths
Definition options.c:129
char record_cache_dir[AST_CACHE_DIR_LEN]
Definition options.c:97
#define AST_MIN_DTMF_DURATION
Definition options.c:50
const char * ast_config_AST_RUN_DIR
Definition options.c:163
char ast_defaultlanguage[MAX_LANGUAGE]
Definition options.c:99
const char * ast_config_AST_SYSTEM_NAME
Definition options.c:171
struct ast_eid ast_eid_default
Global EID.
Definition options.c:94
const char * ast_config_AST_CONFIG_FILE
Definition options.c:153
static void set_ulimit(int value)
Set maximum open files.
Definition options.c:179
const char * ast_config_AST_CTL
Definition options.c:176
#define ast_opt_remote
Definition options.h:124
int ast_language_is_prefix
The following variable controls the layout of localized sound files. If 0, use the historical layout ...
Definition file.c:68
#define AST_CACHE_DIR_LEN
Definition options.h:32
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of 'dangerous' functions from external protocols (AMI,...
#define AST_RTP_PT_FIRST_DYNAMIC
Definition rtp_engine.h:92
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2235
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
char system_name[128]
Definition options.c:122
char monitor_dir[PATH_MAX]
Definition options.c:106
char ctl_perms[PATH_MAX]
Definition options.c:123
char run_dir[PATH_MAX]
Definition options.c:112
char config_dir[PATH_MAX]
Definition options.c:103
char log_dir[PATH_MAX]
Definition options.c:110
char key_dir[PATH_MAX]
Definition options.c:113
char pid_path[PATH_MAX]
Definition options.c:118
char sbin_dir[PATH_MAX]
Definition options.c:117
char spool_dir[PATH_MAX]
Definition options.c:105
char recording_dir[PATH_MAX]
Definition options.c:107
char var_dir[PATH_MAX]
Definition options.c:108
char ctl_group[PATH_MAX]
Definition options.c:125
char run_group[PATH_MAX]
Definition options.c:121
char data_dir[PATH_MAX]
Definition options.c:109
char ctl_owner[PATH_MAX]
Definition options.c:124
char socket_path[PATH_MAX]
Definition options.c:119
char ctl_file[PATH_MAX]
Definition options.c:126
char cache_dir[PATH_MAX]
Definition options.c:102
char db_path[PATH_MAX]
Definition options.c:116
char run_user[PATH_MAX]
Definition options.c:120
char module_dir[PATH_MAX]
Definition options.c:104
char agi_dir[PATH_MAX]
Definition options.c:111
An Entity ID is essentially a MAC address, brief and unique.
Definition utils.h:853
#define ast_set2_flag64(p, value, flag)
Definition utils.h:171
#define ast_clear_flag64(p, flag)
Definition utils.h:154
void ast_set_default_eid(struct ast_eid *eid)
Fill in an ast_eid with the default eid of this machine.
Definition utils.c:3037
#define ast_set_flag64(p, flag)
Definition utils.h:147
int ast_str_to_eid(struct ast_eid *eid, const char *s)
Convert a string into an EID.
Definition utils.c:3113

References _cfg_paths::agi_dir, AST_CACHE_DIR_LEN, ast_clear_flag64, ast_config_AST_CONFIG_FILE, ast_config_AST_CTL, ast_config_AST_RUN_DIR, ast_config_AST_SYSTEM_NAME, ast_config_destroy(), ast_config_load2(), ast_copy_string(), ast_defaultlanguage, ast_eid_default, ast_language_is_prefix, AST_LOCK_TYPE_FLOCK, AST_LOCK_TYPE_LOCKFILE, ast_log, AST_MIN_DTMF_DURATION, AST_OPT_FLAG_ALWAYS_FORK, AST_OPT_FLAG_CACHE_MEDIA_FRAMES, AST_OPT_FLAG_CACHE_RECORD_FILES, AST_OPT_FLAG_CONSOLE, AST_OPT_FLAG_DONT_WARN, AST_OPT_FLAG_DUMP_CORE, AST_OPT_FLAG_EXEC_INCLUDES, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT, AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS, AST_OPT_FLAG_HIGH_PRIORITY, AST_OPT_FLAG_INIT_KEYS, AST_OPT_FLAG_LIGHT_BACKGROUND, AST_OPT_FLAG_LOCK_CONFIG_DIR, AST_OPT_FLAG_NO_COLOR, AST_OPT_FLAG_NO_FORK, AST_OPT_FLAG_QUIET, AST_OPT_FLAG_REF_DEBUG, AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM, AST_OPT_FLAG_STDEXTEN_MACRO, AST_OPT_FLAG_TIMESTAMP, AST_OPT_FLAG_TRANSCODE_VIA_SLIN, AST_OPT_FLAG_TRANSMIT_SILENCE, ast_opt_remote, ast_option_disable_remote_console_shell, ast_option_maxcalls, ast_option_maxfiles, ast_option_maxload, ast_option_rtpptdynamic, ast_option_rtpusedynamic, ast_options, ast_parse_arg(), AST_RTP_PT_FIRST_DYNAMIC, ast_set2_flag64, ast_set_default_eid(), ast_set_flag64, ast_set_lock_type(), ast_str_to_eid(), ast_strlen_zero(), ast_true(), ast_variable_browse(), astman_live_dangerously(), _cfg_paths::cache_dir, cfg_paths, _cfg_paths::config_dir, CONFIG_FLAG_NOREALTIME, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, _cfg_paths::ctl_file, _cfg_paths::ctl_group, _cfg_paths::ctl_owner, _cfg_paths::ctl_perms, _cfg_paths::data_dir, _cfg_paths::db_path, getloadavg(), hostname, internal_channel_set_current_storage_driver(), _cfg_paths::key_dir, live_dangerously, _cfg_paths::log_dir, LOG_ERROR, LOG_WARNING, MAX_LANGUAGE, MAXHOSTNAMELEN, _cfg_paths::module_dir, _cfg_paths::monitor_dir, ast_variable::name, ast_variable::next, option_debug, option_dtmfminduration, option_minmemfree, option_trace, option_verbose, PARSE_IN_RANGE, PARSE_UINT32, pbx_live_dangerously(), _cfg_paths::pid_path, record_cache_dir, _cfg_paths::recording_dir, _cfg_paths::run_dir, _cfg_paths::run_group, _cfg_paths::run_user, _cfg_paths::sbin_dir, set_ulimit(), _cfg_paths::socket_path, _cfg_paths::spool_dir, _cfg_paths::system_name, ast_variable::value, and _cfg_paths::var_dir.

Referenced by main().

◆ load_astmm_phase_1()

void load_astmm_phase_1 ( void  )

Initialize malloc debug phase 1.

Note
Must be called first thing after forking.

Definition at line 1525 of file astmm.c.

1526{
1527}

Referenced by asterisk_daemon().

◆ load_astmm_phase_2()

void load_astmm_phase_2 ( void  )

Initialize malloc debug phase 2.

Definition at line 1529 of file astmm.c.

1530{
1531}

Referenced by asterisk_daemon().

◆ load_modules()

int load_modules ( void  )

Provided by loader.c

Definition at line 2517 of file loader.c.

2518{
2519 struct load_order_entry *order;
2520 unsigned int load_count;
2521 struct load_order load_order;
2522 int res = 0;
2523 int modulecount = 0;
2524 int i;
2525 struct ast_module *cur;
2526#ifdef AST_XML_DOCS
2527 struct ast_str *warning_msg;
2528 char deprecated_in[33];
2529 char removed_in[33];
2530 char replacement[129];
2531#endif
2532 struct timeval start_time = ast_tvnow();
2533 struct timeval end_time;
2534 int64_t usElapsed;
2535
2536 ast_verb(1, "Asterisk Dynamic Loader Starting:\n");
2537
2538#if defined(HAVE_PERMANENT_DLOPEN)
2540 info_list_obj_cmp_fn); /* must not be cleaned at shutdown */
2541 if (!info_list) {
2542 fprintf(stderr, "Module info list allocation failure.\n");
2543 return 1;
2544 }
2545#endif
2546
2549
2552
2554 if (res) {
2555 goto done;
2556 }
2557
2559 if (res) {
2560 goto done;
2561 }
2562
2563 load_count = 0;
2565 load_count++;
2566
2567 if (load_count)
2568 ast_log(LOG_NOTICE, "%u modules will be loaded.\n", load_count);
2569
2570 res = load_resource_list(&load_order, &modulecount);
2571 if (res == -1) {
2572 ast_log(LOG_WARNING, "Some non-required modules failed to load.\n");
2573 res = 0;
2574 }
2575
2576done:
2577 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
2578 ast_free(order->resource);
2579 ast_free(order);
2580 }
2581
2582#ifdef AST_XML_DOCS
2583 warning_msg = ast_str_create(512);
2584#endif
2585
2586 AST_DLLIST_TRAVERSE(&module_list, cur, entry) {
2587#ifdef AST_XML_DOCS
2588 char *mod_name = NULL;
2589 struct ast_xml_xpath_results *results;
2590#endif
2591
2592 if (!cur->flags.running || cur->flags.declined) {
2593 continue;
2594 }
2595
2596#ifdef AST_XML_DOCS
2597 mod_name = get_name_from_resource(cur->resource);
2598 if (!warning_msg || !mod_name) {
2599 /* If we can't allocate memory, we have bigger issues */
2600 ast_free(mod_name);
2601 continue;
2602 }
2603
2604 /* Clear out the previous values */
2605 deprecated_in[0] = removed_in[0] = replacement[0] = 0;
2606
2607 results = ast_xmldoc_query("/docs/module[@name='%s']", mod_name);
2608 if (results) {
2609 struct ast_xml_node *deprecated_node, *removed_node, *replacement_node;
2610 struct ast_xml_node *metadata_nodes = ast_xml_node_get_children(ast_xml_xpath_get_first_result(results));
2611
2612 deprecated_node = ast_xml_find_element(metadata_nodes, "deprecated_in", NULL, NULL);
2613 if (deprecated_node) {
2614 const char *result_tmp = ast_xml_get_text(deprecated_node);
2615 if (!ast_strlen_zero(result_tmp)) {
2616 ast_copy_string(deprecated_in, result_tmp, sizeof(deprecated_in));
2617 }
2618 }
2619
2620 removed_node = ast_xml_find_element(metadata_nodes, "removed_in", NULL, NULL);
2621 if (removed_node) {
2622 const char *result_tmp = ast_xml_get_text(removed_node);
2623 if (!ast_strlen_zero(result_tmp)) {
2624 ast_copy_string(removed_in, result_tmp, sizeof(removed_in));
2625 }
2626 }
2627
2628 replacement_node = ast_xml_find_element(metadata_nodes, "replacement", NULL, NULL);
2629 if (replacement_node) {
2630 const char *result_tmp = ast_xml_get_text(replacement_node);
2631 if (!ast_strlen_zero(result_tmp)) {
2632 ast_copy_string(replacement, result_tmp, sizeof(replacement));
2633 }
2634 }
2635
2637 }
2638
2639 ast_str_reset(warning_msg);
2640
2641 if (cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED || !ast_strlen_zero(deprecated_in)
2642 || !ast_strlen_zero(removed_in) || !ast_strlen_zero(replacement)) {
2643 int already_butted = 0;
2644
2645 ast_str_append(&warning_msg, -1, "Module '%s' has been loaded", mod_name);
2646 if (!ast_strlen_zero(deprecated_in)) {
2647 ast_str_append(&warning_msg, -1, " but %s deprecated in Asterisk version %s",
2648 cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED ? "was" : "will be", deprecated_in);
2649 already_butted = 1;
2650 }
2651
2652 if (!ast_strlen_zero(removed_in)) {
2653 ast_str_append(&warning_msg, -1, " %s will be removed in Asterisk version %s", already_butted ? "and" : "but", removed_in);
2654 } else {
2655 ast_str_append(&warning_msg, -1, " %s may be removed in a future release", already_butted ? "and" : "but");
2656 }
2657
2658 ast_str_append(&warning_msg, -1, ".");
2659
2660 if (!ast_strlen_zero(replacement)) {
2661 ast_str_append(&warning_msg, -1, " Its replacement is '%s'.", replacement);
2662 }
2663 }
2664
2665 if (ast_str_strlen(warning_msg)) {
2666 ast_log(LOG_WARNING, "%s\n", ast_str_buffer(warning_msg));
2667 }
2668
2669 ast_free(mod_name);
2670#else
2672 ast_log(LOG_WARNING, "The deprecated module '%s' has been loaded and is running, it may be removed in a future version\n", cur->resource);
2673 }
2674#endif
2675 }
2676
2677#ifdef AST_XML_DOCS
2678 ast_free(warning_msg);
2679#endif
2680
2682
2683
2684 for (i = 0; i < AST_VECTOR_SIZE(&startup_errors); i++) {
2685 char *str = AST_VECTOR_GET(&startup_errors, i);
2686
2687 ast_log(LOG_ERROR, "%s", str);
2688 ast_free(str);
2689 }
2691
2694
2695 end_time = ast_tvnow();
2696 usElapsed = ast_tvdiff_us(end_time, start_time);
2697
2698#ifdef AST_XML_DOCS
2699 ast_debug(1, "Loader time with AST_XML_DOCS: %" PRId64 ".%06" PRId64 "\n", usElapsed / 1000000, usElapsed % 1000000);
2700#else
2701 ast_debug(1, "Loader time without AST_XML_DOCS: %" PRId64 ".%06" PRId64 "\n", usElapsed / 1000000, usElapsed % 1000000);
2702#endif
2703
2704 return res;
2705}
integer order
Definition analys.c:66
const char * str
Definition app_jack.c:150
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition astobj2.h:367
#define AST_DLLIST_LOCK(head)
Locks a list.
#define AST_DLLIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
static int load_resource_list(struct load_order *load_order, int *mod_count)
Definition loader.c:2280
static struct ast_vector_string startup_errors
Definition loader.c:162
static struct ast_str * startup_error_builder
Definition loader.c:163
static int loader_config_init(struct load_order *load_order)
Definition loader.c:2393
static int loader_builtin_init(struct load_order *load_order)
Definition loader.c:2358
static char * get_name_from_resource(const char *resource)
Definition loader.c:166
@ AST_MODULE_SUPPORT_DEPRECATED
Definition module.h:123
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition strings.h:730
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition strings.h:693
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
enum ast_module_support_level support_level
Definition module.h:430
unsigned int running
Definition loader.c:329
unsigned int declined
Definition loader.c:331
const struct ast_module_info * info
Definition loader.c:303
struct ast_module::@389 flags
char resource[0]
Definition loader.c:342
Support for dynamic strings.
Definition strings.h:623
Definition loader.c:2011
int done
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
Definition time.h:87
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:620
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition vector.h:185
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:691
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node's children.
Definition xml.c:395
const char * ast_xml_get_text(struct ast_xml_node *node)
Get an element content string.
Definition xml.c:353
struct ast_xml_node * ast_xml_xpath_get_first_result(struct ast_xml_xpath_results *results)
Return the first result node of an XPath query.
Definition xml.c:415
void ast_xml_xpath_results_free(struct ast_xml_xpath_results *results)
Free the XPath results.
Definition xml.c:425
struct ast_xml_node * ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue)
Find a node element by name.
Definition xml.c:297
struct ast_xml_xpath_results * ast_xmldoc_query(const char *fmt,...)
Execute an XPath query on the loaded XML documentation.
Definition xmldoc.c:2675

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, ast_copy_string(), ast_debug, AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, ast_log, AST_MODULE_SUPPORT_DEPRECATED, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), ast_str_strlen(), ast_strlen_zero(), ast_tvdiff_us(), ast_tvnow(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, ast_verb, ast_xml_find_element(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_xpath_get_first_result(), ast_xml_xpath_results_free(), ast_xmldoc_query(), ast_module::declined, done, ast_module::flags, get_name_from_resource(), ast_module::info, load_resource_list(), loader_builtin_init(), loader_config_init(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, NULL, order, ast_module::resource, ast_module::running, startup_error_builder, startup_errors, str, and ast_module_info::support_level.

Referenced by asterisk_daemon().

◆ load_pbx()

int load_pbx ( void  )

Provided by pbx.c

Definition at line 8450 of file pbx.c.

8451{
8452 int res = 0;
8453
8455
8456 /* Initialize the PBX */
8457 ast_verb(1, "Asterisk PBX Core Initializing\n");
8458
8459 ast_verb(5, "Registering builtin functions:\n");
8463
8464 /* Register manager application */
8467
8468 if (res) {
8469 return -1;
8470 }
8471
8473 return -1;
8474 }
8476 stasis_subscription_accept_message_type(device_state_sub, hint_change_message_type());
8477 stasis_subscription_accept_message_type(device_state_sub, hint_remove_message_type());
8479
8481 return -1;
8482 }
8485
8486 return 0;
8487}
struct stasis_message_type * ast_device_state_message_type(void)
Get the Stasis message type for device state messages.
struct stasis_topic * ast_device_state_topic_all(void)
Get the Stasis topic for device state messages.
#define EVENT_FLAG_CONFIG
Definition manager.h:82
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
Definition pbx.c:5991
static int action_extensionstatelist(struct mansession *s, const struct message *m)
Definition pbx.c:8373
static struct stasis_subscription * presence_state_sub
Subscription for presence state change events.
Definition pbx.c:790
static void presence_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
Definition pbx.c:8323
static void unload_pbx(void)
Definition pbx.c:8438
static struct ast_custom_function testtime_function
Definition pbx.c:8306
static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
Definition pbx.c:3605
static struct ast_cli_entry pbx_cli[]
Definition pbx.c:6136
static struct stasis_subscription * device_state_sub
Subscription for device state change events.
Definition pbx.c:788
static struct ast_custom_function exception_function
Definition pbx.c:2867
struct stasis_topic * ast_presence_state_topic_all(void)
Get presence state topic.
struct stasis_message_type * ast_presence_state_message_type(void)
Get presence state message type.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
Definition stasis.h:297
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition stasis.c:1090
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition stasis.c:1144
#define stasis_subscribe(topic, callback, data)
Definition stasis.h:649

References __ast_custom_function_register(), action_extensionstatelist(), ARRAY_LEN, ast_cli_register_multiple, ast_device_state_message_type(), ast_device_state_topic_all(), ast_manager_register_xml_core, ast_presence_state_message_type(), ast_presence_state_topic_all(), ast_register_cleanup(), ast_verb, device_state_cb(), device_state_sub, EVENT_FLAG_CALL, EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, exception_function, manager_show_dialplan(), NULL, pbx_cli, presence_state_cb(), presence_state_sub, stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), testtime_function, and unload_pbx().

Referenced by asterisk_daemon().

◆ load_pbx_app()

int load_pbx_app ( void  )

Provided by pbx_app.c

Definition at line 538 of file pbx_app.c.

539{
542
543 return 0;
544}
static struct ast_cli_entry app_cli[]
Definition pbx_app.c:528
static void unload_pbx_app(void)
Definition pbx_app.c:533

References app_cli, ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), and unload_pbx_app().

Referenced by asterisk_daemon().

◆ load_pbx_builtins()

int load_pbx_builtins ( void  )

Provided by pbx_builtins.c

Definition at line 1597 of file pbx_builtins.c.

1598{
1599 int x;
1600
1601 /* Register builtin applications */
1602 for (x = 0; x < ARRAY_LEN(builtins); x++) {
1604 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
1605 return -1;
1606 }
1607 }
1608
1610
1611 return 0;
1612}
static const char name[]
Definition format_mp3.c:68
static SQLHSTMT execute(struct odbc_obj *obj, void *data, int silent)
Common execution function for SQL queries.
Definition func_odbc.c:485
struct pbx_builtin builtins[]
static void unload_pbx_builtins(void)

References ARRAY_LEN, ast_log, ast_register_application2(), ast_register_cleanup(), builtins, execute(), LOG_ERROR, name, NULL, unload_pbx_builtins(), and ast_channel::x.

Referenced by asterisk_daemon().

◆ load_pbx_functions_cli()

int load_pbx_functions_cli ( void  )

Provided by pbx_functions.c

Definition at line 732 of file pbx_functions.c.

733{
736
737 return 0;
738}
static void unload_pbx_functions_cli(void)
static struct ast_cli_entry acf_cli[]

References acf_cli, ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), and unload_pbx_functions_cli().

Referenced by asterisk_daemon().

◆ load_pbx_hangup_handler()

int load_pbx_hangup_handler ( void  )

Provided by pbx_hangup_handler.c

Definition at line 288 of file pbx_hangup_handler.c.

289{
292
293 return 0;
294}
static struct ast_cli_entry cli[]
static void unload_pbx_hangup_handler(void)

References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), cli, and unload_pbx_hangup_handler().

Referenced by asterisk_daemon().

◆ load_pbx_switch()

int load_pbx_switch ( void  )

Provided by pbx_switch.c

Definition at line 125 of file pbx_switch.c.

126{
129
130 return 0;
131}
static void unload_pbx_switch(void)
Definition pbx_switch.c:120
static struct ast_cli_entry sw_cli[]
Definition pbx_switch.c:116

References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), sw_cli, and unload_pbx_switch().

Referenced by asterisk_daemon().

◆ load_pbx_variables()

int load_pbx_variables ( void  )

Provided by pbx_variables.c

Definition at line 1448 of file pbx_variables.c.

1449{
1450 int res = 0;
1451
1456 AST_TEST_REGISTER(test_variable_substrings);
1457
1458 return res;
1459}
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an '=' character...
static struct ast_cli_entry vars_cli[]
static void unload_pbx_variables(void)
int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
Parse and set multiple channel variables, where the pairs are separated by the ',' character,...

References ARRAY_LEN, ast_cli_register_multiple, ast_register_application2(), ast_register_cleanup(), AST_TEST_REGISTER, NULL, pbx_builtin_setvar(), pbx_builtin_setvar_multiple(), unload_pbx_variables(), and vars_cli.

Referenced by asterisk_daemon().

◆ logger_queue_start()

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.

Definition at line 2156 of file logger.c.

2157{
2158 /* Must not be called before the logger is initialized. */
2160
2162 if (!queuelog_init) {
2164 queuelog_init = 1;
2166 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
2167 } else {
2169 }
2170}
static int queuelog_init
Definition logger.c:85
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
Definition logger.c:957
static void logger_queue_init(void)
Definition logger.c:2121
#define ast_assert(a)
Definition utils.h:779

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

Referenced by ast_queue_log(), and asterisk_daemon().

◆ modules_shutdown()

int modules_shutdown ( void  )

Provided by loader.c

Note
Some resources, like timers, are started up dynamically, and thus may be still in use, even if all channels are dead. We must therefore check the usecount before asking modules to unload.

Definition at line 1181 of file loader.c.

1182{
1183 struct ast_module *mod;
1184 int somethingchanged;
1185 int res;
1186
1188
1189 /*!\note Some resources, like timers, are started up dynamically, and thus
1190 * may be still in use, even if all channels are dead. We must therefore
1191 * check the usecount before asking modules to unload. */
1192 do {
1193 /* Reset flag before traversing the list */
1194 somethingchanged = 0;
1195
1197 if (mod->usecount) {
1198 ast_debug(1, "Passing on %s: its use count is %d\n",
1199 mod->resource, mod->usecount);
1200 continue;
1201 }
1203 if (mod->flags.running && !mod->flags.declined && mod->info->unload) {
1204 ast_verb(4, "Unloading %s\n", mod->resource);
1205 mod->info->unload();
1206 }
1207 module_destroy(mod);
1208 somethingchanged = 1;
1209 }
1211 if (!somethingchanged) {
1213 if (mod->flags.keepuntilshutdown) {
1214 ast_module_unref(mod);
1215 mod->flags.keepuntilshutdown = 0;
1216 somethingchanged = 1;
1217 }
1218 }
1219 }
1220 } while (somethingchanged);
1221
1224
1225 return !res;
1226}
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_DLLIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_DLLIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END
Closes a safe loop traversal block.
static void module_destroy(struct ast_module *mod)
Definition loader.c:753
#define ast_module_unref(mod)
Release a reference to the module.
Definition module.h:483
int(* unload)(void)
Definition module.h:362
struct ast_module::@390 entry
unsigned int keepuntilshutdown
Definition loader.c:333
int usecount
Definition loader.c:309

References ast_debug, AST_DLLIST_EMPTY, AST_DLLIST_LOCK, AST_DLLIST_REMOVE_CURRENT, AST_DLLIST_TRAVERSE, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END, AST_DLLIST_UNLOCK, ast_module_unref, ast_verb, ast_module::declined, ast_module::entry, ast_module::flags, ast_module::info, ast_module::keepuntilshutdown, module_destroy(), ast_module::resource, ast_module::running, ast_module_info::unload, and ast_module::usecount.

Referenced by really_quit().

◆ set_asterisk_conf_path()

void set_asterisk_conf_path ( const char *  path)

Definition at line 201 of file options.c.

202{
204}
char config_file[PATH_MAX]
Definition options.c:115

References ast_copy_string(), cfg_paths, and _cfg_paths::config_file.

Referenced by main().

◆ set_socket_path()

void set_socket_path ( const char *  path)

Definition at line 206 of file options.c.

207{
209}

References ast_copy_string(), cfg_paths, and _cfg_paths::socket_path.

Referenced by main().

◆ threadstorage_init()

void threadstorage_init ( void  )

Provided by threadstorage.c

Definition at line 35 of file threadstorage.c.

36{
37}

Referenced by asterisk_daemon().