124#define SLA_CONFIG_FILE "sla.conf"
125#define MAX_CONFNUM 80
346 const char *
hold =
"Unknown";
348 switch (hold_access) {
368 e->
command =
"sla show trunks";
370 "Usage: sla show trunks\n"
371 " This will list all trunks defined in sla.conf\n";
378 "=============================================================\n"
379 "=== Configured SLA Trunks ===================================\n"
380 "=============================================================\n"
385 char ring_timeout[23] =
"(none)";
390 snprintf(ring_timeout,
sizeof(ring_timeout),
"%u Seconds", trunk->
ring_timeout);
393 ast_cli(
a->fd,
"=== ---------------------------------------------------------\n"
394 "=== Trunk Name: %s\n"
395 "=== ==> Device: %s\n"
396 "=== ==> AutoContext: %s\n"
397 "=== ==> RingTimeout: %s\n"
398 "=== ==> BargeAllowed: %s\n"
399 "=== ==> HoldAccess: %s\n"
400 "=== ==> Stations ...\n",
408 ast_cli(
a->fd,
"=== ==> Station name: %s\n", station_ref->
station->name);
411 ast_cli(
a->fd,
"=== ---------------------------------------------------------\n===\n");
416 ast_cli(
a->fd,
"=============================================================\n\n");
423#define S(e) case e: return # e;
431 return "Uknown State";
442 e->
command =
"sla show stations";
444 "Usage: sla show stations\n"
445 " This will list all stations defined in sla.conf\n";
452 "=============================================================\n"
453 "=== Configured SLA Stations =================================\n"
454 "=============================================================\n"
470 ast_cli(
a->fd,
"=== ---------------------------------------------------------\n"
471 "=== Station Name: %s\n"
472 "=== ==> Device: %s\n"
473 "=== ==> AutoContext: %s\n"
474 "=== ==> RingTimeout: %s\n"
475 "=== ==> RingDelay: %s\n"
476 "=== ==> HoldAccess: %s\n"
477 "=== ==> Trunks ...\n",
478 station->name, station->device,
479 S_OR(station->autocontext,
"(none)"),
494 ast_cli(
a->fd,
"=== ==> Trunk Name: %s\n"
495 "=== ==> State: %s\n"
496 "=== ==> RingTimeout: %s\n"
497 "=== ==> RingDelay: %s\n",
502 ast_cli(
a->fd,
"=== ---------------------------------------------------------\n"
508 ast_cli(
a->fd,
"============================================================\n"
579 if (trunk_ref->
chan == chan && !strcmp(trunk_ref->
trunk->
name, trunk_name)) {
594 ast_debug(1,
"Trunk not found for event!\n");
625 data = datastore->
data;
668 .disable_inheritance = 1,
691 if (!
data->confname ||
data->framehook_id < 0) {
769 ast_debug(2,
"Barge disabled, trunk not available\n");
772 ast_debug(2,
"Private hold by another station\n");
817 if (!(ringing_station =
ast_calloc(1,
sizeof(*ringing_station)))) {
825 return ringing_station;
830 if (ringing_station->
station) {
842 if (!(failed_station =
ast_calloc(1,
sizeof(*failed_station)))) {
850 return failed_station;
891 if (trunk_ref->
trunk != trunk || (inactive_only ? trunk_ref->
chan : 0) || trunk_ref == exclude) {
919 char confbridge_args[256];
922 snprintf(confbridge_args,
sizeof(confbridge_args),
"%s", confname);
954 char confkick_args[256];
956 snprintf(confkick_args,
sizeof(confkick_args),
"%s,all", confname);
957 ast_debug(2,
"Kicking all participants from conference %s\n", confname);
1053 if (ringing_trunk->
trunk == trunk_ref->
trunk) {
1107 if (s_trunk_ref->
trunk != ringing_trunk->
trunk) {
1123 *trunk_ref = s_trunk_ref;
1130 if (ringing_trunk) {
1135 return ringing_trunk;
1147 pthread_t dont_care;
1166 if (!ringing_trunk) {
1172 ast_debug(1,
"Found no ringing trunk for station '%s' to answer!\n", ringing_station->
station->name);
1188 args.trunk_ref = s_trunk_ref;
1265 char *tech, *tech_data;
1269 int caller_is_saved;
1278 tech =
strsep(&tech_data,
"/");
1286 caller_is_saved = 0;
1287 if (!
sla.attempt_callerid) {
1288 caller_is_saved = 1;
1296 if (caller_is_saved) {
1329 if (trunk_ref->
chan) {
1360 unsigned int delay = UINT_MAX;
1361 int time_left, time_elapsed;
1363 if (!ringing_trunk) {
1369 if (!ringing_trunk || !trunk_ref) {
1376 delay = trunk_ref->ring_delay;
1385 time_left = (delay * 1000) - time_elapsed;
1428 if (time_left != INT_MAX && time_left > 0) {
1449 if (trunk_ref->
trunk == ringing_trunk->
trunk) {
1454 if (ringing_trunk) {
1486 if (
event->trunk_ref->trunk->active_stations == 1) {
1489 event->trunk_ref->trunk->on_hold = 1;
1494 event->trunk_ref->chan =
NULL;
1507 int time_left, time_elapsed;
1513 if (time_left <= 0) {
1520 if (time_left < *timeout) {
1521 *timeout = time_left;
1540 unsigned int ring_timeout = 0;
1541 int time_elapsed, time_left = INT_MAX, final_trunk_time_left = INT_MIN;
1549 int trunk_time_elapsed, trunk_time_left;
1552 if (ringing_trunk->
trunk == trunk_ref->
trunk) {
1556 if (!ringing_trunk) {
1579 trunk_time_left = (trunk_ref->
ring_timeout * 1000) - trunk_time_elapsed;
1580 if (trunk_time_left > final_trunk_time_left) {
1581 final_trunk_time_left = trunk_time_left;
1594 time_left = (ring_timeout * 1000) - time_elapsed;
1599 if (final_trunk_time_left > INT_MIN && final_trunk_time_left < time_left) {
1600 time_left = final_trunk_time_left;
1604 if (time_left <= 0) {
1613 if (time_left < *timeout) {
1614 *timeout = time_left;
1658 if (time_left <= 0) {
1663 if (time_left < *timeout) {
1664 *timeout = time_left;
1676 unsigned int timeout = UINT_MAX;
1677 struct timeval wait;
1678 unsigned int change_made = 0;
1701 if (timeout == UINT_MAX) {
1707 ts->tv_sec = wait.tv_sec;
1708 ts->tv_nsec = wait.tv_usec * 1000;
1716 if (
event->trunk_ref) {
1718 event->trunk_ref =
NULL;
1721 if (
event->station) {
1723 event->station =
NULL;
1738 struct timespec ts = { 0, };
1739 unsigned int have_timeout = 0;
1758 switch (
event->type) {
1798 char *tech, *tech_data;
1804 int caller_is_saved;
1807 int current_state = 0;
1816 tech_data =
ast_strdupa(trunk_ref->trunk->device);
1817 tech =
strsep(&tech_data,
"/");
1827 caller_is_saved = 0;
1828 if (!
sla.attempt_callerid) {
1829 caller_is_saved = 1;
1837 if (caller_is_saved) {
1852 unsigned int done = 0;
1887 ast_debug(3,
"Originating station device %s no longer active\n", station->device);
1888 trunk_ref->trunk->chan =
NULL;
1893 if (current_state != last_state) {
1896 last_state = current_state;
1900 if (!trunk_ref->trunk->chan) {
1909 snprintf(conf_name,
sizeof(conf_name),
"SLA_%s", trunk_ref->trunk->name);
1916 ast_debug(2,
"Trunk dial %s joining conference %s\n", trunk_ref->trunk->name, conf_name);
1917 conf_run(trunk_ref->trunk->chan, conf_name, &conf_flags,
NULL);
1922 trunk_ref->trunk->chan =
NULL;
1923 trunk_ref->trunk->on_hold = 0;
1951 char *station_name, *trunk_name;
1964 station_name =
strsep(&trunk_name,
"_");
1992 ast_log(
LOG_NOTICE,
"Can't join existing call on trunk '%s' due to access controls.\n", trunk_name);
2010 if (ringing_trunk->
trunk == trunk_ref->trunk) {
2018 if (ringing_trunk) {
2030 trunk_ref->chan = chan;
2032 if (!trunk_ref->trunk->chan) {
2035 pthread_t dont_care;
2080 ast_debug(2,
"Station %s joining conference %s\n",
station->name, conf_name);
2100 if (trunk_ref->
trunk) {
2124 if (!(ringing_trunk =
ast_calloc(1,
sizeof(*ringing_trunk)))) {
2140 return ringing_trunk;
2145 if (ringing_trunk->
trunk) {
2168 ast_log(
LOG_ERROR,
"The SLATrunk application requires an argument, the trunk name\n");
2174 if (
args.argc == 2) {
2202 snprintf(conf_name,
sizeof(conf_name),
"SLA_%s",
args.trunk_name);
2212 ast_debug(2,
"Trunk %s joining conference %s\n",
args.trunk_name, conf_name);
2213 conf_run(chan, conf_name, &conf_flags, opts);
2226 if (ringing_trunk->
trunk == trunk) {
2233 if (ringing_trunk) {
2246 char *
buf, *station_name, *trunk_name;
2252 station_name =
strsep(&trunk_name,
"_");
2258 if (!strcasecmp(trunk_name, trunk_ref->
trunk->
name)) {
2267 ast_log(
LOG_ERROR,
"Could not determine state for trunk %s on station %s!\n", trunk_name, station_name);
2301 ast_debug(1,
"sla_station destructor for '%s'\n", station->name);
2309 snprintf(exten,
sizeof(exten),
"%s_%s", station->name, trunk_ref->
trunk->
name);
2310 snprintf(hint,
sizeof(hint),
"SLA:%s", exten);
2323 struct sla_trunk *trunk = obj, *trunk2 = arg;
2330 struct sla_station *station = obj, *station2 = arg;
2342 pthread_join(
sla.thread,
NULL);
2363 char *tech, *tech_data;
2366 tech =
strsep(&tech_data,
"/");
2379 ast_debug(1,
"sla_trunk destructor for '%s'\n", trunk->
name);
2395 int existing_trunk = 0;
2403 ast_log(
LOG_ERROR,
"SLA Trunk '%s' defined with invalid device '%s'!\n", cat, dev);
2424 if (!strcasecmp(
var->name,
"autocontext")) {
2426 }
else if (!strcasecmp(
var->name,
"ringtimeout")) {
2427 if (sscanf(
var->value,
"%30u", &trunk->ring_timeout) != 1) {
2428 ast_log(
LOG_WARNING,
"Invalid ringtimeout '%s' specified for trunk '%s'\n",
var->value, trunk->name);
2429 trunk->ring_timeout = 0;
2431 }
else if (!strcasecmp(
var->name,
"barge")) {
2433 }
else if (!strcasecmp(
var->name,
"hold")) {
2434 if (!strcasecmp(
var->value,
"private")) {
2436 }
else if (!strcasecmp(
var->value,
"open")) {
2441 }
else if (strcasecmp(
var->name,
"type") && strcasecmp(
var->name,
"device")) {
2450 ast_log(
LOG_ERROR,
"Failed to automatically find or create context '%s' for SLA!\n", trunk->autocontext);
2456 ast_log(
LOG_ERROR,
"Failed to automatically create extension for trunk '%s'!\n", trunk->name);
2461 if (!existing_trunk) {
2477 char *trunk_name, *
options, *cur;
2478 int existing_trunk_ref = 0;
2479 int existing_station_ref = 0;
2491 if (trunk_ref->
trunk == trunk) {
2492 trunk_ref->
mark = 0;
2493 existing_trunk_ref = 1;
2507 if (!strcasecmp(
name,
"ringtimeout")) {
2512 }
else if (!strcasecmp(
name,
"ringdelay")) {
2524 station_ref->
mark = 0;
2525 existing_station_ref = 1;
2531 if (!existing_trunk_ref) {
2534 trunk_ref->
mark = 1;
2539 if (!existing_station_ref) {
2546 if (!existing_trunk_ref) {
2558 int existing_station = 0;
2567 existing_station = 1;
2582 if (!strcasecmp(
var->name,
"trunk")) {
2586 }
else if (!strcasecmp(
var->name,
"autocontext")) {
2588 }
else if (!strcasecmp(
var->name,
"ringtimeout")) {
2589 if (sscanf(
var->value,
"%30u", &station->ring_timeout) != 1) {
2590 ast_log(
LOG_WARNING,
"Invalid ringtimeout '%s' specified for station '%s'\n",
var->value, station->name);
2591 station->ring_timeout = 0;
2593 }
else if (!strcasecmp(
var->name,
"ringdelay")) {
2594 if (sscanf(
var->value,
"%30u", &station->ring_delay) != 1) {
2595 ast_log(
LOG_WARNING,
"Invalid ringdelay '%s' specified for station '%s'\n",
var->value, station->name);
2596 station->ring_delay = 0;
2598 }
else if (!strcasecmp(
var->name,
"hold")) {
2599 if (!strcasecmp(
var->value,
"private")) {
2601 }
else if (!strcasecmp(
var->value,
"open")) {
2606 }
else if (strcasecmp(
var->name,
"type") && strcasecmp(
var->name,
"device")) {
2617 ast_log(
LOG_ERROR,
"Failed to automatically find or create context '%s' for SLA!\n", station->autocontext);
2624 ast_log(
LOG_ERROR,
"Failed to automatically create extension for trunk '%s'!\n", station->name);
2630 snprintf(exten,
sizeof(exten),
"%s_%s", station->name, trunk_ref->
trunk->
name);
2631 snprintf(hint,
sizeof(hint),
"SLA:%s", exten);
2636 ast_log(
LOG_ERROR,
"Failed to automatically create extension for trunk '%s'!\n", station->name);
2643 ast_log(
LOG_ERROR,
"Failed to automatically create hint for trunk '%s'!\n", station->name);
2649 if (!existing_station) {
2666 station_ref->
mark = 1;
2684 trunk_ref->
mark = 1;
2706 if (!station_ref->
mark) {
2726 if (station->
mark) {
2734 if (!trunk_ref->
mark) {
2757 const char *cat =
NULL;
2788 if (!strcasecmp(cat,
"general")) {
2795 if (!strcasecmp(
type,
"trunk")) {
2797 }
else if (!strcasecmp(
type,
"station")) {
@ SLA_TRUNK_STATE_RINGING
@ SLA_TRUNK_STATE_ONHOLD_BYME
static int sla_load_config(int reload)
static int sla_build_station(struct ast_config *cfg, const char *cat)
static int sla_trunk_is_marked(void *obj, void *arg, int flags)
static const char *const slatrunk_app
static struct ast_cli_entry cli_sla[]
static int sla_build_trunk(struct ast_config *cfg, const char *cat)
static int sla_calc_station_delays(unsigned int *timeout)
Calculate the ring delay for a station.
static int sla_station_mark(void *obj, void *arg, int flags)
static int sla_check_failed_station(const struct sla_station *station)
Check to see if this station has failed to be dialed in the past minute.
static int sla_framehook_consume(void *data, enum ast_frame_type type)
Callback function which informs upstream if we are consuming a frame of a specific type.
static struct sla_trunk_ref * sla_choose_idle_trunk(const struct sla_station *station)
For a given station, choose the highest priority idle trunk.
static int sla_check_device(const char *device)
static int sla_ring_station(struct sla_ringing_trunk *ringing_trunk, struct sla_station *station)
Ring a station.
static void sla_trunk_ref_destructor(void *obj)
static int sla_station_is_marked(void *obj, void *arg, int flags)
static int sla_check_inuse_station(const struct sla_station *station)
Check to see if a station is in use.
static int sla_trunk_release_refs(void *obj, void *arg, int flags)
static struct sla_ringing_trunk * sla_choose_ringing_trunk(struct sla_station *station, struct sla_trunk_ref **trunk_ref, int rm)
Choose the highest priority ringing trunk for a station.
static struct sla_ringing_trunk * queue_ringing_trunk(struct sla_trunk *trunk)
static void sla_queue_event_full(enum sla_event_type type, struct sla_trunk_ref *trunk_ref, struct sla_station *station, int lock)
static void sla_queue_event_nolock(enum sla_event_type type)
static void sla_dial_state_callback(struct ast_dial *dial)
static const struct ast_app_option sla_trunk_opts[128]
static void sla_stop_ringing_trunk(struct sla_ringing_trunk *ringing_trunk)
static struct ao2_container * sla_stations
static struct @66 sla
A structure for data used by the sla thread.
static void sla_failed_station_destroy(struct sla_failed_station *failed_station)
static struct sla_ringing_station * sla_create_ringing_station(struct sla_station *station)
static const char *const slastation_app
static void sla_station_ref_destructor(void *obj)
sla_event_type
Event types that can be queued up for the SLA thread.
@ SLA_EVENT_RINGING_TRUNK
static void sla_change_trunk_state(const struct sla_trunk *trunk, enum sla_trunk_state state, enum sla_which_trunk_refs inactive_only, const struct sla_trunk_ref *exclude)
static void sla_add_trunk_to_station(struct sla_station *station, struct ast_variable *var)
static int sla_trunk_cmp(void *obj, void *arg, int flags)
static void sla_handle_ringing_trunk_event(void)
static struct sla_station_ref * sla_create_station_ref(struct sla_station *station)
static int conf_kick_all(struct ast_channel *chan, const char *confname)
static struct ast_frame * sla_framehook(struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data)
static void answer_trunk_chan(struct ast_channel *chan)
static void sla_handle_dial_state_event(void)
static struct sla_trunk_ref * sla_find_trunk_ref_byname(const struct sla_station *station, const char *name)
Find a trunk reference on a station by name.
static void sla_stop_ringing_station(struct sla_ringing_station *ringing_station, enum sla_station_hangup hangup)
static void * run_station(void *data)
static int sla_station_release_refs(void *obj, void *arg, int flags)
static int remove_framehook(struct ast_channel *chan)
@ SLA_TRUNK_OPT_ARG_MOH_CLASS
@ SLA_TRUNK_OPT_ARG_ARRAY_SIZE
static struct sla_trunk_ref * create_trunk_ref(struct sla_trunk *trunk)
static struct sla_trunk * sla_find_trunk(const char *name)
struct @66::@75 ringing_trunks
static int sla_trunk_exec(struct ast_channel *chan, const char *data)
struct @66::@76 ringing_stations
unsigned int attempt_callerid
static void sla_ringing_trunk_destroy(struct sla_ringing_trunk *ringing_trunk)
static void sla_trunk_destructor(void *obj)
static const char * sla_hold_str(unsigned int hold_access)
static void sla_ring_stations(void)
Ring stations based on current set of ringing trunks.
static void sla_queue_event(enum sla_event_type type)
static enum ast_device_state sla_state(const char *data)
static void * dial_trunk(void *data)
static char * sla_show_stations(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static enum ast_device_state sla_state_to_devstate(enum sla_trunk_state state)
static void sla_event_destroy(struct sla_event *event)
static struct sla_trunk_ref * sla_find_trunk_ref(const struct sla_station *station, const struct sla_trunk *trunk)
static void sla_destroy(void)
static int conf_run(struct ast_channel *chan, const char *confname, struct ast_flags *confflags, char *optargs[])
static int sla_station_exec(struct ast_channel *chan, const char *data)
static int sla_check_station_delay(struct sla_station *station, struct sla_ringing_trunk *ringing_trunk)
Calculate the ring delay for a given ringing trunk on a station.
static void sla_handle_hold_event(struct sla_event *event)
static int load_module(void)
Load the module.
static int attach_framehook(struct ast_channel *chan, const char *confname)
static void sla_ringing_station_destroy(struct sla_ringing_station *ringing_station)
static int sla_trunk_mark(void *obj, void *arg, int flags)
static int sla_calc_trunk_timeouts(unsigned int *timeout)
Process trunk ring timeouts.
static int unload_module(void)
static int load_config(int reload)
static int sla_check_station_hold_access(const struct sla_trunk *trunk, const struct sla_station *station)
static int sla_in_use(void)
static struct sla_station * sla_find_station(const char *name)
static void sla_hangup_stations(void)
static struct ao2_container * sla_trunks
static void sla_queue_event_conf(enum sla_event_type type, struct ast_channel *chan, const char *confname)
Queue a SLA event from the conference.
static int sla_check_timed_out_station(const struct sla_ringing_trunk *ringing_trunk, const struct sla_station *station)
Check to see if dialing this station already timed out for this ringing trunk.
static int sla_check_ringing_station(const struct sla_station *station)
Check to see if this station is already ringing.
static int sla_process_timers(struct timespec *ts)
Calculate the time until the next known event.
static const char * trunkstate2str(enum sla_trunk_state state)
static void sla_station_destructor(void *obj)
static int sla_station_cmp(void *obj, void *arg, int flags)
@ SLA_STATION_HANGUP_NORMAL
@ SLA_STATION_HANGUP_TIMEOUT
static const char sla_registrar[]
static const struct ast_datastore_info sla_framehook_datastore
struct @66::@77 failed_stations
static void * sla_thread(void *data)
static int sla_calc_station_timeouts(unsigned int *timeout)
Process station ring timeouts.
static char * sla_show_trunks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct sla_failed_station * sla_create_failed_station(struct sla_station *station)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define ao2_alloc(data_size, destructor_fn)
static void hold(struct ast_channel *chan)
Helper method to place a channel in a bridge on hold.
Internal Asterisk hangup causes.
static int hangup(void *data)
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
#define AST_MAX_EXTENSION
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
int ast_devstate_prov_del(const char *label)
Remove device state provider.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
Add device state provider.
ast_device_state
Device States.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
ast_dial_result
List of return codes for dial run API calls.
@ AST_DIAL_RESULT_INVALID
@ AST_DIAL_RESULT_ANSWERED
@ AST_DIAL_RESULT_TIMEOUT
@ AST_DIAL_RESULT_PROGRESS
@ AST_DIAL_RESULT_RINGING
@ AST_DIAL_RESULT_PROCEEDING
@ AST_DIAL_RESULT_UNANSWERED
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
struct ast_dial * ast_dial_create(void)
New dialing structure.
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
@ AST_FRAMEHOOK_EVENT_WRITE
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
#define AST_FRAMEHOOK_INTERFACE_VERSION
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
char * strsep(char **str, const char *delims)
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
@ CONFIG_FLAG_FILEUNCHANGED
ast_frame_type
Frame types.
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define AST_PTHREADT_NULL
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
int ast_atomic_dec_and_test(volatile int *p)
decrement *p by 1 and return true if the variable has reached 0.
#define ast_cond_signal(cond)
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_DEVSTATE_PROVIDER
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
int ast_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Main Channel structure associated with a channel.
descriptor for a cli entry.
Structure for a data store type.
Structure for a data store object.
Main dialing structure. Contains global options, channels being dialed, and more!
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
Structure for mutex and tracking information.
Caller Party information.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct sla_station * station
struct sla_trunk_ref * trunk_ref
struct sla_station * station
struct sla_trunk_ref * trunk_ref
struct sla_station * station
struct sla_event::@70 entry
struct sla_trunk_ref * trunk_ref
A station that failed to be dialed.
struct sla_station * station
struct sla_failed_station::@71 entry
Framehook to support HOLD within the conference.
A station that is ringing.
struct sla_station * station
struct timeval ring_begin
struct sla_ringing_station::@74 entry
struct sla_ringing_trunk::@72 timed_out_stations
struct timeval ring_begin
struct sla_ringing_trunk::@73 entry
A reference to a station.
struct sla_station * station
struct sla_station_ref::@67 entry
unsigned int ring_timeout
A station's reference to a trunk.
unsigned int ring_timeout
enum sla_trunk_state state
struct ast_channel * chan
struct sla_trunk_ref::@69 entry
unsigned int num_stations
unsigned int ring_timeout
const ast_string_field autocontext
unsigned int hold_stations
unsigned int barge_disabled
struct ast_channel * chan
unsigned int active_stations
const ast_string_field device
struct sla_trunk::@68 stations
const ast_string_field name
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_pthread_create(a, b, c, d)
#define ast_pthread_create_detached_background(a, b, c, d)
#define ast_set_flag(p, flag)