#include "asterisk/abstract_jb.h"
#include "asterisk/astobj2.h"
#include "asterisk/poll-compat.h"
#include "asterisk/frame.h"
#include "asterisk/sched.h"
#include "asterisk/chanvars.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/cdr.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/datastore.h"
#include "asterisk/data.h"
#include "asterisk/channelstate.h"
#include "asterisk/ccss.h"
#include "asterisk/framehook.h"
Go to the source code of this file.
Data Structures | |
struct | ast_bridge_config |
bridge configuration More... | |
struct | ast_chan_write_info_t |
Structure to handle passing func_channel_write info to channels via setoption. More... | |
struct | ast_channel |
Main Channel structure associated with a channel. More... | |
struct | ast_channel::autochans |
struct | ast_channel::datastores |
struct | ast_channel_tech |
Structure to describe a channel "technology", ie a channel driver See for examples:. More... | |
struct | ast_generator |
struct | ast_group_info |
channel group info More... | |
struct | ast_party_caller |
Caller Party information. More... | |
struct | ast_party_connected_line |
Connected Line/Party information. More... | |
struct | ast_party_dialed |
Dialed/Called Party information. More... | |
struct | ast_party_id |
Information needed to identify an endpoint in a call. More... | |
struct | ast_party_name |
Information needed to specify a name in a call. More... | |
struct | ast_party_number |
Information needed to specify a number in a call. More... | |
struct | ast_party_redirecting |
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call diversion or transfer was invoked. More... | |
struct | ast_party_subaddress |
Information needed to specify a subaddress in a call. More... | |
struct | ast_set_party_caller |
Indicate what information in ast_party_caller should be set. More... | |
struct | ast_set_party_connected_line |
Indicate what information in ast_party_connected_line should be set. More... | |
struct | ast_set_party_id |
Indicate what information in ast_party_id should be set. More... | |
struct | ast_set_party_redirecting |
Indicate what information in ast_party_redirecting should be set. More... | |
struct | outgoing_helper |
ast_channel * | ast_channel_get_by_exten (const char *exten, const char *context) |
Find a channel by extension and context. | |
ast_channel * | ast_channel_get_by_name (const char *name) |
Find a channel by name. | |
ast_channel * | ast_channel_get_by_name_prefix (const char *name, size_t name_len) |
Find a channel by a name prefix. | |
ast_channel_iterator * | ast_channel_iterator_all_new (void) |
Create a new channel iterator. | |
ast_channel_iterator * | ast_channel_iterator_by_exten_new (const char *exten, const char *context) |
Create a new channel iterator based on extension. | |
ast_channel_iterator * | ast_channel_iterator_by_name_new (const char *name, size_t name_len) |
Create a new channel iterator based on name. | |
ast_channel_iterator * | ast_channel_iterator_destroy (struct ast_channel_iterator *i) |
Destroy a channel iterator. | |
ast_channel * | ast_channel_iterator_next (struct ast_channel_iterator *i) |
Get the next channel for a channel iterator. | |
Defines | |
#define | AST_AGENT_FD (AST_MAX_FDS-3) |
#define | AST_ALERT_FD (AST_MAX_FDS-1) |
#define | AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) |
Report DTMF on channel 0. | |
#define | AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) |
Report DTMF on channel 1. | |
#define | AST_BRIDGE_IGNORE_SIGS (1 << 4) |
Ignore all signal frames except NULL. | |
#define | AST_BRIDGE_REC_CHANNEL_0 (1 << 2) |
Return all voice frames on channel 0. | |
#define | AST_BRIDGE_REC_CHANNEL_1 (1 << 3) |
Return all voice frames on channel 1. | |
#define | AST_CHAN_WRITE_INFO_T_VERSION 1 |
ast_chan_write_info_t version. Must be incremented if structure is changed | |
#define | ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag,) |
#define | ast_channel_lock(chan) ao2_lock(chan) |
#define | ast_channel_lock_both(chan1, chan2) |
Lock two channels. | |
#define | AST_CHANNEL_NAME 80 |
#define | ast_channel_ref(c) ({ ao2_ref(c, +1); (c); }) |
Increase channel reference count. | |
#define | ast_channel_trylock(chan) ao2_trylock(chan) |
#define | ast_channel_unlock(chan) ao2_unlock(chan) |
#define | ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); }) |
Decrease channel reference count. | |
#define | AST_GENERATOR_FD (AST_MAX_FDS-4) |
#define | AST_MAX_CONTEXT 80 |
#define | AST_MAX_EXTENSION 80 |
#define | AST_MAX_FDS 10 |
#define | AST_TIMING_FD (AST_MAX_FDS-2) |
#define | CHECK_BLOCKING(c) |
#define | DATASTORE_INHERIT_FOREVER INT_MAX |
#define | DEBUGCHAN_FLAG 0x80000000 |
#define | FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) |
#define | MAX_LANGUAGE 40 |
#define | MAX_MUSICCLASS 80 |
Typedefs | |
typedef int(*) | ast_acf_read2_fn_t (struct ast_channel *, const char *, char *, struct ast_str **, ssize_t) |
Typedef for a custom read2 function. | |
typedef int(*) | ast_acf_read_fn_t (struct ast_channel *, const char *, char *, char *, size_t) |
Typedef for a custom read function. | |
typedef int(*) | ast_acf_write_fn_t (struct ast_channel *, const char *, char *, const char *) |
Typedef for a custom write function. | |
typedef unsigned long long | ast_group_t |
Enumerations | |
enum | { AST_CHAN_TP_WANTSJITTER = (1 << 0), AST_CHAN_TP_CREATESJITTER = (1 << 1) } |
ast_channel_tech Properties More... | |
enum | { AST_FLAG_DEFER_DTMF = (1 << 1), AST_FLAG_WRITE_INT = (1 << 2), AST_FLAG_BLOCKING = (1 << 3), AST_FLAG_ZOMBIE = (1 << 4), AST_FLAG_EXCEPTION = (1 << 5), AST_FLAG_MOH = (1 << 6), AST_FLAG_SPYING = (1 << 7), AST_FLAG_NBRIDGE = (1 << 8), AST_FLAG_IN_AUTOLOOP = (1 << 9), AST_FLAG_OUTGOING = (1 << 10), AST_FLAG_IN_DTMF = (1 << 12), AST_FLAG_EMULATE_DTMF = (1 << 13), AST_FLAG_END_DTMF_ONLY = (1 << 14), AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), AST_FLAG_MASQ_NOSTREAM = (1 << 16), AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18), AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20) } |
ast_channel flags More... | |
enum | { AST_FEATURE_PLAY_WARNING = (1 << 0), AST_FEATURE_REDIRECT = (1 << 1), AST_FEATURE_DISCONNECT = (1 << 2), AST_FEATURE_ATXFER = (1 << 3), AST_FEATURE_AUTOMON = (1 << 4), AST_FEATURE_PARKCALL = (1 << 5), AST_FEATURE_AUTOMIXMON = (1 << 6), AST_FEATURE_NO_H_EXTEN = (1 << 7), AST_FEATURE_WARNING_ACTIVE = (1 << 8) } |
ast_bridge_config flags More... | |
enum | { AST_SOFTHANGUP_DEV = (1 << 0), AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), AST_SOFTHANGUP_SHUTDOWN = (1 << 2), AST_SOFTHANGUP_TIMEOUT = (1 << 3), AST_SOFTHANGUP_APPUNLOAD = (1 << 4), AST_SOFTHANGUP_EXPLICIT = (1 << 5), AST_SOFTHANGUP_UNBRIDGE = (1 << 6), AST_SOFTHANGUP_ALL = (0xFFFFFFFF) } |
enum | ast_bridge_result { AST_BRIDGE_COMPLETE = 0, AST_BRIDGE_FAILED = -1, AST_BRIDGE_FAILED_NOWARN = -2, AST_BRIDGE_RETRY = -3 } |
enum | ast_channel_adsicpe { AST_ADSI_UNKNOWN, AST_ADSI_AVAILABLE, AST_ADSI_UNAVAILABLE, AST_ADSI_OFFHOOKONLY } |
enum | AST_PARTY_CHAR_SET { AST_PARTY_CHAR_SET_UNKNOWN = 0, AST_PARTY_CHAR_SET_ISO8859_1 = 1, AST_PARTY_CHAR_SET_WITHDRAWN = 2, AST_PARTY_CHAR_SET_ISO8859_2 = 3, AST_PARTY_CHAR_SET_ISO8859_3 = 4, AST_PARTY_CHAR_SET_ISO8859_4 = 5, AST_PARTY_CHAR_SET_ISO8859_5 = 6, AST_PARTY_CHAR_SET_ISO8859_7 = 7, AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8, AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9 } |
enum | ast_t38_state { T38_STATE_UNAVAILABLE, T38_STATE_UNKNOWN, T38_STATE_NEGOTIATING, T38_STATE_REJECTED, T38_STATE_NEGOTIATED } |
Possible T38 states on channels. More... | |
enum | channelreloadreason { CHANNEL_MODULE_LOAD, CHANNEL_MODULE_RELOAD, CHANNEL_CLI_RELOAD, CHANNEL_MANAGER_RELOAD } |
Channel reload reasons for manager events at load or reload of configuration. More... | |
Functions | |
int | __ast_answer (struct ast_channel *chan, unsigned int delay, int cdr_answer) |
Answer a channel, with a selectable delay before returning. | |
ast_channel *attribute_malloc | __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. | |
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) |
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_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params) |
int | ast_active_channels (void) |
returns number of active/allocated channels | |
static int | ast_add_fd (struct pollfd *pfd, int fd) |
if fd is a valid descriptor, set *pfd with the descriptor | |
int | ast_answer (struct ast_channel *chan) |
Answer a channel. | |
int | ast_autoservice_ignore (struct ast_channel *chan, enum ast_frame_type ftype) |
Ignore certain frame types. | |
int | ast_autoservice_start (struct ast_channel *chan) |
Automatically service a channel for us... | |
int | ast_autoservice_stop (struct ast_channel *chan) |
Stop servicing a channel for us... | |
void | ast_begin_shutdown (int hangup) |
format_t | ast_best_codec (format_t fmts) |
Pick the best audio codec. | |
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. | |
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 state) attribute_pure |
Gives the string form of a given cause code. | |
void | ast_change_name (struct ast_channel *chan, const char *newname) |
Change channel name. | |
int | 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. | |
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. | |
void | ast_channel_clear_softhangup (struct ast_channel *chan, int flag) |
Clear a set of softhangup flags from a channel. | |
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 the settings of when to hang a channel up. | |
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. | |
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. | |
ast_datastore *attribute_malloc | ast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid) |
Create a channel data store object. | |
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) |
Defers DTMF so that you only read things like hangups and audio. | |
int | ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1) |
Bridge two channels together (early). | |
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. | |
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 enum ast_t38_state | ast_channel_get_t38_state (struct ast_channel *chan) |
Retrieves the current T38 state of a channel. | |
void | ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child) |
Inherits channel variable from parent to child channel. | |
int | ast_channel_make_compatible (struct ast_channel *c0, struct ast_channel *c1) |
Makes two channel formats compatible. | |
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 *channel, 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 channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports. | |
ast_channel * | ast_channel_release (struct ast_channel *chan) |
Unlink and release reference to a channel. | |
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. | |
int | ast_channel_sendurl (struct ast_channel *channel, 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 linked id between chan and peer | |
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 *channel, 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 hang a channel up. | |
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 *channel) |
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 a channel technology. | |
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. | |
ast_variable * | ast_channeltype_list (void) |
return an ast_variable list of channeltypes | |
int | ast_check_hangup (struct ast_channel *chan) |
Check 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. | |
void | ast_deactivate_generator (struct ast_channel *chan) |
int | ast_do_masquerade (struct ast_channel *chan) |
Start masquerading a channel. | |
ast_channel * | ast_dummy_channel_alloc (void) |
Create a fake channel structure. | |
static int | ast_fdisset (struct pollfd *pfds, int fd, int maximum, int *start) |
Helper function for migrating select to poll. | |
ast_channel_tech * | ast_get_channel_tech (const char *name) |
Get a channel technology structure by name. | |
ast_group_t | ast_get_group (const char *s) |
int | ast_hangup (struct ast_channel *chan) |
Hang up 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. | |
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_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. | |
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- and pickup groups into buffer | |
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 with payload. | |
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 *f) |
Queue one or more frames to a channel's frame queue. | |
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. | |
int | ast_queue_hangup (struct ast_channel *chan) |
Queue a hangup frame. | |
int | ast_queue_hangup_with_cause (struct ast_channel *chan, int cause) |
Queue a hangup frame with hangupcause set. | |
int | ast_raw_answer (struct ast_channel *chan, int cdr_answer) |
Answer a channel. | |
ast_frame * | ast_read (struct ast_channel *chan) |
Reads a frame. | |
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 rtimeout, char *enders) |
Reads multiple digits. | |
int | ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, 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. | |
ast_channel * | ast_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status) |
Requests a channel. | |
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) |
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 for a specified amount of time, looking for hangups. | |
int | ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data) |
Wait for a specified amount of time, looking for hangups and a condition argument. | |
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. | |
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. | |
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 format) |
Sets write format on channel chan Set write format for channel to whichever component of "format" is best. | |
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 reason) |
Softly hangup up a channel. | |
int | ast_softhangup_nolock (struct ast_channel *chan, int reason) |
Softly hangup up a channel (no channel lock). | |
const char * | ast_state2str (enum ast_channel_state) |
Gives the string form of a given channel state. | |
int | ast_str2cause (const char *name) attribute_pure |
Convert the string form of a cause code to a 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 channel (if supported). | |
char * | ast_transfercapability2str (int transfercapability) attribute_const |
Gives the string form of a given transfer capability. | |
int | ast_waitfor (struct ast_channel *chan, int ms) |
Wait for input on a channel. | |
ast_channel * | ast_waitfor_n (struct ast_channel **chan, 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) |
Waits for input on an fd. | |
ast_channel * | ast_waitfor_nandfds (struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms) |
Waits for activity on a group of channels. | |
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 ctrlfd) |
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 *frame) |
Write a frame to a channel This function writes the given frame to the indicated channel. | |
int | ast_write_text (struct ast_channel *chan, struct ast_frame *frame) |
Write text 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 *frame) |
Write video frame to a channel This function writes the given frame to the indicated channel. | |
const char * | channelreloadreason2txt (enum channelreloadreason reason) |
Convert enum channelreloadreason to text string for manager event. | |
Variables | |
unsigned long | global_fin |
unsigned long | global_fout |
Definition in file channel.h.
#define AST_AGENT_FD (AST_MAX_FDS-3) |
used by agents for pass through
Definition at line 165 of file channel.h.
Referenced by agent_read().
#define AST_ALERT_FD (AST_MAX_FDS-1) |
used for alertpipe
Definition at line 163 of file channel.h.
Referenced by __ast_channel_alloc_ap().
#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) |
Report DTMF on channel 0.
Definition at line 1864 of file channel.h.
Referenced by ast_generic_bridge(), dahdi_bridge(), iax2_bridge(), misdn_bridge(), and set_config_flags().
#define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) |
Report DTMF on channel 1.
Definition at line 1866 of file channel.h.
Referenced by ast_generic_bridge(), dahdi_bridge(), iax2_bridge(), misdn_bridge(), and set_config_flags().
#define AST_BRIDGE_IGNORE_SIGS (1 << 4) |
#define AST_BRIDGE_REC_CHANNEL_0 (1 << 2) |
#define AST_BRIDGE_REC_CHANNEL_1 (1 << 3) |
#define AST_CHAN_WRITE_INFO_T_VERSION 1 |
ast_chan_write_info_t version. Must be incremented if structure is changed
Definition at line 484 of file channel.h.
Referenced by func_channel_write(), and local_setoption().
#define ast_channel_alloc | ( | needqueue, | |||
state, | |||||
cid_num, | |||||
cid_name, | |||||
acctcode, | |||||
exten, | |||||
context, | |||||
linkedid, | |||||
amaflag | ) |
Value:
__ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \ __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
Definition at line 1115 of file channel.h.
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().
#define ast_channel_lock | ( | chan | ) | ao2_lock(chan) |
Definition at line 2392 of file channel.h.
Referenced by __ast_answer(), __ast_channel_masquerade(), __ast_queue_frame(), __ast_read(), __oh323_destroy(), __sip_destroy(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), action_add_agi_cmd(), action_coreshowchannels(), action_hangup(), action_redirect(), action_status(), action_timeout(), add_features_datastores(), add_to_agi(), agent_hangup(), agent_indicate(), ast_activate_generator(), ast_async_goto(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_audiohook_set_mute(), ast_autochan_destroy(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_bridge_timelimit(), ast_call(), ast_call_forward(), 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_cel_report_event(), ast_change_name(), ast_channel_clear_softhangup(), ast_channel_cmp_cb(), ast_channel_connected_line_macro(), ast_channel_destructor(), ast_channel_redirecting_macro(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_check_hangup_locked(), ast_complete_channels(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_eivr_getvariable(), ast_explicit_goto(), ast_handle_cc_control_frame(), ast_hangup(), ast_ignore_cc(), ast_indicate_data(), ast_odbc_retrieve_transaction_obj(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_raw_answer(), ast_read_generator_actions(), ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), ast_safe_sleep_conditional(), ast_sendtext(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout(), ast_setup_cc_recall_datastore(), ast_softhangup(), ast_stopstream(), ast_str_retrieve_variable(), ast_transfer(), ast_udptl_bridge(), ast_var_channel_bridge(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_write(), bridge_play_sounds(), builtin_atxfer(), builtin_automixmonitor(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), channel_set_debug(), channel_spy(), common_exec(), conf_run(), conf_start_moh(), confbridge_exec(), connectedline_read(), connectedline_write(), crement_function_read(), dahdi_bridge(), dahdi_handle_dtmf(), data_channels_provider_handler(), dial_exec_full(), dialog_unlink_all(), disable_jack_hook(), do_forward(), dundi_query_read(), dundi_result_read(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), feature_interpret(), feature_request_and_dial(), find_by_mark(), find_by_part(), find_calling_channel(), find_details(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_header_read(), func_inheritance_write(), func_mute_write(), function_agent(), function_sipchaninfo_read(), generator_force(), generic_fax_exec(), get_agi_cmd(), get_cid_name(), handle_chanlist(), handle_cli_mixmonitor(), handle_invite_replaces(), handle_request_bye(), handle_request_invite(), handle_showchan(), handle_softhangup(), import_ch(), import_helper(), init_jack_data(), jack_hook_callback(), leave_voicemail(), linkedid_match(), listfilter(), local_ast_moh_stop(), local_call(), local_hangup(), local_read(), local_setoption(), login_exec(), lua_get_state(), manage_parkinglot(), manager_mutestream(), manager_park(), mark_transaction_active(), minivm_delete_exec(), minivm_notify_exec(), misdn_answer(), misdn_attempt_transfer(), misdn_update_caller_id(), moh_files_generator(), morsecode_exec(), mute_callback(), my_handle_dtmf(), notify_new_message(), park_call_full(), park_exec_full(), park_space_reserve(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setvar_helper(), peek_read(), pickup_by_exten(), pickup_by_mark(), pickup_by_name_cb(), pickup_by_part(), pickup_do(), pitchshift_helper(), process_sdp(), queue_exec(), receivefax_exec(), redirecting_read(), redirecting_write(), release_transaction(), report_fax_status(), retrydial_exec(), ring_entry(), run_agi(), sendfax_exec(), sendtext_exec(), set_ext_pri(), set_format(), set_security_requirements(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_read(), shared_write(), sip_addheader(), sip_dtmfmode(), sip_new(), sip_read(), sip_removeheader(), smdi_msg_read(), smdi_msg_retrieve_read(), softhangup_exec(), speech_background(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), start_monitor_action(), state_notify_build_xml(), stop_mixmonitor_exec(), transmit_invite(), try_calling(), update_bridge_vars(), and wait_for_answer().
#define ast_channel_lock_both | ( | chan1, | |||
chan2 | ) |
Lock two channels.
Definition at line 2399 of file channel.h.
Referenced by ast_pickup_call(), and do_bridge_masquerade().
#define AST_CHANNEL_NAME 80 |
Max length of an ast_channel name
Definition at line 137 of file channel.h.
Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_channel_destructor(), ast_do_masquerade(), ast_parse_device_state(), ast_queue_cc_frame(), ast_setstate(), cc_core_init_instance(), cc_unique_append(), cccancel_exec(), ccreq_exec(), common_exec(), create_jb(), dahdi_cc_callback(), dial_exec_full(), fast_originate(), page_exec(), park_call_full(), sig_pri_call(), sig_pri_cc_generic_check(), sip_call(), sip_handle_cc(), and softhangup_exec().
#define ast_channel_ref | ( | c | ) | ({ ao2_ref(c, +1); (c); }) |
Increase channel reference count.
c | the channel |
c | always |
Definition at line 2417 of file channel.h.
Referenced by ast_autochan_new_channel(), ast_autochan_setup(), ast_cel_report_event(), handle_getvariablefull(), handle_incoming(), handle_invite_replaces(), handle_request_refer(), and local_attended_transfer().
#define ast_channel_trylock | ( | chan | ) | ao2_trylock(chan) |
Definition at line 2394 of file channel.h.
Referenced by __ast_channel_masquerade(), __oh323_rtp_create(), __sip_autodestruct(), agent_indicate(), agent_logoff(), agent_read(), analog_lock_sub_owner(), ast_call_forward(), ast_do_masquerade(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_udptl_bridge(), ast_write(), auto_congest(), bridge_queue_hangup(), bridge_write(), check_bridge(), check_rtp_timeout(), cleanup_connection(), dahdi_bridge(), dahdi_handle_event(), dahdi_lock_sub_owner(), dahdi_queue_frame(), dahdi_softhangup_all(), dial_exec_full(), do_forward(), get_sip_pvt_byid_locked(), grab_owner(), handle_request_bye(), handle_request_do(), handle_request_refer(), hangup_connection(), iax2_destroy(), iax2_lock_owner(), local_call(), local_hangup(), local_queryoption(), local_queue_frame(), local_setoption(), manager_park(), mgcp_queue_frame(), mgcp_queue_hangup(), misdn_attempt_transfer(), oh323_rtp_read(), oh323_simulate_dtmf_end(), proc_session_timer(), receive_digit(), release_chan(), release_chan_early(), remote_hold(), retrans_pkt(), ring_entry(), scheduler_process_request_queue(), setup_rtp_connection(), sig_pri_lock_owner(), sip_hangup(), sip_park(), sip_reinvite_retry(), sip_set_rtp_peer(), sip_set_udptl_peer(), and update_state().
#define ast_channel_unlock | ( | chan | ) | ao2_unlock(chan) |
Definition at line 2393 of file channel.h.
Referenced by __analog_handle_event(), __ast_answer(), __ast_channel_masquerade(), __ast_queue_frame(), __ast_read(), __oh323_destroy(), __oh323_rtp_create(), __sip_autodestruct(), __sip_destroy(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), action_add_agi_cmd(), action_coreshowchannels(), action_hangup(), action_redirect(), action_timeout(), add_features_datastores(), add_to_agi(), agent_hangup(), agent_indicate(), agent_logoff(), agent_read(), alsa_call(), analog_attempt_transfer(), analog_hangup(), ast_activate_generator(), ast_async_goto(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_audiohook_set_mute(), ast_autochan_destroy(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_bridge_timelimit(), ast_call(), ast_call_forward(), 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_cel_report_event(), ast_change_name(), ast_channel_clear_softhangup(), ast_channel_cmp_cb(), ast_channel_connected_line_macro(), ast_channel_destructor(), ast_channel_redirecting_macro(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_check_hangup_locked(), ast_complete_channels(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_eivr_getvariable(), ast_explicit_goto(), ast_handle_cc_control_frame(), ast_hangup(), ast_ignore_cc(), ast_indicate_data(), ast_odbc_retrieve_transaction_obj(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pickup_call(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_raw_answer(), ast_read_generator_actions(), ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), ast_safe_sleep_conditional(), ast_sendtext(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout(), ast_setup_cc_recall_datastore(), ast_softhangup(), ast_stopstream(), ast_str_retrieve_variable(), ast_transfer(), ast_udptl_bridge(), ast_var_channel_bridge(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_write(), attempt_transfer(), auto_congest(), bridge_exec(), bridge_play_sounds(), bridge_queue_hangup(), bridge_write(), builtin_atxfer(), builtin_automixmonitor(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), channel_set_debug(), channel_spy(), check_bridge(), check_rtp_timeout(), cleanup_connection(), common_exec(), conf_run(), conf_start_moh(), confbridge_exec(), connectedline_read(), connectedline_write(), console_answer(), console_hangup(), console_sendtext(), crement_function_read(), dahdi_bridge(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_queue_frame(), dahdi_softhangup_all(), data_channels_provider_handler(), dial_exec_full(), dialog_unlink_all(), disable_jack_hook(), do_bridge_masquerade(), do_forward(), dundi_query_read(), dundi_result_read(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), fast_originate(), feature_interpret(), feature_request_and_dial(), find_by_mark(), find_by_part(), find_calling_channel(), find_details(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_header_read(), func_inheritance_write(), func_mute_write(), function_agent(), function_sipchaninfo_read(), generator_force(), generic_fax_exec(), get_agi_cmd(), get_cid_name(), handle_chanlist(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_incoming(), handle_invite_replaces(), handle_request_bye(), handle_request_do(), handle_request_invite(), handle_request_refer(), handle_showchan(), handle_softhangup(), hangup_connection(), iax2_destroy(), iax2_queue_control_data(), iax2_queue_frame(), iax2_queue_hangup(), import_ch(), import_helper(), init_jack_data(), jack_hook_callback(), leave_voicemail(), linkedid_match(), listfilter(), local_ast_moh_stop(), local_attended_transfer(), local_bridge_loop(), local_call(), local_hangup(), local_queryoption(), local_queue_frame(), local_read(), local_setoption(), login_exec(), lua_get_state(), manage_parkinglot(), manager_mutestream(), manager_park(), mark_transaction_active(), mgcp_pktcgate_remove(), mgcp_queue_frame(), mgcp_queue_hangup(), minivm_delete_exec(), minivm_notify_exec(), misdn_answer(), misdn_attempt_transfer(), misdn_update_caller_id(), moh_files_generator(), morsecode_exec(), mute_callback(), my_handle_dtmf(), notify_new_message(), oh323_rtp_read(), oh323_simulate_dtmf_end(), park_call_full(), park_exec_full(), park_space_reserve(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setvar_helper(), peek_read(), pickup_by_channel(), pickup_by_exten(), pickup_by_mark(), pickup_by_name_cb(), pickup_by_part(), pickup_do(), pitchshift_helper(), pri_fixup_principle(), pri_queue_frame(), proc_session_timer(), process_sdp(), queue_exec(), receive_digit(), receivefax_exec(), redirecting_read(), redirecting_write(), release_chan(), release_chan_early(), release_transaction(), remote_bridge_loop(), remote_hold(), report_fax_status(), retrans_pkt(), retrydial_exec(), ring_entry(), run_agi(), schedule_delivery(), sendfax_exec(), sendtext_exec(), set_ext_pri(), set_format(), set_hangup_source_and_cause(), set_security_requirements(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_rtp_connection(), setup_transfer_datastore(), shared_read(), shared_write(), sig_pri_attempt_transfer(), sig_pri_cc_generic_check(), sig_pri_handle_hold(), sig_pri_handle_subcmds(), sip_addheader(), sip_dtmfmode(), sip_hangup(), sip_new(), sip_park(), sip_read(), sip_reinvite_retry(), sip_removeheader(), sip_set_rtp_peer(), sip_set_udptl_peer(), smdi_msg_read(), smdi_msg_retrieve_read(), socket_process(), softhangup_exec(), speech_background(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), start_monitor_action(), state_notify_build_xml(), stop_mixmonitor_exec(), transmit_invite(), try_calling(), update_bridge_vars(), update_state(), wait_for_answer(), and wakeup_sub().
#define ast_channel_unref | ( | c | ) | ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); }) |
Decrease channel reference count.
c | the channel |
NULL | always |
Definition at line 2428 of file channel.h.
Referenced by __ast_channel_alloc_ap(), action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_bridge(), action_coreshowchannels(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_timeout(), ast_async_goto_by_name(), ast_autochan_destroy(), ast_autochan_new_channel(), ast_bridge_call(), ast_cel_check_retire_linkedid(), ast_cel_report_event(), ast_channel_release(), ast_complete_channels(), ast_dummy_channel_alloc(), ast_parse_device_state(), ast_pickup_call(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), asyncgoto_exec(), bridge_exec(), change_monitor_action(), common_exec(), data_channels_provider_handler(), do_pause_or_unpause(), func_channels_read(), func_mchan_read(), func_mchan_write(), handle_chanlist(), handle_channelstatus(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_incoming(), handle_invite_replaces(), handle_redirect(), handle_request_refer(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), import_helper(), local_attended_transfer(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), park_call_full(), pbx_builtin_importvar(), pickup_by_channel(), pickup_by_exten(), pickup_by_mark(), pickup_by_part(), senddtmf_exec(), shared_read(), shared_write(), softhangup_exec(), start_monitor_action(), state_notify_build_xml(), and stop_monitor_action().
#define AST_GENERATOR_FD (AST_MAX_FDS-4) |
used by generator
Definition at line 166 of file channel.h.
Referenced by __ast_read(), ast_deactivate_generator(), and ast_do_masquerade().
#define AST_MAX_CONTEXT 80 |
Max length of a context
Definition at line 136 of file channel.h.
Referenced by _macro_exec(), aji_publish_mwi(), cleanup_stale_contexts(), common_exec(), conf_run(), config_parse_variables(), dial_transfer(), do_magic_pickup(), gtalk_load_config(), handle_gosub(), handle_request_invite(), reload_config(), and try_calling().
#define AST_MAX_EXTENSION 80 |
Max length of an extension
Definition at line 135 of file channel.h.
Referenced by __analog_ss_thread(), __ast_context_destroy(), add_extensions(), advanced_options(), aji_publish_mwi(), analog_ss_thread(), ast_device_state_changed(), ast_devstate_changed(), ast_ivr_menu_run_internal(), begin_dial_channel(), build_device(), cc_extension_monitor_init(), conf_run(), destroy_station(), dial_exec_full(), dial_transfer(), disa_exec(), do_forward(), do_magic_pickup(), dundi_lookup_local(), feature_attended_transfer(), feature_blind_transfer(), find_conf_realtime(), forward_message(), function_enum(), get_destination(), handle_gosub(), handle_request_invite(), load_module(), log_exec(), manager_show_dialplan_helper(), mgcp_ss(), phone_check_exception(), pri_dchannel(), pri_ss_thread(), realtime_common(), realtime_switch_common(), search_directory_sub(), show_dialplan_helper(), sig_pri_party_number_convert(), skinny_extensionstate_cb(), skinny_ss(), speech_background(), state_notify_build_xml(), try_calling(), vm_authenticate(), and vmauthenticate().
#define AST_MAX_FDS 10 |
Definition at line 158 of file channel.h.
Referenced by ast_channel_destructor(), ast_do_masquerade(), ast_poll_channel_add(), ast_poll_channel_del(), and ast_waitfor_nandfds().
#define AST_TIMING_FD (AST_MAX_FDS-2) |
used for timingfd
Definition at line 164 of file channel.h.
Referenced by __ast_channel_alloc_ap(), __ast_read(), agent_read(), and ast_do_masquerade().
#define CHECK_BLOCKING | ( | c | ) |
Definition at line 2353 of file channel.h.
Referenced by ast_sendtext(), ast_waitfor_nandfds(), ast_write(), dahdi_read(), and phone_read().
#define DATASTORE_INHERIT_FOREVER INT_MAX |
Definition at line 156 of file channel.h.
Referenced by _macro_exec(), acf_iaxvar_write(), add_features_datastores(), ast_channel_datastore_inherit(), ast_iax2_new(), ast_setup_cc_recall_datastore(), authenticate_reply(), calendar_query_exec(), cc_interfaces_datastore_init(), dial_exec_full(), do_notify(), and socket_process().
#define DEBUGCHAN_FLAG 0x80000000 |
The high bit of the frame count is used as a debug marker, so increments of the counters must be done with care. Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
Definition at line 639 of file channel.h.
Referenced by __ast_read(), ast_write(), channel_set_debug(), handle_core_set_debug_channel(), handle_showchan(), and serialize_showchan().
#define FRAMECOUNT_INC | ( | x | ) | ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) |
#define MAX_LANGUAGE 40 |
#define MAX_MUSICCLASS 80 |
typedef int(*) ast_acf_read2_fn_t(struct ast_channel *, const char *, char *, struct ast_str **, ssize_t) |
typedef int(*) ast_acf_read_fn_t(struct ast_channel *, const char *, char *, char *, size_t) |
typedef int(*) ast_acf_write_fn_t(struct ast_channel *, const char *, char *, const char *) |
typedef unsigned long long ast_group_t |
anonymous enum |
ast_channel_tech Properties
Definition at line 867 of file channel.h.
00867 { 00868 /*! 00869 * \brief Channels have this property if they can accept input with jitter; 00870 * i.e. most VoIP channels 00871 */ 00872 AST_CHAN_TP_WANTSJITTER = (1 << 0), 00873 /*! 00874 * \brief Channels have this property if they can create jitter; 00875 * i.e. most VoIP channels 00876 */ 00877 AST_CHAN_TP_CREATESJITTER = (1 << 1), 00878 };
anonymous enum |
ast_channel flags
Definition at line 881 of file channel.h.
00881 { 00882 /*! Queue incoming DTMF, to be released when this flag is turned off */ 00883 AST_FLAG_DEFER_DTMF = (1 << 1), 00884 /*! write should be interrupt generator */ 00885 AST_FLAG_WRITE_INT = (1 << 2), 00886 /*! a thread is blocking on this channel */ 00887 AST_FLAG_BLOCKING = (1 << 3), 00888 /*! This is a zombie channel */ 00889 AST_FLAG_ZOMBIE = (1 << 4), 00890 /*! There is an exception pending */ 00891 AST_FLAG_EXCEPTION = (1 << 5), 00892 /*! Listening to moh XXX anthm promises me this will disappear XXX */ 00893 AST_FLAG_MOH = (1 << 6), 00894 /*! This channel is spying on another channel */ 00895 AST_FLAG_SPYING = (1 << 7), 00896 /*! This channel is in a native bridge */ 00897 AST_FLAG_NBRIDGE = (1 << 8), 00898 /*! the channel is in an auto-incrementing dialplan processor, 00899 * so when ->priority is set, it will get incremented before 00900 * finding the next priority to run */ 00901 AST_FLAG_IN_AUTOLOOP = (1 << 9), 00902 /*! This is an outgoing call */ 00903 AST_FLAG_OUTGOING = (1 << 10), 00904 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ 00905 AST_FLAG_IN_DTMF = (1 << 12), 00906 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is 00907 * currently being emulated */ 00908 AST_FLAG_EMULATE_DTMF = (1 << 13), 00909 /*! This is set to tell the channel not to generate DTMF begin frames, and 00910 * to instead only generate END frames. */ 00911 AST_FLAG_END_DTMF_ONLY = (1 << 14), 00912 /*! Flag to show channels that this call is hangup due to the fact that the call 00913 was indeed answered, but in another channel */ 00914 AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), 00915 /*! This flag indicates that on a masquerade, an active stream should not 00916 * be carried over */ 00917 AST_FLAG_MASQ_NOSTREAM = (1 << 16), 00918 /*! This flag indicates that the hangup exten was run when the bridge terminated, 00919 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run 00920 * level */ 00921 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), 00922 /*! This flag indicates that the hangup exten should NOT be run when the 00923 * bridge terminates, this will allow the hangup in the pbx loop to be run instead. 00924 * */ 00925 AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18), 00926 /*! Disable certain workarounds. This reintroduces certain bugs, but allows 00927 * some non-traditional dialplans (like AGI) to continue to function. 00928 */ 00929 AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20), 00930 };
anonymous enum |
ast_bridge_config flags
Definition at line 933 of file channel.h.
00933 { 00934 AST_FEATURE_PLAY_WARNING = (1 << 0), 00935 AST_FEATURE_REDIRECT = (1 << 1), 00936 AST_FEATURE_DISCONNECT = (1 << 2), 00937 AST_FEATURE_ATXFER = (1 << 3), 00938 AST_FEATURE_AUTOMON = (1 << 4), 00939 AST_FEATURE_PARKCALL = (1 << 5), 00940 AST_FEATURE_AUTOMIXMON = (1 << 6), 00941 AST_FEATURE_NO_H_EXTEN = (1 << 7), 00942 AST_FEATURE_WARNING_ACTIVE = (1 << 8), 00943 };
anonymous enum |
Definition at line 981 of file channel.h.
00981 { 00982 /*! 00983 * Soft hangup requested by device or other internal reason. 00984 * Actual hangup needed. 00985 */ 00986 AST_SOFTHANGUP_DEV = (1 << 0), 00987 /*! 00988 * Used to break the normal frame flow so an async goto can be 00989 * done instead of actually hanging up. 00990 */ 00991 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), 00992 /*! 00993 * Soft hangup requested by system shutdown. Actual hangup 00994 * needed. 00995 */ 00996 AST_SOFTHANGUP_SHUTDOWN = (1 << 2), 00997 /*! 00998 * Used to break the normal frame flow after a timeout so an 00999 * implicit async goto can be done to the 'T' exten if it exists 01000 * instead of actually hanging up. If the exten does not exist 01001 * then actually hangup. 01002 */ 01003 AST_SOFTHANGUP_TIMEOUT = (1 << 3), 01004 /*! 01005 * Soft hangup requested by application/channel-driver being 01006 * unloaded. Actual hangup needed. 01007 */ 01008 AST_SOFTHANGUP_APPUNLOAD = (1 << 4), 01009 /*! 01010 * Soft hangup requested by non-associated party. Actual hangup 01011 * needed. 01012 */ 01013 AST_SOFTHANGUP_EXPLICIT = (1 << 5), 01014 /*! 01015 * Used to break a bridge so the channel can be spied upon 01016 * instead of actually hanging up. 01017 */ 01018 AST_SOFTHANGUP_UNBRIDGE = (1 << 6), 01019 01020 01021 /*! 01022 * \brief All softhangup flags. 01023 * 01024 * This can be used as an argument to ast_channel_softhangup_clear 01025 * to clear all softhangup flags from a channel. 01026 */ 01027 AST_SOFTHANGUP_ALL = (0xFFFFFFFF) 01028 };
enum ast_bridge_result |
Definition at line 168 of file channel.h.
00168 { 00169 AST_BRIDGE_COMPLETE = 0, 00170 AST_BRIDGE_FAILED = -1, 00171 AST_BRIDGE_FAILED_NOWARN = -2, 00172 AST_BRIDGE_RETRY = -3, 00173 };
enum ast_channel_adsicpe |
Definition at line 650 of file channel.h.
00650 { 00651 AST_ADSI_UNKNOWN, 00652 AST_ADSI_AVAILABLE, 00653 AST_ADSI_UNAVAILABLE, 00654 AST_ADSI_OFFHOOKONLY, 00655 };
enum AST_PARTY_CHAR_SET |
Party name character set enumeration values (values from Q.SIG)
Definition at line 192 of file channel.h.
00192 { 00193 AST_PARTY_CHAR_SET_UNKNOWN = 0, 00194 AST_PARTY_CHAR_SET_ISO8859_1 = 1, 00195 AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */ 00196 AST_PARTY_CHAR_SET_ISO8859_2 = 3, 00197 AST_PARTY_CHAR_SET_ISO8859_3 = 4, 00198 AST_PARTY_CHAR_SET_ISO8859_4 = 5, 00199 AST_PARTY_CHAR_SET_ISO8859_5 = 6, 00200 AST_PARTY_CHAR_SET_ISO8859_7 = 7, 00201 AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8, 00202 AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9, 00203 };
enum ast_t38_state |
Possible T38 states on channels.
Definition at line 660 of file channel.h.
00660 { 00661 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */ 00662 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */ 00663 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */ 00664 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */ 00665 T38_STATE_NEGOTIATED, /*!< T38 established */ 00666 };
enum channelreloadreason |
Channel reload reasons for manager events at load or reload of configuration.
Definition at line 1032 of file channel.h.
01032 { 01033 CHANNEL_MODULE_LOAD, 01034 CHANNEL_MODULE_RELOAD, 01035 CHANNEL_CLI_RELOAD, 01036 CHANNEL_MANAGER_RELOAD, 01037 };
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 will wait up to 'delay' milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow. If 'delay' is less than 500, the function will wait up to 500 milliseconds.
0 | on success | |
non-zero | on failure |
Definition at line 2850 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(), chanlist::chan, errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.
Referenced by ast_answer(), dial_exec_full(), pbx_builtin_answer(), and pbx_builtin_incomplete().
02851 { 02852 int res = 0; 02853 enum ast_channel_state old_state; 02854 02855 old_state = chan->_state; 02856 if ((res = ast_raw_answer(chan, cdr_answer))) { 02857 return res; 02858 } 02859 02860 switch (old_state) { 02861 case AST_STATE_RINGING: 02862 case AST_STATE_RING: 02863 /* wait for media to start flowing, but don't wait any longer 02864 * than 'delay' or 500 milliseconds, whichever is longer 02865 */ 02866 do { 02867 AST_LIST_HEAD_NOLOCK(, ast_frame) frames; 02868 struct ast_frame *cur, *new; 02869 int ms = MAX(delay, 500); 02870 unsigned int done = 0; 02871 02872 AST_LIST_HEAD_INIT_NOLOCK(&frames); 02873 02874 for (;;) { 02875 ms = ast_waitfor(chan, ms); 02876 if (ms < 0) { 02877 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno)); 02878 res = -1; 02879 break; 02880 } 02881 if (ms == 0) { 02882 ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500)); 02883 break; 02884 } 02885 cur = ast_read(chan); 02886 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) && 02887 (cur->subclass.integer == AST_CONTROL_HANGUP))) { 02888 if (cur) { 02889 ast_frfree(cur); 02890 } 02891 res = -1; 02892 ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name); 02893 break; 02894 } 02895 02896 if ((new = ast_frisolate(cur)) != cur) { 02897 ast_frfree(cur); 02898 } 02899 02900 AST_LIST_INSERT_HEAD(&frames, new, frame_list); 02901 02902 /* if a specific delay period was requested, continue 02903 * until that delay has passed. don't stop just because 02904 * incoming media has arrived. 02905 */ 02906 if (delay) { 02907 continue; 02908 } 02909 02910 switch (new->frametype) { 02911 /* all of these frametypes qualify as 'media' */ 02912 case AST_FRAME_VOICE: 02913 case AST_FRAME_VIDEO: 02914 case AST_FRAME_TEXT: 02915 case AST_FRAME_DTMF_BEGIN: 02916 case AST_FRAME_DTMF_END: 02917 case AST_FRAME_IMAGE: 02918 case AST_FRAME_HTML: 02919 case AST_FRAME_MODEM: 02920 done = 1; 02921 break; 02922 case AST_FRAME_CONTROL: 02923 case AST_FRAME_IAX: 02924 case AST_FRAME_NULL: 02925 case AST_FRAME_CNG: 02926 break; 02927 } 02928 02929 if (done) { 02930 break; 02931 } 02932 } 02933 02934 if (res == 0) { 02935 ast_channel_lock(chan); 02936 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) { 02937 ast_queue_frame_head(chan, cur); 02938 ast_frfree(cur); 02939 } 02940 ast_channel_unlock(chan); 02941 } 02942 } while (0); 02943 break; 02944 default: 02945 break; 02946 } 02947 02948 return res; 02949 }
struct ast_channel* attribute_malloc __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.
NULL | failure | |
non-NULL | successfully allocated channel |
Definition at line 1295 of file channel.c.
References __ast_channel_alloc_ap().
01301 { 01302 va_list ap1, ap2; 01303 struct ast_channel *result; 01304 01305 va_start(ap1, name_fmt); 01306 va_start(ap2, name_fmt); 01307 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context, 01308 linkedid, amaflag, file, line, function, name_fmt, ap1, ap2); 01309 va_end(ap1); 01310 va_end(ap2); 01311 01312 return result; 01313 }
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 | |||
) |
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 5181 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_set_connected_line(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, 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_callerid(), 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, chanlist::connected, ast_channel::connected, outgoing_helper::context, ast_channel::context, outgoing_helper::exten, ast_channel::exten, f, handle_cause(), ast_channel::hangupcause, ast_party_connected_line::id, LOG_NOTICE, ast_party_id::name, ast_party_id::number, outgoing_helper::parent_channel, ast_party_number::presentation, ast_party_name::presentation, outgoing_helper::priority, ast_channel::priority, ast_party_number::str, ast_party_name::str, ast_party_number::valid, ast_party_name::valid, and outgoing_helper::vars.
Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().
05182 { 05183 int dummy_outstate; 05184 int cause = 0; 05185 struct ast_channel *chan; 05186 int res = 0; 05187 int last_subclass = 0; 05188 struct ast_party_connected_line connected; 05189 05190 if (outstate) 05191 *outstate = 0; 05192 else 05193 outstate = &dummy_outstate; /* make outstate always a valid pointer */ 05194 05195 chan = ast_request(type, format, requestor, data, &cause); 05196 if (!chan) { 05197 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); 05198 handle_cause(cause, outstate); 05199 return NULL; 05200 } 05201 05202 if (oh) { 05203 if (oh->vars) 05204 ast_set_variables(chan, oh->vars); 05205 /* XXX why is this necessary, for the parent_channel perhaps ? */ 05206 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) 05207 ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num); 05208 if (oh->parent_channel) { 05209 ast_channel_inherit_variables(oh->parent_channel, chan); 05210 ast_channel_datastore_inherit(oh->parent_channel, chan); 05211 } 05212 if (oh->account) 05213 ast_cdr_setaccount(chan, oh->account); 05214 } 05215 05216 ast_set_callerid(chan, cid_num, cid_name, cid_num); 05217 ast_set_flag(chan->cdr, AST_CDR_FLAG_ORIGINATED); 05218 ast_party_connected_line_set_init(&connected, &chan->connected); 05219 if (cid_num) { 05220 connected.id.number.valid = 1; 05221 connected.id.number.str = (char *) cid_num; 05222 connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 05223 } 05224 if (cid_name) { 05225 connected.id.name.valid = 1; 05226 connected.id.name.str = (char *) cid_name; 05227 connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 05228 } 05229 ast_channel_set_connected_line(chan, &connected, NULL); 05230 05231 if (ast_call(chan, data, 0)) { /* ast_call failed... */ 05232 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data); 05233 } else { 05234 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */ 05235 while (timeout && chan->_state != AST_STATE_UP) { 05236 struct ast_frame *f; 05237 res = ast_waitfor(chan, timeout); 05238 if (res == 0) { /* timeout, treat it like ringing */ 05239 *outstate = AST_CONTROL_RINGING; 05240 break; 05241 } 05242 if (res < 0) /* error or done */ 05243 break; 05244 if (timeout > -1) 05245 timeout = res; 05246 if (!ast_strlen_zero(chan->call_forward)) { 05247 if (!(chan = ast_call_forward(NULL, chan, NULL, format, oh, outstate))) { 05248 return NULL; 05249 } 05250 continue; 05251 } 05252 05253 f = ast_read(chan); 05254 if (!f) { 05255 *outstate = AST_CONTROL_HANGUP; 05256 res = 0; 05257 break; 05258 } 05259 if (f->frametype == AST_FRAME_CONTROL) { 05260 switch (f->subclass.integer) { 05261 case AST_CONTROL_RINGING: /* record but keep going */ 05262 *outstate = f->subclass.integer; 05263 break; 05264 05265 case AST_CONTROL_BUSY: 05266 ast_cdr_busy(chan->cdr); 05267 *outstate = f->subclass.integer; 05268 timeout = 0; 05269 break; 05270 05271 case AST_CONTROL_CONGESTION: 05272 ast_cdr_failed(chan->cdr); 05273 *outstate = f->subclass.integer; 05274 timeout = 0; 05275 break; 05276 05277 case AST_CONTROL_ANSWER: 05278 ast_cdr_answer(chan->cdr); 05279 *outstate = f->subclass.integer; 05280 timeout = 0; /* trick to force exit from the while() */ 05281 break; 05282 05283 /* Ignore these */ 05284 case AST_CONTROL_PROGRESS: 05285 case AST_CONTROL_PROCEEDING: 05286 case AST_CONTROL_HOLD: 05287 case AST_CONTROL_UNHOLD: 05288 case AST_CONTROL_VIDUPDATE: 05289 case AST_CONTROL_SRCUPDATE: 05290 case AST_CONTROL_SRCCHANGE: 05291 case AST_CONTROL_CONNECTED_LINE: 05292 case AST_CONTROL_REDIRECTING: 05293 case AST_CONTROL_CC: 05294 case -1: /* Ignore -- just stopping indications */ 05295 break; 05296 05297 default: 05298 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer); 05299 } 05300 last_subclass = f->subclass.integer; 05301 } 05302 ast_frfree(f); 05303 } 05304 } 05305 05306 /* Final fixups */ 05307 if (oh) { 05308 if (!ast_strlen_zero(oh->context)) 05309 ast_copy_string(chan->context, oh->context, sizeof(chan->context)); 05310 if (!ast_strlen_zero(oh->exten)) 05311 ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten)); 05312 if (oh->priority) 05313 chan->priority = oh->priority; 05314 } 05315 if (chan->_state == AST_STATE_UP) 05316 *outstate = AST_CONTROL_ANSWER; 05317 05318 if (res <= 0) { 05319 if ( AST_CONTROL_RINGING == last_subclass ) 05320 chan->hangupcause = AST_CAUSE_NO_ANSWER; 05321 if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) 05322 ast_cdr_init(chan->cdr, chan); 05323 if (chan->cdr) { 05324 char tmp[256]; 05325 snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data); 05326 ast_cdr_setapp(chan->cdr,"Dial",tmp); 05327 ast_cdr_update(chan); 05328 ast_cdr_start(chan->cdr); 05329 ast_cdr_end(chan->cdr); 05330 /* If the cause wasn't handled properly */ 05331 if (ast_cdr_disposition(chan->cdr,chan->hangupcause)) 05332 ast_cdr_failed(chan->cdr); 05333 } 05334 ast_hangup(chan); 05335 chan = NULL; 05336 } 05337 return chan; 05338 }
int ast_activate_generator | ( | struct ast_channel * | chan, | |
struct ast_generator * | gen, | |||
void * | params | |||
) |
Activate a given generator
Definition at line 3001 of file channel.c.
References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), chanlist::chan, gen, ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.
Referenced by ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), eivr_comm(), old_milliwatt_exec(), and transmit_audio().
03002 { 03003 int res = 0; 03004 03005 ast_channel_lock(chan); 03006 if (chan->generatordata) { 03007 if (chan->generator && chan->generator->release) 03008 chan->generator->release(chan, chan->generatordata); 03009 chan->generatordata = NULL; 03010 } 03011 if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) { 03012 res = -1; 03013 } 03014 if (!res) { 03015 ast_settimeout(chan, 50, generator_force, chan); 03016 chan->generator = gen; 03017 } 03018 ast_channel_unlock(chan); 03019 03020 ast_prod(chan); 03021 03022 return res; 03023 }
int ast_active_channels | ( | void | ) |
returns number of active/allocated channels
Definition at line 783 of file channel.c.
References ao2_container_count(), and channels.
Referenced by action_corestatus(), ast_var_channels(), ast_var_channels_table(), handle_chanlist(), handle_show_settings(), and quit_handler().
00784 { 00785 return channels ? ao2_container_count(channels) : 0; 00786 }
static int ast_add_fd | ( | struct pollfd * | pfd, | |
int | fd | |||
) | [inline, static] |
if fd is a valid descriptor, set *pfd with the descriptor
Definition at line 2316 of file channel.h.
Referenced by ast_waitfor_nandfds().
int ast_answer | ( | struct ast_channel * | chan | ) |
Answer a channel.
chan | channel to answer |
This function will wait up to 500 milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow.
0 | on success | |
non-zero | on failure |
Definition at line 2951 of file channel.c.
References __ast_answer(), and chanlist::chan.
Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), 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(), park_exec_full(), parkcall_helper(), pbx_builtin_background(), pickup_do(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), receivefax_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().
02952 { 02953 return __ast_answer(chan, 0, 1); 02954 }
int ast_autoservice_ignore | ( | struct ast_channel * | chan, | |
enum ast_frame_type | ftype | |||
) |
Ignore certain frame types.
0 | success | |
-1 | channel is not in autoservice |
Definition at line 302 of file autoservice.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, asent::chan, asent::ignore_frame_types, and asent::list.
Referenced by builtin_automixmonitor(), builtin_blindtransfer(), feature_exec_app(), and play_message_in_bridged_call().
00303 { 00304 struct asent *as; 00305 int res = -1; 00306 00307 AST_LIST_LOCK(&aslist); 00308 AST_LIST_TRAVERSE(&aslist, as, list) { 00309 if (as->chan == chan) { 00310 res = 0; 00311 as->ignore_frame_types |= (1 << ftype); 00312 break; 00313 } 00314 } 00315 AST_LIST_UNLOCK(&aslist); 00316 return res; 00317 }
int ast_autoservice_start | ( | struct ast_channel * | chan | ) |
Automatically service a channel for us...
0 | success | |
-1 | failure, or the channel is already being autoserviced |
Definition at line 174 of file autoservice.c.
References as_cond, ast_calloc, ast_channel_lock, ast_channel_unlock, ast_cond_signal, AST_FLAG_END_DTMF_ONLY, AST_LIST_EMPTY, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_pthread_create_background, AST_PTHREADT_NULL, ast_set_flag, ast_test_flag, asthread, autoservice_run(), asent::chan, free, asent::list, LOG_WARNING, and asent::use_count.
Referenced by _macro_exec(), acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), ast_app_run_macro(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), bridge_playfile(), builtin_atxfer(), builtin_automixmonitor(), builtin_blindtransfer(), conf_play(), confbridge_exec(), dial_exec_full(), feature_exec_app(), feature_request_and_dial(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), leave_conference_bridge(), lock_read(), lua_autoservice_start(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), originate_exec(), osplookup_exec(), pbx_find_extension(), play_message_in_bridged_call(), post_join_marked(), realtimefield_read(), senddtmf_exec(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), and trylock_read().
00175 { 00176 int res = 0; 00177 struct asent *as; 00178 00179 AST_LIST_LOCK(&aslist); 00180 AST_LIST_TRAVERSE(&aslist, as, list) { 00181 if (as->chan == chan) { 00182 as->use_count++; 00183 break; 00184 } 00185 } 00186 AST_LIST_UNLOCK(&aslist); 00187 00188 if (as) { 00189 /* Entry exists, autoservice is already handling this channel */ 00190 return 0; 00191 } 00192 00193 if (!(as = ast_calloc(1, sizeof(*as)))) 00194 return -1; 00195 00196 /* New entry created */ 00197 as->chan = chan; 00198 as->use_count = 1; 00199 00200 ast_channel_lock(chan); 00201 as->orig_end_dtmf_flag = ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY) ? 1 : 0; 00202 if (!as->orig_end_dtmf_flag) 00203 ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); 00204 ast_channel_unlock(chan); 00205 00206 AST_LIST_LOCK(&aslist); 00207 00208 if (AST_LIST_EMPTY(&aslist) && asthread != AST_PTHREADT_NULL) { 00209 ast_cond_signal(&as_cond); 00210 } 00211 00212 AST_LIST_INSERT_HEAD(&aslist, as, list); 00213 00214 if (asthread == AST_PTHREADT_NULL) { /* need start the thread */ 00215 if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) { 00216 ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); 00217 /* There will only be a single member in the list at this point, 00218 the one we just added. */ 00219 AST_LIST_REMOVE(&aslist, as, list); 00220 free(as); 00221 asthread = AST_PTHREADT_NULL; 00222 res = -1; 00223 } else { 00224 pthread_kill(asthread, SIGURG); 00225 } 00226 } 00227 00228 AST_LIST_UNLOCK(&aslist); 00229 00230 return res; 00231 }
int ast_autoservice_stop | ( | struct ast_channel * | chan | ) |
Stop servicing a channel for us...
chan |
0 | success | |
-1 | error, or the channel has been hungup |
Definition at line 233 of file autoservice.c.
References ast_channel::_softhangup, as_chan_list_state, ast_channel_lock, ast_channel_unlock, ast_clear_flag, AST_FLAG_END_DTMF_ONLY, ast_frfree, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, AST_PTHREADT_NULL, ast_queue_frame_head(), asthread, asent::chan, asent::deferred_frames, f, free, asent::ignore_frame_types, asent::list, asent::orig_end_dtmf_flag, and asent::use_count.
Referenced by _macro_exec(), acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), array(), ast_app_run_macro(), ast_dtmf_stream(), ast_get_srv(), ast_get_txt(), ast_hangup(), bridge_playfile(), builtin_atxfer(), builtin_automixmonitor(), conf_play(), confbridge_exec(), dial_exec_full(), feature_exec_app(), feature_request_and_dial(), finishup(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), leave_conference_bridge(), lock_read(), lua_autoservice_stop(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), originate_exec(), osplookup_exec(), pbx_find_extension(), play_message_in_bridged_call(), post_join_marked(), realtimefield_read(), senddtmf_exec(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), and trylock_read().
00234 { 00235 int res = -1; 00236 struct asent *as, *removed = NULL; 00237 struct ast_frame *f; 00238 int chan_list_state; 00239 00240 AST_LIST_LOCK(&aslist); 00241 00242 /* Save the autoservice channel list state. We _must_ verify that the channel 00243 * list has been rebuilt before we return. Because, after we return, the channel 00244 * could get destroyed and we don't want our poor autoservice thread to step on 00245 * it after its gone! */ 00246 chan_list_state = as_chan_list_state; 00247 00248 /* Find the entry, but do not free it because it still can be in the 00249 autoservice thread array */ 00250 AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) { 00251 if (as->chan == chan) { 00252 as->use_count--; 00253 if (as->use_count < 1) { 00254 AST_LIST_REMOVE_CURRENT(list); 00255 removed = as; 00256 } 00257 break; 00258 } 00259 } 00260 AST_LIST_TRAVERSE_SAFE_END; 00261 00262 if (removed && asthread != AST_PTHREADT_NULL) { 00263 pthread_kill(asthread, SIGURG); 00264 } 00265 00266 AST_LIST_UNLOCK(&aslist); 00267 00268 if (!removed) { 00269 return 0; 00270 } 00271 00272 /* Wait while autoservice thread rebuilds its list. */ 00273 while (chan_list_state == as_chan_list_state) { 00274 usleep(1000); 00275 } 00276 00277 /* Now autoservice thread should have no references to our entry 00278 and we can safely destroy it */ 00279 00280 if (!chan->_softhangup) { 00281 res = 0; 00282 } 00283 00284 if (!as->orig_end_dtmf_flag) { 00285 ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); 00286 } 00287 00288 ast_channel_lock(chan); 00289 while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) { 00290 if (!((1 << f->frametype) & as->ignore_frame_types)) { 00291 ast_queue_frame_head(chan, f); 00292 } 00293 ast_frfree(f); 00294 } 00295 ast_channel_unlock(chan); 00296 00297 free(as); 00298 00299 return res; 00300 }
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 773 of file channel.c.
References ao2_callback, ast_channel_softhangup_cb(), channels, OBJ_MULTIPLE, and OBJ_NODATA.
Referenced by quit_handler().
00774 { 00775 shutting_down = 1; 00776 00777 if (hangup) { 00778 ao2_callback(channels, OBJ_NODATA | OBJ_MULTIPLE, ast_channel_softhangup_cb, NULL); 00779 } 00780 }
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 992 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().
00993 { 00994 /* This just our opinion, expressed in code. We are asked to choose 00995 the best codec to use, given no information */ 00996 int x; 00997 static const format_t prefs[] = 00998 { 00999 /*! Okay, ulaw is used by all telephony equipment, so start with it */ 01000 AST_FORMAT_ULAW, 01001 /*! Unless of course, you're a silly European, so then prefer ALAW */ 01002 AST_FORMAT_ALAW, 01003 AST_FORMAT_G719, 01004 AST_FORMAT_SIREN14, 01005 AST_FORMAT_SIREN7, 01006 AST_FORMAT_TESTLAW, 01007 /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */ 01008 AST_FORMAT_G722, 01009 /*! Okay, well, signed linear is easy to translate into other stuff */ 01010 AST_FORMAT_SLINEAR16, 01011 AST_FORMAT_SLINEAR, 01012 /*! G.726 is standard ADPCM, in RFC3551 packing order */ 01013 AST_FORMAT_G726, 01014 /*! G.726 is standard ADPCM, in AAL2 packing order */ 01015 AST_FORMAT_G726_AAL2, 01016 /*! ADPCM has great sound quality and is still pretty easy to translate */ 01017 AST_FORMAT_ADPCM, 01018 /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to 01019 translate and sounds pretty good */ 01020 AST_FORMAT_GSM, 01021 /*! iLBC is not too bad */ 01022 AST_FORMAT_ILBC, 01023 /*! Speex is free, but computationally more expensive than GSM */ 01024 AST_FORMAT_SPEEX16, 01025 AST_FORMAT_SPEEX, 01026 /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 01027 to use it */ 01028 AST_FORMAT_LPC10, 01029 /*! G.729a is faster than 723 and slightly less expensive */ 01030 AST_FORMAT_G729A, 01031 /*! Down to G.723.1 which is proprietary but at least designed for voice */ 01032 AST_FORMAT_G723_1, 01033 }; 01034 char buf[512]; 01035 01036 /* Strip out video */ 01037 fmts &= AST_FORMAT_AUDIO_MASK; 01038 01039 /* Find the first preferred codec in the format given */ 01040 for (x = 0; x < ARRAY_LEN(prefs); x++) { 01041 if (fmts & prefs[x]) 01042 return prefs[x]; 01043 } 01044 01045 ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts)); 01046 01047 return 0; 01048 }
struct ast_channel* ast_bridged_channel | ( | struct ast_channel * | chan | ) |
Find bridged channel.
chan | Current channel |
Definition at line 6704 of file channel.c.
References ast_channel::_bridge, ast_channel_tech::bridged_channel, chanlist::chan, 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(), schedule_delivery(), 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().
06705 { 06706 struct ast_channel *bridged; 06707 bridged = chan->_bridge; 06708 if (bridged && bridged->tech->bridged_channel) 06709 bridged = bridged->tech->bridged_channel(chan, bridged); 06710 return bridged; 06711 }
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 |
Definition at line 5451 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, chanlist::chan, 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(), and rpt().
05452 { 05453 /* Place an outgoing call, but don't wait any longer than timeout ms before returning. 05454 If the remote end does not answer within the timeout, then do NOT hang up, but 05455 return anyway. */ 05456 int res = -1; 05457 /* Stop if we're a zombie or need a soft hangup */ 05458 ast_channel_lock(chan); 05459 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 05460 if (chan->cdr) { 05461 ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED); 05462 } 05463 if (chan->tech->call) 05464 res = chan->tech->call(chan, addr, timeout); 05465 ast_set_flag(chan, AST_FLAG_OUTGOING); 05466 } 05467 ast_channel_unlock(chan); 05468 return res; 05469 }
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.
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 5100 of file channel.c.
References outgoing_helper::account, accountcode, ast_channel::accountcode, ast_call(), AST_CDR_FLAG_ORIGINATED, ast_cdr_setaccount(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_set_redirecting(), ast_channel_trylock, ast_channel_unlock, ast_channel_update_redirecting(), ast_copy_flags, ast_copy_string(), ast_hangup(), ast_log(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_request(), ast_set_callerid(), ast_set_variables(), ast_string_field_set, ast_strlen_zero(), ast_channel::call_forward, ast_channel::caller, cause, ast_channel::cdr, CHANNEL_DEADLOCK_AVOIDANCE, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, 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().
05101 { 05102 char tmpchan[256]; 05103 struct ast_channel *new = NULL; 05104 struct ast_party_redirecting *apr = &orig->redirecting; 05105 char *data, *type; 05106 int cause = 0; 05107 int res; 05108 05109 /* gather data and request the new forward channel */ 05110 ast_copy_string(tmpchan, orig->call_forward, sizeof(tmpchan)); 05111 if ((data = strchr(tmpchan, '/'))) { 05112 *data++ = '\0'; 05113 type = tmpchan; 05114 } else { 05115 const char *forward_context; 05116 ast_channel_lock(orig); 05117 forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT"); 05118 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", orig->call_forward, S_OR(forward_context, orig->context)); 05119 ast_channel_unlock(orig); 05120 data = tmpchan; 05121 type = "Local"; 05122 } 05123 if (!(new = ast_request(type, format, orig, data, &cause))) { 05124 ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause); 05125 handle_cause(cause, outstate); 05126 ast_hangup(orig); 05127 return NULL; 05128 } 05129 05130 ast_channel_set_redirecting(new, apr, NULL); 05131 05132 /* Copy/inherit important information into new channel */ 05133 if (oh) { 05134 if (oh->vars) { 05135 ast_set_variables(new, oh->vars); 05136 } 05137 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) { 05138 ast_set_callerid(new, oh->cid_num, oh->cid_name, oh->cid_num); 05139 } 05140 if (oh->parent_channel) { 05141 ast_channel_update_redirecting(oh->parent_channel, apr, NULL); 05142 ast_channel_inherit_variables(oh->parent_channel, new); 05143 ast_channel_datastore_inherit(oh->parent_channel, new); 05144 } 05145 if (oh->account) { 05146 ast_cdr_setaccount(new, oh->account); 05147 } 05148 } else if (caller) { /* no outgoing helper so use caller if avaliable */ 05149 ast_channel_update_redirecting(caller, apr, NULL); 05150 ast_channel_inherit_variables(caller, new); 05151 ast_channel_datastore_inherit(caller, new); 05152 } 05153 05154 ast_channel_lock(orig); 05155 while (ast_channel_trylock(new)) { 05156 CHANNEL_DEADLOCK_AVOIDANCE(orig); 05157 } 05158 ast_copy_flags(new->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED); 05159 ast_string_field_set(new, accountcode, orig->accountcode); 05160 ast_party_caller_copy(&new->caller, &orig->caller); 05161 ast_party_connected_line_copy(&new->connected, &orig->connected); 05162 ast_channel_unlock(new); 05163 ast_channel_unlock(orig); 05164 05165 /* call new channel */ 05166 res = ast_call(new, data, 0); 05167 if (timeout) { 05168 *timeout = res; 05169 } 05170 if (res) { 05171 ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data); 05172 ast_hangup(orig); 05173 ast_hangup(new); 05174 return NULL; 05175 } 05176 ast_hangup(orig); 05177 05178 return new; 05179 }
void ast_cancel_shutdown | ( | void | ) |
Cancel a shutdown in progress.
Cancels an existing shutdown and returns to normal operation
Definition at line 789 of file channel.c.
Referenced by handle_abort_shutdown().
00790 { 00791 shutting_down = 0; 00792 }
const char* ast_cause2str | ( | int | state | ) |
Gives the string form of a given cause code.
state | cause to get the description of |
Definition at line 910 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().
00911 { 00912 int x; 00913 00914 for (x = 0; x < ARRAY_LEN(causes); x++) { 00915 if (causes[x].cause == cause) 00916 return causes[x].desc; 00917 } 00918 00919 return "Unknown"; 00920 }
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 5886 of file channel.c.
References __ast_change_name_nolink(), ao2_link, ao2_unlink, ast_channel_lock, ast_channel_unlock, chanlist::chan, and channels.
Referenced by update_name().
05887 { 05888 /* We must re-link, as the hash value will change here. */ 05889 ao2_unlink(channels, chan); 05890 ast_channel_lock(chan); 05891 __ast_change_name_nolink(chan, newname); 05892 ast_channel_unlock(chan); 05893 ao2_link(channels, chan); 05894 }
int 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(?) |
Definition at line 7047 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_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, config, EVENT_FLAG_CALL, 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_party_id::number, ast_channel::readformat, S_COR, ast_channel_tech::send_digit_begin, ast_party_number::str, ast_channel::tech, ast_channel::uniqueid, update_bridge_vars(), ast_party_number::valid, and ast_channel::writeformat.
Referenced by ast_bridge_call().
07049 { 07050 struct ast_channel *chans[2] = { c0, c1 }; 07051 enum ast_bridge_result res = AST_BRIDGE_COMPLETE; 07052 format_t o0nativeformats; 07053 format_t o1nativeformats; 07054 long time_left_ms=0; 07055 char caller_warning = 0; 07056 char callee_warning = 0; 07057 07058 if (c0->_bridge) { 07059 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 07060 c0->name, c0->_bridge->name); 07061 return -1; 07062 } 07063 if (c1->_bridge) { 07064 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 07065 c1->name, c1->_bridge->name); 07066 return -1; 07067 } 07068 07069 /* Stop if we're a zombie or need a soft hangup */ 07070 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 07071 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 07072 return -1; 07073 07074 *fo = NULL; 07075 07076 if (ast_tvzero(config->start_time)) { 07077 config->start_time = ast_tvnow(); 07078 if (config->start_sound) { 07079 if (caller_warning) { 07080 bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000); 07081 } 07082 if (callee_warning) { 07083 bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000); 07084 } 07085 } 07086 } 07087 07088 /* Keep track of bridge */ 07089 c0->_bridge = c1; 07090 c1->_bridge = c0; 07091 07092 ast_set_owners_and_peers(c0, c1); 07093 07094 o0nativeformats = c0->nativeformats; 07095 o1nativeformats = c1->nativeformats; 07096 07097 if (config->feature_timer && !ast_tvzero(config->nexteventts)) { 07098 config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000)); 07099 } else if (config->timelimit) { 07100 time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time); 07101 caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING); 07102 callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING); 07103 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 07104 if ((caller_warning || callee_warning) && config->play_warning) { 07105 long next_warn = config->play_warning; 07106 if (time_left_ms < config->play_warning) { 07107 /* At least one warning was played, which means we are returning after feature */ 07108 long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq; 07109 /* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq', 07110 because nexteventts will be updated once again in the 'if (!to)' block */ 07111 next_warn = config->play_warning - warns_passed * config->warning_freq; 07112 } 07113 config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000)); 07114 } 07115 } else { 07116 config->nexteventts.tv_sec = 0; 07117 config->nexteventts.tv_usec = 0; 07118 } 07119 07120 if (!c0->tech->send_digit_begin) 07121 ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY); 07122 if (!c1->tech->send_digit_begin) 07123 ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY); 07124 manager_bridge_event(1, 1, c0, c1); 07125 07126 /* Before we enter in and bridge these two together tell them both the source of audio has changed */ 07127 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 07128 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 07129 07130 for (/* ever */;;) { 07131 struct timeval now = { 0, }; 07132 int to; 07133 07134 to = -1; 07135 07136 if (!ast_tvzero(config->nexteventts)) { 07137 now = ast_tvnow(); 07138 to = ast_tvdiff_ms(config->nexteventts, now); 07139 if (to <= 0) { 07140 if (!config->timelimit) { 07141 res = AST_BRIDGE_COMPLETE; 07142 break; 07143 } 07144 to = 0; 07145 } 07146 } 07147 07148 if (config->timelimit) { 07149 time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time); 07150 if (time_left_ms < to) 07151 to = time_left_ms; 07152 07153 if (time_left_ms <= 0) { 07154 if (caller_warning && config->end_sound) 07155 bridge_playfile(c0, c1, config->end_sound, 0); 07156 if (callee_warning && config->end_sound) 07157 bridge_playfile(c1, c0, config->end_sound, 0); 07158 *fo = NULL; 07159 res = 0; 07160 break; 07161 } 07162 07163 if (!to) { 07164 if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) { 07165 int t = (time_left_ms + 500) / 1000; /* round to nearest second */ 07166 if (caller_warning) 07167 bridge_playfile(c0, c1, config->warning_sound, t); 07168 if (callee_warning) 07169 bridge_playfile(c1, c0, config->warning_sound, t); 07170 } 07171 07172 if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) { 07173 config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000)); 07174 } else { 07175 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 07176 } 07177 } 07178 ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE); 07179 } 07180 07181 if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */ 07182 if (c0->_softhangup & AST_SOFTHANGUP_UNBRIDGE) { 07183 ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE); 07184 } 07185 if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) { 07186 ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE); 07187 } 07188 c0->_bridge = c1; 07189 c1->_bridge = c0; 07190 ast_debug(1, "Unbridge signal received. Ending native bridge.\n"); 07191 continue; 07192 } 07193 07194 /* Stop if we're a zombie or need a soft hangup */ 07195 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 07196 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { 07197 *fo = NULL; 07198 res = 0; 07199 ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", 07200 c0->name, c1->name, 07201 ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", 07202 ast_check_hangup(c0) ? "Yes" : "No", 07203 ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", 07204 ast_check_hangup(c1) ? "Yes" : "No"); 07205 break; 07206 } 07207 07208 update_bridge_vars(c0, c1); 07209 07210 bridge_play_sounds(c0, c1); 07211 07212 if (c0->tech->bridge && 07213 /* if < 1 ms remains use generic bridging for accurate timing */ 07214 (!config->timelimit || to > 1000 || to == 0) && 07215 (c0->tech->bridge == c1->tech->bridge) && 07216 !c0->monitor && !c1->monitor && 07217 !c0->audiohooks && !c1->audiohooks && 07218 !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) { 07219 int timeoutms = to - 1000 > 0 ? to - 1000 : to; 07220 /* Looks like they share a bridge method and nothing else is in the way */ 07221 ast_set_flag(c0, AST_FLAG_NBRIDGE); 07222 ast_set_flag(c1, AST_FLAG_NBRIDGE); 07223 if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) { 07224 ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans, 07225 "Channel1: %s\r\n" 07226 "Channel2: %s\r\n" 07227 "Uniqueid1: %s\r\n" 07228 "Uniqueid2: %s\r\n" 07229 "CallerID1: %s\r\n" 07230 "CallerID2: %s\r\n", 07231 c0->name, c1->name, 07232 c0->uniqueid, c1->uniqueid, 07233 S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"), 07234 S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>")); 07235 07236 ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); 07237 07238 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 07239 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 07240 07241 if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */ 07242 continue; 07243 } 07244 07245 c0->_bridge = NULL; 07246 c1->_bridge = NULL; 07247 return res; 07248 } else { 07249 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 07250 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 07251 } 07252 switch (res) { 07253 case AST_BRIDGE_RETRY: 07254 if (config->play_warning) { 07255 ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE); 07256 } 07257 continue; 07258 default: 07259 ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name); 07260 /* fallthrough */ 07261 case AST_BRIDGE_FAILED_NOWARN: 07262 break; 07263 } 07264 } 07265 07266 if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || 07267 (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && 07268 !(c0->generator || c1->generator)) { 07269 if (ast_channel_make_compatible(c0, c1)) { 07270 ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name); 07271 manager_bridge_event(0, 1, c0, c1); 07272 return AST_BRIDGE_FAILED; 07273 } 07274 o0nativeformats = c0->nativeformats; 07275 o1nativeformats = c1->nativeformats; 07276 } 07277 07278 update_bridge_vars(c0, c1); 07279 07280 res = ast_generic_bridge(c0, c1, config, fo, rc); 07281 if (res != AST_BRIDGE_RETRY) { 07282 break; 07283 } else if (config->feature_timer) { 07284 /* feature timer expired but has not been updated, sending to ast_bridge_call to do so */ 07285 break; 07286 } 07287 } 07288 07289 ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY); 07290 ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY); 07291 07292 /* Now that we have broken the bridge the source will change yet again */ 07293 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 07294 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 07295 07296 c0->_bridge = NULL; 07297 c1->_bridge = NULL; 07298 07299 ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans, 07300 "Channel1: %s\r\n" 07301 "Channel2: %s\r\n" 07302 "Uniqueid1: %s\r\n" 07303 "Uniqueid2: %s\r\n" 07304 "CallerID1: %s\r\n" 07305 "CallerID2: %s\r\n", 07306 c0->name, c1->name, 07307 c0->uniqueid, c1->uniqueid, 07308 S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"), 07309 S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>")); 07310 ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); 07311 07312 return res; 07313 }
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.
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 1544 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_mark(), pickup_by_part(), and state_notify_build_xml().
01546 { 01547 return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data); 01548 }
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.
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 9192 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, cc_channel_datastore_info, and ast_datastore::data.
Referenced by ast_channel_get_cc_config_params(), dahdi_new(), local_call(), local_request(), and sip_new().
09194 { 09195 struct ast_cc_config_params *cc_params; 09196 struct ast_datastore *cc_datastore; 09197 09198 if (!(cc_params = ast_cc_config_params_init())) { 09199 return -1; 09200 } 09201 09202 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) { 09203 ast_cc_config_params_destroy(cc_params); 09204 return -1; 09205 } 09206 09207 if (base_params) { 09208 ast_cc_copy_config_params(cc_params, base_params); 09209 } 09210 cc_datastore->data = cc_params; 09211 ast_channel_datastore_add(chan, cc_datastore); 09212 return 0; 09213 }
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 2602 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, chanlist::chan, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::readq, and ast_frame::subclass.
Referenced by __ast_pbx_run(), ast_channel_bridge(), check_goto_on_transfer(), and collect_digits().
02603 { 02604 ast_channel_lock(chan); 02605 02606 chan->_softhangup &= ~flag; 02607 02608 if (!chan->_softhangup) { 02609 struct ast_frame *fr; 02610 02611 /* If we have completely cleared the softhangup flag, 02612 * then we need to fully abort the hangup process. This requires 02613 * pulling the END_OF_Q frame out of the channel frame queue if it 02614 * still happens to be there. */ 02615 02616 fr = AST_LIST_LAST(&chan->readq); 02617 if (fr && fr->frametype == AST_FRAME_CONTROL && 02618 fr->subclass.integer == AST_CONTROL_END_OF_Q) { 02619 AST_LIST_REMOVE(&chan->readq, fr, frame_list); 02620 ast_frfree(fr); 02621 } 02622 } 02623 02624 ast_channel_unlock(chan); 02625 }
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 |
Definition at line 830 of file channel.c.
References ast_channel_cmpwhentohangup_tv(), and chanlist::chan.
00831 { 00832 struct timeval when = { offset, }; 00833 return ast_channel_cmpwhentohangup_tv(chan, when); 00834 }
int ast_channel_cmpwhentohangup_tv | ( | struct ast_channel * | chan, | |
struct timeval | offset | |||
) |
Compare a offset with the settings of when to hang a channel up.
chan | channel on which to check for hangup | |
offset | offset in seconds and microseconds from current time |
Definition at line 815 of file channel.c.
References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), chanlist::chan, and ast_channel::whentohangup.
Referenced by ast_channel_cmpwhentohangup().
00816 { 00817 struct timeval whentohangup; 00818 00819 if (ast_tvzero(chan->whentohangup)) 00820 return ast_tvzero(offset) ? 0 : -1; 00821 00822 if (ast_tvzero(offset)) 00823 return 1; 00824 00825 whentohangup = ast_tvadd(offset, ast_tvnow()); 00826 00827 return ast_tvdiff_ms(whentohangup, chan->whentohangup); 00828 }
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 |
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 9090 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(), ast_channel::connected, 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_pickup_call(), atxfer_fail_cleanup(), builtin_atxfer(), builtin_blindtransfer(), feature_request_and_dial(), handle_frame(), pickup_do(), remote_bridge_loop(), and wait_for_answer().
09091 { 09092 const char *macro; 09093 const char *macro_args; 09094 int retval; 09095 09096 ast_channel_lock(macro_chan); 09097 macro = pbx_builtin_getvar_helper(macro_chan, is_caller 09098 ? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO"); 09099 macro = ast_strdupa(S_OR(macro, "")); 09100 macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller 09101 ? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS"); 09102 macro_args = ast_strdupa(S_OR(macro_args, "")); 09103 09104 if (ast_strlen_zero(macro)) { 09105 ast_channel_unlock(macro_chan); 09106 return -1; 09107 } 09108 09109 if (is_frame) { 09110 const struct ast_frame *frame = connected_info; 09111 09112 ast_connected_line_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->connected); 09113 } else { 09114 const struct ast_party_connected_line *connected = connected_info; 09115 09116 ast_party_connected_line_copy(¯o_chan->connected, connected); 09117 } 09118 ast_channel_unlock(macro_chan); 09119 09120 if (!(retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args))) { 09121 ast_channel_lock(macro_chan); 09122 ast_channel_update_connected_line(macro_chan, ¯o_chan->connected, NULL); 09123 ast_channel_unlock(macro_chan); 09124 } 09125 09126 return retval; 09127 }
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 343 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, chanlist::chan, 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().
00345 { 00346 struct ast_channel *bc; 00347 struct ast_data *data_bridged; 00348 struct ast_data *data_cdr; 00349 struct ast_data *data_flags; 00350 struct ast_data *data_zones; 00351 struct ast_data *enum_node; 00352 struct ast_data *data_softhangup; 00353 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */ 00354 struct ast_data *data_callerid; 00355 char value_str[100]; 00356 #endif 00357 00358 if (!tree) { 00359 return -1; 00360 } 00361 00362 ast_data_add_structure(ast_channel, tree, chan); 00363 00364 if (add_bridged) { 00365 bc = ast_bridged_channel(chan); 00366 if (bc) { 00367 data_bridged = ast_data_add_node(tree, "bridged"); 00368 if (!data_bridged) { 00369 return -1; 00370 } 00371 ast_channel_data_add_structure(data_bridged, bc, 0); 00372 } 00373 } 00374 00375 ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat); 00376 ast_data_add_codecs(tree, "nativeformats", chan->nativeformats); 00377 ast_data_add_codecs(tree, "readformat", chan->readformat); 00378 ast_data_add_codecs(tree, "writeformat", chan->writeformat); 00379 ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat); 00380 ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat); 00381 00382 /* state */ 00383 enum_node = ast_data_add_node(tree, "state"); 00384 if (!enum_node) { 00385 return -1; 00386 } 00387 ast_data_add_str(enum_node, "text", ast_state2str(chan->_state)); 00388 ast_data_add_int(enum_node, "value", chan->_state); 00389 00390 /* hangupcause */ 00391 enum_node = ast_data_add_node(tree, "hangupcause"); 00392 if (!enum_node) { 00393 return -1; 00394 } 00395 ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause)); 00396 ast_data_add_int(enum_node, "value", chan->hangupcause); 00397 00398 /* amaflags */ 00399 enum_node = ast_data_add_node(tree, "amaflags"); 00400 if (!enum_node) { 00401 return -1; 00402 } 00403 ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags)); 00404 ast_data_add_int(enum_node, "value", chan->amaflags); 00405 00406 /* transfercapability */ 00407 enum_node = ast_data_add_node(tree, "transfercapability"); 00408 if (!enum_node) { 00409 return -1; 00410 } 00411 ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability)); 00412 ast_data_add_int(enum_node, "value", chan->transfercapability); 00413 00414 /* _softphangup */ 00415 data_softhangup = ast_data_add_node(tree, "softhangup"); 00416 if (!data_softhangup) { 00417 return -1; 00418 } 00419 ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV); 00420 ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO); 00421 ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN); 00422 ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT); 00423 ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD); 00424 ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT); 00425 ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE); 00426 00427 /* channel flags */ 00428 data_flags = ast_data_add_node(tree, "flags"); 00429 if (!data_flags) { 00430 return -1; 00431 } 00432 channel_data_add_flags(data_flags, chan); 00433 00434 ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec); 00435 00436 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */ 00437 /* callerid */ 00438 data_callerid = ast_data_add_node(tree, "callerid"); 00439 if (!data_callerid) { 00440 return -1; 00441 } 00442 ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid)); 00443 /* insert the callerid ton */ 00444 enum_node = ast_data_add_node(data_callerid, "cid_ton"); 00445 if (!enum_node) { 00446 return -1; 00447 } 00448 ast_data_add_int(enum_node, "value", chan->cid.cid_ton); 00449 snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s", 00450 party_number_ton2str(chan->cid.cid_ton), 00451 party_number_plan2str(chan->cid.cid_ton)); 00452 ast_data_add_str(enum_node, "text", value_str); 00453 #endif 00454 00455 /* tone zone */ 00456 if (chan->zone) { 00457 data_zones = ast_data_add_node(tree, "zone"); 00458 if (!data_zones) { 00459 return -1; 00460 } 00461 ast_tone_zone_data_add_structure(data_zones, chan->zone); 00462 } 00463 00464 /* insert cdr */ 00465 data_cdr = ast_data_add_node(tree, "cdr"); 00466 if (!data_cdr) { 00467 return -1; 00468 } 00469 00470 ast_cdr_data_add_structure(data_cdr, chan->cdr, 1); 00471 00472 return 0; 00473 }
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 475 of file channel.c.
References ast_data_search_cmp_structure, and chanlist::chan.
00477 { 00478 return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name); 00479 }
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 2484 of file channel.c.
References AST_LIST_INSERT_HEAD, chanlist::chan, ast_channel::datastores, and ast_datastore::entry.
Referenced by __ast_channel_masquerade(), _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), add_features_datastores(), add_to_agi(), apply_plc(), ast_channel_cc_params_init(), 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(), pbx_builtin_raise_exception(), pitchshift_helper(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), srv_datastore_setup(), and volume_write().
02485 { 02486 int res = 0; 02487 02488 AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry); 02489 02490 return res; 02491 }
struct ast_datastore* attribute_malloc ast_channel_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
const char * | uid | |||
) |
Create a channel data store object.
Definition at line 2457 of file channel.c.
References ast_datastore_alloc, and ast_datastore::info.
02458 { 02459 return ast_datastore_alloc(info, uid); 02460 }
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.
The datastore returned from this function must not be used if the reference to the channel is released.
pointer | to the datastore if found | |
NULL | if not found |
Definition at line 2498 of file channel.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, chanlist::chan, ast_channel::datastores, ast_datastore::entry, 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(), add_agi_cmd(), add_features_datastores(), add_to_agi(), apply_plc(), 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(), 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_parkinglot(), manager_mutestream(), mark_transaction_active(), mute_callback(), park_exec_full(), pbx_builtin_raise_exception(), pitchshift_cb(), pitchshift_helper(), pop_exec(), queue_transfer_fixup(), 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().
02499 { 02500 struct ast_datastore *datastore = NULL; 02501 02502 if (info == NULL) 02503 return NULL; 02504 02505 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore, entry) { 02506 if (datastore->info != info) { 02507 continue; 02508 } 02509 02510 if (uid == NULL) { 02511 /* matched by type only */ 02512 break; 02513 } 02514 02515 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) { 02516 /* Matched by type AND uid */ 02517 break; 02518 } 02519 } 02520 AST_LIST_TRAVERSE_SAFE_END; 02521 02522 return datastore; 02523 }
int ast_channel_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a channel data store object.
Definition at line 2462 of file channel.c.
References ast_datastore_free().
02463 { 02464 return ast_datastore_free(datastore); 02465 }
int ast_channel_datastore_inherit | ( | struct ast_channel * | from, | |
struct ast_channel * | to | |||
) |
Inherit datastores from a parent to a child.
Definition at line 2467 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::entry, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.
Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), do_forward(), findmeexec(), local_call(), and ring_entry().
02468 { 02469 struct ast_datastore *datastore = NULL, *datastore2; 02470 02471 AST_LIST_TRAVERSE(&from->datastores, datastore, entry) { 02472 if (datastore->inheritance > 0) { 02473 datastore2 = ast_datastore_alloc(datastore->info, datastore->uid); 02474 if (datastore2) { 02475 datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL; 02476 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1; 02477 AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry); 02478 } 02479 } 02480 } 02481 return 0; 02482 }
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 2493 of file channel.c.
References AST_LIST_REMOVE, chanlist::chan, ast_channel::datastores, and ast_datastore::entry.
Referenced by acf_fetch(), adjust_frame_for_plc(), ast_do_masquerade(), 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(), and stop_mixmonitor_exec().
02494 { 02495 return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1; 02496 }
int ast_channel_defer_dtmf | ( | struct ast_channel * | chan | ) |
Defers DTMF so that you only read things like hangups and audio.
Definition at line 1526 of file channel.c.
References AST_FLAG_DEFER_DTMF, ast_set_flag, ast_test_flag, and chanlist::chan.
Referenced by find_cache().
01527 { 01528 int pre = 0; 01529 01530 if (chan) { 01531 pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF); 01532 ast_set_flag(chan, AST_FLAG_DEFER_DTMF); 01533 } 01534 return pre; 01535 }
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 |
Definition at line 6947 of file channel.c.
References ast_channel_tech::early_bridge, and ast_channel::tech.
Referenced by dial_exec_full().
06948 { 06949 /* Make sure we can early bridge, if not error out */ 06950 if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge))) 06951 return -1; 06952 06953 return c0->tech->early_bridge(c0, c1); 06954 }
struct ast_channel* ast_channel_get_by_exten | ( | const char * | exten, | |
const char * | context | |||
) |
Find a channel by extension and context.
a | channel that is at the specified extension and context | |
NULL | if no channel was found |
Definition at line 1723 of file channel.c.
References ast_channel_get_full().
01724 { 01725 return ast_channel_get_full(NULL, 0, exten, context); 01726 }
struct ast_channel* ast_channel_get_by_name | ( | const char * | name | ) |
Find a channel by name.
a | channel with the name specified by the argument | |
NULL | if no channel was found |
Definition at line 1713 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().
01714 { 01715 return ast_channel_get_full(name, 0, NULL, NULL); 01716 }
struct ast_channel* ast_channel_get_by_name_prefix | ( | const char * | name, | |
size_t | name_len | |||
) |
Find a channel by a name prefix.
a | channel with the name prefix specified by the arguments | |
NULL | if no channel was found |
Definition at line 1718 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().
01719 { 01720 return ast_channel_get_full(name, name_len, NULL, NULL); 01721 }
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.
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 9254 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().
09255 { 09256 int len = size; 09257 char *slash; 09258 09259 if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) { 09260 return 0; 09261 } 09262 09263 ast_copy_string(agent_type, chan->name, size); 09264 if ((slash = strchr(agent_type, '/'))) { 09265 *slash = '\0'; 09266 } 09267 return 0; 09268 }
struct ast_cc_config_params* ast_channel_get_cc_config_params | ( | struct ast_channel * | chan | ) |
Get the CCSS parameters from a channel.
chan | Channel to retrieve parameters from |
NULL | Failure | |
non-NULL | The parameters desired |
Definition at line 9215 of file channel.c.
References ast_assert, ast_channel_cc_params_init(), ast_channel_datastore_find(), cc_channel_datastore_info, 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(), and sig_pri_cc_generic_check().
09216 { 09217 struct ast_datastore *cc_datastore; 09218 09219 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) { 09220 /* If we can't find the datastore, it almost definitely means that the channel type being 09221 * used has not had its driver modified to parse CC config parameters. The best action 09222 * to take here is to create the parameters on the spot with the defaults set. 09223 */ 09224 if (ast_channel_cc_params_init(chan, NULL)) { 09225 return NULL; 09226 } 09227 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) { 09228 /* Should be impossible */ 09229 return NULL; 09230 } 09231 } 09232 09233 ast_assert(cc_datastore->data != NULL); 09234 return cc_datastore->data; 09235 }
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.
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 9237 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_generic_check(), sip_call(), and sip_handle_cc().
09238 { 09239 int len = name_buffer_length; 09240 char *dash; 09241 if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) { 09242 return 0; 09243 } 09244 09245 /* Dang. Do it the old-fashioned way */ 09246 ast_copy_string(device_name, chan->name, name_buffer_length); 09247 if ((dash = strrchr(device_name, '-'))) { 09248 *dash = '\0'; 09249 } 09250 09251 return 0; 09252 }
static enum ast_t38_state ast_channel_get_t38_state | ( | struct ast_channel * | chan | ) | [inline, static] |
Retrieves the current T38 state of a channel.
Definition at line 2343 of file channel.h.
References ast_channel_queryoption(), AST_OPTION_T38_STATE, and T38_STATE_UNAVAILABLE.
Referenced by generic_fax_exec(), receivefax_exec(), receivefax_t38_init(), sendfax_exec(), sendfax_t38_init(), set_fax_t38_caps(), transmit(), transmit_audio(), and transmit_t38().
02344 { 02345 enum ast_t38_state state = T38_STATE_UNAVAILABLE; 02346 int datalen = sizeof(state); 02347 02348 ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0); 02349 02350 return state; 02351 }
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 |
Definition at line 5896 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(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), and ring_entry().
05897 { 05898 struct ast_var_t *current, *newvar; 05899 const char *varname; 05900 05901 AST_LIST_TRAVERSE(&parent->varshead, current, entries) { 05902 int vartype = 0; 05903 05904 varname = ast_var_full_name(current); 05905 if (!varname) 05906 continue; 05907 05908 if (varname[0] == '_') { 05909 vartype = 1; 05910 if (varname[1] == '_') 05911 vartype = 2; 05912 } 05913 05914 switch (vartype) { 05915 case 1: 05916 newvar = ast_var_assign(&varname[1], ast_var_value(current)); 05917 if (newvar) { 05918 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 05919 ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); 05920 } 05921 break; 05922 case 2: 05923 newvar = ast_var_assign(varname, ast_var_value(current)); 05924 if (newvar) { 05925 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 05926 ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); 05927 } 05928 break; 05929 default: 05930 ast_debug(1, "Not copying variable %s.\n", ast_var_name(current)); 05931 break; 05932 } 05933 } 05934 }
struct ast_channel_iterator* ast_channel_iterator_all_new | ( | void | ) |
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 1611 of file channel.c.
References 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().
01612 { 01613 struct ast_channel_iterator *i; 01614 01615 if (!(i = ast_calloc(1, sizeof(*i)))) { 01616 return NULL; 01617 } 01618 01619 i->simple_iterator = ao2_iterator_init(channels, 0); 01620 i->active_iterator = &i->simple_iterator; 01621 01622 return i; 01623 }
struct ast_channel_iterator* ast_channel_iterator_by_exten_new | ( | const char * | exten, | |
const char * | context | |||
) |
Create a new channel iterator based on extension.
NULL | on failure | |
a | new channel iterator based on the specified parameters |
Definition at line 1601 of file channel.c.
References channel_iterator_search().
Referenced by common_exec(), and pickup_by_exten().
01602 { 01603 return channel_iterator_search(NULL, 0, exten, context); 01604 }
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.
NULL | on failure | |
a | new channel iterator based on the specified parameters |
Definition at line 1606 of file channel.c.
References channel_iterator_search().
Referenced by ast_complete_channels(), common_exec(), and softhangup_exec().
01607 { 01608 return channel_iterator_search(name, name_len, NULL, NULL); 01609 }
struct ast_channel_iterator* ast_channel_iterator_destroy | ( | struct ast_channel_iterator * | i | ) |
Destroy a channel iterator.
Definition at line 1559 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_iterator_destroy(), and ast_free.
Referenced by action_coreshowchannels(), 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().
01560 { 01561 ao2_iterator_destroy(i->active_iterator); 01562 ast_free(i); 01563 01564 return NULL; 01565 }
struct ast_channel* ast_channel_iterator_next | ( | struct ast_channel_iterator * | i | ) |
Get the next channel for a channel iterator.
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 1625 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().
01626 { 01627 return ao2_iterator_next(i->active_iterator); 01628 }
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 |
Definition at line 5660 of file channel.c.
References ast_channel_make_compatible_helper(), and chanlist::chan.
Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), multiplexed_bridge_join(), park_exec_full(), simple_bridge_join(), and wait_for_answer().
05661 { 05662 /* Some callers do not check return code, and we must try to set all call legs correctly */ 05663 int rc = 0; 05664 05665 /* Set up translation from the chan to the peer */ 05666 rc = ast_channel_make_compatible_helper(chan, peer); 05667 05668 if (rc < 0) 05669 return rc; 05670 05671 /* Set up translation from the peer to the chan */ 05672 rc = ast_channel_make_compatible_helper(peer, chan); 05673 05674 return rc; 05675 }
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 |
Definition at line 5767 of file channel.c.
References __ast_channel_masquerade().
Referenced by ast_async_goto(), ast_pickup_call(), attempt_transfer(), builtin_atxfer(), check_availability(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), masq_park_call(), pickup_do(), sip_park(), and skinny_transfer().
05768 { 05769 return __ast_channel_masquerade(original, clone, NULL); 05770 }
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 7329 of file channel.c.
References ast_log(), chanlist::chan, 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().
07330 { 07331 if (!chan->tech->queryoption) { 07332 errno = ENOSYS; 07333 return -1; 07334 } 07335 07336 if (block) 07337 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 07338 07339 return chan->tech->queryoption(chan, option, data, datalen); 07340 }
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 8570 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, ast_queue_control_data(), connected, and update().
Referenced by ast_pickup_call(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), masquerade_colp_transfer(), misdn_queue_connected_line_update(), pickup_do(), and sig_pri_handle_subcmds().
08571 { 08572 unsigned char data[1024]; /* This should be large enough */ 08573 size_t datalen; 08574 08575 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update); 08576 if (datalen == (size_t) -1) { 08577 return; 08578 } 08579 08580 ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen); 08581 }
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 9077 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_queue_control_data(), ast_redirecting_build_data(), and update().
Referenced by cb_events(), handle_response_invite(), misdn_facility_ie_handler(), and sig_pri_handle_subcmds().
09078 { 09079 unsigned char data[1024]; /* This should be large enough */ 09080 size_t datalen; 09081 09082 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update); 09083 if (datalen == (size_t) -1) { 09084 return; 09085 } 09086 09087 ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen); 09088 }
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 5064 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().
05065 { 05066 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */ 05067 { 05068 case 0: 05069 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)"; 05070 case AST_CONTROL_HANGUP: 05071 return "Hangup"; 05072 case AST_CONTROL_RING: 05073 return "Local Ring"; 05074 case AST_CONTROL_RINGING: 05075 return "Remote end Ringing"; 05076 case AST_CONTROL_ANSWER: 05077 return "Remote end has Answered"; 05078 case AST_CONTROL_BUSY: 05079 return "Remote end is Busy"; 05080 case AST_CONTROL_CONGESTION: 05081 return "Congestion (circuits busy)"; 05082 default: 05083 return "Unknown Reason!!"; 05084 } 05085 }
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.
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 |
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 9129 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(), do_forward(), feature_request_and_dial(), handle_frame(), and remote_bridge_loop().
09130 { 09131 const char *macro; 09132 const char *macro_args; 09133 int retval; 09134 09135 ast_channel_lock(macro_chan); 09136 macro = pbx_builtin_getvar_helper(macro_chan, is_caller 09137 ? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO"); 09138 macro = ast_strdupa(S_OR(macro, "")); 09139 macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller 09140 ? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS"); 09141 macro_args = ast_strdupa(S_OR(macro_args, "")); 09142 09143 if (ast_strlen_zero(macro)) { 09144 ast_channel_unlock(macro_chan); 09145 return -1; 09146 } 09147 09148 if (is_frame) { 09149 const struct ast_frame *frame = redirecting_info; 09150 09151 ast_redirecting_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->redirecting); 09152 } else { 09153 const struct ast_party_redirecting *redirecting = redirecting_info; 09154 09155 ast_party_redirecting_copy(¯o_chan->redirecting, redirecting); 09156 } 09157 ast_channel_unlock(macro_chan); 09158 09159 retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args); 09160 if (!retval) { 09161 ast_channel_lock(macro_chan); 09162 ast_channel_update_redirecting(macro_chan, ¯o_chan->redirecting, NULL); 09163 ast_channel_unlock(macro_chan); 09164 } 09165 09166 return retval; 09167 }
int ast_channel_register | ( | const struct ast_channel_tech * | tech | ) |
Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.
tech | Structure defining channel technology or "type" |
Definition at line 837 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, chanlist::list, LOG_WARNING, chanlist::tech, ast_channel::tech, and ast_channel_tech::type.
Referenced by load_module(), and unload_module().
00838 { 00839 struct chanlist *chan; 00840 00841 AST_RWLIST_WRLOCK(&backends); 00842 00843 AST_RWLIST_TRAVERSE(&backends, chan, list) { 00844 if (!strcasecmp(tech->type, chan->tech->type)) { 00845 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type); 00846 AST_RWLIST_UNLOCK(&backends); 00847 return -1; 00848 } 00849 } 00850 00851 if (!(chan = ast_calloc(1, sizeof(*chan)))) { 00852 AST_RWLIST_UNLOCK(&backends); 00853 return -1; 00854 } 00855 chan->tech = tech; 00856 AST_RWLIST_INSERT_HEAD(&backends, chan, list); 00857 00858 ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); 00859 00860 ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description); 00861 00862 AST_RWLIST_UNLOCK(&backends); 00863 00864 return 0; 00865 }
struct ast_channel* ast_channel_release | ( | struct ast_channel * | chan | ) |
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 1827 of file channel.c.
References ao2_unlink, ast_channel_unref, chanlist::chan, and channels.
Referenced by acf_odbc_read(), acf_odbc_write(), action_getvar(), agent_cleanup(), agent_new(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_do_masquerade(), ast_hangup(), ast_iax2_new(), ast_pbx_outgoing_cdr_failed(), ast_request(), ast_str_substitute_variables_full(), bridge_request(), custom_log(), do_notify(), gtalk_newcall(), local_new(), local_request(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), syslog_log(), and write_cdr().
01828 { 01829 /* Safe, even if already unlinked. */ 01830 ao2_unlink(channels, chan); 01831 return ast_channel_unref(chan); 01832 }
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 5597 of file channel.c.
References chanlist::chan, ast_channel_tech::send_html, and ast_channel::tech.
Referenced by agent_sendhtml(), and ast_channel_sendurl().
05598 { 05599 if (chan->tech->send_html) 05600 return chan->tech->send_html(chan, subclass, data, datalen); 05601 return -1; 05602 }
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 5604 of file channel.c.
References ast_channel_sendhtml(), AST_HTML_URL, and chanlist::chan.
Referenced by dial_exec_full(), and sendurl_exec().
05605 { 05606 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1); 05607 }
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 6630 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, chanlist::chan, and update().
06631 { 06632 if (&chan->caller == caller) { 06633 /* Don't set to self */ 06634 return; 06635 } 06636 06637 ast_channel_lock(chan); 06638 ast_party_caller_set(&chan->caller, caller, update); 06639 ast_channel_unlock(chan); 06640 }
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 6642 of file channel.c.
References ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, ast_channel::cdr, chanlist::chan, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), S_COR, ast_party_number::str, ast_party_name::str, update(), ast_party_number::valid, and ast_party_name::valid.
Referenced by callerid_write(), dial_exec_full(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().
06643 { 06644 struct ast_party_caller pre_set; 06645 06646 if (&chan->caller == caller) { 06647 /* Don't set to self */ 06648 return; 06649 } 06650 06651 ast_channel_lock(chan); 06652 pre_set = chan->caller; 06653 ast_party_caller_set(&chan->caller, caller, update); 06654 if (S_COR(pre_set.id.number.valid, pre_set.id.number.str, NULL) 06655 != S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL) 06656 || S_COR(pre_set.id.name.valid, pre_set.id.name.str, NULL) 06657 != S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL)) { 06658 /* The caller id name or number changed. */ 06659 report_new_callerid(chan); 06660 } 06661 if (chan->cdr) { 06662 ast_cdr_setcid(chan->cdr, chan); 06663 } 06664 ast_channel_unlock(chan); 06665 }
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 7930 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_connected_line_set(), ast_channel::connected, connected, and update().
Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), and feature_request_and_dial().
07931 { 07932 if (&chan->connected == connected) { 07933 /* Don't set to self */ 07934 return; 07935 } 07936 07937 ast_channel_lock(chan); 07938 ast_party_connected_line_set(&chan->connected, connected, update); 07939 ast_channel_unlock(chan); 07940 }
void ast_channel_set_fd | ( | struct ast_channel * | chan, | |
int | which, | |||
int | fd | |||
) |
Set the file descriptor on the channel
Definition at line 2526 of file channel.c.
References ast_calloc, chanlist::chan, ast_channel::data, ast_channel::fds, and free.
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(), setformat(), sip_new(), skinny_new(), start_rtp(), and swap_subs().
02527 { 02528 #ifdef HAVE_EPOLL 02529 struct epoll_event ev; 02530 struct ast_epoll_data *aed = NULL; 02531 02532 if (chan->fds[which] > -1) { 02533 epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev); 02534 aed = chan->epfd_data[which]; 02535 } 02536 02537 /* If this new fd is valid, add it to the epoll */ 02538 if (fd > -1) { 02539 if (!aed && (!(aed = ast_calloc(1, sizeof(*aed))))) 02540 return; 02541 02542 chan->epfd_data[which] = aed; 02543 aed->chan = chan; 02544 aed->which = which; 02545 02546 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 02547 ev.data.ptr = aed; 02548 epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev); 02549 } else if (aed) { 02550 /* We don't have to keep around this epoll data structure now */ 02551 free(aed); 02552 chan->epfd_data[which] = NULL; 02553 } 02554 #endif 02555 chan->fds[which] = fd; 02556 return; 02557 }
void ast_channel_set_linkgroup | ( | struct ast_channel * | chan, | |
struct ast_channel * | peer | |||
) |
propagate the linked id between chan and peer
Definition at line 6040 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_change_linkedid(), ast_strdupa, chanlist::chan, ast_channel::linkedid, oldest_linkedid(), and ast_channel::uniqueid.
Referenced by ast_bridge_call(), and ast_do_masquerade().
06041 { 06042 const char* linkedid=NULL; 06043 struct ast_channel *bridged; 06044 06045 linkedid = oldest_linkedid(chan->linkedid, peer->linkedid); 06046 linkedid = oldest_linkedid(linkedid, chan->uniqueid); 06047 linkedid = oldest_linkedid(linkedid, peer->uniqueid); 06048 if (chan->_bridge) { 06049 bridged = ast_bridged_channel(chan); 06050 if (bridged != peer) { 06051 linkedid = oldest_linkedid(linkedid, bridged->linkedid); 06052 linkedid = oldest_linkedid(linkedid, bridged->uniqueid); 06053 } 06054 } 06055 if (peer->_bridge) { 06056 bridged = ast_bridged_channel(peer); 06057 if (bridged != chan) { 06058 linkedid = oldest_linkedid(linkedid, bridged->linkedid); 06059 linkedid = oldest_linkedid(linkedid, bridged->uniqueid); 06060 } 06061 } 06062 06063 /* just in case setting a stringfield to itself causes problems */ 06064 linkedid = ast_strdupa(linkedid); 06065 06066 ast_channel_change_linkedid(chan, linkedid); 06067 ast_channel_change_linkedid(peer, linkedid); 06068 if (chan->_bridge) { 06069 bridged = ast_bridged_channel(chan); 06070 if (bridged != peer) { 06071 ast_channel_change_linkedid(bridged, linkedid); 06072 } 06073 } 06074 if (peer->_bridge) { 06075 bridged = ast_bridged_channel(peer); 06076 if (bridged != chan) { 06077 ast_channel_change_linkedid(bridged, linkedid); 06078 } 06079 } 06080 }
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 8583 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_redirecting_set(), ast_channel::redirecting, and update().
Referenced by ast_call_forward(), ast_indicate_data(), do_forward(), handle_request_invite(), handle_response(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_handle_subcmds().
08584 { 08585 if (&chan->redirecting == redirecting) { 08586 /* Don't set to self */ 08587 return; 08588 } 08589 08590 ast_channel_lock(chan); 08591 ast_party_redirecting_set(&chan->redirecting, redirecting, update); 08592 ast_channel_unlock(chan); 08593 }
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 |
Definition at line 7316 of file channel.c.
References ast_log(), chanlist::chan, 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(), and vm_forwardoptions().
07317 { 07318 if (!chan->tech->setoption) { 07319 errno = ENOSYS; 07320 return -1; 07321 } 07322 07323 if (block) 07324 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 07325 07326 return chan->tech->setoption(chan, option, data, datalen); 07327 }
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 |
Definition at line 808 of file channel.c.
References ast_channel_setwhentohangup_tv(), and chanlist::chan.
00809 { 00810 struct timeval when = { offset, }; 00811 ast_channel_setwhentohangup_tv(chan, when); 00812 }
void ast_channel_setwhentohangup_tv | ( | struct ast_channel * | chan, | |
struct timeval | offset | |||
) |
Set when to hang a channel up.
chan | channel on which to check for hang up | |
offset | offset in seconds and useconds relative to the current time of when to hang up |
Definition at line 801 of file channel.c.
References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), chanlist::chan, and ast_channel::whentohangup.
Referenced by action_timeout(), ast_channel_setwhentohangup(), handle_autohangup(), and timeout_write().
00802 { 00803 chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow()); 00804 ast_queue_frame(chan, &ast_null_frame); 00805 return; 00806 }
struct ast_silence_generator* ast_channel_start_silence_generator | ( | struct ast_channel * | chan | ) |
Starts a silence generator on the given channel.
chan | The channel to generate silence on |
Definition at line 7804 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, silence_generator, state, and ast_channel::writeformat.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), TransferCallStep1(), waitfor_exec(), and waitforring_exec().
07805 { 07806 struct ast_silence_generator *state; 07807 07808 if (!(state = ast_calloc(1, sizeof(*state)))) { 07809 return NULL; 07810 } 07811 07812 state->old_write_format = chan->writeformat; 07813 07814 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 07815 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); 07816 ast_free(state); 07817 return NULL; 07818 } 07819 07820 ast_activate_generator(chan, &silence_generator, state); 07821 07822 ast_debug(1, "Started silence generator on '%s'\n", chan->name); 07823 07824 return state; 07825 }
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. |
Definition at line 7827 of file channel.c.
References ast_deactivate_generator(), ast_debug, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, and state.
Referenced by ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), HandleCallOutgoing(), key_dial_page(), unistim_hangup(), waitfor_exec(), and waitforring_exec().
07828 { 07829 if (!state) 07830 return; 07831 07832 ast_deactivate_generator(chan); 07833 07834 ast_debug(1, "Stopped silence generator on '%s'\n", chan->name); 07835 07836 if (ast_set_write_format(chan, state->old_write_format) < 0) 07837 ast_log(LOG_ERROR, "Could not return write format to its original state\n"); 07838 07839 ast_free(state); 07840 }
int ast_channel_supports_html | ( | struct ast_channel * | channel | ) |
Checks for HTML support on a channel.
Definition at line 5592 of file channel.c.
References chanlist::chan, ast_channel_tech::send_html, and ast_channel::tech.
Referenced by dial_exec_full(), and sendurl_exec().
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 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 5841 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_id, xfer_masquerade_ds::transferee_id, and xfer_ds_info.
Referenced by analog_attempt_transfer(), misdn_attempt_transfer(), and sig_pri_attempt_transfer().
05848 { 05849 struct ast_datastore *xfer_ds; 05850 struct xfer_masquerade_ds *xfer_colp; 05851 int res; 05852 05853 xfer_ds = ast_datastore_alloc(&xfer_ds_info, NULL); 05854 if (!xfer_ds) { 05855 return -1; 05856 } 05857 05858 xfer_colp = ast_calloc(1, sizeof(*xfer_colp)); 05859 if (!xfer_colp) { 05860 ast_datastore_free(xfer_ds); 05861 return -1; 05862 } 05863 party_connected_line_copy_transfer(&xfer_colp->target_id, target_id); 05864 xfer_colp->target_held = target_held; 05865 party_connected_line_copy_transfer(&xfer_colp->transferee_id, transferee_id); 05866 xfer_colp->transferee_held = transferee_held; 05867 xfer_ds->data = xfer_colp; 05868 05869 res = __ast_channel_masquerade(target_chan, transferee_chan, xfer_ds); 05870 if (res) { 05871 ast_datastore_free(xfer_ds); 05872 } 05873 return res; 05874 }
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 1538 of file channel.c.
References ast_clear_flag, AST_FLAG_DEFER_DTMF, and chanlist::chan.
Referenced by find_cache(), and rpt_call().
01539 { 01540 if (chan) 01541 ast_clear_flag(chan, AST_FLAG_DEFER_DTMF); 01542 }
void ast_channel_unregister | ( | const struct ast_channel_tech * | tech | ) |
Unregister a channel technology.
tech | Structure defining channel technology or "type" that was previously registered |
Definition at line 868 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::list, chanlist::tech, ast_channel::tech, and ast_channel_tech::type.
Referenced by __unload_module(), load_module(), and unload_module().
00869 { 00870 struct chanlist *chan; 00871 00872 ast_debug(1, "Unregistering channel type '%s'\n", tech->type); 00873 00874 AST_RWLIST_WRLOCK(&backends); 00875 00876 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { 00877 if (chan->tech == tech) { 00878 AST_LIST_REMOVE_CURRENT(list); 00879 ast_free(chan); 00880 ast_verb(2, "Unregistered channel type '%s'\n", tech->type); 00881 break; 00882 } 00883 } 00884 AST_LIST_TRAVERSE_SAFE_END; 00885 00886 AST_RWLIST_UNLOCK(&backends); 00887 }
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 8557 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, ast_indicate_data(), connected, and update().
Referenced by ast_channel_connected_line_macro(), ast_pickup_call(), atxfer_fail_cleanup(), builtin_atxfer(), builtin_blindtransfer(), connectedline_write(), pickup_do(), and wait_for_answer().
08558 { 08559 unsigned char data[1024]; /* This should be large enough */ 08560 size_t datalen; 08561 08562 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update); 08563 if (datalen == (size_t) -1) { 08564 return; 08565 } 08566 08567 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen); 08568 }
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 9064 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_indicate_data(), ast_redirecting_build_data(), and update().
Referenced by ast_call_forward(), ast_channel_redirecting_macro(), do_forward(), and redirecting_write().
09065 { 09066 unsigned char data[1024]; /* This should be large enough */ 09067 size_t datalen; 09068 09069 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update); 09070 if (datalen == (size_t) -1) { 09071 return; 09072 } 09073 09074 ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen); 09075 }
struct ast_variable* ast_channeltype_list | ( | void | ) |
return an ast_variable list of channeltypes
Definition at line 248 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new(), ast_channel_tech::description, chanlist::list, chanlist::tech, ast_channel_tech::type, and var.
Referenced by ast_var_channel_types(), and ast_var_channel_types_table().
00249 { 00250 struct chanlist *cl; 00251 struct ast_variable *var = NULL, *prev = NULL; 00252 00253 AST_RWLIST_RDLOCK(&backends); 00254 AST_RWLIST_TRAVERSE(&backends, cl, list) { 00255 if (prev) { 00256 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, ""))) 00257 prev = prev->next; 00258 } else { 00259 var = ast_variable_new(cl->tech->type, cl->tech->description, ""); 00260 prev = var; 00261 } 00262 } 00263 AST_RWLIST_UNLOCK(&backends); 00264 00265 return var; 00266 }
int ast_check_hangup | ( | struct ast_channel * | chan | ) |
Check to see if a channel is needing hang up.
chan | channel on which to check for hang up This function determines if the channel is being requested to be hung up. |
Definition at line 742 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), chanlist::chan, 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(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), feature_request_and_dial(), findmeexec(), func_channel_read(), handle_sendimage(), launch_asyncagi(), local_fixup(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_exec(), read_exec(), readexten_exec(), remote_bridge_loop(), rpt(), and run_ras().
00743 { 00744 if (chan->_softhangup) /* yes if soft hangup flag set */ 00745 return 1; 00746 if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */ 00747 return 0; 00748 if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */ 00749 return 0; 00750 ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow())); 00751 chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */ 00752 return 1; 00753 }
int ast_check_hangup_locked | ( | struct ast_channel * | chan | ) |
Definition at line 755 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), and chanlist::chan.
Referenced by action_redirect(), and ast_channel_bridge().
00756 { 00757 int res; 00758 ast_channel_lock(chan); 00759 res = ast_check_hangup(chan); 00760 ast_channel_unlock(chan); 00761 return res; 00762 }
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 8297 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(), connected, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_name_ies::str, update(), and value.
Referenced by ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), local_attended_transfer(), local_indicate(), and masquerade_colp_transfer().
08298 { 08299 int32_t value; 08300 size_t pos = 0; 08301 int res; 08302 08303 static const struct ast_party_id_ies ies = { 08304 .name.str = AST_CONNECTED_LINE_NAME, 08305 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET, 08306 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION, 08307 .name.valid = AST_CONNECTED_LINE_NAME_VALID, 08308 08309 .number.str = AST_CONNECTED_LINE_NUMBER, 08310 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN, 08311 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION, 08312 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID, 08313 08314 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS, 08315 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE, 08316 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, 08317 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID, 08318 08319 .tag = AST_CONNECTED_LINE_TAG, 08320 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION, 08321 }; 08322 08323 /* 08324 * The size of integer values must be fixed in case the frame is 08325 * shipped to another machine. 08326 */ 08327 08328 /* Connected line frame version */ 08329 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 08330 ast_log(LOG_WARNING, "No space left for connected line frame version\n"); 08331 return -1; 08332 } 08333 data[pos++] = AST_CONNECTED_LINE_VERSION; 08334 data[pos++] = 1; 08335 data[pos++] = 2;/* Version 1 did not have a version ie */ 08336 08337 res = party_id_build_data(data + pos, datalen - pos, &connected->id, 08338 "connected line", &ies, update ? &update->id : NULL); 08339 if (res < 0) { 08340 return -1; 08341 } 08342 pos += res; 08343 08344 /* Connected line source */ 08345 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08346 ast_log(LOG_WARNING, "No space left for connected line source\n"); 08347 return -1; 08348 } 08349 data[pos++] = AST_CONNECTED_LINE_SOURCE; 08350 data[pos++] = sizeof(value); 08351 value = htonl(connected->source); 08352 memcpy(data + pos, &value, sizeof(value)); 08353 pos += sizeof(value); 08354 08355 return pos; 08356 }
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 7915 of file channel.c.
References ast_party_connected_line::ani, ast_party_caller::ani, ast_party_connected_line::ani2, ast_party_caller::ani2, ast_party_id_copy(), ast_party_connected_line::id, and ast_party_caller::id.
Referenced by begin_dial_channel(), builtin_atxfer(), dial_exec_full(), feature_request_and_dial(), local_call(), pickup_do(), ring_entry(), and wait_for_answer().
07916 { 07917 ast_party_id_copy(&dest->id, &src->id); 07918 ast_party_id_copy(&dest->ani, &src->ani); 07919 dest->ani2 = src->ani2; 07920 }
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 7922 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().
07923 { 07924 ast_party_id_copy(&dest->id, &src->id); 07925 ast_party_id_copy(&dest->ani, &src->ani); 07926 07927 dest->ani2 = src->ani2; 07928 }
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. |
The filled in connected line structure needs to be destroyed by ast_party_connected_line_free() when it is no longer needed.
Definition at line 8358 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_id_ies::combined_presentation, connected, LOG_DEBUG, LOG_WARNING, and value.
Referenced by __ast_read(), ast_channel_connected_line_macro(), ast_indicate_data(), feature_request_and_dial(), and socket_process().
08359 { 08360 size_t pos; 08361 unsigned char ie_len; 08362 unsigned char ie_id; 08363 int32_t value; 08364 int frame_version = 1; 08365 int combined_presentation = 0; 08366 int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08367 08368 for (pos = 0; pos < datalen; pos += ie_len) { 08369 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) { 08370 ast_log(LOG_WARNING, "Invalid connected line update\n"); 08371 return -1; 08372 } 08373 ie_id = data[pos++]; 08374 ie_len = data[pos++]; 08375 if (datalen < pos + ie_len) { 08376 ast_log(LOG_WARNING, "Invalid connected line update\n"); 08377 return -1; 08378 } 08379 08380 switch (ie_id) { 08381 /* Connected line party frame version */ 08382 case AST_CONNECTED_LINE_VERSION: 08383 if (ie_len != 1) { 08384 ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n", 08385 (unsigned) ie_len); 08386 break; 08387 } 08388 frame_version = data[pos]; 08389 break; 08390 /* Connected line party id name */ 08391 case AST_CONNECTED_LINE_NAME: 08392 ast_free(connected->id.name.str); 08393 connected->id.name.str = ast_malloc(ie_len + 1); 08394 if (connected->id.name.str) { 08395 memcpy(connected->id.name.str, data + pos, ie_len); 08396 connected->id.name.str[ie_len] = 0; 08397 } 08398 break; 08399 case AST_CONNECTED_LINE_NAME_CHAR_SET: 08400 if (ie_len != 1) { 08401 ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n", 08402 (unsigned) ie_len); 08403 break; 08404 } 08405 connected->id.name.char_set = data[pos]; 08406 break; 08407 case AST_CONNECTED_LINE_NAME_PRESENTATION: 08408 if (ie_len != 1) { 08409 ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n", 08410 (unsigned) ie_len); 08411 break; 08412 } 08413 connected->id.name.presentation = data[pos]; 08414 break; 08415 case AST_CONNECTED_LINE_NAME_VALID: 08416 if (ie_len != 1) { 08417 ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n", 08418 (unsigned) ie_len); 08419 break; 08420 } 08421 connected->id.name.valid = data[pos]; 08422 break; 08423 /* Connected line party id number */ 08424 case AST_CONNECTED_LINE_NUMBER: 08425 ast_free(connected->id.number.str); 08426 connected->id.number.str = ast_malloc(ie_len + 1); 08427 if (connected->id.number.str) { 08428 memcpy(connected->id.number.str, data + pos, ie_len); 08429 connected->id.number.str[ie_len] = 0; 08430 } 08431 break; 08432 case AST_CONNECTED_LINE_NUMBER_PLAN: 08433 if (ie_len != 1) { 08434 ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n", 08435 (unsigned) ie_len); 08436 break; 08437 } 08438 connected->id.number.plan = data[pos]; 08439 break; 08440 case AST_CONNECTED_LINE_NUMBER_PRESENTATION: 08441 if (ie_len != 1) { 08442 ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n", 08443 (unsigned) ie_len); 08444 break; 08445 } 08446 connected->id.number.presentation = data[pos]; 08447 break; 08448 case AST_CONNECTED_LINE_NUMBER_VALID: 08449 if (ie_len != 1) { 08450 ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n", 08451 (unsigned) ie_len); 08452 break; 08453 } 08454 connected->id.number.valid = data[pos]; 08455 break; 08456 /* Connected line party id combined presentation */ 08457 case AST_CONNECTED_LINE_ID_PRESENTATION: 08458 if (ie_len != 1) { 08459 ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n", 08460 (unsigned) ie_len); 08461 break; 08462 } 08463 combined_presentation = data[pos]; 08464 got_combined_presentation = 1; 08465 break; 08466 /* Connected line party id subaddress */ 08467 case AST_CONNECTED_LINE_SUBADDRESS: 08468 ast_free(connected->id.subaddress.str); 08469 connected->id.subaddress.str = ast_malloc(ie_len + 1); 08470 if (connected->id.subaddress.str) { 08471 memcpy(connected->id.subaddress.str, data + pos, ie_len); 08472 connected->id.subaddress.str[ie_len] = 0; 08473 } 08474 break; 08475 case AST_CONNECTED_LINE_SUBADDRESS_TYPE: 08476 if (ie_len != 1) { 08477 ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n", 08478 (unsigned) ie_len); 08479 break; 08480 } 08481 connected->id.subaddress.type = data[pos]; 08482 break; 08483 case AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN: 08484 if (ie_len != 1) { 08485 ast_log(LOG_WARNING, 08486 "Invalid connected line subaddress odd-even indicator (%u)\n", 08487 (unsigned) ie_len); 08488 break; 08489 } 08490 connected->id.subaddress.odd_even_indicator = data[pos]; 08491 break; 08492 case AST_CONNECTED_LINE_SUBADDRESS_VALID: 08493 if (ie_len != 1) { 08494 ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n", 08495 (unsigned) ie_len); 08496 break; 08497 } 08498 connected->id.subaddress.valid = data[pos]; 08499 break; 08500 /* Connected line party tag */ 08501 case AST_CONNECTED_LINE_TAG: 08502 ast_free(connected->id.tag); 08503 connected->id.tag = ast_malloc(ie_len + 1); 08504 if (connected->id.tag) { 08505 memcpy(connected->id.tag, data + pos, ie_len); 08506 connected->id.tag[ie_len] = 0; 08507 } 08508 break; 08509 /* Connected line party source */ 08510 case AST_CONNECTED_LINE_SOURCE: 08511 if (ie_len != sizeof(value)) { 08512 ast_log(LOG_WARNING, "Invalid connected line source (%u)\n", 08513 (unsigned) ie_len); 08514 break; 08515 } 08516 memcpy(&value, data + pos, sizeof(value)); 08517 connected->source = ntohl(value); 08518 break; 08519 /* Connected line party unknown element */ 08520 default: 08521 ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n", 08522 (unsigned) ie_id, (unsigned) ie_len); 08523 break; 08524 } 08525 } 08526 08527 switch (frame_version) { 08528 case 1: 08529 /* 08530 * The other end is an earlier version that we need to adjust 08531 * for compatibility. 08532 */ 08533 connected->id.name.valid = 1; 08534 connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 08535 connected->id.number.valid = 1; 08536 if (got_combined_presentation) { 08537 connected->id.name.presentation = combined_presentation; 08538 connected->id.number.presentation = combined_presentation; 08539 } 08540 break; 08541 case 2: 08542 /* The other end is at the same level as we are. */ 08543 break; 08544 default: 08545 /* 08546 * The other end is newer than we are. 08547 * We need to assume that they are compatible with us. 08548 */ 08549 ast_log(LOG_DEBUG, "Connected line frame has newer version: %u\n", 08550 (unsigned) frame_version); 08551 break; 08552 } 08553 08554 return 0; 08555 }
void ast_deactivate_generator | ( | struct ast_channel * | chan | ) |
Deactivate an active generator
Definition at line 2956 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(), chanlist::chan, 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().
02957 { 02958 ast_channel_lock(chan); 02959 if (chan->generatordata) { 02960 if (chan->generator && chan->generator->release) 02961 chan->generator->release(chan, chan->generatordata); 02962 chan->generatordata = NULL; 02963 chan->generator = NULL; 02964 ast_channel_set_fd(chan, AST_GENERATOR_FD, -1); 02965 ast_clear_flag(chan, AST_FLAG_WRITE_INT); 02966 ast_settimeout(chan, 0, NULL, NULL); 02967 } 02968 ast_channel_unlock(chan); 02969 }
int ast_do_masquerade | ( | struct ast_channel * | original | ) |
Start masquerading a channel.
Definition at line 6199 of file channel.c.
References __ast_change_name_nolink(), ast_channel::_bridge, ast_channel::_softhangup, ast_channel::_state, 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_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(), chanlist::connected, ast_channel::connected, ast_datastore::data, ast_channel::datastores, ast_channel::dialed, ast_datastore::entry, errno, EVENT_FLAG_CALL, ast_channel::fdno, ast_channel::fds, ast_channel_tech::fixup, free_translation(), ast_channel_tech::hangup, ast_datastore::info, language, ast_channel::language, LOG_WARNING, ast_channel::masq, ast_channel::masqr, masquerade_colp_transfer(), ast_channel::monitor, 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::visible_indication, ast_channel::writeformat, and xfer_ds_info.
Referenced by __ast_read(), ast_async_goto(), ast_hangup(), ast_waitfor_nandfds(), ast_write(), builtin_atxfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), local_attended_transfer(), sip_park(), and sip_park_thread().
06200 { 06201 format_t x; 06202 int i; 06203 int res=0; 06204 int origstate; 06205 int visible_indication; 06206 struct ast_frame *current; 06207 const struct ast_channel_tech *t; 06208 void *t_pvt; 06209 union { 06210 struct ast_party_dialed dialed; 06211 struct ast_party_caller caller; 06212 struct ast_party_connected_line connected; 06213 struct ast_party_redirecting redirecting; 06214 } exchange; 06215 struct ast_channel *clonechan, *chans[2]; 06216 struct ast_channel *bridged; 06217 struct ast_cdr *cdr; 06218 struct ast_datastore *xfer_ds; 06219 struct xfer_masquerade_ds *xfer_colp; 06220 format_t rformat = original->readformat; 06221 format_t wformat = original->writeformat; 06222 char newn[AST_CHANNEL_NAME]; 06223 char orig[AST_CHANNEL_NAME]; 06224 char masqn[AST_CHANNEL_NAME]; 06225 char zombn[AST_CHANNEL_NAME]; 06226 06227 /* XXX This operation is a bit odd. We're essentially putting the guts of 06228 * the clone channel into the original channel. Start by killing off the 06229 * original channel's backend. While the features are nice, which is the 06230 * reason we're keeping it, it's still awesomely weird. XXX */ 06231 06232 /* The reasoning for the channels ao2_container lock here is complex. 06233 * 06234 * In order to check for a race condition, the original channel must 06235 * be locked. If it is determined that the masquerade should proceed 06236 * the original channel can absolutely not be unlocked until the end 06237 * of the function. Since after determining the masquerade should 06238 * continue requires the channels to be unlinked from the ao2_container, 06239 * the container lock must be held first to achieve proper locking order. 06240 */ 06241 ao2_lock(channels); 06242 06243 /* lock the original channel to determine if the masquerade is require or not */ 06244 ast_channel_lock(original); 06245 06246 /* This checks to see if the masquerade has already happened or not. There is a 06247 * race condition that exists for this function. Since all pvt and channel locks 06248 * must be let go before calling do_masquerade, it is possible that it could be 06249 * called multiple times for the same channel. This check verifies whether 06250 * or not the masquerade has already been completed by another thread */ 06251 if (!original->masq) { 06252 ast_channel_unlock(original); 06253 ao2_unlock(channels); 06254 return 0; /* masq already completed by another thread, or never needed to be done to begin with */ 06255 } 06256 06257 /* now that we have verified no race condition exists, set the clone channel */ 06258 clonechan = original->masq; 06259 06260 /* since this function already holds the global container lock, unlocking original 06261 * for deadlock avoidance will not result in any sort of masquerade race condition. 06262 * If masq is called by a different thread while this happens, it will be stuck waiting 06263 * until we unlock the container. */ 06264 while (ast_channel_trylock(clonechan)) { 06265 CHANNEL_DEADLOCK_AVOIDANCE(original); 06266 } 06267 06268 /* Get any transfer masquerade connected line exchange data. */ 06269 xfer_ds = ast_channel_datastore_find(original, &xfer_ds_info, NULL); 06270 if (xfer_ds) { 06271 ast_channel_datastore_remove(original, xfer_ds); 06272 xfer_colp = xfer_ds->data; 06273 } else { 06274 xfer_colp = NULL; 06275 } 06276 06277 /* 06278 * Release any hold on the transferee channel before proceeding 06279 * with the masquerade. 06280 */ 06281 if (xfer_colp && xfer_colp->transferee_held) { 06282 ast_indicate(clonechan, AST_CONTROL_UNHOLD); 06283 } 06284 06285 /* clear the masquerade channels */ 06286 original->masq = NULL; 06287 clonechan->masqr = NULL; 06288 06289 /* unlink from channels container as name (which is the hash value) will change */ 06290 ao2_unlink(channels, original); 06291 ao2_unlink(channels, clonechan); 06292 06293 ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", 06294 clonechan->name, clonechan->_state, original->name, original->_state); 06295 06296 /* 06297 * Stop any visible indiction on the original channel so we can 06298 * transfer it to the clonechan taking the original's place. 06299 */ 06300 visible_indication = original->visible_indication; 06301 ast_indicate(original, -1); 06302 06303 chans[0] = clonechan; 06304 chans[1] = original; 06305 ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans, 06306 "Clone: %s\r\n" 06307 "CloneState: %s\r\n" 06308 "Original: %s\r\n" 06309 "OriginalState: %s\r\n", 06310 clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state)); 06311 06312 /* Having remembered the original read/write formats, we turn off any translation on either 06313 one */ 06314 free_translation(clonechan); 06315 free_translation(original); 06316 06317 /* Save the original name */ 06318 ast_copy_string(orig, original->name, sizeof(orig)); 06319 /* Save the new name */ 06320 ast_copy_string(newn, clonechan->name, sizeof(newn)); 06321 /* Create the masq name */ 06322 snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn); 06323 06324 /* Mangle the name of the clone channel */ 06325 __ast_change_name_nolink(clonechan, masqn); 06326 06327 /* Copy the name from the clone channel */ 06328 __ast_change_name_nolink(original, newn); 06329 06330 /* share linked id's */ 06331 ast_channel_set_linkgroup(original, clonechan); 06332 06333 /* Swap the technologies */ 06334 t = original->tech; 06335 original->tech = clonechan->tech; 06336 clonechan->tech = t; 06337 06338 /* Swap the cdrs */ 06339 cdr = original->cdr; 06340 original->cdr = clonechan->cdr; 06341 clonechan->cdr = cdr; 06342 06343 t_pvt = original->tech_pvt; 06344 original->tech_pvt = clonechan->tech_pvt; 06345 clonechan->tech_pvt = t_pvt; 06346 06347 /* Swap the alertpipes */ 06348 for (i = 0; i < 2; i++) { 06349 x = original->alertpipe[i]; 06350 original->alertpipe[i] = clonechan->alertpipe[i]; 06351 clonechan->alertpipe[i] = x; 06352 } 06353 06354 /* 06355 * Swap the readq's. The end result should be this: 06356 * 06357 * 1) All frames should be on the new (original) channel. 06358 * 2) Any frames that were already on the new channel before this 06359 * masquerade need to be at the end of the readq, after all of the 06360 * frames on the old (clone) channel. 06361 * 3) The alertpipe needs to get poked for every frame that was already 06362 * on the new channel, since we are now using the alert pipe from the 06363 * old (clone) channel. 06364 */ 06365 { 06366 AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq; 06367 AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL); 06368 06369 AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list); 06370 AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list); 06371 06372 while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) { 06373 AST_LIST_INSERT_TAIL(&original->readq, current, frame_list); 06374 if (original->alertpipe[1] > -1) { 06375 int poke = 0; 06376 06377 if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) { 06378 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 06379 } 06380 } 06381 } 06382 } 06383 06384 /* Swap the raw formats */ 06385 x = original->rawreadformat; 06386 original->rawreadformat = clonechan->rawreadformat; 06387 clonechan->rawreadformat = x; 06388 x = original->rawwriteformat; 06389 original->rawwriteformat = clonechan->rawwriteformat; 06390 clonechan->rawwriteformat = x; 06391 06392 clonechan->_softhangup = AST_SOFTHANGUP_DEV; 06393 06394 /* And of course, so does our current state. Note we need not 06395 call ast_setstate since the event manager doesn't really consider 06396 these separate. We do this early so that the clone has the proper 06397 state of the original channel. */ 06398 origstate = original->_state; 06399 original->_state = clonechan->_state; 06400 clonechan->_state = origstate; 06401 06402 if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) { 06403 ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name); 06404 } 06405 06406 /* Start by disconnecting the original's physical side */ 06407 if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) { 06408 ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n"); 06409 res = -1; 06410 goto done; 06411 } 06412 06413 /* Mangle the name of the clone channel */ 06414 snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */ 06415 __ast_change_name_nolink(clonechan, zombn); 06416 06417 /* Update the type. */ 06418 t_pvt = original->monitor; 06419 original->monitor = clonechan->monitor; 06420 clonechan->monitor = t_pvt; 06421 06422 /* Keep the same language. */ 06423 ast_string_field_set(original, language, clonechan->language); 06424 /* Copy the FD's other than the generator fd */ 06425 for (x = 0; x < AST_MAX_FDS; x++) { 06426 if (x != AST_GENERATOR_FD) 06427 ast_channel_set_fd(original, x, clonechan->fds[x]); 06428 } 06429 06430 ast_app_group_update(clonechan, original); 06431 06432 /* Move data stores over */ 06433 if (AST_LIST_FIRST(&clonechan->datastores)) { 06434 struct ast_datastore *ds; 06435 /* We use a safe traversal here because some fixup routines actually 06436 * remove the datastore from the list and free them. 06437 */ 06438 AST_LIST_TRAVERSE_SAFE_BEGIN(&clonechan->datastores, ds, entry) { 06439 if (ds->info->chan_fixup) 06440 ds->info->chan_fixup(ds->data, clonechan, original); 06441 } 06442 AST_LIST_TRAVERSE_SAFE_END; 06443 AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry); 06444 } 06445 06446 ast_autochan_new_channel(clonechan, original); 06447 06448 clone_variables(original, clonechan); 06449 /* Presense of ADSI capable CPE follows clone */ 06450 original->adsicpe = clonechan->adsicpe; 06451 /* Bridge remains the same */ 06452 /* CDR fields remain the same */ 06453 /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ 06454 /* Application and data remain the same */ 06455 /* Clone exception becomes real one, as with fdno */ 06456 ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING)); 06457 original->fdno = clonechan->fdno; 06458 /* Schedule context remains the same */ 06459 /* Stream stuff stays the same */ 06460 /* Keep the original state. The fixup code will need to work with it most likely */ 06461 06462 /* 06463 * Just swap the whole structures, nevermind the allocations, 06464 * they'll work themselves out. 06465 */ 06466 exchange.dialed = original->dialed; 06467 original->dialed = clonechan->dialed; 06468 clonechan->dialed = exchange.dialed; 06469 06470 exchange.caller = original->caller; 06471 original->caller = clonechan->caller; 06472 clonechan->caller = exchange.caller; 06473 06474 exchange.connected = original->connected; 06475 original->connected = clonechan->connected; 06476 clonechan->connected = exchange.connected; 06477 06478 exchange.redirecting = original->redirecting; 06479 original->redirecting = clonechan->redirecting; 06480 clonechan->redirecting = exchange.redirecting; 06481 06482 report_new_callerid(original); 06483 06484 /* Restore original timing file descriptor */ 06485 ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd); 06486 06487 /* Our native formats are different now */ 06488 original->nativeformats = clonechan->nativeformats; 06489 06490 /* Context, extension, priority, app data, jump table, remain the same */ 06491 /* pvt switches. pbx stays the same, as does next */ 06492 06493 /* Set the write format */ 06494 ast_set_write_format(original, wformat); 06495 06496 /* Set the read format */ 06497 ast_set_read_format(original, rformat); 06498 06499 /* Copy the music class */ 06500 ast_string_field_set(original, musicclass, clonechan->musicclass); 06501 06502 /* copy over accuntcode and set peeraccount across the bridge */ 06503 ast_string_field_set(original, accountcode, S_OR(clonechan->accountcode, "")); 06504 if (original->_bridge) { 06505 /* XXX - should we try to lock original->_bridge here? */ 06506 ast_string_field_set(original->_bridge, peeraccount, S_OR(clonechan->accountcode, "")); 06507 ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL); 06508 } 06509 06510 ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name, 06511 ast_getformatname(wformat), ast_getformatname(rformat)); 06512 06513 /* Okay. Last thing is to let the channel driver know about all this mess, so he 06514 can fix up everything as best as possible */ 06515 if (original->tech->fixup) { 06516 if (original->tech->fixup(clonechan, original)) { 06517 ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n", 06518 original->tech->type, original->name); 06519 res = -1; 06520 goto done; 06521 } 06522 } else 06523 ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n", 06524 original->tech->type, original->name); 06525 06526 /* 06527 * If an indication is currently playing, maintain it on the channel 06528 * that is taking the place of original 06529 * 06530 * This is needed because the masquerade is swapping out in the internals 06531 * of this channel, and the new channel private data needs to be made 06532 * aware of the current visible indication (RINGING, CONGESTION, etc.) 06533 */ 06534 if (visible_indication) { 06535 ast_indicate(original, visible_indication); 06536 } 06537 06538 /* Now, at this point, the "clone" channel is totally F'd up. We mark it as 06539 a zombie so nothing tries to touch it. If it's already been marked as a 06540 zombie, then free it now (since it already is considered invalid). */ 06541 if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { 06542 ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name); 06543 ast_channel_unlock(clonechan); 06544 ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup", 06545 "Channel: %s\r\n" 06546 "Uniqueid: %s\r\n" 06547 "Cause: %d\r\n" 06548 "Cause-txt: %s\r\n", 06549 clonechan->name, 06550 clonechan->uniqueid, 06551 clonechan->hangupcause, 06552 ast_cause2str(clonechan->hangupcause) 06553 ); 06554 clonechan = ast_channel_release(clonechan); 06555 } else { 06556 ast_debug(1, "Released clone lock on '%s'\n", clonechan->name); 06557 ast_set_flag(clonechan, AST_FLAG_ZOMBIE); 06558 ast_queue_frame(clonechan, &ast_null_frame); 06559 } 06560 06561 /* Signal any blocker */ 06562 if (ast_test_flag(original, AST_FLAG_BLOCKING)) 06563 pthread_kill(original->blocker, SIGURG); 06564 ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state); 06565 06566 if ((bridged = ast_bridged_channel(original))) { 06567 ast_channel_lock(bridged); 06568 ast_indicate(bridged, AST_CONTROL_SRCCHANGE); 06569 ast_channel_unlock(bridged); 06570 } 06571 ast_indicate(original, AST_CONTROL_SRCCHANGE); 06572 06573 if (xfer_colp) { 06574 /* 06575 * After the masquerade, the original channel pointer actually 06576 * points to the new transferee channel and the bridged channel 06577 * is still the intended transfer target party. 06578 */ 06579 masquerade_colp_transfer(original, xfer_colp); 06580 } 06581 06582 done: 06583 if (xfer_ds) { 06584 ast_datastore_free(xfer_ds); 06585 } 06586 /* it is possible for the clone channel to disappear during this */ 06587 if (clonechan) { 06588 ast_channel_unlock(original); 06589 ast_channel_unlock(clonechan); 06590 ao2_link(channels, clonechan); 06591 ao2_link(channels, original); 06592 } else { 06593 ast_channel_unlock(original); 06594 ao2_link(channels, original); 06595 } 06596 06597 ao2_unlock(channels); 06598 06599 return res; 06600 }
struct ast_channel* ast_dummy_channel_alloc | ( | void | ) |
Create a fake channel structure.
NULL | failure | |
non-NULL | successfully allocated channel |
Definition at line 1320 of file channel.c.
References __ao2_alloc_debug(), ao2_alloc, ast_channel_unref, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, and ast_string_field_init.
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(), custom_log(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), syslog_log(), and write_cdr().
01322 { 01323 struct ast_channel *tmp; 01324 struct varshead *headp; 01325 01326 #if defined(REF_DEBUG) 01327 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel", 01328 file, line, function, 1); 01329 #elif defined(__AST_DEBUG_MALLOC) 01330 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel", 01331 file, line, function, 0); 01332 #else 01333 tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor); 01334 #endif 01335 if (!tmp) { 01336 /* Dummy channel structure allocation failure. */ 01337 return NULL; 01338 } 01339 01340 if ((ast_string_field_init(tmp, 128))) { 01341 return ast_channel_unref(tmp); 01342 } 01343 01344 headp = &tmp->varshead; 01345 AST_LIST_HEAD_INIT_NOLOCK(headp); 01346 01347 return tmp; 01348 }
static int ast_fdisset | ( | struct pollfd * | pfds, | |
int | fd, | |||
int | maximum, | |||
int * | start | |||
) | [inline, static] |
Helper function for migrating select to poll.
Definition at line 2324 of file channel.h.
References dummy().
02325 { 02326 int x; 02327 int dummy = 0; 02328 02329 if (fd < 0) 02330 return 0; 02331 if (!start) 02332 start = &dummy; 02333 for (x = *start; x < maximum; x++) 02334 if (pfds[x].fd == fd) { 02335 if (x == *start) 02336 (*start)++; 02337 return pfds[x].revents; 02338 } 02339 return 0; 02340 }
struct ast_channel_tech* ast_get_channel_tech | ( | const char * | name | ) |
Get a channel technology structure by name.
name | name of technology to find |
Definition at line 890 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::list, 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().
00891 { 00892 struct chanlist *chanls; 00893 const struct ast_channel_tech *ret = NULL; 00894 00895 AST_RWLIST_RDLOCK(&backends); 00896 00897 AST_RWLIST_TRAVERSE(&backends, chanls, list) { 00898 if (!strcasecmp(name, chanls->tech->type)) { 00899 ret = chanls->tech; 00900 break; 00901 } 00902 } 00903 00904 AST_RWLIST_UNLOCK(&backends); 00905 00906 return ret; 00907 }
ast_group_t ast_get_group | ( | const char * | s | ) |
Definition at line 7494 of file channel.c.
References ast_log(), ast_strdupa, ast_strlen_zero(), LOG_ERROR, LOG_WARNING, and strsep().
Referenced by _parse(), build_device(), build_peer(), config_parse_variables(), func_channel_write_real(), and read_agent_config().
07495 { 07496 char *piece; 07497 char *c; 07498 int start=0, finish=0, x; 07499 ast_group_t group = 0; 07500 07501 if (ast_strlen_zero(s)) 07502 return 0; 07503 07504 c = ast_strdupa(s); 07505 07506 while ((piece = strsep(&c, ","))) { 07507 if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) { 07508 /* Range */ 07509 } else if (sscanf(piece, "%30d", &start)) { 07510 /* Just one */ 07511 finish = start; 07512 } else { 07513 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece); 07514 continue; 07515 } 07516 for (x = start; x <= finish; x++) { 07517 if ((x > 63) || (x < 0)) { 07518 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x); 07519 } else 07520 group |= ((ast_group_t) 1 << x); 07521 } 07522 } 07523 return group; 07524 }
int ast_hangup | ( | struct ast_channel * | chan | ) |
Hang up a channel.
chan | channel to hang up |
Definition at line 2683 of file channel.c.
References ao2_unlink, 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_release(), ast_channel_unlock, 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, chanlist::chan, channels, 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, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, ast_party_id::name, ast_party_id::number, pbx_builtin_getvar_helper(), ast_generator::release, S_COR, S_OR, ast_channel::sched, sched_context_destroy(), ast_party_number::str, ast_party_name::str, ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, ast_party_number::valid, ast_party_name::valid, and ast_channel::vstream.
Referenced by __analog_handle_event(), __analog_ss_thread(), __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_compat(), check_goto_on_transfer(), clear_caller(), 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_parkinglot(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), oss_new(), park_exec_full(), parkandannounce_exec(), phone_new(), play_sound_file(), pri_dchannel(), pri_ss_thread(), rpt(), rpt_call(), rpt_tele_thread(), sip_new(), sip_park(), sip_park_thread(), skinny_new(), skinny_ss(), unistim_new(), usbradio_new(), and wait_for_winner().
02684 { 02685 int res = 0; 02686 char extra_str[64]; /* used for cel logging below */ 02687 02688 /* Don't actually hang up a channel that will masquerade as someone else, or 02689 if someone is going to masquerade as us */ 02690 ast_channel_lock(chan); 02691 02692 if (chan->audiohooks) { 02693 ast_audiohook_detach_list(chan->audiohooks); 02694 chan->audiohooks = NULL; 02695 } 02696 02697 ast_framehook_list_destroy(chan); 02698 02699 ast_autoservice_stop(chan); 02700 02701 if (chan->masq) { 02702 ast_channel_unlock(chan); 02703 if (ast_do_masquerade(chan)) { 02704 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 02705 } 02706 ast_channel_lock(chan); 02707 } 02708 02709 if (chan->masq) { 02710 ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name); 02711 ast_channel_unlock(chan); 02712 return 0; 02713 } 02714 /* If this channel is one which will be masqueraded into something, 02715 mark it as a zombie already, so we know to free it later */ 02716 if (chan->masqr) { 02717 ast_set_flag(chan, AST_FLAG_ZOMBIE); 02718 ast_channel_unlock(chan); 02719 return 0; 02720 } 02721 ast_channel_unlock(chan); 02722 02723 ao2_unlink(channels, chan); 02724 02725 ast_channel_lock(chan); 02726 free_translation(chan); 02727 /* Close audio stream */ 02728 if (chan->stream) { 02729 ast_closestream(chan->stream); 02730 chan->stream = NULL; 02731 } 02732 /* Close video stream */ 02733 if (chan->vstream) { 02734 ast_closestream(chan->vstream); 02735 chan->vstream = NULL; 02736 } 02737 if (chan->sched) { 02738 sched_context_destroy(chan->sched); 02739 chan->sched = NULL; 02740 } 02741 02742 if (chan->generatordata) /* Clear any tone stuff remaining */ 02743 if (chan->generator && chan->generator->release) 02744 chan->generator->release(chan, chan->generatordata); 02745 chan->generatordata = NULL; 02746 chan->generator = NULL; 02747 02748 snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), "")); 02749 ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL); 02750 02751 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { 02752 ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " 02753 "is blocked by thread %ld in procedure %s! Expect a failure\n", 02754 (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc); 02755 ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0); 02756 } 02757 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { 02758 ast_debug(1, "Hanging up channel '%s'\n", chan->name); 02759 if (chan->tech->hangup) 02760 res = chan->tech->hangup(chan); 02761 } else { 02762 ast_debug(1, "Hanging up zombie '%s'\n", chan->name); 02763 } 02764 02765 ast_channel_unlock(chan); 02766 ast_cc_offer(chan); 02767 ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup", 02768 "Channel: %s\r\n" 02769 "Uniqueid: %s\r\n" 02770 "CallerIDNum: %s\r\n" 02771 "CallerIDName: %s\r\n" 02772 "Cause: %d\r\n" 02773 "Cause-txt: %s\r\n", 02774 chan->name, 02775 chan->uniqueid, 02776 S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"), 02777 S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"), 02778 chan->hangupcause, 02779 ast_cause2str(chan->hangupcause) 02780 ); 02781 02782 if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) && 02783 !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) && 02784 (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) { 02785 ast_channel_lock(chan); 02786 02787 ast_cdr_end(chan->cdr); 02788 ast_cdr_detach(chan->cdr); 02789 chan->cdr = NULL; 02790 ast_channel_unlock(chan); 02791 } 02792 02793 chan = ast_channel_release(chan); 02794 02795 return res; 02796 }
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 4184 of file channel.c.
References ast_indicate_data(), and chanlist::chan.
Referenced by __ast_play_and_record(), agent_new(), 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(), do_forward(), feature_request_and_dial(), finishup(), function_remote(), handle_callforward_button(), handle_frame(), handle_recordfile(), handle_request_refer(), local_attended_transfer(), manage_parkinglot(), mgcp_ss(), monitor_dial(), oss_call(), park_call_full(), park_exec_full(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), rna(), rpt(), rpt_exec(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), and sla_trunk_exec().
04185 { 04186 return ast_indicate_data(chan, condition, NULL, 0); 04187 }
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 4236 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_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_VIDUPDATE, AST_CONTROL_WINK, ast_debug, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_read_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(), chanlist::chan, chanlist::connected, ast_channel::connected, ast_frame::data, ast_tone_zone_sound::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_handle_cc_control_frame(), ast_indicate(), disable_t38(), feature_request_and_dial(), generic_fax_exec(), handle_frame(), login_exec(), manage_parkinglot(), 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().
04238 { 04239 /* By using an enum, we'll get compiler warnings for values not handled 04240 * in switch statements. */ 04241 enum ast_control_frame_type condition = _condition; 04242 struct ast_tone_zone_sound *ts = NULL; 04243 int res; 04244 /* this frame is used by framehooks. if it is set, we must free it at the end of this function */ 04245 struct ast_frame *awesome_frame = NULL; 04246 04247 ast_channel_lock(chan); 04248 04249 /* Don't bother if the channel is about to go away, anyway. */ 04250 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 04251 res = -1; 04252 goto indicate_cleanup; 04253 } 04254 04255 if (!ast_framehook_list_is_empty(chan->framehooks)) { 04256 /* Do framehooks now, do it, go, go now */ 04257 struct ast_frame frame = { 04258 .frametype = AST_FRAME_CONTROL, 04259 .subclass.integer = condition, 04260 .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */ 04261 .datalen = datalen 04262 }; 04263 04264 /* we have now committed to freeing this frame */ 04265 awesome_frame = ast_frdup(&frame); 04266 04267 /* who knows what we will get back! the anticipation is killing me. */ 04268 if (!(awesome_frame = ast_framehook_list_read_event(chan->framehooks, &frame))) { 04269 res = 0; 04270 goto indicate_cleanup; 04271 } 04272 04273 condition = awesome_frame->subclass.integer; 04274 data = awesome_frame->data.ptr; 04275 datalen = awesome_frame->datalen; 04276 } 04277 04278 switch (condition) { 04279 case AST_CONTROL_CONNECTED_LINE: 04280 { 04281 struct ast_party_connected_line connected; 04282 04283 ast_party_connected_line_set_init(&connected, &chan->connected); 04284 res = ast_connected_line_parse_data(data, datalen, &connected); 04285 if (!res) { 04286 ast_channel_set_connected_line(chan, &connected, NULL); 04287 } 04288 ast_party_connected_line_free(&connected); 04289 } 04290 break; 04291 04292 case AST_CONTROL_REDIRECTING: 04293 { 04294 struct ast_party_redirecting redirecting; 04295 04296 ast_party_redirecting_set_init(&redirecting, &chan->redirecting); 04297 res = ast_redirecting_parse_data(data, datalen, &redirecting); 04298 if (!res) { 04299 ast_channel_set_redirecting(chan, &redirecting, NULL); 04300 } 04301 ast_party_redirecting_free(&redirecting); 04302 } 04303 break; 04304 04305 default: 04306 break; 04307 } 04308 04309 if (is_visible_indication(condition)) { 04310 /* A new visible indication is requested. */ 04311 chan->visible_indication = condition; 04312 } else if (condition == AST_CONTROL_UNHOLD || _condition < 0) { 04313 /* Visible indication is cleared/stopped. */ 04314 chan->visible_indication = 0; 04315 } 04316 04317 if (chan->tech->indicate) { 04318 /* See if the channel driver can handle this condition. */ 04319 res = chan->tech->indicate(chan, condition, data, datalen); 04320 } else { 04321 res = -1; 04322 } 04323 04324 if (!res) { 04325 /* The channel driver successfully handled this indication */ 04326 res = 0; 04327 goto indicate_cleanup; 04328 } 04329 04330 /* The channel driver does not support this indication, let's fake 04331 * it by doing our own tone generation if applicable. */ 04332 04333 /*!\note If we compare the enumeration type, which does not have any 04334 * negative constants, the compiler may optimize this code away. 04335 * Therefore, we must perform an integer comparison here. */ 04336 if (_condition < 0) { 04337 /* Stop any tones that are playing */ 04338 ast_playtones_stop(chan); 04339 res = 0; 04340 goto indicate_cleanup; 04341 } 04342 04343 /* Handle conditions that we have tones for. */ 04344 switch (condition) { 04345 case _XXX_AST_CONTROL_T38: 04346 /* deprecated T.38 control frame */ 04347 res = -1; 04348 goto indicate_cleanup; 04349 case AST_CONTROL_T38_PARAMETERS: 04350 /* there is no way to provide 'default' behavior for these 04351 * control frames, so we need to return failure, but there 04352 * is also no value in the log message below being emitted 04353 * since failure to handle these frames is not an 'error' 04354 * so just return right now. in addition, we want to return 04355 * whatever value the channel driver returned, in case it 04356 * has some meaning.*/ 04357 goto indicate_cleanup; 04358 case AST_CONTROL_RINGING: 04359 ts = ast_get_indication_tone(chan->zone, "ring"); 04360 /* It is common practice for channel drivers to return -1 if trying 04361 * to indicate ringing on a channel which is up. The idea is to let the 04362 * core generate the ringing inband. However, we don't want the 04363 * warning message about not being able to handle the specific indication 04364 * to print nor do we want ast_indicate_data to return an "error" for this 04365 * condition 04366 */ 04367 if (chan->_state == AST_STATE_UP) { 04368 res = 0; 04369 } 04370 break; 04371 case AST_CONTROL_BUSY: 04372 ts = ast_get_indication_tone(chan->zone, "busy"); 04373 break; 04374 case AST_CONTROL_CONGESTION: 04375 ts = ast_get_indication_tone(chan->zone, "congestion"); 04376 break; 04377 case AST_CONTROL_PROGRESS: 04378 case AST_CONTROL_PROCEEDING: 04379 case AST_CONTROL_VIDUPDATE: 04380 case AST_CONTROL_SRCUPDATE: 04381 case AST_CONTROL_SRCCHANGE: 04382 case AST_CONTROL_RADIO_KEY: 04383 case AST_CONTROL_RADIO_UNKEY: 04384 case AST_CONTROL_OPTION: 04385 case AST_CONTROL_WINK: 04386 case AST_CONTROL_FLASH: 04387 case AST_CONTROL_OFFHOOK: 04388 case AST_CONTROL_TAKEOFFHOOK: 04389 case AST_CONTROL_ANSWER: 04390 case AST_CONTROL_HANGUP: 04391 case AST_CONTROL_RING: 04392 case AST_CONTROL_HOLD: 04393 case AST_CONTROL_UNHOLD: 04394 case AST_CONTROL_TRANSFER: 04395 case AST_CONTROL_CONNECTED_LINE: 04396 case AST_CONTROL_REDIRECTING: 04397 case AST_CONTROL_CC: 04398 case AST_CONTROL_READ_ACTION: 04399 case AST_CONTROL_AOC: 04400 case AST_CONTROL_END_OF_Q: 04401 /* Nothing left to do for these. */ 04402 res = 0; 04403 break; 04404 } 04405 04406 if (ts) { 04407 /* We have a tone to play, yay. */ 04408 ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); 04409 res = ast_playtones_start(chan, 0, ts->data, 1); 04410 ts = ast_tone_zone_sound_unref(ts); 04411 } 04412 04413 if (res) { 04414 /* not handled */ 04415 ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name); 04416 } 04417 04418 indicate_cleanup: 04419 ast_channel_unlock(chan); 04420 if (awesome_frame) { 04421 ast_frfree(awesome_frame); 04422 } 04423 04424 return res; 04425 }
int ast_internal_timing_enabled | ( | struct ast_channel * | chan | ) |
Check if the channel can run in internal timing mode.
chan | The channel to check |
Definition at line 4169 of file channel.c.
References ast_opt_internal_timing, chanlist::chan, and ast_channel::timingfd.
Referenced by add_sdp(), and ast_read_generator_actions().
04170 { 04171 return (ast_opt_internal_timing && chan->timingfd > -1); 04172 }
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 1728 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().
01729 { 01730 /* Do not add a default entry in this switch statement. Each new 01731 * frame type should be addressed directly as to whether it should 01732 * be queued up or not. 01733 */ 01734 switch (frame->frametype) { 01735 case AST_FRAME_CONTROL: 01736 case AST_FRAME_TEXT: 01737 case AST_FRAME_IMAGE: 01738 case AST_FRAME_HTML: 01739 return 1; 01740 01741 case AST_FRAME_DTMF_END: 01742 case AST_FRAME_DTMF_BEGIN: 01743 case AST_FRAME_VOICE: 01744 case AST_FRAME_VIDEO: 01745 case AST_FRAME_NULL: 01746 case AST_FRAME_IAX: 01747 case AST_FRAME_CNG: 01748 case AST_FRAME_MODEM: 01749 return 0; 01750 } 01751 return 0; 01752 }
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 2179 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_copy(), and ast_party_caller::id.
Referenced by ast_call_forward(), and do_forward().
02180 { 02181 if (dest == src) { 02182 /* Don't copy to self */ 02183 return; 02184 } 02185 02186 ast_party_id_copy(&dest->id, &src->id); 02187 ast_party_id_copy(&dest->ani, &src->ani); 02188 dest->ani2 = src->ani2; 02189 }
void ast_party_caller_free | ( | struct ast_party_caller * | doomed | ) |
Destroy the caller party contents.
doomed | The caller party to destroy. |
Definition at line 2205 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().
02206 { 02207 ast_party_id_free(&doomed->id); 02208 ast_party_id_free(&doomed->ani); 02209 }
void ast_party_caller_init | ( | struct ast_party_caller * | init | ) |
Initialize the given caller structure.
init | Caller structure to initialize. |
Definition at line 2172 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(), and sla_ring_station().
02173 { 02174 ast_party_id_init(&init->id); 02175 ast_party_id_init(&init->ani); 02176 init->ani2 = 0; 02177 }
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.
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 2198 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set(), ast_party_caller::id, and update().
Referenced by ast_channel_set_caller(), ast_channel_set_caller_event(), and callerid_write().
02199 { 02200 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL); 02201 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL); 02202 dest->ani2 = src->ani2; 02203 }
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.
init | Caller structure to initialize. | |
guide | Source caller to use as a guide in initializing. |
Definition at line 2191 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(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().
02192 { 02193 ast_party_id_set_init(&init->id, &guide->id); 02194 ast_party_id_set_init(&init->ani, &guide->ani); 02195 init->ani2 = guide->ani2; 02196 }
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. |
DO NOT call ast_party_connected_line_free() on the filled in connected line structure!
Definition at line 2248 of file channel.c.
References ast_party_connected_line::ani, ast_party_caller::ani, ast_party_connected_line::ani2, ast_party_caller::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_channel::caller, chanlist::connected, ast_party_connected_line::id, ast_party_caller::id, and ast_party_connected_line::source.
Referenced by ast_pickup_call().
02249 { 02250 connected->id = caller->id; 02251 connected->ani = caller->ani; 02252 connected->ani2 = caller->ani2; 02253 connected->source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN; 02254 }
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 2219 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(), builtin_atxfer(), dial_exec_full(), do_forward(), local_attended_transfer(), misdn_attempt_transfer(), party_connected_line_copy_transfer(), and pickup_do().
02220 { 02221 if (dest == src) { 02222 /* Don't copy to self */ 02223 return; 02224 } 02225 02226 ast_party_id_copy(&dest->id, &src->id); 02227 ast_party_id_copy(&dest->ani, &src->ani); 02228 dest->ani2 = src->ani2; 02229 dest->source = src->source; 02230 }
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 2256 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_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(), pickup_do(), sig_pri_handle_subcmds(), socket_process(), wait_for_answer(), and xfer_ds_destroy().
02257 { 02258 ast_party_id_free(&doomed->id); 02259 ast_party_id_free(&doomed->ani); 02260 }
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 2211 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(), builtin_atxfer(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_attempt_transfer(), misdn_queue_connected_line_update(), pickup_do(), sig_pri_handle_subcmds(), socket_process(), and wait_for_answer().
02212 { 02213 ast_party_id_init(&init->id); 02214 ast_party_id_init(&init->ani); 02215 init->ani2 = 0; 02216 init->source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN; 02217 }
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 2240 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set(), ast_party_connected_line::id, ast_party_connected_line::source, and update().
Referenced by ast_channel_set_connected_line().
02241 { 02242 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL); 02243 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL); 02244 dest->ani2 = src->ani2; 02245 dest->source = src->source; 02246 }
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.
init | Connected line structure to initialize. | |
guide | Source connected line to use as a guide in initializing. |
Definition at line 2232 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(), and feature_request_and_dial().
02233 { 02234 ast_party_id_set_init(&init->id, &guide->id); 02235 ast_party_id_set_init(&init->ani, &guide->ani); 02236 init->ani2 = guide->ani2; 02237 init->source = guide->source; 02238 }
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 2130 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().
02131 { 02132 if (dest == src) { 02133 /* Don't copy to self */ 02134 return; 02135 } 02136 02137 ast_free(dest->number.str); 02138 dest->number.str = ast_strdup(src->number.str); 02139 dest->number.plan = src->number.plan; 02140 ast_party_subaddress_copy(&dest->subaddress, &src->subaddress); 02141 dest->transit_network_select = src->transit_network_select; 02142 }
void ast_party_dialed_free | ( | struct ast_party_dialed * | doomed | ) |
Destroy the dialed party contents.
doomed | The dialed party to destroy. |
Definition at line 2165 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().
02166 { 02167 ast_free(doomed->number.str); 02168 doomed->number.str = NULL; 02169 ast_party_subaddress_free(&doomed->subaddress); 02170 }
void ast_party_dialed_init | ( | struct ast_party_dialed * | init | ) |
Initialize the given dialed structure.
init | Dialed structure to initialize. |
Definition at line 2122 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().
02123 { 02124 init->number.str = NULL; 02125 init->number.plan = 0;/* Unknown */ 02126 ast_party_subaddress_init(&init->subaddress); 02127 init->transit_network_select = 0; 02128 }
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.
dest | The dialed one wishes to update | |
src | The new dialed values to update the dest |
Definition at line 2152 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().
02153 { 02154 if (src->number.str && src->number.str != dest->number.str) { 02155 ast_free(dest->number.str); 02156 dest->number.str = ast_strdup(src->number.str); 02157 } 02158 dest->number.plan = src->number.plan; 02159 02160 ast_party_subaddress_set(&dest->subaddress, &src->subaddress); 02161 02162 dest->transit_network_select = src->transit_network_select; 02163 }
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.
init | Caller structure to initialize. | |
guide | Source dialed to use as a guide in initializing. |
Definition at line 2144 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().
02145 { 02146 init->number.str = NULL; 02147 init->number.plan = guide->number.plan; 02148 ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress); 02149 init->transit_network_select = guide->transit_network_select; 02150 }
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 2001 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(), and ast_party_redirecting_copy().
02002 { 02003 if (dest == src) { 02004 /* Don't copy to self */ 02005 return; 02006 } 02007 02008 ast_party_name_copy(&dest->name, &src->name); 02009 ast_party_number_copy(&dest->number, &src->number); 02010 ast_party_subaddress_copy(&dest->subaddress, &src->subaddress); 02011 02012 ast_free(dest->tag); 02013 dest->tag = ast_strdup(src->tag); 02014 }
void ast_party_id_free | ( | struct ast_party_id * | doomed | ) |
Destroy the party id contents.
doomed | The party id to destroy. |
Definition at line 2047 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(), and do_forward().
02048 { 02049 ast_party_name_free(&doomed->name); 02050 ast_party_number_free(&doomed->number); 02051 ast_party_subaddress_free(&doomed->subaddress); 02052 02053 ast_free(doomed->tag); 02054 doomed->tag = NULL; 02055 }
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 1993 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(), and do_forward().
01994 { 01995 ast_party_name_init(&init->name); 01996 ast_party_number_init(&init->number); 01997 ast_party_subaddress_init(&init->subaddress); 01998 init->tag = NULL; 01999 }
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 2057 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, and id.
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_handle_subcmds(), sip_call(), and socket_process().
02058 { 02059 int number_priority; 02060 int number_value; 02061 int number_screening; 02062 int name_priority; 02063 int name_value; 02064 02065 /* Determine name presentation priority. */ 02066 if (!id->name.valid) { 02067 name_value = AST_PRES_UNAVAILABLE; 02068 name_priority = 3; 02069 } else { 02070 name_value = id->name.presentation & AST_PRES_RESTRICTION; 02071 switch (name_value) { 02072 case AST_PRES_RESTRICTED: 02073 name_priority = 0; 02074 break; 02075 case AST_PRES_ALLOWED: 02076 name_priority = 1; 02077 break; 02078 case AST_PRES_UNAVAILABLE: 02079 name_priority = 2; 02080 break; 02081 default: 02082 name_value = AST_PRES_UNAVAILABLE; 02083 name_priority = 3; 02084 break; 02085 } 02086 } 02087 02088 /* Determine number presentation priority. */ 02089 if (!id->number.valid) { 02090 number_screening = AST_PRES_USER_NUMBER_UNSCREENED; 02091 number_value = AST_PRES_UNAVAILABLE; 02092 number_priority = 3; 02093 } else { 02094 number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE; 02095 number_value = id->number.presentation & AST_PRES_RESTRICTION; 02096 switch (number_value) { 02097 case AST_PRES_RESTRICTED: 02098 number_priority = 0; 02099 break; 02100 case AST_PRES_ALLOWED: 02101 number_priority = 1; 02102 break; 02103 case AST_PRES_UNAVAILABLE: 02104 number_priority = 2; 02105 break; 02106 default: 02107 number_screening = AST_PRES_USER_NUMBER_UNSCREENED; 02108 number_value = AST_PRES_UNAVAILABLE; 02109 number_priority = 3; 02110 break; 02111 } 02112 } 02113 02114 /* Select the wining presentation value. */ 02115 if (name_priority < number_priority) { 02116 number_value = name_value; 02117 } 02118 02119 return number_value | number_screening; 02120 }
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 2024 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_party_id::number, ast_party_id::subaddress, ast_party_id::tag, and update().
Referenced by ast_party_caller_set(), ast_party_connected_line_set(), and ast_party_redirecting_set().
02025 { 02026 if (dest == src) { 02027 /* Don't set to self */ 02028 return; 02029 } 02030 02031 if (!update || update->name) { 02032 ast_party_name_set(&dest->name, &src->name); 02033 } 02034 if (!update || update->number) { 02035 ast_party_number_set(&dest->number, &src->number); 02036 } 02037 if (!update || update->subaddress) { 02038 ast_party_subaddress_set(&dest->subaddress, &src->subaddress); 02039 } 02040 02041 if (src->tag && src->tag != dest->tag) { 02042 ast_free(dest->tag); 02043 dest->tag = ast_strdup(src->tag); 02044 } 02045 }
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.
init | Party id structure to initialize. | |
guide | Source party id to use as a guide in initializing. |
Definition at line 2016 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(), and ast_party_redirecting_set_init().
02017 { 02018 ast_party_name_set_init(&init->name, &guide->name); 02019 ast_party_number_set_init(&init->number, &guide->number); 02020 ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress); 02021 init->tag = NULL; 02022 }
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 1842 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().
01843 { 01844 if (dest == src) { 01845 /* Don't copy to self */ 01846 return; 01847 } 01848 01849 ast_free(dest->str); 01850 dest->str = ast_strdup(src->str); 01851 dest->char_set = src->char_set; 01852 dest->presentation = src->presentation; 01853 dest->valid = src->valid; 01854 }
void ast_party_name_free | ( | struct ast_party_name * | doomed | ) |
Destroy the party name contents.
doomed | The party name to destroy. |
Definition at line 1881 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 1834 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().
01835 { 01836 init->str = NULL; 01837 init->char_set = AST_PARTY_CHAR_SET_ISO8859_1; 01838 init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 01839 init->valid = 0; 01840 }
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 1864 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().
01865 { 01866 if (dest == src) { 01867 /* Don't set to self */ 01868 return; 01869 } 01870 01871 if (src->str && src->str != dest->str) { 01872 ast_free(dest->str); 01873 dest->str = ast_strdup(src->str); 01874 } 01875 01876 dest->char_set = src->char_set; 01877 dest->presentation = src->presentation; 01878 dest->valid = src->valid; 01879 }
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.
init | Party name structure to initialize. | |
guide | Source party name to use as a guide in initializing. |
Definition at line 1856 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().
01857 { 01858 init->str = NULL; 01859 init->char_set = guide->char_set; 01860 init->presentation = guide->presentation; 01861 init->valid = guide->valid; 01862 }
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 1895 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().
01896 { 01897 if (dest == src) { 01898 /* Don't copy to self */ 01899 return; 01900 } 01901 01902 ast_free(dest->str); 01903 dest->str = ast_strdup(src->str); 01904 dest->plan = src->plan; 01905 dest->presentation = src->presentation; 01906 dest->valid = src->valid; 01907 }
void ast_party_number_free | ( | struct ast_party_number * | doomed | ) |
Destroy the party number contents.
doomed | The party number to destroy. |
Definition at line 1934 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(), and skinny_newcall().
void ast_party_number_init | ( | struct ast_party_number * | init | ) |
Initialize the given number structure.
init | Number structure to initialize. |
Definition at line 1887 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(), and skinny_newcall().
01888 { 01889 init->str = NULL; 01890 init->plan = 0;/* Unknown */ 01891 init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 01892 init->valid = 0; 01893 }
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 1917 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().
01918 { 01919 if (dest == src) { 01920 /* Don't set to self */ 01921 return; 01922 } 01923 01924 if (src->str && src->str != dest->str) { 01925 ast_free(dest->str); 01926 dest->str = ast_strdup(src->str); 01927 } 01928 01929 dest->plan = src->plan; 01930 dest->presentation = src->presentation; 01931 dest->valid = src->valid; 01932 }
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.
init | Party number structure to initialize. | |
guide | Source party number to use as a guide in initializing. |
Definition at line 1909 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().
01910 { 01911 init->str = NULL; 01912 init->plan = guide->plan; 01913 init->presentation = guide->presentation; 01914 init->valid = guide->valid; 01915 }
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 2270 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_channel_redirecting_macro(), begin_dial_channel(), dial_exec_full(), do_forward(), local_call(), and ring_entry().
02271 { 02272 if (dest == src) { 02273 /* Don't copy to self */ 02274 return; 02275 } 02276 02277 ast_party_id_copy(&dest->from, &src->from); 02278 ast_party_id_copy(&dest->to, &src->to); 02279 dest->count = src->count; 02280 dest->reason = src->reason; 02281 }
void ast_party_redirecting_free | ( | struct ast_party_redirecting * | doomed | ) |
Destroy the redirecting information contents.
doomed | The redirecting information to destroy. |
Definition at line 2299 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(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), redirecting_write(), and sig_pri_handle_subcmds().
02300 { 02301 ast_party_id_free(&doomed->from); 02302 ast_party_id_free(&doomed->to); 02303 }
void ast_party_redirecting_init | ( | struct ast_party_redirecting * | init | ) |
Initialize the given redirecting structure.
init | Redirecting structure to initialize. |
Definition at line 2262 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(), do_forward(), handle_request_invite(), handle_response(), and handle_response_invite().
02263 { 02264 ast_party_id_init(&init->from); 02265 ast_party_id_init(&init->to); 02266 init->count = 0; 02267 init->reason = AST_REDIRECTING_REASON_UNKNOWN; 02268 }
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.
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 2291 of file channel.c.
References ast_party_id_set(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, ast_party_redirecting::to, and update().
Referenced by ast_channel_set_redirecting().
02292 { 02293 ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL); 02294 ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL); 02295 dest->reason = src->reason; 02296 dest->count = src->count; 02297 }
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.
init | Redirecting id structure to initialize. | |
guide | Source redirecting id to use as a guide in initializing. |
Definition at line 2283 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().
02284 { 02285 ast_party_id_set_init(&init->from, &guide->from); 02286 ast_party_id_set_init(&init->to, &guide->to); 02287 init->count = guide->count; 02288 init->reason = guide->reason; 02289 }
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 1948 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().
01949 { 01950 if (dest == src) { 01951 /* Don't copy to self */ 01952 return; 01953 } 01954 01955 ast_free(dest->str); 01956 dest->str = ast_strdup(src->str); 01957 dest->type = src->type; 01958 dest->odd_even_indicator = src->odd_even_indicator; 01959 dest->valid = src->valid; 01960 }
void ast_party_subaddress_free | ( | struct ast_party_subaddress * | doomed | ) |
Destroy the party subaddress contents.
doomed | The party subaddress to destroy. |
Definition at line 1987 of file channel.c.
References ast_free, and ast_party_subaddress::str.
Referenced by ast_party_dialed_free(), and ast_party_id_free().
void ast_party_subaddress_init | ( | struct ast_party_subaddress * | init | ) |
Initialize the given subaddress structure.
init | Subaddress structure to initialize. |
Definition at line 1940 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(), sig_pri_call(), and sig_pri_set_subaddress().
01941 { 01942 init->str = NULL; 01943 init->type = 0; 01944 init->odd_even_indicator = 0; 01945 init->valid = 0; 01946 }
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 1970 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().
01971 { 01972 if (dest == src) { 01973 /* Don't set to self */ 01974 return; 01975 } 01976 01977 if (src->str && src->str != dest->str) { 01978 ast_free(dest->str); 01979 dest->str = ast_strdup(src->str); 01980 } 01981 01982 dest->type = src->type; 01983 dest->odd_even_indicator = src->odd_even_indicator; 01984 dest->valid = src->valid; 01985 }
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.
init | Party subaddress structure to initialize. | |
guide | Source party subaddress to use as a guide in initializing. |
Definition at line 1962 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().
01963 { 01964 init->str = NULL; 01965 init->type = guide->type; 01966 init->odd_even_indicator = guide->odd_even_indicator; 01967 init->valid = guide->valid; 01968 }
void ast_poll_channel_add | ( | struct ast_channel * | chan0, | |
struct ast_channel * | chan1 | |||
) |
Add a channel to an optimized waitfor
Definition at line 2560 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().
02561 { 02562 #ifdef HAVE_EPOLL 02563 struct epoll_event ev; 02564 int i = 0; 02565 02566 if (chan0->epfd == -1) 02567 return; 02568 02569 /* Iterate through the file descriptors on chan1, adding them to chan0 */ 02570 for (i = 0; i < AST_MAX_FDS; i++) { 02571 if (chan1->fds[i] == -1) 02572 continue; 02573 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 02574 ev.data.ptr = chan1->epfd_data[i]; 02575 epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev); 02576 } 02577 02578 #endif 02579 return; 02580 }
void ast_poll_channel_del | ( | struct ast_channel * | chan0, | |
struct ast_channel * | chan1 | |||
) |
Delete a channel from an optimized waitfor
Definition at line 2583 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by feature_request_and_dial(), and monitor_dial().
02584 { 02585 #ifdef HAVE_EPOLL 02586 struct epoll_event ev; 02587 int i = 0; 02588 02589 if (chan0->epfd == -1) 02590 return; 02591 02592 for (i = 0; i < AST_MAX_FDS; i++) { 02593 if (chan1->fds[i] == -1) 02594 continue; 02595 epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev); 02596 } 02597 02598 #endif 02599 return; 02600 }
char* ast_print_group | ( | char * | buf, | |
int | buflen, | |||
ast_group_t | group | |||
) |
print call- and pickup groups into buffer
Definition at line 7731 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().
07732 { 07733 unsigned int i; 07734 int first = 1; 07735 char num[3]; 07736 07737 buf[0] = '\0'; 07738 07739 if (!group) /* Return empty string if no group */ 07740 return buf; 07741 07742 for (i = 0; i <= 63; i++) { /* Max group is 63 */ 07743 if (group & ((ast_group_t) 1 << i)) { 07744 if (!first) { 07745 strncat(buf, ", ", buflen - strlen(buf) - 1); 07746 } else { 07747 first = 0; 07748 } 07749 snprintf(num, sizeof(num), "%u", i); 07750 strncat(buf, num, buflen - strlen(buf) - 1); 07751 } 07752 } 07753 return buf; 07754 }
int ast_prod | ( | struct ast_channel * | chan | ) |
Send empty audio to prime a channel driver.
Definition at line 4551 of file channel.c.
References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), chanlist::chan, 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().
04552 { 04553 struct ast_frame a = { AST_FRAME_VOICE }; 04554 char nothing[128]; 04555 04556 /* Send an empty audio frame to get things moving */ 04557 if (chan->_state != AST_STATE_UP) { 04558 ast_debug(1, "Prodding channel '%s'\n", chan->name); 04559 a.subclass.codec = chan->rawwriteformat; 04560 a.data.ptr = nothing + AST_FRIENDLY_OFFSET; 04561 a.src = "ast_prod"; /* this better match check in ast_write */ 04562 if (ast_write(chan, &a)) 04563 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name); 04564 } 04565 return 0; 04566 }
int ast_queue_control | ( | struct ast_channel * | chan, | |
enum ast_control_frame_type | control | |||
) |
Queue a control frame with payload.
chan | channel to queue frame onto | |
control | type of control frame |
zero | on success | |
non-zero | on failure |
Definition at line 1511 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), chanlist::chan, and f.
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_pickup_call(), 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(), pickup_do(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), sig_pri_handle_subcmds(), skinny_call(), skinny_transfer(), skinny_unhold(), unistim_call(), and update_state().
01512 { 01513 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control }; 01514 return ast_queue_frame(chan, &f); 01515 }
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 channel does not need to be locked before calling this function.
Definition at line 1518 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), chanlist::chan, and f.
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(), sip_sipredirect(), and skinny_hold().
01520 { 01521 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen }; 01522 return ast_queue_frame(chan, &f); 01523 }
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 1468 of file channel.c.
References __ast_queue_frame(), and chanlist::chan.
Referenced by __ast_channel_masquerade(), __ast_read(), __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_new(), alsa_call(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), 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(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), usbradio_read(), and wakeup_sub().
01469 { 01470 return __ast_queue_frame(chan, fin, 0, NULL); 01471 }
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 1473 of file channel.c.
References __ast_queue_frame(), and chanlist::chan.
Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), ast_safe_sleep_conditional(), and feature_request_and_dial().
01474 { 01475 return __ast_queue_frame(chan, fin, 1, NULL); 01476 }
int ast_queue_hangup | ( | struct ast_channel * | chan | ) |
Queue a hangup frame.
Definition at line 1479 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, chanlist::chan, and f.
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().
01480 { 01481 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP }; 01482 /* Yeah, let's not change a lock-critical value without locking */ 01483 if (!ast_channel_trylock(chan)) { 01484 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01485 ast_channel_unlock(chan); 01486 } 01487 return ast_queue_frame(chan, &f); 01488 }
int ast_queue_hangup_with_cause | ( | struct ast_channel * | chan, | |
int | cause | |||
) |
Queue a hangup frame with hangupcause set.
[in] | chan | channel to queue frame onto |
[in] | cause | the hangup cause |
Definition at line 1491 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, chanlist::chan, f, and ast_channel::hangupcause.
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(), handle_response_notify(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), misdn_answer(), retrans_pkt(), and TransferCallStep1().
01492 { 01493 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP }; 01494 01495 if (cause >= 0) 01496 f.data.uint32 = cause; 01497 01498 /* Yeah, let's not change a lock-critical value without locking */ 01499 if (!ast_channel_trylock(chan)) { 01500 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01501 if (cause < 0) 01502 f.data.uint32 = chan->hangupcause; 01503 01504 ast_channel_unlock(chan); 01505 } 01506 01507 return ast_queue_frame(chan, &f); 01508 }
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' |
Unlike ast_answer(), this function will not wait for media flow to begin. The caller should be careful before sending media to the channel before incoming media arrives, as the outgoing media may be lost.
0 | on success | |
non-zero | on failure |
Definition at line 2798 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, chanlist::chan, and ast_channel::tech.
Referenced by __ast_answer(), and ast_bridge_call().
02799 { 02800 int res = 0; 02801 02802 ast_channel_lock(chan); 02803 02804 /* You can't answer an outbound call */ 02805 if (ast_test_flag(chan, AST_FLAG_OUTGOING)) { 02806 ast_channel_unlock(chan); 02807 return 0; 02808 } 02809 02810 /* Stop if we're a zombie or need a soft hangup */ 02811 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 02812 ast_channel_unlock(chan); 02813 return -1; 02814 } 02815 02816 ast_channel_unlock(chan); 02817 02818 switch (chan->_state) { 02819 case AST_STATE_RINGING: 02820 case AST_STATE_RING: 02821 ast_channel_lock(chan); 02822 if (chan->tech->answer) { 02823 res = chan->tech->answer(chan); 02824 } 02825 ast_setstate(chan, AST_STATE_UP); 02826 if (cdr_answer) { 02827 ast_cdr_answer(chan->cdr); 02828 } 02829 ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL); 02830 ast_channel_unlock(chan); 02831 break; 02832 case AST_STATE_UP: 02833 ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL); 02834 /* Calling ast_cdr_answer when it it has previously been called 02835 * is essentially a no-op, so it is safe. 02836 */ 02837 if (cdr_answer) { 02838 ast_cdr_answer(chan->cdr); 02839 } 02840 break; 02841 default: 02842 break; 02843 } 02844 02845 ast_indicate(chan, -1); 02846 02847 return res; 02848 }
struct ast_frame* ast_read | ( | struct ast_channel * | chan | ) |
Reads a frame.
chan | channel to read a frame from |
Definition at line 4174 of file channel.c.
References __ast_read(), and chanlist::chan.
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_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), async_wait(), autoservice_run(), background_detect_exec(), channel_spy(), check_goto_on_transfer(), conf_flush(), conf_run(), 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(), iax_park_thread(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), local_bridge_loop(), manage_parkinglot(), masq_park_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), recordthread(), remote_bridge_loop(), rpt(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().
04175 { 04176 return __ast_read(chan, 0); 04177 }
struct ast_frame* ast_read_noaudio | ( | struct ast_channel * | chan | ) |
Reads a frame, returning AST_FRAME_NULL frame if audio.
chan | channel to read a frame from |
Definition at line 4179 of file channel.c.
References __ast_read(), and chanlist::chan.
Referenced by ast_bridge_handle_trip(), and conf_run().
04180 { 04181 return __ast_read(chan, 1); 04182 }
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 |
Definition at line 5527 of file channel.c.
References ast_readstring_full().
Referenced by 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().
05528 { 05529 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1); 05530 }
int ast_readstring_full | ( | struct ast_channel * | c, | |
char * | s, | |||
int | len, | |||
int | timeout, | |||
int | rtimeout, | |||
char * | enders, | |||
int | audiofd, | |||
int | ctrlfd | |||
) |
Definition at line 5532 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().
05533 { 05534 int pos = 0; /* index in the buffer where we accumulate digits */ 05535 int to = ftimeout; 05536 05537 struct ast_silence_generator *silgen = NULL; 05538 05539 /* Stop if we're a zombie or need a soft hangup */ 05540 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 05541 return -1; 05542 if (!len) 05543 return -1; 05544 for (;;) { 05545 int d; 05546 if (c->stream) { 05547 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd); 05548 ast_stopstream(c); 05549 if (!silgen && ast_opt_transmit_silence) 05550 silgen = ast_channel_start_silence_generator(c); 05551 usleep(1000); 05552 if (!d) 05553 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 05554 } else { 05555 if (!silgen && ast_opt_transmit_silence) 05556 silgen = ast_channel_start_silence_generator(c); 05557 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 05558 } 05559 if (d < 0) { 05560 ast_channel_stop_silence_generator(c, silgen); 05561 return AST_GETDATA_FAILED; 05562 } 05563 if (d == 0) { 05564 s[pos] = '\0'; 05565 ast_channel_stop_silence_generator(c, silgen); 05566 return AST_GETDATA_TIMEOUT; 05567 } 05568 if (d == 1) { 05569 s[pos] = '\0'; 05570 ast_channel_stop_silence_generator(c, silgen); 05571 return AST_GETDATA_INTERRUPTED; 05572 } 05573 if (strchr(enders, d) && (pos == 0)) { 05574 s[pos] = '\0'; 05575 ast_channel_stop_silence_generator(c, silgen); 05576 return AST_GETDATA_EMPTY_END_TERMINATED; 05577 } 05578 if (!strchr(enders, d)) { 05579 s[pos++] = d; 05580 } 05581 if (strchr(enders, d) || (pos >= len)) { 05582 s[pos] = '\0'; 05583 ast_channel_stop_silence_generator(c, silgen); 05584 return AST_GETDATA_COMPLETE; 05585 } 05586 to = timeout; 05587 } 05588 /* Never reached */ 05589 return 0; 05590 }
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) |
Definition at line 4427 of file channel.c.
References ast_free, ast_recvtext(), and chanlist::chan.
Referenced by handle_recvchar().
04428 { 04429 int c; 04430 char *buf = ast_recvtext(chan, timeout); 04431 if (buf == NULL) 04432 return -1; /* error or timeout */ 04433 c = *(unsigned char *)buf; 04434 ast_free(buf); 04435 return c; 04436 }
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 4438 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(), chanlist::chan, and f.
Referenced by ast_recvchar(), and handle_recvtext().
04439 { 04440 int res, done = 0; 04441 char *buf = NULL; 04442 04443 while (!done) { 04444 struct ast_frame *f; 04445 if (ast_check_hangup(chan)) 04446 break; 04447 res = ast_waitfor(chan, timeout); 04448 if (res <= 0) /* timeout or error */ 04449 break; 04450 timeout = res; /* update timeout */ 04451 f = ast_read(chan); 04452 if (f == NULL) 04453 break; /* no frame */ 04454 if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) 04455 done = 1; /* force a break */ 04456 else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ 04457 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */ 04458 done = 1; 04459 } 04460 ast_frfree(f); 04461 } 04462 return buf; 04463 }
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 8633 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, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_redirecting::reason, ast_party_name_ies::str, ast_party_redirecting::to, update(), and value.
Referenced by ast_channel_queue_redirecting_update(), ast_channel_update_redirecting(), and local_indicate().
08634 { 08635 int32_t value; 08636 size_t pos = 0; 08637 int res; 08638 08639 static const struct ast_party_id_ies from_ies = { 08640 .name.str = AST_REDIRECTING_FROM_NAME, 08641 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET, 08642 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION, 08643 .name.valid = AST_REDIRECTING_FROM_NAME_VALID, 08644 08645 .number.str = AST_REDIRECTING_FROM_NUMBER, 08646 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN, 08647 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION, 08648 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID, 08649 08650 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS, 08651 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE, 08652 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, 08653 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID, 08654 08655 .tag = AST_REDIRECTING_FROM_TAG, 08656 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION, 08657 }; 08658 static const struct ast_party_id_ies to_ies = { 08659 .name.str = AST_REDIRECTING_TO_NAME, 08660 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET, 08661 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION, 08662 .name.valid = AST_REDIRECTING_TO_NAME_VALID, 08663 08664 .number.str = AST_REDIRECTING_TO_NUMBER, 08665 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN, 08666 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION, 08667 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID, 08668 08669 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS, 08670 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE, 08671 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, 08672 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID, 08673 08674 .tag = AST_REDIRECTING_TO_TAG, 08675 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION, 08676 }; 08677 08678 /* Redirecting frame version */ 08679 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 08680 ast_log(LOG_WARNING, "No space left for redirecting frame version\n"); 08681 return -1; 08682 } 08683 data[pos++] = AST_REDIRECTING_VERSION; 08684 data[pos++] = 1; 08685 data[pos++] = 2;/* Version 1 did not have a version ie */ 08686 08687 res = party_id_build_data(data + pos, datalen - pos, &redirecting->from, 08688 "redirecting-from", &from_ies, update ? &update->from : NULL); 08689 if (res < 0) { 08690 return -1; 08691 } 08692 pos += res; 08693 08694 res = party_id_build_data(data + pos, datalen - pos, &redirecting->to, 08695 "redirecting-to", &to_ies, update ? &update->to : NULL); 08696 if (res < 0) { 08697 return -1; 08698 } 08699 pos += res; 08700 08701 /* Redirecting reason */ 08702 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08703 ast_log(LOG_WARNING, "No space left for redirecting reason\n"); 08704 return -1; 08705 } 08706 data[pos++] = AST_REDIRECTING_REASON; 08707 data[pos++] = sizeof(value); 08708 value = htonl(redirecting->reason); 08709 memcpy(data + pos, &value, sizeof(value)); 08710 pos += sizeof(value); 08711 08712 /* Redirecting count */ 08713 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08714 ast_log(LOG_WARNING, "No space left for redirecting count\n"); 08715 return -1; 08716 } 08717 data[pos++] = AST_REDIRECTING_COUNT; 08718 data[pos++] = sizeof(value); 08719 value = htonl(redirecting->count); 08720 memcpy(data + pos, &value, sizeof(value)); 08721 pos += sizeof(value); 08722 08723 return pos; 08724 }
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. |
The filled in id structure needs to be destroyed by ast_party_redirecting_free() when it is no longer needed.
Definition at line 8726 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().
08727 { 08728 size_t pos; 08729 unsigned char ie_len; 08730 unsigned char ie_id; 08731 int32_t value; 08732 int frame_version = 1; 08733 int from_combined_presentation = 0; 08734 int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08735 int to_combined_presentation = 0; 08736 int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08737 08738 for (pos = 0; pos < datalen; pos += ie_len) { 08739 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) { 08740 ast_log(LOG_WARNING, "Invalid redirecting update\n"); 08741 return -1; 08742 } 08743 ie_id = data[pos++]; 08744 ie_len = data[pos++]; 08745 if (datalen < pos + ie_len) { 08746 ast_log(LOG_WARNING, "Invalid redirecting update\n"); 08747 return -1; 08748 } 08749 08750 switch (ie_id) { 08751 /* Redirecting frame version */ 08752 case AST_REDIRECTING_VERSION: 08753 if (ie_len != 1) { 08754 ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n", 08755 (unsigned) ie_len); 08756 break; 08757 } 08758 frame_version = data[pos]; 08759 break; 08760 /* Redirecting-from party id name */ 08761 case AST_REDIRECTING_FROM_NAME: 08762 ast_free(redirecting->from.name.str); 08763 redirecting->from.name.str = ast_malloc(ie_len + 1); 08764 if (redirecting->from.name.str) { 08765 memcpy(redirecting->from.name.str, data + pos, ie_len); 08766 redirecting->from.name.str[ie_len] = 0; 08767 } 08768 break; 08769 case AST_REDIRECTING_FROM_NAME_CHAR_SET: 08770 if (ie_len != 1) { 08771 ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n", 08772 (unsigned) ie_len); 08773 break; 08774 } 08775 redirecting->from.name.char_set = data[pos]; 08776 break; 08777 case AST_REDIRECTING_FROM_NAME_PRESENTATION: 08778 if (ie_len != 1) { 08779 ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n", 08780 (unsigned) ie_len); 08781 break; 08782 } 08783 redirecting->from.name.presentation = data[pos]; 08784 break; 08785 case AST_REDIRECTING_FROM_NAME_VALID: 08786 if (ie_len != 1) { 08787 ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n", 08788 (unsigned) ie_len); 08789 break; 08790 } 08791 redirecting->from.name.valid = data[pos]; 08792 break; 08793 /* Redirecting-from party id number */ 08794 case AST_REDIRECTING_FROM_NUMBER: 08795 ast_free(redirecting->from.number.str); 08796 redirecting->from.number.str = ast_malloc(ie_len + 1); 08797 if (redirecting->from.number.str) { 08798 memcpy(redirecting->from.number.str, data + pos, ie_len); 08799 redirecting->from.number.str[ie_len] = 0; 08800 } 08801 break; 08802 case AST_REDIRECTING_FROM_NUMBER_PLAN: 08803 if (ie_len != 1) { 08804 ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n", 08805 (unsigned) ie_len); 08806 break; 08807 } 08808 redirecting->from.number.plan = data[pos]; 08809 break; 08810 case AST_REDIRECTING_FROM_NUMBER_PRESENTATION: 08811 if (ie_len != 1) { 08812 ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n", 08813 (unsigned) ie_len); 08814 break; 08815 } 08816 redirecting->from.number.presentation = data[pos]; 08817 break; 08818 case AST_REDIRECTING_FROM_NUMBER_VALID: 08819 if (ie_len != 1) { 08820 ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n", 08821 (unsigned) ie_len); 08822 break; 08823 } 08824 redirecting->from.number.valid = data[pos]; 08825 break; 08826 /* Redirecting-from party id combined presentation */ 08827 case AST_REDIRECTING_FROM_ID_PRESENTATION: 08828 if (ie_len != 1) { 08829 ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n", 08830 (unsigned) ie_len); 08831 break; 08832 } 08833 from_combined_presentation = data[pos]; 08834 got_from_combined_presentation = 1; 08835 break; 08836 /* Redirecting-from party id subaddress */ 08837 case AST_REDIRECTING_FROM_SUBADDRESS: 08838 ast_free(redirecting->from.subaddress.str); 08839 redirecting->from.subaddress.str = ast_malloc(ie_len + 1); 08840 if (redirecting->from.subaddress.str) { 08841 memcpy(redirecting->from.subaddress.str, data + pos, ie_len); 08842 redirecting->from.subaddress.str[ie_len] = 0; 08843 } 08844 break; 08845 case AST_REDIRECTING_FROM_SUBADDRESS_TYPE: 08846 if (ie_len != 1) { 08847 ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n", 08848 (unsigned) ie_len); 08849 break; 08850 } 08851 redirecting->from.subaddress.type = data[pos]; 08852 break; 08853 case AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN: 08854 if (ie_len != 1) { 08855 ast_log(LOG_WARNING, 08856 "Invalid redirecting-from subaddress odd-even indicator (%u)\n", 08857 (unsigned) ie_len); 08858 break; 08859 } 08860 redirecting->from.subaddress.odd_even_indicator = data[pos]; 08861 break; 08862 case AST_REDIRECTING_FROM_SUBADDRESS_VALID: 08863 if (ie_len != 1) { 08864 ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n", 08865 (unsigned) ie_len); 08866 break; 08867 } 08868 redirecting->from.subaddress.valid = data[pos]; 08869 break; 08870 /* Redirecting-from party id tag */ 08871 case AST_REDIRECTING_FROM_TAG: 08872 ast_free(redirecting->from.tag); 08873 redirecting->from.tag = ast_malloc(ie_len + 1); 08874 if (redirecting->from.tag) { 08875 memcpy(redirecting->from.tag, data + pos, ie_len); 08876 redirecting->from.tag[ie_len] = 0; 08877 } 08878 break; 08879 /* Redirecting-to party id name */ 08880 case AST_REDIRECTING_TO_NAME: 08881 ast_free(redirecting->to.name.str); 08882 redirecting->to.name.str = ast_malloc(ie_len + 1); 08883 if (redirecting->to.name.str) { 08884 memcpy(redirecting->to.name.str, data + pos, ie_len); 08885 redirecting->to.name.str[ie_len] = 0; 08886 } 08887 break; 08888 case AST_REDIRECTING_TO_NAME_CHAR_SET: 08889 if (ie_len != 1) { 08890 ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n", 08891 (unsigned) ie_len); 08892 break; 08893 } 08894 redirecting->to.name.char_set = data[pos]; 08895 break; 08896 case AST_REDIRECTING_TO_NAME_PRESENTATION: 08897 if (ie_len != 1) { 08898 ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n", 08899 (unsigned) ie_len); 08900 break; 08901 } 08902 redirecting->to.name.presentation = data[pos]; 08903 break; 08904 case AST_REDIRECTING_TO_NAME_VALID: 08905 if (ie_len != 1) { 08906 ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n", 08907 (unsigned) ie_len); 08908 break; 08909 } 08910 redirecting->to.name.valid = data[pos]; 08911 break; 08912 /* Redirecting-to party id number */ 08913 case AST_REDIRECTING_TO_NUMBER: 08914 ast_free(redirecting->to.number.str); 08915 redirecting->to.number.str = ast_malloc(ie_len + 1); 08916 if (redirecting->to.number.str) { 08917 memcpy(redirecting->to.number.str, data + pos, ie_len); 08918 redirecting->to.number.str[ie_len] = 0; 08919 } 08920 break; 08921 case AST_REDIRECTING_TO_NUMBER_PLAN: 08922 if (ie_len != 1) { 08923 ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n", 08924 (unsigned) ie_len); 08925 break; 08926 } 08927 redirecting->to.number.plan = data[pos]; 08928 break; 08929 case AST_REDIRECTING_TO_NUMBER_PRESENTATION: 08930 if (ie_len != 1) { 08931 ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n", 08932 (unsigned) ie_len); 08933 break; 08934 } 08935 redirecting->to.number.presentation = data[pos]; 08936 break; 08937 case AST_REDIRECTING_TO_NUMBER_VALID: 08938 if (ie_len != 1) { 08939 ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n", 08940 (unsigned) ie_len); 08941 break; 08942 } 08943 redirecting->to.number.valid = data[pos]; 08944 break; 08945 /* Redirecting-to party id combined presentation */ 08946 case AST_REDIRECTING_TO_ID_PRESENTATION: 08947 if (ie_len != 1) { 08948 ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n", 08949 (unsigned) ie_len); 08950 break; 08951 } 08952 to_combined_presentation = data[pos]; 08953 got_to_combined_presentation = 1; 08954 break; 08955 /* Redirecting-to party id subaddress */ 08956 case AST_REDIRECTING_TO_SUBADDRESS: 08957 ast_free(redirecting->to.subaddress.str); 08958 redirecting->to.subaddress.str = ast_malloc(ie_len + 1); 08959 if (redirecting->to.subaddress.str) { 08960 memcpy(redirecting->to.subaddress.str, data + pos, ie_len); 08961 redirecting->to.subaddress.str[ie_len] = 0; 08962 } 08963 break; 08964 case AST_REDIRECTING_TO_SUBADDRESS_TYPE: 08965 if (ie_len != 1) { 08966 ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n", 08967 (unsigned) ie_len); 08968 break; 08969 } 08970 redirecting->to.subaddress.type = data[pos]; 08971 break; 08972 case AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN: 08973 if (ie_len != 1) { 08974 ast_log(LOG_WARNING, 08975 "Invalid redirecting-to subaddress odd-even indicator (%u)\n", 08976 (unsigned) ie_len); 08977 break; 08978 } 08979 redirecting->to.subaddress.odd_even_indicator = data[pos]; 08980 break; 08981 case AST_REDIRECTING_TO_SUBADDRESS_VALID: 08982 if (ie_len != 1) { 08983 ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n", 08984 (unsigned) ie_len); 08985 break; 08986 } 08987 redirecting->to.subaddress.valid = data[pos]; 08988 break; 08989 /* Redirecting-to party id tag */ 08990 case AST_REDIRECTING_TO_TAG: 08991 ast_free(redirecting->to.tag); 08992 redirecting->to.tag = ast_malloc(ie_len + 1); 08993 if (redirecting->to.tag) { 08994 memcpy(redirecting->to.tag, data + pos, ie_len); 08995 redirecting->to.tag[ie_len] = 0; 08996 } 08997 break; 08998 /* Redirecting reason */ 08999 case AST_REDIRECTING_REASON: 09000 if (ie_len != sizeof(value)) { 09001 ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n", 09002 (unsigned) ie_len); 09003 break; 09004 } 09005 memcpy(&value, data + pos, sizeof(value)); 09006 redirecting->reason = ntohl(value); 09007 break; 09008 /* Redirecting count */ 09009 case AST_REDIRECTING_COUNT: 09010 if (ie_len != sizeof(value)) { 09011 ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n", 09012 (unsigned) ie_len); 09013 break; 09014 } 09015 memcpy(&value, data + pos, sizeof(value)); 09016 redirecting->count = ntohl(value); 09017 break; 09018 /* Redirecting unknown element */ 09019 default: 09020 ast_log(LOG_DEBUG, "Unknown redirecting element: %u (%u)\n", 09021 (unsigned) ie_id, (unsigned) ie_len); 09022 break; 09023 } 09024 } 09025 09026 switch (frame_version) { 09027 case 1: 09028 /* 09029 * The other end is an earlier version that we need to adjust 09030 * for compatibility. 09031 */ 09032 redirecting->from.name.valid = 1; 09033 redirecting->from.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 09034 redirecting->from.number.valid = 1; 09035 if (got_from_combined_presentation) { 09036 redirecting->from.name.presentation = from_combined_presentation; 09037 redirecting->from.number.presentation = from_combined_presentation; 09038 } 09039 09040 redirecting->to.name.valid = 1; 09041 redirecting->to.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 09042 redirecting->to.number.valid = 1; 09043 if (got_to_combined_presentation) { 09044 redirecting->to.name.presentation = to_combined_presentation; 09045 redirecting->to.number.presentation = to_combined_presentation; 09046 } 09047 break; 09048 case 2: 09049 /* The other end is at the same level as we are. */ 09050 break; 09051 default: 09052 /* 09053 * The other end is newer than we are. 09054 * We need to assume that they are compatible with us. 09055 */ 09056 ast_log(LOG_DEBUG, "Redirecting frame has newer version: %u\n", 09057 (unsigned) frame_version); 09058 break; 09059 } 09060 09061 return 0; 09062 }
struct ast_channel* ast_request | ( | const char * | type, | |
format_t | format, | |||
const struct ast_channel * | requestor, | |||
void * | data, | |||
int * | status | |||
) |
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 |
NULL | failure | |
non-NULL | channel on success |
Definition at line 5385 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, chanlist::list, LOG_WARNING, ast_channel_tech::requester, set_security_requirements(), ast_channel::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(), and rpt_tele_thread().
05386 { 05387 struct chanlist *chan; 05388 struct ast_channel *c; 05389 format_t capabilities; 05390 format_t fmt; 05391 int res; 05392 int foo; 05393 format_t videoformat = format & AST_FORMAT_VIDEO_MASK; 05394 format_t textformat = format & AST_FORMAT_TEXT_MASK; 05395 05396 if (!cause) 05397 cause = &foo; 05398 *cause = AST_CAUSE_NOTDEFINED; 05399 05400 if (AST_RWLIST_RDLOCK(&backends)) { 05401 ast_log(LOG_WARNING, "Unable to lock technology backend list\n"); 05402 return NULL; 05403 } 05404 05405 AST_RWLIST_TRAVERSE(&backends, chan, list) { 05406 if (strcasecmp(type, chan->tech->type)) 05407 continue; 05408 05409 capabilities = chan->tech->capabilities; 05410 fmt = format & AST_FORMAT_AUDIO_MASK; 05411 if (fmt) { 05412 /* We have audio - is it possible to connect the various calls to each other? 05413 (Avoid this check for calls without audio, like text+video calls) 05414 */ 05415 res = ast_translator_best_choice(&fmt, &capabilities); 05416 if (res < 0) { 05417 char tmp1[256], tmp2[256]; 05418 ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type, 05419 ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities), 05420 ast_getformatname_multiple(tmp2, sizeof(tmp2), format)); 05421 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 05422 AST_RWLIST_UNLOCK(&backends); 05423 return NULL; 05424 } 05425 } 05426 AST_RWLIST_UNLOCK(&backends); 05427 if (!chan->tech->requester) 05428 return NULL; 05429 05430 if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, requestor, data, cause))) 05431 return NULL; 05432 05433 if (set_security_requirements(requestor, c)) { 05434 ast_log(LOG_WARNING, "Setting security requirements failed\n"); 05435 c = ast_channel_release(c); 05436 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 05437 return NULL; 05438 } 05439 05440 /* no need to generate a Newchannel event here; it is done in the channel_alloc call */ 05441 return c; 05442 } 05443 05444 ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type); 05445 *cause = AST_CAUSE_NOSUCHDRIVER; 05446 AST_RWLIST_UNLOCK(&backends); 05447 05448 return NULL; 05449 }
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 | |||
) |
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 5340 of file channel.c.
References __ast_request_and_dial().
Referenced by ast_pbx_outgoing_exten(), and generic_recall().
05341 { 05342 return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL); 05343 }
int ast_safe_sleep | ( | struct ast_channel * | chan, | |
int | ms | |||
) |
Wait for a specified amount of time, looking for hangups.
chan | channel to wait for | |
ms | length of time in milliseconds to sleep |
Definition at line 1822 of file channel.c.
References ast_safe_sleep_conditional(), and chanlist::chan.
Referenced by __analog_ss_thread(), alarmreceiver_exec(), analog_ss_thread(), ast_adsi_transmit_message_full(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), conf_run(), dictate_exec(), flash_exec(), function_ilink(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), parkcall_helper(), 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(), wait_for_hangup(), wait_interval(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().
01823 { 01824 return ast_safe_sleep_conditional(chan, ms, NULL, NULL); 01825 }
int ast_safe_sleep_conditional | ( | struct ast_channel * | chan, | |
int | ms, | |||
int(*)(void *) | cond, | |||
void * | data | |||
) |
Wait for a specified amount of time, looking for hangups and a condition argument.
chan | channel to wait for | |
ms | length of time in milliseconds to sleep | |
cond | a function pointer for testing continue condition | |
data | argument to be passed to the condition test function |
Definition at line 1755 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(), chanlist::chan, f, and ast_channel::generatordata.
Referenced by ast_safe_sleep(), and login_exec().
01756 { 01757 struct ast_frame *f; 01758 struct ast_silence_generator *silgen = NULL; 01759 int res = 0; 01760 AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames; 01761 01762 AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames); 01763 01764 /* If no other generator is present, start silencegen while waiting */ 01765 if (ast_opt_transmit_silence && !chan->generatordata) { 01766 silgen = ast_channel_start_silence_generator(chan); 01767 } 01768 01769 while (ms > 0) { 01770 struct ast_frame *dup_f = NULL; 01771 if (cond && ((*cond)(data) == 0)) { 01772 break; 01773 } 01774 ms = ast_waitfor(chan, ms); 01775 if (ms < 0) { 01776 res = -1; 01777 break; 01778 } 01779 if (ms > 0) { 01780 f = ast_read(chan); 01781 if (!f) { 01782 res = -1; 01783 break; 01784 } 01785 01786 if (!ast_is_deferrable_frame(f)) { 01787 ast_frfree(f); 01788 continue; 01789 } 01790 01791 if ((dup_f = ast_frisolate(f))) { 01792 if (dup_f != f) { 01793 ast_frfree(f); 01794 } 01795 AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list); 01796 } 01797 } 01798 } 01799 01800 /* stop silgen if present */ 01801 if (silgen) { 01802 ast_channel_stop_silence_generator(chan, silgen); 01803 } 01804 01805 /* We need to free all the deferred frames, but we only need to 01806 * queue the deferred frames if there was no error and no 01807 * hangup was received 01808 */ 01809 ast_channel_lock(chan); 01810 while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) { 01811 if (!res) { 01812 ast_queue_frame_head(chan, f); 01813 } 01814 ast_frfree(f); 01815 } 01816 ast_channel_unlock(chan); 01817 01818 return res; 01819 }
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 4541 of file channel.c.
References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), chanlist::chan, 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().
04542 { 04543 if (chan->tech->send_digit_begin) { 04544 ast_senddigit_begin(chan, digit); 04545 ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 04546 } 04547 04548 return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 04549 }
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 4483 of file channel.c.
References ast_debug, ast_playtones_start(), chanlist::chan, ast_channel::name, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().
04484 { 04485 /* Device does not support DTMF tones, lets fake 04486 * it by doing our own generation. */ 04487 static const char * const dtmf_tones[] = { 04488 "941+1336", /* 0 */ 04489 "697+1209", /* 1 */ 04490 "697+1336", /* 2 */ 04491 "697+1477", /* 3 */ 04492 "770+1209", /* 4 */ 04493 "770+1336", /* 5 */ 04494 "770+1477", /* 6 */ 04495 "852+1209", /* 7 */ 04496 "852+1336", /* 8 */ 04497 "852+1477", /* 9 */ 04498 "697+1633", /* A */ 04499 "770+1633", /* B */ 04500 "852+1633", /* C */ 04501 "941+1633", /* D */ 04502 "941+1209", /* * */ 04503 "941+1477" /* # */ 04504 }; 04505 04506 if (!chan->tech->send_digit_begin) 04507 return 0; 04508 04509 if (!chan->tech->send_digit_begin(chan, digit)) 04510 return 0; 04511 04512 if (digit >= '0' && digit <='9') 04513 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0); 04514 else if (digit >= 'A' && digit <= 'D') 04515 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0); 04516 else if (digit == '*') 04517 ast_playtones_start(chan, 0, dtmf_tones[14], 0); 04518 else if (digit == '#') 04519 ast_playtones_start(chan, 0, dtmf_tones[15], 0); 04520 else { 04521 /* not handled */ 04522 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); 04523 } 04524 04525 return 0; 04526 }
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 4528 of file channel.c.
References ast_playtones_stop(), chanlist::chan, ast_channel::generator, ast_channel_tech::send_digit_end, and ast_channel::tech.
Referenced by agent_digit_end(), ast_senddigit(), and ast_write().
04529 { 04530 int res = -1; 04531 04532 if (chan->tech->send_digit_end) 04533 res = chan->tech->send_digit_end(chan, digit, duration); 04534 04535 if (res && chan->generator) 04536 ast_playtones_stop(chan); 04537 04538 return 0; 04539 }
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 |
0 | on success | |
-1 | on failure |
Definition at line 4465 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, chanlist::chan, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.
Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), send_newkey(), and sendtext_exec().
04466 { 04467 int res = 0; 04468 04469 ast_channel_lock(chan); 04470 /* Stop if we're a zombie or need a soft hangup */ 04471 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 04472 ast_channel_unlock(chan); 04473 return -1; 04474 } 04475 CHECK_BLOCKING(chan); 04476 if (chan->tech->send_text) 04477 res = chan->tech->send_text(chan, text); 04478 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04479 ast_channel_unlock(chan); 04480 return res; 04481 }
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.
The channel does not need to be locked before calling this function.
Definition at line 6602 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, chanlist::chan, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), ast_party_number::str, ast_party_name::str, ast_party_number::valid, and ast_party_name::valid.
Referenced by __analog_ss_thread(), __ast_request_and_dial(), analog_ss_thread(), ast_call_forward(), cb_events(), dial_exec_full(), do_forward(), findmeexec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), ring_entry(), rpt_exec(), skinny_newcall(), and socket_process().
06603 { 06604 ast_channel_lock(chan); 06605 06606 if (cid_num) { 06607 chan->caller.id.number.valid = 1; 06608 ast_free(chan->caller.id.number.str); 06609 chan->caller.id.number.str = ast_strdup(cid_num); 06610 } 06611 if (cid_name) { 06612 chan->caller.id.name.valid = 1; 06613 ast_free(chan->caller.id.name.str); 06614 chan->caller.id.name.str = ast_strdup(cid_name); 06615 } 06616 if (cid_ani) { 06617 chan->caller.ani.number.valid = 1; 06618 ast_free(chan->caller.ani.number.str); 06619 chan->caller.ani.number.str = ast_strdup(cid_ani); 06620 } 06621 if (chan->cdr) { 06622 ast_cdr_setcid(chan->cdr, chan); 06623 } 06624 06625 report_new_callerid(chan); 06626 06627 ast_channel_unlock(chan); 06628 }
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 |
Definition at line 2664 of file channel.c.
References ast_bridged_channel(), ast_channel_lock, ast_channel_unlock, ast_string_field_set, ast_strlen_zero(), ast_channel::bridge, chanlist::chan, 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().
02665 { 02666 struct ast_channel *bridge; 02667 02668 ast_channel_lock(chan); 02669 if (force || ast_strlen_zero(chan->hangupsource)) { 02670 ast_string_field_set(chan, hangupsource, source); 02671 } 02672 bridge = ast_bridged_channel(chan); 02673 ast_channel_unlock(chan); 02674 02675 if (bridge && (force || ast_strlen_zero(bridge->hangupsource))) { 02676 ast_channel_lock(bridge); 02677 ast_string_field_set(chan, hangupsource, source); 02678 ast_channel_unlock(bridge); 02679 } 02680 }
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 5052 of file channel.c.
References chanlist::chan, 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(), rpt(), rpt_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().
05053 { 05054 return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, 05055 &chan->readtrans, 0); 05056 }
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 |
Definition at line 7756 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().
07757 { 07758 struct ast_variable *cur; 07759 07760 for (cur = vars; cur; cur = cur->next) 07761 pbx_builtin_setvar_helper(chan, cur->name, cur->value); 07762 }
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 5058 of file channel.c.
References chanlist::chan, 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(), 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().
05059 { 05060 return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, 05061 &chan->writetrans, 1); 05062 }
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 |
Definition at line 3406 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_debug, ast_timer_get_max_rate(), ast_timer_set_rate(), ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.
Referenced by ast_activate_generator(), ast_closestream(), ast_deactivate_generator(), ast_read_generator_actions(), ast_readaudio_callback(), and filestream_destructor().
03407 { 03408 int res; 03409 unsigned int real_rate = rate, max_rate; 03410 03411 ast_channel_lock(c); 03412 03413 if (c->timingfd == -1) { 03414 ast_channel_unlock(c); 03415 return -1; 03416 } 03417 03418 if (!func) { 03419 rate = 0; 03420 data = NULL; 03421 } 03422 03423 if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) { 03424 real_rate = max_rate; 03425 } 03426 03427 ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate); 03428 03429 res = ast_timer_set_rate(c->timer, real_rate); 03430 03431 c->timingfunc = func; 03432 c->timingdata = data; 03433 03434 ast_channel_unlock(c); 03435 03436 return res; 03437 }
int ast_shutting_down | ( | void | ) |
Returns non-zero if Asterisk is being shut down.
Definition at line 795 of file channel.c.
Referenced by handle_request_options().
00796 { 00797 return shutting_down; 00798 }
int ast_softhangup | ( | struct ast_channel * | chan, | |
int | reason | |||
) |
Softly hangup up a channel.
chan | channel to be soft-hung-up | |
reason | an AST_SOFTHANGUP_* reason code |
Definition at line 2641 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_softhangup_nolock(), and chanlist::chan.
Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __unload_module(), agent_hangup(), agent_logoff(), agent_read(), 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().
02642 { 02643 int res; 02644 02645 ast_channel_lock(chan); 02646 res = ast_softhangup_nolock(chan, cause); 02647 ast_channel_unlock(chan); 02648 02649 return res; 02650 }
int ast_softhangup_nolock | ( | struct ast_channel * | chan, | |
int | reason | |||
) |
Softly hangup up a channel (no channel lock).
chan | channel to be soft-hung-up | |
reason | an AST_SOFTHANGUP_* reason code |
Definition at line 2628 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, chanlist::chan, 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(), proc_session_timer(), sig_pri_indicate(), sip_indicate(), and skinny_indicate().
02629 { 02630 ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name); 02631 /* Inform channel driver that we need to be hung up, if it cares */ 02632 chan->_softhangup |= cause; 02633 ast_queue_frame(chan, &ast_null_frame); 02634 /* Interrupt any poll call or such */ 02635 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) 02636 pthread_kill(chan->blocker, SIGURG); 02637 return 0; 02638 }
const char* ast_state2str | ( | enum ast_channel_state | state | ) |
Gives the string form of a given channel state.
Definition at line 937 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(), 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().
00938 { 00939 char *buf; 00940 00941 switch (state) { 00942 case AST_STATE_DOWN: 00943 return "Down"; 00944 case AST_STATE_RESERVED: 00945 return "Rsrvd"; 00946 case AST_STATE_OFFHOOK: 00947 return "OffHook"; 00948 case AST_STATE_DIALING: 00949 return "Dialing"; 00950 case AST_STATE_RING: 00951 return "Ring"; 00952 case AST_STATE_RINGING: 00953 return "Ringing"; 00954 case AST_STATE_UP: 00955 return "Up"; 00956 case AST_STATE_BUSY: 00957 return "Busy"; 00958 case AST_STATE_DIALING_OFFHOOK: 00959 return "Dialing Offhook"; 00960 case AST_STATE_PRERING: 00961 return "Pre-ring"; 00962 default: 00963 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE))) 00964 return "Unknown"; 00965 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state); 00966 return buf; 00967 } 00968 }
int ast_str2cause | ( | const char * | name | ) |
Convert the string form of a cause code to a number.
name | string form of the cause |
Definition at line 923 of file channel.c.
References ARRAY_LEN, and causes.
Referenced by pbx_builtin_hangup().
00924 { 00925 int x; 00926 00927 for (x = 0; x < ARRAY_LEN(causes); x++) 00928 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name))) 00929 return causes[x].cause; 00930 00931 return -1; 00932 }
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 7476 of file channel.c.
References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), f, and ast_channel::generatordata.
Referenced by zapateller_exec().
07477 { 07478 int res; 07479 07480 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol))) 07481 return res; 07482 07483 /* Give us some wiggle room */ 07484 while (chan->generatordata && ast_waitfor(chan, 100) >= 0) { 07485 struct ast_frame *f = ast_read(chan); 07486 if (f) 07487 ast_frfree(f); 07488 else 07489 return -1; 07490 } 07491 return 0; 07492 }
int ast_tonepair_start | ( | struct ast_channel * | chan, | |
int | freq1, | |||
int | freq2, | |||
int | duration, | |||
int | vol | |||
) |
Start a tone going
Definition at line 7458 of file channel.c.
References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, tonepair, and tonepair_def::vol.
Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), play_tone_pair(), rpt_tele_thread(), and sendnoise().
07459 { 07460 struct tonepair_def d = { 0, }; 07461 07462 d.freq1 = freq1; 07463 d.freq2 = freq2; 07464 d.duration = duration; 07465 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */ 07466 if (ast_activate_generator(chan, &tonepair, &d)) 07467 return -1; 07468 return 0; 07469 }
void ast_tonepair_stop | ( | struct ast_channel * | chan | ) |
Stop a tone from playing
Definition at line 7471 of file channel.c.
References ast_deactivate_generator().
Referenced by sendnoise().
07472 { 07473 ast_deactivate_generator(chan); 07474 }
int ast_transfer | ( | struct ast_channel * | chan, | |
char * | dest | |||
) |
Transfer a channel (if supported).
Called by:
Definition at line 5478 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(), chanlist::chan, ast_channel::tech, and ast_channel_tech::transfer.
Referenced by transfer_exec().
05479 { 05480 int res = -1; 05481 05482 /* Stop if we're a zombie or need a soft hangup */ 05483 ast_channel_lock(chan); 05484 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 05485 if (chan->tech->transfer) { 05486 res = chan->tech->transfer(chan, dest); 05487 if (!res) 05488 res = 1; 05489 } else 05490 res = 0; 05491 } 05492 ast_channel_unlock(chan); 05493 05494 if (res <= 0) { 05495 return res; 05496 } 05497 05498 for (;;) { 05499 struct ast_frame *fr; 05500 05501 res = ast_waitfor(chan, -1); 05502 05503 if (res < 0 || !(fr = ast_read(chan))) { 05504 res = -1; 05505 break; 05506 } 05507 05508 if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) { 05509 enum ast_control_transfer *message = fr->data.ptr; 05510 05511 if (*message == AST_TRANSFER_SUCCESS) { 05512 res = 1; 05513 } else { 05514 res = -1; 05515 } 05516 05517 ast_frfree(fr); 05518 break; 05519 } 05520 05521 ast_frfree(fr); 05522 } 05523 05524 return res; 05525 }
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 971 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(), and sig_pri_new_ast_channel().
00972 { 00973 switch (transfercapability) { 00974 case AST_TRANS_CAP_SPEECH: 00975 return "SPEECH"; 00976 case AST_TRANS_CAP_DIGITAL: 00977 return "DIGITAL"; 00978 case AST_TRANS_CAP_RESTRICTED_DIGITAL: 00979 return "RESTRICTED_DIGITAL"; 00980 case AST_TRANS_CAP_3_1K_AUDIO: 00981 return "3K1AUDIO"; 00982 case AST_TRANS_CAP_DIGITAL_W_TONES: 00983 return "DIGITAL_W_TONES"; 00984 case AST_TRANS_CAP_VIDEO: 00985 return "VIDEO"; 00986 default: 00987 return "UNKNOWN"; 00988 } 00989 }
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 |
< | 0 on failure | |
0 | if nothing ever arrived | |
the | # of ms remaining otherwise |
Definition at line 3390 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(), 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(), 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().
03391 { 03392 int oldms = ms; /* -1 if no timeout */ 03393 03394 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms); 03395 if ((ms < 0) && (oldms < 0)) 03396 ms = 0; 03397 return ms; 03398 }
struct ast_channel* ast_waitfor_n | ( | struct ast_channel ** | chan, | |
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.
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 3385 of file channel.c.
References ast_waitfor_nandfds().
Referenced by ast_udptl_bridge(), autoservice_run(), dahdi_bridge(), dial_exec_full(), feature_request_and_dial(), generic_thread_loop(), misdn_bridge(), monitor_dial(), remote_bridge_loop(), rpt(), wait_for_answer(), and wait_for_winner().
03386 { 03387 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms); 03388 }
int ast_waitfor_n_fd | ( | int * | fds, | |
int | n, | |||
int * | ms, | |||
int * | exception | |||
) |
Waits for input on an fd.
Definition at line 3026 of file channel.c.
References ast_waitfor_nandfds().
Referenced by dundi_lookup_internal(), dundi_precache_internal(), and softmix_bridge_thread().
03027 { 03028 int winner = -1; 03029 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms); 03030 return winner; 03031 }
struct ast_channel* ast_waitfor_nandfds | ( | struct ast_channel ** | chan, | |
int | n, | |||
int * | fds, | |||
int | nfds, | |||
int * | exception, | |||
int * | outfd, | |||
int * | ms | |||
) |
Waits for activity on a group of channels.
chan | an array of pointers to channels | |
n | number of channels that are to be waited upon | |
fds | an array of fds to wait upon | |
nfds | the number of fds to wait upon | |
exception | exception flag | |
outfd | fd that had activity on it | |
ms | how long the wait was |
Definition at line 3038 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, and LOG_WARNING.
Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), conf_run(), eivr_comm(), find_cache(), generic_fax_exec(), multiplexed_thread_function(), run_agi(), and waitstream_core().
03041 { 03042 struct timeval start = { 0 , 0 }; 03043 struct pollfd *pfds = NULL; 03044 int res; 03045 long rms; 03046 int x, y, max; 03047 int sz; 03048 struct timeval now = { 0, 0 }; 03049 struct timeval whentohangup = { 0, 0 }, diff; 03050 struct ast_channel *winner = NULL; 03051 struct fdmap { 03052 int chan; 03053 int fdno; 03054 } *fdmap = NULL; 03055 03056 if ((sz = n * AST_MAX_FDS + nfds)) { 03057 pfds = alloca(sizeof(*pfds) * sz); 03058 fdmap = alloca(sizeof(*fdmap) * sz); 03059 } 03060 03061 if (outfd) 03062 *outfd = -99999; 03063 if (exception) 03064 *exception = 0; 03065 03066 /* Perform any pending masquerades */ 03067 for (x = 0; x < n; x++) { 03068 if (c[x]->masq && ast_do_masquerade(c[x])) { 03069 ast_log(LOG_WARNING, "Masquerade failed\n"); 03070 *ms = -1; 03071 return NULL; 03072 } 03073 03074 ast_channel_lock(c[x]); 03075 if (!ast_tvzero(c[x]->whentohangup)) { 03076 if (ast_tvzero(whentohangup)) 03077 now = ast_tvnow(); 03078 diff = ast_tvsub(c[x]->whentohangup, now); 03079 if (diff.tv_sec < 0 || ast_tvzero(diff)) { 03080 /* Should already be hungup */ 03081 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 03082 ast_channel_unlock(c[x]); 03083 return c[x]; 03084 } 03085 if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0) 03086 whentohangup = diff; 03087 } 03088 ast_channel_unlock(c[x]); 03089 } 03090 /* Wait full interval */ 03091 rms = *ms; 03092 /* INT_MAX, not LONG_MAX, because it matters on 64-bit */ 03093 if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) { 03094 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */ 03095 if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */ 03096 rms = *ms; 03097 } 03098 } else if (!ast_tvzero(whentohangup) && rms < 0) { 03099 /* Tiny corner case... call would need to last >24 days */ 03100 rms = INT_MAX; 03101 } 03102 /* 03103 * Build the pollfd array, putting the channels' fds first, 03104 * followed by individual fds. Order is important because 03105 * individual fd's must have priority over channel fds. 03106 */ 03107 max = 0; 03108 for (x = 0; x < n; x++) { 03109 for (y = 0; y < AST_MAX_FDS; y++) { 03110 fdmap[max].fdno = y; /* fd y is linked to this pfds */ 03111 fdmap[max].chan = x; /* channel x is linked to this pfds */ 03112 max += ast_add_fd(&pfds[max], c[x]->fds[y]); 03113 } 03114 CHECK_BLOCKING(c[x]); 03115 } 03116 /* Add the individual fds */ 03117 for (x = 0; x < nfds; x++) { 03118 fdmap[max].chan = -1; 03119 max += ast_add_fd(&pfds[max], fds[x]); 03120 } 03121 03122 if (*ms > 0) 03123 start = ast_tvnow(); 03124 03125 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */ 03126 do { 03127 int kbrms = rms; 03128 if (kbrms > 600000) 03129 kbrms = 600000; 03130 res = ast_poll(pfds, max, kbrms); 03131 if (!res) 03132 rms -= kbrms; 03133 } while (!res && (rms > 0)); 03134 } else { 03135 res = ast_poll(pfds, max, rms); 03136 } 03137 for (x = 0; x < n; x++) 03138 ast_clear_flag(c[x], AST_FLAG_BLOCKING); 03139 if (res < 0) { /* Simulate a timeout if we were interrupted */ 03140 if (errno != EINTR) 03141 *ms = -1; 03142 return NULL; 03143 } 03144 if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */ 03145 now = ast_tvnow(); 03146 for (x = 0; x < n; x++) { 03147 if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) { 03148 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 03149 if (winner == NULL) 03150 winner = c[x]; 03151 } 03152 } 03153 } 03154 if (res == 0) { /* no fd ready, reset timeout and done */ 03155 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */ 03156 return winner; 03157 } 03158 /* 03159 * Then check if any channel or fd has a pending event. 03160 * Remember to check channels first and fds last, as they 03161 * must have priority on setting 'winner' 03162 */ 03163 for (x = 0; x < max; x++) { 03164 res = pfds[x].revents; 03165 if (res == 0) 03166 continue; 03167 if (fdmap[x].chan >= 0) { /* this is a channel */ 03168 winner = c[fdmap[x].chan]; /* override previous winners */ 03169 if (res & POLLPRI) 03170 ast_set_flag(winner, AST_FLAG_EXCEPTION); 03171 else 03172 ast_clear_flag(winner, AST_FLAG_EXCEPTION); 03173 winner->fdno = fdmap[x].fdno; 03174 } else { /* this is an fd */ 03175 if (outfd) 03176 *outfd = pfds[x].fd; 03177 if (exception) 03178 *exception = (res & POLLPRI) ? -1 : 0; 03179 winner = NULL; 03180 } 03181 } 03182 if (*ms > 0) { 03183 *ms -= ast_tvdiff_ms(ast_tvnow(), start); 03184 if (*ms < 0) 03185 *ms = 0; 03186 } 03187 return winner; 03188 }
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 3401 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(), and wait_a_bit().
03402 { 03403 return ast_waitfordigit_full(c, ms, -1, -1); 03404 }
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 3439 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_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(), errno, f, and LOG_WARNING.
Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().
03440 { 03441 /* Stop if we're a zombie or need a soft hangup */ 03442 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 03443 return -1; 03444 03445 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */ 03446 ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); 03447 03448 /* Wait for a digit, no more than ms milliseconds total. */ 03449 03450 while (ms) { 03451 struct ast_channel *rchan; 03452 int outfd=-1; 03453 03454 errno = 0; 03455 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); 03456 03457 if (!rchan && outfd < 0 && ms) { 03458 if (errno == 0 || errno == EINTR) 03459 continue; 03460 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); 03461 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03462 return -1; 03463 } else if (outfd > -1) { 03464 /* The FD we were watching has something waiting */ 03465 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n"); 03466 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03467 return 1; 03468 } else if (rchan) { 03469 int res; 03470 struct ast_frame *f = ast_read(c); 03471 if (!f) 03472 return -1; 03473 03474 switch (f->frametype) { 03475 case AST_FRAME_DTMF_BEGIN: 03476 break; 03477 case AST_FRAME_DTMF_END: 03478 res = f->subclass.integer; 03479 ast_frfree(f); 03480 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03481 return res; 03482 case AST_FRAME_CONTROL: 03483 switch (f->subclass.integer) { 03484 case AST_CONTROL_HANGUP: 03485 ast_frfree(f); 03486 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03487 return -1; 03488 case AST_CONTROL_RINGING: 03489 case AST_CONTROL_ANSWER: 03490 case AST_CONTROL_SRCUPDATE: 03491 case AST_CONTROL_SRCCHANGE: 03492 case AST_CONTROL_CONNECTED_LINE: 03493 case AST_CONTROL_REDIRECTING: 03494 case -1: 03495 /* Unimportant */ 03496 break; 03497 default: 03498 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer); 03499 break; 03500 } 03501 break; 03502 case AST_FRAME_VOICE: 03503 /* Write audio if appropriate */ 03504 if (audiofd > -1) { 03505 if (write(audiofd, f->data.ptr, f->datalen) < 0) { 03506 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 03507 } 03508 } 03509 default: 03510 /* Ignore */ 03511 break; 03512 } 03513 ast_frfree(f); 03514 } 03515 } 03516 03517 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03518 03519 return 0; /* Time is up */ 03520 }
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 4683 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_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_LIST_NEXT, ast_log(), AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, calc_monitor_jump(), chanlist::chan, CHECK_BLOCKING, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, f, 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, 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, and ast_channel::writetrans.
Referenced by adsi_careful_send(), agent_write(), 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(), jb_get_and_deliver(), linear_generator(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), multiplexed_bridge_write(), NBScat_exec(), remote_bridge_loop(), rpt(), send_link_dtmf(), send_link_keyquery(), send_tone_burst(), send_usb_txt(), send_waveform_to_channel(), silence_generator_generate(), simple_bridge_write(), softmix_bridge_poke(), softmix_bridge_write(), spy_generate(), and t38_tx_packet_handler().
04684 { 04685 int res = -1; 04686 struct ast_frame *f = NULL; 04687 int count = 0; 04688 04689 /*Deadlock avoidance*/ 04690 while(ast_channel_trylock(chan)) { 04691 /*cannot goto done since the channel is not locked*/ 04692 if(count++ > 10) { 04693 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name); 04694 return 0; 04695 } 04696 usleep(1); 04697 } 04698 /* Stop if we're a zombie or need a soft hangup */ 04699 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 04700 goto done; 04701 04702 /* Handle any pending masquerades */ 04703 if (chan->masq) { 04704 ast_channel_unlock(chan); 04705 if (ast_do_masquerade(chan)) { 04706 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 04707 return res; /* no need to goto done: chan is already unlocked for masq */ 04708 } 04709 ast_channel_lock(chan); 04710 } 04711 if (chan->masqr) { 04712 res = 0; /* XXX explain, why 0 ? */ 04713 goto done; 04714 } 04715 04716 /* Perform the framehook write event here. After the frame enters the framehook list 04717 * there is no telling what will happen, how awesome is that!!! */ 04718 if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) { 04719 res = 0; 04720 goto done; 04721 } 04722 04723 if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) { 04724 if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) { 04725 ast_deactivate_generator(chan); 04726 } else { 04727 if (fr->frametype == AST_FRAME_DTMF_END) { 04728 /* There is a generator running while we're in the middle of a digit. 04729 * It's probably inband DTMF, so go ahead and pass it so it can 04730 * stop the generator */ 04731 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04732 ast_channel_unlock(chan); 04733 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); 04734 ast_channel_lock(chan); 04735 CHECK_BLOCKING(chan); 04736 } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) { 04737 /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ 04738 res = (chan->tech->indicate == NULL) ? 0 : 04739 chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); 04740 } 04741 res = 0; /* XXX explain, why 0 ? */ 04742 goto done; 04743 } 04744 } 04745 /* High bit prints debugging */ 04746 if (chan->fout & DEBUGCHAN_FLAG) 04747 ast_frame_dump(chan->name, fr, ">>"); 04748 CHECK_BLOCKING(chan); 04749 switch (fr->frametype) { 04750 case AST_FRAME_CONTROL: 04751 res = (chan->tech->indicate == NULL) ? 0 : 04752 chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); 04753 break; 04754 case AST_FRAME_DTMF_BEGIN: 04755 if (chan->audiohooks) { 04756 struct ast_frame *old_frame = fr; 04757 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 04758 if (old_frame != fr) 04759 f = fr; 04760 } 04761 send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No"); 04762 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04763 ast_channel_unlock(chan); 04764 res = ast_senddigit_begin(chan, fr->subclass.integer); 04765 ast_channel_lock(chan); 04766 CHECK_BLOCKING(chan); 04767 break; 04768 case AST_FRAME_DTMF_END: 04769 if (chan->audiohooks) { 04770 struct ast_frame *new_frame = fr; 04771 04772 new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 04773 if (new_frame != fr) { 04774 ast_frfree(new_frame); 04775 } 04776 } 04777 send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes"); 04778 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04779 ast_channel_unlock(chan); 04780 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); 04781 ast_channel_lock(chan); 04782 CHECK_BLOCKING(chan); 04783 break; 04784 case AST_FRAME_TEXT: 04785 if (fr->subclass.integer == AST_FORMAT_T140) { 04786 res = (chan->tech->write_text == NULL) ? 0 : 04787 chan->tech->write_text(chan, fr); 04788 } else { 04789 res = (chan->tech->send_text == NULL) ? 0 : 04790 chan->tech->send_text(chan, (char *) fr->data.ptr); 04791 } 04792 break; 04793 case AST_FRAME_HTML: 04794 res = (chan->tech->send_html == NULL) ? 0 : 04795 chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen); 04796 break; 04797 case AST_FRAME_VIDEO: 04798 /* XXX Handle translation of video codecs one day XXX */ 04799 res = (chan->tech->write_video == NULL) ? 0 : 04800 chan->tech->write_video(chan, fr); 04801 break; 04802 case AST_FRAME_MODEM: 04803 res = (chan->tech->write == NULL) ? 0 : 04804 chan->tech->write(chan, fr); 04805 break; 04806 case AST_FRAME_VOICE: 04807 if (chan->tech->write == NULL) 04808 break; /*! \todo XXX should return 0 maybe ? */ 04809 04810 if (ast_opt_generic_plc && fr->subclass.codec == AST_FORMAT_SLINEAR) { 04811 apply_plc(chan, fr); 04812 } 04813 04814 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */ 04815 if (fr->subclass.codec == chan->rawwriteformat) 04816 f = fr; 04817 else 04818 f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; 04819 04820 if (!f) { 04821 res = 0; 04822 break; 04823 } 04824 04825 if (chan->audiohooks) { 04826 struct ast_frame *prev = NULL, *new_frame, *cur, *dup; 04827 int freeoldlist = 0; 04828 04829 if (f != fr) { 04830 freeoldlist = 1; 04831 } 04832 04833 /* Since ast_audiohook_write may return a new frame, and the cur frame is 04834 * an item in a list of frames, create a new list adding each cur frame back to it 04835 * regardless if the cur frame changes or not. */ 04836 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 04837 new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur); 04838 04839 /* if this frame is different than cur, preserve the end of the list, 04840 * free the old frames, and set cur to be the new frame */ 04841 if (new_frame != cur) { 04842 04843 /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame 04844 * isn't part of local storage, meaning if ast_audiohook_write is called multiple 04845 * times it may override the previous frame we got from it unless we dup it */ 04846 if ((dup = ast_frisolate(new_frame))) { 04847 AST_LIST_NEXT(dup, frame_list) = AST_LIST_NEXT(cur, frame_list); 04848 if (freeoldlist) { 04849 AST_LIST_NEXT(cur, frame_list) = NULL; 04850 ast_frfree(cur); 04851 } 04852 if (new_frame != dup) { 04853 ast_frfree(new_frame); 04854 } 04855 cur = dup; 04856 } 04857 } 04858 04859 /* now, regardless if cur is new or not, add it to the new list, 04860 * if the new list has not started, cur will become the first item. */ 04861 if (prev) { 04862 AST_LIST_NEXT(prev, frame_list) = cur; 04863 } else { 04864 f = cur; /* set f to be the beginning of our new list */ 04865 } 04866 prev = cur; 04867 } 04868 } 04869 04870 /* If Monitor is running on this channel, then we have to write frames out there too */ 04871 /* the translator on chan->writetrans may have returned multiple frames 04872 from the single frame we passed in; if so, feed each one of them to the 04873 monitor */ 04874 if (chan->monitor && chan->monitor->write_stream) { 04875 struct ast_frame *cur; 04876 04877 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 04878 /* XXX must explain this code */ 04879 #ifndef MONITOR_CONSTANT_DELAY 04880 int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples; 04881 if (jump >= 0) { 04882 jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04883 if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1) 04884 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 04885 chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples; 04886 } else { 04887 chan->outsmpl += cur->samples; 04888 } 04889 #else 04890 int jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04891 if (jump - MONITOR_DELAY >= 0) { 04892 if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) 04893 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 04894 chan->outsmpl += chan->insmpl - chan->outsmpl; 04895 } else { 04896 chan->outsmpl += cur->samples; 04897 } 04898 #endif 04899 if (chan->monitor->state == AST_MONITOR_RUNNING) { 04900 if (ast_writestream(chan->monitor->write_stream, cur) < 0) 04901 ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n"); 04902 } 04903 } 04904 } 04905 04906 /* the translator on chan->writetrans may have returned multiple frames 04907 from the single frame we passed in; if so, feed each one of them to the 04908 channel, freeing each one after it has been written */ 04909 if ((f != fr) && AST_LIST_NEXT(f, frame_list)) { 04910 struct ast_frame *cur, *next; 04911 unsigned int skip = 0; 04912 04913 for (cur = f, next = AST_LIST_NEXT(cur, frame_list); 04914 cur; 04915 cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) { 04916 if (!skip) { 04917 if ((res = chan->tech->write(chan, cur)) < 0) { 04918 chan->_softhangup |= AST_SOFTHANGUP_DEV; 04919 skip = 1; 04920 } else if (next) { 04921 /* don't do this for the last frame in the list, 04922 as the code outside the loop will do it once 04923 */ 04924 chan->fout = FRAMECOUNT_INC(chan->fout); 04925 } 04926 } 04927 ast_frfree(cur); 04928 } 04929 04930 /* reset f so the code below doesn't attempt to free it */ 04931 f = NULL; 04932 } else { 04933 res = chan->tech->write(chan, f); 04934 } 04935 break; 04936 case AST_FRAME_NULL: 04937 case AST_FRAME_IAX: 04938 /* Ignore these */ 04939 res = 0; 04940 break; 04941 default: 04942 /* At this point, fr is the incoming frame and f is NULL. Channels do 04943 * not expect to get NULL as a frame pointer and will segfault. Hence, 04944 * we output the original frame passed in. */ 04945 res = chan->tech->write(chan, fr); 04946 break; 04947 } 04948 04949 if (f && f != fr) 04950 ast_frfree(f); 04951 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04952 04953 /* Consider a write failure to force a soft hangup */ 04954 if (res < 0) { 04955 chan->_softhangup |= AST_SOFTHANGUP_DEV; 04956 } else { 04957 chan->fout = FRAMECOUNT_INC(chan->fout); 04958 } 04959 done: 04960 if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) { 04961 /* The list gets recreated if audiohooks are added again later */ 04962 ast_audiohook_detach_list(chan->audiohooks); 04963 chan->audiohooks = NULL; 04964 } 04965 ast_channel_unlock(chan); 04966 return res; 04967 }
int ast_write_text | ( | struct ast_channel * | chan, | |
struct ast_frame * | frame | |||
) |
Write text 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 |
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 4568 of file channel.c.
References ast_write(), chanlist::chan, ast_channel::tech, and ast_channel_tech::write_video.
04569 { 04570 int res; 04571 if (!chan->tech->write_video) 04572 return 0; 04573 res = ast_write(chan, fr); 04574 if (!res) 04575 res = 1; 04576 return res; 04577 }
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 7844 of file channel.c.
References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.
07845 { 07846 switch (reason) { 07847 case CHANNEL_MODULE_LOAD: 07848 return "LOAD (Channel module load)"; 07849 07850 case CHANNEL_MODULE_RELOAD: 07851 return "RELOAD (Channel module reload)"; 07852 07853 case CHANNEL_CLI_RELOAD: 07854 return "CLIRELOAD (Channel module reload by CLI command)"; 07855 07856 default: 07857 return "MANAGERRELOAD (Channel module reload by manager)"; 07858 } 07859 };
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 98 of file channel.c.
Referenced by handle_core_set_debug_channel().
unsigned long global_fout |