Asterisk - The Open Source Telephony Project
21.4.1
|
Shared Line Appearances. More...
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/app.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/astobj2.h"
#include "asterisk/devicestate.h"
#include "asterisk/dial.h"
#include "asterisk/causes.h"
#include "asterisk/format_compatibility.h"
Go to the source code of this file.
Data Structures | |
struct | dial_trunk_args |
struct | run_station_args |
struct | sla_event |
struct | sla_failed_station |
A station that failed to be dialed. More... | |
struct | sla_framehook_data |
Framehook to support HOLD within the conference. More... | |
struct | sla_ringing_station |
A station that is ringing. More... | |
struct | sla_ringing_trunk |
A trunk that is ringing. More... | |
struct | sla_station |
struct | sla_station_ref |
A reference to a station. More... | |
struct | sla_trunk |
struct | sla_trunk_ref |
A station's reference to a trunk. More... | |
Macros | |
#define | MAX_CONFNUM 80 |
#define | S(e) case e: return # e; |
#define | SLA_CONFIG_FILE "sla.conf" |
Enumerations | |
enum | { CONFFLAG_QUIET = (1 << 0), CONFFLAG_MOH = (1 << 1), CONFFLAG_MARKEDEXIT = (1 << 2), CONFFLAG_MARKEDUSER = (1 << 3), CONFFLAG_PASS_DTMF = (1 << 4), CONFFLAG_SLA_STATION = (1 << 5), CONFFLAG_SLA_TRUNK = (1 << 6) } |
enum | { SLA_TRUNK_OPT_MOH = (1 << 0) } |
enum | { SLA_TRUNK_OPT_ARG_MOH_CLASS = 0, SLA_TRUNK_OPT_ARG_ARRAY_SIZE = 1 } |
enum | sla_event_type { SLA_EVENT_HOLD, SLA_EVENT_DIAL_STATE, SLA_EVENT_RINGING_TRUNK } |
Event types that can be queued up for the SLA thread. More... | |
enum | sla_hold_access { SLA_HOLD_OPEN, SLA_HOLD_PRIVATE } |
enum | sla_station_hangup { SLA_STATION_HANGUP_NORMAL, SLA_STATION_HANGUP_TIMEOUT } |
enum | sla_trunk_state { SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_RINGING, SLA_TRUNK_STATE_UP, SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME } |
enum | sla_which_trunk_refs { ALL_TRUNK_REFS, INACTIVE_TRUNK_REFS } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | answer_trunk_chan (struct ast_channel *chan) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | attach_framehook (struct ast_channel *chan, const char *confname) |
static int | conf_kick_all (struct ast_channel *chan, const char *confname) |
static int | conf_run (struct ast_channel *chan, const char *confname, struct ast_flags *confflags, char *optargs[]) |
static struct sla_trunk_ref * | create_trunk_ref (struct sla_trunk *trunk) |
static void * | dial_trunk (void *data) |
static int | load_config (int reload) |
static int | load_module (void) |
Load the module. More... | |
static struct sla_ringing_trunk * | queue_ringing_trunk (struct sla_trunk *trunk) |
static int | reload (void) |
static int | remove_framehook (struct ast_channel *chan) |
static void * | run_station (void *data) |
static void | sla_add_trunk_to_station (struct sla_station *station, struct ast_variable *var) |
static int | sla_build_station (struct ast_config *cfg, const char *cat) |
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. More... | |
static int | sla_calc_station_timeouts (unsigned int *timeout) |
Process station ring timeouts. More... | |
static int | sla_calc_trunk_timeouts (unsigned int *timeout) |
Process trunk ring timeouts. More... | |
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 int | sla_check_device (const char *device) |
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. More... | |
static int | sla_check_inuse_station (const struct sla_station *station) |
Check to see if a station is in use. | |
static int | sla_check_ringing_station (const struct sla_station *station) |
Check to see if this station is already ringing. More... | |
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. More... | |
static int | sla_check_station_hold_access (const struct sla_trunk *trunk, const struct sla_station *station) |
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. More... | |
static struct sla_trunk_ref * | sla_choose_idle_trunk (const struct sla_station *station) |
For a given station, choose the highest priority idle trunk. More... | |
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. More... | |
static struct sla_failed_station * | sla_create_failed_station (struct sla_station *station) |
static struct sla_ringing_station * | sla_create_ringing_station (struct sla_station *station) |
static struct sla_station_ref * | sla_create_station_ref (struct sla_station *station) |
static void | sla_destroy (void) |
static void | sla_dial_state_callback (struct ast_dial *dial) |
static void | sla_event_destroy (struct sla_event *event) |
static void | sla_failed_station_destroy (struct sla_failed_station *failed_station) |
static struct sla_station * | sla_find_station (const char *name) |
static struct sla_trunk * | sla_find_trunk (const char *name) |
static struct sla_trunk_ref * | sla_find_trunk_ref (const struct sla_station *station, const struct sla_trunk *trunk) |
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. More... | |
static struct ast_frame * | sla_framehook (struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data) |
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 void | sla_handle_dial_state_event (void) |
static void | sla_handle_hold_event (struct sla_event *event) |
static void | sla_handle_ringing_trunk_event (void) |
static void | sla_hangup_stations (void) |
static const char * | sla_hold_str (unsigned int hold_access) |
static int | sla_in_use (void) |
static int | sla_load_config (int reload) |
static int | sla_process_timers (struct timespec *ts) |
Calculate the time until the next known event. More... | |
static void | sla_queue_event (enum sla_event_type type) |
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 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 int | sla_ring_station (struct sla_ringing_trunk *ringing_trunk, struct sla_station *station) |
Ring a station. More... | |
static void | sla_ring_stations (void) |
Ring stations based on current set of ringing trunks. More... | |
static void | sla_ringing_station_destroy (struct sla_ringing_station *ringing_station) |
static void | sla_ringing_trunk_destroy (struct sla_ringing_trunk *ringing_trunk) |
static char * | sla_show_stations (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | sla_show_trunks (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static enum ast_device_state | sla_state (const char *data) |
static enum ast_device_state | sla_state_to_devstate (enum sla_trunk_state state) |
static int | sla_station_cmp (void *obj, void *arg, int flags) |
static void | sla_station_destructor (void *obj) |
static int | sla_station_exec (struct ast_channel *chan, const char *data) |
static int | sla_station_is_marked (void *obj, void *arg, int flags) |
static int | sla_station_mark (void *obj, void *arg, int flags) |
static void | sla_station_ref_destructor (void *obj) |
static int | sla_station_release_refs (void *obj, void *arg, int flags) |
static void | sla_stop_ringing_station (struct sla_ringing_station *ringing_station, enum sla_station_hangup hangup) |
static void | sla_stop_ringing_trunk (struct sla_ringing_trunk *ringing_trunk) |
static void * | sla_thread (void *data) |
static int | sla_trunk_cmp (void *obj, void *arg, int flags) |
static void | sla_trunk_destructor (void *obj) |
static int | sla_trunk_exec (struct ast_channel *chan, const char *data) |
static int | sla_trunk_is_marked (void *obj, void *arg, int flags) |
static int | sla_trunk_mark (void *obj, void *arg, int flags) |
static void | sla_trunk_ref_destructor (void *obj) |
static int | sla_trunk_release_refs (void *obj, void *arg, int flags) |
static const char * | trunkstate2str (enum sla_trunk_state state) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Shared Line Appearances" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_DEVSTATE_PROVIDER, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_sla [] |
struct { | |
unsigned int attempt_callerid:1 | |
ast_cond_t cond | |
struct { | |
struct sla_event * first | |
struct sla_event * last | |
} event_q | |
struct { | |
struct sla_failed_station * first | |
struct sla_failed_station * last | |
} failed_stations | |
ast_mutex_t lock | |
struct { | |
struct sla_ringing_station * first | |
struct sla_ringing_station * last | |
} ringing_stations | |
struct { | |
struct sla_ringing_trunk * first | |
struct sla_ringing_trunk * last | |
} ringing_trunks | |
unsigned int stop:1 | |
pthread_t thread | |
} | sla |
A structure for data used by the sla thread. More... | |
static const struct ast_datastore_info | sla_framehook_datastore |
static const char | sla_registrar [] = "SLA" |
static struct ao2_container * | sla_stations |
static const struct ast_app_option | sla_trunk_opts [128] = { [ 'M' ] = { .flag = SLA_TRUNK_OPT_MOH , .arg_index = SLA_TRUNK_OPT_ARG_MOH_CLASS + 1 }, } |
static struct ao2_container * | sla_trunks |
static const char *const | slastation_app = "SLAStation" |
static const char *const | slatrunk_app = "SLATrunk" |
Shared Line Appearances.
Definition in file app_sla.c.
anonymous enum |
Definition at line 130 of file app_sla.c.
enum sla_event_type |
Event types that can be queued up for the SLA thread.
Enumerator | |
---|---|
SLA_EVENT_HOLD |
A station has put the call on hold |
SLA_EVENT_DIAL_STATE |
The state of a dial has changed |
SLA_EVENT_RINGING_TRUNK |
The state of a ringing trunk has changed |
enum sla_hold_access |
Definition at line 171 of file app_sla.c.
|
static |
Load the module.
Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
Definition at line 2849 of file app_sla.c.
References ast_cli_register_multiple, ast_devstate_prov_add(), and ast_register_application_xml.
|
static |
Calculate the ring delay for a station.
Definition at line 1625 of file app_sla.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_ref, sla_check_inuse_station(), sla_check_ringing_station(), sla_check_station_delay(), and sla_choose_ringing_trunk().
Referenced by sla_process_timers().
|
static |
Process station ring timeouts.
Definition at line 1533 of file app_sla.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), sla_ringing_trunk::ring_begin, sla_ringing_station::ring_begin, sla_station::ring_timeout, sla_trunk_ref::ring_timeout, and sla.
Referenced by sla_process_timers().
|
static |
Process trunk ring timeouts.
Definition at line 1501 of file app_sla.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), pbx_builtin_setvar_helper(), sla_ringing_trunk::ring_begin, and sla.
Referenced by sla_process_timers().
|
static |
Check to see if this station has failed to be dialed in the past minute.
Definition at line 1239 of file app_sla.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), and sla.
Referenced by sla_ring_stations().
|
static |
Check to see if this station is already ringing.
Definition at line 1223 of file app_sla.c.
References AST_LIST_TRAVERSE, and sla.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
|
static |
Calculate the ring delay for a given ringing trunk on a station.
station | the station |
ringing_trunk | the trunk. If NULL, the highest priority ringing trunk will be used |
Definition at line 1357 of file app_sla.c.
References ast_tvdiff_ms(), ast_tvnow(), RAII_VAR, sla_ringing_trunk::ring_begin, sla_station::ring_delay, sla_trunk_ref::ring_delay, and sla_choose_ringing_trunk().
Referenced by sla_calc_station_delays(), and sla_ring_stations().
|
static |
Check to see if dialing this station already timed out for this ringing trunk.
Definition at line 1078 of file app_sla.c.
References AST_LIST_TRAVERSE.
Referenced by sla_choose_ringing_trunk(), and sla_ring_stations().
|
static |
For a given station, choose the highest priority idle trunk.
Definition at line 1935 of file app_sla.c.
References ao2_ref, and AST_LIST_TRAVERSE.
|
static |
Choose the highest priority ringing trunk for a station.
station | the station |
rm | remove the ringing trunk once selected |
trunk_ref | a place to store the pointer to this stations reference to the selected trunk |
Definition at line 1099 of file app_sla.c.
References ao2_ref, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, sla, and sla_check_timed_out_station().
Referenced by sla_calc_station_delays(), and sla_check_station_delay().
|
static |
Find a trunk reference on a station by name.
station | the station |
name | the trunk's name |
Definition at line 759 of file app_sla.c.
References ao2_ref, ast_debug, AST_LIST_TRAVERSE, sla_trunk::barge_disabled, sla_trunk::hold_access, sla_trunk::hold_stations, and SLA_HOLD_PRIVATE.
|
static |
Calculate the time until the next known event.
Definition at line 1674 of file app_sla.c.
References ast_samp2tv(), ast_tvadd(), ast_tvnow(), sla_calc_station_delays(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), and SLA_EVENT_RINGING_TRUNK.
|
static |
Ring a station.
Definition at line 1263 of file app_sla.c.
References ast_dial_append(), ast_dial_create(), ast_dial_destroy(), ast_dial_join(), AST_DIAL_RESULT_TRYING, ast_dial_run(), ast_dial_set_state_callback(), AST_LIST_INSERT_HEAD, ast_party_caller_free(), ast_party_caller_init(), ast_strdupa, and sla.
Referenced by sla_ring_stations().
|
static |
Ring stations based on current set of ringing trunks.
Definition at line 1393 of file app_sla.c.
References AST_LIST_TRAVERSE, sla, sla_check_failed_station(), sla_check_inuse_station(), sla_check_ringing_station(), sla_check_station_delay(), sla_check_timed_out_station(), and sla_ring_station().
unsigned int attempt_callerid |
|
static |
struct { ... } sla |
A structure for data used by the sla thread.
Referenced by sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_ringing_station(), sla_choose_ringing_trunk(), sla_ring_station(), and sla_ring_stations().
|
static |
pthread_t thread |
The SLA thread ID
Definition at line 329 of file app_sla.c.
Referenced by ast_ari_channels_create(), feature_attended_transfer(), load_module(), softmix_bridge_destroy(), and stasis_app_control_snoop().