Wed Jan 8 2020 09:50:09

Asterisk developer's documentation


channel.h File Reference

General Asterisk PBX channel definitions. More...

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_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  ast_channel::autochans
 
struct  ast_channel::datastores
 
struct  outgoing_helper
 

Macros

#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. More...
 
#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)
 Report DTMF on channel 1. More...
 
#define AST_BRIDGE_IGNORE_SIGS   (1 << 4)
 Ignore all signal frames except NULL. More...
 
#define AST_BRIDGE_REC_CHANNEL_0   (1 << 2)
 Return all voice frames on channel 0. More...
 
#define AST_BRIDGE_REC_CHANNEL_1   (1 << 3)
 Return all voice frames on channel 1. More...
 
#define AST_CHAN_WRITE_INFO_T_VERSION   1
 ast_chan_write_info_t version. Must be incremented if structure is changed More...
 
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag,...)
 Create a channel structure. More...
 
#define ast_channel_lock(chan)   ao2_lock(chan)
 
#define ast_channel_lock_both(chan1, chan2)
 Lock two channels. More...
 
#define AST_CHANNEL_NAME   80
 
#define ast_channel_ref(c)   ({ ao2_ref(c, +1); (c); })
 Increase channel reference count. More...
 
#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. More...
 
#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. More...
 
typedef int(* ast_acf_read_fn_t )(struct ast_channel *, const char *, char *, char *, size_t)
 Typedef for a custom read function. More...
 
typedef int(* ast_acf_write_fn_t )(struct ast_channel *, const char *, char *, const char *)
 Typedef for a custom write function. More...
 
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_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22),
  AST_FLAG_TIMINGDATA_IS_AO2_OBJ = (1 << 23)
}
 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. More...
 
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. More...
 
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. More...
 
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 More...
 
static int ast_add_fd (struct pollfd *pfd, int fd)
 if fd is a valid descriptor, set *pfd with the descriptor More...
 
int ast_answer (struct ast_channel *chan)
 Answer a channel. More...
 
int ast_autoservice_ignore (struct ast_channel *chan, enum ast_frame_type ftype)
 Ignore certain frame types. More...
 
int ast_autoservice_start (struct ast_channel *chan)
 Automatically service a channel for us... More...
 
int ast_autoservice_stop (struct ast_channel *chan)
 Stop servicing a channel for us... More...
 
void ast_begin_shutdown (int hangup)
 
format_t ast_best_codec (format_t fmts)
 Pick the best audio codec. More...
 
struct ast_channelast_bridged_channel (struct ast_channel *chan)
 Find bridged channel. More...
 
int ast_call (struct ast_channel *chan, char *addr, int timeout)
 Make a call. More...
 
struct ast_channelast_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. More...
 
void ast_cancel_shutdown (void)
 Cancel a shutdown in progress. More...
 
const char * ast_cause2str (int state) attribute_pure
 Gives the string form of a given cause code. More...
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name. More...
 
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. More...
 
struct ast_channelast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
 Call a function with every active channel. More...
 
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. More...
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel. More...
 
int ast_channel_cmpwhentohangup (struct ast_channel *chan, time_t offset)
 Compare a offset with the settings of when to hang a channel up. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore)
 Add a datastore to a channel. More...
 
struct ast_datastore
*attribute_malloc 
ast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid)
 Create a channel data store object. More...
 
struct ast_datastoreast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
 Find a datastore on a channel. More...
 
int ast_channel_datastore_free (struct ast_datastore *datastore)
 Free a channel data store object. More...
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child. More...
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel. More...
 
int ast_channel_defer_dtmf (struct ast_channel *chan)
 Defers DTMF so that you only read things like hangups and audio. More...
 
int ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Bridge two channels together (early) More...
 
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. More...
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel. More...
 
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. More...
 
static enum ast_t38_state ast_channel_get_t38_state (struct ast_channel *chan)
 Retrieves the current T38 state of a channel. More...
 
void ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child)
 Inherits channel variable from parent to child channel. More...
 
int ast_channel_make_compatible (struct ast_channel *c0, struct ast_channel *c1)
 Makes two channel formats compatible. More...
 
int ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clone)
 Weird function made for call transfers. More...
 
int ast_channel_queryoption (struct ast_channel *channel, int option, void *data, int *datalen, int block)
 Checks the value of an option. More...
 
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. More...
 
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. More...
 
const char * ast_channel_reason2str (int reason)
 return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument More...
 
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. More...
 
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. More...
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel. More...
 
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. More...
 
int ast_channel_sendurl (struct ast_channel *channel, const char *url)
 Sends a URL on a given link Send URL on link. More...
 
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. More...
 
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. More...
 
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. More...
 
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 More...
 
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. More...
 
int ast_channel_setoption (struct ast_channel *channel, int option, void *data, int datalen, int block)
 Sets an option on a channel. More...
 
void ast_channel_setwhentohangup (struct ast_channel *chan, time_t offset)
 Set when to hang a channel up. More...
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hang a channel up. More...
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel. More...
 
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. More...
 
int ast_channel_supports_html (struct ast_channel *channel)
 Checks for HTML support on a channel. More...
 
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. More...
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel. More...
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister a channel technology. More...
 
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. More...
 
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. More...
 
struct ast_variableast_channeltype_list (void)
 return an ast_variable list of channeltypes More...
 
int ast_check_hangup (struct ast_channel *chan)
 Check to see if a channel is needing hang up. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_deactivate_generator (struct ast_channel *chan)
 
int ast_do_masquerade (struct ast_channel *chan)
 Start masquerading a channel. More...
 
struct ast_channelast_dummy_channel_alloc (void)
 Create a fake channel structure. More...
 
static int ast_fdisset (struct pollfd *pfds, int fd, int maximum, int *start)
 Helper function for migrating select to poll. More...
 
struct ast_channel_techast_get_channel_tech (const char *name)
 Get a channel technology structure by name. More...
 
ast_group_t ast_get_group (const char *s)
 
int ast_hangup (struct ast_channel *chan)
 Hang up a channel. More...
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel. More...
 
int ast_indicate_data (struct ast_channel *chan, int condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload. More...
 
int ast_internal_timing_enabled (struct ast_channel *chan)
 Check if the channel can run in internal timing mode. More...
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later? More...
 
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. More...
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents. More...
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents. More...
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents. More...
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents. More...
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure. More...
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents. More...
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents. More...
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents. More...
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents. More...
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure. More...
 
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. More...
 
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. More...
 
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 More...
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver. More...
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame with payload. More...
 
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. More...
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *f)
 Queue one or more frames to a channel's frame queue. More...
 
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. More...
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame. More...
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame with hangupcause set. More...
 
int ast_raw_answer (struct ast_channel *chan, int cdr_answer)
 Answer a channel. More...
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame. More...
 
struct ast_frameast_read_noaudio (struct ast_channel *chan)
 Reads a frame, returning AST_FRAME_NULL frame if audio. More...
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
 Reads multiple digits. More...
 
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. More...
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel. More...
 
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. More...
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data. More...
 
struct ast_channelast_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
 Requests a channel. More...
 
struct ast_channelast_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. More...
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups. More...
 
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. More...
 
int ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel More...
 
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. More...
 
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. More...
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_shutting_down (void)
 Returns non-zero if Asterisk is being shut down. More...
 
int ast_softhangup (struct ast_channel *chan, int reason)
 Softly hangup up a channel. More...
 
int ast_softhangup_nolock (struct ast_channel *chan, int reason)
 Softly hangup up a channel (no channel lock) More...
 
const char * ast_state2str (enum ast_channel_state)
 Gives the string form of a given channel state. More...
 
int ast_str2cause (const char *name) attribute_pure
 Convert the string form of a cause code to a number. More...
 
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). More...
 
char * ast_transfercapability2str (int transfercapability) attribute_const
 Gives the string form of a given transfer capability. More...
 
int ast_undestroyed_channels (void)
 
int ast_waitfor (struct ast_channel *chan, int ms)
 Wait for input on a channel. More...
 
struct ast_channelast_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. More...
 
int ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception)
 Waits for input on an fd. More...
 
struct ast_channelast_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. More...
 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const char * channelreloadreason2txt (enum channelreloadreason reason)
 Convert enum channelreloadreason to text string for manager event. More...
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator. More...
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension. More...
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name. More...
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator. More...
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator. More...
 
struct ast_channelast_channel_get_by_name (const char *name)
 Find a channel by name. More...
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix. More...
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context. More...
 

Variables

struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor. More...
 
unsigned long global_fin
 
unsigned long global_fout
 

Detailed Description

General Asterisk PBX channel definitions.

See also:

Definition in file channel.h.

Macro Definition Documentation

#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)
#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)
#define AST_BRIDGE_IGNORE_SIGS   (1 << 4)

Ignore all signal frames except NULL.

Definition at line 1940 of file channel.h.

Referenced by ast_generic_bridge(), iax2_bridge(), local_bridge_loop(), and remote_bridge_loop().

#define AST_BRIDGE_REC_CHANNEL_0   (1 << 2)

Return all voice frames on channel 0.

Definition at line 1936 of file channel.h.

#define AST_BRIDGE_REC_CHANNEL_1   (1 << 3)

Return all voice frames on channel 1.

Definition at line 1938 of file channel.h.

#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__)
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
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.
Definition: channel.c:1366
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107

Create a channel structure.

Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
Absolutely NO channel locks should be held before calling this function.
By default, new channels are set to the "s" extension and "default" context.

Definition at line 1154 of file channel.h.

#define ast_channel_lock (   chan)    ao2_lock(chan)

Definition at line 2466 of file channel.h.

Referenced by __analog_handle_event(), __ast_answer(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), __dahdi_exception(), __oh323_destroy(), __sip_destroy(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), acf_fetch(), acf_odbc_read(), action_add_agi_cmd(), action_coreshowchannels(), action_hangup(), action_redirect(), action_status(), action_timeout(), add_features_datastore(), add_to_agi(), agent_indicate(), agent_lock_owner(), analog_exception(), app_exec(), 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_end_dtmf(), 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_queryoption(), ast_channel_redirecting_macro(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_setoption(), ast_check_hangup_locked(), ast_complete_channels(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_do_pickup(), 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_senddigit_begin(), ast_senddigit_end(), ast_sendtext(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout_full(), 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(), auth_exec(), awesome_locking(), bridge_play_sounds(), builtin_atxfer(), builtin_automixmonitor(), builtin_blindtransfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), call_forward_inherit(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), cdr_read(), cdr_write(), channel_set_debug(), channel_spy(), check_bridge(), check_goto_on_transfer(), clear_caller(), clear_dialed_interfaces(), common_exec(), conf_run(), conf_start_moh(), confbridge_exec(), connectedline_read(), connectedline_write(), create_dynamic_parkinglot(), crement_function_read(), dahdi_bridge(), dahdi_handle_dtmf(), dahdi_handle_event(), data_channels_provider_handler(), deactivate_silence_generator(), dial_exec_full(), disable_jack_hook(), do_forward(), do_notify(), dundi_query_read(), dundi_result_read(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), exec_odbcfinish(), expand_gosub_args(), feature_check(), feature_interpret(), feature_request_and_dial(), find_by_mark(), find_by_part(), find_calling_channel(), find_channel_by_group(), find_conf_realtime(), find_details(), find_or_create_details(), find_speech(), find_transaction(), findmeexec(), 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(), gosub_exec(), gosub_run(), handle_chanlist(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_gosub(), handle_invite_replaces(), handle_request_bye(), handle_request_refer(), handle_showchan(), handle_softhangup(), import_ch(), import_helper(), init_jack_data(), jack_hook_callback(), leave_voicemail(), listfilter(), local_ast_moh_stop(), local_call(), local_hangup(), local_queryoption(), local_queue_frame(), local_read(), local_setoption(), local_write(), login_exec(), lua_get_state(), manage_parked_call(), manager_mutestream(), mark_transaction_active(), meetme_menu_admin_extended(), 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(), parkandannounce_exec(), parked_call_exec(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setamaflags(), pbx_builtin_setvar_helper(), peek_read(), pickup_by_exten(), pickup_by_name_cb(), pitchshift_helper(), pop_exec(), pri_dchannel(), process_sdp(), queue_exec(), receivefax_exec(), redirecting_read(), redirecting_write(), release_transaction(), remote_bridge_loop(), report_fax_status(), retrydial_exec(), return_exec(), 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_pvt_lock_full(), sip_read(), sip_removeheader(), sip_set_rtp_peer(), sip_set_udptl_peer(), smdi_msg_read(), smdi_msg_retrieve_read(), softhangup_exec(), speech_background(), speech_create(), speech_datastore_destroy(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), stackpeek_read(), start_monitor_action(), start_monitor_exec(), state_notify_build_xml(), stop_mixmonitor_exec(), transmit_invite(), try_calling(), update_bridge_vars(), volume_write(), and wait_for_answer().

#define ast_channel_unlock (   chan)    ao2_unlock(chan)

Definition at line 2467 of file channel.h.

Referenced by __analog_handle_event(), __ast_answer(), __ast_channel_masquerade(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), __dahdi_exception(), __oh323_destroy(), __oh323_rtp_create(), __sip_autodestruct(), __sip_destroy(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), acf_fetch(), acf_odbc_read(), action_add_agi_cmd(), action_agents(), action_coreshowchannels(), action_hangup(), action_redirect(), action_status(), action_timeout(), add_features_datastore(), add_to_agi(), agent_indicate(), agent_lock_owner(), agent_logoff(), agent_read(), agents_data_provider_get(), agents_show(), agents_show_online(), alsa_call(), analog_attempt_transfer(), analog_exception(), analog_hangup(), app_exec(), 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_end_dtmf(), 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_bridge(), ast_channel_clear_softhangup(), ast_channel_cmp_cb(), ast_channel_connected_line_macro(), ast_channel_destructor(), ast_channel_queryoption(), ast_channel_redirecting_macro(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_setoption(), ast_check_hangup_locked(), ast_complete_channels(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_do_pickup(), ast_eivr_getvariable(), ast_explicit_goto(), ast_generic_bridge(), 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_senddigit_begin(), ast_senddigit_end(), ast_sendtext(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout_full(), 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(), auth_exec(), auto_congest(), awesome_locking(), bridge_play_sounds(), bridge_queue_hangup(), bridge_write(), builtin_atxfer(), builtin_automixmonitor(), builtin_blindtransfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), call_forward_inherit(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), cdr_read(), cdr_write(), channel_set_debug(), channel_spy(), check_bridge(), check_goto_on_transfer(), check_rtp_timeout(), cleanup_connection(), clear_caller(), clear_dialed_interfaces(), common_exec(), conf_run(), conf_start_moh(), confbridge_exec(), connectedline_read(), connectedline_write(), console_answer(), console_hangup(), console_sendtext(), create_dynamic_parkinglot(), crement_function_read(), dahdi_bridge(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_queue_frame(), dahdi_softhangup_all(), data_channels_provider_handler(), deactivate_silence_generator(), dial_exec_full(), dial_transfer(), dialog_unlink_all(), disable_jack_hook(), do_bridge_masquerade(), do_forward(), do_notify(), dundi_query_read(), dundi_result_read(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), exec_odbcfinish(), expand_gosub_args(), fast_originate(), feature_check(), feature_interpret(), feature_request_and_dial(), find_by_mark(), find_by_part(), find_calling_channel(), find_channel_by_group(), find_conf_realtime(), find_details(), find_or_create_details(), find_speech(), find_transaction(), findmeexec(), 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(), gosub_exec(), gosub_run(), handle_chanlist(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_gosub(), 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(), listfilter(), local_ast_moh_stop(), local_attended_transfer(), local_bridge_loop(), local_call(), local_hangup(), local_queryoption(), local_queue_frame(), local_read(), local_setoption(), local_write(), login_exec(), lua_get_state(), manage_parked_call(), manager_mutestream(), mark_transaction_active(), meetme_menu_admin_extended(), 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(), parkandannounce_exec(), parked_call_exec(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setamaflags(), pbx_builtin_setvar_helper(), peek_read(), pickup_by_channel(), pickup_by_exten(), pickup_by_group(), pickup_by_mark(), pickup_by_name_cb(), pickup_by_part(), pitchshift_helper(), pop_exec(), pri_dchannel(), pri_fixup_principle(), pri_queue_frame(), proc_session_timer(), process_sdp(), queue_exec(), receive_digit(), receivefax_exec(), redirecting_read(), redirecting_write(), reinvite_timeout(), release_chan(), release_chan_early(), release_transaction(), remote_bridge_loop(), remote_hold(), report_fax_status(), retrans_pkt(), retrydial_exec(), return_exec(), ring_entry(), run_agi(), schedule_delivery(), send_provisional_keepalive_full(), 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_cli_show_channels(), sig_pri_handle_hold(), sig_pri_handle_subcmds(), sig_pri_send_aoce_termination_request(), sip_addheader(), sip_dtmfmode(), sip_hangup(), sip_new(), sip_pvt_lock_full(), sip_queue_hangup_cause(), sip_read(), sip_reinvite_retry(), sip_removeheader(), sip_request_call(), sip_set_rtp_peer(), sip_set_udptl_peer(), smdi_msg_read(), smdi_msg_retrieve_read(), socket_process(), softhangup_exec(), speech_background(), speech_create(), speech_datastore_destroy(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), stackpeek_read(), start_monitor_action(), start_monitor_exec(), state_notify_build_xml(), stop_mixmonitor_exec(), transmit_invite(), try_calling(), update_bridge_vars(), update_state(), volume_write(), wait_for_answer(), and wakeup_sub().

#define ast_channel_unref (   c)    ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })

Decrease channel reference count.

Parameters
cthe channel
Return values
NULLalways
Since
1.8

Definition at line 2502 of file channel.h.

Referenced by __ast_channel_alloc_ap(), __sip_autodestruct(), acf_odbc_read(), acf_odbc_write(), action_add_agi_cmd(), action_agents(), action_aocmessage(), action_atxfer(), action_bridge(), action_coreshowchannels(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), agent_hangup(), agent_lock_owner(), agent_logoff(), agent_read(), agents_data_provider_get(), agents_show(), agents_show_online(), ast_add_extension2_lockopt(), ast_async_goto_by_name(), ast_autochan_destroy(), ast_autochan_new_channel(), ast_bridge_call(), ast_cel_fabricate_channel_from_event(), ast_cel_report_event(), ast_channel_release(), ast_complete_channels(), ast_do_masquerade(), ast_dummy_channel_alloc(), ast_hangup(), ast_parse_device_state(), ast_pbx_outgoing_cdr_failed(), ast_pickup_call(), ast_set_hangupsource(), ast_str_substitute_variables_full(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), asyncgoto_exec(), awesome_locking(), bridge_exec(), change_monitor_action(), check_bridge(), cli_odbc_read(), cli_odbc_write(), common_exec(), custom_log(), data_channels_provider_handler(), dialog_unlink_all(), 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_do(), handle_request_refer(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), import_helper(), local_attended_transfer(), local_call(), local_hangup(), local_queryoption(), local_queue_frame(), local_setoption(), make_email_file(), manager_log(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), next_channel(), park_call_full(), pbx_builtin_importvar(), pbx_substitute_variables_helper_full(), pickup_by_channel(), pickup_by_exten(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), reinvite_timeout(), rotate_file(), send_provisional_keepalive_full(), senddtmf_exec(), sendmail(), sendpage(), set_hangup_source_and_cause(), shared_read(), shared_write(), sip_pickup(), sip_pickup_thread(), sip_pvt_lock_full(), sip_queue_hangup_cause(), socket_process(), softhangup_exec(), start_monitor_action(), state_notify_build_xml(), stop_monitor_action(), and syslog_log().

#define AST_GENERATOR_FD   (AST_MAX_FDS-4)

used by generator

Definition at line 166 of file channel.h.

Referenced by __ast_read(), ast_do_masquerade(), and deactivate_generator_nolock().

#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(), ast_do_masquerade(), and ast_settimeout_full().

#define CHECK_BLOCKING (   c)

Definition at line 2427 of file channel.h.

Referenced by ast_sendtext(), ast_waitfor_nandfds(), ast_write(), dahdi_read(), and phone_read().

#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 648 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) )

Definition at line 651 of file channel.h.

Referenced by __ast_read(), and ast_write().

#define MAX_LANGUAGE   40

Max length of the language setting

Definition at line 138 of file channel.h.

Referenced by ast_readconfig().

#define MAX_MUSICCLASS   80

Max length of the music class setting

Definition at line 139 of file channel.h.

Typedef Documentation

typedef int(* ast_acf_read2_fn_t)(struct ast_channel *, const char *, char *, struct ast_str **, ssize_t)

Typedef for a custom read2 function.

Definition at line 476 of file channel.h.

typedef int(* ast_acf_read_fn_t)(struct ast_channel *, const char *, char *, char *, size_t)

Typedef for a custom read function.

Definition at line 473 of file channel.h.

typedef int(* ast_acf_write_fn_t)(struct ast_channel *, const char *, char *, const char *)

Typedef for a custom write function.

Definition at line 479 of file channel.h.

typedef unsigned long long ast_group_t

Definition at line 175 of file channel.h.

Enumeration Type Documentation

anonymous enum

ast_channel_tech Properties

Enumerator
AST_CHAN_TP_WANTSJITTER 

Channels have this property if they can accept input with jitter; i.e. most VoIP channels.

AST_CHAN_TP_CREATESJITTER 

Channels have this property if they can create jitter; i.e. most VoIP channels.

Definition at line 878 of file channel.h.

878  {
879  /*!
880  * \brief Channels have this property if they can accept input with jitter;
881  * i.e. most VoIP channels
882  */
883  AST_CHAN_TP_WANTSJITTER = (1 << 0),
884  /*!
885  * \brief Channels have this property if they can create jitter;
886  * i.e. most VoIP channels
887  */
888  AST_CHAN_TP_CREATESJITTER = (1 << 1),
889 };
Channels have this property if they can create jitter; i.e. most VoIP channels.
Definition: channel.h:888
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
Definition: channel.h:883
anonymous enum

ast_channel flags

Enumerator
AST_FLAG_DEFER_DTMF 

Queue incoming DTMF, to be released when this flag is turned off

AST_FLAG_WRITE_INT 

write should be interrupt generator

AST_FLAG_BLOCKING 

a thread is blocking on this channel

AST_FLAG_ZOMBIE 

This is a zombie channel

AST_FLAG_EXCEPTION 

There is an exception pending

AST_FLAG_MOH 

Listening to moh XXX anthm promises me this will disappear XXX

AST_FLAG_SPYING 

This channel is spying on another channel

AST_FLAG_NBRIDGE 

This channel is in a native bridge

AST_FLAG_IN_AUTOLOOP 

the channel is in an auto-incrementing dialplan processor, so when ->priority is set, it will get incremented before finding the next priority to run

AST_FLAG_OUTGOING 

This is an outgoing call

AST_FLAG_IN_DTMF 

A DTMF_BEGIN frame has been read from this channel, but not yet an END

AST_FLAG_EMULATE_DTMF 

A DTMF_END was received when not IN_DTMF, so the length of the digit is currently being emulated

AST_FLAG_END_DTMF_ONLY 

This is set to tell the channel not to generate DTMF begin frames, and to instead only generate END frames.

AST_FLAG_ANSWERED_ELSEWHERE 

Flag to show channels that this call is hangup due to the fact that the call was indeed answered, but in another channel

AST_FLAG_MASQ_NOSTREAM 

This flag indicates that on a masquerade, an active stream should not be carried over

AST_FLAG_BRIDGE_HANGUP_RUN 

This flag indicates that the hangup exten was run when the bridge terminated, a message aimed at preventing a subsequent hangup exten being run at the pbx_run level

AST_FLAG_BRIDGE_HANGUP_DONT 

This flag indicates that the hangup exten should NOT be run when the bridge terminates, this will allow the hangup in the pbx loop to be run instead.

AST_FLAG_DISABLE_WORKAROUNDS 

Disable certain workarounds. This reintroduces certain bugs, but allows some non-traditional dialplans (like AGI) to continue to function.

AST_FLAG_DISABLE_DEVSTATE_CACHE 

Disable device state event caching. This allows channel drivers to selectively prevent device state events from being cached by certain channels such as anonymous calls which have no persistent represenatation that can be tracked.

AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT 

This flag indicates that a dual channel redirect is in progress. The bridge needs to wait until the flag is cleared to continue.

AST_FLAG_TIMINGDATA_IS_AO2_OBJ 

The data on chan->timingdata is an astobj2 object.

Definition at line 892 of file channel.h.

892  {
893  /*! Queue incoming DTMF, to be released when this flag is turned off */
894  AST_FLAG_DEFER_DTMF = (1 << 1),
895  /*! write should be interrupt generator */
896  AST_FLAG_WRITE_INT = (1 << 2),
897  /*! a thread is blocking on this channel */
898  AST_FLAG_BLOCKING = (1 << 3),
899  /*! This is a zombie channel */
900  AST_FLAG_ZOMBIE = (1 << 4),
901  /*! There is an exception pending */
902  AST_FLAG_EXCEPTION = (1 << 5),
903  /*! Listening to moh XXX anthm promises me this will disappear XXX */
904  AST_FLAG_MOH = (1 << 6),
905  /*! This channel is spying on another channel */
906  AST_FLAG_SPYING = (1 << 7),
907  /*! This channel is in a native bridge */
908  AST_FLAG_NBRIDGE = (1 << 8),
909  /*! the channel is in an auto-incrementing dialplan processor,
910  * so when ->priority is set, it will get incremented before
911  * finding the next priority to run */
912  AST_FLAG_IN_AUTOLOOP = (1 << 9),
913  /*! This is an outgoing call */
914  AST_FLAG_OUTGOING = (1 << 10),
915  /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
916  AST_FLAG_IN_DTMF = (1 << 12),
917  /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
918  * currently being emulated */
919  AST_FLAG_EMULATE_DTMF = (1 << 13),
920  /*! This is set to tell the channel not to generate DTMF begin frames, and
921  * to instead only generate END frames. */
922  AST_FLAG_END_DTMF_ONLY = (1 << 14),
923  /*! Flag to show channels that this call is hangup due to the fact that the call
924  was indeed answered, but in another channel */
925  AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15),
926  /*! This flag indicates that on a masquerade, an active stream should not
927  * be carried over */
928  AST_FLAG_MASQ_NOSTREAM = (1 << 16),
929  /*! This flag indicates that the hangup exten was run when the bridge terminated,
930  * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
931  * level */
932  AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
933  /*! This flag indicates that the hangup exten should NOT be run when the
934  * bridge terminates, this will allow the hangup in the pbx loop to be run instead.
935  * */
936  AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18),
937  /*! Disable certain workarounds. This reintroduces certain bugs, but allows
938  * some non-traditional dialplans (like AGI) to continue to function.
939  */
940  AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
941  /*!
942  * Disable device state event caching. This allows channel
943  * drivers to selectively prevent device state events from being
944  * cached by certain channels such as anonymous calls which have
945  * no persistent represenatation that can be tracked.
946  */
948  /*!
949  * This flag indicates that a dual channel redirect is in
950  * progress. The bridge needs to wait until the flag is cleared
951  * to continue.
952  */
954  /*!
955  * The data on chan->timingdata is an astobj2 object.
956  */
957  AST_FLAG_TIMINGDATA_IS_AO2_OBJ = (1 << 23),
958 };
anonymous enum

ast_bridge_config flags

Enumerator
AST_FEATURE_PLAY_WARNING 
AST_FEATURE_REDIRECT 
AST_FEATURE_DISCONNECT 
AST_FEATURE_ATXFER 
AST_FEATURE_AUTOMON 
AST_FEATURE_PARKCALL 
AST_FEATURE_AUTOMIXMON 
AST_FEATURE_NO_H_EXTEN 
AST_FEATURE_WARNING_ACTIVE 

Definition at line 961 of file channel.h.

anonymous enum
Enumerator
AST_SOFTHANGUP_DEV 

Soft hangup requested by device or other internal reason. Actual hangup needed.

AST_SOFTHANGUP_ASYNCGOTO 

Used to break the normal frame flow so an async goto can be done instead of actually hanging up.

AST_SOFTHANGUP_SHUTDOWN 

Soft hangup requested by system shutdown. Actual hangup needed.

AST_SOFTHANGUP_TIMEOUT 

Used to break the normal frame flow after a timeout so an implicit async goto can be done to the 'T' exten if it exists instead of actually hanging up. If the exten does not exist then actually hangup.

AST_SOFTHANGUP_APPUNLOAD 

Soft hangup requested by application/channel-driver being unloaded. Actual hangup needed.

AST_SOFTHANGUP_EXPLICIT 

Soft hangup requested by non-associated party. Actual hangup needed.

AST_SOFTHANGUP_UNBRIDGE 

Used to break a bridge so the channel can be spied upon instead of actually hanging up.

AST_SOFTHANGUP_ALL 

All softhangup flags.

This can be used as an argument to ast_channel_softhangup_clear to clear all softhangup flags from a channel.

Definition at line 1009 of file channel.h.

1009  {
1010  /*!
1011  * Soft hangup requested by device or other internal reason.
1012  * Actual hangup needed.
1013  */
1014  AST_SOFTHANGUP_DEV = (1 << 0),
1015  /*!
1016  * Used to break the normal frame flow so an async goto can be
1017  * done instead of actually hanging up.
1018  */
1019  AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
1020  /*!
1021  * Soft hangup requested by system shutdown. Actual hangup
1022  * needed.
1023  */
1024  AST_SOFTHANGUP_SHUTDOWN = (1 << 2),
1025  /*!
1026  * Used to break the normal frame flow after a timeout so an
1027  * implicit async goto can be done to the 'T' exten if it exists
1028  * instead of actually hanging up. If the exten does not exist
1029  * then actually hangup.
1030  */
1031  AST_SOFTHANGUP_TIMEOUT = (1 << 3),
1032  /*!
1033  * Soft hangup requested by application/channel-driver being
1034  * unloaded. Actual hangup needed.
1035  */
1036  AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
1037  /*!
1038  * Soft hangup requested by non-associated party. Actual hangup
1039  * needed.
1040  */
1041  AST_SOFTHANGUP_EXPLICIT = (1 << 5),
1042  /*!
1043  * Used to break a bridge so the channel can be spied upon
1044  * instead of actually hanging up.
1045  */
1046  AST_SOFTHANGUP_UNBRIDGE = (1 << 6),
1047 
1048 
1049  /*!
1050  * \brief All softhangup flags.
1051  *
1052  * This can be used as an argument to ast_channel_softhangup_clear
1053  * to clear all softhangup flags from a channel.
1054  */
1055  AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1056 };
All softhangup flags.
Definition: channel.h:1055
Enumerator
AST_BRIDGE_COMPLETE 
AST_BRIDGE_FAILED 
AST_BRIDGE_FAILED_NOWARN 
AST_BRIDGE_RETRY 

Definition at line 168 of file channel.h.

Enumerator
AST_ADSI_UNKNOWN 
AST_ADSI_AVAILABLE 
AST_ADSI_UNAVAILABLE 
AST_ADSI_OFFHOOKONLY 

Definition at line 659 of file channel.h.

Party name character set enumeration values (values from Q.SIG)

Enumerator
AST_PARTY_CHAR_SET_UNKNOWN 
AST_PARTY_CHAR_SET_ISO8859_1 
AST_PARTY_CHAR_SET_WITHDRAWN 
AST_PARTY_CHAR_SET_ISO8859_2 
AST_PARTY_CHAR_SET_ISO8859_3 
AST_PARTY_CHAR_SET_ISO8859_4 
AST_PARTY_CHAR_SET_ISO8859_5 
AST_PARTY_CHAR_SET_ISO8859_7 
AST_PARTY_CHAR_SET_ISO10646_BMPSTRING 
AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING 

Definition at line 192 of file channel.h.

Possible T38 states on channels.

Enumerator
T38_STATE_UNAVAILABLE 

T38 is unavailable on this channel or disabled by configuration

T38_STATE_UNKNOWN 

The channel supports T38 but the current status is unknown

T38_STATE_NEGOTIATING 

T38 is being negotiated

T38_STATE_REJECTED 

Remote side has rejected our offer

T38_STATE_NEGOTIATED 

T38 established

Definition at line 669 of file channel.h.

669  {
670  T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
671  T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
672  T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
673  T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
674  T38_STATE_NEGOTIATED, /*!< T38 established */
675 };

Channel reload reasons for manager events at load or reload of configuration.

Enumerator
CHANNEL_MODULE_LOAD 
CHANNEL_MODULE_RELOAD 
CHANNEL_CLI_RELOAD 
CHANNEL_MANAGER_RELOAD 

Definition at line 1060 of file channel.h.

Function Documentation

int __ast_answer ( struct ast_channel chan,
unsigned int  delay,
int  cdr_answer 
)

Answer a channel, with a selectable delay before returning.

Parameters
chanchannel to answer
delaymaximum amount of time to wait for incoming media
cdr_answerflag to control whether any associated CDR should be marked as 'answered'

This function answers a channel and handles all necessary call setup functions.

Note
The channel passed does not need to be locked, but is locked by the function when needed.
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.
Return values
0on success
non-zeroon failure

Definition at line 2982 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_remaining_ms(), AST_STATE_RING, AST_STATE_RINGING, ast_tvnow(), ast_waitfor(), errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.

Referenced by ast_answer(), pbx_builtin_answer(), and pbx_builtin_incomplete().

2983 {
2984  int res = 0;
2985  enum ast_channel_state old_state;
2986 
2987  old_state = chan->_state;
2988  if ((res = ast_raw_answer(chan, cdr_answer))) {
2989  return res;
2990  }
2991 
2992  switch (old_state) {
2993  case AST_STATE_RINGING:
2994  case AST_STATE_RING:
2995  /* wait for media to start flowing, but don't wait any longer
2996  * than 'delay' or 500 milliseconds, whichever is longer
2997  */
2998  do {
3000  struct ast_frame *cur, *new;
3001  int timeout_ms = MAX(delay, 500);
3002  unsigned int done = 0;
3003  struct timeval start;
3004 
3005  AST_LIST_HEAD_INIT_NOLOCK(&frames);
3006 
3007  start = ast_tvnow();
3008  for (;;) {
3009  int ms = ast_remaining_ms(start, timeout_ms);
3010  ms = ast_waitfor(chan, ms);
3011  if (ms < 0) {
3012  ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno));
3013  res = -1;
3014  break;
3015  }
3016  if (ms == 0) {
3017  ast_debug(2, "Didn't receive a media frame from %s within %u ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500));
3018  break;
3019  }
3020  cur = ast_read(chan);
3021  if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
3022  (cur->subclass.integer == AST_CONTROL_HANGUP))) {
3023  if (cur) {
3024  ast_frfree(cur);
3025  }
3026  res = -1;
3027  ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name);
3028  break;
3029  }
3030 
3031  if ((new = ast_frisolate(cur)) != cur) {
3032  ast_frfree(cur);
3033  }
3034 
3035  AST_LIST_INSERT_HEAD(&frames, new, frame_list);
3036 
3037  /* if a specific delay period was requested, continue
3038  * until that delay has passed. don't stop just because
3039  * incoming media has arrived.
3040  */
3041  if (delay) {
3042  continue;
3043  }
3044 
3045  switch (new->frametype) {
3046  /* all of these frametypes qualify as 'media' */
3047  case AST_FRAME_VOICE:
3048  case AST_FRAME_VIDEO:
3049  case AST_FRAME_TEXT:
3050  case AST_FRAME_DTMF_BEGIN:
3051  case AST_FRAME_DTMF_END:
3052  case AST_FRAME_IMAGE:
3053  case AST_FRAME_HTML:
3054  case AST_FRAME_MODEM:
3055  done = 1;
3056  break;
3057  case AST_FRAME_CONTROL:
3058  case AST_FRAME_IAX:
3059  case AST_FRAME_NULL:
3060  case AST_FRAME_CNG:
3061  break;
3062  }
3063 
3064  if (done) {
3065  break;
3066  }
3067  }
3068 
3069  if (res == 0) {
3070  ast_channel_lock(chan);
3071  while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
3072  ast_queue_frame_head(chan, cur);
3073  ast_frfree(cur);
3074  }
3075  ast_channel_unlock(chan);
3076  }
3077  } while (0);
3078  break;
3079  default:
3080  break;
3081  }
3082 
3083  return res;
3084 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define LOG_WARNING
Definition: logger.h:144
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
ast_channel_state
ast_channel states
Definition: channelstate.h:35
for(;;)
Definition: ast_expr2.c:2460
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
static int frames
Definition: iax2-parser.c:49
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define MAX(a, b)
Definition: utils.h:228
int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
Answer a channel.
Definition: channel.c:2930
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
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.

Since
1.8
Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
Absolutely NO channel locks should be held before calling this function.
By default, new channels are set to the "s" extension and "default" context.

Definition at line 1366 of file channel.c.

References __ast_channel_alloc_ap().

1372 {
1373  va_list ap1, ap2;
1374  struct ast_channel *result;
1375 
1376  va_start(ap1, name_fmt);
1377  va_start(ap2, name_fmt);
1378  result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
1379  linkedid, amaflag, file, line, function, name_fmt, ap1, ap2);
1380  va_end(ap1);
1381  va_end(ap2);
1382 
1383  return result;
1384 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field linkedid
Definition: channel.h:787
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
static struct ast_channel *attribute_malloc __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2)
Create a new channel structure.
Definition: channel.c:1130
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
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.

Parameters
typetype of channel to request
formatrequested channel format
requestorchannel requesting data
datadata to pass to the channel requester
timeoutmaximum amount of time to wait for an answer
reasonwhy unsuccessful (if unsuccessful)
cid_numCaller-ID Number
cid_nameCaller-ID Name (ascii)
ohOutgoing helper
Returns
Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state to know if the call was answered or not.

Definition at line 5456 of file channel.c.

References ast_channel::_state, outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_cdr_alloc(), ast_cdr_answer(), ast_cdr_busy(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_failed(), AST_CDR_FLAG_ORIGINATED, ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_setapp(), ast_cdr_start(), ast_cdr_update(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_set_connected_line(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), ast_party_connected_line_set_init(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_read(), ast_remaining_ms(), ast_request(), ast_set_callerid(), ast_set_flag, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_tvnow(), ast_waitfor(), ast_channel::call_forward, ast_channel::cdr, chanlist::chan, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, f, ast_frame::frametype, handle_cause(), ast_channel::hangupcause, ast_party_connected_line::id, ast_frame_subclass::integer, LOG_NOTICE, ast_party_id::name, ast_party_id::number, outgoing_helper::parent_channel, ast_party_name::presentation, ast_party_number::presentation, ast_channel::priority, outgoing_helper::priority, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, ast_party_number::valid, and outgoing_helper::vars.

Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().

5457 {
5458  int dummy_outstate;
5459  int cause = 0;
5460  struct ast_channel *chan;
5461  int res = 0;
5462  int last_subclass = 0;
5464 
5465  if (outstate)
5466  *outstate = 0;
5467  else
5468  outstate = &dummy_outstate; /* make outstate always a valid pointer */
5469 
5470  chan = ast_request(type, format, requestor, data, &cause);
5471  if (!chan) {
5472  ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
5473  handle_cause(cause, outstate);
5474  return NULL;
5475  }
5476 
5477  if (oh) {
5478  if (oh->vars) {
5479  ast_set_variables(chan, oh->vars);
5480  }
5481  if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
5482  /*
5483  * Use the oh values instead of the function parameters for the
5484  * outgoing CallerID.
5485  */
5486  cid_num = oh->cid_num;
5487  cid_name = oh->cid_name;
5488  }
5489  if (oh->parent_channel) {
5490  /* Safely inherit variables and datastores from the parent channel. */
5495  ast_channel_unlock(chan);
5496  }
5497  if (oh->account) {
5498  ast_channel_lock(chan);
5499  ast_cdr_setaccount(chan, oh->account);
5500  ast_channel_unlock(chan);
5501  }
5502  }
5503 
5504  /*
5505  * I seems strange to set the CallerID on an outgoing call leg
5506  * to whom we are calling, but this function's callers are doing
5507  * various Originate methods. This call leg goes to the local
5508  * user. Once the local user answers, the dialplan needs to be
5509  * able to access the CallerID from the CALLERID function as if
5510  * the local user had placed this call.
5511  */
5513 
5516  if (cid_num) {
5517  connected.id.number.valid = 1;
5518  connected.id.number.str = (char *) cid_num;
5519  connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
5520  }
5521  if (cid_name) {
5522  connected.id.name.valid = 1;
5523  connected.id.name.str = (char *) cid_name;
5525  }
5527 
5528  if (ast_call(chan, data, 0)) { /* ast_call failed... */
5529  ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
5530  } else {
5531  struct timeval start = ast_tvnow();
5532  res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
5533  while (timeout && chan->_state != AST_STATE_UP) {
5534  struct ast_frame *f;
5535  int ms = ast_remaining_ms(start, timeout);
5536 
5537  res = ast_waitfor(chan, ms);
5538  if (res == 0) { /* timeout, treat it like ringing */
5539  *outstate = AST_CONTROL_RINGING;
5540  break;
5541  }
5542  if (res < 0) /* error or done */
5543  break;
5544  if (!ast_strlen_zero(chan->call_forward)) {
5545  if (!(chan = ast_call_forward(NULL, chan, NULL, format, oh, outstate))) {
5546  return NULL;
5547  }
5548  continue;
5549  }
5550 
5551  f = ast_read(chan);
5552  if (!f) {
5553  *outstate = AST_CONTROL_HANGUP;
5554  res = 0;
5555  break;
5556  }
5557  if (f->frametype == AST_FRAME_CONTROL) {
5558  switch (f->subclass.integer) {
5559  case AST_CONTROL_RINGING: /* record but keep going */
5560  *outstate = f->subclass.integer;
5561  break;
5562 
5563  case AST_CONTROL_BUSY:
5564  ast_cdr_busy(chan->cdr);
5565  *outstate = f->subclass.integer;
5566  timeout = 0;
5567  break;
5568 
5570  ast_cdr_failed(chan->cdr);
5571  *outstate = AST_CONTROL_CONGESTION;
5572  timeout = 0;
5573  break;
5574 
5576  ast_cdr_failed(chan->cdr);
5577  *outstate = f->subclass.integer;
5578  timeout = 0;
5579  break;
5580 
5581  case AST_CONTROL_ANSWER:
5582  ast_cdr_answer(chan->cdr);
5583  *outstate = f->subclass.integer;
5584  timeout = 0; /* trick to force exit from the while() */
5585  break;
5586 
5587  /* Ignore these */
5588  case AST_CONTROL_PROGRESS:
5590  case AST_CONTROL_HOLD:
5591  case AST_CONTROL_UNHOLD:
5592  case AST_CONTROL_VIDUPDATE:
5593  case AST_CONTROL_SRCUPDATE:
5594  case AST_CONTROL_SRCCHANGE:
5597  case AST_CONTROL_CC:
5598  case -1: /* Ignore -- just stopping indications */
5599  break;
5600 
5601  default:
5602  ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
5603  }
5604  last_subclass = f->subclass.integer;
5605  }
5606  ast_frfree(f);
5607  }
5608  }
5609 
5610  /* Final fixups */
5611  if (oh) {
5612  if (!ast_strlen_zero(oh->context))
5613  ast_copy_string(chan->context, oh->context, sizeof(chan->context));
5614  if (!ast_strlen_zero(oh->exten))
5615  ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
5616  if (oh->priority)
5617  chan->priority = oh->priority;
5618  }
5619  if (chan->_state == AST_STATE_UP)
5620  *outstate = AST_CONTROL_ANSWER;
5621 
5622  if (res <= 0) {
5623  ast_channel_lock(chan);
5624  if (AST_CONTROL_RINGING == last_subclass) {
5626  }
5627  if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
5628  ast_cdr_init(chan->cdr, chan);
5629  }
5630  if (chan->cdr) {
5631  char tmp[256];
5632 
5633  snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data);
5634  ast_cdr_setapp(chan->cdr, "Dial", tmp);
5635  ast_cdr_update(chan);
5636  ast_cdr_start(chan->cdr);
5637  ast_cdr_end(chan->cdr);
5638  /* If the cause wasn't handled properly */
5639  if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) {
5640  ast_cdr_failed(chan->cdr);
5641  }
5642  }
5643  ast_channel_unlock(chan);
5644  ast_hangup(chan);
5645  chan = NULL;
5646  }
5647  return chan;
5648 }
int ast_cdr_disposition(struct ast_cdr *cdr, int cause)
Save the result of the call based on the AST_CAUSE_*.
Definition: cdr.c:790
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition: channel.c:7051
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
const char * cid_num
Definition: channel.h:1002
void ast_cdr_failed(struct ast_cdr *cdr)
Fail a call.
Definition: cdr.c:764
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
int priority
Definition: channel.h:841
struct ast_channel * parent_channel
Definition: channel.h:1006
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...
Definition: channel.c:2329
void ast_cdr_end(struct ast_cdr *cdr)
End a call.
Definition: cdr.c:933
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
#define ast_set_flag(p, flag)
Definition: utils.h:70
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
Definition: cdr.c:990
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8261
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_cdr * cdr
Definition: channel.h:766
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
struct ast_variable * vars
Definition: channel.h:1005
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2573
const char * exten
Definition: channel.h:1000
const char * cid_name
Definition: channel.h:1003
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&#39;s call_forward str...
Definition: channel.c:5386
const char * account
Definition: channel.h:1004
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5336
void ast_cdr_answer(struct ast_cdr *cdr)
Answer a call.
Definition: cdr.c:737
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:108
int ast_cdr_update(struct ast_channel *chan)
Update CDR on a channel.
Definition: cdr.c:1083
void ast_cdr_start(struct ast_cdr *cdr)
Start a call.
Definition: cdr.c:727
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
const ast_string_field call_forward
Definition: channel.h:787
enum ast_channel_state _state
Definition: channel.h:839
Connected Line/Party information.
Definition: channel.h:401
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition: channel.c:6241
static struct ast_format f[]
Definition: format_g726.c:181
void ast_cdr_setapp(struct ast_cdr *cdr, const char *app, const char *data)
Set the last executed application.
Definition: cdr.c:822
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
static const char type[]
Definition: chan_nbs.c:57
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
const char * context
Definition: channel.h:999
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
static int connected
Definition: cdr_pgsql.c:57
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
static snd_pcm_format_t format
Definition: chan_alsa.c:93
union ast_frame::@172 data
int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:897
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.
Definition: channel.c:8458
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
Definition: cdr.c:499
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
void ast_cdr_busy(struct ast_cdr *cdr)
Busy a call.
Definition: cdr.c:753
int ast_activate_generator ( struct ast_channel chan,
struct ast_generator gen,
void *  params 
)

Activate a given generator

Definition at line 3148 of file channel.c.

References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), gen, ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.

Referenced by app_exec(), ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), eivr_comm(), local_ast_moh_start(), old_milliwatt_exec(), and transmit_audio().

3149 {
3150  int res = 0;
3151 
3152  ast_channel_lock(chan);
3153  if (chan->generatordata) {
3154  struct ast_generator *generator_old = chan->generator;
3155 
3156  if (generator_old && generator_old->release) {
3157  generator_old->release(chan, chan->generatordata);
3158  }
3159  chan->generatordata = NULL;
3160  }
3161  if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
3162  res = -1;
3163  }
3164  if (!res) {
3165  ast_settimeout(chan, 50, generator_force, chan);
3166  chan->generator = gen;
3167  }
3168  ast_channel_unlock(chan);
3169 
3170  ast_prod(chan);
3171 
3172  return res;
3173 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_generator * generator
Definition: channel.h:747
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:4784
static struct ast_generator gen
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.
Definition: channel.c:3557
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void *(* alloc)(struct ast_channel *chan, void *params)
Definition: channel.h:180
static int generator_force(const void *data)
Definition: channel.c:3114
void * generatordata
Definition: channel.h:746
int ast_active_channels ( void  )

returns number of active/allocated channels

Returns
number of channels available for lookup

Definition at line 848 of file channel.c.

References ao2_container_count(), and channels.

Referenced by action_corestatus(), ast_var_channels(), ast_var_channels_table(), dahdi_restart(), handle_chanlist(), handle_show_settings(), and really_quit().

849 {
850  return channels ? ao2_container_count(channels) : 0;
851 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
Definition: astobj2.c:470
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
static int ast_add_fd ( struct pollfd *  pfd,
int  fd 
)
inlinestatic

if fd is a valid descriptor, set *pfd with the descriptor

Returns
Return 1 (not -1!) if added, 0 otherwise (so we can add the return value to the index into the array)

Definition at line 2390 of file channel.h.

Referenced by ast_waitfor_nandfds().

2391 {
2392  pfd->fd = fd;
2393  pfd->events = POLLIN | POLLPRI;
2394  return fd >= 0;
2395 }
int ast_answer ( struct ast_channel chan)

Answer a channel.

Parameters
chanchannel to answer

This function answers a channel and handles all necessary call setup functions.

Note
The channel passed does not need to be locked, but is locked by the function when needed.
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.
Return values
0on success
non-zeroon failure

Definition at line 3086 of file channel.c.

References __ast_answer().

Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_do_pickup(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), builtin_parkcall(), common_exec(), conf_exec(), count_exec(), dahdiras_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), login_exec(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_call_exec(), parked_call_exec(), pbx_builtin_background(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), receivefax_exec(), record_exec(), 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().

3087 {
3088  return __ast_answer(chan, 0, 1);
3089 }
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2982
int ast_autoservice_ignore ( struct ast_channel chan,
enum ast_frame_type  ftype 
)

Ignore certain frame types.

Note
Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames while a channel is in autoservice and queue them up when taken out of autoservice. When this is not desireable, this API may be used to cause the channel to ignore those frametypes after the channel is put into autoservice, but before autoservice is stopped.
Return values
0success
-1channel is not in autoservice

Definition at line 307 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(), feature_exec_app(), and play_message_on_chan().

308 {
309  struct asent *as;
310  int res = -1;
311 
313  AST_LIST_TRAVERSE(&aslist, as, list) {
314  if (as->chan == chan) {
315  res = 0;
316  as->ignore_frame_types |= (1 << ftype);
317  break;
318  }
319  }
321  return res;
322 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_channel * chan
Definition: autoservice.c:57
struct asent::@227 list
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
unsigned int ignore_frame_types
Definition: autoservice.c:63
int ast_autoservice_start ( struct ast_channel chan)

Automatically service a channel for us...

Return values
0success
-1failure, or the channel is already being autoserviced

Definition at line 179 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, 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(), ast_app_exec_macro(), ast_app_exec_sub(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_masq_park_call_exten(), ast_park_call_exten(), bridge_playfile(), builtin_atxfer(), builtin_automixmonitor(), builtin_blindtransfer(), conf_play(), confbridge_exec(), dial_exec_full(), exec(), 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_on_chan(), realtimefield_read(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), and trylock_read().

180 {
181  int res = 0;
182  struct asent *as;
183 
185  AST_LIST_TRAVERSE(&aslist, as, list) {
186  if (as->chan == chan) {
187  as->use_count++;
188  break;
189  }
190  }
192 
193  if (as) {
194  /* Entry exists, autoservice is already handling this channel */
195  return 0;
196  }
197 
198  if (!(as = ast_calloc(1, sizeof(*as))))
199  return -1;
200 
201  /* New entry created */
202  as->chan = chan;
203  as->use_count = 1;
204 
205  ast_channel_lock(chan);
207  if (!as->orig_end_dtmf_flag)
209  ast_channel_unlock(chan);
210 
212 
215  }
216 
218 
219  if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
221  ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
222  /* There will only be a single member in the list at this point,
223  the one we just added. */
224  AST_LIST_REMOVE(&aslist, as, list);
225  free(as);
227  res = -1;
228  } else {
229  pthread_kill(asthread, SIGURG);
230  }
231  }
232 
234 
235  return res;
236 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
static void * autoservice_run(void *ign)
Definition: autoservice.c:79
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
#define ast_cond_signal(cond)
Definition: lock.h:169
static ast_cond_t as_cond
Definition: autoservice.c:72
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:426
struct ast_channel * chan
Definition: autoservice.c:57
#define AST_PTHREADT_NULL
Definition: lock.h:65
struct asent::@227 list
#define free(a)
Definition: astmm.h:94
unsigned int orig_end_dtmf_flag
Definition: autoservice.c:62
unsigned int use_count
Definition: autoservice.c:61
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static pthread_t asthread
Definition: autoservice.c:74
#define ast_calloc(a, b)
Definition: astmm.h:82
int ast_autoservice_stop ( struct ast_channel chan)

Stop servicing a channel for us...

Note
if chan is locked prior to calling ast_autoservice_stop, it is likely that there will be a deadlock between the thread that calls ast_autoservice_stop and the autoservice thread. It is important that chan is not locked prior to this call
Parameters
chan
Return values
0success
-1error, or the channel has been hungup

Definition at line 238 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, ast_frame::frametype, 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_exec_macro(), ast_app_exec_sub(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_hangup(), ast_masq_park_call_exten(), ast_park_call_exten(), bridge_playfile(), builtin_atxfer(), builtin_automixmonitor(), conf_play(), confbridge_exec(), dial_exec_full(), exec(), 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_on_chan(), realtimefield_read(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), and trylock_read().

239 {
240  int res = -1;
241  struct asent *as, *removed = NULL;
242  struct ast_frame *f;
243  int chan_list_state;
244 
246 
247  /* Save the autoservice channel list state. We _must_ verify that the channel
248  * list has been rebuilt before we return. Because, after we return, the channel
249  * could get destroyed and we don't want our poor autoservice thread to step on
250  * it after its gone! */
251  chan_list_state = as_chan_list_state;
252 
253  /* Find the entry, but do not free it because it still can be in the
254  autoservice thread array */
255  AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {
256  if (as->chan == chan) {
257  as->use_count--;
258  if (as->use_count < 1) {
260  removed = as;
261  }
262  break;
263  }
264  }
266 
267  if (removed && asthread != AST_PTHREADT_NULL) {
268  pthread_kill(asthread, SIGURG);
269  }
270 
272 
273  if (!removed) {
274  return 0;
275  }
276 
277  /* Wait while autoservice thread rebuilds its list. */
278  while (chan_list_state == as_chan_list_state) {
279  usleep(1000);
280  }
281 
282  /* Now autoservice thread should have no references to our entry
283  and we can safely destroy it */
284 
285  if (!chan->_softhangup) {
286  res = 0;
287  }
288 
289  if (!as->orig_end_dtmf_flag) {
291  }
292 
293  ast_channel_lock(chan);
294  while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) {
295  if (!((1 << f->frametype) & as->ignore_frame_types)) {
296  ast_queue_frame_head(chan, f);
297  }
298  ast_frfree(f);
299  }
300  ast_channel_unlock(chan);
301 
302  free(as);
303 
304  return res;
305 }
struct asent::@226 deferred_frames
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
static int as_chan_list_state
Definition: autoservice.c:77
struct ast_channel * chan
Definition: autoservice.c:57
#define AST_PTHREADT_NULL
Definition: lock.h:65
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
#define free(a)
Definition: astmm.h:94
unsigned int orig_end_dtmf_flag
Definition: autoservice.c:62
unsigned int use_count
Definition: autoservice.c:61
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static pthread_t asthread
Definition: autoservice.c:74
static struct ast_format f[]
Definition: format_g726.c:181
#define ast_clear_flag(p, flag)
Definition: utils.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
enum ast_frame_type frametype
Definition: frame.h:144
unsigned int ignore_frame_types
Definition: autoservice.c:63
#define ast_frfree(fr)
Definition: frame.h:583
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
void ast_begin_shutdown ( int  hangup)

Initiate system shutdown – prevents new channels from being allocated.

Parameters
hangupIf "hangup" is non-zero, all existing channels will receive soft hangups

Definition at line 838 of file channel.c.

References ao2_callback, ast_channel_softhangup_cb(), channels, OBJ_MULTIPLE, and OBJ_NODATA.

Referenced by can_safely_quit().

839 {
840  shutting_down = 1;
841 
842  if (hangup) {
844  }
845 }
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:910
static int ast_channel_softhangup_cb(void *obj, void *arg, int flags)
Definition: channel.c:829
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
format_t ast_best_codec ( format_t  fmts)

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 1062 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().

1063 {
1064  /* This just our opinion, expressed in code. We are asked to choose
1065  the best codec to use, given no information */
1066  int x;
1067  static const format_t prefs[] =
1068  {
1069  /*! Okay, ulaw is used by all telephony equipment, so start with it */
1071  /*! Unless of course, you're a silly European, so then prefer ALAW */
1077  /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
1079  /*! Okay, well, signed linear is easy to translate into other stuff */
1082  /*! G.726 is standard ADPCM, in RFC3551 packing order */
1084  /*! G.726 is standard ADPCM, in AAL2 packing order */
1086  /*! ADPCM has great sound quality and is still pretty easy to translate */
1088  /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to
1089  translate and sounds pretty good */
1091  /*! iLBC is not too bad */
1093  /*! Speex is free, but computationally more expensive than GSM */
1096  /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
1097  to use it */
1099  /*! G.729a is faster than 723 and slightly less expensive */
1101  /*! Down to G.723.1 which is proprietary but at least designed for voice */
1103  };
1104  char buf[512];
1105 
1106  /* Strip out video */
1107  fmts &= AST_FORMAT_AUDIO_MASK;
1108 
1109  /* Find the first preferred codec in the format given */
1110  for (x = 0; x < ARRAY_LEN(prefs); x++) {
1111  if (fmts & prefs[x])
1112  return prefs[x];
1113  }
1114 
1115  ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
1116 
1117  return 0;
1118 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define AST_FORMAT_G723_1
Definition: frame.h:242
#define LOG_WARNING
Definition: logger.h:144
#define AST_FORMAT_G729A
Definition: frame.h:258
#define AST_FORMAT_LPC10
Definition: frame.h:256
#define AST_FORMAT_ALAW
Definition: frame.h:248
#define AST_FORMAT_SPEEX
Definition: frame.h:260
#define AST_FORMAT_G726
Definition: frame.h:264
#define AST_FORMAT_G726_AAL2
Definition: frame.h:250
#define AST_FORMAT_SLINEAR16
Definition: frame.h:272
#define AST_FORMAT_SIREN7
Definition: frame.h:268
int64_t format_t
Definition: frame_defs.h:32
static struct ast_codec_pref prefs
Definition: chan_iax2.c:258
#define AST_FORMAT_ULAW
Definition: frame.h:246
#define AST_FORMAT_TESTLAW
Definition: frame.h:303
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
#define AST_FORMAT_SIREN14
Definition: frame.h:270
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define AST_FORMAT_G719
Definition: frame.h:299
#define AST_FORMAT_ADPCM
Definition: frame.h:252
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
#define AST_FORMAT_G722
Definition: frame.h:266
#define AST_FORMAT_ILBC
Definition: frame.h:262
#define AST_FORMAT_GSM
Definition: frame.h:244
#define AST_FORMAT_SPEEX16
Definition: frame.h:301
struct ast_channel* ast_bridged_channel ( struct ast_channel chan)

Find bridged channel.

Note
This function does not return a reference to the bridged channel. The reason for this is mostly historical. It should return a reference, but it will take a lot of work to make the code base account for that. So, for now, the old rules still apply for how to handle this function. If this function is being used from the channel thread that owns the channel, then a reference is already held, and channel locking is not required to guarantee that the channel will stay around. If this function is used outside of the associated channel thread, the channel parameter 'chan' MUST be locked before calling this function. Also, 'chan' must remain locked for the entire time that the result of this function is being used.
Parameters
chanCurrent channel
Returns
A pointer to the bridged channel

Definition at line 7160 of file channel.c.

References ast_channel::_bridge, ast_channel_tech::bridged_channel, and ast_channel::tech.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_channel_masquerade(), __ast_read(), __dahdi_exception(), _skinny_show_lines(), action_agents(), action_coreshowchannels(), agents_data_provider_get(), agents_show(), agents_show_online(), analog_attempt_transfer(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_bridge_call(), ast_cel_report_event(), ast_channel_data_add_structure(), ast_channel_set_linkgroup(), ast_do_masquerade(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_var_channel_bridge(), ast_var_channels_table(), attempt_transfer(), cb_events(), channel_spy(), check_bridge(), common_exec(), console_transfer(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), func_channel_read(), get_refer_info(), handle_chanlist(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_refer(), handle_showchan(), handle_soft_key_event_message(), handle_stimulus_message(), key_call(), key_dial_page(), local_attended_transfer(), local_queryoption(), mgcp_hangup(), mgcp_ss(), misdn_attempt_transfer(), mixmonitor_thread(), my_get_sigpvt_bridged_channel(), park_call_full(), pri_dchannel(), schedule_delivery(), serialize_showchan(), sig_pri_attempt_transfer(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_hangup(), sip_set_rtp_peer(), skinny_transfer(), socket_process(), start_spying(), startmon(), TransferCallStep1(), and unistim_hangup().

7161 {
7162  struct ast_channel *bridged;
7163  bridged = chan->_bridge;
7164  if (bridged && bridged->tech->bridged_channel)
7165  bridged = bridged->tech->bridged_channel(chan, bridged);
7166  return bridged;
7167 }
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * _bridge
Definition: channel.h:748
struct ast_channel *(*const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge)
Find bridged channel.
Definition: channel.h:597
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_call ( struct ast_channel chan,
char *  addr,
int  timeout 
)

Make a call.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
chanwhich channel to make the call on
addrdestination of the call (Should be treated as const char *)
timeouttime to wait on for connect

Place a call, take no longer than timeout ms.

Returns
-1 on failure, 0 on not enough time (does not automatically stop ringing), and the number of seconds the connect took otherwise.

Definition at line 5761 of file channel.c.

References AST_CDR_FLAG_DIALED, ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, ast_channel_tech::call, ast_channel::cdr, and ast_channel::tech.

Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), dial_transfer(), do_forward(), do_idle_thread(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), and wait_for_answer().

5762 {
5763  /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
5764  If the remote end does not answer within the timeout, then do NOT hang up, but
5765  return anyway. */
5766  int res = -1;
5767  /* Stop if we're a zombie or need a soft hangup */
5768  ast_channel_lock(chan);
5769  if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
5770  if (chan->cdr) {
5772  }
5773  if (chan->tech->call)
5774  res = chan->tech->call(chan, addr, timeout);
5776  }
5777  ast_channel_unlock(chan);
5778  return res;
5779 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
struct ast_cdr * cdr
Definition: channel.h:766
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const call)(struct ast_channel *chan, char *addr, int timeout)
Call a given phone number (address, etc), but don&#39;t take longer than timeout seconds to do so...
Definition: channel.h:542
struct ast_channel_tech * tech
Definition: channel.h:743
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.

Parameters
callerin channel that requested orig
origchannel being replaced by the call forward channel
timeoutmaximum amount of time to wait for setup of new forward channel
formatrequested channel format
ohoutgoing helper used with original channel
outstatereason why unsuccessful (if uncuccessful)
Returns
Returns the forwarded call's ast_channel on success or NULL on failure

Definition at line 5386 of file channel.c.

References outgoing_helper::account, accountcode, ast_channel::accountcode, ast_call(), AST_CDR_FLAG_ORIGINATED, ast_cdr_setaccount(), ast_channel_lock, ast_channel_lock_both, ast_channel_unlock, ast_copy_flags, ast_copy_string(), ast_hangup(), ast_log(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), ast_request(), ast_set_variables(), ast_string_field_set, ast_channel::call_forward, call_forward_inherit(), ast_channel::cdr, ast_channel::connected, ast_channel::context, ast_channel::data, handle_cause(), LOG_NOTICE, outgoing_helper::parent_channel, pbx_builtin_getvar_helper(), ast_channel::redirecting, S_OR, type, and outgoing_helper::vars.

Referenced by __ast_request_and_dial(), and feature_request_and_dial().

5387 {
5388  char tmpchan[256];
5389  struct ast_channel *new_chan = NULL;
5390  char *data, *type;
5391  int cause = 0;
5392  int res;
5393 
5394  /* gather data and request the new forward channel */
5395  ast_copy_string(tmpchan, orig->call_forward, sizeof(tmpchan));
5396  if ((data = strchr(tmpchan, '/'))) {
5397  *data++ = '\0';
5398  type = tmpchan;
5399  } else {
5400  const char *forward_context;
5401  ast_channel_lock(orig);
5402  forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5403  snprintf(tmpchan, sizeof(tmpchan), "%s@%s", orig->call_forward, S_OR(forward_context, orig->context));
5404  ast_channel_unlock(orig);
5405  data = tmpchan;
5406  type = "Local";
5407  }
5408  if (!(new_chan = ast_request(type, format, orig, data, &cause))) {
5409  ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5410  handle_cause(cause, outstate);
5411  ast_hangup(orig);
5412  return NULL;
5413  }
5414 
5415  /* Copy/inherit important information into new channel */
5416  if (oh) {
5417  if (oh->vars) {
5418  ast_set_variables(new_chan, oh->vars);
5419  }
5420  if (oh->parent_channel) {
5421  call_forward_inherit(new_chan, oh->parent_channel, orig);
5422  }
5423  if (oh->account) {
5424  ast_channel_lock(new_chan);
5425  ast_cdr_setaccount(new_chan, oh->account);
5426  ast_channel_unlock(new_chan);
5427  }
5428  } else if (caller) { /* no outgoing helper so use caller if available */
5429  call_forward_inherit(new_chan, caller, orig);
5430  }
5431 
5432  ast_channel_lock_both(orig, new_chan);
5433  ast_copy_flags(new_chan->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED);
5434  ast_string_field_set(new_chan, accountcode, orig->accountcode);
5437  ast_channel_unlock(new_chan);
5438  ast_channel_unlock(orig);
5439 
5440  /* call new channel */
5441  res = ast_call(new_chan, data, 0);
5442  if (timeout) {
5443  *timeout = res;
5444  }
5445  if (res) {
5446  ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
5447  ast_hangup(orig);
5448  ast_hangup(new_chan);
5449  return NULL;
5450  }
5451  ast_hangup(orig);
5452 
5453  return new_chan;
5454 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_channel * parent_channel
Definition: channel.h:1006
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
Definition: cdr.c:990
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8261
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
struct ast_cdr * cdr
Definition: channel.h:766
#define ast_copy_flags(dest, src, flagz)
Definition: utils.h:84
const char * data
Definition: channel.h:755
struct ast_variable * vars
Definition: channel.h:1005
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
const char * account
Definition: channel.h:1004
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5336
const ast_string_field call_forward
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
static const char type[]
Definition: chan_nbs.c:57
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
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.
Definition: channel.c:2316
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition: channel.c:5359
const ast_string_field accountcode
Definition: channel.h:787
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
static snd_pcm_format_t format
Definition: chan_alsa.c:93
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.
Definition: channel.c:2367
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
void ast_cancel_shutdown ( void  )

Cancel a shutdown in progress.

Cancels an existing shutdown and returns to normal operation

Definition at line 859 of file channel.c.

Referenced by handle_abort_shutdown().

860 {
861  shutting_down = 0;
862 }
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
const char* ast_cause2str ( int  cause)

Gives the string form of a given cause code.

Parameters
statecause to get the description of
Returns
the text form of the binary cause code given

Gives the string form of a given cause code.

Definition at line 980 of file channel.c.

References ARRAY_LEN, causes, and causes_map::desc.

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().

981 {
982  int x;
983 
984  for (x = 0; x < ARRAY_LEN(causes); x++) {
985  if (causes[x].cause == cause)
986  return causes[x].desc;
987  }
988 
989  return "Unknown";
990 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct causes_map causes[]
Definition: channel.c:209
const char * desc
Definition: channel.c:206
void ast_change_name ( struct ast_channel chan,
const char *  newname 
)

Change channel name.

Precondition
Absolutely all channels MUST be unlocked before calling this function.
Parameters
chanthe channel to change the name of
newnamethe name to change to
Returns
nothing
Note
this function must NEVER be used when any channels are locked regardless if it is the channel who's name is being changed or not because it invalidates our channel container locking order... lock container first, then the individual channels, never the other way around.

Definition at line 6229 of file channel.c.

References __ast_change_name_nolink(), ao2_link, ao2_lock, ao2_unlink, ao2_unlock, ast_channel_lock, ast_channel_unlock, and channels.

Referenced by update_name().

6230 {
6231  /* We must re-link, as the hash value will change here. */
6232  ao2_lock(channels);
6233  ast_channel_lock(chan);
6234  ao2_unlink(channels, chan);
6235  __ast_change_name_nolink(chan, newname);
6236  ao2_link(channels, chan);
6237  ast_channel_unlock(chan);
6239 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ao2_link(arg1, arg2)
Definition: astobj2.h:785
#define ao2_unlock(a)
Definition: astobj2.h:497
#define ao2_lock(a)
Definition: astobj2.h:488
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
static void __ast_change_name_nolink(struct ast_channel *chan, const char *newname)
this function simply changes the name of the channel and issues a manager_event with out unlinking an...
Definition: channel.c:6223
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
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.

Parameters
c0first channel to bridge
c1second channel to bridge
configconfig for the channels
fodestination frame(?)
rcdestination channel(?)

Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in *rf (remember, it could be NULL) and which channel (0 or 1) in rc

Definition at line 7506 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_lock_both, ast_channel_make_compatible(), ast_channel_unlock, ast_check_hangup(), ast_check_hangup_locked(), ast_clear_flag, AST_CONTROL_SRCUPDATE, ast_debug, AST_FEATURE_PLAY_WARNING, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_framehook_list_is_empty(), ast_generic_bridge(), ast_indicate(), ast_log(), ast_manager_event_multichan, ast_samp2tv(), ast_set_flag, ast_set_owners_and_peers(), AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_test_suite_event_notify, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verb, ast_channel::audiohooks, ast_channel_tech::bridge, bridge_play_sounds(), bridge_playfile(), ast_channel::caller, ast_bridge_config::end_sound, EVENT_FLAG_CALL, ast_bridge_config::feature_start_time, ast_bridge_config::feature_timer, ast_bridge_config::features_callee, ast_bridge_config::features_caller, ast_bridge_config::flags, ast_channel::framehooks, ast_channel::generator, ast_party_caller::id, LOG_WARNING, manager_bridge_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_party_id::number, ast_bridge_config::play_warning, ast_channel::readformat, S_COR, ast_channel_tech::send_digit_begin, ast_bridge_config::start_sound, ast_bridge_config::start_time, ast_party_number::str, ast_channel::tech, ast_bridge_config::timelimit, ast_channel::uniqueid, update_bridge_vars(), ast_party_number::valid, ast_bridge_config::warning_freq, ast_bridge_config::warning_sound, and ast_channel::writeformat.

Referenced by ast_bridge_call().

7508 {
7509  struct ast_channel *chans[2] = { c0, c1 };
7511  format_t o0nativeformats;
7512  format_t o1nativeformats;
7513  long time_left_ms=0;
7514  char caller_warning = 0;
7515  char callee_warning = 0;
7516 
7517  *fo = NULL;
7518 
7519  if (c0->_bridge) {
7520  ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
7521  c0->name, c0->_bridge->name);
7522  return -1;
7523  }
7524  if (c1->_bridge) {
7525  ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
7526  c1->name, c1->_bridge->name);
7527  return -1;
7528  }
7529 
7530  /* Stop if we're a zombie or need a soft hangup */
7533  return -1;
7534 
7535  caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING);
7536  callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING);
7537 
7538  if (ast_tvzero(config->start_time)) {
7539  config->start_time = ast_tvnow();
7540  if (config->start_sound) {
7541  if (caller_warning) {
7542  bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000);
7543  }
7544  if (callee_warning) {
7545  bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000);
7546  }
7547  }
7548  }
7549 
7550  /* Keep track of bridge */
7551  ast_channel_lock_both(c0, c1);
7552  c0->_bridge = c1;
7553  c1->_bridge = c0;
7554  ast_channel_unlock(c0);
7555  ast_channel_unlock(c1);
7556 
7557  ast_set_owners_and_peers(c0, c1);
7558 
7559  o0nativeformats = c0->nativeformats;
7560  o1nativeformats = c1->nativeformats;
7561 
7562  if (config->feature_timer && !ast_tvzero(config->nexteventts)) {
7563  config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000));
7564  } else if (config->timelimit) {
7565  time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time);
7566  config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
7567  if ((caller_warning || callee_warning) && config->play_warning) {
7568  long next_warn = config->play_warning;
7569  if (time_left_ms < config->play_warning && config->warning_freq > 0) {
7570  /* At least one warning was played, which means we are returning after feature */
7571  long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq;
7572  /* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq',
7573  because nexteventts will be updated once again in the 'if (!to)' block */
7574  next_warn = config->play_warning - warns_passed * config->warning_freq;
7575  }
7576  config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000));
7577  }
7578  } else {
7579  config->nexteventts.tv_sec = 0;
7580  config->nexteventts.tv_usec = 0;
7581  }
7582 
7583  if (!c0->tech->send_digit_begin)
7585  if (!c1->tech->send_digit_begin)
7587  manager_bridge_event(1, 1, c0, c1);
7588 
7589  /* Before we enter in and bridge these two together tell them both the source of audio has changed */
7592 
7593  for (/* ever */;;) {
7594  struct timeval now = { 0, };
7595  int to;
7596 
7597  to = -1;
7598 
7599  if (!ast_tvzero(config->nexteventts)) {
7600  now = ast_tvnow();
7601  to = ast_tvdiff_ms(config->nexteventts, now);
7602  if (to <= 0) {
7603  if (!config->timelimit) {
7604  res = AST_BRIDGE_COMPLETE;
7605  break;
7606  }
7607  to = 0;
7608  }
7609  }
7610 
7611  if (config->timelimit) {
7612  time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
7613  if (time_left_ms < 0) {
7614  time_left_ms = 0;
7615  }
7616 
7617  if (time_left_ms < to) {
7618  to = time_left_ms;
7619  }
7620 
7621  if (time_left_ms <= 0) {
7622  if (caller_warning && config->end_sound)
7623  bridge_playfile(c0, c1, config->end_sound, 0);
7624  if (callee_warning && config->end_sound)
7625  bridge_playfile(c1, c0, config->end_sound, 0);
7626  *fo = NULL;
7627  res = AST_BRIDGE_COMPLETE;
7628  ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s\r\nChannel2: %s", c0->name, c1->name);
7629  break;
7630  }
7631 
7632  if (!to) {
7633  if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
7634  int t = (time_left_ms + 500) / 1000; /* round to nearest second */
7635  if (caller_warning)
7636  bridge_playfile(c0, c1, config->warning_sound, t);
7637  if (callee_warning)
7638  bridge_playfile(c1, c0, config->warning_sound, t);
7639  }
7640 
7641  if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) {
7642  config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000));
7643  } else {
7644  config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
7645  }
7646  }
7648  }
7649 
7650  if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
7653  }
7656  }
7657  ast_channel_lock_both(c0, c1);
7658  c0->_bridge = c1;
7659  c1->_bridge = c0;
7660  ast_channel_unlock(c0);
7661  ast_channel_unlock(c1);
7662  ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
7663  continue;
7664  }
7665 
7666  /* Stop if we're a zombie or need a soft hangup */
7669  *fo = NULL;
7670  res = AST_BRIDGE_COMPLETE;
7671  ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
7672  c0->name, c1->name,
7673  ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
7674  ast_check_hangup(c0) ? "Yes" : "No",
7675  ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
7676  ast_check_hangup(c1) ? "Yes" : "No");
7677  break;
7678  }
7679 
7680  update_bridge_vars(c0, c1);
7681 
7682  bridge_play_sounds(c0, c1);
7683 
7684  if (c0->tech->bridge &&
7685  /* if < 1 ms remains use generic bridging for accurate timing */
7686  (!config->timelimit || to > 1000 || to == -1) &&
7687  (c0->tech->bridge == c1->tech->bridge) &&
7688  !c0->monitor && !c1->monitor &&
7689  !c0->audiohooks && !c1->audiohooks &&
7691  !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
7692  int timeoutms = to - 1000 > 0 ? to - 1000 : to;
7693  /* Looks like they share a bridge method and nothing else is in the way */
7696  if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
7697  ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
7698  "Channel1: %s\r\n"
7699  "Channel2: %s\r\n"
7700  "Uniqueid1: %s\r\n"
7701  "Uniqueid2: %s\r\n"
7702  "CallerID1: %s\r\n"
7703  "CallerID2: %s\r\n",
7704  c0->name, c1->name,
7705  c0->uniqueid, c1->uniqueid,
7706  S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
7707  S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
7708 
7709  ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
7710 
7713 
7714  if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
7715  continue;
7716  }
7717 
7718  ast_channel_lock_both(c0, c1);
7719  c0->_bridge = NULL;
7720  c1->_bridge = NULL;
7721  ast_channel_unlock(c0);
7722  ast_channel_unlock(c1);
7723  return res;
7724  } else {
7727  }
7728  switch (res) {
7729  case AST_BRIDGE_RETRY:
7730  if (config->play_warning) {
7732  }
7733  continue;
7734  default:
7735  ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name);
7736  /* fallthrough */
7738  break;
7739  }
7740  }
7741 
7742  if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) ||
7743  (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) &&
7744  !(c0->generator || c1->generator)) {
7745  if (ast_channel_make_compatible(c0, c1)) {
7746  ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name);
7747  manager_bridge_event(0, 1, c0, c1);
7748  return AST_BRIDGE_FAILED;
7749  }
7750  o0nativeformats = c0->nativeformats;
7751  o1nativeformats = c1->nativeformats;
7752  }
7753 
7754  update_bridge_vars(c0, c1);
7755 
7756  res = ast_generic_bridge(c0, c1, config, fo, rc);
7757  if (res != AST_BRIDGE_RETRY) {
7758  break;
7759  } else if (config->feature_timer) {
7760  /* feature timer expired but has not been updated, sending to ast_bridge_call to do so */
7761  break;
7762  }
7763  }
7764 
7767 
7768  /* Now that we have broken the bridge the source will change yet again */
7771 
7772  ast_channel_lock_both(c0, c1);
7773  c0->_bridge = NULL;
7774  c1->_bridge = NULL;
7775  ast_channel_unlock(c0);
7776  ast_channel_unlock(c1);
7777 
7778  ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
7779  "Channel1: %s\r\n"
7780  "Channel2: %s\r\n"
7781  "Uniqueid1: %s\r\n"
7782  "Uniqueid2: %s\r\n"
7783  "CallerID1: %s\r\n"
7784  "CallerID2: %s\r\n",
7785  c0->name, c1->name,
7786  c0->uniqueid, c1->uniqueid,
7787  S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
7788  S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
7789  ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
7790 
7791  return res;
7792 }
struct ast_channel * masqr
Definition: channel.h:752
Main Channel structure associated with a channel.
Definition: channel.h:742
long feature_timer
Definition: channel.h:980
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_channel * masq
Definition: channel.h:751
static void bridge_play_sounds(struct ast_channel *c0, struct ast_channel *c1)
Definition: channel.c:7478
struct timeval feature_start_time
Definition: channel.h:979
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_flags features_callee
Definition: channel.h:976
format_t writeformat
Definition: channel.h:854
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
#define ast_set_flag(p, flag)
Definition: utils.h:70
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:820
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:172
#define LOG_WARNING
Definition: logger.h:144
struct ast_generator * generator
Definition: channel.h:747
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
#define EVENT_FLAG_CALL
Definition: manager.h:72
struct timeval nexteventts
Definition: channel.h:978
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
format_t nativeformats
Definition: channel.h:852
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
Definition: channel.c:7441
#define ast_verb(level,...)
Definition: logger.h:243
const char * start_sound
Definition: channel.h:986
static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
Definition: channel.c:7203
static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, struct ast_channel *c1)
Send manager event for bridge link and unlink events.
Definition: channel.c:7421
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
unsigned int flags
Definition: channel.h:987
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition: channel.c:2707
struct timeval start_time
Definition: channel.h:977
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
const char * end_sound
Definition: channel.h:985
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:191
struct ast_channel * _bridge
Definition: channel.h:748
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_flags features_caller
Definition: channel.h:975
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
enum ast_bridge_result(*const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels of the same type together.
Definition: channel.h:569
static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
Definition: channel.c:7169
static void ast_set_owners_and_peers(struct ast_channel *chan1, struct ast_channel *chan2)
Definition: channel.c:6430
int64_t format_t
Definition: frame_defs.h:32
struct ast_framehook_list * framehooks
Definition: channel.h:765
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1)
Makes two channel formats compatible.
Definition: channel.c:5970
format_t readformat
Definition: channel.h:853
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Definition: manager.h:226
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: utils.c:1601
const char * warning_sound
Definition: channel.h:984
struct ast_channel_monitor * monitor
Definition: channel.h:769
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
ast_bridge_result
Definition: channel.h:168
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Note
Absolutely NO channel locks should be held before calling this function.
Since
1.8

Definition at line 1634 of file channel.c.

References ao2_callback_data, and channels.

Referenced by ast_pickup_call(), handle_core_set_debug_channel(), my_ast_get_channel_by_name_locked(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), and state_notify_build_xml().

1636 {
1637  return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
1638 }
#define ao2_callback_data(arg1, arg2, arg3, arg4, arg5)
Definition: astobj2.h:943
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
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.

Since
1.8
Note
If base_params is NULL, the channel will get the default values for all CCSS parameters.

This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function.

Parameters
chanThe channel to create the datastore on
base_paramsCCSS parameters we wish to copy into the channel
Return values
0Success
-1Failure

Definition at line 9731 of file channel.c.

References ast_cc_config_params_destroy(), ast_cc_config_params_init, ast_cc_copy_config_params(), ast_channel_datastore_add(), ast_datastore_alloc(), and ast_datastore::data.

Referenced by ast_channel_get_cc_config_params(), dahdi_new(), local_call(), local_request(), and sip_new().

9733 {
9734  struct ast_cc_config_params *cc_params;
9735  struct ast_datastore *cc_datastore;
9736 
9737  if (!(cc_params = ast_cc_config_params_init())) {
9738  return -1;
9739  }
9740 
9741  if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
9742  ast_cc_config_params_destroy(cc_params);
9743  return -1;
9744  }
9745 
9746  if (base_params) {
9747  ast_cc_copy_config_params(cc_params, base_params);
9748  }
9749  cc_datastore->data = cc_params;
9750  ast_channel_datastore_add(chan, cc_datastore);
9751  return 0;
9752 }
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition: ccss.c:579
Structure for a data store object.
Definition: datastore.h:54
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
Definition: ccss.c:741
void * data
Definition: datastore.h:56
static struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:9725
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2590
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.

Parameters
chanthe channel to clear the flag on
flagthe flag or flags to clear
Returns
Nothing.

Definition at line 2707 of file channel.c.

References ast_channel::_softhangup, ast_channel_lock, ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_FRAME_CONTROL, ast_frfree, AST_LIST_LAST, AST_LIST_REMOVE, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::readq, and ast_frame::subclass.

Referenced by __ast_pbx_run(), ast_channel_bridge(), ast_generic_bridge(), check_goto_on_transfer(), and collect_digits().

2708 {
2709  ast_channel_lock(chan);
2710 
2711  chan->_softhangup &= ~flag;
2712 
2713  if (!chan->_softhangup) {
2714  struct ast_frame *fr;
2715 
2716  /* If we have completely cleared the softhangup flag,
2717  * then we need to fully abort the hangup process. This requires
2718  * pulling the END_OF_Q frame out of the channel frame queue if it
2719  * still happens to be there. */
2720 
2721  fr = AST_LIST_LAST(&chan->readq);
2722  if (fr && fr->frametype == AST_FRAME_CONTROL &&
2724  AST_LIST_REMOVE(&chan->readq, fr, frame_list);
2725  ast_frfree(fr);
2726  }
2727  }
2728 
2729  ast_channel_unlock(chan);
2730 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
int _softhangup
Definition: channel.h:832
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
#define ast_channel_unlock(chan)
Definition: channel.h:2467
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel::@156 readq
int ast_channel_cmpwhentohangup ( struct ast_channel chan,
time_t  offset 
)

Compare a offset with the settings of when to hang a channel up.

Parameters
chanchannel on which to check for hang up
offsetoffset in seconds from current time
Returns
1, 0, or -1

This function compares a offset from current time with the absolute time out on a channel (when to hang up). If the absolute time out on a channel is earlier than current time plus the offset, it returns 1, if the two time values are equal, it return 0, otherwise, it return -1.

See Also
ast_channel_cmpwhentohangup_tv()
Version
1.6.1 deprecated function (only had seconds precision)

Definition at line 900 of file channel.c.

References ast_channel_cmpwhentohangup_tv().

901 {
902  struct timeval when = { offset, };
903  return ast_channel_cmpwhentohangup_tv(chan, when);
904 }
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.
Definition: channel.c:885
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.

Parameters
chanchannel on which to check for hangup
offsetoffset in seconds and microseconds from current time
Returns
1, 0, or -1 This function compares a offset from current time with the absolute time out on a channel (when to hang up). If the absolute time out on a channel is earlier than current time plus the offset, it returns 1, if the two time values are equal, it return 0, otherwise, it return -1.
Since
1.6.1

Compare a offset with the settings of when to hang a channel up.

Definition at line 885 of file channel.c.

References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.

Referenced by ast_channel_cmpwhentohangup().

886 {
887  struct timeval whentohangup;
888 
889  if (ast_tvzero(chan->whentohangup))
890  return ast_tvzero(offset) ? 0 : -1;
891 
892  if (ast_tvzero(offset))
893  return 1;
894 
895  whentohangup = ast_tvadd(offset, ast_tvnow());
896 
897  return ast_tvdiff_ms(whentohangup, chan->whentohangup);
898 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
struct timeval whentohangup
Definition: channel.h:789
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.

Since
1.8 Whenever we want to update a channel's connected line information, we may need to run a macro so that an administrator can manipulate the information before sending it out. This function both runs the macro and sends the update to the channel.
Parameters
autoservice_chanChannel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL
macro_chanThe channel to run the macro on. Also the channel from which we determine which macro we need to run.
connected_infoEither an ast_party_connected_line or ast_frame pointer of type AST_CONTROL_CONNECTED_LINE
callerIf true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
frameIf true, then connected_info is an ast_frame pointer, otherwise it is an ast_party_connected_line pointer.
Return values
0Success
-1Either the macro does not exist, or there was an error while attempting to run the macro
Todo:

Have multiple return codes based on the MACRO_RESULT

Make constants so that caller and frame can be more expressive than just '1' and '0'

Definition at line 9618 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_party_connected_line_free(), ast_party_connected_line_init(), ast_strdupa, ast_strlen_zero(), chanlist::connected, ast_channel::connected, ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, and S_OR.

Referenced by __ast_read(), app_exec(), ast_bridge_call(), ast_do_pickup(), ast_generic_bridge(), atxfer_fail_cleanup(), builtin_atxfer(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), parked_call_exec(), remote_bridge_loop(), and wait_for_answer().

9619 {
9620  const char *macro;
9621  const char *macro_args;
9622  int retval;
9623 
9624  ast_channel_lock(macro_chan);
9625  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
9626  ? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO");
9627  macro = ast_strdupa(S_OR(macro, ""));
9628  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
9629  ? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS");
9630  macro_args = ast_strdupa(S_OR(macro_args, ""));
9631 
9632  if (ast_strlen_zero(macro)) {
9633  ast_channel_unlock(macro_chan);
9634  return -1;
9635  }
9636 
9637  if (is_frame) {
9638  const struct ast_frame *frame = connected_info;
9639 
9640  ast_connected_line_parse_data(frame->data.ptr, frame->datalen, &macro_chan->connected);
9641  } else {
9642  const struct ast_party_connected_line *connected = connected_info;
9643 
9644  ast_party_connected_line_copy(&macro_chan->connected, connected);
9645  }
9646  ast_channel_unlock(macro_chan);
9647 
9648  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
9649  if (!retval) {
9650  struct ast_party_connected_line saved_connected;
9651 
9652  ast_party_connected_line_init(&saved_connected);
9653  ast_channel_lock(macro_chan);
9654  ast_party_connected_line_copy(&saved_connected, &macro_chan->connected);
9655  ast_channel_unlock(macro_chan);
9656  ast_channel_update_connected_line(macro_chan, &saved_connected, NULL);
9657  ast_party_connected_line_free(&saved_connected);
9658  }
9659 
9660  return retval;
9661 }
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2308
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
void * ptr
Definition: frame.h:160
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.
Definition: channel.c:9085
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int datalen
Definition: frame.h:148
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
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.
Definition: channel.c:8886
Connected Line/Party information.
Definition: channel.h:401
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: app.c:294
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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.
Definition: channel.c:2316
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
static int connected
Definition: cdr_pgsql.c:57
union ast_frame::@172 data
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.

Parameters
[in]treeThe ast data tree.
[in]chanThe channel structure to add to tree.
[in]add_bridgedAdd the bridged channel to the structure.
Return values
<0on error.
0on success.

Definition at line 357 of file channel.c.

References ast_channel::_softhangup, ast_channel::_state, ast_channel::amaflags, ast_bridged_channel(), ast_cause2str(), ast_cdr_data_add_structure(), ast_cdr_flags2str(), ast_channel_data_add_structure(), ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_int(), ast_data_add_node(), ast_data_add_str(), ast_data_add_structure, ast_data_add_uint(), AST_SOFTHANGUP_APPUNLOAD, AST_SOFTHANGUP_ASYNCGOTO, AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, AST_SOFTHANGUP_SHUTDOWN, AST_SOFTHANGUP_TIMEOUT, AST_SOFTHANGUP_UNBRIDGE, ast_state2str(), ast_tone_zone_data_add_structure(), ast_transfercapability2str(), ast_channel::cdr, channel_data_add_flags(), ast_channel::hangupcause, ast_channel::nativeformats, ast_channel::oldwriteformat, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::transfercapability, ast_channel::whentohangup, ast_channel::writeformat, and ast_channel::zone.

Referenced by agents_data_provider_get(), ast_channel_data_add_structure(), data_channels_provider_handler(), queues_data_provider_get_helper(), and user_add_provider_cb().

359 {
360  struct ast_channel *bc;
361  struct ast_data *data_bridged;
362  struct ast_data *data_cdr;
363  struct ast_data *data_flags;
364  struct ast_data *data_zones;
365  struct ast_data *enum_node;
366  struct ast_data *data_softhangup;
367 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
368  struct ast_data *data_callerid;
369  char value_str[100];
370 #endif
371 
372  if (!tree) {
373  return -1;
374  }
375 
376  ast_data_add_structure(ast_channel, tree, chan);
377 
378  if (add_bridged) {
379  bc = ast_bridged_channel(chan);
380  if (bc) {
381  data_bridged = ast_data_add_node(tree, "bridged");
382  if (!data_bridged) {
383  return -1;
384  }
385  ast_channel_data_add_structure(data_bridged, bc, 0);
386  }
387  }
388 
389  ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat);
390  ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
391  ast_data_add_codecs(tree, "readformat", chan->readformat);
392  ast_data_add_codecs(tree, "writeformat", chan->writeformat);
393  ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat);
394  ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat);
395 
396  /* state */
397  enum_node = ast_data_add_node(tree, "state");
398  if (!enum_node) {
399  return -1;
400  }
401  ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
402  ast_data_add_int(enum_node, "value", chan->_state);
403 
404  /* hangupcause */
405  enum_node = ast_data_add_node(tree, "hangupcause");
406  if (!enum_node) {
407  return -1;
408  }
409  ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
410  ast_data_add_int(enum_node, "value", chan->hangupcause);
411 
412  /* amaflags */
413  enum_node = ast_data_add_node(tree, "amaflags");
414  if (!enum_node) {
415  return -1;
416  }
417  ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
418  ast_data_add_int(enum_node, "value", chan->amaflags);
419 
420  /* transfercapability */
421  enum_node = ast_data_add_node(tree, "transfercapability");
422  if (!enum_node) {
423  return -1;
424  }
426  ast_data_add_int(enum_node, "value", chan->transfercapability);
427 
428  /* _softphangup */
429  data_softhangup = ast_data_add_node(tree, "softhangup");
430  if (!data_softhangup) {
431  return -1;
432  }
433  ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV);
434  ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO);
435  ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN);
436  ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT);
437  ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD);
438  ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT);
439  ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE);
440 
441  /* channel flags */
442  data_flags = ast_data_add_node(tree, "flags");
443  if (!data_flags) {
444  return -1;
445  }
446  channel_data_add_flags(data_flags, chan);
447 
448  ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec);
449 
450 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
451  /* callerid */
452  data_callerid = ast_data_add_node(tree, "callerid");
453  if (!data_callerid) {
454  return -1;
455  }
456  ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
457  /* insert the callerid ton */
458  enum_node = ast_data_add_node(data_callerid, "cid_ton");
459  if (!enum_node) {
460  return -1;
461  }
462  ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
463  snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
464  party_number_ton2str(chan->cid.cid_ton),
465  party_number_plan2str(chan->cid.cid_ton));
466  ast_data_add_str(enum_node, "text", value_str);
467 #endif
468 
469  /* tone zone */
470  if (chan->zone) {
471  data_zones = ast_data_add_node(tree, "zone");
472  if (!data_zones) {
473  return -1;
474  }
475  ast_tone_zone_data_add_structure(data_zones, chan->zone);
476  }
477 
478  /* insert cdr */
479  data_cdr = ast_data_add_node(tree, "cdr");
480  if (!data_cdr) {
481  return -1;
482  }
483 
484  ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
485 
486  return 0;
487 }
Main Channel structure associated with a channel.
Definition: channel.h:742
The data tree to be returned by the callbacks and managed by functions local to this file...
Definition: data.c:85
struct ast_tone_zone * zone
Definition: channel.h:767
format_t writeformat
Definition: channel.h:854
format_t rawwriteformat
Definition: channel.h:856
struct ast_data * ast_data_add_uint(struct ast_data *root, const char *childname, unsigned int value)
Add an unsigned integer node type.
Definition: data.c:2332
struct ast_data * ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean)
Add a boolean node type.
Definition: data.c:2344
struct ast_cdr * cdr
Definition: channel.h:766
unsigned short transfercapability
Definition: channel.h:863
format_t nativeformats
Definition: channel.h:852
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
char * ast_cdr_flags2str(int flags)
Definition: cdr.c:977
format_t rawreadformat
Definition: channel.h:855
int ast_cdr_data_add_structure(struct ast_data *tree, struct ast_cdr *cdr, int recur)
Definition: cdr.c:1674
format_t oldwriteformat
Definition: channel.h:837
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.
Definition: channel.c:357
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
Definition: data.c:2317
int ast_data_add_codecs(struct ast_data *root, const char *node_name, format_t capability)
Add the list of codecs in the root node based on the capability parameter.
Definition: data.c:3112
#define ast_data_add_structure(structure_name, root, structure)
Definition: data.h:620
int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone)
Add a tone_zone structure to the data tree specified.
Definition: indications.c:1127
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
int _softhangup
Definition: channel.h:832
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
format_t readformat
Definition: channel.h:853
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:1041
int hangupcause
Definition: channel.h:849
struct timeval whentohangup
Definition: channel.h:789
struct ast_data * ast_data_add_str(struct ast_data *root, const char *childname, const char *string)
Add a string node type.
Definition: data.c:2401
int amaflags
Definition: channel.h:843
struct ast_data * ast_data_add_int(struct ast_data *root, const char *childname, int value)
Add an integer node type.
Definition: data.c:2322
static void channel_data_add_flags(struct ast_data *tree, struct ast_channel *chan)
Definition: channel.c:281
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.

Parameters
[in]treeThe search tree generated by the data api.
[in]chanThe channel to compare.
[in]structure_nameThe name of the node of the channel structure.
Return values
0The structure matches.
1The structure doesn't matches.

Definition at line 489 of file channel.c.

References ast_data_search_cmp_structure.

491 {
492  return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
493 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_data_search_cmp_structure(search, structure_name, structure, structure_name_cmp)
Definition: data.h:420
int ast_channel_datastore_add ( struct ast_channel chan,
struct ast_datastore datastore 
)

Add a datastore to a channel.

Note
The channel should be locked before calling this function.
Return values
0success
non-zerofailure

Definition at line 2590 of file channel.c.

References AST_LIST_INSERT_HEAD, and ast_channel::datastores.

Referenced by __ast_channel_masquerade(), _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), add_features_datastore(), add_to_agi(), apply_plc(), ast_cel_fabricate_channel_from_event(), ast_channel_cc_params_init(), ast_do_pickup(), ast_iax2_new(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), calendar_query_exec(), cc_interfaces_datastore_init(), dial_exec_full(), do_notify(), dundi_query_read(), enable_jack_hook(), enum_query_read(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_write_real(), get_lock(), gosub_exec(), lua_get_state(), mute_add_audiohook(), pitchshift_helper(), raise_exception(), set_chan_app_data(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), srv_datastore_setup(), try_calling(), and volume_write().

2591 {
2592  int res = 0;
2593 
2594  AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry);
2595 
2596  return res;
2597 }
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
struct ast_channel::datastores datastores
struct ast_datastore* attribute_malloc ast_channel_datastore_alloc ( const struct ast_datastore_info info,
const char *  uid 
)

Create a channel data store object.

Note
None of the datastore API calls lock the ast_channel they are using. So, the channel should be locked before calling the functions that take a channel argument.
Deprecated:
You should use the ast_datastore_alloc() generic function instead.
Version
1.6.1 deprecated

Definition at line 2563 of file channel.c.

References ast_datastore_alloc().

2564 {
2565  return ast_datastore_alloc(info, uid);
2566 }
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
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.

Note
The channel should be locked before calling this function.
The datastore returned from this function must not be used if the reference to the channel is released.
Return values
pointerto the datastore if found
NULLif not found

Definition at line 2604 of file channel.c.

References AST_LIST_TRAVERSE, ast_channel::datastores, ast_datastore::info, and ast_datastore::uid.

Referenced by _macro_exec(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), acf_odbc_read(), add_agi_cmd(), add_features_datastore(), add_to_agi(), apply_plc(), ast_can_pickup(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_completed(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_current_core_id(), ast_cc_is_recall(), ast_cc_offer(), ast_channel_get_cc_config_params(), ast_do_masquerade(), ast_handle_cc_control_frame(), ast_ignore_cc(), ast_odbc_retrieve_transaction_obj(), ast_set_cc_interfaces_chanvar(), attended_transfer_occurred(), audiohook_volume_callback(), audiohook_volume_get(), balance_stack(), builtin_atxfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), cc_build_payload(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), find_details(), find_speech(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_inheritance_write(), func_mute_write(), get_agi_cmd(), get_lock(), gosub_exec(), gosub_run(), handle_gosub(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lock_fixup(), lua_get_state(), manage_parked_call(), manager_mutestream(), mark_transaction_active(), mute_callback(), parked_call_exec(), pitchshift_cb(), pitchshift_helper(), pop_exec(), queue_transfer_fixup(), raise_exception(), release_transaction(), return_exec(), set_security_requirements(), shared_read(), shared_write(), smdi_msg_read(), speech_datastore_destroy(), speex_callback(), speex_read(), speex_write(), srv_query_read(), srv_result_read(), stackpeek_read(), stop_mixmonitor_exec(), try_calling(), unlock_read(), volume_callback(), and volume_write().

2605 {
2606  struct ast_datastore *datastore = NULL;
2607 
2608  if (info == NULL)
2609  return NULL;
2610 
2611  AST_LIST_TRAVERSE(&chan->datastores, datastore, entry) {
2612  if (datastore->info != info) {
2613  continue;
2614  }
2615 
2616  if (uid == NULL) {
2617  /* matched by type only */
2618  break;
2619  }
2620 
2621  if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2622  /* Matched by type AND uid */
2623  break;
2624  }
2625  }
2626 
2627  return datastore;
2628 }
struct ast_datastore::@163 entry
struct ast_datastore_info * info
Definition: datastore.h:57
Structure for a data store object.
Definition: datastore.h:54
const char * uid
Definition: datastore.h:55
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_channel::datastores datastores
int ast_channel_datastore_free ( struct ast_datastore datastore)

Free a channel data store object.

Deprecated:
You should use the ast_datastore_free() generic function instead.
Version
1.6.1 deprecated

Definition at line 2568 of file channel.c.

References ast_datastore_free().

2569 {
2570  return ast_datastore_free(datastore);
2571 }
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
int ast_channel_datastore_inherit ( struct ast_channel from,
struct ast_channel to 
)

Inherit datastores from a parent to a child.

Definition at line 2573 of file channel.c.

References ast_datastore_alloc(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.

Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), findmeexec(), local_call(), ring_entry(), and wait_for_answer().

2574 {
2575  struct ast_datastore *datastore = NULL, *datastore2;
2576 
2577  AST_LIST_TRAVERSE(&from->datastores, datastore, entry) {
2578  if (datastore->inheritance > 0) {
2579  datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2580  if (datastore2) {
2581  datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2582  datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2583  AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry);
2584  }
2585  }
2586  }
2587  return 0;
2588 }
struct ast_datastore::@163 entry
struct ast_datastore_info * info
Definition: datastore.h:57
void *(* duplicate)(void *data)
Definition: datastore.h:33
Structure for a data store object.
Definition: datastore.h:54
const char * uid
Definition: datastore.h:55
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_channel::datastores datastores
#define DATASTORE_INHERIT_FOREVER
Definition: channel.h:156
unsigned int inheritance
Definition: datastore.h:58
void * data
Definition: datastore.h:56
int ast_channel_datastore_remove ( struct ast_channel chan,
struct ast_datastore datastore 
)

Remove a datastore from a channel.

Note
The channel should be locked before calling this function.
Return values
0success
non-zerofailure

Definition at line 2599 of file channel.c.

References AST_LIST_REMOVE, and ast_channel::datastores.

Referenced by acf_fetch(), acf_odbc_read(), adjust_frame_for_plc(), ast_do_masquerade(), ast_do_pickup(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), frame_trace_helper(), lua_get_state(), queue_transfer_fixup(), speech_datastore_destroy(), speex_write(), srv_query_read(), stop_mixmonitor_exec(), and try_calling().

2600 {
2601  return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1;
2602 }
struct ast_datastore::@163 entry
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
struct ast_channel::datastores datastores
int ast_channel_defer_dtmf ( struct ast_channel chan)

Defers DTMF so that you only read things like hangups and audio.

Returns
non-zero if channel was already DTMF-deferred or 0 if channel is just now being DTMF-deferred

Defers DTMF so that you only read things like hangups and audio.

Definition at line 1616 of file channel.c.

References AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.

Referenced by __adsi_transmit_messages(), and find_cache().

1617 {
1618  int pre = 0;
1619 
1620  if (chan) {
1621  pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF);
1623  }
1624  return pre;
1625 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
int ast_channel_early_bridge ( struct ast_channel c0,
struct ast_channel c1 
)

Bridge two channels together (early)

Parameters
c0first channel to bridge
c1second channel to bridge

Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.

Returns
Returns 0 on success and -1 if it could not be done

Definition at line 7406 of file channel.c.

References ast_channel_tech::early_bridge, and ast_channel::tech.

Referenced by dial_exec_full(), and wait_for_answer().

7407 {
7408  /* Make sure we can early bridge, if not error out */
7409  if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
7410  return -1;
7411 
7412  return c0->tech->early_bridge(c0, c1);
7413 }
enum ast_bridge_result(*const early_bridge)(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels of the same type together (early)
Definition: channel.h:573
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel* ast_channel_get_by_exten ( const char *  exten,
const char *  context 
)

Find a channel by extension and context.

  • exten the extension to search for
  • context the context to search for (optional)

Return a channel that is currently at the specified extension and context.

Return values
achannel that is at the specified extension and context
NULLif no channel was found
Since
1.8

Definition at line 1813 of file channel.c.

References ast_channel_get_full().

1814 {
1815  return ast_channel_get_full(NULL, 0, exten, context);
1816 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
struct ast_channel* ast_channel_get_by_name ( const char *  name)

Find a channel by name.

Channel search functions

  • name the name or uniqueid of the channel to search for

Find a channel that has the same name as the provided argument.

Return values
achannel with the name specified by the argument
NULLif no channel was found
Since
1.8

Definition at line 1803 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().

1804 {
1805  return ast_channel_get_full(name, 0, NULL, NULL);
1806 }
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static const char name[]
struct ast_channel* ast_channel_get_by_name_prefix ( const char *  name,
size_t  name_len 
)

Find a channel by a name prefix.

  • name The channel name or uniqueid prefix to search for
  • name_len Only search for up to this many characters from the name

Find a channel that has the same name prefix as specified by the arguments.

Return values
achannel with the name prefix specified by the arguments
NULLif no channel was found
Since
1.8

Definition at line 1808 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().

1809 {
1810  return ast_channel_get_full(name, name_len, NULL, NULL);
1811 }
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static const char name[]
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.

Since
1.8

During call completion, we will need to create a call completion agent structure. To figure out the type of agent to construct, we need to ask the channel driver for the appropriate type.

Prior to adding this function, the call completion core attempted to figure this out for itself by stripping the technology off the channel's name. However, in the case of chan_dahdi, there are multiple agent types registered, and so simply searching for an agent type called "DAHDI" is not possible. In a case where multiple agent types are defined, the channel driver must have a queryoption callback defined in its channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE

If a channel driver does not have a queryoption callback or if the queryoption callback does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology portion of the channel name is used instead. This is perfectly suitable for channel drivers whose channel technologies are a one-to-one match with the agent types defined within.

Note that this function is only called when the agent policy on a given channel is set to "native." Generic agents' type can be determined automatically by the core.

Parameters
chanThe channel for which we wish to retrieve the agent type
[out]agent_typeThe type of agent the channel driver wants us to use
sizeThe size of the buffer to write to

Definition at line 9793 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().

9794 {
9795  int len = size;
9796  char *slash;
9797 
9798  if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) {
9799  return 0;
9800  }
9801 
9802  ast_copy_string(agent_type, chan->name, size);
9803  if ((slash = strchr(agent_type, '/'))) {
9804  *slash = '\0';
9805  }
9806  return 0;
9807 }
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const ast_string_field name
Definition: channel.h:787
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_OPTION_CC_AGENT_TYPE
Definition: frame.h:520
struct ast_cc_config_params* ast_channel_get_cc_config_params ( struct ast_channel chan)

Get the CCSS parameters from a channel.

Since
1.8

This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function.

Parameters
chanChannel to retrieve parameters from
Return values
NULLFailure
non-NULLThe parameters desired

Definition at line 9754 of file channel.c.

References ast_assert, ast_channel_cc_params_init(), ast_channel_datastore_find(), and ast_datastore::data.

Referenced by acf_cc_read(), acf_cc_write(), analog_call(), ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), cc_agent_init(), cc_core_init_instance(), find_agent_callbacks(), local_call(), local_request(), sig_pri_cc_available(), and sig_pri_cc_generic_check().

9755 {
9756  struct ast_datastore *cc_datastore;
9757 
9758  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
9759  /* If we can't find the datastore, it almost definitely means that the channel type being
9760  * used has not had its driver modified to parse CC config parameters. The best action
9761  * to take here is to create the parameters on the spot with the defaults set.
9762  */
9763  if (ast_channel_cc_params_init(chan, NULL)) {
9764  return NULL;
9765  }
9766  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
9767  /* Should be impossible */
9768  return NULL;
9769  }
9770  }
9771 
9772  ast_assert(cc_datastore->data != NULL);
9773  return cc_datastore->data;
9774 }
#define ast_assert(a)
Definition: utils.h:738
Structure for a data store object.
Definition: datastore.h:54
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.
Definition: channel.c:2604
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.
Definition: channel.c:9731
void * data
Definition: datastore.h:56
static struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:9725
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.

Since
1.8

A common practice in Asterisk is to determine the device being talked to by dissecting the channel name. For certain channel types, this is not accurate. For instance, an ISDN channel is named based on what B channel is used, not the device being communicated with.

This function interfaces with a channel tech's queryoption callback to retrieve the name of the device being communicated with. If the channel does not implement this specific option, then the traditional method of using the channel name is used instead.

Parameters
chanThe channel to retrieve the information from
[out]device_nameThe buffer to place the device's name into
name_buffer_lengthThe allocated space for the device_name
Returns
0 always

Definition at line 9776 of file channel.c.

References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_DEVICE_NAME, and ast_channel::name.

Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), cc_core_init_instance(), cccancel_exec(), ccreq_exec(), dial_exec_full(), sig_pri_call(), sig_pri_cc_available(), sig_pri_cc_generic_check(), sip_call(), and sip_handle_cc().

9777 {
9778  int len = name_buffer_length;
9779  char *dash;
9780  if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
9781  return 0;
9782  }
9783 
9784  /* Dang. Do it the old-fashioned way */
9785  ast_copy_string(device_name, chan->name, name_buffer_length);
9786  if ((dash = strrchr(device_name, '-'))) {
9787  *dash = '\0';
9788  }
9789 
9790  return 0;
9791 }
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
#define AST_OPTION_DEVICE_NAME
Definition: frame.h:516
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const ast_string_field name
Definition: channel.h:787
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static enum ast_t38_state ast_channel_get_t38_state ( struct ast_channel chan)
inlinestatic

Retrieves the current T38 state of a channel.

Definition at line 2417 of file channel.h.

References ast_channel_queryoption(), AST_OPTION_T38_STATE, 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().

2418 {
2420  int datalen = sizeof(state);
2421 
2422  ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2423 
2424  return state;
2425 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
ast_t38_state
Possible T38 states on channels.
Definition: channel.h:669
#define AST_OPTION_T38_STATE
Definition: frame.h:490
void ast_channel_inherit_variables ( const struct ast_channel parent,
struct ast_channel child 
)

Inherits channel variable from parent to child channel.

Parameters
parentParent channel
childChild channel

Scans all channel variables in the parent channel, looking for those that should be copied into the child channel. Variables whose names begin with a single '_' are copied into the child channel with the prefix removed. Variables whose names begin with '__' are copied into the child channel with their names unchanged.

Definition at line 6241 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, ast_channel::name, and ast_channel::varshead.

Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), ring_entry(), and wait_for_answer().

6242 {
6243  struct ast_var_t *current, *newvar;
6244  const char *varname;
6245 
6246  AST_LIST_TRAVERSE(&parent->varshead, current, entries) {
6247  int vartype = 0;
6248 
6249  varname = ast_var_full_name(current);
6250  if (!varname)
6251  continue;
6252 
6253  if (varname[0] == '_') {
6254  vartype = 1;
6255  if (varname[1] == '_')
6256  vartype = 2;
6257  }
6258 
6259  switch (vartype) {
6260  case 1:
6261  newvar = ast_var_assign(&varname[1], ast_var_value(current));
6262  if (newvar) {
6263  AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
6264  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6265  ast_var_name(newvar), parent->name, child->name);
6266  }
6267  break;
6268  case 2:
6269  newvar = ast_var_assign(varname, ast_var_value(current));
6270  if (newvar) {
6271  AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
6272  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6273  ast_var_name(newvar), parent->name, child->name);
6274  }
6275  break;
6276  default:
6277  break;
6278  }
6279  }
6280 }
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:89
struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: chanvars.c:41
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:69
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
const ast_string_field name
Definition: channel.h:787
const char * ast_var_full_name(const struct ast_var_t *var)
Definition: chanvars.c:84
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@158 entries
struct varshead varshead
Definition: channel.h:817
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.

Return values
NULLon failure
anew channel iterator
Since
1.8

Definition at line 1701 of file channel.c.

References ast_channel_iterator::active_iterator, ao2_iterator_init(), ast_calloc, channels, and ast_channel_iterator::simple_iterator.

Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), and handle_softhangup().

1702 {
1703  struct ast_channel_iterator *i;
1704 
1705  if (!(i = ast_calloc(1, sizeof(*i)))) {
1706  return NULL;
1707  }
1708 
1711 
1712  return i;
1713 }
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
Definition: astobj2.c:818
struct ao2_iterator simple_iterator
Definition: channel.c:1642
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
struct ao2_iterator * active_iterator
Definition: channel.c:1646
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_channel_iterator* ast_channel_iterator_by_exten_new ( const char *  exten,
const char *  context 
)

Create a new channel iterator based on extension.

  • exten The extension that channels must be in
  • context The context that channels must be in (optional)

After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that are currently in the specified context and extension.

Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1691 of file channel.c.

References channel_iterator_search().

Referenced by common_exec(), and pickup_by_exten().

1692 {
1693  return channel_iterator_search(NULL, 0, exten, context);
1694 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
static struct ast_channel_iterator * channel_iterator_search(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1657
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
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.

  • name channel name or channel uniqueid to match
  • name_len number of characters in the channel name to match on. This would be used to match based on name prefix. If matching on the full channel name is desired, then this parameter should be 0.

After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that exist that have the specified name or name prefix.

Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1696 of file channel.c.

References channel_iterator_search().

Referenced by ast_complete_channels(), common_exec(), and softhangup_exec().

1697 {
1698  return channel_iterator_search(name, name_len, NULL, NULL);
1699 }
static const char name[]
static struct ast_channel_iterator * channel_iterator_search(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1657
struct ast_channel_iterator* ast_channel_iterator_destroy ( struct ast_channel_iterator i)

Destroy a channel iterator.

  • i the itereator to destroy

This function is used to destroy a channel iterator that was retrieved by using one of the channel_iterator_new() functions.

Returns
NULL, for convenience to clear out the pointer to the iterator that was just destroyed.
Since
1.8

Definition at line 1649 of file channel.c.

References ast_channel_iterator::active_iterator, ao2_iterator_destroy(), and ast_free.

Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), pickup_by_exten(), and softhangup_exec().

1650 {
1652  ast_free(i);
1653 
1654  return NULL;
1655 }
#define ast_free(a)
Definition: astmm.h:97
struct ao2_iterator * active_iterator
Definition: channel.c:1646
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
Definition: astobj2.c:833
struct ast_channel* ast_channel_iterator_next ( struct ast_channel_iterator i)

Get the next channel for a channel iterator.

  • i the channel iterator that was created using one of the channel_iterator_new() functions.

This function should be used to iterate through all channels that match a specified set of parameters that were provided when the iterator was created.

Return values
thenext channel that matches the parameters used when the iterator was created.
NULL,ifno more channels match the iterator parameters.
Since
1.8

Definition at line 1715 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().

1716 {
1718 }
#define ao2_iterator_next(arg1)
Definition: astobj2.h:1126
struct ao2_iterator * active_iterator
Definition: channel.c:1646
int ast_channel_make_compatible ( struct ast_channel c0,
struct ast_channel c1 
)

Makes two channel formats compatible.

Parameters
c0first channel to make compatible
c1other channel to make compatible

Set two channels to compatible formats – call before ast_channel_bridge in general.

Returns
Returns 0 on success and -1 if it could not be done

Definition at line 5970 of file channel.c.

References ast_channel_make_compatible_helper().

Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), multiplexed_bridge_join(), parked_call_exec(), simple_bridge_join(), try_calling(), and wait_for_answer().

5971 {
5972  /* Some callers do not check return code, and we must try to set all call legs correctly */
5973  int rc = 0;
5974 
5975  /* Set up translation from the chan to the peer */
5976  rc = ast_channel_make_compatible_helper(chan, peer);
5977 
5978  if (rc < 0)
5979  return rc;
5980 
5981  /* Set up translation from the peer to the chan */
5982  rc = ast_channel_make_compatible_helper(peer, chan);
5983 
5984  return rc;
5985 }
static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
Set up translation from one channel to another.
Definition: channel.c:5920
int ast_channel_masquerade ( struct ast_channel original,
struct ast_channel clone 
)

Weird function made for call transfers.

Parameters
originalchannel to make a copy of
clonecopy of the original channel

This is a very strange and freaky function used primarily for transfer. Suppose that "original" and "clone" are two channels in random situations. This function takes the guts out of "clone" and puts them into the "original" channel, then alerts the channel driver of the change, asking it to fixup any private information (like the p->owner pointer) that is affected by the change. The physical layer of the original channel is hung up.

Note
Neither channel passed here should be locked before calling this function. This function performs deadlock avoidance involving these two channels.

Definition at line 6110 of file channel.c.

References __ast_channel_masquerade().

Referenced by ast_async_goto(), ast_do_pickup(), attempt_transfer(), builtin_atxfer(), check_availability(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), masq_park_call(), sip_park(), and skinny_transfer().

6111 {
6112  return __ast_channel_masquerade(original, clone, NULL);
6113 }
static int __ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
Definition: channel.c:5987
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 7815 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::queryoption, and ast_channel::tech.

Referenced by ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_get_t38_state(), local_queryoption(), rcvfax_exec(), and sndfax_exec().

7816 {
7817  int res;
7818 
7819  ast_channel_lock(chan);
7820  if (!chan->tech->queryoption) {
7821  errno = ENOSYS;
7822  ast_channel_unlock(chan);
7823  return -1;
7824  }
7825 
7826  if (block)
7827  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7828 
7829  res = chan->tech->queryoption(chan, option, data, datalen);
7830  ast_channel_unlock(chan);
7831 
7832  return res;
7833 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
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.

Since
1.8
Parameters
chanAsterisk channel to indicate connected line information
connectedConnected line information
updateWhat connected line information to update. NULL if all.
Returns
Nothing

Definition at line 9098 of file channel.c.

References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_queue_control_data().

Referenced by ast_do_pickup(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), masquerade_colp_transfer(), misdn_queue_connected_line_update(), sig_pri_handle_subcmds(), and sip_call().

9099 {
9100  unsigned char data[1024]; /* This should be large enough */
9101  size_t datalen;
9102 
9103  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9104  if (datalen == (size_t) -1) {
9105  return;
9106  }
9107 
9108  ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9109 }
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.
Definition: channel.c:8825
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.
Definition: channel.c:1608
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.

Since
1.8
Parameters
chanAsterisk channel to indicate redirecting id information
redirectingRedirecting id information
updateWhat redirecting information to update. NULL if all.
Returns
Nothing

Definition at line 9605 of file channel.c.

References AST_CONTROL_REDIRECTING, ast_queue_control_data(), and ast_redirecting_build_data().

Referenced by cb_events(), handle_response_invite(), misdn_facility_ie_handler(), and sig_pri_handle_subcmds().

9606 {
9607  unsigned char data[1024]; /* This should be large enough */
9608  size_t datalen;
9609 
9610  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
9611  if (datalen == (size_t) -1) {
9612  return;
9613  }
9614 
9615  ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
9616 }
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.
Definition: channel.c:1608
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.
Definition: channel.c:9161
const char* ast_channel_reason2str ( int  reason)

return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument

Parameters
reasonThe integer argument, usually taken from AST_CONTROL_ macros
Returns
char pointer explaining the code

Definition at line 5313 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().

5314 {
5315  switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5316  {
5317  case 0:
5318  return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5319  case AST_CONTROL_HANGUP:
5320  return "Hangup";
5321  case AST_CONTROL_RING:
5322  return "Local Ring";
5323  case AST_CONTROL_RINGING:
5324  return "Remote end Ringing";
5325  case AST_CONTROL_ANSWER:
5326  return "Remote end has Answered";
5327  case AST_CONTROL_BUSY:
5328  return "Remote end is Busy";
5330  return "Congestion (circuits busy)";
5331  default:
5332  return "Unknown Reason!!";
5333  }
5334 }
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.

Since
1.8

Whenever we want to update a channel's redirecting information, we may need to run a macro so that an administrator can manipulate the information before sending it out. This function both runs the macro and sends the update to the channel.

Parameters
autoservice_chanChannel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL
macro_chanThe channel to run the macro on. Also the channel from which we determine which macro we need to run.
redirecting_infoEither an ast_party_redirecting or ast_frame pointer of type AST_CONTROL_REDIRECTING
is_callerIf true, then run REDIRECTING_CALLER_SEND_MACRO, otherwise run REDIRECTING_CALLEE_SEND_MACRO
is_frameIf true, then redirecting_info is an ast_frame pointer, otherwise it is an ast_party_redirecting pointer.
Return values
0Success
-1Either the macro does not exist, or there was an error while attempting to run the macro
Todo:

Have multiple return codes based on the MACRO_RESULT

Make constants so that caller and frame can be more expressive than just '1' and '0'

Definition at line 9663 of file channel.c.

References ast_app_run_macro(), ast_channel_lock, ast_channel_unlock, ast_channel_update_redirecting(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_redirecting_parse_data(), ast_strdupa, ast_strlen_zero(), ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, ast_channel::redirecting, and S_OR.

Referenced by ast_bridge_call(), ast_generic_bridge(), call_forward_inherit(), do_forward(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().

9664 {
9665  const char *macro;
9666  const char *macro_args;
9667  int retval;
9668 
9669  ast_channel_lock(macro_chan);
9670  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
9671  ? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO");
9672  macro = ast_strdupa(S_OR(macro, ""));
9673  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
9674  ? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS");
9675  macro_args = ast_strdupa(S_OR(macro_args, ""));
9676 
9677  if (ast_strlen_zero(macro)) {
9678  ast_channel_unlock(macro_chan);
9679  return -1;
9680  }
9681 
9682  if (is_frame) {
9683  const struct ast_frame *frame = redirecting_info;
9684 
9685  ast_redirecting_parse_data(frame->data.ptr, frame->datalen, &macro_chan->redirecting);
9686  } else {
9687  const struct ast_party_redirecting *redirecting = redirecting_info;
9688 
9689  ast_party_redirecting_copy(&macro_chan->redirecting, redirecting);
9690  }
9691  ast_channel_unlock(macro_chan);
9692 
9693  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
9694  if (!retval) {
9695  struct ast_party_redirecting saved_redirecting;
9696 
9697  ast_party_redirecting_init(&saved_redirecting);
9698  ast_channel_lock(macro_chan);
9699  ast_party_redirecting_copy(&saved_redirecting, &macro_chan->redirecting);
9700  ast_channel_unlock(macro_chan);
9701  ast_channel_update_redirecting(macro_chan, &saved_redirecting, NULL);
9702  ast_party_redirecting_free(&saved_redirecting);
9703  }
9704 
9705  return retval;
9706 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
Parse redirecting indication frame data.
Definition: channel.c:9254
void * ptr
Definition: frame.h:160
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.
Definition: channel.c:9592
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int datalen
Definition: frame.h:148
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: app.c:294
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2359
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
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.
Definition: channel.c:2367
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.

Parameters
techStructure defining channel technology or "type"
Returns
Returns 0 on success, -1 on failure.

Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.

Definition at line 907 of file channel.c.

References ast_calloc, ast_debug, ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, ast_channel_tech::description, LOG_WARNING, chanlist::tech, and ast_channel_tech::type.

Referenced by load_module(), and unload_module().

908 {
909  struct chanlist *chan;
910 
912 
914  if (!strcasecmp(tech->type, chan->tech->type)) {
915  ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type);
917  return -1;
918  }
919  }
920 
921  if (!(chan = ast_calloc(1, sizeof(*chan)))) {
923  return -1;
924  }
925  chan->tech = tech;
927 
928  ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
929 
930  ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
931 
933 
934  return 0;
935 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:144
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:243
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:703
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char *const description
Definition: channel.h:509
#define ast_calloc(a, b)
Definition: astmm.h:82
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.

Returns
NULL, convenient for clearing invalid pointers
Note
Absolutely NO channel locks should be held before calling this function.
Since
1.8

Definition at line 1921 of file channel.c.

References ao2_unlink, ast_channel_unref, and channels.

Referenced by agent_cleanup(), ast_iax2_new(), ast_request(), bridge_request(), do_notify(), gtalk_newcall(), local_new(), and local_request().

1922 {
1923  /* Safe, even if already unlinked. */
1924  ao2_unlink(channels, chan);
1925  return ast_channel_unref(chan);
1926 }
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
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.

Returns
0 on success or -1 on failure

Definition at line 5907 of file channel.c.

References ast_channel_tech::send_html, and ast_channel::tech.

Referenced by agent_sendhtml(), ast_channel_sendurl(), and wait_for_answer().

5908 {
5909  if (chan->tech->send_html)
5910  return chan->tech->send_html(chan, subclass, data, datalen);
5911  return -1;
5912 }
struct ast_channel * chan
Definition: app_dial.c:666
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_channel_sendurl ( struct ast_channel channel,
const char *  url 
)

Sends a URL on a given link Send URL on link.

Returns
0 on success or -1 on failure

Definition at line 5914 of file channel.c.

References ast_channel_sendhtml(), and AST_HTML_URL.

Referenced by dial_exec_full(), sendurl_exec(), and try_calling().

5915 {
5916  return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
5917 }
#define AST_HTML_URL
Definition: frame.h:222
struct ast_channel * chan
Definition: app_dial.c:666
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: channel.c:5907
static char url[512]
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.

Since
1.8
Parameters
chanAsterisk channel to set caller id information
callerCaller id information
updateWhat caller information to update. NULL if all.
Returns
Nothing
Note
The channel does not need to be locked before calling this function.

Definition at line 7079 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), and ast_channel::caller.

7080 {
7081  if (&chan->caller == caller) {
7082  /* Don't set to self */
7083  return;
7084  }
7085 
7086  ast_channel_lock(chan);
7087  ast_party_caller_set(&chan->caller, caller, update);
7088  ast_channel_unlock(chan);
7089 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
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.
Definition: channel.c:2295
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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.

Since
1.8
Parameters
chanAsterisk channel to set caller id information
callerCaller id information
updateWhat caller information to update. NULL if all.
Returns
Nothing
Note
The channel does not need to be locked before calling this function.

Definition at line 7091 of file channel.c.

References ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), S_COR, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.

Referenced by callerid_write(), dial_exec_full(), do_forward(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().

7092 {
7093  const char *pre_set_number;
7094  const char *pre_set_name;
7095 
7096  if (&chan->caller == caller) {
7097  /* Don't set to self */
7098  return;
7099  }
7100 
7101  ast_channel_lock(chan);
7102  pre_set_number =
7103  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
7104  pre_set_name = S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL);
7105  ast_party_caller_set(&chan->caller, caller, update);
7106  if (S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)
7107  != pre_set_number
7108  || S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL)
7109  != pre_set_name) {
7110  /* The caller id name or number changed. */
7111  report_new_callerid(chan);
7112  }
7113  if (chan->cdr) {
7114  ast_cdr_setcid(chan->cdr, chan);
7115  }
7116  ast_channel_unlock(chan);
7117 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
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.
Definition: channel.c:2295
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_cdr * cdr
Definition: channel.h:766
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:883
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
#define ast_channel_unlock(chan)
Definition: channel.h:2467
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Since
1.8
Parameters
chanAsterisk channel to set connected line information
connectedConnected line information
updateWhat connected line information to update. NULL if all.
Returns
Nothing
Note
The channel does not need to be locked before calling this function.

Definition at line 8458 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_connected_line_set(), and ast_channel::connected.

Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), and feature_request_and_dial().

8459 {
8460  if (&chan->connected == connected) {
8461  /* Don't set to self */
8462  return;
8463  }
8464 
8465  ast_channel_lock(chan);
8466  ast_party_connected_line_set(&chan->connected, connected, update);
8467  ast_channel_unlock(chan);
8468 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
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.
Definition: channel.c:2337
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_channel_set_fd ( struct ast_channel chan,
int  which,
int  fd 
)

Set the file descriptor on the channel

Definition at line 2631 of file channel.c.

References ast_calloc, ast_epoll_data::chan, chanlist::chan, ast_channel::fds, free, and ast_epoll_data::which.

Referenced by __ast_channel_alloc_ap(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), alsa_new(), ast_do_masquerade(), dahdi_new(), deactivate_generator_nolock(), gtalk_new(), initialize_udptl(), jingle_new(), mgcp_new(), misdn_new(), my_swap_subchannels(), nbs_new(), oss_new(), phone_new(), process_sdp(), setformat(), sip_new(), sip_set_rtp_peer(), skinny_new(), start_rtp(), and swap_subs().

2632 {
2633 #ifdef HAVE_EPOLL
2634  struct epoll_event ev;
2635  struct ast_epoll_data *aed = NULL;
2636 
2637  if (chan->fds[which] > -1) {
2638  epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev);
2639  aed = chan->epfd_data[which];
2640  }
2641 
2642  /* If this new fd is valid, add it to the epoll */
2643  if (fd > -1) {
2644  if (!aed && (!(aed = ast_calloc(1, sizeof(*aed)))))
2645  return;
2646 
2647  chan->epfd_data[which] = aed;
2648  aed->chan = chan;
2649  aed->which = which;
2650 
2651  ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
2652  ev.data.ptr = aed;
2653  epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev);
2654  } else if (aed) {
2655  /* We don't have to keep around this epoll data structure now */
2656  free(aed);
2657  chan->epfd_data[which] = NULL;
2658  }
2659 #endif
2660  chan->fds[which] = fd;
2661  return;
2662 }
struct ast_channel * chan
Definition: channel.c:88
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define free(a)
Definition: astmm.h:94
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_channel_set_linkgroup ( struct ast_channel chan,
struct ast_channel peer 
)

propagate the linked id between chan and peer

propagate the linked id between chan and peer

Definition at line 6387 of file channel.c.

References ast_channel::_bridge, ast_bridged_channel(), ast_channel_change_linkedid(), ast_strdupa, ast_channel::linkedid, oldest_linkedid(), and ast_channel::uniqueid.

Referenced by ast_bridge_call(), and ast_do_masquerade().

6388 {
6389  const char* linkedid=NULL;
6390  struct ast_channel *bridged;
6391 
6392  linkedid = oldest_linkedid(chan->linkedid, peer->linkedid);
6393  linkedid = oldest_linkedid(linkedid, chan->uniqueid);
6394  linkedid = oldest_linkedid(linkedid, peer->uniqueid);
6395  if (chan->_bridge) {
6396  bridged = ast_bridged_channel(chan);
6397  if (bridged && bridged != peer) {
6398  linkedid = oldest_linkedid(linkedid, bridged->linkedid);
6399  linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
6400  }
6401  }
6402  if (peer->_bridge) {
6403  bridged = ast_bridged_channel(peer);
6404  if (bridged && bridged != chan) {
6405  linkedid = oldest_linkedid(linkedid, bridged->linkedid);
6406  linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
6407  }
6408  }
6409 
6410  /* just in case setting a stringfield to itself causes problems */
6411  linkedid = ast_strdupa(linkedid);
6412 
6413  ast_channel_change_linkedid(chan, linkedid);
6414  ast_channel_change_linkedid(peer, linkedid);
6415  if (chan->_bridge) {
6416  bridged = ast_bridged_channel(chan);
6417  if (bridged && bridged != peer) {
6418  ast_channel_change_linkedid(bridged, linkedid);
6419  }
6420  }
6421  if (peer->_bridge) {
6422  bridged = ast_bridged_channel(peer);
6423  if (bridged && bridged != chan) {
6424  ast_channel_change_linkedid(bridged, linkedid);
6425  }
6426  }
6427 }
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field uniqueid
Definition: channel.h:787
const ast_string_field linkedid
Definition: channel.h:787
static const char * oldest_linkedid(const char *a, const char *b)
Definition: channel.c:6320
struct ast_channel * _bridge
Definition: channel.h:748
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
static void ast_channel_change_linkedid(struct ast_channel *chan, const char *linkedid)
Definition: channel.c:6370
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.

Since
1.8
Parameters
chanAsterisk channel to set redirecting id information
redirectingRedirecting id information
updateWhat redirecting information to update. NULL if all.
Returns
Nothing
Note
The channel does not need to be locked before calling this function.

Definition at line 9111 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_redirecting_set(), and ast_channel::redirecting.

Referenced by ast_indicate_data(), handle_request_invite(), handle_response(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_handle_subcmds().

9112 {
9113  if (&chan->redirecting == redirecting) {
9114  /* Don't set to self */
9115  return;
9116  }
9117 
9118  ast_channel_lock(chan);
9119  ast_party_redirecting_set(&chan->redirecting, redirecting, update);
9120  ast_channel_unlock(chan);
9121 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
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.
Definition: channel.c:2388
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_channel_setoption ( struct ast_channel channel,
int  option,
void *  data,
int  datalen,
int  block 
)

Sets an option on a channel.

Parameters
channelchannel to set options on
optionoption to change
datadata specific to option
datalenlength of the data
blockblocking or not

Set an option on a channel (see frame.h), optionally blocking awaiting the reply

Returns
0 on success and -1 on failure

Definition at line 7795 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.

Referenced by analog_hangup(), ast_bridge_call(), ast_channel_make_compatible_helper(), common_exec(), conf_run(), dahdi_hangup(), dial_exec_full(), func_channel_write(), func_channel_write_real(), handle_tddmode(), play_record_review(), rcvfax_exec(), reset_volumes(), set_format(), set_listen_volume(), set_security_requirements(), set_talk_volume(), sndfax_exec(), try_calling(), and vm_forwardoptions().

7796 {
7797  int res;
7798 
7799  ast_channel_lock(chan);
7800  if (!chan->tech->setoption) {
7801  errno = ENOSYS;
7802  ast_channel_unlock(chan);
7803  return -1;
7804  }
7805 
7806  if (block)
7807  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7808 
7809  res = chan->tech->setoption(chan, option, data, datalen);
7810  ast_channel_unlock(chan);
7811 
7812  return res;
7813 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
const char * data
Definition: channel.h:755
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
void ast_channel_setwhentohangup ( struct ast_channel chan,
time_t  offset 
)

Set when to hang a channel up.

Parameters
chanchannel on which to check for hang up
offsetoffset in seconds relative to the current time of when to hang up

This function sets the absolute time out on a channel (when to hang up).

Note
This function does not require that the channel is locked before calling it.
Returns
Nothing
See Also
ast_channel_setwhentohangup_tv()
Version
1.6.1 deprecated function (only had seconds precision)

Definition at line 878 of file channel.c.

References ast_channel_setwhentohangup_tv().

879 {
880  struct timeval when = { offset, };
881  ast_channel_setwhentohangup_tv(chan, when);
882 }
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition: channel.c:871
void ast_channel_setwhentohangup_tv ( struct ast_channel chan,
struct timeval  offset 
)

Set when to hang a channel up.

Parameters
chanchannel on which to check for hang up
offsetoffset in seconds and useconds relative to the current time of when to hang up

This function sets the absolute time out on a channel (when to hang up).

Note
This function does not require that the channel is locked before calling it.
Returns
Nothing
Since
1.6.1

Set when to hang a channel up.

Definition at line 871 of file channel.c.

References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.

Referenced by action_timeout(), ast_channel_setwhentohangup(), handle_autohangup(), sig_pri_send_aoce_termination_request(), and timeout_write().

872 {
873  chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow());
875  return;
876 }
struct ast_frame ast_null_frame
Definition: frame.c:131
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
struct timeval whentohangup
Definition: channel.h:789
struct ast_silence_generator* ast_channel_start_silence_generator ( struct ast_channel chan)

Starts a silence generator on the given channel.

Parameters
chanThe channel to generate silence on
Returns
An ast_silence_generator pointer, or NULL if an error occurs

This function will cause SLINEAR silence to be generated on the supplied channel until it is disabled; if the channel cannot be put into SLINEAR mode then the function will fail.

Note
The pointer returned by this function must be preserved and passed to ast_channel_stop_silence_generator when you wish to stop the silence generation.

Definition at line 8309 of file channel.c.

References ast_activate_generator(), ast_calloc, ast_debug, AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, state, and ast_channel::writeformat.

Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), record_exec(), TransferCallStep1(), waitfor_exec(), and waitforring_exec().

8310 {
8311  struct ast_silence_generator *state;
8312 
8313  if (!(state = ast_calloc(1, sizeof(*state)))) {
8314  return NULL;
8315  }
8316 
8317  state->old_write_format = chan->writeformat;
8318 
8319  if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
8320  ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8321  ast_free(state);
8322  return NULL;
8323  }
8324 
8326 
8327  ast_debug(1, "Started silence generator on '%s'\n", chan->name);
8328 
8329  return state;
8330 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
format_t writeformat
Definition: channel.h:854
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:3148
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 &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static struct ast_generator silence_generator
Definition: channel.c:8299
#define LOG_ERROR
Definition: logger.h:155
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define ast_calloc(a, b)
Definition: astmm.h:82
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.

Parameters
chanThe channel to operate on
stateThe ast_silence_generator pointer return by a previous call to ast_channel_start_silence_generator.
Returns
nothing

This function will stop the operating silence generator and return the channel to its previous write format.

Definition at line 8355 of file channel.c.

References ast_debug, ast_free, ast_log(), ast_set_write_format(), deactivate_silence_generator(), LOG_ERROR, ast_channel::name, and ast_silence_generator::old_write_format.

Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), HandleCallOutgoing(), key_dial_page(), record_exec(), unistim_hangup(), waitfor_exec(), and waitforring_exec().

8356 {
8357  if (!state) {
8358  return;
8359  }
8360 
8361  if (deactivate_silence_generator(chan)) {
8362  ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
8363 
8364  if (ast_set_write_format(chan, state->old_write_format) < 0)
8365  ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8366  }
8367  ast_free(state);
8368 }
static int deactivate_silence_generator(struct ast_channel *chan)
Definition: channel.c:8332
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 &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define LOG_ERROR
Definition: logger.h:155
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
int ast_channel_supports_html ( struct ast_channel channel)

Checks for HTML support on a channel.

Returns
0 if channel does not support HTML or non-zero if it does

Definition at line 5902 of file channel.c.

References ast_channel_tech::send_html, and ast_channel::tech.

Referenced by dial_exec_full(), sendurl_exec(), and try_calling().

5903 {
5904  return (chan->tech->send_html) ? 1 : 0;
5905 }
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.

Since
1.8
Parameters
target_chanTarget of the call transfer. (Masquerade original channel)
target_idNew connected line information for the target channel.
target_heldTRUE if the target call is on hold.
transferee_chanTransferee of the call transfer. (Masquerade clone channel)
transferee_idNew connected line information for the transferee channel.
transferee_heldTRUE if the transferee call is on hold.

Party A - Transferee Party B - Transferer Party C - Target of transfer

Party B transfers A to C.

Party A is connected to bridged channel B1. Party B is connected to channels C1 and C2. Party C is connected to bridged channel B2.

Party B – C1 == B1 – Party A __/ / Party B – C2 == B2 – Party C

Bridged channel B1 is masqueraded into channel C2. Where B1 is the masquerade clone channel and C2 is the masquerade original channel.

See Also
ast_channel_masquerade()
Note
Has the same locking requirements as ast_channel_masquerade().
Return values
0on success.
-1on error.

Definition at line 6184 of file channel.c.

References __ast_channel_masquerade(), ast_calloc, ast_datastore_alloc(), ast_datastore_free(), ast_datastore::data, party_connected_line_copy_transfer(), xfer_masquerade_ds::target_held, xfer_masquerade_ds::target_id, xfer_masquerade_ds::transferee_held, and xfer_masquerade_ds::transferee_id.

Referenced by analog_attempt_transfer(), misdn_attempt_transfer(), and sig_pri_attempt_transfer().

6191 {
6192  struct ast_datastore *xfer_ds;
6193  struct xfer_masquerade_ds *xfer_colp;
6194  int res;
6195 
6196  xfer_ds = ast_datastore_alloc(&xfer_ds_info, NULL);
6197  if (!xfer_ds) {
6198  return -1;
6199  }
6200 
6201  xfer_colp = ast_calloc(1, sizeof(*xfer_colp));
6202  if (!xfer_colp) {
6203  ast_datastore_free(xfer_ds);
6204  return -1;
6205  }
6206  party_connected_line_copy_transfer(&xfer_colp->target_id, target_id);
6207  xfer_colp->target_held = target_held;
6208  party_connected_line_copy_transfer(&xfer_colp->transferee_id, transferee_id);
6209  xfer_colp->transferee_held = transferee_held;
6210  xfer_ds->data = xfer_colp;
6211 
6212  res = __ast_channel_masquerade(target_chan, transferee_chan, xfer_ds);
6213  if (res) {
6214  ast_datastore_free(xfer_ds);
6215  }
6216  return res;
6217 }
Structure for a data store object.
Definition: datastore.h:54
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
static void party_connected_line_copy_transfer(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Definition: channel.c:6125
struct ast_party_connected_line transferee_id
Definition: channel.c:6154
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
static int __ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
Definition: channel.c:5987
void * data
Definition: datastore.h:56
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_party_connected_line target_id
Definition: channel.c:6152
static struct ast_datastore_info xfer_ds_info
Definition: channel.c:6179
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 1628 of file channel.c.

References ast_clear_flag, and AST_FLAG_DEFER_DTMF.

Referenced by __adsi_transmit_messages(), and find_cache().

1629 {
1630  if (chan)
1632 }
#define ast_clear_flag(p, flag)
Definition: utils.h:77
void ast_channel_unregister ( const struct ast_channel_tech tech)

Unregister a channel technology.

Parameters
techStructure defining channel technology or "type" that was previously registered
Returns
No return value.

Unregister a channel technology.

Definition at line 938 of file channel.c.

References ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, chanlist::tech, and ast_channel_tech::type.

Referenced by __unload_module(), load_module(), and unload_module().

939 {
940  struct chanlist *chan;
941 
942  ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
943 
945 
947  if (chan->tech == tech) {
949  ast_free(chan);
950  ast_verb(2, "Unregistered channel type '%s'\n", tech->type);
951  break;
952  }
953  }
955 
957 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
#define ast_verb(level,...)
Definition: logger.h:243
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
List of channel drivers.
Definition: app_dial.c:664
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:542
#define ast_free(a)
Definition: astmm.h:97
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.

Since
1.8
Parameters
chanAsterisk channel to indicate connected line information
connectedConnected line information
updateWhat connected line information to update. NULL if all.
Returns
Nothing

Definition at line 9085 of file channel.c.

References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_indicate_data().

Referenced by app_exec(), ast_channel_connected_line_macro(), ast_do_pickup(), atxfer_fail_cleanup(), builtin_atxfer(), connectedline_write(), parked_call_exec(), and wait_for_answer().

9086 {
9087  unsigned char data[1024]; /* This should be large enough */
9088  size_t datalen;
9089 
9090  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9091  if (datalen == (size_t) -1) {
9092  return;
9093  }
9094 
9095  ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9096 }
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.
Definition: channel.c:8825
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4447
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.

Since
1.8
Parameters
chanAsterisk channel to indicate redirecting id information
redirectingRedirecting id information
updateWhat redirecting information to update. NULL if all.
Returns
Nothing

Definition at line 9592 of file channel.c.

References AST_CONTROL_REDIRECTING, ast_indicate_data(), and ast_redirecting_build_data().

Referenced by ast_channel_redirecting_macro(), call_forward_inherit(), do_forward(), redirecting_write(), and wait_for_answer().

9593 {
9594  unsigned char data[1024]; /* This should be large enough */
9595  size_t datalen;
9596 
9597  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
9598  if (datalen == (size_t) -1) {
9599  return;
9600  }
9601 
9602  ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
9603 }
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4447
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.
Definition: channel.c:9161
struct ast_variable* ast_channeltype_list ( void  )

return an ast_variable list of channeltypes

Definition at line 261 of file channel.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new(), ast_channel_tech::description, chanlist::tech, ast_channel_tech::type, and var.

Referenced by ast_var_channel_types(), and ast_var_channel_types_table().

262 {
263  struct chanlist *cl;
264  struct ast_variable *var = NULL, *prev = NULL;
265 
267  AST_RWLIST_TRAVERSE(&backends, cl, list) {
268  if (prev) {
269  if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, "")))
270  prev = prev->next;
271  } else {
272  var = ast_variable_new(cl->tech->type, cl->tech->description, "");
273  prev = var;
274  }
275  }
277 
278  return var;
279 }
const char *const type
Definition: channel.h:508
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
const char *const description
Definition: channel.h:509
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
Definition: config.c:278
int ast_check_hangup ( struct ast_channel chan)

Check to see if a channel is needing hang up.

Parameters
chanchannel on which to check for hang up This function determines if the channel is being requested to be hung up.
Returns
Returns 0 if not, or 1 if hang up is requested (including time-out).

Check to see if a channel is needing hang up.

Definition at line 806 of file channel.c.

References ast_channel::_softhangup, ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_channel::name, and ast_channel::whentohangup.

Referenced by __ast_pbx_run(), __ast_read(), _macro_exec(), agent_indicate(), agi_exec(), agi_handle_command(), announce_thread(), ast_bridge_call(), ast_call(), ast_channel_bridge(), ast_check_hangup_locked(), ast_indicate_data(), ast_raw_answer(), ast_readstring_full(), ast_recvtext(), ast_rtp_instance_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), autoservice_run(), bridge_call_thread(), bridge_exec(), builtin_atxfer(), call_forward_inherit(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), feature_request_and_dial(), findmeexec(), func_channel_read(), gosub_run(), handle_sendimage(), iax2_bridge(), launch_asyncagi(), local_bridge_loop(), local_fixup(), login_exec(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_builtin_waitexten(), pbx_exec(), read_exec(), readexten_exec(), remote_bridge_loop(), run_agi(), run_ras(), try_calling(), and wait_for_answer().

807 {
808  if (chan->_softhangup) /* yes if soft hangup flag set */
809  return 1;
810  if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */
811  return 0;
812  if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */
813  return 0;
814  ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow()));
815  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", chan->name);
816  chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */
817  return 1;
818 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
const ast_string_field name
Definition: channel.h:787
int _softhangup
Definition: channel.h:832
struct timeval whentohangup
Definition: channel.h:789
int ast_check_hangup_locked ( struct ast_channel chan)

Definition at line 820 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and ast_check_hangup().

Referenced by action_redirect(), and ast_channel_bridge().

821 {
822  int res;
823  ast_channel_lock(chan);
824  res = ast_check_hangup(chan);
825  ast_channel_unlock(chan);
826  return res;
827 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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.

Since
1.8
Parameters
dataBuffer to fill with the frame data
datalenSize of the buffer to fill
connectedConnected line information
updateWhat connected line information to build. NULL if all.
Return values
-1if error
Amountof data buffer used

Definition at line 8825 of file channel.c.

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log(), ast_party_connected_line::id, ast_set_party_connected_line::id, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_connected_line::source, ast_party_name_ies::str, and value.

Referenced by ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), local_attended_transfer(), local_indicate(), and masquerade_colp_transfer().

8826 {
8827  int32_t value;
8828  size_t pos = 0;
8829  int res;
8830 
8831  static const struct ast_party_id_ies ies = {
8833  .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8834  .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8835  .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8836 
8837  .number.str = AST_CONNECTED_LINE_NUMBER,
8838  .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8839  .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8840  .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8841 
8842  .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8843  .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8844  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8845  .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8846 
8847  .tag = AST_CONNECTED_LINE_TAG,
8848  .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8849  };
8850 
8851  /*
8852  * The size of integer values must be fixed in case the frame is
8853  * shipped to another machine.
8854  */
8855 
8856  /* Connected line frame version */
8857  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8858  ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8859  return -1;
8860  }
8861  data[pos++] = AST_CONNECTED_LINE_VERSION;
8862  data[pos++] = 1;
8863  data[pos++] = 2;/* Version 1 did not have a version ie */
8864 
8865  res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8866  "connected line", &ies, update ? &update->id : NULL);
8867  if (res < 0) {
8868  return -1;
8869  }
8870  pos += res;
8871 
8872  /* Connected line source */
8873  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8874  ast_log(LOG_WARNING, "No space left for connected line source\n");
8875  return -1;
8876  }
8877  data[pos++] = AST_CONNECTED_LINE_SOURCE;
8878  data[pos++] = sizeof(value);
8879  value = htonl(connected->source);
8880  memcpy(data + pos, &value, sizeof(value));
8881  pos += sizeof(value);
8882 
8883  return pos;
8884 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8696
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int source
Information about the source of an update.
Definition: channel.h:424
static int party_id_build_data(unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update)
Definition: channel.c:8722
struct ast_set_party_id id
Definition: channel.h:433
int str
Subscriber name ie.
Definition: channel.c:8473
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.

Since
1.8
Parameters
destDestination connected line information
srcSource caller information
Returns
Nothing
Note
Assumes locks are already acquired

Definition at line 8443 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 app_exec(), ast_do_pickup(), begin_dial_channel(), builtin_atxfer(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), local_call(), parked_call_exec(), ring_entry(), and wait_for_answer().

8444 {
8445  ast_party_id_copy(&dest->id, &src->id);
8446  ast_party_id_copy(&dest->ani, &src->ani);
8447  dest->ani2 = src->ani2;
8448 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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.
Definition: channel.c:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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.

Since
1.8
Parameters
destDestination caller information
srcSource connected line information
Returns
Nothing
Note
Assumes locks are already acquired

Definition at line 8450 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().

8451 {
8452  ast_party_id_copy(&dest->id, &src->id);
8453  ast_party_id_copy(&dest->ani, &src->ani);
8454 
8455  dest->ani2 = src->ani2;
8456 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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.
Definition: channel.c:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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.

Since
1.8
Parameters
dataBuffer with the frame data to parse
datalenSize of the buffer
connectedExtracted connected line information
Return values
0on success.
-1on error.
Note
The filled in connected line structure needs to be initialized by ast_party_connected_line_set_init() before calling. If defaults are not required use ast_party_connected_line_init().
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 8886 of file channel.c.

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_free, ast_log(), ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, ast_party_name::char_set, ast_party_id_ies::combined_presentation, ast_party_connected_line::id, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_connected_line::source, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.

Referenced by __ast_read(), ast_channel_connected_line_macro(), ast_indicate_data(), feature_request_and_dial(), socket_process(), wait_for_answer(), and wait_for_winner().

8887 {
8888  size_t pos;
8889  unsigned char ie_len;
8890  unsigned char ie_id;
8891  int32_t value;
8892  int frame_version = 1;
8893  int combined_presentation = 0;
8894  int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8895 
8896  for (pos = 0; pos < datalen; pos += ie_len) {
8897  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8898  ast_log(LOG_WARNING, "Invalid connected line update\n");
8899  return -1;
8900  }
8901  ie_id = data[pos++];
8902  ie_len = data[pos++];
8903  if (datalen < pos + ie_len) {
8904  ast_log(LOG_WARNING, "Invalid connected line update\n");
8905  return -1;
8906  }
8907 
8908  switch (ie_id) {
8909 /* Connected line party frame version */
8911  if (ie_len != 1) {
8912  ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8913  (unsigned) ie_len);
8914  break;
8915  }
8916  frame_version = data[pos];
8917  break;
8918 /* Connected line party id name */
8920  ast_free(connected->id.name.str);
8921  connected->id.name.str = ast_malloc(ie_len + 1);
8922  if (connected->id.name.str) {
8923  memcpy(connected->id.name.str, data + pos, ie_len);
8924  connected->id.name.str[ie_len] = 0;
8925  }
8926  break;
8928  if (ie_len != 1) {
8929  ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8930  (unsigned) ie_len);
8931  break;
8932  }
8933  connected->id.name.char_set = data[pos];
8934  break;
8936  if (ie_len != 1) {
8937  ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8938  (unsigned) ie_len);
8939  break;
8940  }
8941  connected->id.name.presentation = data[pos];
8942  break;
8944  if (ie_len != 1) {
8945  ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8946  (unsigned) ie_len);
8947  break;
8948  }
8949  connected->id.name.valid = data[pos];
8950  break;
8951 /* Connected line party id number */
8953  ast_free(connected->id.number.str);
8954  connected->id.number.str = ast_malloc(ie_len + 1);
8955  if (connected->id.number.str) {
8956  memcpy(connected->id.number.str, data + pos, ie_len);
8957  connected->id.number.str[ie_len] = 0;
8958  }
8959  break;
8961  if (ie_len != 1) {
8962  ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8963  (unsigned) ie_len);
8964  break;
8965  }
8966  connected->id.number.plan = data[pos];
8967  break;
8969  if (ie_len != 1) {
8970  ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8971  (unsigned) ie_len);
8972  break;
8973  }
8974  connected->id.number.presentation = data[pos];
8975  break;
8977  if (ie_len != 1) {
8978  ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8979  (unsigned) ie_len);
8980  break;
8981  }
8982  connected->id.number.valid = data[pos];
8983  break;
8984 /* Connected line party id combined presentation */
8986  if (ie_len != 1) {
8987  ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
8988  (unsigned) ie_len);
8989  break;
8990  }
8991  combined_presentation = data[pos];
8992  got_combined_presentation = 1;
8993  break;
8994 /* Connected line party id subaddress */
8996  ast_free(connected->id.subaddress.str);
8997  connected->id.subaddress.str = ast_malloc(ie_len + 1);
8998  if (connected->id.subaddress.str) {
8999  memcpy(connected->id.subaddress.str, data + pos, ie_len);
9000  connected->id.subaddress.str[ie_len] = 0;
9001  }
9002  break;
9004  if (ie_len != 1) {
9005  ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
9006  (unsigned) ie_len);
9007  break;
9008  }
9009  connected->id.subaddress.type = data[pos];
9010  break;
9012  if (ie_len != 1) {
9014  "Invalid connected line subaddress odd-even indicator (%u)\n",
9015  (unsigned) ie_len);
9016  break;
9017  }
9018  connected->id.subaddress.odd_even_indicator = data[pos];
9019  break;
9021  if (ie_len != 1) {
9022  ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
9023  (unsigned) ie_len);
9024  break;
9025  }
9026  connected->id.subaddress.valid = data[pos];
9027  break;
9028 /* Connected line party tag */
9030  ast_free(connected->id.tag);
9031  connected->id.tag = ast_malloc(ie_len + 1);
9032  if (connected->id.tag) {
9033  memcpy(connected->id.tag, data + pos, ie_len);
9034  connected->id.tag[ie_len] = 0;
9035  }
9036  break;
9037 /* Connected line party source */
9039  if (ie_len != sizeof(value)) {
9040  ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9041  (unsigned) ie_len);
9042  break;
9043  }
9044  memcpy(&value, data + pos, sizeof(value));
9045  connected->source = ntohl(value);
9046  break;
9047 /* Connected line party unknown element */
9048  default:
9049  ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n",
9050  (unsigned) ie_id, (unsigned) ie_len);
9051  break;
9052  }
9053  }
9054 
9055  switch (frame_version) {
9056  case 1:
9057  /*
9058  * The other end is an earlier version that we need to adjust
9059  * for compatibility.
9060  */
9061  connected->id.name.valid = 1;
9063  connected->id.number.valid = 1;
9064  if (got_combined_presentation) {
9067  }
9068  break;
9069  case 2:
9070  /* The other end is at the same level as we are. */
9071  break;
9072  default:
9073  /*
9074  * The other end is newer than we are.
9075  * We need to assume that they are compatible with us.
9076  */
9077  ast_log(LOG_DEBUG, "Connected line frame has newer version: %u\n",
9078  (unsigned) frame_version);
9079  break;
9080  }
9081 
9082  return 0;
9083 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define LOG_WARNING
Definition: logger.h:144
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
int value
Definition: syslog.c:39
#define LOG_DEBUG
Definition: logger.h:122
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int source
Information about the source of an update.
Definition: channel.h:424
#define ast_free(a)
Definition: astmm.h:97
int combined_presentation
Combined name and number presentation ie.
Definition: channel.c:8704
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
int type
Q.931 subaddress type.
Definition: channel.h:270
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
#define ast_malloc(a)
Definition: astmm.h:91
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 3107 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and deactivate_generator_nolock().

Referenced by __ast_read(), app_exec(), 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().

3108 {
3109  ast_channel_lock(chan);
3111  ast_channel_unlock(chan);
3112 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition: channel.c:3091
int ast_do_masquerade ( struct ast_channel original)

Start masquerading a channel.

Note
absolutely NO channel locks should be held before calling this function.

XXX This is a seriously whacked out operation. We're essentially putting the guts of the clone channel into the original channel. Start by killing off the original channel's backend. I'm not sure we're going to keep this function, because while the features are nice, the cost is very high in terms of pure nastiness. XXX

Parameters
chanChannel to masquerade

Start masquerading a channel.

Note
Assumes NO channels and NO channel pvt's are locked. If a channel is locked while calling this function, it invalidates our channel container locking order. All channels must be unlocked before it is permissible to lock the channels' ao2 container.

< TRUE if the clonechan was a zombie before the masquerade.

Definition at line 6546 of file channel.c.

References __ast_change_name_nolink(), ast_channel::_bridge, ast_channel::_softhangup, ast_channel::_state, accountcode, ast_channel::accountcode, ast_channel::adsicpe, ast_channel::alertpipe, ao2_link, ao2_lock, ao2_unlink, ao2_unlock, ast_app_group_update(), ast_autochan_new_channel(), ast_bridge_end_dtmf(), 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_lock_both, AST_CHANNEL_NAME, ast_channel_ref, ast_channel_set_fd(), ast_channel_set_linkgroup(), ast_channel_unlock, ast_channel_unref, ast_clear_flag, AST_CONTROL_SRCCHANGE, AST_CONTROL_UNHOLD, ast_copy_string(), ast_datastore_free(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_DISABLE_DEVSTATE_CACHE, AST_FLAG_EXCEPTION, AST_FLAG_MOH, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_GENERATOR_FD, ast_getformatname(), ast_indicate(), ast_kill_tech, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_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_moh_start(), 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, channels, clone_variables(), ast_channel::connected, ast_datastore::data, ast_channel::datastores, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::fdno, ast_channel::fds, ast_channel_tech::fixup, free_translation(), ast_channel_tech::hangup, ast_channel::hangupcause, ast_datastore::info, language, ast_channel::language, LOG_WARNING, ast_channel::masq, ast_channel::masqr, masquerade_colp_transfer(), ast_channel::monitor, musicclass, ast_channel::musicclass, ast_channel::name, ast_channel::nativeformats, parkinglot, ast_channel::parkinglot, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, ast_channel::redirecting, report_new_callerid(), S_OR, ast_channel::sending_dtmf_digit, ast_channel::sending_dtmf_tv, ast_channel::tech, ast_channel::tech_pvt, ast_channel::timingfd, xfer_masquerade_ds::transferee_held, ast_channel_tech::type, ast_cdr::uniqueid, ast_channel::uniqueid, ast_channel::visible_indication, ast_channel::whentohangup, and ast_channel::writeformat.

Referenced by __ast_read(), ast_async_goto(), ast_do_pickup(), ast_hangup(), ast_waitfor_nandfds(), ast_write(), builtin_atxfer(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), local_attended_transfer(), masq_park_call(), and sip_park().

6547 {
6548  int x;
6549  int i;
6550  int origstate;
6551  unsigned int orig_disablestatecache;
6552  unsigned int clone_disablestatecache;
6553  int visible_indication;
6554  int moh_is_playing;
6555  int clone_was_zombie = 0;/*!< TRUE if the clonechan was a zombie before the masquerade. */
6556  struct ast_frame *current;
6557  const struct ast_channel_tech *t;
6558  void *t_pvt;
6559  union {
6560  struct ast_party_dialed dialed;
6561  struct ast_party_caller caller;
6563  struct ast_party_redirecting redirecting;
6564  } exchange;
6565  struct ast_channel *clonechan, *chans[2];
6566  struct ast_channel *bridged;
6567  struct ast_cdr *cdr;
6568  struct ast_datastore *xfer_ds;
6569  struct xfer_masquerade_ds *xfer_colp;
6570  format_t rformat;
6571  format_t wformat;
6572  format_t tmp_format;
6573  char newn[AST_CHANNEL_NAME];
6574  char orig[AST_CHANNEL_NAME];
6575  char masqn[AST_CHANNEL_NAME];
6576  char zombn[AST_CHANNEL_NAME];
6577  char clone_sending_dtmf_digit;
6578  struct timeval clone_sending_dtmf_tv;
6579 
6580  /* XXX This operation is a bit odd. We're essentially putting the guts of
6581  * the clone channel into the original channel. Start by killing off the
6582  * original channel's backend. While the features are nice, which is the
6583  * reason we're keeping it, it's still awesomely weird. XXX */
6584 
6585  /*
6586  * The reasoning for the channels ao2_container lock here is
6587  * complex.
6588  *
6589  * There is a race condition that exists for this function.
6590  * Since all pvt and channel locks must be let go before calling
6591  * ast_do_masquerade, it is possible that it could be called
6592  * multiple times for the same channel. In order to prevent the
6593  * race condition with competing threads to do the masquerade
6594  * and new masquerade attempts, the channels container must be
6595  * locked for the entire masquerade. The original and clonechan
6596  * need to be unlocked earlier to avoid potential deadlocks with
6597  * the chan_local deadlock avoidance method.
6598  *
6599  * The container lock blocks competing masquerade attempts from
6600  * starting as well as being necessary for proper locking order
6601  * because the channels must to be unlinked to change their
6602  * names.
6603  *
6604  * The original and clonechan locks must be held while the
6605  * channel contents are shuffled around for the masquerade.
6606  *
6607  * The masq and masqr pointers need to be left alone until the
6608  * masquerade has restabilized the channels to prevent another
6609  * masquerade request until the AST_FLAG_ZOMBIE can be set on
6610  * the clonechan.
6611  */
6612  ao2_lock(channels);
6613 
6614  /*
6615  * Lock the original channel to determine if the masquerade is
6616  * still required.
6617  */
6618  ast_channel_lock(original);
6619 
6620  clonechan = original->masq;
6621  if (!clonechan) {
6622  /*
6623  * The masq is already completed by another thread or never
6624  * needed to be done to begin with.
6625  */
6626  ast_channel_unlock(original);
6628  return 0;
6629  }
6630 
6631  /* Bump the refs to ensure that they won't dissapear on us. */
6632  ast_channel_ref(original);
6633  ast_channel_ref(clonechan);
6634 
6635  /* unlink from channels container as name (which is the hash value) will change */
6636  ao2_unlink(channels, original);
6637  ao2_unlink(channels, clonechan);
6638 
6639  /* Get any transfer masquerade connected line exchange data. */
6640  xfer_ds = ast_channel_datastore_find(original, &xfer_ds_info, NULL);
6641  if (xfer_ds) {
6642  ast_channel_datastore_remove(original, xfer_ds);
6643  xfer_colp = xfer_ds->data;
6644  } else {
6645  xfer_colp = NULL;
6646  }
6647 
6648  moh_is_playing = ast_test_flag(original, AST_FLAG_MOH);
6649 
6650  /*
6651  * Stop any visible indication on the original channel so we can
6652  * transfer it to the clonechan taking the original's place.
6653  */
6654  visible_indication = original->visible_indication;
6655  ast_channel_unlock(original);
6656  ast_indicate(original, -1);
6657 
6658  /*
6659  * Release any hold on the transferee channel before going any
6660  * further with the masquerade.
6661  */
6662  if (xfer_colp && xfer_colp->transferee_held) {
6663  ast_indicate(clonechan, AST_CONTROL_UNHOLD);
6664  }
6665 
6666  /* Start the masquerade channel contents rearangement. */
6667  ast_channel_lock_both(original, clonechan);
6668 
6669  ast_debug(4, "Actually Masquerading %s(%u) into the structure of %s(%u)\n",
6670  clonechan->name, clonechan->_state, original->name, original->_state);
6671 
6672  chans[0] = clonechan;
6673  chans[1] = original;
6674  ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans,
6675  "Clone: %s\r\n"
6676  "CloneState: %s\r\n"
6677  "Original: %s\r\n"
6678  "OriginalState: %s\r\n",
6679  clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state));
6680 
6681  /*
6682  * Remember the original read/write formats. We turn off any
6683  * translation on either one
6684  */
6685  rformat = original->readformat;
6686  wformat = original->writeformat;
6687  free_translation(clonechan);
6688  free_translation(original);
6689 
6690  /* Save the current DTMF digit being sent if any. */
6691  clone_sending_dtmf_digit = clonechan->sending_dtmf_digit;
6692  clone_sending_dtmf_tv = clonechan->sending_dtmf_tv;
6693 
6694  /* Save the original name */
6695  ast_copy_string(orig, original->name, sizeof(orig));
6696  /* Save the new name */
6697  ast_copy_string(newn, clonechan->name, sizeof(newn));
6698  /* Create the masq name */
6699  snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
6700 
6701  /* Mangle the name of the clone channel */
6702  __ast_change_name_nolink(clonechan, masqn);
6703 
6704  /* Copy the name from the clone channel */
6705  __ast_change_name_nolink(original, newn);
6706 
6707  /* share linked id's */
6708  ast_channel_set_linkgroup(original, clonechan);
6709 
6710  /* Swap the technologies */
6711  t = original->tech;
6712  original->tech = clonechan->tech;
6713  clonechan->tech = t;
6714 
6715  t_pvt = original->tech_pvt;
6716  original->tech_pvt = clonechan->tech_pvt;
6717  clonechan->tech_pvt = t_pvt;
6718 
6719  /* Swap the cdrs */
6720  cdr = original->cdr;
6721  /* swap cdr uniqueid between channels, to get cdr uniqueid = channel uniqueid */
6722  ast_copy_string(clonechan->cdr->uniqueid, cdr->uniqueid, sizeof(cdr->uniqueid));
6723  original->cdr = clonechan->cdr;
6724  clonechan->cdr = cdr;
6725 
6726  /* Swap the alertpipes */
6727  for (i = 0; i < 2; i++) {
6728  x = original->alertpipe[i];
6729  original->alertpipe[i] = clonechan->alertpipe[i];
6730  clonechan->alertpipe[i] = x;
6731  }
6732 
6733  /*
6734  * Swap the readq's. The end result should be this:
6735  *
6736  * 1) All frames should be on the new (original) channel.
6737  * 2) Any frames that were already on the new channel before this
6738  * masquerade need to be at the end of the readq, after all of the
6739  * frames on the old (clone) channel.
6740  * 3) The alertpipe needs to get poked for every frame that was already
6741  * on the new channel, since we are now using the alert pipe from the
6742  * old (clone) channel.
6743  */
6744  {
6745  AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq;
6746 
6747  AST_LIST_HEAD_INIT_NOLOCK(&tmp_readq);
6748  AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list);
6749  AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list);
6750 
6751  while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
6752  AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
6753  if (original->alertpipe[1] > -1) {
6754  int poke = 0;
6755 
6756  if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
6757  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
6758  }
6759  }
6760  }
6761  }
6762 
6763  /* Swap the raw formats */
6764  tmp_format = original->rawreadformat;
6765  original->rawreadformat = clonechan->rawreadformat;
6766  clonechan->rawreadformat = tmp_format;
6767 
6768  tmp_format = original->rawwriteformat;
6769  original->rawwriteformat = clonechan->rawwriteformat;
6770  clonechan->rawwriteformat = tmp_format;
6771 
6772  clonechan->_softhangup = AST_SOFTHANGUP_DEV;
6773 
6774  /* And of course, so does our current state. Note we need not
6775  call ast_setstate since the event manager doesn't really consider
6776  these separate. We do this early so that the clone has the proper
6777  state of the original channel. */
6778  origstate = original->_state;
6779  original->_state = clonechan->_state;
6780  clonechan->_state = origstate;
6781 
6782  /* And the swap the cachable state too. Otherwise we'd start caching
6783  * Local channels and ignoring real ones. */
6784  orig_disablestatecache = ast_test_flag(original, AST_FLAG_DISABLE_DEVSTATE_CACHE);
6785  clone_disablestatecache = ast_test_flag(clonechan, AST_FLAG_DISABLE_DEVSTATE_CACHE);
6786  if (orig_disablestatecache != clone_disablestatecache) {
6787  if (orig_disablestatecache) {
6790  } else {
6793  }
6794  }
6795 
6796  /* Mangle the name of the clone channel */
6797  snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
6798  __ast_change_name_nolink(clonechan, zombn);
6799 
6800  /* Update the type. */
6801  t_pvt = original->monitor;
6802  original->monitor = clonechan->monitor;
6803  clonechan->monitor = t_pvt;
6804 
6805  /* Keep the same language. */
6806  ast_string_field_set(original, language, clonechan->language);
6807 
6808  /* Keep the same parkinglot. */
6809  ast_string_field_set(original, parkinglot, clonechan->parkinglot);
6810 
6811  /* Copy the FD's other than the generator fd */
6812  for (x = 0; x < AST_MAX_FDS; x++) {
6813  if (x != AST_GENERATOR_FD)
6814  ast_channel_set_fd(original, x, clonechan->fds[x]);
6815  }
6816 
6817  ast_app_group_update(clonechan, original);
6818 
6819  /* Move data stores over */
6820  if (AST_LIST_FIRST(&clonechan->datastores)) {
6821  struct ast_datastore *ds;
6822  /* We use a safe traversal here because some fixup routines actually
6823  * remove the datastore from the list and free them.
6824  */
6825  AST_LIST_TRAVERSE_SAFE_BEGIN(&clonechan->datastores, ds, entry) {
6826  if (ds->info->chan_fixup)
6827  ds->info->chan_fixup(ds->data, clonechan, original);
6828  }
6830  AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry);
6831  }
6832 
6833  ast_autochan_new_channel(clonechan, original);
6834 
6835  clone_variables(original, clonechan);
6836  /* Presense of ADSI capable CPE follows clone */
6837  original->adsicpe = clonechan->adsicpe;
6838  /* Bridge remains the same */
6839  /* CDR fields remain the same */
6840  /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
6841  /* Application and data remain the same */
6842  /* Clone exception becomes real one, as with fdno */
6844  original->fdno = clonechan->fdno;
6845  /* Schedule context remains the same */
6846  /* Stream stuff stays the same */
6847  /* Keep the original state. The fixup code will need to work with it most likely */
6848 
6849  /*
6850  * Just swap the whole structures, nevermind the allocations,
6851  * they'll work themselves out.
6852  */
6853  exchange.dialed = original->dialed;
6854  original->dialed = clonechan->dialed;
6855  clonechan->dialed = exchange.dialed;
6856 
6857  exchange.caller = original->caller;
6858  original->caller = clonechan->caller;
6859  clonechan->caller = exchange.caller;
6860 
6861  exchange.connected = original->connected;
6862  original->connected = clonechan->connected;
6863  clonechan->connected = exchange.connected;
6864 
6865  exchange.redirecting = original->redirecting;
6866  original->redirecting = clonechan->redirecting;
6867  clonechan->redirecting = exchange.redirecting;
6868 
6869  report_new_callerid(original);
6870 
6871  /* Restore original timing file descriptor */
6872  ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
6873 
6874  /* Our native formats are different now */
6875  original->nativeformats = clonechan->nativeformats;
6876 
6877  /* Context, extension, priority, app data, jump table, remain the same */
6878  /* pvt switches. pbx stays the same, as does next */
6879 
6880  /* Set the write format */
6881  ast_set_write_format(original, wformat);
6882 
6883  /* Set the read format */
6884  ast_set_read_format(original, rformat);
6885 
6886  /* Copy the music class */
6887  ast_string_field_set(original, musicclass, clonechan->musicclass);
6888 
6889  /* Copy whentohangup time */
6890  original->whentohangup = clonechan->whentohangup;
6891 
6892  /* copy over accuntcode and set peeraccount across the bridge */
6893  ast_string_field_set(original, accountcode, S_OR(clonechan->accountcode, ""));
6894  if (original->_bridge) {
6895  /* XXX - should we try to lock original->_bridge here? */
6896  ast_string_field_set(original->_bridge, peeraccount, S_OR(clonechan->accountcode, ""));
6897  ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
6898  }
6899 
6900  ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
6901  ast_getformatname(wformat), ast_getformatname(rformat));
6902 
6903  /* Fixup the original clonechan's physical side */
6904  if (original->tech->fixup && original->tech->fixup(clonechan, original)) {
6905  ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (clonechan)\n",
6906  original->tech->type, original->name);
6907  }
6908 
6909  /* Fixup the original original's physical side */
6910  if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
6911  ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (original)\n",
6912  clonechan->tech->type, clonechan->name);
6913  }
6914 
6915  /*
6916  * Now, at this point, the "clone" channel is totally F'd up.
6917  * We mark it as a zombie so nothing tries to touch it. If it's
6918  * already been marked as a zombie, then we must free it (since
6919  * it already is considered invalid).
6920  *
6921  * This must be done before we unlock clonechan to prevent
6922  * setting up another masquerade on the clonechan.
6923  */
6924  if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
6925  clone_was_zombie = 1;
6926  } else {
6927  ast_set_flag(clonechan, AST_FLAG_ZOMBIE);
6928  ast_queue_frame(clonechan, &ast_null_frame);
6929  }
6930 
6931  /* clear the masquerade channels */
6932  original->masq = NULL;
6933  clonechan->masqr = NULL;
6934 
6935  /*
6936  * When we unlock original here, it can be immediately setup to
6937  * masquerade again or hungup. The new masquerade or hangup
6938  * will not actually happen until we release the channels
6939  * container lock.
6940  */
6941  ast_channel_unlock(original);
6942 
6943  /* Disconnect the original original's physical side */
6944  if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) {
6945  ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n");
6946  } else {
6947  /*
6948  * We just hung up the original original's physical side of the
6949  * channel. Set the new zombie to use the kill channel driver
6950  * for safety.
6951  */
6952  clonechan->tech = &ast_kill_tech;
6953  }
6954 
6955  ast_channel_unlock(clonechan);
6956 
6957  if (clone_sending_dtmf_digit) {
6958  /*
6959  * The clonechan was sending a DTMF digit that was not completed
6960  * before the masquerade.
6961  */
6962  ast_bridge_end_dtmf(original, clone_sending_dtmf_digit, clone_sending_dtmf_tv,
6963  "masquerade");
6964  }
6965 
6966  /*
6967  * If an indication is currently playing, maintain it on the
6968  * channel that is taking the place of original.
6969  *
6970  * This is needed because the masquerade is swapping out the
6971  * internals of the channel, and the new channel private data
6972  * needs to be made aware of the current visible indication
6973  * (RINGING, CONGESTION, etc.)
6974  */
6975  if (visible_indication) {
6976  ast_indicate(original, visible_indication);
6977  }
6978 
6979  /* if moh is playing on the original channel then it needs to be
6980  maintained on the channel that is replacing it. */
6981  if (moh_is_playing) {
6982  ast_moh_start(original, NULL, NULL);
6983  }
6984 
6985  ast_channel_lock(original);
6986 
6987  /* Signal any blocker */
6988  if (ast_test_flag(original, AST_FLAG_BLOCKING)) {
6989  pthread_kill(original->blocker, SIGURG);
6990  }
6991 
6992  ast_debug(1, "Done Masquerading %s (%u)\n", original->name, original->_state);
6993 
6994  if ((bridged = ast_bridged_channel(original))) {
6995  ast_channel_ref(bridged);
6996  ast_channel_unlock(original);
6998  ast_channel_unref(bridged);
6999  } else {
7000  ast_channel_unlock(original);
7001  }
7003 
7004  if (xfer_colp) {
7005  /*
7006  * After the masquerade, the original channel pointer actually
7007  * points to the new transferee channel and the bridged channel
7008  * is still the intended transfer target party.
7009  */
7010  masquerade_colp_transfer(original, xfer_colp);
7011  }
7012 
7013  if (xfer_ds) {
7014  ast_datastore_free(xfer_ds);
7015  }
7016 
7017  if (clone_was_zombie) {
7018  ast_channel_lock(clonechan);
7019  ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name);
7020  ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup",
7021  "Channel: %s\r\n"
7022  "Uniqueid: %s\r\n"
7023  "Cause: %d\r\n"
7024  "Cause-txt: %s\r\n",
7025  clonechan->name,
7026  clonechan->uniqueid,
7027  clonechan->hangupcause,
7028  ast_cause2str(clonechan->hangupcause)
7029  );
7030  ast_channel_unlock(clonechan);
7031 
7032  /*
7033  * Drop the system reference to destroy the channel since it is
7034  * already unlinked.
7035  */
7036  ast_channel_unref(clonechan);
7037  } else {
7038  ao2_link(channels, clonechan);
7039  }
7040 
7041  ao2_link(channels, original);
7043 
7044  /* Release our held safety references. */
7045  ast_channel_unref(original);
7046  ast_channel_unref(clonechan);
7047 
7048  return 0;
7049 }
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:155
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
struct ast_channel * masqr
Definition: channel.h:752
struct ast_datastore::@163 entry
#define ast_channel_lock(chan)
Definition: channel.h:2466
void ast_bridge_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition: features.c:3927
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
const char *const type
Definition: channel.h:508
#define ao2_link(arg1, arg2)
Definition: astobj2.h:785
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
static char parkinglot[AST_MAX_CONTEXT]
Definition: chan_mgcp.c:156
struct ast_frame ast_null_frame
Definition: frame.c:131
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int timingfd
Definition: channel.h:838
const ast_string_field uniqueid
Definition: channel.h:787
format_t writeformat
Definition: channel.h:854
int visible_indication
Definition: channel.h:861
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void free_translation(struct ast_channel *clonechan)
Definition: channel.c:2757
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
void * tech_pvt
Definition: channel.h:744
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_datastore_info * info
Definition: datastore.h:57
format_t rawwriteformat
Definition: channel.h:856
char uniqueid[150]
Definition: cdr.h:121
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
#define EVENT_FLAG_CALL
Definition: manager.h:72
static void clone_variables(struct ast_channel *original, struct ast_channel *clonechan)
Clone channel variables from &#39;clone&#39; channel into &#39;original&#39; channel.
Definition: channel.c:6291
struct ast_cdr * cdr
Definition: channel.h:766
#define ao2_unlock(a)
Definition: astobj2.h:497
format_t nativeformats
Definition: channel.h:852
Structure for a data store object.
Definition: datastore.h:54
int alertpipe[2]
Definition: channel.h:851
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.
Definition: channel.c:2604
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
int(*const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan)
Fix up a channel: If a channel is consumed, this is called. Basically update any -&gt;owner links...
Definition: channel.h:579
enum ast_channel_adsicpe adsicpe
Definition: channel.h:844
format_t rawreadformat
Definition: channel.h:855
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
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 &quot;format&quot; is ...
Definition: channel.c:5307
a masquerade happened to alter the participants on a bridge
Definition: cel.h:94
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 &quot;format&quot; is be...
Definition: channel.c:5301
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
Caller Party information.
Definition: channel.h:368
#define ao2_lock(a)
Definition: astobj2.h:488
const ast_string_field parkinglot
Definition: channel.h:787
#define AST_GENERATOR_FD
Definition: channel.h:166
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
propagate the linked id between chan and peer
Definition: channel.c:6387
struct ast_channel * _bridge
Definition: channel.h:748
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
char sending_dtmf_digit
Definition: channel.h:873
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
int fds[AST_MAX_FDS]
Definition: channel.h:829
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
Dialed/Called Party information.
Definition: channel.h:328
static void masquerade_colp_transfer(struct ast_channel *transferee, struct xfer_masquerade_ds *colp)
Definition: channel.c:6498
Responsible for call detail data.
Definition: cdr.h:82
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
Definition: channel.c:668
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
int64_t format_t
Definition: frame_defs.h:32
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
struct timeval sending_dtmf_tv
Definition: channel.h:874
#define AST_TIMING_FD
Definition: channel.h:164
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
while(yyssp!=yyss)
Definition: ast_expr2.c:2538
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
static void __ast_change_name_nolink(struct ast_channel *chan, const char *newname)
this function simply changes the name of the channel and issues a manager_event with out unlinking an...
Definition: channel.c:6223
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
int errno
struct ast_channel::datastores datastores
void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *new_chan)
Switch what channel autochans point to.
Definition: autochan.c:83
#define AST_CHANNEL_NAME
Definition: channel.h:137
#define AST_MAX_FDS
Definition: channel.h:158
#define ast_clear_flag(p, flag)
Definition: utils.h:77
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
void * data
Definition: datastore.h:56
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
Definition: app.c:1329
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2491
format_t readformat
Definition: channel.h:853
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
pthread_t blocker
Definition: channel.h:790
const ast_string_field musicclass
Definition: channel.h:787
const ast_string_field accountcode
Definition: channel.h:787
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Definition: manager.h:226
static int connected
Definition: cdr_pgsql.c:57
struct timeval whentohangup
Definition: channel.h:789
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct ast_channel_monitor * monitor
Definition: channel.h:769
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel::@156 readq
void(* chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references.
Definition: datastore.h:50
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2599
static struct ast_datastore_info xfer_ds_info
Definition: channel.c:6179
const ast_string_field language
Definition: channel.h:787
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
Definition: linkedlists.h:768
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_channel* ast_dummy_channel_alloc ( void  )

Create a fake channel structure.

Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
This function should ONLY be used to create a fake channel that can then be populated with data for use in variable substitution when a real channel does not exist.
The created dummy channel should be destroyed by ast_channel_unref(). Using ast_channel_release() needlessly grabs the channel container lock and can cause a deadlock as a result. Also grabbing the channel container lock reduces system performance.

Definition at line 1391 of file channel.c.

References __ao2_alloc_debug(), ast_channel::alertpipe, ao2_alloc, ARRAY_LEN, ast_channel_unref, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_string_field_init, ast_channel::fds, ast_channel::timingfd, and ast_channel::varshead.

Referenced by acf_odbc_read(), acf_odbc_write(), action_getvar(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_pbx_outgoing_cdr_failed(), ast_str_substitute_variables_full(), cli_odbc_read(), cli_odbc_write(), custom_log(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), and syslog_log().

1393 {
1394  struct ast_channel *tmp;
1395  struct varshead *headp;
1396  int x;
1397 
1398 #if defined(REF_DEBUG)
1399  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
1400  file, line, function, 1);
1401 #elif defined(__AST_DEBUG_MALLOC)
1402  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
1403  file, line, function, 0);
1404 #else
1405  tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor);
1406 #endif
1407  if (!tmp) {
1408  /* Dummy channel structure allocation failure. */
1409  return NULL;
1410  }
1411 
1412  if ((ast_string_field_init(tmp, 128))) {
1413  return ast_channel_unref(tmp);
1414  }
1415 
1416  /*
1417  * Init file descriptors to unopened state just in case
1418  * autoservice is called on the channel or something tries to
1419  * read a frame from it.
1420  */
1421  tmp->timingfd = -1;
1422  for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
1423  tmp->alertpipe[x] = -1;
1424  }
1425  for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) {
1426  tmp->fds[x] = -1;
1427  }
1428 #ifdef HAVE_EPOLL
1429  tmp->epfd = -1;
1430 #endif
1431 
1432  headp = &tmp->varshead;
1434 
1435  return tmp;
1436 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int timingfd
Definition: channel.h:838
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition: channel.c:2530
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
int alertpipe[2]
Definition: channel.h:851
void * __ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, const char *file, int line, const char *funcname, int ref_debug)
Definition: astobj2.c:335
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:249
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:430
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
struct varshead varshead
Definition: channel.h:817
static int ast_fdisset ( struct pollfd *  pfds,
int  fd,
int  maximum,
int *  start 
)
inlinestatic

Helper function for migrating select to poll.

Definition at line 2398 of file channel.h.

References dummy().

Referenced by do_monitor().

2399 {
2400  int x;
2401  int dummy = 0;
2402 
2403  if (fd < 0)
2404  return 0;
2405  if (!start)
2406  start = &dummy;
2407  for (x = *start; x < maximum; x++)
2408  if (pfds[x].fd == fd) {
2409  if (x == *start)
2410  (*start)++;
2411  return pfds[x].revents;
2412  }
2413  return 0;
2414 }
static void dummy(char *unused,...)
Definition: chan_unistim.c:188
struct ast_channel_tech* ast_get_channel_tech ( const char *  name)

Get a channel technology structure by name.

Parameters
namename of technology to find
Returns
a pointer to the structure, or NULL if no matching technology found

Get a channel technology structure by name.

Definition at line 960 of file channel.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::tech, and ast_channel_tech::type.

Referenced by __ast_channel_alloc_ap(), _ast_device_state(), ast_cc_callback(), and ast_var_channel_types_table().

961 {
962  struct chanlist *chanls;
963  const struct ast_channel_tech *ret = NULL;
964 
966 
967  AST_RWLIST_TRAVERSE(&backends, chanls, list) {
968  if (!strcasecmp(name, chanls->tech->type)) {
969  ret = chanls->tech;
970  break;
971  }
972  }
973 
975 
976  return ret;
977 }
const char *const type
Definition: channel.h:508
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
static const char name[]
ast_group_t ast_get_group ( const char *  s)

Definition at line 7987 of file channel.c.

References ast_log(), ast_strdupa, ast_strlen_zero(), group, LOG_ERROR, LOG_WARNING, and strsep().

Referenced by _parse(), build_device(), build_gateway(), build_peer(), config_parse_variables(), func_channel_write_real(), process_dahdi(), and read_agent_config().

7988 {
7989  char *piece;
7990  char *c;
7991  int start=0, finish=0, x;
7992  ast_group_t group = 0;
7993 
7994  if (ast_strlen_zero(s))
7995  return 0;
7996 
7997  c = ast_strdupa(s);
7998 
7999  while ((piece = strsep(&c, ","))) {
8000  if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
8001  /* Range */
8002  } else if (sscanf(piece, "%30d", &start)) {
8003  /* Just one */
8004  finish = start;
8005  } else {
8006  ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
8007  continue;
8008  }
8009  for (x = start; x <= finish; x++) {
8010  if ((x > 63) || (x < 0)) {
8011  ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
8012  } else
8013  group |= ((ast_group_t) 1 << x);
8014  }
8015  }
8016  return group;
8017 }
unsigned long long ast_group_t
Definition: channel.h:175
char * strsep(char **str, const char *delims)
#define LOG_WARNING
Definition: logger.h:144
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static ast_group_t group
Definition: chan_agent.c:221
int ast_hangup ( struct ast_channel chan)

Hang up a channel.

Note
Absolutely NO channel locks should be held before calling this function.
This function performs a hard hangup on a channel. Unlike the soft-hangup, this function performs all stream stopping, etc, on the channel that needs to end. chan is no longer valid after this call.
Parameters
chanchannel to hang up
Returns
Returns 0 on success, -1 on failure.

Hang up a channel.

Definition at line 2804 of file channel.c.

References ao2_unlink, ast_assert, ast_autoservice_stop(), ast_cause2str(), ast_cc_offer(), ast_cdr_detach(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, AST_CEL_HANGUP, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_closestream(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_log(), ast_manager_event, ast_set_flag, ast_test_flag, ast_channel::blocker, ast_channel::blockproc, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, destroy_hooks(), ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, ast_channel::hangupsource, ast_party_caller::id, ast_party_connected_line::id, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_party_id::name, ast_channel::name, ast_party_id::number, pbx_builtin_getvar_helper(), ast_generator::release, S_COR, S_OR, ast_channel::sched, sched_context_destroy(), ast_party_name::str, ast_party_number::str, ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::vstream.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_pbx_run(), __ast_request_and_dial(), __oh323_new(), action_bridge(), agent_request(), 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_call_thread_launch(), bridge_channel_thread(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_availability(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_free(), conf_run(), console_new(), dahdi_handle_event(), dahdi_new(), destroy_conference_bridge(), dial_exec_full(), dial_transfer(), do_forward(), do_hang(), do_idle_thread(), do_monitor(), feature_attended_transfer(), feature_request_and_dial(), findmeexec(), generic_recall(), gtalk_new(), handle_call_forward(), handle_callforward_button(), handle_enbloc_call_message(), handle_frame(), handle_frame_ownerless(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_soft_key_event_message(), handle_stimulus_message(), handle_timeout_trip(), handle_transfer_button(), HandleCallOutgoing(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), jingle_new(), local_hangup(), manage_parked_call(), masq_park_call(), meetme_menu_admin_extended(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), oss_new(), parkandannounce_exec(), parked_call_exec(), phone_new(), play_sound_file(), pri_dchannel(), pri_ss_thread(), sip_park(), sip_park_thread(), sip_pickup_thread(), skinny_new(), skinny_ss(), try_calling(), unistim_new(), wait_for_answer(), and wait_for_winner().

2805 {
2806  char extra_str[64]; /* used for cel logging below */
2807  int was_zombie;
2808 
2809  ast_autoservice_stop(chan);
2810 
2811  ast_channel_lock(chan);
2812 
2813  /*
2814  * Do the masquerade if someone is setup to masquerade into us.
2815  *
2816  * NOTE: We must hold the channel lock after testing for a
2817  * pending masquerade and setting the channel as a zombie to
2818  * prevent __ast_channel_masquerade() from setting up a
2819  * masquerade with a dead channel.
2820  */
2821  while (chan->masq) {
2822  ast_channel_unlock(chan);
2823  ast_do_masquerade(chan);
2824  ast_channel_lock(chan);
2825  }
2826 
2827  if (chan->masqr) {
2828  /*
2829  * This channel is one which will be masqueraded into something.
2830  * Mark it as a zombie already so ast_do_masquerade() will know
2831  * to free it later.
2832  */
2834  destroy_hooks(chan);
2835  ast_channel_unlock(chan);
2836  return 0;
2837  }
2838 
2839  /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2840  if (!(was_zombie = ast_test_flag(chan, AST_FLAG_ZOMBIE))) {
2842  }
2843 
2844  ast_channel_unlock(chan);
2845  ao2_unlink(channels, chan);
2846  ast_channel_lock(chan);
2847 
2848  destroy_hooks(chan);
2849 
2850  free_translation(chan);
2851  /* Close audio stream */
2852  if (chan->stream) {
2853  ast_closestream(chan->stream);
2854  chan->stream = NULL;
2855  }
2856  /* Close video stream */
2857  if (chan->vstream) {
2858  ast_closestream(chan->vstream);
2859  chan->vstream = NULL;
2860  }
2861  if (chan->sched) {
2863  chan->sched = NULL;
2864  }
2865 
2866  if (chan->generatordata) { /* Clear any tone stuff remaining */
2867  if (chan->generator && chan->generator->release) {
2868  chan->generator->release(chan, chan->generatordata);
2869  }
2870  }
2871  chan->generatordata = NULL;
2872  chan->generator = NULL;
2873 
2874  snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
2875  ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
2876 
2877  if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
2878  ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
2879  "is blocked by thread %ld in procedure %s! Expect a failure\n",
2880  (long) pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
2882  }
2883  if (!was_zombie) {
2884  ast_debug(1, "Hanging up channel '%s'\n", chan->name);
2885 
2886  if (chan->tech->hangup) {
2887  chan->tech->hangup(chan);
2888  }
2889  } else {
2890  ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
2891  }
2892 
2893  ast_channel_unlock(chan);
2894 
2895  ast_cc_offer(chan);
2896  ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup",
2897  "Channel: %s\r\n"
2898  "Uniqueid: %s\r\n"
2899  "CallerIDNum: %s\r\n"
2900  "CallerIDName: %s\r\n"
2901  "ConnectedLineNum: %s\r\n"
2902  "ConnectedLineName: %s\r\n"
2903  "Cause: %d\r\n"
2904  "Cause-txt: %s\r\n",
2905  chan->name,
2906  chan->uniqueid,
2907  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
2908  S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
2909  S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, "<unknown>"),
2910  S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, "<unknown>"),
2911  chan->hangupcause,
2912  ast_cause2str(chan->hangupcause)
2913  );
2914 
2915  if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) &&
2918  ast_channel_lock(chan);
2919  ast_cdr_end(chan->cdr);
2920  ast_cdr_detach(chan->cdr);
2921  chan->cdr = NULL;
2922  ast_channel_unlock(chan);
2923  }
2924 
2925  ast_channel_unref(chan);
2926 
2927  return 0;
2928 }
struct ast_channel * masqr
Definition: channel.h:752
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void free_translation(struct ast_channel *clonechan)
Definition: channel.c:2757
void ast_cdr_end(struct ast_cdr *cdr)
End a call.
Definition: cdr.c:933
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
const char * blockproc
Definition: channel.h:753
static void destroy_hooks(struct ast_channel *chan)
Definition: channel.c:2793
struct ast_generator * generator
Definition: channel.h:747
#define EVENT_FLAG_CALL
Definition: manager.h:72
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_assert(a)
Definition: utils.h:738
struct ast_cdr * cdr
Definition: channel.h:766
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
struct sched_context * sched
Definition: channel.h:756
hangup terminates connection
Definition: cel.h:54
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free&#39;s) the given sched_context structure
Definition: sched.c:267
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition: ccss.c:3485
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
void ast_cdr_detach(struct ast_cdr *cdr)
Detaches the detail record for posting (and freeing) either now or at a later time in bulk with other...
Definition: cdr.c:1328
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
const ast_string_field name
Definition: channel.h:787
const ast_string_field hangupsource
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
struct ast_filestream * vstream
Definition: channel.h:758
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition: file.c:904
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
pthread_t blocker
Definition: channel.h:790
int hangupcause
Definition: channel.h:849
long int disposition
Definition: cdr.h:110
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
struct ast_filestream * stream
Definition: channel.h:757
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
void * generatordata
Definition: channel.h:746
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
int ast_indicate ( struct ast_channel chan,
int  condition 
)

Indicates condition of channel.

Note
Absolutely NO channel locks should be held before calling this function.
Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
Parameters
chanchannel to change the indication
conditionwhich condition to indicate on the channel
Returns
Returns 0 on success, -1 on failure

Definition at line 4393 of file channel.c.

References ast_indicate_data().

Referenced by __ast_play_and_record(), agent_request(), alsa_call(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_raw_answer(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), dial_trunk(), disa_exec(), do_forward(), feature_request_and_dial(), finishup(), handle_callforward_button(), handle_frame(), handle_recordfile(), handle_request_refer(), local_attended_transfer(), manage_parked_call(), mgcp_ss(), monitor_dial(), oss_call(), park_call_full(), parked_call_exec(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_incomplete(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), record_exec(), rna(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), try_calling(), and wait_for_answer().

4394 {
4395  return ast_indicate_data(chan, condition, NULL, 0);
4396 }
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4447
int ast_indicate_data ( struct ast_channel chan,
int  condition,
const void *  data,
size_t  datalen 
)

Indicates condition of channel, with payload.

Note
Absolutely NO channel locks should be held before calling this function.
Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
Parameters
chanchannel to change the indication
conditionwhich condition to indicate on the channel
datapointer to payload data
datalensize of payload data
Returns
Returns 0 on success, -1 on failure
Note
If we compare the enumeration type, which does not have any negative constants, the compiler may optimize this code away. Therefore, we must perform an integer comparison here.

Definition at line 4447 of file channel.c.

References ast_channel::_state, _XXX_AST_CONTROL_T38, ast_channel_lock, ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_unlock, ast_check_hangup(), ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_debug, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_write_event(), ast_frdup(), ast_frfree, ast_get_indication_tone(), ast_log(), ast_party_connected_line_free(), ast_party_connected_line_set_init(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_playtones_start(), ast_playtones_stop(), ast_redirecting_parse_data(), AST_STATE_UP, ast_test_flag, ast_tone_zone_sound_unref(), ast_channel::connected, ast_tone_zone_sound::data, ast_frame::data, ast_frame::datalen, ast_channel::framehooks, ast_frame::frametype, ast_channel_tech::indicate, ast_frame_subclass::integer, is_visible_indication(), LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::redirecting, ast_frame::subclass, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.

Referenced by __ast_read(), action_aocmessage(), agent_hangup(), ast_bridge_call(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_generic_bridge(), ast_handle_cc_control_frame(), ast_indicate(), disable_t38(), feature_request_and_dial(), generic_fax_exec(), handle_frame(), local_bridge_loop(), login_exec(), manage_parked_call(), park_call_full(), pbx_builtin_waitexten(), receivefax_t38_init(), remote_bridge_loop(), sendfax_t38_init(), set_fax_t38_caps(), transmit_audio(), transmit_t38(), and wait_for_answer().

4449 {
4450  /* By using an enum, we'll get compiler warnings for values not handled
4451  * in switch statements. */
4452  enum ast_control_frame_type condition = _condition;
4453  struct ast_tone_zone_sound *ts = NULL;
4454  int res;
4455  /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4456  struct ast_frame *awesome_frame = NULL;
4457 
4458  ast_channel_lock(chan);
4459 
4460  /* Don't bother if the channel is about to go away, anyway. */
4461  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
4462  res = -1;
4463  goto indicate_cleanup;
4464  }
4465 
4467  /* Do framehooks now, do it, go, go now */
4468  struct ast_frame frame = {
4470  .subclass.integer = condition,
4471  .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4472  .datalen = datalen
4473  };
4474 
4475  /* we have now committed to freeing this frame */
4476  awesome_frame = ast_frdup(&frame);
4477 
4478  /* who knows what we will get back! the anticipation is killing me. */
4479  if (!(awesome_frame = ast_framehook_list_write_event(chan->framehooks, awesome_frame))
4480  || awesome_frame->frametype != AST_FRAME_CONTROL) {
4481 
4482  res = 0;
4483  goto indicate_cleanup;
4484  }
4485 
4486  condition = awesome_frame->subclass.integer;
4487  data = awesome_frame->data.ptr;
4488  datalen = awesome_frame->datalen;
4489  }
4490 
4491  switch (condition) {
4493  {
4495 
4497  res = ast_connected_line_parse_data(data, datalen, &connected);
4498  if (!res) {
4500  }
4502  }
4503  break;
4504 
4506  {
4507  struct ast_party_redirecting redirecting;
4508 
4509  ast_party_redirecting_set_init(&redirecting, &chan->redirecting);
4510  res = ast_redirecting_parse_data(data, datalen, &redirecting);
4511  if (!res) {
4512  ast_channel_set_redirecting(chan, &redirecting, NULL);
4513  }
4514  ast_party_redirecting_free(&redirecting);
4515  }
4516  break;
4517 
4518  default:
4519  break;
4520  }
4521 
4522  if (is_visible_indication(condition)) {
4523  /* A new visible indication is requested. */
4524  chan->visible_indication = condition;
4525  } else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
4526  /* Visible indication is cleared/stopped. */
4527  chan->visible_indication = 0;
4528  }
4529 
4530  if (chan->tech->indicate) {
4531  /* See if the channel driver can handle this condition. */
4532  res = chan->tech->indicate(chan, condition, data, datalen);
4533  } else {
4534  res = -1;
4535  }
4536 
4537  if (!res) {
4538  /* The channel driver successfully handled this indication */
4539  res = 0;
4540  goto indicate_cleanup;
4541  }
4542 
4543  /* The channel driver does not support this indication, let's fake
4544  * it by doing our own tone generation if applicable. */
4545 
4546  /*!\note If we compare the enumeration type, which does not have any
4547  * negative constants, the compiler may optimize this code away.
4548  * Therefore, we must perform an integer comparison here. */
4549  if (_condition < 0) {
4550  /* Stop any tones that are playing */
4551  ast_playtones_stop(chan);
4552  res = 0;
4553  goto indicate_cleanup;
4554  }
4555 
4556  /* Handle conditions that we have tones for. */
4557  switch (condition) {
4558  case _XXX_AST_CONTROL_T38:
4559  /* deprecated T.38 control frame */
4560  res = -1;
4561  goto indicate_cleanup;
4563  /* there is no way to provide 'default' behavior for these
4564  * control frames, so we need to return failure, but there
4565  * is also no value in the log message below being emitted
4566  * since failure to handle these frames is not an 'error'
4567  * so just return right now. in addition, we want to return
4568  * whatever value the channel driver returned, in case it
4569  * has some meaning.*/
4570  goto indicate_cleanup;
4571  case AST_CONTROL_RINGING:
4572  ts = ast_get_indication_tone(chan->zone, "ring");
4573  /* It is common practice for channel drivers to return -1 if trying
4574  * to indicate ringing on a channel which is up. The idea is to let the
4575  * core generate the ringing inband. However, we don't want the
4576  * warning message about not being able to handle the specific indication
4577  * to print nor do we want ast_indicate_data to return an "error" for this
4578  * condition
4579  */
4580  if (chan->_state == AST_STATE_UP) {
4581  res = 0;
4582  }
4583  break;
4584  case AST_CONTROL_BUSY:
4585  ts = ast_get_indication_tone(chan->zone, "busy");
4586  break;
4589  ts = ast_get_indication_tone(chan->zone, "congestion");
4590  break;
4591  case AST_CONTROL_PROGRESS:
4593  case AST_CONTROL_VIDUPDATE:
4594  case AST_CONTROL_SRCUPDATE:
4595  case AST_CONTROL_SRCCHANGE:
4596  case AST_CONTROL_RADIO_KEY:
4598  case AST_CONTROL_OPTION:
4599  case AST_CONTROL_WINK:
4600  case AST_CONTROL_FLASH:
4601  case AST_CONTROL_OFFHOOK:
4603  case AST_CONTROL_ANSWER:
4604  case AST_CONTROL_HANGUP:
4605  case AST_CONTROL_RING:
4606  case AST_CONTROL_HOLD:
4607  case AST_CONTROL_UNHOLD:
4608  case AST_CONTROL_TRANSFER:
4611  case AST_CONTROL_CC:
4613  case AST_CONTROL_AOC:
4614  case AST_CONTROL_END_OF_Q:
4616  /* Nothing left to do for these. */
4617  res = 0;
4618  break;
4619  }
4620 
4621  if (ts) {
4622  /* We have a tone to play, yay. */
4623  ast_debug(1, "Driver for channel '%s' does not support indication %u, emulating it\n", chan->name, condition);
4624  res = ast_playtones_start(chan, 0, ts->data, 1);
4625  ts = ast_tone_zone_sound_unref(ts);
4626  }
4627 
4628  if (res) {
4629  /* not handled */
4630  ast_log(LOG_WARNING, "Unable to handle indication %u for '%s'\n", condition, chan->name);
4631  }
4632 
4633 indicate_cleanup:
4634  ast_channel_unlock(chan);
4635  if (awesome_frame) {
4636  ast_frfree(awesome_frame);
4637  }
4638 
4639  return res;
4640 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
Parse redirecting indication frame data.
Definition: channel.c:9254
struct ast_tone_zone * zone
Definition: channel.h:767
static int attribute_const is_visible_indication(enum ast_control_frame_type condition)
Definition: channel.c:4398
int visible_indication
Definition: channel.h:861
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...
Definition: channel.c:2329
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:172
#define LOG_WARNING
Definition: logger.h:144
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:411
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int datalen
Definition: frame.h:148
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:226
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.
Definition: channel.c:9111
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
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.
Definition: channel.c:8886
ast_control_frame_type
Internal control frame subtype field values.
Definition: frame.h:319
struct ast_framehook_list * framehooks
Definition: channel.h:765
enum ast_channel_state _state
Definition: channel.h:839
Description of a tone.
Definition: indications.h:36
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:473
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:180
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
Data structure associated with a single frame of data.
Definition: frame.h:142
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...
Definition: channel.c:2380
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:319
static int connected
Definition: cdr_pgsql.c:57
const char * data
Description of a tone.
Definition: indications.h:53
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition: channel.h:576
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.
Definition: channel.c:8458
struct ast_frame * ast_frdup(const struct ast_frame *fr)
Copies a frame.
Definition: frame.c:474
int ast_internal_timing_enabled ( struct ast_channel chan)

Check if the channel can run in internal timing mode.

Parameters
chanThe channel to check
Returns
boolean

This function will return 1 if internal timing is enabled and the timing device is available.

Definition at line 4378 of file channel.c.

References ast_channel::timingfd.

4379 {
4380  return chan->timingfd > -1;
4381 }
int timingfd
Definition: channel.h:838
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.

Parameters
frameThe frame we just read
Return values
1frame should be kept
0frame should be dropped

Definition at line 1818 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().

1819 {
1820  /* Do not add a default entry in this switch statement. Each new
1821  * frame type should be addressed directly as to whether it should
1822  * be queued up or not.
1823  */
1824  switch (frame->frametype) {
1825  case AST_FRAME_CONTROL:
1826  case AST_FRAME_TEXT:
1827  case AST_FRAME_IMAGE:
1828  case AST_FRAME_HTML:
1829  return 1;
1830 
1831  case AST_FRAME_DTMF_END:
1832  case AST_FRAME_DTMF_BEGIN:
1833  case AST_FRAME_VOICE:
1834  case AST_FRAME_VIDEO:
1835  case AST_FRAME_NULL:
1836  case AST_FRAME_IAX:
1837  case AST_FRAME_CNG:
1838  case AST_FRAME_MODEM:
1839  return 0;
1840  }
1841  return 0;
1842 }
enum ast_frame_type frametype
Definition: frame.h:144
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.

Since
1.8
Parameters
destDestination caller
srcSource caller
Returns
Nothing

Definition at line 2276 of file channel.c.

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_copy(), and ast_party_caller::id.

2277 {
2278  if (dest == src) {
2279  /* Don't copy to self */
2280  return;
2281  }
2282 
2283  ast_party_id_copy(&dest->id, &src->id);
2284  ast_party_id_copy(&dest->ani, &src->ani);
2285  dest->ani2 = src->ani2;
2286 }
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.
Definition: channel.c:2095
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_party_caller_free ( struct ast_party_caller doomed)

Destroy the caller party contents.

Since
1.8
Parameters
doomedThe caller party to destroy.
Returns
Nothing

Definition at line 2302 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().

2303 {
2304  ast_party_id_free(&doomed->id);
2305  ast_party_id_free(&doomed->ani);
2306 }
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
void ast_party_caller_init ( struct ast_party_caller init)

Initialize the given caller structure.

Since
1.8
Parameters
initCaller structure to initialize.
Returns
Nothing

Definition at line 2269 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().

2270 {
2271  ast_party_id_init(&init->id);
2272  ast_party_id_init(&init->ani);
2273  init->ani2 = 0;
2274 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
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.

Since
1.8

This is similar to ast_party_caller_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.

Parameters
destThe caller one wishes to update
srcThe new caller values to update the dest
updateWhat caller information to update. NULL if all.
Returns
Nada

Definition at line 2295 of file channel.c.

References ast_party_caller::ani, ast_set_party_caller::ani, ast_party_caller::ani2, ast_party_id_set(), ast_party_caller::id, and ast_set_party_caller::id.

Referenced by ast_channel_set_caller(), ast_channel_set_caller_event(), and callerid_write().

2296 {
2297  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2298  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2299  dest->ani2 = src->ani2;
2300 }
struct ast_set_party_id ani
Definition: channel.h:391
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.
Definition: channel.c:2118
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_set_party_id id
Definition: channel.h:389
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initCaller structure to initialize.
guideSource caller to use as a guide in initializing.
Returns
Nothing

Definition at line 2288 of file channel.c.

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set_init(), and ast_party_caller::id.

Referenced by callerid_write(), dial_exec_full(), do_forward(), misdn_update_caller_id(), ring_entry(), and sig_pri_handle_subcmds().

2289 {
2290  ast_party_id_set_init(&init->id, &guide->id);
2291  ast_party_id_set_init(&init->ani, &guide->ani);
2292  init->ani2 = guide->ani2;
2293 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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.
Definition: channel.c:2110
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.

Since
1.8
Parameters
connectedCollected caller information for the connected line
callerCaller information.
Returns
Nothing
Warning
This is a shallow copy.
DO NOT call ast_party_connected_line_free() on the filled in connected line structure!

Definition at line 2345 of file channel.c.

References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_caller::id, ast_party_connected_line::id, and ast_party_connected_line::source.

2346 {
2347  connected->id = caller->id;
2348  connected->ani = caller->ani;
2349  connected->ani2 = caller->ani2;
2351 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
int source
Information about the source of an update.
Definition: channel.h:424
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.

Since
1.8
Parameters
destDestination connected line
srcSource connected line
Returns
Nothing

Definition at line 2316 of file channel.c.

References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_connected_line::id, and ast_party_connected_line::source.

Referenced by __ast_read(), ast_call_forward(), ast_channel_connected_line_macro(), ast_do_pickup(), builtin_atxfer(), dial_exec_full(), do_forward(), local_attended_transfer(), misdn_attempt_transfer(), party_connected_line_copy_transfer(), try_calling(), and wait_for_answer().

2317 {
2318  if (dest == src) {
2319  /* Don't copy to self */
2320  return;
2321  }
2322 
2323  ast_party_id_copy(&dest->id, &src->id);
2324  ast_party_id_copy(&dest->ani, &src->ani);
2325  dest->ani2 = src->ani2;
2326  dest->source = src->source;
2327 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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.
Definition: channel.c:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_connected_line_free ( struct ast_party_connected_line doomed)

Destroy the connected line information contents.

Since
1.8
Parameters
doomedThe connected line information to destroy.
Returns
Nothing

Definition at line 2353 of file channel.c.

References ast_party_connected_line::ani, ast_party_id_free(), and ast_party_connected_line::id.

Referenced by __ast_read(), app_exec(), ast_channel_connected_line_macro(), ast_channel_destructor(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_indicate_data(), atxfer_fail_cleanup(), builtin_atxfer(), callattempt_free(), chanlist_free(), connectedline_write(), destroy_calling_tree(), feature_request_and_dial(), findmeexec(), local_attended_transfer(), misdn_attempt_transfer(), parked_call_exec(), sig_pri_handle_subcmds(), socket_process(), wait_for_answer(), wait_for_winner(), and xfer_ds_destroy().

2354 {
2355  ast_party_id_free(&doomed->id);
2356  ast_party_id_free(&doomed->ani);
2357 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
void ast_party_connected_line_init ( struct ast_party_connected_line init)

Initialize the given connected line structure.

Since
1.8
Parameters
initConnected line structure to initialize.
Returns
Nothing

Definition at line 2308 of file channel.c.

References ast_party_connected_line::ani, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_id_init(), ast_party_connected_line::id, and ast_party_connected_line::source.

Referenced by __ast_channel_alloc_ap(), __ast_read(), ast_channel_connected_line_macro(), ast_do_pickup(), builtin_atxfer(), do_forward(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_attempt_transfer(), misdn_queue_connected_line_update(), parked_call_exec(), sig_pri_handle_subcmds(), sip_call(), socket_process(), and wait_for_answer().

2309 {
2310  ast_party_id_init(&init->id);
2311  ast_party_id_init(&init->ani);
2312  init->ani2 = 0;
2314 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
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.

Since
1.8 This is similar to ast_party_connected_line_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.
Parameters
destThe connected line one wishes to update
srcThe new connected line values to update the dest
updateWhat connected line information to update. NULL if all.
Returns
Nothing

Definition at line 2337 of file channel.c.

References ast_party_connected_line::ani, ast_set_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set(), ast_party_connected_line::id, ast_set_party_connected_line::id, and ast_party_connected_line::source.

Referenced by ast_channel_set_connected_line(), wait_for_answer(), and wait_for_winner().

2338 {
2339  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2340  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2341  dest->ani2 = src->ani2;
2342  dest->source = src->source;
2343 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
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.
Definition: channel.c:2118
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
struct ast_set_party_id id
Definition: channel.h:433
struct ast_set_party_id ani
Definition: channel.h:435
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initConnected line structure to initialize.
guideSource connected line to use as a guide in initializing.
Returns
Nothing

Definition at line 2329 of file channel.c.

References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set_init(), ast_party_connected_line::id, and ast_party_connected_line::source.

Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), feature_request_and_dial(), wait_for_answer(), and wait_for_winner().

2330 {
2331  ast_party_id_set_init(&init->id, &guide->id);
2332  ast_party_id_set_init(&init->ani, &guide->ani);
2333  init->ani2 = guide->ani2;
2334  init->source = guide->source;
2335 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
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.
Definition: channel.c:2110
int source
Information about the source of an update.
Definition: channel.h:424
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.

Since
1.8
Parameters
destDestination dialed party
srcSource dialed party
Returns
Nothing

Definition at line 2227 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().

2228 {
2229  if (dest == src) {
2230  /* Don't copy to self */
2231  return;
2232  }
2233 
2234  ast_free(dest->number.str);
2235  dest->number.str = ast_strdup(src->number.str);
2236  dest->number.plan = src->number.plan;
2239 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
#define ast_strdup(a)
Definition: astmm.h:109
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. ...
Definition: channel.c:2042
struct ast_party_dialed::@155 number
Dialed/Called number.
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_dialed_free ( struct ast_party_dialed doomed)

Destroy the dialed party contents.

Since
1.8
Parameters
doomedThe dialed party to destroy.
Returns
Nothing

Definition at line 2262 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().

2263 {
2264  ast_free(doomed->number.str);
2265  doomed->number.str = NULL;
2267 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:2081
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
void ast_party_dialed_init ( struct ast_party_dialed init)

Initialize the given dialed structure.

Since
1.8
Parameters
initDialed structure to initialize.
Returns
Nothing

Definition at line 2219 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().

2220 {
2221  init->number.str = NULL;
2222  init->number.plan = 0;/* Unknown */
2224  init->transit_network_select = 0;
2225 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:2034
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.

Since
1.8

This is similar to ast_party_dialed_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.

Parameters
destThe dialed one wishes to update
srcThe new dialed values to update the dest
Returns
Nada

Definition at line 2249 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().

2250 {
2251  if (src->number.str && src->number.str != dest->number.str) {
2252  ast_free(dest->number.str);
2253  dest->number.str = ast_strdup(src->number.str);
2254  }
2255  dest->number.plan = src->number.plan;
2256 
2258 
2260 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_dialed::@155 number
Dialed/Called number.
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
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.
Definition: channel.c:2064
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initCaller structure to initialize.
guideSource dialed to use as a guide in initializing.
Returns
Nothing

Definition at line 2241 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().

2242 {
2243  init->number.str = NULL;
2244  init->number.plan = guide->number.plan;
2247 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
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...
Definition: channel.c:2056
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
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.

Since
1.8
Parameters
destDestination party id
srcSource party id
Returns
Nothing

Definition at line 2095 of file channel.c.

References ast_free, ast_party_name_copy(), ast_party_number_copy(), ast_party_subaddress_copy(), ast_strdup, ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.

Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), and parkandannounce_exec().

2096 {
2097  if (dest == src) {
2098  /* Don't copy to self */
2099  return;
2100  }
2101 
2102  ast_party_name_copy(&dest->name, &src->name);
2103  ast_party_number_copy(&dest->number, &src->number);
2105 
2106  ast_free(dest->tag);
2107  dest->tag = ast_strdup(src->tag);
2108 }
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.
Definition: channel.c:1936
#define ast_strdup(a)
Definition: astmm.h:109
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. ...
Definition: channel.c:2042
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
#define ast_free(a)
Definition: astmm.h:97
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.
Definition: channel.c:1989
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_free ( struct ast_party_id doomed)

Destroy the party id contents.

Since
1.8
Parameters
doomedThe party id to destroy.
Returns
Nothing

Definition at line 2141 of file channel.c.

References ast_free, ast_party_name_free(), ast_party_number_free(), ast_party_subaddress_free(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.

Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_redirecting_free(), parkandannounce_exec(), and sig_pri_mcid_event().

2142 {
2143  ast_party_name_free(&doomed->name);
2144  ast_party_number_free(&doomed->number);
2146 
2147  ast_free(doomed->tag);
2148  doomed->tag = NULL;
2149 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:2081
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:2028
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition: channel.c:1975
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_init ( struct ast_party_id init)

Initialize the given party id structure.

Since
1.8
Parameters
initParty id structure to initialize.
Returns
Nothing

Definition at line 2087 of file channel.c.

References ast_party_name_init(), ast_party_number_init(), ast_party_subaddress_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.

Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_redirecting_init(), dial_exec_full(), parkandannounce_exec(), and sig_pri_mcid_event().

2088 {
2089  ast_party_name_init(&init->name);
2090  ast_party_number_init(&init->number);
2092  init->tag = NULL;
2093 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1981
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition: channel.c:1928
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:2034
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
int ast_party_id_presentation ( const struct ast_party_id id)

Determine the overall presentation value for the given party.

Since
1.8
Parameters
idParty to determine the overall presentation value.
Returns
Overall presentation value for the given party.

Definition at line 2151 of file channel.c.

References AST_PRES_ALLOWED, AST_PRES_NUMBER_NOT_AVAILABLE, AST_PRES_NUMBER_TYPE, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, AST_PRES_UNAVAILABLE, AST_PRES_USER_NUMBER_UNSCREENED, ast_party_id::name, ast_party_id::number, ast_party_name::valid, and ast_party_number::valid.

Referenced by add_rpid(), ast_str_retrieve_variable(), ast_var_channels_table(), callerpres_read(), iax2_call(), initreqprep(), my_set_callerid(), oh323_call(), party_id_build_data(), party_id_read(), redirecting_read(), report_new_callerid(), setup_env(), sig_pri_event_party_id(), sig_pri_handle_subcmds(), sip_call(), and socket_process().

2152 {
2153  int number_priority;
2154  int number_value;
2155  int number_screening;
2156  int name_priority;
2157  int name_value;
2158 
2159  /* Determine name presentation priority. */
2160  if (!id->name.valid) {
2161  name_value = AST_PRES_UNAVAILABLE;
2162  name_priority = 3;
2163  } else {
2164  name_value = id->name.presentation & AST_PRES_RESTRICTION;
2165  switch (name_value) {
2166  case AST_PRES_RESTRICTED:
2167  name_priority = 0;
2168  break;
2169  case AST_PRES_ALLOWED:
2170  name_priority = 1;
2171  break;
2172  case AST_PRES_UNAVAILABLE:
2173  name_priority = 2;
2174  break;
2175  default:
2176  name_value = AST_PRES_UNAVAILABLE;
2177  name_priority = 3;
2178  break;
2179  }
2180  }
2181 
2182  /* Determine number presentation priority. */
2183  if (!id->number.valid) {
2184  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
2185  number_value = AST_PRES_UNAVAILABLE;
2186  number_priority = 3;
2187  } else {
2188  number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
2189  number_value = id->number.presentation & AST_PRES_RESTRICTION;
2190  switch (number_value) {
2191  case AST_PRES_RESTRICTED:
2192  number_priority = 0;
2193  break;
2194  case AST_PRES_ALLOWED:
2195  number_priority = 1;
2196  break;
2197  case AST_PRES_UNAVAILABLE:
2198  number_priority = 2;
2199  break;
2200  default:
2201  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
2202  number_value = AST_PRES_UNAVAILABLE;
2203  number_priority = 3;
2204  break;
2205  }
2206  }
2207 
2208  /* Select the wining presentation value. */
2209  if (name_priority < number_priority) {
2210  number_value = name_value;
2211  }
2212  if (number_value == AST_PRES_UNAVAILABLE) {
2214  }
2215 
2216  return number_value | number_screening;
2217 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define AST_PRES_RESTRICTED
Definition: callerid.h:325
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition: callerid.h:318
#define AST_PRES_NUMBER_TYPE
Definition: callerid.h:317
#define AST_PRES_NUMBER_NOT_AVAILABLE
Definition: callerid.h:353
#define AST_PRES_RESTRICTION
Definition: callerid.h:323
#define AST_PRES_ALLOWED
Definition: callerid.h:324
#define AST_PRES_UNAVAILABLE
Definition: callerid.h:326
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Since
1.8
Parameters
destThe id one wishes to update
srcThe new id values to update the dest
updateWhat id information to update. NULL if all.
Returns
Nothing

Definition at line 2118 of file channel.c.

References ast_free, ast_party_name_set(), ast_party_number_set(), ast_party_subaddress_set(), ast_strdup, ast_party_id::name, ast_set_party_id::name, ast_party_id::number, ast_set_party_id::number, ast_party_id::subaddress, ast_set_party_id::subaddress, and ast_party_id::tag.

Referenced by ast_party_caller_set(), ast_party_connected_line_set(), and ast_party_redirecting_set().

2119 {
2120  if (dest == src) {
2121  /* Don't set to self */
2122  return;
2123  }
2124 
2125  if (!update || update->name) {
2126  ast_party_name_set(&dest->name, &src->name);
2127  }
2128  if (!update || update->number) {
2129  ast_party_number_set(&dest->number, &src->number);
2130  }
2131  if (!update || update->subaddress) {
2133  }
2134 
2135  if (src->tag && src->tag != dest->tag) {
2136  ast_free(dest->tag);
2137  dest->tag = ast_strdup(src->tag);
2138  }
2139 }
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
unsigned char subaddress
Definition: channel.h:317
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
unsigned char number
Definition: channel.h:315
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.
Definition: channel.c:1958
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
unsigned char name
Definition: channel.h:313
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.
Definition: channel.c:2011
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.
Definition: channel.c:2064
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initParty id structure to initialize.
guideSource party id to use as a guide in initializing.
Returns
Nothing

Definition at line 2110 of file channel.c.

References ast_party_name_set_init(), ast_party_number_set_init(), ast_party_subaddress_set_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.

Referenced by ast_party_caller_set_init(), ast_party_connected_line_set_init(), ast_party_redirecting_set_init(), and dial_exec_full().

2111 {
2112  ast_party_name_set_init(&init->name, &guide->name);
2113  ast_party_number_set_init(&init->number, &guide->number);
2115  init->tag = NULL;
2116 }
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...
Definition: channel.c:2003
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
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...
Definition: channel.c:2056
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
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.
Definition: channel.c:1950
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Since
1.8
Parameters
destDestination party name
srcSource party name
Returns
Nothing

Definition at line 1936 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().

1937 {
1938  if (dest == src) {
1939  /* Don't copy to self */
1940  return;
1941  }
1942 
1943  ast_free(dest->str);
1944  dest->str = ast_strdup(src->str);
1945  dest->char_set = src->char_set;
1946  dest->presentation = src->presentation;
1947  dest->valid = src->valid;
1948 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_strdup(a)
Definition: astmm.h:109
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
void ast_party_name_free ( struct ast_party_name doomed)

Destroy the party name contents.

Since
1.8
Parameters
doomedThe party name to destroy.
Returns
Nothing

Definition at line 1975 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().

1976 {
1977  ast_free(doomed->str);
1978  doomed->str = NULL;
1979 }
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
void ast_party_name_init ( struct ast_party_name init)

Initialize the given name structure.

Since
1.8
Parameters
initName structure to initialize.
Returns
Nothing

Definition at line 1928 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().

1929 {
1930  init->str = NULL;
1933  init->valid = 0;
1934 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
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.

Since
1.8
Parameters
destThe name one wishes to update
srcThe new name values to update the dest
Returns
Nothing

Definition at line 1958 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().

1959 {
1960  if (dest == src) {
1961  /* Don't set to self */
1962  return;
1963  }
1964 
1965  if (src->str && src->str != dest->str) {
1966  ast_free(dest->str);
1967  dest->str = ast_strdup(src->str);
1968  }
1969 
1970  dest->char_set = src->char_set;
1971  dest->presentation = src->presentation;
1972  dest->valid = src->valid;
1973 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_strdup(a)
Definition: astmm.h:109
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initParty name structure to initialize.
guideSource party name to use as a guide in initializing.
Returns
Nothing

Definition at line 1950 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().

1951 {
1952  init->str = NULL;
1953  init->char_set = guide->char_set;
1954  init->presentation = guide->presentation;
1955  init->valid = guide->valid;
1956 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
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.

Since
1.8
Parameters
destDestination party number
srcSource party number
Returns
Nothing

Definition at line 1989 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().

1990 {
1991  if (dest == src) {
1992  /* Don't copy to self */
1993  return;
1994  }
1995 
1996  ast_free(dest->str);
1997  dest->str = ast_strdup(src->str);
1998  dest->plan = src->plan;
1999  dest->presentation = src->presentation;
2000  dest->valid = src->valid;
2001 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define ast_strdup(a)
Definition: astmm.h:109
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
void ast_party_number_free ( struct ast_party_number doomed)

Destroy the party number contents.

Since
1.8
Parameters
doomedThe party number to destroy.
Returns
Nothing

Definition at line 2028 of file channel.c.

References ast_free, and ast_party_number::str.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), do_forward(), skinny_newcall(), and wait_for_answer().

2029 {
2030  ast_free(doomed->str);
2031  doomed->str = NULL;
2032 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
#define ast_free(a)
Definition: astmm.h:97
void ast_party_number_init ( struct ast_party_number init)

Initialize the given number structure.

Since
1.8
Parameters
initNumber structure to initialize.
Returns
Nothing

Definition at line 1981 of file channel.c.

References AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), do_forward(), skinny_newcall(), and wait_for_answer().

1982 {
1983  init->str = NULL;
1984  init->plan = 0;/* Unknown */
1986  init->valid = 0;
1987 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
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.

Since
1.8
Parameters
destThe number one wishes to update
srcThe new number values to update the dest
Returns
Nothing

Definition at line 2011 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().

2012 {
2013  if (dest == src) {
2014  /* Don't set to self */
2015  return;
2016  }
2017 
2018  if (src->str && src->str != dest->str) {
2019  ast_free(dest->str);
2020  dest->str = ast_strdup(src->str);
2021  }
2022 
2023  dest->plan = src->plan;
2024  dest->presentation = src->presentation;
2025  dest->valid = src->valid;
2026 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define ast_strdup(a)
Definition: astmm.h:109
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initParty number structure to initialize.
guideSource party number to use as a guide in initializing.
Returns
Nothing

Definition at line 2003 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().

2004 {
2005  init->str = NULL;
2006  init->plan = guide->plan;
2007  init->presentation = guide->presentation;
2008  init->valid = guide->valid;
2009 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
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.

Since
1.8
Parameters
destDestination redirecting
srcSource redirecting
Returns
Nothing

Definition at line 2367 of file channel.c.

References ast_party_id_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by ast_call_forward(), ast_channel_redirecting_macro(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), do_forward(), local_call(), ring_entry(), and wait_for_answer().

2368 {
2369  if (dest == src) {
2370  /* Don't copy to self */
2371  return;
2372  }
2373 
2374  ast_party_id_copy(&dest->from, &src->from);
2375  ast_party_id_copy(&dest->to, &src->to);
2376  dest->count = src->count;
2377  dest->reason = src->reason;
2378 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
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.
Definition: channel.c:2095
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

Destroy the redirecting information contents.

Since
1.8
Parameters
doomedThe redirecting information to destroy.
Returns
Nothing

Definition at line 2396 of file channel.c.

References ast_party_id_free(), ast_party_redirecting::from, and ast_party_redirecting::to.

Referenced by ast_channel_destructor(), ast_channel_redirecting_macro(), ast_dummy_channel_destructor(), ast_indicate_data(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().

2397 {
2398  ast_party_id_free(&doomed->from);
2399  ast_party_id_free(&doomed->to);
2400 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
void ast_party_redirecting_init ( struct ast_party_redirecting init)

Initialize the given redirecting structure.

Since
1.8
Parameters
initRedirecting structure to initialize.
Returns
Nothing

Definition at line 2359 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(), ast_channel_redirecting_macro(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), and wait_for_answer().

2360 {
2361  ast_party_id_init(&init->from);
2362  ast_party_id_init(&init->to);
2363  init->count = 0;
2365 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
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.

Since
1.8

This is similar to ast_party_redirecting_copy, except that NULL values for strings in the src parameter indicate not to update the corresponding dest values.

Parameters
destThe redirecting one wishes to update
srcThe new redirecting values to update the dest
updateWhat redirecting information to update. NULL if all.
Returns
Nothing

Definition at line 2388 of file channel.c.

References ast_party_id_set(), ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, ast_party_redirecting::reason, ast_party_redirecting::to, and ast_set_party_redirecting::to.

Referenced by ast_channel_set_redirecting().

2389 {
2390  ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2391  ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2392  dest->reason = src->reason;
2393  dest->count = src->count;
2394 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
struct ast_set_party_id from
Definition: channel.h:467
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.
Definition: channel.c:2118
struct ast_set_party_id to
Definition: channel.h:469
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initRedirecting id structure to initialize.
guideSource redirecting id to use as a guide in initializing.
Returns
Nothing

Definition at line 2380 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().

2381 {
2382  ast_party_id_set_init(&init->from, &guide->from);
2383  ast_party_id_set_init(&init->to, &guide->to);
2384  init->count = guide->count;
2385  init->reason = guide->reason;
2386 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
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.
Definition: channel.c:2110
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
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.

Since
1.8
Parameters
destDestination party subaddress
srcSource party subaddress
Returns
Nothing

Definition at line 2042 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().

2043 {
2044  if (dest == src) {
2045  /* Don't copy to self */
2046  return;
2047  }
2048 
2049  ast_free(dest->str);
2050  dest->str = ast_strdup(src->str);
2051  dest->type = src->type;
2053  dest->valid = src->valid;
2054 }
#define ast_strdup(a)
Definition: astmm.h:109
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
#define ast_free(a)
Definition: astmm.h:97
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_party_subaddress_free ( struct ast_party_subaddress doomed)

Destroy the party subaddress contents.

Since
1.8
Parameters
doomedThe party subaddress to destroy.
Returns
Nothing

Definition at line 2081 of file channel.c.

References ast_free, and ast_party_subaddress::str.

Referenced by ast_party_dialed_free(), ast_party_id_free(), and pri_dchannel().

2082 {
2083  ast_free(doomed->str);
2084  doomed->str = NULL;
2085 }
char * str
Malloced subaddress string.
Definition: channel.h:263
#define ast_free(a)
Definition: astmm.h:97
void ast_party_subaddress_init ( struct ast_party_subaddress init)

Initialize the given subaddress structure.

Since
1.8
Parameters
initSubaddress structure to initialize.
Returns
Nothing

Definition at line 2034 of file channel.c.

References ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.

Referenced by ast_party_dialed_init(), ast_party_id_init(), pri_dchannel(), sig_pri_call(), and sig_pri_set_subaddress().

2035 {
2036  init->str = NULL;
2037  init->type = 0;
2038  init->odd_even_indicator = 0;
2039  init->valid = 0;
2040 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
int type
Q.931 subaddress type.
Definition: channel.h:270
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.

Since
1.8
Parameters
destThe subaddress one wishes to update
srcThe new subaddress values to update the dest
Returns
Nothing

Definition at line 2064 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(), and ast_party_id_set().

2065 {
2066  if (dest == src) {
2067  /* Don't set to self */
2068  return;
2069  }
2070 
2071  if (src->str && src->str != dest->str) {
2072  ast_free(dest->str);
2073  dest->str = ast_strdup(src->str);
2074  }
2075 
2076  dest->type = src->type;
2078  dest->valid = src->valid;
2079 }
#define ast_strdup(a)
Definition: astmm.h:109
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
#define ast_free(a)
Definition: astmm.h:97
int type
Q.931 subaddress type.
Definition: channel.h:270
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.

Since
1.8

The initialization is needed to allow a set operation to know if a value needs to be updated. Simple integers need the guide's original value in case the set operation is not trying to set a new value. String values are simply set to NULL pointers if they are not going to be updated.

Parameters
initParty subaddress structure to initialize.
guideSource party subaddress to use as a guide in initializing.
Returns
Nothing

Definition at line 2056 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().

2057 {
2058  init->str = NULL;
2059  init->type = guide->type;
2060  init->odd_even_indicator = guide->odd_even_indicator;
2061  init->valid = guide->valid;
2062 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_poll_channel_add ( struct ast_channel chan0,
struct ast_channel chan1 
)

Add a channel to an optimized waitfor

Definition at line 2665 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().

2666 {
2667 #ifdef HAVE_EPOLL
2668  struct epoll_event ev;
2669  int i = 0;
2670 
2671  if (chan0->epfd == -1)
2672  return;
2673 
2674  /* Iterate through the file descriptors on chan1, adding them to chan0 */
2675  for (i = 0; i < AST_MAX_FDS; i++) {
2676  if (chan1->fds[i] == -1)
2677  continue;
2678  ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
2679  ev.data.ptr = chan1->epfd_data[i];
2680  epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev);
2681  }
2682 
2683 #endif
2684  return;
2685 }
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define AST_MAX_FDS
Definition: channel.h:158
void ast_poll_channel_del ( struct ast_channel chan0,
struct ast_channel chan1 
)

Delete a channel from an optimized waitfor

Definition at line 2688 of file channel.c.

References AST_MAX_FDS, and ast_channel::fds.

Referenced by ast_generic_bridge(), feature_request_and_dial(), local_bridge_loop(), monitor_dial(), remote_bridge_loop(), and wait_for_answer().

2689 {
2690 #ifdef HAVE_EPOLL
2691  struct epoll_event ev;
2692  int i = 0;
2693 
2694  if (chan0->epfd == -1)
2695  return;
2696 
2697  for (i = 0; i < AST_MAX_FDS; i++) {
2698  if (chan1->fds[i] == -1)
2699  continue;
2700  epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev);
2701  }
2702 
2703 #endif
2704  return;
2705 }
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define AST_MAX_FDS
Definition: channel.h:158
char* ast_print_group ( char *  buf,
int  buflen,
ast_group_t  group 
)

print call- and pickup groups into buffer

print call- and pickup groups into buffer

Definition at line 8236 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().

8237 {
8238  unsigned int i;
8239  int first = 1;
8240  char num[3];
8241 
8242  buf[0] = '\0';
8243 
8244  if (!group) /* Return empty string if no group */
8245  return buf;
8246 
8247  for (i = 0; i <= 63; i++) { /* Max group is 63 */
8248  if (group & ((ast_group_t) 1 << i)) {
8249  if (!first) {
8250  strncat(buf, ", ", buflen - strlen(buf) - 1);
8251  } else {
8252  first = 0;
8253  }
8254  snprintf(num, sizeof(num), "%u", i);
8255  strncat(buf, num, buflen - strlen(buf) - 1);
8256  }
8257  }
8258  return buf;
8259 }
unsigned long long ast_group_t
Definition: channel.h:175
struct sla_ringing_trunk * first
Definition: app_meetme.c:965
int ast_prod ( struct ast_channel chan)

Send empty audio to prime a channel driver.

Definition at line 4784 of file channel.c.

References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), ast_frame_subclass::codec, ast_frame::data, LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.

Referenced by ast_activate_generator().

4785 {
4786  struct ast_frame a = { AST_FRAME_VOICE };
4787  char nothing[128];
4788 
4789  /* Send an empty audio frame to get things moving */
4790  if (chan->_state != AST_STATE_UP) {
4791  ast_debug(1, "Prodding channel '%s'\n", chan->name);
4792  a.subclass.codec = chan->rawwriteformat;
4793  a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
4794  a.src = "ast_prod"; /* this better match check in ast_write */
4795  if (ast_write(chan, &a))
4796  ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name);
4797  }
4798  return 0;
4799 }
union ast_frame_subclass subclass
Definition: frame.h:146
void * ptr
Definition: frame.h:160
#define LOG_WARNING
Definition: logger.h:144
format_t rawwriteformat
Definition: channel.h:856
format_t codec
Definition: frame.h:137
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
const char * src
Definition: frame.h:158
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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.
Definition: channel.c:4916
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
int ast_queue_control ( struct ast_channel chan,
enum ast_control_frame_type  control 
)

Queue a control frame with payload.

Parameters
chanchannel to queue frame onto
controltype of control frame
Note
The channel does not need to be locked before calling this function.
Return values
zeroon success
non-zeroon failure

Queue a control frame with payload.

Definition at line 1601 of file channel.c.

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), analog_call(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_do_pickup(), attempt_transfer(), auto_congest(), cb_events(), cli_console_answer(), cli_console_flash(), console_answer(), console_call(), console_sendtext(), dahdi_handle_event(), dahdi_hangup(), gtalk_is_answered(), gtalk_ringing_ack(), handle_hd_hf(), handle_incoming(), handle_offhook_message(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), handle_response_refer(), handle_soft_key_event_message(), handle_stimulus_message(), HandleCallIncoming(), jingle_is_answered(), jingle_ringing_ack(), masquerade_colp_transfer(), misdn_facility_ie_handler(), multicast_rtp_call(), nbs_call(), phone_call(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), skinny_call(), skinny_transfer(), skinny_unhold(), unistim_call(), and update_state().

1602 {
1603  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
1604  return ast_queue_frame(chan, &f);
1605 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
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.

Parameters
chanchannel to queue frame onto
controltype of control frame
datapointer to payload data to be included in frame
datalennumber of bytes of payload data
Return values
0success
non-zerofailure

The supplied payload data is copied into the frame, so the caller's copy is not modified nor freed, and the resulting frame will retain a copy of the data even if the caller frees their local copy.

Note
This method should be treated as a 'network transport'; in other words, your frames may be transferred across an IAX2 channel to another system, which may be a different endianness than yours. Because of this, you should ensure that either your frames will never be expected to work across systems, or that you always put your payload data into 'network byte order' before calling this function.
The channel does not need to be locked before calling this function.

Definition at line 1608 of file channel.c.

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), analog_hangup(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), change_t38_state(), dahdi_handle_event(), dahdi_hangup(), handle_request_notify(), handle_response_refer(), iax2_queue_control_data(), iax2_transfer(), interpret_t38_parameters(), local_attended_transfer(), masquerade_colp_transfer(), process_sdp(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), sip_sipredirect(), and skinny_hold().

1610 {
1611  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1612  return ast_queue_frame(chan, &f);
1613 }
int datalen
Definition: frame.h:148
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
int ast_queue_frame ( struct ast_channel chan,
struct ast_frame f 
)

Queue one or more frames to a channel's frame queue.

Parameters
chanthe channel to queue the frame(s) on
fthe 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.
Return values
0success
non-zerofailure

Definition at line 1558 of file channel.c.

References __ast_queue_frame().

Referenced by __ast_channel_masquerade(), __ast_read(), __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_request(), alsa_call(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), ast_dsp_process(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), bridge_write(), cb_events(), cli_console_dial(), cli_console_sendtext(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), do_immediate_setup(), gtalk_handle_dtmf(), handle_keypad_button_message(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), jingle_handle_dtmf(), keypad_digit(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), oss_call(), pri_queue_frame(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), sig_pri_dial_complete(), sig_pri_handle_hold(), sig_pri_handle_subcmds(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), and wakeup_sub().

1559 {
1560  return __ast_queue_frame(chan, fin, 0, NULL);
1561 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1438
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.

Parameters
chanthe channel to queue the frame(s) on
fthe 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.
Return values
0success
non-zerofailure

Definition at line 1563 of file channel.c.

References __ast_queue_frame().

Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), ast_safe_sleep_conditional(), and feature_request_and_dial().

1564 {
1565  return __ast_queue_frame(chan, fin, 1, NULL);
1566 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1438
int ast_queue_hangup ( struct ast_channel chan)

Queue a hangup frame.

Note
The channel does not need to be locked before calling this function.

Queue a hangup frame.

Definition at line 1569 of file channel.c.

References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), and AST_SOFTHANGUP_DEV.

Referenced by bridge_queue_hangup(), cleanup_connection(), cli_console_hangup(), close_call(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_soft_key_event_message(), iax2_destroy(), iax2_queue_hangup(), jingle_hangup_farend(), local_fixup(), local_hangup(), mgcp_queue_hangup(), and sip_queue_hangup_cause().

1570 {
1571  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1572  /* Yeah, let's not change a lock-critical value without locking */
1573  if (!ast_channel_trylock(chan)) {
1575  ast_channel_unlock(chan);
1576  }
1577  return ast_queue_frame(chan, &f);
1578 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_channel_trylock(chan)
Definition: channel.h:2468
int ast_queue_hangup_with_cause ( struct ast_channel chan,
int  cause 
)

Queue a hangup frame with hangupcause set.

Note
The channel does not need to be locked before calling this function.
Parameters
[in]chanchannel to queue frame onto
[in]causethe hangup cause
Returns
0 on success, -1 on error
Since
1.6.1

Queue a hangup frame with hangupcause set.

Definition at line 1581 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, ast_frame::data, ast_channel::hangupcause, and ast_frame::uint32.

Referenced by __analog_handle_event(), __oh323_update_info(), __sip_autodestruct(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), dahdi_r2_on_call_disconnect(), handle_request_bye(), handle_response(), handle_response_invite(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), local_hangup(), misdn_answer(), retrans_pkt(), sip_queue_hangup_cause(), and TransferCallStep1().

1582 {
1583  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1584 
1585  if (cause >= 0)
1586  f.data.uint32 = cause;
1587 
1588  /* Yeah, let's not change a lock-critical value without locking */
1589  if (!ast_channel_trylock(chan)) {
1591  if (cause < 0)
1592  f.data.uint32 = chan->hangupcause;
1593 
1594  ast_channel_unlock(chan);
1595  }
1596 
1597  return ast_queue_frame(chan, &f);
1598 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
uint32_t uint32
Definition: frame.h:160
#define ast_channel_trylock(chan)
Definition: channel.h:2468
union ast_frame::@172 data
int ast_raw_answer ( struct ast_channel chan,
int  cdr_answer 
)

Answer a channel.

Parameters
chanchannel to answer
cdr_answerflag to control whether any associated CDR should be marked as 'answered'

This function answers a channel and handles all necessary call setup functions.

Note
The channel passed does not need to be locked, but is locked by the function when needed.
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.
Return values
0on success
non-zeroon failure

Definition at line 2930 of file channel.c.

References ast_channel::_state, ast_channel_tech::answer, ast_cdr_answer(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, ast_channel::cdr, and ast_channel::tech.

Referenced by __ast_answer(), and ast_bridge_call().

2931 {
2932  int res = 0;
2933 
2934  ast_channel_lock(chan);
2935 
2936  /* You can't answer an outbound call */
2937  if (ast_test_flag(chan, AST_FLAG_OUTGOING)) {
2938  ast_channel_unlock(chan);
2939  return 0;
2940  }
2941 
2942  /* Stop if we're a zombie or need a soft hangup */
2943  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
2944  ast_channel_unlock(chan);
2945  return -1;
2946  }
2947 
2948  ast_channel_unlock(chan);
2949 
2950  switch (chan->_state) {
2951  case AST_STATE_RINGING:
2952  case AST_STATE_RING:
2953  ast_channel_lock(chan);
2954  if (chan->tech->answer) {
2955  res = chan->tech->answer(chan);
2956  }
2957  ast_setstate(chan, AST_STATE_UP);
2958  if (cdr_answer) {
2959  ast_cdr_answer(chan->cdr);
2960  }
2961  ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
2962  ast_channel_unlock(chan);
2963  break;
2964  case AST_STATE_UP:
2965  ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
2966  /* Calling ast_cdr_answer when it it has previously been called
2967  * is essentially a no-op, so it is safe.
2968  */
2969  if (cdr_answer) {
2970  ast_cdr_answer(chan->cdr);
2971  }
2972  break;
2973  default:
2974  break;
2975  }
2976 
2977  ast_indicate(chan, -1);
2978 
2979  return res;
2980 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_cdr * cdr
Definition: channel.h:766
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:548
void ast_cdr_answer(struct ast_cdr *cdr)
Answer a call.
Definition: cdr.c:737
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
enum ast_channel_state _state
Definition: channel.h:839
#define ast_channel_unlock(chan)
Definition: channel.h:2467
A ringing phone is answered.
Definition: cel.h:56
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_frame* ast_read ( struct ast_channel chan)

Reads a frame.

Parameters
chanchannel to read a frame from
Returns
Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected.

Definition at line 4383 of file channel.c.

References __ast_read().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), analog_ss_thread(), ast_bridge_handle_trip(), ast_generic_bridge(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), async_agi_read_frame(), async_wait(), autoservice_run(), background_detect_exec(), channel_spy(), conf_flush(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_bridge(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), eivr_comm(), feature_request_and_dial(), find_cache(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), iax2_bridge(), ices_exec(), isAnsweringMachine(), jack_exec(), local_bridge_loop(), manage_parked_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), remote_bridge_loop(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

4384 {
4385  return __ast_read(chan, 0);
4386 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio)
Definition: channel.c:3836
struct ast_frame* ast_read_noaudio ( struct ast_channel chan)

Reads a frame, returning AST_FRAME_NULL frame if audio.

Parameters
chanchannel to read a frame from
Returns
Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected.
Note
Audio is replaced with AST_FRAME_NULL to avoid transcode when the resulting audio is not necessary.

Definition at line 4388 of file channel.c.

References __ast_read().

Referenced by ast_bridge_handle_trip(), and conf_run().

4389 {
4390  return __ast_read(chan, 1);
4391 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio)
Definition: channel.c:3836
int ast_readstring ( struct ast_channel c,
char *  s,
int  len,
int  timeout,
int  rtimeout,
char *  enders 
)

Reads multiple digits.

Parameters
cchannel to read from
sstring to read in to. Must be at least the size of your length
lenhow many digits to read (maximum)
timeouthow long to timeout between digits
rtimeouttimeout to wait on the first digit
endersdigits to end the string

Read in a digit string "s", max length "len", maximum timeout between digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout for the first digit.

Returns
Returns 0 on normal return, or 1 on a timeout. In the case of a timeout, any digits that were read before the timeout will still be available in s. RETURNS 2 in full version when ctrlfd is available, NOT 1

Definition at line 5837 of file channel.c.

References ast_readstring_full().

Referenced by __adsi_transmit_messages(), adsi_begin_download(), adsi_get_cpeinfo(), adsi_load_session(), ast_app_getdata(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser(), and vm_options().

5838 {
5839  return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
5840 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
Definition: channel.c:5842
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 5842 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().

5843 {
5844  int pos = 0; /* index in the buffer where we accumulate digits */
5845  int to = ftimeout;
5846 
5847  struct ast_silence_generator *silgen = NULL;
5848 
5849  /* Stop if we're a zombie or need a soft hangup */
5851  return -1;
5852  if (!len)
5853  return -1;
5854  for (;;) {
5855  int d;
5856  if (c->stream) {
5857  d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
5858  ast_stopstream(c);
5859  if (!silgen && ast_opt_transmit_silence)
5861  usleep(1000);
5862  if (!d)
5863  d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
5864  } else {
5865  if (!silgen && ast_opt_transmit_silence)
5867  d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
5868  }
5869  if (d < 0) {
5871  return AST_GETDATA_FAILED;
5872  }
5873  if (d == 0) {
5874  s[pos] = '\0';
5876  return AST_GETDATA_TIMEOUT;
5877  }
5878  if (d == 1) {
5879  s[pos] = '\0';
5881  return AST_GETDATA_INTERRUPTED;
5882  }
5883  if (strchr(enders, d) && (pos == 0)) {
5884  s[pos] = '\0';
5887  }
5888  if (!strchr(enders, d)) {
5889  s[pos++] = d;
5890  }
5891  if (strchr(enders, d) || (pos >= len)) {
5892  s[pos] = '\0';
5894  return AST_GETDATA_COMPLETE;
5895  }
5896  to = timeout;
5897  }
5898  /* Never reached */
5899  return 0;
5900 }
#define AST_DIGIT_ANY
Definition: file.h:47
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_opt_transmit_silence
Definition: options.h:120
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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.
Definition: channel.c:8355
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 mon...
Definition: channel.c:3616
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
Definition: file.c:1348
struct ast_filestream * stream
Definition: channel.h:757
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:128
int ast_recvchar ( struct ast_channel chan,
int  timeout 
)

Receives a text character from a channel.

Parameters
chanchannel to act upon
timeouttimeout in milliseconds (0 for infinite wait)

Read a char of text from a channel

Returns
0 on success, -1 on failure

Definition at line 4642 of file channel.c.

References ast_free, and ast_recvtext().

Referenced by handle_recvchar().

4643 {
4644  int c;
4645  char *buf = ast_recvtext(chan, timeout);
4646  if (buf == NULL)
4647  return -1; /* error or timeout */
4648  c = *(unsigned char *)buf;
4649  ast_free(buf);
4650  return c;
4651 }
char * ast_recvtext(struct ast_channel *chan, int timeout)
Receives a text string from a channel Read a string of text from a channel.
Definition: channel.c:4653
#define ast_free(a)
Definition: astmm.h:97
char* ast_recvtext ( struct ast_channel chan,
int  timeout 
)

Receives a text string from a channel Read a string of text from a channel.

Parameters
chanchannel to act upon
timeouttimeout in milliseconds (0 for infinite wait)
Returns
the received text, or NULL to signify failure.

Definition at line 4653 of file channel.c.

References ast_check_hangup(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_TEXT, ast_frfree, ast_read(), ast_remaining_ms(), ast_strndup, ast_tvnow(), ast_waitfor(), ast_frame::data, ast_frame::datalen, f, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, and ast_frame::subclass.

Referenced by ast_recvchar(), and handle_recvtext().

4654 {
4655  int res;
4656  char *buf = NULL;
4657  struct timeval start = ast_tvnow();
4658  int ms;
4659 
4660  while ((ms = ast_remaining_ms(start, timeout))) {
4661  struct ast_frame *f;
4662 
4663  if (ast_check_hangup(chan)) {
4664  break;
4665  }
4666  res = ast_waitfor(chan, ms);
4667  if (res <= 0) {/* timeout or error */
4668  break;
4669  }
4670  f = ast_read(chan);
4671  if (f == NULL) {
4672  break; /* no frame */
4673  }
4675  ast_frfree(f);
4676  break;
4677  } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4678  buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4679  ast_frfree(f);
4680  break;
4681  }
4682  ast_frfree(f);
4683  }
4684  return buf;
4685 }
union ast_frame_subclass subclass
Definition: frame.h:146
void * ptr
Definition: frame.h:160
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int datalen
Definition: frame.h:148
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
static struct ast_format f[]
Definition: format_g726.c:181
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
#define ast_strndup(a, b)
Definition: astmm.h:115
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.

Since
1.8
Parameters
dataBuffer to fill with the frame data
datalenSize of the buffer to fill
redirectingRedirecting id information
updateWhat redirecting information to build. NULL if all.
Return values
-1if error
Amountof data buffer used

Definition at line 9161 of file channel.c.

References ast_log(), AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_redirecting::reason, ast_party_name_ies::str, ast_party_redirecting::to, ast_set_party_redirecting::to, and value.

Referenced by ast_channel_queue_redirecting_update(), ast_channel_update_redirecting(), and local_indicate().

9162 {
9163  int32_t value;
9164  size_t pos = 0;
9165  int res;
9166 
9167  static const struct ast_party_id_ies from_ies = {
9169  .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9170  .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9171  .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9172 
9173  .number.str = AST_REDIRECTING_FROM_NUMBER,
9174  .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9175  .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9176  .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9177 
9178  .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9179  .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9180  .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9181  .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9182 
9183  .tag = AST_REDIRECTING_FROM_TAG,
9184  .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9185  };
9186  static const struct ast_party_id_ies to_ies = {
9188  .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9189  .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9190  .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9191 
9192  .number.str = AST_REDIRECTING_TO_NUMBER,
9193  .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9194  .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9195  .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9196 
9197  .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9198  .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9199  .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9200  .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9201 
9202  .tag = AST_REDIRECTING_TO_TAG,
9203  .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9204  };
9205 
9206  /* Redirecting frame version */
9207  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9208  ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9209  return -1;
9210  }
9211  data[pos++] = AST_REDIRECTING_VERSION;
9212  data[pos++] = 1;
9213  data[pos++] = 2;/* Version 1 did not have a version ie */
9214 
9215  res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9216  "redirecting-from", &from_ies, update ? &update->from : NULL);
9217  if (res < 0) {
9218  return -1;
9219  }
9220  pos += res;
9221 
9222  res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9223  "redirecting-to", &to_ies, update ? &update->to : NULL);
9224  if (res < 0) {
9225  return -1;
9226  }
9227  pos += res;
9228 
9229  /* Redirecting reason */
9230  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9231  ast_log(LOG_WARNING, "No space left for redirecting reason\n");
9232  return -1;
9233  }
9234  data[pos++] = AST_REDIRECTING_REASON;
9235  data[pos++] = sizeof(value);
9236  value = htonl(redirecting->reason);
9237  memcpy(data + pos, &value, sizeof(value));
9238  pos += sizeof(value);
9239 
9240  /* Redirecting count */
9241  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9242  ast_log(LOG_WARNING, "No space left for redirecting count\n");
9243  return -1;
9244  }
9245  data[pos++] = AST_REDIRECTING_COUNT;
9246  data[pos++] = sizeof(value);
9247  value = htonl(redirecting->count);
9248  memcpy(data + pos, &value, sizeof(value));
9249  pos += sizeof(value);
9250 
9251  return pos;
9252 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8696
struct ast_set_party_id from
Definition: channel.h:467
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int party_id_build_data(unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update)
Definition: channel.c:8722
struct ast_set_party_id to
Definition: channel.h:469
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
int str
Subscriber name ie.
Definition: channel.c:8473
int ast_redirecting_parse_data ( const unsigned char *  data,
size_t  datalen,
struct ast_party_redirecting redirecting 
)

Parse redirecting indication frame data.

Since
1.8
Parameters
dataBuffer with the frame data to parse
datalenSize of the buffer
redirectingExtracted redirecting id information
Return values
0on success.
-1on error.
Note
The filled in id structure needs to be initialized by ast_party_redirecting_set_init() before calling.
The filled in id structure needs to be destroyed by ast_party_redirecting_free() when it is no longer needed.

Definition at line 9254 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().

9255 {
9256  size_t pos;
9257  unsigned char ie_len;
9258  unsigned char ie_id;
9259  int32_t value;
9260  int frame_version = 1;
9261  int from_combined_presentation = 0;
9262  int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9263  int to_combined_presentation = 0;
9264  int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9265 
9266  for (pos = 0; pos < datalen; pos += ie_len) {
9267  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9268  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9269  return -1;
9270  }
9271  ie_id = data[pos++];
9272  ie_len = data[pos++];
9273  if (datalen < pos + ie_len) {
9274  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9275  return -1;
9276  }
9277 
9278  switch (ie_id) {
9279 /* Redirecting frame version */
9281  if (ie_len != 1) {
9282  ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9283  (unsigned) ie_len);
9284  break;
9285  }
9286  frame_version = data[pos];
9287  break;
9288 /* Redirecting-from party id name */
9290  ast_free(redirecting->from.name.str);
9291  redirecting->from.name.str = ast_malloc(ie_len + 1);
9292  if (redirecting->from.name.str) {
9293  memcpy(redirecting->from.name.str, data + pos, ie_len);
9294  redirecting->from.name.str[ie_len] = 0;
9295  }
9296  break;
9298  if (ie_len != 1) {
9299  ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9300  (unsigned) ie_len);
9301  break;
9302  }
9303  redirecting->from.name.char_set = data[pos];
9304  break;
9306  if (ie_len != 1) {
9307  ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9308  (unsigned) ie_len);
9309  break;
9310  }
9311  redirecting->from.name.presentation = data[pos];
9312  break;
9314  if (ie_len != 1) {
9315  ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9316  (unsigned) ie_len);
9317  break;
9318  }
9319  redirecting->from.name.valid = data[pos];
9320  break;
9321 /* Redirecting-from party id number */
9323  ast_free(redirecting->from.number.str);
9324  redirecting->from.number.str = ast_malloc(ie_len + 1);
9325  if (redirecting->from.number.str) {
9326  memcpy(redirecting->from.number.str, data + pos, ie_len);
9327  redirecting->from.number.str[ie_len] = 0;
9328  }
9329  break;
9331  if (ie_len != 1) {
9332  ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9333  (unsigned) ie_len);
9334  break;
9335  }
9336  redirecting->from.number.plan = data[pos];
9337  break;
9339  if (ie_len != 1) {
9340  ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9341  (unsigned) ie_len);
9342  break;
9343  }
9344  redirecting->from.number.presentation = data[pos];
9345  break;
9347  if (ie_len != 1) {
9348  ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9349  (unsigned) ie_len);
9350  break;
9351  }
9352  redirecting->from.number.valid = data[pos];
9353  break;
9354 /* Redirecting-from party id combined presentation */
9356  if (ie_len != 1) {
9357  ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9358  (unsigned) ie_len);
9359  break;
9360  }
9361  from_combined_presentation = data[pos];
9362  got_from_combined_presentation = 1;
9363  break;
9364 /* Redirecting-from party id subaddress */
9366  ast_free(redirecting->from.subaddress.str);
9367  redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9368  if (redirecting->from.subaddress.str) {
9369  memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9370  redirecting->from.subaddress.str[ie_len] = 0;
9371  }
9372  break;
9374  if (ie_len != 1) {
9375  ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9376  (unsigned) ie_len);
9377  break;
9378  }
9379  redirecting->from.subaddress.type = data[pos];
9380  break;
9382  if (ie_len != 1) {
9384  "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9385  (unsigned) ie_len);
9386  break;
9387  }
9388  redirecting->from.subaddress.odd_even_indicator = data[pos];
9389  break;
9391  if (ie_len != 1) {
9392  ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9393  (unsigned) ie_len);
9394  break;
9395  }
9396  redirecting->from.subaddress.valid = data[pos];
9397  break;
9398 /* Redirecting-from party id tag */
9400  ast_free(redirecting->from.tag);
9401  redirecting->from.tag = ast_malloc(ie_len + 1);
9402  if (redirecting->from.tag) {
9403  memcpy(redirecting->from.tag, data + pos, ie_len);
9404  redirecting->from.tag[ie_len] = 0;
9405  }
9406  break;
9407 /* Redirecting-to party id name */
9409  ast_free(redirecting->to.name.str);
9410  redirecting->to.name.str = ast_malloc(ie_len + 1);
9411  if (redirecting->to.name.str) {
9412  memcpy(redirecting->to.name.str, data + pos, ie_len);
9413  redirecting->to.name.str[ie_len] = 0;
9414  }
9415  break;
9417  if (ie_len != 1) {
9418  ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9419  (unsigned) ie_len);
9420  break;
9421  }
9422  redirecting->to.name.char_set = data[pos];
9423  break;
9425  if (ie_len != 1) {
9426  ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9427  (unsigned) ie_len);
9428  break;
9429  }
9430  redirecting->to.name.presentation = data[pos];
9431  break;
9433  if (ie_len != 1) {
9434  ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9435  (unsigned) ie_len);
9436  break;
9437  }
9438  redirecting->to.name.valid = data[pos];
9439  break;
9440 /* Redirecting-to party id number */
9442  ast_free(redirecting->to.number.str);
9443  redirecting->to.number.str = ast_malloc(ie_len + 1);
9444  if (redirecting->to.number.str) {
9445  memcpy(redirecting->to.number.str, data + pos, ie_len);
9446  redirecting->to.number.str[ie_len] = 0;
9447  }
9448  break;
9450  if (ie_len != 1) {
9451  ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9452  (unsigned) ie_len);
9453  break;
9454  }
9455  redirecting->to.number.plan = data[pos];
9456  break;
9458  if (ie_len != 1) {
9459  ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9460  (unsigned) ie_len);
9461  break;
9462  }
9463  redirecting->to.number.presentation = data[pos];
9464  break;
9466  if (ie_len != 1) {
9467  ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9468  (unsigned) ie_len);
9469  break;
9470  }
9471  redirecting->to.number.valid = data[pos];
9472  break;
9473 /* Redirecting-to party id combined presentation */
9475  if (ie_len != 1) {
9476  ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9477  (unsigned) ie_len);
9478  break;
9479  }
9480  to_combined_presentation = data[pos];
9481  got_to_combined_presentation = 1;
9482  break;
9483 /* Redirecting-to party id subaddress */
9485  ast_free(redirecting->to.subaddress.str);
9486  redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9487  if (redirecting->to.subaddress.str) {
9488  memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9489  redirecting->to.subaddress.str[ie_len] = 0;
9490  }
9491  break;
9493  if (ie_len != 1) {
9494  ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9495  (unsigned) ie_len);
9496  break;
9497  }
9498  redirecting->to.subaddress.type = data[pos];
9499  break;
9501  if (ie_len != 1) {
9503  "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9504  (unsigned) ie_len);
9505  break;
9506  }
9507  redirecting->to.subaddress.odd_even_indicator = data[pos];
9508  break;
9510  if (ie_len != 1) {
9511  ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9512  (unsigned) ie_len);
9513  break;
9514  }
9515  redirecting->to.subaddress.valid = data[pos];
9516  break;
9517 /* Redirecting-to party id tag */
9519  ast_free(redirecting->to.tag);
9520  redirecting->to.tag = ast_malloc(ie_len + 1);
9521  if (redirecting->to.tag) {
9522  memcpy(redirecting->to.tag, data + pos, ie_len);
9523  redirecting->to.tag[ie_len] = 0;
9524  }
9525  break;
9526 /* Redirecting reason */
9528  if (ie_len != sizeof(value)) {
9529  ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
9530  (unsigned) ie_len);
9531  break;
9532  }
9533  memcpy(&value, data + pos, sizeof(value));
9534  redirecting->reason = ntohl(value);
9535  break;
9536 /* Redirecting count */
9537  case AST_REDIRECTING_COUNT:
9538  if (ie_len != sizeof(value)) {
9539  ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
9540  (unsigned) ie_len);
9541  break;
9542  }
9543  memcpy(&value, data + pos, sizeof(value));
9544  redirecting->count = ntohl(value);
9545  break;
9546 /* Redirecting unknown element */
9547  default:
9548  ast_log(LOG_DEBUG, "Unknown redirecting element: %u (%u)\n",
9549  (unsigned) ie_id, (unsigned) ie_len);
9550  break;
9551  }
9552  }
9553 
9554  switch (frame_version) {
9555  case 1:
9556  /*
9557  * The other end is an earlier version that we need to adjust
9558  * for compatibility.
9559  */
9560  redirecting->from.name.valid = 1;
9562  redirecting->from.number.valid = 1;
9563  if (got_from_combined_presentation) {
9564  redirecting->from.name.presentation = from_combined_presentation;
9565  redirecting->from.number.presentation = from_combined_presentation;
9566  }
9567 
9568  redirecting->to.name.valid = 1;
9570  redirecting->to.number.valid = 1;
9571  if (got_to_combined_presentation) {
9572  redirecting->to.name.presentation = to_combined_presentation;
9573  redirecting->to.number.presentation = to_combined_presentation;
9574  }
9575  break;
9576  case 2:
9577  /* The other end is at the same level as we are. */
9578  break;
9579  default:
9580  /*
9581  * The other end is newer than we are.
9582  * We need to assume that they are compatible with us.
9583  */
9584  ast_log(LOG_DEBUG, "Redirecting frame has newer version: %u\n",
9585  (unsigned) frame_version);
9586  break;
9587  }
9588 
9589  return 0;
9590 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
#define LOG_WARNING
Definition: logger.h:144
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
int value
Definition: syslog.c:39
#define LOG_DEBUG
Definition: logger.h:122
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
int type
Q.931 subaddress type.
Definition: channel.h:270
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
#define ast_malloc(a)
Definition: astmm.h:91
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
struct ast_channel* ast_request ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
int *  status 
)

Requests a channel.

Parameters
typetype of channel to request
formatrequested channel format (codec)
requestorchannel asking for data
datadata to pass to the channel requester (Should be treated as const char *)
statusstatus

Request a channel of a given type, with data as optional information used by the low level module

Return values
NULLfailure
non-NULLchannel on success

Definition at line 5695 of file channel.c.

References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, ast_channel_release(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_TEXT_MASK, AST_FORMAT_VIDEO_MASK, ast_getformatname_multiple(), ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_translator_best_choice(), capabilities, ast_channel_tech::capabilities, chanlist::chan, LOG_WARNING, ast_channel_tech::requester, set_security_requirements(), chanlist::tech, and ast_channel_tech::type.

Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), build_conf(), chanavail_exec(), conf_run(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), meetme_menu_admin_extended(), play_sound_file(), ring_entry(), and wait_for_answer().

5696 {
5697  struct chanlist *chan;
5698  struct ast_channel *c;
5700  format_t fmt;
5701  int res;
5702  int foo;
5703  format_t videoformat = format & AST_FORMAT_VIDEO_MASK;
5704  format_t textformat = format & AST_FORMAT_TEXT_MASK;
5705 
5706  if (!cause)
5707  cause = &foo;
5708  *cause = AST_CAUSE_NOTDEFINED;
5709 
5710  if (AST_RWLIST_RDLOCK(&backends)) {
5711  ast_log(LOG_WARNING, "Unable to lock technology backend list\n");
5712  return NULL;
5713  }
5714 
5715  AST_RWLIST_TRAVERSE(&backends, chan, list) {
5716  if (strcasecmp(type, chan->tech->type))
5717  continue;
5718 
5719  capabilities = chan->tech->capabilities;
5720  fmt = format & AST_FORMAT_AUDIO_MASK;
5721  if (fmt) {
5722  /* We have audio - is it possible to connect the various calls to each other?
5723  (Avoid this check for calls without audio, like text+video calls)
5724  */
5725  res = ast_translator_best_choice(&fmt, &capabilities);
5726  if (res < 0) {
5727  char tmp1[256], tmp2[256];
5728  ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
5729  ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities),
5730  ast_getformatname_multiple(tmp2, sizeof(tmp2), format));
5733  return NULL;
5734  }
5735  }
5737  if (!chan->tech->requester)
5738  return NULL;
5739 
5740  if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, requestor, data, cause)))
5741  return NULL;
5742 
5743  if (set_security_requirements(requestor, c)) {
5744  ast_log(LOG_WARNING, "Setting security requirements failed\n");
5745  c = ast_channel_release(c);
5747  return NULL;
5748  }
5749 
5750  /* no need to generate a Newchannel event here; it is done in the channel_alloc call */
5751  return c;
5752  }
5753 
5754  ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
5755  *cause = AST_CAUSE_NOSUCHDRIVER;
5757 
5758  return NULL;
5759 }
Main Channel structure associated with a channel.
Definition: channel.h:742
const char *const type
Definition: channel.h:508
struct ast_channel *(*const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Requester - to set up call data structures (pvt&#39;s)
Definition: channel.h:519
format_t capabilities
Definition: channel.h:511
#define AST_CAUSE_NOSUCHDRIVER
Definition: causes.h:155
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1921
#define LOG_WARNING
Definition: logger.h:144
static struct aji_capabilities * capabilities
Definition: res_jabber.c:393
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const char * data
Definition: channel.h:755
the list of registered channel types
Definition: channel.c:143
static int set_security_requirements(const struct ast_channel *requestor, struct ast_channel *out)
Definition: channel.c:5655
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_FORMAT_TEXT_MASK
Definition: frame.h:297
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
#define AST_CAUSE_NOTDEFINED
Definition: causes.h:154
int64_t format_t
Definition: frame_defs.h:32
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_FORMAT_VIDEO_MASK
Definition: frame.h:290
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
static const char type[]
Definition: chan_nbs.c:57
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Definition: causes.h:129
static snd_pcm_format_t format
Definition: chan_alsa.c:93
format_t ast_translator_best_choice(format_t *dsts, format_t *srcs)
Chooses the best translation path.
Definition: translate.c:984
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.

Parameters
typetype of channel to request
formatrequested channel format
requestorchannel asking for data
datadata to pass to the channel requester
timeoutmaximum amount of time to wait for an answer
reasonwhy unsuccessful (if unsuccessful)
cid_numCaller-ID Number
cid_nameCaller-ID Name (ascii)
Returns
Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state to know if the call was answered or not.

Definition at line 5650 of file channel.c.

References __ast_request_and_dial().

Referenced by ast_pbx_outgoing_exten(), and generic_recall().

5651 {
5652  return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL);
5653 }
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...
Definition: channel.c:5456
const char * data
Definition: channel.h:755
static const char type[]
Definition: chan_nbs.c:57
static snd_pcm_format_t format
Definition: chan_alsa.c:93
int ast_safe_sleep ( struct ast_channel chan,
int  ms 
)

Wait for a specified amount of time, looking for hangups.

Parameters
chanchannel to wait for
mslength of time in milliseconds to sleep. This should never be less than zero.

Waits for a specified amount of time, servicing the channel as required.

Returns
returns -1 on hangup, otherwise 0.

Wait for a specified amount of time, looking for hangups.

Definition at line 1916 of file channel.c.

References ast_safe_sleep_conditional().

Referenced by __analog_ss_thread(), adsi_transmit_message_full(), alarmreceiver_exec(), analog_ss_thread(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), builtin_parkcall(), conf_run(), dahdi_send_callrerouting_facility_exec(), dial_trunk(), dictate_exec(), disa_exec(), flash_exec(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), pbx_builtin_wait(), play_moh_exec(), playtone(), privacy_exec(), receive_ademco_contact_id(), skinny_ss(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().

1917 {
1918  return ast_safe_sleep_conditional(chan, ms, NULL, NULL);
1919 }
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.
Definition: channel.c:1845
int ast_safe_sleep_conditional ( struct ast_channel chan,
int  timeout_ms,
int(*)(void *)  cond,
void *  data 
)

Wait for a specified amount of time, looking for hangups and a condition argument.

Parameters
chanchannel to wait for
mslength of time in milliseconds to sleep.
conda function pointer for testing continue condition
dataargument to be passed to the condition test function
Returns
returns -1 on hangup, otherwise 0.

Waits for a specified amount of time, servicing the channel as required. If cond returns 0, this function returns.

Wait for a specified amount of time, looking for hangups and a condition argument.

Definition at line 1845 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_remaining_ms(), ast_tvnow(), ast_waitfor(), cond, f, and ast_channel::generatordata.

Referenced by ast_safe_sleep(), and login_exec().

1846 {
1847  struct ast_frame *f;
1848  struct ast_silence_generator *silgen = NULL;
1849  int res = 0;
1850  struct timeval start;
1851  int ms;
1852  AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
1853 
1854  AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
1855 
1856  /* If no other generator is present, start silencegen while waiting */
1857  if (ast_opt_transmit_silence && !chan->generatordata) {
1858  silgen = ast_channel_start_silence_generator(chan);
1859  }
1860 
1861  start = ast_tvnow();
1862  while ((ms = ast_remaining_ms(start, timeout_ms))) {
1863  struct ast_frame *dup_f = NULL;
1864 
1865  if (cond && ((*cond)(data) == 0)) {
1866  break;
1867  }
1868  ms = ast_waitfor(chan, ms);
1869  if (ms < 0) {
1870  res = -1;
1871  break;
1872  }
1873  if (ms > 0) {
1874  f = ast_read(chan);
1875  if (!f) {
1876  res = -1;
1877  break;
1878  }
1879 
1880  if (!ast_is_deferrable_frame(f)) {
1881  ast_frfree(f);
1882  continue;
1883  }
1884 
1885  if ((dup_f = ast_frisolate(f))) {
1886  if (dup_f != f) {
1887  ast_frfree(f);
1888  }
1889  AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list);
1890  }
1891  }
1892  }
1893 
1894  /* stop silgen if present */
1895  if (silgen) {
1896  ast_channel_stop_silence_generator(chan, silgen);
1897  }
1898 
1899  /* We need to free all the deferred frames, but we only need to
1900  * queue the deferred frames if there was no error and no
1901  * hangup was received
1902  */
1903  ast_channel_lock(chan);
1904  while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
1905  if (!res) {
1906  ast_queue_frame_head(chan, f);
1907  }
1908  ast_frfree(f);
1909  }
1910  ast_channel_unlock(chan);
1911 
1912  return res;
1913 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_opt_transmit_silence
Definition: options.h:120
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
ast_cond_t cond
Definition: app_meetme.c:963
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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.
Definition: channel.c:8355
static struct ast_format f[]
Definition: format_g726.c:181
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition: channel.c:1818
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_frfree(fr)
Definition: frame.h:583
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
union ast_frame::@172 data
int ast_senddigit ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
durationthe duration of the digit ending in ms
Returns
0 on success, -1 on failure

Definition at line 4774 of file channel.c.

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), ast_channel_tech::send_digit_begin, and ast_channel::tech.

Referenced by ast_dtmf_stream(), dial_exec_full(), and manager_play_dtmf().

4775 {
4776  if (chan->tech->send_digit_begin) {
4777  ast_senddigit_begin(chan, digit);
4779  }
4780 
4781  return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
4782 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1916
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:111
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4705
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4755
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_senddigit_begin ( struct ast_channel chan,
char  digit 
)

Send a DTMF digit to a channel.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
Returns
0 on success, -1 on failure

Definition at line 4705 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_debug, ast_playtones_start(), ast_tvnow(), ast_channel::name, ast_channel_tech::send_digit_begin, ast_channel::sending_dtmf_digit, ast_channel::sending_dtmf_tv, and ast_channel::tech.

Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().

4706 {
4707  /* Device does not support DTMF tones, lets fake
4708  * it by doing our own generation. */
4709  static const char * const dtmf_tones[] = {
4710  "941+1336", /* 0 */
4711  "697+1209", /* 1 */
4712  "697+1336", /* 2 */
4713  "697+1477", /* 3 */
4714  "770+1209", /* 4 */
4715  "770+1336", /* 5 */
4716  "770+1477", /* 6 */
4717  "852+1209", /* 7 */
4718  "852+1336", /* 8 */
4719  "852+1477", /* 9 */
4720  "697+1633", /* A */
4721  "770+1633", /* B */
4722  "852+1633", /* C */
4723  "941+1633", /* D */
4724  "941+1209", /* * */
4725  "941+1477" /* # */
4726  };
4727 
4728  if (!chan->tech->send_digit_begin)
4729  return 0;
4730 
4731  ast_channel_lock(chan);
4732  chan->sending_dtmf_digit = digit;
4733  chan->sending_dtmf_tv = ast_tvnow();
4734  ast_channel_unlock(chan);
4735 
4736  if (!chan->tech->send_digit_begin(chan, digit))
4737  return 0;
4738 
4739  if (digit >= '0' && digit <='9')
4740  ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4741  else if (digit >= 'A' && digit <= 'D')
4742  ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4743  else if (digit == '*')
4744  ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4745  else if (digit == '#')
4746  ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4747  else {
4748  /* not handled */
4749  ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
4750  }
4751 
4752  return 0;
4753 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
char sending_dtmf_digit
Definition: channel.h:873
struct timeval sending_dtmf_tv
Definition: channel.h:874
const ast_string_field name
Definition: channel.h:787
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:319
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_senddigit_end ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
durationthe duration of the digit ending in ms
Returns
Returns 0 on success, -1 on failure

Definition at line 4755 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_playtones_stop(), ast_channel::generator, ast_channel_tech::send_digit_end, ast_channel::sending_dtmf_digit, and ast_channel::tech.

Referenced by agent_digit_end(), ast_bridge_end_dtmf(), ast_senddigit(), and ast_write().

4756 {
4757  int res = -1;
4758 
4759  ast_channel_lock(chan);
4760  if (chan->sending_dtmf_digit == digit) {
4761  chan->sending_dtmf_digit = 0;
4762  }
4763  ast_channel_unlock(chan);
4764 
4765  if (chan->tech->send_digit_end)
4766  res = chan->tech->send_digit_end(chan, digit, duration);
4767 
4768  if (res && chan->generator)
4769  ast_playtones_stop(chan);
4770 
4771  return 0;
4772 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_generator * generator
Definition: channel.h:747
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:535
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:411
char sending_dtmf_digit
Definition: channel.h:873
#define ast_channel_unlock(chan)
Definition: channel.h:2467
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_sendtext ( struct ast_channel chan,
const char *  text 
)

Sends text to a channel.

Parameters
chanchannel to act upon
textstring of text to send on the channel

Write text to a display on a channel

Note
The channel does not need to be locked before calling this function.
Return values
0on success
-1on failure

Definition at line 4687 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_test_flag, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.

Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), and sendtext_exec().

4688 {
4689  int res = 0;
4690 
4691  ast_channel_lock(chan);
4692  /* Stop if we're a zombie or need a soft hangup */
4693  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
4694  ast_channel_unlock(chan);
4695  return -1;
4696  }
4697  CHECK_BLOCKING(chan);
4698  if (chan->tech->send_text)
4699  res = chan->tech->send_text(chan, text);
4701  ast_channel_unlock(chan);
4702  return res;
4703 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
char * text
Definition: app_queue.c:1091
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
struct ast_channel_tech * tech
Definition: channel.h:743
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.

Note
Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
The channel does not need to be locked before calling this function.

Definition at line 7051 of file channel.c.

References ast_party_caller::ani, ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_free, ast_strdup, ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.

Referenced by __analog_ss_thread(), __ast_request_and_dial(), analog_ss_thread(), cb_events(), disa_exec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), privacy_exec(), ring_entry(), skinny_newcall(), and socket_process().

7052 {
7053  ast_channel_lock(chan);
7054 
7055  if (cid_num) {
7056  chan->caller.id.number.valid = 1;
7057  ast_free(chan->caller.id.number.str);
7058  chan->caller.id.number.str = ast_strdup(cid_num);
7059  }
7060  if (cid_name) {
7061  chan->caller.id.name.valid = 1;
7062  ast_free(chan->caller.id.name.str);
7063  chan->caller.id.name.str = ast_strdup(cid_name);
7064  }
7065  if (cid_ani) {
7066  chan->caller.ani.number.valid = 1;
7067  ast_free(chan->caller.ani.number.str);
7068  chan->caller.ani.number.str = ast_strdup(cid_ani);
7069  }
7070  if (chan->cdr) {
7071  ast_cdr_setcid(chan->cdr, chan);
7072  }
7073 
7074  report_new_callerid(chan);
7075 
7076  ast_channel_unlock(chan);
7077 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_cdr * cdr
Definition: channel.h:766
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:883
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_free(a)
Definition: astmm.h:97
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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.

Parameters
chanchannel to set the field on
sourcea string describing the source of the hangup for this channel
force
Note
Absolutely NO channel locks should be held before calling this function.
Since
1.8

Hangupsource is generally the channel name that caused the bridge to be hung up, but it can also be other things such as "dialplan/agi" This can then be logged in the CDR or CEL

Definition at line 2769 of file channel.c.

References ast_bridged_channel(), ast_channel_lock, ast_channel_ref, ast_channel_unlock, ast_channel_unref, ast_string_field_set, ast_strlen_zero(), ast_channel::bridge, and ast_channel::hangupsource.

Referenced by __dahdi_exception(), analog_exception(), func_channel_write_real(), handle_hangup(), pbx_builtin_hangup(), set_hangup_source_and_cause(), and sip_queue_hangup_cause().

2770 {
2771  struct ast_channel *bridge;
2772 
2773  ast_channel_lock(chan);
2774  if (force || ast_strlen_zero(chan->hangupsource)) {
2775  ast_string_field_set(chan, hangupsource, source);
2776  }
2777  bridge = ast_bridged_channel(chan);
2778  if (bridge) {
2779  ast_channel_ref(bridge);
2780  }
2781  ast_channel_unlock(chan);
2782 
2783  if (bridge) {
2784  ast_channel_lock(bridge);
2785  if (force || ast_strlen_zero(bridge->hangupsource)) {
2786  ast_string_field_set(bridge, hangupsource, source);
2787  }
2788  ast_channel_unlock(bridge);
2789  ast_channel_unref(bridge);
2790  }
2791 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field hangupsource
Definition: channel.h:787
struct ast_bridge * bridge
Definition: channel.h:865
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2491
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
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.

Parameters
chanchannel to change
formatformat to change to
Returns
Returns 0 on success, -1 on failure

Definition at line 5301 of file channel.c.

References ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().

Referenced by __ast_play_and_record(), __oh323_update_info(), adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_do_masquerade(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), build_conf(), conf_run(), 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(), meetme_menu_admin_extended(), mgcp_rtp_read(), oh323_rtp_read(), old_milliwatt_exec(), process_sdp(), record_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().

5302 {
5303  return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
5304  &chan->readtrans, 0);
5305 }
static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction)
Definition: channel.c:5218
format_t rawreadformat
Definition: channel.h:855
format_t readformat
Definition: channel.h:853
struct ast_trans_pvt * readtrans
Definition: channel.h:763
void ast_set_variables ( struct ast_channel chan,
struct ast_variable vars 
)

adds a list of channel variables to a channel

Parameters
chanthe channel
varsa linked list of variables

Variable names can be for a regular channel variable or a dialplan function that has the ability to be written to.

Definition at line 8261 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().

8262 {
8263  struct ast_variable *cur;
8264 
8265  for (cur = vars; cur; cur = cur->next)
8266  pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8267 }
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
Definition: pbx.c:10546
struct ast_variable * next
Definition: config.h:82
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.

Parameters
chanchannel to change
formatnew format for writing
Returns
Returns 0 on success, -1 on failure

Definition at line 5307 of file channel.c.

References ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.

Referenced by __oh323_update_info(), adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_stopstream(), ast_write(), bridge_channel_join(), bridge_make_compatible(), build_conf(), chanspy_exec(), conf_run(), dahdiscan_exec(), echo_exec(), extenspy_exec(), generic_fax_exec(), gtalk_rtp_read(), jack_exec(), jingle_rtp_read(), linear_alloc(), linear_release(), login_exec(), meetme_menu_admin_extended(), 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(), 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().

5308 {
5309  return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
5310  &chan->writetrans, 1);
5311 }
format_t writeformat
Definition: channel.h:854
static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction)
Definition: channel.c:5218
format_t rawwriteformat
Definition: channel.h:856
struct ast_trans_pvt * writetrans
Definition: channel.h:762
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.

Parameters
cchannel
ratenumber of timer ticks per second
funccallback function
data

If timers are supported, force a scheduled expiration on the timer fd, at which point we call the callback function / data

Note
Call this function with a rate of 0 to turn off the timer ticks
Version
1.6.1 changed samples parameter to rate, accomodates new timing methods

Definition at line 3557 of file channel.c.

References ast_settimeout_full().

Referenced by ast_activate_generator(), ast_readaudio_callback(), deactivate_generator_nolock(), and filestream_close().

3558 {
3559  return ast_settimeout_full(c, rate, func, data, 0);
3560 }
int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
Definition: channel.c:3562
int ast_settimeout_full ( struct ast_channel c,
unsigned int  rate,
int(*)(const void *data)  func,
void *  data,
unsigned int  is_ao2_obj 
)

Definition at line 3562 of file channel.c.

References ao2_ref, ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_debug, AST_FLAG_TIMINGDATA_IS_AO2_OBJ, ast_set_flag, ast_test_flag, ast_timer_get_max_rate(), ast_timer_set_rate(), AST_TIMING_FD, ast_channel::data, ast_channel::fdno, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.

Referenced by ast_readaudio_callback(), and ast_settimeout().

3563 {
3564  int res;
3565  unsigned int real_rate = rate, max_rate;
3566 
3567  ast_channel_lock(c);
3568 
3569  if (c->timingfd == -1) {
3570  ast_channel_unlock(c);
3571  return -1;
3572  }
3573 
3574  if (!func) {
3575  rate = 0;
3576  data = NULL;
3577  }
3578 
3579  if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
3580  real_rate = max_rate;
3581  }
3582 
3583  ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3584 
3585  res = ast_timer_set_rate(c->timer, real_rate);
3586 
3588  ao2_ref(c->timingdata, -1);
3589  }
3590 
3591  c->timingfunc = func;
3592  c->timingdata = data;
3593 
3594  if (data && is_ao2_obj) {
3595  ao2_ref(data, 1);
3597  } else {
3599  }
3600 
3601  if (func == NULL && rate == 0 && c->fdno == AST_TIMING_FD) {
3602  /* Clearing the timing func and setting the rate to 0
3603  * means that we don't want to be reading from the timingfd
3604  * any more. Setting c->fdno to -1 means we won't have any
3605  * errant reads from the timingfd, meaning we won't potentially
3606  * miss any important frames.
3607  */
3608  c->fdno = -1;
3609  }
3610 
3611  ast_channel_unlock(c);
3612 
3613  return res;
3614 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Definition: timing.c:208
int timingfd
Definition: channel.h:838
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
struct ast_timer * timer
Definition: channel.h:866
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ao2_ref(o, delta)
Definition: astobj2.h:472
int(* timingfunc)(const void *data)
Definition: channel.h:759
#define AST_TIMING_FD
Definition: channel.h:164
void * timingdata
Definition: channel.h:760
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:163
#define ast_clear_flag(p, flag)
Definition: utils.h:77
int ast_shutting_down ( void  )

Returns non-zero if Asterisk is being shut down.

Returns
non-zero if Asterisk is being shut down

Definition at line 865 of file channel.c.

References shutting_down.

Referenced by handle_request_options().

866 {
867  return shutting_down;
868 }
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel.

Parameters
chanchannel to be soft-hung-up
reasonan AST_SOFTHANGUP_* reason code

Call the protocol layer, but don't destroy the channel structure (use this if you are trying to safely hangup a channel managed by another thread.

Note
The channel passed to this function does not need to be locked.
Returns
Returns 0 regardless

Softly hangup up a channel.

Definition at line 2746 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and ast_softhangup_nolock().

Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), agent_hangup(), agent_logoff(), agent_read(), ast_bridge_call(), ast_channel_softhangup_cb(), ast_dial_join(), cc_generic_agent_stop_ringing(), conf_free(), dahdi_handle_event(), handle_hangup(), handle_softhangup(), login_exec(), manager_park(), mgcp_pktcgate_remove(), read_agent_config(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().

2747 {
2748  int res;
2749 
2750  ast_channel_lock(chan);
2751  res = ast_softhangup_nolock(chan, cause);
2752  ast_channel_unlock(chan);
2753 
2754  return res;
2755 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2733
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_softhangup_nolock ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel (no channel lock)

Parameters
chanchannel to be soft-hung-up
reasonan AST_SOFTHANGUP_* reason code

Softly hangup up a channel (no channel lock)

Definition at line 2733 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, and ast_channel::name.

Referenced by __analog_handle_event(), action_hangup(), analog_attempt_transfer(), ast_async_goto(), ast_softhangup(), attempt_transfer(), check_pendings(), check_rtp_timeout(), dahdi_softhangup_all(), gosub_run(), oh323_indicate(), pri_dchannel(), proc_session_timer(), sig_pri_indicate(), sig_pri_send_aoce_termination_request(), sip_indicate(), and skinny_indicate().

2734 {
2735  ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
2736  /* Inform channel driver that we need to be hung up, if it cares */
2737  chan->_softhangup |= cause;
2739  /* Interrupt any poll call or such */
2740  if (ast_test_flag(chan, AST_FLAG_BLOCKING))
2741  pthread_kill(chan->blocker, SIGURG);
2742  return 0;
2743 }
struct ast_frame ast_null_frame
Definition: frame.c:131
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
const ast_string_field name
Definition: channel.h:787
int _softhangup
Definition: channel.h:832
pthread_t blocker
Definition: channel.h:790
const char* ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

Parameters
ast_channel_statestate to get the name of
Returns
the text form of the binary state given
Note
This function is not reentrant.

Definition at line 1007 of file channel.c.

References AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_threadstorage_get(), STATE2STR_BUFSIZE, and state2str_threadbuf.

Referenced by __ast_channel_alloc_ap(), action_coreshowchannels(), action_status(), agent_hangup(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_showchan(), local_attended_transfer(), mgcp_new(), serialize_showchan(), sip_hangup(), and update_connectedline().

1008 {
1009  char *buf;
1010 
1011  switch (state) {
1012  case AST_STATE_DOWN:
1013  return "Down";
1014  case AST_STATE_RESERVED:
1015  return "Rsrvd";
1016  case AST_STATE_OFFHOOK:
1017  return "OffHook";
1018  case AST_STATE_DIALING:
1019  return "Dialing";
1020  case AST_STATE_RING:
1021  return "Ring";
1022  case AST_STATE_RINGING:
1023  return "Ringing";
1024  case AST_STATE_UP:
1025  return "Up";
1026  case AST_STATE_BUSY:
1027  return "Busy";
1029  return "Dialing Offhook";
1030  case AST_STATE_PRERING:
1031  return "Pre-ring";
1032  default:
1034  return "Unknown";
1035  snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
1036  return buf;
1037  }
1038 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define STATE2STR_BUFSIZE
Definition: channel.c:107
static struct ast_threadstorage state2str_threadbuf
Definition: channel.c:106
int ast_str2cause ( const char *  name)

Convert the string form of a cause code to a number.

Parameters
namestring form of the cause
Returns
the cause code

Convert the string form of a cause code to a number.

Definition at line 993 of file channel.c.

References ARRAY_LEN, and causes.

Referenced by pbx_builtin_hangup().

994 {
995  int x;
996 
997  for (x = 0; x < ARRAY_LEN(causes); x++)
998  if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
999  return causes[x].cause;
1000 
1001  return -1;
1002 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct causes_map causes[]
Definition: channel.c:209
static const char name[]
int ast_tonepair ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Play a tone pair for a given amount of time

Definition at line 7969 of file channel.c.

References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), and ast_channel::generatordata.

Referenced by zapateller_exec().

7970 {
7971  int res;
7972 
7973  if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7974  return res;
7975 
7976  /* Give us some wiggle room */
7977  while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
7978  struct ast_frame *f = ast_read(chan);
7979  if (f)
7980  ast_frfree(f);
7981  else
7982  return -1;
7983  }
7984  return 0;
7985 }
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
static struct ast_format f[]
Definition: format_g726.c:181
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7951
#define ast_frfree(fr)
Definition: frame.h:583
void * generatordata
Definition: channel.h:746
int ast_tonepair_start ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Start a tone going

Definition at line 7951 of file channel.c.

References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.

Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), and sendnoise().

7952 {
7953  struct tonepair_def d = { 0, };
7954 
7955  d.freq1 = freq1;
7956  d.freq2 = freq2;
7957  d.duration = duration;
7958  d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7959  if (ast_activate_generator(chan, &tonepair, &d))
7960  return -1;
7961  return 0;
7962 }
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:3148
int duration
Definition: channel.c:7838
static struct ast_generator tonepair
Definition: channel.c:7945
void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7964 of file channel.c.

References ast_deactivate_generator().

Referenced by sendnoise().

7965 {
7967 }
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
int ast_transfer ( struct ast_channel chan,
char *  dest 
)

Transfer a channel (if supported).

Return values
-1on error
0if not supported
1if supported and requested
Parameters
chancurrent channel
destdestination extension for transfer

Transfer a channel (if supported).

Called by:

  • app_transfer
  • the manager interface

Definition at line 5788 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_CONTROL_TRANSFER, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_frfree, ast_read(), ast_test_flag, AST_TRANSFER_SUCCESS, ast_waitfor(), ast_frame::data, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, ast_frame::subclass, ast_channel::tech, and ast_channel_tech::transfer.

Referenced by transfer_exec().

5789 {
5790  int res = -1;
5791 
5792  /* Stop if we're a zombie or need a soft hangup */
5793  ast_channel_lock(chan);
5794  if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
5795  if (chan->tech->transfer) {
5796  res = chan->tech->transfer(chan, dest);
5797  if (!res)
5798  res = 1;
5799  } else
5800  res = 0;
5801  }
5802  ast_channel_unlock(chan);
5803 
5804  if (res <= 0) {
5805  return res;
5806  }
5807 
5808  for (;;) {
5809  struct ast_frame *fr;
5810 
5811  res = ast_waitfor(chan, -1);
5812 
5813  if (res < 0 || !(fr = ast_read(chan))) {
5814  res = -1;
5815  break;
5816  }
5817 
5819  enum ast_control_transfer *message = fr->data.ptr;
5820 
5821  if (*message == AST_TRANSFER_SUCCESS) {
5822  res = 1;
5823  } else {
5824  res = -1;
5825  }
5826 
5827  ast_frfree(fr);
5828  break;
5829  }
5830 
5831  ast_frfree(fr);
5832  }
5833 
5834  return res;
5835 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
ast_control_transfer
Definition: frame.h:422
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
char* ast_transfercapability2str ( int  transfercapability) const

Gives the string form of a given transfer capability.

Parameters
transfercapabilitytransfer capability to get the name of
Returns
the text form of the binary transfer capability

Definition at line 1041 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().

1042 {
1043  switch (transfercapability) {
1044  case AST_TRANS_CAP_SPEECH:
1045  return "SPEECH";
1046  case AST_TRANS_CAP_DIGITAL:
1047  return "DIGITAL";
1049  return "RESTRICTED_DIGITAL";
1051  return "3K1AUDIO";
1053  return "DIGITAL_W_TONES";
1054  case AST_TRANS_CAP_VIDEO:
1055  return "VIDEO";
1056  default:
1057  return "UNKNOWN";
1058  }
1059 }
#define AST_TRANS_CAP_DIGITAL_W_TONES
Definition: transcap.h:39
#define AST_TRANS_CAP_3_1K_AUDIO
Definition: transcap.h:37
#define AST_TRANS_CAP_VIDEO
Definition: transcap.h:40
#define AST_TRANS_CAP_RESTRICTED_DIGITAL
Definition: transcap.h:36
#define AST_TRANS_CAP_SPEECH
Definition: transcap.h:34
#define AST_TRANS_CAP_DIGITAL
Definition: transcap.h:35
int ast_undestroyed_channels ( void  )
Returns
the number of channels not yet destroyed

Definition at line 853 of file channel.c.

References ast_atomic_fetchadd_int().

Referenced by can_safely_quit().

854 {
856 }
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
Definition: lock.h:603
static int chancount
Definition: channel.c:102
int ast_waitfor ( struct ast_channel chan,
int  ms 
)

Wait for input on a channel.

Parameters
chanchannel to wait on
mslength of time to wait on the channel

Wait for input on a channel for a given # of milliseconds (<0 for indefinite).

Return values
<0 on failure
0if nothing ever arrived
the# of ms remaining otherwise

Definition at line 3539 of file channel.c.

References ast_waitfor_nandfds().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), analog_ss_thread(), ast_dtmf_stream(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), async_wait(), background_detect_exec(), channel_spy(), conf_flush(), dahdi_accept_r2_call_exec(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().

3540 {
3541  if (ms < 0) {
3542  do {
3543  ms = 100000;
3544  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3545  } while (!ms);
3546  } else {
3547  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3548  }
3549  return ms;
3550 }
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.
Definition: channel.c:3188
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.

Returns
Return channel with activity, or NULL if none has activity.
Parameters
chanan array of pointers to channels
nnumber of channels that are to be waited upon
mstime "ms" is modified in-place, if applicable

Definition at line 3534 of file channel.c.

References ast_waitfor_nandfds().

Referenced by ast_generic_bridge(), ast_udptl_bridge(), autoservice_run(), dahdi_bridge(), dial_exec_full(), feature_request_and_dial(), generic_thread_loop(), iax2_bridge(), local_bridge_loop(), misdn_bridge(), monitor_dial(), remote_bridge_loop(), wait_for_answer(), and wait_for_winner().

3535 {
3536  return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3537 }
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.
Definition: channel.c:3188
int ast_waitfor_n_fd ( int *  fds,
int  n,
int *  ms,
int *  exception 
)

Waits for input on an fd.

Note
This version works on fd's only. Be careful with it.

Waits for input on an fd.

Definition at line 3176 of file channel.c.

References ast_waitfor_nandfds().

Referenced by dundi_lookup_internal(), dundi_precache_internal(), and softmix_bridge_thread().

3177 {
3178  int winner = -1;
3179  ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
3180  return winner;
3181 }
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.
Definition: channel.c:3188
struct ast_channel* ast_waitfor_nandfds ( struct ast_channel **  c,
int  n,
int *  fds,
int  nfds,
int *  exception,
int *  outfd,
int *  ms 
)

Waits for activity on a group of channels.

Parameters
chanan array of pointers to channels
nnumber of channels that are to be waited upon
fdsan array of fds to wait upon
nfdsthe number of fds to wait upon
exceptionexception flag
outfdfd that had activity on it
mshow long the wait was

Big momma function here. Wait for activity on any of the n channels, or any of the nfds file descriptors.

Returns
Returns the channel with activity, or NULL on error or if an FD came first. If the FD came first, it will be returned in outfd, otherwise, outfd will be -1

Waits for activity on a group of channels.

Definition at line 3188 of file channel.c.

References ast_channel::_softhangup, ast_add_fd(), ast_alloca, ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_MAX_FDS, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), chanlist::chan, CHECK_BLOCKING, errno, ast_channel::fdno, and name.

Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), bridge_channel_join_multithreaded(), conf_run(), eivr_comm(), find_cache(), generic_fax_exec(), multiplexed_thread_function(), run_agi(), and waitstream_core().

3191 {
3192  struct timeval start = { 0 , 0 };
3193  struct pollfd *pfds = NULL;
3194  int res;
3195  long rms;
3196  int x, y, max;
3197  int sz;
3198  struct timeval now = { 0, 0 };
3199  struct timeval whentohangup = { 0, 0 }, diff;
3200  struct ast_channel *winner = NULL;
3201  struct fdmap {
3202  int chan;
3203  int fdno;
3204  } *fdmap = NULL;
3205 
3206  if (outfd)
3207  *outfd = -99999;
3208  if (exception)
3209  *exception = 0;
3210 
3211  if ((sz = n * AST_MAX_FDS + nfds)) {
3212  pfds = ast_alloca(sizeof(*pfds) * sz);
3213  fdmap = ast_alloca(sizeof(*fdmap) * sz);
3214  } else {
3215  /* nothing to allocate and no FDs to check */
3216  return NULL;
3217  }
3218 
3219  /* Perform any pending masquerades */
3220  for (x = 0; x < n; x++) {
3221  while (c[x]->masq) {
3222  ast_do_masquerade(c[x]);
3223  }
3224 
3225  ast_channel_lock(c[x]);
3226  if (!ast_tvzero(c[x]->whentohangup)) {
3227  if (ast_tvzero(whentohangup))
3228  now = ast_tvnow();
3229  diff = ast_tvsub(c[x]->whentohangup, now);
3230  if (diff.tv_sec < 0 || ast_tvzero(diff)) {
3231  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", c[x]->name);
3232  /* Should already be hungup */
3234  ast_channel_unlock(c[x]);
3235  return c[x];
3236  }
3237  if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
3238  whentohangup = diff;
3239  }
3240  ast_channel_unlock(c[x]);
3241  }
3242  /* Wait full interval */
3243  rms = *ms;
3244  /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3245  if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3246  rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3247  if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3248  rms = *ms;
3249  }
3250  } else if (!ast_tvzero(whentohangup) && rms < 0) {
3251  /* Tiny corner case... call would need to last >24 days */
3252  rms = INT_MAX;
3253  }
3254  /*
3255  * Build the pollfd array, putting the channels' fds first,
3256  * followed by individual fds. Order is important because
3257  * individual fd's must have priority over channel fds.
3258  */
3259  max = 0;
3260  for (x = 0; x < n; x++) {
3261  for (y = 0; y < AST_MAX_FDS; y++) {
3262  fdmap[max].fdno = y; /* fd y is linked to this pfds */
3263  fdmap[max].chan = x; /* channel x is linked to this pfds */
3264  max += ast_add_fd(&pfds[max], c[x]->fds[y]);
3265  }
3266  CHECK_BLOCKING(c[x]);
3267  }
3268  /* Add the individual fds */
3269  for (x = 0; x < nfds; x++) {
3270  fdmap[max].chan = -1;
3271  max += ast_add_fd(&pfds[max], fds[x]);
3272  }
3273 
3274  if (*ms > 0)
3275  start = ast_tvnow();
3276 
3277  if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3278  do {
3279  int kbrms = rms;
3280  if (kbrms > 600000)
3281  kbrms = 600000;
3282  res = ast_poll(pfds, max, kbrms);
3283  if (!res)
3284  rms -= kbrms;
3285  } while (!res && (rms > 0));
3286  } else {
3287  res = ast_poll(pfds, max, rms);
3288  }
3289  for (x = 0; x < n; x++)
3291  if (res < 0) { /* Simulate a timeout if we were interrupted */
3292  if (errno != EINTR)
3293  *ms = -1;
3294  return NULL;
3295  }
3296  if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3297  now = ast_tvnow();
3298  for (x = 0; x < n; x++) {
3299  if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) {
3300  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", c[x]->name);
3302  if (winner == NULL)
3303  winner = c[x];
3304  }
3305  }
3306  }
3307  if (res == 0) { /* no fd ready, reset timeout and done */
3308  *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3309  return winner;
3310  }
3311  /*
3312  * Then check if any channel or fd has a pending event.
3313  * Remember to check channels first and fds last, as they
3314  * must have priority on setting 'winner'
3315  */
3316  for (x = 0; x < max; x++) {
3317  res = pfds[x].revents;
3318  if (res == 0)
3319  continue;
3320  if (fdmap[x].chan >= 0) { /* this is a channel */
3321  winner = c[fdmap[x].chan]; /* override previous winners */
3322  if (res & POLLPRI)
3324  else
3326  winner->fdno = fdmap[x].fdno;
3327  } else { /* this is an fd */
3328  if (outfd)
3329  *outfd = pfds[x].fd;
3330  if (exception)
3331  *exception = (res & POLLPRI) ? -1 : 0;
3332  winner = NULL;
3333  }
3334  }
3335  if (*ms > 0) {
3336  *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3337  if (*ms < 0)
3338  *ms = 0;
3339  }
3340  return winner;
3341 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
#define ast_set_flag(p, flag)
Definition: utils.h:70
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition: channel.h:2390
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
#define ast_poll(a, b, c)
Definition: poll-compat.h:88
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
Definition: time.h:120
int _softhangup
Definition: channel.h:832
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
static const char name[]
#define AST_MAX_FDS
Definition: channel.h:158
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: utils.c:1601
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

Waits for a digit.

Parameters
cchannel to wait for a digit on
mshow many milliseconds to wait (<0 for indefinite).
Returns
Returns <0 on error, 0 on no entry, and the digit on success.

Definition at line 3552 of file channel.c.

References ast_waitfordigit_full().

Referenced by __analog_ss_thread(), _while_exec(), adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_print(), adsi_read_encoded_dtmf(), adsi_transmit_message_full(), advanced_options(), analog_my_getsigstr(), analog_ss_thread(), ast_app_dtget(), ast_control_streamfile(), ast_record_review(), bridge_channel_feature(), builtin_atxfer(), collect_digits(), common_exec(), cpeid_exec(), dialout(), directory_exec(), forward_message(), get_folder(), ivr_dispatch(), mgcp_ss(), my_getsigstr(), pbx_builtin_waitexten(), play_record_review(), pri_ss_thread(), read_exec(), read_newoption(), readexten_exec(), retrydial_exec(), select_item_menu(), select_item_pause(), select_item_seq(), sendnoise(), testclient_exec(), testserver_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().

3553 {
3554  return ast_waitfordigit_full(c, ms, -1, -1);
3555 }
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 mon...
Definition: channel.c:3616
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.

Parameters
cchannel to wait for a digit on
mshow many milliseconds to wait (<0 for indefinite).
audiofdaudio file descriptor to write to if audio frames are received
ctrlfdcontrol file descriptor to monitor for reading
Returns
Returns 1 if ctrlfd becomes available

Definition at line 3616 of file channel.c.

References ast_check_hangup(), ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_FLAG_END_DTMF_ONLY, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_VOICE, ast_frfree, ast_log(), ast_read(), ast_remaining_ms(), ast_set_flag, ast_test_flag, ast_tvnow(), ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::ptr, and ast_frame::subclass.

Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().

3617 {
3618  struct timeval start = ast_tvnow();
3619  int ms;
3620 
3621  /* Stop if we're a zombie or need a soft hangup */
3623  return -1;
3624 
3625  /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3627 
3628  /* Wait for a digit, no more than timeout_ms milliseconds total.
3629  * Or, wait indefinitely if timeout_ms is <0.
3630  */
3631  while ((ms = ast_remaining_ms(start, timeout_ms))) {
3632  struct ast_channel *rchan;
3633  int outfd = -1;
3634 
3635  errno = 0;
3636  /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3637  * it is unhelpful if it waited less than a millisecond.
3638  */
3639  rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3640 
3641  if (!rchan && outfd < 0 && ms) {
3642  if (errno == 0 || errno == EINTR)
3643  continue;
3644  ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3646  return -1;
3647  } else if (outfd > -1) {
3648  /* The FD we were watching has something waiting */
3649  ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3651  return 1;
3652  } else if (rchan) {
3653  int res;
3654  struct ast_frame *f = ast_read(c);
3655  if (!f)
3656  return -1;
3657 
3658  switch (f->frametype) {
3659  case AST_FRAME_DTMF_BEGIN:
3660  break;
3661  case AST_FRAME_DTMF_END:
3662  res = f->subclass.integer;
3663  ast_frfree(f);
3665  return res;
3666  case AST_FRAME_CONTROL:
3667  switch (f->subclass.integer) {
3668  case AST_CONTROL_HANGUP:
3669  ast_frfree(f);
3671  return -1;
3672  case AST_CONTROL_RINGING:
3673  case AST_CONTROL_ANSWER:
3674  case AST_CONTROL_SRCUPDATE:
3675  case AST_CONTROL_SRCCHANGE:
3679  case AST_CONTROL_HOLD:
3680  case AST_CONTROL_UNHOLD:
3681  case -1:
3682  /* Unimportant */
3683  break;
3684  default:
3685  ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3686  break;
3687  }
3688  break;
3689  case AST_FRAME_VOICE:
3690  /* Write audio if appropriate */
3691  if (audiofd > -1) {
3692  if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3693  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3694  }
3695  }
3696  default:
3697  /* Ignore */
3698  break;
3699  }
3700  ast_frfree(f);
3701  }
3702  }
3703 
3705 
3706  return 0; /* Time is up */
3707 }
union ast_frame_subclass subclass
Definition: frame.h:146
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
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.
Definition: channel.c:3188
int datalen
Definition: frame.h:148
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
static struct ast_format f[]
Definition: format_g726.c:181
#define ast_clear_flag(p, flag)
Definition: utils.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
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.

Parameters
chandestination channel of the frame
frameframe that will be written
Returns
It returns 0 on success, -1 on failure.
Todo:
XXX should return 0 maybe ?

Definition at line 4916 of file channel.c.

References ast_channel::_softhangup, apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, AST_FORMAT_AUDIO_MASK, ast_format_rate(), AST_FORMAT_SLINEAR, AST_FORMAT_T140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate(), ast_getformatname(), ast_getformatname_multiple(), AST_LIST_NEXT, ast_log(), AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, calc_monitor_jump(), CHECK_BLOCKING, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, ast_filestream::fmt, ast_format::format, ast_channel::fout, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_channel::generatordata, ast_channel_tech::indicate, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, chanlist::next, ast_channel::outsmpl, ast_frame::ptr, ast_channel::rawwriteformat, ast_channel_monitor::read_stream, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel_tech::write, ast_channel_monitor::write_stream, ast_channel_tech::write_text, ast_channel_tech::write_video, ast_channel::writeformat, and ast_channel::writetrans.

Referenced by adsi_careful_send(), agent_write(), ast_bridge_call(), ast_generic_bridge(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), ast_udptl_bridge(), ast_write_video(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), feature_request_and_dial(), gen_generate(), generic_fax_exec(), handle_jack_audio(), iax2_bridge(), jb_get_and_deliver(), linear_generator(), local_bridge_loop(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), multiplexed_bridge_write(), NBScat_exec(), playtones_generator(), remote_bridge_loop(), send_tone_burst(), send_waveform_to_channel(), silence_generator_generate(), simple_bridge_write(), sms_generate(), softmix_bridge_poke(), softmix_bridge_write(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().

4917 {
4918  int res = -1;
4919  struct ast_frame *f = NULL;
4920  int count = 0;
4921 
4922  /*Deadlock avoidance*/
4923  while(ast_channel_trylock(chan)) {
4924  /*cannot goto done since the channel is not locked*/
4925  if(count++ > 10) {
4926  ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name);
4927  return 0;
4928  }
4929  usleep(1);
4930  }
4931  /* Stop if we're a zombie or need a soft hangup */
4932  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
4933  goto done;
4934 
4935  /* Handle any pending masquerades */
4936  while (chan->masq) {
4937  ast_channel_unlock(chan);
4938  ast_do_masquerade(chan);
4939  ast_channel_lock(chan);
4940  }
4941  if (chan->masqr) {
4942  res = 0; /* XXX explain, why 0 ? */
4943  goto done;
4944  }
4945 
4946  /* Perform the framehook write event here. After the frame enters the framehook list
4947  * there is no telling what will happen, how awesome is that!!! */
4948  if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) {
4949  res = 0;
4950  goto done;
4951  }
4952 
4953  if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
4954  if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
4956  } else {
4957  if (fr->frametype == AST_FRAME_DTMF_END) {
4958  /* There is a generator running while we're in the middle of a digit.
4959  * It's probably inband DTMF, so go ahead and pass it so it can
4960  * stop the generator */
4962  ast_channel_unlock(chan);
4963  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
4964  ast_channel_lock(chan);
4965  CHECK_BLOCKING(chan);
4966  } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
4967  /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
4968  res = (chan->tech->indicate == NULL) ? 0 :
4969  chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
4970  }
4971  res = 0; /* XXX explain, why 0 ? */
4972  goto done;
4973  }
4974  }
4975  /* High bit prints debugging */
4976  if (chan->fout & DEBUGCHAN_FLAG)
4977  ast_frame_dump(chan->name, fr, ">>");
4978  CHECK_BLOCKING(chan);
4979  switch (fr->frametype) {
4980  case AST_FRAME_CONTROL:
4981  res = (chan->tech->indicate == NULL) ? 0 :
4982  chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
4983  break;
4984  case AST_FRAME_DTMF_BEGIN:
4985  if (chan->audiohooks) {
4986  struct ast_frame *old_frame = fr;
4988  if (old_frame != fr)
4989  f = fr;
4990  }
4991  send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No");
4993  ast_channel_unlock(chan);
4994  res = ast_senddigit_begin(chan, fr->subclass.integer);
4995  ast_channel_lock(chan);
4996  CHECK_BLOCKING(chan);
4997  break;
4998  case AST_FRAME_DTMF_END:
4999  if (chan->audiohooks) {
5000  struct ast_frame *new_frame = fr;
5001 
5003  if (new_frame != fr) {
5004  ast_frfree(new_frame);
5005  }
5006  }
5007  send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes");
5009  ast_channel_unlock(chan);
5010  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5011  ast_channel_lock(chan);
5012  CHECK_BLOCKING(chan);
5013  break;
5014  case AST_FRAME_TEXT:
5015  if (fr->subclass.integer == AST_FORMAT_T140) {
5016  res = (chan->tech->write_text == NULL) ? 0 :
5017  chan->tech->write_text(chan, fr);
5018  } else {
5019  res = (chan->tech->send_text == NULL) ? 0 :
5020  chan->tech->send_text(chan, (char *) fr->data.ptr);
5021  }
5022  break;
5023  case AST_FRAME_HTML:
5024  res = (chan->tech->send_html == NULL) ? 0 :
5025  chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5026  break;
5027  case AST_FRAME_VIDEO:
5028  /* XXX Handle translation of video codecs one day XXX */
5029  res = (chan->tech->write_video == NULL) ? 0 :
5030  chan->tech->write_video(chan, fr);
5031  break;
5032  case AST_FRAME_MODEM:
5033  res = (chan->tech->write == NULL) ? 0 :
5034  chan->tech->write(chan, fr);
5035  break;
5036  case AST_FRAME_VOICE:
5037  if (chan->tech->write == NULL)
5038  break; /*! \todo XXX should return 0 maybe ? */
5039 
5040  if (ast_opt_generic_plc && fr->subclass.codec == AST_FORMAT_SLINEAR) {
5041  apply_plc(chan, fr);
5042  }
5043 
5044  /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5045  if (fr->subclass.codec == chan->rawwriteformat) {
5046  f = fr;
5047  } else {
5048  if ((!(fr->subclass.codec & chan->nativeformats)) && (chan->writeformat != fr->subclass.codec)) {
5049  char nf[512];
5050 
5051  /*
5052  * XXX Something is not right. We are not compatible with this
5053  * frame. Bad things can happen. Problems range from no audio,
5054  * one-way audio, to unexplained line hangups. As a last resort
5055  * try to adjust the format. Ideally, we do not want to do this
5056  * because it indicates a deeper problem. For now, we log these
5057  * events to reduce user impact and help identify the problem
5058  * areas.
5059  */
5060  ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
5061  chan->name, ast_getformatname(fr->subclass.codec), ast_getformatname(chan->writeformat),
5063  ast_set_write_format(chan, fr->subclass.codec);
5064  }
5065 
5066  f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
5067  }
5068 
5069  if (!f) {
5070  res = 0;
5071  break;
5072  }
5073 
5074  if (chan->audiohooks) {
5075  struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5076  int freeoldlist = 0;
5077 
5078  if (f != fr) {
5079  freeoldlist = 1;
5080  }
5081 
5082  /* Since ast_audiohook_write may return a new frame, and the cur frame is
5083  * an item in a list of frames, create a new list adding each cur frame back to it
5084  * regardless if the cur frame changes or not. */
5085  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5086  new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur);
5087 
5088  /* if this frame is different than cur, preserve the end of the list,
5089  * free the old frames, and set cur to be the new frame */
5090  if (new_frame != cur) {
5091 
5092  /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5093  * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5094  * times it may override the previous frame we got from it unless we dup it */
5095  if ((dup = ast_frisolate(new_frame))) {
5097  if (freeoldlist) {
5098  AST_LIST_NEXT(cur, frame_list) = NULL;
5099  ast_frfree(cur);
5100  }
5101  if (new_frame != dup) {
5102  ast_frfree(new_frame);
5103  }
5104  cur = dup;
5105  }
5106  }
5107 
5108  /* now, regardless if cur is new or not, add it to the new list,
5109  * if the new list has not started, cur will become the first item. */
5110  if (prev) {
5111  AST_LIST_NEXT(prev, frame_list) = cur;
5112  } else {
5113  f = cur; /* set f to be the beginning of our new list */
5114  }
5115  prev = cur;
5116  }
5117  }
5118 
5119  /* If Monitor is running on this channel, then we have to write frames out there too */
5120  /* the translator on chan->writetrans may have returned multiple frames
5121  from the single frame we passed in; if so, feed each one of them to the
5122  monitor */
5123  if (chan->monitor && chan->monitor->write_stream) {
5124  struct ast_frame *cur;
5125 
5126  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5127  /* XXX must explain this code */
5128 #ifndef MONITOR_CONSTANT_DELAY
5129  int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples;
5130  if (jump >= 0) {
5132  if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
5133  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5134  chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples;
5135  } else {
5136  chan->outsmpl += cur->samples;
5137  }
5138 #else
5140  if (jump - MONITOR_DELAY >= 0) {
5141  if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1)
5142  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5143  chan->outsmpl += chan->insmpl - chan->outsmpl;
5144  } else {
5145  chan->outsmpl += cur->samples;
5146  }
5147 #endif
5148  if (chan->monitor->state == AST_MONITOR_RUNNING) {
5149  if (ast_writestream(chan->monitor->write_stream, cur) < 0)
5150  ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
5151  }
5152  }
5153  }
5154 
5155  /* the translator on chan->writetrans may have returned multiple frames
5156  from the single frame we passed in; if so, feed each one of them to the
5157  channel, freeing each one after it has been written */
5158  if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5159  struct ast_frame *cur, *next;
5160  unsigned int skip = 0;
5161 
5162  for (cur = f, next = AST_LIST_NEXT(cur, frame_list);
5163  cur;
5164  cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) {
5165  if (!skip) {
5166  if ((res = chan->tech->write(chan, cur)) < 0) {
5168  skip = 1;
5169  } else if (next) {
5170  /* don't do this for the last frame in the list,
5171  as the code outside the loop will do it once
5172  */
5173  chan->fout = FRAMECOUNT_INC(chan->fout);
5174  }
5175  }
5176  ast_frfree(cur);
5177  }
5178 
5179  /* reset f so the code below doesn't attempt to free it */
5180  f = NULL;
5181  } else {
5182  res = chan->tech->write(chan, f);
5183  }
5184  break;
5185  case AST_FRAME_NULL:
5186  case AST_FRAME_IAX:
5187  /* Ignore these */
5188  res = 0;
5189  break;
5190  default:
5191  /* At this point, fr is the incoming frame and f is NULL. Channels do
5192  * not expect to get NULL as a frame pointer and will segfault. Hence,
5193  * we output the original frame passed in. */
5194  res = chan->tech->write(chan, fr);
5195  break;
5196  }
5197 
5198  if (f && f != fr)
5199  ast_frfree(f);
5201 
5202  /* Consider a write failure to force a soft hangup */
5203  if (res < 0) {
5205  } else {
5206  chan->fout = FRAMECOUNT_INC(chan->fout);
5207  }
5208 done:
5210  /* The list gets recreated if audiohooks are added again later */
5212  chan->audiohooks = NULL;
5213  }
5214  ast_channel_unlock(chan);
5215  return res;
5216 }
union ast_frame_subclass subclass
Definition: frame.h:146
struct ast_channel * masqr
Definition: channel.h:752
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_channel * masq
Definition: channel.h:751
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: frame.c:778
#define DEBUGCHAN_FLAG
Definition: channel.h:648
format_t writeformat
Definition: channel.h:854
static int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
calculates the number of samples to jump forward with in a monitor stream.
Definition: channel.c:3823
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
determines if a audiohook_list is empty or not.
Definition: audiohook.c:744
#define LOG_WARNING
Definition: logger.h:144
unsigned int fout
Definition: channel.h:847
format_t rawwriteformat
Definition: channel.h:856
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
unsigned long outsmpl
Definition: channel.h:827
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
Definition: frame.h:809
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
Definition: translate.c:328
format_t nativeformats
Definition: channel.h:852
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
static void send_dtmf_event(struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end)
Definition: channel.c:3709
format_t codec
Definition: frame.h:137
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4705
const char * data
Definition: channel.h:755
format_t format
Definition: mod_format.h:47
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 &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4755
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:594
struct ast_format * fmt
Definition: mod_format.h:102
#define ast_opt_generic_plc
Definition: options.h:132
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition: channel.c:4890
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_trans_pvt * writetrans
Definition: channel.h:762
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
struct ast_frame * ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
Pass a frame off to be handled by the audiohook core.
Definition: audiohook.c:762
unsigned long insmpl
Definition: channel.h:826
struct ast_framehook_list * framehooks
Definition: channel.h:765
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:180
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
Definition: file.c:879
struct ast_filestream * read_stream
Definition: monitor.h:41
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
#define SEEK_FORCECUR
Definition: file.h:50
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
struct ast_filestream * write_stream
Definition: monitor.h:42
static struct ast_format f[]
Definition: format_g726.c:181
#define FRAMECOUNT_INC(x)
Definition: channel.h:651
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:554
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
#define AST_FORMAT_T140
Definition: frame.h:294
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
Definition: file.c:150
struct ast_frame * next
Definition: frame.h:164
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_channel_trylock(chan)
Definition: channel.h:2468
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel_monitor * monitor
Definition: channel.h:769
enum AST_MONITORING_STATE state
Definition: monitor.h:49
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:418
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition: channel.h:576
void * generatordata
Definition: channel.h:746
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
int samples
Definition: frame.h:150
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.

Parameters
chandestination channel of the frame
frameframe that will be written
Returns
It returns 1 on success, 0 if not implemented, and -1 on failure.
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.

Parameters
chandestination channel of the frame
frameframe that will be written
Returns
It returns 1 on success, 0 if not implemented, and -1 on failure.

Definition at line 4801 of file channel.c.

References ast_write(), ast_channel::tech, and ast_channel_tech::write_video.

4802 {
4803  int res;
4804  if (!chan->tech->write_video)
4805  return 0;
4806  res = ast_write(chan, fr);
4807  if (!res)
4808  res = 1;
4809  return res;
4810 }
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
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.
Definition: channel.c:4916
struct ast_channel_tech * tech
Definition: channel.h:743
const char* channelreloadreason2txt ( enum channelreloadreason  reason)

Convert enum channelreloadreason to text string for manager event.

Parameters
reasonThe reason for reload (manager, cli, start etc)

\ brief Convert channel reloadreason (ENUM) to text string for manager event

Definition at line 8372 of file channel.c.

References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.

Referenced by reload_config().

8373 {
8374  switch (reason) {
8375  case CHANNEL_MODULE_LOAD:
8376  return "LOAD (Channel module load)";
8377 
8378  case CHANNEL_MODULE_RELOAD:
8379  return "RELOAD (Channel module reload)";
8380 
8381  case CHANNEL_CLI_RELOAD:
8382  return "CLIRELOAD (Channel module reload by CLI command)";
8383 
8384  default:
8385  return "MANAGERRELOAD (Channel module reload by manager)";
8386  }
8387 };

Variable Documentation

struct ast_channel_tech ast_kill_tech

Kill the channel channel driver technology descriptor.

Kill the channel channel driver technology descriptor.

The purpose of this channel technology is to encourage the channel to hangup as quickly as possible.

Note
Used by DTMF atxfer and zombie channels.

Definition at line 668 of file channel.c.

Referenced by ast_do_masquerade().

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 104 of file channel.c.

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().

unsigned long global_fout

Definition at line 104 of file channel.c.

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().