Channel Management. More...
#include "asterisk.h"#include "asterisk/_private.h"#include <sys/time.h>#include <signal.h>#include <math.h>#include "asterisk/paths.h"#include "asterisk/pbx.h"#include "asterisk/frame.h"#include "asterisk/mod_format.h"#include "asterisk/sched.h"#include "asterisk/channel.h"#include "asterisk/musiconhold.h"#include "asterisk/say.h"#include "asterisk/file.h"#include "asterisk/cli.h"#include "asterisk/translate.h"#include "asterisk/manager.h"#include "asterisk/cel.h"#include "asterisk/chanvars.h"#include "asterisk/linkedlists.h"#include "asterisk/indications.h"#include "asterisk/monitor.h"#include "asterisk/causes.h"#include "asterisk/callerid.h"#include "asterisk/utils.h"#include "asterisk/lock.h"#include "asterisk/app.h"#include "asterisk/transcap.h"#include "asterisk/devicestate.h"#include "asterisk/threadstorage.h"#include "asterisk/slinfactory.h"#include "asterisk/audiohook.h"#include "asterisk/framehook.h"#include "asterisk/timing.h"#include "asterisk/autochan.h"#include "asterisk/stringfields.h"#include "asterisk/global_datastores.h"#include "asterisk/data.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_channel_iterator |
| struct | ast_epoll_data |
| struct | ast_party_id_ies |
| struct | ast_party_name_ies |
| struct | ast_party_number_ies |
| struct | ast_party_subaddress_ies |
| struct | ast_silence_generator |
| struct | backends |
| the list of registered channel types More... | |
| struct | chanlist |
| List of channel drivers. More... | |
| struct | plc_ds |
| struct | tonepair_def |
| struct | tonepair_state |
| struct | xfer_masquerade_ds |
Defines | |
| #define | AST_DEFAULT_EMULATE_DTMF_DURATION 100 |
| #define | AST_MIN_DTMF_DURATION 80 |
| #define | AST_MIN_DTMF_GAP 45 |
| #define | DATA_EXPORT_CHANNEL(MEMBER) |
| #define | FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n" |
| #define | NUM_CHANNEL_BUCKETS 1567 |
| #define | STATE2STR_BUFSIZE 32 |
Enumerations | |
| enum | { AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_NUMBER_PRESENTATION } |
| Element identifiers for connected line indication frame data. More... | |
| enum | { AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_REASON, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_NUMBER_PRESENTATION } |
| Element identifiers for redirecting indication frame data. More... | |
Functions | |
| int | __ast_answer (struct ast_channel *chan, unsigned int delay, int cdr_answer) |
| Answer a channel, with a selectable delay before returning. | |
| static void | __ast_change_name_nolink (struct ast_channel *chan, const char *newname) |
| this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container. | |
| struct ast_channel * | __ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt,...) |
| Create a channel structure. | |
| static struct ast_channel *attribute_malloc | __ast_channel_alloc_ap (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2) |
| Create a new channel structure. | |
| static int | __ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds) |
| static int | __ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after) |
| static struct ast_frame * | __ast_read (struct ast_channel *chan, int dropaudio) |
| struct ast_channel * | __ast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) |
| Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
| static void | __init_state2str_threadbuf (void) |
| static void | adjust_frame_for_plc (struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore) |
| static void | apply_plc (struct ast_channel *chan, struct ast_frame *frame) |
| int | ast_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params) |
| int | ast_active_channels (void) |
| returns number of active/allocated channels | |
| int | ast_answer (struct ast_channel *chan) |
| Answer a channel. | |
| void | ast_begin_shutdown (int hangup) |
| format_t | ast_best_codec (format_t fmts) |
| Pick the best audio codec. | |
| struct ast_channel * | ast_bridged_channel (struct ast_channel *chan) |
| Find bridged channel. | |
| int | ast_call (struct ast_channel *chan, char *addr, int timeout) |
| Make a call. | |
| struct ast_channel * | ast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate) |
| Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated. | |
| void | ast_cancel_shutdown (void) |
| Cancel a shutdown in progress. | |
| const char * | ast_cause2str (int cause) |
| Gives the string form of a given hangup cause. | |
| void | ast_change_name (struct ast_channel *chan, const char *newname) |
| Change channel name. | |
| struct ast_channel * | ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...) |
| enum ast_bridge_result | ast_channel_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) |
| Bridge two channels together. | |
| struct ast_channel * | ast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags) |
| Call a function with every active channel. | |
| int | ast_channel_cc_params_init (struct ast_channel *chan, const struct ast_cc_config_params *base_params) |
| Set up datastore with CCSS parameters for a channel. | |
| static void | ast_channel_change_linkedid (struct ast_channel *chan, const char *linkedid) |
| void | ast_channel_clear_softhangup (struct ast_channel *chan, int flag) |
| Clear a set of softhangup flags from a channel. | |
| static int | ast_channel_cmp_cb (void *obj, void *arg, int flags) |
| int | ast_channel_cmpwhentohangup (struct ast_channel *chan, time_t offset) |
| Compare a offset with the settings of when to hang a channel up. | |
| int | ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset) |
| Compare a offset with when to hangup channel. | |
| int | ast_channel_connected_line_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int is_frame) |
| Run a connected line interception macro and update a channel's connected line information. | |
| int | ast_channel_data_add_structure (struct ast_data *tree, struct ast_channel *chan, int add_bridged) |
| Insert into an astdata tree, the channel structure. | |
| int | ast_channel_data_cmp_structure (const struct ast_data_search *tree, struct ast_channel *chan, const char *structure_name) |
| Compare to channel structures using the data api. | |
| int | ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore) |
| Add a datastore to a channel. | |
| struct ast_datastore * | ast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid) |
| Create a channel data store object. | |
| 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. | |
| int | ast_channel_datastore_free (struct ast_datastore *datastore) |
| Free a channel data store object. | |
| int | ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to) |
| Inherit datastores from a parent to a child. | |
| int | ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore) |
| Remove a datastore from a channel. | |
| int | ast_channel_defer_dtmf (struct ast_channel *chan) |
| Set defer DTMF flag on channel. | |
| static void | ast_channel_destructor (void *obj) |
| Free a channel structure. | |
| int | ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1) |
| Bridge two channels together (early) | |
| struct ast_channel * | ast_channel_get_by_exten (const char *exten, const char *context) |
| Find a channel by extension and context. | |
| struct ast_channel * | ast_channel_get_by_name (const char *name) |
| Find a channel by name. | |
| struct ast_channel * | ast_channel_get_by_name_prefix (const char *name, size_t name_len) |
| Find a channel by a name prefix. | |
| int | ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size) |
| Find the appropriate CC agent type to use given a channel. | |
| struct ast_cc_config_params * | ast_channel_get_cc_config_params (struct ast_channel *chan) |
| Get the CCSS parameters from a channel. | |
| int | ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length) |
| Get a device name given its channel structure. | |
| static struct ast_channel * | ast_channel_get_full (const char *name, size_t name_len, const char *exten, const char *context) |
| static int | ast_channel_hash_cb (const void *obj, const int flags) |
| void | ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child) |
| Inherits channel variable from parent to child channel. | |
| struct ast_channel_iterator * | ast_channel_iterator_all_new (void) |
| Create a new channel iterator. | |
| struct ast_channel_iterator * | ast_channel_iterator_by_exten_new (const char *exten, const char *context) |
| Create a new channel iterator based on extension. | |
| struct ast_channel_iterator * | ast_channel_iterator_by_name_new (const char *name, size_t name_len) |
| Create a new channel iterator based on name. | |
| struct ast_channel_iterator * | ast_channel_iterator_destroy (struct ast_channel_iterator *i) |
| Destroy a channel iterator. | |
| struct ast_channel * | ast_channel_iterator_next (struct ast_channel_iterator *i) |
| Get the next channel for a channel iterator. | |
| int | ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer) |
| Makes two channel formats compatible. | |
| static int | ast_channel_make_compatible_helper (struct ast_channel *from, struct ast_channel *to) |
| Set up translation from one channel to another. | |
| int | ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clone) |
| Weird function made for call transfers. | |
| int | ast_channel_queryoption (struct ast_channel *chan, int option, void *data, int *datalen, int block) |
| Checks the value of an option. | |
| void | ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Queue a connected line update frame on a channel. | |
| void | ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Queue a redirecting update frame on a channel. | |
| const char * | ast_channel_reason2str (int reason) |
| return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument | |
| int | ast_channel_redirecting_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame) |
| Run a redirecting interception macro and update a channel's redirecting information. | |
| int | ast_channel_register (const struct ast_channel_tech *tech) |
| Register a new telephony channel in Asterisk. | |
| struct ast_channel * | ast_channel_release (struct ast_channel *chan) |
| Unlink and release reference to a channel. | |
| int | ast_channel_sendhtml (struct ast_channel *chan, int subclass, const char *data, int datalen) |
| Sends HTML on given channel Send HTML or URL on link. | |
| int | ast_channel_sendurl (struct ast_channel *chan, const char *url) |
| Sends a URL on a given link Send URL on link. | |
| void | ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update) |
| Set the caller id information in the Asterisk channel. | |
| void | ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update) |
| Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed. | |
| void | ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Set the connected line information in the Asterisk channel. | |
| void | ast_channel_set_fd (struct ast_channel *chan, int which, int fd) |
| void | ast_channel_set_linkgroup (struct ast_channel *chan, struct ast_channel *peer) |
| Propagate the oldest linkedid between associated channels. | |
| void | ast_channel_set_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Set the redirecting id information in the Asterisk channel. | |
| int | ast_channel_setoption (struct ast_channel *chan, int option, void *data, int datalen, int block) |
| Sets an option on a channel. | |
| void | ast_channel_setwhentohangup (struct ast_channel *chan, time_t offset) |
| Set when to hang a channel up. | |
| void | ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset) |
| Set when to hangup channel. | |
| static int | ast_channel_softhangup_cb (void *obj, void *arg, int flags) |
| struct ast_silence_generator * | ast_channel_start_silence_generator (struct ast_channel *chan) |
| Starts a silence generator on the given channel. | |
| void | ast_channel_stop_silence_generator (struct ast_channel *chan, struct ast_silence_generator *state) |
| Stops a previously-started silence generator on the given channel. | |
| int | ast_channel_supports_html (struct ast_channel *chan) |
| Checks for HTML support on a channel. | |
| int | ast_channel_transfer_masquerade (struct ast_channel *target_chan, const struct ast_party_connected_line *target_id, int target_held, struct ast_channel *transferee_chan, const struct ast_party_connected_line *transferee_id, int transferee_held) |
| Setup a masquerade to transfer a call. | |
| void | ast_channel_undefer_dtmf (struct ast_channel *chan) |
| Unset defer DTMF flag on channel. | |
| void | ast_channel_unregister (const struct ast_channel_tech *tech) |
| Unregister channel driver. | |
| void | ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Indicate that the connected line information has changed. | |
| void | ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Indicate that the redirecting id has changed. | |
| void | ast_channels_init (void) |
| struct ast_variable * | ast_channeltype_list (void) |
| return an ast_variable list of channeltypes | |
| int | ast_check_hangup (struct ast_channel *chan) |
| Checks to see if a channel is needing hang up. | |
| int | ast_check_hangup_locked (struct ast_channel *chan) |
| int | ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Build the connected line information data frame. | |
| void | ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src) |
| Copy the caller information to the connected line information. | |
| void | ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src) |
| Copy the connected line information to the caller information. | |
| int | ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected) |
| Parse connected line indication frame data. | |
| AST_DATA_STRUCTURE (ast_channel, DATA_EXPORT_CHANNEL) | |
| void | ast_deactivate_generator (struct ast_channel *chan) |
| int | ast_do_masquerade (struct ast_channel *original) |
| Masquerade a channel. | |
| struct ast_channel * | ast_dummy_channel_alloc (void) |
| Create a fake channel structure. | |
| static void | ast_dummy_channel_destructor (void *obj) |
| Free a dummy channel structure. | |
| static enum ast_bridge_result | ast_generic_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) |
| struct ast_channel_tech * | ast_get_channel_tech (const char *name) |
| Get handle to channel driver based on name. | |
| ast_group_t | ast_get_group (const char *s) |
| int | ast_hangup (struct ast_channel *chan) |
| Hangup a channel. | |
| int | ast_indicate (struct ast_channel *chan, int condition) |
| Indicates condition of channel. | |
| int | ast_indicate_data (struct ast_channel *chan, int _condition, const void *data, size_t datalen) |
| Indicates condition of channel, with payload. | |
| void | ast_install_music_functions (int(*start_ptr)(struct ast_channel *, const char *, const char *), void(*stop_ptr)(struct ast_channel *), void(*cleanup_ptr)(struct ast_channel *)) |
| int | ast_internal_timing_enabled (struct ast_channel *chan) |
| Check if the channel can run in internal timing mode. | |
| int | ast_is_deferrable_frame (const struct ast_frame *frame) |
| Should we keep this frame for later? | |
| void | ast_moh_cleanup (struct ast_channel *chan) |
| int | ast_moh_start (struct ast_channel *chan, const char *mclass, const char *interpclass) |
| Turn on music on hold on a given channel. | |
| void | ast_moh_stop (struct ast_channel *chan) |
| Turn off music on hold on a given channel. | |
| void | ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src) |
| Copy the source caller information to the destination caller. | |
| void | ast_party_caller_free (struct ast_party_caller *doomed) |
| Destroy the caller party contents. | |
| void | ast_party_caller_init (struct ast_party_caller *init) |
| Initialize the given caller structure. | |
| void | ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update) |
| Set the caller information based on another caller source. | |
| void | ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide) |
| Initialize the given caller structure using the given guide for a set update operation. | |
| void | ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller) |
| Collect the caller party information into a connected line structure. | |
| void | ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src) |
| Copy the source connected line information to the destination connected line. | |
| void | ast_party_connected_line_free (struct ast_party_connected_line *doomed) |
| Destroy the connected line information contents. | |
| void | ast_party_connected_line_init (struct ast_party_connected_line *init) |
| Initialize the given connected line structure. | |
| void | ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update) |
| Set the connected line information based on another connected line source. | |
| void | ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide) |
| Initialize the given connected line structure using the given guide for a set update operation. | |
| void | ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src) |
| Copy the source dialed party information to the destination dialed party. | |
| void | ast_party_dialed_free (struct ast_party_dialed *doomed) |
| Destroy the dialed party contents. | |
| void | ast_party_dialed_init (struct ast_party_dialed *init) |
| Initialize the given dialed structure. | |
| void | ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src) |
| Set the dialed information based on another dialed source. | |
| void | ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide) |
| Initialize the given dialed structure using the given guide for a set update operation. | |
| void | ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src) |
| Copy the source party id information to the destination party id. | |
| void | ast_party_id_free (struct ast_party_id *doomed) |
| Destroy the party id contents. | |
| void | ast_party_id_init (struct ast_party_id *init) |
| Initialize the given party id structure. | |
| int | ast_party_id_presentation (const struct ast_party_id *id) |
| Determine the overall presentation value for the given party. | |
| void | ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update) |
| Set the source party id information into the destination party id. | |
| void | ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide) |
| Initialize the given party id structure using the given guide for a set update operation. | |
| void | ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src) |
| Copy the source party name information to the destination party name. | |
| void | ast_party_name_free (struct ast_party_name *doomed) |
| Destroy the party name contents. | |
| void | ast_party_name_init (struct ast_party_name *init) |
| Initialize the given name structure. | |
| void | ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src) |
| Set the source party name information into the destination party name. | |
| void | ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide) |
| Initialize the given party name structure using the given guide for a set update operation. | |
| void | ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src) |
| Copy the source party number information to the destination party number. | |
| void | ast_party_number_free (struct ast_party_number *doomed) |
| Destroy the party number contents. | |
| void | ast_party_number_init (struct ast_party_number *init) |
| Initialize the given number structure. | |
| void | ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src) |
| Set the source party number information into the destination party number. | |
| void | ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide) |
| Initialize the given party number structure using the given guide for a set update operation. | |
| void | ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src) |
| Copy the source redirecting information to the destination redirecting. | |
| void | ast_party_redirecting_free (struct ast_party_redirecting *doomed) |
| Destroy the redirecting information contents. | |
| void | ast_party_redirecting_init (struct ast_party_redirecting *init) |
| Initialize the given redirecting structure. | |
| void | ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update) |
| Set the redirecting information based on another redirecting source. | |
| void | ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide) |
| Initialize the given redirecting id structure using the given guide for a set update operation. | |
| void | ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src) |
| Copy the source party subaddress information to the destination party subaddress. | |
| void | ast_party_subaddress_free (struct ast_party_subaddress *doomed) |
| Destroy the party subaddress contents. | |
| void | ast_party_subaddress_init (struct ast_party_subaddress *init) |
| Initialize the given subaddress structure. | |
| void | ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src) |
| Set the source party subaddress information into the destination party subaddress. | |
| void | ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide) |
| Initialize the given party subaddress structure using the given guide for a set update operation. | |
| int | ast_plc_reload (void) |
| Reload genericplc configuration value from codecs.conf. | |
| void | ast_poll_channel_add (struct ast_channel *chan0, struct ast_channel *chan1) |
| void | ast_poll_channel_del (struct ast_channel *chan0, struct ast_channel *chan1) |
| char * | ast_print_group (char *buf, int buflen, ast_group_t group) |
| Print call group and pickup group ---. | |
| int | ast_prod (struct ast_channel *chan) |
| Send empty audio to prime a channel driver. | |
| int | ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control) |
| Queue a control frame. | |
| int | ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen) |
| Queue a control frame with payload. | |
| int | ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin) |
| Queue one or more frames to a channel's frame queue. | |
| int | ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *fin) |
| Queue one or more frames to the head of a channel's frame queue. | |
| int | ast_queue_hangup (struct ast_channel *chan) |
| Queue a hangup frame for channel. | |
| int | ast_queue_hangup_with_cause (struct ast_channel *chan, int cause) |
| Queue a hangup frame for channel. | |
| int | ast_raw_answer (struct ast_channel *chan, int cdr_answer) |
| Answer a channel. | |
| struct ast_frame * | ast_read (struct ast_channel *chan) |
| Reads a frame. | |
| static void | ast_read_generator_actions (struct ast_channel *chan, struct ast_frame *f) |
| struct ast_frame * | ast_read_noaudio (struct ast_channel *chan) |
| Reads a frame, returning AST_FRAME_NULL frame if audio. | |
| int | ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders) |
| Reads multiple digits. | |
| int | ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd) |
| int | ast_recvchar (struct ast_channel *chan, int timeout) |
| Receives a text character from a channel. | |
| char * | ast_recvtext (struct ast_channel *chan, int timeout) |
| Receives a text string from a channel Read a string of text from a channel. | |
| int | ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Build the redirecting id data frame. | |
| int | ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting) |
| Parse redirecting indication frame data. | |
| struct ast_channel * | ast_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) |
| Requests a channel. | |
| struct ast_channel * | ast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) |
| Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
| int | ast_safe_sleep (struct ast_channel *chan, int ms) |
| Wait, look for hangups. | |
| int | ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data) |
| Wait, look for hangups and condition arg. | |
| int | ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| int | ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| says digits of a string | |
| int | ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang) |
| says digits | |
| int | ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd) |
| int | ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options) |
| says an enumeration | |
| int | ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options) |
| says a number | |
| int | ast_say_phonetic_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| int | ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration) |
| Send a DTMF digit to a channel. | |
| int | ast_senddigit_begin (struct ast_channel *chan, char digit) |
| Send a DTMF digit to a channel. | |
| int | ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration) |
| Send a DTMF digit to a channel. | |
| int | ast_sendtext (struct ast_channel *chan, const char *text) |
| Sends text to a channel. | |
| void | ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani) |
| Set caller ID number, name and ANI and generate AMI event. | |
| void | ast_set_hangupsource (struct ast_channel *chan, const char *source, int force) |
| Set the source of the hangup in this channel and it's bridge. | |
| static void | ast_set_owners_and_peers (struct ast_channel *chan1, struct ast_channel *chan2) |
| int | ast_set_read_format (struct ast_channel *chan, format_t fmt) |
| Sets read format on channel chan Set read format for channel to whichever component of "format" is best. | |
| void | ast_set_variables (struct ast_channel *chan, struct ast_variable *vars) |
| adds a list of channel variables to a channel | |
| int | ast_set_write_format (struct ast_channel *chan, format_t fmt) |
| Sets write format on channel chan Set write format for channel to whichever component of "format" is best. | |
| int | ast_setstate (struct ast_channel *chan, enum ast_channel_state state) |
| Change the state of a channel. | |
| int | ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data) |
| Enable or disable timer ticks for a channel. | |
| int | ast_shutting_down (void) |
| Returns non-zero if Asterisk is being shut down. | |
| int | ast_softhangup (struct ast_channel *chan, int cause) |
| Softly hangup a channel, lock. | |
| int | ast_softhangup_nolock (struct ast_channel *chan, int cause) |
| Softly hangup a channel, don't lock. | |
| const char * | ast_state2str (enum ast_channel_state state) |
| Gives the string form of a given channel state. | |
| int | ast_str2cause (const char *name) |
| Convert a symbolic hangup cause to number. | |
| int | ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol) |
| int | ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol) |
| void | ast_tonepair_stop (struct ast_channel *chan) |
| int | ast_transfer (struct ast_channel *chan, char *dest) |
| Transfer a call to dest, if the channel supports transfer. | |
| char * | ast_transfercapability2str (int transfercapability) |
| Gives the string form of a given transfer capability. | |
| void | ast_uninstall_music_functions (void) |
| int | ast_waitfor (struct ast_channel *c, int ms) |
| Wait for input on a channel. | |
| struct ast_channel * | ast_waitfor_n (struct ast_channel **c, int n, int *ms) |
| Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds. | |
| int | ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception) |
| Wait for x amount of time on a file descriptor to have input. | |
| struct ast_channel * | ast_waitfor_nandfds (struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms) |
| Wait for x amount of time on a file descriptor to have input. | |
| int | ast_waitfordigit (struct ast_channel *c, int ms) |
| Waits for a digit. | |
| int | ast_waitfordigit_full (struct ast_channel *c, int ms, int audiofd, int cmdfd) |
| Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. | |
| int | ast_write (struct ast_channel *chan, struct ast_frame *fr) |
| Write a frame to a channel This function writes the given frame to the indicated channel. | |
| int | ast_write_video (struct ast_channel *chan, struct ast_frame *fr) |
| Write video frame to a channel This function writes the given frame to the indicated channel. | |
| static void | bridge_play_sounds (struct ast_channel *c0, struct ast_channel *c1) |
| static void | bridge_playfile (struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain) |
| static int | calc_monitor_jump (int samples, int sample_rate, int seek_rate) |
| calculates the number of samples to jump forward with in a monitor stream. | |
| static void | call_forward_inherit (struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig) |
| static void * | channel_cc_params_copy (void *data) |
| static void | channel_cc_params_destroy (void *data) |
| static void | channel_data_add_flags (struct ast_data *tree, struct ast_channel *chan) |
| static struct ast_channel_iterator * | channel_iterator_search (const char *name, size_t name_len, const char *exten, const char *context) |
| const char * | channelreloadreason2txt (enum channelreloadreason reason) |
| Convert enum channelreloadreason to text string for manager event. | |
| static void | clone_variables (struct ast_channel *original, struct ast_channel *clonechan) |
| Clone channel variables from 'clone' channel into 'original' channel. | |
| static char * | complete_channeltypes (struct ast_cli_args *a) |
| static int | data_channels_provider_handler (const struct ast_data_search *search, struct ast_data *root) |
| static int | data_channeltypes_provider_handler (const struct ast_data_search *search, struct ast_data *data_root) |
| static void | free_translation (struct ast_channel *clonechan) |
| static int | generator_force (const void *data) |
| static void | handle_cause (int cause, int *outstate) |
| static char * | handle_cli_core_show_channeltype (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show details about a channel driver - CLI command. | |
| static char * | handle_cli_core_show_channeltypes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show channel types - CLI command. | |
| static int attribute_const | is_visible_indication (enum ast_control_frame_type condition) |
| static struct ast_frame * | kill_exception (struct ast_channel *chan) |
| static int | kill_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
| static int | kill_hangup (struct ast_channel *chan) |
| static struct ast_frame * | kill_read (struct ast_channel *chan) |
| static int | kill_write (struct ast_channel *chan, struct ast_frame *frame) |
| static void | manager_bridge_event (int onoff, int type, struct ast_channel *c0, struct ast_channel *c1) |
| Send manager event for bridge link and unlink events. | |
| static void | masquerade_colp_transfer (struct ast_channel *transferee, struct xfer_masquerade_ds *colp) |
| static const char * | oldest_linkedid (const char *a, const char *b) |
| static void | party_connected_line_copy_transfer (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src) |
| static int | party_id_build_data (unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update) |
| static int | party_name_build_data (unsigned char *data, size_t datalen, const struct ast_party_name *name, const char *label, const struct ast_party_name_ies *ies) |
| static int | party_number_build_data (unsigned char *data, size_t datalen, const struct ast_party_number *number, const char *label, const struct ast_party_number_ies *ies) |
| static int | party_subaddress_build_data (unsigned char *data, size_t datalen, const struct ast_party_subaddress *subaddress, const char *label, const struct ast_party_subaddress_ies *ies) |
| static void | plc_ds_destroy (void *data) |
| static void | queue_dtmf_readq (struct ast_channel *chan, struct ast_frame *f) |
| static void | report_new_callerid (struct ast_channel *chan) |
| static void | send_dtmf_event (struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end) |
| static int | set_format (struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction) |
| static int | set_security_requirements (const struct ast_channel *requestor, struct ast_channel *out) |
| static int | should_skip_dtmf (struct ast_channel *chan) |
| Determine whether or not we should ignore DTMF in the readq. | |
| static void * | silence_generator_alloc (struct ast_channel *chan, void *data) |
| static int | silence_generator_generate (struct ast_channel *chan, void *data, int len, int samples) |
| static void | silence_generator_release (struct ast_channel *chan, void *data) |
| static void * | tonepair_alloc (struct ast_channel *chan, void *params) |
| static int | tonepair_generator (struct ast_channel *chan, void *data, int len, int samples) |
| static void | tonepair_release (struct ast_channel *chan, void *params) |
| static void | update_bridge_vars (struct ast_channel *c0, struct ast_channel *c1) |
| static void | xfer_ds_destroy (void *data) |
Variables | |
| struct ast_channel_tech | ast_kill_tech |
| Kill the channel channel driver technology descriptor. | |
| static void(* | ast_moh_cleanup_ptr )(struct ast_channel *) = NULL |
| static int(* | ast_moh_start_ptr )(struct ast_channel *, const char *, const char *) = NULL |
| static void(* | ast_moh_stop_ptr )(struct ast_channel *) = NULL |
| static struct backends | backends |
| struct { | |
| int cause | |
| const char * desc | |
| const char * name | |
| } | causes [] |
| map AST_CAUSE's to readable string representations | |
| static struct ast_datastore_info | cc_channel_datastore_info |
| static struct ast_data_entry | channel_providers [] |
| static struct ao2_container * | channels |
| All active channels on the system. | |
| static struct ast_data_handler | channels_provider |
| static struct ast_data_handler | channeltypes_provider |
| static struct ast_cli_entry | cli_channel [] |
| unsigned long | global_fin |
| unsigned long | global_fout |
| static struct ast_channel_tech | null_tech |
| static struct ast_datastore_info | plc_ds_info |
| static int | shutting_down |
| Prevent new channel allocation if shutting down. | |
| static struct ast_generator | silence_generator |
| static struct ast_threadstorage | state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , } |
| static struct ast_generator | tonepair |
| static int | uniqueint |
| static struct ast_datastore_info | xfer_ds_info |
Channel Management.
Definition in file channel.c.
| #define AST_DEFAULT_EMULATE_DTMF_DURATION 100 |
Default amount of time to use when emulating a digit as a begin and end 100ms
Definition at line 104 of file channel.c.
Referenced by __ast_read(), and ast_senddigit().
| #define AST_MIN_DTMF_DURATION 80 |
Minimum allowed digit length - 80ms
Definition at line 107 of file channel.c.
Referenced by __ast_read().
| #define AST_MIN_DTMF_GAP 45 |
Minimum amount of time between the end of the last digit and the beginning of a new one - 45ms
Definition at line 111 of file channel.c.
Referenced by __ast_read(), and should_skip_dtmf().
| #define FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n" |
| #define NUM_CHANNEL_BUCKETS 1567 |
Definition at line 141 of file channel.c.
Referenced by ast_channels_init().
| #define STATE2STR_BUFSIZE 32 |
Definition at line 100 of file channel.c.
Referenced by ast_state2str().
| anonymous enum |
Element identifiers for connected line indication frame data.
Definition at line 8500 of file channel.c.
{
AST_CONNECTED_LINE_NUMBER,
AST_CONNECTED_LINE_NAME,
AST_CONNECTED_LINE_NUMBER_PLAN,
AST_CONNECTED_LINE_ID_PRESENTATION,/* Combined number and name presentation. */
AST_CONNECTED_LINE_SOURCE,
AST_CONNECTED_LINE_SUBADDRESS,
AST_CONNECTED_LINE_SUBADDRESS_TYPE,
AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
AST_CONNECTED_LINE_SUBADDRESS_VALID,
AST_CONNECTED_LINE_TAG,
AST_CONNECTED_LINE_VERSION,
AST_CONNECTED_LINE_NAME_VALID,
AST_CONNECTED_LINE_NAME_CHAR_SET,
AST_CONNECTED_LINE_NAME_PRESENTATION,
AST_CONNECTED_LINE_NUMBER_VALID,
AST_CONNECTED_LINE_NUMBER_PRESENTATION,
};
| anonymous enum |
Element identifiers for redirecting indication frame data.
Definition at line 8821 of file channel.c.
{
AST_REDIRECTING_FROM_NUMBER,
AST_REDIRECTING_FROM_NAME,
AST_REDIRECTING_FROM_NUMBER_PLAN,
AST_REDIRECTING_FROM_ID_PRESENTATION,
AST_REDIRECTING_TO_NUMBER,
AST_REDIRECTING_TO_NAME,
AST_REDIRECTING_TO_NUMBER_PLAN,
AST_REDIRECTING_TO_ID_PRESENTATION,
AST_REDIRECTING_REASON,
AST_REDIRECTING_COUNT,
AST_REDIRECTING_FROM_SUBADDRESS,
AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
AST_REDIRECTING_FROM_SUBADDRESS_VALID,
AST_REDIRECTING_TO_SUBADDRESS,
AST_REDIRECTING_TO_SUBADDRESS_TYPE,
AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
AST_REDIRECTING_TO_SUBADDRESS_VALID,
AST_REDIRECTING_FROM_TAG,
AST_REDIRECTING_TO_TAG,
AST_REDIRECTING_VERSION,
AST_REDIRECTING_FROM_NAME_VALID,
AST_REDIRECTING_FROM_NAME_CHAR_SET,
AST_REDIRECTING_FROM_NAME_PRESENTATION,
AST_REDIRECTING_FROM_NUMBER_VALID,
AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
AST_REDIRECTING_TO_NAME_VALID,
AST_REDIRECTING_TO_NAME_CHAR_SET,
AST_REDIRECTING_TO_NAME_PRESENTATION,
AST_REDIRECTING_TO_NUMBER_VALID,
AST_REDIRECTING_TO_NUMBER_PRESENTATION,
};
| int __ast_answer | ( | struct ast_channel * | chan, |
| unsigned int | delay, | ||
| int | cdr_answer | ||
| ) |
Answer a channel, with a selectable delay before returning.
| chan | channel to answer |
| delay | maximum amount of time to wait for incoming media |
| cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
This function answers a channel and handles all necessary call setup functions.
| 0 | on success |
| non-zero | on failure |
Definition at line 2923 of file channel.c.
References ast_channel::_state, ast_channel_lock, ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_frisolate(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_log(), ast_queue_frame_head(), ast_raw_answer(), ast_read(), AST_STATE_RING, AST_STATE_RINGING, ast_waitfor(), errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.
Referenced by ast_answer(), pbx_builtin_answer(), and pbx_builtin_incomplete().
{
int res = 0;
enum ast_channel_state old_state;
old_state = chan->_state;
if ((res = ast_raw_answer(chan, cdr_answer))) {
return res;
}
switch (old_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
/* wait for media to start flowing, but don't wait any longer
* than 'delay' or 500 milliseconds, whichever is longer
*/
do {
AST_LIST_HEAD_NOLOCK(, ast_frame) frames;
struct ast_frame *cur, *new;
int ms = MAX(delay, 500);
unsigned int done = 0;
AST_LIST_HEAD_INIT_NOLOCK(&frames);
for (;;) {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno));
res = -1;
break;
}
if (ms == 0) {
ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500));
break;
}
cur = ast_read(chan);
if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
(cur->subclass.integer == AST_CONTROL_HANGUP))) {
if (cur) {
ast_frfree(cur);
}
res = -1;
ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name);
break;
}
if ((new = ast_frisolate(cur)) != cur) {
ast_frfree(cur);
}
AST_LIST_INSERT_HEAD(&frames, new, frame_list);
/* if a specific delay period was requested, continue
* until that delay has passed. don't stop just because
* incoming media has arrived.
*/
if (delay) {
continue;
}
switch (new->frametype) {
/* all of these frametypes qualify as 'media' */
case AST_FRAME_VOICE:
case AST_FRAME_VIDEO:
case AST_FRAME_TEXT:
case AST_FRAME_DTMF_BEGIN:
case AST_FRAME_DTMF_END:
case AST_FRAME_IMAGE:
case AST_FRAME_HTML:
case AST_FRAME_MODEM:
done = 1;
break;
case AST_FRAME_CONTROL:
case AST_FRAME_IAX:
case AST_FRAME_NULL:
case AST_FRAME_CNG:
break;
}
if (done) {
break;
}
}
if (res == 0) {
ast_channel_lock(chan);
while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
ast_queue_frame_head(chan, cur);
ast_frfree(cur);
}
ast_channel_unlock(chan);
}
} while (0);
break;
default:
break;
}
return res;
}
| static void __ast_change_name_nolink | ( | struct ast_channel * | chan, |
| const char * | newname | ||
| ) | [static] |
this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container.
Definition at line 6062 of file channel.c.
References ast_manager_event, ast_string_field_set, EVENT_FLAG_CALL, name, ast_channel::name, and ast_channel::uniqueid.
Referenced by ast_change_name(), and ast_do_masquerade().
{
ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
ast_string_field_set(chan, name, newname);
}
| struct ast_channel* __ast_channel_alloc | ( | int | needqueue, |
| int | state, | ||
| const char * | cid_num, | ||
| const char * | cid_name, | ||
| const char * | acctcode, | ||
| const char * | exten, | ||
| const char * | context, | ||
| const char * | linkedid, | ||
| const int | amaflag, | ||
| const char * | file, | ||
| int | line, | ||
| const char * | function, | ||
| const char * | name_fmt, | ||
| ... | |||
| ) | [read] |
Create a channel structure.
| NULL | failure |
| non-NULL | successfully allocated channel |
Definition at line 1344 of file channel.c.
References __ast_channel_alloc_ap().
{
va_list ap1, ap2;
struct ast_channel *result;
va_start(ap1, name_fmt);
va_start(ap2, name_fmt);
result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
linkedid, amaflag, file, line, function, name_fmt, ap1, ap2);
va_end(ap1);
va_end(ap2);
return result;
}
| static struct ast_channel* attribute_malloc __ast_channel_alloc_ap | ( | int | needqueue, |
| int | state, | ||
| const char * | cid_num, | ||
| const char * | cid_name, | ||
| const char * | acctcode, | ||
| const char * | exten, | ||
| const char * | context, | ||
| const char * | linkedid, | ||
| const int | amaflag, | ||
| const char * | file, | ||
| int | line, | ||
| const char * | function, | ||
| const char * | name_fmt, | ||
| va_list | ap1, | ||
| va_list | ap2 | ||
| ) | [static, read] |
Create a new channel structure.
Definition at line 1109 of file channel.c.
References __ao2_alloc_debug(), ast_channel::_state, accountcode, ast_channel::accountcode, ast_channel::alertpipe, ast_channel::amaflags, ao2_alloc, ao2_link, ARRAY_LEN, AST_ALERT_FD, ast_atomic_fetchadd_int(), ast_cdr_alloc(), ast_cdr_init(), ast_cdr_start(), AST_CEL_CHANNEL_START, ast_cel_report_event(), ast_channel_destructor(), ast_channel_set_fd(), ast_channel_unref, ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_default_accountcode, ast_default_amaflags, ast_get_channel_tech(), AST_LIST_HEAD_INIT_NOLOCK, ast_log(), ast_manager_event, ast_party_caller_init(), ast_party_connected_line_init(), ast_party_dialed_init(), ast_party_redirecting_init(), ast_state2str(), ast_strdup, ast_strdupa, ast_string_field_build, ast_string_field_build_va, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_timer_fd(), ast_timer_get_name(), ast_timer_open(), AST_TIMING_FD, ast_channel::autochans, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, ast_channel::context, ast_channel::datastores, defaultlanguage, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::exten, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_channel::fout, global_fin, global_fout, ast_party_caller::id, language, LOG_WARNING, name, ast_party_id::name, ast_channel::name, null_tech, ast_party_id::number, ast_channel::priority, ast_channel::redirecting, S_OR, ast_channel::sched, sched_context_create(), state, ast_party_name::str, ast_party_number::str, ast_channel::streamid, chanlist::tech, ast_channel::tech, ast_channel::timer, ast_channel::timingfd, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::varshead.
Referenced by __ast_channel_alloc(), and ast_channel_alloc().
{
struct ast_channel *tmp;
int x;
int flags;
struct varshead *headp;
char *tech = "", *tech2 = NULL;
/* If shutting down, don't allocate any new channels */
if (shutting_down) {
ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n");
return NULL;
}
#if defined(REF_DEBUG)
tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line,
function, 1);
#elif defined(__AST_DEBUG_MALLOC)
tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line,
function, 0);
#else
tmp = ao2_alloc(sizeof(*tmp), ast_channel_destructor);
#endif
if (!tmp) {
/* Channel structure allocation failure. */
return NULL;
}
/*
* Init file descriptors to unopened state so
* the destructor can know not to close them.
*/
tmp->timingfd = -1;
for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
tmp->alertpipe[x] = -1;
}
for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) {
tmp->fds[x] = -1;
}
#ifdef HAVE_EPOLL
tmp->epfd = epoll_create(25);
#endif
if (!(tmp->sched = sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
return ast_channel_unref(tmp);
}
ast_party_dialed_init(&tmp->dialed);
ast_party_caller_init(&tmp->caller);
ast_party_connected_line_init(&tmp->connected);
ast_party_redirecting_init(&tmp->redirecting);
if (cid_name) {
tmp->caller.id.name.valid = 1;
tmp->caller.id.name.str = ast_strdup(cid_name);
if (!tmp->caller.id.name.str) {
return ast_channel_unref(tmp);
}
}
if (cid_num) {
tmp->caller.id.number.valid = 1;
tmp->caller.id.number.str = ast_strdup(cid_num);
if (!tmp->caller.id.number.str) {
return ast_channel_unref(tmp);
}
}
if ((tmp->timer = ast_timer_open())) {
if (strcmp(ast_timer_get_name(tmp->timer), "timerfd")) {
needqueue = 0;
}
tmp->timingfd = ast_timer_fd(tmp->timer);
}
if (needqueue) {
if (pipe(tmp->alertpipe)) {
ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n");
return ast_channel_unref(tmp);
} else {
flags = fcntl(tmp->alertpipe[0], F_GETFL);
if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
return ast_channel_unref(tmp);
}
flags = fcntl(tmp->alertpipe[1], F_GETFL);
if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
return ast_channel_unref(tmp);
}
}
}
/*
* This is the last place the channel constructor can fail.
*
* The destructor takes advantage of this fact to ensure that the
* AST_CEL_CHANNEL_END is not posted if we have not posted the
* AST_CEL_CHANNEL_START yet.
*/
if ((ast_string_field_init(tmp, 128))) {
return ast_channel_unref(tmp);
}
/* Always watch the alertpipe */
ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]);
/* And timing pipe */
ast_channel_set_fd(tmp, AST_TIMING_FD, tmp->timingfd);
/* Initial state */
tmp->_state = state;
tmp->streamid = -1;
tmp->fin = global_fin;
tmp->fout = global_fout;
if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
ast_string_field_build(tmp, uniqueid, "%li.%d", (long) time(NULL),
ast_atomic_fetchadd_int(&uniqueint, 1));
} else {
ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME,
(long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1));
}
if (!ast_strlen_zero(linkedid)) {
ast_string_field_set(tmp, linkedid, linkedid);
} else {
ast_string_field_set(tmp, linkedid, tmp->uniqueid);
}
if (!ast_strlen_zero(name_fmt)) {
char *slash, *slash2;
/* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
* And they all use slightly different formats for their name string.
* This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
* This means, that the stringfields must have a routine that takes the va_lists directly, and
* uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
* This new function was written so this can be accomplished.
*/
ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2);
tech = ast_strdupa(tmp->name);
if ((slash = strchr(tech, '/'))) {
if ((slash2 = strchr(slash + 1, '/'))) {
tech2 = slash + 1;
*slash2 = '\0';
}
*slash = '\0';
}
} else {
/*
* Start the string with '-' so it becomes an empty string
* in the destructor.
*/
ast_string_field_set(tmp, name, "-**Unknown**");
}
/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
/* These 4 variables need to be set up for the cdr_init() to work right */
if (amaflag)
tmp->amaflags = amaflag;
else
tmp->amaflags = ast_default_amaflags;
if (!ast_strlen_zero(acctcode))
ast_string_field_set(tmp, accountcode, acctcode);
else
ast_string_field_set(tmp, accountcode, ast_default_accountcode);
if (!ast_strlen_zero(context))
ast_copy_string(tmp->context, context, sizeof(tmp->context));
else
strcpy(tmp->context, "default");
if (!ast_strlen_zero(exten))
ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
else
strcpy(tmp->exten, "s");
tmp->priority = 1;
tmp->cdr = ast_cdr_alloc();
ast_cdr_init(tmp->cdr, tmp);
ast_cdr_start(tmp->cdr);
ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
headp = &tmp->varshead;
AST_LIST_HEAD_INIT_NOLOCK(headp);
AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores);
AST_LIST_HEAD_INIT_NOLOCK(&tmp->autochans);
ast_string_field_set(tmp, language, defaultlanguage);
tmp->tech = &null_tech;
ao2_link(channels, tmp);
/*
* And now, since the channel structure is built, and has its name, let's
* call the manager event generator with this Newchannel event. This is the
* proper and correct place to make this call, but you sure do have to pass
* a lot of data into this func to do it here!
*/
if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) {
ast_manager_event(tmp, EVENT_FLAG_CALL, "Newchannel",
"Channel: %s\r\n"
"ChannelState: %d\r\n"
"ChannelStateDesc: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"AccountCode: %s\r\n"
"Exten: %s\r\n"
"Context: %s\r\n"
"Uniqueid: %s\r\n",
tmp->name,
state,
ast_state2str(state),
S_OR(cid_num, ""),
S_OR(cid_name, ""),
tmp->accountcode,
S_OR(exten, ""),
S_OR(context, ""),
tmp->uniqueid);
}
return tmp;
}
| static int __ast_channel_masquerade | ( | struct ast_channel * | original, |
| struct ast_channel * | clonechan, | ||
| struct ast_datastore * | xfer_ds | ||
| ) | [static] |
Definition at line 5826 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_datastore_add(), ast_channel_lock_both, ast_channel_trylock, ast_channel_unlock, ast_debug, AST_FLAG_ZOMBIE, ast_log(), ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel_tech::get_base_channel, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, and ast_channel::tech.
Referenced by ast_channel_masquerade(), and ast_channel_transfer_masquerade().
{
int res = -1;
struct ast_channel *final_orig, *final_clone, *base;
for (;;) {
final_orig = original;
final_clone = clonechan;
ast_channel_lock_both(original, clonechan);
if (ast_test_flag(original, AST_FLAG_ZOMBIE)
|| ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
/* Zombies! Run! */
ast_log(LOG_WARNING,
"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
original->name, clonechan->name);
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
}
/*
* Each of these channels may be sitting behind a channel proxy
* (i.e. chan_agent) and if so, we don't really want to
* masquerade it, but its proxy
*/
if (original->_bridge
&& (original->_bridge != ast_bridged_channel(original))
&& (original->_bridge->_bridge != original)) {
final_orig = original->_bridge;
}
if (clonechan->_bridge
&& (clonechan->_bridge != ast_bridged_channel(clonechan))
&& (clonechan->_bridge->_bridge != clonechan)) {
final_clone = clonechan->_bridge;
}
if (final_clone->tech->get_base_channel
&& (base = final_clone->tech->get_base_channel(final_clone))) {
final_clone = base;
}
if ((final_orig != original) || (final_clone != clonechan)) {
/*
* Lots and lots of deadlock avoidance. The main one we're
* competing with is ast_write(), which locks channels
* recursively, when working with a proxy channel.
*/
if (ast_channel_trylock(final_orig)) {
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
/* Try again */
continue;
}
if (ast_channel_trylock(final_clone)) {
ast_channel_unlock(final_orig);
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
/* Try again */
continue;
}
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
original = final_orig;
clonechan = final_clone;
if (ast_test_flag(original, AST_FLAG_ZOMBIE)
|| ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
/* Zombies! Run! */
ast_log(LOG_WARNING,
"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
original->name, clonechan->name);
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
}
}
break;
}
if (original == clonechan) {
ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
}
ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
clonechan->name, original->name);
if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
original->masq = clonechan;
clonechan->masqr = original;
if (xfer_ds) {
ast_channel_datastore_add(original, xfer_ds);
}
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clonechan, &ast_null_frame);
ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name);
res = 0;
} else if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name);
} else if (original->masqr) {
/* not yet as a previously planned masq hasn't yet happened */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->name, original->masqr->name);
} else if (clonechan->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
clonechan->masq->name, clonechan->name);
} else { /* (clonechan->masqr) */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
clonechan->name, clonechan->masqr->name);
}
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return res;
}
| static int __ast_queue_frame | ( | struct ast_channel * | chan, |
| struct ast_frame * | fin, | ||
| int | head, | ||
| struct ast_frame * | after | ||
| ) | [static] |
Definition at line 1399 of file channel.c.
References ast_channel::alertpipe, ast_channel_lock, ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_CONTROL_HANGUP, AST_FLAG_BLOCKING, AST_FRAME_CONTROL, AST_FRAME_NULL, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup(), ast_frfree, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_LIST_AFTER, AST_LIST_INSERT_TAIL, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_test_flag, ast_timer_enable_continuous(), ast_channel::blocker, errno, f, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_channel::name, ast_channel::readq, ast_frame::subclass, ast_channel::timer, and ast_channel::timingfd.
Referenced by __ast_read(), ast_queue_frame(), and ast_queue_frame_head().
{
struct ast_frame *f;
struct ast_frame *cur;
unsigned int new_frames = 0;
unsigned int new_voice_frames = 0;
unsigned int queued_frames = 0;
unsigned int queued_voice_frames = 0;
AST_LIST_HEAD_NOLOCK(, ast_frame) frames;
ast_channel_lock(chan);
/*
* Check the last frame on the queue if we are queuing the new
* frames after it.
*/
cur = AST_LIST_LAST(&chan->readq);
if (cur && cur->frametype == AST_FRAME_CONTROL && !head && (!after || after == cur)) {
switch (cur->subclass.integer) {
case AST_CONTROL_END_OF_Q:
if (fin->frametype == AST_FRAME_CONTROL
&& fin->subclass.integer == AST_CONTROL_HANGUP) {
/*
* Destroy the end-of-Q marker frame so we can queue the hangup
* frame in its place.
*/
AST_LIST_REMOVE(&chan->readq, cur, frame_list);
ast_frfree(cur);
/*
* This has degenerated to a normal queue append anyway. Since
* we just destroyed the last frame in the queue we must make
* sure that "after" is NULL or bad things will happen.
*/
after = NULL;
break;
}
/* Fall through */
case AST_CONTROL_HANGUP:
/* Don't queue anything. */
ast_channel_unlock(chan);
return 0;
default:
break;
}
}
/* Build copies of all the new frames and count them */
AST_LIST_HEAD_INIT_NOLOCK(&frames);
for (cur = fin; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
if (!(f = ast_frdup(cur))) {
if (AST_LIST_FIRST(&frames)) {
ast_frfree(AST_LIST_FIRST(&frames));
}
ast_channel_unlock(chan);
return -1;
}
AST_LIST_INSERT_TAIL(&frames, f, frame_list);
new_frames++;
if (f->frametype == AST_FRAME_VOICE) {
new_voice_frames++;
}
}
/* Count how many frames exist on the queue */
AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) {
queued_frames++;
if (cur->frametype == AST_FRAME_VOICE) {
queued_voice_frames++;
}
}
if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
int count = 0;
ast_log(LOG_WARNING, "Exceptionally long %squeue length queuing to %s\n", queued_frames + new_frames > 128 ? "" : "voice ", chan->name);
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) {
/* Save the most recent frame */
if (!AST_LIST_NEXT(cur, frame_list)) {
break;
} else if (cur->frametype == AST_FRAME_VOICE || cur->frametype == AST_FRAME_VIDEO || cur->frametype == AST_FRAME_NULL) {
if (++count > 64) {
break;
}
AST_LIST_REMOVE_CURRENT(frame_list);
ast_frfree(cur);
}
}
AST_LIST_TRAVERSE_SAFE_END;
}
if (after) {
AST_LIST_INSERT_LIST_AFTER(&chan->readq, &frames, after, frame_list);
} else {
if (head) {
AST_LIST_APPEND_LIST(&frames, &chan->readq, frame_list);
AST_LIST_HEAD_INIT_NOLOCK(&chan->readq);
}
AST_LIST_APPEND_LIST(&chan->readq, &frames, frame_list);
}
if (chan->alertpipe[1] > -1) {
int blah[new_frames];
memset(blah, 1, sizeof(blah));
if (write(chan->alertpipe[1], &blah, sizeof(blah)) != (sizeof(blah))) {
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n",
chan->name, queued_frames, strerror(errno));
}
} else if (chan->timingfd > -1) {
ast_timer_enable_continuous(chan->timer);
} else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
pthread_kill(chan->blocker, SIGURG);
}
ast_channel_unlock(chan);
return 0;
}
| static struct ast_frame* __ast_read | ( | struct ast_channel * | chan, |
| int | dropaudio | ||
| ) | [static, read] |
Definition at line 3715 of file channel.c.
References __ast_queue_frame(), ast_channel::_softhangup, ast_channel::_state, ast_control_read_action_payload::action, ast_channel::alertpipe, ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_bridged_channel(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_connected_line_macro(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_HANGUP, AST_CONTROL_READ_ACTION, ast_deactivate_generator(), ast_debug, AST_DEFAULT_EMULATE_DTMF_DURATION, ast_do_masquerade(), AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_DTMF, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_format_rate(), AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_NULL, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, AST_FRAME_VOICE, ast_framehook_list_read_event(), ast_frfree, AST_GENERATOR_FD, ast_getformatname(), ast_getformatname_multiple(), ast_indicate_data(), AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), AST_MIN_DTMF_DURATION, AST_MIN_DTMF_GAP, AST_MONITOR_RUNNING, ast_null_frame, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_queue_control(), ast_queue_frame(), ast_queue_frame_head(), ast_read_generator_actions(), ast_seekstream(), ast_set_flag, ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_UP, ast_test_flag, ast_timer_ack(), ast_timer_disable_continuous(), ast_timer_get_event(), ast_timer_set_rate(), AST_TIMING_EVENT_CONTINUOUS, AST_TIMING_EVENT_EXPIRED, AST_TIMING_FD, ast_translate(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_writestream(), ast_channel::audiohooks, ast_channel::blocker, calc_monitor_jump(), cause, ast_frame_subclass::codec, ast_channel::connected, ast_frame::data, DEBUGCHAN_FLAG, ast_generator::digit, ast_channel::dtmf_tv, ast_channel::dtmff, ast_channel::emulate_dtmf_digit, ast_channel::emulate_dtmf_duration, errno, ast_channel_tech::exception, f, ast_channel::fdno, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_filestream::fmt, ast_format::format, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_generator::generate, ast_channel::generator, ast_channel::generatordata, ast_channel::hangupcause, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_DTMF, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_channel::masq, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::nativeformats, ast_channel::outsmpl, ast_control_read_action_payload::payload, ast_control_read_action_payload::payload_size, ast_frame::ptr, queue_dtmf_readq(), ast_channel_tech::read, ast_channel_monitor::read_stream, ast_channel::readq, ast_channel::readtrans, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), should_skip_dtmf(), ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, ast_channel::timingfunc, and ast_frame::uint32.
Referenced by ast_read(), and ast_read_noaudio().
{
struct ast_frame *f = NULL; /* the return value */
int blah;
int prestate;
int cause = 0;
/* this function is very long so make sure there is only one return
* point at the end (there are only two exceptions to this).
*/
if (chan->masq) {
if (ast_do_masquerade(chan))
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
else
f = &ast_null_frame;
return f;
}
/* if here, no masq has happened, lock the channel and proceed */
ast_channel_lock(chan);
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
if (chan->generator)
ast_deactivate_generator(chan);
/*
* It is possible for chan->_softhangup to be set and there
* still be control frames that need to be read. Instead of
* just going to 'done' in the case of ast_check_hangup(), we
* need to queue the end-of-Q frame so that it can mark the end
* of the read queue. If there are frames to be read,
* ast_queue_control() will be called repeatedly, but will only
* queue the first end-of-Q frame.
*/
if (chan->_softhangup) {
ast_queue_control(chan, AST_CONTROL_END_OF_Q);
} else {
goto done;
}
} else {
#ifdef AST_DEVMODE
/*
* The ast_waitfor() code records which of the channel's file
* descriptors reported that data is available. In theory,
* ast_read() should only be called after ast_waitfor() reports
* that a channel has data available for reading. However,
* there still may be some edge cases throughout the code where
* ast_read() is called improperly. This can potentially cause
* problems, so if this is a developer build, make a lot of
* noise if this happens so that it can be addressed.
*
* One of the potential problems is blocking on a dead channel.
*/
if (chan->fdno == -1) {
ast_log(LOG_ERROR,
"ast_read() on chan '%s' called with no recorded file descriptor.\n",
chan->name);
}
#endif
}
prestate = chan->_state;
/* Read and ignore anything on the alertpipe, but read only
one sizeof(blah) per frame that we send from it */
if (chan->alertpipe[0] > -1) {
int flags = fcntl(chan->alertpipe[0], F_GETFL);
/* For some odd reason, the alertpipe occasionally loses nonblocking status,
* which immediately causes a deadlock scenario. Detect and prevent this. */
if ((flags & O_NONBLOCK) == 0) {
ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", chan->name);
if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
f = &ast_null_frame;
goto done;
}
}
if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) {
if (errno != EINTR && errno != EAGAIN)
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
}
if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
enum ast_timer_event res;
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
res = ast_timer_get_event(chan->timer);
switch (res) {
case AST_TIMING_EVENT_EXPIRED:
ast_timer_ack(chan->timer, 1);
if (chan->timingfunc) {
/* save a copy of func/data before unlocking the channel */
int (*func)(const void *) = chan->timingfunc;
void *data = chan->timingdata;
chan->fdno = -1;
ast_channel_unlock(chan);
func(data);
} else {
ast_timer_set_rate(chan->timer, 0);
chan->fdno = -1;
ast_channel_unlock(chan);
}
/* cannot 'goto done' because the channel is already unlocked */
return &ast_null_frame;
case AST_TIMING_EVENT_CONTINUOUS:
if (AST_LIST_EMPTY(&chan->readq) ||
!AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) {
ast_timer_disable_continuous(chan->timer);
}
break;
}
} else if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
/* if the AST_GENERATOR_FD is set, call the generator with args
* set to -1 so it can do whatever it needs to.
*/
void *tmp = chan->generatordata;
chan->generatordata = NULL; /* reset to let ast_write get through */
chan->generator->generate(chan, tmp, -1, -1);
chan->generatordata = tmp;
f = &ast_null_frame;
chan->fdno = -1;
goto done;
}
/* Check for pending read queue */
if (!AST_LIST_EMPTY(&chan->readq)) {
int skip_dtmf = should_skip_dtmf(chan);
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, f, frame_list) {
/* We have to be picky about which frame we pull off of the readq because
* there are cases where we want to leave DTMF frames on the queue until
* some later time. */
if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
continue;
}
AST_LIST_REMOVE_CURRENT(frame_list);
break;
}
AST_LIST_TRAVERSE_SAFE_END;
if (!f) {
/* There were no acceptable frames on the readq. */
f = &ast_null_frame;
if (chan->alertpipe[0] > -1) {
int poke = 0;
/* Restore the state of the alertpipe since we aren't ready for any
* of the frames in the readq. */
if (write(chan->alertpipe[1], &poke, sizeof(poke)) != sizeof(poke)) {
ast_log(LOG_ERROR, "Failed to write to alertpipe: %s\n", strerror(errno));
}
}
}
/* Interpret hangup and end-of-Q frames to return NULL */
/* XXX why not the same for frames from the channel ? */
if (f->frametype == AST_FRAME_CONTROL) {
switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
chan->_softhangup |= AST_SOFTHANGUP_DEV;
cause = f->data.uint32;
/* Fall through */
case AST_CONTROL_END_OF_Q:
ast_frfree(f);
f = NULL;
break;
default:
break;
}
}
} else {
chan->blocker = pthread_self();
if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
if (chan->tech->exception)
f = chan->tech->exception(chan);
else {
ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
f = &ast_null_frame;
}
/* Clear the exception flag */
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
} else if (chan->tech && chan->tech->read)
f = chan->tech->read(chan);
else
ast_log(LOG_WARNING, "No read routine on channel %s\n", chan->name);
}
/*
* Reset the recorded file descriptor that triggered this read so that we can
* easily detect when ast_read() is called without properly using ast_waitfor().
*/
chan->fdno = -1;
/* Perform the framehook read event here. After the frame enters the framehook list
* there is no telling what will happen, <insert mad scientist laugh here>!!! */
f = ast_framehook_list_read_event(chan->framehooks, f);
if (f) {
struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
struct ast_control_read_action_payload *read_action_payload;
struct ast_party_connected_line connected;
/* if the channel driver returned more than one frame, stuff the excess
into the readq for the next ast_read call
*/
if (AST_LIST_NEXT(f, frame_list)) {
ast_queue_frame(chan, AST_LIST_NEXT(f, frame_list));
ast_frfree(AST_LIST_NEXT(f, frame_list));
AST_LIST_NEXT(f, frame_list) = NULL;
}
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass.integer == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP && ast_bridged_channel(chan)) {
ast_debug(1, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
} else {
/* Answer the CDR */
ast_setstate(chan, AST_STATE_UP);
/* removed a call to ast_cdr_answer(chan->cdr) from here. */
ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
}
} else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
read_action_payload = f->data.ptr;
switch (read_action_payload->action) {
case AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO:
ast_party_connected_line_init(&connected);
ast_party_connected_line_copy(&connected, &chan->connected);
if (ast_connected_line_parse_data(read_action_payload->payload,
read_action_payload->payload_size, &connected)) {
ast_party_connected_line_free(&connected);
break;
}
if (ast_channel_connected_line_macro(NULL, chan, &connected, 1, 0)) {
ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE,
read_action_payload->payload,
read_action_payload->payload_size);
}
ast_party_connected_line_free(&connected);
break;
}
ast_frfree(f);
f = &ast_null_frame;
}
break;
case AST_FRAME_DTMF_END:
send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
queue_dtmf_readq(chan, f);
ast_frfree(f);
f = &ast_null_frame;
} else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) {
if (!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
/* If it hasn't been long enough, defer this digit */
queue_dtmf_readq(chan, f);
ast_frfree(f);
f = &ast_null_frame;
} else {
/* There was no begin, turn this into a begin and send the end later */
f->frametype = AST_FRAME_DTMF_BEGIN;
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = f->subclass.integer;
chan->dtmf_tv = ast_tvnow();
if (f->len) {
if (f->len > AST_MIN_DTMF_DURATION)
chan->emulate_dtmf_duration = f->len;
else
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
} else
chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
}
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
/*!
* \todo XXX It is possible to write a digit to the audiohook twice
* if the digit was originally read while the channel was in autoservice. */
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
} else {
struct timeval now = ast_tvnow();
if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
ast_clear_flag(chan, AST_FLAG_IN_DTMF);
if (!f->len)
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
/* detect tones that were received on
* the wire with durations shorter than
* AST_MIN_DTMF_DURATION and set f->len
* to the actual duration of the DTMF
* frames on the wire. This will cause
* dtmf emulation to be triggered later
* on.
*/
if (ast_tvdiff_ms(now, chan->dtmf_tv) < AST_MIN_DTMF_DURATION) {
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
ast_log(LOG_DTMF, "DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->subclass.integer, f->len, chan->name);
}
} else if (!f->len) {
ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
f->len = AST_MIN_DTMF_DURATION;
}
if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = f->subclass.integer;
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
ast_frfree(f);
f = &ast_null_frame;
} else {
ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
if (f->len < AST_MIN_DTMF_DURATION) {
f->len = AST_MIN_DTMF_DURATION;
}
chan->dtmf_tv = now;
}
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
}
break;
case AST_FRAME_DTMF_BEGIN:
send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
(!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
ast_frfree(f);
f = &ast_null_frame;
} else {
ast_set_flag(chan, AST_FLAG_IN_DTMF);
chan->dtmf_tv = ast_tvnow();
ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
}
break;
case AST_FRAME_NULL:
/* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
* is reached , because we want to make sure we pass at least one
* voice frame through before starting the next digit, to ensure a gap
* between DTMF digits. */
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
struct timeval now = ast_tvnow();
if (!chan->emulate_dtmf_duration) {
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
} else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
chan->emulate_dtmf_duration = 0;
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f) {
ast_frfree(old_frame);
}
}
}
}
break;
case AST_FRAME_VOICE:
/* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
* is reached , because we want to make sure we pass at least one
* voice frame through before starting the next digit, to ensure a gap
* between DTMF digits. */
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !chan->emulate_dtmf_duration) {
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
}
if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
if (dropaudio)
ast_read_generator_actions(chan, f);
ast_frfree(f);
f = &ast_null_frame;
}
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
struct timeval now = ast_tvnow();
if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
chan->emulate_dtmf_duration = 0;
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
} else {
/* Drop voice frames while we're still in the middle of the digit */
ast_frfree(f);
f = &ast_null_frame;
}
} else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) {
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
/* Send frame to audiohooks if present */
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
if (old_frame != f)
ast_frfree(old_frame);
}
if (chan->monitor && chan->monitor->read_stream ) {
/* XXX what does this do ? */
#ifndef MONITOR_CONSTANT_DELAY
int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
if (jump >= 0) {
jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
chan->insmpl += (chan->outsmpl - chan->insmpl) + f->samples;
} else
chan->insmpl+= f->samples;
#else
int jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
if (ast_seekstream(chan->monitor->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
chan->insmpl += chan->outsmpl - chan->insmpl;
} else
chan->insmpl += f->samples;
#endif
if (chan->monitor->state == AST_MONITOR_RUNNING) {
if (ast_writestream(chan->monitor->read_stream, f) < 0)
ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n");
}
}
if (chan->readtrans && (f = ast_translate(chan->readtrans, f, 1)) == NULL) {
f = &ast_null_frame;
}
/* it is possible for the translation process on chan->readtrans to have
produced multiple frames from the single input frame we passed it; if
this happens, queue the additional frames *before* the frames we may
have queued earlier. if the readq was empty, put them at the head of
the queue, and if it was not, put them just after the frame that was
at the end of the queue.
*/
if (AST_LIST_NEXT(f, frame_list)) {
if (!readq_tail) {
ast_queue_frame_head(chan, AST_LIST_NEXT(f, frame_list));
} else {
__ast_queue_frame(chan, AST_LIST_NEXT(f, frame_list), 0, readq_tail);
}
ast_frfree(AST_LIST_NEXT(f, frame_list));
AST_LIST_NEXT(f, frame_list) = NULL;
}
/* Run generator sitting on the line if timing device not available
* and synchronous generation of outgoing frames is necessary */
ast_read_generator_actions(chan, f);
}
break;
default:
/* Just pass it on! */
break;
}
} else {
/* Make sure we always return NULL in the future */
if (!chan->_softhangup) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
}
if (cause)
chan->hangupcause = cause;
if (chan->generator)
ast_deactivate_generator(chan);
/* We no longer End the CDR here */
}
/* High bit prints debugging */
if (chan->fin & DEBUGCHAN_FLAG)
ast_frame_dump(chan->name, f, "<<");
chan->fin = FRAMECOUNT_INC(chan->fin);
done:
if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
chan->generator->digit(chan, f->subclass.integer);
if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
/* The list gets recreated if audiohooks are added again later */
ast_audiohook_detach_list(chan->audiohooks);
chan->audiohooks = NULL;
}
ast_channel_unlock(chan);
return f;
}
| struct ast_channel* __ast_request_and_dial | ( | const char * | type, |
| format_t | format, | ||
| const struct ast_channel * | requestor, | ||
| void * | data, | ||
| int | timeout, | ||
| int * | reason, | ||
| const char * | cid_num, | ||
| const char * | cid_name, | ||
| struct outgoing_helper * | oh | ||
| ) | [read] |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
| type | type of channel to request |
| format | requested channel format |
| requestor | channel requesting data |
| data | data to pass to the channel requester |
| timeout | maximum amount of time to wait for an answer |
| reason | why unsuccessful (if unsuccessful) |
| cid_num | Caller-ID Number |
| cid_name | Caller-ID Name (ascii) |
| oh | Outgoing helper |
Definition at line 5306 of file channel.c.
References ast_channel::_state, outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_cdr_alloc(), ast_cdr_answer(), ast_cdr_busy(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_failed(), AST_CDR_FLAG_ORIGINATED, ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_setapp(), ast_cdr_start(), ast_cdr_update(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_set_connected_line(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), ast_party_connected_line_set_init(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_read(), ast_request(), ast_set_flag, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_waitfor(), ast_channel::call_forward, cause, ast_channel::cdr, chanlist::chan, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, f, ast_frame::frametype, handle_cause(), ast_channel::hangupcause, ast_party_connected_line::id, ast_frame_subclass::integer, LOG_NOTICE, ast_party_id::name, ast_party_id::number, outgoing_helper::parent_channel, ast_party_name::presentation, ast_party_number::presentation, ast_channel::priority, outgoing_helper::priority, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, ast_party_number::valid, and outgoing_helper::vars.
Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().
{
int dummy_outstate;
int cause = 0;
struct ast_channel *chan;
int res = 0;
int last_subclass = 0;
struct ast_party_connected_line connected;
if (outstate)
*outstate = 0;
else
outstate = &dummy_outstate; /* make outstate always a valid pointer */
chan = ast_request(type, format, requestor, data, &cause);
if (!chan) {
ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
handle_cause(cause, outstate);
return NULL;
}
if (oh) {
if (oh->vars) {
ast_set_variables(chan, oh->vars);
}
if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
/*
* Use the oh values instead of the function parameters for the
* outgoing CallerID.
*/
cid_num = oh->cid_num;
cid_name = oh->cid_name;
}
if (oh->parent_channel) {
/* Safely inherit variables and datastores from the parent channel. */
ast_channel_lock_both(oh->parent_channel, chan);
ast_channel_inherit_variables(oh->parent_channel, chan);
ast_channel_datastore_inherit(oh->parent_channel, chan);
ast_channel_unlock(oh->parent_channel);
ast_channel_unlock(chan);
}
if (oh->account) {
ast_channel_lock(chan);
ast_cdr_setaccount(chan, oh->account);
ast_channel_unlock(chan);
}
}
ast_set_flag(chan->cdr, AST_CDR_FLAG_ORIGINATED);
ast_party_connected_line_set_init(&connected, &chan->connected);
if (cid_num) {
connected.id.number.valid = 1;
connected.id.number.str = (char *) cid_num;
connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
}
if (cid_name) {
connected.id.name.valid = 1;
connected.id.name.str = (char *) cid_name;
connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
}
ast_channel_set_connected_line(chan, &connected, NULL);
if (ast_call(chan, data, 0)) { /* ast_call failed... */
ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
} else {
res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
while (timeout && chan->_state != AST_STATE_UP) {
struct ast_frame *f;
res = ast_waitfor(chan, timeout);
if (res == 0) { /* timeout, treat it like ringing */
*outstate = AST_CONTROL_RINGING;
break;
}
if (res < 0) /* error or done */
break;
if (timeout > -1)
timeout = res;
if (!ast_strlen_zero(chan->call_forward)) {
if (!(chan = ast_call_forward(NULL, chan, NULL, format, oh, outstate))) {
return NULL;
}
continue;
}
f = ast_read(chan);
if (!f) {
*outstate = AST_CONTROL_HANGUP;
res = 0;
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
switch (f->subclass.integer) {
case AST_CONTROL_RINGING: /* record but keep going */
*outstate = f->subclass.integer;
break;
case AST_CONTROL_BUSY:
ast_cdr_busy(chan->cdr);
*outstate = f->subclass.integer;
timeout = 0;
break;
case AST_CONTROL_INCOMPLETE:
ast_cdr_failed(chan->cdr);
*outstate = AST_CONTROL_CONGESTION;
timeout = 0;
break;
case AST_CONTROL_CONGESTION:
ast_cdr_failed(chan->cdr);
*outstate = f->subclass.integer;
timeout = 0;
break;
case AST_CONTROL_ANSWER:
ast_cdr_answer(chan->cdr);
*outstate = f->subclass.integer;
timeout = 0; /* trick to force exit from the while() */
break;
/* Ignore these */
case AST_CONTROL_PROGRESS:
case AST_CONTROL_PROCEEDING:
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_CONNECTED_LINE:
case AST_CONTROL_REDIRECTING:
case AST_CONTROL_CC:
case -1: /* Ignore -- just stopping indications */
break;
default:
ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
}
last_subclass = f->subclass.integer;
}
ast_frfree(f);
}
}
/* Final fixups */
if (oh) {
if (!ast_strlen_zero(oh->context))
ast_copy_string(chan->context, oh->context, sizeof(chan->context));
if (!ast_strlen_zero(oh->exten))
ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
if (oh->priority)
chan->priority = oh->priority;
}
if (chan->_state == AST_STATE_UP)
*outstate = AST_CONTROL_ANSWER;
if (res <= 0) {
ast_channel_lock(chan);
if (AST_CONTROL_RINGING == last_subclass) {
chan->hangupcause = AST_CAUSE_NO_ANSWER;
}
if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
ast_cdr_init(chan->cdr, chan);
}
if (chan->cdr) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data);
ast_cdr_setapp(chan->cdr, "Dial", tmp);
ast_cdr_update(chan);
ast_cdr_start(chan->cdr);
ast_cdr_end(chan->cdr);
/* If the cause wasn't handled properly */
if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) {
ast_cdr_failed(chan->cdr);
}
}
ast_channel_unlock(chan);
ast_hangup(chan);
chan = NULL;
}
return chan;
}
| static void adjust_frame_for_plc | ( | struct ast_channel * | chan, |
| struct ast_frame * | frame, | ||
| struct ast_datastore * | datastore | ||
| ) | [static] |
Definition at line 4688 of file channel.c.
References ast_calloc, ast_channel_datastore_remove(), ast_datastore_free(), ast_free, AST_FRIENDLY_OFFSET, ast_datastore::data, ast_frame::data, ast_frame::datalen, plc_ds::num_samples, ast_frame::offset, plc_fillin(), plc_rx(), plc_ds::plc_state, ast_frame::ptr, ast_frame::samples, and plc_ds::samples_buf.
Referenced by apply_plc().
{
int num_new_samples = frame->samples;
struct plc_ds *plc = datastore->data;
/* As a general note, let me explain the somewhat odd calculations used when taking
* the frame offset into account here. According to documentation in frame.h, the frame's
* offset field indicates the number of bytes that the audio is offset. The plc->samples_buf
* is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN
* samples. So I had two choices to make here with the offset.
*
* 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that
* I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer
* arithmetic come out right. I would have to do some odd casting or division for this to
* work as I wanted.
* 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic
* to work out better with the plc->samples_buf. The downside here is that the buffer's
* allocation contains an extra 64 bytes of unused space.
*
* I decided to go with option 2. This is why in the calloc statement and the statement that
* sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2.
*/
/* If this audio frame has no samples to fill in, ignore it */
if (!num_new_samples) {
return;
}
/* First, we need to be sure that our buffer is large enough to accomodate
* the samples we need to fill in. This will likely only occur on the first
* frame we write.
*/
if (plc->num_samples < num_new_samples) {
ast_free(plc->samples_buf);
plc->samples_buf = ast_calloc(1, (num_new_samples * sizeof(*plc->samples_buf)) + (AST_FRIENDLY_OFFSET * 2));
if (!plc->samples_buf) {
ast_channel_datastore_remove(chan, datastore);
ast_datastore_free(datastore);
return;
}
plc->num_samples = num_new_samples;
}
if (frame->datalen == 0) {
plc_fillin(&plc->plc_state, plc->samples_buf + AST_FRIENDLY_OFFSET, frame->samples);
frame->data.ptr = plc->samples_buf + AST_FRIENDLY_OFFSET;
frame->datalen = num_new_samples * 2;
frame->offset = AST_FRIENDLY_OFFSET * 2;
} else {
plc_rx(&plc->plc_state, frame->data.ptr, frame->samples);
}
}
| static void apply_plc | ( | struct ast_channel * | chan, |
| struct ast_frame * | frame | ||
| ) | [static] |
Definition at line 4741 of file channel.c.
References adjust_frame_for_plc(), ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc(), ast_datastore_free(), and ast_datastore::data.
Referenced by ast_write().
{
struct ast_datastore *datastore;
struct plc_ds *plc;
datastore = ast_channel_datastore_find(chan, &plc_ds_info, NULL);
if (datastore) {
plc = datastore->data;
adjust_frame_for_plc(chan, frame, datastore);
return;
}
datastore = ast_datastore_alloc(&plc_ds_info, NULL);
if (!datastore) {
return;
}
plc = ast_calloc(1, sizeof(*plc));
if (!plc) {
ast_datastore_free(datastore);
return;
}
datastore->data = plc;
ast_channel_datastore_add(chan, datastore);
adjust_frame_for_plc(chan, frame, datastore);
}
| int ast_activate_generator | ( | struct ast_channel * | chan, |
| struct ast_generator * | gen, | ||
| void * | params | ||
| ) |
Activate a given generator
Definition at line 3074 of file channel.c.
References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), gen, ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.
Referenced by app_exec(), ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), eivr_comm(), local_ast_moh_start(), old_milliwatt_exec(), and transmit_audio().
{
int res = 0;
ast_channel_lock(chan);
if (chan->generatordata) {
if (chan->generator && chan->generator->release)
chan->generator->release(chan, chan->generatordata);
chan->generatordata = NULL;
}
if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
res = -1;
}
if (!res) {
ast_settimeout(chan, 50, generator_force, chan);
chan->generator = gen;
}
ast_channel_unlock(chan);
ast_prod(chan);
return res;
}
| int ast_active_channels | ( | void | ) |
returns number of active/allocated channels
Definition at line 832 of file channel.c.
References ao2_container_count(), and channels.
Referenced by action_corestatus(), ast_var_channels(), ast_var_channels_table(), dahdi_restart(), handle_chanlist(), handle_show_settings(), and quit_handler().
{
return channels ? ao2_container_count(channels) : 0;
}
| int ast_answer | ( | struct ast_channel * | chan | ) |
Answer a channel.
| chan | channel to answer |
This function answers a channel and handles all necessary call setup functions.
| 0 | on success |
| non-zero | on failure |
Definition at line 3024 of file channel.c.
References __ast_answer().
Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_do_pickup(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), builtin_parkcall(), common_exec(), conf_exec(), count_exec(), dahdiras_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), login_exec(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_call_exec(), parked_call_exec(), pbx_builtin_background(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), receivefax_exec(), record_exec(), rpt_exec(), sayunixtime_exec(), send_waveform_to_channel(), sendfax_exec(), setup_privacy_args(), skel_exec(), sla_station_exec(), speech_background(), testclient_exec(), testserver_exec(), transmit(), vm_exec(), vm_execmain(), waitfor_exec(), and zapateller_exec().
{
return __ast_answer(chan, 0, 1);
}
| void ast_begin_shutdown | ( | int | hangup | ) |
Initiate system shutdown -- prevents new channels from being allocated.
| hangup | If "hangup" is non-zero, all existing channels will receive soft hangups |
Definition at line 822 of file channel.c.
References ao2_callback, ast_channel_softhangup_cb(), channels, OBJ_MULTIPLE, and OBJ_NODATA.
Referenced by quit_handler().
{
shutting_down = 1;
if (hangup) {
ao2_callback(channels, OBJ_NODATA | OBJ_MULTIPLE, ast_channel_softhangup_cb, NULL);
}
}
Pick the best audio codec.
Pick the best codec Choose the best codec... Uhhh... Yah.
Okay, ulaw is used by all telephony equipment, so start with it
Unless of course, you're a silly European, so then prefer ALAW
G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority
Okay, well, signed linear is easy to translate into other stuff
G.726 is standard ADPCM, in RFC3551 packing order
G.726 is standard ADPCM, in AAL2 packing order
ADPCM has great sound quality and is still pretty easy to translate
Okay, we're down to vocoders now, so pick GSM because it's small and easier to translate and sounds pretty good
iLBC is not too bad
Speex is free, but computationally more expensive than GSM
Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough to use it
G.729a is faster than 723 and slightly less expensive
Down to G.723.1 which is proprietary but at least designed for voice
Definition at line 1041 of file channel.c.
References ARRAY_LEN, AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_AUDIO_MASK, AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_TESTLAW, AST_FORMAT_ULAW, ast_getformatname_multiple(), ast_log(), LOG_WARNING, and prefs.
Referenced by __oh323_new(), agent_call(), ast_codec_choose(), ast_iax2_new(), ast_speech_new(), bridge_make_compatible(), builtin_atxfer(), echo_exec(), findmeexec(), gtalk_new(), handle_open_receive_channel_ack_message(), iax2_request(), jingle_new(), local_new(), login_exec(), mgcp_new(), multicast_rtp_request(), set_format(), sip_new(), skinny_new(), skinny_set_rtp_peer(), socket_process(), start_rtp(), transmit_connect(), and unistim_new().
{
/* This just our opinion, expressed in code. We are asked to choose
the best codec to use, given no information */
int x;
static const format_t prefs[] =
{
/*! Okay, ulaw is used by all telephony equipment, so start with it */
AST_FORMAT_ULAW,
/*! Unless of course, you're a silly European, so then prefer ALAW */
AST_FORMAT_ALAW,
AST_FORMAT_G719,
AST_FORMAT_SIREN14,
AST_FORMAT_SIREN7,
AST_FORMAT_TESTLAW,
/*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
AST_FORMAT_G722,
/*! Okay, well, signed linear is easy to translate into other stuff */
AST_FORMAT_SLINEAR16,
AST_FORMAT_SLINEAR,
/*! G.726 is standard ADPCM, in RFC3551 packing order */
AST_FORMAT_G726,
/*! G.726 is standard ADPCM, in AAL2 packing order */
AST_FORMAT_G726_AAL2,
/*! ADPCM has great sound quality and is still pretty easy to translate */
AST_FORMAT_ADPCM,
/*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to
translate and sounds pretty good */
AST_FORMAT_GSM,
/*! iLBC is not too bad */
AST_FORMAT_ILBC,
/*! Speex is free, but computationally more expensive than GSM */
AST_FORMAT_SPEEX16,
AST_FORMAT_SPEEX,
/*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
to use it */
AST_FORMAT_LPC10,
/*! G.729a is faster than 723 and slightly less expensive */
AST_FORMAT_G729A,
/*! Down to G.723.1 which is proprietary but at least designed for voice */
AST_FORMAT_G723_1,
};
char buf[512];
/* Strip out video */
fmts &= AST_FORMAT_AUDIO_MASK;
/* Find the first preferred codec in the format given */
for (x = 0; x < ARRAY_LEN(prefs); x++) {
if (fmts & prefs[x])
return prefs[x];
}
ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
return 0;
}
| struct ast_channel* ast_bridged_channel | ( | struct ast_channel * | chan | ) | [read] |
Find bridged channel.
| chan | Current channel |
Definition at line 6910 of file channel.c.
References ast_channel::_bridge, ast_channel_tech::bridged_channel, and ast_channel::tech.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_channel_masquerade(), __ast_read(), __dahdi_exception(), _skinny_show_lines(), action_agents(), action_coreshowchannels(), agents_data_provider_get(), agents_show(), agents_show_online(), analog_attempt_transfer(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_bridge_call(), ast_cel_report_event(), ast_channel_data_add_structure(), ast_channel_set_linkgroup(), ast_do_masquerade(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_var_channel_bridge(), ast_var_channels_table(), attempt_transfer(), cb_events(), channel_spy(), check_bridge(), common_exec(), console_transfer(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), func_channel_read(), get_refer_info(), handle_chanlist(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_refer(), handle_showchan(), handle_soft_key_event_message(), handle_stimulus_message(), key_call(), key_dial_page(), local_attended_transfer(), local_queryoption(), mgcp_hangup(), mgcp_ss(), misdn_attempt_transfer(), mixmonitor_thread(), my_get_sigpvt_bridged_channel(), park_call_full(), pri_dchannel(), schedule_delivery(), serialize_showchan(), sig_pri_attempt_transfer(), sig_pri_handle_hold(), sip_hangup(), sip_set_rtp_peer(), skinny_transfer(), socket_process(), start_spying(), startmon(), TransferCallStep1(), and unistim_hangup().
{
struct ast_channel *bridged;
bridged = chan->_bridge;
if (bridged && bridged->tech->bridged_channel)
bridged = bridged->tech->bridged_channel(chan, bridged);
return bridged;
}
| int ast_call | ( | struct ast_channel * | chan, |
| char * | addr, | ||
| int | timeout | ||
| ) |
Make a call.
| chan | which channel to make the call on |
| addr | destination of the call |
| timeout | time to wait on for connect |
Place a call, take no longer than timeout ms.
Definition at line 5600 of file channel.c.
References AST_CDR_FLAG_DIALED, ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, ast_channel_tech::call, ast_channel::cdr, and ast_channel::tech.
Referenced by __ast_request_and_dial(), ast_call_forward(), attempt_reconnect(), begin_dial_channel(), connect_link(), dial_exec_full(), dial_transfer(), do_forward(), do_idle_thread(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), rpt(), rpt_exec(), and wait_for_answer().
{
/* Place an outgoing call, but don't wait any longer than timeout ms before returning.
If the remote end does not answer within the timeout, then do NOT hang up, but
return anyway. */
int res = -1;
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
if (chan->cdr) {
ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED);
}
if (chan->tech->call)
res = chan->tech->call(chan, addr, timeout);
ast_set_flag(chan, AST_FLAG_OUTGOING);
}
ast_channel_unlock(chan);
return res;
}
| struct ast_channel* ast_call_forward | ( | struct ast_channel * | caller, |
| struct ast_channel * | orig, | ||
| int * | timeout, | ||
| format_t | format, | ||
| struct outgoing_helper * | oh, | ||
| int * | outstate | ||
| ) | [read] |
Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated.
| caller | in channel that requested orig |
| orig | channel being replaced by the call forward channel |
| timeout | maximum amount of time to wait for setup of new forward channel |
| format | requested channel format |
| oh | outgoing helper used with original channel |
| outstate | reason why unsuccessful (if uncuccessful) |
Definition at line 5236 of file channel.c.
References outgoing_helper::account, accountcode, ast_channel::accountcode, ast_call(), AST_CDR_FLAG_ORIGINATED, ast_cdr_setaccount(), ast_channel_lock, ast_channel_lock_both, ast_channel_unlock, ast_copy_flags, ast_copy_string(), ast_hangup(), ast_log(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), ast_request(), ast_set_variables(), ast_string_field_set, ast_channel::call_forward, call_forward_inherit(), cause, ast_channel::cdr, ast_channel::connected, ast_channel::context, ast_channel::data, handle_cause(), LOG_NOTICE, outgoing_helper::parent_channel, pbx_builtin_getvar_helper(), ast_channel::redirecting, S_OR, type, and outgoing_helper::vars.
Referenced by __ast_request_and_dial(), and feature_request_and_dial().
{
char tmpchan[256];
struct ast_channel *new_chan = NULL;
char *data, *type;
int cause = 0;
int res;
/* gather data and request the new forward channel */
ast_copy_string(tmpchan, orig->call_forward, sizeof(tmpchan));
if ((data = strchr(tmpchan, '/'))) {
*data++ = '\0';
type = tmpchan;
} else {
const char *forward_context;
ast_channel_lock(orig);
forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
snprintf(tmpchan, sizeof(tmpchan), "%s@%s", orig->call_forward, S_OR(forward_context, orig->context));
ast_channel_unlock(orig);
data = tmpchan;
type = "Local";
}
if (!(new_chan = ast_request(type, format, orig, data, &cause))) {
ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
handle_cause(cause, outstate);
ast_hangup(orig);
return NULL;
}
/* Copy/inherit important information into new channel */
if (oh) {
if (oh->vars) {
ast_set_variables(new_chan, oh->vars);
}
if (oh->parent_channel) {
call_forward_inherit(new_chan, oh->parent_channel, orig);
}
if (oh->account) {
ast_channel_lock(new_chan);
ast_cdr_setaccount(new_chan, oh->account);
ast_channel_unlock(new_chan);
}
} else if (caller) { /* no outgoing helper so use caller if avaliable */
call_forward_inherit(new_chan, caller, orig);
}
ast_channel_lock_both(orig, new_chan);
ast_copy_flags(new_chan->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED);
ast_string_field_set(new_chan, accountcode, orig->accountcode);
ast_party_connected_line_copy(&new_chan->connected, &orig->connected);
ast_party_redirecting_copy(&new_chan->redirecting, &orig->redirecting);
ast_channel_unlock(new_chan);
ast_channel_unlock(orig);
/* call new channel */
res = ast_call(new_chan, data, 0);
if (timeout) {
*timeout = res;
}
if (res) {
ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
ast_hangup(orig);
ast_hangup(new_chan);
return NULL;
}
ast_hangup(orig);
return new_chan;
}
| void ast_cancel_shutdown | ( | void | ) |
Cancel a shutdown in progress.
Cancels an existing shutdown and returns to normal operation
Definition at line 838 of file channel.c.
Referenced by handle_abort_shutdown().
{
shutting_down = 0;
}
| const char* ast_cause2str | ( | int | cause | ) |
Gives the string form of a given hangup cause.
Gives the string form of a given cause code.
Definition at line 959 of file channel.c.
References ARRAY_LEN, and causes.
Referenced by __transmit_response(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_hangup(), dial_exec_full(), findmeexec(), sip_hangup(), and transmit_request_with_auth().
| void ast_change_name | ( | struct ast_channel * | chan, |
| const char * | newname | ||
| ) |
Change channel name.
| chan | the channel to change the name of |
| newname | the name to change to |
Definition at line 6068 of file channel.c.
References __ast_change_name_nolink(), ao2_link, ao2_unlink, ast_channel_lock, ast_channel_unlock, and channels.
Referenced by update_name().
{
/* We must re-link, as the hash value will change here. */
ao2_unlink(channels, chan);
ast_channel_lock(chan);
__ast_change_name_nolink(chan, newname);
ast_channel_unlock(chan);
ao2_link(channels, chan);
}
| struct ast_channel * ast_channel_alloc | ( | int | needqueue, |
| int | state, | ||
| const char * | cid_num, | ||
| const char * | cid_name, | ||
| const char * | acctcode, | ||
| const char * | exten, | ||
| const char * | context, | ||
| const char * | linkedid, | ||
| const int | amaflag, | ||
| const char * | name_fmt, | ||
| ... | |||
| ) | [read] |
Definition at line 9508 of file channel.c.
References __ast_channel_alloc_ap().
Referenced by __oh323_new(), action_bridge(), agent_new(), alsa_new(), ast_async_goto(), ast_iax2_new(), ast_pbx_outgoing_exten(), bridge_exec(), bridge_request(), builtin_atxfer(), check_goto_on_transfer(), console_new(), dahdi_new(), do_notify(), gtalk_new(), iax_park(), jingle_new(), local_new(), masq_park_call(), mgcp_new(), misdn_new(), multicast_rtp_request(), nbs_new(), oss_new(), phone_new(), sip_new(), sip_park(), skinny_new(), unistim_new(), and usbradio_new().
{
va_list ap1, ap2;
struct ast_channel *result;
va_start(ap1, name_fmt);
va_start(ap2, name_fmt);
result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
linkedid, amaflag, __FILE__, __LINE__, __FUNCTION__, name_fmt, ap1, ap2);
va_end(ap1);
va_end(ap2);
return result;
}
| enum ast_bridge_result ast_channel_bridge | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1, | ||
| struct ast_bridge_config * | config, | ||
| struct ast_frame ** | fo, | ||
| struct ast_channel ** | rc | ||
| ) |
Bridge two channels together.
| c0 | first channel to bridge |
| c1 | second channel to bridge |
| config | config for the channels |
| fo | destination frame(?) |
| rc | destination channel(?) |
Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in *rf (remember, it could be NULL) and which channel (0 or 1) in rc
Definition at line 7253 of file channel.c.
References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, AST_BRIDGE_RETRY, ast_channel_clear_softhangup(), ast_channel_make_compatible(), ast_check_hangup(), ast_check_hangup_locked(), ast_clear_flag, AST_CONTROL_SRCUPDATE, ast_debug, AST_FEATURE_PLAY_WARNING, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_framehook_list_is_empty(), ast_generic_bridge(), ast_indicate(), ast_log(), ast_manager_event_multichan, ast_samp2tv(), ast_set_flag, ast_set_owners_and_peers(), AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verb, ast_channel::audiohooks, ast_channel_tech::bridge, bridge_play_sounds(), bridge_playfile(), ast_channel::caller, ast_bridge_config::end_sound, EVENT_FLAG_CALL, ast_bridge_config::feature_start_time, ast_bridge_config::feature_timer, ast_bridge_config::features_callee, ast_bridge_config::features_caller, ast_bridge_config::flags, ast_channel::framehooks, ast_channel::generator, ast_party_caller::id, LOG_WARNING, manager_bridge_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_party_id::number, ast_bridge_config::play_warning, ast_channel::readformat, S_COR, ast_channel_tech::send_digit_begin, ast_bridge_config::start_sound, ast_bridge_config::start_time, ast_party_number::str, ast_channel::tech, ast_bridge_config::timelimit, ast_channel::uniqueid, update_bridge_vars(), ast_party_number::valid, ast_bridge_config::warning_freq, ast_bridge_config::warning_sound, and ast_channel::writeformat.
Referenced by ast_bridge_call().
{
struct ast_channel *chans[2] = { c0, c1 };
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
format_t o0nativeformats;
format_t o1nativeformats;
long time_left_ms=0;
char caller_warning = 0;
char callee_warning = 0;
*fo = NULL;
if (c0->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
c0->name, c0->_bridge->name);
return -1;
}
if (c1->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
c1->name, c1->_bridge->name);
return -1;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
return -1;
caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING);
callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING);
if (ast_tvzero(config->start_time)) {
config->start_time = ast_tvnow();
if (config->start_sound) {
if (caller_warning) {
bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000);
}
if (callee_warning) {
bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000);
}
}
}
/* Keep track of bridge */
c0->_bridge = c1;
c1->_bridge = c0;
ast_set_owners_and_peers(c0, c1);
o0nativeformats = c0->nativeformats;
o1nativeformats = c1->nativeformats;
if (config->feature_timer && !ast_tvzero(config->nexteventts)) {
config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000));
} else if (config->timelimit) {
time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time);
config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
if ((caller_warning || callee_warning) && config->play_warning) {
long next_warn = config->play_warning;
if (time_left_ms < config->play_warning && config->warning_freq > 0) {
/* At least one warning was played, which means we are returning after feature */
long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq;
/* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq',
because nexteventts will be updated once again in the 'if (!to)' block */
next_warn = config->play_warning - warns_passed * config->warning_freq;
}
config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000));
}
} else {
config->nexteventts.tv_sec = 0;
config->nexteventts.tv_usec = 0;
}
if (!c0->tech->send_digit_begin)
ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY);
if (!c1->tech->send_digit_begin)
ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY);
manager_bridge_event(1, 1, c0, c1);
/* Before we enter in and bridge these two together tell them both the source of audio has changed */
ast_indicate(c0, AST_CONTROL_SRCUPDATE);
ast_indicate(c1, AST_CONTROL_SRCUPDATE);
for (/* ever */;;) {
struct timeval now = { 0, };
int to;
to = -1;
if (!ast_tvzero(config->nexteventts)) {
now = ast_tvnow();
to = ast_tvdiff_ms(config->nexteventts, now);
if (to <= 0) {
if (!config->timelimit) {
res = AST_BRIDGE_COMPLETE;
break;
}
to = 0;
}
}
if (config->timelimit) {
time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
if (time_left_ms < to)
to = time_left_ms;
if (time_left_ms <= 0) {
if (caller_warning && config->end_sound)
bridge_playfile(c0, c1, config->end_sound, 0);
if (callee_warning && config->end_sound)
bridge_playfile(c1, c0, config->end_sound, 0);
*fo = NULL;
res = 0;
break;
}
if (!to) {
if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
int t = (time_left_ms + 500) / 1000; /* round to nearest second */
if (caller_warning)
bridge_playfile(c0, c1, config->warning_sound, t);
if (callee_warning)
bridge_playfile(c1, c0, config->warning_sound, t);
}
if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) {
config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000));
} else {
config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
}
}
ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE);
}
if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
if (c0->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
}
if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
c0->_bridge = c1;
c1->_bridge = c0;
ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
continue;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) {
*fo = NULL;
res = 0;
ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
c0->name, c1->name,
ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
ast_check_hangup(c0) ? "Yes" : "No",
ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
ast_check_hangup(c1) ? "Yes" : "No");
break;
}
update_bridge_vars(c0, c1);
bridge_play_sounds(c0, c1);
if (c0->tech->bridge &&
/* if < 1 ms remains use generic bridging for accurate timing */
(!config->timelimit || to > 1000 || to == 0) &&
(c0->tech->bridge == c1->tech->bridge) &&
!c0->monitor && !c1->monitor &&
!c0->audiohooks && !c1->audiohooks &&
ast_framehook_list_is_empty(c0->framehooks) && ast_framehook_list_is_empty(c1->framehooks) &&
!c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
int timeoutms = to - 1000 > 0 ? to - 1000 : to;
/* Looks like they share a bridge method and nothing else is in the way */
ast_set_flag(c0, AST_FLAG_NBRIDGE);
ast_set_flag(c1, AST_FLAG_NBRIDGE);
if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
"Channel1: %s\r\n"
"Channel2: %s\r\n"
"Uniqueid1: %s\r\n"
"Uniqueid2: %s\r\n"
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name,
c0->uniqueid, c1->uniqueid,
S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
continue;
}
c0->_bridge = NULL;
c1->_bridge = NULL;
return res;
} else {
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
}
switch (res) {
case AST_BRIDGE_RETRY:
if (config->play_warning) {
ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE);
}
continue;
default:
ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name);
/* fallthrough */
case AST_BRIDGE_FAILED_NOWARN:
break;
}
}
if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) ||
(c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) &&
!(c0->generator || c1->generator)) {
if (ast_channel_make_compatible(c0, c1)) {
ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name);
manager_bridge_event(0, 1, c0, c1);
return AST_BRIDGE_FAILED;
}
o0nativeformats = c0->nativeformats;
o1nativeformats = c1->nativeformats;
}
update_bridge_vars(c0, c1);
res = ast_generic_bridge(c0, c1, config, fo, rc);
if (res != AST_BRIDGE_RETRY) {
break;
} else if (config->feature_timer) {
/* feature timer expired but has not been updated, sending to ast_bridge_call to do so */
break;
}
}
ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY);
ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY);
/* Now that we have broken the bridge the source will change yet again */
ast_indicate(c0, AST_CONTROL_SRCUPDATE);
ast_indicate(c1, AST_CONTROL_SRCUPDATE);
c0->_bridge = NULL;
c1->_bridge = NULL;
ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
"Channel1: %s\r\n"
"Channel2: %s\r\n"
"Uniqueid1: %s\r\n"
"Uniqueid2: %s\r\n"
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name,
c0->uniqueid, c1->uniqueid,
S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
}
| struct ast_channel* ast_channel_callback | ( | ao2_callback_data_fn * | cb_fn, |
| void * | arg, | ||
| void * | data, | ||
| int | ao2_flags | ||
| ) | [read] |
Call a function with every active channel.
This function executes a callback one time for each active channel on the system. The channel is provided as an argument to the function.
Definition at line 1595 of file channel.c.
References ao2_callback_data, and channels.
Referenced by ast_cel_check_retire_linkedid(), ast_pickup_call(), handle_core_set_debug_channel(), my_ast_get_channel_by_name_locked(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), and state_notify_build_xml().
{
return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
}
| int ast_channel_cc_params_init | ( | struct ast_channel * | chan, |
| const struct ast_cc_config_params * | base_params | ||
| ) |
Set up datastore with CCSS parameters for a channel.
This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function.
| chan | The channel to create the datastore on |
| base_params | CCSS parameters we wish to copy into the channel |
| 0 | Success |
| -1 | Failure |
Definition at line 9414 of file channel.c.
References ast_cc_config_params_destroy(), ast_cc_config_params_init, ast_cc_copy_config_params(), ast_channel_datastore_add(), ast_datastore_alloc(), and ast_datastore::data.
Referenced by ast_channel_get_cc_config_params(), dahdi_new(), local_call(), local_request(), and sip_new().
{
struct ast_cc_config_params *cc_params;
struct ast_datastore *cc_datastore;
if (!(cc_params = ast_cc_config_params_init())) {
return -1;
}
if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
ast_cc_config_params_destroy(cc_params);
return -1;
}
if (base_params) {
ast_cc_copy_config_params(cc_params, base_params);
}
cc_datastore->data = cc_params;
ast_channel_datastore_add(chan, cc_datastore);
return 0;
}
| static void ast_channel_change_linkedid | ( | struct ast_channel * | chan, |
| const char * | linkedid | ||
| ) | [static] |
Set the channel's linkedid to the given string, and also check to see if the channel's old linkedid is now being retired
Definition at line 6207 of file channel.c.
References ast_cel_check_retire_linkedid(), ast_string_field_set, ast_strlen_zero(), and ast_channel::linkedid.
Referenced by ast_channel_set_linkgroup().
{
/* if the linkedid for this channel is being changed from something, check... */
if (!ast_strlen_zero(chan->linkedid) && 0 != strcmp(chan->linkedid, linkedid)) {
ast_cel_check_retire_linkedid(chan);
}
ast_string_field_set(chan, linkedid, linkedid);
}
| void ast_channel_clear_softhangup | ( | struct ast_channel * | chan, |
| int | flag | ||
| ) |
Clear a set of softhangup flags from a channel.
Never clear a softhangup flag from a channel directly. Instead, use this function. This ensures that all aspects of the softhangup process are aborted.
| chan | the channel to clear the flag on |
| flag | the flag or flags to clear |
Definition at line 2652 of file channel.c.
References ast_channel::_softhangup, ast_channel_lock, ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_FRAME_CONTROL, ast_frfree, AST_LIST_LAST, AST_LIST_REMOVE, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::readq, and ast_frame::subclass.
Referenced by __ast_pbx_run(), ast_channel_bridge(), ast_generic_bridge(), check_goto_on_transfer(), and collect_digits().
{
ast_channel_lock(chan);
chan->_softhangup &= ~flag;
if (!chan->_softhangup) {
struct ast_frame *fr;
/* If we have completely cleared the softhangup flag,
* then we need to fully abort the hangup process. This requires
* pulling the END_OF_Q frame out of the channel frame queue if it
* still happens to be there. */
fr = AST_LIST_LAST(&chan->readq);
if (fr && fr->frametype == AST_FRAME_CONTROL &&
fr->subclass.integer == AST_CONTROL_END_OF_Q) {
AST_LIST_REMOVE(&chan->readq, fr, frame_list);
ast_frfree(fr);
}
}
ast_channel_unlock(chan);
}
| static int ast_channel_cmp_cb | ( | void * | obj, |
| void * | arg, | ||
| int | flags | ||
| ) | [static] |
Definition at line 1681 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strlen_zero(), CMP_MATCH, ast_channel::context, ast_channel::exten, ast_channel::macrocontext, ast_channel::macroexten, ast_channel::name, and ast_channel::uniqueid.
Referenced by ast_channels_init().
{
struct ast_channel *chan = obj, *cmp_args = arg;
size_t name_len;
int ret = CMP_MATCH;
/* This is sort of a hack. Basically, we're using an arbitrary field
* in ast_channel to pass the name_len for a prefix match. If this
* gets changed, then the uses of ao2_find() must be changed, too. */
name_len = cmp_args->rings;
ast_channel_lock(chan);
if (!ast_strlen_zero(cmp_args->name)) { /* match by name */
if ((!name_len && strcasecmp(chan->name, cmp_args->name)) ||
(name_len && strncasecmp(chan->name, cmp_args->name, name_len))) {
ret = 0; /* name match failed */
}
} else if (!ast_strlen_zero(cmp_args->exten)) {
if (cmp_args->context && strcasecmp(chan->context, cmp_args->context) &&
strcasecmp(chan->macrocontext, cmp_args->context)) {
ret = 0; /* context match failed */
}
if (ret && strcasecmp(chan->exten, cmp_args->exten) &&
strcasecmp(chan->macroexten, cmp_args->exten)) {
ret = 0; /* exten match failed */
}
} else if (!ast_strlen_zero(cmp_args->uniqueid)) {
if ((!name_len && strcasecmp(chan->uniqueid, cmp_args->uniqueid)) ||
(name_len && strncasecmp(chan->uniqueid, cmp_args->uniqueid, name_len))) {
ret = 0; /* uniqueid match failed */
}
} else {
ret = 0;
}
ast_channel_unlock(chan);
return ret;
}
| int ast_channel_cmpwhentohangup | ( | struct ast_channel * | chan, |
| time_t | offset | ||
| ) |
Compare a offset with the settings of when to hang a channel up.
| chan | channel on which to check for hang up |
| offset | offset in seconds from current time |
This function compares a offset from current time with the absolute time out on a channel (when to hang up). If the absolute time out on a channel is earlier than current time plus the offset, it returns 1, if the two time values are equal, it return 0, otherwise, it return -1.
Definition at line 879 of file channel.c.
References ast_channel_cmpwhentohangup_tv().
{
struct timeval when = { offset, };
return ast_channel_cmpwhentohangup_tv(chan, when);
}
| int ast_channel_cmpwhentohangup_tv | ( | struct ast_channel * | chan, |
| struct timeval | offset | ||
| ) |
Compare a offset with when to hangup channel.
Compare a offset with the settings of when to hang a channel up.
Definition at line 864 of file channel.c.
References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by ast_channel_cmpwhentohangup().
{
struct timeval whentohangup;
if (ast_tvzero(chan->whentohangup))
return ast_tvzero(offset) ? 0 : -1;
if (ast_tvzero(offset))
return 1;
whentohangup = ast_tvadd(offset, ast_tvnow());
return ast_tvdiff_ms(whentohangup, chan->whentohangup);
}
| int ast_channel_connected_line_macro | ( | struct ast_channel * | autoservice_chan, |
| struct ast_channel * | macro_chan, | ||
| const void * | connected_info, | ||
| int | caller, | ||
| int | frame | ||
| ) |
Run a connected line interception macro and update a channel's connected line information.
| autoservice_chan | Channel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL |
| macro_chan | The channel to run the macro on. Also the channel from which we determine which macro we need to run. |
| connected_info | Either an ast_party_connected_line or ast_frame pointer of type AST_CONTROL_CONNECTED_LINE |
| caller | If true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO |
| frame | If true, then connected_info is an ast_frame pointer, otherwise it is an ast_party_connected_line pointer. |
| 0 | Success |
| -1 | Either the macro does not exist, or there was an error while attempting to run the macro |
Have multiple return codes based on the MACRO_RESULT
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 9312 of file channel.c.
References ast_app_run_macro(), ast_channel_lock, ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_parse_data(), ast_party_connected_line_copy(), ast_strdupa, ast_strlen_zero(), chanlist::connected, ast_channel::connected, ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, and S_OR.
Referenced by __ast_read(), ast_bridge_call(), ast_do_pickup(), ast_generic_bridge(), atxfer_fail_cleanup(), builtin_atxfer(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), parked_call_exec(), remote_bridge_loop(), and wait_for_answer().
{
const char *macro;
const char *macro_args;
int retval;
ast_channel_lock(macro_chan);
macro = pbx_builtin_getvar_helper(macro_chan, is_caller
? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO");
macro = ast_strdupa(S_OR(macro, ""));
macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS");
macro_args = ast_strdupa(S_OR(macro_args, ""));
if (ast_strlen_zero(macro)) {
ast_channel_unlock(macro_chan);
return -1;
}
if (is_frame) {
const struct ast_frame *frame = connected_info;
ast_connected_line_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->connected);
} else {
const struct ast_party_connected_line *connected = connected_info;
ast_party_connected_line_copy(¯o_chan->connected, connected);
}
ast_channel_unlock(macro_chan);
if (!(retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args))) {
ast_channel_lock(macro_chan);
ast_channel_update_connected_line(macro_chan, ¯o_chan->connected, NULL);
ast_channel_unlock(macro_chan);
}
return retval;
}
| int ast_channel_data_add_structure | ( | struct ast_data * | tree, |
| struct ast_channel * | chan, | ||
| int | add_bridged | ||
| ) |
Insert into an astdata tree, the channel structure.
| [in] | tree | The ast data tree. |
| [in] | chan | The channel structure to add to tree. |
| [in] | add_bridged | Add the bridged channel to the structure. |
| <0 | on error. |
| 0 | on success. |
Definition at line 342 of file channel.c.
References ast_channel::_softhangup, ast_channel::_state, ast_channel::amaflags, ast_bridged_channel(), ast_cause2str(), ast_cdr_data_add_structure(), ast_cdr_flags2str(), ast_channel_data_add_structure(), ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_int(), ast_data_add_node(), ast_data_add_str(), ast_data_add_structure, ast_data_add_uint(), AST_SOFTHANGUP_APPUNLOAD, AST_SOFTHANGUP_ASYNCGOTO, AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, AST_SOFTHANGUP_SHUTDOWN, AST_SOFTHANGUP_TIMEOUT, AST_SOFTHANGUP_UNBRIDGE, ast_state2str(), ast_tone_zone_data_add_structure(), ast_transfercapability2str(), ast_channel::cdr, channel_data_add_flags(), ast_channel::hangupcause, ast_channel::nativeformats, ast_channel::oldwriteformat, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::transfercapability, ast_channel::whentohangup, ast_channel::writeformat, and ast_channel::zone.
Referenced by agents_data_provider_get(), ast_channel_data_add_structure(), data_channels_provider_handler(), queues_data_provider_get_helper(), and user_add_provider_cb().
{
struct ast_channel *bc;
struct ast_data *data_bridged;
struct ast_data *data_cdr;
struct ast_data *data_flags;
struct ast_data *data_zones;
struct ast_data *enum_node;
struct ast_data *data_softhangup;
#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
struct ast_data *data_callerid;
char value_str[100];
#endif
if (!tree) {
return -1;
}
ast_data_add_structure(ast_channel, tree, chan);
if (add_bridged) {
bc = ast_bridged_channel(chan);
if (bc) {
data_bridged = ast_data_add_node(tree, "bridged");
if (!data_bridged) {
return -1;
}
ast_channel_data_add_structure(data_bridged, bc, 0);
}
}
ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat);
ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
ast_data_add_codecs(tree, "readformat", chan->readformat);
ast_data_add_codecs(tree, "writeformat", chan->writeformat);
ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat);
ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat);
/* state */
enum_node = ast_data_add_node(tree, "state");
if (!enum_node) {
return -1;
}
ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
ast_data_add_int(enum_node, "value", chan->_state);
/* hangupcause */
enum_node = ast_data_add_node(tree, "hangupcause");
if (!enum_node) {
return -1;
}
ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
ast_data_add_int(enum_node, "value", chan->hangupcause);
/* amaflags */
enum_node = ast_data_add_node(tree, "amaflags");
if (!enum_node) {
return -1;
}
ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
ast_data_add_int(enum_node, "value", chan->amaflags);
/* transfercapability */
enum_node = ast_data_add_node(tree, "transfercapability");
if (!enum_node) {
return -1;
}
ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability));
ast_data_add_int(enum_node, "value", chan->transfercapability);
/* _softphangup */
data_softhangup = ast_data_add_node(tree, "softhangup");
if (!data_softhangup) {
return -1;
}
ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV);
ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO);
ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN);
ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT);
ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD);
ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT);
ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE);
/* channel flags */
data_flags = ast_data_add_node(tree, "flags");
if (!data_flags) {
return -1;
}
channel_data_add_flags(data_flags, chan);
ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec);
#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
/* callerid */
data_callerid = ast_data_add_node(tree, "callerid");
if (!data_callerid) {
return -1;
}
ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
/* insert the callerid ton */
enum_node = ast_data_add_node(data_callerid, "cid_ton");
if (!enum_node) {
return -1;
}
ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
party_number_ton2str(chan->cid.cid_ton),
party_number_plan2str(chan->cid.cid_ton));
ast_data_add_str(enum_node, "text", value_str);
#endif
/* tone zone */
if (chan->zone) {
data_zones = ast_data_add_node(tree, "zone");
if (!data_zones) {
return -1;
}
ast_tone_zone_data_add_structure(data_zones, chan->zone);
}
/* insert cdr */
data_cdr = ast_data_add_node(tree, "cdr");
if (!data_cdr) {
return -1;
}
ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
return 0;
}
| int ast_channel_data_cmp_structure | ( | const struct ast_data_search * | tree, |
| struct ast_channel * | chan, | ||
| const char * | structure_name | ||
| ) |
Compare to channel structures using the data api.
| [in] | tree | The search tree generated by the data api. |
| [in] | chan | The channel to compare. |
| [in] | structure_name | The name of the node of the channel structure. |
| 0 | The structure matches. |
| 1 | The structure doesn't matches. |
Definition at line 474 of file channel.c.
References ast_data_search_cmp_structure.
{
return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
}
| int ast_channel_datastore_add | ( | struct ast_channel * | chan, |
| struct ast_datastore * | datastore | ||
| ) |
Add a datastore to a channel.
| 0 | success |
| non-zero | failure |
Definition at line 2535 of file channel.c.
References AST_LIST_INSERT_HEAD, and ast_channel::datastores.
Referenced by __ast_channel_masquerade(), _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), add_features_datastores(), add_to_agi(), apply_plc(), ast_channel_cc_params_init(), ast_do_pickup(), ast_iax2_new(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), calendar_query_exec(), cc_interfaces_datastore_init(), dial_exec_full(), do_notify(), dundi_query_read(), enable_jack_hook(), enum_query_read(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_write_real(), get_lock(), gosub_exec(), lua_get_state(), mute_add_audiohook(), pitchshift_helper(), raise_exception(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), srv_datastore_setup(), try_calling(), and volume_write().
{
int res = 0;
AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry);
return res;
}
| struct ast_datastore* ast_channel_datastore_alloc | ( | const struct ast_datastore_info * | info, |
| const char * | uid | ||
| ) | [read] |
Create a channel data store object.
Definition at line 2508 of file channel.c.
References ast_datastore_alloc().
{
return ast_datastore_alloc(info, uid);
}
| struct ast_datastore* ast_channel_datastore_find | ( | struct ast_channel * | chan, |
| const struct ast_datastore_info * | info, | ||
| const char * | uid | ||
| ) | [read] |
Find a datastore on a channel.
| pointer | to the datastore if found |
| NULL | if not found |
Definition at line 2549 of file channel.c.
References AST_LIST_TRAVERSE, ast_channel::datastores, ast_datastore::info, and ast_datastore::uid.
Referenced by _macro_exec(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), acf_odbc_read(), add_agi_cmd(), add_features_datastores(), add_to_agi(), apply_plc(), ast_can_pickup(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_completed(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_current_core_id(), ast_cc_is_recall(), ast_cc_offer(), ast_channel_get_cc_config_params(), ast_do_masquerade(), ast_handle_cc_control_frame(), ast_ignore_cc(), ast_odbc_retrieve_transaction_obj(), ast_set_cc_interfaces_chanvar(), attended_transfer_occurred(), audiohook_volume_callback(), audiohook_volume_get(), builtin_atxfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), cc_build_payload(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), find_details(), find_speech(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_inheritance_write(), func_mute_write(), get_agi_cmd(), get_lock(), gosub_exec(), handle_gosub(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lock_fixup(), lua_get_state(), manage_parked_call(), manager_mutestream(), mark_transaction_active(), mute_callback(), parked_call_exec(), pitchshift_cb(), pitchshift_helper(), pop_exec(), queue_transfer_fixup(), raise_exception(), release_transaction(), return_exec(), set_security_requirements(), shared_read(), shared_write(), smdi_msg_read(), speech_background(), speech_destroy(), speex_callback(), speex_read(), speex_write(), srv_query_read(), srv_result_read(), stop_mixmonitor_exec(), try_calling(), unlock_read(), volume_callback(), and volume_write().
{
struct ast_datastore *datastore = NULL;
if (info == NULL)
return NULL;
AST_LIST_TRAVERSE(&chan->datastores, datastore, entry) {
if (datastore->info != info) {
continue;
}
if (uid == NULL) {
/* matched by type only */
break;
}
if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
/* Matched by type AND uid */
break;
}
}
return datastore;
}
| int ast_channel_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a channel data store object.
Definition at line 2513 of file channel.c.
References ast_datastore_free().
{
return ast_datastore_free(datastore);
}
| int ast_channel_datastore_inherit | ( | struct ast_channel * | from, |
| struct ast_channel * | to | ||
| ) |
Inherit datastores from a parent to a child.
Definition at line 2518 of file channel.c.
References ast_datastore_alloc(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.
Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), findmeexec(), local_call(), ring_entry(), and wait_for_answer().
{
struct ast_datastore *datastore = NULL, *datastore2;
AST_LIST_TRAVERSE(&from->datastores, datastore, entry) {
if (datastore->inheritance > 0) {
datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
if (datastore2) {
datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry);
}
}
}
return 0;
}
| int ast_channel_datastore_remove | ( | struct ast_channel * | chan, |
| struct ast_datastore * | datastore | ||
| ) |
Remove a datastore from a channel.
| 0 | success |
| non-zero | failure |
Definition at line 2544 of file channel.c.
References AST_LIST_REMOVE, and ast_channel::datastores.
Referenced by acf_fetch(), acf_odbc_read(), adjust_frame_for_plc(), ast_do_masquerade(), ast_do_pickup(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), frame_trace_helper(), lua_get_state(), queue_transfer_fixup(), speech_background(), speech_destroy(), speex_write(), srv_query_read(), stop_mixmonitor_exec(), and try_calling().
{
return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1;
}
| int ast_channel_defer_dtmf | ( | struct ast_channel * | chan | ) |
Set defer DTMF flag on channel.
Defers DTMF so that you only read things like hangups and audio.
Definition at line 1577 of file channel.c.
References AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.
Referenced by __adsi_transmit_messages(), and find_cache().
{
int pre = 0;
if (chan) {
pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF);
ast_set_flag(chan, AST_FLAG_DEFER_DTMF);
}
return pre;
}
| static void ast_channel_destructor | ( | void * | obj | ) | [static] |
Free a channel structure.
Definition at line 2357 of file channel.c.
References ast_channel::alertpipe, ast_app_group_discard(), ast_cdr_discard(), AST_CEL_CHANNEL_END, ast_cel_check_retire_linkedid(), ast_cel_report_event(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), ast_datastore_free(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_free, ast_frfree, ast_jb_destroy(), AST_LIST_REMOVE_HEAD, ast_log(), AST_MAX_FDS, ast_moh_cleanup(), ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_string_field_free_memory, ast_timer_close(), ast_tone_zone_unref(), ast_translator_free_path(), ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::datastores, ast_channel::dialed, f, free, LOG_WARNING, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::pbx, ast_channel::readq, ast_channel::readtrans, ast_channel::redirecting, ast_channel::sched, sched_context_destroy(), ast_channel_monitor::stop, ast_channel::tech_pvt, ast_channel::timer, ast_channel::varshead, ast_channel::writetrans, and ast_channel::zone.
Referenced by __ast_channel_alloc_ap().
{
struct ast_channel *chan = obj;
int fd;
#ifdef HAVE_EPOLL
int i;
#endif
struct ast_var_t *vardata;
struct ast_frame *f;
struct varshead *headp;
struct ast_datastore *datastore;
char device_name[AST_CHANNEL_NAME];
if (chan->name) {
/* The string fields were initialized. */
ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL);
ast_cel_check_retire_linkedid(chan);
}
/* Get rid of each of the data stores on the channel */
ast_channel_lock(chan);
while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry)))
/* Free the data store */
ast_datastore_free(datastore);
ast_channel_unlock(chan);
/* Lock and unlock the channel just to be sure nobody has it locked still
due to a reference that was stored in a datastore. (i.e. app_chanspy) */
ast_channel_lock(chan);
ast_channel_unlock(chan);
if (chan->tech_pvt) {
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
ast_free(chan->tech_pvt);
}
if (chan->sched)
sched_context_destroy(chan->sched);
if (chan->name) {
char *dashptr;
/* The string fields were initialized. */
ast_copy_string(device_name, chan->name, sizeof(device_name));
if ((dashptr = strrchr(device_name, '-'))) {
*dashptr = '\0';
}
} else {
device_name[0] = '\0';
}
/* Stop monitoring */
if (chan->monitor)
chan->monitor->stop( chan, 0 );
/* If there is native format music-on-hold state, free it */
if (chan->music_state)
ast_moh_cleanup(chan);
/* Free translators */
if (chan->readtrans)
ast_translator_free_path(chan->readtrans);
if (chan->writetrans)
ast_translator_free_path(chan->writetrans);
if (chan->pbx)
ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
ast_party_dialed_free(&chan->dialed);
ast_party_caller_free(&chan->caller);
ast_party_connected_line_free(&chan->connected);
ast_party_redirecting_free(&chan->redirecting);
/* Close pipes if appropriate */
if ((fd = chan->alertpipe[0]) > -1)
close(fd);
if ((fd = chan->alertpipe[1]) > -1)
close(fd);
if (chan->timer) {
ast_timer_close(chan->timer);
}
#ifdef HAVE_EPOLL
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan->epfd_data[i])
free(chan->epfd_data[i]);
}
close(chan->epfd);
#endif
while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list)))
ast_frfree(f);
/* loop over the variables list, freeing all data and deleting list items */
/* no need to lock the list, as the channel is already locked */
headp = &chan->varshead;
while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
ast_var_delete(vardata);
ast_app_group_discard(chan);
/* Destroy the jitterbuffer */
ast_jb_destroy(chan);
if (chan->cdr) {
ast_cdr_discard(chan->cdr);
chan->cdr = NULL;
}
if (chan->zone) {
chan->zone = ast_tone_zone_unref(chan->zone);
}
ast_string_field_free_memory(chan);
if (device_name[0]) {
/*
* We have a device name to notify of a new state.
*
* Queue an unknown state, because, while we know that this particular
* instance is dead, we don't know the state of all other possible
* instances.
*/
ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
}
}
| int ast_channel_early_bridge | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1 | ||
| ) |
Bridge two channels together (early)
| c0 | first channel to bridge |
| c1 | second channel to bridge |
Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
Definition at line 7153 of file channel.c.
References ast_channel_tech::early_bridge, and ast_channel::tech.
Referenced by dial_exec_full(), and wait_for_answer().
{
/* Make sure we can early bridge, if not error out */
if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
return -1;
return c0->tech->early_bridge(c0, c1);
}
| struct ast_channel* ast_channel_get_by_exten | ( | const char * | exten, |
| const char * | context | ||
| ) | [read] |
Find a channel by extension and context.
Return a channel that is currently at the specified extension and context.
| a | channel that is at the specified extension and context |
| NULL | if no channel was found |
Definition at line 1774 of file channel.c.
References ast_channel_get_full().
{
return ast_channel_get_full(NULL, 0, exten, context);
}
| struct ast_channel* ast_channel_get_by_name | ( | const char * | name | ) | [read] |
Find a channel by name.
Channel search functions
Find a channel that has the same name as the provided argument.
| a | channel with the name specified by the argument |
| NULL | if no channel was found |
Definition at line 1764 of file channel.c.
References ast_channel_get_full().
Referenced by action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), ast_async_goto_by_name(), ast_bridge_call(), asyncgoto_exec(), change_monitor_action(), do_pause_or_unpause(), func_mchan_read(), func_mchan_write(), handle_channelstatus(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_redirect(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), import_helper(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), park_call_full(), pbx_builtin_importvar(), senddtmf_exec(), shared_read(), shared_write(), start_monitor_action(), and stop_monitor_action().
{
return ast_channel_get_full(name, 0, NULL, NULL);
}
| struct ast_channel* ast_channel_get_by_name_prefix | ( | const char * | name, |
| size_t | name_len | ||
| ) | [read] |
Find a channel by a name prefix.
Find a channel that has the same name prefix as specified by the arguments.
| a | channel with the name prefix specified by the arguments |
| NULL | if no channel was found |
Definition at line 1769 of file channel.c.
References ast_channel_get_full().
Referenced by action_aocmessage(), action_bridge(), ast_parse_device_state(), bridge_exec(), cc_generic_agent_stop_ringing(), common_exec(), handle_cli_mixmonitor(), shared_read(), and shared_write().
{
return ast_channel_get_full(name, name_len, NULL, NULL);
}
| int ast_channel_get_cc_agent_type | ( | struct ast_channel * | chan, |
| char * | agent_type, | ||
| size_t | size | ||
| ) |
Find the appropriate CC agent type to use given a channel.
During call completion, we will need to create a call completion agent structure. To figure out the type of agent to construct, we need to ask the channel driver for the appropriate type.
Prior to adding this function, the call completion core attempted to figure this out for itself by stripping the technology off the channel's name. However, in the case of chan_dahdi, there are multiple agent types registered, and so simply searching for an agent type called "DAHDI" is not possible. In a case where multiple agent types are defined, the channel driver must have a queryoption callback defined in its channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
If a channel driver does not have a queryoption callback or if the queryoption callback does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology portion of the channel name is used instead. This is perfectly suitable for channel drivers whose channel technologies are a one-to-one match with the agent types defined within.
Note that this function is only called when the agent policy on a given channel is set to "native." Generic agents' type can be determined automatically by the core.
| chan | The channel for which we wish to retrieve the agent type | |
| [out] | agent_type | The type of agent the channel driver wants us to use |
| size | The size of the buffer to write to |
Definition at line 9476 of file channel.c.
References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_CC_AGENT_TYPE, and ast_channel::name.
Referenced by find_agent_callbacks().
{
int len = size;
char *slash;
if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) {
return 0;
}
ast_copy_string(agent_type, chan->name, size);
if ((slash = strchr(agent_type, '/'))) {
*slash = '\0';
}
return 0;
}
| struct ast_cc_config_params* ast_channel_get_cc_config_params | ( | struct ast_channel * | chan | ) | [read] |
Get the CCSS parameters from a channel.
This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function.
| chan | Channel to retrieve parameters from |
| NULL | Failure |
| non-NULL | The parameters desired |
Definition at line 9437 of file channel.c.
References ast_assert, ast_channel_cc_params_init(), ast_channel_datastore_find(), and ast_datastore::data.
Referenced by acf_cc_read(), acf_cc_write(), analog_call(), ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), cc_agent_init(), cc_core_init_instance(), find_agent_callbacks(), local_call(), local_request(), sig_pri_cc_available(), and sig_pri_cc_generic_check().
{
struct ast_datastore *cc_datastore;
if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
/* If we can't find the datastore, it almost definitely means that the channel type being
* used has not had its driver modified to parse CC config parameters. The best action
* to take here is to create the parameters on the spot with the defaults set.
*/
if (ast_channel_cc_params_init(chan, NULL)) {
return NULL;
}
if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
/* Should be impossible */
return NULL;
}
}
ast_assert(cc_datastore->data != NULL);
return cc_datastore->data;
}
| int ast_channel_get_device_name | ( | struct ast_channel * | chan, |
| char * | device_name, | ||
| size_t | name_buffer_length | ||
| ) |
Get a device name given its channel structure.
A common practice in Asterisk is to determine the device being talked to by dissecting the channel name. For certain channel types, this is not accurate. For instance, an ISDN channel is named based on what B channel is used, not the device being communicated with.
This function interfaces with a channel tech's queryoption callback to retrieve the name of the device being communicated with. If the channel does not implement this specific option, then the traditional method of using the channel name is used instead.
| chan | The channel to retrieve the information from | |
| [out] | device_name | The buffer to place the device's name into |
| name_buffer_length | The allocated space for the device_name |
Definition at line 9459 of file channel.c.
References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_DEVICE_NAME, and ast_channel::name.
Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), cc_core_init_instance(), cccancel_exec(), ccreq_exec(), dial_exec_full(), sig_pri_call(), sig_pri_cc_available(), sig_pri_cc_generic_check(), sip_call(), and sip_handle_cc().
{
int len = name_buffer_length;
char *dash;
if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
return 0;
}
/* Dang. Do it the old-fashioned way */
ast_copy_string(device_name, chan->name, name_buffer_length);
if ((dash = strrchr(device_name, '-'))) {
*dash = '\0';
}
return 0;
}
| static struct ast_channel* ast_channel_get_full | ( | const char * | name, |
| size_t | name_len, | ||
| const char * | exten, | ||
| const char * | context | ||
| ) | [static, read] |
Definition at line 1722 of file channel.c.
References ao2_find, ast_copy_string(), ast_strlen_zero(), chanlist::chan, channels, ast_channel::context, ast_channel::exten, name, ast_channel::name, OBJ_POINTER, and ast_channel::uniqueid.
Referenced by ast_channel_get_by_exten(), ast_channel_get_by_name(), and ast_channel_get_by_name_prefix().
{
struct ast_channel tmp_chan = {
.name = name,
/* This is sort of a hack. Basically, we're using an arbitrary field
* in ast_channel to pass the name_len for a prefix match. If this
* gets changed, then the compare callback must be changed, too. */
.rings = name_len,
};
struct ast_channel *chan;
if (exten) {
ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
}
if (context) {
ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
}
if ((chan = ao2_find(channels, &tmp_chan,
(!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0))) {
return chan;
}
if (!name) {
return NULL;
}
/* If name was specified, but the result was NULL,
* try a search on uniqueid, instead. */
{
struct ast_channel tmp_chan2 = {
.uniqueid = name,
.rings = name_len,
};
return ao2_find(channels, &tmp_chan2, 0);
}
}
| static int ast_channel_hash_cb | ( | const void * | obj, |
| const int | flags | ||
| ) | [static] |
Definition at line 7792 of file channel.c.
References ast_str_case_hash(), ast_strlen_zero(), and ast_channel::name.
Referenced by ast_channels_init().
{
const struct ast_channel *chan = obj;
/* If the name isn't set, return 0 so that the ao2_find() search will
* start in the first bucket. */
if (ast_strlen_zero(chan->name)) {
return 0;
}
return ast_str_case_hash(chan->name);
}
| void ast_channel_inherit_variables | ( | const struct ast_channel * | parent, |
| struct ast_channel * | child | ||
| ) |
Inherits channel variable from parent to child channel.
| parent | Parent channel |
| child | Child channel |
Scans all channel variables in the parent channel, looking for those that should be copied into the child channel. Variables whose names begin with a single '_' are copied into the child channel with the prefix removed. Variables whose names begin with '__' are copied into the child channel with their names unchanged.
Definition at line 6078 of file channel.c.
References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_full_name(), ast_var_name(), ast_var_value(), ast_var_t::entries, and ast_channel::varshead.
Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), ring_entry(), and wait_for_answer().
{
struct ast_var_t *current, *newvar;
const char *varname;
AST_LIST_TRAVERSE(&parent->varshead, current, entries) {
int vartype = 0;
varname = ast_var_full_name(current);
if (!varname)
continue;
if (varname[0] == '_') {
vartype = 1;
if (varname[1] == '_')
vartype = 2;
}
switch (vartype) {
case 1:
newvar = ast_var_assign(&varname[1], ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
}
break;
case 2:
newvar = ast_var_assign(varname, ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
}
break;
default:
ast_debug(1, "Not copying variable %s.\n", ast_var_name(current));
break;
}
}
}
| struct ast_channel_iterator* ast_channel_iterator_all_new | ( | void | ) | [read] |
Create a new channel iterator.
After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that exist.
| NULL | on failure |
| a | new channel iterator |
Definition at line 1662 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_iterator_init(), ast_calloc, channels, and ast_channel_iterator::simple_iterator.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), and handle_softhangup().
{
struct ast_channel_iterator *i;
if (!(i = ast_calloc(1, sizeof(*i)))) {
return NULL;
}
i->simple_iterator = ao2_iterator_init(channels, 0);
i->active_iterator = &i->simple_iterator;
return i;
}
| struct ast_channel_iterator* ast_channel_iterator_by_exten_new | ( | const char * | exten, |
| const char * | context | ||
| ) | [read] |
Create a new channel iterator based on extension.
After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that are currently in the specified context and extension.
| NULL | on failure |
| a | new channel iterator based on the specified parameters |
Definition at line 1652 of file channel.c.
References channel_iterator_search().
Referenced by common_exec(), and pickup_by_exten().
{
return channel_iterator_search(NULL, 0, exten, context);
}
| struct ast_channel_iterator* ast_channel_iterator_by_name_new | ( | const char * | name, |
| size_t | name_len | ||
| ) | [read] |
Create a new channel iterator based on name.
After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that exist that have the specified name or name prefix.
| NULL | on failure |
| a | new channel iterator based on the specified parameters |
Definition at line 1657 of file channel.c.
References channel_iterator_search().
Referenced by ast_complete_channels(), common_exec(), and softhangup_exec().
{
return channel_iterator_search(name, name_len, NULL, NULL);
}
| struct ast_channel_iterator* ast_channel_iterator_destroy | ( | struct ast_channel_iterator * | i | ) | [read] |
Destroy a channel iterator.
This function is used to destroy a channel iterator that was retrieved by using one of the channel_iterator_new() functions.
Definition at line 1610 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_iterator_destroy(), and ast_free.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), pickup_by_exten(), and softhangup_exec().
{
ao2_iterator_destroy(i->active_iterator);
ast_free(i);
return NULL;
}
| struct ast_channel* ast_channel_iterator_next | ( | struct ast_channel_iterator * | i | ) | [read] |
Get the next channel for a channel iterator.
This function should be used to iterate through all channels that match a specified set of parameters that were provided when the iterator was created.
| the | next channel that matches the parameters used when the iterator was created. |
| NULL,if | no more channels match the iterator parameters. |
Definition at line 1676 of file channel.c.
References ast_channel_iterator::active_iterator, and ao2_iterator_next.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), next_channel(), pickup_by_exten(), and softhangup_exec().
{
return ao2_iterator_next(i->active_iterator);
}
| int ast_channel_make_compatible | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1 | ||
| ) |
Makes two channel formats compatible.
| c0 | first channel to make compatible |
| c1 | other channel to make compatible |
Set two channels to compatible formats -- call before ast_channel_bridge in general.
Definition at line 5809 of file channel.c.
References ast_channel_make_compatible_helper().
Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), multiplexed_bridge_join(), parked_call_exec(), simple_bridge_join(), try_calling(), and wait_for_answer().
{
/* Some callers do not check return code, and we must try to set all call legs correctly */
int rc = 0;
/* Set up translation from the chan to the peer */
rc = ast_channel_make_compatible_helper(chan, peer);
if (rc < 0)
return rc;
/* Set up translation from the peer to the chan */
rc = ast_channel_make_compatible_helper(peer, chan);
return rc;
}
| static int ast_channel_make_compatible_helper | ( | struct ast_channel * | from, |
| struct ast_channel * | to | ||
| ) | [static] |
Set up translation from one channel to another.
Definition at line 5759 of file channel.c.
References ast_channel_setoption(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_SLINEAR, ast_getformatname(), ast_log(), ast_opt_generic_plc, ast_opt_transcode_via_slin, AST_OPTION_MAKE_COMPATIBLE, ast_set_read_format(), ast_set_write_format(), ast_translate_path_steps(), ast_translator_best_choice(), ast_channel_tech::bridge, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ast_channel::readformat, ast_channel::tech, and ast_channel::writeformat.
Referenced by ast_channel_make_compatible().
{
format_t src, dst;
int use_slin;
/* See if the channel driver can natively make these two channels compatible */
if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
!ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) {
return 0;
}
if (from->readformat == to->writeformat && from->writeformat == to->readformat) {
/* Already compatible! Moving on ... */
return 0;
}
/* Set up translation from the 'from' channel to the 'to' channel */
src = from->nativeformats;
dst = to->nativeformats;
/* If there's no audio in this call, don't bother with trying to find a translation path */
if ((src & AST_FORMAT_AUDIO_MASK) == 0 || (dst & AST_FORMAT_AUDIO_MASK) == 0)
return 0;
if (ast_translator_best_choice(&dst, &src) < 0) {
ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name);
return -1;
}
/* if the best path is not 'pass through', then
* transcoding is needed; if desired, force transcode path
* to use SLINEAR between channels, but only if there is
* no direct conversion available. If generic PLC is
* desired, then transcoding via SLINEAR is a requirement
*/
use_slin = (src == AST_FORMAT_SLINEAR || dst == AST_FORMAT_SLINEAR);
if ((src != dst) && (ast_opt_generic_plc || ast_opt_transcode_via_slin) &&
(ast_translate_path_steps(dst, src) != 1 || use_slin))
dst = AST_FORMAT_SLINEAR;
if (ast_set_read_format(from, dst) < 0) {
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst));
return -1;
}
if (ast_set_write_format(to, dst) < 0) {
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst));
return -1;
}
return 0;
}
| int ast_channel_masquerade | ( | struct ast_channel * | original, |
| struct ast_channel * | clone | ||
| ) |
Weird function made for call transfers.
| original | channel to make a copy of |
| clone | copy of the original channel |
This is a very strange and freaky function used primarily for transfer. Suppose that "original" and "clone" are two channels in random situations. This function takes the guts out of "clone" and puts them into the "original" channel, then alerts the channel driver of the change, asking it to fixup any private information (like the p->owner pointer) that is affected by the change. The physical layer of the original channel is hung up.
Definition at line 5949 of file channel.c.
References __ast_channel_masquerade().
Referenced by ast_async_goto(), ast_do_pickup(), attempt_transfer(), builtin_atxfer(), check_availability(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), masq_park_call(), sip_park(), and skinny_transfer().
{
return __ast_channel_masquerade(original, clone, NULL);
}
| int ast_channel_queryoption | ( | struct ast_channel * | channel, |
| int | option, | ||
| void * | data, | ||
| int * | datalen, | ||
| int | block | ||
| ) |
Checks the value of an option.
Query the value of an option Works similarly to setoption except only reads the options.
Definition at line 7544 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::queryoption, and ast_channel::tech.
Referenced by ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_get_t38_state(), local_queryoption(), rcvfax_exec(), and sndfax_exec().
{
int res;
ast_channel_lock(chan);
if (!chan->tech->queryoption) {
errno = ENOSYS;
ast_channel_unlock(chan);
return -1;
}
if (block)
ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
res = chan->tech->queryoption(chan, option, data, datalen);
ast_channel_unlock(chan);
return res;
}
| void ast_channel_queue_connected_line_update | ( | struct ast_channel * | chan, |
| const struct ast_party_connected_line * | connected, | ||
| const struct ast_set_party_connected_line * | update | ||
| ) |
Queue a connected line update frame on a channel.
| chan | Asterisk channel to indicate connected line information |
| connected | Connected line information |
| update | What connected line information to update. NULL if all. |
Definition at line 8792 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_queue_control_data().
Referenced by ast_do_pickup(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), masquerade_colp_transfer(), misdn_queue_connected_line_update(), sig_pri_handle_subcmds(), and sip_call().
{
unsigned char data[1024]; /* This should be large enough */
size_t datalen;
datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
if (datalen == (size_t) -1) {
return;
}
ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
}
| void ast_channel_queue_redirecting_update | ( | struct ast_channel * | chan, |
| const struct ast_party_redirecting * | redirecting, | ||
| const struct ast_set_party_redirecting * | update | ||
| ) |
Queue a redirecting update frame on a channel.
| chan | Asterisk channel to indicate redirecting id information |
| redirecting | Redirecting id information |
| update | What redirecting information to update. NULL if all. |
Definition at line 9299 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_queue_control_data(), and ast_redirecting_build_data().
Referenced by cb_events(), handle_response_invite(), misdn_facility_ie_handler(), and sig_pri_handle_subcmds().
{
unsigned char data[1024]; /* This should be large enough */
size_t datalen;
datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
if (datalen == (size_t) -1) {
return;
}
ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
}
| const char* ast_channel_reason2str | ( | int | reason | ) |
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
| reason | The integer argument, usually taken from AST_CONTROL_ macros |
Definition at line 5163 of file channel.c.
References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_RING, and AST_CONTROL_RINGING.
Referenced by attempt_thread().
{
switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
{
case 0:
return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
case AST_CONTROL_HANGUP:
return "Hangup";
case AST_CONTROL_RING:
return "Local Ring";
case AST_CONTROL_RINGING:
return "Remote end Ringing";
case AST_CONTROL_ANSWER:
return "Remote end has Answered";
case AST_CONTROL_BUSY:
return "Remote end is Busy";
case AST_CONTROL_CONGESTION:
return "Congestion (circuits busy)";
default:
return "Unknown Reason!!";
}
}
| int ast_channel_redirecting_macro | ( | struct ast_channel * | autoservice_chan, |
| struct ast_channel * | macro_chan, | ||
| const void * | redirecting_info, | ||
| int | is_caller, | ||
| int | is_frame | ||
| ) |
Run a redirecting interception macro and update a channel's redirecting information.
Whenever we want to update a channel's redirecting information, we may need to run a macro so that an administrator can manipulate the information before sending it out. This function both runs the macro and sends the update to the channel.
| autoservice_chan | Channel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL |
| macro_chan | The channel to run the macro on. Also the channel from which we determine which macro we need to run. |
| redirecting_info | Either an ast_party_redirecting or ast_frame pointer of type AST_CONTROL_REDIRECTING |
| is_caller | If true, then run REDIRECTING_CALLER_SEND_MACRO, otherwise run REDIRECTING_CALLEE_SEND_MACRO |
| is_frame | If true, then redirecting_info is an ast_frame pointer, otherwise it is an ast_party_redirecting pointer. |
| 0 | Success |
| -1 | Either the macro does not exist, or there was an error while attempting to run the macro |
Have multiple return codes based on the MACRO_RESULT
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 9351 of file channel.c.
References ast_app_run_macro(), ast_channel_lock, ast_channel_unlock, ast_channel_update_redirecting(), ast_party_redirecting_copy(), ast_redirecting_parse_data(), ast_strdupa, ast_strlen_zero(), ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, ast_channel::redirecting, and S_OR.
Referenced by ast_bridge_call(), ast_generic_bridge(), call_forward_inherit(), do_forward(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().
{
const char *macro;
const char *macro_args;
int retval;
ast_channel_lock(macro_chan);
macro = pbx_builtin_getvar_helper(macro_chan, is_caller
? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO");
macro = ast_strdupa(S_OR(macro, ""));
macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS");
macro_args = ast_strdupa(S_OR(macro_args, ""));
if (ast_strlen_zero(macro)) {
ast_channel_unlock(macro_chan);
return -1;
}
if (is_frame) {
const struct ast_frame *frame = redirecting_info;
ast_redirecting_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->redirecting);
} else {
const struct ast_party_redirecting *redirecting = redirecting_info;
ast_party_redirecting_copy(¯o_chan->redirecting, redirecting);
}
ast_channel_unlock(macro_chan);
retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
if (!retval) {
ast_channel_lock(macro_chan);
ast_channel_update_redirecting(macro_chan, ¯o_chan->redirecting, NULL);
ast_channel_unlock(macro_chan);
}
return retval;
}
| int ast_channel_register | ( | const struct ast_channel_tech * | tech | ) |
Register a new telephony channel in Asterisk.
Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.
Definition at line 886 of file channel.c.
References ast_calloc, ast_debug, ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, ast_channel_tech::description, LOG_WARNING, chanlist::tech, and ast_channel_tech::type.
Referenced by load_module(), and unload_module().
{
struct chanlist *chan;
AST_RWLIST_WRLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, chan, list) {
if (!strcasecmp(tech->type, chan->tech->type)) {
ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type);
AST_RWLIST_UNLOCK(&backends);
return -1;
}
}
if (!(chan = ast_calloc(1, sizeof(*chan)))) {
AST_RWLIST_UNLOCK(&backends);
return -1;
}
chan->tech = tech;
AST_RWLIST_INSERT_HEAD(&backends, chan, list);
ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
AST_RWLIST_UNLOCK(&backends);
return 0;
}
| struct ast_channel* ast_channel_release | ( | struct ast_channel * | chan | ) | [read] |
Unlink and release reference to a channel.
This function will unlink the channel from the global channels container if it is still there and also release the current reference to the channel.
Definition at line 1878 of file channel.c.
References ao2_unlink, ast_channel_unref, and channels.
Referenced by agent_cleanup(), ast_do_masquerade(), ast_iax2_new(), ast_request(), bridge_request(), do_notify(), gtalk_newcall(), local_new(), and local_request().
{
/* Safe, even if already unlinked. */
ao2_unlink(channels, chan);
return ast_channel_unref(chan);
}
| int ast_channel_sendhtml | ( | struct ast_channel * | channel, |
| int | subclass, | ||
| const char * | data, | ||
| int | datalen | ||
| ) |
Sends HTML on given channel Send HTML or URL on link.
Definition at line 5746 of file channel.c.
References ast_channel_tech::send_html, and ast_channel::tech.
Referenced by agent_sendhtml(), ast_channel_sendurl(), and wait_for_answer().
| int ast_channel_sendurl | ( | struct ast_channel * | channel, |
| const char * | url | ||
| ) |
Sends a URL on a given link Send URL on link.
Definition at line 5753 of file channel.c.
References ast_channel_sendhtml(), and AST_HTML_URL.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
{
return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
}
| void ast_channel_set_caller | ( | struct ast_channel * | chan, |
| const struct ast_party_caller * | caller, | ||
| const struct ast_set_party_caller * | update | ||
| ) |
Set the caller id information in the Asterisk channel.
| chan | Asterisk channel to set caller id information |
| caller | Caller id information |
| update | What caller information to update. NULL if all. |
Definition at line 6829 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), and ast_channel::caller.
{
if (&chan->caller == caller) {
/* Don't set to self */
return;
}
ast_channel_lock(chan);
ast_party_caller_set(&chan->caller, caller, update);
ast_channel_unlock(chan);
}
| void ast_channel_set_caller_event | ( | struct ast_channel * | chan, |
| const struct ast_party_caller * | caller, | ||
| const struct ast_set_party_caller * | update | ||
| ) |
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed.
| chan | Asterisk channel to set caller id information |
| caller | Caller id information |
| update | What caller information to update. NULL if all. |
Definition at line 6841 of file channel.c.
References ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), S_COR, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.
Referenced by callerid_write(), dial_exec_full(), do_forward(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().
{
const char *pre_set_number;
const char *pre_set_name;
if (&chan->caller == caller) {
/* Don't set to self */
return;
}
ast_channel_lock(chan);
pre_set_number =
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
pre_set_name = S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL);
ast_party_caller_set(&chan->caller, caller, update);
if (S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)
!= pre_set_number
|| S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL)
!= pre_set_name) {
/* The caller id name or number changed. */
report_new_callerid(chan);
}
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
}
ast_channel_unlock(chan);
}
| void ast_channel_set_connected_line | ( | struct ast_channel * | chan, |
| const struct ast_party_connected_line * | connected, | ||
| const struct ast_set_party_connected_line * | update | ||
| ) |
Set the connected line information in the Asterisk channel.
| chan | Asterisk channel to set connected line information |
| connected | Connected line information |
| update | What connected line information to update. NULL if all. |
Definition at line 8152 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_connected_line_set(), and ast_channel::connected.
Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), and feature_request_and_dial().
{
if (&chan->connected == connected) {
/* Don't set to self */
return;
}
ast_channel_lock(chan);
ast_party_connected_line_set(&chan->connected, connected, update);
ast_channel_unlock(chan);
}
| void ast_channel_set_fd | ( | struct ast_channel * | chan, |
| int | which, | ||
| int | fd | ||
| ) |
Set the file descriptor on the channel
Definition at line 2576 of file channel.c.
References ast_calloc, ast_epoll_data::chan, chanlist::chan, ast_channel::fds, free, and ast_epoll_data::which.
Referenced by __ast_channel_alloc_ap(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), alsa_new(), ast_deactivate_generator(), ast_do_masquerade(), dahdi_new(), gtalk_new(), jingle_new(), mgcp_new(), misdn_new(), my_swap_subchannels(), nbs_new(), oss_new(), phone_new(), process_sdp(), setformat(), sip_new(), skinny_new(), start_rtp(), and swap_subs().
{
#ifdef HAVE_EPOLL
struct epoll_event ev;
struct ast_epoll_data *aed = NULL;
if (chan->fds[which] > -1) {
epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev);
aed = chan->epfd_data[which];
}
/* If this new fd is valid, add it to the epoll */
if (fd > -1) {
if (!aed && (!(aed = ast_calloc(1, sizeof(*aed)))))
return;
chan->epfd_data[which] = aed;
aed->chan = chan;
aed->which = which;
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.ptr = aed;
epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev);
} else if (aed) {
/* We don't have to keep around this epoll data structure now */
free(aed);
chan->epfd_data[which] = NULL;
}
#endif
chan->fds[which] = fd;
return;
}
| void ast_channel_set_linkgroup | ( | struct ast_channel * | chan, |
| struct ast_channel * | peer | ||
| ) |
Propagate the oldest linkedid between associated channels.
propagate the linked id between chan and peer
Definition at line 6222 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_change_linkedid(), ast_strdupa, ast_channel::linkedid, oldest_linkedid(), and ast_channel::uniqueid.
Referenced by ast_bridge_call(), and ast_do_masquerade().
{
const char* linkedid=NULL;
struct ast_channel *bridged;
linkedid = oldest_linkedid(chan->linkedid, peer->linkedid);
linkedid = oldest_linkedid(linkedid, chan->uniqueid);
linkedid = oldest_linkedid(linkedid, peer->uniqueid);
if (chan->_bridge) {
bridged = ast_bridged_channel(chan);
if (bridged != peer) {
linkedid = oldest_linkedid(linkedid, bridged->linkedid);
linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
}
}
if (peer->_bridge) {
bridged = ast_bridged_channel(peer);
if (bridged != chan) {
linkedid = oldest_linkedid(linkedid, bridged->linkedid);
linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
}
}
/* just in case setting a stringfield to itself causes problems */
linkedid = ast_strdupa(linkedid);
ast_channel_change_linkedid(chan, linkedid);
ast_channel_change_linkedid(peer, linkedid);
if (chan->_bridge) {
bridged = ast_bridged_channel(chan);
if (bridged != peer) {
ast_channel_change_linkedid(bridged, linkedid);
}
}
if (peer->_bridge) {
bridged = ast_bridged_channel(peer);
if (bridged != chan) {
ast_channel_change_linkedid(bridged, linkedid);
}
}
}
| void ast_channel_set_redirecting | ( | struct ast_channel * | chan, |
| const struct ast_party_redirecting * | redirecting, | ||
| const struct ast_set_party_redirecting * | update | ||
| ) |
Set the redirecting id information in the Asterisk channel.
| chan | Asterisk channel to set redirecting id information |
| redirecting | Redirecting id information |
| update | What redirecting information to update. NULL if all. |
Definition at line 8805 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_redirecting_set(), and ast_channel::redirecting.
Referenced by ast_indicate_data(), do_forward(), handle_request_invite(), handle_response(), misdn_copy_redirecting_to_ast(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().
{
if (&chan->redirecting == redirecting) {
/* Don't set to self */
return;
}
ast_channel_lock(chan);
ast_party_redirecting_set(&chan->redirecting, redirecting, update);
ast_channel_unlock(chan);
}
| int ast_channel_setoption | ( | struct ast_channel * | channel, |
| int | option, | ||
| void * | data, | ||
| int | datalen, | ||
| int | block | ||
| ) |
Sets an option on a channel.
| channel | channel to set options on |
| option | option to change |
| data | data specific to option |
| datalen | length of the data |
| block | blocking or not |
Set an option on a channel (see frame.h), optionally blocking awaiting the reply
Definition at line 7524 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.
Referenced by analog_hangup(), ast_bridge_call(), ast_channel_make_compatible_helper(), common_exec(), conf_run(), dahdi_hangup(), dial_exec_full(), func_channel_write(), func_channel_write_real(), handle_tddmode(), play_record_review(), rcvfax_exec(), reset_volumes(), rpt(), rpt_exec(), set_format(), set_listen_volume(), set_security_requirements(), set_talk_volume(), sndfax_exec(), try_calling(), and vm_forwardoptions().
{
int res;
ast_channel_lock(chan);
if (!chan->tech->setoption) {
errno = ENOSYS;
ast_channel_unlock(chan);
return -1;
}
if (block)
ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
res = chan->tech->setoption(chan, option, data, datalen);
ast_channel_unlock(chan);
return res;
}
| void ast_channel_setwhentohangup | ( | struct ast_channel * | chan, |
| time_t | offset | ||
| ) |
Set when to hang a channel up.
| chan | channel on which to check for hang up |
| offset | offset in seconds relative to the current time of when to hang up |
This function sets the absolute time out on a channel (when to hang up).
Definition at line 857 of file channel.c.
References ast_channel_setwhentohangup_tv().
{
struct timeval when = { offset, };
ast_channel_setwhentohangup_tv(chan, when);
}
| void ast_channel_setwhentohangup_tv | ( | struct ast_channel * | chan, |
| struct timeval | offset | ||
| ) |
Set when to hangup channel.
Set when to hang a channel up.
Definition at line 850 of file channel.c.
References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by action_timeout(), ast_channel_setwhentohangup(), handle_autohangup(), sig_pri_send_aoce_termination_request(), and timeout_write().
{
chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow());
ast_queue_frame(chan, &ast_null_frame);
return;
}
| static int ast_channel_softhangup_cb | ( | void * | obj, |
| void * | arg, | ||
| int | flags | ||
| ) | [static] |
Definition at line 813 of file channel.c.
References ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.
Referenced by ast_begin_shutdown().
{
struct ast_channel *chan = obj;
ast_softhangup(chan, AST_SOFTHANGUP_SHUTDOWN);
return 0;
}
| struct ast_silence_generator* ast_channel_start_silence_generator | ( | struct ast_channel * | chan | ) | [read] |
Starts a silence generator on the given channel.
| chan | The channel to generate silence on |
This function will cause SLINEAR silence to be generated on the supplied channel until it is disabled; if the channel cannot be put into SLINEAR mode then the function will fail.
Definition at line 8026 of file channel.c.
References ast_activate_generator(), ast_calloc, ast_debug, AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, state, and ast_channel::writeformat.
Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), record_exec(), TransferCallStep1(), waitfor_exec(), and waitforring_exec().
{
struct ast_silence_generator *state;
if (!(state = ast_calloc(1, sizeof(*state)))) {
return NULL;
}
state->old_write_format = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
ast_free(state);
return NULL;
}
ast_activate_generator(chan, &silence_generator, state);
ast_debug(1, "Started silence generator on '%s'\n", chan->name);
return state;
}
| void ast_channel_stop_silence_generator | ( | struct ast_channel * | chan, |
| struct ast_silence_generator * | state | ||
| ) |
Stops a previously-started silence generator on the given channel.
| chan | The channel to operate on |
| state | The ast_silence_generator pointer return by a previous call to ast_channel_start_silence_generator. |
This function will stop the operating silence generator and return the channel to its previous write format.
Definition at line 8049 of file channel.c.
References ast_deactivate_generator(), ast_debug, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, and ast_silence_generator::old_write_format.
Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), HandleCallOutgoing(), key_dial_page(), record_exec(), unistim_hangup(), waitfor_exec(), and waitforring_exec().
{
if (!state)
return;
ast_deactivate_generator(chan);
ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
if (ast_set_write_format(chan, state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
ast_free(state);
}
| int ast_channel_supports_html | ( | struct ast_channel * | channel | ) |
Checks for HTML support on a channel.
Definition at line 5741 of file channel.c.
References ast_channel_tech::send_html, and ast_channel::tech.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
| int ast_channel_transfer_masquerade | ( | struct ast_channel * | target_chan, |
| const struct ast_party_connected_line * | target_id, | ||
| int | target_held, | ||
| struct ast_channel * | transferee_chan, | ||
| const struct ast_party_connected_line * | transferee_id, | ||
| int | transferee_held | ||
| ) |
Setup a masquerade to transfer a call.
| target_chan | Target of the call transfer. (Masquerade original channel) |
| target_id | New connected line information for the target channel. |
| target_held | TRUE if the target call is on hold. |
| transferee_chan | Transferee of the call transfer. (Masquerade clone channel) |
| transferee_id | New connected line information for the transferee channel. |
| transferee_held | TRUE if the transferee call is on hold. |
Party A - Transferee Party B - Transferer Party C - Target of transfer
Party B transfers A to C.
Party A is connected to bridged channel B1. Party B is connected to channels C1 and C2. Party C is connected to bridged channel B2.
Party B -- C1 == B1 -- Party A __/ / Party B -- C2 == B2 -- Party C
Bridged channel B1 is masqueraded into channel C2. Where B1 is the masquerade clone channel and C2 is the masquerade original channel.
| 0 | on success. |
| -1 | on error. |
Definition at line 6023 of file channel.c.
References __ast_channel_masquerade(), ast_calloc, ast_datastore_alloc(), ast_datastore_free(), ast_datastore::data, party_connected_line_copy_transfer(), xfer_masquerade_ds::target_held, xfer_masquerade_ds::target_id, xfer_masquerade_ds::transferee_held, and xfer_masquerade_ds::transferee_id.
Referenced by analog_attempt_transfer(), misdn_attempt_transfer(), and sig_pri_attempt_transfer().
{
struct ast_datastore *xfer_ds;
struct xfer_masquerade_ds *xfer_colp;
int res;
xfer_ds = ast_datastore_alloc(&xfer_ds_info, NULL);
if (!xfer_ds) {
return -1;
}
xfer_colp = ast_calloc(1, sizeof(*xfer_colp));
if (!xfer_colp) {
ast_datastore_free(xfer_ds);
return -1;
}
party_connected_line_copy_transfer(&xfer_colp->target_id, target_id);
xfer_colp->target_held = target_held;
party_connected_line_copy_transfer(&xfer_colp->transferee_id, transferee_id);
xfer_colp->transferee_held = transferee_held;
xfer_ds->data = xfer_colp;
res = __ast_channel_masquerade(target_chan, transferee_chan, xfer_ds);
if (res) {
ast_datastore_free(xfer_ds);
}
return res;
}
| void ast_channel_undefer_dtmf | ( | struct ast_channel * | chan | ) |
Unset defer DTMF flag on channel.
Undo defer. ast_read will return any DTMF characters that were queued
Definition at line 1589 of file channel.c.
References ast_clear_flag, and AST_FLAG_DEFER_DTMF.
Referenced by __adsi_transmit_messages(), find_cache(), and rpt_call().
{
if (chan)
ast_clear_flag(chan, AST_FLAG_DEFER_DTMF);
}
| void ast_channel_unregister | ( | const struct ast_channel_tech * | tech | ) |
Unregister channel driver.
Unregister a channel technology.
Definition at line 917 of file channel.c.
References ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, chanlist::tech, and ast_channel_tech::type.
Referenced by __unload_module(), load_module(), and unload_module().
{
struct chanlist *chan;
ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
AST_RWLIST_WRLOCK(&backends);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) {
if (chan->tech == tech) {
AST_LIST_REMOVE_CURRENT(list);
ast_free(chan);
ast_verb(2, "Unregistered channel type '%s'\n", tech->type);
break;
}
}
AST_LIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&backends);
}
| void ast_channel_update_connected_line | ( | struct ast_channel * | chan, |
| const struct ast_party_connected_line * | connected, | ||
| const struct ast_set_party_connected_line * | update | ||
| ) |
Indicate that the connected line information has changed.
| chan | Asterisk channel to indicate connected line information |
| connected | Connected line information |
| update | What connected line information to update. NULL if all. |
Definition at line 8779 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_indicate_data().
Referenced by ast_channel_connected_line_macro(), ast_do_pickup(), atxfer_fail_cleanup(), builtin_atxfer(), connectedline_write(), parked_call_exec(), and wait_for_answer().
{
unsigned char data[1024]; /* This should be large enough */
size_t datalen;
datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
if (datalen == (size_t) -1) {
return;
}
ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
}
| void ast_channel_update_redirecting | ( | struct ast_channel * | chan, |
| const struct ast_party_redirecting * | redirecting, | ||
| const struct ast_set_party_redirecting * | update | ||
| ) |
Indicate that the redirecting id has changed.
| chan | Asterisk channel to indicate redirecting id information |
| redirecting | Redirecting id information |
| update | What redirecting information to update. NULL if all. |
Definition at line 9286 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_indicate_data(), and ast_redirecting_build_data().
Referenced by ast_channel_redirecting_macro(), call_forward_inherit(), do_forward(), redirecting_write(), and wait_for_answer().
{
unsigned char data[1024]; /* This should be large enough */
size_t datalen;
datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
if (datalen == (size_t) -1) {
return;
}
ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
}
| void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 7940 of file channel.c.
References ao2_container_alloc, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_cli_register_multiple(), ast_data_register_multiple_core, ast_plc_reload(), channels, cli_channel, and NUM_CHANNEL_BUCKETS.
Referenced by main().
| struct ast_variable* ast_channeltype_list | ( | void | ) | [read] |
return an ast_variable list of channeltypes
Definition at line 247 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new(), ast_channel_tech::description, chanlist::tech, ast_channel_tech::type, and var.
Referenced by ast_var_channel_types(), and ast_var_channel_types_table().
{
struct chanlist *cl;
struct ast_variable *var = NULL, *prev = NULL;
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
if (prev) {
if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, "")))
prev = prev->next;
} else {
var = ast_variable_new(cl->tech->type, cl->tech->description, "");
prev = var;
}
}
AST_RWLIST_UNLOCK(&backends);
return var;
}
| int ast_check_hangup | ( | struct ast_channel * | chan | ) |
Checks to see if a channel is needing hang up.
Check to see if a channel is needing hang up.
Definition at line 791 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by __ast_pbx_run(), __ast_read(), _macro_exec(), agent_indicate(), agi_exec(), agi_handle_command(), announce_thread(), ast_bridge_call(), ast_call(), ast_channel_bridge(), ast_check_hangup_locked(), ast_indicate_data(), ast_raw_answer(), ast_readstring_full(), ast_recvtext(), ast_rtp_instance_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), autoservice_run(), bridge_call_thread(), bridge_exec(), builtin_atxfer(), call_forward_inherit(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), feature_request_and_dial(), findmeexec(), func_channel_read(), handle_sendimage(), iax2_bridge(), launch_asyncagi(), local_bridge_loop(), local_fixup(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_builtin_waitexten(), pbx_exec(), read_exec(), readexten_exec(), remote_bridge_loop(), rpt(), rpt_exec(), run_agi(), run_ras(), try_calling(), and wait_for_answer().
{
if (chan->_softhangup) /* yes if soft hangup flag set */
return 1;
if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */
return 0;
if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */
return 0;
ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow()));
chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */
return 1;
}
| int ast_check_hangup_locked | ( | struct ast_channel * | chan | ) |
Definition at line 804 of file channel.c.
References ast_channel_lock, ast_channel_unlock, and ast_check_hangup().
Referenced by action_redirect(), and ast_channel_bridge().
{
int res;
ast_channel_lock(chan);
res = ast_check_hangup(chan);
ast_channel_unlock(chan);
return res;
}
| int ast_connected_line_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_connected_line * | connected, | ||
| const struct ast_set_party_connected_line * | update | ||
| ) |
Build the connected line information data frame.
| data | Buffer to fill with the frame data |
| datalen | Size of the buffer to fill |
| connected | Connected line information |
| update | What connected line information to build. NULL if all. |
| -1 | if error |
| Amount | of data buffer used |
Definition at line 8519 of file channel.c.
References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log(), ast_party_connected_line::id, ast_set_party_connected_line::id, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_connected_line::source, ast_party_name_ies::str, and value.
Referenced by ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), local_attended_transfer(), local_indicate(), and masquerade_colp_transfer().
{
int32_t value;
size_t pos = 0;
int res;
static const struct ast_party_id_ies ies = {
.name.str = AST_CONNECTED_LINE_NAME,
.name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
.name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
.name.valid = AST_CONNECTED_LINE_NAME_VALID,
.number.str = AST_CONNECTED_LINE_NUMBER,
.number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
.number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
.number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
.subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
.subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
.subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
.subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
.tag = AST_CONNECTED_LINE_TAG,
.combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
};
/*
* The size of integer values must be fixed in case the frame is
* shipped to another machine.
*/
/* Connected line frame version */
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for connected line frame version\n");
return -1;
}
data[pos++] = AST_CONNECTED_LINE_VERSION;
data[pos++] = 1;
data[pos++] = 2;/* Version 1 did not have a version ie */
res = party_id_build_data(data + pos, datalen - pos, &connected->id,
"connected line", &ies, update ? &update->id : NULL);
if (res < 0) {
return -1;
}
pos += res;
/* Connected line source */
if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
ast_log(LOG_WARNING, "No space left for connected line source\n");
return -1;
}
data[pos++] = AST_CONNECTED_LINE_SOURCE;
data[pos++] = sizeof(value);
value = htonl(connected->source);
memcpy(data + pos, &value, sizeof(value));
pos += sizeof(value);
return pos;
}
| void ast_connected_line_copy_from_caller | ( | struct ast_party_connected_line * | dest, |
| const struct ast_party_caller * | src | ||
| ) |
Copy the caller information to the connected line information.
| dest | Destination connected line information |
| src | Source caller information |
Definition at line 8137 of file channel.c.
References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_caller::id, and ast_party_connected_line::id.
Referenced by ast_do_pickup(), begin_dial_channel(), builtin_atxfer(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), local_call(), parked_call_exec(), ring_entry(), and wait_for_answer().
{
ast_party_id_copy(&dest->id, &src->id);
ast_party_id_copy(&dest->ani, &src->ani);
dest->ani2 = src->ani2;
}
| void ast_connected_line_copy_to_caller | ( | struct ast_party_caller * | dest, |
| const struct ast_party_connected_line * | src | ||
| ) |
Copy the connected line information to the caller information.
| dest | Destination caller information |
| src | Source connected line information |
Definition at line 8144 of file channel.c.
References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_caller::id, and ast_party_connected_line::id.
Referenced by local_call(), and local_indicate().
{
ast_party_id_copy(&dest->id, &src->id);
ast_party_id_copy(&dest->ani, &src->ani);
dest->ani2 = src->ani2;
}
| int ast_connected_line_parse_data | ( | const unsigned char * | data, |
| size_t | datalen, | ||
| struct ast_party_connected_line * | connected | ||
| ) |
Parse connected line indication frame data.
| data | Buffer with the frame data to parse |
| datalen | Size of the buffer |
| connected | Extracted connected line information |
| 0 | on success. |
| -1 | on error. |
Definition at line 8580 of file channel.c.
References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_free, ast_log(), ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, ast_party_name::char_set, ast_party_id_ies::combined_presentation, ast_party_connected_line::id, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_connected_line::source, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.
Referenced by __ast_read(), ast_channel_connected_line_macro(), ast_indicate_data(), feature_request_and_dial(), socket_process(), and wait_for_answer().
{
size_t pos;
unsigned char ie_len;
unsigned char ie_id;
int32_t value;
int frame_version = 1;
int combined_presentation = 0;
int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
for (pos = 0; pos < datalen; pos += ie_len) {
if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
ast_log(LOG_WARNING, "Invalid connected line update\n");
return -1;
}
ie_id = data[pos++];
ie_len = data[pos++];
if (datalen < pos + ie_len) {
ast_log(LOG_WARNING, "Invalid connected line update\n");
return -1;
}
switch (ie_id) {
/* Connected line party frame version */
case AST_CONNECTED_LINE_VERSION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
(unsigned) ie_len);
break;
}
frame_version = data[pos];
break;
/* Connected line party id name */
case AST_CONNECTED_LINE_NAME:
ast_free(connected->id.name.str);
connected->id.name.str = ast_malloc(ie_len + 1);
if (connected->id.name.str) {
memcpy(connected->id.name.str, data + pos, ie_len);
connected->id.name.str[ie_len] = 0;
}
break;
case AST_CONNECTED_LINE_NAME_CHAR_SET:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.name.char_set = data[pos];
break;
case AST_CONNECTED_LINE_NAME_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.name.presentation = data[pos];
break;
case AST_CONNECTED_LINE_NAME_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.name.valid = data[pos];
break;
/* Connected line party id number */
case AST_CONNECTED_LINE_NUMBER:
ast_free(connected->id.number.str);
connected->id.number.str = ast_malloc(ie_len + 1);
if (connected->id.number.str) {
memcpy(connected->id.number.str, data + pos, ie_len);
connected->id.number.str[ie_len] = 0;
}
break;
case AST_CONNECTED_LINE_NUMBER_PLAN:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.number.plan = data[pos];
break;
case AST_CONNECTED_LINE_NUMBER_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.number.presentation = data[pos];
break;
case AST_CONNECTED_LINE_NUMBER_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.number.valid = data[pos];
break;
/* Connected line party id combined presentation */
case AST_CONNECTED_LINE_ID_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
(unsigned) ie_len);
break;
}
combined_presentation = data[pos];
got_combined_presentation = 1;
break;
/* Connected line party id subaddress */
case AST_CONNECTED_LINE_SUBADDRESS:
ast_free(connected->id.subaddress.str);
connected->id.subaddress.str = ast_malloc(ie_len + 1);
if (connected->id.subaddress.str) {
memcpy(connected->id.subaddress.str, data + pos, ie_len);
connected->id.subaddress.str[ie_len] = 0;
}
break;
case AST_CONNECTED_LINE_SUBADDRESS_TYPE:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.subaddress.type = data[pos];
break;
case AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN:
if (ie_len != 1) {
ast_log(LOG_WARNING,
"Invalid connected line subaddress odd-even indicator (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.subaddress.odd_even_indicator = data[pos];
break;
case AST_CONNECTED_LINE_SUBADDRESS_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
(unsigned) ie_len);
break;
}
connected->id.subaddress.valid = data[pos];
break;
/* Connected line party tag */
case AST_CONNECTED_LINE_TAG:
ast_free(connected->id.tag);
connected->id.tag = ast_malloc(ie_len + 1);
if (connected->id.tag) {
memcpy(connected->id.tag, data + pos, ie_len);
connected->id.tag[ie_len] = 0;
}
break;
/* Connected line party source */
case AST_CONNECTED_LINE_SOURCE:
if (ie_len != sizeof(value)) {
ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
(unsigned) ie_len);
break;
}
memcpy(&value, data + pos, sizeof(value));
connected->source = ntohl(value);
break;
/* Connected line party unknown element */
default:
ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n",
(unsigned) ie_id, (unsigned) ie_len);
break;
}
}
switch (frame_version) {
case 1:
/*
* The other end is an earlier version that we need to adjust
* for compatibility.
*/
connected->id.name.valid = 1;
connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
connected->id.number.valid = 1;
if (got_combined_presentation) {
connected->id.name.presentation = combined_presentation;
connected->id.number.presentation = combined_presentation;
}
break;
case 2:
/* The other end is at the same level as we are. */
break;
default:
/*
* The other end is newer than we are.
* We need to assume that they are compatible with us.
*/
ast_log(LOG_DEBUG, "Connected line frame has newer version: %u\n",
(unsigned) frame_version);
break;
}
return 0;
}
| AST_DATA_STRUCTURE | ( | ast_channel | , |
| DATA_EXPORT_CHANNEL | |||
| ) |
| void ast_deactivate_generator | ( | struct ast_channel * | chan | ) |
Deactivate an active generator
Definition at line 3029 of file channel.c.
References ast_channel_lock, ast_channel_set_fd(), ast_channel_unlock, ast_clear_flag, AST_FLAG_WRITE_INT, AST_GENERATOR_FD, ast_settimeout(), ast_channel::generator, ast_channel::generatordata, and ast_generator::release.
Referenced by __ast_read(), app_exec(), ast_channel_stop_silence_generator(), ast_openstream_full(), ast_playtones_stop(), ast_quiet_chan(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write(), cb_events(), channel_spy(), dial_exec_full(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), transmit_audio(), and wait_for_answer().
{
ast_channel_lock(chan);
if (chan->generatordata) {
if (chan->generator && chan->generator->release)
chan->generator->release(chan, chan->generatordata);
chan->generatordata = NULL;
chan->generator = NULL;
ast_channel_set_fd(chan, AST_GENERATOR_FD, -1);
ast_clear_flag(chan, AST_FLAG_WRITE_INT);
ast_settimeout(chan, 0, NULL, NULL);
}
ast_channel_unlock(chan);
}
| int ast_do_masquerade | ( | struct ast_channel * | original | ) |
Masquerade a channel.
Start masquerading a channel.
Definition at line 6381 of file channel.c.
References __ast_change_name_nolink(), ast_channel::_bridge, ast_channel::_softhangup, ast_channel::_state, accountcode, ast_channel::accountcode, ast_channel::adsicpe, ast_channel::alertpipe, ao2_link, ao2_lock, ao2_unlink, ao2_unlock, ast_app_group_update(), ast_autochan_new_channel(), ast_bridged_channel(), ast_cause2str(), AST_CEL_BRIDGE_UPDATE, ast_cel_report_event(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_release(), ast_channel_set_fd(), ast_channel_set_linkgroup(), ast_channel_trylock, ast_channel_unlock, AST_CONTROL_SRCCHANGE, AST_CONTROL_UNHOLD, ast_copy_string(), ast_datastore_free(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_GENERATOR_FD, ast_getformatname(), ast_indicate(), ast_kill_tech, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_NOLOCK, AST_LIST_HEAD_SET_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_manager_event, ast_manager_event_multichan, AST_MAX_FDS, ast_null_frame, ast_queue_frame(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_state2str(), ast_string_field_set, ast_test_flag, AST_TIMING_FD, ast_channel::blocker, ast_channel::caller, ast_channel::cdr, ast_datastore_info::chan_fixup, CHANNEL_DEADLOCK_AVOIDANCE, channels, clone_variables(), ast_channel::connected, ast_datastore::data, ast_channel::datastores, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::fdno, ast_channel::fds, ast_channel_tech::fixup, free_translation(), ast_channel_tech::hangup, ast_channel::hangupcause, ast_datastore::info, language, ast_channel::language, LOG_WARNING, ast_channel::masq, ast_channel::masqr, masquerade_colp_transfer(), ast_channel::monitor, musicclass, ast_channel::musicclass, ast_channel::name, ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, ast_channel::redirecting, report_new_callerid(), S_OR, ast_channel::tech, ast_channel::tech_pvt, ast_channel::timingfd, xfer_masquerade_ds::transferee_held, ast_channel_tech::type, ast_channel::uniqueid, ast_channel::visible_indication, and ast_channel::writeformat.
Referenced by __ast_read(), ast_async_goto(), ast_do_pickup(), ast_hangup(), ast_waitfor_nandfds(), ast_write(), builtin_atxfer(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), local_attended_transfer(), masq_park_call(), and sip_park().
{
format_t x;
int i;
int res=0;
int origstate;
int visible_indication;
struct ast_frame *current;
const struct ast_channel_tech *t;
void *t_pvt;
union {
struct ast_party_dialed dialed;
struct ast_party_caller caller;
struct ast_party_connected_line connected;
struct ast_party_redirecting redirecting;
} exchange;
struct ast_channel *clonechan, *chans[2];
struct ast_channel *bridged;
struct ast_cdr *cdr;
struct ast_datastore *xfer_ds;
struct xfer_masquerade_ds *xfer_colp;
format_t rformat = original->readformat;
format_t wformat = original->writeformat;
char newn[AST_CHANNEL_NAME];
char orig[AST_CHANNEL_NAME];
char masqn[AST_CHANNEL_NAME];
char zombn[AST_CHANNEL_NAME];
/* XXX This operation is a bit odd. We're essentially putting the guts of
* the clone channel into the original channel. Start by killing off the
* original channel's backend. While the features are nice, which is the
* reason we're keeping it, it's still awesomely weird. XXX */
/* The reasoning for the channels ao2_container lock here is complex.
*
* In order to check for a race condition, the original channel must
* be locked. If it is determined that the masquerade should proceed
* the original channel can absolutely not be unlocked until the end
* of the function. Since after determining the masquerade should
* continue requires the channels to be unlinked from the ao2_container,
* the container lock must be held first to achieve proper locking order.
*/
ao2_lock(channels);
/* lock the original channel to determine if the masquerade is required or not */
ast_channel_lock(original);
/*
* This checks to see if the masquerade has already happened or
* not. There is a race condition that exists for this
* function. Since all pvt and channel locks must be let go
* before calling do_masquerade, it is possible that it could be
* called multiple times for the same channel. This check
* verifies whether or not the masquerade has already been
* completed by another thread.
*/
while ((clonechan = original->masq) && ast_channel_trylock(clonechan)) {
/*
* A masq is needed but we could not get the clonechan lock
* immediately. Since this function already holds the global
* container lock, unlocking original for deadlock avoidance
* will not result in any sort of masquerade race condition. If
* masq is called by a different thread while this happens, it
* will be stuck waiting until we unlock the container.
*/
CHANNEL_DEADLOCK_AVOIDANCE(original);
}
/*
* A final masq check must be done after deadlock avoidance for
* clonechan above or we could get a double masq. This is
* posible with ast_hangup at least.
*/
if (!clonechan) {
/* masq already completed by another thread, or never needed to be done to begin with */
ast_channel_unlock(original);
ao2_unlock(channels);
return 0;
}
/* Get any transfer masquerade connected line exchange data. */
xfer_ds = ast_channel_datastore_find(original, &xfer_ds_info, NULL);
if (xfer_ds) {
ast_channel_datastore_remove(original, xfer_ds);
xfer_colp = xfer_ds->data;
} else {
xfer_colp = NULL;
}
/*
* Release any hold on the transferee channel before proceeding
* with the masquerade.
*/
if (xfer_colp && xfer_colp->transferee_held) {
ast_indicate(clonechan, AST_CONTROL_UNHOLD);
}
/* clear the masquerade channels */
original->masq = NULL;
clonechan->masqr = NULL;
/* unlink from channels container as name (which is the hash value) will change */
ao2_unlink(channels, original);
ao2_unlink(channels, clonechan);
ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
clonechan->name, clonechan->_state, original->name, original->_state);
/*
* Stop any visible indiction on the original channel so we can
* transfer it to the clonechan taking the original's place.
*/
visible_indication = original->visible_indication;
ast_indicate(original, -1);
chans[0] = clonechan;
chans[1] = original;
ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans,
"Clone: %s\r\n"
"CloneState: %s\r\n"
"Original: %s\r\n"
"OriginalState: %s\r\n",
clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state));
/* Having remembered the original read/write formats, we turn off any translation on either
one */
free_translation(clonechan);
free_translation(original);
/* Save the original name */
ast_copy_string(orig, original->name, sizeof(orig));
/* Save the new name */
ast_copy_string(newn, clonechan->name, sizeof(newn));
/* Create the masq name */
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
/* Mangle the name of the clone channel */
__ast_change_name_nolink(clonechan, masqn);
/* Copy the name from the clone channel */
__ast_change_name_nolink(original, newn);
/* share linked id's */
ast_channel_set_linkgroup(original, clonechan);
/* Swap the technologies */
t = original->tech;
original->tech = clonechan->tech;
clonechan->tech = t;
/* Swap the cdrs */
cdr = original->cdr;
original->cdr = clonechan->cdr;
clonechan->cdr = cdr;
t_pvt = original->tech_pvt;
original->tech_pvt = clonechan->tech_pvt;
clonechan->tech_pvt = t_pvt;
/* Swap the alertpipes */
for (i = 0; i < 2; i++) {
x = original->alertpipe[i];
original->alertpipe[i] = clonechan->alertpipe[i];
clonechan->alertpipe[i] = x;
}
/*
* Swap the readq's. The end result should be this:
*
* 1) All frames should be on the new (original) channel.
* 2) Any frames that were already on the new channel before this
* masquerade need to be at the end of the readq, after all of the
* frames on the old (clone) channel.
* 3) The alertpipe needs to get poked for every frame that was already
* on the new channel, since we are now using the alert pipe from the
* old (clone) channel.
*/
{
AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq;
AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL);
AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list);
AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list);
while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
if (original->alertpipe[1] > -1) {
int poke = 0;
if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
}
}
/* Swap the raw formats */
x = original->rawreadformat;
original->rawreadformat = clonechan->rawreadformat;
clonechan->rawreadformat = x;
x = original->rawwriteformat;
original->rawwriteformat = clonechan->rawwriteformat;
clonechan->rawwriteformat = x;
clonechan->_softhangup = AST_SOFTHANGUP_DEV;
/* And of course, so does our current state. Note we need not
call ast_setstate since the event manager doesn't really consider
these separate. We do this early so that the clone has the proper
state of the original channel. */
origstate = original->_state;
original->_state = clonechan->_state;
clonechan->_state = origstate;
if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name);
}
/* Start by disconnecting the original's physical side */
if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) {
ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n");
res = -1;
goto done;
}
/*
* We just hung up the physical side of the channel. Set the
* new zombie to use the kill channel driver for safety.
*/
clonechan->tech = &ast_kill_tech;
/* Mangle the name of the clone channel */
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
__ast_change_name_nolink(clonechan, zombn);
/* Update the type. */
t_pvt = original->monitor;
original->monitor = clonechan->monitor;
clonechan->monitor = t_pvt;
/* Keep the same language. */
ast_string_field_set(original, language, clonechan->language);
/* Copy the FD's other than the generator fd */
for (x = 0; x < AST_MAX_FDS; x++) {
if (x != AST_GENERATOR_FD)
ast_channel_set_fd(original, x, clonechan->fds[x]);
}
ast_app_group_update(clonechan, original);
/* Move data stores over */
if (AST_LIST_FIRST(&clonechan->datastores)) {
struct ast_datastore *ds;
/* We use a safe traversal here because some fixup routines actually
* remove the datastore from the list and free them.
*/
AST_LIST_TRAVERSE_SAFE_BEGIN(&clonechan->datastores, ds, entry) {
if (ds->info->chan_fixup)
ds->info->chan_fixup(ds->data, clonechan, original);
}
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry);
}
ast_autochan_new_channel(clonechan, original);
clone_variables(original, clonechan);
/* Presense of ADSI capable CPE follows clone */
original->adsicpe = clonechan->adsicpe;
/* Bridge remains the same */
/* CDR fields remain the same */
/* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
/* Application and data remain the same */
/* Clone exception becomes real one, as with fdno */
ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING));
original->fdno = clonechan->fdno;
/* Schedule context remains the same */
/* Stream stuff stays the same */
/* Keep the original state. The fixup code will need to work with it most likely */
/*
* Just swap the whole structures, nevermind the allocations,
* they'll work themselves out.
*/
exchange.dialed = original->dialed;
original->dialed = clonechan->dialed;
clonechan->dialed = exchange.dialed;
exchange.caller = original->caller;
original->caller = clonechan->caller;
clonechan->caller = exchange.caller;
exchange.connected = original->connected;
original->connected = clonechan->connected;
clonechan->connected = exchange.connected;
exchange.redirecting = original->redirecting;
original->redirecting = clonechan->redirecting;
clonechan->redirecting = exchange.redirecting;
report_new_callerid(original);
/* Restore original timing file descriptor */
ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
/* Our native formats are different now */
original->nativeformats = clonechan->nativeformats;
/* Context, extension, priority, app data, jump table, remain the same */
/* pvt switches. pbx stays the same, as does next */
/* Set the write format */
ast_set_write_format(original, wformat);
/* Set the read format */
ast_set_read_format(original, rformat);
/* Copy the music class */
ast_string_field_set(original, musicclass, clonechan->musicclass);
/* copy over accuntcode and set peeraccount across the bridge */
ast_string_field_set(original, accountcode, S_OR(clonechan->accountcode, ""));
if (original->_bridge) {
/* XXX - should we try to lock original->_bridge here? */
ast_string_field_set(original->_bridge, peeraccount, S_OR(clonechan->accountcode, ""));
ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
}
ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
ast_getformatname(wformat), ast_getformatname(rformat));
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
if (original->tech->fixup) {
if (original->tech->fixup(clonechan, original)) {
ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
original->tech->type, original->name);
res = -1;
goto done;
}
} else
ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n",
original->tech->type, original->name);
/*
* If an indication is currently playing, maintain it on the channel
* that is taking the place of original
*
* This is needed because the masquerade is swapping out in the internals
* of this channel, and the new channel private data needs to be made
* aware of the current visible indication (RINGING, CONGESTION, etc.)
*/
if (visible_indication) {
ast_indicate(original, visible_indication);
}
/* Now, at this point, the "clone" channel is totally F'd up. We mark it as
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name);
ast_channel_unlock(clonechan);
ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"Cause: %d\r\n"
"Cause-txt: %s\r\n",
clonechan->name,
clonechan->uniqueid,
clonechan->hangupcause,
ast_cause2str(clonechan->hangupcause)
);
clonechan = ast_channel_release(clonechan);
} else {
ast_debug(1, "Released clone lock on '%s'\n", clonechan->name);
ast_set_flag(clonechan, AST_FLAG_ZOMBIE);
ast_queue_frame(clonechan, &ast_null_frame);
}
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state);
if ((bridged = ast_bridged_channel(original))) {
ast_channel_lock(bridged);
ast_indicate(bridged, AST_CONTROL_SRCCHANGE);
ast_channel_unlock(bridged);
}
ast_indicate(original, AST_CONTROL_SRCCHANGE);
if (xfer_colp) {
/*
* After the masquerade, the original channel pointer actually
* points to the new transferee channel and the bridged channel
* is still the intended transfer target party.
*/
masquerade_colp_transfer(original, xfer_colp);
}
done:
if (xfer_ds) {
ast_datastore_free(xfer_ds);
}
/* it is possible for the clone channel to disappear during this */
if (clonechan) {
ast_channel_unlock(original);
ast_channel_unlock(clonechan);
ao2_link(channels, clonechan);
ao2_link(channels, original);
} else {
ast_channel_unlock(original);
ao2_link(channels, original);
}
ao2_unlock(channels);
return res;
}
| struct ast_channel* ast_dummy_channel_alloc | ( | void | ) | [read] |
Create a fake channel structure.
| NULL | failure |
| non-NULL | successfully allocated channel |
Definition at line 1369 of file channel.c.
References __ao2_alloc_debug(), ao2_alloc, ast_channel_unref, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_string_field_init, and ast_channel::varshead.
Referenced by acf_odbc_read(), acf_odbc_write(), action_getvar(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_pbx_outgoing_cdr_failed(), ast_str_substitute_variables_full(), cli_odbc_read(), cli_odbc_write(), custom_log(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), syslog_log(), and write_cdr().
{
struct ast_channel *tmp;
struct varshead *headp;
#if defined(REF_DEBUG)
tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
file, line, function, 1);
#elif defined(__AST_DEBUG_MALLOC)
tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
file, line, function, 0);
#else
tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor);
#endif
if (!tmp) {
/* Dummy channel structure allocation failure. */
return NULL;
}
if ((ast_string_field_init(tmp, 128))) {
return ast_channel_unref(tmp);
}
headp = &tmp->varshead;
AST_LIST_HEAD_INIT_NOLOCK(headp);
return tmp;
}
| static void ast_dummy_channel_destructor | ( | void * | obj | ) | [static] |
Free a dummy channel structure.
Definition at line 2482 of file channel.c.
References ast_cdr_discard(), AST_LIST_REMOVE_HEAD, ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_string_field_free_memory, ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::dialed, ast_channel::redirecting, and ast_channel::varshead.
Referenced by ast_dummy_channel_alloc().
{
struct ast_channel *chan = obj;
struct ast_var_t *vardata;
struct varshead *headp;
headp = &chan->varshead;
ast_party_dialed_free(&chan->dialed);
ast_party_caller_free(&chan->caller);
ast_party_connected_line_free(&chan->connected);
ast_party_redirecting_free(&chan->redirecting);
/* loop over the variables list, freeing all data and deleting list items */
/* no need to lock the list, as the channel is already locked */
while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
ast_var_delete(vardata);
if (chan->cdr) {
ast_cdr_discard(chan->cdr);
chan->cdr = NULL;
}
ast_string_field_free_memory(chan);
}
| static enum ast_bridge_result ast_generic_bridge | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1, | ||
| struct ast_bridge_config * | config, | ||
| struct ast_frame ** | fo, | ||
| struct ast_channel ** | rc | ||
| ) | [static] |
Definition at line 6953 of file channel.c.
References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_IGNORE_SIGS, AST_BRIDGE_RETRY, ast_channel_clear_softhangup(), ast_channel_connected_line_macro(), ast_channel_redirecting_macro(), ast_clear_flag, AST_CONTROL_AOC, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_debug, AST_FEATURE_WARNING_ACTIVE, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_indicate_data(), ast_jb_do_usecheck(), ast_jb_empty_and_reset(), ast_jb_get_and_deliver(), ast_jb_get_when_to_wakeup(), ast_jb_put(), ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_samp2tv(), ast_set_flag, AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_waitfor_n(), ast_write(), ast_frame::data, ast_frame::datalen, f, ast_bridge_config::feature_timer, ast_bridge_config::flags, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_frame::ptr, ast_frame::subclass, ast_channel::tech_pvt, and ast_bridge_config::timelimit.
Referenced by ast_channel_bridge().
{
/* Copy voice back and forth between the two channels. */
struct ast_channel *cs[3];
struct ast_frame *f;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
format_t o0nativeformats;
format_t o1nativeformats;
int watch_c0_dtmf;
int watch_c1_dtmf;
void *pvt0, *pvt1;
/* Indicates whether a frame was queued into a jitterbuffer */
int frame_put_in_jb = 0;
int jb_in_use;
int to;
cs[0] = c0;
cs[1] = c1;
pvt0 = c0->tech_pvt;
pvt1 = c1->tech_pvt;
o0nativeformats = c0->nativeformats;
o1nativeformats = c1->nativeformats;
watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
/* Check the need of a jitterbuffer for each channel */
jb_in_use = ast_jb_do_usecheck(c0, c1);
if (jb_in_use)
ast_jb_empty_and_reset(c0, c1);
ast_poll_channel_add(c0, c1);
if (config->feature_timer > 0 && ast_tvzero(config->nexteventts)) {
/* nexteventts is not set when the bridge is not scheduled to
* break, so calculate when the bridge should possibly break
* if a partial feature match timed out */
config->nexteventts = ast_tvadd(ast_tvnow(), ast_samp2tv(config->feature_timer, 1000));
}
for (;;) {
struct ast_channel *who, *other;
if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
(o0nativeformats != c0->nativeformats) ||
(o1nativeformats != c1->nativeformats)) {
/* Check for Masquerade, codec changes, etc */
res = AST_BRIDGE_RETRY;
break;
}
if (config->nexteventts.tv_sec) {
to = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
if (to <= 0) {
if (config->timelimit && !config->feature_timer && !ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
res = AST_BRIDGE_RETRY;
/* generic bridge ending to play warning */
ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE);
} else if (config->feature_timer) {
/* feature timer expired - make sure we do not play warning */
ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE);
res = AST_BRIDGE_RETRY;
} else {
res = AST_BRIDGE_COMPLETE;
}
break;
}
} else {
/* If a feature has been started and the bridge is configured to
* to not break, leave the channel bridge when the feature timer
* time has elapsed so the DTMF will be sent to the other side.
*/
if (!ast_tvzero(config->nexteventts)) {
int diff = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
if (diff <= 0) {
res = AST_BRIDGE_RETRY;
break;
}
}
to = -1;
}
/* Calculate the appropriate max sleep interval - in general, this is the time,
left to the closest jb delivery moment */
if (jb_in_use)
to = ast_jb_get_when_to_wakeup(c0, c1, to);
who = ast_waitfor_n(cs, 2, &to);
if (!who) {
/* No frame received within the specified timeout - check if we have to deliver now */
if (jb_in_use)
ast_jb_get_and_deliver(c0, c1);
if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
if (c0->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
}
if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
c0->_bridge = c1;
c1->_bridge = c0;
}
continue;
}
f = ast_read(who);
if (!f) {
*fo = NULL;
*rc = who;
ast_debug(1, "Didn't get a frame from channel: %s\n",who->name);
break;
}
other = (who == c0) ? c1 : c0; /* the 'other' channel */
/* Try add the frame info the who's bridged channel jitterbuff */
if (jb_in_use)
frame_put_in_jb = !ast_jb_put(other, f);
if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
int bridge_exit = 0;
switch (f->subclass.integer) {
case AST_CONTROL_AOC:
ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_REDIRECTING:
if (ast_channel_redirecting_macro(who, other, f, other == c0, 1)) {
ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
case AST_CONTROL_CONNECTED_LINE:
if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) {
ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_T38_PARAMETERS:
ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
if (jb_in_use) {
ast_jb_empty_and_reset(c0, c1);
}
break;
default:
*fo = f;
*rc = who;
bridge_exit = 1;
ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name);
break;
}
if (bridge_exit)
break;
}
if ((f->frametype == AST_FRAME_VOICE) ||
(f->frametype == AST_FRAME_DTMF_BEGIN) ||
(f->frametype == AST_FRAME_DTMF) ||
(f->frametype == AST_FRAME_VIDEO) ||
(f->frametype == AST_FRAME_IMAGE) ||
(f->frametype == AST_FRAME_HTML) ||
(f->frametype == AST_FRAME_MODEM) ||
(f->frametype == AST_FRAME_TEXT)) {
/* monitored dtmf causes exit from bridge */
int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf;
if (monitored_source &&
(f->frametype == AST_FRAME_DTMF_END ||
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
ast_debug(1, "Got DTMF %s on channel (%s)\n",
f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
who->name);
break;
}
/* Write immediately frames, not passed through jb */
if (!frame_put_in_jb)
ast_write(other, f);
/* Check if we have to deliver now */
if (jb_in_use)
ast_jb_get_and_deliver(c0, c1);
}
/* XXX do we want to pass on also frames not matched above ? */
ast_frfree(f);
#ifndef HAVE_EPOLL
/* Swap who gets priority */
cs[2] = cs[0];
cs[0] = cs[1];
cs[1] = cs[2];
#endif
}
ast_poll_channel_del(c0, c1);
return res;
}
| struct ast_channel_tech* ast_get_channel_tech | ( | const char * | name | ) | [read] |
Get handle to channel driver based on name.
Get a channel technology structure by name.
Definition at line 939 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::tech, and ast_channel_tech::type.
Referenced by __ast_channel_alloc_ap(), _ast_device_state(), ast_cc_callback(), and ast_var_channel_types_table().
{
struct chanlist *chanls;
const struct ast_channel_tech *ret = NULL;
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, chanls, list) {
if (!strcasecmp(name, chanls->tech->type)) {
ret = chanls->tech;
break;
}
}
AST_RWLIST_UNLOCK(&backends);
return ret;
}
| ast_group_t ast_get_group | ( | const char * | s | ) |
Definition at line 7716 of file channel.c.
References ast_log(), ast_strdupa, ast_strlen_zero(), group, LOG_ERROR, LOG_WARNING, and strsep().
Referenced by _parse(), build_device(), build_gateway(), build_peer(), config_parse_variables(), func_channel_write_real(), process_dahdi(), and read_agent_config().
{
char *piece;
char *c;
int start=0, finish=0, x;
ast_group_t group = 0;
if (ast_strlen_zero(s))
return 0;
c = ast_strdupa(s);
while ((piece = strsep(&c, ","))) {
if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
/* Range */
} else if (sscanf(piece, "%30d", &start)) {
/* Just one */
finish = start;
} else {
ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
continue;
}
for (x = start; x <= finish; x++) {
if ((x > 63) || (x < 0)) {
ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
} else
group |= ((ast_group_t) 1 << x);
}
}
return group;
}
| int ast_hangup | ( | struct ast_channel * | chan | ) |
Hangup a channel.
Hang up a channel.
Definition at line 2733 of file channel.c.
References ao2_lock, ao2_unlink, ao2_unlock, ast_assert, ast_audiohook_detach_list(), ast_autoservice_stop(), ast_cause2str(), ast_cc_offer(), ast_cdr_detach(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, AST_CEL_HANGUP, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_closestream(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_framehook_list_destroy(), ast_log(), ast_manager_event, ast_set_flag, ast_test_flag, ast_channel::audiohooks, ast_channel::blocker, ast_channel::blockproc, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, ast_channel::hangupsource, ast_party_caller::id, ast_party_connected_line::id, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_party_id::name, ast_channel::name, ast_party_id::number, pbx_builtin_getvar_helper(), ast_generator::release, S_COR, S_OR, ast_channel::sched, sched_context_destroy(), ast_party_name::str, ast_party_number::str, ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::vstream.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_pbx_run(), __ast_request_and_dial(), __oh323_new(), action_bridge(), alsa_new(), analog_handle_init_event(), analog_ss_thread(), answer_exec_run(), app_exec(), ast_async_goto(), ast_call_forward(), ast_dial_destroy(), ast_dial_hangup(), ast_iax2_new(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), async_wait(), begin_dial_channel(), bridge_call_thread(), bridge_channel_thread(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_availability(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_free(), conf_run(), connect_link(), console_new(), dahdi_handle_event(), dahdi_new(), destroy_conference_bridge(), dial_exec_full(), dial_transfer(), do_forward(), do_hang(), do_idle_thread(), feature_attended_transfer(), feature_request_and_dial(), findmeexec(), generic_recall(), gtalk_new(), handle_call_forward(), handle_callforward_button(), handle_enbloc_call_message(), handle_frame(), handle_frame_ownerless(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_soft_key_event_message(), handle_stimulus_message(), handle_timeout_trip(), handle_transfer_button(), HandleCallOutgoing(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), jingle_new(), local_hangup(), manage_parked_call(), masq_park_call(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), oss_new(), parkandannounce_exec(), parked_call_exec(), phone_new(), play_sound_file(), pri_dchannel(), pri_ss_thread(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), sip_park(), sip_park_thread(), sip_pickup_thread(), skinny_new(), skinny_ss(), ss7_start_call(), try_calling(), unistim_new(), usbradio_new(), wait_for_answer(), and wait_for_winner().
{
char extra_str[64]; /* used for cel logging below */
ast_autoservice_stop(chan);
ao2_lock(channels);
ast_channel_lock(chan);
if (chan->audiohooks) {
ast_audiohook_detach_list(chan->audiohooks);
chan->audiohooks = NULL;
}
ast_framehook_list_destroy(chan);
/*
* Do the masquerade if someone is setup to masquerade into us.
*
* NOTE: We must hold the channel lock after testing for a
* pending masquerade and setting the channel as a zombie to
* prevent __ast_channel_masquerade() from setting up a
* masquerade with a dead channel.
*/
while (chan->masq) {
ast_channel_unlock(chan);
ao2_unlock(channels);
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
/* Abort the loop or we might never leave. */
ao2_lock(channels);
ast_channel_lock(chan);
break;
}
ao2_lock(channels);
ast_channel_lock(chan);
}
if (chan->masqr) {
/*
* This channel is one which will be masqueraded into something.
* Mark it as a zombie already so ast_do_masquerade() will know
* to free it later.
*/
ast_set_flag(chan, AST_FLAG_ZOMBIE);
ast_channel_unlock(chan);
ao2_unlock(channels);
return 0;
}
ao2_unlink(channels, chan);
ao2_unlock(channels);
free_translation(chan);
/* Close audio stream */
if (chan->stream) {
ast_closestream(chan->stream);
chan->stream = NULL;
}
/* Close video stream */
if (chan->vstream) {
ast_closestream(chan->vstream);
chan->vstream = NULL;
}
if (chan->sched) {
sched_context_destroy(chan->sched);
chan->sched = NULL;
}
if (chan->generatordata) { /* Clear any tone stuff remaining */
if (chan->generator && chan->generator->release) {
chan->generator->release(chan, chan->generatordata);
}
}
chan->generatordata = NULL;
chan->generator = NULL;
snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
"is blocked by thread %ld in procedure %s! Expect a failure\n",
(long) pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0);
}
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
ast_debug(1, "Hanging up channel '%s'\n", chan->name);
/*
* This channel is now dead so mark it as a zombie so anyone
* left holding a reference to this channel will not use it.
*/
ast_set_flag(chan, AST_FLAG_ZOMBIE);
if (chan->tech->hangup) {
chan->tech->hangup(chan);
}
} else {
ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
}
ast_channel_unlock(chan);
ast_cc_offer(chan);
ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"Cause: %d\r\n"
"Cause-txt: %s\r\n",
chan->name,
chan->uniqueid,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, "<unknown>"),
S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, "<unknown>"),
chan->hangupcause,
ast_cause2str(chan->hangupcause)
);
if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) &&
!ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) &&
(chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) {
ast_channel_lock(chan);
ast_cdr_end(chan->cdr);
ast_cdr_detach(chan->cdr);
chan->cdr = NULL;
ast_channel_unlock(chan);
}
ast_channel_unref(chan);
return 0;
}
| int ast_indicate | ( | struct ast_channel * | chan, |
| int | condition | ||
| ) |
Indicates condition of channel.
| chan | channel to change the indication |
| condition | which condition to indicate on the channel |
Definition at line 4262 of file channel.c.
References ast_indicate_data().
Referenced by __ast_play_and_record(), agent_request(), alsa_call(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_raw_answer(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), disa_exec(), do_forward(), feature_request_and_dial(), finishup(), function_remote(), handle_callforward_button(), handle_frame(), handle_recordfile(), handle_request_refer(), local_attended_transfer(), manage_parked_call(), mgcp_ss(), monitor_dial(), oss_call(), park_call_full(), parked_call_exec(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_incomplete(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), record_exec(), rna(), rpt(), rpt_exec(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), try_calling(), and wait_for_answer().
{
return ast_indicate_data(chan, condition, NULL, 0);
}
| int ast_indicate_data | ( | struct ast_channel * | chan, |
| int | condition, | ||
| const void * | data, | ||
| size_t | datalen | ||
| ) |
Indicates condition of channel, with payload.
| chan | channel to change the indication |
| condition | which condition to indicate on the channel |
| data | pointer to payload data |
| datalen | size of payload data |
Definition at line 4316 of file channel.c.
References ast_channel::_state, _XXX_AST_CONTROL_T38, ast_channel_lock, ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_unlock, ast_check_hangup(), ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_debug, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_write_event(), ast_frdup(), ast_frfree, ast_get_indication_tone(), ast_log(), ast_party_connected_line_free(), ast_party_connected_line_set_init(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_playtones_start(), ast_playtones_stop(), ast_redirecting_parse_data(), AST_STATE_UP, ast_test_flag, ast_tone_zone_sound_unref(), ast_channel::connected, ast_tone_zone_sound::data, ast_frame::data, ast_frame::datalen, ast_channel::framehooks, ast_frame::frametype, ast_channel_tech::indicate, ast_frame_subclass::integer, is_visible_indication(), LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::redirecting, ast_frame::subclass, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.
Referenced by __ast_read(), action_aocmessage(), agent_hangup(), ast_bridge_call(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_generic_bridge(), ast_handle_cc_control_frame(), ast_indicate(), disable_t38(), feature_request_and_dial(), generic_fax_exec(), handle_frame(), local_bridge_loop(), login_exec(), manage_parked_call(), park_call_full(), pbx_builtin_waitexten(), receivefax_t38_init(), remote_bridge_loop(), sendfax_t38_init(), set_fax_t38_caps(), transmit_audio(), transmit_t38(), and wait_for_answer().
{
/* By using an enum, we'll get compiler warnings for values not handled
* in switch statements. */
enum ast_control_frame_type condition = _condition;
struct ast_tone_zone_sound *ts = NULL;
int res;
/* this frame is used by framehooks. if it is set, we must free it at the end of this function */
struct ast_frame *awesome_frame = NULL;
ast_channel_lock(chan);
/* Don't bother if the channel is about to go away, anyway. */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
res = -1;
goto indicate_cleanup;
}
if (!ast_framehook_list_is_empty(chan->framehooks)) {
/* Do framehooks now, do it, go, go now */
struct ast_frame frame = {
.frametype = AST_FRAME_CONTROL,
.subclass.integer = condition,
.data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
.datalen = datalen
};
/* we have now committed to freeing this frame */
awesome_frame = ast_frdup(&frame);
/* who knows what we will get back! the anticipation is killing me. */
if (!(awesome_frame = ast_framehook_list_write_event(chan->framehooks, awesome_frame))
|| awesome_frame->frametype != AST_FRAME_CONTROL) {
res = 0;
goto indicate_cleanup;
}
condition = awesome_frame->subclass.integer;
data = awesome_frame->data.ptr;
datalen = awesome_frame->datalen;
}
switch (condition) {
case AST_CONTROL_CONNECTED_LINE:
{
struct ast_party_connected_line connected;
ast_party_connected_line_set_init(&connected, &chan->connected);
res = ast_connected_line_parse_data(data, datalen, &connected);
if (!res) {
ast_channel_set_connected_line(chan, &connected, NULL);
}
ast_party_connected_line_free(&connected);
}
break;
case AST_CONTROL_REDIRECTING:
{
struct ast_party_redirecting redirecting;
ast_party_redirecting_set_init(&redirecting, &chan->redirecting);
res = ast_redirecting_parse_data(data, datalen, &redirecting);
if (!res) {
ast_channel_set_redirecting(chan, &redirecting, NULL);
}
ast_party_redirecting_free(&redirecting);
}
break;
default:
break;
}
if (is_visible_indication(condition)) {
/* A new visible indication is requested. */
chan->visible_indication = condition;
} else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
/* Visible indication is cleared/stopped. */
chan->visible_indication = 0;
}
if (chan->tech->indicate) {
/* See if the channel driver can handle this condition. */
res = chan->tech->indicate(chan, condition, data, datalen);
} else {
res = -1;
}
if (!res) {
/* The channel driver successfully handled this indication */
res = 0;
goto indicate_cleanup;
}
/* The channel driver does not support this indication, let's fake
* it by doing our own tone generation if applicable. */
/*!\note If we compare the enumeration type, which does not have any
* negative constants, the compiler may optimize this code away.
* Therefore, we must perform an integer comparison here. */
if (_condition < 0) {
/* Stop any tones that are playing */
ast_playtones_stop(chan);
res = 0;
goto indicate_cleanup;
}
/* Handle conditions that we have tones for. */
switch (condition) {
case _XXX_AST_CONTROL_T38:
/* deprecated T.38 control frame */
res = -1;
goto indicate_cleanup;
case AST_CONTROL_T38_PARAMETERS:
/* there is no way to provide 'default' behavior for these
* control frames, so we need to return failure, but there
* is also no value in the log message below being emitted
* since failure to handle these frames is not an 'error'
* so just return right now. in addition, we want to return
* whatever value the channel driver returned, in case it
* has some meaning.*/
goto indicate_cleanup;
case AST_CONTROL_RINGING:
ts = ast_get_indication_tone(chan->zone, "ring");
/* It is common practice for channel drivers to return -1 if trying
* to indicate ringing on a channel which is up. The idea is to let the
* core generate the ringing inband. However, we don't want the
* warning message about not being able to handle the specific indication
* to print nor do we want ast_indicate_data to return an "error" for this
* condition
*/
if (chan->_state == AST_STATE_UP) {
res = 0;
}
break;
case AST_CONTROL_BUSY:
ts = ast_get_indication_tone(chan->zone, "busy");
break;
case AST_CONTROL_INCOMPLETE:
case AST_CONTROL_CONGESTION:
ts = ast_get_indication_tone(chan->zone, "congestion");
break;
case AST_CONTROL_PROGRESS:
case AST_CONTROL_PROCEEDING:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_RADIO_KEY:
case AST_CONTROL_RADIO_UNKEY:
case AST_CONTROL_OPTION:
case AST_CONTROL_WINK:
case AST_CONTROL_FLASH:
case AST_CONTROL_OFFHOOK:
case AST_CONTROL_TAKEOFFHOOK:
case AST_CONTROL_ANSWER:
case AST_CONTROL_HANGUP:
case AST_CONTROL_RING:
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_TRANSFER:
case AST_CONTROL_CONNECTED_LINE:
case AST_CONTROL_REDIRECTING:
case AST_CONTROL_CC:
case AST_CONTROL_READ_ACTION:
case AST_CONTROL_AOC:
case AST_CONTROL_END_OF_Q:
case AST_CONTROL_UPDATE_RTP_PEER:
/* Nothing left to do for these. */
res = 0;
break;
}
if (ts) {
/* We have a tone to play, yay. */
ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
res = ast_playtones_start(chan, 0, ts->data, 1);
ts = ast_tone_zone_sound_unref(ts);
}
if (res) {
/* not handled */
ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name);
}
indicate_cleanup:
ast_channel_unlock(chan);
if (awesome_frame) {
ast_frfree(awesome_frame);
}
return res;
}
| void ast_install_music_functions | ( | int(*)(struct ast_channel *, const char *, const char *) | start_ptr, |
| void(*)(struct ast_channel *) | stop_ptr, | ||
| void(*)(struct ast_channel *) | cleanup_ptr | ||
| ) |
Definition at line 7752 of file channel.c.
References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.
Referenced by load_module().
{
ast_moh_start_ptr = start_ptr;
ast_moh_stop_ptr = stop_ptr;
ast_moh_cleanup_ptr = cleanup_ptr;
}
| int ast_internal_timing_enabled | ( | struct ast_channel * | chan | ) |
Check if the channel can run in internal timing mode.
| chan | The channel to check |
This function will return 1 if internal timing is enabled and the timing device is available.
Definition at line 4247 of file channel.c.
References ast_opt_internal_timing, and ast_channel::timingfd.
Referenced by add_sdp(), and ast_read_generator_actions().
{
return (ast_opt_internal_timing && chan->timingfd > -1);
}
| int ast_is_deferrable_frame | ( | const struct ast_frame * | frame | ) |
Should we keep this frame for later?
There are functions such as ast_safe_sleep which will service a channel to ensure that it does not have a large backlog of queued frames. When this happens, we want to hold on to specific frame types and just drop others. This function will tell if the frame we just read should be held onto.
| frame | The frame we just read |
| 1 | frame should be kept |
| 0 | frame should be dropped |
Definition at line 1779 of file channel.c.
References AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, and ast_frame::frametype.
Referenced by ast_safe_sleep_conditional(), autoservice_run(), and feature_request_and_dial().
{
/* Do not add a default entry in this switch statement. Each new
* frame type should be addressed directly as to whether it should
* be queued up or not.
*/
switch (frame->frametype) {
case AST_FRAME_CONTROL:
case AST_FRAME_TEXT:
case AST_FRAME_IMAGE:
case AST_FRAME_HTML:
return 1;
case AST_FRAME_DTMF_END:
case AST_FRAME_DTMF_BEGIN:
case AST_FRAME_VOICE:
case AST_FRAME_VIDEO:
case AST_FRAME_NULL:
case AST_FRAME_IAX:
case AST_FRAME_CNG:
case AST_FRAME_MODEM:
return 0;
}
return 0;
}
| void ast_moh_cleanup | ( | struct ast_channel * | chan | ) |
Definition at line 7786 of file channel.c.
References ast_moh_cleanup_ptr.
Referenced by ast_channel_destructor().
{
if (ast_moh_cleanup_ptr)
ast_moh_cleanup_ptr(chan);
}
| int ast_moh_start | ( | struct ast_channel * | chan, |
| const char * | mclass, | ||
| const char * | interpclass | ||
| ) |
Turn on music on hold on a given channel.
| chan | The channel structure that will get music on hold |
| mclass | The class to use if the musicclass is not currently set on the channel structure. |
| interpclass | The class to use if the musicclass is not currently set on the channel structure or in the mclass argument. |
| Zero | on success |
| non-zero | on failure |
Definition at line 7769 of file channel.c.
References ast_moh_start_ptr, and ast_verb.
Referenced by alsa_indicate(), app_exec(), conf_run(), conf_start_moh(), console_indicate(), dahdi_indicate(), dial_exec_full(), feature_exec_app(), gtalk_indicate(), handle_setmusic(), iax2_indicate(), jingle_indicate(), key_call(), leave_conference_bridge(), local_indicate(), menu_callback(), mgcp_indicate(), misdn_indication(), moh_handle_digit(), monitor_dial(), oh323_indicate(), oss_indicate(), phone_indicate(), play_moh_exec(), post_join_marked(), post_join_unmarked(), queue_exec(), retrydial_exec(), rna(), say_periodic_announcement(), say_position(), sig_pri_indicate(), sig_ss7_indicate(), sip_indicate(), skinny_indicate(), start_moh_exec(), TransferCallStep1(), unistim_indicate(), usbradio_indicate(), and wait_moh_exec().
{
if (ast_moh_start_ptr)
return ast_moh_start_ptr(chan, mclass, interpclass);
ast_verb(3, "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : (interpclass ? interpclass : "default"));
return 0;
}
| void ast_moh_stop | ( | struct ast_channel * | chan | ) |
Turn off music on hold on a given channel.
Turn off music on hold on a given channel
Definition at line 7780 of file channel.c.
References ast_moh_stop_ptr.
Referenced by alsa_indicate(), app_exec(), ast_quiet_chan(), conf_run(), console_indicate(), dahdi_indicate(), dial_exec_full(), do_bridge_masquerade(), feature_exec_app(), gtalk_indicate(), handle_setmusic(), iax2_indicate(), jingle_indicate(), key_call(), key_dial_page(), local_indicate(), menu_callback(), mgcp_indicate(), misdn_indication(), moh_handle_digit(), monitor_dial(), oh323_indicate(), oss_indicate(), phone_indicate(), play_moh_exec(), post_join_marked(), post_join_unmarked(), queue_exec(), retrydial_exec(), say_periodic_announcement(), say_position(), sig_pri_indicate(), sig_ss7_indicate(), sip_indicate(), skinny_indicate(), stop_moh_exec(), try_calling(), unistim_hangup(), unistim_indicate(), usbradio_indicate(), wait_for_answer(), and wait_moh_exec().
{
if (ast_moh_stop_ptr)
ast_moh_stop_ptr(chan);
}
| void ast_party_caller_copy | ( | struct ast_party_caller * | dest, |
| const struct ast_party_caller * | src | ||
| ) |
Copy the source caller information to the destination caller.
| dest | Destination caller |
| src | Source caller |
Definition at line 2230 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_copy(), and ast_party_caller::id.
Referenced by wait_for_answer().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_party_id_copy(&dest->id, &src->id);
ast_party_id_copy(&dest->ani, &src->ani);
dest->ani2 = src->ani2;
}
| void ast_party_caller_free | ( | struct ast_party_caller * | doomed | ) |
Destroy the caller party contents.
| doomed | The caller party to destroy. |
Definition at line 2256 of file channel.c.
References ast_party_caller::ani, ast_party_id_free(), and ast_party_caller::id.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), callerid_write(), dial_trunk(), and sla_ring_station().
{
ast_party_id_free(&doomed->id);
ast_party_id_free(&doomed->ani);
}
| void ast_party_caller_init | ( | struct ast_party_caller * | init | ) |
Initialize the given caller structure.
| init | Caller structure to initialize. |
Definition at line 2223 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_init(), and ast_party_caller::id.
Referenced by __ast_channel_alloc_ap(), dial_trunk(), sig_pri_set_caller_id(), sig_ss7_set_caller_id(), and sla_ring_station().
{
ast_party_id_init(&init->id);
ast_party_id_init(&init->ani);
init->ani2 = 0;
}
| void ast_party_caller_set | ( | struct ast_party_caller * | dest, |
| const struct ast_party_caller * | src, | ||
| const struct ast_set_party_caller * | update | ||
| ) |
Set the caller information based on another caller source.
This is similar to ast_party_caller_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.
| dest | The caller one wishes to update |
| src | The new caller values to update the dest |
| update | What caller information to update. NULL if all. |
Definition at line 2249 of file channel.c.
References ast_party_caller::ani, ast_set_party_caller::ani, ast_party_caller::ani2, ast_party_id_set(), ast_party_caller::id, and ast_set_party_caller::id.
Referenced by ast_channel_set_caller(), ast_channel_set_caller_event(), and callerid_write().
{
ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
dest->ani2 = src->ani2;
}
| void ast_party_caller_set_init | ( | struct ast_party_caller * | init, |
| const struct ast_party_caller * | guide | ||
| ) |
Initialize the given caller structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Caller structure to initialize. |
| guide | Source caller to use as a guide in initializing. |
Definition at line 2242 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set_init(), and ast_party_caller::id.
Referenced by callerid_write(), dial_exec_full(), do_forward(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().
{
ast_party_id_set_init(&init->id, &guide->id);
ast_party_id_set_init(&init->ani, &guide->ani);
init->ani2 = guide->ani2;
}
| void ast_party_connected_line_collect_caller | ( | struct ast_party_connected_line * | connected, |
| struct ast_party_caller * | caller | ||
| ) |
Collect the caller party information into a connected line structure.
| connected | Collected caller information for the connected line |
| caller | Caller information. |
Definition at line 2299 of file channel.c.
References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_caller::id, ast_party_connected_line::id, and ast_party_connected_line::source.
| void ast_party_connected_line_copy | ( | struct ast_party_connected_line * | dest, |
| const struct ast_party_connected_line * | src | ||
| ) |
Copy the source connected line information to the destination connected line.
| dest | Destination connected line |
| src | Source connected line |
Definition at line 2270 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_read(), ast_call_forward(), ast_channel_connected_line_macro(), ast_do_pickup(), builtin_atxfer(), dial_exec_full(), do_forward(), local_attended_transfer(), misdn_attempt_transfer(), party_connected_line_copy_transfer(), try_calling(), and wait_for_answer().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_party_id_copy(&dest->id, &src->id);
ast_party_id_copy(&dest->ani, &src->ani);
dest->ani2 = src->ani2;
dest->source = src->source;
}
| void ast_party_connected_line_free | ( | struct ast_party_connected_line * | doomed | ) |
Destroy the connected line information contents.
| doomed | The connected line information to destroy. |
Definition at line 2307 of file channel.c.
References ast_party_connected_line::ani, ast_party_id_free(), and ast_party_connected_line::id.
Referenced by __ast_read(), ast_channel_destructor(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_indicate_data(), atxfer_fail_cleanup(), builtin_atxfer(), callattempt_free(), chanlist_free(), connectedline_write(), feature_request_and_dial(), local_attended_transfer(), misdn_attempt_transfer(), parked_call_exec(), sig_pri_handle_subcmds(), socket_process(), wait_for_answer(), and xfer_ds_destroy().
{
ast_party_id_free(&doomed->id);
ast_party_id_free(&doomed->ani);
}
| void ast_party_connected_line_init | ( | struct ast_party_connected_line * | init | ) |
Initialize the given connected line structure.
| init | Connected line structure to initialize. |
Definition at line 2262 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_id_init(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_channel_alloc_ap(), __ast_read(), ast_do_pickup(), builtin_atxfer(), do_forward(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_attempt_transfer(), misdn_queue_connected_line_update(), parked_call_exec(), sig_pri_handle_subcmds(), sip_call(), socket_process(), and wait_for_answer().
{
ast_party_id_init(&init->id);
ast_party_id_init(&init->ani);
init->ani2 = 0;
init->source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN;
}
| void ast_party_connected_line_set | ( | struct ast_party_connected_line * | dest, |
| const struct ast_party_connected_line * | src, | ||
| const struct ast_set_party_connected_line * | update | ||
| ) |
Set the connected line information based on another connected line source.
| dest | The connected line one wishes to update |
| src | The new connected line values to update the dest |
| update | What connected line information to update. NULL if all. |
Definition at line 2291 of file channel.c.
References ast_party_connected_line::ani, ast_set_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set(), ast_party_connected_line::id, ast_set_party_connected_line::id, and ast_party_connected_line::source.
Referenced by ast_channel_set_connected_line(), and wait_for_answer().
| void ast_party_connected_line_set_init | ( | struct ast_party_connected_line * | init, |
| const struct ast_party_connected_line * | guide | ||
| ) |
Initialize the given connected line structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Connected line structure to initialize. |
| guide | Source connected line to use as a guide in initializing. |
Definition at line 2283 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set_init(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), feature_request_and_dial(), and wait_for_answer().
{
ast_party_id_set_init(&init->id, &guide->id);
ast_party_id_set_init(&init->ani, &guide->ani);
init->ani2 = guide->ani2;
init->source = guide->source;
}
| void ast_party_dialed_copy | ( | struct ast_party_dialed * | dest, |
| const struct ast_party_dialed * | src | ||
| ) |
Copy the source dialed party information to the destination dialed party.
| dest | Destination dialed party |
| src | Source dialed party |
Definition at line 2181 of file channel.c.
References ast_free, ast_party_subaddress_copy(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by local_call().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_free(dest->number.str);
dest->number.str = ast_strdup(src->number.str);
dest->number.plan = src->number.plan;
ast_party_subaddress_copy(&dest->subaddress, &src->subaddress);
dest->transit_network_select = src->transit_network_select;
}
| void ast_party_dialed_free | ( | struct ast_party_dialed * | doomed | ) |
Destroy the dialed party contents.
| doomed | The dialed party to destroy. |
Definition at line 2216 of file channel.c.
References ast_free, ast_party_subaddress_free(), ast_party_dialed::number, ast_party_dialed::str, and ast_party_dialed::subaddress.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), and callerid_write().
{
ast_free(doomed->number.str);
doomed->number.str = NULL;
ast_party_subaddress_free(&doomed->subaddress);
}
| void ast_party_dialed_init | ( | struct ast_party_dialed * | init | ) |
Initialize the given dialed structure.
| init | Dialed structure to initialize. |
Definition at line 2173 of file channel.c.
References ast_party_subaddress_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by __ast_channel_alloc_ap().
{
init->number.str = NULL;
init->number.plan = 0;/* Unknown */
ast_party_subaddress_init(&init->subaddress);
init->transit_network_select = 0;
}
| void ast_party_dialed_set | ( | struct ast_party_dialed * | dest, |
| const struct ast_party_dialed * | src | ||
| ) |
Set the dialed information based on another dialed source.
This is similar to ast_party_dialed_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.
| dest | The dialed one wishes to update |
| src | The new dialed values to update the dest |
Definition at line 2203 of file channel.c.
References ast_free, ast_party_subaddress_set(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by callerid_write().
{
if (src->number.str && src->number.str != dest->number.str) {
ast_free(dest->number.str);
dest->number.str = ast_strdup(src->number.str);
}
dest->number.plan = src->number.plan;
ast_party_subaddress_set(&dest->subaddress, &src->subaddress);
dest->transit_network_select = src->transit_network_select;
}
| void ast_party_dialed_set_init | ( | struct ast_party_dialed * | init, |
| const struct ast_party_dialed * | guide | ||
| ) |
Initialize the given dialed structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Caller structure to initialize. |
| guide | Source dialed to use as a guide in initializing. |
Definition at line 2195 of file channel.c.
References ast_party_subaddress_set_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by callerid_write().
{
init->number.str = NULL;
init->number.plan = guide->number.plan;
ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress);
init->transit_network_select = guide->transit_network_select;
}
| void ast_party_id_copy | ( | struct ast_party_id * | dest, |
| const struct ast_party_id * | src | ||
| ) |
Copy the source party id information to the destination party id.
| dest | Destination party id |
| src | Source party id |
Definition at line 2052 of file channel.c.
References ast_free, ast_party_name_copy(), ast_party_number_copy(), ast_party_subaddress_copy(), ast_strdup, ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), and parkandannounce_exec().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_party_name_copy(&dest->name, &src->name);
ast_party_number_copy(&dest->number, &src->number);
ast_party_subaddress_copy(&dest->subaddress, &src->subaddress);
ast_free(dest->tag);
dest->tag = ast_strdup(src->tag);
}
| void ast_party_id_free | ( | struct ast_party_id * | doomed | ) |
Destroy the party id contents.
| doomed | The party id to destroy. |
Definition at line 2098 of file channel.c.
References ast_free, ast_party_name_free(), ast_party_number_free(), ast_party_subaddress_free(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_redirecting_free(), parkandannounce_exec(), and sig_pri_mcid_event().
{
ast_party_name_free(&doomed->name);
ast_party_number_free(&doomed->number);
ast_party_subaddress_free(&doomed->subaddress);
ast_free(doomed->tag);
doomed->tag = NULL;
}
| void ast_party_id_init | ( | struct ast_party_id * | init | ) |
Initialize the given party id structure.
| init | Party id structure to initialize. |
Definition at line 2044 of file channel.c.
References ast_party_name_init(), ast_party_number_init(), ast_party_subaddress_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_redirecting_init(), dial_exec_full(), and sig_pri_mcid_event().
{
ast_party_name_init(&init->name);
ast_party_number_init(&init->number);
ast_party_subaddress_init(&init->subaddress);
init->tag = NULL;
}
| int ast_party_id_presentation | ( | const struct ast_party_id * | id | ) |
Determine the overall presentation value for the given party.
| id | Party to determine the overall presentation value. |
Definition at line 2108 of file channel.c.
References AST_PRES_ALLOWED, AST_PRES_NUMBER_TYPE, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, AST_PRES_UNAVAILABLE, AST_PRES_USER_NUMBER_UNSCREENED, ast_party_id::name, ast_party_id::number, ast_party_name::valid, and ast_party_number::valid.
Referenced by add_rpid(), ast_str_retrieve_variable(), ast_var_channels_table(), callerpres_read(), iax2_call(), initreqprep(), my_set_callerid(), oh323_call(), party_id_build_data(), party_id_read(), redirecting_read(), report_new_callerid(), setup_env(), sig_pri_event_party_id(), sig_pri_handle_subcmds(), sip_call(), and socket_process().
{
int number_priority;
int number_value;
int number_screening;
int name_priority;
int name_value;
/* Determine name presentation priority. */
if (!id->name.valid) {
name_value = AST_PRES_UNAVAILABLE;
name_priority = 3;
} else {
name_value = id->name.presentation & AST_PRES_RESTRICTION;
switch (name_value) {
case AST_PRES_RESTRICTED:
name_priority = 0;
break;
case AST_PRES_ALLOWED:
name_priority = 1;
break;
case AST_PRES_UNAVAILABLE:
name_priority = 2;
break;
default:
name_value = AST_PRES_UNAVAILABLE;
name_priority = 3;
break;
}
}
/* Determine number presentation priority. */
if (!id->number.valid) {
number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
number_value = AST_PRES_UNAVAILABLE;
number_priority = 3;
} else {
number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
number_value = id->number.presentation & AST_PRES_RESTRICTION;
switch (number_value) {
case AST_PRES_RESTRICTED:
number_priority = 0;
break;
case AST_PRES_ALLOWED:
number_priority = 1;
break;
case AST_PRES_UNAVAILABLE:
number_priority = 2;
break;
default:
number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
number_value = AST_PRES_UNAVAILABLE;
number_priority = 3;
break;
}
}
/* Select the wining presentation value. */
if (name_priority < number_priority) {
number_value = name_value;
}
return number_value | number_screening;
}
| void ast_party_id_set | ( | struct ast_party_id * | dest, |
| const struct ast_party_id * | src, | ||
| const struct ast_set_party_id * | update | ||
| ) |
Set the source party id information into the destination party id.
| dest | The id one wishes to update |
| src | The new id values to update the dest |
| update | What id information to update. NULL if all. |
Definition at line 2075 of file channel.c.
References ast_free, ast_party_name_set(), ast_party_number_set(), ast_party_subaddress_set(), ast_strdup, ast_party_id::name, ast_set_party_id::name, ast_party_id::number, ast_set_party_id::number, ast_party_id::subaddress, ast_set_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_set(), ast_party_connected_line_set(), and ast_party_redirecting_set().
{
if (dest == src) {
/* Don't set to self */
return;
}
if (!update || update->name) {
ast_party_name_set(&dest->name, &src->name);
}
if (!update || update->number) {
ast_party_number_set(&dest->number, &src->number);
}
if (!update || update->subaddress) {
ast_party_subaddress_set(&dest->subaddress, &src->subaddress);
}
if (src->tag && src->tag != dest->tag) {
ast_free(dest->tag);
dest->tag = ast_strdup(src->tag);
}
}
| void ast_party_id_set_init | ( | struct ast_party_id * | init, |
| const struct ast_party_id * | guide | ||
| ) |
Initialize the given party id structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Party id structure to initialize. |
| guide | Source party id to use as a guide in initializing. |
Definition at line 2067 of file channel.c.
References ast_party_name_set_init(), ast_party_number_set_init(), ast_party_subaddress_set_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_set_init(), ast_party_connected_line_set_init(), ast_party_redirecting_set_init(), and dial_exec_full().
{
ast_party_name_set_init(&init->name, &guide->name);
ast_party_number_set_init(&init->number, &guide->number);
ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress);
init->tag = NULL;
}
| void ast_party_name_copy | ( | struct ast_party_name * | dest, |
| const struct ast_party_name * | src | ||
| ) |
Copy the source party name information to the destination party name.
| dest | Destination party name |
| src | Source party name |
Definition at line 1893 of file channel.c.
References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_copy().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_free(dest->str);
dest->str = ast_strdup(src->str);
dest->char_set = src->char_set;
dest->presentation = src->presentation;
dest->valid = src->valid;
}
| void ast_party_name_free | ( | struct ast_party_name * | doomed | ) |
Destroy the party name contents.
| doomed | The party name to destroy. |
Definition at line 1932 of file channel.c.
References ast_free, and ast_party_name::str.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), and skinny_newcall().
| void ast_party_name_init | ( | struct ast_party_name * | init | ) |
Initialize the given name structure.
| init | Name structure to initialize. |
Definition at line 1885 of file channel.c.
References AST_PARTY_CHAR_SET_ISO8859_1, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), and skinny_newcall().
{
init->str = NULL;
init->char_set = AST_PARTY_CHAR_SET_ISO8859_1;
init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
init->valid = 0;
}
| void ast_party_name_set | ( | struct ast_party_name * | dest, |
| const struct ast_party_name * | src | ||
| ) |
Set the source party name information into the destination party name.
| dest | The name one wishes to update |
| src | The new name values to update the dest |
Definition at line 1915 of file channel.c.
References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_set().
{
if (dest == src) {
/* Don't set to self */
return;
}
if (src->str && src->str != dest->str) {
ast_free(dest->str);
dest->str = ast_strdup(src->str);
}
dest->char_set = src->char_set;
dest->presentation = src->presentation;
dest->valid = src->valid;
}
| void ast_party_name_set_init | ( | struct ast_party_name * | init, |
| const struct ast_party_name * | guide | ||
| ) |
Initialize the given party name structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Party name structure to initialize. |
| guide | Source party name to use as a guide in initializing. |
Definition at line 1907 of file channel.c.
References ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_set_init().
{
init->str = NULL;
init->char_set = guide->char_set;
init->presentation = guide->presentation;
init->valid = guide->valid;
}
| void ast_party_number_copy | ( | struct ast_party_number * | dest, |
| const struct ast_party_number * | src | ||
| ) |
Copy the source party number information to the destination party number.
| dest | Destination party number |
| src | Source party number |
Definition at line 1946 of file channel.c.
References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_copy().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_free(dest->str);
dest->str = ast_strdup(src->str);
dest->plan = src->plan;
dest->presentation = src->presentation;
dest->valid = src->valid;
}
| void ast_party_number_free | ( | struct ast_party_number * | doomed | ) |
Destroy the party number contents.
| doomed | The party number to destroy. |
Definition at line 1985 of file channel.c.
References ast_free, and ast_party_number::str.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), do_forward(), skinny_newcall(), and wait_for_answer().
| void ast_party_number_init | ( | struct ast_party_number * | init | ) |
Initialize the given number structure.
| init | Number structure to initialize. |
Definition at line 1938 of file channel.c.
References AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), do_forward(), skinny_newcall(), and wait_for_answer().
{
init->str = NULL;
init->plan = 0;/* Unknown */
init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
init->valid = 0;
}
| void ast_party_number_set | ( | struct ast_party_number * | dest, |
| const struct ast_party_number * | src | ||
| ) |
Set the source party number information into the destination party number.
| dest | The number one wishes to update |
| src | The new number values to update the dest |
Definition at line 1968 of file channel.c.
References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_set().
{
if (dest == src) {
/* Don't set to self */
return;
}
if (src->str && src->str != dest->str) {
ast_free(dest->str);
dest->str = ast_strdup(src->str);
}
dest->plan = src->plan;
dest->presentation = src->presentation;
dest->valid = src->valid;
}
| void ast_party_number_set_init | ( | struct ast_party_number * | init, |
| const struct ast_party_number * | guide | ||
| ) |
Initialize the given party number structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Party number structure to initialize. |
| guide | Source party number to use as a guide in initializing. |
Definition at line 1960 of file channel.c.
References ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_set_init().
{
init->str = NULL;
init->plan = guide->plan;
init->presentation = guide->presentation;
init->valid = guide->valid;
}
| void ast_party_redirecting_copy | ( | struct ast_party_redirecting * | dest, |
| const struct ast_party_redirecting * | src | ||
| ) |
Copy the source redirecting information to the destination redirecting.
| dest | Destination redirecting |
| src | Source redirecting |
Definition at line 2321 of file channel.c.
References ast_party_id_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by ast_call_forward(), ast_channel_redirecting_macro(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), do_forward(), local_call(), ring_entry(), and wait_for_answer().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_party_id_copy(&dest->from, &src->from);
ast_party_id_copy(&dest->to, &src->to);
dest->count = src->count;
dest->reason = src->reason;
}
| void ast_party_redirecting_free | ( | struct ast_party_redirecting * | doomed | ) |
Destroy the redirecting information contents.
| doomed | The redirecting information to destroy. |
Definition at line 2350 of file channel.c.
References ast_party_id_free(), ast_party_redirecting::from, and ast_party_redirecting::to.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), ast_indicate_data(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().
{
ast_party_id_free(&doomed->from);
ast_party_id_free(&doomed->to);
}
| void ast_party_redirecting_init | ( | struct ast_party_redirecting * | init | ) |
Initialize the given redirecting structure.
| init | Redirecting structure to initialize. |
Definition at line 2313 of file channel.c.
References ast_party_id_init(), AST_REDIRECTING_REASON_UNKNOWN, ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by __ast_channel_alloc_ap(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), and wait_for_answer().
{
ast_party_id_init(&init->from);
ast_party_id_init(&init->to);
init->count = 0;
init->reason = AST_REDIRECTING_REASON_UNKNOWN;
}
| void ast_party_redirecting_set | ( | struct ast_party_redirecting * | dest, |
| const struct ast_party_redirecting * | src, | ||
| const struct ast_set_party_redirecting * | update | ||
| ) |
Set the redirecting information based on another redirecting source.
This is similar to ast_party_redirecting_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.
| dest | The redirecting one wishes to update |
| src | The new redirecting values to update the dest |
| update | What redirecting information to update. NULL if all. |
Definition at line 2342 of file channel.c.
References ast_party_id_set(), ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, ast_party_redirecting::reason, ast_party_redirecting::to, and ast_set_party_redirecting::to.
Referenced by ast_channel_set_redirecting().
| void ast_party_redirecting_set_init | ( | struct ast_party_redirecting * | init, |
| const struct ast_party_redirecting * | guide | ||
| ) |
Initialize the given redirecting id structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Redirecting id structure to initialize. |
| guide | Source redirecting id to use as a guide in initializing. |
Definition at line 2334 of file channel.c.
References ast_party_id_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by ast_indicate_data(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_redirecting_convert().
{
ast_party_id_set_init(&init->from, &guide->from);
ast_party_id_set_init(&init->to, &guide->to);
init->count = guide->count;
init->reason = guide->reason;
}
| void ast_party_subaddress_copy | ( | struct ast_party_subaddress * | dest, |
| const struct ast_party_subaddress * | src | ||
| ) |
Copy the source party subaddress information to the destination party subaddress.
| dest | Destination party subaddress |
| src | Source party subaddress |
Definition at line 1999 of file channel.c.
References ast_free, ast_strdup, ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_copy(), and ast_party_id_copy().
{
if (dest == src) {
/* Don't copy to self */
return;
}
ast_free(dest->str);
dest->str = ast_strdup(src->str);
dest->type = src->type;
dest->odd_even_indicator = src->odd_even_indicator;
dest->valid = src->valid;
}
| void ast_party_subaddress_free | ( | struct ast_party_subaddress * | doomed | ) |
Destroy the party subaddress contents.
| doomed | The party subaddress to destroy. |
Definition at line 2038 of file channel.c.
References ast_free, and ast_party_subaddress::str.
Referenced by ast_party_dialed_free(), ast_party_id_free(), and pri_dchannel().
| void ast_party_subaddress_init | ( | struct ast_party_subaddress * | init | ) |
Initialize the given subaddress structure.
| init | Subaddress structure to initialize. |
Definition at line 1991 of file channel.c.
References ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_init(), ast_party_id_init(), pri_dchannel(), sig_pri_call(), and sig_pri_set_subaddress().
{
init->str = NULL;
init->type = 0;
init->odd_even_indicator = 0;
init->valid = 0;
}
| void ast_party_subaddress_set | ( | struct ast_party_subaddress * | dest, |
| const struct ast_party_subaddress * | src | ||
| ) |
Set the source party subaddress information into the destination party subaddress.
| dest | The subaddress one wishes to update |
| src | The new subaddress values to update the dest |
Definition at line 2021 of file channel.c.
References ast_free, ast_strdup, ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_set(), ast_party_id_set(), and sig_pri_handle_subcmds().
{
if (dest == src) {
/* Don't set to self */
return;
}
if (src->str && src->str != dest->str) {
ast_free(dest->str);
dest->str = ast_strdup(src->str);
}
dest->type = src->type;
dest->odd_even_indicator = src->odd_even_indicator;
dest->valid = src->valid;
}
| void ast_party_subaddress_set_init | ( | struct ast_party_subaddress * | init, |
| const struct ast_party_subaddress * | guide | ||
| ) |
Initialize the given party subaddress structure using the given guide for a set update operation.
The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.
| init | Party subaddress structure to initialize. |
| guide | Source party subaddress to use as a guide in initializing. |
Definition at line 2013 of file channel.c.
References ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_set_init(), and ast_party_id_set_init().
{
init->str = NULL;
init->type = guide->type;
init->odd_even_indicator = guide->odd_even_indicator;
init->valid = guide->valid;
}
| int ast_plc_reload | ( | void | ) |
Reload genericplc configuration value from codecs.conf.
Implementation is in main/channel.c
Definition at line 7805 of file channel.c.
References ast_config_destroy(), ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_variable::value, and var.
Referenced by ast_channels_init().
{
struct ast_variable *var;
struct ast_flags config_flags = { 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
}
}
ast_config_destroy(cfg);
return 0;
}
| void ast_poll_channel_add | ( | struct ast_channel * | chan0, |
| struct ast_channel * | chan1 | ||
| ) |
Add a channel to an optimized waitfor
Definition at line 2610 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_generic_bridge(), begin_dial_channel(), feature_request_and_dial(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().
{
#ifdef HAVE_EPOLL
struct epoll_event ev;
int i = 0;
if (chan0->epfd == -1)
return;
/* Iterate through the file descriptors on chan1, adding them to chan0 */
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan1->fds[i] == -1)
continue;
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.ptr = chan1->epfd_data[i];
epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev);
}
#endif
return;
}
| void ast_poll_channel_del | ( | struct ast_channel * | chan0, |
| struct ast_channel * | chan1 | ||
| ) |
Delete a channel from an optimized waitfor
Definition at line 2633 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_generic_bridge(), feature_request_and_dial(), local_bridge_loop(), monitor_dial(), remote_bridge_loop(), and wait_for_answer().
{
#ifdef HAVE_EPOLL
struct epoll_event ev;
int i = 0;
if (chan0->epfd == -1)
return;
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan1->fds[i] == -1)
continue;
epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev);
}
#endif
return;
}
| char* ast_print_group | ( | char * | buf, |
| int | buflen, | ||
| ast_group_t | group | ||
| ) |
Print call group and pickup group ---.
print call- and pickup groups into buffer
Definition at line 7953 of file channel.c.
References first.
Referenced by _sip_show_peer(), _skinny_show_line(), func_channel_read(), function_sippeer(), misdn_cfg_get_config_string(), print_group(), read_config(), and serialize_showchan().
{
unsigned int i;
int first = 1;
char num[3];
buf[0] = '\0';
if (!group) /* Return empty string if no group */
return buf;
for (i = 0; i <= 63; i++) { /* Max group is 63 */
if (group & ((ast_group_t) 1 << i)) {
if (!first) {
strncat(buf, ", ", buflen - strlen(buf) - 1);
} else {
first = 0;
}
snprintf(num, sizeof(num), "%u", i);
strncat(buf, num, buflen - strlen(buf) - 1);
}
}
return buf;
}
| int ast_prod | ( | struct ast_channel * | chan | ) |
Send empty audio to prime a channel driver.
Definition at line 4635 of file channel.c.
References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), ast_frame_subclass::codec, ast_frame::data, LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.
Referenced by ast_activate_generator().
{
struct ast_frame a = { AST_FRAME_VOICE };
char nothing[128];
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
ast_debug(1, "Prodding channel '%s'\n", chan->name);
a.subclass.codec = chan->rawwriteformat;
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod"; /* this better match check in ast_write */
if (ast_write(chan, &a))
ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name);
}
return 0;
}
| int ast_queue_control | ( | struct ast_channel * | chan, |
| enum ast_control_frame_type | control | ||
| ) |
Queue a control frame.
Queue a control frame with payload.
Definition at line 1562 of file channel.c.
References AST_FRAME_CONTROL, and ast_queue_frame().
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), analog_call(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_do_pickup(), attempt_transfer(), auto_congest(), cb_events(), cli_console_answer(), cli_console_flash(), console_answer(), console_call(), console_sendtext(), dahdi_handle_event(), dahdi_hangup(), gtalk_is_answered(), gtalk_ringing_ack(), handle_hd_hf(), handle_offhook_message(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), handle_response_refer(), handle_soft_key_event_message(), handle_stimulus_message(), HandleCallIncoming(), jingle_is_answered(), jingle_ringing_ack(), masquerade_colp_transfer(), misdn_facility_ie_handler(), multicast_rtp_call(), nbs_call(), phone_call(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), skinny_call(), skinny_transfer(), skinny_unhold(), unistim_call(), and update_state().
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
return ast_queue_frame(chan, &f);
}
| int ast_queue_control_data | ( | struct ast_channel * | chan, |
| enum ast_control_frame_type | control, | ||
| const void * | data, | ||
| size_t | datalen | ||
| ) |
Queue a control frame with payload.
| chan | channel to queue frame onto |
| control | type of control frame |
| data | pointer to payload data to be included in frame |
| datalen | number of bytes of payload data |
| 0 | success |
| non-zero | failure |
The supplied payload data is copied into the frame, so the caller's copy is not modified nor freed, and the resulting frame will retain a copy of the data even if the caller frees their local copy.
Definition at line 1569 of file channel.c.
References AST_FRAME_CONTROL, and ast_queue_frame().
Referenced by __analog_handle_event(), analog_hangup(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), change_t38_state(), dahdi_handle_event(), dahdi_hangup(), handle_request_notify(), handle_response_refer(), iax2_queue_control_data(), iax2_transfer(), interpret_t38_parameters(), local_attended_transfer(), masquerade_colp_transfer(), process_sdp(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), sip_sipredirect(), and skinny_hold().
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
return ast_queue_frame(chan, &f);
}
| int ast_queue_frame | ( | struct ast_channel * | chan, |
| struct ast_frame * | f | ||
| ) |
Queue one or more frames to a channel's frame queue.
| chan | the channel to queue the frame(s) on |
| f | the frame(s) to queue. Note that the frame(s) will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame(s) being passed if necessary. |
| 0 | success |
| non-zero | failure |
Definition at line 1519 of file channel.c.
References __ast_queue_frame().
Referenced by __ast_channel_masquerade(), __ast_read(), __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_request(), alsa_call(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), ast_dsp_process(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), bridge_write(), cb_events(), cli_console_dial(), cli_console_sendtext(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), do_immediate_setup(), gtalk_handle_dtmf(), handle_keypad_button_message(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), jingle_handle_dtmf(), keypad_digit(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), oss_call(), pri_queue_frame(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), rpt_call(), sig_pri_handle_hold(), sig_pri_handle_subcmds(), sig_ss7_queue_frame(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), usbradio_read(), and wakeup_sub().
{
return __ast_queue_frame(chan, fin, 0, NULL);
}
| int ast_queue_frame_head | ( | struct ast_channel * | chan, |
| struct ast_frame * | f | ||
| ) |
Queue one or more frames to the head of a channel's frame queue.
| chan | the channel to queue the frame(s) on |
| f | the frame(s) to queue. Note that the frame(s) will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame(s) being passed if necessary. |
| 0 | success |
| non-zero | failure |
Definition at line 1524 of file channel.c.
References __ast_queue_frame().
Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), ast_safe_sleep_conditional(), and feature_request_and_dial().
{
return __ast_queue_frame(chan, fin, 1, NULL);
}
| int ast_queue_hangup | ( | struct ast_channel * | chan | ) |
Queue a hangup frame for channel.
Queue a hangup frame.
Definition at line 1530 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), and AST_SOFTHANGUP_DEV.
Referenced by bridge_queue_hangup(), cleanup_connection(), cli_console_hangup(), close_call(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_request_cancel(), handle_soft_key_event_message(), iax2_destroy(), iax2_queue_hangup(), jingle_hangup_farend(), local_fixup(), local_hangup(), and mgcp_queue_hangup().
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
ast_channel_unlock(chan);
}
return ast_queue_frame(chan, &f);
}
| int ast_queue_hangup_with_cause | ( | struct ast_channel * | chan, |
| int | cause | ||
| ) |
Queue a hangup frame for channel.
Queue a hangup frame with hangupcause set.
Definition at line 1542 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, cause, ast_frame::data, ast_channel::hangupcause, and ast_frame::uint32.
Referenced by __analog_handle_event(), __oh323_update_info(), __sip_autodestruct(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), dahdi_r2_on_call_disconnect(), handle_request_bye(), handle_response(), handle_response_invite(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), misdn_answer(), retrans_pkt(), and TransferCallStep1().
{
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
if (cause >= 0)
f.data.uint32 = cause;
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
if (cause < 0)
f.data.uint32 = chan->hangupcause;
ast_channel_unlock(chan);
}
return ast_queue_frame(chan, &f);
}
| int ast_raw_answer | ( | struct ast_channel * | chan, |
| int | cdr_answer | ||
| ) |
Answer a channel.
| chan | channel to answer |
| cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
This function answers a channel and handles all necessary call setup functions.
| 0 | on success |
| non-zero | on failure |
Definition at line 2871 of file channel.c.
References ast_channel::_state, ast_channel_tech::answer, ast_cdr_answer(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, ast_channel::cdr, and ast_channel::tech.
Referenced by __ast_answer(), and ast_bridge_call().
{
int res = 0;
ast_channel_lock(chan);
/* You can't answer an outbound call */
if (ast_test_flag(chan, AST_FLAG_OUTGOING)) {
ast_channel_unlock(chan);
return 0;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
ast_channel_unlock(chan);
return -1;
}
ast_channel_unlock(chan);
switch (chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
ast_channel_lock(chan);
if (chan->tech->answer) {
res = chan->tech->answer(chan);
}
ast_setstate(chan, AST_STATE_UP);
if (cdr_answer) {
ast_cdr_answer(chan->cdr);
}
ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
ast_channel_unlock(chan);
break;
case AST_STATE_UP:
ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
/* Calling ast_cdr_answer when it it has previously been called
* is essentially a no-op, so it is safe.
*/
if (cdr_answer) {
ast_cdr_answer(chan->cdr);
}
break;
default:
break;
}
ast_indicate(chan, -1);
return res;
}
| struct ast_frame* ast_read | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame.
| chan | channel to read a frame from |
Definition at line 4252 of file channel.c.
References __ast_read().
Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), analog_ss_thread(), ast_bridge_handle_trip(), ast_generic_bridge(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), async_agi_read_frame(), async_wait(), autoservice_run(), background_detect_exec(), channel_spy(), conf_flush(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_bridge(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), eivr_comm(), feature_request_and_dial(), find_cache(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), iax2_bridge(), ices_exec(), isAnsweringMachine(), jack_exec(), local_bridge_loop(), manage_parked_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), remote_bridge_loop(), rpt(), rpt_exec(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().
{
return __ast_read(chan, 0);
}
| static void ast_read_generator_actions | ( | struct ast_channel * | chan, |
| struct ast_frame * | f | ||
| ) | [static] |
Definition at line 3609 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, ast_format_rate(), AST_FRAME_CNG, ast_internal_timing_enabled(), ast_settimeout(), chanlist::chan, ast_frame_subclass::codec, ast_frame::datalen, ast_frame::frametype, ast_generator::generate, ast_channel::generator, generator_force(), ast_channel::generatordata, ast_frame::samples, ast_frame::subclass, ast_channel::timingfd, ast_channel::timingfunc, and ast_channel::writeformat.
Referenced by __ast_read().
{
if (chan->generator && chan->generator->generate && chan->generatordata && !ast_internal_timing_enabled(chan)) {
void *tmp = chan->generatordata;
int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate;
int res;
int samples;
if (chan->timingfunc) {
ast_debug(1, "Generator got voice, switching to phase locked mode\n");
ast_settimeout(chan, 0, NULL, NULL);
}
chan->generatordata = NULL; /* reset, to let writes go through */
if (f->subclass.codec != chan->writeformat) {
float factor;
factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec));
samples = (int) ( ((float) f->samples) * factor );
} else {
samples = f->samples;
}
/* This unlock is here based on two assumptions that hold true at this point in the
* code. 1) this function is only called from within __ast_read() and 2) all generators
* call ast_write() in their generate callback.
*
* The reason this is added is so that when ast_write is called, the lock that occurs
* there will not recursively lock the channel. Doing this will cause intended deadlock
* avoidance not to work in deeper functions
*/
ast_channel_unlock(chan);
res = generate(chan, tmp, f->datalen, samples);
ast_channel_lock(chan);
chan->generatordata = tmp;
if (res) {
ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
} else if (f->frametype == AST_FRAME_CNG) {
if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
ast_debug(1, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 50, generator_force, chan);
}
}
}
| struct ast_frame* ast_read_noaudio | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame, returning AST_FRAME_NULL frame if audio.
| chan | channel to read a frame from |
Definition at line 4257 of file channel.c.
References __ast_read().
Referenced by ast_bridge_handle_trip(), and conf_run().
{
return __ast_read(chan, 1);
}
| int ast_readstring | ( | struct ast_channel * | c, |
| char * | s, | ||
| int | len, | ||
| int | timeout, | ||
| int | rtimeout, | ||
| char * | enders | ||
| ) |
Reads multiple digits.
| c | channel to read from |
| s | string to read in to. Must be at least the size of your length |
| len | how many digits to read (maximum) |
| timeout | how long to timeout between digits |
| rtimeout | timeout to wait on the first digit |
| enders | digits to end the string |
Read in a digit string "s", max length "len", maximum timeout between digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout for the first digit.
Definition at line 5676 of file channel.c.
References ast_readstring_full().
Referenced by __adsi_transmit_messages(), ast_adsi_begin_download(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_app_getdata(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser(), and vm_options().
{
return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
}
| int ast_readstring_full | ( | struct ast_channel * | c, |
| char * | s, | ||
| int | len, | ||
| int | timeout, | ||
| int | ftimeout, | ||
| char * | enders, | ||
| int | audiofd, | ||
| int | ctrlfd | ||
| ) |
Definition at line 5681 of file channel.c.
References ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_check_hangup(), AST_DIGIT_ANY, AST_FLAG_ZOMBIE, AST_GETDATA_COMPLETE, AST_GETDATA_EMPTY_END_TERMINATED, AST_GETDATA_FAILED, AST_GETDATA_INTERRUPTED, AST_GETDATA_TIMEOUT, ast_opt_transmit_silence, ast_stopstream(), ast_test_flag, ast_waitfordigit_full(), ast_waitstream_full(), and ast_channel::stream.
Referenced by ast_app_getdata_full(), and ast_readstring().
{
int pos = 0; /* index in the buffer where we accumulate digits */
int to = ftimeout;
struct ast_silence_generator *silgen = NULL;
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
return -1;
if (!len)
return -1;
for (;;) {
int d;
if (c->stream) {
d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
ast_stopstream(c);
if (!silgen && ast_opt_transmit_silence)
silgen = ast_channel_start_silence_generator(c);
usleep(1000);
if (!d)
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
} else {
if (!silgen && ast_opt_transmit_silence)
silgen = ast_channel_start_silence_generator(c);
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
}
if (d < 0) {
ast_channel_stop_silence_generator(c, silgen);
return AST_GETDATA_FAILED;
}
if (d == 0) {
s[pos] = '\0';
ast_channel_stop_silence_generator(c, silgen);
return AST_GETDATA_TIMEOUT;
}
if (d == 1) {
s[pos] = '\0';
ast_channel_stop_silence_generator(c, silgen);
return AST_GETDATA_INTERRUPTED;
}
if (strchr(enders, d) && (pos == 0)) {
s[pos] = '\0';
ast_channel_stop_silence_generator(c, silgen);
return AST_GETDATA_EMPTY_END_TERMINATED;
}
if (!strchr(enders, d)) {
s[pos++] = d;
}
if (strchr(enders, d) || (pos >= len)) {
s[pos] = '\0';
ast_channel_stop_silence_generator(c, silgen);
return AST_GETDATA_COMPLETE;
}
to = timeout;
}
/* Never reached */
return 0;
}
| int ast_recvchar | ( | struct ast_channel * | chan, |
| int | timeout | ||
| ) |
Receives a text character from a channel.
| chan | channel to act upon |
| timeout | timeout in milliseconds (0 for infinite wait) |
Read a char of text from a channel
Definition at line 4511 of file channel.c.
References ast_free, and ast_recvtext().
Referenced by handle_recvchar().
{
int c;
char *buf = ast_recvtext(chan, timeout);
if (buf == NULL)
return -1; /* error or timeout */
c = *(unsigned char *)buf;
ast_free(buf);
return c;
}
| char* ast_recvtext | ( | struct ast_channel * | chan, |
| int | timeout | ||
| ) |
Receives a text string from a channel Read a string of text from a channel.
| chan | channel to act upon |
| timeout | timeout in milliseconds (0 for infinite wait) |
Definition at line 4522 of file channel.c.
References ast_check_hangup(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_TEXT, ast_frfree, ast_read(), ast_strndup, ast_waitfor(), ast_frame::data, ast_frame::datalen, f, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, and ast_frame::subclass.
Referenced by ast_recvchar(), and handle_recvtext().
{
int res, done = 0;
char *buf = NULL;
while (!done) {
struct ast_frame *f;
if (ast_check_hangup(chan))
break;
res = ast_waitfor(chan, timeout);
if (res <= 0) /* timeout or error */
break;
timeout = res; /* update timeout */
f = ast_read(chan);
if (f == NULL)
break; /* no frame */
if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP)
done = 1; /* force a break */
else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
done = 1;
}
ast_frfree(f);
}
return buf;
}
| int ast_redirecting_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_redirecting * | redirecting, | ||
| const struct ast_set_party_redirecting * | update | ||
| ) |
Build the redirecting id data frame.
| data | Buffer to fill with the frame data |
| datalen | Size of the buffer to fill |
| redirecting | Redirecting id information |
| update | What redirecting information to build. NULL if all. |
| -1 | if error |
| Amount | of data buffer used |
Definition at line 8855 of file channel.c.
References ast_log(), AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_redirecting::reason, ast_party_name_ies::str, ast_party_redirecting::to, ast_set_party_redirecting::to, and value.
Referenced by ast_channel_queue_redirecting_update(), ast_channel_update_redirecting(), and local_indicate().
{
int32_t value;
size_t pos = 0;
int res;
static const struct ast_party_id_ies from_ies = {
.name.str = AST_REDIRECTING_FROM_NAME,
.name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
.name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
.name.valid = AST_REDIRECTING_FROM_NAME_VALID,
.number.str = AST_REDIRECTING_FROM_NUMBER,
.number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
.number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
.number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
.subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
.subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
.subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
.subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
.tag = AST_REDIRECTING_FROM_TAG,
.combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
};
static const struct ast_party_id_ies to_ies = {
.name.str = AST_REDIRECTING_TO_NAME,
.name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
.name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
.name.valid = AST_REDIRECTING_TO_NAME_VALID,
.number.str = AST_REDIRECTING_TO_NUMBER,
.number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
.number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
.number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
.subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
.subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
.subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
.subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
.tag = AST_REDIRECTING_TO_TAG,
.combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
};
/* Redirecting frame version */
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
return -1;
}
data[pos++] = AST_REDIRECTING_VERSION;
data[pos++] = 1;
data[pos++] = 2;/* Version 1 did not have a version ie */
res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
"redirecting-from", &from_ies, update ? &update->from : NULL);
if (res < 0) {
return -1;
}
pos += res;
res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
"redirecting-to", &to_ies, update ? &update->to : NULL);
if (res < 0) {
return -1;
}
pos += res;
/* Redirecting reason */
if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
ast_log(LOG_WARNING, "No space left for redirecting reason\n");
return -1;
}
data[pos++] = AST_REDIRECTING_REASON;
data[pos++] = sizeof(value);
value = htonl(redirecting->reason);
memcpy(data + pos, &value, sizeof(value));
pos += sizeof(value);
/* Redirecting count */
if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
ast_log(LOG_WARNING, "No space left for redirecting count\n");
return -1;
}
data[pos++] = AST_REDIRECTING_COUNT;
data[pos++] = sizeof(value);
value = htonl(redirecting->count);
memcpy(data + pos, &value, sizeof(value));
pos += sizeof(value);
return pos;
}
| int ast_redirecting_parse_data | ( | const unsigned char * | data, |
| size_t | datalen, | ||
| struct ast_party_redirecting * | redirecting | ||
| ) |
Parse redirecting indication frame data.
| data | Buffer with the frame data to parse |
| datalen | Size of the buffer |
| redirecting | Extracted redirecting id information |
| 0 | on success. |
| -1 | on error. |
Definition at line 8948 of file channel.c.
References ast_free, ast_log(), ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_name::char_set, ast_party_redirecting::count, ast_party_redirecting::from, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::reason, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_redirecting::to, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.
Referenced by ast_channel_redirecting_macro(), and ast_indicate_data().
{
size_t pos;
unsigned char ie_len;
unsigned char ie_id;
int32_t value;
int frame_version = 1;
int from_combined_presentation = 0;
int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
int to_combined_presentation = 0;
int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
for (pos = 0; pos < datalen; pos += ie_len) {
if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
ast_log(LOG_WARNING, "Invalid redirecting update\n");
return -1;
}
ie_id = data[pos++];
ie_len = data[pos++];
if (datalen < pos + ie_len) {
ast_log(LOG_WARNING, "Invalid redirecting update\n");
return -1;
}
switch (ie_id) {
/* Redirecting frame version */
case AST_REDIRECTING_VERSION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
(unsigned) ie_len);
break;
}
frame_version = data[pos];
break;
/* Redirecting-from party id name */
case AST_REDIRECTING_FROM_NAME:
ast_free(redirecting->from.name.str);
redirecting->from.name.str = ast_malloc(ie_len + 1);
if (redirecting->from.name.str) {
memcpy(redirecting->from.name.str, data + pos, ie_len);
redirecting->from.name.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_FROM_NAME_CHAR_SET:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.name.char_set = data[pos];
break;
case AST_REDIRECTING_FROM_NAME_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.name.presentation = data[pos];
break;
case AST_REDIRECTING_FROM_NAME_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.name.valid = data[pos];
break;
/* Redirecting-from party id number */
case AST_REDIRECTING_FROM_NUMBER:
ast_free(redirecting->from.number.str);
redirecting->from.number.str = ast_malloc(ie_len + 1);
if (redirecting->from.number.str) {
memcpy(redirecting->from.number.str, data + pos, ie_len);
redirecting->from.number.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_FROM_NUMBER_PLAN:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.number.plan = data[pos];
break;
case AST_REDIRECTING_FROM_NUMBER_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.number.presentation = data[pos];
break;
case AST_REDIRECTING_FROM_NUMBER_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.number.valid = data[pos];
break;
/* Redirecting-from party id combined presentation */
case AST_REDIRECTING_FROM_ID_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
(unsigned) ie_len);
break;
}
from_combined_presentation = data[pos];
got_from_combined_presentation = 1;
break;
/* Redirecting-from party id subaddress */
case AST_REDIRECTING_FROM_SUBADDRESS:
ast_free(redirecting->from.subaddress.str);
redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
if (redirecting->from.subaddress.str) {
memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
redirecting->from.subaddress.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_FROM_SUBADDRESS_TYPE:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.subaddress.type = data[pos];
break;
case AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN:
if (ie_len != 1) {
ast_log(LOG_WARNING,
"Invalid redirecting-from subaddress odd-even indicator (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.subaddress.odd_even_indicator = data[pos];
break;
case AST_REDIRECTING_FROM_SUBADDRESS_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->from.subaddress.valid = data[pos];
break;
/* Redirecting-from party id tag */
case AST_REDIRECTING_FROM_TAG:
ast_free(redirecting->from.tag);
redirecting->from.tag = ast_malloc(ie_len + 1);
if (redirecting->from.tag) {
memcpy(redirecting->from.tag, data + pos, ie_len);
redirecting->from.tag[ie_len] = 0;
}
break;
/* Redirecting-to party id name */
case AST_REDIRECTING_TO_NAME:
ast_free(redirecting->to.name.str);
redirecting->to.name.str = ast_malloc(ie_len + 1);
if (redirecting->to.name.str) {
memcpy(redirecting->to.name.str, data + pos, ie_len);
redirecting->to.name.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_TO_NAME_CHAR_SET:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.name.char_set = data[pos];
break;
case AST_REDIRECTING_TO_NAME_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.name.presentation = data[pos];
break;
case AST_REDIRECTING_TO_NAME_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.name.valid = data[pos];
break;
/* Redirecting-to party id number */
case AST_REDIRECTING_TO_NUMBER:
ast_free(redirecting->to.number.str);
redirecting->to.number.str = ast_malloc(ie_len + 1);
if (redirecting->to.number.str) {
memcpy(redirecting->to.number.str, data + pos, ie_len);
redirecting->to.number.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_TO_NUMBER_PLAN:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.number.plan = data[pos];
break;
case AST_REDIRECTING_TO_NUMBER_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.number.presentation = data[pos];
break;
case AST_REDIRECTING_TO_NUMBER_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.number.valid = data[pos];
break;
/* Redirecting-to party id combined presentation */
case AST_REDIRECTING_TO_ID_PRESENTATION:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
(unsigned) ie_len);
break;
}
to_combined_presentation = data[pos];
got_to_combined_presentation = 1;
break;
/* Redirecting-to party id subaddress */
case AST_REDIRECTING_TO_SUBADDRESS:
ast_free(redirecting->to.subaddress.str);
redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
if (redirecting->to.subaddress.str) {
memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
redirecting->to.subaddress.str[ie_len] = 0;
}
break;
case AST_REDIRECTING_TO_SUBADDRESS_TYPE:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.subaddress.type = data[pos];
break;
case AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN:
if (ie_len != 1) {
ast_log(LOG_WARNING,
"Invalid redirecting-to subaddress odd-even indicator (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.subaddress.odd_even_indicator = data[pos];
break;
case AST_REDIRECTING_TO_SUBADDRESS_VALID:
if (ie_len != 1) {
ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
(unsigned) ie_len);
break;
}
redirecting->to.subaddress.valid = data[pos];
break;
/* Redirecting-to party id tag */
case AST_REDIRECTING_TO_TAG:
ast_free(redirecting->to.tag);
redirecting->to.tag = ast_malloc(ie_len + 1);
if (redirecting->to.tag) {
memcpy(redirecting->to.tag, data + pos, ie_len);
redirecting->to.tag[ie_len] = 0;
}
break;
/* Redirecting reason */
case AST_REDIRECTING_REASON:
if (ie_len != sizeof(value)) {
ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
(unsigned) ie_len);
break;
}
memcpy(&value, data + pos, sizeof(value));
redirecting->reason = ntohl(value);
break;
/* Redirecting count */
case AST_REDIRECTING_COUNT:
if (ie_len != sizeof(value)) {
ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
(unsigned) ie_len);
break;
}
memcpy(&value, data + pos, sizeof(value));
redirecting->count = ntohl(value);
break;
/* Redirecting unknown element */
default:
ast_log(LOG_DEBUG, "Unknown redirecting element: %u (%u)\n",
(unsigned) ie_id, (unsigned) ie_len);
break;
}
}
switch (frame_version) {
case 1:
/*
* The other end is an earlier version that we need to adjust
* for compatibility.
*/
redirecting->from.name.valid = 1;
redirecting->from.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
redirecting->from.number.valid = 1;
if (got_from_combined_presentation) {
redirecting->from.name.presentation = from_combined_presentation;
redirecting->from.number.presentation = from_combined_presentation;
}
redirecting->to.name.valid = 1;
redirecting->to.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
redirecting->to.number.valid = 1;
if (got_to_combined_presentation) {
redirecting->to.name.presentation = to_combined_presentation;
redirecting->to.number.presentation = to_combined_presentation;
}
break;
case 2:
/* The other end is at the same level as we are. */
break;
default:
/*
* The other end is newer than we are.
* We need to assume that they are compatible with us.
*/
ast_log(LOG_DEBUG, "Redirecting frame has newer version: %u\n",
(unsigned) frame_version);
break;
}
return 0;
}
| struct ast_channel* ast_request | ( | const char * | type, |
| format_t | format, | ||
| const struct ast_channel * | requestor, | ||
| void * | data, | ||
| int * | status | ||
| ) | [read] |
Requests a channel.
| type | type of channel to request |
| format | requested channel format (codec) |
| requestor | channel asking for data |
| data | data to pass to the channel requester |
| status | status |
Request a channel of a given type, with data as optional information used by the low level module
| NULL | failure |
| non-NULL | channel on success |
Definition at line 5534 of file channel.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, ast_channel_release(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_TEXT_MASK, AST_FORMAT_VIDEO_MASK, ast_getformatname_multiple(), ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_translator_best_choice(), capabilities, ast_channel_tech::capabilities, chanlist::chan, LOG_WARNING, ast_channel_tech::requester, set_security_requirements(), chanlist::tech, and ast_channel_tech::type.
Referenced by __ast_request_and_dial(), ast_call_forward(), attempt_reconnect(), begin_dial_channel(), build_conf(), chanavail_exec(), conf_run(), connect_link(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), and wait_for_answer().
{
struct chanlist *chan;
struct ast_channel *c;
format_t capabilities;
format_t fmt;
int res;
int foo;
format_t videoformat = format & AST_FORMAT_VIDEO_MASK;
format_t textformat = format & AST_FORMAT_TEXT_MASK;
if (!cause)
cause = &foo;
*cause = AST_CAUSE_NOTDEFINED;
if (AST_RWLIST_RDLOCK(&backends)) {
ast_log(LOG_WARNING, "Unable to lock technology backend list\n");
return NULL;
}
AST_RWLIST_TRAVERSE(&backends, chan, list) {
if (strcasecmp(type, chan->tech->type))
continue;
capabilities = chan->tech->capabilities;
fmt = format & AST_FORMAT_AUDIO_MASK;
if (fmt) {
/* We have audio - is it possible to connect the various calls to each other?
(Avoid this check for calls without audio, like text+video calls)
*/
res = ast_translator_best_choice(&fmt, &capabilities);
if (res < 0) {
char tmp1[256], tmp2[256];
ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities),
ast_getformatname_multiple(tmp2, sizeof(tmp2), format));
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
AST_RWLIST_UNLOCK(&backends);
return NULL;
}
}
AST_RWLIST_UNLOCK(&backends);
if (!chan->tech->requester)
return NULL;
if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, requestor, data, cause)))
return NULL;
if (set_security_requirements(requestor, c)) {
ast_log(LOG_WARNING, "Setting security requirements failed\n");
c = ast_channel_release(c);
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
return NULL;
}
/* no need to generate a Newchannel event here; it is done in the channel_alloc call */
return c;
}
ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
*cause = AST_CAUSE_NOSUCHDRIVER;
AST_RWLIST_UNLOCK(&backends);
return NULL;
}
| struct ast_channel* ast_request_and_dial | ( | const char * | type, |
| format_t | format, | ||
| const struct ast_channel * | requestor, | ||
| void * | data, | ||
| int | timeout, | ||
| int * | reason, | ||
| const char * | cid_num, | ||
| const char * | cid_name | ||
| ) | [read] |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
| type | type of channel to request |
| format | requested channel format |
| requestor | channel asking for data |
| data | data to pass to the channel requester |
| timeout | maximum amount of time to wait for an answer |
| reason | why unsuccessful (if unsuccessful) |
| cid_num | Caller-ID Number |
| cid_name | Caller-ID Name (ascii) |
Definition at line 5489 of file channel.c.
References __ast_request_and_dial().
Referenced by ast_pbx_outgoing_exten(), and generic_recall().
{
return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL);
}
| int ast_safe_sleep | ( | struct ast_channel * | chan, |
| int | ms | ||
| ) |
Wait, look for hangups.
Wait for a specified amount of time, looking for hangups.
Definition at line 1873 of file channel.c.
References ast_safe_sleep_conditional().
Referenced by __analog_ss_thread(), alarmreceiver_exec(), analog_ss_thread(), ast_adsi_transmit_message_full(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), builtin_parkcall(), conf_run(), dictate_exec(), disa_exec(), flash_exec(), function_ilink(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), pbx_builtin_wait(), play_moh_exec(), play_tone_pair(), playtone(), privacy_exec(), receive_ademco_contact_id(), rpt_call(), rpt_exec(), rpt_tele_thread(), send_morse(), send_tone_telemetry(), skinny_ss(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_interval(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().
{
return ast_safe_sleep_conditional(chan, ms, NULL, NULL);
}
| int ast_safe_sleep_conditional | ( | struct ast_channel * | chan, |
| int | ms, | ||
| int(*)(void *) | cond, | ||
| void * | data | ||
| ) |
Wait, look for hangups and condition arg.
Wait for a specified amount of time, looking for hangups and a condition argument.
Definition at line 1806 of file channel.c.
References ast_channel_lock, ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unlock, ast_frfree, ast_frisolate(), ast_is_deferrable_frame(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_opt_transmit_silence, ast_queue_frame_head(), ast_read(), ast_waitfor(), cond, f, and ast_channel::generatordata.
Referenced by ast_safe_sleep(), and login_exec().
{
struct ast_frame *f;
struct ast_silence_generator *silgen = NULL;
int res = 0;
AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
/* If no other generator is present, start silencegen while waiting */
if (ast_opt_transmit_silence && !chan->generatordata) {
silgen = ast_channel_start_silence_generator(chan);
}
while (ms > 0) {
struct ast_frame *dup_f = NULL;
if (cond && ((*cond)(data) == 0)) {
break;
}
ms = ast_waitfor(chan, ms);
if (ms < 0) {
res = -1;
break;
}
if (ms > 0) {
f = ast_read(chan);
if (!f) {
res = -1;
break;
}
if (!ast_is_deferrable_frame(f)) {
ast_frfree(f);
continue;
}
if ((dup_f = ast_frisolate(f))) {
if (dup_f != f) {
ast_frfree(f);
}
AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list);
}
}
}
/* stop silgen if present */
if (silgen) {
ast_channel_stop_silence_generator(chan, silgen);
}
/* We need to free all the deferred frames, but we only need to
* queue the deferred frames if there was no error and no
* hangup was received
*/
ast_channel_lock(chan);
while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
if (!res) {
ast_queue_frame_head(chan, f);
}
ast_frfree(f);
}
ast_channel_unlock(chan);
return res;
}
| int ast_say_character_str | ( | struct ast_channel * | chan, |
| const char * | str, | ||
| const char * | ints, | ||
| const char * | lang | ||
| ) |
Definition at line 8115 of file channel.c.
References ast_say_character_str_full.
Referenced by common_exec(), pbx_builtin_saycharacters(), play_mailbox_owner(), rpt_tele_thread(), saycharstr(), saynode(), and vmsayname_exec().
{
return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
}
| int ast_say_digit_str | ( | struct ast_channel * | chan, |
| const char * | num, | ||
| const char * | ints, | ||
| const char * | lang | ||
| ) |
says digits of a string
| chan | channel to act upon |
| num | string to speak |
| ints | which dtmf to interrupt on |
| lang | language to speak in |
Vocally says the digits of a given string
| 0 | on succes |
| DTMF | if interrupted |
| -1 | on failure |
Definition at line 8109 of file channel.c.
References ast_say_digit_str_full.
Referenced by __analog_ss_thread(), forward_message(), invent_message(), mgcp_ss(), pbx_builtin_saydigits(), and play_message_callerid().
{
return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
}
| int ast_say_digits | ( | struct ast_channel * | chan, |
| int | num, | ||
| const char * | ints, | ||
| const char * | lang | ||
| ) |
says digits
| chan | channel to act upon |
| num | number to speak |
| ints | which dtmf to interrupt on |
| lang | language to speak |
Vocally says digits of a given number
| 0 | on success |
| DTMF | if interrupted |
| -1 | on failure |
Definition at line 8103 of file channel.c.
References ast_say_digits_full().
Referenced by common_exec(), conf_exec(), conf_run(), park_call_full(), parkandannounce_exec(), and rpt_tele_thread().
{
return ast_say_digits_full(chan, num, ints, lang, -1, -1);
}
| int ast_say_digits_full | ( | struct ast_channel * | chan, |
| int | num, | ||
| const char * | ints, | ||
| const char * | lang, | ||
| int | audiofd, | ||
| int | ctrlfd | ||
| ) |
Definition at line 8127 of file channel.c.
References ast_say_digit_str_full.
Referenced by ast_say_digits(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_he(), ast_say_number_full_hu(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_ur(), ast_say_number_full_vi(), ast_say_number_full_zh(), and say_init_mode().
{
char buf[256];
snprintf(buf, sizeof(buf), "%d", num);
return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd);
}
| int ast_say_enumeration | ( | struct ast_channel * | chan, |
| int | num, | ||
| const char * | ints, | ||
| const char * | lang, | ||
| const char * | options | ||
| ) |
says an enumeration
| chan | channel to say them enumeration on |
| num | number to say on the channel |
| ints | which dtmf to interrupt on |
| lang | language to speak the enumeration |
| options | set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural |
Vocally says an enumeration on a given channel (first, sencond, third, forth, thirtyfirst, hundredth, ....) Especially useful for dates and messages. Says 'last' if num equals to INT_MAX
| 0 | on success |
| DTMF | digit on interrupt |
| -1 | on failure |
Definition at line 8097 of file channel.c.
References ast_say_enumeration_full.
Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_pl(), and ast_say_date_with_format_vi().
{
return ast_say_enumeration_full(chan, num, ints, language, options, -1, -1);
}
| int ast_say_number | ( | struct ast_channel * | chan, |
| int | num, | ||
| const char * | ints, | ||
| const char * | lang, | ||
| const char * | options | ||
| ) |
says a number
| chan | channel to say them number on |
| num | number to say on the channel |
| ints | which dtmf to interrupt on |
| lang | language to speak the number |
| options | set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural |
Vocally says a number on a given channel
| 0 | on success |
| DTMF | digit on interrupt |
| -1 | on failure |
Definition at line 8091 of file channel.c.
References ast_say_number_full.
Referenced by announce_user_count(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_pt(), ast_say_date_th(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), ast_say_datetime_he(), ast_say_datetime_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_hu(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), ast_say_time_th(), ast_say_time_zh(), bridge_playfile(), conf_run(), count_exec(), dictate_exec(), get_folder(), gr_say_number_female(), pbx_builtin_saynumber(), play_message(), play_message_duration(), rpt_tele_thread(), say_and_wait(), say_position(), saynum(), try_calling(), vm_intro_gr(), vm_intro_he(), vm_intro_multilang(), vm_intro_pt(), and vm_intro_pt_BR().
{
return ast_say_number_full(chan, num, ints, language, options, -1, -1);
}
| int ast_say_phonetic_str | ( | struct ast_channel * | chan, |
| const char * | str, | ||
| const char * | ints, | ||
| const char * | lang | ||
| ) |
Definition at line 8121 of file channel.c.
References ast_say_phonetic_str_full.
Referenced by pbx_builtin_sayphonetic().
{
return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
}
| int ast_senddigit | ( | struct ast_channel * | chan, |
| char | digit, | ||
| unsigned int | duration | ||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon |
| digit | the DTMF digit to send, encoded in ASCII |
| duration | the duration of the digit ending in ms |
Definition at line 4625 of file channel.c.
References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by ast_dtmf_stream(), dial_exec_full(), do_dtmf_phone(), manager_play_dtmf(), and rpt_call().
{
if (chan->tech->send_digit_begin) {
ast_senddigit_begin(chan, digit);
ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
}
return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
}
| int ast_senddigit_begin | ( | struct ast_channel * | chan, |
| char | digit | ||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon |
| digit | the DTMF digit to send, encoded in ASCII |
Definition at line 4567 of file channel.c.
References ast_debug, ast_playtones_start(), ast_channel::name, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().
{
/* Device does not support DTMF tones, lets fake
* it by doing our own generation. */
static const char * const dtmf_tones[] = {
"941+1336", /* 0 */
"697+1209", /* 1 */
"697+1336", /* 2 */
"697+1477", /* 3 */
"770+1209", /* 4 */
"770+1336", /* 5 */
"770+1477", /* 6 */
"852+1209", /* 7 */
"852+1336", /* 8 */
"852+1477", /* 9 */
"697+1633", /* A */
"770+1633", /* B */
"852+1633", /* C */
"941+1633", /* D */
"941+1209", /* * */
"941+1477" /* # */
};
if (!chan->tech->send_digit_begin)
return 0;
if (!chan->tech->send_digit_begin(chan, digit))
return 0;
if (digit >= '0' && digit <='9')
ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
else if (digit >= 'A' && digit <= 'D')
ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
else if (digit == '*')
ast_playtones_start(chan, 0, dtmf_tones[14], 0);
else if (digit == '#')
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
return 0;
}
| int ast_senddigit_end | ( | struct ast_channel * | chan, |
| char | digit, | ||
| unsigned int | duration | ||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon |
| digit | the DTMF digit to send, encoded in ASCII |
| duration | the duration of the digit ending in ms |
Definition at line 4612 of file channel.c.
References ast_playtones_stop(), ast_channel::generator, ast_channel_tech::send_digit_end, and ast_channel::tech.
Referenced by agent_digit_end(), ast_senddigit(), and ast_write().
{
int res = -1;
if (chan->tech->send_digit_end)
res = chan->tech->send_digit_end(chan, digit, duration);
if (res && chan->generator)
ast_playtones_stop(chan);
return 0;
}
| int ast_sendtext | ( | struct ast_channel * | chan, |
| const char * | text | ||
| ) |
Sends text to a channel.
| chan | channel to act upon |
| text | string of text to send on the channel |
Write text to a display on a channel
| 0 | on success |
| -1 | on failure |
Definition at line 4549 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_test_flag, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.
Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), send_newkey(), and sendtext_exec().
{
int res = 0;
ast_channel_lock(chan);
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
ast_channel_unlock(chan);
return -1;
}
CHECK_BLOCKING(chan);
if (chan->tech->send_text)
res = chan->tech->send_text(chan, text);
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
return res;
}
| void ast_set_callerid | ( | struct ast_channel * | chan, |
| const char * | cid_num, | ||
| const char * | cid_name, | ||
| const char * | cid_ani | ||
| ) |
Set caller ID number, name and ANI and generate AMI event.
Definition at line 6801 of file channel.c.
References ast_party_caller::ani, ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_free, ast_strdup, ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.
Referenced by __analog_ss_thread(), analog_ss_thread(), cb_events(), disa_exec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), privacy_exec(), ring_entry(), rpt_exec(), skinny_newcall(), and socket_process().
{
ast_channel_lock(chan);
if (cid_num) {
chan->caller.id.number.valid = 1;
ast_free(chan->caller.id.number.str);
chan->caller.id.number.str = ast_strdup(cid_num);
}
if (cid_name) {
chan->caller.id.name.valid = 1;
ast_free(chan->caller.id.name.str);
chan->caller.id.name.str = ast_strdup(cid_name);
}
if (cid_ani) {
chan->caller.ani.number.valid = 1;
ast_free(chan->caller.ani.number.str);
chan->caller.ani.number.str = ast_strdup(cid_ani);
}
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
}
report_new_callerid(chan);
ast_channel_unlock(chan);
}
| void ast_set_hangupsource | ( | struct ast_channel * | chan, |
| const char * | source, | ||
| int | force | ||
| ) |
Set the source of the hangup in this channel and it's bridge.
| chan | channel to set the field on |
| source | a string describing the source of the hangup for this channel |
| force |
Hangupsource is generally the channel name that caused the bridge to be hung up, but it can also be other things such as "dialplan/agi" This can then be logged in the CDR or CEL
Definition at line 2714 of file channel.c.
References ast_bridged_channel(), ast_channel_lock, ast_channel_unlock, ast_string_field_set, ast_strlen_zero(), ast_channel::bridge, and ast_channel::hangupsource.
Referenced by __dahdi_exception(), func_channel_write_real(), handle_hangup(), handle_request_bye(), handle_request_cancel(), handle_response_invite(), pbx_builtin_hangup(), and set_hangup_source_and_cause().
{
struct ast_channel *bridge;
ast_channel_lock(chan);
if (force || ast_strlen_zero(chan->hangupsource)) {
ast_string_field_set(chan, hangupsource, source);
}
bridge = ast_bridged_channel(chan);
ast_channel_unlock(chan);
if (bridge && (force || ast_strlen_zero(bridge->hangupsource))) {
ast_channel_lock(bridge);
ast_string_field_set(chan, hangupsource, source);
ast_channel_unlock(bridge);
}
}
| static void ast_set_owners_and_peers | ( | struct ast_channel * | chan1, |
| struct ast_channel * | chan2 | ||
| ) | [static] |
Definition at line 6265 of file channel.c.
References accountcode, ast_channel::accountcode, ast_log(), ast_string_field_set, ast_strlen_zero(), LOG_DEBUG, ast_channel::name, and ast_channel::peeraccount.
Referenced by ast_channel_bridge().
{
if (!ast_strlen_zero(chan1->accountcode) && ast_strlen_zero(chan2->peeraccount)) {
ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n",
chan1->accountcode, chan2->name, chan1->name);
ast_string_field_set(chan2, peeraccount, chan1->accountcode);
}
if (!ast_strlen_zero(chan2->accountcode) && ast_strlen_zero(chan1->peeraccount)) {
ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n",
chan2->accountcode, chan1->name, chan2->name);
ast_string_field_set(chan1, peeraccount, chan2->accountcode);
}
if (!ast_strlen_zero(chan1->peeraccount) && ast_strlen_zero(chan2->accountcode)) {
ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n",
chan1->peeraccount, chan2->name, chan1->name);
ast_string_field_set(chan2, accountcode, chan1->peeraccount);
}
if (!ast_strlen_zero(chan2->peeraccount) && ast_strlen_zero(chan1->accountcode)) {
ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n",
chan2->peeraccount, chan1->name, chan2->name);
ast_string_field_set(chan1, accountcode, chan2->peeraccount);
}
if (0 != strcmp(chan1->accountcode, chan2->peeraccount)) {
ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n",
chan2->peeraccount, chan1->peeraccount, chan2->name, chan1->name);
ast_string_field_set(chan2, peeraccount, chan1->accountcode);
}
if (0 != strcmp(chan2->accountcode, chan1->peeraccount)) {
ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n",
chan1->peeraccount, chan2->peeraccount, chan1->name, chan2->name);
ast_string_field_set(chan1, peeraccount, chan2->accountcode);
}
}
| int ast_set_read_format | ( | struct ast_channel * | chan, |
| format_t | format | ||
| ) |
Sets read format on channel chan Set read format for channel to whichever component of "format" is best.
| chan | channel to change |
| format | format to change to |
Definition at line 5151 of file channel.c.
References ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().
Referenced by __ast_play_and_record(), __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_make_compatible_helper(), ast_do_masquerade(), attempt_reconnect(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), build_conf(), conf_run(), connect_link(), dictate_exec(), do_waiting(), eagi_exec(), echo_exec(), generic_fax_exec(), gtalk_rtp_read(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), jingle_rtp_read(), login_exec(), measurenoise(), mgcp_rtp_read(), oh323_rtp_read(), old_milliwatt_exec(), process_sdp(), record_exec(), rpt(), rpt_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().
{
return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
&chan->readtrans, 0);
}
| void ast_set_variables | ( | struct ast_channel * | chan, |
| struct ast_variable * | vars | ||
| ) |
adds a list of channel variables to a channel
| chan | the channel |
| vars | a linked list of variables |
Variable names can be for a regular channel variable or a dialplan function that has the ability to be written to.
Definition at line 7978 of file channel.c.
References ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), and ast_variable::value.
Referenced by __ast_request_and_dial(), ast_call_forward(), ast_pbx_outgoing_app(), and ast_pbx_outgoing_exten().
{
struct ast_variable *cur;
for (cur = vars; cur; cur = cur->next)
pbx_builtin_setvar_helper(chan, cur->name, cur->value);
}
| int ast_set_write_format | ( | struct ast_channel * | chan, |
| format_t | format | ||
| ) |
Sets write format on channel chan Set write format for channel to whichever component of "format" is best.
| chan | channel to change |
| format | new format for writing |
Definition at line 5157 of file channel.c.
References ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.
Referenced by __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_stopstream(), ast_write(), attempt_reconnect(), bridge_channel_join(), bridge_make_compatible(), build_conf(), chanspy_exec(), conf_run(), connect_link(), dahdiscan_exec(), echo_exec(), extenspy_exec(), generic_fax_exec(), gtalk_rtp_read(), jack_exec(), jingle_rtp_read(), linear_alloc(), linear_release(), login_exec(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_release(), mp3_exec(), NBScat_exec(), oh323_rtp_read(), old_milliwatt_exec(), playtones_alloc(), playtones_release(), process_sdp(), rpt(), rpt_exec(), send_waveform_to_channel(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), tonepair_alloc(), tonepair_release(), transmit_audio(), and unistim_rtp_read().
{
return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
&chan->writetrans, 1);
}
| int ast_setstate | ( | struct ast_channel * | chan, |
| enum ast_channel_state | state | ||
| ) |
Change the state of a channel.
Definition at line 6869 of file channel.c.
References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_manager_event, ast_state2str(), ast_channel::caller, ast_channel::connected, EVENT_FLAG_CALL, ast_party_caller::id, ast_party_connected_line::id, name, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, state, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), agent_call(), alsa_answer(), analog_answer(), analog_call(), analog_exception(), analog_ss_thread(), ast_raw_answer(), cb_events(), check_availability(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), do_bridge_masquerade(), gtalk_call(), gtalk_newcall(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_response_invite(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_call(), jingle_call(), jingle_newcall(), local_queue_frame(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), my_set_waitingfordt(), nbs_call(), nbs_hangup(), oh323_answer(), oss_answer(), pbx_builtin_busy(), pbx_builtin_congestion(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), pri_dchannel(), pri_ss_thread(), release_chan(), release_chan_early(), sig_pri_answer(), sig_pri_call(), sig_pri_indicate(), sig_ss7_call(), sig_ss7_indicate(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), ss7_linkset(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), update_state(), usbradio_answer(), and usbradio_call().
{
int oldstate = chan->_state;
char name[AST_CHANNEL_NAME], *dashptr;
if (oldstate == state)
return 0;
ast_copy_string(name, chan->name, sizeof(name));
if ((dashptr = strrchr(name, '-'))) {
*dashptr = '\0';
}
chan->_state = state;
/* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
* for this channel is using the callback method for device state. If we pass in an actual state here
* we override what they are saying the state is and things go amuck. */
ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name);
/* setstate used to conditionally report Newchannel; this is no more */
ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate",
"Channel: %s\r\n"
"ChannelState: %d\r\n"
"ChannelStateDesc: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"Uniqueid: %s\r\n",
chan->name, chan->_state, ast_state2str(chan->_state),
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, ""),
chan->uniqueid);
return 0;
}
| int ast_settimeout | ( | struct ast_channel * | c, |
| unsigned int | rate, | ||
| int(*)(const void *data) | func, | ||
| void * | data | ||
| ) |
Enable or disable timer ticks for a channel.
| c | channel |
| rate | number of timer ticks per second |
| func | callback function |
| data |
If timers are supported, force a scheduled expiration on the timer fd, at which point we call the callback function / data
Definition at line 3479 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_debug, ast_timer_get_max_rate(), ast_timer_set_rate(), ast_channel::data, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.
Referenced by ast_activate_generator(), ast_deactivate_generator(), ast_read_generator_actions(), ast_readaudio_callback(), and filestream_close().
{
int res;
unsigned int real_rate = rate, max_rate;
ast_channel_lock(c);
if (c->timingfd == -1) {
ast_channel_unlock(c);
return -1;
}
if (!func) {
rate = 0;
data = NULL;
}
if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
real_rate = max_rate;
}
ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
res = ast_timer_set_rate(c->timer, real_rate);
c->timingfunc = func;
c->timingdata = data;
ast_channel_unlock(c);
return res;
}
| int ast_shutting_down | ( | void | ) |
Returns non-zero if Asterisk is being shut down.
Definition at line 844 of file channel.c.
References shutting_down.
Referenced by handle_request_options().
{
return shutting_down;
}
| int ast_softhangup | ( | struct ast_channel * | chan, |
| int | cause | ||
| ) |
Softly hangup a channel, lock.
Softly hangup up a channel.
Definition at line 2691 of file channel.c.
References ast_channel_lock, ast_channel_unlock, and ast_softhangup_nolock().
Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), agent_hangup(), agent_logoff(), agent_read(), ast_bridge_call(), ast_channel_softhangup_cb(), ast_dial_join(), birdbath(), cc_generic_agent_stop_ringing(), conf_free(), connect_link(), dahdi_handle_event(), flush_telem(), function_ilink(), handle_hangup(), handle_link_data(), handle_softhangup(), login_exec(), manager_park(), mgcp_pktcgate_remove(), read_agent_config(), rpt(), rpt_call(), rpt_do_restart(), rpt_exec(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().
{
int res;
ast_channel_lock(chan);
res = ast_softhangup_nolock(chan, cause);
ast_channel_unlock(chan);
return res;
}
| int ast_softhangup_nolock | ( | struct ast_channel * | chan, |
| int | cause | ||
| ) |
Softly hangup a channel, don't lock.
Softly hangup up a channel (no channel lock)
Definition at line 2678 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel::blocker, cause, and ast_channel::name.
Referenced by __analog_handle_event(), action_hangup(), ast_async_goto(), ast_softhangup(), attempt_transfer(), check_pendings(), check_rtp_timeout(), dahdi_softhangup_all(), oh323_indicate(), pri_dchannel(), proc_session_timer(), sig_pri_indicate(), sig_pri_send_aoce_termination_request(), sip_indicate(), skinny_indicate(), and ss7_linkset().
{
ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
/* Inform channel driver that we need to be hung up, if it cares */
chan->_softhangup |= cause;
ast_queue_frame(chan, &ast_null_frame);
/* Interrupt any poll call or such */
if (ast_test_flag(chan, AST_FLAG_BLOCKING))
pthread_kill(chan->blocker, SIGURG);
return 0;
}
| const char* ast_state2str | ( | enum ast_channel_state | state | ) |
Gives the string form of a given channel state.
Definition at line 986 of file channel.c.
References AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_threadstorage_get(), STATE2STR_BUFSIZE, and state2str_threadbuf.
Referenced by __ast_channel_alloc_ap(), action_coreshowchannels(), action_status(), agent_hangup(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_showchan(), local_attended_transfer(), mgcp_new(), serialize_showchan(), sip_hangup(), and update_connectedline().
{
char *buf;
switch (state) {
case AST_STATE_DOWN:
return "Down";
case AST_STATE_RESERVED:
return "Rsrvd";
case AST_STATE_OFFHOOK:
return "OffHook";
case AST_STATE_DIALING:
return "Dialing";
case AST_STATE_RING:
return "Ring";
case AST_STATE_RINGING:
return "Ringing";
case AST_STATE_UP:
return "Up";
case AST_STATE_BUSY:
return "Busy";
case AST_STATE_DIALING_OFFHOOK:
return "Dialing Offhook";
case AST_STATE_PRERING:
return "Pre-ring";
default:
if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
return "Unknown";
snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state);
return buf;
}
}
| int ast_str2cause | ( | const char * | name | ) |
| int ast_tonepair | ( | struct ast_channel * | chan, |
| int | freq1, | ||
| int | freq2, | ||
| int | duration, | ||
| int | vol | ||
| ) |
Play a tone pair for a given amount of time
Definition at line 7698 of file channel.c.
References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), and ast_channel::generatordata.
Referenced by zapateller_exec().
{
int res;
if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
return res;
/* Give us some wiggle room */
while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
struct ast_frame *f = ast_read(chan);
if (f)
ast_frfree(f);
else
return -1;
}
return 0;
}
| int ast_tonepair_start | ( | struct ast_channel * | chan, |
| int | freq1, | ||
| int | freq2, | ||
| int | duration, | ||
| int | vol | ||
| ) |
Start a tone going
Definition at line 7680 of file channel.c.
References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.
Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), play_tone_pair(), rpt_tele_thread(), and sendnoise().
| void ast_tonepair_stop | ( | struct ast_channel * | chan | ) |
Stop a tone from playing
Definition at line 7693 of file channel.c.
References ast_deactivate_generator().
Referenced by sendnoise().
{
ast_deactivate_generator(chan);
}
| int ast_transfer | ( | struct ast_channel * | chan, |
| char * | dest | ||
| ) |
Transfer a call to dest, if the channel supports transfer.
Transfer a channel (if supported).
Called by:
Definition at line 5627 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_CONTROL_TRANSFER, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_frfree, ast_read(), ast_test_flag, AST_TRANSFER_SUCCESS, ast_waitfor(), ast_frame::data, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, ast_frame::subclass, ast_channel::tech, and ast_channel_tech::transfer.
Referenced by transfer_exec().
{
int res = -1;
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
if (chan->tech->transfer) {
res = chan->tech->transfer(chan, dest);
if (!res)
res = 1;
} else
res = 0;
}
ast_channel_unlock(chan);
if (res <= 0) {
return res;
}
for (;;) {
struct ast_frame *fr;
res = ast_waitfor(chan, -1);
if (res < 0 || !(fr = ast_read(chan))) {
res = -1;
break;
}
if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) {
enum ast_control_transfer *message = fr->data.ptr;
if (*message == AST_TRANSFER_SUCCESS) {
res = 1;
} else {
res = -1;
}
ast_frfree(fr);
break;
}
ast_frfree(fr);
}
return res;
}
| char* ast_transfercapability2str | ( | int | transfercapability | ) | const |
Gives the string form of a given transfer capability.
| transfercapability | transfer capability to get the name of |
Definition at line 1020 of file channel.c.
References AST_TRANS_CAP_3_1K_AUDIO, AST_TRANS_CAP_DIGITAL, AST_TRANS_CAP_DIGITAL_W_TONES, AST_TRANS_CAP_RESTRICTED_DIGITAL, AST_TRANS_CAP_SPEECH, and AST_TRANS_CAP_VIDEO.
Referenced by ast_channel_data_add_structure(), cb_events(), misdn_call(), oh323_call(), sig_pri_call(), sig_pri_new_ast_channel(), and sig_ss7_new_ast_channel().
{
switch (transfercapability) {
case AST_TRANS_CAP_SPEECH:
return "SPEECH";
case AST_TRANS_CAP_DIGITAL:
return "DIGITAL";
case AST_TRANS_CAP_RESTRICTED_DIGITAL:
return "RESTRICTED_DIGITAL";
case AST_TRANS_CAP_3_1K_AUDIO:
return "3K1AUDIO";
case AST_TRANS_CAP_DIGITAL_W_TONES:
return "DIGITAL_W_TONES";
case AST_TRANS_CAP_VIDEO:
return "VIDEO";
default:
return "UNKNOWN";
}
}
| void ast_uninstall_music_functions | ( | void | ) |
Definition at line 7761 of file channel.c.
References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.
Referenced by unload_module().
{
ast_moh_start_ptr = NULL;
ast_moh_stop_ptr = NULL;
ast_moh_cleanup_ptr = NULL;
}
| int ast_waitfor | ( | struct ast_channel * | chan, |
| int | ms | ||
| ) |
Wait for input on a channel.
| chan | channel to wait on |
| ms | length of time to wait on the channel |
Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
| < | 0 on failure |
| 0 | if nothing ever arrived |
| the | # of ms remaining otherwise |
Definition at line 3463 of file channel.c.
References ast_waitfor_nandfds().
Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), analog_ss_thread(), ast_dtmf_stream(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), async_wait(), background_detect_exec(), channel_spy(), conf_flush(), dahdi_accept_r2_call_exec(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().
{
int oldms = ms; /* -1 if no timeout */
ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
if ((ms < 0) && (oldms < 0))
ms = 0;
return ms;
}
| struct ast_channel* ast_waitfor_n | ( | struct ast_channel ** | chan, |
| int | n, | ||
| int * | ms | ||
| ) | [read] |
Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds.
| chan | an array of pointers to channels |
| n | number of channels that are to be waited upon |
| ms | time "ms" is modified in-place, if applicable |
Definition at line 3458 of file channel.c.
References ast_waitfor_nandfds().
Referenced by ast_generic_bridge(), ast_udptl_bridge(), autoservice_run(), dahdi_bridge(), dial_exec_full(), feature_request_and_dial(), generic_thread_loop(), iax2_bridge(), local_bridge_loop(), misdn_bridge(), monitor_dial(), remote_bridge_loop(), rpt(), rpt_exec(), wait_for_answer(), and wait_for_winner().
{
return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
}
| int ast_waitfor_n_fd | ( | int * | fds, |
| int | n, | ||
| int * | ms, | ||
| int * | exception | ||
| ) |
Wait for x amount of time on a file descriptor to have input.
Waits for input on an fd.
Definition at line 3099 of file channel.c.
References ast_waitfor_nandfds().
Referenced by dundi_lookup_internal(), dundi_precache_internal(), and softmix_bridge_thread().
{
int winner = -1;
ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
return winner;
}
| struct ast_channel* ast_waitfor_nandfds | ( | struct ast_channel ** | c, |
| int | n, | ||
| int * | fds, | ||
| int | nfds, | ||
| int * | exception, | ||
| int * | outfd, | ||
| int * | ms | ||
| ) | [read] |
Wait for x amount of time on a file descriptor to have input.
Waits for activity on a group of channels.
Definition at line 3111 of file channel.c.
References ast_channel::_softhangup, ast_add_fd(), ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, ast_log(), AST_MAX_FDS, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), chanlist::chan, CHECK_BLOCKING, errno, ast_channel::fdno, and LOG_WARNING.
Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), bridge_channel_join_multithreaded(), conf_run(), eivr_comm(), find_cache(), generic_fax_exec(), multiplexed_thread_function(), run_agi(), and waitstream_core().
{
struct timeval start = { 0 , 0 };
struct pollfd *pfds = NULL;
int res;
long rms;
int x, y, max;
int sz;
struct timeval now = { 0, 0 };
struct timeval whentohangup = { 0, 0 }, diff;
struct ast_channel *winner = NULL;
struct fdmap {
int chan;
int fdno;
} *fdmap = NULL;
if ((sz = n * AST_MAX_FDS + nfds)) {
pfds = alloca(sizeof(*pfds) * sz);
fdmap = alloca(sizeof(*fdmap) * sz);
}
if (outfd)
*outfd = -99999;
if (exception)
*exception = 0;
/* Perform any pending masquerades */
for (x = 0; x < n; x++) {
if (c[x]->masq && ast_do_masquerade(c[x])) {
ast_log(LOG_WARNING, "Masquerade failed\n");
*ms = -1;
return NULL;
}
ast_channel_lock(c[x]);
if (!ast_tvzero(c[x]->whentohangup)) {
if (ast_tvzero(whentohangup))
now = ast_tvnow();
diff = ast_tvsub(c[x]->whentohangup, now);
if (diff.tv_sec < 0 || ast_tvzero(diff)) {
/* Should already be hungup */
c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
ast_channel_unlock(c[x]);
return c[x];
}
if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
whentohangup = diff;
}
ast_channel_unlock(c[x]);
}
/* Wait full interval */
rms = *ms;
/* INT_MAX, not LONG_MAX, because it matters on 64-bit */
if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
rms = *ms;
}
} else if (!ast_tvzero(whentohangup) && rms < 0) {
/* Tiny corner case... call would need to last >24 days */
rms = INT_MAX;
}
/*
* Build the pollfd array, putting the channels' fds first,
* followed by individual fds. Order is important because
* individual fd's must have priority over channel fds.
*/
max = 0;
for (x = 0; x < n; x++) {
for (y = 0; y < AST_MAX_FDS; y++) {
fdmap[max].fdno = y; /* fd y is linked to this pfds */
fdmap[max].chan = x; /* channel x is linked to this pfds */
max += ast_add_fd(&pfds[max], c[x]->fds[y]);
}
CHECK_BLOCKING(c[x]);
}
/* Add the individual fds */
for (x = 0; x < nfds; x++) {
fdmap[max].chan = -1;
max += ast_add_fd(&pfds[max], fds[x]);
}
if (*ms > 0)
start = ast_tvnow();
if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
do {
int kbrms = rms;
if (kbrms > 600000)
kbrms = 600000;
res = ast_poll(pfds, max, kbrms);
if (!res)
rms -= kbrms;
} while (!res && (rms > 0));
} else {
res = ast_poll(pfds, max, rms);
}
for (x = 0; x < n; x++)
ast_clear_flag(c[x], AST_FLAG_BLOCKING);
if (res < 0) { /* Simulate a timeout if we were interrupted */
if (errno != EINTR)
*ms = -1;
return NULL;
}
if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
now = ast_tvnow();
for (x = 0; x < n; x++) {
if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) {
c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
if (winner == NULL)
winner = c[x];
}
}
}
if (res == 0) { /* no fd ready, reset timeout and done */
*ms = 0; /* XXX use 0 since we may not have an exact timeout. */
return winner;
}
/*
* Then check if any channel or fd has a pending event.
* Remember to check channels first and fds last, as they
* must have priority on setting 'winner'
*/
for (x = 0; x < max; x++) {
res = pfds[x].revents;
if (res == 0)
continue;
if (fdmap[x].chan >= 0) { /* this is a channel */
winner = c[fdmap[x].chan]; /* override previous winners */
if (res & POLLPRI)
ast_set_flag(winner, AST_FLAG_EXCEPTION);
else
ast_clear_flag(winner, AST_FLAG_EXCEPTION);
winner->fdno = fdmap[x].fdno;
} else { /* this is an fd */
if (outfd)
*outfd = pfds[x].fd;
if (exception)
*exception = (res & POLLPRI) ? -1 : 0;
winner = NULL;
}
}
if (*ms > 0) {
*ms -= ast_tvdiff_ms(ast_tvnow(), start);
if (*ms < 0)
*ms = 0;
}
return winner;
}
| int ast_waitfordigit | ( | struct ast_channel * | c, |
| int | ms | ||
| ) |
Waits for a digit.
| c | channel to wait for a digit on |
| ms | how many milliseconds to wait |
Definition at line 3474 of file channel.c.
References ast_waitfordigit_full().
Referenced by __analog_ss_thread(), _while_exec(), advanced_options(), analog_my_getsigstr(), analog_ss_thread(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_print(), ast_adsi_read_encoded_dtmf(), ast_adsi_transmit_message_full(), ast_app_dtget(), ast_control_streamfile(), ast_record_review(), bridge_channel_feature(), builtin_atxfer(), collect_digits(), common_exec(), cpeid_exec(), dialout(), directory_exec(), forward_message(), get_folder(), ivr_dispatch(), mgcp_ss(), my_getsigstr(), pbx_builtin_waitexten(), play_record_review(), pri_ss_thread(), read_exec(), read_newoption(), readexten_exec(), retrydial_exec(), select_item_menu(), select_item_pause(), select_item_seq(), sendnoise(), testclient_exec(), testserver_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().
{
return ast_waitfordigit_full(c, ms, -1, -1);
}
| int ast_waitfordigit_full | ( | struct ast_channel * | c, |
| int | ms, | ||
| int | audiofd, | ||
| int | ctrlfd | ||
| ) |
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
| c | channel to wait for a digit on |
| ms | how many milliseconds to wait |
| audiofd | audio file descriptor to write to if audio frames are received |
| ctrlfd | control file descriptor to monitor for reading |
Definition at line 3512 of file channel.c.
References ast_check_hangup(), ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UPDATE_RTP_PEER, AST_FLAG_END_DTMF_ONLY, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_VOICE, ast_frfree, ast_log(), ast_read(), ast_set_flag, ast_test_flag, ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::ptr, and ast_frame::subclass.
Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().
{
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
return -1;
/* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
ast_set_flag(c, AST_FLAG_END_DTMF_ONLY);
/* Wait for a digit, no more than ms milliseconds total. */
while (ms) {
struct ast_channel *rchan;
int outfd=-1;
errno = 0;
rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
if (!rchan && outfd < 0 && ms) {
if (errno == 0 || errno == EINTR)
continue;
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
} else if (outfd > -1) {
/* The FD we were watching has something waiting */
ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return 1;
} else if (rchan) {
int res;
struct ast_frame *f = ast_read(c);
if (!f)
return -1;
switch (f->frametype) {
case AST_FRAME_DTMF_BEGIN:
break;
case AST_FRAME_DTMF_END:
res = f->subclass.integer;
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_FRAME_CONTROL:
switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
case AST_CONTROL_RINGING:
case AST_CONTROL_ANSWER:
case AST_CONTROL_SRCUPDATE:
case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_CONNECTED_LINE:
case AST_CONTROL_REDIRECTING:
case AST_CONTROL_UPDATE_RTP_PEER:
case -1:
/* Unimportant */
break;
default:
ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
break;
}
break;
case AST_FRAME_VOICE:
/* Write audio if appropriate */
if (audiofd > -1) {
if (write(audiofd, f->data.ptr, f->datalen) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
default:
/* Ignore */
break;
}
ast_frfree(f);
}
}
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return 0; /* Time is up */
}
| int ast_write | ( | struct ast_channel * | chan, |
| struct ast_frame * | frame | ||
| ) |
Write a frame to a channel This function writes the given frame to the indicated channel.
| chan | destination channel of the frame |
| frame | frame that will be written |
Definition at line 4767 of file channel.c.
References ast_channel::_softhangup, apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, AST_FORMAT_AUDIO_MASK, ast_format_rate(), AST_FORMAT_SLINEAR, AST_FORMAT_T140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate(), ast_getformatname(), ast_getformatname_multiple(), AST_LIST_NEXT, ast_log(), AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, calc_monitor_jump(), CHECK_BLOCKING, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, ast_filestream::fmt, ast_format::format, ast_channel::fout, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_channel::generatordata, ast_channel_tech::indicate, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, chanlist::next, ast_channel::outsmpl, ast_frame::ptr, ast_channel::rawwriteformat, ast_channel_monitor::read_stream, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel_tech::write, ast_channel_monitor::write_stream, ast_channel_tech::write_text, ast_channel_tech::write_video, ast_channel::writeformat, and ast_channel::writetrans.
Referenced by adsi_careful_send(), agent_write(), ast_bridge_call(), ast_generic_bridge(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), ast_udptl_bridge(), ast_write_video(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), feature_request_and_dial(), function_ilink(), gen_generate(), generic_fax_exec(), handle_jack_audio(), handle_link_data(), iax2_bridge(), jb_get_and_deliver(), linear_generator(), local_bridge_loop(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), multiplexed_bridge_write(), NBScat_exec(), playtones_generator(), remote_bridge_loop(), rpt(), rpt_exec(), send_link_dtmf(), send_link_keyquery(), send_tone_burst(), send_usb_txt(), send_waveform_to_channel(), silence_generator_generate(), simple_bridge_write(), sms_generate(), softmix_bridge_poke(), softmix_bridge_write(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().
{
int res = -1;
struct ast_frame *f = NULL;
int count = 0;
/*Deadlock avoidance*/
while(ast_channel_trylock(chan)) {
/*cannot goto done since the channel is not locked*/
if(count++ > 10) {
ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name);
return 0;
}
usleep(1);
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
goto done;
/* Handle any pending masquerades */
if (chan->masq) {
ast_channel_unlock(chan);
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
return res; /* no need to goto done: chan is already unlocked for masq */
}
ast_channel_lock(chan);
}
if (chan->masqr) {
res = 0; /* XXX explain, why 0 ? */
goto done;
}
/* Perform the framehook write event here. After the frame enters the framehook list
* there is no telling what will happen, how awesome is that!!! */
if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) {
res = 0;
goto done;
}
if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
ast_deactivate_generator(chan);
} else {
if (fr->frametype == AST_FRAME_DTMF_END) {
/* There is a generator running while we're in the middle of a digit.
* It's probably inband DTMF, so go ahead and pass it so it can
* stop the generator */
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
} else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
res = (chan->tech->indicate == NULL) ? 0 :
chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
}
res = 0; /* XXX explain, why 0 ? */
goto done;
}
}
/* High bit prints debugging */
if (chan->fout & DEBUGCHAN_FLAG)
ast_frame_dump(chan->name, fr, ">>");
CHECK_BLOCKING(chan);
switch (fr->frametype) {
case AST_FRAME_CONTROL:
res = (chan->tech->indicate == NULL) ? 0 :
chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
if (chan->audiohooks) {
struct ast_frame *old_frame = fr;
fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
if (old_frame != fr)
f = fr;
}
send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
res = ast_senddigit_begin(chan, fr->subclass.integer);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
case AST_FRAME_DTMF_END:
if (chan->audiohooks) {
struct ast_frame *new_frame = fr;
new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
if (new_frame != fr) {
ast_frfree(new_frame);
}
}
send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
case AST_FRAME_TEXT:
if (fr->subclass.integer == AST_FORMAT_T140) {
res = (chan->tech->write_text == NULL) ? 0 :
chan->tech->write_text(chan, fr);
} else {
res = (chan->tech->send_text == NULL) ? 0 :
chan->tech->send_text(chan, (char *) fr->data.ptr);
}
break;
case AST_FRAME_HTML:
res = (chan->tech->send_html == NULL) ? 0 :
chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
break;
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
res = (chan->tech->write_video == NULL) ? 0 :
chan->tech->write_video(chan, fr);
break;
case AST_FRAME_MODEM:
res = (chan->tech->write == NULL) ? 0 :
chan->tech->write(chan, fr);
break;
case AST_FRAME_VOICE:
if (chan->tech->write == NULL)
break; /*! \todo XXX should return 0 maybe ? */
if (ast_opt_generic_plc && fr->subclass.codec == AST_FORMAT_SLINEAR) {
apply_plc(chan, fr);
}
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
if (fr->subclass.codec == chan->rawwriteformat) {
f = fr;
} else {
/* XXX Something is not right we are not compatible with this frame bad things can happen
* problems range from no/one-way audio to unexplained line hangups as a last resort try adjust the format
* ideally we do not want to do this and this indicates a deeper problem for now we log these events to
* eliminate user impact and help identify the problem areas
* JIRA issues related to this :-
* ASTERISK-14384, ASTERISK-17502, ASTERISK-17541, ASTERISK-18063, ASTERISK-18325, ASTERISK-18422*/
if ((!(fr->subclass.codec & chan->nativeformats)) && (chan->writeformat != fr->subclass.codec)) {
char nf[512];
ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
chan->name, ast_getformatname(fr->subclass.codec), ast_getformatname(chan->writeformat),
ast_getformatname_multiple(nf, sizeof(nf), chan->nativeformats & AST_FORMAT_AUDIO_MASK));
ast_set_write_format(chan, fr->subclass.codec);
}
f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
}
if (!f) {
res = 0;
break;
}
if (chan->audiohooks) {
struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
int freeoldlist = 0;
if (f != fr) {
freeoldlist = 1;
}
/* Since ast_audiohook_write may return a new frame, and the cur frame is
* an item in a list of frames, create a new list adding each cur frame back to it
* regardless if the cur frame changes or not. */
for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur);
/* if this frame is different than cur, preserve the end of the list,
* free the old frames, and set cur to be the new frame */
if (new_frame != cur) {
/* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
* isn't part of local storage, meaning if ast_audiohook_write is called multiple
* times it may override the previous frame we got from it unless we dup it */
if ((dup = ast_frisolate(new_frame))) {
AST_LIST_NEXT(dup, frame_list) = AST_LIST_NEXT(cur, frame_list);
if (freeoldlist) {
AST_LIST_NEXT(cur, frame_list) = NULL;
ast_frfree(cur);
}
if (new_frame != dup) {
ast_frfree(new_frame);
}
cur = dup;
}
}
/* now, regardless if cur is new or not, add it to the new list,
* if the new list has not started, cur will become the first item. */
if (prev) {
AST_LIST_NEXT(prev, frame_list) = cur;
} else {
f = cur; /* set f to be the beginning of our new list */
}
prev = cur;
}
}
/* If Monitor is running on this channel, then we have to write frames out there too */
/* the translator on chan->writetrans may have returned multiple frames
from the single frame we passed in; if so, feed each one of them to the
monitor */
if (chan->monitor && chan->monitor->write_stream) {
struct ast_frame *cur;
for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
/* XXX must explain this code */
#ifndef MONITOR_CONSTANT_DELAY
int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples;
if (jump >= 0) {
jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples;
} else {
chan->outsmpl += cur->samples;
}
#else
int jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
chan->outsmpl += chan->insmpl - chan->outsmpl;
} else {
chan->outsmpl += cur->samples;
}
#endif
if (chan->monitor->state == AST_MONITOR_RUNNING) {
if (ast_writestream(chan->monitor->write_stream, cur) < 0)
ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
}
}
}
/* the translator on chan->writetrans may have returned multiple frames
from the single frame we passed in; if so, feed each one of them to the
channel, freeing each one after it has been written */
if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
struct ast_frame *cur, *next;
unsigned int skip = 0;
for (cur = f, next = AST_LIST_NEXT(cur, frame_list);
cur;
cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) {
if (!skip) {
if ((res = chan->tech->write(chan, cur)) < 0) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
skip = 1;
} else if (next) {
/* don't do this for the last frame in the list,
as the code outside the loop will do it once
*/
chan->fout = FRAMECOUNT_INC(chan->fout);
}
}
ast_frfree(cur);
}
/* reset f so the code below doesn't attempt to free it */
f = NULL;
} else {
res = chan->tech->write(chan, f);
}
break;
case AST_FRAME_NULL:
case AST_FRAME_IAX:
/* Ignore these */
res = 0;
break;
default:
/* At this point, fr is the incoming frame and f is NULL. Channels do
* not expect to get NULL as a frame pointer and will segfault. Hence,
* we output the original frame passed in. */
res = chan->tech->write(chan, fr);
break;
}
if (f && f != fr)
ast_frfree(f);
ast_clear_flag(chan, AST_FLAG_BLOCKING);
/* Consider a write failure to force a soft hangup */
if (res < 0) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
} else {
chan->fout = FRAMECOUNT_INC(chan->fout);
}
done:
if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
/* The list gets recreated if audiohooks are added again later */
ast_audiohook_detach_list(chan->audiohooks);
chan->audiohooks = NULL;
}
ast_channel_unlock(chan);
return res;
}
| int ast_write_video | ( | struct ast_channel * | chan, |
| struct ast_frame * | frame | ||
| ) |
Write video frame to a channel This function writes the given frame to the indicated channel.
| chan | destination channel of the frame |
| frame | frame that will be written |
Definition at line 4652 of file channel.c.
References ast_write(), ast_channel::tech, and ast_channel_tech::write_video.
{
int res;
if (!chan->tech->write_video)
return 0;
res = ast_write(chan, fr);
if (!res)
res = 1;
return res;
}
| static void bridge_play_sounds | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1 | ||
| ) | [static] |
Definition at line 7225 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strdupa, bridge_playfile(), pbx_builtin_getvar_helper(), and pbx_builtin_setvar_helper().
Referenced by ast_channel_bridge().
{
const char *s, *sound;
/* See if we need to play an audio file to any side of the bridge */
ast_channel_lock(c0);
if ((s = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) {
sound = ast_strdupa(s);
ast_channel_unlock(c0);
bridge_playfile(c0, c1, sound, 0);
pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL);
} else {
ast_channel_unlock(c0);
}
ast_channel_lock(c1);
if ((s = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) {
sound = ast_strdupa(s);
ast_channel_unlock(c1);
bridge_playfile(c1, c0, sound, 0);
pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL);
} else {
ast_channel_unlock(c1);
}
}
| static void bridge_playfile | ( | struct ast_channel * | chan, |
| struct ast_channel * | peer, | ||
| const char * | sound, | ||
| int | remain | ||
| ) | [static] |
Definition at line 6919 of file channel.c.
References ast_autoservice_start(), ast_autoservice_stop(), AST_DIGIT_ANY, ast_say_number(), ast_stream_and_wait(), and ast_channel::language.
Referenced by ast_channel_bridge(), and bridge_play_sounds().
{
int min = 0, sec = 0, check;
check = ast_autoservice_start(peer);
if (check)
return;
if (remain > 0) {
if (remain / 60 > 1) {
min = remain / 60;
sec = remain % 60;
} else {
sec = remain;
}
}
if (!strcmp(sound,"timeleft")) { /* Queue support */
ast_stream_and_wait(chan, "vm-youhave", "");
if (min) {
ast_say_number(chan, min, AST_DIGIT_ANY, chan->language, NULL);
ast_stream_and_wait(chan, "queue-minutes", "");
}
if (sec) {
ast_say_number(chan, sec, AST_DIGIT_ANY, chan->language, NULL);
ast_stream_and_wait(chan, "queue-seconds", "");
}
} else {
ast_stream_and_wait(chan, sound, "");
}
ast_autoservice_stop(peer);
}
| static int calc_monitor_jump | ( | int | samples, |
| int | sample_rate, | ||
| int | seek_rate | ||
| ) | [inline, static] |
calculates the number of samples to jump forward with in a monitor stream.
| number | of samples to seek forward after rate conversion. |
Definition at line 3702 of file channel.c.
References ast_frame::samples.
Referenced by __ast_read(), and ast_write().
| static void call_forward_inherit | ( | struct ast_channel * | new_chan, |
| struct ast_channel * | parent, | ||
| struct ast_channel * | orig | ||
| ) | [static] |
Definition at line 5209 of file channel.c.
References ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_redirecting_macro(), ast_channel_unlock, ast_channel_update_redirecting(), ast_check_hangup(), AST_FLAG_ZOMBIE, ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_test_flag, and ast_channel::redirecting.
Referenced by ast_call_forward().
{
if (!ast_test_flag(parent, AST_FLAG_ZOMBIE) && !ast_check_hangup(parent)) {
struct ast_party_redirecting redirecting;
/*
* The parent is not a ZOMBIE or hungup so update it with the
* original channel's redirecting information.
*/
ast_party_redirecting_init(&redirecting);
ast_channel_lock(orig);
ast_party_redirecting_copy(&redirecting, &orig->redirecting);
ast_channel_unlock(orig);
if (ast_channel_redirecting_macro(orig, parent, &redirecting, 1, 0)) {
ast_channel_update_redirecting(parent, &redirecting, NULL);
}
ast_party_redirecting_free(&redirecting);
}
/* Safely inherit variables and datastores from the parent channel. */
ast_channel_lock_both(parent, new_chan);
ast_channel_inherit_variables(parent, new_chan);
ast_channel_datastore_inherit(parent, new_chan);
ast_channel_unlock(new_chan);
ast_channel_unlock(parent);
}
| static void* channel_cc_params_copy | ( | void * | data | ) | [static] |
Definition at line 9391 of file channel.c.
References ast_cc_config_params_init, and ast_cc_copy_config_params().
{
const struct ast_cc_config_params *src = data;
struct ast_cc_config_params *dest = ast_cc_config_params_init();
if (!dest) {
return NULL;
}
ast_cc_copy_config_params(dest, src);
return dest;
}
| static void channel_cc_params_destroy | ( | void * | data | ) | [static] |
Definition at line 9402 of file channel.c.
References ast_cc_config_params_destroy().
{
struct ast_cc_config_params *cc_params = data;
ast_cc_config_params_destroy(cc_params);
}
| static void channel_data_add_flags | ( | struct ast_data * | tree, |
| struct ast_channel * | chan | ||
| ) | [static] |
Definition at line 267 of file channel.c.
References ast_data_add_bool(), AST_FLAG_ANSWERED_ELSEWHERE, AST_FLAG_BLOCKING, AST_FLAG_BRIDGE_HANGUP_DONT, AST_FLAG_BRIDGE_HANGUP_RUN, AST_FLAG_DEFER_DTMF, AST_FLAG_DISABLE_WORKAROUNDS, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_AUTOLOOP, AST_FLAG_IN_DTMF, AST_FLAG_MASQ_NOSTREAM, AST_FLAG_MOH, AST_FLAG_NBRIDGE, AST_FLAG_OUTGOING, AST_FLAG_SPYING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, and ast_test_flag.
Referenced by ast_channel_data_add_structure().
{
ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF));
ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT));
ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING));
ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE));
ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION));
ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH));
ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING));
ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE));
ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP));
ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING));
ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF));
ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF));
ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY));
ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE));
ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM));
ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
}
| static struct ast_channel_iterator* channel_iterator_search | ( | const char * | name, |
| size_t | name_len, | ||
| const char * | exten, | ||
| const char * | context | ||
| ) | [static, read] |
Definition at line 1618 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_find, ast_calloc, ast_copy_string(), ast_free, ast_strlen_zero(), channels, ast_channel::context, ast_channel::exten, name, ast_channel::name, OBJ_MULTIPLE, and OBJ_POINTER.
Referenced by ast_channel_iterator_by_exten_new(), and ast_channel_iterator_by_name_new().
{
struct ast_channel_iterator *i;
struct ast_channel tmp_chan = {
.name = name,
/* This is sort of a hack. Basically, we're using an arbitrary field
* in ast_channel to pass the name_len for a prefix match. If this
* gets changed, then the compare callback must be changed, too. */
.rings = name_len,
};
if (!(i = ast_calloc(1, sizeof(*i)))) {
return NULL;
}
if (exten) {
ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
}
if (context) {
ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
}
if (!(i->active_iterator = ao2_find(channels, &tmp_chan,
OBJ_MULTIPLE | ((!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0)))) {
ast_free(i);
return NULL;
}
return i;
}
| const char* channelreloadreason2txt | ( | enum channelreloadreason | reason | ) |
Convert enum channelreloadreason to text string for manager event.
\ brief Convert channel reloadreason (ENUM) to text string for manager event
Definition at line 8066 of file channel.c.
References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.
Referenced by reload_config().
{
switch (reason) {
case CHANNEL_MODULE_LOAD:
return "LOAD (Channel module load)";
case CHANNEL_MODULE_RELOAD:
return "RELOAD (Channel module reload)";
case CHANNEL_CLI_RELOAD:
return "CLIRELOAD (Channel module reload by CLI command)";
default:
return "MANAGERRELOAD (Channel module reload by manager)";
}
};
| static void clone_variables | ( | struct ast_channel * | original, |
| struct ast_channel * | clonechan | ||
| ) | [static] |
Clone channel variables from 'clone' channel into 'original' channel.
All variables except those related to app_groupcount are cloned. Variables are actually _removed_ from 'clone' channel, presumably because it will subsequently be destroyed.
Definition at line 6127 of file channel.c.
References AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_t::entries, ast_var_t::name, ast_var_t::value, and ast_channel::varshead.
Referenced by ast_do_masquerade().
{
struct ast_var_t *current, *newvar;
/* Append variables from clone channel into original channel */
/* XXX Is this always correct? We have to in order to keep MACROS working XXX */
if (AST_LIST_FIRST(&clonechan->varshead))
AST_LIST_APPEND_LIST(&original->varshead, &clonechan->varshead, entries);
/* then, dup the varshead list into the clone */
AST_LIST_TRAVERSE(&original->varshead, current, entries) {
newvar = ast_var_assign(current->name, current->value);
if (newvar)
AST_LIST_INSERT_TAIL(&clonechan->varshead, newvar, entries);
}
}
| static char* complete_channeltypes | ( | struct ast_cli_args * | a | ) | [static] |
Definition at line 522 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdup, ast_cli_args::n, ast_cli_args::pos, chanlist::tech, ast_channel_tech::type, and ast_cli_args::word.
Referenced by handle_cli_core_show_channeltype().
{
struct chanlist *cl;
int which = 0;
int wordlen;
char *ret = NULL;
if (a->pos != 3)
return NULL;
wordlen = strlen(a->word);
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
if (!strncasecmp(a->word, cl->tech->type, wordlen) && ++which > a->n) {
ret = ast_strdup(cl->tech->type);
break;
}
}
AST_RWLIST_UNLOCK(&backends);
return ret;
}
| static int data_channels_provider_handler | ( | const struct ast_data_search * | search, |
| struct ast_data * | root | ||
| ) | [static] |
Definition at line 7825 of file channel.c.
References ast_channel_data_add_structure(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_data_add_node(), ast_data_remove_node(), ast_data_search_match(), ast_log(), and LOG_ERROR.
{
struct ast_channel *c;
struct ast_channel_iterator *iter = NULL;
struct ast_data *data_channel;
for (iter = ast_channel_iterator_all_new();
iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
ast_channel_lock(c);
data_channel = ast_data_add_node(root, "channel");
if (!data_channel) {
ast_channel_unlock(c);
continue;
}
if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {
ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", c->name);
}
ast_channel_unlock(c);
if (!ast_data_search_match(search, data_channel)) {
ast_data_remove_node(root, data_channel);
}
}
if (iter) {
ast_channel_iterator_destroy(iter);
}
return 0;
}
| static int data_channeltypes_provider_handler | ( | const struct ast_data_search * | search, |
| struct ast_data * | data_root | ||
| ) | [static] |
Definition at line 7863 of file channel.c.
References ast_channel_tech::answer, ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_node(), ast_data_add_str(), ast_data_remove_node(), ast_data_search_match(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::bridge, ast_channel_tech::bridged_channel, ast_channel_tech::call, ast_channel_tech::capabilities, ast_channel_tech::cc_callback, ast_channel_tech::description, ast_channel_tech::devicestate, ast_channel_tech::early_bridge, ast_channel_tech::exception, ast_channel_tech::fixup, ast_channel_tech::func_channel_read, ast_channel_tech::func_channel_write, ast_channel_tech::get_base_channel, ast_channel_tech::get_pvt_uniqueid, ast_channel_tech::hangup, ast_channel_tech::indicate, ast_channel_tech::queryoption, ast_channel_tech::read, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, ast_channel_tech::set_base_channel, ast_channel_tech::setoption, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, ast_channel_tech::write, ast_channel_tech::write_text, and ast_channel_tech::write_video.
{
struct chanlist *cl;
struct ast_data *data_type;
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
data_type = ast_data_add_node(data_root, "type");
if (!data_type) {
continue;
}
ast_data_add_str(data_type, "name", cl->tech->type);
ast_data_add_str(data_type, "description", cl->tech->description);
ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0);
ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0);
ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0);
ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0);
ast_data_add_bool(data_type, "send_digit_end", cl->tech->send_digit_end ? 1 : 0);
ast_data_add_bool(data_type, "call", cl->tech->call ? 1 : 0);
ast_data_add_bool(data_type, "hangup", cl->tech->hangup ? 1 : 0);
ast_data_add_bool(data_type, "answer", cl->tech->answer ? 1 : 0);
ast_data_add_bool(data_type, "read", cl->tech->read ? 1 : 0);
ast_data_add_bool(data_type, "write", cl->tech->write ? 1 : 0);
ast_data_add_bool(data_type, "send_text", cl->tech->send_text ? 1 : 0);
ast_data_add_bool(data_type, "send_image", cl->tech->send_image ? 1 : 0);
ast_data_add_bool(data_type, "send_html", cl->tech->send_html ? 1 : 0);
ast_data_add_bool(data_type, "exception", cl->tech->exception ? 1 : 0);
ast_data_add_bool(data_type, "bridge", cl->tech->bridge ? 1 : 0);
ast_data_add_bool(data_type, "early_bridge", cl->tech->early_bridge ? 1 : 0);
ast_data_add_bool(data_type, "fixup", cl->tech->fixup ? 1 : 0);
ast_data_add_bool(data_type, "setoption", cl->tech->setoption ? 1 : 0);
ast_data_add_bool(data_type, "queryoption", cl->tech->queryoption ? 1 : 0);
ast_data_add_bool(data_type, "write_video", cl->tech->write_video ? 1 : 0);
ast_data_add_bool(data_type, "write_text", cl->tech->write_text ? 1 : 0);
ast_data_add_bool(data_type, "bridged_channel", cl->tech->bridged_channel ? 1 : 0);
ast_data_add_bool(data_type, "func_channel_read", cl->tech->func_channel_read ? 1 : 0);
ast_data_add_bool(data_type, "func_channel_write", cl->tech->func_channel_write ? 1 : 0);
ast_data_add_bool(data_type, "get_base_channel", cl->tech->get_base_channel ? 1 : 0);
ast_data_add_bool(data_type, "set_base_channel", cl->tech->set_base_channel ? 1 : 0);
ast_data_add_bool(data_type, "get_pvt_uniqueid", cl->tech->get_pvt_uniqueid ? 1 : 0);
ast_data_add_bool(data_type, "cc_callback", cl->tech->cc_callback ? 1 : 0);
ast_data_add_codecs(data_type, "capabilities", cl->tech->capabilities);
if (!ast_data_search_match(search, data_type)) {
ast_data_remove_node(data_root, data_type);
}
}
AST_RWLIST_UNLOCK(&backends);
return 0;
}
| static void free_translation | ( | struct ast_channel * | clonechan | ) | [static] |
Definition at line 2702 of file channel.c.
References ast_translator_free_path(), ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readtrans, and ast_channel::writetrans.
Referenced by ast_do_masquerade(), and ast_hangup().
{
if (clonechan->writetrans)
ast_translator_free_path(clonechan->writetrans);
if (clonechan->readtrans)
ast_translator_free_path(clonechan->readtrans);
clonechan->writetrans = NULL;
clonechan->readtrans = NULL;
clonechan->rawwriteformat = clonechan->nativeformats;
clonechan->rawreadformat = clonechan->nativeformats;
}
| static int generator_force | ( | const void * | data | ) | [static] |
Definition at line 3044 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, AST_FORMAT_AUDIO_MASK, ast_format_rate(), chanlist::chan, ast_generator::generate, ast_channel::generator, ast_channel::generatordata, and ast_channel::writeformat.
Referenced by ast_activate_generator(), and ast_read_generator_actions().
{
/* Called if generator doesn't have data */
void *tmp;
int res;
int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL;
struct ast_channel *chan = (struct ast_channel *)data;
ast_channel_lock(chan);
tmp = chan->generatordata;
chan->generatordata = NULL;
if (chan->generator)
generate = chan->generator->generate;
ast_channel_unlock(chan);
if (!tmp || !generate)
return 0;
res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50);
chan->generatordata = tmp;
if (res) {
ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
return 0;
}
| static void handle_cause | ( | int | cause, |
| int * | outstate | ||
| ) | [static] |
Definition at line 5186 of file channel.c.
References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CONTROL_BUSY, and AST_CONTROL_CONGESTION.
Referenced by __ast_request_and_dial(), and ast_call_forward().
{
if (outstate) {
/* compute error and return */
if (cause == AST_CAUSE_BUSY)
*outstate = AST_CONTROL_BUSY;
else if (cause == AST_CAUSE_CONGESTION)
*outstate = AST_CONTROL_CONGESTION;
else
*outstate = 0;
}
}
| static char* handle_cli_core_show_channeltype | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Show details about a channel driver - CLI command.
Definition at line 547 of file channel.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_getformatname_multiple(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::capabilities, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_channeltypes(), ast_channel_tech::devicestate, ast_cli_args::fd, ast_channel_tech::indicate, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.
{
struct chanlist *cl = NULL;
char buf[512];
switch (cmd) {
case CLI_INIT:
e->command = "core show channeltype";
e->usage =
"Usage: core show channeltype <name>\n"
" Show details about the specified channel type, <name>.\n";
return NULL;
case CLI_GENERATE:
return complete_channeltypes(a);
}
if (a->argc != 4)
return CLI_SHOWUSAGE;
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
if (!strncasecmp(cl->tech->type, a->argv[3], strlen(cl->tech->type)))
break;
}
if (!cl) {
ast_cli(a->fd, "\n%s is not a registered channel driver.\n", a->argv[3]);
AST_RWLIST_UNLOCK(&backends);
return CLI_FAILURE;
}
ast_cli(a->fd,
"-- Info about channel driver: %s --\n"
" Device State: %s\n"
" Indication: %s\n"
" Transfer : %s\n"
" Capabilities: %s\n"
" Digit Begin: %s\n"
" Digit End: %s\n"
" Send HTML : %s\n"
" Image Support: %s\n"
" Text Support: %s\n",
cl->tech->type,
(cl->tech->devicestate) ? "yes" : "no",
(cl->tech->indicate) ? "yes" : "no",
(cl->tech->transfer) ? "yes" : "no",
ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1),
(cl->tech->send_digit_begin) ? "yes" : "no",
(cl->tech->send_digit_end) ? "yes" : "no",
(cl->tech->send_html) ? "yes" : "no",
(cl->tech->send_image) ? "yes" : "no",
(cl->tech->send_text) ? "yes" : "no"
);
AST_RWLIST_UNLOCK(&backends);
return CLI_SUCCESS;
}
| static char* handle_cli_core_show_channeltypes | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Show channel types - CLI command.
Definition at line 481 of file channel.c.
References ast_cli_args::argc, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_channel_tech::description, ast_channel_tech::devicestate, ast_cli_args::fd, FORMAT, ast_channel_tech::indicate, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.
{
#define FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n"
struct chanlist *cl;
int count_chan = 0;
switch (cmd) {
case CLI_INIT:
e->command = "core show channeltypes";
e->usage =
"Usage: core show channeltypes\n"
" Lists available channel types registered in your\n"
" Asterisk server.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != 3)
return CLI_SHOWUSAGE;
ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Indications", "Transfer");
ast_cli(a->fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------");
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
ast_cli(a->fd, FORMAT, cl->tech->type, cl->tech->description,
(cl->tech->devicestate) ? "yes" : "no",
(cl->tech->indicate) ? "yes" : "no",
(cl->tech->transfer) ? "yes" : "no");
count_chan++;
}
AST_RWLIST_UNLOCK(&backends);
ast_cli(a->fd, "----------\n%d channel drivers registered.\n", count_chan);
return CLI_SUCCESS;
#undef FORMAT
}
| static int attribute_const is_visible_indication | ( | enum ast_control_frame_type | condition | ) | [static] |
Definition at line 4267 of file channel.c.
References _XXX_AST_CONTROL_T38, AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, and AST_CONTROL_WINK.
Referenced by ast_indicate_data().
{
/* Don't include a default case here so that we get compiler warnings
* when a new type is added. */
switch (condition) {
case AST_CONTROL_PROGRESS:
case AST_CONTROL_PROCEEDING:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
case AST_CONTROL_SRCCHANGE:
case AST_CONTROL_RADIO_KEY:
case AST_CONTROL_RADIO_UNKEY:
case AST_CONTROL_OPTION:
case AST_CONTROL_WINK:
case AST_CONTROL_FLASH:
case AST_CONTROL_OFFHOOK:
case AST_CONTROL_TAKEOFFHOOK:
case AST_CONTROL_ANSWER:
case AST_CONTROL_HANGUP:
case AST_CONTROL_CONNECTED_LINE:
case AST_CONTROL_REDIRECTING:
case AST_CONTROL_TRANSFER:
case AST_CONTROL_T38_PARAMETERS:
case _XXX_AST_CONTROL_T38:
case AST_CONTROL_CC:
case AST_CONTROL_READ_ACTION:
case AST_CONTROL_AOC:
case AST_CONTROL_END_OF_Q:
case AST_CONTROL_UPDATE_RTP_PEER:
break;
case AST_CONTROL_INCOMPLETE:
case AST_CONTROL_CONGESTION:
case AST_CONTROL_BUSY:
case AST_CONTROL_RINGING:
case AST_CONTROL_RING:
case AST_CONTROL_HOLD:
/* You can hear these */
return 1;
case AST_CONTROL_UNHOLD:
/* This is a special case. You stop hearing this. */
break;
}
return 0;
}
| static struct ast_frame* kill_exception | ( | struct ast_channel * | chan | ) | [static, read] |
| static int kill_fixup | ( | struct ast_channel * | oldchan, |
| struct ast_channel * | newchan | ||
| ) | [static] |
| static int kill_hangup | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 638 of file channel.c.
References ast_channel::tech_pvt.
{
chan->tech_pvt = NULL;
return 0;
}
| static struct ast_frame* kill_read | ( | struct ast_channel * | chan | ) | [static, read] |
| static int kill_write | ( | struct ast_channel * | chan, |
| struct ast_frame * | frame | ||
| ) | [static] |
| static void manager_bridge_event | ( | int | onoff, |
| int | type, | ||
| struct ast_channel * | c0, | ||
| struct ast_channel * | c1 | ||
| ) | [static] |
Send manager event for bridge link and unlink events.
| onoff | Link/Unlinked |
| type | 1 for core, 2 for native |
| c0 | first channel in bridge |
| c1 | second channel in bridge |
Definition at line 7168 of file channel.c.
References ast_manager_event_multichan, ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_channel::name, ast_party_id::number, S_COR, ast_party_number::str, ast_channel::uniqueid, and ast_party_number::valid.
Referenced by ast_channel_bridge().
{
struct ast_channel *chans[2] = { c0, c1 };
ast_manager_event_multichan(EVENT_FLAG_CALL, "Bridge", 2, chans,
"Bridgestate: %s\r\n"
"Bridgetype: %s\r\n"
"Channel1: %s\r\n"
"Channel2: %s\r\n"
"Uniqueid1: %s\r\n"
"Uniqueid2: %s\r\n"
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
onoff ? "Link" : "Unlink",
type == 1 ? "core" : "native",
c0->name, c1->name,
c0->uniqueid, c1->uniqueid,
S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, ""),
S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, ""));
}
| static void masquerade_colp_transfer | ( | struct ast_channel * | transferee, |
| struct xfer_masquerade_ds * | colp | ||
| ) | [static] |
Definition at line 6333 of file channel.c.
References ast_channel_queue_connected_line_update(), ast_connected_line_build_data(), AST_CONTROL_READ_ACTION, AST_CONTROL_UNHOLD, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, ast_queue_control(), ast_queue_control_data(), frame_size, ast_control_read_action_payload::payload_size, xfer_masquerade_ds::target_held, xfer_masquerade_ds::target_id, and xfer_masquerade_ds::transferee_id.
Referenced by ast_do_masquerade().
{
struct ast_control_read_action_payload *frame_payload;
int payload_size;
int frame_size;
unsigned char connected_line_data[1024];
/* Release any hold on the target. */
if (colp->target_held) {
ast_queue_control(transferee, AST_CONTROL_UNHOLD);
}
/*
* Since transferee may not actually be bridged to another channel,
* there is no way for us to queue a frame so that its connected
* line status will be updated. Instead, we use the somewhat
* hackish approach of using a special control frame type that
* instructs ast_read() to perform a specific action. In this
* case, the frame we queue tells ast_read() to call the
* connected line interception macro configured for transferee.
*/
payload_size = ast_connected_line_build_data(connected_line_data,
sizeof(connected_line_data), &colp->target_id, NULL);
if (payload_size != -1) {
frame_size = payload_size + sizeof(*frame_payload);
frame_payload = alloca(frame_size);
frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
frame_payload->payload_size = payload_size;
memcpy(frame_payload->payload, connected_line_data, payload_size);
ast_queue_control_data(transferee, AST_CONTROL_READ_ACTION, frame_payload,
frame_size);
}
/*
* In addition to queueing the read action frame so that the
* connected line info on transferee will be updated, we also are
* going to queue a plain old connected line update on transferee to
* update the target.
*/
ast_channel_queue_connected_line_update(transferee, &colp->transferee_id, NULL);
}
| static const char* oldest_linkedid | ( | const char * | a, |
| const char * | b | ||
| ) | [static] |
Definition at line 6157 of file channel.c.
References ast_strlen_zero().
Referenced by ast_channel_set_linkgroup().
{
const char *satime, *saseq;
const char *sbtime, *sbseq;
const char *dash;
unsigned int atime, aseq, btime, bseq;
if (ast_strlen_zero(a))
return b;
if (ast_strlen_zero(b))
return a;
satime = a;
sbtime = b;
/* jump over the system name */
if ((dash = strrchr(satime, '-'))) {
satime = dash+1;
}
if ((dash = strrchr(sbtime, '-'))) {
sbtime = dash+1;
}
/* the sequence comes after the '.' */
saseq = strchr(satime, '.');
sbseq = strchr(sbtime, '.');
if (!saseq || !sbseq)
return NULL;
saseq++;
sbseq++;
/* convert it all to integers */
atime = atoi(satime); /* note that atoi is ignoring the '.' after the time string */
btime = atoi(sbtime); /* note that atoi is ignoring the '.' after the time string */
aseq = atoi(saseq);
bseq = atoi(sbseq);
/* and finally compare */
if (atime == btime) {
return (aseq < bseq) ? a : b;
}
else {
return (atime < btime) ? a : b;
}
}
| static void party_connected_line_copy_transfer | ( | struct ast_party_connected_line * | dest, |
| const struct ast_party_connected_line * | src | ||
| ) | [static] |
Definition at line 5964 of file channel.c.
References AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, ast_party_connected_line_copy(), and ast_party_connected_line::source.
Referenced by ast_channel_transfer_masquerade().
{
struct ast_party_connected_line connected;
connected = *((struct ast_party_connected_line *) src);
connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
/* Make sure empty strings will be erased. */
if (!connected.id.name.str) {
connected.id.name.str = "";
}
if (!connected.id.number.str) {
connected.id.number.str = "";
}
if (!connected.id.subaddress.str) {
connected.id.subaddress.str = "";
}
if (!connected.id.tag) {
connected.id.tag = "";
}
ast_party_connected_line_copy(dest, &connected);
}
| static int party_id_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_id * | id, | ||
| const char * | label, | ||
| const struct ast_party_id_ies * | ies, | ||
| const struct ast_set_party_id * | update | ||
| ) | [static] |
Definition at line 8416 of file channel.c.
References ast_log(), ast_party_id_presentation(), ast_party_id_ies::combined_presentation, LOG_WARNING, ast_party_id::name, ast_set_party_id::name, ast_party_id_ies::name, ast_party_id::number, ast_set_party_id::number, ast_party_id_ies::number, party_name_build_data(), party_number_build_data(), party_subaddress_build_data(), ast_party_id::subaddress, ast_set_party_id::subaddress, ast_party_id_ies::subaddress, ast_party_id::tag, and ast_party_id_ies::tag.
Referenced by ast_connected_line_build_data(), and ast_redirecting_build_data().
{
size_t length;
size_t pos = 0;
int res;
/*
* The size of integer values must be fixed in case the frame is
* shipped to another machine.
*/
if (!update || update->name) {
res = party_name_build_data(data + pos, datalen - pos, &id->name, label,
&ies->name);
if (res < 0) {
return -1;
}
pos += res;
}
if (!update || update->number) {
res = party_number_build_data(data + pos, datalen - pos, &id->number, label,
&ies->number);
if (res < 0) {
return -1;
}
pos += res;
}
if (!update || update->subaddress) {
res = party_subaddress_build_data(data + pos, datalen - pos, &id->subaddress,
label, &ies->subaddress);
if (res < 0) {
return -1;
}
pos += res;
}
/* *************** Party id user tag **************************** */
if (id->tag) {
length = strlen(id->tag);
if (datalen < pos + (sizeof(data[0]) * 2) + length) {
ast_log(LOG_WARNING, "No space left for %s tag\n", label);
return -1;
}
data[pos++] = ies->tag;
data[pos++] = length;
memcpy(data + pos, id->tag, length);
pos += length;
}
/* *************** Party id combined presentation *************** */
if (!update || update->number) {
int presentation;
if (!update || update->name) {
presentation = ast_party_id_presentation(id);
} else {
/*
* We must compromise because not all the information is available
* to determine a combined presentation value.
* We will only send the number presentation instead.
*/
presentation = id->number.presentation;
}
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s combined presentation\n", label);
return -1;
}
data[pos++] = ies->combined_presentation;
data[pos++] = 1;
data[pos++] = presentation;
}
return pos;
}
| static int party_name_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_name * | name, | ||
| const char * | label, | ||
| const struct ast_party_name_ies * | ies | ||
| ) | [static] |
Definition at line 8190 of file channel.c.
References ast_log(), ast_party_name::char_set, ast_party_name_ies::char_set, LOG_WARNING, ast_party_name::presentation, ast_party_name_ies::presentation, ast_party_name::str, ast_party_name_ies::str, ast_party_name::valid, and ast_party_name_ies::valid.
Referenced by party_id_build_data().
{
size_t length;
size_t pos = 0;
/*
* The size of integer values must be fixed in case the frame is
* shipped to another machine.
*/
if (name->str) {
length = strlen(name->str);
if (datalen < pos + (sizeof(data[0]) * 2) + length) {
ast_log(LOG_WARNING, "No space left for %s name\n", label);
return -1;
}
data[pos++] = ies->str;
data[pos++] = length;
memcpy(data + pos, name->str, length);
pos += length;
}
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s name char set\n", label);
return -1;
}
data[pos++] = ies->char_set;
data[pos++] = 1;
data[pos++] = name->char_set;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s name presentation\n", label);
return -1;
}
data[pos++] = ies->presentation;
data[pos++] = 1;
data[pos++] = name->presentation;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s name valid\n", label);
return -1;
}
data[pos++] = ies->valid;
data[pos++] = 1;
data[pos++] = name->valid;
return pos;
}
| static int party_number_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_number * | number, | ||
| const char * | label, | ||
| const struct ast_party_number_ies * | ies | ||
| ) | [static] |
Definition at line 8264 of file channel.c.
References ast_log(), LOG_WARNING, ast_party_number::plan, ast_party_number_ies::plan, ast_party_number::presentation, ast_party_number_ies::presentation, ast_party_number::str, ast_party_number_ies::str, ast_party_number::valid, and ast_party_number_ies::valid.
Referenced by party_id_build_data().
{
size_t length;
size_t pos = 0;
/*
* The size of integer values must be fixed in case the frame is
* shipped to another machine.
*/
if (number->str) {
length = strlen(number->str);
if (datalen < pos + (sizeof(data[0]) * 2) + length) {
ast_log(LOG_WARNING, "No space left for %s number\n", label);
return -1;
}
data[pos++] = ies->str;
data[pos++] = length;
memcpy(data + pos, number->str, length);
pos += length;
}
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s numbering plan\n", label);
return -1;
}
data[pos++] = ies->plan;
data[pos++] = 1;
data[pos++] = number->plan;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s number presentation\n", label);
return -1;
}
data[pos++] = ies->presentation;
data[pos++] = 1;
data[pos++] = number->presentation;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s number valid\n", label);
return -1;
}
data[pos++] = ies->valid;
data[pos++] = 1;
data[pos++] = number->valid;
return pos;
}
| static int party_subaddress_build_data | ( | unsigned char * | data, |
| size_t | datalen, | ||
| const struct ast_party_subaddress * | subaddress, | ||
| const char * | label, | ||
| const struct ast_party_subaddress_ies * | ies | ||
| ) | [static] |
Definition at line 8338 of file channel.c.
References ast_log(), LOG_WARNING, ast_party_subaddress::odd_even_indicator, ast_party_subaddress_ies::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress_ies::str, ast_party_subaddress::type, ast_party_subaddress_ies::type, ast_party_subaddress::valid, and ast_party_subaddress_ies::valid.
Referenced by party_id_build_data().
{
size_t length;
size_t pos = 0;
/*
* The size of integer values must be fixed in case the frame is
* shipped to another machine.
*/
if (subaddress->str) {
length = strlen(subaddress->str);
if (datalen < pos + (sizeof(data[0]) * 2) + length) {
ast_log(LOG_WARNING, "No space left for %s subaddress\n", label);
return -1;
}
data[pos++] = ies->str;
data[pos++] = length;
memcpy(data + pos, subaddress->str, length);
pos += length;
}
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s type of subaddress\n", label);
return -1;
}
data[pos++] = ies->type;
data[pos++] = 1;
data[pos++] = subaddress->type;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING,
"No space left for %s subaddress odd-even indicator\n", label);
return -1;
}
data[pos++] = ies->odd_even_indicator;
data[pos++] = 1;
data[pos++] = subaddress->odd_even_indicator;
if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
ast_log(LOG_WARNING, "No space left for %s subaddress valid\n", label);
return -1;
}
data[pos++] = ies->valid;
data[pos++] = 1;
data[pos++] = subaddress->valid;
return pos;
}
| static void plc_ds_destroy | ( | void * | data | ) | [static] |
Definition at line 4676 of file channel.c.
References ast_free, and plc_ds::samples_buf.
{
struct plc_ds *plc = data;
ast_free(plc->samples_buf);
ast_free(plc);
}
| static void queue_dtmf_readq | ( | struct ast_channel * | chan, |
| struct ast_frame * | f | ||
| ) | [inline, static] |
Definition at line 3657 of file channel.c.
References AST_FRAME_DTMF_END, ast_queue_frame(), ast_channel::dtmff, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, and ast_frame::subclass.
Referenced by __ast_read().
{
struct ast_frame *fr = &chan->dtmff;
fr->frametype = AST_FRAME_DTMF_END;
fr->subclass.integer = f->subclass.integer;
fr->len = f->len;
/* The only time this function will be called is for a frame that just came
* out of the channel driver. So, we want to stick it on the tail of the
* readq. */
ast_queue_frame(chan, fr);
}
| static void report_new_callerid | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 6303 of file channel.c.
References ast_describe_caller_presentation(), ast_manager_event, ast_party_id_presentation(), ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.
Referenced by ast_channel_set_caller_event(), ast_do_masquerade(), and ast_set_callerid().
{
int pres;
pres = ast_party_id_presentation(&chan->caller.id);
ast_manager_event(chan, EVENT_FLAG_CALL, "NewCallerid",
"Channel: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"Uniqueid: %s\r\n"
"CID-CallingPres: %d (%s)\r\n",
chan->name,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
chan->uniqueid,
pres,
ast_describe_caller_presentation(pres)
);
}
| static void send_dtmf_event | ( | struct ast_channel * | chan, |
| const char * | direction, | ||
| const char | digit, | ||
| const char * | begin, | ||
| const char * | end | ||
| ) | [static] |
Definition at line 3596 of file channel.c.
References ast_manager_event, EVENT_FLAG_DTMF, ast_channel::name, and ast_channel::uniqueid.
Referenced by __ast_read(), and ast_write().
{
ast_manager_event(chan, EVENT_FLAG_DTMF,
"DTMF",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"Digit: %c\r\n"
"Direction: %s\r\n"
"Begin: %s\r\n"
"End: %s\r\n",
chan->name, chan->uniqueid, digit, direction, begin, end);
}
| static int set_format | ( | struct ast_channel * | chan, |
| format_t | fmt, | ||
| format_t * | rawformat, | ||
| format_t * | format, | ||
| struct ast_trans_pvt ** | trans, | ||
| const int | direction | ||
| ) | [static] |
Definition at line 5068 of file channel.c.
References ast_best_codec(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, ast_debug, AST_FORMAT_AUDIO_MASK, ast_getformatname(), ast_getformatname_multiple(), ast_log(), AST_OPTION_FORMAT_READ, AST_OPTION_FORMAT_WRITE, ast_translator_best_choice(), ast_translator_build_path(), ast_translator_free_path(), LOG_WARNING, ast_channel::name, and ast_channel::nativeformats.
Referenced by ast_set_read_format(), and ast_set_write_format().
{
format_t native, native_fmt = ast_best_codec(fmt);
int res;
char from[200], to[200];
/* Make sure we only consider audio */
fmt &= AST_FORMAT_AUDIO_MASK;
native = chan->nativeformats;
if (!fmt || !native) /* No audio requested */
return 0; /* Let's try a call without any sounds (video, text) */
/* See if the underlying channel driver is capable of performing transcoding for us */
if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) {
ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name,
direction ? "write" : "read", ast_getformatname(native_fmt));
chan->nativeformats = *rawformat = *format = native_fmt;
if (*trans) {
ast_translator_free_path(*trans);
}
*trans = NULL;
return 0;
}
/* Find a translation path from the native format to one of the desired formats */
if (!direction)
/* reading */
res = ast_translator_best_choice(&fmt, &native);
else
/* writing */
res = ast_translator_best_choice(&native, &fmt);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n",
ast_getformatname_multiple(from, sizeof(from), native),
ast_getformatname_multiple(to, sizeof(to), fmt));
return -1;
}
/* Now we have a good choice for both. */
ast_channel_lock(chan);
if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format) || (*trans))) {
/* the channel is already in these formats, so nothing to do */
ast_channel_unlock(chan);
return 0;
}
*rawformat = native;
/* User perspective is fmt */
*format = fmt;
/* Free any read translation we have right now */
if (*trans) {
ast_translator_free_path(*trans);
*trans = NULL;
}
/* Build a translation path from the raw format to the desired format */
if (*format == *rawformat) {
/*
* If we were able to swap the native format to the format that
* has been requested, then there is no need to try to build
* a translation path.
*/
res = 0;
} else {
if (!direction) {
/* reading */
*trans = ast_translator_build_path(*format, *rawformat);
} else {
/* writing */
*trans = ast_translator_build_path(*rawformat, *format);
}
res = *trans ? 0 : -1;
}
ast_channel_unlock(chan);
ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
direction ? "write" : "read", ast_getformatname(fmt));
return res;
}
| static int set_security_requirements | ( | const struct ast_channel * | requestor, |
| struct ast_channel * | out | ||
| ) | [static] |
Definition at line 5494 of file channel.c.
References ast_channel_datastore_find(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, AST_OPTION_SECURE_MEDIA, AST_OPTION_SECURE_SIGNALING, ast_datastore::data, ast_secure_call_store::media, secure_call_info, and ast_secure_call_store::signaling.
Referenced by ast_request().
{
int ops[2][2] = {
{AST_OPTION_SECURE_SIGNALING, 0},
{AST_OPTION_SECURE_MEDIA, 0},
};
int i;
struct ast_channel *r = (struct ast_channel *) requestor; /* UGLY */
struct ast_datastore *ds;
if (!requestor || !out) {
return 0;
}
ast_channel_lock(r);
if ((ds = ast_channel_datastore_find(r, &secure_call_info, NULL))) {
struct ast_secure_call_store *encrypt = ds->data;
ops[0][1] = encrypt->signaling;
ops[1][1] = encrypt->media;
} else {
ast_channel_unlock(r);
return 0;
}
ast_channel_unlock(r);
for (i = 0; i < 2; i++) {
if (ops[i][1]) {
if (ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0)) {
/* We require a security feature, but the channel won't provide it */
return -1;
}
} else {
/* We don't care if we can't clear the option on a channel that doesn't support it */
ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0);
}
}
return 0;
}
| static int should_skip_dtmf | ( | struct ast_channel * | chan | ) | [inline, static] |
Determine whether or not we should ignore DTMF in the readq.
Definition at line 3675 of file channel.c.
References AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_MIN_DTMF_GAP, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::dtmf_tv.
Referenced by __ast_read().
{
if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) {
/* We're in the middle of emulating a digit, or DTMF has been
* explicitly deferred. Skip this digit, then. */
return 1;
}
if (!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
/* We're not in the middle of a digit, but it hasn't been long enough
* since the last digit, so we'll have to skip DTMF for now. */
return 1;
}
return 0;
}
| static void* silence_generator_alloc | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
| static int silence_generator_generate | ( | struct ast_channel * | chan, |
| void * | data, | ||
| int | len, | ||
| int | samples | ||
| ) | [static] |
Definition at line 7997 of file channel.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_write(), ast_frame::frametype, and ast_frame::samples.
{
short buf[samples];
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
.subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf,
.samples = samples,
.datalen = sizeof(buf),
};
memset(buf, 0, sizeof(buf));
if (ast_write(chan, &frame))
return -1;
return 0;
}
| static void silence_generator_release | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
| static void* tonepair_alloc | ( | struct ast_channel * | chan, |
| void * | params | ||
| ) | [static] |
Definition at line 7598 of file channel.c.
References ast_calloc, AST_FLAG_WRITE_INT, AST_FORMAT_SLINEAR, ast_log(), ast_set_flag, ast_set_write_format(), cos, tonepair_def::duration, tonepair_state::duration, tonepair_state::fac1, tonepair_state::fac2, tonepair_def::freq1, tonepair_def::freq2, LOG_WARNING, M_PI, tonepair_state::modulate, ast_channel::name, tonepair_state::origwfmt, tonepair_release(), tonepair_state::v1_1, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, tonepair_state::v3_2, tonepair_def::vol, and ast_channel::writeformat.
{
struct tonepair_state *ts;
struct tonepair_def *td = params;
if (!(ts = ast_calloc(1, sizeof(*ts))))
return NULL;
ts->origwfmt = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
tonepair_release(NULL, ts);
ts = NULL;
} else {
ts->fac1 = 2.0 * cos(2.0 * M_PI * (td->freq1 / 8000.0)) * 32768.0;
ts->v1_1 = 0;
ts->v2_1 = sin(-4.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
ts->v3_1 = sin(-2.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
ts->v2_1 = 0;
ts->fac2 = 2.0 * cos(2.0 * M_PI * (td->freq2 / 8000.0)) * 32768.0;
ts->v2_2 = sin(-4.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
ts->v3_2 = sin(-2.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
ts->duration = td->duration;
ts->modulate = 0;
}
/* Let interrupts interrupt :) */
ast_set_flag(chan, AST_FLAG_WRITE_INT);
return ts;
}
| static int tonepair_generator | ( | struct ast_channel * | chan, |
| void * | data, | ||
| int | len, | ||
| int | samples | ||
| ) | [static] |
Definition at line 7627 of file channel.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_write(), ast_frame_subclass::codec, ast_frame::data, tonepair_state::data, ast_frame::datalen, tonepair_state::duration, tonepair_state::f, tonepair_state::fac1, tonepair_state::fac2, ast_frame::frametype, len(), LOG_WARNING, tonepair_state::modulate, ast_frame::offset, tonepair_state::pos, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, tonepair_state::v1_1, tonepair_state::v1_2, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, and tonepair_state::v3_2.
{
struct tonepair_state *ts = data;
int x;
/* we need to prepare a frame with 16 * timelen samples as we're
* generating SLIN audio
*/
len = samples * 2;
if (len > sizeof(ts->data) / 2 - 1) {
ast_log(LOG_WARNING, "Can't generate that much data!\n");
return -1;
}
memset(&ts->f, 0, sizeof(ts->f));
for (x=0;x<len/2;x++) {
ts->v1_1 = ts->v2_1;
ts->v2_1 = ts->v3_1;
ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
ts->v1_2 = ts->v2_2;
ts->v2_2 = ts->v3_2;
ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
if (ts->modulate) {
int p;
p = ts->v3_2 - 32768;
if (p < 0) p = -p;
p = ((p * 9) / 10) + 1;
ts->data[x] = (ts->v3_1 * p) >> 15;
} else
ts->data[x] = ts->v3_1 + ts->v3_2;
}
ts->f.frametype = AST_FRAME_VOICE;
ts->f.subclass.codec = AST_FORMAT_SLINEAR;
ts->f.datalen = len;
ts->f.samples = samples;
ts->f.offset = AST_FRIENDLY_OFFSET;
ts->f.data.ptr = ts->data;
ast_write(chan, &ts->f);
ts->pos += x;
if (ts->duration > 0) {
if (ts->pos >= ts->duration * 8)
return -1;
}
return 0;
}
| static void tonepair_release | ( | struct ast_channel * | chan, |
| void * | params | ||
| ) | [static] |
Definition at line 7589 of file channel.c.
References ast_free, ast_set_write_format(), and tonepair_state::origwfmt.
Referenced by tonepair_alloc().
{
struct tonepair_state *ts = params;
if (chan)
ast_set_write_format(chan, ts->origwfmt);
ast_free(ts);
}
| static void update_bridge_vars | ( | struct ast_channel * | c0, |
| struct ast_channel * | c1 | ||
| ) | [static] |
Definition at line 7188 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strdupa, ast_strlen_zero(), ast_channel_tech::get_pvt_uniqueid, ast_channel::name, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and ast_channel::tech.
Referenced by ast_channel_bridge().
{
const char *c0_name;
const char *c1_name;
const char *c0_pvtid = NULL;
const char *c1_pvtid = NULL;
ast_channel_lock(c1);
c1_name = ast_strdupa(c1->name);
if (c1->tech->get_pvt_uniqueid) {
c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1));
}
ast_channel_unlock(c1);
ast_channel_lock(c0);
if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) {
pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1_name);
}
if (c1_pvtid) {
pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid);
}
c0_name = ast_strdupa(c0->name);
if (c0->tech->get_pvt_uniqueid) {
c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0));
}
ast_channel_unlock(c0);
ast_channel_lock(c1);
if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) {
pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0_name);
}
if (c0_pvtid) {
pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0_pvtid);
}
ast_channel_unlock(c1);
}
| static void xfer_ds_destroy | ( | void * | data | ) | [static] |
Definition at line 6009 of file channel.c.
References ast_free, ast_party_connected_line_free(), xfer_masquerade_ds::target_id, and xfer_masquerade_ds::transferee_id.
{
struct xfer_masquerade_ds *ds = data;
ast_party_connected_line_free(&ds->target_id);
ast_party_connected_line_free(&ds->transferee_id);
ast_free(ds);
}
| struct ast_channel_tech ast_kill_tech |
Kill the channel channel driver technology descriptor.
The purpose of this channel technology is to encourage the channel to hangup as quickly as possible.
Definition at line 653 of file channel.c.
Referenced by ast_do_masquerade().
void(* ast_moh_cleanup_ptr)(struct ast_channel *) = NULL [static] |
Definition at line 7750 of file channel.c.
Referenced by ast_install_music_functions(), ast_moh_cleanup(), and ast_uninstall_music_functions().
int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *) = NULL [static] |
Definition at line 7748 of file channel.c.
Referenced by ast_install_music_functions(), ast_moh_start(), and ast_uninstall_music_functions().
void(* ast_moh_stop_ptr)(struct ast_channel *) = NULL [static] |
Definition at line 7749 of file channel.c.
Referenced by ast_install_music_functions(), ast_moh_stop(), and ast_uninstall_music_functions().
| int cause |
Definition at line 197 of file channel.c.
Referenced by __ast_read(), __ast_request_and_dial(), action_hangup(), ast_call_forward(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), ast_str2cause(), asterisk2osp(), cb_events(), dial_exec_full(), dial_transfer(), do_forward(), dump_cause(), dundi_ie_append_cause(), enc_ie_cause(), feature_request_and_dial(), hangup_connection(), oh323_hangup(), ospfinished_exec(), ospnext_exec(), parse_disconnect(), parse_release(), parse_release_complete(), parse_status(), pbx_builtin_hangup(), play_sound_file(), sig_pri_hangup(), sig_pri_kill_call(), sig_ss7_hangup(), sms_messagerx(), and sms_messagerx2().
struct { ... } causes[] [static] |
map AST_CAUSE's to readable string representations
Referenced by ast_cause2str(), ast_str2cause(), and dump_cause().
struct ast_datastore_info cc_channel_datastore_info [static] |
{
.type = "Call Completion",
.duplicate = channel_cc_params_copy,
.destroy = channel_cc_params_destroy,
}
struct ast_data_entry channel_providers[] [static] |
{
AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),
AST_DATA_ENTRY("/asterisk/core/channeltypes", &channeltypes_provider),
}
struct ao2_container* channels [static] |
All active channels on the system.
Definition at line 190 of file channel.c.
Referenced by __ast_channel_alloc_ap(), ast_active_channels(), ast_begin_shutdown(), ast_change_name(), ast_channel_callback(), ast_channel_get_full(), ast_channel_iterator_all_new(), ast_channel_release(), ast_channels_init(), ast_do_masquerade(), ast_hangup(), and channel_iterator_search().
struct ast_data_handler channels_provider [static] |
{
.version = AST_DATA_HANDLER_VERSION,
.get = data_channels_provider_handler
}
struct ast_data_handler channeltypes_provider [static] |
{
.version = AST_DATA_HANDLER_VERSION,
.get = data_channeltypes_provider_handler
}
struct ast_cli_entry cli_channel[] [static] |
{
AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
AST_CLI_DEFINE(handle_cli_core_show_channeltype, "Give more details on that channel type")
}
Definition at line 609 of file channel.c.
Referenced by ast_channels_init().
| const char* desc |
Definition at line 199 of file channel.c.
Referenced by acf_retrieve_docs(), ast_data_add_codecs(), ast_tcptls_client_create(), ast_tcptls_client_start(), ast_tcptls_server_root(), dump_cause(), handle_cli_ulimit(), init_acf_query(), load_rpt_vars(), misdn_cfg_get_desc(), show_config_description(), and str2desc().
| unsigned long global_fin |
The current value of the debug flags is stored in the two variables global_fin and global_fout (declared in main/channel.c)
Definition at line 97 of file channel.c.
Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().
| unsigned long global_fout |
Definition at line 97 of file channel.c.
Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().
struct ast_channel_tech null_tech [static] |
{
.type = "NULL",
.description = "Null channel (should not see this)",
}
Definition at line 1099 of file channel.c.
Referenced by __ast_channel_alloc_ap().
struct ast_datastore_info plc_ds_info [static] |
{
.type = "plc",
.destroy = plc_ds_destroy,
}
int shutting_down [static] |
Prevent new channel allocation if shutting down.
Definition at line 93 of file channel.c.
Referenced by ast_shutting_down().
struct ast_generator silence_generator [static] |
{
.alloc = silence_generator_alloc,
.release = silence_generator_release,
.generate = silence_generator_generate,
}
struct ast_threadstorage state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , } [static] |
Definition at line 99 of file channel.c.
Referenced by ast_state2str().
struct ast_generator tonepair [static] |
{
alloc: tonepair_alloc,
release: tonepair_release,
generate: tonepair_generator,
}
struct ast_datastore_info xfer_ds_info [static] |
{
.type = "xfer_colp",
.destroy = xfer_ds_destroy,
}