130#define SLA_CONFIG_FILE     "sla.conf" 
  131#define MAX_CONFNUM 80 
  352    const char *
hold = 
"Unknown";
 
  354    switch (hold_access) {
 
 
  374        e->
command = 
"sla show trunks";
 
  376            "Usage: sla show trunks\n" 
  377            "       This will list all trunks defined in sla.conf\n";
 
  384                "=============================================================\n" 
  385                "=== Configured SLA Trunks ===================================\n" 
  386                "=============================================================\n" 
  391        char ring_timeout[23] = 
"(none)";
 
  396            snprintf(ring_timeout, 
sizeof(ring_timeout), 
"%u Seconds", trunk->
ring_timeout);
 
  399        ast_cli(
a->fd, 
"=== ---------------------------------------------------------\n" 
  400                    "=== Trunk Name:       %s\n" 
  401                    "=== ==> Device:       %s\n" 
  402                    "=== ==> AutoContext:  %s\n" 
  403                    "=== ==> RingTimeout:  %s\n" 
  404                    "=== ==> BargeAllowed: %s\n" 
  405                    "=== ==> HoldAccess:   %s\n" 
  406                    "=== ==> Stations ...\n",
 
  417        ast_cli(
a->fd, 
"=== ---------------------------------------------------------\n===\n");
 
  422    ast_cli(
a->fd, 
"=============================================================\n\n");
 
 
  429#define S(e) case e: return # e; 
  437    return "Unknown State";
 
 
  448        e->
command = 
"sla show stations";
 
  450            "Usage: sla show stations\n" 
  451            "       This will list all stations defined in sla.conf\n";
 
  458                "=============================================================\n" 
  459                "=== Configured SLA Stations =================================\n" 
  460                "=============================================================\n" 
  476        ast_cli(
a->fd, 
"=== ---------------------------------------------------------\n" 
  477                    "=== Station Name:    %s\n" 
  478                    "=== ==> Device:      %s\n" 
  479                    "=== ==> AutoContext: %s\n" 
  480                    "=== ==> RingTimeout: %s\n" 
  481                    "=== ==> RingDelay:   %s\n" 
  482                    "=== ==> HoldAccess:  %s\n" 
  483                    "=== ==> Trunks ...\n",
 
  500            ast_cli(
a->fd, 
"===    ==> Trunk Name: %s\n" 
  501                "===       ==> State:       %s\n" 
  502                "===       ==> RingTimeout: %s\n" 
  503                "===       ==> RingDelay:   %s\n",
 
  508        ast_cli(
a->fd, 
"=== ---------------------------------------------------------\n" 
  514    ast_cli(
a->fd, 
"============================================================\n" 
 
  585            if (trunk_ref->
chan == chan && !strcmp(trunk_ref->
trunk->
name, trunk_name)) {
 
  600        ast_debug(1, 
"Trunk not found for event!\n");
 
 
  631    data = datastore->
data;
 
 
  674        .disable_inheritance = 1,
 
  697    if (!
data->confname || 
data->framehook_id < 0) {
 
 
  775            ast_debug(2, 
"Barge disabled, trunk not available\n");
 
  778            ast_debug(2, 
"Private hold by another station\n");
 
 
  823    if (!(ringing_station = 
ast_calloc(1, 
sizeof(*ringing_station)))) {
 
  831    return ringing_station;
 
 
  836    if (ringing_station->
station) {
 
 
  848    if (!(failed_station = 
ast_calloc(1, 
sizeof(*failed_station)))) {
 
  856    return failed_station;
 
 
  897            if (trunk_ref->
trunk != trunk || (inactive_only ? trunk_ref->
chan : 0) || trunk_ref == exclude) {
 
 
  925    char confbridge_args[256];
 
  928    snprintf(confbridge_args, 
sizeof(confbridge_args), 
"%s", confname);
 
 
  960    char confkick_args[256];
 
  962    snprintf(confkick_args, 
sizeof(confkick_args), 
"%s,all", confname);
 
  963    ast_debug(2, 
"Kicking all participants from conference %s\n", confname);
 
 
 1059            if (ringing_trunk->
trunk == trunk_ref->
trunk) {
 
 
 1113            if (s_trunk_ref->
trunk != ringing_trunk->
trunk) {
 
 1129                *trunk_ref = s_trunk_ref;
 
 1136        if (ringing_trunk) {
 
 1141    return ringing_trunk;
 
 
 1153        pthread_t dont_care;
 
 1172            if (!ringing_trunk) {
 
 1178                ast_debug(1, 
"Found no ringing trunk for station '%s' to answer!\n", ringing_station->
station->
name);
 
 1194            args.trunk_ref = s_trunk_ref;
 
 
 1271    char *tech, *tech_data;
 
 1275    int caller_is_saved;
 
 1284    tech = 
strsep(&tech_data, 
"/");
 
 1292    caller_is_saved = 0;
 
 1293    if (!
sla.attempt_callerid) {
 
 1294        caller_is_saved = 1;
 
 1302    if (caller_is_saved) {
 
 
 1335        if (trunk_ref->
chan) {
 
 
 1366    unsigned int delay = UINT_MAX;
 
 1367    int time_left, time_elapsed;
 
 1369    if (!ringing_trunk) {
 
 1375    if (!ringing_trunk || !trunk_ref) {
 
 1382    delay = trunk_ref->ring_delay;
 
 1391    time_left = (delay * 1000) - time_elapsed;
 
 
 1434            if (time_left != INT_MAX && time_left > 0) {
 
 
 1455                if (trunk_ref->
trunk == ringing_trunk->
trunk) {
 
 1460            if (ringing_trunk) {
 
 
 1492    if (
event->trunk_ref->trunk->active_stations == 1) {
 
 1495        event->trunk_ref->trunk->on_hold = 1;
 
 1500    event->trunk_ref->chan = 
NULL;
 
 
 1513        int time_left, time_elapsed;
 
 1519        if (time_left <= 0) {
 
 1526        if (time_left < *timeout) {
 
 1527            *timeout = time_left;
 
 
 1546        unsigned int ring_timeout = 0;
 
 1547        int time_elapsed, time_left = INT_MAX, final_trunk_time_left = INT_MIN;
 
 1555            int trunk_time_elapsed, trunk_time_left;
 
 1558                if (ringing_trunk->
trunk == trunk_ref->
trunk) {
 
 1562            if (!ringing_trunk) {
 
 1585            trunk_time_left = (trunk_ref->
ring_timeout * 1000) - trunk_time_elapsed;
 
 1586            if (trunk_time_left > final_trunk_time_left) {
 
 1587                final_trunk_time_left = trunk_time_left;
 
 1600            time_left = (ring_timeout * 1000) - time_elapsed;
 
 1605        if (final_trunk_time_left > INT_MIN && final_trunk_time_left < time_left) {
 
 1606            time_left = final_trunk_time_left;
 
 1610        if (time_left <= 0) {
 
 1619        if (time_left < *timeout) {
 
 1620            *timeout = time_left;
 
 
 1664        if (time_left <= 0) {
 
 1669        if (time_left < *timeout) {
 
 1670            *timeout = time_left;
 
 
 1682    unsigned int timeout = UINT_MAX;
 
 1683    struct timeval wait;
 
 1684    unsigned int change_made = 0;
 
 1707    if (timeout == UINT_MAX) {
 
 1713        ts->tv_sec = wait.tv_sec;
 
 1714        ts->tv_nsec = wait.tv_usec * 1000;
 
 
 1722    if (
event->trunk_ref) {
 
 1724        event->trunk_ref = 
NULL;
 
 1727    if (
event->station) {
 
 1729        event->station = 
NULL;
 
 
 1744        struct timespec ts = { 0, };
 
 1745        unsigned int have_timeout = 0;
 
 1764            switch (
event->type) {
 
 
 1804    char *tech, *tech_data;
 
 1810    int caller_is_saved;
 
 1813    int current_state = 0;
 
 1822    tech_data = 
ast_strdupa(trunk_ref->trunk->device);
 
 1823    tech = 
strsep(&tech_data, 
"/");
 
 1833    caller_is_saved = 0;
 
 1834    if (!
sla.attempt_callerid) {
 
 1835        caller_is_saved = 1;
 
 1843    if (caller_is_saved) {
 
 1858        unsigned int done = 0;
 
 1893            ast_debug(3, 
"Originating station device %s no longer active\n", station->device);
 
 1894            trunk_ref->trunk->chan = 
NULL;
 
 1899        if (current_state != last_state) {
 
 1902            last_state = current_state;
 
 1906    if (!trunk_ref->trunk->chan) {
 
 1915    snprintf(conf_name, 
sizeof(conf_name), 
"SLA_%s", trunk_ref->trunk->name);
 
 1922    ast_debug(2, 
"Trunk dial %s joining conference %s\n", trunk_ref->trunk->name, conf_name);
 
 1923    conf_run(trunk_ref->trunk->chan, conf_name, &conf_flags, 
NULL);
 
 1928    trunk_ref->trunk->chan = 
NULL;
 
 1929    trunk_ref->trunk->on_hold = 0;
 
 
 1957    char *station_name, *trunk_name;
 
 1970    station_name = 
strsep(&trunk_name, 
"_");
 
 1998            ast_log(
LOG_NOTICE, 
"Can't join existing call on trunk '%s' due to access controls.\n", trunk_name);
 
 2016            if (ringing_trunk->
trunk == trunk_ref->trunk) {
 
 2024        if (ringing_trunk) {
 
 2036    trunk_ref->chan = chan;
 
 2038    if (!trunk_ref->trunk->chan) {
 
 2041        pthread_t dont_care;
 
 
 2106    if (trunk_ref->
trunk) {
 
 
 2130    if (!(ringing_trunk = 
ast_calloc(1, 
sizeof(*ringing_trunk)))) {
 
 2146    return ringing_trunk;
 
 
 2151    if (ringing_trunk->
trunk) {
 
 
 2174        ast_log(
LOG_ERROR, 
"The SLATrunk application requires an argument, the trunk name\n");
 
 2180    if (
args.argc == 2) {
 
 2208    snprintf(conf_name, 
sizeof(conf_name), 
"SLA_%s", 
args.trunk_name);
 
 2218    ast_debug(2, 
"Trunk %s joining conference %s\n", 
args.trunk_name, conf_name);
 
 2219    conf_run(chan, conf_name, &conf_flags, opts);
 
 2232        if (ringing_trunk->
trunk == trunk) {
 
 2239    if (ringing_trunk) {
 
 
 2252    char *
buf, *station_name, *trunk_name;
 
 2258    station_name = 
strsep(&trunk_name, 
"_");
 
 2264            if (!strcasecmp(trunk_name, trunk_ref->
trunk->
name)) {
 
 2273        ast_log(
LOG_ERROR, 
"Could not determine state for trunk %s on station %s!\n", trunk_name, station_name);
 
 
 2307    ast_debug(1, 
"sla_station destructor for '%s'\n", station->
name);
 
 2315            snprintf(exten, 
sizeof(exten), 
"%s_%s", station->
name, trunk_ref->
trunk->
name);
 
 2316            snprintf(hint, 
sizeof(hint), 
"SLA:%s", exten);
 
 
 2329    struct sla_trunk *trunk = obj, *trunk2 = arg;
 
 
 2336    struct sla_station *station = obj, *station2 = arg;
 
 
 2348        pthread_join(
sla.thread, 
NULL);
 
 
 2369    char *tech, *tech_data;
 
 2372    tech = 
strsep(&tech_data, 
"/");
 
 
 2385    ast_debug(1, 
"sla_trunk destructor for '%s'\n", trunk->
name);
 
 
 2401    int existing_trunk = 0;
 
 2409        ast_log(
LOG_ERROR, 
"SLA Trunk '%s' defined with invalid device '%s'!\n", cat, dev);
 
 2430        if (!strcasecmp(
var->name, 
"autocontext")) {
 
 2432        } 
else if (!strcasecmp(
var->name, 
"ringtimeout")) {
 
 2433            if (sscanf(
var->value, 
"%30u", &trunk->ring_timeout) != 1) {
 
 2434                ast_log(
LOG_WARNING, 
"Invalid ringtimeout '%s' specified for trunk '%s'\n", 
var->value, trunk->name);
 
 2435                trunk->ring_timeout = 0;
 
 2437        } 
else if (!strcasecmp(
var->name, 
"barge")) {
 
 2439        } 
else if (!strcasecmp(
var->name, 
"hold")) {
 
 2440            if (!strcasecmp(
var->value, 
"private")) {
 
 2442            } 
else if (!strcasecmp(
var->value, 
"open")) {
 
 2447        } 
else if (strcasecmp(
var->name, 
"type") && strcasecmp(
var->name, 
"device")) {
 
 2456            ast_log(
LOG_ERROR, 
"Failed to automatically find or create context '%s' for SLA!\n", trunk->autocontext);
 
 2462            ast_log(
LOG_ERROR, 
"Failed to automatically create extension for trunk '%s'!\n", trunk->name);
 
 2467    if (!existing_trunk) {
 
 
 2483    char *trunk_name, *
options, *cur;
 
 2484    int existing_trunk_ref = 0;
 
 2485    int existing_station_ref = 0;
 
 2497        if (trunk_ref->
trunk == trunk) {
 
 2498            trunk_ref->
mark = 0;
 
 2499            existing_trunk_ref = 1;
 
 2513        if (!strcasecmp(
name, 
"ringtimeout")) {
 
 2518        } 
else if (!strcasecmp(
name, 
"ringdelay")) {
 
 2530            station_ref->
mark = 0;
 
 2531            existing_station_ref = 1;
 
 2537        if (!existing_trunk_ref) {
 
 2540            trunk_ref->
mark = 1;
 
 2545    if (!existing_station_ref) {
 
 2552    if (!existing_trunk_ref) {
 
 
 2564    int existing_station = 0;
 
 2573        existing_station = 1;
 
 2588        if (!strcasecmp(
var->name, 
"trunk")) {
 
 2592        } 
else if (!strcasecmp(
var->name, 
"autocontext")) {
 
 2594        } 
else if (!strcasecmp(
var->name, 
"ringtimeout")) {
 
 2595            if (sscanf(
var->value, 
"%30u", &station->ring_timeout) != 1) {
 
 2596                ast_log(
LOG_WARNING, 
"Invalid ringtimeout '%s' specified for station '%s'\n", 
var->value, station->name);
 
 2597                station->ring_timeout = 0;
 
 2599        } 
else if (!strcasecmp(
var->name, 
"ringdelay")) {
 
 2600            if (sscanf(
var->value, 
"%30u", &station->ring_delay) != 1) {
 
 2601                ast_log(
LOG_WARNING, 
"Invalid ringdelay '%s' specified for station '%s'\n", 
var->value, station->name);
 
 2602                station->ring_delay = 0;
 
 2604        } 
else if (!strcasecmp(
var->name, 
"hold")) {
 
 2605            if (!strcasecmp(
var->value, 
"private")) {
 
 2607            } 
else if (!strcasecmp(
var->value, 
"open")) {
 
 2612        } 
else if (strcasecmp(
var->name, 
"type") && strcasecmp(
var->name, 
"device")) {
 
 2623            ast_log(
LOG_ERROR, 
"Failed to automatically find or create context '%s' for SLA!\n", station->autocontext);
 
 2630            ast_log(
LOG_ERROR, 
"Failed to automatically create extension for trunk '%s'!\n", station->name);
 
 2636            snprintf(exten, 
sizeof(exten), 
"%s_%s", station->name, trunk_ref->
trunk->
name);
 
 2637            snprintf(hint, 
sizeof(hint), 
"SLA:%s", exten);
 
 2642                ast_log(
LOG_ERROR, 
"Failed to automatically create extension for trunk '%s'!\n", station->name);
 
 2649                ast_log(
LOG_ERROR, 
"Failed to automatically create hint for trunk '%s'!\n", station->name);
 
 2655    if (!existing_station) {
 
 
 2672        station_ref->
mark = 1;
 
 
 2690        trunk_ref->
mark = 1;
 
 
 2712            if (!station_ref->
mark) {
 
 
 2732    if (station->
mark) {
 
 2740            if (!trunk_ref->
mark) {
 
 
 2763    const char *cat = 
NULL;
 
 2794        if (!strcasecmp(cat, 
"general")) {
 
 2801        if (!strcasecmp(
type, 
"trunk")) {
 
 2803        } 
else if (!strcasecmp(
type, 
"station")) {
 
 
void ast_context_destroy(void)
void ast_cli_unregister_multiple(void)
static int load_config(void)
@ 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)
struct @68::@80 ringing_stations
static struct @68 sla
A structure for data used by the sla thread.
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 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)
struct @68::@79 ringing_trunks
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)
static struct sla_trunk_ref * create_trunk_ref(struct sla_trunk *trunk)
struct @68::@81 failed_stations
static struct sla_trunk * sla_find_trunk(const char *name)
static int sla_trunk_exec(struct ast_channel *chan, const char *data)
@ SLA_TRUNK_OPT_ARG_MOH_CLASS
@ SLA_TRUNK_OPT_ARG_ARRAY_SIZE
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 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
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)
char * strsep(char **str, const char *delims)
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.
#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.
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.
@ CONFIG_FLAG_FILEUNCHANGED
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)
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.
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
#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.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
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
enum ast_frame_type frametype
union ast_frame::@239 data
Structure for mutex and tracking information.
Caller Party information.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
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_trunk_ref * trunk_ref
struct sla_event::@74 entry
A station that failed to be dialed.
struct sla_station * station
struct sla_failed_station::@75 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::@78 entry
struct sla_ringing_trunk::@77 entry
struct timeval ring_begin
struct sla_ringing_trunk::@76 timed_out_stations
A reference to a station.
struct sla_station * station
struct sla_station_ref::@71 entry
struct sla_station::@69 entry
unsigned int ring_timeout
const ast_string_field autocontext
struct sla_station::@70 trunks
const ast_string_field device
const ast_string_field name
A station's reference to a trunk.
unsigned int ring_timeout
struct sla_trunk_ref::@73 entry
enum sla_trunk_state state
struct ast_channel * chan
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
struct sla_trunk::@72 stations
unsigned int active_stations
const ast_string_field device
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)