Asterisk - The Open Source Telephony Project  GIT-master-a1fa8df
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. More...
 
void ast_builtins_init (void)
 initialize the _full_cmd string in * each of the builtins. More...
 
int ast_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. More...
 
int ast_dns_system_resolver_init (void)
 Initializes the resolver. More...
 
int ast_endpoint_init (void)
 Endpoint support initialization. More...
 
int ast_file_init (void)
 
int ast_local_init (void)
 Initialize the local proxy channel. More...
 
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 More...
 
int ast_pj_init (void)
 
void ast_process_pending_reloads (void)
 Process reload requests received during startup. More...
 
int ast_rtp_engine_init (void)
 initializes the rtp engine arrays More...
 
int ast_ssl_init (void)
 
void ast_stun_init (void)
 Initialize the STUN system in Asterisk. More...
 
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. More...
 
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. More...
 
void load_astmm_phase_2 (void)
 Initialize malloc debug phase 2. More...
 
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. More...
 
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 1426 of file config_options.c.

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

Referenced by asterisk_daemon().

1427 {
1428 #ifdef AST_XML_DOCS
1430  if (!(xmldocs = ast_xmldoc_build_documentation("configInfo"))) {
1431  ast_log(LOG_ERROR, "Couldn't build config documentation\n");
1432  return -1;
1433  }
1435 #endif /* AST_XML_DOCS */
1436  return 0;
1437 }
static void aco_deinit(void)
static struct ast_cli_entry cli_aco[]
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
Definition: xmldoc.c:2653
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct ao2_container * xmldocs
#define ARRAY_LEN(a)
Definition: utils.h:639
#define LOG_ERROR
Definition: logger.h:285

◆ ast_autoservice_init()

void ast_autoservice_init ( void  )

Provided by autoservice.c

Definition at line 380 of file autoservice.c.

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

Referenced by asterisk_daemon().

381 {
384 }
#define ast_cond_init(cond, attr)
Definition: lock.h:199
static void autoservice_shutdown(void)
Definition: autoservice.c:369
#define NULL
Definition: resample.c:96
static ast_cond_t as_cond
Definition: autoservice.c:71
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19

◆ 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 5605 of file bridge.c.

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

Referenced by asterisk_daemon().

5606 {
5608 
5609  if (ast_stasis_bridging_init()) {
5610  return -1;
5611  }
5612 
5614  if (!bridge_manager) {
5615  return -1;
5616  }
5617 
5620  if (!bridges) {
5621  return -1;
5622  }
5624 
5626 
5628 
5629  ast_manager_register_xml_core("BridgeTechnologyList", 0, manager_bridge_tech_list);
5630  ast_manager_register_xml_core("BridgeTechnologySuspend", 0, manager_bridge_tech_suspend);
5631  ast_manager_register_xml_core("BridgeTechnologyUnsuspend", 0, manager_bridge_tech_unsuspend);
5632 
5633  return 0;
5634 }
static void bridge_cleanup(void)
Definition: bridge.c:5591
static int manager_bridge_tech_suspend(struct mansession *s, const struct message *m)
Definition: bridge.c:5508
static void bridge_prnt_obj(void *v_obj, void *where, ao2_prnt_fn *prnt)
Definition: bridge.c:5573
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct bridge_manager_controller * bridge_manager
Definition: bridge.c:172
#define NULL
Definition: resample.c:96
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:197
static int manager_bridge_tech_unsuspend(struct mansession *s, const struct message *m)
Definition: bridge.c:5513
static struct bridge_manager_controller * bridge_manager_create(void)
Definition: bridge.c:5009
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.
int ast_stasis_bridging_init(void)
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct ao2_container * bridges
Definition: bridge.c:123
void ast_bridging_init_basic(void)
static int bridge_sort_cmp(const void *obj_left, const void *obj_right, int flags)
Definition: bridge.c:5048
Replace objects with duplicate keys in container.
Definition: astobj2.h:1215
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1358
static int manager_bridge_tech_list(struct mansession *s, const struct message *m)
Definition: bridge.c:5518
static struct ast_cli_entry bridge_cli[]
Definition: bridge.c:5462

◆ 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 2209 of file main/cli.c.

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

Referenced by asterisk_daemon().

2210 {
2211  AST_VECTOR_INIT(&shutdown_commands, 0);
2214 }
static void cli_shutdown(void)
Definition: main/cli.c:2203
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct ast_cli_entry cli_cli[]
Definition: main/cli.c:1984

◆ ast_channels_init()

int ast_channels_init ( void  )

Provided by channel.c

Definition at line 8026 of file channel.c.

References ami_vars, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_container_register(), ari_vars, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_channel_register(), ast_cli_register_multiple, AST_NUM_CHANNEL_BUCKETS, ast_register_cleanup(), AST_RWLIST_HEAD_INIT, ast_stasis_channels_init(), channels_shutdown(), NULL, and prnt_channel_key().

Referenced by asterisk_daemon().

8027 {
8030  if (!channels) {
8031  return -1;
8032  }
8034 
8036 
8038 
8040 
8042 
8045 
8046  return 0;
8047 }
#define AST_NUM_CHANNEL_BUCKETS
Definition: channel.h:156
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct external_vars ami_vars
Definition: channel.c:7850
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
Definition: linkedlists.h:638
#define NULL
Definition: resample.c:96
static int ast_channel_hash_cb(const void *obj, const int flags)
Definition: channel.c:7805
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:698
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.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
Definition: channel.c:1424
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct external_vars ari_vars
Definition: channel.c:7851
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:120
static void channels_shutdown(void)
Definition: channel.c:8012
int ast_stasis_channels_init(void)
Initialize the stasis channel topic and message types.
int ast_channel_register(const struct ast_channel_tech *tech)
Register a new telephony channel in Asterisk.
Definition: channel.c:535
static void prnt_channel_key(void *v_obj, void *where, ao2_prnt_fn *prnt)
Definition: channel.c:7829
static struct ast_cli_entry cli_channel[]
Definition: channel.c:386

◆ ast_cli_perms_init()

int ast_cli_perms_init ( int  reload)

Provided by cli.c

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

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

Referenced by asterisk_daemon(), and handle_cli_reload_permissions().

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 }
struct ast_variable * next
static int reload(void)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3154
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
Structure for variables, used for configurations and for channel variables.
static const char perms_config[]
CLI permissions config file.
Definition: main/cli.c:85
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3328
#define NULL
Definition: resample.c:96
static int cli_default_perm
Default permissions value 1=Permit 0=Deny.
Definition: main/cli.c:87
#define ast_log
Definition: astobj2.c:42
#define ast_mutex_trylock(a)
Definition: lock.h:189
struct cli_perm_head * perms
Definition: main/cli.c:81
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define CONFIG_STATUS_FILEUNCHANGED
List of restrictions per user.
Definition: main/cli.c:69
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
list of users to apply restrictions.
Definition: main/cli.c:78
#define LOG_NOTICE
Definition: logger.h:263
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
Structure used to handle boolean flags.
Definition: utils.h:199
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740
List of users and permissions.
Definition: main/cli.c:93
char * command
Definition: main/cli.c:71
unsigned int permit
Definition: main/cli.c:70
static void destroy_user_perms(void)
cleanup (free) cli_perms linkedlist.
Definition: main/cli.c:2065
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ 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 618 of file devicestate.c.

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().

619 {
622  ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
623  return -1;
624  }
626 
627  return 0;
628 }
#define ast_cond_init(cond, attr)
Definition: lock.h:199
#define NULL
Definition: resample.c:96
static void device_state_engine_cleanup(void)
Definition: devicestate.c:605
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:567
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define LOG_ERROR
Definition: logger.h:285
static pthread_t change_thread
The device state change notification thread.
Definition: devicestate.c:211
static void * do_devstate_changes(void *data)
Go through the dev state change queue and update changes in the dev state thread. ...
Definition: devicestate.c:523
static ast_cond_t change_pending
Flag for the queue.
Definition: devicestate.c:214

◆ 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 243 of file dns_system_resolver.c.

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

Referenced by asterisk_daemon().

244 {
245  /* Register the base resolver */
247 
248  if (res) {
250  }
251 
252  /* Instantiate the task processor */
253  dns_system_resolver_tp = ast_taskprocessor_get("dns_system_resolver_tp",
255 
256  /* Return error if the task processor failed to instantiate */
257  if (!dns_system_resolver_tp) {
259  }
260 
261  /* Register the cleanup function */
263 
265 }
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...
return a reference to a taskprocessor, create one if it does not exist
Definition: taskprocessor.h:75
#define DNS_SYSTEM_RESOLVER_SUCCESS
Resolver return code upon success.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_dns_resolver_register(struct ast_dns_resolver *resolver)
Register a DNS resolver.
Definition: dns_core.c:630
static void dns_system_resolver_destroy(void)
Destructor.
struct ast_dns_resolver dns_system_resolver_base
The base definition for the dns_system_resolver.
#define DNS_SYSTEM_RESOLVER_FAILURE
Resolver return code upon failure.
static struct ast_taskprocessor * dns_system_resolver_tp
The task processor to use for making DNS searches asynchronous.

◆ ast_endpoint_init()

int ast_endpoint_init ( void  )

Endpoint support initialization.

Returns
0 on success.
Non-zero on error.

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

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

Referenced by asterisk_daemon().

497 {
499 
501  ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
502  if (!endpoints) {
503  return -1;
504  }
505 
507  TECH_ENDPOINT_BUCKETS, ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
508  if (!tech_endpoints) {
509  return -1;
510  }
511 
512  return 0;
513 }
#define NULL
Definition: resample.c:96
#define ENDPOINT_BUCKETS
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct ao2_container * endpoints
static struct ao2_container * tech_endpoints
#define TECH_ENDPOINT_BUCKETS
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static void endpoint_cleanup(void)

◆ ast_file_init()

int ast_file_init ( void  )

Provided by file.c

Definition at line 1983 of file file.c.

Referenced by asterisk_daemon().

1984 {
1989  return 0;
1990 }
static struct ast_cli_entry cli_file[]
Definition: file.c:1972
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static void file_shutdown(void)
Definition: file.c:1976
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_message_type * ast_format_unregister_type(void)
Get the message type used for signaling a format unregistration.
#define ARRAY_LEN(a)
Definition: utils.h:639
struct stasis_message_type * ast_format_register_type(void)
Get the message type used for signaling a format registration.

◆ 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 1140 of file core_local.c.

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, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, local_shutdown(), locals_cmp_cb(), LOG_ERROR, manager_optimize_away(), NULL, and STASIS_MESSAGE_TYPE_INIT.

Referenced by asterisk_daemon().

1141 {
1143  return -1;
1144  }
1145 
1147  return -1;
1148  }
1149 
1151  return -1;
1152  }
1153 
1155  return -1;
1156  }
1158 
1160  if (!locals) {
1161  return -1;
1162  }
1163 
1164  /* Make sure we can register our channel type */
1166  ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
1167 
1168  return -1;
1169  }
1172 
1174  return 0;
1175 }
static int manager_optimize_away(struct mansession *s, const struct message *m)
Definition: core_local.c:1073
static int locals_cmp_cb(void *obj, void *arg, int flags)
Definition: core_local.c:1110
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
#define EVENT_FLAG_CALL
Definition: manager.h:72
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
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
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:535
#define NULL
Definition: resample.c:96
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:197
static struct ast_cli_entry cli_local[]
Definition: core_local.c:1069
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
#define ARRAY_LEN(a)
Definition: utils.h:639
struct stasis_message_type * ast_local_optimization_end_type(void)
Message type for when a local channel optimization completes.
#define LOG_ERROR
Definition: logger.h:285
static struct ast_channel_tech local_tech
Definition: core_local.c:173
struct ast_format_cap * capabilities
Definition: channel.h:633
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_begin_type(void)
Message type for when a local channel optimization begins.
static struct ao2_container * locals
Definition: core_local.c:138
static void local_shutdown(void)
Definition: core_local.c:1122

◆ ast_msg_init()

int ast_msg_init ( void  )

Provided by message.c

Definition at line 1730 of file message.c.

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

Referenced by asterisk_daemon().

1731 {
1732  int res;
1733 
1734  msg_q_tp = ast_taskprocessor_get("ast_msg_queue", TPS_REF_DEFAULT);
1735  if (!msg_q_tp) {
1736  return -1;
1737  }
1738 
1740  if (AST_VECTOR_INIT(&msg_techs, 8)) {
1741  return -1;
1742  }
1743 
1744  ast_rwlock_init(&msg_handlers_lock);
1745  if (AST_VECTOR_INIT(&msg_handlers, 4)) {
1746  return -1;
1747  }
1748 
1750 
1753  res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL);
1755 
1757 
1758  return res;
1759 }
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...
int ast_msg_handler_register(const struct ast_msg_handler *handler)
Register a ast_msg_handler.
Definition: message.c:1629
return a reference to a taskprocessor, create one if it does not exist
Definition: taskprocessor.h:75
static void message_shutdown(void)
Definition: message.c:1704
static struct ast_custom_function msg_function
Definition: message.c:282
#define NULL
Definition: resample.c:96
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:197
static struct ast_custom_function msg_data_function
Definition: message.c:293
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:222
static int msg_send_exec(struct ast_channel *chan, const char *data)
Definition: message.c:1226
static struct ast_msg_handler dialplan_msg_handler
Definition: message.c:892
static ast_rwlock_t msg_techs_lock
Lock for msg_techs vector.
Definition: message.c:255
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
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:103
static int action_messagesend(struct mansession *s, const struct message *m)
Definition: message.c:1306
#define EVENT_FLAG_MESSAGE
Definition: manager.h:91

◆ ast_msg_shutdown()

void ast_msg_shutdown ( void  )

Provided by message.c

Definition at line 1689 of file message.c.

References ast_taskprocessor_unreference().

Referenced by can_safely_quit().

1690 {
1691  if (msg_q_tp) {
1692  msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
1693  }
1694 }
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.

◆ ast_named_locks_init()

int ast_named_locks_init ( void  )

Provided by named_locks.c

Definition at line 52 of file named_locks.c.

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

Referenced by asterisk_daemon().

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 NULL
Definition: resample.c:96
struct ao2_container * named_locks
Definition: named_locks.c:33
static void named_locks_shutdown(void)
Definition: named_locks.c:47
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define NAMED_LOCKS_BUCKETS
Definition: named_locks.c:34

◆ 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.

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

Referenced by asterisk_daemon().

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 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:618
static struct stasis_topic * parking_topic
Topic for parking lots.
Definition: parking.c:41
static void parking_stasis_cleanup(void)
Definition: parking.c:46

◆ ast_pj_init()

int ast_pj_init ( void  )

Provided by libasteriskpj.c

Definition at line 45 of file libasteriskpj.c.

References AST_PJPROJECT_INIT_LOG_LEVEL.

Referenced by asterisk_daemon().

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:166

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

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

Referenced by asterisk_daemon().

1408 {
1409  struct reload_queue_item *item;
1410 
1411  modules_loaded = 1;
1412 
1414 
1415  if (do_full_reload) {
1416  do_full_reload = 0;
1418  ast_log(LOG_NOTICE, "Executing deferred reload request.\n");
1420  return;
1421  }
1422 
1423  while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) {
1424  ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module);
1425  ast_module_reload(item->module);
1426  ast_free(item);
1427  }
1428 
1430 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
Definition: loader.c:1562
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
char module[0]
Definition: loader.c:635
#define ast_log
Definition: astobj2.c:42
static int modules_loaded
Internal flag to indicate all modules have been initially loaded.
Definition: loader.c:291
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
#define LOG_NOTICE
Definition: logger.h:263
#define ast_free(a)
Definition: astmm.h:182
static int do_full_reload
Definition: loader.c:638
Definition: search.h:40

◆ ast_rtp_engine_init()

int ast_rtp_engine_init ( void  )

initializes the rtp engine arrays

Definition at line 3622 of file rtp_engine.c.

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_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, NULL, rtp_engine_shutdown(), set_next_mime_type(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by asterisk_daemon().

3623 {
3626 
3627  rtp_topic = stasis_topic_create("rtp:all");
3628  if (!rtp_topic) {
3629  return -1;
3630  }
3634 
3635  /* Define all the RTP mime types available */
3636  set_next_mime_type(ast_format_g723, 0, "audio", "G723", 8000);
3637  set_next_mime_type(ast_format_gsm, 0, "audio", "GSM", 8000);
3638  set_next_mime_type(ast_format_ulaw, 0, "audio", "PCMU", 8000);
3639  set_next_mime_type(ast_format_ulaw, 0, "audio", "G711U", 8000);
3640  set_next_mime_type(ast_format_alaw, 0, "audio", "PCMA", 8000);
3641  set_next_mime_type(ast_format_alaw, 0, "audio", "G711A", 8000);
3642  set_next_mime_type(ast_format_g726, 0, "audio", "G726-32", 8000);
3643  set_next_mime_type(ast_format_adpcm, 0, "audio", "DVI4", 8000);
3644  set_next_mime_type(ast_format_slin, 0, "audio", "L16", 8000);
3645  set_next_mime_type(ast_format_slin16, 0, "audio", "L16", 16000);
3646  set_next_mime_type(ast_format_slin16, 0, "audio", "L16-256", 16000);
3647  set_next_mime_type(ast_format_slin12, 0, "audio", "L16", 12000);
3648  set_next_mime_type(ast_format_slin24, 0, "audio", "L16", 24000);
3649  set_next_mime_type(ast_format_slin32, 0, "audio", "L16", 32000);
3650  set_next_mime_type(ast_format_slin44, 0, "audio", "L16", 44000);
3651  set_next_mime_type(ast_format_slin48, 0, "audio", "L16", 48000);
3652  set_next_mime_type(ast_format_slin96, 0, "audio", "L16", 96000);
3653  set_next_mime_type(ast_format_slin192, 0, "audio", "L16", 192000);
3654  set_next_mime_type(ast_format_lpc10, 0, "audio", "LPC", 8000);
3655  set_next_mime_type(ast_format_g729, 0, "audio", "G729", 8000);
3656  set_next_mime_type(ast_format_g729, 0, "audio", "G729A", 8000);
3657  set_next_mime_type(ast_format_g729, 0, "audio", "G.729", 8000);
3658  set_next_mime_type(ast_format_speex, 0, "audio", "speex", 8000);
3659  set_next_mime_type(ast_format_speex16, 0, "audio", "speex", 16000);
3660  set_next_mime_type(ast_format_speex32, 0, "audio", "speex", 32000);
3661  set_next_mime_type(ast_format_ilbc, 0, "audio", "iLBC", 8000);
3662  /* this is the sample rate listed in the RTP profile for the G.722 codec, *NOT* the actual sample rate of the media stream */
3663  set_next_mime_type(ast_format_g722, 0, "audio", "G722", 8000);
3664  set_next_mime_type(ast_format_g726_aal2, 0, "audio", "AAL2-G726-32", 8000);
3665  set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 8000);
3666  set_next_mime_type(NULL, AST_RTP_CISCO_DTMF, "audio", "cisco-telephone-event", 8000);
3667  set_next_mime_type(NULL, AST_RTP_CN, "audio", "CN", 8000);
3668  set_next_mime_type(ast_format_jpeg, 0, "video", "JPEG", 90000);
3669  set_next_mime_type(ast_format_png, 0, "video", "PNG", 90000);
3670  set_next_mime_type(ast_format_h261, 0, "video", "H261", 90000);
3671  set_next_mime_type(ast_format_h263, 0, "video", "H263", 90000);
3672  set_next_mime_type(ast_format_h263p, 0, "video", "h263-1998", 90000);
3673  set_next_mime_type(ast_format_h264, 0, "video", "H264", 90000);
3674  set_next_mime_type(ast_format_h265, 0, "video", "H265", 90000);
3675  set_next_mime_type(ast_format_mp4, 0, "video", "MP4V-ES", 90000);
3676  set_next_mime_type(ast_format_t140_red, 0, "text", "RED", 1000);
3677  set_next_mime_type(ast_format_t140, 0, "text", "T140", 1000);
3678  set_next_mime_type(ast_format_siren7, 0, "audio", "G7221", 16000);
3679  set_next_mime_type(ast_format_siren14, 0, "audio", "G7221", 32000);
3680  set_next_mime_type(ast_format_g719, 0, "audio", "G719", 48000);
3681  /* Opus, VP8, and VP9 */
3682  set_next_mime_type(ast_format_opus, 0, "audio", "opus", 48000);
3683  set_next_mime_type(ast_format_vp8, 0, "video", "VP8", 90000);
3684  set_next_mime_type(ast_format_vp9, 0, "video", "VP9", 90000);
3685 
3686  /* Define the static rtp payload mappings */
3688  #ifdef USE_DEPRECATED_G726
3689  add_static_payload(2, ast_format_g726, 0);/* Technically this is G.721, but if Cisco can do it, so can we... */
3690  #endif
3693  add_static_payload(5, ast_format_adpcm, 0);/* 8 kHz */
3694  add_static_payload(6, ast_format_adpcm, 0); /* 16 kHz */
3698  add_static_payload(10, ast_format_slin, 0); /* 2 channels */
3699  add_static_payload(11, ast_format_slin, 0); /* 1 channel */
3701  add_static_payload(16, ast_format_adpcm, 0); /* 11.025 kHz */
3702  add_static_payload(17, ast_format_adpcm, 0); /* 22.050 kHz */
3704  add_static_payload(19, NULL, AST_RTP_CN); /* Also used for CN */
3708 
3709  /*
3710  * Dynamic payload types - Even when dynamically assigning them we'll fall
3711  * back to using the statically declared values as the default number.
3712  */
3715 
3722  add_static_payload(105, ast_format_t140_red, 0); /* Real time text chat (with redundancy encoding) */
3723  add_static_payload(106, ast_format_t140, 0); /* Real time text chat */
3727 
3731 
3735  add_static_payload(118, ast_format_slin16, 0); /* 16 Khz signed linear */
3737 
3738  add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */
3745  /* payload types above 127 are not valid */
3746 
3754 
3755  return 0;
3756 }
struct stasis_message_type * ast_rtp_rtcp_sent_type(void)
Message type for an RTCP message sent from this Asterisk instance.
struct ast_format * ast_format_vp8
Built-in cached vp8 format.
Definition: format_cache.c:191
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:111
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:146
struct ast_format * ast_format_siren14
Built-in cached siren14 format.
Definition: format_cache.c:211
struct ast_format * ast_format_slin192
Built-in cached signed linear 192kHz format.
Definition: format_cache.c:81
struct ast_format * ast_format_mp4
Built-in cached mp4 format.
Definition: format_cache.c:186
struct ast_format * ast_format_t140_red
Built-in cached t140 red format.
Definition: format_cache.c:236
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:261
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
struct ast_format * ast_format_slin32
Built-in cached signed linear 32kHz format.
Definition: format_cache.c:61
static void rtp_engine_shutdown(void)
Definition: rtp_engine.c:3585
struct ast_format * ast_format_slin96
Built-in cached signed linear 96kHz format.
Definition: format_cache.c:76
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_jpeg
Built-in cached jpeg format.
Definition: format_cache.c:201
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:116
struct ast_format * ast_format_slin24
Built-in cached signed linear 24kHz format.
Definition: format_cache.c:56
#define NULL
Definition: resample.c:96
struct ast_format * ast_format_g722
Built-in cached g722 format.
Definition: format_cache.c:106
struct stasis_message_type * ast_rtp_rtcp_received_type(void)
Message type for an RTCP message received from some external source.
struct ast_format * ast_format_h261
Built-in cached h261 format.
Definition: format_cache.c:161
struct ast_format * ast_format_g719
Built-in cached g719 format.
Definition: format_cache.c:156
static void add_static_payload(int payload, struct ast_format *format, int rtp_code)
Definition: rtp_engine.c:3183
struct ast_format * ast_format_h263p
Built-in cached h263 plus format.
Definition: format_cache.c:171
struct ast_format * ast_format_lpc10
Built-in cached ilbc format.
Definition: format_cache.c:126
#define AST_LOG_CATEGORY_DTLS
Definition: rtp_engine.h:2832
struct ast_format * ast_format_slin12
Built-in cached signed linear 12kHz format.
Definition: format_cache.c:46
static uintmax_t debug_category_dtls_packet_id
Definition: rtp_engine.c:3571
static uintmax_t debug_category_rtp_id
Definition: rtp_engine.c:3536
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct ast_format * ast_format_opus
Built-in cached opus format.
Definition: format_cache.c:221
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:96
static uintmax_t debug_category_rtcp_id
Definition: rtp_engine.c:3550
struct ast_format * ast_format_speex16
Built-in cached speex at 16kHz format.
Definition: format_cache.c:136
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:618
struct ast_format * ast_format_png
Built-in cached png format.
Definition: format_cache.c:206
static uintmax_t debug_category_rtp_packet_id
Definition: rtp_engine.c:3543
static struct stasis_topic * rtp_topic
Stasis Message Bus API topic for RTP related messages
Definition: rtp_engine.c:278
#define AST_LOG_CATEGORY_RTCP_PACKET
Definition: rtp_engine.h:2830
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:131
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:222
static uintmax_t debug_category_ice_id
Definition: rtp_engine.c:3578
static uintmax_t debug_category_rtcp_packet_id
Definition: rtp_engine.c:3557
struct ast_format * ast_format_vp9
Built-in cached vp9 format.
Definition: format_cache.c:196
struct ast_format * ast_format_h264
Built-in cached h264 format.
Definition: format_cache.c:176
#define AST_RTP_CISCO_DTMF
Definition: rtp_engine.h:270
#define AST_LOG_CATEGORY_RTP
Definition: rtp_engine.h:2824
#define AST_LOG_CATEGORY_ICE
Definition: rtp_engine.h:2836
#define AST_LOG_CATEGORY_RTCP
Definition: rtp_engine.h:2828
static void set_next_mime_type(struct ast_format *format, int rtp_code, const char *type, const char *subtype, unsigned int sample_rate)
Definition: rtp_engine.c:3155
struct ast_format * ast_format_h265
Built-in cached h265 format.
Definition: format_cache.c:181
static uintmax_t debug_category_dtls_id
Definition: rtp_engine.c:3564
struct ast_format * ast_format_siren7
Built-in cached siren7 format.
Definition: format_cache.c:216
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_adpcm
Built-in cached adpcm format.
Definition: format_cache.c:101
struct ast_format * ast_format_slin44
Built-in cached signed linear 44kHz format.
Definition: format_cache.c:66
struct ast_format * ast_format_slin16
Built-in cached signed linear 16kHz format.
Definition: format_cache.c:51
#define AST_LOG_CATEGORY_DTLS_PACKET
Definition: rtp_engine.h:2834
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:151
#define AST_LOG_CATEGORY_RTP_PACKET
Definition: rtp_engine.h:2826
uintmax_t ast_debug_category_register(const char *name)
Register a debug level logger category.
struct ast_format * ast_format_speex32
Built-in cached speex at 32kHz format.
Definition: format_cache.c:141
#define AST_RTP_CN
Definition: rtp_engine.h:268
#define AST_RTP_DTMF
Definition: rtp_engine.h:266
struct ast_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:231
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:166
struct ast_format * ast_format_slin48
Built-in cached signed linear 48kHz format.
Definition: format_cache.c:71
struct ast_format * ast_format_ilbc
Built-in cached ilbc format.
Definition: format_cache.c:121

◆ ast_ssl_init()

int ast_ssl_init ( void  )

Provided by ssl.c

Definition at line 205 of file libasteriskssl.c.

Referenced by asterisk_daemon().

206 {
207  return 0;
208 }

◆ ast_stun_init()

void ast_stun_init ( void  )

Initialize the STUN system in Asterisk.

Provided by stun.c

Definition at line 563 of file stun.c.

References ast_cli_register_multiple, ast_debug_category_register(), AST_LOG_CATEGORY_STUN, AST_LOG_CATEGORY_STUN_PACKET, ast_register_cleanup(), and stun_shutdown().

Referenced by asterisk_daemon().

564 {
565  ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
567 
570 }
static void stun_shutdown(void)
Definition: stun.c:554
descriptor for a cli entry.
Definition: cli.h:171
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static uintmax_t debug_category_stun_packet_id
Definition: stun.c:547
static struct ast_cli_entry cli_stun[]
Definition: stun.c:536
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static uintmax_t debug_category_stun_id
Definition: stun.c:540
#define AST_LOG_CATEGORY_STUN
Definition: stun.h:37
uintmax_t ast_debug_category_register(const char *name)
Register a debug level logger category.
#define AST_LOG_CATEGORY_STUN_PACKET
Definition: stun.h:39

◆ ast_term_init()

int ast_term_init ( void  )

Provided by term.c

Definition at line 165 of file term.c.

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().

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 
220 end:
221  if (vt100compat) {
222  /* Make commands show up in nice colors */
224  snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
225  } else if (ast_opt_force_black_background) {
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 }
static int parse_terminfo_file(int fd)
Definition: term.c:106
#define ast_opt_force_black_background
Definition: options.h:131
static int vt100compat
Definition: term.c:43
#define COLOR_WHITE
Definition: term.h:61
char * end
Definition: eagi_proxy.c:73
static char enddata[80]
Definition: term.c:45
#define ast_opt_console
Definition: options.h:109
#define ast_opt_no_color
Definition: options.h:114
static char quitdata[80]
Definition: term.c:46
#define COLOR_BLACK
Definition: term.h:47
#define ATTR_RESET
Definition: term.h:35
#define ast_opt_light_background
Definition: options.h:130
static const char *const termpath[]
Definition: term.c:48
#define ESC
Definition: term.h:30

◆ ast_test_init()

int ast_test_init ( void  )

Provided by test.c

Definition at line 1221 of file test.c.

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().

1222 {
1223 #ifdef TEST_FRAMEWORK
1224  ast_register_cleanup(test_cleanup);
1225 
1226  /* Create stasis topic */
1227  test_suite_topic = stasis_topic_create("testsuite:all");
1228  if (!test_suite_topic) {
1229  return -1;
1230  }
1231 
1232  if (STASIS_MESSAGE_TYPE_INIT(ast_test_suite_message_type) != 0) {
1233  return -1;
1234  }
1235 
1236  AST_TEST_REGISTER(test_registrations);
1237 
1238  /* Register cli commands */
1239  ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
1240 #endif
1241 
1242  return 0;
1243 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:618
#define ARRAY_LEN(a)
Definition: utils.h:639

◆ ast_timing_init()

int ast_timing_init ( void  )

Provided by timing.c

Definition at line 289 of file timing.c.

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

Referenced by asterisk_daemon().

290 {
292  return -1;
293  }
294 
296 
298 }
static void timing_shutdown(void)
Definition: timing.c:281
static int timing_holder_cmp(void *_h1, void *_h2)
Definition: timing.c:59
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct ast_heap * timing_interfaces
Definition: timing.c:52
#define ast_heap_create(init_height, cmp_fn, index_offset)
Definition: heap.h:102
static struct ast_cli_entry cli_timing[]
Definition: timing.c:277

◆ ast_tps_init()

int ast_tps_init ( void  )

Provided by taskprocessor.c

Definition at line 301 of file taskprocessor.c.

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().

302 {
305  if (!tps_singletons) {
306  ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
307  return -1;
308  }
309 
310  if (AST_VECTOR_RW_INIT(&overloaded_subsystems, 10)) {
311  ao2_ref(tps_singletons, -1);
312  ast_log(LOG_ERROR, "taskprocessor subsystems vector failed to initialize!\n");
313  return -1;
314  }
315 
316  ast_cond_init(&cli_ping_cond, NULL);
317 
319 
321 
322  return 0;
323 }
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.
Definition: vector.h:158
static void tps_shutdown(void)
static int tps_cmp_cb(void *obj, void *arg, int flags)
The astobj2 compare callback for taskprocessors.
static int tps_hash_cb(const void *obj, const int flags)
The astobj2 hash callback for taskprocessors.
#define ast_cond_init(cond, attr)
Definition: lock.h:199
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define TPS_MAX_BUCKETS
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ARRAY_LEN(a)
Definition: utils.h:639
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static struct ast_cli_entry taskprocessor_clis[]

◆ 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 2879 of file xmldoc.c.

References ast_asprintf, ast_calloc, ast_cli_register, ast_config_AST_DATA_DIR, ast_config_destroy(), ast_config_load2(), ast_debug, ast_free, ast_log, ast_malloc, ast_register_cleanup(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strlen_zero(), ast_variable_browse(), ast_xml_close(), ast_xml_get_root(), ast_xml_init(), ast_xml_node_get_name(), ast_xml_open(), CONFIG_STATUS_FILEINVALID, default_documentation_language, documentation_tree::doc, documentation_language, documentation_tree::filename, GLOB_ABORTED, LOG_ERROR, LOG_WARNING, MY_GLOB_FLAGS, ast_variable::name, ast_variable::next, NULL, ast_variable::value, var, and xmldoc_unload_documentation().

Referenced by asterisk_daemon().

2880 {
2881  struct ast_xml_node *root_node;
2882  struct ast_xml_doc *tmpdoc;
2883  struct documentation_tree *doc_tree;
2884  char *xmlpattern;
2885  struct ast_config *cfg = NULL;
2886  struct ast_variable *var = NULL;
2887  struct ast_flags cnfflags = { 0 };
2888  int globret, i, dup, duplicate;
2889  glob_t globbuf;
2890 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE) || defined(DEBUG_NONGNU)
2891  int xmlpattern_maxlen;
2892 #endif
2893 
2894  /* setup default XML documentation language */
2896 
2897  if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) {
2898  for (var = ast_variable_browse(cfg, "options"); var; var = var->next) {
2899  if (!strcasecmp(var->name, "documentation_language")) {
2900  if (!ast_strlen_zero(var->value)) {
2901  snprintf(documentation_language, sizeof(documentation_language), "%s", var->value);
2902  }
2903  }
2904  }
2905  ast_config_destroy(cfg);
2906  }
2907 
2908  /* initialize the XML library. */
2909  ast_xml_init();
2910 
2912  /* register function to be run when asterisk finish. */
2914 
2915  globbuf.gl_offs = 0; /* slots to reserve in gl_pathv */
2916 
2917 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE) || defined(DEBUG_NONGNU)
2918  xmlpattern_maxlen = strlen(ast_config_AST_DATA_DIR) + strlen("/documentation/thirdparty") + strlen("/*-??_??.xml") + 1;
2919  xmlpattern = ast_malloc(xmlpattern_maxlen);
2920  globret = xml_pathmatch(xmlpattern, xmlpattern_maxlen, &globbuf);
2921 #else
2922  /* Get every *-LANG.xml file inside $(ASTDATADIR)/documentation */
2923  if (ast_asprintf(&xmlpattern, "%s/documentation{/thirdparty/,/}*-{%s,%.2s_??,%s}.xml", ast_config_AST_DATA_DIR,
2925  return 1;
2926  }
2927  globret = glob(xmlpattern, MY_GLOB_FLAGS, NULL, &globbuf);
2928 #endif
2929 
2930  ast_debug(3, "gl_pathc %zu\n", (size_t)globbuf.gl_pathc);
2931  if (globret == GLOB_NOSPACE) {
2932  ast_log(LOG_WARNING, "XML load failure, glob expansion of pattern '%s' failed: Not enough memory\n", xmlpattern);
2933  ast_free(xmlpattern);
2934  return 1;
2935  } else if (globret == GLOB_ABORTED) {
2936  ast_log(LOG_WARNING, "XML load failure, glob expansion of pattern '%s' failed: Read error\n", xmlpattern);
2937  ast_free(xmlpattern);
2938  return 1;
2939  }
2940  ast_free(xmlpattern);
2941 
2943  /* loop over expanded files */
2944  for (i = 0; i < globbuf.gl_pathc; i++) {
2945  /* check for duplicates (if we already [try to] open the same file. */
2946  duplicate = 0;
2947  for (dup = 0; dup < i; dup++) {
2948  if (!strcmp(globbuf.gl_pathv[i], globbuf.gl_pathv[dup])) {
2949  duplicate = 1;
2950  break;
2951  }
2952  }
2953  if (duplicate || strchr(globbuf.gl_pathv[i], '*')) {
2954  /* skip duplicates as well as pathnames not found
2955  * (due to use of GLOB_NOCHECK in xml_pathmatch) */
2956  continue;
2957  }
2958  tmpdoc = NULL;
2959  tmpdoc = ast_xml_open(globbuf.gl_pathv[i]);
2960  if (!tmpdoc) {
2961  ast_log(LOG_ERROR, "Could not open XML documentation at '%s'\n", globbuf.gl_pathv[i]);
2962  continue;
2963  }
2964  /* Get doc root node and check if it starts with '<docs>' */
2965  root_node = ast_xml_get_root(tmpdoc);
2966  if (!root_node) {
2967  ast_log(LOG_ERROR, "Error getting documentation root node\n");
2968  ast_xml_close(tmpdoc);
2969  continue;
2970  }
2971  /* Check root node name for malformed xmls. */
2972  if (strcmp(ast_xml_node_get_name(root_node), "docs")) {
2973  ast_log(LOG_ERROR, "Documentation file is not well formed!\n");
2974  ast_xml_close(tmpdoc);
2975  continue;
2976  }
2977  doc_tree = ast_calloc(1, sizeof(*doc_tree));
2978  if (!doc_tree) {
2979  ast_log(LOG_ERROR, "Unable to allocate documentation_tree structure!\n");
2980  ast_xml_close(tmpdoc);
2981  continue;
2982  }
2983  doc_tree->doc = tmpdoc;
2984  doc_tree->filename = ast_strdup(globbuf.gl_pathv[i]);
2986  }
2988 
2989  globfree(&globbuf);
2990 
2991  return 0;
2992 }
struct ast_variable * next
XML documentation tree.
Definition: xmldoc.c:54
int ast_xml_init(void)
Initialize the XML library implementation. This function is used to setup everything needed to start ...
Definition: xml.c:46
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:274
static struct ast_cli_entry cli_dump_xmldocs
Definition: xmldoc.c:2859
#define CONFIG_STATUS_FILEINVALID
struct ast_xml_doc * ast_xml_open(char *filename)
Open an XML document.
Definition: xml.c:63
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3154
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
struct ast_xml_node * ast_xml_get_root(struct ast_xml_doc *doc)
Get the document root node.
Definition: xml.c:199
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:269
#define ast_cli_register(e)
Registers a command or an array of commands.
Definition: cli.h:256
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static const char default_documentation_language[]
Default documentation language.
Definition: xmldoc.c:44
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
struct ast_xml_doc * doc
Definition: xmldoc.c:56
#define MY_GLOB_FLAGS
static char documentation_language[6]
XML documentation language.
Definition: xmldoc.c:51
const char * ast_config_AST_DATA_DIR
Definition: options.c:158
char * filename
Definition: xmldoc.c:55
#define LOG_ERROR
Definition: logger.h:285
static void xmldoc_unload_documentation(void)
Close and unload XML documentation.
Definition: xmldoc.c:2862
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define GLOB_ABORTED
Definition: ael_lex.c:839
void ast_xml_close(struct ast_xml_doc *doc)
Close an already open document and free the used structure.
Definition: xml.c:180
Structure used to handle boolean flags.
Definition: utils.h:199
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740
Definition: search.h:40
Container of documentation trees.
Definition: xmldoc.c:75
const char * ast_xml_node_get_name(struct ast_xml_node *node)
Get the name of a node.
Definition: xml.c:340

◆ astdb_init()

int astdb_init ( void  )

Provided by db.c

Definition at line 1082 of file main/db.c.

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

Referenced by asterisk_daemon().

1083 {
1085 
1086  if (db_init()) {
1087  return -1;
1088  }
1089 
1091  return -1;
1092  }
1093 
1100  return 0;
1101 }
static struct ast_cli_entry cli_database[]
Definition: main/db.c:873
static void astdb_atexit(void)
Definition: main/db.c:1058
static int manager_dbdel(struct mansession *s, const struct message *m)
Definition: main/db.c:950
#define ast_cond_init(cond, attr)
Definition: lock.h:199
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:197
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:567
static pthread_t syncthread
Definition: main/db.c:111
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: clicompat.c:13
static int db_init(void)
Definition: main/db.c:282
static ast_cond_t dbcond
Definition: main/db.c:109
#define ARRAY_LEN(a)
Definition: utils.h:639
static void * db_sync_thread(void *data)
Definition: main/db.c:1025
static int manager_dbget(struct mansession *s, const struct message *m)
Definition: main/db.c:908
static int manager_dbput(struct mansession *s, const struct message *m)
Definition: main/db.c:883
#define EVENT_FLAG_REPORTING
Definition: manager.h:80
static int manager_dbdeltree(struct mansession *s, const struct message *m)
Definition: main/db.c:975

◆ astobj2_init()

int astobj2_init ( void  )

Provided by astobj2.c

Definition at line 1166 of file astobj2.c.

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().

1167 {
1168  char ref_filename[1024];
1169 
1170  if (ast_opt_ref_debug) {
1171  snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
1172  ref_log = fopen(ref_filename, "w");
1173  if (!ref_log) {
1174  ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
1175  }
1176  }
1177 
1179 
1180  if (container_init() != 0) {
1181  fclose(ref_log);
1182  ref_log = NULL;
1183  return -1;
1184  }
1185 
1186 #if defined(AO2_DEBUG)
1187  ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
1188 #endif /* defined(AO2_DEBUG) */
1189 
1190  return 0;
1191 }
static void astobj2_cleanup(void)
Definition: astobj2.c:1154
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
#define LOG_ERROR
Definition: logger.h:285
const char * ast_config_AST_LOG_DIR
Definition: options.c:159
static FILE * ref_log
Definition: astobj2.c:44
#define ast_opt_ref_debug
Definition: options.h:135
int container_init(void)

◆ clean_time_zones()

void clean_time_zones ( void  )

Provided by localtime.c

Definition at line 1590 of file localtime.c.

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

Referenced by really_quit().

1591 {
1592  struct state *sp;
1593 
1595  while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
1596  sstate_free(sp);
1597  }
1599 }
struct state::@410 list
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static void sstate_free(struct state *p)
Definition: localtime.c:789
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832

◆ close_logger()

void close_logger ( void  )

Provided by logger.c

Definition at line 1899 of file logger.c.

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_cond_signal, ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_logger_category_unload(), AST_PTHREADT_NULL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::fileptr, logchannel::list, logger_initialized, and NULL.

Referenced by really_quit().

1900 {
1901  struct logchannel *f = NULL;
1902 
1904 
1906 
1907  logger_initialized = 0;
1908 
1909  /* Stop logger thread */
1911  close_logger_thread = 1;
1914 
1915  if (logthread != AST_PTHREADT_NULL) {
1916  pthread_join(logthread, NULL);
1917  }
1918 
1920 
1921  if (qlog) {
1922  fclose(qlog);
1923  qlog = NULL;
1924  }
1925 
1926  while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) {
1927  if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
1928  fclose(f->fileptr);
1929  f->fileptr = NULL;
1930  }
1931  ast_free(f);
1932  }
1933 
1934  closelog(); /* syslog */
1935 
1937 }
static struct ast_cli_entry cli_logger[]
Definition: logger.c:1546
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static pthread_t logthread
Definition: logger.c:187
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
int ast_logger_category_unload(void)
Unload system wide logger category functionality.
struct logchannel::@391 list
#define NULL
Definition: resample.c:96
#define ast_cond_signal(cond)
Definition: lock.h:201
static FILE * qlog
Definition: logger.c:191
static int logger_initialized
Definition: logger.c:85
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
#define ARRAY_LEN(a)
Definition: utils.h:639
#define ast_free(a)
Definition: astmm.h:182
FILE * fileptr
Definition: logger.c:143
static int close_logger_thread
Definition: logger.c:189
static ast_cond_t logcond
Definition: logger.c:188

◆ dns_core_init()

int dns_core_init ( void  )

Provided by dns_core.c

Definition at line 614 of file dns_core.c.

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

Referenced by asterisk_daemon().

615 {
617  if (!sched) {
618  return -1;
619  }
620 
622  return -1;
623  }
624 
626 
627  return 0;
628 }
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:195
static void dns_shutdown(void)
Definition: dns_core.c:606
Definition: sched.c:76
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:236

◆ dnsmgr_start_refresh()

void dnsmgr_start_refresh ( void  )

Provided by dnsmgr.c

Definition at line 302 of file dnsmgr.c.

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

Referenced by asterisk_daemon().

303 {
304  if (refresh_sched > -1) {
307  }
308 }
static struct refresh_info master_refresh_info
Definition: dnsmgr.c:101
Definition: sched.c:76
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:524
static int refresh_sched
Definition: dnsmgr.c:63
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
Definition: sched.h:46
static int refresh_list(const void *data)
Definition: dnsmgr.c:272

◆ init_logger()

int init_logger ( void  )

Provided by logger.c

Definition at line 1857 of file logger.c.

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

Referenced by asterisk_daemon().

1858 {
1859  int res;
1860  /* auto rotate if sig SIGXFSZ comes a-knockin */
1861  sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
1862 
1863  /* Re-initialize the logmsgs mutex. The recursive mutex can be accessed prior
1864  * to Asterisk being forked into the background, which can cause the thread
1865  * ID tracked by the underlying pthread mutex to be different than the ID of
1866  * the thread that unlocks the mutex. Since init_logger is called after the
1867  * fork, it is safe to initialize the mutex here for future accesses.
1868  */
1872 
1873  /* start logger thread */
1876  return -1;
1877  }
1878 
1879  /* register the logger cli commands */
1881 
1883 
1884  /* create log channels */
1886  res = init_logger_chain(NULL);
1888  ast_verb_update();
1889  logger_initialized = 1;
1890  if (res) {
1891  ast_log(LOG_ERROR, "Errors detected in logger.conf. Default console logging is being used.\n");
1892  }
1893 
1895 
1896  return 0;
1897 }
static struct ast_cli_entry cli_logger[]
Definition: logger.c:1546
static int init_logger_chain(const char *altconf)
Read config, setup channels.
Definition: logger.c:708
static struct sigaction handle_SIGXFSZ
Definition: logger.c:1561
static pthread_t logthread
Definition: logger.c:187
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition: logger.c:2219
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_cond_init(cond, attr)
Definition: lock.h:199
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
static int logger_initialized
Definition: logger.c:85
#define ARRAY_LEN(a)
Definition: utils.h:639
#define LOG_ERROR
Definition: logger.h:285
#define ast_cond_destroy(cond)
Definition: lock.h:200
const char * ast_config_AST_LOG_DIR
Definition: options.c:159
static void * logger_thread(void *data)
Actual logging thread.
Definition: logger.c:1748
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:559
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:2088
#define ast_mutex_init(pmutex)
Definition: lock.h:184
#define ast_mutex_destroy(a)
Definition: lock.h:186
ast_mutex_t lock
Definition: logger.c:186
static ast_cond_t logcond
Definition: logger.c:188
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: main/utils.c:2231
int ast_logger_category_load(void)
Load/Initialize system wide logger category functionality.

◆ load_asterisk_conf()

void load_asterisk_conf ( void  )

Definition at line 210 of file options.c.

References _cfg_paths::agi_dir, AST_CACHE_DIR_LEN, ast_clear_flag, 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_STDEXTEN_MACRO, AST_OPT_FLAG_TIMESTAMP, AST_OPT_FLAG_TRANSCODE_VIA_SLIN, AST_OPT_FLAG_TRANSMIT_SILENCE, ast_opt_remote, ast_option_maxcalls, ast_option_maxfiles, ast_option_maxload, ast_option_rtpptdynamic, ast_option_rtpusedynamic, ast_parse_arg(), AST_RTP_PT_FIRST_DYNAMIC, ast_set2_flag, ast_set_default_eid(), ast_set_flag, ast_set_lock_type(), ast_str_to_eid(), ast_strlen_zero(), ast_true(), ast_variable_browse(), _cfg_paths::cache_dir, _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, _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().

211 {
212  struct ast_config *cfg;
213  struct ast_variable *v;
214  char hostname[MAXHOSTNAMELEN] = "";
215  struct ast_flags config_flags = { CONFIG_FLAG_NOREALTIME };
216  struct {
217  unsigned int dbdir:1;
218  unsigned int keydir:1;
219  } found = { 0, 0 };
220  /* Default to false for security */
221  int live_dangerously = 0;
222  int option_debug_new = 0;
223  int option_trace_new = 0;
224  int option_verbose_new = 0;
225 
226  /* init with buildtime config */
227 #ifdef REF_DEBUG
228  /* The REF_DEBUG compiler flag is now only used to enable refdebug by default.
229  * Support for debugging reference counts is always compiled in. */
231 #endif
232 
234 
235  cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
236 
237  /* If AST_OPT_FLAG_EXEC_INCLUDES was previously enabled with -X turn it off now.
238  * Using #exec from other configs requires that it be enabled from asterisk.conf. */
240 
241  /* no asterisk.conf? no problem, use buildtime config! */
243  fprintf(stderr, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
244  return;
245  }
246 
247  for (v = ast_variable_browse(cfg, "files"); v; v = v->next) {
248  if (!strcasecmp(v->name, "astctlpermissions")) {
250  } else if (!strcasecmp(v->name, "astctlowner")) {
252  } else if (!strcasecmp(v->name, "astctlgroup")) {
254  } else if (!strcasecmp(v->name, "astctl")) {
256  }
257  }
258 
259  for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {
260  if (!strcasecmp(v->name, "astcachedir")) {
262  } else if (!strcasecmp(v->name, "astetcdir")) {
264  } else if (!strcasecmp(v->name, "astspooldir")) {
266  snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", v->value);
267  snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", v->value);
268  } else if (!strcasecmp(v->name, "astvarlibdir")) {
270  if (!found.dbdir) {
271  snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);
272  }
273  } else if (!strcasecmp(v->name, "astdbdir")) {
274  snprintf(cfg_paths.db_path, sizeof(cfg_paths.db_path), "%s/astdb", v->value);
275  found.dbdir = 1;
276  } else if (!strcasecmp(v->name, "astdatadir")) {
278  if (!found.keydir) {
279  snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);
280  }
281  } else if (!strcasecmp(v->name, "astkeydir")) {
282  snprintf(cfg_paths.key_dir, sizeof(cfg_paths.key_dir), "%s/keys", v->value);
283  found.keydir = 1;
284  } else if (!strcasecmp(v->name, "astlogdir")) {
286  } else if (!strcasecmp(v->name, "astagidir")) {
288  } else if (!strcasecmp(v->name, "astrundir")) {
289  snprintf(cfg_paths.pid_path, sizeof(cfg_paths.pid_path), "%s/%s", v->value, "asterisk.pid");
291  } else if (!strcasecmp(v->name, "astmoddir")) {
293  } else if (!strcasecmp(v->name, "astsbindir")) {
295  }
296  }
297 
298  /* Combine astrundir and astctl settings. */
299  snprintf(cfg_paths.socket_path, sizeof(cfg_paths.socket_path), "%s/%s",
301 
302  for (v = ast_variable_browse(cfg, "options"); v; v = v->next) {
303  /* verbose level (-v at startup) */
304  if (!strcasecmp(v->name, "verbose")) {
305  option_verbose_new = atoi(v->value);
306  /* whether or not to force timestamping in CLI verbose output. (-T at startup) */
307  } else if (!strcasecmp(v->name, "timestamp")) {
309  /* whether or not to support #exec in config files */
310  } else if (!strcasecmp(v->name, "execincludes")) {
312  /* debug level (-d at startup) */
313  } else if (!strcasecmp(v->name, "debug")) {
314  option_debug_new = 0;
315  if (sscanf(v->value, "%30d", &option_debug_new) != 1) {
316  option_debug_new = ast_true(v->value) ? 1 : 0;
317  }
318  } else if (!strcasecmp(v->name, "trace")) {
319  option_trace_new = 0;
320  if (sscanf(v->value, "%30d", &option_trace_new) != 1) {
321  option_trace_new = ast_true(v->value) ? 1 : 0;
322  }
323  } else if (!strcasecmp(v->name, "refdebug")) {
325 #if HAVE_WORKING_FORK
326  /* Disable forking (-f at startup) */
327  } else if (!strcasecmp(v->name, "nofork")) {
329  /* Always fork, even if verbose or debug are enabled (-F at startup) */
330  } else if (!strcasecmp(v->name, "alwaysfork")) {
332 #endif
333  /* Run quietly (-q at startup ) */
334  } else if (!strcasecmp(v->name, "quiet")) {
336  /* Run as console (-c at startup, implies nofork) */
337  } else if (!strcasecmp(v->name, "console")) {
338  if (!ast_opt_remote) {
340  }
341  /* Run with high priority if the O/S permits (-p at startup) */
342  } else if (!strcasecmp(v->name, "highpriority")) {
344  /* Initialize RSA auth keys (IAX2) (-i at startup) */
345  } else if (!strcasecmp(v->name, "initcrypto")) {
347  /* Disable ANSI colors for console (-c at startup) */
348  } else if (!strcasecmp(v->name, "nocolor")) {
350  /* Disable some usage warnings for picky people :p */
351  } else if (!strcasecmp(v->name, "dontwarn")) {
353  /* Dump core in case of crash (-g) */
354  } else if (!strcasecmp(v->name, "dumpcore")) {
356  /* Cache recorded sound files to another directory during recording */
357  } else if (!strcasecmp(v->name, "cache_record_files")) {
359 #if !defined(LOW_MEMORY)
360  /* Cache media frames for performance */
361  } else if (!strcasecmp(v->name, "cache_media_frames")) {
363 #endif
364  /* Specify cache directory */
365  } else if (!strcasecmp(v->name, "record_cache_dir")) {
367  /* Build transcode paths via SLINEAR, instead of directly */
368  } else if (!strcasecmp(v->name, "transcode_via_sln")) {
370  /* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */
371  } else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) {
373  } else if (!strcasecmp(v->name, "mindtmfduration")) {
374  if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) {
376  }
377  } else if (!strcasecmp(v->name, "rtp_use_dynamic")) {
379  /* http://www.iana.org/assignments/rtp-parameters
380  * RTP dynamic payload types start at 96 normally; extend down to 0 */
381  } else if (!strcasecmp(v->name, "rtp_pt_dynamic")) {
384  } else if (!strcasecmp(v->name, "maxcalls")) {
385  if ((sscanf(v->value, "%30d", &ast_option_maxcalls) != 1) || (ast_option_maxcalls < 0)) {
387  }
388  } else if (!strcasecmp(v->name, "maxload")) {
389  double test[1];
390 
391  if (getloadavg(test, 1) == -1) {
392  ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n");
393  ast_option_maxload = 0.0;
394  } else if ((sscanf(v->value, "%30lf", &ast_option_maxload) != 1) || (ast_option_maxload < 0.0)) {
395  ast_option_maxload = 0.0;
396  }
397  /* Set the maximum amount of open files */
398  } else if (!strcasecmp(v->name, "maxfiles")) {
399  ast_option_maxfiles = atoi(v->value);
400  if (!ast_opt_remote) {
402  }
403  /* What user to run as */
404  } else if (!strcasecmp(v->name, "runuser")) {
406  /* What group to run as */
407  } else if (!strcasecmp(v->name, "rungroup")) {
409  } else if (!strcasecmp(v->name, "systemname")) {
411  } else if (!strcasecmp(v->name, "autosystemname")) {
412  if (ast_true(v->value)) {
413  if (!gethostname(hostname, sizeof(hostname) - 1)) {
415  } else {
418  }
419  ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using '%s' instead.\n", ast_config_AST_SYSTEM_NAME);
420  }
421  }
422  } else if (!strcasecmp(v->name, "languageprefix")) {
424  } else if (!strcasecmp(v->name, "defaultlanguage")) {
426  } else if (!strcasecmp(v->name, "lockmode")) {
427  if (!strcasecmp(v->value, "lockfile")) {
429  } else if (!strcasecmp(v->value, "flock")) {
431  } else {
432  ast_log(LOG_WARNING, "'%s' is not a valid setting for the lockmode option, "
433  "defaulting to 'lockfile'\n", v->value);
435  }
436 #if defined(HAVE_SYSINFO)
437  } else if (!strcasecmp(v->name, "minmemfree")) {
438  /* specify the minimum amount of free memory to retain. Asterisk should stop accepting new calls
439  * if the amount of free memory falls below this watermark */
440  if ((sscanf(v->value, "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) {
441  option_minmemfree = 0;
442  }
443 #endif
444  } else if (!strcasecmp(v->name, "entityid")) {
445  struct ast_eid tmp_eid;
446  if (!ast_str_to_eid(&tmp_eid, v->value)) {
447  ast_eid_default = tmp_eid;
448  } else {
449  ast_log(LOG_WARNING, "Invalid Entity ID '%s' provided\n", v->value);
450  }
451  } else if (!strcasecmp(v->name, "lightbackground")) {
453  } else if (!strcasecmp(v->name, "forceblackbackground")) {
455  } else if (!strcasecmp(v->name, "hideconnect")) {
457  } else if (!strcasecmp(v->name, "lockconfdir")) {
459  } else if (!strcasecmp(v->name, "stdexten")) {
460  /* Choose how to invoke the extensions.conf stdexten */
461  if (!strcasecmp(v->value, "gosub")) {
463  } else if (!strcasecmp(v->value, "macro")) {
465  } else {
467  "'%s' is not a valid setting for the stdexten option, defaulting to 'gosub'\n",
468  v->value);
470  }
471  } else if (!strcasecmp(v->name, "live_dangerously")) {
472  live_dangerously = ast_true(v->value);
473  } else if (!strcasecmp(v->name, "hide_messaging_ami_events")) {
475  }
476  }
477  if (!ast_opt_remote) {
478  pbx_live_dangerously(live_dangerously);
479  }
480 
481  option_debug += option_debug_new;
482  option_trace += option_trace_new;
483  option_verbose += option_verbose_new;
484 
485  ast_config_destroy(cfg);
486 }
struct ast_variable * next
char run_user[PATH_MAX]
Definition: options.c:119
int ast_option_maxfiles
Definition: options.c:81
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
Definition: main/app.c:2392
unsigned int option_dtmfminduration
Definition: options.c:83
char data_dir[PATH_MAX]
Definition: options.c:108
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous dialplan functions to run. ...
Definition: pbx_functions.c:46
char cache_dir[PATH_MAX]
Definition: options.c:101
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
int option_debug
Definition: options.c:69
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:274
#define CONFIG_STATUS_FILEINVALID
char ctl_group[PATH_MAX]
Definition: options.c:124
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3154
Structure for variables, used for configurations and for channel variables.
char var_dir[PATH_MAX]
Definition: options.c:107
const char * ast_config_AST_SYSTEM_NAME
Definition: options.c:170
char module_dir[PATH_MAX]
Definition: options.c:103
int option_verbose
Definition: options.c:67
char key_dir[PATH_MAX]
Definition: options.c:112
void ast_set_default_eid(struct ast_eid *eid)
Fill in an ast_eid with the default eid of this machine.
Definition: main/utils.c:2749
double ast_option_maxload
Definition: options.c:77
#define MAXHOSTNAMELEN
Definition: network.h:69
#define AST_RTP_PT_FIRST_DYNAMIC
Definition: rtp_engine.h:92
#define AST_MIN_DTMF_DURATION
Definition: options.c:49
const char * ast_config_AST_CONFIG_FILE
Definition: options.c:152
An Entity ID is essentially a MAC address, brief and unique.
Definition: utils.h:786
int ast_option_maxcalls
Definition: options.c:79
#define MAX_LANGUAGE
Definition: channel.h:173
const char * ast_config_AST_RUN_DIR
Definition: options.c:162
char sbin_dir[PATH_MAX]
Definition: options.c:116
char run_group[PATH_MAX]
Definition: options.c:120
char ast_defaultlanguage[MAX_LANGUAGE]
Definition: options.c:98
#define ast_log
Definition: astobj2.c:42
char spool_dir[PATH_MAX]
Definition: options.c:104
long option_minmemfree
Definition: options.c:86
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int ast_language_is_prefix
The following variable controls the layout of localized sound files. If 0, use the historical layout ...
Definition: file.c:67
#define AST_CACHE_DIR_LEN
Definition: options.h:32
char db_path[PATH_MAX]
Definition: options.c:115
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
int ast_str_to_eid(struct ast_eid *eid, const char *s)
Convert a string into an EID.
Definition: main/utils.c:2825
char recording_dir[PATH_MAX]
Definition: options.c:106
char monitor_dir[PATH_MAX]
Definition: options.c:105
#define CONFIG_STATUS_FILEUNCHANGED
char ctl_owner[PATH_MAX]
Definition: options.c:123
#define LOG_ERROR
Definition: logger.h:285
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define ast_opt_remote
Definition: options.h:112
char record_cache_dir[AST_CACHE_DIR_LEN]
Definition: options.c:96
char pid_path[PATH_MAX]
Definition: options.c:117
char config_dir[PATH_MAX]
Definition: options.c:102
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of &#39;dangerous&#39; functions from external protocols (AMI, etc.).
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
Structure used to handle boolean flags.
Definition: utils.h:199
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CONFIG_STATUS_FILEMISSING
char run_dir[PATH_MAX]
Definition: options.c:111
struct ast_flags ast_options
Definition: options.c:61
static void set_ulimit(int value)
Set maximum open files.
Definition: options.c:178
char ctl_perms[PATH_MAX]
Definition: options.c:122
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
char socket_path[PATH_MAX]
Definition: options.c:118
char agi_dir[PATH_MAX]
Definition: options.c:110
const char * ast_config_AST_CTL
Definition: options.c:175
int getloadavg(double *list, int nelem)
int ast_option_rtpusedynamic
Definition: options.c:88
static struct _cfg_paths cfg_paths
Definition: options.c:128
char log_dir[PATH_MAX]
Definition: options.c:109
char ctl_file[PATH_MAX]
Definition: options.c:125
unsigned int ast_option_rtpptdynamic
Definition: options.c:89
char system_name[128]
Definition: options.c:121
struct ast_eid ast_eid_default
Global EID.
Definition: options.c:93
static char hostname[MAXHOSTNAMELEN]
Definition: logger.c:110
int option_trace
Definition: options.c:71

◆ load_astmm_phase_1()

void load_astmm_phase_1 ( void  )

Initialize malloc debug phase 1.

Note
Must be called first thing after forking.
Returns
Nothing

Definition at line 1557 of file astmm.c.

Referenced by asterisk_daemon().

1558 {
1559 }

◆ load_astmm_phase_2()

void load_astmm_phase_2 ( void  )

Initialize malloc debug phase 2.

Returns
Nothing

Definition at line 1561 of file astmm.c.

Referenced by asterisk_daemon().

1562 {
1563 }

◆ load_modules()

int load_modules ( void  )

Provided by loader.c

Definition at line 2338 of file loader.c.

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, load_order_entry::resource, ast_module::running, startup_errors, str, and ast_module_info::support_level.

Referenced by asterisk_daemon().

2339 {
2340  struct load_order_entry *order;
2341  unsigned int load_count;
2342  struct load_order load_order;
2343  int res = 0;
2344  int modulecount = 0;
2345  int i;
2346  struct ast_module *cur;
2347 #ifdef AST_XML_DOCS
2348  struct ast_str *warning_msg;
2349  char deprecated_in[33];
2350  char removed_in[33];
2351  char replacement[129];
2352 #endif
2353  struct timeval start_time = ast_tvnow();
2354  struct timeval end_time;
2355  int64_t usElapsed;
2356 
2357  ast_verb(1, "Asterisk Dynamic Loader Starting:\n");
2358 
2359 #if defined(HAVE_PERMANENT_DLOPEN)
2361  info_list_obj_cmp_fn); /* must not be cleaned at shutdown */
2362  if (!info_list) {
2363  fprintf(stderr, "Module info list allocation failure.\n");
2364  return 1;
2365  }
2366 #endif
2367 
2370 
2373 
2375  if (res) {
2376  goto done;
2377  }
2378 
2380  if (res) {
2381  goto done;
2382  }
2383 
2384  load_count = 0;
2386  load_count++;
2387 
2388  if (load_count)
2389  ast_log(LOG_NOTICE, "%u modules will be loaded.\n", load_count);
2390 
2391  res = load_resource_list(&load_order, &modulecount);
2392  if (res == -1) {
2393  ast_log(LOG_WARNING, "Some non-required modules failed to load.\n");
2394  res = 0;
2395  }
2396 
2397 done:
2398  while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
2399  ast_free(order->resource);
2400  ast_free(order);
2401  }
2402 
2403 #ifdef AST_XML_DOCS
2404  warning_msg = ast_str_create(512);
2405 #endif
2406 
2408 #ifdef AST_XML_DOCS
2409  char *mod_name = NULL;
2410  struct ast_xml_xpath_results *results;
2411 #endif
2412 
2413  if (!cur->flags.running || cur->flags.declined) {
2414  continue;
2415  }
2416 
2417 #ifdef AST_XML_DOCS
2418  mod_name = get_name_from_resource(cur->resource);
2419  if (!warning_msg || !mod_name) {
2420  /* If we can't allocate memory, we have bigger issues */
2421  ast_free(mod_name);
2422  continue;
2423  }
2424 
2425  /* Clear out the previous values */
2426  deprecated_in[0] = removed_in[0] = replacement[0] = 0;
2427 
2428  results = ast_xmldoc_query("/docs/module[@name='%s']", mod_name);
2429  if (results) {
2430  struct ast_xml_node *deprecated_node, *removed_node, *replacement_node;
2431  struct ast_xml_node *metadata_nodes = ast_xml_node_get_children(ast_xml_xpath_get_first_result(results));
2432 
2433  deprecated_node = ast_xml_find_element(metadata_nodes, "deprecated_in", NULL, NULL);
2434  if (deprecated_node) {
2435  const char *result_tmp = ast_xml_get_text(deprecated_node);
2436  if (!ast_strlen_zero(result_tmp)) {
2437  ast_copy_string(deprecated_in, result_tmp, sizeof(deprecated_in));
2438  }
2439  }
2440 
2441  removed_node = ast_xml_find_element(metadata_nodes, "removed_in", NULL, NULL);
2442  if (removed_node) {
2443  const char *result_tmp = ast_xml_get_text(removed_node);
2444  if (!ast_strlen_zero(result_tmp)) {
2445  ast_copy_string(removed_in, result_tmp, sizeof(removed_in));
2446  }
2447  }
2448 
2449  replacement_node = ast_xml_find_element(metadata_nodes, "replacement", NULL, NULL);
2450  if (replacement_node) {
2451  const char *result_tmp = ast_xml_get_text(replacement_node);
2452  if (!ast_strlen_zero(result_tmp)) {
2453  ast_copy_string(replacement, result_tmp, sizeof(replacement));
2454  }
2455  }
2456 
2457  ast_xml_xpath_results_free(results);
2458  }
2459 
2460  ast_str_reset(warning_msg);
2461 
2462  if (cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED || !ast_strlen_zero(deprecated_in)
2463  || !ast_strlen_zero(removed_in) || !ast_strlen_zero(replacement)) {
2464  int already_butted = 0;
2465 
2466  ast_str_append(&warning_msg, -1, "Module '%s' has been loaded", mod_name);
2467  if (!ast_strlen_zero(deprecated_in)) {
2468  ast_str_append(&warning_msg, -1, " but %s deprecated in Asterisk version %s",
2469  cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED ? "was" : "will be", deprecated_in);
2470  already_butted = 1;
2471  }
2472 
2473  if (!ast_strlen_zero(removed_in)) {
2474  ast_str_append(&warning_msg, -1, " %s will be removed in Asterisk version %s", already_butted ? "and" : "but", removed_in);
2475  } else {
2476  ast_str_append(&warning_msg, -1, " %s may be removed in a future release", already_butted ? "and" : "but");
2477  }
2478 
2479  ast_str_append(&warning_msg, -1, ".");
2480 
2481  if (!ast_strlen_zero(replacement)) {
2482  ast_str_append(&warning_msg, -1, " Its replacement is '%s'.", replacement);
2483  }
2484  }
2485 
2486  if (ast_str_strlen(warning_msg)) {
2487  ast_log(LOG_WARNING, "%s\n", ast_str_buffer(warning_msg));
2488  }
2489 
2490  ast_free(mod_name);
2491 #else
2493  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);
2494  }
2495 #endif
2496  }
2497 
2498 #ifdef AST_XML_DOCS
2499  ast_free(warning_msg);
2500 #endif
2501 
2503 
2504 
2505  for (i = 0; i < AST_VECTOR_SIZE(&startup_errors); i++) {
2506  char *str = AST_VECTOR_GET(&startup_errors, i);
2507 
2508  ast_log(LOG_ERROR, "%s", str);
2509  ast_free(str);
2510  }
2512 
2515 
2516  end_time = ast_tvnow();
2517  usElapsed = ast_tvdiff_us(end_time, start_time);
2518 
2519 #ifdef AST_XML_DOCS
2520  ast_debug(1, "Loader time with AST_XML_DOCS: %ld.%06ld\n", usElapsed / 1000000, usElapsed % 1000000);
2521 #else
2522  ast_debug(1, "Loader time without AST_XML_DOCS: %ld.%06ld\n", usElapsed / 1000000, usElapsed % 1000000);
2523 #endif
2524 
2525  return res;
2526 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
unsigned int running
Definition: loader.c:320
static char * get_name_from_resource(const char *resource)
Definition: loader.c:157
#define LOG_WARNING
Definition: logger.h:274
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
#define AST_DLLIST_UNLOCK(head)
Attempts to unlock a list.
Definition: dlinkedlists.h:122
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
Definition: loader.c:1832
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:1091
struct ast_xml_xpath_results * ast_xmldoc_query(const char *fmt,...)
Execute an XPath query on the loaded XML documentation.
Definition: xmldoc.c:2545
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
const char * str
Definition: app_jack.c:147
struct ast_module::@385 flags
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
int done
Definition: test_amihooks.c:48
char * resource
Definition: loader.c:1833
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
const struct ast_module_info * info
Definition: loader.c:294
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: dlinkedlists.h:575
integer order
Definition: analys.c:66
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
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:266
unsigned int declined
Definition: loader.c:322
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
static int load_resource_list(struct load_order *load_order, int *mod_count)
Definition: loader.c:2101
#define LOG_ERROR
Definition: logger.h:285
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static int loader_builtin_init(struct load_order *load_order)
Definition: loader.c:2179
static int loader_config_init(struct load_order *load_order)
Definition: loader.c:2214
static struct ast_str * startup_error_builder
Definition: loader.c:154
#define LOG_NOTICE
Definition: logger.h:263
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:182
void ast_xml_xpath_results_free(struct ast_xml_xpath_results *results)
Free the XPath results.
Definition: xml.c:370
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:653
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:688
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:680
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
const char * ast_xml_get_text(struct ast_xml_node *node)
Get an element content string.
Definition: xml.c:317
Definition: search.h:40
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
Definition: time.h:78
static struct ast_vector_string startup_errors
Definition: loader.c:153
enum ast_module_support_level support_level
Definition: module.h:416
char resource[0]
Definition: loader.c:333
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:365
#define AST_DLLIST_LOCK(head)
Locks a list.
Definition: dlinkedlists.h:45
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node&#39;s children.
Definition: xml.c:345
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

◆ load_pbx()

int load_pbx ( void  )

Provided by pbx.c

Definition at line 8460 of file pbx.c.

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(), EVENT_FLAG_CALL, EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, manager_show_dialplan(), NULL, presence_state_cb(), stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and unload_pbx().

Referenced by asterisk_daemon().

8461 {
8462  int res = 0;
8463 
8465 
8466  /* Initialize the PBX */
8467  ast_verb(1, "Asterisk PBX Core Initializing\n");
8468 
8469  ast_verb(2, "Registering builtin functions:\n");
8473 
8474  /* Register manager application */
8477 
8478  if (res) {
8479  return -1;
8480  }
8481 
8483  return -1;
8484  }
8486  stasis_subscription_accept_message_type(device_state_sub, hint_change_message_type());
8487  stasis_subscription_accept_message_type(device_state_sub, hint_remove_message_type());
8489 
8491  return -1;
8492  }
8495 
8496  return 0;
8497 }
static struct stasis_subscription * presence_state_sub
Subscription for presence state change events.
Definition: pbx.c:770
#define EVENT_FLAG_CALL
Definition: manager.h:72
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:1079
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct ast_cli_entry pbx_cli[]
Definition: pbx.c:6164
#define NULL
Definition: resample.c:96
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:197
#define ast_verb(level,...)
Definition: logger.h:455
struct stasis_message_type * ast_device_state_message_type(void)
Get the Stasis message type for device state messages.
static void presence_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
Definition: pbx.c:8333
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct ast_custom_function testtime_function
Definition: pbx.c:8316
static void unload_pbx(void)
Definition: pbx.c:8448
#define ARRAY_LEN(a)
Definition: utils.h:639
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:652
#define EVENT_FLAG_CONFIG
Definition: manager.h:78
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
Definition: pbx.c:6019
static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
Definition: pbx.c:3584
struct stasis_topic * ast_device_state_topic_all(void)
Get the Stasis topic for device state messages.
Definition: devicestate.c:668
static int action_extensionstatelist(struct mansession *s, const struct message *m)
Definition: pbx.c:8383
static struct ast_custom_function exception_function
Definition: pbx.c:2852
#define EVENT_FLAG_REPORTING
Definition: manager.h:80
struct stasis_message_type * ast_presence_state_message_type(void)
Get presence state message type.
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:1025
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
struct stasis_topic * ast_presence_state_topic_all(void)
Get presence state topic.
static struct stasis_subscription * device_state_sub
Subscription for device state change events.
Definition: pbx.c:768

◆ load_pbx_app()

int load_pbx_app ( void  )

Provided by pbx_app.c

Definition at line 511 of file pbx_app.c.

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

Referenced by asterisk_daemon().

512 {
515 
516  return 0;
517 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct ast_cli_entry app_cli[]
Definition: pbx_app.c:501
static void unload_pbx_app(void)
Definition: pbx_app.c:506
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639

◆ load_pbx_builtins()

int load_pbx_builtins ( void  )

Provided by pbx_builtins.c

Definition at line 1637 of file pbx_builtins.c.

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

Referenced by asterisk_daemon().

1638 {
1639  int x;
1640 
1641  /* Register builtin applications */
1642  for (x = 0; x < ARRAY_LEN(builtins); x++) {
1644  ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
1645  return -1;
1646  }
1647  }
1648 
1650 
1651  return 0;
1652 }
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:454
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct pbx_builtin builtins[]
#define ARRAY_LEN(a)
Definition: utils.h:639
#define LOG_ERROR
Definition: logger.h:285
static void unload_pbx_builtins(void)
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:103

◆ load_pbx_functions_cli()

int load_pbx_functions_cli ( void  )

Provided by pbx_functions.c

Definition at line 732 of file pbx_functions.c.

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

Referenced by asterisk_daemon().

733 {
736 
737  return 0;
738 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static void unload_pbx_functions_cli(void)
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct ast_cli_entry acf_cli[]

◆ load_pbx_hangup_handler()

int load_pbx_hangup_handler ( void  )

Provided by pbx_hangup_handler.c

Definition at line 292 of file pbx_hangup_handler.c.

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

Referenced by asterisk_daemon().

293 {
296 
297  return 0;
298 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static void unload_pbx_hangup_handler(void)
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct ast_cli_entry cli[]

◆ load_pbx_switch()

int load_pbx_switch ( void  )

Provided by pbx_switch.c

Definition at line 125 of file pbx_switch.c.

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

Referenced by asterisk_daemon().

126 {
129 
130  return 0;
131 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct ast_cli_entry sw_cli[]
Definition: pbx_switch.c:116
#define ARRAY_LEN(a)
Definition: utils.h:639
static void unload_pbx_switch(void)
Definition: pbx_switch.c:120

◆ load_pbx_variables()

int load_pbx_variables ( void  )

Provided by pbx_variables.c

Definition at line 1216 of file pbx_variables.c.

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

Referenced by asterisk_daemon().

1217 {
1218  int res = 0;
1219 
1224 
1225  return res;
1226 }
static void unload_pbx_variables(void)
static struct ast_cli_entry vars_cli[]
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ARRAY_LEN(a)
Definition: utils.h:639
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 &#39;,&#39; character...
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:103
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 &#39;=&#39; character...

◆ 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.
Returns
Nothing

Definition at line 1841 of file logger.c.

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().

1842 {
1843  /* Must not be called before the logger is initialized. */
1845 
1847  if (!queuelog_init) {
1849  queuelog_init = 1;
1851  ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
1852  } else {
1854  }
1855 }
static int queuelog_init
Definition: logger.c:84
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_assert(a)
Definition: utils.h:710
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
Definition: logger.c:881
static int logger_initialized
Definition: logger.c:85
static void logger_queue_init(void)
Definition: logger.c:1804

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

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::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().

1183 {
1184  struct ast_module *mod;
1185  int somethingchanged;
1186  int res;
1187 
1189 
1190  /*!\note Some resources, like timers, are started up dynamically, and thus
1191  * may be still in use, even if all channels are dead. We must therefore
1192  * check the usecount before asking modules to unload. */
1193  do {
1194  /* Reset flag before traversing the list */
1195  somethingchanged = 0;
1196 
1198  if (mod->usecount) {
1199  ast_debug(1, "Passing on %s: its use count is %d\n",
1200  mod->resource, mod->usecount);
1201  continue;
1202  }
1204  if (mod->flags.running && !mod->flags.declined && mod->info->unload) {
1205  ast_verb(1, "Unloading %s\n", mod->resource);
1206  mod->info->unload();
1207  }
1208  module_destroy(mod);
1209  somethingchanged = 1;
1210  }
1212  if (!somethingchanged) {
1214  if (mod->flags.keepuntilshutdown) {
1215  ast_module_unref(mod);
1216  mod->flags.keepuntilshutdown = 0;
1217  somethingchanged = 1;
1218  }
1219  }
1220  }
1221  } while (somethingchanged);
1222 
1223  res = AST_DLLIST_EMPTY(&module_list);
1225 
1226  return !res;
1227 }
unsigned int running
Definition: loader.c:320
#define AST_DLLIST_UNLOCK(head)
Attempts to unlock a list.
Definition: dlinkedlists.h:122
static void module_destroy(struct ast_module *mod)
Definition: loader.c:744
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: dlinkedlists.h:887
int usecount
Definition: loader.c:300
#define AST_DLLIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: dlinkedlists.h:752
struct ast_module::@385 flags
#define ast_verb(level,...)
Definition: logger.h:455
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
const struct ast_module_info * info
Definition: loader.c:294
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: dlinkedlists.h:575
int(* unload)(void)
Definition: module.h:348
unsigned int declined
Definition: loader.c:322
#define AST_DLLIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: dlinkedlists.h:468
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END
Closes a safe loop traversal block.
Definition: dlinkedlists.h:920
unsigned int keepuntilshutdown
Definition: loader.c:324
Definition: search.h:40
char resource[0]
Definition: loader.c:333
#define AST_DLLIST_LOCK(head)
Locks a list.
Definition: dlinkedlists.h:45

◆ set_asterisk_conf_path()

void set_asterisk_conf_path ( const char *  path)

Definition at line 200 of file options.c.

References ast_copy_string(), and _cfg_paths::config_file.

Referenced by main().

201 {
203 }
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct _cfg_paths cfg_paths
Definition: options.c:128
char config_file[PATH_MAX]
Definition: options.c:114

◆ set_socket_path()

void set_socket_path ( const char *  path)

Definition at line 205 of file options.c.

References ast_copy_string(), and _cfg_paths::socket_path.

Referenced by main().

206 {
208 }
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
char socket_path[PATH_MAX]
Definition: options.c:118
static struct _cfg_paths cfg_paths
Definition: options.c:128

◆ threadstorage_init()

void threadstorage_init ( void  )